local L=Roact.PureComponent:extend(script.Name)function L.init(L)L.Maid=Maid.new()L.PaneSize,L.SetPaneSize=Roact.createBinding(UDim2.new())L:UpdateHistoryState()L.Maid.TrackHistory=L.props.Core.History.Changed:Connect(function()L:UpdateHistoryState()end)L:UpdateSelectionState()L.Maid.TrackSelection=L.props.Core.Selection.Changed:Connect(function()L:UpdateSelectionState()end)L:UpdateExplorerState()L.Maid.TrackExplorer=L.props.Core.ExplorerVisibilityChanged:Connect(function()L:UpdateExplorerState()end)end function L.UpdateHistoryState(L)L:setState({CanUndo=L.props.Core.History.Index>0,CanRedo=L.props.Core.History.Index~=#L.props.Core.History.Stack})end function L.UpdateSelectionState(L)L:setState({IsSelectionEmpty=#L.props.Core.Selection.Items==0})end function L.UpdateExplorerState(L)L:setState({IsExplorerOpen=L.props.Core.ExplorerVisible})end function L.willUnmount(L)L.Maid:Destroy()end function L.render(L)return new("\070\114\097\109\101",{BackgroundTransparency=.7;BackgroundColor3=Color3.fromRGB(0,0,0);BorderSizePixel=0,Size=L.PaneSize,LayoutOrder=L.props.LayoutOrder},{Corners=new("\085\073\067\111\114\110\101\114",{CornerRadius=UDim.new(0,3)}),SizeConstraint=new("\085\073\083\105\122\101\067\111\110\115\116\114\097\105\110\116",{MinSize=Vector2.new(70,0)}),Layout=new("\085\073\071\114\105\100\076\097\121\111\117\116",{CellPadding=UDim2.new(0,0,0,0);CellSize=UDim2.new(0,35,0,35),FillDirection=Enum.FillDirection.Horizontal;FillDirectionMaxCells=0,HorizontalAlignment=Enum.HorizontalAlignment.Left,VerticalAlignment=Enum.VerticalAlignment.Top,SortOrder=Enum.SortOrder.LayoutOrder;StartCorner=Enum.StartCorner.TopLeft;[Roact.Ref]=function(W)if W then L.SetPaneSize(UDim2.fromOffset(W.AbsoluteContentSize.X,W.AbsoluteContentSize.Y))end end;[Roact.Change.AbsoluteContentSize]=function(W)L.SetPaneSize(UDim2.fromOffset(W.AbsoluteContentSize.X,W.AbsoluteContentSize.Y))end}),UndoButton=new(SelectionButton,{LayoutOrder=0,IconAssetId="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\052\049\055\052\049\052\048\056";IsActive=L.state.CanUndo,OnActivated=L.props.Core.History.Undo,TooltipText="\060\098\062\085\078\068\079\060\047\098\062\060\098\114 \047\062\083\104\105\102\116-\090"});RedoButton=new(SelectionButton,{LayoutOrder=1,IconAssetId="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\052\049\055\052\049\051\050\055",IsActive=L.state.CanRedo,OnActivated=L.props.Core.History.Redo,TooltipText="\060\098\062\082\069\068\079\060\047\098\062\060\098\114 \047\062\083\104\105\102\116-\089"});DeleteButton=new(SelectionButton,{LayoutOrder=2,IconAssetId="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\052\049\056\057\054\050\057\056";IsActive=not L.state.IsSelectionEmpty,OnActivated=L.props.Core.DeleteSelection;TooltipText="\060\098\062\068\069\076\069\084\069\060\047\098\062\060\098\114 \047\062\083\104\105\102\116-\088"}),ExportButton=new(SelectionButton,{LayoutOrder=3;IconAssetId="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\052\049\055\052\049\051\051\055",IsActive=not L.state.IsSelectionEmpty,OnActivated=L.props.Core.ExportSelection,TooltipText="\060\098\062\069\088\080\079\082\084\060\047\098\062\060\098\114 \047\062\083\104\105\102\116-\080"}),CloneButton=new(SelectionButton,{LayoutOrder=4;IconAssetId="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\052\050\048\055\051\057\050\054",IsActive=not L.state.IsSelectionEmpty,OnActivated=L.props.Core.CloneSelection,TooltipText="\060\098\062\067\076\079\078\069\060\047\098\062\060\098\114 \047\062\083\104\105\102\116-\067"});ExplorerButton=new(SelectionButton,{LayoutOrder=5,IconAssetId="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\051\050\054\054\050\049\052\056\053",IsActive=L.state.IsExplorerOpen,OnActivated=L.props.Core.ToggleExplorer;TooltipText="\060\098\062\069\088\080\076\079\082\069\082\060\047\098\062\060\098\114 \047\062\083\104\105\102\116-\072"})})end return L

local SelectionPane = Roact.PureComponent:extend(script.Name)

function SelectionPane:init()
    self.Maid = Maid.new()
    self.PaneSize, self.SetPaneSize = Roact.createBinding(UDim2.new())

    self:UpdateHistoryState()
    self.Maid.TrackHistory = self.props.Core.History.Changed:Connect(function ()
        self:UpdateHistoryState()
    end)

    self:UpdateSelectionState()
    self.Maid.TrackSelection = self.props.Core.Selection.Changed:Connect(function ()
        self:UpdateSelectionState()
    end)

    self:UpdateExplorerState()
    self.Maid.TrackExplorer = self.props.Core.ExplorerVisibilityChanged:Connect(function ()
        self:UpdateExplorerState()
    end)
end

function SelectionPane:UpdateHistoryState()
    self:setState({
        CanUndo = (self.props.Core.History.Index > 0);
        CanRedo = (self.props.Core.History.Index ~= #self.props.Core.History.Stack);
    })
end

function SelectionPane:UpdateSelectionState()
    self:setState({
        IsSelectionEmpty = (#self.props.Core.Selection.Items == 0);
    })
end

function SelectionPane:UpdateExplorerState()
    self:setState({
        IsExplorerOpen = self.props.Core.ExplorerVisible;
    })
end

function SelectionPane:willUnmount()
    self.Maid:Destroy()
end

function SelectionPane:render()
    return new('Frame', {
        BackgroundTransparency = 0.7;
        BackgroundColor3 = Color3.fromRGB(0, 0, 0);
        BorderSizePixel = 0;
        Size = self.PaneSize;
        LayoutOrder = self.props.LayoutOrder;
    }, {
        Corners = new('UICorner', {
            CornerRadius = UDim.new(0, 3);
        });
        SizeConstraint = new('UISizeConstraint', {
            MinSize = Vector2.new(70, 0);
        });
        Layout = new('UIGridLayout', {
            CellPadding = UDim2.new(0, 0, 0, 0);
            CellSize = UDim2.new(0, 35, 0, 35);
            FillDirection = Enum.FillDirection.Horizontal;
            FillDirectionMaxCells = 0;
            HorizontalAlignment = Enum.HorizontalAlignment.Left;
            VerticalAlignment = Enum.VerticalAlignment.Top;
            SortOrder = Enum.SortOrder.LayoutOrder;
            StartCorner = Enum.StartCorner.TopLeft;
            [Roact.Ref] = function (rbx)
                if rbx then
                    self.SetPaneSize(UDim2.fromOffset(rbx.AbsoluteContentSize.X, rbx.AbsoluteContentSize.Y))
                end
            end;
            [Roact.Change.AbsoluteContentSize] = function (rbx)
                self.SetPaneSize(UDim2.fromOffset(rbx.AbsoluteContentSize.X, rbx.AbsoluteContentSize.Y))
            end;
        });

        UndoButton = new(SelectionButton, {
            LayoutOrder = 0;
            IconAssetId = 'rbxassetid://141741408';
            IsActive = self.state.CanUndo;
            OnActivated = self.props.Core.History.Undo;
            TooltipText = '<b>UNDO</b><br />Shift-Z';
        });
        RedoButton = new(SelectionButton, {
            LayoutOrder = 1;
            IconAssetId = 'rbxassetid://141741327';
            IsActive = self.state.CanRedo;
            OnActivated = self.props.Core.History.Redo;
            TooltipText = '<b>REDO</b><br />Shift-Y';
        });
        DeleteButton = new(SelectionButton, {
            LayoutOrder = 2;
            IconAssetId = 'rbxassetid://141896298';
            IsActive = not self.state.IsSelectionEmpty;
            OnActivated = self.props.Core.DeleteSelection;
            TooltipText = '<b>DELETE</b><br />Shift-X';
        });
        ExportButton = new(SelectionButton, {
            LayoutOrder = 3;
            IconAssetId = 'rbxassetid://141741337';
            IsActive = not self.state.IsSelectionEmpty;
            OnActivated = self.props.Core.ExportSelection;
            TooltipText = '<b>EXPORT</b><br />Shift-P';
        });
        CloneButton = new(SelectionButton, {
            LayoutOrder = 4;
            IconAssetId = 'rbxassetid://142073926';
            IsActive = not self.state.IsSelectionEmpty;
            OnActivated = self.props.Core.CloneSelection;
            TooltipText = '<b>CLONE</b><br />Shift-C';
        });
        ExplorerButton = new(SelectionButton, {
            LayoutOrder = 5;
            IconAssetId = 'rbxassetid://2326621485';
            IsActive = self.state.IsExplorerOpen;
            OnActivated = self.props.Core.ToggleExplorer;
            TooltipText = '<b>EXPLORER</b><br />Shift-H';
        });
    })
end

return SelectionPane
