@occluze/tether 0.6.0 → 0.6.1
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 +1 -1
- package/dist/esm/chunks/account-JBZJN7X7.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/tether.account.js +9 -3
- package/dist/tether.account.min.js +1 -1
- package/dist/tether.js +1 -1
- package/dist/tether.min.js +1 -1
- package/dist/tether.min.js.map +1 -1
- package/package.json +2 -2
- package/src/account.js +4 -4
- package/src/index.js +1 -1
- package/dist/esm/chunks/account-WAWNASZU.js +0 -1
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ Site settings → Custom code → **Head**:
|
|
|
50
50
|
<script src="https://cdn.jsdelivr.net/gh/ravi-klaassens/tether@0.6/dist/tether.min.js" defer></script>
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
**Versions:** `@0.6` gets every 0.6.x fix automatically (recommended), `@v0.6.
|
|
53
|
+
**Versions:** `@0.6` gets every 0.6.x fix automatically (recommended), `@v0.6.1` pins one release,
|
|
54
54
|
`@latest` always takes the newest. Hosting the file yourself? Put the optional parts next to it (`tether.markets.min.js`,
|
|
55
55
|
`tether.search.min.js`, `tether.account.min.js`, `tether.analytics.min.js`, `tether.extras.min.js`,
|
|
56
56
|
`tether.diagnose.min.js`): each loads only when a page uses it.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as u}from"./chunk-BGIKQY6H.js";import"./chunk-ZVUPVSLF.js";import"./chunk-YXCXIPQV.js";import{B as x,D as O,G as F,b as a,e as G,g,h as f,o as p,p as y,s as _,u as S,w as z}from"./chunk-KARKXC6G.js";import"./chunk-VC46IEJQ.js";var N=()=>`${a.prefix}:account:${a.domain}`,L=()=>`${a.prefix}:account-login:${a.domain}`,P=()=>a.account?.remember?window.localStorage:window.sessionStorage,H=t=>btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),v=()=>H(crypto.getRandomValues(new Uint8Array(32))),Z=async t=>H(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t))),A=t=>(a.account?.navigate||(e=>window.location.assign(e)))(t),B=(t,e)=>{try{return JSON.parse(t.getItem(e)||"null")}catch{return null}},b=(t,e,n)=>{try{n?t.setItem(e,JSON.stringify(n)):t.removeItem(e)}catch{}},U=null,s=null,D=null,I=null,d=()=>a.account?.server?String(a.account.server).replace(/\/$/,""):"",R=()=>`${a.prefix}:account-hint:${a.domain}`,T=null;async function C(t,{method:e="GET",body:n}={}){let r=await fetch(`${d()}${t}`,{method:e,credentials:"include",headers:e==="POST"?{"Content-Type":"application/json","X-Tether-Account":"1"}:{},body:n?JSON.stringify(n):void 0}),c=await r.json().catch(()=>({}));if(!r.ok&&r.status!==401)throw new f(`Customer accounts: ${c.error||r.status}`,{status:r.status});return c}async function J(){T||(T=await C("/me"));try{T.loggedIn?window.localStorage.setItem(R(),"1"):window.localStorage.removeItem(R())}catch{}return T}async function $(){if(U)return U;let t=a.account?.shopDomain||a.domain,e=c=>fetch(`https://${t}/.well-known/${c}`).then(o=>{if(!o.ok)throw new f(`Customer accounts: ${c} answered ${o.status}`,{status:o.status});return o.json()}),[n,r]=await Promise.all([e("openid-configuration"),e("customer-account-api")]);return U={...n,graphql:r.graphql_api},U}var tt=()=>a.account?.callbackUrl||`${window.location.origin}${window.location.pathname}`;function V(){return d()?!!T?.loggedIn:!!(s?.refresh||s?.access&&s.expiresAt>Date.now())}async function et({returnTo:t=window.location.href,locale:e}={}){if(d()){let h=new URL(`${d()}/login`);h.searchParams.set("returnTo",t);let m=e||a.account.locale||(a.locale||"").split("-")[0];m&&h.searchParams.set("locale",m),a.country&&h.searchParams.set("country",String(a.country).toUpperCase()),A(h.toString());return}if(!a.account?.clientId)throw new f("Customer accounts: set account.clientId",{code:"NOT_CONFIGURED"});let n=await $(),r=v(),c=v(),o=v(),l=tt();b(window.sessionStorage,L(),{state:r,nonce:c,verifier:o,redirect:l,returnTo:t,at:Date.now()});let i=new URL(n.authorization_endpoint),w={client_id:a.account.clientId,scope:"openid email customer-account-api:full",response_type:"code",redirect_uri:l,state:r,nonce:c,code_challenge:await Z(o),code_challenge_method:"S256"},k=e||a.account.locale||(a.locale||"").split("-")[0];k&&(w.locale=k),a.country&&(w.region_country=String(a.country).toUpperCase()),Object.entries(w).forEach(([h,m])=>i.searchParams.set(h,m)),A(i.toString())}async function W(t){let e=await $(),n=await fetch(a.account.tokenUrl||e.token_endpoint,{method:"POST",body:new URLSearchParams(t)}),r=await n.json().catch(()=>({}));if(!n.ok||!r.access_token)throw new f(`Customer accounts: token ${n.status} ${r.error||""}`.trim(),{status:n.status,code:n.status===400||n.status===401?"SESSION_ENDED":"TOKEN_FAILED"});return r}function nt(t){try{return JSON.parse(atob(t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")))}catch{return null}}function X(t,e=s){s={access:t.access_token,expiresAt:Date.now()+Math.max(0,(Number(t.expires_in)||3600)-120)*1e3,refresh:t.refresh_token||e?.refresh,idToken:t.id_token||e?.idToken},b(P(),N(),s)}async function ot(){let t=new URLSearchParams(window.location.search),e=B(window.sessionStorage,L());if(!e||!t.has("code")&&!t.has("error")||t.get("state")!==e.state)return!1;b(window.sessionStorage,L(),null);let n=new URL(window.location.href);if(["code","state","iss","error","error_description"].forEach(w=>n.searchParams.delete(w)),window.history.replaceState(window.history.state,"",n),t.has("error"))return S("account-error",{error:t.get("error")}),!1;if(Date.now()-e.at>10*6e4)throw new f("Customer accounts: the login took too long, please try again");let r=await W({grant_type:"authorization_code",client_id:a.account.clientId,redirect_uri:e.redirect,code:t.get("code"),code_verifier:e.verifier}),c=await $(),o=nt(r.id_token||""),l=[].concat(o?.aud||[]);if(!o||o.nonce!==e.nonce||o.iss!==c.issuer||!l.includes(a.account.clientId)||o.exp*1e3<Date.now())throw new f("Customer accounts: the login answer did not check out (nonce/issuer/audience)");X(r,null),await Y(),S("account-login",{});let i=e.returnTo&&new URL(e.returnTo,window.location.href);return i&&i.origin===window.location.origin&&i.href!==n.href&&A(i.href),!0}async function E(){return d()||(s||(s=B(P(),N())),!s)?null:s.access&&s.expiresAt>Date.now()?s.access:s.refresh?(D||(D=(async()=>{try{X(await W({grant_type:"refresh_token",client_id:a.account.clientId,refresh_token:s.refresh})),await Y()}catch(t){if(t.code==="SESSION_ENDED")q();else throw t}finally{D=null}})()),await D,s?.access||null):(q(),null)}function q(){s=null,I=null,b(P(),N(),null),u.customerAccessToken=null}async function Y(){u.customerAccessToken=s?.access||null,u.id()&&s?.access&&await u.setBuyerIdentity({customerAccessToken:s.access},{create:!1}).catch(t=>g(t,"account cart"))}async function Q(t,e={}){if(d())throw new f("Customer accounts in server mode only answer customer() and orders()",{code:"NOT_ALLOWED"});let n=await E();if(!n)throw new f("Not logged in",{code:"NOT_LOGGED_IN"});let r=await $(),c=i=>fetch(r.graphql,{method:"POST",headers:{"Content-Type":"application/json",Authorization:i},body:JSON.stringify({query:t,variables:e})}),o=await c(n);o.status===401&&s?.refresh&&(s.expiresAt=0,o=await c(await E()));let l=await o.json().catch(()=>({}));if(!o.ok||l.errors?.length)throw new f(l.errors?.map(i=>i.message).join(" | ")||`Customer accounts: ${o.status}`,{status:o.status});return l.data}async function rt(){if(d()){let e=await J();return e.loggedIn?{...e.customer,emailAddress:{emailAddress:e.customer.email},defaultAddress:{formatted:e.customer.address}}:null}return I||(I=(await Q("query TetherCustomer{customer{id firstName lastName displayName emailAddress{emailAddress}defaultAddress{formatted}}}")).customer,I)}async function at({first:t=10}={}){return d()?(await C(`/orders?first=${t}`)).orders||[]:(await Q("query TetherOrders($first:Int!){customer{orders(first:$first,sortKey:PROCESSED_AT,reverse:true){nodes{id name processedAt financialStatus fulfillmentStatus statusPageUrl totalPrice{amount currencyCode}lineItems(first:20){nodes{title variantTitle quantity image{url altText}}}}}}}",{first:t})).customer?.orders?.nodes||[]}async function ct({returnTo:t=a.account?.logoutUrl||`${window.location.origin}/`}={}){if(d()){let c=await C("/logout",{method:"POST",body:{returnTo:t,cartId:u.id()}});T={loggedIn:!1};try{window.localStorage.removeItem(R())}catch{}S("account-logout",{}),c.logoutUrl?A(c.logoutUrl):j(document);return}let e=s?.idToken||B(P(),N())?.idToken;if(u.id()&&await u.setBuyerIdentity({customerAccessToken:null},{create:!1}).catch(()=>{}),q(),S("account-logout",{}),!e){j(document);return}let n=await $(),r=new URL(n.end_session_endpoint);r.searchParams.set("id_token_hint",e),r.searchParams.set("post_logout_redirect_uri",t),A(r.toString())}var K=t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},st=t=>{try{return new Date(t).toLocaleDateString(a.locale||void 0)}catch{return t}};async function j(t=document){let e=d()?!!(await J().catch(()=>({loggedIn:!1}))).loggedIn:V()||!!await E().catch(()=>null);if(_(t,p("show")).forEach(c=>{let o=y(c,"show");o==="logged-in"&&O(c,e),o==="logged-out"&&O(c,!e)}),!e)return;let n=_(t,p("account-bind"));if(n.length){let c=await rt().catch(o=>(g(o,"account"),null));n.forEach(o=>{let l={"first-name":c?.firstName,"last-name":c?.lastName,name:c?.displayName,email:c?.emailAddress?.emailAddress,address:c?.defaultAddress?.formatted?.join(", ")}[y(o,"account-bind")];l!=null&&x(o,l)})}let r=_(t,p("orders"));if(r.length){let c=await at({first:parseInt(y(r[0],"limit")||"10",10)}).catch(o=>(g(o,"orders"),[]));r.forEach(o=>F(o,c,(l,i)=>{_(l,p("order-bind")).forEach(w=>{let k=y(w,"order-bind");if(k==="url"){K(i.statusPageUrl)&&w.setAttribute("href",i.statusPageUrl);return}let h={name:i.name,date:st(i.processedAt),total:z(i.totalPrice),status:i.financialStatus?.toLowerCase(),fulfillment:i.fulfillmentStatus?.toLowerCase(),items:i.lineItems.nodes.map(m=>`${m.quantity}\xD7 ${m.title}`).join(", ")}[k];h!=null&&x(w,h)}),y(l,"order-bind")==="url"&&K(i.statusPageUrl)&&l.setAttribute("href",i.statusPageUrl)}))}}var M=!1;async function ft(t=document){if(!M){if(M=!0,document.addEventListener("click",e=>{let n=e.target;n.closest?.(p("account-login"))?(e.preventDefault(),et().catch(r=>g(r,"login"))):n.closest?.(p("account-logout"))&&(e.preventDefault(),ct().catch(r=>g(r,"logout")))}),d()){let e=new URL(window.location.href);e.searchParams.get("account")&&(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),S("account-login",{})),u.beforeCheckout=async()=>{if(!(await J()).loggedIn||!u.id())return null;let n=await C("/cart",{method:"POST",body:{cartId:u.id()}}).catch(()=>null);return n?.checkoutUrl?`${n.checkoutUrl}${n.checkoutUrl.includes("?")?"&":"?"}logged_in=true`:null}}else{try{await ot()}catch(e){g(e,"login")}!u.customerAccessToken&&await E().catch(()=>null)&&(u.customerAccessToken=s.access)}G("account",V()?"logged in":"logged out")}await j(t)}export{rt as customer,E as getToken,ot as handleCallback,V as isLoggedIn,et as login,ct as logout,ft as mountAccount,at as orders,Q as query,j as render};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as W,b as Z,d as x,f as S,g as X,h as g,i as Y,j as ee,k as te,l as ne,m as re}from"./chunks/chunk-CISGFYOF.js";import{a as j}from"./chunks/chunk-6R752OYZ.js";import{a as V}from"./chunks/chunk-4UR45XTC.js";import{a as Q,b as c}from"./chunks/chunk-BGIKQY6H.js";import{a as _,b as R,c as q,d as F,h as G,i as B}from"./chunks/chunk-ZVUPVSLF.js";import{l as K}from"./chunks/chunk-YXCXIPQV.js";import{K as h,b as r,c as O,d as w,e as L,f as M,g as u,h as D,j as N,l as U,n as f,o as a,s as H,u as k,w as z,y as J}from"./chunks/chunk-KARKXC6G.js";import"./chunks/chunk-VC46IEJQ.js";var me={diagnose:()=>import("./chunks/diagnose-6ZSK5DGE.js"),markets:()=>import("./chunks/markets-ui-HJCVLCKJ.js"),search:()=>import("./chunks/search-LN2H6SXS.js"),extras:()=>import("./chunks/extras-QDCSW6VU.js"),account:()=>import("./chunks/account-
|
|
1
|
+
import{a as W,b as Z,d as x,f as S,g as X,h as g,i as Y,j as ee,k as te,l as ne,m as re}from"./chunks/chunk-CISGFYOF.js";import{a as j}from"./chunks/chunk-6R752OYZ.js";import{a as V}from"./chunks/chunk-4UR45XTC.js";import{a as Q,b as c}from"./chunks/chunk-BGIKQY6H.js";import{a as _,b as R,c as q,d as F,h as G,i as B}from"./chunks/chunk-ZVUPVSLF.js";import{l as K}from"./chunks/chunk-YXCXIPQV.js";import{K as h,b as r,c as O,d as w,e as L,f as M,g as u,h as D,j as N,l as U,n as f,o as a,s as H,u as k,w as z,y as J}from"./chunks/chunk-KARKXC6G.js";import"./chunks/chunk-VC46IEJQ.js";var me={diagnose:()=>import("./chunks/diagnose-6ZSK5DGE.js"),markets:()=>import("./chunks/markets-ui-HJCVLCKJ.js"),search:()=>import("./chunks/search-LN2H6SXS.js"),extras:()=>import("./chunks/extras-QDCSW6VU.js"),account:()=>import("./chunks/account-JBZJN7X7.js"),analytics:()=>import("./chunks/analytics-22NMIVBV.js")},l=t=>me[t](),oe=void 0;var ae="0.6.1",m=null,C=null;function p(t=document){if(!w())return 0;let e=0;return X(),re(t),g(t,W()).forEach(n=>{if(x.has(n))return;x.add(n),e++;let o=new Z(n);S.add(o),n.addEventListener(`${r.prefix}:list-rendered`,i=>p(i.detail.container)),te(o.load())}),g(t,a("product")).forEach(n=>{Y(n)&&e++}),g(t,`${a("country-select")},${a("country-bind")}`).length&&l("markets").then(n=>n.renderCountrySelects(t)).catch(n=>u(n,"markets")),(r.account?.clientId||r.account?.server)&&(g(t,`[${f("account-login")}],[${f("account-bind")}],[${f("orders")}],[${f("show")}^="logged-"]`).length||/[?&]code=/.test(window.location.search)||he())&&l("account").then(n=>n.mountAccount(t)).catch(n=>u(n,"account")),g(t,a("search")).length&&l("search").then(n=>n.mountSearch(t)).catch(n=>u(n,"search")),H(t,a("account-link")).forEach(n=>{n.setAttribute("href",`https://${r.domain}/account`)}),ne(),c.render(),L(`mounted ${e} scope(s)`,t),e}function se(){c.close()}function pe(t){let e=t?.closest?.(a("product"));return e&&j.get(e)||null}var ce=!1;function ge(){ce||(ce=!0,document.addEventListener("click",t=>{let e=t.target;if(!e?.closest)return;if(e.closest(a("cart-open"))){t.preventDefault(),c.toggle();return}if(e.closest(a("cart-close"))){t.preventDefault(),c.close();return}let n=e.closest(a("cart-clear"));if(n){t.preventDefault(),h(n,()=>c.clear().catch(d=>u(d,"cart clear")));return}let o=e.closest(a("checkout"));if(o){t.preventDefault(),h(o,()=>c.checkout());return}let i=e.closest(ie());if(i&&i.closest(a("cart-lines"))){let d=i.getAttribute(`data-${r.prefix}-key`),E=c.lines.find($=>$.id===d),b=$=>{t.preventDefault(),$().catch(fe=>u(fe,"cart line"))};if(e.closest(a("line-remove")))return i.classList.add("is-busy"),b(()=>c.removeLine(d));if(E&&e.closest(a("line-plus")))return b(()=>c.changeQuantity(d,1));if(E&&e.closest(a("line-minus")))return b(()=>c.changeQuantity(d,-1))}let s=e.closest(a("discount-remove"));if(s){t.preventDefault();let d=s.closest(a("discount-code"))?.getAttribute(f("discount-code"));d&&c.removeDiscount(d).catch(E=>u(E,"discount"));return}let y=e.closest(a("group-add"));y&&(t.preventDefault(),h(y,()=>ue(y)))}),document.addEventListener("change",t=>{let e=t.target;if(!e?.closest)return;let n=e.closest(ie()),o=n?.getAttribute(`data-${r.prefix}-key`),i=(s,y)=>{n.classList.add("is-busy"),n.setAttribute("aria-busy","true"),s.catch(d=>u(d,y))};o&&e.matches(`input${a("line","quantity")}`)?i(c.updateLine(o,parseInt(e.value,10)||0),"cart line"):o&&e.matches(`select${a("line-plan")}`)?i(c.updateLine(o,{sellingPlanId:e.value||null}),"cart line plan"):e.matches(`select${a("country-select")}`)?e.value&&I(e.value).catch(s=>u(s,"country")):e.matches(a("cart-note"))&&c.setNote(e.value).catch(s=>u(s,"cart note"))}),document.addEventListener("submit",t=>{let e=t.target.closest?.(a("discount-form"));if(!e)return;t.preventDefault();let n=e.querySelector(a("discount-input"))||e.querySelector("input"),o=n?.value.trim();o&&h(e,async()=>{let i=s=>{e.classList.toggle("is-invalid",s),n&&(s?n.setAttribute("aria-invalid","true"):n.removeAttribute("aria-invalid"))};try{await c.applyDiscount(o),i(!1),k("discount-applied",{code:o},e),n&&(n.value="")}catch(s){i(!0),s?.code==="INVALID_DISCOUNT"?k("discount-invalid",{code:o},e):u(s,"discount")}})},!0),document.addEventListener("input",t=>{let e=t.target.closest?.(a("discount-form"));e&&(e.classList.remove("is-invalid"),t.target.removeAttribute?.("aria-invalid"))}),window.addEventListener("storage",t=>{r.domain&&t.key?.startsWith(`${r.prefix}:`)&&l("extras").then(e=>e.onStorage(t)).catch(()=>{})}),document.addEventListener(`${r.prefix}:variant-changed`,t=>{let e=t.target;(r.variantUrl||e.hasAttribute?.(f("variant-url")))&&l("extras").then(n=>n.writeVariantUrl(e,t.detail)).catch(()=>{})}),r.astro!==!1&&(document.addEventListener("astro:page-load",()=>(m||Promise.resolve()).then(()=>{let t=A();if(!t&&T){try{t=JSON.parse(localStorage.getItem(`${r.prefix}:market:${r.domain}`)||"null")}catch{t=null}t=t?.country?t:de}T=!!A(),t?.country&&(String(t.country).toUpperCase()!==String(r.country||"").toUpperCase()||String(t.language||"").toUpperCase()!==String(r.language||"").toUpperCase())?I(t.country,{language:t.language??null,locale:t.locale,remember:!1}).then(()=>p(document),()=>p(document)):p(document)})),document.addEventListener("astro:before-swap",()=>se())),window.addEventListener("online",()=>{ee(),S.forEach(t=>{t.root.getAttribute(f("state"))==="error"&&t.load()})}),document.addEventListener("keydown",t=>{if(!c.isOpen())return;if(t.key==="Escape"){c.close();return}if(t.key!=="Tab"||r.cartFocus===!1)return;let e=c.drawers().find(s=>s.classList.contains(r.cartDrawerOpenClass)),n=e?Q(e):[];if(!n.length)return;let o=n[0],i=n[n.length-1];(!e.contains(document.activeElement)||t.shiftKey&&document.activeElement===o||!t.shiftKey&&document.activeElement===i)&&(t.preventDefault(),(t.shiftKey?i:o).focus())}))}function ie(){return`[data-${r.prefix}-key]`}var ue=t=>l("extras").then(e=>e.addGroup(t)),v=null;function le(t={}){return m&&!Object.keys(t).length?m:(O({...window.TETHER_CONFIG||{},...t}),w()?(ge(),r.observe&&Ee(),r.analytics&&!v&&(v=[],["product-ready","list-ready","cart-updated","cart-toggled","checkout","search"].forEach(e=>document.addEventListener(`${r.prefix}:${e}`,n=>v.push(n))),document.addEventListener("astro:page-load",()=>v.push(new CustomEvent(`${r.prefix}:page`))),l("analytics").then(e=>e.startAnalytics(v)).catch(e=>u(e,"analytics"))),m=ye(t).then(()=>c.init()).then(async e=>{let n=r.country?String(r.country).toUpperCase():null;if(e&&n&&e.buyerIdentity?.countryCode&&e.buyerIdentity.countryCode!==n)try{e=await c.setBuyerIdentity({countryCode:n},{create:!1})}catch(o){u(o,"cart country")}return k("ready",{cart:e}),P}),m):(M("TETHER_CONFIG is missing domain or token. Tether is idle."),m=Promise.resolve(null),m))}function A(t=document){let e=o=>t.querySelector(`meta[name="${r.prefix}-page-${o}"]`)?.getAttribute("content")||void 0,n=e("country");return n?{country:n.toUpperCase(),language:e("language"),locale:e("locale")}:null}var de=null,T=!1;async function ye(t){let e=r.markets||{};de={country:r.country,language:r.language,locale:r.locale};let n=A();if(T=!!n,n){r.country=n.country,r.language=n.language?n.language.toUpperCase():void 0,n.locale&&(r.locale=n.locale);return}if(e.detect===!1)return;let o=null;if(e.detect)try{o=(await l("markets")).detectMarket(e)}catch(i){u(i,"markets");return}else if(e.remember!==!1){try{o=JSON.parse(localStorage.getItem(`${r.prefix}:market:${r.domain}`)||"null")}catch{}o&&!/^[A-Z]{2}$/.test(o.country||"")&&(o=null)}o&&(o.country&&(r.country=o.country),o.language&&(r.language=o.language),o.locale&&!t.locale&&(r.locale=o.locale),L("market",o))}function he(){try{return!!(sessionStorage[`${r.prefix}:account:${r.domain}`]||localStorage[`${r.prefix}:account:${r.domain}`]||localStorage[`${r.prefix}:account-hint:${r.domain}`])}catch{return!1}}var ve=new Proxy({},{get:(t,e)=>(...n)=>l("account").then(o=>o[e](...n))});function I(t,e){return l("markets").then(n=>n.setCountry(t,e))}function Ee(){if(C||typeof MutationObserver>"u")return;let t=null,e=new Set;C=new MutationObserver(n=>{n.forEach(o=>o.addedNodes.forEach(i=>{i.nodeType===1&&e.add(i)})),clearTimeout(t),t=setTimeout(()=>{e.forEach(o=>{o.isConnected&&p(o)}),e.clear()},50)}),C.observe(document.body,{childList:!0,subtree:!0})}var P={VERSION:ae,init:le,mount:p,unmount:se,get config(){return r},get ready(){return m||Promise.resolve(null)},query:U,withContext:N,cart:c,getProduct:q,getProducts:G,getRecommendations:B,getScope:pe,addGroup:ue,account:ve,primeProduct:R,normalizeProductKey:_,clearProductCache:F,formatMoney:z,imageUrl:J,plans:K,TetherError:D,resolveProductKey:V,setCountry:I,detectMarket:t=>l("markets").then(e=>e.detectMarket(t||r.markets)),getLocalization:()=>l("markets").then(t=>t.getLocalization()),diagnose:t=>l("diagnose").then(e=>e.diagnose({...t,version:ae})),__core:oe,__parts:{},on(t,e){let n=o=>e(o.detail,o);return document.addEventListener(`${r.prefix}:${t}`,n),()=>document.removeEventListener(`${r.prefix}:${t}`,n)}},De=P;if(typeof window<"u"&&typeof document<"u"&&(window.Tether=P,window.TETHER_CONFIG&&window.TETHER_CONFIG.autoMount!==!1&&!window.TETHER_INTEGRATION)){let e=()=>le().then(()=>p(document));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}export{ae as VERSION,ue as addGroup,P as api,De as default,pe as getScope,le as init,p as mount,I as setCountry,se as unmount};
|
package/dist/tether.account.js
CHANGED
|
@@ -104,7 +104,6 @@
|
|
|
104
104
|
if (server()) {
|
|
105
105
|
const u2 = new URL(`${server()}/login`);
|
|
106
106
|
u2.searchParams.set("returnTo", returnTo);
|
|
107
|
-
if (Cart.id()) u2.searchParams.set("cart", Cart.id());
|
|
108
107
|
const lang2 = locale || cfg.account.locale || (cfg.locale || "").split("-")[0];
|
|
109
108
|
if (lang2) u2.searchParams.set("locale", lang2);
|
|
110
109
|
if (cfg.country) u2.searchParams.set("country", String(cfg.country).toUpperCase());
|
|
@@ -284,6 +283,13 @@
|
|
|
284
283
|
u.searchParams.set("post_logout_redirect_uri", returnTo);
|
|
285
284
|
go(u.toString());
|
|
286
285
|
}
|
|
286
|
+
var https = (u) => {
|
|
287
|
+
try {
|
|
288
|
+
return new URL(u).protocol === "https:";
|
|
289
|
+
} catch {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
287
293
|
var date = (s) => {
|
|
288
294
|
try {
|
|
289
295
|
return new Date(s).toLocaleDateString(cfg.locale || void 0);
|
|
@@ -320,13 +326,13 @@
|
|
|
320
326
|
qsa(node, sel("order-bind")).forEach((el) => {
|
|
321
327
|
const k = get(el, "order-bind");
|
|
322
328
|
if (k === "url") {
|
|
323
|
-
el.setAttribute("href", o.statusPageUrl);
|
|
329
|
+
if (https(o.statusPageUrl)) el.setAttribute("href", o.statusPageUrl);
|
|
324
330
|
return;
|
|
325
331
|
}
|
|
326
332
|
const v = { name: o.name, date: date(o.processedAt), total: formatMoney(o.totalPrice), status: o.financialStatus?.toLowerCase(), fulfillment: o.fulfillmentStatus?.toLowerCase(), items: o.lineItems.nodes.map((l) => `${l.quantity}\xD7 ${l.title}`).join(", ") }[k];
|
|
327
333
|
if (v != null) setText(el, v);
|
|
328
334
|
});
|
|
329
|
-
if (get(node, "order-bind") === "url") node.setAttribute("href", o.statusPageUrl);
|
|
335
|
+
if (get(node, "order-bind") === "url" && https(o.statusPageUrl)) node.setAttribute("href", o.statusPageUrl);
|
|
330
336
|
}));
|
|
331
337
|
}
|
|
332
338
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var rt=Object.defineProperty;var at=(t,e)=>{for(var o in e)rt(t,o,{get:e[o],enumerable:!0})};var F={};at(F,{customer:()=>et,getToken:()=>x,handleCallback:()=>Z,isLoggedIn:()=>G,login:()=>X,logout:()=>nt,mountAccount:()=>mt,orders:()=>ot,query:()=>K,render:()=>U});var ct=window.Tether.__core["config.js"],{DEFAULTS:gt,cfg:a,configure:pt,isConfigured:yt,log:M,reportError:g,warn:_t}=ct;var st=window.Tether.__core["client.js"],{TetherError:w,endpoint:Tt,gql:kt,request:It,unwrap:At,withContext:xt}=st;var it=window.Tether.__core["dom.js"],{attr:Et,busy:Ut,cdnUrl:$t,dataKey:bt,emit:y,formatDate:Nt,formatMoney:z,formatPercent:Pt,get:_,has:Dt,hasTemplate:Ot,imageUrl:vt,notifyLayoutChanged:Lt,parseJSONAttr:jt,productUrl:qt,qsa:T,readText:Rt,repeat:H,repeatKeyed:Jt,sameImage:Bt,scoped:Gt,sel:p,setImage:Kt,setSelected:Ft,setText:D,setTextTracked:Mt,show:O,toAttributes:zt,watchImages:Ht}=it;var lt=window.Tether.__core["cart.js"],{Cart:u,focusables:Wt,toLineInput:Xt}=lt;var $=()=>`${a.prefix}:account:${a.domain}`,j=()=>`${a.prefix}:account-login:${a.domain}`,b=()=>a.account?.remember?window.localStorage:window.sessionStorage,W=t=>btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),v=()=>W(crypto.getRandomValues(new Uint8Array(32))),ut=async t=>W(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t))),A=t=>(a.account?.navigate||(e=>window.location.assign(e)))(t),J=(t,e)=>{try{return JSON.parse(t.getItem(e)||"null")}catch{return null}},N=(t,e,o)=>{try{o?t.setItem(e,JSON.stringify(o)):t.removeItem(e)}catch{}},E=null,s=null,L=null,k=null,d=()=>a.account?.server?String(a.account.server).replace(/\/$/,""):"",q=()=>`${a.prefix}:account-hint:${a.domain}`,I=null;async function P(t,{method:e="GET",body:o}={}){let r=await fetch(`${d()}${t}`,{method:e,credentials:"include",headers:e==="POST"?{"Content-Type":"application/json","X-Tether-Account":"1"}:{},body:o?JSON.stringify(o):void 0}),c=await r.json().catch(()=>({}));if(!r.ok&&r.status!==401)throw new w(`Customer accounts: ${c.error||r.status}`,{status:r.status});return c}async function B(){I||(I=await P("/me"));try{I.loggedIn?window.localStorage.setItem(q(),"1"):window.localStorage.removeItem(q())}catch{}return I}async function C(){if(E)return E;let t=a.account?.shopDomain||a.domain,e=c=>fetch(`https://${t}/.well-known/${c}`).then(n=>{if(!n.ok)throw new w(`Customer accounts: ${c} answered ${n.status}`,{status:n.status});return n.json()}),[o,r]=await Promise.all([e("openid-configuration"),e("customer-account-api")]);return E={...o,graphql:r.graphql_api},E}var dt=()=>a.account?.callbackUrl||`${window.location.origin}${window.location.pathname}`;function G(){return d()?!!I?.loggedIn:!!(s?.refresh||s?.access&&s.expiresAt>Date.now())}async function X({returnTo:t=window.location.href,locale:e}={}){if(d()){let f=new URL(`${d()}/login`);f.searchParams.set("returnTo",t),u.id()&&f.searchParams.set("cart",u.id());let h=e||a.account.locale||(a.locale||"").split("-")[0];h&&f.searchParams.set("locale",h),a.country&&f.searchParams.set("country",String(a.country).toUpperCase()),A(f.toString());return}if(!a.account?.clientId)throw new w("Customer accounts: set account.clientId",{code:"NOT_CONFIGURED"});let o=await C(),r=v(),c=v(),n=v(),l=dt();N(window.sessionStorage,j(),{state:r,nonce:c,verifier:n,redirect:l,returnTo:t,at:Date.now()});let i=new URL(o.authorization_endpoint),m={client_id:a.account.clientId,scope:"openid email customer-account-api:full",response_type:"code",redirect_uri:l,state:r,nonce:c,code_challenge:await ut(n),code_challenge_method:"S256"},S=e||a.account.locale||(a.locale||"").split("-")[0];S&&(m.locale=S),a.country&&(m.region_country=String(a.country).toUpperCase()),Object.entries(m).forEach(([f,h])=>i.searchParams.set(f,h)),A(i.toString())}async function Y(t){let e=await C(),o=await fetch(a.account.tokenUrl||e.token_endpoint,{method:"POST",body:new URLSearchParams(t)}),r=await o.json().catch(()=>({}));if(!o.ok||!r.access_token)throw new w(`Customer accounts: token ${o.status} ${r.error||""}`.trim(),{status:o.status,code:o.status===400||o.status===401?"SESSION_ENDED":"TOKEN_FAILED"});return r}function ft(t){try{return JSON.parse(atob(t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")))}catch{return null}}function Q(t,e=s){s={access:t.access_token,expiresAt:Date.now()+Math.max(0,(Number(t.expires_in)||3600)-120)*1e3,refresh:t.refresh_token||e?.refresh,idToken:t.id_token||e?.idToken},N(b(),$(),s)}async function Z(){let t=new URLSearchParams(window.location.search),e=J(window.sessionStorage,j());if(!e||!t.has("code")&&!t.has("error")||t.get("state")!==e.state)return!1;N(window.sessionStorage,j(),null);let o=new URL(window.location.href);if(["code","state","iss","error","error_description"].forEach(m=>o.searchParams.delete(m)),window.history.replaceState(window.history.state,"",o),t.has("error"))return y("account-error",{error:t.get("error")}),!1;if(Date.now()-e.at>10*6e4)throw new w("Customer accounts: the login took too long, please try again");let r=await Y({grant_type:"authorization_code",client_id:a.account.clientId,redirect_uri:e.redirect,code:t.get("code"),code_verifier:e.verifier}),c=await C(),n=ft(r.id_token||""),l=[].concat(n?.aud||[]);if(!n||n.nonce!==e.nonce||n.iss!==c.issuer||!l.includes(a.account.clientId)||n.exp*1e3<Date.now())throw new w("Customer accounts: the login answer did not check out (nonce/issuer/audience)");Q(r,null),await tt(),y("account-login",{});let i=e.returnTo&&new URL(e.returnTo,window.location.href);return i&&i.origin===window.location.origin&&i.href!==o.href&&A(i.href),!0}async function x(){return d()||(s||(s=J(b(),$())),!s)?null:s.access&&s.expiresAt>Date.now()?s.access:s.refresh?(L||(L=(async()=>{try{Q(await Y({grant_type:"refresh_token",client_id:a.account.clientId,refresh_token:s.refresh})),await tt()}catch(t){if(t.code==="SESSION_ENDED")R();else throw t}finally{L=null}})()),await L,s?.access||null):(R(),null)}function R(){s=null,k=null,N(b(),$(),null),u.customerAccessToken=null}async function tt(){u.customerAccessToken=s?.access||null,u.id()&&s?.access&&await u.setBuyerIdentity({customerAccessToken:s.access},{create:!1}).catch(t=>g(t,"account cart"))}async function K(t,e={}){if(d())throw new w("Customer accounts in server mode only answer customer() and orders()",{code:"NOT_ALLOWED"});let o=await x();if(!o)throw new w("Not logged in",{code:"NOT_LOGGED_IN"});let r=await C(),c=i=>fetch(r.graphql,{method:"POST",headers:{"Content-Type":"application/json",Authorization:i},body:JSON.stringify({query:t,variables:e})}),n=await c(o);n.status===401&&s?.refresh&&(s.expiresAt=0,n=await c(await x()));let l=await n.json().catch(()=>({}));if(!n.ok||l.errors?.length)throw new w(l.errors?.map(i=>i.message).join(" | ")||`Customer accounts: ${n.status}`,{status:n.status});return l.data}async function et(){if(d()){let e=await B();return e.loggedIn?{...e.customer,emailAddress:{emailAddress:e.customer.email},defaultAddress:{formatted:e.customer.address}}:null}return k||(k=(await K("query TetherCustomer{customer{id firstName lastName displayName emailAddress{emailAddress}defaultAddress{formatted}}}")).customer,k)}async function ot({first:t=10}={}){return d()?(await P(`/orders?first=${t}`)).orders||[]:(await K("query TetherOrders($first:Int!){customer{orders(first:$first,sortKey:PROCESSED_AT,reverse:true){nodes{id name processedAt financialStatus fulfillmentStatus statusPageUrl totalPrice{amount currencyCode}lineItems(first:20){nodes{title variantTitle quantity image{url altText}}}}}}}",{first:t})).customer?.orders?.nodes||[]}async function nt({returnTo:t=a.account?.logoutUrl||`${window.location.origin}/`}={}){if(d()){let c=await P("/logout",{method:"POST",body:{returnTo:t,cartId:u.id()}});I={loggedIn:!1};try{window.localStorage.removeItem(q())}catch{}y("account-logout",{}),c.logoutUrl?A(c.logoutUrl):U(document);return}let e=s?.idToken||J(b(),$())?.idToken;if(u.id()&&await u.setBuyerIdentity({customerAccessToken:null},{create:!1}).catch(()=>{}),R(),y("account-logout",{}),!e){U(document);return}let o=await C(),r=new URL(o.end_session_endpoint);r.searchParams.set("id_token_hint",e),r.searchParams.set("post_logout_redirect_uri",t),A(r.toString())}var wt=t=>{try{return new Date(t).toLocaleDateString(a.locale||void 0)}catch{return t}};async function U(t=document){let e=d()?!!(await B().catch(()=>({loggedIn:!1}))).loggedIn:G()||!!await x().catch(()=>null);if(T(t,p("show")).forEach(c=>{let n=_(c,"show");n==="logged-in"&&O(c,e),n==="logged-out"&&O(c,!e)}),!e)return;let o=T(t,p("account-bind"));if(o.length){let c=await et().catch(n=>(g(n,"account"),null));o.forEach(n=>{let l={"first-name":c?.firstName,"last-name":c?.lastName,name:c?.displayName,email:c?.emailAddress?.emailAddress,address:c?.defaultAddress?.formatted?.join(", ")}[_(n,"account-bind")];l!=null&&D(n,l)})}let r=T(t,p("orders"));if(r.length){let c=await ot({first:parseInt(_(r[0],"limit")||"10",10)}).catch(n=>(g(n,"orders"),[]));r.forEach(n=>H(n,c,(l,i)=>{T(l,p("order-bind")).forEach(m=>{let S=_(m,"order-bind");if(S==="url"){m.setAttribute("href",i.statusPageUrl);return}let f={name:i.name,date:wt(i.processedAt),total:z(i.totalPrice),status:i.financialStatus?.toLowerCase(),fulfillment:i.fulfillmentStatus?.toLowerCase(),items:i.lineItems.nodes.map(h=>`${h.quantity}\xD7 ${h.title}`).join(", ")}[S];f!=null&&D(m,f)}),_(l,"order-bind")==="url"&&l.setAttribute("href",i.statusPageUrl)}))}}var V=!1;async function mt(t=document){if(!V){if(V=!0,document.addEventListener("click",e=>{let o=e.target;o.closest?.(p("account-login"))?(e.preventDefault(),X().catch(r=>g(r,"login"))):o.closest?.(p("account-logout"))&&(e.preventDefault(),nt().catch(r=>g(r,"logout")))}),d()){let e=new URL(window.location.href);e.searchParams.get("account")&&(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),y("account-login",{})),u.beforeCheckout=async()=>{if(!(await B()).loggedIn||!u.id())return null;let o=await P("/cart",{method:"POST",body:{cartId:u.id()}}).catch(()=>null);return o?.checkoutUrl?`${o.checkoutUrl}${o.checkoutUrl.includes("?")?"&":"?"}logged_in=true`:null}}else{try{await Z()}catch(e){g(e,"login")}!u.customerAccessToken&&await x().catch(()=>null)&&(u.customerAccessToken=s.access)}M("account",G()?"logged in":"logged out")}await U(t)}window.Tether.__parts.account=F;})();
|
|
1
|
+
(()=>{var at=Object.defineProperty;var st=(t,e)=>{for(var o in e)at(t,o,{get:e[o],enumerable:!0})};var F={};st(F,{customer:()=>ot,getToken:()=>U,handleCallback:()=>tt,isLoggedIn:()=>G,login:()=>Y,logout:()=>rt,mountAccount:()=>ht,orders:()=>nt,query:()=>K,render:()=>E});var ct=window.Tether.__core["config.js"],{DEFAULTS:pt,cfg:a,configure:yt,isConfigured:_t,log:M,reportError:g,warn:St}=ct;var it=window.Tether.__core["client.js"],{TetherError:f,endpoint:kt,gql:It,request:At,unwrap:Ut,withContext:xt}=it;var lt=window.Tether.__core["dom.js"],{attr:Et,busy:$t,cdnUrl:bt,dataKey:Nt,emit:y,formatDate:Pt,formatMoney:z,formatPercent:Dt,get:_,has:Ot,hasTemplate:vt,imageUrl:Lt,notifyLayoutChanged:jt,parseJSONAttr:qt,productUrl:Rt,qsa:T,readText:Jt,repeat:H,repeatKeyed:Bt,sameImage:Gt,scoped:Kt,sel:p,setImage:Ft,setSelected:Mt,setText:D,setTextTracked:zt,show:O,toAttributes:Ht,watchImages:Vt}=lt;var ut=window.Tether.__core["cart.js"],{Cart:u,focusables:Xt,toLineInput:Yt}=ut;var $=()=>`${a.prefix}:account:${a.domain}`,j=()=>`${a.prefix}:account-login:${a.domain}`,b=()=>a.account?.remember?window.localStorage:window.sessionStorage,X=t=>btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),v=()=>X(crypto.getRandomValues(new Uint8Array(32))),dt=async t=>X(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t))),A=t=>(a.account?.navigate||(e=>window.location.assign(e)))(t),J=(t,e)=>{try{return JSON.parse(t.getItem(e)||"null")}catch{return null}},N=(t,e,o)=>{try{o?t.setItem(e,JSON.stringify(o)):t.removeItem(e)}catch{}},C=null,c=null,L=null,k=null,d=()=>a.account?.server?String(a.account.server).replace(/\/$/,""):"",q=()=>`${a.prefix}:account-hint:${a.domain}`,I=null;async function P(t,{method:e="GET",body:o}={}){let r=await fetch(`${d()}${t}`,{method:e,credentials:"include",headers:e==="POST"?{"Content-Type":"application/json","X-Tether-Account":"1"}:{},body:o?JSON.stringify(o):void 0}),s=await r.json().catch(()=>({}));if(!r.ok&&r.status!==401)throw new f(`Customer accounts: ${s.error||r.status}`,{status:r.status});return s}async function B(){I||(I=await P("/me"));try{I.loggedIn?window.localStorage.setItem(q(),"1"):window.localStorage.removeItem(q())}catch{}return I}async function x(){if(C)return C;let t=a.account?.shopDomain||a.domain,e=s=>fetch(`https://${t}/.well-known/${s}`).then(n=>{if(!n.ok)throw new f(`Customer accounts: ${s} answered ${n.status}`,{status:n.status});return n.json()}),[o,r]=await Promise.all([e("openid-configuration"),e("customer-account-api")]);return C={...o,graphql:r.graphql_api},C}var ft=()=>a.account?.callbackUrl||`${window.location.origin}${window.location.pathname}`;function G(){return d()?!!I?.loggedIn:!!(c?.refresh||c?.access&&c.expiresAt>Date.now())}async function Y({returnTo:t=window.location.href,locale:e}={}){if(d()){let m=new URL(`${d()}/login`);m.searchParams.set("returnTo",t);let h=e||a.account.locale||(a.locale||"").split("-")[0];h&&m.searchParams.set("locale",h),a.country&&m.searchParams.set("country",String(a.country).toUpperCase()),A(m.toString());return}if(!a.account?.clientId)throw new f("Customer accounts: set account.clientId",{code:"NOT_CONFIGURED"});let o=await x(),r=v(),s=v(),n=v(),l=ft();N(window.sessionStorage,j(),{state:r,nonce:s,verifier:n,redirect:l,returnTo:t,at:Date.now()});let i=new URL(o.authorization_endpoint),w={client_id:a.account.clientId,scope:"openid email customer-account-api:full",response_type:"code",redirect_uri:l,state:r,nonce:s,code_challenge:await dt(n),code_challenge_method:"S256"},S=e||a.account.locale||(a.locale||"").split("-")[0];S&&(w.locale=S),a.country&&(w.region_country=String(a.country).toUpperCase()),Object.entries(w).forEach(([m,h])=>i.searchParams.set(m,h)),A(i.toString())}async function Q(t){let e=await x(),o=await fetch(a.account.tokenUrl||e.token_endpoint,{method:"POST",body:new URLSearchParams(t)}),r=await o.json().catch(()=>({}));if(!o.ok||!r.access_token)throw new f(`Customer accounts: token ${o.status} ${r.error||""}`.trim(),{status:o.status,code:o.status===400||o.status===401?"SESSION_ENDED":"TOKEN_FAILED"});return r}function wt(t){try{return JSON.parse(atob(t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")))}catch{return null}}function Z(t,e=c){c={access:t.access_token,expiresAt:Date.now()+Math.max(0,(Number(t.expires_in)||3600)-120)*1e3,refresh:t.refresh_token||e?.refresh,idToken:t.id_token||e?.idToken},N(b(),$(),c)}async function tt(){let t=new URLSearchParams(window.location.search),e=J(window.sessionStorage,j());if(!e||!t.has("code")&&!t.has("error")||t.get("state")!==e.state)return!1;N(window.sessionStorage,j(),null);let o=new URL(window.location.href);if(["code","state","iss","error","error_description"].forEach(w=>o.searchParams.delete(w)),window.history.replaceState(window.history.state,"",o),t.has("error"))return y("account-error",{error:t.get("error")}),!1;if(Date.now()-e.at>10*6e4)throw new f("Customer accounts: the login took too long, please try again");let r=await Q({grant_type:"authorization_code",client_id:a.account.clientId,redirect_uri:e.redirect,code:t.get("code"),code_verifier:e.verifier}),s=await x(),n=wt(r.id_token||""),l=[].concat(n?.aud||[]);if(!n||n.nonce!==e.nonce||n.iss!==s.issuer||!l.includes(a.account.clientId)||n.exp*1e3<Date.now())throw new f("Customer accounts: the login answer did not check out (nonce/issuer/audience)");Z(r,null),await et(),y("account-login",{});let i=e.returnTo&&new URL(e.returnTo,window.location.href);return i&&i.origin===window.location.origin&&i.href!==o.href&&A(i.href),!0}async function U(){return d()||(c||(c=J(b(),$())),!c)?null:c.access&&c.expiresAt>Date.now()?c.access:c.refresh?(L||(L=(async()=>{try{Z(await Q({grant_type:"refresh_token",client_id:a.account.clientId,refresh_token:c.refresh})),await et()}catch(t){if(t.code==="SESSION_ENDED")R();else throw t}finally{L=null}})()),await L,c?.access||null):(R(),null)}function R(){c=null,k=null,N(b(),$(),null),u.customerAccessToken=null}async function et(){u.customerAccessToken=c?.access||null,u.id()&&c?.access&&await u.setBuyerIdentity({customerAccessToken:c.access},{create:!1}).catch(t=>g(t,"account cart"))}async function K(t,e={}){if(d())throw new f("Customer accounts in server mode only answer customer() and orders()",{code:"NOT_ALLOWED"});let o=await U();if(!o)throw new f("Not logged in",{code:"NOT_LOGGED_IN"});let r=await x(),s=i=>fetch(r.graphql,{method:"POST",headers:{"Content-Type":"application/json",Authorization:i},body:JSON.stringify({query:t,variables:e})}),n=await s(o);n.status===401&&c?.refresh&&(c.expiresAt=0,n=await s(await U()));let l=await n.json().catch(()=>({}));if(!n.ok||l.errors?.length)throw new f(l.errors?.map(i=>i.message).join(" | ")||`Customer accounts: ${n.status}`,{status:n.status});return l.data}async function ot(){if(d()){let e=await B();return e.loggedIn?{...e.customer,emailAddress:{emailAddress:e.customer.email},defaultAddress:{formatted:e.customer.address}}:null}return k||(k=(await K("query TetherCustomer{customer{id firstName lastName displayName emailAddress{emailAddress}defaultAddress{formatted}}}")).customer,k)}async function nt({first:t=10}={}){return d()?(await P(`/orders?first=${t}`)).orders||[]:(await K("query TetherOrders($first:Int!){customer{orders(first:$first,sortKey:PROCESSED_AT,reverse:true){nodes{id name processedAt financialStatus fulfillmentStatus statusPageUrl totalPrice{amount currencyCode}lineItems(first:20){nodes{title variantTitle quantity image{url altText}}}}}}}",{first:t})).customer?.orders?.nodes||[]}async function rt({returnTo:t=a.account?.logoutUrl||`${window.location.origin}/`}={}){if(d()){let s=await P("/logout",{method:"POST",body:{returnTo:t,cartId:u.id()}});I={loggedIn:!1};try{window.localStorage.removeItem(q())}catch{}y("account-logout",{}),s.logoutUrl?A(s.logoutUrl):E(document);return}let e=c?.idToken||J(b(),$())?.idToken;if(u.id()&&await u.setBuyerIdentity({customerAccessToken:null},{create:!1}).catch(()=>{}),R(),y("account-logout",{}),!e){E(document);return}let o=await x(),r=new URL(o.end_session_endpoint);r.searchParams.set("id_token_hint",e),r.searchParams.set("post_logout_redirect_uri",t),A(r.toString())}var V=t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},mt=t=>{try{return new Date(t).toLocaleDateString(a.locale||void 0)}catch{return t}};async function E(t=document){let e=d()?!!(await B().catch(()=>({loggedIn:!1}))).loggedIn:G()||!!await U().catch(()=>null);if(T(t,p("show")).forEach(s=>{let n=_(s,"show");n==="logged-in"&&O(s,e),n==="logged-out"&&O(s,!e)}),!e)return;let o=T(t,p("account-bind"));if(o.length){let s=await ot().catch(n=>(g(n,"account"),null));o.forEach(n=>{let l={"first-name":s?.firstName,"last-name":s?.lastName,name:s?.displayName,email:s?.emailAddress?.emailAddress,address:s?.defaultAddress?.formatted?.join(", ")}[_(n,"account-bind")];l!=null&&D(n,l)})}let r=T(t,p("orders"));if(r.length){let s=await nt({first:parseInt(_(r[0],"limit")||"10",10)}).catch(n=>(g(n,"orders"),[]));r.forEach(n=>H(n,s,(l,i)=>{T(l,p("order-bind")).forEach(w=>{let S=_(w,"order-bind");if(S==="url"){V(i.statusPageUrl)&&w.setAttribute("href",i.statusPageUrl);return}let m={name:i.name,date:mt(i.processedAt),total:z(i.totalPrice),status:i.financialStatus?.toLowerCase(),fulfillment:i.fulfillmentStatus?.toLowerCase(),items:i.lineItems.nodes.map(h=>`${h.quantity}\xD7 ${h.title}`).join(", ")}[S];m!=null&&D(w,m)}),_(l,"order-bind")==="url"&&V(i.statusPageUrl)&&l.setAttribute("href",i.statusPageUrl)}))}}var W=!1;async function ht(t=document){if(!W){if(W=!0,document.addEventListener("click",e=>{let o=e.target;o.closest?.(p("account-login"))?(e.preventDefault(),Y().catch(r=>g(r,"login"))):o.closest?.(p("account-logout"))&&(e.preventDefault(),rt().catch(r=>g(r,"logout")))}),d()){let e=new URL(window.location.href);e.searchParams.get("account")&&(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),y("account-login",{})),u.beforeCheckout=async()=>{if(!(await B()).loggedIn||!u.id())return null;let o=await P("/cart",{method:"POST",body:{cartId:u.id()}}).catch(()=>null);return o?.checkoutUrl?`${o.checkoutUrl}${o.checkoutUrl.includes("?")?"&":"?"}logged_in=true`:null}}else{try{await tt()}catch(e){g(e,"login")}!u.customerAccessToken&&await U().catch(()=>null)&&(u.customerAccessToken=c.access)}M("account",G()?"logged in":"logged out")}await E(t)}window.Tether.__parts.account=F;})();
|
package/dist/tether.js
CHANGED
package/dist/tether.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(()=>{var hn=Object.defineProperty;var M=(t,e)=>{for(var n in e)hn(t,n,{get:e[n],enumerable:!0})};var Lt={};M(Lt,{DEFAULTS:()=>Xt,cfg:()=>a,configure:()=>Zt,isConfigured:()=>Tt,log:()=>L,reportError:()=>P,warn:()=>U});var Xt={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:null,cartDrawerOpenClass:"is-open",openCartOnAdd:!0,cartFocus:!0,checkoutTarget:"_self",defaultPurchase:"one-time",variantUrl:!1,maxAge:60,lowStock:5,autoMount:!0,observe:!1,astro:!0,partsUrl:null,formatMoney:null,onLayoutChange:null,onCartOpen:null,onCartClose:null,onLineEnter:null,onLineLeave:null,onValueChange:null,onError:null,debug:!1},a={...Xt};function Zt(t={}){return Object.keys(a).forEach(e=>delete a[e]),Object.assign(a,Xt,t),a.domain&&(a.domain=String(a.domain).replace(/^https?:\/\//,"").replace(/\/.*$/,"")),a.storageKey||(a.storageKey=`${a.prefix}:cart:${a.domain}`),a.apiVersion==="unstable"&&U('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),a}var Tt=()=>!!(a.domain&&a.token);function L(...t){a.debug&&console.log(`[${a.prefix}]`,...t)}function U(...t){console.warn(`[${a.prefix}]`,...t)}function P(t,e){if(U(e,t&&t.message?t.message:t),typeof a.onError=="function")try{a.onError(t,e)}catch{}}var ne={};M(ne,{TetherError:()=>E,endpoint:()=>Re,gql:()=>F,request:()=>qt,unwrap:()=>ee,withContext:()=>Ot});var E=class extends Error{constructor(e,{status:n,errors:r,userErrors:i,code:s}={}){super(e),this.name="TetherError",this.code=s||(n?`HTTP_${n}`:"ERROR"),this.status=n,this.errors=r,this.userErrors=i}};function Re(t=a){return`https://${t.domain}/api/${t.apiVersion}/graphql.json`}function Ot(t,e=a){let n=[];if(e.country&&n.push(`country: ${String(e.country).toUpperCase()}`),e.language&&n.push(`language: ${String(e.language).toUpperCase().replace("-","_")}`),!n.length||/@inContext/.test(t))return t;let r=`@inContext(${n.join(", ")})`;return/^\s*\{/.test(t)?`query ${r} ${t.trimStart()}`:t.replace(/^(\s*(?:query|mutation)(?:\s+\w+)?\s*(?:\([^)]*\))?)/,`$1 ${r}`)}var te=t=>new Promise(e=>setTimeout(e,t));async function qt(t,e,n={},{context:r=!0}={}){if(!t.domain||!t.token)throw new E("Tether is not configured: domain and token are required",{code:"NOT_CONFIGURED"});let i=r?Ot(e,t):e,s=t.maxAge??60;s>0&&!/^\s*mutation\b/.test(i)&&(i+=` #${Math.floor(Date.now()/(s*1e3))}`);let o=JSON.stringify({query:i,variables:n}),c=0;for(;;){let u;try{u=await(t.fetch||fetch)(Re(t),{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":t.token},body:o})}catch(m){if(c++<t.retries){await te(300*2**c);continue}throw new E(`Network error: ${m.message}`,{code:"NETWORK"})}if(u.status===430)throw new E("Shopify security rejection (430)",{status:430});if((u.status===429||u.status>=500)&&c++<t.retries){L("retry",u.status,c),await te(300*2**c);continue}let h;try{h=await u.json()}catch{throw new E(`Invalid response (${u.status})`,{status:u.status})}if(h.errors?.length){if(h.errors.some(y=>/quantityAvailable/.test(y.message||""))&&/\bquantityAvailable\b/.test(o))return L("no inventory permission, retrying without quantityAvailable"),qt(t,e.replace(/\bquantityAvailable\b/g,""),n,{context:r});if(h.errors.some(y=>/'warnings'/.test(y.message||""))&&/warnings \{ code message target \}/.test(e))return qt(t,e.replace(/ warnings \{ code message target \}/g,""),n,{context:r});if(h.errors.some(y=>y.extensions?.code==="THROTTLED")&&c++<t.retries){await te(500*2**c);continue}throw new E(h.errors.map(y=>y.message).join(" | "),{status:u.status,errors:h.errors})}if(!u.ok)throw new E(`HTTP ${u.status}`,{status:u.status});return h.data}}var F=(t,e,n)=>qt(a,t,e,n);function ee(t,e){if(!t)throw new E(`${e}: empty response`);let n=t.userErrors||[];if(n.length)throw new E(n.map(r=>r.message).join(" | "),{userErrors:n});return t}var Se={};M(Se,{Cart:()=>A,focusables:()=>Rt,toLineInput:()=>Xe});var ie={};M(ie,{ALLOCATION_FIELDS:()=>Qe,SELLING_PLAN_FIELDS:()=>Be,cartFragment:()=>Nt,collectionFields:()=>re,metafieldIdentifiers:()=>Ke,productFragment:()=>gt});var x="amount currencyCode",tt="url altText width height";function Ke(t=a){return(t.metafields||[]).map(e=>{if(typeof e=="string"){let n=e.indexOf(".");return{namespace:e.slice(0,n),key:e.slice(n+1)}}return e}).filter(e=>e.namespace&&e.key)}function fn(t=a){let e=Ke(t);return e.length?`metafields(identifiers:[${e.map(r=>`{namespace: ${JSON.stringify(r.namespace)}, key: ${JSON.stringify(r.key)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${tt}}}}}`:""}var Be=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${x}}}... on SellingPlanFixedPriceAdjustment{price{${x}}}}}`,Qe=` sellingPlan{id}checkoutChargeAmount{${x}}remainingBalanceChargeAmount{${x}}priceAdjustments{price{${x}}compareAtPrice{${x}}perDeliveryPrice{${x}}unitPrice{${x}}}`;function gt(t=a){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${tt}}images(first:${t.imagesFirst}){nodes{${tt}}}options{name optionValues{name swatch{color image{previewImage{${tt}}}}}}priceRange{minVariantPrice{${x}}maxVariantPrice{${x}}}compareAtPriceRange{minVariantPrice{${x}}maxVariantPrice{${x}}}${fn(t)} sellingPlanGroups(first:${t.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${t.sellingPlansFirst}){nodes{${Be}}}}}variants(first:${t.variantsFirst}){nodes{id title availableForSale currentlyNotInStock quantityAvailable sku barcode selectedOptions{name value}image{${tt}}price{${x}}compareAtPrice{${x}}unitPrice{${x}}sellingPlanAllocations(first:${t.sellingPlansFirst}){nodes{${Qe}}}}}}`}function Nt(){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${x}}totalAmount{${x}}checkoutChargeAmount{${x}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${x}}subtotalAmount{${x}}amountPerQuantity{${x}}compareAtAmountPerQuantity{${x}}}discountAllocations{discountedAmount{${x}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${x}}priceAdjustments{price{${x}}compareAtPrice{${x}}perDeliveryPrice{${x}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping quantityAvailable image{${tt}}price{${x}}compareAtPrice{${x}}selectedOptions{name value}product{id title handle vendor featuredImage{${tt}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function re(){return`
|
|
2
2
|
id handle title description descriptionHtml
|
|
3
3
|
image { ${tt} }
|
|
4
|
-
seo { title description }`}var pe={};M(pe,{clearProductCache:()=>ce,getProduct:()=>nt,getProducts:()=>vt,getRecommendations:()=>bt,hydrateProducts:()=>le,normalizeProductKey:()=>ct,primeProduct:()=>et,refreshProducts:()=>de,takeStale:()=>ue});var _=new Map,Ge=[],se=new Map,ae=!1,yt=0,oe=t=>typeof t=="string"&&t.startsWith("gid://");function ct(t){let e=String(t??"").trim();if(!e)return null;if(oe(e))return e;if(/^\d+$/.test(e))return`gid://shopify/Product/${e}`;let n=e.match(/\/products\/([^/?#]+)/);return n?n[1]:e}function et(t){if(!t)return;let e=Promise.resolve(t);_.set(t.handle,e),_.set(t.id,e)}function nt(t){let e=ct(t);if(!e)return Promise.reject(new E("empty product key",{code:"NOT_FOUND"}));if(_.has(e))return _.get(e);let n=new Promise((r,i)=>{se.set(e,{resolve:r,reject:i}),Ge.push(e),ae||(ae=!0,setTimeout(mn,0))});return _.set(e,n),n}async function mn(){ae=!1;let t=yt,e=Ge.splice(0);if(!e.length)return;let n=e.filter(oe),r=e.filter(f=>!oe(f)),i=[],s=[],o={};n.length&&(i.push("$ids: [ID!]!"),o.ids=n,s.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),r.forEach((f,h)=>{i.push(`$h${h}: String!`),o[`h${h}`]=f,s.push(`h${h}: product(handle: $h${h}) { ...TetherProduct }`)});let c=`query TetherProducts(${i.join(",")}){${s.join(" ")}}${gt()}`;L("fetch products",e);let u=(f,h)=>{let m=se.get(f);se.delete(f),m&&h(m)};try{let f=await F(c,o),h=new Map;(f.byId||[]).forEach(m=>{m&&h.set(m.id,m)}),r.forEach((m,C)=>{f[`h${C}`]&&h.set(m,f[`h${C}`])}),e.forEach(m=>u(m,C=>{if(h.has(m)){let y=h.get(m);t===yt&&(et(y),Ft.set(y.handle,Date.now()),Ft.set(y.id,Date.now())),C.resolve(y)}else{let y=_.get(m);t===yt&&setTimeout(()=>{_.get(m)===y&&_.delete(m)},1e4),C.reject(new E(`Product not found: ${m}`,{code:"NOT_FOUND"}))}}))}catch(f){e.forEach(h=>u(h,m=>{t===yt&&_.delete(h),m.reject(f)}))}}function ce(){_.clear(),yt++,ot.clear(),Ft.clear()}var ot=new Set,Ft=new Map,gn=6e4;function le(t){(t||[]).forEach(e=>{!e?.id||!e.handle||Date.now()-(Ft.get(e.handle)||0)<gn&&_.has(e.handle)||(et(e),ot.add(e.handle),ot.add(e.id))})}function ue(t){let e=ct(t);if(!ot.has(e))return!1;let n=_.get(e);return ot.delete(e),n?.then?.(r=>{ot.delete(r.handle),ot.delete(r.id)}),!0}function de(t){return t.forEach(e=>_.delete(ct(e))),t.map(e=>nt(e))}async function vt({collection:t,query:e,first:n=a.collectionFirst,after:r=null,sortKey:i,reverse:s=!1,filters:o}={}){let c=gt();if(t){let f=await F(`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${re()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}${c}`,{handle:t,first:n,after:r,sortKey:i||void 0,reverse:s,filters:o||void 0});if(!f.collection)throw new E(`Collection not found: ${t}`,{code:"NOT_FOUND"});let{products:h,...m}=f.collection;return h.nodes.forEach(et),{collection:m,products:h.nodes,pageInfo:h.pageInfo}}let u=await F(`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}}}${c}`,{first:n,after:r,query:e||void 0,sortKey:i||void 0,reverse:s});return u.products.nodes.forEach(et),{collection:null,products:u.products.nodes,pageInfo:u.products.pageInfo}}async function bt(t,e="RELATED"){let n=ct(typeof t=="object"?t?.id:t),r=n?.startsWith("gid://"),s=(await F(`query TetherRecs(${r?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${r?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}${gt()}`,r?{id:n,intent:e}:{handle:n,intent:e})).productRecommendations||[];return s.forEach(et),s}var xt={};M(xt,{GID:()=>R,allPlans:()=>G,allocationFor:()=>V,findPlan:()=>wt,hasPlans:()=>yn,planAdjustment:()=>fe,planCheckoutCharge:()=>he,planPrice:()=>$t,planSavings:()=>Dt,plansForVariant:()=>vn,toGid:()=>_t});var R={product:t=>_t(t,"Product"),variant:t=>_t(t,"ProductVariant"),sellingPlan:t=>_t(t,"SellingPlan")};function _t(t,e){let n=String(t??"").trim();return n?n.startsWith("gid://")?n:/^\d+$/.test(n)?`gid://shopify/${e}/${n}`:n:null}function G(t){return(t?.sellingPlanGroups?.nodes||[]).flatMap(n=>(n.sellingPlans?.nodes||[]).map(r=>({...r,group:n})))}function yn(t){return G(t).length>0}function V(t,e){return!t||!e?null:(t.sellingPlanAllocations?.nodes||[]).find(n=>n.sellingPlan?.id===e)||null}function vn(t,e){return G(t).filter(n=>V(e,n.id))}function $t(t,e){let r=V(t,e)?.priceAdjustments?.[0];return r?.perDeliveryPrice||r?.price||t?.price||null}function he(t,e){let n=V(t,e);return n?.checkoutChargeAmount||n?.priceAdjustments?.[0]?.price||t?.price||null}function Dt(t,e){let n=parseFloat(t?.price?.amount),r=parseFloat($t(t,e)?.amount);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r>=n?{amount:null,percentage:0}:{amount:{amount:(n-r).toFixed(2),currencyCode:t.price.currencyCode},percentage:Math.round((1-r/n)*100)}}function fe(t){let e=t?.priceAdjustments?.[0]?.adjustmentValue;if(!e)return null;switch(e.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:e.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:e.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:e.price};default:return null}}function wt(t,e){if(!e)return null;let n=G(t),r=R.sellingPlan(e),i=String(e).trim().toLowerCase();return n.find(s=>s.id===r)||n.find(s=>s.name.toLowerCase()===i)||n.find(s=>(s.options||[]).some(o=>String(o.value).toLowerCase()===i))||null}var xe={};M(xe,{attr:()=>g,busy:()=>B,cdnUrl:()=>Je,dataKey:()=>We,emit:()=>$,formatDate:()=>ye,formatMoney:()=>D,formatPercent:()=>ge,get:()=>p,has:()=>H,hasTemplate:()=>ve,imageUrl:()=>jt,notifyLayoutChanged:()=>J,parseJSONAttr:()=>we,productUrl:()=>At,qsa:()=>w,readText:()=>me,repeat:()=>K,repeatKeyed:()=>be,sameImage:()=>Mt,scoped:()=>rt,sel:()=>l,setImage:()=>j,setSelected:()=>Pt,setText:()=>S,setTextTracked:()=>W,show:()=>T,toAttributes:()=>lt,watchImages:()=>$e});var g=t=>`${a.prefix}-${t}`,l=(t,e)=>e===void 0?`[${g(t)}]`:`[${g(t)}="${e}"]`,p=(t,e)=>t.getAttribute(g(e)),H=(t,e)=>t.hasAttribute(g(e)),We=()=>`data-${a.prefix}-key`;function At(t,e){let n=a.productPath||"/product";if(!/\{(handle|id)\}/.test(n))return`${n.replace(/\/$/,"")}/${t}`;let r=e?String(e).split("/").pop():"";return n.replace(/\{handle\}/g,encodeURIComponent(t||"")).replace(/\{id\}/g,encodeURIComponent(r))}var w=(t,e)=>t?[...t.querySelectorAll(e)]:[],rt=(t,e,n)=>w(t,e).filter(r=>r.closest(n)===t);function $(t,e,n=document){n.dispatchEvent(new CustomEvent(`${a.prefix}:${t}`,{detail:e,bubbles:!0}))}function ge(t,e=a.locale){if(!t)return"";try{return new Intl.NumberFormat(e||void 0,{style:"percent",maximumFractionDigits:0}).format(t/100)}catch{return`${t}%`}}function D(t){if(!t)return"";if(typeof a.formatMoney=="function")return a.formatMoney(t,a.locale);let e=parseFloat(t.amount);if(Number.isNaN(e))return"";try{return new Intl.NumberFormat(a.locale||void 0,{style:"currency",currency:t.currencyCode}).format(e)}catch{return`${t.currencyCode} ${e.toFixed(2)}`}}function ye(t){if(!t)return"";try{return new Date(t).toLocaleDateString(a.locale||void 0)}catch{return""}}function jt(t,{width:e,height:n,crop:r}={}){if(!t)return t;try{let i=new URL(t);return e&&i.searchParams.set("width",String(e)),n&&i.searchParams.set("height",String(n)),r&&i.searchParams.set("crop",r),i.toString()}catch{return t}}function Je(t,e){if(!t||!e)return t;let n=r=>e.getAttribute(r);return jt(t,{width:n("max-width"),height:n("max-height"),crop:n("max-width")||n("max-height")?n("crop"):null})}var Mt=(t,e)=>!!(t&&e)&&t.split("?")[0]===e.split("?")[0];function j(t,e,n){if(!e)return;let r=Je(e,t);if(t.tagName==="IMG"&&Mt(t.getAttribute("src"),r)){n!=null&&!t.getAttribute("alt")&&t.setAttribute("alt",n);return}t.tagName==="IMG"?(t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.setAttribute("src",r),n!=null&&t.setAttribute("alt",n),t.getAttribute("loading")||t.setAttribute("loading","lazy")):t.style.backgroundImage=`url("${r}")`}function S(t,e){let n=e==null?"":String(e);t.tagName==="INPUT"||t.tagName==="TEXTAREA"?t.value=n:t.textContent=n}var me=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA"?t.value:t.textContent;function W(t,e){let n=me(t);S(t,e);let r=me(t);if(n!==r&&t.dataset.tetherSeen&&typeof a.onValueChange=="function")try{a.onValueChange(t,n)}catch{}t.dataset.tetherSeen="1"}function T(t,e){let n="tetherPrevDisplay";if(e){if(t.dataset.tetherShown!==void 0)return;t.dataset.tetherShown="",t.removeAttribute("hidden"),t.dataset[n]!==void 0?(t.style.display=t.dataset[n],delete t.dataset[n]):t.style.display==="none"&&(t.style.display=""),typeof getComputedStyle=="function"&&getComputedStyle(t).display==="none"&&(t.style.display=t.getAttribute(`${a.prefix}-display`)||"block")}else delete t.dataset.tetherShown,t.dataset[n]===void 0&&t.style.display!=="none"&&(t.dataset[n]=t.style.display||""),t.style.display="none"}function Pt(t,e){t.classList.toggle("is-selected",e),t.setAttribute("aria-pressed",e?"true":"false"),t.tagName==="INPUT"&&(t.type==="radio"||t.type==="checkbox")&&(t.checked=e);let n=t.querySelector?.('input[type="radio"],input[type="checkbox"]');n&&(n.checked=e)}var Ut=new WeakMap,ve=t=>!!Ut.get(t);function ze(t){if(!Ut.has(t)){let e=t.firstElementChild?.cloneNode(!0)??null;Ut.set(t,e),t.innerHTML=""}return Ut.get(t)}function K(t,e,n){let r=ze(t);if(!r){e.length&&U("repeater without a template child",t);return}t.innerHTML="",e.forEach((i,s)=>{let o=r.cloneNode(!0);n(o,i,s),t.appendChild(o)})}function be(t,e,n,r,{onEnter:i,onLeave:s}={}){let o=ze(t);if(!o){U("repeater without a template child",t);return}let c=We(),u=`data-${a.prefix}-leaving`,f=()=>[...t.children].filter(b=>b.hasAttribute(c)&&!b.hasAttribute(u)),h=new Map(f().map(b=>[b.getAttribute(c),b])),m=[],C=new Set;e.forEach((b,N)=>{let d=String(n(b,N)),v=h.get(d);v?h.delete(d):(v=o.cloneNode(!0),v.setAttribute(c,d),C.add(v)),r(v,b,N,C.has(v)),m.push(v)});let y=m.filter(b=>!C.has(b)),O=f().filter(b=>y.includes(b));if(!(O.length===y.length&&O.every((b,N)=>b===y[N]))){h.forEach(b=>b.remove()),m.forEach(b=>t.appendChild(b));return}m.forEach((b,N)=>{if(!C.has(b))return;let d=m[N-1];if(d&&d.parentNode===t?d.after(b):t.prepend(b),i)try{i(b)}catch{}}),h.forEach(b=>{b.setAttribute(u,""),b.removeAttribute(c),b.style.pointerEvents="none",b.inert=!0;let N=()=>b.remove();if(s)try{s(b,N)}catch{N()}else N()})}var He=null;function J(t){clearTimeout(He),He=setTimeout(()=>{typeof a.onLayoutChange=="function"?a.onLayoutChange(t):window.ScrollTrigger?.refresh&&window.ScrollTrigger.refresh(),$("layout-changed",{reason:t})},120)}function $e(t,e){let n=w(t,"img").filter(s=>!s.complete);if(!n.length)return;let r=n.length,i=()=>{--r===0&&J(`${e}:images`)};n.forEach(s=>{s.addEventListener("load",i,{once:!0}),s.addEventListener("error",i,{once:!0})})}function B(t,e){return t.getAttribute("aria-busy")==="true"?Promise.resolve():(t.setAttribute("aria-busy","true"),Promise.resolve().then(e).finally(()=>t.removeAttribute("aria-busy")))}function we(t,e){let n=t&&p(t,e);if(!n)return null;try{return JSON.parse(n)}catch{return U(`invalid JSON in ${g(e)}`,t),null}}function lt(t){return t?Array.isArray(t)?t.map(e=>({key:String(e.key),value:String(e.value??"")})):Object.entries(t).map(([e,n])=>({key:e,value:String(n??"")})):[]}function Xe(t,e=1,n={}){let r=typeof t=="object"&&t!==null?t:{variantId:t,quantity:e,...n},i=R.variant(r.merchandiseId||r.variantId||r.id);if(!i)throw new E("add(): variantId is required");let s={merchandiseId:i,quantity:Math.max(1,parseInt(r.quantity??1,10)||1)},o=r.sellingPlanId||r.sellingPlan;o&&(s.sellingPlanId=R.sellingPlan(o));let c=lt(r.attributes);return c.length&&(s.attributes=c),s}function Ye(t,e,n){return`mutation Tether_${t}(${e}){${t}(${n}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${Nt()}`}var bn='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Vt=null,Rt=t=>w(t,bn).filter(e=>e.offsetParent!==null||e===document.activeElement);function Ae(t){w(document,l("cart-open")).forEach(e=>e.setAttribute("aria-expanded",String(t))),w(document,l("cart-drawer")).forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",p(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),e.classList.contains(a.cartDrawerOpenClass)||(e.setAttribute("aria-hidden","true"),a.cartFocus!==!1&&(e.inert=!0))})}var Pe=t=>/does not exist|not found|invalid id/i.test(t?.message||""),A={state:null,_chain:Promise.resolve(),id(){try{return localStorage.getItem(a.storageKey)}catch{return null}},_setId(t){try{t?localStorage.setItem(a.storageKey,t):localStorage.removeItem(a.storageKey)}catch{}},get lines(){return this.state?.lines?.nodes||[]},get count(){return this.state?.totalQuantity||0},lastError:null,customerAccessToken:null,pendingQty:new Map,warnings:[],loaded:!1,_take(t,e){let n=ee(t,e);return this.warnings=(n.warnings||[]).filter((r,i,s)=>s.findIndex(o=>o.message===r.message)===i).map(r=>({...r,message:typeof a.warningText=="function"&&a.warningText(r)||r.message})),this.warnings.length&&$("cart-warning",{warnings:this.warnings}),n.cart},_queue(t){let e=this._chain.then(t,t).then(n=>(this.lastError&&(this.lastError=null,this.render()),n),n=>{throw this.lastError=n,this.render(),$("cart-error",{error:n}),n});return this._chain=e.catch(()=>{}),e},_commit(t,e){this.state=t,t?.id&&this._setId(t.id);try{localStorage.setItem(`${a.storageKey}:seen`,`${Date.now()}|${t?.totalQuantity||0}`)}catch{}return this.render(),$("cart-updated",{cart:t,reason:e}),t},async init(){let t=this.id();if(!t)return this.state=null,this.loaded=!0,this.render(),$("cart-updated",{cart:null,reason:"load"}),null;if(!this.loaded)try{let e=(localStorage.getItem(`${a.storageKey}:seen`)||"").split("|")[1];e&&w(document,l("cart-count")).forEach(n=>{/^\s*0?\s*$/.test(n.textContent)&&(n.textContent=e)})}catch{}try{let e=await F(`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${Nt()}`,{id:t});e.cart?this.state=e.cart:(this._setId(null),this.state=null)}catch(e){P(e,"cart load failed"),this.lastError=e,Pe(e)&&this._setId(null),this.state=null}return this.loaded=!0,this.render(),$("cart-updated",{cart:this.state,reason:"load"}),this.state},async _create(t={}){let e=a.country||this.customerAccessToken?{...a.country?{countryCode:String(a.country).toUpperCase()}:{},...this.customerAccessToken?{customerAccessToken:this.customerAccessToken}:{}}:void 0,n=await F(Ye("cartCreate","$input: CartInput!","input: $input"),{input:{buyerIdentity:e,...t}});return this._take(n.cartCreate,"cartCreate")},async _mutate(t,e,n,r,i){let s=this.id();if(!s)return i?this._create(i):null;try{let o=await F(Ye(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${n}`),{...r,cartId:s});return this._take(o[t],t)}catch(o){if(i&&Pe(o))return L("cart expired, creating a new one"),this._setId(null),this._create(i);throw o}},add(t,e=1,n={}){let r=(Array.isArray(t)?t:[t]).map(i=>Xe(i,e,n));return this._queue(async()=>{let i=await this._mutate("cartLinesAdd","$lines: [CartLineInput!]!","lines: $lines",{lines:r},{lines:r});return this._commit(i,"add"),$("added",{cart:i,lines:r}),a.openCartOnAdd&&this.open(),i})},updateLine(t,e){let n=typeof e=="number"?{quantity:e}:{...e};if(n.quantity!==void 0&&n.quantity<=0)return this.removeLine(t);let r={id:t};return n.quantity!==void 0&&(r.quantity=n.quantity),"sellingPlanId"in n&&(r.sellingPlanId=n.sellingPlanId?R.sellingPlan(n.sellingPlanId):null),n.attributes&&(r.attributes=lt(n.attributes)),(n.merchandiseId||n.variantId)&&(r.merchandiseId=R.variant(n.merchandiseId||n.variantId)),this._queue(async()=>this._commit(await this._mutate("cartLinesUpdate","$lines: [CartLineUpdateInput!]!","lines: $lines",{lines:[r]}),"update"))},changeQuantity(t,e){let n=this.lines.find(s=>s.id===t);if(!n)return Promise.resolve(this.state);let r=Math.max(0,(this.pendingQty.get(t)?.qty??n.quantity)+e),i={qty:r,done:!1};return this.pendingQty.set(t,i),this.render(),$("cart-updated",{cart:this.state,reason:"pending"}),this.updateLine(t,r).finally(()=>{this.pendingQty.get(t)===i&&(this.pendingQty.delete(t),this.render(),$("cart-updated",{cart:this.state,reason:"settled"}))})},quantityOf(t){return this.pendingQty.get(t.id)?.qty??t.quantity},removeLine(t){let e=Array.isArray(t)?t:[t];return this._queue(async()=>this._commit(await this._mutate("cartLinesRemove","$lineIds: [ID!]!","lineIds: $lineIds",{lineIds:e}),"remove"))},clear(){let t=this.lines.map(e=>e.id);return t.length?this.removeLine(t):Promise.resolve(this.state)},setNote(t){return this._queue(async()=>this._commit(await this._mutate("cartNoteUpdate","$note: String!","note: $note",{note:t??""},{note:t??""}),"note"))},setAttributes(t){let e=new Map((this.state?.attributes||[]).map(r=>[r.key,r.value]));lt(t).forEach(r=>e.set(r.key,r.value));let n=[...e].filter(([,r])=>r!=="").map(([r,i])=>({key:r,value:i}));return this._queue(async()=>this._commit(await this._mutate("cartAttributesUpdate","$attributes: [AttributeInput!]!","attributes: $attributes",{attributes:n},{attributes:n}),"attributes"))},setDiscountCodes(t){let e=(Array.isArray(t)?t:[t]).map(n=>String(n).trim()).filter(Boolean);return this._queue(async()=>this._commit(await this._mutate("cartDiscountCodesUpdate","$discountCodes: [String!]!","discountCodes: $discountCodes",{discountCodes:e},{discountCodes:e}),"discount"))},async applyDiscount(t){let e=(this.state?.discountCodes||[]).map(i=>i.code),n=await this.setDiscountCodes([...new Set([...e,t])]);if((n?.discountCodes||[]).find(i=>i.code.toLowerCase()===String(t).toLowerCase())?.applicable)return n;throw await this.removeDiscount(t).catch(()=>{}),new E(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let e=String(t).toLowerCase();return this.setDiscountCodes((this.state?.discountCodes||[]).map(n=>n.code).filter(n=>n.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return this._queue(async()=>{let n=await this._mutate("cartBuyerIdentityUpdate","$buyerIdentity: CartBuyerIdentityInput!","buyerIdentity: $buyerIdentity",{buyerIdentity:t},e?{buyerIdentity:t}:null).catch(r=>{if(e||!Pe(r))throw r;return this._setId(null),null});return this._commit(n,"buyer-identity")})},async checkout(t=a.checkoutTarget){let e=this.id();if(!e||this.state&&!this.count)return null;let n=t==="_blank"?window.open("","_blank"):null;if(n)try{n.opener=null}catch{}try{let r=await F("query TetherCheckout($id: ID!) { cart(id: $id) { checkoutUrl } }",{id:e}),i=this.beforeCheckout&&await this.beforeCheckout().catch(()=>null)||r.cart?.checkoutUrl;if(i&&this.customerAccessToken&&(i+=`${i.includes("?")?"&":"?"}logged_in=true`),!i)throw new E("No checkoutUrl (cart empty or expired)");return $("checkout",{url:i,cart:this.state}),n&&!n.closed?n.location.href=i:window.location.href=i,i}catch(r){return n&&n.close(),P(r,"checkout failed"),null}},drawers(){return w(document,l("cart-drawer"))},_open:!1,isOpen(){let t=this.drawers();return t.length?t.some(e=>e.classList.contains(a.cartDrawerOpenClass)):this._open},open(){if(this.isOpen())return;this._open=!0;let t=this.drawers().filter(e=>p(e,"cart-drawer")!=="manual");t.forEach(e=>{e.inert=!1,e.classList.add(a.cartDrawerOpenClass),e.setAttribute("aria-hidden","false")}),Ae(!0),a.cartFocus!==!1&&t[0]&&(Vt=document.activeElement,setTimeout(()=>{let e=Rt(t[0])[0]||t[0];e===t[0]&&!t[0].hasAttribute("tabindex")&&(t[0].tabIndex=-1),e.focus?.({preventScroll:!0})},60)),typeof a.onCartOpen=="function"&&a.onCartOpen(t),$("cart-toggled",{open:!0})},close(){if(!this.isOpen())return;this._open=!1;let t=this.drawers(),e=t.some(n=>n.contains(document.activeElement));t.forEach(n=>{n.classList.remove(a.cartDrawerOpenClass),n.setAttribute("aria-hidden","true"),a.cartFocus!==!1&&(n.inert=!0)}),Ae(!1),e&&Vt?.isConnected&&Vt.focus({preventScroll:!0}),Vt=null,typeof a.onCartClose=="function"&&a.onCartClose(t),$("cart-toggled",{open:!1})},toggle(){this.isOpen()?this.close():this.open()},subscribe(t){let e=()=>t(this.state,{open:this.isOpen(),count:this.count,loaded:this.loaded,warnings:this.warnings}),n=()=>e();return["cart-updated","cart-toggled"].forEach(r=>document.addEventListener(`${a.prefix}:${r}`,n)),e(),()=>["cart-updated","cart-toggled"].forEach(r=>document.removeEventListener(`${a.prefix}:${r}`,n))},render(){let t=this.state,e=t?t.totalQuantity:0,n=s=>t?D(t.cost?.[s]):"";Ae(this.isOpen()),w(document,l("cart-count")).forEach(s=>W(s,e)),w(document,l("cart-subtotal")).forEach(s=>W(s,n("subtotalAmount"))),w(document,l("cart-total")).forEach(s=>W(s,n("totalAmount"))),w(document,l("cart-checkout-charge")).forEach(s=>W(s,n("checkoutChargeAmount")));let r=this.lines.some(s=>s.sellingPlanAllocation),i={"cart-empty":e===0,"cart-filled":e>0,"cart-has-subscription":r,"cart-no-subscription":!r,"cart-has-discount":(t?.discountCodes||[]).some(s=>s.applicable),"cart-error":!!this.lastError,"cart-warning":this.warnings.length>0};w(document,l("cart-warning")).forEach(s=>W(s,[...new Set(this.warnings.map(o=>o.message))].join(" "))),w(document,l("show")).forEach(s=>{let o=p(s,"show");o in i&&!s.closest(l("product"))&&T(s,i[o])}),w(document,l("checkout")).forEach(s=>{s.classList.toggle("is-disabled",!e),s.setAttribute("aria-disabled",String(!e))}),w(document,`textarea${l("cart-note")},input${l("cart-note")}`).forEach(s=>{document.activeElement!==s&&(s.value=t?.note||"")}),w(document,l("cart-discounts")).forEach(s=>{K(s,t?.discountCodes||[],(o,c)=>{o.setAttribute(g("discount-code"),c.code);let u=o.querySelector(l("discount","code"))||(o.firstElementChild?null:o);u&&S(u,c.code),o.classList.toggle("is-inapplicable",!c.applicable)})}),w(document,l("cart-lines")).forEach(s=>{be(s,this.lines,o=>o.id,(o,c)=>wn(o,c),{onEnter:a.onLineEnter,onLeave:a.onLineLeave})}),t&&J("cart")}};function $n(t,e){let n=t.merchandise||{},r=t.sellingPlanAllocation?.sellingPlan;switch(e){case"title":return n.product?.title;case"product-title":return n.product?.title;case"variant-title":return n.title==="Default Title"?"":n.title;case"options":return(n.selectedOptions||[]).filter(i=>i.value!=="Default Title").map(i=>`${i.name}: ${i.value}`).join(", ");case"vendor":return n.product?.vendor;case"sku":return n.sku;case"price":return D(t.cost?.amountPerQuantity||n.price);case"compare-at-price":return D(t.cost?.compareAtAmountPerQuantity||n.compareAtPrice);case"line-total":return D(t.cost?.totalAmount);case"line-subtotal":return D(t.cost?.subtotalAmount);case"quantity":return A.quantityOf(t);case"plan":return r?.name||"";case"plan-description":return r?.description||"";case"components":return(t.lineComponents||[]).map(i=>`${i.quantity} \xD7 ${i.merchandise?.product?.title||""}`).join(", ");default:if(e.startsWith("attribute:")){let i=e.slice(10);return(t.attributes||[]).find(s=>s.key===i)?.value||""}return}}function wn(t,e){let n=e.merchandise||{},r=!!e.sellingPlanAllocation;t.setAttribute(g("line-id"),e.id),t.classList.toggle("is-subscription",r),w(t,l("line")).forEach(c=>{let u=p(c,"line");if(u==="image")return j(c,n.image?.url||n.product?.featuredImage?.url,n.product?.title);if(u==="url"){let h=At(n.product?.handle,n.product?.id),m=new URLSearchParams;n.id&&m.set("variant",String(n.id).split("/").pop());let C=e.sellingPlanAllocation?.sellingPlan?.id;C&&m.set("selling_plan",C.split("/").pop());let y=m.toString();return c.setAttribute("href",y?`${h}${h.includes("?")?"&":"?"}${y}`:h)}let f=$n(e,u);f!==void 0&&W(c,f)});let i=A.warnings.find(c=>c.target===e.id);t.classList.toggle("is-warning",!!i);let s=A.pendingQty.has(e.id);t.classList.toggle("is-busy",s),s?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),w(t,l("line","warning")).forEach(c=>W(c,i?.message||""));let o={subscription:r,"one-time":!r,"on-sale":parseFloat(e.cost?.compareAtAmountPerQuantity?.amount)>parseFloat(e.cost?.amountPerQuantity?.amount),"has-components":(e.lineComponents||[]).length>0,warning:!!i};w(t,l("line-show")).forEach(c=>{let u=p(c,"line-show");u in o&&T(c,o[u])}),w(t,`select${l("line-plan")}`).forEach(c=>{let u=n.product?.handle;u&&nt(u).then(f=>{let h=G(f),C=[...!f.requiresSellingPlan&&p(c,"line-plan")!=="subscription-only"?[{value:"",label:c.getAttribute(g("one-time-label"))||"One-time purchase"}]:[],...h.map(O=>({value:O.id,label:O.name}))],y=C.map(O=>O.value).join("|");c.dataset.tetherSig!==y&&(c.innerHTML="",C.forEach(O=>{let at=document.createElement("option");at.value=O.value,at.textContent=O.label,c.appendChild(at)}),c.dataset.tetherSig=y),c.value=e.sellingPlanAllocation?.sellingPlan?.id||"",T(c,h.length>0)}).catch(f=>P(f,"line plan options"))})}var ke={};M(ke,{ProductScope:()=>St,rememberOptionNames:()=>Gt,scopes:()=>it});var Ce={};M(Ce,{STATUS_KEYS:()=>Bt,boundary:()=>Kt,isNotFound:()=>ht,ownedBy:()=>Ee,resolveProductKey:()=>z,setScopeStatus:()=>Y});function z(t,e=window.location,n="product"){let r=(p(t,n)||"").trim();if(!r.toLowerCase().startsWith("url:"))return{key:r||null,fromUrl:!1,raw:r};let i=r.slice(4).trim(),s=null;if(i.toLowerCase()==="path"){let o=e.pathname.split("/").filter(Boolean);s=o.length?xn(o[o.length-1]):null}else s=new URLSearchParams(e.search).get(i||"handle");return s=s&&s.trim()?s.trim():null,{key:s,fromUrl:!0,raw:r}}function xn(t){try{return decodeURIComponent(t)}catch{return t}}var Bt=["loading","ready","error","not-found"],ht=t=>t?.code==="NOT_FOUND",Kt=()=>["product","collection","products","recommendations"].map(t=>l(t)).join(","),Ee=(t,e)=>t===e||t.parentElement?.closest(Kt())===e;function Y(t,e,n){let r=e==="not-found";t.setAttribute(g("state"),r?"error":e),e==="error"||r?t.setAttribute(g("error"),r?"not-found":n?.code||"error"):t.removeAttribute(g("error")),rt(t,l("show"),Kt()).forEach(i=>{let s=p(i,"show");Bt.includes(s)&&T(i,s===e)}),(e==="error"||r)&&rt(t,l("add-to-cart"),Kt()).forEach(i=>{i.classList.add("is-disabled"),i.setAttribute("aria-disabled","true"),"disabled"in i&&(i.disabled=!0)})}var it=new WeakMap,Ze=()=>l("product");function An(t,e){let n=e.indexOf("."),r=e.slice(0,n),i=e.slice(n+1);return(t.metafields||[]).find(o=>o&&o.namespace===r&&o.key===i)||null}var Qt=new Map;function Gt(t){(t||[]).forEach(e=>{e?.handle&&!Qt.has(e.handle)&&Qt.set(e.handle,(e.options||[]).map(n=>n.name))})}var St=class{constructor(e,n){this.root=e,this.product=n,this.selected={},this.variant=null,this.quantity=Math.max(0,parseInt(p(e,"quantity")??"1",10)||(H(e,"quantity")?0:1)),this.plans=G(n),this.purchase="one-time",this.planId=null,it.set(e,this),e.setAttribute(g("state"),"ready"),e.removeAttribute(g("error")),this.initSelection(),this.initPurchase(),this.renderProduct(),this.bind(),this.renderVariant(),$e(e,"product"),J("product"),$("product-ready",{product:n,scope:this},e)}update(e){let n=this.variant?.id;this.product=e,this.plans=G(e),this.planId&&!this.plans.some(i=>i.id===this.planId)&&(this.planId=this.plans[0]?.id||null),!this.plans.length&&this.purchase==="subscription"&&(this.purchase="one-time");let r=e.variants.nodes.find(i=>i.id===n);r&&(this.selected={},r.selectedOptions.forEach(i=>{this.selected[i.name]=i.value})),this.root.setAttribute(g("state"),"ready"),this.root.removeAttribute(g("error")),this.renderProduct(),this.renderVariant(),J("product"),$("product-updated",{product:e,scope:this},this.root)}$(e){let n=rt(this.root,e,Ze());return this.root.matches(e)?[this.root,...n]:n}optName(e){let n=this.product?.options||[];if(!e||n.some(i=>i.name===e))return e;let r=(Qt.get(this.product.handle)||[]).indexOf(e);return r>=0&&n[r]?n[r].name:e}initSelection(){let e=this.product.variants.nodes,n=e.find(i=>i.availableForSale)||e[0];n&&n.selectedOptions.forEach(i=>{this.selected[i.name]=i.value});let r=new URLSearchParams(window.location.search).get("variant")||p(this.root,"variant");if(r){let i=R.variant(r),s=e.find(o=>o.id===i);s&&(this.selected={},s.selectedOptions.forEach(o=>{this.selected[o.name]=o.value}))}}initPurchase(){if(!this.plans.length)return;let e=new URLSearchParams(window.location.search),n=wt(this.product,e.get("selling_plan")),r=wt(this.product,p(this.root,"default-plan"));this.planId=(n||r||this.plans[0]).id;let i=n?"subscription":p(this.root,"default-purchase")||a.defaultPurchase;this.purchase=this.product.requiresSellingPlan||i==="subscription"?"subscription":"one-time"}findVariant(){return this.product.variants.nodes.find(e=>e.selectedOptions.every(n=>this.selected[n.name]===n.value))||null}isValueAvailable(e,n){return this.product.variants.nodes.some(r=>r.availableForSale&&r.selectedOptions.every(i=>i.name===e?i.value===n:this.selected[i.name]===i.value))}get plan(){return this.plans.find(e=>e.id===this.planId)||null}get subscriptionAvailable(){return!!(this.variant&&this.plans.some(e=>V(this.variant,e.id)))}get isSubscription(){return this.purchase==="subscription"&&!!V(this.variant,this.planId)}getLine(){if(!this.variant)return null;let e={merchandiseId:this.variant.id,quantity:this.quantity};this.isSubscription&&(e.sellingPlanId=this.planId);let n=this.collectAttributes();return n.length&&(e.attributes=n),e}collectAttributes(){let e=lt(we(this.root,"line-attributes")),n=this.$(l("line-attribute")).map(r=>{let i=p(r,"line-attribute"),s;return r.type==="checkbox"?s=r.checked?r.value&&r.value!=="on"?r.value:"Yes":"":r.type==="radio"?s=r.checked?r.value:null:s=r.value,s==null||s===""?null:{key:i,value:String(s)}}).filter(Boolean);return[...e,...n]}select(e,n){if(this.selected[e]===n)return;let r=this.product.variants.nodes.filter(s=>s.selectedOptions.some(o=>o.name===e&&o.value===n));if(!r.length)return;let i={...this.selected,[e]:n};if(!r.some(s=>s.selectedOptions.every(o=>i[o.name]===o.value))){let s=c=>c.selectedOptions.filter(u=>u.name!==e&&this.selected[u.name]===u.value).length*2+(c.availableForSale?1:0);r.reduce((c,u)=>s(u)>s(c)?u:c).selectedOptions.forEach(c=>{i[c.name]=c.value})}this.selected=i,this.renderVariant()}selectVariant(e){let n=this.product.variants.nodes.find(r=>r.id===R.variant(e));n&&(this.selected={},n.selectedOptions.forEach(r=>{this.selected[r.name]=r.value}),this.renderVariant())}setPurchase(e){let n=e==="subscription"?"subscription":"one-time";n==="one-time"&&this.product.requiresSellingPlan||this.purchase!==n&&(this.purchase=n,this.renderVariant())}selectPlan(e){let n=wt(this.product,e);n&&(this.planId=n.id,this.purchase="subscription",this.renderVariant())}setQuantity(e){let n=H(this.root,"quantity")?0:1;this.quantity=Math.max(n,parseInt(e,10)||0),this.$(l("qty")).forEach(r=>S(r,this.quantity)),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let e=this.getLine();if(!e||e.quantity<1)return null;let n=await A.add(e);return $("product-added",{product:this.product,variant:this.variant,line:e},this.root),n}bind(){let e=n=>n&&n.closest(Ze())===this.root;this.root.addEventListener("click",n=>{let r=n.target;if(!r?.closest)return;let i=r.closest(l("option-value"));if(e(i)&&i.closest(l("option-list"))){n.preventDefault(),this.select(this.optName(p(i.closest(l("option-list")),"option-list")),p(i,"option-value"));return}let s=r.closest(l("plan-value"));if(e(s)){n.preventDefault(),this.selectPlan(p(s,"plan-value"));return}let o=r.closest(`${l("purchase")}:not(select)`);if(e(o)){o.tagName!=="INPUT"&&n.preventDefault(),this.setPurchase(p(o,"purchase"));return}let c=r.closest(l("qty-plus"));if(e(c)){n.preventDefault(),this.setQuantity(this.quantity+1);return}let u=r.closest(l("qty-minus"));if(e(u)){n.preventDefault(),this.setQuantity(this.quantity-1);return}let f=r.closest(l("add-to-cart"));e(f)&&(n.preventDefault(),this.onAddClick(f))}),this.root.addEventListener("change",n=>{let r=n.target;e(r)&&(r.matches(`select${l("option")}`)?this.select(this.optName(p(r,"option")),r.value):r.matches(`select${l("variant-select")}`)?this.selectVariant(r.value):r.matches(`select${l("plan")}`)?r.value?this.selectPlan(r.value):this.setPurchase("one-time"):r.matches(`select${l("purchase")}`)?this.setPurchase(r.value):r.matches(l("qty"))&&this.setQuantity(r.value))})}onAddClick(e){let n=e.querySelector(l("add-label"))||e,r=p(e,"adding-text"),i=s=>S(n,s);n.dataset.tetherLabel===void 0&&(n.dataset.tetherLabel=n.tagName==="INPUT"?n.value:n.textContent),B(e,async()=>{r&&i(r);try{await this.addToCart()}catch(s){P(s,"add to cart failed"),$("error",{error:s,context:"add-to-cart"},this.root)}finally{r&&i(n.dataset.tetherLabel)}}).then(()=>{this.renderVariant()})}renderProduct(){let e=this.product;Qt.has(e.handle)||this.$(`${l("option-list")},select${l("option")}`).map(i=>p(i,"option-list")||p(i,"option")).some(i=>e.options.some(s=>s.name===i))&&Gt([e]);let n=this.product;this.$(l("bind")).forEach(r=>{let i=p(r,"bind")||"",s={title:n.title,"description-text":n.description,vendor:n.vendor,type:n.productType,handle:n.handle}[i];if(s!==void 0)return S(r,s);switch(i){case"description":r.innerHTML=n.descriptionHtml||"";return;case"published-at":return S(r,ye(n.publishedAt));case"min-price":return S(r,D(n.priceRange.minVariantPrice));case"max-price":return S(r,D(n.priceRange.maxVariantPrice));case"featured-image":return j(r,n.featuredImage?.url,n.featuredImage?.altText||n.title);case"url":case"link":r.setAttribute("href",At(n.handle,n.id)),i==="url"&&!r.firstElementChild&&!r.textContent.trim()&&S(r,n.title);return;case"images":{let o=[...r.children].map(c=>c.tagName==="IMG"?c:c.querySelector("img"));if(!ve(r)&&o.length===n.images.nodes.length&&o.every((c,u)=>Mt(c?.getAttribute("src"),n.images.nodes[u].url)))return}return K(r,n.images.nodes,(o,c)=>{let u=o.matches(`img,${l("bind","image")}`)?o:o.querySelector("img")||o;j(u,c.url,c.altText||n.title)});case"tags":{let o=(r.getAttribute("exclude")||"").split(",").map(c=>c.trim()).filter(Boolean);return K(r,n.tags.filter(c=>!o.includes(c)),(c,u)=>S(c,u))}default:if(/^image:\d+$/.test(i)){let o=n.images.nodes[i.slice(6)-1]||n.featuredImage;return j(r,o?.url,o?.altText||n.title)}if(i.startsWith("metafield:")){let o=An(n,i.slice(10));return o?o.reference?.image?j(r,o.reference.image.url,o.reference.image.altText):(/^(rich_text|multi_line_text)_field$/.test(o.type)&&(r.style.whiteSpace="pre-line"),S(r,o.value)):S(r,"")}return}}),this.$(l("option-list")).forEach(r=>{let i=this.optName(p(r,"option-list")),s=n.options.find(o=>o.name===i);return!s||s.optionValues.length<=1&&H(r,"hide-single")?T(r,!1):K(r,s.optionValues,(o,c)=>{o.setAttribute(g("option-value"),c.name);let u=o.querySelector(l("bind","option-value"));u?S(u,c.name):o.firstElementChild||S(o,c.name);let f=o.querySelector(l("bind","swatch"));f&&c.swatch?.color&&(f.style.backgroundColor=c.swatch.color),f&&c.swatch?.image?.previewImage&&j(f,c.swatch.image.previewImage.url,c.name)})}),this.$(`select${l("option")}`).forEach(r=>{let i=n.options.find(s=>s.name===this.optName(p(r,"option")));if(!i)return T(r,!1);r.innerHTML="",i.optionValues.forEach(s=>r.appendChild(new Option(s.name,s.name)))}),this.$(`select${l("variant-select")}`).forEach(r=>{r.innerHTML="",n.variants.nodes.forEach(i=>r.appendChild(new Option(i.title,i.id)))}),this.$(l("plan-list")).forEach(r=>{let i=(p(r,"plan-list")||"").trim(),s=["","true","all","*"].includes(i.toLowerCase())?null:i,o=this.plans.filter(c=>!s||c.group.name===s);K(r,o,(c,u)=>{c.setAttribute(g("plan-value"),u.id),!c.firstElementChild&&!c.querySelector(l("plan-bind"))&&S(c,u.name)})}),this.$(`select${l("plan")}`).forEach(r=>{r.innerHTML="",!n.requiresSellingPlan&&p(r,"plan")!=="subscription-only"&&r.appendChild(new Option(r.getAttribute(g("one-time-label"))||"One-time purchase","")),this.plans.forEach(i=>r.appendChild(new Option(i.name,i.id)))})}renderVariant(){let e=this.product,n=this.findVariant();if(n||([n]=e.variants.nodes,n&&(this.selected={},n.selectedOptions.forEach(d=>{this.selected[d.name]=d.value}))),this.variant=n,!n)return;if(this.plans.length&&!V(n,this.planId)){let d=this.plans.find(v=>V(n,v.id));d&&(this.planId=d.id)}let r=this.isSubscription,i=n.price,s=this.planId?$t(n,this.planId):null,o=r?s:i,c=r&&V(n,this.planId)?.priceAdjustments?.[0]?.compareAtPrice||n.compareAtPrice,u=c&&parseFloat(c.amount)>parseFloat(o.amount),f=u?Math.round((1-parseFloat(o.amount)/parseFloat(c.amount))*100):0,h=this.planId?Dt(n,this.planId):{amount:null,percentage:0},m=this.plan,C={amount:(parseFloat(o.amount)*Math.max(1,this.quantity)).toFixed(2),currencyCode:o.currencyCode},y=D,O=d=>ge(d),at={price:()=>y(o),"total-price":()=>y(C),"one-time-price":()=>y(i),"subscription-price":()=>y(s),"subscription-savings":()=>O(h.percentage),"subscription-savings-amount":()=>y(h.amount),"checkout-charge":()=>{let d=r?he(n,this.planId):o;return d&&y({amount:(parseFloat(d.amount)*Math.max(1,this.quantity)).toFixed(2),currencyCode:d.currencyCode})},"plan-name":()=>m?.name,"plan-description":()=>m?.description,"plan-group":()=>m?.group?.name,"compare-at-price":()=>u?y(c):"","unit-price":()=>y(n.unitPrice),"discount-percentage":()=>`${f}%`,"discount-amount":()=>u?y({amount:String(parseFloat(c.amount)-parseFloat(o.amount)),currencyCode:o.currencyCode}):"","variant-title":()=>n.title,"variant-id":()=>n.id,sku:()=>n.sku,barcode:()=>n.barcode,stock:()=>n.quantityAvailable,quantity:()=>this.quantity};this.$(l("bind")).forEach(d=>{let v=p(d,"bind");v==="variant-image"?j(d,n.image?.url||e.featuredImage?.url,n.image?.altText||e.title):at[v]&&S(d,at[v]())}),this.$(l("option-selected")).forEach(d=>S(d,this.selected[this.optName(p(d,"option-selected"))]||"")),this.$(l("option-list")).forEach(d=>{let v=this.optName(p(d,"option-list"));w(d,l("option-value")).forEach(k=>{let X=p(k,"option-value");Pt(k,this.selected[v]===X);let I=!this.isValueAvailable(v,X);k.classList.toggle("is-unavailable",I),k.setAttribute("data-unavailable",I?"true":"false")})}),this.$(`select${l("option")}`).forEach(d=>{d.value=this.selected[this.optName(p(d,"option"))]||""}),this.$(`select${l("variant-select")}`).forEach(d=>{d.value=n.id}),this.$(l("purchase")).forEach(d=>{if(d.tagName==="SELECT"){d.value=this.purchase;return}let v=p(d,"purchase");Pt(d,v===this.purchase);let k=v==="subscription"?!this.subscriptionAvailable:e.requiresSellingPlan;d.classList.toggle("is-unavailable",k)}),this.$(l("plan-value")).forEach(d=>{let v=p(d,"plan-value"),k=this.plans.find(I=>I.id===v),X=!!V(n,v);Pt(d,r&&v===this.planId),d.classList.toggle("is-unavailable",!X),w(d,l("plan-bind")).forEach(I=>{let Z=fe(k),Me=Dt(n,v),dn=p(I,"plan-bind"),Ve={name:()=>k?.name,option:()=>(k?.options||[]).map(pn=>pn.value).join(", "),description:()=>k?.description,price:()=>y($t(n,v)),savings:()=>O(Me.percentage),"savings-amount":()=>y(Me.amount),adjustment:()=>Z?Z.type==="percentage"?`${Z.value}%`:y(Z.value):""}[dn];Ve&&S(I,Ve())})}),this.$(`select${l("plan")}`).forEach(d=>{d.value=r?this.planId:""});let b=n.quantityAvailable!=null&&n.quantityAvailable>0&&n.quantityAvailable<=(a.lowStock??5),N={"in-stock":n.availableForSale,"out-of-stock":!n.availableForSale,backorder:n.availableForSale&&n.currentlyNotInStock,"on-sale":!!u,"not-on-sale":!u,"has-variants":e.variants.nodes.length>1,"single-variant":e.variants.nodes.length===1,"low-stock":b,"plenty-in-stock":n.availableForSale&&!b,"subscription-available":this.subscriptionAvailable,"subscription-unavailable":!this.subscriptionAvailable,"subscription-only":!!e.requiresSellingPlan,"one-time-available":!e.requiresSellingPlan,"subscription-selected":r,"one-time-selected":!r,"has-savings":r?h.percentage>0:!!u,loading:!1,ready:!0,error:!1,"not-found":!1};this.$(l("show")).forEach(d=>{let v=p(d,"show");v in N&&(Bt.includes(v)&&!Ee(d,this.root)||T(d,N[v]))}),this.root.classList.toggle("is-subscription",r),this.root.setAttribute(g("purchase-mode"),r?"subscription":"one-time"),this.$(l("add-to-cart")).forEach(d=>{let v=!n.availableForSale;d.classList.toggle("is-disabled",v),d.setAttribute("aria-disabled",String(v)),"disabled"in d&&(d.disabled=v);let k=p(d,"soldout-text"),X=p(d,"subscribe-text");if(k||X){let I=d.querySelector(l("add-label"))||d;I.dataset.tetherLabel===void 0&&(I.dataset.tetherLabel=I.tagName==="INPUT"?I.value:I.textContent);let Z=I.dataset.tetherLabel;r&&X&&(Z=X),v&&k&&(Z=k),d.getAttribute("aria-busy")!=="true"&&S(I,Z)}}),$("variant-changed",{product:e,variant:n,selected:{...this.selected},purchase:this.purchase,sellingPlanId:r?this.planId:null},this.root)}};var Ie={};M(Ie,{ListScope:()=>Et,listSelector:()=>ut});var ut=()=>`${l("collection")},${l("products")},${l("recommendations")}`,Et=class{constructor(e){this.root=e,this.products=[],this.pageInfo=null,this.collection=null,Y(e,"loading"),e.addEventListener("click",n=>{let r=n.target.closest?.(l("load-more"));r&&r.closest(ut())===e&&(n.preventDefault(),B(r,()=>this.load(!0)))})}$(e){return rt(this.root,e,ut())}options(){let e=this.root,n={first:parseInt(p(e,"limit")||"",10)||void 0,sortKey:p(e,"sort")||void 0,reverse:p(e,"reverse")==="true"};return H(e,"collection")?n.collection=p(e,"collection"):n.query=p(e,"products")||"",n}async load(e=!1){let n=this.loadToken=(this.loadToken||0)+1,r=()=>n!==this.loadToken;try{if(H(this.root,"recommendations")){let{key:i}=z(this.root,window.location,"recommendations"),s=this.root.closest(l("product"));if(!i&&s&&({key:i}=z(s)),!i)throw new E("No product for recommendations",{code:"NOT_FOUND"});let o=await bt(i,p(this.root,"intent")||"RELATED");if(r())return;let c=parseInt(p(this.root,"limit")||"",10);this.products=c?o.slice(0,c):o}else{let i=await vt({...this.options(),after:e?this.pageInfo?.endCursor:null});if(r())return;this.collection=i.collection,this.pageInfo=i.pageInfo,this.products=e?[...this.products,...i.products]:i.products}this.render(),Y(this.root,"ready"),$("list-ready",{products:this.products,collection:this.collection},this.root)}catch(i){if(r())return;e||Y(this.root,ht(i)?"not-found":"error",i),ht(i)&&H(this.root,"recommendations")||P(i,"list load failed"),$("error",{error:i,context:"list"},this.root)}}render(){let e=this.collection;this.$(l("collection-bind")).forEach(r=>{switch(p(r,"collection-bind")){case"title":return S(r,e?.title||"");case"description":r.innerHTML=e?.descriptionHtml||"";return;case"image":return j(r,e?.image?.url,e?.image?.altText||e?.title);case"count":return S(r,this.products.length);default:return}}),this.$(l("list")).forEach(r=>{K(r,this.products,(i,s)=>{i.setAttribute(g("product"),s.handle),i.removeAttribute(g("state"))}),$("list-rendered",{container:r},this.root)});let n=this.products.length===0;this.$(l("show")).forEach(r=>{let i=p(r,"show");i==="list-empty"&&T(r,n),i==="list-filled"&&T(r,!n)}),this.$(l("load-more")).forEach(r=>T(r,!!this.pageInfo?.hasNextPage)),J("list")}};var Oe={};M(Oe,{hydrateFromPage:()=>qe,liveLists:()=>mt,liveProducts:()=>ft,mountProduct:()=>zt,mountedLists:()=>Wt,mountedProducts:()=>Ct,pruneLive:()=>Jt,retryFailed:()=>Te,settleMarket:()=>Yt,trackMarket:()=>Le,within:()=>dt});var Ct=new WeakSet,Wt=new WeakSet,ft=new Set,mt=new Set,tn=new WeakMap;function Jt(){ft.forEach(t=>{t.isConnected||ft.delete(t)}),mt.forEach(t=>{t.root.isConnected||mt.delete(t)})}function dt(t,e){return[...t.matches?.(e)?[t]:[],...w(t,e)]}function zt(t){if(Ct.has(t))return!1;let{key:e,fromUrl:n,raw:r}=z(t);if(!e)return n?(Ct.add(t),Y(t,"not-found"),$("product-not-found",{key:null,source:r},t)):t.closest(ut())||U(`[${g("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t),!1;Ct.add(t),ft.add(t);let i={};tn.set(t,i);let s=()=>tn.get(t)===i;it.get(t)?t.setAttribute(g("state"),"updating"):Y(t,"loading");let o=nt(e);return Q?.add(o),o.then(c=>{if(!s())return;let u=it.get(t);u?u.update(c):new St(t,c),Pn(t,c),a.revalidate!==!1&&ue(e)&&Sn(e)}).catch(c=>{if(!s())return;let u=ht(c);Y(t,u?"not-found":"error",c),u?($("product-not-found",{key:e,source:r},t),n?L(`product not found: ${e}`):P(c,`product ${e}`)):(P(c,`product ${e}`),$("error",{error:c,context:"product",key:e},t))}),!0}function Pn(t,e){let n=p(t,"page-title");!n||typeof document>"u"||(document.title=n.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function Te(){Jt(),ft.forEach(t=>{t.getAttribute(g("state"))!=="error"||t.getAttribute(g("error"))==="not-found"||(Ct.delete(t),zt(t))})}var Ht=new Set;function Sn(t){Ht.size||setTimeout(En,0),Ht.add(t)}function En(){let t=[...Ht];Ht=new Set,de(t).forEach((e,n)=>e.then(r=>{ft.forEach(i=>{let s=it.get(i);if(!s||!i.isConnected)return;let o=z(i).key;o!==t[n]&&o!==r.handle&&o!==r.id||JSON.stringify(s.product)!==JSON.stringify(r)&&s.update(r)})}).catch(r=>P(r,`refresh ${t[n]}`)))}var en=new WeakSet,Q=null,Le=t=>(Q?.add(t),t);function Yt(){if(!Q)return;let t=[...Q];Promise.allSettled(t).then(()=>{!Q||t.some(e=>!Q.has(e))||(t.length===Q.size?(Q=null,document.documentElement.classList.remove(`${a.prefix}-market-pending`)):Yt())})}function qe(t=document){w(t.ownerDocument||t,'script[type="application/json"][data-tether-hydrate]').forEach(e=>{if(!en.has(e)){en.add(e);try{let n=JSON.parse(e.textContent);Gt(n.products);let r=(i,s)=>String(i||"").toUpperCase()===String(s||"").toUpperCase();r(n.country,a.country)&&r(n.language,a.language)?le(n.products):(L("hydration skipped: other market"),Q||(Q=new Set,document.documentElement.classList.add(`${a.prefix}-market-pending`)))}catch(n){U("bad data-tether-hydrate",n)}}})}var{cfg:Cn}=Lt,nn={"config.js":Lt,"client.js":ne,"dom.js":xe,"fragments.js":ie,"loader.js":pe,"selling-plans.js":xt,"status.js":Ce,"cart.js":Se,"product.js":ke,"collection.js":Ie,"mounting.js":Oe},Ne=typeof document<"u"&&document.currentScript?.src||"",kt={};function q(t){if(kt[t])return kt[t];let e=Cn.partsUrl||Ne.replace(/[^/]*$/,""),n=/\.min\.js(\?|$)/.test(Ne)||!Ne?".min":"",r=`${e.replace(/\/?$/,"/")}tether.${t}${n}.js`;return kt[t]=new Promise((i,s)=>{let o=document.createElement("script");o.src=r,o.async=!0,o.onload=()=>window.Tether?.__parts?.[t]?i(window.Tether.__parts[t]):s(new Error(`${r} did not register`)),o.onerror=()=>{delete kt[t],s(new Error(`Could not load ${r}. Host it next to the Tether script, or set partsUrl.`))},document.head.appendChild(o)}),kt[t]}var rn="0.6.0",st=null,Fe=null;function pt(t=document){if(!Tt())return 0;let e=0;return Jt(),qe(t),dt(t,ut()).forEach(n=>{if(Wt.has(n))return;Wt.add(n),e++;let r=new Et(n);mt.add(r),n.addEventListener(`${a.prefix}:list-rendered`,i=>pt(i.detail.container)),Le(r.load())}),dt(t,l("product")).forEach(n=>{zt(n)&&e++}),dt(t,`${l("country-select")},${l("country-bind")}`).length&&q("markets").then(n=>n.renderCountrySelects(t)).catch(n=>P(n,"markets")),(a.account?.clientId||a.account?.server)&&(dt(t,`[${g("account-login")}],[${g("account-bind")}],[${g("orders")}],[${g("show")}^="logged-"]`).length||/[?&]code=/.test(window.location.search)||Ln())&&q("account").then(n=>n.mountAccount(t)).catch(n=>P(n,"account")),dt(t,l("search")).length&&q("search").then(n=>n.mountSearch(t)).catch(n=>P(n,"search")),w(t,l("account-link")).forEach(n=>{n.setAttribute("href",`https://${a.domain}/account`)}),Yt(),A.render(),L(`mounted ${e} scope(s)`,t),e}function on(){A.close()}function kn(t){let e=t?.closest?.(l("product"));return e&&it.get(e)||null}var sn=!1;function In(){sn||(sn=!0,document.addEventListener("click",t=>{let e=t.target;if(!e?.closest)return;if(e.closest(l("cart-open"))){t.preventDefault(),A.toggle();return}if(e.closest(l("cart-close"))){t.preventDefault(),A.close();return}let n=e.closest(l("cart-clear"));if(n){t.preventDefault(),B(n,()=>A.clear().catch(c=>P(c,"cart clear")));return}let r=e.closest(l("checkout"));if(r){t.preventDefault(),B(r,()=>A.checkout());return}let i=e.closest(an());if(i&&i.closest(l("cart-lines"))){let c=i.getAttribute(`data-${a.prefix}-key`),u=A.lines.find(h=>h.id===c),f=h=>{t.preventDefault(),h().catch(m=>P(m,"cart line"))};if(e.closest(l("line-remove")))return i.classList.add("is-busy"),f(()=>A.removeLine(c));if(u&&e.closest(l("line-plus")))return f(()=>A.changeQuantity(c,1));if(u&&e.closest(l("line-minus")))return f(()=>A.changeQuantity(c,-1))}let s=e.closest(l("discount-remove"));if(s){t.preventDefault();let c=s.closest(l("discount-code"))?.getAttribute(g("discount-code"));c&&A.removeDiscount(c).catch(u=>P(u,"discount"));return}let o=e.closest(l("group-add"));o&&(t.preventDefault(),B(o,()=>cn(o)))}),document.addEventListener("change",t=>{let e=t.target;if(!e?.closest)return;let n=e.closest(an()),r=n?.getAttribute(`data-${a.prefix}-key`),i=(s,o)=>{n.classList.add("is-busy"),n.setAttribute("aria-busy","true"),s.catch(c=>P(c,o))};r&&e.matches(`input${l("line","quantity")}`)?i(A.updateLine(r,parseInt(e.value,10)||0),"cart line"):r&&e.matches(`select${l("line-plan")}`)?i(A.updateLine(r,{sellingPlanId:e.value||null}),"cart line plan"):e.matches(`select${l("country-select")}`)?e.value&&Ue(e.value).catch(s=>P(s,"country")):e.matches(l("cart-note"))&&A.setNote(e.value).catch(s=>P(s,"cart note"))}),document.addEventListener("submit",t=>{let e=t.target.closest?.(l("discount-form"));if(!e)return;t.preventDefault();let n=e.querySelector(l("discount-input"))||e.querySelector("input"),r=n?.value.trim();r&&B(e,async()=>{let i=s=>{e.classList.toggle("is-invalid",s),n&&(s?n.setAttribute("aria-invalid","true"):n.removeAttribute("aria-invalid"))};try{await A.applyDiscount(r),i(!1),$("discount-applied",{code:r},e),n&&(n.value="")}catch(s){i(!0),s?.code==="INVALID_DISCOUNT"?$("discount-invalid",{code:r},e):P(s,"discount")}})},!0),document.addEventListener("input",t=>{let e=t.target.closest?.(l("discount-form"));e&&(e.classList.remove("is-invalid"),t.target.removeAttribute?.("aria-invalid"))}),window.addEventListener("storage",t=>{a.domain&&t.key?.startsWith(`${a.prefix}:`)&&q("extras").then(e=>e.onStorage(t)).catch(()=>{})}),document.addEventListener(`${a.prefix}:variant-changed`,t=>{let e=t.target;(a.variantUrl||e.hasAttribute?.(g("variant-url")))&&q("extras").then(n=>n.writeVariantUrl(e,t.detail)).catch(()=>{})}),a.astro!==!1&&(document.addEventListener("astro:page-load",()=>(st||Promise.resolve()).then(()=>{let t=_e();if(!t&&De){try{t=JSON.parse(localStorage.getItem(`${a.prefix}:market:${a.domain}`)||"null")}catch{t=null}t=t?.country?t:un}De=!!_e(),t?.country&&(String(t.country).toUpperCase()!==String(a.country||"").toUpperCase()||String(t.language||"").toUpperCase()!==String(a.language||"").toUpperCase())?Ue(t.country,{language:t.language??null,locale:t.locale,remember:!1}).then(()=>pt(document),()=>pt(document)):pt(document)})),document.addEventListener("astro:before-swap",()=>on())),window.addEventListener("online",()=>{Te(),mt.forEach(t=>{t.root.getAttribute(g("state"))==="error"&&t.load()})}),document.addEventListener("keydown",t=>{if(!A.isOpen())return;if(t.key==="Escape"){A.close();return}if(t.key!=="Tab"||a.cartFocus===!1)return;let e=A.drawers().find(s=>s.classList.contains(a.cartDrawerOpenClass)),n=e?Rt(e):[];if(!n.length)return;let r=n[0],i=n[n.length-1];(!e.contains(document.activeElement)||t.shiftKey&&document.activeElement===r||!t.shiftKey&&document.activeElement===i)&&(t.preventDefault(),(t.shiftKey?i:r).focus())}))}function an(){return`[data-${a.prefix}-key]`}var cn=t=>q("extras").then(e=>e.addGroup(t)),It=null;function ln(t={}){return st&&!Object.keys(t).length?st:(Zt({...window.TETHER_CONFIG||{},...t}),Tt()?(In(),a.observe&&On(),a.analytics&&!It&&(It=[],["product-ready","list-ready","cart-updated","cart-toggled","checkout","search"].forEach(e=>document.addEventListener(`${a.prefix}:${e}`,n=>It.push(n))),document.addEventListener("astro:page-load",()=>It.push(new CustomEvent(`${a.prefix}:page`))),q("analytics").then(e=>e.startAnalytics(It)).catch(e=>P(e,"analytics"))),st=Tn(t).then(()=>A.init()).then(async e=>{let n=a.country?String(a.country).toUpperCase():null;if(e&&n&&e.buyerIdentity?.countryCode&&e.buyerIdentity.countryCode!==n)try{e=await A.setBuyerIdentity({countryCode:n},{create:!1})}catch(r){P(r,"cart country")}return $("ready",{cart:e}),je}),st):(U("TETHER_CONFIG is missing domain or token. Tether is idle."),st=Promise.resolve(null),st))}function _e(t=document){let e=r=>t.querySelector(`meta[name="${a.prefix}-page-${r}"]`)?.getAttribute("content")||void 0,n=e("country");return n?{country:n.toUpperCase(),language:e("language"),locale:e("locale")}:null}var un=null,De=!1;async function Tn(t){let e=a.markets||{};un={country:a.country,language:a.language,locale:a.locale};let n=_e();if(De=!!n,n){a.country=n.country,a.language=n.language?n.language.toUpperCase():void 0,n.locale&&(a.locale=n.locale);return}if(e.detect===!1)return;let r=null;if(e.detect)try{r=(await q("markets")).detectMarket(e)}catch(i){P(i,"markets");return}else if(e.remember!==!1){try{r=JSON.parse(localStorage.getItem(`${a.prefix}:market:${a.domain}`)||"null")}catch{}r&&!/^[A-Z]{2}$/.test(r.country||"")&&(r=null)}r&&(r.country&&(a.country=r.country),r.language&&(a.language=r.language),r.locale&&!t.locale&&(a.locale=r.locale),L("market",r))}function Ln(){try{return!!(sessionStorage[`${a.prefix}:account:${a.domain}`]||localStorage[`${a.prefix}:account:${a.domain}`]||localStorage[`${a.prefix}:account-hint:${a.domain}`])}catch{return!1}}var qn=new Proxy({},{get:(t,e)=>(...n)=>q("account").then(r=>r[e](...n))});function Ue(t,e){return q("markets").then(n=>n.setCountry(t,e))}function On(){if(Fe||typeof MutationObserver>"u")return;let t=null,e=new Set;Fe=new MutationObserver(n=>{n.forEach(r=>r.addedNodes.forEach(i=>{i.nodeType===1&&e.add(i)})),clearTimeout(t),t=setTimeout(()=>{e.forEach(r=>{r.isConnected&&pt(r)}),e.clear()},50)}),Fe.observe(document.body,{childList:!0,subtree:!0})}var je={VERSION:rn,init:ln,mount:pt,unmount:on,get config(){return a},get ready(){return st||Promise.resolve(null)},query:F,withContext:Ot,cart:A,getProduct:nt,getProducts:vt,getRecommendations:bt,getScope:kn,addGroup:cn,account:qn,primeProduct:et,normalizeProductKey:ct,clearProductCache:ce,formatMoney:D,imageUrl:jt,plans:xt,TetherError:E,resolveProductKey:z,setCountry:Ue,detectMarket:t=>q("markets").then(e=>e.detectMarket(t||a.markets)),getLocalization:()=>q("markets").then(t=>t.getLocalization()),diagnose:t=>q("diagnose").then(e=>e.diagnose({...t,version:rn})),__core:nn,__parts:{},on(t,e){let n=r=>e(r.detail,r);return document.addEventListener(`${a.prefix}:${t}`,n),()=>document.removeEventListener(`${a.prefix}:${t}`,n)}},Pr=je;if(typeof window<"u"&&typeof document<"u"&&(window.Tether=je,window.TETHER_CONFIG&&window.TETHER_CONFIG.autoMount!==!1&&!window.TETHER_INTEGRATION)){let e=()=>ln().then(()=>pt(document));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}})();
|
|
4
|
+
seo { title description }`}var pe={};M(pe,{clearProductCache:()=>ce,getProduct:()=>nt,getProducts:()=>vt,getRecommendations:()=>bt,hydrateProducts:()=>le,normalizeProductKey:()=>ct,primeProduct:()=>et,refreshProducts:()=>de,takeStale:()=>ue});var _=new Map,Ge=[],se=new Map,ae=!1,yt=0,oe=t=>typeof t=="string"&&t.startsWith("gid://");function ct(t){let e=String(t??"").trim();if(!e)return null;if(oe(e))return e;if(/^\d+$/.test(e))return`gid://shopify/Product/${e}`;let n=e.match(/\/products\/([^/?#]+)/);return n?n[1]:e}function et(t){if(!t)return;let e=Promise.resolve(t);_.set(t.handle,e),_.set(t.id,e)}function nt(t){let e=ct(t);if(!e)return Promise.reject(new E("empty product key",{code:"NOT_FOUND"}));if(_.has(e))return _.get(e);let n=new Promise((r,i)=>{se.set(e,{resolve:r,reject:i}),Ge.push(e),ae||(ae=!0,setTimeout(mn,0))});return _.set(e,n),n}async function mn(){ae=!1;let t=yt,e=Ge.splice(0);if(!e.length)return;let n=e.filter(oe),r=e.filter(f=>!oe(f)),i=[],s=[],o={};n.length&&(i.push("$ids: [ID!]!"),o.ids=n,s.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),r.forEach((f,h)=>{i.push(`$h${h}: String!`),o[`h${h}`]=f,s.push(`h${h}: product(handle: $h${h}) { ...TetherProduct }`)});let c=`query TetherProducts(${i.join(",")}){${s.join(" ")}}${gt()}`;L("fetch products",e);let u=(f,h)=>{let m=se.get(f);se.delete(f),m&&h(m)};try{let f=await F(c,o),h=new Map;(f.byId||[]).forEach(m=>{m&&h.set(m.id,m)}),r.forEach((m,C)=>{f[`h${C}`]&&h.set(m,f[`h${C}`])}),e.forEach(m=>u(m,C=>{if(h.has(m)){let y=h.get(m);t===yt&&(et(y),Ft.set(y.handle,Date.now()),Ft.set(y.id,Date.now())),C.resolve(y)}else{let y=_.get(m);t===yt&&setTimeout(()=>{_.get(m)===y&&_.delete(m)},1e4),C.reject(new E(`Product not found: ${m}`,{code:"NOT_FOUND"}))}}))}catch(f){e.forEach(h=>u(h,m=>{t===yt&&_.delete(h),m.reject(f)}))}}function ce(){_.clear(),yt++,ot.clear(),Ft.clear()}var ot=new Set,Ft=new Map,gn=6e4;function le(t){(t||[]).forEach(e=>{!e?.id||!e.handle||Date.now()-(Ft.get(e.handle)||0)<gn&&_.has(e.handle)||(et(e),ot.add(e.handle),ot.add(e.id))})}function ue(t){let e=ct(t);if(!ot.has(e))return!1;let n=_.get(e);return ot.delete(e),n?.then?.(r=>{ot.delete(r.handle),ot.delete(r.id)}),!0}function de(t){return t.forEach(e=>_.delete(ct(e))),t.map(e=>nt(e))}async function vt({collection:t,query:e,first:n=a.collectionFirst,after:r=null,sortKey:i,reverse:s=!1,filters:o}={}){let c=gt();if(t){let f=await F(`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${re()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}${c}`,{handle:t,first:n,after:r,sortKey:i||void 0,reverse:s,filters:o||void 0});if(!f.collection)throw new E(`Collection not found: ${t}`,{code:"NOT_FOUND"});let{products:h,...m}=f.collection;return h.nodes.forEach(et),{collection:m,products:h.nodes,pageInfo:h.pageInfo}}let u=await F(`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}}}${c}`,{first:n,after:r,query:e||void 0,sortKey:i||void 0,reverse:s});return u.products.nodes.forEach(et),{collection:null,products:u.products.nodes,pageInfo:u.products.pageInfo}}async function bt(t,e="RELATED"){let n=ct(typeof t=="object"?t?.id:t),r=n?.startsWith("gid://"),s=(await F(`query TetherRecs(${r?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${r?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}${gt()}`,r?{id:n,intent:e}:{handle:n,intent:e})).productRecommendations||[];return s.forEach(et),s}var xt={};M(xt,{GID:()=>R,allPlans:()=>G,allocationFor:()=>V,findPlan:()=>wt,hasPlans:()=>yn,planAdjustment:()=>fe,planCheckoutCharge:()=>he,planPrice:()=>$t,planSavings:()=>Dt,plansForVariant:()=>vn,toGid:()=>_t});var R={product:t=>_t(t,"Product"),variant:t=>_t(t,"ProductVariant"),sellingPlan:t=>_t(t,"SellingPlan")};function _t(t,e){let n=String(t??"").trim();return n?n.startsWith("gid://")?n:/^\d+$/.test(n)?`gid://shopify/${e}/${n}`:n:null}function G(t){return(t?.sellingPlanGroups?.nodes||[]).flatMap(n=>(n.sellingPlans?.nodes||[]).map(r=>({...r,group:n})))}function yn(t){return G(t).length>0}function V(t,e){return!t||!e?null:(t.sellingPlanAllocations?.nodes||[]).find(n=>n.sellingPlan?.id===e)||null}function vn(t,e){return G(t).filter(n=>V(e,n.id))}function $t(t,e){let r=V(t,e)?.priceAdjustments?.[0];return r?.perDeliveryPrice||r?.price||t?.price||null}function he(t,e){let n=V(t,e);return n?.checkoutChargeAmount||n?.priceAdjustments?.[0]?.price||t?.price||null}function Dt(t,e){let n=parseFloat(t?.price?.amount),r=parseFloat($t(t,e)?.amount);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r>=n?{amount:null,percentage:0}:{amount:{amount:(n-r).toFixed(2),currencyCode:t.price.currencyCode},percentage:Math.round((1-r/n)*100)}}function fe(t){let e=t?.priceAdjustments?.[0]?.adjustmentValue;if(!e)return null;switch(e.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:e.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:e.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:e.price};default:return null}}function wt(t,e){if(!e)return null;let n=G(t),r=R.sellingPlan(e),i=String(e).trim().toLowerCase();return n.find(s=>s.id===r)||n.find(s=>s.name.toLowerCase()===i)||n.find(s=>(s.options||[]).some(o=>String(o.value).toLowerCase()===i))||null}var xe={};M(xe,{attr:()=>g,busy:()=>B,cdnUrl:()=>Je,dataKey:()=>We,emit:()=>$,formatDate:()=>ye,formatMoney:()=>D,formatPercent:()=>ge,get:()=>p,has:()=>H,hasTemplate:()=>ve,imageUrl:()=>jt,notifyLayoutChanged:()=>J,parseJSONAttr:()=>we,productUrl:()=>At,qsa:()=>w,readText:()=>me,repeat:()=>K,repeatKeyed:()=>be,sameImage:()=>Mt,scoped:()=>rt,sel:()=>l,setImage:()=>j,setSelected:()=>Pt,setText:()=>S,setTextTracked:()=>W,show:()=>T,toAttributes:()=>lt,watchImages:()=>$e});var g=t=>`${a.prefix}-${t}`,l=(t,e)=>e===void 0?`[${g(t)}]`:`[${g(t)}="${e}"]`,p=(t,e)=>t.getAttribute(g(e)),H=(t,e)=>t.hasAttribute(g(e)),We=()=>`data-${a.prefix}-key`;function At(t,e){let n=a.productPath||"/product";if(!/\{(handle|id)\}/.test(n))return`${n.replace(/\/$/,"")}/${t}`;let r=e?String(e).split("/").pop():"";return n.replace(/\{handle\}/g,encodeURIComponent(t||"")).replace(/\{id\}/g,encodeURIComponent(r))}var w=(t,e)=>t?[...t.querySelectorAll(e)]:[],rt=(t,e,n)=>w(t,e).filter(r=>r.closest(n)===t);function $(t,e,n=document){n.dispatchEvent(new CustomEvent(`${a.prefix}:${t}`,{detail:e,bubbles:!0}))}function ge(t,e=a.locale){if(!t)return"";try{return new Intl.NumberFormat(e||void 0,{style:"percent",maximumFractionDigits:0}).format(t/100)}catch{return`${t}%`}}function D(t){if(!t)return"";if(typeof a.formatMoney=="function")return a.formatMoney(t,a.locale);let e=parseFloat(t.amount);if(Number.isNaN(e))return"";try{return new Intl.NumberFormat(a.locale||void 0,{style:"currency",currency:t.currencyCode}).format(e)}catch{return`${t.currencyCode} ${e.toFixed(2)}`}}function ye(t){if(!t)return"";try{return new Date(t).toLocaleDateString(a.locale||void 0)}catch{return""}}function jt(t,{width:e,height:n,crop:r}={}){if(!t)return t;try{let i=new URL(t);return e&&i.searchParams.set("width",String(e)),n&&i.searchParams.set("height",String(n)),r&&i.searchParams.set("crop",r),i.toString()}catch{return t}}function Je(t,e){if(!t||!e)return t;let n=r=>e.getAttribute(r);return jt(t,{width:n("max-width"),height:n("max-height"),crop:n("max-width")||n("max-height")?n("crop"):null})}var Mt=(t,e)=>!!(t&&e)&&t.split("?")[0]===e.split("?")[0];function j(t,e,n){if(!e)return;let r=Je(e,t);if(t.tagName==="IMG"&&Mt(t.getAttribute("src"),r)){n!=null&&!t.getAttribute("alt")&&t.setAttribute("alt",n);return}t.tagName==="IMG"?(t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.setAttribute("src",r),n!=null&&t.setAttribute("alt",n),t.getAttribute("loading")||t.setAttribute("loading","lazy")):t.style.backgroundImage=`url("${r}")`}function S(t,e){let n=e==null?"":String(e);t.tagName==="INPUT"||t.tagName==="TEXTAREA"?t.value=n:t.textContent=n}var me=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA"?t.value:t.textContent;function W(t,e){let n=me(t);S(t,e);let r=me(t);if(n!==r&&t.dataset.tetherSeen&&typeof a.onValueChange=="function")try{a.onValueChange(t,n)}catch{}t.dataset.tetherSeen="1"}function T(t,e){let n="tetherPrevDisplay";if(e){if(t.dataset.tetherShown!==void 0)return;t.dataset.tetherShown="",t.removeAttribute("hidden"),t.dataset[n]!==void 0?(t.style.display=t.dataset[n],delete t.dataset[n]):t.style.display==="none"&&(t.style.display=""),typeof getComputedStyle=="function"&&getComputedStyle(t).display==="none"&&(t.style.display=t.getAttribute(`${a.prefix}-display`)||"block")}else delete t.dataset.tetherShown,t.dataset[n]===void 0&&t.style.display!=="none"&&(t.dataset[n]=t.style.display||""),t.style.display="none"}function Pt(t,e){t.classList.toggle("is-selected",e),t.setAttribute("aria-pressed",e?"true":"false"),t.tagName==="INPUT"&&(t.type==="radio"||t.type==="checkbox")&&(t.checked=e);let n=t.querySelector?.('input[type="radio"],input[type="checkbox"]');n&&(n.checked=e)}var Ut=new WeakMap,ve=t=>!!Ut.get(t);function ze(t){if(!Ut.has(t)){let e=t.firstElementChild?.cloneNode(!0)??null;Ut.set(t,e),t.innerHTML=""}return Ut.get(t)}function K(t,e,n){let r=ze(t);if(!r){e.length&&U("repeater without a template child",t);return}t.innerHTML="",e.forEach((i,s)=>{let o=r.cloneNode(!0);n(o,i,s),t.appendChild(o)})}function be(t,e,n,r,{onEnter:i,onLeave:s}={}){let o=ze(t);if(!o){U("repeater without a template child",t);return}let c=We(),u=`data-${a.prefix}-leaving`,f=()=>[...t.children].filter(b=>b.hasAttribute(c)&&!b.hasAttribute(u)),h=new Map(f().map(b=>[b.getAttribute(c),b])),m=[],C=new Set;e.forEach((b,N)=>{let d=String(n(b,N)),v=h.get(d);v?h.delete(d):(v=o.cloneNode(!0),v.setAttribute(c,d),C.add(v)),r(v,b,N,C.has(v)),m.push(v)});let y=m.filter(b=>!C.has(b)),O=f().filter(b=>y.includes(b));if(!(O.length===y.length&&O.every((b,N)=>b===y[N]))){h.forEach(b=>b.remove()),m.forEach(b=>t.appendChild(b));return}m.forEach((b,N)=>{if(!C.has(b))return;let d=m[N-1];if(d&&d.parentNode===t?d.after(b):t.prepend(b),i)try{i(b)}catch{}}),h.forEach(b=>{b.setAttribute(u,""),b.removeAttribute(c),b.style.pointerEvents="none",b.inert=!0;let N=()=>b.remove();if(s)try{s(b,N)}catch{N()}else N()})}var He=null;function J(t){clearTimeout(He),He=setTimeout(()=>{typeof a.onLayoutChange=="function"?a.onLayoutChange(t):window.ScrollTrigger?.refresh&&window.ScrollTrigger.refresh(),$("layout-changed",{reason:t})},120)}function $e(t,e){let n=w(t,"img").filter(s=>!s.complete);if(!n.length)return;let r=n.length,i=()=>{--r===0&&J(`${e}:images`)};n.forEach(s=>{s.addEventListener("load",i,{once:!0}),s.addEventListener("error",i,{once:!0})})}function B(t,e){return t.getAttribute("aria-busy")==="true"?Promise.resolve():(t.setAttribute("aria-busy","true"),Promise.resolve().then(e).finally(()=>t.removeAttribute("aria-busy")))}function we(t,e){let n=t&&p(t,e);if(!n)return null;try{return JSON.parse(n)}catch{return U(`invalid JSON in ${g(e)}`,t),null}}function lt(t){return t?Array.isArray(t)?t.map(e=>({key:String(e.key),value:String(e.value??"")})):Object.entries(t).map(([e,n])=>({key:e,value:String(n??"")})):[]}function Xe(t,e=1,n={}){let r=typeof t=="object"&&t!==null?t:{variantId:t,quantity:e,...n},i=R.variant(r.merchandiseId||r.variantId||r.id);if(!i)throw new E("add(): variantId is required");let s={merchandiseId:i,quantity:Math.max(1,parseInt(r.quantity??1,10)||1)},o=r.sellingPlanId||r.sellingPlan;o&&(s.sellingPlanId=R.sellingPlan(o));let c=lt(r.attributes);return c.length&&(s.attributes=c),s}function Ye(t,e,n){return`mutation Tether_${t}(${e}){${t}(${n}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${Nt()}`}var bn='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Vt=null,Rt=t=>w(t,bn).filter(e=>e.offsetParent!==null||e===document.activeElement);function Ae(t){w(document,l("cart-open")).forEach(e=>e.setAttribute("aria-expanded",String(t))),w(document,l("cart-drawer")).forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",p(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),e.classList.contains(a.cartDrawerOpenClass)||(e.setAttribute("aria-hidden","true"),a.cartFocus!==!1&&(e.inert=!0))})}var Pe=t=>/does not exist|not found|invalid id/i.test(t?.message||""),A={state:null,_chain:Promise.resolve(),id(){try{return localStorage.getItem(a.storageKey)}catch{return null}},_setId(t){try{t?localStorage.setItem(a.storageKey,t):localStorage.removeItem(a.storageKey)}catch{}},get lines(){return this.state?.lines?.nodes||[]},get count(){return this.state?.totalQuantity||0},lastError:null,customerAccessToken:null,pendingQty:new Map,warnings:[],loaded:!1,_take(t,e){let n=ee(t,e);return this.warnings=(n.warnings||[]).filter((r,i,s)=>s.findIndex(o=>o.message===r.message)===i).map(r=>({...r,message:typeof a.warningText=="function"&&a.warningText(r)||r.message})),this.warnings.length&&$("cart-warning",{warnings:this.warnings}),n.cart},_queue(t){let e=this._chain.then(t,t).then(n=>(this.lastError&&(this.lastError=null,this.render()),n),n=>{throw this.lastError=n,this.render(),$("cart-error",{error:n}),n});return this._chain=e.catch(()=>{}),e},_commit(t,e){this.state=t,t?.id&&this._setId(t.id);try{localStorage.setItem(`${a.storageKey}:seen`,`${Date.now()}|${t?.totalQuantity||0}`)}catch{}return this.render(),$("cart-updated",{cart:t,reason:e}),t},async init(){let t=this.id();if(!t)return this.state=null,this.loaded=!0,this.render(),$("cart-updated",{cart:null,reason:"load"}),null;if(!this.loaded)try{let e=(localStorage.getItem(`${a.storageKey}:seen`)||"").split("|")[1];e&&w(document,l("cart-count")).forEach(n=>{/^\s*0?\s*$/.test(n.textContent)&&(n.textContent=e)})}catch{}try{let e=await F(`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${Nt()}`,{id:t});e.cart?this.state=e.cart:(this._setId(null),this.state=null)}catch(e){P(e,"cart load failed"),this.lastError=e,Pe(e)&&this._setId(null),this.state=null}return this.loaded=!0,this.render(),$("cart-updated",{cart:this.state,reason:"load"}),this.state},async _create(t={}){let e=a.country||this.customerAccessToken?{...a.country?{countryCode:String(a.country).toUpperCase()}:{},...this.customerAccessToken?{customerAccessToken:this.customerAccessToken}:{}}:void 0,n=await F(Ye("cartCreate","$input: CartInput!","input: $input"),{input:{buyerIdentity:e,...t}});return this._take(n.cartCreate,"cartCreate")},async _mutate(t,e,n,r,i){let s=this.id();if(!s)return i?this._create(i):null;try{let o=await F(Ye(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${n}`),{...r,cartId:s});return this._take(o[t],t)}catch(o){if(i&&Pe(o))return L("cart expired, creating a new one"),this._setId(null),this._create(i);throw o}},add(t,e=1,n={}){let r=(Array.isArray(t)?t:[t]).map(i=>Xe(i,e,n));return this._queue(async()=>{let i=await this._mutate("cartLinesAdd","$lines: [CartLineInput!]!","lines: $lines",{lines:r},{lines:r});return this._commit(i,"add"),$("added",{cart:i,lines:r}),a.openCartOnAdd&&this.open(),i})},updateLine(t,e){let n=typeof e=="number"?{quantity:e}:{...e};if(n.quantity!==void 0&&n.quantity<=0)return this.removeLine(t);let r={id:t};return n.quantity!==void 0&&(r.quantity=n.quantity),"sellingPlanId"in n&&(r.sellingPlanId=n.sellingPlanId?R.sellingPlan(n.sellingPlanId):null),n.attributes&&(r.attributes=lt(n.attributes)),(n.merchandiseId||n.variantId)&&(r.merchandiseId=R.variant(n.merchandiseId||n.variantId)),this._queue(async()=>this._commit(await this._mutate("cartLinesUpdate","$lines: [CartLineUpdateInput!]!","lines: $lines",{lines:[r]}),"update"))},changeQuantity(t,e){let n=this.lines.find(s=>s.id===t);if(!n)return Promise.resolve(this.state);let r=Math.max(0,(this.pendingQty.get(t)?.qty??n.quantity)+e),i={qty:r,done:!1};return this.pendingQty.set(t,i),this.render(),$("cart-updated",{cart:this.state,reason:"pending"}),this.updateLine(t,r).finally(()=>{this.pendingQty.get(t)===i&&(this.pendingQty.delete(t),this.render(),$("cart-updated",{cart:this.state,reason:"settled"}))})},quantityOf(t){return this.pendingQty.get(t.id)?.qty??t.quantity},removeLine(t){let e=Array.isArray(t)?t:[t];return this._queue(async()=>this._commit(await this._mutate("cartLinesRemove","$lineIds: [ID!]!","lineIds: $lineIds",{lineIds:e}),"remove"))},clear(){let t=this.lines.map(e=>e.id);return t.length?this.removeLine(t):Promise.resolve(this.state)},setNote(t){return this._queue(async()=>this._commit(await this._mutate("cartNoteUpdate","$note: String!","note: $note",{note:t??""},{note:t??""}),"note"))},setAttributes(t){let e=new Map((this.state?.attributes||[]).map(r=>[r.key,r.value]));lt(t).forEach(r=>e.set(r.key,r.value));let n=[...e].filter(([,r])=>r!=="").map(([r,i])=>({key:r,value:i}));return this._queue(async()=>this._commit(await this._mutate("cartAttributesUpdate","$attributes: [AttributeInput!]!","attributes: $attributes",{attributes:n},{attributes:n}),"attributes"))},setDiscountCodes(t){let e=(Array.isArray(t)?t:[t]).map(n=>String(n).trim()).filter(Boolean);return this._queue(async()=>this._commit(await this._mutate("cartDiscountCodesUpdate","$discountCodes: [String!]!","discountCodes: $discountCodes",{discountCodes:e},{discountCodes:e}),"discount"))},async applyDiscount(t){let e=(this.state?.discountCodes||[]).map(i=>i.code),n=await this.setDiscountCodes([...new Set([...e,t])]);if((n?.discountCodes||[]).find(i=>i.code.toLowerCase()===String(t).toLowerCase())?.applicable)return n;throw await this.removeDiscount(t).catch(()=>{}),new E(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let e=String(t).toLowerCase();return this.setDiscountCodes((this.state?.discountCodes||[]).map(n=>n.code).filter(n=>n.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return this._queue(async()=>{let n=await this._mutate("cartBuyerIdentityUpdate","$buyerIdentity: CartBuyerIdentityInput!","buyerIdentity: $buyerIdentity",{buyerIdentity:t},e?{buyerIdentity:t}:null).catch(r=>{if(e||!Pe(r))throw r;return this._setId(null),null});return this._commit(n,"buyer-identity")})},async checkout(t=a.checkoutTarget){let e=this.id();if(!e||this.state&&!this.count)return null;let n=t==="_blank"?window.open("","_blank"):null;if(n)try{n.opener=null}catch{}try{let r=await F("query TetherCheckout($id: ID!) { cart(id: $id) { checkoutUrl } }",{id:e}),i=this.beforeCheckout&&await this.beforeCheckout().catch(()=>null)||r.cart?.checkoutUrl;if(i&&this.customerAccessToken&&(i+=`${i.includes("?")?"&":"?"}logged_in=true`),!i)throw new E("No checkoutUrl (cart empty or expired)");return $("checkout",{url:i,cart:this.state}),n&&!n.closed?n.location.href=i:window.location.href=i,i}catch(r){return n&&n.close(),P(r,"checkout failed"),null}},drawers(){return w(document,l("cart-drawer"))},_open:!1,isOpen(){let t=this.drawers();return t.length?t.some(e=>e.classList.contains(a.cartDrawerOpenClass)):this._open},open(){if(this.isOpen())return;this._open=!0;let t=this.drawers().filter(e=>p(e,"cart-drawer")!=="manual");t.forEach(e=>{e.inert=!1,e.classList.add(a.cartDrawerOpenClass),e.setAttribute("aria-hidden","false")}),Ae(!0),a.cartFocus!==!1&&t[0]&&(Vt=document.activeElement,setTimeout(()=>{let e=Rt(t[0])[0]||t[0];e===t[0]&&!t[0].hasAttribute("tabindex")&&(t[0].tabIndex=-1),e.focus?.({preventScroll:!0})},60)),typeof a.onCartOpen=="function"&&a.onCartOpen(t),$("cart-toggled",{open:!0})},close(){if(!this.isOpen())return;this._open=!1;let t=this.drawers(),e=t.some(n=>n.contains(document.activeElement));t.forEach(n=>{n.classList.remove(a.cartDrawerOpenClass),n.setAttribute("aria-hidden","true"),a.cartFocus!==!1&&(n.inert=!0)}),Ae(!1),e&&Vt?.isConnected&&Vt.focus({preventScroll:!0}),Vt=null,typeof a.onCartClose=="function"&&a.onCartClose(t),$("cart-toggled",{open:!1})},toggle(){this.isOpen()?this.close():this.open()},subscribe(t){let e=()=>t(this.state,{open:this.isOpen(),count:this.count,loaded:this.loaded,warnings:this.warnings}),n=()=>e();return["cart-updated","cart-toggled"].forEach(r=>document.addEventListener(`${a.prefix}:${r}`,n)),e(),()=>["cart-updated","cart-toggled"].forEach(r=>document.removeEventListener(`${a.prefix}:${r}`,n))},render(){let t=this.state,e=t?t.totalQuantity:0,n=s=>t?D(t.cost?.[s]):"";Ae(this.isOpen()),w(document,l("cart-count")).forEach(s=>W(s,e)),w(document,l("cart-subtotal")).forEach(s=>W(s,n("subtotalAmount"))),w(document,l("cart-total")).forEach(s=>W(s,n("totalAmount"))),w(document,l("cart-checkout-charge")).forEach(s=>W(s,n("checkoutChargeAmount")));let r=this.lines.some(s=>s.sellingPlanAllocation),i={"cart-empty":e===0,"cart-filled":e>0,"cart-has-subscription":r,"cart-no-subscription":!r,"cart-has-discount":(t?.discountCodes||[]).some(s=>s.applicable),"cart-error":!!this.lastError,"cart-warning":this.warnings.length>0};w(document,l("cart-warning")).forEach(s=>W(s,[...new Set(this.warnings.map(o=>o.message))].join(" "))),w(document,l("show")).forEach(s=>{let o=p(s,"show");o in i&&!s.closest(l("product"))&&T(s,i[o])}),w(document,l("checkout")).forEach(s=>{s.classList.toggle("is-disabled",!e),s.setAttribute("aria-disabled",String(!e))}),w(document,`textarea${l("cart-note")},input${l("cart-note")}`).forEach(s=>{document.activeElement!==s&&(s.value=t?.note||"")}),w(document,l("cart-discounts")).forEach(s=>{K(s,t?.discountCodes||[],(o,c)=>{o.setAttribute(g("discount-code"),c.code);let u=o.querySelector(l("discount","code"))||(o.firstElementChild?null:o);u&&S(u,c.code),o.classList.toggle("is-inapplicable",!c.applicable)})}),w(document,l("cart-lines")).forEach(s=>{be(s,this.lines,o=>o.id,(o,c)=>wn(o,c),{onEnter:a.onLineEnter,onLeave:a.onLineLeave})}),t&&J("cart")}};function $n(t,e){let n=t.merchandise||{},r=t.sellingPlanAllocation?.sellingPlan;switch(e){case"title":return n.product?.title;case"product-title":return n.product?.title;case"variant-title":return n.title==="Default Title"?"":n.title;case"options":return(n.selectedOptions||[]).filter(i=>i.value!=="Default Title").map(i=>`${i.name}: ${i.value}`).join(", ");case"vendor":return n.product?.vendor;case"sku":return n.sku;case"price":return D(t.cost?.amountPerQuantity||n.price);case"compare-at-price":return D(t.cost?.compareAtAmountPerQuantity||n.compareAtPrice);case"line-total":return D(t.cost?.totalAmount);case"line-subtotal":return D(t.cost?.subtotalAmount);case"quantity":return A.quantityOf(t);case"plan":return r?.name||"";case"plan-description":return r?.description||"";case"components":return(t.lineComponents||[]).map(i=>`${i.quantity} \xD7 ${i.merchandise?.product?.title||""}`).join(", ");default:if(e.startsWith("attribute:")){let i=e.slice(10);return(t.attributes||[]).find(s=>s.key===i)?.value||""}return}}function wn(t,e){let n=e.merchandise||{},r=!!e.sellingPlanAllocation;t.setAttribute(g("line-id"),e.id),t.classList.toggle("is-subscription",r),w(t,l("line")).forEach(c=>{let u=p(c,"line");if(u==="image")return j(c,n.image?.url||n.product?.featuredImage?.url,n.product?.title);if(u==="url"){let h=At(n.product?.handle,n.product?.id),m=new URLSearchParams;n.id&&m.set("variant",String(n.id).split("/").pop());let C=e.sellingPlanAllocation?.sellingPlan?.id;C&&m.set("selling_plan",C.split("/").pop());let y=m.toString();return c.setAttribute("href",y?`${h}${h.includes("?")?"&":"?"}${y}`:h)}let f=$n(e,u);f!==void 0&&W(c,f)});let i=A.warnings.find(c=>c.target===e.id);t.classList.toggle("is-warning",!!i);let s=A.pendingQty.has(e.id);t.classList.toggle("is-busy",s),s?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),w(t,l("line","warning")).forEach(c=>W(c,i?.message||""));let o={subscription:r,"one-time":!r,"on-sale":parseFloat(e.cost?.compareAtAmountPerQuantity?.amount)>parseFloat(e.cost?.amountPerQuantity?.amount),"has-components":(e.lineComponents||[]).length>0,warning:!!i};w(t,l("line-show")).forEach(c=>{let u=p(c,"line-show");u in o&&T(c,o[u])}),w(t,`select${l("line-plan")}`).forEach(c=>{let u=n.product?.handle;u&&nt(u).then(f=>{let h=G(f),C=[...!f.requiresSellingPlan&&p(c,"line-plan")!=="subscription-only"?[{value:"",label:c.getAttribute(g("one-time-label"))||"One-time purchase"}]:[],...h.map(O=>({value:O.id,label:O.name}))],y=C.map(O=>O.value).join("|");c.dataset.tetherSig!==y&&(c.innerHTML="",C.forEach(O=>{let at=document.createElement("option");at.value=O.value,at.textContent=O.label,c.appendChild(at)}),c.dataset.tetherSig=y),c.value=e.sellingPlanAllocation?.sellingPlan?.id||"",T(c,h.length>0)}).catch(f=>P(f,"line plan options"))})}var ke={};M(ke,{ProductScope:()=>St,rememberOptionNames:()=>Gt,scopes:()=>it});var Ce={};M(Ce,{STATUS_KEYS:()=>Bt,boundary:()=>Kt,isNotFound:()=>ht,ownedBy:()=>Ee,resolveProductKey:()=>z,setScopeStatus:()=>Y});function z(t,e=window.location,n="product"){let r=(p(t,n)||"").trim();if(!r.toLowerCase().startsWith("url:"))return{key:r||null,fromUrl:!1,raw:r};let i=r.slice(4).trim(),s=null;if(i.toLowerCase()==="path"){let o=e.pathname.split("/").filter(Boolean);s=o.length?xn(o[o.length-1]):null}else s=new URLSearchParams(e.search).get(i||"handle");return s=s&&s.trim()?s.trim():null,{key:s,fromUrl:!0,raw:r}}function xn(t){try{return decodeURIComponent(t)}catch{return t}}var Bt=["loading","ready","error","not-found"],ht=t=>t?.code==="NOT_FOUND",Kt=()=>["product","collection","products","recommendations"].map(t=>l(t)).join(","),Ee=(t,e)=>t===e||t.parentElement?.closest(Kt())===e;function Y(t,e,n){let r=e==="not-found";t.setAttribute(g("state"),r?"error":e),e==="error"||r?t.setAttribute(g("error"),r?"not-found":n?.code||"error"):t.removeAttribute(g("error")),rt(t,l("show"),Kt()).forEach(i=>{let s=p(i,"show");Bt.includes(s)&&T(i,s===e)}),(e==="error"||r)&&rt(t,l("add-to-cart"),Kt()).forEach(i=>{i.classList.add("is-disabled"),i.setAttribute("aria-disabled","true"),"disabled"in i&&(i.disabled=!0)})}var it=new WeakMap,Ze=()=>l("product");function An(t,e){let n=e.indexOf("."),r=e.slice(0,n),i=e.slice(n+1);return(t.metafields||[]).find(o=>o&&o.namespace===r&&o.key===i)||null}var Qt=new Map;function Gt(t){(t||[]).forEach(e=>{e?.handle&&!Qt.has(e.handle)&&Qt.set(e.handle,(e.options||[]).map(n=>n.name))})}var St=class{constructor(e,n){this.root=e,this.product=n,this.selected={},this.variant=null,this.quantity=Math.max(0,parseInt(p(e,"quantity")??"1",10)||(H(e,"quantity")?0:1)),this.plans=G(n),this.purchase="one-time",this.planId=null,it.set(e,this),e.setAttribute(g("state"),"ready"),e.removeAttribute(g("error")),this.initSelection(),this.initPurchase(),this.renderProduct(),this.bind(),this.renderVariant(),$e(e,"product"),J("product"),$("product-ready",{product:n,scope:this},e)}update(e){let n=this.variant?.id;this.product=e,this.plans=G(e),this.planId&&!this.plans.some(i=>i.id===this.planId)&&(this.planId=this.plans[0]?.id||null),!this.plans.length&&this.purchase==="subscription"&&(this.purchase="one-time");let r=e.variants.nodes.find(i=>i.id===n);r&&(this.selected={},r.selectedOptions.forEach(i=>{this.selected[i.name]=i.value})),this.root.setAttribute(g("state"),"ready"),this.root.removeAttribute(g("error")),this.renderProduct(),this.renderVariant(),J("product"),$("product-updated",{product:e,scope:this},this.root)}$(e){let n=rt(this.root,e,Ze());return this.root.matches(e)?[this.root,...n]:n}optName(e){let n=this.product?.options||[];if(!e||n.some(i=>i.name===e))return e;let r=(Qt.get(this.product.handle)||[]).indexOf(e);return r>=0&&n[r]?n[r].name:e}initSelection(){let e=this.product.variants.nodes,n=e.find(i=>i.availableForSale)||e[0];n&&n.selectedOptions.forEach(i=>{this.selected[i.name]=i.value});let r=new URLSearchParams(window.location.search).get("variant")||p(this.root,"variant");if(r){let i=R.variant(r),s=e.find(o=>o.id===i);s&&(this.selected={},s.selectedOptions.forEach(o=>{this.selected[o.name]=o.value}))}}initPurchase(){if(!this.plans.length)return;let e=new URLSearchParams(window.location.search),n=wt(this.product,e.get("selling_plan")),r=wt(this.product,p(this.root,"default-plan"));this.planId=(n||r||this.plans[0]).id;let i=n?"subscription":p(this.root,"default-purchase")||a.defaultPurchase;this.purchase=this.product.requiresSellingPlan||i==="subscription"?"subscription":"one-time"}findVariant(){return this.product.variants.nodes.find(e=>e.selectedOptions.every(n=>this.selected[n.name]===n.value))||null}isValueAvailable(e,n){return this.product.variants.nodes.some(r=>r.availableForSale&&r.selectedOptions.every(i=>i.name===e?i.value===n:this.selected[i.name]===i.value))}get plan(){return this.plans.find(e=>e.id===this.planId)||null}get subscriptionAvailable(){return!!(this.variant&&this.plans.some(e=>V(this.variant,e.id)))}get isSubscription(){return this.purchase==="subscription"&&!!V(this.variant,this.planId)}getLine(){if(!this.variant)return null;let e={merchandiseId:this.variant.id,quantity:this.quantity};this.isSubscription&&(e.sellingPlanId=this.planId);let n=this.collectAttributes();return n.length&&(e.attributes=n),e}collectAttributes(){let e=lt(we(this.root,"line-attributes")),n=this.$(l("line-attribute")).map(r=>{let i=p(r,"line-attribute"),s;return r.type==="checkbox"?s=r.checked?r.value&&r.value!=="on"?r.value:"Yes":"":r.type==="radio"?s=r.checked?r.value:null:s=r.value,s==null||s===""?null:{key:i,value:String(s)}}).filter(Boolean);return[...e,...n]}select(e,n){if(this.selected[e]===n)return;let r=this.product.variants.nodes.filter(s=>s.selectedOptions.some(o=>o.name===e&&o.value===n));if(!r.length)return;let i={...this.selected,[e]:n};if(!r.some(s=>s.selectedOptions.every(o=>i[o.name]===o.value))){let s=c=>c.selectedOptions.filter(u=>u.name!==e&&this.selected[u.name]===u.value).length*2+(c.availableForSale?1:0);r.reduce((c,u)=>s(u)>s(c)?u:c).selectedOptions.forEach(c=>{i[c.name]=c.value})}this.selected=i,this.renderVariant()}selectVariant(e){let n=this.product.variants.nodes.find(r=>r.id===R.variant(e));n&&(this.selected={},n.selectedOptions.forEach(r=>{this.selected[r.name]=r.value}),this.renderVariant())}setPurchase(e){let n=e==="subscription"?"subscription":"one-time";n==="one-time"&&this.product.requiresSellingPlan||this.purchase!==n&&(this.purchase=n,this.renderVariant())}selectPlan(e){let n=wt(this.product,e);n&&(this.planId=n.id,this.purchase="subscription",this.renderVariant())}setQuantity(e){let n=H(this.root,"quantity")?0:1;this.quantity=Math.max(n,parseInt(e,10)||0),this.$(l("qty")).forEach(r=>S(r,this.quantity)),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let e=this.getLine();if(!e||e.quantity<1)return null;let n=await A.add(e);return $("product-added",{product:this.product,variant:this.variant,line:e},this.root),n}bind(){let e=n=>n&&n.closest(Ze())===this.root;this.root.addEventListener("click",n=>{let r=n.target;if(!r?.closest)return;let i=r.closest(l("option-value"));if(e(i)&&i.closest(l("option-list"))){n.preventDefault(),this.select(this.optName(p(i.closest(l("option-list")),"option-list")),p(i,"option-value"));return}let s=r.closest(l("plan-value"));if(e(s)){n.preventDefault(),this.selectPlan(p(s,"plan-value"));return}let o=r.closest(`${l("purchase")}:not(select)`);if(e(o)){o.tagName!=="INPUT"&&n.preventDefault(),this.setPurchase(p(o,"purchase"));return}let c=r.closest(l("qty-plus"));if(e(c)){n.preventDefault(),this.setQuantity(this.quantity+1);return}let u=r.closest(l("qty-minus"));if(e(u)){n.preventDefault(),this.setQuantity(this.quantity-1);return}let f=r.closest(l("add-to-cart"));e(f)&&(n.preventDefault(),this.onAddClick(f))}),this.root.addEventListener("change",n=>{let r=n.target;e(r)&&(r.matches(`select${l("option")}`)?this.select(this.optName(p(r,"option")),r.value):r.matches(`select${l("variant-select")}`)?this.selectVariant(r.value):r.matches(`select${l("plan")}`)?r.value?this.selectPlan(r.value):this.setPurchase("one-time"):r.matches(`select${l("purchase")}`)?this.setPurchase(r.value):r.matches(l("qty"))&&this.setQuantity(r.value))})}onAddClick(e){let n=e.querySelector(l("add-label"))||e,r=p(e,"adding-text"),i=s=>S(n,s);n.dataset.tetherLabel===void 0&&(n.dataset.tetherLabel=n.tagName==="INPUT"?n.value:n.textContent),B(e,async()=>{r&&i(r);try{await this.addToCart()}catch(s){P(s,"add to cart failed"),$("error",{error:s,context:"add-to-cart"},this.root)}finally{r&&i(n.dataset.tetherLabel)}}).then(()=>{this.renderVariant()})}renderProduct(){let e=this.product;Qt.has(e.handle)||this.$(`${l("option-list")},select${l("option")}`).map(i=>p(i,"option-list")||p(i,"option")).some(i=>e.options.some(s=>s.name===i))&&Gt([e]);let n=this.product;this.$(l("bind")).forEach(r=>{let i=p(r,"bind")||"",s={title:n.title,"description-text":n.description,vendor:n.vendor,type:n.productType,handle:n.handle}[i];if(s!==void 0)return S(r,s);switch(i){case"description":r.innerHTML=n.descriptionHtml||"";return;case"published-at":return S(r,ye(n.publishedAt));case"min-price":return S(r,D(n.priceRange.minVariantPrice));case"max-price":return S(r,D(n.priceRange.maxVariantPrice));case"featured-image":return j(r,n.featuredImage?.url,n.featuredImage?.altText||n.title);case"url":case"link":r.setAttribute("href",At(n.handle,n.id)),i==="url"&&!r.firstElementChild&&!r.textContent.trim()&&S(r,n.title);return;case"images":{let o=[...r.children].map(c=>c.tagName==="IMG"?c:c.querySelector("img"));if(!ve(r)&&o.length===n.images.nodes.length&&o.every((c,u)=>Mt(c?.getAttribute("src"),n.images.nodes[u].url)))return}return K(r,n.images.nodes,(o,c)=>{let u=o.matches(`img,${l("bind","image")}`)?o:o.querySelector("img")||o;j(u,c.url,c.altText||n.title)});case"tags":{let o=(r.getAttribute("exclude")||"").split(",").map(c=>c.trim()).filter(Boolean);return K(r,n.tags.filter(c=>!o.includes(c)),(c,u)=>S(c,u))}default:if(/^image:\d+$/.test(i)){let o=n.images.nodes[i.slice(6)-1]||n.featuredImage;return j(r,o?.url,o?.altText||n.title)}if(i.startsWith("metafield:")){let o=An(n,i.slice(10));return o?o.reference?.image?j(r,o.reference.image.url,o.reference.image.altText):(/^(rich_text|multi_line_text)_field$/.test(o.type)&&(r.style.whiteSpace="pre-line"),S(r,o.value)):S(r,"")}return}}),this.$(l("option-list")).forEach(r=>{let i=this.optName(p(r,"option-list")),s=n.options.find(o=>o.name===i);return!s||s.optionValues.length<=1&&H(r,"hide-single")?T(r,!1):K(r,s.optionValues,(o,c)=>{o.setAttribute(g("option-value"),c.name);let u=o.querySelector(l("bind","option-value"));u?S(u,c.name):o.firstElementChild||S(o,c.name);let f=o.querySelector(l("bind","swatch"));f&&c.swatch?.color&&(f.style.backgroundColor=c.swatch.color),f&&c.swatch?.image?.previewImage&&j(f,c.swatch.image.previewImage.url,c.name)})}),this.$(`select${l("option")}`).forEach(r=>{let i=n.options.find(s=>s.name===this.optName(p(r,"option")));if(!i)return T(r,!1);r.innerHTML="",i.optionValues.forEach(s=>r.appendChild(new Option(s.name,s.name)))}),this.$(`select${l("variant-select")}`).forEach(r=>{r.innerHTML="",n.variants.nodes.forEach(i=>r.appendChild(new Option(i.title,i.id)))}),this.$(l("plan-list")).forEach(r=>{let i=(p(r,"plan-list")||"").trim(),s=["","true","all","*"].includes(i.toLowerCase())?null:i,o=this.plans.filter(c=>!s||c.group.name===s);K(r,o,(c,u)=>{c.setAttribute(g("plan-value"),u.id),!c.firstElementChild&&!c.querySelector(l("plan-bind"))&&S(c,u.name)})}),this.$(`select${l("plan")}`).forEach(r=>{r.innerHTML="",!n.requiresSellingPlan&&p(r,"plan")!=="subscription-only"&&r.appendChild(new Option(r.getAttribute(g("one-time-label"))||"One-time purchase","")),this.plans.forEach(i=>r.appendChild(new Option(i.name,i.id)))})}renderVariant(){let e=this.product,n=this.findVariant();if(n||([n]=e.variants.nodes,n&&(this.selected={},n.selectedOptions.forEach(d=>{this.selected[d.name]=d.value}))),this.variant=n,!n)return;if(this.plans.length&&!V(n,this.planId)){let d=this.plans.find(v=>V(n,v.id));d&&(this.planId=d.id)}let r=this.isSubscription,i=n.price,s=this.planId?$t(n,this.planId):null,o=r?s:i,c=r&&V(n,this.planId)?.priceAdjustments?.[0]?.compareAtPrice||n.compareAtPrice,u=c&&parseFloat(c.amount)>parseFloat(o.amount),f=u?Math.round((1-parseFloat(o.amount)/parseFloat(c.amount))*100):0,h=this.planId?Dt(n,this.planId):{amount:null,percentage:0},m=this.plan,C={amount:(parseFloat(o.amount)*Math.max(1,this.quantity)).toFixed(2),currencyCode:o.currencyCode},y=D,O=d=>ge(d),at={price:()=>y(o),"total-price":()=>y(C),"one-time-price":()=>y(i),"subscription-price":()=>y(s),"subscription-savings":()=>O(h.percentage),"subscription-savings-amount":()=>y(h.amount),"checkout-charge":()=>{let d=r?he(n,this.planId):o;return d&&y({amount:(parseFloat(d.amount)*Math.max(1,this.quantity)).toFixed(2),currencyCode:d.currencyCode})},"plan-name":()=>m?.name,"plan-description":()=>m?.description,"plan-group":()=>m?.group?.name,"compare-at-price":()=>u?y(c):"","unit-price":()=>y(n.unitPrice),"discount-percentage":()=>`${f}%`,"discount-amount":()=>u?y({amount:String(parseFloat(c.amount)-parseFloat(o.amount)),currencyCode:o.currencyCode}):"","variant-title":()=>n.title,"variant-id":()=>n.id,sku:()=>n.sku,barcode:()=>n.barcode,stock:()=>n.quantityAvailable,quantity:()=>this.quantity};this.$(l("bind")).forEach(d=>{let v=p(d,"bind");v==="variant-image"?j(d,n.image?.url||e.featuredImage?.url,n.image?.altText||e.title):at[v]&&S(d,at[v]())}),this.$(l("option-selected")).forEach(d=>S(d,this.selected[this.optName(p(d,"option-selected"))]||"")),this.$(l("option-list")).forEach(d=>{let v=this.optName(p(d,"option-list"));w(d,l("option-value")).forEach(k=>{let X=p(k,"option-value");Pt(k,this.selected[v]===X);let I=!this.isValueAvailable(v,X);k.classList.toggle("is-unavailable",I),k.setAttribute("data-unavailable",I?"true":"false")})}),this.$(`select${l("option")}`).forEach(d=>{d.value=this.selected[this.optName(p(d,"option"))]||""}),this.$(`select${l("variant-select")}`).forEach(d=>{d.value=n.id}),this.$(l("purchase")).forEach(d=>{if(d.tagName==="SELECT"){d.value=this.purchase;return}let v=p(d,"purchase");Pt(d,v===this.purchase);let k=v==="subscription"?!this.subscriptionAvailable:e.requiresSellingPlan;d.classList.toggle("is-unavailable",k)}),this.$(l("plan-value")).forEach(d=>{let v=p(d,"plan-value"),k=this.plans.find(I=>I.id===v),X=!!V(n,v);Pt(d,r&&v===this.planId),d.classList.toggle("is-unavailable",!X),w(d,l("plan-bind")).forEach(I=>{let Z=fe(k),Me=Dt(n,v),dn=p(I,"plan-bind"),Ve={name:()=>k?.name,option:()=>(k?.options||[]).map(pn=>pn.value).join(", "),description:()=>k?.description,price:()=>y($t(n,v)),savings:()=>O(Me.percentage),"savings-amount":()=>y(Me.amount),adjustment:()=>Z?Z.type==="percentage"?`${Z.value}%`:y(Z.value):""}[dn];Ve&&S(I,Ve())})}),this.$(`select${l("plan")}`).forEach(d=>{d.value=r?this.planId:""});let b=n.quantityAvailable!=null&&n.quantityAvailable>0&&n.quantityAvailable<=(a.lowStock??5),N={"in-stock":n.availableForSale,"out-of-stock":!n.availableForSale,backorder:n.availableForSale&&n.currentlyNotInStock,"on-sale":!!u,"not-on-sale":!u,"has-variants":e.variants.nodes.length>1,"single-variant":e.variants.nodes.length===1,"low-stock":b,"plenty-in-stock":n.availableForSale&&!b,"subscription-available":this.subscriptionAvailable,"subscription-unavailable":!this.subscriptionAvailable,"subscription-only":!!e.requiresSellingPlan,"one-time-available":!e.requiresSellingPlan,"subscription-selected":r,"one-time-selected":!r,"has-savings":r?h.percentage>0:!!u,loading:!1,ready:!0,error:!1,"not-found":!1};this.$(l("show")).forEach(d=>{let v=p(d,"show");v in N&&(Bt.includes(v)&&!Ee(d,this.root)||T(d,N[v]))}),this.root.classList.toggle("is-subscription",r),this.root.setAttribute(g("purchase-mode"),r?"subscription":"one-time"),this.$(l("add-to-cart")).forEach(d=>{let v=!n.availableForSale;d.classList.toggle("is-disabled",v),d.setAttribute("aria-disabled",String(v)),"disabled"in d&&(d.disabled=v);let k=p(d,"soldout-text"),X=p(d,"subscribe-text");if(k||X){let I=d.querySelector(l("add-label"))||d;I.dataset.tetherLabel===void 0&&(I.dataset.tetherLabel=I.tagName==="INPUT"?I.value:I.textContent);let Z=I.dataset.tetherLabel;r&&X&&(Z=X),v&&k&&(Z=k),d.getAttribute("aria-busy")!=="true"&&S(I,Z)}}),$("variant-changed",{product:e,variant:n,selected:{...this.selected},purchase:this.purchase,sellingPlanId:r?this.planId:null},this.root)}};var Ie={};M(Ie,{ListScope:()=>Et,listSelector:()=>ut});var ut=()=>`${l("collection")},${l("products")},${l("recommendations")}`,Et=class{constructor(e){this.root=e,this.products=[],this.pageInfo=null,this.collection=null,Y(e,"loading"),e.addEventListener("click",n=>{let r=n.target.closest?.(l("load-more"));r&&r.closest(ut())===e&&(n.preventDefault(),B(r,()=>this.load(!0)))})}$(e){return rt(this.root,e,ut())}options(){let e=this.root,n={first:parseInt(p(e,"limit")||"",10)||void 0,sortKey:p(e,"sort")||void 0,reverse:p(e,"reverse")==="true"};return H(e,"collection")?n.collection=p(e,"collection"):n.query=p(e,"products")||"",n}async load(e=!1){let n=this.loadToken=(this.loadToken||0)+1,r=()=>n!==this.loadToken;try{if(H(this.root,"recommendations")){let{key:i}=z(this.root,window.location,"recommendations"),s=this.root.closest(l("product"));if(!i&&s&&({key:i}=z(s)),!i)throw new E("No product for recommendations",{code:"NOT_FOUND"});let o=await bt(i,p(this.root,"intent")||"RELATED");if(r())return;let c=parseInt(p(this.root,"limit")||"",10);this.products=c?o.slice(0,c):o}else{let i=await vt({...this.options(),after:e?this.pageInfo?.endCursor:null});if(r())return;this.collection=i.collection,this.pageInfo=i.pageInfo,this.products=e?[...this.products,...i.products]:i.products}this.render(),Y(this.root,"ready"),$("list-ready",{products:this.products,collection:this.collection},this.root)}catch(i){if(r())return;e||Y(this.root,ht(i)?"not-found":"error",i),ht(i)&&H(this.root,"recommendations")||P(i,"list load failed"),$("error",{error:i,context:"list"},this.root)}}render(){let e=this.collection;this.$(l("collection-bind")).forEach(r=>{switch(p(r,"collection-bind")){case"title":return S(r,e?.title||"");case"description":r.innerHTML=e?.descriptionHtml||"";return;case"image":return j(r,e?.image?.url,e?.image?.altText||e?.title);case"count":return S(r,this.products.length);default:return}}),this.$(l("list")).forEach(r=>{K(r,this.products,(i,s)=>{i.setAttribute(g("product"),s.handle),i.removeAttribute(g("state"))}),$("list-rendered",{container:r},this.root)});let n=this.products.length===0;this.$(l("show")).forEach(r=>{let i=p(r,"show");i==="list-empty"&&T(r,n),i==="list-filled"&&T(r,!n)}),this.$(l("load-more")).forEach(r=>T(r,!!this.pageInfo?.hasNextPage)),J("list")}};var Oe={};M(Oe,{hydrateFromPage:()=>qe,liveLists:()=>mt,liveProducts:()=>ft,mountProduct:()=>zt,mountedLists:()=>Wt,mountedProducts:()=>Ct,pruneLive:()=>Jt,retryFailed:()=>Te,settleMarket:()=>Yt,trackMarket:()=>Le,within:()=>dt});var Ct=new WeakSet,Wt=new WeakSet,ft=new Set,mt=new Set,tn=new WeakMap;function Jt(){ft.forEach(t=>{t.isConnected||ft.delete(t)}),mt.forEach(t=>{t.root.isConnected||mt.delete(t)})}function dt(t,e){return[...t.matches?.(e)?[t]:[],...w(t,e)]}function zt(t){if(Ct.has(t))return!1;let{key:e,fromUrl:n,raw:r}=z(t);if(!e)return n?(Ct.add(t),Y(t,"not-found"),$("product-not-found",{key:null,source:r},t)):t.closest(ut())||U(`[${g("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t),!1;Ct.add(t),ft.add(t);let i={};tn.set(t,i);let s=()=>tn.get(t)===i;it.get(t)?t.setAttribute(g("state"),"updating"):Y(t,"loading");let o=nt(e);return Q?.add(o),o.then(c=>{if(!s())return;let u=it.get(t);u?u.update(c):new St(t,c),Pn(t,c),a.revalidate!==!1&&ue(e)&&Sn(e)}).catch(c=>{if(!s())return;let u=ht(c);Y(t,u?"not-found":"error",c),u?($("product-not-found",{key:e,source:r},t),n?L(`product not found: ${e}`):P(c,`product ${e}`)):(P(c,`product ${e}`),$("error",{error:c,context:"product",key:e},t))}),!0}function Pn(t,e){let n=p(t,"page-title");!n||typeof document>"u"||(document.title=n.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function Te(){Jt(),ft.forEach(t=>{t.getAttribute(g("state"))!=="error"||t.getAttribute(g("error"))==="not-found"||(Ct.delete(t),zt(t))})}var Ht=new Set;function Sn(t){Ht.size||setTimeout(En,0),Ht.add(t)}function En(){let t=[...Ht];Ht=new Set,de(t).forEach((e,n)=>e.then(r=>{ft.forEach(i=>{let s=it.get(i);if(!s||!i.isConnected)return;let o=z(i).key;o!==t[n]&&o!==r.handle&&o!==r.id||JSON.stringify(s.product)!==JSON.stringify(r)&&s.update(r)})}).catch(r=>P(r,`refresh ${t[n]}`)))}var en=new WeakSet,Q=null,Le=t=>(Q?.add(t),t);function Yt(){if(!Q)return;let t=[...Q];Promise.allSettled(t).then(()=>{!Q||t.some(e=>!Q.has(e))||(t.length===Q.size?(Q=null,document.documentElement.classList.remove(`${a.prefix}-market-pending`)):Yt())})}function qe(t=document){w(t.ownerDocument||t,'script[type="application/json"][data-tether-hydrate]').forEach(e=>{if(!en.has(e)){en.add(e);try{let n=JSON.parse(e.textContent);Gt(n.products);let r=(i,s)=>String(i||"").toUpperCase()===String(s||"").toUpperCase();r(n.country,a.country)&&r(n.language,a.language)?le(n.products):(L("hydration skipped: other market"),Q||(Q=new Set,document.documentElement.classList.add(`${a.prefix}-market-pending`)))}catch(n){U("bad data-tether-hydrate",n)}}})}var{cfg:Cn}=Lt,nn={"config.js":Lt,"client.js":ne,"dom.js":xe,"fragments.js":ie,"loader.js":pe,"selling-plans.js":xt,"status.js":Ce,"cart.js":Se,"product.js":ke,"collection.js":Ie,"mounting.js":Oe},Ne=typeof document<"u"&&document.currentScript?.src||"",kt={};function q(t){if(kt[t])return kt[t];let e=Cn.partsUrl||Ne.replace(/[^/]*$/,""),n=/\.min\.js(\?|$)/.test(Ne)||!Ne?".min":"",r=`${e.replace(/\/?$/,"/")}tether.${t}${n}.js`;return kt[t]=new Promise((i,s)=>{let o=document.createElement("script");o.src=r,o.async=!0,o.onload=()=>window.Tether?.__parts?.[t]?i(window.Tether.__parts[t]):s(new Error(`${r} did not register`)),o.onerror=()=>{delete kt[t],s(new Error(`Could not load ${r}. Host it next to the Tether script, or set partsUrl.`))},document.head.appendChild(o)}),kt[t]}var rn="0.6.1",st=null,Fe=null;function pt(t=document){if(!Tt())return 0;let e=0;return Jt(),qe(t),dt(t,ut()).forEach(n=>{if(Wt.has(n))return;Wt.add(n),e++;let r=new Et(n);mt.add(r),n.addEventListener(`${a.prefix}:list-rendered`,i=>pt(i.detail.container)),Le(r.load())}),dt(t,l("product")).forEach(n=>{zt(n)&&e++}),dt(t,`${l("country-select")},${l("country-bind")}`).length&&q("markets").then(n=>n.renderCountrySelects(t)).catch(n=>P(n,"markets")),(a.account?.clientId||a.account?.server)&&(dt(t,`[${g("account-login")}],[${g("account-bind")}],[${g("orders")}],[${g("show")}^="logged-"]`).length||/[?&]code=/.test(window.location.search)||Ln())&&q("account").then(n=>n.mountAccount(t)).catch(n=>P(n,"account")),dt(t,l("search")).length&&q("search").then(n=>n.mountSearch(t)).catch(n=>P(n,"search")),w(t,l("account-link")).forEach(n=>{n.setAttribute("href",`https://${a.domain}/account`)}),Yt(),A.render(),L(`mounted ${e} scope(s)`,t),e}function on(){A.close()}function kn(t){let e=t?.closest?.(l("product"));return e&&it.get(e)||null}var sn=!1;function In(){sn||(sn=!0,document.addEventListener("click",t=>{let e=t.target;if(!e?.closest)return;if(e.closest(l("cart-open"))){t.preventDefault(),A.toggle();return}if(e.closest(l("cart-close"))){t.preventDefault(),A.close();return}let n=e.closest(l("cart-clear"));if(n){t.preventDefault(),B(n,()=>A.clear().catch(c=>P(c,"cart clear")));return}let r=e.closest(l("checkout"));if(r){t.preventDefault(),B(r,()=>A.checkout());return}let i=e.closest(an());if(i&&i.closest(l("cart-lines"))){let c=i.getAttribute(`data-${a.prefix}-key`),u=A.lines.find(h=>h.id===c),f=h=>{t.preventDefault(),h().catch(m=>P(m,"cart line"))};if(e.closest(l("line-remove")))return i.classList.add("is-busy"),f(()=>A.removeLine(c));if(u&&e.closest(l("line-plus")))return f(()=>A.changeQuantity(c,1));if(u&&e.closest(l("line-minus")))return f(()=>A.changeQuantity(c,-1))}let s=e.closest(l("discount-remove"));if(s){t.preventDefault();let c=s.closest(l("discount-code"))?.getAttribute(g("discount-code"));c&&A.removeDiscount(c).catch(u=>P(u,"discount"));return}let o=e.closest(l("group-add"));o&&(t.preventDefault(),B(o,()=>cn(o)))}),document.addEventListener("change",t=>{let e=t.target;if(!e?.closest)return;let n=e.closest(an()),r=n?.getAttribute(`data-${a.prefix}-key`),i=(s,o)=>{n.classList.add("is-busy"),n.setAttribute("aria-busy","true"),s.catch(c=>P(c,o))};r&&e.matches(`input${l("line","quantity")}`)?i(A.updateLine(r,parseInt(e.value,10)||0),"cart line"):r&&e.matches(`select${l("line-plan")}`)?i(A.updateLine(r,{sellingPlanId:e.value||null}),"cart line plan"):e.matches(`select${l("country-select")}`)?e.value&&Ue(e.value).catch(s=>P(s,"country")):e.matches(l("cart-note"))&&A.setNote(e.value).catch(s=>P(s,"cart note"))}),document.addEventListener("submit",t=>{let e=t.target.closest?.(l("discount-form"));if(!e)return;t.preventDefault();let n=e.querySelector(l("discount-input"))||e.querySelector("input"),r=n?.value.trim();r&&B(e,async()=>{let i=s=>{e.classList.toggle("is-invalid",s),n&&(s?n.setAttribute("aria-invalid","true"):n.removeAttribute("aria-invalid"))};try{await A.applyDiscount(r),i(!1),$("discount-applied",{code:r},e),n&&(n.value="")}catch(s){i(!0),s?.code==="INVALID_DISCOUNT"?$("discount-invalid",{code:r},e):P(s,"discount")}})},!0),document.addEventListener("input",t=>{let e=t.target.closest?.(l("discount-form"));e&&(e.classList.remove("is-invalid"),t.target.removeAttribute?.("aria-invalid"))}),window.addEventListener("storage",t=>{a.domain&&t.key?.startsWith(`${a.prefix}:`)&&q("extras").then(e=>e.onStorage(t)).catch(()=>{})}),document.addEventListener(`${a.prefix}:variant-changed`,t=>{let e=t.target;(a.variantUrl||e.hasAttribute?.(g("variant-url")))&&q("extras").then(n=>n.writeVariantUrl(e,t.detail)).catch(()=>{})}),a.astro!==!1&&(document.addEventListener("astro:page-load",()=>(st||Promise.resolve()).then(()=>{let t=_e();if(!t&&De){try{t=JSON.parse(localStorage.getItem(`${a.prefix}:market:${a.domain}`)||"null")}catch{t=null}t=t?.country?t:un}De=!!_e(),t?.country&&(String(t.country).toUpperCase()!==String(a.country||"").toUpperCase()||String(t.language||"").toUpperCase()!==String(a.language||"").toUpperCase())?Ue(t.country,{language:t.language??null,locale:t.locale,remember:!1}).then(()=>pt(document),()=>pt(document)):pt(document)})),document.addEventListener("astro:before-swap",()=>on())),window.addEventListener("online",()=>{Te(),mt.forEach(t=>{t.root.getAttribute(g("state"))==="error"&&t.load()})}),document.addEventListener("keydown",t=>{if(!A.isOpen())return;if(t.key==="Escape"){A.close();return}if(t.key!=="Tab"||a.cartFocus===!1)return;let e=A.drawers().find(s=>s.classList.contains(a.cartDrawerOpenClass)),n=e?Rt(e):[];if(!n.length)return;let r=n[0],i=n[n.length-1];(!e.contains(document.activeElement)||t.shiftKey&&document.activeElement===r||!t.shiftKey&&document.activeElement===i)&&(t.preventDefault(),(t.shiftKey?i:r).focus())}))}function an(){return`[data-${a.prefix}-key]`}var cn=t=>q("extras").then(e=>e.addGroup(t)),It=null;function ln(t={}){return st&&!Object.keys(t).length?st:(Zt({...window.TETHER_CONFIG||{},...t}),Tt()?(In(),a.observe&&On(),a.analytics&&!It&&(It=[],["product-ready","list-ready","cart-updated","cart-toggled","checkout","search"].forEach(e=>document.addEventListener(`${a.prefix}:${e}`,n=>It.push(n))),document.addEventListener("astro:page-load",()=>It.push(new CustomEvent(`${a.prefix}:page`))),q("analytics").then(e=>e.startAnalytics(It)).catch(e=>P(e,"analytics"))),st=Tn(t).then(()=>A.init()).then(async e=>{let n=a.country?String(a.country).toUpperCase():null;if(e&&n&&e.buyerIdentity?.countryCode&&e.buyerIdentity.countryCode!==n)try{e=await A.setBuyerIdentity({countryCode:n},{create:!1})}catch(r){P(r,"cart country")}return $("ready",{cart:e}),je}),st):(U("TETHER_CONFIG is missing domain or token. Tether is idle."),st=Promise.resolve(null),st))}function _e(t=document){let e=r=>t.querySelector(`meta[name="${a.prefix}-page-${r}"]`)?.getAttribute("content")||void 0,n=e("country");return n?{country:n.toUpperCase(),language:e("language"),locale:e("locale")}:null}var un=null,De=!1;async function Tn(t){let e=a.markets||{};un={country:a.country,language:a.language,locale:a.locale};let n=_e();if(De=!!n,n){a.country=n.country,a.language=n.language?n.language.toUpperCase():void 0,n.locale&&(a.locale=n.locale);return}if(e.detect===!1)return;let r=null;if(e.detect)try{r=(await q("markets")).detectMarket(e)}catch(i){P(i,"markets");return}else if(e.remember!==!1){try{r=JSON.parse(localStorage.getItem(`${a.prefix}:market:${a.domain}`)||"null")}catch{}r&&!/^[A-Z]{2}$/.test(r.country||"")&&(r=null)}r&&(r.country&&(a.country=r.country),r.language&&(a.language=r.language),r.locale&&!t.locale&&(a.locale=r.locale),L("market",r))}function Ln(){try{return!!(sessionStorage[`${a.prefix}:account:${a.domain}`]||localStorage[`${a.prefix}:account:${a.domain}`]||localStorage[`${a.prefix}:account-hint:${a.domain}`])}catch{return!1}}var qn=new Proxy({},{get:(t,e)=>(...n)=>q("account").then(r=>r[e](...n))});function Ue(t,e){return q("markets").then(n=>n.setCountry(t,e))}function On(){if(Fe||typeof MutationObserver>"u")return;let t=null,e=new Set;Fe=new MutationObserver(n=>{n.forEach(r=>r.addedNodes.forEach(i=>{i.nodeType===1&&e.add(i)})),clearTimeout(t),t=setTimeout(()=>{e.forEach(r=>{r.isConnected&&pt(r)}),e.clear()},50)}),Fe.observe(document.body,{childList:!0,subtree:!0})}var je={VERSION:rn,init:ln,mount:pt,unmount:on,get config(){return a},get ready(){return st||Promise.resolve(null)},query:F,withContext:Ot,cart:A,getProduct:nt,getProducts:vt,getRecommendations:bt,getScope:kn,addGroup:cn,account:qn,primeProduct:et,normalizeProductKey:ct,clearProductCache:ce,formatMoney:D,imageUrl:jt,plans:xt,TetherError:E,resolveProductKey:z,setCountry:Ue,detectMarket:t=>q("markets").then(e=>e.detectMarket(t||a.markets)),getLocalization:()=>q("markets").then(t=>t.getLocalization()),diagnose:t=>q("diagnose").then(e=>e.diagnose({...t,version:rn})),__core:nn,__parts:{},on(t,e){let n=r=>e(r.detail,r);return document.addEventListener(`${a.prefix}:${t}`,n),()=>document.removeEventListener(`${a.prefix}:${t}`,n)}},Pr=je;if(typeof window<"u"&&typeof document<"u"&&(window.Tether=je,window.TETHER_CONFIG&&window.TETHER_CONFIG.autoMount!==!1&&!window.TETHER_INTEGRATION)){let e=()=>ln().then(()=>pt(document));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}})();
|
|
5
5
|
//# sourceMappingURL=tether.min.js.map
|