Frame.defaultProps={BackgroundTransparency=1,BorderSizePixel=0,Size=UDim2.new(1,0,1,0)}function Frame.render(v)local f=Support.CloneTable(v.props)local q=v.state if f.AspectRatio then local v=new("\085\073\065\115\112\101\099\116\082\097\116\105\111\067\111\110\115\116\114\097\105\110\116",{AspectRatio=f.AspectRatio})f[Roact.Children]=Support.Merge({AspectRatio=v},f[Roact.Children]or{})if f.DominantAxis=="\087\105\100\116\104"then f.SizeConstraint="\082\101\108\097\116\105\118\101\088\088"if typeof(f.Width)=="\085\068\105\109"then f.Height=UDim.new(f.Width.Scale/f.AspectRatio,0)else f.Size=UDim2.new(f.Size.X,UDim.new(f.Size.X.Scale/f.AspectRatio,0))end elseif f.DominantAxis=="\072\101\105\103\104\116"then f.SizeConstraint="\082\101\108\097\116\105\118\101\089\089"if typeof(f.Height)=="\085\068\105\109"then f.Width=UDim.new(f.Height.Scale*f.AspectRatio,0)else f.Size=UDim2.new(UDim.new(f.Size.Y.Scale*f.AspectRatio,0),f.Size.Y)end end end if f.Layout=="\076\105\115\116"then local q=new("\085\073\076\105\115\116\076\097\121\111\117\116",{FillDirection=f.LayoutDirection,Padding=f.LayoutPadding;HorizontalAlignment=f.HorizontalAlignment;VerticalAlignment=f.VerticalAlignment,SortOrder=f.SortOrder or"\076\097\121\111\117\116\079\114\100\101\114";[Roact.Ref]=function(f)v:UpdateContentSize(f)end;[Roact.Change.AbsoluteContentSize]=function(f)v:UpdateContentSize(f)end})f.Size=v:GetSize()f[Roact.Children]=Support.Merge({Layout=q},f[Roact.Children])end f.AspectRatio=nil f.DominantAxis=nil f.Layout=nil f.LayoutDirection=nil f.LayoutPadding=nil f.HorizontalAlignment=nil f.VerticalAlignment=nil f.HorizontalPadding=nil f.VerticalPadding=nil f.SortOrder=nil f.Width=nil f.Height=nil f.ResizeParent=nil return new("\070\114\097\109\101",f)end function Frame.GetSize(f,v)local q=f.props local z=q.Size=="\087\082\065\080\095\067\079\078\084\069\078\084"or q.Width=="\087\082\065\080\095\067\079\078\084\069\078\084"local W=q.Size=="\087\082\065\080\095\067\079\078\084\069\078\084"or q.Height=="\087\082\065\080\095\067\079\078\084\069\078\084"local l=z or W local Z=UDim2.new(0,q.HorizontalPadding or 0,0,q.VerticalPadding or 0)return Z+UDim2.new((v and z)and UDim.new(0,v.X)or typeof(q.Width)=="\085\068\105\109"and q.Width or q.Size.X,(v and W)and UDim.new(0,v.Y)or typeof(q.Height)=="\085\068\105\109"and q.Height or q.Size.Y)end function Frame.UpdateContentSize(f,v)if not(v and v.Parent)then return end v.Parent.Size=f:GetSize(v.AbsoluteContentSize)local q=f.props.ResizeParent local z=q and v.Parent.Parent if q and z then local f=z.Size.X local W=z.Size.Y if Support.IsInTable(q,"\087\073\068\084\072")then f=UDim.new(0,v.Parent.AbsoluteSize.X)end if Support.IsInTable(q,"\072\069\073\071\072\084")then W=UDim.new(0,v.Parent.AbsoluteSize.Y)end z.Size=UDim2.new(f,W)end end return Frame

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.LayoutPadding,
            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.LayoutPadding = 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
