import { InjectionToken, NgZone } from "@angular/core";
import { Observable } from "rxjs";
import { EntityData } from "../metadata";
import { DamAsset } from "./dam-asset";

/**
 * The base class that all custom DAM providers must implement
 *
 * @export
 * @abstract
 * @class DamProviderBase
 */
export declare abstract class DamProviderBase {
    constructor(zone: NgZone);

    /**
     * This method must load the script of the DAM and open the finder.
     * Call @loadDynamicScript to make sure script is loaded and then configure and open the widget.
     *
     * @param {HTMLElement} damWrapper The dom element in Sitefinity where the widget must me inserted
     * @param {EntityData} mediaEntityData Metadata for the content type to be inserted
     * @param {boolean} allowMultiSelect Specifies if the users can select one or multiple assets from the DAM
     * @memberof DamProviderBase
     */
    abstract loadMediaSelector(damWrapper: HTMLElement, mediaEntityData: EntityData, allowMultiSelect: boolean): void;

    /**
     * Returns if the provider type is supported.
     *
     * @param {string} providerTypeName The name of the provider to validate
     * @returns {boolean}
     * @memberof DamProviderBase
     */
    abstract isSupported(providerTypeName: string): boolean;

    /**
     * Returns the value of the specified property from the setting.
     * If property does not exist returns null.
     *
     * @param {string} name The name of the property
     * @returns {string}
     * @memberof DamProviderBase
     */
    protected getPropertyValue(name: string): string;

    /**
     * Adds the script to the document body with the specified URL.
     *
     * @param {string} url The url of the script
     * @memberof DamProviderBase
     */
    protected loadDynamicScript(url: string): Observable<void>;

    /**
     * Must be called to notify Admin App that assets from the DAM provider are selected before they are imported in Sitefinity.
     * Sets loading in the dialog to false.
     *
     * @memberof DamProviderBase
     */
    protected mediaSelected(): void;

    /**
     * Must be called to notify Admin App that an error has occurred.
     * Displays the error in the dialog.
     *
     * @memberof DamProviderBase
     */
    protected error(error: string): void;

    /**
     * Must be called to notify Admin App to handle the selected assets.
     * All DAM assets must be processed to match the interface.
     *
     * @memberof DamProviderBase
     */
    protected assetsSelected(assets: DamAsset[]): void;

    /**
     * Must be called to notify Admin App that import process is canceled.
     * Closes the dialog.
     *
     * @memberof DamProviderBase
     */
    protected cancel(): void;
}

export declare const DAM_PROVIDER_TOKEN: InjectionToken<string>;
