{
  "version": 3,
  "sources": ["/cdn/shop/t/248/assets/notify-me.js?nc=1795554567"],
  "sourcesContent": ["/*\n * Notify me: Klaviyo's back in stock for the sold-out sizes of products with custom.notify_me.\n * The product page's button fires `pa:notify` with the chosen variant; this opens its dialog and sends the\n * sign-up straight to Klaviyo's client API (no onsite.js). Loaded only on those products.\n * A sign-up Klaviyo does not confirm (throttled, down, no connection) waits in the browser and\n * snippets/klaviyo-outbox sends it again.\n */\n(() => {\n  // The listeners are delegated to the document: bind them once per page, even if the script runs twice.\n  if (document.__notifyMe) return;\n  document.__notifyMe = true;\n\n  const EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n  // Each opening is a new sign-up: an answer that arrives for an earlier one is ignored.\n  let openings = 0;\n\n  const say = (form, text, tone) => {\n    const status = form.querySelector('[data-notify-status]');\n    if (!status) return;\n    status.textContent = text;\n    if (tone) status.dataset.tone = tone; else delete status.dataset.tone;\n  };\n\n  // A sign-up Klaviyo did not confirm waits in localStorage \u00ABscfKlOutbox\u00BB, and snippets/klaviyo-outbox sends\n  // it again from every page, well spaced, until Klaviyo takes it. True when it is stored: only then is the\n  // shopper told it is done, because without storage (private mode, quota, disabled) nobody would send it again.\n  const keep = (entry) => {\n    // The outbox drops what it cannot send (no public key, no variant): such an entry is as good as lost.\n    if (!entry.company || !entry.variant) return false;\n    try {\n      const stored = JSON.parse(localStorage.getItem('scfKlOutbox') || '[]');\n      // The same e-mail asking again for the same size replaces its entry; the 8 newest stay (the outbox's cap).\n      const box = (Array.isArray(stored) ? stored : []).filter(\n        (x) => !(x && x.kind === 'bis' && x.email === entry.email && String(x.variant) === entry.variant)\n      );\n      box.push(entry);\n      localStorage.setItem('scfKlOutbox', JSON.stringify(box.slice(-8)));\n    } catch (_) {\n      return false;\n    }\n    // The outbox is on this page as well: with this it tries the entry without waiting for the next page.\n    window.dispatchEvent(new Event('scf:outbox'));\n    return true;\n  };\n\n  document.addEventListener('pa:notify', (event) => {\n    const dialog = event.target.querySelector?.('[data-notify]');\n    if (!dialog) return;\n    const form = dialog.querySelector('[data-notify-form]');\n    form.querySelector('[name=\"variant\"]').value = String(event.detail?.variantId || '');\n    form.querySelector('[name=\"email\"]').removeAttribute('aria-invalid');\n    form.querySelector('[data-notify-submit]').disabled = false;\n    const size = dialog.querySelector('[data-notify-variant]');\n    if (size) size.textContent = event.detail?.label || '';\n    form.dataset.opening = String(++openings);\n    delete form.dataset.state;\n    say(form, '');\n    if (!dialog.open) dialog.showModal();\n  });\n\n  document.addEventListener('click', (event) => {\n    const dialog = event.target.closest?.('[data-notify]');\n    if (!dialog) return;\n    // The close button, or a click on the backdrop (the dialog itself, outside its form).\n    if (event.target.closest('[data-notify-close]') || event.target === dialog) dialog.close();\n  });\n\n  document.addEventListener('submit', async (event) => {\n    const form = event.target.closest?.('[data-notify-form]');\n    if (!form) return;\n    event.preventDefault();\n    const dialog = form.closest('[data-notify]');\n    const submit = form.querySelector('[data-notify-submit]');\n    const field = form.querySelector('[name=\"email\"]');\n    const email = field.value.trim();\n    if (!EMAIL.test(email)) {\n      field.setAttribute('aria-invalid', 'true');\n      say(form, dialog.dataset.invalid, 'error');\n      field.focus();\n      return;\n    }\n    field.removeAttribute('aria-invalid');\n    submit.disabled = true;\n    say(form, '');\n    const opening = form.dataset.opening;\n    const current = () => form.dataset.opening === opening;\n    // The size this sign-up is for, read now: when the answer comes the dialog may be open for another one.\n    const variant = form.querySelector('[name=\"variant\"]').value;\n    // A request that stalls gives up after a while: it then counts as not confirmed, like any that fails.\n    const wait = Number(dialog.dataset.timeout) || 10000;\n    const signal = typeof AbortSignal !== 'undefined' && AbortSignal.timeout ? AbortSignal.timeout(wait) : undefined;\n    try {\n      // null when the request fails: no connection, the time above ran out, or Klaviyo is throttling the\n      // account (its 429 comes without CORS headers, so the browser hides it from the page). None of them\n      // says whether the sign-up arrived.\n      const response = await fetch(`https://a.klaviyo.com/client/back-in-stock-subscriptions/?company_id=${encodeURIComponent(dialog.dataset.company)}`, {\n        method: 'POST',\n        headers: { 'Content-Type': 'application/vnd.api+json', revision: dialog.dataset.revision },\n        signal,\n        body: JSON.stringify({\n          data: {\n            type: 'back-in-stock-subscription',\n            attributes: {\n              profile: { data: { type: 'profile', attributes: { email } } },\n              channels: ['EMAIL']\n            },\n            relationships: {\n              variant: { data: { type: 'catalog-variant', id: `$shopify:::$default:::${variant}` } }\n            }\n          }\n        })\n      }).catch(() => null);\n      // Not confirmed either: 408, 429 and 5xx. Klaviyo has not taken the sign-up, but it has not said it is\n      // wrong, so it goes to the outbox, even if the dialog has moved on to another size meanwhile (the shopper\n      // asked for this one too). Sent once from here: trying again at once would only add to the throttling.\n      const unconfirmed = !response || response.status === 408 || response.status === 429 || response.status >= 500;\n      const kept = unconfirmed && keep({\n        t: Date.now(), kind: 'bis', company: dialog.dataset.company, variant, email, n: 0,\n        // Not before 30 to 50 s from now, on this page or the next one. An entry with no `next` is due at once:\n        // the outbox would send it half a second after the request above failed, and Klaviyo, whose throttling\n        // asked for 15 to 32 s on launch night, would refuse it again. The scatter keeps the browsers that failed\n        // together from coming back together.\n        next: Date.now() + 30000 + Math.floor(Math.random() * 20000)\n      });\n      if (!current()) return;\n      // What the outbox will deliver is done for the shopper; a refusal the page can read (another 4xx) is not.\n      if (!response?.ok && !kept) throw new Error(`Klaviyo ${response ? response.status : 'unreachable'}`);\n      form.dataset.state = 'done';\n      say(form, dialog.dataset.success);\n      // The field and the button are hidden now: the focus goes to the confirmation.\n      form.querySelector('[data-notify-status]')?.focus();\n    } catch (_) {\n      if (current()) say(form, dialog.dataset.error, 'error');\n    } finally {\n      if (current()) submit.disabled = false;\n    }\n  });\n})();\n"],
  "mappings": "CAOC,IAAM,CAEL,GAAI,SAAS,WAAY,OACzB,SAAS,WAAa,GAEtB,MAAM,MAAQ,6BAEd,IAAI,SAAW,EAEf,MAAM,IAAM,CAAC,KAAM,KAAM,OAAS,CAChC,MAAM,OAAS,KAAK,cAAc,sBAAsB,EACnD,SACL,OAAO,YAAc,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