(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@wm/components/base'), require('@wm/components/dialogs'), require('@wm/components/input'), require('@wm/core')) :
    typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common', '@wm/components/base', '@wm/components/dialogs', '@wm/components/input', '@wm/core'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.wm = global.wm || {}, global.wm.components = global.wm.components || {}, global.wm.components.dialogs = global.wm.components.dialogs || {}, global.wm.components.dialogs.partialdialog = {}), global.ng.core, global.ng.common, global.wm.components.base, global.wm.components.dialogs, global.wm.components.input, global.wm.core));
})(this, (function (exports, i0, i2, base, i3, i4, i1) { 'use strict';

    function _interopNamespaceDefault(e) {
        var n = Object.create(null);
        if (e) {
            Object.keys(e).forEach(function (k) {
                if (k !== 'default') {
                    var d = Object.getOwnPropertyDescriptor(e, k);
                    Object.defineProperty(n, k, d.get ? d : {
                        enumerable: true,
                        get: function () { return e[k]; }
                    });
                }
            });
        }
        n.default = e;
        return Object.freeze(n);
    }

    var i0__namespace = /*#__PURE__*/_interopNamespaceDefault(i0);
    var i2__namespace = /*#__PURE__*/_interopNamespaceDefault(i2);
    var i3__namespace = /*#__PURE__*/_interopNamespaceDefault(i3);
    var i4__namespace = /*#__PURE__*/_interopNamespaceDefault(i4);
    var i1__namespace = /*#__PURE__*/_interopNamespaceDefault(i1);

    const registerProps = () => {
        base.register('wm-partialdialog', new Map([
            ['animation', base.PROP_STRING],
            ['class', base.PROP_STRING],
            ['closable', { value: true, PROP_BOOLEAN: base.PROP_BOOLEAN }],
            ['content', base.PROP_STRING],
            ['iconclass', { value: 'wi wi-file', PROP_STRING: base.PROP_STRING }],
            ['iconheight', base.PROP_STRING],
            ['iconmargin', base.PROP_STRING],
            ['iconurl', base.PROP_STRING],
            ['iconwidth', base.PROP_STRING],
            ['modal', { value: false, ...base.PROP_BOOLEAN }],
            ['name', base.PROP_STRING],
            ['oktext', { value: 'OK', ...base.PROP_STRING }],
            ['showactions', { value: true, ...base.PROP_BOOLEAN }],
            ['tabindex', { value: 0, ...base.PROP_NUMBER }],
            ['headinglevel', { value: 'h4', ...base.PROP_STRING }],
            ['title', { value: 'Page Content', ...base.PROP_STRING }]
        ]));
    };

    const _c0 = ["partial"];
    const _c1 = ["dialogTemplate"];
    const _c2 = ["wmPartialDialog", ""];
    function PartialDialogComponent_ng_template_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
        i0__namespace.ɵɵelementContainer(0);
    } }
    function PartialDialogComponent_ng_template_0_div_3_Template(rf, ctx) { if (rf & 1) {
        const _r1 = i0__namespace.ɵɵgetCurrentView();
        i0__namespace.ɵɵelementStart(0, "div", 5)(1, "button", 6);
        i0__namespace.ɵɵlistener("click", function PartialDialogComponent_ng_template_0_div_3_Template_button_click_1_listener($event) { i0__namespace.ɵɵrestoreView(_r1); const ctx_r1 = i0__namespace.ɵɵnextContext(2); return i0__namespace.ɵɵresetView(ctx_r1.onOk($event)); });
        i0__namespace.ɵɵelementEnd()();
    } if (rf & 2) {
        const ctx_r1 = i0__namespace.ɵɵnextContext(2);
        i0__namespace.ɵɵadvance();
        i0__namespace.ɵɵattribute("aria-label", ctx_r1.oktext);
    } }
    function PartialDialogComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
        i0__namespace.ɵɵelement(0, "div", 1);
        i0__namespace.ɵɵelementStart(1, "div", 2);
        i0__namespace.ɵɵtemplate(2, PartialDialogComponent_ng_template_0_ng_container_2_Template, 1, 0, "ng-container", 3);
        i0__namespace.ɵɵelementEnd();
        i0__namespace.ɵɵtemplate(3, PartialDialogComponent_ng_template_0_div_3_Template, 2, 1, "div", 4);
    } if (rf & 2) {
        const ctx_r1 = i0__namespace.ɵɵnextContext();
        i0__namespace.ɵɵproperty("closable", ctx_r1.closable)("iconclass", ctx_r1.iconclass)("iconurl", ctx_r1.iconurl)("iconwidth", ctx_r1.iconwidth)("iconheight", ctx_r1.iconheight)("iconmargin", ctx_r1.iconmargin)("heading", ctx_r1.title)("headinglevel", ctx_r1.headinglevel)("title", ctx_r1.title)("titleid", ctx_r1.titleId);
        i0__namespace.ɵɵadvance(2);
        i0__namespace.ɵɵproperty("ngTemplateOutlet", ctx_r1.dialogContent);
        i0__namespace.ɵɵadvance();
        i0__namespace.ɵɵproperty("ngIf", ctx_r1.showactions);
    } }
    const DIALOG_CLS = 'app-dialog modal-dialog app-page-dialog';
    const WIDGET_INFO = { widgetType: 'wm-partialdialog' };
    class PartialDialogComponent extends i3.BaseDialog {
        static { this.initializeProps = registerProps(); }
        constructor(inj, app, dialogClass, modal, closable, explicitContext) {
            if (modal === null || modal === undefined) {
                modal = false;
            }
            // setting the backdrop to 'static' will not close the dialog on backdrop click
            const backdrop = i1.toBoolean(modal) ? 'static' : true;
            super(inj, WIDGET_INFO, {
                class: `${DIALOG_CLS} ${dialogClass || ''}`,
                backdrop,
                keyboard: !i1.toBoolean(modal)
            }, explicitContext);
            this.app = app;
        }
        getTemplateRef() {
            return this.dialogTemplate;
        }
        /**
         * Click event handler for the ok button
         * invokes on-ok event callback
         * @param {Event} $event
         */
        onOk($event) {
            this.invokeEventCallback('ok', { $event });
        }
        ngOnInit() {
            super.ngOnInit();
            this.register(this.viewParent);
        }
        setPartialLoadListener() {
            const cancelSubscription = this.app.subscribe('partialLoaded', () => {
                const parEle = this.partialRef.nativeElement;
                let partialScope;
                if (parEle) {
                    partialScope = parEle.widget;
                    this.Widgets = partialScope.Widgets;
                    this.Variables = partialScope.Variables;
                    this.Actions = partialScope.Actions;
                }
                cancelSubscription();
            });
        }
        open(initState) {
            super.open(initState);
            // WMS-19410 - Set the partial load listener to access widgets, variables and actions of page dialog
            this.setPartialLoadListener();
        }
        static { this.ɵfac = function PartialDialogComponent_Factory(t) { return new (t || PartialDialogComponent)(i0__namespace.ɵɵdirectiveInject(i0__namespace.Injector), i0__namespace.ɵɵdirectiveInject(i1__namespace.App), i0__namespace.ɵɵinjectAttribute('class'), i0__namespace.ɵɵinjectAttribute('modal'), i0__namespace.ɵɵinjectAttribute('closable'), i0__namespace.ɵɵdirectiveInject('EXPLICIT_CONTEXT', 8)); }; }
        static { this.ɵcmp = /*@__PURE__*/ i0__namespace.ɵɵdefineComponent({ type: PartialDialogComponent, selectors: [["div", "wmPartialDialog", ""]], contentQueries: function PartialDialogComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
                i0__namespace.ɵɵcontentQuery(dirIndex, i0.TemplateRef, 5);
                i0__namespace.ɵɵcontentQuery(dirIndex, _c0, 5);
            } if (rf & 2) {
                let _t;
                i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.dialogContent = _t.first);
                i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.partialRef = _t.first);
            } }, viewQuery: function PartialDialogComponent_Query(rf, ctx) { if (rf & 1) {
                i0__namespace.ɵɵviewQuery(_c1, 7);
            } if (rf & 2) {
                let _t;
                i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.dialogTemplate = _t.first);
            } }, features: [i0__namespace.ɵɵProvidersFeature([
                    base.provideAsWidgetRef(PartialDialogComponent),
                    base.provideAsDialogRef(PartialDialogComponent)
                ]), i0__namespace.ɵɵInheritDefinitionFeature], attrs: _c2, decls: 2, vars: 0, consts: [["dialogTemplate", ""], ["wmDialogHeader", "", 3, "closable", "iconclass", "iconurl", "iconwidth", "iconheight", "iconmargin", "heading", "headinglevel", "title", "titleid"], ["wmDialogBody", ""], [4, "ngTemplateOutlet"], ["wmDialogFooter", "", 4, "ngIf"], ["wmDialogFooter", ""], ["caption.bind", "oktext", "wmButton", "", 1, "btn-primary", "ok-action", 3, "click"]], template: function PartialDialogComponent_Template(rf, ctx) { if (rf & 1) {
                i0__namespace.ɵɵtemplate(0, PartialDialogComponent_ng_template_0_Template, 4, 12, "ng-template", null, 0, i0__namespace.ɵɵtemplateRefExtractor);
            } }, dependencies: [i2__namespace.NgIf, i2__namespace.NgTemplateOutlet, i3__namespace.DialogBodyDirective, i3__namespace.DialogFooterDirective, i3__namespace.DialogHeaderComponent, i4__namespace.ButtonComponent], encapsulation: 2 }); }
    }
    (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(PartialDialogComponent, [{
            type: i0.Component,
            args: [{ selector: 'div[wmPartialDialog]', providers: [
                        base.provideAsWidgetRef(PartialDialogComponent),
                        base.provideAsDialogRef(PartialDialogComponent)
                    ], template: "<ng-template #dialogTemplate>\n    <div wmDialogHeader [closable]=\"closable\"\n         [iconclass]=\"iconclass\"\n         [iconurl]=\"iconurl\"\n         [iconwidth]=\"iconwidth\"\n         [iconheight]=\"iconheight\"\n         [iconmargin]=\"iconmargin\"\n         [heading]=\"title\"\n         [headinglevel]=\"headinglevel\"\n         [title]=\"title\"\n         [titleid]=\"titleId\"\n    ></div>\n    <div wmDialogBody>\n        <ng-container *ngTemplateOutlet=\"dialogContent\"></ng-container>\n    </div>\n    <div wmDialogFooter *ngIf=\"showactions\">\n        <button (click)=\"onOk($event)\" [attr.aria-label]=\"oktext\" caption.bind=\"oktext\" class=\"btn-primary ok-action\"\n                wmButton></button>\n    </div>\n</ng-template>\n" }]
        }], () => [{ type: i0__namespace.Injector }, { type: i1__namespace.App }, { type: undefined, decorators: [{
                    type: i0.Attribute,
                    args: ['class']
                }] }, { type: undefined, decorators: [{
                    type: i0.Attribute,
                    args: ['modal']
                }] }, { type: undefined, decorators: [{
                    type: i0.Attribute,
                    args: ['closable']
                }] }, { type: undefined, decorators: [{
                    type: i0.Inject,
                    args: ['EXPLICIT_CONTEXT']
                }, {
                    type: i0.Optional
                }] }], { dialogTemplate: [{
                type: i0.ViewChild,
                args: ['dialogTemplate', { static: true }]
            }], dialogContent: [{
                type: i0.ContentChild,
                args: [i0.TemplateRef]
            }], partialRef: [{
                type: i0.ContentChild,
                args: ['partial']
            }] }); })();
    (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassDebugInfo(PartialDialogComponent, { className: "PartialDialogComponent", filePath: "partial-dialog.component.ts", lineNumber: 31 }); })();

    const components = [
        PartialDialogComponent
    ];
    class PartialDialogModule {
        static { this.ɵfac = function PartialDialogModule_Factory(t) { return new (t || PartialDialogModule)(); }; }
        static { this.ɵmod = /*@__PURE__*/ i0__namespace.ɵɵdefineNgModule({ type: PartialDialogModule }); }
        static { this.ɵinj = /*@__PURE__*/ i0__namespace.ɵɵdefineInjector({ imports: [i2.CommonModule,
                i3.DialogModule,
                i4.InputModule,
                base.WmComponentsModule] }); }
    }
    (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(PartialDialogModule, [{
            type: i0.NgModule,
            args: [{
                    imports: [
                        i2.CommonModule,
                        i3.DialogModule,
                        i4.InputModule,
                        base.WmComponentsModule
                    ],
                    declarations: [...components],
                    exports: [...components]
                }]
        }], null, null); })();
    (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0__namespace.ɵɵsetNgModuleScope(PartialDialogModule, { declarations: [PartialDialogComponent], imports: [i2.CommonModule,
            i3.DialogModule,
            i4.InputModule,
            base.WmComponentsModule], exports: [PartialDialogComponent] }); })();

    exports.PartialDialogComponent = PartialDialogComponent;
    exports.PartialDialogModule = PartialDialogModule;

}));
