function Icon.set(G,T,g,b,R)local Y=G._settingsDictionary[T]assert(Y~=nil,("\115\101\116\116\105\110\103 \'\037\115\' \100\111\101\115 \110\111\116 \101\120\105\115\116"):format(T))if type(b)=="\115\116\114\105\110\103"then b=b:lower()end local a=G:get(T,b)if b=="\104\111\118\101\114\105\110\103"then Y.hoveringValue=g if R~="\095\105\103\110\111\114\101\080\114\101\118\105\111\117\115"then Y.additionalValues["\112\114\101\118\105\111\117\115\095"..b]=a end if type(R)=="\115\116\114\105\110\103"then Y.additionalValues[R..("\095"..b)]=a end G:_update(T)else local C=b local v=Y.type if v=="\116\111\103\103\108\101\097\098\108\101"then local T={}if C=="\100\101\115\101\108\101\099\116\101\100"or C=="\115\101\108\101\099\116\101\100"then table.insert(T,C)else table.insert(T,"\100\101\115\101\108\101\099\116\101\100")table.insert(T,"\115\101\108\101\099\116\101\100")C=nil end for T,b in pairs(T)do Y.values[b]=g if R~="\095\105\103\110\111\114\101\080\114\101\118\105\111\117\115"then Y.additionalValues["\112\114\101\118\105\111\117\115\095"..b]=a end if type(R)=="\115\116\114\105\110\103"then Y.additionalValues[R..("\095"..b)]=a end end else Y.value=g if type(R)=="\115\116\114\105\110\103"then if R~="\095\105\103\110\111\114\101\080\114\101\118\105\111\117\115"then Y.additionalValues.previous=a end Y.additionalValues[R]=a end end if a==g then return G,"\086\097\108\117\101 \119\097\115 \097\108\114\101\097\100\121 \115\101\116"end local K=G:getToggleState()if not G._updateAfterSettingAll and(Y.instanceNames and(K==C or C==nil))then local g=T=="\105\099\111\110\083\105\122\101"and(a and a.X.Scale==1)local b=Y.tweenAction and(not g and G:get(Y.tweenAction))or TweenInfo.new(0)G:_update(T,K,b)end end if Y.callMethods then for T,R in pairs(Y.callMethods)do R(G,g,b)end end if Y.callSignals then for T,g in pairs(Y.callSignals)do g:Fire()end end return G end function Icon.setAdditionalValue(G,T,g,b,R)local Y=G._settingsDictionary[T]assert(Y~=nil,("\115\101\116\116\105\110\103 \'\037\115\' \100\111\101\115 \110\111\116 \101\120\105\115\116"):format(T))local a=g.."\095"if R then a=a..R end for T,g in pairs(Y.additionalValues)do if string.match(T,a)then Y.additionalValues[T]=b end end end function Icon.get(R,T,g,b)local G=R._settingsDictionary[T]assert(G~=nil,("\115\101\116\116\105\110\103 \'\037\115\' \100\111\101\115 \110\111\116 \101\120\105\115\116"):format(T))local Y,a if typeof(g)=="\115\116\114\105\110\103"then g=g:lower()end if g=="\104\111\118\101\114\105\110\103"and b==nil then Y=G.hoveringValue a=type(b)=="\115\116\114\105\110\103"and G.additionalValues[b..("\095"..g)]end local C=G.type if C=="\116\111\103\103\108\101\097\098\108\101"then local T=(g=="\100\101\115\101\108\101\099\116\101\100"or g=="\115\101\108\101\099\116\101\100")and g or R:getToggleState()if a==nil then a=type(b)=="\115\116\114\105\110\103"and G.additionalValues[b..("\095"..T)]end if Y==nil then Y=G.values[T]end else if a==nil then a=type(b)=="\115\116\114\105\110\103"and G.additionalValues[b]end if Y==nil then Y=G.value end end return Y,a end function Icon.getHovering(g,T)local b=g._settingsDictionary[T]assert(b~=nil,("\115\101\116\116\105\110\103 \'\037\115\' \100\111\101\115 \110\111\116 \101\120\105\115\116"):format(T))return b.hoveringValue end function Icon.getToggleState(g,T)T=T or g.isSelected return T and"\115\101\108\101\099\116\101\100"or"\100\101\115\101\108\101\099\116\101\100"end function Icon.getIconState(T)if T.hovering then return"\104\111\118\101\114\105\110\103"else return T:getToggleState()end end function Icon._update(R,T,g,b)local G=R._settingsDictionary[T]assert(G~=nil,("\115\101\116\116\105\110\103 \'\037\115\' \100\111\101\115 \110\111\116 \101\120\105\115\116"):format(T))g=g or R:getToggleState()local Y=G.value or G.values and G.values[g]if R.hovering and G.hoveringValue then Y=G.hoveringValue end if Y==nil then return end local a=b or G.tweenAction and(G.tweenAction~=""and R:get(G.tweenAction))or R:get("\116\111\103\103\108\101\084\114\097\110\115\105\116\105\111\110\073\110\102\111")or TweenInfo.new(.15)local C=G.propertyName local v={string=true,NumberSequence=true,Text=true,EnumItem=true,ColorSequence=true}local K=R._uniqueSettingsDictionary[T]local t=Y if G.useForcedGroupValue then t=G.forcedGroupValue end if G.instanceNames then for g,b in pairs(G.instanceNames)do local G=R.instances[b]local d=typeof(G[C])local q=v[d]or typeof(G)=="\116\097\098\108\101"if K then K(T,G,C,t)elseif q then G[C]=Y else(tweenService:Create(G,a,{[C]=t})):Play()end if T=="\105\099\111\110\083\105\122\101"and G[C]~=t then R.updated:Fire()end end end end function Icon._updateAll(b,T,g)for R,G in pairs(b._settingsDictionary)do if G.instanceNames then b:_update(R,T,g)end end end function Icon._updateHovering(g,T)for b,R in pairs(g._settingsDictionary)do if R.instanceNames and R.hoveringValue~=nil then g:_update(b,nil,T)end end end function Icon._updateStateOverlay(b,T,g)local R=b.instances.iconOverlay R.BackgroundTransparency=T or 1 R.BackgroundColor3=g or Color3.new(1,1,1)end function Icon.setTheme(b,T,g)b._updateAfterSettingAll=g for T,g in pairs(T)do if T=="\116\111\103\103\108\101\097\098\108\101"then for T,g in pairs(g.deselected)do if not b.lockedSettings[T]then b:set(T,g,"\098\111\116\104")end end for T,g in pairs(g.selected)do if not b.lockedSettings[T]then b:set(T,g,"\115\101\108\101\099\116\101\100")end end else for g,R in pairs(g)do if not b.lockedSettings[g]then local G=b._settingsDictionary[g]if T=="\097\099\116\105\111\110"and G==nil then G={}b._settingsDictionary[g]={}end b:set(g,R)end end end end b._updateAfterSettingAll=nil if g then b:_updateAll()end return b end function Icon.getInstance(g,T)return g.instances[T]end function Icon.setInstance(b,T,g)local R=b.instances[T]b.instances[T]=g if R then R:Destroy()end return b end function Icon.getSettingDetail(g,T)for g,b in pairs(g._settings)do for g,b in pairs(b)do if g==T then return b end end end return false end function Icon.modifySetting(b,T,g)local R=b:getSettingDetail(T)for T,g in pairs(g)do R[T]=g end return b end function Icon.convertLabelToNumberSpinner(g,T)g:set("\105\099\111\110\076\097\098\101\108\083\105\122\101",UDim2.new(1,0,1,0))T.Parent=g:getInstance("\105\099\111\110\066\117\116\116\111\110")local b={}setmetatable(b,{__newindex=function(g,b,R)for T,g in pairs(T.Frame:GetDescendants())do if g:IsA("\084\101\120\116\076\097\098\101\108")then g[b]=R end end end})local R=g:getInstance("\105\099\111\110\066\117\116\116\111\110")R.ZIndex=0 g:setInstance("\105\099\111\110\076\097\098\101\108",b)g:modifySetting("\105\099\111\110\084\101\120\116",{instanceNames={}})g:setInstance("\105\099\111\110\076\097\098\101\108\083\112\105\110\110\101\114",T.Frame)local G={"\105\099\111\110\076\097\098\101\108\086\105\115\105\098\108\101";"\105\099\111\110\076\097\098\101\108\065\110\099\104\111\114\080\111\105\110\116";"\105\099\111\110\076\097\098\101\108\080\111\115\105\116\105\111\110","\105\099\111\110\076\097\098\101\108\083\105\122\101"}for T,b in pairs(G)do g:modifySetting(b,{instanceNames={"\105\099\111\110\076\097\098\101\108\083\112\105\110\110\101\114"}})end g:_updateAll()return g end function Icon.setEnabled(g,T)g.enabled=T g.instances.iconContainer.Visible=T g.updated:Fire()return g end function Icon.setName(g,T)g.name=T g.instances.iconContainer.Name=T return g end function Icon.setProperty(b,T,g)b[T]=g return b end function Icon._playClickSound(T)local g=T.instances.clickSound if g.SoundId~=nil and(#g.SoundId>0 and g.Volume>0)then local T=g:Clone()T.Parent=g.Parent T:Play()debris:AddItem(T,g.TimeLength)end end function Icon.select(g,T)g.isSelected=true g:_setToggleItemsVisible(true,T)g:_updateNotice()g:_updateAll()g:_playClickSound()if#g.dropdownIcons>0 or#g.menuIcons>0 then IconController:_updateSelectionGroup()end if userInputService.GamepadEnabled then for T,b in pairs(g.toggleItems)do if#b>0 then local T=Maid.new()guiService:AddSelectionTuple(g.UID,unpack(b))guiService.SelectedObject=b[1]IconController.activeButtonBCallbacks+=1 T:give(userInputService.InputEnded:Connect(function(T,b)local R=false for T,g in pairs(g.blockBackBehaviourChecks)do if g()==true then R=true break end end if T.KeyCode==Enum.KeyCode.ButtonB and not R then guiService.SelectedObject=g.instances.iconButton g:deselect()end end))T:give(g.deselected:Connect(function()T:clean()end))T:give(function()IconController.activeButtonBCallbacks-=1 if IconController.activeButtonBCallbacks<0 then IconController.activeButtonBCallbacks=0 end end)end end end g.selected:Fire()g.toggled:Fire(g.isSelected)return g end function Icon.deselect(g,T)g.isSelected=false g:_setToggleItemsVisible(false,T)g:_updateNotice()g:_updateAll()g:_playClickSound()if#g.dropdownIcons>0 or#g.menuIcons>0 then IconController:_updateSelectionGroup()end g.deselected:Fire()g.toggled:Fire(g.isSelected)if userInputService.GamepadEnabled then guiService:RemoveSelectionGroup(g.UID)end return g end function Icon.notify(b,T,g)(coroutine.wrap(function()if not T then T=b.deselected end if b._parentIcon then b._parentIcon:notify(T)end local R=Signal.new()local G=b._endNotices:Connect(function()R:Fire()end)local Y=T:Connect(function()R:Fire()end)g=g or httpService:GenerateGUID(true)b.notices[g]={completeSignal=R,clearNoticeEvent=T}b.totalNotices+=1 b:_updateNotice()b.notified:Fire(g)R:Wait()G:Disconnect()Y:Disconnect()R:Disconnect()b.totalNotices-=1 b.notices[g]=nil b:_updateNotice()end))()return b end function Icon._updateNotice(T)local g=true if T.totalNotices<1 then g=false end if not T.isSelected then if(#T.dropdownIcons>0 or#T.menuIcons>0)and T.totalNotices>0 then g=true end end if T.isSelected then if#T.dropdownIcons>0 or#T.menuIcons>0 then g=false end end local b=g and 0 or 1 T:set("\110\111\116\105\099\101\073\109\097\103\101\084\114\097\110\115\112\097\114\101\110\099\121",b)T:set("\110\111\116\105\099\101\084\101\120\116\084\114\097\110\115\112\097\114\101\110\099\121",b)T.instances.noticeLabel.Text=T.totalNotices<100 and T.totalNotices or"\057\057\043"end function Icon.clearNotices(T)T._endNotices:Fire()return T end function Icon.disableStateOverlay(g,T)if T==nil then T=true end local b=g.instances.iconOverlay b.Visible=not T return g end

function Icon:set(settingName, value, iconState, setAdditional)
	local settingDetail = self._settingsDictionary[settingName]
	assert(settingDetail ~= nil, ("setting '%s' does not exist"):format(settingName))
	if type(iconState) == "string" then
		iconState = iconState:lower()
	end
	local previousValue = self:get(settingName, iconState)

	if iconState == "hovering" then
		-- Apply hovering state if valid
		settingDetail.hoveringValue = value
		if setAdditional ~= "_ignorePrevious" then
			settingDetail.additionalValues["previous_"..iconState] = previousValue
		end
		if type(setAdditional) == "string" then
			settingDetail.additionalValues[setAdditional.."_"..iconState] = previousValue
		end
		self:_update(settingName)

	else
		-- Update the settings value
		local toggleState = iconState
		local settingType = settingDetail.type
		if settingType == "toggleable" then
			local valuesToSet = {}
			if toggleState == "deselected" or toggleState == "selected" then
				table.insert(valuesToSet, toggleState)
			else
				table.insert(valuesToSet, "deselected")
				table.insert(valuesToSet, "selected")
				toggleState = nil
			end
			for i, v in pairs(valuesToSet) do
				settingDetail.values[v] = value
				if setAdditional ~= "_ignorePrevious" then
					settingDetail.additionalValues["previous_"..v] = previousValue
				end
				if type(setAdditional) == "string" then
					settingDetail.additionalValues[setAdditional.."_"..v] = previousValue
				end
			end
		else
			settingDetail.value = value
			if type(setAdditional) == "string" then
				if setAdditional ~= "_ignorePrevious" then
					settingDetail.additionalValues["previous"] = previousValue
				end
				settingDetail.additionalValues[setAdditional] = previousValue
			end
		end

		-- Check previous and new are not the same
		if previousValue == value then
			return self, "Value was already set"
		end

		-- Update appearances of associated instances
		local currentToggleState = self:getToggleState()
		if not self._updateAfterSettingAll and settingDetail.instanceNames and (currentToggleState == toggleState or toggleState == nil) then
			local ignoreTweenAction = (settingName == "iconSize" and previousValue and previousValue.X.Scale == 1)
			local tweenInfo = (settingDetail.tweenAction and not ignoreTweenAction and self:get(settingDetail.tweenAction)) or TweenInfo.new(0)
			self:_update(settingName, currentToggleState, tweenInfo)
		end
	end

	-- Call any methods present
	if settingDetail.callMethods then
		for _, callMethod in pairs(settingDetail.callMethods) do
			callMethod(self, value, iconState)
		end
	end
	
	-- Call any signals present
	if settingDetail.callSignals then
		for _, callSignal in pairs(settingDetail.callSignals) do
			callSignal:Fire()
		end
	end
	return self
end

function Icon:setAdditionalValue(settingName, setAdditional, value, iconState)
	local settingDetail = self._settingsDictionary[settingName]
	assert(settingDetail ~= nil, ("setting '%s' does not exist"):format(settingName))
	local stringMatch = setAdditional.."_"
	if iconState then
		stringMatch = stringMatch..iconState
	end
	for key, _ in pairs(settingDetail.additionalValues) do
		if string.match(key, stringMatch) then
			settingDetail.additionalValues[key] = value
		end
	end
end

function Icon:get(settingName, iconState, getAdditional)
	local settingDetail = self._settingsDictionary[settingName]
	assert(settingDetail ~= nil, ("setting '%s' does not exist"):format(settingName))
	local valueToReturn, additionalValueToReturn
	if typeof(iconState) == "string" then
		iconState = iconState:lower()
	end

	--if ((self.hovering and settingDetail.hoveringValue) or iconState == "hovering") and getAdditional == nil then
	if (iconState == "hovering") and getAdditional == nil then
		valueToReturn = settingDetail.hoveringValue
		additionalValueToReturn = type(getAdditional) == "string" and settingDetail.additionalValues[getAdditional.."_"..iconState]
	end

	local settingType = settingDetail.type
	if settingType == "toggleable" then
		local toggleState = ((iconState == "deselected" or iconState == "selected") and iconState) or self:getToggleState()
		if additionalValueToReturn == nil then
			additionalValueToReturn = type(getAdditional) == "string" and settingDetail.additionalValues[getAdditional.."_"..toggleState]
		end
		if valueToReturn == nil then
			valueToReturn = settingDetail.values[toggleState]
		end
	
	else
		if additionalValueToReturn == nil then
			additionalValueToReturn = type(getAdditional) == "string" and settingDetail.additionalValues[getAdditional]
		end
		if valueToReturn == nil then
			valueToReturn = settingDetail.value
		end
	end

	return valueToReturn, additionalValueToReturn
end

function Icon:getHovering(settingName)
	local settingDetail = self._settingsDictionary[settingName]
	assert(settingDetail ~= nil, ("setting '%s' does not exist"):format(settingName))
	return settingDetail.hoveringValue
end

function Icon:getToggleState(isSelected)
	isSelected = isSelected or self.isSelected
	return (isSelected and "selected") or "deselected"
end

function Icon:getIconState()
	if self.hovering then
		return "hovering"
	else
		return self:getToggleState()
	end
end

function Icon:_update(settingName, toggleState, customTweenInfo)
	local settingDetail = self._settingsDictionary[settingName]
	assert(settingDetail ~= nil, ("setting '%s' does not exist"):format(settingName))
	toggleState = toggleState or self:getToggleState()
	local value = settingDetail.value or (settingDetail.values and settingDetail.values[toggleState])
	if self.hovering and settingDetail.hoveringValue then
		value = settingDetail.hoveringValue
	end
	if value == nil then return end
	local tweenInfo = customTweenInfo or (settingDetail.tweenAction and settingDetail.tweenAction ~= "" and self:get(settingDetail.tweenAction)) or self:get("toggleTransitionInfo") or TweenInfo.new(0.15)
	local propertyName = settingDetail.propertyName
	local invalidPropertiesTypes = {
		["string"] = true,
		["NumberSequence"] = true,
		["Text"] = true,
		["EnumItem"] = true,
		["ColorSequence"] = true,
	}
	local uniqueSetting = self._uniqueSettingsDictionary[settingName]
	local newValue = value
	if settingDetail.useForcedGroupValue then
		newValue = settingDetail.forcedGroupValue
	end
	if settingDetail.instanceNames then
		for _, instanceName in pairs(settingDetail.instanceNames) do
			local instance = self.instances[instanceName]
			local propertyType = typeof(instance[propertyName])
			local cannotTweenProperty = invalidPropertiesTypes[propertyType] or typeof(instance) == "table"
			if uniqueSetting then
				uniqueSetting(settingName, instance, propertyName, newValue)
			elseif cannotTweenProperty then
				instance[propertyName] = value
			else
				tweenService:Create(instance, tweenInfo, {[propertyName] = newValue}):Play()
			end
			--
			if settingName == "iconSize" and instance[propertyName] ~= newValue then
				self.updated:Fire()
			end
			--
		end
	end
end

function Icon:_updateAll(iconState, customTweenInfo)
	for settingName, settingDetail in pairs(self._settingsDictionary) do
		if settingDetail.instanceNames then
			self:_update(settingName, iconState, customTweenInfo)
		end
	end
end

function Icon:_updateHovering(customTweenInfo)
	for settingName, settingDetail in pairs(self._settingsDictionary) do
		if settingDetail.instanceNames and settingDetail.hoveringValue ~= nil then
			self:_update(settingName, nil, customTweenInfo)
		end
	end
end

function Icon:_updateStateOverlay(transparency, color)
	local stateOverlay = self.instances.iconOverlay
	stateOverlay.BackgroundTransparency = transparency or 1
	stateOverlay.BackgroundColor3 = color or Color3.new(1, 1, 1)
end

function Icon:setTheme(theme, updateAfterSettingAll)
	self._updateAfterSettingAll = updateAfterSettingAll
	for settingsType, settingsDetails in pairs(theme) do
		if settingsType == "toggleable" then
			for settingName, settingValue in pairs(settingsDetails.deselected) do
				if not self.lockedSettings[settingName] then
					self:set(settingName, settingValue, "both")
				end
			end
			for settingName, settingValue in pairs(settingsDetails.selected) do
				if not self.lockedSettings[settingName] then
					self:set(settingName, settingValue, "selected")
				end
			end
		else
			for settingName, settingValue in pairs(settingsDetails) do
				if not self.lockedSettings[settingName] then
					local settingDetail = self._settingsDictionary[settingName]
					if settingsType == "action" and settingDetail == nil then
						settingDetail = {}
						self._settingsDictionary[settingName] = {}
					end
					self:set(settingName, settingValue)
				end
			end
		end
	end
	self._updateAfterSettingAll = nil
	if updateAfterSettingAll then
		self:_updateAll()
	end
	return self
end

function Icon:getInstance(instanceName)
	return self.instances[instanceName]
end

function Icon:setInstance(instanceName, instance)
	local originalInstance = self.instances[instanceName]
	self.instances[instanceName] = instance
	if originalInstance then
		originalInstance:Destroy()
	end
	return self
end

function Icon:getSettingDetail(targetSettingName)
	for _, settingsDetails in pairs(self._settings) do
		for settingName, settingDetail in pairs(settingsDetails) do
			if settingName == targetSettingName then
				return settingDetail
			end
		end
	end
	return false
end

function Icon:modifySetting(settingName, dictionary)
	local settingDetail = self:getSettingDetail(settingName)
	for key, value in pairs(dictionary) do
		settingDetail[key] = value
	end
	return self
end

function Icon:convertLabelToNumberSpinner(numberSpinner)
	-- This updates the number spinners appearance
	self:set("iconLabelSize", UDim2.new(1,0,1,0))
	numberSpinner.Parent = self:getInstance("iconButton")

	-- This creates a fake iconLabel which updates the property of all descendant spinner TextLabels when indexed
	local textLabel = {}
	setmetatable(textLabel, {__newindex = function(_, index, value)
		for _, label in pairs(numberSpinner.Frame:GetDescendants()) do
			if label:IsA("TextLabel") then
				label[index] = value
			end
		end
	end})

	-- This overrides existing instances and settings so that they update the spinners properties (instead of the old textlabel)
	local iconButton = self:getInstance("iconButton")
	iconButton.ZIndex = 0
	self:setInstance("iconLabel", textLabel)
	self:modifySetting("iconText", {instanceNames = {}}) -- We do this to prevent text being modified within the metatable above
	self:setInstance("iconLabelSpinner", numberSpinner.Frame)
	local settingsToConvert = {"iconLabelVisible", "iconLabelAnchorPoint", "iconLabelPosition", "iconLabelSize"}
	for _, settingName in pairs(settingsToConvert) do
		self:modifySetting(settingName, {instanceNames = {"iconLabelSpinner"}})
	end

	-- This applies all the values we just updated
	self:_updateAll()
	return self
end

function Icon:setEnabled(bool)
	self.enabled = bool
	self.instances.iconContainer.Visible = bool
	self.updated:Fire()
	return self
end

function Icon:setName(string)
	self.name = string
	self.instances.iconContainer.Name = string
	return self
end

function Icon:setProperty(propertyName, value)
	self[propertyName] = value
	return self
end

function Icon:_playClickSound()
	local clickSound = self.instances.clickSound
	if clickSound.SoundId ~= nil and #clickSound.SoundId > 0 and clickSound.Volume > 0 then
		local clickSoundCopy = clickSound:Clone()
		clickSoundCopy.Parent = clickSound.Parent
		clickSoundCopy:Play()
		debris:AddItem(clickSoundCopy, clickSound.TimeLength)
	end
end

function Icon:select(byIcon)
	--if self.locked then return self end
	self.isSelected = true
	self:_setToggleItemsVisible(true, byIcon)
	self:_updateNotice()
	self:_updateAll()
	self:_playClickSound()
	if #self.dropdownIcons > 0 or #self.menuIcons > 0 then
		IconController:_updateSelectionGroup()
	end
	if userInputService.GamepadEnabled then
		-- If a corresponding guiObject is found (set via :setToggleItem()) then this automatically
		-- moves the controller selection to a selectable and active instance within that guiObject.
		-- It also support back (Controller B) being pressed by navigating to previous pages or
		-- closing the icon and focusing selection back on the controller navigation topbar.
		for toggleItem, buttonInstancesArray in pairs(self.toggleItems) do
			if #buttonInstancesArray > 0 then
				local focusMaid = Maid.new()
				guiService:AddSelectionTuple(self.UID, unpack(buttonInstancesArray))
				guiService.SelectedObject = buttonInstancesArray[1]
				IconController.activeButtonBCallbacks += 1
				focusMaid:give(userInputService.InputEnded:Connect(function(input, processed)
					local blockBackBehaviour = false
					for _, func in pairs(self.blockBackBehaviourChecks) do
						if func() == true then
							blockBackBehaviour = true
							break
						end
					end
					if input.KeyCode == Enum.KeyCode.ButtonB and not blockBackBehaviour then
						guiService.SelectedObject = self.instances.iconButton
						self:deselect()
					end
				end))
				focusMaid:give(self.deselected:Connect(function()
					focusMaid:clean()
				end))
				focusMaid:give(function()
					IconController.activeButtonBCallbacks -= 1
					if IconController.activeButtonBCallbacks < 0 then
						IconController.activeButtonBCallbacks = 0
					end
				end)
			end
		end
	end
	self.selected:Fire()
    self.toggled:Fire(self.isSelected)
	return self
end

function Icon:deselect(byIcon)
	--if self.locked then return self end
	self.isSelected = false
	self:_setToggleItemsVisible(false, byIcon)
	self:_updateNotice()
	self:_updateAll()
	self:_playClickSound()
	if #self.dropdownIcons > 0 or #self.menuIcons > 0 then
		IconController:_updateSelectionGroup()
	end
    self.deselected:Fire()
    self.toggled:Fire(self.isSelected)
	if userInputService.GamepadEnabled then
		guiService:RemoveSelectionGroup(self.UID)
	end
	return self
end

function Icon:notify(clearNoticeEvent, noticeId)
	coroutine.wrap(function()
		if not clearNoticeEvent then
			clearNoticeEvent = self.deselected
		end
		if self._parentIcon then
			self._parentIcon:notify(clearNoticeEvent)
		end
		
		local notifComplete = Signal.new()
		local endEvent = self._endNotices:Connect(function()
			notifComplete:Fire()
		end)
		local customEvent = clearNoticeEvent:Connect(function()
			notifComplete:Fire()
		end)
		
		noticeId = noticeId or httpService:GenerateGUID(true)
		self.notices[noticeId] = {
			completeSignal = notifComplete,
			clearNoticeEvent = clearNoticeEvent,
		}
		self.totalNotices += 1
		self:_updateNotice()

		self.notified:Fire(noticeId)
		notifComplete:Wait()
		
		endEvent:Disconnect()
		customEvent:Disconnect()
		notifComplete:Disconnect()
		
		self.totalNotices -= 1
		self.notices[noticeId] = nil
		self:_updateNotice()
	end)()
	return self
end

function Icon:_updateNotice()
	local enabled = true
	if self.totalNotices < 1 then
		enabled = false
	end
	-- Deselect
	if not self.isSelected then
		if (#self.dropdownIcons > 0 or #self.menuIcons > 0) and self.totalNotices > 0 then
			enabled = true
		end
	end
	-- Select
	if self.isSelected then
		if #self.dropdownIcons > 0 or #self.menuIcons > 0 then
			enabled = false
		end
	end
	local value = (enabled and 0) or 1
	self:set("noticeImageTransparency", value)
	self:set("noticeTextTransparency", value)
	self.instances.noticeLabel.Text = (self.totalNotices < 100 and self.totalNotices) or "99+"
end

function Icon:clearNotices()
	self._endNotices:Fire()
	return self
end

function Icon:disableStateOverlay(bool)
	if bool == nil then
		bool = true
	end
	local stateOverlay = self.instances.iconOverlay
	stateOverlay.Visible = not bool
	return self
end


