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("\082\097\100\105\111\066\117\116\116\111\110\076\097\098\101\108")local X={}X.__index=X X.__type="\082\097\100\105\111\066\117\116\116\111\110\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.Frame=x I.Button=x.RadioContainer.RadioButton 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.Label local I=x.Frame.RadioContainer local function N()local N=x.Frame.AbsoluteSize local X=N.y/N.x I.Size=UDim2.new(X,0,1,0)C.Size=UDim2.new(1-X,-10,1,0)C.Position=UDim2.new(X,10,0,0)end N()x._Maid:Mark((x.Frame:GetPropertyChangedSignal("\065\098\115\111\108\117\116\101\083\105\122\101")):Connect(N))end function X.GetValue(x)return x.Button.Circle.Visible end function X.SetValue(C,x)x=not(not x)local I=C.Frame.RadioContainer local N=I.BorderColor3 local X=I.BackgroundColor3 I.Outline.ImageColor3=x and N or X I.RadioButton.Circle.Visible=x end function X.Destroy(x)x._Maid:Sweep()x.Frame:Destroy()end return X
--[[
Classes.RadioButtonLabel

This class creates a single radio button label.

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

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

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

-- CONSTANTS

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

local RADIOBUTTON_LABEL = Defaults:WaitForChild("RadioButtonLabel")

-- Class

local RadioButtonLabelClass = {}
RadioButtonLabelClass.__index = RadioButtonLabelClass
RadioButtonLabelClass.__type = "RadioButtonLabel"

function RadioButtonLabelClass:__tostring()
	return RadioButtonLabelClass.__type
end

-- Public Constructors

function RadioButtonLabelClass.new(frame)
	local self = setmetatable({}, RadioButtonLabelClass)
	
	self._Maid = Lazy.Utilities.Maid.new()
	
	self.Frame = frame
	self.Button = frame.RadioContainer.RadioButton
	
	init(self)
	self:SetValue(false)
	
	return self
end

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

-- Private Methods

function init(self)
	local label = self.Frame.Label
	local container = self.Frame.RadioContainer
	
	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))
end

-- Public Methods

function RadioButtonLabelClass:GetValue()
	return self.Button.Circle.Visible
end

function RadioButtonLabelClass:SetValue(bool)
	bool = not not bool
	
	local container = self.Frame.RadioContainer
	local colorA = container.BorderColor3
	local colorB = container.BackgroundColor3
	
	container.Outline.ImageColor3 = bool and colorA or colorB
	container.RadioButton.Circle.Visible = bool
end

function RadioButtonLabelClass:Destroy()
	self._Maid:Sweep()
	self.Frame:Destroy()
end

--

return RadioButtonLabelClass