import * as i0 from '@angular/core';
import { TemplateRef, Component, Attribute, Self, Inject, Optional, ViewChild, ContentChild, NgModule } from '@angular/core';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import { PROP_STRING, PROP_BOOLEAN, PROP_NUMBER, PROP_ANY, register, Context, provideAsWidgetRef, provideAsDialogRef, WmComponentsModule } from '@wm/components/base';
import * as i2 from '@wm/components/dialogs';
import { BaseDialog, DialogModule } from '@wm/components/dialogs';
import { InputModule } from '@wm/components/input';
import { toBoolean } from '@wm/core';

const registerProps = () => {
    register('wm-dialog', new Map([
        ['animation', PROP_STRING],
        ['class', PROP_STRING],
        ['closable', { value: true, ...PROP_BOOLEAN }],
        ['iconclass', { value: 'wi wi-file-text', PROP_STRING }],
        ['iconheight', PROP_STRING],
        ['iconmargin', PROP_STRING],
        ['iconurl', PROP_STRING],
        ['iconwidth', PROP_STRING],
        ['modal', { value: true, ...PROP_BOOLEAN }],
        ['name', PROP_STRING],
        ['showheader', { value: true, ...PROP_BOOLEAN }],
        ['tabindex', { value: 0, ...PROP_NUMBER }],
        ['title', { value: 'Information', ...PROP_STRING }],
        ['headinglevel', { value: 'h4', ...PROP_STRING }],
        ['eventsource', PROP_ANY]
    ]));
};

const _c0 = ["dialogBody"];
const _c1 = ["dialogFooter"];
const _c2 = ["dialogTemplate"];
const _c3 = ["wmDialog", ""];
function DialogComponent_ng_template_0_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 4);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("closable", ctx_r0.closable)("iconclass", ctx_r0.iconclass)("iconurl", ctx_r0.iconurl)("iconwidth", ctx_r0.iconwidth)("iconheight", ctx_r0.iconheight)("iconmargin", ctx_r0.iconmargin)("heading", ctx_r0.title)("headinglevel", ctx_r0.headinglevel)("title", ctx_r0.title)("titleid", ctx_r0.titleId);
} }
function DialogComponent_ng_template_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function DialogComponent_ng_template_0_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function DialogComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, DialogComponent_ng_template_0_div_0_Template, 1, 10, "div", 1);
    i0.ɵɵelementStart(1, "div", 2);
    i0.ɵɵtemplate(2, DialogComponent_ng_template_0_ng_container_2_Template, 1, 0, "ng-container", 3);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, DialogComponent_ng_template_0_ng_container_3_Template, 1, 0, "ng-container", 3);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngIf", ctx_r0.showheader);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.dialogBody);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.dialogFooter);
} }
const DIALOG_CLS = 'app-dialog modal-dialog';
const WIDGET_INFO = { widgetType: 'wm-dialog' };
class DialogComponent extends BaseDialog {
    static { this.initializeProps = registerProps(); }
    constructor(inj, dialogClass, modal, closable, contexts, explicitContext) {
        if (modal === null || modal === undefined) {
            modal = true;
        }
        if (closable === null || closable === undefined) {
            closable = true;
        }
        // contexts[0] will refer to the self context provided by this component
        contexts[0].closeDialog = () => this.close();
        // setting the backdrop to 'static' will not close the dialog on backdrop click
        const backdrop = toBoolean(modal) ? 'static' : true;
        super(inj, WIDGET_INFO, {
            class: `${DIALOG_CLS} ${dialogClass || ''}`,
            backdrop,
            keyboard: toBoolean(closable) ? true : !toBoolean(modal)
        }, explicitContext);
        this.isDialogComponent = true;
    }
    getTemplateRef() {
        return this.dialogTemplate;
    }
    ngOnInit() {
        super.ngOnInit();
        this.register(this.viewParent);
    }
    static { this.ɵfac = function DialogComponent_Factory(t) { return new (t || DialogComponent)(i0.ɵɵdirectiveInject(i0.Injector), i0.ɵɵinjectAttribute('class'), i0.ɵɵinjectAttribute('modal'), i0.ɵɵinjectAttribute('closable'), i0.ɵɵdirectiveInject(Context, 2), i0.ɵɵdirectiveInject('EXPLICIT_CONTEXT', 8)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DialogComponent, selectors: [["div", "wmDialog", ""]], contentQueries: function DialogComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
            i0.ɵɵcontentQuery(dirIndex, _c0, 5, TemplateRef);
            i0.ɵɵcontentQuery(dirIndex, _c1, 5, TemplateRef);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dialogBody = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dialogFooter = _t.first);
        } }, viewQuery: function DialogComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c2, 7, TemplateRef);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dialogTemplate = _t.first);
        } }, features: [i0.ɵɵProvidersFeature([
                provideAsWidgetRef(DialogComponent),
                provideAsDialogRef(DialogComponent),
                { provide: Context, useFactory: () => { return {}; }, multi: true }
            ]), i0.ɵɵInheritDefinitionFeature], attrs: _c3, decls: 2, vars: 0, consts: [["dialogTemplate", ""], ["wmDialogHeader", "", 3, "closable", "iconclass", "iconurl", "iconwidth", "iconheight", "iconmargin", "heading", "headinglevel", "title", "titleid", 4, "ngIf"], ["wmDialogBody", ""], [4, "ngTemplateOutlet"], ["wmDialogHeader", "", 3, "closable", "iconclass", "iconurl", "iconwidth", "iconheight", "iconmargin", "heading", "headinglevel", "title", "titleid"]], template: function DialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, DialogComponent_ng_template_0_Template, 4, 3, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
        } }, dependencies: [i1.NgIf, i1.NgTemplateOutlet, i2.DialogBodyDirective, i2.DialogHeaderComponent], encapsulation: 2 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DialogComponent, [{
        type: Component,
        args: [{ selector: 'div[wmDialog]', providers: [
                    provideAsWidgetRef(DialogComponent),
                    provideAsDialogRef(DialogComponent),
                    { provide: Context, useFactory: () => { return {}; }, multi: true }
                ], 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         *ngIf=\"showheader\"\n         [title]=\"title\"\n         [titleid]=\"titleId\"\n    ></div>\n    <div wmDialogBody>\n        <ng-container *ngTemplateOutlet=\"dialogBody\"></ng-container>\n    </div>\n    <ng-container *ngTemplateOutlet=\"dialogFooter\"></ng-container>\n</ng-template>\n" }]
    }], () => [{ type: i0.Injector }, { type: undefined, decorators: [{
                type: Attribute,
                args: ['class']
            }] }, { type: undefined, decorators: [{
                type: Attribute,
                args: ['modal']
            }] }, { type: undefined, decorators: [{
                type: Attribute,
                args: ['closable']
            }] }, { type: Array, decorators: [{
                type: Self
            }, {
                type: Inject,
                args: [Context]
            }] }, { type: undefined, decorators: [{
                type: Inject,
                args: ['EXPLICIT_CONTEXT']
            }, {
                type: Optional
            }] }], { dialogTemplate: [{
            type: ViewChild,
            args: ['dialogTemplate', { static: true, read: TemplateRef }]
        }], dialogBody: [{
            type: ContentChild,
            args: ['dialogBody', /* TODO: add static flag */ { read: TemplateRef }]
        }], dialogFooter: [{
            type: ContentChild,
            args: ['dialogFooter', /* TODO: add static flag */ { read: TemplateRef }]
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(DialogComponent, { className: "DialogComponent", filePath: "dialog.component.ts", lineNumber: 33 }); })();

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

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

export { DesignDialogModule, DialogComponent };
//# sourceMappingURL=index.mjs.map
