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, M as MapToComponentMethod, I as InjectVegaSlimmer } from './global-slimmer-registry-17c4efd4.js';
import { s as slotPlaceholder } from './placeholder-bf562081.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-46020a03.js';
import { s as sanitizeVegaComponent } from './component-7d906393.js';
import { f as formatAndValidResponsiveToken } from './design-token-53758173.js';
import { a as arrayToClassString } from './ui-64815a12.js';
import { D as DomNodeSubjectObserverFactory } from './dom-node-subject-observer-factory-3897e95b.js';
import { a as VegaClick, d as VegaExpand } from './vega-event-id-578c6c6d.js';
import { c as chevronUp } from './chevron-up-b1989751.js';
import { c as chevronDown } from './chevron-down-4a75d28e.js';
import { V as VegaInternalIconManager } from './internal-icon-manager-bd80b3bb.js';
import { O as Observer } from './observer-3959f9dd.js';
import { C as ChangeManager } from './change-manager-6a7eb88c.js';
import { A as ACCORDION_EXPAND_TOPIC } from './static-subject-title-52f93124.js';
import { Y as isAccordionObserverPayload } from './type-guard-ed1004cc.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-697ad0b7.js';
import { T as TranslationSlimmer } from './translation-slimmer-32353a1c.js';
import './breakpoints-d9faf11c.js';
import './responsive-format-facade-3ec5c161.js';
import './ui-93922c59.js';
import './breakpoints-332702ed.js';
import './number-4398f2e1.js';
import './pixel-f32c07ce.js';
import './array-7888f339.js';
import './feature-flag-controller-30f7b625.js';
import './index-bfc6dfa2.js';
import './typography-396de03f.js';
import './state-border-formatter-a243f3fc.js';
import './icon-manager-539d7cf7.js';
import './create-public-api-runtime-metrics-slimmer-aaadaa08.js';
import './dynamic-slimmer-90b8af32.js';
import './misc-9fdbcfbb.js';
import './internal-translation-controller-d8217d93.js';
import './internal-vega-event-manager-1ac5ee9a.js';
import './try-get-document-bef0f526.js';

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 VegaAccordionRenderer extends VegaSlimmer {
  render() {
    return (h("div", { class: {
        'accordion': true,
        'background': this.drawsBackground,
        'expanded': this.expand,
        'collapsed': !this.expand,
        'icon-position-center': this.iconPosition === 'center',
      } },
      this.renderHeader(),
      this.renderContent()));
  }
  renderHeader() {
    const titleDom = (h(Fragment, null,
      this.renderPrefixIcon(),
      this.accordionTitle ? this.renderTitle() : this.renderTitleSlot()));
    return (h("div", { class: "accordion-header" },
      h("vega-flex", { gap: "size-8", "align-items": "start" },
        this.expandIconAlign === 'left' && this.renderExpandIcon(),
        titleDom,
        this.expandIconAlign === 'right' && this.renderExpandIcon())));
  }
  renderPrefixIcon() {
    return (this.prefixIcon && (h("div", { class: "accordion-prefix-icon" },
      h("vega-icon", { icon: this.prefixIcon, size: "size-24" }))));
  }
  renderTitle() {
    return h("div", { class: "accordion-title" }, this.accordionTitle);
  }
  renderExpandIcon() {
    const classes = [
      'accordion-expand-icon',
      `accordion-expand-icon-align-${this.expandIconAlign}`,
      formatAndValidResponsiveToken(this.showExpandIcon, 'display'),
    ];
    return (h("div", { class: `${arrayToClassString(classes)}` },
      h("vega-button-circle", { size: "small", "icon-color": "text-link", variant: "icon-only", "data-aria-label": this.getExpandIconAriaLabel(), "data-aria-expanded": `${this.expand}`, icon: VegaInternalIconManager.getIconKey(this.expandIconAlign === 'left' ? 'chevron-down' : 'chevron-up'), ref: (ref) => {
          DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaClick, () => {
            this.expandController.flipExpand();
          });
        } })));
  }
  renderContent() {
    return (h("div", { class: "accordion-content" },
      h("slot", { name: "content" }),
      h("slot", { name: "accordion-content" })));
  }
  renderTitleSlot() {
    return (h("div", { class: "accordion-title-slot" },
      h("slot", { name: "title" }),
      h("slot", { name: "accordion-title" })));
  }
  getExpandIconAriaLabel() {
    if (this.accordionTitle) {
      return this.expand
        ? this.translationSlimmer.t('Collapse {0} accordion', this.accordionTitle)
        : this.translationSlimmer.t('Expand {0} accordion', this.accordionTitle);
    }
    return this.expand
      ? this.translationSlimmer.t('Collapse accordion')
      : this.translationSlimmer.t('Expand accordion');
  }
}
(() => {
  VegaInternalIconManager.register({
    'chevron-up': chevronUp,
    'chevron-down': chevronDown,
  });
})();
__decorate$2([
  MapToComponentField()
], VegaAccordionRenderer.prototype, "drawsBackground", void 0);
__decorate$2([
  MapToComponentField()
], VegaAccordionRenderer.prototype, "prefixIcon", void 0);
__decorate$2([
  MapToComponentField()
], VegaAccordionRenderer.prototype, "accordionTitle", void 0);
__decorate$2([
  MapToComponentField()
], VegaAccordionRenderer.prototype, "expandIconAlign", void 0);
__decorate$2([
  MapToComponentField()
], VegaAccordionRenderer.prototype, "expand", void 0);
__decorate$2([
  MapToComponentField()
], VegaAccordionRenderer.prototype, "iconPosition", void 0);
__decorate$2([
  MapToComponentField()
], VegaAccordionRenderer.prototype, "showExpandIcon", void 0);
__decorate$2([
  MapToComponentField()
], VegaAccordionRenderer.prototype, "expandController", void 0);
__decorate$2([
  MapToComponentField()
], VegaAccordionRenderer.prototype, "translationSlimmer", 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 VegaAccordionExpandController extends VegaSlimmer {
  flipExpand() {
    this.expand = !this.expand;
  }
  onExpand() {
    if (this.groupId && this.expand) {
      ChangeManager.notify(ACCORDION_EXPAND_TOPIC, {
        groupId: this.groupId,
        element: this.host,
      });
    }
    this.expandEventEmitter.emit(this.expand);
  }
  registerObserver() {
    this.observer = new Observer(isAccordionObserverPayload, this.shouldCollapseSelfIfOtherExpand.bind(this));
    ChangeManager.register(ACCORDION_EXPAND_TOPIC, this.observer);
  }
  unregisterObserver() {
    if (this.observer) {
      ChangeManager.unregister(ACCORDION_EXPAND_TOPIC, this.observer);
      this.observer = null;
    }
  }
  shouldCollapseSelfIfOtherExpand(payload) {
    if (this.groupId === payload.groupId && this.host !== payload.element) {
      this.expand = false;
    }
  }
}
__decorate$1([
  MapToComponentField()
], VegaAccordionExpandController.prototype, "host", void 0);
__decorate$1([
  MapToComponentField()
], VegaAccordionExpandController.prototype, "groupId", void 0);
__decorate$1([
  MapToComponentField({ writable: true })
], VegaAccordionExpandController.prototype, "expand", void 0);
__decorate$1([
  MapToComponentField()
], VegaAccordionExpandController.prototype, "expandEventEmitter", void 0);
__decorate$1([
  MapToComponentMethod('watchExpand')
], VegaAccordionExpandController.prototype, "onExpand", null);
__decorate$1([
  MapToComponentMethod('componentWillLoad')
], VegaAccordionExpandController.prototype, "registerObserver", null);
__decorate$1([
  MapToComponentMethod('disconnectedCallback')
], VegaAccordionExpandController.prototype, "unregisterObserver", null);

const vegaAccordionCss = ":host(.v-block),.v-block{display:block}:host(.v-inline-block),.v-inline-block{display:inline-block}:host(.v-hidden),.v-hidden{display:none}@media (min-width: 320px){:host(.S\\:v-block),.S\\:v-block{display:block}:host(.S\\:v-inline-block),.S\\:v-inline-block{display:inline-block}:host(.S\\:v-hidden),.S\\:v-hidden{display:none}}@media (min-width: 768px){:host(.M\\:v-block),.M\\:v-block{display:block}:host(.M\\:v-inline-block),.M\\:v-inline-block{display:inline-block}:host(.M\\:v-hidden),.M\\:v-hidden{display:none}}@media (min-width: 1024px){:host(.L\\:v-block),.L\\:v-block{display:block}:host(.L\\:v-inline-block),.L\\:v-inline-block{display:inline-block}:host(.L\\:v-hidden),.L\\:v-hidden{display:none}}@media (min-width: 1440px){:host(.XL\\:v-block),.XL\\:v-block{display:block}:host(.XL\\:v-inline-block),.XL\\:v-inline-block{display:inline-block}:host(.XL\\:v-hidden),.XL\\:v-hidden{display:none}}:host{display:block;text-align:left;line-height:normal}.accordion{display:block;border-radius:16px}.accordion-title,.accordion-title-slot{font-family:\"Inter\", sans-serif;font-size:20px;font-weight:700;line-height:28px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1));overflow:hidden;flex-basis:0;flex-grow:1;padding-top:2px;padding-bottom:2px}@media screen and (min-width: 768px) and (max-width: 1023px){.accordion-title,.accordion-title-slot{font-family:\"Inter\", sans-serif;font-size:20px;font-weight:700;line-height:28px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){.accordion-title,.accordion-title-slot{font-family:\"Inter\", sans-serif;font-size:20px;font-weight:700;line-height:28px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){.accordion-title,.accordion-title-slot{font-family:\"Inter\", sans-serif;font-size:20px;font-weight:700;line-height:28px;letter-spacing:0px}}.accordion-prefix-icon{width:24px;height:32px;color:rgba(var(--v-text-primary, 32, 54, 69, 1));box-sizing:border-box;padding-top:4px;padding-bottom:4px;min-width:-webkit-min-content;min-width:-moz-min-content;min-width:min-content;flex-shrink:0}.icon-position-center .accordion-prefix-icon{align-self:center}.accordion-content{transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}.accordion.background{padding:24px;background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1))}.accordion.expanded .accordion-content{margin-top:24px}.accordion.collapsed .accordion-content{max-height:0px;overflow:hidden;display:none}.accordion.collapsed .accordion-expand-icon-align-left{transform:rotate(-90deg)}.accordion.collapsed .accordion-expand-icon-align-right{transform:rotate(180deg)}.accordion-expand-icon{transition-property:transform;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;min-width:-webkit-min-content;min-width:-moz-min-content;min-width:min-content;flex-shrink:0}.icon-position-center .accordion-expand-icon{align-self:center}.hidden{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 VegaAccordion = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaExpand = createEvent(this, "vegaExpand", 7);
    this.accordionExpand = createEvent(this, "accordionExpand", 7);
    this.globalSlimmers = {};
    this.renderer = new VegaAccordionRenderer();
    this.expandController = new VegaAccordionExpandController();
    this.translationSlimmer = new TranslationSlimmer();
    this.expandEventEmitter = createEventEmitSlimmer(VegaAccordion, VegaExpand, 'accordionExpand');
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Determines whether the accordion block should be displayed
     *    with its default background color `bg-primary`
     *    and padding of `size-24`.
     *
     * @vegaVersion 1.3.0
     */
    this.drawsBackground = true;
    /**
     * Specifies the placement of the expand icon in the accordion.
     *
     * @vegaVersion 1.3.0
     */
    this.expandIconAlign = 'right';
    /* this property is modified by a slimmer */
    /**
     * Controls whether the accordion is expanded.
     *
     * @vegaVersion 1.0.4
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.expand = true;
    /**
     * Specifies the vertical placement of the prefix icon
     *    and expand icon within the accordion.
     *
     * @vegaVersion 1.8.1
     */
    this.iconPosition = 'top';
    /**
     * Specifies whether to display or hide the expand icon in the accordion.
     *
     * It can be provided as a ResponsiveType or boolean value.
     *
     * @vegaVersion 1.3.0
     */
    this.showExpandIcon = true;
  }
  watchExpand() {
  }
  render() {
    slotPlaceholder(h("slot", null));
    return sanitizeVegaComponent(h(Host, null, this.renderer.render()), this.host);
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "expand": ["watchExpand"]
  }; }
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaAccordion.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaAccordion.prototype, "renderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaAccordion.prototype, "expandController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaAccordion.prototype, "translationSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaAccordion.prototype, "expandEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaAccordion.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaAccordion.style = vegaAccordionCss;

export { VegaAccordion as vega_accordion };
