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