{
  "version": 3,
  "sources": ["/cdn/shop/t/95/assets/product-form.js?cb=20261119"],
  "sourcesContent": ["if (!customElements.get('product-form')) {\n  customElements.define(\n    'product-form',\n    class ProductForm extends HTMLElement {\n      constructor() {\n        super();\n\n        this.form = this.querySelector('form');\n        // The variant id input is rendered by the variants/add_to_cart blocks.\n        // Templates without them (e.g. the bundle builder) have no such input \u2014\n        // guard so the constructor doesn't throw and abort the panel bindings below.\n        const variantIdInput = this.form?.querySelector('[name=id]');\n        if (variantIdInput) variantIdInput.disabled = false;\n        this.form.addEventListener('submit', this.onSubmitHandler.bind(this));\n        this.cart = document.querySelector('cart-notification') || document.querySelector('cart-drawer');\n        this.submitButton = this.querySelector('[id^=\"ProductSubmitButton-\"]');\n\n        this.querySelectorAll('.product-panel').forEach((panel) => {\n            \n            panel.querySelector('[aria-controls]').addEventListener('click', (e) => {\n                panel.setAttribute('aria-expanded', panel.getAttribute('aria-expanded') === 'true' ? 'false' : 'true');\n            });\n        });\n\n        this.querySelector('#increase-quantity')?.addEventListener('click', (e) => {\n            const quantity = this.querySelector('#quantity');\n            quantity.value = parseInt(quantity.value) + 1;\n        });\n\n        this.querySelector('#decrease-quantity')?.addEventListener('click', (e) => {\n            const quantity = this.querySelector('#quantity');\n            if (parseInt(quantity.value) > 1)\n                quantity.value = parseInt(quantity.value) - 1;\n        });\n\n        \n        this.submitButton?.setAttribute('aria-haspopup', 'dialog');\n\n        this.hideErrors = this.dataset.hideErrors === 'true';\n      }\n\n      onSubmitHandler(evt) {\n        if (window.addToCartHandler) {\n            evt.preventDefault();\n\n            window.addToCartHandler(this.form);\n            return;\n        }\n        \n        return;\n        if (this.submitButton.getAttribute('aria-disabled') === 'true') return;\n\n        this.handleErrorMessage();\n\n        this.submitButton.setAttribute('aria-disabled', true);\n        this.submitButton.classList.add('loading');\n        this.querySelector('.loading-overlay__spinner').classList.remove('hidden');\n\n        const config = fetchConfig('javascript');\n        config.headers['X-Requested-With'] = 'XMLHttpRequest';\n        delete config.headers['Content-Type'];\n\n        const formData = new FormData(this.form);\n\n        config.body = formData;\n\n        fetch(`${routes.cart_add_url}`, config)\n          .then((response) => response.json())\n          .then((response) => {\n            if (response.status) {\n              publish(PUB_SUB_EVENTS.cartError, {\n                source: 'product-form',\n                productVariantId: formData.get('id'),\n                errors: response.errors || response.description,\n                message: response.message,\n              });\n              this.handleErrorMessage(response.description);\n\n              const soldOutMessage = this.submitButton.querySelector('.sold-out-message');\n              if (!soldOutMessage) return;\n              this.submitButton.setAttribute('aria-disabled', true);\n              this.submitButton.querySelector('span').classList.add('hidden');\n              soldOutMessage.classList.remove('hidden');\n              this.error = true;\n              return;\n            } else if (!this.cart) {\n              window.location = window.routes.cart_url;\n              return;\n            }\n\n            if (!this.error)\n              publish(PUB_SUB_EVENTS.cartUpdate, { source: 'product-form', productVariantId: formData.get('id'), cartData: response });\n            this.error = false;\n            const quickAddModal = this.closest('quick-add-modal');\n            if (quickAddModal) {\n              document.body.addEventListener(\n                'modalClosed',\n                () => {\n                  setTimeout(() => {\n                    this.cart.renderContents(response);\n                  });\n                },\n                { once: true }\n              );\n              quickAddModal.hide(true);\n            } else {\n              this.cart.renderContents(response);\n            }\n          })\n          .catch((e) => {\n            console.error(e);\n          })\n          .finally(() => {\n            this.submitButton.classList.remove('loading');\n            if (this.cart && this.cart.classList.contains('is-empty')) this.cart.classList.remove('is-empty');\n            if (!this.error) this.submitButton.removeAttribute('aria-disabled');\n            this.querySelector('.loading-overlay__spinner').classList.add('hidden');\n          });\n      }\n\n      handleErrorMessage(errorMessage = false) {\n        if (this.hideErrors) return;\n\n        this.errorMessageWrapper =\n          this.errorMessageWrapper || this.querySelector('.product-form__error-message-wrapper');\n        if (!this.errorMessageWrapper) return;\n        this.errorMessage = this.errorMessage || this.errorMessageWrapper.querySelector('.product-form__error-message');\n\n        this.errorMessageWrapper.toggleAttribute('hidden', !errorMessage);\n\n        if (errorMessage) {\n          this.errorMessage.textContent = errorMessage;\n        }\n      }\n    }\n  );\n}\n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