local x=script.Parent.Parent local C=require(x:WaitForChild("\076\097\122\121\076\111\097\100\101\114"))local I=x:WaitForChild("\068\101\102\097\117\108\116\115")local N=I:WaitForChild("\067\104\101\099\107\098\111\120\076\097\098\101\108")local X={}X.__index=X X.__type="\067\104\101\099\107\098\111\120\076\097\098\101\108"function X.__tostring(x)return X.__type end function X.new(x)local I=setmetatable({},X)I._Maid=C.Utilities.Maid.new()I._ChangedBind=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")I.Frame=x I.Button=x.CheckContainer.CheckButton I.Changed=I._ChangedBind.Event init(I)I:SetValue(false)return I end function X.Create(x)local C=N:Clone()C.Label.Text=x return X.new(C)end function init(x)local C=x.Frame.CheckContainer local I=x.Button.Checkmark x._Maid:Mark(x.Button.Activated:Connect(function()x:SetValue(not I.Visible)end))end function X.GetValue(x)return x.Button.Checkmark.Visible end function X.SetValue(C,x)x=not(not x)local I=C.Frame.CheckContainer local N=I.BackgroundColor3 local X=I.BorderColor3 local a=I.Outline.BackgroundColor3 local O=x and X or a if x and I.CheckButton.BackgroundTransparency==1 then O=a end for x,C in next,I.Outline:GetChildren()do C.BackgroundColor3=O end I.CheckButton.BackgroundColor3=x and X or N I.CheckButton.Checkmark.Visible=x C._ChangedBind:Fire(x)end function X.Destroy(x)x._Maid:Sweep()x.Changed=nil end return X
--[[
Classes.CheckboxLabel

This class creates a single checkbox label

Constructors:
	new(frame [instance])
		>
	Create(text)
		> Creates a CheckboxLabel from the text provided.

Properties:
	Frame [instance]
		> The container frame for the CheckboxLabel. Can be used for positioning and resizing.
	Button [instance]
 		> The button used to track when the user clicks on the checkbox button or not

Methods:
	:GetValue() [boolean]
		> Returns whether the checkbox is selected or not.
	:SetValue(bool [boolean]) [void]
		> Sets if the checkbox is selected or not.
	:Destroy() [void]
		> Destroys the RadioButtonLabel and all the events, etc that were running it.

Events:
	.Changed:Connect(function(bool [boolean])
		> Fired when the user clicks the checkbox.
--]]


-- CONSTANTS

local GuiLib = script.Parent.Parent
local Lazy = require(GuiLib:WaitForChild("LazyLoader"))
local Defaults = GuiLib:WaitForChild("Defaults")

local CHECKBOX_LABEL = Defaults:WaitForChild("CheckboxLabel")

-- Class

local CheckboxLabelClass = {}
CheckboxLabelClass.__index = CheckboxLabelClass
CheckboxLabelClass.__type = "CheckboxLabel"

function CheckboxLabelClass:__tostring()
	return CheckboxLabelClass.__type
end

-- Public Constructors

function CheckboxLabelClass.new(frame)
	local self = setmetatable({}, CheckboxLabelClass)
	
	self._Maid = Lazy.Utilities.Maid.new()
	self._ChangedBind = Instance.new("BindableEvent")
	
	self.Frame = frame
	self.Button = frame.CheckContainer.CheckButton
	self.Changed = self._ChangedBind.Event
	
	init(self)
	self:SetValue(false)
	
	return self
end

function CheckboxLabelClass.Create(text)
	local cbLabel = CHECKBOX_LABEL:Clone()
	cbLabel.Label.Text = text
	return CheckboxLabelClass.new(cbLabel)
end

-- Private Methods

function init(self)
	--local label = self.Frame.Label
	local container = self.Frame.CheckContainer
	local checkmark = self.Button.Checkmark
	
	--local function contentSizeUpdate()
	--	local absSize = self.Frame.AbsoluteSize
	--	local ratio = absSize.y / absSize.x
	--	container.Size = UDim2.new(ratio, 0, 1, 0)
	--	label.Size = UDim2.new(1 - ratio, -10, 1, 0)
	--	label.Position = UDim2.new(ratio, 10, 0, 0)
	--end
	
	--contentSizeUpdate()
	--self._Maid:Mark(self.Frame:GetPropertyChangedSignal("AbsoluteSize"):Connect(contentSizeUpdate))
	
	self._Maid:Mark(self.Button.Activated:Connect(function()
		self:SetValue(not checkmark.Visible)
	end))
end

-- Public Methods

function CheckboxLabelClass:GetValue()
	return self.Button.Checkmark.Visible
end

function CheckboxLabelClass:SetValue(bool)
	bool = not not bool
	
	local container = self.Frame.CheckContainer
	local colorA = container.BackgroundColor3
	local colorB = container.BorderColor3
	local colorC = container.Outline.BackgroundColor3
	
	local outlineColor = bool and colorB or colorC
	if (bool and container.CheckButton.BackgroundTransparency == 1) then
		outlineColor = colorC
	end
	
	for _, child in next, container.Outline:GetChildren() do
		child.BackgroundColor3 = outlineColor
	end
	
	container.CheckButton.BackgroundColor3 = bool and colorB or colorA
	container.CheckButton.Checkmark.Visible = bool
	
	self._ChangedBind:Fire(bool)
end

function CheckboxLabelClass:Destroy()
	self._Maid:Sweep()
	--self.Frame:Destroy()
	self.Changed = nil
end

--

return CheckboxLabelClass