import * as i0 from '@angular/core';
import { InjectionToken, inject, DestroyRef, ElementRef, Directive } from '@angular/core';
import { MOBILE_CONFIG_ERROR } from '@fundamental-ngx/cdk/utils';
import { DialogService } from '@fundamental-ngx/core/dialog';

const MOBILE_MODE_CONFIG = new InjectionToken('Provides configuration for mobile control');
var MobileModeControl;
(function (MobileModeControl) {
    MobileModeControl["MENU"] = "MENU";
    MobileModeControl["SELECT"] = "SELECT";
    MobileModeControl["POPOVER"] = "POPOVER";
    MobileModeControl["COMBOBOX"] = "COMBOBOX";
    MobileModeControl["MULTI_INPUT"] = "MULTI_INPUT";
    MobileModeControl["MULTI_COMBOBOX"] = "MULTI_COMBOBOX";
    MobileModeControl["SEARCH_FIELD"] = "SEARCH_FIELD";
    MobileModeControl["DATE_PICKER"] = "DATE_PICKER";
    MobileModeControl["DATETIME_PICKER"] = "DATETIME_PICKER";
})(MobileModeControl || (MobileModeControl = {}));
class MobileModeBase {
    /** @hidden */
    constructor(_component, target) {
        this._component = _component;
        this.target = target;
        /** @hidden */
        this._destroyRef = inject(DestroyRef);
        /** @hidden */
        this._elementRef = inject(ElementRef);
        /** @hidden */
        this._dialogService = inject(DialogService);
        /** @hidden */
        this._mobileModes = inject(MOBILE_MODE_CONFIG, { optional: true }) || [];
        this.mobileConfig = this._getMobileModeConfig();
        this.dialogConfig = this.mobileConfig.dialogConfig;
    }
    /** @hidden */
    _getMobileModeConfig() {
        const injectedConfig = this._mobileModes.find((mode) => mode.target === this.target);
        // Handle both signal and plain property access for mobileConfig
        const mobileConfigProp = this._component.mobileConfig;
        const componentMobileConfig = typeof mobileConfigProp === 'function' ? mobileConfigProp() : mobileConfigProp;
        if (injectedConfig || componentMobileConfig) {
            return injectedConfig
                ? this._mergeConfigs(injectedConfig.config || {}, componentMobileConfig || {})
                : componentMobileConfig;
        }
        else {
            throw new Error(MOBILE_CONFIG_ERROR);
        }
    }
    /** @hidden Merges two mobile mode configs, with config2 taking precedence. */
    _mergeConfigs(config1, config2) {
        return {
            ...config1,
            ...config2,
            dialogConfig: {
                ...config1.dialogConfig,
                ...config2.dialogConfig
            }
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MobileModeBase, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: MobileModeBase, isStandalone: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MobileModeBase, decorators: [{
            type: Directive
        }], ctorParameters: () => [{ type: undefined }, { type: MobileModeControl }] });

/**
 * Generated bundle index. Do not edit.
 */

export { MOBILE_MODE_CONFIG, MobileModeBase, MobileModeControl };
//# sourceMappingURL=fundamental-ngx-core-mobile-mode.mjs.map
