local q=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local Q=q:WaitForChild("\077\111\100\117\108\101\115")local R=require(Q.src.utils.Logger)local j=((game:GetService("\083\116\097\114\116\101\114\080\108\097\121\101\114")):WaitForChild("\083\116\097\114\116\101\114\080\108\097\121\101\114\083\099\114\105\112\116\115")).clientSrc local E=require(Q.Roact)local x=require(Q.src.utils.SupportLibrary)local F=E.createElement local J=E.PureComponent:extend("\070\114\097\109\101")J.defaultProps={BackgroundTransparency=1,BorderSizePixel=0;Size=UDim2.new(1,0,1,0)}function J.render(q)local Q=x.CloneTable(q.props)local R=q.state if Q.AspectRatio then local q=F("\085\073\065\115\112\101\099\116\082\097\116\105\111\067\111\110\115\116\114\097\105\110\116",{AspectRatio=Q.AspectRatio})Q[E.Children]=x.Merge({AspectRatio=q},Q[E.Children]or{})if Q.DominantAxis=="\087\105\100\116\104"then Q.SizeConstraint="\082\101\108\097\116\105\118\101\088\088"if typeof(Q.Width)=="\085\068\105\109"then Q.Height=UDim.new(Q.Width.Scale/Q.AspectRatio,0)else Q.Size=UDim2.new(Q.Size.X,UDim.new(Q.Size.X.Scale/Q.AspectRatio,0))end elseif Q.DominantAxis=="\072\101\105\103\104\116"then Q.SizeConstraint="\082\101\108\097\116\105\118\101\089\089"if typeof(Q.Height)=="\085\068\105\109"then Q.Width=UDim.new(Q.Height.Scale*Q.AspectRatio,0)else Q.Size=UDim2.new(UDim.new(Q.Size.Y.Scale*Q.AspectRatio,0),Q.Size.Y)end end end if Q.Layout=="\076\105\115\116"then local R=F("\085\073\076\105\115\116\076\097\121\111\117\116",{FillDirection=Q.LayoutDirection;Padding=Q.Padding,HorizontalAlignment=Q.HorizontalAlignment,VerticalAlignment=Q.VerticalAlignment,SortOrder=Q.SortOrder or"\076\097\121\111\117\116\079\114\100\101\114";[E.Ref]=function(Q)q:UpdateContentSize(Q)end;[E.Change.AbsoluteContentSize]=function(Q)q:UpdateContentSize(Q)end})Q.Size=q:GetSize()Q[E.Children]=x.Merge({Layout=R},Q[E.Children])end Q.AspectRatio=nil Q.DominantAxis=nil Q.Layout=nil Q.LayoutDirection=nil Q.Padding=nil Q.HorizontalAlignment=nil Q.VerticalAlignment=nil Q.HorizontalPadding=nil Q.VerticalPadding=nil Q.SortOrder=nil Q.Width=nil Q.Height=nil Q.ResizeParent=nil return F("\070\114\097\109\101",Q)end function J.GetSize(Q,q)local R=Q.props local j=R.Size=="\087\082\065\080\095\067\079\078\084\069\078\084"or R.Width=="\087\082\065\080\095\067\079\078\084\069\078\084"local E=R.Size=="\087\082\065\080\095\067\079\078\084\069\078\084"or R.Height=="\087\082\065\080\095\067\079\078\084\069\078\084"local x=j or E local F=UDim2.new(0,R.HorizontalPadding or 0,0,R.VerticalPadding or 0)return F+UDim2.new((q and j)and UDim.new(0,q.X)or typeof(R.Width)=="\085\068\105\109"and R.Width or R.Size.X,(q and E)and UDim.new(0,q.Y)or typeof(R.Height)=="\085\068\105\109"and R.Height or R.Size.Y)end function J.UpdateContentSize(Q,q)if not(q and q.Parent)then return end q.Parent.Size=Q:GetSize(q.AbsoluteContentSize)local R=Q.props.ResizeParent local j=R and q.Parent.Parent if R and j then local Q=j.Size.X local E=j.Size.Y if x.IsInTable(R,"\087\073\068\084\072")then Q=UDim.new(0,q.Parent.AbsoluteSize.X)end if x.IsInTable(R,"\072\069\073\071\072\084")then E=UDim.new(0,q.Parent.AbsoluteSize.Y)end j.Size=UDim2.new(Q,E)end end return J
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local logger = require(Modules.src.utils.Logger)
local clientSrc = game:GetService('StarterPlayer'):WaitForChild('StarterPlayerScripts').clientSrc

local Roact = require(Modules.Roact)
local Support = require(Modules.src.utils.SupportLibrary)

-- Roact
local new = Roact.createElement

-- Create component
local Frame = Roact.PureComponent:extend'Frame'

-- Set defaults
Frame.defaultProps = {
	BackgroundTransparency = 1,
	BorderSizePixel = 0,
	Size = UDim2.new(1, 0, 1, 0),
}

function Frame:render()
	local props = Support.CloneTable(self.props)
	local state = self.state

	-- Include aspect ratio constraint if specified
	if props.AspectRatio then
		local Constraint = new('UIAspectRatioConstraint', { AspectRatio = props.AspectRatio })

		-- Insert constraint into children
		props[Roact.Children] = Support.Merge({ AspectRatio = Constraint }, props[Roact.Children] or {})

		-- Base height off width using the aspect ratio
		if props.DominantAxis == 'Width' then
			props.SizeConstraint = 'RelativeXX'
			if typeof(props.Width) == 'UDim' then
				props.Height = UDim.new(props.Width.Scale / props.AspectRatio, 0)
			else
				props.Size = UDim2.new(props.Size.X, UDim.new(props.Size.X.Scale / props.AspectRatio, 0))
			end

			-- Base width off height using the aspect ratio
		elseif props.DominantAxis == 'Height' then
			props.SizeConstraint = 'RelativeYY'
			if typeof(props.Height) == 'UDim' then
				props.Width = UDim.new(props.Height.Scale * props.AspectRatio, 0)
			else
				props.Size = UDim2.new(UDim.new(props.Size.Y.Scale * props.AspectRatio, 0), props.Size.Y)
			end
		end
	end

	-- Include list layout if specified
	if props.Layout == 'List' then
		local Layout = new('UIListLayout', {
			FillDirection = props.LayoutDirection,
			Padding = props.Padding,
			HorizontalAlignment = props.HorizontalAlignment,
			VerticalAlignment = props.VerticalAlignment,
			SortOrder = props.SortOrder or 'LayoutOrder',
			[Roact.Ref] = function(rbx)
				self:UpdateContentSize(rbx)
			end,
			[Roact.Change.AbsoluteContentSize] = function(rbx)
				self:UpdateContentSize(rbx)
			end,
		})

		-- Update size
		props.Size = self:GetSize()

		-- Insert layout into children
		props[Roact.Children] = Support.Merge({ Layout = Layout }, props[Roact.Children])
	end

	-- Filter out custom properties
	props.AspectRatio = nil
	props.DominantAxis = nil
	props.Layout = nil
	props.LayoutDirection = nil
	props.Padding = nil
	props.HorizontalAlignment = nil
	props.VerticalAlignment = nil
	props.HorizontalPadding = nil
	props.VerticalPadding = nil
	props.SortOrder = nil
	props.Width = nil
	props.Height = nil
	props.ResizeParent = nil

	-- Display component in wrapper
	return new('Frame', props)
end

function Frame:GetSize(ContentSize)
	local props = self.props

	-- Determine dynamic dimensions
	local DynamicWidth = props.Size == 'WRAP_CONTENT' or props.Width == 'WRAP_CONTENT'
	local DynamicHeight = props.Size == 'WRAP_CONTENT' or props.Height == 'WRAP_CONTENT'
	local DynamicSize = DynamicWidth or DynamicHeight

	-- Get padding from props
	local Padding = UDim2.new(0, props.HorizontalPadding or 0, 0, props.VerticalPadding or 0)

	-- Calculate size based on content if dynamic
	return Padding + UDim2.new(
		(ContentSize and DynamicWidth) and UDim.new(0, ContentSize.X) or (typeof(props.Width) == 'UDim' and props.Width or props.Size.X),
		(ContentSize and DynamicHeight) and UDim.new(0, ContentSize.Y) or (typeof(props.Height) == 'UDim' and props.Height or props.Size.Y)
	)
end

function Frame:UpdateContentSize(Layout)
	if not (Layout and Layout.Parent) then return end

	-- Set container size based on content
	Layout.Parent.Size = self:GetSize(Layout.AbsoluteContentSize)

	-- Set parent size based on content if specified
	local ResizeParent = self.props.ResizeParent
	local Parent = ResizeParent and Layout.Parent.Parent
	if ResizeParent and Parent then
		local ParentWidth = Parent.Size.X
		local ParentHeight = Parent.Size.Y
		if Support.IsInTable(ResizeParent, 'WIDTH') then
			ParentWidth = UDim.new(0, Layout.Parent.AbsoluteSize.X)
		end
		if Support.IsInTable(ResizeParent, 'HEIGHT') then
			ParentHeight = UDim.new(0, Layout.Parent.AbsoluteSize.Y)
		end
		Parent.Size = UDim2.new(ParentWidth, ParentHeight)
	end
end

return Frame