'use strict';

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

const core = require('./core-906e2cc9.js');

const Notifier = class {
    constructor(hostRef) {
        core.registerInstance(this, hostRef);
    }
    onTrigger(event) {
        if (event.detail.name == "close") {
            event.stopPropagation();
            this.notice = undefined;
        }
    }
    onUpdatedNotice(newValue) {
        if (this.timer) {
            window.clearTimeout(this.timer);
            this.timer = undefined;
        }
        if (newValue != undefined) {
            this.timer = window.setTimeout(() => {
                this.notice = undefined;
                this.timer = undefined;
            }, 5000);
        }
    }
    onNotice(event) {
        this.notice = event.detail;
    }
    render() {
        const notice = !this.notice ? undefined : typeof (this.notice) == "string" ? JSON.parse(this.notice) : this.notice;
        const color = notice && notice.type != "default" ? notice.type : "primary";
        return notice == undefined ? core.h("slot", null) :
            [
                core.h("slot", null),
                core.h("aside", { class: notice.type }, core.h("p", null, notice.message, core.h("smoothly-trigger", { color: color, fill: "clear", name: "close" }, core.h("smoothly-icon", { name: "close-circle", color: color })))),
            ];
    }
    static get watchers() { return {
        "notice": ["onUpdatedNotice"]
    }; }
    static get style() { return ".sc-smoothly-notifier-h{display:block}[hidden].sc-smoothly-notifier-h{display:none}smoothly-trigger.sc-smoothly-notifier{display:inline-block;vertical-align:middle;margin-left:1.5em}aside.sc-smoothly-notifier{text-align:center;vertical-align:middle;width:100%;height:2.8em}aside.warning.sc-smoothly-notifier{background-color:rgb(var(--smoothly-warning-tint));color:rgb(var(--smoothly-warning-contrast))}aside.success.sc-smoothly-notifier{background-color:rgb(var(--smoothly-success-tint));color:rgb(var(--smoothly-success-contrast))}aside.danger.sc-smoothly-notifier{background-color:rgb(var(--smoothly-danger-tint));color:rgb(var(--smoothly-danger-contrast))}aside.default.sc-smoothly-notifier{background-color:rgb(var(--smoothly-primary-tint));color:rgb(var(--smoothly-primary-contrast))}"; }
};

exports.smoothly_notifier = Notifier;
