{
  "version": 3,
  "sources": ["/cdn/shop/t/175/assets/tee-reset-customization.js?caf_v=20261004-autofill-card-1"],
  "sourcesContent": ["/* TeeInBlue auto-fill suggestion \u2014 v3 inline card (2026-10-04).\n   Was: a full-screen modal (#tee_reset_customization, z-index 99999) opened on\n   `teeinblue-event-component-injected`, which stacked on top of the Klaviyo popup after a reload.\n   Now: snippets/tee-reset-customization.liquid ships a <template>; this script clones it into the theme\n   shell `.caf-pdp-custom-panel` (after the progress header, before the app form) when\n   window.teeinblue.hasCustomization(productId) is true. Never touches TeeInBlue DOM \u2014 the app fills or\n   clears its own form through its public API (refillCustomization / resetCustomization).\n   States: shown \u2192 busy (spinner on the clicked button) \u2192 done (\"Filled in \u2014 check the details below\",\n   ~2.6s) \u2192 collapsed and removed. \"Start fresh\" and \u00D7 collapse straight away; typing into a text field hides\n   the suggestion (the shopper took over). Shown once per page view, and only for a customization saved on an\n   earlier visit (TeeInBlue saves as soon as the shopper starts, so a mid-visit save never triggers it). */\n(() => {\n  if (window.__cafAutofillInit) return;\n  window.__cafAutofillInit = true;\n\n  const doc = document;\n  const TEMPLATE_ID = 'caf-autofill-template';\n  const PANEL_SELECTOR = '.caf-pdp-custom-panel';\n  const DONE_VISIBLE_MS = 2600;\n  const COLLAPSE_MS = 320;\n  const SPINNER = '<span class=\"caf-autofill__spin\" aria-hidden=\"true\"></span>';\n\n  let state = 'idle'; // idle \u2192 shown \u2192 busy \u2192 done \u2192 closed\n  let card = null;\n  let watchStop = 0;\n  // TeeInBlue saves the customization as soon as the shopper picks/types something, so hasCustomization()\n  // turns true mid-visit. The card is only for a customization saved on an EARLIER visit: once the shopper\n  // has touched the form in this page view, never offer it.\n  let touchedForm = false;\n\n  const getProductId = () => window.TeeInBlueCampaign && window.TeeInBlueCampaign.productId;\n\n  const hasSavedCustomization = () => {\n    try {\n      const id = getProductId();\n      return Boolean(id && window.teeinblue && typeof window.teeinblue.hasCustomization === 'function' && window.teeinblue.hasCustomization(id));\n    } catch (error) {\n      return false;\n    }\n  };\n\n  const getPanel = () => {\n    const panel = doc.querySelector(PANEL_SELECTOR);\n    return panel && panel.querySelector('#teeFormInputs') ? panel : null;\n  };\n\n  const say = (message) => {\n    const live = card && card.querySelector('[data-caf-autofill-live]');\n    if (!live) return;\n    live.textContent = '';\n    window.setTimeout(() => {\n      live.textContent = message;\n    }, 60);\n  };\n\n  const focusAfterCard = () => {\n    const title = doc.querySelector(`${PANEL_SELECTOR} .caf-pdp-progress__title`);\n    if (title && typeof title.focus === 'function') title.focus({ preventScroll: true });\n  };\n\n  const collapse = (message) => {\n    if (!card || state === 'closed') return;\n    const node = card;\n    const hadFocus = node.contains(doc.activeElement);\n    state = 'closed';\n    if (message) say(message);\n    node.classList.add('is-collapsing');\n    window.setTimeout(() => {\n      node.remove();\n      if (hadFocus) focusAfterCard();\n    }, COLLAPSE_MS);\n  };\n\n  const setBusy = (button) => {\n    state = 'busy';\n    card.querySelectorAll('[data-caf-autofill]').forEach((control) => {\n      control.disabled = true;\n    });\n    card.setAttribute('aria-busy', 'true');\n    const label = button.querySelector('.caf-autofill__label');\n    if (label) label.insertAdjacentHTML('beforebegin', SPINNER);\n  };\n\n  const showDone = () => {\n    if (!card || state === 'closed') return;\n    state = 'done';\n    const hadFocus = card.contains(doc.activeElement);\n    card.removeAttribute('aria-busy');\n    card.classList.add('is-done');\n    say('Filled in with your last details. Please check them below.');\n    if (hadFocus) {\n      const done = card.querySelector('.caf-autofill__done');\n      if (done) done.focus({ preventScroll: true });\n    }\n    window.setTimeout(() => collapse(), DONE_VISIBLE_MS);\n  };\n\n  const runAction = (action) => {\n    const api = window.teeinblue;\n    const id = getProductId();\n    try {\n      if (action === 'refill' && api && typeof api.refillCustomization === 'function') {\n        api.refillCustomization(id);\n      } else if (action === 'reset' && api && typeof api.resetCustomization === 'function') {\n        api.resetCustomization(id);\n      }\n    } catch (error) {\n      collapse();\n      return;\n    }\n    if (action === 'refill') {\n      // The app re-renders its fields on the next ticks; show the confirmation once they settle.\n      window.setTimeout(showDone, 450);\n    } else {\n      window.setTimeout(() => collapse('Okay \u2014 starting fresh.'), 250);\n    }\n  };\n\n  const onCardClick = (event) => {\n    const button = event.target instanceof Element && event.target.closest('[data-caf-autofill]');\n    if (!button || state !== 'shown') return;\n    const action = button.dataset.cafAutofill;\n    if (action === 'dismiss') {\n      collapse();\n      return;\n    }\n    setBusy(button);\n    // Let the spinner paint before the (synchronous) app call re-renders the form.\n    window.requestAnimationFrame(() => window.setTimeout(() => runAction(action), 40));\n  };\n\n  const place = () => {\n    const panel = getPanel();\n    const template = doc.getElementById(TEMPLATE_ID);\n    if (!panel || !template || !template.content || !template.content.firstElementChild) return false;\n    card = template.content.firstElementChild.cloneNode(true);\n    card.addEventListener('click', onCardClick);\n    // TeeInBlue normally restores the saved details into its form on load already \u2192 describe that.\n    const prefilled = Array.from(panel.querySelectorAll('#teeFormInputs input[type=\"text\"], #teeFormInputs textarea')).some(\n      (input) => !input.classList.contains('tee-custom-select__search-input') && input.value.trim() !== '',\n    );\n    if (prefilled) {\n      card.classList.add('is-prefilled');\n      card.querySelectorAll('[data-prefilled-text]').forEach((node) => {\n        node.textContent = node.dataset.prefilledText;\n      });\n    }\n    const header = panel.querySelector(':scope > .caf-pdp-progress');\n    if (header) header.after(card);\n    else panel.prepend(card);\n    state = 'shown';\n    return true;\n  };\n\n  const check = () => {\n    if (state !== 'idle') return true;\n    if (touchedForm) {\n      state = 'closed';\n      return true;\n    }\n    if (!hasSavedCustomization()) return false;\n    return place();\n  };\n\n  ['pointerdown', 'keydown', 'input', 'change'].forEach((type) => {\n    doc.addEventListener(\n      type,\n      (event) => {\n        if (!event.isTrusted || !(event.target instanceof Element) || !event.target.closest('#teeFormInputs, #teeFormActions')) return;\n        touchedForm = true;\n      },\n      true,\n    );\n  });\n\n  // TeeInBlue may inject before or after this deferred script runs, and the CAF shell is created by\n  // theme-hotfixes-product.js on its own timers \u2014 retry for a short while, then stop.\n  const watch = () => {\n    if (check()) return;\n    watchStop = Date.now() + 15000;\n    const details = doc.querySelector('.product__details--product-page') || doc.body;\n    const observer = new MutationObserver(() => {\n      if (check() || Date.now() > watchStop) observer.disconnect();\n    });\n    observer.observe(details, { childList: true, subtree: true });\n    [400, 1200, 2500, 5000, 9000].forEach((delay) => window.setTimeout(check, delay));\n    window.setTimeout(() => observer.disconnect(), 15500);\n  };\n\n  // Keep the card next to the progress header if that header is (re)built after us.\n  doc.addEventListener('caf:personalize-progress', () => {\n    if (!card || state !== 'shown') return;\n    const header = card.parentElement && card.parentElement.querySelector(':scope > .caf-pdp-progress');\n    if (header && header.nextElementSibling !== card) header.after(card);\n  });\n\n  // Typing into a text field by hand = the shopper took over: hide the suggestion (nothing is wiped), so\n  // \"Use my last details\" can no longer overwrite what they just typed. Not for the searchable-dropdown box:\n  // the layout shift would scroll the page and TeeInBlue closes its open list on scroll.\n  doc.addEventListener(\n    'input',\n    (event) => {\n      if (state !== 'shown' || !event.isTrusted || !(event.target instanceof Element)) return;\n      if (event.target.closest('.tee-custom-select')) return;\n      if (event.target.closest('#teeFormInputs')) collapse();\n    },\n    true,\n  );\n\n  doc.addEventListener('teeinblue-event-component-injected', check);\n\n  if (doc.readyState === 'loading') {\n    doc.addEventListener('DOMContentLoaded', watch);\n  } else {\n    watch();\n  }\n})();\n"],
  "mappings": "CAWC,IAAM,CACL,GAAI,OAAO,kBAAmB,OAC9B,OAAO,kBAAoB,GAE3B,MAAM,IAAM,SACN,YAAc,wBACd,eAAiB,wBACjB,gBAAkB,KAClB,YAAc,IACd,QAAU,8DAEhB,IAAI,MAAQ,OACR,KAAO,KACP,UAAY,EAIZ,YAAc,GAElB,MAAM,aAAe,IAAM,OAAO,mBAAqB,OAAO,kBAAkB,UAE1E,sBAAwB,IAAM,CAClC,GAAI,CACF,MAAM,GAAK,aAAa,EACxB,MAAO,GAAQ,IAAM,OAAO,WAAa,OAAO,OAAO,UAAU,kBAAqB,YAAc,OAAO,UAAU,iBAAiB,EAAE,EAC1I,MAAgB,CACd,M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