import { p as proxyCustomElement, H, h } from './p-1407a5e8.js';

const ICON_MAP = {
    success: '✓',
    warning: '⚠',
    info: 'ℹ',
    error: '✕',
    loading: '⏳',
};
const Message = /*@__PURE__*/ proxyCustomElement(class Message extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
    }
    get el() { return this; }
    /** 消息文字 */
    message = '';
    /** 消息类型 */
    type = 'info';
    /** 是否显示关闭按钮 */
    closable = false;
    /** 显示时间（毫秒），0 为不自动关闭 */
    duration = 3000;
    visible = true;
    componentDidLoad() {
        if (this.duration > 0) {
            setTimeout(() => this.close(), this.duration);
        }
    }
    close = () => {
        this.visible = false;
        setTimeout(() => this.el.remove(), 300);
    };
    render() {
        return (h("div", { key: '51069b8f2a5079fcfd64bb24168907bbcfbfd869', class: {
                'hb-message': true,
                [`hb-message--${this.type}`]: true,
                'hb-message--visible': this.visible,
            }, role: "alert" }, h("span", { key: 'ad3123ae0c4eb9b8010c446bf0016d54af7b8a3a', class: "hb-message__icon" }, ICON_MAP[this.type]), h("span", { key: '557ea0f92544ab58079a498b8f90dc774746c0a2', class: "hb-message__text" }, this.message), this.closable && (h("span", { key: 'e90e3380ba2b9a473d5f839983b959584948fd2a', class: "hb-message__close", onClick: this.close }, "\u00D7"))));
    }
}, [1, "hb-message", {
        "message": [1],
        "type": [1],
        "closable": [4],
        "duration": [2],
        "visible": [32]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["hb-message"];
    components.forEach(tagName => { switch (tagName) {
        case "hb-message":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, Message);
            }
            break;
    } });
}
defineCustomElement$1();

const HbMessage = Message;
const defineCustomElement = defineCustomElement$1;

export { HbMessage, defineCustomElement };

//# sourceMappingURL=hb-message.js.map