import { h, F as Fragment, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-090d31ca.js';
import { c as MapToComponentField, V as VegaSlimmer, I as InjectVegaSlimmer } from './global-slimmer-registry-17c4efd4.js';
import { g as getDeviceType, D as DeviceType } from './ui-64815a12.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-4b1afd04.js';
import { D as DomNodeSubjectObserverFactory } from './dom-node-subject-observer-factory-3897e95b.js';
import { a as VegaClick } from './vega-event-id-578c6c6d.js';
import { s as sanitizeVegaComponent } from './component-7d906393.js';
import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-0a406a71.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-697ad0b7.js';
import { C as ComponentGlobalStyleSlimmer } from './component-global-style-slimmer-ac703085.js';
import './change-manager-6a7eb88c.js';
import './observer-3959f9dd.js';
import './internal-vega-event-manager-1ac5ee9a.js';
import './vega-env-manager-8f8dc473.js';
import './feature-flag-controller-5ebc0cec.js';
import './index-9c9865c0.js';
import './dynamic-slimmer-90b8af32.js';
import './try-get-document-bef0f526.js';
import './vega-nonce-manager-497e5eb5.js';
import './index-3b327f29.js';

var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaBreadcrumbRenderer extends VegaSlimmer {
  /**
   * get the component container div element
   *
   * @returns {HTMLDivElement} the container element ref
   */
  getBreadcrumbContainerRef() {
    return this.vegaBreadcrumbContainerRef;
  }
  render() {
    return (h("div", { class: {
        'vega-breadcrumb': true,
        'compact-mode': this.isCompactMode,
        'last-item-clickable': this.lastItemClickable,
        'collapsed': this.isCollapsed(),
        'single': this.items.length === 1,
      }, ref: (node) => (this.vegaBreadcrumbContainerRef = node) }, this.renderItems()));
  }
  renderItems() {
    const htmlItems = this.items.map((item, index) => this.itemRenderer.render(item, {
      isCompactMode: this.isCompactMode,
      isLastItem: this.items.length === index + 1,
    }));
    if (this.isCollapsed()) {
      htmlItems.splice(1, 0, this.collapsedItemRenderer.render(this.items.slice(1, this.items.length - 1)));
    }
    return h(Fragment, null, htmlItems);
  }
  isCollapsed() {
    return (!this.isCompactMode &&
      this.maxItems !== 'none' &&
      this.maxItems >= 4 &&
      this.items.length > this.maxItems);
  }
  // True when device is mobile and compact mode is enabled.
  // Used to switch into the compact single-item mobile rendering mode.
  get isCompactMode() {
    return this.compactOnMobile && getDeviceType() === DeviceType.MOBILE;
  }
}
__decorate$3([
  MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "items", void 0);
__decorate$3([
  MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "compactOnMobile", void 0);
__decorate$3([
  MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "lastItemClickable", void 0);
__decorate$3([
  MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "maxItems", void 0);
__decorate$3([
  MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "itemRenderer", void 0);
__decorate$3([
  MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "collapsedItemRenderer", void 0);

var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaBreadcrumbCollapsedItemRenderer extends VegaSlimmer {
  render(items) {
    return (h("div", { class: "vega-breadcrumb-item" },
      h("vega-dropdown", { placement: ['bottom'], alignment: 'center', maxHeight: 200 },
        h("vega-text", null, "..."),
        h("vega-box", { slot: "items" }, items.map((item) => (h("vega-dropdown-item", { key: item.label, label: item.label }, this.itemRenderer.render(item, { isInDropdown: true })))))),
      h("vega-icon", { icon: "chevron-right-rounded", size: "size-12", color: "text-secondary" })));
  }
}
__decorate$2([
  MapToComponentField()
], VegaBreadcrumbCollapsedItemRenderer.prototype, "itemRenderer", void 0);

var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaBreadcrumbItemRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.onButtonLinkClick = (payload, item) => {
      const event = this.clickEventEmitter.emit(item);
      if (event && event.defaultPrevented) {
        payload.preventDefault();
      }
    };
  }
  render(item, options) {
    return (h("div", { class: "vega-breadcrumb-item", key: item.label }, this.renderContent(item, options)));
  }
  renderContent(item, options) {
    if (options.isCompactMode && (!options.isLastItem || this.lastItemClickable)) {
      return (h(Fragment, null,
        this.renderIcon('chevron-left-rounded', 'text-link'),
        this.renderLabel(item)));
    }
    else if (options.isLastItem) {
      return this.renderLabel(item, !this.lastItemClickable);
    }
    else if (options.isInDropdown) {
      return this.renderLink(item, false, true);
    }
    else {
      return (h(Fragment, null,
        this.renderLabel(item),
        this.renderIcon('chevron-right-rounded', 'text-secondary')));
    }
  }
  renderIcon(icon, color) {
    return h("vega-icon", { icon: icon, size: "size-12", color: color });
  }
  renderLabel(item, isPlainLabel) {
    return item.tooltip ? (h("vega-tooltip", { text: item.tooltip, placement: ['bottom'] }, this.renderLink(item, isPlainLabel))) : (this.renderLink(item, isPlainLabel));
  }
  renderLink(item, isPlainLabel, isInDropdown = false) {
    return isPlainLabel ? (h("span", { class: "vega-breadcrumb-last-label" }, item.label)) : (h("vega-button-link", { label: item.label, link: item.href, eventful: true, class: {
        'vega-breadcrumb-dropdown-link': isInDropdown,
      }, ref: (ref) => {
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaClick, (payload) => {
          this.onButtonLinkClick(payload, item);
        });
      } }));
  }
}
__decorate$1([
  MapToComponentField()
], VegaBreadcrumbItemRenderer.prototype, "lastItemClickable", void 0);
__decorate$1([
  MapToComponentField()
], VegaBreadcrumbItemRenderer.prototype, "clickEventEmitter", void 0);

const vegaBreadcrumbGlobalCss = ".vega-breadcrumb-dropdown-link::part(label-text){color:rgba(var(--v-text-primary, 32, 54, 69, 1));font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}";

const vegaBreadcrumbCss = ":host{display:block}:host .vega-breadcrumb{display:flex;gap:8px;flex-wrap:wrap}:host .vega-breadcrumb-hidden{display:none !important}:host .vega-breadcrumb-item{display:flex;gap:8px;align-items:center}:host .vega-breadcrumb-item vega-button-link::part(label-text){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-breadcrumb-item vega-button-link::part(label-text){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-breadcrumb-item vega-button-link::part(label-text){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-breadcrumb-item vega-button-link::part(label-text){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host .vega-breadcrumb-item vega-dropdown vega-text{cursor:pointer;font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px;color:rgba(var(--v-text-link, 19, 98, 226, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-breadcrumb-item vega-dropdown vega-text{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-breadcrumb-item vega-dropdown vega-text{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-breadcrumb-item vega-dropdown vega-text{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host .vega-breadcrumb-item vega-icon{flex-shrink:0}:host .vega-breadcrumb-item .vega-breadcrumb-last-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-breadcrumb-item .vega-breadcrumb-last-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-breadcrumb-item .vega-breadcrumb-last-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-breadcrumb-item .vega-breadcrumb-last-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host .vega-breadcrumb-item vega-button-link::part(label-container){text-decoration:none}:host .vega-breadcrumb.compact-mode>.vega-breadcrumb-item{display:none}:host .vega-breadcrumb.compact-mode .vega-breadcrumb-item:nth-last-child(2){display:flex}:host .vega-breadcrumb.compact-mode.last-item-clickable .vega-breadcrumb-item:nth-last-child(2){display:none}:host .vega-breadcrumb.compact-mode.last-item-clickable .vega-breadcrumb-item:last-child{display:flex}:host .vega-breadcrumb.compact-mode.single .vega-breadcrumb-item{display:flex;font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-breadcrumb.compact-mode.single .vega-breadcrumb-item{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-breadcrumb.compact-mode.single .vega-breadcrumb-item{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-breadcrumb.compact-mode.single .vega-breadcrumb-item{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host .vega-breadcrumb.collapsed .vega-breadcrumb-item:nth-child(n+3):not(:last-child){display:none}";

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1; i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const VegaBreadcrumb = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaClick = createEvent(this, "vegaClick", 7);
    this.click = createEvent(this, "click", 7);
    this.globalSlimmers = {};
    this.renderer = new VegaBreadcrumbRenderer();
    this.collapsedItemRenderer = new VegaBreadcrumbCollapsedItemRenderer();
    this.itemRenderer = new VegaBreadcrumbItemRenderer();
    this.eventsPrevent = new ChildNodesEventPreventSlimmer([VegaClick], () => this.renderer.getBreadcrumbContainerRef());
    this.clickEventEmitter = createEventEmitSlimmer(VegaBreadcrumb, VegaClick);
    this.componentGlobalStyleSlimmer = new ComponentGlobalStyleSlimmer(vegaBreadcrumbGlobalCss);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Determines the maximum number of visible items in the `vega-breadcrumb` component,
     *   primarily in desktop mode.
  
     * When the number of items exceeds this limit, the component automatically
     *   collapses the center items, rendering only the first and last items visible.
  
     * If you set this value to `none`, all items will remain expanded.
  
     * The minimum allowed value for this property is 4.
     *
     * @vegaVersion 1.41.0
     */
    this.maxItems = 4;
    /**
     * Represents the individual elements within the `vega-breadcrumb` component.
     *
     * @vegaVersion 1.41.0
     */
    this.items = [];
    /**
     * Compact mode toggle for mobile viewport.
     *
     * When `true` (default), the breadcrumb displays only the last clickable
     * item on mobile devices to save horizontal space.
     * When `false`, the full multi-item layout is shown on mobile, identical to
     * desktop behavior (still subject to collapsing based on `maxItems`).
     *
     * @vegaVersion 2.66.0
     */
    this.compactOnMobile = true;
    /**
     * Determines whether the last breadcrumb item is clickable.
     *
     * When `false` (default), the last item is rendered as plain text.
     * When `true`, the last item becomes a clickable link, styled
     * the same as the other breadcrumb items.
     *
     * @vegaVersion 2.81.0
     */
    this.lastItemClickable = false;
  }
  render() {
    return sanitizeVegaComponent(h(Host, null, this.renderer.render()), this.host);
  }
  get host() { return getElement(this); }
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaBreadcrumb.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "renderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "collapsedItemRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "itemRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "eventsPrevent", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "clickEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "componentGlobalStyleSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaBreadcrumb.style = vegaBreadcrumbCss;

export { VegaBreadcrumb as vega_breadcrumb };
