function Icon.setDropdown(b,h)for h,b in pairs(b.dropdownIcons)do b:leave()end if type(h)=="\116\097\098\108\101"then for h,I in pairs(h)do I:join(b,"\100\114\111\112\100\111\119\110",true)end end b:_updateDropdown()return b end function Icon._updateDropdown(h)local b={maxIconsBeforeScroll=h:get("\100\114\111\112\100\111\119\110\077\097\120\073\099\111\110\115\066\101\102\111\114\101\083\099\114\111\108\108")or"\095\078\073\076";minWidth=h:get("\100\114\111\112\100\111\119\110\077\105\110\087\105\100\116\104")or"\095\078\073\076",padding=h:get("\100\114\111\112\100\111\119\110\076\105\115\116\080\097\100\100\105\110\103")or"\095\078\073\076",dropdownAlignment=h:get("\100\114\111\112\100\111\119\110\065\108\105\103\110\109\101\110\116")or"\095\078\073\076";iconAlignment=h:get("\097\108\105\103\110\109\101\110\116")or"\095\078\073\076";scrollBarThickness=h:get("\100\114\111\112\100\111\119\110\083\099\114\111\108\108\066\097\114\084\104\105\099\107\110\101\115\115")or"\095\078\073\076"}for h,b in pairs(b)do if b=="\095\078\073\076"then return end end local I=b.padding.Offset local r=h.instances.dropdownContainer local Q=h.instances.dropdownFrame local l=h.instances.dropdownList local j=#h.dropdownIcons local o=j>b.maxIconsBeforeScroll and b.maxIconsBeforeScroll or j local n=-I local S=0 local x=b.minWidth table.sort(h.dropdownIcons,function(h,b)return h:get("\111\114\100\101\114")<b:get("\111\114\100\101\114")end)for b=1,j,1 do local r=h.dropdownIcons[b]local Q,l=r:get("\105\099\111\110\083\105\122\101",nil,"\098\101\102\111\114\101\068\114\111\112\100\111\119\110")local L=l.Y.Offset+I if b<=o then S=S+L end if b==j then S=S+L/4 end n=n+L local u=l.X.Offset if u>x then x=u end end local L=o==j and 0 or n h:set("\100\114\111\112\100\111\119\110\067\097\110\118\097\115\083\105\122\101",UDim2.new(0,0,0,L))h:set("\100\114\111\112\100\111\119\110\083\105\122\101",UDim2.new(0,(x+4)*2,0,S))local u=b.dropdownAlignment:lower()local Y={left={AnchorPoint=Vector2.new(0,0);PositionXScale=0,ThicknessMultiplier=0};mid={AnchorPoint=Vector2.new(.5,0),PositionXScale=.5;ThicknessMultiplier=.5},right={AnchorPoint=Vector2.new(.5,0),PositionXScale=1;FrameAnchorPoint=Vector2.new(0,0);FramePositionXScale=0;ThicknessMultiplier=1}}local V=Y[u]if not V then V=Y[b.iconAlignment:lower()]end r.AnchorPoint=V.AnchorPoint r.Position=UDim2.new(V.PositionXScale,0,1,I+0)local k=b.scrollBarThickness local N=k*V.ThicknessMultiplier local X=Q.VerticalScrollBarPosition==Enum.VerticalScrollBarPosition.Right and N or-N Q.AnchorPoint=V.FrameAnchorPoint or V.AnchorPoint Q.Position=UDim2.new(V.FramePositionXScale or V.PositionXScale,X,0,0)h._dropdownCanvasPos=Vector2.new(0,0)end function Icon._dropdownIgnoreClipping(h)h:_ignoreClipping("\100\114\111\112\100\111\119\110")end
-- Dropdowns
function Icon:setDropdown(arrayOfIcons)
	-- Reset any previous icons
	for i, otherIcon in pairs(self.dropdownIcons) do
		otherIcon:leave()
	end
	-- Apply new icons
	if type(arrayOfIcons) == "table" then
		for i, otherIcon in pairs(arrayOfIcons) do
			otherIcon:join(self, "dropdown", true)
		end
	end
	-- Update dropdown
	self:_updateDropdown()
	return self
end

function Icon:_updateDropdown()
	local values = {
		maxIconsBeforeScroll = self:get("dropdownMaxIconsBeforeScroll") or "_NIL",
		minWidth = self:get("dropdownMinWidth") or "_NIL",
		padding = self:get("dropdownListPadding") or "_NIL",
		dropdownAlignment = self:get("dropdownAlignment") or "_NIL",
		iconAlignment = self:get("alignment") or "_NIL",
		scrollBarThickness = self:get("dropdownScrollBarThickness") or "_NIL",
	}
	for k, v in pairs(values) do
		if v == "_NIL" then
			return
		end
	end

	local YPadding = values.padding.Offset
	local dropdownContainer = self.instances.dropdownContainer
	local dropdownFrame = self.instances.dropdownFrame
	local dropdownList = self.instances.dropdownList
	local totalIcons = #self.dropdownIcons

	local lastVisibleIconIndex = (totalIcons > values.maxIconsBeforeScroll and values.maxIconsBeforeScroll)
		or totalIcons
	local newCanvasSizeY = -YPadding
	local newFrameSizeY = 0
	local newMinWidth = values.minWidth
	table.sort(self.dropdownIcons, function(a, b)
		return a:get("order") < b:get("order")
	end)
	for i = 1, totalIcons do
		local otherIcon = self.dropdownIcons[i]
		local _, otherIconSize = otherIcon:get("iconSize", nil, "beforeDropdown")
		local increment = otherIconSize.Y.Offset + YPadding
		if i <= lastVisibleIconIndex then
			newFrameSizeY = newFrameSizeY + increment
		end
		if i == totalIcons then
			newFrameSizeY = newFrameSizeY + increment / 4
		end
		newCanvasSizeY = newCanvasSizeY + increment
		local otherIconWidth = otherIconSize.X.Offset --+ 4 + 100 -- the +100 is to allow for notices
		if otherIconWidth > newMinWidth then
			newMinWidth = otherIconWidth
		end
	end

	local finalCanvasSizeY = (lastVisibleIconIndex == totalIcons and 0) or newCanvasSizeY
	self:set("dropdownCanvasSize", UDim2.new(0, 0, 0, finalCanvasSizeY))
	self:set("dropdownSize", UDim2.new(0, (newMinWidth + 4) * 2, 0, newFrameSizeY))

	-- Set alignment while considering screen bounds
	local dropdownAlignment = values.dropdownAlignment:lower()
	local alignmentDetails = {
		left = {
			AnchorPoint = Vector2.new(0, 0),
			PositionXScale = 0,
			ThicknessMultiplier = 0,
		},
		mid = {
			AnchorPoint = Vector2.new(0.5, 0),
			PositionXScale = 0.5,
			ThicknessMultiplier = 0.5,
		},
		right = {
			AnchorPoint = Vector2.new(0.5, 0),
			PositionXScale = 1,
			FrameAnchorPoint = Vector2.new(0, 0),
			FramePositionXScale = 0,
			ThicknessMultiplier = 1,
		},
	}
	local alignmentDetail = alignmentDetails[dropdownAlignment]
	if not alignmentDetail then
		alignmentDetail = alignmentDetails[values.iconAlignment:lower()]
	end
	dropdownContainer.AnchorPoint = alignmentDetail.AnchorPoint
	dropdownContainer.Position = UDim2.new(alignmentDetail.PositionXScale, 0, 1, YPadding + 0)
	local scrollbarThickness = values.scrollBarThickness
	local newThickness = scrollbarThickness * alignmentDetail.ThicknessMultiplier
	local additionalOffset = (
		dropdownFrame.VerticalScrollBarPosition == Enum.VerticalScrollBarPosition.Right and newThickness
	) or -newThickness
	dropdownFrame.AnchorPoint = alignmentDetail.FrameAnchorPoint or alignmentDetail.AnchorPoint
	dropdownFrame.Position =
		UDim2.new(alignmentDetail.FramePositionXScale or alignmentDetail.PositionXScale, additionalOffset, 0, 0)
	self._dropdownCanvasPos = Vector2.new(0, 0)
end

function Icon:_dropdownIgnoreClipping()
	self:_ignoreClipping("dropdown")
end
