import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Emit, Prop } from 'vue-property-decorator';
import { InputState } from '../../mixins/input-state/input-state';
import { ModulIconName } from '../../utils/modul-icons/modul-icons';
import { ModulVue } from '../../utils/vue/vue';
import { VALIDATION_MESSAGE_NAME } from '../component-names';
import MSvgPlugin, { MSvg } from '../svg/svg';
import AccordionTransitionPlugin, { MAccordionTransition } from '../transitions/accordion-transition/accordion-transition';
import WithRender from './validation-message.html?style=./validation-message.scss';
var MValidationMessage = /** @class */ (function (_super) {
    __extends(MValidationMessage, _super);
    function MValidationMessage() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.svgTitle = '';
        _this.iconName = '';
        _this.classMessage = '';
        return _this;
    }
    MValidationMessage.prototype.onClick = function (event) { };
    Object.defineProperty(MValidationMessage.prototype, "message", {
        get: function () {
            if (this.as().hasErrorMessage && this.as().hasError) {
                this.classMessage = 'error';
                this.svgTitle = this.$i18n.translate('m-validation-message:title-error-icon');
                this.iconName = ModulIconName.Error;
                return this.as().errorMessage;
            }
            if (this.as().hasValidMessage && this.as().isValid) {
                this.classMessage = 'valid';
                this.svgTitle = this.$i18n.translate('m-validation-message:title-valid-icon');
                this.iconName = ModulIconName.Confirmation;
                return this.as().validMessage;
            }
        },
        enumerable: false,
        configurable: true
    });
    MValidationMessage.prototype.created = function () {
        if (this.$svgSprite) {
            this.$svgSprite.addSvg(ModulIconName.Error, require('./../../assets/icons/svg/error.svg'));
            this.$svgSprite.addSvg(ModulIconName.Confirmation, require('./../../assets/icons/svg/confirmation.svg'));
        }
    };
    __decorate([
        Prop({ default: true })
    ], MValidationMessage.prototype, "transition", void 0);
    __decorate([
        Emit('click')
    ], MValidationMessage.prototype, "onClick", null);
    MValidationMessage = __decorate([
        WithRender,
        Component({
            components: {
                MSvg: MSvg,
                MAccordionTransition: MAccordionTransition
            },
            mixins: [InputState]
        })
    ], MValidationMessage);
    return MValidationMessage;
}(ModulVue));
export { MValidationMessage };
var ValidationMessagePlugin = {
    install: function (v, options) {
        v.use(MSvgPlugin);
        v.use(AccordionTransitionPlugin);
        v.component(VALIDATION_MESSAGE_NAME, MValidationMessage);
    }
};
export default ValidationMessagePlugin;
//# sourceMappingURL=validation-message.js.map