(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/material/dialog'), require('@angular/material/icon'), require('@angular/material/button'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/forms'), require('@sd-angular/core/button'), require('uuid'), require('@sd-angular/core/date-time'), require('@sd-angular/core/common')) :
    typeof define === 'function' && define.amd ? define('@sd-angular/core/confirm', ['exports', '@angular/core', '@angular/common', '@angular/material/dialog', '@angular/material/icon', '@angular/material/button', '@angular/material/form-field', '@angular/material/input', '@angular/forms', '@sd-angular/core/button', 'uuid', '@sd-angular/core/date-time', '@sd-angular/core/common'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['sd-angular'] = global['sd-angular'] || {}, global['sd-angular'].core = global['sd-angular'].core || {}, global['sd-angular'].core.confirm = {}), global.ng.core, global.ng.common, global.ng.material.dialog, global.ng.material.icon, global.ng.material.button, global.ng.material.formField, global.ng.material.input, global.ng.forms, global['sd-angular'].core.button, global.uuid, global['sd-angular'].core['date-time']));
}(this, (function (exports, core, common, dialog, icon, button, formField, input, forms, button$1, uuid, dateTime) { 'use strict';

    var DialogConfirmComponent = /** @class */ (function () {
        function DialogConfirmComponent(dialogRef, data) {
            var _a, _b, _c, _d, _e, _f, _g;
            this.dialogRef = dialogRef;
            this.data = data;
            this.required = false;
            this.isString = false;
            this.id = "I" + uuid.v4();
            this.isString = typeof ((_a = this.data) === null || _a === void 0 ? void 0 : _a.message) === 'string';
            if (data === null || data === void 0 ? void 0 : data.input) {
                this.value = (_c = (_b = data === null || data === void 0 ? void 0 : data.input) === null || _b === void 0 ? void 0 : _b.defaultValue) !== null && _c !== void 0 ? _c : '';
                this.required = ((_d = data === null || data === void 0 ? void 0 : data.input) === null || _d === void 0 ? void 0 : _d.required) || false;
            }
            if (data === null || data === void 0 ? void 0 : data.date) {
                this.value = (_f = (_e = data === null || data === void 0 ? void 0 : data.date) === null || _e === void 0 ? void 0 : _e.defaultValue) !== null && _f !== void 0 ? _f : '';
                this.required = ((_g = data === null || data === void 0 ? void 0 : data.date) === null || _g === void 0 ? void 0 : _g.required) || false;
            }
        }
        return DialogConfirmComponent;
    }());
    DialogConfirmComponent.decorators = [
        { type: core.Component, args: [{
                    selector: 'sd-dialog-confirm',
                    template: "<h1 mat-dialog-title class=\"\">\r\n  <mat-icon *ngIf=\"data?.icon\" [ngClass]=\"data?.icon\">\r\n    {{ data?.icon }}\r\n  </mat-icon>\r\n  <span [innerHtml]=\"data?.title || 'Confirm'\"></span>\r\n</h1>\r\n<div mat-dialog-content>\r\n  <div *ngIf=\"isString\" [innerHtml]=\"data?.message\"></div>\r\n  <div *ngIf=\"!isString\" [innerHtml]=\"data?.message | json\"></div>\r\n  <div *ngIf=\"data?.input\">\r\n    <mat-form-field appearance=\"outline\">\r\n      <textarea style=\"width: 100%\" matInput [placeholder]=\"data.input?.placeholder\" [(ngModel)]=\"value\"\r\n        autocomplete=\"off\" rows=\"5\" [maxlength]=\"data.input?.maxlength\"></textarea>\r\n    </mat-form-field>\r\n  </div>\r\n  <div *ngIf=\"data?.date\">\r\n    <sd-date-time [placeholder]=\"data.date?.placeholder\" [(model)]=\"value\" type=\"date\" [min]=\"data.date?.min\"\r\n      [max]=\"data.date?.max\" [required]=\"required\">\r\n    </sd-date-time>\r\n  </div>\r\n</div>\r\n<div mat-dialog-actions align=\"end\">\r\n  <sd-button *ngIf=\"data?.noTitle\" [color]=\"data?.noButtonColor || 'secondary'\" [mat-dialog-close]=\"'CANCEL'\"\r\n    [title]=\"data?.noTitle\" size=\"sm\"></sd-button>\r\n  <sd-button class=\"ml-12\" *ngIf=\"data?.yesTitle\" [mat-dialog-close]=\"value || 'ACCEPT'\"\r\n    [color]=\"data?.yesButtonColor || 'primary'\" [disabled]=\"required && !value\" cdkFocusInitial\r\n    [title]=\"data?.yesTitle\" size=\"sm\"></sd-button>\r\n</div>",
                    styles: [":host .mat-dialog-content{margin:0 -16px 16px!important}:host .mat-button{background-color:#f5f5f5}:host>>>.mat-dialog-title{align-items:center;display:flex;justify-content:flex-start}:host>>>.mat-dialog-title .mat-icon{margin-right:5px}:host{display:block;padding:12px 16px}:host>>>.mat-dialog-title .mat-icon.info{color:#2962ff}:host>>>.mat-dialog-title .mat-icon.warning{color:#ffc107}:host>>>.mat-dialog-title .mat-icon.done{color:#4caf50}:host>>>.mat-dialog-title .mat-icon.error{color:#d32f2f}"]
                },] }
    ];
    DialogConfirmComponent.ctorParameters = function () { return [
        { type: dialog.MatDialogRef },
        { type: undefined, decorators: [{ type: core.Inject, args: [dialog.MAT_DIALOG_DATA,] }] }
    ]; };

    var SdConfirmService = /** @class */ (function () {
        function SdConfirmService(dialog) {
            var _this = this;
            this.dialog = dialog;
            this.withInput = function (option) {
                var dialogRef = _this.dialog.open(DialogConfirmComponent, {
                    width: '400px',
                    data: {
                        title: (option === null || option === void 0 ? void 0 : option.title) || 'Xác nhận',
                        message: option === null || option === void 0 ? void 0 : option.message,
                        yesTitle: (option === null || option === void 0 ? void 0 : option.yesTitle) || 'Có',
                        noTitle: (option === null || option === void 0 ? void 0 : option.noTitle) || 'Không',
                        noButtonColor: (option === null || option === void 0 ? void 0 : option.noButtonColor) || 'secondary',
                        yesButtonColor: (option === null || option === void 0 ? void 0 : option.yesButtonColor) || 'primary',
                        input: {
                            maxlength: (option === null || option === void 0 ? void 0 : option.maxlength) || 255,
                            required: option === null || option === void 0 ? void 0 : option.required,
                            defaultValue: (option === null || option === void 0 ? void 0 : option.defaultValue) || ''
                        },
                    },
                });
                return new Promise(function (resolve, reject) {
                    dialogRef.afterClosed().subscribe(function (result) {
                        if (result) {
                            if (result === 'ACCEPT') {
                                resolve(result);
                            }
                            else if (result === 'CANCEL') {
                                reject(result);
                            }
                            else {
                                resolve(result);
                            }
                        }
                    });
                });
            };
            this.withDate = function (option) {
                var dialogRef = _this.dialog.open(DialogConfirmComponent, {
                    width: '400px',
                    data: {
                        title: (option === null || option === void 0 ? void 0 : option.title) || 'Xác nhận',
                        message: option === null || option === void 0 ? void 0 : option.message,
                        yesTitle: (option === null || option === void 0 ? void 0 : option.yesTitle) || 'Có',
                        noTitle: (option === null || option === void 0 ? void 0 : option.noTitle) || 'Không',
                        noButtonColor: (option === null || option === void 0 ? void 0 : option.noButtonColor) || 'secondary',
                        yesButtonColor: (option === null || option === void 0 ? void 0 : option.yesButtonColor) || 'primary',
                        date: {
                            placeholder: option === null || option === void 0 ? void 0 : option.placeholder,
                            required: option === null || option === void 0 ? void 0 : option.required,
                            defaultValue: (option === null || option === void 0 ? void 0 : option.defaultValue) || '',
                        },
                    },
                });
                return new Promise(function (resolve, reject) {
                    dialogRef.afterClosed().subscribe(function (result) {
                        if (result) {
                            if (result === 'ACCEPT') {
                                resolve(result);
                            }
                            else if (result === 'CANCEL') {
                                reject(result);
                            }
                            else {
                                resolve(result);
                            }
                        }
                    });
                });
            };
        }
        return SdConfirmService;
    }());
    SdConfirmService.decorators = [
        { type: core.Injectable }
    ];
    SdConfirmService.ctorParameters = function () { return [
        { type: dialog.MatDialog }
    ]; };

    var SdConfirmModule = /** @class */ (function () {
        function SdConfirmModule() {
        }
        return SdConfirmModule;
    }());
    SdConfirmModule.decorators = [
        { type: core.NgModule, args: [{
                    imports: [
                        common.CommonModule,
                        forms.FormsModule,
                        formField.MatFormFieldModule,
                        input.MatInputModule,
                        dateTime.SdDateTimeModule,
                        icon.MatIconModule,
                        button.MatButtonModule,
                        dialog.MatDialogModule,
                        button$1.SdButtonModule,
                    ],
                    declarations: [DialogConfirmComponent],
                    entryComponents: [DialogConfirmComponent],
                    exports: [],
                    providers: [SdConfirmService],
                },] }
    ];

    /*
     * Public API Surface of superdev-angular-core
     */

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

    exports.DialogConfirmComponent = DialogConfirmComponent;
    exports.SdConfirmModule = SdConfirmModule;
    exports.SdConfirmService = SdConfirmService;

    Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=sd-angular-core-confirm.umd.js.map
