{
  "version": 3,
  "sources": ["/cdn/shop/t/9/assets/product-price-v2.js?el_sale_v=20260806_111811"],
  "sourcesContent": ["import { ThemeEvents } from '@theme/events';\nimport { Component } from '@theme/component';\nimport { StandardEvents, ProductSelectEvent } from '@shopify/events';\n\nconst syncHomeSaleCards = () => {\n  document.querySelectorAll('.etsy-market-card__price').forEach((priceBlock) => {\n    const salePrice = priceBlock.querySelector('strong');\n    const comparePrice = priceBlock.querySelector('s');\n    const discount = priceBlock.querySelector('.etsy-market-card__discount');\n    if (!salePrice || !comparePrice || !discount) return;\n\n    const saleCents = Math.round(Number.parseFloat((salePrice.textContent || '').replace(/[^0-9.]/g, '')) * 100);\n    const compareCents = Math.round(Number.parseFloat((comparePrice.textContent || '').replace(/[^0-9.]/g, '')) * 100);\n    if (!Number.isFinite(saleCents) || !Number.isFinite(compareCents) || saleCents <= 0 || compareCents <= saleCents) return;\n\n    const percent = Math.round(((compareCents - saleCents) / compareCents) * 100);\n    discount.textContent = `(${percent}% off)`;\n  });\n};\n\nif (document.readyState === 'loading') {\n  document.addEventListener('DOMContentLoaded', syncHomeSaleCards, { once: true });\n} else {\n  syncHomeSaleCards();\n}\nwindow.setTimeout(syncHomeSaleCards, 500);\n\nconst activeStorewideSaleConfig = () => {\n  const config = window.EveryLegendSaleConfig || {};\n  const discountPercent = Number(config.discount_percent);\n  const startsAt = config.starts_at ? new Date(config.starts_at).getTime() : null;\n  const endsAt = config.ends_at ? new Date(config.ends_at).getTime() : null;\n  const now = Date.now();\n  if (config.active !== true || !Number.isFinite(discountPercent) || discountPercent <= 0 || discountPercent >= 100) return null;\n  if (Number.isFinite(startsAt) && now < startsAt) return null;\n  if (Number.isFinite(endsAt) && now >= endsAt) return null;\n  return config;\n};\n\nconst syncUnderMediaRecommendationPrices = () => {\n  document.querySelectorAll('.etsy-under-media-card__price').forEach((priceBlock) => {\n    const salePrice = priceBlock.querySelector('strong');\n    if (!salePrice) return;\n\n    const saleCents = Math.round(Number.parseFloat((salePrice.textContent || '').replace(/[^0-9.]/g, '')) * 100);\n    const saleConfig = activeStorewideSaleConfig();\n    let comparePrice = priceBlock.querySelector('s');\n    if (!Number.isFinite(saleCents) || saleCents <= 0 || !saleConfig) {\n      comparePrice?.remove();\n      return;\n    }\n\n    const compareCents = Math.round(saleCents / (1 - Number(saleConfig.discount_percent) / 100));\n    const compareText = new Intl.NumberFormat(undefined, { style: 'currency', currency: 'USD' }).format(compareCents / 100);\n    if (!comparePrice) {\n      comparePrice = document.createElement('s');\n      salePrice.insertAdjacentElement('afterend', comparePrice);\n    }\n    if (comparePrice.textContent !== compareText) comparePrice.textContent = compareText;\n  });\n};\n\nconst startUnderMediaRecommendationPriceSync = () => {\n  syncUnderMediaRecommendationPrices();\n  window.setTimeout(syncUnderMediaRecommendationPrices, 500);\n  window.setTimeout(syncUnderMediaRecommendationPrices, 1500);\n\n  const recommendations = document.querySelector('.etsy-under-media-recommendations');\n  if (!recommendations) return;\n\n  let pending = false;\n  const scheduleSync = () => {\n    if (pending) return;\n    pending = true;\n    requestAnimationFrame(() => {\n      pending = false;\n      syncUnderMediaRecommendationPrices();\n    });\n  };\n  const observer = new MutationObserver(scheduleSync);\n  observer.observe(recommendations, {\n    childList: true,\n    subtree: true,\n  });\n  setTimeout(() => observer.disconnect(), 12000);\n};\n\nif (document.readyState === 'loading') {\n  document.addEventListener('DOMContentLoaded', startUnderMediaRecommendationPriceSync, { once: true });\n} else {\n  startUnderMediaRecommendationPriceSync();\n}\n\nconst formatSaleCountdown = (saleEndsAt = activeStorewideSaleConfig()?.ends_at) => {\n  const end = new Date(saleEndsAt).getTime();\n  const remaining = end - Date.now();\n  if (!Number.isFinite(end) || remaining <= 0) return 'Sale ended';\n  return 'Limited-time sale';\n};\n\n/**\n * @typedef {Object} ProductPriceRefs\n * @property {HTMLElement} priceContainer\n * @property {HTMLElement} [volumePricingNote]\n */\n\n/**\n * A custom element that displays a product price.\n * This component listens for variant update events and updates the price display accordingly.\n * It handles price updates from two different sources:\n * 1. Variant picker (in quick add modal or product page)\n * 2. Swatches variant picker (in product cards)\n *\n * @extends {Component<ProductPriceRefs>}\n */\nclass ProductPrice extends Component {\n  connectedCallback() {\n    super.connectedCallback();\n    this.#ensureSaleStyle();\n    this.#syncSaleLine();\n    const closestSection = this.closest('.shopify-section, dialog');\n    if (!closestSection) return;\n    closestSection.addEventListener(StandardEvents.productSelect, this.#handleProductSelect);\n  }\n\n  disconnectedCallback() {\n    super.disconnectedCallback();\n    const closestSection = this.closest('.shopify-section, dialog');\n    if (!closestSection) return;\n    closestSection.removeEventListener(StandardEvents.productSelect, this.#handleProductSelect);\n  }\n\n  /**\n   * Handles product select event and updates the price.\n   * @param {ProductSelectEvent} event - The product select event.\n   */\n  #handleProductSelect = (event) => {\n    if (!(event.target instanceof Element) || event.target.closest('product-card')) return;\n\n    event.promise\n      .then(({ detail }) => {\n        if (!detail?.html) return;\n\n        const { html, newProduct } = detail;\n\n        if (newProduct) {\n          this.dataset.productId = newProduct.id;\n        } else if (detail.productId && detail.productId !== this.dataset.productId) {\n          return;\n        }\n\n        const { priceContainer, volumePricingNote } = this.refs;\n        // Find the new product-price element in the updated HTML\n        const newProductPrice = html.querySelector(`product-price[data-block-id=\"${this.dataset.blockId}\"]`);\n        if (!newProductPrice) return;\n\n        // Update price container\n        const newPrice = newProductPrice.querySelector('[ref=\"priceContainer\"]');\n        if (newPrice && priceContainer) {\n          priceContainer.replaceWith(newPrice);\n          this.#syncSaleLine();\n        }\n\n        // Update volume pricing note\n        const newNote = newProductPrice.querySelector('[ref=\"volumePricingNote\"]');\n        if (!newNote) {\n          volumePricingNote?.remove();\n        } else if (!volumePricingNote) {\n          // Use newPrice since priceContainer was just replaced and now points to the detached element\n          newPrice?.insertAdjacentElement('afterend', /** @type {Element} */ (newNote.cloneNode(true)));\n        } else {\n          volumePricingNote.replaceWith(newNote);\n        }\n\n        // Update installments (SPI banner) variant ID to trigger payment terms re-render\n        const installmentsInput = /** @type {HTMLInputElement|null} */ (\n          this.querySelector(`#product-form-installment-${this.dataset.blockId} input[name=\"id\"]`)\n        );\n        if (installmentsInput) {\n          installmentsInput.value = detail.resource?.id ?? '';\n          installmentsInput.dispatchEvent(new Event('change', { bubbles: true }));\n        }\n      })\n      .catch((error) => {\n        if (error?.name !== 'AbortError') console.warn('[product-price] Event promise rejected:', error);\n      });\n  };\n\n  #ensureSaleStyle() {\n    if (document.getElementById('everylegend-sale-price-js-style-v2')) return;\n\n    const style = document.createElement('style');\n    style.id = 'everylegend-sale-price-js-style-v2';\n    style.textContent = `\n      .product-details .price,\n      .product-details product-price {\n        color: #2f2938 !important;\n        font-size: clamp(1.92rem, 1.66rem + 0.78vw, 2.62rem) !important;\n        line-height: 0.98 !important;\n        font-weight: 800 !important;\n        letter-spacing: 0 !important;\n      }\n\n      .product-details .price__sale {\n        display: flex !important;\n        flex-wrap: wrap !important;\n        align-items: baseline !important;\n        column-gap: 12px !important;\n        row-gap: 2px !important;\n      }\n\n      .product-details .price-item__group {\n        display: inline-flex !important;\n        align-items: baseline !important;\n      }\n\n      .product-details .compare-at-price,\n      .product-details s {\n        color: #5f5967 !important;\n        font-size: clamp(1.08rem, 0.94rem + 0.34vw, 1.46rem) !important;\n        font-weight: 450 !important;\n        text-decoration-line: line-through !important;\n        text-decoration-thickness: 2px !important;\n        text-decoration-color: #5f5967 !important;\n      }\n\n      .product-details .etsy-sale-line {\n        display: flex !important;\n        flex-wrap: wrap !important;\n        gap: 8px !important;\n        align-items: baseline !important;\n        margin-top: 6px !important;\n        color: #49772d !important;\n        font-size: clamp(1.03rem, 0.9rem + 0.34vw, 1.4rem) !important;\n        font-weight: 800 !important;\n        line-height: 1.12 !important;\n        letter-spacing: 0 !important;\n      }\n\n      .product-details .etsy-sale-line [aria-hidden=\"true\"] {\n        font-size: 0.76em !important;\n      }\n    `;\n    document.head.appendChild(style);\n  }\n\n  #syncSaleLine() {\n    if (this.closest('product-card')) return;\n\n    const priceContainer = this.querySelector('[ref=\"priceContainer\"]');\n    const salePrice = priceContainer?.querySelector('.price-item--sale');\n    const regularPrice = priceContainer?.querySelector('.compare-at-price');\n    this.querySelectorAll('.etsy-sale-line').forEach((line) => line.remove());\n    if (!priceContainer || !salePrice || !regularPrice) return;\n\n    const parseMoney = (value) => Number.parseFloat(value.replace(/[^0-9.]/g, ''));\n    const sale = parseMoney(salePrice.textContent || '');\n    const regular = parseMoney(regularPrice.textContent || '');\n    if (!Number.isFinite(sale) || !Number.isFinite(regular) || regular <= sale) return;\n\n    const percent = Math.round(((regular - sale) / regular) * 100);\n    const saleConfig = activeStorewideSaleConfig();\n    const configuredPercent = Number(saleConfig?.discount_percent);\n    const line = document.createElement('div');\n    line.className = 'etsy-sale-line';\n    line.dataset.saleEndsAt = saleConfig?.ends_at || '';\n    const countdown = formatSaleCountdown(line.dataset.saleEndsAt);\n    const displayPercent = Number.isFinite(configuredPercent) ? configuredPercent : percent;\n    line.innerHTML = countdown\n      ? `<span>${displayPercent}% off</span><span aria-hidden=\"true\">&bull;</span><span class=\"etsy-sale-countdown\">${countdown}</span>`\n      : `<span>${displayPercent}% off</span>`;\n    priceContainer.insertAdjacentElement('afterend', line);\n\n    const target = line.querySelector('.etsy-sale-countdown');\n    const tick = () => {\n      if (!target) return;\n      target.textContent = formatSaleCountdown(line.dataset.saleEndsAt);\n    };\n    tick();\n    window.setInterval(tick, 1000);\n  }\n}\n\nif (!customElements.get('product-price')) {\n  customElements.define('product-price', ProductPrice);\n}\n"],
  "mappings": "AAAA,MAA4B,gBAC5B,OAAS,cAAiB,mBAC1B,OAAS,mBAA0C,kBAEnD,MAAM,kBAAoB,IAAM,CAC9B,SAAS,iBAAiB,0BAA0B,EAAE,QAAS,YAAe,CAC5E,MAAM,UAAY,WAAW,cAAc,QAAQ,EAC7C,aAAe,WAAW,cAAc,GAAG,EAC3C,SAAW,WAAW,cAAc,6BAA6B,EACvE,GAAI,CAAC,WAAa,CAAC,cAAgB,CAAC,SAAU,OAE9C,MAAM,UAAY,KAAK,MAAM,OAAO,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