<div class="d-flex flex-row w-100 overflow-x-auto p-1">
    <CascadingValue Value="@MapIsActive">
        <EditorFunctionToolbar @ref="EditorFunctionToolbarRef" EditorStateChanged="(async(state) => await EditorStateChanged.InvokeAsync(state))"
                               EditorZoneTypeChanged="(async(zonetype) => await EditorZoneTypeChanged.InvokeAsync(zonetype))" />
        <AlignmentToolbar MultiSelectedEdge="@MultiSelectedEdge" MultiSelectedNode="@MultiSelectedNode" EditorState="@EditorState"
                          AlignStateClick="(async(state) => await AlignStateClick.InvokeAsync(state))" 
                          EditorStateChanged="(async(state) => await EditorStateChanged.InvokeAsync(state))" />
        <ControlToolbar ShowGrid="@ShowGrid" ShowName="@ShowName" ShowMapSlam="@ShowMapSlam" NodesUndoable="@NodesUndoable"
                        ControlStateClick="(async(state) => await ControlStateClick.InvokeAsync(state))"
                        EditorExtensionChanged="(async (data) => await EditorExtensionChanged.InvokeAsync(data))"
                        ZoneSelected="@ZoneSelected"
                        MultiSelectedEdge="@MultiSelectedEdge" />
    </CascadingValue>
</div>

@code {
    [Parameter]
    public bool MapIsActive { get; set; }

    [Parameter]
    public EventCallback<EditorState> EditorStateChanged { get; set; }

    [Parameter]
    public EventCallback<ZoneType> EditorZoneTypeChanged { get; set; }

    [Parameter]
    public EditorState EditorState { get; set; }

    [Parameter]
    public bool MultiSelectedNode { get; set; }

    [Parameter]
    public bool MultiSelectedEdge { get; set; }

    [Parameter]
    public bool ZoneSelected { get; set; }

    [Parameter]
    public EventCallback<AlignState> AlignStateClick { get; set; }

    [Parameter]
    public EventCallback<ControlState> ControlStateClick { get; set; }

    [Parameter]
    public EventCallback<(ControlState, bool)> EditorExtensionChanged { get; set; }

    [Parameter]
    public bool ShowGrid { get; set; }

    [Parameter]
    public bool ShowName { get; set; }

    [Parameter]
    public bool ShowMapSlam { get; set; }

    [Parameter]
    public bool NodesUndoable { get; set; }

    private EditorFunctionToolbar EditorFunctionToolbarRef = null!;

    public void SetEditorState(EditorState state) => EditorFunctionToolbarRef.SetEditorState(state);
}
