{
  "version": 3,
  "sources": ["/cdn/shop/t/4/assets/variant-selects.js?mvary=mobile"],
  "sourcesContent": ["if (!customElements.get('variant-selects')) {\n  customElements.define(\n    'variant-selects',\n    class VariantSelects extends HTMLElement {\n      constructor() {\n        super();\n      }\n\n      get selectedOptionValues() {\n        return Array.from(this.querySelectorAll('select option[selected], fieldset input:checked')).map(\n          ({ dataset }) => dataset.optionValueId\n        );\n      }\n\n      getInputForEventTarget(target) {\n        return target.tagName === 'SELECT' ? target.selectedOptions[0] : target;\n      }\n\n      connectedCallback() {\n        if (this._hasChangeListener) {\n          return;\n        }\n\n        this._hasChangeListener = true;\n\n        this.addEventListener(\n          'change',\n          (event) => {\n            // Check if target is inside this element\n            const targetInThisElement = this.contains(event.target);\n\n            // Check if there's a nested variant-selects between this and target\n            let hasNestedVariantSelects = false;\n            let currentElement = event.target;\n\n            while (currentElement && currentElement !== document.body) {\n              if (currentElement.tagName === 'VARIANT-SELECTS') {\n                if (currentElement !== this) {\n                  hasNestedVariantSelects = true;\n                  break;\n                } else {\n                  break;\n                }\n              }\n              currentElement = currentElement.parentElement;\n            }\n\n            // Ignore if target is not in this element or there's a nested variant-selects\n            if (!targetInThisElement || hasNestedVariantSelects) {\n              return;\n            }\n\n            const target = this.getInputForEventTarget(event.target);\n            this.updateSelectedSwatchValue(event);\n            FoxTheme.pubsub.publish(FoxTheme.pubsub.PUB_SUB_EVENTS.optionValueSelectionChange, {\n              data: {\n                event,\n                target,\n                selectedOptionValues: this.selectedOptionValues,\n              },\n            });\n          },\n          true\n        ); // Use CAPTURE phase to catch events before they bubble\n      }\n\n      updateSelectedSwatchValue({ target }) {\n        const { value, tagName } = target;\n\n        if (tagName === 'SELECT' && target.selectedOptions.length) {\n          Array.from(target.options)\n            .find((option) => option.getAttribute('selected'))\n            .removeAttribute('selected');\n          target.selectedOptions[0].setAttribute('selected', 'selected');\n\n          const swatchValue = target.selectedOptions[0].dataset.optionSwatchValue;\n          const selectedDropdownSwatchValue = target\n            .closest('.product-form__input')\n            .querySelector('[data-selected-value] > .swatch');\n          if (!selectedDropdownSwatchValue) return;\n          if (swatchValue) {\n            selectedDropdownSwatchValue.style.setProperty('--swatch--background', swatchValue);\n            selectedDropdownSwatchValue.classList.remove('swatch--unavailable');\n          } else {\n            selectedDropdownSwatchValue.style.setProperty('--swatch--background', 'unset');\n            selectedDropdownSwatchValue.classList.add('swatch--unavailable');\n          }\n\n          selectedDropdownSwatchValue.style.setProperty(\n            '--swatch-focal-point',\n            target.selectedOptions[0].dataset.optionSwatchFocalPoint || 'unset'\n          );\n        } else if (tagName === 'INPUT' && target.type === 'radio') {\n          const selectedSwatchValue = target.closest(`.product-form__input`).querySelector('[data-selected-value]');\n          if (selectedSwatchValue) selectedSwatchValue.innerHTML = value;\n        }\n      }\n    }\n  );\n}\n"],
  "mappings": "AAAK,eAAe,IAAI,iBAAiB,GACvC,eAAe,OACb,kBACA,cAA6B,WAAY,CACvC,aAAc,CACZ,MAAM,CACR,CAEA,IAAI,sBAAuB,CACzB,OAAO,MAAM,KAAK,KAAK,iBAAiB,iDAAiD,CAAC,EAAE,IAC1F,CAAC,CAAE,OAAQ,IAAM,QAAQ,aAC3B,CACF,CAEA,uBAAuB,OAAQ,CAC7B,OAAO,OAAO,UAAY,SAAW,OAAO,gBAAgB,CAAC,EAAI,MACnE,CAEA,mBAAoB,CACd,KAAK,qBAIT,KAAK,mBAAqB,GAE1B,KAAK,iBACH,SACC,OAAU,CAET,MAAM,oBAAsB,KAAK,SAAS,MAAM,MAAM,EAGtD,IAAI,wBAA0B,GAC1B,eAAiB,MAAM,OAE3B,KAAO,gBAAkB,iBAAmB,SAAS,MAAM,CACzD,GAAI,eAAe,UAAY,kBAC7B,GAAI,iBAAmB,KAAM,CAC3B,wBAA0B,GAC1B,KACF,KACE,OAGJ,eAAiB,eAAe,aAClC,CAGA,GAAI,CAAC,qBAAuB,wBAC1B,OAGF,MAAM,OAAS,KAAK,uBAAuB,MAAM,MAAM,EACvD,KAAK,0BA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