{
  "version": 3,
  "sources": ["/cdn/shop/t/97/assets/promo-pricing.js?cb=20261119"],
  "sourcesContent": ["/**\n * BFCM promotion on the product page: struck-through prices and the promotion's\n * percent on the Loop purchase options (one-time and Subscribe & Save).\n *\n * The prices here are an ESTIMATE of what Shopify's automatic discounts will\n * charge; the cart always shows the real amounts. Everything comes from data:\n *   - prices and plan prices (what the Loop plan gives): the product JSON that the\n *     Loop widget carries (data-product), for the selected variant and plan;\n *   - the usual subscription percent (struck through), the promotion's extra percent,\n *     window and eligible tag: Theme settings > BFCM promotion\n *     (snippets/promo-config.liquid). The percent shown as new is the total the\n *     shopper gets against the regular price: the Loop plan's own plus any extra.\n * Nothing is added to the cart to read a price.\n *\n * Loop rewrites these elements whenever the variant, plan or purchase option\n * changes, so the estimate is re-applied after every Loop update.\n */\n(() => {\n  const CONFIG_ID = 'pb-promo-config';\n  const WIDGET_SELECTOR = '.loop-subscription-container';\n  const FIELDSET_SELECTOR = '#loop-selling-plan-fieldset';\n  const PLAN_RADIO_SELECTOR = '.loop-selling-plan-selector-option:checked';\n  const HIDDEN_CLASS = 'loop-display-none';\n  const ACTIVE_CLASS = 'is-promo';\n  // Classes of the shared component (assets/subscription-container.css) and of the cart's own list.\n  const SC_CLASSES = Object.freeze({ old: 'sc-old', new: 'sc-new' });\n  const CART_CLASSES = Object.freeze({ old: 'pb-promo-old', new: 'pb-promo-new' });\n\n  const formatMoney = (cents) =>\n    new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', currencyDisplay: 'narrowSymbol' }).format(cents / 100);\n\n  const readJson = (text) => {\n    try {\n      return JSON.parse(text);\n    } catch (error) {\n      return null;\n    }\n  };\n\n  const readConfig = () => readJson(document.getElementById(CONFIG_ID)?.textContent || '');\n\n  // Mode \"on\" and \"off\" are the shop's decision; \"auto\" follows the dates.\n  const isInWindow = (config, now = Date.now()) => {\n    if (config.mode === 'on') return true;\n    if (config.mode === 'off') return false;\n    return now >= Date.parse(config.startsAt) && now < Date.parse(config.endsAt);\n  };\n\n  // A total after a percent taken off its whole amount (rounded to the cent).\n  const afterPercent = (cents, percent) => Math.round((cents * (100 - percent)) / 100);\n\n  // What the cart charges for a line under a percentage discount: Shopify takes the percent off EACH unit,\n  // cutting it to the cent (22.99 x 20% = 4.598 -> 4.59), and multiplies by the quantity. Not the same as\n  // afterPercent on the line total (6 x 22.99 -> 110.35 that way, 110.40 in the cart).\n  const unitAfterPercent = (unitCents, percent) => unitCents - Math.floor((unitCents * percent) / 100);\n\n  const lineAfterPercent = (unitCents, quantity, percent) => unitAfterPercent(unitCents, percent) * quantity;\n\n  const percentOff = (regularCents, paidCents) => (regularCents > 0 ? Math.round((1 - paidCents / regularCents) * 100) : 0);\n\n  const fillTemplate = (template, percent) => template.replace('__percent__', percent);\n\n  /** The prices to show for the selected variant, or null when the promotion does not apply. */\n  const estimateFor = (product, variantId, planId, config) => {\n    if (!product || !(product.tags || []).includes(config.eligibleTag)) return null;\n    const variant = (product.variants || []).find((candidate) => String(candidate.id) === String(variantId));\n    if (!variant) return null;\n\n    const regular = variant.price;\n    const allocations = variant.selling_plan_allocations || [];\n    const allocation = allocations.find((candidate) => String(candidate.selling_plan_id) === String(planId)) || allocations[0];\n\n    const estimate = { oneTime: { regular, paid: afterPercent(regular, config.oneTimePercent) }, subscription: null };\n    if (allocation) {\n      // A Loop plan can price the first order and the next ones differently: one adjustment per stage.\n      const stages = (allocation.price_adjustments || []).map((adjustment) => adjustment.price);\n      const firstPrice = stages.length ? stages[0] : allocation.price;\n      const recurringPrice = stages.length ? stages[stages.length - 1] : allocation.price;\n      const percentFor = (price) => percentOff(regular, afterPercent(price, config.subscriptionPercent));\n      const paid = afterPercent(allocation.price, config.subscriptionPercent);\n      estimate.subscription = {\n        regular,\n        paid,\n        regularPercent: config.subscriptionRegularPercent,\n        totalPercent: percentOff(regular, paid),\n        firstOrderPercent: percentFor(firstPrice),\n        recurringPercent: percentFor(recurringPrice)\n      };\n    }\n    return estimate;\n  };\n\n  /* ---------- Writing into the Loop widget ---------- */\n\n  const setText = (element, text) => {\n    if (element && element.textContent !== text) element.textContent = text;\n  };\n\n  const showStrike = (strikeEl, regular, paid) => {\n    if (!strikeEl) return;\n    const show = regular > paid;\n    strikeEl.classList.toggle(HIDDEN_CLASS, !show);\n    setText(strikeEl, show ? formatMoney(regular) : '');\n  };\n\n  const paintOneTime = (widget, prices) => {\n    showStrike(widget.querySelector('#loop-price-one-time-original'), prices.regular, prices.paid);\n    setText(widget.querySelector('#loop-price-one-time'), formatMoney(prices.paid));\n  };\n\n  // The usual percent struck next to the one the shopper gets now: \"Save <s>15%</s> 20%\". Equal percents show one.\n  const percentHtml = (oldPercent, newPercent, classes = CART_CLASSES) =>\n    oldPercent === newPercent ? `${newPercent}%` : `<s class=\"${classes.old}\">${oldPercent}%</s> <span class=\"${classes.new}\">${newPercent}%</span>`;\n\n  /**\n   * Subscribe & Save, texts only (the numbers are the ones already calculated): the lock-in strip,\n   * \"Save <s>15%</s> 20%\" in the title and the first benefit \"<s>Save 15% on every order</s> 20% off for life\".\n   */\n  const paintSubscription = (widget, variantId, subscription, config) => {\n    const titleEl = widget.querySelector(`[id^='loop-discount-badge-${variantId}-']`);\n    const group = titleEl?.closest('.sc-option');\n    if (!group) return;\n\n    const { regularPercent, totalPercent } = subscription;\n    const hasPromo = totalPercent > regularPercent;\n    const lock = group.querySelector('[data-sc-lock]');\n    if (lock) {\n      lock.hidden = !hasPromo;\n      setText(lock.querySelector('[data-sc-lock-text]'), fillTemplate(config.texts.lockIn, totalPercent));\n    }\n    if (!hasPromo) return;\n\n    titleEl.classList.remove(HIDDEN_CLASS);\n    const titleHtml = `Save ${percentHtml(regularPercent, totalPercent, SC_CLASSES)}`;\n    if (titleEl.innerHTML !== titleHtml) titleEl.innerHTML = titleHtml;\n\n    const benefitEl = group.querySelector('[data-sc-benefit-saving]');\n    const benefitHtml =\n      `<span class=\"sc-benefit__old\">${fillTemplate(config.texts.saveEveryOrder, regularPercent)}</span>` +\n      `<span class=\"sc-benefit__new\">${fillTemplate(config.texts.offForLife, totalPercent)}</span>`;\n    if (benefitEl && benefitEl.innerHTML !== benefitHtml) benefitEl.innerHTML = benefitHtml;\n  };\n\n  const applyTo = (widget, config) => {\n    const fieldset = widget.querySelector(FIELDSET_SELECTOR);\n    const product = readJson(fieldset?.dataset.product || '');\n    const planId = widget.querySelector(PLAN_RADIO_SELECTOR)?.value;\n    const estimate = estimateFor(product, fieldset?.dataset.selectedVariantId, planId, config);\n    widget.classList.toggle(ACTIVE_CLASS, Boolean(estimate));\n    if (!estimate) return;\n\n    paintOneTime(widget, estimate.oneTime);\n    if (estimate.subscription) paintSubscription(widget, fieldset.dataset.selectedVariantId, estimate.subscription, config);\n  };\n\n  /* ---------- Staying in sync with Loop ---------- */\n\n  const touchesWidget = (mutation) => {\n    const target = mutation.target.nodeType === Node.TEXT_NODE ? mutation.target.parentElement : mutation.target;\n    if (target?.closest?.(WIDGET_SELECTOR)) return true;\n    return [...mutation.addedNodes].some((node) => node.nodeType === Node.ELEMENT_NODE && (node.matches(WIDGET_SELECTOR) || node.querySelector(WIDGET_SELECTOR)));\n  };\n\n  const applyAll = (config) => {\n    if (!isInWindow(config)) return;\n    document.querySelectorAll(WIDGET_SELECTOR).forEach((widget) => applyTo(widget, config));\n  };\n\n  const start = () => {\n    const config = readConfig();\n    if (!config || !document.querySelector(WIDGET_SELECTOR)) return;\n\n    let scheduled = false;\n    const schedule = () => {\n      if (scheduled) return;\n      scheduled = true;\n      window.requestAnimationFrame(() => {\n        scheduled = false;\n        applyAll(config);\n      });\n    };\n\n    new MutationObserver((mutations) => {\n      if (mutations.some(touchesWidget)) schedule();\n    }).observe(document.body, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['class', 'data-selected-variant-id'] });\n    document.addEventListener('change', schedule);\n    schedule();\n  };\n\n  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start);\n  else start();\n\n  window.PocoBeroPromo = Object.freeze({\n    estimateFor,\n    isInWindow,\n    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