import { h } from "@stencil/core";
const ICON_MAP = {
    success: '✓',
    warning: '⚠',
    info: 'ℹ',
    error: '✕',
    loading: '⏳',
};
/**
 * Message 消息提示组件
 * 常用于主动操作后的反馈提示
 */
export class Message {
    el;
    /** 消息文字 */
    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"))));
    }
    static get is() { return "hb-message"; }
    static get encapsulation() { return "shadow"; }
    static get properties() {
        return {
            "message": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u6D88\u606F\u6587\u5B57"
                },
                "getter": false,
                "setter": false,
                "attribute": "message",
                "reflect": false,
                "defaultValue": "''"
            },
            "type": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "MessageType",
                    "resolved": "\"error\" | \"info\" | \"loading\" | \"success\" | \"warning\"",
                    "references": {
                        "MessageType": {
                            "location": "local",
                            "path": "/Users/vscoderwhy/Desktop/product/web-common/huibo-ui/src/components/Message/Message.tsx",
                            "id": "src/components/Message/Message.tsx::MessageType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u6D88\u606F\u7C7B\u578B"
                },
                "getter": false,
                "setter": false,
                "attribute": "type",
                "reflect": false,
                "defaultValue": "'info'"
            },
            "closable": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u662F\u5426\u663E\u793A\u5173\u95ED\u6309\u94AE"
                },
                "getter": false,
                "setter": false,
                "attribute": "closable",
                "reflect": false,
                "defaultValue": "false"
            },
            "duration": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u663E\u793A\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C0 \u4E3A\u4E0D\u81EA\u52A8\u5173\u95ED"
                },
                "getter": false,
                "setter": false,
                "attribute": "duration",
                "reflect": false,
                "defaultValue": "3000"
            }
        };
    }
    static get states() {
        return {
            "visible": {}
        };
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=Message.js.map
