var _a;
import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Emit, Prop } from 'vue-property-decorator';
import { BackdropMode, Portal } from '../../mixins/portal/portal';
import DialogServicePlugin from '../../utils/dialog/dialog-service.plugin';
import { ModulVue } from '../../utils/vue/vue';
import { MButton } from '../button/button';
import { BUTTON_NAME, DIALOG_NAME, I18N_NAME, ICON_NAME, LINK_NAME, MESSAGE_NAME } from '../component-names';
import { MI18n } from '../i18n/i18n';
import { MIcon } from '../icon/icon';
import { MLink } from '../link/link';
import { MMessage } from '../message/message';
import WithRender from './dialog.html?style=./dialog.scss';
export var MDialogWidth;
(function (MDialogWidth) {
    MDialogWidth["Default"] = "default";
    MDialogWidth["Large"] = "large";
})(MDialogWidth || (MDialogWidth = {}));
export var MDialogState;
(function (MDialogState) {
    MDialogState["Default"] = "default";
    MDialogState["Warning"] = "warning";
    MDialogState["Confirmation"] = "confirmation";
    MDialogState["Information"] = "information";
    MDialogState["Error"] = "error";
})(MDialogState || (MDialogState = {}));
var MDialog = /** @class */ (function (_super) {
    __extends(MDialog, _super);
    function MDialog() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MDialog.prototype.handlesFocus = function () {
        return true;
    };
    MDialog.prototype.openDialog = function () {
        this.as().propOpen = true;
    };
    MDialog.prototype.doCustomPropOpen = function (value) {
        return false;
    };
    MDialog.prototype.getBackdropMode = function () {
        return BackdropMode.BackdropFast;
    };
    MDialog.prototype.getPortalElement = function () {
        return this.$refs.article;
    };
    MDialog.prototype.onOk = function (event) {
        this.as().propOpen = false;
    };
    MDialog.prototype.onSecondaryBtn = function (event) {
        this.as().propOpen = false;
    };
    MDialog.prototype.onCancel = function (event) {
        this.as().propOpen = false;
    };
    Object.defineProperty(MDialog.prototype, "hasDefaultSlot", {
        get: function () {
            return !!this.$slots.default;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "hasFooterSlot", {
        get: function () {
            return !!this.$slots.footer;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "hasHint", {
        get: function () {
            return !!this.hint;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "hasTitle", {
        get: function () {
            return !!this.title;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "hasMessage", {
        get: function () {
            return !!this.message;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "hasOkLabel", {
        get: function () {
            return !!this.okLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "hasOkPrecision", {
        get: function () {
            return !!this.okPrecision;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "hasSecBtnLabel", {
        get: function () {
            return !!this.secBtnLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "hasSecBtnPrecision", {
        get: function () {
            return !!this.secBtnPrecision;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "dialogStyles", {
        get: function () {
            return { 'width': this.btnWidth };
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "hasCancelLabel", {
        get: function () {
            return !!this.cancelLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "hasWidthLarge", {
        get: function () {
            return this.width === MDialogWidth.Large;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MDialog.prototype, "getState", {
        get: function () {
            var state = '';
            switch (this.state) {
                case MDialogState.Confirmation:
                    state = 'confirmation';
                    break;
                case MDialogState.Information:
                    state = 'information';
                    break;
                case MDialogState.Warning:
                    state = 'warning';
                    break;
                case MDialogState.Error:
                    state = 'error';
                    break;
                default:
                    break;
            }
            return state;
        },
        enumerable: true,
        configurable: true
    });
    __decorate([
        Prop()
    ], MDialog.prototype, "title", void 0);
    __decorate([
        Prop()
    ], MDialog.prototype, "message", void 0);
    __decorate([
        Prop()
    ], MDialog.prototype, "okLabel", void 0);
    __decorate([
        Prop()
    ], MDialog.prototype, "okPrecision", void 0);
    __decorate([
        Prop({ default: false })
    ], MDialog.prototype, "secBtn", void 0);
    __decorate([
        Prop()
    ], MDialog.prototype, "secBtnLabel", void 0);
    __decorate([
        Prop()
    ], MDialog.prototype, "secBtnPrecision", void 0);
    __decorate([
        Prop({ default: '100%' })
    ], MDialog.prototype, "btnWidth", void 0);
    __decorate([
        Prop()
    ], MDialog.prototype, "cancelLabel", void 0);
    __decorate([
        Prop({ default: true })
    ], MDialog.prototype, "negativeLink", void 0);
    __decorate([
        Prop()
    ], MDialog.prototype, "hint", void 0);
    __decorate([
        Prop({
            default: MDialogWidth.Default,
            validator: function (value) {
                return value === MDialogWidth.Default ||
                    value === MDialogWidth.Large;
            }
        })
    ], MDialog.prototype, "width", void 0);
    __decorate([
        Prop({
            default: MDialogState.Default,
            validator: function (value) {
                return value === MDialogState.Default ||
                    value === MDialogState.Warning ||
                    value === MDialogState.Confirmation ||
                    value === MDialogState.Information ||
                    value === MDialogState.Error;
            }
        })
    ], MDialog.prototype, "state", void 0);
    __decorate([
        Emit('ok')
    ], MDialog.prototype, "onOk", null);
    __decorate([
        Emit('secondaryBtn')
    ], MDialog.prototype, "onSecondaryBtn", null);
    __decorate([
        Emit('cancel')
    ], MDialog.prototype, "onCancel", null);
    MDialog = __decorate([
        WithRender,
        Component({
            components: (_a = {},
                _a[BUTTON_NAME] = MButton,
                _a[LINK_NAME] = MLink,
                _a[MESSAGE_NAME] = MMessage,
                _a[ICON_NAME] = MIcon,
                _a[I18N_NAME] = MI18n,
                _a),
            mixins: [Portal]
        })
    ], MDialog);
    return MDialog;
}(ModulVue));
export { MDialog };
var DialogPlugin = {
    install: function (v, options) {
        v.use(DialogServicePlugin);
        v.component(DIALOG_NAME, MDialog);
    }
};
export default DialogPlugin;
//# sourceMappingURL=dialog.js.map