import { Host, h } from "@stencil/core";
import { cls } from "../../utils/helpers";
export class XTimeline {
    constructor() {
        /**
         * Element has not empty collapse slot
         */
        this.hasCollapseSlot = false;
        this.color = undefined;
        this.accent = undefined;
        this.time = undefined;
        this.meta = undefined;
    }
    /**
     * On component will be loaded hook
     */
    componentWillLoad() {
        this.hasCollapseSlot = !!this.el.querySelector('[slot="collapse"]');
    }
    parseTime(datetime) {
        const match = datetime.match(/(\d+:)/g);
        const minutes = parseInt(match[1]) || 0;
        const hours = parseInt(match[0]) || 0;
        const hour = hours === 0 ? 12 : hours;
        const clock = hours >= 12 ? 'PM' : 'AM';
        const formattedHours = hours > 12 ? hours - 12 : hour;
        return `${formattedHours}:${minutes.toString().padStart(2, '0')} <small>${clock}</small>`;
    }
    /**
     * Render element
     */
    render() {
        return h(Host, { key: '3e83b0dc0abd3c57de8518acc1f5ea94e716ff5c', class: cls(`timeline-color-${this.color}`, { 'timeline-bullet-accent': this.accent }) }, this.time && h("div", { key: '57f15db151a85a0c2dc14f1be5d298bd731a5a09', class: "timeline-item-time", innerHTML: this.parseTime(this.time) }), h("div", { key: '421dfe549aaf9559064c33a3ca11c0f1d583d0c7', class: "timeline-item-bullet" }), h("div", { key: 'b6dc73725a2ca5dd234913fb8969857d27107ce6', class: "timeline-item-body" }, this.hasCollapseSlot && h("x-collapse", { key: '22c930c236c4f5d1d602f35a3ffa7dba8d18518e' }, h("div", { key: '864b48d38bf3611a7c94d319104fe5570162bb8d', class: "timeline-item-header", slot: "header" }, h("div", { key: 'f8940c7fb8243b39a111403842ef3c848a424471', class: "timeline-item-text" }, h("slot", { key: '3893adcbaed6a8644fadf956d23e75590690a598' })), this.meta && h("div", { key: '89fa1adc7cf690b050132670f72a2b3e45670c07', class: "timeline-item-meta", innerHTML: this.meta })), h("div", { key: 'c52a0e9ee96eb9c6f3c51e5f020dfa609e2e441f', class: "timeline-item-colapse" }, h("slot", { key: 'c38f5aba42930c50f5ed563c3093f02c8d6a535c', name: "collapse" }))), !this.hasCollapseSlot && h("div", { key: '0e16653efa4dea214000ab1eef93f60943afccb7', class: "timeline-item-header" }, h("div", { key: '99e792a525e2818fa5fbd7172f2d5bcfb1433998', class: "timeline-item-text" }, h("slot", { key: 'd8fd1f6e9ac38fe505d67b1e8c06e404357d3dba' })), this.meta && h("div", { key: '5eecdd9328deffafccaa6c3661eda786905726a2', class: "timeline-item-meta", innerHTML: this.meta }))));
    }
    static get is() { return "x-timeline-item"; }
    static get properties() {
        return {
            "color": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "ColorType",
                    "resolved": "\"accent\" | \"blue\" | \"cyan\" | \"danger\" | \"default\" | \"green\" | \"indigo\" | \"info\" | \"orange\" | \"pink\" | \"primary\" | \"purple\" | \"red\" | \"success\" | \"teal\" | \"warning\" | \"yellow\"",
                    "references": {
                        "ColorType": {
                            "location": "import",
                            "path": "../../constants/colors",
                            "id": "src/constants/colors.ts::ColorType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Element color name"
                },
                "attribute": "color",
                "reflect": false
            },
            "accent": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Element accent checkpoint"
                },
                "attribute": "accent",
                "reflect": false
            },
            "time": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "time",
                "reflect": false
            },
            "meta": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "meta",
                "reflect": false
            }
        };
    }
    static get elementRef() { return "el"; }
}
