@occluze/tether 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +5 -5
  2. package/dist/esm/astro.js +1 -1
  3. package/dist/esm/chunks/account-FKLGF264.js +1 -0
  4. package/dist/esm/chunks/{account-pages-XR6QZ3DX.js → account-pages-PNORWX72.js} +1 -1
  5. package/dist/esm/chunks/analytics-V24XX2J7.js +1 -0
  6. package/dist/esm/chunks/{chunk-FPJGQ7Z5.js → chunk-2IHA3PVC.js} +1 -1
  7. package/dist/esm/chunks/chunk-2LYWZ72A.js +1 -0
  8. package/dist/esm/chunks/{chunk-A2PCQK2F.js → chunk-2NV5PSJ2.js} +1 -1
  9. package/dist/esm/chunks/chunk-2X5U24IC.js +1 -0
  10. package/dist/esm/chunks/chunk-5B36ISJF.js +1 -0
  11. package/dist/esm/chunks/chunk-6WE7XCHH.js +1 -0
  12. package/dist/esm/chunks/chunk-6ZIOAYKF.js +1 -0
  13. package/dist/esm/chunks/{chunk-FM7ZLLVP.js → chunk-CR5IGHCO.js} +1 -1
  14. package/dist/esm/chunks/{chunk-X2JZPXLF.js → chunk-E3JL6WS3.js} +1 -1
  15. package/dist/esm/chunks/{chunk-COQ6ATC6.js → chunk-F5CLIGSC.js} +1 -1
  16. package/dist/esm/chunks/{chunk-HXZSNZOV.js → chunk-GOKJQGLG.js} +1 -1
  17. package/dist/esm/chunks/chunk-RW23CJDZ.js +1 -0
  18. package/dist/esm/chunks/chunk-TW34GYSL.js +1 -0
  19. package/dist/esm/chunks/chunk-VKKKH75V.js +1 -0
  20. package/dist/esm/chunks/{chunk-A3GXCQJ4.js → chunk-YWQWLKFW.js} +1 -1
  21. package/dist/esm/chunks/chunk-YYNBHXQF.js +1 -0
  22. package/dist/esm/chunks/{diagnose-IFRNCEYG.js → diagnose-3RTKEBNW.js} +1 -1
  23. package/dist/esm/chunks/extras-O54VUXK6.js +1 -0
  24. package/dist/esm/chunks/lists-MRTI5RXY.js +1 -0
  25. package/dist/esm/chunks/markets-ui-P7G33T6Y.js +1 -0
  26. package/dist/esm/chunks/search-YSRDFVD7.js +1 -0
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/server.js +2 -2
  29. package/dist/tether.account-pages.js +2 -2
  30. package/dist/tether.account-pages.min.js +1 -1
  31. package/dist/tether.account.js +2 -2
  32. package/dist/tether.account.min.js +1 -1
  33. package/dist/tether.analytics.js +2 -2
  34. package/dist/tether.analytics.min.js +1 -1
  35. package/dist/tether.diagnose.js +4 -4
  36. package/dist/tether.diagnose.min.js +2 -2
  37. package/dist/tether.extras.js +1 -1
  38. package/dist/tether.extras.min.js +1 -1
  39. package/dist/tether.js +75 -200
  40. package/dist/tether.lists.js +268 -0
  41. package/dist/tether.lists.min.js +1 -0
  42. package/dist/tether.markets.js +3 -3
  43. package/dist/tether.markets.min.js +1 -1
  44. package/dist/tether.min.js +1 -1
  45. package/dist/tether.min.js.map +4 -4
  46. package/dist/tether.search.js +2 -2
  47. package/dist/tether.search.min.js +1 -1
  48. package/dist/types/src/client.d.ts +6 -6
  49. package/dist/types/src/collection.d.ts +7 -23
  50. package/dist/types/src/config-sections.d.ts +7 -0
  51. package/dist/types/src/config.d.ts +6 -0
  52. package/dist/types/src/index.d.ts +4 -3
  53. package/dist/types/src/lazy.d.ts +1 -0
  54. package/dist/types/src/lists.d.ts +20 -0
  55. package/dist/types/src/loader.d.ts +7 -27
  56. package/dist/types/src/mounting.d.ts +1 -6
  57. package/dist/types/src/product-shape.d.ts +13 -36
  58. package/dist/types/src/server.d.ts +5 -4
  59. package/dist/types/src/shopify-values.d.ts +6 -0
  60. package/dist/types/src/storefront/catalog.d.ts +2 -4
  61. package/dist/types/src/version.d.ts +1 -1
  62. package/package.json +5 -5
  63. package/dist/esm/chunks/account-BS5MCC2R.js +0 -1
  64. package/dist/esm/chunks/analytics-BYN3QHBA.js +0 -1
  65. package/dist/esm/chunks/chunk-2IVIZDT5.js +0 -1
  66. package/dist/esm/chunks/chunk-EGIDFV3T.js +0 -1
  67. package/dist/esm/chunks/chunk-EW3GKRT4.js +0 -1
  68. package/dist/esm/chunks/chunk-GXCCTPDF.js +0 -1
  69. package/dist/esm/chunks/chunk-MJFKAMFM.js +0 -1
  70. package/dist/esm/chunks/chunk-TE5PNI76.js +0 -1
  71. package/dist/esm/chunks/extras-3477M6Y7.js +0 -1
  72. package/dist/esm/chunks/markets-ui-3L2UZ7PK.js +0 -1
  73. package/dist/esm/chunks/search-YR73GIWY.js +0 -1
@@ -1 +0,0 @@
1
- import{b as Z,d as Pt,g as Q,h as kt,p as R,v as Et}from"./chunk-2IVIZDT5.js";import{A as W,C as v,D as vt,E as At,F as g,G as k,H as M,K as Lt,P as D,a as b,c as q,d as H,h as V,k as ht,l as L,m as s,n as f,o as yt,p as d,t as y,v as bt,w as P,x as St,y as T,z as wt}from"./chunk-EW3GKRT4.js";import{C as Ct,r as l,x as gt,z as w}from"./chunk-GXCCTPDF.js";var ne={id:"string",quantity:"number",attributes:["object"],cost:{totalAmount:R,subtotalAmount:R,amountPerQuantity:R},merchandise:{id:"string",selectedOptions:["object"],product:"object"}},tt={id:"string",checkoutUrl:"string",totalQuantity:"number",attributes:["object"],discountCodes:["object"],cost:{totalAmount:R,subtotalAmount:R},lines:{nodes:[ne]}};var re='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',ie=60,et=!1,K=null,oe=t=>t!==null&&"focus"in t,It=t=>d(t,re).filter(e=>e.offsetParent!==null||e===document.activeElement),$=()=>d(document,s("cart-drawer")),nt=t=>t.classList.contains(l.cartDrawerOpenClass);function S(){let t=$();return t.length?t.some(nt):et}function j(t){d(document,s("cart-open")).forEach(e=>{e.setAttribute("aria-expanded",String(t))}),$().forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",f(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),!nt(e)&&(e.setAttribute("aria-hidden","true"),l.cartFocus&&(e.inert=!0))})}function ae(t){let e=It(t)[0]??t;e===t&&!t.hasAttribute("tabindex")&&(t.tabIndex=-1),e.focus({preventScroll:!0})}function B(){if(S())return;et=!0;let t=$().filter(n=>f(n,"cart-drawer")!=="manual");t.forEach(n=>{n.inert=!1,n.classList.add(l.cartDrawerOpenClass),n.setAttribute("aria-hidden","false")}),j(!0);let[e]=t;l.cartFocus&&e&&(K=oe(document.activeElement)?document.activeElement:null,setTimeout(()=>{ae(e)},ie)),l.onCartOpen?.(t),y("cart-toggled",{open:!0})}function rt(){if(!S())return;et=!1;let t=$(),e=t.some(n=>n.contains(document.activeElement));t.forEach(n=>{n.classList.remove(l.cartDrawerOpenClass),n.setAttribute("aria-hidden","true"),l.cartFocus&&(n.inert=!0)}),j(!1),e&&K?.isConnected&&K.focus({preventScroll:!0}),K=null,l.onCartClose?.(t),y("cart-toggled",{open:!1})}function xt(){S()?rt():B()}function se(t){if(t.key!=="Tab"||!l.cartFocus||!S())return;let e=$().find(nt);if(!e)return;let n=It(e),r=n[0],i=n.at(-1);if(!r||!i)return;let o=document.activeElement,a=t.shiftKey?o===r:o===i;e.contains(o)&&!a||(t.preventDefault(),(t.shiftKey?i:r).focus())}var ue=/^image:(\d+)$/,Tt="metafield:",ce=/^(rich_text|multi_line_text)_field$/,le=["","true","all","*"],ot=t=>t.tagName==="SELECT",it=(t,e)=>t.$(`select${e}`).filter(ot);function de(t,e){let n=e.images.nodes,r=[...t.children].map(o=>o.tagName==="IMG"?o:o.querySelector("img"));!St(t)&&r.length===n.length&&r.every((o,a)=>bt(o?.getAttribute("src"),n[a]?.url))||T(t,n,(o,a)=>{let u=o.matches(`img,${s("bind","image")}`)?o:d(o,"img")[0]??o;P(u,a.url,a.altText||e.title)})}function me(t,e,n){let r=n.indexOf("."),i=n.slice(0,r),o=n.slice(r+1),a=(e.metafields??[]).find(c=>c?.namespace===i&&c.key===o);if(!a){g(t,"");return}let u=a.reference?.image;if(u){P(t,u.url,u.altText);return}ce.test(a.type)&&(t.style.whiteSpace="pre-line"),g(t,a.value)}var pe=new Map(Object.entries({title:t=>t.title,"description-text":t=>t.description,vendor:t=>t.vendor,type:t=>t.productType,handle:t=>t.handle,"published-at":t=>vt(t.publishedAt),"min-price":t=>v(t.priceRange.minVariantPrice),"max-price":t=>v(t.priceRange.maxVariantPrice)}));function fe(t,e){let n=(t.getAttribute("exclude")??"").split(",").map(i=>i.trim()).filter(Boolean),r=e.tags.filter(i=>!n.includes(i));T(t,r,(i,o)=>{g(i,o)})}function ge(t,e,n){let r=pe.get(e);if(r){g(t,r(n));return}switch(e){case"description":At(t,n.descriptionHtml);break;case"featured-image":P(t,n.featuredImage?.url,n.featuredImage?.altText||n.title);break;case"url":case"link":{let i=W(n.handle,n.id);i&&t.setAttribute("href",i),e==="url"&&!t.firstElementChild&&!t.textContent.trim()&&g(t,n.title);break}case"images":de(t,n);break;case"tags":fe(t,n);break;default:he(t,e,n)}}function he(t,e,n){let r=ue.exec(e);if(r){let i=n.images.nodes[Number(r[1])-1]??n.featuredImage;P(t,i?.url,i?.altText||n.title)}else e.startsWith(Tt)&&me(t,n,e.slice(Tt.length))}function ye(t){let{product:e}=t;t.$(s("option-list")).forEach(n=>{let r=t.optName(f(n,"option-list")),i=e.options.find(o=>o.name===r);if(!i||i.optionValues.length<=1&&yt(n,"hide-single")){M(n,!1);return}T(n,i.optionValues,(o,a)=>{o.setAttribute(L("option-value"),a.name);let u=d(o,s("bind","option-value"))[0];u?g(u,a.name):o.firstElementChild||g(o,a.name);let c=d(o,s("bind","swatch"))[0],{swatch:p}=a;!c||!p||(p.color&&(c.style.backgroundColor=p.color),p.image?.previewImage&&P(c,p.image.previewImage.url,a.name))})})}function Ce(t){let{product:e}=t;it(t,s("option")).forEach(n=>{let r=e.options.find(i=>i.name===t.optName(f(n,"option")));if(!r){M(n,!1);return}n.replaceChildren(...r.optionValues.map(i=>new Option(i.name,i.name)))}),it(t,s("variant-select")).forEach(n=>{n.replaceChildren(...e.variants.nodes.map(r=>new Option(r.title,r.id)))}),it(t,s("plan")).forEach(n=>{let r=t.plans.map(a=>new Option(a.name,a.id)),i=!e.requiresSellingPlan&&f(n,"plan")!=="subscription-only",o=n.getAttribute(L("one-time-label"))||"One-time purchase";n.replaceChildren(...i?[new Option(o,"")]:[],...r)})}function be(t){t.$(s("plan-list")).forEach(e=>{let n=(f(e,"plan-list")??"").trim(),r=le.includes(n.toLowerCase())?null:n,i=t.plans.filter(o=>!r||o.group.name===r);T(e,i,(o,a)=>{o.setAttribute(L("plan-value"),a.id),!o.firstElementChild&&!o.querySelector(s("plan-bind"))&&g(o,a.name)})})}function Xe(t){t.$(s("bind")).forEach(e=>{ge(e,f(e,"bind")??"",t.product)}),ye(t),Ce(t),be(t)}var Mt="Default Title",at=(t,e)=>e.get(t.id)?.quantity??t.quantity,$t=t=>t.split("/").pop()??t;function Se(t){let e=t.merchandise,n=W(e.product.handle,e.product.id);if(!n)return null;let r=new URLSearchParams;r.set("variant",$t(e.id));let i=t.sellingPlanAllocation?.sellingPlan.id;return i&&r.set("selling_plan",$t(i)),`${n}${n.includes("?")?"&":"?"}${r.toString()}`}var Ot=t=>t.merchandise.product.title,Rt={title:Ot,"product-title":Ot,"variant-title":t=>t.merchandise.title===Mt?"":t.merchandise.title,options:t=>t.merchandise.selectedOptions.filter(e=>e.value!==Mt).map(e=>`${e.name}: ${e.value}`).join(", "),vendor:t=>t.merchandise.product.vendor,sku:t=>t.merchandise.sku??"",price:t=>v(t.cost.amountPerQuantity),"compare-at-price":t=>v(t.cost.compareAtAmountPerQuantity??t.merchandise.compareAtPrice),"line-total":t=>v(t.cost.totalAmount),"line-subtotal":t=>v(t.cost.subtotalAmount),quantity:(t,e)=>at(t,e.pending),plan:t=>t.sellingPlanAllocation?.sellingPlan.name??"","plan-description":t=>t.sellingPlanAllocation?.sellingPlan.description??"",components:t=>(t.lineComponents??[]).map(e=>`${e.quantity} \xD7 ${e.merchandise.product.title}`).join(", ")},Ut="attribute:";function we(t,e,n){if(Object.hasOwn(Rt,e))return Rt[e]?.(t,n);if(!e.startsWith(Ut))return;let r=e.slice(Ut.length);return t.attributes.find(i=>i.key===r)?.value??""}function ve(t,e,n){let r=kt(n),i=!n.requiresSellingPlan&&f(t,"line-plan")!=="subscription-only",o={value:"",label:t.getAttribute(L("one-time-label"))||"One-time purchase"},a=[...i?[o]:[],...r.map(c=>({value:c.id,label:c.name}))],u=a.map(c=>c.value).join("|");t.dataset.tetherSig!==u&&(t.replaceChildren(...a.map(c=>{let p=document.createElement("option");return p.value=c.value,p.textContent=c.label,p})),t.dataset.tetherSig=u),t.value=e.sellingPlanAllocation?.sellingPlan.id??"",M(t,r.length>0)}function Ae(t,e,n){let r=!!e.sellingPlanAllocation;t.classList.toggle("is-subscription",r);let i=n.warnings.find(u=>u.target===e.id);t.classList.toggle("is-warning",!!i);let o=n.pending.has(e.id);t.classList.toggle("is-busy",o),o?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),d(t,s("line","warning")).forEach(u=>{k(u,i?.message??"")});let a=new Map([["subscription",r],["one-time",!r],["on-sale",Pt(e.cost.compareAtAmountPerQuantity?.amount,e.cost.amountPerQuantity.amount)],["has-components",(e.lineComponents??[]).length>0],["warning",!!i]]);d(t,s("line-show")).forEach(u=>{let c=f(u,"line-show"),p=c===null?void 0:a.get(c);p!==void 0&&M(u,p)})}function Le(t,e,n){let r=e.merchandise;t.setAttribute(L("line-id"),e.id),d(t,s("line")).forEach(o=>{let a=f(o,"line")??"";if(a==="image"){P(o,r.image?.url??r.product.featuredImage?.url,r.product.title);return}if(a==="url"){let c=Se(e);c&&o.setAttribute("href",c);return}let u=we(e,a,n);u!==void 0&&k(o,u)}),Ae(t,e,n),d(t,s("line-plan")).filter(ot).forEach(o=>{Et(r.product.handle).then(a=>{ve(o,e,a)}).catch(a=>{w(a,"line plan options")})})}function Pe(t,e){let n=t?.totalQuantity??0,r=(t?.lines.nodes??[]).some(o=>o.sellingPlanAllocation),i=new Map([["cart-empty",n===0],["cart-filled",n>0],["cart-has-subscription",r],["cart-no-subscription",!r],["cart-has-discount",(t?.discountCodes??[]).some(o=>o.applicable)],["cart-error",e.failed],["cart-warning",e.warnings.length>0]]);d(document,s("show")).forEach(o=>{let a=f(o,"show"),u=a===null?void 0:i.get(a);u===void 0||o.closest(s("product"))||M(o,u)}),d(document,s("checkout")).forEach(o=>{o.classList.toggle("is-disabled",!n),o.setAttribute("aria-disabled",String(!n))})}function ke(t){d(document,`textarea${s("cart-note")},input${s("cart-note")}`).forEach(e=>{document.activeElement!==e&&g(e,t?.note??"")}),d(document,s("cart-discounts")).forEach(e=>{T(e,t?.discountCodes??[],(n,r)=>{n.setAttribute(L("discount-code"),r.code);let i=n.querySelector(s("discount","code"))??(n.firstElementChild?null:n);i&&g(i,r.code),n.classList.toggle("is-inapplicable",!r.applicable)})})}function qt(t){let{cart:e}=t,n=r=>e?v(e.cost[r]):"";j(S()),d(document,s("cart-count")).forEach(r=>{k(r,e?.totalQuantity??0)}),d(document,s("cart-subtotal")).forEach(r=>{k(r,n("subtotalAmount"))}),d(document,s("cart-total")).forEach(r=>{k(r,n("totalAmount"))}),d(document,s("cart-checkout-charge")).forEach(r=>{k(r,n("checkoutChargeAmount"))}),Pe(e,t),d(document,s("cart-warning")).forEach(r=>{k(r,[...new Set(t.warnings.map(i=>i.message))].join(" "))}),ke(e),d(document,s("cart-lines")).forEach(r=>{wt(r,e?.lines.nodes??[],i=>i.id,(i,o)=>{Le(i,o,t)},{onEnter:l.onLineEnter,onLeave:l.onLineLeave})}),e&&Lt("cart")}function Dt(t){d(document,s("cart-count")).forEach(e=>{/^\s*0?\s*$/.test(e.textContent)&&(e.textContent=String(t))})}function st(t,e="localStorage"){try{return window[e].getItem(t)}catch{return null}}function ut(t,e,n="localStorage"){try{window[n].setItem(t,e)}catch{}}function Qt(t,e="localStorage"){try{window[e].removeItem(t)}catch{}}var Nt=/^gid:\/\/shopify\/Cart\/[\w-]+(\?key=[\w-]+)?$/;var h={kind:"unknown"},U=[],O=new Map,G=()=>h;function m(){switch(h.kind){case"ready":case"error":return h.cart;case"unknown":case"empty":return null}}var Ft=()=>U,ct=t=>t?{kind:"ready",cart:t}:{kind:"empty"},Ht=()=>`${l.storageKey}:seen`;function E(){let t=st(l.storageKey);return t?Nt.test(t)?t:(I(),null):null}function I(){Qt(l.storageKey)}function lt(t){h=ct(t),t&&ut(l.storageKey,t.id)}function N(){qt({cart:m(),warnings:U,pending:O,failed:h.kind==="error"})}function _(t){N(),y("cart-updated",{cart:m(),reason:t})}function C(t,e){return lt(t),ut(Ht(),`${Date.now()}|${t?.totalQuantity??0}`),_(e),t}function F(t){h=t.kind==="loaded"?ct(t.cart):{kind:"error",error:t.error,cart:null},_("load")}function Ee(){let t=st(Ht())?.split("|")[1]??"",e=Number(t);return/^\d+$/.test(t)&&Number.isSafeInteger(e)?e:null}function Vt(){if(h.kind!=="unknown")return;let t=Ee();t!==null&&Dt(t)}function Wt(t){U=t.filter((e,n)=>t.findIndex(r=>r.message===e.message)===n).map(e=>({...e,message:l.warningText?.(e)||e.message})),U.length&&y("cart-warning",{warnings:U})}var _t=()=>{};function Ie(){let t=Promise.resolve();return e=>{let n=t.then(e);return t=n.then(_t,_t),n}}var xe=Ie();function Kt(t){return xe(t).then(e=>(h.kind==="error"&&(h=ct(h.cart),N()),e),e=>{throw h={kind:"error",error:e,cart:m()},N(),y("cart-error",{error:e}),e})}var dt=t=>at(t,O),Te=()=>({open:S(),count:m()?.totalQuantity??0,loaded:h.kind!=="unknown",warnings:[...U]});function jt(t){let e=["cart-updated","cart-toggled"].map(r=>`${l.prefix}:${r}`),n=()=>{t(m(),Te())};return e.forEach(r=>{document.addEventListener(r,n)}),n(),()=>{e.forEach(r=>{document.removeEventListener(r,n)})}}var Me=/does not exist|not found|invalid id/i,$e=t=>H({[t]:q({cart:q(tt)})});function X(t){return t instanceof b?t.userErrors?.some(e=>e.field?.[0]==="cartId")?!0:(t.errors??[]).some(e=>Me.test(e.message)):!1}function Gt(t){if(!(t instanceof b))return!1;let{code:e,status:n=0}=t;return e==="NETWORK"||e==="INVALID_RESPONSE"||e==="SERVER_ERROR"||n>=500}function Xt(t,e=1,n={}){let r=typeof t=="object"&&t!==null?t:{...n,quantity:e,...t==null?{}:{variantId:t}},i=Q.variant(r.merchandiseId||r.variantId||r.id);if(!i)throw new b("add(): variantId is required");let o=parseInt(String(r.quantity??1),10),a={merchandiseId:i,quantity:Math.max(1,o||1)},u=Q.sellingPlan(r.sellingPlanId||r.sellingPlan);u&&(a.sellingPlanId=u);let c=D(r.attributes);return c.length&&(a.attributes=c),a}function Oe(t,e,n){return r=>`mutation Tether_${t}(${e}){${t}(${n}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${Z(r)}`}async function Yt(t,e,n,r){let i=await V(Oe(t,e,n),r,$e(t),{operation:"mutation"}),o=ht(i[t],t);return Wt(o.warnings??[]),o.cart}function Bt(t){let e=l.country?{buyerIdentity:{countryCode:l.country},...t}:t;return Yt("cartCreate","$input: CartInput!","input: $input",{input:e})}async function x({name:t,args:e,inner:n,variables:r,createInput:i}){let o=E();if(!o)return i?Bt(i):null;try{return await Yt(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${n}`,{...r,cartId:o})}catch(a){if(!X(a)||(I(),!i))throw a;return gt("cart expired, creating a new one"),Bt(i)}}async function mt(t){return(await V(n=>`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${Z(n)}`,{id:t},H({cart:q(tt)}))).cart}async function zt(t){return(await V("query TetherCheckout($id:ID!){cart(id:$id){checkoutUrl}}",{id:t},H({cart:q({checkoutUrl:"string"})}))).cart?.checkoutUrl??null}function Jt(t,e){let n=typeof e=="number"?{quantity:e}:e,r={id:t};n.quantity!==void 0&&(r.quantity=n.quantity),"sellingPlanId"in n&&(r.sellingPlanId=n.sellingPlanId?Q.sellingPlan(n.sellingPlanId):null),n.attributes&&(r.attributes=D(n.attributes));let i=n.merchandiseId||n.variantId;return i&&(r.merchandiseId=Q.variant(i)),r}var pt=t=>x({name:"cartLinesUpdate",args:"$lines: [CartLineUpdateInput!]!",inner:"lines: $lines",variables:{lines:t},createInput:null}),Y=t=>x({name:"cartLinesRemove",args:"$lineIds: [ID!]!",inner:"lineIds: $lineIds",variables:{lineIds:t},createInput:null}),Zt=(t,e)=>e>0?pt([{id:t,quantity:e}]):Y([t]);var ft=null;function te(t){ft=t}var Re=t=>zt(t).then(e=>({kind:"url",url:e}),e=>({kind:"failed",error:e}));async function Ue(){if(!ft)return null;try{let t=await ft();return t&&`${t}${t.includes("?")?"&":"?"}logged_in=true`}catch(t){return w(t,"account checkout"),null}}async function qe(t){let e=Re(t),n=await Ue();if(n)return n;let r=await e;if(r.kind==="failed")throw r.error;if(!r.url)throw new b("No checkoutUrl (cart empty or expired)");return r.url}function De(t){try{t.opener=null}catch{}}async function ee(t=l.checkoutTarget){let e=E(),n=m();if(!e||n&&!n.totalQuantity)return null;let r=t==="_blank"?window.open("","_blank"):null;r&&De(r);try{let i=await qe(e);if(!Ct(i))throw new b("The checkout URL is not https: not opened");return y("checkout",{url:i,cart:m()}),r&&!r.closed?r.location.href=i:window.location.href=i,i}catch(i){return r?.close(),w(i,"checkout failed"),null}}var J=()=>m()?.lines.nodes??[];async function Qe(){let t=E();if(t)try{let e=await mt(t);e||I(),C(e,"load")}catch(e){w(e,"cart reload after a failed change")}}function A(t){return Kt(()=>t().catch(async e=>{throw Gt(e)&&await Qe(),e}))}function Ne(t,e){let n=J().find(u=>u.id===t);if(!n)return Promise.resolve(m());let r=Math.max(0,dt(n)+e),i={quantity:r};O.set(t,i),_("pending");let o=()=>O.get(t)===i;return A(async()=>{if(!o())return m();if(J().find(p=>p.id===t)?.quantity===r)return m();let c=await Zt(t,r);return o()?C(c,r>0?"update":"remove"):(lt(c),c)}).finally(()=>{o()&&(O.delete(t),_("settled"))})}function _e(t){let e=(m()?.discountCodes??[]).map(r=>r.code),n=typeof t=="function"?t(e):t;return(Array.isArray(n)?n:[n]).map(r=>r.trim()).filter(Boolean)}function Fe(t){let e=new Map((m()?.attributes??[]).map(n=>[n.key,n.value]));return D(t).forEach(n=>e.set(n.key,n.value)),[...e].filter(([,n])=>n!=="").map(([n,r])=>({key:n,value:r}))}async function He(){let t=E();if(!t)return F({kind:"loaded",cart:null}),null;Vt();try{let e=await mt(t);e||I(),F({kind:"loaded",cart:e})}catch(e){w(e,"cart load failed"),X(e)&&I(),F({kind:"failed",error:e})}return m()}var z={init:He,id:E,get status(){return G()},get state(){return m()},get lines(){return[...J()]},get count(){return m()?.totalQuantity??0},get loaded(){return G().kind!=="unknown"},get lastError(){let t=G();return t.kind!=="error"?null:t.error instanceof Error?t.error:new Error(String(t.error))},get warnings(){return[...Ft()]},get pendingQty(){return O},setCheckoutResolver:te,forgetSaved(){I(),F({kind:"loaded",cart:null})},render:N,subscribe:jt,add(t,e=1,n={}){let r=(Array.isArray(t)?t:[t]).map(i=>Xt(i,e,n));return A(async()=>{let i=await x({name:"cartLinesAdd",args:"$lines: [CartLineInput!]!",inner:"lines: $lines",variables:{lines:r},createInput:{lines:r}});if(!i)throw new b("Shopify answered the add without a cart");return C(i,"add"),y("added",{cart:i,lines:r}),l.openCartOnAdd&&B(),i})},updateLine(t,e){let n=typeof e=="number"?e:e.quantity;if(n!==void 0&&n<=0)return z.removeLine(t);let r=Jt(t,e);return A(async()=>C(await pt([r]),"update"))},changeQuantity:Ne,quantityOf:dt,removeLine(t){let e=Array.isArray(t)?t:[t];return A(async()=>C(await Y(e),"remove"))},clear(){return A(async()=>{let t=J().map(e=>e.id);return t.length?C(await Y(t),"remove"):m()})},setNote(t){let e={note:t??""};return A(async()=>C(await x({name:"cartNoteUpdate",args:"$note: String!",inner:"note: $note",variables:e,createInput:e}),"note"))},setAttributes(t){return A(async()=>{let e={attributes:Fe(t)},n=await x({name:"cartAttributesUpdate",args:"$attributes: [AttributeInput!]!",inner:"attributes: $attributes",variables:e,createInput:e});return C(n,"attributes")})},setDiscountCodes(t){return A(async()=>{let e={discountCodes:_e(t)},n=await x({name:"cartDiscountCodesUpdate",args:"$discountCodes: [String!]!",inner:"discountCodes: $discountCodes",variables:e,createInput:e});return C(n,"discount")})},async applyDiscount(t){let e=await z.setDiscountCodes(i=>[...new Set([...i,t])]),n=t.toLowerCase();if((e?.discountCodes??[]).find(i=>i.code.toLowerCase()===n)?.applicable)return e;try{await z.removeDiscount(t)}catch(i){w(i,"removing a discount code Shopify refused")}throw new b(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let e=t.toLowerCase();return z.setDiscountCodes(n=>n.filter(r=>r.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return A(async()=>{let n=await x({name:"cartBuyerIdentityUpdate",args:"$buyerIdentity: CartBuyerIdentityInput!",inner:"buyerIdentity: $buyerIdentity",variables:{buyerIdentity:t},createInput:e?{buyerIdentity:t}:null}).catch(r=>{if(e||!X(r))throw r;return null});return C(n,"buyer-identity")})},checkout:ee,drawers:$,isOpen:S,open:B,close:rt,toggle:xt};export{se as a,ot as b,it as c,Xe as d,st as e,ut as f,Qt as g,z as h};
@@ -1 +0,0 @@
1
- import{a as k,b as z,c as B}from"./chunk-A2PCQK2F.js";import{b as g,d as y,g as l}from"./chunk-A3GXCQJ4.js";import{D as _,E as J,r as D,v as U,x as W,y as Q,z as Y}from"./chunk-2IVIZDT5.js";import{E as K,F as C,H as w,K as F,M as q,a as H,l as u,m as c,n as s,o as P,p as N,q as A,t as d,w as O,y as I}from"./chunk-EW3GKRT4.js";import{b as m,d as M,o as b,p as $,r as p,x as v,y as x,z as h}from"./chunk-GXCCTPDF.js";var j="url:",T=()=>`${c("collection")},${c("products")},${c("recommendations")}`,et=t=>t instanceof window.Element,G=t=>parseInt(t??"",10)||void 0,ot=t=>t==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",V=class{constructor(e){m(this,"root");m(this,"products",[]);m(this,"pageInfo",null);m(this,"collection",null);m(this,"loadToken",0);this.root=e,l(e,"loading"),e.addEventListener("click",o=>{if(!et(o.target))return;let n=o.target.closest(c("load-more"));n?.closest(T())===e&&(o.preventDefault(),q(n,()=>this.load(!0)))})}$(e){return A(this.root,e,T())}options(){let{root:e}=this,o={reverse:s(e,"reverse")==="true"},n=G(s(e,"limit"));n&&(o.first=n);let r=s(e,"sort");if(r&&(o.sortKey=r),P(e,"collection"))return o.collection=s(e,"collection")??"",o;let i=s(e,"products")??"";return o.query=i.startsWith(j)?new URL(window.location.href).searchParams.get(i.slice(j.length))||"":i,o}async loadRecommendations(){let{key:e}=g(this.root,window.location,"recommendations"),o=this.root.closest(c("product"));if(!e&&o&&({key:e}=g(o)),!e)throw new H("No product for recommendations",{code:"NOT_FOUND"});return J(e,ot(s(this.root,"intent")))}async load(e=!1){this.loadToken+=1;let o=this.loadToken,n=()=>o!==this.loadToken;try{if(P(this.root,"recommendations")){let r=await this.loadRecommendations();if(n())return;let i=G(s(this.root,"limit"));this.products=i?r.slice(0,i):r}else{let r=await _({...this.options(),after:e?this.pageInfo?.endCursor??null:null});if(n())return;this.collection=r.collection,this.pageInfo=r.pageInfo,this.products=e?[...this.products,...r.products]:r.products}this.render(),l(this.root,"ready"),d("list-ready",{products:this.products,collection:this.collection},this.root)}catch(r){if(n())return;e||l(this.root,y(r)?"not-found":"error",r),y(r)&&P(this.root,"recommendations")||h(r,"list load failed"),d("error",{error:r,context:"list"},this.root)}}render(){let{collection:e}=this;this.$(c("collection-bind")).forEach(n=>{switch(s(n,"collection-bind")??""){case"title":C(n,e?.title??"");break;case"description":K(n,e?.descriptionHtml);break;case"image":O(n,e?.image?.url,e?.image?.altText||e?.title);break;case"count":C(n,this.products.length);break}}),this.$(c("list")).forEach(n=>{I(n,this.products,(r,i)=>{r.setAttribute(u("product"),i.handle),r.removeAttribute(u("state"))}),d("list-rendered",{container:n},this.root)});let o=this.products.length===0;this.$(c("show")).forEach(n=>{let r=s(n,"show");r==="list-empty"&&w(n,o),r==="list-filled"&&w(n,!o)}),this.$(c("load-more")).forEach(n=>{w(n,!!this.pageInfo?.hasNextPage)}),F("list")}};var rt='script[type="application/json"][data-tether-hydrate]',L=new WeakSet,Ht=new WeakSet,E=new Set,X=new Set,Z=new WeakMap;function nt(){E.forEach(t=>{t.isConnected||E.delete(t)}),X.forEach(t=>{t.root.isConnected||X.delete(t)})}function it(t,e){return[...t.matches?.(e)?[t]:[],...N(t,e)]}function st(t,e){let o=s(t,"page-title");!o||typeof document>"u"||(document.title=o.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function ct(t,{fromUrl:e,raw:o}){e?(L.add(t),l(t,"not-found"),d("product-not-found",{key:null,source:o},t)):t.closest(T())||x(`[${u("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t)}function at(t,e,{fromUrl:o,raw:n},r){let i=y(r);if(l(t,i?"not-found":"error",r),!i){h(r,`product ${e}`),d("error",{error:r,context:"product",key:e},t);return}d("product-not-found",{key:e,source:n},t),o?v(`product not found: ${e}`):h(r,`product ${e}`)}function ut(t){if(L.has(t))return!1;let{key:e,...o}=g(t);if(!e)return ct(t,o),!1;L.add(t),E.add(t);let n={};Z.set(t,n);let r=()=>Z.get(t)===n;return k.get(t)?t.setAttribute(u("state"),"updating"):l(t,"loading"),mt(U(e)).then(f=>{if(!r())return;let R=k.get(t);R?R.update(f):new B(t,f),st(t,f),p.revalidate&&Q(e)&&dt(e)}).catch(f=>{r()&&at(t,e,o,f)}),!0}function Nt(){nt(),E.forEach(t=>{t.getAttribute(u("state"))!=="error"||t.getAttribute(u("error"))==="not-found"||(L.delete(t),ut(t))})}var S=new Set;function dt(t){S.size||setTimeout(ft,0),S.add(t)}function lt(t,e){E.forEach(o=>{let n=k.get(o);if(!n||!o.isConnected)return;let r=g(o).key;r!==t&&r!==e.handle&&r!==e.id||JSON.stringify(n.product)!==JSON.stringify(e)&&n.update(e)})}function ft(){let t=[...S];S=new Set,t.forEach(e=>{Y(e).then(o=>{lt(e,o)}).catch(o=>{h(o,`refresh ${e}`)})})}var a=null,mt=t=>(a?.add(t),t);function pt(){if(!a)return;let t=[...a];Promise.allSettled(t).then(()=>{if(!(!a||t.some(e=>!a?.has(e)))){if(t.length!==a.size){pt();return}a=null,document.documentElement.classList.remove(`${p.prefix}-market-pending`)}})}function ht(t){if(!M(t))return{country:void 0,language:void 0,products:[]};let{products:e}=t,o=Array.isArray(e)?e:[];return{country:b(t.country)??void 0,language:$(t.language)??void 0,products:o.filter(D)}}var tt=new WeakSet;function At(t=document){it(t,rt).forEach(e=>{if(tt.has(e))return;tt.add(e);let o;try{o=JSON.parse(e.textContent)}catch(f){x("bad data-tether-hydrate",f);return}let{country:n,language:r,products:i}=ht(o);if(z(i),n===p.country&&r===p.language){W(i);return}v("hydration skipped: other market"),a||(a=new Set,document.documentElement.classList.add(`${p.prefix}-market-pending`))})}export{T as a,V as b,L as c,Ht as d,E as e,X as f,nt as g,it as h,ut as i,Nt as j,mt as k,pt as l,At as m};
@@ -1 +0,0 @@
1
- import{c as v}from"./chunk-COQ6ATC6.js";import{a as b,b as S}from"./chunk-HXZSNZOV.js";import{a as k}from"./chunk-A2PCQK2F.js";import"./chunk-FPJGQ7Z5.js";import"./chunk-A3GXCQJ4.js";import"./chunk-EGIDFV3T.js";import{h as p}from"./chunk-MJFKAMFM.js";import"./chunk-2IVIZDT5.js";import{N as h,O as w,m as l,n as f,o as g,p as d,t as y}from"./chunk-EW3GKRT4.js";import{r as s,y as m,z as u}from"./chunk-GXCCTPDF.js";function U(t,r){let e=w(h(t,"line-attributes"));return r?[{key:"_group",value:r},...e]:e}async function V(t){let r=t.closest(l("group"));if(!r)return null;let e=f(r,"group"),n=U(r,e),i=d(r,l("product")).flatMap(a=>{let o=k.get(a);if(!o?.variant?.availableForSale||o.quantity<=0)return[];let c=o.getLine();return c?[{...c,attributes:[...c.attributes??[],...n]}]:[]});if(!i.length)return m("group-add: nothing selected"),null;try{let a=await p.add(i);return y("group-added",{group:e,lines:i},r),a}catch(a){return u(a,"group add"),null}}function _(t){if(t.key===s.storageKey||t.key===`${s.storageKey}:seen`){p.init().catch(n=>{u(n,"cart from another tab")});return}if(t.key!==b()||!t.newValue)return;let r=S(t.newValue);if(!r)return;let e={language:r.language??null,locale:r.locale,remember:!1};v(r.country,e).catch(n=>{u(n,"market from another tab")})}var E=new WeakMap,K=t=>t.split("/").pop()??t;function x(t){try{window.history.replaceState(window.history.state,"",t)}catch{}}function $(t,{variant:r,sellingPlanId:e}){let n=`${r.id}|${e??""}`,i=E.get(t);if(E.set(t,n),!i||i===n)return;let a=s.variantUrl&&document.querySelector(l("product"))===t;if(!g(t,"variant-url")&&!a)return;let o=new URL(window.location.href);o.searchParams.set("variant",K(r.id)),e?o.searchParams.set("selling_plan",K(e)):o.searchParams.delete("selling_plan"),x(o)}export{V as addGroup,_ as onStorage,$ as writeVariantUrl};
@@ -1 +0,0 @@
1
- import{a as E,c as P,e as k,f as T,g as A,h as p,i as x}from"./chunk-TE5PNI76.js";import{d as F,e as I}from"./chunk-HXZSNZOV.js";import"./chunk-A2PCQK2F.js";import"./chunk-FPJGQ7Z5.js";import"./chunk-A3GXCQJ4.js";import{h as u}from"./chunk-MJFKAMFM.js";import{w}from"./chunk-2IVIZDT5.js";import{a as L,d as h,h as b,l as s,m as C,n as v,t as z}from"./chunk-EW3GKRT4.js";import{o as f,p as g,r as a,z as y}from"./chunk-GXCCTPDF.js";var _="{name} ({currency})",j="name",d=null;function B(){d=null}var D="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}",O={isoCode:"string",name:"string",currency:"object"},H=h({localization:{country:O,availableCountries:[O]}});function R(){return d??(d=b(D,{},H).then(e=>e.localization,e=>{throw d=null,e})),d}function U(e,n){switch(n){case"name":return e.name;case"code":return e.isoCode;case"currency":return e.currency.isoCode;case"symbol":return e.currency.symbol;default:return""}}var Y=(e,n)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,i)=>U(n,i));function q(e,n,o){let i=e.getAttribute(s("country-label"))||_,r=(e.getAttribute(s("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),c=r.length?r.map(t=>n.find(l=>l.isoCode===t)).filter(t=>t!==void 0):n;e.replaceChildren(...c.map(t=>new Option(Y(i,t),t.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=c.length<2&&!e.hasAttribute(s("always-enabled"))}function $(e,n,o){let i=(a.country||o.country.isoCode).toUpperCase(),r=[...o.availableCountries].sort((t,l)=>t.name.localeCompare(l.name,a.locale||void 0)),c=r.find(t=>t.isoCode===i)??o.country;e.forEach(t=>{q(t,r,i)}),n.forEach(t=>{t.textContent=U(c,v(t,"country-bind")||j)})}function S(e=document){let n=p(e,`select${C("country-select")}`),o=p(e,C("country-bind"));return!n.length&&!o.length?Promise.resolve():R().then(i=>{$(n,o,i)}).catch(i=>{y(i,"country select")})}var Q=e=>Object.values(a.markets?.locales??{}).find(n=>f(n.country)===e);function V(e,n){return e!==void 0?g(e):n?n.language?g(n.language):void 0:a.language}function Z(e){w();let n=[];return u.id()&&n.push(u.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{y(o,"cart country")})),A(),T.forEach(o=>n.push(o.load())),k.forEach(o=>{o.closest(E())||(P.delete(o),x(o))}),n}async function re(e,{language:n,locale:o,remember:i=!0}={}){let r=f(e);if(!r)throw new L(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let c=Q(r),t=o||c?.locale,l=t||a.locale,m=V(n,c),M=r!==a.country||m!==a.language||l!==a.locale;if(a.country=r,a.language=m||void 0,a.locale=l,i&&I({country:r,language:m,locale:t}),!M)return S(),u.state;n!==void 0&&B();let N=Z(r);return S(),z("country-changed",{country:r,language:a.language}),await Promise.all(N),u.state}export{F as detectMarket,R as getLocalization,S as renderCountrySelects,re as setCountry};
@@ -1 +0,0 @@
1
- import{h as M}from"./chunk-TE5PNI76.js";import"./chunk-A2PCQK2F.js";import"./chunk-FPJGQ7Z5.js";import"./chunk-A3GXCQJ4.js";import"./chunk-MJFKAMFM.js";import"./chunk-2IVIZDT5.js";import{A as x,C,F as q,H as d,c as S,d as E,h as T,l as A,m as o,n as m,p as h,t as I,w as L,y as w}from"./chunk-EW3GKRT4.js";import{b as a,r as u,x as b,z as y}from"./chunk-GXCCTPDF.js";var N=E({predictiveSearch:S({products:[{priceRange:"object"}],collections:["object"],queries:[{text:"string"}]})}),U="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",D=6,V=2,F="/search",R=new WeakSet,v=0;function $(s,t,e){return parseInt(m(s,t)||"",10)||e}var H=s=>s.tagName==="A"?s:s.querySelector("a");function p(s,t){h(s,o("search-bind")).forEach(e=>{let i=m(e,"search-bind");i==="image"?L(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&q(e,t[i])})}function k(s,t){let e=H(s);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var f=class{constructor(t,e,i){a(this,"root");a(this,"input");a(this,"results");a(this,"limit");a(this,"minCharacters");a(this,"resultsId");a(this,"searchNumber",0);a(this,"timer");a(this,"lastTerm","");a(this,"cache",new Map);this.root=t,this.input=e,this.results=i,this.limit=$(t,"search-limit",D),this.minCharacters=$(t,"search-min",V),i.id||(v+=1,i.id=`${u.prefix}-search-${v}`),this.resultsId=i.id,this.setUpAria(),this.listen()}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){this.input.addEventListener("input",()=>{let t=this.input.value.trim();t!==this.lastTerm&&(this.lastTerm=t,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(t),u.searchDelay))}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)}),this.input.addEventListener("keydown",t=>{this.onKeydown(t)}),document.addEventListener("click",t=>{this.root.contains(t.target)||this.open(!1)})}setState(t){this.root.setAttribute(A("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return h(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let i=await T(U,{q:t,limit:this.limit},N);return this.cache.set(t,i.predictiveSearch),i.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let i=await this.fetchResults(t);e===this.searchNumber&&this.render(i,t)}catch(i){if(e!==this.searchNumber){b("a superseded search failed",i);return}this.setState("error"),y(i,"search")}}fillList(t,e,i){h(this.results,o(t)).forEach(l=>{w(l,e,i),d(l,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||F,i=e.includes("?")?"&":"?";return`${e}${i}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let i=t?.products??[],l=t?.collections??[],c=(t?.queries??[]).filter(n=>n.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(n,r)=>{let P=C(r.priceRange.minVariantPrice);p(n,{title:r.title,price:P,image:r.featuredImage}),k(n,x(r.handle,r.id)),n.classList.toggle("is-sold-out",!r.availableForSale)}),this.fillList("search-collections",l,(n,r)=>{p(n,{title:r.title,image:r.image}),k(n,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${r.handle}`)}),this.fillList("search-queries",c,(n,r)=>{p(n,{text:r.text}),H(n)?.setAttribute("href",this.queryUrl(r.text))});let g=i.length+l.length+c.length;this.showCount(g),this.setState(g?"ready":"empty"),this.open(!0),I("search",{term:e,products:i,collections:l,queries:c},this.root)}showCount(t){h(this.root,o("show")).forEach(e=>{let i=m(e,"show");i==="search-empty"&&d(e,t===0),i==="search-results"&&d(e,t>0)}),this.options().forEach((e,i)=>{e.id||(e.id=`${this.resultsId}-${i}`),e.setAttribute("aria-selected","false")})}highlight(t,e){t.forEach((l,c)=>{l.setAttribute("aria-selected",String(c===e))});let i=t[e];i&&(this.input.setAttribute("aria-activedescendant",i.id),i.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),i=e.findIndex(l=>l.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(i+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,i<=0?e.length-1:i-1)):t.key==="Enter"&&i>=0?(t.preventDefault(),e[i]?.click()):t.key==="Escape"&&this.open(!1)}};function j(s=document){for(let t of M(s,o("search"))){if(R.has(t))continue;R.add(t);let e=t.querySelector(o("search-input"))??t.querySelector("input"),i=t.querySelector(o("search-results"));e&&i&&new f(t,e,i)}}export{j as mountSearch};