import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { c as cls } from './helpers.js';
import { d as defineCustomElement$3 } from './component6.js';
import { d as defineCustomElement$2 } from './component2.js';

const XTimeline = /*@__PURE__*/ proxyCustomElement(class XTimeline extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        /**
         * 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: 'ec86d9ef34a2a967fca524384364e2d9c8e39547', class: cls(`timeline-color-${this.color}`, { 'timeline-bullet-accent': this.accent }) }, this.time && h("div", { key: '6bee837029f2fc8e7ccc47bed5fdc25fc9135049', class: "timeline-item-time", innerHTML: this.parseTime(this.time) }), h("div", { key: '8e57bd60ad8d24a915f3fede9c12916df774015c', class: "timeline-item-bullet" }), h("div", { key: 'e26de1d67059227df9a4e5f0c234d302653a4b18', class: "timeline-item-body" }, this.hasCollapseSlot && h("x-collapse", { key: 'f979f606b09777220ed12e30873adf5b976e3703' }, h("div", { key: '3ce1519e23bd2b49c72fbcb5039d62246feb4211', class: "timeline-item-header", slot: "header" }, h("div", { key: 'b2aee9f204b80125e9ff0bfdcd76a02e5839ffbd', class: "timeline-item-text" }, h("slot", { key: 'f1f3a072da7aa047a5e77377fb7ccaf761bc1d9c' })), this.meta && h("div", { key: 'c8b78290b2dd58632ee68ceade9b6a5bdd56f3f1', class: "timeline-item-meta", innerHTML: this.meta })), h("div", { key: 'a25e3f4f46b30ae62e0093aae15978d97520ec06', class: "timeline-item-colapse" }, h("slot", { key: 'f7e0b5b7eb3ba2b69d8f727707625509720eb0d6', name: "collapse" }))), !this.hasCollapseSlot && h("div", { key: '2f06991b86fd0b993a6b9a47855682ac498d25c7', class: "timeline-item-header" }, h("div", { key: 'edeed6ee91a730692a14c2edf12b94c916ddb1d7', class: "timeline-item-text" }, h("slot", { key: 'ecfa26f32a4fab4c11814b4e99ed0ffcdbef7954' })), this.meta && h("div", { key: '62eb31421e25f8f5a31df3c68c435f05cc2e684a', class: "timeline-item-meta", innerHTML: this.meta }))));
    }
    get el() { return this; }
}, [4, "x-timeline-item", {
        "color": [1],
        "accent": [4],
        "time": [1],
        "meta": [1]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["x-timeline-item", "x-collapse", "x-icon"];
    components.forEach(tagName => { switch (tagName) {
        case "x-timeline-item":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, XTimeline);
            }
            break;
        case "x-collapse":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "x-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}

const XTimelineItem = XTimeline;
const defineCustomElement = defineCustomElement$1;

export { XTimelineItem, defineCustomElement };
