@swishapp/sdk 0.138.0 → 0.139.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/swish.js CHANGED
@@ -1,18 +1,18 @@
1
- var Wo=Object.create;var Yn=Object.defineProperty;var Xo=Object.getOwnPropertyDescriptor;var Jo=Object.getOwnPropertyNames;var Yo=Object.getPrototypeOf,Zo=Object.prototype.hasOwnProperty;var r=(e,t)=>Yn(e,"name",{value:t,configurable:!0});var ea=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ta=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Jo(t))!Zo.call(e,s)&&s!==n&&Yn(e,s,{get:()=>t[s],enumerable:!(i=Xo(t,s))||i.enumerable});return e};var na=(e,t,n)=>(n=e!=null?Wo(Yo(e)):{},ta(t||!e||!e.__esModule?Yn(n,"default",{value:e,enumerable:!0}):n,e));var Ho=ea((DS,$o)=>{"use strict";var Bp=(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=Vp(i),this._batchScheduleFn=$p(i),this._cacheKeyFn=Hp(i),this._cacheMap=Qp(i),this._batch=null,this.name=Gp(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=jp(this),o=this._cacheMap,a;if(o){a=this._cacheKeyFn(i);var c=o.get(a);if(c){var l=s.cacheHits||(s.cacheHits=[]);return new Promise(function(p){l.push(function(){p(c)})})}}s.keys.push(i);var d=new Promise(function(p,f){s.callbacks.push({resolve:p,reject:f})});return o&&o.set(a,d),d},"load"),t.loadMany=r(function(i){if(!Vo(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 c;s instanceof Error?(c=Promise.reject(s),c.catch(function(){})):c=Promise.resolve(s),o.set(a,c)}}return this},"prime"),e})(),Np=typeof process=="object"&&typeof process.nextTick=="function"?function(e){ns||(ns=Promise.resolve()),ns.then(function(){process.nextTick(e)})}:typeof setImmediate=="function"?function(e){setImmediate(e)}:function(e){setTimeout(e)},ns;function jp(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(){Up(e,n)}),n}r(jp,"getCurrentBatch");function Up(e,t){if(t.hasDispatched=!0,t.keys.length===0){ss(t);return}var n;try{n=e._batchLoadFn(t.keys)}catch(i){return is(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 is(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(!Vo(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."+(`
1
+ var Xo=Object.create;var Yn=Object.defineProperty;var Jo=Object.getOwnPropertyDescriptor;var Yo=Object.getOwnPropertyNames;var Zo=Object.getPrototypeOf,ea=Object.prototype.hasOwnProperty;var r=(e,t)=>Yn(e,"name",{value:t,configurable:!0});var ta=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var na=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Yo(t))!ea.call(e,s)&&s!==n&&Yn(e,s,{get:()=>t[s],enumerable:!(i=Jo(t,s))||i.enumerable});return e};var ia=(e,t,n)=>(n=e!=null?Xo(Zo(e)):{},na(t||!e||!e.__esModule?Yn(n,"default",{value:e,enumerable:!0}):n,e));var Qo=ta((MS,Ho)=>{"use strict";var Np=(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=$p(i),this._batchScheduleFn=Hp(i),this._cacheKeyFn=Qp(i),this._cacheMap=Gp(i),this._batch=null,this.name=zp(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=Up(this),o=this._cacheMap,a;if(o){a=this._cacheKeyFn(i);var c=o.get(a);if(c){var l=s.cacheHits||(s.cacheHits=[]);return new Promise(function(p){l.push(function(){p(c)})})}}s.keys.push(i);var d=new Promise(function(p,f){s.callbacks.push({resolve:p,reject:f})});return o&&o.set(a,d),d},"load"),t.loadMany=r(function(i){if(!$o(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 c;s instanceof Error?(c=Promise.reject(s),c.catch(function(){})):c=Promise.resolve(s),o.set(a,c)}}return this},"prime"),e})(),jp=typeof process=="object"&&typeof process.nextTick=="function"?function(e){is||(is=Promise.resolve()),is.then(function(){process.nextTick(e)})}:typeof setImmediate=="function"?function(e){setImmediate(e)}:function(e){setTimeout(e)},is;function Up(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(){Vp(e,n)}),n}r(Up,"getCurrentBatch");function Vp(e,t){if(t.hasDispatched=!0,t.keys.length===0){rs(t);return}var n;try{n=e._batchLoadFn(t.keys)}catch(i){return ss(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 ss(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(!$o(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)));ss(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){is(e,t,i)})}r(Up,"dispatchBatch");function is(e,t,n){ss(t);for(var i=0;i<t.keys.length;i++)e.clear(t.keys[i]),t.callbacks[i].reject(n)}r(is,"failedDispatch");function ss(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}r(ss,"resolveCacheHits");function Vp(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(Vp,"getValidMaxBatchSize");function $p(e){var t=e&&e.batchScheduleFn;if(t===void 0)return Np;if(typeof t!="function")throw new TypeError("batchScheduleFn must be a function: "+t);return t}r($p,"getValidBatchScheduleFn");function Hp(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(Hp,"getValidCacheKeyFn");function Qp(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(Qp,"getValidCacheMap");function Gp(e){return e&&e.name?e.name:null}r(Gp,"getValidName");function Vo(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(Vo,"isArrayLike");$o.exports=Bp});function cs(e,t="",n=new Map){for(let[i,s]of Object.entries(e)){let o=t?`${t}.${i}`:i;typeof s=="object"&&s!==null?cs(s,o,n):typeof s=="string"&&n.set(o,s)}return n}r(cs,"c");var ia=new Set(["en","de","fi","ru","sv","pl"]),rt="en";function ls(e,t){return t?.count===void 0?e:t.count===1?`${e}One`:`${e}Other`}r(ls,"d");function as(e,t,n){t=ls(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(as,"g");function us(e,t){let n=null;async function i(o){let a=await import(`${e}/locales/${o.toLowerCase()}.js`);return cs(a.default)}r(i,"a");function s(o,a){return n?n.has(ls(o,a))?{status:"ready",value:as(n,o,a),key:o}:{status:"missing",value:as(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;ia.has(o)||(console.warn(`[swish] Unsupported language "${o}", falling back to "${rt}".`),a=rt);let c;try{c=await i(a)}catch(l){if(console.warn(`[swish-i18n] Failed to load locale "${a}".`,l),a!==rt)try{c=await i(rt)}catch{console.warn(`[swish] Failed to load fallback locale "${rt}".`);return}else return}if(t?.[a])for(let[l,d]of Object.entries(t[a]))d!==void 0&&c.set(l,d);n=c}}}r(us,"L");var F=r(e=>e.split("/").pop()??"","shopifyGidToId"),we=r((e,t)=>typeof t=="string"&&t.startsWith("gid://shopify/")?t:`gid://shopify/${e}/${t}`,"shopifyIdToGid"),pe=r(e=>e.toLowerCase().replace(".myshopify.com",""),"toShopName");var Te=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 c=await fetch(t,n);return c.ok&&await this.set(s,c.clone(),i??this.defaultCacheControl),c})().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),c=await crypto.subtle.digest("SHA-256",a);return`/${Array.from(new Uint8Array(c)).map(p=>p.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(),l=(Date.now()-a)/1e3,d=i+(s??0);return l>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(),l=(Date.now()-a)/1e3;return l>i&&l<=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 kt=class{static{r(this,"AjaxApiClient")}constructor(t){this.config=t;let n=pe(t.storeDomain);this.cache=new Te(`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(c=>n(c,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 fetchProduct(t){return this.request(`/products/${t}.js`)}async addToCart(t){let n={...t,items:t.items.map(i=>{let s=Number(F(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 updateCartAttributes(t){return this.request("/cart/update.js",{method:"POST",body:JSON.stringify({attributes:t})})}async clearCache(){await this.cache.clear()}};var At=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-change"||i==="cart-update"){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){if(!Array.isArray(t.items))return[];if(this.previousCart){let i=new Set(t.items.map(s=>s.key));return this.previousCart.items.filter(s=>!i.has(s.key)).map(s=>this.toCartChangeItem(s))}let n=new Set(t.items.map(i=>i.variant_id));return(t.items_removed??[]).filter(i=>!n.has(i.variant_id))}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 Zn="_swish",Pt=class{static{r(this,"CheckoutBridge")}constructor(t){this.api=t.api,this.ajax=t.ajax,this.events=t.events,this.context=t.context,this.preRelease=t.preRelease}listen(){this.api.initAuth().then(()=>this.sync()),this.events.subscribe("cart-add",()=>{this.write()}),this.events.subscribe(["cart-update","cart-change"],t=>{let n=t.detail;!n||n.item_count<=0||this.write(n.attributes?.[Zn])}),this.events.subscribe("token-update",()=>{this.sync()})}async sync(){try{let t=await this.ajax.fetchCart();if(!t||t.item_count<=0)return;await this.write(t.attributes?.[Zn])}catch(t){console.warn("Failed to sync Swish checkout bridge",t)}}composeValue(){let t=this.api.getAuthToken();if(!t)return null;let{country:n,language:i}=this.context.localization;return JSON.stringify({t,c:n,l:i,pr:this.preRelease,r:this.context.routes.rootUrl})}async write(t){let n=this.composeValue();if(!(!n||t===n))try{await this.ajax.updateCartAttributes({[Zn]:n})}catch(i){console.warn("Failed to write Swish checkout bridge attribute",i)}}};var ps="swish:customiser:mounted",Tt="swish-customiser",sa="https://swish.app/cdn",ra=r(e=>{try{return window.sessionStorage?.getItem(e)==="1"}catch{return!1}},"readFlag"),oa=r((e,t)=>{try{t?window.sessionStorage?.setItem(e,"1"):window.sessionStorage?.removeItem(e)}catch{}},"writeFlag"),hs=r(()=>ra(ps),"readSticky"),ei=r(e=>oa(ps,e),"writeSticky"),aa=r(()=>{let e=new URLSearchParams(window.location.search);if(!e.has(Tt))return;e.delete(Tt);let t=e.toString(),n=window.location.pathname+(t?`?${t}`:"")+window.location.hash;window.history.replaceState(null,"",n)},"scrubLaunchParam"),ca=r(()=>{let e=window.Shopify?.theme?.id;return e===void 0?void 0:String(e)},"readThemeId"),fs=r(()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).has(Tt)||hs(),"isCustomiserRequested"),la=r(e=>`${e.endsWith("/")?e.slice(0,-1):e}/customiser@${he}/`,"customiserDirUrl"),ms=r((e,t={})=>{if(typeof window>"u")return;let i=new URLSearchParams(window.location.search).has(Tt),s=hs();if(!i&&!s)return;i&&(aa(),ei(!0));let o=la(t.baseUrl??sa);import(`${o}sdk.js`).then(a=>{a.mountCustomiser(e,{shop:t.shop,themeId:ca(),appUrl:o,onClose:r(()=>{ei(!1),window.location.reload()},"onClose")})}).catch(a=>{console.error("[swish] failed to load customiser SDK bundle",a),ei(!1),window.location.reload()})},"loadCustomiserIfRequested");function ua(){let e=document.body||document.documentElement;return e?Promise.resolve(e):new Promise(t=>{window.addEventListener("DOMContentLoaded",()=>t(e))})}r(ua,"waitForDOM");function ot({onElementFound:e,selector:t,observerOptions:n,mustMatch:i}){let s=new WeakSet,o=new MutationObserver(d=>{let p=!1;for(let f of d)if(f.addedNodes.length>0){p=!0;break}p&&a()}),a=r(()=>{document.querySelectorAll(t).forEach(d=>{s.has(d)||(s.add(d),i?.(d)!==!1&&c(d))})},"locateElements"),c=r(d=>{if(!n){e(d);return}let p=new IntersectionObserver(f=>{for(let h of f)h.isIntersecting&&(p.disconnect(),e(d))},n);p.observe(d)},"observeElement");return r(async()=>{let d=await ua();a(),o.observe(d,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}r(ot,"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 Ke(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(Ke,"findNearestElement");function ys({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(ys,"createHrefObserver");var da=Symbol.for("preact-signals");function _t(){if(De>1)De--;else{var e,t=!1;for((function(){var s=Lt;for(Lt=void 0;s!==void 0;)s.S.v===s.v&&(s.S.i=s.i),s=s.o})();at!==void 0;){var n=at;for(at=void 0,Dt++;n!==void 0;){var i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ws(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=i}}if(Dt=0,De--,t)throw e}}r(_t,"t");function ee(e){if(De>0)return e();ti=++pa,De++;try{return e()}finally{_t()}}r(ee,"n");var B=void 0;function ni(e){var t=B;B=void 0;try{return e()}finally{B=t}}r(ni,"o");var vs,at=void 0,De=0,Dt=0,pa=0,ti=0,Lt=void 0,Ot=0;function gs(e){if(B!==void 0){var t=e.n;if(t===void 0||t.t!==B)return t={i:0,S:e,p:B.s,n:void 0,t:B,e:void 0,x:void 0,r:t},B.s!==void 0&&(B.s.n=t),B.s=t,e.n=t,32&B.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=B.s,t.n=void 0,B.s.n=t,B.s=t),t}}r(gs,"a");function te(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(te,"l");te.prototype.brand=da;te.prototype.h=function(){return!0};te.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:ni(function(){var i;(i=t.W)==null||i.call(t)}))};te.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&&ni(function(){var s;(s=t.Z)==null||s.call(t)}))}};te.prototype.subscribe=function(e){var t=this;return X(function(){var n=t.value,i=B;B=void 0;try{e(n)}finally{B=i}},{name:"sub"})};te.prototype.valueOf=function(){return this.value};te.prototype.toString=function(){return this.value+""};te.prototype.toJSON=function(){return this.value};te.prototype.peek=function(){var e=this;return ni(function(){return e.value})};Object.defineProperty(te.prototype,"value",{get:r(function(){var e=gs(this);return e!==void 0&&(e.i=this.i),this.v},"get"),set:r(function(e){if(e!==this.v){if(Dt>100)throw new Error("Cycle detected");(function(n){De!==0&&Dt===0&&n.l!==ti&&(n.l=ti,Lt={S:n,v:n.v,i:n.i,o:Lt})})(this),this.v=e,this.i++,Ot++,De++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{_t()}}},"set")});function L(e,t){return new te(e,t)}r(L,"y");function ws(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(ws,"w");function bs(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(bs,"_");function Is(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(Is,"b");function qe(e,t){te.call(this,void 0),this.x=e,this.s=void 0,this.g=Ot-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(qe,"p");qe.prototype=new te;qe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ot))return!0;if(this.g=Ot,this.f|=1,this.i>0&&!ws(this))return this.f&=-2,!0;var e=B;try{bs(this),B=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 B=e,Is(this),this.f&=-2,!0};qe.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)}te.prototype.S.call(this,e)};qe.prototype.U=function(e){if(this.t!==void 0&&(te.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)}};qe.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(qe.prototype,"value",{get:r(function(){if(1&this.f)throw new Error("Cycle detected");var e=gs(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v},"get")});function re(e,t){return new qe(e,t)}r(re,"g");function Ss(e){var t=e.m;if(e.m=void 0,typeof t=="function"){De++;var n=B;B=void 0;try{t()}catch(i){throw e.f&=-2,e.f|=8,ii(e),i}finally{B=n,_t()}}}r(Ss,"S");function ii(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ss(e)}r(ii,"m");function ha(e){if(B!==this)throw new Error("Out-of-order effect");Is(this),B=e,this.f&=-2,8&this.f&&ii(this),_t()}r(ha,"x");function We(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,vs&&vs.push(this)}r(We,"E");We.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.m=t)}finally{e()}};We.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ss(this),bs(this),De++;var e=B;return B=this,ha.bind(this,e)};We.prototype.N=function(){2&this.f||(this.f|=2,this.u=at,at=this)};We.prototype.d=function(){this.f|=8,1&this.f||ii(this)};We.prototype.dispose=function(){this.d()};function X(e,t){var n=new We(e,t);try{n.c()}catch(s){throw n.d(),s}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}r(X,"j");var fa="swish-save, swish-drawer";function xs(e,t){return e.closest(fa)===t}r(xs,"belongsToHost");function Mt(e,t){return X(()=>{let n=t();e.querySelectorAll("[data-swish-when]").forEach(s=>{if(!xs(s,e))return;let a=!(s.dataset.swishWhen??"").split(",").map(c=>c.trim()).includes(n);s.hidden!==a&&(s.hidden=a)})})}r(Mt,"bindWhen");function Cs(e,t,n){e.hidden&&(e.hidden=!1);let i=`[data-swish-bind="${t}"]`;return X(()=>{let s=n(),o=String(s);e.querySelectorAll(i).forEach(c=>{xs(c,e)&&c.textContent!==o&&(c.textContent=o)})})}r(Cs,"bindValue");var ma=["home","saves","lists","orders","notifications","profile"],ya=["view"],va=typeof HTMLElement<"u"?HTMLElement:class{},ct=class extends va{constructor(){super(...arguments);this.disposers=[];this.deferredReady=null;this.clickHandler=r(()=>{let n=Fe();if(!n)return;let i=this.resolveView();n.intents.invoke(`view:${i}`)},"clickHandler")}static{r(this,"SwishDrawerElement")}static get observedAttributes(){return[...ya]}connectedCallback(){if(!this.isConnected)return;let n=Fe();if(!n){if(this.deferredReady)return;let i=r(()=>{this.deferredReady=null,this.connectedCallback()},"handler");this.deferredReady=i,document.addEventListener("swish-ready",i,{once:!0});return}this.bind(n),this.addEventListener("click",this.clickHandler)}disconnectedCallback(){this.deferredReady&&(document.removeEventListener("swish-ready",this.deferredReady),this.deferredReady=null),this.removeEventListener("click",this.clickHandler),this.dispose()}bind(n){let i=n.state.itemCount(),s=n.state.effect(()=>{let{count:c,loading:l}=i.value;this.setAttribute("state",c>0?"has-saves":"empty"),!l&&!this.hasAttribute("ready")&&this.toggleAttribute("ready",!0)}),o=Cs(this,"count",()=>i.value.count),a=Mt(this,()=>i.value.count>0?"has-saves":"empty");this.disposers.push(s,o,a)}dispose(){for(;this.disposers.length;)this.disposers.pop()?.()}resolveView(){let n=this.getAttribute("view");return n&&ma.includes(n)?n:(n&&console.warn(`[swish] <swish-drawer> view="${n}" is not a recognized view. Falling back to "home".`),"home")}};var ga=["product","variant","context","match"],wa="a[href*='/products/']";function ba(e){if(e==="variant"||e==="product"||e==="auto")return e}r(ba,"parseMatch");function Ia(e){return e==="product-card"?"product":"auto"}r(Ia,"defaultMatchForContext");var Sa=typeof HTMLElement<"u"?HTMLElement:class{},lt=class extends Sa{constructor(){super(...arguments);this.disposers=[];this.state=null;this.deferredReady=null;this.clickHandler=r(n=>{n.stopPropagation(),this.state?.toggle()},"clickHandler")}static{r(this,"SwishSaveElement")}static get observedAttributes(){return[...ga]}connectedCallback(){if(!this.isConnected)return;let n=Fe();if(!n){if(this.deferredReady)return;let i=r(()=>{this.deferredReady=null,this.connectedCallback()},"handler");this.deferredReady=i,document.addEventListener("swish-ready",i,{once:!0});return}this.bind(n),this.addEventListener("click",this.clickHandler)}attributeChangedCallback(n,i,s){i===s||!this.isConnected||!this.state||this.rebind()}disconnectedCallback(){this.deferredReady&&(document.removeEventListener("swish-ready",this.deferredReady),this.deferredReady=null),this.removeEventListener("click",this.clickHandler),this.dispose()}bind(n){let i=this.resolveContext(n),s=ba(this.getAttribute("match"))??Ia(this.getAttribute("context"));this.state=n.state.itemState(i,{match:s});let o=n.state.effect(()=>{let c=this.state?.value;c&&(this.setAttribute("state",c.status),this.setAttribute("aria-pressed",String(c.saved)),!c.loading&&!this.hasAttribute("ready")&&this.toggleAttribute("ready",!0))}),a=Mt(this,()=>this.state?.value.status??"unsaved");this.disposers.push(()=>this.state?.dispose()),this.disposers.push(o),this.disposers.push(a)}rebind(){let n=Fe();n&&(this.dispose(),this.bind(n))}dispose(){for(;this.disposers.length;)this.disposers.pop()?.();this.state=null}resolveContext(n){let i=this.getAttribute("product"),s=this.getAttribute("variant");if(i)return n.state.itemContextFromIds({productId:i,variantId:s});let o=this.getAttribute("context");if(o==="pdp")return n.state.itemContext(window.location);if(o==="product-card"){let a=Ke(this,wa);if(a)return n.state.itemContext(a)}return n.state.itemContext(this)}};var Es=null;function si(e){Es=e,!(typeof customElements>"u")&&(customElements.get("swish-save")||customElements.define("swish-save",lt),customElements.get("swish-drawer")||customElements.define("swish-drawer",ct))}r(si,"initElements");function Fe(){return Es}r(Fe,"getSwish");var qt=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 xa=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,ut=r(e=>{let t=e.match(xa);return t?{productHandle:decodeURIComponent(t[1]),variantId:t[2]}:null},"parseProductUrl"),Rs=r(({source:e,onProductUrlChange:t})=>{let n=r(i=>{let s=ut(i);s?.productHandle&&t(s)},"handleChange");if(e instanceof HTMLAnchorElement)return ys({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 Ft,Ca={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function ri(e){return!e&&!Ft?Ca:{lang:e?.lang??Ft?.lang,message:e?.message,abortEarly:e?.abortEarly??Ft?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Ft?.abortPipeEarly}}r(ri,"getGlobalConfig");var Ea;function Ra(e){return Ea?.get(e)}r(Ra,"getGlobalMessage");var ka;function Aa(e){return ka?.get(e)}r(Aa,"getSchemaMessage");var Pa;function Ta(e,t){return Pa?.get(e)?.get(t)}r(Ta,"getSpecificMessage");function dt(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(dt,"_stringify");function Y(e,t,n,i,s){let o=s&&"input"in s?s.input:n.value,a=s?.expected??e.expects??null,c=s?.received??dt(o),l={kind:e.kind,type:e.type,input:o,expected:a,received:c,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:s?.path,issues:s?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},d=e.kind==="schema",p=s?.message??e.message??Ta(e.reference,l.lang)??(d?Aa(l.lang):null)??i.message??Ra(l.lang);p!==void 0&&(l.message=typeof p=="function"?p(l):p),d&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}r(Y,"_addIssue");var ks=new WeakMap;function oe(e){let t=ks.get(e);return t||(t={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},ri())}},ks.set(e,t)),t}r(oe,"_getStandardProps");function Da(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}r(Da,"_isValidObjectKey");function oi(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}r(oi,"_joinExpects");var La=class extends Error{static{r(this,"ValiError")}constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ai(e){return{kind:"validation",type:"integer",reference:ai,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&Y(this,"integer",t,n),t}}}r(ai,"integer");function pt(e,t){return{kind:"validation",type:"min_length",reference:pt,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,i){return n.typed&&n.value.length<this.requirement&&Y(this,"length",n,i,{received:`${n.value.length}`}),n}}}r(pt,"minLength");function fe(e,t){return{kind:"validation",type:"min_value",reference:fe,async:!1,expects:`>=${e instanceof Date?e.toJSON():dt(e)}`,requirement:e,message:t,"~run"(n,i){return n.typed&&!(n.value>=this.requirement)&&Y(this,"value",n,i,{received:n.value instanceof Date?n.value.toJSON():dt(n.value)}),n}}}r(fe,"minValue");function N(e){return{kind:"transformation",type:"transform",reference:N,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}r(N,"transform");var Oa={abortEarly:!0};function _a(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}r(_a,"getFallback");function Ps(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}r(Ps,"getDefault");function H(e,t){return{kind:"schema",type:"array",reference:H,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return oe(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],c=this.item["~run"]({value:a},i);if(c.issues){let l={type:"array",origin:"value",input:s,key:o,value:a};for(let d of c.issues)d.path?d.path.unshift(l):d.path=[l],n.issues?.push(d);if(n.issues||(n.issues=c.issues),i.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value.push(c.value)}}else Y(this,"type",n,i);return n}}}r(H,"array");function C(e){return{kind:"schema",type:"boolean",reference:C,expects:"boolean",async:!1,message:e,get"~standard"(){return oe(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:Y(this,"type",t,n),t}}}r(C,"boolean");function ci(e,t){return{kind:"schema",type:"instance",reference:ci,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return oe(this)},"~run"(n,i){return n.value instanceof this.class?n.typed=!0:Y(this,"type",n,i),n}}}r(ci,"instance");function V(e,t){return{kind:"schema",type:"literal",reference:V,expects:dt(e),async:!1,literal:e,message:t,get"~standard"(){return oe(this)},"~run"(n,i){return n.value===this.literal?n.typed=!0:Y(this,"type",n,i),n}}}r(V,"literal");function A(e){return{kind:"schema",type:"number",reference:A,expects:"number",async:!1,message:e,get"~standard"(){return oe(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:Y(this,"type",t,n),t}}}r(A,"number");function b(e,t){return{kind:"schema",type:"object",reference:b,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return oe(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 c=o in s?s[o]:Ps(a),l=a["~run"]({value:c},i);if(l.issues){let d={type:"object",origin:"value",input:s,key:o,value:c};for(let p of l.issues)p.path?p.path.unshift(d):p.path=[d],n.issues?.push(p);if(n.issues||(n.issues=l.issues),i.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value[o]=l.value}else if(a.fallback!==void 0)n.value[o]=_a(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(Y(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 Y(this,"type",n,i);return n}}}r(b,"object");function m(e,t){return{kind:"schema",type:"optional",reference:m,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return oe(this)},"~run"(n,i){return n.value===void 0&&(this.default!==void 0&&(n.value=Ps(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,i)}}}r(m,"optional");function ne(e,t){return{kind:"schema",type:"picklist",reference:ne,expects:oi(e.map(dt),"|"),async:!1,options:e,message:t,get"~standard"(){return oe(this)},"~run"(n,i){return this.options.includes(n.value)?n.typed=!0:Y(this,"type",n,i),n}}}r(ne,"picklist");function Z(e,t,n){return{kind:"schema",type:"record",reference:Z,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return oe(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){i.typed=!0,i.value={};for(let a in o)if(Da(o,a)){let c=o[a],l=this.key["~run"]({value:a},s);if(l.issues){let p={type:"object",origin:"key",input:o,key:a,value:c};for(let f of l.issues)f.path=[p],i.issues?.push(f);if(i.issues||(i.issues=l.issues),s.abortEarly){i.typed=!1;break}}let d=this.value["~run"]({value:c},s);if(d.issues){let p={type:"object",origin:"value",input:o,key:a,value:c};for(let f of d.issues)f.path?f.path.unshift(p):f.path=[p],i.issues?.push(f);if(i.issues||(i.issues=d.issues),s.abortEarly){i.typed=!1;break}}(!l.typed||!d.typed)&&(i.typed=!1),l.typed&&(i.value[l.value]=d.value)}}else Y(this,"type",i,s);return i}}}r(Z,"record");function x(e){return{kind:"schema",type:"string",reference:x,expects:"string",async:!1,message:e,get"~standard"(){return oe(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:Y(this,"type",t,n),t}}}r(x,"string");function As(e){let t;if(e)for(let n of e)if(t)for(let i of n.issues)t.push(i);else t=n.issues;return t}r(As,"_subIssues");function U(e,t){return{kind:"schema",type:"union",reference:U,expects:oi(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return oe(this)},"~run"(n,i){let s,o,a;for(let c of this.options){let l=c["~run"]({value:n.value},i);if(l.typed)if(l.issues)o?o.push(l):o=[l];else{s=l;break}else a?a.push(l):a=[l]}if(s)return s;if(o){if(o.length===1)return o[0];Y(this,"type",n,i,{issues:As(o)}),n.typed=!0}else{if(a?.length===1)return a[0];Y(this,"type",n,i,{issues:As(a)})}return n}}}r(U,"union");function ie(){return{kind:"schema",type:"unknown",reference:ie,expects:"unknown",async:!1,get"~standard"(){return oe(this)},"~run"(e){return e.typed=!0,e}}}r(ie,"unknown");function Be(e,t,n){return{kind:"schema",type:"variant",reference:Be,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return oe(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){let a,c=0,l=this.key,d=[],p=r((f,h)=>{for(let y of f.options){if(y.type==="variant")p(y,new Set(h).add(y.key));else{let g=!0,v=0;for(let I of h){let S=y.entries[I];if(I in o?S["~run"]({typed:!1,value:o[I]},Oa).issues:S.type!=="exact_optional"&&S.type!=="optional"&&S.type!=="nullish"){g=!1,l!==I&&(c<v||c===v&&I in o&&!(l in o))&&(c=v,l=I,d=[]),l===I&&d.push(y.entries[I].expects);break}v++}if(g){let I=y["~run"]({value:o},s);(!a||!a.typed&&I.typed)&&(a=I)}}if(a&&!a.issues)break}},"parseOptions");if(p(this,new Set([this.key])),a)return a;Y(this,"type",i,s,{input:o[l],expected:oi(d,"|"),path:[{type:"object",origin:"value",input:o,key:l,value:o[l]}]})}else Y(this,"type",i,s);return i}}}r(Be,"variant");function Ts(e,t,n){let i=e["~run"]({value:t},ri(n));if(i.issues)throw new La(i.issues);return i.value}r(Ts,"parse");function T(...e){return{...e[0],pipe:e,get"~standard"(){return oe(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(T,"pipe");function _(e,t,n){let i=e["~run"]({value:t},ri(n));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}r(_,"safeParse");var Xe=T(U([T(x(),N(F)),A()]),N(e=>Number(e)),T(A(),fe(1)));var E=class{constructor(t,n,i,s){this.swish=t;this.ui=n;this.eventBus=i;this.options=s}static{r(this,"IntentHandler")}};var Ma=U([b({variantId:Xe,quantity:m(T(A(),fe(1)),1)}),b({items:T(H(b({variantId:Xe,quantity:m(T(A(),fe(1)),1)})),pt(1))})]),Bt=class extends E{static{r(this,"CreateCartLineHandler")}async invoke(t){let n=_(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 Nt=class extends E{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=b({listId:x()}),jt=class extends E{static{r(this,"DeleteListHandler")}async invoke(t){let n=_(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 Fa=b({itemId:x()}),Ut=class extends E{static{r(this,"EditItemListsHandler")}async invoke(t){let n=_(Fa,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:c}=s.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:a,variant:c}}}return{intent:"unsave:item",code:"ok",data:{itemId:s.data.data.itemId}}}};var Ba=b({itemId:T(x()),productId:T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A()),variantId:m(T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A()))}),Vt=class extends E{static{r(this,"EditItemVariantHandler")}async invoke(t){let n=_(Ba,t);if(!n.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:n.issues.map(h=>h.message)};let{itemId:i,productId:s,variantId:o}=n.output;if(!(!o||this.swish.options.intents.editSavedProduct.promptVariantChange)){let h=await this.swish.api.items.updateById(i,{productId:s,variantId:o});if("error"in h)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[h.error.message]};if(!h.data)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:["No item returned from API"]};let y=await this.swish.storefront.loadProduct({productId:String(s),variantId:o?String(o):void 0});if(!y.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load product data",issues:[y.errors?.message??"No product data returned from API"]};let g=y.data.product,v=y.data.variant;return{intent:"edit:item-variant",code:"ok",data:{item:h.data,product:g,variant:v}}}let c=await this.ui.showVariantSelect({itemId:i,productId:s,variantId:o});if(c.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:l,product:d,variant:p}=c.data;return{intent:"edit:item-variant",code:"ok",data:{item:l,product:d,variant:p}}}};var Na=b({listId:x(),access:ne(["public","private"])}),$t=class extends E{static{r(this,"EditListAccessHandler")}async invoke(t){let n=_(Na,t);if(!n.success)return{intent:"edit:list-access",code:"error",message:"Invalid intent data",issues:n.issues.map(c=>c.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 ja=b({listId:x()}),Ht=class extends E{static{r(this,"EditListHandler")}async invoke(t){let n=_(ja,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 Ua=b({variantId:Xe,quantity:m(T(A(),fe(1)),1)}),Va=150,$a=U([b({variantId:Xe,quantity:m(T(A(),fe(1)),1)}),b({items:T(H(Ua),pt(1))})]),Qt=class extends E{static{r(this,"InitiateCheckoutHandler")}async invoke(t){let n=_($a,t);if(!n.success)return{intent:"initiate:checkout",code:"error",message:"Invalid intent data",issues:n.issues.map(c=>c.message)};let i=n.output,o=("items"in i?i.items:[{variantId:i.variantId,quantity:i.quantity}]).map(c=>`${c.variantId}:${c.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),Va),{intent:"initiate:checkout",code:"ok",data:{checkoutUrl:a.href}}}};var Ha=b({productId:T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A()),variantId:m(T(U([T(x(),N(F)),A()]),N(Number),A()))}),Gt=class extends E{static{r(this,"InitiateQuickBuyHandler")}async invoke(t){let n=_(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,Ga=b({returnTo:x()}),zt=class extends E{static{r(this,"InitiateSignInHandler")}async invoke(t){let n=_(Ga,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 za=150,Kt=class extends E{static{r(this,"InitiateSignOutHandler")}async invoke(){return this.scheduleRedirect(),{intent:"initiate:sign-out",code:"ok",data:void 0}}scheduleRedirect(){window.setTimeout(()=>this.redirectToSignOut(),za)}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 Wt=class extends E{static{r(this,"SaveCartLineHandler")}async invoke(t){return t?.items?.length?this.options.saveCartLine.confirm?this.saveWithPrompt(t.items):this.saveWithUndo(t.items):{intent:"save:cart-line",code:"error",message:"No items to save",issues:["items array is empty or missing"]}}async saveWithPrompt(t){let n=t[0];if((await this.ui.showToast({title:"t:toast.saveForLaterTitle",text:n.title??"",image:n.image,action:{label:"t:toast.saveForLater"},variant:"full"})).code!=="ok")return{intent:"save:cart-line",code:"closed"};let{error:s}=await this.createItems(t);return s||(this.options.saveCartLine.showFeedback&&await this.ui.showToast({title:"t:toast.savedForLater",text:n.title??"",image:n.image,variant:"full"}),{intent:"save:cart-line",code:"ok",data:t})}async saveWithUndo(t){let n=this.createItems(t);if(!this.options.saveCartLine.showFeedback){let{error:d}=await n;return d??{intent:"save:cart-line",code:"ok",data:t}}let i=t[0],s=new AbortController,o=this.ui.showToast({title:"t:toast.savedForLater",text:i.title??"",image:i.image,action:{label:"t:toast.undo"},variant:"full"},{signal:s.signal}),{error:a,itemIds:c}=await n;if(a){if(s.abort(),(await o).code==="ok"){let p=await this.removeSavedItems(c);a.issues=[...a.issues??[],...p]}return a}if((await o).code==="ok"){let d=await this.removeSavedItems(c);return d.length>0?{intent:"save:cart-line",code:"error",message:"Failed to undo saved cart items",issues:d}:{intent:"save:cart-line",code:"closed"}}return{intent:"save:cart-line",code:"ok",data:t}}async removeSavedItems(t){return(await Promise.all(t.map(i=>this.swish.api.smartLists.removeItem("saved-from-cart",i)))).flatMap(i=>"error"in i?[i.error.message]:[])}async createItems(t){let n=[];for(let i of t){let s=await this.swish.api.items.create({productId:i.productId,variantId:i.variantId,quantity:i.quantity,source:"cart"});if("error"in s)return{error:{intent:"save:cart-line",code:"error",message:"Failed to save item from cart",issues:[s.error.message]},itemIds:n};if(!s.data?.id)return{error:{intent:"save:cart-line",code:"error",message:"Failed to save item from cart",issues:["API response is missing the created item id"]},itemIds:n};n.push(s.data.id)}return{itemIds:n}}};var Ka=b({productId:T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A()),variantId:m(T(U([T(x(),N(F)),A()]),N(Number),A())),quantity:m(T(A(),fe(1))),tags:m(H(x()))}),Xt=class extends E{static{r(this,"SaveItemHandler")}async invoke(t){let n=_(Ka,t);if(!n.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:n.issues.map(I=>I.message)};let{productId:i,variantId:s,quantity:o,tags:a}=n.output,c=await this.swish.storefront.loadProduct({productId:String(i),variantId:s?String(s):void 0});if(c.errors)return{intent:"save:item",code:"error",message:c.errors.message??"Failed to load product data",issues:c.errors.graphQLErrors?.map(I=>I.message)??[]};if(!c.data||!c.data.product)return{intent:"save:item",code:"error",message:"Failed to load product data",issues:["API response missing data"]};let{product:l,variant:d}=c.data,p=l.variantsCount?.count&&l.variantsCount.count>1,f=!!s,y=!(typeof this.options.saveProduct.promptVariantIfMissing=="function"?this.options.saveProduct.promptVariantIfMissing({product:l,variant:d}):this.options.saveProduct.promptVariantIfMissing)||!this.options.saveProduct.promptVariantIfPresent&&f;if(!p||y){let I=r(()=>!p&&l.selectedOrFirstAvailableVariant?Number(F(l.selectedOrFirstAvailableVariant.id)):s,"variantIdToUse"),S=await this.swish.api.items.create({productId:i,variantId:I(),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:l,variant:p?d:l.selectedOrFirstAvailableVariant}}:{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]}}let g;if(this.options.saveProduct.saveBeforeVariantPrompt){let I=await this.swish.api.items.create({productId:i,quantity:o,tags:a});"data"in I&&I.data&&(g=I.data)}let v=await this.ui.showVariantSelect({productId:i,variantId:s,itemId:g?.id});return v.code==="closed"?g?{intent:"save:item",code:"ok",data:{item:g,product:l,variant:d}}:{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:v.data}}};function ht(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(ht,"buildShareListUrl");async function ft(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(ft,"copyToClipboard");function Ds(){let e=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||e}r(Ds,"isMobileDevice");var Wa=b({listId:x()}),Jt=class extends E{static{r(this,"ShareListHandler")}async invoke(t){let n=_(Wa,t);if(!n.success)return{intent:"initiate:share",code:"error",message:"Invalid intent data",issues:n.issues.map(l=>l.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=ht(this.swish,{publicListId:i}).toString();if(Ds()&&typeof navigator.share=="function"&&(await navigator.share({title:this.swish.i18n.t("listMenu.share"),url:o}).then(()=>({ok:!0})).catch(()=>({ok:!1}))).ok)return{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"native"}};let c=await ft(o);return c.ok?{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"clipboard"}}:{intent:"initiate:share",code:"error",message:"Failed to share list",issues:c.issues}}};var rm=b({title:m(x()),text:x(),image:m(x()),action:m(b({label:x(),url:m(x())})),variant:m(ne(["compact","full"])),icon:m(x())}),Yt=class extends E{static{r(this,"ShowToastHandler")}async invoke(t){return{intent:"show:toast",code:(await this.ui.showToast(t)).code,data:void 0}}};var Xa=b({itemId:x(),delete:m(C())}),Zt=class extends E{static{r(this,"UnsaveItemHandler")}async invoke(t){let n=_(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:c,product:l,variant:d}=a.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:c,product:l,variant:d}}}if(a.data.action==="unsave"){let{itemId:c}=a.data.data;return{intent:"unsave:item",code:"ok",data:{itemId:c}}}}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 en=class extends E{static{r(this,"ViewHomeHandler")}async invoke(t){return{intent:"view:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var Ja=b({listId:x()}),tn=class extends E{static{r(this,"ViewListDetailPageMenuHandler")}async invoke(t){let n=_(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=b({listId:x(),listType:m(ne(["user","smart","shared"]),"user")}),nn=class extends E{static{r(this,"ViewListHandler")}async invoke(t){let n=_(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=b({listId:x()}),sn=class extends E{static{r(this,"ViewListMenuHandler")}async invoke(t){let n=_(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 rn=class extends E{static{r(this,"ViewListsHandler")}async invoke(t){return{intent:"view:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var on=class extends E{static{r(this,"ViewNotificationsHandler")}async invoke(t){return{intent:"view:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var ec=b({orderId:T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A())}),an=class extends E{static{r(this,"ViewOrderHandler")}async invoke(t){let n=_(ec,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 tc=b({orderId:x()}),cn=class extends E{static{r(this,"ViewOrderMenuHandler")}async invoke(t){let n=_(tc,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 ln=class extends E{static{r(this,"ViewOrdersHandler")}async invoke(t){return{intent:"view:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var nc=b({productId:T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A()),variantId:m(T(U([T(x(),N(F)),A()]),N(Number),A()))}),un=class extends E{static{r(this,"ViewProductHandler")}async invoke(t){let n=_(nc,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 dn=class extends E{static{r(this,"ViewProfileHandler")}async invoke(t){return{intent:"view:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var pn=class extends E{static{r(this,"ViewSavesHandler")}async invoke(t){return{intent:"view:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var J=class{constructor(t,n,i){this.swish=t;this.ui=n;this.options=i}static{r(this,"IntentHook")}};var hn=class extends J{static{r(this,"AfterCreateCartLineHook")}async invoke(t){this.options.createCartLine.afterComplete?.(t)}};var fn=class extends J{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:"t:toast.saved",text:n.title,image:i?.image?.url??n.featuredImage?.url,action:{label:"t:toast.view"}})).complete).code==="ok"&&this.swish.intents.invoke("view:saves")}}};var mn=class extends J{static{r(this,"AfterEditListAccessHook")}async invoke(t){if(t.code!=="ok")return;let n=t.data.list.access==="public"?"t:toast.listNowPublic":"t:toast.listNowPrivate";await(await this.swish.intents.invoke("show:toast",{text:n,variant:"compact",icon:"check"})).complete}};var yn=class extends J{static{r(this,"AfterSaveCartLineHook")}async invoke(t){this.options.saveCartLine.afterComplete?.(t)}};var vn=class extends J{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:"t:toast.saved",text:i.title,image:s?.image?.url??i.featuredImage?.url,action:{label:"t:toast.addToList"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:n.id})}}};var gn=class extends J{static{r(this,"AfterShareListHook")}async invoke(t){if(t.code!=="ok")return;await(await this.swish.intents.invoke("show:toast",{variant:"compact",text:"t:toast.linkCopied",icon:"check"})).complete}};var wn=class extends J{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 Ls(e){let t=e.startsWith("#")?e.slice(1):e;return t==="swish"||t.startsWith("swish-")}r(Ls,"isSwishHash");var bn=class extends J{static{r(this,"BeforeViewHomeHook")}async invoke(){Ls(window.location.hash)||window.history.replaceState(window.history.state,"",window.location.pathname+window.location.search+"#swish")}};var In=class{constructor(t,n){this._invoking=!1;this.swish=t,this.ui=n,this.eventBus=new EventTarget,this.options=t.options.intents,this.handlers=this.initHandlers(),this.initIntentHooks(),this.initIntentWatcher(),this.initCartChangeListener()}static{r(this,"Intents")}applyPreview(t){this.options=t,this.handlers=this.initHandlers()}initHandlers(){return{"create:cart-line":new Bt(this.swish,this.ui,this.eventBus,this.options),"initiate:checkout":new Qt(this.swish,this.ui,this.eventBus,this.options),"save:item":new Xt(this.swish,this.ui,this.eventBus,this.options),"save:cart-line":new Wt(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new Zt(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new Vt(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Ut(this.swish,this.ui,this.eventBus,this.options),"create:list":new Nt(this.swish,this.ui,this.eventBus,this.options),"edit:list":new Ht(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new $t(this.swish,this.ui,this.eventBus,this.options),"delete:list":new jt(this.swish,this.ui,this.eventBus,this.options),"view:home":new en(this.swish,this.ui,this.eventBus,this.options),"initiate:share":new Jt(this.swish,this.ui,this.eventBus,this.options),"view:list":new nn(this.swish,this.ui,this.eventBus,this.options),"view:lists":new rn(this.swish,this.ui,this.eventBus,this.options),"view:orders":new ln(this.swish,this.ui,this.eventBus,this.options),"view:order":new an(this.swish,this.ui,this.eventBus,this.options),"view:saves":new pn(this.swish,this.ui,this.eventBus,this.options),"view:notifications":new on(this.swish,this.ui,this.eventBus,this.options),"view:profile":new dn(this.swish,this.ui,this.eventBus,this.options),"view:product":new un(this.swish,this.ui,this.eventBus,this.options),"view:list-menu":new sn(this.swish,this.ui,this.eventBus,this.options),"view:order-menu":new cn(this.swish,this.ui,this.eventBus,this.options),"view:list-detail-page-menu":new tn(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-in":new zt(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-out":new Kt(this.swish,this.ui,this.eventBus,this.options),"initiate:quick-buy":new Gt(this.swish,this.ui,this.eventBus,this.options),"show:toast":new Yt(this.swish,this.ui,this.eventBus,this.options)}}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 c={lifecycle:"after",intent:o.intent,data:i,response:o};this.eventBus.dispatchEvent(new CustomEvent(o.intent,{detail:c}))}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((c,l)=>{a[l]=c}),{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,c)=>{c!=="swish-intent"&&(s[c]=a)});let o=ut(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:F(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 bn(this.swish,this.ui,this.options).invoke()}),this.eventBus.addEventListener("create:cart-line",t=>{new hn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:item",t=>{new vn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:item-lists",t=>{new fn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("view:home",t=>{new wn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:list-access",t=>{new mn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("initiate:share",t=>{new gn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:cart-line",t=>{new yn(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(){ot({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")}),ot({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 G=m(Z(x(),U([x(),A()])),{}),ic=b({url:m(x(),""),altText:m(x(),"")}),sc=b({id:x(),enabled:C(),intent:x()}),rc=b({type:V("drawer-header"),hidden:m(C(),!1),design:G,options:m(b({title:m(x(),""),logo:m(ic,{url:"",altText:""}),useCloseButton:m(C(),!1),accountButton:m(C(),!0),notificationButton:m(C(),!0)}),{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0})}),oc=b({type:V("drawer-footer"),hidden:m(C(),!1),design:G,options:m(b({displayType:m(ne(["floating","docked"]),"docked"),showIcons:m(C(),!1),showText:m(C(),!0),items:m(H(sc),[{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"}]})}),ac=Be("type",[rc,oc]),cc=b({type:ne(["sign-in","notifications","recently-viewed","saved-from-cart","saved-items","lists"]),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),lc=b({title:x(),url:x(),hidden:m(C(),!1)}),uc=b({type:V("mini-menu"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{}),items:m(H(lc),[])}),dc=b({type:V("content-block"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{}),title:m(x()),body:m(x()),image:m(b({url:x(),width:m(A()),height:m(A())})),link:m(b({url:x(),target:m(ne(["_self","_blank"]))}))}),pc=b({type:V("featured-collection"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{}),handle:x()}),hc=Be("type",[cc,uc,dc,pc]),fc=b({type:V("lists-section"),hidden:m(C(),!1),design:G,options:m(b({display:m(ne(["myLists","forYouLists"]),"myLists"),layout:m(ne(["list","slider"]),"slider")}),{display:"myLists",layout:"slider"})}),mc=b({type:V("all-items-grid"),hidden:m(C(),!1),design:G,options:m(b({showSaveButton:m(C(),!0),showQuickBuyButton:m(C(),!0),showBuyButton:m(C(),!1),showVariantTitle:m(C(),!0),enableVariantChange:m(C(),!1),showVariantOptionNames:m(C(),!0),hideCompareAtPrice:m(C(),!1),linkToProductPage:m(C(),!1)}),{showSaveButton:!0,showQuickBuyButton:!0,showBuyButton:!1,showVariantTitle:!0,enableVariantChange:!1,showVariantOptionNames:!0,hideCompareAtPrice:!1,linkToProductPage:!1})}),yc=Be("type",[fc,mc]),vc=b({type:V("lists-grid"),hidden:m(C(),!1),design:G,options:m(b({displayType:m(ne(["list","slider"]),"slider")}),{displayType:"slider"})}),gc=vc,wc=b({type:V("list-items-grid"),hidden:m(C(),!1),design:G,options:m(b({desktopColumns:m(A(),4),showBuyButton:m(C(),!0),showVariantTitle:m(C(),!0),showVariantOptionNames:m(C(),!1),enableVariantChange:m(C(),!0),hideCompareAtPrice:m(C(),!1),linkToProductPage:m(C(),!0)}),{desktopColumns:4,showBuyButton:!0,showVariantTitle:!0,showVariantOptionNames:!1,enableVariantChange:!0,hideCompareAtPrice:!1,linkToProductPage:!0})}),bc=wc,Ic=b({type:V("list-items-grid"),hidden:m(C(),!1),design:G,options:m(b({showBuyButton:m(C(),!1),showVariantTitle:m(C(),!0),showVariantOptionNames:m(C(),!1),enableVariantChange:m(C(),!1),hideCompareAtPrice:m(C(),!1),linkToProductPage:m(C(),!1)}),{showBuyButton:!1,showVariantTitle:!0,showVariantOptionNames:!1,enableVariantChange:!1,hideCompareAtPrice:!1,linkToProductPage:!1})}),Sc=Ic,xc=b({type:V("orders-list"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Cc=xc,Ec=b({type:V("order-info"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Rc=b({type:V("order-items"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),kc=b({type:V("order-actions"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Ac=Be("type",[Ec,Rc,kc]),Pc=b({type:V("image-slider"),hidden:m(C(),!1),design:G,options:m(b({flush:m(C(),!0),loop:m(C(),!1)}),{flush:!0,loop:!1})}),Tc=b({type:V("product-info"),hidden:m(C(),!1),design:G,options:m(b({descriptionMaxLines:m(A(),4),variantSelectDisplayType:m(ne(["pills","rows"]),"pills"),hideSingleValueOptions:m(C(),!0),images:m(b({baseTint:m(C(),!0)}),{baseTint:!0})}),{descriptionMaxLines:4,variantSelectDisplayType:"pills",hideSingleValueOptions:!0,images:{baseTint:!0}})}),Dc=b({type:V("buy-buttons"),hidden:m(C(),!1),design:G,options:m(b({shopPay:m(C(),!1)}),{shopPay:!1})}),Lc=b({type:V("complementary-products"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Oc=b({type:V("related-products"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),_c=Be("type",[Pc,Tc,Dc,Lc,Oc]),Mc=b({type:V("profile-form"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),qc=Mc,Fc=b({type:V("notifications-list"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Bc=Fc,Nc=b({sections:m(H(ac),[{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"}]}}])}),jc=b({sections:m(H(hc),[{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"}]}])}),Uc=b({sections:m(H(yc),[{type:"lists-section",options:{display:"myLists"}},{type:"lists-section",options:{display:"forYouLists"}},{type:"all-items-grid"}])}),Vc=b({sections:m(H(gc),[{type:"lists-grid"}])}),$c=b({sections:m(H(bc),[{type:"list-items-grid"}])}),Hc=b({sections:m(H(Sc),[{type:"list-items-grid"}])}),Qc=b({sections:m(H(Cc),[{type:"orders-list"}])}),Gc=b({sections:m(H(Ac),[{type:"order-info"},{type:"order-items"},{type:"order-actions"}])}),zc=b({sections:m(H(_c),[{type:"image-slider"},{type:"product-info"},{type:"buy-buttons"},{type:"complementary-products"},{type:"related-products"}])}),Kc=b({sections:m(H(qc),[{type:"profile-form"}])}),Wc=b({sections:m(H(Bc),[{type:"notifications-list"}])}),Os=b({baseUrl:m(x(),"https://swish.app/cdn"),css:m(H(U([x(),ci(URL)])),[]),design:m(Z(x(),ie()),{}),icons:m(Z(x(),x()),{}),images:m(b({baseTint:m(C(),!0)}),{baseTint:!0}),toasts:m(b({autoHideDuration:m(T(A(),fe(0),ai()),5e3)}),{autoHideDuration:5e3}),drawer:m(Nc,{}),home:m(jc,{}),saves:m(Uc,{}),lists:m(Vc,{}),listDetail:m(Hc,{}),listDetailPage:m($c,{}),orders:m(Qc,{}),orderDetail:m(Gc,{}),productDetail:m(zc,{}),profile:m(Kc,{}),notifications:m(Wc,{})});var _s=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:{productTitle:e.transforms?.productTitle??(({product:t})=>t?.title??""),productDescription:e.transforms?.productDescription??(({product:t})=>t?.descriptionHtml??""),productBadges:e.transforms?.productBadges??(({defaultBadges:t})=>t),productPrice:e.transforms?.productPrice??(()=>{}),addToCartButton:e.transforms?.addToCartButton??(()=>!1),linkToProductPage:e.transforms?.linkToProductPage??(()=>!1),variantTitle:e.transforms?.variantTitle??(({variant:t})=>t?.title??""),optionValues:e.transforms?.optionValues??(({optionValues:t})=>t),combinedListingParent:e.transforms?.combinedListingParent??(()=>!1),hideOption:e.transforms?.hideOption??(()=>!1)},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:Ts(Os,e.ui??{})}),"createSwishOptions");var mt=Math.min,Oe=Math.max,yt=Math.round,vt=Math.floor,be=r(e=>({x:e,y:e}),"createCoords");function li(e,t){return typeof e=="function"?e(t):e}r(li,"evaluate");function ui(e){return e.split("-")[0]}r(ui,"getSide");function di(e){return e.split("-")[1]}r(di,"getAlignment");function Ms(e){return e==="x"?"y":"x"}r(Ms,"getOppositeAxis");function qs(e){return e==="y"?"height":"width"}r(qs,"getAxisLength");function Sn(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}r(Sn,"getSideAxis");function Fs(e){return Ms(Sn(e))}r(Fs,"getAlignmentAxis");function Xc(e){return{top:0,right:0,bottom:0,left:0,...e}}r(Xc,"expandPaddingObject");function Bs(e){return typeof e!="number"?Xc(e):{top:e,right:e,bottom:e,left:e}}r(Bs,"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 Ns(e,t,n){let{reference:i,floating:s}=e,o=Sn(t),a=Fs(t),c=qs(a),l=ui(t),d=o==="y",p=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,h=i[c]/2-s[c]/2,y;switch(l){case"top":y={x:p,y:i.y-s.height};break;case"bottom":y={x:p,y:i.y+i.height};break;case"right":y={x:i.x+i.width,y:f};break;case"left":y={x:i.x-s.width,y:f};break;default:y={x:i.x,y:i.y}}switch(di(t)){case"start":y[a]-=h*(n&&d?-1:1);break;case"end":y[a]+=h*(n&&d?-1:1);break}return y}r(Ns,"computeCoordsFromPlacement");async function js(e,t){var n;t===void 0&&(t={});let{x:i,y:s,platform:o,rects:a,elements:c,strategy:l}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:h=!1,padding:y=0}=li(t,e),g=Bs(y),I=c[h?f==="floating"?"reference":"floating":f],S=Ne(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(I)))==null||n?I:I.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(c.floating)),boundary:d,rootBoundary:p,strategy:l})),R=f==="floating"?{x:i,y:s,width:a.floating.width,height:a.floating.height}:a.reference,P=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c.floating)),D=await(o.isElement==null?void 0:o.isElement(P))?await(o.getScale==null?void 0:o.getScale(P))||{x:1,y:1}:{x:1,y:1},k=Ne(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:R,offsetParent:P,strategy:l}):R);return{top:(S.top-k.top+g.top)/D.y,bottom:(k.bottom-S.bottom+g.bottom)/D.y,left:(S.left-k.left+g.left)/D.x,right:(k.right-S.right+g.right)/D.x}}r(js,"detectOverflow");var Jc=50,Us=r(async(e,t,n)=>{let{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,c=a.detectOverflow?a:{...a,detectOverflow:js},l=await(a.isRTL==null?void 0:a.isRTL(t)),d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:p,y:f}=Ns(d,i,l),h=i,y=0,g={};for(let v=0;v<o.length;v++){let I=o[v];if(!I)continue;let{name:S,fn:R}=I,{x:P,y:D,data:k,reset:O}=await R({x:p,y:f,initialPlacement:i,placement:h,strategy:s,middlewareData:g,rects:d,platform:c,elements:{reference:e,floating:t}});p=P??p,f=D??f,g[S]={...g[S],...k},O&&y<Jc&&(y++,typeof O=="object"&&(O.placement&&(h=O.placement),O.rects&&(d=O.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):O.rects),{x:p,y:f}=Ns(d,h,l)),v=-1)}return{x:p,y:f,placement:h,strategy:s,middlewareData:g}},"computePosition");var Yc=new Set(["left","top"]);async function Zc(e,t){let{placement:n,platform:i,elements:s}=e,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=ui(n),c=di(n),l=Sn(n)==="y",d=Yc.has(a)?-1:1,p=o&&l?-1:1,f=li(t,e),{mainAxis:h,crossAxis:y,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return c&&typeof g=="number"&&(y=c==="end"?g*-1:g),l?{x:y*p,y:h*d}:{x:h*d,y:y*p}}r(Zc,"convertValueToCoords");var Vs=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:c}=t,l=await Zc(t,e);return a===((n=c.offset)==null?void 0:n.placement)&&(i=c.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:a}}}}},"offset");function xn(){return typeof window<"u"}r(xn,"hasWindow");function Ue(e){return Hs(e)?(e.nodeName||"").toLowerCase():"#document"}r(Ue,"getNodeName");function ae(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}r(ae,"getWindow");function Ie(e){var t;return(t=(Hs(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}r(Ie,"getDocumentElement");function Hs(e){return xn()?e instanceof Node||e instanceof ae(e).Node:!1}r(Hs,"isNode");function ye(e){return xn()?e instanceof Element||e instanceof ae(e).Element:!1}r(ye,"isElement");function Ee(e){return xn()?e instanceof HTMLElement||e instanceof ae(e).HTMLElement:!1}r(Ee,"isHTMLElement");function $s(e){return!xn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ae(e).ShadowRoot}r($s,"isShadowRoot");function Ye(e){let{overflow:t,overflowX:n,overflowY:i,display:s}=ve(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&s!=="inline"&&s!=="contents"}r(Ye,"isOverflowElement");function Qs(e){return/^(table|td|th)$/.test(Ue(e))}r(Qs,"isTableElement");function gt(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}r(gt,"isTopLayer");var el=/transform|translate|scale|rotate|perspective|filter/,tl=/paint|layout|strict|content/,je=r(e=>!!e&&e!=="none","isNotNone"),pi;function Cn(e){let t=ye(e)?ve(e):e;return je(t.transform)||je(t.translate)||je(t.scale)||je(t.rotate)||je(t.perspective)||!En()&&(je(t.backdropFilter)||je(t.filter))||el.test(t.willChange||"")||tl.test(t.contain||"")}r(Cn,"isContainingBlock");function Gs(e){let t=Le(e);for(;Ee(t)&&!Ve(t);){if(Cn(t))return t;if(gt(t))return null;t=Le(t)}return null}r(Gs,"getContainingBlock");function En(){return pi==null&&(pi=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),pi}r(En,"isWebKit");function Ve(e){return/^(html|body|#document)$/.test(Ue(e))}r(Ve,"isLastTraversableNode");function ve(e){return ae(e).getComputedStyle(e)}r(ve,"getComputedStyle");function wt(e){return ye(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}r(wt,"getNodeScroll");function Le(e){if(Ue(e)==="html")return e;let t=e.assignedSlot||e.parentNode||$s(e)&&e.host||Ie(e);return $s(t)?t.host:t}r(Le,"getParentNode");function zs(e){let t=Le(e);return Ve(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ee(t)&&Ye(t)?t:zs(t)}r(zs,"getNearestOverflowAncestor");function Je(e,t,n){var i;t===void 0&&(t=[]),n===void 0&&(n=!0);let s=zs(e),o=s===((i=e.ownerDocument)==null?void 0:i.body),a=ae(s);if(o){let c=Rn(a);return t.concat(a,a.visualViewport||[],Ye(s)?s:[],c&&n?Je(c):[])}else return t.concat(s,Je(s,[],n))}r(Je,"getOverflowAncestors");function Rn(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}r(Rn,"getFrameElement");function Js(e){let t=ve(e),n=parseFloat(t.width)||0,i=parseFloat(t.height)||0,s=Ee(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:i,c=yt(n)!==o||yt(i)!==a;return c&&(n=o,i=a),{width:n,height:i,$:c}}r(Js,"getCssDimensions");function fi(e){return ye(e)?e:e.contextElement}r(fi,"unwrapElement");function Ze(e){let t=fi(e);if(!Ee(t))return be(1);let n=t.getBoundingClientRect(),{width:i,height:s,$:o}=Js(t),a=(o?yt(n.width):n.width)/i,c=(o?yt(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}r(Ze,"getScale");var nl=be(0);function Ys(e){let t=ae(e);return!En()||!t.visualViewport?nl:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}r(Ys,"getVisualOffsets");function il(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ae(e)?!1:t}r(il,"shouldAddVisualOffsets");function $e(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);let s=e.getBoundingClientRect(),o=fi(e),a=be(1);t&&(i?ye(i)&&(a=Ze(i)):a=Ze(e));let c=il(o,n,i)?Ys(o):be(0),l=(s.left+c.x)/a.x,d=(s.top+c.y)/a.y,p=s.width/a.x,f=s.height/a.y;if(o){let h=ae(o),y=i&&ye(i)?ae(i):i,g=h,v=Rn(g);for(;v&&i&&y!==g;){let I=Ze(v),S=v.getBoundingClientRect(),R=ve(v),P=S.left+(v.clientLeft+parseFloat(R.paddingLeft))*I.x,D=S.top+(v.clientTop+parseFloat(R.paddingTop))*I.y;l*=I.x,d*=I.y,p*=I.x,f*=I.y,l+=P,d+=D,g=ae(v),v=Rn(g)}}return Ne({width:p,height:f,x:l,y:d})}r($e,"getBoundingClientRect");function kn(e,t){let n=wt(e).scrollLeft;return t?t.left+n:$e(Ie(e)).left+n}r(kn,"getWindowScrollBarX");function Zs(e,t){let n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-kn(e,n),s=n.top+t.scrollTop;return{x:i,y:s}}r(Zs,"getHTMLOffset");function sl(e){let{elements:t,rect:n,offsetParent:i,strategy:s}=e,o=s==="fixed",a=Ie(i),c=t?gt(t.floating):!1;if(i===a||c&&o)return n;let l={scrollLeft:0,scrollTop:0},d=be(1),p=be(0),f=Ee(i);if((f||!f&&!o)&&((Ue(i)!=="body"||Ye(a))&&(l=wt(i)),f)){let y=$e(i);d=Ze(i),p.x=y.x+i.clientLeft,p.y=y.y+i.clientTop}let h=a&&!f&&!o?Zs(a,l):be(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-l.scrollLeft*d.x+p.x+h.x,y:n.y*d.y-l.scrollTop*d.y+p.y+h.y}}r(sl,"convertOffsetParentRelativeRectToViewportRelativeRect");function rl(e){return Array.from(e.getClientRects())}r(rl,"getClientRects");function ol(e){let t=Ie(e),n=wt(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+kn(e),c=-n.scrollTop;return ve(i).direction==="rtl"&&(a+=Oe(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:a,y:c}}r(ol,"getDocumentRect");var Ks=25;function al(e,t){let n=ae(e),i=Ie(e),s=n.visualViewport,o=i.clientWidth,a=i.clientHeight,c=0,l=0;if(s){o=s.width,a=s.height;let p=En();(!p||p&&t==="fixed")&&(c=s.offsetLeft,l=s.offsetTop)}let d=kn(i);if(d<=0){let p=i.ownerDocument,f=p.body,h=getComputedStyle(f),y=p.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,g=Math.abs(i.clientWidth-f.clientWidth-y);g<=Ks&&(o-=g)}else d<=Ks&&(o+=d);return{width:o,height:a,x:c,y:l}}r(al,"getViewportRect");function cl(e,t){let n=$e(e,!0,t==="fixed"),i=n.top+e.clientTop,s=n.left+e.clientLeft,o=Ee(e)?Ze(e):be(1),a=e.clientWidth*o.x,c=e.clientHeight*o.y,l=s*o.x,d=i*o.y;return{width:a,height:c,x:l,y:d}}r(cl,"getInnerBoundingClientRect");function Ws(e,t,n){let i;if(t==="viewport")i=al(e,n);else if(t==="document")i=ol(Ie(e));else if(ye(t))i=cl(t,n);else{let s=Ys(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 er(e,t){let n=Le(e);return n===t||!ye(n)||Ve(n)?!1:ve(n).position==="fixed"||er(n,t)}r(er,"hasFixedPositionAncestor");function ll(e,t){let n=t.get(e);if(n)return n;let i=Je(e,[],!1).filter(c=>ye(c)&&Ue(c)!=="body"),s=null,o=ve(e).position==="fixed",a=o?Le(e):e;for(;ye(a)&&!Ve(a);){let c=ve(a),l=Cn(a);!l&&c.position==="fixed"&&(s=null),(o?!l&&!s:!l&&c.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Ye(a)&&!l&&er(e,a))?i=i.filter(p=>p!==a):s=c,a=Le(a)}return t.set(e,i),i}r(ll,"getClippingElementAncestors");function ul(e){let{element:t,boundary:n,rootBoundary:i,strategy:s}=e,a=[...n==="clippingAncestors"?gt(t)?[]:ll(t,this._c):[].concat(n),i],c=Ws(t,a[0],s),l=c.top,d=c.right,p=c.bottom,f=c.left;for(let h=1;h<a.length;h++){let y=Ws(t,a[h],s);l=Oe(y.top,l),d=mt(y.right,d),p=mt(y.bottom,p),f=Oe(y.left,f)}return{width:d-f,height:p-l,x:f,y:l}}r(ul,"getClippingRect");function dl(e){let{width:t,height:n}=Js(e);return{width:t,height:n}}r(dl,"getDimensions");function pl(e,t,n){let i=Ee(t),s=Ie(t),o=n==="fixed",a=$e(e,!0,o,t),c={scrollLeft:0,scrollTop:0},l=be(0);function d(){l.x=kn(s)}if(r(d,"setLeftRTLScrollbarOffset"),i||!i&&!o)if((Ue(t)!=="body"||Ye(s))&&(c=wt(t)),i){let y=$e(t,!0,o,t);l.x=y.x+t.clientLeft,l.y=y.y+t.clientTop}else s&&d();o&&!i&&s&&d();let p=s&&!i&&!o?Zs(s,c):be(0),f=a.left+c.scrollLeft-l.x-p.x,h=a.top+c.scrollTop-l.y-p.y;return{x:f,y:h,width:a.width,height:a.height}}r(pl,"getRectRelativeToOffsetParent");function hi(e){return ve(e).position==="static"}r(hi,"isStaticPositioned");function Xs(e,t){if(!Ee(e)||ve(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ie(e)===n&&(n=n.ownerDocument.body),n}r(Xs,"getTrueOffsetParent");function tr(e,t){let n=ae(e);if(gt(e))return n;if(!Ee(e)){let s=Le(e);for(;s&&!Ve(s);){if(ye(s)&&!hi(s))return s;s=Le(s)}return n}let i=Xs(e,t);for(;i&&Qs(i)&&hi(i);)i=Xs(i,t);return i&&Ve(i)&&hi(i)&&!Cn(i)?n:i||Gs(e)||n}r(tr,"getOffsetParent");var hl=r(async function(e){let t=this.getOffsetParent||tr,n=this.getDimensions,i=await n(e.floating);return{reference:pl(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},"getElementRects");function fl(e){return ve(e).direction==="rtl"}r(fl,"isRTL");var ml={convertOffsetParentRelativeRectToViewportRelativeRect:sl,getDocumentElement:Ie,getClippingRect:ul,getOffsetParent:tr,getElementRects:hl,getClientRects:rl,getDimensions:dl,getScale:Ze,isElement:ye,isRTL:fl};function nr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}r(nr,"rectsAreEqual");function yl(e,t){let n=null,i,s=Ie(e);function o(){var c;clearTimeout(i),(c=n)==null||c.disconnect(),n=null}r(o,"cleanup");function a(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),o();let d=e.getBoundingClientRect(),{left:p,top:f,width:h,height:y}=d;if(c||t(),!h||!y)return;let g=vt(f),v=vt(s.clientWidth-(p+h)),I=vt(s.clientHeight-(f+y)),S=vt(p),P={rootMargin:-g+"px "+-v+"px "+-I+"px "+-S+"px",threshold:Oe(0,mt(1,l))||1},D=!0;function k(O){let M=O[0].intersectionRatio;if(M!==l){if(!D)return a();M?a(!1,M):i=setTimeout(()=>{a(!1,1e-7)},1e3)}M===1&&!nr(d,e.getBoundingClientRect())&&a(),D=!1}r(k,"handleObserve");try{n=new IntersectionObserver(k,{...P,root:s.ownerDocument})}catch{n=new IntersectionObserver(k,P)}n.observe(e)}return r(a,"refresh"),a(!0),o}r(yl,"observeMove");function ir(e,t,n,i){i===void 0&&(i={});let{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,d=fi(e),p=s||o?[...d?Je(d):[],...t?Je(t):[]]:[];p.forEach(S=>{s&&S.addEventListener("scroll",n,{passive:!0}),o&&S.addEventListener("resize",n)});let f=d&&c?yl(d,n):null,h=-1,y=null;a&&(y=new ResizeObserver(S=>{let[R]=S;R&&R.target===d&&y&&t&&(y.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var P;(P=y)==null||P.observe(t)})),n()}),d&&!l&&y.observe(d),t&&y.observe(t));let g,v=l?$e(e):null;l&&I();function I(){let S=$e(e);v&&!nr(v,S)&&n(),v=S,g=requestAnimationFrame(I)}return r(I,"frameLoop"),n(),()=>{var S;p.forEach(R=>{s&&R.removeEventListener("scroll",n),o&&R.removeEventListener("resize",n)}),f?.(),(S=y)==null||S.disconnect(),y=null,l&&cancelAnimationFrame(g)}}r(ir,"autoUpdate");var sr=Vs;var rr=r((e,t,n)=>{let i=new Map,s={platform:ml,...n},o={...s.platform,_c:i};return Us(e,t,{...s,platform:o})},"computePosition");function vl(e){let t=e.getAttribute("swish-item-context");return t?t==="location"?globalThis.window?.location??e:Ke(e,t)??e:e}r(vl,"resolveItemContextSource");function or(e,t){return e.getAttribute("swish-item-context")?vl(e):t}r(or,"resolvePlacementItemContextSource");function mi(e,t){if(!t.element)throw new Error("Element must be provided");let n=null,i=null,s=new Map,o=r((f,h)=>{e.events.publish("placement-warning",{placementId:t.id,code:f,message:h})},"warn"),a=r(()=>{if(n){console.warn("Placement already mounted. Skipping mount.");return}wl(t);try{document.querySelectorAll(t.target.selector)}catch(f){o("invalid-selector",f instanceof Error?f.message:"Invalid CSS selector");return}n=ot({selector:t.target.selector,observerOptions:t.target.observerOptions,mustMatch:t.target.mustMatch,onElementFound:r(f=>c(f),"onElementFound")}),i=setTimeout(()=>{s.size===0&&o("no-matches",`No elements match selector "${t.target.selector}"`),i=null},2e3)},"mount"),c=r(f=>{s.has(f)||f.hasAttribute("swish-ignore")||f.getAttribute("swish-placement-target")===t.id||(f.setAttribute("swish-placement-target",t.id),l(f))},"evaluateAndMount"),l=r(async f=>{let h=[],y=t.mount.mode,g=ur(f,t.mount.at);if(!g){o("mount-target-not-found","Could not resolve a mount target relative to the matched element.");return}let v=await(typeof t.element=="function"?t.element(t):_l(e,t.element));if(!v){o("element-factory-empty","Element factory returned no element to mount.");return}if(v.setAttribute("swish-placement-element",t.id),typeof t.element!="function"){let j=t.element;j.props&&Ml(v,j.props),j.classNames&&pr(v,j.classNames)}let I;t.container&&(I=Ol(t.id,t.container),I.appendChild(v));let S,R=I??v;if(t.layout?.type==="overlay"){Pl(g);let j=t.layout.anchor??"bottom-right";R.setAttribute("swish-placement-overlay",t.id),R.setAttribute("swish-placement-anchor",j)}else t.layout?.type==="anchored"&&R.setAttribute("swish-placement-anchored",t.id);let P=!1,D;if(t.layout?.type==="inline"){let j=t.layout,le=j.rowSelector?g.closest(j.rowSelector):null;le?S=le:(S=Ll(t.id,g,j),P=!0),D=S.getAttribute("swish-placement-inline-row"),S.setAttribute("swish-placement-inline-row",t.id)}let k=I??v;if(!Al(g,k,y)){try{k.remove()}catch{}o("insert-failed",`Could not insert element with mode "${y}" \u2014 target has no parent.`);return}if(t.layout?.type==="anchored"){let j=ur(f,t.layout.to)??g,le=Tl(j,R,t.layout);h.push(le)}let M={targetEl:f,renderTargetEl:g,mountEl:v,containerEl:I,rowEl:S,rowWasCreated:P,rowInlineAttrPrevValue:D,cleanupFns:h,ownsNode:!0};s.set(f,M),i&&(clearTimeout(i),i=null);let q={id:t.id,targetEl:f,renderTargetEl:g,mountEl:M.mountEl,containerEl:I,rowEl:S,cleanup:r(j=>h.push(j),"cleanup")};t.element?.name==="save-button"&&gl(e,q),t.onMount?.(q)},"mountElement"),d=r(f=>{let h=s.get(f);if(h){if(t.onUnmount?.({id:t.id,targetEl:h.targetEl,renderTargetEl:h.renderTargetEl,mountEl:h.mountEl,containerEl:h.containerEl,rowEl:h.rowEl}),h.cleanupFns.forEach(y=>y()),h.targetEl.getAttribute("swish-placement-target")===t.id&&h.targetEl.removeAttribute("swish-placement-target"),h.ownsNode&&(h.containerEl||h.mountEl).remove(),h.rowEl){if(h.rowWasCreated){let y=h.rowEl.parentElement;y&&h.targetEl.parentElement===h.rowEl?h.rowEl.replaceWith(h.targetEl):y?y.removeChild(h.rowEl):h.rowEl.remove()}else if(h.rowInlineAttrPrevValue!==void 0){let y=h.rowInlineAttrPrevValue;y===null?h.rowEl.removeAttribute("swish-placement-inline-row"):h.rowEl.setAttribute("swish-placement-inline-row",y)}}s.delete(f)}},"unmountElement");return{mount:a,unmount:r(()=>{n&&(n.disconnect(),n=null),i&&(clearTimeout(i),i=null),s.forEach((f,h)=>d(h)),s.clear()},"unmount")}}r(mi,"createPlacement");var gl=r((e,{mountEl:t,targetEl:n,cleanup:i})=>{let s=or(t,n),o=e.state.itemContext(s),a=e.state.effect(()=>{let{loading:c,productId:l,variantId:d}=o.value;c||(t.setAttribute("product-id",l??""),t.setAttribute("variant-id",d??""))});i(()=>a?.())},"saveButtonMount");function wl(e){let t=bl(e.id),n=kl(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(wl,"ensurePlacementStylesheet");function bl(e){return`swish-placement-style-${Il(e)}`}r(bl,"getPlacementStyleId");function Il(e){return e.replace(/[^a-zA-Z0-9\-_]/g,"_")}r(Il,"cssEscapeId");function ar(e){return`--swish-placement-${Sl(String(e))}`}r(ar,"designKeyToCSSVar");function Sl(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Sl,"toKebabCase");function xl(e){return Object.entries(e??{sm:500,lg:700}).map(([i,s])=>({name:i,minWidth:s})).sort((i,s)=>i.minWidth-s.minWidth)}r(xl,"getBreakpoints");function dr(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(dr,"normalizeResponsiveValue");var Cl=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function cr(e,t){if(t!=null)return typeof t=="number"&&!Cl.has(e)?`${t}px`:String(t)}r(cr,"formatDesignValue");function El(e,t,n){if(!t)return"";let i=new Set(n.map(l=>l.name)),s=[],o={},a=Object.entries(t).map(([l,d])=>[l,d]);for(let[l,d]of a){let p=dr(d,i),f=cr(String(l),p.base);f!==void 0&&s.push(`${ar(l)}:${f};`);for(let h of n){let y=p[h.name],g=cr(String(l),y);g!==void 0&&(o[h.name]||(o[h.name]=[]),o[h.name].push(`${ar(l)}:${g};`))}}let c=[];s.length&&c.push(`[swish-placement-element="${e}"]{${s.join("")}}`);for(let l of n){let d=o[l.name];d?.length&&c.push(`@media(min-width:${l.minWidth}px){[swish-placement-element="${e}"]{${d.join("")}}}`)}return c.join("")}r(El,"emitDesignCSS");function An(e){return e==null?"0px":typeof e=="number"?`${e}px`:e}r(An,"formatOffsetValue");function lr(e){return e==null?"":typeof e=="number"?`${e}`:e}r(lr,"formatZIndexValue");function Rl(e,t,n){let i=new Set(n.map(d=>d.name)),s=dr(t,i),o=s.base??{},a=An(o.x),c=An(o.y),l=[];l.push(`[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${a};--swish-placement-offset-y:${c};}`);for(let d of n){let p=s[d.name];if(!p)continue;let f=An(p.x),h=An(p.y);l.push(`@media(min-width:${d.minWidth}px){[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${f};--swish-placement-offset-y:${h};}}`)}return l.join("")}r(Rl,"emitOverlayOffsetCSS");function kl(e){let t=e.id,n=xl(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=Rl(t,e.layout.offset,n),c=e.layout.zIndex?`[swish-placement-overlay="${t}"]{--swish-placement-overlay-z:${lr(e.layout.zIndex)};}`:"";o+=a+c+s}else if(e.layout?.type==="anchored"){let a=e.layout.zIndex?lr(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=El(t,e.design,n);a&&(o+=a)}return e.css&&(o+=e.css.trim()),o}r(kl,"buildPlacementCSS");function ur(e,t){if(!t||t==="target")return e;if(typeof t=="string"&&(t={nearest:t}),"nearest"in t)return Ke(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(ur,"resolveMountTarget");function Al(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(Al,"insertIntoDOM");function Pl(e){let t=e.parentElement;return t?(window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t):null}r(Pl,"ensureRelativeParent");function Tl(e,t,n){let i=[];return n.inside?i.push(Dl(n.offset??0)):n.offset&&i.push(sr(n.offset)),ir(e,t,r(()=>{rr(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(Tl,"setupAnchoredPosition");function Dl(e){return{name:"anchoredInside",fn({x:t,y:n,rects:i,placement:s}){let[o,a]=s.split("-"),c=0,l=0,d=o==="top"||o==="bottom";return o==="top"?l=i.floating.height+e:o==="bottom"?l=-(i.floating.height+e):o==="left"?c=i.floating.width+e:o==="right"&&(c=-(i.floating.width+e)),d&&a==="start"?c=e:d&&a==="end"?c=-e:!d&&a==="start"?l=e:!d&&a==="end"&&(l=-e),{x:t+c,y:n+l}}}}r(Dl,"anchoredInsideMiddleware");function Ll(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(Ll,"wrapWithFlexRow");function Ol(e,t){let n=t.tag||"div",i=document.createElement(n);return i.setAttribute("swish-placement-container",e),t.classNames&&pr(i,t.classNames),i}r(Ol,"createContainer");function _l(e,t){return e.ui.createElement(t.name,{})}r(_l,"createElement");function Ml(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(Ml,"applyProps");function pr(e,t){e.classList.add(...t)}r(pr,"applyClassNames");var Pn=class{constructor(t){this.app=t;this.mountedPlacements=[]}static{r(this,"Placements")}mountConfigured(t){this.mountedPlacements=t.map(n=>this.mountSpec(n))}create(t){return mi(this.app,t)}applyPreview(t=[]){this.unmountAll(),this.mountConfigured(t)}get list(){return this.mountedPlacements}mountSpec(t){let n=mi(this.app,t);return n.mount(),{spec:t,...n}}unmountAll(){this.mountedPlacements.forEach(t=>t.unmount()),this.mountedPlacements=[]}};function hr(e){return F(String(e).trim())}r(hr,"normalizeSwishQueryId");function Tn(e){let t=e.productId?hr(e.productId):"",n=e.variantId?hr(e.variantId):"";return n?["swish","items",t,n]:["swish","items",t]}r(Tn,"swishItemsQueryKey");var ql=["item-create","item-update","item-delete"],fr="auth-cache-clear",mr="token-update";function yr({events:e,queryClient:t}){return e.subscribe([...ql,fr,mr],n=>{if(!(n instanceof CustomEvent))return;if(n.type===fr){t.clear();return}if(n.type===mr){t.invalidateQueries({queryKey:["swish"]});return}if(!n.detail?.productId)return;let i=Tn({productId:n.detail.productId});t.invalidateQueries({queryKey:i})})}r(yr,"bindSwishItemQueryInvalidation");var Re=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 Fl=class extends Re{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"}},et=new Fl;var Bl={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")},Nl=class{static{r(this,"TimeoutManager")}#e=Bl;#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)}},ke=new Nl;function vr(e){setTimeout(e,0)}r(vr,"systemSetTimeoutZero");var br=typeof window>"u"||"Deno"in globalThis;function z(){}r(z,"noop");function Ir(e,t){return typeof e=="function"?e(t):e}r(Ir,"functionalUpdate");function bt(e){return typeof e=="number"&&e>=0&&e!==1/0}r(bt,"isValidTimeout");function Dn(e,t){return Math.max(e+(t||0)-Date.now(),0)}r(Dn,"timeUntilStale");function Se(e,t){return typeof e=="function"?e(t):e}r(Se,"resolveStaleTime");function ce(e,t){return typeof e=="function"?e(t):e}r(ce,"resolveEnabled");function vi(e,t){let{type:n="all",exact:i,fetchStatus:s,predicate:o,queryKey:a,stale:c}=e;if(a){if(i){if(t.queryHash!==It(a,t.options))return!1}else if(!nt(t.queryKey,a))return!1}if(n!=="all"){let l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||s&&s!==t.state.fetchStatus||o&&!o(t))}r(vi,"matchQuery");function gi(e,t){let{exact:n,status:i,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(tt(t.options.mutationKey)!==tt(o))return!1}else if(!nt(t.options.mutationKey,o))return!1}return!(i&&t.state.status!==i||s&&!s(t))}r(gi,"matchMutation");function It(e,t){return(t?.queryKeyHashFn||tt)(e)}r(It,"hashQueryKeyByOptions");function tt(e){return JSON.stringify(e,(t,n)=>yi(n)?Object.keys(n).sort().reduce((i,s)=>(i[s]=n[s],i),{}):n)}r(tt,"hashKey");function nt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>nt(e[n],t[n])):!1}r(nt,"partialMatchKey");var jl=Object.prototype.hasOwnProperty;function Sr(e,t,n=0){if(e===t)return e;if(n>500)return t;let i=gr(e)&&gr(t);if(!i&&!(yi(e)&&yi(t)))return t;let o=(i?e:Object.keys(e)).length,a=i?t:Object.keys(t),c=a.length,l=i?new Array(c):{},d=0;for(let p=0;p<c;p++){let f=i?p:a[p],h=e[f],y=t[f];if(h===y){l[f]=h,(i?p<o:jl.call(e,f))&&d++;continue}if(h===null||y===null||typeof h!="object"||typeof y!="object"){l[f]=y;continue}let g=Sr(h,y,n+1);l[f]=g,g===h&&d++}return o===c&&d===o?e:l}r(Sr,"replaceEqualDeep");function Ln(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(Ln,"shallowEqualObjects");function gr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}r(gr,"isPlainArray");function yi(e){if(!wr(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!wr(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}r(yi,"isPlainObject");function wr(e){return Object.prototype.toString.call(e)==="[object Object]"}r(wr,"hasObjectPrototype");function xr(e){return new Promise(t=>{ke.setTimeout(t,e)})}r(xr,"sleep");function St(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Sr(e,t):t}r(St,"replaceData");function Cr(e,t,n=0){let i=[...e,t];return n&&i.length>n?i.slice(1):i}r(Cr,"addToEnd");function Er(e,t,n=0){let i=[t,...e];return n&&i.length>n?i.slice(0,-1):i}r(Er,"addToStart");var xt=Symbol();function On(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===xt?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}r(On,"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 He=(()=>{let e=r(()=>br,"isServerFn");return{isServer(){return e()},setIsServer(t){e=t}}})();function Ct(){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(Ct,"pendingThenable");function kr(e){let t;if(e.then(n=>(t=n,n),z)?.catch(z),t!==void 0)return{data:t}}r(kr,"tryResolveSync");function Ar(e){return e}r(Ar,"defaultTransformerFn");function Ul(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}r(Ul,"dehydrateMutation");function Vl(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(Vl,"dehydrateQuery");function Pr(e){return e.state.isPaused}r(Pr,"defaultShouldDehydrateMutation");function Tr(e){return e.state.status==="success"}r(Tr,"defaultShouldDehydrateQuery");function $l(e){return!0}r($l,"defaultShouldRedactErrors");function wi(e,t={}){let n=t.shouldDehydrateMutation??e.getDefaultOptions().dehydrate?.shouldDehydrateMutation??Pr,i=e.getMutationCache().getAll().flatMap(l=>n(l)?[Ul(l)]:[]),s=t.shouldDehydrateQuery??e.getDefaultOptions().dehydrate?.shouldDehydrateQuery??Tr,o=t.shouldRedactErrors??e.getDefaultOptions().dehydrate?.shouldRedactErrors??$l,a=t.serializeData??e.getDefaultOptions().dehydrate?.serializeData??Ar,c=e.getQueryCache().getAll().flatMap(l=>s(l)?[Vl(l,a,o)]:[]);return{mutations:i,queries:c}}r(wi,"dehydrate");function bi(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||[],c=t.queries||[];a.forEach(({state:l,...d})=>{i.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...d},l)}),c.forEach(({queryKey:l,state:d,queryHash:p,meta:f,promise:h,dehydratedAt:y})=>{let g=h?kr(h):void 0,v=d.data===void 0?g?.data:d.data,I=v===void 0?v:o(v),S=s.get(p),R=S?.state.status==="pending",P=S?.state.fetchStatus==="fetching";if(S){let D=g&&y!==void 0&&y>S.state.dataUpdatedAt;if(d.dataUpdatedAt>S.state.dataUpdatedAt||D){let{fetchStatus:k,...O}=d;S.setState({...O,data:I})}}else S=s.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:l,queryHash:p,meta:f},{...d,data:I,fetchStatus:"idle",status:I!==void 0?"success":d.status});h&&!R&&!P&&(y===void 0||y>S.state.dataUpdatedAt)&&S.fetch(void 0,{initialPromise:Promise.resolve(h).then(o)}).catch(z)})}r(bi,"hydrate");var Hl=vr;function Ql(){let e=[],t=0,n=r(c=>{c()},"notifyFn"),i=r(c=>{c()},"batchNotifyFn"),s=Hl,o=r(c=>{t?e.push(c):s(()=>{n(c)})},"schedule"),a=r(()=>{let c=e;e=[],c.length&&s(()=>{i(()=>{c.forEach(l=>{n(l)})})})},"flush");return{batch:r(c=>{let l;t++;try{l=c()}finally{t--,t||a()}return l},"batch"),batchCalls:r(c=>(...l)=>{o(()=>{c(...l)})},"batchCalls"),schedule:o,setNotifyFunction:r(c=>{n=c},"setNotifyFunction"),setBatchNotifyFunction:r(c=>{i=c},"setBatchNotifyFunction"),setScheduler:r(c=>{s=c},"setScheduler")}}r(Ql,"createNotifyManager");var K=Ql();var Gl=class extends Re{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}},it=new Gl;function zl(e){return Math.min(1e3*2**e,3e4)}r(zl,"defaultRetryDelay");function Ii(e){return(e??"online")==="online"?it.isOnline():!0}r(Ii,"canFetch");var _n=class extends Error{static{r(this,"CancelledError")}constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Mn(e){let t=!1,n=0,i,s=Ct(),o=r(()=>s.status!=="pending","isResolved"),a=r(v=>{if(!o()){let I=new _n(v);h(I),e.onCancel?.(I)}},"cancel"),c=r(()=>{t=!0},"cancelRetry"),l=r(()=>{t=!1},"continueRetry"),d=r(()=>et.isFocused()&&(e.networkMode==="always"||it.isOnline())&&e.canRun(),"canContinue"),p=r(()=>Ii(e.networkMode)&&e.canRun(),"canStart"),f=r(v=>{o()||(i?.(),s.resolve(v))},"resolve"),h=r(v=>{o()||(i?.(),s.reject(v))},"reject"),y=r(()=>new Promise(v=>{i=r(I=>{(o()||d())&&v(I)},"continueFn"),e.onPause?.()}).then(()=>{i=void 0,o()||e.onContinue?.()}),"pause"),g=r(()=>{if(o())return;let v,I=n===0?e.initialPromise:void 0;try{v=I??e.fn()}catch(S){v=Promise.reject(S)}Promise.resolve(v).then(f).catch(S=>{if(o())return;let R=e.retry??(He.isServer()?0:3),P=e.retryDelay??zl,D=typeof P=="function"?P(n,S):P,k=R===!0||typeof R=="number"&&n<R||typeof R=="function"&&R(n,S);if(t||!k){h(S);return}n++,e.onFail?.(n,S),xr(D).then(()=>d()?void 0:y()).then(()=>{t?h(S):g()})})},"run");return{promise:s,status:r(()=>s.status,"status"),cancel:a,continue:r(()=>(i?.(),s),"continue"),cancelRetry:c,continueRetry:l,canStart:p,start:r(()=>(p()?g():y().then(g),s),"start")}}r(Mn,"createRetryer");var qn=class{static{r(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),bt(this.gcTime)&&(this.#e=ke.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(He.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(ke.clearTimeout(this.#e),this.#e=void 0)}};var Or=class extends qn{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=Lr(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=Lr(this.options);t.data!==void 0&&(this.setState(Dr(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){let n=St(this.state.data,e,this.options);return this.#c({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({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=>ce(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===xt||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Se(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:!Dn(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.#c({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 c=this.observers.find(l=>l.options.queryFn);c&&this.setOptions(c.options)}let n=new AbortController,i=r(c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:r(()=>(this.#r=!0,n.signal),"get")})},"addSignalProperty"),s=r(()=>{let c=On(this.options,t),d=r(()=>{let p={client:this.#s,queryKey:this.queryKey,meta:this.meta};return i(p),p},"createQueryFnContext")();return this.#r=!1,this.options.persister?this.options.persister(c,d,this):c(d)},"fetchFn"),a=r(()=>{let c={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#s,state:this.state,fetchFn:s};return i(c),c},"createFetchContext")();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:"fetch",meta:a.fetchOptions?.meta}),this.#i=Mn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:r(c=>{c instanceof _n&&c.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},"onCancel"),onFail:r((c,l)=>{this.#c({type:"failed",failureCount:c,error:l})},"onFail"),onPause:r(()=>{this.#c({type:"pause"})},"onPause"),onContinue:r(()=>{this.#c({type:"continue"})},"onContinue"),retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:r(()=>!0,"canRun")});try{let c=await this.#i.start();if(c===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(c),this.#n.config.onSuccess?.(c,this),this.#n.config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof _n){if(c.silent)return this.#i.promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw this.#c({type:"error",error:c}),this.#n.config.onError?.(c,this),this.#n.config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}#c(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,...Dr(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),K.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 Dr(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}r(Dr,"successState");function Lr(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(Lr,"getDefaultState");var Ci=class extends Re{static{r(this,"QueryObserver")}constructor(e,t){super(),this.options=t,this.#e=e,this.#a=null,this.#r=Ct(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#s=void 0;#i;#o;#r;#a;#c;#h;#f;#u;#d;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),_r(this.#t,this.options)?this.#p():this.updateResult(),this.#w())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return xi(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return xi(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 ce(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&&!Ln(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let i=this.hasListeners();i&&Mr(this.#t,n,this.options,t)&&this.#p(),this.updateResult(),i&&(this.#t!==n||ce(this.options.enabled,this.#t)!==ce(t.enabled,this.#t)||Se(this.options.staleTime,this.#t)!==Se(t.staleTime,this.#t))&&this.#y();let s=this.#v();i&&(this.#t!==n||ce(this.options.enabled,this.#t)!==ce(t.enabled,this.#t)||s!==this.#l)&&this.#g(s)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Wl(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=Se(this.options.staleTime,this.#t);if(He.isServer()||this.#s.isStale||!bt(e))return;let n=Dn(this.#s.dataUpdatedAt,e)+1;this.#u=ke.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.#l=e,!(He.isServer()||ce(this.options.enabled,this.#t)===!1||!bt(this.#l)||this.#l===0)&&(this.#d=ke.setInterval(()=>{(this.options.refetchIntervalInBackground||et.isFocused())&&this.#p()},this.#l))}#w(){this.#y(),this.#g(this.#v())}#b(){this.#u&&(ke.clearTimeout(this.#u),this.#u=void 0)}#I(){this.#d&&(ke.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,l=e!==n?e.state:this.#n,{state:d}=e,p={...d},f=!1,h;if(t._optimisticResults){let q=this.hasListeners(),j=!q&&_r(e,t),le=q&&Mr(e,n,t,i);(j||le)&&(p={...p,...Si(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(p.fetchStatus="idle")}let{error:y,errorUpdatedAt:g,status:v}=p;h=p.data;let I=!1;if(t.placeholderData!==void 0&&h===void 0&&v==="pending"){let q;s?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(q=s.data,I=!0):q=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,q!==void 0&&(v="success",h=St(s?.data,q,t),f=!0)}if(t.select&&h!==void 0&&!I)if(s&&h===o?.data&&t.select===this.#c)h=this.#h;else try{this.#c=t.select,h=t.select(h),h=St(s?.data,h,t),this.#h=h,this.#a=null}catch(q){this.#a=q}this.#a&&(y=this.#a,h=this.#h,g=Date.now(),v="error");let S=p.fetchStatus==="fetching",R=v==="pending",P=v==="error",D=R&&S,k=h!==void 0,M={status:v,fetchStatus:p.fetchStatus,isPending:R,isSuccess:v==="success",isError:P,isInitialLoading:D,isLoading:D,data:h,dataUpdatedAt:p.dataUpdatedAt,error:y,errorUpdatedAt:g,failureCount:p.fetchFailureCount,failureReason:p.fetchFailureReason,errorUpdateCount:p.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:p.dataUpdateCount>l.dataUpdateCount||p.errorUpdateCount>l.errorUpdateCount,isFetching:S,isRefetching:S&&!R,isLoadingError:P&&!k,isPaused:p.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:P&&k,isStale:Ei(e,t),refetch:this.refetch,promise:this.#r,isEnabled:ce(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let q=M.data!==void 0,j=M.status==="error"&&!q,le=r(Pe=>{j?Pe.reject(M.error):q&&Pe.resolve(M.data)},"finalizeThenableIfPossible"),_e=r(()=>{let Pe=this.#r=M.promise=Ct();le(Pe)},"recreateThenable"),me=this.#r;switch(me.status){case"pending":e.queryHash===n.queryHash&&le(me);break;case"fulfilled":(j||M.data!==me.value)&&_e();break;case"rejected":(!j||M.error!==me.reason)&&_e();break}}return M}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),Ln(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 c=a;return this.#s[c]!==e[c]&&o.has(c)})},"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){K.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Kl(e,t){return ce(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}r(Kl,"shouldLoadOnMount");function _r(e,t){return Kl(e,t)||e.state.data!==void 0&&xi(e,t,t.refetchOnMount)}r(_r,"shouldFetchOnMount");function xi(e,t,n){if(ce(t.enabled,e)!==!1&&Se(t.staleTime,e)!=="static"){let i=typeof n=="function"?n(e):n;return i==="always"||i!==!1&&Ei(e,t)}return!1}r(xi,"shouldFetchOn");function Mr(e,t,n,i){return(e!==t||ce(i.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ei(e,n)}r(Mr,"shouldFetchOptionally");function Ei(e,t){return ce(t.enabled,e)!==!1&&e.isStaleByTime(Se(t.staleTime,e))}r(Ei,"isStale");function Wl(e,t){return!Ln(e.getCurrentResult(),t)}r(Wl,"shouldAssignObserverCurrentProperties");function Ri(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||[],c={pages:[],pageParams:[]},l=0,d=r(async()=>{let p=!1,f=r(g=>{Rr(g,()=>t.signal,()=>p=!0)},"addSignalProperty"),h=On(t.options,t.fetchOptions),y=r(async(g,v,I)=>{if(p)return Promise.reject();if(v==null&&g.pages.length)return Promise.resolve(g);let R=r(()=>{let O={client:t.client,queryKey:t.queryKey,pageParam:v,direction:I?"backward":"forward",meta:t.options.meta};return f(O),O},"createQueryFnContext")(),P=await h(R),{maxPages:D}=t.options,k=I?Er:Cr;return{pages:k(g.pages,P,D),pageParams:k(g.pageParams,v,D)}},"fetchPage");if(s&&o.length){let g=s==="backward",v=g?Xl:qr,I={pages:o,pageParams:a},S=v(i,I);c=await y(I,S,g)}else{let g=e??o.length;do{let v=l===0?a[0]??i.initialPageParam:qr(i,c);if(l>0&&v==null)break;c=await y(c,v),l++}while(l<g)}return c},"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(Ri,"infiniteQueryBehavior");function qr(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(qr,"getNextPageParam");function Xl(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}r(Xl,"getPreviousPageParam");var Fr=class extends qn{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||Jl(),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=Mn({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),K.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function Jl(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}r(Jl,"getDefaultState");var Br=class extends Re{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 Fr({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=Fn(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=Fn(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=Fn(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=Fn(e);return typeof t=="string"?this.#t.get(t)?.find(i=>i!==e&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){K.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=>gi(t,n))}findAll(e={}){return this.getAll().filter(t=>gi(e,t))}notify(e){K.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return K.batch(()=>Promise.all(e.map(t=>t.continue().catch(z))))}};function Fn(e){return e.options.scope?.id}r(Fn,"scopeFor");var Nr=class extends Re{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??It(i,t),o=this.get(s);return o||(o=new Or({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(){K.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=>vi(t,n))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(n=>vi(e,n)):t}notify(e){K.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){K.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){K.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var ki=class{static{r(this,"QueryClient")}#e;#t;#n;#s;#i;#o;#r;#a;constructor(e={}){this.#e=e.queryCache||new Nr,this.#t=e.mutationCache||new Br,this.#n=e.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#r=et.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=it.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(Se(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=Ir(t,o);if(a!==void 0)return this.#e.build(this,i).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return K.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;K.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){let n=this.#e;return K.batch(()=>(n.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},i=K.batch(()=>this.#e.findAll(e).map(s=>s.cancel(n)));return Promise.all(i).then(z).catch(z)}invalidateQueries(e,t={}){return K.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=K.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(Se(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=Ri(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(z).catch(z)}ensureInfiniteQueryData(e){return e.behavior=Ri(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return it.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(tt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#s.values()],n={};return t.forEach(i=>{nt(e,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(tt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(i=>{nt(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=It(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===xt&&(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 jr(){return new ki({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,gcTime:1e3*60*60*1,staleTime:1e3*60*10}}})}r(jr,"createSwishQueryClient");var Yl="swish-query-cache";function Zl(e){return e.replace(/\.myshopify\.com$/,"")||"unknown-store"}r(Zl,"normalizeStoreKeyPart");function Bn({customerId:e,storeDomain:t}){let n=e??"guest",i=Zl(t??"");return`${Yl}:${i}:${n}`}r(Bn,"getSwishQueryStorageKey");var eu=1e3*60*60*24,tu=1e3;function Ai(){return!!globalThis.window?.localStorage}r(Ai,"canUseLocalStorage");function nu(e){if(!Ai())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(nu,"readPersistedState");function iu(e,t){if(Ai())try{globalThis.window.localStorage.setItem(e,JSON.stringify(t))}catch{}}r(iu,"writePersistedState");function su(e){if(Ai())try{globalThis.window.localStorage.removeItem(e)}catch{}}r(su,"removePersistedState");function ru(e,t){return Number.isFinite(e.timestamp)?Date.now()-e.timestamp>t:!0}r(ru,"isPersistedStateExpired");function Ur({queryClient:e,cacheBuster:t,customerId:n,storeDomain:i,maxAgeMs:s=eu,throttleMs:o=tu}){let a=Bn({customerId:n,storeDomain:i}),c=L(!1),l=nu(a);l?.buster===t&&!ru(l,s)?bi(e,l.clientState):l&&su(a),c.value=!0;let d=null,p=!1,f=r(()=>{iu(a,{buster:t,timestamp:Date.now(),clientState:wi(e)})},"persistNow"),h=r(()=>{p=!0,!d&&(d=setTimeout(()=>{d=null,p&&(p=!1,f())},Math.max(o,0)))},"schedulePersist"),y=r(()=>{p&&(p=!1,d&&(clearTimeout(d),d=null),f())},"flushPersist"),g=e.getQueryCache().subscribe(I=>{c.value&&h()}),v=r(()=>{y()},"onPageHide");return globalThis.window?.addEventListener("pagehide",v),{restored:c,storageKey:a,dispose:r(()=>{globalThis.window?.removeEventListener("pagehide",v),g(),y()},"dispose")}}r(Ur,"initSwishQueryPersistence");function Vr({events:e,cacheBuster:t,customerId:n,storeDomain:i}){let s=jr(),o=Ur({queryClient:s,cacheBuster:t,customerId:n,storeDomain:i});return yr({events:e,queryClient:s}),{client:s,cacheBuster:t,restored:o.restored,storageKey:o.storageKey,keys:{items:Tn}}}r(Vr,"createSwishQuery");var $r=r(e=>L({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"),Hr=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:c,itemId:l}=s?t.dataset:{},f=!!(a||o)||!!l,h=L({loading:!1,productHandle:o,productId:a,variantId:c,itemId:l});if(!f&&(n||i)){let y=t.href,g=ut(y);g?.productHandle&&g.productHandle!==h.value.productHandle&&(h.value={...h.value,...g,productId:void 0},Rs({source:t,onProductUrlChange:r(v=>{h.value={...h.value,...v,productId:v.productHandle===h.value.productHandle?h.value.productId:void 0}},"onProductUrlChange")}))}return X(()=>{h.value.loading||!h.value.productId&&h.value.productHandle&&(h.value={...h.value,loading:!0},e.storefront.loadProductId({productHandle:h.value.productHandle}).then(y=>{y.errors&&console.error("Error loading product id",y.errors);let g=y.data?.product?.id?F(y.data.product.id):void 0;h.value={...h.value,productId:g,loading:!g}}))}),h},"itemContextSignal");function Qr({queryClient:e,options:t,restored:n}){let i=L(null),s=L(!1),o=L(null),a=L(!1),c=r(g=>{let v=n?.value??!0,I=g.enabled??!0;return{...g,enabled:!!(I&&v)}},"getObserverOptions"),l=new Ci(e,c(t.value)),d=r(g=>{ee(()=>{i.value=g.data??null,s.value=g.isLoading,a.value=g.isRefetching,o.value=g.error??null})},"syncResult"),p=l.subscribe(d);d(l.getCurrentResult());let f=X(()=>{l.setOptions(c(t.value))}),h=!1;return{data:i,loading:s,error:o,refetching:a,refetch:r(()=>l.refetch(),"refetch"),dispose:r(()=>{h||(h=!0,f(),p(),l.destroy())},"dispose")}}r(Qr,"createTanstackQuerySignal");var Pi=50;function Gr(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(Gr,"arraysShallowEqual");function ou(e,t,n){if(n==="variant"||n==="auto"&&!!t){if(!t)return null;let s=F(t);return e.find(o=>String(o.variantId)===s)??null}return e[0]??null}r(ou,"pickSavedItem");function au(e){ee(()=>{if(e.savedItemsLoading.value=e.apiLoading,e.savedItemsError.value=e.apiError,e.forcedItemId){let o=[e.forcedItemId];Gr(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>=Pi&&console.warn(`[swish] item-state query hit the per-product limit (${Pi}). Some saved items may be missing.`);let n=t.map(o=>o.id);Gr(e.savedItemIds.value,n)||(e.savedItemIds.value=n);let s=ou(t,e.variantId,e.policy)?.id??null;s!==e.savedItemId.value&&(e.savedItemId.value=s)})}r(au,"syncFromApi");var zr=r(e=>(t,n={})=>{let i=[],s={onSave:n.onSave,onUnsave:n.onUnsave,onListsUpdate:n.onListsUpdate,onVariantUpdate:n.onVariantUpdate},o=L(n.match??"auto"),a=r($=>{s.onSave=$.onSave,s.onUnsave=$.onUnsave,s.onListsUpdate=$.onListsUpdate,s.onVariantUpdate=$.onVariantUpdate;let W=$.match??"auto";o.value!==W&&(o.value=W)},"setOptions"),c=re(()=>{let{productId:$,loading:W}=t.value;return!$||W?null:`product:${F($)}`}),l=re(()=>t.value.loading||!!t.value.itemId||!t.value.productId),d=L(!l.value),p=L(null),f=L(!1),h=L(!1),y=L(!1),g=re(()=>f.value||h.value||y.value),v=L(!1),I=L(!1),S=re(()=>{let $=c.value,W=l.value,{productId:de}=t.value;return{queryKey:e.query.keys.items({productId:de}),queryFn:r(async()=>{let ge=await e.api.items.list({limit:Pi,query:$??void 0},{batch:!0});if("error"in ge)throw ge.error;return ge},"queryFn"),enabled:!W}}),{data:R,loading:P,error:D,refetching:k,dispose:O}=Qr({queryClient:e.query.client,options:S,restored:e.query.restored});i.push(O);let M=t.value.itemId??null,q=L(M),j=L(M?[M]:[]),le=X(()=>au({apiData:R.value,apiLoading:P.value,apiError:D.value,forcedItemId:t.value.itemId,variantId:t.value.variantId,policy:o.value,savedItemId:q,savedItemIds:j,savedItemsLoading:d,savedItemsError:p}));i.push(le);async function _e(){if(!q.value)return;ee(()=>{h.value=!0,I.value=!0});let W=await(await e.intents.invoke("unsave:item",{itemId:q.value})).complete;if(W.code==="ok"){let de=W.data;"itemId"in de?(ee(()=>{q.value=null,h.value=!1}),s.onUnsave?.(de)):h.value=!1}else ee(()=>{h.value=!1,I.value=!1})}r(_e,"unsave");async function me(){if(!q.value)return;y.value=!0;let W=await(await e.intents.invoke("edit:item-lists",{itemId:q.value})).complete;if(W.code==="ok"){let de=W.data;"itemId"in de?(q.value=null,s.onUnsave?.(de)):s.onListsUpdate?.(de)}y.value=!1}r(me,"updateLists");async function Pe(){if(!q.value)return;let{productId:$,variantId:W}=t.value;if(!$)return;y.value=!0;let ge=await(await e.intents.invoke("edit:item-variant",{itemId:q.value,productId:$,variantId:W})).complete;ge.code==="ok"&&s.onVariantUpdate?.(ge.data),y.value=!1}r(Pe,"updateVariant");async function Ce(){let{productId:$,variantId:W}=t.value;if(!$)return;let de=o.value==="product"?void 0:W;ee(()=>{f.value=!0,v.value=!0});let Rt=await(await e.intents.invoke("save:item",{productId:$,variantId:de})).complete;if(Rt.code==="ok"){let os=Rt.data;ee(()=>{q.value=os.item.id,f.value=!1}),s.onSave?.(os)}else Rt.code==="error"&&console.warn("Failed to create item",Rt),ee(()=>{f.value=!1,v.value=!1})}r(Ce,"save");let st=re(()=>d.value||g.value||t.value.loading),ue=X(()=>{(v.value||I.value)&&!g.value&&!k.value&&ee(()=>{v.value=!1,I.value=!1})});i.push(ue);let Me=re(()=>{let $=!!q.value,W=f.value||k.value&&v.value,de=h.value||k.value&&I.value,ge="unsaved";return $?ge="saved":W&&(ge="saving"),{error:p.value,status:ge,savedItemId:q.value,savedItemIds:j.value,loading:st.value,submitting:g.value,saved:$,saving:W,unsaving:de}});async function Ko(){st.value||(Me.value.saved&&Me.value.savedItemId?await _e():Me.value.saved||await Ce())}return r(Ko,"toggle"),Object.assign(Me,{save:Ce,unsave:_e,updateLists:me,updateVariant:Pe,update:me,toggle:Ko,setOptions:a,setCallbacks:a,dispose:r(()=>{for(;i.length;)i.pop()?.()},"dispose")})},"itemStateSignal");var Kr=r(e=>()=>{let{data:t,loading:n,error:i}=e.state.swishQuery(()=>e.api.items.count(),{refetch:["item-create","item-delete"]}),s=L(0),o=L(!0),a=L(null);return X(()=>{ee(()=>{o.value=n.value,a.value=i.value,s.value=t.value?.count??0})}),re(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var cu="token-update",Wr=r(e=>(t,n)=>{let i=L(null),s=L(null),o=L(null),a=L(!n?.skip),c=L(!1),l=re(()=>a.value&&c.value);async function d(){if(!n?.skip?.value)try{a.value=!0;let p=await t(n?.variables?.value);ee(()=>{o.value="error"in p?p.error:null,i.value="data"in p?p.data:null,s.value="pageInfo"in p?p.pageInfo:null,a.value=!1,c.value=!0})}catch(p){ee(()=>{o.value=p,a.value=!1,c.value=!0})}}return r(d,"executeFetch"),X(()=>{if(d(),n?.refetch?.length){let p=[...n.refetch,cu];return e.events.subscribe(p,d)}}),{data:i,pageInfo:s,error:o,loading:a,refetching:l}},"swishQuerySignals");var Qe="GraphQL Client";var Ti="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",Di="Response returned unexpected Content-Type:",Li="An unknown error has occurred. The API did not return a data object or any errors in its response.",Nn={json:"application/json",multipart:"multipart/mixed"},Oi="X-SDK-Variant",_i="X-SDK-Version",Jr="shopify-graphql-client",Yr="1.4.2",jn=1e3,Zr=[429,503],Mi=/@(defer)\b/i,Xr=`\r
8
- `,eo=/boundary="?([^=";]+)"?/i,qi=Xr+Xr;function xe(e,t=Qe){return e.startsWith(`${t}`)?e:`${t}: ${e}`}r(xe,"formatErrorMessage");function Ae(e){return e instanceof Error?e.message:JSON.stringify(e)}r(Ae,"getErrorMessage");function Fi(e){return e instanceof Error&&e.cause?e.cause:void 0}r(Fi,"getErrorCause");function Bi(e){return e.flatMap(({errors:t})=>t??[])}r(Bi,"combineErrors");function Un({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(Un,"validateRetries");function se(e,t){return t&&(typeof t!="object"||Array.isArray(t)||typeof t=="object"&&Object.keys(t).length>0)?{[e]:t}:{}}r(se,"getKeyValueIfValid");function Ni(e,t){if(e.length===0)return t;let i={[e.pop()]:t};return e.length===0?i:Ni(e,i)}r(Ni,"buildDataObjectByPath");function io(e,t){return Object.keys(t||{}).reduce((n,i)=>(typeof t[i]=="object"||Array.isArray(t[i]))&&e[i]?(n[i]=io(e[i],t[i]),n):(n[i]=t[i],n),Array.isArray(e)?[...e]:{...e})}r(io,"combineObjects");function ji([e,...t]){return t.reduce(io,{...e})}r(ji,"buildCombinedDataObject");function Ui({clientLogger:e,customFetchApi:t=fetch,client:n=Qe,defaultRetryWaitTime:i=jn,retriableCodes:s=Zr}){let o=r(async(a,c,l)=>{let d=c+1,p=l+1,f;try{if(f=await t(...a),e({type:"HTTP-Response",content:{requestParams:a,response:f}}),!f.ok&&s.includes(f.status)&&d<=p)throw new Error;let h=f?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return h&&e({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:h}}),f}catch(h){if(d<=p){let y=f?.headers.get("Retry-After");return await lu(y?parseInt(y,10):i),e({type:"HTTP-Retry",content:{requestParams:a,lastResponse:f,retryAttempt:c,maxRetries:l}}),o(a,d,l)}throw new Error(xe(`${l>0?`Attempted maximum number of ${l} network retries. Last message - `:""}${Ae(h)}`,n))}},"httpFetch");return o}r(Ui,"generateHttpFetch");async function lu(e){return new Promise(t=>setTimeout(t,e))}r(lu,"sleep");function Vi({headers:e,url:t,customFetchApi:n=fetch,retries:i=0,logger:s}){Un({client:Qe,retries:i});let o={headers:e,url:t,retries:i},a=uu(s),c=Ui({customFetchApi:n,clientLogger:a,defaultRetryWaitTime:jn}),l=du(c,o),d=pu(l),p=wu(l);return{config:o,fetch:l,request:d,requestStream:p}}r(Vi,"createGraphQLClient");function uu(e){return t=>{e&&e(t)}}r(uu,"generateClientLogger");async function so(e){let{errors:t,data:n,extensions:i}=await e.json();return{...se("data",n),...se("extensions",i),headers:e.headers,...t||!n?{errors:{networkStatusCode:e.status,message:xe(t?Ti:Li),...se("graphQLErrors",t),response:e}}:{}}}r(so,"processJSONResponse");function du(e,{url:t,headers:n,retries:i}){return async(s,o={})=>{let{variables:a,headers:c,url:l,retries:d,keepalive:p,signal:f}=o,h=JSON.stringify({query:s,variables:a});Un({client:Qe,retries:d});let y=Object.entries({...n,...c}).reduce((v,[I,S])=>(v[I]=Array.isArray(S)?S.join(", "):S.toString(),v),{});return!y[Oi]&&!y[_i]&&(y[Oi]=Jr,y[_i]=Yr),e([l??t,{method:"POST",headers:y,body:h,signal:f,keepalive:p}],1,d??i)}}r(du,"generateFetch");function pu(e){return async(...t)=>{if(Mi.test(t[0]))throw new Error(xe("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(Nn.json)?await so(n):{errors:{networkStatusCode:i,message:xe(`${Di} ${o}`),response:n}}:{errors:{networkStatusCode:i,message:xe(s),response:n}}}catch(i){return{errors:{message:Ae(i),...n==null?{}:{networkStatusCode:n.status,response:n}}}}}}r(pu,"generateRequest");async function*hu(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(hu,"getStreamBodyIterator");function fu(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(c=>c.trim().length>0).map(c=>c.slice(c.indexOf(qi)+qi.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 - ${Ae(n)}`)}}}}r(fu,"readStreamChunk");function mu(e){return{async*[Symbol.asyncIterator](){try{yield{...await so(e),hasNext:!1}}catch(t){yield{errors:{message:xe(Ae(t)),networkStatusCode:e.status,response:e},hasNext:!1}}}}}r(mu,"createJsonResponseAsyncIterator");function yu(e){return e.map(t=>{try{return JSON.parse(t)}catch(n){throw new Error(`Error in parsing multipart response - ${Ae(n)}`)}}).map(t=>{let{data:n,incremental:i,hasNext:s,extensions:o,errors:a}=t;if(!i)return{data:n||{},...se("errors",a),...se("extensions",o),hasNext:s};let c=i.map(({data:l,path:d,errors:p})=>({data:l&&d?Ni(d,l):{},...se("errors",p)}));return{data:c.length===1?c[0].data:ji([...c.map(({data:l})=>l)]),...se("errors",Bi(c)),hasNext:s}})}r(yu,"getResponseDataFromChunkBodies");function vu(e,t){if(e.length>0)throw new Error(Ti,{cause:{graphQLErrors:e}});if(Object.keys(t).length===0)throw new Error(Li)}r(vu,"validateResponseData");function gu(e,t){let n=(t??"").match(eo),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=hu(e),o={},a;return{async*[Symbol.asyncIterator](){try{let c=!0;for await(let l of fu(s,i)){let d=yu(l);a=d.find(f=>f.extensions)?.extensions??a;let p=Bi(d);o=ji([o,...d.map(({data:f})=>f)]),c=d.slice(-1)[0].hasNext,vu(p,o),yield{...se("data",o),...se("extensions",a),hasNext:c}}if(c)throw new Error("Response stream terminated unexpectedly")}catch(c){let l=Fi(c);yield{...se("data",o),...se("extensions",a),errors:{message:xe(Ae(c)),networkStatusCode:e.status,...se("graphQLErrors",l?.graphQLErrors),response:e},hasNext:!1}}}}}r(gu,"createMultipartResponseAsyncInterator");function wu(e){return async(...t)=>{if(!Mi.test(t[0]))throw new Error(xe("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(Nn.json):return mu(n);case s.includes(Nn.multipart):return gu(n,s);default:throw new Error(`${Di} ${s}`,{cause:n})}}catch(n){return{async*[Symbol.asyncIterator](){let i=Fi(n);yield{errors:{message:xe(Ae(n)),...se("networkStatusCode",i?.status),...se("response",i)},hasNext:!1}}}}}}r(wu,"generateRequestStream");function $i({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($i,"validateDomainAndGetStoreUrl");function Vn({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(Vn,"validateApiVersion");function $n(e){let t=e*3-2;return t===10?t:`0${t}`}r($n,"getQuarterMonth");function Hi(e,t,n){let i=t-n;return i<=0?`${e-1}-${$n(i+4)}`:`${e}-${$n(i)}`}r(Hi,"getPrevousVersion");function ro(){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(ro,"getCurrentApiVersion");function Qi(){let{year:e,quarter:t,version:n}=ro(),i=t===4?`${e+1}-01`:`${e}-${$n(t+1)}`;return[Hi(e,t,3),Hi(e,t,2),Hi(e,t,1),n,i,"unstable"]}r(Qi,"getCurrentSupportedApiVersions");function Gi(e){return t=>({...t??{},...e.headers})}r(Gi,"generateGetHeaders");function zi({getHeaders:e,getApiUrl:t}){return(n,i)=>{let s=[n];if(i&&Object.keys(i).length>0){let{variables:o,apiVersion:a,headers:c,retries:l,signal:d}=i;s.push({...o?{variables:o}:{},...c?{headers:e(c)}:{},...a?{url:t(a)}:{},...l?{retries:l}:{},...d?{signal:d}:{}})}return s}}r(zi,"generateGetGQLClientParams");var Ki="application/json",oo="storefront-api-client",ao="1.0.10",co="X-Shopify-Storefront-Access-Token",lo="Shopify-Storefront-Private-Token",uo="X-SDK-Variant",po="X-SDK-Version",ho="X-SDK-Variant-Source",Ge="Storefront API Client";function fo(e){if(e&&typeof window<"u")throw new Error(`${Ge}: 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(fo,"validatePrivateAccessTokenUsage");function mo(e,t){if(!e&&!t)throw new Error(`${Ge}: a public or private access token must be provided`);if(e&&t)throw new Error(`${Ge}: only provide either a public or private access token`)}r(mo,"validateRequiredAccessTokens");function Wi({storeDomain:e,apiVersion:t,publicAccessToken:n,privateAccessToken:i,clientName:s,retries:o=0,customFetchApi:a,logger:c}){let l=Qi(),d=$i({client:Ge,storeDomain:e}),p={client:Ge,currentSupportedApiVersions:l,logger:c};Vn({...p,apiVersion:t}),mo(n,i),fo(i);let f=bu(d,t,p),h={storeDomain:d,apiVersion:t,...n?{publicAccessToken:n}:{privateAccessToken:i},headers:{"Content-Type":Ki,Accept:Ki,[uo]:oo,[po]:ao,...s?{[ho]:s}:{},...n?{[co]:n}:{[lo]:i}},apiUrl:f(),clientName:s},y=Vi({headers:h.headers,url:h.apiUrl,retries:o,customFetchApi:a,logger:c}),g=Gi(h),v=Iu(h,f),I=zi({getHeaders:g,getApiUrl:v});return Object.freeze({config:h,getHeaders:g,getApiUrl:v,fetch:r((...R)=>y.fetch(...I(...R)),"fetch"),request:r((...R)=>y.request(...I(...R)),"request"),requestStream:r((...R)=>y.requestStream(...I(...R)),"requestStream")})}r(Wi,"createStorefrontApiClient");function bu(e,t,n){return i=>{i&&Vn({...n,apiVersion:i});let s=(i??t).trim();return`${e}/api/${s}/graphql.json`}}r(bu,"generateApiUrlFormatter");function Iu(e,t){return n=>n?t(n):e.apiUrl}r(Iu,"generateGetApiUrl");var Hn=`
7
+ `+String(i)));rs(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){ss(e,t,i)})}r(Vp,"dispatchBatch");function ss(e,t,n){rs(t);for(var i=0;i<t.keys.length;i++)e.clear(t.keys[i]),t.callbacks[i].reject(n)}r(ss,"failedDispatch");function rs(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}r(rs,"resolveCacheHits");function $p(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($p,"getValidMaxBatchSize");function Hp(e){var t=e&&e.batchScheduleFn;if(t===void 0)return jp;if(typeof t!="function")throw new TypeError("batchScheduleFn must be a function: "+t);return t}r(Hp,"getValidBatchScheduleFn");function Qp(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(Qp,"getValidCacheKeyFn");function Gp(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(Gp,"getValidCacheMap");function zp(e){return e&&e.name?e.name:null}r(zp,"getValidName");function $o(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($o,"isArrayLike");Ho.exports=Np});function ls(e,t="",n=new Map){for(let[i,s]of Object.entries(e)){let o=t?`${t}.${i}`:i;typeof s=="object"&&s!==null?ls(s,o,n):typeof s=="string"&&n.set(o,s)}return n}r(ls,"c");var sa=new Set(["en","de","fi","ru","sv","pl"]),rt="en";function us(e,t){return t?.count===void 0?e:t.count===1?`${e}One`:`${e}Other`}r(us,"d");function cs(e,t,n){t=us(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(cs,"g");function ds(e,t){let n=null;async function i(o){let a=await import(`${e}/locales/${o.toLowerCase()}.js`);return ls(a.default)}r(i,"a");function s(o,a){return n?n.has(us(o,a))?{status:"ready",value:cs(n,o,a),key:o}:{status:"missing",value:cs(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;sa.has(o)||(console.warn(`[swish] Unsupported language "${o}", falling back to "${rt}".`),a=rt);let c;try{c=await i(a)}catch(l){if(console.warn(`[swish-i18n] Failed to load locale "${a}".`,l),a!==rt)try{c=await i(rt)}catch{console.warn(`[swish] Failed to load fallback locale "${rt}".`);return}else return}if(t?.[a])for(let[l,d]of Object.entries(t[a]))d!==void 0&&c.set(l,d);n=c}}}r(ds,"L");var F=r(e=>e.split("/").pop()??"","shopifyGidToId"),we=r((e,t)=>typeof t=="string"&&t.startsWith("gid://shopify/")?t:`gid://shopify/${e}/${t}`,"shopifyIdToGid"),pe=r(e=>e.toLowerCase().replace(".myshopify.com",""),"toShopName");var Te=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 c=await fetch(t,n);return c.ok&&await this.set(s,c.clone(),i??this.defaultCacheControl),c})().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),c=await crypto.subtle.digest("SHA-256",a);return`/${Array.from(new Uint8Array(c)).map(p=>p.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(),l=(Date.now()-a)/1e3,d=i+(s??0);return l>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(),l=(Date.now()-a)/1e3;return l>i&&l<=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 kt=class{static{r(this,"AjaxApiClient")}constructor(t){this.config=t;let n=pe(t.storeDomain);this.cache=new Te(`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(c=>n(c,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 fetchProduct(t){return this.request(`/products/${t}.js`)}async addToCart(t){let n={...t,items:t.items.map(i=>{let s=Number(F(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 updateCartAttributes(t){return this.request("/cart/update.js",{method:"POST",body:JSON.stringify({attributes:t})})}async clearCache(){await this.cache.clear()}};var At=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-change"||i==="cart-update"){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){if(!Array.isArray(t.items))return[];if(this.previousCart){let i=new Set(t.items.map(s=>s.key));return this.previousCart.items.filter(s=>!i.has(s.key)).map(s=>this.toCartChangeItem(s))}let n=new Set(t.items.map(i=>i.variant_id));return(t.items_removed??[]).filter(i=>!n.has(i.variant_id))}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 Zn="_swish",Pt=class{static{r(this,"CheckoutBridge")}constructor(t){this.api=t.api,this.ajax=t.ajax,this.events=t.events,this.context=t.context,this.preRelease=t.preRelease}listen(){this.api.initAuth().then(()=>this.sync()),this.events.subscribe("cart-add",()=>{this.write()}),this.events.subscribe(["cart-update","cart-change"],t=>{let n=t.detail;!n||n.item_count<=0||this.write(n.attributes?.[Zn])}),this.events.subscribe("token-update",()=>{this.sync()})}async sync(){try{let t=await this.ajax.fetchCart();if(!t||t.item_count<=0)return;await this.write(t.attributes?.[Zn])}catch(t){console.warn("Failed to sync Swish checkout bridge",t)}}composeValue(){let t=this.api.getAuthToken();if(!t)return null;let{country:n,language:i}=this.context.localization;return JSON.stringify({t,c:n,l:i,pr:this.preRelease,r:this.context.routes.rootUrl})}async write(t){let n=this.composeValue();if(!(!n||t===n))try{await this.ajax.updateCartAttributes({[Zn]:n})}catch(i){console.warn("Failed to write Swish checkout bridge attribute",i)}}};var hs="swish:customiser:mounted",Tt="swish-customiser",ra="https://swish.app/cdn",oa=r(e=>{try{return window.sessionStorage?.getItem(e)==="1"}catch{return!1}},"readFlag"),aa=r((e,t)=>{try{t?window.sessionStorage?.setItem(e,"1"):window.sessionStorage?.removeItem(e)}catch{}},"writeFlag"),fs=r(()=>oa(hs),"readSticky"),ei=r(e=>aa(hs,e),"writeSticky"),ca=r(()=>{let e=new URLSearchParams(window.location.search);if(!e.has(Tt))return;e.delete(Tt);let t=e.toString(),n=window.location.pathname+(t?`?${t}`:"")+window.location.hash;window.history.replaceState(null,"",n)},"scrubLaunchParam"),la=r(()=>{let e=window.Shopify?.theme?.id;return e===void 0?void 0:String(e)},"readThemeId"),ms=r(()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).has(Tt)||fs(),"isCustomiserRequested"),ua=r(e=>`${e.endsWith("/")?e.slice(0,-1):e}/customiser@${he}/`,"customiserDirUrl"),ys=r((e,t={})=>{if(typeof window>"u")return;let i=new URLSearchParams(window.location.search).has(Tt),s=fs();if(!i&&!s)return;i&&(ca(),ei(!0));let o=ua(t.baseUrl??ra);import(`${o}sdk.js`).then(a=>{a.mountCustomiser(e,{shop:t.shop,themeId:la(),appUrl:o,onClose:r(()=>{ei(!1),window.location.reload()},"onClose")})}).catch(a=>{console.error("[swish] failed to load customiser SDK bundle",a),ei(!1),window.location.reload()})},"loadCustomiserIfRequested");function da(){let e=document.body||document.documentElement;return e?Promise.resolve(e):new Promise(t=>{window.addEventListener("DOMContentLoaded",()=>t(e))})}r(da,"waitForDOM");function ot({onElementFound:e,selector:t,observerOptions:n,mustMatch:i}){let s=new WeakSet,o=new MutationObserver(d=>{let p=!1;for(let f of d)if(f.addedNodes.length>0){p=!0;break}p&&a()}),a=r(()=>{document.querySelectorAll(t).forEach(d=>{s.has(d)||(s.add(d),i?.(d)!==!1&&c(d))})},"locateElements"),c=r(d=>{if(!n){e(d);return}let p=new IntersectionObserver(f=>{for(let h of f)h.isIntersecting&&(p.disconnect(),e(d))},n);p.observe(d)},"observeElement");return r(async()=>{let d=await da();a(),o.observe(d,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}r(ot,"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 Ke(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(Ke,"findNearestElement");function vs({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(vs,"createHrefObserver");var pa=Symbol.for("preact-signals");function _t(){if(De>1)De--;else{var e,t=!1;for((function(){var s=Lt;for(Lt=void 0;s!==void 0;)s.S.v===s.v&&(s.S.i=s.i),s=s.o})();at!==void 0;){var n=at;for(at=void 0,Dt++;n!==void 0;){var i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&bs(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=i}}if(Dt=0,De--,t)throw e}}r(_t,"t");function ee(e){if(De>0)return e();ti=++ha,De++;try{return e()}finally{_t()}}r(ee,"n");var B=void 0;function ni(e){var t=B;B=void 0;try{return e()}finally{B=t}}r(ni,"o");var gs,at=void 0,De=0,Dt=0,ha=0,ti=0,Lt=void 0,Ot=0;function ws(e){if(B!==void 0){var t=e.n;if(t===void 0||t.t!==B)return t={i:0,S:e,p:B.s,n:void 0,t:B,e:void 0,x:void 0,r:t},B.s!==void 0&&(B.s.n=t),B.s=t,e.n=t,32&B.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=B.s,t.n=void 0,B.s.n=t,B.s=t),t}}r(ws,"a");function te(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(te,"l");te.prototype.brand=pa;te.prototype.h=function(){return!0};te.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:ni(function(){var i;(i=t.W)==null||i.call(t)}))};te.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&&ni(function(){var s;(s=t.Z)==null||s.call(t)}))}};te.prototype.subscribe=function(e){var t=this;return X(function(){var n=t.value,i=B;B=void 0;try{e(n)}finally{B=i}},{name:"sub"})};te.prototype.valueOf=function(){return this.value};te.prototype.toString=function(){return this.value+""};te.prototype.toJSON=function(){return this.value};te.prototype.peek=function(){var e=this;return ni(function(){return e.value})};Object.defineProperty(te.prototype,"value",{get:r(function(){var e=ws(this);return e!==void 0&&(e.i=this.i),this.v},"get"),set:r(function(e){if(e!==this.v){if(Dt>100)throw new Error("Cycle detected");(function(n){De!==0&&Dt===0&&n.l!==ti&&(n.l=ti,Lt={S:n,v:n.v,i:n.i,o:Lt})})(this),this.v=e,this.i++,Ot++,De++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{_t()}}},"set")});function L(e,t){return new te(e,t)}r(L,"y");function bs(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(bs,"w");function Is(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(Is,"_");function Ss(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(Ss,"b");function qe(e,t){te.call(this,void 0),this.x=e,this.s=void 0,this.g=Ot-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(qe,"p");qe.prototype=new te;qe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ot))return!0;if(this.g=Ot,this.f|=1,this.i>0&&!bs(this))return this.f&=-2,!0;var e=B;try{Is(this),B=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 B=e,Ss(this),this.f&=-2,!0};qe.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)}te.prototype.S.call(this,e)};qe.prototype.U=function(e){if(this.t!==void 0&&(te.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)}};qe.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(qe.prototype,"value",{get:r(function(){if(1&this.f)throw new Error("Cycle detected");var e=ws(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v},"get")});function re(e,t){return new qe(e,t)}r(re,"g");function xs(e){var t=e.m;if(e.m=void 0,typeof t=="function"){De++;var n=B;B=void 0;try{t()}catch(i){throw e.f&=-2,e.f|=8,ii(e),i}finally{B=n,_t()}}}r(xs,"S");function ii(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,xs(e)}r(ii,"m");function fa(e){if(B!==this)throw new Error("Out-of-order effect");Ss(this),B=e,this.f&=-2,8&this.f&&ii(this),_t()}r(fa,"x");function We(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,gs&&gs.push(this)}r(We,"E");We.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.m=t)}finally{e()}};We.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,xs(this),Is(this),De++;var e=B;return B=this,fa.bind(this,e)};We.prototype.N=function(){2&this.f||(this.f|=2,this.u=at,at=this)};We.prototype.d=function(){this.f|=8,1&this.f||ii(this)};We.prototype.dispose=function(){this.d()};function X(e,t){var n=new We(e,t);try{n.c()}catch(s){throw n.d(),s}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}r(X,"j");var ma="swish-save, swish-drawer";function Cs(e,t){return e.closest(ma)===t}r(Cs,"belongsToHost");function Mt(e,t){return X(()=>{let n=t();e.querySelectorAll("[data-swish-when]").forEach(s=>{if(!Cs(s,e))return;let a=!(s.dataset.swishWhen??"").split(",").map(c=>c.trim()).includes(n);s.hidden!==a&&(s.hidden=a)})})}r(Mt,"bindWhen");function Es(e,t,n){e.hidden&&(e.hidden=!1);let i=`[data-swish-bind="${t}"]`;return X(()=>{let s=n(),o=String(s);e.querySelectorAll(i).forEach(c=>{Cs(c,e)&&c.textContent!==o&&(c.textContent=o)})})}r(Es,"bindValue");var ya=["home","saves","lists","orders","notifications","profile"],va=["view"],ga=typeof HTMLElement<"u"?HTMLElement:class{},ct=class extends ga{constructor(){super(...arguments);this.disposers=[];this.clickHandler=r(n=>{n.stopPropagation(),n.preventDefault();let i=Fe(),s=this.resolveView();i.intents.invoke(`view:${s}`)},"clickHandler")}static{r(this,"SwishDrawerElement")}static get observedAttributes(){return[...va]}connectedCallback(){if(!this.isConnected)return;let n=Fe();this.bind(n),this.addEventListener("click",this.clickHandler)}disconnectedCallback(){this.removeEventListener("click",this.clickHandler),this.dispose()}bind(n){let i=n.state.itemCount(),s=n.state.effect(()=>{let{count:c,loading:l}=i.value;this.setAttribute("state",c>0?"has-saves":"empty"),!l&&!this.hasAttribute("ready")&&this.toggleAttribute("ready",!0)}),o=Es(this,"count",()=>i.value.count),a=Mt(this,()=>i.value.count>0?"has-saves":"empty");this.disposers.push(s,o,a)}dispose(){for(;this.disposers.length;)this.disposers.pop()?.()}resolveView(){let n=this.getAttribute("view");return n&&ya.includes(n)?n:(n&&console.warn(`[swish] <swish-drawer> view="${n}" is not a recognized view. Falling back to "home".`),"home")}};var wa=["product","variant","context","match"],ba="a[href*='/products/']";function Ia(e){if(e==="variant"||e==="product"||e==="auto")return e}r(Ia,"parseMatch");function Sa(e){return e==="product-card"?"product":"auto"}r(Sa,"defaultMatchForContext");var xa=typeof HTMLElement<"u"?HTMLElement:class{},lt=class extends xa{constructor(){super(...arguments);this.disposers=[];this.state=null;this.clickHandler=r(n=>{n.stopPropagation(),n.preventDefault(),this.state?.toggle()},"clickHandler")}static{r(this,"SwishSaveElement")}static get observedAttributes(){return[...wa]}connectedCallback(){if(!this.isConnected)return;let n=Fe();this.bind(n),this.addEventListener("click",this.clickHandler)}attributeChangedCallback(n,i,s){i===s||!this.isConnected||!this.state||this.rebind()}disconnectedCallback(){this.removeEventListener("click",this.clickHandler),this.dispose()}bind(n){let i=this.resolveContext(n),s=Ia(this.getAttribute("match"))??Sa(this.getAttribute("context"));this.state=n.state.itemState(i,{match:s});let o=n.state.effect(()=>{let c=this.state?.value;c&&(this.setAttribute("state",c.status),this.setAttribute("aria-pressed",String(c.saved)),!c.loading&&!this.hasAttribute("ready")&&this.toggleAttribute("ready",!0))}),a=Mt(this,()=>this.state?.value.status??"unsaved");this.disposers.push(()=>this.state?.dispose()),this.disposers.push(o),this.disposers.push(a)}rebind(){let n=Fe();this.dispose(),this.bind(n)}dispose(){for(;this.disposers.length;)this.disposers.pop()?.();this.state=null}resolveContext(n){let i=this.getAttribute("product"),s=this.getAttribute("variant");if(i)return n.state.itemContextFromIds({productId:i,variantId:s});let o=this.getAttribute("context");if(o==="pdp")return n.state.itemContext(window.location);if(o==="product-card"){let a=Ke(this,ba);if(a)return n.state.itemContext(a)}return n.state.itemContext(this)}};var si=null;function ri(e){si=e,!(typeof customElements>"u")&&(customElements.get("swish-save")||customElements.define("swish-save",lt),customElements.get("swish-drawer")||customElements.define("swish-drawer",ct))}r(ri,"initElements");function Fe(){if(!si)throw new Error("Swish is not initialized");return si}r(Fe,"getSwish");var qt=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 Ca=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,ut=r(e=>{let t=e.match(Ca);return t?{productHandle:decodeURIComponent(t[1]),variantId:t[2]}:null},"parseProductUrl"),Rs=r(({source:e,onProductUrlChange:t})=>{let n=r(i=>{let s=ut(i);s?.productHandle&&t(s)},"handleChange");if(e instanceof HTMLAnchorElement)return vs({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 Ft,Ea={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function oi(e){return!e&&!Ft?Ea:{lang:e?.lang??Ft?.lang,message:e?.message,abortEarly:e?.abortEarly??Ft?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Ft?.abortPipeEarly}}r(oi,"getGlobalConfig");var Ra;function ka(e){return Ra?.get(e)}r(ka,"getGlobalMessage");var Aa;function Pa(e){return Aa?.get(e)}r(Pa,"getSchemaMessage");var Ta;function Da(e,t){return Ta?.get(e)?.get(t)}r(Da,"getSpecificMessage");function dt(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(dt,"_stringify");function Y(e,t,n,i,s){let o=s&&"input"in s?s.input:n.value,a=s?.expected??e.expects??null,c=s?.received??dt(o),l={kind:e.kind,type:e.type,input:o,expected:a,received:c,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:s?.path,issues:s?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},d=e.kind==="schema",p=s?.message??e.message??Da(e.reference,l.lang)??(d?Pa(l.lang):null)??i.message??ka(l.lang);p!==void 0&&(l.message=typeof p=="function"?p(l):p),d&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}r(Y,"_addIssue");var ks=new WeakMap;function oe(e){let t=ks.get(e);return t||(t={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},oi())}},ks.set(e,t)),t}r(oe,"_getStandardProps");function La(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}r(La,"_isValidObjectKey");function ai(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}r(ai,"_joinExpects");var Oa=class extends Error{static{r(this,"ValiError")}constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ci(e){return{kind:"validation",type:"integer",reference:ci,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&Y(this,"integer",t,n),t}}}r(ci,"integer");function pt(e,t){return{kind:"validation",type:"min_length",reference:pt,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,i){return n.typed&&n.value.length<this.requirement&&Y(this,"length",n,i,{received:`${n.value.length}`}),n}}}r(pt,"minLength");function fe(e,t){return{kind:"validation",type:"min_value",reference:fe,async:!1,expects:`>=${e instanceof Date?e.toJSON():dt(e)}`,requirement:e,message:t,"~run"(n,i){return n.typed&&!(n.value>=this.requirement)&&Y(this,"value",n,i,{received:n.value instanceof Date?n.value.toJSON():dt(n.value)}),n}}}r(fe,"minValue");function N(e){return{kind:"transformation",type:"transform",reference:N,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}r(N,"transform");var _a={abortEarly:!0};function Ma(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}r(Ma,"getFallback");function Ps(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}r(Ps,"getDefault");function H(e,t){return{kind:"schema",type:"array",reference:H,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return oe(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],c=this.item["~run"]({value:a},i);if(c.issues){let l={type:"array",origin:"value",input:s,key:o,value:a};for(let d of c.issues)d.path?d.path.unshift(l):d.path=[l],n.issues?.push(d);if(n.issues||(n.issues=c.issues),i.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value.push(c.value)}}else Y(this,"type",n,i);return n}}}r(H,"array");function C(e){return{kind:"schema",type:"boolean",reference:C,expects:"boolean",async:!1,message:e,get"~standard"(){return oe(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:Y(this,"type",t,n),t}}}r(C,"boolean");function li(e,t){return{kind:"schema",type:"instance",reference:li,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return oe(this)},"~run"(n,i){return n.value instanceof this.class?n.typed=!0:Y(this,"type",n,i),n}}}r(li,"instance");function V(e,t){return{kind:"schema",type:"literal",reference:V,expects:dt(e),async:!1,literal:e,message:t,get"~standard"(){return oe(this)},"~run"(n,i){return n.value===this.literal?n.typed=!0:Y(this,"type",n,i),n}}}r(V,"literal");function A(e){return{kind:"schema",type:"number",reference:A,expects:"number",async:!1,message:e,get"~standard"(){return oe(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:Y(this,"type",t,n),t}}}r(A,"number");function b(e,t){return{kind:"schema",type:"object",reference:b,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return oe(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 c=o in s?s[o]:Ps(a),l=a["~run"]({value:c},i);if(l.issues){let d={type:"object",origin:"value",input:s,key:o,value:c};for(let p of l.issues)p.path?p.path.unshift(d):p.path=[d],n.issues?.push(p);if(n.issues||(n.issues=l.issues),i.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value[o]=l.value}else if(a.fallback!==void 0)n.value[o]=Ma(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(Y(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 Y(this,"type",n,i);return n}}}r(b,"object");function m(e,t){return{kind:"schema",type:"optional",reference:m,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return oe(this)},"~run"(n,i){return n.value===void 0&&(this.default!==void 0&&(n.value=Ps(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,i)}}}r(m,"optional");function ne(e,t){return{kind:"schema",type:"picklist",reference:ne,expects:ai(e.map(dt),"|"),async:!1,options:e,message:t,get"~standard"(){return oe(this)},"~run"(n,i){return this.options.includes(n.value)?n.typed=!0:Y(this,"type",n,i),n}}}r(ne,"picklist");function Z(e,t,n){return{kind:"schema",type:"record",reference:Z,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return oe(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){i.typed=!0,i.value={};for(let a in o)if(La(o,a)){let c=o[a],l=this.key["~run"]({value:a},s);if(l.issues){let p={type:"object",origin:"key",input:o,key:a,value:c};for(let f of l.issues)f.path=[p],i.issues?.push(f);if(i.issues||(i.issues=l.issues),s.abortEarly){i.typed=!1;break}}let d=this.value["~run"]({value:c},s);if(d.issues){let p={type:"object",origin:"value",input:o,key:a,value:c};for(let f of d.issues)f.path?f.path.unshift(p):f.path=[p],i.issues?.push(f);if(i.issues||(i.issues=d.issues),s.abortEarly){i.typed=!1;break}}(!l.typed||!d.typed)&&(i.typed=!1),l.typed&&(i.value[l.value]=d.value)}}else Y(this,"type",i,s);return i}}}r(Z,"record");function x(e){return{kind:"schema",type:"string",reference:x,expects:"string",async:!1,message:e,get"~standard"(){return oe(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:Y(this,"type",t,n),t}}}r(x,"string");function As(e){let t;if(e)for(let n of e)if(t)for(let i of n.issues)t.push(i);else t=n.issues;return t}r(As,"_subIssues");function U(e,t){return{kind:"schema",type:"union",reference:U,expects:ai(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return oe(this)},"~run"(n,i){let s,o,a;for(let c of this.options){let l=c["~run"]({value:n.value},i);if(l.typed)if(l.issues)o?o.push(l):o=[l];else{s=l;break}else a?a.push(l):a=[l]}if(s)return s;if(o){if(o.length===1)return o[0];Y(this,"type",n,i,{issues:As(o)}),n.typed=!0}else{if(a?.length===1)return a[0];Y(this,"type",n,i,{issues:As(a)})}return n}}}r(U,"union");function ie(){return{kind:"schema",type:"unknown",reference:ie,expects:"unknown",async:!1,get"~standard"(){return oe(this)},"~run"(e){return e.typed=!0,e}}}r(ie,"unknown");function Be(e,t,n){return{kind:"schema",type:"variant",reference:Be,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return oe(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){let a,c=0,l=this.key,d=[],p=r((f,h)=>{for(let y of f.options){if(y.type==="variant")p(y,new Set(h).add(y.key));else{let g=!0,v=0;for(let I of h){let S=y.entries[I];if(I in o?S["~run"]({typed:!1,value:o[I]},_a).issues:S.type!=="exact_optional"&&S.type!=="optional"&&S.type!=="nullish"){g=!1,l!==I&&(c<v||c===v&&I in o&&!(l in o))&&(c=v,l=I,d=[]),l===I&&d.push(y.entries[I].expects);break}v++}if(g){let I=y["~run"]({value:o},s);(!a||!a.typed&&I.typed)&&(a=I)}}if(a&&!a.issues)break}},"parseOptions");if(p(this,new Set([this.key])),a)return a;Y(this,"type",i,s,{input:o[l],expected:ai(d,"|"),path:[{type:"object",origin:"value",input:o,key:l,value:o[l]}]})}else Y(this,"type",i,s);return i}}}r(Be,"variant");function Ts(e,t,n){let i=e["~run"]({value:t},oi(n));if(i.issues)throw new Oa(i.issues);return i.value}r(Ts,"parse");function T(...e){return{...e[0],pipe:e,get"~standard"(){return oe(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(T,"pipe");function _(e,t,n){let i=e["~run"]({value:t},oi(n));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}r(_,"safeParse");var Xe=T(U([T(x(),N(F)),A()]),N(e=>Number(e)),T(A(),fe(1)));var E=class{constructor(t,n,i,s){this.swish=t;this.ui=n;this.eventBus=i;this.options=s}static{r(this,"IntentHandler")}};var qa=U([b({variantId:Xe,quantity:m(T(A(),fe(1)),1)}),b({items:T(H(b({variantId:Xe,quantity:m(T(A(),fe(1)),1)})),pt(1))})]),Bt=class extends E{static{r(this,"CreateCartLineHandler")}async invoke(t){let n=_(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 Nt=class extends E{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 Fa=b({listId:x()}),jt=class extends E{static{r(this,"DeleteListHandler")}async invoke(t){let n=_(Fa,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=b({itemId:x()}),Ut=class extends E{static{r(this,"EditItemListsHandler")}async invoke(t){let n=_(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:c}=s.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:a,variant:c}}}return{intent:"unsave:item",code:"ok",data:{itemId:s.data.data.itemId}}}};var Na=b({itemId:T(x()),productId:T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A()),variantId:m(T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A()))}),Vt=class extends E{static{r(this,"EditItemVariantHandler")}async invoke(t){let n=_(Na,t);if(!n.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:n.issues.map(h=>h.message)};let{itemId:i,productId:s,variantId:o}=n.output;if(!(!o||this.swish.options.intents.editSavedProduct.promptVariantChange)){let h=await this.swish.api.items.updateById(i,{productId:s,variantId:o});if("error"in h)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[h.error.message]};if(!h.data)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:["No item returned from API"]};let y=await this.swish.storefront.loadProduct({productId:String(s),variantId:o?String(o):void 0});if(!y.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load product data",issues:[y.errors?.message??"No product data returned from API"]};let g=y.data.product,v=y.data.variant;return{intent:"edit:item-variant",code:"ok",data:{item:h.data,product:g,variant:v}}}let c=await this.ui.showVariantSelect({itemId:i,productId:s,variantId:o});if(c.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:l,product:d,variant:p}=c.data;return{intent:"edit:item-variant",code:"ok",data:{item:l,product:d,variant:p}}}};var ja=b({listId:x(),access:ne(["public","private"])}),$t=class extends E{static{r(this,"EditListAccessHandler")}async invoke(t){let n=_(ja,t);if(!n.success)return{intent:"edit:list-access",code:"error",message:"Invalid intent data",issues:n.issues.map(c=>c.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 Ua=b({listId:x()}),Ht=class extends E{static{r(this,"EditListHandler")}async invoke(t){let n=_(Ua,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 Va=b({variantId:Xe,quantity:m(T(A(),fe(1)),1)}),$a=150,Ha=U([b({variantId:Xe,quantity:m(T(A(),fe(1)),1)}),b({items:T(H(Va),pt(1))})]),Qt=class extends E{static{r(this,"InitiateCheckoutHandler")}async invoke(t){let n=_(Ha,t);if(!n.success)return{intent:"initiate:checkout",code:"error",message:"Invalid intent data",issues:n.issues.map(c=>c.message)};let i=n.output,o=("items"in i?i.items:[{variantId:i.variantId,quantity:i.quantity}]).map(c=>`${c.variantId}:${c.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),$a),{intent:"initiate:checkout",code:"ok",data:{checkoutUrl:a.href}}}};var Qa=b({productId:T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A()),variantId:m(T(U([T(x(),N(F)),A()]),N(Number),A()))}),Gt=class extends E{static{r(this,"InitiateQuickBuyHandler")}async invoke(t){let n=_(Qa,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}}};function Ds(e,t){try{let n=new URL(e,t);return n.origin!==t?"/":n.pathname+n.search+n.hash}catch{return"/"}}r(Ds,"toRelativeReturnTo");var Ga=150,za=b({returnTo:x()}),zt=class extends E{static{r(this,"InitiateSignInHandler")}async invoke(t){let n=_(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),Ga)}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",Ds(t,window.location.origin)),window.location.assign(o.toString())}};var Ka=150,Kt=class extends E{static{r(this,"InitiateSignOutHandler")}async invoke(){return this.scheduleRedirect(),{intent:"initiate:sign-out",code:"ok",data:void 0}}scheduleRedirect(){window.setTimeout(()=>this.redirectToSignOut(),Ka)}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 Wt=class extends E{static{r(this,"SaveCartLineHandler")}async invoke(t){return t?.items?.length?this.options.saveCartLine.confirm?this.saveWithPrompt(t.items):this.saveWithUndo(t.items):{intent:"save:cart-line",code:"error",message:"No items to save",issues:["items array is empty or missing"]}}async saveWithPrompt(t){let n=t[0];if((await this.ui.showToast({title:"t:toast.saveForLaterTitle",text:n.title??"",image:n.image,action:{label:"t:toast.saveForLater"},variant:"full"})).code!=="ok")return{intent:"save:cart-line",code:"closed"};let{error:s}=await this.createItems(t);return s||(this.options.saveCartLine.showFeedback&&await this.ui.showToast({title:"t:toast.savedForLater",text:n.title??"",image:n.image,variant:"full"}),{intent:"save:cart-line",code:"ok",data:t})}async saveWithUndo(t){let n=this.createItems(t);if(!this.options.saveCartLine.showFeedback){let{error:d}=await n;return d??{intent:"save:cart-line",code:"ok",data:t}}let i=t[0],s=new AbortController,o=this.ui.showToast({title:"t:toast.savedForLater",text:i.title??"",image:i.image,action:{label:"t:toast.undo"},variant:"full"},{signal:s.signal}),{error:a,itemIds:c}=await n;if(a){if(s.abort(),(await o).code==="ok"){let p=await this.removeSavedItems(c);a.issues=[...a.issues??[],...p]}return a}if((await o).code==="ok"){let d=await this.removeSavedItems(c);return d.length>0?{intent:"save:cart-line",code:"error",message:"Failed to undo saved cart items",issues:d}:{intent:"save:cart-line",code:"closed"}}return{intent:"save:cart-line",code:"ok",data:t}}async removeSavedItems(t){return(await Promise.all(t.map(i=>this.swish.api.smartLists.removeItem("saved-from-cart",i)))).flatMap(i=>"error"in i?[i.error.message]:[])}async createItems(t){let n=[];for(let i of t){let s=await this.swish.api.items.create({productId:i.productId,variantId:i.variantId,quantity:i.quantity,source:"cart"});if("error"in s)return{error:{intent:"save:cart-line",code:"error",message:"Failed to save item from cart",issues:[s.error.message]},itemIds:n};if(!s.data?.id)return{error:{intent:"save:cart-line",code:"error",message:"Failed to save item from cart",issues:["API response is missing the created item id"]},itemIds:n};n.push(s.data.id)}return{itemIds:n}}};var Wa=b({productId:T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A()),variantId:m(T(U([T(x(),N(F)),A()]),N(Number),A())),quantity:m(T(A(),fe(1))),tags:m(H(x()))}),Xt=class extends E{static{r(this,"SaveItemHandler")}async invoke(t){let n=_(Wa,t);if(!n.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:n.issues.map(I=>I.message)};let{productId:i,variantId:s,quantity:o,tags:a}=n.output,c=await this.swish.storefront.loadProduct({productId:String(i),variantId:s?String(s):void 0});if(c.errors)return{intent:"save:item",code:"error",message:c.errors.message??"Failed to load product data",issues:c.errors.graphQLErrors?.map(I=>I.message)??[]};if(!c.data||!c.data.product)return{intent:"save:item",code:"error",message:"Failed to load product data",issues:["API response missing data"]};let{product:l,variant:d}=c.data,p=l.variantsCount?.count&&l.variantsCount.count>1,f=!!s,y=!(typeof this.options.saveProduct.promptVariantIfMissing=="function"?this.options.saveProduct.promptVariantIfMissing({product:l,variant:d}):this.options.saveProduct.promptVariantIfMissing)||!this.options.saveProduct.promptVariantIfPresent&&f;if(!p||y){let I=r(()=>!p&&l.selectedOrFirstAvailableVariant?Number(F(l.selectedOrFirstAvailableVariant.id)):s,"variantIdToUse"),S=await this.swish.api.items.create({productId:i,variantId:I(),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:l,variant:p?d:l.selectedOrFirstAvailableVariant}}:{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]}}let g;if(this.options.saveProduct.saveBeforeVariantPrompt){let I=await this.swish.api.items.create({productId:i,quantity:o,tags:a});"data"in I&&I.data&&(g=I.data)}let v=await this.ui.showVariantSelect({productId:i,variantId:s,itemId:g?.id});return v.code==="closed"?g?{intent:"save:item",code:"ok",data:{item:g,product:l,variant:d}}:{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:v.data}}};function ht(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(ht,"buildShareListUrl");async function ft(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(ft,"copyToClipboard");function Ls(){let e=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||e}r(Ls,"isMobileDevice");var Xa=b({listId:x()}),Jt=class extends E{static{r(this,"ShareListHandler")}async invoke(t){let n=_(Xa,t);if(!n.success)return{intent:"initiate:share",code:"error",message:"Invalid intent data",issues:n.issues.map(l=>l.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=ht(this.swish,{publicListId:i}).toString();if(Ls()&&typeof navigator.share=="function"&&(await navigator.share({title:this.swish.i18n.t("listMenu.share"),url:o}).then(()=>({ok:!0})).catch(()=>({ok:!1}))).ok)return{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"native"}};let c=await ft(o);return c.ok?{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"clipboard"}}:{intent:"initiate:share",code:"error",message:"Failed to share list",issues:c.issues}}};var lm=b({title:m(x()),text:x(),image:m(x()),action:m(b({label:x(),url:m(x())})),variant:m(ne(["compact","full"])),icon:m(x())}),Yt=class extends E{static{r(this,"ShowToastHandler")}async invoke(t){return{intent:"show:toast",code:(await this.ui.showToast(t)).code,data:void 0}}};var Ja=b({itemId:x(),delete:m(C())}),Zt=class extends E{static{r(this,"UnsaveItemHandler")}async invoke(t){let n=_(Ja,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:c,product:l,variant:d}=a.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:c,product:l,variant:d}}}if(a.data.action==="unsave"){let{itemId:c}=a.data.data;return{intent:"unsave:item",code:"ok",data:{itemId:c}}}}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 en=class extends E{static{r(this,"ViewHomeHandler")}async invoke(t){return{intent:"view:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var Ya=b({listId:x()}),tn=class extends E{static{r(this,"ViewListDetailPageMenuHandler")}async invoke(t){let n=_(Ya,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 Za=b({listId:x(),listType:m(ne(["user","smart","shared"]),"user")}),nn=class extends E{static{r(this,"ViewListHandler")}async invoke(t){let n=_(Za,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 ec=b({listId:x()}),sn=class extends E{static{r(this,"ViewListMenuHandler")}async invoke(t){let n=_(ec,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 rn=class extends E{static{r(this,"ViewListsHandler")}async invoke(t){return{intent:"view:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var on=class extends E{static{r(this,"ViewNotificationsHandler")}async invoke(t){return{intent:"view:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var tc=b({orderId:T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A())}),an=class extends E{static{r(this,"ViewOrderHandler")}async invoke(t){let n=_(tc,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 nc=b({orderId:x()}),cn=class extends E{static{r(this,"ViewOrderMenuHandler")}async invoke(t){let n=_(nc,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 ln=class extends E{static{r(this,"ViewOrdersHandler")}async invoke(t){return{intent:"view:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var ic=b({productId:T(U([T(x(),N(F)),A()]),N(e=>Number(e)),A()),variantId:m(T(U([T(x(),N(F)),A()]),N(Number),A()))}),un=class extends E{static{r(this,"ViewProductHandler")}async invoke(t){let n=_(ic,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 dn=class extends E{static{r(this,"ViewProfileHandler")}async invoke(t){return{intent:"view:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var pn=class extends E{static{r(this,"ViewSavesHandler")}async invoke(t){return{intent:"view:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var J=class{constructor(t,n,i){this.swish=t;this.ui=n;this.options=i}static{r(this,"IntentHook")}};var hn=class extends J{static{r(this,"AfterCreateCartLineHook")}async invoke(t){this.options.createCartLine.afterComplete?.(t)}};var fn=class extends J{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:"t:toast.saved",text:n.title,image:i?.image?.url??n.featuredImage?.url,action:{label:"t:toast.view"}})).complete).code==="ok"&&this.swish.intents.invoke("view:saves")}}};var mn=class extends J{static{r(this,"AfterEditListAccessHook")}async invoke(t){if(t.code!=="ok")return;let n=t.data.list.access==="public"?"t:toast.listNowPublic":"t:toast.listNowPrivate";await(await this.swish.intents.invoke("show:toast",{text:n,variant:"compact",icon:"check"})).complete}};var yn=class extends J{static{r(this,"AfterSaveCartLineHook")}async invoke(t){this.options.saveCartLine.afterComplete?.(t)}};var vn=class extends J{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:"t:toast.saved",text:i.title,image:s?.image?.url??i.featuredImage?.url,action:{label:"t:toast.addToList"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:n.id})}}};var gn=class extends J{static{r(this,"AfterShareListHook")}async invoke(t){if(t.code!=="ok")return;await(await this.swish.intents.invoke("show:toast",{variant:"compact",text:"t:toast.linkCopied",icon:"check"})).complete}};var wn=class extends J{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 Os(e){let t=e.startsWith("#")?e.slice(1):e;return t==="swish"||t.startsWith("swish-")}r(Os,"isSwishHash");var bn=class extends J{static{r(this,"BeforeViewHomeHook")}async invoke(){Os(window.location.hash)||window.history.replaceState(window.history.state,"",window.location.pathname+window.location.search+"#swish")}};var In=class{constructor(t,n){this._invoking=!1;this.swish=t,this.ui=n,this.eventBus=new EventTarget,this.options=t.options.intents,this.handlers=this.initHandlers(),this.initIntentHooks(),this.initIntentWatcher(),this.initCartChangeListener()}static{r(this,"Intents")}applyPreview(t){this.options=t,this.handlers=this.initHandlers()}initHandlers(){return{"create:cart-line":new Bt(this.swish,this.ui,this.eventBus,this.options),"initiate:checkout":new Qt(this.swish,this.ui,this.eventBus,this.options),"save:item":new Xt(this.swish,this.ui,this.eventBus,this.options),"save:cart-line":new Wt(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new Zt(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new Vt(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Ut(this.swish,this.ui,this.eventBus,this.options),"create:list":new Nt(this.swish,this.ui,this.eventBus,this.options),"edit:list":new Ht(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new $t(this.swish,this.ui,this.eventBus,this.options),"delete:list":new jt(this.swish,this.ui,this.eventBus,this.options),"view:home":new en(this.swish,this.ui,this.eventBus,this.options),"initiate:share":new Jt(this.swish,this.ui,this.eventBus,this.options),"view:list":new nn(this.swish,this.ui,this.eventBus,this.options),"view:lists":new rn(this.swish,this.ui,this.eventBus,this.options),"view:orders":new ln(this.swish,this.ui,this.eventBus,this.options),"view:order":new an(this.swish,this.ui,this.eventBus,this.options),"view:saves":new pn(this.swish,this.ui,this.eventBus,this.options),"view:notifications":new on(this.swish,this.ui,this.eventBus,this.options),"view:profile":new dn(this.swish,this.ui,this.eventBus,this.options),"view:product":new un(this.swish,this.ui,this.eventBus,this.options),"view:list-menu":new sn(this.swish,this.ui,this.eventBus,this.options),"view:order-menu":new cn(this.swish,this.ui,this.eventBus,this.options),"view:list-detail-page-menu":new tn(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-in":new zt(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-out":new Kt(this.swish,this.ui,this.eventBus,this.options),"initiate:quick-buy":new Gt(this.swish,this.ui,this.eventBus,this.options),"show:toast":new Yt(this.swish,this.ui,this.eventBus,this.options)}}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 c={lifecycle:"after",intent:o.intent,data:i,response:o};this.eventBus.dispatchEvent(new CustomEvent(o.intent,{detail:c}))}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((c,l)=>{a[l]=c}),{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,c)=>{c!=="swish-intent"&&(s[c]=a)});let o=ut(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:F(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 bn(this.swish,this.ui,this.options).invoke()}),this.eventBus.addEventListener("create:cart-line",t=>{new hn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:item",t=>{new vn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:item-lists",t=>{new fn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("view:home",t=>{new wn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:list-access",t=>{new mn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("initiate:share",t=>{new gn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:cart-line",t=>{new yn(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(){ot({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")}),ot({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 G=m(Z(x(),U([x(),A()])),{}),sc=b({url:m(x(),""),altText:m(x(),"")}),rc=b({id:x(),enabled:C(),intent:x()}),oc=b({type:V("drawer-header"),hidden:m(C(),!1),design:G,options:m(b({title:m(x(),""),logo:m(sc,{url:"",altText:""}),useCloseButton:m(C(),!1),accountButton:m(C(),!0),notificationButton:m(C(),!0)}),{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0})}),ac=b({type:V("drawer-footer"),hidden:m(C(),!1),design:G,options:m(b({displayType:m(ne(["floating","docked"]),"docked"),showIcons:m(C(),!1),showText:m(C(),!0),items:m(H(rc),[{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"}]})}),cc=Be("type",[oc,ac]),lc=b({type:ne(["sign-in","notifications","recently-viewed","saved-from-cart","saved-items","lists"]),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),uc=b({title:x(),url:x(),hidden:m(C(),!1)}),dc=b({type:V("mini-menu"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{}),items:m(H(uc),[])}),pc=b({type:V("content-block"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{}),title:m(x()),body:m(x()),image:m(b({url:x(),width:m(A()),height:m(A())})),link:m(b({url:x(),target:m(ne(["_self","_blank"]))}))}),hc=b({type:V("featured-collection"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{}),handle:x()}),fc=Be("type",[lc,dc,pc,hc]),mc=b({type:V("lists-section"),hidden:m(C(),!1),design:G,options:m(b({display:m(ne(["myLists","forYouLists"]),"myLists"),layout:m(ne(["list","slider"]),"slider")}),{display:"myLists",layout:"slider"})}),yc=b({type:V("all-items-grid"),hidden:m(C(),!1),design:G,options:m(b({showSaveButton:m(C(),!0),showQuickBuyButton:m(C(),!0),showBuyButton:m(C(),!1),showVariantTitle:m(C(),!0),enableVariantChange:m(C(),!1),showVariantOptionNames:m(C(),!0),hideCompareAtPrice:m(C(),!1),linkToProductPage:m(C(),!1)}),{showSaveButton:!0,showQuickBuyButton:!0,showBuyButton:!1,showVariantTitle:!0,enableVariantChange:!1,showVariantOptionNames:!0,hideCompareAtPrice:!1,linkToProductPage:!1})}),vc=Be("type",[mc,yc]),gc=b({type:V("lists-grid"),hidden:m(C(),!1),design:G,options:m(b({displayType:m(ne(["list","slider"]),"slider")}),{displayType:"slider"})}),wc=gc,bc=b({type:V("list-items-grid"),hidden:m(C(),!1),design:G,options:m(b({desktopColumns:m(A(),4),showBuyButton:m(C(),!0),showVariantTitle:m(C(),!0),showVariantOptionNames:m(C(),!1),enableVariantChange:m(C(),!0),hideCompareAtPrice:m(C(),!1),linkToProductPage:m(C(),!0)}),{desktopColumns:4,showBuyButton:!0,showVariantTitle:!0,showVariantOptionNames:!1,enableVariantChange:!0,hideCompareAtPrice:!1,linkToProductPage:!0})}),Ic=bc,Sc=b({type:V("list-items-grid"),hidden:m(C(),!1),design:G,options:m(b({showBuyButton:m(C(),!1),showVariantTitle:m(C(),!0),showVariantOptionNames:m(C(),!1),enableVariantChange:m(C(),!1),hideCompareAtPrice:m(C(),!1),linkToProductPage:m(C(),!1)}),{showBuyButton:!1,showVariantTitle:!0,showVariantOptionNames:!1,enableVariantChange:!1,hideCompareAtPrice:!1,linkToProductPage:!1})}),xc=Sc,Cc=b({type:V("orders-list"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Ec=Cc,Rc=b({type:V("order-info"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),kc=b({type:V("order-items"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Ac=b({type:V("order-actions"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Pc=Be("type",[Rc,kc,Ac]),Tc=b({type:V("image-slider"),hidden:m(C(),!1),design:G,options:m(b({flush:m(C(),!0),loop:m(C(),!1)}),{flush:!0,loop:!1})}),Dc=b({type:V("product-info"),hidden:m(C(),!1),design:G,options:m(b({descriptionMaxLines:m(A(),4),variantSelectDisplayType:m(ne(["pills","rows"]),"pills"),hideSingleValueOptions:m(C(),!0),images:m(b({baseTint:m(C(),!0)}),{baseTint:!0})}),{descriptionMaxLines:4,variantSelectDisplayType:"pills",hideSingleValueOptions:!0,images:{baseTint:!0}})}),Lc=b({type:V("buy-buttons"),hidden:m(C(),!1),design:G,options:m(b({shopPay:m(C(),!1)}),{shopPay:!1})}),Oc=b({type:V("complementary-products"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),_c=b({type:V("related-products"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Mc=Be("type",[Tc,Dc,Lc,Oc,_c]),qc=b({type:V("profile-form"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Fc=qc,Bc=b({type:V("notifications-list"),hidden:m(C(),!1),design:G,options:m(Z(x(),ie()),{})}),Nc=Bc,jc=b({sections:m(H(cc),[{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"}]}}])}),Uc=b({sections:m(H(fc),[{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"}]}])}),Vc=b({sections:m(H(vc),[{type:"lists-section",options:{display:"myLists"}},{type:"lists-section",options:{display:"forYouLists"}},{type:"all-items-grid"}])}),$c=b({sections:m(H(wc),[{type:"lists-grid"}])}),Hc=b({sections:m(H(Ic),[{type:"list-items-grid"}])}),Qc=b({sections:m(H(xc),[{type:"list-items-grid"}])}),Gc=b({sections:m(H(Ec),[{type:"orders-list"}])}),zc=b({sections:m(H(Pc),[{type:"order-info"},{type:"order-items"},{type:"order-actions"}])}),Kc=b({sections:m(H(Mc),[{type:"image-slider"},{type:"product-info"},{type:"buy-buttons"},{type:"complementary-products"},{type:"related-products"}])}),Wc=b({sections:m(H(Fc),[{type:"profile-form"}])}),Xc=b({sections:m(H(Nc),[{type:"notifications-list"}])}),_s=b({baseUrl:m(x(),"https://swish.app/cdn"),css:m(H(U([x(),li(URL)])),[]),design:m(Z(x(),ie()),{}),icons:m(Z(x(),x()),{}),images:m(b({baseTint:m(C(),!0)}),{baseTint:!0}),toasts:m(b({autoHideDuration:m(T(A(),fe(0),ci()),5e3)}),{autoHideDuration:5e3}),drawer:m(jc,{}),home:m(Uc,{}),saves:m(Vc,{}),lists:m($c,{}),listDetail:m(Qc,{}),listDetailPage:m(Hc,{}),orders:m(Gc,{}),orderDetail:m(zc,{}),productDetail:m(Kc,{}),profile:m(Wc,{}),notifications:m(Xc,{})});var Ms=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:{productTitle:e.transforms?.productTitle??(({product:t})=>t?.title??""),productDescription:e.transforms?.productDescription??(({product:t})=>t?.descriptionHtml??""),productBadges:e.transforms?.productBadges??(({defaultBadges:t})=>t),productPrice:e.transforms?.productPrice??(()=>{}),addToCartButton:e.transforms?.addToCartButton??(()=>!1),linkToProductPage:e.transforms?.linkToProductPage??(()=>!1),variantTitle:e.transforms?.variantTitle??(({variant:t})=>t?.title??""),optionValues:e.transforms?.optionValues??(({optionValues:t})=>t),combinedListingParent:e.transforms?.combinedListingParent??(()=>!1),hideOption:e.transforms?.hideOption??(()=>!1)},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:Ts(_s,e.ui??{})}),"createSwishOptions");var mt=Math.min,Oe=Math.max,yt=Math.round,vt=Math.floor,be=r(e=>({x:e,y:e}),"createCoords");function ui(e,t){return typeof e=="function"?e(t):e}r(ui,"evaluate");function di(e){return e.split("-")[0]}r(di,"getSide");function pi(e){return e.split("-")[1]}r(pi,"getAlignment");function qs(e){return e==="x"?"y":"x"}r(qs,"getOppositeAxis");function Fs(e){return e==="y"?"height":"width"}r(Fs,"getAxisLength");function Sn(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}r(Sn,"getSideAxis");function Bs(e){return qs(Sn(e))}r(Bs,"getAlignmentAxis");function Jc(e){return{top:0,right:0,bottom:0,left:0,...e}}r(Jc,"expandPaddingObject");function Ns(e){return typeof e!="number"?Jc(e):{top:e,right:e,bottom:e,left:e}}r(Ns,"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 js(e,t,n){let{reference:i,floating:s}=e,o=Sn(t),a=Bs(t),c=Fs(a),l=di(t),d=o==="y",p=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,h=i[c]/2-s[c]/2,y;switch(l){case"top":y={x:p,y:i.y-s.height};break;case"bottom":y={x:p,y:i.y+i.height};break;case"right":y={x:i.x+i.width,y:f};break;case"left":y={x:i.x-s.width,y:f};break;default:y={x:i.x,y:i.y}}switch(pi(t)){case"start":y[a]-=h*(n&&d?-1:1);break;case"end":y[a]+=h*(n&&d?-1:1);break}return y}r(js,"computeCoordsFromPlacement");async function Us(e,t){var n;t===void 0&&(t={});let{x:i,y:s,platform:o,rects:a,elements:c,strategy:l}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:h=!1,padding:y=0}=ui(t,e),g=Ns(y),I=c[h?f==="floating"?"reference":"floating":f],S=Ne(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(I)))==null||n?I:I.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(c.floating)),boundary:d,rootBoundary:p,strategy:l})),R=f==="floating"?{x:i,y:s,width:a.floating.width,height:a.floating.height}:a.reference,P=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c.floating)),D=await(o.isElement==null?void 0:o.isElement(P))?await(o.getScale==null?void 0:o.getScale(P))||{x:1,y:1}:{x:1,y:1},k=Ne(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:R,offsetParent:P,strategy:l}):R);return{top:(S.top-k.top+g.top)/D.y,bottom:(k.bottom-S.bottom+g.bottom)/D.y,left:(S.left-k.left+g.left)/D.x,right:(k.right-S.right+g.right)/D.x}}r(Us,"detectOverflow");var Yc=50,Vs=r(async(e,t,n)=>{let{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,c=a.detectOverflow?a:{...a,detectOverflow:Us},l=await(a.isRTL==null?void 0:a.isRTL(t)),d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:p,y:f}=js(d,i,l),h=i,y=0,g={};for(let v=0;v<o.length;v++){let I=o[v];if(!I)continue;let{name:S,fn:R}=I,{x:P,y:D,data:k,reset:O}=await R({x:p,y:f,initialPlacement:i,placement:h,strategy:s,middlewareData:g,rects:d,platform:c,elements:{reference:e,floating:t}});p=P??p,f=D??f,g[S]={...g[S],...k},O&&y<Yc&&(y++,typeof O=="object"&&(O.placement&&(h=O.placement),O.rects&&(d=O.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):O.rects),{x:p,y:f}=js(d,h,l)),v=-1)}return{x:p,y:f,placement:h,strategy:s,middlewareData:g}},"computePosition");var Zc=new Set(["left","top"]);async function el(e,t){let{placement:n,platform:i,elements:s}=e,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=di(n),c=pi(n),l=Sn(n)==="y",d=Zc.has(a)?-1:1,p=o&&l?-1:1,f=ui(t,e),{mainAxis:h,crossAxis:y,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return c&&typeof g=="number"&&(y=c==="end"?g*-1:g),l?{x:y*p,y:h*d}:{x:h*d,y:y*p}}r(el,"convertValueToCoords");var $s=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:c}=t,l=await el(t,e);return a===((n=c.offset)==null?void 0:n.placement)&&(i=c.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:a}}}}},"offset");function xn(){return typeof window<"u"}r(xn,"hasWindow");function Ue(e){return Qs(e)?(e.nodeName||"").toLowerCase():"#document"}r(Ue,"getNodeName");function ae(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}r(ae,"getWindow");function Ie(e){var t;return(t=(Qs(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}r(Ie,"getDocumentElement");function Qs(e){return xn()?e instanceof Node||e instanceof ae(e).Node:!1}r(Qs,"isNode");function ye(e){return xn()?e instanceof Element||e instanceof ae(e).Element:!1}r(ye,"isElement");function Ee(e){return xn()?e instanceof HTMLElement||e instanceof ae(e).HTMLElement:!1}r(Ee,"isHTMLElement");function Hs(e){return!xn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ae(e).ShadowRoot}r(Hs,"isShadowRoot");function Ye(e){let{overflow:t,overflowX:n,overflowY:i,display:s}=ve(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&s!=="inline"&&s!=="contents"}r(Ye,"isOverflowElement");function Gs(e){return/^(table|td|th)$/.test(Ue(e))}r(Gs,"isTableElement");function gt(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}r(gt,"isTopLayer");var tl=/transform|translate|scale|rotate|perspective|filter/,nl=/paint|layout|strict|content/,je=r(e=>!!e&&e!=="none","isNotNone"),hi;function Cn(e){let t=ye(e)?ve(e):e;return je(t.transform)||je(t.translate)||je(t.scale)||je(t.rotate)||je(t.perspective)||!En()&&(je(t.backdropFilter)||je(t.filter))||tl.test(t.willChange||"")||nl.test(t.contain||"")}r(Cn,"isContainingBlock");function zs(e){let t=Le(e);for(;Ee(t)&&!Ve(t);){if(Cn(t))return t;if(gt(t))return null;t=Le(t)}return null}r(zs,"getContainingBlock");function En(){return hi==null&&(hi=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),hi}r(En,"isWebKit");function Ve(e){return/^(html|body|#document)$/.test(Ue(e))}r(Ve,"isLastTraversableNode");function ve(e){return ae(e).getComputedStyle(e)}r(ve,"getComputedStyle");function wt(e){return ye(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}r(wt,"getNodeScroll");function Le(e){if(Ue(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Hs(e)&&e.host||Ie(e);return Hs(t)?t.host:t}r(Le,"getParentNode");function Ks(e){let t=Le(e);return Ve(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ee(t)&&Ye(t)?t:Ks(t)}r(Ks,"getNearestOverflowAncestor");function Je(e,t,n){var i;t===void 0&&(t=[]),n===void 0&&(n=!0);let s=Ks(e),o=s===((i=e.ownerDocument)==null?void 0:i.body),a=ae(s);if(o){let c=Rn(a);return t.concat(a,a.visualViewport||[],Ye(s)?s:[],c&&n?Je(c):[])}else return t.concat(s,Je(s,[],n))}r(Je,"getOverflowAncestors");function Rn(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}r(Rn,"getFrameElement");function Ys(e){let t=ve(e),n=parseFloat(t.width)||0,i=parseFloat(t.height)||0,s=Ee(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:i,c=yt(n)!==o||yt(i)!==a;return c&&(n=o,i=a),{width:n,height:i,$:c}}r(Ys,"getCssDimensions");function mi(e){return ye(e)?e:e.contextElement}r(mi,"unwrapElement");function Ze(e){let t=mi(e);if(!Ee(t))return be(1);let n=t.getBoundingClientRect(),{width:i,height:s,$:o}=Ys(t),a=(o?yt(n.width):n.width)/i,c=(o?yt(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}r(Ze,"getScale");var il=be(0);function Zs(e){let t=ae(e);return!En()||!t.visualViewport?il:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}r(Zs,"getVisualOffsets");function sl(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ae(e)?!1:t}r(sl,"shouldAddVisualOffsets");function $e(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);let s=e.getBoundingClientRect(),o=mi(e),a=be(1);t&&(i?ye(i)&&(a=Ze(i)):a=Ze(e));let c=sl(o,n,i)?Zs(o):be(0),l=(s.left+c.x)/a.x,d=(s.top+c.y)/a.y,p=s.width/a.x,f=s.height/a.y;if(o){let h=ae(o),y=i&&ye(i)?ae(i):i,g=h,v=Rn(g);for(;v&&i&&y!==g;){let I=Ze(v),S=v.getBoundingClientRect(),R=ve(v),P=S.left+(v.clientLeft+parseFloat(R.paddingLeft))*I.x,D=S.top+(v.clientTop+parseFloat(R.paddingTop))*I.y;l*=I.x,d*=I.y,p*=I.x,f*=I.y,l+=P,d+=D,g=ae(v),v=Rn(g)}}return Ne({width:p,height:f,x:l,y:d})}r($e,"getBoundingClientRect");function kn(e,t){let n=wt(e).scrollLeft;return t?t.left+n:$e(Ie(e)).left+n}r(kn,"getWindowScrollBarX");function er(e,t){let n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-kn(e,n),s=n.top+t.scrollTop;return{x:i,y:s}}r(er,"getHTMLOffset");function rl(e){let{elements:t,rect:n,offsetParent:i,strategy:s}=e,o=s==="fixed",a=Ie(i),c=t?gt(t.floating):!1;if(i===a||c&&o)return n;let l={scrollLeft:0,scrollTop:0},d=be(1),p=be(0),f=Ee(i);if((f||!f&&!o)&&((Ue(i)!=="body"||Ye(a))&&(l=wt(i)),f)){let y=$e(i);d=Ze(i),p.x=y.x+i.clientLeft,p.y=y.y+i.clientTop}let h=a&&!f&&!o?er(a,l):be(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-l.scrollLeft*d.x+p.x+h.x,y:n.y*d.y-l.scrollTop*d.y+p.y+h.y}}r(rl,"convertOffsetParentRelativeRectToViewportRelativeRect");function ol(e){return Array.from(e.getClientRects())}r(ol,"getClientRects");function al(e){let t=Ie(e),n=wt(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+kn(e),c=-n.scrollTop;return ve(i).direction==="rtl"&&(a+=Oe(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:a,y:c}}r(al,"getDocumentRect");var Ws=25;function cl(e,t){let n=ae(e),i=Ie(e),s=n.visualViewport,o=i.clientWidth,a=i.clientHeight,c=0,l=0;if(s){o=s.width,a=s.height;let p=En();(!p||p&&t==="fixed")&&(c=s.offsetLeft,l=s.offsetTop)}let d=kn(i);if(d<=0){let p=i.ownerDocument,f=p.body,h=getComputedStyle(f),y=p.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,g=Math.abs(i.clientWidth-f.clientWidth-y);g<=Ws&&(o-=g)}else d<=Ws&&(o+=d);return{width:o,height:a,x:c,y:l}}r(cl,"getViewportRect");function ll(e,t){let n=$e(e,!0,t==="fixed"),i=n.top+e.clientTop,s=n.left+e.clientLeft,o=Ee(e)?Ze(e):be(1),a=e.clientWidth*o.x,c=e.clientHeight*o.y,l=s*o.x,d=i*o.y;return{width:a,height:c,x:l,y:d}}r(ll,"getInnerBoundingClientRect");function Xs(e,t,n){let i;if(t==="viewport")i=cl(e,n);else if(t==="document")i=al(Ie(e));else if(ye(t))i=ll(t,n);else{let s=Zs(e);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Ne(i)}r(Xs,"getClientRectFromClippingAncestor");function tr(e,t){let n=Le(e);return n===t||!ye(n)||Ve(n)?!1:ve(n).position==="fixed"||tr(n,t)}r(tr,"hasFixedPositionAncestor");function ul(e,t){let n=t.get(e);if(n)return n;let i=Je(e,[],!1).filter(c=>ye(c)&&Ue(c)!=="body"),s=null,o=ve(e).position==="fixed",a=o?Le(e):e;for(;ye(a)&&!Ve(a);){let c=ve(a),l=Cn(a);!l&&c.position==="fixed"&&(s=null),(o?!l&&!s:!l&&c.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Ye(a)&&!l&&tr(e,a))?i=i.filter(p=>p!==a):s=c,a=Le(a)}return t.set(e,i),i}r(ul,"getClippingElementAncestors");function dl(e){let{element:t,boundary:n,rootBoundary:i,strategy:s}=e,a=[...n==="clippingAncestors"?gt(t)?[]:ul(t,this._c):[].concat(n),i],c=Xs(t,a[0],s),l=c.top,d=c.right,p=c.bottom,f=c.left;for(let h=1;h<a.length;h++){let y=Xs(t,a[h],s);l=Oe(y.top,l),d=mt(y.right,d),p=mt(y.bottom,p),f=Oe(y.left,f)}return{width:d-f,height:p-l,x:f,y:l}}r(dl,"getClippingRect");function pl(e){let{width:t,height:n}=Ys(e);return{width:t,height:n}}r(pl,"getDimensions");function hl(e,t,n){let i=Ee(t),s=Ie(t),o=n==="fixed",a=$e(e,!0,o,t),c={scrollLeft:0,scrollTop:0},l=be(0);function d(){l.x=kn(s)}if(r(d,"setLeftRTLScrollbarOffset"),i||!i&&!o)if((Ue(t)!=="body"||Ye(s))&&(c=wt(t)),i){let y=$e(t,!0,o,t);l.x=y.x+t.clientLeft,l.y=y.y+t.clientTop}else s&&d();o&&!i&&s&&d();let p=s&&!i&&!o?er(s,c):be(0),f=a.left+c.scrollLeft-l.x-p.x,h=a.top+c.scrollTop-l.y-p.y;return{x:f,y:h,width:a.width,height:a.height}}r(hl,"getRectRelativeToOffsetParent");function fi(e){return ve(e).position==="static"}r(fi,"isStaticPositioned");function Js(e,t){if(!Ee(e)||ve(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ie(e)===n&&(n=n.ownerDocument.body),n}r(Js,"getTrueOffsetParent");function nr(e,t){let n=ae(e);if(gt(e))return n;if(!Ee(e)){let s=Le(e);for(;s&&!Ve(s);){if(ye(s)&&!fi(s))return s;s=Le(s)}return n}let i=Js(e,t);for(;i&&Gs(i)&&fi(i);)i=Js(i,t);return i&&Ve(i)&&fi(i)&&!Cn(i)?n:i||zs(e)||n}r(nr,"getOffsetParent");var fl=r(async function(e){let t=this.getOffsetParent||nr,n=this.getDimensions,i=await n(e.floating);return{reference:hl(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},"getElementRects");function ml(e){return ve(e).direction==="rtl"}r(ml,"isRTL");var yl={convertOffsetParentRelativeRectToViewportRelativeRect:rl,getDocumentElement:Ie,getClippingRect:dl,getOffsetParent:nr,getElementRects:fl,getClientRects:ol,getDimensions:pl,getScale:Ze,isElement:ye,isRTL:ml};function ir(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}r(ir,"rectsAreEqual");function vl(e,t){let n=null,i,s=Ie(e);function o(){var c;clearTimeout(i),(c=n)==null||c.disconnect(),n=null}r(o,"cleanup");function a(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),o();let d=e.getBoundingClientRect(),{left:p,top:f,width:h,height:y}=d;if(c||t(),!h||!y)return;let g=vt(f),v=vt(s.clientWidth-(p+h)),I=vt(s.clientHeight-(f+y)),S=vt(p),P={rootMargin:-g+"px "+-v+"px "+-I+"px "+-S+"px",threshold:Oe(0,mt(1,l))||1},D=!0;function k(O){let M=O[0].intersectionRatio;if(M!==l){if(!D)return a();M?a(!1,M):i=setTimeout(()=>{a(!1,1e-7)},1e3)}M===1&&!ir(d,e.getBoundingClientRect())&&a(),D=!1}r(k,"handleObserve");try{n=new IntersectionObserver(k,{...P,root:s.ownerDocument})}catch{n=new IntersectionObserver(k,P)}n.observe(e)}return r(a,"refresh"),a(!0),o}r(vl,"observeMove");function sr(e,t,n,i){i===void 0&&(i={});let{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,d=mi(e),p=s||o?[...d?Je(d):[],...t?Je(t):[]]:[];p.forEach(S=>{s&&S.addEventListener("scroll",n,{passive:!0}),o&&S.addEventListener("resize",n)});let f=d&&c?vl(d,n):null,h=-1,y=null;a&&(y=new ResizeObserver(S=>{let[R]=S;R&&R.target===d&&y&&t&&(y.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var P;(P=y)==null||P.observe(t)})),n()}),d&&!l&&y.observe(d),t&&y.observe(t));let g,v=l?$e(e):null;l&&I();function I(){let S=$e(e);v&&!ir(v,S)&&n(),v=S,g=requestAnimationFrame(I)}return r(I,"frameLoop"),n(),()=>{var S;p.forEach(R=>{s&&R.removeEventListener("scroll",n),o&&R.removeEventListener("resize",n)}),f?.(),(S=y)==null||S.disconnect(),y=null,l&&cancelAnimationFrame(g)}}r(sr,"autoUpdate");var rr=$s;var or=r((e,t,n)=>{let i=new Map,s={platform:yl,...n},o={...s.platform,_c:i};return Vs(e,t,{...s,platform:o})},"computePosition");function gl(e){let t=e.getAttribute("swish-item-context");return t?t==="location"?globalThis.window?.location??e:Ke(e,t)??e:e}r(gl,"resolveItemContextSource");function ar(e,t){return e.getAttribute("swish-item-context")?gl(e):t}r(ar,"resolvePlacementItemContextSource");function yi(e,t){if(!t.element)throw new Error("Element must be provided");let n=null,i=null,s=new Map,o=r((f,h)=>{e.events.publish("placement-warning",{placementId:t.id,code:f,message:h})},"warn"),a=r(()=>{if(n){console.warn("Placement already mounted. Skipping mount.");return}bl(t);try{document.querySelectorAll(t.target.selector)}catch(f){o("invalid-selector",f instanceof Error?f.message:"Invalid CSS selector");return}n=ot({selector:t.target.selector,observerOptions:t.target.observerOptions,mustMatch:t.target.mustMatch,onElementFound:r(f=>c(f),"onElementFound")}),i=setTimeout(()=>{s.size===0&&o("no-matches",`No elements match selector "${t.target.selector}"`),i=null},2e3)},"mount"),c=r(f=>{s.has(f)||f.hasAttribute("swish-ignore")||f.getAttribute("swish-placement-target")===t.id||(f.setAttribute("swish-placement-target",t.id),l(f))},"evaluateAndMount"),l=r(async f=>{let h=[],y=t.mount.mode,g=dr(f,t.mount.at);if(!g){o("mount-target-not-found","Could not resolve a mount target relative to the matched element.");return}let v=await(typeof t.element=="function"?t.element(t):Ml(e,t.element));if(!v){o("element-factory-empty","Element factory returned no element to mount.");return}if(v.setAttribute("swish-placement-element",t.id),typeof t.element!="function"){let j=t.element;j.props&&ql(v,j.props),j.classNames&&hr(v,j.classNames)}let I;t.container&&(I=_l(t.id,t.container),I.appendChild(v));let S,R=I??v;if(t.layout?.type==="overlay"){Tl(g);let j=t.layout.anchor??"bottom-right";R.setAttribute("swish-placement-overlay",t.id),R.setAttribute("swish-placement-anchor",j)}else t.layout?.type==="anchored"&&R.setAttribute("swish-placement-anchored",t.id);let P=!1,D;if(t.layout?.type==="inline"){let j=t.layout,le=j.rowSelector?g.closest(j.rowSelector):null;le?S=le:(S=Ol(t.id,g,j),P=!0),D=S.getAttribute("swish-placement-inline-row"),S.setAttribute("swish-placement-inline-row",t.id)}let k=I??v;if(!Pl(g,k,y)){try{k.remove()}catch{}o("insert-failed",`Could not insert element with mode "${y}" \u2014 target has no parent.`);return}if(t.layout?.type==="anchored"){let j=dr(f,t.layout.to)??g,le=Dl(j,R,t.layout);h.push(le)}let M={targetEl:f,renderTargetEl:g,mountEl:v,containerEl:I,rowEl:S,rowWasCreated:P,rowInlineAttrPrevValue:D,cleanupFns:h,ownsNode:!0};s.set(f,M),i&&(clearTimeout(i),i=null);let q={id:t.id,targetEl:f,renderTargetEl:g,mountEl:M.mountEl,containerEl:I,rowEl:S,cleanup:r(j=>h.push(j),"cleanup")};t.element?.name==="save-button"&&wl(e,q),t.onMount?.(q)},"mountElement"),d=r(f=>{let h=s.get(f);if(h){if(t.onUnmount?.({id:t.id,targetEl:h.targetEl,renderTargetEl:h.renderTargetEl,mountEl:h.mountEl,containerEl:h.containerEl,rowEl:h.rowEl}),h.cleanupFns.forEach(y=>y()),h.targetEl.getAttribute("swish-placement-target")===t.id&&h.targetEl.removeAttribute("swish-placement-target"),h.ownsNode&&(h.containerEl||h.mountEl).remove(),h.rowEl){if(h.rowWasCreated){let y=h.rowEl.parentElement;y&&h.targetEl.parentElement===h.rowEl?h.rowEl.replaceWith(h.targetEl):y?y.removeChild(h.rowEl):h.rowEl.remove()}else if(h.rowInlineAttrPrevValue!==void 0){let y=h.rowInlineAttrPrevValue;y===null?h.rowEl.removeAttribute("swish-placement-inline-row"):h.rowEl.setAttribute("swish-placement-inline-row",y)}}s.delete(f)}},"unmountElement");return{mount:a,unmount:r(()=>{n&&(n.disconnect(),n=null),i&&(clearTimeout(i),i=null),s.forEach((f,h)=>d(h)),s.clear()},"unmount")}}r(yi,"createPlacement");var wl=r((e,{mountEl:t,targetEl:n,cleanup:i})=>{let s=ar(t,n),o=e.state.itemContext(s),a=e.state.effect(()=>{let{loading:c,productId:l,variantId:d}=o.value;c||(t.setAttribute("product-id",l??""),t.setAttribute("variant-id",d??""))});i(()=>a?.())},"saveButtonMount");function bl(e){let t=Il(e.id),n=Al(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(bl,"ensurePlacementStylesheet");function Il(e){return`swish-placement-style-${Sl(e)}`}r(Il,"getPlacementStyleId");function Sl(e){return e.replace(/[^a-zA-Z0-9\-_]/g,"_")}r(Sl,"cssEscapeId");function cr(e){return`--swish-placement-${xl(String(e))}`}r(cr,"designKeyToCSSVar");function xl(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(xl,"toKebabCase");function Cl(e){return Object.entries(e??{sm:500,lg:700}).map(([i,s])=>({name:i,minWidth:s})).sort((i,s)=>i.minWidth-s.minWidth)}r(Cl,"getBreakpoints");function pr(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(pr,"normalizeResponsiveValue");var El=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function lr(e,t){if(t!=null)return typeof t=="number"&&!El.has(e)?`${t}px`:String(t)}r(lr,"formatDesignValue");function Rl(e,t,n){if(!t)return"";let i=new Set(n.map(l=>l.name)),s=[],o={},a=Object.entries(t).map(([l,d])=>[l,d]);for(let[l,d]of a){let p=pr(d,i),f=lr(String(l),p.base);f!==void 0&&s.push(`${cr(l)}:${f};`);for(let h of n){let y=p[h.name],g=lr(String(l),y);g!==void 0&&(o[h.name]||(o[h.name]=[]),o[h.name].push(`${cr(l)}:${g};`))}}let c=[];s.length&&c.push(`[swish-placement-element="${e}"]{${s.join("")}}`);for(let l of n){let d=o[l.name];d?.length&&c.push(`@media(min-width:${l.minWidth}px){[swish-placement-element="${e}"]{${d.join("")}}}`)}return c.join("")}r(Rl,"emitDesignCSS");function An(e){return e==null?"0px":typeof e=="number"?`${e}px`:e}r(An,"formatOffsetValue");function ur(e){return e==null?"":typeof e=="number"?`${e}`:e}r(ur,"formatZIndexValue");function kl(e,t,n){let i=new Set(n.map(d=>d.name)),s=pr(t,i),o=s.base??{},a=An(o.x),c=An(o.y),l=[];l.push(`[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${a};--swish-placement-offset-y:${c};}`);for(let d of n){let p=s[d.name];if(!p)continue;let f=An(p.x),h=An(p.y);l.push(`@media(min-width:${d.minWidth}px){[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${f};--swish-placement-offset-y:${h};}}`)}return l.join("")}r(kl,"emitOverlayOffsetCSS");function Al(e){let t=e.id,n=Cl(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=kl(t,e.layout.offset,n),c=e.layout.zIndex?`[swish-placement-overlay="${t}"]{--swish-placement-overlay-z:${ur(e.layout.zIndex)};}`:"";o+=a+c+s}else if(e.layout?.type==="anchored"){let a=e.layout.zIndex?ur(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=Rl(t,e.design,n);a&&(o+=a)}return e.css&&(o+=e.css.trim()),o}r(Al,"buildPlacementCSS");function dr(e,t){if(!t||t==="target")return e;if(typeof t=="string"&&(t={nearest:t}),"nearest"in t)return Ke(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(dr,"resolveMountTarget");function Pl(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(Pl,"insertIntoDOM");function Tl(e){let t=e.parentElement;return t?(window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t):null}r(Tl,"ensureRelativeParent");function Dl(e,t,n){let i=[];return n.inside?i.push(Ll(n.offset??0)):n.offset&&i.push(rr(n.offset)),sr(e,t,r(()=>{or(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(Dl,"setupAnchoredPosition");function Ll(e){return{name:"anchoredInside",fn({x:t,y:n,rects:i,placement:s}){let[o,a]=s.split("-"),c=0,l=0,d=o==="top"||o==="bottom";return o==="top"?l=i.floating.height+e:o==="bottom"?l=-(i.floating.height+e):o==="left"?c=i.floating.width+e:o==="right"&&(c=-(i.floating.width+e)),d&&a==="start"?c=e:d&&a==="end"?c=-e:!d&&a==="start"?l=e:!d&&a==="end"&&(l=-e),{x:t+c,y:n+l}}}}r(Ll,"anchoredInsideMiddleware");function Ol(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(Ol,"wrapWithFlexRow");function _l(e,t){let n=t.tag||"div",i=document.createElement(n);return i.setAttribute("swish-placement-container",e),t.classNames&&hr(i,t.classNames),i}r(_l,"createContainer");function Ml(e,t){return e.ui.createElement(t.name,{})}r(Ml,"createElement");function ql(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(ql,"applyProps");function hr(e,t){e.classList.add(...t)}r(hr,"applyClassNames");var Pn=class{constructor(t){this.app=t;this.mountedPlacements=[]}static{r(this,"Placements")}mountConfigured(t){this.mountedPlacements=t.map(n=>this.mountSpec(n))}create(t){return yi(this.app,t)}applyPreview(t=[]){this.unmountAll(),this.mountConfigured(t)}get list(){return this.mountedPlacements}mountSpec(t){let n=yi(this.app,t);return n.mount(),{spec:t,...n}}unmountAll(){this.mountedPlacements.forEach(t=>t.unmount()),this.mountedPlacements=[]}};function fr(e){return F(String(e).trim())}r(fr,"normalizeSwishQueryId");function Tn(e){let t=e.productId?fr(e.productId):"",n=e.variantId?fr(e.variantId):"";return n?["swish","items",t,n]:["swish","items",t]}r(Tn,"swishItemsQueryKey");var Fl=["item-create","item-update","item-delete"],mr="auth-cache-clear",yr="token-update";function vr({events:e,queryClient:t}){return e.subscribe([...Fl,mr,yr],n=>{if(!(n instanceof CustomEvent))return;if(n.type===mr){t.clear();return}if(n.type===yr){t.invalidateQueries({queryKey:["swish"]});return}if(!n.detail?.productId)return;let i=Tn({productId:n.detail.productId});t.invalidateQueries({queryKey:i})})}r(vr,"bindSwishItemQueryInvalidation");var Re=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 Bl=class extends Re{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"}},et=new Bl;var Nl={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")},jl=class{static{r(this,"TimeoutManager")}#e=Nl;#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)}},ke=new jl;function gr(e){setTimeout(e,0)}r(gr,"systemSetTimeoutZero");var Ir=typeof window>"u"||"Deno"in globalThis;function z(){}r(z,"noop");function Sr(e,t){return typeof e=="function"?e(t):e}r(Sr,"functionalUpdate");function bt(e){return typeof e=="number"&&e>=0&&e!==1/0}r(bt,"isValidTimeout");function Dn(e,t){return Math.max(e+(t||0)-Date.now(),0)}r(Dn,"timeUntilStale");function Se(e,t){return typeof e=="function"?e(t):e}r(Se,"resolveStaleTime");function ce(e,t){return typeof e=="function"?e(t):e}r(ce,"resolveEnabled");function gi(e,t){let{type:n="all",exact:i,fetchStatus:s,predicate:o,queryKey:a,stale:c}=e;if(a){if(i){if(t.queryHash!==It(a,t.options))return!1}else if(!nt(t.queryKey,a))return!1}if(n!=="all"){let l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||s&&s!==t.state.fetchStatus||o&&!o(t))}r(gi,"matchQuery");function wi(e,t){let{exact:n,status:i,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(tt(t.options.mutationKey)!==tt(o))return!1}else if(!nt(t.options.mutationKey,o))return!1}return!(i&&t.state.status!==i||s&&!s(t))}r(wi,"matchMutation");function It(e,t){return(t?.queryKeyHashFn||tt)(e)}r(It,"hashQueryKeyByOptions");function tt(e){return JSON.stringify(e,(t,n)=>vi(n)?Object.keys(n).sort().reduce((i,s)=>(i[s]=n[s],i),{}):n)}r(tt,"hashKey");function nt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>nt(e[n],t[n])):!1}r(nt,"partialMatchKey");var Ul=Object.prototype.hasOwnProperty;function xr(e,t,n=0){if(e===t)return e;if(n>500)return t;let i=wr(e)&&wr(t);if(!i&&!(vi(e)&&vi(t)))return t;let o=(i?e:Object.keys(e)).length,a=i?t:Object.keys(t),c=a.length,l=i?new Array(c):{},d=0;for(let p=0;p<c;p++){let f=i?p:a[p],h=e[f],y=t[f];if(h===y){l[f]=h,(i?p<o:Ul.call(e,f))&&d++;continue}if(h===null||y===null||typeof h!="object"||typeof y!="object"){l[f]=y;continue}let g=xr(h,y,n+1);l[f]=g,g===h&&d++}return o===c&&d===o?e:l}r(xr,"replaceEqualDeep");function Ln(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(Ln,"shallowEqualObjects");function wr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}r(wr,"isPlainArray");function vi(e){if(!br(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!br(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}r(vi,"isPlainObject");function br(e){return Object.prototype.toString.call(e)==="[object Object]"}r(br,"hasObjectPrototype");function Cr(e){return new Promise(t=>{ke.setTimeout(t,e)})}r(Cr,"sleep");function St(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?xr(e,t):t}r(St,"replaceData");function Er(e,t,n=0){let i=[...e,t];return n&&i.length>n?i.slice(1):i}r(Er,"addToEnd");function Rr(e,t,n=0){let i=[t,...e];return n&&i.length>n?i.slice(0,-1):i}r(Rr,"addToStart");var xt=Symbol();function On(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===xt?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}r(On,"ensureQueryFn");function kr(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(kr,"addConsumeAwareSignal");var He=(()=>{let e=r(()=>Ir,"isServerFn");return{isServer(){return e()},setIsServer(t){e=t}}})();function Ct(){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(Ct,"pendingThenable");function Ar(e){let t;if(e.then(n=>(t=n,n),z)?.catch(z),t!==void 0)return{data:t}}r(Ar,"tryResolveSync");function Pr(e){return e}r(Pr,"defaultTransformerFn");function Vl(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}r(Vl,"dehydrateMutation");function $l(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($l,"dehydrateQuery");function Tr(e){return e.state.isPaused}r(Tr,"defaultShouldDehydrateMutation");function Dr(e){return e.state.status==="success"}r(Dr,"defaultShouldDehydrateQuery");function Hl(e){return!0}r(Hl,"defaultShouldRedactErrors");function bi(e,t={}){let n=t.shouldDehydrateMutation??e.getDefaultOptions().dehydrate?.shouldDehydrateMutation??Tr,i=e.getMutationCache().getAll().flatMap(l=>n(l)?[Vl(l)]:[]),s=t.shouldDehydrateQuery??e.getDefaultOptions().dehydrate?.shouldDehydrateQuery??Dr,o=t.shouldRedactErrors??e.getDefaultOptions().dehydrate?.shouldRedactErrors??Hl,a=t.serializeData??e.getDefaultOptions().dehydrate?.serializeData??Pr,c=e.getQueryCache().getAll().flatMap(l=>s(l)?[$l(l,a,o)]:[]);return{mutations:i,queries:c}}r(bi,"dehydrate");function Ii(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??Pr,a=t.mutations||[],c=t.queries||[];a.forEach(({state:l,...d})=>{i.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...d},l)}),c.forEach(({queryKey:l,state:d,queryHash:p,meta:f,promise:h,dehydratedAt:y})=>{let g=h?Ar(h):void 0,v=d.data===void 0?g?.data:d.data,I=v===void 0?v:o(v),S=s.get(p),R=S?.state.status==="pending",P=S?.state.fetchStatus==="fetching";if(S){let D=g&&y!==void 0&&y>S.state.dataUpdatedAt;if(d.dataUpdatedAt>S.state.dataUpdatedAt||D){let{fetchStatus:k,...O}=d;S.setState({...O,data:I})}}else S=s.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:l,queryHash:p,meta:f},{...d,data:I,fetchStatus:"idle",status:I!==void 0?"success":d.status});h&&!R&&!P&&(y===void 0||y>S.state.dataUpdatedAt)&&S.fetch(void 0,{initialPromise:Promise.resolve(h).then(o)}).catch(z)})}r(Ii,"hydrate");var Ql=gr;function Gl(){let e=[],t=0,n=r(c=>{c()},"notifyFn"),i=r(c=>{c()},"batchNotifyFn"),s=Ql,o=r(c=>{t?e.push(c):s(()=>{n(c)})},"schedule"),a=r(()=>{let c=e;e=[],c.length&&s(()=>{i(()=>{c.forEach(l=>{n(l)})})})},"flush");return{batch:r(c=>{let l;t++;try{l=c()}finally{t--,t||a()}return l},"batch"),batchCalls:r(c=>(...l)=>{o(()=>{c(...l)})},"batchCalls"),schedule:o,setNotifyFunction:r(c=>{n=c},"setNotifyFunction"),setBatchNotifyFunction:r(c=>{i=c},"setBatchNotifyFunction"),setScheduler:r(c=>{s=c},"setScheduler")}}r(Gl,"createNotifyManager");var K=Gl();var zl=class extends Re{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}},it=new zl;function Kl(e){return Math.min(1e3*2**e,3e4)}r(Kl,"defaultRetryDelay");function Si(e){return(e??"online")==="online"?it.isOnline():!0}r(Si,"canFetch");var _n=class extends Error{static{r(this,"CancelledError")}constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Mn(e){let t=!1,n=0,i,s=Ct(),o=r(()=>s.status!=="pending","isResolved"),a=r(v=>{if(!o()){let I=new _n(v);h(I),e.onCancel?.(I)}},"cancel"),c=r(()=>{t=!0},"cancelRetry"),l=r(()=>{t=!1},"continueRetry"),d=r(()=>et.isFocused()&&(e.networkMode==="always"||it.isOnline())&&e.canRun(),"canContinue"),p=r(()=>Si(e.networkMode)&&e.canRun(),"canStart"),f=r(v=>{o()||(i?.(),s.resolve(v))},"resolve"),h=r(v=>{o()||(i?.(),s.reject(v))},"reject"),y=r(()=>new Promise(v=>{i=r(I=>{(o()||d())&&v(I)},"continueFn"),e.onPause?.()}).then(()=>{i=void 0,o()||e.onContinue?.()}),"pause"),g=r(()=>{if(o())return;let v,I=n===0?e.initialPromise:void 0;try{v=I??e.fn()}catch(S){v=Promise.reject(S)}Promise.resolve(v).then(f).catch(S=>{if(o())return;let R=e.retry??(He.isServer()?0:3),P=e.retryDelay??Kl,D=typeof P=="function"?P(n,S):P,k=R===!0||typeof R=="number"&&n<R||typeof R=="function"&&R(n,S);if(t||!k){h(S);return}n++,e.onFail?.(n,S),Cr(D).then(()=>d()?void 0:y()).then(()=>{t?h(S):g()})})},"run");return{promise:s,status:r(()=>s.status,"status"),cancel:a,continue:r(()=>(i?.(),s),"continue"),cancelRetry:c,continueRetry:l,canStart:p,start:r(()=>(p()?g():y().then(g),s),"start")}}r(Mn,"createRetryer");var qn=class{static{r(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),bt(this.gcTime)&&(this.#e=ke.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(He.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(ke.clearTimeout(this.#e),this.#e=void 0)}};var _r=class extends qn{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=Or(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=Or(this.options);t.data!==void 0&&(this.setState(Lr(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){let n=St(this.state.data,e,this.options);return this.#c({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({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=>ce(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===xt||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Se(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:!Dn(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.#c({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 c=this.observers.find(l=>l.options.queryFn);c&&this.setOptions(c.options)}let n=new AbortController,i=r(c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:r(()=>(this.#r=!0,n.signal),"get")})},"addSignalProperty"),s=r(()=>{let c=On(this.options,t),d=r(()=>{let p={client:this.#s,queryKey:this.queryKey,meta:this.meta};return i(p),p},"createQueryFnContext")();return this.#r=!1,this.options.persister?this.options.persister(c,d,this):c(d)},"fetchFn"),a=r(()=>{let c={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#s,state:this.state,fetchFn:s};return i(c),c},"createFetchContext")();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:"fetch",meta:a.fetchOptions?.meta}),this.#i=Mn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:r(c=>{c instanceof _n&&c.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},"onCancel"),onFail:r((c,l)=>{this.#c({type:"failed",failureCount:c,error:l})},"onFail"),onPause:r(()=>{this.#c({type:"pause"})},"onPause"),onContinue:r(()=>{this.#c({type:"continue"})},"onContinue"),retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:r(()=>!0,"canRun")});try{let c=await this.#i.start();if(c===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(c),this.#n.config.onSuccess?.(c,this),this.#n.config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof _n){if(c.silent)return this.#i.promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw this.#c({type:"error",error:c}),this.#n.config.onError?.(c,this),this.#n.config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}#c(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,...xi(n.data,this.options),fetchMeta:e.meta??null};case"success":let i={...n,...Lr(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),K.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function xi(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Si(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}r(xi,"fetchState");function Lr(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}r(Lr,"successState");function Or(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(Or,"getDefaultState");var Ei=class extends Re{static{r(this,"QueryObserver")}constructor(e,t){super(),this.options=t,this.#e=e,this.#a=null,this.#r=Ct(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#s=void 0;#i;#o;#r;#a;#c;#h;#f;#u;#d;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Mr(this.#t,this.options)?this.#p():this.updateResult(),this.#w())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ci(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ci(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 ce(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&&!Ln(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let i=this.hasListeners();i&&qr(this.#t,n,this.options,t)&&this.#p(),this.updateResult(),i&&(this.#t!==n||ce(this.options.enabled,this.#t)!==ce(t.enabled,this.#t)||Se(this.options.staleTime,this.#t)!==Se(t.staleTime,this.#t))&&this.#y();let s=this.#v();i&&(this.#t!==n||ce(this.options.enabled,this.#t)!==ce(t.enabled,this.#t)||s!==this.#l)&&this.#g(s)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Xl(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=Se(this.options.staleTime,this.#t);if(He.isServer()||this.#s.isStale||!bt(e))return;let n=Dn(this.#s.dataUpdatedAt,e)+1;this.#u=ke.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.#l=e,!(He.isServer()||ce(this.options.enabled,this.#t)===!1||!bt(this.#l)||this.#l===0)&&(this.#d=ke.setInterval(()=>{(this.options.refetchIntervalInBackground||et.isFocused())&&this.#p()},this.#l))}#w(){this.#y(),this.#g(this.#v())}#b(){this.#u&&(ke.clearTimeout(this.#u),this.#u=void 0)}#I(){this.#d&&(ke.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,l=e!==n?e.state:this.#n,{state:d}=e,p={...d},f=!1,h;if(t._optimisticResults){let q=this.hasListeners(),j=!q&&Mr(e,t),le=q&&qr(e,n,t,i);(j||le)&&(p={...p,...xi(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(p.fetchStatus="idle")}let{error:y,errorUpdatedAt:g,status:v}=p;h=p.data;let I=!1;if(t.placeholderData!==void 0&&h===void 0&&v==="pending"){let q;s?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(q=s.data,I=!0):q=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,q!==void 0&&(v="success",h=St(s?.data,q,t),f=!0)}if(t.select&&h!==void 0&&!I)if(s&&h===o?.data&&t.select===this.#c)h=this.#h;else try{this.#c=t.select,h=t.select(h),h=St(s?.data,h,t),this.#h=h,this.#a=null}catch(q){this.#a=q}this.#a&&(y=this.#a,h=this.#h,g=Date.now(),v="error");let S=p.fetchStatus==="fetching",R=v==="pending",P=v==="error",D=R&&S,k=h!==void 0,M={status:v,fetchStatus:p.fetchStatus,isPending:R,isSuccess:v==="success",isError:P,isInitialLoading:D,isLoading:D,data:h,dataUpdatedAt:p.dataUpdatedAt,error:y,errorUpdatedAt:g,failureCount:p.fetchFailureCount,failureReason:p.fetchFailureReason,errorUpdateCount:p.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:p.dataUpdateCount>l.dataUpdateCount||p.errorUpdateCount>l.errorUpdateCount,isFetching:S,isRefetching:S&&!R,isLoadingError:P&&!k,isPaused:p.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:P&&k,isStale:Ri(e,t),refetch:this.refetch,promise:this.#r,isEnabled:ce(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let q=M.data!==void 0,j=M.status==="error"&&!q,le=r(Pe=>{j?Pe.reject(M.error):q&&Pe.resolve(M.data)},"finalizeThenableIfPossible"),_e=r(()=>{let Pe=this.#r=M.promise=Ct();le(Pe)},"recreateThenable"),me=this.#r;switch(me.status){case"pending":e.queryHash===n.queryHash&&le(me);break;case"fulfilled":(j||M.data!==me.value)&&_e();break;case"rejected":(!j||M.error!==me.reason)&&_e();break}}return M}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),Ln(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 c=a;return this.#s[c]!==e[c]&&o.has(c)})},"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){K.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Wl(e,t){return ce(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}r(Wl,"shouldLoadOnMount");function Mr(e,t){return Wl(e,t)||e.state.data!==void 0&&Ci(e,t,t.refetchOnMount)}r(Mr,"shouldFetchOnMount");function Ci(e,t,n){if(ce(t.enabled,e)!==!1&&Se(t.staleTime,e)!=="static"){let i=typeof n=="function"?n(e):n;return i==="always"||i!==!1&&Ri(e,t)}return!1}r(Ci,"shouldFetchOn");function qr(e,t,n,i){return(e!==t||ce(i.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ri(e,n)}r(qr,"shouldFetchOptionally");function Ri(e,t){return ce(t.enabled,e)!==!1&&e.isStaleByTime(Se(t.staleTime,e))}r(Ri,"isStale");function Xl(e,t){return!Ln(e.getCurrentResult(),t)}r(Xl,"shouldAssignObserverCurrentProperties");function ki(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||[],c={pages:[],pageParams:[]},l=0,d=r(async()=>{let p=!1,f=r(g=>{kr(g,()=>t.signal,()=>p=!0)},"addSignalProperty"),h=On(t.options,t.fetchOptions),y=r(async(g,v,I)=>{if(p)return Promise.reject();if(v==null&&g.pages.length)return Promise.resolve(g);let R=r(()=>{let O={client:t.client,queryKey:t.queryKey,pageParam:v,direction:I?"backward":"forward",meta:t.options.meta};return f(O),O},"createQueryFnContext")(),P=await h(R),{maxPages:D}=t.options,k=I?Rr:Er;return{pages:k(g.pages,P,D),pageParams:k(g.pageParams,v,D)}},"fetchPage");if(s&&o.length){let g=s==="backward",v=g?Jl:Fr,I={pages:o,pageParams:a},S=v(i,I);c=await y(I,S,g)}else{let g=e??o.length;do{let v=l===0?a[0]??i.initialPageParam:Fr(i,c);if(l>0&&v==null)break;c=await y(c,v),l++}while(l<g)}return c},"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(ki,"infiniteQueryBehavior");function Fr(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(Fr,"getNextPageParam");function Jl(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}r(Jl,"getPreviousPageParam");var Br=class extends qn{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||Yl(),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=Mn({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),K.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function Yl(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}r(Yl,"getDefaultState");var Nr=class extends Re{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 Br({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=Fn(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=Fn(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=Fn(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=Fn(e);return typeof t=="string"?this.#t.get(t)?.find(i=>i!==e&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){K.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=>wi(t,n))}findAll(e={}){return this.getAll().filter(t=>wi(e,t))}notify(e){K.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return K.batch(()=>Promise.all(e.map(t=>t.continue().catch(z))))}};function Fn(e){return e.options.scope?.id}r(Fn,"scopeFor");var jr=class extends Re{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??It(i,t),o=this.get(s);return o||(o=new _r({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(){K.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=>gi(t,n))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(n=>gi(e,n)):t}notify(e){K.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){K.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){K.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var Ai=class{static{r(this,"QueryClient")}#e;#t;#n;#s;#i;#o;#r;#a;constructor(e={}){this.#e=e.queryCache||new jr,this.#t=e.mutationCache||new Nr,this.#n=e.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#r=et.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=it.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(Se(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=Sr(t,o);if(a!==void 0)return this.#e.build(this,i).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return K.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;K.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){let n=this.#e;return K.batch(()=>(n.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},i=K.batch(()=>this.#e.findAll(e).map(s=>s.cancel(n)));return Promise.all(i).then(z).catch(z)}invalidateQueries(e,t={}){return K.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=K.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(Se(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=ki(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(z).catch(z)}ensureInfiniteQueryData(e){return e.behavior=ki(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return it.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(tt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#s.values()],n={};return t.forEach(i=>{nt(e,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(tt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(i=>{nt(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=It(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===xt&&(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 Ur(){return new Ai({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,gcTime:1e3*60*60*1,staleTime:1e3*60*10}}})}r(Ur,"createSwishQueryClient");var Zl="swish-query-cache";function eu(e){return e.replace(/\.myshopify\.com$/,"")||"unknown-store"}r(eu,"normalizeStoreKeyPart");function Bn({customerId:e,storeDomain:t}){let n=e??"guest",i=eu(t??"");return`${Zl}:${i}:${n}`}r(Bn,"getSwishQueryStorageKey");var tu=1e3*60*60*24,nu=1e3;function Pi(){return!!globalThis.window?.localStorage}r(Pi,"canUseLocalStorage");function iu(e){if(!Pi())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(iu,"readPersistedState");function su(e,t){if(Pi())try{globalThis.window.localStorage.setItem(e,JSON.stringify(t))}catch{}}r(su,"writePersistedState");function ru(e){if(Pi())try{globalThis.window.localStorage.removeItem(e)}catch{}}r(ru,"removePersistedState");function ou(e,t){return Number.isFinite(e.timestamp)?Date.now()-e.timestamp>t:!0}r(ou,"isPersistedStateExpired");function Vr({queryClient:e,cacheBuster:t,customerId:n,storeDomain:i,maxAgeMs:s=tu,throttleMs:o=nu}){let a=Bn({customerId:n,storeDomain:i}),c=L(!1),l=iu(a);l?.buster===t&&!ou(l,s)?Ii(e,l.clientState):l&&ru(a),c.value=!0;let d=null,p=!1,f=r(()=>{su(a,{buster:t,timestamp:Date.now(),clientState:bi(e)})},"persistNow"),h=r(()=>{p=!0,!d&&(d=setTimeout(()=>{d=null,p&&(p=!1,f())},Math.max(o,0)))},"schedulePersist"),y=r(()=>{p&&(p=!1,d&&(clearTimeout(d),d=null),f())},"flushPersist"),g=e.getQueryCache().subscribe(I=>{c.value&&h()}),v=r(()=>{y()},"onPageHide");return globalThis.window?.addEventListener("pagehide",v),{restored:c,storageKey:a,dispose:r(()=>{globalThis.window?.removeEventListener("pagehide",v),g(),y()},"dispose")}}r(Vr,"initSwishQueryPersistence");function $r({events:e,cacheBuster:t,customerId:n,storeDomain:i}){let s=Ur(),o=Vr({queryClient:s,cacheBuster:t,customerId:n,storeDomain:i});return vr({events:e,queryClient:s}),{client:s,cacheBuster:t,restored:o.restored,storageKey:o.storageKey,keys:{items:Tn}}}r($r,"createSwishQuery");var Hr=r(e=>L({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"),Qr=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:c,itemId:l}=s?t.dataset:{},f=!!(a||o)||!!l,h=L({loading:!1,productHandle:o,productId:a,variantId:c,itemId:l});if(!f&&(n||i)){let y=t.href,g=ut(y);g?.productHandle&&g.productHandle!==h.value.productHandle&&(h.value={...h.value,...g,productId:void 0},Rs({source:t,onProductUrlChange:r(v=>{h.value={...h.value,...v,productId:v.productHandle===h.value.productHandle?h.value.productId:void 0}},"onProductUrlChange")}))}return X(()=>{h.value.loading||!h.value.productId&&h.value.productHandle&&(h.value={...h.value,loading:!0},e.storefront.loadProductId({productHandle:h.value.productHandle}).then(y=>{y.errors&&console.error("Error loading product id",y.errors);let g=y.data?.product?.id?F(y.data.product.id):void 0;h.value={...h.value,productId:g,loading:!g}}))}),h},"itemContextSignal");function Gr({queryClient:e,options:t,restored:n}){let i=L(null),s=L(!1),o=L(null),a=L(!1),c=r(g=>{let v=n?.value??!0,I=g.enabled??!0;return{...g,enabled:!!(I&&v)}},"getObserverOptions"),l=new Ei(e,c(t.value)),d=r(g=>{ee(()=>{i.value=g.data??null,s.value=g.isLoading,a.value=g.isRefetching,o.value=g.error??null})},"syncResult"),p=l.subscribe(d);d(l.getCurrentResult());let f=X(()=>{l.setOptions(c(t.value))}),h=!1;return{data:i,loading:s,error:o,refetching:a,refetch:r(()=>l.refetch(),"refetch"),dispose:r(()=>{h||(h=!0,f(),p(),l.destroy())},"dispose")}}r(Gr,"createTanstackQuerySignal");var Ti=50;function zr(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(zr,"arraysShallowEqual");function au(e,t,n){if(n==="variant"||n==="auto"&&!!t){if(!t)return null;let s=F(t);return e.find(o=>String(o.variantId)===s)??null}return e[0]??null}r(au,"pickSavedItem");function cu(e){ee(()=>{if(e.savedItemsLoading.value=e.apiLoading,e.savedItemsError.value=e.apiError,e.forcedItemId){let o=[e.forcedItemId];zr(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>=Ti&&console.warn(`[swish] item-state query hit the per-product limit (${Ti}). Some saved items may be missing.`);let n=t.map(o=>o.id);zr(e.savedItemIds.value,n)||(e.savedItemIds.value=n);let s=au(t,e.variantId,e.policy)?.id??null;s!==e.savedItemId.value&&(e.savedItemId.value=s)})}r(cu,"syncFromApi");var Kr=r(e=>(t,n={})=>{let i=[],s={onSave:n.onSave,onUnsave:n.onUnsave,onListsUpdate:n.onListsUpdate,onVariantUpdate:n.onVariantUpdate},o=L(n.match??"auto"),a=r($=>{s.onSave=$.onSave,s.onUnsave=$.onUnsave,s.onListsUpdate=$.onListsUpdate,s.onVariantUpdate=$.onVariantUpdate;let W=$.match??"auto";o.value!==W&&(o.value=W)},"setOptions"),c=re(()=>{let{productId:$,loading:W}=t.value;return!$||W?null:`product:${F($)}`}),l=re(()=>t.value.loading||!!t.value.itemId||!t.value.productId),d=L(!l.value),p=L(null),f=L(!1),h=L(!1),y=L(!1),g=re(()=>f.value||h.value||y.value),v=L(!1),I=L(!1),S=re(()=>{let $=c.value,W=l.value,{productId:de}=t.value;return{queryKey:e.query.keys.items({productId:de}),queryFn:r(async()=>{let ge=await e.api.items.list({limit:Ti,query:$??void 0},{batch:!0});if("error"in ge)throw ge.error;return ge},"queryFn"),enabled:!W}}),{data:R,loading:P,error:D,refetching:k,dispose:O}=Gr({queryClient:e.query.client,options:S,restored:e.query.restored});i.push(O);let M=t.value.itemId??null,q=L(M),j=L(M?[M]:[]),le=X(()=>cu({apiData:R.value,apiLoading:P.value,apiError:D.value,forcedItemId:t.value.itemId,variantId:t.value.variantId,policy:o.value,savedItemId:q,savedItemIds:j,savedItemsLoading:d,savedItemsError:p}));i.push(le);async function _e(){if(!q.value)return;ee(()=>{h.value=!0,I.value=!0});let W=await(await e.intents.invoke("unsave:item",{itemId:q.value})).complete;if(W.code==="ok"){let de=W.data;"itemId"in de?(ee(()=>{q.value=null,h.value=!1}),s.onUnsave?.(de)):h.value=!1}else ee(()=>{h.value=!1,I.value=!1})}r(_e,"unsave");async function me(){if(!q.value)return;y.value=!0;let W=await(await e.intents.invoke("edit:item-lists",{itemId:q.value})).complete;if(W.code==="ok"){let de=W.data;"itemId"in de?(q.value=null,s.onUnsave?.(de)):s.onListsUpdate?.(de)}y.value=!1}r(me,"updateLists");async function Pe(){if(!q.value)return;let{productId:$,variantId:W}=t.value;if(!$)return;y.value=!0;let ge=await(await e.intents.invoke("edit:item-variant",{itemId:q.value,productId:$,variantId:W})).complete;ge.code==="ok"&&s.onVariantUpdate?.(ge.data),y.value=!1}r(Pe,"updateVariant");async function Ce(){let{productId:$,variantId:W}=t.value;if(!$)return;let de=o.value==="product"?void 0:W;ee(()=>{f.value=!0,v.value=!0});let Rt=await(await e.intents.invoke("save:item",{productId:$,variantId:de})).complete;if(Rt.code==="ok"){let as=Rt.data;ee(()=>{q.value=as.item.id,f.value=!1}),s.onSave?.(as)}else Rt.code==="error"&&console.warn("Failed to create item",Rt),ee(()=>{f.value=!1,v.value=!1})}r(Ce,"save");let st=re(()=>d.value||g.value||t.value.loading),ue=X(()=>{(v.value||I.value)&&!g.value&&!k.value&&ee(()=>{v.value=!1,I.value=!1})});i.push(ue);let Me=re(()=>{let $=!!q.value,W=f.value||k.value&&v.value,de=h.value||k.value&&I.value,ge="unsaved";return $?ge="saved":W&&(ge="saving"),{error:p.value,status:ge,savedItemId:q.value,savedItemIds:j.value,loading:st.value,submitting:g.value,saved:$,saving:W,unsaving:de}});async function Wo(){st.value||(Me.value.saved&&Me.value.savedItemId?await _e():Me.value.saved||await Ce())}return r(Wo,"toggle"),Object.assign(Me,{save:Ce,unsave:_e,updateLists:me,updateVariant:Pe,update:me,toggle:Wo,setOptions:a,setCallbacks:a,dispose:r(()=>{for(;i.length;)i.pop()?.()},"dispose")})},"itemStateSignal");var Wr=r(e=>()=>{let{data:t,loading:n,error:i}=e.state.swishQuery(()=>e.api.items.count(),{refetch:["item-create","item-delete"]}),s=L(0),o=L(!0),a=L(null);return X(()=>{ee(()=>{o.value=n.value,a.value=i.value,s.value=t.value?.count??0})}),re(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var lu="token-update",Xr=r(e=>(t,n)=>{let i=L(null),s=L(null),o=L(null),a=L(!n?.skip),c=L(!1),l=re(()=>a.value&&c.value);async function d(){if(!n?.skip?.value)try{a.value=!0;let p=await t(n?.variables?.value);ee(()=>{o.value="error"in p?p.error:null,i.value="data"in p?p.data:null,s.value="pageInfo"in p?p.pageInfo:null,a.value=!1,c.value=!0})}catch(p){ee(()=>{o.value=p,a.value=!1,c.value=!0})}}return r(d,"executeFetch"),X(()=>{if(d(),n?.refetch?.length){let p=[...n.refetch,lu];return e.events.subscribe(p,d)}}),{data:i,pageInfo:s,error:o,loading:a,refetching:l}},"swishQuerySignals");var Qe="GraphQL Client";var Di="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",Li="Response returned unexpected Content-Type:",Oi="An unknown error has occurred. The API did not return a data object or any errors in its response.",Nn={json:"application/json",multipart:"multipart/mixed"},_i="X-SDK-Variant",Mi="X-SDK-Version",Yr="shopify-graphql-client",Zr="1.4.2",jn=1e3,eo=[429,503],qi=/@(defer)\b/i,Jr=`\r
8
+ `,to=/boundary="?([^=";]+)"?/i,Fi=Jr+Jr;function xe(e,t=Qe){return e.startsWith(`${t}`)?e:`${t}: ${e}`}r(xe,"formatErrorMessage");function Ae(e){return e instanceof Error?e.message:JSON.stringify(e)}r(Ae,"getErrorMessage");function Bi(e){return e instanceof Error&&e.cause?e.cause:void 0}r(Bi,"getErrorCause");function Ni(e){return e.flatMap(({errors:t})=>t??[])}r(Ni,"combineErrors");function Un({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(Un,"validateRetries");function se(e,t){return t&&(typeof t!="object"||Array.isArray(t)||typeof t=="object"&&Object.keys(t).length>0)?{[e]:t}:{}}r(se,"getKeyValueIfValid");function ji(e,t){if(e.length===0)return t;let i={[e.pop()]:t};return e.length===0?i:ji(e,i)}r(ji,"buildDataObjectByPath");function so(e,t){return Object.keys(t||{}).reduce((n,i)=>(typeof t[i]=="object"||Array.isArray(t[i]))&&e[i]?(n[i]=so(e[i],t[i]),n):(n[i]=t[i],n),Array.isArray(e)?[...e]:{...e})}r(so,"combineObjects");function Ui([e,...t]){return t.reduce(so,{...e})}r(Ui,"buildCombinedDataObject");function Vi({clientLogger:e,customFetchApi:t=fetch,client:n=Qe,defaultRetryWaitTime:i=jn,retriableCodes:s=eo}){let o=r(async(a,c,l)=>{let d=c+1,p=l+1,f;try{if(f=await t(...a),e({type:"HTTP-Response",content:{requestParams:a,response:f}}),!f.ok&&s.includes(f.status)&&d<=p)throw new Error;let h=f?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return h&&e({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:h}}),f}catch(h){if(d<=p){let y=f?.headers.get("Retry-After");return await uu(y?parseInt(y,10):i),e({type:"HTTP-Retry",content:{requestParams:a,lastResponse:f,retryAttempt:c,maxRetries:l}}),o(a,d,l)}throw new Error(xe(`${l>0?`Attempted maximum number of ${l} network retries. Last message - `:""}${Ae(h)}`,n))}},"httpFetch");return o}r(Vi,"generateHttpFetch");async function uu(e){return new Promise(t=>setTimeout(t,e))}r(uu,"sleep");function $i({headers:e,url:t,customFetchApi:n=fetch,retries:i=0,logger:s}){Un({client:Qe,retries:i});let o={headers:e,url:t,retries:i},a=du(s),c=Vi({customFetchApi:n,clientLogger:a,defaultRetryWaitTime:jn}),l=pu(c,o),d=hu(l),p=bu(l);return{config:o,fetch:l,request:d,requestStream:p}}r($i,"createGraphQLClient");function du(e){return t=>{e&&e(t)}}r(du,"generateClientLogger");async function ro(e){let{errors:t,data:n,extensions:i}=await e.json();return{...se("data",n),...se("extensions",i),headers:e.headers,...t||!n?{errors:{networkStatusCode:e.status,message:xe(t?Di:Oi),...se("graphQLErrors",t),response:e}}:{}}}r(ro,"processJSONResponse");function pu(e,{url:t,headers:n,retries:i}){return async(s,o={})=>{let{variables:a,headers:c,url:l,retries:d,keepalive:p,signal:f}=o,h=JSON.stringify({query:s,variables:a});Un({client:Qe,retries:d});let y=Object.entries({...n,...c}).reduce((v,[I,S])=>(v[I]=Array.isArray(S)?S.join(", "):S.toString(),v),{});return!y[_i]&&!y[Mi]&&(y[_i]=Yr,y[Mi]=Zr),e([l??t,{method:"POST",headers:y,body:h,signal:f,keepalive:p}],1,d??i)}}r(pu,"generateFetch");function hu(e){return async(...t)=>{if(qi.test(t[0]))throw new Error(xe("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(Nn.json)?await ro(n):{errors:{networkStatusCode:i,message:xe(`${Li} ${o}`),response:n}}:{errors:{networkStatusCode:i,message:xe(s),response:n}}}catch(i){return{errors:{message:Ae(i),...n==null?{}:{networkStatusCode:n.status,response:n}}}}}}r(hu,"generateRequest");async function*fu(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(fu,"getStreamBodyIterator");function mu(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(c=>c.trim().length>0).map(c=>c.slice(c.indexOf(Fi)+Fi.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 - ${Ae(n)}`)}}}}r(mu,"readStreamChunk");function yu(e){return{async*[Symbol.asyncIterator](){try{yield{...await ro(e),hasNext:!1}}catch(t){yield{errors:{message:xe(Ae(t)),networkStatusCode:e.status,response:e},hasNext:!1}}}}}r(yu,"createJsonResponseAsyncIterator");function vu(e){return e.map(t=>{try{return JSON.parse(t)}catch(n){throw new Error(`Error in parsing multipart response - ${Ae(n)}`)}}).map(t=>{let{data:n,incremental:i,hasNext:s,extensions:o,errors:a}=t;if(!i)return{data:n||{},...se("errors",a),...se("extensions",o),hasNext:s};let c=i.map(({data:l,path:d,errors:p})=>({data:l&&d?ji(d,l):{},...se("errors",p)}));return{data:c.length===1?c[0].data:Ui([...c.map(({data:l})=>l)]),...se("errors",Ni(c)),hasNext:s}})}r(vu,"getResponseDataFromChunkBodies");function gu(e,t){if(e.length>0)throw new Error(Di,{cause:{graphQLErrors:e}});if(Object.keys(t).length===0)throw new Error(Oi)}r(gu,"validateResponseData");function wu(e,t){let n=(t??"").match(to),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=fu(e),o={},a;return{async*[Symbol.asyncIterator](){try{let c=!0;for await(let l of mu(s,i)){let d=vu(l);a=d.find(f=>f.extensions)?.extensions??a;let p=Ni(d);o=Ui([o,...d.map(({data:f})=>f)]),c=d.slice(-1)[0].hasNext,gu(p,o),yield{...se("data",o),...se("extensions",a),hasNext:c}}if(c)throw new Error("Response stream terminated unexpectedly")}catch(c){let l=Bi(c);yield{...se("data",o),...se("extensions",a),errors:{message:xe(Ae(c)),networkStatusCode:e.status,...se("graphQLErrors",l?.graphQLErrors),response:e},hasNext:!1}}}}}r(wu,"createMultipartResponseAsyncInterator");function bu(e){return async(...t)=>{if(!qi.test(t[0]))throw new Error(xe("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(Nn.json):return yu(n);case s.includes(Nn.multipart):return wu(n,s);default:throw new Error(`${Li} ${s}`,{cause:n})}}catch(n){return{async*[Symbol.asyncIterator](){let i=Bi(n);yield{errors:{message:xe(Ae(n)),...se("networkStatusCode",i?.status),...se("response",i)},hasNext:!1}}}}}}r(bu,"generateRequestStream");function Hi({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(Hi,"validateDomainAndGetStoreUrl");function Vn({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(Vn,"validateApiVersion");function $n(e){let t=e*3-2;return t===10?t:`0${t}`}r($n,"getQuarterMonth");function Qi(e,t,n){let i=t-n;return i<=0?`${e-1}-${$n(i+4)}`:`${e}-${$n(i)}`}r(Qi,"getPrevousVersion");function oo(){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(oo,"getCurrentApiVersion");function Gi(){let{year:e,quarter:t,version:n}=oo(),i=t===4?`${e+1}-01`:`${e}-${$n(t+1)}`;return[Qi(e,t,3),Qi(e,t,2),Qi(e,t,1),n,i,"unstable"]}r(Gi,"getCurrentSupportedApiVersions");function zi(e){return t=>({...t??{},...e.headers})}r(zi,"generateGetHeaders");function Ki({getHeaders:e,getApiUrl:t}){return(n,i)=>{let s=[n];if(i&&Object.keys(i).length>0){let{variables:o,apiVersion:a,headers:c,retries:l,signal:d}=i;s.push({...o?{variables:o}:{},...c?{headers:e(c)}:{},...a?{url:t(a)}:{},...l?{retries:l}:{},...d?{signal:d}:{}})}return s}}r(Ki,"generateGetGQLClientParams");var Wi="application/json",ao="storefront-api-client",co="1.0.10",lo="X-Shopify-Storefront-Access-Token",uo="Shopify-Storefront-Private-Token",po="X-SDK-Variant",ho="X-SDK-Version",fo="X-SDK-Variant-Source",Ge="Storefront API Client";function mo(e){if(e&&typeof window<"u")throw new Error(`${Ge}: 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(mo,"validatePrivateAccessTokenUsage");function yo(e,t){if(!e&&!t)throw new Error(`${Ge}: a public or private access token must be provided`);if(e&&t)throw new Error(`${Ge}: only provide either a public or private access token`)}r(yo,"validateRequiredAccessTokens");function Xi({storeDomain:e,apiVersion:t,publicAccessToken:n,privateAccessToken:i,clientName:s,retries:o=0,customFetchApi:a,logger:c}){let l=Gi(),d=Hi({client:Ge,storeDomain:e}),p={client:Ge,currentSupportedApiVersions:l,logger:c};Vn({...p,apiVersion:t}),yo(n,i),mo(i);let f=Iu(d,t,p),h={storeDomain:d,apiVersion:t,...n?{publicAccessToken:n}:{privateAccessToken:i},headers:{"Content-Type":Wi,Accept:Wi,[po]:ao,[ho]:co,...s?{[fo]:s}:{},...n?{[lo]:n}:{[uo]:i}},apiUrl:f(),clientName:s},y=$i({headers:h.headers,url:h.apiUrl,retries:o,customFetchApi:a,logger:c}),g=zi(h),v=Su(h,f),I=Ki({getHeaders:g,getApiUrl:v});return Object.freeze({config:h,getHeaders:g,getApiUrl:v,fetch:r((...R)=>y.fetch(...I(...R)),"fetch"),request:r((...R)=>y.request(...I(...R)),"request"),requestStream:r((...R)=>y.requestStream(...I(...R)),"requestStream")})}r(Xi,"createStorefrontApiClient");function Iu(e,t,n){return i=>{i&&Vn({...n,apiVersion:i});let s=(i??t).trim();return`${e}/api/${s}/graphql.json`}}r(Iu,"generateApiUrlFormatter");function Su(e,t){return n=>n?t(n):e.apiUrl}r(Su,"generateGetApiUrl");var Hn=`
9
9
  fragment productImageFields on Image {
10
10
  id
11
11
  altText
12
12
  url
13
13
  thumbhash
14
14
  }
15
- `,Xi=`
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
- `,Ji=`
96
+ `,Yi=`
97
97
  fragment productVariantDataFields on ProductVariant {
98
98
  id
99
99
  availableForSale
@@ -125,7 +125,7 @@ Values:
125
125
  value
126
126
  }
127
127
  }
128
- `;var yo=`
128
+ `;var vo=`
129
129
  query GetProduct(
130
130
  $productId: ID!
131
131
  $variantId: ID!
@@ -150,10 +150,10 @@ Values:
150
150
  }
151
151
  }
152
152
  }
153
- ${Xi}
154
153
  ${Ji}
154
+ ${Yi}
155
155
  ${Hn}
156
- `,vo=`
156
+ `,go=`
157
157
  query GetProductByHandle(
158
158
  $handle: String!
159
159
  $variantId: ID!
@@ -178,10 +178,10 @@ Values:
178
178
  }
179
179
  }
180
180
  }
181
- ${Xi}
182
181
  ${Ji}
182
+ ${Yi}
183
183
  ${Hn}
184
- `,go=`
184
+ `,wo=`
185
185
  query GetProductImagesById(
186
186
  $ids: [ID!]!
187
187
  $country: CountryCode!
@@ -206,7 +206,7 @@ Values:
206
206
  }
207
207
  }
208
208
  ${Hn}
209
- `,wo=`
209
+ `,bo=`
210
210
  query GetProductRecommendationsById(
211
211
  $productId: ID!
212
212
  $intent: ProductRecommendationIntent
@@ -217,7 +217,7 @@ Values:
217
217
  id
218
218
  }
219
219
  }
220
- `,bo=`
220
+ `,Io=`
221
221
  query GetProductRecommendationsByHandle(
222
222
  $handle: String!
223
223
  $intent: ProductRecommendationIntent
@@ -228,19 +228,19 @@ Values:
228
228
  id
229
229
  }
230
230
  }
231
- `,Io=`
231
+ `,So=`
232
232
  query GetProductIdByHandle($handle: String!) {
233
233
  product(handle: $handle) {
234
234
  id
235
235
  }
236
236
  }
237
- `,So=`
237
+ `,xo=`
238
238
  query GetProductHandleById($productId: ID!) {
239
239
  product(id: $productId) {
240
240
  handle
241
241
  }
242
242
  }
243
- `,xo=`
243
+ `,Co=`
244
244
  query GetCollectionProducts(
245
245
  $handle: String!
246
246
  $first: Int!
@@ -263,17 +263,17 @@ Values:
263
263
  }
264
264
  }
265
265
  }
266
- `;var Co=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(xo,{handle:t,first:n,after:i??void 0,country:s,language:o})},"loadCollectionProducts");var Ro=r(async(e,{productId:t,productHandle:n,variantId:i,selectedOptions:s,productMetafields:o=[],variantMetafields:a=[],country:c,language:l})=>{if(!t&&!n)throw new Error("Either productId or productHandle must be provided");let d=!!i,p=!!s?.length,f=t?yo:vo,h=t?{productId:we("Product",t),variantId:i?we("ProductVariant",i):"gid://shopify/ProductVariant/0",selectedOptions:p?s:[],productMetafields:o,variantMetafields:a,includeVariantById:d,includeVariantBySelectedOptions:p,country:c,language:l}:{handle:n,variantId:i?we("ProductVariant",i):"gid://shopify/ProductVariant/0",selectedOptions:p?s:[],productMetafields:o,variantMetafields:a,includeVariantById:d,includeVariantBySelectedOptions:p,country:c,language:l},y=await e.query(f,h),g=Eo(o),v=Eo(a),I=Su(y.data?.product??null,g,v),S=y.data?.variantNode??null,R=(S?Yi(S,v):null)??I?.variant??null;return{data:{product:I,variant:R},errors:y.errors}},"loadProduct"),Eo=r(e=>{let t=new Set;for(let{namespace:n}of e)n&&t.add(n);return Array.from(t)},"uniqueNamespaces"),ko=r((e,t)=>{let n={};for(let i of t)n[i]={};for(let i of e??[])i&&((n[i.namespace]??={})[i.key]=i.value);return n},"normalizeMetafields"),Yi=r((e,t)=>({...e,metafields:ko(e.metafields,t)}),"withNormalizedVariantMetafields"),Su=r((e,t,n)=>e?{...e,metafields:ko(e.metafields,t),selectedOrFirstAvailableVariant:e.selectedOrFirstAvailableVariant?Yi(e.selectedOrFirstAvailableVariant,n):null,variant:e.variant?Yi(e.variant,n):e.variant}:null,"withNormalizedMetafields");var Ao=r(async(e,{productHandle:t})=>{if(!t)throw new Error("A product handle must be provided");return e.query(Io,{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?we("ProductVariant",o.variantId.toString()):we("Product",o.productId.toString())),country:n,language:i};try{return{data:(await e.query(go,s)).data?.nodes.map(c=>c===null?null:"image"in c?c.image:"featuredImage"in c?c.featuredImage:null).filter(c=>c!==null)??[],errors:null}}catch(o){return console.error(o),{data:null,errors:o}}},"loadProductImages");var To=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 c={productId:we("Product",t),intent:i,country:s,language:o};return e.query(wo,c)}let a={handle:n,intent:i,country:s,language:o};return e.query(bo,a)},"loadProductRecommendations");var Do=r(async(e,{productId:t})=>{if(!t)throw new Error("A product ID must be provided");return e.query(So,{productId:we("Product",t)})},"loadProductHandle");var xu="2026-04",Cu=["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=>Ro(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=>To(this,{...t,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=r(async t=>Ao(this,t),"loadProductId");this.loadProductHandle=r(async t=>Do(this,t),"loadProductHandle");this.loadCollectionProducts=r(async t=>Co(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=pe(n.myshopifyDomain);this.shortCache=new Te(`storefront-api-short-${s}`,"max-age=60, stale-while-revalidate=3600"),this.longCache=new Te(`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=Wi({apiVersion:xu,customFetchApi:r((o,a)=>a?.method==="OPTIONS"?this.fetch(o,a):Cu.some(c=>a?.body?.toString().includes(`query ${c}`))?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 Eu=Object.defineProperty,u=r((e,t)=>Eu(e,"name",{value:t,configurable:!0}),"t"),Ru={bodySerializer:u(e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),"bodySerializer")},ku=u(({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:c,sseSleepFn:l,url:d,...p})=>{let f,h=l??(y=>new Promise(g=>setTimeout(g,y)));return{stream:u(async function*(){let y=o??3e3,g=0,v=p.signal??new AbortController().signal;for(;!v.aborted;){g++;let I=p.headers instanceof Headers?p.headers:new Headers(p.headers);f!==void 0&&I.set("Last-Event-ID",f);try{let S={redirect:"follow",...p,body:p.serializedBody,headers:I,signal:v},R=new Request(d,S);e&&(R=await e(d,S));let P=await(p.fetch??globalThis.fetch)(R);if(!P.ok)throw new Error(`SSE failed: ${P.status} ${P.statusText}`);if(!P.body)throw new Error("No body in SSE response");let D=P.body.pipeThrough(new TextDecoderStream).getReader(),k="",O=u(()=>{try{D.cancel()}catch{}},"abortHandler");v.addEventListener("abort",O);try{for(;;){let{done:M,value:q}=await D.read();if(M)break;k+=q,k=k.replace(/\r\n/g,`
266
+ `;var Eo=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(Co,{handle:t,first:n,after:i??void 0,country:s,language:o})},"loadCollectionProducts");var ko=r(async(e,{productId:t,productHandle:n,variantId:i,selectedOptions:s,productMetafields:o=[],variantMetafields:a=[],country:c,language:l})=>{if(!t&&!n)throw new Error("Either productId or productHandle must be provided");let d=!!i,p=!!s?.length,f=t?vo:go,h=t?{productId:we("Product",t),variantId:i?we("ProductVariant",i):"gid://shopify/ProductVariant/0",selectedOptions:p?s:[],productMetafields:o,variantMetafields:a,includeVariantById:d,includeVariantBySelectedOptions:p,country:c,language:l}:{handle:n,variantId:i?we("ProductVariant",i):"gid://shopify/ProductVariant/0",selectedOptions:p?s:[],productMetafields:o,variantMetafields:a,includeVariantById:d,includeVariantBySelectedOptions:p,country:c,language:l},y=await e.query(f,h),g=Ro(o),v=Ro(a),I=xu(y.data?.product??null,g,v),S=y.data?.variantNode??null,R=(S?Zi(S,v):null)??I?.variant??null;return{data:{product:I,variant:R},errors:y.errors}},"loadProduct"),Ro=r(e=>{let t=new Set;for(let{namespace:n}of e)n&&t.add(n);return Array.from(t)},"uniqueNamespaces"),Ao=r((e,t)=>{let n={};for(let i of t)n[i]={};for(let i of e??[])i&&((n[i.namespace]??={})[i.key]=i.value);return n},"normalizeMetafields"),Zi=r((e,t)=>({...e,metafields:Ao(e.metafields,t)}),"withNormalizedVariantMetafields"),xu=r((e,t,n)=>e?{...e,metafields:Ao(e.metafields,t),selectedOrFirstAvailableVariant:e.selectedOrFirstAvailableVariant?Zi(e.selectedOrFirstAvailableVariant,n):null,variant:e.variant?Zi(e.variant,n):e.variant}:null,"withNormalizedMetafields");var Po=r(async(e,{productHandle:t})=>{if(!t)throw new Error("A product handle must be provided");return e.query(So,{handle:t})},"loadProductId");var To=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?we("ProductVariant",o.variantId.toString()):we("Product",o.productId.toString())),country:n,language:i};try{return{data:(await e.query(wo,s)).data?.nodes.map(c=>c===null?null:"image"in c?c.image:"featuredImage"in c?c.featuredImage:null).filter(c=>c!==null)??[],errors:null}}catch(o){return console.error(o),{data:null,errors:o}}},"loadProductImages");var Do=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 c={productId:we("Product",t),intent:i,country:s,language:o};return e.query(bo,c)}let a={handle:n,intent:i,country:s,language:o};return e.query(Io,a)},"loadProductRecommendations");var Lo=r(async(e,{productId:t})=>{if(!t)throw new Error("A product ID must be provided");return e.query(xo,{productId:we("Product",t)})},"loadProductHandle");var Cu="2026-04",Eu=["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=>ko(this,{...t,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProduct");this.loadProductImages=r(async t=>To(this,{...t,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=r(async t=>Do(this,{...t,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=r(async t=>Po(this,t),"loadProductId");this.loadProductHandle=r(async t=>Lo(this,t),"loadProductHandle");this.loadCollectionProducts=r(async t=>Eo(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=pe(n.myshopifyDomain);this.shortCache=new Te(`storefront-api-short-${s}`,"max-age=60, stale-while-revalidate=3600"),this.longCache=new Te(`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=Xi({apiVersion:Cu,customFetchApi:r((o,a)=>a?.method==="OPTIONS"?this.fetch(o,a):Eu.some(c=>a?.body?.toString().includes(`query ${c}`))?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 Ru=Object.defineProperty,u=r((e,t)=>Ru(e,"name",{value:t,configurable:!0}),"t"),ku={bodySerializer:u(e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),"bodySerializer")},Au=u(({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:c,sseSleepFn:l,url:d,...p})=>{let f,h=l??(y=>new Promise(g=>setTimeout(g,y)));return{stream:u(async function*(){let y=o??3e3,g=0,v=p.signal??new AbortController().signal;for(;!v.aborted;){g++;let I=p.headers instanceof Headers?p.headers:new Headers(p.headers);f!==void 0&&I.set("Last-Event-ID",f);try{let S={redirect:"follow",...p,body:p.serializedBody,headers:I,signal:v},R=new Request(d,S);e&&(R=await e(d,S));let P=await(p.fetch??globalThis.fetch)(R);if(!P.ok)throw new Error(`SSE failed: ${P.status} ${P.statusText}`);if(!P.body)throw new Error("No body in SSE response");let D=P.body.pipeThrough(new TextDecoderStream).getReader(),k="",O=u(()=>{try{D.cancel()}catch{}},"abortHandler");v.addEventListener("abort",O);try{for(;;){let{done:M,value:q}=await D.read();if(M)break;k+=q,k=k.replace(/\r\n/g,`
267
267
  `).replace(/\r/g,`
268
268
  `);let j=k.split(`
269
269
 
270
270
  `);k=j.pop()??"";for(let le of j){let _e=le.split(`
271
271
  `),me=[],Pe;for(let ue of _e)if(ue.startsWith("data:"))me.push(ue.replace(/^data:\s*/,""));else if(ue.startsWith("event:"))Pe=ue.replace(/^event:\s*/,"");else if(ue.startsWith("id:"))f=ue.replace(/^id:\s*/,"");else if(ue.startsWith("retry:")){let Me=Number.parseInt(ue.replace(/^retry:\s*/,""),10);Number.isNaN(Me)||(y=Me)}let Ce,st=!1;if(me.length){let ue=me.join(`
272
- `);try{Ce=JSON.parse(ue),st=!0}catch{Ce=ue}}st&&(s&&await s(Ce),i&&(Ce=await i(Ce))),n?.({data:Ce,event:Pe,id:f,retry:y}),me.length&&(yield Ce)}}}finally{v.removeEventListener("abort",O),D.releaseLock()}break}catch(S){if(t?.(S),a!==void 0&&g>=a)break;let R=Math.min(y*2**(g-1),c??3e4);await h(R)}}},"createStream")()}},"createSseClient"),Au=u(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),Pu=u(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),Tu=u(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),_o=u(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let c=(e?s:s.map(l=>encodeURIComponent(l))).join(Pu(i));switch(i){case"label":return`.${c}`;case"matrix":return`;${n}=${c}`;case"simple":return c;default:return`${n}=${c}`}}let o=Au(i),a=s.map(c=>i==="label"||i==="simple"?e?c:encodeURIComponent(c):Gn({allowReserved:e,name:n,value:c})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),Gn=u(({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"),Mo=u(({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 l=[];Object.entries(s).forEach(([p,f])=>{l=[...l,p,e?f:encodeURIComponent(f)]});let d=l.join(",");switch(i){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}let a=Tu(i),c=Object.entries(s).map(([l,d])=>Gn({allowReserved:e,name:i==="deepObject"?`${n}[${l}]`:l,value:d})).join(a);return i==="label"||i==="matrix"?a+c:c},"serializeObjectParam"),Du=/\{[^{}]+\}/g,Lu=u(({path:e,url:t})=>{let n=t,i=t.match(Du);if(i)for(let s of i){let o=!1,a=s.substring(1,s.length-1),c="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),c="label"):a.startsWith(";")&&(a=a.substring(1),c="matrix");let l=e[a];if(l==null)continue;if(Array.isArray(l)){n=n.replace(s,_o({explode:o,name:a,style:c,value:l}));continue}if(typeof l=="object"){n=n.replace(s,Mo({explode:o,name:a,style:c,value:l,valueOnly:!0}));continue}if(c==="matrix"){n=n.replace(s,`;${Gn({name:a,value:l})}`);continue}let d=encodeURIComponent(c==="label"?`.${l}`:l);n=n.replace(s,d)}return n},"defaultPathSerializer"),Ou=u(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=Lu({path:t,url:a}));let c=n?i(n):"";return c.startsWith("?")&&(c=c.substring(1)),c&&(a+=`?${c}`),a},"getUrl");function es(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(es,"U");u(es,"getValidRequestBody");var _u=u(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"),qo=u(({parameters:e={},...t}={})=>u(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 c=_o({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});c&&i.push(c)}else if(typeof o=="object"){let c=Mo({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});c&&i.push(c)}else{let c=Gn({allowReserved:a.allowReserved,name:s,value:o});c&&i.push(c)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),Mu=u(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"),qu=u((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"),Fu=u(async({security:e,...t})=>{for(let n of e){if(qu(t,n.name))continue;let i=await _u(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"),Lo=u(e=>Ou({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:qo(e.querySerializer),url:e.url}),"buildUrl"),Oo=u((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=Fo(e.headers,t.headers),i},"mergeConfigs"),Bu=u(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),Fo=u((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?Bu(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"),Bo=class{static{r(this,"z")}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}};u(Bo,"Interceptors");var Zi=Bo,Nu=u(()=>({error:new Zi,request:new Zi,response:new Zi}),"createInterceptors"),ju=qo({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Uu={"Content-Type":"application/json"},ts=u((e={})=>({...Ru,headers:Uu,parseAs:"auto",querySerializer:ju,...e}),"createConfig"),No=u((e={})=>{let t=Oo(ts(),e),n=u(()=>({...t}),"getConfig"),i=u(d=>(t=Oo(t,d),n()),"setConfig"),s=Nu(),o=u(async d=>{let p={...t,...d,fetch:d.fetch??t.fetch??globalThis.fetch,headers:Fo(t.headers,d.headers),serializedBody:void 0};p.security&&await Fu({...p,security:p.security}),p.requestValidator&&await p.requestValidator(p),p.body!==void 0&&p.bodySerializer&&(p.serializedBody=p.bodySerializer(p.body)),(p.body===void 0||p.serializedBody==="")&&p.headers.delete("Content-Type");let f=Lo(p);return{opts:p,url:f}},"beforeRequest"),a=u(async d=>{let{opts:p,url:f}=await o(d),h={redirect:"follow",...p,body:es(p)},y=new Request(f,h);for(let k of s.request.fns)k&&(y=await k(y,p));let g=p.fetch,v;try{v=await g(y)}catch(k){let O=k;for(let M of s.error.fns)M&&(O=await M(k,void 0,y,p));if(O=O||{},p.throwOnError)throw O;return p.responseStyle==="data"?void 0:{error:O,request:y,response:void 0}}for(let k of s.response.fns)k&&(v=await k(v,y,p));let I={request:y,response:v};if(v.ok){let k=(p.parseAs==="auto"?Mu(v.headers.get("Content-Type")):p.parseAs)??"json";if(v.status===204||v.headers.get("Content-Length")==="0"){let M;switch(k){case"arrayBuffer":case"blob":case"text":M=await v[k]();break;case"formData":M=new FormData;break;case"stream":M=v.body;break;default:M={};break}return p.responseStyle==="data"?M:{data:M,...I}}let O;switch(k){case"arrayBuffer":case"blob":case"formData":case"text":O=await v[k]();break;case"json":{let M=await v.text();O=M?JSON.parse(M):{};break}case"stream":return p.responseStyle==="data"?v.body:{data:v.body,...I}}return k==="json"&&(p.responseValidator&&await p.responseValidator(O),p.responseTransformer&&(O=await p.responseTransformer(O))),p.responseStyle==="data"?O:{data:O,...I}}let S=await v.text(),R;try{R=JSON.parse(S)}catch{}let P=R??S,D=P;for(let k of s.error.fns)k&&(D=await k(P,v,y,p));if(D=D||{},p.throwOnError)throw D;return p.responseStyle==="data"?void 0:{error:D,...I}},"request"),c=u(d=>p=>a({...p,method:d}),"makeMethodFn"),l=u(d=>async p=>{let{opts:f,url:h}=await o(p);return ku({...f,body:f.body,headers:f.headers,method:d,onRequest:u(async(y,g)=>{let v=new Request(y,g);for(let I of s.request.fns)I&&(v=await I(v,f));return v},"onRequest"),serializedBody:es(f),url:h})},"makeSseFn");return{buildUrl:Lo,connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),getConfig:n,head:c("HEAD"),interceptors:s,options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),request:a,setConfig:i,sse:{connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),head:l("HEAD"),options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),trace:l("TRACE")},trace:c("TRACE")}},"createClient"),w=No(ts({baseUrl:"https://swish.app/api/2026-07"})),Vu=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),$u=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),Hu=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),Qu=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),Gu=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),zu=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),Ku=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),Wu=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),Xu=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),Ju=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),Yu=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Zu=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),ed=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),td=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),nd=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),id=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),sd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),rd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),od=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),ad=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),cd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),ld=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),ud=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),dd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),pd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),hd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),fd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),md=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),yd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),vd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),gd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),wd=u(e=>(e?.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),bd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),Id=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),Sd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),xd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),Cd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),Ed=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),Rd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),kd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),Ad=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),Pd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items/{itemId}",...e}),"smartListsControllerRemoveItem"),Td=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/themes",...e}),"themesControllerFindAll"),Dd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/themes/live",...e}),"themesControllerFindLive"),Ld=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/themes/{themeId}",...e}),"themesControllerFindById"),Od=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/products",...e}),"productsControllerFindAll"),_d=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/products/{productId}",...e}),"productsControllerFindById"),Md=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/tokens",...e}),"adminTokensControllerFindAll"),qd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/tokens",...e,headers:{"Content-Type":"application/json",...e.headers}}),"adminTokensControllerCreate"),Fd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/tokens/{id}",...e}),"adminTokensControllerRevoke"),Bd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations",...e}),"integrationsControllerFindAll"),Nd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations/{integrationId}",...e}),"integrationsControllerFindById"),jd=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations/{integrationId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"integrationsControllerUpdate"),Ud=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations/{integrationId}/connection",...e}),"integrationsControllerDisconnect"),Vd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations/{integrationId}/connection",...e}),"integrationsControllerGetConnection"),$d=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations/{integrationId}/connection",...e,headers:{"Content-Type":"application/json",...e.headers}}),"integrationsControllerConnect"),Hd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers",...e}),"customersControllerFindAll"),Qd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}",...e}),"customersControllerFindById"),Gd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerItemsControllerDeleteMany"),zd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items",...e}),"customerItemsControllerFindAll"),Kd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerItemsControllerCreate"),Wd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items/count",...e}),"customerItemsControllerCount"),Xd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items/{itemId}",...e}),"customerItemsControllerDeleteById"),Jd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items/{itemId}",...e}),"customerItemsControllerFindById"),Yd=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerItemsControllerUpdate"),Zd=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerItemsControllerSetLists"),ep=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists",...e}),"customerListsControllerFindAll"),tp=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerListsControllerCreate"),np=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}",...e}),"customerListsControllerDeleteById"),ip=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}",...e}),"customerListsControllerFindById"),sp=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerListsControllerUpdate"),rp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}/items",...e}),"customerListsControllerFindItems"),op=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerListsControllerAddItems"),ap=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerListsControllerSetItemsOrder"),cp=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}/items/{itemId}",...e}),"customerListsControllerRemoveItem"),lp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/smart-lists",...e}),"customerSmartListsControllerFindAll"),up=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/smart-lists/{smartListId}",...e}),"customerSmartListsControllerFindById"),dp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/smart-lists/{smartListId}/items",...e}),"customerSmartListsControllerFindItems"),pp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/reports",...e}),"reportsControllerGetIndex"),hp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/reports/most-saved-products",...e}),"reportsControllerGetMostSavedProducts"),fp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/reports/most-saved-variants",...e}),"reportsControllerGetMostSavedVariants"),mp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/analytics/summary",...e}),"adminAnalyticsControllerGetSummary"),yp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/analytics/metrics",...e}),"adminAnalyticsControllerGetMetrics"),vp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/analytics/dimensions",...e}),"adminAnalyticsControllerGetDimensions"),gp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/events",...e}),"adminEventsControllerFindEvents"),wp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups",...e}),"setupControllerList"),bp=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups",...e,headers:{"Content-Type":"application/json",...e.headers}}),"setupControllerCreate"),Ip=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups/state",...e}),"setupControllerGetState"),Sp=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups/state",...e,headers:{"Content-Type":"application/json",...e.headers}}),"setupControllerPatchState"),xp=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups/{id}",...e}),"setupControllerDelete"),Cp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups/{id}",...e}),"setupControllerGet"),Ep=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"setupControllerUpdate"),Rp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/onboarding",...e}),"onboardingChecklistsControllerList"),kp=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/onboarding/{checklistId}",...e}),"onboardingChecklistsControllerDelete"),Ap=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/onboarding/{checklistId}",...e}),"onboardingChecklistsControllerGet"),Pp=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/admin/onboarding/{checklistId}/{stepId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"onboardingChecklistsControllerUpsertStep"),Tp=u(e=>(e?.client??w).delete({url:"/admin/mcp",...e}),"mcpControllerDelete"),Dp=u(e=>(e?.client??w).get({url:"/admin/mcp",...e}),"mcpControllerGet"),Lp=u(e=>(e?.client??w).post({url:"/admin/mcp",...e}),"mcpControllerPost"),Op=u(e=>(e.client??w).post({url:"/flow/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"flowControllerCreateList"),_p=u(e=>(e.client??w).post({url:"/flow/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"flowControllerAddItem"),Mp=u(e=>(e.client??w).post({url:"/flow/items/remove",...e,headers:{"Content-Type":"application/json",...e.headers}}),"flowControllerRemoveItem"),qp=u(e=>(e.client??w).post({url:"/flow/lists/delete",...e,headers:{"Content-Type":"application/json",...e.headers}}),"flowControllerDeleteList"),Et="2026-07",jo=u(e=>new Fp(e),"createApiClient"),Uo=class{static{r(this,"Ur")}constructor(t){this.version=Et,this.items={list:u(n=>this.handlePaginatedRequest(Ju({query:n,client:this.client})),"list"),create:u(n=>this.handleRequest(Yu({body:n,client:this.client})),"create"),delete:u(n=>this.handleRequest(Xu({body:{itemIds:n},client:this.client})),"delete"),findById:u(n=>this.handleRequest(td({path:{itemId:n},client:this.client})),"findById"),updateById:u((n,i)=>this.handleRequest(nd({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:u(n=>this.handleRequest(ed({path:{itemId:n},client:this.client})),"deleteById"),setListsById:u((n,i)=>this.handleRequest(id({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:u(()=>this.handleRequest(Zu({client:this.client})),"count")},this.lists={list:u(n=>this.handlePaginatedRequest(Vu({query:n,client:this.client})),"list"),create:u(n=>this.handleRequest($u({body:n,client:this.client})),"create"),findById:u(n=>this.handleRequest(Qu({path:{listId:n},client:this.client})),"findById"),updateById:u((n,i)=>this.handleRequest(Gu({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:u(n=>this.handleRequest(Hu({path:{listId:n},client:this.client})),"deleteById"),orderItems:u((n,i)=>this.handleRequest(zu({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:u((n,i)=>this.handleRequest(Ku({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:u((n,i)=>this.handleRequest(Wu({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:u((n={})=>this.handleRequest(rd({body:n,client:this.client})),"createToken"),identify:u(n=>this.handleRequest(sd({body:n,client:this.client})),"identify"),getProfile:u(()=>this.handleRequest(od({client:this.client})),"getProfile"),updateProfile:u(n=>this.handleRequest(ad({body:n,client:this.client})),"updateProfile")},this.orders={list:u(n=>this.handlePaginatedRequest(ld({query:n,client:this.client})),"list"),findById:u(n=>this.handleRequest(ud({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:u(n=>this.handlePaginatedRequest(dd({query:n,client:this.client})),"list"),save:u(n=>this.handleRequest(pd({body:{listId:n},client:this.client})),"save"),findById:u(n=>this.handleRequest(fd({path:{sharedListId:n},client:this.client})),"findById"),deleteById:u(n=>this.handleRequest(hd({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:u((n,i)=>this.handlePaginatedRequest(md({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.tracking={track:u(n=>this.handleRequest(cd({body:n,client:this.client})),"track")},this.notifications={list:u(n=>this.handlePaginatedRequest(yd({query:n,client:this.client})),"list"),getUnreadCount:u(()=>this.handleRequest(vd({client:this.client})),"getUnreadCount"),markAsRead:u(n=>this.handleRequest(gd({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:u(()=>this.handleRequest(wd({client:this.client})),"markAllAsRead"),deleteById:u(n=>this.handleRequest(bd({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:u(n=>this.handlePaginatedRequest(Id({query:n,client:this.client})),"list"),create:u(n=>this.handleRequest(Sd({body:n,client:this.client})),"create"),findById:u(n=>this.handleRequest(Cd({path:{id:n},client:this.client})),"findById"),updateById:u((n,i)=>this.handleRequest(Ed({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:u(n=>this.handleRequest(xd({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:u(()=>this.handleRequest(Rd({client:this.client})),"list"),findById:u(n=>this.handleRequest(kd({path:{smartListId:n},client:this.client})),"findById"),findItems:u((n,i)=>this.handlePaginatedRequest(Ad({path:{smartListId:n},query:i,client:this.client})),"findItems"),removeItem:u((n,i)=>this.handleRequest(Pd({path:{smartListId:n,itemId:i},client:this.client})),"removeItem")},this.themes={list:u(n=>this.handlePaginatedRequest(Td({query:n,client:this.client})),"list"),findLive:u(()=>this.handleRequest(Dd({client:this.client})),"findLive"),findById:u(n=>this.handleRequest(Ld({path:{themeId:n},client:this.client})),"findById")},this.products={list:u(n=>this.handlePaginatedRequest(Od({query:n,client:this.client})),"list"),findById:u((n,i)=>this.handleRequest(_d({path:{productId:n},query:i,client:this.client})),"findById")},this.adminTokens={list:u(()=>this.handleRequest(Md({client:this.client})),"list"),create:u(n=>this.handleRequest(qd({body:n,client:this.client})),"create"),revokeById:u(n=>this.handleRequest(Fd({path:{id:n},client:this.client})),"revokeById")},this.integrations={list:u(()=>this.handleRequest(Bd({client:this.client})),"list"),findById:u(n=>this.handleRequest(Nd({path:{integrationId:n},client:this.client})),"findById"),updateById:u((n,i)=>this.handleRequest(jd({path:{integrationId:n},body:i,client:this.client})),"updateById"),getConnection:u(n=>this.handleRequest(Vd({path:{integrationId:n},client:this.client})),"getConnection"),connect:u((n,i)=>this.handleConnectRequest($d({path:{integrationId:n},body:i,client:this.client})),"connect"),disconnect:u(n=>this.handleRequest(Ud({path:{integrationId:n},client:this.client})),"disconnect")},this.customers={list:u(n=>this.handlePaginatedRequest(Hd({query:n,client:this.client})),"list"),findById:u(n=>this.handleRequest(Qd({path:{customerId:n},client:this.client})),"findById")},this.customerItems={list:u((n,i)=>this.handlePaginatedRequest(zd({path:{customerId:n},query:i,client:this.client})),"list"),create:u((n,i)=>this.handleRequest(Kd({path:{customerId:n},body:i,client:this.client})),"create"),delete:u((n,i)=>this.handleRequest(Gd({path:{customerId:n},body:{itemIds:i},client:this.client})),"delete"),count:u(n=>this.handleRequest(Wd({path:{customerId:n},client:this.client})),"count"),findById:u((n,i)=>this.handleRequest(Jd({path:{customerId:n,itemId:i},client:this.client})),"findById"),updateById:u((n,i,s)=>this.handleRequest(Yd({path:{customerId:n,itemId:i},body:s,client:this.client})),"updateById"),deleteById:u((n,i)=>this.handleRequest(Xd({path:{customerId:n,itemId:i},client:this.client})),"deleteById"),setListsById:u((n,i,s)=>this.handleRequest(Zd({path:{customerId:n,itemId:i},body:{listIds:s},client:this.client})),"setListsById")},this.customerLists={list:u((n,i)=>this.handlePaginatedRequest(ep({path:{customerId:n},query:i,client:this.client})),"list"),create:u((n,i)=>this.handleRequest(tp({path:{customerId:n},body:i,client:this.client})),"create"),findById:u((n,i)=>this.handleRequest(ip({path:{customerId:n,listId:i},client:this.client})),"findById"),updateById:u((n,i,s)=>this.handleRequest(sp({path:{customerId:n,listId:i},body:s,client:this.client})),"updateById"),deleteById:u((n,i)=>this.handleRequest(np({path:{customerId:n,listId:i},client:this.client})),"deleteById"),findItems:u((n,i,s)=>this.handlePaginatedRequest(rp({path:{customerId:n,listId:i},query:s,client:this.client})),"findItems"),addItems:u((n,i,s)=>this.handleRequest(op({path:{customerId:n,listId:i},body:{itemIds:s},client:this.client})),"addItems"),orderItems:u((n,i,s)=>this.handleRequest(ap({path:{customerId:n,listId:i},body:{itemIds:s},client:this.client})),"orderItems"),removeItem:u((n,i,s)=>this.handleRequest(cp({path:{customerId:n,listId:i,itemId:s},client:this.client})),"removeItem")},this.customerSmartLists={list:u(n=>this.handleRequest(lp({path:{customerId:n},client:this.client})),"list"),findById:u((n,i)=>this.handleRequest(up({path:{customerId:n,smartListId:i},client:this.client})),"findById"),findItems:u((n,i,s)=>this.handlePaginatedRequest(dp({path:{customerId:n,smartListId:i},query:s,client:this.client})),"findItems")},this.setups={list:u(()=>this.handleRequest(wp({client:this.client})),"list"),create:u(n=>this.handleRequest(bp({body:n,client:this.client})),"create"),getState:u(()=>this.handleRequest(Ip({client:this.client})),"getState"),patchState:u(n=>this.handleRequest(Sp({body:n,client:this.client})),"patchState"),findById:u(n=>this.handleRequest(Cp({path:{id:n},client:this.client})),"findById"),updateById:u((n,i)=>this.handleRequest(Ep({path:{id:n},body:i,client:this.client})),"updateById"),deleteById:u(n=>this.handleRequest(xp({path:{id:n},client:this.client})),"deleteById")},this.reports={list:u(()=>this.handlePaginatedRequest(pp({client:this.client})),"list"),mostSavedProducts:u(n=>this.handlePaginatedRequest(hp({query:n,client:this.client})),"mostSavedProducts"),mostSavedVariants:u(n=>this.handlePaginatedRequest(fp({query:n,client:this.client})),"mostSavedVariants")},this.adminAnalytics={getSummary:u(n=>this.handleRequest(mp({query:n,client:this.client})),"getSummary"),getMetrics:u(n=>this.handleRequest(yp({query:n,client:this.client})),"getMetrics"),getDimensions:u(n=>this.handleRequest(vp({query:n,client:this.client})),"getDimensions")},this.adminEvents={list:u(n=>this.handlePaginatedRequest(gp({query:n,client:this.client})),"list")},this.onboarding={list:u(()=>this.handleRequest(Rp({client:this.client})),"list"),get:u(n=>this.handleRequest(Ap({path:{checklistId:n},client:this.client})),"get"),delete:u(n=>this.handleRequest(kp({path:{checklistId:n},client:this.client})),"delete"),upsertStep:u((n,i,s)=>this.handleRequest(Pp({path:{checklistId:n,stepId:i},body:s,client:this.client})),"upsertStep")},this.mcp={get:u(()=>this.handleRequest(Dp({client:this.client})),"get"),post:u(()=>this.handleRequest(Lp({client:this.client})),"post"),delete:u(()=>this.handleRequest(Tp({client:this.client})),"delete")},this.flow={createList:u(n=>this.handleRequest(Op({body:n,client:this.client})),"createList"),addItem:u(n=>this.handleRequest(_p({body:n,client:this.client})),"addItem"),removeItem:u(n=>this.handleRequest(Mp({body:n,client:this.client})),"removeItem"),deleteList:u(n=>this.handleRequest(qp({body:n,client:this.client})),"deleteList")},this.handleRequest=u(async n=>{let{data:i,error:s}=await n;return s!=null&&s.error?{error:s.error}:{data:i?.data}},"handleRequest"),this.handleConnectRequest=u(async n=>{let i=await n,{data:s,error:o}=i;return o!=null&&o.error?{error:o.error}:s&&"redirectUrl"in s?{data:s}:{data:s?.data??null}},"handleConnectRequest"),this.handlePaginatedRequest=u(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=No(ts({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}};u(Uo,"SwishClient");var Fp=Uo;var Qo=na(Ho(),1);var Go=r(e=>new Qo.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 zn=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":Et},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=pe(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${t}`)??void 0}setSessionId(t){let n=pe(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${n}`,t)}deleteSessionId(){let t=pe(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${t}`)}getSwishToken(){let t=pe(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${t}`)??void 0}setSwishToken(t){let n=pe(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${n}`,t)}deleteSwishToken(){let t=pe(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 Kn=class{static{r(this,"SwishApi")}constructor(t,n,i,s,o){this.config=t,this.storefrontContext=n;let a=pe(n.myshopifyDomain);this.cache=new Te(`swish-api-${a}`,"max-age=60, stale-while-revalidate=3600",s+Et),this.cache.cleanupExpiredEntries().catch(l=>{console.warn("Swish API cache initialization cleanup error:",l)}),this.auth=new zn(this,n,i,o);let c={authToken:this.auth.getSwishToken(),config:{...t,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)};this.apiClient=jo(c),this.itemsLoader=Go(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"),c=s.includes("/profiles");return i==="GET"&&!a&&!c?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(),c=t.ok;await this.cache.clear(),o&&a&&c&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(t,n),t}setAuthToken(t){this.apiClient.setAuthToken(t)}getAuthToken(){return this.auth.getSwishToken()}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"),removeItem:r(async(t,n)=>this.apiClient.smartLists.removeItem(t,n),"removeItem")}}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 Wn=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","DELETE /smart-lists\\/([^/]+)\\/items\\/([^/]+)\\/?$":"item-delete","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[c,l]=a.split(" ");return c!==t?!1:new RegExp(l).test(s)})?.[1]}};var Xn=class{constructor(t,n){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,this.isPreview=n,this.previewCssStylesheet=n?new CSSStyleSheet:void 0,this.themeVariablesStylesheet=new CSSStyleSheet,this.icons=L(n?{}:t.options.ui.icons??{}),this.uiOptions=L(t.options.ui)}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"),t.getAttribute("ref")==="drawer"&&this.swishApp.events.publish("drawer-state-change",{open:!0}))})().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.getAttribute("ref")==="drawer"&&this.swishApp.events.publish("drawer-state-change",{open:!1}),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:c})=>{t.removeEventListener(a,c)})},"cleanup");Object.entries(n).forEach(([a,c])=>{let l=r(d=>{let p=c(d);o(),i(p)},"listener");s.push({event:a,listener:l}),t.addEventListener(a,l)})})}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}hideDrawer(){let t=this.queryComponent("drawer");!t||t.getAttribute("open")!=="true"||t.dispatchEvent(new CustomEvent("close"))}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}initListDetailPage(){this.swishApp.placements.create({id:"swish-list-detail-page",target:{selector:"#wishlist-page"},mount:{at:"target",mode:"replace"},element:{name:"list-detail-page"}}).mount()}async showToast(t,n){let i=Date.now(),s=n?.signal,o=await this.requireUiComponent("toast-manager",{singleInstance:!0,onHydrated:r(a=>{s?.aborted||(a.current?.show(t,i),s?.addEventListener("abort",()=>a.current?.hide(i),{once:!0}))},"onHydrated")});return new Promise(a=>{if(s?.aborted){a({code:"closed"});return}let c=r(f=>{o.removeEventListener(`close-${i}`,l),o.removeEventListener(`submit-${i}`,d),s?.removeEventListener("abort",p),a(f)},"finish"),l=r(()=>c({code:"closed"}),"onClose"),d=r(()=>c({code:"ok",data:void 0}),"onSubmit"),p=r(()=>c({code:"closed"}),"onAbort");o.addEventListener(`close-${i}`,l),o.addEventListener(`submit-${i}`,d),s?.addEventListener("abort",p,{once:!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]=await Promise.all([this.loadTemplate(t),this.loadCricalResources()]),s=document.createElement("template");s.innerHTML=i.replace(' shadowrootmode="open"',"");let o=s.content.firstElementChild;return o.addEventListener("connected",()=>{o.shadowRoot&&(o.shadowRoot.adoptedStyleSheets=[this.themeVariablesStylesheet],this.hydrateElement(t,o,n?.onHydrated))},{once:!0}),o}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:c}])=>{s.shadowRoot&&o&&(s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,...a,o],s.shadowRoot?.querySelector(":host > style")?.remove()),c(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@${he}/${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@${he}/${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@${he}/theme.css`,n=await fetch(t).then(s=>s.text());this.themeVariablesStylesheet.replaceSync(n);let i=zo(this.swishApp.options.ui.design);Object.entries(i).forEach(([s,o])=>{this.themeVariablesStylesheet.cssRules[0].cssRules[0].style.setProperty(s,o)})})(),this._loadCricalResourcesPromise)}applyPreview({design:t,css:n,icons:i,...s}){if(!this.previewCssStylesheet)return;let o=n?.filter(l=>typeof l=="string").map(l=>l.toString()).join(`
273
- `)??"",a=t?zo(t):{},c=`@layer theme { :host {
272
+ `);try{Ce=JSON.parse(ue),st=!0}catch{Ce=ue}}st&&(s&&await s(Ce),i&&(Ce=await i(Ce))),n?.({data:Ce,event:Pe,id:f,retry:y}),me.length&&(yield Ce)}}}finally{v.removeEventListener("abort",O),D.releaseLock()}break}catch(S){if(t?.(S),a!==void 0&&g>=a)break;let R=Math.min(y*2**(g-1),c??3e4);await h(R)}}},"createStream")()}},"createSseClient"),Pu=u(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),Tu=u(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),Du=u(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),Mo=u(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let c=(e?s:s.map(l=>encodeURIComponent(l))).join(Tu(i));switch(i){case"label":return`.${c}`;case"matrix":return`;${n}=${c}`;case"simple":return c;default:return`${n}=${c}`}}let o=Pu(i),a=s.map(c=>i==="label"||i==="simple"?e?c:encodeURIComponent(c):Gn({allowReserved:e,name:n,value:c})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),Gn=u(({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"),qo=u(({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 l=[];Object.entries(s).forEach(([p,f])=>{l=[...l,p,e?f:encodeURIComponent(f)]});let d=l.join(",");switch(i){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}let a=Du(i),c=Object.entries(s).map(([l,d])=>Gn({allowReserved:e,name:i==="deepObject"?`${n}[${l}]`:l,value:d})).join(a);return i==="label"||i==="matrix"?a+c:c},"serializeObjectParam"),Lu=/\{[^{}]+\}/g,Ou=u(({path:e,url:t})=>{let n=t,i=t.match(Lu);if(i)for(let s of i){let o=!1,a=s.substring(1,s.length-1),c="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),c="label"):a.startsWith(";")&&(a=a.substring(1),c="matrix");let l=e[a];if(l==null)continue;if(Array.isArray(l)){n=n.replace(s,Mo({explode:o,name:a,style:c,value:l}));continue}if(typeof l=="object"){n=n.replace(s,qo({explode:o,name:a,style:c,value:l,valueOnly:!0}));continue}if(c==="matrix"){n=n.replace(s,`;${Gn({name:a,value:l})}`);continue}let d=encodeURIComponent(c==="label"?`.${l}`:l);n=n.replace(s,d)}return n},"defaultPathSerializer"),_u=u(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=Ou({path:t,url:a}));let c=n?i(n):"";return c.startsWith("?")&&(c=c.substring(1)),c&&(a+=`?${c}`),a},"getUrl");function ts(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(ts,"U");u(ts,"getValidRequestBody");var Mu=u(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"),Fo=u(({parameters:e={},...t}={})=>u(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 c=Mo({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});c&&i.push(c)}else if(typeof o=="object"){let c=qo({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});c&&i.push(c)}else{let c=Gn({allowReserved:a.allowReserved,name:s,value:o});c&&i.push(c)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),qu=u(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"),Fu=u((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"),Bu=u(async({security:e,...t})=>{for(let n of e){if(Fu(t,n.name))continue;let i=await Mu(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"),Oo=u(e=>_u({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Fo(e.querySerializer),url:e.url}),"buildUrl"),_o=u((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"),Nu=u(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),Bo=u((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?Nu(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"),No=class{static{r(this,"z")}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}};u(No,"Interceptors");var es=No,ju=u(()=>({error:new es,request:new es,response:new es}),"createInterceptors"),Uu=Fo({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Vu={"Content-Type":"application/json"},ns=u((e={})=>({...ku,headers:Vu,parseAs:"auto",querySerializer:Uu,...e}),"createConfig"),jo=u((e={})=>{let t=_o(ns(),e),n=u(()=>({...t}),"getConfig"),i=u(d=>(t=_o(t,d),n()),"setConfig"),s=ju(),o=u(async d=>{let p={...t,...d,fetch:d.fetch??t.fetch??globalThis.fetch,headers:Bo(t.headers,d.headers),serializedBody:void 0};p.security&&await Bu({...p,security:p.security}),p.requestValidator&&await p.requestValidator(p),p.body!==void 0&&p.bodySerializer&&(p.serializedBody=p.bodySerializer(p.body)),(p.body===void 0||p.serializedBody==="")&&p.headers.delete("Content-Type");let f=Oo(p);return{opts:p,url:f}},"beforeRequest"),a=u(async d=>{let{opts:p,url:f}=await o(d),h={redirect:"follow",...p,body:ts(p)},y=new Request(f,h);for(let k of s.request.fns)k&&(y=await k(y,p));let g=p.fetch,v;try{v=await g(y)}catch(k){let O=k;for(let M of s.error.fns)M&&(O=await M(k,void 0,y,p));if(O=O||{},p.throwOnError)throw O;return p.responseStyle==="data"?void 0:{error:O,request:y,response:void 0}}for(let k of s.response.fns)k&&(v=await k(v,y,p));let I={request:y,response:v};if(v.ok){let k=(p.parseAs==="auto"?qu(v.headers.get("Content-Type")):p.parseAs)??"json";if(v.status===204||v.headers.get("Content-Length")==="0"){let M;switch(k){case"arrayBuffer":case"blob":case"text":M=await v[k]();break;case"formData":M=new FormData;break;case"stream":M=v.body;break;default:M={};break}return p.responseStyle==="data"?M:{data:M,...I}}let O;switch(k){case"arrayBuffer":case"blob":case"formData":case"text":O=await v[k]();break;case"json":{let M=await v.text();O=M?JSON.parse(M):{};break}case"stream":return p.responseStyle==="data"?v.body:{data:v.body,...I}}return k==="json"&&(p.responseValidator&&await p.responseValidator(O),p.responseTransformer&&(O=await p.responseTransformer(O))),p.responseStyle==="data"?O:{data:O,...I}}let S=await v.text(),R;try{R=JSON.parse(S)}catch{}let P=R??S,D=P;for(let k of s.error.fns)k&&(D=await k(P,v,y,p));if(D=D||{},p.throwOnError)throw D;return p.responseStyle==="data"?void 0:{error:D,...I}},"request"),c=u(d=>p=>a({...p,method:d}),"makeMethodFn"),l=u(d=>async p=>{let{opts:f,url:h}=await o(p);return Au({...f,body:f.body,headers:f.headers,method:d,onRequest:u(async(y,g)=>{let v=new Request(y,g);for(let I of s.request.fns)I&&(v=await I(v,f));return v},"onRequest"),serializedBody:ts(f),url:h})},"makeSseFn");return{buildUrl:Oo,connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),getConfig:n,head:c("HEAD"),interceptors:s,options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),request:a,setConfig:i,sse:{connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),head:l("HEAD"),options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),trace:l("TRACE")},trace:c("TRACE")}},"createClient"),w=jo(ns({baseUrl:"https://swish.app/api/2026-07"})),$u=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),Hu=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),Qu=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),Gu=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),zu=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),Ku=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),Wu=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),Xu=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),Ju=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),Yu=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),Zu=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),ed=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),td=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),nd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),id=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),sd=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),rd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),od=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),ad=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),cd=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),ld=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),ud=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),dd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),pd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),hd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),fd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),md=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),yd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),vd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),gd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),wd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),bd=u(e=>(e?.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),Id=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),Sd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),xd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),Cd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),Ed=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),Rd=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),kd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),Ad=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),Pd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),Td=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items/{itemId}",...e}),"smartListsControllerRemoveItem"),Dd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/themes",...e}),"themesControllerFindAll"),Ld=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/themes/live",...e}),"themesControllerFindLive"),Od=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/themes/{themeId}",...e}),"themesControllerFindById"),_d=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/products",...e}),"productsControllerFindAll"),Md=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/products/{productId}",...e}),"productsControllerFindById"),qd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/tokens",...e}),"adminTokensControllerFindAll"),Fd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/tokens",...e,headers:{"Content-Type":"application/json",...e.headers}}),"adminTokensControllerCreate"),Bd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/tokens/{id}",...e}),"adminTokensControllerRevoke"),Nd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations",...e}),"integrationsControllerFindAll"),jd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations/{integrationId}",...e}),"integrationsControllerFindById"),Ud=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations/{integrationId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"integrationsControllerUpdate"),Vd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations/{integrationId}/connection",...e}),"integrationsControllerDisconnect"),$d=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations/{integrationId}/connection",...e}),"integrationsControllerGetConnection"),Hd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/integrations/{integrationId}/connection",...e,headers:{"Content-Type":"application/json",...e.headers}}),"integrationsControllerConnect"),Qd=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers",...e}),"customersControllerFindAll"),Gd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}",...e}),"customersControllerFindById"),zd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerItemsControllerDeleteMany"),Kd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items",...e}),"customerItemsControllerFindAll"),Wd=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerItemsControllerCreate"),Xd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items/count",...e}),"customerItemsControllerCount"),Jd=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items/{itemId}",...e}),"customerItemsControllerDeleteById"),Yd=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items/{itemId}",...e}),"customerItemsControllerFindById"),Zd=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerItemsControllerUpdate"),ep=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerItemsControllerSetLists"),tp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists",...e}),"customerListsControllerFindAll"),np=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerListsControllerCreate"),ip=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}",...e}),"customerListsControllerDeleteById"),sp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}",...e}),"customerListsControllerFindById"),rp=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerListsControllerUpdate"),op=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}/items",...e}),"customerListsControllerFindItems"),ap=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerListsControllerAddItems"),cp=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"customerListsControllerSetItemsOrder"),lp=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/lists/{listId}/items/{itemId}",...e}),"customerListsControllerRemoveItem"),up=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/smart-lists",...e}),"customerSmartListsControllerFindAll"),dp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/smart-lists/{smartListId}",...e}),"customerSmartListsControllerFindById"),pp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/customers/{customerId}/smart-lists/{smartListId}/items",...e}),"customerSmartListsControllerFindItems"),hp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/reports",...e}),"reportsControllerGetIndex"),fp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/reports/most-saved-products",...e}),"reportsControllerGetMostSavedProducts"),mp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/reports/most-saved-variants",...e}),"reportsControllerGetMostSavedVariants"),yp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/analytics/summary",...e}),"adminAnalyticsControllerGetSummary"),vp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/analytics/metrics",...e}),"adminAnalyticsControllerGetMetrics"),gp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/analytics/dimensions",...e}),"adminAnalyticsControllerGetDimensions"),wp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/events",...e}),"adminEventsControllerFindEvents"),bp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups",...e}),"setupControllerList"),Ip=u(e=>(e.client??w).post({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups",...e,headers:{"Content-Type":"application/json",...e.headers}}),"setupControllerCreate"),Sp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups/state",...e}),"setupControllerGetState"),xp=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups/state",...e,headers:{"Content-Type":"application/json",...e.headers}}),"setupControllerPatchState"),Cp=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups/{id}",...e}),"setupControllerDelete"),Ep=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups/{id}",...e}),"setupControllerGet"),Rp=u(e=>(e.client??w).patch({security:[{scheme:"bearer",type:"http"}],url:"/admin/setups/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"setupControllerUpdate"),kp=u(e=>(e?.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/onboarding",...e}),"onboardingChecklistsControllerList"),Ap=u(e=>(e.client??w).delete({security:[{scheme:"bearer",type:"http"}],url:"/admin/onboarding/{checklistId}",...e}),"onboardingChecklistsControllerDelete"),Pp=u(e=>(e.client??w).get({security:[{scheme:"bearer",type:"http"}],url:"/admin/onboarding/{checklistId}",...e}),"onboardingChecklistsControllerGet"),Tp=u(e=>(e.client??w).put({security:[{scheme:"bearer",type:"http"}],url:"/admin/onboarding/{checklistId}/{stepId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"onboardingChecklistsControllerUpsertStep"),Dp=u(e=>(e?.client??w).delete({url:"/admin/mcp",...e}),"mcpControllerDelete"),Lp=u(e=>(e?.client??w).get({url:"/admin/mcp",...e}),"mcpControllerGet"),Op=u(e=>(e?.client??w).post({url:"/admin/mcp",...e}),"mcpControllerPost"),_p=u(e=>(e.client??w).post({url:"/flow/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"flowControllerCreateList"),Mp=u(e=>(e.client??w).post({url:"/flow/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"flowControllerAddItem"),qp=u(e=>(e.client??w).post({url:"/flow/items/remove",...e,headers:{"Content-Type":"application/json",...e.headers}}),"flowControllerRemoveItem"),Fp=u(e=>(e.client??w).post({url:"/flow/lists/delete",...e,headers:{"Content-Type":"application/json",...e.headers}}),"flowControllerDeleteList"),Et="2026-07",Uo=u(e=>new Bp(e),"createApiClient"),Vo=class{static{r(this,"Ur")}constructor(t){this.version=Et,this.items={list:u(n=>this.handlePaginatedRequest(Yu({query:n,client:this.client})),"list"),create:u(n=>this.handleRequest(Zu({body:n,client:this.client})),"create"),delete:u(n=>this.handleRequest(Ju({body:{itemIds:n},client:this.client})),"delete"),findById:u(n=>this.handleRequest(nd({path:{itemId:n},client:this.client})),"findById"),updateById:u((n,i)=>this.handleRequest(id({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:u(n=>this.handleRequest(td({path:{itemId:n},client:this.client})),"deleteById"),setListsById:u((n,i)=>this.handleRequest(sd({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:u(()=>this.handleRequest(ed({client:this.client})),"count")},this.lists={list:u(n=>this.handlePaginatedRequest($u({query:n,client:this.client})),"list"),create:u(n=>this.handleRequest(Hu({body:n,client:this.client})),"create"),findById:u(n=>this.handleRequest(Gu({path:{listId:n},client:this.client})),"findById"),updateById:u((n,i)=>this.handleRequest(zu({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:u(n=>this.handleRequest(Qu({path:{listId:n},client:this.client})),"deleteById"),orderItems:u((n,i)=>this.handleRequest(Ku({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:u((n,i)=>this.handleRequest(Wu({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:u((n,i)=>this.handleRequest(Xu({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:u((n={})=>this.handleRequest(od({body:n,client:this.client})),"createToken"),identify:u(n=>this.handleRequest(rd({body:n,client:this.client})),"identify"),getProfile:u(()=>this.handleRequest(ad({client:this.client})),"getProfile"),updateProfile:u(n=>this.handleRequest(cd({body:n,client:this.client})),"updateProfile")},this.orders={list:u(n=>this.handlePaginatedRequest(ud({query:n,client:this.client})),"list"),findById:u(n=>this.handleRequest(dd({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:u(n=>this.handlePaginatedRequest(pd({query:n,client:this.client})),"list"),save:u(n=>this.handleRequest(hd({body:{listId:n},client:this.client})),"save"),findById:u(n=>this.handleRequest(md({path:{sharedListId:n},client:this.client})),"findById"),deleteById:u(n=>this.handleRequest(fd({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:u((n,i)=>this.handlePaginatedRequest(yd({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.tracking={track:u(n=>this.handleRequest(ld({body:n,client:this.client})),"track")},this.notifications={list:u(n=>this.handlePaginatedRequest(vd({query:n,client:this.client})),"list"),getUnreadCount:u(()=>this.handleRequest(gd({client:this.client})),"getUnreadCount"),markAsRead:u(n=>this.handleRequest(wd({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:u(()=>this.handleRequest(bd({client:this.client})),"markAllAsRead"),deleteById:u(n=>this.handleRequest(Id({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:u(n=>this.handlePaginatedRequest(Sd({query:n,client:this.client})),"list"),create:u(n=>this.handleRequest(xd({body:n,client:this.client})),"create"),findById:u(n=>this.handleRequest(Ed({path:{id:n},client:this.client})),"findById"),updateById:u((n,i)=>this.handleRequest(Rd({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:u(n=>this.handleRequest(Cd({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:u(()=>this.handleRequest(kd({client:this.client})),"list"),findById:u(n=>this.handleRequest(Ad({path:{smartListId:n},client:this.client})),"findById"),findItems:u((n,i)=>this.handlePaginatedRequest(Pd({path:{smartListId:n},query:i,client:this.client})),"findItems"),removeItem:u((n,i)=>this.handleRequest(Td({path:{smartListId:n,itemId:i},client:this.client})),"removeItem")},this.themes={list:u(n=>this.handlePaginatedRequest(Dd({query:n,client:this.client})),"list"),findLive:u(()=>this.handleRequest(Ld({client:this.client})),"findLive"),findById:u(n=>this.handleRequest(Od({path:{themeId:n},client:this.client})),"findById")},this.products={list:u(n=>this.handlePaginatedRequest(_d({query:n,client:this.client})),"list"),findById:u((n,i)=>this.handleRequest(Md({path:{productId:n},query:i,client:this.client})),"findById")},this.adminTokens={list:u(()=>this.handleRequest(qd({client:this.client})),"list"),create:u(n=>this.handleRequest(Fd({body:n,client:this.client})),"create"),revokeById:u(n=>this.handleRequest(Bd({path:{id:n},client:this.client})),"revokeById")},this.integrations={list:u(()=>this.handleRequest(Nd({client:this.client})),"list"),findById:u(n=>this.handleRequest(jd({path:{integrationId:n},client:this.client})),"findById"),updateById:u((n,i)=>this.handleRequest(Ud({path:{integrationId:n},body:i,client:this.client})),"updateById"),getConnection:u(n=>this.handleRequest($d({path:{integrationId:n},client:this.client})),"getConnection"),connect:u((n,i)=>this.handleConnectRequest(Hd({path:{integrationId:n},body:i,client:this.client})),"connect"),disconnect:u(n=>this.handleRequest(Vd({path:{integrationId:n},client:this.client})),"disconnect")},this.customers={list:u(n=>this.handlePaginatedRequest(Qd({query:n,client:this.client})),"list"),findById:u(n=>this.handleRequest(Gd({path:{customerId:n},client:this.client})),"findById")},this.customerItems={list:u((n,i)=>this.handlePaginatedRequest(Kd({path:{customerId:n},query:i,client:this.client})),"list"),create:u((n,i)=>this.handleRequest(Wd({path:{customerId:n},body:i,client:this.client})),"create"),delete:u((n,i)=>this.handleRequest(zd({path:{customerId:n},body:{itemIds:i},client:this.client})),"delete"),count:u(n=>this.handleRequest(Xd({path:{customerId:n},client:this.client})),"count"),findById:u((n,i)=>this.handleRequest(Yd({path:{customerId:n,itemId:i},client:this.client})),"findById"),updateById:u((n,i,s)=>this.handleRequest(Zd({path:{customerId:n,itemId:i},body:s,client:this.client})),"updateById"),deleteById:u((n,i)=>this.handleRequest(Jd({path:{customerId:n,itemId:i},client:this.client})),"deleteById"),setListsById:u((n,i,s)=>this.handleRequest(ep({path:{customerId:n,itemId:i},body:{listIds:s},client:this.client})),"setListsById")},this.customerLists={list:u((n,i)=>this.handlePaginatedRequest(tp({path:{customerId:n},query:i,client:this.client})),"list"),create:u((n,i)=>this.handleRequest(np({path:{customerId:n},body:i,client:this.client})),"create"),findById:u((n,i)=>this.handleRequest(sp({path:{customerId:n,listId:i},client:this.client})),"findById"),updateById:u((n,i,s)=>this.handleRequest(rp({path:{customerId:n,listId:i},body:s,client:this.client})),"updateById"),deleteById:u((n,i)=>this.handleRequest(ip({path:{customerId:n,listId:i},client:this.client})),"deleteById"),findItems:u((n,i,s)=>this.handlePaginatedRequest(op({path:{customerId:n,listId:i},query:s,client:this.client})),"findItems"),addItems:u((n,i,s)=>this.handleRequest(ap({path:{customerId:n,listId:i},body:{itemIds:s},client:this.client})),"addItems"),orderItems:u((n,i,s)=>this.handleRequest(cp({path:{customerId:n,listId:i},body:{itemIds:s},client:this.client})),"orderItems"),removeItem:u((n,i,s)=>this.handleRequest(lp({path:{customerId:n,listId:i,itemId:s},client:this.client})),"removeItem")},this.customerSmartLists={list:u(n=>this.handleRequest(up({path:{customerId:n},client:this.client})),"list"),findById:u((n,i)=>this.handleRequest(dp({path:{customerId:n,smartListId:i},client:this.client})),"findById"),findItems:u((n,i,s)=>this.handlePaginatedRequest(pp({path:{customerId:n,smartListId:i},query:s,client:this.client})),"findItems")},this.setups={list:u(()=>this.handleRequest(bp({client:this.client})),"list"),create:u(n=>this.handleRequest(Ip({body:n,client:this.client})),"create"),getState:u(()=>this.handleRequest(Sp({client:this.client})),"getState"),patchState:u(n=>this.handleRequest(xp({body:n,client:this.client})),"patchState"),findById:u(n=>this.handleRequest(Ep({path:{id:n},client:this.client})),"findById"),updateById:u((n,i)=>this.handleRequest(Rp({path:{id:n},body:i,client:this.client})),"updateById"),deleteById:u(n=>this.handleRequest(Cp({path:{id:n},client:this.client})),"deleteById")},this.reports={list:u(()=>this.handlePaginatedRequest(hp({client:this.client})),"list"),mostSavedProducts:u(n=>this.handlePaginatedRequest(fp({query:n,client:this.client})),"mostSavedProducts"),mostSavedVariants:u(n=>this.handlePaginatedRequest(mp({query:n,client:this.client})),"mostSavedVariants")},this.adminAnalytics={getSummary:u(n=>this.handleRequest(yp({query:n,client:this.client})),"getSummary"),getMetrics:u(n=>this.handleRequest(vp({query:n,client:this.client})),"getMetrics"),getDimensions:u(n=>this.handleRequest(gp({query:n,client:this.client})),"getDimensions")},this.adminEvents={list:u(n=>this.handlePaginatedRequest(wp({query:n,client:this.client})),"list")},this.onboarding={list:u(()=>this.handleRequest(kp({client:this.client})),"list"),get:u(n=>this.handleRequest(Pp({path:{checklistId:n},client:this.client})),"get"),delete:u(n=>this.handleRequest(Ap({path:{checklistId:n},client:this.client})),"delete"),upsertStep:u((n,i,s)=>this.handleRequest(Tp({path:{checklistId:n,stepId:i},body:s,client:this.client})),"upsertStep")},this.mcp={get:u(()=>this.handleRequest(Lp({client:this.client})),"get"),post:u(()=>this.handleRequest(Op({client:this.client})),"post"),delete:u(()=>this.handleRequest(Dp({client:this.client})),"delete")},this.flow={createList:u(n=>this.handleRequest(_p({body:n,client:this.client})),"createList"),addItem:u(n=>this.handleRequest(Mp({body:n,client:this.client})),"addItem"),removeItem:u(n=>this.handleRequest(qp({body:n,client:this.client})),"removeItem"),deleteList:u(n=>this.handleRequest(Fp({body:n,client:this.client})),"deleteList")},this.handleRequest=u(async n=>{let{data:i,error:s}=await n;return s!=null&&s.error?{error:s.error}:{data:i?.data}},"handleRequest"),this.handleConnectRequest=u(async n=>{let i=await n,{data:s,error:o}=i;return o!=null&&o.error?{error:o.error}:s&&"redirectUrl"in s?{data:s}:{data:s?.data??null}},"handleConnectRequest"),this.handlePaginatedRequest=u(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=jo(ns({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}};u(Vo,"SwishClient");var Bp=Vo;var Go=ia(Qo(),1);var zo=r(e=>new Go.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 zn=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":Et},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=pe(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${t}`)??void 0}setSessionId(t){let n=pe(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${n}`,t)}deleteSessionId(){let t=pe(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${t}`)}getSwishToken(){let t=pe(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${t}`)??void 0}setSwishToken(t){let n=pe(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${n}`,t)}deleteSwishToken(){let t=pe(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 Kn=class{static{r(this,"SwishApi")}constructor(t,n,i,s,o){this.config=t,this.storefrontContext=n;let a=pe(n.myshopifyDomain);this.cache=new Te(`swish-api-${a}`,"max-age=60, stale-while-revalidate=3600",s+Et),this.cache.cleanupExpiredEntries().catch(l=>{console.warn("Swish API cache initialization cleanup error:",l)}),this.auth=new zn(this,n,i,o);let c={authToken:this.auth.getSwishToken(),config:{...t,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)};this.apiClient=Uo(c),this.itemsLoader=zo(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"),c=s.includes("/profiles");return i==="GET"&&!a&&!c?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(),c=t.ok;await this.cache.clear(),o&&a&&c&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(t,n),t}setAuthToken(t){this.apiClient.setAuthToken(t)}getAuthToken(){return this.auth.getSwishToken()}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"),removeItem:r(async(t,n)=>this.apiClient.smartLists.removeItem(t,n),"removeItem")}}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 Wn=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","DELETE /smart-lists\\/([^/]+)\\/items\\/([^/]+)\\/?$":"item-delete","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[c,l]=a.split(" ");return c!==t?!1:new RegExp(l).test(s)})?.[1]}};var Xn=class{constructor(t,n){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,this.isPreview=n,this.previewCssStylesheet=n?new CSSStyleSheet:void 0,this.themeVariablesStylesheet=new CSSStyleSheet,this.icons=L(n?{}:t.options.ui.icons??{}),this.uiOptions=L(t.options.ui)}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"),t.getAttribute("ref")==="drawer"&&this.swishApp.events.publish("drawer-state-change",{open:!0}))})().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.getAttribute("ref")==="drawer"&&this.swishApp.events.publish("drawer-state-change",{open:!1}),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:c})=>{t.removeEventListener(a,c)})},"cleanup");Object.entries(n).forEach(([a,c])=>{let l=r(d=>{let p=c(d);o(),i(p)},"listener");s.push({event:a,listener:l}),t.addEventListener(a,l)})})}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}hideDrawer(){let t=this.queryComponent("drawer");!t||t.getAttribute("open")!=="true"||t.dispatchEvent(new CustomEvent("close"))}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}initListDetailPage(){this.swishApp.placements.create({id:"swish-list-detail-page",target:{selector:"#wishlist-page"},mount:{at:"target",mode:"replace"},element:{name:"list-detail-page"}}).mount()}async showToast(t,n){let i=Date.now(),s=n?.signal,o=await this.requireUiComponent("toast-manager",{singleInstance:!0,onHydrated:r(a=>{s?.aborted||(a.current?.show(t,i),s?.addEventListener("abort",()=>a.current?.hide(i),{once:!0}))},"onHydrated")});return new Promise(a=>{if(s?.aborted){a({code:"closed"});return}let c=r(f=>{o.removeEventListener(`close-${i}`,l),o.removeEventListener(`submit-${i}`,d),s?.removeEventListener("abort",p),a(f)},"finish"),l=r(()=>c({code:"closed"}),"onClose"),d=r(()=>c({code:"ok",data:void 0}),"onSubmit"),p=r(()=>c({code:"closed"}),"onAbort");o.addEventListener(`close-${i}`,l),o.addEventListener(`submit-${i}`,d),s?.addEventListener("abort",p,{once:!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]=await Promise.all([this.loadTemplate(t),this.loadCricalResources()]),s=document.createElement("template");s.innerHTML=i.replace(' shadowrootmode="open"',"");let o=s.content.firstElementChild;return o.addEventListener("connected",()=>{o.shadowRoot&&(o.shadowRoot.adoptedStyleSheets=[this.themeVariablesStylesheet],this.hydrateElement(t,o,n?.onHydrated))},{once:!0}),o}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:c}])=>{s.shadowRoot&&o&&(s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,...a,o],s.shadowRoot?.querySelector(":host > style")?.remove()),c(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@${he}/${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@${he}/${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@${he}/theme.css`,n=await fetch(t).then(s=>s.text());this.themeVariablesStylesheet.replaceSync(n);let i=Ko(this.swishApp.options.ui.design);Object.entries(i).forEach(([s,o])=>{this.themeVariablesStylesheet.cssRules[0].cssRules[0].style.setProperty(s,o)})})(),this._loadCricalResourcesPromise)}applyPreview({design:t,css:n,icons:i,...s}){if(!this.previewCssStylesheet)return;let o=n?.filter(l=>typeof l=="string").map(l=>l.toString()).join(`
273
+ `)??"",a=t?Ko(t):{},c=`@layer theme { :host {
274
274
  ${Object.entries(a).map(([l,d])=>`${l}: ${d};`).join(`
275
275
  `)}
276
- }} ${o??""}`;this.previewCssStylesheet.replaceSync(c),Xp(this.icons.peek(),i??{})||(this.icons.value=i??{}),Object.keys(s).length>0&&(this.uiOptions.value={...this.uiOptions.peek(),...s})}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let t=`${this.swishApp.options.ui.baseUrl}/ui@${he}/bundle.css`,n=r(a=>{let c=new CSSStyleSheet;return c.replaceSync(a),c},"createCssStylesheet"),i=this.isPreview?[]:this.swishApp.options.ui.css,[s,...o]=await Promise.all([fetch(t).then(a=>a.text()).then(n),...i.map(async a=>a instanceof URL?n(await fetch(a).then(c=>c.text())):n(a))]);return this.previewCssStylesheet&&o.push(this.previewCssStylesheet),{bundleCssStylesheet:s,customCssStylesheets:o}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:t,template:n,position:i,refElement:s,singleInstance:o}){if(o&&this.queryComponent(t))return this.queryComponent(t);let a=o?0:++this.elementId;s.insertAdjacentHTML(i,n.replace(' shadowrootmode="open"',"").replace(`ref="${t}"`,`ref="${t}" instance="${a}"`));let c=this.queryComponent(t,a);if(!c)throw new Error(`Element ${t} not found in DOM`);return o&&c.setAttribute("swish-singleton",""),c.shadowRoot&&(c.shadowRoot.adoptedStyleSheets=[this.themeVariablesStylesheet]),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(`
276
+ }} ${o??""}`;this.previewCssStylesheet.replaceSync(c),Jp(this.icons.peek(),i??{})||(this.icons.value=i??{}),Object.keys(s).length>0&&(this.uiOptions.value={...this.uiOptions.peek(),...s})}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let t=`${this.swishApp.options.ui.baseUrl}/ui@${he}/bundle.css`,n=r(a=>{let c=new CSSStyleSheet;return c.replaceSync(a),c},"createCssStylesheet"),i=this.isPreview?[]:this.swishApp.options.ui.css,[s,...o]=await Promise.all([fetch(t).then(a=>a.text()).then(n),...i.map(async a=>a instanceof URL?n(await fetch(a).then(c=>c.text())):n(a))]);return this.previewCssStylesheet&&o.push(this.previewCssStylesheet),{bundleCssStylesheet:s,customCssStylesheets:o}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:t,template:n,position:i,refElement:s,singleInstance:o}){if(o&&this.queryComponent(t))return this.queryComponent(t);let a=o?0:++this.elementId;s.insertAdjacentHTML(i,n.replace(' shadowrootmode="open"',"").replace(`ref="${t}"`,`ref="${t}" instance="${a}"`));let c=this.queryComponent(t,a);if(!c)throw new Error(`Element ${t} not found in DOM`);return o&&c.setAttribute("swish-singleton",""),c.shadowRoot&&(c.shadowRoot.adoptedStyleSheets=[this.themeVariablesStylesheet]),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(`
277
277
  html[swish-locked] body {
278
278
  overflow: hidden;
279
279
  position: fixed;
@@ -281,4 +281,4 @@ Values:
281
281
  left: 0px;
282
282
  right: 0px;
283
283
  }
284
- `),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 zo(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-${zp(s)}`;t[a]=Kp(s,o)}}})},"walk");return n(e),t}r(zo,"flattenDesignTokens");function zp(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(zp,"toKebabCase");function Kp(e,t){return typeof t=="number"&&!Wp(e)?`${t}px`:String(t)}r(Kp,"formatDesignValue");function Wp(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("letterspacing")||t.includes("lineheight")}r(Wp,"isNonPxValue");function Xp(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let i of n)if(e[i]!==t[i])return!1;return!0}r(Xp,"shallowEqualStringMap");var Jp=typeof HTMLElement<"u"?HTMLElement:class{},Jn=class extends Jp{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 he="0.138.0",$x=`https://swish.app/cdn/sdk@${he}/swish.js`,Hx=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=fs(),n=_s(e),i=new rs(n,t);return globalThis.window.swish=i,ms(i,{baseUrl:e.customiser?.baseUrl,shop:n.context.myshopifyDomain}),document.dispatchEvent(new Event("swish-ready")),i.api.initAuth().then(()=>{typeof globalThis.window.Shopify?.analytics?.publish=="function"&&globalThis.window.Shopify.analytics.publish("swish-ready",{market:n.context.localization.market,country:n.context.localization.country,language:n.context.localization.language,rootUrl:n.context.routes.rootUrl,preRelease:he==="unstable"})}),i},"createSwish"),rs=class{constructor(t,n){this.ui={createElement:r((t,n)=>this.swishUi.createElement(t,n),"createElement"),showDrawer:r(t=>this.swishUi.showDrawer(t),"showDrawer"),hideDrawer:r(()=>this.swishUi.hideDrawer(),"hideDrawer"),applyPreview:r(t=>this.swishUi.applyPreview(t),"applyPreview")};this.utils={copyToClipboard:ft,createShareUrl:r(t=>ht(this,t),"createShareUrl")};this.state={itemContext:Hr(this),itemContextFromIds:$r,itemState:zr(this),itemCount:Kr(this),swishQuery:Wr(this),effect:X,signal:L,computed:re};this.swishOptions=t,this.isPreview=n,this.events=new qt,this._i18n=us(`${t.ui.baseUrl}/i18n@${he}`,t.translations),this.swishApiPublisher=new Wn(this.events);let i=he;this.swishApi=new Kn({responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.context,this.events,i,this.swishOptions.auth.tokenUrl),this.ajaxApiPublisher=new At(this.events),this.ajaxApi=new kt({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 Xn(this,n),this.query=Vr({events:this.events,cacheBuster:he,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()}),n||(this.checkoutBridge=new Pt({api:this.swishApi,ajax:this.ajaxApi,events:this.events,context:this.swishOptions.context,preRelease:he==="unstable"}),this.checkoutBridge.listen()),customElements.get("swish-ui")||customElements.define("swish-ui",Jn),this.intents=new In(this,this.swishUi),this.placements=new Pn(this),si(this),this.swishUi.initListDetailPage(),n||this.placements.mountConfigured(this.swishOptions.placements)}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{createLocationObserver:ze}}get iconsSignal(){return this.swishUi.icons}get uiOptionsSignal(){return this.swishUi.uiOptions}};export{he as VERSION,ht as buildShareListUrl,ft as copyToClipboard,Hx as createSwish,Bn as getSwishQueryStorageKey,$x as swishSdkUrl};
284
+ `),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 Ko(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-${Kp(s)}`;t[a]=Wp(s,o)}}})},"walk");return n(e),t}r(Ko,"flattenDesignTokens");function Kp(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Kp,"toKebabCase");function Wp(e,t){return typeof t=="number"&&!Xp(e)?`${t}px`:String(t)}r(Wp,"formatDesignValue");function Xp(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("letterspacing")||t.includes("lineheight")}r(Xp,"isNonPxValue");function Jp(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let i of n)if(e[i]!==t[i])return!1;return!0}r(Jp,"shallowEqualStringMap");var Yp=typeof HTMLElement<"u"?HTMLElement:class{},Jn=class extends Yp{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 he="0.139.0",zx=`https://swish.app/cdn/sdk@${he}/swish.js`,Kx=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=ms(),n=Ms(e),i=new os(n,t);return globalThis.window.swish=i,ys(i,{baseUrl:e.customiser?.baseUrl,shop:n.context.myshopifyDomain}),document.dispatchEvent(new Event("swish-ready")),i.api.initAuth().then(()=>{typeof globalThis.window.Shopify?.analytics?.publish=="function"&&globalThis.window.Shopify.analytics.publish("swish-ready",{market:n.context.localization.market,country:n.context.localization.country,language:n.context.localization.language,rootUrl:n.context.routes.rootUrl,preRelease:he==="unstable"})}),i},"createSwish"),os=class{constructor(t,n){this.ui={createElement:r((t,n)=>this.swishUi.createElement(t,n),"createElement"),showDrawer:r(t=>this.swishUi.showDrawer(t),"showDrawer"),hideDrawer:r(()=>this.swishUi.hideDrawer(),"hideDrawer"),applyPreview:r(t=>this.swishUi.applyPreview(t),"applyPreview")};this.utils={copyToClipboard:ft,createShareUrl:r(t=>ht(this,t),"createShareUrl")};this.state={itemContext:Qr(this),itemContextFromIds:Hr,itemState:Kr(this),itemCount:Wr(this),swishQuery:Xr(this),effect:X,signal:L,computed:re};this.swishOptions=t,this.isPreview=n,this.events=new qt,this._i18n=ds(`${t.ui.baseUrl}/i18n@${he}`,t.translations),this.swishApiPublisher=new Wn(this.events);let i=he;this.swishApi=new Kn({responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.context,this.events,i,this.swishOptions.auth.tokenUrl),this.ajaxApiPublisher=new At(this.events),this.ajaxApi=new kt({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 Xn(this,n),this.query=$r({events:this.events,cacheBuster:he,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()}),n||(this.checkoutBridge=new Pt({api:this.swishApi,ajax:this.ajaxApi,events:this.events,context:this.swishOptions.context,preRelease:he==="unstable"}),this.checkoutBridge.listen()),customElements.get("swish-ui")||customElements.define("swish-ui",Jn),this.intents=new In(this,this.swishUi),this.placements=new Pn(this),ri(this),this.swishUi.initListDetailPage(),n||this.placements.mountConfigured(this.swishOptions.placements)}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{createLocationObserver:ze}}get iconsSignal(){return this.swishUi.icons}get uiOptionsSignal(){return this.swishUi.uiOptions}};export{he as VERSION,ht as buildShareListUrl,ft as copyToClipboard,Kx as createSwish,Bn as getSwishQueryStorageKey,zx as swishSdkUrl};