{"version":3,"file":"actionbar-v2.mjs","sources":["../../../../src/actionbar/v2/actionbar.ts"],"sourcesContent":["import { html, unsafeCSS, CSSResult, nothing, type TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { appendStylesheet } from '../../core/utils';\nimport styles from './actionbar.scss?inline';\nimport slotStyles from './actionbar.slot.scss?inline';\nimport { BaseOrganism } from '../../base-organism/base-organism';\n\n@customElement('pips-v2-actionbar')\nexport class ActionbarV2 extends BaseOrganism {\n  static override styles: CSSResult[] = [...BaseOrganism.styles, unsafeCSS(styles)];\n\n  /** @internal - Do not set externally, managed by slot detection */\n  @property({ type: Boolean, reflect: true, attribute: 'has-cta' }) hasCtaContent = false;\n\n  /** @internal - Do not set externally, managed by slot detection */\n  @property({ type: Boolean, reflect: true, attribute: 'single-cta' }) hasSingleCta = false;\n\n  /** @internal - Do not set externally, managed by slot detection */\n  @property({ type: Boolean, reflect: true, attribute: 'has-phone' }) hasPhoneContent = false;\n\n  override connectedCallback(): void {\n    super.connectedCallback();\n    appendStylesheet({\n      target: this,\n      styles: slotStyles,\n      name: `${this.tagName.toLowerCase()}-slot`\n    });\n  }\n\n  private onCtaSlotChange(e: Event) {\n    const count = (e.target as HTMLSlotElement).assignedElements({ flatten: true }).length;\n    this.hasCtaContent = count > 0;\n    this.hasSingleCta = count === 1;\n  }\n\n  private onPhoneSectionSlotChange(e: Event) {\n    const slot = e.target as HTMLSlotElement;\n    const otherSlotName = slot.name === 'phone' ? 'phone-hours' : 'phone';\n    const otherSlot = this.shadowRoot?.querySelector(`slot[name=\"${otherSlotName}\"]`) as HTMLSlotElement;\n\n    this.hasPhoneContent =\n      slot.assignedElements({ flatten: true }).length > 0 ||\n      (otherSlot?.assignedElements({ flatten: true }).length ?? 0) > 0;\n  }\n\n  private renderPhoneSection() {\n    return html`\n      <div class=\"phone-container\" role=\"group\" aria-label=\"Contact information\" ?hidden=${!this.hasPhoneContent}>\n        <slot name=\"phone\" @slotchange=${this.onPhoneSectionSlotChange}></slot>\n        <slot name=\"phone-hours\" @slotchange=${this.onPhoneSectionSlotChange}></slot>\n      </div>\n    `;\n  }\n\n  private renderSeparator() {\n    return this.hasPhoneContent && this.hasCtaContent\n      ? html`<div class=\"separator\" role=\"presentation\" aria-hidden=\"true\"></div>`\n      : nothing;\n  }\n\n  protected override renderFinePrintSlot(): TemplateResult | typeof nothing {\n    return nothing;\n  }\n\n  protected override renderContent(): TemplateResult | typeof nothing {\n    return html`\n      <div class=\"module-region\" role=\"region\" aria-label=\"Action bar\">\n        <div class=\"content-container\">\n          <slot name=\"heading\"></slot>\n          <slot name=\"body\"></slot>\n        </div>\n        <div class=\"phone-action-container\">\n          ${this.renderPhoneSection()}\n          ${this.renderSeparator()}\n          <div class=\"action-container\">\n            <slot name=\"call-to-action\" @slotchange=${this.onCtaSlotChange}></slot>\n          </div>\n        </div>\n      </div>\n      <slot name=\"fine-print\"></slot>\n    `;\n  }\n}\n"],"names":["ActionbarV2","BaseOrganism","constructor","super","arguments","this","hasCtaContent","hasSingleCta","hasPhoneContent","connectedCallback","appendStylesheet","target","styles","name","tagName","toLowerCase","e","count","assignedElements","flatten","length","slot","otherSlotName","otherSlot","shadowRoot","querySelector","renderPhoneSection","html","onPhoneSectionSlotChange","renderSeparator","nothing","renderContent","onCtaSlotChange","unsafeCSS","__decorateClass","property","type","Boolean","reflect","attribute","prototype","customElement"],"mappings":"41CAQO,IAAMA,EAAN,cAA0BC,CAAAA,CAA1B,aAAAC,CAAAC,MAAAA,GAAAC,SAAAA,EAI6DC,KAAAC,iBAGGD,KAAAE,gBAGDF,KAAAG,kBAAkB,CAE7E,mBAAAC,CACPN,MAAMM,kBAAAA,EACNC,EAAiB,CACfC,OAAQN,KACRO,mpDACAC,KAAM,GAAGR,KAAKS,QAAQC,YAAAA,CAAAA,OAAAA,CAAAA,CAE1B,CAEQ,gBAAgBC,EAAAA,CACtB,MAAMC,EAASD,EAAEL,OAA2BO,iBAAiB,CAAEC,UAAS,CAAA,EAA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