{
  "version": 3,
  "sources": ["/cdn/shop/t/100/assets/cart-ship-sync.js"],
  "sourcesContent": ["// Keeps the order-level ship attribute (\"Expected Ship Date\") on the cart in sync\n// with what snippets/cart-ship-estimate.liquid computed. The hidden form inputs cover the regular\n// Checkout button, but accelerated checkout (Shop Pay, Apple Pay, etc.) skips the cart form, so we\n// also write the attributes with /cart/update.js whenever the rendered values differ from the cart's.\n(() => {\n  if (window.__ekoShipSync) return;\n  window.__ekoShipSync = true;\n\n  const synced = {};\n  let timer;\n\n  const sync = () => {\n    // The cart page and the cart drawer each render their own copy of these inputs, and only the\n    // surface being used is re-rendered after a change - the other copy can be stale. Read just the\n    // drawer's inputs while it's open (or if there's no cart page), otherwise just the page's.\n    const all = [...document.querySelectorAll('[data-eko-ship-attr]')];\n    const inDrawer = (input) => !!input.closest('cart-drawer');\n    const pageInputs = all.filter((input) => !inDrawer(input));\n    const drawerOpen = !!document.querySelector('cart-drawer.active');\n    const inputs = drawerOpen || !pageInputs.length ? all.filter(inDrawer) : pageInputs;\n\n    const attributes = {};\n    inputs.forEach((input) => {\n      const name = input.dataset.ekoShipAttr;\n      const known = name in synced ? synced[name] : input.dataset.current;\n      if (input.value !== known) attributes[name] = input.value;\n    });\n    if (!Object.keys(attributes).length) return;\n    fetch(`${window.Shopify?.routes?.root || '/'}cart/update.js`, {\n      method: 'POST',\n      headers: { 'Content-Type': 'application/json', Accept: 'application/json' },\n      body: JSON.stringify({ attributes }),\n    })\n      .then((res) => {\n        if (res.ok) Object.assign(synced, attributes);\n      })\n      .catch(() => {});\n  };\n\n  const schedule = () => {\n    clearTimeout(timer);\n    timer = setTimeout(sync, 300);\n  };\n\n  // Cart page / drawer re-render their sections after every change, replacing the inputs.\n  new MutationObserver(schedule).observe(document.documentElement, { childList: true, subtree: true });\n  schedule();\n})();\n"],
  "mappings": "CAIC,IAAM,CACL,GAAI,OAAO,cAAe,OAC1B,OAAO,cAAgB,GAEvB,MAAM,OAAS,CAAC,EAChB,IAAI,MAEJ,MAAM,KAAO,IAAM,CAIjB,MAAM,IAAM,CAAC,GAAG,SAAS,iBAAiB,sBAAsB,CAAC,EAC3D,SAAY,OAAU,CAAC,CAAC,MAAM,QAAQ,aAAa,EACnD,WAAa,IAAI,OAAQ,OAAU,CAAC,SAAS,KAAK,CAAC,EAEnD,OADa,CAAC,CAAC,SAAS,cAAc,oBAAoB,GACnC,CAAC,WAAW,OAAS,IAAI,OAAO,QAAQ,EAAI,WAEnE,WAAa,CAAC,EACpB,OAAO,QAAS,OAAU,CACxB,MAAM,KAAO,MAAM,QAAQ,YACrB,MAAQ,QAAQ,OAAS,OAAO,IAAI,EAAI,MAAM,QAAQ,QACxD,MAAM,QAAU,QAAO,WAAW,IAAI,EAAI,MAAM,MACtD,CAAC,EACI,OAAO,KAAK,UAAU,EAAE,QAC7B,MAAM,GAAG,OAAO,SAAS,QAAQ,MAAQ,GAAG,iBAAkB,CAC5D,OAAQ,OACR,QAAS,CAAE,eAAgB,mBAAoB,OAAQ,kBAAmB,EAC1E,KAAM,KAAK,UAAU,CAAE,UAAW,CAAC,CACrC,CAAC,EACE,KAAM,KAAQ,CACT,IAAI,IAAI,OAAO,OAAO,OAAQ,UAAU,CAC9C,CAAC,EACA,MAAM,IAAM,CAAC,CAAC,CACnB,EAEM,SAAW,IAAM,CACrB,aAAa,KAAK,EAClB,MAAQ,WAAW,KAAM,GAAG,CAC9B,EAGA,IAAI,iBAAiB,QAAQ,EAAE,QAAQ,SAAS,gBAAiB,CAAE,UAAW,GAAM,QAAS,EAAK,CAAC,EACnG,SAAS,CACX,GAAG",
  "names": []
}
