@occluze/tether 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +52 -110
  2. package/dist/esm/astro.js +1 -1
  3. package/dist/esm/chunks/{account-CXMA5RPZ.js → account-5X563BON.js} +1 -1
  4. package/dist/esm/chunks/{account-pages-IZO7FEOZ.js → account-pages-XR6QZ3DX.js} +1 -1
  5. package/dist/esm/chunks/analytics-JSFHDBU3.js +1 -0
  6. package/dist/esm/chunks/{chunk-BBVUVPMO.js → chunk-255K6OZ7.js} +1 -1
  7. package/dist/esm/chunks/chunk-3OEIEDTK.js +1 -0
  8. package/dist/esm/chunks/chunk-55OHYO66.js +1 -0
  9. package/dist/esm/chunks/chunk-A3GXCQJ4.js +1 -0
  10. package/dist/esm/chunks/chunk-EW3GKRT4.js +1 -0
  11. package/dist/esm/chunks/{chunk-N3V45JPS.js → chunk-FM7ZLLVP.js} +1 -1
  12. package/dist/esm/chunks/chunk-GXCCTPDF.js +1 -0
  13. package/dist/esm/chunks/{chunk-6TFMLT4A.js → chunk-J7GYROV4.js} +1 -1
  14. package/dist/esm/chunks/{chunk-WT7RGGJU.js → chunk-KNJB72OO.js} +1 -1
  15. package/dist/esm/chunks/chunk-KVPLRK6Y.js +1 -0
  16. package/dist/esm/chunks/chunk-O4G2PAQC.js +1 -0
  17. package/dist/esm/chunks/chunk-WNFEYPHV.js +1 -0
  18. package/dist/esm/chunks/{chunk-4HD4J5JC.js → chunk-WXF4L42L.js} +1 -1
  19. package/dist/esm/chunks/{diagnose-XCEBQKBO.js → diagnose-XQQTDHLQ.js} +1 -1
  20. package/dist/esm/chunks/extras-6WLNUEGD.js +1 -0
  21. package/dist/esm/chunks/{markets-ui-M4IQ62CT.js → markets-ui-OAJW4PFU.js} +1 -1
  22. package/dist/esm/chunks/search-LUECIYJR.js +1 -0
  23. package/dist/esm/index.js +1 -1
  24. package/dist/esm/server.js +2 -2
  25. package/dist/tether.diagnose.js +2 -2
  26. package/dist/tether.diagnose.min.js +2 -2
  27. package/dist/tether.extras.js +33 -22
  28. package/dist/tether.extras.min.js +1 -1
  29. package/dist/tether.js +210 -196
  30. package/dist/tether.markets.js +13 -2
  31. package/dist/tether.markets.min.js +1 -1
  32. package/dist/tether.min.js +3 -3
  33. package/dist/tether.min.js.map +4 -4
  34. package/dist/types/src/account/page-answers.d.ts +3 -1
  35. package/dist/types/src/analytics.d.ts +3 -1
  36. package/dist/types/src/cart/mutations.d.ts +2 -2
  37. package/dist/types/src/cart/store.d.ts +8 -2
  38. package/dist/types/src/cart.d.ts +1 -0
  39. package/dist/types/src/client.d.ts +21 -11
  40. package/dist/types/src/controls/navigation.d.ts +3 -1
  41. package/dist/types/src/dom.d.ts +3 -1
  42. package/dist/types/src/index.d.ts +2 -2
  43. package/dist/types/src/markets.d.ts +9 -2
  44. package/dist/types/src/markup.d.ts +7 -5
  45. package/dist/types/src/presets/barba.d.ts +3 -1
  46. package/dist/types/src/product-state.d.ts +3 -1
  47. package/dist/types/src/server.d.ts +4 -4
  48. package/dist/types/src/store-html.d.ts +4 -4
  49. package/dist/types/src/uri.d.ts +6 -0
  50. package/package.json +57 -5
  51. package/dist/esm/chunks/analytics-PG5FPRDN.js +0 -1
  52. package/dist/esm/chunks/chunk-E5YO6274.js +0 -1
  53. package/dist/esm/chunks/chunk-EW5SYO6L.js +0 -1
  54. package/dist/esm/chunks/chunk-HJY2JSNB.js +0 -1
  55. package/dist/esm/chunks/chunk-MQYB6BH4.js +0 -1
  56. package/dist/esm/chunks/chunk-RPMBCAGS.js +0 -1
  57. package/dist/esm/chunks/chunk-VFNHIGCS.js +0 -1
  58. package/dist/esm/chunks/chunk-YN6LEBEN.js +0 -1
  59. package/dist/esm/chunks/chunk-Z6HS3H7K.js +0 -1
  60. package/dist/esm/chunks/extras-4HU3VSBQ.js +0 -1
  61. package/dist/esm/chunks/search-A5DS2IOS.js +0 -1
@@ -0,0 +1 @@
1
+ var b=Object.defineProperty;var Y=(n,e,t)=>e in n?b(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ln=(n,e)=>{for(var t in e)b(n,t,{get:e[t],enumerable:!0})};var Un=(n,e,t)=>Y(n,typeof e!="symbol"?e+"":e,t);var G=/^(\d{4})-(01|04|07|10)$/;function C(n){let e=G.exec(typeof n=="string"?n:"");return e?{year:Number(e[1]),month:Number(e[2])}:null}var S=n=>C(n)!==null,z=(n,e)=>`${n}-${String(e).padStart(2,"0")}`;function A(n,e=1){let t=C(n);if(!t)throw new Error(`not a quarterly Shopify API version: ${n}`);let o=t.year*4+(t.month-1)/3+e;return z(Math.floor(o/4),o%4*3+1)}function Fn(n,e=new Date){if(n==="unstable")return{version:n,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let t=C(n);if(!t)return{version:n,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let o=new Date(Date.UTC(t.year,t.month-1,1)),r=new Date(Date.UTC(t.year,t.month-1+12,1)),i=(r.getTime()-e.getTime())/2630016e3,f=o<=e,u=`supported until about ${r.toISOString().slice(0,7)}`;return f?i<=0?u="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see docs/reference.md)":i<3&&(u=`${u}: plan the upgrade to ${A(n)} or later (see docs/reference.md)`):u="not released yet (release candidate at best)",{version:n,ok:f&&i>0,monthsLeft:Math.round(i),next:A(n),note:u}}function O(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function j(n,e){return O(n)?n[e]:void 0}function v(n){return Array.isArray(n)?n:[]}function Q(n){return typeof n=="string"&&n!==""?n:null}var Z=n=>typeof n=="number"&&Number.isFinite(n)?n:null,Vn=n=>Z(n)??0,x=(n,e)=>v(n).map(t=>e(t)),Hn=(n,e)=>({nodes:x(j(n,"nodes"),e)}),Dn=n=>x(n,Q).filter(e=>e!==null);var B=/^[A-Z]{2}$/,W=new Set(["XX","T1"]),J=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),X=/^[A-Z]{2,3}$/;function h(n){let e=(typeof n=="string"?n:"").trim().toUpperCase();return!B.test(e)||W.has(e)?null:e}function T(n){let e=(typeof n=="string"?n:"").trim().replace("-","_").toUpperCase();if(J.has(e))return e;let t=e.split("_")[0]??"";return X.test(t)?t:null}var E="2026-07";var q=/^[A-Za-z0-9_.-]+$/,nn=/^(\$app(:[A-Za-z0-9_-]+)?|[A-Za-z0-9_.-]+)$/,en=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,tn=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,on=/^[A-Za-z_$][\w$]*$/,R="https://site.invalid",rn=new Set(["localhost","127.0.0.1","[::1]"]),N=["saved","server","webflow"],sn=["no-banner","default-banner","custom-banner"],y=n=>typeof n=="string"&&n!=="",an=n=>typeof n=="function";function P(n,e){if(typeof n!="string"||!n)return"";let t=n.replace(/^https?:\/\//,"").replace(/\/.*$/,"");return fn(t)?t:(e("domain",n),"")}function M(n){if(!y(n))return!1;try{let e=new URL(n,`${R}/`);return e.origin===R?!0:e.protocol==="https:"||e.protocol==="http:"&&rn.has(e.hostname)}catch{return!1}}function L(n,e){return n==null||n===""?null:typeof n=="string"&&(M(n)||un(n))?n:(e("partsUrl",n),null)}function un(n){if(typeof location>"u")return!1;try{return new URL(n).origin===location.origin}catch{return!1}}function ln(n){if(typeof n!="string")return null;try{let e=new URL(n);return e.protocol==="https:"&&e.href===new URL(e.origin).href?e.origin:null}catch{return null}}function U(n,e){if(!Array.isArray(n))return e("embedOrigins",n),[];let t=[],o=n;for(let r of o){let i=ln(r);i?t.push(i):e("embedOrigin",r)}return t}function cn(n){let e,t;if(typeof n=="string"){let o=n.indexOf(".");e=o>0?n.slice(0,o):"",t=n.slice(o+1)}else typeof n=="object"&&n!==null&&(e=Reflect.get(n,"namespace"),t=Reflect.get(n,"key"));return typeof e!="string"||typeof t!="string"?null:nn.test(e)&&q.test(t)?{namespace:e,key:t}:null}function I(n,e){if(!Array.isArray(n))return e("metafields",n),[];let t=[],o=n;for(let r of o){let i=cn(r);i?t.push(typeof r=="string"?r:i):e("metafield",r)}return t}var d=n=>e=>n(e)?e:void 0,fn=n=>y(n)&&en.test(n),dn=n=>y(n)&&tn.test(n),pn=n=>typeof n=="boolean"||y(n)&&on.test(n),g=d(M),k=d(y),_=d(n=>typeof n=="boolean"),F=d(an);function m(n,e,t,o){if(e==null)return null;if(!O(e))return o(n,e),null;let r={};for(let i in t){let f=e[i];if(f===void 0)continue;let u=t[i](f);u===void 0?o(`${n}.${i}`,f):r[i]=u}return r}var gn={server:g,orderUrl:g,subscriptionsUrl:g,paymentUrl:g,logoutUrl:g,locale:k,navigate:F},yn="customer accounts need the Worker since 0.7.0: set account.server",mn={country:k,language:k,locale:k},On={detect:n=>{if(typeof n=="boolean")return n;let e=Array.isArray(n)?n:[n];return typeof n=="string"||Array.isArray(n)?N.filter(t=>e.includes(t)):void 0},locales:n=>{if(!O(n))return;let e={};for(let[t,o]of Object.entries(n)){let r=m(`markets.locales.${t}`,o,mn,()=>{});r&&(e[t]=r)}return e},cookie:d(dn),remember:_,strict:_},kn={consent:n=>sn.find(e=>e===n),proxy:n=>n!==void 0&&!!n},Cn={dataLayer:d(pn),shopify:n=>typeof n=="boolean"?n:m("analytics.shopify",n,kn,()=>{})??void 0,onEvent:F};function $(n,e,t){let o=m("account",n,gn,e);if(o===null)return null;let{server:r}=o;return r===void 0?(t(yn),null):{...o,server:r}}var w=(n,e)=>m("markets",n,On,e),V=(n,e)=>m("analytics",n,Cn,e);var l={domain:"",token:"",apiVersion:E,country:void 0,language:void 0,locale:void 0,markets:null,prefix:"tether",productPath:"/product",collectionPath:"/collection",metafields:[],embedOrigins:[],imagesFirst:25,variantsFirst:100,sellingPlanGroupsFirst:10,sellingPlansFirst:25,collectionFirst:24,retries:2,revalidate:!0,storageKey:"",cartDrawerOpenClass:"is-open",openCartOnAdd:!0,cartFocus:!0,checkoutTarget:"_self",defaultPurchase:"one-time",variantUrl:!1,maxAge:60,lowStock:5,searchDelay:150,autoMount:!0,observe:!1,astro:!0,partsUrl:null,analytics:null,account:null,warningText:null,formatMoney:null,onLayoutChange:null,onCartOpen:null,onCartClose:null,onLineEnter:null,onLineLeave:null,onValueChange:null,onError:null,debug:!1},a={...l};function K(n){let e=t=>(c(`Tether.config is read-only (${String(t)}): pass options to Tether.init() instead`),!1);return new Proxy(n,{get(t,o){let r=Reflect.get(t,o);return typeof r=="object"&&r!==null?K(r):r},set:(t,o)=>e(o),deleteProperty:(t,o)=>e(o),defineProperty:(t,o)=>e(o)})}var Xn=K(a),hn=/^[a-z][a-z0-9-]*$/,Tn=["revalidate","openCartOnAdd","cartFocus","variantUrl","autoMount","observe","astro","debug"],wn=["token","productPath","collectionPath","cartDrawerOpenClass"],bn=["imagesFirst","variantsFirst","sellingPlanGroupsFirst","sellingPlansFirst","collectionFirst","retries","maxAge","lowStock","searchDelay"],An=["warningText","formatMoney","onLayoutChange","onCartOpen","onCartClose","onLineEnter","onLineLeave","onValueChange","onError"];function p(n,e,t){return e!==void 0&&c(`invalid ${n} ${JSON.stringify(e)}: using ${JSON.stringify(t)}`),t}function s(n,e){c(`invalid ${n} ${JSON.stringify(e)}: ignored`)}function Sn(n){for(let e of Object.keys(n))e in l||c(`unknown option ${JSON.stringify(e)}: ignored`)}function xn(n,e,t){typeof t=="function"?n[e]=t:t!=null&&s(e,t)}function En(n,e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:p(n,e,l[n])}function Rn(n,e){return typeof e=="boolean"?e:p(n,e,l[n])}function _n(n,e){return typeof e=="string"?e:p(n,e,l[n])}function Nn(n){if(!(n==null||n==="")){try{if(typeof n=="string"&&Intl.getCanonicalLocales(n).length)return n}catch{}s("locale",n)}}function H(n,e,t){return t.find(o=>o===e)??p(n,e,t[0])}function Pn(n){return n==="unstable"?(c('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),n):S(n)?n:p("apiVersion",n,l.apiVersion)}function D(n,e,t){if(e==null||e==="")return;let o=t(e);if(o!==null)return o;s(n,e)}function Mn(n){Sn(n);let e=P(n.domain,s),t=typeof n.prefix=="string"&&hn.test(n.prefix)?n.prefix:p("prefix",n.prefix,l.prefix),o={...l,domain:e,apiVersion:Pn(n.apiVersion),country:D("country",n.country,h),locale:Nn(n.locale),partsUrl:L(n.partsUrl,s),language:D("language",n.language,T),markets:w(n.markets,s),analytics:V(n.analytics,s),account:$(n.account,s,c),prefix:t,storageKey:typeof n.storageKey=="string"&&n.storageKey?n.storageKey:`${t}:cart:${e}`,metafields:I(n.metafields??[],s),embedOrigins:U(n.embedOrigins??[],s),checkoutTarget:H("checkoutTarget",n.checkoutTarget,["_self","_blank"]),defaultPurchase:H("defaultPurchase",n.defaultPurchase,["one-time","subscription"])};for(let r of bn)o[r]=En(r,n[r]);for(let r of Tn)o[r]=Rn(r,n[r]);for(let r of wn)o[r]=_n(r,n[r]);for(let r of An)xn(o,r,n[r]);return o}var qn=n=>w(n,s);function ne(n={}){let e=Mn(n);for(let t of Object.keys(a))t in e||Reflect.deleteProperty(a,t);return Object.assign(a,e)}var ee=()=>!!(a.domain&&a.token);function te(...n){a.debug&&console.log(`[${a.prefix}]`,...n)}function c(...n){console.warn(`[${a.prefix}]`,...n)}function oe(n,e){if(c(e,n instanceof Error&&n.message?n.message:n),!!a.onError)try{a.onError(n,e)}catch(t){c("onError threw",t)}}function se(n){return n instanceof Error?n.message:String(n)}var ue={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function le(n){if(typeof n!="string")return!1;try{return new URL(n).protocol==="https:"}catch{return!1}}function ce(n){return/^shp[a-z]{2}_/.test(n.trim())}function fe(n,e){if(!n)return"";let t=parseFloat(n.amount);if(Number.isNaN(t))return"";try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:n.currencyCode}).format(t)}catch{return`${n.currencyCode} ${t.toFixed(2)}`}}function de(n,e,t){if(!/\{(handle|id)\}/.test(n))return e?`${n.replace(/\/$/,"")}/${encodeURIComponent(e)}`:null;let o=t?t.split("/").at(-1)??"":"";return n.includes("{handle}")&&!e||n.includes("{id}")&&!o?null:n.replace(/\{handle\}/g,encodeURIComponent(e??"")).replace(/\{id\}/g,encodeURIComponent(o))}function pe(n){let e=String(n??"").trim();return e?e.startsWith("gid://")?e:/^\d+$/.test(e)?`gid://shopify/Product/${e}`:/\/products\/([^/?#]+)/.exec(e)?.[1]??e:null}export{Ln as a,Un as b,Fn as c,O as d,j as e,v as f,Q as g,Z as h,Vn as i,x as j,Hn as k,Dn as l,N as m,cn as n,h as o,T as p,l as q,a as r,Xn as s,Mn as t,qn as u,ne as v,ee as w,te as x,c as y,oe as z,se as A,ue as B,le as C,ce as D,fe as E,de as F,pe as G};
@@ -1,4 +1,4 @@
1
- import{a as b,b as h,c as y,d as v,i as $}from"./chunk-MQYB6BH4.js";import{G as k,a as te,d as x,e as T,n as _,r as P,x as V}from"./chunk-E5YO6274.js";var de={};te(de,{GID:()=>Q,allPlans:()=>I,allocationFor:()=>M,findPlan:()=>ue,hasPlans:()=>oe,planAdjustment:()=>ce,planCheckoutCharge:()=>se,planPrice:()=>B,planSavings:()=>ae,plansForVariant:()=>le,toGid:()=>C});var re=/^(-?)(\d+)(?:\.(\d+))?$/;function G(e,n){let t=re.exec(e.trim());if(!t)return null;let[,r="",o="0",l=""]=t,u=BigInt(`${o}${l.padEnd(n,"0")}`);return r==="-"?-u:u}var L=e=>e.split(".")[1]?.length??0;function Fe(e,n){if(e==null||n==null)return!1;let t=Math.max(L(e.trim()),L(n.trim())),r=G(e,t),o=G(n,t);return r===null||o===null?!1:r>o}var q=2,U=new Map;function W(e){let n=U.get(e);if(n!==void 0)return n;let t=q;try{t=new Intl.NumberFormat("en",{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??q}catch{}return U.set(e,t),t}function O(e){return Math.round(parseFloat(e.amount)*10**W(e.currencyCode))}function K(e,n){let t=W(n);return{amount:(e/10**t).toFixed(t),currencyCode:n}}var ie=100;function C(e,n){let t=typeof e=="string"||typeof e=="number"?String(e).trim():"";return t?t.startsWith("gid://")?t:/^\d+$/.test(t)?`gid://shopify/${n}/${t}`:t:null}var Q={product:e=>C(e,"Product"),variant:e=>C(e,"ProductVariant"),sellingPlan:e=>C(e,"SellingPlan")};function I(e){return(e?.sellingPlanGroups?.nodes??[]).flatMap(t=>t.sellingPlans.nodes.map(r=>({...r,group:t})))}function oe(e){return I(e).length>0}function M(e,n){return!e||!n?null:(e.sellingPlanAllocations?.nodes??[]).find(r=>r.sellingPlan.id===n)??null}function le(e,n){return I(e).filter(t=>M(n,t.id))}function B(e,n){let t=M(e,n)?.priceAdjustments[0];return t?.perDeliveryPrice??t?.price??e?.price??null}function se(e,n){let t=M(e,n);return t?.checkoutChargeAmount??t?.priceAdjustments[0]?.price??e?.price??null}function ae(e,n){let t=B(e,n);if(!e||!t)return{amount:null,percentage:0};let r=parseFloat(e.price.amount),o=parseFloat(t.amount);if(!Number.isFinite(r)||!Number.isFinite(o)||r<=0||o>=r)return{amount:null,percentage:0};let l=O(e.price)-O(t);return{amount:K(l,e.price.currencyCode),percentage:Math.round((1-o/r)*ie)}}function ce(e){let n=e?.priceAdjustments[0]?.adjustmentValue;if(!n)return null;switch(n.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:n.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:n.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:n.price};default:return null}}function ue(e,n){if(!n)return null;let t=I(e),r=Q.sellingPlan(n),o=n.trim().toLowerCase();return t.find(l=>l.id===r)??t.find(l=>l.name.toLowerCase()===o)??t.find(l=>l.options.some(u=>u.value.toLowerCase()===o))??null}var i="amount currencyCode",H={inventory:!0},Y=e=>e.inventory?"quantityAvailable":"",g="url altText width height";function pe(e){let n=[];for(let r of e){let o=_(r);o&&n.push(o)}return n.length?`metafields(identifiers:[${n.map(({namespace:r,key:o})=>`{namespace: ${JSON.stringify(r)}, key: ${JSON.stringify(o)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${g}}}}}`:""}var ge=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${i}}}... on SellingPlanFixedPriceAdjustment{price{${i}}}}}`,me=` sellingPlan{id}checkoutChargeAmount{${i}}remainingBalanceChargeAmount{${i}}priceAdjustments{price{${i}}compareAtPrice{${i}}perDeliveryPrice{${i}}unitPrice{${i}}}`;function z(e=P,n=H){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${g}}images(first:${e.imagesFirst}){nodes{${g}}}options{name optionValues{name swatch{color image{previewImage{${g}}}}}}priceRange{minVariantPrice{${i}}maxVariantPrice{${i}}}compareAtPriceRange{minVariantPrice{${i}}maxVariantPrice{${i}}}${pe(e.metafields)} sellingPlanGroups(first:${e.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${e.sellingPlansFirst}){nodes{${ge}}}}}variants(first:${e.variantsFirst}){nodes{id title availableForSale currentlyNotInStock ${Y(n)} sku barcode selectedOptions{name value}image{${g}}price{${i}}compareAtPrice{${i}}unitPrice{${i}}sellingPlanAllocations(first:${e.sellingPlansFirst}){nodes{${me}}}}}}`}function Ne(e=H){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${i}}totalAmount{${i}}checkoutChargeAmount{${i}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${i}}subtotalAmount{${i}}amountPerQuantity{${i}}compareAtAmountPerQuantity{${i}}}discountAllocations{discountedAmount{${i}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${i}}priceAdjustments{price{${i}}compareAtPrice{${i}}perDeliveryPrice{${i}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping ${Y(e)} image{${g}}price{${i}}compareAtPrice{${i}}selectedOptions{name value}product{id title handle vendor featuredImage{${g}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function J(){return`
1
+ import{a as b,b as h,c as y,d as v,h as $}from"./chunk-EW3GKRT4.js";import{G as k,a as te,d as x,e as T,n as _,r as P,x as V}from"./chunk-GXCCTPDF.js";var de={};te(de,{GID:()=>Q,allPlans:()=>I,allocationFor:()=>M,findPlan:()=>ue,hasPlans:()=>oe,planAdjustment:()=>ce,planCheckoutCharge:()=>se,planPrice:()=>B,planSavings:()=>ae,plansForVariant:()=>le,toGid:()=>C});var re=/^(-?)(\d+)(?:\.(\d+))?$/;function G(e,n){let t=re.exec(e.trim());if(!t)return null;let[,r="",o="0",l=""]=t,u=BigInt(`${o}${l.padEnd(n,"0")}`);return r==="-"?-u:u}var L=e=>e.split(".")[1]?.length??0;function Fe(e,n){if(e==null||n==null)return!1;let t=Math.max(L(e.trim()),L(n.trim())),r=G(e,t),o=G(n,t);return r===null||o===null?!1:r>o}var q=2,U=new Map;function W(e){let n=U.get(e);if(n!==void 0)return n;let t=q;try{t=new Intl.NumberFormat("en",{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??q}catch{}return U.set(e,t),t}function O(e){return Math.round(parseFloat(e.amount)*10**W(e.currencyCode))}function K(e,n){let t=W(n);return{amount:(e/10**t).toFixed(t),currencyCode:n}}var ie=100;function C(e,n){let t=typeof e=="string"||typeof e=="number"?String(e).trim():"";return t?t.startsWith("gid://")?t:/^\d+$/.test(t)?`gid://shopify/${n}/${t}`:t:null}var Q={product:e=>C(e,"Product"),variant:e=>C(e,"ProductVariant"),sellingPlan:e=>C(e,"SellingPlan")};function I(e){return(e?.sellingPlanGroups?.nodes??[]).flatMap(t=>t.sellingPlans.nodes.map(r=>({...r,group:t})))}function oe(e){return I(e).length>0}function M(e,n){return!e||!n?null:(e.sellingPlanAllocations?.nodes??[]).find(r=>r.sellingPlan.id===n)??null}function le(e,n){return I(e).filter(t=>M(n,t.id))}function B(e,n){let t=M(e,n)?.priceAdjustments[0];return t?.perDeliveryPrice??t?.price??e?.price??null}function se(e,n){let t=M(e,n);return t?.checkoutChargeAmount??t?.priceAdjustments[0]?.price??e?.price??null}function ae(e,n){let t=B(e,n);if(!e||!t)return{amount:null,percentage:0};let r=parseFloat(e.price.amount),o=parseFloat(t.amount);if(!Number.isFinite(r)||!Number.isFinite(o)||r<=0||o>=r)return{amount:null,percentage:0};let l=O(e.price)-O(t);return{amount:K(l,e.price.currencyCode),percentage:Math.round((1-o/r)*ie)}}function ce(e){let n=e?.priceAdjustments[0]?.adjustmentValue;if(!n)return null;switch(n.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:n.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:n.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:n.price};default:return null}}function ue(e,n){if(!n)return null;let t=I(e),r=Q.sellingPlan(n),o=n.trim().toLowerCase();return t.find(l=>l.id===r)??t.find(l=>l.name.toLowerCase()===o)??t.find(l=>l.options.some(u=>u.value.toLowerCase()===o))??null}var i="amount currencyCode",H={inventory:!0},Y=e=>e.inventory?"quantityAvailable":"",g="url altText width height";function pe(e){let n=[];for(let r of e){let o=_(r);o&&n.push(o)}return n.length?`metafields(identifiers:[${n.map(({namespace:r,key:o})=>`{namespace: ${JSON.stringify(r)}, key: ${JSON.stringify(o)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${g}}}}}`:""}var ge=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${i}}}... on SellingPlanFixedPriceAdjustment{price{${i}}}}}`,me=` sellingPlan{id}checkoutChargeAmount{${i}}remainingBalanceChargeAmount{${i}}priceAdjustments{price{${i}}compareAtPrice{${i}}perDeliveryPrice{${i}}unitPrice{${i}}}`;function z(e=P,n=H){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${g}}images(first:${e.imagesFirst}){nodes{${g}}}options{name optionValues{name swatch{color image{previewImage{${g}}}}}}priceRange{minVariantPrice{${i}}maxVariantPrice{${i}}}compareAtPriceRange{minVariantPrice{${i}}maxVariantPrice{${i}}}${pe(e.metafields)} sellingPlanGroups(first:${e.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${e.sellingPlansFirst}){nodes{${ge}}}}}variants(first:${e.variantsFirst}){nodes{id title availableForSale currentlyNotInStock ${Y(n)} sku barcode selectedOptions{name value}image{${g}}price{${i}}compareAtPrice{${i}}unitPrice{${i}}sellingPlanAllocations(first:${e.sellingPlansFirst}){nodes{${me}}}}}}`}function Ne(e=H){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${i}}totalAmount{${i}}checkoutChargeAmount{${i}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${i}}subtotalAmount{${i}}amountPerQuantity{${i}}compareAtAmountPerQuantity{${i}}}discountAllocations{discountedAmount{${i}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${i}}priceAdjustments{price{${i}}compareAtPrice{${i}}perDeliveryPrice{${i}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping ${Y(e)} image{${g}}price{${i}}compareAtPrice{${i}}selectedOptions{name value}product{id title handle vendor featuredImage{${g}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function J(){return`
2
2
  id handle title description descriptionHtml
3
3
  image { ${g} }
4
4
  seo { title description }`}var N={amount:"string",currencyCode:"string"},f={id:"string",handle:"string",title:"string",options:["object"],images:{nodes:["object"]},priceRange:{minVariantPrice:N,maxVariantPrice:N},variants:{nodes:[{id:"string",price:N,selectedOptions:["object"]}]}},D={nodes:[f],pageInfo:{hasNextPage:"boolean"}},_e=e=>T(e,"id")!==""&&T(e,"handle")!==""&&h(e,f),X=e=>x(e)&&(e.id===void 0||h(e,f));var fe=1e4,Pe=6e4,c=new Map,E=new Map,m=new Set,F=new Map,ne=[],R=!1,A=0,Z=e=>e.startsWith("gid://"),j=k;function S(e){if(!e)return;let n=Promise.resolve(e);c.set(e.handle,n),c.set(e.id,n)}function he(e){let n=j(e);if(!n)return Promise.reject(new b("empty product key",{code:"NOT_FOUND"}));let t=c.get(n);if(t)return t;let r=new Promise((o,l)=>{E.set(n,{resolve:o,reject:l}),ne.push(n),R||(R=!0,setTimeout(()=>void Se(),0))});return c.set(n,r),r}var w=e=>n=>`${e}${z(P,n)}`;function ye(e){let n=e.filter(Z),t=e.filter(p=>!Z(p)),r=[],o=[],l={};return n.length&&(r.push("$ids: [ID!]!"),l.ids=n,o.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),t.forEach((p,s)=>{r.push(`$h${s}: String!`),l[`h${s}`]=p,o.push(`h${s}: product(handle: $h${s}) { ...TetherProduct }`)}),{query:w(`query TetherProducts(${r.join(",")}){${o.join(" ")}}`),variables:l,handles:t}}function ee(e,n){let t=E.get(e);E.delete(e),t&&n(t)}function $e(e,n){if(n!==A)return;let t=c.get(e);setTimeout(()=>{c.get(e)===t&&c.delete(e)},fe)}function Ae(e){if(!x(e))return!1;let{byId:n=[],...t}=e;return h(n,[y(X)])&&Object.values(t).every(y(f))}async function Se(){R=!1;let e=A,n=ne.splice(0);if(!n.length)return;let{query:t,variables:r,handles:o}=ye(n);V("fetch products",n);let l;try{l=await $(t,r,Ae)}catch(s){n.forEach(d=>{ee(d,a=>{e===A&&c.delete(d),a.reject(s)})});return}let u=new Map;for(let s of l.byId??[])s?.id&&u.set(s.id,s);o.forEach((s,d)=>{let a=l[`h${d}`];a&&u.set(s,a)});let p=Date.now();n.forEach(s=>{ee(s,d=>{let a=u.get(s);if(!a){$e(s,e),d.reject(new b(`Product not found: ${s}`,{code:"NOT_FOUND"}));return}e===A&&(S(a),F.set(a.handle,p),F.set(a.id,p)),d.resolve(a)})})}function Ke(){c.clear(),A+=1,m.clear(),F.clear()}function Qe(e){for(let n of e??[])!n.id||!n.handle||Date.now()-(F.get(n.handle)??0)<Pe&&c.has(n.handle)||(S(n),m.add(n.handle),m.add(n.id))}function Be(e){let n=j(e);return!n||!m.has(n)?!1:(m.delete(n),c.get(n)?.then(t=>{m.delete(t.handle),m.delete(t.id)},xe),!0)}function xe(){}function He(e){let n=j(e);return n&&c.delete(n),he(e)}var be=v({collection:y({handle:"string",products:D})}),ve=v({products:D}),Ce=v({productRecommendations:y([f])}),Ie=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${J()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,Me="query TetherSearch($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}";async function Ye({collection:e,query:n,first:t=P.collectionFirst,after:r=null,sortKey:o,reverse:l=!1,filters:u}={}){if(e){let s=await $(w(Ie),{handle:e,first:t,after:r,sortKey:o||void 0,reverse:l,filters:u??void 0},be);if(!s.collection)throw new b(`Collection not found: ${e}`,{code:"NOT_FOUND"});let{products:d,...a}=s.collection;return d.nodes.forEach(S),{collection:a,products:d.nodes,pageInfo:d.pageInfo}}let p=await $(w(Me),{first:t,after:r,query:n||void 0,sortKey:o||void 0,reverse:l},ve);return p.products.nodes.forEach(S),{collection:null,products:p.products.nodes,pageInfo:p.products.pageInfo}}async function ze(e,n="RELATED"){let t=j(typeof e=="object"?e?.id:e),r=t?.startsWith("gid://")??!1,l=(await $(w(`query TetherRecs(${r?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${r?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`),r?{id:t,intent:n}:{handle:t,intent:n},Ce)).productRecommendations??[];return l.forEach(S),l}export{z as a,Ne as b,J as c,Fe as d,O as e,K as f,Q as g,I as h,M as i,B as j,se as k,ae as l,ce as m,ue as n,de as o,N as p,f as q,_e as r,X as s,j as t,S as u,he as v,Ke as w,Qe as x,Be as y,He as z,be as A,ve as B,Ce as C,Ye as D,ze as E};
@@ -1 +1 @@
1
- import{d as e}from"./chunk-HJY2JSNB.js";import{r as o}from"./chunk-E5YO6274.js";var c=()=>`${o.prefix}:account-hint:${o.domain}`;function i(r){e(r,"sessionStorage"),e(r,"localStorage")}function m(){i(`${o.prefix}:account:${o.domain}`),i(`${o.prefix}:account-login:${o.domain}`)}var s=r=>r==="in"||r==="expired"||r==="error";export{c as a,m as b,s as c};
1
+ import{g as e}from"./chunk-55OHYO66.js";import{r as o}from"./chunk-GXCCTPDF.js";var c=()=>`${o.prefix}:account-hint:${o.domain}`;function i(r){e(r,"sessionStorage"),e(r,"localStorage")}function m(){i(`${o.prefix}:account:${o.domain}`),i(`${o.prefix}:account-login:${o.domain}`)}var s=r=>r==="in"||r==="expired"||r==="error";export{c as a,m as b,s as c};
@@ -0,0 +1 @@
1
+ import{c as a}from"./chunk-O4G2PAQC.js";import{a as o}from"./chunk-WNFEYPHV.js";import{o as u,p as i,r as n,x as c,z as g}from"./chunk-GXCCTPDF.js";var f={country:void 0,language:void 0,locale:void 0},l=!1;function d(){let t=e=>document.querySelector(`meta[name="${n.prefix}-page-${e}"]`)?.getAttribute("content")||void 0,r=u(t("country"));return r?{country:r,language:i(t("language"))??void 0,locale:t("locale")}:null}async function m(){let t=n.markets??{};if(t.detect===!1)return null;if(!t.detect)return t.remember===!1?null:a();try{return(await o("markets")).detectMarket(t)}catch(r){return g(r,"markets"),null}}async function C(t){f={country:n.country,language:n.language,locale:n.locale};let r=d();if(l=r!==null,r){n.country=r.country,n.language=r.language,r.locale&&(n.locale=r.locale);return}let e=await m();e&&(e.country&&(n.country=e.country),e.language&&(n.language=e.language),e.locale&&!t.locale&&(n.locale=e.locale),c("market",e))}var s=(t,r)=>(t??"").toUpperCase()===(r??"").toUpperCase();function P(){let t=d(),r=t===null&&l;l=t!==null;let e=t??(r?a()??f:null);return!e?.country||s(e.country,n.country)&&s(e.language,n.language)?null:{country:e.country,language:e.language,locale:e.locale}}function S(t,r){return o("markets").then(e=>e.setCountry(t,r))}export{C as a,P as b,S as c};
@@ -0,0 +1 @@
1
+ import{a as M}from"./chunk-A3GXCQJ4.js";import{e as m,f as p}from"./chunk-55OHYO66.js";import{m as k,o as i,p as g,r as u,u as y}from"./chunk-GXCCTPDF.js";var S="tether_country",C=()=>`${u.prefix}:market:${u.domain}`,w={getItem:e=>m(e)};function b(){let e=typeof window<"u";return{document:typeof document<"u"?document:null,location:e?window.location:null,storage:w,global:e?window:{}}}function E(e){try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return null;throw t}}function L(e){if(typeof e!="object"||e===null)return null;let t=i(Reflect.get(e,"country"));if(!t)return null;let n=Reflect.get(e,"locale");return{country:t,language:g(Reflect.get(e,"language"))??void 0,locale:typeof n=="string"&&n?n:void 0}}var h=e=>L(E(e));function x(e=w){let t=e.getItem(C());return t?h(t):null}function R(e,t){if(!e||!t)return null;let n=e.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith(`${t}=`));return n?M(n.slice(t.length+1)):null}function s(e,t){if(!e||!t)return null;let n=t.toLowerCase(),r=Object.keys(e).find(o=>o.toLowerCase()===n);return r?e[r]??null:null}function v(e,t){let n=a=>t.document?.querySelector(`meta[name="${a}"]`)?.getAttribute("content"),r=Reflect.get(t.global,"TETHER_COUNTRY"),o=Reflect.get(t.global,"TETHER_LANGUAGE"),l=n("tether-country")||R(t.document,e.cookie||S);return{country:r||l,language:o||n("tether-language")}}function N(e,t){let n=(t.location?.pathname??"/").split("/").find(c=>c!==""),r=s(e.locales,n);if(r)return r;let o=t.document?.documentElement.getAttribute("lang");if(!o)return null;let l=s(e.locales,o)??s(e.locales,o.split("-")[0]);if(l)return{locale:o,...l};if(e.locales&&e.strict)return null;let a=o.split("-")[1];return{language:o,country:a?.length===2?a:null,locale:o}}function O(e,t,n){switch(e){case"saved":return t.remember===!1?null:x(n.storage);case"server":return v(t,n);case"webflow":return N(t,n)}}function H(e){return e?e===!0?k:e:["saved"]}function I(e=u.markets,t=b()){let n=(e===u.markets?e:y(e))??{};if(n.detect===!1)return{};let r={},o={sources:r};for(let l of H(n.detect)){let a=O(l,n,t);if(!a)continue;let c=i(a.country),d=g(a.language),f=typeof a.locale=="string"&&a.locale?a.locale:null;c&&!o.country&&(o.country=c,r.country=l),d&&!o.language&&(o.language=d,r.language=l),f&&!o.locale&&(o.locale=f,r.locale=l)}return o}function _(e){if(u.markets?.remember===!1)return;let t={country:e.country,language:e.language||void 0,locale:e.locale||void 0};p(C(),JSON.stringify(t))}export{C as a,h as b,x as c,I as d,_ as e};
@@ -0,0 +1 @@
1
+ var e={diagnose:()=>import("./diagnose-XQQTDHLQ.js"),markets:()=>import("./markets-ui-OAJW4PFU.js"),search:()=>import("./search-LUECIYJR.js"),extras:()=>import("./extras-6WLNUEGD.js"),account:()=>import("./account-5X563BON.js"),"account-pages":()=>import("./account-pages-XR6QZ3DX.js"),analytics:()=>import("./analytics-JSFHDBU3.js")},a=t=>e[t](),r=void 0;export{a,r as b};
@@ -1 +1 @@
1
- import{a as k,b as z,c as B}from"./chunk-YN6LEBEN.js";import{a as g,c as y,f as l}from"./chunk-VFNHIGCS.js";import{D as _,E as J,r as D,v as U,x as W,y as Q,z as Y}from"./chunk-6TFMLT4A.js";import{F as K,G as C,I as w,L as F,N as q,a as H,m as u,n as c,o as s,p as P,q as N,r as A,u as d,x as O,z as I}from"./chunk-MQYB6BH4.js";import{b as m,d as M,o as b,p as $,r as p,x as v,y as x,z as h}from"./chunk-E5YO6274.js";var j="url:",T=()=>`${c("collection")},${c("products")},${c("recommendations")}`,et=t=>t instanceof window.Element,G=t=>parseInt(t??"",10)||void 0,ot=t=>t==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",V=class{constructor(e){m(this,"root");m(this,"products",[]);m(this,"pageInfo",null);m(this,"collection",null);m(this,"loadToken",0);this.root=e,l(e,"loading"),e.addEventListener("click",o=>{if(!et(o.target))return;let n=o.target.closest(c("load-more"));n?.closest(T())===e&&(o.preventDefault(),q(n,()=>this.load(!0)))})}$(e){return A(this.root,e,T())}options(){let{root:e}=this,o={reverse:s(e,"reverse")==="true"},n=G(s(e,"limit"));n&&(o.first=n);let r=s(e,"sort");if(r&&(o.sortKey=r),P(e,"collection"))return o.collection=s(e,"collection")??"",o;let i=s(e,"products")??"";return o.query=i.startsWith(j)?new URL(window.location.href).searchParams.get(i.slice(j.length))||"":i,o}async loadRecommendations(){let{key:e}=g(this.root,window.location,"recommendations"),o=this.root.closest(c("product"));if(!e&&o&&({key:e}=g(o)),!e)throw new H("No product for recommendations",{code:"NOT_FOUND"});return J(e,ot(s(this.root,"intent")))}async load(e=!1){this.loadToken+=1;let o=this.loadToken,n=()=>o!==this.loadToken;try{if(P(this.root,"recommendations")){let r=await this.loadRecommendations();if(n())return;let i=G(s(this.root,"limit"));this.products=i?r.slice(0,i):r}else{let r=await _({...this.options(),after:e?this.pageInfo?.endCursor??null:null});if(n())return;this.collection=r.collection,this.pageInfo=r.pageInfo,this.products=e?[...this.products,...r.products]:r.products}this.render(),l(this.root,"ready"),d("list-ready",{products:this.products,collection:this.collection},this.root)}catch(r){if(n())return;e||l(this.root,y(r)?"not-found":"error",r),y(r)&&P(this.root,"recommendations")||h(r,"list load failed"),d("error",{error:r,context:"list"},this.root)}}render(){let{collection:e}=this;this.$(c("collection-bind")).forEach(n=>{switch(s(n,"collection-bind")??""){case"title":C(n,e?.title??"");break;case"description":K(n,e?.descriptionHtml);break;case"image":O(n,e?.image?.url,e?.image?.altText||e?.title);break;case"count":C(n,this.products.length);break}}),this.$(c("list")).forEach(n=>{I(n,this.products,(r,i)=>{r.setAttribute(u("product"),i.handle),r.removeAttribute(u("state"))}),d("list-rendered",{container:n},this.root)});let o=this.products.length===0;this.$(c("show")).forEach(n=>{let r=s(n,"show");r==="list-empty"&&w(n,o),r==="list-filled"&&w(n,!o)}),this.$(c("load-more")).forEach(n=>{w(n,!!this.pageInfo?.hasNextPage)}),F("list")}};var rt='script[type="application/json"][data-tether-hydrate]',L=new WeakSet,Ht=new WeakSet,E=new Set,X=new Set,Z=new WeakMap;function nt(){E.forEach(t=>{t.isConnected||E.delete(t)}),X.forEach(t=>{t.root.isConnected||X.delete(t)})}function it(t,e){return[...t.matches?.(e)?[t]:[],...N(t,e)]}function st(t,e){let o=s(t,"page-title");!o||typeof document>"u"||(document.title=o.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function ct(t,{fromUrl:e,raw:o}){e?(L.add(t),l(t,"not-found"),d("product-not-found",{key:null,source:o},t)):t.closest(T())||x(`[${u("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t)}function at(t,e,{fromUrl:o,raw:n},r){let i=y(r);if(l(t,i?"not-found":"error",r),!i){h(r,`product ${e}`),d("error",{error:r,context:"product",key:e},t);return}d("product-not-found",{key:e,source:n},t),o?v(`product not found: ${e}`):h(r,`product ${e}`)}function ut(t){if(L.has(t))return!1;let{key:e,...o}=g(t);if(!e)return ct(t,o),!1;L.add(t),E.add(t);let n={};Z.set(t,n);let r=()=>Z.get(t)===n;return k.get(t)?t.setAttribute(u("state"),"updating"):l(t,"loading"),mt(U(e)).then(f=>{if(!r())return;let R=k.get(t);R?R.update(f):new B(t,f),st(t,f),p.revalidate&&Q(e)&&dt(e)}).catch(f=>{r()&&at(t,e,o,f)}),!0}function Nt(){nt(),E.forEach(t=>{t.getAttribute(u("state"))!=="error"||t.getAttribute(u("error"))==="not-found"||(L.delete(t),ut(t))})}var S=new Set;function dt(t){S.size||setTimeout(ft,0),S.add(t)}function lt(t,e){E.forEach(o=>{let n=k.get(o);if(!n||!o.isConnected)return;let r=g(o).key;r!==t&&r!==e.handle&&r!==e.id||JSON.stringify(n.product)!==JSON.stringify(e)&&n.update(e)})}function ft(){let t=[...S];S=new Set,t.forEach(e=>{Y(e).then(o=>{lt(e,o)}).catch(o=>{h(o,`refresh ${e}`)})})}var a=null,mt=t=>(a?.add(t),t);function pt(){if(!a)return;let t=[...a];Promise.allSettled(t).then(()=>{if(!(!a||t.some(e=>!a?.has(e)))){if(t.length!==a.size){pt();return}a=null,document.documentElement.classList.remove(`${p.prefix}-market-pending`)}})}function ht(t){if(!M(t))return{country:void 0,language:void 0,products:[]};let{products:e}=t,o=Array.isArray(e)?e:[];return{country:b(t.country)??void 0,language:$(t.language)??void 0,products:o.filter(D)}}var tt=new WeakSet;function At(t=document){it(t,rt).forEach(e=>{if(tt.has(e))return;tt.add(e);let o;try{o=JSON.parse(e.textContent)}catch(f){x("bad data-tether-hydrate",f);return}let{country:n,language:r,products:i}=ht(o);if(z(i),n===p.country&&r===p.language){W(i);return}v("hydration skipped: other market"),a||(a=new Set,document.documentElement.classList.add(`${p.prefix}-market-pending`))})}export{T as a,V as b,L as c,Ht as d,E as e,X as f,nt as g,it as h,ut as i,Nt as j,mt as k,pt as l,At as m};
1
+ import{a as k,b as z,c as B}from"./chunk-3OEIEDTK.js";import{b as g,d as y,g as l}from"./chunk-A3GXCQJ4.js";import{D as _,E as J,r as D,v as U,x as W,y as Q,z as Y}from"./chunk-J7GYROV4.js";import{E as K,F as C,H as w,K as F,M as q,a as H,l as u,m as c,n as s,o as P,p as N,q as A,t as d,w as O,y as I}from"./chunk-EW3GKRT4.js";import{b as m,d as M,o as b,p as $,r as p,x as v,y as x,z as h}from"./chunk-GXCCTPDF.js";var j="url:",T=()=>`${c("collection")},${c("products")},${c("recommendations")}`,et=t=>t instanceof window.Element,G=t=>parseInt(t??"",10)||void 0,ot=t=>t==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",V=class{constructor(e){m(this,"root");m(this,"products",[]);m(this,"pageInfo",null);m(this,"collection",null);m(this,"loadToken",0);this.root=e,l(e,"loading"),e.addEventListener("click",o=>{if(!et(o.target))return;let n=o.target.closest(c("load-more"));n?.closest(T())===e&&(o.preventDefault(),q(n,()=>this.load(!0)))})}$(e){return A(this.root,e,T())}options(){let{root:e}=this,o={reverse:s(e,"reverse")==="true"},n=G(s(e,"limit"));n&&(o.first=n);let r=s(e,"sort");if(r&&(o.sortKey=r),P(e,"collection"))return o.collection=s(e,"collection")??"",o;let i=s(e,"products")??"";return o.query=i.startsWith(j)?new URL(window.location.href).searchParams.get(i.slice(j.length))||"":i,o}async loadRecommendations(){let{key:e}=g(this.root,window.location,"recommendations"),o=this.root.closest(c("product"));if(!e&&o&&({key:e}=g(o)),!e)throw new H("No product for recommendations",{code:"NOT_FOUND"});return J(e,ot(s(this.root,"intent")))}async load(e=!1){this.loadToken+=1;let o=this.loadToken,n=()=>o!==this.loadToken;try{if(P(this.root,"recommendations")){let r=await this.loadRecommendations();if(n())return;let i=G(s(this.root,"limit"));this.products=i?r.slice(0,i):r}else{let r=await _({...this.options(),after:e?this.pageInfo?.endCursor??null:null});if(n())return;this.collection=r.collection,this.pageInfo=r.pageInfo,this.products=e?[...this.products,...r.products]:r.products}this.render(),l(this.root,"ready"),d("list-ready",{products:this.products,collection:this.collection},this.root)}catch(r){if(n())return;e||l(this.root,y(r)?"not-found":"error",r),y(r)&&P(this.root,"recommendations")||h(r,"list load failed"),d("error",{error:r,context:"list"},this.root)}}render(){let{collection:e}=this;this.$(c("collection-bind")).forEach(n=>{switch(s(n,"collection-bind")??""){case"title":C(n,e?.title??"");break;case"description":K(n,e?.descriptionHtml);break;case"image":O(n,e?.image?.url,e?.image?.altText||e?.title);break;case"count":C(n,this.products.length);break}}),this.$(c("list")).forEach(n=>{I(n,this.products,(r,i)=>{r.setAttribute(u("product"),i.handle),r.removeAttribute(u("state"))}),d("list-rendered",{container:n},this.root)});let o=this.products.length===0;this.$(c("show")).forEach(n=>{let r=s(n,"show");r==="list-empty"&&w(n,o),r==="list-filled"&&w(n,!o)}),this.$(c("load-more")).forEach(n=>{w(n,!!this.pageInfo?.hasNextPage)}),F("list")}};var rt='script[type="application/json"][data-tether-hydrate]',L=new WeakSet,Ht=new WeakSet,E=new Set,X=new Set,Z=new WeakMap;function nt(){E.forEach(t=>{t.isConnected||E.delete(t)}),X.forEach(t=>{t.root.isConnected||X.delete(t)})}function it(t,e){return[...t.matches?.(e)?[t]:[],...N(t,e)]}function st(t,e){let o=s(t,"page-title");!o||typeof document>"u"||(document.title=o.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function ct(t,{fromUrl:e,raw:o}){e?(L.add(t),l(t,"not-found"),d("product-not-found",{key:null,source:o},t)):t.closest(T())||x(`[${u("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t)}function at(t,e,{fromUrl:o,raw:n},r){let i=y(r);if(l(t,i?"not-found":"error",r),!i){h(r,`product ${e}`),d("error",{error:r,context:"product",key:e},t);return}d("product-not-found",{key:e,source:n},t),o?v(`product not found: ${e}`):h(r,`product ${e}`)}function ut(t){if(L.has(t))return!1;let{key:e,...o}=g(t);if(!e)return ct(t,o),!1;L.add(t),E.add(t);let n={};Z.set(t,n);let r=()=>Z.get(t)===n;return k.get(t)?t.setAttribute(u("state"),"updating"):l(t,"loading"),mt(U(e)).then(f=>{if(!r())return;let R=k.get(t);R?R.update(f):new B(t,f),st(t,f),p.revalidate&&Q(e)&&dt(e)}).catch(f=>{r()&&at(t,e,o,f)}),!0}function Nt(){nt(),E.forEach(t=>{t.getAttribute(u("state"))!=="error"||t.getAttribute(u("error"))==="not-found"||(L.delete(t),ut(t))})}var S=new Set;function dt(t){S.size||setTimeout(ft,0),S.add(t)}function lt(t,e){E.forEach(o=>{let n=k.get(o);if(!n||!o.isConnected)return;let r=g(o).key;r!==t&&r!==e.handle&&r!==e.id||JSON.stringify(n.product)!==JSON.stringify(e)&&n.update(e)})}function ft(){let t=[...S];S=new Set,t.forEach(e=>{Y(e).then(o=>{lt(e,o)}).catch(o=>{h(o,`refresh ${e}`)})})}var a=null,mt=t=>(a?.add(t),t);function pt(){if(!a)return;let t=[...a];Promise.allSettled(t).then(()=>{if(!(!a||t.some(e=>!a?.has(e)))){if(t.length!==a.size){pt();return}a=null,document.documentElement.classList.remove(`${p.prefix}-market-pending`)}})}function ht(t){if(!M(t))return{country:void 0,language:void 0,products:[]};let{products:e}=t,o=Array.isArray(e)?e:[];return{country:b(t.country)??void 0,language:$(t.language)??void 0,products:o.filter(D)}}var tt=new WeakSet;function At(t=document){it(t,rt).forEach(e=>{if(tt.has(e))return;tt.add(e);let o;try{o=JSON.parse(e.textContent)}catch(f){x("bad data-tether-hydrate",f);return}let{country:n,language:r,products:i}=ht(o);if(z(i),n===p.country&&r===p.language){W(i);return}v("hydration skipped: other market"),a||(a=new Set,document.documentElement.classList.add(`${p.prefix}-market-pending`))})}export{T as a,V as b,L as c,Ht as d,E as e,X as f,nt as g,it as h,ut as i,Nt as j,mt as k,pt as l,At as m};
@@ -1,4 +1,4 @@
1
- import{a as h,d as A}from"./chunk-VFNHIGCS.js";import{a as M}from"./chunk-Z6HS3H7K.js";import{h as E,v as D}from"./chunk-6TFMLT4A.js";import{d as P,e as $,i as v,m as p,n as l,o as m,q as d,y as S}from"./chunk-MQYB6BH4.js";import{c as k,r as a,w}from"./chunk-E5YO6274.js";var R=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),N=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),x=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
1
+ import{b as h,e as A}from"./chunk-A3GXCQJ4.js";import{a as M}from"./chunk-WNFEYPHV.js";import{h as E,v as D}from"./chunk-J7GYROV4.js";import{d as P,e as $,h as v,l as p,m as l,n as m,p as d,x as S}from"./chunk-EW3GKRT4.js";import{c as k,r as a,w}from"./chunk-GXCCTPDF.js";var R=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),N=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),x=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
2
2
  always-enabled bind cart-checkout-charge cart-clear cart-close cart-count cart-discounts cart-drawer cart-label cart-lines
3
3
  cart-note cart-open cart-subtotal cart-total cart-warning checkout code collection collection-bind countries country
4
4
  country-bind country-label country-select default-plan default-purchase discount discount-code discount-form discount-input
@@ -0,0 +1 @@
1
+ import{c as v}from"./chunk-KVPLRK6Y.js";import{a as b,b as S}from"./chunk-O4G2PAQC.js";import{a as k}from"./chunk-3OEIEDTK.js";import"./chunk-255K6OZ7.js";import"./chunk-A3GXCQJ4.js";import"./chunk-WNFEYPHV.js";import{h as p}from"./chunk-55OHYO66.js";import"./chunk-J7GYROV4.js";import{N as h,O as w,m as l,n as f,o as g,p as d,t as y}from"./chunk-EW3GKRT4.js";import{r as s,y as m,z as u}from"./chunk-GXCCTPDF.js";function U(t,r){let e=w(h(t,"line-attributes"));return r?[{key:"_group",value:r},...e]:e}async function V(t){let r=t.closest(l("group"));if(!r)return null;let e=f(r,"group"),n=U(r,e),i=d(r,l("product")).flatMap(a=>{let o=k.get(a);if(!o?.variant?.availableForSale||o.quantity<=0)return[];let c=o.getLine();return c?[{...c,attributes:[...c.attributes??[],...n]}]:[]});if(!i.length)return m("group-add: nothing selected"),null;try{let a=await p.add(i);return y("group-added",{group:e,lines:i},r),a}catch(a){return u(a,"group add"),null}}function _(t){if(t.key===s.storageKey||t.key===`${s.storageKey}:seen`){p.init().catch(n=>{u(n,"cart from another tab")});return}if(t.key!==b()||!t.newValue)return;let r=S(t.newValue);if(!r)return;let e={language:r.language??null,locale:r.locale,remember:!1};v(r.country,e).catch(n=>{u(n,"market from another tab")})}var E=new WeakMap,K=t=>t.split("/").pop()??t;function x(t){try{window.history.replaceState(window.history.state,"",t)}catch{}}function $(t,{variant:r,sellingPlanId:e}){let n=`${r.id}|${e??""}`,i=E.get(t);if(E.set(t,n),!i||i===n)return;let a=s.variantUrl&&document.querySelector(l("product"))===t;if(!g(t,"variant-url")&&!a)return;let o=new URL(window.location.href);o.searchParams.set("variant",K(r.id)),e?o.searchParams.set("selling_plan",K(e)):o.searchParams.delete("selling_plan"),x(o)}export{V as addGroup,_ as onStorage,$ as writeVariantUrl};
@@ -1 +1 @@
1
- import{a as E,c as P,e as k,f as T,g as A,h as p,i as x}from"./chunk-4HD4J5JC.js";import{b as F,c as I}from"./chunk-RPMBCAGS.js";import"./chunk-YN6LEBEN.js";import"./chunk-BBVUVPMO.js";import"./chunk-VFNHIGCS.js";import{e as u}from"./chunk-HJY2JSNB.js";import{w}from"./chunk-6TFMLT4A.js";import{a as L,d as h,i as b,m as s,n as C,o as v,u as z}from"./chunk-MQYB6BH4.js";import{o as f,p as g,r as a,z as y}from"./chunk-E5YO6274.js";var _="{name} ({currency})",j="name",d=null;function B(){d=null}var D="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}",O={isoCode:"string",name:"string",currency:"object"},H=h({localization:{country:O,availableCountries:[O]}});function R(){return d??(d=b(D,{},H).then(e=>e.localization,e=>{throw d=null,e})),d}function U(e,n){switch(n){case"name":return e.name;case"code":return e.isoCode;case"currency":return e.currency.isoCode;case"symbol":return e.currency.symbol;default:return""}}var Y=(e,n)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,i)=>U(n,i));function q(e,n,o){let i=e.getAttribute(s("country-label"))||_,r=(e.getAttribute(s("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),c=r.length?r.map(t=>n.find(l=>l.isoCode===t)).filter(t=>t!==void 0):n;e.replaceChildren(...c.map(t=>new Option(Y(i,t),t.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=c.length<2&&!e.hasAttribute(s("always-enabled"))}function $(e,n,o){let i=(a.country||o.country.isoCode).toUpperCase(),r=[...o.availableCountries].sort((t,l)=>t.name.localeCompare(l.name,a.locale||void 0)),c=r.find(t=>t.isoCode===i)??o.country;e.forEach(t=>{q(t,r,i)}),n.forEach(t=>{t.textContent=U(c,v(t,"country-bind")||j)})}function S(e=document){let n=p(e,`select${C("country-select")}`),o=p(e,C("country-bind"));return!n.length&&!o.length?Promise.resolve():R().then(i=>{$(n,o,i)}).catch(i=>{y(i,"country select")})}var Q=e=>Object.values(a.markets?.locales??{}).find(n=>f(n.country)===e);function V(e,n){return e!==void 0?g(e):n?n.language?g(n.language):void 0:a.language}function Z(e){w();let n=[];return u.id()&&n.push(u.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{y(o,"cart country")})),A(),T.forEach(o=>n.push(o.load())),k.forEach(o=>{o.closest(E())||(P.delete(o),x(o))}),n}async function re(e,{language:n,locale:o,remember:i=!0}={}){let r=f(e);if(!r)throw new L(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let c=Q(r),t=o||c?.locale,l=t||a.locale,m=V(n,c),M=r!==a.country||m!==a.language||l!==a.locale;if(a.country=r,a.language=m||void 0,a.locale=l,i&&I({country:r,language:m,locale:t}),!M)return S(),u.state;n!==void 0&&B();let N=Z(r);return S(),z("country-changed",{country:r,language:a.language}),await Promise.all(N),u.state}export{F as detectMarket,R as getLocalization,S as renderCountrySelects,re as setCountry};
1
+ import{a as E,c as P,e as k,f as T,g as A,h as p,i as x}from"./chunk-WXF4L42L.js";import{d as F,e as I}from"./chunk-O4G2PAQC.js";import"./chunk-3OEIEDTK.js";import"./chunk-255K6OZ7.js";import"./chunk-A3GXCQJ4.js";import{h as u}from"./chunk-55OHYO66.js";import{w}from"./chunk-J7GYROV4.js";import{a as L,d as h,h as b,l as s,m as C,n as v,t as z}from"./chunk-EW3GKRT4.js";import{o as f,p as g,r as a,z as y}from"./chunk-GXCCTPDF.js";var _="{name} ({currency})",j="name",d=null;function B(){d=null}var D="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}",O={isoCode:"string",name:"string",currency:"object"},H=h({localization:{country:O,availableCountries:[O]}});function R(){return d??(d=b(D,{},H).then(e=>e.localization,e=>{throw d=null,e})),d}function U(e,n){switch(n){case"name":return e.name;case"code":return e.isoCode;case"currency":return e.currency.isoCode;case"symbol":return e.currency.symbol;default:return""}}var Y=(e,n)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,i)=>U(n,i));function q(e,n,o){let i=e.getAttribute(s("country-label"))||_,r=(e.getAttribute(s("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),c=r.length?r.map(t=>n.find(l=>l.isoCode===t)).filter(t=>t!==void 0):n;e.replaceChildren(...c.map(t=>new Option(Y(i,t),t.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=c.length<2&&!e.hasAttribute(s("always-enabled"))}function $(e,n,o){let i=(a.country||o.country.isoCode).toUpperCase(),r=[...o.availableCountries].sort((t,l)=>t.name.localeCompare(l.name,a.locale||void 0)),c=r.find(t=>t.isoCode===i)??o.country;e.forEach(t=>{q(t,r,i)}),n.forEach(t=>{t.textContent=U(c,v(t,"country-bind")||j)})}function S(e=document){let n=p(e,`select${C("country-select")}`),o=p(e,C("country-bind"));return!n.length&&!o.length?Promise.resolve():R().then(i=>{$(n,o,i)}).catch(i=>{y(i,"country select")})}var Q=e=>Object.values(a.markets?.locales??{}).find(n=>f(n.country)===e);function V(e,n){return e!==void 0?g(e):n?n.language?g(n.language):void 0:a.language}function Z(e){w();let n=[];return u.id()&&n.push(u.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{y(o,"cart country")})),A(),T.forEach(o=>n.push(o.load())),k.forEach(o=>{o.closest(E())||(P.delete(o),x(o))}),n}async function re(e,{language:n,locale:o,remember:i=!0}={}){let r=f(e);if(!r)throw new L(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let c=Q(r),t=o||c?.locale,l=t||a.locale,m=V(n,c),M=r!==a.country||m!==a.language||l!==a.locale;if(a.country=r,a.language=m||void 0,a.locale=l,i&&I({country:r,language:m,locale:t}),!M)return S(),u.state;n!==void 0&&B();let N=Z(r);return S(),z("country-changed",{country:r,language:a.language}),await Promise.all(N),u.state}export{F as detectMarket,R as getLocalization,S as renderCountrySelects,re as setCountry};
@@ -0,0 +1 @@
1
+ import{h as M}from"./chunk-WXF4L42L.js";import"./chunk-3OEIEDTK.js";import"./chunk-255K6OZ7.js";import"./chunk-A3GXCQJ4.js";import"./chunk-55OHYO66.js";import"./chunk-J7GYROV4.js";import{A as x,C,F as q,H as d,c as S,d as E,h as T,l as A,m as o,n as m,p as h,t as I,w as L,y as w}from"./chunk-EW3GKRT4.js";import{b as a,r as u,x as b,z as y}from"./chunk-GXCCTPDF.js";var N=E({predictiveSearch:S({products:[{priceRange:"object"}],collections:["object"],queries:[{text:"string"}]})}),U="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",D=6,V=2,F="/search",R=new WeakSet,v=0;function $(s,t,e){return parseInt(m(s,t)||"",10)||e}var H=s=>s.tagName==="A"?s:s.querySelector("a");function p(s,t){h(s,o("search-bind")).forEach(e=>{let i=m(e,"search-bind");i==="image"?L(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&q(e,t[i])})}function k(s,t){let e=H(s);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var f=class{constructor(t,e,i){a(this,"root");a(this,"input");a(this,"results");a(this,"limit");a(this,"minCharacters");a(this,"resultsId");a(this,"searchNumber",0);a(this,"timer");a(this,"lastTerm","");a(this,"cache",new Map);this.root=t,this.input=e,this.results=i,this.limit=$(t,"search-limit",D),this.minCharacters=$(t,"search-min",V),i.id||(v+=1,i.id=`${u.prefix}-search-${v}`),this.resultsId=i.id,this.setUpAria(),this.listen()}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){this.input.addEventListener("input",()=>{let t=this.input.value.trim();t!==this.lastTerm&&(this.lastTerm=t,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(t),u.searchDelay))}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)}),this.input.addEventListener("keydown",t=>{this.onKeydown(t)}),document.addEventListener("click",t=>{this.root.contains(t.target)||this.open(!1)})}setState(t){this.root.setAttribute(A("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return h(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let i=await T(U,{q:t,limit:this.limit},N);return this.cache.set(t,i.predictiveSearch),i.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let i=await this.fetchResults(t);e===this.searchNumber&&this.render(i,t)}catch(i){if(e!==this.searchNumber){b("a superseded search failed",i);return}this.setState("error"),y(i,"search")}}fillList(t,e,i){h(this.results,o(t)).forEach(l=>{w(l,e,i),d(l,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||F,i=e.includes("?")?"&":"?";return`${e}${i}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let i=t?.products??[],l=t?.collections??[],c=(t?.queries??[]).filter(n=>n.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(n,r)=>{let P=C(r.priceRange.minVariantPrice);p(n,{title:r.title,price:P,image:r.featuredImage}),k(n,x(r.handle,r.id)),n.classList.toggle("is-sold-out",!r.availableForSale)}),this.fillList("search-collections",l,(n,r)=>{p(n,{title:r.title,image:r.image}),k(n,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${r.handle}`)}),this.fillList("search-queries",c,(n,r)=>{p(n,{text:r.text}),H(n)?.setAttribute("href",this.queryUrl(r.text))});let g=i.length+l.length+c.length;this.showCount(g),this.setState(g?"ready":"empty"),this.open(!0),I("search",{term:e,products:i,collections:l,queries:c},this.root)}showCount(t){h(this.root,o("show")).forEach(e=>{let i=m(e,"show");i==="search-empty"&&d(e,t===0),i==="search-results"&&d(e,t>0)}),this.options().forEach((e,i)=>{e.id||(e.id=`${this.resultsId}-${i}`),e.setAttribute("aria-selected","false")})}highlight(t,e){t.forEach((l,c)=>{l.setAttribute("aria-selected",String(c===e))});let i=t[e];i&&(this.input.setAttribute("aria-activedescendant",i.id),i.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),i=e.findIndex(l=>l.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(i+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,i<=0?e.length-1:i-1)):t.key==="Enter"&&i>=0?(t.preventDefault(),e[i]?.click()):t.key==="Escape"&&this.open(!1)}};function j(s=document){for(let t of M(s,o("search"))){if(R.has(t))continue;R.add(t);let e=t.querySelector(o("search-input"))??t.querySelector("input"),i=t.querySelector(o("search-results"));e&&i&&new f(t,e,i)}}export{j as mountSearch};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{a as nt,b as ot,d as T,f as w,g as C,h as p,i as rt,j as it,k as st,l as k,m as S}from"./chunks/chunk-4HD4J5JC.js";import{a as at,b as ct,c as h}from"./chunks/chunk-EW5SYO6L.js";import"./chunks/chunk-RPMBCAGS.js";import{a as et}from"./chunks/chunk-YN6LEBEN.js";import"./chunks/chunk-BBVUVPMO.js";import{a as tt}from"./chunks/chunk-VFNHIGCS.js";import{a as ut,b as lt,c as dt}from"./chunks/chunk-WT7RGGJU.js";import{a as l,b as mt}from"./chunks/chunk-Z6HS3H7K.js";import{a as z,b as Z,e as s}from"./chunks/chunk-HJY2JSNB.js";import{D as J,E as X,o as q,t as K,u as Q,v as W,w as Y}from"./chunks/chunk-6TFMLT4A.js";import{D as j,K as P,N as f,a as v,g as _,k as G,m as d,n as r,s as U,t as g,u as y,v as B}from"./chunks/chunk-MQYB6BH4.js";import{e as H,r as c,s as $,v as V,w as E,x as L,y as F,z as a}from"./chunks/chunk-E5YO6274.js";var Nt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],Ot=()=>[...Nt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Dt(){return!!Z(ut())}function ft(t){!c.account||!(p(t,Ot()).length>0||dt(new URLSearchParams(window.location.search).get("account"))||Dt())||l("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function u(t){return(...e)=>l("account").then(n=>{let o=n[t];return o(...e)})}var pt={login:u("login"),logout:u("logout"),isLoggedIn:u("isLoggedIn"),customer:u("customer"),orders:u("orders"),order:u("order"),updateProfile:u("updateProfile"),addresses:u("addresses"),saveAddress:u("saveAddress"),deleteAddress:u("deleteAddress"),subscriptions:u("subscriptions"),subscriptionAction:u("subscriptionAction"),requestReturn:u("requestReturn"),render:u("render"),mountAccount:u("mountAccount")};var gt=()=>`data-${c.prefix}-key`,ht=t=>t instanceof window.Element;function Et(t){let e=t.closest(`[${gt()}]`),n=e?.getAttribute(gt());return e&&n?{line:e,id:n}:null}function A(t,e){t.catch(n=>{a(n,e)})}function Rt(t,e){let n=Et(e);if(!n?.line.closest(r("cart-lines")))return;let{line:o,id:i}=n;if(e.closest(r("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),A(s.removeLine(i),"cart line");return}let R=Ht(e);!R||!s.lines.some(It=>It.id===i)||(t.preventDefault(),A(s.changeQuantity(i,R),"cart line"))}function Ht(t){return t.closest(r("line-plus"))?1:t.closest(r("line-minus"))?-1:0}function $t(t){let{target:e}=t;if(!ht(e))return;if(e.closest(r("cart-open"))){t.preventDefault(),s.toggle();return}if(e.closest(r("cart-close"))){t.preventDefault(),s.close();return}let n=e.closest(r("cart-clear"));if(n){t.preventDefault(),f(n,()=>s.clear().catch(i=>{a(i,"cart clear")}));return}let o=e.closest(r("checkout"));if(o){t.preventDefault(),f(o,()=>s.checkout());return}Rt(t,e)}function yt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),A(e,n)}function Vt(t){let{target:e}=t;if(!ht(e))return;let n=Et(e);n&&e instanceof window.HTMLInputElement&&e.matches(r("line","quantity"))?yt(n.line,s.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(r("line-plan"))?yt(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Ft(e)&&e.matches(r("cart-note"))&&A(s.setNote(e.value),"cart note")}var Ft=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function _t(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}z(t)}}function vt(){document.addEventListener("click",$t),document.addEventListener("change",Vt),document.addEventListener("keydown",_t)}var x=t=>t instanceof window.Element;function Gt(t){let e=t.querySelector(r("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function Pt(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function Ut(t,e,n){try{await s.applyDiscount(n),Pt(t,e,!1),y("discount-applied",{code:n},t),e&&(e.value="")}catch(o){Pt(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?y("discount-invalid",{code:n},t):a(o,"discount")}}function Bt(t){let{target:e}=t,n=x(e)?e.closest(r("discount-form")):null;if(!n)return;t.preventDefault();let o=Gt(n),i=o?.value.trim();i&&f(n,()=>Ut(n,o,i))}function jt(t){let{target:e}=t;if(!x(e))return;let n=e.closest(r("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function qt(t){let{target:e}=t,n=x(e)?e.closest(r("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(r("discount-code"))?.getAttribute(d("discount-code"));o&&s.removeDiscount(o).catch(i=>{a(i,"discount")})}function wt(){document.addEventListener("submit",Bt,!0),document.addEventListener("input",jt),document.addEventListener("click",qt)}var M=t=>l("extras").then(e=>e.addGroup(t)),I=t=>{a(t,"extras")};function zt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(r("group-add")):null;n&&(t.preventDefault(),f(n,()=>M(n)).catch(I))}function Kt(t){!c.domain||!t.key?.startsWith(`${c.prefix}:`)||l("extras").then(e=>{e.onStorage(t)}).catch(I)}function Qt(t){if(!g(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!c.variantUrl&&!e.hasAttribute(d("variant-url"))||l("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(I))}function At(){document.addEventListener("click",zt),window.addEventListener("storage",Kt),document.addEventListener(`${c.prefix}:variant-changed`,Qt)}var N=null;function bt(){N=document.body}async function Wt(t){await t.ready();let e=ct();if(!e){N!==document.body&&t.mount(document);return}try{await h(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Yt(t){document.addEventListener("astro:page-load",()=>{Wt(t).catch(e=>{a(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{N=null,t.unmount()})}function Jt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(r("country-select"))||e.value&&h(e.value).catch(n=>{a(n,"country")})}function Xt(){it(),w.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function Lt(t){c.astro&&Yt(t),document.addEventListener("change",Jt),window.addEventListener("online",Xt)}var Ct="0.7.1",Zt=50;function te(){let t=P("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var m=null,O=null,kt=null,Tt=!1;function ee(t){let e=0;return p(t,nt()).forEach(n=>{if(T.has(n))return;T.add(n),e++;let o=new ot(n);w.add(o),n.addEventListener(`${c.prefix}:list-rendered`,i=>{g(i,"list-rendered")&&b(i.detail.container)}),st(o.load())}),e}function ne(t){p(t,`${r("country-select")},${r("country-bind")}`).length&&l("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),ft(t),p(t,r("search")).length&&l("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function St(t){let e=ee(t);return p(t,r("product")).forEach(n=>{rt(n)&&e++}),ne(t),e}function b(t=document){if(!E())return 0;t===document&&bt(),C(),S(t.ownerDocument??document);let e=St(t);return k(),s.render(),L(`mounted ${e} scope(s)`,t),e}function oe(t){let e=t.filter(o=>o.isConnected&&!t.some(i=>i!==o&&i.contains(o)));if(!e.length||!E())return;C(),e.forEach(o=>{S(o)});let n=e.reduce((o,i)=>o+St(i),0);k(),s.render(),L(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function xt(){s.close()}function re(t){let e=t?.closest(r("product"));return e?et.get(e)??null:null}function ie(){Tt||(Tt=!0,vt(),wt(),At(),Lt({ready:()=>m??Promise.resolve(null),mount:b,unmount:xt}))}function se(){let t=[];kt=t,U.forEach(e=>{document.addEventListener(`${c.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",e=>t.push(e)),l("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ae(t){let e=c.country,n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await s.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function Mt(t={}){return m&&!Object.keys(t).length?m:(V({...te(),...t}),E()?(lt(),ie(),c.observe&&ce(),c.analytics&&!kt&&se(),m=at(t).then(()=>s.init()).then(ae).then(e=>(y("ready",{cart:e}),D)),m):(F("TETHER_CONFIG is missing domain or token. Tether is idle."),m=Promise.resolve(null),m))}function ce(){if(O||typeof MutationObserver>"u")return;let t,e=new Set;O=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(i=>{i instanceof window.Element&&e.add(i)})}),clearTimeout(t),t=setTimeout(()=>{let o=[...e];e.clear(),oe(o)},Zt)}),O.observe(document.body,{childList:!0,subtree:!0})}var ue=t=>l("markets").then(e=>e.detectMarket(t??c.markets)),le=()=>l("markets").then(t=>t.getLocalization()),de=t=>l("diagnose").then(e=>e.diagnose({...t,version:Ct}));function me(t,e){let n=`${c.prefix}:${t}`,o=i=>{g(i,t)&&e(i.detail,i)};return document.addEventListener(n,o),()=>{document.removeEventListener(n,o)}}var fe={VERSION:Ct,init:Mt,mount:b,unmount:xt,get config(){return $},get ready(){return m??Promise.resolve(null)},query:G,withContext:_,cart:s,getProduct:W,getProducts:J,getRecommendations:X,getScope:re,addGroup:M,account:pt,primeProduct:Q,normalizeProductKey:K,clearProductCache:Y,formatMoney:j,imageUrl:B,plans:q,TetherError:v,resolveProductKey:tt,setCountry:h,detectMarket:ue,getLocalization:le,diagnose:de,on:me},pe={__core:mt,__parts:{}},D=Object.assign(fe,pe),sn=D;function ge(){Reflect.set(window,"Tether",D);let t=P("TETHER_CONFIG");if(!t||H(t,"autoMount")===!1||P("TETHER_INTEGRATION"))return;let e=()=>{Mt().then(()=>b(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&ge();export{Ct as VERSION,M as addGroup,D as api,sn as default,re as getScope,Mt as init,b as mount,h as setCountry,xt as unmount};
1
+ import{a as nt,b as ot,d as C,f as w,g as T,h as p,i as rt,j as it,k as st,l as k,m as S}from"./chunks/chunk-WXF4L42L.js";import{a as at,b as ct,c as h}from"./chunks/chunk-KVPLRK6Y.js";import"./chunks/chunk-O4G2PAQC.js";import{a as et}from"./chunks/chunk-3OEIEDTK.js";import"./chunks/chunk-255K6OZ7.js";import{b as tt}from"./chunks/chunk-A3GXCQJ4.js";import{a as ut,b as lt,c as dt}from"./chunks/chunk-KNJB72OO.js";import{a as l,b as mt}from"./chunks/chunk-WNFEYPHV.js";import{a as z,e as Z,h as s}from"./chunks/chunk-55OHYO66.js";import{D as J,E as X,o as q,t as K,u as Q,v as W,w as Y}from"./chunks/chunk-J7GYROV4.js";import{C as j,J as P,M as f,a as v,f as _,j as G,l as d,m as r,r as U,s as g,t as y,u as B}from"./chunks/chunk-EW3GKRT4.js";import{e as H,r as c,s as $,v as V,w as E,x as L,y as F,z as a}from"./chunks/chunk-GXCCTPDF.js";var Nt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],Ot=()=>[...Nt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Dt(){return!!Z(ut())}function ft(t){!c.account||!(p(t,Ot()).length>0||dt(new URLSearchParams(window.location.search).get("account"))||Dt())||l("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function u(t){return(...e)=>l("account").then(n=>{let o=n[t];return o(...e)})}var pt={login:u("login"),logout:u("logout"),isLoggedIn:u("isLoggedIn"),customer:u("customer"),orders:u("orders"),order:u("order"),updateProfile:u("updateProfile"),addresses:u("addresses"),saveAddress:u("saveAddress"),deleteAddress:u("deleteAddress"),subscriptions:u("subscriptions"),subscriptionAction:u("subscriptionAction"),requestReturn:u("requestReturn"),render:u("render"),mountAccount:u("mountAccount")};var gt=()=>`data-${c.prefix}-key`,ht=t=>t instanceof window.Element;function Et(t){let e=t.closest(`[${gt()}]`),n=e?.getAttribute(gt());return e&&n?{line:e,id:n}:null}function A(t,e){t.catch(n=>{a(n,e)})}function Rt(t,e){let n=Et(e);if(!n?.line.closest(r("cart-lines")))return;let{line:o,id:i}=n;if(e.closest(r("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),A(s.removeLine(i),"cart line");return}let R=Ht(e);!R||!s.lines.some(It=>It.id===i)||(t.preventDefault(),A(s.changeQuantity(i,R),"cart line"))}function Ht(t){return t.closest(r("line-plus"))?1:t.closest(r("line-minus"))?-1:0}function $t(t){let{target:e}=t;if(!ht(e))return;if(e.closest(r("cart-open"))){t.preventDefault(),s.toggle();return}if(e.closest(r("cart-close"))){t.preventDefault(),s.close();return}let n=e.closest(r("cart-clear"));if(n){t.preventDefault(),f(n,()=>s.clear().catch(i=>{a(i,"cart clear")}));return}let o=e.closest(r("checkout"));if(o){t.preventDefault(),f(o,()=>s.checkout());return}Rt(t,e)}function yt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),A(e,n)}function Vt(t){let{target:e}=t;if(!ht(e))return;let n=Et(e);n&&e instanceof window.HTMLInputElement&&e.matches(r("line","quantity"))?yt(n.line,s.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(r("line-plan"))?yt(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Ft(e)&&e.matches(r("cart-note"))&&A(s.setNote(e.value),"cart note")}var Ft=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function _t(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}z(t)}}function vt(){document.addEventListener("click",$t),document.addEventListener("change",Vt),document.addEventListener("keydown",_t)}var x=t=>t instanceof window.Element;function Gt(t){let e=t.querySelector(r("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function Pt(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function Ut(t,e,n){try{await s.applyDiscount(n),Pt(t,e,!1),y("discount-applied",{code:n},t),e&&(e.value="")}catch(o){Pt(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?y("discount-invalid",{code:n},t):a(o,"discount")}}function Bt(t){let{target:e}=t,n=x(e)?e.closest(r("discount-form")):null;if(!n)return;t.preventDefault();let o=Gt(n),i=o?.value.trim();i&&f(n,()=>Ut(n,o,i))}function jt(t){let{target:e}=t;if(!x(e))return;let n=e.closest(r("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function qt(t){let{target:e}=t,n=x(e)?e.closest(r("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(r("discount-code"))?.getAttribute(d("discount-code"));o&&s.removeDiscount(o).catch(i=>{a(i,"discount")})}function wt(){document.addEventListener("submit",Bt,!0),document.addEventListener("input",jt),document.addEventListener("click",qt)}var M=t=>l("extras").then(e=>e.addGroup(t)),I=t=>{a(t,"extras")};function zt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(r("group-add")):null;n&&(t.preventDefault(),f(n,()=>M(n)).catch(I))}function Kt(t){!c.domain||!t.key?.startsWith(`${c.prefix}:`)||l("extras").then(e=>{e.onStorage(t)}).catch(I)}function Qt(t){if(!g(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!c.variantUrl&&!e.hasAttribute(d("variant-url"))||l("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(I))}function At(){document.addEventListener("click",zt),window.addEventListener("storage",Kt),document.addEventListener(`${c.prefix}:variant-changed`,Qt)}var N=null;function bt(){N=document.body}async function Wt(t){await t.ready();let e=ct();if(!e){N!==document.body&&t.mount(document);return}try{await h(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Yt(t){document.addEventListener("astro:page-load",()=>{Wt(t).catch(e=>{a(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{N=null,t.unmount()})}function Jt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(r("country-select"))||e.value&&h(e.value).catch(n=>{a(n,"country")})}function Xt(){it(),w.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function Lt(t){c.astro&&Yt(t),document.addEventListener("change",Jt),window.addEventListener("online",Xt)}var Tt="0.8.0",Zt=50;function te(){let t=P("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var m=null,O=null,kt=null,Ct=!1;function ee(t){let e=0;return p(t,nt()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=new ot(n);w.add(o),n.addEventListener(`${c.prefix}:list-rendered`,i=>{g(i,"list-rendered")&&b(i.detail.container)}),st(o.load())}),e}function ne(t){p(t,`${r("country-select")},${r("country-bind")}`).length&&l("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),ft(t),p(t,r("search")).length&&l("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function St(t){let e=ee(t);return p(t,r("product")).forEach(n=>{rt(n)&&e++}),ne(t),e}function b(t=document){if(!E())return 0;t===document&&bt(),T(),S(t.ownerDocument??document);let e=St(t);return k(),s.render(),L(`mounted ${e} scope(s)`,t),e}function oe(t){let e=t.filter(o=>o.isConnected&&!t.some(i=>i!==o&&i.contains(o)));if(!e.length||!E())return;T(),e.forEach(o=>{S(o)});let n=e.reduce((o,i)=>o+St(i),0);k(),s.render(),L(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function xt(){s.close()}function re(t){let e=t?.closest(r("product"));return e?et.get(e)??null:null}function ie(){Ct||(Ct=!0,vt(),wt(),At(),Lt({ready:()=>m??Promise.resolve(null),mount:b,unmount:xt}))}function se(){let t=[];kt=t,U.forEach(e=>{document.addEventListener(`${c.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",e=>t.push(e)),l("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ae(t){let e=c.country,n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await s.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function Mt(t={}){return m&&!Object.keys(t).length?m:(V({...te(),...t}),E()?(lt(),ie(),c.observe&&ce(),c.analytics&&!kt&&se(),m=at(t).then(()=>s.init()).then(ae).then(e=>(y("ready",{cart:e}),D)),m):(F("TETHER_CONFIG is missing domain or token. Tether is idle."),m=Promise.resolve(null),m))}function ce(){if(O||typeof MutationObserver>"u")return;let t,e=new Set;O=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(i=>{i instanceof window.Element&&e.add(i)})}),clearTimeout(t),t=setTimeout(()=>{let o=[...e];e.clear(),oe(o)},Zt)}),O.observe(document.body,{childList:!0,subtree:!0})}var ue=t=>l("markets").then(e=>e.detectMarket(t??c.markets)),le=()=>l("markets").then(t=>t.getLocalization()),de=t=>l("diagnose").then(e=>e.diagnose({...t,version:Tt}));function me(t,e){let n=`${c.prefix}:${t}`,o=i=>{g(i,t)&&e(i.detail,i)};return document.addEventListener(n,o),()=>{document.removeEventListener(n,o)}}var fe={VERSION:Tt,init:Mt,mount:b,unmount:xt,get config(){return $},get ready(){return m??Promise.resolve(null)},query:G,withContext:_,cart:s,getProduct:W,getProducts:J,getRecommendations:X,getScope:re,addGroup:M,account:pt,primeProduct:Q,normalizeProductKey:K,clearProductCache:Y,formatMoney:j,imageUrl:B,plans:q,TetherError:v,resolveProductKey:tt,setCountry:h,detectMarket:ue,getLocalization:le,diagnose:de,on:me},pe={__core:mt,__parts:{}},D=Object.assign(fe,pe),sn=D;function ge(){Reflect.set(window,"Tether",D);let t=P("TETHER_CONFIG");if(!t||H(t,"autoMount")===!1||P("TETHER_INTEGRATION"))return;let e=()=>{Mt().then(()=>b(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&ge();export{Tt as VERSION,M as addGroup,D as api,sn as default,re as getScope,Mt as init,b as mount,h as setCountry,xt as unmount};
@@ -1,2 +1,2 @@
1
- import{b as G,f as H,g as Q}from"./chunks/chunk-BBVUVPMO.js";import{A as J,B as K,C as j,a as M,c as T,h as v,i as b,j as $,l as F,o as q,q as V,s as B}from"./chunks/chunk-6TFMLT4A.js";import{C as _,a as S,c as k,d as C,f as L,g as rt,h as P,j as N,v as D}from"./chunks/chunk-MQYB6BH4.js";import{B as E,E as U,F as I,G as O,q as g,t as A}from"./chunks/chunk-E5YO6274.js";function Y(t,e={}){if(!t)return null;let{variant:r,sellingPlan:a,defaultPurchase:c=g.defaultPurchase,lowStock:u=g.lowStock}=e,d=H(t,{variant:r,sellingPlan:a,defaultPurchase:c}),n=Q(t,{...d,quantity:1},u);if(!n)throw new S(`Product ${t.handle} has no variants`);let{selected:l,line:p}=n,i=(o,s)=>!G(t,l,o,s);return{variant:n.variant,selected:l,purchase:n.purchase.kind,plan:p.kind==="subscription"?n.plan:null,plans:v(t).map(o=>({id:o.id,name:o.name,price:$(n.variant,o.id),savings:F(n.variant,o.id).percentage,selected:p.kind==="subscription"&&o.id===p.planId,available:!!b(n.variant,o.id)})),savings:n.savings.percentage,price:n.price,compareAtPrice:n.compareAtPrice,available:n.variant.availableForSale,show:n.show,unavailable:Object.fromEntries(t.options.map(o=>[o.name,o.optionValues.map(s=>s.name).filter(s=>i(o.name,s))])),isUnavailable:i}}var ot=500,it=100,at=100,st="query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}",lt="query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}",ct=()=>`query TetherServerCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${T()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,ut="query TetherServerProducts($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}}}",dt=()=>`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${T()}}pageInfo{hasNextPage endCursor}}}`,ft=t=>`query TetherServerRecs(${t?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${t?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`,pt=C({product:k(V)}),mt=C({node:k(B)}),gt=C({collections:{nodes:[{handle:"string"}],pageInfo:{hasNextPage:"boolean"}}});async function yt(t){let e=[],r=null;for(let a=0;a<at;a++){let c=await P(t,dt(),{first:it,after:r},gt);if(e.push(...c.collections.nodes),!c.collections.pageInfo.hasNextPage)break;r=c.collections.pageInfo.endCursor}return e}function z(t,e){let r=(i,o,s)=>P(t,f=>`${i}
2
- ${M(t,f)}`,o,s);async function a(i){let o=O(i);if(!o)return null;if(o.startsWith("gid://")){let{node:f}=await r(st,{id:o},mt);return f?.id?f:null}return(await r(lt,{handle:o},pt)).product}async function c(i,{first:o=e,after:s=null,sortKey:f,reverse:m=!1,filters:w}){let h=await r(ct(),{handle:i,first:o,after:s,sortKey:f||void 0,reverse:m,filters:w??void 0},J);if(!h.collection)return{collection:null,products:[],pageInfo:{hasNextPage:!1,endCursor:null}};let{products:y,...nt}=h.collection;return{collection:nt,products:y.nodes,pageInfo:y.pageInfo}}async function u(i={}){let{collection:o,query:s,first:f=e,after:m=null,sortKey:w,reverse:h=!1}=i;if(o)return c(o,i);let y=await r(ut,{first:f,after:m,query:s||void 0,sortKey:w||void 0,reverse:h},K);return{collection:null,products:y.products.nodes,pageInfo:y.products.pageInfo}}async function d(i={}){let o=[],s=null;for(let f=0;f<ot;f++){let m=await u({...i,first:e,after:s});if(o.push(...m.products),!m.pageInfo.hasNextPage)break;s=m.pageInfo.endCursor}return o}async function n(i,o={}){let s=await u({...o,collection:i});return s.collection?{...s.collection,products:s.products,pageInfo:s.pageInfo}:null}async function l(i,o="RELATED"){let s=O(typeof i=="object"?i?.id:i),f=s?.startsWith("gid://")??!1;return(await r(ft(f),f?{id:s,intent:o}:{handle:s,intent:o},j)).productRecommendations??[]}return{getProduct:a,getProducts:u,allProducts:d,getCollection:n,allCollections:()=>yt(t),getRecommendations:l}}var X={size:"https://schema.org/size",color:"https://schema.org/color",colour:"https://schema.org/color",material:"https://schema.org/material"},R=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");function W(t){return JSON.parse(JSON.stringify(t))}var Z=t=>t.split("/").pop()??t;function Pt(t){return t.availableForSale?t.currentlyNotInStock?"https://schema.org/BackOrder":"https://schema.org/InStock":"https://schema.org/OutOfStock"}function ht(t,e){if(!t.requiresSellingPlan)return e.price;let r=v(t).find(a=>b(e,a.id));return(r&&$(e,r.id))??e.price}function tt(t,e,r){let a=ht(t,e),c=r?.includes("?")?"&":"?";return{"@type":"Offer",price:a.amount,priceCurrency:a.currencyCode,availability:Pt(e),url:r?`${r}${c}variant=${Z(e.id)}`:void 0}}function St(t,e,r,a){let c=e.selectedOptions.flatMap(u=>{let d=X[u.name.toLowerCase()];return d?[[d.split("/").pop()??d,u.value]]:[]});return{"@type":"Product",name:`${t.title} - ${e.title}`,sku:e.sku||void 0,image:e.image?.url||a[0],...Object.fromEntries(c),offers:tt(t,e,r)}}function Ct(t,{url:e},r){if(e)return e;let a=I(r.productPath,t.handle,t.id);if(!(!r.siteUrl||!a))return new URL(a,r.siteUrl).toString()}function x(t,e,r){if(!t)return null;let a=Ct(t,e,r),c=t.images.nodes.map(i=>i.url).filter(Boolean),u=e.brand||t.vendor,d=u?{"@type":"Brand",name:u}:void 0,n=t.description.trim()||void 0,l=t.variants.nodes;if(l.length<=1){let[i]=l;return W({"@context":"https://schema.org","@type":"Product",name:t.title,description:n,url:a,image:c,sku:i?.sku||void 0,brand:d,offers:i?tt(t,i,a):void 0})}let p=t.options.map(i=>X[i.name.toLowerCase()]).filter(Boolean);return W({"@context":"https://schema.org","@type":"ProductGroup",name:t.title,description:n,url:a,productGroupID:Z(t.id),image:c,brand:d,variesBy:[...new Set(p)],hasVariant:l.map(i=>St(t,i,a,c))})}var It=25,Ot=2,vt=1;function bt(t,{productPath:e=g.productPath,id:r}={}){return I(e,t,r)}function et(t,e){for(let r of e){let a=t[r];if(typeof a=="string"&&a)return a}return""}function $t(t){let e={};for(let[u,d]of Object.entries(t))u in g&&(e[u]=d);let r=typeof t.domain=="string"&&t.domain?t.domain:"",a=typeof t.token=="string"&&t.token?t.token:"",c=A({...e,domain:r||et(t,E.domain),token:a||et(t,E.token)});return t.fetch&&(c.fetch=t.fetch),t.pageSize!==void 0&&(c.pageSize=t.pageSize),t.siteUrl!==void 0&&(c.siteUrl=t.siteUrl),c}var wt=t=>typeof t=="number"&&Number.isInteger(t)&&t>0?t:It;function kt(t,e){return{...t,description:"",descriptionHtml:"",images:{nodes:t.images.nodes.slice(0,Math.max(1,e))},variants:{nodes:t.variants.nodes.map(r=>({...r,image:null}))}}}function Yt(t={}){let e=$t(t);if(!e.domain||!e.token)throw new S("createStorefront needs domain and token: pass them, or import.meta.env with PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN",{code:"NOT_CONFIGURED"});let r=z(e,wt(e.pageSize)),a={productPath:e.productPath,siteUrl:e.siteUrl};function c(n,{card:l=!1,images:p=Ot}={}){let i=(Array.isArray(n)?n:[n]).filter(s=>s!=null),o={v:vt,at:new Date().toISOString(),country:e.country||null,language:e.language||null,products:l?i.map(s=>kt(s,p)):i};return`<script type="application/json" data-tether-hydrate>${R(o)}<\/script>`}function u(n,l={}){return n?`<script type="application/ld+json">${R(x(n,l,a))}<\/script>`:""}function d(n,l={}){return Y(n,{defaultPurchase:e.defaultPurchase,lowStock:e.lowStock,...l})}return{config:e,query:(n,l,p)=>P(e,n,l??{},N,{...p,operation:L(n)}),...r,hydrate:c,formatMoney:(n,l=e.locale)=>U(n,l),formatPercent:(n,l=e.locale)=>_(n,l),imageUrl:D,jsonLd:u,jsonLdData:(n,l={})=>x(n,l,a),initialState:d,productUrl:(n,l={})=>bt(n,{productPath:e.productPath,...l}),plans:q}}export{S as TetherError,Yt as createStorefront,U as formatMoney,_ as formatPercent,D as imageUrl,Y as initialState,q as plans,O as productKey,bt as productUrl,rt as withContext};
1
+ import{b as j,f as Q,g as G}from"./chunks/chunk-255K6OZ7.js";import{A as B,B as J,C as K,a as D,c as R,h as O,i as v,j as b,l as M,o as F,q,s as V}from"./chunks/chunk-J7GYROV4.js";import{B as _,a as h,c as w,d as S,f as nt,g as k,i as L,u as U}from"./chunks/chunk-EW3GKRT4.js";import{B as E,E as N,F as C,G as I,q as g,t as A}from"./chunks/chunk-GXCCTPDF.js";function H(t,e={}){if(!t)return null;let{variant:r,sellingPlan:a,defaultPurchase:c=g.defaultPurchase,lowStock:u=g.lowStock}=e,d=Q(t,{variant:r,sellingPlan:a,defaultPurchase:c}),n=G(t,{...d,quantity:1},u);if(!n)throw new h(`Product ${t.handle} has no variants`);let{selected:l,line:p}=n,i=(o,s)=>!j(t,l,o,s);return{variant:n.variant,selected:l,purchase:n.purchase.kind,plan:p.kind==="subscription"?n.plan:null,plans:O(t).map(o=>({id:o.id,name:o.name,price:b(n.variant,o.id),savings:M(n.variant,o.id).percentage,selected:p.kind==="subscription"&&o.id===p.planId,available:!!v(n.variant,o.id)})),savings:n.savings.percentage,price:n.price,compareAtPrice:n.compareAtPrice,available:n.variant.availableForSale,show:n.show,unavailable:Object.fromEntries(t.options.map(o=>[o.name,o.optionValues.map(s=>s.name).filter(s=>i(o.name,s))])),isUnavailable:i}}var rt=500,ot=100,it=100,at="query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}",st="query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}",lt=()=>`query TetherServerCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${R()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,ct="query TetherServerProducts($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}}}",ut=()=>`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${R()}}pageInfo{hasNextPage endCursor}}}`,dt=t=>`query TetherServerRecs(${t?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${t?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`,ft=S({product:w(q)}),pt=S({node:w(V)}),mt=S({collections:{nodes:[{handle:"string"}],pageInfo:{hasNextPage:"boolean"}}});async function gt(t){let e=[],r=null;for(let a=0;a<it;a++){let c=await k(t,ut(),{first:ot,after:r},mt);if(e.push(...c.collections.nodes),!c.collections.pageInfo.hasNextPage)break;r=c.collections.pageInfo.endCursor}return e}function Y(t,e){let r=(i,o,s)=>k(t,f=>`${i}
2
+ ${D(t,f)}`,o,s);async function a(i){let o=I(i);if(!o)return null;if(o.startsWith("gid://")){let{node:f}=await r(at,{id:o},pt);return f?.id?f:null}return(await r(st,{handle:o},ft)).product}async function c(i,{first:o=e,after:s=null,sortKey:f,reverse:m=!1,filters:$}){let P=await r(lt(),{handle:i,first:o,after:s,sortKey:f||void 0,reverse:m,filters:$??void 0},B);if(!P.collection)return{collection:null,products:[],pageInfo:{hasNextPage:!1,endCursor:null}};let{products:y,...et}=P.collection;return{collection:et,products:y.nodes,pageInfo:y.pageInfo}}async function u(i={}){let{collection:o,query:s,first:f=e,after:m=null,sortKey:$,reverse:P=!1}=i;if(o)return c(o,i);let y=await r(ct,{first:f,after:m,query:s||void 0,sortKey:$||void 0,reverse:P},J);return{collection:null,products:y.products.nodes,pageInfo:y.products.pageInfo}}async function d(i={}){let o=[],s=null;for(let f=0;f<rt;f++){let m=await u({...i,first:e,after:s});if(o.push(...m.products),!m.pageInfo.hasNextPage)break;s=m.pageInfo.endCursor}return o}async function n(i,o={}){let s=await u({...o,collection:i});return s.collection?{...s.collection,products:s.products,pageInfo:s.pageInfo}:null}async function l(i,o="RELATED"){let s=I(typeof i=="object"?i?.id:i),f=s?.startsWith("gid://")??!1;return(await r(dt(f),f?{id:s,intent:o}:{handle:s,intent:o},K)).productRecommendations??[]}return{getProduct:a,getProducts:u,allProducts:d,getCollection:n,allCollections:()=>gt(t),getRecommendations:l}}var W={size:"https://schema.org/size",color:"https://schema.org/color",colour:"https://schema.org/color",material:"https://schema.org/material"},T=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");function z(t){return JSON.parse(JSON.stringify(t))}var X=t=>t.split("/").pop()??t;function yt(t){return t.availableForSale?t.currentlyNotInStock?"https://schema.org/BackOrder":"https://schema.org/InStock":"https://schema.org/OutOfStock"}function Pt(t,e){if(!t.requiresSellingPlan)return e.price;let r=O(t).find(a=>v(e,a.id));return(r&&b(e,r.id))??e.price}function Z(t,e,r){let a=Pt(t,e),c=r?.includes("?")?"&":"?";return{"@type":"Offer",price:a.amount,priceCurrency:a.currencyCode,availability:yt(e),url:r?`${r}${c}variant=${X(e.id)}`:void 0}}function ht(t,e,r,a){let c=e.selectedOptions.flatMap(u=>{let d=W[u.name.toLowerCase()];return d?[[d.split("/").pop()??d,u.value]]:[]});return{"@type":"Product",name:`${t.title} - ${e.title}`,sku:e.sku||void 0,image:e.image?.url||a[0],...Object.fromEntries(c),offers:Z(t,e,r)}}function St(t,{url:e},r){if(e)return e;let a=C(r.productPath,t.handle,t.id);if(!(!r.siteUrl||!a))return new URL(a,r.siteUrl).toString()}function x(t,e,r){if(!t)return null;let a=St(t,e,r),c=t.images.nodes.map(i=>i.url).filter(Boolean),u=e.brand||t.vendor,d=u?{"@type":"Brand",name:u}:void 0,n=t.description.trim()||void 0,l=t.variants.nodes;if(l.length<=1){let[i]=l;return z({"@context":"https://schema.org","@type":"Product",name:t.title,description:n,url:a,image:c,sku:i?.sku||void 0,brand:d,offers:i?Z(t,i,a):void 0})}let p=t.options.map(i=>W[i.name.toLowerCase()]).filter(Boolean);return z({"@context":"https://schema.org","@type":"ProductGroup",name:t.title,description:n,url:a,productGroupID:X(t.id),image:c,brand:d,variesBy:[...new Set(p)],hasVariant:l.map(i=>ht(t,i,a,c))})}var Ct=25,It=2,Ot=1;function vt(t,{productPath:e=g.productPath,id:r}={}){return C(e,t,r)}function tt(t,e){for(let r of e){let a=t[r];if(typeof a=="string"&&a)return a}return""}function bt(t){let e={};for(let[u,d]of Object.entries(t))u in g&&(e[u]=d);let r=typeof t.domain=="string"&&t.domain?t.domain:"",a=typeof t.token=="string"&&t.token?t.token:"",c=A({...e,domain:r||tt(t,E.domain),token:a||tt(t,E.token)});return t.fetch&&(c.fetch=t.fetch),t.pageSize!==void 0&&(c.pageSize=t.pageSize),t.siteUrl!==void 0&&(c.siteUrl=t.siteUrl),c}var $t=t=>typeof t=="number"&&Number.isInteger(t)&&t>0?t:Ct;function wt(t,e){return{...t,description:"",descriptionHtml:"",images:{nodes:t.images.nodes.slice(0,Math.max(1,e))},variants:{nodes:t.variants.nodes.map(r=>({...r,image:null}))}}}function Ht(t={}){let e=bt(t);if(!e.domain||!e.token)throw new h("createStorefront needs domain and token: pass them, or import.meta.env with PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN",{code:"NOT_CONFIGURED"});let r=Y(e,$t(e.pageSize)),a={productPath:e.productPath,siteUrl:e.siteUrl};function c(n,{card:l=!1,images:p=It}={}){let i=(Array.isArray(n)?n:[n]).filter(s=>s!=null),o={v:Ot,at:new Date().toISOString(),country:e.country||null,language:e.language||null,products:l?i.map(s=>wt(s,p)):i};return`<script type="application/json" data-tether-hydrate>${T(o)}<\/script>`}function u(n,l={}){return n?`<script type="application/ld+json">${T(x(n,l,a))}<\/script>`:""}function d(n,l={}){return H(n,{defaultPurchase:e.defaultPurchase,lowStock:e.lowStock,...l})}return{config:e,query:(n,l,p)=>L(e,n,l,p),...r,hydrate:c,formatMoney:(n,l=e.locale)=>N(n,l),formatPercent:(n,l=e.locale)=>_(n,l),imageUrl:U,jsonLd:u,jsonLdData:(n,l={})=>x(n,l,a),initialState:d,productUrl:(n,l={})=>vt(n,{productPath:e.productPath,...l}),plans:F}}export{h as TetherError,Ht as createStorefront,N as formatMoney,_ as formatPercent,U as imageUrl,H as initialState,F as plans,I as productKey,vt as productUrl,nt as withContext};
@@ -70,9 +70,9 @@
70
70
  let note = `supported until about ${supportedUntil.toISOString().slice(0, 7)}`;
71
71
  if (!isReleased) note = "not released yet (release candidate at best)";
72
72
  else if (monthsLeft <= 0) {
73
- note = "no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)";
73
+ note = "no longer supported: Shopify falls back to the oldest supported version. Upgrade (see docs/reference.md)";
74
74
  } else if (monthsLeft < UPGRADE_WARNING_MONTHS) {
75
- note = `${note}: plan the upgrade to ${nextApiVersion(version)} or later (see README)`;
75
+ note = `${note}: plan the upgrade to ${nextApiVersion(version)} or later (see docs/reference.md)`;
76
76
  }
77
77
  return {
78
78
  version,
@@ -1,4 +1,4 @@
1
- (()=>{var L=Object.defineProperty;var Y=(e,n)=>{for(var t in n)L(e,t,{get:n[t],enumerable:!0})};var P={};Y(P,{apiVersionStatus:()=>y,checkMarkup:()=>k,diagnose:()=>ke,didYouMean:()=>f});var G=window.Tether.__core["config.ts"],[a,S,Re,$e,Ae,Te,_e]=G;var B=window.Tether.__core["client.ts"],[R,$,Ne,A,xe]=B;var Q=window.Tether.__core["dom.ts"],[De,p,Oe,Ve,Ue,Ie,m,Ce,T,qe,He,Le,d,Ye,l,Ge,Be,Qe]=Q;var j=window.Tether.__core["loader.ts"],[Ke,_]=j;var K=window.Tether.__core["selling-plans.ts"],[v]=K;var W=window.Tether.__core["status.ts"],[N,h]=W;var F=/^(\d{4})-(01|04|07|10)$/;function M(e){let n=F.exec(typeof e=="string"?e:"");return n?{year:Number(n[1]),month:Number(n[2])}:null}var z=(e,n)=>`${e}-${String(n).padStart(2,"0")}`;function x(e,n=1){let t=M(e);if(!t)throw new Error(`not a quarterly Shopify API version: ${e}`);let r=t.year*4+(t.month-1)/3+n;return z(Math.floor(r/4),r%4*3+1)}function y(e,n=new Date){if(e==="unstable")return{version:e,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let t=M(e);if(!t)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let r=new Date(Date.UTC(t.year,t.month-1,1)),s=new Date(Date.UTC(t.year,t.month-1+12,1)),o=(s.getTime()-n.getTime())/2630016e3,i=r<=n,c=`supported until about ${s.toISOString().slice(0,7)}`;return i?o<=0?c="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":o<3&&(c=`${c}: plan the upgrade to ${x(e)} or later (see README)`):c="not released yet (release candidate at best)",{version:e,ok:i&&o>0,monthsLeft:Math.round(o),next:x(e),note:c}}var J=window.Tether.__core["lazy.ts"],[D]=J;var O=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),V=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),U=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
1
+ (()=>{var L=Object.defineProperty;var Y=(e,n)=>{for(var t in n)L(e,t,{get:n[t],enumerable:!0})};var P={};Y(P,{apiVersionStatus:()=>y,checkMarkup:()=>k,diagnose:()=>ke,didYouMean:()=>f});var G=window.Tether.__core["config.ts"],[a,E,$e,Re,Te,Ae,_e]=G;var B=window.Tether.__core["client.ts"],[$,R,Ne,T,xe]=B;var Q=window.Tether.__core["dom.ts"],[De,p,Oe,Ve,Ue,Ie,m,Ce,A,qe,He,Le,d,Ye,l,Ge,Be,Qe]=Q;var j=window.Tether.__core["loader.ts"],[Ke,_]=j;var K=window.Tether.__core["selling-plans.ts"],[v]=K;var W=window.Tether.__core["status.ts"],[N,h]=W;var F=/^(\d{4})-(01|04|07|10)$/;function M(e){let n=F.exec(typeof e=="string"?e:"");return n?{year:Number(n[1]),month:Number(n[2])}:null}var z=(e,n)=>`${e}-${String(n).padStart(2,"0")}`;function x(e,n=1){let t=M(e);if(!t)throw new Error(`not a quarterly Shopify API version: ${e}`);let r=t.year*4+(t.month-1)/3+n;return z(Math.floor(r/4),r%4*3+1)}function y(e,n=new Date){if(e==="unstable")return{version:e,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let t=M(e);if(!t)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let r=new Date(Date.UTC(t.year,t.month-1,1)),s=new Date(Date.UTC(t.year,t.month-1+12,1)),o=(s.getTime()-n.getTime())/2630016e3,i=r<=n,c=`supported until about ${s.toISOString().slice(0,7)}`;return i?o<=0?c="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see docs/reference.md)":o<3&&(c=`${c}: plan the upgrade to ${x(e)} or later (see docs/reference.md)`):c="not released yet (release candidate at best)",{version:e,ok:i&&o>0,monthsLeft:Math.round(o),next:x(e),note:c}}var J=window.Tether.__core["lazy.ts"],[D]=J;var O=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),V=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),U=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
2
2
  always-enabled bind cart-checkout-charge cart-clear cart-close cart-count cart-discounts cart-drawer cart-label cart-lines
3
3
  cart-note cart-open cart-subtotal cart-total cart-warning checkout code collection collection-bind countries country
4
4
  country-bind country-label country-select default-plan default-purchase discount discount-code discount-form discount-input
@@ -11,4 +11,4 @@
11
11
  plan-value product products purchase purchase-mode qty qty-minus qty-plus quantity recommendations reverse search
12
12
  search-bind search-collections search-input search-limit search-min search-products search-queries search-results
13
13
  search-state show soldout-text sort state subscribe-text variant variant-select variant-url max-width max-height crop
14
- sig label hydrated busy`.split(/\s+/).filter(Boolean)),X=["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"],Z=["option-list","plan-list","cart-lines","list"],w="metafield:",ee=/^image:\d+$/,te=2;function ne(e,n){let t=Array.from({length:n.length+1},(r,s)=>s);for(let r=1;r<=e.length;r++){let s=[r];for(let o=1;o<=n.length;o++){let i=(t[o-1]??0)+(e[r-1]===n[o-1]?0:1);s.push(Math.min((t[o]??0)+1,(s[o-1]??0)+1,i))}t=s}return t[n.length]??0}function f(e,n,t=""){let r=null,s=1/0;for(let i of n){let c=ne(e,i);c<s&&(s=c,r=i)}let o=Math.max(2,Math.floor(e.length/4));return r!==null&&s<=o?` Did you mean "${t}${r}"?`:""}function re(e){let n=e.id?`#${e.id}`:"",t=e.className&&typeof e.className=="string"?e.className.trim().split(/\s+/):[],r=t.length?`.${t.slice(0,te).join(".")}`:"";return`<${e.tagName.toLowerCase()}${n}${r}>`}var I=()=>`${l("collection")},${l("products")},${l("recommendations")}`;function oe(e,n){d(e,l("product")).forEach(t=>{if(t.closest(I())&&t.closest(l("list")))return;let{key:r,fromUrl:s,raw:o}=h(t);o?s&&!r&&n("warn",`${p("product")}="${o}" but this URL has no value for it (e.g. ?handle=my-product).`,t):n("error",`${p("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,t)})}function se(e,n){for(let t of X)d(e,l(t)).forEach(r=>{r.closest(l("product"))||t==="line-attribute"&&r.closest(l("group"))||n("warn",`${p(t)} outside any ${p("product")}: it does nothing here.`,r)});d(e,l("group-add")).forEach(t=>{t.closest(l("group"))||n("warn",`${p("group-add")} outside a ${p("group")}.`,t)});for(let t of Z)d(e,l(t)).forEach(r=>{!r.firstElementChild&&!T(r)&&n("warn",`${p(t)} without a template child: put one example element inside it.`,r)});d(e,I()).forEach(t=>{d(t,l("list")).length||n("error",`List without a ${p("list")} child: products have nowhere to render.`,t)})}function ie(e,n){d(e,l("show")).forEach(t=>{let r=m(t,"show")??"";O.has(r)||n("warn",`Unknown ${p("show")}="${r}".${f(r,O)}`,t)}),d(e,l("bind")).forEach(t=>{let r=m(t,"bind")||"";!r||V.has(r)||ee.test(r)||r.startsWith(w)||n("warn",`Unknown ${p("bind")}="${r}": it stays empty.${f(r,V)}`,t)})}function ae(e,n){d(e,l("bind")).forEach(t=>{let r=m(t,"bind")||"";if(!r.startsWith(w))return;let s=r.slice(w.length);a.metafields.some(i=>(typeof i=="string"?i:`${i.namespace}.${i.key}`)===s)||n("error",`${p("bind")}="${r}" but "${s}" is not in config.metafields, so it stays empty.`,t)})}function ce(e,n){let t=`${a.prefix}-`,r=new Set;d(e,"*").forEach(s=>{for(let{name:o}of s.attributes){if(!o.startsWith(t))continue;let i=o.slice(t.length);U.has(i)||r.has(i)||(r.add(i),n("warn",`Unknown attribute ${o}: Tether ignores it.${f(i,U,t)}`,s))}})}function le(e,n){let t=d(e,l("cart-drawer")).length;d(e,l("cart-open")).length&&!t&&n("warn",`${p("cart-open")} exists but there is no ${p("cart-drawer")} on this page.`),t>1&&n("warn",`More than one ${p("cart-drawer")}.`),d(e,`[${p("state")}="error"]`).forEach(r=>{r.matches(N())&&n("error",`Scope failed to load (${m(r,"error")||"error"}).`,r)})}function k(e=document){let n=[],t=(r,s,o)=>{n.push(o?{level:r,message:s,element:re(o),el:o}:{level:r,message:s})};return oe(e,t),se(e,t),ie(e,t),ce(e,t),ae(e,t),le(e,t),n}var ue=20,de=3,C=4;function pe(e){return e?`${e.slice(0,C)}\u2026${e.slice(-C)} (${e.length} chars)`:"(missing)"}function q(e,n){if(e instanceof Error&&e.message)return e.message;let t=typeof e=="object"&&e!==null?Reflect.get(e,"code"):void 0;return typeof t=="string"&&t?t:n}function me(){return{domain:a.domain||"(missing)",token:pe(a.token),apiVersion:a.apiVersion,endpoint:a.domain?R():null,country:a.country,language:a.language,locale:a.locale,markets:a.markets,prefix:a.prefix,productPath:a.productPath,metafields:a.metafields,autoMount:a.autoMount,observe:a.observe,onError:typeof a.onError=="function"}}async function fe(){return{country:a.country||null,language:a.language||null,locale:a.locale||null,detected:a.markets?.detect?(await D("markets")).detectMarket(a.markets):null}}function ge({ok:e,monthsLeft:n,note:t}){return e&&(n===void 0||n>=de)?null:{level:e?"warn":"error",message:`apiVersion ${a.apiVersion}: ${t}`}}var he=A({shop:{name:"string",primaryDomain:{url:"string"},paymentSettings:{currencyCode:"string"}}});async function be(){if(!S())return{kind:"not-configured"};let e=Date.now();try{let n=await $("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},he,{context:!1});return{kind:"reachable",shop:{name:n.shop.name,url:n.shop.primaryDomain.url,currency:n.shop.paymentSettings.currencyCode},latencyMs:Date.now()-e}}catch(n){return{kind:"unreachable",error:n,latencyMs:Date.now()-e}}}function ye(e,n,t){let r=[],s=t.options.map(i=>i.name),o=d(e,l("product")).filter(i=>h(i).key===n&&i.querySelector(l("add-to-cart")));for(let i of o){let c=new Set(d(i,`${l("option-list")},select${l("option")}`).map(u=>m(u,"option-list")||m(u,"option")));if(!(!c.size&&d(i,`select${l("variant-select")}`).length)){if(!a.language)for(let u of c)!u||s.includes(u)||r.push({level:"warn",message:`Product "${t.handle}" has no option "${u}" (its options: ${s.join(", ")||"none"}).${f(u,s)}`});for(let u of t.options)u.optionValues.length<=1||c.has(u.name)||r.push({level:"warn",message:`Product "${t.handle}": option "${u.name}" (${u.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})}}return r}async function we(e,n){let t=d(e,l("product")).map(o=>h(o).key),r=[...new Set(t.filter(o=>o!==null&&o!==""))].slice(0,ue);(await Promise.allSettled(r.map(o=>_(o)))).forEach((o,i)=>{let c=r[i]??"";if(o.status==="rejected"){let g=q(o.reason,"not loaded");n.products.push({key:c,error:o.reason instanceof Error?o.reason.message:void 0}),n.problems.push({level:"error",message:`Product "${c}": ${g}. Is it published to the Headless channel?`});return}let u=o.value,E=v(u);n.products.push({key:c,handle:u.handle,title:u.title,plans:E.length,requiresSellingPlan:u.requiresSellingPlan});for(let g of E)n.sellingPlans.push({product:u.handle,group:g.group.name,plan:g.name,id:g.id});n.problems.push(...ye(e,c,u))})}async function ke({root:e=document,silent:n=!1,version:t="",now:r=new Date}={}){let s=await be(),o={version:t,config:me(),apiVersion:y(a.apiVersion,r),market:await fe(),reachable:s.kind==="reachable",shop:s.kind==="reachable"?s.shop:null,latencyMs:s.kind==="not-configured"?null:s.latencyMs,products:[],sellingPlans:[],problems:[]};switch(s.kind){case"not-configured":o.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});break;case"unreachable":o.problems.push({level:"error",message:`Storefront API not reachable: ${q(s.error,"unknown error")}`});break;case"reachable":await we(e,o);break}let i=ge(o.apiVersion);return i&&o.problems.push(i),typeof document<"u"&&o.problems.push(...k(e)),n||Pe(o),o}function Pe(e){let n=e.problems.filter(c=>c.level==="error").length,t=e.problems.length-n;console.group(`[${a.prefix}] diagnose: ${n?`${n} error(s)`:"no errors"}, ${t} warning(s)`),console.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),console.log("config",e.config);let{country:r,language:s,detected:o}=e.market,i=[r,s].filter(Boolean).join(" / ")||"the store default";console.log("market",`in use: ${i}`,o?`(detection picks ${JSON.stringify(o)})`:""),console.log(e.shop?`Storefront API reachable: ${e.shop.name} (${e.latencyMs??0} ms)`:"Storefront API NOT reachable"),e.products.length&&console.table(e.products),e.sellingPlans.length?console.table(e.sellingPlans):e.reachable&&console.log("No selling plans on the products of this page.");for(let c of e.problems)c.level==="error"?console.error(c.message,c.el??""):console.warn(c.message,c.el??"");console.groupEnd()}function b(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ee(e){return b(e)&&b(e.__core)&&b(e.__parts)}function H(e,n){let t=Reflect.get(window,"Tether");if(!Ee(t))throw new Error(`tether.${e}.js runs after the Tether script, which loads it, and needs its window.Tether`);t.__parts[e]=n}H("diagnose",P);})();
14
+ sig label hydrated busy`.split(/\s+/).filter(Boolean)),X=["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"],Z=["option-list","plan-list","cart-lines","list"],w="metafield:",ee=/^image:\d+$/,te=2;function ne(e,n){let t=Array.from({length:n.length+1},(r,s)=>s);for(let r=1;r<=e.length;r++){let s=[r];for(let o=1;o<=n.length;o++){let i=(t[o-1]??0)+(e[r-1]===n[o-1]?0:1);s.push(Math.min((t[o]??0)+1,(s[o-1]??0)+1,i))}t=s}return t[n.length]??0}function f(e,n,t=""){let r=null,s=1/0;for(let i of n){let c=ne(e,i);c<s&&(s=c,r=i)}let o=Math.max(2,Math.floor(e.length/4));return r!==null&&s<=o?` Did you mean "${t}${r}"?`:""}function re(e){let n=e.id?`#${e.id}`:"",t=e.className&&typeof e.className=="string"?e.className.trim().split(/\s+/):[],r=t.length?`.${t.slice(0,te).join(".")}`:"";return`<${e.tagName.toLowerCase()}${n}${r}>`}var I=()=>`${l("collection")},${l("products")},${l("recommendations")}`;function oe(e,n){d(e,l("product")).forEach(t=>{if(t.closest(I())&&t.closest(l("list")))return;let{key:r,fromUrl:s,raw:o}=h(t);o?s&&!r&&n("warn",`${p("product")}="${o}" but this URL has no value for it (e.g. ?handle=my-product).`,t):n("error",`${p("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,t)})}function se(e,n){for(let t of X)d(e,l(t)).forEach(r=>{r.closest(l("product"))||t==="line-attribute"&&r.closest(l("group"))||n("warn",`${p(t)} outside any ${p("product")}: it does nothing here.`,r)});d(e,l("group-add")).forEach(t=>{t.closest(l("group"))||n("warn",`${p("group-add")} outside a ${p("group")}.`,t)});for(let t of Z)d(e,l(t)).forEach(r=>{!r.firstElementChild&&!A(r)&&n("warn",`${p(t)} without a template child: put one example element inside it.`,r)});d(e,I()).forEach(t=>{d(t,l("list")).length||n("error",`List without a ${p("list")} child: products have nowhere to render.`,t)})}function ie(e,n){d(e,l("show")).forEach(t=>{let r=m(t,"show")??"";O.has(r)||n("warn",`Unknown ${p("show")}="${r}".${f(r,O)}`,t)}),d(e,l("bind")).forEach(t=>{let r=m(t,"bind")||"";!r||V.has(r)||ee.test(r)||r.startsWith(w)||n("warn",`Unknown ${p("bind")}="${r}": it stays empty.${f(r,V)}`,t)})}function ae(e,n){d(e,l("bind")).forEach(t=>{let r=m(t,"bind")||"";if(!r.startsWith(w))return;let s=r.slice(w.length);a.metafields.some(i=>(typeof i=="string"?i:`${i.namespace}.${i.key}`)===s)||n("error",`${p("bind")}="${r}" but "${s}" is not in config.metafields, so it stays empty.`,t)})}function ce(e,n){let t=`${a.prefix}-`,r=new Set;d(e,"*").forEach(s=>{for(let{name:o}of s.attributes){if(!o.startsWith(t))continue;let i=o.slice(t.length);U.has(i)||r.has(i)||(r.add(i),n("warn",`Unknown attribute ${o}: Tether ignores it.${f(i,U,t)}`,s))}})}function le(e,n){let t=d(e,l("cart-drawer")).length;d(e,l("cart-open")).length&&!t&&n("warn",`${p("cart-open")} exists but there is no ${p("cart-drawer")} on this page.`),t>1&&n("warn",`More than one ${p("cart-drawer")}.`),d(e,`[${p("state")}="error"]`).forEach(r=>{r.matches(N())&&n("error",`Scope failed to load (${m(r,"error")||"error"}).`,r)})}function k(e=document){let n=[],t=(r,s,o)=>{n.push(o?{level:r,message:s,element:re(o),el:o}:{level:r,message:s})};return oe(e,t),se(e,t),ie(e,t),ce(e,t),ae(e,t),le(e,t),n}var ue=20,de=3,C=4;function pe(e){return e?`${e.slice(0,C)}\u2026${e.slice(-C)} (${e.length} chars)`:"(missing)"}function q(e,n){if(e instanceof Error&&e.message)return e.message;let t=typeof e=="object"&&e!==null?Reflect.get(e,"code"):void 0;return typeof t=="string"&&t?t:n}function me(){return{domain:a.domain||"(missing)",token:pe(a.token),apiVersion:a.apiVersion,endpoint:a.domain?$():null,country:a.country,language:a.language,locale:a.locale,markets:a.markets,prefix:a.prefix,productPath:a.productPath,metafields:a.metafields,autoMount:a.autoMount,observe:a.observe,onError:typeof a.onError=="function"}}async function fe(){return{country:a.country||null,language:a.language||null,locale:a.locale||null,detected:a.markets?.detect?(await D("markets")).detectMarket(a.markets):null}}function ge({ok:e,monthsLeft:n,note:t}){return e&&(n===void 0||n>=de)?null:{level:e?"warn":"error",message:`apiVersion ${a.apiVersion}: ${t}`}}var he=T({shop:{name:"string",primaryDomain:{url:"string"},paymentSettings:{currencyCode:"string"}}});async function be(){if(!E())return{kind:"not-configured"};let e=Date.now();try{let n=await R("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},he,{context:!1});return{kind:"reachable",shop:{name:n.shop.name,url:n.shop.primaryDomain.url,currency:n.shop.paymentSettings.currencyCode},latencyMs:Date.now()-e}}catch(n){return{kind:"unreachable",error:n,latencyMs:Date.now()-e}}}function ye(e,n,t){let r=[],s=t.options.map(i=>i.name),o=d(e,l("product")).filter(i=>h(i).key===n&&i.querySelector(l("add-to-cart")));for(let i of o){let c=new Set(d(i,`${l("option-list")},select${l("option")}`).map(u=>m(u,"option-list")||m(u,"option")));if(!(!c.size&&d(i,`select${l("variant-select")}`).length)){if(!a.language)for(let u of c)!u||s.includes(u)||r.push({level:"warn",message:`Product "${t.handle}" has no option "${u}" (its options: ${s.join(", ")||"none"}).${f(u,s)}`});for(let u of t.options)u.optionValues.length<=1||c.has(u.name)||r.push({level:"warn",message:`Product "${t.handle}": option "${u.name}" (${u.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})}}return r}async function we(e,n){let t=d(e,l("product")).map(o=>h(o).key),r=[...new Set(t.filter(o=>o!==null&&o!==""))].slice(0,ue);(await Promise.allSettled(r.map(o=>_(o)))).forEach((o,i)=>{let c=r[i]??"";if(o.status==="rejected"){let g=q(o.reason,"not loaded");n.products.push({key:c,error:o.reason instanceof Error?o.reason.message:void 0}),n.problems.push({level:"error",message:`Product "${c}": ${g}. Is it published to the Headless channel?`});return}let u=o.value,S=v(u);n.products.push({key:c,handle:u.handle,title:u.title,plans:S.length,requiresSellingPlan:u.requiresSellingPlan});for(let g of S)n.sellingPlans.push({product:u.handle,group:g.group.name,plan:g.name,id:g.id});n.problems.push(...ye(e,c,u))})}async function ke({root:e=document,silent:n=!1,version:t="",now:r=new Date}={}){let s=await be(),o={version:t,config:me(),apiVersion:y(a.apiVersion,r),market:await fe(),reachable:s.kind==="reachable",shop:s.kind==="reachable"?s.shop:null,latencyMs:s.kind==="not-configured"?null:s.latencyMs,products:[],sellingPlans:[],problems:[]};switch(s.kind){case"not-configured":o.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});break;case"unreachable":o.problems.push({level:"error",message:`Storefront API not reachable: ${q(s.error,"unknown error")}`});break;case"reachable":await we(e,o);break}let i=ge(o.apiVersion);return i&&o.problems.push(i),typeof document<"u"&&o.problems.push(...k(e)),n||Pe(o),o}function Pe(e){let n=e.problems.filter(c=>c.level==="error").length,t=e.problems.length-n;console.group(`[${a.prefix}] diagnose: ${n?`${n} error(s)`:"no errors"}, ${t} warning(s)`),console.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),console.log("config",e.config);let{country:r,language:s,detected:o}=e.market,i=[r,s].filter(Boolean).join(" / ")||"the store default";console.log("market",`in use: ${i}`,o?`(detection picks ${JSON.stringify(o)})`:""),console.log(e.shop?`Storefront API reachable: ${e.shop.name} (${e.latencyMs??0} ms)`:"Storefront API NOT reachable"),e.products.length&&console.table(e.products),e.sellingPlans.length?console.table(e.sellingPlans):e.reachable&&console.log("No selling plans on the products of this page.");for(let c of e.problems)c.level==="error"?console.error(c.message,c.el??""):console.warn(c.message,c.el??"");console.groupEnd()}function b(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Se(e){return b(e)&&b(e.__core)&&b(e.__parts)}function H(e,n){let t=Reflect.get(window,"Tether");if(!Se(t))throw new Error(`tether.${e}.js runs after the Tether script, which loads it, and needs its window.Tether`);t.__parts[e]=n}H("diagnose",P);})();
@@ -33,10 +33,32 @@
33
33
  var m5 = window.Tether.__core["page-market.ts"];
34
34
  var [setCountry] = m5;
35
35
 
36
- // server/src/shared/json.ts
37
- function isRecord(value) {
38
- return value !== null && typeof value === "object" && !Array.isArray(value);
36
+ // tether-core:market-codes.ts
37
+ var m6 = window.Tether.__core["market-codes.ts"];
38
+ var [toCountry, toLanguage] = m6;
39
+
40
+ // src/markets.ts
41
+ var storageKey = () => `${cfg.prefix}:market:${cfg.domain}`;
42
+ function parseJsonOrNull(text) {
43
+ try {
44
+ return JSON.parse(text);
45
+ } catch (error) {
46
+ if (error instanceof SyntaxError) return null;
47
+ throw error;
48
+ }
49
+ }
50
+ function toMarket(value) {
51
+ if (typeof value !== "object" || value === null) return null;
52
+ const country = toCountry(Reflect.get(value, "country"));
53
+ if (!country) return null;
54
+ const locale = Reflect.get(value, "locale");
55
+ return {
56
+ country,
57
+ language: toLanguage(Reflect.get(value, "language")) ?? void 0,
58
+ locale: typeof locale === "string" && locale ? locale : void 0
59
+ };
39
60
  }
61
+ var parseSavedMarket = (text) => toMarket(parseJsonOrNull(text));
40
62
 
41
63
  // src/extras.ts
42
64
  function groupAttributes(group, name) {
@@ -67,22 +89,6 @@
67
89
  return null;
68
90
  }
69
91
  }
70
- function parseStoredMarket(text) {
71
- let value;
72
- try {
73
- value = JSON.parse(text);
74
- } catch {
75
- return null;
76
- }
77
- if (!isRecord(value)) return null;
78
- const { country, language, locale } = value;
79
- if (typeof country !== "string" || !country) return null;
80
- return {
81
- country,
82
- language: typeof language === "string" ? language : null,
83
- locale: typeof locale === "string" ? locale : void 0
84
- };
85
- }
86
92
  function onStorage(event) {
87
93
  if (event.key === cfg.storageKey || event.key === `${cfg.storageKey}:seen`) {
88
94
  Cart.init().catch((error) => {
@@ -90,10 +96,10 @@
90
96
  });
91
97
  return;
92
98
  }
93
- if (event.key !== `${cfg.prefix}:market:${cfg.domain}` || !event.newValue) return;
94
- const market = parseStoredMarket(event.newValue);
99
+ if (event.key !== storageKey() || !event.newValue) return;
100
+ const market = parseSavedMarket(event.newValue);
95
101
  if (!market) return;
96
- const options = { language: market.language, locale: market.locale, remember: false };
102
+ const options = { language: market.language ?? null, locale: market.locale, remember: false };
97
103
  setCountry(market.country, options).catch((error) => {
98
104
  reportError(error, "market from another tab");
99
105
  });
@@ -120,6 +126,11 @@
120
126
  replaceUrlIfAllowed(url);
121
127
  }
122
128
 
129
+ // server/src/shared/json.ts
130
+ function isRecord(value) {
131
+ return value !== null && typeof value === "object" && !Array.isArray(value);
132
+ }
133
+
123
134
  // src/part-registry.ts
124
135
  function isTetherInternals(value) {
125
136
  return isRecord(value) && isRecord(value["__core"]) && isRecord(value["__parts"]);
@@ -1 +1 @@
1
- (()=>{var N=Object.defineProperty;var A=(t,r)=>{for(var e in r)N(t,e,{get:r[e],enumerable:!0})};var m={};A(m,{addGroup:()=>I,onStorage:()=>$,writeVariantUrl:()=>q});var O=window.Tether.__core["config.ts"],[i,V,j,z,D,c,d]=O;var P=window.Tether.__core["dom.ts"],[W,Y,g,w,Z,v,h,y,B,H,k,Q,x,X,l,tt,rt,et]=P;var C=window.Tether.__core["product.ts"],[T]=C;var M=window.Tether.__core["cart.ts"],[f]=M;var R=window.Tether.__core["page-market.ts"],[_]=R;function u(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function U(t,r){let e=g(k(t,"line-attributes"));return r?[{key:"_group",value:r},...e]:e}async function I(t){let r=t.closest(l("group"));if(!r)return null;let e=h(r,"group"),n=U(r,e),o=x(r,l("product")).flatMap(a=>{let s=T.get(a);if(!s?.variant?.availableForSale||s.quantity<=0)return[];let p=s.getLine();return p?[{...p,attributes:[...p.attributes??[],...n]}]:[]});if(!o.length)return d("group-add: nothing selected"),null;try{let a=await f.add(o);return w("group-added",{group:e,lines:o},r),a}catch(a){return c(a,"group add"),null}}function L(t){let r;try{r=JSON.parse(t)}catch{return null}if(!u(r))return null;let{country:e,language:n,locale:o}=r;return typeof e!="string"||!e?null:{country:e,language:typeof n=="string"?n:null,locale:typeof o=="string"?o:void 0}}function $(t){if(t.key===i.storageKey||t.key===`${i.storageKey}:seen`){f.init().catch(n=>{c(n,"cart from another tab")});return}if(t.key!==`${i.prefix}:market:${i.domain}`||!t.newValue)return;let r=L(t.newValue);if(!r)return;let e={language:r.language,locale:r.locale,remember:!1};_(r.country,e).catch(n=>{c(n,"market from another tab")})}var b=new WeakMap,S=t=>t.split("/").pop()??t;function J(t){try{window.history.replaceState(window.history.state,"",t)}catch{}}function q(t,{variant:r,sellingPlanId:e}){let n=`${r.id}|${e??""}`,o=b.get(t);if(b.set(t,n),!o||o===n)return;let a=i.variantUrl&&document.querySelector(l("product"))===t;if(!y(t,"variant-url")&&!a)return;let s=new URL(window.location.href);s.searchParams.set("variant",S(r.id)),e?s.searchParams.set("selling_plan",S(e)):s.searchParams.delete("selling_plan"),J(s)}function F(t){return u(t)&&u(t.__core)&&u(t.__parts)}function E(t,r){let e=Reflect.get(window,"Tether");if(!F(e))throw new Error(`tether.${t}.js runs after the Tether script, which loads it, and needs its window.Tether`);e.__parts[t]=r}E("extras",m);})();
1
+ (()=>{var N=Object.defineProperty;var R=(e,t)=>{for(var n in t)N(e,n,{get:t[n],enumerable:!0})};var f={};R(f,{addGroup:()=>q,onStorage:()=>j,writeVariantUrl:()=>V});var O=window.Tether.__core["config.ts"],[c,Y,Z,P,I,i,p]=O;var v=window.Tether.__core["dom.ts"],[Q,X,m,y,ee,te,k,w,ne,re,h,oe,S,ae,s,ce,ue,ie]=v;var U=window.Tether.__core["product.ts"],[C]=U;var K=window.Tether.__core["cart.ts"],[d]=K;var F=window.Tether.__core["page-market.ts"],[M]=F;var H=window.Tether.__core["market-codes.ts"],[x,b]=H;var E=()=>`${c.prefix}:market:${c.domain}`;function $(e){try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return null;throw t}}function D(e){if(typeof e!="object"||e===null)return null;let t=x(Reflect.get(e,"country"));if(!t)return null;let n=Reflect.get(e,"locale");return{country:t,language:b(Reflect.get(e,"language"))??void 0,locale:typeof n=="string"&&n?n:void 0}}var T=e=>D($(e));function J(e,t){let n=m(h(e,"line-attributes"));return t?[{key:"_group",value:t},...n]:n}async function q(e){let t=e.closest(s("group"));if(!t)return null;let n=k(t,"group"),r=J(t,n),u=S(t,s("product")).flatMap(a=>{let o=C.get(a);if(!o?.variant?.availableForSale||o.quantity<=0)return[];let g=o.getLine();return g?[{...g,attributes:[...g.attributes??[],...r]}]:[]});if(!u.length)return p("group-add: nothing selected"),null;try{let a=await d.add(u);return y("group-added",{group:n,lines:u},t),a}catch(a){return i(a,"group add"),null}}function j(e){if(e.key===c.storageKey||e.key===`${c.storageKey}:seen`){d.init().catch(r=>{i(r,"cart from another tab")});return}if(e.key!==E()||!e.newValue)return;let t=T(e.newValue);if(!t)return;let n={language:t.language??null,locale:t.locale,remember:!1};M(t.country,n).catch(r=>{i(r,"market from another tab")})}var _=new WeakMap,L=e=>e.split("/").pop()??e;function z(e){try{window.history.replaceState(window.history.state,"",e)}catch{}}function V(e,{variant:t,sellingPlanId:n}){let r=`${t.id}|${n??""}`,u=_.get(e);if(_.set(e,r),!u||u===r)return;let a=c.variantUrl&&document.querySelector(s("product"))===e;if(!w(e,"variant-url")&&!a)return;let o=new URL(window.location.href);o.searchParams.set("variant",L(t.id)),n?o.searchParams.set("selling_plan",L(n)):o.searchParams.delete("selling_plan"),z(o)}function l(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function W(e){return l(e)&&l(e.__core)&&l(e.__parts)}function A(e,t){let n=Reflect.get(window,"Tether");if(!W(n))throw new Error(`tether.${e}.js runs after the Tether script, which loads it, and needs its window.Tether`);n.__parts[e]=t}A("extras",f);})();