{
  "version": 3,
  "sources": ["/cdn/shop/t/69/assets/tnf-swatch-prices.js?cb=20260522b"],
  "sourcesContent": ["/* TNF swatch prices v4 \u2014 universal PDP swatch price renderer + stronger sold-out styling.\n   RULES:\n     (1) If variant.available === false \u2192 SKIP price (no price shown) + apply stronger grey styling\n     (2) If variant has compare_at_price > price (on sale) \u2192 RED price + grey strikethrough\n     (3) Else if variant.price differs from product.price (main) \u2192 BLUE price\n     (4) Else (variant matches main, no sale) \u2192 render nothing\n   Suppresses theme's native .block-swatch__price for uniform rendering.\n   Adds CSS to strengthen sold-out swatch visual cue (theme's default 0.45 opacity \u2192 0.3 + full grayscale + muted background).\n   ADDITIVE DOM ONLY:\n     - Inserts <span class=\"tnf-swatch-price\"> next to .block-swatch__item-text\n     - Sets display:none on theme native .block-swatch__price\n     - Injects a <style> with .block-swatch--soldout overrides + .tnf-sw-soldout helper class\n     - DOES NOT touch radio inputs, click handlers, variant selectors, sticky ATC, QB modal, cart, ATC button, form\n   Scoped to template == 'product' via conditional script tag in layout/theme.liquid. */\n(function () {\n  if (window.__tnfSwatchPricesInited) return;\n  window.__tnfSwatchPricesInited = true;\n\n  var variantsByTitle = {};\n  var mainPriceCents = null;\n  var dataReady = false;\n\n  function fmtMoney(cents) { return '$' + (cents / 100).toFixed(2); }\n\n  function getHandle() {\n    var m = (location.pathname || '').match(/\\/products\\/([^\\/?#]+)/);\n    return m ? m[1] : '';\n  }\n\n  function injectStyles() {\n    if (document.getElementById('tnf-swatch-prices-style')) return;\n    var s = document.createElement('style');\n    s.id = 'tnf-swatch-prices-style';\n    s.textContent = [\n      // Stronger sold-out visual cue \u2014 replaces theme defaults (0.45 opacity, 0.6 grayscale)\n      '.block-swatch--soldout .block-swatch__image { opacity: 0.3 !important; filter: grayscale(1) !important; }',\n      '.block-swatch--soldout .block-swatch__item { background: #f5f6f7 !important; border-color: #d4d8dc !important; }',\n      '.block-swatch--soldout .block-swatch__item-text { opacity: 0.55 !important; color: #95a0aa !important; }',\n      // Also apply via attribute fallback in case theme didn't add --soldout class\n      '.tnf-sw-soldout .block-swatch__image { opacity: 0.3 !important; filter: grayscale(1) !important; }',\n      '.tnf-sw-soldout .block-swatch__item { background: #f5f6f7 !important; border-color: #d4d8dc !important; }',\n      '.tnf-sw-soldout .block-swatch__item-text { opacity: 0.55 !important; color: #95a0aa !important; text-decoration: line-through; }',\n      // In-stock swatches: brighten the visual (less grey vs sold-out contrast)\n      '.block-swatch:not(.block-swatch--soldout):not(.tnf-sw-soldout) .block-swatch__item { border-color: #e5e9ed !important; background: #ffffff !important; }',\n      // Title alignment: fixed min-height so prices align horizontally across swatches with varying title lengths\n      '.block-swatch__item-text { min-height: 30px; display: flex !important; flex-direction: column; align-items: center; justify-content: center; }'\n    ].join('\\n');\n    document.head.appendChild(s);\n  }\n\n  function fetchData() {\n    var handle = getHandle();\n    if (!handle) return;\n    fetch('/products/' + handle + '.js', { credentials: 'same-origin' })\n      .then(function (r) { return r.ok ? r.json() : null; })\n      .then(function (p) {\n        if (!p || !p.variants || p.variants.length < 2) return;\n        mainPriceCents = typeof p.price === 'number' ? p.price : parseInt(p.price, 10);\n        var allPrices = [];\n        var inStockPrices = [];\n        p.variants.forEach(function (v) {\n          var pr = typeof v.price === 'number' ? v.price : parseInt(v.price, 10);\n          allPrices.push(pr);\n          if (v.available) inStockPrices.push(pr);\n          variantsByTitle[v.title] = {\n            price: pr,\n            compareAt: v.compare_at_price ? (typeof v.compare_at_price === 'number' ? v.compare_at_price : parseInt(v.compare_at_price, 10)) : null,\n            available: !!v.available\n          };\n        });\n        // If every variant has the same price (no variance), skip all price rendering \u2014 uniform-pricing products (Built-style).\n        // Otherwise (any variance), render every IN-STOCK variant: max-priced one = BLUE (most expensive / reference), cheaper ones = RED (deal).\n        // Variance check uses IN-STOCK variants only \u2014 customer can only buy in-stock options.\n        // If all in-stock variants share the same price (PEScience case), no swatch prices needed; main price block + Promi shows the truth.\n        var uniqInStockPrices = {};\n        inStockPrices.forEach(function (x) { uniqInStockPrices[x] = 1; });\n        window.__tnfSwatchHasVariance = Object.keys(uniqInStockPrices).length > 1;\n        window.__tnfSwatchMaxInStock = inStockPrices.length ? Math.max.apply(null, inStockPrices) : null;\n        dataReady = true;\n        injectAll();\n      })\n      .catch(function () {});\n  }\n\n  function injectAll() {\n    if (!dataReady) return;\n    var items = document.querySelectorAll('.block-swatch__item');\n    for (var i = 0; i < items.length; i++) {\n      var item = items[i];\n\n      // Always suppress theme's native price rendering\n      var native = item.querySelector('.block-swatch__price');\n      if (native && native.style.display !== 'none') native.style.display = 'none';\n\n      var labelEl = item.querySelector('.block-swatch__item-text');\n      if (!labelEl) continue;\n      var title = (labelEl.textContent || '').trim();\n      var v = variantsByTitle[title];\n\n      // Apply sold-out class to parent .block-swatch wrapper if variant is unavailable\n      // (catches cases where theme didn't add --soldout \u2014 e.g. inferred from input ID -oos suffix)\n      if (v && !v.available) {\n        var wrapper = item.closest('.block-swatch');\n        if (wrapper && !wrapper.classList.contains('block-swatch--soldout') && !wrapper.classList.contains('tnf-sw-soldout')) {\n          wrapper.classList.add('tnf-sw-soldout');\n        }\n      }\n\n      if (item.dataset.tnfSwPriced === '1') continue;\n      if (!v || isNaN(v.price)) continue;\n\n      // NEW RULE: skip price entirely for sold-out variants\n      if (!v.available) {\n        item.dataset.tnfSwPriced = '1';\n        continue;\n      }\n\n      // If product has zero price variance (all variants same), don't render any prices (Built-style \u2014 clean look).\n      if (!window.__tnfSwatchHasVariance) {\n        item.dataset.tnfSwPriced = '1';\n        continue;\n      }\n\n      var isSale = v.compareAt && v.compareAt > v.price;\n      // Title-pattern detection: treat clearance/last-chance/final-sale variants as sale (RED) even without compare_at_price set in Shopify.\n      var clearancePattern = /LAST\\s*CHANCE|CLEARANCE|FINAL\\s*SALE/i;\n      var isClearance = !isSale && clearancePattern.test(title);\n      if (isClearance) isSale = true;\n\n      // \"Cheaper than the highest in-stock variant\" = RED (deal). Equal to max = BLUE (reference price).\n      var maxRef = window.__tnfSwatchMaxInStock;\n      var isCheaperThanMax = maxRef !== null && v.price < maxRef;\n      var isRed = isSale || isCheaperThanMax;\n\n      var color = isRed ? '#e32c2b' : '#1e2d7d';\n      var priceSpan = document.createElement('span');\n      priceSpan.className = 'tnf-swatch-price';\n      priceSpan.style.cssText = 'display:block;font-size:11.5px;font-weight:700;color:' + color + ';margin-top:3px;line-height:1.2;letter-spacing:0.2px;';\n      priceSpan.textContent = fmtMoney(v.price);\n\n      // Only append compare-at strikethrough when there's a real value > price.\n      // Title-pattern clearance detection sets isSale=true even without a compare_at_price \u2014 those render JUST the red price (no $0.00 strikethrough).\n      if (isSale && v.compareAt && v.compareAt > v.price) {\n        var cmp = document.createElement('span');\n        cmp.style.cssText = 'color:#95a0aa;font-weight:600;text-decoration:line-through;margin-left:5px;font-size:10.5px;';\n        cmp.textContent = fmtMoney(v.compareAt);\n        priceSpan.appendChild(cmp);\n      }\n\n      labelEl.parentNode.insertBefore(priceSpan, labelEl.nextSibling);\n      item.dataset.tnfSwPriced = '1';\n    }\n  }\n\n  function init() {\n    injectStyles();\n    fetchData();\n    var obs = new MutationObserver(function () { if (dataReady) injectAll(); });\n    obs.observe(document.body, { childList: true, subtree: true });\n    setTimeout(function () { obs.disconnect(); }, 30000);\n  }\n\n  if (document.readyState !== 'loading') init();\n  else document.addEventListener('DOMContentLoaded', init);\n})();\n"],
  "mappings": "CAcC,UAAY,CACX,GAAI,OAAO,wBAAyB,OACpC,OAAO,wBAA0B,GAEjC,IAAI,gBAAkB,CAAC,EACnB,eAAiB,KACjB,UAAY,GAEhB,SAAS,SAAS,MAAO,CAAE,MAAO,KAAO,MAAQ,KAAK,QAAQ,CAAC,CAAG,CAElE,SAAS,WAAY,CACnB,IAAI,GAAK,SAAS,UAAY,IAAI,MAAM,wBAAwB,EAChE,OAAO,EAAI,EAAE,CAAC,EAAI,EACpB,CAEA,SAAS,cAAe,CACtB,GAAI,UAAS,eAAe,yBAAyB,EACrD,KAAI,EAAI,SAAS,cAAc,OAAO,EACtC,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