{
  "version": 3,
  "sources": ["/cdn/shop/t/337/assets/pdp2026-variant-picker.js?cb=1792163867774"],
  "sourcesContent": ["/* 2026 PDP variant picker.\n\n   Keeps each option's label value in step with the chosen control -- the\n   design writes the selection into the label (\"MATERIAL - Tiger's Eye\",\n   \"SIZE - 7\", Figma 279:215 / 279:712). Liquid renders the initial value from\n   option.selected_value, but nothing updated it afterwards, so the label kept\n   showing the size the page loaded with.\n\n   Variant switching itself is handled by VariantRadios in global.js; this only\n   mirrors the state into the labels. */\n(function () {\n  /* A heading is \"NAME - value\", and the separator belongs to the value: a row\n     with nothing selected shows its name alone rather than a dangling dash. */\n  function setLabel(label, value) {\n    if (!label) return;\n    const target = label.querySelector('.pdp2026-option__label-value');\n    const separator = label.querySelector('.pdp2026-option__label-sep');\n    if (target) target.textContent = value || '';\n    if (separator) separator.hidden = !value;\n  }\n\n  function syncLabels(root) {\n    root.querySelectorAll('.pdp2026-option').forEach((group) => {\n      const name = group.dataset.optionName;\n      if (!name) return;\n      // Compare the name property rather than building an attribute selector:\n      // bundle options are named like \"Piece (Material)\" and would need\n      // escaping in a selector string.\n      const checked = Array.from(\n        root.querySelectorAll('input.pdp2026-option__input')\n      ).find((input) => input.name === name && input.checked);\n      if (!checked) return;\n      /* The label names the chosen value and nothing else. A sold-out size\n         used to read \"SIZE - 10 \u00B7 Sold Out\", which said the same thing three\n         times over: the chip is struck through and the line under the picker\n         already reads \"Size 10 is sold out\". */\n      const value = checked.value;\n\n      /* Limited-edition values sit in a second row under their own heading\n         (Figma 279:1238). The two rows share one selection, so exactly one of\n         them names it and the other shows its heading alone -- which is what\n         the live theme does. Liquid renders this for the initial variant; this\n         keeps it right when the shopper picks across the two rows. */\n      const limitedRow = group.querySelector('.pdp2026-swatches--limited');\n      const main = group.querySelector('.pdp2026-option__label:not(.pdp2026-swatches__row-label)');\n      if (limitedRow) {\n        const inLimited = limitedRow.contains(checked);\n        setLabel(limitedRow.querySelector('.pdp2026-option__label'), inLimited ? value : '');\n        setLabel(main, inLimited ? '' : value);\n        return;\n      }\n      setLabel(main, value);\n    });\n  }\n\n  /* Bundle pieces repeat the chosen material under the piece name\n     (Figma 279:2736). Each piece owns its own swatches, so read the checked\n     one inside that piece rather than from the options block as a whole. */\n  function syncPieceMeta(root) {\n    root.querySelectorAll('.pdp2026-piece').forEach((piece) => {\n      const target = piece.querySelector('[data-pdp2026-piece-meta]');\n      if (!target) return;\n      const checked = piece.querySelector(\n        '.pdp2026-swatches .pdp2026-option__input:checked'\n      );\n      if (checked) target.textContent = checked.value;\n    });\n    root.querySelectorAll('.pdp2026-piece').forEach(syncPieceImage);\n    root.querySelectorAll('.pdp2026-piece').forEach(syncPiecePreorder);\n  }\n\n  /* The entries beside a piece: {title, id, src?} for each of its variants. */\n  function pieceVariants(piece) {\n    const data = piece.querySelector('.pdp2026-piece__image-data');\n    if (!data) return [];\n    try {\n      const entries = JSON.parse(data.textContent);\n      return Array.isArray(entries) ? entries : [];\n    } catch (error) {\n      return [];\n    }\n  }\n\n  /* Every value chosen inside this piece -- its material and, where the piece\n     has them, its size. Both are needed: a variant title reads\n     \"18k Gold Plated / 6\", and matching on the material alone would settle on\n     whichever size came first. */\n  function pieceSelections(piece) {\n    return Array.from(\n      piece.querySelectorAll('.pdp2026-option__input:checked')\n    ).map((input) => input.value);\n  }\n\n  /* The variant whose options are exactly the ones chosen.\n\n     Matched on the title's parts, not on the title as a string. A variant\n     title is its option values joined with \" / \", and a size is a bare\n     number, so \"18k Gold Plated / 5\" contains \"8\" -- the one in \"18k\" -- and\n     a substring test put size 8 on the size 5 variant. Comparing whole parts\n     cannot collide that way. */\n  function pieceVariant(piece) {\n    const values = pieceSelections(piece);\n    const entries = pieceVariants(piece);\n    if (!values.length) return null;\n\n    return (\n      entries.find((entry) => {\n        const parts = String(entry.title)\n          .split(' / ')\n          .map((part) => part.trim());\n        return values.every((value) => parts.indexOf(String(value).trim()) !== -1);\n      }) || null\n    );\n  }\n\n  /* Re-ask Globo for this piece's ship date against the variant now chosen:\n     a pre-order date can differ between sizes, and one size of a piece can be\n     on pre-order while another is in stock. decorate() hides the row again\n     when the answer is no, so switching back to a stocked size clears it. */\n  function syncPiecePreorder(piece) {\n    const slot = piece.querySelector('[data-preorder-slot]');\n    if (!slot) return;\n\n    const variant = pieceVariant(piece);\n    if (variant && variant.id) {\n      slot.setAttribute('data-preorder-variant', variant.id);\n    }\n    if (window.EttikaPreorderCard) window.EttikaPreorderCard.decorate(piece);\n    syncSplitNote(piece.closest('.pdp2026-set'));\n  }\n\n  /* \"Pieces in this set may ship separately.\" -- true only once something in\n     the set actually is on pre-order, so it follows the rows rather than the\n     product type. */\n  function syncSplitNote(set) {\n    if (!set) return;\n    const note = set.parentElement\n      ? set.parentElement.querySelector('[data-pdp2026-split-note]')\n      : null;\n    if (!note) return;\n\n    const anyPreorder = !!set.querySelector('[data-preorder-slot]:not([hidden])');\n    note.toggleAttribute('hidden', !anyPreorder);\n  }\n\n  /* The rows are filled by ettika-preorder-card-status.js, which answers on\n     Globo's schedule and re-runs on its own observer -- not only when an\n     option changes. So watch the rows themselves rather than assuming every\n     change comes through this file, or the note goes stale the first time a\n     row appears without a click. */\n  function watchPreorderRows() {\n    document.querySelectorAll('.pdp2026-set').forEach((set) => {\n      const observer = new MutationObserver(() => syncSplitNote(set));\n      set.querySelectorAll('[data-preorder-slot]').forEach((slot) => {\n        observer.observe(slot, { attributes: true, attributeFilter: ['hidden'] });\n      });\n      syncSplitNote(set);\n    });\n  }\n\n  /* Swap a bundle piece's thumbnail to match its chosen material. The image\n     is rendered server-side for the initial selection; the per-variant sources\n     ride along in a JSON script beside it. */\n  function syncPieceImage(piece) {\n    const img = piece.querySelector('[data-pdp2026-piece-img]');\n    const data = piece.querySelector('.pdp2026-piece__image-data');\n    const checked = piece.querySelector('.pdp2026-swatches .pdp2026-option__input:checked');\n    if (!img || !data || !checked) return;\n\n    let entries;\n    try {\n      entries = JSON.parse(data.textContent);\n    } catch (error) {\n      return;\n    }\n    if (!Array.isArray(entries)) return;\n\n    // Variant titles read \"Clear Crystal with 18k Gold Plating\" or\n    // \"... / 6\" once a size is involved, so match on containment.\n    // Every variant is listed now, including ones with no image of their own,\n    // so skip those rather than matching one and then having nothing to show.\n    const hit = entries.find(\n      (entry) =>\n        entry.src &&\n        (entry.title === checked.value || entry.title.indexOf(checked.value) !== -1)\n    );\n    if (hit && hit.src && img.getAttribute('src') !== hit.src) {\n      img.setAttribute('src', hit.src);\n    }\n  }\n\n  function syncAll() {\n    document.querySelectorAll('.pdp2026-options').forEach((root) => {\n      syncLabels(root);\n      syncPieceMeta(root);\n    });\n  }\n\n  document.addEventListener('change', (event) => {\n    const input = event.target;\n    if (!input.matches || !input.matches('.pdp2026-option__input')) return;\n    const root = input.closest('.pdp2026-options');\n    if (!root) return;\n    syncLabels(root);\n    syncPieceMeta(root);\n  });\n\n  if (document.readyState === 'loading') {\n    document.addEventListener('DOMContentLoaded', () => {\n      syncAll();\n      watchPreorderRows();\n    });\n  } else {\n    syncAll();\n    watchPreorderRows();\n  }\n  // A variant change can re-render the options block from the section.\n  document.addEventListener('pdp2026:options-updated', syncAll);\n  window.pdp2026SyncOptionLabels = syncAll;\n})();\n\n/* Accordion (Figma 278:337). The open/close height is animated in CSS with\n   grid-template-rows, so this only moves the class and the aria state.\n   Delegated, so accordions re-rendered on a variant change keep working. */\n(function () {\n  document.addEventListener('click', (event) => {\n    const trigger = event.target.closest && event.target.closest('.pdp2026-accordion__trigger');\n    if (!trigger) return;\n\n    const item = trigger.closest('.pdp2026-accordion__item');\n    const panel = document.getElementById(trigger.getAttribute('aria-controls'));\n    if (!item || !panel) return;\n\n    const open = trigger.getAttribute('aria-expanded') === 'true';\n\n    /* One panel at a time: opening a second one while the first is still down\n       pushes the page around under whoever is reading. Only siblings in the\n       same accordion are closed, so two accordions on a page keep their own\n       state. */\n    if (!open) {\n      const group = item.parentElement;\n      if (group) {\n        group.querySelectorAll('.pdp2026-accordion__item.is-open').forEach((other) => {\n          if (other === item) return;\n          other.classList.remove('is-open');\n          const otherTrigger = other.querySelector('.pdp2026-accordion__trigger');\n          if (otherTrigger) otherTrigger.setAttribute('aria-expanded', 'false');\n        });\n      }\n    }\n\n    trigger.setAttribute('aria-expanded', open ? 'false' : 'true');\n    // Class only -- the hidden attribute would set display:none and the panel\n    // would snap instead of animating.\n    item.classList.toggle('is-open', !open);\n  });\n})();\n"],
  "mappings": "CAUC,UAAY,CAGX,SAAS,SAAS,MAAO,MAAO,CAC9B,GAAI,CAAC,MAAO,OACZ,MAAM,OAAS,MAAM,cAAc,8BAA8B,EAC3D,UAAY,MAAM,cAAc,4BAA4B,EAC9D,SAAQ,OAAO,YAAc,OAAS,IACtC,YAAW,UAAU,OAAS,CAAC,MACrC,CAEA,SAAS,WAAW,KAAM,CACxB,KAAK,iBAAiB,iBAAiB,EAAE,QAAS,OAAU,CAC1D,MAAM,KAAO,MAAM,QAAQ,WAC3B,GAAI,CAAC,KAAM,OAIX,MAAM,QAAU,MAAM,KACpB,KAAK,iBAAiB,6BAA6B,CACrD,EAAE,KAAM,OAAU,MAAM,OAAS,MAAQ,MAAM,OAAO,EACtD,GAAI,CAAC,QAAS,OAKd,MAAM,MAAQ,QAAQ,MAOhB,WAAa,MAAM,cAAc,4BAA4B,EAC7D,KAAO,MAAM,cAAc,0DAA0D,EAC3F,GAAI,WAAY,CACd,MAAM,UAAY,WAAW,SAAS,OAAO,EAC7C,SAAS,WAAW,cAAc,wBAAwB,EAAG,UAAY,MAAQ,EAAE,EACnF,SAAS,KAAM,UAAY,GAAK,KAAK,EACrC,MACF,CACA,SAAS,KAAM,KAAK,CACtB,CAAC,CACH,CAKA,SAAS,cAAc,KAAM,CAC3B,KAAK,iBAAiB,gBAAgB,EAAE,QAAS,OAAU,CACzD,MAAM,OAAS,MAAM,cAAc,2BAA2B,EAC9D,GAAI,CAAC,OAAQ,OACb,MAAM,QAAU,MAAM,cACpB,kDACF,EACI,UAAS,OAAO,YAAc,QAAQ,MAC5C,CAAC,EACD,KA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