local Z=Cheer.CreateComponent("\066\084\068\114\111\112\100\111\119\110",View)function Z.Start(H,S,w)Cheer.Bind(View,Z.Toggle)Z.Draw(H,S,w)return Z end function Z.Toggle()local Z=View.Options:GetChildren()for Z,H in pairs(Z)do H.Visible=not H.Visible end end function Z.SetOption(Z)View.CurrentOption.Text=Z:upper()end function Z.Draw(H,S,w)View.Options:ClearAllChildren()for H,S in ipairs(H)do local e=View.OptionButton:Clone()e.Parent=View.Options e.OptionLabel.Text=S:upper()e.MouseButton1Click:Connect(function()w(S)Z.SetOption(S)Z.Toggle()end)e.Position=UDim2.new(math.ceil(H/9)-1,(e.Position.X.Offset+math.ceil(H/9)*-1)+1,(H%9==0 and 9 or H%9)*e.Size.Y.Scale,e.Position.Y.Offset)end View.Visible=true end return Z
-- Create component
local Component = Cheer.CreateComponent("BTDropdown", View)

function Component.Start(Options, CurrentOption, Callback)
	-- Toggle options when clicked
	Cheer.Bind(View, Component.Toggle)

	-- Draw the component with the given options
	Component.Draw(Options, CurrentOption, Callback)

	-- Return component for chaining
	return Component
end

function Component.Toggle()
	-- Toggles the visibility of the dropdown options

	-- Show each option button open or closed
	local Buttons = View.Options:GetChildren()
	for _, Button in pairs(Buttons) do
		Button.Visible = not Button.Visible
	end
end

function Component.SetOption(Option)
	-- Draws the current option into the dropdown

	-- Set the label
	View.CurrentOption.Text = Option:upper()
end

function Component.Draw(Options, CurrentOption, Callback)
	-- Draws the dropdown with the given data

	-- Clear existing buttons
	View.Options:ClearAllChildren()

	-- Create a button for each option
	for Index, Option in ipairs(Options) do
		-- Create the button
		local Button = View.OptionButton:Clone()
		Button.Parent = View.Options
		Button.OptionLabel.Text = Option:upper()
		Button.MouseButton1Click:Connect(function()
			Callback(Option)
			Component.SetOption(Option)
			Component.Toggle()
		end)

		-- Position the button
		Button.Position = UDim2.new(
			math.ceil(Index / 9) - 1,
			Button.Position.X.Offset + (math.ceil(Index / 9) * -1) + 1,
			(Index % 9 == 0 and 9 or Index % 9) * Button.Size.Y.Scale,
			Button.Position.Y.Offset
		)
	end

	-- Show the view
	View.Visible = true
end

return Component
