local C={}local f=game:GetService("\083\101\108\101\099\116\105\111\110")local U=game:GetService("\067\104\097\110\103\101\072\105\115\116\111\114\121\083\101\114\118\105\099\101")local w=script.Parent.Parent.Parent.assets local a=script.Parent.Parent local z=require(a.util.stylesheet)function C.new(C,a,J)local m=w.Icon:Clone()m.Name,m.Container.Title.Text=C,C m.Container.Image.Image=a m.Trigger.MouseEnter:Connect(function()m.Background.BackgroundColor3=z.PrimaryColor3 end)m.Trigger.MouseLeave:Connect(function()local C=(settings()).Studio.Theme.Name m.Background.BackgroundColor3=z[C].Accent end)m.Trigger.MouseButton1Click:Connect(function()local w=(settings()).Studio.Theme.Name local J=f:Get()m.Background.BackgroundColor3=z[w].Accent U:SetWaypoint("\073\110\115\101\114\116\105\110\103\047\065\112\112\108\121\105\110\103 \105\099\111\110 "..(C.." \116\111 \115\101\108\101\099\116\105\111\110\115"))for C,f in ipairs(J)do if f:IsA("\073\109\097\103\101\076\097\098\101\108")or f:IsA("\073\109\097\103\101\066\117\116\116\111\110")then f.Image=a else local C=Instance.new("\073\109\097\103\101\076\097\098\101\108")local U=Instance.new("\085\073\065\115\112\101\099\116\082\097\116\105\111\067\111\110\115\116\114\097\105\110\116",C)C.BackgroundTransparency=1 C.Name="\073\099\111\110"C.Image=a C.Parent=f end end U:SetWaypoint("\065\102\116\101\114 \105\110\115\101\114\116\105\111\110\047\097\112\112\108\105\099\097\116\105\111\110 \111\102 \105\099\111\110 "..(C.." \116\111 \115\101\108\101\099\116\105\111\110\115"))end)m.Parent=J end return C
local icon = {}

local Selection = game:GetService("Selection")
local ChangeHistoryService = game:GetService("ChangeHistoryService")

local assets = script.Parent.Parent.Parent.assets
local modules = script.Parent.Parent

local stylesheet = require(modules.util.stylesheet)

function icon.new(name, id, parent)
    local object = assets.Icon:Clone()
    object.Name, object.Container.Title.Text = name, name
    object.Container.Image.Image = id

    object.Trigger.MouseEnter:Connect(function()
        object.Background.BackgroundColor3 = stylesheet.PrimaryColor3
    end)

    object.Trigger.MouseLeave:Connect(function()
        local themeOption = settings().Studio.Theme.Name
        object.Background.BackgroundColor3 = stylesheet[themeOption].Accent
    end)

    object.Trigger.MouseButton1Click:Connect(function()
        local themeOption = settings().Studio.Theme.Name
        local currentSelection = Selection:Get()
        object.Background.BackgroundColor3 = stylesheet[themeOption].Accent

        ChangeHistoryService:SetWaypoint("Inserting/Applying icon " .. name .. " to selections")
        for _, selectedObject in ipairs(currentSelection) do
            if selectedObject:IsA("ImageLabel") or selectedObject:IsA("ImageButton") then
                selectedObject.Image = id
            else
                local image = Instance.new("ImageLabel")
                local aspectRatioConstraint = Instance.new("UIAspectRatioConstraint", image)
                image.BackgroundTransparency = 1
                image.Name = "Icon"
                image.Image = id
                image.Parent = selectedObject
            end
        end
        ChangeHistoryService:SetWaypoint("After insertion/application of icon " .. name .. " to selections")
    end)

    object.Parent = parent
end

return icon