@swishapp/sdk 0.130.0 → 0.131.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/state/item-context-signal.d.ts +8 -1
- package/dist/state/item-state-signal.d.ts +31 -3
- package/dist/swish.d.ts +11 -2
- package/dist/swish.js +29 -29
- package/package.json +1 -1
package/dist/swish.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
1
|
+
var No=Object.create;var Hn=Object.defineProperty;var Uo=Object.getOwnPropertyDescriptor;var $o=Object.getOwnPropertyNames;var Vo=Object.getPrototypeOf,Ho=Object.prototype.hasOwnProperty;var r=(e,t)=>Hn(e,"name",{value:t,configurable:!0});var Qo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var zo=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of $o(t))!Ho.call(e,s)&&s!==n&&Hn(e,s,{get:()=>t[s],enumerable:!(i=Uo(t,s))||i.enumerable});return e};var Go=(e,t,n)=>(n=e!=null?No(Vo(e)):{},zo(t||!e||!e.__esModule?Hn(n,"default",{value:e,enumerable:!0}):n,e));var ko=Qo((kI,Ro)=>{"use strict";var sd=(function(){function e(n,i){if(typeof n!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+n+"."));this._batchLoadFn=n,this._maxBatchSize=ld(i),this._batchScheduleFn=cd(i),this._cacheKeyFn=ud(i),this._cacheMap=dd(i),this._batch=null,this.name=pd(i)}r(e,"DataLoader");var t=e.prototype;return t.load=r(function(i){if(i==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(i)+"."));var s=od(this),o=this._cacheMap,a;if(o){a=this._cacheKeyFn(i);var l=o.get(a);if(l){var c=s.cacheHits||(s.cacheHits=[]);return new Promise(function(u){c.push(function(){u(l)})})}}s.keys.push(i);var d=new Promise(function(u,p){s.callbacks.push({resolve:u,reject:p})});return o&&o.set(a,d),d},"load"),t.loadMany=r(function(i){if(!Eo(i))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+i+"."));for(var s=[],o=0;o<i.length;o++)s.push(this.load(i[o]).catch(function(a){return a}));return Promise.all(s)},"loadMany"),t.clear=r(function(i){var s=this._cacheMap;if(s){var o=this._cacheKeyFn(i);s.delete(o)}return this},"clear"),t.clearAll=r(function(){var i=this._cacheMap;return i&&i.clear(),this},"clearAll"),t.prime=r(function(i,s){var o=this._cacheMap;if(o){var a=this._cacheKeyFn(i);if(o.get(a)===void 0){var l;s instanceof Error?(l=Promise.reject(s),l.catch(function(){})):l=Promise.resolve(s),o.set(a,l)}}return this},"prime"),e})(),rd=typeof process=="object"&&typeof process.nextTick=="function"?function(e){Qi||(Qi=Promise.resolve()),Qi.then(function(){process.nextTick(e)})}:typeof setImmediate=="function"?function(e){setImmediate(e)}:function(e){setTimeout(e)},Qi;function od(e){var t=e._batch;if(t!==null&&!t.hasDispatched&&t.keys.length<e._maxBatchSize)return t;var n={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=n,e._batchScheduleFn(function(){ad(e,n)}),n}r(od,"getCurrentBatch");function ad(e,t){if(t.hasDispatched=!0,t.keys.length===0){Gi(t);return}var n;try{n=e._batchLoadFn(t.keys)}catch(i){return zi(e,t,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(i)+".")))}if(!n||typeof n.then!="function")return zi(e,t,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise: "+String(n)+".")));n.then(function(i){if(!Eo(i))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(i)+"."));if(i.length!==t.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys."+(`
|
|
2
2
|
|
|
3
3
|
Keys:
|
|
4
4
|
`+String(t.keys))+(`
|
|
5
5
|
|
|
6
6
|
Values:
|
|
7
|
-
`+String(i)));$i(t);for(var s=0;s<t.callbacks.length;s++){var o=i[s];o instanceof Error?t.callbacks[s].reject(o):t.callbacks[s].resolve(o)}}).catch(function(i){Ni(e,t,i)})}r(Ku,"dispatchBatch");function Ni(e,t,n){$i(t);for(var i=0;i<t.keys.length;i++)e.clear(t.keys[i]),t.callbacks[i].reject(n)}r(Ni,"failedDispatch");function $i(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}r($i,"resolveCacheHits");function Wu(e){var t=!e||e.batch!==!1;if(!t)return 1;var n=e&&e.maxBatchSize;if(n===void 0)return 1/0;if(typeof n!="number"||n<1)throw new TypeError("maxBatchSize must be a positive number: "+n);return n}r(Wu,"getValidMaxBatchSize");function Xu(e){var t=e&&e.batchScheduleFn;if(t===void 0)return zu;if(typeof t!="function")throw new TypeError("batchScheduleFn must be a function: "+t);return t}r(Xu,"getValidBatchScheduleFn");function Ju(e){var t=e&&e.cacheKeyFn;if(t===void 0)return function(n){return n};if(typeof t!="function")throw new TypeError("cacheKeyFn must be a function: "+t);return t}r(Ju,"getValidCacheKeyFn");function Yu(e){var t=!e||e.cache!==!1;if(!t)return null;var n=e&&e.cacheMap;if(n===void 0)return new Map;if(n!==null){var i=["get","set","delete","clear"],s=i.filter(function(o){return n&&typeof n[o]!="function"});if(s.length!==0)throw new TypeError("Custom cacheMap missing methods: "+s.join(", "))}return n}r(Yu,"getValidCacheMap");function Zu(e){return e&&e.name?e.name:null}r(Zu,"getValidName");function yo(e){return typeof e=="object"&&e!==null&&typeof e.length=="number"&&(e.length===0||e.length>0&&Object.prototype.hasOwnProperty.call(e,e.length-1))}r(yo,"isArrayLike");vo.exports=Qu});function Ki(e,t="",n=new Map){for(let[i,s]of Object.entries(e)){let o=t?`${t}.${i}`:i;typeof s=="object"&&s!==null?Ki(s,o,n):typeof s=="string"&&n.set(o,s)}return n}r(Ki,"c");var Fo=new Set(["en"]),nt="en";function Wi(e,t){return t?.count===void 0?e:t.count===1?`${e}One`:`${e}Other`}r(Wi,"d");function Gi(e,t,n){t=Wi(t,n);let i=e.get(t)??t;return n&&(n.count!==void 0&&(i=i.replace("{{count}}",n.count.toString())),Object.entries(n).forEach(([s,o])=>{s!=="count"&&typeof o=="string"&&(i=i.replace(`{{${s}}}`,o))})),i}r(Gi,"f");function Xi(e,t){let n=null;async function i(o){let a=await import(`${e}/locales/${o.toLowerCase()}.js`);return Ki(a.default)}r(i,"a");function s(o,a){return n?n.has(Wi(o,a))?{status:"ready",value:Gi(n,o,a),key:o}:{status:"missing",value:Gi(n,o,a),key:o}:{status:"pending",value:o,key:o}}return r(s,"r"),{t(o,a){return s(o,a).value},resolveTranslation:s,async loadLocale(o){let a=o;Fo.has(o)||(console.warn(`[swish] Unsupported language "${o}", falling back to "${nt}".`),a=nt);let l;try{l=await i(a)}catch(c){if(console.warn(`[swish-i18n] Failed to load locale "${a}".`,c),a!==nt)try{l=await i(nt)}catch{console.warn(`[swish] Failed to load fallback locale "${nt}".`);return}else return}if(t?.[a])for(let[c,p]of Object.entries(t[a]))p!==void 0&&l.set(c,p);n=l}}}r(Xi,"L");var N=r(e=>e.split("/").pop()??"","shopifyGidToId"),Pe=r((e,t)=>`gid://shopify/${e}/${t}`,"shopifyIdToGid"),he=r(e=>e.toLowerCase().replace(".myshopify.com",""),"toShopName");var Ae=class{constructor(t,n,i=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.clearCachePromise=null;this.cacheName=t,this.defaultCacheControl=n,this.keyPrefix=i}static{r(this,"FetchCache")}async get(t){try{let n=await caches.open(this.cacheName),i=await n.match(t);if(i&&this.isExpired(i)){await n.delete(t);return}return i}catch(n){console.warn("Cache get error:",n);return}}async set(t,n,i){try{if(i?.includes("no-cache"))return;let s=this.createCacheableResponse(n,i);await(await caches.open(this.cacheName)).put(t,s)}catch(s){console.warn("Cache set error:",s)}}async fetchWithCache(t,n,i){let s=await this.getCacheKey(t,n);if(this.clearCachePromise&&await this.clearCachePromise,this.inFlightRequests.has(s))return this.inFlightRequests.get(s).then(a=>a.clone());let o=(async()=>{let a=await this.get(s);if(a)return this.isStaleButRevalidatable(a)&&this.revalidateInBackground(s,t,n,i),a.clone();let l=await fetch(t,n);return l.ok&&await this.set(s,l.clone(),i??this.defaultCacheControl),l})().finally(()=>{this.inFlightRequests.delete(s)});return this.inFlightRequests.set(s,o),o}async delete(t){try{return await(await caches.open(this.cacheName)).delete(t)}catch(n){return console.warn("Cache delete error:",n),!1}}async clear(){return this.clearCachePromise?this.clearCachePromise:(this.clearCachePromise=new Promise(async(t,n)=>{try{let i=await caches.open(this.cacheName),s=await i.keys();await Promise.all(s.map(o=>i.delete(o))),t()}catch(i){console.warn("Cache clear error:",i),n(i)}}),this.clearCachePromise.then(()=>{this.clearCachePromise=null}).catch(t=>{console.warn("Cache clear error:",t)}))}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(i=>i.url)}catch(t){return console.warn("Cache keys error:",t),[]}}async has(t){try{let n=await caches.open(this.cacheName),i=await n.match(t);return i&&this.isExpired(i)?(await n.delete(t),!1):i!==void 0}catch(n){return console.warn("Cache has error:",n),!1}}async getStats(){try{return{total:(await(await caches.open(this.cacheName)).keys()).length}}catch(t){return console.warn("Cache stats error:",t),{total:0}}}async cleanupExpiredEntries(){try{let t=await caches.open(this.cacheName),n=await t.keys(),i=0;for(let o of n){let a=await t.match(o);a&&this.isExpired(a)&&(await t.delete(o),i++)}let s=n.length-i;return{removed:i,remaining:s}}catch(t){return console.warn("Cache cleanup error:",t),{removed:0,remaining:0}}}async getCacheKey(t,n){let i=this.getInputUrl(t),s=`${this.keyPrefix}${i}/${JSON.stringify(n)}`,a=new TextEncoder().encode(s),l=await crypto.subtle.digest("SHA-256",a);return`/${Array.from(new Uint8Array(l)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}getInputUrl(t){return t instanceof URL?t.toString():typeof t=="string"?t:t.url}isExpired(t){let n=t.headers.get("Cache-Control");if(!n)return!1;let i=this.parseMaxAge(n),s=this.parseStaleWhileRevalidate(n);if(i===null)return!1;let o=t.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3,p=i+(s??0);return c>p}isStaleButRevalidatable(t){let n=t.headers.get("Cache-Control");if(!n)return!1;let i=this.parseMaxAge(n),s=this.parseStaleWhileRevalidate(n);if(i===null||s===null)return!1;let o=t.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3;return c>i&&c<=i+s}async revalidateInBackground(t,n,i,s){if(this.revalidationPromises.has(t))return;let o=(async()=>{try{let a=await fetch(n,i);a.ok&&await this.set(t,a.clone(),s??this.defaultCacheControl)}catch(a){console.warn("Background revalidation error:",a)}finally{this.revalidationPromises.delete(t)}})();this.revalidationPromises.set(t,o)}parseMaxAge(t){let n=new RegExp(/max-age=(\d+)/).exec(t);return n?parseInt(n[1],10):null}parseStaleWhileRevalidate(t){let n=new RegExp(/stale-while-revalidate=(\d+)/).exec(t);return n?parseInt(n[1],10):null}createCacheableResponse(t,n){let i=new Headers(t.headers);return i.set("Cache-Control",n),i.has("Date")||i.set("Date",new Date().toUTCString()),new Response(t.body,{status:t.status,statusText:t.statusText,headers:i})}};var wt=class{static{r(this,"AjaxApiClient")}constructor(t){this.config=t;let n=he(t.storeDomain);this.cache=new Ae(`ajax-api-${n}`,"max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(i=>{console.warn("Ajax API cache initialization cleanup error:",i)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let t=window.fetch,n=this.config.responseInterceptor,i=this.getFetchRequest.bind(this);window.fetch=function(...s){let o=t.apply(this,s);if(typeof n=="function"){let a=i(s[0]);o.then(l=>n(l,a))}return o}}getFetchRequest(t){return t instanceof Request?t:new Request(t)}fetch(t,n){return(t instanceof Request?t.method:n?.method??"GET")==="GET"?this.cache.fetchWithCache(t,n):fetch(t,n)}async request(t,n={}){let i=`${window.location.origin}${t}`,s={"Content-Type":"application/json",Accept:"application/json"},o=await this.fetch(i,{...n,headers:{...s,...n.headers}});if(!o.ok){let a;try{a=await o.json()}catch{a={message:`HTTP ${o.status}: ${o.statusText}`,status:o.status.toString(),description:o.statusText}}throw new Error(a.message||a.description)}return o.json()}async fetchCart(){return this.request("/cart.js")}async addToCart(t){let n={...t,items:t.items.map(i=>{let s=Number(N(String(i.id)));if(!Number.isFinite(s)||s<=0)throw new Error(`Invalid Shopify ID: ${i.id}`);return{...i,id:s}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(n)})}async clearCache(){await this.cache.clear()}};var bt=class{constructor(t){this.eventMap={"/cart/add":"cart-add","/cart/update":"cart-update","/cart/change":"cart-change","/cart/clear":"cart-clear"};this.previousCart=null;this.eventBus=t,this.processFetchResponse=this.processFetchResponse.bind(this)}static{r(this,"AjaxApiPublisher")}async processFetchResponse(t,n){try{let i=this.getEventName(n.url);if(!(i||n.url.includes("/cart.js")))return;let o=await t.clone().json();if(i==="cart-update"&&!o.items_removed){let a=this.diffRemovedItems(o);this.snapshotCart(o),this.eventBus.publish(i,{...o,items_removed:a})}else this.snapshotCart(o),i&&this.eventBus.publish(i,o)}catch(i){console.warn(i)}}getEventName(t){for(let[n,i]of Object.entries(this.eventMap))if(t.includes(n))return i;return null}snapshotCart(t){typeof t=="object"&&t!==null&&"token"in t&&"items"in t&&(this.previousCart=t)}diffRemovedItems(t){let n=this.previousCart;if(!n)return[];let i=new Set(t.items.map(o=>o.key)),s=[];for(let o of n.items)i.has(o.key)||s.push(this.toCartChangeItem(o));return s}toCartChangeItem(t){return{product_id:t.product_id,variant_id:t.variant_id,id:String(t.id),image:t.image,price:String(t.price),presentment_price:t.price,quantity:t.quantity,title:t.title,product_title:t.product_title,variant_title:t.variant_title,vendor:t.vendor,product_type:t.product_type,sku:t.sku,url:t.url,untranslated_product_title:t.product_title,untranslated_variant_title:t.variant_title,view_key:""}}};var it=Math.min,Oe=Math.max,st=Math.round,rt=Math.floor,ye=r(e=>({x:e,y:e}),"createCoords");function Nn(e,t){return typeof e=="function"?e(t):e}r(Nn,"evaluate");function $n(e){return e.split("-")[0]}r($n,"getSide");function Un(e){return e.split("-")[1]}r(Un,"getAlignment");function Yi(e){return e==="x"?"y":"x"}r(Yi,"getOppositeAxis");function Zi(e){return e==="y"?"height":"width"}r(Zi,"getAxisLength");function It(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}r(It,"getSideAxis");function es(e){return Yi(It(e))}r(es,"getAlignmentAxis");function jo(e){return{top:0,right:0,bottom:0,left:0,...e}}r(jo,"expandPaddingObject");function ts(e){return typeof e!="number"?jo(e):{top:e,right:e,bottom:e,left:e}}r(ts,"getPaddingObject");function _e(e){let{x:t,y:n,width:i,height:s}=e;return{width:i,height:s,top:n,left:t,right:t+i,bottom:n+s,x:t,y:n}}r(_e,"rectToClientRect");function ns(e,t,n){let{reference:i,floating:s}=e,o=It(t),a=es(t),l=Zi(a),c=$n(t),p=o==="y",u=i.x+i.width/2-s.width/2,d=i.y+i.height/2-s.height/2,m=i[l]/2-s[l]/2,h;switch(c){case"top":h={x:u,y:i.y-s.height};break;case"bottom":h={x:u,y:i.y+i.height};break;case"right":h={x:i.x+i.width,y:d};break;case"left":h={x:i.x-s.width,y:d};break;default:h={x:i.x,y:i.y}}switch(Un(t)){case"start":h[a]-=m*(n&&p?-1:1);break;case"end":h[a]+=m*(n&&p?-1:1);break}return h}r(ns,"computeCoordsFromPlacement");async function is(e,t){var n;t===void 0&&(t={});let{x:i,y:s,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:p="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:m=!1,padding:h=0}=Nn(t,e),w=ts(h),b=l[m?d==="floating"?"reference":"floating":d],S=_e(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:p,rootBoundary:u,strategy:c})),P=d==="floating"?{x:i,y:s,width:a.floating.width,height:a.floating.height}:a.reference,A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),T=await(o.isElement==null?void 0:o.isElement(A))?await(o.getScale==null?void 0:o.getScale(A))||{x:1,y:1}:{x:1,y:1},C=_e(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:P,offsetParent:A,strategy:c}):P);return{top:(S.top-C.top+w.top)/T.y,bottom:(C.bottom-S.bottom+w.bottom)/T.y,left:(S.left-C.left+w.left)/T.x,right:(C.right-S.right+w.right)/T.x}}r(is,"detectOverflow");var No=50,ss=r(async(e,t,n)=>{let{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:is},c=await(a.isRTL==null?void 0:a.isRTL(t)),p=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:d}=ns(p,i,c),m=i,h=0,w={};for(let f=0;f<o.length;f++){let b=o[f];if(!b)continue;let{name:S,fn:P}=b,{x:A,y:T,data:C,reset:R}=await P({x:u,y:d,initialPlacement:i,placement:m,strategy:s,middlewareData:w,rects:p,platform:l,elements:{reference:e,floating:t}});u=A??u,d=T??d,w[S]={...w[S],...C},R&&h<No&&(h++,typeof R=="object"&&(R.placement&&(m=R.placement),R.rects&&(p=R.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):R.rects),{x:u,y:d}=ns(p,m,c)),f=-1)}return{x:u,y:d,placement:m,strategy:s,middlewareData:w}},"computePosition");var $o=new Set(["left","top"]);async function Uo(e,t){let{placement:n,platform:i,elements:s}=e,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=$n(n),l=Un(n),c=It(n)==="y",p=$o.has(a)?-1:1,u=o&&c?-1:1,d=Nn(t,e),{mainAxis:m,crossAxis:h,alignmentAxis:w}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof w=="number"&&(h=l==="end"?w*-1:w),c?{x:h*u,y:m*p}:{x:m*p,y:h*u}}r(Uo,"convertValueToCoords");var rs=r(function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,i;let{x:s,y:o,placement:a,middlewareData:l}=t,c=await Uo(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:a}}}}},"offset");function St(){return typeof window<"u"}r(St,"hasWindow");function qe(e){return as(e)?(e.nodeName||"").toLowerCase():"#document"}r(qe,"getNodeName");function ce(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}r(ce,"getWindow");function ve(e){var t;return(t=(as(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}r(ve,"getDocumentElement");function as(e){return St()?e instanceof Node||e instanceof ce(e).Node:!1}r(as,"isNode");function fe(e){return St()?e instanceof Element||e instanceof ce(e).Element:!1}r(fe,"isElement");function Ie(e){return St()?e instanceof HTMLElement||e instanceof ce(e).HTMLElement:!1}r(Ie,"isHTMLElement");function os(e){return!St()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ce(e).ShadowRoot}r(os,"isShadowRoot");function Qe(e){let{overflow:t,overflowX:n,overflowY:i,display:s}=me(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&s!=="inline"&&s!=="contents"}r(Qe,"isOverflowElement");function ls(e){return/^(table|td|th)$/.test(qe(e))}r(ls,"isTableElement");function ot(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}r(ot,"isTopLayer");var Vo=/transform|translate|scale|rotate|perspective|filter/,Ho=/paint|layout|strict|content/,Me=r(e=>!!e&&e!=="none","isNotNone"),Vn;function xt(e){let t=fe(e)?me(e):e;return Me(t.transform)||Me(t.translate)||Me(t.scale)||Me(t.rotate)||Me(t.perspective)||!Ct()&&(Me(t.backdropFilter)||Me(t.filter))||Vo.test(t.willChange||"")||Ho.test(t.contain||"")}r(xt,"isContainingBlock");function cs(e){let t=Te(e);for(;Ie(t)&&!Be(t);){if(xt(t))return t;if(ot(t))return null;t=Te(t)}return null}r(cs,"getContainingBlock");function Ct(){return Vn==null&&(Vn=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Vn}r(Ct,"isWebKit");function Be(e){return/^(html|body|#document)$/.test(qe(e))}r(Be,"isLastTraversableNode");function me(e){return ce(e).getComputedStyle(e)}r(me,"getComputedStyle");function at(e){return fe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}r(at,"getNodeScroll");function Te(e){if(qe(e)==="html")return e;let t=e.assignedSlot||e.parentNode||os(e)&&e.host||ve(e);return os(t)?t.host:t}r(Te,"getParentNode");function us(e){let t=Te(e);return Be(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ie(t)&&Qe(t)?t:us(t)}r(us,"getNearestOverflowAncestor");function He(e,t,n){var i;t===void 0&&(t=[]),n===void 0&&(n=!0);let s=us(e),o=s===((i=e.ownerDocument)==null?void 0:i.body),a=ce(s);if(o){let l=Et(a);return t.concat(a,a.visualViewport||[],Qe(s)?s:[],l&&n?He(l):[])}else return t.concat(s,He(s,[],n))}r(He,"getOverflowAncestors");function Et(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}r(Et,"getFrameElement");function fs(e){let t=me(e),n=parseFloat(t.width)||0,i=parseFloat(t.height)||0,s=Ie(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:i,l=st(n)!==o||st(i)!==a;return l&&(n=o,i=a),{width:n,height:i,$:l}}r(fs,"getCssDimensions");function Qn(e){return fe(e)?e:e.contextElement}r(Qn,"unwrapElement");function ze(e){let t=Qn(e);if(!Ie(t))return ye(1);let n=t.getBoundingClientRect(),{width:i,height:s,$:o}=fs(t),a=(o?st(n.width):n.width)/i,l=(o?st(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}r(ze,"getScale");var Qo=ye(0);function ms(e){let t=ce(e);return!Ct()||!t.visualViewport?Qo:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}r(ms,"getVisualOffsets");function zo(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ce(e)?!1:t}r(zo,"shouldAddVisualOffsets");function Fe(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);let s=e.getBoundingClientRect(),o=Qn(e),a=ye(1);t&&(i?fe(i)&&(a=ze(i)):a=ze(e));let l=zo(o,n,i)?ms(o):ye(0),c=(s.left+l.x)/a.x,p=(s.top+l.y)/a.y,u=s.width/a.x,d=s.height/a.y;if(o){let m=ce(o),h=i&&fe(i)?ce(i):i,w=m,f=Et(w);for(;f&&i&&h!==w;){let b=ze(f),S=f.getBoundingClientRect(),P=me(f),A=S.left+(f.clientLeft+parseFloat(P.paddingLeft))*b.x,T=S.top+(f.clientTop+parseFloat(P.paddingTop))*b.y;c*=b.x,p*=b.y,u*=b.x,d*=b.y,c+=A,p+=T,w=ce(f),f=Et(w)}}return _e({width:u,height:d,x:c,y:p})}r(Fe,"getBoundingClientRect");function Rt(e,t){let n=at(e).scrollLeft;return t?t.left+n:Fe(ve(e)).left+n}r(Rt,"getWindowScrollBarX");function ys(e,t){let n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-Rt(e,n),s=n.top+t.scrollTop;return{x:i,y:s}}r(ys,"getHTMLOffset");function Go(e){let{elements:t,rect:n,offsetParent:i,strategy:s}=e,o=s==="fixed",a=ve(i),l=t?ot(t.floating):!1;if(i===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},p=ye(1),u=ye(0),d=Ie(i);if((d||!d&&!o)&&((qe(i)!=="body"||Qe(a))&&(c=at(i)),d)){let h=Fe(i);p=ze(i),u.x=h.x+i.clientLeft,u.y=h.y+i.clientTop}let m=a&&!d&&!o?ys(a,c):ye(0);return{width:n.width*p.x,height:n.height*p.y,x:n.x*p.x-c.scrollLeft*p.x+u.x+m.x,y:n.y*p.y-c.scrollTop*p.y+u.y+m.y}}r(Go,"convertOffsetParentRelativeRectToViewportRelativeRect");function Ko(e){return Array.from(e.getClientRects())}r(Ko,"getClientRects");function Wo(e){let t=ve(e),n=at(e),i=e.ownerDocument.body,s=Oe(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=Oe(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),a=-n.scrollLeft+Rt(e),l=-n.scrollTop;return me(i).direction==="rtl"&&(a+=Oe(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:a,y:l}}r(Wo,"getDocumentRect");var ps=25;function Xo(e,t){let n=ce(e),i=ve(e),s=n.visualViewport,o=i.clientWidth,a=i.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;let u=Ct();(!u||u&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}let p=Rt(i);if(p<=0){let u=i.ownerDocument,d=u.body,m=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,w=Math.abs(i.clientWidth-d.clientWidth-h);w<=ps&&(o-=w)}else p<=ps&&(o+=p);return{width:o,height:a,x:l,y:c}}r(Xo,"getViewportRect");function Jo(e,t){let n=Fe(e,!0,t==="fixed"),i=n.top+e.clientTop,s=n.left+e.clientLeft,o=Ie(e)?ze(e):ye(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=s*o.x,p=i*o.y;return{width:a,height:l,x:c,y:p}}r(Jo,"getInnerBoundingClientRect");function ds(e,t,n){let i;if(t==="viewport")i=Xo(e,n);else if(t==="document")i=Wo(ve(e));else if(fe(t))i=Jo(t,n);else{let s=ms(e);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return _e(i)}r(ds,"getClientRectFromClippingAncestor");function vs(e,t){let n=Te(e);return n===t||!fe(n)||Be(n)?!1:me(n).position==="fixed"||vs(n,t)}r(vs,"hasFixedPositionAncestor");function Yo(e,t){let n=t.get(e);if(n)return n;let i=He(e,[],!1).filter(l=>fe(l)&&qe(l)!=="body"),s=null,o=me(e).position==="fixed",a=o?Te(e):e;for(;fe(a)&&!Be(a);){let l=me(a),c=xt(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Qe(a)&&!c&&vs(e,a))?i=i.filter(u=>u!==a):s=l,a=Te(a)}return t.set(e,i),i}r(Yo,"getClippingElementAncestors");function Zo(e){let{element:t,boundary:n,rootBoundary:i,strategy:s}=e,a=[...n==="clippingAncestors"?ot(t)?[]:Yo(t,this._c):[].concat(n),i],l=ds(t,a[0],s),c=l.top,p=l.right,u=l.bottom,d=l.left;for(let m=1;m<a.length;m++){let h=ds(t,a[m],s);c=Oe(h.top,c),p=it(h.right,p),u=it(h.bottom,u),d=Oe(h.left,d)}return{width:p-d,height:u-c,x:d,y:c}}r(Zo,"getClippingRect");function ea(e){let{width:t,height:n}=fs(e);return{width:t,height:n}}r(ea,"getDimensions");function ta(e,t,n){let i=Ie(t),s=ve(t),o=n==="fixed",a=Fe(e,!0,o,t),l={scrollLeft:0,scrollTop:0},c=ye(0);function p(){c.x=Rt(s)}if(r(p,"setLeftRTLScrollbarOffset"),i||!i&&!o)if((qe(t)!=="body"||Qe(s))&&(l=at(t)),i){let h=Fe(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&p();o&&!i&&s&&p();let u=s&&!i&&!o?ys(s,l):ye(0),d=a.left+l.scrollLeft-c.x-u.x,m=a.top+l.scrollTop-c.y-u.y;return{x:d,y:m,width:a.width,height:a.height}}r(ta,"getRectRelativeToOffsetParent");function Hn(e){return me(e).position==="static"}r(Hn,"isStaticPositioned");function hs(e,t){if(!Ie(e)||me(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ve(e)===n&&(n=n.ownerDocument.body),n}r(hs,"getTrueOffsetParent");function gs(e,t){let n=ce(e);if(ot(e))return n;if(!Ie(e)){let s=Te(e);for(;s&&!Be(s);){if(fe(s)&&!Hn(s))return s;s=Te(s)}return n}let i=hs(e,t);for(;i&&ls(i)&&Hn(i);)i=hs(i,t);return i&&Be(i)&&Hn(i)&&!xt(i)?n:i||cs(e)||n}r(gs,"getOffsetParent");var na=r(async function(e){let t=this.getOffsetParent||gs,n=this.getDimensions,i=await n(e.floating);return{reference:ta(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},"getElementRects");function ia(e){return me(e).direction==="rtl"}r(ia,"isRTL");var sa={convertOffsetParentRelativeRectToViewportRelativeRect:Go,getDocumentElement:ve,getClippingRect:Zo,getOffsetParent:gs,getElementRects:na,getClientRects:Ko,getDimensions:ea,getScale:ze,isElement:fe,isRTL:ia};function ws(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}r(ws,"rectsAreEqual");function ra(e,t){let n=null,i,s=ve(e);function o(){var l;clearTimeout(i),(l=n)==null||l.disconnect(),n=null}r(o,"cleanup");function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();let p=e.getBoundingClientRect(),{left:u,top:d,width:m,height:h}=p;if(l||t(),!m||!h)return;let w=rt(d),f=rt(s.clientWidth-(u+m)),b=rt(s.clientHeight-(d+h)),S=rt(u),A={rootMargin:-w+"px "+-f+"px "+-b+"px "+-S+"px",threshold:Oe(0,it(1,c))||1},T=!0;function C(R){let E=R[0].intersectionRatio;if(E!==c){if(!T)return a();E?a(!1,E):i=setTimeout(()=>{a(!1,1e-7)},1e3)}E===1&&!ws(p,e.getBoundingClientRect())&&a(),T=!1}r(C,"handleObserve");try{n=new IntersectionObserver(C,{...A,root:s.ownerDocument})}catch{n=new IntersectionObserver(C,A)}n.observe(e)}return r(a,"refresh"),a(!0),o}r(ra,"observeMove");function bs(e,t,n,i){i===void 0&&(i={});let{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,p=Qn(e),u=s||o?[...p?He(p):[],...t?He(t):[]]:[];u.forEach(S=>{s&&S.addEventListener("scroll",n,{passive:!0}),o&&S.addEventListener("resize",n)});let d=p&&l?ra(p,n):null,m=-1,h=null;a&&(h=new ResizeObserver(S=>{let[P]=S;P&&P.target===p&&h&&t&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var A;(A=h)==null||A.observe(t)})),n()}),p&&!c&&h.observe(p),t&&h.observe(t));let w,f=c?Fe(e):null;c&&b();function b(){let S=Fe(e);f&&!ws(f,S)&&n(),f=S,w=requestAnimationFrame(b)}return r(b,"frameLoop"),n(),()=>{var S;u.forEach(P=>{s&&P.removeEventListener("scroll",n),o&&P.removeEventListener("resize",n)}),d?.(),(S=h)==null||S.disconnect(),h=null,c&&cancelAnimationFrame(w)}}r(bs,"autoUpdate");var Is=rs;var Ss=r((e,t,n)=>{let i=new Map,s={platform:sa,...n},o={...s.platform,_c:i};return ss(e,t,{...s,platform:o})},"computePosition");function oa(){let e=document.body||document.documentElement;return e?Promise.resolve(e):new Promise(t=>{window.addEventListener("DOMContentLoaded",()=>t(e))})}r(oa,"waitForDOM");function Se({onElementFound:e,selector:t,observerOptions:n,mustMatch:i}){let s=new WeakSet,o=new MutationObserver(p=>{let u=!1;for(let d of p)if(d.addedNodes.length>0){u=!0;break}u&&a()}),a=r(()=>{document.querySelectorAll(t).forEach(p=>{s.has(p)||(s.add(p),i?.(p)!==!1&&l(p))})},"locateElements"),l=r(p=>{if(!n){e(p);return}let u=new IntersectionObserver(d=>{for(let m of d)m.isIntersecting&&(u.disconnect(),e(p))},n);u.observe(p)},"observeElement");return r(async()=>{let p=await oa();a(),o.observe(p,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}r(Se,"createElementLocator");function Ge({onLocationChange:e,fireOnInit:t=!1}){let n=r(()=>{e(window.location)},"handleChange");window.addEventListener("popstate",n);let i=history.pushState,s=history.replaceState;return history.pushState=function(...o){i.apply(this,o),n()},history.replaceState=function(...o){s.apply(this,o),n()},t&&n(),()=>{window.removeEventListener("popstate",n),history.pushState=i,history.replaceState=s}}r(Ge,"createLocationObserver");function kt(e,t){let n=e.parentElement;for(;n;){let i=n.querySelector(t);if(i&&i!==e)return i;n=n.parentElement}return null}r(kt,"findNearestElement");function xs({element:e,onHrefChange:t}){let n=r(()=>{t(e.href)},"handleChange"),i=new MutationObserver(()=>{n()});return i.observe(e,{attributes:!0,attributeFilter:["href"]}),()=>{i.disconnect()}}r(xs,"createHrefObserver");function zn(e){let t=e.getAttribute("swish-item-context");return t?t==="location"?globalThis.window?.location??e:kt(e,t)??e:e}r(zn,"resolveItemContextSource");function Cs(e,t){return e.getAttribute("swish-item-context")?zn(e):t}r(Cs,"resolvePlacementItemContextSource");function Gn(e,t){if(!t.element)throw new Error("Element must be provided");let n=null,i=new Map,s=r(()=>{if(n){console.warn("Placement already mounted. Skipping mount.");return}la(t),n=Se({selector:t.target.selector,observerOptions:t.target.observerOptions,mustMatch:t.target.mustMatch,onElementFound:r(p=>o(p),"onElementFound")})},"mount"),o=r(p=>{i.has(p)||p.hasAttribute("swish-ignore")||p.getAttribute("swish-placement-target")===t.id||(p.setAttribute("swish-placement-target",t.id),a(p))},"evaluateAndMount"),a=r(async p=>{let u=[],d=t.mount.mode,m=Ps(p,t.mount.at);if(!m)return;let h=await(typeof t.element=="function"?t.element(t):xa(e,t.element));if(!h)return;if(h.setAttribute("swish-placement-element",t.id),typeof t.element!="function"){let E=t.element;E.props&&Ca(h,E.props),E.classNames&&Ts(h,E.classNames)}let w;t.container&&(w=Sa(t.id,t.container),w.appendChild(h));let f,b=w??h;if(t.layout?.type==="overlay"){ga(m);let E=t.layout.anchor??"bottom-right";b.setAttribute("swish-placement-overlay",t.id),b.setAttribute("swish-placement-anchor",E)}else t.layout?.type==="anchored"&&b.setAttribute("swish-placement-anchored",t.id);let S=!1,P;if(t.layout?.type==="inline"){let E=t.layout,M=E.rowSelector?m.closest(E.rowSelector):null;M?f=M:(f=Ia(t.id,m,E),S=!0),P=f.getAttribute("swish-placement-inline-row"),f.setAttribute("swish-placement-inline-row",t.id)}let A=w??h;if(!va(m,A,d)){try{A.remove()}catch{}return}if(t.layout?.type==="anchored"){let E=Ps(p,t.layout.to)??m,M=wa(E,b,t.layout);u.push(M)}let C={targetEl:p,renderTargetEl:m,mountEl:h,containerEl:w,rowEl:f,rowWasCreated:S,rowInlineAttrPrevValue:P,cleanupFns:u,ownsNode:!0};i.set(p,C);let R={id:t.id,targetEl:p,renderTargetEl:m,mountEl:C.mountEl,containerEl:w,rowEl:f,cleanup:r(E=>u.push(E),"cleanup")};t.element?.name==="save-button"&&aa(e,R),t.onMount?.(R)},"mountElement"),l=r(p=>{let u=i.get(p);if(u){if(t.onUnmount?.({id:t.id,targetEl:u.targetEl,renderTargetEl:u.renderTargetEl,mountEl:u.mountEl,containerEl:u.containerEl,rowEl:u.rowEl}),u.cleanupFns.forEach(d=>d()),u.targetEl.getAttribute("swish-placement-target")===t.id&&u.targetEl.removeAttribute("swish-placement-target"),u.ownsNode&&(u.containerEl||u.mountEl).remove(),u.rowEl){if(u.rowWasCreated){let d=u.rowEl.parentElement;d&&u.targetEl.parentElement===u.rowEl?u.rowEl.replaceWith(u.targetEl):d?d.removeChild(u.rowEl):u.rowEl.remove()}else if(u.rowInlineAttrPrevValue!==void 0){let d=u.rowInlineAttrPrevValue;d===null?u.rowEl.removeAttribute("swish-placement-inline-row"):u.rowEl.setAttribute("swish-placement-inline-row",d)}}i.delete(p)}},"unmountElement");return{mount:s,unmount:r(()=>{n&&(n.disconnect(),n=null),i.forEach((p,u)=>l(u)),i.clear()},"unmount")}}r(Gn,"createPlacement");var aa=r((e,{mountEl:t,targetEl:n,cleanup:i})=>{let s=Cs(t,n),o=e.state.itemContext(s),a=e.state.effect(()=>{let{loading:l,productId:c,variantId:p}=o.value;l||(t.setAttribute("product-id",c??""),t.setAttribute("variant-id",p??""))});i(()=>a?.())},"saveButtonMount");function la(e){let t=ca(e.id),n=ya(e),i=document.getElementById(t);if(i){i.textContent=n;return}let s=document.createElement("style");s.id=t,s.setAttribute("swish-placement-style",e.id),s.textContent=n,document.head.appendChild(s)}r(la,"ensurePlacementStylesheet");function ca(e){return`swish-placement-style-${ua(e)}`}r(ca,"getPlacementStyleId");function ua(e){return e.replace(/[^a-zA-Z0-9\-_]/g,"_")}r(ua,"cssEscapeId");function Es(e){return`--swish-placement-${pa(String(e))}`}r(Es,"designKeyToCSSVar");function pa(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(pa,"toKebabCase");function da(e){return Object.entries(e??{sm:500,lg:700}).map(([i,s])=>({name:i,minWidth:s})).sort((i,s)=>i.minWidth-s.minWidth)}r(da,"getBreakpoints");function As(e,t){if(e==null)return{};if(typeof e=="object"&&!Array.isArray(e)){if(t&&t.size){let n=Object.keys(e);return"base"in e||n.some(s=>t.has(s))?e:{base:e}}return e}return{base:e}}r(As,"normalizeResponsiveValue");var ha=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function Rs(e,t){if(t!=null)return typeof t=="number"&&!ha.has(e)?`${t}px`:String(t)}r(Rs,"formatDesignValue");function fa(e,t,n){if(!t)return"";let i=new Set(n.map(c=>c.name)),s=[],o={},a=Object.entries(t).map(([c,p])=>[c,p]);for(let[c,p]of a){let u=As(p,i),d=Rs(String(c),u.base);d!==void 0&&s.push(`${Es(c)}:${d};`);for(let m of n){let h=u[m.name],w=Rs(String(c),h);w!==void 0&&(o[m.name]||(o[m.name]=[]),o[m.name].push(`${Es(c)}:${w};`))}}let l=[];s.length&&l.push(`[swish-placement-element="${e}"]{${s.join("")}}`);for(let c of n){let p=o[c.name];p?.length&&l.push(`@media(min-width:${c.minWidth}px){[swish-placement-element="${e}"]{${p.join("")}}}`)}return l.join("")}r(fa,"emitDesignCSS");function Pt(e){return e==null?"0px":typeof e=="number"?`${e}px`:e}r(Pt,"formatOffsetValue");function ks(e){return e==null?"":typeof e=="number"?`${e}`:e}r(ks,"formatZIndexValue");function ma(e,t,n){let i=new Set(n.map(p=>p.name)),s=As(t,i),o=s.base??{},a=Pt(o.x),l=Pt(o.y),c=[];c.push(`[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${a};--swish-placement-offset-y:${l};}`);for(let p of n){let u=s[p.name];if(!u)continue;let d=Pt(u.x),m=Pt(u.y);c.push(`@media(min-width:${p.minWidth}px){[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${d};--swish-placement-offset-y:${m};}}`)}return c.join("")}r(ma,"emitOverlayOffsetCSS");function ya(e){let t=e.id,n=da(e.breakpoints),i=`[swish-placement-inline-row="${t}"]{display:flex;flex-direction:row;align-items:center;gap:var(--swish-placement-inline-gap,8px);width:100%}[swish-placement-inline-row="${t}"]>*:not([swish-placement-element="${t}"]){flex:1;min-width:0}`,s=`[swish-placement-overlay="${t}"]{position:absolute;z-index:var(--swish-placement-overlay-z,10);transform:translate(calc(var(--swish-placement-sign-x,1)*var(--swish-placement-offset-x,0px)),calc(var(--swish-placement-sign-y,1)*var(--swish-placement-offset-y,0px)));}[swish-placement-overlay="${t}"][swish-placement-anchor="top-left"]{top:0;left:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="top-right"]{top:0;right:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="bottom-left"]{bottom:0;left:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="bottom-right"]{bottom:0;right:0;}[swish-placement-overlay="${t}"][swish-placement-anchor$="left"]{--swish-placement-sign-x:1;}[swish-placement-overlay="${t}"][swish-placement-anchor$="right"]{--swish-placement-sign-x:-1;}[swish-placement-overlay="${t}"][swish-placement-anchor^="top"]{--swish-placement-sign-y:1;}[swish-placement-overlay="${t}"][swish-placement-anchor^="bottom"]{--swish-placement-sign-y:-1;}`,o="";if(e.layout?.type==="overlay"){let a=ma(t,e.layout.offset,n),l=e.layout.zIndex?`[swish-placement-overlay="${t}"]{--swish-placement-overlay-z:${ks(e.layout.zIndex)};}`:"";o+=a+l+s}else if(e.layout?.type==="anchored"){let a=e.layout.zIndex?ks(e.layout.zIndex):"10";o+=`[swish-placement-anchored="${t}"]{position:absolute;width:max-content;top:0;left:0;z-index:${a};}`}else e.layout?.type==="inline"&&(o+=i);if(e.design){let a=fa(t,e.design,n);a&&(o+=a)}return e.css&&(o+=e.css.trim()),o}r(ya,"buildPlacementCSS");function Ps(e,t){if(!t||t==="target")return e;if(typeof t=="string"&&(t={nearest:t}),"nearest"in t)return kt(e,t.nearest);if("closest"in t)return e.closest(t.closest);if("query"in t)return e.querySelector(t.query);if("withinClosest"in t){let n=e.closest(t.withinClosest.root);return n?n.querySelector(t.withinClosest.selector):null}return e}r(Ps,"resolveMountTarget");function va(e,t,n){switch(n){case"before":return e.parentElement?(e.before(t),!0):!1;case"after":{let i=e.parentElement;return i?(i.insertBefore(t,e.nextSibling),!0):!1}case"append":return e.appendChild(t),!0;case"prepend":return e.insertBefore(t,e.firstChild),!0;case"replace":return e.parentElement?(e.replaceWith(t),!0):!1}}r(va,"insertIntoDOM");function ga(e){let t=e.parentElement;return t?(window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t):null}r(ga,"ensureRelativeParent");function wa(e,t,n){let i=[];return n.inside?i.push(ba(n.offset??0)):n.offset&&i.push(Is(n.offset)),bs(e,t,r(()=>{Ss(e,t,{placement:n.placement??"bottom-end",middleware:i}).then(({x:o,y:a})=>{Object.assign(t.style,{left:`${o}px`,top:`${a}px`})})},"update"))}r(wa,"setupAnchoredPosition");function ba(e){return{name:"anchoredInside",fn({x:t,y:n,rects:i,placement:s}){let[o,a]=s.split("-"),l=0,c=0,p=o==="top"||o==="bottom";return o==="top"?c=i.floating.height+e:o==="bottom"?c=-(i.floating.height+e):o==="left"?l=i.floating.width+e:o==="right"&&(l=-(i.floating.width+e)),p&&a==="start"?l=e:p&&a==="end"?l=-e:!p&&a==="start"?c=e:!p&&a==="end"&&(c=-e),{x:t+l,y:n+c}}}}r(ba,"anchoredInsideMiddleware");function Ia(e,t,n){if(!t.parentElement)throw new Error("Cannot inline-wrap: refEl has no parentElement");let s=document.createElement("div");return s.setAttribute("swish-placement-inline-row",e),t.before(s),s.appendChild(t),s}r(Ia,"wrapWithFlexRow");function Sa(e,t){let n=t.tag||"div",i=document.createElement(n);return i.setAttribute("swish-placement-container",e),t.classNames&&Ts(i,t.classNames),i}r(Sa,"createContainer");function xa(e,t){return e.ui.createElement(t.name,{})}r(xa,"createElement");function Ca(e,t){for(let[n,i]of Object.entries(t)){let s=n.replace(/([A-Z])/g,"-$1").toLowerCase();i===!1||i===void 0||i===null||(i===!0?e.setAttribute(s,"true"):e.setAttribute(s,String(i)))}}r(Ca,"applyProps");function Ts(e,t){e.classList.add(...t)}r(Ts,"applyClassNames");var At=class{constructor(){this.eventBus=new EventTarget}static{r(this,"EventBus")}subscribe(t,n,i){return Array.isArray(t)||(t=[t]),t.forEach(s=>{this.eventBus.addEventListener(s,n,i)}),()=>{t.forEach(s=>{this.eventBus.removeEventListener(s,n,i)})}}unsubscribe(t,n,i){this.eventBus.removeEventListener(t,n,i)}publish(t,n){this.eventBus.dispatchEvent(new CustomEvent(t,{detail:n}))}};var Ea=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,lt=r(e=>{let t=e.match(Ea);return t?{productHandle:decodeURIComponent(t[1]),variantId:t[2]}:null},"parseProductUrl"),Ds=r(({source:e,onProductUrlChange:t})=>{let n=r(i=>{let s=lt(i);s?.productHandle&&t(s)},"handleChange");if(e instanceof HTMLAnchorElement)return xs({element:e,onHrefChange:r(i=>n(i),"onHrefChange")});if(e instanceof Location)return Ge({onLocationChange:r(i=>n(i.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Kn;function Wn(e){return{lang:e?.lang??Kn?.lang,message:e?.message,abortEarly:e?.abortEarly??Kn?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Kn?.abortPipeEarly}}r(Wn,"getGlobalConfig");var Ra;function ka(e){return Ra?.get(e)}r(ka,"getGlobalMessage");var Pa;function Aa(e){return Pa?.get(e)}r(Aa,"getSchemaMessage");var Ta;function Da(e,t){return Ta?.get(e)?.get(t)}r(Da,"getSpecificMessage");function ct(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}r(ct,"_stringify");function te(e,t,n,i,s){let o=s&&"input"in s?s.input:n.value,a=s?.expected??e.expects??null,l=s?.received??ct(o),c={kind:e.kind,type:e.type,input:o,expected:a,received:l,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:s?.path,issues:s?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},p=e.kind==="schema",u=s?.message??e.message??Da(e.reference,c.lang)??(p?Aa(c.lang):null)??i.message??ka(c.lang);u!==void 0&&(c.message=typeof u=="function"?u(c):u),p&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}r(te,"_addIssue");function ue(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},Wn())}}}r(ue,"_getStandardProps");function Oa(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}r(Oa,"_isValidObjectKey");function Xn(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}r(Xn,"_joinExpects");var La=class extends Error{static{r(this,"ValiError")}constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ut(e,t){return{kind:"validation",type:"min_length",reference:ut,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,i){return n.typed&&n.value.length<this.requirement&&te(this,"length",n,i,{received:`${n.value.length}`}),n}}}r(ut,"minLength");function ge(e,t){return{kind:"validation",type:"min_value",reference:ge,async:!1,expects:`>=${e instanceof Date?e.toJSON():ct(e)}`,requirement:e,message:t,"~run"(n,i){return n.typed&&!(n.value>=this.requirement)&&te(this,"value",n,i,{received:n.value instanceof Date?n.value.toJSON():ct(n.value)}),n}}}r(ge,"minValue");function U(e){return{kind:"transformation",type:"transform",reference:U,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}r(U,"transform");function _a(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}r(_a,"getFallback");function Ls(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}r(Ls,"getDefault");function X(e,t){return{kind:"schema",type:"array",reference:X,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return ue(this)},"~run"(n,i){let s=n.value;if(Array.isArray(s)){n.typed=!0,n.value=[];for(let o=0;o<s.length;o++){let a=s[o],l=this.item["~run"]({value:a},i);if(l.issues){let c={type:"array",origin:"value",input:s,key:o,value:a};for(let p of l.issues)p.path?p.path.unshift(c):p.path=[c],n.issues?.push(p);if(n.issues||(n.issues=l.issues),i.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else te(this,"type",n,i);return n}}}r(X,"array");function D(e){return{kind:"schema",type:"boolean",reference:D,expects:"boolean",async:!1,message:e,get"~standard"(){return ue(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:te(this,"type",t,n),t}}}r(D,"boolean");function Jn(e,t){return{kind:"schema",type:"instance",reference:Jn,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return ue(this)},"~run"(n,i){return n.value instanceof this.class?n.typed=!0:te(this,"type",n,i),n}}}r(Jn,"instance");function K(e,t){return{kind:"schema",type:"literal",reference:K,expects:ct(e),async:!1,literal:e,message:t,get"~standard"(){return ue(this)},"~run"(n,i){return n.value===this.literal?n.typed=!0:te(this,"type",n,i),n}}}r(K,"literal");function _(e){return{kind:"schema",type:"number",reference:_,expects:"number",async:!1,message:e,get"~standard"(){return ue(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:te(this,"type",t,n),t}}}r(_,"number");function I(e,t){return{kind:"schema",type:"object",reference:I,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return ue(this)},"~run"(n,i){let s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(let o in this.entries){let a=this.entries[o];if(o in s||(a.type==="exact_optional"||a.type==="optional"||a.type==="nullish")&&a.default!==void 0){let l=o in s?s[o]:Ls(a),c=a["~run"]({value:l},i);if(c.issues){let p={type:"object",origin:"value",input:s,key:o,value:l};for(let u of c.issues)u.path?u.path.unshift(p):u.path=[p],n.issues?.push(u);if(n.issues||(n.issues=c.issues),i.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[o]=c.value}else if(a.fallback!==void 0)n.value[o]=_a(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(te(this,"key",n,i,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),i.abortEarly))break}}else te(this,"type",n,i);return n}}}r(I,"object");function y(e,t){return{kind:"schema",type:"optional",reference:y,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return ue(this)},"~run"(n,i){return n.value===void 0&&(this.default!==void 0&&(n.value=Ls(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,i)}}}r(y,"optional");function se(e,t){return{kind:"schema",type:"picklist",reference:se,expects:Xn(e.map(ct),"|"),async:!1,options:e,message:t,get"~standard"(){return ue(this)},"~run"(n,i){return this.options.includes(n.value)?n.typed=!0:te(this,"type",n,i),n}}}r(se,"picklist");function ee(e,t,n){return{kind:"schema",type:"record",reference:ee,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return ue(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){i.typed=!0,i.value={};for(let a in o)if(Oa(o,a)){let l=o[a],c=this.key["~run"]({value:a},s);if(c.issues){let u={type:"object",origin:"key",input:o,key:a,value:l};for(let d of c.issues)d.path=[u],i.issues?.push(d);if(i.issues||(i.issues=c.issues),s.abortEarly){i.typed=!1;break}}let p=this.value["~run"]({value:l},s);if(p.issues){let u={type:"object",origin:"value",input:o,key:a,value:l};for(let d of p.issues)d.path?d.path.unshift(u):d.path=[u],i.issues?.push(d);if(i.issues||(i.issues=p.issues),s.abortEarly){i.typed=!1;break}}(!c.typed||!p.typed)&&(i.typed=!1),c.typed&&(i.value[c.value]=p.value)}}else te(this,"type",i,s);return i}}}r(ee,"record");function x(e){return{kind:"schema",type:"string",reference:x,expects:"string",async:!1,message:e,get"~standard"(){return ue(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:te(this,"type",t,n),t}}}r(x,"string");function Os(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}r(Os,"_subIssues");function V(e,t){return{kind:"schema",type:"union",reference:V,expects:Xn(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return ue(this)},"~run"(n,i){let s,o,a;for(let l of this.options){let c=l["~run"]({value:n.value},i);if(c.typed)if(c.issues)o?o.push(c):o=[c];else{s=c;break}else a?a.push(c):a=[c]}if(s)return s;if(o){if(o.length===1)return o[0];te(this,"type",n,i,{issues:Os(o)}),n.typed=!0}else{if(a?.length===1)return a[0];te(this,"type",n,i,{issues:Os(a)})}return n}}}r(V,"union");function re(){return{kind:"schema",type:"unknown",reference:re,expects:"unknown",async:!1,get"~standard"(){return ue(this)},"~run"(e){return e.typed=!0,e}}}r(re,"unknown");function je(e,t,n){return{kind:"schema",type:"variant",reference:je,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return ue(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){let a,l=0,c=this.key,p=[],u=r((d,m)=>{for(let h of d.options){if(h.type==="variant")u(h,new Set(m).add(h.key));else{let w=!0,f=0;for(let b of m){let S=h.entries[b];if(b in o?S["~run"]({typed:!1,value:o[b]},{abortEarly:!0}).issues:S.type!=="exact_optional"&&S.type!=="optional"&&S.type!=="nullish"){w=!1,c!==b&&(l<f||l===f&&b in o&&!(c in o))&&(l=f,c=b,p=[]),c===b&&p.push(h.entries[b].expects);break}f++}if(w){let b=h["~run"]({value:o},s);(!a||!a.typed&&b.typed)&&(a=b)}}if(a&&!a.issues)break}},"parseOptions");if(u(this,new Set([this.key])),a)return a;te(this,"type",i,s,{input:o[c],expected:Xn(p,"|"),path:[{type:"object",origin:"value",input:o,key:c,value:o[c]}]})}else te(this,"type",i,s);return i}}}r(je,"variant");function _s(e,t,n){let i=e["~run"]({value:t},Wn(n));if(i.issues)throw new La(i.issues);return i.value}r(_s,"parse");function q(...e){return{...e[0],pipe:e,get"~standard"(){return ue(this)},"~run"(t,n){for(let i of e)if(i.kind!=="metadata"){if(t.issues&&(i.kind==="schema"||i.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=i["~run"](t,n))}return t}}}r(q,"pipe");function B(e,t,n){let i=e["~run"]({value:t},Wn(n));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}r(B,"safeParse");var Ke=q(V([q(x(),U(N)),_()]),U(e=>Number(e)),q(_(),ge(1)));var k=class{constructor(t,n,i,s){this.swish=t;this.ui=n;this.eventBus=i;this.options=s}static{r(this,"IntentHandler")}};var Ma=V([I({variantId:Ke,quantity:y(q(_(),ge(1)),1)}),I({items:q(X(I({variantId:Ke,quantity:y(q(_(),ge(1)),1)})),ut(1))})]),Tt=class extends k{static{r(this,"CreateCartLineHandler")}async invoke(t){let n=B(Ma,t);if(!n.success)return{intent:"create:cart-line",code:"error",message:"Invalid intent data",issues:n.issues.map(s=>s.message)};let i=n.output;try{let s="items"in i?i.items.map(a=>({id:a.variantId,quantity:a.quantity})):[{id:i.variantId,quantity:i.quantity}];return{intent:"create:cart-line",code:"ok",data:await this.swish.ajax.addToCart({items:s})}}catch(s){let o=[],a="Failed to add item to cart";return s instanceof Error?(s.message&&(a=s.message,o.push(s.message)),s.stack&&o.push(s.stack)):typeof s=="string"&&s.trim()?(a=s,o.push(s)):s!=null&&o.push(String(s)),{intent:"create:cart-line",code:"error",message:a,issues:o.length?o:["Cart request failed"]}}}};var Dt=class extends k{static{r(this,"CreateListHandler")}async invoke(t){let n=await this.ui.showListEditor();if(n.code==="closed")return{intent:"create:list",code:"closed"};let{list:i}=n.data;return{intent:"create:list",code:"ok",data:{list:i}}}};var qa=I({listId:x()}),Ot=class extends k{static{r(this,"DeleteListHandler")}async invoke(t){let n=B(qa,t);if(!n.success)return{intent:"delete:list",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output;return(await this.ui.showDeleteListAlert({listId:i})).code==="closed"?{intent:"delete:list",code:"closed"}:{intent:"delete:list",code:"ok",data:{listId:i}}}};var Ba=I({itemId:x()}),Lt=class extends k{static{r(this,"EditItemListsHandler")}async invoke(t){let n=B(Ba,t);if(!n.success)return{intent:"edit:item-lists",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{itemId:i}=n.output,s=await this.ui.showListSelect({itemId:i});if(s.code==="closed")return{intent:"edit:item-lists",code:"closed"};if(s.data.action==="submit"){let{item:o,product:a,variant:l}=s.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:a,variant:l}}}return{intent:"unsave:item",code:"ok",data:{itemId:s.data.data.itemId}}}};var Fa=I({itemId:q(x()),productId:q(V([q(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(q(V([q(x(),U(N)),_()]),U(e=>Number(e)),_()))}),_t=class extends k{static{r(this,"EditItemVariantHandler")}async invoke(t){let n=B(Fa,t);if(!n.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:n.issues.map(m=>m.message)};let{itemId:i,productId:s,variantId:o}=n.output;if(!(!o||this.swish.options.intents.editSavedProduct.promptVariantChange)){let m=await this.swish.api.items.updateById(i,{productId:s,variantId:o});if("error"in m)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[m.error.message]};if(!m.data)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:["No item returned from API"]};let h=await this.swish.storefront.loadProduct({productId:String(s),variantId:o?String(o):void 0});if(!h.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load product data",issues:[h.errors?.message??"No product data returned from API"]};let w=h.data.product,f=h.data.variant;return{intent:"edit:item-variant",code:"ok",data:{item:m.data,product:w,variant:f}}}let l=await this.ui.showVariantSelect({itemId:i,productId:s,variantId:o});if(l.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:c,product:p,variant:u}=l.data;return{intent:"edit:item-variant",code:"ok",data:{item:c,product:p,variant:u}}}};var ja=I({listId:x(),access:se(["public","private"])}),Mt=class extends k{static{r(this,"EditListAccessHandler")}async invoke(t){let n=B(ja,t);if(!n.success)return{intent:"edit:list-access",code:"error",message:"Invalid intent data",issues:n.issues.map(l=>l.message)};let{listId:i,access:s}=n.output;if((await this.ui.showConfirmDialog({titleKey:s==="public"?"listMenu.public.title":"listMenu.private.title",descriptionKey:s==="public"?"listMenu.public.description":"listMenu.private.description",confirmLabelKey:s==="public"?"listMenu.public.text":"listMenu.private.text",cancelLabelKey:"listMenu.cancel",danger:!1})).code==="closed")return{intent:"edit:list-access",code:"closed"};let a=await this.swish.api.lists.updateById(i,{access:s});return"error"in a?{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:[a.error.message]}:a.data?{intent:"edit:list-access",code:"ok",data:{list:a.data}}:{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:["API response missing data"]}}};var Na=I({listId:x()}),qt=class extends k{static{r(this,"EditListHandler")}async invoke(t){let n=B(Na,t);if(!n.success)return{intent:"edit:list",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{listId:i}=n.output,s=await this.ui.showListEditor({listId:i});if(s.code==="closed")return{intent:"edit:list",code:"closed"};let{list:o}=s.data;return{intent:"edit:list",code:"ok",data:{list:o}}}};var $a=I({variantId:Ke,quantity:y(q(_(),ge(1)),1)}),Ua=150,Va=V([I({variantId:Ke,quantity:y(q(_(),ge(1)),1)}),I({items:q(X($a),ut(1))})]),Bt=class extends k{static{r(this,"InitiateCheckoutHandler")}async invoke(t){let n=B(Va,t);if(!n.success)return{intent:"initiate:checkout",code:"error",message:"Invalid intent data",issues:n.issues.map(l=>l.message)};let i=n.output,o=("items"in i?i.items:[{variantId:i.variantId,quantity:i.quantity}]).map(l=>`${l.variantId}:${l.quantity}`).join(","),a=new URL(`/cart/${o}`,this.swish.shopUrl);return a.searchParams.set("checkout","1"),typeof window<"u"&&window.setTimeout(()=>window.location.assign(a.href),Ua),{intent:"initiate:checkout",code:"ok",data:{checkoutUrl:a.href}}}};var Ha=I({productId:q(V([q(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(q(V([q(x(),U(N)),_()]),U(Number),_()))}),Ft=class extends k{static{r(this,"InitiateQuickBuyHandler")}async invoke(t){let n=B(Ha,t);if(!n.success)return{intent:"initiate:quick-buy",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{productId:i,variantId:s}=n.output,o=await this.ui.showQuickBuy({productId:i,variantId:s});return o.code==="closed"?{intent:"initiate:quick-buy",code:"closed"}:{intent:"initiate:quick-buy",code:"ok",data:o.data}}};var Qa=150,za=I({returnTo:x()}),jt=class extends k{static{r(this,"InitiateSignInHandler")}async invoke(t){let n=B(za,t);if(!n.success)return{intent:"initiate:sign-in",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let i=n.output.returnTo;return(await this.ui.showConfirmDialog({titleKey:"signIn.title",descriptionKey:"signIn.description",confirmLabelKey:"signIn.continue",danger:!1})).code==="closed"?{intent:"initiate:sign-in",code:"closed"}:(this.scheduleRedirect(i),{intent:"initiate:sign-in",code:"ok",data:void 0})}scheduleRedirect(t){window.setTimeout(()=>this.redirectToSignIn(t),Qa)}redirectToSignIn(t){let{routes:n,newCustomerAccounts:i}=this.swish.storefrontContext,s=i?"/customer_identity/login":n.accountUrl,o=new URL(s,window.location.origin);o.searchParams.set("return_to",t),window.location.assign(o.toString())}};var Ga=150,Nt=class extends k{static{r(this,"InitiateSignOutHandler")}async invoke(){return this.scheduleRedirect(),{intent:"initiate:sign-out",code:"ok",data:void 0}}scheduleRedirect(){window.setTimeout(()=>this.redirectToSignOut(),Ga)}redirectToSignOut(){let{accountUrl:t,rootUrl:n}=this.swish.storefrontContext.routes,{newCustomerAccounts:i}=this.swish.storefrontContext,s;if(i){let o=new URL(t,window.location.origin);o.pathname=o.pathname.replace(/\/$/,"")+"/logout",s=o.toString()}else s=new URL("/account/logout",window.location.origin).toString();s+=`?return_url=${encodeURIComponent(n)}`,window.location.assign(s)}};var $t=class extends k{static{r(this,"SaveCartLineHandler")}async invoke(t){if(!t?.items?.length)return{intent:"save:cart-line",code:"error",message:"No items to save",issues:["items array is empty or missing"]};let{confirm:n,showFeedback:i}=this.options.saveCartLine,s=t.items[0];if(n&&(await this.ui.showToast({title:"Save this for later?",text:s.title??"",image:s.image,action:{label:"Save for later"},variant:"full"})).code!=="ok")return{intent:"save:cart-line",code:"closed"};for(let o of t.items){let a=await this.swish.api.items.create({productId:o.productId,variantId:o.variantId,quantity:o.quantity,source:"cart"});if("error"in a)return{intent:"save:cart-line",code:"error",message:"Failed to save item from cart",issues:[a.error.message]}}return i&&await this.ui.showToast({title:"We've saved this for you",text:s.title??"",image:s.image,variant:"full"}),{intent:"save:cart-line",code:"ok",data:t.items}}};var Ka=I({productId:q(V([q(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(q(V([q(x(),U(N)),_()]),U(Number),_())),quantity:y(q(_(),ge(1))),tags:y(X(x()))}),Ut=class extends k{static{r(this,"SaveItemHandler")}async invoke(t){let n=B(Ka,t);if(!n.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:n.issues.map(b=>b.message)};let{productId:i,variantId:s,quantity:o,tags:a}=n.output,l=await this.swish.storefront.loadProduct({productId:String(i),variantId:s?String(s):void 0});if(l.errors)return{intent:"save:item",code:"error",message:l.errors.message??"Failed to load product data",issues:l.errors.graphQLErrors?.map(b=>b.message)??[]};if(!l.data||!l.data.product)return{intent:"save:item",code:"error",message:"Failed to load product data",issues:["API response missing data"]};let{product:c,variant:p}=l.data,u=c.variantsCount?.count&&c.variantsCount.count>1,d=!!s,h=!(typeof this.options.saveProduct.promptVariantIfMissing=="function"?this.options.saveProduct.promptVariantIfMissing({product:c,variant:p}):this.options.saveProduct.promptVariantIfMissing)||!this.options.saveProduct.promptVariantIfPresent&&d;if(!u||h){let b=r(()=>!u&&c.selectedOrFirstAvailableVariant?Number(N(c.selectedOrFirstAvailableVariant.id)):s,"variantIdToUse"),S=await this.swish.api.items.create({productId:i,variantId:b(),quantity:o,tags:a});return"error"in S?{intent:"save:item",code:"error",message:"Failed to create item",issues:[S.error.message]}:S.data?{intent:"save:item",code:"ok",data:{item:S.data,product:c,variant:u?p:c.selectedOrFirstAvailableVariant}}:{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]}}let w;if(this.options.saveProduct.saveBeforeVariantPrompt){let b=await this.swish.api.items.create({productId:i,quantity:o,tags:a});"data"in b&&b.data&&(w=b.data)}let f=await this.ui.showVariantSelect({productId:i,variantId:s,itemId:w?.id});return f.code==="closed"?w?{intent:"save:item",code:"ok",data:{item:w,product:c,variant:p}}:{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:f.data}}};function pt(e,t){let{storeDomain:n}=e.options.storefront,{rootUrl:i,listDetailPagePath:s}=e.options.context.routes,o=new URL(`https://${n}`),a=new URL(`${i==="/"?"":i}${s}`,o);return a.searchParams.set("public-list-id",t.publicListId),a}r(pt,"buildShareListUrl");async function dt(e){return typeof navigator?.clipboard?.writeText!="function"?{ok:!1,issues:["Clipboard API not available"]}:navigator.clipboard.writeText(e).then(()=>({ok:!0})).catch(t=>({ok:!1,issues:[t?.message??"Failed to copy to clipboard"]}))}r(dt,"copyToClipboard");function Ms(){let e=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||e}r(Ms,"isMobileDevice");var Wa=I({listId:x()}),Vt=class extends k{static{r(this,"ShareListHandler")}async invoke(t){let n=B(Wa,t);if(!n.success)return{intent:"initiate:share",code:"error",message:"Invalid intent data",issues:n.issues.map(c=>c.message)};let{listId:i}=n.output,s=await this.swish.api.lists.findById(i);if("error"in s)return{intent:"initiate:share",code:"error",message:"Failed to fetch list",issues:[s.error.message]};if(!s.data)return{intent:"initiate:share",code:"error",message:"List not found",issues:[]};if(s.data.access!=="public"){let p=await(await this.swish.intents.invoke("edit:list-access",{listId:i,access:"public"})).complete;if(p.code!=="ok")return{...p,intent:"initiate:share"}}let o=pt(this.swish,{publicListId:i}).toString();if(Ms()&&typeof navigator.share=="function"&&(await navigator.share({title:"Share list",url:o}).then(()=>({ok:!0})).catch(()=>({ok:!1}))).ok)return{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"native"}};let l=await dt(o);return l.ok?{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"clipboard"}}:{intent:"initiate:share",code:"error",message:"Failed to share list",issues:l.issues}}};var Af=I({title:y(x()),text:x(),image:y(x()),action:y(I({label:x(),url:y(x())})),variant:y(se(["compact","full"])),icon:y(x())}),Ht=class extends k{static{r(this,"ShowToastHandler")}async invoke(t){return{intent:"show:toast",code:(await this.ui.showToast(t)).code,data:void 0}}};var Xa=I({itemId:x(),delete:y(D())}),Qt=class extends k{static{r(this,"UnsaveItemHandler")}async invoke(t){let n=B(Xa,t);if(!n.success)return{intent:"unsave:item",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{itemId:i,delete:s}=n.output;if(this.options.unsaveProduct.selectList&&!s){let a=await this.ui.showListSelect({itemId:i});if(a.code==="closed")return{intent:"unsave:item",code:"closed"};if(a.data.action==="submit"){let{item:l,product:c,variant:p}=a.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:l,product:c,variant:p}}}if(a.data.action==="unsave"){let{itemId:l}=a.data.data;return{intent:"unsave:item",code:"ok",data:{itemId:l}}}}if(!this.options.unsaveProduct.confirm){let a=await this.swish.api.items.deleteById(i);return"error"in a?{intent:"unsave:item",code:"error",message:"Failed to delete item",issues:[a.error.message]}:{intent:"unsave:item",code:"ok",data:{itemId:i}}}return(await this.ui.showUnsaveAlert({itemId:i})).code==="closed"?{intent:"unsave:item",code:"closed"}:{intent:"unsave:item",code:"ok",data:{itemId:i}}}};var zt=class extends k{static{r(this,"ViewHomeHandler")}async invoke(t){return{intent:"view:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var Ja=I({listId:x()}),Gt=class extends k{static{r(this,"ViewListDetailPageMenuHandler")}async invoke(t){let n=B(Ja,t);if(!n.success)return{intent:"view:list-detail-page-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output;return{intent:"view:list-detail-page-menu",code:(await this.ui.showListDetailPageMenu({listId:i})).code,data:void 0}}};var Ya=I({listId:x(),listType:y(se(["user","smart","shared"]),"user")}),Kt=class extends k{static{r(this,"ViewListHandler")}async invoke(t){let n=B(Ya,t);if(!n.success)return{intent:"view:list",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{listId:i,listType:s}=n.output;return{intent:"view:list",code:(await this.ui.showDrawer({view:"list",listId:i,listType:s})).code,data:void 0}}};var Za=I({listId:x()}),Wt=class extends k{static{r(this,"ViewListMenuHandler")}async invoke(t){let n=B(Za,t);if(!n.success)return{intent:"view:list-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output,s=await this.ui.showListMenu({listId:i});if(s.code==="closed")return{intent:"view:list-menu",code:"closed"};if(s.data.action==="edit")return{intent:"edit:list",code:"ok",data:s.data.data};if(s.data.action==="delete")return{intent:"delete:list",code:"ok",data:{listId:i}};if(s.data.action==="edit-access"){let o=s.data.data?.currentListAccess,a=o==="public"?"private":o==="private"?"public":void 0;return a?(await this.swish.intents.invoke("edit:list-access",{listId:i,access:a})).complete:{intent:"view:list-menu",code:"error",message:"Missing list access from UI",issues:["List menu UI did not provide currentListAccess"]}}return s.data.action==="share"?(await this.swish.intents.invoke("initiate:share",{listId:i})).complete:s.data.action==="add-items"?{intent:"view:list-menu",code:"ok",data:{listId:i}}:{intent:"view:list-menu",code:"error",message:"Unknown list menu action",issues:["Unknown action returned from list menu UI"]}}};var Xt=class extends k{static{r(this,"ViewListsHandler")}async invoke(t){return{intent:"view:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var Jt=class extends k{static{r(this,"ViewNotificationsHandler")}async invoke(t){return{intent:"view:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var el=I({orderId:q(V([q(x(),U(N)),_()]),U(e=>Number(e)),_())}),Yt=class extends k{static{r(this,"ViewOrderHandler")}async invoke(t){let n=B(el,t);if(!n.success)return{intent:"view:order",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{orderId:i}=n.output;return{intent:"view:order",code:(await this.ui.showDrawer({view:"order",orderId:i.toString()})).code,data:void 0}}};var tl=I({orderId:x()}),Zt=class extends k{static{r(this,"ViewOrderMenuHandler")}async invoke(t){let n=B(tl,t);if(!n.success)return{intent:"view:order-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{orderId:i}=n.output;return{intent:"view:order-menu",code:(await this.ui.showOrderMenu({orderId:i})).code,data:void 0}}};var en=class extends k{static{r(this,"ViewOrdersHandler")}async invoke(t){return{intent:"view:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var nl=I({productId:q(V([q(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(q(V([q(x(),U(N)),_()]),U(Number),_()))}),tn=class extends k{static{r(this,"ViewProductHandler")}async invoke(t){let n=B(nl,t);if(!n.success)return{intent:"view:product",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{productId:i,variantId:s}=n.output;return{intent:"view:product",code:(await this.ui.showDrawer({view:"product",productId:i.toString(),variantId:s?.toString()})).code,data:void 0}}};var nn=class extends k{static{r(this,"ViewProfileHandler")}async invoke(t){return{intent:"view:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var sn=class extends k{static{r(this,"ViewSavesHandler")}async invoke(t){return{intent:"view:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var Z=class{constructor(t,n,i){this.swish=t;this.ui=n;this.options=i}static{r(this,"IntentHook")}};var rn=class extends Z{static{r(this,"AfterCreateCartLineHook")}async invoke(t){this.options.createCartLine.afterComplete?.(t)}};var on=class extends Z{static{r(this,"AfterEditItemListsHook")}async invoke(t){if(this.options.editSavedProduct.showFeedback&&t.code==="ok"){if("itemId"in t.data)return;let{product:n,variant:i}=t.data;n&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:n.title,image:i?.image?.url??n.featuredImage?.url,action:{label:"View"}})).complete).code==="ok"&&this.swish.intents.invoke("view:saves")}}};var an=class extends Z{static{r(this,"AfterEditListAccessHook")}async invoke(t){if(t.code!=="ok")return;let n=t.data.list.access==="public"?"List is now public":"List is now private";await(await this.swish.intents.invoke("show:toast",{text:n,variant:"compact",icon:"check"})).complete}};var ln=class extends Z{static{r(this,"AfterSaveCartLineHook")}async invoke(t){this.options.saveCartLine.afterComplete?.(t)}};var cn=class extends Z{static{r(this,"AfterSaveItemHook")}async invoke(t){if(this.options.saveProduct.showFeedback&&t.code==="ok"){let{item:n,product:i,variant:s}=t.data;i&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:i.title,image:s?.image?.url??i.featuredImage?.url,action:{label:"Add to List"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:n.id})}}};var un=class extends Z{static{r(this,"AfterShareListHook")}async invoke(t){if(t.code!=="ok")return;await(await this.swish.intents.invoke("show:toast",{variant:"compact",text:"Link copied",icon:"check"})).complete}};var pn=class extends Z{static{r(this,"AfterViewHomeHook")}async invoke(t){if(t.code==="closed"){let n=new URL(window.location.href);(n.hash==="#swish-home"||n.hash==="#swish")&&(n.hash="",window.history.replaceState({},document.title,n.toString()))}}};function qs(e){let t=e.startsWith("#")?e.slice(1):e;return t==="swish"||t.startsWith("swish-")}r(qs,"isSwishHash");var dn=class extends Z{static{r(this,"BeforeViewHomeHook")}async invoke(){qs(window.location.hash)||window.history.replaceState(window.history.state,"",window.location.pathname+window.location.search+"#swish")}};var hn=class{constructor(t,n){this._invoking=!1;this.swish=t,this.ui=n,this.eventBus=new EventTarget,this.options=t.options.intents,this.handlers={"create:cart-line":new Tt(this.swish,this.ui,this.eventBus,this.options),"initiate:checkout":new Bt(this.swish,this.ui,this.eventBus,this.options),"save:item":new Ut(this.swish,this.ui,this.eventBus,this.options),"save:cart-line":new $t(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new Qt(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new _t(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Lt(this.swish,this.ui,this.eventBus,this.options),"create:list":new Dt(this.swish,this.ui,this.eventBus,this.options),"edit:list":new qt(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new Mt(this.swish,this.ui,this.eventBus,this.options),"delete:list":new Ot(this.swish,this.ui,this.eventBus,this.options),"view:home":new zt(this.swish,this.ui,this.eventBus,this.options),"initiate:share":new Vt(this.swish,this.ui,this.eventBus,this.options),"view:list":new Kt(this.swish,this.ui,this.eventBus,this.options),"view:lists":new Xt(this.swish,this.ui,this.eventBus,this.options),"view:orders":new en(this.swish,this.ui,this.eventBus,this.options),"view:order":new Yt(this.swish,this.ui,this.eventBus,this.options),"view:saves":new sn(this.swish,this.ui,this.eventBus,this.options),"view:notifications":new Jt(this.swish,this.ui,this.eventBus,this.options),"view:profile":new nn(this.swish,this.ui,this.eventBus,this.options),"view:product":new tn(this.swish,this.ui,this.eventBus,this.options),"view:list-menu":new Wt(this.swish,this.ui,this.eventBus,this.options),"view:order-menu":new Zt(this.swish,this.ui,this.eventBus,this.options),"view:list-detail-page-menu":new Gt(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-in":new jt(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-out":new Nt(this.swish,this.ui,this.eventBus,this.options),"initiate:quick-buy":new Ft(this.swish,this.ui,this.eventBus,this.options),"show:toast":new Ht(this.swish,this.ui,this.eventBus,this.options)},this.initIntentHooks(),this.initIntentWatcher(),this.initCartChangeListener()}static{r(this,"Intents")}publishAnalyticsEvent(t,n){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(t,n)}async invoke(t,...n){let i=n[0],s={lifecycle:"before",intent:t,data:i,response:null};return this.publishAnalyticsEvent("swish-intent",s),this.publishAnalyticsEvent(`swish-intent=${t}`,s),this._invoking=!0,this.eventBus.dispatchEvent(new CustomEvent(`before:${t}`,{detail:s})),this._invoking=!1,{intent:t,data:i,complete:this.handleIntent(t,i).then(o=>{let a={lifecycle:"after",intent:t,data:i,response:o};if(this.publishAnalyticsEvent("swish-intent",a),this.publishAnalyticsEvent(`swish-intent=${t}`,a),this.eventBus.dispatchEvent(new CustomEvent(t,{detail:a})),o.code==="ok"&&o.intent!==t){let l={lifecycle:"after",intent:o.intent,data:i,response:o};this.eventBus.dispatchEvent(new CustomEvent(o.intent,{detail:l}))}return o})}}listen(t,n){let i=r(o=>{"detail"in o&&o.detail?n(o.detail.response):console.warn("Intent response event without detail",o)},"eventListener"),s=r(()=>{this.eventBus.removeEventListener(`${t}`,i)},"unsubscribe");return this.eventBus.addEventListener(`${t}`,i),s}parseIntentFromString(t){let n=String(t),i=n.indexOf("?");if(i===-1)return{intent:n,data:{}};let s=n.slice(0,i),o=new URLSearchParams(n.slice(i+1)),a={};return o.forEach((l,c)=>{a[c]=l}),{intent:s,data:a}}parseIntentFromUrl(t){let n=t.searchParams.get("swish-intent");if(!n)return null;let i=n,s={};t.searchParams.forEach((a,l)=>{l!=="swish-intent"&&(s[l]=a)});let o=lt(t.pathname);return o&&(!s.product&&!s.productId&&(s.product=o.productHandle),!s.variant&&!s.variantId&&o.variantId&&(s.variant=o.variantId)),{intent:i,data:s}}mapParamNames(t){let n={product:"productId",variant:"variantId",list:"listId",order:"orderId",item:"itemId"},i={};for(let[s,o]of Object.entries(t))i[n[s]??s]=o;return i}async resolveIntentData(t){let{productId:n}=t;if(!n||/^\d+$/.test(n)||n.startsWith("gid://"))return t;let i=await this.swish.storefront.loadProductId({productHandle:n});return i.data?.product?.id?{...t,productId:N(i.data.product.id)}:t}async invokeFromParsed(t,n){let i=this.mapParamNames(n),s=await this.resolveIntentData(i);Object.keys(s).length>0?this.invoke(t,s):this.invoke(t)}parseIntentFromHash(t){let n=t.startsWith("#")?t.slice(1):t;return{swish:"view:home","swish-home":"view:home","swish-lists":"view:lists","swish-orders":"view:orders","swish-saves":"view:saves","swish-notifications":"view:notifications","swish-profile":"view:profile"}[n]||null}async handleIntent(t,n){let i=this.handlers[t];return i?i.invoke(n):{intent:t,code:"error",message:"Invalid intent",issues:[`Intent ${t} not found`]}}initIntentHooks(){this.eventBus.addEventListener("before:view:home",()=>{new dn(this.swish,this.ui,this.options).invoke()}),this.eventBus.addEventListener("create:cart-line",t=>{new rn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:item",t=>{new cn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:item-lists",t=>{new on(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("view:home",t=>{new pn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:list-access",t=>{new an(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("initiate:share",t=>{new un(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:cart-line",t=>{new ln(this.swish,this.ui,this.options).invoke(t.detail.response)})}initCartChangeListener(){this.swish.events.subscribe(["cart-change","cart-update"],t=>{if(!this.options.removeCartLine.saveCartLine)return;let i=t.detail?.items_removed;if(!i?.length)return;let s=i.map(o=>({productId:o.product_id,variantId:o.variant_id,quantity:o.quantity,title:o.product_title,image:o.image,variantTitle:o.variant_title}));this.invoke("save:cart-line",{items:s})})}initIntentWatcher(){Se({selector:"[swish-intent]",onElementFound:r(t=>{let n=t.getAttribute("swish-intent");if(!n)return;let{intent:i,data:s}=this.parseIntentFromString(n);t.addEventListener("click",()=>{this.invokeFromParsed(i,s)})},"onElementFound")}),Se({selector:"a[href*='swish-intent='],a[href*='#swish']",onElementFound:r(t=>{t instanceof HTMLAnchorElement&&t.addEventListener("click",n=>{if(!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey){let i=new URL(t.href),s=this.parseIntentFromUrl(i);if(s)n.preventDefault(),n.stopPropagation(),this.invokeFromParsed(s.intent,s.data);else if(i.hash){let o=this.parseIntentFromHash(i.hash);o&&(n.preventDefault(),n.stopPropagation(),this.invoke(o))}}})},"onElementFound")}),Ge({fireOnInit:!0,onLocationChange:r(t=>{if(this._invoking)return;let n=new URL(t.href),i=this.parseIntentFromUrl(n);if(i)n.searchParams.delete("swish-intent"),history.replaceState(history.state,"",n.toString()),this.invokeFromParsed(i.intent,i.data);else if(n.hash){let s=this.parseIntentFromHash(n.hash);s&&this.invoke(s)}},"onLocationChange")})}};var J=y(ee(x(),V([x(),_()])),{}),il=I({url:y(x(),""),altText:y(x(),"")}),sl=I({id:x(),enabled:D(),intent:x()}),rl=I({type:K("drawer-header"),hidden:y(D(),!1),design:J,options:y(I({title:y(x(),""),logo:y(il,{url:"",altText:""}),useCloseButton:y(D(),!1),accountButton:y(D(),!0),notificationButton:y(D(),!0)}),{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0})}),ol=I({type:K("drawer-footer"),hidden:y(D(),!1),design:J,options:y(I({displayType:y(se(["floating","docked"]),"docked"),showIcons:y(D(),!1),showText:y(D(),!0),items:y(X(sl),[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}])}),{displayType:"docked",showIcons:!1,showText:!0,items:[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}]})}),al=je("type",[rl,ol]),ll=I({type:se(["sign-in","notifications","recently-viewed","saved-from-cart","saved-items","lists"]),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{})}),cl=I({title:x(),url:x()}),ul=I({type:K("mini-menu"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{}),items:y(X(cl),[])}),pl=I({type:K("content-block"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{}),title:y(x()),body:y(x()),image:y(I({url:x(),width:y(_()),height:y(_())})),link:y(I({url:x(),target:y(se(["_self","_blank"]))}))}),dl=I({type:K("featured-collection"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{}),handle:x()}),hl=je("type",[ll,ul,pl,dl]),fl=I({type:K("lists-section"),hidden:y(D(),!1),design:J,options:y(I({display:y(se(["myLists","forYouLists"]),"myLists"),layout:y(se(["list","slider"]),"slider")}),{display:"myLists",layout:"slider"})}),ml=I({type:K("all-items-grid"),hidden:y(D(),!1),design:J,options:y(I({showSaveButton:y(D(),!0),showQuickBuyButton:y(D(),!0),showVariantTitle:y(D(),!0),enableVariantChange:y(D(),!1),showVariantOptionNames:y(D(),!0)}),{showSaveButton:!0,showQuickBuyButton:!0,showVariantTitle:!0,enableVariantChange:!1,showVariantOptionNames:!0})}),yl=je("type",[fl,ml]),vl=I({desktopColumns:y(_(),4),showBuyButton:y(D(),!0),showVariantOptionNames:y(D(),!1),enableVariantChange:y(D(),!0)}),gl=I({type:K("lists-grid"),hidden:y(D(),!1),design:J,options:y(I({displayType:y(se(["list","slider"]),"slider"),listDetailPage:y(vl,{desktopColumns:4,showBuyButton:!0,showVariantOptionNames:!1,enableVariantChange:!0})}),{displayType:"slider",listDetailPage:{desktopColumns:4,showBuyButton:!0,showVariantOptionNames:!1,enableVariantChange:!0}})}),wl=gl,bl=I({type:K("orders-list"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{})}),Il=bl,Sl=I({type:K("order-info"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{})}),xl=I({type:K("order-items"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{})}),Cl=I({type:K("order-actions"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{})}),El=je("type",[Sl,xl,Cl]),Rl=I({type:K("image-slider"),hidden:y(D(),!1),design:J,options:y(I({flush:y(D(),!0),loop:y(D(),!1)}),{flush:!0,loop:!1})}),kl=I({type:K("product-info"),hidden:y(D(),!1),design:J,options:y(I({descriptionMaxLines:y(_(),4),variantSelectDisplayType:y(se(["pills","rows"]),"pills"),hideSingleValueOptions:y(D(),!0),images:y(I({baseTint:y(D(),!0)}),{baseTint:!0})}),{descriptionMaxLines:4,variantSelectDisplayType:"pills",hideSingleValueOptions:!0,images:{baseTint:!0}})}),Pl=I({type:K("buy-buttons"),hidden:y(D(),!1),design:J,options:y(I({shopPay:y(D(),!1)}),{shopPay:!1})}),Al=I({type:K("complementary-products"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{})}),Tl=I({type:K("related-products"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{})}),Dl=je("type",[Rl,kl,Pl,Al,Tl]),Ol=I({type:K("profile-form"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{})}),Ll=Ol,_l=I({type:K("notifications-list"),hidden:y(D(),!1),design:J,options:y(ee(x(),re()),{})}),Ml=_l,ql=I({enableVariantChange:y(D(),!1),showVariantOptionNames:y(D(),!1)}),Bl=I({sections:y(X(al),[{type:"drawer-header",options:{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0}},{type:"drawer-footer",options:{displayType:"docked",showIcons:!1,showText:!0,items:[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}]}}])}),Fl=I({sections:y(X(hl),[{type:"sign-in"},{type:"notifications"},{type:"recently-viewed"},{type:"saved-from-cart"},{type:"saved-items"},{type:"lists"},{type:"mini-menu",hidden:!0,items:[{title:"Shipping",url:"/policies/shipping-policy"},{title:"Returns",url:"/policies/refund-policy"},{title:"Contact Us",url:"/pages/contact"}]}])}),jl=I({sections:y(X(yl),[{type:"lists-section",options:{display:"myLists"}},{type:"lists-section",options:{display:"forYouLists"}},{type:"all-items-grid"}])}),Nl=I({sections:y(X(wl),[{type:"lists-grid"}])}),$l=I({sections:y(X(Il),[{type:"orders-list"}])}),Ul=I({sections:y(X(El),[{type:"order-info"},{type:"order-items"},{type:"order-actions"}])}),Vl=I({sections:y(X(Dl),[{type:"image-slider"},{type:"product-info"},{type:"buy-buttons"},{type:"complementary-products"},{type:"related-products"}])}),Hl=I({sections:y(X(Ll),[{type:"profile-form"}])}),Ql=I({sections:y(X(Ml),[{type:"notifications-list"}])}),Bs=I({baseUrl:y(x(),"https://swish.app/cdn"),css:y(X(V([x(),Jn(URL)])),[]),design:y(ee(x(),re()),{}),icons:y(ee(x(),x()),{}),images:y(I({baseTint:y(D(),!0)}),{baseTint:!0}),fullpage:y(I({listDetail:y(ql,{})}),{listDetail:{}}),drawer:y(Bl,{}),home:y(Fl,{}),saves:y(jl,{}),lists:y(Nl,{}),orders:y($l,{}),orderDetail:y(Ul,{}),productDetail:y(Vl,{}),profile:y(Hl,{}),notifications:y(Ql,{})});var Fs=r(e=>({auth:{tokenUrl:e.auth?.tokenUrl??"/apps/wishlist/api/profiles/token"},storefront:{storeDomain:e.storefront?.storeDomain??"",accessToken:e.storefront?.accessToken??""},context:{...e.context,routes:{...e.context.routes,rootUrl:e.context.routes?.rootUrl??"/",listDetailPagePath:e.context.routes?.listDetailPagePath??"/apps/wishlist"},localization:{country:e.context.localization.country.toUpperCase(),language:e.context.localization.language.toUpperCase(),market:e.context.localization.market}},metafields:{product:e.metafields?.product??[],productVariant:e.metafields?.productVariant??[]},transforms:{badges:e.transforms?.badges??(({defaultBadges:t})=>t),title:e.transforms?.title??(({product:t})=>t?.title??""),description:e.transforms?.description??(({product:t})=>t?.descriptionHtml??""),variantTitle:e.transforms?.variantTitle??(({variant:t})=>t?.title??""),optionValues:e.transforms?.optionValues??(({optionValues:t})=>t),addToCartButton:e.transforms?.addToCartButton??(()=>!0)},intents:{saveProduct:{promptVariantIfMissing:e?.intents?.saveProduct?.promptVariantIfMissing??!0,promptVariantIfPresent:e?.intents?.saveProduct?.promptVariantIfPresent??!1,saveBeforeVariantPrompt:e?.intents?.saveProduct?.saveBeforeVariantPrompt??!0,showFeedback:e?.intents?.saveProduct?.showFeedback??!0},unsaveProduct:{selectList:e?.intents?.unsaveProduct?.selectList??!0,confirm:e?.intents?.unsaveProduct?.confirm??!0,showFeedback:e?.intents?.unsaveProduct?.showFeedback??!0},editSavedProduct:{promptVariantChange:e?.intents?.editSavedProduct?.promptVariantChange??!0,showFeedback:e?.intents?.editSavedProduct?.showFeedback??!0},initiateQuickBuy:{promptVariantIfPresent:e?.intents?.initiateQuickBuy?.promptVariantIfPresent??!0},createCartLine:{afterComplete:e?.intents?.createCartLine?.afterComplete},removeCartLine:{saveCartLine:e?.intents?.removeCartLine?.saveCartLine??!0},saveCartLine:{confirm:e?.intents?.saveCartLine?.confirm??!1,showFeedback:e?.intents?.saveCartLine?.showFeedback??!0,afterComplete:e?.intents?.saveCartLine?.afterComplete}},placements:e.placements??[],translations:e.translations,ui:_s(Bs,e.ui??{})}),"createSwishOptions");function js(e){return N(String(e).trim())}r(js,"normalizeSwishQueryId");function fn(e){let t=e.productId?js(e.productId):"",n=e.variantId?js(e.variantId):"";return n?["swish","items",t,n]:["swish","items",t]}r(fn,"swishItemsQueryKey");var zl=["item-create","item-update","item-delete"],Ns="auth-cache-clear",$s="token-update";function Us({events:e,queryClient:t}){return e.subscribe([...zl,Ns,$s],n=>{if(!(n instanceof CustomEvent))return;if(n.type===Ns){t.clear();return}if(n.type===$s){t.invalidateQueries({queryKey:["swish"]});return}if(!n.detail?.productId)return;let i=fn({productId:n.detail.productId});t.invalidateQueries({queryKey:i})})}r(Us,"bindSwishItemQueryInvalidation");var xe=class{static{r(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var Gl=class extends xe{static{r(this,"FocusManager")}#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){let t=r(()=>e(),"listener");return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},We=new Gl;var Kl={setTimeout:r((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:r(e=>clearTimeout(e),"clearTimeout"),setInterval:r((e,t)=>setInterval(e,t),"setInterval"),clearInterval:r(e=>clearInterval(e),"clearInterval")},Wl=class{static{r(this,"TimeoutManager")}#e=Kl;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},Ce=new Wl;function Vs(e){setTimeout(e,0)}r(Vs,"systemSetTimeoutZero");var zs=typeof window>"u"||"Deno"in globalThis;function z(){}r(z,"noop");function Gs(e,t){return typeof e=="function"?e(t):e}r(Gs,"functionalUpdate");function ht(e){return typeof e=="number"&&e>=0&&e!==1/0}r(ht,"isValidTimeout");function mn(e,t){return Math.max(e+(t||0)-Date.now(),0)}r(mn,"timeUntilStale");function we(e,t){return typeof e=="function"?e(t):e}r(we,"resolveStaleTime");function pe(e,t){return typeof e=="function"?e(t):e}r(pe,"resolveEnabled");function Zn(e,t){let{type:n="all",exact:i,fetchStatus:s,predicate:o,queryKey:a,stale:l}=e;if(a){if(i){if(t.queryHash!==ft(a,t.options))return!1}else if(!Je(t.queryKey,a))return!1}if(n!=="all"){let c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||s&&s!==t.state.fetchStatus||o&&!o(t))}r(Zn,"matchQuery");function ei(e,t){let{exact:n,status:i,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(Xe(t.options.mutationKey)!==Xe(o))return!1}else if(!Je(t.options.mutationKey,o))return!1}return!(i&&t.state.status!==i||s&&!s(t))}r(ei,"matchMutation");function ft(e,t){return(t?.queryKeyHashFn||Xe)(e)}r(ft,"hashQueryKeyByOptions");function Xe(e){return JSON.stringify(e,(t,n)=>Yn(n)?Object.keys(n).sort().reduce((i,s)=>(i[s]=n[s],i),{}):n)}r(Xe,"hashKey");function Je(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Je(e[n],t[n])):!1}r(Je,"partialMatchKey");var Xl=Object.prototype.hasOwnProperty;function Ks(e,t,n=0){if(e===t)return e;if(n>500)return t;let i=Hs(e)&&Hs(t);if(!i&&!(Yn(e)&&Yn(t)))return t;let o=(i?e:Object.keys(e)).length,a=i?t:Object.keys(t),l=a.length,c=i?new Array(l):{},p=0;for(let u=0;u<l;u++){let d=i?u:a[u],m=e[d],h=t[d];if(m===h){c[d]=m,(i?u<o:Xl.call(e,d))&&p++;continue}if(m===null||h===null||typeof m!="object"||typeof h!="object"){c[d]=h;continue}let w=Ks(m,h,n+1);c[d]=w,w===m&&p++}return o===l&&p===o?e:c}r(Ks,"replaceEqualDeep");function yn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}r(yn,"shallowEqualObjects");function Hs(e){return Array.isArray(e)&&e.length===Object.keys(e).length}r(Hs,"isPlainArray");function Yn(e){if(!Qs(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Qs(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}r(Yn,"isPlainObject");function Qs(e){return Object.prototype.toString.call(e)==="[object Object]"}r(Qs,"hasObjectPrototype");function Ws(e){return new Promise(t=>{Ce.setTimeout(t,e)})}r(Ws,"sleep");function mt(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Ks(e,t):t}r(mt,"replaceData");function Xs(e,t,n=0){let i=[...e,t];return n&&i.length>n?i.slice(1):i}r(Xs,"addToEnd");function Js(e,t,n=0){let i=[t,...e];return n&&i.length>n?i.slice(0,-1):i}r(Js,"addToStart");var yt=Symbol();function vn(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===yt?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}r(vn,"ensureQueryFn");function Ys(e,t,n){let i=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:r(()=>(s??=t(),i||(i=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s),"get")}),e}r(Ys,"addConsumeAwareSignal");var Ne=(()=>{let e=r(()=>zs,"isServerFn");return{isServer(){return e()},setIsServer(t){e=t}}})();function vt(){let e,t,n=new Promise((s,o)=>{e=s,t=o});n.status="pending",n.catch(()=>{});function i(s){Object.assign(n,s),delete n.resolve,delete n.reject}return r(i,"finalize"),n.resolve=s=>{i({status:"fulfilled",value:s}),e(s)},n.reject=s=>{i({status:"rejected",reason:s}),t(s)},n}r(vt,"pendingThenable");function Zs(e){let t;if(e.then(n=>(t=n,n),z)?.catch(z),t!==void 0)return{data:t}}r(Zs,"tryResolveSync");function er(e){return e}r(er,"defaultTransformerFn");function Jl(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}r(Jl,"dehydrateMutation");function Yl(e,t,n){let i=r(()=>{let s=e.promise?.then(t).catch(o=>n(o)?Promise.reject(new Error("redacted")):Promise.reject(o));return s?.catch(z),s},"dehydratePromise");return{dehydratedAt:Date.now(),state:{...e.state,...e.state.data!==void 0&&{data:t(e.state.data)}},queryKey:e.queryKey,queryHash:e.queryHash,...e.state.status==="pending"&&{promise:i()},...e.meta&&{meta:e.meta}}}r(Yl,"dehydrateQuery");function tr(e){return e.state.isPaused}r(tr,"defaultShouldDehydrateMutation");function nr(e){return e.state.status==="success"}r(nr,"defaultShouldDehydrateQuery");function Zl(e){return!0}r(Zl,"defaultShouldRedactErrors");function ti(e,t={}){let n=t.shouldDehydrateMutation??e.getDefaultOptions().dehydrate?.shouldDehydrateMutation??tr,i=e.getMutationCache().getAll().flatMap(c=>n(c)?[Jl(c)]:[]),s=t.shouldDehydrateQuery??e.getDefaultOptions().dehydrate?.shouldDehydrateQuery??nr,o=t.shouldRedactErrors??e.getDefaultOptions().dehydrate?.shouldRedactErrors??Zl,a=t.serializeData??e.getDefaultOptions().dehydrate?.serializeData??er,l=e.getQueryCache().getAll().flatMap(c=>s(c)?[Yl(c,a,o)]:[]);return{mutations:i,queries:l}}r(ti,"dehydrate");function ni(e,t,n){if(typeof t!="object"||t===null)return;let i=e.getMutationCache(),s=e.getQueryCache(),o=n?.defaultOptions?.deserializeData??e.getDefaultOptions().hydrate?.deserializeData??er,a=t.mutations||[],l=t.queries||[];a.forEach(({state:c,...p})=>{i.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...p},c)}),l.forEach(({queryKey:c,state:p,queryHash:u,meta:d,promise:m,dehydratedAt:h})=>{let w=m?Zs(m):void 0,f=p.data===void 0?w?.data:p.data,b=f===void 0?f:o(f),S=s.get(u),P=S?.state.status==="pending",A=S?.state.fetchStatus==="fetching";if(S){let T=w&&h!==void 0&&h>S.state.dataUpdatedAt;if(p.dataUpdatedAt>S.state.dataUpdatedAt||T){let{fetchStatus:C,...R}=p;S.setState({...R,data:b})}}else S=s.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:c,queryHash:u,meta:d},{...p,data:b,fetchStatus:"idle",status:b!==void 0?"success":p.status});m&&!P&&!A&&(h===void 0||h>S.state.dataUpdatedAt)&&S.fetch(void 0,{initialPromise:Promise.resolve(m).then(o)}).catch(z)})}r(ni,"hydrate");var ec=Vs;function tc(){let e=[],t=0,n=r(l=>{l()},"notifyFn"),i=r(l=>{l()},"batchNotifyFn"),s=ec,o=r(l=>{t?e.push(l):s(()=>{n(l)})},"schedule"),a=r(()=>{let l=e;e=[],l.length&&s(()=>{i(()=>{l.forEach(c=>{n(c)})})})},"flush");return{batch:r(l=>{let c;t++;try{c=l()}finally{t--,t||a()}return c},"batch"),batchCalls:r(l=>(...c)=>{o(()=>{l(...c)})},"batchCalls"),schedule:o,setNotifyFunction:r(l=>{n=l},"setNotifyFunction"),setBatchNotifyFunction:r(l=>{i=l},"setBatchNotifyFunction"),setScheduler:r(l=>{s=l},"setScheduler")}}r(tc,"createNotifyManager");var G=tc();var nc=class extends xe{static{r(this,"OnlineManager")}#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){let t=r(()=>e(!0),"onlineListener"),n=r(()=>e(!1),"offlineListener");return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#e}},Ye=new nc;function ic(e){return Math.min(1e3*2**e,3e4)}r(ic,"defaultRetryDelay");function ii(e){return(e??"online")==="online"?Ye.isOnline():!0}r(ii,"canFetch");var gn=class extends Error{static{r(this,"CancelledError")}constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function wn(e){let t=!1,n=0,i,s=vt(),o=r(()=>s.status!=="pending","isResolved"),a=r(f=>{if(!o()){let b=new gn(f);m(b),e.onCancel?.(b)}},"cancel"),l=r(()=>{t=!0},"cancelRetry"),c=r(()=>{t=!1},"continueRetry"),p=r(()=>We.isFocused()&&(e.networkMode==="always"||Ye.isOnline())&&e.canRun(),"canContinue"),u=r(()=>ii(e.networkMode)&&e.canRun(),"canStart"),d=r(f=>{o()||(i?.(),s.resolve(f))},"resolve"),m=r(f=>{o()||(i?.(),s.reject(f))},"reject"),h=r(()=>new Promise(f=>{i=r(b=>{(o()||p())&&f(b)},"continueFn"),e.onPause?.()}).then(()=>{i=void 0,o()||e.onContinue?.()}),"pause"),w=r(()=>{if(o())return;let f,b=n===0?e.initialPromise:void 0;try{f=b??e.fn()}catch(S){f=Promise.reject(S)}Promise.resolve(f).then(d).catch(S=>{if(o())return;let P=e.retry??(Ne.isServer()?0:3),A=e.retryDelay??ic,T=typeof A=="function"?A(n,S):A,C=P===!0||typeof P=="number"&&n<P||typeof P=="function"&&P(n,S);if(t||!C){m(S);return}n++,e.onFail?.(n,S),Ws(T).then(()=>p()?void 0:h()).then(()=>{t?m(S):w()})})},"run");return{promise:s,status:r(()=>s.status,"status"),cancel:a,continue:r(()=>(i?.(),s),"continue"),cancelRetry:l,continueRetry:c,canStart:u,start:r(()=>(u()?w():h().then(w),s),"start")}}r(wn,"createRetryer");var bn=class{static{r(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ht(this.gcTime)&&(this.#e=Ce.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ne.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Ce.clearTimeout(this.#e),this.#e=void 0)}};var rr=class extends bn{static{r(this,"Query")}#e;#t;#n;#s;#i;#o;#r;constructor(e){super(),this.#r=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#s=e.client,this.#n=this.#s.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=sr(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#o,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let t=sr(this.options);t.data!==void 0&&(this.setState(ir(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){let n=mt(this.state.data,e,this.options);return this.#l({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#l({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(z).catch(z):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>pe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===yt||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>we(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!mn(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#r||this.#a()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#a(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}let n=new AbortController,i=r(l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:r(()=>(this.#r=!0,n.signal),"get")})},"addSignalProperty"),s=r(()=>{let l=vn(this.options,t),p=r(()=>{let u={client:this.#s,queryKey:this.queryKey,meta:this.meta};return i(u),u},"createQueryFnContext")();return this.#r=!1,this.options.persister?this.options.persister(l,p,this):l(p)},"fetchFn"),a=r(()=>{let l={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#s,state:this.state,fetchFn:s};return i(l),l},"createFetchContext")();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:"fetch",meta:a.fetchOptions?.meta}),this.#i=wn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:r(l=>{l instanceof gn&&l.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},"onCancel"),onFail:r((l,c)=>{this.#l({type:"failed",failureCount:l,error:c})},"onFail"),onPause:r(()=>{this.#l({type:"pause"})},"onPause"),onContinue:r(()=>{this.#l({type:"continue"})},"onContinue"),retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:r(()=>!0,"canRun")});try{let l=await this.#i.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof gn){if(l.silent)return this.#i.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#l({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#l(e){let t=r(n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...si(n.data,this.options),fetchMeta:e.meta??null};case"success":let i={...n,...ir(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?i:void 0,i;case"error":let s=e.error;return{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}},"reducer");this.state=t(this.state),G.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function si(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ii(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}r(si,"fetchState");function ir(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}r(ir,"successState");function sr(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,i=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}r(sr,"getDefaultState");var oi=class extends xe{static{r(this,"QueryObserver")}constructor(e,t){super(),this.options=t,this.#e=e,this.#a=null,this.#r=vt(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#s=void 0;#i;#o;#r;#a;#l;#h;#f;#u;#p;#c;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),or(this.#t,this.options)?this.#d():this.updateResult(),this.#w())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ri(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ri(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#I(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof pe(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),t._defaulted&&!yn(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let i=this.hasListeners();i&&ar(this.#t,n,this.options,t)&&this.#d(),this.updateResult(),i&&(this.#t!==n||pe(this.options.enabled,this.#t)!==pe(t.enabled,this.#t)||we(this.options.staleTime,this.#t)!==we(t.staleTime,this.#t))&&this.#y();let s=this.#v();i&&(this.#t!==n||pe(this.options.enabled,this.#t)!==pe(t.enabled,this.#t)||s!==this.#c)&&this.#g(s)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return rc(this,n)&&(this.#s=n,this.#o=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#s}trackResult(e,t){return new Proxy(e,{get:r((n,i)=>(this.trackProp(i),t?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#r.status==="pending"&&this.#r.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,i)),"get")})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#d(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(z)),t}#y(){this.#b();let e=we(this.options.staleTime,this.#t);if(Ne.isServer()||this.#s.isStale||!ht(e))return;let n=mn(this.#s.dataUpdatedAt,e)+1;this.#u=Ce.setTimeout(()=>{this.#s.isStale||this.updateResult()},n)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#g(e){this.#I(),this.#c=e,!(Ne.isServer()||pe(this.options.enabled,this.#t)===!1||!ht(this.#c)||this.#c===0)&&(this.#p=Ce.setInterval(()=>{(this.options.refetchIntervalInBackground||We.isFocused())&&this.#d()},this.#c))}#w(){this.#y(),this.#g(this.#v())}#b(){this.#u&&(Ce.clearTimeout(this.#u),this.#u=void 0)}#I(){this.#p&&(Ce.clearInterval(this.#p),this.#p=void 0)}createResult(e,t){let n=this.#t,i=this.options,s=this.#s,o=this.#i,a=this.#o,c=e!==n?e.state:this.#n,{state:p}=e,u={...p},d=!1,m;if(t._optimisticResults){let M=this.hasListeners(),j=!M&&or(e,t),Y=M&&ar(e,n,t,i);(j||Y)&&(u={...u,...si(p.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:h,errorUpdatedAt:w,status:f}=u;m=u.data;let b=!1;if(t.placeholderData!==void 0&&m===void 0&&f==="pending"){let M;s?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(M=s.data,b=!0):M=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,M!==void 0&&(f="success",m=mt(s?.data,M,t),d=!0)}if(t.select&&m!==void 0&&!b)if(s&&m===o?.data&&t.select===this.#l)m=this.#h;else try{this.#l=t.select,m=t.select(m),m=mt(s?.data,m,t),this.#h=m,this.#a=null}catch(M){this.#a=M}this.#a&&(h=this.#a,m=this.#h,w=Date.now(),f="error");let S=u.fetchStatus==="fetching",P=f==="pending",A=f==="error",T=P&&S,C=m!==void 0,E={status:f,fetchStatus:u.fetchStatus,isPending:P,isSuccess:f==="success",isError:A,isInitialLoading:T,isLoading:T,data:m,dataUpdatedAt:u.dataUpdatedAt,error:h,errorUpdatedAt:w,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:S,isRefetching:S&&!P,isLoadingError:A&&!C,isPaused:u.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:A&&C,isStale:ai(e,t),refetch:this.refetch,promise:this.#r,isEnabled:pe(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let M=E.data!==void 0,j=E.status==="error"&&!M,Y=r(be=>{j?be.reject(E.error):M&&be.resolve(E.data)},"finalizeThenableIfPossible"),ne=r(()=>{let be=this.#r=E.promise=vt();Y(be)},"recreateThenable"),W=this.#r;switch(W.status){case"pending":e.queryHash===n.queryHash&&Y(W);break;case"fulfilled":(j||E.data!==W.value)&&ne();break;case"rejected":(!j||E.error!==W.reason)&&ne();break}}return E}updateResult(){let e=this.#s,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#o=this.options,this.#i.data!==void 0&&(this.#f=this.#t),yn(t,e))return;this.#s=t;let n=r(()=>{if(!e)return!0;let{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!this.#m.size)return!0;let o=new Set(s??this.#m);return this.options.throwOnError&&o.add("error"),Object.keys(this.#s).some(a=>{let l=a;return this.#s[l]!==e[l]&&o.has(l)})},"shouldNotifyListeners");this.#x({listeners:n()})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#w()}#x(e){G.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function sc(e,t){return pe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}r(sc,"shouldLoadOnMount");function or(e,t){return sc(e,t)||e.state.data!==void 0&&ri(e,t,t.refetchOnMount)}r(or,"shouldFetchOnMount");function ri(e,t,n){if(pe(t.enabled,e)!==!1&&we(t.staleTime,e)!=="static"){let i=typeof n=="function"?n(e):n;return i==="always"||i!==!1&&ai(e,t)}return!1}r(ri,"shouldFetchOn");function ar(e,t,n,i){return(e!==t||pe(i.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ai(e,n)}r(ar,"shouldFetchOptionally");function ai(e,t){return pe(t.enabled,e)!==!1&&e.isStaleByTime(we(t.staleTime,e))}r(ai,"isStale");function rc(e,t){return!yn(e.getCurrentResult(),t)}r(rc,"shouldAssignObserverCurrentProperties");function li(e){return{onFetch:r((t,n)=>{let i=t.options,s=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],a=t.state.data?.pageParams||[],l={pages:[],pageParams:[]},c=0,p=r(async()=>{let u=!1,d=r(w=>{Ys(w,()=>t.signal,()=>u=!0)},"addSignalProperty"),m=vn(t.options,t.fetchOptions),h=r(async(w,f,b)=>{if(u)return Promise.reject();if(f==null&&w.pages.length)return Promise.resolve(w);let P=r(()=>{let R={client:t.client,queryKey:t.queryKey,pageParam:f,direction:b?"backward":"forward",meta:t.options.meta};return d(R),R},"createQueryFnContext")(),A=await m(P),{maxPages:T}=t.options,C=b?Js:Xs;return{pages:C(w.pages,A,T),pageParams:C(w.pageParams,f,T)}},"fetchPage");if(s&&o.length){let w=s==="backward",f=w?oc:lr,b={pages:o,pageParams:a},S=f(i,b);l=await h(b,S,w)}else{let w=e??o.length;do{let f=c===0?a[0]??i.initialPageParam:lr(i,l);if(c>0&&f==null)break;l=await h(l,f),c++}while(c<w)}return l},"fetchFn");t.options.persister?t.fetchFn=()=>t.options.persister?.(p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=p},"onFetch")}}r(li,"infiniteQueryBehavior");function lr(e,{pages:t,pageParams:n}){let i=t.length-1;return t.length>0?e.getNextPageParam(t[i],t,n[i],n):void 0}r(lr,"getNextPageParam");function oc(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}r(oc,"getPreviousPageParam");var cr=class extends bn{static{r(this,"Mutation")}#e;#t;#n;#s;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||ac(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(e){let t=r(()=>{this.#i({type:"continue"})},"onContinue"),n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=wn({fn:r(()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:r((o,a)=>{this.#i({type:"failed",failureCount:o,error:a})},"onFail"),onPause:r(()=>{this.#i({type:"pause"})},"onPause"),onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:r(()=>this.#n.canRun(this),"canRun")});let i=this.state.status==="pending",s=!this.#s.canStart();try{if(i)t();else{this.#i({type:"pending",variables:e,isPaused:s}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let a=await this.options.onMutate?.(e,n);a!==this.state.context&&this.#i({type:"pending",context:a,variables:e,isPaused:s})}let o=await this.#s.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:"success",data:o}),o}catch(o){try{await this.#n.config.onError?.(o,e,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onError?.(o,e,this.state.context,n)}catch(a){Promise.reject(a)}try{await this.#n.config.onSettled?.(void 0,o,this.state.variables,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,o,e,this.state.context,n)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:o}),o}finally{this.#n.runNext(this)}}#i(e){let t=r(n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}},"reducer");this.state=t(this.state),G.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function ac(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}r(ac,"getDefaultState");var ur=class extends xe{static{r(this,"MutationCache")}constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let i=new cr({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(i),i}add(e){this.#e.add(e);let t=In(e);if(typeof t=="string"){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=In(e);if(typeof t=="string"){let n=this.#t.get(t);if(n)if(n.length>1){let i=n.indexOf(e);i!==-1&&n.splice(i,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=In(e);if(typeof t=="string"){let i=this.#t.get(t)?.find(s=>s.state.status==="pending");return!i||i===e}else return!0}runNext(e){let t=In(e);return typeof t=="string"?this.#t.get(t)?.find(i=>i!==e&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){G.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(n=>ei(t,n))}findAll(e={}){return this.getAll().filter(t=>ei(e,t))}notify(e){G.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return G.batch(()=>Promise.all(e.map(t=>t.continue().catch(z))))}};function In(e){return e.options.scope?.id}r(In,"scopeFor");var pr=class extends xe{static{r(this,"QueryCache")}constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let i=t.queryKey,s=t.queryHash??ft(i,t),o=this.get(s);return o||(o=new rr({client:e,queryKey:i,queryHash:s,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(i)}),this.add(o)),o}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){G.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(n=>Zn(t,n))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Zn(e,n)):t}notify(e){G.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){G.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){G.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var ci=class{static{r(this,"QueryClient")}#e;#t;#n;#s;#i;#o;#r;#a;constructor(e={}){this.#e=e.queryCache||new pr,this.#t=e.mutationCache||new ur,this.#n=e.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#r=We.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Ye.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#r?.(),this.#r=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),i=n.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(we(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(i))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{let i=n.data;return[t,i]})}setQueryData(e,t,n){let i=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(i.queryHash)?.state.data,a=Gs(t,o);if(a!==void 0)return this.#e.build(this,i).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return G.batch(()=>this.#e.findAll(e).map(({queryKey:i})=>[i,this.setQueryData(i,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;G.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){let n=this.#e;return G.batch(()=>(n.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},i=G.batch(()=>this.#e.findAll(e).map(s=>s.cancel(n)));return Promise.all(i).then(z).catch(z)}invalidateQueries(e,t={}){return G.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},i=G.batch(()=>this.#e.findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let o=s.fetch(void 0,n);return n.throwOnError||(o=o.catch(z)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(i).then(z)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(we(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(z).catch(z)}fetchInfiniteQuery(e){return e.behavior=li(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(z).catch(z)}ensureInfiniteQueryData(e){return e.behavior=li(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ye.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#s.set(Xe(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#s.values()],n={};return t.forEach(i=>{Je(e,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Xe(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(i=>{Je(e,i.mutationKey)&&Object.assign(n,i.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ft(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===yt&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function dr(){return new ci({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,gcTime:1e3*60*60*1,staleTime:1e3*60*10}}})}r(dr,"createSwishQueryClient");var lc=Symbol.for("preact-signals");function xn(){if(Le>1)Le--;else{for(var e,t=!1;gt!==void 0;){var n=gt;for(gt=void 0,ui++;n!==void 0;){var i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&yr(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=i}}if(ui=0,Le--,t)throw e}}r(xn,"t");function Ee(e){if(Le>0)return e();Le++;try{return e()}finally{xn()}}r(Ee,"n");var F=void 0;function fr(e){var t=F;F=void 0;try{return e()}finally{F=t}}r(fr,"o");var hr,gt=void 0,Le=0,ui=0,Sn=0;function mr(e){if(F!==void 0){var t=e.n;if(t===void 0||t.t!==F)return t={i:0,S:e,p:F.s,n:void 0,t:F,e:void 0,x:void 0,r:t},F.s!==void 0&&(F.s.n=t),F.s=t,e.n=t,32&F.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=F.s,t.n=void 0,F.s.n=t,F.s=t),t}}r(mr,"e");function oe(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(oe,"d");oe.prototype.brand=lc;oe.prototype.h=function(){return!0};oe.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:fr(function(){var i;(i=t.W)==null||i.call(t)}))};oe.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,i=e.x;n!==void 0&&(n.x=i,e.e=void 0),i!==void 0&&(i.e=n,e.x=void 0),e===this.t&&(this.t=i,i===void 0&&fr(function(){var s;(s=t.Z)==null||s.call(t)}))}};oe.prototype.subscribe=function(e){var t=this;return ae(function(){var n=t.value,i=F;F=void 0;try{e(n)}finally{F=i}},{name:"sub"})};oe.prototype.valueOf=function(){return this.value};oe.prototype.toString=function(){return this.value+""};oe.prototype.toJSON=function(){return this.value};oe.prototype.peek=function(){var e=F;F=void 0;try{return this.value}finally{F=e}};Object.defineProperty(oe.prototype,"value",{get:r(function(){var e=mr(this);return e!==void 0&&(e.i=this.i),this.v},"get"),set:r(function(e){if(e!==this.v){if(ui>100)throw new Error("Cycle detected");this.v=e,this.i++,Sn++,Le++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{xn()}}},"set")});function $(e,t){return new oe(e,t)}r($,"c");function yr(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}r(yr,"a");function vr(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}r(vr,"l");function gr(e){for(var t=e.s,n=void 0;t!==void 0;){var i=t.p;t.i===-1?(t.S.U(t),i!==void 0&&(i.n=t.n),t.n!==void 0&&(t.n.p=i)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=i}e.s=n}r(gr,"y");function $e(e,t){oe.call(this,void 0),this.x=e,this.s=void 0,this.g=Sn-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r($e,"w");$e.prototype=new oe;$e.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Sn))return!0;if(this.g=Sn,this.f|=1,this.i>0&&!yr(this))return this.f&=-2,!0;var e=F;try{vr(this),F=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return F=e,gr(this),this.f&=-2,!0};$e.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}oe.prototype.S.call(this,e)};$e.prototype.U=function(e){if(this.t!==void 0&&(oe.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};$e.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty($e.prototype,"value",{get:r(function(){if(1&this.f)throw new Error("Cycle detected");var e=mr(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v},"get")});function de(e,t){return new $e(e,t)}r(de,"b");function wr(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Le++;var n=F;F=void 0;try{t()}catch(i){throw e.f&=-2,e.f|=8,pi(e),i}finally{F=n,xn()}}}r(wr,"_");function pi(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,wr(e)}r(pi,"p");function cc(e){if(F!==this)throw new Error("Out-of-order effect");gr(this),F=e,this.f&=-2,8&this.f&&pi(this),xn()}r(cc,"g");function Ze(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name,hr&&hr.push(this)}r(Ze,"S");Ze.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};Ze.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,wr(this),vr(this),Le++;var e=F;return F=this,cc.bind(this,e)};Ze.prototype.N=function(){2&this.f||(this.f|=2,this.o=gt,gt=this)};Ze.prototype.d=function(){this.f|=8,1&this.f||pi(this)};Ze.prototype.dispose=function(){this.d()};function ae(e,t){var n=new Ze(e,t);try{n.c()}catch(s){throw n.d(),s}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}r(ae,"m");var uc="swish-query-cache";function pc(e){return e.replace(/\.myshopify\.com$/,"")||"unknown-store"}r(pc,"normalizeStoreKeyPart");function Cn({customerId:e,storeDomain:t}){let n=e??"guest",i=pc(t??"");return`${uc}:${i}:${n}`}r(Cn,"getSwishQueryStorageKey");var dc=1e3*60*60*24,hc=1e3;function di(){return!!globalThis.window?.localStorage}r(di,"canUseLocalStorage");function fc(e){if(!di())return null;let t=globalThis.window.localStorage.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return globalThis.window.localStorage.removeItem(e),null}}r(fc,"readPersistedState");function mc(e,t){if(di())try{globalThis.window.localStorage.setItem(e,JSON.stringify(t))}catch{}}r(mc,"writePersistedState");function yc(e){if(di())try{globalThis.window.localStorage.removeItem(e)}catch{}}r(yc,"removePersistedState");function vc(e,t){return Number.isFinite(e.timestamp)?Date.now()-e.timestamp>t:!0}r(vc,"isPersistedStateExpired");function br({queryClient:e,cacheBuster:t,customerId:n,storeDomain:i,maxAgeMs:s=dc,throttleMs:o=hc}){let a=Cn({customerId:n,storeDomain:i}),l=$(!1),c=fc(a);c?.buster===t&&!vc(c,s)?ni(e,c.clientState):c&&yc(a),l.value=!0;let p=null,u=!1,d=r(()=>{mc(a,{buster:t,timestamp:Date.now(),clientState:ti(e)})},"persistNow"),m=r(()=>{u=!0,!p&&(p=setTimeout(()=>{p=null,u&&(u=!1,d())},Math.max(o,0)))},"schedulePersist"),h=r(()=>{u&&(u=!1,p&&(clearTimeout(p),p=null),d())},"flushPersist"),w=e.getQueryCache().subscribe(b=>{l.value&&m()}),f=r(()=>{h()},"onPageHide");return globalThis.window?.addEventListener("pagehide",f),{restored:l,storageKey:a,dispose:r(()=>{globalThis.window?.removeEventListener("pagehide",f),w(),h()},"dispose")}}r(br,"initSwishQueryPersistence");function Ir({events:e,cacheBuster:t,customerId:n,storeDomain:i}){let s=dr(),o=br({queryClient:s,cacheBuster:t,customerId:n,storeDomain:i});return Us({events:e,queryClient:s}),{client:s,cacheBuster:t,restored:o.restored,storageKey:o.storageKey,keys:{items:fn}}}r(Ir,"createSwishQuery");var Sr=r(e=>t=>{let n=t instanceof Location,i=t instanceof HTMLAnchorElement,s=t instanceof HTMLElement;if(!n&&!i&&!s)throw new Error("Invalid source");let{productHandle:o,productId:a,variantId:l,itemId:c}=s?t.dataset:{},d=!!(a||o)||!!c,m=$({loading:!1,productHandle:o,productId:a,variantId:l,itemId:c});if(!d&&(n||i)){let h=t.href,w=lt(h);w?.productHandle&&w.productHandle!==m.value.productHandle&&(m.value={...m.value,...w,productId:void 0},Ds({source:t,onProductUrlChange:r(f=>{m.value={...m.value,...f,productId:f.productHandle===m.value.productHandle?m.value.productId:void 0}},"onProductUrlChange")}))}return ae(()=>{m.value.loading||!m.value.productId&&m.value.productHandle&&(m.value={...m.value,loading:!0},e.storefront.loadProductId({productHandle:m.value.productHandle}).then(h=>{h.errors&&console.error("Error loading product id",h.errors);let w=h.data?.product?.id?N(h.data.product.id):void 0;m.value={...m.value,productId:w,loading:!w}}))}),m},"itemContextSignal");function xr({queryClient:e,options:t,restored:n}){let i=$(null),s=$(!1),o=$(null),a=$(!1),l=r(w=>{let f=n?.value??!0,b=w.enabled??!0;return{...w,enabled:!!(b&&f)}},"getObserverOptions"),c=new oi(e,l(t.value)),p=r(w=>{Ee(()=>{i.value=w.data??null,s.value=w.isLoading,a.value=w.isRefetching,o.value=w.error??null})},"syncResult"),u=c.subscribe(p);p(c.getCurrentResult());let d=ae(()=>{c.setOptions(l(t.value))}),m=!1;return{data:i,loading:s,error:o,refetching:a,refetch:r(()=>c.refetch(),"refetch"),dispose:r(()=>{m||(m=!0,d(),u(),c.destroy())},"dispose")}}r(xr,"createTanstackQuerySignal");var Cr=r(e=>t=>{let n=[],i=de(()=>{let{productId:M,variantId:j,loading:Y}=t.value;return!M||Y?null:j?`variant:${N(j)}`:`product:${N(M)}`}),s=de(()=>t.value.loading||!!t.value.itemId||!t.value.productId),o=$(!s.value),a=$(null),l=$(!1),c=$(!1),p=de(()=>{let M=i.value,j=s.value,{productId:Y,variantId:ne}=t.value;return{queryKey:e.query.keys.items({productId:Y,variantId:ne}),queryFn:r(async()=>{let W=await e.api.items.list({limit:1,query:M??void 0});if("error"in W)throw W.error;return W},"queryFn"),enabled:!j}}),{data:u,loading:d,error:m,refetching:h,dispose:w}=xr({queryClient:e.query.client,options:p,restored:e.query.restored});n.push(w);let f=$(t.value.itemId??null),b=ae(()=>{Ee(()=>{if(o.value=d.value,a.value=m.value,!t.value.itemId){let M=u.value?.data?.[0]?.id??null;M!==f.value&&(f.value=M)}})});n.push(b);async function S(){if(!f.value)return;l.value=!0;let j=await(await e.intents.invoke("unsave:item",{itemId:f.value})).complete;j.code==="ok"&&"itemId"in j.data&&(f.value=null),l.value=!1}r(S,"unsave");async function P(){if(!f.value)return;l.value=!0;let j=await(await e.intents.invoke("edit:item-lists",{itemId:f.value})).complete;j.code==="ok"&&"itemId"in j.data&&(f.value=null),l.value=!1}r(P,"update");async function A(){let{productId:M,variantId:j}=t.value;if(!M)return;l.value=!0,c.value=!0;let ne=await(await e.intents.invoke("save:item",{productId:M,variantId:j})).complete;if(ne.code==="ok"){let W=ne.data;f.value=W.item.id,l.value=!1}else ne.code==="error"&&console.warn("Failed to create item",ne),Ee(()=>{l.value=!1,c.value=!1})}r(A,"save");let T=de(()=>o.value||l.value||t.value.loading),C=ae(()=>{c.value&&!l.value&&!h.value&&(c.value=!1)});n.push(C);let R=de(()=>{let M=h.value&&c.value,j=!!f.value,Y=!j&&(l.value||M),ne=de(()=>Y?"saving":j?"saved":"unsaved");return{error:a.value,status:ne.value,savedItemId:f.value,loading:T.value,submitting:l.value,saved:j,saving:Y}});async function E(){T.value||(R.value.saved&&R.value.savedItemId?S():R.value.saved||await A())}return r(E,"toggle"),Object.assign(R,{save:A,unsave:S,update:P,toggle:E,dispose:r(()=>{for(;n.length;)n.pop()?.()},"dispose")})},"itemStateSignal");var Er=r(e=>()=>{let{data:t,loading:n,error:i}=e.state.swishQuery(()=>e.api.items.count(),{refetch:["item-create","item-delete"]}),s=$(0),o=$(!0),a=$(null);return ae(()=>{Ee(()=>{o.value=n.value,a.value=i.value,s.value=t.value?.count??0})}),de(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var gc="token-update",Rr=r(e=>(t,n)=>{let i=$(null),s=$(null),o=$(null),a=$(!n?.skip),l=$(!1),c=de(()=>a.value&&l.value);async function p(){if(!n?.skip?.value)try{a.value=!0;let u=await t(n?.variables?.value);Ee(()=>{o.value="error"in u?u.error:null,i.value="data"in u?u.data:null,s.value="pageInfo"in u?u.pageInfo:null,a.value=!1,l.value=!0})}catch(u){Ee(()=>{o.value=u,a.value=!1,l.value=!0})}}return r(p,"executeFetch"),ae(()=>{if(p(),n?.refetch?.length){let u=[...n.refetch,gc];return e.events.subscribe(u,p)}}),{data:i,pageInfo:s,error:o,loading:a,refetching:c}},"swishQuerySignals");function wc(e,t){let n=zn(t),i=e.state.itemContext(n),s=e.state.itemState(i);e.state.effect(()=>{let{status:a,saved:l}=s.value;t.setAttribute("swish-item-state",a),t.setAttribute("aria-pressed",String(l))}),t.querySelectorAll("[swish-item-label]").forEach(a=>{bc(e,a,s)});let o=r(()=>{s.toggle()},"onClick");t.addEventListener("click",o)}r(wc,"bindItemState");function bc(e,t,n){let i=t.textContent??"",s=t.getAttribute("swish-item-label-unsaved")??"Save",o=t.getAttribute("swish-item-label-saved")??"Saved",a={unsaved:s,saved:o,saving:t.getAttribute("swish-item-label-saving")??o};e.state.effect(()=>{t.textContent=a[n.value.status]??i})}r(bc,"bindItemLabel");function Ic(e,t){let n=e.state.itemCount();e.state.effect(()=>{let{count:i,loading:s}=n.value,o=s?"":String(i);t.setAttribute("swish-item-count",o),t.textContent=o})}r(Ic,"bindItemCount");function kr(e){Se({selector:"[swish-item-state]",onElementFound:r(t=>{wc(e,t)},"onElementFound")}),Se({selector:"[swish-item-count]",onElementFound:r(t=>{Ic(e,t)},"onElementFound")})}r(kr,"initDeclarativeState");var Ue="GraphQL Client";var hi="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",fi="Response returned unexpected Content-Type:",mi="An unknown error has occurred. The API did not return a data object or any errors in its response.",En={json:"application/json",multipart:"multipart/mixed"},yi="X-SDK-Variant",vi="X-SDK-Version",Ar="shopify-graphql-client",Tr="1.4.1",Rn=1e3,Dr=[429,503],gi=/@(defer)\b/i,Pr=`\r
|
|
8
|
-
`,Or=/boundary="?([^=";]+)"?/i,wi=Pr+Pr;function Re(e,t=Ue){return e.startsWith(`${t}`)?e:`${t}: ${e}`}r(Re,"formatErrorMessage");function De(e){return e instanceof Error?e.message:JSON.stringify(e)}r(De,"getErrorMessage");function bi(e){return e instanceof Error&&e.cause?e.cause:void 0}r(bi,"getErrorCause");function Ii(e){return e.flatMap(({errors:t})=>t??[])}r(Ii,"combineErrors");function kn({client:e,retries:t}){if(t!==void 0&&(typeof t!="number"||t<0||t>3))throw new Error(`${e}: The provided "retries" value (${t}) is invalid - it cannot be less than ${0} or greater than ${3}`)}r(kn,"validateRetries");function le(e,t){return t&&(typeof t!="object"||Array.isArray(t)||typeof t=="object"&&Object.keys(t).length>0)?{[e]:t}:{}}r(le,"getKeyValueIfValid");function Si(e,t){if(e.length===0)return t;let i={[e.pop()]:t};return e.length===0?i:Si(e,i)}r(Si,"buildDataObjectByPath");function Mr(e,t){return Object.keys(t||{}).reduce((n,i)=>(typeof t[i]=="object"||Array.isArray(t[i]))&&e[i]?(n[i]=Mr(e[i],t[i]),n):(n[i]=t[i],n),Array.isArray(e)?[...e]:{...e})}r(Mr,"combineObjects");function xi([e,...t]){return t.reduce(Mr,{...e})}r(xi,"buildCombinedDataObject");function Ci({clientLogger:e,customFetchApi:t=fetch,client:n=Ue,defaultRetryWaitTime:i=Rn,retriableCodes:s=Dr}){let o=r(async(a,l,c)=>{let p=l+1,u=c+1,d;try{if(d=await t(...a),e({type:"HTTP-Response",content:{requestParams:a,response:d}}),!d.ok&&s.includes(d.status)&&p<=u)throw new Error;let m=d?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return m&&e({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:m}}),d}catch(m){if(p<=u){let h=d?.headers.get("Retry-After");return await Sc(h?parseInt(h,10):i),e({type:"HTTP-Retry",content:{requestParams:a,lastResponse:d,retryAttempt:l,maxRetries:c}}),o(a,p,c)}throw new Error(Re(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${De(m)}`,n))}},"httpFetch");return o}r(Ci,"generateHttpFetch");async function Sc(e){return new Promise(t=>setTimeout(t,e))}r(Sc,"sleep");function Ei({headers:e,url:t,customFetchApi:n=fetch,retries:i=0,logger:s}){kn({client:Ue,retries:i});let o={headers:e,url:t,retries:i},a=xc(s),l=Ci({customFetchApi:n,clientLogger:a,defaultRetryWaitTime:Rn}),c=Cc(l,o),p=Ec(c),u=Oc(c);return{config:o,fetch:c,request:p,requestStream:u}}r(Ei,"createGraphQLClient");function xc(e){return t=>{e&&e(t)}}r(xc,"generateClientLogger");async function qr(e){let{errors:t,data:n,extensions:i}=await e.json();return{...le("data",n),...le("extensions",i),headers:e.headers,...t||!n?{errors:{networkStatusCode:e.status,message:Re(t?hi:mi),...le("graphQLErrors",t),response:e}}:{}}}r(qr,"processJSONResponse");function Cc(e,{url:t,headers:n,retries:i}){return async(s,o={})=>{let{variables:a,headers:l,url:c,retries:p,keepalive:u,signal:d}=o,m=JSON.stringify({query:s,variables:a});kn({client:Ue,retries:p});let h=Object.entries({...n,...l}).reduce((f,[b,S])=>(f[b]=Array.isArray(S)?S.join(", "):S.toString(),f),{});return!h[yi]&&!h[vi]&&(h[yi]=Ar,h[vi]=Tr),e([c??t,{method:"POST",headers:h,body:m,signal:d,keepalive:u}],1,p??i)}}r(Cc,"generateFetch");function Ec(e){return async(...t)=>{if(gi.test(t[0]))throw new Error(Re("This operation will result in a streamable response - use requestStream() instead."));let n=null;try{n=await e(...t);let{status:i,statusText:s}=n,o=n.headers.get("content-type")||"";return n.ok?o.includes(En.json)?await qr(n):{errors:{networkStatusCode:i,message:Re(`${fi} ${o}`),response:n}}:{errors:{networkStatusCode:i,message:Re(s),response:n}}}catch(i){return{errors:{message:De(i),...n==null?{}:{networkStatusCode:n.status,response:n}}}}}}r(Ec,"generateRequest");async function*Rc(e){let t=new TextDecoder;if(e.body[Symbol.asyncIterator])for await(let n of e.body)yield t.decode(n);else{let n=e.body.getReader(),i;try{for(;!(i=await n.read()).done;)yield t.decode(i.value)}finally{n.cancel()}}}r(Rc,"getStreamBodyIterator");function kc(e,t){return{async*[Symbol.asyncIterator](){try{let n="";for await(let i of e)if(n+=i,n.indexOf(t)>-1){let s=n.lastIndexOf(t),a=n.slice(0,s).split(t).filter(l=>l.trim().length>0).map(l=>l.slice(l.indexOf(wi)+wi.length).trim());a.length>0&&(yield a),n=n.slice(s+t.length),n.trim()==="--"&&(n="")}}catch(n){throw new Error(`Error occured while processing stream payload - ${De(n)}`)}}}}r(kc,"readStreamChunk");function Pc(e){return{async*[Symbol.asyncIterator](){yield{...await qr(e),hasNext:!1}}}}r(Pc,"createJsonResponseAsyncIterator");function Ac(e){return e.map(t=>{try{return JSON.parse(t)}catch(n){throw new Error(`Error in parsing multipart response - ${De(n)}`)}}).map(t=>{let{data:n,incremental:i,hasNext:s,extensions:o,errors:a}=t;if(!i)return{data:n||{},...le("errors",a),...le("extensions",o),hasNext:s};let l=i.map(({data:c,path:p,errors:u})=>({data:c&&p?Si(p,c):{},...le("errors",u)}));return{data:l.length===1?l[0].data:xi([...l.map(({data:c})=>c)]),...le("errors",Ii(l)),hasNext:s}})}r(Ac,"getResponseDataFromChunkBodies");function Tc(e,t){if(e.length>0)throw new Error(hi,{cause:{graphQLErrors:e}});if(Object.keys(t).length===0)throw new Error(mi)}r(Tc,"validateResponseData");function Dc(e,t){let n=(t??"").match(Or),i=`--${n?n[1]:"-"}`;if(!e.body?.getReader&&!e.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:e});let s=Rc(e),o={},a;return{async*[Symbol.asyncIterator](){try{let l=!0;for await(let c of kc(s,i)){let p=Ac(c);a=p.find(d=>d.extensions)?.extensions??a;let u=Ii(p);o=xi([o,...p.map(({data:d})=>d)]),l=p.slice(-1)[0].hasNext,Tc(u,o),yield{...le("data",o),...le("extensions",a),hasNext:l}}if(l)throw new Error("Response stream terminated unexpectedly")}catch(l){let c=bi(l);yield{...le("data",o),...le("extensions",a),errors:{message:Re(De(l)),networkStatusCode:e.status,...le("graphQLErrors",c?.graphQLErrors),response:e},hasNext:!1}}}}}r(Dc,"createMultipartResponseAsyncInterator");function Oc(e){return async(...t)=>{if(!gi.test(t[0]))throw new Error(Re("This operation does not result in a streamable response - use request() instead."));try{let n=await e(...t),{statusText:i}=n;if(!n.ok)throw new Error(i,{cause:n});let s=n.headers.get("content-type")||"";switch(!0){case s.includes(En.json):return Pc(n);case s.includes(En.multipart):return Dc(n,s);default:throw new Error(`${fi} ${s}`,{cause:n})}}catch(n){return{async*[Symbol.asyncIterator](){let i=bi(n);yield{errors:{message:Re(De(n)),...le("networkStatusCode",i?.status),...le("response",i)},hasNext:!1}}}}}}r(Oc,"generateRequestStream");function Ri({client:e,storeDomain:t}){try{if(!t||typeof t!="string")throw new Error;let n=t.trim(),i=n.match(/^https?:/)?n:`https://${n}`,s=new URL(i);return s.protocol="https",s.origin}catch(n){throw new Error(`${e}: a valid store domain ("${t}") must be provided`,{cause:n})}}r(Ri,"validateDomainAndGetStoreUrl");function Pn({client:e,currentSupportedApiVersions:t,apiVersion:n,logger:i}){let s=`${e}: the provided apiVersion ("${n}")`,o=`Currently supported API versions: ${t.join(", ")}`;if(!n||typeof n!="string")throw new Error(`${s} is invalid. ${o}`);let a=n.trim();t.includes(a)||(i?i({type:"Unsupported_Api_Version",content:{apiVersion:n,supportedApiVersions:t}}):console.warn(`${s} is likely deprecated or not supported. ${o}`))}r(Pn,"validateApiVersion");function An(e){let t=e*3-2;return t===10?t:`0${t}`}r(An,"getQuarterMonth");function ki(e,t,n){let i=t-n;return i<=0?`${e-1}-${An(i+4)}`:`${e}-${An(i)}`}r(ki,"getPrevousVersion");function Br(){let e=new Date,t=e.getUTCMonth(),n=e.getUTCFullYear(),i=Math.floor(t/3+1);return{year:n,quarter:i,version:`${n}-${An(i)}`}}r(Br,"getCurrentApiVersion");function Pi(){let{year:e,quarter:t,version:n}=Br(),i=t===4?`${e+1}-01`:`${e}-${An(t+1)}`;return[ki(e,t,3),ki(e,t,2),ki(e,t,1),n,i,"unstable"]}r(Pi,"getCurrentSupportedApiVersions");function Ai(e){return t=>({...t??{},...e.headers})}r(Ai,"generateGetHeaders");function Ti({getHeaders:e,getApiUrl:t}){return(n,i)=>{let s=[n];if(i&&Object.keys(i).length>0){let{variables:o,apiVersion:a,headers:l,retries:c,signal:p}=i;s.push({...o?{variables:o}:{},...l?{headers:e(l)}:{},...a?{url:t(a)}:{},...c?{retries:c}:{},...p?{signal:p}:{}})}return s}}r(Ti,"generateGetGQLClientParams");var Di="application/json",Fr="storefront-api-client",jr="1.0.9",Nr="X-Shopify-Storefront-Access-Token",$r="Shopify-Storefront-Private-Token",Ur="X-SDK-Variant",Vr="X-SDK-Version",Hr="X-SDK-Variant-Source",Ve="Storefront API Client";function Qr(e){if(e&&typeof window<"u")throw new Error(`${Ve}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}r(Qr,"validatePrivateAccessTokenUsage");function zr(e,t){if(!e&&!t)throw new Error(`${Ve}: a public or private access token must be provided`);if(e&&t)throw new Error(`${Ve}: only provide either a public or private access token`)}r(zr,"validateRequiredAccessTokens");function Oi({storeDomain:e,apiVersion:t,publicAccessToken:n,privateAccessToken:i,clientName:s,retries:o=0,customFetchApi:a,logger:l}){let c=Pi(),p=Ri({client:Ve,storeDomain:e}),u={client:Ve,currentSupportedApiVersions:c,logger:l};Pn({...u,apiVersion:t}),zr(n,i),Qr(i);let d=Lc(p,t,u),m={storeDomain:p,apiVersion:t,...n?{publicAccessToken:n}:{privateAccessToken:i},headers:{"Content-Type":Di,Accept:Di,[Ur]:Fr,[Vr]:jr,...s?{[Hr]:s}:{},...n?{[Nr]:n}:{[$r]:i}},apiUrl:d(),clientName:s},h=Ei({headers:m.headers,url:m.apiUrl,retries:o,customFetchApi:a,logger:l}),w=Ai(m),f=_c(m,d),b=Ti({getHeaders:w,getApiUrl:f});return Object.freeze({config:m,getHeaders:w,getApiUrl:f,fetch:r((...P)=>h.fetch(...b(...P)),"fetch"),request:r((...P)=>h.request(...b(...P)),"request"),requestStream:r((...P)=>h.requestStream(...b(...P)),"requestStream")})}r(Oi,"createStorefrontApiClient");function Lc(e,t,n){return i=>{i&&Pn({...n,apiVersion:i});let s=(i??t).trim();return`${e}/api/${s}/graphql.json`}}r(Lc,"generateApiUrlFormatter");function _c(e,t){return n=>n?t(n):e.apiUrl}r(_c,"generateGetApiUrl");var Tn=`
|
|
7
|
+
`+String(i)));Gi(t);for(var s=0;s<t.callbacks.length;s++){var o=i[s];o instanceof Error?t.callbacks[s].reject(o):t.callbacks[s].resolve(o)}}).catch(function(i){zi(e,t,i)})}r(ad,"dispatchBatch");function zi(e,t,n){Gi(t);for(var i=0;i<t.keys.length;i++)e.clear(t.keys[i]),t.callbacks[i].reject(n)}r(zi,"failedDispatch");function Gi(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}r(Gi,"resolveCacheHits");function ld(e){var t=!e||e.batch!==!1;if(!t)return 1;var n=e&&e.maxBatchSize;if(n===void 0)return 1/0;if(typeof n!="number"||n<1)throw new TypeError("maxBatchSize must be a positive number: "+n);return n}r(ld,"getValidMaxBatchSize");function cd(e){var t=e&&e.batchScheduleFn;if(t===void 0)return rd;if(typeof t!="function")throw new TypeError("batchScheduleFn must be a function: "+t);return t}r(cd,"getValidBatchScheduleFn");function ud(e){var t=e&&e.cacheKeyFn;if(t===void 0)return function(n){return n};if(typeof t!="function")throw new TypeError("cacheKeyFn must be a function: "+t);return t}r(ud,"getValidCacheKeyFn");function dd(e){var t=!e||e.cache!==!1;if(!t)return null;var n=e&&e.cacheMap;if(n===void 0)return new Map;if(n!==null){var i=["get","set","delete","clear"],s=i.filter(function(o){return n&&typeof n[o]!="function"});if(s.length!==0)throw new TypeError("Custom cacheMap missing methods: "+s.join(", "))}return n}r(dd,"getValidCacheMap");function pd(e){return e&&e.name?e.name:null}r(pd,"getValidName");function Eo(e){return typeof e=="object"&&e!==null&&typeof e.length=="number"&&(e.length===0||e.length>0&&Object.prototype.hasOwnProperty.call(e,e.length-1))}r(Eo,"isArrayLike");Ro.exports=sd});function ts(e,t="",n=new Map){for(let[i,s]of Object.entries(e)){let o=t?`${t}.${i}`:i;typeof s=="object"&&s!==null?ts(s,o,n):typeof s=="string"&&n.set(o,s)}return n}r(ts,"c");var Ko=new Set(["en"]),ot="en";function ns(e,t){return t?.count===void 0?e:t.count===1?`${e}One`:`${e}Other`}r(ns,"d");function es(e,t,n){t=ns(t,n);let i=e.get(t)??t;return n&&(n.count!==void 0&&(i=i.replace("{{count}}",n.count.toString())),Object.entries(n).forEach(([s,o])=>{s!=="count"&&typeof o=="string"&&(i=i.replace(`{{${s}}}`,o))})),i}r(es,"f");function is(e,t){let n=null;async function i(o){let a=await import(`${e}/locales/${o.toLowerCase()}.js`);return ts(a.default)}r(i,"a");function s(o,a){return n?n.has(ns(o,a))?{status:"ready",value:es(n,o,a),key:o}:{status:"missing",value:es(n,o,a),key:o}:{status:"pending",value:o,key:o}}return r(s,"r"),{t(o,a){return s(o,a).value},resolveTranslation:s,async loadLocale(o){let a=o;Ko.has(o)||(console.warn(`[swish] Unsupported language "${o}", falling back to "${ot}".`),a=ot);let l;try{l=await i(a)}catch(c){if(console.warn(`[swish-i18n] Failed to load locale "${a}".`,c),a!==ot)try{l=await i(ot)}catch{console.warn(`[swish] Failed to load fallback locale "${ot}".`);return}else return}if(t?.[a])for(let[c,d]of Object.entries(t[a]))d!==void 0&&l.set(c,d);n=l}}}r(is,"L");var N=r(e=>e.split("/").pop()??"","shopifyGidToId"),Oe=r((e,t)=>`gid://shopify/${e}/${t}`,"shopifyIdToGid"),me=r(e=>e.toLowerCase().replace(".myshopify.com",""),"toShopName");var _e=class{constructor(t,n,i=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.clearCachePromise=null;this.cacheName=t,this.defaultCacheControl=n,this.keyPrefix=i}static{r(this,"FetchCache")}async get(t){try{let n=await caches.open(this.cacheName),i=await n.match(t);if(i&&this.isExpired(i)){await n.delete(t);return}return i}catch(n){console.warn("Cache get error:",n);return}}async set(t,n,i){try{if(i?.includes("no-cache"))return;let s=this.createCacheableResponse(n,i);await(await caches.open(this.cacheName)).put(t,s)}catch(s){console.warn("Cache set error:",s)}}async fetchWithCache(t,n,i){let s=await this.getCacheKey(t,n);if(this.clearCachePromise&&await this.clearCachePromise,this.inFlightRequests.has(s))return this.inFlightRequests.get(s).then(a=>a.clone());let o=(async()=>{let a=await this.get(s);if(a)return this.isStaleButRevalidatable(a)&&this.revalidateInBackground(s,t,n,i),a.clone();let l=await fetch(t,n);return l.ok&&await this.set(s,l.clone(),i??this.defaultCacheControl),l})().finally(()=>{this.inFlightRequests.delete(s)});return this.inFlightRequests.set(s,o),o}async delete(t){try{return await(await caches.open(this.cacheName)).delete(t)}catch(n){return console.warn("Cache delete error:",n),!1}}async clear(){return this.clearCachePromise?this.clearCachePromise:(this.clearCachePromise=new Promise(async(t,n)=>{try{let i=await caches.open(this.cacheName),s=await i.keys();await Promise.all(s.map(o=>i.delete(o))),t()}catch(i){console.warn("Cache clear error:",i),n(i)}}),this.clearCachePromise.then(()=>{this.clearCachePromise=null}).catch(t=>{console.warn("Cache clear error:",t)}))}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(i=>i.url)}catch(t){return console.warn("Cache keys error:",t),[]}}async has(t){try{let n=await caches.open(this.cacheName),i=await n.match(t);return i&&this.isExpired(i)?(await n.delete(t),!1):i!==void 0}catch(n){return console.warn("Cache has error:",n),!1}}async getStats(){try{return{total:(await(await caches.open(this.cacheName)).keys()).length}}catch(t){return console.warn("Cache stats error:",t),{total:0}}}async cleanupExpiredEntries(){try{let t=await caches.open(this.cacheName),n=await t.keys(),i=0;for(let o of n){let a=await t.match(o);a&&this.isExpired(a)&&(await t.delete(o),i++)}let s=n.length-i;return{removed:i,remaining:s}}catch(t){return console.warn("Cache cleanup error:",t),{removed:0,remaining:0}}}async getCacheKey(t,n){let i=this.getInputUrl(t),s=`${this.keyPrefix}${i}/${JSON.stringify(n)}`,a=new TextEncoder().encode(s),l=await crypto.subtle.digest("SHA-256",a);return`/${Array.from(new Uint8Array(l)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}getInputUrl(t){return t instanceof URL?t.toString():typeof t=="string"?t:t.url}isExpired(t){let n=t.headers.get("Cache-Control");if(!n)return!1;let i=this.parseMaxAge(n),s=this.parseStaleWhileRevalidate(n);if(i===null)return!1;let o=t.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3,d=i+(s??0);return c>d}isStaleButRevalidatable(t){let n=t.headers.get("Cache-Control");if(!n)return!1;let i=this.parseMaxAge(n),s=this.parseStaleWhileRevalidate(n);if(i===null||s===null)return!1;let o=t.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3;return c>i&&c<=i+s}async revalidateInBackground(t,n,i,s){if(this.revalidationPromises.has(t))return;let o=(async()=>{try{let a=await fetch(n,i);a.ok&&await this.set(t,a.clone(),s??this.defaultCacheControl)}catch(a){console.warn("Background revalidation error:",a)}finally{this.revalidationPromises.delete(t)}})();this.revalidationPromises.set(t,o)}parseMaxAge(t){let n=new RegExp(/max-age=(\d+)/).exec(t);return n?parseInt(n[1],10):null}parseStaleWhileRevalidate(t){let n=new RegExp(/stale-while-revalidate=(\d+)/).exec(t);return n?parseInt(n[1],10):null}createCacheableResponse(t,n){let i=new Headers(t.headers);return i.set("Cache-Control",n),i.has("Date")||i.set("Date",new Date().toUTCString()),new Response(t.body,{status:t.status,statusText:t.statusText,headers:i})}};var Ct=class{static{r(this,"AjaxApiClient")}constructor(t){this.config=t;let n=me(t.storeDomain);this.cache=new _e(`ajax-api-${n}`,"max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(i=>{console.warn("Ajax API cache initialization cleanup error:",i)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let t=window.fetch,n=this.config.responseInterceptor,i=this.getFetchRequest.bind(this);window.fetch=function(...s){let o=t.apply(this,s);if(typeof n=="function"){let a=i(s[0]);o.then(l=>n(l,a))}return o}}getFetchRequest(t){return t instanceof Request?t:new Request(t)}fetch(t,n){return(t instanceof Request?t.method:n?.method??"GET")==="GET"?this.cache.fetchWithCache(t,n):fetch(t,n)}async request(t,n={}){let i=`${window.location.origin}${t}`,s={"Content-Type":"application/json",Accept:"application/json"},o=await this.fetch(i,{...n,headers:{...s,...n.headers}});if(!o.ok){let a;try{a=await o.json()}catch{a={message:`HTTP ${o.status}: ${o.statusText}`,status:o.status.toString(),description:o.statusText}}throw new Error(a.message||a.description)}return o.json()}async fetchCart(){return this.request("/cart.js")}async addToCart(t){let n={...t,items:t.items.map(i=>{let s=Number(N(String(i.id)));if(!Number.isFinite(s)||s<=0)throw new Error(`Invalid Shopify ID: ${i.id}`);return{...i,id:s}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(n)})}async clearCache(){await this.cache.clear()}};var Et=class{constructor(t){this.eventMap={"/cart/add":"cart-add","/cart/update":"cart-update","/cart/change":"cart-change","/cart/clear":"cart-clear"};this.previousCart=null;this.eventBus=t,this.processFetchResponse=this.processFetchResponse.bind(this)}static{r(this,"AjaxApiPublisher")}async processFetchResponse(t,n){try{let i=this.getEventName(n.url);if(!(i||n.url.includes("/cart.js")))return;let o=await t.clone().json();if(i==="cart-update"&&!o.items_removed){let a=this.diffRemovedItems(o);this.snapshotCart(o),this.eventBus.publish(i,{...o,items_removed:a})}else this.snapshotCart(o),i&&this.eventBus.publish(i,o)}catch(i){console.warn(i)}}getEventName(t){for(let[n,i]of Object.entries(this.eventMap))if(t.includes(n))return i;return null}snapshotCart(t){typeof t=="object"&&t!==null&&"token"in t&&"items"in t&&(this.previousCart=t)}diffRemovedItems(t){let n=this.previousCart;if(!n)return[];let i=new Set(t.items.map(o=>o.key)),s=[];for(let o of n.items)i.has(o.key)||s.push(this.toCartChangeItem(o));return s}toCartChangeItem(t){return{product_id:t.product_id,variant_id:t.variant_id,id:String(t.id),image:t.image,price:String(t.price),presentment_price:t.price,quantity:t.quantity,title:t.title,product_title:t.product_title,variant_title:t.variant_title,vendor:t.vendor,product_type:t.product_type,sku:t.sku,url:t.url,untranslated_product_title:t.product_title,untranslated_variant_title:t.variant_title,view_key:""}}};var at=Math.min,Fe=Math.max,lt=Math.round,ct=Math.floor,be=r(e=>({x:e,y:e}),"createCoords");function Qn(e,t){return typeof e=="function"?e(t):e}r(Qn,"evaluate");function zn(e){return e.split("-")[0]}r(zn,"getSide");function Gn(e){return e.split("-")[1]}r(Gn,"getAlignment");function rs(e){return e==="x"?"y":"x"}r(rs,"getOppositeAxis");function os(e){return e==="y"?"height":"width"}r(os,"getAxisLength");function Rt(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}r(Rt,"getSideAxis");function as(e){return rs(Rt(e))}r(as,"getAlignmentAxis");function Wo(e){return{top:0,right:0,bottom:0,left:0,...e}}r(Wo,"expandPaddingObject");function ls(e){return typeof e!="number"?Wo(e):{top:e,right:e,bottom:e,left:e}}r(ls,"getPaddingObject");function Ne(e){let{x:t,y:n,width:i,height:s}=e;return{width:i,height:s,top:n,left:t,right:t+i,bottom:n+s,x:t,y:n}}r(Ne,"rectToClientRect");function cs(e,t,n){let{reference:i,floating:s}=e,o=Rt(t),a=as(t),l=os(a),c=zn(t),d=o==="y",u=i.x+i.width/2-s.width/2,p=i.y+i.height/2-s.height/2,f=i[l]/2-s[l]/2,h;switch(c){case"top":h={x:u,y:i.y-s.height};break;case"bottom":h={x:u,y:i.y+i.height};break;case"right":h={x:i.x+i.width,y:p};break;case"left":h={x:i.x-s.width,y:p};break;default:h={x:i.x,y:i.y}}switch(Gn(t)){case"start":h[a]-=f*(n&&d?-1:1);break;case"end":h[a]+=f*(n&&d?-1:1);break}return h}r(cs,"computeCoordsFromPlacement");async function us(e,t){var n;t===void 0&&(t={});let{x:i,y:s,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:f=!1,padding:h=0}=Qn(t,e),w=ls(h),b=l[f?p==="floating"?"reference":"floating":p],S=Ne(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),k=p==="floating"?{x:i,y:s,width:a.floating.width,height:a.floating.height}:a.reference,A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),D=await(o.isElement==null?void 0:o.isElement(A))?await(o.getScale==null?void 0:o.getScale(A))||{x:1,y:1}:{x:1,y:1},C=Ne(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:A,strategy:c}):k);return{top:(S.top-C.top+w.top)/D.y,bottom:(C.bottom-S.bottom+w.bottom)/D.y,left:(S.left-C.left+w.left)/D.x,right:(C.right-S.right+w.right)/D.x}}r(us,"detectOverflow");var Xo=50,ds=r(async(e,t,n)=>{let{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:us},c=await(a.isRTL==null?void 0:a.isRTL(t)),d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:p}=cs(d,i,c),f=i,h=0,w={};for(let m=0;m<o.length;m++){let b=o[m];if(!b)continue;let{name:S,fn:k}=b,{x:A,y:D,data:C,reset:P}=await k({x:u,y:p,initialPlacement:i,placement:f,strategy:s,middlewareData:w,rects:d,platform:l,elements:{reference:e,floating:t}});u=A??u,p=D??p,w[S]={...w[S],...C},P&&h<Xo&&(h++,typeof P=="object"&&(P.placement&&(f=P.placement),P.rects&&(d=P.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):P.rects),{x:u,y:p}=cs(d,f,c)),m=-1)}return{x:u,y:p,placement:f,strategy:s,middlewareData:w}},"computePosition");var Jo=new Set(["left","top"]);async function Yo(e,t){let{placement:n,platform:i,elements:s}=e,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=zn(n),l=Gn(n),c=Rt(n)==="y",d=Jo.has(a)?-1:1,u=o&&c?-1:1,p=Qn(t,e),{mainAxis:f,crossAxis:h,alignmentAxis:w}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof w=="number"&&(h=l==="end"?w*-1:w),c?{x:h*u,y:f*d}:{x:f*d,y:h*u}}r(Yo,"convertValueToCoords");var ps=r(function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,i;let{x:s,y:o,placement:a,middlewareData:l}=t,c=await Yo(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:a}}}}},"offset");function kt(){return typeof window<"u"}r(kt,"hasWindow");function $e(e){return fs(e)?(e.nodeName||"").toLowerCase():"#document"}r($e,"getNodeName");function ue(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}r(ue,"getWindow");function Ie(e){var t;return(t=(fs(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}r(Ie,"getDocumentElement");function fs(e){return kt()?e instanceof Node||e instanceof ue(e).Node:!1}r(fs,"isNode");function ve(e){return kt()?e instanceof Element||e instanceof ue(e).Element:!1}r(ve,"isElement");function Re(e){return kt()?e instanceof HTMLElement||e instanceof ue(e).HTMLElement:!1}r(Re,"isHTMLElement");function hs(e){return!kt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ue(e).ShadowRoot}r(hs,"isShadowRoot");function Je(e){let{overflow:t,overflowX:n,overflowY:i,display:s}=ge(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&s!=="inline"&&s!=="contents"}r(Je,"isOverflowElement");function ms(e){return/^(table|td|th)$/.test($e(e))}r(ms,"isTableElement");function ut(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}r(ut,"isTopLayer");var Zo=/transform|translate|scale|rotate|perspective|filter/,ea=/paint|layout|strict|content/,Ue=r(e=>!!e&&e!=="none","isNotNone"),Kn;function Pt(e){let t=ve(e)?ge(e):e;return Ue(t.transform)||Ue(t.translate)||Ue(t.scale)||Ue(t.rotate)||Ue(t.perspective)||!At()&&(Ue(t.backdropFilter)||Ue(t.filter))||Zo.test(t.willChange||"")||ea.test(t.contain||"")}r(Pt,"isContainingBlock");function ys(e){let t=Me(e);for(;Re(t)&&!Ve(t);){if(Pt(t))return t;if(ut(t))return null;t=Me(t)}return null}r(ys,"getContainingBlock");function At(){return Kn==null&&(Kn=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Kn}r(At,"isWebKit");function Ve(e){return/^(html|body|#document)$/.test($e(e))}r(Ve,"isLastTraversableNode");function ge(e){return ue(e).getComputedStyle(e)}r(ge,"getComputedStyle");function dt(e){return ve(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}r(dt,"getNodeScroll");function Me(e){if($e(e)==="html")return e;let t=e.assignedSlot||e.parentNode||hs(e)&&e.host||Ie(e);return hs(t)?t.host:t}r(Me,"getParentNode");function vs(e){let t=Me(e);return Ve(t)?e.ownerDocument?e.ownerDocument.body:e.body:Re(t)&&Je(t)?t:vs(t)}r(vs,"getNearestOverflowAncestor");function Xe(e,t,n){var i;t===void 0&&(t=[]),n===void 0&&(n=!0);let s=vs(e),o=s===((i=e.ownerDocument)==null?void 0:i.body),a=ue(s);if(o){let l=Tt(a);return t.concat(a,a.visualViewport||[],Je(s)?s:[],l&&n?Xe(l):[])}else return t.concat(s,Xe(s,[],n))}r(Xe,"getOverflowAncestors");function Tt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}r(Tt,"getFrameElement");function Is(e){let t=ge(e),n=parseFloat(t.width)||0,i=parseFloat(t.height)||0,s=Re(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:i,l=lt(n)!==o||lt(i)!==a;return l&&(n=o,i=a),{width:n,height:i,$:l}}r(Is,"getCssDimensions");function Xn(e){return ve(e)?e:e.contextElement}r(Xn,"unwrapElement");function Ye(e){let t=Xn(e);if(!Re(t))return be(1);let n=t.getBoundingClientRect(),{width:i,height:s,$:o}=Is(t),a=(o?lt(n.width):n.width)/i,l=(o?lt(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}r(Ye,"getScale");var ta=be(0);function Ss(e){let t=ue(e);return!At()||!t.visualViewport?ta:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}r(Ss,"getVisualOffsets");function na(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ue(e)?!1:t}r(na,"shouldAddVisualOffsets");function He(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);let s=e.getBoundingClientRect(),o=Xn(e),a=be(1);t&&(i?ve(i)&&(a=Ye(i)):a=Ye(e));let l=na(o,n,i)?Ss(o):be(0),c=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,u=s.width/a.x,p=s.height/a.y;if(o){let f=ue(o),h=i&&ve(i)?ue(i):i,w=f,m=Tt(w);for(;m&&i&&h!==w;){let b=Ye(m),S=m.getBoundingClientRect(),k=ge(m),A=S.left+(m.clientLeft+parseFloat(k.paddingLeft))*b.x,D=S.top+(m.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,d*=b.y,u*=b.x,p*=b.y,c+=A,d+=D,w=ue(m),m=Tt(w)}}return Ne({width:u,height:p,x:c,y:d})}r(He,"getBoundingClientRect");function Dt(e,t){let n=dt(e).scrollLeft;return t?t.left+n:He(Ie(e)).left+n}r(Dt,"getWindowScrollBarX");function xs(e,t){let n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-Dt(e,n),s=n.top+t.scrollTop;return{x:i,y:s}}r(xs,"getHTMLOffset");function ia(e){let{elements:t,rect:n,offsetParent:i,strategy:s}=e,o=s==="fixed",a=Ie(i),l=t?ut(t.floating):!1;if(i===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},d=be(1),u=be(0),p=Re(i);if((p||!p&&!o)&&(($e(i)!=="body"||Je(a))&&(c=dt(i)),p)){let h=He(i);d=Ye(i),u.x=h.x+i.clientLeft,u.y=h.y+i.clientTop}let f=a&&!p&&!o?xs(a,c):be(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x+f.x,y:n.y*d.y-c.scrollTop*d.y+u.y+f.y}}r(ia,"convertOffsetParentRelativeRectToViewportRelativeRect");function sa(e){return Array.from(e.getClientRects())}r(sa,"getClientRects");function ra(e){let t=Ie(e),n=dt(e),i=e.ownerDocument.body,s=Fe(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=Fe(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),a=-n.scrollLeft+Dt(e),l=-n.scrollTop;return ge(i).direction==="rtl"&&(a+=Fe(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:a,y:l}}r(ra,"getDocumentRect");var gs=25;function oa(e,t){let n=ue(e),i=Ie(e),s=n.visualViewport,o=i.clientWidth,a=i.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;let u=At();(!u||u&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}let d=Dt(i);if(d<=0){let u=i.ownerDocument,p=u.body,f=getComputedStyle(p),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,w=Math.abs(i.clientWidth-p.clientWidth-h);w<=gs&&(o-=w)}else d<=gs&&(o+=d);return{width:o,height:a,x:l,y:c}}r(oa,"getViewportRect");function aa(e,t){let n=He(e,!0,t==="fixed"),i=n.top+e.clientTop,s=n.left+e.clientLeft,o=Re(e)?Ye(e):be(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=s*o.x,d=i*o.y;return{width:a,height:l,x:c,y:d}}r(aa,"getInnerBoundingClientRect");function ws(e,t,n){let i;if(t==="viewport")i=oa(e,n);else if(t==="document")i=ra(Ie(e));else if(ve(t))i=aa(t,n);else{let s=Ss(e);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Ne(i)}r(ws,"getClientRectFromClippingAncestor");function Cs(e,t){let n=Me(e);return n===t||!ve(n)||Ve(n)?!1:ge(n).position==="fixed"||Cs(n,t)}r(Cs,"hasFixedPositionAncestor");function la(e,t){let n=t.get(e);if(n)return n;let i=Xe(e,[],!1).filter(l=>ve(l)&&$e(l)!=="body"),s=null,o=ge(e).position==="fixed",a=o?Me(e):e;for(;ve(a)&&!Ve(a);){let l=ge(a),c=Pt(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Je(a)&&!c&&Cs(e,a))?i=i.filter(u=>u!==a):s=l,a=Me(a)}return t.set(e,i),i}r(la,"getClippingElementAncestors");function ca(e){let{element:t,boundary:n,rootBoundary:i,strategy:s}=e,a=[...n==="clippingAncestors"?ut(t)?[]:la(t,this._c):[].concat(n),i],l=ws(t,a[0],s),c=l.top,d=l.right,u=l.bottom,p=l.left;for(let f=1;f<a.length;f++){let h=ws(t,a[f],s);c=Fe(h.top,c),d=at(h.right,d),u=at(h.bottom,u),p=Fe(h.left,p)}return{width:d-p,height:u-c,x:p,y:c}}r(ca,"getClippingRect");function ua(e){let{width:t,height:n}=Is(e);return{width:t,height:n}}r(ua,"getDimensions");function da(e,t,n){let i=Re(t),s=Ie(t),o=n==="fixed",a=He(e,!0,o,t),l={scrollLeft:0,scrollTop:0},c=be(0);function d(){c.x=Dt(s)}if(r(d,"setLeftRTLScrollbarOffset"),i||!i&&!o)if(($e(t)!=="body"||Je(s))&&(l=dt(t)),i){let h=He(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&d();o&&!i&&s&&d();let u=s&&!i&&!o?xs(s,l):be(0),p=a.left+l.scrollLeft-c.x-u.x,f=a.top+l.scrollTop-c.y-u.y;return{x:p,y:f,width:a.width,height:a.height}}r(da,"getRectRelativeToOffsetParent");function Wn(e){return ge(e).position==="static"}r(Wn,"isStaticPositioned");function bs(e,t){if(!Re(e)||ge(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ie(e)===n&&(n=n.ownerDocument.body),n}r(bs,"getTrueOffsetParent");function Es(e,t){let n=ue(e);if(ut(e))return n;if(!Re(e)){let s=Me(e);for(;s&&!Ve(s);){if(ve(s)&&!Wn(s))return s;s=Me(s)}return n}let i=bs(e,t);for(;i&&ms(i)&&Wn(i);)i=bs(i,t);return i&&Ve(i)&&Wn(i)&&!Pt(i)?n:i||ys(e)||n}r(Es,"getOffsetParent");var pa=r(async function(e){let t=this.getOffsetParent||Es,n=this.getDimensions,i=await n(e.floating);return{reference:da(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},"getElementRects");function ha(e){return ge(e).direction==="rtl"}r(ha,"isRTL");var fa={convertOffsetParentRelativeRectToViewportRelativeRect:ia,getDocumentElement:Ie,getClippingRect:ca,getOffsetParent:Es,getElementRects:pa,getClientRects:sa,getDimensions:ua,getScale:Ye,isElement:ve,isRTL:ha};function Rs(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}r(Rs,"rectsAreEqual");function ma(e,t){let n=null,i,s=Ie(e);function o(){var l;clearTimeout(i),(l=n)==null||l.disconnect(),n=null}r(o,"cleanup");function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();let d=e.getBoundingClientRect(),{left:u,top:p,width:f,height:h}=d;if(l||t(),!f||!h)return;let w=ct(p),m=ct(s.clientWidth-(u+f)),b=ct(s.clientHeight-(p+h)),S=ct(u),A={rootMargin:-w+"px "+-m+"px "+-b+"px "+-S+"px",threshold:Fe(0,at(1,c))||1},D=!0;function C(P){let E=P[0].intersectionRatio;if(E!==c){if(!D)return a();E?a(!1,E):i=setTimeout(()=>{a(!1,1e-7)},1e3)}E===1&&!Rs(d,e.getBoundingClientRect())&&a(),D=!1}r(C,"handleObserve");try{n=new IntersectionObserver(C,{...A,root:s.ownerDocument})}catch{n=new IntersectionObserver(C,A)}n.observe(e)}return r(a,"refresh"),a(!0),o}r(ma,"observeMove");function ks(e,t,n,i){i===void 0&&(i={});let{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,d=Xn(e),u=s||o?[...d?Xe(d):[],...t?Xe(t):[]]:[];u.forEach(S=>{s&&S.addEventListener("scroll",n,{passive:!0}),o&&S.addEventListener("resize",n)});let p=d&&l?ma(d,n):null,f=-1,h=null;a&&(h=new ResizeObserver(S=>{let[k]=S;k&&k.target===d&&h&&t&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var A;(A=h)==null||A.observe(t)})),n()}),d&&!c&&h.observe(d),t&&h.observe(t));let w,m=c?He(e):null;c&&b();function b(){let S=He(e);m&&!Rs(m,S)&&n(),m=S,w=requestAnimationFrame(b)}return r(b,"frameLoop"),n(),()=>{var S;u.forEach(k=>{s&&k.removeEventListener("scroll",n),o&&k.removeEventListener("resize",n)}),p?.(),(S=h)==null||S.disconnect(),h=null,c&&cancelAnimationFrame(w)}}r(ks,"autoUpdate");var Ps=ps;var As=r((e,t,n)=>{let i=new Map,s={platform:fa,...n},o={...s.platform,_c:i};return ds(e,t,{...s,platform:o})},"computePosition");function ya(){let e=document.body||document.documentElement;return e?Promise.resolve(e):new Promise(t=>{window.addEventListener("DOMContentLoaded",()=>t(e))})}r(ya,"waitForDOM");function ke({onElementFound:e,selector:t,observerOptions:n,mustMatch:i}){let s=new WeakSet,o=new MutationObserver(d=>{let u=!1;for(let p of d)if(p.addedNodes.length>0){u=!0;break}u&&a()}),a=r(()=>{document.querySelectorAll(t).forEach(d=>{s.has(d)||(s.add(d),i?.(d)!==!1&&l(d))})},"locateElements"),l=r(d=>{if(!n){e(d);return}let u=new IntersectionObserver(p=>{for(let f of p)f.isIntersecting&&(u.disconnect(),e(d))},n);u.observe(d)},"observeElement");return r(async()=>{let d=await ya();a(),o.observe(d,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}r(ke,"createElementLocator");function Ze({onLocationChange:e,fireOnInit:t=!1}){let n=r(()=>{e(window.location)},"handleChange");window.addEventListener("popstate",n);let i=history.pushState,s=history.replaceState;return history.pushState=function(...o){i.apply(this,o),n()},history.replaceState=function(...o){s.apply(this,o),n()},t&&n(),()=>{window.removeEventListener("popstate",n),history.pushState=i,history.replaceState=s}}r(Ze,"createLocationObserver");function Lt(e,t){let n=e.parentElement;for(;n;){let i=n.querySelector(t);if(i&&i!==e)return i;n=n.parentElement}return null}r(Lt,"findNearestElement");function Ts({element:e,onHrefChange:t}){let n=r(()=>{t(e.href)},"handleChange"),i=new MutationObserver(()=>{n()});return i.observe(e,{attributes:!0,attributeFilter:["href"]}),()=>{i.disconnect()}}r(Ts,"createHrefObserver");function Jn(e){let t=e.getAttribute("swish-item-context");return t?t==="location"?globalThis.window?.location??e:Lt(e,t)??e:e}r(Jn,"resolveItemContextSource");function Ds(e,t){return e.getAttribute("swish-item-context")?Jn(e):t}r(Ds,"resolvePlacementItemContextSource");function Yn(e,t){if(!t.element)throw new Error("Element must be provided");let n=null,i=new Map,s=r(()=>{if(n){console.warn("Placement already mounted. Skipping mount.");return}ga(t),n=ke({selector:t.target.selector,observerOptions:t.target.observerOptions,mustMatch:t.target.mustMatch,onElementFound:r(d=>o(d),"onElementFound")})},"mount"),o=r(d=>{i.has(d)||d.hasAttribute("swish-ignore")||d.getAttribute("swish-placement-target")===t.id||(d.setAttribute("swish-placement-target",t.id),a(d))},"evaluateAndMount"),a=r(async d=>{let u=[],p=t.mount.mode,f=Ms(d,t.mount.at);if(!f)return;let h=await(typeof t.element=="function"?t.element(t):Oa(e,t.element));if(!h)return;if(h.setAttribute("swish-placement-element",t.id),typeof t.element!="function"){let E=t.element;E.props&&_a(h,E.props),E.classNames&&Bs(h,E.classNames)}let w;t.container&&(w=La(t.id,t.container),w.appendChild(h));let m,b=w??h;if(t.layout?.type==="overlay"){Pa(f);let E=t.layout.anchor??"bottom-right";b.setAttribute("swish-placement-overlay",t.id),b.setAttribute("swish-placement-anchor",E)}else t.layout?.type==="anchored"&&b.setAttribute("swish-placement-anchored",t.id);let S=!1,k;if(t.layout?.type==="inline"){let E=t.layout,B=E.rowSelector?f.closest(E.rowSelector):null;B?m=B:(m=Da(t.id,f,E),S=!0),k=m.getAttribute("swish-placement-inline-row"),m.setAttribute("swish-placement-inline-row",t.id)}let A=w??h;if(!ka(f,A,p)){try{A.remove()}catch{}return}if(t.layout?.type==="anchored"){let E=Ms(d,t.layout.to)??f,B=Aa(E,b,t.layout);u.push(B)}let C={targetEl:d,renderTargetEl:f,mountEl:h,containerEl:w,rowEl:m,rowWasCreated:S,rowInlineAttrPrevValue:k,cleanupFns:u,ownsNode:!0};i.set(d,C);let P={id:t.id,targetEl:d,renderTargetEl:f,mountEl:C.mountEl,containerEl:w,rowEl:m,cleanup:r(E=>u.push(E),"cleanup")};t.element?.name==="save-button"&&va(e,P),t.onMount?.(P)},"mountElement"),l=r(d=>{let u=i.get(d);if(u){if(t.onUnmount?.({id:t.id,targetEl:u.targetEl,renderTargetEl:u.renderTargetEl,mountEl:u.mountEl,containerEl:u.containerEl,rowEl:u.rowEl}),u.cleanupFns.forEach(p=>p()),u.targetEl.getAttribute("swish-placement-target")===t.id&&u.targetEl.removeAttribute("swish-placement-target"),u.ownsNode&&(u.containerEl||u.mountEl).remove(),u.rowEl){if(u.rowWasCreated){let p=u.rowEl.parentElement;p&&u.targetEl.parentElement===u.rowEl?u.rowEl.replaceWith(u.targetEl):p?p.removeChild(u.rowEl):u.rowEl.remove()}else if(u.rowInlineAttrPrevValue!==void 0){let p=u.rowInlineAttrPrevValue;p===null?u.rowEl.removeAttribute("swish-placement-inline-row"):u.rowEl.setAttribute("swish-placement-inline-row",p)}}i.delete(d)}},"unmountElement");return{mount:s,unmount:r(()=>{n&&(n.disconnect(),n=null),i.forEach((d,u)=>l(u)),i.clear()},"unmount")}}r(Yn,"createPlacement");var va=r((e,{mountEl:t,targetEl:n,cleanup:i})=>{let s=Ds(t,n),o=e.state.itemContext(s),a=e.state.effect(()=>{let{loading:l,productId:c,variantId:d}=o.value;l||(t.setAttribute("product-id",c??""),t.setAttribute("variant-id",d??""))});i(()=>a?.())},"saveButtonMount");function ga(e){let t=wa(e.id),n=Ra(e),i=document.getElementById(t);if(i){i.textContent=n;return}let s=document.createElement("style");s.id=t,s.setAttribute("swish-placement-style",e.id),s.textContent=n,document.head.appendChild(s)}r(ga,"ensurePlacementStylesheet");function wa(e){return`swish-placement-style-${ba(e)}`}r(wa,"getPlacementStyleId");function ba(e){return e.replace(/[^a-zA-Z0-9\-_]/g,"_")}r(ba,"cssEscapeId");function Ls(e){return`--swish-placement-${Ia(String(e))}`}r(Ls,"designKeyToCSSVar");function Ia(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Ia,"toKebabCase");function Sa(e){return Object.entries(e??{sm:500,lg:700}).map(([i,s])=>({name:i,minWidth:s})).sort((i,s)=>i.minWidth-s.minWidth)}r(Sa,"getBreakpoints");function qs(e,t){if(e==null)return{};if(typeof e=="object"&&!Array.isArray(e)){if(t&&t.size){let n=Object.keys(e);return"base"in e||n.some(s=>t.has(s))?e:{base:e}}return e}return{base:e}}r(qs,"normalizeResponsiveValue");var xa=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function Os(e,t){if(t!=null)return typeof t=="number"&&!xa.has(e)?`${t}px`:String(t)}r(Os,"formatDesignValue");function Ca(e,t,n){if(!t)return"";let i=new Set(n.map(c=>c.name)),s=[],o={},a=Object.entries(t).map(([c,d])=>[c,d]);for(let[c,d]of a){let u=qs(d,i),p=Os(String(c),u.base);p!==void 0&&s.push(`${Ls(c)}:${p};`);for(let f of n){let h=u[f.name],w=Os(String(c),h);w!==void 0&&(o[f.name]||(o[f.name]=[]),o[f.name].push(`${Ls(c)}:${w};`))}}let l=[];s.length&&l.push(`[swish-placement-element="${e}"]{${s.join("")}}`);for(let c of n){let d=o[c.name];d?.length&&l.push(`@media(min-width:${c.minWidth}px){[swish-placement-element="${e}"]{${d.join("")}}}`)}return l.join("")}r(Ca,"emitDesignCSS");function Ot(e){return e==null?"0px":typeof e=="number"?`${e}px`:e}r(Ot,"formatOffsetValue");function _s(e){return e==null?"":typeof e=="number"?`${e}`:e}r(_s,"formatZIndexValue");function Ea(e,t,n){let i=new Set(n.map(d=>d.name)),s=qs(t,i),o=s.base??{},a=Ot(o.x),l=Ot(o.y),c=[];c.push(`[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${a};--swish-placement-offset-y:${l};}`);for(let d of n){let u=s[d.name];if(!u)continue;let p=Ot(u.x),f=Ot(u.y);c.push(`@media(min-width:${d.minWidth}px){[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${p};--swish-placement-offset-y:${f};}}`)}return c.join("")}r(Ea,"emitOverlayOffsetCSS");function Ra(e){let t=e.id,n=Sa(e.breakpoints),i=`[swish-placement-inline-row="${t}"]{display:flex;flex-direction:row;align-items:center;gap:var(--swish-placement-inline-gap,8px);width:100%}[swish-placement-inline-row="${t}"]>*:not([swish-placement-element="${t}"]){flex:1;min-width:0}`,s=`[swish-placement-overlay="${t}"]{position:absolute;z-index:var(--swish-placement-overlay-z,10);transform:translate(calc(var(--swish-placement-sign-x,1)*var(--swish-placement-offset-x,0px)),calc(var(--swish-placement-sign-y,1)*var(--swish-placement-offset-y,0px)));}[swish-placement-overlay="${t}"][swish-placement-anchor="top-left"]{top:0;left:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="top-right"]{top:0;right:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="bottom-left"]{bottom:0;left:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="bottom-right"]{bottom:0;right:0;}[swish-placement-overlay="${t}"][swish-placement-anchor$="left"]{--swish-placement-sign-x:1;}[swish-placement-overlay="${t}"][swish-placement-anchor$="right"]{--swish-placement-sign-x:-1;}[swish-placement-overlay="${t}"][swish-placement-anchor^="top"]{--swish-placement-sign-y:1;}[swish-placement-overlay="${t}"][swish-placement-anchor^="bottom"]{--swish-placement-sign-y:-1;}`,o="";if(e.layout?.type==="overlay"){let a=Ea(t,e.layout.offset,n),l=e.layout.zIndex?`[swish-placement-overlay="${t}"]{--swish-placement-overlay-z:${_s(e.layout.zIndex)};}`:"";o+=a+l+s}else if(e.layout?.type==="anchored"){let a=e.layout.zIndex?_s(e.layout.zIndex):"10";o+=`[swish-placement-anchored="${t}"]{position:absolute;width:max-content;top:0;left:0;z-index:${a};}`}else e.layout?.type==="inline"&&(o+=i);if(e.design){let a=Ca(t,e.design,n);a&&(o+=a)}return e.css&&(o+=e.css.trim()),o}r(Ra,"buildPlacementCSS");function Ms(e,t){if(!t||t==="target")return e;if(typeof t=="string"&&(t={nearest:t}),"nearest"in t)return Lt(e,t.nearest);if("closest"in t)return e.closest(t.closest);if("query"in t)return e.querySelector(t.query);if("withinClosest"in t){let n=e.closest(t.withinClosest.root);return n?n.querySelector(t.withinClosest.selector):null}return e}r(Ms,"resolveMountTarget");function ka(e,t,n){switch(n){case"before":return e.parentElement?(e.before(t),!0):!1;case"after":{let i=e.parentElement;return i?(i.insertBefore(t,e.nextSibling),!0):!1}case"append":return e.appendChild(t),!0;case"prepend":return e.insertBefore(t,e.firstChild),!0;case"replace":return e.parentElement?(e.replaceWith(t),!0):!1}}r(ka,"insertIntoDOM");function Pa(e){let t=e.parentElement;return t?(window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t):null}r(Pa,"ensureRelativeParent");function Aa(e,t,n){let i=[];return n.inside?i.push(Ta(n.offset??0)):n.offset&&i.push(Ps(n.offset)),ks(e,t,r(()=>{As(e,t,{placement:n.placement??"bottom-end",middleware:i}).then(({x:o,y:a})=>{Object.assign(t.style,{left:`${o}px`,top:`${a}px`})})},"update"))}r(Aa,"setupAnchoredPosition");function Ta(e){return{name:"anchoredInside",fn({x:t,y:n,rects:i,placement:s}){let[o,a]=s.split("-"),l=0,c=0,d=o==="top"||o==="bottom";return o==="top"?c=i.floating.height+e:o==="bottom"?c=-(i.floating.height+e):o==="left"?l=i.floating.width+e:o==="right"&&(l=-(i.floating.width+e)),d&&a==="start"?l=e:d&&a==="end"?l=-e:!d&&a==="start"?c=e:!d&&a==="end"&&(c=-e),{x:t+l,y:n+c}}}}r(Ta,"anchoredInsideMiddleware");function Da(e,t,n){if(!t.parentElement)throw new Error("Cannot inline-wrap: refEl has no parentElement");let s=document.createElement("div");return s.setAttribute("swish-placement-inline-row",e),t.before(s),s.appendChild(t),s}r(Da,"wrapWithFlexRow");function La(e,t){let n=t.tag||"div",i=document.createElement(n);return i.setAttribute("swish-placement-container",e),t.classNames&&Bs(i,t.classNames),i}r(La,"createContainer");function Oa(e,t){return e.ui.createElement(t.name,{})}r(Oa,"createElement");function _a(e,t){for(let[n,i]of Object.entries(t)){let s=n.replace(/([A-Z])/g,"-$1").toLowerCase();i===!1||i===void 0||i===null||(i===!0?e.setAttribute(s,"true"):e.setAttribute(s,String(i)))}}r(_a,"applyProps");function Bs(e,t){e.classList.add(...t)}r(Bs,"applyClassNames");var _t=class{constructor(){this.eventBus=new EventTarget}static{r(this,"EventBus")}subscribe(t,n,i){return Array.isArray(t)||(t=[t]),t.forEach(s=>{this.eventBus.addEventListener(s,n,i)}),()=>{t.forEach(s=>{this.eventBus.removeEventListener(s,n,i)})}}unsubscribe(t,n,i){this.eventBus.removeEventListener(t,n,i)}publish(t,n){this.eventBus.dispatchEvent(new CustomEvent(t,{detail:n}))}};var Ma=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,pt=r(e=>{let t=e.match(Ma);return t?{productHandle:decodeURIComponent(t[1]),variantId:t[2]}:null},"parseProductUrl"),Fs=r(({source:e,onProductUrlChange:t})=>{let n=r(i=>{let s=pt(i);s?.productHandle&&t(s)},"handleChange");if(e instanceof HTMLAnchorElement)return Ts({element:e,onHrefChange:r(i=>n(i),"onHrefChange")});if(e instanceof Location)return Ze({onLocationChange:r(i=>n(i.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Zn;function ei(e){return{lang:e?.lang??Zn?.lang,message:e?.message,abortEarly:e?.abortEarly??Zn?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Zn?.abortPipeEarly}}r(ei,"getGlobalConfig");var qa;function Ba(e){return qa?.get(e)}r(Ba,"getGlobalMessage");var Fa;function ja(e){return Fa?.get(e)}r(ja,"getSchemaMessage");var Na;function Ua(e,t){return Na?.get(e)?.get(t)}r(Ua,"getSpecificMessage");function ht(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}r(ht,"_stringify");function ne(e,t,n,i,s){let o=s&&"input"in s?s.input:n.value,a=s?.expected??e.expects??null,l=s?.received??ht(o),c={kind:e.kind,type:e.type,input:o,expected:a,received:l,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:s?.path,issues:s?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},d=e.kind==="schema",u=s?.message??e.message??Ua(e.reference,c.lang)??(d?ja(c.lang):null)??i.message??Ba(c.lang);u!==void 0&&(c.message=typeof u=="function"?u(c):u),d&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}r(ne,"_addIssue");function de(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},ei())}}}r(de,"_getStandardProps");function $a(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}r($a,"_isValidObjectKey");function ti(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}r(ti,"_joinExpects");var Va=class extends Error{static{r(this,"ValiError")}constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ft(e,t){return{kind:"validation",type:"min_length",reference:ft,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,i){return n.typed&&n.value.length<this.requirement&&ne(this,"length",n,i,{received:`${n.value.length}`}),n}}}r(ft,"minLength");function Se(e,t){return{kind:"validation",type:"min_value",reference:Se,async:!1,expects:`>=${e instanceof Date?e.toJSON():ht(e)}`,requirement:e,message:t,"~run"(n,i){return n.typed&&!(n.value>=this.requirement)&&ne(this,"value",n,i,{received:n.value instanceof Date?n.value.toJSON():ht(n.value)}),n}}}r(Se,"minValue");function U(e){return{kind:"transformation",type:"transform",reference:U,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}r(U,"transform");function Ha(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}r(Ha,"getFallback");function Ns(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}r(Ns,"getDefault");function W(e,t){return{kind:"schema",type:"array",reference:W,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return de(this)},"~run"(n,i){let s=n.value;if(Array.isArray(s)){n.typed=!0,n.value=[];for(let o=0;o<s.length;o++){let a=s[o],l=this.item["~run"]({value:a},i);if(l.issues){let c={type:"array",origin:"value",input:s,key:o,value:a};for(let d of l.issues)d.path?d.path.unshift(c):d.path=[c],n.issues?.push(d);if(n.issues||(n.issues=l.issues),i.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else ne(this,"type",n,i);return n}}}r(W,"array");function T(e){return{kind:"schema",type:"boolean",reference:T,expects:"boolean",async:!1,message:e,get"~standard"(){return de(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:ne(this,"type",t,n),t}}}r(T,"boolean");function ni(e,t){return{kind:"schema",type:"instance",reference:ni,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return de(this)},"~run"(n,i){return n.value instanceof this.class?n.typed=!0:ne(this,"type",n,i),n}}}r(ni,"instance");function K(e,t){return{kind:"schema",type:"literal",reference:K,expects:ht(e),async:!1,literal:e,message:t,get"~standard"(){return de(this)},"~run"(n,i){return n.value===this.literal?n.typed=!0:ne(this,"type",n,i),n}}}r(K,"literal");function _(e){return{kind:"schema",type:"number",reference:_,expects:"number",async:!1,message:e,get"~standard"(){return de(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:ne(this,"type",t,n),t}}}r(_,"number");function I(e,t){return{kind:"schema",type:"object",reference:I,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return de(this)},"~run"(n,i){let s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(let o in this.entries){let a=this.entries[o];if(o in s||(a.type==="exact_optional"||a.type==="optional"||a.type==="nullish")&&a.default!==void 0){let l=o in s?s[o]:Ns(a),c=a["~run"]({value:l},i);if(c.issues){let d={type:"object",origin:"value",input:s,key:o,value:l};for(let u of c.issues)u.path?u.path.unshift(d):u.path=[d],n.issues?.push(u);if(n.issues||(n.issues=c.issues),i.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[o]=c.value}else if(a.fallback!==void 0)n.value[o]=Ha(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(ne(this,"key",n,i,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),i.abortEarly))break}}else ne(this,"type",n,i);return n}}}r(I,"object");function y(e,t){return{kind:"schema",type:"optional",reference:y,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return de(this)},"~run"(n,i){return n.value===void 0&&(this.default!==void 0&&(n.value=Ns(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,i)}}}r(y,"optional");function se(e,t){return{kind:"schema",type:"picklist",reference:se,expects:ti(e.map(ht),"|"),async:!1,options:e,message:t,get"~standard"(){return de(this)},"~run"(n,i){return this.options.includes(n.value)?n.typed=!0:ne(this,"type",n,i),n}}}r(se,"picklist");function te(e,t,n){return{kind:"schema",type:"record",reference:te,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return de(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){i.typed=!0,i.value={};for(let a in o)if($a(o,a)){let l=o[a],c=this.key["~run"]({value:a},s);if(c.issues){let u={type:"object",origin:"key",input:o,key:a,value:l};for(let p of c.issues)p.path=[u],i.issues?.push(p);if(i.issues||(i.issues=c.issues),s.abortEarly){i.typed=!1;break}}let d=this.value["~run"]({value:l},s);if(d.issues){let u={type:"object",origin:"value",input:o,key:a,value:l};for(let p of d.issues)p.path?p.path.unshift(u):p.path=[u],i.issues?.push(p);if(i.issues||(i.issues=d.issues),s.abortEarly){i.typed=!1;break}}(!c.typed||!d.typed)&&(i.typed=!1),c.typed&&(i.value[c.value]=d.value)}}else ne(this,"type",i,s);return i}}}r(te,"record");function x(e){return{kind:"schema",type:"string",reference:x,expects:"string",async:!1,message:e,get"~standard"(){return de(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:ne(this,"type",t,n),t}}}r(x,"string");function js(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}r(js,"_subIssues");function V(e,t){return{kind:"schema",type:"union",reference:V,expects:ti(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return de(this)},"~run"(n,i){let s,o,a;for(let l of this.options){let c=l["~run"]({value:n.value},i);if(c.typed)if(c.issues)o?o.push(c):o=[c];else{s=c;break}else a?a.push(c):a=[c]}if(s)return s;if(o){if(o.length===1)return o[0];ne(this,"type",n,i,{issues:js(o)}),n.typed=!0}else{if(a?.length===1)return a[0];ne(this,"type",n,i,{issues:js(a)})}return n}}}r(V,"union");function re(){return{kind:"schema",type:"unknown",reference:re,expects:"unknown",async:!1,get"~standard"(){return de(this)},"~run"(e){return e.typed=!0,e}}}r(re,"unknown");function Qe(e,t,n){return{kind:"schema",type:"variant",reference:Qe,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return de(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){let a,l=0,c=this.key,d=[],u=r((p,f)=>{for(let h of p.options){if(h.type==="variant")u(h,new Set(f).add(h.key));else{let w=!0,m=0;for(let b of f){let S=h.entries[b];if(b in o?S["~run"]({typed:!1,value:o[b]},{abortEarly:!0}).issues:S.type!=="exact_optional"&&S.type!=="optional"&&S.type!=="nullish"){w=!1,c!==b&&(l<m||l===m&&b in o&&!(c in o))&&(l=m,c=b,d=[]),c===b&&d.push(h.entries[b].expects);break}m++}if(w){let b=h["~run"]({value:o},s);(!a||!a.typed&&b.typed)&&(a=b)}}if(a&&!a.issues)break}},"parseOptions");if(u(this,new Set([this.key])),a)return a;ne(this,"type",i,s,{input:o[c],expected:ti(d,"|"),path:[{type:"object",origin:"value",input:o,key:c,value:o[c]}]})}else ne(this,"type",i,s);return i}}}r(Qe,"variant");function Us(e,t,n){let i=e["~run"]({value:t},ei(n));if(i.issues)throw new Va(i.issues);return i.value}r(Us,"parse");function M(...e){return{...e[0],pipe:e,get"~standard"(){return de(this)},"~run"(t,n){for(let i of e)if(i.kind!=="metadata"){if(t.issues&&(i.kind==="schema"||i.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=i["~run"](t,n))}return t}}}r(M,"pipe");function q(e,t,n){let i=e["~run"]({value:t},ei(n));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}r(q,"safeParse");var et=M(V([M(x(),U(N)),_()]),U(e=>Number(e)),M(_(),Se(1)));var R=class{constructor(t,n,i,s){this.swish=t;this.ui=n;this.eventBus=i;this.options=s}static{r(this,"IntentHandler")}};var Qa=V([I({variantId:et,quantity:y(M(_(),Se(1)),1)}),I({items:M(W(I({variantId:et,quantity:y(M(_(),Se(1)),1)})),ft(1))})]),Mt=class extends R{static{r(this,"CreateCartLineHandler")}async invoke(t){let n=q(Qa,t);if(!n.success)return{intent:"create:cart-line",code:"error",message:"Invalid intent data",issues:n.issues.map(s=>s.message)};let i=n.output;try{let s="items"in i?i.items.map(a=>({id:a.variantId,quantity:a.quantity})):[{id:i.variantId,quantity:i.quantity}];return{intent:"create:cart-line",code:"ok",data:await this.swish.ajax.addToCart({items:s})}}catch(s){let o=[],a="Failed to add item to cart";return s instanceof Error?(s.message&&(a=s.message,o.push(s.message)),s.stack&&o.push(s.stack)):typeof s=="string"&&s.trim()?(a=s,o.push(s)):s!=null&&o.push(String(s)),{intent:"create:cart-line",code:"error",message:a,issues:o.length?o:["Cart request failed"]}}}};var qt=class extends R{static{r(this,"CreateListHandler")}async invoke(t){let n=await this.ui.showListEditor();if(n.code==="closed")return{intent:"create:list",code:"closed"};let{list:i}=n.data;return{intent:"create:list",code:"ok",data:{list:i}}}};var za=I({listId:x()}),Bt=class extends R{static{r(this,"DeleteListHandler")}async invoke(t){let n=q(za,t);if(!n.success)return{intent:"delete:list",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output;return(await this.ui.showDeleteListAlert({listId:i})).code==="closed"?{intent:"delete:list",code:"closed"}:{intent:"delete:list",code:"ok",data:{listId:i}}}};var Ga=I({itemId:x()}),Ft=class extends R{static{r(this,"EditItemListsHandler")}async invoke(t){let n=q(Ga,t);if(!n.success)return{intent:"edit:item-lists",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{itemId:i}=n.output,s=await this.ui.showListSelect({itemId:i});if(s.code==="closed")return{intent:"edit:item-lists",code:"closed"};if(s.data.action==="submit"){let{item:o,product:a,variant:l}=s.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:a,variant:l}}}return{intent:"unsave:item",code:"ok",data:{itemId:s.data.data.itemId}}}};var Ka=I({itemId:M(x()),productId:M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_()))}),jt=class extends R{static{r(this,"EditItemVariantHandler")}async invoke(t){let n=q(Ka,t);if(!n.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:n.issues.map(f=>f.message)};let{itemId:i,productId:s,variantId:o}=n.output;if(!(!o||this.swish.options.intents.editSavedProduct.promptVariantChange)){let f=await this.swish.api.items.updateById(i,{productId:s,variantId:o});if("error"in f)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[f.error.message]};if(!f.data)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:["No item returned from API"]};let h=await this.swish.storefront.loadProduct({productId:String(s),variantId:o?String(o):void 0});if(!h.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load product data",issues:[h.errors?.message??"No product data returned from API"]};let w=h.data.product,m=h.data.variant;return{intent:"edit:item-variant",code:"ok",data:{item:f.data,product:w,variant:m}}}let l=await this.ui.showVariantSelect({itemId:i,productId:s,variantId:o});if(l.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:c,product:d,variant:u}=l.data;return{intent:"edit:item-variant",code:"ok",data:{item:c,product:d,variant:u}}}};var Wa=I({listId:x(),access:se(["public","private"])}),Nt=class extends R{static{r(this,"EditListAccessHandler")}async invoke(t){let n=q(Wa,t);if(!n.success)return{intent:"edit:list-access",code:"error",message:"Invalid intent data",issues:n.issues.map(l=>l.message)};let{listId:i,access:s}=n.output;if((await this.ui.showConfirmDialog({titleKey:s==="public"?"listMenu.public.title":"listMenu.private.title",descriptionKey:s==="public"?"listMenu.public.description":"listMenu.private.description",confirmLabelKey:s==="public"?"listMenu.public.text":"listMenu.private.text",cancelLabelKey:"listMenu.cancel",danger:!1})).code==="closed")return{intent:"edit:list-access",code:"closed"};let a=await this.swish.api.lists.updateById(i,{access:s});return"error"in a?{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:[a.error.message]}:a.data?{intent:"edit:list-access",code:"ok",data:{list:a.data}}:{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:["API response missing data"]}}};var Xa=I({listId:x()}),Ut=class extends R{static{r(this,"EditListHandler")}async invoke(t){let n=q(Xa,t);if(!n.success)return{intent:"edit:list",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{listId:i}=n.output,s=await this.ui.showListEditor({listId:i});if(s.code==="closed")return{intent:"edit:list",code:"closed"};let{list:o}=s.data;return{intent:"edit:list",code:"ok",data:{list:o}}}};var Ja=I({variantId:et,quantity:y(M(_(),Se(1)),1)}),Ya=150,Za=V([I({variantId:et,quantity:y(M(_(),Se(1)),1)}),I({items:M(W(Ja),ft(1))})]),$t=class extends R{static{r(this,"InitiateCheckoutHandler")}async invoke(t){let n=q(Za,t);if(!n.success)return{intent:"initiate:checkout",code:"error",message:"Invalid intent data",issues:n.issues.map(l=>l.message)};let i=n.output,o=("items"in i?i.items:[{variantId:i.variantId,quantity:i.quantity}]).map(l=>`${l.variantId}:${l.quantity}`).join(","),a=new URL(`/cart/${o}`,this.swish.shopUrl);return a.searchParams.set("checkout","1"),typeof window<"u"&&window.setTimeout(()=>window.location.assign(a.href),Ya),{intent:"initiate:checkout",code:"ok",data:{checkoutUrl:a.href}}}};var el=I({productId:M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M(V([M(x(),U(N)),_()]),U(Number),_()))}),Vt=class extends R{static{r(this,"InitiateQuickBuyHandler")}async invoke(t){let n=q(el,t);if(!n.success)return{intent:"initiate:quick-buy",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{productId:i,variantId:s}=n.output,o=await this.ui.showQuickBuy({productId:i,variantId:s});return o.code==="closed"?{intent:"initiate:quick-buy",code:"closed"}:{intent:"initiate:quick-buy",code:"ok",data:o.data}}};var tl=150,nl=I({returnTo:x()}),Ht=class extends R{static{r(this,"InitiateSignInHandler")}async invoke(t){let n=q(nl,t);if(!n.success)return{intent:"initiate:sign-in",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let i=n.output.returnTo;return(await this.ui.showConfirmDialog({titleKey:"signIn.title",descriptionKey:"signIn.description",confirmLabelKey:"signIn.continue",danger:!1})).code==="closed"?{intent:"initiate:sign-in",code:"closed"}:(this.scheduleRedirect(i),{intent:"initiate:sign-in",code:"ok",data:void 0})}scheduleRedirect(t){window.setTimeout(()=>this.redirectToSignIn(t),tl)}redirectToSignIn(t){let{routes:n,newCustomerAccounts:i}=this.swish.storefrontContext,s=i?"/customer_identity/login":n.accountUrl,o=new URL(s,window.location.origin);o.searchParams.set("return_to",t),window.location.assign(o.toString())}};var il=150,Qt=class extends R{static{r(this,"InitiateSignOutHandler")}async invoke(){return this.scheduleRedirect(),{intent:"initiate:sign-out",code:"ok",data:void 0}}scheduleRedirect(){window.setTimeout(()=>this.redirectToSignOut(),il)}redirectToSignOut(){let{accountUrl:t,rootUrl:n}=this.swish.storefrontContext.routes,{newCustomerAccounts:i}=this.swish.storefrontContext,s;if(i){let o=new URL(t,window.location.origin);o.pathname=o.pathname.replace(/\/$/,"")+"/logout",s=o.toString()}else s=new URL("/account/logout",window.location.origin).toString();s+=`?return_url=${encodeURIComponent(n)}`,window.location.assign(s)}};var zt=class extends R{static{r(this,"SaveCartLineHandler")}async invoke(t){if(!t?.items?.length)return{intent:"save:cart-line",code:"error",message:"No items to save",issues:["items array is empty or missing"]};let{confirm:n,showFeedback:i}=this.options.saveCartLine,s=t.items[0];if(n&&(await this.ui.showToast({title:"Save this for later?",text:s.title??"",image:s.image,action:{label:"Save for later"},variant:"full"})).code!=="ok")return{intent:"save:cart-line",code:"closed"};for(let o of t.items){let a=await this.swish.api.items.create({productId:o.productId,variantId:o.variantId,quantity:o.quantity,source:"cart"});if("error"in a)return{intent:"save:cart-line",code:"error",message:"Failed to save item from cart",issues:[a.error.message]}}return i&&await this.ui.showToast({title:"We've saved this for you",text:s.title??"",image:s.image,variant:"full"}),{intent:"save:cart-line",code:"ok",data:t.items}}};var sl=I({productId:M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M(V([M(x(),U(N)),_()]),U(Number),_())),quantity:y(M(_(),Se(1))),tags:y(W(x()))}),Gt=class extends R{static{r(this,"SaveItemHandler")}async invoke(t){let n=q(sl,t);if(!n.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:n.issues.map(b=>b.message)};let{productId:i,variantId:s,quantity:o,tags:a}=n.output,l=await this.swish.storefront.loadProduct({productId:String(i),variantId:s?String(s):void 0});if(l.errors)return{intent:"save:item",code:"error",message:l.errors.message??"Failed to load product data",issues:l.errors.graphQLErrors?.map(b=>b.message)??[]};if(!l.data||!l.data.product)return{intent:"save:item",code:"error",message:"Failed to load product data",issues:["API response missing data"]};let{product:c,variant:d}=l.data,u=c.variantsCount?.count&&c.variantsCount.count>1,p=!!s,h=!(typeof this.options.saveProduct.promptVariantIfMissing=="function"?this.options.saveProduct.promptVariantIfMissing({product:c,variant:d}):this.options.saveProduct.promptVariantIfMissing)||!this.options.saveProduct.promptVariantIfPresent&&p;if(!u||h){let b=r(()=>!u&&c.selectedOrFirstAvailableVariant?Number(N(c.selectedOrFirstAvailableVariant.id)):s,"variantIdToUse"),S=await this.swish.api.items.create({productId:i,variantId:b(),quantity:o,tags:a});return"error"in S?{intent:"save:item",code:"error",message:"Failed to create item",issues:[S.error.message]}:S.data?{intent:"save:item",code:"ok",data:{item:S.data,product:c,variant:u?d:c.selectedOrFirstAvailableVariant}}:{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]}}let w;if(this.options.saveProduct.saveBeforeVariantPrompt){let b=await this.swish.api.items.create({productId:i,quantity:o,tags:a});"data"in b&&b.data&&(w=b.data)}let m=await this.ui.showVariantSelect({productId:i,variantId:s,itemId:w?.id});return m.code==="closed"?w?{intent:"save:item",code:"ok",data:{item:w,product:c,variant:d}}:{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:m.data}}};function mt(e,t){let{storeDomain:n}=e.options.storefront,{rootUrl:i,listDetailPagePath:s}=e.options.context.routes,o=new URL(`https://${n}`),a=new URL(`${i==="/"?"":i}${s}`,o);return a.searchParams.set("public-list-id",t.publicListId),a}r(mt,"buildShareListUrl");async function yt(e){return typeof navigator?.clipboard?.writeText!="function"?{ok:!1,issues:["Clipboard API not available"]}:navigator.clipboard.writeText(e).then(()=>({ok:!0})).catch(t=>({ok:!1,issues:[t?.message??"Failed to copy to clipboard"]}))}r(yt,"copyToClipboard");function $s(){let e=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||e}r($s,"isMobileDevice");var rl=I({listId:x()}),Kt=class extends R{static{r(this,"ShareListHandler")}async invoke(t){let n=q(rl,t);if(!n.success)return{intent:"initiate:share",code:"error",message:"Invalid intent data",issues:n.issues.map(c=>c.message)};let{listId:i}=n.output,s=await this.swish.api.lists.findById(i);if("error"in s)return{intent:"initiate:share",code:"error",message:"Failed to fetch list",issues:[s.error.message]};if(!s.data)return{intent:"initiate:share",code:"error",message:"List not found",issues:[]};if(s.data.access!=="public"){let d=await(await this.swish.intents.invoke("edit:list-access",{listId:i,access:"public"})).complete;if(d.code!=="ok")return{...d,intent:"initiate:share"}}let o=mt(this.swish,{publicListId:i}).toString();if($s()&&typeof navigator.share=="function"&&(await navigator.share({title:"Share list",url:o}).then(()=>({ok:!0})).catch(()=>({ok:!1}))).ok)return{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"native"}};let l=await yt(o);return l.ok?{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"clipboard"}}:{intent:"initiate:share",code:"error",message:"Failed to share list",issues:l.issues}}};var $f=I({title:y(x()),text:x(),image:y(x()),action:y(I({label:x(),url:y(x())})),variant:y(se(["compact","full"])),icon:y(x())}),Wt=class extends R{static{r(this,"ShowToastHandler")}async invoke(t){return{intent:"show:toast",code:(await this.ui.showToast(t)).code,data:void 0}}};var ol=I({itemId:x(),delete:y(T())}),Xt=class extends R{static{r(this,"UnsaveItemHandler")}async invoke(t){let n=q(ol,t);if(!n.success)return{intent:"unsave:item",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{itemId:i,delete:s}=n.output;if(this.options.unsaveProduct.selectList&&!s){let a=await this.ui.showListSelect({itemId:i});if(a.code==="closed")return{intent:"unsave:item",code:"closed"};if(a.data.action==="submit"){let{item:l,product:c,variant:d}=a.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:l,product:c,variant:d}}}if(a.data.action==="unsave"){let{itemId:l}=a.data.data;return{intent:"unsave:item",code:"ok",data:{itemId:l}}}}if(!this.options.unsaveProduct.confirm){let a=await this.swish.api.items.deleteById(i);return"error"in a?{intent:"unsave:item",code:"error",message:"Failed to delete item",issues:[a.error.message]}:{intent:"unsave:item",code:"ok",data:{itemId:i}}}return(await this.ui.showUnsaveAlert({itemId:i})).code==="closed"?{intent:"unsave:item",code:"closed"}:{intent:"unsave:item",code:"ok",data:{itemId:i}}}};var Jt=class extends R{static{r(this,"ViewHomeHandler")}async invoke(t){return{intent:"view:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var al=I({listId:x()}),Yt=class extends R{static{r(this,"ViewListDetailPageMenuHandler")}async invoke(t){let n=q(al,t);if(!n.success)return{intent:"view:list-detail-page-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output;return{intent:"view:list-detail-page-menu",code:(await this.ui.showListDetailPageMenu({listId:i})).code,data:void 0}}};var ll=I({listId:x(),listType:y(se(["user","smart","shared"]),"user")}),Zt=class extends R{static{r(this,"ViewListHandler")}async invoke(t){let n=q(ll,t);if(!n.success)return{intent:"view:list",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{listId:i,listType:s}=n.output;return{intent:"view:list",code:(await this.ui.showDrawer({view:"list",listId:i,listType:s})).code,data:void 0}}};var cl=I({listId:x()}),en=class extends R{static{r(this,"ViewListMenuHandler")}async invoke(t){let n=q(cl,t);if(!n.success)return{intent:"view:list-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output,s=await this.ui.showListMenu({listId:i});if(s.code==="closed")return{intent:"view:list-menu",code:"closed"};if(s.data.action==="edit")return{intent:"edit:list",code:"ok",data:s.data.data};if(s.data.action==="delete")return{intent:"delete:list",code:"ok",data:{listId:i}};if(s.data.action==="edit-access"){let o=s.data.data?.currentListAccess,a=o==="public"?"private":o==="private"?"public":void 0;return a?(await this.swish.intents.invoke("edit:list-access",{listId:i,access:a})).complete:{intent:"view:list-menu",code:"error",message:"Missing list access from UI",issues:["List menu UI did not provide currentListAccess"]}}return s.data.action==="share"?(await this.swish.intents.invoke("initiate:share",{listId:i})).complete:s.data.action==="add-items"?{intent:"view:list-menu",code:"ok",data:{listId:i}}:{intent:"view:list-menu",code:"error",message:"Unknown list menu action",issues:["Unknown action returned from list menu UI"]}}};var tn=class extends R{static{r(this,"ViewListsHandler")}async invoke(t){return{intent:"view:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var nn=class extends R{static{r(this,"ViewNotificationsHandler")}async invoke(t){return{intent:"view:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var ul=I({orderId:M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_())}),sn=class extends R{static{r(this,"ViewOrderHandler")}async invoke(t){let n=q(ul,t);if(!n.success)return{intent:"view:order",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{orderId:i}=n.output;return{intent:"view:order",code:(await this.ui.showDrawer({view:"order",orderId:i.toString()})).code,data:void 0}}};var dl=I({orderId:x()}),rn=class extends R{static{r(this,"ViewOrderMenuHandler")}async invoke(t){let n=q(dl,t);if(!n.success)return{intent:"view:order-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{orderId:i}=n.output;return{intent:"view:order-menu",code:(await this.ui.showOrderMenu({orderId:i})).code,data:void 0}}};var on=class extends R{static{r(this,"ViewOrdersHandler")}async invoke(t){return{intent:"view:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var pl=I({productId:M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M(V([M(x(),U(N)),_()]),U(Number),_()))}),an=class extends R{static{r(this,"ViewProductHandler")}async invoke(t){let n=q(pl,t);if(!n.success)return{intent:"view:product",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{productId:i,variantId:s}=n.output;return{intent:"view:product",code:(await this.ui.showDrawer({view:"product",productId:i.toString(),variantId:s?.toString()})).code,data:void 0}}};var ln=class extends R{static{r(this,"ViewProfileHandler")}async invoke(t){return{intent:"view:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var cn=class extends R{static{r(this,"ViewSavesHandler")}async invoke(t){return{intent:"view:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var Z=class{constructor(t,n,i){this.swish=t;this.ui=n;this.options=i}static{r(this,"IntentHook")}};var un=class extends Z{static{r(this,"AfterCreateCartLineHook")}async invoke(t){this.options.createCartLine.afterComplete?.(t)}};var dn=class extends Z{static{r(this,"AfterEditItemListsHook")}async invoke(t){if(this.options.editSavedProduct.showFeedback&&t.code==="ok"){if("itemId"in t.data)return;let{product:n,variant:i}=t.data;n&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:n.title,image:i?.image?.url??n.featuredImage?.url,action:{label:"View"}})).complete).code==="ok"&&this.swish.intents.invoke("view:saves")}}};var pn=class extends Z{static{r(this,"AfterEditListAccessHook")}async invoke(t){if(t.code!=="ok")return;let n=t.data.list.access==="public"?"List is now public":"List is now private";await(await this.swish.intents.invoke("show:toast",{text:n,variant:"compact",icon:"check"})).complete}};var hn=class extends Z{static{r(this,"AfterSaveCartLineHook")}async invoke(t){this.options.saveCartLine.afterComplete?.(t)}};var fn=class extends Z{static{r(this,"AfterSaveItemHook")}async invoke(t){if(this.options.saveProduct.showFeedback&&t.code==="ok"){let{item:n,product:i,variant:s}=t.data;i&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:i.title,image:s?.image?.url??i.featuredImage?.url,action:{label:"Add to List"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:n.id})}}};var mn=class extends Z{static{r(this,"AfterShareListHook")}async invoke(t){if(t.code!=="ok")return;await(await this.swish.intents.invoke("show:toast",{variant:"compact",text:"Link copied",icon:"check"})).complete}};var yn=class extends Z{static{r(this,"AfterViewHomeHook")}async invoke(t){if(t.code==="closed"){let n=new URL(window.location.href);(n.hash==="#swish-home"||n.hash==="#swish")&&(n.hash="",window.history.replaceState({},document.title,n.toString()))}}};function Vs(e){let t=e.startsWith("#")?e.slice(1):e;return t==="swish"||t.startsWith("swish-")}r(Vs,"isSwishHash");var vn=class extends Z{static{r(this,"BeforeViewHomeHook")}async invoke(){Vs(window.location.hash)||window.history.replaceState(window.history.state,"",window.location.pathname+window.location.search+"#swish")}};var gn=class{constructor(t,n){this._invoking=!1;this.swish=t,this.ui=n,this.eventBus=new EventTarget,this.options=t.options.intents,this.handlers={"create:cart-line":new Mt(this.swish,this.ui,this.eventBus,this.options),"initiate:checkout":new $t(this.swish,this.ui,this.eventBus,this.options),"save:item":new Gt(this.swish,this.ui,this.eventBus,this.options),"save:cart-line":new zt(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new Xt(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new jt(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Ft(this.swish,this.ui,this.eventBus,this.options),"create:list":new qt(this.swish,this.ui,this.eventBus,this.options),"edit:list":new Ut(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new Nt(this.swish,this.ui,this.eventBus,this.options),"delete:list":new Bt(this.swish,this.ui,this.eventBus,this.options),"view:home":new Jt(this.swish,this.ui,this.eventBus,this.options),"initiate:share":new Kt(this.swish,this.ui,this.eventBus,this.options),"view:list":new Zt(this.swish,this.ui,this.eventBus,this.options),"view:lists":new tn(this.swish,this.ui,this.eventBus,this.options),"view:orders":new on(this.swish,this.ui,this.eventBus,this.options),"view:order":new sn(this.swish,this.ui,this.eventBus,this.options),"view:saves":new cn(this.swish,this.ui,this.eventBus,this.options),"view:notifications":new nn(this.swish,this.ui,this.eventBus,this.options),"view:profile":new ln(this.swish,this.ui,this.eventBus,this.options),"view:product":new an(this.swish,this.ui,this.eventBus,this.options),"view:list-menu":new en(this.swish,this.ui,this.eventBus,this.options),"view:order-menu":new rn(this.swish,this.ui,this.eventBus,this.options),"view:list-detail-page-menu":new Yt(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-in":new Ht(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-out":new Qt(this.swish,this.ui,this.eventBus,this.options),"initiate:quick-buy":new Vt(this.swish,this.ui,this.eventBus,this.options),"show:toast":new Wt(this.swish,this.ui,this.eventBus,this.options)},this.initIntentHooks(),this.initIntentWatcher(),this.initCartChangeListener()}static{r(this,"Intents")}publishAnalyticsEvent(t,n){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(t,n)}async invoke(t,...n){let i=n[0],s={lifecycle:"before",intent:t,data:i,response:null};return this.publishAnalyticsEvent("swish-intent",s),this.publishAnalyticsEvent(`swish-intent=${t}`,s),this._invoking=!0,this.eventBus.dispatchEvent(new CustomEvent(`before:${t}`,{detail:s})),this._invoking=!1,{intent:t,data:i,complete:this.handleIntent(t,i).then(o=>{let a={lifecycle:"after",intent:t,data:i,response:o};if(this.publishAnalyticsEvent("swish-intent",a),this.publishAnalyticsEvent(`swish-intent=${t}`,a),this.eventBus.dispatchEvent(new CustomEvent(t,{detail:a})),o.code==="ok"&&o.intent!==t){let l={lifecycle:"after",intent:o.intent,data:i,response:o};this.eventBus.dispatchEvent(new CustomEvent(o.intent,{detail:l}))}return o})}}listen(t,n){let i=r(o=>{"detail"in o&&o.detail?n(o.detail.response):console.warn("Intent response event without detail",o)},"eventListener"),s=r(()=>{this.eventBus.removeEventListener(`${t}`,i)},"unsubscribe");return this.eventBus.addEventListener(`${t}`,i),s}parseIntentFromString(t){let n=String(t),i=n.indexOf("?");if(i===-1)return{intent:n,data:{}};let s=n.slice(0,i),o=new URLSearchParams(n.slice(i+1)),a={};return o.forEach((l,c)=>{a[c]=l}),{intent:s,data:a}}parseIntentFromUrl(t){let n=t.searchParams.get("swish-intent");if(!n)return null;let i=n,s={};t.searchParams.forEach((a,l)=>{l!=="swish-intent"&&(s[l]=a)});let o=pt(t.pathname);return o&&(!s.product&&!s.productId&&(s.product=o.productHandle),!s.variant&&!s.variantId&&o.variantId&&(s.variant=o.variantId)),{intent:i,data:s}}mapParamNames(t){let n={product:"productId",variant:"variantId",list:"listId",order:"orderId",item:"itemId"},i={};for(let[s,o]of Object.entries(t))i[n[s]??s]=o;return i}async resolveIntentData(t){let{productId:n}=t;if(!n||/^\d+$/.test(n)||n.startsWith("gid://"))return t;let i=await this.swish.storefront.loadProductId({productHandle:n});return i.data?.product?.id?{...t,productId:N(i.data.product.id)}:t}async invokeFromParsed(t,n){let i=this.mapParamNames(n),s=await this.resolveIntentData(i);Object.keys(s).length>0?this.invoke(t,s):this.invoke(t)}parseIntentFromHash(t){let n=t.startsWith("#")?t.slice(1):t;return{swish:"view:home","swish-home":"view:home","swish-lists":"view:lists","swish-orders":"view:orders","swish-saves":"view:saves","swish-notifications":"view:notifications","swish-profile":"view:profile"}[n]||null}async handleIntent(t,n){let i=this.handlers[t];return i?i.invoke(n):{intent:t,code:"error",message:"Invalid intent",issues:[`Intent ${t} not found`]}}initIntentHooks(){this.eventBus.addEventListener("before:view:home",()=>{new vn(this.swish,this.ui,this.options).invoke()}),this.eventBus.addEventListener("create:cart-line",t=>{new un(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:item",t=>{new fn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:item-lists",t=>{new dn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("view:home",t=>{new yn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:list-access",t=>{new pn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("initiate:share",t=>{new mn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:cart-line",t=>{new hn(this.swish,this.ui,this.options).invoke(t.detail.response)})}initCartChangeListener(){this.swish.events.subscribe(["cart-change","cart-update"],t=>{if(!this.options.removeCartLine.saveCartLine)return;let i=t.detail?.items_removed;if(!i?.length)return;let s=i.map(o=>({productId:o.product_id,variantId:o.variant_id,quantity:o.quantity,title:o.product_title,image:o.image,variantTitle:o.variant_title}));this.invoke("save:cart-line",{items:s})})}initIntentWatcher(){ke({selector:"[swish-intent]",onElementFound:r(t=>{let n=t.getAttribute("swish-intent");if(!n)return;let{intent:i,data:s}=this.parseIntentFromString(n);t.addEventListener("click",()=>{this.invokeFromParsed(i,s)})},"onElementFound")}),ke({selector:"a[href*='swish-intent='],a[href*='#swish']",onElementFound:r(t=>{t instanceof HTMLAnchorElement&&t.addEventListener("click",n=>{if(!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey){let i=new URL(t.href),s=this.parseIntentFromUrl(i);if(s)n.preventDefault(),n.stopPropagation(),this.invokeFromParsed(s.intent,s.data);else if(i.hash){let o=this.parseIntentFromHash(i.hash);o&&(n.preventDefault(),n.stopPropagation(),this.invoke(o))}}})},"onElementFound")}),Ze({fireOnInit:!0,onLocationChange:r(t=>{if(this._invoking)return;let n=new URL(t.href),i=this.parseIntentFromUrl(n);if(i)n.searchParams.delete("swish-intent"),history.replaceState(history.state,"",n.toString()),this.invokeFromParsed(i.intent,i.data);else if(n.hash){let s=this.parseIntentFromHash(n.hash);s&&this.invoke(s)}},"onLocationChange")})}};var X=y(te(x(),V([x(),_()])),{}),hl=I({url:y(x(),""),altText:y(x(),"")}),fl=I({id:x(),enabled:T(),intent:x()}),ml=I({type:K("drawer-header"),hidden:y(T(),!1),design:X,options:y(I({title:y(x(),""),logo:y(hl,{url:"",altText:""}),useCloseButton:y(T(),!1),accountButton:y(T(),!0),notificationButton:y(T(),!0)}),{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0})}),yl=I({type:K("drawer-footer"),hidden:y(T(),!1),design:X,options:y(I({displayType:y(se(["floating","docked"]),"docked"),showIcons:y(T(),!1),showText:y(T(),!0),items:y(W(fl),[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}])}),{displayType:"docked",showIcons:!1,showText:!0,items:[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}]})}),vl=Qe("type",[ml,yl]),gl=I({type:se(["sign-in","notifications","recently-viewed","saved-from-cart","saved-items","lists"]),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{})}),wl=I({title:x(),url:x()}),bl=I({type:K("mini-menu"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{}),items:y(W(wl),[])}),Il=I({type:K("content-block"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{}),title:y(x()),body:y(x()),image:y(I({url:x(),width:y(_()),height:y(_())})),link:y(I({url:x(),target:y(se(["_self","_blank"]))}))}),Sl=I({type:K("featured-collection"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{}),handle:x()}),xl=Qe("type",[gl,bl,Il,Sl]),Cl=I({type:K("lists-section"),hidden:y(T(),!1),design:X,options:y(I({display:y(se(["myLists","forYouLists"]),"myLists"),layout:y(se(["list","slider"]),"slider")}),{display:"myLists",layout:"slider"})}),El=I({type:K("all-items-grid"),hidden:y(T(),!1),design:X,options:y(I({showSaveButton:y(T(),!0),showQuickBuyButton:y(T(),!0),showVariantTitle:y(T(),!0),enableVariantChange:y(T(),!1),showVariantOptionNames:y(T(),!0)}),{showSaveButton:!0,showQuickBuyButton:!0,showVariantTitle:!0,enableVariantChange:!1,showVariantOptionNames:!0})}),Rl=Qe("type",[Cl,El]),kl=I({desktopColumns:y(_(),4),showBuyButton:y(T(),!0),showVariantOptionNames:y(T(),!1),enableVariantChange:y(T(),!0)}),Pl=I({type:K("lists-grid"),hidden:y(T(),!1),design:X,options:y(I({displayType:y(se(["list","slider"]),"slider"),listDetailPage:y(kl,{desktopColumns:4,showBuyButton:!0,showVariantOptionNames:!1,enableVariantChange:!0})}),{displayType:"slider",listDetailPage:{desktopColumns:4,showBuyButton:!0,showVariantOptionNames:!1,enableVariantChange:!0}})}),Al=Pl,Tl=I({type:K("orders-list"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{})}),Dl=Tl,Ll=I({type:K("order-info"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{})}),Ol=I({type:K("order-items"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{})}),_l=I({type:K("order-actions"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{})}),Ml=Qe("type",[Ll,Ol,_l]),ql=I({type:K("image-slider"),hidden:y(T(),!1),design:X,options:y(I({flush:y(T(),!0),loop:y(T(),!1)}),{flush:!0,loop:!1})}),Bl=I({type:K("product-info"),hidden:y(T(),!1),design:X,options:y(I({descriptionMaxLines:y(_(),4),variantSelectDisplayType:y(se(["pills","rows"]),"pills"),hideSingleValueOptions:y(T(),!0),images:y(I({baseTint:y(T(),!0)}),{baseTint:!0})}),{descriptionMaxLines:4,variantSelectDisplayType:"pills",hideSingleValueOptions:!0,images:{baseTint:!0}})}),Fl=I({type:K("buy-buttons"),hidden:y(T(),!1),design:X,options:y(I({shopPay:y(T(),!1)}),{shopPay:!1})}),jl=I({type:K("complementary-products"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{})}),Nl=I({type:K("related-products"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{})}),Ul=Qe("type",[ql,Bl,Fl,jl,Nl]),$l=I({type:K("profile-form"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{})}),Vl=$l,Hl=I({type:K("notifications-list"),hidden:y(T(),!1),design:X,options:y(te(x(),re()),{})}),Ql=Hl,zl=I({enableVariantChange:y(T(),!1),showVariantOptionNames:y(T(),!1)}),Gl=I({sections:y(W(vl),[{type:"drawer-header",options:{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0}},{type:"drawer-footer",options:{displayType:"docked",showIcons:!1,showText:!0,items:[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}]}}])}),Kl=I({sections:y(W(xl),[{type:"sign-in"},{type:"notifications"},{type:"recently-viewed"},{type:"saved-from-cart"},{type:"saved-items"},{type:"lists"},{type:"mini-menu",hidden:!0,items:[{title:"Shipping",url:"/policies/shipping-policy"},{title:"Returns",url:"/policies/refund-policy"},{title:"Contact Us",url:"/pages/contact"}]}])}),Wl=I({sections:y(W(Rl),[{type:"lists-section",options:{display:"myLists"}},{type:"lists-section",options:{display:"forYouLists"}},{type:"all-items-grid"}])}),Xl=I({sections:y(W(Al),[{type:"lists-grid"}])}),Jl=I({sections:y(W(Dl),[{type:"orders-list"}])}),Yl=I({sections:y(W(Ml),[{type:"order-info"},{type:"order-items"},{type:"order-actions"}])}),Zl=I({sections:y(W(Ul),[{type:"image-slider"},{type:"product-info"},{type:"buy-buttons"},{type:"complementary-products"},{type:"related-products"}])}),ec=I({sections:y(W(Vl),[{type:"profile-form"}])}),tc=I({sections:y(W(Ql),[{type:"notifications-list"}])}),Hs=I({baseUrl:y(x(),"https://swish.app/cdn"),css:y(W(V([x(),ni(URL)])),[]),design:y(te(x(),re()),{}),icons:y(te(x(),x()),{}),images:y(I({baseTint:y(T(),!0)}),{baseTint:!0}),fullpage:y(I({listDetail:y(zl,{})}),{listDetail:{}}),drawer:y(Gl,{}),home:y(Kl,{}),saves:y(Wl,{}),lists:y(Xl,{}),orders:y(Jl,{}),orderDetail:y(Yl,{}),productDetail:y(Zl,{}),profile:y(ec,{}),notifications:y(tc,{})});var Qs=r(e=>({auth:{tokenUrl:e.auth?.tokenUrl??"/apps/wishlist/api/profiles/token"},storefront:{storeDomain:e.storefront?.storeDomain??"",accessToken:e.storefront?.accessToken??""},context:{...e.context,routes:{...e.context.routes,rootUrl:e.context.routes?.rootUrl??"/",listDetailPagePath:e.context.routes?.listDetailPagePath??"/apps/wishlist"},localization:{country:e.context.localization.country.toUpperCase(),language:e.context.localization.language.toUpperCase(),market:e.context.localization.market}},metafields:{product:e.metafields?.product??[],productVariant:e.metafields?.productVariant??[]},transforms:{badges:e.transforms?.badges??(({defaultBadges:t})=>t),title:e.transforms?.title??(({product:t})=>t?.title??""),description:e.transforms?.description??(({product:t})=>t?.descriptionHtml??""),variantTitle:e.transforms?.variantTitle??(({variant:t})=>t?.title??""),optionValues:e.transforms?.optionValues??(({optionValues:t})=>t),addToCartButton:e.transforms?.addToCartButton??(()=>!0)},intents:{saveProduct:{promptVariantIfMissing:e?.intents?.saveProduct?.promptVariantIfMissing??!0,promptVariantIfPresent:e?.intents?.saveProduct?.promptVariantIfPresent??!1,saveBeforeVariantPrompt:e?.intents?.saveProduct?.saveBeforeVariantPrompt??!0,showFeedback:e?.intents?.saveProduct?.showFeedback??!0},unsaveProduct:{selectList:e?.intents?.unsaveProduct?.selectList??!0,confirm:e?.intents?.unsaveProduct?.confirm??!0,showFeedback:e?.intents?.unsaveProduct?.showFeedback??!0},editSavedProduct:{promptVariantChange:e?.intents?.editSavedProduct?.promptVariantChange??!0,showFeedback:e?.intents?.editSavedProduct?.showFeedback??!0},initiateQuickBuy:{promptVariantIfPresent:e?.intents?.initiateQuickBuy?.promptVariantIfPresent??!0},createCartLine:{afterComplete:e?.intents?.createCartLine?.afterComplete},removeCartLine:{saveCartLine:e?.intents?.removeCartLine?.saveCartLine??!0},saveCartLine:{confirm:e?.intents?.saveCartLine?.confirm??!1,showFeedback:e?.intents?.saveCartLine?.showFeedback??!0,afterComplete:e?.intents?.saveCartLine?.afterComplete}},placements:e.placements??[],translations:e.translations,ui:Us(Hs,e.ui??{})}),"createSwishOptions");function zs(e){return N(String(e).trim())}r(zs,"normalizeSwishQueryId");function wn(e){let t=e.productId?zs(e.productId):"",n=e.variantId?zs(e.variantId):"";return n?["swish","items",t,n]:["swish","items",t]}r(wn,"swishItemsQueryKey");var nc=["item-create","item-update","item-delete"],Gs="auth-cache-clear",Ks="token-update";function Ws({events:e,queryClient:t}){return e.subscribe([...nc,Gs,Ks],n=>{if(!(n instanceof CustomEvent))return;if(n.type===Gs){t.clear();return}if(n.type===Ks){t.invalidateQueries({queryKey:["swish"]});return}if(!n.detail?.productId)return;let i=wn({productId:n.detail.productId});t.invalidateQueries({queryKey:i})})}r(Ws,"bindSwishItemQueryInvalidation");var Pe=class{static{r(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var ic=class extends Pe{static{r(this,"FocusManager")}#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){let t=r(()=>e(),"listener");return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},tt=new ic;var sc={setTimeout:r((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:r(e=>clearTimeout(e),"clearTimeout"),setInterval:r((e,t)=>setInterval(e,t),"setInterval"),clearInterval:r(e=>clearInterval(e),"clearInterval")},rc=class{static{r(this,"TimeoutManager")}#e=sc;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},Ae=new rc;function Xs(e){setTimeout(e,0)}r(Xs,"systemSetTimeoutZero");var Zs=typeof window>"u"||"Deno"in globalThis;function z(){}r(z,"noop");function er(e,t){return typeof e=="function"?e(t):e}r(er,"functionalUpdate");function vt(e){return typeof e=="number"&&e>=0&&e!==1/0}r(vt,"isValidTimeout");function bn(e,t){return Math.max(e+(t||0)-Date.now(),0)}r(bn,"timeUntilStale");function xe(e,t){return typeof e=="function"?e(t):e}r(xe,"resolveStaleTime");function pe(e,t){return typeof e=="function"?e(t):e}r(pe,"resolveEnabled");function si(e,t){let{type:n="all",exact:i,fetchStatus:s,predicate:o,queryKey:a,stale:l}=e;if(a){if(i){if(t.queryHash!==gt(a,t.options))return!1}else if(!it(t.queryKey,a))return!1}if(n!=="all"){let c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||s&&s!==t.state.fetchStatus||o&&!o(t))}r(si,"matchQuery");function ri(e,t){let{exact:n,status:i,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(nt(t.options.mutationKey)!==nt(o))return!1}else if(!it(t.options.mutationKey,o))return!1}return!(i&&t.state.status!==i||s&&!s(t))}r(ri,"matchMutation");function gt(e,t){return(t?.queryKeyHashFn||nt)(e)}r(gt,"hashQueryKeyByOptions");function nt(e){return JSON.stringify(e,(t,n)=>ii(n)?Object.keys(n).sort().reduce((i,s)=>(i[s]=n[s],i),{}):n)}r(nt,"hashKey");function it(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>it(e[n],t[n])):!1}r(it,"partialMatchKey");var oc=Object.prototype.hasOwnProperty;function tr(e,t,n=0){if(e===t)return e;if(n>500)return t;let i=Js(e)&&Js(t);if(!i&&!(ii(e)&&ii(t)))return t;let o=(i?e:Object.keys(e)).length,a=i?t:Object.keys(t),l=a.length,c=i?new Array(l):{},d=0;for(let u=0;u<l;u++){let p=i?u:a[u],f=e[p],h=t[p];if(f===h){c[p]=f,(i?u<o:oc.call(e,p))&&d++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){c[p]=h;continue}let w=tr(f,h,n+1);c[p]=w,w===f&&d++}return o===l&&d===o?e:c}r(tr,"replaceEqualDeep");function In(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}r(In,"shallowEqualObjects");function Js(e){return Array.isArray(e)&&e.length===Object.keys(e).length}r(Js,"isPlainArray");function ii(e){if(!Ys(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ys(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}r(ii,"isPlainObject");function Ys(e){return Object.prototype.toString.call(e)==="[object Object]"}r(Ys,"hasObjectPrototype");function nr(e){return new Promise(t=>{Ae.setTimeout(t,e)})}r(nr,"sleep");function wt(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?tr(e,t):t}r(wt,"replaceData");function ir(e,t,n=0){let i=[...e,t];return n&&i.length>n?i.slice(1):i}r(ir,"addToEnd");function sr(e,t,n=0){let i=[t,...e];return n&&i.length>n?i.slice(0,-1):i}r(sr,"addToStart");var bt=Symbol();function Sn(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===bt?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}r(Sn,"ensureQueryFn");function rr(e,t,n){let i=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:r(()=>(s??=t(),i||(i=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s),"get")}),e}r(rr,"addConsumeAwareSignal");var ze=(()=>{let e=r(()=>Zs,"isServerFn");return{isServer(){return e()},setIsServer(t){e=t}}})();function It(){let e,t,n=new Promise((s,o)=>{e=s,t=o});n.status="pending",n.catch(()=>{});function i(s){Object.assign(n,s),delete n.resolve,delete n.reject}return r(i,"finalize"),n.resolve=s=>{i({status:"fulfilled",value:s}),e(s)},n.reject=s=>{i({status:"rejected",reason:s}),t(s)},n}r(It,"pendingThenable");function or(e){let t;if(e.then(n=>(t=n,n),z)?.catch(z),t!==void 0)return{data:t}}r(or,"tryResolveSync");function ar(e){return e}r(ar,"defaultTransformerFn");function ac(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}r(ac,"dehydrateMutation");function lc(e,t,n){let i=r(()=>{let s=e.promise?.then(t).catch(o=>n(o)?Promise.reject(new Error("redacted")):Promise.reject(o));return s?.catch(z),s},"dehydratePromise");return{dehydratedAt:Date.now(),state:{...e.state,...e.state.data!==void 0&&{data:t(e.state.data)}},queryKey:e.queryKey,queryHash:e.queryHash,...e.state.status==="pending"&&{promise:i()},...e.meta&&{meta:e.meta}}}r(lc,"dehydrateQuery");function lr(e){return e.state.isPaused}r(lr,"defaultShouldDehydrateMutation");function cr(e){return e.state.status==="success"}r(cr,"defaultShouldDehydrateQuery");function cc(e){return!0}r(cc,"defaultShouldRedactErrors");function oi(e,t={}){let n=t.shouldDehydrateMutation??e.getDefaultOptions().dehydrate?.shouldDehydrateMutation??lr,i=e.getMutationCache().getAll().flatMap(c=>n(c)?[ac(c)]:[]),s=t.shouldDehydrateQuery??e.getDefaultOptions().dehydrate?.shouldDehydrateQuery??cr,o=t.shouldRedactErrors??e.getDefaultOptions().dehydrate?.shouldRedactErrors??cc,a=t.serializeData??e.getDefaultOptions().dehydrate?.serializeData??ar,l=e.getQueryCache().getAll().flatMap(c=>s(c)?[lc(c,a,o)]:[]);return{mutations:i,queries:l}}r(oi,"dehydrate");function ai(e,t,n){if(typeof t!="object"||t===null)return;let i=e.getMutationCache(),s=e.getQueryCache(),o=n?.defaultOptions?.deserializeData??e.getDefaultOptions().hydrate?.deserializeData??ar,a=t.mutations||[],l=t.queries||[];a.forEach(({state:c,...d})=>{i.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...d},c)}),l.forEach(({queryKey:c,state:d,queryHash:u,meta:p,promise:f,dehydratedAt:h})=>{let w=f?or(f):void 0,m=d.data===void 0?w?.data:d.data,b=m===void 0?m:o(m),S=s.get(u),k=S?.state.status==="pending",A=S?.state.fetchStatus==="fetching";if(S){let D=w&&h!==void 0&&h>S.state.dataUpdatedAt;if(d.dataUpdatedAt>S.state.dataUpdatedAt||D){let{fetchStatus:C,...P}=d;S.setState({...P,data:b})}}else S=s.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:c,queryHash:u,meta:p},{...d,data:b,fetchStatus:"idle",status:b!==void 0?"success":d.status});f&&!k&&!A&&(h===void 0||h>S.state.dataUpdatedAt)&&S.fetch(void 0,{initialPromise:Promise.resolve(f).then(o)}).catch(z)})}r(ai,"hydrate");var uc=Xs;function dc(){let e=[],t=0,n=r(l=>{l()},"notifyFn"),i=r(l=>{l()},"batchNotifyFn"),s=uc,o=r(l=>{t?e.push(l):s(()=>{n(l)})},"schedule"),a=r(()=>{let l=e;e=[],l.length&&s(()=>{i(()=>{l.forEach(c=>{n(c)})})})},"flush");return{batch:r(l=>{let c;t++;try{c=l()}finally{t--,t||a()}return c},"batch"),batchCalls:r(l=>(...c)=>{o(()=>{l(...c)})},"batchCalls"),schedule:o,setNotifyFunction:r(l=>{n=l},"setNotifyFunction"),setBatchNotifyFunction:r(l=>{i=l},"setBatchNotifyFunction"),setScheduler:r(l=>{s=l},"setScheduler")}}r(dc,"createNotifyManager");var G=dc();var pc=class extends Pe{static{r(this,"OnlineManager")}#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){let t=r(()=>e(!0),"onlineListener"),n=r(()=>e(!1),"offlineListener");return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#e}},st=new pc;function hc(e){return Math.min(1e3*2**e,3e4)}r(hc,"defaultRetryDelay");function li(e){return(e??"online")==="online"?st.isOnline():!0}r(li,"canFetch");var xn=class extends Error{static{r(this,"CancelledError")}constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Cn(e){let t=!1,n=0,i,s=It(),o=r(()=>s.status!=="pending","isResolved"),a=r(m=>{if(!o()){let b=new xn(m);f(b),e.onCancel?.(b)}},"cancel"),l=r(()=>{t=!0},"cancelRetry"),c=r(()=>{t=!1},"continueRetry"),d=r(()=>tt.isFocused()&&(e.networkMode==="always"||st.isOnline())&&e.canRun(),"canContinue"),u=r(()=>li(e.networkMode)&&e.canRun(),"canStart"),p=r(m=>{o()||(i?.(),s.resolve(m))},"resolve"),f=r(m=>{o()||(i?.(),s.reject(m))},"reject"),h=r(()=>new Promise(m=>{i=r(b=>{(o()||d())&&m(b)},"continueFn"),e.onPause?.()}).then(()=>{i=void 0,o()||e.onContinue?.()}),"pause"),w=r(()=>{if(o())return;let m,b=n===0?e.initialPromise:void 0;try{m=b??e.fn()}catch(S){m=Promise.reject(S)}Promise.resolve(m).then(p).catch(S=>{if(o())return;let k=e.retry??(ze.isServer()?0:3),A=e.retryDelay??hc,D=typeof A=="function"?A(n,S):A,C=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,S);if(t||!C){f(S);return}n++,e.onFail?.(n,S),nr(D).then(()=>d()?void 0:h()).then(()=>{t?f(S):w()})})},"run");return{promise:s,status:r(()=>s.status,"status"),cancel:a,continue:r(()=>(i?.(),s),"continue"),cancelRetry:l,continueRetry:c,canStart:u,start:r(()=>(u()?w():h().then(w),s),"start")}}r(Cn,"createRetryer");var En=class{static{r(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),vt(this.gcTime)&&(this.#e=Ae.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ze.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Ae.clearTimeout(this.#e),this.#e=void 0)}};var pr=class extends En{static{r(this,"Query")}#e;#t;#n;#s;#i;#o;#r;constructor(e){super(),this.#r=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#s=e.client,this.#n=this.#s.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=dr(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#o,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let t=dr(this.options);t.data!==void 0&&(this.setState(ur(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){let n=wt(this.state.data,e,this.options);return this.#l({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#l({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(z).catch(z):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>pe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===bt||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>xe(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!bn(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#r||this.#a()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#a(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}let n=new AbortController,i=r(l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:r(()=>(this.#r=!0,n.signal),"get")})},"addSignalProperty"),s=r(()=>{let l=Sn(this.options,t),d=r(()=>{let u={client:this.#s,queryKey:this.queryKey,meta:this.meta};return i(u),u},"createQueryFnContext")();return this.#r=!1,this.options.persister?this.options.persister(l,d,this):l(d)},"fetchFn"),a=r(()=>{let l={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#s,state:this.state,fetchFn:s};return i(l),l},"createFetchContext")();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:"fetch",meta:a.fetchOptions?.meta}),this.#i=Cn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:r(l=>{l instanceof xn&&l.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},"onCancel"),onFail:r((l,c)=>{this.#l({type:"failed",failureCount:l,error:c})},"onFail"),onPause:r(()=>{this.#l({type:"pause"})},"onPause"),onContinue:r(()=>{this.#l({type:"continue"})},"onContinue"),retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:r(()=>!0,"canRun")});try{let l=await this.#i.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof xn){if(l.silent)return this.#i.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#l({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#l(e){let t=r(n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...ci(n.data,this.options),fetchMeta:e.meta??null};case"success":let i={...n,...ur(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?i:void 0,i;case"error":let s=e.error;return{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}},"reducer");this.state=t(this.state),G.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function ci(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:li(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}r(ci,"fetchState");function ur(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}r(ur,"successState");function dr(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,i=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}r(dr,"getDefaultState");var di=class extends Pe{static{r(this,"QueryObserver")}constructor(e,t){super(),this.options=t,this.#e=e,this.#a=null,this.#r=It(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#s=void 0;#i;#o;#r;#a;#l;#h;#f;#u;#d;#c;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),hr(this.#t,this.options)?this.#p():this.updateResult(),this.#w())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ui(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ui(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#I(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof pe(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),t._defaulted&&!In(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let i=this.hasListeners();i&&fr(this.#t,n,this.options,t)&&this.#p(),this.updateResult(),i&&(this.#t!==n||pe(this.options.enabled,this.#t)!==pe(t.enabled,this.#t)||xe(this.options.staleTime,this.#t)!==xe(t.staleTime,this.#t))&&this.#y();let s=this.#v();i&&(this.#t!==n||pe(this.options.enabled,this.#t)!==pe(t.enabled,this.#t)||s!==this.#c)&&this.#g(s)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return mc(this,n)&&(this.#s=n,this.#o=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#s}trackResult(e,t){return new Proxy(e,{get:r((n,i)=>(this.trackProp(i),t?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#r.status==="pending"&&this.#r.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,i)),"get")})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#p({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#p(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(z)),t}#y(){this.#b();let e=xe(this.options.staleTime,this.#t);if(ze.isServer()||this.#s.isStale||!vt(e))return;let n=bn(this.#s.dataUpdatedAt,e)+1;this.#u=Ae.setTimeout(()=>{this.#s.isStale||this.updateResult()},n)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#g(e){this.#I(),this.#c=e,!(ze.isServer()||pe(this.options.enabled,this.#t)===!1||!vt(this.#c)||this.#c===0)&&(this.#d=Ae.setInterval(()=>{(this.options.refetchIntervalInBackground||tt.isFocused())&&this.#p()},this.#c))}#w(){this.#y(),this.#g(this.#v())}#b(){this.#u&&(Ae.clearTimeout(this.#u),this.#u=void 0)}#I(){this.#d&&(Ae.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,i=this.options,s=this.#s,o=this.#i,a=this.#o,c=e!==n?e.state:this.#n,{state:d}=e,u={...d},p=!1,f;if(t._optimisticResults){let B=this.hasListeners(),ce=!B&&hr(e,t),Ce=B&&fr(e,n,t,i);(ce||Ce)&&(u={...u,...ci(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:h,errorUpdatedAt:w,status:m}=u;f=u.data;let b=!1;if(t.placeholderData!==void 0&&f===void 0&&m==="pending"){let B;s?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(B=s.data,b=!0):B=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,B!==void 0&&(m="success",f=wt(s?.data,B,t),p=!0)}if(t.select&&f!==void 0&&!b)if(s&&f===o?.data&&t.select===this.#l)f=this.#h;else try{this.#l=t.select,f=t.select(f),f=wt(s?.data,f,t),this.#h=f,this.#a=null}catch(B){this.#a=B}this.#a&&(h=this.#a,f=this.#h,w=Date.now(),m="error");let S=u.fetchStatus==="fetching",k=m==="pending",A=m==="error",D=k&&S,C=f!==void 0,E={status:m,fetchStatus:u.fetchStatus,isPending:k,isSuccess:m==="success",isError:A,isInitialLoading:D,isLoading:D,data:f,dataUpdatedAt:u.dataUpdatedAt,error:h,errorUpdatedAt:w,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:S,isRefetching:S&&!k,isLoadingError:A&&!C,isPaused:u.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:A&&C,isStale:pi(e,t),refetch:this.refetch,promise:this.#r,isEnabled:pe(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let B=E.data!==void 0,ce=E.status==="error"&&!B,Ce=r(ye=>{ce?ye.reject(E.error):B&&ye.resolve(E.data)},"finalizeThenableIfPossible"),Le=r(()=>{let ye=this.#r=E.promise=It();Ce(ye)},"recreateThenable"),ee=this.#r;switch(ee.status){case"pending":e.queryHash===n.queryHash&&Ce(ee);break;case"fulfilled":(ce||E.data!==ee.value)&&Le();break;case"rejected":(!ce||E.error!==ee.reason)&&Le();break}}return E}updateResult(){let e=this.#s,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#o=this.options,this.#i.data!==void 0&&(this.#f=this.#t),In(t,e))return;this.#s=t;let n=r(()=>{if(!e)return!0;let{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!this.#m.size)return!0;let o=new Set(s??this.#m);return this.options.throwOnError&&o.add("error"),Object.keys(this.#s).some(a=>{let l=a;return this.#s[l]!==e[l]&&o.has(l)})},"shouldNotifyListeners");this.#x({listeners:n()})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#w()}#x(e){G.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function fc(e,t){return pe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}r(fc,"shouldLoadOnMount");function hr(e,t){return fc(e,t)||e.state.data!==void 0&&ui(e,t,t.refetchOnMount)}r(hr,"shouldFetchOnMount");function ui(e,t,n){if(pe(t.enabled,e)!==!1&&xe(t.staleTime,e)!=="static"){let i=typeof n=="function"?n(e):n;return i==="always"||i!==!1&&pi(e,t)}return!1}r(ui,"shouldFetchOn");function fr(e,t,n,i){return(e!==t||pe(i.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&pi(e,n)}r(fr,"shouldFetchOptionally");function pi(e,t){return pe(t.enabled,e)!==!1&&e.isStaleByTime(xe(t.staleTime,e))}r(pi,"isStale");function mc(e,t){return!In(e.getCurrentResult(),t)}r(mc,"shouldAssignObserverCurrentProperties");function hi(e){return{onFetch:r((t,n)=>{let i=t.options,s=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],a=t.state.data?.pageParams||[],l={pages:[],pageParams:[]},c=0,d=r(async()=>{let u=!1,p=r(w=>{rr(w,()=>t.signal,()=>u=!0)},"addSignalProperty"),f=Sn(t.options,t.fetchOptions),h=r(async(w,m,b)=>{if(u)return Promise.reject();if(m==null&&w.pages.length)return Promise.resolve(w);let k=r(()=>{let P={client:t.client,queryKey:t.queryKey,pageParam:m,direction:b?"backward":"forward",meta:t.options.meta};return p(P),P},"createQueryFnContext")(),A=await f(k),{maxPages:D}=t.options,C=b?sr:ir;return{pages:C(w.pages,A,D),pageParams:C(w.pageParams,m,D)}},"fetchPage");if(s&&o.length){let w=s==="backward",m=w?yc:mr,b={pages:o,pageParams:a},S=m(i,b);l=await h(b,S,w)}else{let w=e??o.length;do{let m=c===0?a[0]??i.initialPageParam:mr(i,l);if(c>0&&m==null)break;l=await h(l,m),c++}while(c<w)}return l},"fetchFn");t.options.persister?t.fetchFn=()=>t.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=d},"onFetch")}}r(hi,"infiniteQueryBehavior");function mr(e,{pages:t,pageParams:n}){let i=t.length-1;return t.length>0?e.getNextPageParam(t[i],t,n[i],n):void 0}r(mr,"getNextPageParam");function yc(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}r(yc,"getPreviousPageParam");var yr=class extends En{static{r(this,"Mutation")}#e;#t;#n;#s;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||vc(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(e){let t=r(()=>{this.#i({type:"continue"})},"onContinue"),n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Cn({fn:r(()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:r((o,a)=>{this.#i({type:"failed",failureCount:o,error:a})},"onFail"),onPause:r(()=>{this.#i({type:"pause"})},"onPause"),onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:r(()=>this.#n.canRun(this),"canRun")});let i=this.state.status==="pending",s=!this.#s.canStart();try{if(i)t();else{this.#i({type:"pending",variables:e,isPaused:s}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let a=await this.options.onMutate?.(e,n);a!==this.state.context&&this.#i({type:"pending",context:a,variables:e,isPaused:s})}let o=await this.#s.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:"success",data:o}),o}catch(o){try{await this.#n.config.onError?.(o,e,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onError?.(o,e,this.state.context,n)}catch(a){Promise.reject(a)}try{await this.#n.config.onSettled?.(void 0,o,this.state.variables,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,o,e,this.state.context,n)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:o}),o}finally{this.#n.runNext(this)}}#i(e){let t=r(n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}},"reducer");this.state=t(this.state),G.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function vc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}r(vc,"getDefaultState");var vr=class extends Pe{static{r(this,"MutationCache")}constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let i=new yr({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(i),i}add(e){this.#e.add(e);let t=Rn(e);if(typeof t=="string"){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=Rn(e);if(typeof t=="string"){let n=this.#t.get(t);if(n)if(n.length>1){let i=n.indexOf(e);i!==-1&&n.splice(i,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=Rn(e);if(typeof t=="string"){let i=this.#t.get(t)?.find(s=>s.state.status==="pending");return!i||i===e}else return!0}runNext(e){let t=Rn(e);return typeof t=="string"?this.#t.get(t)?.find(i=>i!==e&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){G.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(n=>ri(t,n))}findAll(e={}){return this.getAll().filter(t=>ri(e,t))}notify(e){G.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return G.batch(()=>Promise.all(e.map(t=>t.continue().catch(z))))}};function Rn(e){return e.options.scope?.id}r(Rn,"scopeFor");var gr=class extends Pe{static{r(this,"QueryCache")}constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let i=t.queryKey,s=t.queryHash??gt(i,t),o=this.get(s);return o||(o=new pr({client:e,queryKey:i,queryHash:s,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(i)}),this.add(o)),o}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){G.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(n=>si(t,n))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(n=>si(e,n)):t}notify(e){G.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){G.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){G.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var fi=class{static{r(this,"QueryClient")}#e;#t;#n;#s;#i;#o;#r;#a;constructor(e={}){this.#e=e.queryCache||new gr,this.#t=e.mutationCache||new vr,this.#n=e.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#r=tt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=st.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#r?.(),this.#r=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),i=n.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(xe(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(i))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{let i=n.data;return[t,i]})}setQueryData(e,t,n){let i=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(i.queryHash)?.state.data,a=er(t,o);if(a!==void 0)return this.#e.build(this,i).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return G.batch(()=>this.#e.findAll(e).map(({queryKey:i})=>[i,this.setQueryData(i,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;G.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){let n=this.#e;return G.batch(()=>(n.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},i=G.batch(()=>this.#e.findAll(e).map(s=>s.cancel(n)));return Promise.all(i).then(z).catch(z)}invalidateQueries(e,t={}){return G.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},i=G.batch(()=>this.#e.findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let o=s.fetch(void 0,n);return n.throwOnError||(o=o.catch(z)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(i).then(z)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(xe(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(z).catch(z)}fetchInfiniteQuery(e){return e.behavior=hi(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(z).catch(z)}ensureInfiniteQueryData(e){return e.behavior=hi(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return st.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#s.set(nt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#s.values()],n={};return t.forEach(i=>{it(e,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(nt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(i=>{it(e,i.mutationKey)&&Object.assign(n,i.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=gt(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===bt&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function wr(){return new fi({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,gcTime:1e3*60*60*1,staleTime:1e3*60*10}}})}r(wr,"createSwishQueryClient");var gc=Symbol.for("preact-signals");function Pn(){if(je>1)je--;else{for(var e,t=!1;St!==void 0;){var n=St;for(St=void 0,mi++;n!==void 0;){var i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&xr(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=i}}if(mi=0,je--,t)throw e}}r(Pn,"t");function ie(e){if(je>0)return e();je++;try{return e()}finally{Pn()}}r(ie,"n");var j=void 0;function Ir(e){var t=j;j=void 0;try{return e()}finally{j=t}}r(Ir,"o");var br,St=void 0,je=0,mi=0,kn=0;function Sr(e){if(j!==void 0){var t=e.n;if(t===void 0||t.t!==j)return t={i:0,S:e,p:j.s,n:void 0,t:j,e:void 0,x:void 0,r:t},j.s!==void 0&&(j.s.n=t),j.s=t,e.n=t,32&j.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=j.s,t.n=void 0,j.s.n=t,j.s=t),t}}r(Sr,"e");function oe(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(oe,"d");oe.prototype.brand=gc;oe.prototype.h=function(){return!0};oe.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:Ir(function(){var i;(i=t.W)==null||i.call(t)}))};oe.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,i=e.x;n!==void 0&&(n.x=i,e.e=void 0),i!==void 0&&(i.e=n,e.x=void 0),e===this.t&&(this.t=i,i===void 0&&Ir(function(){var s;(s=t.Z)==null||s.call(t)}))}};oe.prototype.subscribe=function(e){var t=this;return ae(function(){var n=t.value,i=j;j=void 0;try{e(n)}finally{j=i}},{name:"sub"})};oe.prototype.valueOf=function(){return this.value};oe.prototype.toString=function(){return this.value+""};oe.prototype.toJSON=function(){return this.value};oe.prototype.peek=function(){var e=j;j=void 0;try{return this.value}finally{j=e}};Object.defineProperty(oe.prototype,"value",{get:r(function(){var e=Sr(this);return e!==void 0&&(e.i=this.i),this.v},"get"),set:r(function(e){if(e!==this.v){if(mi>100)throw new Error("Cycle detected");this.v=e,this.i++,kn++,je++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Pn()}}},"set")});function F(e,t){return new oe(e,t)}r(F,"c");function xr(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}r(xr,"a");function Cr(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}r(Cr,"l");function Er(e){for(var t=e.s,n=void 0;t!==void 0;){var i=t.p;t.i===-1?(t.S.U(t),i!==void 0&&(i.n=t.n),t.n!==void 0&&(t.n.p=i)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=i}e.s=n}r(Er,"y");function Ge(e,t){oe.call(this,void 0),this.x=e,this.s=void 0,this.g=kn-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(Ge,"w");Ge.prototype=new oe;Ge.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===kn))return!0;if(this.g=kn,this.f|=1,this.i>0&&!xr(this))return this.f&=-2,!0;var e=j;try{Cr(this),j=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return j=e,Er(this),this.f&=-2,!0};Ge.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}oe.prototype.S.call(this,e)};Ge.prototype.U=function(e){if(this.t!==void 0&&(oe.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Ge.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Ge.prototype,"value",{get:r(function(){if(1&this.f)throw new Error("Cycle detected");var e=Sr(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v},"get")});function he(e,t){return new Ge(e,t)}r(he,"b");function Rr(e){var t=e.u;if(e.u=void 0,typeof t=="function"){je++;var n=j;j=void 0;try{t()}catch(i){throw e.f&=-2,e.f|=8,yi(e),i}finally{j=n,Pn()}}}r(Rr,"_");function yi(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Rr(e)}r(yi,"p");function wc(e){if(j!==this)throw new Error("Out-of-order effect");Er(this),j=e,this.f&=-2,8&this.f&&yi(this),Pn()}r(wc,"g");function rt(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name,br&&br.push(this)}r(rt,"S");rt.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};rt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Rr(this),Cr(this),je++;var e=j;return j=this,wc.bind(this,e)};rt.prototype.N=function(){2&this.f||(this.f|=2,this.o=St,St=this)};rt.prototype.d=function(){this.f|=8,1&this.f||yi(this)};rt.prototype.dispose=function(){this.d()};function ae(e,t){var n=new rt(e,t);try{n.c()}catch(s){throw n.d(),s}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}r(ae,"m");var bc="swish-query-cache";function Ic(e){return e.replace(/\.myshopify\.com$/,"")||"unknown-store"}r(Ic,"normalizeStoreKeyPart");function An({customerId:e,storeDomain:t}){let n=e??"guest",i=Ic(t??"");return`${bc}:${i}:${n}`}r(An,"getSwishQueryStorageKey");var Sc=1e3*60*60*24,xc=1e3;function vi(){return!!globalThis.window?.localStorage}r(vi,"canUseLocalStorage");function Cc(e){if(!vi())return null;let t=globalThis.window.localStorage.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return globalThis.window.localStorage.removeItem(e),null}}r(Cc,"readPersistedState");function Ec(e,t){if(vi())try{globalThis.window.localStorage.setItem(e,JSON.stringify(t))}catch{}}r(Ec,"writePersistedState");function Rc(e){if(vi())try{globalThis.window.localStorage.removeItem(e)}catch{}}r(Rc,"removePersistedState");function kc(e,t){return Number.isFinite(e.timestamp)?Date.now()-e.timestamp>t:!0}r(kc,"isPersistedStateExpired");function kr({queryClient:e,cacheBuster:t,customerId:n,storeDomain:i,maxAgeMs:s=Sc,throttleMs:o=xc}){let a=An({customerId:n,storeDomain:i}),l=F(!1),c=Cc(a);c?.buster===t&&!kc(c,s)?ai(e,c.clientState):c&&Rc(a),l.value=!0;let d=null,u=!1,p=r(()=>{Ec(a,{buster:t,timestamp:Date.now(),clientState:oi(e)})},"persistNow"),f=r(()=>{u=!0,!d&&(d=setTimeout(()=>{d=null,u&&(u=!1,p())},Math.max(o,0)))},"schedulePersist"),h=r(()=>{u&&(u=!1,d&&(clearTimeout(d),d=null),p())},"flushPersist"),w=e.getQueryCache().subscribe(b=>{l.value&&f()}),m=r(()=>{h()},"onPageHide");return globalThis.window?.addEventListener("pagehide",m),{restored:l,storageKey:a,dispose:r(()=>{globalThis.window?.removeEventListener("pagehide",m),w(),h()},"dispose")}}r(kr,"initSwishQueryPersistence");function Pr({events:e,cacheBuster:t,customerId:n,storeDomain:i}){let s=wr(),o=kr({queryClient:s,cacheBuster:t,customerId:n,storeDomain:i});return Ws({events:e,queryClient:s}),{client:s,cacheBuster:t,restored:o.restored,storageKey:o.storageKey,keys:{items:wn}}}r(Pr,"createSwishQuery");var Ar=r(e=>F({loading:!1,productId:e.productId==null?void 0:String(e.productId),variantId:e.variantId==null?void 0:String(e.variantId),itemId:e.itemId??void 0}),"itemContextFromIds"),Tr=r(e=>t=>{let n=t instanceof Location,i=t instanceof HTMLAnchorElement,s=t instanceof HTMLElement;if(!n&&!i&&!s)throw new Error("Invalid source");let{productHandle:o,productId:a,variantId:l,itemId:c}=s?t.dataset:{},p=!!(a||o)||!!c,f=F({loading:!1,productHandle:o,productId:a,variantId:l,itemId:c});if(!p&&(n||i)){let h=t.href,w=pt(h);w?.productHandle&&w.productHandle!==f.value.productHandle&&(f.value={...f.value,...w,productId:void 0},Fs({source:t,onProductUrlChange:r(m=>{f.value={...f.value,...m,productId:m.productHandle===f.value.productHandle?f.value.productId:void 0}},"onProductUrlChange")}))}return ae(()=>{f.value.loading||!f.value.productId&&f.value.productHandle&&(f.value={...f.value,loading:!0},e.storefront.loadProductId({productHandle:f.value.productHandle}).then(h=>{h.errors&&console.error("Error loading product id",h.errors);let w=h.data?.product?.id?N(h.data.product.id):void 0;f.value={...f.value,productId:w,loading:!w}}))}),f},"itemContextSignal");function Dr({queryClient:e,options:t,restored:n}){let i=F(null),s=F(!1),o=F(null),a=F(!1),l=r(w=>{let m=n?.value??!0,b=w.enabled??!0;return{...w,enabled:!!(b&&m)}},"getObserverOptions"),c=new di(e,l(t.value)),d=r(w=>{ie(()=>{i.value=w.data??null,s.value=w.isLoading,a.value=w.isRefetching,o.value=w.error??null})},"syncResult"),u=c.subscribe(d);d(c.getCurrentResult());let p=ae(()=>{c.setOptions(l(t.value))}),f=!1;return{data:i,loading:s,error:o,refetching:a,refetch:r(()=>c.refetch(),"refetch"),dispose:r(()=>{f||(f=!0,p(),u(),c.destroy())},"dispose")}}r(Dr,"createTanstackQuerySignal");var gi=50;function Lr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}r(Lr,"arraysShallowEqual");function Pc(e,t,n){if(n==="variant"||n==="auto"&&!!t){if(!t)return null;let s=N(t);return e.find(o=>String(o.variantId)===s)??null}return e[0]??null}r(Pc,"pickSavedItem");function Ac(e){ie(()=>{if(e.savedItemsLoading.value=e.apiLoading,e.savedItemsError.value=e.apiError,e.forcedItemId){let o=[e.forcedItemId];Lr(e.savedItemIds.value,o)||(e.savedItemIds.value=o),e.savedItemId.value!==e.forcedItemId&&(e.savedItemId.value=e.forcedItemId);return}let t=e.apiData?.data??[];t.length>=gi&&console.warn(`[swish] item-state query hit the per-product limit (${gi}). Some saved items may be missing.`);let n=t.map(o=>o.id);Lr(e.savedItemIds.value,n)||(e.savedItemIds.value=n);let s=Pc(t,e.variantId,e.policy)?.id??null;s!==e.savedItemId.value&&(e.savedItemId.value=s)})}r(Ac,"syncFromApi");var Or=r(e=>(t,n={})=>{let i=[],s={onSave:n.onSave,onUnsave:n.onUnsave,onListsUpdate:n.onListsUpdate,onVariantUpdate:n.onVariantUpdate},o=F(n.match??"auto"),a=r(H=>{s.onSave=H.onSave,s.onUnsave=H.onUnsave,s.onListsUpdate=H.onListsUpdate,s.onVariantUpdate=H.onVariantUpdate;let J=H.match??"auto";o.value!==J&&(o.value=J)},"setOptions"),l=he(()=>{let{productId:H,loading:J}=t.value;return!H||J?null:`product:${N(H)}`}),c=he(()=>t.value.loading||!!t.value.itemId||!t.value.productId),d=F(!c.value),u=F(null),p=F(!1),f=F(!1),h=F(!1),w=he(()=>p.value||f.value||h.value),m=F(!1),b=F(!1),S=he(()=>{let H=l.value,J=c.value,{productId:fe}=t.value;return{queryKey:e.query.keys.items({productId:fe}),queryFn:r(async()=>{let we=await e.api.items.list({limit:gi,query:H??void 0},{batch:!0});if("error"in we)throw we.error;return we},"queryFn"),enabled:!J}}),{data:k,loading:A,error:D,refetching:C,dispose:P}=Dr({queryClient:e.query.client,options:S,restored:e.query.restored});i.push(P);let E=t.value.itemId??null,B=F(E),ce=F(E?[E]:[]),Ce=ae(()=>Ac({apiData:k.value,apiLoading:A.value,apiError:D.value,forcedItemId:t.value.itemId,variantId:t.value.variantId,policy:o.value,savedItemId:B,savedItemIds:ce,savedItemsLoading:d,savedItemsError:u}));i.push(Ce);async function Le(){if(!B.value)return;ie(()=>{f.value=!0,b.value=!0});let J=await(await e.intents.invoke("unsave:item",{itemId:B.value})).complete;if(J.code==="ok"){let fe=J.data;"itemId"in fe?(ie(()=>{B.value=null,f.value=!1}),s.onUnsave?.(fe)):f.value=!1}else ie(()=>{f.value=!1,b.value=!1})}r(Le,"unsave");async function ee(){if(!B.value)return;h.value=!0;let J=await(await e.intents.invoke("edit:item-lists",{itemId:B.value})).complete;if(J.code==="ok"){let fe=J.data;"itemId"in fe?(B.value=null,s.onUnsave?.(fe)):s.onListsUpdate?.(fe)}h.value=!1}r(ee,"updateLists");async function ye(){if(!B.value)return;let{productId:H,variantId:J}=t.value;if(!H)return;h.value=!0;let we=await(await e.intents.invoke("edit:item-variant",{itemId:B.value,productId:H,variantId:J})).complete;we.code==="ok"&&s.onVariantUpdate?.(we.data),h.value=!1}r(ye,"updateVariant");async function Y(){let{productId:H,variantId:J}=t.value;if(!H)return;let fe=o.value==="product"?void 0:J;ie(()=>{p.value=!0,m.value=!0});let xt=await(await e.intents.invoke("save:item",{productId:H,variantId:fe})).complete;if(xt.code==="ok"){let Zi=xt.data;ie(()=>{B.value=Zi.item.id,p.value=!1}),s.onSave?.(Zi)}else xt.code==="error"&&console.warn("Failed to create item",xt),ie(()=>{p.value=!1,m.value=!1})}r(Y,"save");let Be=he(()=>d.value||w.value||t.value.loading),$=ae(()=>{(m.value||b.value)&&!w.value&&!C.value&&ie(()=>{m.value=!1,b.value=!1})});i.push($);let Ee=he(()=>{let H=!!B.value,J=p.value||C.value&&m.value,fe=f.value||C.value&&b.value,we="unsaved";return H?we="saved":J&&(we="saving"),{error:u.value,status:we,savedItemId:B.value,savedItemIds:ce.value,loading:Be.value,submitting:w.value,saved:H,saving:J,unsaving:fe}});async function jo(){Be.value||(Ee.value.saved&&Ee.value.savedItemId?await Le():Ee.value.saved||await Y())}return r(jo,"toggle"),Object.assign(Ee,{save:Y,unsave:Le,updateLists:ee,updateVariant:ye,update:ee,toggle:jo,setOptions:a,setCallbacks:a,dispose:r(()=>{for(;i.length;)i.pop()?.()},"dispose")})},"itemStateSignal");var _r=r(e=>()=>{let{data:t,loading:n,error:i}=e.state.swishQuery(()=>e.api.items.count(),{refetch:["item-create","item-delete"]}),s=F(0),o=F(!0),a=F(null);return ae(()=>{ie(()=>{o.value=n.value,a.value=i.value,s.value=t.value?.count??0})}),he(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var Tc="token-update",Mr=r(e=>(t,n)=>{let i=F(null),s=F(null),o=F(null),a=F(!n?.skip),l=F(!1),c=he(()=>a.value&&l.value);async function d(){if(!n?.skip?.value)try{a.value=!0;let u=await t(n?.variables?.value);ie(()=>{o.value="error"in u?u.error:null,i.value="data"in u?u.data:null,s.value="pageInfo"in u?u.pageInfo:null,a.value=!1,l.value=!0})}catch(u){ie(()=>{o.value=u,a.value=!1,l.value=!0})}}return r(d,"executeFetch"),ae(()=>{if(d(),n?.refetch?.length){let u=[...n.refetch,Tc];return e.events.subscribe(u,d)}}),{data:i,pageInfo:s,error:o,loading:a,refetching:c}},"swishQuerySignals");function Dc(e){if(e==="variant"||e==="product"||e==="auto")return e}r(Dc,"parseMatch");function Lc(e,t){let n=Jn(t),i=e.state.itemContext(n),s=Dc(t.getAttribute("swish-item-match")),o=e.state.itemState(i,{match:s});e.state.effect(()=>{let{status:l,saved:c}=o.value;t.setAttribute("swish-item-state",l),t.setAttribute("aria-pressed",String(c))}),t.querySelectorAll("[swish-item-label]").forEach(l=>{Oc(e,l,o)});let a=r(()=>{o.toggle()},"onClick");t.addEventListener("click",a)}r(Lc,"bindItemState");function Oc(e,t,n){let i=t.textContent??"",s=t.getAttribute("swish-item-label-unsaved")??"Save",o=t.getAttribute("swish-item-label-saved")??"Saved",a={unsaved:s,saved:o,saving:t.getAttribute("swish-item-label-saving")??o};e.state.effect(()=>{t.textContent=a[n.value.status]??i})}r(Oc,"bindItemLabel");function _c(e,t){let n=e.state.itemCount();e.state.effect(()=>{let{count:i,loading:s}=n.value,o=s?"":String(i);t.setAttribute("swish-item-count",o),t.textContent=o})}r(_c,"bindItemCount");function qr(e){ke({selector:"[swish-item-state]",onElementFound:r(t=>{Lc(e,t)},"onElementFound")}),ke({selector:"[swish-item-count]",onElementFound:r(t=>{_c(e,t)},"onElementFound")})}r(qr,"initDeclarativeState");var Ke="GraphQL Client";var wi="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",bi="Response returned unexpected Content-Type:",Ii="An unknown error has occurred. The API did not return a data object or any errors in its response.",Tn={json:"application/json",multipart:"multipart/mixed"},Si="X-SDK-Variant",xi="X-SDK-Version",Fr="shopify-graphql-client",jr="1.4.1",Dn=1e3,Nr=[429,503],Ci=/@(defer)\b/i,Br=`\r
|
|
8
|
+
`,Ur=/boundary="?([^=";]+)"?/i,Ei=Br+Br;function Te(e,t=Ke){return e.startsWith(`${t}`)?e:`${t}: ${e}`}r(Te,"formatErrorMessage");function qe(e){return e instanceof Error?e.message:JSON.stringify(e)}r(qe,"getErrorMessage");function Ri(e){return e instanceof Error&&e.cause?e.cause:void 0}r(Ri,"getErrorCause");function ki(e){return e.flatMap(({errors:t})=>t??[])}r(ki,"combineErrors");function Ln({client:e,retries:t}){if(t!==void 0&&(typeof t!="number"||t<0||t>3))throw new Error(`${e}: The provided "retries" value (${t}) is invalid - it cannot be less than ${0} or greater than ${3}`)}r(Ln,"validateRetries");function le(e,t){return t&&(typeof t!="object"||Array.isArray(t)||typeof t=="object"&&Object.keys(t).length>0)?{[e]:t}:{}}r(le,"getKeyValueIfValid");function Pi(e,t){if(e.length===0)return t;let i={[e.pop()]:t};return e.length===0?i:Pi(e,i)}r(Pi,"buildDataObjectByPath");function Hr(e,t){return Object.keys(t||{}).reduce((n,i)=>(typeof t[i]=="object"||Array.isArray(t[i]))&&e[i]?(n[i]=Hr(e[i],t[i]),n):(n[i]=t[i],n),Array.isArray(e)?[...e]:{...e})}r(Hr,"combineObjects");function Ai([e,...t]){return t.reduce(Hr,{...e})}r(Ai,"buildCombinedDataObject");function Ti({clientLogger:e,customFetchApi:t=fetch,client:n=Ke,defaultRetryWaitTime:i=Dn,retriableCodes:s=Nr}){let o=r(async(a,l,c)=>{let d=l+1,u=c+1,p;try{if(p=await t(...a),e({type:"HTTP-Response",content:{requestParams:a,response:p}}),!p.ok&&s.includes(p.status)&&d<=u)throw new Error;let f=p?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return f&&e({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:f}}),p}catch(f){if(d<=u){let h=p?.headers.get("Retry-After");return await Mc(h?parseInt(h,10):i),e({type:"HTTP-Retry",content:{requestParams:a,lastResponse:p,retryAttempt:l,maxRetries:c}}),o(a,d,c)}throw new Error(Te(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${qe(f)}`,n))}},"httpFetch");return o}r(Ti,"generateHttpFetch");async function Mc(e){return new Promise(t=>setTimeout(t,e))}r(Mc,"sleep");function Di({headers:e,url:t,customFetchApi:n=fetch,retries:i=0,logger:s}){Ln({client:Ke,retries:i});let o={headers:e,url:t,retries:i},a=qc(s),l=Ti({customFetchApi:n,clientLogger:a,defaultRetryWaitTime:Dn}),c=Bc(l,o),d=Fc(c),u=Qc(c);return{config:o,fetch:c,request:d,requestStream:u}}r(Di,"createGraphQLClient");function qc(e){return t=>{e&&e(t)}}r(qc,"generateClientLogger");async function Qr(e){let{errors:t,data:n,extensions:i}=await e.json();return{...le("data",n),...le("extensions",i),headers:e.headers,...t||!n?{errors:{networkStatusCode:e.status,message:Te(t?wi:Ii),...le("graphQLErrors",t),response:e}}:{}}}r(Qr,"processJSONResponse");function Bc(e,{url:t,headers:n,retries:i}){return async(s,o={})=>{let{variables:a,headers:l,url:c,retries:d,keepalive:u,signal:p}=o,f=JSON.stringify({query:s,variables:a});Ln({client:Ke,retries:d});let h=Object.entries({...n,...l}).reduce((m,[b,S])=>(m[b]=Array.isArray(S)?S.join(", "):S.toString(),m),{});return!h[Si]&&!h[xi]&&(h[Si]=Fr,h[xi]=jr),e([c??t,{method:"POST",headers:h,body:f,signal:p,keepalive:u}],1,d??i)}}r(Bc,"generateFetch");function Fc(e){return async(...t)=>{if(Ci.test(t[0]))throw new Error(Te("This operation will result in a streamable response - use requestStream() instead."));let n=null;try{n=await e(...t);let{status:i,statusText:s}=n,o=n.headers.get("content-type")||"";return n.ok?o.includes(Tn.json)?await Qr(n):{errors:{networkStatusCode:i,message:Te(`${bi} ${o}`),response:n}}:{errors:{networkStatusCode:i,message:Te(s),response:n}}}catch(i){return{errors:{message:qe(i),...n==null?{}:{networkStatusCode:n.status,response:n}}}}}}r(Fc,"generateRequest");async function*jc(e){let t=new TextDecoder;if(e.body[Symbol.asyncIterator])for await(let n of e.body)yield t.decode(n);else{let n=e.body.getReader(),i;try{for(;!(i=await n.read()).done;)yield t.decode(i.value)}finally{n.cancel()}}}r(jc,"getStreamBodyIterator");function Nc(e,t){return{async*[Symbol.asyncIterator](){try{let n="";for await(let i of e)if(n+=i,n.indexOf(t)>-1){let s=n.lastIndexOf(t),a=n.slice(0,s).split(t).filter(l=>l.trim().length>0).map(l=>l.slice(l.indexOf(Ei)+Ei.length).trim());a.length>0&&(yield a),n=n.slice(s+t.length),n.trim()==="--"&&(n="")}}catch(n){throw new Error(`Error occured while processing stream payload - ${qe(n)}`)}}}}r(Nc,"readStreamChunk");function Uc(e){return{async*[Symbol.asyncIterator](){yield{...await Qr(e),hasNext:!1}}}}r(Uc,"createJsonResponseAsyncIterator");function $c(e){return e.map(t=>{try{return JSON.parse(t)}catch(n){throw new Error(`Error in parsing multipart response - ${qe(n)}`)}}).map(t=>{let{data:n,incremental:i,hasNext:s,extensions:o,errors:a}=t;if(!i)return{data:n||{},...le("errors",a),...le("extensions",o),hasNext:s};let l=i.map(({data:c,path:d,errors:u})=>({data:c&&d?Pi(d,c):{},...le("errors",u)}));return{data:l.length===1?l[0].data:Ai([...l.map(({data:c})=>c)]),...le("errors",ki(l)),hasNext:s}})}r($c,"getResponseDataFromChunkBodies");function Vc(e,t){if(e.length>0)throw new Error(wi,{cause:{graphQLErrors:e}});if(Object.keys(t).length===0)throw new Error(Ii)}r(Vc,"validateResponseData");function Hc(e,t){let n=(t??"").match(Ur),i=`--${n?n[1]:"-"}`;if(!e.body?.getReader&&!e.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:e});let s=jc(e),o={},a;return{async*[Symbol.asyncIterator](){try{let l=!0;for await(let c of Nc(s,i)){let d=$c(c);a=d.find(p=>p.extensions)?.extensions??a;let u=ki(d);o=Ai([o,...d.map(({data:p})=>p)]),l=d.slice(-1)[0].hasNext,Vc(u,o),yield{...le("data",o),...le("extensions",a),hasNext:l}}if(l)throw new Error("Response stream terminated unexpectedly")}catch(l){let c=Ri(l);yield{...le("data",o),...le("extensions",a),errors:{message:Te(qe(l)),networkStatusCode:e.status,...le("graphQLErrors",c?.graphQLErrors),response:e},hasNext:!1}}}}}r(Hc,"createMultipartResponseAsyncInterator");function Qc(e){return async(...t)=>{if(!Ci.test(t[0]))throw new Error(Te("This operation does not result in a streamable response - use request() instead."));try{let n=await e(...t),{statusText:i}=n;if(!n.ok)throw new Error(i,{cause:n});let s=n.headers.get("content-type")||"";switch(!0){case s.includes(Tn.json):return Uc(n);case s.includes(Tn.multipart):return Hc(n,s);default:throw new Error(`${bi} ${s}`,{cause:n})}}catch(n){return{async*[Symbol.asyncIterator](){let i=Ri(n);yield{errors:{message:Te(qe(n)),...le("networkStatusCode",i?.status),...le("response",i)},hasNext:!1}}}}}}r(Qc,"generateRequestStream");function Li({client:e,storeDomain:t}){try{if(!t||typeof t!="string")throw new Error;let n=t.trim(),i=n.match(/^https?:/)?n:`https://${n}`,s=new URL(i);return s.protocol="https",s.origin}catch(n){throw new Error(`${e}: a valid store domain ("${t}") must be provided`,{cause:n})}}r(Li,"validateDomainAndGetStoreUrl");function On({client:e,currentSupportedApiVersions:t,apiVersion:n,logger:i}){let s=`${e}: the provided apiVersion ("${n}")`,o=`Currently supported API versions: ${t.join(", ")}`;if(!n||typeof n!="string")throw new Error(`${s} is invalid. ${o}`);let a=n.trim();t.includes(a)||(i?i({type:"Unsupported_Api_Version",content:{apiVersion:n,supportedApiVersions:t}}):console.warn(`${s} is likely deprecated or not supported. ${o}`))}r(On,"validateApiVersion");function _n(e){let t=e*3-2;return t===10?t:`0${t}`}r(_n,"getQuarterMonth");function Oi(e,t,n){let i=t-n;return i<=0?`${e-1}-${_n(i+4)}`:`${e}-${_n(i)}`}r(Oi,"getPrevousVersion");function zr(){let e=new Date,t=e.getUTCMonth(),n=e.getUTCFullYear(),i=Math.floor(t/3+1);return{year:n,quarter:i,version:`${n}-${_n(i)}`}}r(zr,"getCurrentApiVersion");function _i(){let{year:e,quarter:t,version:n}=zr(),i=t===4?`${e+1}-01`:`${e}-${_n(t+1)}`;return[Oi(e,t,3),Oi(e,t,2),Oi(e,t,1),n,i,"unstable"]}r(_i,"getCurrentSupportedApiVersions");function Mi(e){return t=>({...t??{},...e.headers})}r(Mi,"generateGetHeaders");function qi({getHeaders:e,getApiUrl:t}){return(n,i)=>{let s=[n];if(i&&Object.keys(i).length>0){let{variables:o,apiVersion:a,headers:l,retries:c,signal:d}=i;s.push({...o?{variables:o}:{},...l?{headers:e(l)}:{},...a?{url:t(a)}:{},...c?{retries:c}:{},...d?{signal:d}:{}})}return s}}r(qi,"generateGetGQLClientParams");var Bi="application/json",Gr="storefront-api-client",Kr="1.0.9",Wr="X-Shopify-Storefront-Access-Token",Xr="Shopify-Storefront-Private-Token",Jr="X-SDK-Variant",Yr="X-SDK-Version",Zr="X-SDK-Variant-Source",We="Storefront API Client";function eo(e){if(e&&typeof window<"u")throw new Error(`${We}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}r(eo,"validatePrivateAccessTokenUsage");function to(e,t){if(!e&&!t)throw new Error(`${We}: a public or private access token must be provided`);if(e&&t)throw new Error(`${We}: only provide either a public or private access token`)}r(to,"validateRequiredAccessTokens");function Fi({storeDomain:e,apiVersion:t,publicAccessToken:n,privateAccessToken:i,clientName:s,retries:o=0,customFetchApi:a,logger:l}){let c=_i(),d=Li({client:We,storeDomain:e}),u={client:We,currentSupportedApiVersions:c,logger:l};On({...u,apiVersion:t}),to(n,i),eo(i);let p=zc(d,t,u),f={storeDomain:d,apiVersion:t,...n?{publicAccessToken:n}:{privateAccessToken:i},headers:{"Content-Type":Bi,Accept:Bi,[Jr]:Gr,[Yr]:Kr,...s?{[Zr]:s}:{},...n?{[Wr]:n}:{[Xr]:i}},apiUrl:p(),clientName:s},h=Di({headers:f.headers,url:f.apiUrl,retries:o,customFetchApi:a,logger:l}),w=Mi(f),m=Gc(f,p),b=qi({getHeaders:w,getApiUrl:m});return Object.freeze({config:f,getHeaders:w,getApiUrl:m,fetch:r((...k)=>h.fetch(...b(...k)),"fetch"),request:r((...k)=>h.request(...b(...k)),"request"),requestStream:r((...k)=>h.requestStream(...b(...k)),"requestStream")})}r(Fi,"createStorefrontApiClient");function zc(e,t,n){return i=>{i&&On({...n,apiVersion:i});let s=(i??t).trim();return`${e}/api/${s}/graphql.json`}}r(zc,"generateApiUrlFormatter");function Gc(e,t){return n=>n?t(n):e.apiUrl}r(Gc,"generateGetApiUrl");var Mn=`
|
|
9
9
|
fragment productImageFields on Image {
|
|
10
10
|
id
|
|
11
11
|
altText
|
|
12
12
|
url
|
|
13
13
|
thumbhash
|
|
14
14
|
}
|
|
15
|
-
`,
|
|
15
|
+
`,ji=`
|
|
16
16
|
fragment productFields on Product {
|
|
17
17
|
id
|
|
18
18
|
availableForSale
|
|
@@ -93,7 +93,7 @@ Values:
|
|
|
93
93
|
}
|
|
94
94
|
# totalInventory
|
|
95
95
|
}
|
|
96
|
-
`,
|
|
96
|
+
`,Ni=`
|
|
97
97
|
fragment productVariantDataFields on ProductVariant {
|
|
98
98
|
id
|
|
99
99
|
availableForSale
|
|
@@ -122,7 +122,7 @@ Values:
|
|
|
122
122
|
value
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
`;var
|
|
125
|
+
`;var no=`
|
|
126
126
|
query GetProduct(
|
|
127
127
|
$productId: ID!
|
|
128
128
|
$variantId: ID!
|
|
@@ -147,10 +147,10 @@ Values:
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
${
|
|
151
|
-
${
|
|
152
|
-
${
|
|
153
|
-
`,
|
|
150
|
+
${ji}
|
|
151
|
+
${Ni}
|
|
152
|
+
${Mn}
|
|
153
|
+
`,io=`
|
|
154
154
|
query GetProductByHandle(
|
|
155
155
|
$handle: String!
|
|
156
156
|
$variantId: ID!
|
|
@@ -175,10 +175,10 @@ Values:
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
${
|
|
179
|
-
${
|
|
180
|
-
${
|
|
181
|
-
`,
|
|
178
|
+
${ji}
|
|
179
|
+
${Ni}
|
|
180
|
+
${Mn}
|
|
181
|
+
`,so=`
|
|
182
182
|
query GetProductImagesById(
|
|
183
183
|
$ids: [ID!]!
|
|
184
184
|
$country: CountryCode!
|
|
@@ -202,8 +202,8 @@ Values:
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
${
|
|
206
|
-
`,
|
|
205
|
+
${Mn}
|
|
206
|
+
`,ro=`
|
|
207
207
|
query GetProductRecommendationsById(
|
|
208
208
|
$productId: ID!
|
|
209
209
|
$intent: ProductRecommendationIntent
|
|
@@ -214,7 +214,7 @@ Values:
|
|
|
214
214
|
id
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
`,
|
|
217
|
+
`,oo=`
|
|
218
218
|
query GetProductRecommendationsByHandle(
|
|
219
219
|
$handle: String!
|
|
220
220
|
$intent: ProductRecommendationIntent
|
|
@@ -225,13 +225,13 @@ Values:
|
|
|
225
225
|
id
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
`,
|
|
228
|
+
`,ao=`
|
|
229
229
|
query GetProductIdByHandle($handle: String!) {
|
|
230
230
|
product(handle: $handle) {
|
|
231
231
|
id
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
`,
|
|
234
|
+
`,lo=`
|
|
235
235
|
query GetCollectionProducts(
|
|
236
236
|
$handle: String!
|
|
237
237
|
$first: Int!
|
|
@@ -254,19 +254,19 @@ Values:
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
`;var
|
|
257
|
+
`;var co=r(async(e,{productId:t,productHandle:n,variantId:i,selectedOptions:s,productMetafields:o=[],variantMetafields:a=[],country:l,language:c})=>{if(!t&&!n)throw new Error("Either productId or productHandle must be provided");let d=!!i,u=!!s?.length,p=t?no:io,f=t?{productId:Oe("Product",t),variantId:i?Oe("ProductVariant",i):"gid://shopify/ProductVariant/0",selectedOptions:u?s:[],productMetafields:o,variantMetafields:a,includeVariantById:d,includeVariantBySelectedOptions:u,country:l,language:c}:{handle:n,variantId:i?Oe("ProductVariant",i):"gid://shopify/ProductVariant/0",selectedOptions:u?s:[],productMetafields:o,variantMetafields:a,includeVariantById:d,includeVariantBySelectedOptions:u,country:l,language:c},h=await e.query(p,f),w=h.data?.product??null,m=h.data?.variantNode??w?.variant??null;return{data:{product:w,variant:m},errors:h.errors}},"loadProduct");var uo=r(async(e,{productHandle:t})=>{if(!t)throw new Error("A product handle must be provided");return e.query(ao,{handle:t})},"loadProductId");var po=r(async(e,{items:t,country:n,language:i})=>{if(!t?.length)throw new Error("A list of items must be provided");let s={ids:t.map(o=>o.variantId?Oe("ProductVariant",o.variantId.toString()):Oe("Product",o.productId.toString())),country:n,language:i};try{return{data:(await e.query(so,s)).data?.nodes.map(l=>l===null?null:"image"in l?l.image:"featuredImage"in l?l.featuredImage:null).filter(l=>l!==null)??[],errors:null}}catch(o){return console.error(o),{data:null,errors:o}}},"loadProductImages");var ho=r(async(e,{productId:t,productHandle:n,intent:i,country:s,language:o})=>{if(!t&&!n)throw new Error("Either productId or productHandle must be provided");if(t){let l={productId:Oe("Product",t),intent:i,country:s,language:o};return e.query(ro,l)}let a={handle:n,intent:i,country:s,language:o};return e.query(oo,a)},"loadProductRecommendations");var fo=r(async(e,{handle:t,first:n,after:i,country:s,language:o})=>{if(!t)throw new Error("A collection handle must be provided");return e.query(lo,{handle:t,first:n,after:i??void 0,country:s,language:o})},"loadCollectionProducts");var Kc="2026-04",Wc=["GetProductIdByHandle"],qn=class{constructor(t,n,i){this.client=null;this.query=r(async(t,n)=>{if(!this.client)throw new Error("Storefront API client not initialized");let i=await this.client.request(t,{variables:n});return{data:i.data,errors:i.errors??null}},"query");this.loadProduct=r(async t=>co(this,{...t,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProduct");this.loadProductImages=r(async t=>po(this,{...t,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=r(async t=>ho(this,{...t,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=r(async t=>uo(this,t),"loadProductId");this.loadCollectionProducts=r(async t=>fo(this,{...t,country:this.context.localization.country,language:this.context.localization.language}),"loadCollectionProducts");this.options=t,this.context=n,this.metafields={productMetafields:i?.product.map(o=>({namespace:o.split(".")[0],key:o.split(".")[1]}))??[],variantMetafields:i?.productVariant.map(o=>({namespace:o.split(".")[0],key:o.split(".")[1]}))??[]};let s=me(n.myshopifyDomain);this.shortCache=new _e(`storefront-api-short-${s}`,"max-age=60, stale-while-revalidate=3600"),this.longCache=new _e(`storefront-api-long-${s}`,"max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(o=>{console.warn("Storefront API cache initialization cleanup error:",o)}),this.longCache.cleanupExpiredEntries().catch(o=>{console.warn("Storefront API cache initialization cleanup error:",o)}),this.client=Fi({apiVersion:Kc,customFetchApi:r((o,a)=>a?.method==="OPTIONS"?this.fetch(o,a):Wc.some(l=>a?.body?.toString().includes(`query ${l}`))?this.longCache.fetchWithCache(o,a):this.shortCache.fetchWithCache(o,a),"customFetchApi"),publicAccessToken:this.options.accessToken,storeDomain:this.options.storeDomain})}static{r(this,"StorefrontApiClient")}fetch(t,n){return n?.method==="OPTIONS"?fetch(t,n):this.shortCache.fetchWithCache(t,n)}async clearCache(){await this.shortCache.clear()}};var Xc=Object.defineProperty,v=r((e,t)=>Xc(e,"name",{value:t,configurable:!0}),"t"),Jc={bodySerializer:v(e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),"bodySerializer")},Yc=v(({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:l,sseSleepFn:c,url:d,...u})=>{let p,f=c??(h=>new Promise(w=>setTimeout(w,h)));return{stream:v(async function*(){let h=o??3e3,w=0,m=u.signal??new AbortController().signal;for(;!m.aborted;){w++;let b=u.headers instanceof Headers?u.headers:new Headers(u.headers);p!==void 0&&b.set("Last-Event-ID",p);try{let S={redirect:"follow",...u,body:u.serializedBody,headers:b,signal:m},k=new Request(d,S);e&&(k=await e(d,S));let A=await(u.fetch??globalThis.fetch)(k);if(!A.ok)throw new Error(`SSE failed: ${A.status} ${A.statusText}`);if(!A.body)throw new Error("No body in SSE response");let D=A.body.pipeThrough(new TextDecoderStream).getReader(),C="",P=v(()=>{try{D.cancel()}catch{}},"abortHandler");m.addEventListener("abort",P);try{for(;;){let{done:E,value:B}=await D.read();if(E)break;C+=B,C=C.replace(/\r\n/g,`
|
|
258
258
|
`).replace(/\r/g,`
|
|
259
|
-
`);let
|
|
259
|
+
`);let ce=C.split(`
|
|
260
260
|
|
|
261
|
-
`);C=
|
|
262
|
-
`),
|
|
263
|
-
`);try{ie=JSON.parse(H),et=!0}catch{ie=H}}et&&(s&&await s(ie),i&&(ie=await i(ie))),n?.({data:ie,event:be,id:d,retry:h}),W.length&&(yield ie)}}}finally{f.removeEventListener("abort",R),T.releaseLock()}break}catch(S){if(t?.(S),a!==void 0&&w>=a)break;let P=Math.min(h*2**(w-1),l??3e4);await m(P)}}},"createStream")()}},"createSseClient"),Nc=v(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),$c=v(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),Uc=v(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),ao=v(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let l=(e?s:s.map(c=>encodeURIComponent(c))).join($c(i));switch(i){case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;case"simple":return l;default:return`${n}=${l}`}}let o=Nc(i),a=s.map(l=>i==="label"||i==="simple"?e?l:encodeURIComponent(l):On({allowReserved:e,name:n,value:l})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),On=v(({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},"serializePrimitiveParam"),lo=v(({allowReserved:e,explode:t,name:n,style:i,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${n}=${s.toISOString()}`;if(i!=="deepObject"&&!t){let c=[];Object.entries(s).forEach(([u,d])=>{c=[...c,u,e?d:encodeURIComponent(d)]});let p=c.join(",");switch(i){case"form":return`${n}=${p}`;case"label":return`.${p}`;case"matrix":return`;${n}=${p}`;default:return p}}let a=Uc(i),l=Object.entries(s).map(([c,p])=>On({allowReserved:e,name:i==="deepObject"?`${n}[${c}]`:c,value:p})).join(a);return i==="label"||i==="matrix"?a+l:l},"serializeObjectParam"),Vc=/\{[^{}]+\}/g,Hc=v(({path:e,url:t})=>{let n=t,i=t.match(Vc);if(i)for(let s of i){let o=!1,a=s.substring(1,s.length-1),l="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),l="label"):a.startsWith(";")&&(a=a.substring(1),l="matrix");let c=e[a];if(c==null)continue;if(Array.isArray(c)){n=n.replace(s,ao({explode:o,name:a,style:l,value:c}));continue}if(typeof c=="object"){n=n.replace(s,lo({explode:o,name:a,style:l,value:c,valueOnly:!0}));continue}if(l==="matrix"){n=n.replace(s,`;${On({name:a,value:c})}`);continue}let p=encodeURIComponent(l==="label"?`.${c}`:c);n=n.replace(s,p)}return n},"defaultPathSerializer"),Qc=v(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=Hc({path:t,url:a}));let l=n?i(n):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function qi(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}r(qi,"N");v(qi,"getValidRequestBody");var zc=v(async(e,t)=>{let n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},"getAuthToken"),co=v(({parameters:e={},...t}={})=>v(n=>{let i=[];if(n&&typeof n=="object")for(let s in n){let o=n[s];if(o==null)continue;let a=e[s]||t;if(Array.isArray(o)){let l=ao({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});l&&i.push(l)}else if(typeof o=="object"){let l=lo({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});l&&i.push(l)}else{let l=On({allowReserved:a.allowReserved,name:s,value:o});l&&i.push(l)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),Gc=v(e=>{var t;if(!e)return"stream";let n=(t=e.split(";")[0])==null?void 0:t.trim();if(n){if(n.startsWith("application/json")||n.endsWith("+json"))return"json";if(n==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(i=>n.startsWith(i)))return"blob";if(n.startsWith("text/"))return"text"}},"getParseAs"),Kc=v((e,t)=>{var n,i;return t?!!(e.headers.has(t)||(n=e.query)!=null&&n[t]||(i=e.headers.get("Cookie"))!=null&&i.includes(`${t}=`)):!1},"checkForExistence"),Wc=v(async({security:e,...t})=>{for(let n of e){if(Kc(t,n.name))continue;let i=await zc(n,t.auth);if(!i)continue;let s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=i;break;case"cookie":t.headers.append("Cookie",`${s}=${i}`);break;default:t.headers.set(s,i);break}}},"setAuthParams"),ro=v(e=>Qc({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:co(e.querySerializer),url:e.url}),"buildUrl"),oo=v((e,t)=>{var n;let i={...e,...t};return(n=i.baseUrl)!=null&&n.endsWith("/")&&(i.baseUrl=i.baseUrl.substring(0,i.baseUrl.length-1)),i.headers=uo(e.headers,t.headers),i},"mergeConfigs"),Xc=v(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),uo=v((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?Xc(n):Object.entries(n);for(let[s,o]of i)if(o===null)t.delete(s);else if(Array.isArray(o))for(let a of o)t.append(s,a);else o!==void 0&&t.set(s,typeof o=="object"?JSON.stringify(o):o)}return t},"mergeHeaders"),po=class{static{r(this,"j")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(t){let n=this.getInterceptorIndex(t);this.fns[n]&&(this.fns[n]=null)}exists(t){let n=this.getInterceptorIndex(t);return!!this.fns[n]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,n){let i=this.getInterceptorIndex(t);return this.fns[i]?(this.fns[i]=n,t):!1}use(t){return this.fns.push(t),this.fns.length-1}};v(po,"Interceptors");var Mi=po,Jc=v(()=>({error:new Mi,request:new Mi,response:new Mi}),"createInterceptors"),Yc=co({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Zc={"Content-Type":"application/json"},Bi=v((e={})=>({...Fc,headers:Zc,parseAs:"auto",querySerializer:Yc,...e}),"createConfig"),ho=v((e={})=>{let t=oo(Bi(),e),n=v(()=>({...t}),"getConfig"),i=v(p=>(t=oo(t,p),n()),"setConfig"),s=Jc(),o=v(async p=>{let u={...t,...p,fetch:p.fetch??t.fetch??globalThis.fetch,headers:uo(t.headers,p.headers),serializedBody:void 0};u.security&&await Wc({...u,security:u.security}),u.requestValidator&&await u.requestValidator(u),u.body!==void 0&&u.bodySerializer&&(u.serializedBody=u.bodySerializer(u.body)),(u.body===void 0||u.serializedBody==="")&&u.headers.delete("Content-Type");let d=ro(u);return{opts:u,url:d}},"beforeRequest"),a=v(async p=>{let{opts:u,url:d}=await o(p),m={redirect:"follow",...u,body:qi(u)},h=new Request(d,m);for(let C of s.request.fns)C&&(h=await C(h,u));let w=u.fetch,f;try{f=await w(h)}catch(C){let R=C;for(let E of s.error.fns)E&&(R=await E(C,void 0,h,u));if(R=R||{},u.throwOnError)throw R;return u.responseStyle==="data"?void 0:{error:R,request:h,response:void 0}}for(let C of s.response.fns)C&&(f=await C(f,h,u));let b={request:h,response:f};if(f.ok){let C=(u.parseAs==="auto"?Gc(f.headers.get("Content-Type")):u.parseAs)??"json";if(f.status===204||f.headers.get("Content-Length")==="0"){let E;switch(C){case"arrayBuffer":case"blob":case"text":E=await f[C]();break;case"formData":E=new FormData;break;case"stream":E=f.body;break;default:E={};break}return u.responseStyle==="data"?E:{data:E,...b}}let R;switch(C){case"arrayBuffer":case"blob":case"formData":case"text":R=await f[C]();break;case"json":{let E=await f.text();R=E?JSON.parse(E):{};break}case"stream":return u.responseStyle==="data"?f.body:{data:f.body,...b}}return C==="json"&&(u.responseValidator&&await u.responseValidator(R),u.responseTransformer&&(R=await u.responseTransformer(R))),u.responseStyle==="data"?R:{data:R,...b}}let S=await f.text(),P;try{P=JSON.parse(S)}catch{}let A=P??S,T=A;for(let C of s.error.fns)C&&(T=await C(A,f,h,u));if(T=T||{},u.throwOnError)throw T;return u.responseStyle==="data"?void 0:{error:T,...b}},"request"),l=v(p=>u=>a({...u,method:p}),"makeMethodFn"),c=v(p=>async u=>{let{opts:d,url:m}=await o(u);return jc({...d,body:d.body,headers:d.headers,method:p,onRequest:v(async(h,w)=>{let f=new Request(h,w);for(let b of s.request.fns)b&&(f=await b(f,d));return f},"onRequest"),serializedBody:qi(d),url:m})},"makeSseFn");return{buildUrl:ro,connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),getConfig:n,head:l("HEAD"),interceptors:s,options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),request:a,setConfig:i,sse:{connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),head:c("HEAD"),options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),trace:c("TRACE")},trace:l("TRACE")}},"createClient"),O=ho(Bi({baseUrl:"https://swish.app/api/2026-04"})),eu=v(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),tu=v(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),nu=v(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),iu=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),su=v(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),ru=v(e=>(e.client??O).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),ou=v(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),au=v(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),lu=v(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),cu=v(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),uu=v(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),pu=v(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),du=v(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),hu=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),fu=v(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),mu=v(e=>(e.client??O).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),yu=v(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),vu=v(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),gu=v(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),wu=v(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),bu=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),Iu=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),Su=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),xu=v(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),Cu=v(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),Eu=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),Ru=v(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),ku=v(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),Pu=v(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),Au=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),Tu=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),Du=v(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),Ou=v(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),Lu=v(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),_u=v(e=>(e?.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),Mu=v(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),qu=v(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),Bu=v(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),Fu=v(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),ju=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),Nu=v(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),$u=v(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),Uu=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),Vu=v(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),Fi="2026-04",fo=v(e=>new Hu(e),"createApiClient"),mo=class{static{r(this,"xe")}constructor(t){this.version=Fi,this.items={list:v(n=>this.handlePaginatedRequest(cu({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(uu({body:n,client:this.client})),"create"),delete:v(n=>this.handleRequest(lu({body:{itemIds:n},client:this.client})),"delete"),findById:v(n=>this.handleRequest(hu({path:{itemId:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(fu({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(du({path:{itemId:n},client:this.client})),"deleteById"),setListsById:v((n,i)=>this.handleRequest(mu({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:v(()=>this.handleRequest(pu({client:this.client})),"count")},this.lists={list:v(n=>this.handlePaginatedRequest(eu({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(tu({body:n,client:this.client})),"create"),findById:v(n=>this.handleRequest(iu({path:{listId:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(su({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(nu({path:{listId:n},client:this.client})),"deleteById"),orderItems:v((n,i)=>this.handleRequest(ru({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:v((n,i)=>this.handleRequest(ou({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:v((n,i)=>this.handleRequest(au({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:v((n={})=>this.handleRequest(vu({body:n,client:this.client})),"createToken"),identify:v(n=>this.handleRequest(yu({body:n,client:this.client})),"identify"),getProfile:v(()=>this.handleRequest(gu({client:this.client})),"getProfile"),updateProfile:v(n=>this.handleRequest(wu({body:n,client:this.client})),"updateProfile")},this.orders={list:v(n=>this.handlePaginatedRequest(Cu({query:n,client:this.client})),"list"),findById:v(n=>this.handleRequest(Eu({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:v(n=>this.handlePaginatedRequest(Ru({query:n,client:this.client})),"list"),save:v(n=>this.handleRequest(ku({body:{listId:n},client:this.client})),"save"),findById:v(n=>this.handleRequest(Au({path:{sharedListId:n},client:this.client})),"findById"),deleteById:v(n=>this.handleRequest(Pu({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:v((n,i)=>this.handlePaginatedRequest(Tu({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.analytics={savedItems:v(n=>this.handleRequest(bu({query:n,client:this.client})),"savedItems"),sessions:v(n=>this.handleRequest(Iu({query:n,client:this.client})),"sessions"),newLists:v(n=>this.handleRequest(Su({query:n,client:this.client})),"newLists")},this.tracking={track:v(n=>this.handleRequest(xu({body:n,client:this.client})),"track")},this.notifications={list:v(n=>this.handlePaginatedRequest(Du({query:n,client:this.client})),"list"),getUnreadCount:v(()=>this.handleRequest(Ou({client:this.client})),"getUnreadCount"),markAsRead:v(n=>this.handleRequest(Lu({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:v(()=>this.handleRequest(_u({client:this.client})),"markAllAsRead"),deleteById:v(n=>this.handleRequest(Mu({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:v(n=>this.handlePaginatedRequest(qu({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(Bu({body:n,client:this.client})),"create"),findById:v(n=>this.handleRequest(ju({path:{id:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(Nu({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(Fu({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:v(()=>this.handleRequest($u({client:this.client})),"list"),findById:v(n=>this.handleRequest(Uu({path:{smartListId:n},client:this.client})),"findById"),findItems:v((n,i)=>this.handlePaginatedRequest(Vu({path:{smartListId:n},query:i,client:this.client})),"findItems")},this.handleRequest=v(async n=>{let{data:i,error:s}=await n;return s!=null&&s.error?{error:s.error}:{data:i?.data}},"handleRequest"),this.handlePaginatedRequest=v(async n=>{var i;let{data:s,error:o}=await n;return o!=null&&o.error?{error:o.error}:{data:s?.data??[],pageInfo:s?.pageInfo??{next:null,previous:null,totalCount:((i=s?.data)==null?void 0:i.length)??0}}},"handlePaginatedRequest"),this.client=ho(Bi({baseUrl:`https://swish.app/api/${this.version}`,...t.config})),t.authToken&&(this.authToken=t.authToken),t.requestInterceptor&&this.client.interceptors.request.use(t.requestInterceptor),t.responseInterceptor&&this.client.interceptors.response.use(t.responseInterceptor),this.client.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(t){this.authToken=t}directRequestInterceptor(t){return this.authToken&&t.headers.set("Authorization",`Bearer ${this.authToken}`),t}};v(mo,"SwishClient");var Hu=mo;var wo=Bo(go(),1);var bo=r(e=>new wo.default(async t=>{let n=[...new Set(t)].sort((s,o)=>s.localeCompare(o)),i=await e.items.list({query:n.join(" "),limit:200});return"error"in i?(console.error("Failed to load items",i.error),t.map(()=>({data:[],pageInfo:{next:null,previous:null,totalCount:0}}))):t.map(s=>{let o=i.data.find(a=>s===`variant:${a.variantId}`||s===`product:${a.productId}`);return{data:o?[o]:[],pageInfo:{next:null,previous:null,totalCount:o?1:0}}})},{batchScheduleFn:r(t=>setTimeout(t,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var ep=Object.defineProperty,g=r((e,t)=>ep(e,"name",{value:t,configurable:!0}),"t"),tp={bodySerializer:g(e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),"bodySerializer")},np=g(({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:l,sseSleepFn:c,url:p,...u})=>{let d,m=c??(h=>new Promise(w=>setTimeout(w,h)));return{stream:g(async function*(){let h=o??3e3,w=0,f=u.signal??new AbortController().signal;for(;!f.aborted;){w++;let b=u.headers instanceof Headers?u.headers:new Headers(u.headers);d!==void 0&&b.set("Last-Event-ID",d);try{let S={redirect:"follow",...u,body:u.serializedBody,headers:b,signal:f},P=new Request(p,S);e&&(P=await e(p,S));let A=await(u.fetch??globalThis.fetch)(P);if(!A.ok)throw new Error(`SSE failed: ${A.status} ${A.statusText}`);if(!A.body)throw new Error("No body in SSE response");let T=A.body.pipeThrough(new TextDecoderStream).getReader(),C="",R=g(()=>{try{T.cancel()}catch{}},"abortHandler");f.addEventListener("abort",R);try{for(;;){let{done:E,value:M}=await T.read();if(E)break;C+=M,C=C.replace(/\r\n/g,`
|
|
261
|
+
`);C=ce.pop()??"";for(let Ce of ce){let Le=Ce.split(`
|
|
262
|
+
`),ee=[],ye;for(let $ of Le)if($.startsWith("data:"))ee.push($.replace(/^data:\s*/,""));else if($.startsWith("event:"))ye=$.replace(/^event:\s*/,"");else if($.startsWith("id:"))p=$.replace(/^id:\s*/,"");else if($.startsWith("retry:")){let Ee=Number.parseInt($.replace(/^retry:\s*/,""),10);Number.isNaN(Ee)||(h=Ee)}let Y,Be=!1;if(ee.length){let $=ee.join(`
|
|
263
|
+
`);try{Y=JSON.parse($),Be=!0}catch{Y=$}}Be&&(s&&await s(Y),i&&(Y=await i(Y))),n?.({data:Y,event:ye,id:p,retry:h}),ee.length&&(yield Y)}}}finally{m.removeEventListener("abort",P),D.releaseLock()}break}catch(S){if(t?.(S),a!==void 0&&w>=a)break;let k=Math.min(h*2**(w-1),l??3e4);await f(k)}}},"createStream")()}},"createSseClient"),Zc=v(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),eu=v(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),tu=v(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),vo=v(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let l=(e?s:s.map(c=>encodeURIComponent(c))).join(eu(i));switch(i){case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;case"simple":return l;default:return`${n}=${l}`}}let o=Zc(i),a=s.map(l=>i==="label"||i==="simple"?e?l:encodeURIComponent(l):Bn({allowReserved:e,name:n,value:l})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),Bn=v(({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},"serializePrimitiveParam"),go=v(({allowReserved:e,explode:t,name:n,style:i,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${n}=${s.toISOString()}`;if(i!=="deepObject"&&!t){let c=[];Object.entries(s).forEach(([u,p])=>{c=[...c,u,e?p:encodeURIComponent(p)]});let d=c.join(",");switch(i){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}let a=tu(i),l=Object.entries(s).map(([c,d])=>Bn({allowReserved:e,name:i==="deepObject"?`${n}[${c}]`:c,value:d})).join(a);return i==="label"||i==="matrix"?a+l:l},"serializeObjectParam"),nu=/\{[^{}]+\}/g,iu=v(({path:e,url:t})=>{let n=t,i=t.match(nu);if(i)for(let s of i){let o=!1,a=s.substring(1,s.length-1),l="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),l="label"):a.startsWith(";")&&(a=a.substring(1),l="matrix");let c=e[a];if(c==null)continue;if(Array.isArray(c)){n=n.replace(s,vo({explode:o,name:a,style:l,value:c}));continue}if(typeof c=="object"){n=n.replace(s,go({explode:o,name:a,style:l,value:c,valueOnly:!0}));continue}if(l==="matrix"){n=n.replace(s,`;${Bn({name:a,value:c})}`);continue}let d=encodeURIComponent(l==="label"?`.${c}`:c);n=n.replace(s,d)}return n},"defaultPathSerializer"),su=v(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=iu({path:t,url:a}));let l=n?i(n):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function $i(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}r($i,"N");v($i,"getValidRequestBody");var ru=v(async(e,t)=>{let n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},"getAuthToken"),wo=v(({parameters:e={},...t}={})=>v(n=>{let i=[];if(n&&typeof n=="object")for(let s in n){let o=n[s];if(o==null)continue;let a=e[s]||t;if(Array.isArray(o)){let l=vo({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});l&&i.push(l)}else if(typeof o=="object"){let l=go({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});l&&i.push(l)}else{let l=Bn({allowReserved:a.allowReserved,name:s,value:o});l&&i.push(l)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),ou=v(e=>{var t;if(!e)return"stream";let n=(t=e.split(";")[0])==null?void 0:t.trim();if(n){if(n.startsWith("application/json")||n.endsWith("+json"))return"json";if(n==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(i=>n.startsWith(i)))return"blob";if(n.startsWith("text/"))return"text"}},"getParseAs"),au=v((e,t)=>{var n,i;return t?!!(e.headers.has(t)||(n=e.query)!=null&&n[t]||(i=e.headers.get("Cookie"))!=null&&i.includes(`${t}=`)):!1},"checkForExistence"),lu=v(async({security:e,...t})=>{for(let n of e){if(au(t,n.name))continue;let i=await ru(n,t.auth);if(!i)continue;let s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=i;break;case"cookie":t.headers.append("Cookie",`${s}=${i}`);break;default:t.headers.set(s,i);break}}},"setAuthParams"),mo=v(e=>su({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:wo(e.querySerializer),url:e.url}),"buildUrl"),yo=v((e,t)=>{var n;let i={...e,...t};return(n=i.baseUrl)!=null&&n.endsWith("/")&&(i.baseUrl=i.baseUrl.substring(0,i.baseUrl.length-1)),i.headers=bo(e.headers,t.headers),i},"mergeConfigs"),cu=v(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),bo=v((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?cu(n):Object.entries(n);for(let[s,o]of i)if(o===null)t.delete(s);else if(Array.isArray(o))for(let a of o)t.append(s,a);else o!==void 0&&t.set(s,typeof o=="object"?JSON.stringify(o):o)}return t},"mergeHeaders"),Io=class{static{r(this,"j")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(t){let n=this.getInterceptorIndex(t);this.fns[n]&&(this.fns[n]=null)}exists(t){let n=this.getInterceptorIndex(t);return!!this.fns[n]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,n){let i=this.getInterceptorIndex(t);return this.fns[i]?(this.fns[i]=n,t):!1}use(t){return this.fns.push(t),this.fns.length-1}};v(Io,"Interceptors");var Ui=Io,uu=v(()=>({error:new Ui,request:new Ui,response:new Ui}),"createInterceptors"),du=wo({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),pu={"Content-Type":"application/json"},Vi=v((e={})=>({...Jc,headers:pu,parseAs:"auto",querySerializer:du,...e}),"createConfig"),So=v((e={})=>{let t=yo(Vi(),e),n=v(()=>({...t}),"getConfig"),i=v(d=>(t=yo(t,d),n()),"setConfig"),s=uu(),o=v(async d=>{let u={...t,...d,fetch:d.fetch??t.fetch??globalThis.fetch,headers:bo(t.headers,d.headers),serializedBody:void 0};u.security&&await lu({...u,security:u.security}),u.requestValidator&&await u.requestValidator(u),u.body!==void 0&&u.bodySerializer&&(u.serializedBody=u.bodySerializer(u.body)),(u.body===void 0||u.serializedBody==="")&&u.headers.delete("Content-Type");let p=mo(u);return{opts:u,url:p}},"beforeRequest"),a=v(async d=>{let{opts:u,url:p}=await o(d),f={redirect:"follow",...u,body:$i(u)},h=new Request(p,f);for(let C of s.request.fns)C&&(h=await C(h,u));let w=u.fetch,m;try{m=await w(h)}catch(C){let P=C;for(let E of s.error.fns)E&&(P=await E(C,void 0,h,u));if(P=P||{},u.throwOnError)throw P;return u.responseStyle==="data"?void 0:{error:P,request:h,response:void 0}}for(let C of s.response.fns)C&&(m=await C(m,h,u));let b={request:h,response:m};if(m.ok){let C=(u.parseAs==="auto"?ou(m.headers.get("Content-Type")):u.parseAs)??"json";if(m.status===204||m.headers.get("Content-Length")==="0"){let E;switch(C){case"arrayBuffer":case"blob":case"text":E=await m[C]();break;case"formData":E=new FormData;break;case"stream":E=m.body;break;default:E={};break}return u.responseStyle==="data"?E:{data:E,...b}}let P;switch(C){case"arrayBuffer":case"blob":case"formData":case"text":P=await m[C]();break;case"json":{let E=await m.text();P=E?JSON.parse(E):{};break}case"stream":return u.responseStyle==="data"?m.body:{data:m.body,...b}}return C==="json"&&(u.responseValidator&&await u.responseValidator(P),u.responseTransformer&&(P=await u.responseTransformer(P))),u.responseStyle==="data"?P:{data:P,...b}}let S=await m.text(),k;try{k=JSON.parse(S)}catch{}let A=k??S,D=A;for(let C of s.error.fns)C&&(D=await C(A,m,h,u));if(D=D||{},u.throwOnError)throw D;return u.responseStyle==="data"?void 0:{error:D,...b}},"request"),l=v(d=>u=>a({...u,method:d}),"makeMethodFn"),c=v(d=>async u=>{let{opts:p,url:f}=await o(u);return Yc({...p,body:p.body,headers:p.headers,method:d,onRequest:v(async(h,w)=>{let m=new Request(h,w);for(let b of s.request.fns)b&&(m=await b(m,p));return m},"onRequest"),serializedBody:$i(p),url:f})},"makeSseFn");return{buildUrl:mo,connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),getConfig:n,head:l("HEAD"),interceptors:s,options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),request:a,setConfig:i,sse:{connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),head:c("HEAD"),options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),trace:c("TRACE")},trace:l("TRACE")}},"createClient"),L=So(Vi({baseUrl:"https://swish.app/api/2026-04"})),hu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),fu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),mu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),yu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),vu=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),gu=v(e=>(e.client??L).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),wu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),bu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),Iu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),Su=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),xu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Cu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),Eu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),Ru=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),ku=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),Pu=v(e=>(e.client??L).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),Au=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),Tu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),Du=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),Lu=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),Ou=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),_u=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),Mu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),qu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),Bu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),Fu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),ju=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),Nu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),Uu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),$u=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),Vu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),Hu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),Qu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),zu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),Gu=v(e=>(e?.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),Ku=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),Wu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),Xu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),Ju=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),Yu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),Zu=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),ed=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),td=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),nd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),Hi="2026-04",xo=v(e=>new id(e),"createApiClient"),Co=class{static{r(this,"xe")}constructor(t){this.version=Hi,this.items={list:v(n=>this.handlePaginatedRequest(Su({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(xu({body:n,client:this.client})),"create"),delete:v(n=>this.handleRequest(Iu({body:{itemIds:n},client:this.client})),"delete"),findById:v(n=>this.handleRequest(Ru({path:{itemId:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(ku({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(Eu({path:{itemId:n},client:this.client})),"deleteById"),setListsById:v((n,i)=>this.handleRequest(Pu({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:v(()=>this.handleRequest(Cu({client:this.client})),"count")},this.lists={list:v(n=>this.handlePaginatedRequest(hu({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(fu({body:n,client:this.client})),"create"),findById:v(n=>this.handleRequest(yu({path:{listId:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(vu({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(mu({path:{listId:n},client:this.client})),"deleteById"),orderItems:v((n,i)=>this.handleRequest(gu({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:v((n,i)=>this.handleRequest(wu({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:v((n,i)=>this.handleRequest(bu({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:v((n={})=>this.handleRequest(Tu({body:n,client:this.client})),"createToken"),identify:v(n=>this.handleRequest(Au({body:n,client:this.client})),"identify"),getProfile:v(()=>this.handleRequest(Du({client:this.client})),"getProfile"),updateProfile:v(n=>this.handleRequest(Lu({body:n,client:this.client})),"updateProfile")},this.orders={list:v(n=>this.handlePaginatedRequest(Bu({query:n,client:this.client})),"list"),findById:v(n=>this.handleRequest(Fu({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:v(n=>this.handlePaginatedRequest(ju({query:n,client:this.client})),"list"),save:v(n=>this.handleRequest(Nu({body:{listId:n},client:this.client})),"save"),findById:v(n=>this.handleRequest($u({path:{sharedListId:n},client:this.client})),"findById"),deleteById:v(n=>this.handleRequest(Uu({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:v((n,i)=>this.handlePaginatedRequest(Vu({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.analytics={savedItems:v(n=>this.handleRequest(Ou({query:n,client:this.client})),"savedItems"),sessions:v(n=>this.handleRequest(_u({query:n,client:this.client})),"sessions"),newLists:v(n=>this.handleRequest(Mu({query:n,client:this.client})),"newLists")},this.tracking={track:v(n=>this.handleRequest(qu({body:n,client:this.client})),"track")},this.notifications={list:v(n=>this.handlePaginatedRequest(Hu({query:n,client:this.client})),"list"),getUnreadCount:v(()=>this.handleRequest(Qu({client:this.client})),"getUnreadCount"),markAsRead:v(n=>this.handleRequest(zu({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:v(()=>this.handleRequest(Gu({client:this.client})),"markAllAsRead"),deleteById:v(n=>this.handleRequest(Ku({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:v(n=>this.handlePaginatedRequest(Wu({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(Xu({body:n,client:this.client})),"create"),findById:v(n=>this.handleRequest(Yu({path:{id:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(Zu({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(Ju({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:v(()=>this.handleRequest(ed({client:this.client})),"list"),findById:v(n=>this.handleRequest(td({path:{smartListId:n},client:this.client})),"findById"),findItems:v((n,i)=>this.handlePaginatedRequest(nd({path:{smartListId:n},query:i,client:this.client})),"findItems")},this.handleRequest=v(async n=>{let{data:i,error:s}=await n;return s!=null&&s.error?{error:s.error}:{data:i?.data}},"handleRequest"),this.handlePaginatedRequest=v(async n=>{var i;let{data:s,error:o}=await n;return o!=null&&o.error?{error:o.error}:{data:s?.data??[],pageInfo:s?.pageInfo??{next:null,previous:null,totalCount:((i=s?.data)==null?void 0:i.length)??0}}},"handlePaginatedRequest"),this.client=So(Vi({baseUrl:`https://swish.app/api/${this.version}`,...t.config})),t.authToken&&(this.authToken=t.authToken),t.requestInterceptor&&this.client.interceptors.request.use(t.requestInterceptor),t.responseInterceptor&&this.client.interceptors.response.use(t.responseInterceptor),this.client.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(t){this.authToken=t}directRequestInterceptor(t){return this.authToken&&t.headers.set("Authorization",`Bearer ${this.authToken}`),t}};v(Co,"SwishClient");var id=Co;var Po=Go(ko(),1);var Ao=r(e=>new Po.default(async t=>{let n=[...new Set(t)].sort((s,o)=>s.localeCompare(o)),i=await e.items.list({query:n.join(" "),limit:200});if("error"in i){let s=new Error(i.error.message);return t.map(()=>s)}return t.map(s=>{let o=i.data.filter(a=>s===`variant:${a.variantId}`||s===`product:${a.productId}`);return{data:o,pageInfo:{next:null,previous:null,totalCount:o.length}}})},{batchScheduleFn:r(t=>setTimeout(t,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var hd=Object.defineProperty,g=r((e,t)=>hd(e,"name",{value:t,configurable:!0}),"t"),fd={bodySerializer:g(e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),"bodySerializer")},md=g(({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:l,sseSleepFn:c,url:d,...u})=>{let p,f=c??(h=>new Promise(w=>setTimeout(w,h)));return{stream:g(async function*(){let h=o??3e3,w=0,m=u.signal??new AbortController().signal;for(;!m.aborted;){w++;let b=u.headers instanceof Headers?u.headers:new Headers(u.headers);p!==void 0&&b.set("Last-Event-ID",p);try{let S={redirect:"follow",...u,body:u.serializedBody,headers:b,signal:m},k=new Request(d,S);e&&(k=await e(d,S));let A=await(u.fetch??globalThis.fetch)(k);if(!A.ok)throw new Error(`SSE failed: ${A.status} ${A.statusText}`);if(!A.body)throw new Error("No body in SSE response");let D=A.body.pipeThrough(new TextDecoderStream).getReader(),C="",P=g(()=>{try{D.cancel()}catch{}},"abortHandler");m.addEventListener("abort",P);try{for(;;){let{done:E,value:B}=await D.read();if(E)break;C+=B,C=C.replace(/\r\n/g,`
|
|
264
264
|
`).replace(/\r/g,`
|
|
265
|
-
`);let
|
|
265
|
+
`);let ce=C.split(`
|
|
266
266
|
|
|
267
|
-
`);C=
|
|
268
|
-
`),
|
|
269
|
-
`);try{ie=JSON.parse(H),et=!0}catch{ie=H}}et&&(s&&await s(ie),i&&(ie=await i(ie))),n?.({data:ie,event:be,id:d,retry:h}),W.length&&(yield ie)}}}finally{f.removeEventListener("abort",R),T.releaseLock()}break}catch(S){if(t?.(S),a!==void 0&&w>=a)break;let P=Math.min(h*2**(w-1),l??3e4);await m(P)}}},"createStream")()}},"createSseClient"),ip=g(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),sp=g(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),rp=g(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),xo=g(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let l=(e?s:s.map(c=>encodeURIComponent(c))).join(sp(i));switch(i){case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;case"simple":return l;default:return`${n}=${l}`}}let o=ip(i),a=s.map(l=>i==="label"||i==="simple"?e?l:encodeURIComponent(l):Ln({allowReserved:e,name:n,value:l})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),Ln=g(({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},"serializePrimitiveParam"),Co=g(({allowReserved:e,explode:t,name:n,style:i,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${n}=${s.toISOString()}`;if(i!=="deepObject"&&!t){let c=[];Object.entries(s).forEach(([u,d])=>{c=[...c,u,e?d:encodeURIComponent(d)]});let p=c.join(",");switch(i){case"form":return`${n}=${p}`;case"label":return`.${p}`;case"matrix":return`;${n}=${p}`;default:return p}}let a=rp(i),l=Object.entries(s).map(([c,p])=>Ln({allowReserved:e,name:i==="deepObject"?`${n}[${c}]`:c,value:p})).join(a);return i==="label"||i==="matrix"?a+l:l},"serializeObjectParam"),op=/\{[^{}]+\}/g,ap=g(({path:e,url:t})=>{let n=t,i=t.match(op);if(i)for(let s of i){let o=!1,a=s.substring(1,s.length-1),l="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),l="label"):a.startsWith(";")&&(a=a.substring(1),l="matrix");let c=e[a];if(c==null)continue;if(Array.isArray(c)){n=n.replace(s,xo({explode:o,name:a,style:l,value:c}));continue}if(typeof c=="object"){n=n.replace(s,Co({explode:o,name:a,style:l,value:c,valueOnly:!0}));continue}if(l==="matrix"){n=n.replace(s,`;${Ln({name:a,value:c})}`);continue}let p=encodeURIComponent(l==="label"?`.${c}`:c);n=n.replace(s,p)}return n},"defaultPathSerializer"),lp=g(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=ap({path:t,url:a}));let l=n?i(n):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function Vi(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}r(Vi,"N");g(Vi,"getValidRequestBody");var cp=g(async(e,t)=>{let n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},"getAuthToken"),Eo=g(({parameters:e={},...t}={})=>g(n=>{let i=[];if(n&&typeof n=="object")for(let s in n){let o=n[s];if(o==null)continue;let a=e[s]||t;if(Array.isArray(o)){let l=xo({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});l&&i.push(l)}else if(typeof o=="object"){let l=Co({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});l&&i.push(l)}else{let l=Ln({allowReserved:a.allowReserved,name:s,value:o});l&&i.push(l)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),up=g(e=>{var t;if(!e)return"stream";let n=(t=e.split(";")[0])==null?void 0:t.trim();if(n){if(n.startsWith("application/json")||n.endsWith("+json"))return"json";if(n==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(i=>n.startsWith(i)))return"blob";if(n.startsWith("text/"))return"text"}},"getParseAs"),pp=g((e,t)=>{var n,i;return t?!!(e.headers.has(t)||(n=e.query)!=null&&n[t]||(i=e.headers.get("Cookie"))!=null&&i.includes(`${t}=`)):!1},"checkForExistence"),dp=g(async({security:e,...t})=>{for(let n of e){if(pp(t,n.name))continue;let i=await cp(n,t.auth);if(!i)continue;let s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=i;break;case"cookie":t.headers.append("Cookie",`${s}=${i}`);break;default:t.headers.set(s,i);break}}},"setAuthParams"),Io=g(e=>lp({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Eo(e.querySerializer),url:e.url}),"buildUrl"),So=g((e,t)=>{var n;let i={...e,...t};return(n=i.baseUrl)!=null&&n.endsWith("/")&&(i.baseUrl=i.baseUrl.substring(0,i.baseUrl.length-1)),i.headers=Ro(e.headers,t.headers),i},"mergeConfigs"),hp=g(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),Ro=g((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?hp(n):Object.entries(n);for(let[s,o]of i)if(o===null)t.delete(s);else if(Array.isArray(o))for(let a of o)t.append(s,a);else o!==void 0&&t.set(s,typeof o=="object"?JSON.stringify(o):o)}return t},"mergeHeaders"),ko=class{static{r(this,"j")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(t){let n=this.getInterceptorIndex(t);this.fns[n]&&(this.fns[n]=null)}exists(t){let n=this.getInterceptorIndex(t);return!!this.fns[n]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,n){let i=this.getInterceptorIndex(t);return this.fns[i]?(this.fns[i]=n,t):!1}use(t){return this.fns.push(t),this.fns.length-1}};g(ko,"Interceptors");var Ui=ko,fp=g(()=>({error:new Ui,request:new Ui,response:new Ui}),"createInterceptors"),mp=Eo({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),yp={"Content-Type":"application/json"},Hi=g((e={})=>({...tp,headers:yp,parseAs:"auto",querySerializer:mp,...e}),"createConfig"),Po=g((e={})=>{let t=So(Hi(),e),n=g(()=>({...t}),"getConfig"),i=g(p=>(t=So(t,p),n()),"setConfig"),s=fp(),o=g(async p=>{let u={...t,...p,fetch:p.fetch??t.fetch??globalThis.fetch,headers:Ro(t.headers,p.headers),serializedBody:void 0};u.security&&await dp({...u,security:u.security}),u.requestValidator&&await u.requestValidator(u),u.body!==void 0&&u.bodySerializer&&(u.serializedBody=u.bodySerializer(u.body)),(u.body===void 0||u.serializedBody==="")&&u.headers.delete("Content-Type");let d=Io(u);return{opts:u,url:d}},"beforeRequest"),a=g(async p=>{let{opts:u,url:d}=await o(p),m={redirect:"follow",...u,body:Vi(u)},h=new Request(d,m);for(let C of s.request.fns)C&&(h=await C(h,u));let w=u.fetch,f;try{f=await w(h)}catch(C){let R=C;for(let E of s.error.fns)E&&(R=await E(C,void 0,h,u));if(R=R||{},u.throwOnError)throw R;return u.responseStyle==="data"?void 0:{error:R,request:h,response:void 0}}for(let C of s.response.fns)C&&(f=await C(f,h,u));let b={request:h,response:f};if(f.ok){let C=(u.parseAs==="auto"?up(f.headers.get("Content-Type")):u.parseAs)??"json";if(f.status===204||f.headers.get("Content-Length")==="0"){let E;switch(C){case"arrayBuffer":case"blob":case"text":E=await f[C]();break;case"formData":E=new FormData;break;case"stream":E=f.body;break;default:E={};break}return u.responseStyle==="data"?E:{data:E,...b}}let R;switch(C){case"arrayBuffer":case"blob":case"formData":case"text":R=await f[C]();break;case"json":{let E=await f.text();R=E?JSON.parse(E):{};break}case"stream":return u.responseStyle==="data"?f.body:{data:f.body,...b}}return C==="json"&&(u.responseValidator&&await u.responseValidator(R),u.responseTransformer&&(R=await u.responseTransformer(R))),u.responseStyle==="data"?R:{data:R,...b}}let S=await f.text(),P;try{P=JSON.parse(S)}catch{}let A=P??S,T=A;for(let C of s.error.fns)C&&(T=await C(A,f,h,u));if(T=T||{},u.throwOnError)throw T;return u.responseStyle==="data"?void 0:{error:T,...b}},"request"),l=g(p=>u=>a({...u,method:p}),"makeMethodFn"),c=g(p=>async u=>{let{opts:d,url:m}=await o(u);return np({...d,body:d.body,headers:d.headers,method:p,onRequest:g(async(h,w)=>{let f=new Request(h,w);for(let b of s.request.fns)b&&(f=await b(f,d));return f},"onRequest"),serializedBody:Vi(d),url:m})},"makeSseFn");return{buildUrl:Io,connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),getConfig:n,head:l("HEAD"),interceptors:s,options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),request:a,setConfig:i,sse:{connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),head:c("HEAD"),options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),trace:c("TRACE")},trace:l("TRACE")}},"createClient"),L=Po(Hi({baseUrl:"https://swish.app/api/2026-04"})),vp=g(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),gp=g(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),wp=g(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),bp=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),Ip=g(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),Sp=g(e=>(e.client??L).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),xp=g(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),Cp=g(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),Ep=g(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),Rp=g(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),kp=g(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Pp=g(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),Ap=g(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),Tp=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),Dp=g(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),Op=g(e=>(e.client??L).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),Lp=g(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),_p=g(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),Mp=g(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),qp=g(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),Bp=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),Fp=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),jp=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),Np=g(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),$p=g(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),Up=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),Vp=g(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),Hp=g(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),Qp=g(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),zp=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),Gp=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),Kp=g(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),Wp=g(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),Xp=g(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),Jp=g(e=>(e?.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),Yp=g(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),Zp=g(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),ed=g(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),td=g(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),nd=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),id=g(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),sd=g(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),rd=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),od=g(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),Qi="2026-04",gI=g(e=>new ad(e),"createApiClient"),Ao=class{static{r(this,"xe")}constructor(t){this.version=Qi,this.items={list:g(n=>this.handlePaginatedRequest(Rp({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(kp({body:n,client:this.client})),"create"),delete:g(n=>this.handleRequest(Ep({body:{itemIds:n},client:this.client})),"delete"),findById:g(n=>this.handleRequest(Tp({path:{itemId:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(Dp({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(Ap({path:{itemId:n},client:this.client})),"deleteById"),setListsById:g((n,i)=>this.handleRequest(Op({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:g(()=>this.handleRequest(Pp({client:this.client})),"count")},this.lists={list:g(n=>this.handlePaginatedRequest(vp({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(gp({body:n,client:this.client})),"create"),findById:g(n=>this.handleRequest(bp({path:{listId:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(Ip({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(wp({path:{listId:n},client:this.client})),"deleteById"),orderItems:g((n,i)=>this.handleRequest(Sp({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:g((n,i)=>this.handleRequest(xp({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:g((n,i)=>this.handleRequest(Cp({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:g((n={})=>this.handleRequest(_p({body:n,client:this.client})),"createToken"),identify:g(n=>this.handleRequest(Lp({body:n,client:this.client})),"identify"),getProfile:g(()=>this.handleRequest(Mp({client:this.client})),"getProfile"),updateProfile:g(n=>this.handleRequest(qp({body:n,client:this.client})),"updateProfile")},this.orders={list:g(n=>this.handlePaginatedRequest($p({query:n,client:this.client})),"list"),findById:g(n=>this.handleRequest(Up({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:g(n=>this.handlePaginatedRequest(Vp({query:n,client:this.client})),"list"),save:g(n=>this.handleRequest(Hp({body:{listId:n},client:this.client})),"save"),findById:g(n=>this.handleRequest(zp({path:{sharedListId:n},client:this.client})),"findById"),deleteById:g(n=>this.handleRequest(Qp({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:g((n,i)=>this.handlePaginatedRequest(Gp({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.analytics={savedItems:g(n=>this.handleRequest(Bp({query:n,client:this.client})),"savedItems"),sessions:g(n=>this.handleRequest(Fp({query:n,client:this.client})),"sessions"),newLists:g(n=>this.handleRequest(jp({query:n,client:this.client})),"newLists")},this.tracking={track:g(n=>this.handleRequest(Np({body:n,client:this.client})),"track")},this.notifications={list:g(n=>this.handlePaginatedRequest(Kp({query:n,client:this.client})),"list"),getUnreadCount:g(()=>this.handleRequest(Wp({client:this.client})),"getUnreadCount"),markAsRead:g(n=>this.handleRequest(Xp({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:g(()=>this.handleRequest(Jp({client:this.client})),"markAllAsRead"),deleteById:g(n=>this.handleRequest(Yp({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:g(n=>this.handlePaginatedRequest(Zp({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(ed({body:n,client:this.client})),"create"),findById:g(n=>this.handleRequest(nd({path:{id:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(id({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(td({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:g(()=>this.handleRequest(sd({client:this.client})),"list"),findById:g(n=>this.handleRequest(rd({path:{smartListId:n},client:this.client})),"findById"),findItems:g((n,i)=>this.handlePaginatedRequest(od({path:{smartListId:n},query:i,client:this.client})),"findItems")},this.handleRequest=g(async n=>{let{data:i,error:s}=await n;return s!=null&&s.error?{error:s.error}:{data:i?.data}},"handleRequest"),this.handlePaginatedRequest=g(async n=>{var i;let{data:s,error:o}=await n;return o!=null&&o.error?{error:o.error}:{data:s?.data??[],pageInfo:s?.pageInfo??{next:null,previous:null,totalCount:((i=s?.data)==null?void 0:i.length)??0}}},"handlePaginatedRequest"),this.client=Po(Hi({baseUrl:`https://swish.app/api/${this.version}`,...t.config})),t.authToken&&(this.authToken=t.authToken),t.requestInterceptor&&this.client.interceptors.request.use(t.requestInterceptor),t.responseInterceptor&&this.client.interceptors.response.use(t.responseInterceptor),this.client.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(t){this.authToken=t}directRequestInterceptor(t){return this.authToken&&t.headers.set("Authorization",`Bearer ${this.authToken}`),t}};g(Ao,"SwishClient");var ad=Ao;var _n=class{constructor(t,n,i,s){this.tokenHasProfile=!1;this.api=t,this.context=n,this.eventBus=i,this.tokenUrl=s}static{r(this,"SwishApiAuth")}hasProfile(){return this.tokenHasProfile}hasToken(){return!!this.getSwishToken()}async renewToken(){return this._renewPromise?this._renewPromise:(this._renewPromise=(async()=>{this._initPromise=void 0,this.deleteSwishToken(),await this.init(),this._renewPromise=void 0})(),this._renewPromise)}async init(){return this._initPromise?this._initPromise:(this._initPromise=(async()=>{let t=this.getSwishToken();this.migrateLegacySession();let n=this.context.customer.id;n?(this.hasSessionToken()&&(this.eventBus.publish("auth-cache-clear",null),await this.api.clearCache()),await this.initCustomer(n)):(this.hasCustomerToken()&&await this.resetSession(),await this.initSession());let i=this.getSwishToken();i&&i!==t&&this.eventBus.publish("token-update",null)})(),this._initPromise)}async initCustomer(t){let n=`gid://shopify/Customer/${t}`,i=this.getTokenBySub(n);if(i){this.initToken(i);return}let s=this.getSessionId();await this.acquireToken(s,n)}async initSession(){let t=this.getSessionId(),n=t?this.getTokenBySub(t):null;if(n){this.initToken(n);return}await this.acquireToken(t)}initToken(t){let n=this.getTokenData(t);if(!n)throw new Error("Invalid Swish token.");this.tokenHasProfile=n.has_profile!==!1,this.api.setAuthToken(t)}async acquireToken(t,n){let i={};n&&(i.customer=n),t&&(i.session=t);let s=await fetch(this.tokenUrl,{method:"POST",headers:{"Content-Type":"application/json","Swish-Api-Version":Qi},body:JSON.stringify(i)});if(!s.ok)throw console.error("Failed to create customer token",s.status),new Error("Failed to create customer token");let a=(await s.json()).data;if(!a?.token)throw console.error("Failed to create customer token empty response"),new Error("Failed to create customer token");a.profile.startsWith("gid://swish/Session/")&&this.setSessionId(a.profile),this.setSwishToken(a.token),this.initToken(a.token)}async resetSession(){this.deleteSessionId(),this.deleteSwishToken(),await this.api.clearCache(),this.eventBus.publish("auth-cache-clear",null)}getTokenData(t){try{return JSON.parse(atob(t.split(".")[1]))}catch(n){return console.error("Failed to parse Swish token",{cause:n}),null}}willTokenExpire(t,n=60){let i=this.getTokenData(t);return!!(i&&i.exp&&i.exp<Date.now()/1e3+n)}hasCustomerToken(){let t=this.getSwishToken();return t?this.getTokenData(t)?.sub?.startsWith("gid://shopify/Customer/")??!1:!1}hasSessionToken(){let t=this.getSwishToken();return t?this.getTokenData(t)?.sub?.startsWith("gid://swish/Session/")??!1:!1}getTokenBySub(t){if(!t)return null;let n=this.getSwishToken();if(!n)return null;let i=this.getTokenData(n);return!i||i.sub!==t||this.willTokenExpire(n,60)?null:n}getSessionId(){let t=he(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${t}`)??void 0}setSessionId(t){let n=he(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${n}`,t)}deleteSessionId(){let t=he(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${t}`)}getSwishToken(){let t=he(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${t}`)??void 0}setSwishToken(t){let n=he(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${n}`,t)}deleteSwishToken(){let t=he(this.context.myshopifyDomain);sessionStorage.removeItem(`swish-token-${t}`)}migrateLegacySession(){try{let t=localStorage.getItem("wk_session_id")??localStorage.getItem("swish-profile")?.split("/").pop()??localStorage.getItem("swish-session")?.split("/").pop();t&&(this.setSessionId(`gid://swish/Session/${t}`),localStorage.removeItem("wk_session_id"),localStorage.removeItem("swish-profile"),localStorage.removeItem("swish-session"))}catch(t){console.warn("Failed to migrate legacy session id to Swish session",{cause:t})}}};var Mn=class{static{r(this,"SwishApi")}constructor(t,n,i,s,o){this.config=t,this.storefrontContext=n;let a=he(n.myshopifyDomain);this.cache=new Ae(`swish-api-${a}`,"max-age=60, stale-while-revalidate=3600",s+Fi),this.cache.cleanupExpiredEntries().catch(c=>{console.warn("Swish API cache initialization cleanup error:",c)}),this.auth=new _n(this,n,i,o);let l={authToken:this.auth.getSwishToken(),config:{...t,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)};this.apiClient=fo(l),this.itemsLoader=bo(this)}async fetchFunction(t,n){let i=t instanceof Request?t.method:n?.method??"GET",s=t instanceof Request?t.url:typeof t=="string"?t:t.toString();if(s.includes("/smart-lists"))return fetch(t,n);let a=s.includes("/orders"),l=s.includes("/profiles");return i==="GET"&&!a&&!l?this.cache.fetchWithCache(t,n):fetch(t,n)}async requestInterceptor(t){await this.initAuth();try{t.headers.set("Market-Context-Type","country"),t.headers.set("Market-Context-Value",this.storefrontContext.localization.country),t.headers.set("Country",this.storefrontContext.localization.country),t.headers.set("Language",this.storefrontContext.localization.language),t.headers.set("Market",this.storefrontContext.localization.market)}catch(n){console.warn("Failed to set storefront context headers:",n)}return this.config.requestInterceptor&&(t=await this.config.requestInterceptor(t)),t}async responseInterceptor(t,n){let i=n.method!=="GET",s=n.url.includes("/profiles/token");if(i&&!s){let o=this.auth.hasToken(),a=!this.auth.hasProfile(),l=t.ok;await this.cache.clear(),o&&a&&l&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(t,n),t}setAuthToken(t){this.apiClient.setAuthToken(t)}initAuth(){return this.auth.init()}async withFallback(t,n){return await this.initAuth(),this.auth.hasProfile()?t():Promise.resolve(n)}async withSignedInCustomerFallback(t,n){return await this.initAuth(),!!this.storefrontContext.customer.id&&this.auth.hasProfile()?t():Promise.resolve(n)}get items(){return{...this.apiClient.items,count:r(async()=>this.withFallback(()=>this.apiClient.items.count(),{data:{count:0}}),"count"),list:r(async(t,n)=>{let i=r(()=>{if(n?.batch&&t?.query){t.limit!==1&&console.warn("Batching will always limit to 1 item");let s=t.query.split(" ");s.length>1&&console.warn("Batching will only support one query parameter");let o=s[0];if(!o.match(/^product:\d+$/)&&!o.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(o)}return this.apiClient.items.list(t)},"execute");return n?.shared?i():this.withFallback(i,{data:[],pageInfo:{next:null,previous:null,totalCount:0}})},"list"),findById:r(async t=>this.withFallback(()=>this.apiClient.items.findById(t),{data:null}),"findById")}}get lists(){return{...this.apiClient.lists,list:r(async t=>this.withFallback(()=>this.apiClient.lists.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:r(async(t,n)=>{let i=r(()=>this.apiClient.lists.findById(t),"execute");return n?.shared?i():this.withFallback(()=>this.apiClient.lists.findById(t),{data:null})},"findById")}}get orders(){return{...this.apiClient.orders,list:r(async t=>this.withFallback(()=>this.apiClient.orders.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:r(async t=>this.withFallback(()=>(typeof t=="string"&&(t=parseInt(t.split("/").pop()??t)),this.apiClient.orders.findById(t)),{data:null}),"findById")}}get notifications(){return{...this.apiClient.notifications,list:r(async t=>this.withSignedInCustomerFallback(()=>this.apiClient.notifications.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),getUnreadCount:r(async()=>this.withSignedInCustomerFallback(()=>this.apiClient.notifications.getUnreadCount(),{data:{count:0}}),"getUnreadCount"),markAsRead:r(t=>this.apiClient.notifications.markAsRead(t),"markAsRead"),markAllAsRead:r(()=>this.apiClient.notifications.markAllAsRead(),"markAllAsRead"),deleteById:r(t=>this.apiClient.notifications.deleteById(t),"deleteById")}}get smartLists(){return{...this.apiClient.smartLists,list:r(async()=>this.withFallback(()=>this.apiClient.smartLists.list(),{data:null}),"list"),findById:r(async t=>t==="recently-viewed"?this.apiClient.smartLists.findById(t):this.withFallback(()=>this.apiClient.smartLists.findById(t),{data:null}),"findById"),findItems:r(async(t,n)=>t==="recently-viewed"?this.apiClient.smartLists.findItems(t,n):this.withFallback(()=>this.apiClient.smartLists.findItems(t,n),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"findItems")}}get profiles(){return{...this.apiClient.profiles,getProfile:r(async()=>this.withSignedInCustomerFallback(()=>this.apiClient.profiles.getProfile(),{data:null}),"getProfile"),updateProfile:r(async t=>this.apiClient.profiles.updateProfile(t),"updateProfile")}}async clearCache(){await this.cache.clear()}};var qn=class{constructor(t){this.eventMap={"POST /items\\/?$":"item-create","DELETE /items\\/?$":"item-delete","PATCH /items\\/([^/]+)\\/?$":"item-update","DELETE /items\\/([^/]+)\\/?$":"item-delete","PUT /items\\/([^/]+)\\/lists\\/?$":"item-lists-update","POST /lists\\/?$":"list-create","DELETE /lists\\/?$":"list-delete","PATCH /lists\\/([^/]+)\\/?$":"list-update","DELETE /lists\\/([^/]+)\\/?$":"list-delete","POST /notifications\\/read\\/all\\/?$":"notification-update","POST /notifications\\/read\\/?$":"notification-update","PATCH /notifications\\/([^/]+)\\/?$":"notification-update","DELETE /notifications\\/([^/]+)\\/?$":"notification-delete"};this.eventBus=t,this.processFetchResponse=this.processFetchResponse.bind(this)}static{r(this,"SwishApiPublisher")}async processFetchResponse(t,n){try{let i=this.getEventName(n.method,t.status,n.url);if(!i)return;let s=await t.clone().text();if(t.headers.get("Content-Type")?.includes("application/json"))try{s=JSON.parse(s).data}catch(o){console.warn(o)}this.eventBus.publish(i,s)}catch(i){console.warn(i)}}getEventName(t,n,i){t=t.toUpperCase();let s=new URL(i).pathname;return t==="GET"||n<200||n>=300?void 0:Object.entries(this.eventMap).find(([a])=>{let[l,c]=a.split(" ");return l!==t?!1:new RegExp(c).test(s)})?.[1]}};var Bn=class{constructor(t){this.inflightModals=new Map;this.modalsWithScrollLock=new Set;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this.elementId=0;this._templatePromises=new Map;this._importPromises=new Map;this._lockScroll=r(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=r(()=>this.unlockScroll(),"_unlockScroll");this.swishApp=t}static{r(this,"SwishUi")}async showModal(t){if(this.inflightModals.has(t))return this.inflightModals.get(t);let n=(async()=>{typeof t=="string"&&(t=await this.requireUiComponent(t)),!(!t||t.getAttribute("open")==="true")&&(this.lockScroll(),this.modalsWithScrollLock.add(t),t.setAttribute("open","true"))})().finally(()=>{this.inflightModals.delete(t)});return this.inflightModals.set(t,n),n}async hideModal(t){if(this.inflightModals.has(t))return this.inflightModals.get(t);let n=(async()=>{try{if(typeof t=="string"&&(t=await this.requireUiComponent(t)),t?.getAttribute("open")!=="true")return;t.setAttribute("open","false"),t.hasAttribute("swish-singleton")||t.addEventListener("closed",()=>{t.remove()},{once:!0})}finally{t&&typeof t!="string"&&this.modalsWithScrollLock.has(t)&&(this.modalsWithScrollLock.delete(t),this.unlockScroll())}})().finally(()=>{this.inflightModals.delete(t)});return this.inflightModals.set(t,n),n}waitForEvent(t,n){return new Promise(i=>{let s=[],o=r(()=>{s.forEach(({event:a,listener:l})=>{t.removeEventListener(a,l)})},"cleanup");Object.entries(n).forEach(([a,l])=>{let c=r(p=>{let u=l(p);o(),i(u)},"listener");s.push({event:a,listener:c}),t.addEventListener(a,c)})})}async showSignIn(t){let n=await this.requireUiComponent("sign-in");n.setAttribute("return-to",t?.returnTo??window.location.pathname),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showUnsaveAlert(t){if(!t.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let n=await this.requireUiComponent("unsave-alert");n.setAttribute("item-id",t.itemId),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(s=>s instanceof CustomEvent?{code:"ok",data:s.detail}:(console.warn("Unsave alert submitted without detail",s),{code:"closed"}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showDeleteListAlert(t){if(!t.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let n=await this.requireUiComponent("delete-list-alert");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showConfirmDialog(t){await this.hideAllToasts();let n=await this.requireUiComponent("confirm-dialog");t.titleKey?n.setAttribute("title-key",t.titleKey):n.removeAttribute("title-key"),t.descriptionKey?n.setAttribute("description-key",t.descriptionKey):n.removeAttribute("description-key"),t.confirmLabelKey?n.setAttribute("confirm-label-key",t.confirmLabelKey):n.removeAttribute("confirm-label-key"),t.cancelLabelKey?n.setAttribute("cancel-label-key",t.cancelLabelKey):n.removeAttribute("cancel-label-key"),t.danger?n.setAttribute("danger",""):n.removeAttribute("danger"),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showDrawer(t){await this.hideAllToasts();let n=await this.requireUiComponent("drawer",{singleInstance:!0});n.setAttribute("account-url",this.swishApp.storefrontContext.routes.accountUrl),this.swishApp.storefrontContext.customer.id&&n.setAttribute("customer-id",this.swishApp.storefrontContext.customer.id),n.setAttribute("view",t?.view??"home"),t?.listId&&n.setAttribute("list-id",t.listId),t?.listType&&n.setAttribute("list-type",t.listType),t?.productId&&n.setAttribute("product-id",t.productId),t?.variantId&&n.setAttribute("variant-id",t.variantId),t?.orderId&&n.setAttribute("order-id",t.orderId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListMenu(t){if(!t.listId)throw new Error("listId is required");await this.hideAllToasts();let n=await this.requireUiComponent("list-menu");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),edit:r(s=>s instanceof CustomEvent?{code:"ok",data:{action:"edit",data:s.detail}}:(console.warn("List menu edit without detail",s),{code:"closed"}),"edit"),delete:r(()=>({code:"ok",data:{action:"delete"}}),"delete"),"add-items":r(()=>({code:"ok",data:{action:"add-items"}}),"add-items"),share:r(()=>({code:"ok",data:{action:"share"}}),"share"),"edit-access":r(s=>{if(s instanceof CustomEvent){let a=s.detail?.currentListAccess;if(a==="public"||a==="private")return{code:"ok",data:{action:"edit-access",data:{currentListAccess:a}}}}return{code:"ok",data:{action:"edit-access"}}},"edit-access")});return await this.hideModal(n),i}async showOrderMenu(t){if(!t.orderId)throw new Error("orderId is required");await this.hideAllToasts();let n=await this.requireUiComponent("order-menu");n.setAttribute("order-id",t.orderId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListDetailPageMenu(t){await this.hideAllToasts();let n=await this.requireUiComponent("list-detail-page-menu");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListSelect(t){if(!t.itemId)throw new Error("itemId is required");await this.hideAllToasts();let n=await this.requireUiComponent("list-select");n.setAttribute("item-id",t.itemId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(s=>"detail"in s&&s.detail?{code:"ok",data:{action:"submit",data:s.detail}}:(console.warn("List select submit without detail",s),{code:"closed"}),"submit"),unsave:r(s=>s instanceof CustomEvent?{code:"ok",data:{action:"unsave",data:s.detail}}:(console.warn("List select unsave without detail",s),{code:"closed"}),"unsave")});return await this.hideModal(n),i}async initListDetailPage(t,n){let i=await this.requireUiComponent("list-detail-page",{refElement:n});t.listId&&i.setAttribute("list-id",t.listId)}async showToast(t){let n=Date.now(),i=await this.requireUiComponent("toast-manager",{singleInstance:!0,onHydrated:r(s=>{s.current.show(t,n)},"onHydrated")});return this.waitForEvent(i,{[`close-${n}`]:()=>({code:"closed"}),[`submit-${n}`]:()=>({code:"ok",data:void 0})})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{singleInstance:!0,onHydrated:r(t=>{t.current.clear()},"onHydrated")})}async showVariantSelect(t){await this.hideAllToasts();let n=await this.requireUiComponent("variant-select");if(t?.itemId&&n.setAttribute("item-id",t.itemId),t?.productId)n.setAttribute("product-id",t.productId.toString());else if(t?.productHandle)n.setAttribute("product-handle",t.productHandle);else throw new Error("Either productId or productHandle must be provided");t?.variantId&&n.setAttribute("variant-id",t.variantId.toString()),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Variant select submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(n),i}async showQuickBuy(t){await this.hideAllToasts();let n=await this.requireUiComponent("quick-buy");if(t?.productId)n.setAttribute("product-id",t.productId.toString());else if(t?.productHandle)n.setAttribute("product-handle",t.productHandle);else throw new Error("ProductId or productHandle must be provided");t?.variantId&&n.setAttribute("variant-id",t.variantId.toString()),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Quick buy submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(n),i}async showListEditor(t){let n=await this.requireUiComponent("list-editor");t?.listId&&n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("List editor submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(n),i}async createElement(t,n){let[i,{themeVariablesStylesheet:s}]=await Promise.all([this.loadTemplate(t),this.loadCricalResources()]),o=document.createElement("template");o.innerHTML=i.replace(' shadowrootmode="open"',"");let a=o.content.firstElementChild;return a.addEventListener("connected",()=>{a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[s],this.hydrateElement(t,a,n?.onHydrated))},{once:!0}),a}async hydrateElement(t,n,i){if(n.hasAttribute("hydrated")){i?.(n.getComponentRef());return}await Promise.all([this.loadNonCriticalResources(),this.loadLocale(),this.importScript(t)]).then(([{bundleCssStylesheet:s,customCssStylesheets:o},,{hydrate:a}])=>{n.shadowRoot&&s&&(n.shadowRoot.adoptedStyleSheets=[...n.shadowRoot.adoptedStyleSheets,...o,s],n.shadowRoot?.querySelector(":host > style")?.remove()),a(n),n.setAttribute("hydrated","")}),i?.(n.getComponentRef())}async requireUiComponent(t,n){this.loadCricalResources();let i=await this.loadTemplate(t),s=await this.insertComponent({name:t,template:i,refElement:n?.refElement??document.body,position:"beforeend",singleInstance:n?.singleInstance??!1});return s.shadowRoot&&!s.hasAttribute("hydrated")?Promise.all([this.loadNonCriticalResources(),this.loadLocale(),this.importScript(t)]).then(([{bundleCssStylesheet:o,customCssStylesheets:a},,{hydrate:l}])=>{s.shadowRoot&&o&&(s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,...a,o],s.shadowRoot?.querySelector(":host > style")?.remove()),l(s),s.setAttribute("hydrated",""),n?.onHydrated?.(s.getComponentRef())}):s.hasAttribute("hydrated")&&n?.onHydrated?.(s.getComponentRef()),s}async loadTemplate(t){let n=`${this.swishApp.options.ui.baseUrl}/ui@${ke}/${t}.html`;if(this._templatePromises.has(n))return this._templatePromises.get(n);let i=fetch(n).then(s=>s.text());return this._templatePromises.set(n,i),i}async importScript(t){let n=`${this.swishApp.options.ui.baseUrl}/ui@${ke}/${t}.js`;if(this._importPromises.has(n))return this._importPromises.get(n);let i=import(n);return this._importPromises.set(n,i),i}async loadLocale(){if(this._loadLocalePromise)return this._loadLocalePromise;let t=this.swishApp.storefrontContext.localization.language.toLowerCase();return this._loadLocalePromise=this.swishApp.i18n.loadLocale(t),this._loadLocalePromise}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let t=`${this.swishApp.options.ui.baseUrl}/ui@${ke}/theme.css`,n=await fetch(t).then(o=>o.text()),i=new CSSStyleSheet;i.replaceSync(n);let s=ld(this.swishApp.options.ui.design);return Object.entries(s).forEach(([o,a])=>{i.cssRules[0].cssRules[0].style.setProperty(o,a)}),{themeVariablesStylesheet:i}})(),this._loadCricalResourcesPromise)}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let t=`${this.swishApp.options.ui.baseUrl}/ui@${ke}/bundle.css`,n=r(o=>{let a=new CSSStyleSheet;return a.replaceSync(o),a},"createCssStylesheet"),[i,...s]=await Promise.all([fetch(t).then(o=>o.text()).then(n),...this.swishApp.options.ui.css.map(async o=>o instanceof URL?n(await fetch(o).then(a=>a.text())):n(o))]);return{bundleCssStylesheet:i,customCssStylesheets:s}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:t,template:n,position:i,refElement:s,singleInstance:o}){if(o&&this.queryComponent(t))return this.queryComponent(t);let{themeVariablesStylesheet:a}=await this.loadCricalResources(),l=o?0:++this.elementId;s.insertAdjacentHTML(i,n.replace(' shadowrootmode="open"',"").replace(`ref="${t}"`,`ref="${t}" instance="${l}"`));let c=this.queryComponent(t,l);if(!c)throw new Error(`Element ${t} not found in DOM`);return o&&c.setAttribute("swish-singleton",""),c.shadowRoot&&(c.shadowRoot.adoptedStyleSheets=[a]),c}queryComponent(t,n=0){let i=`swish-ui[ref="${t}"][instance="${n}"]`;return document.querySelector(i)}lockScroll(){this.scrollLockRefCount++,this.scrollLockRefCount===1&&(this.scrollPositionBeforeLock=window.scrollY,this.scrollLockStyleSheet||(this.scrollLockStyleSheet=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,this.scrollLockStyleSheet]),this.scrollLockStyleSheet.replaceSync(`
|
|
267
|
+
`);C=ce.pop()??"";for(let Ce of ce){let Le=Ce.split(`
|
|
268
|
+
`),ee=[],ye;for(let $ of Le)if($.startsWith("data:"))ee.push($.replace(/^data:\s*/,""));else if($.startsWith("event:"))ye=$.replace(/^event:\s*/,"");else if($.startsWith("id:"))p=$.replace(/^id:\s*/,"");else if($.startsWith("retry:")){let Ee=Number.parseInt($.replace(/^retry:\s*/,""),10);Number.isNaN(Ee)||(h=Ee)}let Y,Be=!1;if(ee.length){let $=ee.join(`
|
|
269
|
+
`);try{Y=JSON.parse($),Be=!0}catch{Y=$}}Be&&(s&&await s(Y),i&&(Y=await i(Y))),n?.({data:Y,event:ye,id:p,retry:h}),ee.length&&(yield Y)}}}finally{m.removeEventListener("abort",P),D.releaseLock()}break}catch(S){if(t?.(S),a!==void 0&&w>=a)break;let k=Math.min(h*2**(w-1),l??3e4);await f(k)}}},"createStream")()}},"createSseClient"),yd=g(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),vd=g(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),gd=g(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),Lo=g(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let l=(e?s:s.map(c=>encodeURIComponent(c))).join(vd(i));switch(i){case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;case"simple":return l;default:return`${n}=${l}`}}let o=yd(i),a=s.map(l=>i==="label"||i==="simple"?e?l:encodeURIComponent(l):Fn({allowReserved:e,name:n,value:l})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),Fn=g(({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},"serializePrimitiveParam"),Oo=g(({allowReserved:e,explode:t,name:n,style:i,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${n}=${s.toISOString()}`;if(i!=="deepObject"&&!t){let c=[];Object.entries(s).forEach(([u,p])=>{c=[...c,u,e?p:encodeURIComponent(p)]});let d=c.join(",");switch(i){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}let a=gd(i),l=Object.entries(s).map(([c,d])=>Fn({allowReserved:e,name:i==="deepObject"?`${n}[${c}]`:c,value:d})).join(a);return i==="label"||i==="matrix"?a+l:l},"serializeObjectParam"),wd=/\{[^{}]+\}/g,bd=g(({path:e,url:t})=>{let n=t,i=t.match(wd);if(i)for(let s of i){let o=!1,a=s.substring(1,s.length-1),l="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),l="label"):a.startsWith(";")&&(a=a.substring(1),l="matrix");let c=e[a];if(c==null)continue;if(Array.isArray(c)){n=n.replace(s,Lo({explode:o,name:a,style:l,value:c}));continue}if(typeof c=="object"){n=n.replace(s,Oo({explode:o,name:a,style:l,value:c,valueOnly:!0}));continue}if(l==="matrix"){n=n.replace(s,`;${Fn({name:a,value:c})}`);continue}let d=encodeURIComponent(l==="label"?`.${c}`:c);n=n.replace(s,d)}return n},"defaultPathSerializer"),Id=g(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=bd({path:t,url:a}));let l=n?i(n):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function Wi(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}r(Wi,"N");g(Wi,"getValidRequestBody");var Sd=g(async(e,t)=>{let n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},"getAuthToken"),_o=g(({parameters:e={},...t}={})=>g(n=>{let i=[];if(n&&typeof n=="object")for(let s in n){let o=n[s];if(o==null)continue;let a=e[s]||t;if(Array.isArray(o)){let l=Lo({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});l&&i.push(l)}else if(typeof o=="object"){let l=Oo({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});l&&i.push(l)}else{let l=Fn({allowReserved:a.allowReserved,name:s,value:o});l&&i.push(l)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),xd=g(e=>{var t;if(!e)return"stream";let n=(t=e.split(";")[0])==null?void 0:t.trim();if(n){if(n.startsWith("application/json")||n.endsWith("+json"))return"json";if(n==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(i=>n.startsWith(i)))return"blob";if(n.startsWith("text/"))return"text"}},"getParseAs"),Cd=g((e,t)=>{var n,i;return t?!!(e.headers.has(t)||(n=e.query)!=null&&n[t]||(i=e.headers.get("Cookie"))!=null&&i.includes(`${t}=`)):!1},"checkForExistence"),Ed=g(async({security:e,...t})=>{for(let n of e){if(Cd(t,n.name))continue;let i=await Sd(n,t.auth);if(!i)continue;let s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=i;break;case"cookie":t.headers.append("Cookie",`${s}=${i}`);break;default:t.headers.set(s,i);break}}},"setAuthParams"),To=g(e=>Id({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:_o(e.querySerializer),url:e.url}),"buildUrl"),Do=g((e,t)=>{var n;let i={...e,...t};return(n=i.baseUrl)!=null&&n.endsWith("/")&&(i.baseUrl=i.baseUrl.substring(0,i.baseUrl.length-1)),i.headers=Mo(e.headers,t.headers),i},"mergeConfigs"),Rd=g(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),Mo=g((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?Rd(n):Object.entries(n);for(let[s,o]of i)if(o===null)t.delete(s);else if(Array.isArray(o))for(let a of o)t.append(s,a);else o!==void 0&&t.set(s,typeof o=="object"?JSON.stringify(o):o)}return t},"mergeHeaders"),qo=class{static{r(this,"j")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(t){let n=this.getInterceptorIndex(t);this.fns[n]&&(this.fns[n]=null)}exists(t){let n=this.getInterceptorIndex(t);return!!this.fns[n]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,n){let i=this.getInterceptorIndex(t);return this.fns[i]?(this.fns[i]=n,t):!1}use(t){return this.fns.push(t),this.fns.length-1}};g(qo,"Interceptors");var Ki=qo,kd=g(()=>({error:new Ki,request:new Ki,response:new Ki}),"createInterceptors"),Pd=_o({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Ad={"Content-Type":"application/json"},Xi=g((e={})=>({...fd,headers:Ad,parseAs:"auto",querySerializer:Pd,...e}),"createConfig"),Bo=g((e={})=>{let t=Do(Xi(),e),n=g(()=>({...t}),"getConfig"),i=g(d=>(t=Do(t,d),n()),"setConfig"),s=kd(),o=g(async d=>{let u={...t,...d,fetch:d.fetch??t.fetch??globalThis.fetch,headers:Mo(t.headers,d.headers),serializedBody:void 0};u.security&&await Ed({...u,security:u.security}),u.requestValidator&&await u.requestValidator(u),u.body!==void 0&&u.bodySerializer&&(u.serializedBody=u.bodySerializer(u.body)),(u.body===void 0||u.serializedBody==="")&&u.headers.delete("Content-Type");let p=To(u);return{opts:u,url:p}},"beforeRequest"),a=g(async d=>{let{opts:u,url:p}=await o(d),f={redirect:"follow",...u,body:Wi(u)},h=new Request(p,f);for(let C of s.request.fns)C&&(h=await C(h,u));let w=u.fetch,m;try{m=await w(h)}catch(C){let P=C;for(let E of s.error.fns)E&&(P=await E(C,void 0,h,u));if(P=P||{},u.throwOnError)throw P;return u.responseStyle==="data"?void 0:{error:P,request:h,response:void 0}}for(let C of s.response.fns)C&&(m=await C(m,h,u));let b={request:h,response:m};if(m.ok){let C=(u.parseAs==="auto"?xd(m.headers.get("Content-Type")):u.parseAs)??"json";if(m.status===204||m.headers.get("Content-Length")==="0"){let E;switch(C){case"arrayBuffer":case"blob":case"text":E=await m[C]();break;case"formData":E=new FormData;break;case"stream":E=m.body;break;default:E={};break}return u.responseStyle==="data"?E:{data:E,...b}}let P;switch(C){case"arrayBuffer":case"blob":case"formData":case"text":P=await m[C]();break;case"json":{let E=await m.text();P=E?JSON.parse(E):{};break}case"stream":return u.responseStyle==="data"?m.body:{data:m.body,...b}}return C==="json"&&(u.responseValidator&&await u.responseValidator(P),u.responseTransformer&&(P=await u.responseTransformer(P))),u.responseStyle==="data"?P:{data:P,...b}}let S=await m.text(),k;try{k=JSON.parse(S)}catch{}let A=k??S,D=A;for(let C of s.error.fns)C&&(D=await C(A,m,h,u));if(D=D||{},u.throwOnError)throw D;return u.responseStyle==="data"?void 0:{error:D,...b}},"request"),l=g(d=>u=>a({...u,method:d}),"makeMethodFn"),c=g(d=>async u=>{let{opts:p,url:f}=await o(u);return md({...p,body:p.body,headers:p.headers,method:d,onRequest:g(async(h,w)=>{let m=new Request(h,w);for(let b of s.request.fns)b&&(m=await b(m,p));return m},"onRequest"),serializedBody:Wi(p),url:f})},"makeSseFn");return{buildUrl:To,connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),getConfig:n,head:l("HEAD"),interceptors:s,options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),request:a,setConfig:i,sse:{connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),head:c("HEAD"),options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),trace:c("TRACE")},trace:l("TRACE")}},"createClient"),O=Bo(Xi({baseUrl:"https://swish.app/api/2026-04"})),Td=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),Dd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),Ld=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),Od=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),_d=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),Md=g(e=>(e.client??O).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),qd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),Bd=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),Fd=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),jd=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),Nd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Ud=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),$d=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),Vd=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),Hd=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),Qd=g(e=>(e.client??O).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),zd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),Gd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),Kd=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),Wd=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),Xd=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),Jd=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),Yd=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),Zd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),ep=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),tp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),np=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),ip=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),sp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),rp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),op=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),ap=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),lp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),cp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),up=g(e=>(e?.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),dp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),pp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),hp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),fp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),mp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),yp=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),vp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),gp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),wp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),Ji="2026-04",LI=g(e=>new bp(e),"createApiClient"),Fo=class{static{r(this,"xe")}constructor(t){this.version=Ji,this.items={list:g(n=>this.handlePaginatedRequest(jd({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(Nd({body:n,client:this.client})),"create"),delete:g(n=>this.handleRequest(Fd({body:{itemIds:n},client:this.client})),"delete"),findById:g(n=>this.handleRequest(Vd({path:{itemId:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(Hd({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest($d({path:{itemId:n},client:this.client})),"deleteById"),setListsById:g((n,i)=>this.handleRequest(Qd({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:g(()=>this.handleRequest(Ud({client:this.client})),"count")},this.lists={list:g(n=>this.handlePaginatedRequest(Td({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(Dd({body:n,client:this.client})),"create"),findById:g(n=>this.handleRequest(Od({path:{listId:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(_d({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(Ld({path:{listId:n},client:this.client})),"deleteById"),orderItems:g((n,i)=>this.handleRequest(Md({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:g((n,i)=>this.handleRequest(qd({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:g((n,i)=>this.handleRequest(Bd({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:g((n={})=>this.handleRequest(Gd({body:n,client:this.client})),"createToken"),identify:g(n=>this.handleRequest(zd({body:n,client:this.client})),"identify"),getProfile:g(()=>this.handleRequest(Kd({client:this.client})),"getProfile"),updateProfile:g(n=>this.handleRequest(Wd({body:n,client:this.client})),"updateProfile")},this.orders={list:g(n=>this.handlePaginatedRequest(ep({query:n,client:this.client})),"list"),findById:g(n=>this.handleRequest(tp({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:g(n=>this.handlePaginatedRequest(np({query:n,client:this.client})),"list"),save:g(n=>this.handleRequest(ip({body:{listId:n},client:this.client})),"save"),findById:g(n=>this.handleRequest(rp({path:{sharedListId:n},client:this.client})),"findById"),deleteById:g(n=>this.handleRequest(sp({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:g((n,i)=>this.handlePaginatedRequest(op({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.analytics={savedItems:g(n=>this.handleRequest(Xd({query:n,client:this.client})),"savedItems"),sessions:g(n=>this.handleRequest(Jd({query:n,client:this.client})),"sessions"),newLists:g(n=>this.handleRequest(Yd({query:n,client:this.client})),"newLists")},this.tracking={track:g(n=>this.handleRequest(Zd({body:n,client:this.client})),"track")},this.notifications={list:g(n=>this.handlePaginatedRequest(ap({query:n,client:this.client})),"list"),getUnreadCount:g(()=>this.handleRequest(lp({client:this.client})),"getUnreadCount"),markAsRead:g(n=>this.handleRequest(cp({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:g(()=>this.handleRequest(up({client:this.client})),"markAllAsRead"),deleteById:g(n=>this.handleRequest(dp({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:g(n=>this.handlePaginatedRequest(pp({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(hp({body:n,client:this.client})),"create"),findById:g(n=>this.handleRequest(mp({path:{id:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(yp({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(fp({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:g(()=>this.handleRequest(vp({client:this.client})),"list"),findById:g(n=>this.handleRequest(gp({path:{smartListId:n},client:this.client})),"findById"),findItems:g((n,i)=>this.handlePaginatedRequest(wp({path:{smartListId:n},query:i,client:this.client})),"findItems")},this.handleRequest=g(async n=>{let{data:i,error:s}=await n;return s!=null&&s.error?{error:s.error}:{data:i?.data}},"handleRequest"),this.handlePaginatedRequest=g(async n=>{var i;let{data:s,error:o}=await n;return o!=null&&o.error?{error:o.error}:{data:s?.data??[],pageInfo:s?.pageInfo??{next:null,previous:null,totalCount:((i=s?.data)==null?void 0:i.length)??0}}},"handlePaginatedRequest"),this.client=Bo(Xi({baseUrl:`https://swish.app/api/${this.version}`,...t.config})),t.authToken&&(this.authToken=t.authToken),t.requestInterceptor&&this.client.interceptors.request.use(t.requestInterceptor),t.responseInterceptor&&this.client.interceptors.response.use(t.responseInterceptor),this.client.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(t){this.authToken=t}directRequestInterceptor(t){return this.authToken&&t.headers.set("Authorization",`Bearer ${this.authToken}`),t}};g(Fo,"SwishClient");var bp=Fo;var jn=class{constructor(t,n,i,s){this.tokenHasProfile=!1;this.api=t,this.context=n,this.eventBus=i,this.tokenUrl=s}static{r(this,"SwishApiAuth")}hasProfile(){return this.tokenHasProfile}hasToken(){return!!this.getSwishToken()}async renewToken(){return this._renewPromise?this._renewPromise:(this._renewPromise=(async()=>{this._initPromise=void 0,this.deleteSwishToken(),await this.init(),this._renewPromise=void 0})(),this._renewPromise)}async init(){return this._initPromise?this._initPromise:(this._initPromise=(async()=>{let t=this.getSwishToken();this.migrateLegacySession();let n=this.context.customer.id;n?(this.hasSessionToken()&&(this.eventBus.publish("auth-cache-clear",null),await this.api.clearCache()),await this.initCustomer(n)):(this.hasCustomerToken()&&await this.resetSession(),await this.initSession());let i=this.getSwishToken();i&&i!==t&&this.eventBus.publish("token-update",null)})(),this._initPromise)}async initCustomer(t){let n=`gid://shopify/Customer/${t}`,i=this.getTokenBySub(n);if(i){this.initToken(i);return}let s=this.getSessionId();await this.acquireToken(s,n)}async initSession(){let t=this.getSessionId(),n=t?this.getTokenBySub(t):null;if(n){this.initToken(n);return}await this.acquireToken(t)}initToken(t){let n=this.getTokenData(t);if(!n)throw new Error("Invalid Swish token.");this.tokenHasProfile=n.has_profile!==!1,this.api.setAuthToken(t)}async acquireToken(t,n){let i={};n&&(i.customer=n),t&&(i.session=t);let s=await fetch(this.tokenUrl,{method:"POST",headers:{"Content-Type":"application/json","Swish-Api-Version":Ji},body:JSON.stringify(i)});if(!s.ok)throw console.error("Failed to create customer token",s.status),new Error("Failed to create customer token");let a=(await s.json()).data;if(!a?.token)throw console.error("Failed to create customer token empty response"),new Error("Failed to create customer token");a.profile.startsWith("gid://swish/Session/")&&this.setSessionId(a.profile),this.setSwishToken(a.token),this.initToken(a.token)}async resetSession(){this.deleteSessionId(),this.deleteSwishToken(),await this.api.clearCache(),this.eventBus.publish("auth-cache-clear",null)}getTokenData(t){try{return JSON.parse(atob(t.split(".")[1]))}catch(n){return console.error("Failed to parse Swish token",{cause:n}),null}}willTokenExpire(t,n=60){let i=this.getTokenData(t);return!!(i&&i.exp&&i.exp<Date.now()/1e3+n)}hasCustomerToken(){let t=this.getSwishToken();return t?this.getTokenData(t)?.sub?.startsWith("gid://shopify/Customer/")??!1:!1}hasSessionToken(){let t=this.getSwishToken();return t?this.getTokenData(t)?.sub?.startsWith("gid://swish/Session/")??!1:!1}getTokenBySub(t){if(!t)return null;let n=this.getSwishToken();if(!n)return null;let i=this.getTokenData(n);return!i||i.sub!==t||this.willTokenExpire(n,60)?null:n}getSessionId(){let t=me(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${t}`)??void 0}setSessionId(t){let n=me(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${n}`,t)}deleteSessionId(){let t=me(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${t}`)}getSwishToken(){let t=me(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${t}`)??void 0}setSwishToken(t){let n=me(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${n}`,t)}deleteSwishToken(){let t=me(this.context.myshopifyDomain);sessionStorage.removeItem(`swish-token-${t}`)}migrateLegacySession(){try{let t=localStorage.getItem("wk_session_id")??localStorage.getItem("swish-profile")?.split("/").pop()??localStorage.getItem("swish-session")?.split("/").pop();t&&(this.setSessionId(`gid://swish/Session/${t}`),localStorage.removeItem("wk_session_id"),localStorage.removeItem("swish-profile"),localStorage.removeItem("swish-session"))}catch(t){console.warn("Failed to migrate legacy session id to Swish session",{cause:t})}}};var Nn=class{static{r(this,"SwishApi")}constructor(t,n,i,s,o){this.config=t,this.storefrontContext=n;let a=me(n.myshopifyDomain);this.cache=new _e(`swish-api-${a}`,"max-age=60, stale-while-revalidate=3600",s+Hi),this.cache.cleanupExpiredEntries().catch(c=>{console.warn("Swish API cache initialization cleanup error:",c)}),this.auth=new jn(this,n,i,o);let l={authToken:this.auth.getSwishToken(),config:{...t,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)};this.apiClient=xo(l),this.itemsLoader=Ao(this)}async fetchFunction(t,n){let i=t instanceof Request?t.method:n?.method??"GET",s=t instanceof Request?t.url:typeof t=="string"?t:t.toString();if(s.includes("/smart-lists"))return fetch(t,n);let a=s.includes("/orders"),l=s.includes("/profiles");return i==="GET"&&!a&&!l?this.cache.fetchWithCache(t,n):fetch(t,n)}async requestInterceptor(t){await this.initAuth();try{t.headers.set("Market-Context-Type","country"),t.headers.set("Market-Context-Value",this.storefrontContext.localization.country),t.headers.set("Country",this.storefrontContext.localization.country),t.headers.set("Language",this.storefrontContext.localization.language),t.headers.set("Market",this.storefrontContext.localization.market)}catch(n){console.warn("Failed to set storefront context headers:",n)}return this.config.requestInterceptor&&(t=await this.config.requestInterceptor(t)),t}async responseInterceptor(t,n){let i=n.method!=="GET",s=n.url.includes("/profiles/token");if(i&&!s){let o=this.auth.hasToken(),a=!this.auth.hasProfile(),l=t.ok;await this.cache.clear(),o&&a&&l&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(t,n),t}setAuthToken(t){this.apiClient.setAuthToken(t)}initAuth(){return this.auth.init()}async withFallback(t,n){return await this.initAuth(),this.auth.hasProfile()?t():Promise.resolve(n)}async withSignedInCustomerFallback(t,n){return await this.initAuth(),!!this.storefrontContext.customer.id&&this.auth.hasProfile()?t():Promise.resolve(n)}get items(){return{...this.apiClient.items,count:r(async()=>this.withFallback(()=>this.apiClient.items.count(),{data:{count:0}}),"count"),list:r(async(t,n)=>{let i=r(()=>{if(n?.batch&&t?.query){let s=t.query.split(" ");s.length>1&&console.warn("Batching will only support one query parameter");let o=s[0];if(!o.match(/^product:\d+$/)&&!o.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(o)}return this.apiClient.items.list(t)},"execute");return n?.shared?i():this.withFallback(i,{data:[],pageInfo:{next:null,previous:null,totalCount:0}})},"list"),findById:r(async t=>this.withFallback(()=>this.apiClient.items.findById(t),{data:null}),"findById")}}get lists(){return{...this.apiClient.lists,list:r(async t=>this.withFallback(()=>this.apiClient.lists.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:r(async(t,n)=>{let i=r(()=>this.apiClient.lists.findById(t),"execute");return n?.shared?i():this.withFallback(()=>this.apiClient.lists.findById(t),{data:null})},"findById")}}get orders(){return{...this.apiClient.orders,list:r(async t=>this.withFallback(()=>this.apiClient.orders.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:r(async t=>this.withFallback(()=>(typeof t=="string"&&(t=parseInt(t.split("/").pop()??t)),this.apiClient.orders.findById(t)),{data:null}),"findById")}}get notifications(){return{...this.apiClient.notifications,list:r(async t=>this.withSignedInCustomerFallback(()=>this.apiClient.notifications.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),getUnreadCount:r(async()=>this.withSignedInCustomerFallback(()=>this.apiClient.notifications.getUnreadCount(),{data:{count:0}}),"getUnreadCount"),markAsRead:r(t=>this.apiClient.notifications.markAsRead(t),"markAsRead"),markAllAsRead:r(()=>this.apiClient.notifications.markAllAsRead(),"markAllAsRead"),deleteById:r(t=>this.apiClient.notifications.deleteById(t),"deleteById")}}get smartLists(){return{...this.apiClient.smartLists,list:r(async()=>this.withFallback(()=>this.apiClient.smartLists.list(),{data:null}),"list"),findById:r(async t=>t==="recently-viewed"?this.apiClient.smartLists.findById(t):this.withFallback(()=>this.apiClient.smartLists.findById(t),{data:null}),"findById"),findItems:r(async(t,n)=>t==="recently-viewed"?this.apiClient.smartLists.findItems(t,n):this.withFallback(()=>this.apiClient.smartLists.findItems(t,n),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"findItems")}}get profiles(){return{...this.apiClient.profiles,getProfile:r(async()=>this.withSignedInCustomerFallback(()=>this.apiClient.profiles.getProfile(),{data:null}),"getProfile"),updateProfile:r(async t=>this.apiClient.profiles.updateProfile(t),"updateProfile")}}async clearCache(){await this.cache.clear()}};var Un=class{constructor(t){this.eventMap={"POST /items\\/?$":"item-create","DELETE /items\\/?$":"item-delete","PATCH /items\\/([^/]+)\\/?$":"item-update","DELETE /items\\/([^/]+)\\/?$":"item-delete","PUT /items\\/([^/]+)\\/lists\\/?$":"item-lists-update","POST /lists\\/?$":"list-create","DELETE /lists\\/?$":"list-delete","PATCH /lists\\/([^/]+)\\/?$":"list-update","DELETE /lists\\/([^/]+)\\/?$":"list-delete","POST /notifications\\/read\\/all\\/?$":"notification-update","POST /notifications\\/read\\/?$":"notification-update","PATCH /notifications\\/([^/]+)\\/?$":"notification-update","DELETE /notifications\\/([^/]+)\\/?$":"notification-delete"};this.eventBus=t,this.processFetchResponse=this.processFetchResponse.bind(this)}static{r(this,"SwishApiPublisher")}async processFetchResponse(t,n){try{let i=this.getEventName(n.method,t.status,n.url);if(!i)return;let s=await t.clone().text();if(t.headers.get("Content-Type")?.includes("application/json"))try{s=JSON.parse(s).data}catch(o){console.warn(o)}this.eventBus.publish(i,s)}catch(i){console.warn(i)}}getEventName(t,n,i){t=t.toUpperCase();let s=new URL(i).pathname;return t==="GET"||n<200||n>=300?void 0:Object.entries(this.eventMap).find(([a])=>{let[l,c]=a.split(" ");return l!==t?!1:new RegExp(c).test(s)})?.[1]}};var $n=class{constructor(t){this.inflightModals=new Map;this.modalsWithScrollLock=new Set;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this.elementId=0;this._templatePromises=new Map;this._importPromises=new Map;this._lockScroll=r(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=r(()=>this.unlockScroll(),"_unlockScroll");this.swishApp=t}static{r(this,"SwishUi")}async showModal(t){if(this.inflightModals.has(t))return this.inflightModals.get(t);let n=(async()=>{typeof t=="string"&&(t=await this.requireUiComponent(t)),!(!t||t.getAttribute("open")==="true")&&(this.lockScroll(),this.modalsWithScrollLock.add(t),t.setAttribute("open","true"))})().finally(()=>{this.inflightModals.delete(t)});return this.inflightModals.set(t,n),n}async hideModal(t){if(this.inflightModals.has(t))return this.inflightModals.get(t);let n=(async()=>{try{if(typeof t=="string"&&(t=await this.requireUiComponent(t)),t?.getAttribute("open")!=="true")return;t.setAttribute("open","false"),t.hasAttribute("swish-singleton")||t.addEventListener("closed",()=>{t.remove()},{once:!0})}finally{t&&typeof t!="string"&&this.modalsWithScrollLock.has(t)&&(this.modalsWithScrollLock.delete(t),this.unlockScroll())}})().finally(()=>{this.inflightModals.delete(t)});return this.inflightModals.set(t,n),n}waitForEvent(t,n){return new Promise(i=>{let s=[],o=r(()=>{s.forEach(({event:a,listener:l})=>{t.removeEventListener(a,l)})},"cleanup");Object.entries(n).forEach(([a,l])=>{let c=r(d=>{let u=l(d);o(),i(u)},"listener");s.push({event:a,listener:c}),t.addEventListener(a,c)})})}async showSignIn(t){let n=await this.requireUiComponent("sign-in");n.setAttribute("return-to",t?.returnTo??window.location.pathname),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showUnsaveAlert(t){if(!t.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let n=await this.requireUiComponent("unsave-alert");n.setAttribute("item-id",t.itemId),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(s=>s instanceof CustomEvent?{code:"ok",data:s.detail}:(console.warn("Unsave alert submitted without detail",s),{code:"closed"}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showDeleteListAlert(t){if(!t.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let n=await this.requireUiComponent("delete-list-alert");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showConfirmDialog(t){await this.hideAllToasts();let n=await this.requireUiComponent("confirm-dialog");t.titleKey?n.setAttribute("title-key",t.titleKey):n.removeAttribute("title-key"),t.descriptionKey?n.setAttribute("description-key",t.descriptionKey):n.removeAttribute("description-key"),t.confirmLabelKey?n.setAttribute("confirm-label-key",t.confirmLabelKey):n.removeAttribute("confirm-label-key"),t.cancelLabelKey?n.setAttribute("cancel-label-key",t.cancelLabelKey):n.removeAttribute("cancel-label-key"),t.danger?n.setAttribute("danger",""):n.removeAttribute("danger"),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showDrawer(t){await this.hideAllToasts();let n=await this.requireUiComponent("drawer",{singleInstance:!0});n.setAttribute("account-url",this.swishApp.storefrontContext.routes.accountUrl),this.swishApp.storefrontContext.customer.id&&n.setAttribute("customer-id",this.swishApp.storefrontContext.customer.id),n.setAttribute("view",t?.view??"home"),t?.listId&&n.setAttribute("list-id",t.listId),t?.listType&&n.setAttribute("list-type",t.listType),t?.productId&&n.setAttribute("product-id",t.productId),t?.variantId&&n.setAttribute("variant-id",t.variantId),t?.orderId&&n.setAttribute("order-id",t.orderId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListMenu(t){if(!t.listId)throw new Error("listId is required");await this.hideAllToasts();let n=await this.requireUiComponent("list-menu");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),edit:r(s=>s instanceof CustomEvent?{code:"ok",data:{action:"edit",data:s.detail}}:(console.warn("List menu edit without detail",s),{code:"closed"}),"edit"),delete:r(()=>({code:"ok",data:{action:"delete"}}),"delete"),"add-items":r(()=>({code:"ok",data:{action:"add-items"}}),"add-items"),share:r(()=>({code:"ok",data:{action:"share"}}),"share"),"edit-access":r(s=>{if(s instanceof CustomEvent){let a=s.detail?.currentListAccess;if(a==="public"||a==="private")return{code:"ok",data:{action:"edit-access",data:{currentListAccess:a}}}}return{code:"ok",data:{action:"edit-access"}}},"edit-access")});return await this.hideModal(n),i}async showOrderMenu(t){if(!t.orderId)throw new Error("orderId is required");await this.hideAllToasts();let n=await this.requireUiComponent("order-menu");n.setAttribute("order-id",t.orderId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListDetailPageMenu(t){await this.hideAllToasts();let n=await this.requireUiComponent("list-detail-page-menu");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListSelect(t){if(!t.itemId)throw new Error("itemId is required");await this.hideAllToasts();let n=await this.requireUiComponent("list-select");n.setAttribute("item-id",t.itemId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(s=>"detail"in s&&s.detail?{code:"ok",data:{action:"submit",data:s.detail}}:(console.warn("List select submit without detail",s),{code:"closed"}),"submit"),unsave:r(s=>s instanceof CustomEvent?{code:"ok",data:{action:"unsave",data:s.detail}}:(console.warn("List select unsave without detail",s),{code:"closed"}),"unsave")});return await this.hideModal(n),i}async initListDetailPage(t,n){let i=await this.requireUiComponent("list-detail-page",{refElement:n});t.listId&&i.setAttribute("list-id",t.listId)}async showToast(t){let n=Date.now(),i=await this.requireUiComponent("toast-manager",{singleInstance:!0,onHydrated:r(s=>{s.current.show(t,n)},"onHydrated")});return this.waitForEvent(i,{[`close-${n}`]:()=>({code:"closed"}),[`submit-${n}`]:()=>({code:"ok",data:void 0})})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{singleInstance:!0,onHydrated:r(t=>{t.current.clear()},"onHydrated")})}async showVariantSelect(t){await this.hideAllToasts();let n=await this.requireUiComponent("variant-select");if(t?.itemId&&n.setAttribute("item-id",t.itemId),t?.productId)n.setAttribute("product-id",t.productId.toString());else if(t?.productHandle)n.setAttribute("product-handle",t.productHandle);else throw new Error("Either productId or productHandle must be provided");t?.variantId&&n.setAttribute("variant-id",t.variantId.toString()),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Variant select submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(n),i}async showQuickBuy(t){await this.hideAllToasts();let n=await this.requireUiComponent("quick-buy");if(t?.productId)n.setAttribute("product-id",t.productId.toString());else if(t?.productHandle)n.setAttribute("product-handle",t.productHandle);else throw new Error("ProductId or productHandle must be provided");t?.variantId&&n.setAttribute("variant-id",t.variantId.toString()),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Quick buy submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(n),i}async showListEditor(t){let n=await this.requireUiComponent("list-editor");t?.listId&&n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("List editor submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(n),i}async createElement(t,n){let[i,{themeVariablesStylesheet:s}]=await Promise.all([this.loadTemplate(t),this.loadCricalResources()]),o=document.createElement("template");o.innerHTML=i.replace(' shadowrootmode="open"',"");let a=o.content.firstElementChild;return a.addEventListener("connected",()=>{a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[s],this.hydrateElement(t,a,n?.onHydrated))},{once:!0}),a}async hydrateElement(t,n,i){if(n.hasAttribute("hydrated")){i?.(n.getComponentRef());return}await Promise.all([this.loadNonCriticalResources(),this.loadLocale(),this.importScript(t)]).then(([{bundleCssStylesheet:s,customCssStylesheets:o},,{hydrate:a}])=>{n.shadowRoot&&s&&(n.shadowRoot.adoptedStyleSheets=[...n.shadowRoot.adoptedStyleSheets,...o,s],n.shadowRoot?.querySelector(":host > style")?.remove()),a(n),n.setAttribute("hydrated","")}),i?.(n.getComponentRef())}async requireUiComponent(t,n){this.loadCricalResources();let i=await this.loadTemplate(t),s=await this.insertComponent({name:t,template:i,refElement:n?.refElement??document.body,position:"beforeend",singleInstance:n?.singleInstance??!1});return s.shadowRoot&&!s.hasAttribute("hydrated")?Promise.all([this.loadNonCriticalResources(),this.loadLocale(),this.importScript(t)]).then(([{bundleCssStylesheet:o,customCssStylesheets:a},,{hydrate:l}])=>{s.shadowRoot&&o&&(s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,...a,o],s.shadowRoot?.querySelector(":host > style")?.remove()),l(s),s.setAttribute("hydrated",""),n?.onHydrated?.(s.getComponentRef())}):s.hasAttribute("hydrated")&&n?.onHydrated?.(s.getComponentRef()),s}async loadTemplate(t){let n=`${this.swishApp.options.ui.baseUrl}/ui@${De}/${t}.html`;if(this._templatePromises.has(n))return this._templatePromises.get(n);let i=fetch(n).then(s=>s.text());return this._templatePromises.set(n,i),i}async importScript(t){let n=`${this.swishApp.options.ui.baseUrl}/ui@${De}/${t}.js`;if(this._importPromises.has(n))return this._importPromises.get(n);let i=import(n);return this._importPromises.set(n,i),i}async loadLocale(){if(this._loadLocalePromise)return this._loadLocalePromise;let t=this.swishApp.storefrontContext.localization.language.toLowerCase();return this._loadLocalePromise=this.swishApp.i18n.loadLocale(t),this._loadLocalePromise}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let t=`${this.swishApp.options.ui.baseUrl}/ui@${De}/theme.css`,n=await fetch(t).then(o=>o.text()),i=new CSSStyleSheet;i.replaceSync(n);let s=Ip(this.swishApp.options.ui.design);return Object.entries(s).forEach(([o,a])=>{i.cssRules[0].cssRules[0].style.setProperty(o,a)}),{themeVariablesStylesheet:i}})(),this._loadCricalResourcesPromise)}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let t=`${this.swishApp.options.ui.baseUrl}/ui@${De}/bundle.css`,n=r(o=>{let a=new CSSStyleSheet;return a.replaceSync(o),a},"createCssStylesheet"),[i,...s]=await Promise.all([fetch(t).then(o=>o.text()).then(n),...this.swishApp.options.ui.css.map(async o=>o instanceof URL?n(await fetch(o).then(a=>a.text())):n(o))]);return{bundleCssStylesheet:i,customCssStylesheets:s}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:t,template:n,position:i,refElement:s,singleInstance:o}){if(o&&this.queryComponent(t))return this.queryComponent(t);let{themeVariablesStylesheet:a}=await this.loadCricalResources(),l=o?0:++this.elementId;s.insertAdjacentHTML(i,n.replace(' shadowrootmode="open"',"").replace(`ref="${t}"`,`ref="${t}" instance="${l}"`));let c=this.queryComponent(t,l);if(!c)throw new Error(`Element ${t} not found in DOM`);return o&&c.setAttribute("swish-singleton",""),c.shadowRoot&&(c.shadowRoot.adoptedStyleSheets=[a]),c}queryComponent(t,n=0){let i=`swish-ui[ref="${t}"][instance="${n}"]`;return document.querySelector(i)}lockScroll(){this.scrollLockRefCount++,this.scrollLockRefCount===1&&(this.scrollPositionBeforeLock=window.scrollY,this.scrollLockStyleSheet||(this.scrollLockStyleSheet=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,this.scrollLockStyleSheet]),this.scrollLockStyleSheet.replaceSync(`
|
|
270
270
|
html[swish-locked] body {
|
|
271
271
|
overflow: hidden;
|
|
272
272
|
position: fixed;
|
|
@@ -274,4 +274,4 @@ Values:
|
|
|
274
274
|
left: 0px;
|
|
275
275
|
right: 0px;
|
|
276
276
|
}
|
|
277
|
-
`),document.documentElement.setAttribute("swish-locked",""))}unlockScroll(){this.scrollLockRefCount>0&&this.scrollLockRefCount--,this.scrollLockRefCount===0&&(this.scrollLockStyleSheet&&this.scrollLockStyleSheet.replaceSync(""),window.scrollTo({top:this.scrollPositionBeforeLock,behavior:"instant"}),this.scrollPositionBeforeLock=0,document.documentElement.removeAttribute("swish-locked"))}};function
|
|
277
|
+
`),document.documentElement.setAttribute("swish-locked",""))}unlockScroll(){this.scrollLockRefCount>0&&this.scrollLockRefCount--,this.scrollLockRefCount===0&&(this.scrollLockStyleSheet&&this.scrollLockStyleSheet.replaceSync(""),window.scrollTo({top:this.scrollPositionBeforeLock,behavior:"instant"}),this.scrollPositionBeforeLock=0,document.documentElement.removeAttribute("swish-locked"))}};function Ip(e){if(!e)return{};let t={},n=r(i=>{Object.entries(i).forEach(([s,o])=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o)){n(o);return}if(typeof o=="string"||typeof o=="number"){let a=s.startsWith("--")?s:`--swish-theme-${Sp(s)}`;t[a]=xp(s,o)}}})},"walk");return n(e),t}r(Ip,"flattenDesignTokens");function Sp(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Sp,"toKebabCase");function xp(e,t){return typeof t=="number"&&!Cp(e)?`${t}px`:String(t)}r(xp,"formatDesignValue");function Cp(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("letterspacing")||t.includes("lineheight")}r(Cp,"isNonPxValue");var Ep=typeof HTMLElement<"u"?HTMLElement:class{},Vn=class extends Ep{constructor(){super();this.getComponentRef=r(()=>this.componentRef,"getComponentRef");this.setComponentRef=r(n=>{this.componentRef=n},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let n=this.querySelector("template");n&&this.shadowRoot&&(this.shadowRoot.appendChild(n.content),n.remove())}static{r(this,"SwishUiElement")}connectedCallback(){this.dispatchEvent(new CustomEvent("connected"))}};var De="0.131.0",NS=`https://swish.app/cdn/sdk@${De}/swish.js`,US=r(async e=>{if(globalThis.window===void 0)throw new Error("Swish is not supported in this environment");if(globalThis.window.swish)return globalThis.window.swish;let t=Qs(e),n=new Yi(t);return globalThis.window.swish=n,document.dispatchEvent(new Event("swish-ready")),n.api.initAuth().then(()=>{typeof globalThis.window.Shopify?.analytics?.publish=="function"&&globalThis.window.Shopify.analytics.publish("swish-ready",{market:t.context.localization.market,country:t.context.localization.country,language:t.context.localization.language,rootUrl:t.context.routes.rootUrl,preRelease:De==="unstable"})}),n},"createSwish"),Yi=class{constructor(t){this._mountedPlacements=[];this.ui={createElement:r((t,n)=>this.swishUi.createElement(t,n),"createElement")};this.utils={copyToClipboard:yt,createShareUrl:r(t=>mt(this,t),"createShareUrl")};this.state={itemContext:Tr(this),itemContextFromIds:Ar,itemState:Or(this),itemCount:_r(this),swishQuery:Mr(this),effect:ae,signal:F,computed:he};this.swishOptions=t,this.events=new _t,this._i18n=is(`${t.ui.baseUrl}/i18n@${De}`,t.translations),this.swishApiPublisher=new Un(this.events);let n=De;this.swishApi=new Nn({responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.context,this.events,n,this.swishOptions.auth.tokenUrl),this.ajaxApiPublisher=new Et(this.events),this.ajaxApi=new Ct({storeDomain:this.swishOptions.storefront.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new qn(this.swishOptions.storefront,this.swishOptions.context,this.swishOptions.metafields),this.swishUi=new $n(this),this.query=Pr({events:this.events,cacheBuster:De,customerId:this.swishOptions.context.customer.id,storeDomain:this.swishOptions.context.myshopifyDomain}),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",Vn),this.intents=new gn(this,this.swishUi),qr(this),this._mountedPlacements=this.swishOptions.placements.map(i=>{let s=Yn(this,i);return s.mount(),{spec:i,...s}})}static{r(this,"SwishApp")}get options(){return this.swishOptions}get storefrontContext(){return this.swishOptions.context}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get i18n(){return this._i18n}get shopUrl(){return`https://${this.swishOptions.storefront.storeDomain}`}get dom(){return{createElementLocator:ke,createLocationObserver:Ze,createPlacement:r(t=>Yn(this,t),"createPlacement"),placements:this._mountedPlacements}}};export{De as VERSION,mt as buildShareListUrl,yt as copyToClipboard,US as createSwish,An as getSwishQueryStorageKey,NS as swishSdkUrl};
|