import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-ClISz4NF.js';
import { v as validateAccessibleLabel } from './wcag-CD6_13JO.js';
import { c as canValidateWcagOnRender } from './gov.log-BtqD9K8d.js';
import { g as govHost } from './template-CoD1xawt.js';
import { t as tick } from './stencil.utils-Cjg0wpDG.js';
import './string.utils-vN03FcXN.js';
import './helpers.types-DNztiAH0.js';
import './utils-CQvUntGY.js';

const BreadcrumbsClass = {
    root: 'gov-breadcrumbs',
};

const GovBreadcrumbs = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.govChange = createEvent(this, "gov-change");
        this.inited = false;
        /**
         * Defines whether the components can be collapsible when element doesn't fit in one row.
         */
        this.collapsible = false;
        /**
         * Defines whether the breadcrumbs are open or closed by button
         */
        this.isExpanded = false;
        /**
         * Adds an accessible label to display the full breadcrumb navigation that only screen readers can see.
         */
        this.accessibleToggleLabel = 'Zobrazit či skrýt navigaci';
        this.expanded = false;
        this.toggleOption = false;
        this.h = govHost(this.host);
    }
    async componentDidRender() {
        this.scheduleContentVerification();
        if (canValidateWcagOnRender()) {
            tick(() => this.validateAccessibility());
        }
    }
    scheduleContentVerification() {
        if (this.inited)
            return;
        this.inited = true;
        tick(() => {
            this.calculateWidthOfItems();
            this.inited = false;
        });
    }
    calculateWidthOfItems() {
        const hostWidth = this.host.getBoundingClientRect().width;
        let sumOfWidths = 0;
        this.host.querySelectorAll('li').forEach((li) => {
            sumOfWidths += li.getBoundingClientRect().width;
        });
        this.toggleOption = sumOfWidths > hostWidth;
    }
    render() {
        return (h(Host, { key: '5a2d10c3705a0d19458ea76e65ab6e0449eb620d', class: this.h.classes(BreadcrumbsClass.root), expanded: this.expanded }, h("nav", { key: '41b98c6ee95ea397f9802f5ac120d2674859cb4d', "aria-label": this.accessibleLabel, "aria-labelledby": this.accessibleLabelledBy }, h("slot", { key: '10fed9d58caa49017c34665e4b711252854040b7' })), this.toggleOption ? (h("gov-button", { size: 'xs', color: 'primary', type: 'base', "aria-label": this.accessibleToggleLabel, "aria-pressed": this.expanded, "aria-expanded": this.expanded, "on-gov-click": () => this.expanded = !this.expanded }, h("gov-icon", { name: this.expanded ? 'chevron-up' : 'chevron-down', type: "components" }))) : null));
    }
    /**
     * Validate the WCAG attributes of the component
     */
    async validateAccessibility() {
        validateAccessibleLabel(this.accessibleLabel, this.accessibleLabelledBy, BreadcrumbsClass.root, this.host);
        validateAccessibleLabel(this.accessibleToggleLabel, undefined, BreadcrumbsClass.root, this.host);
    }
    get host() { return getElement(this); }
};

export { GovBreadcrumbs as gov_breadcrumbs };
//# sourceMappingURL=gov-breadcrumbs.entry.js.map

//# sourceMappingURL=gov-breadcrumbs.entry.js.map