local q=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local Q=q:WaitForChild("\077\111\100\117\108\101\115")local R=require(Q.src.utils.Logger)local j=((game:GetService("\083\116\097\114\116\101\114\080\108\097\121\101\114")):WaitForChild("\083\116\097\114\116\101\114\080\108\097\121\101\114\083\099\114\105\112\116\115")).clientSrc local E=require(Q.M)local x=require(j.getApiFromComponent)local F=require(j.Components.common.UICorner)local J=require(j.Components.common.Frame)local S=require(Q.Roact)local k=require(Q.RoactRodux)local i=require(j.Components.common.TextLabel)local g=require(j.Components.common.UIPadding)local X=require(j.Components.common.BillboardBuyButton)local L=S.createElement local h=S.PureComponent:extend("\082\111\111\109\076\111\099\107\083\099\114\101\101\110")local function v(q)return L(i,E.extend({},{LayoutOrder=1,Size=UDim2.new(.4,0,.4,0);TextScaled=true;TextSize=30;AnchorPoint=Vector2.new(.5,0),TextXAlignment=Enum.TextXAlignment.Center;TextYAlignment=Enum.TextYAlignment.Center,TextColor3=Color3.fromRGB(255,255,255),BackgroundTransparency=q.BackgroundTransparency or.7,BackgroundColor3=Color3.fromRGB(255,255,255);BorderColor3=Color3.fromRGB(255,255,255)},q))end function h.init(q)q.api=x(q)end function h.render(q)local Q=q.props local j=Q.isLockActive local E=q.props.lockPlaceholder:WaitForChild("\068\105\115\112\108\097\121")if not j then E.Transparency=1 E.CanCollide=false R:d("\082\101\109\111\118\105\110\103 \108\111\099\107")return end local x=Q.price local S=L(v,{LayoutOrder=1,Size=UDim2.new(.3,0,.3,0),Text=j and"\076\111\099\107\101\100"or"\079\112\101\110"},{UICorner=L(F),UIPadding=L(g,{padding=5})})local k=L(v,{LayoutOrder=2;Size=UDim2.new(.7,0,.2,0),Text="\085\110\108\111\099\107 \102\111\114\058"},{UICorner=L(F),UIPadding=L(g,{padding=5})})local i=L(v,{LayoutOrder=3;Size=UDim2.new(.7,0,.2,0),Text=tostring(x).." \099\111\105\110\115"},{UICorner=L(F),UIPadding=L(g,{padding=5})})local h=function()local Q=q.props.roomId q.api:buyItem(Q)end local b=L(X,{CFrame=E.CFrame;onClicked=h})return L(J,{Layout="\076\105\115\116",LayoutDirection="\086\101\114\116\105\099\097\108",HorizontalAlignment="\067\101\110\116\101\114";Padding=UDim.new(0,3);Size=UDim2.new(1,0,1,0);AnchorPoint=Vector2.new(0,0)},{lockedText=S,priceText=k,priceAmountText=i;buyButton=b})end local b=(k.connect(function(q,Q)local R=Q.roomId local j=q.rooms[R]local E=q.inventory[R]return{isLockActive=not E;price=j.price}end))(h)return b
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local logger = require(Modules.src.utils.Logger)
local clientSrc = game:GetService('StarterPlayer'):WaitForChild('StarterPlayerScripts').clientSrc
local M = require(Modules.M)
local getApiFromComponent = require(clientSrc.getApiFromComponent)

local UICorner = require(clientSrc.Components.common.UICorner)
local Frame = require(clientSrc.Components.common.Frame)
local Roact = require(Modules.Roact)
local RoactRodux = require(Modules.RoactRodux)
local TextLabel = require(clientSrc.Components.common.TextLabel)
local UIPadding = require(clientSrc.Components.common.UIPadding)
local BillboardBuyButton = require(clientSrc.Components.common.BillboardBuyButton)

local createElement = Roact.createElement
local RoomLockScreen = Roact.PureComponent:extend('RoomLockScreen')

local function StyledText(props)
	return createElement(
		TextLabel,
		M.extend(
			{},
			{
				LayoutOrder = 1,
				Size = UDim2.new(0.4, 0, 0.4, 0),
				TextScaled = true,
				TextSize = 30,
				AnchorPoint = Vector2.new(0.5, 0),
				TextXAlignment = Enum.TextXAlignment.Center,
				TextYAlignment = Enum.TextYAlignment.Center,
				TextColor3 = Color3.fromRGB(255, 255, 255),
				BackgroundTransparency = props.BackgroundTransparency or 0.7,
				BackgroundColor3 = Color3.fromRGB(255, 255, 255),
				BorderColor3 = Color3.fromRGB(255, 255, 255),
			},
			props
		)
	)
end

function RoomLockScreen:init()
	self.api = getApiFromComponent(self)
end

function RoomLockScreen:render()
	local props = self.props
	local isLockActive = props.isLockActive

	local display = self.props.lockPlaceholder:WaitForChild('Display')

	if not isLockActive then
		display.Transparency = 1
		display.CanCollide = false
		logger:d('Removing lock')

		return
	end

	local price = props.price

	local lockedText = createElement(
		StyledText,
		{
			LayoutOrder = 1,
			Size = UDim2.new(0.3, 0, 0.3, 0),
			Text = isLockActive and 'Locked' or 'Open',
		},
		{
			UICorner = createElement(UICorner),
			UIPadding = createElement(UIPadding, { padding = 5 }),
		}
	)
	local priceText = createElement(
		StyledText,
		{
			LayoutOrder = 2,
			Size = UDim2.new(0.7, 0, 0.2, 0),
			Text = 'Unlock for:',
		},
		{
			UICorner = createElement(UICorner),
			UIPadding = createElement(UIPadding, { padding = 5 }),
		}
	)
	local priceAmountText = createElement(
		StyledText,
		{
			LayoutOrder = 3,
			Size = UDim2.new(0.7, 0, 0.2, 0),
			Text = tostring(price) .. ' coins',
		},
		{
			UICorner = createElement(UICorner),
			UIPadding = createElement(UIPadding, { padding = 5 }),
		}
	)

	local onClicked = function()
		local itemId = self.props.roomId
		self.api:buyItem(itemId)
	end

	local buyButton = createElement(BillboardBuyButton, {
		CFrame = display.CFrame,
		onClicked = onClicked,
	})

	return createElement(
		Frame,
		{
			Layout = 'List',
			LayoutDirection = 'Vertical',
			HorizontalAlignment = 'Center',
			Padding = UDim.new(0, 3),
			Size = UDim2.new(1, 0, 1, 0),
			AnchorPoint = Vector2.new(0, 0),
		},
		{
			lockedText = lockedText,
			priceText = priceText,
			priceAmountText = priceAmountText,
			buyButton = buyButton,
		}
	)
end

local RoomLockScreenConnected = RoactRodux.connect(function(state, props)
	local roomId = props.roomId
	local room = state.rooms[roomId]
	local hasRoom = state.inventory[roomId]

	return {
		isLockActive = not hasRoom,
		price = room.price,
	}
end)(RoomLockScreen)

return RoomLockScreenConnected