{
  "version": 3,
  "sources": ["/cdn/shop/t/58/assets/special-order-ack.js?twrg_rev=20260814-1"],
  "sourcesContent": ["/**\n * Special order acknowledgment gate.\n *\n * Blocks Add to Cart on special order products until the customer ticks a box\n * confirming they understand the item is built or ordered to order, with no set\n * lead time, and agrees to the special order terms.\n *\n * Integration note, carried over from subscription-ack.js: the theme's\n * <product-form> binds its own 'submit' listener directly on the form, and\n * listeners on the event target itself fire in registration order regardless of\n * the capture flag. So we listen on `document` in the CAPTURE phase, which\n * always runs before any listener bound to the target, and stop propagation\n * from there. product-form.js is never modified.\n *\n * Fails open. Any parse or wiring error lets the cart through rather than\n * blocking a sale.\n */\n(function () {\n  'use strict';\n\n  var cfgEl = document.querySelector('[data-special-order-config]');\n  var tplEl = document.querySelector('[data-special-order-template]');\n  if (!cfgEl || !tplEl) return;\n\n  /* If a product is somehow both a subscription product and a special order\n     product, the subscription gate owns the page. Two stacked modals would be\n     worse than one, and the subscription disclosure is the one carrying a\n     recurring charge. No product is in both sets today; this is a guard, not a\n     workaround. */\n  if (document.querySelector('[data-subscription-ack-config]')) return;\n\n  var CFG;\n  try {\n    CFG = JSON.parse(cfgEl.textContent);\n  } catch (e) {\n    return; // Bad config should never block the cart.\n  }\n\n  /* Reveals the notice's \"Read the special order terms\" button. Set only once\n     we know the modal can actually open, so the button is never dead on click. */\n  document.documentElement.classList.add('so-ack-ready');\n\n  var passThrough = false; // true for the one resubmit we allow through\n\n  /* -------------------------------------------------------------- the modal */\n\n  var modal = null;\n  var lastFocus = null;\n  var pendingForm = null;\n  var readOnly = false;\n\n  function buildModal() {\n    if (modal) return modal;\n    var frag = tplEl.content.cloneNode(true);\n    modal = frag.querySelector('.so-ack');\n    document.body.appendChild(modal);\n\n    modal.querySelector('[data-so-heading]').textContent = CFG.heading;\n    modal.querySelector('[data-so-intro]').textContent = CFG.intro;\n    modal.querySelector('[data-so-checklabel]').textContent = CFG.checkLabel;\n    modal.querySelector('[data-so-confirm]').textContent = CFG.confirmLabel;\n\n    var list = modal.querySelector('[data-so-terms]');\n    (CFG.terms || []).forEach(function (t) {\n      var li = document.createElement('li');\n      li.textContent = t;\n      list.appendChild(li);\n    });\n\n    modal.querySelector('[data-so-fine]').innerHTML =\n      'Questions about lead time or availability before you order? Call our '\n      + CFG.phoneLabel + ' direct at <a class=\"so-ack__tel\" href=\"'\n      + CFG.phoneHref + '\">' + CFG.phone + '</a>.';\n\n    modal.querySelectorAll('[data-so-close]').forEach(function (b) {\n      b.addEventListener('click', close);\n    });\n    modal.querySelector('[data-so-scrim]').addEventListener('click', close);\n\n    var box = modal.querySelector('[data-so-checkbox]');\n    var go = modal.querySelector('[data-so-confirm]');\n    box.addEventListener('change', function () { go.disabled = !box.checked; });\n    go.addEventListener('click', confirmAdd);\n\n    return modal;\n  }\n\n  /** @param {HTMLFormElement|null} form  null opens the modal as a plain read of\n   *  the terms, with no add-to-cart pending behind it. */\n  function open(form) {\n    var m = buildModal();\n    pendingForm = form;\n    readOnly = !form;\n\n    var box = m.querySelector('[data-so-checkbox]');\n    var wrap = m.querySelector('[data-so-checkwrap]');\n    var go = m.querySelector('[data-so-confirm]');\n    var back = m.querySelector('.so-ack__btn--ghost');\n\n    box.checked = false;\n    go.disabled = true;\n    wrap.hidden = readOnly;\n    go.hidden = readOnly;\n    back.textContent = readOnly ? CFG.closeLabel : CFG.backLabel;\n\n    lastFocus = document.activeElement;\n    m.hidden = false;\n    // Force a frame so the transition runs.\n    requestAnimationFrame(function () { m.setAttribute('data-open', 'true'); });\n    document.documentElement.style.overflow = 'hidden';\n    setTimeout(function () { (readOnly ? back : box).focus(); }, 60);\n  }\n\n  function close() {\n    if (!modal) return;\n    modal.removeAttribute('data-open');\n    document.documentElement.style.overflow = '';\n    setTimeout(function () { if (modal) modal.hidden = true; }, 200);\n    if (lastFocus && lastFocus.focus) lastFocus.focus();\n    pendingForm = null;\n    readOnly = false;\n  }\n\n  document.addEventListener('keydown', function (e) {\n    if (e.key === 'Escape' && modal && modal.getAttribute('data-open') === 'true') close();\n  });\n\n  /* Delegated: the notice lives inside the product info block, which Canopy\n     re-renders on variant change. A directly bound listener would not survive. */\n  document.addEventListener('click', function (e) {\n    var trigger = e.target.closest ? e.target.closest('[data-so-open]') : null;\n    if (!trigger) return;\n    e.preventDefault();\n    open(null);\n  });\n\n  /* ----------------------------------------------- write the order record */\n\n  function setProp(form, name, value) {\n    var sel = 'input[name=\"properties[' + name + ']\"]';\n    var input = form.querySelector(sel);\n    if (!input) {\n      input = document.createElement('input');\n      input.type = 'hidden';\n      input.name = 'properties[' + name + ']';\n      form.appendChild(input);\n    }\n    input.value = value;\n  }\n\n  function selectedVariant(form) {\n    var idInput = form.querySelector('[name=\"id\"]');\n    if (!idInput) return null;\n    var id = Number(idInput.value);\n    return (CFG.variants || []).filter(function (v) { return v.id === id; })[0] || null;\n  }\n\n  function quantityOf(form) {\n    var q = form.querySelector('[name=\"quantity\"]');\n    var n = q ? parseInt(q.value, 10) : 1;\n    return isNaN(n) || n < 1 ? 1 : n;\n  }\n\n  function stampProperties(form) {\n    var v = selectedVariant(form);\n\n    // Visible on the cart line, the checkout, the confirmation email and the\n    // packing slip. This is the reinforcement half.\n    setProp(form, CFG.lineItemLabel, CFG.lineItemValue);\n\n    // Hidden audit trail. termsRev is what lets us prove which wording the\n    // customer actually agreed to if an order is ever disputed.\n    setProp(form, '_so_ack', 'true');\n    setProp(form, '_so_ack_at', new Date().toISOString());\n    setProp(form, '_so_ack_terms_rev', CFG.termsRev);\n    setProp(form, '_so_ack_qty', String(quantityOf(form)));\n    if (v) {\n      setProp(form, '_so_ack_variant', v.title || '');\n      setProp(form, '_so_ack_sku', v.sku || '');\n    }\n  }\n\n  function confirmAdd() {\n    var form = pendingForm;\n    if (!form) return close();\n\n    stampProperties(form);\n    close();\n\n    // Let the theme's own handler run this time.\n    passThrough = true;\n    if (typeof form.requestSubmit === 'function') {\n      form.requestSubmit();\n    } else {\n      form.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }));\n    }\n  }\n\n  /* ------------------------------------------------------------- the gate */\n\n  document.addEventListener('submit', function (evt) {\n    var form = evt.target;\n    if (!form || !form.classList || !form.classList.contains('js-product-form')) return;\n    if (!form.closest('product-form')) return;\n\n    if (passThrough) {\n      passThrough = false;\n      return; // our own resubmit, let it through\n    }\n\n    evt.preventDefault();\n    evt.stopPropagation();\n    evt.stopImmediatePropagation();\n    open(form);\n  }, true); // capture: runs before the form's own listeners\n})();\n"],
  "mappings": "CAiBC,UAAY,CACX,aAEA,IAAI,MAAQ,SAAS,cAAc,6BAA6B,EAC5D,MAAQ,SAAS,cAAc,+BAA+B,EAQlE,GAPI,CAAC,OAAS,CAAC,OAOX,SAAS,cAAc,gCAAgC,EAAG,OAE9D,IAAI,IACJ,GAAI,CACF,IAAM,KAAK,MAAM,MAAM,WAAW,CACpC,OAAS,EAAG,CACV,MACF,CAIA,SAAS,gBAAgB,UAAU,IAAI,cAAc,EAErD,IAAI,YAAc,GAId,MAAQ,KACR,UAAY,KACZ,YAAc,KACd,SAAW,GAEf,SAAS,YAAa,CACpB,GAAI,MAAO,OAAO,MAClB,IAAI,KAAO,MAAM,QAAQ,UAAU,EAAI,EACvC,MAAQ,KAAK,cAAc,SAAS,EACpC,SAAS,KAAK,YAAY,KAAK,EAE/B,MAAM,cAAc,mBAAmB,EAAE,YAAc,IAAI,QAC3D,MAAM,cAAc,iBAAiB,EAAE,YAAc,IAAI,MACzD,MAAM,cAAc,sBAAsB,EAAE,YAAc,IAAI,WAC9D,MAAM,cAAc,mBAAmB,EAAE,YAAc,IAAI,aAE3D,IAAI,KAAO,MAAM,cAAc,iBAAiB,GAC/C,IAAI,OAAS,CAAC,GAAG,QAAQ,SAAU,EAAG,CACrC,IAAI,GAAK,SAAS,cAAc,IAAI,EACpC,GAAG,YAAc,EACjB,KAAK,YAAY,EAAE,CACrB,CAAC,EAED,MAAM,cAAc,gBAAgB,EAAE,UACpC,wEACE,IAAI,WAAa,2CACjB,IAAI,UAAY,KAAO,IAAI,M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