import { AXClickEvent } from '@acorex/cdk/common';
import * as _angular_core from '@angular/core';
import { EventEmitter, OnChanges, OnDestroy, WritableSignal, NgZone, ComponentRef, SimpleChanges } from '@angular/core';
import { AXBasePageComponent } from '@acorex/components/page';
import { AXTabStripChangedEvent } from '@acorex/components/tabs';
import * as _acorex_platform_layout_widget_core from '@acorex/platform/layout/widget-core';
import { AXPWidgetConfig, AXPWidgetCategory, AXPWidgetGroupEnum, AXPWidgetNode, AXPBaseWidgetComponent, AXPWidgetRegistryService, AXPLayoutBaseWidgetComponent, AXPWidgetCoreContextChangeEvent } from '@acorex/platform/layout/widget-core';
import { AXPWidgetItemData, AXPWidgetItemClickEvent } from '@acorex/platform/layout/components';
import { AXMenuItem } from '@acorex/components/menu';
import { Subject } from 'rxjs';
import { AXPBroadcastEventService } from '@acorex/platform/core';
import { AXUnsubscriber } from '@acorex/core/utils';
import { AXPClipBoardService, AXPSettingsService } from '@acorex/platform/common';

declare class AXPDesignerAddWidgetButtonComponent {
    private designerService;
    private parent;
    handleClick(e: AXClickEvent): Promise<void>;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPDesignerAddWidgetButtonComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXPDesignerAddWidgetButtonComponent, "axp-designer-add-widget-button", never, {}, {}, never, never, true, never>;
}

declare class AXPDesignerAddWidgetLineButtonComponent {
    text: _angular_core.InputSignal<unknown>;
    onClick: _angular_core.OutputEmitterRef<void>;
    protected handleClick(): void;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPDesignerAddWidgetLineButtonComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXPDesignerAddWidgetLineButtonComponent, "axp-designer-add-widget-line-button", never, { "text": { "alias": "text"; "required": false; "isSignal": true; }; }, { "onClick": "onClick"; }, never, never, true, never>;
}

declare class AXPDesignerAddWidgetMiniButtonComponent {
    private designerService;
    private parent;
    onClick: EventEmitter<void>;
    protected handleClick(e: MouseEvent): Promise<void>;
    private get __class();
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPDesignerAddWidgetMiniButtonComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXPDesignerAddWidgetMiniButtonComponent, "axp-designer-add-widget-mini-button", never, {}, { "onClick": "onClick"; }, never, never, true, never>;
}

declare class AXPDesignerFlexDrawerComponent {
    itemsCount: _angular_core.ModelSignal<number>;
    onSelect: _angular_core.OutputEmitterRef<number>;
    protected items: _angular_core.Signal<number[]>;
    protected range: _angular_core.WritableSignal<number>;
    protected handleMouseHover(c: number): void;
    protected handleClick(c: number): void;
    protected handleMouseLeave(event: MouseEvent): void;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPDesignerFlexDrawerComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXPDesignerFlexDrawerComponent, "axp-designer-flex-drawer", never, { "itemsCount": { "alias": "items"; "required": false; "isSignal": true; }; }, { "itemsCount": "itemsChange"; "onSelect": "onSelect"; }, never, never, true, never>;
}

declare class AXPDesignerGridDrawerComponent {
    rowsCount: _angular_core.ModelSignal<number>;
    colsCount: _angular_core.ModelSignal<number>;
    onSelect: _angular_core.OutputEmitterRef<{
        rows: number;
        cols: number;
    }>;
    protected rows: _angular_core.Signal<number[]>;
    protected columns: _angular_core.Signal<number[]>;
    protected rangeR: _angular_core.WritableSignal<number>;
    protected rangeC: _angular_core.WritableSignal<number>;
    protected handleMouseHover(r: number, c: number): void;
    protected handleClick(r: number, c: number): void;
    protected handleMouseLeave(event: MouseEvent): void;
    private get __style();
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPDesignerGridDrawerComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXPDesignerGridDrawerComponent, "axp-designer-grid-drawer", never, { "rowsCount": { "alias": "rows"; "required": false; "isSignal": true; }; "colsCount": { "alias": "columns"; "required": false; "isSignal": true; }; }, { "rowsCount": "rowsChange"; "colsCount": "columnsChange"; "onSelect": "onSelect"; }, never, never, true, never>;
}

interface AXPDisplayWidgetConfig extends AXPWidgetConfig {
    pinned: boolean;
}
declare class AXPDesignerWidgetPickerComponent extends AXBasePageComponent {
    private settingsService;
    private readonly pinnedSettingKey;
    protected searchTerm: _angular_core.ModelSignal<string>;
    private widgets;
    private allWidgets;
    private pinnedWidgets;
    private displayWidgets;
    protected selectedWidgets: _angular_core.WritableSignal<AXPDisplayWidgetConfig[]>;
    private orderedList;
    protected pinnedList: _angular_core.Signal<AXPDisplayWidgetConfig[]>;
    protected regularList: _angular_core.Signal<AXPDisplayWidgetConfig[]>;
    protected pinnedWidgetItems: _angular_core.Signal<AXPWidgetItemData[]>;
    protected regularWidgetItems: _angular_core.Signal<AXPWidgetItemData[]>;
    protected categories: _angular_core.Signal<AXPWidgetCategory[]>;
    protected tabs: _angular_core.Signal<AXPWidgetCategory[]>;
    protected maxVisibleWidgets: _angular_core.Signal<number>;
    protected currentTabIndex: _angular_core.WritableSignal<number>;
    protected selectedTab: _angular_core.Signal<AXPWidgetCategory>;
    protected ngOnInit(): Promise<void>;
    protected handleTabChange(event: AXTabStripChangedEvent): void;
    protected handleWidgetClick(clickEvent: AXPWidgetItemClickEvent): void;
    protected handleWidgetPinClick(clickEvent: AXPWidgetItemClickEvent): Promise<void>;
    protected isWidgetSelected(widget: AXPDisplayWidgetConfig): boolean;
    protected isWidgetItemSelected(widgetItem: AXPWidgetItemData): boolean;
    protected handleConfirmSelection(): void;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPDesignerWidgetPickerComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXPDesignerWidgetPickerComponent, "ng-component", never, { "searchTerm": { "alias": "searchTerm"; "required": false; "isSignal": true; }; }, { "searchTerm": "searchTermChange"; }, never, never, true, never>;
}

declare class AXPWidgetPickerService {
    private popupService;
    private widgetRegistryService;
    private translationService;
    showPicker(options: {
        groups: AXPWidgetGroupEnum[];
    }): Promise<AXPWidgetNode[]>;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPWidgetPickerService, never>;
    static ɵprov: _angular_core.ɵɵInjectableDeclaration<AXPWidgetPickerService>;
}

type AXPDesignerMode = {
    id: 'designer';
    title: 'Designer';
} | {
    id: 'view';
    title: 'View';
} | {
    id: 'edit';
    title: 'Edit';
};
declare class AXPDesignerModes {
    static readonly View: AXPDesignerMode;
    static readonly Design: AXPDesignerMode;
    static readonly Edit: AXPDesignerMode;
}
declare enum AXPTemplateLoadingStrategy {
    Connector = "Connector",
    Broadcast = "Broadcast"
}
interface AXPDesignerWidgetComponent {
    onContextMenu(context: {
        items: AXMenuItem[];
    }): void;
    executeCommand(command: {
        name: string;
        data?: any;
        handled: boolean;
    }): Promise<void>;
}
interface AXPDesignerPreviewMessage {
    id: string;
    document: AXPWidgetNode;
}
interface AXPDesignerSaveFormMessage {
    id: string;
    success: boolean;
    content?: string;
}
declare const AXPDesignerMessageKeys: {
    Preview: string;
    Loaded: string;
    ContextChanged: string;
    PreviewWindow: string;
    RequestFormContent: string;
    ResponseFormContent: string;
    SaveForm: string;
    FormSaved: string;
};

type AXPDesignerPreviewSize = 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
interface AXPDesignerFocusCommand {
    widget: AXPWidgetNode | null;
}
interface AXPDesignerUpdateCommand {
    values: any;
    widget?: AXPWidgetNode | null;
    mode: 'init' | 'update';
}
interface AXPDesignerUpdateEvent {
    values: any;
    widget: AXPWidgetNode;
}
interface AXPDesignerSelectCommand {
    widget: AXPWidgetNode;
}
interface AXPDesignerRegisterCommand {
    id: number;
    widget: AXPWidgetNode;
    config: AXPWidgetConfig;
    instance: AXPBaseWidgetComponent;
}
interface AXPDesignerSelectEvent {
    widget: AXPWidgetNode;
}
interface AXPDesignerRefreshCommand {
    widget: AXPWidgetNode;
}
interface AXPDesignerRefreshEvent {
    widget: AXPWidgetNode;
}
interface AXPDesignerAddNodeCommand {
    widget: AXPWidgetNode;
}
interface AXPDesignerAddNodeEvent {
    widget: AXPWidgetNode;
}
interface AXPDesignerFocusEvent {
    widget: AXPWidgetNode | null;
}
declare class AXPDesignerService {
    #private;
    private popupService;
    private toastService;
    private fileService;
    private loadingService;
    private widgetRegisteryService;
    private connector;
    private eventService;
    private widgetPickerService;
    readonly document: _angular_core.WritableSignal<AXPWidgetNode>;
    readonly currentPageIndex: _angular_core.WritableSignal<number>;
    readonly currentPage: _angular_core.WritableSignal<AXPWidgetNode>;
    private commandManager;
    private clipboard;
    canCutCopy: _angular_core.Signal<boolean>;
    canDelete: _angular_core.Signal<boolean>;
    canInsert: _angular_core.Signal<boolean>;
    canPaste: _angular_core.Signal<boolean>;
    readonly history: _angular_core.Signal<{
        description: string;
        icon: string;
        isPast: boolean;
        isFuture: boolean;
        isCurrent: boolean;
    }[]>;
    readonly canUndo: _angular_core.Signal<boolean>;
    readonly canRedo: _angular_core.Signal<boolean>;
    readonly canSave: _angular_core.Signal<boolean>;
    readonly unsavedChanges: _angular_core.WritableSignal<boolean>;
    breadcrumbs: _angular_core.Signal<AXPWidgetNode[]>;
    selectedNode: _angular_core.WritableSignal<AXPWidgetNode | null>;
    selectedNodeConfig: _angular_core.Signal<AXPWidgetConfig<any>>;
    private _focusedNode;
    focusedNode: () => AXPWidgetNode | null;
    readonly size: _angular_core.WritableSignal<AXPDesignerPreviewSize>;
    readonly onSelected: Subject<AXPDesignerSelectEvent>;
    readonly onRefresh: Subject<AXPDesignerRefreshEvent>;
    readonly onUpdate: Subject<AXPDesignerUpdateEvent>;
    readonly onFocused: Subject<AXPDesignerFocusEvent>;
    private templateId;
    private loadingStrategy;
    constructor();
    private can;
    register(command: AXPDesignerRegisterCommand): void;
    select(command: AXPDesignerSelectCommand): void;
    update(command: AXPDesignerUpdateCommand): void;
    focus(command: AXPDesignerFocusCommand): void;
    refresh(command: AXPDesignerRefreshCommand): void;
    private findBreadcrumbs;
    showPicker(currentNode?: AXPWidgetNode): Promise<AXPWidgetNode[]>;
    new(): void;
    private createDoc;
    private createPage;
    addNewPage(): void;
    removePage(index: number): void;
    clonePage(index: number): void;
    goToPage(index: number): void;
    private reRenderPage;
    findWidgetById(root: AXPWidgetNode, id: string): AXPWidgetNode | null;
    private findParent;
    private findNearestContainer;
    addWidget(currentNode: AXPWidgetNode, node: AXPWidgetNode): AXPWidgetNode;
    removeWidget(node?: AXPWidgetNode): void;
    navigateTo(index: number): void;
    redo(): void;
    undo(): void;
    clearHistory(): void;
    private removeMetaProp;
    private addMetaToNodes;
    copy(widget?: AXPWidgetNode | null): void;
    cut(widget?: AXPWidgetNode | null): void;
    clone(widget?: AXPWidgetNode | null): void;
    paste(parentNode?: AXPWidgetNode | undefined): void;
    save(): Promise<void>;
    saveAs(node?: AXPWidgetNode): Promise<void>;
    export(node?: AXPWidgetNode): string;
    downloadJson(): void;
    loadById(id: string, options?: {
        strategy: AXPTemplateLoadingStrategy;
    }): Promise<void>;
    importJSon(): Promise<void>;
    loadByContent(content: string): Promise<void>;
    private countTotalNodes;
    private generateUniqueName;
    generateUniqueId(): number;
    private collectAllNames;
    updatePreview(): void;
    openPreviewDialog(): Promise<void>;
    openPreviewWindow(): void;
    getContextMenuItems(instance: AXPDesignerWidgetComponent, isRoot?: boolean): AXMenuItem[];
    executeCommand(context: {
        instance: AXPDesignerWidgetComponent;
        name: string;
        data?: any;
    }): Promise<void>;
    unsubscribeEvents(): void;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPDesignerService, never>;
    static ɵprov: _angular_core.ɵɵInjectableDeclaration<AXPDesignerService>;
}

declare class AXPLayoutDesignerComponent {
    protected service: AXPDesignerService;
    id: _angular_core.InputSignal<string | null | undefined>;
    strategy: _angular_core.InputSignal<string | null | undefined>;
    private propertyViewer;
    protected nodeConfig: _angular_core.Signal<AXPWidgetConfig<any> | null>;
    constructor();
    ngOnInit(): void;
    private get __styles();
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPLayoutDesignerComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXPLayoutDesignerComponent, "axp-layout-designer", never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; "strategy": { "alias": "strategy"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
}

interface AXPDesignerContent {
    json: string;
    html?: string;
}
declare abstract class AXPDesignerConnector<T = string> {
    abstract save(id: string, content: AXPDesignerContent): Promise<boolean>;
    abstract saveAs(content: AXPDesignerContent): Promise<boolean>;
    abstract load(id: T): Promise<string | null>;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPDesignerConnector<any>, never>;
    static ɵprov: _angular_core.ɵɵInjectableDeclaration<AXPDesignerConnector<any>>;
}

declare const AXP_DESIGNER_COPY_MENU: AXMenuItem;
declare const AXP_DESIGNER_CLONE_MENU: AXMenuItem;
declare const AXP_DESIGNER_CUT_MENU: AXMenuItem;
declare const AXP_DESIGNER_PASTE_MENU: AXMenuItem;
declare const AXP_DESIGNER_ADD_WIDGET_MENU: AXMenuItem;
declare const AXP_DESIGNER_SELECT_WIDGET_MENU: AXMenuItem;
declare const AXP_DESIGNER_DELETE_WIDGET_MENU: AXMenuItem;
declare const AXP_DESIGNER_SAVE_AS_WIDGET_MENU: AXMenuItem;
declare function cloneWidgetMenu(item: AXMenuItem, options?: Partial<AXMenuItem>): AXMenuItem;

declare class AXPWidgetDesignerRendererDirective implements OnChanges, OnDestroy {
    protected mergedOptions: WritableSignal<any>;
    private injector;
    protected widgetRegistry: AXPWidgetRegistryService;
    protected zone: NgZone;
    protected isLoading: WritableSignal<boolean>;
    private instance;
    private config?;
    private isLoadingComponent;
    private currentNodeId;
    private service;
    private viewContainerRef;
    parentNode: _angular_core.InputSignal<AXPLayoutBaseWidgetComponent<Record<string, any>> | null | undefined>;
    parentElement: _angular_core.InputSignal<HTMLElement | null | undefined>;
    parentComponent: _angular_core.InputSignal<ComponentRef<any> | null | undefined>;
    index: _angular_core.InputSignal<number | null | undefined>;
    locked: _angular_core.InputSignal<boolean>;
    mode: _angular_core.InputSignal<keyof _acorex_platform_layout_widget_core.AXPWidgetConfigComponents>;
    node: _angular_core.InputSignal<AXPWidgetNode>;
    private hostElement;
    private getId;
    private isCurrentWidget;
    private subs;
    /**
     * @ignore
     */
    constructor();
    ngOnChanges(changes: SimpleChanges): void;
    ngOnDestroy(): void;
    private loadComponent;
    private overlay;
    select(): void;
    focus(): void;
    blur(): void;
    private applySelectedStyle;
    private removeSelectedStyle;
    private addOverlay;
    private removeOverlay;
    private preprocessAndInitialOptions;
    private applyOptions;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPWidgetDesignerRendererDirective, never>;
    static ɵdir: _angular_core.ɵɵDirectiveDeclaration<AXPWidgetDesignerRendererDirective, "[axp-widget-designer-renderer]", never, { "parentNode": { "alias": "parentNode"; "required": false; "isSignal": true; }; "parentElement": { "alias": "parentElement"; "required": false; "isSignal": true; }; "parentComponent": { "alias": "parentComponent"; "required": false; "isSignal": true; }; "index": { "alias": "index"; "required": false; "isSignal": true; }; "locked": { "alias": "locked"; "required": false; "isSignal": true; }; "mode": { "alias": "mode"; "required": true; "isSignal": true; }; "node": { "alias": "node"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
}

declare class AXPLayoutDesignerPreviewViewerComponent {
    protected context: any;
    protected readonly document: _angular_core.WritableSignal<AXPWidgetNode>;
    protected readonly currentPageIndex: _angular_core.WritableSignal<number>;
    protected connector: AXPDesignerConnector<any>;
    protected eventService: AXPBroadcastEventService;
    protected unsubscriber: AXUnsubscriber;
    protected readonly currentPage: _angular_core.Signal<AXPWidgetNode>;
    constructor();
    ngAfterViewInit(): void;
    protected handleContextChanged(e: AXPWidgetCoreContextChangeEvent): void;
    ngOnDestroy(): void;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPLayoutDesignerPreviewViewerComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXPLayoutDesignerPreviewViewerComponent, "axp-layout-builder-viewer", never, {}, {}, never, never, true, never>;
}

declare class AXPLayoutDesignerPreviewComponent extends AXBasePageComponent {
    protected clipboard: AXPClipBoardService;
    protected settings: AXPSettingsService;
    protected eventService: AXPBroadcastEventService;
    protected initialSize: string;
    protected isDialogWindow: boolean;
    private jsonSettingsKey;
    protected jsonViewCollapsed: _angular_core.WritableSignal<boolean>;
    protected size: _angular_core.WritableSignal<string>;
    protected context: _angular_core.WritableSignal<any>;
    constructor();
    protected ngOnInit(): Promise<void>;
    protected handleCloseButton(): void;
    protected handlePreviewWindow(): void;
    protected handleCopyJson(): void;
    protected handleCollapsedChange(value: boolean): Promise<void>;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXPLayoutDesignerPreviewComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXPLayoutDesignerPreviewComponent, "axp-layout-preview", never, {}, {}, never, never, true, never>;
}

export { AXPDesignerAddWidgetButtonComponent, AXPDesignerAddWidgetLineButtonComponent, AXPDesignerAddWidgetMiniButtonComponent, AXPDesignerConnector, AXPDesignerFlexDrawerComponent, AXPDesignerGridDrawerComponent, AXPDesignerMessageKeys, AXPDesignerModes, AXPDesignerService, AXPDesignerWidgetPickerComponent, AXPLayoutDesignerComponent, AXPLayoutDesignerPreviewComponent, AXPLayoutDesignerPreviewViewerComponent, AXPTemplateLoadingStrategy, AXPWidgetDesignerRendererDirective, AXPWidgetPickerService, AXP_DESIGNER_ADD_WIDGET_MENU, AXP_DESIGNER_CLONE_MENU, AXP_DESIGNER_COPY_MENU, AXP_DESIGNER_CUT_MENU, AXP_DESIGNER_DELETE_WIDGET_MENU, AXP_DESIGNER_PASTE_MENU, AXP_DESIGNER_SAVE_AS_WIDGET_MENU, AXP_DESIGNER_SELECT_WIDGET_MENU, cloneWidgetMenu };
export type { AXPDesignerAddNodeCommand, AXPDesignerAddNodeEvent, AXPDesignerContent, AXPDesignerFocusCommand, AXPDesignerFocusEvent, AXPDesignerMode, AXPDesignerPreviewMessage, AXPDesignerPreviewSize, AXPDesignerRefreshCommand, AXPDesignerRefreshEvent, AXPDesignerRegisterCommand, AXPDesignerSaveFormMessage, AXPDesignerSelectCommand, AXPDesignerSelectEvent, AXPDesignerUpdateCommand, AXPDesignerUpdateEvent, AXPDesignerWidgetComponent, AXPDisplayWidgetConfig };
