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=((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 j=require(Q.Roact)local E=require(Q.RoactRodux)local x=require(Q.M)local F=require(R.Components.common.RoundButton)local J=require(R.Components.common.UIPadding)local S=require(R.Components.common.TextLabel)local k=require(R.getApiFromComponent)local i=require(Q.src.objects.InventoryObjects)local g=i.OBJECT_TYPES local X=j.createElement local L=j.PureComponent:extend("\069\113\117\105\112\083\116\097\116\117\115\067\101\108\108")function L.init(q)q.api=k(q)end function L.render(q)local Q=q.props local R=Q.playerSlotsCount local j=q.props.equippedItems local E=function()q.api:unequipAll()end local x=X(F,{Text="\085\110\101\113\117\105\112 \097\108\108",onClicked=E;Size=UDim2.new(.8,0,.35,0);AnchorPoint=Vector2.new(.5,1);Position=UDim2.new(.5,0,1,0)})local k=X(S,{Size=UDim2.new(1,0,.65,0);Position=UDim2.new(0,0,0,0),TextScaled=true,TextSize=30,AnchorPoint=Vector2.new(0,0);TextXAlignment=Enum.TextXAlignment.Center;TextYAlignment=Enum.TextYAlignment.Bottom,Text="\069\113\117\105\112\112\101\100 "..(#j..(" \047 "..R))},{UIPadding=X(J,{padding=10})})local i=X("\070\114\097\109\101",{BackgroundTransparency=1;AnchorPoint=Vector2.new(0,0),Size=UDim2.new(0,100,0,100);ZIndex=1},{k;x})return i end local h=(E.connect(function(q)local function Q(q)return q.type~=g.ROOM end local function R(q)return q.id,q end return{items=q.shop.items,equippedItems=q.player.equippedItems,isPlaying=q.player.isPlaying;playerSlotsCount=q.player.playerSlotsCount,isGhosting=q.player.isGhosting,inventory=x.map(x.filter(q.inventory,Q),R)}end))(L)return h
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 Roact = require(Modules.Roact)
local RoactRodux = require(Modules.RoactRodux)
local M = require(Modules.M)
local RoundButton = require(clientSrc.Components.common.RoundButton)
local UIPadding = require(clientSrc.Components.common.UIPadding)
local TextLabel = require(clientSrc.Components.common.TextLabel)

local getApiFromComponent = require(clientSrc.getApiFromComponent)

local InventoryObjects = require(Modules.src.objects.InventoryObjects)
local OBJECT_TYPES = InventoryObjects.OBJECT_TYPES

local createElement = Roact.createElement

local EquipStatusCell = Roact.PureComponent:extend('EquipStatusCell')

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

function EquipStatusCell:render()
	local props = self.props
	local playerSlotsCount = props.playerSlotsCount
	local equippedItems = self.props.equippedItems

	local unequipAll = function()
		self.api:unequipAll()
	end

	local unequipAllButton = createElement(RoundButton, {
		Text = 'Unequip all',
		onClicked = unequipAll,
		Size = UDim2.new(0.8, 0, 0.35, 0),
		AnchorPoint = Vector2.new(0.5, 1),
		Position = UDim2.new(0.5, 0, 1, 0),
	})

	local slotsCount = createElement(
		TextLabel,
		{
			Size = UDim2.new(1, 0, 0.65, 0),
			Position = UDim2.new(0, 0, 0, 0),
			TextScaled = true,
			TextSize = 30,
			AnchorPoint = Vector2.new(0, 0),
			TextXAlignment = Enum.TextXAlignment.Center,
			TextYAlignment = Enum.TextYAlignment.Bottom,
			Text = 'Equipped ' .. #equippedItems .. ' / ' .. playerSlotsCount,
		},
		{ UIPadding = createElement(UIPadding, { padding = 10 }) }
	)

	local closeButtonWithCount = createElement(
		'Frame',
		{
			BackgroundTransparency = 1,
			AnchorPoint = Vector2.new(0, 0),
			Size = UDim2.new(0, 100, 0, 100),
			ZIndex = 1,
		},
		{ slotsCount, unequipAllButton }
	)

	return closeButtonWithCount
end

local EquipStatusCellConnected = RoactRodux.connect(function(state)
	local function isVisible(item)
		return item.type ~= OBJECT_TYPES.ROOM
	end
	local function byId(item)
		return item.id, item
	end

	return {
		items = state.shop.items,
		equippedItems = state.player.equippedItems,
		isPlaying = state.player.isPlaying,
		playerSlotsCount = state.player.playerSlotsCount,
		isGhosting = state.player.isGhosting,
		inventory = M.map(M.filter(state.inventory, isVisible), byId),
	}
end)(EquipStatusCell)

return EquipStatusCellConnected