{
  "version": 3,
  "sources": ["/cdn/shop/t/4/assets/product-price.js?pp=2"],
  "sourcesContent": ["import { ThemeEvents } from '@theme/events';\nimport { Component } from '@theme/component';\nimport { StandardEvents, ProductSelectEvent } from '@shopify/events';\n\n/**\n * @typedef {Object} ProductPriceRefs\n * @property {HTMLElement} priceContainer\n * @property {HTMLElement} [volumePricingNote]\n */\n\n/**\n * A custom element that displays a product price.\n * This component listens for variant update events and updates the price display accordingly.\n * It handles price updates from two different sources:\n * 1. Variant picker (in quick add modal or product page)\n * 2. Swatches variant picker (in product cards)\n *\n * @extends {Component<ProductPriceRefs>}\n */\nclass ProductPrice extends Component {\n  connectedCallback() {\n    super.connectedCallback();\n    const closestSection = this.closest('.shopify-section, dialog');\n    if (!closestSection) return;\n    closestSection.addEventListener(StandardEvents.productSelect, this.#handleProductSelect);\n  }\n\n  disconnectedCallback() {\n    super.disconnectedCallback();\n    const closestSection = this.closest('.shopify-section, dialog');\n    if (!closestSection) return;\n    closestSection.removeEventListener(StandardEvents.productSelect, this.#handleProductSelect);\n  }\n\n  /**\n   * Handles product select event and updates the price.\n   * @param {ProductSelectEvent} event - The product select event.\n   */\n  #handleProductSelect = (event) => {\n    if (!(event.target instanceof Element) || event.target.closest('product-card')) return;\n\n    event.promise\n      .then(({ detail }) => {\n        if (!detail?.html) return;\n\n        const { html, newProduct } = detail;\n\n        if (newProduct) {\n          this.dataset.productId = newProduct.id;\n        } else if (detail.productId && detail.productId !== this.dataset.productId) {\n          return;\n        }\n\n        const { priceContainer, volumePricingNote } = this.refs;\n        // Find the new product-price element in the updated HTML\n        const newProductPrice = html.querySelector(`product-price[data-block-id=\"${this.dataset.blockId}\"]`);\n        if (!newProductPrice) return;\n\n        // Update price container\n        const newPrice = newProductPrice.querySelector('[ref=\"priceContainer\"]');\n        if (newPrice && priceContainer) {\n          priceContainer.replaceWith(newPrice);\n        }\n\n        document.dispatchEvent(new CustomEvent('fp:branding-price-sync'));\n\n        // Update volume pricing note\n        const newNote = newProductPrice.querySelector('[ref=\"volumePricingNote\"]');\n        if (!newNote) {\n          volumePricingNote?.remove();\n        } else if (!volumePricingNote) {\n          // Use newPrice since priceContainer was just replaced and now points to the detached element\n          newPrice?.insertAdjacentElement('afterend', /** @type {Element} */ (newNote.cloneNode(true)));\n        } else {\n          volumePricingNote.replaceWith(newNote);\n        }\n\n        // Update installments (SPI banner) variant ID to trigger payment terms re-render\n        const installmentsInput = /** @type {HTMLInputElement|null} */ (\n          this.querySelector(`#product-form-installment-${this.dataset.blockId} input[name=\"id\"]`)\n        );\n        if (installmentsInput) {\n          installmentsInput.value = detail.resource?.id ?? '';\n          installmentsInput.dispatchEvent(new Event('change', { bubbles: true }));\n        }\n      })\n      .catch((error) => {\n        if (error?.name !== 'AbortError') console.warn('[product-price] Event promise rejected:', error);\n      });\n  };\n}\n\nif (!customElements.get('product-price')) {\n  customElements.define('product-price', ProductPrice);\n}\n"],
  "mappings": "AAAA,MAA4B,gBAC5B,OAAS,cAAiB,mBAC1B,OAAS,mBAA0C,kBAiBnD,MAAM,qBAAqB,SAAU,CACnC,mBAAoB,CAClB,MAAM,kBAAkB,EACxB,MAAM,eAAiB,KAAK,QAAQ,0BAA0B,EACzD,gBACL,eAAe,iBAAiB,eAAe,cAAe,KAAK,oBAAoB,CACzF,CAEA,sBAAuB,CACrB,MAAM,qBAAqB,EAC3B,MAAM,eAAiB,KAAK,QAAQ,0BAA0B,EACzD,gBACL,eAAe,oBAAoB,eAAe,cAAe,KAAK,oBAAoB,CAC5F,CAMA,qBAAwB,OAAU,CAC5B,EAAE,MAAM,kBAAkB,UAAY,MAAM,OAAO,QAAQ,cAAc,GAE7E,MAAM,QACH,KAAK,CAAC,CAAE,MAAO,IAAM,CACpB,GAAI,CAAC,QAAQ,KAAM,OAEnB,KAAM,CAAE,KAAM,UAAW,EAAI,OAE7B,GAAI,WACF,KAAK,QAAQ,UAAY,WAAW,WAC3B,OAAO,WAAa,OAAO,YAAc,KAAK,QAAQ,UAC/D,OAGF,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