local L=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local p=L:WaitForChild("\099\111\109\109\111\110")local A=require(p:WaitForChild("\065\115\115\101\116\067\097\116\097\103\111\114\105\101\115"))local C=require(p:WaitForChild("\065\115\115\101\116\115"))return function(L,p,K)L=L or{}local f=C.byId[p.assetId]if f then local C=A.byId[f.type]if C and C.id==K then if p.type=="\065\083\083\069\084\095\085\078\069\081\085\073\080"then local A={}local C=false for L,K in pairs(L)do if K==p.assetId and not C then C=true else table.insert(A,K)end end return A end end end return L end
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local common = ReplicatedStorage:WaitForChild("common")

local AssetCatagories = require(common:WaitForChild("AssetCatagories"))
local Assets = require(common:WaitForChild("Assets"))

return function(equipped, action, cataId)
    equipped = equipped or {}

    local asset = Assets.byId[action.assetId]
    if asset then
        local catagory = AssetCatagories.byId[asset.type]
        if catagory and catagory.id == cataId then
            if action.type == "ASSET_UNEQUIP" then
                -- search for first occorance of assetid and remove it
                -- this is disgusting. but i cant think right now.
                local newEquipped = {}
                local removed = false -- removed the asset we wanted to
                for _, equippedAssetId in pairs(equipped) do
                    if equippedAssetId == action.assetId and not removed then
                        removed = true
                    else
                        table.insert(newEquipped,equippedAssetId)
                    end
                end
                return newEquipped
            end
        end
    end
    return equipped
end