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

const registerProps = () => {
    register('wm-alertdialog', new Map([
        ['alerttype', { value: 'error', ...PROP_STRING }],
        ['animation', PROP_STRING],
        ['class', PROP_STRING],
        ['closable', { value: true, PROP_BOOLEAN }],
        ['iconclass', { value: 'wi wi-warning', PROP_STRING }],
        ['iconheight', PROP_STRING],
        ['iconmargin', PROP_STRING],
        ['iconurl', PROP_STRING],
        ['iconwidth', PROP_STRING],
        ['message', { value: 'Am an alert box!', ...PROP_STRING }],
        ['modal', { value: false, ...PROP_BOOLEAN }],
        ['name', PROP_STRING],
        ['oktext', { value: 'OK', ...PROP_STRING }],
        ['tabindex', { value: 0, ...PROP_NUMBER }],
        ['headinglevel', { value: 'h4', ...PROP_STRING }],
        ['title', { value: 'Alert', ...PROP_STRING }]
    ]));
};

const _c0 = ["dialogTemplate"];
const _c1 = ["wmAlertDialog", ""];
function AlertDialogComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelement(0, "div", 1);
    i0.ɵɵelementStart(1, "div", 2);
    i0.ɵɵelement(2, "p", 3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 4)(4, "button", 5);
    i0.ɵɵlistener("click", function AlertDialogComponent_ng_template_0_Template_button_click_4_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onOk($event)); });
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵ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.ɵɵadvance(2);
    i0.ɵɵclassMapInterpolate1("app-dialog-message text-", ctx_r1.alerttype, "");
    i0.ɵɵproperty("textContent", ctx_r1.message);
    i0.ɵɵadvance(2);
    i0.ɵɵattribute("aria-label", ctx_r1.oktext);
} }
const DIALOG_CLS = 'app-dialog modal-dialog app-alert-dialog';
const WIDGET_INFO = { widgetType: 'wm-alertdialog' };
class AlertDialogComponent extends BaseDialog {
    static { this.initializeProps = registerProps(); }
    constructor(inj, dialogClass, modal, closable, explicitContext) {
        if (modal === null || modal === undefined) {
            modal = false;
        }
        if (closable === null || closable === undefined) {
            closable = true;
        }
        // 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(modal)
        }, explicitContext);
    }
    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);
    }
    static { this.ɵfac = function AlertDialogComponent_Factory(t) { return new (t || AlertDialogComponent)(i0.ɵɵdirectiveInject(i0.Injector), i0.ɵɵinjectAttribute('class'), i0.ɵɵinjectAttribute('modal'), i0.ɵɵinjectAttribute('closable'), i0.ɵɵdirectiveInject('EXPLICIT_CONTEXT', 8)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AlertDialogComponent, selectors: [["div", "wmAlertDialog", ""]], viewQuery: function AlertDialogComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0, 7);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dialogTemplate = _t.first);
        } }, features: [i0.ɵɵProvidersFeature([
                provideAsWidgetRef(AlertDialogComponent),
                provideAsDialogRef(AlertDialogComponent)
            ]), i0.ɵɵInheritDefinitionFeature], attrs: _c1, decls: 2, vars: 0, consts: [["dialogTemplate", ""], ["wmDialogHeader", "", 3, "closable", "iconclass", "iconurl", "iconwidth", "iconheight", "iconmargin", "heading", "headinglevel", "title", "titleid"], ["wmDialogBody", ""], [3, "textContent"], ["wmDialogFooter", ""], ["caption.bind", "oktext", "wmButton", "", 1, "btn-primary", "ok-action", 3, "click"]], template: function AlertDialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, AlertDialogComponent_ng_template_0_Template, 5, 15, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
        } }, dependencies: [i1.DialogBodyDirective, i1.DialogFooterDirective, i1.DialogHeaderComponent, i2.ButtonComponent, i3.TextContentDirective], encapsulation: 2 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AlertDialogComponent, [{
        type: Component,
        args: [{ selector: 'div[wmAlertDialog]', providers: [
                    provideAsWidgetRef(AlertDialogComponent),
                    provideAsDialogRef(AlertDialogComponent)
                ], 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\"></div>\n    <div wmDialogBody>\n        <p class=\"app-dialog-message text-{{alerttype}}\" [textContent]=\"message\"></p>\n    </div>\n    <div wmDialogFooter>\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.Injector }, { type: undefined, decorators: [{
                type: Attribute,
                args: ['class']
            }] }, { type: undefined, decorators: [{
                type: Attribute,
                args: ['modal']
            }] }, { type: undefined, decorators: [{
                type: Attribute,
                args: ['closable']
            }] }, { type: undefined, decorators: [{
                type: Inject,
                args: ['EXPLICIT_CONTEXT']
            }, {
                type: Optional
            }] }], { dialogTemplate: [{
            type: ViewChild,
            args: ['dialogTemplate', { static: true }]
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AlertDialogComponent, { className: "AlertDialogComponent", filePath: "alert-dialog.component.ts", lineNumber: 31 }); })();

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

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

export { AlertDialogComponent, AlertDialogModule };
//# sourceMappingURL=index.mjs.map
