import { HeaderContentDefinition, IconValue, ShellConfig, ToolbarContentDefinition, ToolPanelDefinition } from '../types';
/**
 * State for managing shell UI.
 *
 * This interface holds both configuration-like properties (toolPanels, headerContents)
 * and runtime state (isPanelOpen, expandedSections). The Maps allow for efficient
 * registration/unregistration of panels and content.
 */
export interface ShellState {
    /** Registered tool panels (from plugins + consumer API) */
    toolPanels: Map<string, ToolPanelDefinition>;
    /** Registered header content (from plugins + consumer API) */
    headerContents: Map<string, HeaderContentDefinition>;
    /** Toolbar content registered via API or light DOM */
    toolbarContents: Map<string, ToolbarContentDefinition>;
    /** Whether a <tbw-grid-tool-buttons> container was found in light DOM */
    hasToolButtonsContainer: boolean;
    /** Light DOM header content elements */
    lightDomHeaderContent: HTMLElement[];
    /** Light DOM header title from <tbw-grid-header title="..."> */
    lightDomTitle: string | null;
    /** IDs of tool panels registered from light DOM (to avoid re-parsing) */
    lightDomToolPanelIds: Set<string>;
    /** IDs of toolbar content registered from light DOM (to avoid re-parsing) */
    lightDomToolbarContentIds: Set<string>;
    /** IDs of tool panels registered via registerToolPanel API */
    apiToolPanelIds: Set<string>;
    /** Whether the tool panel sidebar is open */
    isPanelOpen: boolean;
    /** Which accordion sections are expanded (by panel ID) */
    expandedSections: Set<string>;
    /** Whether light DOM header content has been moved to placeholder (perf optimization) */
    lightDomContentMoved: boolean;
    /** Cleanup functions for header content render returns */
    headerContentCleanups: Map<string, () => void>;
    /** Cleanup functions for each panel section's render return */
    panelCleanups: Map<string, () => void>;
    /** Cleanup functions for toolbar content render returns */
    toolbarContentCleanups: Map<string, () => void>;
}
/**
 * Runtime-only shell state (not configuration).
 *
 * Configuration (toolPanels, headerContents, toolbarContents, title) lives in
 * effectiveConfig.shell. This state holds runtime UI state and cleanup functions.
 */
export interface ShellRuntimeState {
    /** Whether the tool panel sidebar is currently open */
    isPanelOpen: boolean;
    /** Which accordion sections are currently expanded (by panel ID) */
    expandedSections: Set<string>;
    /** Cleanup functions for header content render returns */
    headerContentCleanups: Map<string, () => void>;
    /** Cleanup functions for each panel section's render return */
    panelCleanups: Map<string, () => void>;
    /** Cleanup functions for toolbar content render returns */
    toolbarContentCleanups: Map<string, () => void>;
    /** IDs of tool panels registered from light DOM (to avoid re-parsing) */
    lightDomToolPanelIds: Set<string>;
    /** IDs of tool panels registered via registerToolPanel API */
    apiToolPanelIds: Set<string>;
    /** Whether a <tbw-grid-tool-buttons> container was found in light DOM */
    hasToolButtonsContainer: boolean;
}
/**
 * Create initial shell runtime state.
 */
export declare function createShellRuntimeState(): ShellRuntimeState;
/**
 * Create initial shell state.
 */
export declare function createShellState(): ShellState;
/**
 * Determine if shell header should be rendered.
 * Reads only from effectiveConfig.shell (single source of truth).
 */
export declare function shouldRenderShellHeader(config: ShellConfig | undefined): boolean;
/**
 * Render the shell header HTML.
 *
 * Toolbar contents come from two sources:
 * 1. Light DOM slot (users provide their own HTML in <tbw-grid-tool-buttons>)
 * 2. Config/API with render function (programmatic insertion)
 *
 * Users have full control over toolbar HTML, styling, and behavior.
 * The only button the grid creates is the tool panel toggle.
 *
 * @param toolPanelIcon - Icon for the tool panel toggle (from grid icon config)
 */
export declare function renderShellHeader(config: ShellConfig | undefined, state: ShellState, toolPanelIcon?: IconValue): string;
/**
 * Render the shell body wrapper HTML (contains grid content + accordion-style tool panel).
 * @param icons - Optional icons for expand/collapse chevrons (from grid config)
 */
export declare function renderShellBody(config: ShellConfig | undefined, state: ShellState, gridContentHtml: string, icons?: {
    expand?: IconValue;
    collapse?: IconValue;
}): string;
/**
 * Parse light DOM shell elements (tbw-grid-header, etc.).
 * Safe to call multiple times - will only parse once when elements are available.
 */
export declare function parseLightDomShell(host: HTMLElement, state: ShellState): void;
/**
 * Callback type for creating a toolbar content renderer from a light DOM container.
 * This is used by framework adapters (Angular, React, etc.) to create renderers
 * from their template syntax.
 */
export type ToolbarContentRendererFactory = (container: HTMLElement) => ((target: HTMLElement) => void | (() => void)) | undefined;
/**
 * Parse toolbar buttons container element (<tbw-grid-tool-buttons>).
 * This is a content container - we don't parse individual children.
 * The entire container content is registered as a single toolbar content entry.
 *
 * Example:
 * ```html
 * <tbw-grid>
 *   <tbw-grid-tool-buttons>
 *     <button>My button</button>
 *     <button>My other button</button>
 *   </tbw-grid-tool-buttons>
 * </tbw-grid>
 * ```
 *
 * The container's children are moved to the toolbar area during render.
 * We treat this as opaque content - users control what goes inside.
 *
 * @param host - The grid host element
 * @param state - Shell state to update
 * @param rendererFactory - Optional factory for creating renderers (used by framework adapters)
 */
export declare function parseLightDomToolButtons(host: HTMLElement, state: ShellState, rendererFactory?: ToolbarContentRendererFactory): void;
/**
 * Callback type for creating a tool panel renderer from a light DOM element.
 * This is used by framework adapters (Angular, React, etc.) to create renderers
 * from their template syntax.
 */
export type ToolPanelRendererFactory = (element: HTMLElement) => ((container: HTMLElement) => void | (() => void)) | undefined;
/**
 * Parse light DOM tool panel elements (<tbw-grid-tool-panel>).
 * These can appear as direct children of <tbw-grid> for declarative tool panel configuration.
 *
 * Attributes:
 * - `id` (required): Unique panel identifier
 * - `title` (required): Panel title shown in accordion header
 * - `icon`: Icon for accordion section header (emoji or text)
 * - `tooltip`: Tooltip for accordion section header
 * - `order`: Panel order priority (lower = first, default: 100)
 *
 * For vanilla JS, the element's innerHTML is used as the panel content.
 * For framework adapters, the adapter can provide a custom renderer factory.
 *
 * @param host - The grid host element
 * @param state - Shell state to update
 * @param rendererFactory - Optional factory for creating renderers (used by framework adapters)
 */
export declare function parseLightDomToolPanels(host: HTMLElement, state: ShellState, rendererFactory?: ToolPanelRendererFactory): void;
/**
 * Set up event listeners for shell toolbar buttons and accordion.
 */
export declare function setupShellEventListeners(renderRoot: Element, config: ShellConfig | undefined, state: ShellState, callbacks: {
    onPanelToggle: () => void;
    onSectionToggle: (sectionId: string) => void;
}): void;
/**
 * Set up resize handle for tool panel.
 * Returns a cleanup function to remove event listeners.
 */
export declare function setupToolPanelResize(renderRoot: Element, config: ShellConfig | undefined, onResize: (width: number) => void): () => void;
/**
 * Render toolbar content (render functions) into toolbar slots.
 * All contents (config + API + light DOM) are now unified.
 */
export declare function renderCustomToolbarContents(renderRoot: Element, config: ShellConfig | undefined, state: ShellState): void;
/**
 * Render header content from plugins into the shell content area.
 * Also moves light DOM header content to the placeholder (once).
 */
export declare function renderHeaderContent(renderRoot: Element, state: ShellState): void;
/**
 * Render content for expanded accordion sections.
 * @param icons - Optional icons for expand/collapse chevrons (from grid config)
 */
export declare function renderPanelContent(renderRoot: Element, state: ShellState, icons?: {
    expand?: IconValue;
    collapse?: IconValue;
}): void;
/**
 * Update toolbar button active states.
 */
export declare function updateToolbarActiveStates(renderRoot: Element, state: ShellState): void;
/**
 * Update tool panel open/close state.
 */
export declare function updatePanelState(renderRoot: Element, state: ShellState): void;
/**
 * Cleanup all shell state when grid disconnects.
 */
export declare function cleanupShellState(state: ShellState): void;
/**
 * Callbacks for ShellController to communicate with the grid.
 * This interface decouples the controller from grid internals.
 */
export interface ShellControllerCallbacks {
    /** Get the render root for DOM queries (the grid element) */
    getShadow: () => Element;
    /** Get the current shell config */
    getShellConfig: () => ShellConfig | undefined;
    /** Get accordion expand/collapse icons */
    getAccordionIcons: () => {
        expand: IconValue;
        collapse: IconValue;
    };
    /** Emit an event from the grid */
    emit: (eventName: string, detail: unknown) => void;
    /** Refresh the shell header (re-parse light DOM and re-render) */
    refreshShellHeader: () => void;
}
/**
 * Controller interface for managing shell/tool panel behavior.
 */
export interface ShellController {
    /** Whether the shell has been initialized */
    readonly isInitialized: boolean;
    /** Set the initialized state */
    setInitialized(value: boolean): void;
    /** Whether the tool panel is currently open */
    readonly isPanelOpen: boolean;
    /** Get the currently active panel ID (deprecated) */
    readonly activePanel: string | null;
    /** Get IDs of expanded accordion sections */
    readonly expandedSections: string[];
    /** Open the tool panel */
    openToolPanel(): void;
    /** Close the tool panel */
    closeToolPanel(): void;
    /** Toggle the tool panel */
    toggleToolPanel(): void;
    /** Toggle an accordion section */
    toggleToolPanelSection(sectionId: string): void;
    /** Get registered tool panels */
    getToolPanels(): ToolPanelDefinition[];
    /** Register a tool panel */
    registerToolPanel(panel: ToolPanelDefinition): void;
    /** Unregister a tool panel */
    unregisterToolPanel(panelId: string): void;
    /** Get registered header contents */
    getHeaderContents(): HeaderContentDefinition[];
    /** Register header content */
    registerHeaderContent(content: HeaderContentDefinition): void;
    /** Unregister header content */
    unregisterHeaderContent(contentId: string): void;
    /** Get all registered toolbar contents */
    getToolbarContents(): ToolbarContentDefinition[];
    /** Register toolbar content */
    registerToolbarContent(content: ToolbarContentDefinition): void;
    /** Unregister toolbar content */
    unregisterToolbarContent(contentId: string): void;
}
/**
 * Create a ShellController instance.
 * The controller encapsulates all tool panel orchestration logic.
 */
export declare function createShellController(state: ShellState, callbacks: ShellControllerCallbacks): ShellController;
/**
 * Core grid content HTML template.
 * Uses faux scrollbar pattern for smooth virtualized scrolling.
 */
export declare const GRID_CONTENT_HTML = "\n  <div class=\"tbw-scroll-area\">\n    <div class=\"rows-body-wrapper\">\n      <div class=\"rows-body\" role=\"grid\">\n        <div class=\"header\" role=\"rowgroup\">\n          <div class=\"header-row\" role=\"row\" part=\"header-row\"></div>\n        </div>\n        <div class=\"rows-container\" role=\"presentation\">\n          <div class=\"rows-viewport\" role=\"presentation\">\n            <div class=\"rows\"></div>\n          </div>\n        </div>\n      </div>\n    </div>\n  </div>\n  <div class=\"faux-vscroll\">\n    <div class=\"faux-vscroll-spacer\"></div>\n  </div>\n";
/**
 * Build the complete grid DOM structure using direct DOM construction.
 * This is 2-3x faster than innerHTML for initial render.
 *
 * @param renderRoot - The element to render into (will be cleared)
 * @param shellConfig - Shell configuration
 * @param state - Shell state
 * @param icons - Optional icons
 * @returns Whether shell is active (for post-render setup)
 */
export declare function buildGridDOMIntoElement(renderRoot: Element, shellConfig: ShellConfig | undefined, runtimeState: {
    isPanelOpen: boolean;
    expandedSections: Set<string>;
}, icons?: {
    toolPanel?: IconValue;
    expand?: IconValue;
    collapse?: IconValue;
}): boolean;
//# sourceMappingURL=shell.d.ts.map