import { TemplateResult } from 'lit';
import { type ISplitItem, SplitItem } from './SplitItem.js';
import { type ISplitPanel, SplitPanel } from './SplitPanel.js';
import SplitView from './SplitView.js';
import { IPanelObject, LayoutType, SplitItemRenderCallback, SplitLayoutAddOptions, SplitLayoutInit, SplitPanelAddOptions } from './type.js';
interface LayoutObject {
    type: LayoutType;
    value: SplitItem | SplitPanel;
}
interface SerializedLayoutObject {
    type: LayoutType;
    value: ISplitItem | ISplitPanel;
}
export interface ISplitLayout {
    /**
     * The map of all definitions of panels and
     */
    definitions: SerializedLayoutObject[];
    /**
     * The ordered list of panel keys in the view.
     */
    items: string[];
    /**
     * The key of the active panel or item.
     * From here it can be deduced whether the active item is a panel or an item and what's the active panel.
     */
    active?: string;
}
export interface ITabCloseDetail {
    tab: string;
    panel: string;
}
/**
 * Split layout manager creates a view where the application can put "items" into
 * and render them inside "panels". The application can create as many panels as needed.
 * Panels can be layout vertically or horizontally.
 *
 * ## Basic usage
 *
 * ```javascript
 * const layout = new SplitLayout({
 *  stateCallback: async (state: ISplitLayout): Promise<void> => {
 *    localStorage.setItem('layout', JSON.stringify(state));
 *  }
 * });
 * const restored = await readStoredState(); // a function that reads the state from the store
 * await layout.initialize(restored);
 *
 * const content = layout.render((itemToRender: SplitItem): TemplateResult => { return html`...` });
 * ```
 *
 * Each time the layout configuration change the optional `stateCallback` function
 * is called.
 * It's not mandatory to set this callback function but if you want the state to
 * persist you have to serialize the manager manually when needed.
 * Since the manage implement the `toJSON()` method it is safe to pass the instance of the manager
 * to a idb store or serialize with `JSON.stringify()`.
 *
 * @fires change - When the layout configuration change. This is the best time to perform DOM update.
 * @fires nameitem - When the layout requests to name an item. This usually happens then a code calls
 *                   the `requestNameUpdate()` method after the item's name changed.
 * @fires closetab - When a tab wa closed via a user interaction.
 */
export declare class SplitLayout extends EventTarget {
    options: SplitLayoutInit;
    /**
     * The list of all definitions of panels and items.
     */
    definitions: Map<string, LayoutObject>;
    /**
     * Holds an ordered list of panels in the layout.
     * Though, this interface is consistent with other panels, it can only keep panels, not items.
     */
    items: IPanelObject[];
    private activeInternal?;
    /**
     * The key of the panel that is marked as "active", that is,
     * the panel the user last interacted with.
     */
    get active(): string | undefined;
    /**
     * Returns an object that is marked as active or undefined if none is marked as active.
     */
    get activeObject(): LayoutObject | undefined;
    /**
     * An active panel that the user last interacted with.
     */
    get activePanel(): SplitPanel | undefined;
    /**
     * An active panel item that the user last interacted with.
     */
    get activeItem(): SplitItem | undefined;
    /**
     * Whether the manager is dirty, that is, a change ocurred
     * while storing the layout.
     */
    protected isDirty: boolean;
    /**
     * A flag that determines that the state is being stored in the store.
     */
    protected storing: boolean;
    /**
     * The value of the debouncer timeout.
     */
    protected debouncer?: number;
    constructor(options?: SplitLayoutInit);
    /**
     * Initializes the split layout manager.
     * When passed the `state` parameter it restores the previously serialized state.
     *
     * @param state A state to restore. When not set an empty layout is rendered.
     */
    initialize(state?: ISplitLayout): void;
    protected reset(): void;
    /**
     * Clears the state and disposes of all resources.
     */
    dispose(): void;
    /**
     * Overrides the current state.
     * Note, this operation does not call the `stateCallback()` callback.
     * @param state the state to set.
     */
    new(state: ISplitLayout): void;
    toJSON(): ISplitLayout;
    /**
     * Schedules a layout store operation in a debouncer.
     * Once active all other request to store the layout are ignored until
     * the timeout is triggered.
     */
    scheduleStore(): void;
    /**
     * This function is called automatically when the store configuration
     * change. There's no need to call it manually unless you want to trigger
     * the storing state flow. However, at that moment the state is already stored
     * (unless there was an error).
     */
    storeLayout(): Promise<void>;
    protected handleFocusIn(e: Event): void;
    /**
     * Sets an active panel or item.
     * @param panelOrItemKey the key of the panel or item that is active.
     */
    setActive(panelOrItemKey: string): void;
    protected findViewFromEvent(e: Event): SplitView | undefined;
    /**
     * @param panelKey The panel key to search for the view for.
     * @returns The `split-view` element in the document
     */
    findView(panelKey: string): SplitView | undefined;
    /**
     * Finds parents an item or another panel is anchored to.
     * An item can have multiple parents. A panel can only have a single parent.
     *
     * @param itemOrPanelKey The key of the panel or an item.
     * @returns THe list of panels the item is added. It can only return up to 1 result when looking for a panel's parent.
     */
    getParents(itemOrPanelKey: string): SplitPanel[];
    /**
     * Finds a panel by id.
     *
     * @param panelKey The id of the panel.
     * @returns The panel if found
     */
    findPanel(panelKey: string): SplitPanel | undefined;
    /**
     * Finds a panel item by id.
     *
     * @param itemKey The id of the panel item.
     * @returns The item if found
     */
    findItem(itemKey: string): SplitItem | undefined;
    /**
     * Informs the screen that something has changed
     */
    notifyChange(): void;
    /**
     * Dispatches the `nameitem` event.
     * The detail object has the item to be added to the items.
     * The event handler can manipulate properties of the item, except for the index which will be set by the manager.
     *
     * Note, use the `requestNameUpdate()` when requesting a name update. The other method includes side
     * effects like updating the view.
     *
     * @param item The item to notify.
     */
    dispatchNameItem(item: SplitItem): void;
    /**
     * Do not call this method from the outside of the layout manager logic.
     * It is a way to communicate a tab was closed.
     */
    notifyTabClose(itemKey: string, panel: string): void;
    /**
     * Requests an update on the view element.
     *
     * @param panelKey The id of the panel. When not set it uses the active panel
     */
    updateView(panelKey?: string): void;
    /**
     * Requests to dispatch the `nameitem` event so the application can update the name of the tab.
     *
     * @param itemKey The key of the item.
     */
    requestNameUpdate(itemKey: string): void;
    /**
     * Dispatches the `nameitem` event so the application
     * can update the name of an item that has a specific `parent`.
     *
     * @param parentValue The key of the `parent` property to look for.
     */
    requestNameUpdateByParent(parentValue: string): void;
    /**
     * A shortcut to rename an item.
     * @param itemKey The key of the item to rename
     * @param label The label to set. It won't trigger side effects if the label is the same.
     */
    setItemLabel(itemKey: string, label: string): void;
    addPanel(opts?: SplitPanelAddOptions): SplitPanel;
    /**
     * Adds an item to the active panel.
     *
     * To add an item to a specific panel find a reference to
     * the panel instance and call `addItem()` there.
     *
     * @param item The item to add.
     */
    addItem(item: ISplitItem): SplitItem;
    /**
     * Removes an item from the layout. This means removing an item from all panels.
     * If you want to remove an item from a specific panel then find the panel first and then call `removeItem()`.
     *
     * @param key The key of the item to remove.
     */
    removeItem(key: string): void;
    /**
     * Moves a tab between panels or inside a panel
     *
     * @param fromPanelKey The id of the source panel of the item
     * @param toPanelKey The id of the target panel of the item
     * @param itemKey The key of the item
     * @param toIndex The index to which add the item. Default as the last.
     */
    moveItem(fromPanelKey: string, toPanelKey: string, itemKey: string, opts?: SplitLayoutAddOptions): void;
    /**
     * Iterates over panels from the root.
     * This iterates the panels structure in order defined in the `items` array on
     * each panel.
     *
     * @param parentPanel The parent SplitLayout to start the iteration from.
     */
    panelIterator(parentPanel?: SplitPanel): Generator<SplitPanel>;
    /**
     * Iterates over items that have specific `parent` property set.
     *
     * This is useful to close multiple object that belong to a parent.
     *
     * @param key The key of the `parent` property of a `SplitItem` to include in the iteration
     * @param parentPanel The `SplitPanel` to start the iteration from.
     */
    parentItemsIterator(key: string, parentPanel?: SplitPanel): Generator<SplitItem>;
    /**
     * Finds all items in all panels that have specified parent.
     * @param parentValue The key of the parent to search for.
     */
    removeByParent(parentValue: string): void;
    /**
     * Checks whether the item with the given key is already managed by the manager.
     * @param itemKey The key of the item to check
     * @returns true if the item is in the definitions.
     */
    hasItem(itemKey: string): boolean;
    /**
     * Selects an item in a panel.
     *
     * When the parent is give then it tries to select the item on that panel.
     * Otherwise it checks whether the item is in the current panel and if so it selects it.
     * Otherwise, it selects the item on a first panel the item is in.
     *
     * @param itemKey The key of the item to set selected in the view.
     * @param panelKey The optional panel key. When not set it finds the first panel the item is on.
     */
    selectItem(itemKey: string, panelKey?: string): void;
    /**
     * Checks whether the manager has at least one panel that has items.
     *
     * This is useful to render the empty state when no items are added.
     */
    isEmpty(): boolean;
    render(itemCallback: SplitItemRenderCallback): TemplateResult[];
}
export {};
//# sourceMappingURL=SplitLayout.d.ts.map