@occluze/tether 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/esm/astro.js +2 -2
- package/dist/esm/chunks/account-3MYRPPTR.js +1 -0
- package/dist/esm/chunks/{account-pages-3C5KTPQV.js → account-pages-OZHK5HHY.js} +1 -1
- package/dist/esm/chunks/{analytics-VWSZOX2D.js → analytics-QHX2YHZS.js} +1 -1
- package/dist/esm/chunks/chunk-24KD36UC.js +1 -0
- package/dist/esm/chunks/{chunk-F2BYVA7V.js → chunk-2G6U6ZYV.js} +1 -1
- package/dist/esm/chunks/{chunk-MJNPD6LB.js → chunk-74SGIWQE.js} +1 -1
- package/dist/esm/chunks/{chunk-3UCVDDK6.js → chunk-A3GZFAB3.js} +1 -1
- package/dist/esm/chunks/chunk-A6BZFYZY.js +1 -0
- package/dist/esm/chunks/{chunk-HROQXZYN.js → chunk-EYG7QGPA.js} +1 -1
- package/dist/esm/chunks/{chunk-P6DV24RG.js → chunk-FX7EJ6RB.js} +1 -1
- package/dist/esm/chunks/{chunk-OURC3H6L.js → chunk-GCGRUVYO.js} +1 -1
- package/dist/esm/chunks/{chunk-2IGCUTG5.js → chunk-LSB7RVRZ.js} +1 -1
- package/dist/esm/chunks/{chunk-S5BUUIB6.js → chunk-NF5H2Q7V.js} +1 -1
- package/dist/esm/chunks/chunk-PZERNTCD.js +1 -0
- package/dist/esm/chunks/chunk-RVWHBZAF.js +1 -0
- package/dist/esm/chunks/chunk-SJNNEEDX.js +1 -0
- package/dist/esm/chunks/{chunk-XU27NSXT.js → chunk-SOLTIZAI.js} +1 -1
- package/dist/esm/chunks/{chunk-ZBV2JSHE.js → chunk-WHNUPECA.js} +1 -1
- package/dist/esm/chunks/{chunk-2A2GN3Z7.js → chunk-ZB4FBE6W.js} +1 -1
- package/dist/esm/chunks/{diagnose-TE72GNOO.js → diagnose-O3QCZTHT.js} +1 -1
- package/dist/esm/chunks/{extras-7GTMJMOZ.js → extras-O6ZRL5FK.js} +1 -1
- package/dist/esm/chunks/lists-XF33XENI.js +1 -0
- package/dist/esm/chunks/{markets-ui-AAQM4PEE.js → markets-ui-V2ROBFZP.js} +1 -1
- package/dist/esm/chunks/search-ZLKIFARH.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/server.js +2 -2
- package/dist/tether.account-pages.js +2 -2
- package/dist/tether.account-pages.min.js +1 -1
- package/dist/tether.account.js +4 -7
- package/dist/tether.account.min.js +1 -1
- package/dist/tether.analytics.js +1 -1
- package/dist/tether.analytics.min.js +1 -1
- package/dist/tether.diagnose.js +1 -1
- package/dist/tether.diagnose.min.js +1 -1
- package/dist/tether.extras.js +1 -1
- package/dist/tether.extras.min.js +1 -1
- package/dist/tether.js +110 -64
- package/dist/tether.lists.js +11 -7
- package/dist/tether.lists.min.js +1 -1
- package/dist/tether.markets.js +1 -1
- package/dist/tether.markets.min.js +1 -1
- package/dist/tether.min.js +1 -1
- package/dist/tether.min.js.map +4 -4
- package/dist/tether.search.js +4 -6
- package/dist/tether.search.min.js +1 -1
- package/dist/types/server/src/shared/metafield-ref.d.ts +15 -0
- package/dist/types/src/dom.d.ts +12 -0
- package/dist/types/src/server.d.ts +5 -2
- package/dist/types/src/shopify-values.d.ts +2 -0
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/dist/esm/chunks/account-LCMJ7QU5.js +0 -1
- package/dist/esm/chunks/chunk-D3MRWOFI.js +0 -1
- package/dist/esm/chunks/chunk-EUCFOBIT.js +0 -1
- package/dist/esm/chunks/chunk-P73VN3B6.js +0 -1
- package/dist/esm/chunks/chunk-SOFWDTR7.js +0 -1
- package/dist/esm/chunks/chunk-YJC3CSEG.js +0 -1
- package/dist/esm/chunks/lists-ZMVRGD6L.js +0 -1
- package/dist/esm/chunks/search-PWF4YZQO.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c,c as u,d as o}from"./chunk-
|
|
1
|
+
import{b as c,c as u,d as o}from"./chunk-A6BZFYZY.js";import{d as m,e as s,n as g,x as p}from"./chunk-PZERNTCD.js";var e="amount currencyCode",P={inventory:!0},f=t=>t.inventory?"quantityAvailable":"",n="url altText width height";function A(t){let i=[];for(let l of t){let r=g(l);r&&i.push(r)}return i.length?`metafields(identifiers:[${i.map(({namespace:l,key:r})=>`{namespace: ${JSON.stringify(l)}, key: ${JSON.stringify(r)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${n}}}}}`:""}var h=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${e}}}... on SellingPlanFixedPriceAdjustment{price{${e}}}}}`,$=` sellingPlan{id}checkoutChargeAmount{${e}}remainingBalanceChargeAmount{${e}}priceAdjustments{price{${e}}compareAtPrice{${e}}perDeliveryPrice{${e}}unitPrice{${e}}}`;function b(t=p,i=P){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${n}}images(first:${t.imagesFirst}){nodes{${n}}}options{name optionValues{name swatch{color image{previewImage{${n}}}}}}priceRange{minVariantPrice{${e}}maxVariantPrice{${e}}}compareAtPriceRange{minVariantPrice{${e}}maxVariantPrice{${e}}}${A(t.metafields)} sellingPlanGroups(first:${t.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${t.sellingPlansFirst}){nodes{${h}}}}}variants(first:${t.variantsFirst}){nodes{id title availableForSale currentlyNotInStock ${f(i)} sku barcode selectedOptions{name value}image{${n}}price{${e}}compareAtPrice{${e}}unitPrice{${e}}sellingPlanAllocations(first:${t.sellingPlansFirst}){nodes{${$}}}}}}`}function x(t=P){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${e}}totalAmount{${e}}checkoutChargeAmount{${e}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${e}}subtotalAmount{${e}}amountPerQuantity{${e}}compareAtAmountPerQuantity{${e}}}discountAllocations{discountedAmount{${e}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${e}}priceAdjustments{price{${e}}compareAtPrice{${e}}perDeliveryPrice{${e}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping ${f(t)} image{${n}}price{${e}}compareAtPrice{${e}}selectedOptions{name value}product{id title handle vendor featuredImage{${n}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function F(){return` id handle title description descriptionHtml image{${n}}seo{title description}`}var d={amount:"string",currencyCode:"string"},a={id:"string",handle:"string",title:"string",options:["object"],images:{nodes:["object"]},priceRange:{minVariantPrice:d,maxVariantPrice:d},variants:{nodes:[{id:"string",price:d,selectedOptions:["object"]}]}},y={nodes:[a],pageInfo:{hasNextPage:"boolean"}},O=t=>s(t,"id")!==""&&s(t,"handle")!==""&&c(t,a),V=t=>m(t)&&(t.id===void 0||c(t,a)),k=o({collection:u({handle:"string",products:y})}),N=o({products:y}),_=o({productRecommendations:u([a])});export{b as a,x as b,F as c,d,a as e,O as f,V as g,k as h,N as i,_ as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as m,f as p}from"./chunk-
|
|
1
|
+
import{e as m,f as p}from"./chunk-FX7EJ6RB.js";import{a as M}from"./chunk-LSB7RVRZ.js";import{A as y,m as k,o as i,p as g,x as u}from"./chunk-PZERNTCD.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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as E}from"./chunk-
|
|
1
|
+
import{e as E}from"./chunk-NF5H2Q7V.js";import{a as M}from"./chunk-SJNNEEDX.js";import{b as h,e as A}from"./chunk-LSB7RVRZ.js";import{c as D}from"./chunk-RVWHBZAF.js";import"./chunk-WHNUPECA.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-A6BZFYZY.js";import{C as w,c as k,x as a}from"./chunk-PZERNTCD.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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as v}from"./chunk-
|
|
1
|
+
import{c as v}from"./chunk-A3GZFAB3.js";import{a as b,b as S}from"./chunk-ZB4FBE6W.js";import{a as k}from"./chunk-2G6U6ZYV.js";import{h as p}from"./chunk-FX7EJ6RB.js";import"./chunk-SOLTIZAI.js";import"./chunk-NF5H2Q7V.js";import"./chunk-SJNNEEDX.js";import"./chunk-LSB7RVRZ.js";import"./chunk-RVWHBZAF.js";import"./chunk-WHNUPECA.js";import{N as h,P as w,m as l,n as f,o as g,p as d,t as y}from"./chunk-A6BZFYZY.js";import{E as m,F as u,x as s}from"./chunk-PZERNTCD.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as R}from"./chunk-24KD36UC.js";import"./chunk-SJNNEEDX.js";import{b as w,d as I,g as T}from"./chunk-LSB7RVRZ.js";import{a as H,b as m,d as h}from"./chunk-RVWHBZAF.js";import{c as q,h as x,i as M,j as F}from"./chunk-WHNUPECA.js";import{E as v,F as E,H as f,K,M as A,O,a as P,h as a,l as $,m as c,n as s,o as d,q as N,t as u,w as b,y as k}from"./chunk-A6BZFYZY.js";import{F as L,b as l,x as y}from"./chunk-PZERNTCD.js";var U="url:",W=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${q()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,j="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 z({collection:n,query:t,first:r=y.collectionFirst,after:e=null,sortKey:o,reverse:i=!1,filters:D}={}){if(n){let S=await a(h(W),{handle:n,first:r,after:e,sortKey:o||void 0,reverse:i,filters:D??void 0},x);if(!S.collection)throw new P(`Collection not found: ${n}`,{code:"NOT_FOUND"});let{products:g,...Y}=S.collection;return g.nodes.forEach(m),{collection:Y,products:g.nodes,pageInfo:g.pageInfo}}let p=await a(h(j),{first:r,after:e,query:t||void 0,sortKey:o||void 0,reverse:i},M);return p.products.nodes.forEach(m),{collection:null,products:p.products.nodes,pageInfo:p.products.pageInfo}}async function X(n,t="RELATED"){let r=H(typeof n=="object"?n?.id:n);if(!r)throw new P("No product for recommendations",{code:"NOT_FOUND"});let e=r.startsWith("gid://"),i=(await a(h(`query TetherRecs(${e?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${e?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`),e?{id:r,intent:t}:{handle:r,intent:t},F)).productRecommendations??[];return i.forEach(m),i}var Z=n=>n instanceof window.Element,_=(n,t)=>O(n,"limit",{min:1,max:250,fallback:t}),G=n=>n==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",C=class{constructor(t){l(this,"root");l(this,"products",[]);l(this,"pageInfo",null);l(this,"collection",null);l(this,"loadToken",0);this.root=t,t.addEventListener("click",r=>{if(!Z(r.target))return;let e=r.target.closest(c("load-more"));e?.closest(R())===t&&(r.preventDefault(),A(e,()=>this.load(!0)))})}$(t){return N(this.root,t,R())}options(){let{root:t}=this,r={reverse:s(t,"reverse")==="true",first:_(t,y.collectionFirst)},e=s(t,"sort");if(e&&(r.sortKey=e),d(t,"collection"))return r.collection=s(t,"collection")??"",r;let o=s(t,"products")??"";return r.query=o.startsWith(U)?new URL(window.location.href).searchParams.get(o.slice(U.length))||"":o,r}async loadRecommendations(){let{key:t}=w(this.root,window.location,"recommendations"),r=this.root.closest(c("product"));return!t&&r&&({key:t}=w(r)),X(t,G(s(this.root,"intent")))}async load(t=!1){this.loadToken+=1;let r=this.loadToken,e=()=>r!==this.loadToken;try{if(d(this.root,"recommendations")){let o=await this.loadRecommendations();if(e())return;this.products=o.slice(0,_(this.root,o.length))}else{let o=await z({...this.options(),after:t?this.pageInfo?.endCursor??null:null});if(e())return;this.collection=o.collection,this.pageInfo=o.pageInfo,this.products=t?[...this.products,...o.products]:o.products}this.render(),T(this.root,"ready"),u("list-ready",{products:this.products,collection:this.collection},this.root)}catch(o){if(e())return;t||T(this.root,I(o)?"not-found":"error",o),I(o)&&d(this.root,"recommendations")||L(o,"list load failed"),u("error",{error:o,context:"list"},this.root)}}render(){let{collection:t}=this;this.$(c("collection-bind")).forEach(e=>{switch(s(e,"collection-bind")??""){case"title":E(e,t?.title??"");break;case"description":v(e,t?.descriptionHtml);break;case"image":b(e,t?.image?.url,t?.image?.altText||t?.title);break;case"count":E(e,this.products.length);break}}),this.$(c("list")).forEach(e=>{k(e,this.products,(o,i)=>{o.setAttribute($("product"),i.handle),o.removeAttribute($("state"))}),u("list-rendered",{container:e},this.root)});let r=this.products.length===0;this.$(c("show")).forEach(e=>{let o=s(e,"show");o==="list-empty"&&f(e,r),o==="list-filled"&&f(e,!r)}),this.$(c("load-more")).forEach(e=>{f(e,!!this.pageInfo?.hasNextPage)}),K("list")}},Q=new WeakMap;function ct(n){let t=Q.get(n);return t||(t=new C(n),Q.set(n,t)),t.load()}export{z as getProducts,X as getRecommendations,ct as loadList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E,c as P,d as k,e as T,f as p,g as A}from"./chunk-
|
|
1
|
+
import{a as E,c as P,d as k,e as T,f as p,g as A}from"./chunk-EYG7QGPA.js";import{a as I}from"./chunk-24KD36UC.js";import{d as F,e as x}from"./chunk-ZB4FBE6W.js";import"./chunk-2G6U6ZYV.js";import{h as u}from"./chunk-FX7EJ6RB.js";import"./chunk-SOLTIZAI.js";import"./chunk-NF5H2Q7V.js";import"./chunk-SJNNEEDX.js";import"./chunk-LSB7RVRZ.js";import{e as w}from"./chunk-RVWHBZAF.js";import"./chunk-WHNUPECA.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-A6BZFYZY.js";import{F as y,o as f,p as g,x as a}from"./chunk-PZERNTCD.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")})),T(),k.forEach(o=>n.push(o.load())),P.forEach(o=>{o.closest(I())||(E.delete(o),A(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&&x({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{f as R}from"./chunk-EYG7QGPA.js";import"./chunk-24KD36UC.js";import"./chunk-2G6U6ZYV.js";import"./chunk-FX7EJ6RB.js";import"./chunk-SOLTIZAI.js";import"./chunk-NF5H2Q7V.js";import"./chunk-SJNNEEDX.js";import"./chunk-LSB7RVRZ.js";import"./chunk-RVWHBZAF.js";import"./chunk-WHNUPECA.js";import{A as C,C as M,F as q,H as m,O as p,c as E,d as T,h as A,l as I,m as o,n as d,p as h,t as L,w,y as x}from"./chunk-A6BZFYZY.js";import{D as y,F as S,b as n,x as u}from"./chunk-PZERNTCD.js";var N=T({predictiveSearch:E({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=10,F=2,O="/search",k=new WeakSet,v=0,H=a=>a.tagName==="A"?a:a.querySelector("a");function f(a,t){h(a,o("search-bind")).forEach(e=>{let i=d(e,"search-bind");i==="image"?w(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&q(e,t[i])})}function $(a,t){let e=H(a);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var g=class{constructor(t,e,i){n(this,"root");n(this,"input");n(this,"results");n(this,"limit");n(this,"minCharacters");n(this,"resultsId");n(this,"searchNumber",0);n(this,"timer");n(this,"lastTerm","");n(this,"cache",new Map);this.root=t,this.input=e,this.results=i,this.limit=p(t,"search-limit",{min:1,max:V,fallback:D}),this.minCharacters=p(t,"search-min",{min:1,fallback:F}),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(I("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 A(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){y("a superseded search failed",i);return}this.setState("error"),S(i,"search")}}fillList(t,e,i){h(this.results,o(t)).forEach(l=>{x(l,e,i),m(l,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||O,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(s=>s.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(s,r)=>{let P=M(r.priceRange.minVariantPrice);f(s,{title:r.title,price:P,image:r.featuredImage}),$(s,C(r.handle,r.id)),s.classList.toggle("is-sold-out",!r.availableForSale)}),this.fillList("search-collections",l,(s,r)=>{f(s,{title:r.title,image:r.image}),$(s,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${r.handle}`)}),this.fillList("search-queries",c,(s,r)=>{f(s,{text:r.text}),H(s)?.setAttribute("href",this.queryUrl(r.text))});let b=i.length+l.length+c.length;this.showCount(b),this.setState(b?"ready":"empty"),this.open(!0),L("search",{term:e,products:i,collections:l,queries:c},this.root)}showCount(t){h(this.root,o("show")).forEach(e=>{let i=d(e,"show");i==="search-empty"&&m(e,t===0),i==="search-results"&&m(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 B(a=document){for(let t of R(a,o("search"))){if(k.has(t))continue;k.add(t);let e=t.querySelector(o("search-input"))??t.querySelector("input"),i=t.querySelector(o("search-results"));e&&i&&new g(t,e,i)}}export{B as mountSearch};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as st,b as at,c as ct}from"./chunks/chunk-MJNPD6LB.js";import{b as C,d as w,e as T,f as p,g as et,h as nt,i as ot,j as k,k as S}from"./chunks/chunk-HROQXZYN.js";import{a as lt,b as dt}from"./chunks/chunk-SOFWDTR7.js";import{a as rt,b as it,c as h}from"./chunks/chunk-3UCVDDK6.js";import"./chunks/chunk-2A2GN3Z7.js";import{a as tt}from"./chunks/chunk-F2BYVA7V.js";import{a as z,e as X,h as s}from"./chunks/chunk-P6DV24RG.js";import"./chunks/chunk-XU27NSXT.js";import{l as Q}from"./chunks/chunk-S5BUUIB6.js";import{a as u,b as ut}from"./chunks/chunk-YJC3CSEG.js";import{b as Z}from"./chunks/chunk-2IGCUTG5.js";import{a as K,b as W,c as Y,e as J}from"./chunks/chunk-EUCFOBIT.js";import"./chunks/chunk-ZBV2JSHE.js";import{C as q,J as P,M as f,a as v,f as G,j as U,l as d,m as r,r as B,s as g,t as y,u as j}from"./chunks/chunk-P73VN3B6.js";import{e as $,r as c,s as V,v as F,w as E,x as L,y as _,z as a}from"./chunks/chunk-D3MRWOFI.js";var x="0.9.1";var Mt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],It=()=>[...Mt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Nt(){return!!X(st())}function mt(t){!c.account||!(p(t,It()).length>0||ct(new URLSearchParams(window.location.search).get("account"))||Nt())||u("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function l(t){return(...e)=>u("account").then(n=>{let o=n[t];return o(...e)})}var ft={login:l("login"),logout:l("logout"),isLoggedIn:l("isLoggedIn"),customer:l("customer"),orders:l("orders"),order:l("order"),updateProfile:l("updateProfile"),addresses:l("addresses"),saveAddress:l("saveAddress"),deleteAddress:l("deleteAddress"),subscriptions:l("subscriptions"),subscriptionAction:l("subscriptionAction"),requestReturn:l("requestReturn"),render:l("render"),mountAccount:l("mountAccount")};var pt=()=>`data-${c.prefix}-key`,yt=t=>t instanceof window.Element;function ht(t){let e=t.closest(`[${pt()}]`),n=e?.getAttribute(pt());return e&&n?{line:e,id:n}:null}function A(t,e){t.catch(n=>{a(n,e)})}function Ot(t,e){let n=ht(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 H=Dt(e);!H||!s.lines.some(xt=>xt.id===i)||(t.preventDefault(),A(s.changeQuantity(i,H),"cart line"))}function Dt(t){return t.closest(r("line-plus"))?1:t.closest(r("line-minus"))?-1:0}function Rt(t){let{target:e}=t;if(!yt(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}Ot(t,e)}function gt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),A(e,n)}function Ht(t){let{target:e}=t;if(!yt(e))return;let n=ht(e);n&&e instanceof window.HTMLInputElement&&e.matches(r("line","quantity"))?gt(n.line,s.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(r("line-plan"))?gt(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):$t(e)&&e.matches(r("cart-note"))&&A(s.setNote(e.value),"cart note")}var $t=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function Vt(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}z(t)}}function Et(){document.addEventListener("click",Rt),document.addEventListener("change",Ht),document.addEventListener("keydown",Vt)}var M=t=>t instanceof window.Element;function Ft(t){let e=t.querySelector(r("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function vt(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function _t(t,e,n){try{await s.applyDiscount(n),vt(t,e,!1),y("discount-applied",{code:n},t),e&&(e.value="")}catch(o){vt(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?y("discount-invalid",{code:n},t):a(o,"discount")}}function Gt(t){let{target:e}=t,n=M(e)?e.closest(r("discount-form")):null;if(!n)return;t.preventDefault();let o=Ft(n),i=o?.value.trim();i&&f(n,()=>_t(n,o,i))}function Ut(t){let{target:e}=t;if(!M(e))return;let n=e.closest(r("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Bt(t){let{target:e}=t,n=M(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 Pt(){document.addEventListener("submit",Gt,!0),document.addEventListener("input",Ut),document.addEventListener("click",Bt)}var I=t=>u("extras").then(e=>e.addGroup(t)),N=t=>{a(t,"extras")};function jt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(r("group-add")):null;n&&(t.preventDefault(),f(n,()=>I(n)).catch(N))}function qt(t){!c.domain||!t.key?.startsWith(`${c.prefix}:`)||u("extras").then(e=>{e.onStorage(t)}).catch(N)}function Qt(t){if(!g(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!c.variantUrl&&!e.hasAttribute(d("variant-url"))||u("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(N))}function wt(){document.addEventListener("click",jt),window.addEventListener("storage",qt),document.addEventListener(`${c.prefix}:variant-changed`,Qt)}var O=null;function At(){O=document.body}async function zt(t){await t.ready();let e=it();if(!e){O!==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 Kt(t){document.addEventListener("astro:page-load",()=>{zt(t).catch(e=>{a(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{O=null,t.unmount()})}function Wt(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 Yt(){nt(),w.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function bt(t){c.astro&&Kt(t),document.addEventListener("change",Wt),window.addEventListener("online",Yt)}var Jt=50;function Xt(){let t=P("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var m=null,D=null,Ct=null,Lt=!1;function Zt(t){let e=0;return p(t,lt()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=dt(n);w.add(o),n.addEventListener(`${c.prefix}:list-rendered`,i=>{g(i,"list-rendered")&&b(i.detail.container)}),ot(o.load())}),e}function te(t){p(t,`${r("country-select")},${r("country-bind")}`).length&&u("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),mt(t),p(t,r("search")).length&&u("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function Tt(t){let e=Zt(t);return p(t,r("product")).forEach(n=>{et(n)&&e++}),te(t),e}function b(t=document){if(!E())return 0;t===document&&At(),T(),S(t.ownerDocument??document);let e=Tt(t);return k(),s.render(),L(`mounted ${e} scope(s)`,t),e}function ee(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+Tt(i),0);k(),s.render(),L(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function kt(){s.close()}function ne(t){let e=t?.closest(r("product"));return e?tt.get(e)??null:null}function oe(){Lt||(Lt=!0,Et(),Pt(),wt(),bt({ready:()=>m??Promise.resolve(null),mount:b,unmount:kt}))}function re(){let t=[];Ct=t,B.forEach(e=>{document.addEventListener(`${c.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",e=>t.push(e)),u("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ie(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 St(t={}){return m&&!Object.keys(t).length?m:(F({...Xt(),...t}),E()?(at(),oe(),c.observe&&se(),c.analytics&&!Ct&&re(),m=rt(t).then(()=>s.init()).then(ie).then(e=>(y("ready",{cart:e}),R)),m):(_("TETHER_CONFIG is missing domain or token. Tether is idle."),m=Promise.resolve(null),m))}function se(){if(D||typeof MutationObserver>"u")return;let t,e=new Set;D=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(),ee(o)},Jt)}),D.observe(document.body,{childList:!0,subtree:!0})}var ae=t=>u("markets").then(e=>e.detectMarket(t??c.markets)),ce=t=>u("lists").then(e=>e.getProducts(t)),ue=(t,e)=>u("lists").then(n=>n.getRecommendations(t,e)),le=()=>u("markets").then(t=>t.getLocalization()),de=t=>u("diagnose").then(e=>e.diagnose({...t,version:x}));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:x,init:St,mount:b,unmount:kt,get config(){return V},get ready(){return m??Promise.resolve(null)},query:U,withContext:G,cart:s,getProduct:Y,getProducts:ce,getRecommendations:ue,getScope:ne,addGroup:I,account:ft,primeProduct:W,normalizeProductKey:K,clearProductCache:J,formatMoney:q,imageUrl:j,plans:Q,TetherError:v,resolveProductKey:Z,setCountry:h,detectMarket:ae,getLocalization:le,diagnose:de,on:me},pe={__core:ut,__parts:{}},R=Object.assign(fe,pe),cn=R;function ge(){Reflect.set(window,"Tether",R);let t=P("TETHER_CONFIG");if(!t||$(t,"autoMount")===!1||P("TETHER_INTEGRATION"))return;let e=()=>{St().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{x as VERSION,I as addGroup,R as api,cn as default,ne as getScope,St as init,b as mount,h as setCountry,kt as unmount};
|
|
1
|
+
import{a as st,b as at,c as ct}from"./chunks/chunk-74SGIWQE.js";import{b as C,d as w,e as T,f as p,g as et,h as nt,i as ot,j as k,k as S}from"./chunks/chunk-EYG7QGPA.js";import{a as lt,b as dt}from"./chunks/chunk-24KD36UC.js";import{a as rt,b as it,c as h}from"./chunks/chunk-A3GZFAB3.js";import"./chunks/chunk-ZB4FBE6W.js";import{a as tt}from"./chunks/chunk-2G6U6ZYV.js";import{a as z,e as X,h as s}from"./chunks/chunk-FX7EJ6RB.js";import"./chunks/chunk-SOLTIZAI.js";import{l as Q}from"./chunks/chunk-NF5H2Q7V.js";import{a as u,b as ut}from"./chunks/chunk-SJNNEEDX.js";import{b as Z}from"./chunks/chunk-LSB7RVRZ.js";import{a as K,b as W,c as Y,e as J}from"./chunks/chunk-RVWHBZAF.js";import"./chunks/chunk-WHNUPECA.js";import{C as q,J as P,M as f,a as v,f as G,j as U,l as d,m as r,r as B,s as g,t as y,u as j}from"./chunks/chunk-A6BZFYZY.js";import{B as F,C as E,D as L,E as _,F as a,e as $,x as c,y as V}from"./chunks/chunk-PZERNTCD.js";var x="0.9.3";var Mt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],It=()=>[...Mt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Nt(){return!!X(st())}function mt(t){!c.account||!(p(t,It()).length>0||ct(new URLSearchParams(window.location.search).get("account"))||Nt())||u("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function l(t){return(...e)=>u("account").then(n=>{let o=n[t];return o(...e)})}var ft={login:l("login"),logout:l("logout"),isLoggedIn:l("isLoggedIn"),customer:l("customer"),orders:l("orders"),order:l("order"),updateProfile:l("updateProfile"),addresses:l("addresses"),saveAddress:l("saveAddress"),deleteAddress:l("deleteAddress"),subscriptions:l("subscriptions"),subscriptionAction:l("subscriptionAction"),requestReturn:l("requestReturn"),render:l("render"),mountAccount:l("mountAccount")};var pt=()=>`data-${c.prefix}-key`,yt=t=>t instanceof window.Element;function ht(t){let e=t.closest(`[${pt()}]`),n=e?.getAttribute(pt());return e&&n?{line:e,id:n}:null}function A(t,e){t.catch(n=>{a(n,e)})}function Ot(t,e){let n=ht(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 H=Dt(e);!H||!s.lines.some(xt=>xt.id===i)||(t.preventDefault(),A(s.changeQuantity(i,H),"cart line"))}function Dt(t){return t.closest(r("line-plus"))?1:t.closest(r("line-minus"))?-1:0}function Rt(t){let{target:e}=t;if(!yt(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}Ot(t,e)}function gt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),A(e,n)}function Ht(t){let{target:e}=t;if(!yt(e))return;let n=ht(e);n&&e instanceof window.HTMLInputElement&&e.matches(r("line","quantity"))?gt(n.line,s.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(r("line-plan"))?gt(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):$t(e)&&e.matches(r("cart-note"))&&A(s.setNote(e.value),"cart note")}var $t=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function Vt(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}z(t)}}function Et(){document.addEventListener("click",Rt),document.addEventListener("change",Ht),document.addEventListener("keydown",Vt)}var M=t=>t instanceof window.Element;function Ft(t){let e=t.querySelector(r("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function vt(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function _t(t,e,n){try{await s.applyDiscount(n),vt(t,e,!1),y("discount-applied",{code:n},t),e&&(e.value="")}catch(o){vt(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?y("discount-invalid",{code:n},t):a(o,"discount")}}function Gt(t){let{target:e}=t,n=M(e)?e.closest(r("discount-form")):null;if(!n)return;t.preventDefault();let o=Ft(n),i=o?.value.trim();i&&f(n,()=>_t(n,o,i))}function Ut(t){let{target:e}=t;if(!M(e))return;let n=e.closest(r("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Bt(t){let{target:e}=t,n=M(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 Pt(){document.addEventListener("submit",Gt,!0),document.addEventListener("input",Ut),document.addEventListener("click",Bt)}var I=t=>u("extras").then(e=>e.addGroup(t)),N=t=>{a(t,"extras")};function jt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(r("group-add")):null;n&&(t.preventDefault(),f(n,()=>I(n)).catch(N))}function qt(t){!c.domain||!t.key?.startsWith(`${c.prefix}:`)||u("extras").then(e=>{e.onStorage(t)}).catch(N)}function Qt(t){if(!g(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!c.variantUrl&&!e.hasAttribute(d("variant-url"))||u("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(N))}function wt(){document.addEventListener("click",jt),window.addEventListener("storage",qt),document.addEventListener(`${c.prefix}:variant-changed`,Qt)}var O=null;function At(){O=document.body}async function zt(t){await t.ready();let e=it();if(!e){O!==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 Kt(t){document.addEventListener("astro:page-load",()=>{zt(t).catch(e=>{a(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{O=null,t.unmount()})}function Wt(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 Yt(){nt(),w.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function bt(t){c.astro&&Kt(t),document.addEventListener("change",Wt),window.addEventListener("online",Yt)}var Jt=50;function Xt(){let t=P("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var m=null,D=null,Ct=null,Lt=!1;function Zt(t){let e=0;return p(t,lt()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=dt(n);w.add(o),n.addEventListener(`${c.prefix}:list-rendered`,i=>{g(i,"list-rendered")&&b(i.detail.container)}),ot(o.load())}),e}function te(t){p(t,`${r("country-select")},${r("country-bind")}`).length&&u("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),mt(t),p(t,r("search")).length&&u("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function Tt(t){let e=Zt(t);return p(t,r("product")).forEach(n=>{et(n)&&e++}),te(t),e}function b(t=document){if(!E())return 0;t===document&&At(),T(),S(t.ownerDocument??document);let e=Tt(t);return k(),s.render(),L(`mounted ${e} scope(s)`,t),e}function ee(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+Tt(i),0);k(),s.render(),L(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function kt(){s.close()}function ne(t){let e=t?.closest(r("product"));return e?tt.get(e)??null:null}function oe(){Lt||(Lt=!0,Et(),Pt(),wt(),bt({ready:()=>m??Promise.resolve(null),mount:b,unmount:kt}))}function re(){let t=[];Ct=t,B.forEach(e=>{document.addEventListener(`${c.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",e=>t.push(e)),u("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ie(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 St(t={}){return m&&!Object.keys(t).length?m:(F({...Xt(),...t}),E()?(at(),oe(),c.observe&&se(),c.analytics&&!Ct&&re(),m=rt(t).then(()=>s.init()).then(ie).then(e=>(y("ready",{cart:e}),R)),m):(_("TETHER_CONFIG is missing domain or token. Tether is idle."),m=Promise.resolve(null),m))}function se(){if(D||typeof MutationObserver>"u")return;let t,e=new Set;D=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(),ee(o)},Jt)}),D.observe(document.body,{childList:!0,subtree:!0})}var ae=t=>u("markets").then(e=>e.detectMarket(t??c.markets)),ce=t=>u("lists").then(e=>e.getProducts(t)),ue=(t,e)=>u("lists").then(n=>n.getRecommendations(t,e)),le=()=>u("markets").then(t=>t.getLocalization()),de=t=>u("diagnose").then(e=>e.diagnose({...t,version:x}));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:x,init:St,mount:b,unmount:kt,get config(){return V},get ready(){return m??Promise.resolve(null)},query:U,withContext:G,cart:s,getProduct:Y,getProducts:ce,getRecommendations:ue,getScope:ne,addGroup:I,account:ft,primeProduct:W,normalizeProductKey:K,clearProductCache:J,formatMoney:q,imageUrl:j,plans:Q,TetherError:v,resolveProductKey:Z,setCountry:h,detectMarket:ae,getLocalization:le,diagnose:de,on:me},pe={__core:ut,__parts:{}},R=Object.assign(fe,pe),cn=R;function ge(){Reflect.set(window,"Tether",R);let t=P("TETHER_CONFIG");if(!t||$(t,"autoMount")===!1||P("TETHER_INTEGRATION"))return;let e=()=>{St().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{x as VERSION,I as addGroup,R as api,cn as default,ne as getScope,St as init,b as mount,h as setCountry,kt as unmount};
|
package/dist/esm/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as
|
|
2
|
-
${
|
|
1
|
+
import{b as Q,f as G,g as H}from"./chunks/chunk-SOLTIZAI.js";import{e as O,f as v,g as w,i as F,l as q}from"./chunks/chunk-NF5H2Q7V.js";import{a as M,c as T,e as V,g as J,h as B,i as K,j}from"./chunks/chunk-WHNUPECA.js";import{B as D,a as y,c as k,d as I,f as ot,g as E,i as _,u as L}from"./chunks/chunk-A6BZFYZY.js";import{E as U,q as $,t as x,u as S,v as C,w as g,z as A}from"./chunks/chunk-PZERNTCD.js";function z(t,e={}){if(!t)return null;let{variant:r,sellingPlan:a,defaultPurchase:c=g.defaultPurchase,lowStock:u=g.lowStock}=e,d=G(t,{variant:r,sellingPlan:a,defaultPurchase:c}),n=H(t,{...d,quantity:1},u);if(!n)throw new y(`Product ${t.handle} has no variants`);let{selected:l,line:p}=n,i=(o,s)=>!Q(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:w(n.variant,o.id),savings:F(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 it=500,at=100,st=100,lt="query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}",ct="query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}",ut=()=>`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}}}}`,dt="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}}}",ft=()=>`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${T()}}pageInfo{hasNextPage endCursor}}}`,pt=t=>`query TetherServerRecs(${t?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${t?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`,mt=I({product:k(V)}),gt=I({node:k(J)}),yt=I({collections:{nodes:[{handle:"string"}],pageInfo:{hasNextPage:"boolean"}}});async function Pt(t){let e=[],r=null;for(let a=0;a<st;a++){let c=await E(t,ft(),{first:at,after:r},yt);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)=>E(t,f=>`${i}
|
|
2
|
+
${M(t,f)}`,o,s);async function a(i){let o=C(i);if(!o)return null;if(o.startsWith("gid://")){let{node:f}=await r(lt,{id:o},gt);return f?.id?f:null}return(await r(ct,{handle:o},mt)).product}async function c(i,{first:o=e,after:s=null,sortKey:f,reverse:m=!1,filters:b}){let h=await r(ut(),{handle:i,first:o,after:s,sortKey:f||void 0,reverse:m,filters:b??void 0},B);if(!h.collection)return{collection:null,products:[],pageInfo:{hasNextPage:!1,endCursor:null}};let{products:P,...rt}=h.collection;return{collection:rt,products:P.nodes,pageInfo:P.pageInfo}}async function u(i={}){let{collection:o,query:s,first:f=e,after:m=null,sortKey:b,reverse:h=!1}=i;if(o)return c(o,i);let P=await r(dt,{first:f,after:m,query:s||void 0,sortKey:b||void 0,reverse:h},K);return{collection:null,products:P.products.nodes,pageInfo:P.products.pageInfo}}async function d(i={}){let o=[],s=null;for(let f=0;f<it;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=C(typeof i=="object"?i?.id:i);if(!s)throw new y("No product for recommendations",{code:"NOT_FOUND"});let f=s.startsWith("gid://");return(await r(pt(f),f?{id:s,intent:o}:{handle:s,intent:o},j)).productRecommendations??[]}return{getProduct:a,getProducts:u,allProducts:d,getCollection:n,allCollections:()=>Pt(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 ht(t){return t.availableForSale?t.currentlyNotInStock?"https://schema.org/BackOrder":"https://schema.org/InStock":"https://schema.org/OutOfStock"}function St(t,e){if(!t.requiresSellingPlan)return e.price;let r=O(t).find(a=>v(e,a.id));return(r&&w(e,r.id))??e.price}function tt(t,e,r){let a=St(t,e),c=r?.includes("?")?"&":"?";return{"@type":"Offer",price:a.amount,priceCurrency:a.currencyCode,availability:ht(e),url:r?`${r}${c}variant=${Z(e.id)}`:void 0}}function Ct(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 It(t,{url:e},r){if(e)return e;let a=S(r.productPath,t.handle,t.id);if(!(!r.siteUrl||!a))return new URL(a,r.siteUrl).toString()}function N(t,e,r){if(!t)return null;let a=It(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=>Ct(t,i,a,c))})}var et=25,vt=2,wt=1;function bt(t,{productPath:e=g.productPath,id:r}={}){return S(e,t,r)}function nt(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))Object.hasOwn(g,u)&&(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||nt(t,$.domain),token:a||nt(t,$.token)}),pageSize:kt(t.pageSize)};return t.fetch&&(c.fetch=t.fetch),t.siteUrl!==void 0&&(c.siteUrl=t.siteUrl),c}function kt(t){return typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=250?t:(t!==void 0&&U(`invalid pageSize ${JSON.stringify(t)}: using ${String(et)}`),et)}function Et(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 zt(t={}){let e=$t(t);if(!e.domain||!e.token)throw new y("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,e.pageSize),a={productPath:e.productPath,siteUrl:e.siteUrl};function c(n,{card:l=!1,images:p=vt}={}){let i=(Array.isArray(n)?n:[n]).filter(s=>s!=null),o={v:wt,at:new Date().toISOString(),country:e.country||null,language:e.language||null,products:l?i.map(s=>Et(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(N(n,l,a))}<\/script>`:""}function d(n,l={}){return z(n,{defaultPurchase:e.defaultPurchase,lowStock:e.lowStock,...l})}return{config:e,query:(n,l,p)=>_(e,n,l,p),...r,hydrate:c,formatMoney:(n,l=e.locale)=>x(n,l),formatPercent:(n,l=e.locale)=>D(n,l),imageUrl:L,jsonLd:u,jsonLdData:(n,l={})=>N(n,l,a),initialState:d,productUrl:(n,l={})=>bt(n,{productPath:e.productPath,...l}),plans:q}}export{y as TetherError,zt as createStorefront,x as formatMoney,D as formatPercent,L as imageUrl,z as initialState,q as plans,C as productKey,bt as productUrl,ot as withContext};
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
// tether-core:dom.ts
|
|
29
29
|
var m2 = window.Tether.__core["dom.ts"];
|
|
30
|
-
var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m2;
|
|
30
|
+
var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, integerAttribute, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m2;
|
|
31
31
|
|
|
32
32
|
// tether-core:client.ts
|
|
33
33
|
var m3 = window.Tether.__core["client.ts"];
|
|
@@ -318,7 +318,7 @@
|
|
|
318
318
|
|
|
319
319
|
// tether-core:shopify-values.ts
|
|
320
320
|
var m4 = window.Tether.__core["shopify-values.ts"];
|
|
321
|
-
var [isHttpsUrl] = m4;
|
|
321
|
+
var [isHttpsUrl, MAX_CONNECTION_SIZE] = m4;
|
|
322
322
|
|
|
323
323
|
// src/account/markup.ts
|
|
324
324
|
function showIn(root, name, conditions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var De=Object.defineProperty;var Me=(e,t)=>{for(var n in t)De(e,n,{get:t[n],enumerable:!0})};var oe={};Me(oe,{addresses:()=>G,deleteAddress:()=>V,order:()=>j,renderPages:()=>bt,requestReturn:()=>K,saveAddress:()=>H,setup:()=>Te,showUnavailable:()=>wt,subscriptionAction:()=>J,subscriptions:()=>Z,updateProfile:()=>z});var qe=window.Tether.__core["config.ts"],[Tt,Ot,Et,St,Lt,T,Pt]=qe;var ve=window.Tether.__core["dom.ts"],[It,h,Rt,Ct,ue,P,b,p,Nt,Dt,Mt,qt,vt,Ht,l,A,Ft,u,_,Ut,y,B]=ve;var He=window.Tether.__core["client.ts"],[Bt,$t,jt,zt,Gt,C]=He;var de={order:{name:"order",method:"GET",path:"/order",fields:{id:!0}},addresses:{name:"addresses",method:"GET",path:"/addresses",fields:{}},subscriptions:{name:"subscriptions",method:"GET",path:"/subscriptions",fields:{}},profile:{name:"profile",method:"POST",path:"/profile",fields:{firstName:!0,lastName:!0}},saveAddress:{name:"saveAddress",method:"POST",path:"/address",fields:{id:!0,address:!0,isDefault:!0}},deleteAddress:{name:"deleteAddress",method:"POST",path:"/address/delete",fields:{id:!0}},subscription:{name:"subscription",method:"POST",path:"/subscription",fields:{id:!0,action:!0}},requestReturn:{name:"requestReturn",method:"POST",path:"/return",fields:{orderId:!0,lines:!0}}},Zt=new Map(Object.values(de).map(e=>[`${e.method} ${e.path}`,{...e,fields:Object.keys(e.fields)}]));function le(e,t){let n=de[e];if(n.method==="POST")return{method:"POST",path:n.path};let r=t,s=new URLSearchParams;for(let d of Object.keys(n.fields)){let c=r[d];(typeof c=="string"||typeof c=="number")&&s.set(d,String(c))}let o=s.toString();return{method:"GET",path:o?`${n.path}?${o}`:n.path}}function g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function i(e,t){return g(e)?e[t]:void 0}function ce(e){return Array.isArray(e)?e:[]}function a(e){return typeof e=="string"&&e!==""?e:null}var $=e=>typeof e=="number"&&Number.isFinite(e)?e:null,N=e=>$(e)??0,k=(e,t)=>ce(e).map(n=>t(n)),x=(e,t)=>({nodes:k(i(e,"nodes"),t)}),W=e=>k(e,a).filter(t=>t!==null);function I(e){let t=a(i(e,"amount")),n=a(i(e,"currencyCode"));return t===null||n===null?null:{amount:t,currencyCode:n}}function X(e){let t=a(i(e,"url"));return t===null?null:{url:t,altText:a(i(e,"altText"))}}var me=e=>({title:a(i(e,"title")),variantTitle:a(i(e,"variantTitle")),quantity:N(i(e,"quantity")),image:X(i(e,"image"))});var ee=e=>new C(`Customer accounts: the answer has no ${e}`);function O(e,t){let n=a(e);if(!n)throw ee(t);return n}function fe(e){let t=n=>a(i(e,n));return{id:t("id"),firstName:t("firstName"),lastName:t("lastName"),company:t("company"),address1:t("address1"),address2:t("address2"),city:t("city"),province:t("province"),zoneCode:t("zoneCode"),zip:t("zip"),country:t("country"),countryCode:t("countryCode"),phoneNumber:t("phoneNumber"),formatted:W(i(e,"formatted"))}}var pe=e=>g(e)?fe(e):null,te=e=>({...fe(e),id:O(i(e,"id"),"address id")}),ge=e=>k(e,t=>({...te(t),isDefault:i(t,"isDefault")===!0})),Fe=e=>({...me(e),id:O(i(e,"id"),"line item id"),name:a(i(e,"name")),sku:a(i(e,"sku")),price:I(i(e,"price")),totalPrice:I(i(e,"totalPrice")),suggestedReturnReasonDefinitions:x(i(e,"suggestedReturnReasonDefinitions"),t=>({id:O(i(t,"id"),"return reason id"),name:a(i(t,"name")),handle:a(i(t,"handle"))}))}),Ue=e=>({id:a(i(e,"id")),status:a(i(e,"status")),createdAt:a(i(e,"createdAt")),estimatedDeliveryAt:a(i(e,"estimatedDeliveryAt")),latestShipmentStatus:a(i(e,"latestShipmentStatus")),trackingInformation:k(i(e,"trackingInformation"),t=>({company:a(i(t,"company")),number:a(i(t,"number")),url:a(i(t,"url"))}))});function _e(e){let t=a(i(i(e,"lineItem"),"id"));return{quantity:N(i(e,"quantity")),lineItem:t===null?null:{id:t}}}function Be(e){return g(e)?{returnableLineItems:x(e.returnableLineItems,_e)}:null}function ye(e){if(!g(e))return null;let t=s=>a(e[s]),n=s=>I(e[s]),r=e.requiresShipping;return{id:O(e.id,"order id"),name:t("name"),number:$(e.number),processedAt:t("processedAt"),cancelledAt:t("cancelledAt"),financialStatus:t("financialStatus"),fulfillmentStatus:t("fulfillmentStatus"),statusPageUrl:t("statusPageUrl"),requiresShipping:typeof r=="boolean"?r:null,totalPrice:n("totalPrice"),subtotal:n("subtotal"),totalShipping:n("totalShipping"),totalTax:n("totalTax"),shippingAddress:pe(e.shippingAddress),billingAddress:pe(e.billingAddress),lineItems:x(e.lineItems,Fe),fulfillments:x(e.fulfillments,Ue),returnInformation:Be(e.returnInformation),returns:x(e.returns,ne)}}var $e=e=>({id:a(i(e,"id")),name:a(i(e,"name")),title:a(i(e,"title")),variantTitle:a(i(e,"variantTitle")),quantity:N(i(e,"quantity")),sku:a(i(e,"sku")),currentPrice:I(i(e,"currentPrice")),lineDiscountedPrice:I(i(e,"lineDiscountedPrice")),image:X(i(e,"image"))}),he=e=>({cycleIndex:$(i(e,"cycleIndex")),skipped:i(e,"skipped")===!0,billingAttemptExpectedDate:a(i(e,"billingAttemptExpectedDate"))});function je(e){if(!g(e))return null;let t=e.intervalCount;return{interval:a(e.interval),intervalCount:g(t)?{count:N(t.count)}:null}}var ze=e=>({id:O(i(e,"id"),"subscription id"),status:a(i(e,"status")),nextBillingDate:a(i(e,"nextBillingDate")),currencyCode:a(i(e,"currencyCode")),deliveryPrice:I(i(e,"deliveryPrice")),deliveryPolicy:je(i(e,"deliveryPolicy")),lines:x(i(e,"lines"),$e),upcomingBillingCycles:x(i(e,"upcomingBillingCycles"),he)}),be=e=>k(e,ze);function we(e){let{contract:t,billingCycle:n}=e;if(g(t))return{contract:{id:a(t.id),status:a(t.status)}};if(g(n)){let{cycleIndex:r,skipped:s}=he(n);return{billingCycle:{cycleIndex:r,skipped:s}}}throw ee("changed subscription")}function ne(e){return{id:O(i(e,"id"),"return id"),status:a(i(e,"status"))}}var Ae=e=>O(e,"deleted address id"),xe=e=>({firstName:a(i(e,"firstName")),lastName:a(i(e,"lastName"))});var re=null;function Te(e){re=e}function D(){if(!re)throw new Error("account-pages: loaded without the account part");return re}async function E(e,t){let{serverFetch:n}=D(),{method:r,path:s}=le(e,t),o=await n(s,r==="POST"?{method:r,body:t}:{});if(o.kind==="logged-out")throw new C("Not logged in",{code:"NOT_LOGGED_IN",status:401});return o.data}function v(e){D().reset(),ue("account-updated",{what:e})}async function j(e){let t=await E("order",{id:e});return ye(t.order)}async function z({firstName:e,lastName:t}={}){let n=await E("profile",{firstName:e,lastName:t});return v("profile"),xe(n.customer)}async function G(){let e=await E("addresses",{});return ge(e.addresses)}async function H(e,{id:t,isDefault:n}={}){let r=await E("saveAddress",{id:t,address:e,isDefault:n});return v("addresses"),te(r.address)}async function V(e){let t=await E("deleteAddress",{id:e});return v("addresses"),Ae(t.deleted)}async function Z(){let e=await E("subscriptions",{});return be(e.subscriptions)}async function J(e,t){let n=await E("subscription",{id:e,action:t});return v("subscriptions"),we(n)}async function K(e,t){let n=await E("requestReturn",{orderId:e,lines:t});return v("orders"),ne(n.return)}var Ge=window.Tether.__core["shopify-values.ts"],[se]=Ge;function m(e,t,n){l(e,u(t)).forEach(r=>{let s=p(r,t)??"";Object.hasOwn(n,s)&&B(r,n[s]===!0)})}var S=(e,t)=>l(e,u(t)).concat(e.matches(u(t))?[e]:[]),L=e=>e?e.toLowerCase().replace(/_/g," "):"",F=e=>(e?.formatted??[]).join(", "),w=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;var Ve=(e,t)=>({title:e.title||e.name||"","variant-title":e.variantTitle||"",quantity:String(e.quantity),price:b(e.price),total:b(e.totalPrice),sku:e.sku||"",returnable:t===null?void 0:String(t)}),Ze=e=>e.tagName==="INPUT";function Je(e,t,n){m(e,"order-line-show",{returnable:n>0}),l(e,u("return-quantity")).forEach(r=>{Ze(r)&&(r.max=String(n),r.min="0",r.value||(r.value="0"),r.disabled=n<1)}),l(e,`select${u("return-reason")}`).forEach(r=>{r.dataset.tetherFilled!==t.id&&(r.dataset.tetherFilled=t.id,(t.suggestedReturnReasonDefinitions?.nodes??[]).forEach(s=>{r.appendChild(new Option(s.name??"",s.id))}))})}function Oe(e,t,n){A(e,t,(r,s)=>{let o=s.id,d=n&&o?n.get(o)??0:null;o&&(r.dataset.tetherLine=o);let c=Ve(s,d);S(r,"order-line").forEach(f=>{let R=p(f,"order-line")??"";if(R==="image"){s.image&&_(f,s.image.url,s.image.altText||s.title||"");return}let ae=w(c,R);ae!==void 0&&y(f,ae)}),o&&d!==null&&Je(r,{...s,id:o},d)})}function Ke(e){let t=p(e,"order")||"";return t.startsWith("url:")?new URL(window.location.href).searchParams.get(t.slice(4)||"id"):t}function U(e,t){e.setAttribute(h("order-state"),t),m(e,"order-show",{loading:t==="loading",ready:!1,"not-found":t==="not-found",error:t==="error"})}var Ye=e=>({name:e.name??"",date:P(e.processedAt),total:b(e.totalPrice),subtotal:b(e.subtotal),shipping:b(e.totalShipping),tax:b(e.totalTax),status:L(e.financialStatus),fulfillment:L(e.fulfillmentStatus),"shipping-address":F(e.shippingAddress),"billing-address":F(e.billingAddress),items:e.lineItems.nodes.map(t=>`${String(t.quantity)}\xD7 ${t.title||t.name||""}`).join(", "),cancelled:P(e.cancelledAt)});function Qe(e,t){let n=t.trackingInformation[0],r={status:L(t.latestShipmentStatus||t.status),date:P(t.createdAt),eta:P(t.estimatedDeliveryAt),company:n?.company||"",number:n?.number||""};S(e,"fulfillment-bind").forEach(s=>{let o=p(s,"fulfillment-bind")??"";if(o==="url"){let c=n?.url??null,f=c!==null&&se(c);f&&s.setAttribute("href",c),B(s,f);return}let d=w(r,o);d!==void 0&&y(s,d)})}function We(e,t){let n=new Map((t.returnInformation?.returnableLineItems.nodes??[]).map(d=>[d.lineItem?.id??"",d.quantity])),r=t.fulfillments.nodes,s=Ye(t);l(e,u("order-bind")).forEach(d=>{let c=p(d,"order-bind")??"";if(c==="url"){let R=t.statusPageUrl;R!==null&&se(R)&&d.setAttribute("href",R);return}let f=w(s,c);f!==void 0&&y(d,f)}),l(e,u("order-lines")).forEach(d=>{Oe(d,t.lineItems.nodes,n)}),l(e,u("order-fulfillments")).forEach(d=>{A(d,r,Qe)});let o=e.dataset.tetherReturned==="1";m(e,"order-show",{loading:!1,ready:!0,error:!1,"not-found":!1,cancelled:!!t.cancelledAt,shipped:r.length>0,returnable:[...n.values()].some(d=>d>0),"has-returns":!o&&t.returns.nodes.length>0,"return-requested":o}),e.setAttribute(h("order-state"),"ready")}async function Y(e){let t=Ke(e);if(!t){e.setAttribute(h("order-state"),"not-found"),m(e,"order-show",{"not-found":!0});return}U(e,"loading");let n;try{n=await j(t)}catch(r){T(r,"order"),U(e,"error");return}if(!n){U(e,"not-found");return}e.dataset.tetherOrderId=n.id,We(e,n)}var Ee=[],Se=e=>Ee.find(t=>t.id===e),Xe=e=>({formatted:F(e),name:[e.firstName,e.lastName].filter(Boolean).join(" "),company:e.company||"",address1:e.address1||"",address2:e.address2||"",city:e.city||"",zip:e.zip||"",province:e.province||"",country:e.country||"",phone:e.phoneNumber||""});function et(e,t){e.dataset.tetherAddress=t.id;let n=Xe(t);S(e,"address-bind").forEach(r=>{let s=w(n,p(r,"address-bind")??"");s!==void 0&&y(r,s)}),m(e,"address-show",{default:t.isDefault,"not-default":!t.isDefault})}async function M(e){let t=l(e,u("addresses"));if(!t.length)return;m(e,"show",{"addresses-loading":!0,"addresses-empty":!1});let n;try{n=await G()}catch(r){T(r,"addresses"),m(e,"show",{"addresses-loading":!1,"addresses-error":!0});return}Ee=n,m(e,"show",{"addresses-loading":!1,"addresses-empty":n.length===0,"addresses-error":!1}),t.forEach(r=>{A(r,n,et)})}function tt(e){let t=e.upcomingBillingCycles.nodes[0],n=e.status,r=n==="ACTIVE";return{active:r,paused:n==="PAUSED",cancelled:n==="CANCELLED",expired:n==="EXPIRED",failed:n==="FAILED",skipped:!!t?.skipped,"can-pause":r,"can-resume":n==="PAUSED"||n==="FAILED","can-skip":r&&t!==void 0&&!t.skipped,"can-unskip":r&&!!t?.skipped,"can-cancel":r||n==="PAUSED"||n==="FAILED"}}function nt(e){let t=L(e.deliveryPolicy?.interval);if(!t)return"";let n=e.deliveryPolicy?.intervalCount?.count??1;return n<=1?t:`${String(n)} ${t}s`}function rt(e){let t=e.lines.nodes,n=t.reduce((r,s)=>r+Number.parseFloat(s.lineDiscountedPrice?.amount??"0"),0);return{status:L(e.status),next:P(e.nextBillingDate),interval:nt(e),products:t.map(r=>`${String(r.quantity)}\xD7 ${r.title??""}`).join(", "),total:b(t.length&&e.currencyCode?{amount:String(n),currencyCode:e.currencyCode}:null),delivery:b(e.deliveryPrice)}}function st(e,t){let n={title:t.title??"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:b(t.currentPrice)};S(e,"subscription-line").forEach(r=>{let s=p(r,"subscription-line")??"";if(s==="image"){t.image&&_(r,t.image.url,t.image.altText||t.title||"");return}let o=w(n,s);o!==void 0&&y(r,o)})}function it(e,t){e.dataset.tetherSubscription=t.id,e.setAttribute(h("subscription-status"),L(t.status));let n=rt(t);l(e,u("subscription-bind")).forEach(s=>{let o=w(n,p(s,"subscription-bind")??"");o!==void 0&&y(s,o)}),l(e,u("subscription-lines")).forEach(s=>{A(s,t.lines.nodes,st)});let r=tt(t);m(e,"subscription-show",r),l(e,u("subscription-action")).forEach(s=>{let o=w(r,`can-${p(s,"subscription-action")??""}`)===!0;"disabled"in s&&(s.disabled=!o),s.classList.toggle("is-disabled",!o)})}async function Q(e){let t=l(e,u("subscriptions"));if(!t.length)return;m(e,"show",{"subscriptions-loading":!0,"subscriptions-empty":!1});let n;try{n=await Z()}catch(r){T(r,"subscriptions"),m(e,"show",{"subscriptions-loading":!1,"subscriptions-error":!0});return}m(e,"show",{"subscriptions-loading":!1,"subscriptions-empty":n.length===0,"subscriptions-error":!1}),t.forEach(r=>{A(r,n,it)})}var ot=["pause","resume","skip","unskip","cancel"],at=e=>ot.some(t=>t===e),Pe=e=>e instanceof window.HTMLInputElement||e instanceof window.HTMLSelectElement||e instanceof window.HTMLTextAreaElement,ke=e=>e instanceof window.HTMLFormElement;function Le(e){let t={};for(let n of e.elements)Pe(n)&&(!n.name||n.type==="submit"||n.type==="button"||n.type==="checkbox"||(t[n.name]=n.value));return t}function ut(e){let n=(e instanceof C?e.userErrors??[]:[]).map(s=>s.message).join(" ");return n||(e instanceof Error&&e.message?e.message:"Something went wrong").replace(/^Customer accounts: /,"")}async function q(e,t){if(e.getAttribute("aria-busy")==="true")return"busy";e.classList.add("is-busy"),e.setAttribute("aria-busy","true"),e.setAttribute(h("form-state"),"pending");let n=l(e,u("form-error"));n.forEach(r=>{y(r,"")});try{return await t(),e.setAttribute(h("form-state"),"saved"),"saved"}catch(r){return e.setAttribute(h("form-state"),"error"),n.forEach(s=>{y(s,ut(r))}),"error"}finally{e.classList.remove("is-busy"),e.removeAttribute("aria-busy")}}var ie=e=>{let t=p(e,"confirm");return!t||window.confirm(t)},Ie=e=>{e.reset(),delete e.dataset.tetherAddressId};function dt(e){let t=e.target;if(t instanceof window.HTMLFormElement){if(t.matches(u("profile-form")))e.preventDefault(),q(t,async()=>{await z(Le(t)),await D().bindCustomer(document)});else if(t.matches(u("address-form"))){e.preventDefault();let n=t.dataset.tetherAddressId,r=t.elements.namedItem("isDefault"),s=r instanceof window.HTMLInputElement&&r.checked;q(t,async()=>{await H(Le(t),{id:n,isDefault:s}),Ie(t),await M(document)})}}}function lt(e){let t=Se(e),n=document.querySelector(u("address-form"));if(!t||!n||!ke(n))return;n.dataset.tetherAddressId=t.id;let r={...t};for(let s of n.elements)if(Pe(s)){if(s.name==="isDefault")s instanceof window.HTMLInputElement&&(s.checked=t.isDefault);else if(s.name&&Object.hasOwn(r,s.name)){let o=r[s.name];s.value=typeof o=="string"?o:""}}n.scrollIntoView({block:"nearest"})}function ct(e,t){let n=t.closest("[data-tether-address]"),r=n instanceof window.HTMLElement?n.dataset.tetherAddress:void 0;if(t.closest(u("address-new"))){let o=document.querySelector(u("address-form"));return o&&ke(o)&&Ie(o),!0}if(!(n instanceof window.HTMLElement)||!r)return!1;let s=t.closest(u("address-delete"));if(s){if(e.preventDefault(),!ie(s))return!0;q(n,async()=>{await V(r),await M(document)})}else if(t.closest(u("address-default")))e.preventDefault(),q(n,async()=>{await H(null,{id:r,isDefault:!0}),await M(document)});else if(t.closest(u("address-edit")))e.preventDefault(),lt(r);else return!1;return!0}function mt(e){let t=e.closest("[data-tether-subscription]"),n=p(e,"subscription-action"),r="disabled"in e&&e.disabled===!0||e.classList.contains("is-disabled");if(!(t instanceof window.HTMLElement)||!at(n)||r||!ie(e))return;let s=t.dataset.tetherSubscription??"";t.setAttribute(h("subscription-state"),"pending"),q(t,async()=>{await J(s,n),await Q(document)}).then(o=>{let d=o==="error"?"error":"done";l(document,"[data-tether-subscription]").filter(c=>c===t||c.dataset.tetherSubscription===s).forEach(c=>{c.setAttribute(h("subscription-state"),d)})})}function pt(e){let t=e.querySelector(u("return-quantity")),n=e.querySelector(u("return-reason")),r=e.querySelector(u("return-note")),s=f=>f&&"value"in f&&typeof f.value=="string"?f.value:"",o={lineItemId:e.dataset.tetherLine??"",quantity:Number.parseInt(s(t)||"0",10)},d=s(n);d&&(o.reasonId=d);let c=s(r);return c&&(o.note=c),o}function ft(e){let t=e.closest(u("order"));if(!(t instanceof window.HTMLElement))return;let n=t.dataset.tetherOrderId;if(!n)return;let r=l(t,"[data-tether-line]").map(pt).filter(s=>s.quantity>0);!r.length||!ie(e)||q(t,async()=>{await K(n,r),t.dataset.tetherReturned="1",await Y(t)})}function gt(e){let t=e.target;if(!(t instanceof window.Element)||ct(e,t))return;let n=t.closest(u("subscription-action"));if(n instanceof window.HTMLElement){e.preventDefault(),mt(n);return}let r=t.closest(u("order-return"));r instanceof window.HTMLElement&&(e.preventDefault(),ft(r))}function Re(){document.addEventListener("submit",dt,!0),document.addEventListener("input",e=>{let t=e.target;t instanceof window.HTMLElement&&t.closest(u("profile-form"))&&(t.dataset.tetherTouched="1")}),document.addEventListener("click",gt)}var yt=["firstName","lastName"];async function ht(e){if(!(e instanceof window.HTMLFormElement))return;let t;try{t=await D().customer()}catch(r){T(r,"account");return}if(!t)return;let n=e.elements;yt.forEach(r=>{let s=n.namedItem(r);(s instanceof window.HTMLInputElement||s instanceof window.HTMLTextAreaElement)&&!s.dataset.tetherTouched&&(s.value=t[r]??"")})}var Ce=!1;async function bt(e=document){Ce||(Ce=!0,Re()),await Promise.all([...l(e,u("order")).map(t=>Y(t)),...l(e,u("profile-form")).map(t=>ht(t)),M(e),Q(e)])}function wt(e){l(e,u("order")).forEach(t=>{U(t,"error")}),m(e,"show",{"addresses-loading":!1,"addresses-error":!0,"subscriptions-loading":!1,"subscriptions-error":!0})}function At(e){return g(e)&&g(e.__core)&&g(e.__parts)}function Ne(e,t){let n=Reflect.get(window,"Tether");if(!At(n))throw new Error(`tether.${e}.js runs after the Tether script, which loads it, and needs its window.Tether`);n.__parts[e]=t}Ne("account-pages",oe);})();
|
|
1
|
+
(()=>{var De=Object.defineProperty;var Me=(e,t)=>{for(var n in t)De(e,n,{get:t[n],enumerable:!0})};var oe={};Me(oe,{addresses:()=>G,deleteAddress:()=>V,order:()=>j,renderPages:()=>bt,requestReturn:()=>K,saveAddress:()=>H,setup:()=>Te,showUnavailable:()=>wt,subscriptionAction:()=>J,subscriptions:()=>Z,updateProfile:()=>z});var qe=window.Tether.__core["config.ts"],[Tt,Ot,Et,St,Lt,T,Pt]=qe;var ve=window.Tether.__core["dom.ts"],[It,h,Ct,Rt,ue,P,b,p,Nt,Dt,Mt,qt,vt,Ht,Ft,l,A,Ut,u,_,_t,y,B]=ve;var He=window.Tether.__core["client.ts"],[$t,jt,zt,Gt,Vt,R]=He;var de={order:{name:"order",method:"GET",path:"/order",fields:{id:!0}},addresses:{name:"addresses",method:"GET",path:"/addresses",fields:{}},subscriptions:{name:"subscriptions",method:"GET",path:"/subscriptions",fields:{}},profile:{name:"profile",method:"POST",path:"/profile",fields:{firstName:!0,lastName:!0}},saveAddress:{name:"saveAddress",method:"POST",path:"/address",fields:{id:!0,address:!0,isDefault:!0}},deleteAddress:{name:"deleteAddress",method:"POST",path:"/address/delete",fields:{id:!0}},subscription:{name:"subscription",method:"POST",path:"/subscription",fields:{id:!0,action:!0}},requestReturn:{name:"requestReturn",method:"POST",path:"/return",fields:{orderId:!0,lines:!0}}},Jt=new Map(Object.values(de).map(e=>[`${e.method} ${e.path}`,{...e,fields:Object.keys(e.fields)}]));function le(e,t){let n=de[e];if(n.method==="POST")return{method:"POST",path:n.path};let r=t,s=new URLSearchParams;for(let d of Object.keys(n.fields)){let c=r[d];(typeof c=="string"||typeof c=="number")&&s.set(d,String(c))}let o=s.toString();return{method:"GET",path:o?`${n.path}?${o}`:n.path}}function g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function i(e,t){return g(e)?e[t]:void 0}function ce(e){return Array.isArray(e)?e:[]}function a(e){return typeof e=="string"&&e!==""?e:null}var $=e=>typeof e=="number"&&Number.isFinite(e)?e:null,N=e=>$(e)??0,k=(e,t)=>ce(e).map(n=>t(n)),x=(e,t)=>({nodes:k(i(e,"nodes"),t)}),Q=e=>k(e,a).filter(t=>t!==null);function I(e){let t=a(i(e,"amount")),n=a(i(e,"currencyCode"));return t===null||n===null?null:{amount:t,currencyCode:n}}function W(e){let t=a(i(e,"url"));return t===null?null:{url:t,altText:a(i(e,"altText"))}}var me=e=>({title:a(i(e,"title")),variantTitle:a(i(e,"variantTitle")),quantity:N(i(e,"quantity")),image:W(i(e,"image"))});var ee=e=>new R(`Customer accounts: the answer has no ${e}`);function O(e,t){let n=a(e);if(!n)throw ee(t);return n}function fe(e){let t=n=>a(i(e,n));return{id:t("id"),firstName:t("firstName"),lastName:t("lastName"),company:t("company"),address1:t("address1"),address2:t("address2"),city:t("city"),province:t("province"),zoneCode:t("zoneCode"),zip:t("zip"),country:t("country"),countryCode:t("countryCode"),phoneNumber:t("phoneNumber"),formatted:Q(i(e,"formatted"))}}var pe=e=>g(e)?fe(e):null,te=e=>({...fe(e),id:O(i(e,"id"),"address id")}),ge=e=>k(e,t=>({...te(t),isDefault:i(t,"isDefault")===!0})),Fe=e=>({...me(e),id:O(i(e,"id"),"line item id"),name:a(i(e,"name")),sku:a(i(e,"sku")),price:I(i(e,"price")),totalPrice:I(i(e,"totalPrice")),suggestedReturnReasonDefinitions:x(i(e,"suggestedReturnReasonDefinitions"),t=>({id:O(i(t,"id"),"return reason id"),name:a(i(t,"name")),handle:a(i(t,"handle"))}))}),Ue=e=>({id:a(i(e,"id")),status:a(i(e,"status")),createdAt:a(i(e,"createdAt")),estimatedDeliveryAt:a(i(e,"estimatedDeliveryAt")),latestShipmentStatus:a(i(e,"latestShipmentStatus")),trackingInformation:k(i(e,"trackingInformation"),t=>({company:a(i(t,"company")),number:a(i(t,"number")),url:a(i(t,"url"))}))});function _e(e){let t=a(i(i(e,"lineItem"),"id"));return{quantity:N(i(e,"quantity")),lineItem:t===null?null:{id:t}}}function Be(e){return g(e)?{returnableLineItems:x(e.returnableLineItems,_e)}:null}function ye(e){if(!g(e))return null;let t=s=>a(e[s]),n=s=>I(e[s]),r=e.requiresShipping;return{id:O(e.id,"order id"),name:t("name"),number:$(e.number),processedAt:t("processedAt"),cancelledAt:t("cancelledAt"),financialStatus:t("financialStatus"),fulfillmentStatus:t("fulfillmentStatus"),statusPageUrl:t("statusPageUrl"),requiresShipping:typeof r=="boolean"?r:null,totalPrice:n("totalPrice"),subtotal:n("subtotal"),totalShipping:n("totalShipping"),totalTax:n("totalTax"),shippingAddress:pe(e.shippingAddress),billingAddress:pe(e.billingAddress),lineItems:x(e.lineItems,Fe),fulfillments:x(e.fulfillments,Ue),returnInformation:Be(e.returnInformation),returns:x(e.returns,ne)}}var $e=e=>({id:a(i(e,"id")),name:a(i(e,"name")),title:a(i(e,"title")),variantTitle:a(i(e,"variantTitle")),quantity:N(i(e,"quantity")),sku:a(i(e,"sku")),currentPrice:I(i(e,"currentPrice")),lineDiscountedPrice:I(i(e,"lineDiscountedPrice")),image:W(i(e,"image"))}),he=e=>({cycleIndex:$(i(e,"cycleIndex")),skipped:i(e,"skipped")===!0,billingAttemptExpectedDate:a(i(e,"billingAttemptExpectedDate"))});function je(e){if(!g(e))return null;let t=e.intervalCount;return{interval:a(e.interval),intervalCount:g(t)?{count:N(t.count)}:null}}var ze=e=>({id:O(i(e,"id"),"subscription id"),status:a(i(e,"status")),nextBillingDate:a(i(e,"nextBillingDate")),currencyCode:a(i(e,"currencyCode")),deliveryPrice:I(i(e,"deliveryPrice")),deliveryPolicy:je(i(e,"deliveryPolicy")),lines:x(i(e,"lines"),$e),upcomingBillingCycles:x(i(e,"upcomingBillingCycles"),he)}),be=e=>k(e,ze);function we(e){let{contract:t,billingCycle:n}=e;if(g(t))return{contract:{id:a(t.id),status:a(t.status)}};if(g(n)){let{cycleIndex:r,skipped:s}=he(n);return{billingCycle:{cycleIndex:r,skipped:s}}}throw ee("changed subscription")}function ne(e){return{id:O(i(e,"id"),"return id"),status:a(i(e,"status"))}}var Ae=e=>O(e,"deleted address id"),xe=e=>({firstName:a(i(e,"firstName")),lastName:a(i(e,"lastName"))});var re=null;function Te(e){re=e}function D(){if(!re)throw new Error("account-pages: loaded without the account part");return re}async function E(e,t){let{serverFetch:n}=D(),{method:r,path:s}=le(e,t),o=await n(s,r==="POST"?{method:r,body:t}:{});if(o.kind==="logged-out")throw new R("Not logged in",{code:"NOT_LOGGED_IN",status:401});return o.data}function v(e){D().reset(),ue("account-updated",{what:e})}async function j(e){let t=await E("order",{id:e});return ye(t.order)}async function z({firstName:e,lastName:t}={}){let n=await E("profile",{firstName:e,lastName:t});return v("profile"),xe(n.customer)}async function G(){let e=await E("addresses",{});return ge(e.addresses)}async function H(e,{id:t,isDefault:n}={}){let r=await E("saveAddress",{id:t,address:e,isDefault:n});return v("addresses"),te(r.address)}async function V(e){let t=await E("deleteAddress",{id:e});return v("addresses"),Ae(t.deleted)}async function Z(){let e=await E("subscriptions",{});return be(e.subscriptions)}async function J(e,t){let n=await E("subscription",{id:e,action:t});return v("subscriptions"),we(n)}async function K(e,t){let n=await E("requestReturn",{orderId:e,lines:t});return v("orders"),ne(n.return)}var Ge=window.Tether.__core["shopify-values.ts"],[se,fn]=Ge;function m(e,t,n){l(e,u(t)).forEach(r=>{let s=p(r,t)??"";Object.hasOwn(n,s)&&B(r,n[s]===!0)})}var S=(e,t)=>l(e,u(t)).concat(e.matches(u(t))?[e]:[]),L=e=>e?e.toLowerCase().replace(/_/g," "):"",F=e=>(e?.formatted??[]).join(", "),w=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;var Ve=(e,t)=>({title:e.title||e.name||"","variant-title":e.variantTitle||"",quantity:String(e.quantity),price:b(e.price),total:b(e.totalPrice),sku:e.sku||"",returnable:t===null?void 0:String(t)}),Ze=e=>e.tagName==="INPUT";function Je(e,t,n){m(e,"order-line-show",{returnable:n>0}),l(e,u("return-quantity")).forEach(r=>{Ze(r)&&(r.max=String(n),r.min="0",r.value||(r.value="0"),r.disabled=n<1)}),l(e,`select${u("return-reason")}`).forEach(r=>{r.dataset.tetherFilled!==t.id&&(r.dataset.tetherFilled=t.id,(t.suggestedReturnReasonDefinitions?.nodes??[]).forEach(s=>{r.appendChild(new Option(s.name??"",s.id))}))})}function Oe(e,t,n){A(e,t,(r,s)=>{let o=s.id,d=n&&o?n.get(o)??0:null;o&&(r.dataset.tetherLine=o);let c=Ve(s,d);S(r,"order-line").forEach(f=>{let C=p(f,"order-line")??"";if(C==="image"){s.image&&_(f,s.image.url,s.image.altText||s.title||"");return}let ae=w(c,C);ae!==void 0&&y(f,ae)}),o&&d!==null&&Je(r,{...s,id:o},d)})}function Ke(e){let t=p(e,"order")||"";return t.startsWith("url:")?new URL(window.location.href).searchParams.get(t.slice(4)||"id"):t}function U(e,t){e.setAttribute(h("order-state"),t),m(e,"order-show",{loading:t==="loading",ready:!1,"not-found":t==="not-found",error:t==="error"})}var Xe=e=>({name:e.name??"",date:P(e.processedAt),total:b(e.totalPrice),subtotal:b(e.subtotal),shipping:b(e.totalShipping),tax:b(e.totalTax),status:L(e.financialStatus),fulfillment:L(e.fulfillmentStatus),"shipping-address":F(e.shippingAddress),"billing-address":F(e.billingAddress),items:e.lineItems.nodes.map(t=>`${String(t.quantity)}\xD7 ${t.title||t.name||""}`).join(", "),cancelled:P(e.cancelledAt)});function Ye(e,t){let n=t.trackingInformation[0],r={status:L(t.latestShipmentStatus||t.status),date:P(t.createdAt),eta:P(t.estimatedDeliveryAt),company:n?.company||"",number:n?.number||""};S(e,"fulfillment-bind").forEach(s=>{let o=p(s,"fulfillment-bind")??"";if(o==="url"){let c=n?.url??null,f=c!==null&&se(c);f&&s.setAttribute("href",c),B(s,f);return}let d=w(r,o);d!==void 0&&y(s,d)})}function Qe(e,t){let n=new Map((t.returnInformation?.returnableLineItems.nodes??[]).map(d=>[d.lineItem?.id??"",d.quantity])),r=t.fulfillments.nodes,s=Xe(t);l(e,u("order-bind")).forEach(d=>{let c=p(d,"order-bind")??"";if(c==="url"){let C=t.statusPageUrl;C!==null&&se(C)&&d.setAttribute("href",C);return}let f=w(s,c);f!==void 0&&y(d,f)}),l(e,u("order-lines")).forEach(d=>{Oe(d,t.lineItems.nodes,n)}),l(e,u("order-fulfillments")).forEach(d=>{A(d,r,Ye)});let o=e.dataset.tetherReturned==="1";m(e,"order-show",{loading:!1,ready:!0,error:!1,"not-found":!1,cancelled:!!t.cancelledAt,shipped:r.length>0,returnable:[...n.values()].some(d=>d>0),"has-returns":!o&&t.returns.nodes.length>0,"return-requested":o}),e.setAttribute(h("order-state"),"ready")}async function X(e){let t=Ke(e);if(!t){e.setAttribute(h("order-state"),"not-found"),m(e,"order-show",{"not-found":!0});return}U(e,"loading");let n;try{n=await j(t)}catch(r){T(r,"order"),U(e,"error");return}if(!n){U(e,"not-found");return}e.dataset.tetherOrderId=n.id,Qe(e,n)}var Ee=[],Se=e=>Ee.find(t=>t.id===e),We=e=>({formatted:F(e),name:[e.firstName,e.lastName].filter(Boolean).join(" "),company:e.company||"",address1:e.address1||"",address2:e.address2||"",city:e.city||"",zip:e.zip||"",province:e.province||"",country:e.country||"",phone:e.phoneNumber||""});function et(e,t){e.dataset.tetherAddress=t.id;let n=We(t);S(e,"address-bind").forEach(r=>{let s=w(n,p(r,"address-bind")??"");s!==void 0&&y(r,s)}),m(e,"address-show",{default:t.isDefault,"not-default":!t.isDefault})}async function M(e){let t=l(e,u("addresses"));if(!t.length)return;m(e,"show",{"addresses-loading":!0,"addresses-empty":!1});let n;try{n=await G()}catch(r){T(r,"addresses"),m(e,"show",{"addresses-loading":!1,"addresses-error":!0});return}Ee=n,m(e,"show",{"addresses-loading":!1,"addresses-empty":n.length===0,"addresses-error":!1}),t.forEach(r=>{A(r,n,et)})}function tt(e){let t=e.upcomingBillingCycles.nodes[0],n=e.status,r=n==="ACTIVE";return{active:r,paused:n==="PAUSED",cancelled:n==="CANCELLED",expired:n==="EXPIRED",failed:n==="FAILED",skipped:!!t?.skipped,"can-pause":r,"can-resume":n==="PAUSED"||n==="FAILED","can-skip":r&&t!==void 0&&!t.skipped,"can-unskip":r&&!!t?.skipped,"can-cancel":r||n==="PAUSED"||n==="FAILED"}}function nt(e){let t=L(e.deliveryPolicy?.interval);if(!t)return"";let n=e.deliveryPolicy?.intervalCount?.count??1;return n<=1?t:`${String(n)} ${t}s`}function rt(e){let t=e.lines.nodes,n=t.reduce((r,s)=>r+Number.parseFloat(s.lineDiscountedPrice?.amount??"0"),0);return{status:L(e.status),next:P(e.nextBillingDate),interval:nt(e),products:t.map(r=>`${String(r.quantity)}\xD7 ${r.title??""}`).join(", "),total:b(t.length&&e.currencyCode?{amount:String(n),currencyCode:e.currencyCode}:null),delivery:b(e.deliveryPrice)}}function st(e,t){let n={title:t.title??"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:b(t.currentPrice)};S(e,"subscription-line").forEach(r=>{let s=p(r,"subscription-line")??"";if(s==="image"){t.image&&_(r,t.image.url,t.image.altText||t.title||"");return}let o=w(n,s);o!==void 0&&y(r,o)})}function it(e,t){e.dataset.tetherSubscription=t.id,e.setAttribute(h("subscription-status"),L(t.status));let n=rt(t);l(e,u("subscription-bind")).forEach(s=>{let o=w(n,p(s,"subscription-bind")??"");o!==void 0&&y(s,o)}),l(e,u("subscription-lines")).forEach(s=>{A(s,t.lines.nodes,st)});let r=tt(t);m(e,"subscription-show",r),l(e,u("subscription-action")).forEach(s=>{let o=w(r,`can-${p(s,"subscription-action")??""}`)===!0;"disabled"in s&&(s.disabled=!o),s.classList.toggle("is-disabled",!o)})}async function Y(e){let t=l(e,u("subscriptions"));if(!t.length)return;m(e,"show",{"subscriptions-loading":!0,"subscriptions-empty":!1});let n;try{n=await Z()}catch(r){T(r,"subscriptions"),m(e,"show",{"subscriptions-loading":!1,"subscriptions-error":!0});return}m(e,"show",{"subscriptions-loading":!1,"subscriptions-empty":n.length===0,"subscriptions-error":!1}),t.forEach(r=>{A(r,n,it)})}var ot=["pause","resume","skip","unskip","cancel"],at=e=>ot.some(t=>t===e),Pe=e=>e instanceof window.HTMLInputElement||e instanceof window.HTMLSelectElement||e instanceof window.HTMLTextAreaElement,ke=e=>e instanceof window.HTMLFormElement;function Le(e){let t={};for(let n of e.elements)Pe(n)&&(!n.name||n.type==="submit"||n.type==="button"||n.type==="checkbox"||(t[n.name]=n.value));return t}function ut(e){let n=(e instanceof R?e.userErrors??[]:[]).map(s=>s.message).join(" ");return n||(e instanceof Error&&e.message?e.message:"Something went wrong").replace(/^Customer accounts: /,"")}async function q(e,t){if(e.getAttribute("aria-busy")==="true")return"busy";e.classList.add("is-busy"),e.setAttribute("aria-busy","true"),e.setAttribute(h("form-state"),"pending");let n=l(e,u("form-error"));n.forEach(r=>{y(r,"")});try{return await t(),e.setAttribute(h("form-state"),"saved"),"saved"}catch(r){return e.setAttribute(h("form-state"),"error"),n.forEach(s=>{y(s,ut(r))}),"error"}finally{e.classList.remove("is-busy"),e.removeAttribute("aria-busy")}}var ie=e=>{let t=p(e,"confirm");return!t||window.confirm(t)},Ie=e=>{e.reset(),delete e.dataset.tetherAddressId};function dt(e){let t=e.target;if(t instanceof window.HTMLFormElement){if(t.matches(u("profile-form")))e.preventDefault(),q(t,async()=>{await z(Le(t)),await D().bindCustomer(document)});else if(t.matches(u("address-form"))){e.preventDefault();let n=t.dataset.tetherAddressId,r=t.elements.namedItem("isDefault"),s=r instanceof window.HTMLInputElement&&r.checked;q(t,async()=>{await H(Le(t),{id:n,isDefault:s}),Ie(t),await M(document)})}}}function lt(e){let t=Se(e),n=document.querySelector(u("address-form"));if(!t||!n||!ke(n))return;n.dataset.tetherAddressId=t.id;let r={...t};for(let s of n.elements)if(Pe(s)){if(s.name==="isDefault")s instanceof window.HTMLInputElement&&(s.checked=t.isDefault);else if(s.name&&Object.hasOwn(r,s.name)){let o=r[s.name];s.value=typeof o=="string"?o:""}}n.scrollIntoView({block:"nearest"})}function ct(e,t){let n=t.closest("[data-tether-address]"),r=n instanceof window.HTMLElement?n.dataset.tetherAddress:void 0;if(t.closest(u("address-new"))){let o=document.querySelector(u("address-form"));return o&&ke(o)&&Ie(o),!0}if(!(n instanceof window.HTMLElement)||!r)return!1;let s=t.closest(u("address-delete"));if(s){if(e.preventDefault(),!ie(s))return!0;q(n,async()=>{await V(r),await M(document)})}else if(t.closest(u("address-default")))e.preventDefault(),q(n,async()=>{await H(null,{id:r,isDefault:!0}),await M(document)});else if(t.closest(u("address-edit")))e.preventDefault(),lt(r);else return!1;return!0}function mt(e){let t=e.closest("[data-tether-subscription]"),n=p(e,"subscription-action"),r="disabled"in e&&e.disabled===!0||e.classList.contains("is-disabled");if(!(t instanceof window.HTMLElement)||!at(n)||r||!ie(e))return;let s=t.dataset.tetherSubscription??"";t.setAttribute(h("subscription-state"),"pending"),q(t,async()=>{await J(s,n),await Y(document)}).then(o=>{let d=o==="error"?"error":"done";l(document,"[data-tether-subscription]").filter(c=>c===t||c.dataset.tetherSubscription===s).forEach(c=>{c.setAttribute(h("subscription-state"),d)})})}function pt(e){let t=e.querySelector(u("return-quantity")),n=e.querySelector(u("return-reason")),r=e.querySelector(u("return-note")),s=f=>f&&"value"in f&&typeof f.value=="string"?f.value:"",o={lineItemId:e.dataset.tetherLine??"",quantity:Number.parseInt(s(t)||"0",10)},d=s(n);d&&(o.reasonId=d);let c=s(r);return c&&(o.note=c),o}function ft(e){let t=e.closest(u("order"));if(!(t instanceof window.HTMLElement))return;let n=t.dataset.tetherOrderId;if(!n)return;let r=l(t,"[data-tether-line]").map(pt).filter(s=>s.quantity>0);!r.length||!ie(e)||q(t,async()=>{await K(n,r),t.dataset.tetherReturned="1",await X(t)})}function gt(e){let t=e.target;if(!(t instanceof window.Element)||ct(e,t))return;let n=t.closest(u("subscription-action"));if(n instanceof window.HTMLElement){e.preventDefault(),mt(n);return}let r=t.closest(u("order-return"));r instanceof window.HTMLElement&&(e.preventDefault(),ft(r))}function Ce(){document.addEventListener("submit",dt,!0),document.addEventListener("input",e=>{let t=e.target;t instanceof window.HTMLElement&&t.closest(u("profile-form"))&&(t.dataset.tetherTouched="1")}),document.addEventListener("click",gt)}var yt=["firstName","lastName"];async function ht(e){if(!(e instanceof window.HTMLFormElement))return;let t;try{t=await D().customer()}catch(r){T(r,"account");return}if(!t)return;let n=e.elements;yt.forEach(r=>{let s=n.namedItem(r);(s instanceof window.HTMLInputElement||s instanceof window.HTMLTextAreaElement)&&!s.dataset.tetherTouched&&(s.value=t[r]??"")})}var Re=!1;async function bt(e=document){Re||(Re=!0,Ce()),await Promise.all([...l(e,u("order")).map(t=>X(t)),...l(e,u("profile-form")).map(t=>ht(t)),M(e),Y(e)])}function wt(e){l(e,u("order")).forEach(t=>{U(t,"error")}),m(e,"show",{"addresses-loading":!1,"addresses-error":!0,"subscriptions-loading":!1,"subscriptions-error":!0})}function At(e){return g(e)&&g(e.__core)&&g(e.__parts)}function Ne(e,t){let n=Reflect.get(window,"Tether");if(!At(n))throw new Error(`tether.${e}.js runs after the Tether script, which loads it, and needs its window.Tether`);n.__parts[e]=t}Ne("account-pages",oe);})();
|
package/dist/tether.account.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
// tether-core:dom.ts
|
|
37
37
|
var m3 = window.Tether.__core["dom.ts"];
|
|
38
|
-
var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m3;
|
|
38
|
+
var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, integerAttribute, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m3;
|
|
39
39
|
|
|
40
40
|
// tether-core:cart.ts
|
|
41
41
|
var m4 = window.Tether.__core["cart.ts"];
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
|
|
255
255
|
// tether-core:shopify-values.ts
|
|
256
256
|
var m6 = window.Tether.__core["shopify-values.ts"];
|
|
257
|
-
var [isHttpsUrl] = m6;
|
|
257
|
+
var [isHttpsUrl, MAX_CONNECTION_SIZE] = m6;
|
|
258
258
|
|
|
259
259
|
// src/account/markup.ts
|
|
260
260
|
function showIn(root, name, conditions) {
|
|
@@ -317,10 +317,7 @@
|
|
|
317
317
|
var DEFAULT_ORDER_COUNT = 10;
|
|
318
318
|
var MAX_ORDER_COUNT = 50;
|
|
319
319
|
var isOrderCount = (value) => typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= MAX_ORDER_COUNT;
|
|
320
|
-
|
|
321
|
-
const asked = Number.parseInt(limit || String(DEFAULT_ORDER_COUNT), 10) || DEFAULT_ORDER_COUNT;
|
|
322
|
-
return Math.min(Math.max(asked, 1), MAX_ORDER_COUNT);
|
|
323
|
-
}
|
|
320
|
+
var listLimit = (list) => integerAttribute(list, "limit", { min: 1, max: MAX_ORDER_COUNT, fallback: DEFAULT_ORDER_COUNT });
|
|
324
321
|
var numericId = (gid) => gid.replace(/\?.*$/, "").replace(/^.*\//, "");
|
|
325
322
|
function orderUrl(order2) {
|
|
326
323
|
const template = cfg.account?.orderUrl;
|
|
@@ -364,7 +361,7 @@
|
|
|
364
361
|
const first = lists[0];
|
|
365
362
|
if (!first) return;
|
|
366
363
|
showIn(root, "show", { "orders-loading": true, "orders-empty": false });
|
|
367
|
-
const limit = listLimit(
|
|
364
|
+
const limit = listLimit(first);
|
|
368
365
|
let orders2;
|
|
369
366
|
try {
|
|
370
367
|
orders2 = await loadOrders(limit);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var Pt=Object.defineProperty;var Tt=(t,e)=>{for(var r in e)Pt(t,r,{get:e[r],enumerable:!0})};var j={};Tt(j,{addresses:()=>ee,customer:()=>F,deleteAddress:()=>ne,isLoggedIn:()=>ht,login:()=>yt,logout:()=>At,mountAccount:()=>ue,order:()=>Qt,orders:()=>xt,render:()=>_,requestReturn:()=>ie,saveAddress:()=>re,subscriptionAction:()=>se,subscriptions:()=>oe,updateProfile:()=>te});var St=window.Tether.__core["config.ts"],[u,me,V,fe,ge,y,pe]=St;var Lt=window.Tether.__core["client.ts"],[he,ye,xe,Ae,Oe,p]=Lt;var bt=window.Tether.__core["dom.ts"],[Pe,Te,Se,Le,P,B,T,m,be,Re,Ee,Ie,Ne,Ce,d,E,ve,c,I,Ue,A,S]=bt;var Rt=window.Tether.__core["cart.ts"],[L]=Rt;var Et=window.Tether.__core["lazy.ts"],[G]=Et;function g(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function a(t,e){return g(t)?t[e]:void 0}function M(t){return Array.isArray(t)?t:[]}function i(t){return typeof t=="string"&&t!==""?t:null}var It=t=>typeof t=="number"&&Number.isFinite(t)?t:null,J=t=>It(t)??0,N=(t,e)=>M(t).map(r=>e(r)),K=(t,e)=>({nodes:N(a(t,"nodes"),e)}),$=t=>N(t,i).filter(e=>e!==null);function z(t){return t instanceof Error?t.message:String(t)}function W(t,e,r="localStorage"){try{window[r].setItem(t,e)}catch{}}function D(t,e="localStorage"){try{window[e].removeItem(t)}catch{}}var q=()=>`${u.prefix}:account-hint:${u.domain}`;var X=t=>t==="in"||t==="expired"||t==="error";function Nt(t){let e=i(a(t,"amount")),r=i(a(t,"currencyCode"));return e===null||r===null?null:{amount:e,currencyCode:r}}function Ct(t){let e=i(a(t,"url"));return e===null?null:{url:e,altText:i(a(t,"altText"))}}var vt=t=>({title:i(a(t,"title")),variantTitle:i(a(t,"variantTitle")),quantity:J(a(t,"quantity")),image:Ct(a(t,"image"))}),Ut=(t,e)=>({id:e,name:i(a(t,"name")),processedAt:i(a(t,"processedAt")),financialStatus:i(a(t,"financialStatus")),fulfillmentStatus:i(a(t,"fulfillmentStatus")),statusPageUrl:i(a(t,"statusPageUrl")),totalPrice:Nt(a(t,"totalPrice")),lineItems:K(a(t,"lineItems"),vt)});function Z(t){let e=[];for(let r of M(t)){let n=i(a(r,"id"));if(n===null)return{kind:"missing-id"};e.push(Ut(r,n))}return{kind:"read",orders:e}}var _t=t=>new p(`Customer accounts: the answer has no ${t}`);function Y(t){let e=g(t)?t:{},r=i(e.id),n=i(e.email),o=e.address;return{...r===null?{}:{id:r},firstName:i(e.firstName),lastName:i(e.lastName),displayName:i(e.displayName),emailAddress:n===null?null:{emailAddress:n},defaultAddress:Array.isArray(o)?{formatted:$(o)}:null}}function Q(t){let e=Z(t);if(e.kind==="missing-id")throw _t("order id");return e.orders}function Mt(t){let e=i(a(t,"message"));if(e===null)return null;let r=a(t,"field");return{message:e,field:Array.isArray(r)?$(r):null,code:i(a(t,"code"))}}var tt=t=>N(t,Mt).filter(e=>e!==null);var x=null;function et(){let t=u.account?.server;if(!t)throw new p("Customer accounts need the Worker: set account.server",{code:"NOT_CONFIGURED"});return new URL(t,window.location.href).href.replace(/\/$/,"")}function rt(t){t?W(q(),"1"):D(q())}async function $t(t,e){try{return await fetch(t,e)}catch(r){throw new p(`Network error: ${z(r)}`,{code:"NETWORK"})}}async function Dt(t){let e;try{e=await t.json()}catch{return{}}return g(e)?e:{}}async function O(t,{method:e="GET",body:r}={}){let n={method:e,credentials:"include"};e==="POST"&&(n.headers={"Content-Type":"application/json","X-Tether-Account":"1"}),r&&(n.body=JSON.stringify(r));let o=await $t(`${et()}${t}`,n);if(o.status===401)return{kind:"logged-out"};let s=await Dt(o);if(!o.ok){let l=i(s.error)??String(o.status),w=tt(s.userErrors);throw new p(`Customer accounts: ${l}`,{status:o.status,...w.length>0&&{userErrors:w},...s.code==="INVALID"&&{code:"INVALID"}})}return{kind:"answer",data:s}}async function C(){if(!x){let t=await O("/me");x=t.kind==="answer"&&t.data.loggedIn===!0?{loggedIn:!0,customer:Y(t.data.customer)}:{loggedIn:!1}}return rt(x.loggedIn),x}var nt=()=>x?.loggedIn===!0;function ot(){x=null}function st(t){let e=u.account?.navigate;e?e(t):window.location.assign(t)}var qt=t=>t||u.account?.locale||(u.locale||"").split("-")[0]||"";function it({returnTo:t,locale:e}){let r=new URL(`${et()}/login`);r.searchParams.set("returnTo",t);let n=qt(e);n&&r.searchParams.set("locale",n),u.country&&r.searchParams.set("country",u.country.toUpperCase()),st(r.toString())}async function at(){let t=L.id();if(!(await C()).loggedIn||!t)return null;let e=await O("/cart",{method:"POST",body:{cartId:t}});return e.kind==="logged-out"?null:i(e.data.checkoutUrl)}async function ct(t){let e=await O("/logout",{method:"POST",body:{returnTo:t,cartId:L.id()}});x=null,rt(!1),P("account-logout",{});let r=e.kind==="answer"?i(e.data.logoutUrl):null;return r?(st(r),"redirected"):"stayed"}var Ft=window.Tether.__core["shopify-values.ts"],[ut]=Ft;function b(t,e,r){d(t,c(e)).forEach(n=>{let o=m(n,e)??"";Object.hasOwn(r,o)&&S(n,r[o]===!0)})}var dt=(t,e)=>d(t,c(e)).concat(t.matches(c(e))?[t]:[]);var k=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0;var jt=(t,e)=>({title:t.title||t.name||"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:T(t.price),total:T(t.totalPrice),sku:t.sku||"",returnable:e===null?void 0:String(e)}),Ht=t=>t.tagName==="INPUT";function Vt(t,e,r){b(t,"order-line-show",{returnable:r>0}),d(t,c("return-quantity")).forEach(n=>{Ht(n)&&(n.max=String(r),n.min="0",n.value||(n.value="0"),n.disabled=r<1)}),d(t,`select${c("return-reason")}`).forEach(n=>{n.dataset.tetherFilled!==e.id&&(n.dataset.tetherFilled=e.id,(e.suggestedReturnReasonDefinitions?.nodes??[]).forEach(o=>{n.appendChild(new Option(o.name??"",o.id))}))})}function lt(t,e,r){E(t,e,(n,o)=>{let s=o.id,l=r&&s?r.get(s)??0:null;s&&(n.dataset.tetherLine=s);let w=jt(o,l);dt(n,"order-line").forEach(h=>{let R=m(h,"order-line")??"";if(R==="image"){o.image&&I(h,o.image.url,o.image.altText||o.title||"");return}let H=k(w,R);H!==void 0&&A(h,H)}),s&&l!==null&&Vt(n,{...o,id:s},l)})}var v=10,U=50,mt=t=>typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=U;function Bt(t){let e=Number.parseInt(t||String(v),10)||v;return Math.min(Math.max(e,1),U)}var Gt=t=>t.replace(/\?.*$/,"").replace(/^.*\//,"");function Jt(t){let e=u.account?.orderUrl;if(e)return e.replaceAll("{id}",encodeURIComponent(Gt(t.id)));let r=t.statusPageUrl;return r!==null&&ut(r)?r:null}var Kt=t=>({name:t.name??"",date:B(t.processedAt),total:T(t.totalPrice),status:t.financialStatus?.toLowerCase(),fulfillment:t.fulfillmentStatus?.toLowerCase(),items:t.lineItems.nodes.map(e=>`${String(e.quantity)}\xD7 ${e.title??""}`).join(", ")});function zt(t,e){let r=e.lineItems.nodes,n=Jt(e),o=Kt(e);d(t,c("order-bind")).forEach(s=>{let l=m(s,"order-bind")??"";if(l==="url"){n&&s.setAttribute("href",n);return}if(l==="image"){let h=r.find(R=>R.image)?.image;h&&I(s,h.url,h.altText||r[0]?.title||"");return}let w=k(o,l);w!==void 0&&A(s,w)}),d(t,c("order-lines")).forEach(s=>{lt(s,r,null)}),m(t,"order-bind")==="url"&&n&&t.setAttribute("href",n)}async function ft(t,e){let r=d(t,c("orders")),n=r[0];if(!n)return;b(t,"show",{"orders-loading":!0,"orders-empty":!1});let o=Bt(m(n,"limit")),s;try{s=await e(o)}catch(l){y(l,"orders"),s=null}b(t,"show",{"orders-loading":!1,"orders-empty":s?.length===0}),r.forEach(l=>{E(l,s??[],zt)})}var Wt=["order","addresses","subscriptions","profile-form","address-form"],ht=nt;function yt({returnTo:t=window.location.href,locale:e}={}){return new Promise(r=>{it({returnTo:t,locale:e}),r()})}async function F(){let t=await C();return t.loggedIn?t.customer:null}async function xt({first:t=v}={}){if(!mt(t))throw new p(`Customer accounts: orders() takes first from 1 to ${String(U)}`,{code:"INVALID"});let e=await O(`/orders?${new URLSearchParams({first:String(t)}).toString()}`);return e.kind==="logged-out"?[]:Q(e.data.orders)}async function At({returnTo:t=u.account?.logoutUrl||`${window.location.origin}/`}={}){await ct(t)==="stayed"&&await _(document)}async function Xt(){try{return(await C()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}}catch(t){return{kind:"unknown",error:t}}}var gt=t=>Wt.some(e=>d(t,c(e)).length>0);function Zt(t){d(t,c("account-link")).forEach(e=>{e.setAttribute("href",Yt(m(e,"account-link")))})}function Yt(t){let e=u.account,r=`https://${u.domain}/account`;return t==="payment"?e?.paymentUrl||e?.subscriptionsUrl||r:t==="subscriptions"&&e?.subscriptionsUrl||r}async function _(t=document){let e=await Xt();e.kind==="unknown"&&y(e.error,"account");let r=e.kind==="logged-in";if(d(t,c("show")).forEach(n=>{let o=m(n,"show");o==="logged-in"&&S(n,r),o==="logged-out"&&S(n,!r)}),Zt(t),e.kind==="unknown"&>(t)){(await f()).showUnavailable(t);return}r&&(await Ot(t),await Promise.all([ft(t,n=>xt({first:n})),gt(t)?f().then(n=>n.renderPages(t)):null]))}async function Ot(t){let e=d(t,c("account-bind"));if(!e.length)return;let r;try{r=await F()}catch(o){y(o,"account");return}if(!r)return;let n={"first-name":r.firstName,"last-name":r.lastName,name:r.displayName,email:r.emailAddress?.emailAddress,address:r.defaultAddress?.formatted.join(", ")};e.forEach(o=>{let s=k(n,m(o,"account-bind")??"");s!=null&&A(o,s)})}var pt=null;function f(){return pt??(pt=G("account-pages").then(t=>(t.setup({serverFetch:O,customer:F,bindCustomer:Ot,reset:ot}),t))),pt}var Qt=t=>f().then(e=>e.order(t)),te=t=>f().then(e=>e.updateProfile(t)),ee=()=>f().then(t=>t.addresses()),re=(t,e)=>f().then(r=>r.saveAddress(t,e)),ne=t=>f().then(e=>e.deleteAddress(t)),oe=()=>f().then(t=>t.subscriptions()),se=(t,e)=>f().then(r=>r.subscriptionAction(t,e)),ie=(t,e)=>f().then(r=>r.requestReturn(t,e));function ae(t){let e=t.target;e instanceof window.Element&&(e.closest(c("account-login"))?(t.preventDefault(),yt().catch(r=>{y(r,"login")})):e.closest(c("account-logout"))&&(t.preventDefault(),At().catch(r=>{y(r,"logout")})))}function ce(){let t=new URL(window.location.href),e=t.searchParams.get("account");if(X(e))switch(t.searchParams.delete("account"),window.history.replaceState(window.history.state,"",t),e){case"in":P("account-login",{});break;case"expired":case"error":P("account-error",{error:e});break}}var wt=!1;async function ue(t=document){if(wt){await _(t);return}wt=!0,document.addEventListener("click",ae),ce(),L.setCheckoutResolver(at),await _(t),V("account",ht()?"logged in":"logged out")}function de(t){return g(t)&&g(t.__core)&&g(t.__parts)}function kt(t,e){let r=Reflect.get(window,"Tether");if(!de(r))throw new Error(`tether.${t}.js runs after the Tether script, which loads it, and needs its window.Tether`);r.__parts[t]=e}kt("account",j);})();
|
|
1
|
+
(()=>{var Tt=Object.defineProperty;var St=(t,e)=>{for(var r in e)Tt(t,r,{get:e[r],enumerable:!0})};var j={};St(j,{addresses:()=>re,customer:()=>F,deleteAddress:()=>oe,isLoggedIn:()=>yt,login:()=>xt,logout:()=>Ot,mountAccount:()=>de,order:()=>te,orders:()=>At,render:()=>U,requestReturn:()=>ae,saveAddress:()=>ne,subscriptionAction:()=>ie,subscriptions:()=>se,updateProfile:()=>ee});var Lt=window.Tether.__core["config.ts"],[u,fe,V,ge,pe,y,we]=Lt;var bt=window.Tether.__core["client.ts"],[ye,xe,Ae,Oe,ke,p]=bt;var Et=window.Tether.__core["dom.ts"],[Te,Se,Le,be,P,B,T,m,Ee,Re,G,Ie,Ne,Ce,ve,d,R,Ue,c,I,_e,A,S]=Et;var Rt=window.Tether.__core["cart.ts"],[L]=Rt;var It=window.Tether.__core["lazy.ts"],[J]=It;function g(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function a(t,e){return g(t)?t[e]:void 0}function _(t){return Array.isArray(t)?t:[]}function i(t){return typeof t=="string"&&t!==""?t:null}var Nt=t=>typeof t=="number"&&Number.isFinite(t)?t:null,K=t=>Nt(t)??0,N=(t,e)=>_(t).map(r=>e(r)),X=(t,e)=>({nodes:N(a(t,"nodes"),e)}),$=t=>N(t,i).filter(e=>e!==null);function z(t){return t instanceof Error?t.message:String(t)}function W(t,e,r="localStorage"){try{window[r].setItem(t,e)}catch{}}function D(t,e="localStorage"){try{window[e].removeItem(t)}catch{}}var M=()=>`${u.prefix}:account-hint:${u.domain}`;var Z=t=>t==="in"||t==="expired"||t==="error";function Ct(t){let e=i(a(t,"amount")),r=i(a(t,"currencyCode"));return e===null||r===null?null:{amount:e,currencyCode:r}}function vt(t){let e=i(a(t,"url"));return e===null?null:{url:e,altText:i(a(t,"altText"))}}var Ut=t=>({title:i(a(t,"title")),variantTitle:i(a(t,"variantTitle")),quantity:K(a(t,"quantity")),image:vt(a(t,"image"))}),_t=(t,e)=>({id:e,name:i(a(t,"name")),processedAt:i(a(t,"processedAt")),financialStatus:i(a(t,"financialStatus")),fulfillmentStatus:i(a(t,"fulfillmentStatus")),statusPageUrl:i(a(t,"statusPageUrl")),totalPrice:Ct(a(t,"totalPrice")),lineItems:X(a(t,"lineItems"),Ut)});function Y(t){let e=[];for(let r of _(t)){let n=i(a(r,"id"));if(n===null)return{kind:"missing-id"};e.push(_t(r,n))}return{kind:"read",orders:e}}var $t=t=>new p(`Customer accounts: the answer has no ${t}`);function Q(t){let e=g(t)?t:{},r=i(e.id),n=i(e.email),o=e.address;return{...r===null?{}:{id:r},firstName:i(e.firstName),lastName:i(e.lastName),displayName:i(e.displayName),emailAddress:n===null?null:{emailAddress:n},defaultAddress:Array.isArray(o)?{formatted:$(o)}:null}}function tt(t){let e=Y(t);if(e.kind==="missing-id")throw $t("order id");return e.orders}function Dt(t){let e=i(a(t,"message"));if(e===null)return null;let r=a(t,"field");return{message:e,field:Array.isArray(r)?$(r):null,code:i(a(t,"code"))}}var et=t=>N(t,Dt).filter(e=>e!==null);var x=null;function rt(){let t=u.account?.server;if(!t)throw new p("Customer accounts need the Worker: set account.server",{code:"NOT_CONFIGURED"});return new URL(t,window.location.href).href.replace(/\/$/,"")}function nt(t){t?W(M(),"1"):D(M())}async function Mt(t,e){try{return await fetch(t,e)}catch(r){throw new p(`Network error: ${z(r)}`,{code:"NETWORK"})}}async function qt(t){let e;try{e=await t.json()}catch{return{}}return g(e)?e:{}}async function O(t,{method:e="GET",body:r}={}){let n={method:e,credentials:"include"};e==="POST"&&(n.headers={"Content-Type":"application/json","X-Tether-Account":"1"}),r&&(n.body=JSON.stringify(r));let o=await Mt(`${rt()}${t}`,n);if(o.status===401)return{kind:"logged-out"};let s=await qt(o);if(!o.ok){let l=i(s.error)??String(o.status),w=et(s.userErrors);throw new p(`Customer accounts: ${l}`,{status:o.status,...w.length>0&&{userErrors:w},...s.code==="INVALID"&&{code:"INVALID"}})}return{kind:"answer",data:s}}async function C(){if(!x){let t=await O("/me");x=t.kind==="answer"&&t.data.loggedIn===!0?{loggedIn:!0,customer:Q(t.data.customer)}:{loggedIn:!1}}return nt(x.loggedIn),x}var ot=()=>x?.loggedIn===!0;function st(){x=null}function it(t){let e=u.account?.navigate;e?e(t):window.location.assign(t)}var Ft=t=>t||u.account?.locale||(u.locale||"").split("-")[0]||"";function at({returnTo:t,locale:e}){let r=new URL(`${rt()}/login`);r.searchParams.set("returnTo",t);let n=Ft(e);n&&r.searchParams.set("locale",n),u.country&&r.searchParams.set("country",u.country.toUpperCase()),it(r.toString())}async function ct(){let t=L.id();if(!(await C()).loggedIn||!t)return null;let e=await O("/cart",{method:"POST",body:{cartId:t}});return e.kind==="logged-out"?null:i(e.data.checkoutUrl)}async function ut(t){let e=await O("/logout",{method:"POST",body:{returnTo:t,cartId:L.id()}});x=null,nt(!1),P("account-logout",{});let r=e.kind==="answer"?i(e.data.logoutUrl):null;return r?(it(r),"redirected"):"stayed"}var jt=window.Tether.__core["shopify-values.ts"],[dt,ar]=jt;function b(t,e,r){d(t,c(e)).forEach(n=>{let o=m(n,e)??"";Object.hasOwn(r,o)&&S(n,r[o]===!0)})}var lt=(t,e)=>d(t,c(e)).concat(t.matches(c(e))?[t]:[]);var k=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0;var Ht=(t,e)=>({title:t.title||t.name||"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:T(t.price),total:T(t.totalPrice),sku:t.sku||"",returnable:e===null?void 0:String(e)}),Vt=t=>t.tagName==="INPUT";function Bt(t,e,r){b(t,"order-line-show",{returnable:r>0}),d(t,c("return-quantity")).forEach(n=>{Vt(n)&&(n.max=String(r),n.min="0",n.value||(n.value="0"),n.disabled=r<1)}),d(t,`select${c("return-reason")}`).forEach(n=>{n.dataset.tetherFilled!==e.id&&(n.dataset.tetherFilled=e.id,(e.suggestedReturnReasonDefinitions?.nodes??[]).forEach(o=>{n.appendChild(new Option(o.name??"",o.id))}))})}function mt(t,e,r){R(t,e,(n,o)=>{let s=o.id,l=r&&s?r.get(s)??0:null;s&&(n.dataset.tetherLine=s);let w=Ht(o,l);lt(n,"order-line").forEach(h=>{let E=m(h,"order-line")??"";if(E==="image"){o.image&&I(h,o.image.url,o.image.altText||o.title||"");return}let H=k(w,E);H!==void 0&&A(h,H)}),s&&l!==null&&Bt(n,{...o,id:s},l)})}var q=10,v=50,ft=t=>typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=v,Gt=t=>G(t,"limit",{min:1,max:v,fallback:q}),Jt=t=>t.replace(/\?.*$/,"").replace(/^.*\//,"");function Kt(t){let e=u.account?.orderUrl;if(e)return e.replaceAll("{id}",encodeURIComponent(Jt(t.id)));let r=t.statusPageUrl;return r!==null&&dt(r)?r:null}var Xt=t=>({name:t.name??"",date:B(t.processedAt),total:T(t.totalPrice),status:t.financialStatus?.toLowerCase(),fulfillment:t.fulfillmentStatus?.toLowerCase(),items:t.lineItems.nodes.map(e=>`${String(e.quantity)}\xD7 ${e.title??""}`).join(", ")});function zt(t,e){let r=e.lineItems.nodes,n=Kt(e),o=Xt(e);d(t,c("order-bind")).forEach(s=>{let l=m(s,"order-bind")??"";if(l==="url"){n&&s.setAttribute("href",n);return}if(l==="image"){let h=r.find(E=>E.image)?.image;h&&I(s,h.url,h.altText||r[0]?.title||"");return}let w=k(o,l);w!==void 0&&A(s,w)}),d(t,c("order-lines")).forEach(s=>{mt(s,r,null)}),m(t,"order-bind")==="url"&&n&&t.setAttribute("href",n)}async function gt(t,e){let r=d(t,c("orders")),n=r[0];if(!n)return;b(t,"show",{"orders-loading":!0,"orders-empty":!1});let o=Gt(n),s;try{s=await e(o)}catch(l){y(l,"orders"),s=null}b(t,"show",{"orders-loading":!1,"orders-empty":s?.length===0}),r.forEach(l=>{R(l,s??[],zt)})}var Wt=["order","addresses","subscriptions","profile-form","address-form"],yt=ot;function xt({returnTo:t=window.location.href,locale:e}={}){return new Promise(r=>{at({returnTo:t,locale:e}),r()})}async function F(){let t=await C();return t.loggedIn?t.customer:null}async function At({first:t=q}={}){if(!ft(t))throw new p(`Customer accounts: orders() takes first from 1 to ${String(v)}`,{code:"INVALID"});let e=await O(`/orders?${new URLSearchParams({first:String(t)}).toString()}`);return e.kind==="logged-out"?[]:tt(e.data.orders)}async function Ot({returnTo:t=u.account?.logoutUrl||`${window.location.origin}/`}={}){await ut(t)==="stayed"&&await U(document)}async function Zt(){try{return(await C()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}}catch(t){return{kind:"unknown",error:t}}}var pt=t=>Wt.some(e=>d(t,c(e)).length>0);function Yt(t){d(t,c("account-link")).forEach(e=>{e.setAttribute("href",Qt(m(e,"account-link")))})}function Qt(t){let e=u.account,r=`https://${u.domain}/account`;return t==="payment"?e?.paymentUrl||e?.subscriptionsUrl||r:t==="subscriptions"&&e?.subscriptionsUrl||r}async function U(t=document){let e=await Zt();e.kind==="unknown"&&y(e.error,"account");let r=e.kind==="logged-in";if(d(t,c("show")).forEach(n=>{let o=m(n,"show");o==="logged-in"&&S(n,r),o==="logged-out"&&S(n,!r)}),Yt(t),e.kind==="unknown"&&pt(t)){(await f()).showUnavailable(t);return}r&&(await kt(t),await Promise.all([gt(t,n=>At({first:n})),pt(t)?f().then(n=>n.renderPages(t)):null]))}async function kt(t){let e=d(t,c("account-bind"));if(!e.length)return;let r;try{r=await F()}catch(o){y(o,"account");return}if(!r)return;let n={"first-name":r.firstName,"last-name":r.lastName,name:r.displayName,email:r.emailAddress?.emailAddress,address:r.defaultAddress?.formatted.join(", ")};e.forEach(o=>{let s=k(n,m(o,"account-bind")??"");s!=null&&A(o,s)})}var wt=null;function f(){return wt??(wt=J("account-pages").then(t=>(t.setup({serverFetch:O,customer:F,bindCustomer:kt,reset:st}),t))),wt}var te=t=>f().then(e=>e.order(t)),ee=t=>f().then(e=>e.updateProfile(t)),re=()=>f().then(t=>t.addresses()),ne=(t,e)=>f().then(r=>r.saveAddress(t,e)),oe=t=>f().then(e=>e.deleteAddress(t)),se=()=>f().then(t=>t.subscriptions()),ie=(t,e)=>f().then(r=>r.subscriptionAction(t,e)),ae=(t,e)=>f().then(r=>r.requestReturn(t,e));function ce(t){let e=t.target;e instanceof window.Element&&(e.closest(c("account-login"))?(t.preventDefault(),xt().catch(r=>{y(r,"login")})):e.closest(c("account-logout"))&&(t.preventDefault(),Ot().catch(r=>{y(r,"logout")})))}function ue(){let t=new URL(window.location.href),e=t.searchParams.get("account");if(Z(e))switch(t.searchParams.delete("account"),window.history.replaceState(window.history.state,"",t),e){case"in":P("account-login",{});break;case"expired":case"error":P("account-error",{error:e});break}}var ht=!1;async function de(t=document){if(ht){await U(t);return}ht=!0,document.addEventListener("click",ce),ue(),L.setCheckoutResolver(ct),await U(t),V("account",yt()?"logged in":"logged out")}function le(t){return g(t)&&g(t.__core)&&g(t.__parts)}function Pt(t,e){let r=Reflect.get(window,"Tether");if(!le(r))throw new Error(`tether.${t}.js runs after the Tether script, which loads it, and needs its window.Tether`);r.__parts[t]=e}Pt("account",j);})();
|
package/dist/tether.analytics.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
// tether-core:dom.ts
|
|
19
19
|
var m2 = window.Tether.__core["dom.ts"];
|
|
20
|
-
var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m2;
|
|
20
|
+
var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, integerAttribute, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m2;
|
|
21
21
|
|
|
22
22
|
// tether-core:cart.ts
|
|
23
23
|
var m3 = window.Tether.__core["cart.ts"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var U=Object.defineProperty;var $=(t,n)=>{for(var e in n)U(t,e,{get:n[e],enumerable:!0})};var k={};$(k,{startAnalytics:()=>yt});var G=window.Tether.__core["config.ts"],[a,bt,_,vt,wt,l,Tt]=G;var H=window.Tether.__core["dom.ts"],[C,_t,Ct,Et,xt,At,St,Pt,Lt,Nt,E,
|
|
1
|
+
(()=>{var U=Object.defineProperty;var $=(t,n)=>{for(var e in n)U(t,e,{get:n[e],enumerable:!0})};var k={};$(k,{startAnalytics:()=>yt});var G=window.Tether.__core["config.ts"],[a,bt,_,vt,wt,l,Tt]=G;var H=window.Tether.__core["dom.ts"],[C,_t,Ct,Et,xt,At,St,Pt,Lt,Nt,It,E,Rt,Vt,Dt,Mt,qt,Bt,p,Ot,Ft,jt,Ut]=H;var W=window.Tether.__core["cart.ts"],[b]=W;var Y=window.Tether.__core["product.ts"],[x]=Y;var J=window.Tether.__core["client.ts"],[Wt,A,Yt,Jt,S,Zt]=J;var Z=500,P={"default-banner":"https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js",other:"https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.2/consent-tracking-api.js"},z="https://cdn.shopify.com/storefront/analytics/shopify.js",N=()=>window,y=()=>N().Shopify;function I(){let t=a.analytics?.shopify;return typeof t=="object"?t:{}}function R(){try{let t=y()?.customerPrivacy;return t?.consentStatus==="loaded"&&t.currentVisitorConsent?.()?.analytics!=="no"&&!!t.analyticsProcessingAllowed?.()}catch{return!1}}function K(t){let n=`hydrogen:${t}`;return{getTrackingValues:()=>{let e=R()?y()?.customerPrivacy?.__internal:void 0;return{uniqueToken:e?.uniqueToken?.({generateFallback:!0,tag:n})??"",visitToken:e?.visitToken?.({generateFallback:!0,tag:n})??""}}}}var X=t=>(n,e)=>{let o=t.subscribers.get(n)??new Set;return t.subscribers.set(n,o),o.add(e),()=>t.subscribers.get(n)?.delete(e)};function Q(t){let n=[],e=[],o={shop:{shopId:t,channel:"headless"},consent:{mode:I().consent||"no-banner"}},r=()=>{if(R())for(let i of n)for(;i.next<e.length;i.next+=1){let s=e[i.next];s&&tt(i,s)}},c={getConfig:()=>o,publish(i,s={}){if(e.push({event:i,payload:{shop:o.shop,url:window.location.href,...s}}),e.length>Z){e.shift();for(let u of n)u.next=Math.max(0,u.next-1)}r()},addDestination(i){let s={name:i.name,next:0,subscribers:new Map,context:K(i.name)};return Promise.resolve(i.setup?.({subscribe:X(s),getConfig:c.getConfig})).then(()=>{n.push(s),r()}).catch(u=>{l(u,`analytics ${i.name}`)}),()=>{let u=n.indexOf(s);u>=0&&n.splice(u,1)}}};return document.addEventListener("consentTrackingApiLoaded",r),document.addEventListener("visitorConsentCollected",r),c}function tt(t,{event:n,payload:e}){t.subscribers.get(n)?.forEach(o=>{try{o(e,t.context)}catch(r){l(r,`analytics ${t.name}`)}})}function L(t){let n=document.createElement("script");n.src=t,n.async=!0,document.head.appendChild(n)}async function V(t){let n=y();if(n?.analytics)return n.analytics;let e=await A("query TetherShopId { shop { id } }",{},S({shop:{id:"string"}}),{context:!1}),o=y()??{};N().Shopify=o,o.country=a.country??"US";let[r="en"]=(a.locale||"en").split("-");o.locale=r.toLowerCase(),o.shop=a.domain,o.routes={root:"/",match:()=>({pageTemplateName:t()?"product":"page"}),...o.routes};let{proxy:c,consent:i}=I();o.customerPrivacy={...o.customerPrivacy,config:c?{isHeadless:!0,asyncConsent:!0,asyncVisitorState:!0,consentDomain:window.location.host}:{isHeadless:!0,storefrontAccessToken:a.token,checkoutRootDomain:a.domain}};let s=Q(e.shop.id);return o.analytics=s,L(i==="default-banner"?P["default-banner"]:P.other),L(z),_("shopify analytics ready",e.shop.id),s}var nt="Default Title",D=100,et=200,ot=t=>t?parseFloat(t.amount):0,M=t=>(t??"").split("/").pop()??"";function T(t,n,e=1,o){let r={item_id:n?.sku||M(n?.id)||M(t.id),item_name:t.title,item_variant:n?.title===nt?void 0:n?.title,item_brand:t.vendor||void 0,item_category:t.productType||void 0,price:ot(n?.price??t.priceRange?.minVariantPrice),quantity:e};return o!=null&&(r.index=o),r}var h=(t,n=t.quantity)=>T(t.merchandise.product,t.merchandise,n);function f(t){let n=t.reduce((e,o)=>e+o.price*(o.quantity||1),0);return Math.round(n*D)/D}var rt=(t,n,e=1)=>({id:t.id,title:t.title,price:n.price,vendor:t.vendor||"",variantId:n.id,variantTitle:n.title,quantity:e,sku:n.sku||void 0,productType:t.productType||void 0}),q=t=>({id:t.id,quantity:t.quantity,merchandise:{id:t.merchandise.id,title:t.merchandise.title,price:t.merchandise.price,sku:t.merchandise.sku,product:{id:t.merchandise.product.id,title:t.merchandise.product.title,vendor:t.merchandise.product.vendor||"",handle:t.merchandise.product.handle}}});function it(){let{dataLayer:t}=a.analytics??{},n=typeof t=="string"?t:"dataLayer",e=Reflect.get(window,n);if(Array.isArray(e))return e;let o=[];return Reflect.set(window,n,o),o}function st(t,n){let e=it();if(!n){e.push({event:t});return}e.push({ecommerce:null}),e.push({event:t,ecommerce:n})}var m=null,v=null,O=null,w=new WeakSet;function d(t,n,e,o){a.analytics?.dataLayer&&st(t,n),m&&e&&m.publish(e,o);try{a.analytics?.onEvent?.(t,n)}catch(r){l(r,"analytics onEvent")}}function F(){let t=document.querySelector(p("product"));return!t||t.closest(`${p("collection")},${p("products")},${p("recommendations")}`)?null:x.get(t)??null}function at({product:t,scope:n}){if(w.has(n.root)||F()!==n)return;w.add(n.root);let e=n.variant??t.variants.nodes[0],o=[T(t,e)],r=e?[rt(t,e)]:[];d("view_item",{currency:e?.price.currencyCode,value:f(o),items:o},"product_viewed",{products:r})}function ct({products:t,collection:n}){let e=t.slice(0,et).map((r,c)=>T(r,r.variants.nodes[0],1,c)),o={item_list_id:n?.handle||"products",item_list_name:n?.title||"Products"};if(!n){d("view_item_list",{...o,items:e});return}d("view_item_list",{...o,items:e},"collection_viewed",{collection:{id:n.id,handle:n.handle}})}function ut(t,n,e){let o=t?.cost.totalAmount.currencyCode;n.forEach((r,c)=>{let i=e.get(c),s=r.quantity-(i?.quantity??0);if(s<=0)return;let u=[h(r,s)];d("add_to_cart",{currency:o,value:f(u),items:u},"product_added_to_cart",{cart:t,prevCart:O,currentLine:q(r),prevLine:i?q(i):void 0})}),e.forEach((r,c)=>{let i=r.quantity-(n.get(c)?.quantity??0);if(i<=0)return;let s=[h(r,i)];d("remove_from_cart",{currency:o,value:f(s),items:s})})}function dt({cart:t,reason:n}){let e=new Map((t?.lines.nodes??[]).map(o=>[o.merchandise.id,o]));v&&n!=="load"&&n!=="pending"&&ut(t,e,v),v=e,O=t}function lt(){let t=b.lines.map(n=>h(n));d("view_cart",{currency:b.state?.cost.totalAmount.currencyCode,value:f(t),items:t})}function pt({cart:t}){if(!t)return;let n=t.lines.nodes.map(o=>h(o)),e=t.discountCodes.filter(o=>o.applicable).map(o=>o.code);d("begin_checkout",{currency:t.cost.totalAmount.currencyCode,value:f(n),coupon:e.join(",")||void 0,items:n})}var ft={"product-ready":at,"list-ready":ct,"cart-updated":dt,"cart-toggled":({open:t})=>{t&<()},checkout:pt,search:({term:t})=>{t&&d("search",{search_term:t},"search_viewed",{searchTerm:t})}};function mt(t,n){ft[n](t.detail)}function B(t){if(t.type==="astro:page-load"){w=new WeakSet,m?.publish("page_viewed",{});return}C.forEach(n=>{E(t,n)&&mt(t,n)})}async function yt(t){a.analytics?.shopify&&(m=await V(()=>F()!=null).catch(n=>(l(n,"shopify analytics"),null))),m?.publish("page_viewed",{}),t.splice(0).forEach(B),t.push=(...n)=>(n.forEach(B),t.length)}function g(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ht(t){return g(t)&&g(t.__core)&&g(t.__parts)}function j(t,n){let e=Reflect.get(window,"Tether");if(!ht(e))throw new Error(`tether.${t}.js runs after the Tether script, which loads it, and needs its window.Tether`);e.__parts[t]=n}j("analytics",k);})();
|
package/dist/tether.diagnose.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
// tether-core:dom.ts
|
|
26
26
|
var m3 = window.Tether.__core["dom.ts"];
|
|
27
|
-
var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m3;
|
|
27
|
+
var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, integerAttribute, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m3;
|
|
28
28
|
|
|
29
29
|
// tether-core:loader.ts
|
|
30
30
|
var m4 = window.Tether.__core["loader.ts"];
|
|
@@ -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,E,$e,Re,Te,Ae,_e]=G;var B=window.Tether.__core["client.ts"],[$,R,Ne,xe,T,Me]=B;var K=window.Tether.__core["dom.ts"],[Oe,p,Ve,Ue,Ce,Ie,qe,m,He,A,Le,Ye,Ge,Be,d,
|
|
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,xe,T,Me]=B;var K=window.Tether.__core["dom.ts"],[Oe,p,Ve,Ue,Ce,Ie,qe,m,He,A,Le,Ye,Ge,Be,Ke,d,Qe,je,l,We,Fe,ze,Je]=K;var Q=window.Tether.__core["loader.ts"],[Ze,_,et,tt,nt]=Q;var j=window.Tether.__core["selling-plans.ts"],[v]=j;var W=window.Tether.__core["status.ts"],[N,st,h,it]=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
|
package/dist/tether.extras.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
// tether-core:dom.ts
|
|
21
21
|
var m2 = window.Tether.__core["dom.ts"];
|
|
22
|
-
var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m2;
|
|
22
|
+
var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, integerAttribute, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m2;
|
|
23
23
|
|
|
24
24
|
// tether-core:product.ts
|
|
25
25
|
var m3 = window.Tether.__core["product.ts"];
|
|
@@ -1 +1 @@
|
|
|
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"],[
|
|
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"],[u,Y,Z,P,I,i,p]=O;var v=window.Tether.__core["dom.ts"],[Q,X,m,ee,y,te,ne,k,w,re,oe,ae,ue,h,ce,S,ie,se,s,le,ge,de,fe]=v;var U=window.Tether.__core["product.ts"],[C]=U;var K=window.Tether.__core["cart.ts"],[d]=K;var H=window.Tether.__core["page-market.ts"],[M]=H;var F=window.Tether.__core["market-codes.ts"],[x,b]=F;var E=()=>`${u.prefix}:market:${u.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),c=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(!c.length)return p("group-add: nothing selected"),null;try{let a=await d.add(c);return y("group-added",{group:n,lines:c},t),a}catch(a){return i(a,"group add"),null}}function j(e){if(e.key===u.storageKey||e.key===`${u.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??""}`,c=_.get(e);if(_.set(e,r),!c||c===r)return;let a=u.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);})();
|