@occluze/tether 0.6.8 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/esm/astro.js +2 -2
- package/dist/esm/chunks/account-UIPWJQ3Y.js +1 -0
- package/dist/esm/chunks/account-pages-6ROA6Y4V.js +1 -0
- package/dist/esm/chunks/analytics-2V632IRV.js +1 -0
- package/dist/esm/chunks/chunk-4GCXM764.js +1 -0
- package/dist/esm/chunks/chunk-56FCLJJD.js +1 -0
- package/dist/esm/chunks/chunk-5Z5O3767.js +1 -0
- package/dist/esm/chunks/chunk-6OZJCAGZ.js +1 -0
- package/dist/esm/chunks/chunk-A5SYCVQM.js +1 -0
- package/dist/esm/chunks/chunk-BA4LQJJQ.js +1 -0
- package/dist/esm/chunks/chunk-BFTZR4OB.js +4 -0
- package/dist/esm/chunks/chunk-C5JYQCWH.js +1 -0
- package/dist/esm/chunks/chunk-E5YO6274.js +1 -0
- package/dist/esm/chunks/chunk-MPDWM2NN.js +1 -0
- package/dist/esm/chunks/chunk-T44MUL4Y.js +1 -0
- package/dist/esm/chunks/chunk-YLUULATY.js +1 -0
- package/dist/esm/chunks/diagnose-3FEKRIEK.js +14 -0
- package/dist/esm/chunks/extras-6POFBNOP.js +1 -0
- package/dist/esm/chunks/markets-ui-FD6NI2OG.js +1 -0
- package/dist/esm/chunks/search-UJ73YBQ5.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/server.js +2 -2
- package/dist/presets/barba.esm.js +19 -23
- package/dist/tether.account-pages.js +320 -365
- package/dist/tether.account-pages.min.js +1 -1
- package/dist/tether.account.js +242 -491
- package/dist/tether.account.min.js +1 -1
- package/dist/tether.analytics.js +66 -88
- package/dist/tether.analytics.min.js +1 -1
- package/dist/tether.diagnose.js +36 -33
- package/dist/tether.diagnose.min.js +2 -2
- package/dist/tether.extras.js +28 -36
- package/dist/tether.extras.min.js +1 -1
- package/dist/tether.js +1270 -894
- package/dist/tether.markets.js +73 -90
- package/dist/tether.markets.min.js +1 -1
- package/dist/tether.min.js +0 -0
- package/dist/tether.min.js.map +4 -4
- package/dist/tether.search.js +44 -68
- package/dist/tether.search.min.js +1 -1
- package/dist/types/server/src/shared/account-orders.d.ts +44 -0
- package/dist/types/server/src/shared/account-routes.d.ts +153 -0
- package/dist/types/server/src/shared/api-versions.d.ts +13 -0
- package/dist/types/server/src/shared/error-message.d.ts +2 -0
- package/dist/types/server/src/shared/json.d.ts +25 -0
- package/dist/types/server/src/shared/market-codes.d.ts +16 -0
- package/dist/types/src/account/addresses-view.d.ts +5 -0
- package/dist/types/src/account/answers.d.ts +40 -0
- package/dist/types/src/account/markup.d.ts +19 -0
- package/dist/types/src/account/operations.d.ts +41 -0
- package/dist/types/src/account/order-lines.d.ts +13 -0
- package/dist/types/src/account/order-list.d.ts +12 -0
- package/dist/types/src/account/order-page.d.ts +6 -0
- package/dist/types/src/account/page-answers.d.ts +182 -0
- package/dist/types/src/account/page-events.d.ts +2 -0
- package/dist/types/src/account/server-client.d.ts +60 -0
- package/dist/types/src/account/subscriptions-view.d.ts +2 -0
- package/dist/types/src/account-api.d.ts +18 -0
- package/dist/types/src/account-marks.d.ts +15 -0
- package/dist/types/src/account-pages.d.ts +8 -0
- package/dist/types/src/account.d.ts +64 -0
- package/dist/types/src/amounts.d.ts +12 -0
- package/dist/types/src/analytics-shopify.d.ts +41 -0
- package/dist/types/src/analytics.d.ts +2 -0
- package/dist/types/src/api-version.d.ts +28 -0
- package/dist/types/src/astro.d.ts +42 -0
- package/dist/types/src/cart/cart-shape.d.ts +43 -0
- package/dist/types/src/cart/checkout.d.ts +16 -0
- package/dist/types/src/cart/drawer.d.ts +18 -0
- package/dist/types/src/cart/mutations.d.ts +79 -0
- package/dist/types/src/cart/render.d.ts +17 -0
- package/dist/types/src/cart/store.d.ts +182 -0
- package/dist/types/src/cart.d.ts +106 -0
- package/dist/types/src/client.d.ts +100 -0
- package/dist/types/src/collection.d.ts +25 -0
- package/dist/types/src/config-sections.d.ts +40 -0
- package/dist/types/src/config.d.ts +185 -0
- package/dist/types/src/controls/cart-controls.d.ts +2 -0
- package/dist/types/src/controls/discount.d.ts +2 -0
- package/dist/types/src/controls/extras.d.ts +5 -0
- package/dist/types/src/controls/navigation.d.ts +12 -0
- package/dist/types/src/diagnose-markup.d.ts +19 -0
- package/dist/types/src/diagnose.d.ts +60 -0
- package/dist/types/src/dom.d.ts +75 -0
- package/dist/types/src/extras.d.ts +21 -0
- package/dist/types/src/fragments.d.ts +158 -0
- package/dist/types/src/globals.d.ts +15 -0
- package/dist/types/src/images.d.ts +20 -0
- package/dist/types/src/index.d.ts +167 -0
- package/dist/types/src/initial.d.ts +56 -0
- package/dist/types/src/lazy.d.ts +28 -0
- package/dist/types/src/loader.d.ts +84 -0
- package/dist/types/src/market-codes.d.ts +6 -0
- package/dist/types/src/markets-ui.d.ts +32 -0
- package/dist/types/src/markets.d.ts +72 -0
- package/dist/types/src/markup.d.ts +131 -0
- package/dist/types/src/mounting.d.ts +46 -0
- package/dist/types/src/page-market.d.ts +27 -0
- package/dist/types/src/presets/barba.d.ts +56 -0
- package/dist/types/src/product-events.d.ts +2 -0
- package/dist/types/src/product-render.d.ts +17 -0
- package/dist/types/src/product-shape.d.ts +88 -0
- package/dist/types/src/product-state.d.ts +110 -0
- package/dist/types/src/product.d.ts +66 -0
- package/dist/types/src/repeaters.d.ts +16 -0
- package/dist/types/src/search.d.ts +33 -0
- package/dist/types/src/selling-plans.d.ts +64 -0
- package/dist/types/src/server.d.ts +88 -0
- package/dist/types/src/shopify-values.d.ts +46 -0
- package/dist/types/src/status.d.ts +33 -0
- package/dist/types/src/storage.d.ts +12 -0
- package/dist/types/src/store-html.d.ts +39 -0
- package/dist/types/src/storefront/catalog.d.ts +38 -0
- package/dist/types/src/storefront/json-ld.d.ts +20 -0
- package/dist/types/src/variant-render.d.ts +14 -0
- package/package.json +24 -23
- package/src/account/addresses-view.ts +58 -0
- package/src/account/answers.ts +79 -0
- package/src/account/markup.ts +36 -0
- package/src/account/operations.ts +145 -0
- package/src/account/{order-lines.js → order-lines.ts} +20 -41
- package/src/account/order-list.ts +107 -0
- package/src/account/order-page.ts +137 -0
- package/src/account/page-answers.ts +317 -0
- package/src/account/{page-events.js → page-events.ts} +55 -90
- package/src/account/server-client.ts +183 -0
- package/src/account/{subscriptions-view.js → subscriptions-view.ts} +25 -68
- package/src/account-api.ts +98 -0
- package/src/account-marks.ts +35 -0
- package/src/{account-pages.js → account-pages.ts} +29 -37
- package/src/account.ts +284 -0
- package/src/amounts.ts +64 -0
- package/src/{analytics-shopify.js → analytics-shopify.ts} +112 -107
- package/src/analytics.ts +315 -0
- package/src/{api-version.js → api-version.ts} +25 -31
- package/src/{astro.js → astro.ts} +110 -104
- package/src/cart/cart-shape.ts +25 -0
- package/src/cart/checkout.ts +101 -0
- package/src/cart/{drawer.js → drawer.ts} +18 -31
- package/src/cart/mutations.ts +237 -0
- package/src/cart/{render.js → render.ts} +68 -96
- package/src/cart/store.ts +279 -0
- package/src/{cart.js → cart.ts} +82 -128
- package/src/client.ts +391 -0
- package/src/{collection.js → collection.ts} +30 -38
- package/src/config-sections.ts +284 -0
- package/src/config.ts +480 -0
- package/src/controls/{cart-controls.js → cart-controls.ts} +22 -54
- package/src/controls/{discount.js → discount.ts} +13 -34
- package/src/controls/{extras.js → extras.ts} +15 -24
- package/src/controls/{navigation.js → navigation.ts} +24 -30
- package/src/{diagnose-markup.js → diagnose-markup.ts} +37 -72
- package/src/{diagnose.js → diagnose.ts} +95 -96
- package/src/dom.ts +268 -0
- package/src/{extras.js → extras.ts} +43 -52
- package/src/fragments.ts +261 -0
- package/src/globals.d.ts +15 -0
- package/src/{images.js → images.ts} +30 -43
- package/src/index.ts +415 -0
- package/src/initial.ts +101 -0
- package/src/lazy-iife.ts +197 -0
- package/src/lazy.ts +42 -0
- package/src/{loader.js → loader.ts} +149 -123
- package/src/market-codes.ts +6 -0
- package/src/{markets-ui.js → markets-ui.ts} +91 -68
- package/src/markets.ts +246 -0
- package/src/markup.ts +127 -0
- package/src/{mounting.js → mounting.ts} +88 -101
- package/src/{page-market.js → page-market.ts} +32 -38
- package/src/part-integrity.ts +7 -0
- package/src/parts/account-pages.ts +7 -0
- package/src/parts/account.ts +7 -0
- package/src/parts/analytics.ts +7 -0
- package/src/parts/diagnose.ts +7 -0
- package/src/parts/extras.ts +7 -0
- package/src/parts/markets.ts +7 -0
- package/src/parts/search.ts +7 -0
- package/src/presets/barba.ts +194 -0
- package/src/{product-events.js → product-events.ts} +33 -48
- package/src/{product-render.js → product-render.ts} +38 -77
- package/src/product-shape.ts +49 -0
- package/src/product-state.ts +318 -0
- package/src/{product.js → product.ts} +90 -126
- package/src/{repeaters.js → repeaters.ts} +40 -52
- package/src/{search.js → search.ts} +85 -103
- package/src/selling-plans.ts +145 -0
- package/src/server.ts +211 -0
- package/src/{shopify-values.js → shopify-values.ts} +24 -22
- package/src/{status.js → status.ts} +34 -54
- package/src/storage.ts +34 -0
- package/src/store-html.ts +359 -0
- package/src/storefront/catalog.ts +196 -0
- package/src/storefront/{json-ld.js → json-ld.ts} +45 -68
- package/src/{variant-render.js → variant-render.ts} +24 -50
- package/dist/esm/chunks/account-C3NP6HFB.js +0 -1
- package/dist/esm/chunks/account-pages-WLK374FO.js +0 -1
- package/dist/esm/chunks/analytics-G3SAWMNL.js +0 -1
- package/dist/esm/chunks/chunk-27PJJZGC.js +0 -1
- package/dist/esm/chunks/chunk-2FSXS55U.js +0 -1
- package/dist/esm/chunks/chunk-FCSWQDVV.js +0 -1
- package/dist/esm/chunks/chunk-FOMSMIAM.js +0 -1
- package/dist/esm/chunks/chunk-GZJTCLLW.js +0 -1
- package/dist/esm/chunks/chunk-HEQILZVR.js +0 -1
- package/dist/esm/chunks/chunk-JOOEXYF3.js +0 -4
- package/dist/esm/chunks/chunk-MPTQYLSM.js +0 -1
- package/dist/esm/chunks/chunk-NEHZ37TU.js +0 -3
- package/dist/esm/chunks/chunk-V74KGEJF.js +0 -1
- package/dist/esm/chunks/chunk-VT4CDUJJ.js +0 -1
- package/dist/esm/chunks/chunk-YJLWX2HK.js +0 -1
- package/dist/esm/chunks/diagnose-6VVGZNTY.js +0 -14
- package/dist/esm/chunks/extras-GJVRDFM3.js +0 -1
- package/dist/esm/chunks/markets-ui-UNB4PTA7.js +0 -1
- package/dist/esm/chunks/search-OU75RNQL.js +0 -1
- package/src/account/addresses-view.js +0 -92
- package/src/account/browser-session.js +0 -359
- package/src/account/markup.js +0 -48
- package/src/account/operations.js +0 -180
- package/src/account/order-list.js +0 -91
- package/src/account/order-page.js +0 -192
- package/src/account/server-client.js +0 -172
- package/src/account/shared.js +0 -111
- package/src/account/shopify-auth.js +0 -150
- package/src/account-api.js +0 -118
- package/src/account-links.js +0 -35
- package/src/account.js +0 -342
- package/src/amounts.js +0 -36
- package/src/analytics.js +0 -352
- package/src/cart/checkout.js +0 -97
- package/src/cart/mutations.js +0 -234
- package/src/cart/store.js +0 -326
- package/src/client.js +0 -267
- package/src/config.js +0 -349
- package/src/dom.js +0 -287
- package/src/fragments.js +0 -237
- package/src/index.js +0 -353
- package/src/initial.js +0 -87
- package/src/lazy-iife.js +0 -116
- package/src/lazy.js +0 -39
- package/src/market-codes.js +0 -35
- package/src/markets.js +0 -334
- package/src/markup.js +0 -64
- package/src/parts/account-pages.js +0 -6
- package/src/parts/account.js +0 -6
- package/src/parts/analytics.js +0 -6
- package/src/parts/diagnose.js +0 -6
- package/src/parts/extras.js +0 -6
- package/src/parts/markets.js +0 -6
- package/src/parts/search.js +0 -6
- package/src/presets/barba.js +0 -190
- package/src/product-state.js +0 -318
- package/src/selling-plans.js +0 -154
- package/src/server.js +0 -215
- package/src/store-html.js +0 -0
- package/src/storefront/catalog.js +0 -199
- package/types/astro.d.ts +0 -28
- package/types/barba.d.ts +0 -16
- package/types/index.d.ts +0 -577
- package/types/server.d.ts +0 -182
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as S,b as J,c as C,d as K,e as z,f as Z,g as tt}from"./chunk-HEQILZVR.js";import{b as $,e as et}from"./chunk-FCSWQDVV.js";import{b as Y}from"./chunk-MPTQYLSM.js";import{d as W,e as k,f as P,k as X}from"./chunk-JOOEXYF3.js";import{A as m,B as D,C as E,E as B,F as U,G as y,H as F,I as R,J as d,L as T,M as A,N as L,O as G,P as j,Q as H,R as Q,b as w,i as q,r as p,s as o,t as l,u as I,v as f,w as M,x as g,z as _}from"./chunk-YJLWX2HK.js";var dt=/^image:(\d+)$/,it="metafield:",ht=/^(rich_text|multi_line_text)_field$/,pt=["","true","all","*"],V=e=>e.tagName==="SELECT",b=(e,t)=>e.$(`select${t}`).filter(V);function ft(e,t){let i=t.images.nodes,n=[...e.children].map(s=>s.tagName==="IMG"?s:s.querySelector("img"));!D(e)&&n.length===i.length&&n.every((s,r)=>_(s?.getAttribute("src"),i[r]?.url))||E(e,i,(s,r)=>{let c=s.matches(`img,${o("bind","image")}`)?s:f(s,"img")[0]??s;m(c,r.url,r.altText||t.title)})}function mt(e,t,i){let n=i.indexOf("."),a=i.slice(0,n),s=i.slice(n+1),r=(t.metafields??[]).find(u=>u?.namespace===a&&u.key===s);if(!r){d(e,"");return}let c=r.reference?.image;if(c){m(e,c.url,c.altText);return}ht.test(r.type)&&(e.style.whiteSpace="pre-line"),d(e,r.value)}var gt=new Map(Object.entries({title:e=>e.title,"description-text":e=>e.description,vendor:e=>e.vendor,type:e=>e.productType,handle:e=>e.handle,"published-at":e=>F(e.publishedAt),"min-price":e=>y(e.priceRange.minVariantPrice),"max-price":e=>y(e.priceRange.maxVariantPrice)}));function bt(e,t){let i=(e.getAttribute("exclude")??"").split(",").map(a=>a.trim()).filter(Boolean),n=t.tags.filter(a=>!i.includes(a));E(e,n,(a,s)=>{d(a,s)})}function vt(e,t,i){let n=gt.get(t);if(n){d(e,n(i));return}switch(t){case"description":R(e,i.descriptionHtml);break;case"featured-image":m(e,i.featuredImage?.url,i.featuredImage?.altText||i.title);break;case"url":case"link":e.setAttribute("href",B(i.handle,i.id)),t==="url"&&!e.firstElementChild&&!e.textContent.trim()&&d(e,i.title);break;case"images":ft(e,i);break;case"tags":bt(e,i);break;default:xt(e,t,i)}}function xt(e,t,i){let n=dt.exec(t);if(n){let a=i.images.nodes[Number(n[1])-1]??i.featuredImage;m(e,a?.url,a?.altText||i.title)}else t.startsWith(it)&&mt(e,i,t.slice(it.length))}function It(e){let{product:t}=e;e.$(o("option-list")).forEach(i=>{let n=e.optName(l(i,"option-list")),a=t.options.find(s=>s.name===n);if(!a||a.optionValues.length<=1&&I(i,"hide-single")){T(i,!1);return}E(i,a.optionValues,(s,r)=>{s.setAttribute(p("option-value"),r.name);let c=f(s,o("bind","option-value"))[0];c?d(c,r.name):s.firstElementChild||d(s,r.name);let u=f(s,o("bind","swatch"))[0],h=r.swatch;!u||!h||(h.color&&(u.style.backgroundColor=h.color),h.image?.previewImage&&m(u,h.image.previewImage.url,r.name))})})}function Et(e){let{product:t}=e;b(e,o("option")).forEach(i=>{let n=t.options.find(a=>a.name===e.optName(l(i,"option")));if(!n){T(i,!1);return}i.replaceChildren(...n.optionValues.map(a=>new Option(a.name,a.name)))}),b(e,o("variant-select")).forEach(i=>{i.replaceChildren(...t.variants.nodes.map(n=>new Option(n.title,n.id)))}),b(e,o("plan")).forEach(i=>{let n=e.plans.map(r=>new Option(r.name,r.id)),a=!t.requiresSellingPlan&&l(i,"plan")!=="subscription-only",s=i.getAttribute(p("one-time-label"))||"One-time purchase";i.replaceChildren(...a?[new Option(s,"")]:[],...n)})}function yt(e){e.$(o("plan-list")).forEach(t=>{let i=(l(t,"plan-list")??"").trim(),n=pt.includes(i.toLowerCase())?null:i,a=e.plans.filter(s=>!n||s.group.name===n);E(t,a,(s,r)=>{s.setAttribute(p("plan-value"),r.id),!s.firstElementChild&&!s.querySelector(o("plan-bind"))&&d(s,r.name)})})}function nt(e){e.$(o("bind")).forEach(t=>{vt(t,l(t,"bind")??"",e.product)}),It(e),Et(e),yt(e)}var at={money:y,percent:U},Tt=e=>e.tagName==="INPUT";function O(e){let t=f(e,o("add-label"))[0]??e,i=t.dataset.tetherLabel??(Tt(t)?t.value:t.textContent);return t.dataset.tetherLabel=i,{label:t,original:i}}function Pt(e,t){let{product:i}=e,n=a=>t.selected[e.optName(a)]??"";e.$(o("option-selected")).forEach(a=>{d(a,n(l(a,"option-selected")))}),e.$(o("option-list")).forEach(a=>{let s=e.optName(l(a,"option-list"));f(a,o("option-value")).forEach(r=>{let c=l(r,"option-value")??"";A(r,t.selected[s]===c);let u=!J(i,t.selected,s,c);r.classList.toggle("is-unavailable",u),r.setAttribute("data-unavailable",u?"true":"false")})}),b(e,o("option")).forEach(a=>{a.value=n(l(a,"option"))}),b(e,o("variant-select")).forEach(a=>{a.value=t.variant.id})}function At(e,t){let{variant:i,purchase:n,isSubscription:a}=t;e.$(o("purchase")).forEach(s=>{if(V(s)){s.value=n.kind;return}let r=l(s,"purchase");A(s,r===n.kind);let c=r==="subscription"?!t.subscriptionAvailable:e.product.requiresSellingPlan;s.classList.toggle("is-unavailable",c)}),e.$(o("plan-value")).forEach(s=>{let r=l(s,"plan-value")??"";A(s,a&&r===n.planId),s.classList.toggle("is-unavailable",!P(i,r));let c=e.plans.find(h=>h.id===r),u=tt(i,r,c,at);f(s,o("plan-bind")).forEach(h=>{let v=u.get(l(h,"plan-bind")??"");v&&d(h,v())})}),b(e,o("plan")).forEach(s=>{s.value=a?n.planId??"":""})}function St(e,t){let i=new Map(Object.entries(t.show));$.forEach(n=>i.set(n,n==="ready")),e.$(o("show")).forEach(n=>{let a=l(n,"show")??"",s=i.get(a);s!==void 0&&($.some(r=>r===a)&&!et(n,e.root)||T(n,s))})}function Ct(e,t){let i=!t.variant.availableForSale;e.$(o("add-to-cart")).forEach(n=>{n.classList.toggle("is-disabled",i),n.setAttribute("aria-disabled",String(i)),"disabled"in n&&(n.disabled=i);let a=l(n,"soldout-text"),s=l(n,"subscribe-text");if(!a&&!s)return;let{label:r,original:c}=O(n),u=c;t.isSubscription&&s&&(u=s),i&&a&&(u=a),n.getAttribute("aria-busy")!=="true"&&d(r,u)})}function st(e,t){let{variant:i}=t,{product:n}=e,a=Z(t,at);e.$(o("bind")).forEach(s=>{let r=l(s,"bind")??"";if(r==="variant-image"){m(s,i.image?.url||n.featuredImage?.url,i.image?.altText||n.title);return}let c=a.get(r);c&&d(s,c())}),Pt(e,t),At(e,t),St(e,t),e.root.classList.toggle("is-subscription",t.isSubscription),e.root.setAttribute(p("purchase-mode"),t.isSubscription?"subscription":"one-time"),Ct(e,t)}var ot=()=>o("product"),Nt=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA",rt=e=>e instanceof window.Element;function x(e,t,i){let n=t.closest(i);return n?.closest(ot())===e.root?n:null}function wt(e,t){let{label:i,original:n}=O(t),a=l(t,"adding-text");j(t,async()=>{a&&d(i,a);try{await e.addToCart()}catch(s){q(s,"add to cart failed"),g("error",{error:s,context:"add-to-cart"},e.root)}finally{a&&d(i,n)}}).then(()=>{e.renderVariant()})}function Lt(e,t,i){let n=x(e,i,o("option-value")),a=n?.closest(o("option-list"));if(n&&a){t.preventDefault(),e.select(e.optName(l(a,"option-list")),l(n,"option-value")??"");return}let s=x(e,i,o("plan-value"));if(s){t.preventDefault(),e.selectPlan(l(s,"plan-value"));return}let r=x(e,i,`${o("purchase")}:not(select)`);if(r){r.tagName!=="INPUT"&&t.preventDefault(),e.setPurchase(l(r,"purchase"));return}let c=x(e,i,o("qty-plus")),u=c?null:x(e,i,o("qty-minus"));if(c||u){t.preventDefault(),e.setQuantity(e.quantity+(c?1:-1));return}let h=x(e,i,o("add-to-cart"));h&&(t.preventDefault(),wt(e,h))}function kt(e,t){let i=Nt(t)?t.value:"";t.matches(`select${o("option")}`)?e.select(e.optName(l(t,"option")),i):t.matches(`select${o("variant-select")}`)?e.selectVariant(i):t.matches(`select${o("plan")}`)?i?e.selectPlan(i):e.setPurchase("one-time"):t.matches(`select${o("purchase")}`)?e.setPurchase(i):t.matches(o("qty"))&&e.setQuantity(i)}function lt(e){e.root.addEventListener("click",t=>{rt(t.target)&&Lt(e,t,t.target)}),e.root.addEventListener("change",t=>{let{target:i}=t;rt(i)&&i.closest(ot())===e.root&&kt(e,i)})}var $t=new WeakMap,Vt=()=>o("product"),N=new Map;function Ot(e){e.forEach(t=>{N.has(t.handle)||N.set(t.handle,t.options.map(i=>i.name))})}var ct=e=>e.tagName==="INPUT",qt=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA";function Mt(e){return ct(e)&&e.type==="checkbox"?e.checked?e.value&&e.value!=="on"?e.value:"Yes":null:ct(e)&&e.type==="radio"?e.checked?e.value:null:qt(e)&&e.value||null}var ut=class{constructor(t,i){this.root=t,this.product=i,this.plans=k(i);let n=new URLSearchParams(window.location.search),a=K(i,{variant:n.get("variant")||l(t,"variant"),sellingPlan:n.get("selling_plan"),defaultPlan:l(t,"default-plan"),defaultPurchase:l(t,"default-purchase")||w.defaultPurchase});this.selected=a.selected,this.purchaseChoice=a.purchase,this.variant=null,this.quantity=I(t,"quantity")?Math.max(0,parseInt(l(t,"quantity")??"",10)||0):1,$t.set(t,this),t.setAttribute(p("state"),"ready"),t.removeAttribute(p("error")),this.renderProduct(),lt(this),this.renderVariant(),G(t,"product"),L("product"),g("product-ready",{product:i,scope:this},t)}update(t){let i=this.variant?.id;this.product=t,this.plans=k(t);let n=t.variants.nodes.find(a=>a.id===i);n&&(this.selected=S(n)),this.root.setAttribute(p("state"),"ready"),this.root.removeAttribute(p("error")),this.renderProduct(),this.renderVariant(),L("product"),g("product-updated",{product:t,scope:this},this.root)}$(t){let i=M(this.root,t,Vt());return this.root.matches(t)?[this.root,...i]:i}optName(t){if(!t)return"";let{options:i}=this.product;if(i.some(a=>a.name===t))return t;let n=(N.get(this.product.handle)??[]).indexOf(t);return i[n]?.name??t}get purchase(){return this.purchaseChoice.kind}set purchase(t){let i=t==="subscription"?"subscription":"one-time";this.purchaseChoice=C(this.product,this.variant,{kind:i,planId:this.planId})}get planId(){return this.purchaseChoice.planId}set planId(t){this.purchaseChoice=C(this.product,this.variant,{kind:this.purchase,planId:t})}get plan(){return this.plans.find(t=>t.id===this.planId)??null}get subscriptionAvailable(){return this.plans.some(t=>P(this.variant,t.id))}get isSubscription(){return this.purchase==="subscription"&&P(this.variant,this.planId)!==null}getLine(){if(!this.variant)return null;let t={merchandiseId:this.variant.id,quantity:this.quantity};this.isSubscription&&this.planId&&(t.sellingPlanId=this.planId);let i=this.collectAttributes();return i.length&&(t.attributes=i),t}collectAttributes(){let t=H(this.root,"line-attributes"),i=Q(t),n=this.$(o("line-attribute")).flatMap(a=>{let s=Mt(a);return s===null?[]:[{key:l(a,"line-attribute")??"",value:s}]});return[...i,...n]}select(t,i){if(this.selected[t]===i)return;let n=this.product.variants.nodes.filter(r=>r.selectedOptions.some(c=>c.name===t&&c.value===i)),[a]=n;if(!a)return;let s={...this.selected,[t]:i};if(!n.some(r=>r.selectedOptions.every(c=>s[c.name]===c.value))){let r=u=>u.selectedOptions.filter(v=>v.name!==t&&this.selected[v.name]===v.value).length*2+(u.availableForSale?1:0),c=n.reduce((u,h)=>r(h)>r(u)?h:u,a);Object.assign(s,S(c))}this.selected=s,this.renderVariant()}selectVariant(t){let i=this.product.variants.nodes.find(n=>n.id===W.variant(t));i&&(this.selected=S(i),this.renderVariant())}setPurchase(t){let i=t==="subscription"?"subscription":"one-time",n=C(this.product,this.variant,{kind:i,planId:this.planId});n.kind!==this.purchase&&(this.purchaseChoice=n,this.renderVariant())}selectPlan(t){let i=X(this.product,t);i&&(this.purchaseChoice={kind:"subscription",planId:i.id},this.renderVariant())}setQuantity(t){let i=I(this.root,"quantity")?0:1;this.quantity=Math.max(i,parseInt(String(t),10)||0),this.$(o("qty")).forEach(n=>{d(n,this.quantity)}),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let t=this.getLine();if(!t||t.quantity<1)return null;let i=await Y.add(t);return g("product-added",{product:this.product,variant:this.variant,line:t},this.root),i}renderProduct(){let{product:t}=this;N.has(t.handle)||this.$(`${o("option-list")},select${o("option")}`).map(n=>l(n,"option-list")||l(n,"option")).some(n=>t.options.some(a=>a.name===n))&&Ot([t]),nt(this)}renderVariant(){let t=z(this.product,{selected:this.selected,purchase:this.purchaseChoice,quantity:this.quantity},w.lowStock);if(!t){this.variant=null;return}this.variant=t.variant,this.selected=t.selected,this.purchaseChoice=t.purchase,st(this,t),g("variant-changed",{product:this.product,variant:t.variant,selected:{...t.selected},purchase:t.purchase.kind,sellingPlanId:t.isSubscription?t.purchase.planId:null},this.root)}};export{$t as a,Ot as b,ut as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{L as p,r as c,s as i,t as a,w as l}from"./chunk-YJLWX2HK.js";var m="url:";function w(e){try{return decodeURIComponent(e)}catch(t){if(t instanceof URIError)return e;throw t}}function b(e,t=window.location,d="product"){let r=(a(e,d)??"").trim();if(!r.toLowerCase().startsWith(m))return{key:r||null,fromUrl:!1,raw:r};let n=r.slice(m.length).trim(),o;if(n.toLowerCase()==="path"){let s=t.pathname.split("/").filter(Boolean),f=s[s.length-1];o=f===void 0?null:w(f)}else o=new URLSearchParams(t.search).get(n||"handle");return{key:o?.trim()||null,fromUrl:!0,raw:r}}var y=["loading","ready","error","not-found"],S=e=>y.some(t=>t===e),h=e=>typeof e=="object"&&e!==null&&"code"in e?e.code:void 0,x=e=>h(e)==="NOT_FOUND",u=()=>["product","collection","products","recommendations"].map(e=>i(e)).join(","),E=(e,t)=>e===t||e.parentElement?.closest(u())===t;function U(e){let t=h(e);return typeof t=="string"&&t?t:"error"}function A(e,t,d){let r=t==="not-found",n=t==="error"||r;e.setAttribute(c("state"),r?"error":t),n?e.setAttribute(c("error"),r?"not-found":U(d)):e.removeAttribute(c("error")),l(e,i("show"),u()).forEach(o=>{let s=a(o,"show");S(s)&&p(o,s===t)}),n&&l(e,i("add-to-cart"),u()).forEach(o=>{o.classList.add("is-disabled"),o.setAttribute("aria-disabled","true"),"disabled"in o&&(o.disabled=!0)})}export{b as a,y as b,x as c,u as d,E as e,A as f};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var o=Object.defineProperty;var c=(t,r)=>{for(var e in r)o(t,e,{get:r[e],enumerable:!0})};var i={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function p(t){if(typeof t!="string")return!1;try{return new URL(t).protocol==="https:"}catch{return!1}}function s(t){return/^shp[a-z]{2}_/.test(t.trim())}function f(t,r){if(!t)return"";let e=parseFloat(t.amount);if(Number.isNaN(e))return"";try{return new Intl.NumberFormat(r||void 0,{style:"currency",currency:t.currencyCode}).format(e)}catch{return`${t.currencyCode} ${e.toFixed(2)}`}}function O(t,r,e){if(!/\{(handle|id)\}/.test(t))return`${t.replace(/\/$/,"")}/${r??String(r)}`;let n=e?e.split("/").pop()??"":"";return t.replace(/\{handle\}/g,encodeURIComponent(r??"")).replace(/\{id\}/g,encodeURIComponent(n))}function S(t){let r=String(t??"").trim();return r?r.startsWith("gid://")?r:/^\d+$/.test(r)?`gid://shopify/Product/${r}`:/\/products\/([^/?#]+)/.exec(r)?.[1]??r:null}export{c as a,i as b,p as c,s as d,f as e,O as f,S as g};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as h,C as x,G as d,J as I,L as T,b as u,s as a,t as c,v as s}from"./chunk-YJLWX2HK.js";import{c as g}from"./chunk-FOMSMIAM.js";function U(t,e,o){s(t,a(e)).forEach(r=>{let n=c(r,e)??"";Object.hasOwn(o,n)&&T(r,o[n]===!0)})}var w=(t,e)=>s(t,a(e)).concat(t.matches(a(e))?[t]:[]),C=t=>t?t.toLowerCase().replace(/_/g," "):"",D=t=>(t?.formatted??[]).join(", "),y=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0;function j(t){try{return new Date(t).toLocaleDateString(u.locale)}catch(e){if(e instanceof RangeError)return t;throw e}}function k(t){let e=u.account?.orderUrl;if(e){let o=t.id.split("/").pop()?.split("?")[0]??"";return e.replace("{id}",encodeURIComponent(o))}return g(t.statusPageUrl)?t.statusPageUrl??null:null}var b=(t,e)=>({title:t.title||t.name,"variant-title":t.variantTitle||"",quantity:String(t.quantity),price:d(t.price),total:d(t.totalPrice),sku:t.sku||"",returnable:e===null?void 0:String(e)}),q=t=>t.tagName==="INPUT";function O(t,e,o){U(t,"order-line-show",{returnable:o>0}),s(t,a("return-quantity")).forEach(r=>{q(r)&&(r.max=String(o),r.min="0",r.value||(r.value="0"),r.disabled=o<1)}),s(t,`select${a("return-reason")}`).forEach(r=>{r.dataset.tetherFilled!==e.id&&(r.dataset.tetherFilled=e.id,(e.suggestedReturnReasonDefinitions?.nodes??[]).forEach(n=>{r.appendChild(new Option(n.name,n.id))}))})}function V(t,e,o){x(t,e,(r,n)=>{let i=n.id,f=o&&i?o.get(i)??0:null;i&&(r.dataset.tetherLine=i);let E=b(n,f);w(r,"order-line").forEach(l=>{let m=c(l,"order-line")??"";if(m==="image"){n.image&&h(l,n.image.url,n.image.altText||n.title);return}let p=y(E,m);p!==void 0&&I(l,p)}),i&&f!==null&&O(r,{...n,id:i},f)})}export{j as a,k as b,U as c,w as d,C as e,D as f,y as g,V as h};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as f,e as y,f as m,g as b,h as x,i as v,j as A,k}from"./chunk-JOOEXYF3.js";var S=100,j=100,h=n=>Math.round(parseFloat(n.amount)*S),P=(n,e)=>({amount:(n/S).toFixed(2),currencyCode:e}),C=(n,e)=>P(h(n)*e,n.currencyCode),F=n=>Object.fromEntries(n.selectedOptions.map(e=>[e.name,e.value]));function M(n,e){return n.variants.nodes.find(s=>s.selectedOptions.every(i=>e[i.name]===i.value))??null}function T(n,e,s,i){return n.variants.nodes.some(t=>t.availableForSale&&t.selectedOptions.every(a=>a.name===s?a.value===i:e[a.name]===a.value))}function I(n,e,s){let i=y(n),t=i.find(o=>o.id===s.planId)??i[0];if(!t)return{kind:"one-time",planId:null};let a=m(e,t.id)?t:i.find(o=>m(e,o.id))??t;return n.requiresSellingPlan||s.kind==="subscription"?{kind:"subscription",planId:a.id}:{kind:"one-time",planId:a.id}}function N(n,{variant:e,sellingPlan:s,defaultPlan:i,defaultPurchase:t}){let a=n.variants.nodes,o=f.variant(e),c=a.find(l=>l.id===o)??a.find(l=>l.availableForSale)??a[0]??null,r=k(n,s),p=r??k(n,i),u=r||t==="subscription"?"subscription":"one-time";return{selected:c?F(c):{},purchase:I(n,c,{kind:u,planId:p?.id??null})}}function O(n,e,s,i,t){let a=n.quantityAvailable,o=a!=null&&a>0&&a<=e,c=i.compareAtPrice!==null;return{"in-stock":n.availableForSale,"out-of-stock":!n.availableForSale,backorder:n.availableForSale&&n.currentlyNotInStock,"on-sale":c,"not-on-sale":!c,"has-variants":s>1,"single-variant":s===1,"low-stock":o,"plenty-in-stock":n.availableForSale&&!o,"subscription-available":i.subscriptionAvailable,"subscription-unavailable":!i.subscriptionAvailable,"subscription-only":t,"one-time-available":!t,"subscription-selected":i.isSubscription,"one-time-selected":!i.isSubscription,"has-savings":i.isSubscription?i.savings.percentage>0:c}}function U(n,e,s){let i=M(n,e.selected),t=i??n.variants.nodes[0];if(!t)return null;let a=I(n,t,e.purchase),{planId:o}=a,c=y(n),r=a.kind==="subscription"?m(t,o):null,p=r?b(t,o)??t.price:t.price,u=r?.priceAdjustments[0]?.compareAtPrice??t.compareAtPrice,l={isSubscription:r!==null,subscriptionAvailable:c.some(d=>m(t,d.id)),compareAtPrice:u&&parseFloat(u.amount)>parseFloat(p.amount)?u:null,savings:v(t,o)};return{...l,variant:t,selected:i?e.selected:F(t),purchase:a,plan:c.find(d=>d.id===o)??null,quantity:e.quantity,price:p,show:O(t,s,n.variants.nodes.length,l,n.requiresSellingPlan)}}function w(n,e){let{variant:s,plan:i,price:t,compareAtPrice:a,quantity:o}=n,c=n.purchase.planId,r=g=>C(g,Math.max(1,o)),d={price:()=>e.money(t),"total-price":()=>e.money(r(t)),"one-time-price":()=>e.money(s.price),"subscription-price":()=>e.money(c?b(s,c):null),"subscription-savings":()=>e.percent(n.savings.percentage),"subscription-savings-amount":()=>e.money(n.savings.amount),"checkout-charge":()=>{let g=n.isSubscription?x(s,c)??t:t;return e.money(r(g))},"plan-name":()=>i?.name,"plan-description":()=>i?.description,"plan-group":()=>i?.group.name,"compare-at-price":()=>e.money(a),"unit-price":()=>e.money(s.unitPrice),"discount-percentage":()=>a?`${Math.round((1-parseFloat(t.amount)/parseFloat(a.amount))*j)}%`:"0%","discount-amount":()=>a?e.money(P(h(a)-h(t),t.currencyCode)):"","variant-title":()=>s.title,"variant-id":()=>s.id,sku:()=>s.sku,barcode:()=>s.barcode,stock:()=>s.quantityAvailable,quantity:()=>o};return new Map(Object.entries(d))}function E(n,e,s,i){let a={name:()=>s?.name,option:()=>(s?.options??[]).map(o=>o.value).join(", "),description:()=>s?.description,price:()=>i.money(b(n,e)),savings:()=>i.percent(v(n,e).percentage),"savings-amount":()=>i.money(v(n,e).amount),adjustment:()=>{let o=A(s);return o?o.type==="percentage"?`${o.value}%`:i.money(o.value):""}};return new Map(Object.entries(a))}export{F as a,T as b,I as c,N as d,U as e,w as f,E as g};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{b as d,c as m}from"./chunk-YJLWX2HK.js";import{a as f}from"./chunk-FOMSMIAM.js";var v={};f(v,{GID:()=>p,allPlans:()=>u,allocationFor:()=>c,findPlan:()=>x,hasPlans:()=>$,planAdjustment:()=>F,planCheckoutCharge:()=>h,planPrice:()=>g,planSavings:()=>y,plansForVariant:()=>A,toGid:()=>s});function s(e,i){let t=typeof e=="string"||typeof e=="number"?String(e).trim():"";return t?t.startsWith("gid://")?t:/^\d+$/.test(t)?`gid://shopify/${i}/${t}`:t:null}var p={product:e=>s(e,"Product"),variant:e=>s(e,"ProductVariant"),sellingPlan:e=>s(e,"SellingPlan")};function u(e){return(e?.sellingPlanGroups?.nodes??[]).flatMap(t=>t.sellingPlans.nodes.map(r=>({...r,group:t})))}function $(e){return u(e).length>0}function c(e,i){return!e||!i?null:(e.sellingPlanAllocations?.nodes??[]).find(r=>r.sellingPlan.id===i)??null}function A(e,i){return u(e).filter(t=>c(i,t.id))}function g(e,i){let t=c(e,i)?.priceAdjustments[0];return t?.perDeliveryPrice??t?.price??e?.price??null}function h(e,i){let t=c(e,i);return t?.checkoutChargeAmount??t?.priceAdjustments[0]?.price??e?.price??null}function y(e,i){let t=parseFloat(e?.price.amount??""),r=parseFloat(g(e,i)?.amount??"");return!e||!Number.isFinite(t)||!Number.isFinite(r)||t<=0||r>=t?{amount:null,percentage:0}:{amount:{amount:(t-r).toFixed(2),currencyCode:e.price.currencyCode},percentage:Math.round((1-r/t)*100)}}function F(e){let i=e?.priceAdjustments[0]?.adjustmentValue;if(!i)return null;switch(i.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:i.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:i.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:i.price};default:return null}}function x(e,i){if(!i)return null;let t=u(e),r=p.sellingPlan(i),o=i.trim().toLowerCase();return t.find(l=>l.id===r)??t.find(l=>l.name.toLowerCase()===o)??t.find(l=>l.options.some(P=>P.value.toLowerCase()===o))??null}var n="amount currencyCode",a="url altText width height";function C(e){let i=[];for(let r of e){let o=m(r);o&&i.push(o)}return i.length?`metafields(identifiers:[${i.map(({namespace:r,key:o})=>`{namespace: ${JSON.stringify(r)}, key: ${JSON.stringify(o)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${a}}}}}`:""}var j=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${n}}}... on SellingPlanFixedPriceAdjustment{price{${n}}}}}`,S=` sellingPlan{id}checkoutChargeAmount{${n}}remainingBalanceChargeAmount{${n}}priceAdjustments{price{${n}}compareAtPrice{${n}}perDeliveryPrice{${n}}unitPrice{${n}}}`;function k(e=d){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${a}}images(first:${e.imagesFirst}){nodes{${a}}}options{name optionValues{name swatch{color image{previewImage{${a}}}}}}priceRange{minVariantPrice{${n}}maxVariantPrice{${n}}}compareAtPriceRange{minVariantPrice{${n}}maxVariantPrice{${n}}}${C(e.metafields)} sellingPlanGroups(first:${e.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${e.sellingPlansFirst}){nodes{${j}}}}}variants(first:${e.variantsFirst}){nodes{id title availableForSale currentlyNotInStock quantityAvailable sku barcode selectedOptions{name value}image{${a}}price{${n}}compareAtPrice{${n}}unitPrice{${n}}sellingPlanAllocations(first:${e.sellingPlansFirst}){nodes{${S}}}}}}`}function I(){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${n}}totalAmount{${n}}checkoutChargeAmount{${n}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${n}}subtotalAmount{${n}}amountPerQuantity{${n}}compareAtAmountPerQuantity{${n}}}discountAllocations{discountedAmount{${n}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${n}}priceAdjustments{price{${n}}compareAtPrice{${n}}perDeliveryPrice{${n}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping quantityAvailable image{${a}}price{${n}}compareAtPrice{${n}}selectedOptions{name value}product{id title handle vendor featuredImage{${a}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function L(){return`
|
|
2
|
-
id handle title description descriptionHtml
|
|
3
|
-
image { ${a} }
|
|
4
|
-
seo { title description }`}export{k as a,I as b,L as c,p as d,u as e,c as f,g,h,y as i,F as j,x as k,v as l};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as pt}from"./chunk-NEHZ37TU.js";import{b as H,d as O,e as ft}from"./chunk-JOOEXYF3.js";import{A as st,C as ct,D as ut,E as lt,G as L,J as V,K as v,L as _,N as dt,R as S,b as i,g as ot,i as C,l as w,p as Q,q as at,r as F,s as c,t as k,v as u,x as g}from"./chunk-YJLWX2HK.js";import{c as it}from"./chunk-FOMSMIAM.js";var Nt='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Mt=60,X=!1,K=null,Wt=t=>t!==null&&"focus"in t,mt=t=>u(t,Nt).filter(e=>e.offsetParent!==null||e===document.activeElement),I=()=>u(document,c("cart-drawer")),Y=t=>t.classList.contains(i.cartDrawerOpenClass);function h(){let t=I();return t.length?t.some(Y):X}function j(t){u(document,c("cart-open")).forEach(e=>{e.setAttribute("aria-expanded",String(t))}),I().forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",k(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),!Y(e)&&(e.setAttribute("aria-hidden","true"),i.cartFocus&&(e.inert=!0))})}function Gt(t){let e=mt(t)[0]??t;e===t&&!t.hasAttribute("tabindex")&&(t.tabIndex=-1),e.focus({preventScroll:!0})}function B(){if(h())return;X=!0;let t=I().filter(n=>k(n,"cart-drawer")!=="manual");t.forEach(n=>{n.inert=!1,n.classList.add(i.cartDrawerOpenClass),n.setAttribute("aria-hidden","false")}),j(!0);let[e]=t;i.cartFocus&&e&&(K=Wt(document.activeElement)?document.activeElement:null,setTimeout(()=>{Gt(e)},Mt)),i.onCartOpen?.(t),g("cart-toggled",{open:!0})}function z(){if(!h())return;X=!1;let t=I(),e=t.some(n=>n.contains(document.activeElement));t.forEach(n=>{n.classList.remove(i.cartDrawerOpenClass),n.setAttribute("aria-hidden","true"),i.cartFocus&&(n.inert=!0)}),j(!1),e&&K?.isConnected&&K.focus({preventScroll:!0}),K=null,i.onCartClose?.(t),g("cart-toggled",{open:!1})}function gt(){h()?z():B()}function Rt(t){if(t.key!=="Tab"||!i.cartFocus||!h())return;let e=I().find(Y);if(!e)return;let n=mt(e),r=n[0],o=n.at(-1);if(!r||!o)return;let a=document.activeElement,s=t.shiftKey?a===r:a===o;e.contains(a)&&!s||(t.preventDefault(),(t.shiftKey?o:r).focus())}var Vt=/^(-?)(\d+)(?:\.(\d+))?$/;function ht(t,e){let n=Vt.exec(t.trim());if(!n)return null;let[,r="",o="0",a=""]=n,s=BigInt(`${o}${a.padEnd(e,"0")}`);return r==="-"?-s:s}var yt=t=>t.split(".")[1]?.length??0;function bt(t,e){if(t==null||e==null)return!1;let n=Math.max(yt(t.trim()),yt(e.trim())),r=ht(t,n),o=ht(e,n);return r===null||o===null?!1:r>o}var Ct="Default Title",J=(t,e)=>e.get(t.id)?.quantity??t.quantity,wt=t=>t.split("/").pop()??t;function Ht(t){let e=t.merchandise,n=lt(e.product.handle,e.product.id),r=new URLSearchParams;r.set("variant",wt(e.id));let o=t.sellingPlanAllocation?.sellingPlan.id;return o&&r.set("selling_plan",wt(o)),`${n}${n.includes("?")?"&":"?"}${r.toString()}`}var kt=t=>t.merchandise.product.title,vt={title:kt,"product-title":kt,"variant-title":t=>t.merchandise.title===Ct?"":t.merchandise.title,options:t=>t.merchandise.selectedOptions.filter(e=>e.value!==Ct).map(e=>`${e.name}: ${e.value}`).join(", "),vendor:t=>t.merchandise.product.vendor,sku:t=>t.merchandise.sku??"",price:t=>L(t.cost.amountPerQuantity),"compare-at-price":t=>L(t.cost.compareAtAmountPerQuantity??t.merchandise.compareAtPrice),"line-total":t=>L(t.cost.totalAmount),"line-subtotal":t=>L(t.cost.subtotalAmount),quantity:(t,e)=>J(t,e.pending),plan:t=>t.sellingPlanAllocation?.sellingPlan.name??"","plan-description":t=>t.sellingPlanAllocation?.sellingPlan.description??"",components:t=>(t.lineComponents??[]).map(e=>`${e.quantity} \xD7 ${e.merchandise.product.title}`).join(", ")},At="attribute:";function Xt(t,e,n){if(Object.hasOwn(vt,e))return vt[e]?.(t,n);if(!e.startsWith(At))return;let r=e.slice(At.length);return t.attributes.find(o=>o.key===r)?.value??""}function Yt(t,e,n){let r=ft(n),o=!n.requiresSellingPlan&&k(t,"line-plan")!=="subscription-only",a={value:"",label:t.getAttribute(F("one-time-label"))||"One-time purchase"},s=[...o?[a]:[],...r.map(d=>({value:d.id,label:d.name}))],f=s.map(d=>d.value).join("|");t.dataset.tetherSig!==f&&(t.replaceChildren(...s.map(d=>{let T=document.createElement("option");return T.value=d.value,T.textContent=d.label,T})),t.dataset.tetherSig=f),t.value=e.sellingPlanAllocation?.sellingPlan.id??"",_(t,r.length>0)}function zt(t,e,n){let r=!!e.sellingPlanAllocation;t.classList.toggle("is-subscription",r);let o=n.warnings.find(f=>f.target===e.id);t.classList.toggle("is-warning",!!o);let a=n.pending.has(e.id);t.classList.toggle("is-busy",a),a?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),u(t,c("line","warning")).forEach(f=>{v(f,o?.message??"")});let s={subscription:r,"one-time":!r,"on-sale":bt(e.cost.compareAtAmountPerQuantity?.amount,e.cost.amountPerQuantity.amount),"has-components":(e.lineComponents??[]).length>0,warning:!!o};u(t,c("line-show")).forEach(f=>{let d=k(f,"line-show");d!==null&&Object.hasOwn(s,d)&&_(f,s[d])})}function Jt(t,e,n){let r=e.merchandise;t.setAttribute(F("line-id"),e.id),u(t,c("line")).forEach(o=>{let a=k(o,"line")??"";if(a==="image"){st(o,r.image?.url??r.product.featuredImage?.url,r.product.title);return}if(a==="url"){o.setAttribute("href",Ht(e));return}let s=Xt(e,a,n);s!==void 0&&v(o,s)}),zt(t,e,n),u(t,`select${c("line-plan")}`).forEach(o=>{pt(r.product.handle).then(a=>{Yt(o,e,a)}).catch(a=>{C(a,"line plan options")})})}function Zt(t,e){let n=t?.totalQuantity??0,r=(t?.lines.nodes??[]).some(a=>a.sellingPlanAllocation),o={"cart-empty":n===0,"cart-filled":n>0,"cart-has-subscription":r,"cart-no-subscription":!r,"cart-has-discount":(t?.discountCodes??[]).some(a=>a.applicable),"cart-error":e.failed,"cart-warning":e.warnings.length>0};u(document,c("show")).forEach(a=>{let s=k(a,"show");s===null||!Object.hasOwn(o,s)||a.closest(c("product"))||_(a,o[s])}),u(document,c("checkout")).forEach(a=>{a.classList.toggle("is-disabled",!n),a.setAttribute("aria-disabled",String(!n))})}function te(t){u(document,`textarea${c("cart-note")},input${c("cart-note")}`).forEach(e=>{document.activeElement!==e&&V(e,t?.note??"")}),u(document,c("cart-discounts")).forEach(e=>{ct(e,t?.discountCodes??[],(n,r)=>{n.setAttribute(F("discount-code"),r.code);let o=n.querySelector(c("discount","code"))??(n.firstElementChild?null:n);o&&V(o,r.code),n.classList.toggle("is-inapplicable",!r.applicable)})})}function It(t){let{cart:e}=t,n=r=>e?L(e.cost[r]):"";j(h()),u(document,c("cart-count")).forEach(r=>{v(r,e?.totalQuantity??0)}),u(document,c("cart-subtotal")).forEach(r=>{v(r,n("subtotalAmount"))}),u(document,c("cart-total")).forEach(r=>{v(r,n("totalAmount"))}),u(document,c("cart-checkout-charge")).forEach(r=>{v(r,n("checkoutChargeAmount"))}),Zt(e,t),u(document,c("cart-warning")).forEach(r=>{v(r,[...new Set(t.warnings.map(o=>o.message))].join(" "))}),te(e),u(document,c("cart-lines")).forEach(r=>{ut(r,e?.lines.nodes??[],o=>o.id,(o,a)=>{Jt(o,a,t)},{onEnter:i.onLineEnter,onLeave:i.onLineLeave})}),e&&dt("cart")}function xt(t){u(document,c("cart-count")).forEach(e=>{/^\s*0?\s*$/.test(e.textContent)&&(e.textContent=t)})}var m={kind:"unknown"},$=[],x=new Map,p={accessToken:null,beforeCheckout:null},N=()=>m;function l(){switch(m.kind){case"ready":case"error":return m.cart;case"unknown":case"empty":return null}}var Lt=()=>$,M=t=>t?{kind:"ready",cart:t}:{kind:"empty"},$t=()=>`${i.storageKey}:seen`;function Tt(t){try{return localStorage.getItem(t)}catch{return null}}function Z(t,e){try{e===null?localStorage.removeItem(t):localStorage.setItem(t,e)}catch{}}var E=()=>Tt(i.storageKey)||null;function q(){Z(i.storageKey,null)}function tt(t){m=M(t),t&&Z(i.storageKey,t.id)}function P(){It({cart:l(),warnings:$,pending:x,failed:m.kind==="error"})}function D(t){P(),g("cart-updated",{cart:l(),reason:t})}function y(t,e){return tt(t),Z($t(),`${Date.now()}|${t?.totalQuantity??0}`),D(e),t}function W(t){m=t.kind==="loaded"?M(t.cart):{kind:"error",error:t.error,cart:null},D("load")}function St(t){let e=l();m=t==null?M(e):{kind:"error",error:t,cart:e}}function Ot(){if(m.kind!=="unknown")return;let t=Tt($t())?.split("|")[1];t&&xt(t)}function Pt(t){$=t.filter((e,n)=>t.findIndex(r=>r.message===e.message)===n).map(e=>({...e,message:i.warningText?.(e)||e.message})),$.length&&g("cart-warning",{warnings:$})}var Et=()=>{};function ee(){let t=Promise.resolve();return e=>{let n=t.then(e);return t=n.then(Et,Et),n}}var ne=ee();function b(t){return ne(t).then(e=>(m.kind==="error"&&(m=M(m.cart),P()),e),e=>{throw m={kind:"error",error:e,cart:l()},P(),g("cart-error",{error:e}),e})}var et=t=>J(t,x),re=()=>({open:h(),count:l()?.totalQuantity??0,loaded:m.kind!=="unknown",warnings:$});function qt(t){let e=["cart-updated","cart-toggled"].map(r=>`${i.prefix}:${r}`),n=()=>{t(l(),re())};return e.forEach(r=>{document.addEventListener(r,n)}),n(),()=>{e.forEach(r=>{document.removeEventListener(r,n)})}}var oe=/does not exist|not found|invalid id/i;function G(t){return t instanceof w?t.userErrors?.some(e=>e.field?.[0]==="cartId")?!0:(t.errors??[]).some(e=>oe.test(e.message)):!1}function Ut(t,e=1,n={}){let r=typeof t=="object"&&t!==null?t:{...n,variantId:t,quantity:e},o=O.variant(r.merchandiseId||r.variantId||r.id);if(!o)throw new w("add(): variantId is required");let a=parseInt(String(r.quantity??1),10),s={merchandiseId:o,quantity:Math.max(1,a||1)},f=O.sellingPlan(r.sellingPlanId||r.sellingPlan);f&&(s.sellingPlanId=f);let d=S(r.attributes);return d.length&&(s.attributes=d),s}function ae(t,e,n){return`mutation Tether_${t}(${e}){${t}(${n}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${H()}`}async function Qt(t,e,n,r){let o=await Q(ae(t,e,n),r),a=at(o[t],t);return Pt(a.warnings??[]),a.cart}function Dt(t){let e={...i.country?{countryCode:i.country.toUpperCase()}:{},...p.accessToken?{customerAccessToken:p.accessToken}:{}},n=Object.keys(e).length?{buyerIdentity:e,...t}:t;return Qt("cartCreate","$input: CartInput!","input: $input",{input:n})}async function A({name:t,args:e,inner:n,variables:r,createInput:o}){let a=E();if(!a)return o?Dt(o):null;try{return await Qt(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${n}`,{...r,cartId:a})}catch(s){if(!G(s)||(q(),!o))throw s;return ot("cart expired, creating a new one"),Dt(o)}}async function Ft(t){return(await Q(`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${H()}`,{id:t})).cart}async function _t(t){return(await Q("query TetherCheckout($id: ID!) { cart(id: $id) { checkoutUrl } }",{id:t})).cart?.checkoutUrl??null}function Kt(t,e){let n=typeof e=="number"?{quantity:e}:e,r={id:t};n.quantity!==void 0&&(r.quantity=n.quantity),"sellingPlanId"in n&&(r.sellingPlanId=n.sellingPlanId?O.sellingPlan(n.sellingPlanId):null),n.attributes&&(r.attributes=S(n.attributes));let o=n.merchandiseId||n.variantId;return o&&(r.merchandiseId=O.variant(o)),r}var nt=t=>A({name:"cartLinesUpdate",args:"$lines: [CartLineUpdateInput!]!",inner:"lines: $lines",variables:{lines:t},createInput:null}),rt=t=>A({name:"cartLinesRemove",args:"$lineIds: [ID!]!",inner:"lineIds: $lineIds",variables:{lineIds:t},createInput:null}),jt=(t,e)=>e>0?nt([{id:t,quantity:e}]):rt([t]);var ie=t=>_t(t).then(e=>({kind:"url",url:e}),e=>({kind:"failed",error:e}));async function se(){if(!p.beforeCheckout)return null;try{return await p.beforeCheckout()}catch(t){return C(t,"account checkout"),null}}async function ce(t){let e=ie(t),n=await se();if(!n){let r=await e;if(r.kind==="failed")throw r.error;n=r.url}if(!n)throw new w("No checkoutUrl (cart empty or expired)");return p.accessToken?`${n}${n.includes("?")?"&":"?"}logged_in=true`:n}function ue(t){try{t.opener=null}catch{}}async function Bt(t=i.checkoutTarget){let e=E(),n=l();if(!e||n&&!n.totalQuantity)return null;let r=t==="_blank"?window.open("","_blank"):null;r&&ue(r);try{let o=await ce(e);if(!it(o))throw new w("The checkout URL is not https: not opened");return g("checkout",{url:o,cart:l()}),r&&!r.closed?r.location.href=o:window.location.href=o,o}catch(o){return r?.close(),C(o,"checkout failed"),null}}var R=()=>l()?.lines.nodes??[];function le(t,e){let n=R().find(f=>f.id===t);if(!n)return Promise.resolve(l());let r=Math.max(0,et(n)+e),o={quantity:r};x.set(t,o),D("pending");let a=()=>x.get(t)===o;return b(async()=>{if(!a())return l();if(R().find(T=>T.id===t)?.quantity===r)return l();let d=await jt(t,r);return a()?y(d,r>0?"update":"remove"):(tt(d),d)}).finally(()=>{a()&&(x.delete(t),D("settled"))})}function de(t){let e=(l()?.discountCodes??[]).map(r=>r.code),n=typeof t=="function"?t(e):t;return(Array.isArray(n)?n:[n]).map(r=>r.trim()).filter(Boolean)}function fe(t){let e=new Map((l()?.attributes??[]).map(n=>[n.key,n.value]));return S(t).forEach(n=>e.set(n.key,n.value)),[...e].filter(([,n])=>n!=="").map(([n,r])=>({key:n,value:r}))}async function pe(){let t=E();if(!t)return W({kind:"loaded",cart:null}),null;Ot();try{let e=await Ft(t);e||q(),W({kind:"loaded",cart:e})}catch(e){C(e,"cart load failed"),G(e)&&q(),W({kind:"failed",error:e})}return l()}var U={init:pe,id:E,get status(){return N()},get state(){return l()},get lines(){return R()},get count(){return l()?.totalQuantity??0},get loaded(){return N().kind!=="unknown"},get lastError(){let t=N();return t.kind==="error"?t.error:null},set lastError(t){St(t)},get warnings(){return Lt()},get pendingQty(){return x},get customerAccessToken(){return p.accessToken},set customerAccessToken(t){p.accessToken=t||null},get beforeCheckout(){return p.beforeCheckout},set beforeCheckout(t){p.beforeCheckout=typeof t=="function"?t:null},setCustomer(t){t.accessToken!==void 0&&(p.accessToken=t.accessToken),t.beforeCheckout!==void 0&&(p.beforeCheckout=t.beforeCheckout)},_commit:y,render:P,subscribe:qt,add(t,e=1,n={}){let r=(Array.isArray(t)?t:[t]).map(o=>Ut(o,e,n));return b(async()=>{let o=await A({name:"cartLinesAdd",args:"$lines: [CartLineInput!]!",inner:"lines: $lines",variables:{lines:r},createInput:{lines:r}});return y(o,"add"),g("added",{cart:o,lines:r}),i.openCartOnAdd&&B(),o})},updateLine(t,e){let n=typeof e=="number"?e:e.quantity;if(n!==void 0&&n<=0)return U.removeLine(t);let r=Kt(t,e);return b(async()=>y(await nt([r]),"update"))},changeQuantity:le,quantityOf:et,removeLine(t){let e=Array.isArray(t)?t:[t];return b(async()=>y(await rt(e),"remove"))},clear(){let t=R().map(e=>e.id);return t.length?U.removeLine(t):Promise.resolve(l())},setNote(t){let e={note:t??""};return b(async()=>y(await A({name:"cartNoteUpdate",args:"$note: String!",inner:"note: $note",variables:e,createInput:e}),"note"))},setAttributes(t){return b(async()=>{let e={attributes:fe(t)},n=await A({name:"cartAttributesUpdate",args:"$attributes: [AttributeInput!]!",inner:"attributes: $attributes",variables:e,createInput:e});return y(n,"attributes")})},setDiscountCodes(t){return b(async()=>{let e={discountCodes:de(t)},n=await A({name:"cartDiscountCodesUpdate",args:"$discountCodes: [String!]!",inner:"discountCodes: $discountCodes",variables:e,createInput:e});return y(n,"discount")})},async applyDiscount(t){let e=await U.setDiscountCodes(o=>[...new Set([...o,t])]),n=t.toLowerCase();if((e?.discountCodes??[]).find(o=>o.code.toLowerCase()===n)?.applicable)return e;try{await U.removeDiscount(t)}catch(o){C(o,"removing a discount code Shopify refused")}throw new w(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let e=t.toLowerCase();return U.setDiscountCodes(n=>n.filter(r=>r.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return b(async()=>{let n=await A({name:"cartBuyerIdentityUpdate",args:"$buyerIdentity: CartBuyerIdentityInput!",inner:"buyerIdentity: $buyerIdentity",variables:{buyerIdentity:t},createInput:e?{buyerIdentity:t}:null}).catch(r=>{if(e||!G(r))throw r;return null});return y(n,"buyer-identity")})},checkout:Bt,drawers:I,isOpen:h,open:B,close:z,toggle:gt};export{Rt as a,U as b};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as y,c as q}from"./chunk-JOOEXYF3.js";import{b as I,g as T,l as g,p as h}from"./chunk-YJLWX2HK.js";import{g as E}from"./chunk-FOMSMIAM.js";var _=1e4,N=6e4,d=new Map,w=new Map,f=new Set,m=new Map,K=[],S=!1,p=0,C=t=>t.startsWith("gid://"),P=E;function $(t){if(!t)return;let e=Promise.resolve(t);d.set(t.handle,e),d.set(t.id,e)}function b(t){let e=P(t);if(!e)return Promise.reject(new g("empty product key",{code:"NOT_FOUND"}));let o=d.get(e);if(o)return o;let r=new Promise((i,s)=>{w.set(e,{resolve:i,reject:s}),K.push(e),S||(S=!0,setTimeout(()=>void F(),0))});return d.set(e,r),r}function x(t){let e=t.filter(C),o=t.filter(u=>!C(u)),r=[],i=[],s={};return e.length&&(r.push("$ids: [ID!]!"),s.ids=e,i.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),o.forEach((u,n)=>{r.push(`$h${n}: String!`),s[`h${n}`]=u,i.push(`h${n}: product(handle: $h${n}) { ...TetherProduct }`)}),{query:`query TetherProducts(${r.join(",")}){${i.join(" ")}}${y()}`,variables:s,handles:o}}function v(t,e){let o=w.get(t);w.delete(t),o&&e(o)}function D(t,e){if(e!==p)return;let o=d.get(t);setTimeout(()=>{d.get(t)===o&&d.delete(t)},_)}async function F(){S=!1;let t=p,e=K.splice(0);if(!e.length)return;let{query:o,variables:r,handles:i}=x(e);T("fetch products",e);let s;try{s=await h(o,r)}catch(n){e.forEach(a=>{v(a,c=>{t===p&&d.delete(a),c.reject(n)})});return}let l=new Map;for(let n of s.byId??[])n&&l.set(n.id,n);i.forEach((n,a)=>{let c=s[`h${a}`];c&&l.set(n,c)});let u=Date.now();e.forEach(n=>{v(n,a=>{let c=l.get(n);if(!c){D(n,t),a.reject(new g(`Product not found: ${n}`,{code:"NOT_FOUND"}));return}t===p&&($(c),m.set(c.handle,u),m.set(c.id,u)),a.resolve(c)})})}function L(){d.clear(),p+=1,f.clear(),m.clear()}function Q(t){for(let e of t??[])!e.id||!e.handle||Date.now()-(m.get(e.handle)??0)<N&&d.has(e.handle)||($(e),f.add(e.handle),f.add(e.id))}function W(t){let e=P(t);return!e||!f.has(e)?!1:(f.delete(e),d.get(e)?.then(o=>{f.delete(o.handle),f.delete(o.id)}),!0)}function z(t){for(let e of t){let o=P(e);o&&d.delete(o)}return t.map(e=>b(e))}var M=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${q()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,O="query TetherSearch($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}";async function B({collection:t,query:e,first:o=I.collectionFirst,after:r=null,sortKey:i,reverse:s=!1,filters:l}={}){let u=y();if(t){let a=await h(`${M}
|
|
2
|
-
${u}`,{handle:t,first:o,after:r,sortKey:i||void 0,reverse:s,filters:l??void 0});if(!a.collection)throw new g(`Collection not found: ${t}`,{code:"NOT_FOUND"});let{products:c,...R}=a.collection;return c.nodes.forEach($),{collection:R,products:c.nodes,pageInfo:c.pageInfo}}let n=await h(`${O}
|
|
3
|
-
${u}`,{first:o,after:r,query:e||void 0,sortKey:i||void 0,reverse:s});return n.products.nodes.forEach($),{collection:null,products:n.products.nodes,pageInfo:n.products.pageInfo}}async function G(t,e="RELATED"){let o=P(typeof t=="object"?t?.id:t),r=o?.startsWith("gid://")??!1,s=(await h(`query TetherRecs(${r?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${r?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}${y()}`,r?{id:o,intent:e}:{handle:o,intent:e})).productRecommendations??[];return s.forEach($),s}export{P as a,$ as b,b as c,L as d,Q as e,W as f,z as g,B as h,G as i};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as S,b as Y,c as _}from"./chunk-2FSXS55U.js";import{a as m,c as g,f}from"./chunk-FCSWQDVV.js";import{c as F,e as M,f as q,g as K,h as W,i as D}from"./chunk-NEHZ37TU.js";import{A as N,C as A,I as O,J as L,L as k,N as I,P as U,b as h,g as R,h as T,i as p,l as $,r as u,s as c,t as i,u as E,v,w as C,x as l}from"./chunk-YJLWX2HK.js";var B="url:",x=()=>`${c("collection")},${c("products")},${c("recommendations")}`,V=t=>t instanceof window.Element,H=t=>parseInt(t??"",10)||void 0,X=t=>t==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",J=class{constructor(e){this.root=e,this.products=[],this.pageInfo=null,this.collection=null,this.loadToken=0,f(e,"loading"),e.addEventListener("click",r=>{if(!V(r.target))return;let n=r.target.closest(c("load-more"));n?.closest(x())===e&&(r.preventDefault(),U(n,()=>this.load(!0)))})}$(e){return C(this.root,e,x())}options(){let{root:e}=this,r={reverse:i(e,"reverse")==="true"},n=H(i(e,"limit"));n&&(r.first=n);let o=i(e,"sort");if(o&&(r.sortKey=o),E(e,"collection"))return r.collection=i(e,"collection")??"",r;let s=i(e,"products")??"";return r.query=s.startsWith(B)?new URL(window.location.href).searchParams.get(s.slice(B.length))||"":s,r}async loadRecommendations(){let{key:e}=m(this.root,window.location,"recommendations"),r=this.root.closest(c("product"));if(!e&&r&&({key:e}=m(r)),!e)throw new $("No product for recommendations",{code:"NOT_FOUND"});return D(e,X(i(this.root,"intent")))}async load(e=!1){this.loadToken+=1;let r=this.loadToken,n=()=>r!==this.loadToken;try{if(E(this.root,"recommendations")){let o=await this.loadRecommendations();if(n())return;let s=H(i(this.root,"limit"));this.products=s?o.slice(0,s):o}else{let o=await W({...this.options(),after:e?this.pageInfo?.endCursor??null:null});if(n())return;this.collection=o.collection,this.pageInfo=o.pageInfo,this.products=e?[...this.products,...o.products]:o.products}this.render(),f(this.root,"ready"),l("list-ready",{products:this.products,collection:this.collection},this.root)}catch(o){if(n())return;e||f(this.root,g(o)?"not-found":"error",o),g(o)&&E(this.root,"recommendations")||p(o,"list load failed"),l("error",{error:o,context:"list"},this.root)}}render(){let{collection:e}=this;this.$(c("collection-bind")).forEach(n=>{switch(i(n,"collection-bind")??""){case"title":L(n,e?.title??"");break;case"description":O(n,e?.descriptionHtml);break;case"image":N(n,e?.image?.url,e?.image?.altText||e?.title);break;case"count":L(n,this.products.length);break}}),this.$(c("list")).forEach(n=>{A(n,this.products,(o,s)=>{o.setAttribute(u("product"),s.handle),o.removeAttribute(u("state"))}),l("list-rendered",{container:n},this.root)});let r=this.products.length===0;this.$(c("show")).forEach(n=>{let o=i(n,"show");o==="list-empty"&&k(n,r),o==="list-filled"&&k(n,!r)}),this.$(c("load-more")).forEach(n=>{k(n,!!this.pageInfo?.hasNextPage)}),I("list")}};var Z='script[type="application/json"][data-tether-hydrate]',P=new WeakSet,Pt=new WeakSet,y=new Set,j=new Set,z=new WeakMap;function tt(){y.forEach(t=>{t.isConnected||y.delete(t)}),j.forEach(t=>{t.root.isConnected||j.delete(t)})}function bt(t,e){return[...t.matches?.(e)?[t]:[],...v(t,e)]}function et(t,e){let r=i(t,"page-title");!r||typeof document>"u"||(document.title=r.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function ot(t,{fromUrl:e,raw:r}){e?(P.add(t),f(t,"not-found"),l("product-not-found",{key:null,source:r},t)):t.closest(x())||T(`[${u("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t)}function rt(t,e,{fromUrl:r,raw:n},o){let s=g(o);if(f(t,s?"not-found":"error",o),!s){p(o,`product ${e}`),l("error",{error:o,context:"product",key:e},t);return}l("product-not-found",{key:e,source:n},t),r?R(`product not found: ${e}`):p(o,`product ${e}`)}function nt(t){if(P.has(t))return!1;let{key:e,...r}=m(t);if(!e)return ot(t,r),!1;P.add(t),y.add(t);let n={};z.set(t,n);let o=()=>z.get(t)===n;return S.get(t)?t.setAttribute(u("state"),"updating"):f(t,"loading"),at(F(e)).then(d=>{if(!o())return;let w=S.get(t);w?w.update(d):new _(t,d),et(t,d),h.revalidate&&q(e)&&st(e)}).catch(d=>{o()&&rt(t,e,r,d)}),!0}function Rt(){tt(),y.forEach(t=>{t.getAttribute(u("state"))!=="error"||t.getAttribute(u("error"))==="not-found"||(P.delete(t),nt(t))})}var b=new Set;function st(t){b.size||setTimeout(ct,0),b.add(t)}function it(t,e){y.forEach(r=>{let n=S.get(r);if(!n||!r.isConnected)return;let o=m(r).key;o!==t&&o!==e.handle&&o!==e.id||JSON.stringify(n.product)!==JSON.stringify(e)&&n.update(e)})}function ct(){let t=[...b];b=new Set,K(t).forEach((e,r)=>{let n=t[r];e.then(o=>{it(n,o)}).catch(o=>{p(o,`refresh ${n}`)})})}var a=null,at=t=>(a?.add(t),t);function dt(){if(!a)return;let t=[...a];Promise.allSettled(t).then(()=>{if(!(!a||t.some(e=>!a?.has(e)))){if(t.length!==a.size){dt();return}a=null,document.documentElement.classList.remove(`${h.prefix}-market-pending`)}})}var ut=t=>!!(t?.id&&t.handle),Q=(t,e)=>(t??"").toUpperCase()===(e??"").toUpperCase(),G=new WeakSet;function Tt(t=document){v(t.ownerDocument??t,Z).forEach(e=>{if(G.has(e))return;G.add(e);let r;try{r=JSON.parse(e.textContent)}catch(w){T("bad data-tether-hydrate",w);return}let{country:n,language:o,products:s}=r??{},d=Array.isArray(s)?s.filter(ut):[];if(Y(d),Q(n,h.country)&&Q(o,h.language)){M(d);return}R("hydration skipped: other market"),a||(a=new Set,document.documentElement.classList.add(`${h.prefix}-market-pending`))})}export{x as a,J as b,P as c,Pt as d,y as e,j as f,tt as g,bt as h,nt as i,Rt as j,at as k,dt as l,Tt as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t={diagnose:()=>import("./diagnose-6VVGZNTY.js"),markets:()=>import("./markets-ui-UNB4PTA7.js"),search:()=>import("./search-OU75RNQL.js"),extras:()=>import("./extras-GJVRDFM3.js"),account:()=>import("./account-C3NP6HFB.js"),"account-pages":()=>import("./account-pages-WLK374FO.js"),analytics:()=>import("./analytics-G3SAWMNL.js")},r=o=>t[o](),a=void 0;export{r as a,a as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as U,f as R}from"./chunk-FOMSMIAM.js";var b={domain:"",token:"",apiVersion:"2026-07",country:void 0,language:void 0,locale:void 0,markets:null,prefix:"tether",productPath:"/product",collectionPath:"/collection",metafields:[],imagesFirst:25,variantsFirst:100,sellingPlanGroupsFirst:10,sellingPlansFirst:25,collectionFirst:24,retries:2,revalidate:!0,storageKey:"",cartDrawerOpenClass:"is-open",openCartOnAdd:!0,cartFocus:!0,checkoutTarget:"_self",defaultPurchase:"one-time",variantUrl:!1,maxAge:60,lowStock:5,searchDelay:150,autoMount:!0,observe:!1,astro:!0,partsUrl:null,analytics:null,account:null,warningText:null,formatMoney:null,onLayoutChange:null,onCartOpen:null,onCartClose:null,onLineEnter:null,onLineLeave:null,onValueChange:null,onError:null,debug:!1},i={...b},rt=/^[a-z][a-z0-9-]*$/,nt=/^[A-Za-z0-9_.-]+$/,ot=/^(\$app(:[A-Za-z0-9_-]+)?|[A-Za-z0-9_.-]+)$/,it=["imagesFirst","variantsFirst","sellingPlanGroupsFirst","sellingPlansFirst","collectionFirst","retries","maxAge","lowStock"],st=["warningText","formatMoney","onLayoutChange","onCartOpen","onCartClose","onLineEnter","onLineLeave","onValueChange","onError"];function g(t,e,r){return e!==void 0&&d(`invalid ${t} ${JSON.stringify(e)}: using ${JSON.stringify(r)}`),r}function at(t,e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:g(t,e,b[t])}function F(t,e,r){return r.find(n=>n===e)??g(t,e,r[0])}function ut(t){return typeof t!="string"?"":t.replace(/^https?:\/\//,"").replace(/\/.*$/,"")}function ct(t){let e,r;if(typeof t=="string"){let n=t.indexOf(".");e=n>0?t.slice(0,n):"",r=t.slice(n+1)}else typeof t=="object"&&t!==null&&(e=Reflect.get(t,"namespace"),r=Reflect.get(t,"key"));return typeof e!="string"||typeof r!="string"?null:ot.test(e)&&nt.test(r)?{namespace:e,key:r}:null}function ft(t){if(!Array.isArray(t))return g("metafields",t,[]);let e=[];for(let r of t){let n=ct(r);n?e.push(typeof r=="string"?r:n):g("metafield",r,null)}return e}function lt(t){let e=ut(t.domain),r=typeof t.prefix=="string"&&rt.test(t.prefix)?t.prefix:g("prefix",t.prefix,b.prefix),n={...b,...t,domain:e,prefix:r,storageKey:t.storageKey||`${r}:cart:${e}`,metafields:ft(t.metafields??[]),checkoutTarget:F("checkoutTarget",t.checkoutTarget,["_self","_blank"]),defaultPurchase:F("defaultPurchase",t.defaultPurchase,["one-time","subscription"])};for(let o of it)n[o]=at(o,t[o]);for(let o of st)typeof n[o]!="function"&&(n[o]=null);return n.apiVersion==="unstable"&&d('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),n}function zt(t={}){let e=lt(t);for(let r of Object.keys(i))r in e||Reflect.deleteProperty(i,r);return Object.assign(i,e)}var Jt=()=>!!(i.domain&&i.token);function k(...t){i.debug&&console.log(`[${i.prefix}]`,...t)}function d(...t){console.warn(`[${i.prefix}]`,...t)}function h(t,e){if(d(e,t instanceof Error&&t.message?t.message:t),!!i.onError)try{i.onError(t,e)}catch(r){d("onError threw",r)}}var pt=/^[A-Z]{2}$/,dt=new Set(["XX","T1"]),mt=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),gt=/^[A-Z]{2,3}$/;function D(t){let e=(typeof t=="string"?t:"").trim().toUpperCase();return!pt.test(e)||dt.has(e)?null:e}function j(t){let e=(typeof t=="string"?t:"").trim().replace("-","_").toUpperCase();if(mt.has(e))return e;let r=e.split("_")[0]??"";return gt.test(r)?r:null}var l=class extends Error{constructor(e,{status:r,errors:n,userErrors:o,code:s}={}){super(e),this.name="TetherError",this.code=s??(r?`HTTP_${r}`:"ERROR"),this.status=r,this.errors=n,this.userErrors=o}};function ht(t=i){return`https://${t.domain}/api/${t.apiVersion}/graphql.json`}function yt(t,e=i){let r=[],n=D(e.country),o=j(e.language);if(n&&r.push(`country: ${n}`),o&&r.push(`language: ${o}`),!r.length||t.includes("@inContext"))return t;let s=`@inContext(${r.join(", ")})`;return/^\s*\{/.test(t)?`query ${s} ${t.trimStart()}`:t.replace(/^(\s*(?:query|mutation)(?:\s+\w+)?\s*(?:\([^)]*\))?)/,`$1 ${s}`)}var H=300,At=500,V=430,T="quantityAvailable",B=new Set,xt=t=>`${t.domain} ${t.apiVersion} ${t.token}`,Et=t=>new Promise(e=>setTimeout(e,t));function O(t,e){if(t===401||t===403){let r=e.token.startsWith("shpat_")?", not an Admin API token (shpat_\u2026)":"";return`Shopify rejected the Storefront token for ${e.domain} (${t}): use the public Storefront API token (Headless channel)${r}`}return t===404?`Store or API version not found (404): check domain ${e.domain} and apiVersion ${e.apiVersion}`:`HTTP ${t} from ${e.domain}`}function bt(t,e,r){let n=e.map(s=>s.message).filter(Boolean).join(" | "),o=n||"Storefront API error";return t.ok||(o=t.status===401||t.status===403||!n?O(t.status,r):n),new l(o,{status:t.status,errors:e})}async function Tt(t,e,r,n){let o;try{o=await(t.fetch??fetch)(ht(t),{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":t.token},body:JSON.stringify({query:e,variables:r})})}catch(u){if(n)return{kind:"retry",backoffMs:H};throw new l(`Network error: ${u instanceof Error?u.message:String(u)}`,{code:"NETWORK"})}if(o.status===V)throw new l("Shopify security rejection (430)",{status:V});if(n&&(o.status===429||o.status>=500))return{kind:"retry",backoffMs:H};let s;try{s=await o.json()}catch{let u=o.ok?`Invalid response (${o.status})`:O(o.status,t);throw new l(u,{status:o.status})}let{data:c,errors:f=[]}=s??{};if(f.length){if(e.includes(T)&&f.some(u=>u.message.includes(T)))return{kind:"inventory-refused"};if(n&&f.some(u=>u.extensions?.code==="THROTTLED"))return{kind:"retry",backoffMs:At};throw bt(o,f,t)}if(!o.ok)throw new l(O(o.status,t),{status:o.status});return{kind:"data",data:c}}async function wt(t,e,r={},{context:n=!0}={}){if(!t.domain||!t.token)throw new l("Tether is not configured: domain and token are required",{code:"NOT_CONFIGURED"});let o=n?yt(e,t):e;t.maxAge>0&&!/^\s*mutation\b/.test(o)&&(o+=` #${Math.floor(Date.now()/(t.maxAge*1e3))}`);let s=xt(t),c=0;for(;;){let f=B.has(s)?o.replaceAll(T,""):o,u=await Tt(t,f,r,c<t.retries);switch(u.kind){case"data":return u.data;case"inventory-refused":k(`the token can't read inventory: ${T} is left out from now on`),B.add(s);break;case"retry":c+=1,k("retry",c),await Et(u.backoffMs*2**c);break}}}var Xt=(t,e,r)=>wt(i,t,e,r);function Qt(t,e){if(!t)throw new l(`${e}: empty response`);let r=t.userErrors??[];if(r.length)throw new l(r.map(n=>n.message).join(" | "),{userErrors:r});return t}var p=t=>`${i.prefix}-${t}`,St=(t,e)=>e===void 0?`[${p(t)}]`:`[${p(t)}="${e}"]`,$=(t,e)=>t.getAttribute(p(e)),Ct=(t,e)=>t.hasAttribute(p(e));function G(t,e){return t?[...t.querySelectorAll(e)]:[]}var kt=(t,e,r)=>G(t,e).filter(n=>n.closest(r)===t);function N(t,e,r=document){r.dispatchEvent(new CustomEvent(`${i.prefix}:${t}`,{detail:e,bubbles:!0}))}function K(t,{width:e,height:r,crop:n}={}){if(!t)return t;let o;try{o=new URL(t)}catch(s){if(s instanceof TypeError)return t;throw s}return e&&o.searchParams.set("width",String(e)),r&&o.searchParams.set("height",String(r)),n&&o.searchParams.set("crop",n),o.toString()}function v(t,e){return t.getAttribute(e)??t.getAttribute(p(e))??t.getAttribute(`data-${e}`)}function z(t,e){if(!t||!e)return t;let r=v(e,"max-width"),n=v(e,"max-height");return K(t,{width:r,height:n,crop:r||n?v(e,"crop"):null})}var J=(t,e)=>!!(t&&e)&&t?.split("?")[0]===e?.split("?")[0];function Ot(t){return/^\s*[a-z][a-z0-9+.-]*:/i.test(t)&&!/^\s*(https?:|data:image\/)/i.test(t)?"none":`url("${t.replace(/["\\\n\r\f]/g,n=>`\\${n.charCodeAt(0).toString(16)} `)}")`}function $t(t,e,r){if(!e)return;let n=z(e,t);if(t.tagName!=="IMG"){t.style.backgroundImage=Ot(n);return}if(J(t.getAttribute("src"),n)){r!=null&&!t.getAttribute("alt")&&t.setAttribute("alt",r);return}t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.setAttribute("src",n),r!=null&&t.setAttribute("alt",r),t.getAttribute("loading")||t.setAttribute("loading","lazy")}var I=new WeakMap,Nt=t=>!!I.get(t),P=t=>t.cloneNode(!0);function q(t){let e=I.get(t);if(e!==void 0)return e;let r=t.firstElementChild,n=r?P(r):null;return I.set(t,n),t.replaceChildren(),n}function vt(t,e,r){let n=q(t);if(!n){e.length&&d("repeater without a template child",t);return}t.replaceChildren(),e.forEach((o,s)=>{let c=P(n);r(c,o,s),t.appendChild(c)})}function It(t,e){let r=()=>{t.remove()};if(!e){r();return}try{e(t,r)}catch(n){h(n,"repeater onLeave"),r()}}function Pt(t,e,r,n){e.forEach((o,s)=>{if(!r.has(o))return;let c=e[s-1];if(c?.parentNode===t?c.after(o):t.prepend(o),!!n)try{n(o)}catch(f){h(f,"repeater onEnter")}})}function Lt(t,e,r,n,{onEnter:o,onLeave:s}={}){let c=q(t);if(!c){d("repeater without a template child",t);return}let f=`data-${i.prefix}-key`,u=`data-${i.prefix}-leaving`,_=()=>[...t.children].filter(a=>a.hasAttribute(f)&&!a.hasAttribute(u)),y=new Map(_().map(a=>[a.getAttribute(f),a])),A=[],x=new Set;e.forEach((a,E)=>{let C=String(r(a,E)),m=y.get(C);m?y.delete(C):(m=P(c),m.setAttribute(f,C),x.add(m)),n(m,a,E,x.has(m)),A.push(m)});let S=A.filter(a=>!x.has(a)),M=_().filter(a=>S.includes(a));if(!(M.length===S.length&&M.every((a,E)=>a===S[E]))){y.forEach(a=>{a.remove()}),A.forEach(a=>t.appendChild(a));return}Pt(t,A,x,o),y.forEach(a=>{a.setAttribute(u,""),a.removeAttribute(f),a.style.pointerEvents="none",a.inert=!0,It(a,s)})}var _t=new Set(["SCRIPT","OBJECT","EMBED","BASE","META","LINK","NOSCRIPT","TEMPLATE","ANIMATE","SET"]),Mt=new Set(["href","src","action","formaction","xlink:href","poster","data","background"]),Ut=/^\s*(javascript|vbscript|data):/i,Rt=/^\s*data:image\/(png|gif|jpeg|webp|avif);/i,Ft=/[- ]/g;function Dt(t,e){let r=e.name.toLowerCase();if(r.startsWith("on")||r==="srcdoc")return!0;let n=e.value.replace(Ft,"");return!Mt.has(r)||!Ut.test(n)?!1:!(t.tagName==="IMG"&&r==="src"&&Rt.test(n))}function jt(t){for(let e of[...t.querySelectorAll("*")]){if(_t.has(e.tagName.toUpperCase())){e.remove();continue}for(let r of[...e.attributes])Dt(e,r)&&e.removeAttribute(r.name)}}function W(t,e=globalThis.document){let r=e.createElement("template");return r.innerHTML=t??"",jt(r.content),r.content}var Y="data-tether-seen",L="data-tether-shown",w="data-tether-prev-display",Ht=120;function pe(t,e){return R(i.productPath||"/product",t,e)}function tt(t,e){try{return t()}catch(r){if(r instanceof RangeError)return e;throw r}}function de(t,e=i.locale){return t?tt(()=>new Intl.NumberFormat(e||void 0,{style:"percent",maximumFractionDigits:0}).format(t/100),`${t}%`):""}function me(t){return t?i.formatMoney?i.formatMoney(t,i.locale):U(t,i.locale):""}function ge(t){return t?tt(()=>new Date(t).toLocaleDateString(i.locale||void 0),""):""}function he(t,e){t.replaceChildren(W(e,t.ownerDocument))}var et=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA",Z=t=>t.tagName==="INPUT";function Vt(t,e){let r=e==null?"":String(e);et(t)?t.value=r:t.textContent=r}var X=t=>et(t)?t.value:t.textContent;function ye(t,e){let r=X(t);if(Vt(t,e),r!==X(t)&&t.hasAttribute(Y)&&i.onValueChange)try{i.onValueChange(t,r)}catch(n){h(n,"onValueChange")}t.setAttribute(Y,"1")}function Bt(t){if(t.hasAttribute(L))return;t.setAttribute(L,""),t.removeAttribute("hidden");let e=t.getAttribute(w);e!==null?(t.style.display=e,t.removeAttribute(w)):t.style.display==="none"&&(t.style.display=""),typeof getComputedStyle=="function"&&getComputedStyle(t).display==="none"&&(t.style.display=t.getAttribute(p("display"))||"block")}function Ae(t,e){if(e){Bt(t);return}t.removeAttribute(L),!t.hasAttribute(w)&&t.style.display!=="none"&&t.setAttribute(w,t.style.display),t.style.display="none"}function xe(t,e){t.classList.toggle("is-selected",e),t.setAttribute("aria-pressed",e?"true":"false"),Z(t)&&(t.type==="radio"||t.type==="checkbox")&&(t.checked=e);let r=t.querySelector('input[type="radio"],input[type="checkbox"]');r&&Z(r)&&(r.checked=e)}var Q;function Gt(t){clearTimeout(Q),Q=setTimeout(()=>{let{ScrollTrigger:e}=window;i.onLayoutChange?i.onLayoutChange(t):e?.refresh?.(),N("layout-changed",{reason:t})},Ht)}function Ee(t,e){let r=[...t.querySelectorAll("img")].filter(s=>!s.complete),n=r.length,o=()=>{n-=1,n===0&&Gt(`${e}:images`)};r.forEach(s=>{s.addEventListener("load",o,{once:!0}),s.addEventListener("error",o,{once:!0})})}function be(t,e){return t.getAttribute("aria-busy")==="true"?Promise.resolve(void 0):(t.setAttribute("aria-busy","true"),Promise.resolve().then(e).finally(()=>{t.removeAttribute("aria-busy")}))}function Te(t,e){let r=t?$(t,e):null;if(!r)return null;try{return JSON.parse(r)}catch{return d(`invalid JSON in ${p(e)}`,t),null}}function we(t){return t?Array.isArray(t)?t.map(e=>({key:String(e.key),value:String(e.value??"")})):Object.entries(t).map(([e,r])=>({key:e,value:String(r??"")})):[]}export{b as a,i as b,ct as c,lt as d,zt as e,Jt as f,k as g,d as h,h as i,D as j,j as k,l,ht as m,yt as n,wt as o,Xt as p,Qt as q,p as r,St as s,$ as t,Ct as u,G as v,kt as w,N as x,K as y,J as z,$t as A,Nt as B,vt as C,Lt as D,pe as E,de as F,me as G,ge as H,he as I,Vt as J,ye as K,Ae as L,xe as M,Gt as N,Ee as O,be as P,Te as Q,we as R};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{a as m,d as P}from"./chunk-FCSWQDVV.js";import{a as v}from"./chunk-VT4CDUJJ.js";import{c as R}from"./chunk-NEHZ37TU.js";import{e as S}from"./chunk-JOOEXYF3.js";import{B as k,b as i,f as $,m as E,p as w,r as p,s as l,t as f,v as d}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";var V=/^(\d{4})-(01|04|07|10)$/;function T(e){let n=V.exec(typeof e=="string"?e:"");return n?{year:Number(n[1]),month:Number(n[2])}:null}var q=(e,n)=>`${e}-${String(n).padStart(2,"0")}`;function A(e,n=1){let t=T(e);if(!t)throw new Error(`not a quarterly Shopify API version: ${e}`);let o=t.year*4+(t.month-1)/3+n;return q(Math.floor(o/4),o%4*3+1)}function _(e,n=new Date){if(e==="unstable")return{version:e,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let t=T(e);if(!t)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let o=new Date(Date.UTC(t.year,t.month-1,1)),r=new Date(Date.UTC(t.year,t.month-1+12,1)),s=(r.getTime()-n.getTime())/2630016e3,a=o<=n,c=`supported until about ${r.toISOString().slice(0,7)}`;return a?s<=0?c="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":s<3&&(c=`${c}: plan the upgrade to ${A(e)} or later (see README)`):c="not released yet (release candidate at best)",{version:e,ok:a&&s>0,monthsLeft:Math.round(s),next:A(e),note:c}}var M=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),N=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),D=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
|
|
2
|
-
always-enabled bind cart-checkout-charge cart-clear cart-close cart-count cart-discounts cart-drawer cart-label cart-lines
|
|
3
|
-
cart-note cart-open cart-subtotal cart-total cart-warning checkout code collection collection-bind countries country
|
|
4
|
-
country-bind country-label country-select default-plan default-purchase discount discount-code discount-form discount-input
|
|
5
|
-
discount-remove display error group group-add hide-single language limit line line-attribute line-attributes line-id
|
|
6
|
-
line-minus line-plan line-plus line-remove line-show list load-more market-pending one-time-label option option-list
|
|
7
|
-
option-selected option-value order order-bind order-line order-lines order-line-show order-show order-state order-fulfillments
|
|
8
|
-
fulfillment-bind order-return return-quantity return-reason return-note orders profile-form address-form addresses address-bind
|
|
9
|
-
address-show address-edit address-new address-delete address-default subscriptions subscription-bind subscription-lines
|
|
10
|
-
subscription-line subscription-show subscription-action subscription-status subscription-state confirm form-state form-error page-country page-language page-locale page-title plan plan-bind plan-list
|
|
11
|
-
plan-value product products purchase purchase-mode qty qty-minus qty-plus quantity recommendations reverse search
|
|
12
|
-
search-bind search-collections search-input search-limit search-min search-products search-queries search-results
|
|
13
|
-
search-state show soldout-text sort state subscribe-text variant variant-select variant-url max-width max-height crop
|
|
14
|
-
sig label hydrated busy`.split(/\s+/).filter(Boolean)),C=["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"],H=["option-list","plan-list","cart-lines","list"],b="metafield:",Y=/^image:\d+$/,G=2;function B(e,n){let t=Array.from({length:n.length+1},(o,r)=>r);for(let o=1;o<=e.length;o++){let r=[o];for(let s=1;s<=n.length;s++){let a=(t[s-1]??0)+(e[o-1]===n[s-1]?0:1);r.push(Math.min((t[s]??0)+1,(r[s-1]??0)+1,a))}t=r}return t[n.length]??0}function g(e,n,t=""){let o=null,r=1/0;for(let a of n){let c=B(e,a);c<r&&(r=c,o=a)}let s=Math.max(2,Math.floor(e.length/4));return o!==null&&r<=s?` Did you mean "${t}${o}"?`:""}function L(e){let n=e.id?`#${e.id}`:"",t=e.className&&typeof e.className=="string"?e.className.trim().split(/\s+/):[],o=t.length?`.${t.slice(0,G).join(".")}`:"";return`<${e.tagName.toLowerCase()}${n}${o}>`}var x=()=>`${l("collection")},${l("products")},${l("recommendations")}`;function Q(e,n){d(e,l("product")).forEach(t=>{if(t.closest(x())&&t.closest(l("list")))return;let{key:o,fromUrl:r,raw:s}=m(t);s?r&&!o&&n("warn",`${p("product")}="${s}" but this URL has no value for it (e.g. ?handle=my-product).`,t):n("error",`${p("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,t)})}function W(e,n){for(let t of C)d(e,l(t)).forEach(o=>{o.closest(l("product"))||t==="line-attribute"&&o.closest(l("group"))||n("warn",`${p(t)} outside any ${p("product")}: it does nothing here.`,o)});d(e,l("group-add")).forEach(t=>{t.closest(l("group"))||n("warn",`${p("group-add")} outside a ${p("group")}.`,t)});for(let t of H)d(e,l(t)).forEach(o=>{!o.firstElementChild&&!k(o)&&n("warn",`${p(t)} without a template child: put one example element inside it.`,o)});d(e,x()).forEach(t=>{d(t,l("list")).length||n("error",`List without a ${p("list")} child: products have nowhere to render.`,t)})}function j(e,n){d(e,l("show")).forEach(t=>{let o=f(t,"show")??"";M.has(o)||n("warn",`Unknown ${p("show")}="${o}".${g(o,M)}`,t)}),d(e,l("bind")).forEach(t=>{let o=f(t,"bind")||"";!o||N.has(o)||Y.test(o)||o.startsWith(b)||n("warn",`Unknown ${p("bind")}="${o}": it stays empty.${g(o,N)}`,t)})}function K(e,n){d(e,l("bind")).forEach(t=>{let o=f(t,"bind")||"";if(!o.startsWith(b))return;let r=o.slice(b.length);i.metafields.some(a=>(typeof a=="string"?a:`${a.namespace}.${a.key}`)===r)||n("error",`${p("bind")}="${o}" but "${r}" is not in config.metafields, so it stays empty.`,t)})}function F(e,n){let t=`${i.prefix}-`,o=new Set;d(e,"*").forEach(r=>{for(let{name:s}of r.attributes){if(!s.startsWith(t))continue;let a=s.slice(t.length);D.has(a)||o.has(a)||(o.add(a),n("warn",`Unknown attribute ${s}: Tether ignores it.${g(a,D,t)}`,r))}})}function z(e,n){let t=d(e,l("cart-drawer")).length;d(e,l("cart-open")).length&&!t&&n("warn",`${p("cart-open")} exists but there is no ${p("cart-drawer")} on this page.`),t>1&&n("warn",`More than one ${p("cart-drawer")}.`),d(e,`[${p("state")}="error"]`).forEach(o=>{o.matches(P())&&n("error",`Scope failed to load (${f(o,"error")||"error"}).`,o)})}function U(e=document){let n=[],t=(o,r,s)=>{n.push(s?{level:o,message:r,element:L(s),el:s}:{level:o,message:r})};return Q(e,t),W(e,t),j(e,t),F(e,t),K(e,t),z(e,t),n}var J=20,X=3,O=4;function Z(e){return e?`${e.slice(0,O)}\u2026${e.slice(-O)} (${e.length} chars)`:"(missing)"}function I(e,n){if(e instanceof Error&&e.message)return e.message;let t=typeof e=="object"&&e!==null?Reflect.get(e,"code"):void 0;return typeof t=="string"&&t?t:n}function ee(){return{domain:i.domain||"(missing)",token:Z(i.token),apiVersion:i.apiVersion,endpoint:i.domain?E():null,country:i.country,language:i.language,locale:i.locale,markets:i.markets,prefix:i.prefix,productPath:i.productPath,metafields:i.metafields,autoMount:i.autoMount,observe:i.observe,onError:typeof i.onError=="function"}}async function te(){return{country:i.country||null,language:i.language||null,locale:i.locale||null,detected:i.markets?.detect?(await v("markets")).detectMarket(i.markets):null}}function ne({ok:e,monthsLeft:n,note:t}){return e&&(n===void 0||n>=X)?null:{level:e?"warn":"error",message:`apiVersion ${i.apiVersion}: ${t}`}}async function oe(){if(!$())return{kind:"not-configured"};let e=Date.now();try{let n=await w("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},{context:!1});return{kind:"reachable",shop:{name:n.shop.name,url:n.shop.primaryDomain.url,currency:n.shop.paymentSettings.currencyCode},latencyMs:Date.now()-e}}catch(n){return{kind:"unreachable",error:n,latencyMs:Date.now()-e}}}function se(e,n,t){let o=[],r=t.options.map(a=>a.name),s=d(e,l("product")).filter(a=>m(a).key===n&&a.querySelector(l("add-to-cart")));for(let a of s){let c=new Set(d(a,`${l("option-list")},select${l("option")}`).map(u=>f(u,"option-list")||f(u,"option")));if(!(!c.size&&d(a,`select${l("variant-select")}`).length)){if(!i.language)for(let u of c)!u||r.includes(u)||o.push({level:"warn",message:`Product "${t.handle}" has no option "${u}" (its options: ${r.join(", ")||"none"}).${g(u,r)}`});for(let u of t.options)u.optionValues.length<=1||c.has(u.name)||o.push({level:"warn",message:`Product "${t.handle}": option "${u.name}" (${u.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})}}return o}async function re(e,n){let t=d(e,l("product")).map(s=>m(s).key),o=[...new Set(t.filter(s=>s!==null&&s!==""))].slice(0,J);(await Promise.allSettled(o.map(s=>R(s)))).forEach((s,a)=>{let c=o[a]??"";if(s.status==="rejected"){let h=I(s.reason,"not loaded");n.products.push({key:c,error:s.reason instanceof Error?s.reason.message:void 0}),n.problems.push({level:"error",message:`Product "${c}": ${h}. Is it published to the Headless channel?`});return}let u=s.value,y=S(u);n.products.push({key:c,handle:u.handle,title:u.title,plans:y.length,requiresSellingPlan:u.requiresSellingPlan});for(let h of y)n.sellingPlans.push({product:u.handle,group:h.group.name,plan:h.name,id:h.id});n.problems.push(...se(e,c,u))})}async function we({root:e=document,silent:n=!1,version:t,now:o=new Date}={}){let r=await oe(),s={version:t,config:ee(),apiVersion:_(i.apiVersion,o),market:await te(),reachable:r.kind==="reachable",shop:r.kind==="reachable"?r.shop:null,latencyMs:r.kind==="not-configured"?null:r.latencyMs,products:[],sellingPlans:[],problems:[]};switch(r.kind){case"not-configured":s.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});break;case"unreachable":s.problems.push({level:"error",message:`Storefront API not reachable: ${I(r.error,"unknown error")}`});break;case"reachable":await re(e,s);break}let a=ne(s.apiVersion);return a&&s.problems.push(a),typeof document<"u"&&s.problems.push(...U(e)),n||ae(s),s}function ae(e){let n=e.problems.filter(c=>c.level==="error").length,t=e.problems.length-n;console.group(`[${i.prefix}] diagnose: ${n?`${n} error(s)`:"no errors"}, ${t} warning(s)`),console.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),console.log("config",e.config);let{country:o,language:r,detected:s}=e.market,a=[o,r].filter(Boolean).join(" / ")||"the store default";console.log("market",`in use: ${a}`,s?`(detection picks ${JSON.stringify(s)})`:""),console.log(e.shop?`Storefront API reachable: ${e.shop.name} (${e.latencyMs??0} ms)`:"Storefront API NOT reachable"),e.products.length&&console.table(e.products),e.sellingPlans.length?console.table(e.sellingPlans):e.reachable&&console.log("No selling plans on the products of this page.");for(let c of e.problems)c.level==="error"?console.error(c.message,c.el??""):console.warn(c.message,c.el??"");console.groupEnd()}export{_ as apiVersionStatus,U as checkMarkup,we as diagnose,g as didYouMean};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as b}from"./chunk-2FSXS55U.js";import"./chunk-HEQILZVR.js";import"./chunk-FCSWQDVV.js";import{b as p}from"./chunk-MPTQYLSM.js";import"./chunk-NEHZ37TU.js";import"./chunk-JOOEXYF3.js";import{Q as h,R as w,b as s,h as f,i,s as c,t as g,u as d,v as y,x as m}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";function x(t,r){let e=w(h(t,"line-attributes"));return r?[{key:"_group",value:r},...e]:e}async function V(t){let r=t.closest(c("group"));if(!r)return null;let e=g(r,"group"),a=x(r,e),n=y(r,c("product")).flatMap(u=>{let o=b.get(u);if(!o?.variant?.availableForSale||o.quantity<=0)return[];let l=o.getLine();return l?[{...l,attributes:[...l.attributes??[],...a]}]:[]});if(!n.length)return f("group-add: nothing selected"),null;try{let u=await p.add(n);return m("group-added",{group:e,lines:n},r),u}catch(u){return i(u,"group add"),null}}function $(t){let r;try{r=JSON.parse(t)}catch{return null}if(typeof r!="object"||r===null)return null;let{country:e,language:a,locale:n}=r;return typeof e!="string"||!e?null:{country:e,language:typeof a=="string"?a:null,locale:typeof n=="string"?n:void 0}}function _(t){if(t.key===s.storageKey||t.key===`${s.storageKey}:seen`){p.init().catch(n=>{i(n,"cart from another tab")});return}if(t.key!==`${s.prefix}:market:${s.domain}`||!t.newValue)return;let r=$(t.newValue),{Tether:e}=window;if(!r||!e)return;let a={language:r.language,locale:r.locale,remember:!1};e.setCountry(r.country,a).catch(n=>{i(n,"market from another tab")})}var k=new WeakMap,S=t=>t.split("/").pop()??t;function A(t){try{window.history.replaceState(window.history.state,"",t)}catch{}}function v(t,{variant:r,sellingPlanId:e}){let a=`${r.id}|${e??""}`,n=k.get(t);if(k.set(t,a),!n||n===a)return;let u=s.variantUrl&&document.querySelector(c("product"))===t;if(!d(t,"variant-url")&&!u)return;let o=new URL(window.location.href);o.searchParams.set("variant",S(r.id)),e?o.searchParams.set("selling_plan",S(e)):o.searchParams.delete("selling_plan"),A(o)}export{V as addGroup,_ as onStorage,v as writeVariantUrl};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as T,c as P,d as F,e as h}from"./chunk-27PJJZGC.js";import{a as E,c as w,e as x,f as A,g as U,h as y,i as I}from"./chunk-V74KGEJF.js";import"./chunk-2FSXS55U.js";import"./chunk-HEQILZVR.js";import"./chunk-FCSWQDVV.js";import{b as l}from"./chunk-MPTQYLSM.js";import{d as v}from"./chunk-NEHZ37TU.js";import"./chunk-JOOEXYF3.js";import{b as c,i as f,j as m,k as g,l as C,r as s,s as p,t as b,x as L}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";var _="{name} ({currency})",j="name";function B(e,t){switch(t){case"name":return e.name;case"code":return e.isoCode;case"currency":return e.currency.isoCode;case"symbol":return e.currency.symbol;default:return""}}var M=(e,t)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,a)=>B(t,a));function O(e,t,o){let a=e.getAttribute(s("country-label"))||_,r=(e.getAttribute(s("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),i=r.length?r.map(n=>t.find(u=>u.isoCode===n)).filter(n=>n!==void 0):t;e.replaceChildren(...i.map(n=>new Option(M(a,n),n.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=i.length<2&&!e.hasAttribute(s("always-enabled"))}function S(e,t,o){let a=(c.country||o.country.isoCode).toUpperCase(),r=[...o.availableCountries].sort((n,u)=>n.name.localeCompare(u.name,c.locale||void 0)),i=r.find(n=>n.isoCode===a)??o.country;e.forEach(n=>{O(n,r,a)}),t.forEach(n=>{n.textContent=B(i,b(n,"country-bind")||j)})}function k(e=document){let t=y(e,`select${p("country-select")}`),o=y(e,p("country-bind"));return!t.length&&!o.length?Promise.resolve():h().then(a=>{S(t,o,a)}).catch(a=>{f(a,"country select")})}var $=e=>Object.values(c.markets?.locales??{}).find(t=>m(t.country)===e);function z(e,t){return e!==void 0?g(e):t?t.language?g(t.language):void 0:c.language}function R(e){v();let t=[];return l.id()&&t.push(l.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{f(o,"cart country")})),U(),A.forEach(o=>t.push(o.load())),x.forEach(o=>{o.closest(E())||(w.delete(o),I(o))}),t}async function X(e,{language:t,locale:o,remember:a=!0}={}){let r=m(e);if(!r)throw new C(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let i=$(r),n=o||i?.locale,u=n||c.locale,d=z(t,i),D=r!==c.country?.toUpperCase()||d!==c.language||u!==c.locale;if(c.country=r,c.language=d||void 0,c.locale=u,a&&P({country:r,language:d,locale:n}),!D)return k(),l.state;t!==void 0&&F();let N=R(r);return k(),L("country-changed",{country:r,language:c.language}),await Promise.all(N),l.state}export{T as detectMarket,h as getLocalization,k as renderCountrySelects,X as setCountry};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as C}from"./chunk-V74KGEJF.js";import"./chunk-2FSXS55U.js";import"./chunk-HEQILZVR.js";import"./chunk-FCSWQDVV.js";import"./chunk-MPTQYLSM.js";import"./chunk-NEHZ37TU.js";import"./chunk-JOOEXYF3.js";import{A as E,C as S,E as L,G as T,J as q,L as d,b as l,g,i as b,p as A,r as y,s as h,t as u,v as c,x as w}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";var R="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",v=6,D=2,F="/search",I=new WeakSet,x=0;function $(r,t,e){return parseInt(u(r,t)||"",10)||e}var k=r=>r.tagName==="A"?r:r.querySelector("a");function f(r,t){c(r,h("search-bind")).forEach(e=>{let i=u(e,"search-bind");i==="image"?E(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&q(e,t[i])})}function U(r,t){let e=k(r);e&&(e.setAttribute("href",t),e.setAttribute("role","option"))}var p=class{constructor(t,e,i){this.root=t,this.input=e,this.results=i,this.limit=$(t,"search-limit",v),this.minCharacters=$(t,"search-min",D),i.id||(x+=1,i.id=`${l.prefix}-search-${x}`),this.resultsId=i.id,this.searchNumber=0,this.timer=void 0,this.lastTerm="",this.cache=new Map,this.setUpAria(),this.listen()}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){this.input.addEventListener("input",()=>{let t=this.input.value.trim();t!==this.lastTerm&&(this.lastTerm=t,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(t),l.searchDelay))}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)}),this.input.addEventListener("keydown",t=>{this.onKeydown(t)}),document.addEventListener("click",t=>{this.root.contains(t.target)||this.open(!1)})}setState(t){this.root.setAttribute(y("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return c(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let i=await A(R,{q:t,limit:this.limit});return this.cache.set(t,i.predictiveSearch),i.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let i=await this.fetchResults(t);e===this.searchNumber&&this.render(i,t)}catch(i){if(e!==this.searchNumber){g("a superseded search failed",i);return}this.setState("error"),b(i,"search")}}fillList(t,e,i){c(this.results,h(t)).forEach(n=>{S(n,e,i),d(n,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||F,i=e.includes("?")?"&":"?";return`${e}${i}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let i=t?.products??[],n=t?.collections??[],o=(t?.queries??[]).filter(a=>a.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(a,s)=>{let N=T(s.priceRange.minVariantPrice);f(a,{title:s.title,price:N,image:s.featuredImage}),U(a,L(s.handle,s.id)),a.classList.toggle("is-sold-out",!s.availableForSale)}),this.fillList("search-collections",n,(a,s)=>{f(a,{title:s.title,image:s.image}),U(a,`${(l.collectionPath||"/collection").replace(/\/$/,"")}/${s.handle}`)}),this.fillList("search-queries",o,(a,s)=>{f(a,{text:s.text}),k(a)?.setAttribute("href",this.queryUrl(s.text))});let m=i.length+n.length+o.length;this.showCount(m),this.setState(m?"ready":"empty"),this.open(!0),w("search",{term:e,products:i,collections:n,queries:o},this.root)}showCount(t){c(this.root,h("show")).forEach(e=>{let i=u(e,"show");i==="search-empty"&&d(e,t===0),i==="search-results"&&d(e,t>0)}),this.options().forEach((e,i)=>{e.id||(e.id=`${this.resultsId}-${i}`),e.setAttribute("aria-selected","false")})}highlight(t,e){t.forEach((n,o)=>{n.setAttribute("aria-selected",String(o===e))});let i=t[e];i&&(this.input.setAttribute("aria-activedescendant",i.id),i.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),i=e.findIndex(n=>n.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(i+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,i<=0?e.length-1:i-1)):t.key==="Enter"&&i>=0?(t.preventDefault(),e[i]?.click()):t.key==="Escape"&&this.open(!1)}};function _(r=document){for(let t of C(r,h("search"))){if(I.has(t))continue;I.add(t);let e=t.querySelector(h("search-input"))??t.querySelector("input"),i=t.querySelector(h("search-results"));e&&i&&new p(t,e,i)}}export{_ as mountSearch};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The customer's addresses (`tether-addresses`), with `tether-show="addresses-loading"`, `addresses-empty` and
|
|
3
|
-
* `addresses-error`. The last list rendered is kept, so an edit button can fill the address form from it.
|
|
4
|
-
*/
|
|
5
|
-
import { reportError } from '../config.js';
|
|
6
|
-
import { get, qsa, repeat, sel, setText } from '../dom.js';
|
|
7
|
-
import { addressText, bindsIn, ownValue, showIn } from './markup.js';
|
|
8
|
-
import { addresses } from './operations.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {object} CustomerAddress An address of account-ops.js's documents, with `isDefault` added.
|
|
12
|
-
* @property {string} id
|
|
13
|
-
* @property {string | null} firstName
|
|
14
|
-
* @property {string | null} lastName
|
|
15
|
-
* @property {string | null} company
|
|
16
|
-
* @property {string | null} address1
|
|
17
|
-
* @property {string | null} address2
|
|
18
|
-
* @property {string | null} city
|
|
19
|
-
* @property {string | null} province
|
|
20
|
-
* @property {string | null} zoneCode
|
|
21
|
-
* @property {string | null} zip
|
|
22
|
-
* @property {string | null} country
|
|
23
|
-
* @property {string | null} countryCode
|
|
24
|
-
* @property {string | null} phoneNumber
|
|
25
|
-
* @property {string[]} formatted
|
|
26
|
-
* @property {boolean} isDefault
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/** @type {readonly CustomerAddress[]} */
|
|
30
|
-
let shown = [];
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @param {string} id
|
|
34
|
-
* @returns {CustomerAddress | undefined} The address with this id in the list shown last.
|
|
35
|
-
*/
|
|
36
|
-
export const shownAddress = (id) => shown.find((address) => address.id === id);
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @param {CustomerAddress} address
|
|
40
|
-
* @returns {Record<string, string>} The text of each `tether-address-bind` value.
|
|
41
|
-
*/
|
|
42
|
-
const addressTexts = (address) => ({
|
|
43
|
-
formatted: addressText(address),
|
|
44
|
-
name: [address.firstName, address.lastName].filter(Boolean).join(' '),
|
|
45
|
-
company: address.company || '',
|
|
46
|
-
address1: address.address1 || '',
|
|
47
|
-
address2: address.address2 || '',
|
|
48
|
-
city: address.city || '',
|
|
49
|
-
zip: address.zip || '',
|
|
50
|
-
province: address.province || '',
|
|
51
|
-
country: address.country || '',
|
|
52
|
-
phone: address.phoneNumber || '',
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @param {HTMLElement} row
|
|
57
|
-
* @param {CustomerAddress} address
|
|
58
|
-
*/
|
|
59
|
-
function fillAddress(row, address) {
|
|
60
|
-
row.dataset['tetherAddress'] = address.id;
|
|
61
|
-
const texts = addressTexts(address);
|
|
62
|
-
bindsIn(row, 'address-bind').forEach((el) => {
|
|
63
|
-
const text = ownValue(texts, get(el, 'address-bind') ?? '');
|
|
64
|
-
if (text !== undefined) setText(el, text);
|
|
65
|
-
});
|
|
66
|
-
showIn(row, 'address-show', { default: address.isDefault, 'not-default': !address.isDefault });
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Loads and renders the addresses. A failure is reported and shows `addresses-error`, never "no addresses yet".
|
|
71
|
-
*
|
|
72
|
-
* @param {ParentNode} root
|
|
73
|
-
*/
|
|
74
|
-
export async function renderAddresses(root) {
|
|
75
|
-
const boxes = qsa(root, sel('addresses'));
|
|
76
|
-
if (!boxes.length) return;
|
|
77
|
-
showIn(root, 'show', { 'addresses-loading': true, 'addresses-empty': false });
|
|
78
|
-
/** @type {CustomerAddress[]} */
|
|
79
|
-
let list;
|
|
80
|
-
try {
|
|
81
|
-
list = await addresses();
|
|
82
|
-
} catch (error) {
|
|
83
|
-
reportError(error, 'addresses');
|
|
84
|
-
showIn(root, 'show', { 'addresses-loading': false, 'addresses-error': true });
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
shown = list;
|
|
88
|
-
showIn(root, 'show', { 'addresses-loading': false, 'addresses-empty': list.length === 0, 'addresses-error': false });
|
|
89
|
-
boxes.forEach((box) => {
|
|
90
|
-
repeat(box, list, fillAddress);
|
|
91
|
-
});
|
|
92
|
-
}
|