import * as i0 from '@angular/core';
import { TemplateRef, EventEmitter, ChangeDetectorRef, AfterViewInit, OnDestroy } from '@angular/core';
import * as _fundamental_ngx_platform_dynamic_page from '@fundamental-ngx/platform/dynamic-page';
import { Nullable } from '@fundamental-ngx/cdk/utils';
import { DialogService, DialogRef } from '@fundamental-ngx/core/dialog';
import { DynamicPage } from '@fundamental-ngx/core/dynamic-page';
import { TriggerConfig, PopoverComponent } from '@fundamental-ngx/core/popover';
import { HeaderSizes } from '@fundamental-ngx/core/title';
import { SearchInput } from '@fundamental-ngx/platform/search-field';
import { BehaviorSubject } from 'rxjs';
import { FormGroup, ValidatorFn, FormBuilder } from '@angular/forms';
import { TableDataSource } from '@fundamental-ngx/platform/table';

/**
 * Directive used to change dirty label of Variant Management component.
 *
 * Usage:
 *
 * ```
 * html
 * <fdp-variant-management>
 *     <span *fdpVariantManagementDirtyLabel>I'm dirty</span>
 * </fdp-variant-management>
 * ```
 */
declare class VariantManagementDirtyLabelDirective {
    templateRef: TemplateRef<any>;
    /** @hidden */
    constructor(templateRef: TemplateRef<any>);
    static ɵfac: i0.ɵɵFactoryDeclaration<VariantManagementDirtyLabelDirective, never>;
    static ɵdir: i0.ɵɵDirectiveDeclaration<VariantManagementDirtyLabelDirective, "[fdpVariantManagementDirtyLabel]", never, {}, {}, never, never, true, never>;
}

type VariantAccess = 'private' | 'public';
/** Base Variant interface. */
interface Variant<T = any> {
    /** Variant ID. */
    id?: string;
    /** Variant name to be displayed in popover list. */
    name: string;
    /** Variant's author name. */
    createdBy: string;
    /** Whether variant is editable. */
    readonly: boolean;
    /** Whether variant is marked as favourite. */
    favourite: boolean;
    /** Whether to apply variant automatically. */
    isDefault: boolean;
    /** Visibility of the variant. If public, available for everyone. */
    access: VariantAccess;
    /** Variant data. Can contain any type of data. */
    data: T;
    /** Whether to automatically apply changes in preset managed component. */
    applyAutomatically?: boolean;
}
type NewVariant = Partial<Pick<Variant, 'name' | 'isDefault' | 'access' | 'applyAutomatically' | 'readonly' | 'favourite'>>;

interface VariantManagement<T = any> {
    activeVariantChangeSubject: BehaviorSubject<Variant | null>;
    activeVariant: Variant;
    updateActivePreset(data: T, componentName: string | null): void;
    getActiveVariantData(): T;
    getOriginalActiveVariantData(): T;
}

declare class VariantItem<T = any> implements Variant<T> {
    /** Visibility of the variant. If public, available for everyone. */
    access: VariantAccess;
    /** Whether to automatically apply changes in preset managed component. */
    applyAutomatically?: boolean | undefined;
    /** Variant's author name. */
    createdBy: string;
    /** Variant data. Can contain any type of data. */
    data: T;
    /** Whether variant is marked as favourite. */
    favourite: boolean;
    /** Variant ID. */
    id: string;
    /** Whether to apply variant automatically. */
    isDefault: boolean;
    /** Variant name to be displayed in popover list. */
    name: string;
    /** Whether variant is editable. */
    readonly: boolean;
    /** @hidden */
    constructor(config: Partial<Variant>);
    /**
     * Clones current variant and applies new config on top of it.
     * @param newVariantData New config.
     * @param refreshId Whether to assign new ID to the new variant.
     */
    clone(newVariantData?: NewVariant, refreshId?: boolean): VariantItem;
}

declare class VariantManagementComponent<T = any> implements VariantManagement<T> {
    private readonly _dialogService;
    private readonly _cdr;
    /** Initial variants array. */
    set variants(items: Variant<T>[]);
    /** Header size. */
    headerSize: HeaderSizes;
    /** Popover trigger events. */
    popoverTriggers: (string | TriggerConfig)[];
    /** User's name which will be applied to all new variants user creates. */
    userName: string;
    /** Whether to display search field for variants list. */
    displaySearch: boolean;
    /** Whether the variant management component is in readonly mode. */
    readonly: boolean;
    /** Event emitted when variants data has been updated. */
    variantsChange: EventEmitter<Variant<T>[]>;
    /** Event emitted when new variant selected. */
    activeVariantChange: EventEmitter<Variant<T>>;
    /**
     * Custom dirty label directive.
     */
    dirtyLabel: VariantManagementDirtyLabelDirective;
    /** @hidden */
    _popover: PopoverComponent;
    /** @hidden */
    protected readonly _initialClass = "fd-variant-management";
    /**
     * Used internally for communicating with wrapper component.
     */
    activeVariantChangeSubject: BehaviorSubject<Variant<T> | null>;
    /** @hidden */
    _variantChanged: boolean;
    /** Selected variant. */
    activeVariant: VariantItem<T>;
    /** @hidden */
    _variants: VariantItem<T>[];
    /** @Hidden */
    _filterPhrase: Nullable<string>;
    /** @hidden */
    get _dynamicPage(): DynamicPage | null;
    /** @hidden */
    protected _dynamicPageCollapsed$: BehaviorSubject<boolean>;
    /** @hidden */
    protected _coreDynamicPage: DynamicPage | null;
    /** @hidden */
    protected _platformDynamicPage: _fundamental_ngx_platform_dynamic_page.PlatformDynamicPage | null;
    /** @Hidden */
    private _originalActiveVariant;
    /** @hidden */
    constructor(_dialogService: DialogService, _cdr: ChangeDetectorRef);
    /**
     * Manually select variant.
     * @param variant Variant to select.
     */
    selectVariant(variant: VariantItem<T>): void;
    /** Returns original variant data. */
    getOriginalActiveVariantData(): Variant<T>['data'];
    /** Returns current active variant data with applied changes. */
    getActiveVariantData(): Variant<T>['data'];
    /**
     * Saves current variant with its configuration.
     */
    saveCurrentVariant(): void;
    /** @hidden */
    _openSaveDialog(): void;
    /**
     * Updates current active preset with new configuration.
     * @param preset Preset configuration.
     * @param componentName component to which this preset belongs to.
     */
    updateActivePreset(preset: T, componentName: string): void;
    /** @hidden */
    _openManageDialog(): void;
    /** @hidden */
    _onSearchSubmit(search: SearchInput): void;
    /** @hidden */
    _cancelSearch(): void;
    /** @Hidden */
    _trackFn(index: number, item: VariantItem<T>): string;
    /** @hidden */
    private _transformVariants;
    static ɵfac: i0.ɵɵFactoryDeclaration<VariantManagementComponent<any>, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<VariantManagementComponent<any>, "fdp-variant-management", never, { "variants": { "alias": "variants"; "required": false; }; "headerSize": { "alias": "headerSize"; "required": false; }; "popoverTriggers": { "alias": "popoverTriggers"; "required": false; }; "userName": { "alias": "userName"; "required": false; }; "displaySearch": { "alias": "displaySearch"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; }, { "variantsChange": "variantsChange"; "activeVariantChange": "activeVariantChange"; }, ["dirtyLabel"], never, true, never>;
    static ngAcceptInputType_displaySearch: unknown;
    static ngAcceptInputType_readonly: unknown;
}

interface SaveDialogContext {
    currentVariantName: string;
    existingVariantNames: string[];
}

declare class ManageVariantItemComponent {
    dialog: DialogRef<SaveDialogContext>;
    private readonly _formBuilder;
    /** @hidden */
    private readonly _formContainer;
    /** @Hidden */
    _form: FormGroup;
    /** @hidden */
    _nameValidator: ValidatorFn[];
    /** @hidden */
    private readonly _dialogConfig;
    /** @hidden */
    constructor(dialog: DialogRef<SaveDialogContext>, _formBuilder: FormBuilder);
    /** @Hidden */
    _submitForm(): void;
    /** @hidden */
    private _variantNameValidator;
    static ɵfac: i0.ɵɵFactoryDeclaration<ManageVariantItemComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<ManageVariantItemComponent, "fdp-manage-variant-item", never, {}, {}, never, never, true, never>;
}

/**
 * Wrapper component used to wrap components that implement `PresetManagedComponent`.
 * It automatically bounds existing presets from `Variant Management` component to `PresetManagedComponent`.
 * Wrapper component supports two ways of providing Variant Management component.
 * First one is to pass reference via Input property.
 * Second one is to put Variant Management component inside wrapper component so it would be accessible via @ContentChild.
 * Usage example:
 *
 * ```html
 *  Usage outside wrapper component:
 *  <fdp-variant-management #variantManagement [variants]="..."></fdp-variant-management>
 *  <fdp-variant-management-wrapper [variantManager]="variantManagement">
 *      <fdp-smart-filter-bar>...</fdp-smart-filter-bar>
 *      <fdp-table>...</fdp-table>
 *  </fdp-variant-management-wrapper>
 *
 *  Usage inside wrapper component:
 *  <fdp-variant-management-wrapper>
 *      <fdp-variant-management [variants]="..."></fdp-variant-management>
 *      <fdp-smart-filter-bar>...</fdp-smart-filter-bar>
 *      <fdp-table>...</fdp-table>
 *  </fdp-variant-management-wrapper>
 * ```
 */
declare class VariantManagementWrapperComponent implements AfterViewInit, OnDestroy {
    /** Variant management component. */
    variantManager: VariantManagement;
    /** @hidden */
    private readonly _managedComponents;
    /** @hidden */
    private set _projectedVariantManager(value);
    private get _projectedVariantManager();
    /** @hidden */
    private get _variantManagement();
    /** @hidden */
    private _variantManager;
    /** @hidden */
    private _activeVariantSubscription;
    /** @hidden */
    private _componentsPresetChangeSubscription;
    /** @hidden */
    private _destroyRef;
    /** @hidden */
    ngAfterViewInit(): void;
    /** @hidden */
    ngOnDestroy(): void;
    /**
     * @hidden
     * Listens to the preset change in Variant Management component and applies new configuration across projected components.
     */
    private _setPresets;
    /**
     * @hidden
     * Listens to preset configuration changes in projected components and sends updated config to Variant Management component.
     */
    private _listenToPresetChanges;
    /** @hidden */
    private _getComponentPreset;
    static ɵfac: i0.ɵɵFactoryDeclaration<VariantManagementWrapperComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<VariantManagementWrapperComponent, "fdp-variant-management-wrapper", never, { "variantManager": { "alias": "variantManager"; "required": false; }; }, {}, ["_projectedVariantManager", "_managedComponents"], ["*"], true, never>;
}

declare class ManageVariantsDialogComponent {
    dialog: DialogRef<VariantItem[]>;
    private readonly _cdr;
    /** @hidden */
    _source: TableDataSource<VariantItem>;
    /**
     * @hidden
     * Used to apply typings in template.
     */
    _variantModel: VariantItem;
    /** @hidden */
    private readonly _variants;
    /** @hidden */
    private readonly _dataProvider;
    /** @hidden */
    constructor(dialog: DialogRef<VariantItem[]>, _cdr: ChangeDetectorRef);
    /** @Hidden */
    _markAsFavourite(item: VariantItem): void;
    /** @hidden */
    _removeVariant(item: VariantItem): void;
    /**
     * @hidden
     * Closes dialog with updated variants array.
     */
    _saveVariants(): void;
    static ɵfac: i0.ɵɵFactoryDeclaration<ManageVariantsDialogComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<ManageVariantsDialogComponent, "fdp-manage-variants-dialog", never, {}, {}, never, never, true, never>;
}

/**
 * @deprecated
 * Use direct imports of components and directives.
 */
declare class VariantManagementModule {
    static ɵfac: i0.ɵɵFactoryDeclaration<VariantManagementModule, never>;
    static ɵmod: i0.ɵɵNgModuleDeclaration<VariantManagementModule, never, [typeof VariantManagementComponent, typeof VariantManagementDirtyLabelDirective, typeof ManageVariantItemComponent, typeof VariantManagementWrapperComponent, typeof ManageVariantsDialogComponent], [typeof VariantManagementComponent, typeof VariantManagementDirtyLabelDirective, typeof ManageVariantItemComponent, typeof VariantManagementWrapperComponent, typeof ManageVariantsDialogComponent]>;
    static ɵinj: i0.ɵɵInjectorDeclaration<VariantManagementModule>;
}

export { ManageVariantItemComponent, ManageVariantsDialogComponent, VariantManagementComponent, VariantManagementDirtyLabelDirective, VariantManagementModule, VariantManagementWrapperComponent };
export type { NewVariant, Variant, VariantAccess };
