function Icon.setLabel(V,q,O)q=q or""V:set("\105\099\111\110\084\101\120\116",q,O)return V end function Icon.setCornerRadius(d,q,O,V)local u=d.instances.iconCorner.CornerRadius local U=UDim.new(q or u.Scale,O or u.Offset)d:set("\105\099\111\110\067\111\114\110\101\114\082\097\100\105\117\115",U,V)return d end function Icon.setImage(V,q,O)local d=tonumber(q)and"\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..q or q or""return V:set("\105\099\111\110\073\109\097\103\101",d,O)end function Icon.setOrder(V,q,O)local d=tonumber(q)or 1 return V:set("\111\114\100\101\114",d,O)end function Icon.setLeft(O,q)return O:set("\097\108\105\103\110\109\101\110\116","\108\101\102\116",q)end function Icon.setMid(O,q)return O:set("\097\108\105\103\110\109\101\110\116","\109\105\100",q)end function Icon.setRight(O,q)return O:set("\097\108\105\103\110\109\101\110\116","\114\105\103\104\116",q)end function Icon.setImageYScale(V,q,O)local d=tonumber(q)or.63 return V:set("\105\099\111\110\073\109\097\103\101\089\083\099\097\108\101",d,O)end function Icon.setImageRatio(V,q,O)local d=tonumber(q)or 1 return V:set("\105\099\111\110\073\109\097\103\101\082\097\116\105\111",d,O)end function Icon.setLabelYScale(V,q,O)local d=tonumber(q)or.45 return V:set("\105\099\111\110\076\097\098\101\108\089\083\099\097\108\101",d,O)end function Icon.setBaseZIndex(V,q,O)local d=tonumber(q)or 1 return V:set("\098\097\115\101\090\073\110\100\101\120",d,O)end function Icon._updateBaseZIndex(O,q)local V=O.instances.iconContainer local d=tonumber(q)or V.ZIndex local u=d-V.ZIndex if u==0 then return"\084\104\101 \098\097\115\101\086\097\108\117\101 \105\115 \116\104\101 \115\097\109\101"end for q,O in pairs(O.instances)do O.ZIndex=O.ZIndex+u end return true end function Icon.setSize(d,q,O,V)local u=tonumber(q)or 32 local U=tonumber(O)or u d:set("\102\111\114\099\101\100\073\099\111\110\083\105\122\101",UDim2.new(0,u,0,U),V)d:set("\105\099\111\110\083\105\122\101",UDim2.new(0,u,0,U),V)return d end function Icon._updateIconSize(V,q,O)if V._destroyed then return end local d=12 local u=8 local U={iconImage=V:get("\105\099\111\110\073\109\097\103\101",O)or"\095\078\073\076";iconText=V:get("\105\099\111\110\084\101\120\116",O)or"\095\078\073\076",iconSize=V:get("\105\099\111\110\083\105\122\101",O)or"\095\078\073\076";forcedIconSize=V:get("\102\111\114\099\101\100\073\099\111\110\083\105\122\101",O)or"\095\078\073\076";iconImageYScale=V:get("\105\099\111\110\073\109\097\103\101\089\083\099\097\108\101",O)or"\095\078\073\076",iconImageRatio=V:get("\105\099\111\110\073\109\097\103\101\082\097\116\105\111",O)or"\095\078\073\076",iconLabelYScale=V:get("\105\099\111\110\076\097\098\101\108\089\083\099\097\108\101",O)or"\095\078\073\076"}for q,O in pairs(U)do if O=="\095\078\073\076"then return end end local S=V.instances.iconContainer local L=V.instances.iconLabel if not S.Parent then return end local a=U.iconSize.X.Offset local m=U.iconSize.X.Scale local f=a+m*S.Parent.AbsoluteSize.X local i=U.forcedIconSize.X.Offset local X=m>0 and f or 9999 local Q=U.iconSize.Y.Offset local P=U.iconSize.Y.Scale local j=Q+P*S.Parent.AbsoluteSize.Y local n=j*U.iconLabelYScale local T=(textService:GetTextSize(U.iconText,n,L.Font,Vector2.new(10000,n))).X local p=(j*U.iconImageYScale)*U.iconImageRatio local e=U.iconImage~=""local o=U.iconText~=""local A=.5 local r if e and not o then A=.45 V:set("\105\099\111\110\073\109\097\103\101\086\105\115\105\098\108\101",true,O)V:set("\105\099\111\110\073\109\097\103\101\065\110\099\104\111\114\080\111\105\110\116",Vector2.new(.5,.5),O)V:set("\105\099\111\110\073\109\097\103\101\080\111\115\105\116\105\111\110",UDim2.new(.5,0,.5,0),O)V:set("\105\099\111\110\073\109\097\103\101\083\105\122\101",UDim2.new(U.iconImageYScale*U.iconImageRatio,0,U.iconImageYScale,0),O)V:set("\105\099\111\110\076\097\098\101\108\086\105\115\105\098\108\101",false,O)elseif not e and o then r=T+d*2 V:set("\105\099\111\110\076\097\098\101\108\086\105\115\105\098\108\101",true,O)V:set("\105\099\111\110\076\097\098\101\108\065\110\099\104\111\114\080\111\105\110\116",Vector2.new(0,.5),O)V:set("\105\099\111\110\076\097\098\101\108\080\111\115\105\116\105\111\110",UDim2.new(0,d,.5,0),O)V:set("\105\099\111\110\076\097\098\101\108\083\105\122\101",UDim2.new(1,-d*2,U.iconLabelYScale,0),O)V:set("\105\099\111\110\076\097\098\101\108\084\101\120\116\088\065\108\105\103\110\109\101\110\116",Enum.TextXAlignment.Center,O)V:set("\105\099\111\110\073\109\097\103\101\086\105\115\105\098\108\101",false,O)elseif e and o then local q=(d+p)+u r=(q+T)+d V:set("\105\099\111\110\073\109\097\103\101\086\105\115\105\098\108\101",true,O)V:set("\105\099\111\110\073\109\097\103\101\065\110\099\104\111\114\080\111\105\110\116",Vector2.new(0,.5),O)V:set("\105\099\111\110\073\109\097\103\101\080\111\115\105\116\105\111\110",UDim2.new(0,d,.5,0),O)V:set("\105\099\111\110\073\109\097\103\101\083\105\122\101",UDim2.new(0,p,U.iconImageYScale,0),O)V:set("\105\099\111\110\076\097\098\101\108\086\105\115\105\098\108\101",true,O)V:set("\105\099\111\110\076\097\098\101\108\065\110\099\104\111\114\080\111\105\110\116",Vector2.new(0,.5),O)V:set("\105\099\111\110\076\097\098\101\108\080\111\115\105\116\105\111\110",UDim2.new(0,q,.5,0),O)V:set("\105\099\111\110\076\097\098\101\108\083\105\122\101",UDim2.new(1,-q-d,U.iconLabelYScale,0),O)V:set("\105\099\111\110\076\097\098\101\108\084\101\120\116\088\065\108\105\103\110\109\101\110\116",Enum.TextXAlignment.Left,O)end if r then if not V._updatingIconSize then V._updatingIconSize=true local q=m>0 and m or 0 local d=m>0 and 0 or math.clamp(r,i,X)V:set("\105\099\111\110\083\105\122\101",UDim2.new(q,d,U.iconSize.Y.Scale,U.iconSize.Y.Offset),O,"\095\105\103\110\111\114\101\080\114\101\118\105\111\117\115")V._updatingIconSize=false end end V:set("\105\099\111\110\076\097\098\101\108\084\101\120\116\083\105\122\101",n,O)V:set("\110\111\116\105\099\101\070\114\097\109\101\080\111\115\105\116\105\111\110",UDim2.new(A,0,0,-2),O)if V.captionText then local q=6 local O=.8 local d=.58 local u=V.instances.captionContainer local U=V.instances.captionLabel local S=j*O local L=S*d local a=V:get("\099\097\112\116\105\111\110\070\111\110\116")local m=(textService:GetTextSize(V.captionText,L,a,Vector2.new(10000,L))).X U.TextSize=L U.Size=UDim2.new(0,m,d,0)u.Size=UDim2.new(0,m+q*2,0,j*O)end V._updatingIconSize=false end
-- TOGGLEABLE METHODS
function Icon:setLabel(text, iconState)
	text = text or ""
	self:set("iconText", text, iconState)
	return self
end

function Icon:setCornerRadius(scale, offset, iconState)
	local oldCornerRadius = self.instances.iconCorner.CornerRadius
	local newCornerRadius = UDim.new(scale or oldCornerRadius.Scale, offset or oldCornerRadius.Offset)
	self:set("iconCornerRadius", newCornerRadius, iconState)
	return self
end

function Icon:setImage(imageId, iconState)
	local textureId = (tonumber(imageId) and "http://www.roblox.com/asset/?id=" .. imageId) or imageId or ""
	return self:set("iconImage", textureId, iconState)
end

function Icon:setOrder(order, iconState)
	local newOrder = tonumber(order) or 1
	return self:set("order", newOrder, iconState)
end

function Icon:setLeft(iconState)
	return self:set("alignment", "left", iconState)
end

function Icon:setMid(iconState)
	return self:set("alignment", "mid", iconState)
end

function Icon:setRight(iconState)
	return self:set("alignment", "right", iconState)
end

function Icon:setImageYScale(YScale, iconState)
	local newYScale = tonumber(YScale) or 0.63
	return self:set("iconImageYScale", newYScale, iconState)
end

function Icon:setImageRatio(ratio, iconState)
	local newRatio = tonumber(ratio) or 1
	return self:set("iconImageRatio", newRatio, iconState)
end

function Icon:setLabelYScale(YScale, iconState)
	local newYScale = tonumber(YScale) or 0.45
	return self:set("iconLabelYScale", newYScale, iconState)
end

function Icon:setBaseZIndex(ZIndex, iconState)
	local newBaseZIndex = tonumber(ZIndex) or 1
	return self:set("baseZIndex", newBaseZIndex, iconState)
end

function Icon:_updateBaseZIndex(baseValue)
	local container = self.instances.iconContainer
	local newBaseValue = tonumber(baseValue) or container.ZIndex
	local difference = newBaseValue - container.ZIndex
	if difference == 0 then
		return "The baseValue is the same"
	end
	for _, object in pairs(self.instances) do
		object.ZIndex = object.ZIndex + difference
	end
	return true
end

function Icon:setSize(XOffset, YOffset, iconState)
	local newXOffset = tonumber(XOffset) or 32
	local newYOffset = tonumber(YOffset) or newXOffset
	self:set("forcedIconSize", UDim2.new(0, newXOffset, 0, newYOffset), iconState)
	self:set("iconSize", UDim2.new(0, newXOffset, 0, newYOffset), iconState)
	return self
end

function Icon:_updateIconSize(_, iconState)
	if self._destroyed then
		return
	end
	-- This is responsible for handling the appearance and size of the icons label and image, in additon to its own size
	local X_MARGIN = 12
	local X_GAP = 8

	local values = {
		iconImage = self:get("iconImage", iconState) or "_NIL",
		iconText = self:get("iconText", iconState) or "_NIL",
		iconSize = self:get("iconSize", iconState) or "_NIL",
		forcedIconSize = self:get("forcedIconSize", iconState) or "_NIL",
		iconImageYScale = self:get("iconImageYScale", iconState) or "_NIL",
		iconImageRatio = self:get("iconImageRatio", iconState) or "_NIL",
		iconLabelYScale = self:get("iconLabelYScale", iconState) or "_NIL",
	}
	for k, v in pairs(values) do
		if v == "_NIL" then
			return
		end
	end

	local iconContainer = self.instances.iconContainer
	local iconLabel = self.instances.iconLabel
	if not iconContainer.Parent then
		return
	end

	-- We calculate the cells dimensions as apposed to reading because there's a possibility the cells dimensions were changed at the exact time and have not yet updated
	-- this essentially saves us from waiting a heartbeat which causes additonal complications
	local cellSizeXOffset = values.iconSize.X.Offset
	local cellSizeXScale = values.iconSize.X.Scale
	local cellWidth = cellSizeXOffset + (cellSizeXScale * iconContainer.Parent.AbsoluteSize.X)
	local minCellWidth = values.forcedIconSize.X.Offset --cellWidth
	local maxCellWidth = (cellSizeXScale > 0 and cellWidth) or 9999
	local cellSizeYOffset = values.iconSize.Y.Offset
	local cellSizeYScale = values.iconSize.Y.Scale
	local cellHeight = cellSizeYOffset + (cellSizeYScale * iconContainer.Parent.AbsoluteSize.Y)
	local labelHeight = cellHeight * values.iconLabelYScale
	local labelWidth =
		textService:GetTextSize(values.iconText, labelHeight, iconLabel.Font, Vector2.new(10000, labelHeight)).X
	local imageWidth = cellHeight * values.iconImageYScale * values.iconImageRatio

	local usingImage = values.iconImage ~= ""
	local usingText = values.iconText ~= ""
	local notifPosYScale = 0.5
	local desiredCellWidth

	if usingImage and not usingText then
		notifPosYScale = 0.45
		self:set("iconImageVisible", true, iconState)
		self:set("iconImageAnchorPoint", Vector2.new(0.5, 0.5), iconState)
		self:set("iconImagePosition", UDim2.new(0.5, 0, 0.5, 0), iconState)
		self:set(
			"iconImageSize",
			UDim2.new(values.iconImageYScale * values.iconImageRatio, 0, values.iconImageYScale, 0),
			iconState
		)
		self:set("iconLabelVisible", false, iconState)
	elseif not usingImage and usingText then
		desiredCellWidth = labelWidth + (X_MARGIN * 2)
		self:set("iconLabelVisible", true, iconState)
		self:set("iconLabelAnchorPoint", Vector2.new(0, 0.5), iconState)
		self:set("iconLabelPosition", UDim2.new(0, X_MARGIN, 0.5, 0), iconState)
		self:set("iconLabelSize", UDim2.new(1, -X_MARGIN * 2, values.iconLabelYScale, 0), iconState)
		self:set("iconLabelTextXAlignment", Enum.TextXAlignment.Center, iconState)
		self:set("iconImageVisible", false, iconState)
	elseif usingImage and usingText then
		local labelGap = X_MARGIN + imageWidth + X_GAP
		desiredCellWidth = labelGap + labelWidth + X_MARGIN
		self:set("iconImageVisible", true, iconState)
		self:set("iconImageAnchorPoint", Vector2.new(0, 0.5), iconState)
		self:set("iconImagePosition", UDim2.new(0, X_MARGIN, 0.5, 0), iconState)
		self:set("iconImageSize", UDim2.new(0, imageWidth, values.iconImageYScale, 0), iconState)
		----
		self:set("iconLabelVisible", true, iconState)
		self:set("iconLabelAnchorPoint", Vector2.new(0, 0.5), iconState)
		self:set("iconLabelPosition", UDim2.new(0, labelGap, 0.5, 0), iconState)
		self:set("iconLabelSize", UDim2.new(1, -labelGap - X_MARGIN, values.iconLabelYScale, 0), iconState)
		self:set("iconLabelTextXAlignment", Enum.TextXAlignment.Left, iconState)
	end
	if desiredCellWidth then
		if not self._updatingIconSize then
			self._updatingIconSize = true
			local widthScale = (cellSizeXScale > 0 and cellSizeXScale) or 0
			local widthOffset = (cellSizeXScale > 0 and 0) or math.clamp(desiredCellWidth, minCellWidth, maxCellWidth)
			self:set(
				"iconSize",
				UDim2.new(widthScale, widthOffset, values.iconSize.Y.Scale, values.iconSize.Y.Offset),
				iconState,
				"_ignorePrevious"
			)
			self._updatingIconSize = false
		end
	end
	self:set("iconLabelTextSize", labelHeight, iconState)
	self:set("noticeFramePosition", UDim2.new(notifPosYScale, 0, 0, -2), iconState)

	-- Caption
	if self.captionText then
		local CAPTION_X_MARGIN = 6
		local CAPTION_CONTAINER_Y_SIZE_SCALE = 0.8
		local CAPTION_LABEL_Y_SCALE = 0.58
		local captionContainer = self.instances.captionContainer
		local captionLabel = self.instances.captionLabel
		local captionContainerHeight = cellHeight * CAPTION_CONTAINER_Y_SIZE_SCALE
		local captionLabelHeight = captionContainerHeight * CAPTION_LABEL_Y_SCALE
		local labelFont = self:get("captionFont")
		local textWidth = textService:GetTextSize(
			self.captionText,
			captionLabelHeight,
			labelFont,
			Vector2.new(10000, captionLabelHeight)
		).X
		captionLabel.TextSize = captionLabelHeight
		captionLabel.Size = UDim2.new(0, textWidth, CAPTION_LABEL_Y_SCALE, 0)
		captionContainer.Size =
			UDim2.new(0, textWidth + CAPTION_X_MARGIN * 2, 0, cellHeight * CAPTION_CONTAINER_Y_SIZE_SCALE)
	end

	self._updatingIconSize = false
end
