{
  "version": 3,
  "sources": ["/cdn/shop/t/186/assets/collapse-custom.js"],
  "sourcesContent": ["import { Component } from '@theme/component';\n\n/**\n * @typedef {Object} CollapseRefs\n * @property {HTMLElement} [button] - The optional button element to trigger collapse/expand\n * @property {HTMLElement} panel - The panel element to collapse/expand\n */\n\n/**\n * A custom element that manages collapse/expand functionality\n *\n * @extends {Component<CollapseRefs>}\n */\nclass CollapseCustom extends Component {\n  requiredRefs = ['panel'];\n\n  /**\n   * @type {boolean}\n   */\n  #expanded = false;\n\n  /**\n   * @type {number}\n   */\n  #collapsedHeight = 0;\n\n  /**\n   * @type {number}\n   */\n  #collapsedHeightThreshold = 0;\n\n  /**\n   * @type {number}\n   */\n  #fullHeight = 0;\n\n  /**\n   * @type {Animation | undefined}\n   */\n  #animation;\n\n\n  /**\n   * @constant {number}\n   */\n  #animationSpeed = 300;\n\n  /**\n   * @type {AbortController}\n   */\n  #controller = new AbortController();\n\n  /**\n   * @type {HTMLElement | null}\n   */\n  #buttonElement = null;\n\n  /**\n   * @type {string}\n   */\n  #initialButtonText = '';\n\n  /**\n   * @type {string}\n   */\n  #expandText = '';\n\n  /**\n   * @type {string}\n   */\n  #collapseText = '';\n\n  connectedCallback() {\n    super.connectedCallback();\n\n    const { signal } = this.#controller;\n\n    this.#expanded = this.hasAttribute('expanded');\n\n    const collapsedHeightAttr = this.getAttribute('collapsed-height');\n    if (collapsedHeightAttr) {\n      const collapsedHeight = parseInt(collapsedHeightAttr, 10);\n      if (!Number.isNaN(collapsedHeight)) {\n        this.#collapsedHeight = Math.max(collapsedHeight, 0);\n        this.#collapsedHeightThreshold = Math.max(collapsedHeight - 8, 0);\n      }\n    }\n    \n    if (this.#collapsedHeight === 0) {\n      this.#collapsedHeight = Math.max(this.refs.panel.offsetHeight || 0, 0);\n      this.#collapsedHeightThreshold = Math.max(this.#collapsedHeight - 8, 0);\n    }\n    \n    if (this.refs.button) {\n      this.refs.button.addEventListener('click', this.#handleButtonClick, { signal });\n      this.refs.button.setAttribute('aria-expanded', String(this.#expanded));\n      \n      this.#initializeButtonText();\n    }\n\n\n    if (!this.#expanded) {\n      const { panel } = this.refs;\n      panel.style.height = 'auto';\n      this.#fullHeight = panel.scrollHeight;\n      panel.style.height = `${this.#collapsedHeight}px`;\n      panel.style.overflow = 'hidden';\n    } else {\n      const { panel } = this.refs;\n      panel.style.height = 'auto';\n      this.#fullHeight = panel.scrollHeight;\n      panel.style.height = '';\n    }\n\n    if (this.refs.panel.classList.contains('collapsible__panel--fade')) {\n      const fadeHeight = this.refs.panel.getAttribute('data-fade-height');\n      const fadeSize = fadeHeight ? parseInt(fadeHeight, 10) : 60;\n      \n      if (!this.#expanded) {\n        this.refs.panel.style.setProperty('--fade-size', `${fadeSize}px`);\n      } else {\n        this.refs.panel.style.setProperty('--fade-size', '0px');\n      }\n    }\n\n    this.#updateButtonVisibility();\n  }\n\n  disconnectedCallback() {\n    super.disconnectedCallback();\n    this.#controller.abort();\n  }\n\n  /**\n   * Handles button click to toggle collapse/expand\n   * @param {Event} event\n   */\n  #handleButtonClick = (event) => {\n    event.preventDefault();\n    this.toggle();\n  };\n\n  /**\n   * Collapses the panel\n   */\n  collapse() {\n    if (!this.#expanded) return;\n\n    this.#dispatchEvent('onCollapse');\n\n    const { panel } = this.refs;\n    const startHeight = panel.offsetHeight;\n    const endHeight = this.#collapsedHeight;\n\n    this.#animation?.cancel();\n\n    this.#animation = panel.animate(\n      {\n        height: [`${startHeight}px`, `${endHeight}px`],\n      },\n      {\n        duration: this.#animationSpeed,\n        easing: 'ease-in-out',\n      }\n    );\n\n    if (this.refs.panel.classList.contains('collapsible__panel--fade')) {\n      const fadeHeight = this.refs.panel.getAttribute('data-fade-height');\n      const fadeSize = fadeHeight ? parseInt(fadeHeight, 10) : 60;\n      this.refs.panel.style.setProperty('--fade-size', `${fadeSize}px`);\n    }\n\n    this.#animation.onfinish = () => {\n      panel.style.height = `${this.#collapsedHeight}px`;\n      panel.style.overflow = 'hidden';\n      this.#expanded = false;\n      this.removeAttribute('expanded');\n      if (this.refs.button) {\n        this.refs.button.setAttribute('aria-expanded', 'false');\n      }\n      this.#updateButtonText();\n      this.#updateButtonVisibility();\n      this.#dispatchEvent('onCollapseEnd');\n    };\n  }\n\n  /**\n   * Expands the panel\n   */\n  expand() {\n    if (this.#expanded) return;\n\n    this.#dispatchEvent('onExpanding');\n\n    const { panel } = this.refs;\n    const startHeight = panel.offsetHeight;\n    \n    panel.style.height = 'auto';\n    const endHeight = panel.scrollHeight;\n    panel.style.height = `${startHeight}px`;\n    panel.style.overflow = 'hidden';\n\n    this.#animation?.cancel();\n\n    this.#animation = panel.animate(\n      {\n        height: [`${startHeight}px`, `${endHeight}px`],\n      },\n      {\n        duration: this.#animationSpeed,\n        easing: 'ease-in-out',\n      }\n    );\n\n    if (this.refs.panel.classList.contains('collapsible__panel--fade')) {\n      this.refs.panel.style.setProperty('--fade-size', '0px');\n    }\n\n    this.#animation.onfinish = () => {\n      panel.style.removeProperty('height');\n      panel.style.overflow = '';\n      this.#expanded = true;\n      this.setAttribute('expanded', '');\n      this.#fullHeight = panel.scrollHeight;\n      if (this.refs.button) {\n        this.refs.button.setAttribute('aria-expanded', 'true');\n      }\n      this.#updateButtonText();\n      this.#updateButtonVisibility();\n      this.#dispatchEvent('onExpandEnd');\n    };\n  }\n\n  /**\n   * Toggles between collapsed and expanded states\n   */\n  toggle() {\n    if (this.#expanded) {\n      this.collapse();\n    } else {\n      this.expand();\n    }\n  }\n\n  /**\n   * Initializes button text based on data attributes and initial state\n   */\n  #initializeButtonText() {\n    if (!this.refs.button) return;\n\n    const foundElement = this.refs.button.querySelector('a, button');\n    const buttonElement = (foundElement instanceof HTMLElement ? foundElement : this.refs.button);\n    this.#buttonElement = buttonElement;\n\n    this.#initialButtonText = buttonElement.textContent?.trim() || '';\n\n    const expandTextAttr = this.refs.button.getAttribute('data-expand-text');\n    const collapseTextAttr = this.refs.button.getAttribute('data-collapse-text');\n\n    if (this.#expanded) {\n      if (collapseTextAttr) {\n        this.#collapseText = collapseTextAttr;\n      } else {\n        this.#collapseText = this.#initialButtonText;\n        this.refs.button.setAttribute('data-collapse-text', this.#initialButtonText);\n      }\n      this.#expandText = expandTextAttr || '';\n    } else {\n      if (expandTextAttr) {\n        this.#expandText = expandTextAttr;\n      } else {\n        this.#expandText = this.#initialButtonText;\n        this.refs.button.setAttribute('data-expand-text', this.#initialButtonText);\n      }\n      this.#collapseText = collapseTextAttr || '';\n    }\n\n    this.#updateButtonText();\n  }\n\n  /**\n   * Updates button text based on current state\n   */\n  #updateButtonText() {\n    if (!this.#buttonElement) return;\n\n    const text = this.#expanded ? this.#collapseText : this.#expandText;\n    if (text) {\n      this.#buttonElement.textContent = text;\n    }\n  }\n\n  /**\n   * Updates button visibility based on panel height\n   */\n  #updateButtonVisibility() {\n    if (this.#collapsedHeightThreshold === 0) return;\n\n    const { panel } = this.refs;\n    let fullHeight = this.#fullHeight;\n    \n    if (fullHeight === 0) {\n      const tempHeight = panel.style.height;\n      panel.style.height = 'auto';\n      fullHeight = panel.scrollHeight;\n      panel.style.height = tempHeight;\n      this.#fullHeight = fullHeight;\n    }\n\n    const shouldHide = fullHeight < this.#collapsedHeightThreshold;\n\n    if (this.refs.button) {\n      if (shouldHide) {\n        this.refs.button.style.display = 'none';\n      } else {\n        this.refs.button.style.display = '';\n      }\n    }\n\n  }\n\n  /**\n   * Dispatches a custom event\n   * @param {string} eventName\n   */\n  #dispatchEvent(eventName) {\n    const event = new CustomEvent(eventName, {\n      bubbles: true,\n      detail: {\n        expanded: this.#expanded,\n        element: this,\n      },\n    });\n    this.dispatchEvent(event);\n  }\n}\n\nif (!customElements.get('collapse-custom')) {\n  customElements.define('collapse-custom', CollapseCustom);\n}\n\n"],
  "mappings": "AAAA,OAAS,cAAiB,mBAa1B,MAAM,uBAAuB,SAAU,CACrC,aAAe,CAAC,OAAO,EAKvB,UAAY,GAKZ,iBAAmB,EAKnB,0BAA4B,EAK5B,YAAc,EAKd,WAMA,gBAAkB,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