import { OnInit, OnDestroy, ChangeDetectorRef, ElementRef, NgZone } from '@angular/core';
import { Subject } from 'rxjs';
import { BaseResourceComponent } from '@memberjunction/ng-shared';
import { CompositeKey } from '@memberjunction/core';
import { TreeBranchConfig } from '@memberjunction/ng-trees';
import { ResourceData, MJQueryEntityExtended, MJQueryCategoryEntity } from '@memberjunction/core-entities';
import { QueryEntityLinkClickEvent, QueryRowClickEvent } from '@memberjunction/ng-query-viewer';
import { CompositionTokenClickEvent } from '@memberjunction/ng-code-editor';
import * as i0 from "@angular/core";
/**
 * Tree node for the query category hierarchy
 */
interface CategoryNode {
    category: MJQueryCategoryEntity;
    children: CategoryNode[];
    queries: MJQueryEntityExtended[];
    expanded: boolean;
    level: number;
}
/**
 * A resource component for browsing and executing stored queries.
 * Features:
 * - Hierarchical category navigation
 * - Query search
 * - Query viewer with parameter input
 * - Entity linking for clickable record IDs
 */
export declare class QueryBrowserResourceComponent extends BaseResourceComponent implements OnInit, OnDestroy {
    private cdr;
    private elementRef;
    private zone;
    private static readonly SETTINGS_KEY;
    private static readonly STATUS_FILTERS_KEY;
    private static readonly EXPANDED_STATE_KEY;
    private static readonly DEFAULT_PANEL_WIDTH;
    private static readonly MIN_PANEL_WIDTH;
    private static readonly MAX_PANEL_WIDTH;
    isLoading: boolean;
    categories: MJQueryCategoryEntity[];
    categoryTree: CategoryNode[];
    /** All queries the user has permission to run */
    queries: MJQueryEntityExtended[];
    filteredQueries: MJQueryEntityExtended[];
    private filteredQueryIds;
    selectedQuery: MJQueryEntityExtended | null;
    searchText: string;
    PanelWidth: number;
    IsResizing: boolean;
    /** Status filter toggles — which statuses to show in the tree */
    StatusFilters: Record<string, boolean>;
    /** Ordered list of all possible statuses for the filter bar */
    readonly AllStatuses: string[];
    /** Tracks expanded state by category ID — persisted across sessions */
    private expandedState;
    private metadata;
    protected destroy$: Subject<void>;
    private dataLoaded;
    private boundOnResizeMove;
    private boundOnResizeEnd;
    ShowQueryDrawer: boolean;
    DrawerMode: 'create' | 'edit';
    DrawerQueryId: string | null;
    DrawerName: string;
    DrawerSQL: string;
    private drawerSqlEditor;
    DrawerDescription: string;
    DrawerCategoryID: string;
    DrawerStatus: 'Pending' | 'Approved' | 'Rejected' | 'Expired';
    DrawerReusable: boolean;
    IsSavingDrawer: boolean;
    DrawerNameError: boolean;
    DrawerSaveError: string | null;
    /** Ordered status options for the drawer dropdown — all valid Query statuses */
    readonly DrawerStatuses: Array<'Pending' | 'Approved' | 'Rejected' | 'Expired'>;
    private initialDrawerSnapshot;
    /** The category ID of the most recently interacted-with folder in the tree */
    private activeCategoryID;
    /** Tree dropdown config for Query Categories (branches only, no leaves) */
    CategoryBranchConfig: TreeBranchConfig;
    /** The DrawerCategoryID as a CompositeKey for the tree dropdown binding */
    get DrawerCategoryIDAsKey(): CompositeKey | null;
    constructor(cdr: ChangeDetectorRef, elementRef: ElementRef, zone: NgZone);
    ngOnInit(): void;
    ngOnDestroy(): void;
    GetResourceDisplayName(data: ResourceData): Promise<string>;
    GetResourceIconClass(data: ResourceData): Promise<string>;
    private loadData;
    private buildCategoryTree;
    onSearchChange(value: string): void;
    clearSearch(): void;
    /** Toggle a status filter on/off and rebuild the tree */
    toggleStatusFilter(status: string): void;
    /** Get the count of queries with a given status */
    getStatusCount(status: string): number;
    /** Get the CSS color for a query status */
    getStatusColor(status: string): string;
    /** Get the Font Awesome icon for a query status */
    getStatusIcon(status: string): string;
    /** Apply both status and search filters to produce filteredQueries */
    private applyFilters;
    /** Load saved status filter preferences */
    private loadSavedStatusFilters;
    /** Save status filter preferences with debouncing */
    private saveStatusFilters;
    /** Load saved expanded/collapsed state for category nodes */
    private loadSavedExpandedState;
    /** Save expanded/collapsed state with debouncing */
    private saveExpandedState;
    toggleExpand(node: CategoryNode, event?: Event): void;
    expandAll(): void;
    collapseAll(): void;
    selectQuery(query: MJQueryEntityExtended, event?: Event): void;
    isQueryVisible(query: MJQueryEntityExtended): boolean;
    hasVisibleContent(node: CategoryNode): boolean;
    onEntityLinkClick(event: QueryEntityLinkClickEvent): void;
    onRowDoubleClick(event: QueryRowClickEvent): void;
    onOpenQueryRecord(event: {
        queryId: string;
        queryName: string;
    }): void;
    onCompositionTokenClick(event: CompositionTokenClickEvent): void;
    /**
     * Find a query by its composition path (e.g., "Demos/Active Users").
     * Matches the last segment as query name and preceding segments as category hierarchy.
     */
    private findQueryByCompositionPath;
    /**
     * Expand category tree nodes to reveal a specific query.
     */
    private expandTreeToQuery;
    /** True when the current user has permission to create new queries. */
    get CanCreateQuery(): boolean;
    /** True when the current user has permission to edit queries. */
    get CanEditQuery(): boolean;
    /** Close the drawer when Escape is pressed (if open). */
    OnEscapeKey(): void;
    /** Open the drawer in create mode, optionally pre-selecting a category. */
    OpenCreateDrawer(categoryID?: string): void;
    /**
     * Open the drawer in edit mode, pre-populated from a MJQueryEntityExtended.
     * Stops event propagation so clicking the edit icon doesn't also select the query.
     */
    OpenEditDrawer(query: MJQueryEntityExtended, event?: Event): void;
    /**
     * Close the drawer. If dirty, ask for confirmation unless force=true.
     */
    CloseDrawer(force?: boolean): void;
    /** Close drawer when clicking the backdrop. */
    OnDrawerBackdropClick(): void;
    /** Update DrawerSQL when the code editor emits a change. */
    OnDrawerSQLChange(value: string): void;
    /** Update DrawerCategoryID when the tree dropdown selection changes. */
    OnDrawerCategoryChange(value: CompositeKey | CompositeKey[] | null): void;
    private get currentDrawerSnapshot();
    private captureDrawerSnapshot;
    get IsDrawerDirty(): boolean;
    /** Save the drawer form (create or edit). */
    SaveDrawer(): Promise<void>;
    /** Open the full entity form in a new tab (for sub-entity management). */
    OpenFullRecord(): void;
    getTotalQueryCount(): number;
    getNodeQueryCount(node: CategoryNode): number;
    refresh(): void;
    trackByCategory(index: number, node: CategoryNode): string;
    trackByQuery(index: number, query: MJQueryEntityExtended): string;
    /**
     * Select a query by ID, expanding the tree to show it.
     * Clears selection if no matching query is found.
     */
    private selectQueryById;
    /**
     * React to back/forward navigation or deep-link activation.
     * Called by the base class when the URL query params change externally.
     */
    protected OnQueryParamsChanged(params: Record<string, string>, source: 'popstate' | 'deeplink'): void;
    /**
     * Expands the category tree to show the given query
     */
    private expandCategoryForQuery;
    /**
     * Load saved panel width from user settings
     */
    private loadSavedPanelWidth;
    /**
     * Start resizing the left panel via drag handle
     */
    onResizeStart(event: MouseEvent): void;
    private onResizeMove;
    private onResizeEnd;
    /** Case-insensitive UUID check whether a query is the currently selected query. */
    IsQuerySelected(query: MJQueryEntityExtended): boolean;
    static ɵfac: i0.ɵɵFactoryDeclaration<QueryBrowserResourceComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<QueryBrowserResourceComponent, "mj-query-browser-resource", never, {}, {}, never, never, false, never>;
}
export {};
//# sourceMappingURL=query-browser-resource.component.d.ts.map