{
  "version": 3,
  "sources": ["/cdn/shop/t/64/assets/s-sticky-add-to-cart.js?r=2"],
  "sourcesContent": ["/**\n * <s-sticky-add-to-cart> \u2014 floating add-to-cart bar.\n *\n * Shows [data-satc-bar] once the page's [data-product-form] has scrolled above\n * the viewport, and hides it while the footer is on screen. Its buttons click\n * the form's own Add to cart (name=\"add\") / Buy now (name=\"return_to\") buttons,\n * so the selected variant and quantity apply. Price and variant text follow the\n * page's [data-product-price] and selected options after variant changes.\n */\nclass SStickyAddToCart extends HTMLElement {\n  #ac;\n  #bar;\n  #observer;\n  #mutations;\n  #formPassed = false;\n  #footerVisible = false;\n\n  connectedCallback() {\n    this.#bar = this.querySelector('[data-satc-bar]');\n    const form = document.querySelector('[data-product-form]');\n    if (!this.#bar || !form) return;\n\n    this.#ac = new AbortController();\n    const opts = { signal: this.#ac.signal };\n    this.querySelector('[data-satc-add]')?.addEventListener('click', () => this.#press('add'), opts);\n    this.querySelector('[data-satc-buy]')?.addEventListener('click', () => this.#press('return_to'), opts);\n\n    const footer = document.querySelector('footer, [data-footer]');\n    this.#observer = new IntersectionObserver((entries) => {\n      for (const entry of entries) {\n        if (entry.target === form) {\n          this.#formPassed = !entry.isIntersecting && entry.boundingClientRect.top < 0;\n        } else {\n          this.#footerVisible = entry.isIntersecting;\n        }\n      }\n      this.#toggle(this.#formPassed && !this.#footerVisible);\n    });\n    this.#observer.observe(form);\n    if (footer) this.#observer.observe(footer);\n\n    // The product-title / product-form partials are swapped on variant change.\n    const column = form.parentElement?.closest('div') ?? form.parentElement;\n    this.#mutations = new MutationObserver(() => this.#sync());\n    if (column) this.#mutations.observe(column, { childList: true, subtree: true });\n    this.#sync();\n  }\n\n  disconnectedCallback() {\n    this.#ac?.abort();\n    this.#observer?.disconnect();\n    this.#mutations?.disconnect();\n    document.documentElement.removeAttribute('data-sticky-atc');\n  }\n\n  #toggle(show) {\n    this.#bar.toggleAttribute('data-open', show);\n    this.#bar.inert = !show;\n    document.documentElement.toggleAttribute('data-sticky-atc', show);\n  }\n\n  #formButton(name) {\n    return document.querySelector(`[data-product-form] button[name=\"${name}\"]`);\n  }\n\n  #press(name) {\n    const button = this.#formButton(name);\n    if (button && !button.disabled && button.getAttribute('aria-disabled') !== 'true') {\n      button.click();\n      return;\n    }\n    const notifyForm = document.querySelector('[data-product-form] [data-back-in-stock]');\n    (notifyForm ?? document.querySelector('[data-product-form]'))?.scrollIntoView({ behavior: 'smooth', block: 'center' });\n    notifyForm?.querySelector('input[type=\"email\"]')?.focus({ preventScroll: true });\n  }\n\n  #sync() {\n    const price = document.querySelector('[data-product-price]');\n    const priceTarget = this.querySelector('[data-satc-price]');\n    if (price && priceTarget) {\n      // The price block's first span is the current (or sale) price; drop its screen-reader label.\n      const first = price.querySelector(':scope > div > span')?.cloneNode(true);\n      first?.querySelectorAll('.sr-only').forEach((label) => label.remove());\n      const current = first?.textContent.trim();\n      if (current) priceTarget.textContent = current;\n    }\n\n    const variantTarget = this.querySelector('[data-satc-variant]');\n    // Only the main product form's option choices; other forms on the page (e.g. Pairs well with)\n    // and hidden variant-ID selects would otherwise add raw ID numbers to the label.\n    const mainForm = document.querySelector('[data-product-form]');\n    const checked = mainForm\n      ? [...mainForm.querySelectorAll('input[type=\"radio\"]:checked, select')].filter((input) => input.name !== 'id')\n      : [];\n    if (variantTarget && checked.length) {\n      variantTarget.textContent = checked.map((input) => input.value).filter(Boolean).join(' / ');\n    }\n\n    const add = this.querySelector('[data-satc-add]');\n    const label = this.querySelector('[data-satc-label]');\n    const addButton = this.#formButton('add');\n    const available = Boolean(addButton);\n    // Sold out with a Notify me form: keep the bar's button live; pressing it scrolls to the form.\n    const notify = !available && Boolean(document.querySelector('[data-product-form] [data-back-in-stock] form input[type=\"email\"]'));\n    if (add && label) {\n      add.disabled = !available && !notify;\n      // In stock: the original \"Add to cart\" text. Only when the main button says Pre-order does the bar follow it.\n      const isPreorder = Boolean(label.dataset.preorder) && addButton?.textContent.trim() === label.dataset.preorder;\n      label.textContent = available ? (isPreorder ? label.dataset.preorder : label.dataset.add) : notify ? label.dataset.notify || label.dataset.soldOut : label.dataset.soldOut;\n    }\n    this.querySelector('[data-satc-buy]')?.toggleAttribute('hidden', !this.#formButton('return_to'));\n  }\n}\n\nif (!customElements.get('s-sticky-add-to-cart')) {\n  customElements.define('s-sticky-add-to-cart', SStickyAddToCart);\n}\n"],
  "mappings": "AASA,MAAM,yBAAyB,WAAY,CACzC,IACA,KACA,UACA,WACA,YAAc,GACd,eAAiB,GAEjB,mBAAoB,CAClB,KAAK,KAAO,KAAK,cAAc,iBAAiB,EAChD,MAAM,KAAO,SAAS,cAAc,qBAAqB,EACzD,GAAI,CAAC,KAAK,MAAQ,CAAC,KAAM,OAEzB,KAAK,IAAM,IAAI,gBACf,MAAM,KAAO,CAAE,OAAQ,KAAK,IAAI,MAAO,EACvC,KAAK,cAAc,iBAAiB,GAAG,iBAAiB,QAAS,IAAM,KAAK,OAAO,KAAK,EAAG,IAAI,EAC/F,KAAK,cAAc,iBAAiB,GAAG,iBAAiB,QAAS,IAAM,KAAK,OAAO,WAAW,EAAG,IAAI,EAErG,MAAM,OAAS,SAAS,cAAc,uBAAuB,EAC7D,KAAK,UAAY,IAAI,qBAAsB,SAAY,CACrD,UAAW,SAAS,QACd,MAAM,SAAW,KACnB,KAAK,YAAc,CAAC,MAAM,gBAAkB,MAAM,mBAAmB,IAAM,EAE3E,KAAK,eAAiB,MAAM,eAGhC,KAAK,QAAQ,KAAK,aAAe,CAAC,KAAK,cAAc,CACvD,CAAC,EACD,KAAK,UAAU,QAAQ,IAAI,EACvB,QAAQ,KAAK,UAAU,QAAQ,MAAM,EAGzC,MAAM,OAAS,KAAK,eAAe,QAAQ,KAAK,GAAK,KAAK,cAC1D,KAAK,WAAa,IAAI,iBAAiB,IAAM,KAAK,MAAM,CAAC,EACrD,QAAQ,KAAK,WAAW,QAAQ,OAAQ,CAAE,UAAW,GAAM,QAAS,EAAK,CAAC,EAC9E,KAAK,MAAM,CACb,CAEA,sB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