{
  "version": 3,
  "sources": ["/cdn/shop/t/20/assets/cf-sticky-atc.js?cfv=60"],
  "sourcesContent": ["/**\n * <cf-sticky-atc> \u2014 mobile add-to-cart bar that appears once the real buy\n * button has scrolled away.\n *\n * It deliberately owns no cart logic. The bar's button forwards its click to the\n * theme's own add-to-cart button, so variant selection, quantity, sold-out\n * states, cart drawer opening and error handling all keep working exactly as\n * they do without it. Duplicating any of that is how sticky bars end up adding\n * the wrong variant.\n *\n * Price and availability are mirrored from the live product form, so a variant\n * change is reflected in the bar without this element knowing what a variant is.\n */\nclass CfStickyAtc extends HTMLElement {\n  connectedCallback() {\n    this.bar = this.querySelector('[data-cf-sticky-bar]');\n    this.proxyButton = this.querySelector('[data-cf-sticky-submit]');\n    this.priceTarget = this.querySelector('[data-cf-sticky-price]');\n    this.badgeTarget = this.querySelector('[data-cf-sticky-badge]');\n    if (!this.bar || !this.proxyButton) return;\n\n    // The section is the reliable scope: multiple product sections can coexist\n    // in the theme editor, and this keeps the bar bound to its own form.\n    this.scope = this.closest('.shopify-section, [id^=\"shopify-section\"]') || document;\n\n    this.proxyButton.addEventListener('click', this.forwardClick);\n\n    this.observeAnchor();\n    this.mirrorPrice();\n  }\n\n  disconnectedCallback() {\n    this.proxyButton?.removeEventListener('click', this.forwardClick);\n    this.intersectionObserver?.disconnect();\n    this.priceObserver?.disconnect();\n  }\n\n  get realButton() {\n    return this.scope.querySelector(\n      'add-to-cart-component button[type=\"submit\"], .product-form__buttons button[type=\"submit\"], button[name=\"add\"]'\n    );\n  }\n\n  forwardClick = (event) => {\n    event.preventDefault();\n    const button = this.realButton;\n    if (!button) return;\n\n    if (button.disabled) {\n      // Nothing to add: send focus to the picker so the shopper can fix it\n      this.scope.querySelector('variant-picker')?.scrollIntoView({ behavior: 'smooth', block: 'center' });\n      return;\n    }\n\n    button.click();\n  };\n\n  /**\n   * Show the bar only while the real button is off screen. An IntersectionObserver\n   * on the button itself is cheaper and more accurate than measuring scroll\n   * offsets, and it survives layout changes such as an expanding accordion.\n   */\n  observeAnchor() {\n    const anchor = this.realButton;\n    if (!anchor) return;\n\n    this.intersectionObserver = new IntersectionObserver(\n      ([entry]) => {\n        const visible = !entry.isIntersecting;\n        this.bar.toggleAttribute('data-visible', visible);\n        // Reserve room so a fixed bar never sits permanently on top of the\n        // last of the page content, typically the footer.\n        document.documentElement.style.setProperty(\n          '--cf-satc-space',\n          visible ? `${this.bar.offsetHeight}px` : '0px'\n        );\n      },\n      { rootMargin: '0px 0px -8px 0px' }\n    );\n\n    this.intersectionObserver.observe(anchor);\n  }\n\n  /**\n   * Keep the bar's price, Club label and disabled state in step with the live\n   * form.\n   *\n   * The observer is bound to the <product-price> element rather than to the\n   * price node itself, because a variant change replaces the inner\n   * [ref=\"priceContainer\"] wholesale and an observer on the replaced node would\n   * be watching a detached tree.\n   *\n   * With Club pricing on, the block contains a label, two figures and a caption.\n   * Mirroring its whole textContent would put all four in a bar that has room\n   * for one, so the payable figure is read from its own marked node and the\n   * label from its own.\n   */\n  mirrorPrice() {\n    const root = this.scope.querySelector('product-price, .product-price, .price');\n    if (!root || !this.priceTarget) return;\n\n    const clean = (node) => (node?.textContent || '').replace(/\\s+/g, ' ').trim();\n\n    const sync = () => {\n      const now = root.querySelector('[data-cf-price-now]');\n      this.priceTarget.textContent = clean(now) || clean(root);\n\n      if (this.badgeTarget) {\n        const badge = root.querySelector('[data-cf-club-badge]');\n        const label =\n          badge?.querySelector('.cf-club-badge__status') ||\n          badge?.querySelector('.cf-club-badge__label') ||\n          badge;\n        this.badgeTarget.textContent = clean(label);\n        this.badgeTarget.hidden = !badge;\n      }\n\n      const button = this.realButton;\n      if (button) this.proxyButton.toggleAttribute('data-unavailable', button.disabled);\n    };\n\n    sync();\n    this.priceObserver = new MutationObserver(sync);\n    this.priceObserver.observe(root, { childList: true, subtree: true, characterData: true });\n  }\n}\n\nif (!customElements.get('cf-sticky-atc')) {\n  customElements.define('cf-sticky-atc', CfStickyAtc);\n}\n"],
  "mappings": "AAaA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