local j=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local c=j:WaitForChild("\077\111\100\117\108\101\115")local L=require(c.src.utils.Logger)local b=require(c.src.utils.Dict)local f=require(c.src.utils.None)local function E(j,c)j=j or{}if c.type=="\105\110\105\116\105\097\108\105\122\101\080\108\097\121\101\114\073\110\118\101\110\116\111\114\121"then local L=j[c.playerId]if L~=nil then return j end return b.join(j,{[c.playerId]={}})elseif c.type=="\097\100\100\073\116\101\109\115\084\111\080\108\097\121\101\114\073\110\118\101\110\116\111\114\121"then local L=j[c.playerId]if L==nil then local L=("\078\111 \112\108\097\121\101\114 \119\105\116\104 \116\104\101 \073\068 \037\113"):format(tostring(c.playerId))warn(L)return j end return b.join(j,{[c.playerId]=b.join(L,c.items)})elseif c.type=="\114\101\109\111\118\101\073\116\101\109\070\114\111\109\080\108\097\121\101\114\073\110\118\101\110\116\111\114\121"then local L=j[c.playerId]if L==nil then local L=("\078\111 \112\108\097\121\101\114 \119\105\116\104 \116\104\101 \073\068 \037\113"):format(tostring(c.playerId))warn(L)return j end return b.join(j,{[c.playerId]=b.join(L,{[c.itemId]=f})})end return j end return E
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local logger = require(Modules.src.utils.Logger)

local Dict = require(Modules.src.utils.Dict)
local None = require(Modules.src.utils.None)

local function playerInventories(state, action)
	state = state or {}

	if action.type == 'initializePlayerInventory' then
		local existingPlayer = state[action.playerId]

		if existingPlayer ~= nil then
			return state
		end

		return Dict.join(state, {
			[action.playerId] = {},
		})
	elseif action.type == 'addItemsToPlayerInventory' then
		local inventory = state[action.playerId]

		if inventory == nil then
			local message = ('No player with the ID %q'):format(tostring(action.playerId))
			warn(message)

			return state
		end

		return Dict.join(state, { [action.playerId] = Dict.join(inventory, action.items) })
	elseif action.type == 'removeItemFromPlayerInventory' then
		local inventory = state[action.playerId]

		if inventory == nil then
			local message = ('No player with the ID %q'):format(tostring(action.playerId))
			warn(message)

			return state
		end

		return Dict.join(state, { [action.playerId] = Dict.join(inventory, { [action.itemId] = None }) })
	end

	return state
end

return playerInventories