@swishapp/sdk 0.73.0 → 0.80.1

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.
@@ -1,7 +1,6 @@
1
1
  import { StorefrontApiOptions, SwishClientConfig } from "../swish";
2
- import { StorefrontContext, SwishBadgeOptions, SwishMetafieldOptions, SwishOptions, SwishProxyOptions, SwishUiOptions } from "./types";
2
+ import { StorefrontContext, SwishBadgeOptions, SwishMetafieldOptions, SwishOptions, SwishUiOptions } from "./types";
3
3
  export type SwishOptionsInput = {
4
- proxy?: SwishProxyOptions;
5
4
  storefrontApi: StorefrontApiOptions;
6
5
  storefrontContext: StorefrontContext;
7
6
  badges?: SwishBadgeOptions;
@@ -3,7 +3,6 @@ import { CountryCode, LanguageCode } from "../storefront-api/types/storefront.ty
3
3
  import { GetProductCardDataQuery, GetProductCardDataWithVariantQuery, StorefrontApiOptions, SwishClientConfig } from "../swish";
4
4
  import { Badge } from "../utils/shopify-badge-utils";
5
5
  export interface SwishOptions {
6
- proxy: SwishProxyOptions;
7
6
  storefrontApi: StorefrontApiOptions;
8
7
  storefrontContext: StorefrontContext;
9
8
  badges: SwishBadgeOptions;
@@ -24,9 +23,6 @@ export interface SwishBadgeOptions {
24
23
  defaultBadges: string[];
25
24
  }) => (string | Badge)[];
26
25
  }
27
- export interface SwishProxyOptions {
28
- baseUrl: string;
29
- }
30
26
  export interface SwishUiOptions {
31
27
  baseUrl: string;
32
28
  components: SwishComponentOptions;
@@ -36,6 +32,7 @@ export interface SwishUiOptions {
36
32
  version: string;
37
33
  }
38
34
  export interface StorefrontContext {
35
+ myshopifyDomain: string;
39
36
  customer: {
40
37
  id: string | null;
41
38
  email: string | null;
@@ -0,0 +1,27 @@
1
+ import { StorefrontContext } from "../swish";
2
+ import { SwishApi } from "./swish-api-client";
3
+ export declare class SwishApiAuth {
4
+ private readonly context;
5
+ private readonly api;
6
+ private tokenHasProfile;
7
+ constructor(api: SwishApi, context: StorefrontContext);
8
+ hasProfile(): boolean;
9
+ hasToken(): boolean;
10
+ init(): Promise<void>;
11
+ initCustomer(customerId: string): Promise<void>;
12
+ initSession(): Promise<void>;
13
+ initToken(token: string): void;
14
+ acquireToken(session?: string, customer?: string): Promise<void>;
15
+ resetSession(): Promise<void>;
16
+ getTokenData(token: string): any;
17
+ willTokenExpire(token: string, duration?: number): boolean;
18
+ hasCustomerToken(): any;
19
+ getTokenBySub(sub: string): string | null;
20
+ getSessionId(): string | undefined;
21
+ setSessionId(sessionId: string): void;
22
+ deleteSessionId(): void;
23
+ getSwishToken(): string | undefined;
24
+ setSwishToken(token: string): void;
25
+ deleteSwishToken(): void;
26
+ migrateLegacySession(): void;
27
+ }
@@ -1,20 +1,20 @@
1
1
  import { ApiResponse, Item, ItemControllerFindData, ItemDetail, ListControllerFindData, ListDetail, OrderDetailDto, OrderDto, OrdersControllerFindData, PaginatedApiResponse, SwishClientConfig } from "@swishapp/api-client";
2
2
  import { StorefrontContext } from "../options/types";
3
3
  export interface SwishApiConfig extends SwishClientConfig {
4
- proxyMode?: boolean;
5
- customerId?: string;
4
+ requestInterceptor?: (request: Request) => Promise<Request> | Request;
6
5
  responseInterceptor?: (response: Response, request: Request) => Promise<void> | void;
7
6
  }
8
7
  export declare class SwishApi {
9
8
  private readonly cache;
10
9
  private readonly apiClient;
11
10
  private readonly config;
12
- private readonly context;
13
11
  private readonly itemsLoader;
12
+ private readonly auth;
14
13
  constructor(config: SwishApiConfig, context: StorefrontContext, cacheKeyPrefix: string);
15
- private _bootstrapAuthPromise?;
16
- bootstrapAuth(): Promise<void>;
17
- private processProfileHeader;
14
+ private _initAuthPromise?;
15
+ initAuth(): Promise<void>;
16
+ setAuthToken(token: string): void;
17
+ private withFallback;
18
18
  get items(): {
19
19
  list: (query?: ItemControllerFindData["query"], options?: {
20
20
  batch?: boolean;
@@ -39,14 +39,12 @@ export declare class SwishApi {
39
39
  };
40
40
  get orders(): {
41
41
  list: (query?: OrdersControllerFindData["query"]) => Promise<PaginatedApiResponse<OrderDto>>;
42
- findById: (orderId: number) => Promise<ApiResponse<OrderDetailDto>>;
42
+ findById: (orderId: string | number) => Promise<ApiResponse<OrderDetailDto>>;
43
43
  };
44
44
  get profiles(): {
45
- customerAccountsVersion: () => Promise<ApiResponse<import("@swishapp/api-client").AccountsVersionResult>>;
46
- createToken: (body?: import("@swishapp/api-client").CreateProfileTokenInput, options?: {
47
- useProxy?: boolean;
48
- }) => Promise<ApiResponse<import("@swishapp/api-client").CreateProfileTokenResult>>;
49
- identify: (body: import("@swishapp/api-client").IdentifyProfileInput) => Promise<ApiResponse<import("@swishapp/api-client").IdentifyProfileResult>>;
45
+ createToken: (body?: import("@swishapp/api-client").CreateProfileTokenInput) => Promise<ApiResponse<import("@swishapp/api-client").CreateProfileTokenResult>>;
46
+ identify: (body: import("@swishapp/api-client").IdentifyProfileInput) => Promise<ApiResponse<unknown>>;
47
+ getProfile: () => Promise<ApiResponse<import("@swishapp/api-client").Profile>>;
50
48
  };
51
49
  clearCache(): Promise<void>;
52
50
  }
package/dist/swish.d.ts CHANGED
@@ -2,16 +2,16 @@ import { AjaxApiClient } from "./ajax-api/ajax-api-client";
2
2
  import { createElementLocator, createLocationObserver } from "./dom/dom-utils";
3
3
  import { EventBus } from "./events/event-bus";
4
4
  import { Intents } from "./intents/intents";
5
+ import { SwishOptionsInput } from "./options/swish-options";
6
+ import { SwishOptions } from "./options/types";
5
7
  import { computed, effect, signal } from "./state";
6
8
  import { StorefrontApiClient } from "./storefront-api/storefront-api-client";
7
9
  import { SwishApi } from "./swish-api/swish-api-client";
8
- import { ShopifyBadgesUtils } from "./utils/shopify-badge-utils";
9
- import { SwishOptionsInput } from "./options/swish-options";
10
- import { SwishOptions } from "./options/types";
11
10
  import { SwishUi } from "./swish-ui/swish-ui";
11
+ import { ShopifyBadgesUtils } from "./utils/shopify-badge-utils";
12
12
  export declare const VERSION: string;
13
13
  export declare const createSwish: (optionsInput: SwishOptionsInput) => Promise<SwishApp>;
14
- export declare class SwishApp {
14
+ declare class SwishApp {
15
15
  private readonly swishApi;
16
16
  private readonly swishApiPublisher;
17
17
  private readonly storefrontApi;
@@ -91,13 +91,14 @@ export declare class SwishApp {
91
91
  computed: typeof computed;
92
92
  };
93
93
  }
94
- export type * from "./types";
95
94
  export type * from "@swishapp/api-client";
96
95
  export type * from "./ajax-api/ajax-api-client";
97
96
  export type { EventName } from "./events/event-bus";
98
- export type * from "./storefront-api/storefront-api-client";
99
97
  export type * from "./intents/types";
100
- export type { Ref, SwishUiElement } from "./swish-ui/swish-ui-element";
101
- export type { Toast, ToastManager, UnsaveAlertSubmitData, ListSelectSubmitData, VariantSelectSubmitData, UnsaveAlertOptions, ListSelectOptions, VariantSelectOptions, QuickBuySubmitData, QuickBuyOptions, } from "./swish-ui/types";
102
98
  export type * from "./options/types";
99
+ export type * from "./storefront-api/storefront-api-client";
100
+ export type { Ref, SwishUiElement } from "./swish-ui/swish-ui-element";
101
+ export type { ListSelectOptions, ListSelectSubmitData, QuickBuyOptions, QuickBuySubmitData, Toast, ToastManager, UnsaveAlertOptions, UnsaveAlertSubmitData, VariantSelectOptions, VariantSelectSubmitData, } from "./swish-ui/types";
102
+ export type * from "./types";
103
103
  export type { ShopBridge } from "./utils/shop-bridge";
104
+ export type { SwishApp };
package/dist/swish.js CHANGED
@@ -1,11 +1,11 @@
1
- var pn=Object.create;var Qe=Object.defineProperty;var fn=Object.getOwnPropertyDescriptor;var dn=Object.getOwnPropertyNames;var hn=Object.getPrototypeOf,yn=Object.prototype.hasOwnProperty;var s=(r,e)=>Qe(r,"name",{value:e,configurable:!0});var mn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var vn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of dn(e))!yn.call(r,i)&&i!==t&&Qe(r,i,{get:()=>e[i],enumerable:!(n=fn(e,i))||n.enumerable});return r};var gn=(r,e,t)=>(t=r!=null?pn(hn(r)):{},vn(e||!r||!r.__esModule?Qe(t,"default",{value:r,enumerable:!0}):t,r));var sn=mn((Wu,nn)=>{"use strict";var Ni=(function(){function r(t,n){if(typeof t!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+t+"."));this._batchLoadFn=t,this._maxBatchSize=Fi(n),this._batchScheduleFn=Hi(n),this._cacheKeyFn=Qi(n),this._cacheMap=zi(n),this._batch=null,this.name=Wi(n)}s(r,"DataLoader");var e=r.prototype;return e.load=s(function(n){if(n==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(n)+"."));var i=Mi(this),o=this._cacheMap,a;if(o){a=this._cacheKeyFn(n);var u=o.get(a);if(u){var l=i.cacheHits||(i.cacheHits=[]);return new Promise(function(p){l.push(function(){p(u)})})}}i.keys.push(n);var c=new Promise(function(p,d){i.callbacks.push({resolve:p,reject:d})});return o&&o.set(a,c),c},"load"),e.loadMany=s(function(n){if(!rn(n))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+n+"."));for(var i=[],o=0;o<n.length;o++)i.push(this.load(n[o]).catch(function(a){return a}));return Promise.all(i)},"loadMany"),e.clear=s(function(n){var i=this._cacheMap;if(i){var o=this._cacheKeyFn(n);i.delete(o)}return this},"clear"),e.clearAll=s(function(){var n=this._cacheMap;return n&&n.clear(),this},"clearAll"),e.prime=s(function(n,i){var o=this._cacheMap;if(o){var a=this._cacheKeyFn(n);if(o.get(a)===void 0){var u;i instanceof Error?(u=Promise.reject(i),u.catch(function(){})):u=Promise.resolve(i),o.set(a,u)}}return this},"prime"),r})(),Gi=typeof process=="object"&&typeof process.nextTick=="function"?function(r){Rt||(Rt=Promise.resolve()),Rt.then(function(){process.nextTick(r)})}:typeof setImmediate=="function"?function(r){setImmediate(r)}:function(r){setTimeout(r)},Rt;function Mi(r){var e=r._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<r._maxBatchSize)return e;var t={hasDispatched:!1,keys:[],callbacks:[]};return r._batch=t,r._batchScheduleFn(function(){ji(r,t)}),t}s(Mi,"getCurrentBatch");function ji(r,e){if(e.hasDispatched=!0,e.keys.length===0){Pt(e);return}var t;try{t=r._batchLoadFn(e.keys)}catch(n){return Dt(r,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(n)+".")))}if(!t||typeof t.then!="function")return Dt(r,e,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(t)+".")));t.then(function(n){if(!rn(n))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(n)+"."));if(n.length!==e.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 ar=Object.create;var Qe=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var cr=Object.getPrototypeOf,pr=Object.prototype.hasOwnProperty;var s=(n,e)=>Qe(n,"name",{value:e,configurable:!0});var dr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var fr=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of lr(e))!pr.call(n,i)&&i!==t&&Qe(n,i,{get:()=>e[i],enumerable:!(r=ur(e,i))||r.enumerable});return n};var hr=(n,e,t)=>(t=n!=null?ar(cr(n)):{},fr(e||!n||!n.__esModule?Qe(t,"default",{value:n,enumerable:!0}):t,n));var nr=dr((Ju,tr)=>{"use strict";var Fi=(function(){function n(t,r){if(typeof t!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+t+"."));this._batchLoadFn=t,this._maxBatchSize=Wi(r),this._batchScheduleFn=Xi(r),this._cacheKeyFn=Ki(r),this._cacheMap=Yi(r),this._batch=null,this.name=Ji(r)}s(n,"DataLoader");var e=n.prototype;return e.load=s(function(r){if(r==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(r)+"."));var i=Qi(this),o=this._cacheMap,u;if(o){u=this._cacheKeyFn(r);var a=o.get(u);if(a){var l=i.cacheHits||(i.cacheHits=[]);return new Promise(function(p){l.push(function(){p(a)})})}}i.keys.push(r);var c=new Promise(function(p,f){i.callbacks.push({resolve:p,reject:f})});return o&&o.set(u,c),c},"load"),e.loadMany=s(function(r){if(!er(r))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+r+"."));for(var i=[],o=0;o<r.length;o++)i.push(this.load(r[o]).catch(function(u){return u}));return Promise.all(i)},"loadMany"),e.clear=s(function(r){var i=this._cacheMap;if(i){var o=this._cacheKeyFn(r);i.delete(o)}return this},"clear"),e.clearAll=s(function(){var r=this._cacheMap;return r&&r.clear(),this},"clearAll"),e.prime=s(function(r,i){var o=this._cacheMap;if(o){var u=this._cacheKeyFn(r);if(o.get(u)===void 0){var a;i instanceof Error?(a=Promise.reject(i),a.catch(function(){})):a=Promise.resolve(i),o.set(u,a)}}return this},"prime"),n})(),Hi=typeof process=="object"&&typeof process.nextTick=="function"?function(n){Rt||(Rt=Promise.resolve()),Rt.then(function(){process.nextTick(n)})}:typeof setImmediate=="function"?function(n){setImmediate(n)}:function(n){setTimeout(n)},Rt;function Qi(n){var e=n._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<n._maxBatchSize)return e;var t={hasDispatched:!1,keys:[],callbacks:[]};return n._batch=t,n._batchScheduleFn(function(){zi(n,t)}),t}s(Qi,"getCurrentBatch");function zi(n,e){if(e.hasDispatched=!0,e.keys.length===0){Tt(e);return}var t;try{t=n._batchLoadFn(e.keys)}catch(r){return Dt(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(r)+".")))}if(!t||typeof t.then!="function")return Dt(n,e,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(t)+".")));t.then(function(r){if(!er(r))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(r)+"."));if(r.length!==e.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(e.keys))+(`
5
5
 
6
6
  Values:
7
- `+String(n)));Pt(e);for(var i=0;i<e.callbacks.length;i++){var o=n[i];o instanceof Error?e.callbacks[i].reject(o):e.callbacks[i].resolve(o)}}).catch(function(n){Dt(r,e,n)})}s(ji,"dispatchBatch");function Dt(r,e,t){Pt(e);for(var n=0;n<e.keys.length;n++)r.clear(e.keys[n]),e.callbacks[n].reject(t)}s(Dt,"failedDispatch");function Pt(r){if(r.cacheHits)for(var e=0;e<r.cacheHits.length;e++)r.cacheHits[e]()}s(Pt,"resolveCacheHits");function Fi(r){var e=!r||r.batch!==!1;if(!e)return 1;var t=r&&r.maxBatchSize;if(t===void 0)return 1/0;if(typeof t!="number"||t<1)throw new TypeError("maxBatchSize must be a positive number: "+t);return t}s(Fi,"getValidMaxBatchSize");function Hi(r){var e=r&&r.batchScheduleFn;if(e===void 0)return Gi;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}s(Hi,"getValidBatchScheduleFn");function Qi(r){var e=r&&r.cacheKeyFn;if(e===void 0)return function(t){return t};if(typeof e!="function")throw new TypeError("cacheKeyFn must be a function: "+e);return e}s(Qi,"getValidCacheKeyFn");function zi(r){var e=!r||r.cache!==!1;if(!e)return null;var t=r&&r.cacheMap;if(t===void 0)return new Map;if(t!==null){var n=["get","set","delete","clear"],i=n.filter(function(o){return t&&typeof t[o]!="function"});if(i.length!==0)throw new TypeError("Custom cacheMap missing methods: "+i.join(", "))}return t}s(zi,"getValidCacheMap");function Wi(r){return r&&r.name?r.name:null}s(Wi,"getValidName");function rn(r){return typeof r=="object"&&r!==null&&typeof r.length=="number"&&(r.length===0||r.length>0&&Object.prototype.hasOwnProperty.call(r,r.length-1))}s(rn,"isArrayLike");nn.exports=Ni});var R=s(r=>r.split("/").pop()??"","shopifyGidToId"),w=s((r,e)=>`gid://shopify/${r}/${e}`,"shopifyIdToGid");var Q=class{constructor(e,t,n=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.clearCachePromise=null;this.cacheName=e,this.defaultCacheControl=t,this.keyPrefix=n}static{s(this,"FetchCache")}async get(e){try{let t=await caches.open(this.cacheName),n=await t.match(e);if(n&&this.isExpired(n)){await t.delete(e);return}return n}catch(t){console.warn("Cache get error:",t);return}}async set(e,t,n){try{if(n?.includes("no-cache"))return;let i=this.createCacheableResponse(t,n);await(await caches.open(this.cacheName)).put(e,i)}catch(i){console.warn("Cache set error:",i)}}async fetchWithCache(e,t,n){let i=await this.getCacheKey(e,t);if(this.clearCachePromise&&await this.clearCachePromise,this.inFlightRequests.has(i))return this.inFlightRequests.get(i).then(a=>a.clone());let o=(async()=>{let a=await this.get(i);if(a)return this.isStaleButRevalidatable(a)&&this.revalidateInBackground(i,e,t,n),a.clone();let u=await fetch(e,t);return u.ok&&await this.set(i,u.clone(),n??this.defaultCacheControl),u})().finally(()=>{this.inFlightRequests.delete(i)});return this.inFlightRequests.set(i,o),o}async delete(e){try{return await(await caches.open(this.cacheName)).delete(e)}catch(t){return console.warn("Cache delete error:",t),!1}}async clear(){return this.clearCachePromise?this.clearCachePromise:(this.clearCachePromise=new Promise(async(e,t)=>{try{let n=await caches.open(this.cacheName),i=await n.keys();await Promise.all(i.map(o=>n.delete(o))),e()}catch(n){console.warn("Cache clear error:",n),t(n)}}),this.clearCachePromise.then(()=>{this.clearCachePromise=null}).catch(e=>{console.warn("Cache clear error:",e)}))}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(n=>n.url)}catch(e){return console.warn("Cache keys error:",e),[]}}async has(e){try{let t=await caches.open(this.cacheName),n=await t.match(e);return n&&this.isExpired(n)?(await t.delete(e),!1):n!==void 0}catch(t){return console.warn("Cache has error:",t),!1}}async getStats(){try{return{total:(await(await caches.open(this.cacheName)).keys()).length}}catch(e){return console.warn("Cache stats error:",e),{total:0}}}async cleanupExpiredEntries(){try{let e=await caches.open(this.cacheName),t=await e.keys(),n=0;for(let o of t){let a=await e.match(o);a&&this.isExpired(a)&&(await e.delete(o),n++)}let i=t.length-n;return{removed:n,remaining:i}}catch(e){return console.warn("Cache cleanup error:",e),{removed:0,remaining:0}}}async getCacheKey(e,t){let n=this.getInputUrl(e),i=`${this.keyPrefix}${n}/${JSON.stringify(t)}`,a=new TextEncoder().encode(i),u=await crypto.subtle.digest("SHA-256",a);return`/${Array.from(new Uint8Array(u)).map(p=>p.toString(16).padStart(2,"0")).join("")}`}getInputUrl(e){return e instanceof URL?e.toString():typeof e=="string"?e:e.url}isExpired(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let n=this.parseMaxAge(t),i=this.parseStaleWhileRevalidate(t);if(n===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),l=(Date.now()-a)/1e3,c=n+(i??0);return l>c}isStaleButRevalidatable(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let n=this.parseMaxAge(t),i=this.parseStaleWhileRevalidate(t);if(n===null||i===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),l=(Date.now()-a)/1e3;return l>n&&l<=n+i}async revalidateInBackground(e,t,n,i){if(this.revalidationPromises.has(e))return;let o=(async()=>{try{let a=await fetch(t,n);a.ok&&await this.set(e,a.clone(),i??this.defaultCacheControl)}catch(a){console.warn("Background revalidation error:",a)}finally{this.revalidationPromises.delete(e)}})();this.revalidationPromises.set(e,o)}parseMaxAge(e){let t=new RegExp(/max-age=(\d+)/).exec(e);return t?parseInt(t[1],10):null}parseStaleWhileRevalidate(e){let t=new RegExp(/stale-while-revalidate=(\d+)/).exec(e);return t?parseInt(t[1],10):null}createCacheableResponse(e,t){let n=new Headers(e.headers);return n.set("Cache-Control",t),n.has("Date")||n.set("Date",new Date().toUTCString()),new Response(e.body,{status:e.status,statusText:e.statusText,headers:n})}};var ye=class{static{s(this,"AjaxApiClient")}constructor(e){this.config=e,this.cache=new Q("ajax-api","max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(t=>{console.warn("Ajax API cache initialization cleanup error:",t)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let e=window.fetch,t=this.config.responseInterceptor,n=this.getFetchRequest.bind(this);window.fetch=function(...i){let o=e.apply(this,i);if(typeof t=="function"){let a=n(i[0]);o.then(u=>t(u,a))}return o}}getFetchRequest(e){return e instanceof Request?e:new Request(e)}getBaseUrl(){if(!this.config?.storeDomain)throw new Error("Cart API client not initialized - missing store domain");return`https://${this.config.storeDomain}`}fetch(e,t){return(e instanceof Request?e.method:t?.method??"GET")==="GET"?this.cache.fetchWithCache(e,t):fetch(e,t)}async request(e,t={}){let n=`${this.getBaseUrl()}${e}`,i={"Content-Type":"application/json",Accept:"application/json"},o=await this.fetch(n,{...t,headers:{...i,...t.headers}});if(!o.ok){let a;try{a=await o.json()}catch{a={message:`HTTP ${o.status}: ${o.statusText}`,status:o.status.toString(),description:o.statusText}}throw new Error(a.message||a.description)}return o.json()}async fetchCart(){return this.request("/cart.js")}async addToCart(e){let t={...e,items:e.items.map(n=>{let i=R(n.id);if(!i)throw new Error(`Invalid Shopify GID format: ${n.id}`);let o=parseInt(i,10);if(isNaN(o))throw new Error(`Invalid numeric ID extracted from GID: ${n.id}`);return{...n,id:o}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(t)})}async clearCache(){await this.cache.clear()}};var me=class{constructor(e){this.eventMap={"/cart/add":"cart-add","/cart/update":"cart-update","/cart/change":"cart-change","/cart/clear":"cart-clear"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{s(this,"AjaxApiPublisher")}async processFetchResponse(e,t){try{let n=this.getEventName(t.url);if(n){let i=await e.clone().json();this.eventBus.publish(n,i)}}catch(n){console.warn(n)}}getEventName(e){for(let[t,n]of Object.entries(this.eventMap))if(e.includes(t))return n;return null}};function In(){let r=document.body||document.documentElement;return r?Promise.resolve(r):new Promise(e=>{window.addEventListener("DOMContentLoaded",()=>e(r))})}s(In,"waitForDOM");function pe({onElementFound:r,selector:e,observerOptions:t}){let n=new WeakSet,i=new MutationObserver(l=>{let c=!1;for(let p of l)if(p.addedNodes.length>0){c=!0;break}c&&o()}),o=s(()=>{document.querySelectorAll(e).forEach(l=>{n.has(l)||(a(l),n.add(l))})},"locateElements"),a=s(l=>{if(!t){r(l);return}let c=new IntersectionObserver(p=>{for(let d of p)d.isIntersecting&&(c.disconnect(),r(l))},t);c.observe(l)},"observeElement");return s(async()=>{let l=await In();o(),i.observe(l,{childList:!0,subtree:!0})},"locateAndObserveElements")(),i}s(pe,"createElementLocator");function oe({onLocationChange:r,fireOnInit:e=!1}){let t=s(()=>{r(window.location)},"handleChange");window.addEventListener("popstate",t);let n=history.pushState,i=history.replaceState;return history.pushState=function(...o){n.apply(this,o),t()},history.replaceState=function(...o){i.apply(this,o),t()},e&&t(),()=>{window.removeEventListener("popstate",t),history.pushState=n,history.replaceState=i}}s(oe,"createLocationObserver");function Vt({element:r,onHrefChange:e}){let t=s(()=>{e(r.href)},"handleChange"),n=new MutationObserver(()=>{t()});return n.observe(r,{attributes:!0,attributeFilter:["href"]}),()=>{n.disconnect()}}s(Vt,"createHrefObserver");var ve=class{constructor(){this.eventBus=new EventTarget}static{s(this,"EventBus")}subscribe(e,t,n){return Array.isArray(e)||(e=[e]),e.forEach(i=>{this.eventBus.addEventListener(i,t,n)}),()=>{e.forEach(i=>{this.eventBus.removeEventListener(i,t,n)})}}unsubscribe(e,t,n){this.eventBus.removeEventListener(e,t,n)}publish(e,t){this.eventBus.dispatchEvent(new CustomEvent(e,{detail:t}))}};var ze;function Nt(r){return{lang:r?.lang??ze?.lang,message:r?.message,abortEarly:r?.abortEarly??ze?.abortEarly,abortPipeEarly:r?.abortPipeEarly??ze?.abortPipeEarly}}s(Nt,"getGlobalConfig");var wn;function bn(r){return wn?.get(r)}s(bn,"getGlobalMessage");var En;function Cn(r){return En?.get(r)}s(Cn,"getSchemaMessage");var xn;function Sn(r,e){return xn?.get(r)?.get(e)}s(Sn,"getSpecificMessage");function We(r){let e=typeof r;return e==="string"?`"${r}"`:e==="number"||e==="bigint"||e==="boolean"?`${r}`:e==="object"||e==="function"?(r&&Object.getPrototypeOf(r)?.constructor?.name)??"null":e}s(We,"_stringify");function X(r,e,t,n,i){let o=i&&"input"in i?i.input:t.value,a=i?.expected??r.expects??null,u=i?.received??We(o),l={kind:r.kind,type:r.type,input:o,expected:a,received:u,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:r.requirement,path:i?.path,issues:i?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},c=r.kind==="schema",p=i?.message??r.message??Sn(r.reference,l.lang)??(c?Cn(l.lang):null)??n.message??bn(l.lang);p!==void 0&&(l.message=typeof p=="function"?p(l):p),c&&(t.typed=!1),t.issues?t.issues.push(l):t.issues=[l]}s(X,"_addIssue");function Z(r){return{version:1,vendor:"valibot",validate(e){return r["~run"]({value:e},Nt())}}}s(Z,"_getStandardProps");function An(r,e){let t=[...new Set(r)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}s(An,"_joinExpects");function Xe(r,e){return{kind:"validation",type:"min_value",reference:Xe,async:!1,expects:`>=${r instanceof Date?r.toJSON():We(r)}`,requirement:r,message:e,"~run"(t,n){return t.typed&&!(t.value>=this.requirement)&&X(this,"value",t,n,{received:t.value instanceof Date?t.value.toJSON():We(t.value)}),t}}}s(Xe,"minValue");function j(r){return{kind:"transformation",type:"transform",reference:j,async:!1,operation:r,"~run"(e){return e.value=this.operation(e.value),e}}}s(j,"transform");function kn(r,e,t){return typeof r.fallback=="function"?r.fallback(e,t):r.fallback}s(kn,"getFallback");function Gt(r,e,t){return typeof r.default=="function"?r.default(e,t):r.default}s(Gt,"getDefault");function Ke(r,e){return{kind:"schema",type:"array",reference:Ke,expects:"Array",async:!1,item:r,message:e,get"~standard"(){return Z(this)},"~run"(t,n){let i=t.value;if(Array.isArray(i)){t.typed=!0,t.value=[];for(let o=0;o<i.length;o++){let a=i[o],u=this.item["~run"]({value:a},n);if(u.issues){let l={type:"array",origin:"value",input:i,key:o,value:a};for(let c of u.issues)c.path?c.path.unshift(l):c.path=[l],t.issues?.push(c);if(t.issues||(t.issues=u.issues),n.abortEarly){t.typed=!1;break}}u.typed||(t.typed=!1),t.value.push(u.value)}}else X(this,"type",t,n);return t}}}s(Ke,"array");function U(r){return{kind:"schema",type:"number",reference:U,expects:"number",async:!1,message:r,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:X(this,"type",e,t),e}}}s(U,"number");function A(r,e){return{kind:"schema",type:"object",reference:A,expects:"Object",async:!1,entries:r,message:e,get"~standard"(){return Z(this)},"~run"(t,n){let i=t.value;if(i&&typeof i=="object"){t.typed=!0,t.value={};for(let o in this.entries){let a=this.entries[o];if(o in i||(a.type==="exact_optional"||a.type==="optional"||a.type==="nullish")&&a.default!==void 0){let u=o in i?i[o]:Gt(a),l=a["~run"]({value:u},n);if(l.issues){let c={type:"object",origin:"value",input:i,key:o,value:u};for(let p of l.issues)p.path?p.path.unshift(c):p.path=[c],t.issues?.push(p);if(t.issues||(t.issues=l.issues),n.abortEarly){t.typed=!1;break}}l.typed||(t.typed=!1),t.value[o]=l.value}else if(a.fallback!==void 0)t.value[o]=kn(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(X(this,"key",t,n,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:i,key:o,value:i[o]}]}),n.abortEarly))break}}else X(this,"type",t,n);return t}}}s(A,"object");function N(r,e){return{kind:"schema",type:"optional",reference:N,expects:`(${r.expects} | undefined)`,async:!1,wrapped:r,default:e,get"~standard"(){return Z(this)},"~run"(t,n){return t.value===void 0&&(this.default!==void 0&&(t.value=Gt(this,t,n)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,n)}}}s(N,"optional");function b(r){return{kind:"schema",type:"string",reference:b,expects:"string",async:!1,message:r,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:X(this,"type",e,t),e}}}s(b,"string");function Ut(r){let e;if(r)for(let t of r)e?e.push(...t.issues):e=t.issues;return e}s(Ut,"_subIssues");function ee(r,e){return{kind:"schema",type:"union",reference:ee,expects:An(r.map(t=>t.expects),"|"),async:!1,options:r,message:e,get"~standard"(){return Z(this)},"~run"(t,n){let i,o,a;for(let u of this.options){let l=u["~run"]({value:t.value},n);if(l.typed)if(l.issues)o?o.push(l):o=[l];else{i=l;break}else a?a.push(l):a=[l]}if(i)return i;if(o){if(o.length===1)return o[0];X(this,"type",t,n,{issues:Ut(o)}),t.typed=!0}else{if(a?.length===1)return a[0];X(this,"type",t,n,{issues:Ut(a)})}return t}}}s(ee,"union");function G(...r){return{...r[0],pipe:r,get"~standard"(){return Z(this)},"~run"(e,t){for(let n of r)if(n.kind!=="metadata"){if(e.issues&&(n.kind==="schema"||n.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=n["~run"](e,t))}return e}}}s(G,"pipe");function _(r,e,t){let n=r["~run"]({value:e},Nt(t));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}s(_,"safeParse");var E=class{constructor(e,t,n,i){this.swish=e;this.ui=t;this.eventBus=n;this.options=i}static{s(this,"IntentHandler")}};var Rn=A({itemId:N(G(b())),productId:G(ee([G(b(),j(R)),U()]),j(r=>Number(r)),U()),variantId:N(G(ee([G(b(),j(R)),U()]),j(r=>Number(r)),U()))}),ae=class extends E{static{s(this,"EditItemVariantHandler")}async invoke(e,t=!1){return new Promise(n=>{let i=e.data,o=_(Rn,i);if(!o.success){n({code:"error",message:"Invalid intent data",issues:o.issues.map(c=>c.message)});return}let{itemId:a,productId:u,variantId:l}=o.output;this.ui.showVariantSelect({productId:u.toString(),variantId:l?.toString(),onClose:s(()=>{n({code:"closed"})},"onClose"),onSubmit:s(async c=>{let{item:p,product:d,variant:m}=c,h={code:"ok",data:{item:p,product:d,variant:m}};t||this.eventBus.dispatchEvent(new CustomEvent("edit:swish/ItemVariant",{detail:h})),n(h)},"onSubmit")})})}};var Dn=A({productId:G(ee([G(b(),j(R)),U()]),j(r=>Number(r)),U()),variantId:N(G(ee([G(b(),j(R)),U()]),j(Number),U())),quantity:N(G(U(),Xe(1))),tags:N(Ke(b()))}),ge=class extends E{static{s(this,"CreateItemHandler")}async invoke(e){let t=e.data,n=_(Dn,t);if(!n.success)return{code:"error",message:"Invalid intent data",issues:n.issues.map(m=>m.message)};let{productId:i,variantId:o,quantity:a,tags:u}=n.output,l=await this.swish.storefront.loadSaveIntentData({productId:w("Product",i),variantId:o?w("ProductVariant",o):void 0});if(l.errors)return{code:"error",message:l.errors.message??"Failed to load save intent data",issues:l.errors.graphQLErrors?.map(m=>m.message)??[]};if(!l.data||!l.data.product)return{code:"error",message:"Failed to load save intent data",issues:["API response missing data"]};let{product:c}=l.data,p=c.variantsCount?.count&&c.variantsCount.count>1;if(!p||!this.options.save.requireVariant){let m=s(()=>!p&&c.selectedOrFirstAvailableVariant?Number(R(c.selectedOrFirstAvailableVariant.id)):o,"variantIdToUse"),h=await this.swish.api.items.create({productId:i,variantId:m(),quantity:a,tags:u});if("error"in h)return{code:"error",message:"Failed to create item",issues:[h.error.message]};if(!h.data)return{code:"error",message:"Could not complete item creation",issues:["API response missing data"]};let D="variant"in l.data?l.data.variant:void 0,y={code:"ok",data:{item:h.data,product:c,variant:p?D:c.selectedOrFirstAvailableVariant}};return this.eventBus.dispatchEvent(new CustomEvent("create:swish/Item",{detail:y})),y}let d=await new ae(this.swish,this.ui,this.eventBus,this.options).invoke({action:"edit",type:"swish/ItemVariant",data:{productId:i,variantId:o}});return this.eventBus.dispatchEvent(new CustomEvent("create:swish/Item",{detail:d})),d}};var Ie=class extends E{static{s(this,"CreateListHandler")}async invoke(e){return new Promise(t=>{this.ui.showListEditor({onClose:s(()=>{t({code:"closed"})},"onClose"),onSubmit:s(async n=>{let{list:i}=n;t({code:"ok",data:{list:i}})},"onSubmit")})})}};var Pn=A({itemId:b()}),we=class extends E{static{s(this,"DeleteItemHandler")}async invoke(e){return new Promise(async t=>{let n=_(Pn,e.data);if(!n.success){t({code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)});return}let{itemId:i}=n.output;if(!this.options.unsave.requireConfirmation){let o=await this.swish.api.items.deleteById(i);if("error"in o){t({code:"error",message:"Failed to delete item",issues:[o.error.message]});return}t({code:"ok",data:{itemId:i}});return}this.ui.showUnsaveAlert({itemId:i,onClose:s(()=>{t({code:"closed"})},"onClose"),onSubmit:s(()=>{t({code:"ok",data:{itemId:i}})},"onSubmit")})})}};var Tn=A({listId:b()}),be=class extends E{static{s(this,"DeleteListHandler")}async invoke(e){return new Promise(t=>{let n=e.data,i=_(Tn,n);if(!i.success){t({code:"error",message:"Invalid intent data",issues:i.issues.map(a=>a.message)});return}let{listId:o}=i.output;this.ui.showDeleteListAlert({listId:o,onClose:s(()=>{t({code:"closed"})},"onClose"),onSubmit:s(async()=>{t({code:"ok",data:{listId:o}})},"onSubmit")})})}};var _n=A({itemId:b()}),Ee=class extends E{static{s(this,"EditItemListsHandler")}async invoke(e,t=!1){return new Promise(n=>{let i=e.data,o=_(_n,i);if(!o.success){n({code:"error",message:"Invalid intent data",issues:o.issues.map(u=>u.message)});return}let{itemId:a}=o.output;this.ui.showListSelect({itemId:a,onClose:s(()=>{n({code:"closed"})},"onClose"),onSubmit:s(async u=>{let{item:l,product:c,variant:p}=u,d={code:"ok",data:{item:l,product:c,variant:p}};t||this.eventBus.dispatchEvent(new CustomEvent("edit:swish/ItemLists",{detail:d})),n(d)},"onSubmit"),onUnsave(u){let l={code:"ok",data:{itemId:u.itemId}};n(l)}})})}};var On=A({listId:b()}),Ce=class extends E{static{s(this,"EditListHandler")}async invoke(e){return new Promise(t=>{let n=e.data,i=_(On,n);if(!i.success){t({code:"error",message:"Invalid intent data",issues:i.issues.map(a=>a.message)});return}let{listId:o}=i.output;this.ui.showListEditor({listId:o,onClose:s(()=>{t({code:"closed"})},"onClose"),onSubmit:s(async a=>{let{list:u}=a;t({code:"ok",data:{list:u}})},"onSubmit")})})}};var xe=class extends E{static{s(this,"OpenHomeHandler")}async invoke(e){return new Promise(t=>{this.ui.showDrawer({onClose:s(()=>{t({code:"closed"})},"onClose")})})}};var Ln=A({listId:b()}),Se=class extends E{static{s(this,"OpenListMenuHandler")}async invoke(e){return new Promise(t=>{let n=e.data,i=_(Ln,n);if(!i.success){t({code:"error",message:"Invalid intent data",issues:i.issues.map(a=>a.message)});return}let{listId:o}=i.output;this.ui.showListMenu({listId:o,onClose:s(()=>{t({code:"closed"})},"onClose"),onEdit:s(a=>{t({code:"ok",data:a})},"onEdit"),onDelete:s(()=>{t({code:"ok",data:{listId:o}})},"onDelete")})})}};var Xs=A({returnTo:N(b())}),Ae=class extends E{static{s(this,"OpenSignInHandler")}async invoke(e){return new Promise(t=>{this.ui.showSignIn({returnTo:e.data?.returnTo,onClose:s(()=>{t({code:"closed"})},"onClose")})})}};var $n=A({productId:b(),variantId:N(b())}),ke=class extends E{static{s(this,"OpenQuickBuyHandler")}async invoke(e){return new Promise(t=>{let n=_($n,e.data);if(!n.success){t({code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)});return}let{productId:i,variantId:o}=n.output;this.ui.showQuickBuy({productId:i,variantId:o,onClose:s(()=>{t({code:"closed"})},"onClose"),onSubmit:s(a=>{t({code:"ok",data:a})},"onSubmit")})})}};var ue=class{constructor(e,t,n){this.swish=e;this.ui=t;this.options=n}static{s(this,"IntentHook")}};var Re=class extends ue{static{s(this,"AfterCreateItemHook")}async invoke(e){if(this.options.save.showToast&&e.code==="ok"){let{item:t,product:n,variant:i}=e.data;n&&this.ui.showToast({title:"Saved",text:n.title,image:i?.image?.url??n.featuredImage?.url,action:{label:"Add to List",onClick:s(()=>{this.swish.intents.invoke({action:"edit",type:"swish/ItemLists",data:{itemId:t.id}})},"onClick")}})}}};var De=class extends ue{static{s(this,"AfterEditItemListsHook")}async invoke(e){if(this.options.edit.showToast&&e.code==="ok"){if("itemId"in e.data)return;let{product:t,variant:n}=e.data;t&&this.ui.showToast({title:"Saved",text:t.title,image:n?.image?.url??t.featuredImage?.url,action:{label:"View",onClick:s(()=>{this.swish.intents.invoke({action:"open",type:"swish/Home"})},"onClick")}})}}};var Pe=class{static{s(this,"Intents")}constructor(e,t){this.swish=e,this.ui=t,this.eventBus=new EventTarget,this.options=e.options.swishUi.intents,this.initIntentHooks(),this.initIntentWatcher()}publishAnalyticsEvent(e,t){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(e,t)}async invoke(e){let t=this.parseIntent(e),n=this.getIntentQuery(t),i={lifecycle:"before",intent:t};return this.publishAnalyticsEvent("swish-intent",i),this.publishAnalyticsEvent(`swish-intent=${n}`,i),{intent:t,complete:this.handleIntent(t).then(o=>{let a={lifecycle:"after",intent:t,response:o};return this.publishAnalyticsEvent("swish-intent",a),this.publishAnalyticsEvent(`swish-intent=${n}`,a),o})}}listen(e,t){let n=this.getIntentQuery(e),i=s(a=>{"detail"in a&&a.detail?t(a.detail):console.warn("Intent response event without detail",a)},"eventListener"),o=s(()=>{this.eventBus.removeEventListener(n,i)},"unsubscribe");return this.eventBus.addEventListener(n,i),o}getIntentQuery(e){return`${e.action}:${e.type}`}parseIntent(e){if(typeof e=="string"){let[t,...n]=e.split(","),[i,o]=t.split(":"),a=n.reduce((u,l)=>{let[c,p]=l.split("=");return u[c]=p,u},{});return{action:i,type:o,data:a}}return e}async handleIntent(e){return e.action==="create"&&e.type==="swish/Item"?new ge(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="delete"&&e.type==="swish/Item"?new we(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="edit"&&e.type==="swish/ItemVariant"?new ae(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="edit"&&e.type==="swish/ItemLists"?new Ee(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="create"&&e.type==="swish/List"?new Ie(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="edit"&&e.type==="swish/List"?new Ce(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="delete"&&e.type==="swish/List"?new be(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/Home"?new xe(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/ListMenu"?new Se(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/SignIn"?new Ae(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/QuickBuy"?new ke(this.swish,this.ui,this.eventBus,this.options).invoke(e):{code:"error",message:"Invalid intent",issues:["Invalid intent"]}}initIntentHooks(){this.eventBus.addEventListener("create:swish/Item",e=>{new Re(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:swish/ItemLists",e=>{new De(this.swish,this.ui,this.options).invoke(e.detail)})}initIntentWatcher(){pe({selector:"[swish-intent]",onElementFound:s(e=>{let t=this.parseIntent(e.getAttribute("swish-intent"));t&&e.addEventListener("click",()=>{this.invoke(t)})},"onElementFound")}),pe({selector:"a[href*='swish-intent=']",onElementFound:s(e=>{e instanceof HTMLAnchorElement&&e.addEventListener("click",t=>{if(!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey){let i=new URL(e.href).searchParams.get("swish-intent");if(i){let o=this.parseIntent(i);o&&(t.preventDefault(),t.stopPropagation(),this.invoke(o))}}})},"onElementFound")}),oe({fireOnInit:!0,onLocationChange:s(e=>{let t=new URLSearchParams(window.location.search).get("swish-intent");if(t){let n=this.parseIntent(t);if(n){this.invoke(n);let i=new URL(window.location.href);i.searchParams.delete("swish-intent"),window.history.replaceState({},document.title,i.toString())}}},"onLocationChange")})}};var Bn=Symbol.for("preact-signals");function _e(){if(K>1)K--;else{for(var r,e=!1;fe!==void 0;){var t=fe;for(fe=void 0,Ye++;t!==void 0;){var n=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&Ft(t))try{t.c()}catch(i){e||(r=i,e=!0)}t=n}}if(Ye=0,K--,e)throw r}}s(_e,"t");function Y(r){if(K>0)return r();K++;try{return r()}finally{_e()}}s(Y,"r");var g=void 0;function Mt(r){var e=g;g=void 0;try{return r()}finally{g=e}}s(Mt,"n");var fe=void 0,K=0,Ye=0,Te=0;function jt(r){if(g!==void 0){var e=r.n;if(e===void 0||e.t!==g)return e={i:0,S:r,p:g.s,n:void 0,t:g,e:void 0,x:void 0,r:e},g.s!==void 0&&(g.s.n=e),g.s=e,r.n=e,32&g.f&&r.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=g.s,e.n=void 0,g.s.n=e,g.s=e),e}}s(jt,"e");function L(r,e){this.v=r,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}s(L,"u");L.prototype.brand=Bn;L.prototype.h=function(){return!0};L.prototype.S=function(r){var e=this,t=this.t;t!==r&&r.e===void 0&&(r.x=t,this.t=r,t!==void 0?t.e=r:Mt(function(){var n;(n=e.W)==null||n.call(e)}))};L.prototype.U=function(r){var e=this;if(this.t!==void 0){var t=r.e,n=r.x;t!==void 0&&(t.x=n,r.e=void 0),n!==void 0&&(n.e=t,r.x=void 0),r===this.t&&(this.t=n,n===void 0&&Mt(function(){var i;(i=e.Z)==null||i.call(e)}))}};L.prototype.subscribe=function(r){var e=this;return V(function(){var t=e.value,n=g;g=void 0;try{r(t)}finally{g=n}},{name:"sub"})};L.prototype.valueOf=function(){return this.value};L.prototype.toString=function(){return this.value+""};L.prototype.toJSON=function(){return this.value};L.prototype.peek=function(){var r=g;g=void 0;try{return this.value}finally{g=r}};Object.defineProperty(L.prototype,"value",{get:s(function(){var r=jt(this);return r!==void 0&&(r.i=this.i),this.v},"get"),set:s(function(r){if(r!==this.v){if(Ye>100)throw new Error("Cycle detected");this.v=r,this.i++,Te++,K++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{_e()}}},"set")});function C(r,e){return new L(r,e)}s(C,"d");function Ft(r){for(var e=r.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}s(Ft,"c");function Ht(r){for(var e=r.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){r.s=e;break}}}s(Ht,"a");function Qt(r){for(var e=r.s,t=void 0;e!==void 0;){var n=e.p;e.i===-1?(e.S.U(e),n!==void 0&&(n.n=e.n),e.n!==void 0&&(e.n.p=n)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=n}r.s=t}s(Qt,"l");function te(r,e){L.call(this,void 0),this.x=r,this.s=void 0,this.g=Te-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}s(te,"y");te.prototype=new L;te.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Te))return!0;if(this.g=Te,this.f|=1,this.i>0&&!Ft(this))return this.f&=-2,!0;var r=g;try{Ht(this),g=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return g=r,Qt(this),this.f&=-2,!0};te.prototype.S=function(r){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}L.prototype.S.call(this,r)};te.prototype.U=function(r){if(this.t!==void 0&&(L.prototype.U.call(this,r),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};te.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var r=this.t;r!==void 0;r=r.x)r.t.N()}};Object.defineProperty(te.prototype,"value",{get:s(function(){if(1&this.f)throw new Error("Cycle detected");var r=jt(this);if(this.h(),r!==void 0&&(r.i=this.i),16&this.f)throw this.v;return this.v},"get")});function B(r,e){return new te(r,e)}s(B,"w");function zt(r){var e=r.u;if(r.u=void 0,typeof e=="function"){K++;var t=g;g=void 0;try{e()}catch(n){throw r.f&=-2,r.f|=8,Je(r),n}finally{g=t,_e()}}}s(zt,"_");function Je(r){for(var e=r.s;e!==void 0;e=e.n)e.S.U(e);r.x=void 0,r.s=void 0,zt(r)}s(Je,"b");function qn(r){if(g!==this)throw new Error("Out-of-order effect");Qt(this),g=r,this.f&=-2,8&this.f&&Je(this),_e()}s(qn,"g");function le(r,e){this.x=r,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}s(le,"p");le.prototype.c=function(){var r=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{r()}};le.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,zt(this),Ht(this),K++;var r=g;return g=this,qn.bind(this,r)};le.prototype.N=function(){2&this.f||(this.f|=2,this.o=fe,fe=this)};le.prototype.d=function(){this.f|=8,1&this.f||Je(this)};le.prototype.dispose=function(){this.d()};function V(r,e){var t=new le(r,e);try{t.c()}catch(i){throw t.d(),i}var n=t.d.bind(t);return n[Symbol.dispose]=n,n}s(V,"E");var Vn=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,Ze=s(r=>{let e=r.match(Vn);return e?{productHandle:e[1],variantId:e[2]}:null},"parseProductUrl"),Wt=s(({source:r,onProductUrlChange:e})=>{let t=s(n=>{let i=Ze(n);i?.productHandle&&e(i)},"handleChange");if(r instanceof HTMLAnchorElement)return Vt({element:r,onHrefChange:s(n=>t(n),"onHrefChange")});if(r instanceof Location)return oe({onLocationChange:s(n=>t(n.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Xt=s(r=>e=>{let{productHandle:t,productId:n,variantId:i,itemId:o}=e?.dataset??{},l=!!(n||t)||!!o,c=C({loading:!1,productId:n,variantId:i,itemId:o});if(!l){let p=e instanceof HTMLAnchorElement?e:window.location,d=Ze(p.href);d?.productHandle&&d.productHandle!==c.value.productHandle&&(c.value={...c.value,...d,productId:void 0},Wt({source:p,onProductUrlChange:s(m=>{c.value={...c.value,...m,productId:m.productHandle!==c.value.productHandle?void 0:c.value.productId}},"onProductUrlChange")}))}return V(()=>{c.value.loading||!c.value.productId&&c.value.productHandle&&(c.value={...c.value,loading:!0},r.storefront.loadProductId({productHandle:c.value.productHandle}).then(p=>{p.errors&&console.error("Error loading product id",p.errors),c.value={...c.value,productId:p.data?.product?.id?R(p.data.product.id):void 0,loading:!1}}))}),c},"itemContextSignal");var Kt=s(r=>e=>{let t=B(()=>{let{productId:I,variantId:v,loading:P}=e.value;return!I||P?null:v?`variant:${R(v)}`:`product:${R(I)}`}),n=B(()=>e.value.loading||!!e.value.itemId||!e.value.productId),i=B(()=>({limit:1,query:t.value??void 0})),o=C(!n.value),a=C(null),u=C(!1),l=C(!1),{data:c,loading:p,error:d,refetching:m}=r.state.swishQuery(I=>r.api.items.list(I),{refetch:["item-create","item-update","item-delete"],variables:i,skip:n}),h=C(e.value.itemId??null);V(()=>{Y(()=>{if(o.value=p.value,a.value=d.value,!e.value.itemId){let I=c.value?.[0]?.id??null;I!==h.value&&(h.value=I)}})});async function D(){if(!h.value)return;u.value=!0,(await(await r.intents.invoke({action:"delete",type:"swish/Item",data:{itemId:h.value}})).complete).code==="ok"&&(h.value=null),u.value=!1}s(D,"unsave");async function y(){if(!h.value)return;u.value=!0;let v=await(await r.intents.invoke({action:"edit",type:"swish/ItemLists",data:{itemId:h.value}})).complete;v.code==="ok"&&"itemId"in v.data&&(h.value=null),u.value=!1}s(y,"update");async function S(){let{productId:I,variantId:v}=e.value;if(!I)return;u.value=!0,l.value=!0;let T=await(await r.intents.invoke({action:"create",type:"swish/Item",data:{productId:I,variantId:v}})).complete;if(T.code==="ok"){let ce=T.data;h.value=ce.item.id,u.value=!1}else T.code==="error"&&console.warn("Failed to create item",T),Y(()=>{u.value=!1,l.value=!1})}s(S,"save");let O=B(()=>o.value||u.value||e.value.loading);V(()=>{l.value&&!u.value&&!m.value&&(l.value=!1)});let k=B(()=>{let I=m.value&&l.value,v=!!h.value,P=!v&&(u.value||I),T=v&&(u.value||I),ce=B(()=>P?"saving":T?"unsaving":v?"saved":"unsaved");return{error:a.value,status:ce.value,savedItemId:h.value,loading:O.value,submitting:u.value,saved:v,saving:P,unsaving:T}});async function F(){O.value||(k.value.saved&&k.value.savedItemId?y():k.value.saved||await S())}return s(F,"toggle"),Object.assign(k,{save:S,unsave:D,update:y,toggle:F})},"itemStateSignal");var Yt=s(r=>()=>{let{data:e,loading:t,error:n}=r.state.swishQuery(()=>r.api.items.count(),{refetch:["item-create","item-delete"]}),i=C(0),o=C(!0),a=C(null);return V(()=>{Y(()=>{o.value=t.value,a.value=n.value,i.value=e.value?.count??0})}),B(()=>({count:i.value,loading:o.value,error:a.value}))},"itemCountSignal");var Jt=s(r=>(e,t)=>{let n=C(null),i=C(null),o=C(null),a=C(!t?.skip),u=C(!1),l=B(()=>a.value&&u.value);async function c(){if(!t?.skip?.value)try{a.value=!0;let p=await e(t?.variables?.value);Y(()=>{o.value="error"in p?p.error:null,n.value="data"in p?p.data:null,i.value="pageInfo"in p?p.pageInfo:null,a.value=!1,u.value=!0})}catch(p){Y(()=>{o.value=p,a.value=!1,u.value=!0})}}return s(c,"executeFetch"),V(()=>{if(c(),t?.refetch?.length)return r.events.subscribe(t.refetch,c)}),{data:n,pageInfo:i,error:o,loading:a,refetching:l}},"swishQuerySignals");var re="GraphQL Client";var et="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",tt="Response returned unexpected Content-Type:",rt="An unknown error has occurred. The API did not return a data object or any errors in its response.",Oe={json:"application/json",multipart:"multipart/mixed"},nt="X-SDK-Variant",it="X-SDK-Version",er="shopify-graphql-client",tr="1.4.1",Le=1e3,rr=[429,503],st=/@(defer)\b/i,Zt=`\r
8
- `,nr=/boundary="?([^=";]+)"?/i,ot=Zt+Zt;function H(r,e=re){return r.startsWith(`${e}`)?r:`${e}: ${r}`}s(H,"formatErrorMessage");function W(r){return r instanceof Error?r.message:JSON.stringify(r)}s(W,"getErrorMessage");function at(r){return r instanceof Error&&r.cause?r.cause:void 0}s(at,"getErrorCause");function ut(r){return r.flatMap(({errors:e})=>e??[])}s(ut,"combineErrors");function $e({client:r,retries:e}){if(e!==void 0&&(typeof e!="number"||e<0||e>3))throw new Error(`${r}: The provided "retries" value (${e}) is invalid - it cannot be less than ${0} or greater than ${3}`)}s($e,"validateRetries");function $(r,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[r]:e}:{}}s($,"getKeyValueIfValid");function lt(r,e){if(r.length===0)return e;let n={[r.pop()]:e};return r.length===0?n:lt(r,n)}s(lt,"buildDataObjectByPath");function or(r,e){return Object.keys(e||{}).reduce((t,n)=>(typeof e[n]=="object"||Array.isArray(e[n]))&&r[n]?(t[n]=or(r[n],e[n]),t):(t[n]=e[n],t),Array.isArray(r)?[...r]:{...r})}s(or,"combineObjects");function ct([r,...e]){return e.reduce(or,{...r})}s(ct,"buildCombinedDataObject");function pt({clientLogger:r,customFetchApi:e=fetch,client:t=re,defaultRetryWaitTime:n=Le,retriableCodes:i=rr}){let o=s(async(a,u,l)=>{let c=u+1,p=l+1,d;try{if(d=await e(...a),r({type:"HTTP-Response",content:{requestParams:a,response:d}}),!d.ok&&i.includes(d.status)&&c<=p)throw new Error;let m=d?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return m&&r({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:m}}),d}catch(m){if(c<=p){let h=d?.headers.get("Retry-After");return await Un(h?parseInt(h,10):n),r({type:"HTTP-Retry",content:{requestParams:a,lastResponse:d,retryAttempt:u,maxRetries:l}}),o(a,c,l)}throw new Error(H(`${l>0?`Attempted maximum number of ${l} network retries. Last message - `:""}${W(m)}`,t))}},"httpFetch");return o}s(pt,"generateHttpFetch");async function Un(r){return new Promise(e=>setTimeout(e,r))}s(Un,"sleep");function ft({headers:r,url:e,customFetchApi:t=fetch,retries:n=0,logger:i}){$e({client:re,retries:n});let o={headers:r,url:e,retries:n},a=Nn(i),u=pt({customFetchApi:t,clientLogger:a,defaultRetryWaitTime:Le}),l=Gn(u,o),c=Mn(l),p=Xn(l);return{config:o,fetch:l,request:c,requestStream:p}}s(ft,"createGraphQLClient");function Nn(r){return e=>{r&&r(e)}}s(Nn,"generateClientLogger");async function ar(r){let{errors:e,data:t,extensions:n}=await r.json();return{...$("data",t),...$("extensions",n),headers:r.headers,...e||!t?{errors:{networkStatusCode:r.status,message:H(e?et:rt),...$("graphQLErrors",e),response:r}}:{}}}s(ar,"processJSONResponse");function Gn(r,{url:e,headers:t,retries:n}){return async(i,o={})=>{let{variables:a,headers:u,url:l,retries:c,keepalive:p,signal:d}=o,m=JSON.stringify({query:i,variables:a});$e({client:re,retries:c});let h=Object.entries({...t,...u}).reduce((y,[S,O])=>(y[S]=Array.isArray(O)?O.join(", "):O.toString(),y),{});return!h[nt]&&!h[it]&&(h[nt]=er,h[it]=tr),r([l??e,{method:"POST",headers:h,body:m,signal:d,keepalive:p}],1,c??n)}}s(Gn,"generateFetch");function Mn(r){return async(...e)=>{if(st.test(e[0]))throw new Error(H("This operation will result in a streamable response - use requestStream() instead."));let t=null;try{t=await r(...e);let{status:n,statusText:i}=t,o=t.headers.get("content-type")||"";return t.ok?o.includes(Oe.json)?await ar(t):{errors:{networkStatusCode:n,message:H(`${tt} ${o}`),response:t}}:{errors:{networkStatusCode:n,message:H(i),response:t}}}catch(n){return{errors:{message:W(n),...t==null?{}:{networkStatusCode:t.status,response:t}}}}}}s(Mn,"generateRequest");async function*jn(r){let e=new TextDecoder;if(r.body[Symbol.asyncIterator])for await(let t of r.body)yield e.decode(t);else{let t=r.body.getReader(),n;try{for(;!(n=await t.read()).done;)yield e.decode(n.value)}finally{t.cancel()}}}s(jn,"getStreamBodyIterator");function Fn(r,e){return{async*[Symbol.asyncIterator](){try{let t="";for await(let n of r)if(t+=n,t.indexOf(e)>-1){let i=t.lastIndexOf(e),a=t.slice(0,i).split(e).filter(u=>u.trim().length>0).map(u=>u.slice(u.indexOf(ot)+ot.length).trim());a.length>0&&(yield a),t=t.slice(i+e.length),t.trim()==="--"&&(t="")}}catch(t){throw new Error(`Error occured while processing stream payload - ${W(t)}`)}}}}s(Fn,"readStreamChunk");function Hn(r){return{async*[Symbol.asyncIterator](){yield{...await ar(r),hasNext:!1}}}}s(Hn,"createJsonResponseAsyncIterator");function Qn(r){return r.map(e=>{try{return JSON.parse(e)}catch(t){throw new Error(`Error in parsing multipart response - ${W(t)}`)}}).map(e=>{let{data:t,incremental:n,hasNext:i,extensions:o,errors:a}=e;if(!n)return{data:t||{},...$("errors",a),...$("extensions",o),hasNext:i};let u=n.map(({data:l,path:c,errors:p})=>({data:l&&c?lt(c,l):{},...$("errors",p)}));return{data:u.length===1?u[0].data:ct([...u.map(({data:l})=>l)]),...$("errors",ut(u)),hasNext:i}})}s(Qn,"getResponseDataFromChunkBodies");function zn(r,e){if(r.length>0)throw new Error(et,{cause:{graphQLErrors:r}});if(Object.keys(e).length===0)throw new Error(rt)}s(zn,"validateResponseData");function Wn(r,e){let t=(e??"").match(nr),n=`--${t?t[1]:"-"}`;if(!r.body?.getReader&&!r.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:r});let i=jn(r),o={},a;return{async*[Symbol.asyncIterator](){try{let u=!0;for await(let l of Fn(i,n)){let c=Qn(l);a=c.find(d=>d.extensions)?.extensions??a;let p=ut(c);o=ct([o,...c.map(({data:d})=>d)]),u=c.slice(-1)[0].hasNext,zn(p,o),yield{...$("data",o),...$("extensions",a),hasNext:u}}if(u)throw new Error("Response stream terminated unexpectedly")}catch(u){let l=at(u);yield{...$("data",o),...$("extensions",a),errors:{message:H(W(u)),networkStatusCode:r.status,...$("graphQLErrors",l?.graphQLErrors),response:r},hasNext:!1}}}}}s(Wn,"createMultipartResponseAsyncInterator");function Xn(r){return async(...e)=>{if(!st.test(e[0]))throw new Error(H("This operation does not result in a streamable response - use request() instead."));try{let t=await r(...e),{statusText:n}=t;if(!t.ok)throw new Error(n,{cause:t});let i=t.headers.get("content-type")||"";switch(!0){case i.includes(Oe.json):return Hn(t);case i.includes(Oe.multipart):return Wn(t,i);default:throw new Error(`${tt} ${i}`,{cause:t})}}catch(t){return{async*[Symbol.asyncIterator](){let n=at(t);yield{errors:{message:H(W(t)),...$("networkStatusCode",n?.status),...$("response",n)},hasNext:!1}}}}}}s(Xn,"generateRequestStream");function dt({client:r,storeDomain:e}){try{if(!e||typeof e!="string")throw new Error;let t=e.trim(),n=t.match(/^https?:/)?t:`https://${t}`,i=new URL(n);return i.protocol="https",i.origin}catch(t){throw new Error(`${r}: a valid store domain ("${e}") must be provided`,{cause:t})}}s(dt,"validateDomainAndGetStoreUrl");function Be({client:r,currentSupportedApiVersions:e,apiVersion:t,logger:n}){let i=`${r}: the provided apiVersion ("${t}")`,o=`Currently supported API versions: ${e.join(", ")}`;if(!t||typeof t!="string")throw new Error(`${i} is invalid. ${o}`);let a=t.trim();e.includes(a)||(n?n({type:"Unsupported_Api_Version",content:{apiVersion:t,supportedApiVersions:e}}):console.warn(`${i} is likely deprecated or not supported. ${o}`))}s(Be,"validateApiVersion");function qe(r){let e=r*3-2;return e===10?e:`0${e}`}s(qe,"getQuarterMonth");function ht(r,e,t){let n=e-t;return n<=0?`${r-1}-${qe(n+4)}`:`${r}-${qe(n)}`}s(ht,"getPrevousVersion");function ur(){let r=new Date,e=r.getUTCMonth(),t=r.getUTCFullYear(),n=Math.floor(e/3+1);return{year:t,quarter:n,version:`${t}-${qe(n)}`}}s(ur,"getCurrentApiVersion");function yt(){let{year:r,quarter:e,version:t}=ur(),n=e===4?`${r+1}-01`:`${r}-${qe(e+1)}`;return[ht(r,e,3),ht(r,e,2),ht(r,e,1),t,n,"unstable"]}s(yt,"getCurrentSupportedApiVersions");function mt(r){return e=>({...e??{},...r.headers})}s(mt,"generateGetHeaders");function vt({getHeaders:r,getApiUrl:e}){return(t,n)=>{let i=[t];if(n&&Object.keys(n).length>0){let{variables:o,apiVersion:a,headers:u,retries:l,signal:c}=n;i.push({...o?{variables:o}:{},...u?{headers:r(u)}:{},...a?{url:e(a)}:{},...l?{retries:l}:{},...c?{signal:c}:{}})}return i}}s(vt,"generateGetGQLClientParams");var gt="application/json",lr="storefront-api-client",cr="1.0.9",pr="X-Shopify-Storefront-Access-Token",fr="Shopify-Storefront-Private-Token",dr="X-SDK-Variant",hr="X-SDK-Version",yr="X-SDK-Variant-Source",ne="Storefront API Client";function mr(r){if(r&&typeof window<"u")throw new Error(`${ne}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}s(mr,"validatePrivateAccessTokenUsage");function vr(r,e){if(!r&&!e)throw new Error(`${ne}: a public or private access token must be provided`);if(r&&e)throw new Error(`${ne}: only provide either a public or private access token`)}s(vr,"validateRequiredAccessTokens");function It({storeDomain:r,apiVersion:e,publicAccessToken:t,privateAccessToken:n,clientName:i,retries:o=0,customFetchApi:a,logger:u}){let l=yt(),c=dt({client:ne,storeDomain:r}),p={client:ne,currentSupportedApiVersions:l,logger:u};Be({...p,apiVersion:e}),vr(t,n),mr(n);let d=Kn(c,e,p),m={storeDomain:c,apiVersion:e,...t?{publicAccessToken:t}:{privateAccessToken:n},headers:{"Content-Type":gt,Accept:gt,[dr]:lr,[hr]:cr,...i?{[yr]:i}:{},...t?{[pr]:t}:{[fr]:n}},apiUrl:d(),clientName:i},h=ft({headers:m.headers,url:m.apiUrl,retries:o,customFetchApi:a,logger:u}),D=mt(m),y=Yn(m,d),S=vt({getHeaders:D,getApiUrl:y});return Object.freeze({config:m,getHeaders:D,getApiUrl:y,fetch:s((...k)=>h.fetch(...S(...k)),"fetch"),request:s((...k)=>h.request(...S(...k)),"request"),requestStream:s((...k)=>h.requestStream(...S(...k)),"requestStream")})}s(It,"createStorefrontApiClient");function Kn(r,e,t){return n=>{n&&Be({...t,apiVersion:n});let i=(n??e).trim();return`${r}/api/${i}/graphql.json`}}s(Kn,"generateApiUrlFormatter");function Yn(r,e){return t=>t?e(t):r.apiUrl}s(Yn,"generateGetApiUrl");var q=`
7
+ `+String(r)));Tt(e);for(var i=0;i<e.callbacks.length;i++){var o=r[i];o instanceof Error?e.callbacks[i].reject(o):e.callbacks[i].resolve(o)}}).catch(function(r){Dt(n,e,r)})}s(zi,"dispatchBatch");function Dt(n,e,t){Tt(e);for(var r=0;r<e.keys.length;r++)n.clear(e.keys[r]),e.callbacks[r].reject(t)}s(Dt,"failedDispatch");function Tt(n){if(n.cacheHits)for(var e=0;e<n.cacheHits.length;e++)n.cacheHits[e]()}s(Tt,"resolveCacheHits");function Wi(n){var e=!n||n.batch!==!1;if(!e)return 1;var t=n&&n.maxBatchSize;if(t===void 0)return 1/0;if(typeof t!="number"||t<1)throw new TypeError("maxBatchSize must be a positive number: "+t);return t}s(Wi,"getValidMaxBatchSize");function Xi(n){var e=n&&n.batchScheduleFn;if(e===void 0)return Hi;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}s(Xi,"getValidBatchScheduleFn");function Ki(n){var e=n&&n.cacheKeyFn;if(e===void 0)return function(t){return t};if(typeof e!="function")throw new TypeError("cacheKeyFn must be a function: "+e);return e}s(Ki,"getValidCacheKeyFn");function Yi(n){var e=!n||n.cache!==!1;if(!e)return null;var t=n&&n.cacheMap;if(t===void 0)return new Map;if(t!==null){var r=["get","set","delete","clear"],i=r.filter(function(o){return t&&typeof t[o]!="function"});if(i.length!==0)throw new TypeError("Custom cacheMap missing methods: "+i.join(", "))}return t}s(Yi,"getValidCacheMap");function Ji(n){return n&&n.name?n.name:null}s(Ji,"getValidName");function er(n){return typeof n=="object"&&n!==null&&typeof n.length=="number"&&(n.length===0||n.length>0&&Object.prototype.hasOwnProperty.call(n,n.length-1))}s(er,"isArrayLike");tr.exports=Fi});var R=s(n=>n.split("/").pop()??"","shopifyGidToId"),b=s((n,e)=>`gid://shopify/${n}/${e}`,"shopifyIdToGid");var Q=class{constructor(e,t,r=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.clearCachePromise=null;this.cacheName=e,this.defaultCacheControl=t,this.keyPrefix=r}static{s(this,"FetchCache")}async get(e){try{let t=await caches.open(this.cacheName),r=await t.match(e);if(r&&this.isExpired(r)){await t.delete(e);return}return r}catch(t){console.warn("Cache get error:",t);return}}async set(e,t,r){try{if(r?.includes("no-cache"))return;let i=this.createCacheableResponse(t,r);await(await caches.open(this.cacheName)).put(e,i)}catch(i){console.warn("Cache set error:",i)}}async fetchWithCache(e,t,r){let i=await this.getCacheKey(e,t);if(this.clearCachePromise&&await this.clearCachePromise,this.inFlightRequests.has(i))return this.inFlightRequests.get(i).then(u=>u.clone());let o=(async()=>{let u=await this.get(i);if(u)return this.isStaleButRevalidatable(u)&&this.revalidateInBackground(i,e,t,r),u.clone();let a=await fetch(e,t);return a.ok&&await this.set(i,a.clone(),r??this.defaultCacheControl),a})().finally(()=>{this.inFlightRequests.delete(i)});return this.inFlightRequests.set(i,o),o}async delete(e){try{return await(await caches.open(this.cacheName)).delete(e)}catch(t){return console.warn("Cache delete error:",t),!1}}async clear(){return this.clearCachePromise?this.clearCachePromise:(this.clearCachePromise=new Promise(async(e,t)=>{try{let r=await caches.open(this.cacheName),i=await r.keys();await Promise.all(i.map(o=>r.delete(o))),e()}catch(r){console.warn("Cache clear error:",r),t(r)}}),this.clearCachePromise.then(()=>{this.clearCachePromise=null}).catch(e=>{console.warn("Cache clear error:",e)}))}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(r=>r.url)}catch(e){return console.warn("Cache keys error:",e),[]}}async has(e){try{let t=await caches.open(this.cacheName),r=await t.match(e);return r&&this.isExpired(r)?(await t.delete(e),!1):r!==void 0}catch(t){return console.warn("Cache has error:",t),!1}}async getStats(){try{return{total:(await(await caches.open(this.cacheName)).keys()).length}}catch(e){return console.warn("Cache stats error:",e),{total:0}}}async cleanupExpiredEntries(){try{let e=await caches.open(this.cacheName),t=await e.keys(),r=0;for(let o of t){let u=await e.match(o);u&&this.isExpired(u)&&(await e.delete(o),r++)}let i=t.length-r;return{removed:r,remaining:i}}catch(e){return console.warn("Cache cleanup error:",e),{removed:0,remaining:0}}}async getCacheKey(e,t){let r=this.getInputUrl(e),i=`${this.keyPrefix}${r}/${JSON.stringify(t)}`,u=new TextEncoder().encode(i),a=await crypto.subtle.digest("SHA-256",u);return`/${Array.from(new Uint8Array(a)).map(p=>p.toString(16).padStart(2,"0")).join("")}`}getInputUrl(e){return e instanceof URL?e.toString():typeof e=="string"?e:e.url}isExpired(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let r=this.parseMaxAge(t),i=this.parseStaleWhileRevalidate(t);if(r===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let u=new Date(o).getTime(),l=(Date.now()-u)/1e3,c=r+(i??0);return l>c}isStaleButRevalidatable(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let r=this.parseMaxAge(t),i=this.parseStaleWhileRevalidate(t);if(r===null||i===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let u=new Date(o).getTime(),l=(Date.now()-u)/1e3;return l>r&&l<=r+i}async revalidateInBackground(e,t,r,i){if(this.revalidationPromises.has(e))return;let o=(async()=>{try{let u=await fetch(t,r);u.ok&&await this.set(e,u.clone(),i??this.defaultCacheControl)}catch(u){console.warn("Background revalidation error:",u)}finally{this.revalidationPromises.delete(e)}})();this.revalidationPromises.set(e,o)}parseMaxAge(e){let t=new RegExp(/max-age=(\d+)/).exec(e);return t?parseInt(t[1],10):null}parseStaleWhileRevalidate(e){let t=new RegExp(/stale-while-revalidate=(\d+)/).exec(e);return t?parseInt(t[1],10):null}createCacheableResponse(e,t){let r=new Headers(e.headers);return r.set("Cache-Control",t),r.has("Date")||r.set("Date",new Date().toUTCString()),new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})}};var he=class{static{s(this,"AjaxApiClient")}constructor(e){this.config=e,this.cache=new Q("ajax-api","max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(t=>{console.warn("Ajax API cache initialization cleanup error:",t)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let e=window.fetch,t=this.config.responseInterceptor,r=this.getFetchRequest.bind(this);window.fetch=function(...i){let o=e.apply(this,i);if(typeof t=="function"){let u=r(i[0]);o.then(a=>t(a,u))}return o}}getFetchRequest(e){return e instanceof Request?e:new Request(e)}getBaseUrl(){if(!this.config?.storeDomain)throw new Error("Cart API client not initialized - missing store domain");return`https://${this.config.storeDomain}`}fetch(e,t){return(e instanceof Request?e.method:t?.method??"GET")==="GET"?this.cache.fetchWithCache(e,t):fetch(e,t)}async request(e,t={}){let r=`${this.getBaseUrl()}${e}`,i={"Content-Type":"application/json",Accept:"application/json"},o=await this.fetch(r,{...t,headers:{...i,...t.headers}});if(!o.ok){let u;try{u=await o.json()}catch{u={message:`HTTP ${o.status}: ${o.statusText}`,status:o.status.toString(),description:o.statusText}}throw new Error(u.message||u.description)}return o.json()}async fetchCart(){return this.request("/cart.js")}async addToCart(e){let t={...e,items:e.items.map(r=>{let i=R(r.id);if(!i)throw new Error(`Invalid Shopify GID format: ${r.id}`);let o=parseInt(i,10);if(isNaN(o))throw new Error(`Invalid numeric ID extracted from GID: ${r.id}`);return{...r,id:o}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(t)})}async clearCache(){await this.cache.clear()}};var ye=class{constructor(e){this.eventMap={"/cart/add":"cart-add","/cart/update":"cart-update","/cart/change":"cart-change","/cart/clear":"cart-clear"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{s(this,"AjaxApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.url);if(r){let i=await e.clone().json();this.eventBus.publish(r,i)}}catch(r){console.warn(r)}}getEventName(e){for(let[t,r]of Object.entries(this.eventMap))if(e.includes(t))return r;return null}};function yr(){let n=document.body||document.documentElement;return n?Promise.resolve(n):new Promise(e=>{window.addEventListener("DOMContentLoaded",()=>e(n))})}s(yr,"waitForDOM");function ce({onElementFound:n,selector:e,observerOptions:t}){let r=new WeakSet,i=new MutationObserver(l=>{let c=!1;for(let p of l)if(p.addedNodes.length>0){c=!0;break}c&&o()}),o=s(()=>{document.querySelectorAll(e).forEach(l=>{r.has(l)||(u(l),r.add(l))})},"locateElements"),u=s(l=>{if(!t){n(l);return}let c=new IntersectionObserver(p=>{for(let f of p)f.isIntersecting&&(c.disconnect(),n(l))},t);c.observe(l)},"observeElement");return s(async()=>{let l=await yr();o(),i.observe(l,{childList:!0,subtree:!0})},"locateAndObserveElements")(),i}s(ce,"createElementLocator");function se({onLocationChange:n,fireOnInit:e=!1}){let t=s(()=>{n(window.location)},"handleChange");window.addEventListener("popstate",t);let r=history.pushState,i=history.replaceState;return history.pushState=function(...o){r.apply(this,o),t()},history.replaceState=function(...o){i.apply(this,o),t()},e&&t(),()=>{window.removeEventListener("popstate",t),history.pushState=r,history.replaceState=i}}s(se,"createLocationObserver");function Vt({element:n,onHrefChange:e}){let t=s(()=>{e(n.href)},"handleChange"),r=new MutationObserver(()=>{t()});return r.observe(n,{attributes:!0,attributeFilter:["href"]}),()=>{r.disconnect()}}s(Vt,"createHrefObserver");var me=class{constructor(){this.eventBus=new EventTarget}static{s(this,"EventBus")}subscribe(e,t,r){return Array.isArray(e)||(e=[e]),e.forEach(i=>{this.eventBus.addEventListener(i,t,r)}),()=>{e.forEach(i=>{this.eventBus.removeEventListener(i,t,r)})}}unsubscribe(e,t,r){this.eventBus.removeEventListener(e,t,r)}publish(e,t){this.eventBus.dispatchEvent(new CustomEvent(e,{detail:t}))}};var ze;function Nt(n){return{lang:n?.lang??ze?.lang,message:n?.message,abortEarly:n?.abortEarly??ze?.abortEarly,abortPipeEarly:n?.abortPipeEarly??ze?.abortPipeEarly}}s(Nt,"getGlobalConfig");var mr;function vr(n){return mr?.get(n)}s(vr,"getGlobalMessage");var gr;function Ir(n){return gr?.get(n)}s(Ir,"getSchemaMessage");var wr;function br(n,e){return wr?.get(n)?.get(e)}s(br,"getSpecificMessage");function We(n){let e=typeof n;return e==="string"?`"${n}"`:e==="number"||e==="bigint"||e==="boolean"?`${n}`:e==="object"||e==="function"?(n&&Object.getPrototypeOf(n)?.constructor?.name)??"null":e}s(We,"_stringify");function X(n,e,t,r,i){let o=i&&"input"in i?i.input:t.value,u=i?.expected??n.expects??null,a=i?.received??We(o),l={kind:n.kind,type:n.type,input:o,expected:u,received:a,message:`Invalid ${e}: ${u?`Expected ${u} but r`:"R"}eceived ${a}`,requirement:n.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=n.kind==="schema",p=i?.message??n.message??br(n.reference,l.lang)??(c?Ir(l.lang):null)??r.message??vr(l.lang);p!==void 0&&(l.message=typeof p=="function"?p(l):p),c&&(t.typed=!1),t.issues?t.issues.push(l):t.issues=[l]}s(X,"_addIssue");function Z(n){return{version:1,vendor:"valibot",validate(e){return n["~run"]({value:e},Nt())}}}s(Z,"_getStandardProps");function Er(n,e){let t=[...new Set(n)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}s(Er,"_joinExpects");function Xe(n,e){return{kind:"validation",type:"min_value",reference:Xe,async:!1,expects:`>=${n instanceof Date?n.toJSON():We(n)}`,requirement:n,message:e,"~run"(t,r){return t.typed&&!(t.value>=this.requirement)&&X(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():We(t.value)}),t}}}s(Xe,"minValue");function j(n){return{kind:"transformation",type:"transform",reference:j,async:!1,operation:n,"~run"(e){return e.value=this.operation(e.value),e}}}s(j,"transform");function Sr(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}s(Sr,"getFallback");function Gt(n,e,t){return typeof n.default=="function"?n.default(e,t):n.default}s(Gt,"getDefault");function Ke(n,e){return{kind:"schema",type:"array",reference:Ke,expects:"Array",async:!1,item:n,message:e,get"~standard"(){return Z(this)},"~run"(t,r){let i=t.value;if(Array.isArray(i)){t.typed=!0,t.value=[];for(let o=0;o<i.length;o++){let u=i[o],a=this.item["~run"]({value:u},r);if(a.issues){let l={type:"array",origin:"value",input:i,key:o,value:u};for(let c of a.issues)c.path?c.path.unshift(l):c.path=[l],t.issues?.push(c);if(t.issues||(t.issues=a.issues),r.abortEarly){t.typed=!1;break}}a.typed||(t.typed=!1),t.value.push(a.value)}}else X(this,"type",t,r);return t}}}s(Ke,"array");function U(n){return{kind:"schema",type:"number",reference:U,expects:"number",async:!1,message:n,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:X(this,"type",e,t),e}}}s(U,"number");function A(n,e){return{kind:"schema",type:"object",reference:A,expects:"Object",async:!1,entries:n,message:e,get"~standard"(){return Z(this)},"~run"(t,r){let i=t.value;if(i&&typeof i=="object"){t.typed=!0,t.value={};for(let o in this.entries){let u=this.entries[o];if(o in i||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){let a=o in i?i[o]:Gt(u),l=u["~run"]({value:a},r);if(l.issues){let c={type:"object",origin:"value",input:i,key:o,value:a};for(let p of l.issues)p.path?p.path.unshift(c):p.path=[c],t.issues?.push(p);if(t.issues||(t.issues=l.issues),r.abortEarly){t.typed=!1;break}}l.typed||(t.typed=!1),t.value[o]=l.value}else if(u.fallback!==void 0)t.value[o]=Sr(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(X(this,"key",t,r,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:i,key:o,value:i[o]}]}),r.abortEarly))break}}else X(this,"type",t,r);return t}}}s(A,"object");function N(n,e){return{kind:"schema",type:"optional",reference:N,expects:`(${n.expects} | undefined)`,async:!1,wrapped:n,default:e,get"~standard"(){return Z(this)},"~run"(t,r){return t.value===void 0&&(this.default!==void 0&&(t.value=Gt(this,t,r)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,r)}}}s(N,"optional");function E(n){return{kind:"schema",type:"string",reference:E,expects:"string",async:!1,message:n,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:X(this,"type",e,t),e}}}s(E,"string");function Ut(n){let e;if(n)for(let t of n)e?e.push(...t.issues):e=t.issues;return e}s(Ut,"_subIssues");function ee(n,e){return{kind:"schema",type:"union",reference:ee,expects:Er(n.map(t=>t.expects),"|"),async:!1,options:n,message:e,get"~standard"(){return Z(this)},"~run"(t,r){let i,o,u;for(let a of this.options){let l=a["~run"]({value:t.value},r);if(l.typed)if(l.issues)o?o.push(l):o=[l];else{i=l;break}else u?u.push(l):u=[l]}if(i)return i;if(o){if(o.length===1)return o[0];X(this,"type",t,r,{issues:Ut(o)}),t.typed=!0}else{if(u?.length===1)return u[0];X(this,"type",t,r,{issues:Ut(u)})}return t}}}s(ee,"union");function G(...n){return{...n[0],pipe:n,get"~standard"(){return Z(this)},"~run"(e,t){for(let r of n)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r["~run"](e,t))}return e}}}s(G,"pipe");function _(n,e,t){let r=n["~run"]({value:e},Nt(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}s(_,"safeParse");var S=class{constructor(e,t,r,i){this.swish=e;this.ui=t;this.eventBus=r;this.options=i}static{s(this,"IntentHandler")}};var Cr=A({itemId:N(G(E())),productId:G(ee([G(E(),j(R)),U()]),j(n=>Number(n)),U()),variantId:N(G(ee([G(E(),j(R)),U()]),j(n=>Number(n)),U()))}),oe=class extends S{static{s(this,"EditItemVariantHandler")}async invoke(e,t=!1){return new Promise(r=>{let i=e.data,o=_(Cr,i);if(!o.success){r({code:"error",message:"Invalid intent data",issues:o.issues.map(c=>c.message)});return}let{itemId:u,productId:a,variantId:l}=o.output;this.ui.showVariantSelect({productId:a.toString(),variantId:l?.toString(),onClose:s(()=>{r({code:"closed"})},"onClose"),onSubmit:s(async c=>{let{item:p,product:f,variant:m}=c,h={code:"ok",data:{item:p,product:f,variant:m}};t||this.eventBus.dispatchEvent(new CustomEvent("edit:swish/ItemVariant",{detail:h})),r(h)},"onSubmit")})})}};var xr=A({productId:G(ee([G(E(),j(R)),U()]),j(n=>Number(n)),U()),variantId:N(G(ee([G(E(),j(R)),U()]),j(Number),U())),quantity:N(G(U(),Xe(1))),tags:N(Ke(E()))}),ve=class extends S{static{s(this,"CreateItemHandler")}async invoke(e){let t=e.data,r=_(xr,t);if(!r.success)return{code:"error",message:"Invalid intent data",issues:r.issues.map(m=>m.message)};let{productId:i,variantId:o,quantity:u,tags:a}=r.output,l=await this.swish.storefront.loadSaveIntentData({productId:b("Product",i),variantId:o?b("ProductVariant",o):void 0});if(l.errors)return{code:"error",message:l.errors.message??"Failed to load save intent data",issues:l.errors.graphQLErrors?.map(m=>m.message)??[]};if(!l.data||!l.data.product)return{code:"error",message:"Failed to load save intent data",issues:["API response missing data"]};let{product:c}=l.data,p=c.variantsCount?.count&&c.variantsCount.count>1;if(!p||!this.options.save.requireVariant){let m=s(()=>!p&&c.selectedOrFirstAvailableVariant?Number(R(c.selectedOrFirstAvailableVariant.id)):o,"variantIdToUse"),h=await this.swish.api.items.create({productId:i,variantId:m(),quantity:u,tags:a});if("error"in h)return{code:"error",message:"Failed to create item",issues:[h.error.message]};if(!h.data)return{code:"error",message:"Could not complete item creation",issues:["API response missing data"]};let D="variant"in l.data?l.data.variant:void 0,y={code:"ok",data:{item:h.data,product:c,variant:p?D:c.selectedOrFirstAvailableVariant}};return this.eventBus.dispatchEvent(new CustomEvent("create:swish/Item",{detail:y})),y}let f=await new oe(this.swish,this.ui,this.eventBus,this.options).invoke({action:"edit",type:"swish/ItemVariant",data:{productId:i,variantId:o}});return this.eventBus.dispatchEvent(new CustomEvent("create:swish/Item",{detail:f})),f}};var ge=class extends S{static{s(this,"CreateListHandler")}async invoke(e){return new Promise(t=>{this.ui.showListEditor({onClose:s(()=>{t({code:"closed"})},"onClose"),onSubmit:s(async r=>{let{list:i}=r;t({code:"ok",data:{list:i}})},"onSubmit")})})}};var Ar=A({itemId:E()}),Ie=class extends S{static{s(this,"DeleteItemHandler")}async invoke(e){return new Promise(async t=>{let r=_(Ar,e.data);if(!r.success){t({code:"error",message:"Invalid intent data",issues:r.issues.map(o=>o.message)});return}let{itemId:i}=r.output;if(!this.options.unsave.requireConfirmation){let o=await this.swish.api.items.deleteById(i);if("error"in o){t({code:"error",message:"Failed to delete item",issues:[o.error.message]});return}t({code:"ok",data:{itemId:i}});return}this.ui.showUnsaveAlert({itemId:i,onClose:s(()=>{t({code:"closed"})},"onClose"),onSubmit:s(()=>{t({code:"ok",data:{itemId:i}})},"onSubmit")})})}};var kr=A({listId:E()}),we=class extends S{static{s(this,"DeleteListHandler")}async invoke(e){return new Promise(t=>{let r=e.data,i=_(kr,r);if(!i.success){t({code:"error",message:"Invalid intent data",issues:i.issues.map(u=>u.message)});return}let{listId:o}=i.output;this.ui.showDeleteListAlert({listId:o,onClose:s(()=>{t({code:"closed"})},"onClose"),onSubmit:s(async()=>{t({code:"ok",data:{listId:o}})},"onSubmit")})})}};var Rr=A({itemId:E()}),be=class extends S{static{s(this,"EditItemListsHandler")}async invoke(e,t=!1){return new Promise(r=>{let i=e.data,o=_(Rr,i);if(!o.success){r({code:"error",message:"Invalid intent data",issues:o.issues.map(a=>a.message)});return}let{itemId:u}=o.output;this.ui.showListSelect({itemId:u,onClose:s(()=>{r({code:"closed"})},"onClose"),onSubmit:s(async a=>{let{item:l,product:c,variant:p}=a,f={code:"ok",data:{item:l,product:c,variant:p}};t||this.eventBus.dispatchEvent(new CustomEvent("edit:swish/ItemLists",{detail:f})),r(f)},"onSubmit"),onUnsave(a){let l={code:"ok",data:{itemId:a.itemId}};r(l)}})})}};var Dr=A({listId:E()}),Ee=class extends S{static{s(this,"EditListHandler")}async invoke(e){return new Promise(t=>{let r=e.data,i=_(Dr,r);if(!i.success){t({code:"error",message:"Invalid intent data",issues:i.issues.map(u=>u.message)});return}let{listId:o}=i.output;this.ui.showListEditor({listId:o,onClose:s(()=>{t({code:"closed"})},"onClose"),onSubmit:s(async u=>{let{list:a}=u;t({code:"ok",data:{list:a}})},"onSubmit")})})}};var Se=class extends S{static{s(this,"OpenHomeHandler")}async invoke(e){return new Promise(t=>{this.ui.showDrawer({onClose:s(()=>{t({code:"closed"})},"onClose")})})}};var Tr=A({listId:E()}),Ce=class extends S{static{s(this,"OpenListMenuHandler")}async invoke(e){return new Promise(t=>{let r=e.data,i=_(Tr,r);if(!i.success){t({code:"error",message:"Invalid intent data",issues:i.issues.map(u=>u.message)});return}let{listId:o}=i.output;this.ui.showListMenu({listId:o,onClose:s(()=>{t({code:"closed"})},"onClose"),onEdit:s(u=>{t({code:"ok",data:u})},"onEdit"),onDelete:s(()=>{t({code:"ok",data:{listId:o}})},"onDelete")})})}};var Zs=A({returnTo:N(E())}),xe=class extends S{static{s(this,"OpenSignInHandler")}async invoke(e){return new Promise(t=>{this.ui.showSignIn({returnTo:e.data?.returnTo,onClose:s(()=>{t({code:"closed"})},"onClose")})})}};var Pr=A({productId:E(),variantId:N(E())}),Ae=class extends S{static{s(this,"OpenQuickBuyHandler")}async invoke(e){return new Promise(t=>{let r=_(Pr,e.data);if(!r.success){t({code:"error",message:"Invalid intent data",issues:r.issues.map(u=>u.message)});return}let{productId:i,variantId:o}=r.output;this.ui.showQuickBuy({productId:i,variantId:o,onClose:s(()=>{t({code:"closed"})},"onClose"),onSubmit:s(u=>{t({code:"ok",data:u})},"onSubmit")})})}};var ae=class{constructor(e,t,r){this.swish=e;this.ui=t;this.options=r}static{s(this,"IntentHook")}};var ke=class extends ae{static{s(this,"AfterCreateItemHook")}async invoke(e){if(this.options.save.showToast&&e.code==="ok"){let{item:t,product:r,variant:i}=e.data;r&&this.ui.showToast({title:"Saved",text:r.title,image:i?.image?.url??r.featuredImage?.url,action:{label:"Add to List",onClick:s(()=>{this.swish.intents.invoke({action:"edit",type:"swish/ItemLists",data:{itemId:t.id}})},"onClick")}})}}};var Re=class extends ae{static{s(this,"AfterEditItemListsHook")}async invoke(e){if(this.options.edit.showToast&&e.code==="ok"){if("itemId"in e.data)return;let{product:t,variant:r}=e.data;t&&this.ui.showToast({title:"Saved",text:t.title,image:r?.image?.url??t.featuredImage?.url,action:{label:"View",onClick:s(()=>{this.swish.intents.invoke({action:"open",type:"swish/Home"})},"onClick")}})}}};var De=class{static{s(this,"Intents")}constructor(e,t){this.swish=e,this.ui=t,this.eventBus=new EventTarget,this.options=e.options.swishUi.intents,this.initIntentHooks(),this.initIntentWatcher()}publishAnalyticsEvent(e,t){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(e,t)}async invoke(e){let t=this.parseIntent(e),r=this.getIntentQuery(t),i={lifecycle:"before",intent:t};return this.publishAnalyticsEvent("swish-intent",i),this.publishAnalyticsEvent(`swish-intent=${r}`,i),{intent:t,complete:this.handleIntent(t).then(o=>{let u={lifecycle:"after",intent:t,response:o};return this.publishAnalyticsEvent("swish-intent",u),this.publishAnalyticsEvent(`swish-intent=${r}`,u),o})}}listen(e,t){let r=this.getIntentQuery(e),i=s(u=>{"detail"in u&&u.detail?t(u.detail):console.warn("Intent response event without detail",u)},"eventListener"),o=s(()=>{this.eventBus.removeEventListener(r,i)},"unsubscribe");return this.eventBus.addEventListener(r,i),o}getIntentQuery(e){return`${e.action}:${e.type}`}parseIntent(e){if(typeof e=="string"){let[t,...r]=e.split(","),[i,o]=t.split(":"),u=r.reduce((a,l)=>{let[c,p]=l.split("=");return a[c]=p,a},{});return{action:i,type:o,data:u}}return e}async handleIntent(e){return e.action==="create"&&e.type==="swish/Item"?new ve(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="delete"&&e.type==="swish/Item"?new Ie(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="edit"&&e.type==="swish/ItemVariant"?new oe(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="edit"&&e.type==="swish/ItemLists"?new be(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="create"&&e.type==="swish/List"?new ge(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="edit"&&e.type==="swish/List"?new Ee(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="delete"&&e.type==="swish/List"?new we(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/Home"?new Se(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/ListMenu"?new Ce(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/SignIn"?new xe(this.swish,this.ui,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/QuickBuy"?new Ae(this.swish,this.ui,this.eventBus,this.options).invoke(e):{code:"error",message:"Invalid intent",issues:["Invalid intent"]}}initIntentHooks(){this.eventBus.addEventListener("create:swish/Item",e=>{new ke(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:swish/ItemLists",e=>{new Re(this.swish,this.ui,this.options).invoke(e.detail)})}initIntentWatcher(){ce({selector:"[swish-intent]",onElementFound:s(e=>{let t=this.parseIntent(e.getAttribute("swish-intent"));t&&e.addEventListener("click",()=>{this.invoke(t)})},"onElementFound")}),ce({selector:"a[href*='swish-intent=']",onElementFound:s(e=>{e instanceof HTMLAnchorElement&&e.addEventListener("click",t=>{if(!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey){let i=new URL(e.href).searchParams.get("swish-intent");if(i){let o=this.parseIntent(i);o&&(t.preventDefault(),t.stopPropagation(),this.invoke(o))}}})},"onElementFound")}),se({fireOnInit:!0,onLocationChange:s(e=>{let t=new URLSearchParams(window.location.search).get("swish-intent");if(t){let r=this.parseIntent(t);if(r){this.invoke(r);let i=new URL(window.location.href);i.searchParams.delete("swish-intent"),window.history.replaceState({},document.title,i.toString())}}},"onLocationChange")})}};var Mt=s(n=>({storefrontApi:{storeDomain:n.storefrontApi?.storeDomain??"",accessToken:n.storefrontApi?.accessToken??""},storefrontContext:{...n.storefrontContext,localization:{country:n.storefrontContext.localization.country.toUpperCase(),language:n.storefrontContext.localization.language.toUpperCase(),market:n.storefrontContext.localization.market}},badges:{getBadges:n.badges?.getBadges??(({defaultBadges:e})=>e)},metafields:{product:n.metafields?.product??[],productVariant:n.metafields?.productVariant??[]},swishApi:{authProxy:n.swishApi?.authProxy??"/apps/wishlist/api",version:n.swishApi?.version??"2026-01"},swishUi:{baseUrl:n.swishUi?.baseUrl??"https://swish.app/cdn",version:n.swishUi?.version??"0.73.0",components:{productRow:{showVariantTitle:n.swishUi?.components?.productRow?.showVariantTitle??!1},productDetail:{descriptionMaxLines:n.swishUi?.components?.productDetail?.descriptionMaxLines??4},variantSelect:{displayType:n.swishUi?.components?.variantSelect?.displayType??"pills"},imageSlider:{flush:n.swishUi?.components?.imageSlider?.flush??!1,loop:n.swishUi?.components?.imageSlider?.loop??!1},images:{baseTint:n.swishUi?.components?.images?.baseTint??!1},buyButtons:{shopPay:n.swishUi?.components?.buyButtons?.shopPay??!1},listDetailPage:{desktopColumns:n.swishUi?.components?.listDetailPage?.desktopColumns??4,showBuyButton:n.swishUi?.components?.listDetailPage?.showBuyButton??!0},drawer:{title:n.swishUi?.components?.drawer?.title??"",logo:{url:n.swishUi?.components?.drawer?.logo?.url??"",altText:n.swishUi?.components?.drawer?.logo?.altText??""},navigation:{variant:n.swishUi?.components?.drawer?.navigation?.variant??"floating",items:n.swishUi?.components?.drawer?.navigation?.items??[{id:"home",enabled:!0,href:"/"},{id:"items",enabled:!0,href:"/items"},{id:"lists",enabled:!0,href:"/lists"},{id:"chat",enabled:!1,href:"/chat"},{id:"orders",enabled:!0,href:"/orders"},{id:"profile",enabled:!0,href:"/profile"}]},miniMenu:{items:n.swishUi?.components?.drawer?.miniMenu?.items??[]}}},css:n.swishUi?.css??[],intents:{save:{requireVariant:n.swishUi?.intents?.save?.requireVariant??!1,showToast:n.swishUi?.intents?.save?.showToast??!1},edit:{showToast:n.swishUi?.intents?.edit?.showToast??!1},unsave:{requireConfirmation:n.swishUi?.intents?.unsave?.requireConfirmation??!1,openEditor:n.swishUi?.intents?.unsave?.openEditor??!1,showToast:n.swishUi?.intents?.unsave?.showToast??!1}},theme:n.swishUi?.theme??{}}}),"createSwishOptions");var _r=Symbol.for("preact-signals");function Pe(){if(K>1)K--;else{for(var n,e=!1;pe!==void 0;){var t=pe;for(pe=void 0,Ye++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&Ht(t))try{t.c()}catch(i){e||(n=i,e=!0)}t=r}}if(Ye=0,K--,e)throw n}}s(Pe,"t");function Y(n){if(K>0)return n();K++;try{return n()}finally{Pe()}}s(Y,"r");var g=void 0;function jt(n){var e=g;g=void 0;try{return n()}finally{g=e}}s(jt,"n");var pe=void 0,K=0,Ye=0,Te=0;function Ft(n){if(g!==void 0){var e=n.n;if(e===void 0||e.t!==g)return e={i:0,S:n,p:g.s,n:void 0,t:g,e:void 0,x:void 0,r:e},g.s!==void 0&&(g.s.n=e),g.s=e,n.n=e,32&g.f&&n.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=g.s,e.n=void 0,g.s.n=e,g.s=e),e}}s(Ft,"e");function L(n,e){this.v=n,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}s(L,"u");L.prototype.brand=_r;L.prototype.h=function(){return!0};L.prototype.S=function(n){var e=this,t=this.t;t!==n&&n.e===void 0&&(n.x=t,this.t=n,t!==void 0?t.e=n:jt(function(){var r;(r=e.W)==null||r.call(e)}))};L.prototype.U=function(n){var e=this;if(this.t!==void 0){var t=n.e,r=n.x;t!==void 0&&(t.x=r,n.e=void 0),r!==void 0&&(r.e=t,n.x=void 0),n===this.t&&(this.t=r,r===void 0&&jt(function(){var i;(i=e.Z)==null||i.call(e)}))}};L.prototype.subscribe=function(n){var e=this;return V(function(){var t=e.value,r=g;g=void 0;try{n(t)}finally{g=r}},{name:"sub"})};L.prototype.valueOf=function(){return this.value};L.prototype.toString=function(){return this.value+""};L.prototype.toJSON=function(){return this.value};L.prototype.peek=function(){var n=g;g=void 0;try{return this.value}finally{g=n}};Object.defineProperty(L.prototype,"value",{get:s(function(){var n=Ft(this);return n!==void 0&&(n.i=this.i),this.v},"get"),set:s(function(n){if(n!==this.v){if(Ye>100)throw new Error("Cycle detected");this.v=n,this.i++,Te++,K++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Pe()}}},"set")});function C(n,e){return new L(n,e)}s(C,"d");function Ht(n){for(var e=n.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}s(Ht,"c");function Qt(n){for(var e=n.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){n.s=e;break}}}s(Qt,"a");function zt(n){for(var e=n.s,t=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}n.s=t}s(zt,"l");function te(n,e){L.call(this,void 0),this.x=n,this.s=void 0,this.g=Te-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}s(te,"y");te.prototype=new L;te.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Te))return!0;if(this.g=Te,this.f|=1,this.i>0&&!Ht(this))return this.f&=-2,!0;var n=g;try{Qt(this),g=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return g=n,zt(this),this.f&=-2,!0};te.prototype.S=function(n){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}L.prototype.S.call(this,n)};te.prototype.U=function(n){if(this.t!==void 0&&(L.prototype.U.call(this,n),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};te.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var n=this.t;n!==void 0;n=n.x)n.t.N()}};Object.defineProperty(te.prototype,"value",{get:s(function(){if(1&this.f)throw new Error("Cycle detected");var n=Ft(this);if(this.h(),n!==void 0&&(n.i=this.i),16&this.f)throw this.v;return this.v},"get")});function q(n,e){return new te(n,e)}s(q,"w");function Wt(n){var e=n.u;if(n.u=void 0,typeof e=="function"){K++;var t=g;g=void 0;try{e()}catch(r){throw n.f&=-2,n.f|=8,Je(n),r}finally{g=t,Pe()}}}s(Wt,"_");function Je(n){for(var e=n.s;e!==void 0;e=e.n)e.S.U(e);n.x=void 0,n.s=void 0,Wt(n)}s(Je,"b");function Or(n){if(g!==this)throw new Error("Out-of-order effect");zt(this),g=n,this.f&=-2,8&this.f&&Je(this),Pe()}s(Or,"g");function ue(n,e){this.x=n,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}s(ue,"p");ue.prototype.c=function(){var n=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{n()}};ue.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Wt(this),Qt(this),K++;var n=g;return g=this,Or.bind(this,n)};ue.prototype.N=function(){2&this.f||(this.f|=2,this.o=pe,pe=this)};ue.prototype.d=function(){this.f|=8,1&this.f||Je(this)};ue.prototype.dispose=function(){this.d()};function V(n,e){var t=new ue(n,e);try{t.c()}catch(i){throw t.d(),i}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}s(V,"E");var Lr=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,Ze=s(n=>{let e=n.match(Lr);return e?{productHandle:e[1],variantId:e[2]}:null},"parseProductUrl"),Xt=s(({source:n,onProductUrlChange:e})=>{let t=s(r=>{let i=Ze(r);i?.productHandle&&e(i)},"handleChange");if(n instanceof HTMLAnchorElement)return Vt({element:n,onHrefChange:s(r=>t(r),"onHrefChange")});if(n instanceof Location)return se({onLocationChange:s(r=>t(r.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Kt=s(n=>e=>{let{productHandle:t,productId:r,variantId:i,itemId:o}=e?.dataset??{},l=!!(r||t)||!!o,c=C({loading:!1,productId:r,variantId:i,itemId:o});if(!l){let p=e instanceof HTMLAnchorElement?e:window.location,f=Ze(p.href);f?.productHandle&&f.productHandle!==c.value.productHandle&&(c.value={...c.value,...f,productId:void 0},Xt({source:p,onProductUrlChange:s(m=>{c.value={...c.value,...m,productId:m.productHandle!==c.value.productHandle?void 0:c.value.productId}},"onProductUrlChange")}))}return V(()=>{c.value.loading||!c.value.productId&&c.value.productHandle&&(c.value={...c.value,loading:!0},n.storefront.loadProductId({productHandle:c.value.productHandle}).then(p=>{p.errors&&console.error("Error loading product id",p.errors),c.value={...c.value,productId:p.data?.product?.id?R(p.data.product.id):void 0,loading:!1}}))}),c},"itemContextSignal");var Yt=s(n=>e=>{let t=q(()=>{let{productId:w,variantId:v,loading:T}=e.value;return!w||T?null:v?`variant:${R(v)}`:`product:${R(w)}`}),r=q(()=>e.value.loading||!!e.value.itemId||!e.value.productId),i=q(()=>({limit:1,query:t.value??void 0})),o=C(!r.value),u=C(null),a=C(!1),l=C(!1),{data:c,loading:p,error:f,refetching:m}=n.state.swishQuery(w=>n.api.items.list(w),{refetch:["item-create","item-update","item-delete"],variables:i,skip:r}),h=C(e.value.itemId??null);V(()=>{Y(()=>{if(o.value=p.value,u.value=f.value,!e.value.itemId){let w=c.value?.[0]?.id??null;w!==h.value&&(h.value=w)}})});async function D(){if(!h.value)return;a.value=!0,(await(await n.intents.invoke({action:"delete",type:"swish/Item",data:{itemId:h.value}})).complete).code==="ok"&&(h.value=null),a.value=!1}s(D,"unsave");async function y(){if(!h.value)return;a.value=!0;let v=await(await n.intents.invoke({action:"edit",type:"swish/ItemLists",data:{itemId:h.value}})).complete;v.code==="ok"&&"itemId"in v.data&&(h.value=null),a.value=!1}s(y,"update");async function x(){let{productId:w,variantId:v}=e.value;if(!w)return;a.value=!0,l.value=!0;let P=await(await n.intents.invoke({action:"create",type:"swish/Item",data:{productId:w,variantId:v}})).complete;if(P.code==="ok"){let le=P.data;h.value=le.item.id,a.value=!1}else P.code==="error"&&console.warn("Failed to create item",P),Y(()=>{a.value=!1,l.value=!1})}s(x,"save");let O=q(()=>o.value||a.value||e.value.loading);V(()=>{l.value&&!a.value&&!m.value&&(l.value=!1)});let k=q(()=>{let w=m.value&&l.value,v=!!h.value,T=!v&&(a.value||w),P=v&&(a.value||w),le=q(()=>T?"saving":P?"unsaving":v?"saved":"unsaved");return{error:u.value,status:le.value,savedItemId:h.value,loading:O.value,submitting:a.value,saved:v,saving:T,unsaving:P}});async function F(){O.value||(k.value.saved&&k.value.savedItemId?y():k.value.saved||await x())}return s(F,"toggle"),Object.assign(k,{save:x,unsave:D,update:y,toggle:F})},"itemStateSignal");var Jt=s(n=>()=>{let{data:e,loading:t,error:r}=n.state.swishQuery(()=>n.api.items.count(),{refetch:["item-create","item-delete"]}),i=C(0),o=C(!0),u=C(null);return V(()=>{Y(()=>{o.value=t.value,u.value=r.value,i.value=e.value?.count??0})}),q(()=>({count:i.value,loading:o.value,error:u.value}))},"itemCountSignal");var Zt=s(n=>(e,t)=>{let r=C(null),i=C(null),o=C(null),u=C(!t?.skip),a=C(!1),l=q(()=>u.value&&a.value);async function c(){if(!t?.skip?.value)try{u.value=!0;let p=await e(t?.variables?.value);Y(()=>{o.value="error"in p?p.error:null,r.value="data"in p?p.data:null,i.value="pageInfo"in p?p.pageInfo:null,u.value=!1,a.value=!0})}catch(p){Y(()=>{o.value=p,u.value=!1,a.value=!0})}}return s(c,"executeFetch"),V(()=>{if(c(),t?.refetch?.length)return n.events.subscribe(t.refetch,c)}),{data:r,pageInfo:i,error:o,loading:u,refetching:l}},"swishQuerySignals");var ne="GraphQL Client";var et="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",tt="Response returned unexpected Content-Type:",nt="An unknown error has occurred. The API did not return a data object or any errors in its response.",_e={json:"application/json",multipart:"multipart/mixed"},rt="X-SDK-Variant",it="X-SDK-Version",tn="shopify-graphql-client",nn="1.4.1",Oe=1e3,rn=[429,503],st=/@(defer)\b/i,en=`\r
8
+ `,sn=/boundary="?([^=";]+)"?/i,ot=en+en;function H(n,e=ne){return n.startsWith(`${e}`)?n:`${e}: ${n}`}s(H,"formatErrorMessage");function W(n){return n instanceof Error?n.message:JSON.stringify(n)}s(W,"getErrorMessage");function at(n){return n instanceof Error&&n.cause?n.cause:void 0}s(at,"getErrorCause");function ut(n){return n.flatMap(({errors:e})=>e??[])}s(ut,"combineErrors");function Le({client:n,retries:e}){if(e!==void 0&&(typeof e!="number"||e<0||e>3))throw new Error(`${n}: The provided "retries" value (${e}) is invalid - it cannot be less than ${0} or greater than ${3}`)}s(Le,"validateRetries");function $(n,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[n]:e}:{}}s($,"getKeyValueIfValid");function lt(n,e){if(n.length===0)return e;let r={[n.pop()]:e};return n.length===0?r:lt(n,r)}s(lt,"buildDataObjectByPath");function un(n,e){return Object.keys(e||{}).reduce((t,r)=>(typeof e[r]=="object"||Array.isArray(e[r]))&&n[r]?(t[r]=un(n[r],e[r]),t):(t[r]=e[r],t),Array.isArray(n)?[...n]:{...n})}s(un,"combineObjects");function ct([n,...e]){return e.reduce(un,{...n})}s(ct,"buildCombinedDataObject");function pt({clientLogger:n,customFetchApi:e=fetch,client:t=ne,defaultRetryWaitTime:r=Oe,retriableCodes:i=rn}){let o=s(async(u,a,l)=>{let c=a+1,p=l+1,f;try{if(f=await e(...u),n({type:"HTTP-Response",content:{requestParams:u,response:f}}),!f.ok&&i.includes(f.status)&&c<=p)throw new Error;let m=f?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return m&&n({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:u,deprecationNotice:m}}),f}catch(m){if(c<=p){let h=f?.headers.get("Retry-After");return await $r(h?parseInt(h,10):r),n({type:"HTTP-Retry",content:{requestParams:u,lastResponse:f,retryAttempt:a,maxRetries:l}}),o(u,c,l)}throw new Error(H(`${l>0?`Attempted maximum number of ${l} network retries. Last message - `:""}${W(m)}`,t))}},"httpFetch");return o}s(pt,"generateHttpFetch");async function $r(n){return new Promise(e=>setTimeout(e,n))}s($r,"sleep");function dt({headers:n,url:e,customFetchApi:t=fetch,retries:r=0,logger:i}){Le({client:ne,retries:r});let o={headers:n,url:e,retries:r},u=qr(i),a=pt({customFetchApi:t,clientLogger:u,defaultRetryWaitTime:Oe}),l=Br(a,o),c=Vr(l),p=Hr(l);return{config:o,fetch:l,request:c,requestStream:p}}s(dt,"createGraphQLClient");function qr(n){return e=>{n&&n(e)}}s(qr,"generateClientLogger");async function ln(n){let{errors:e,data:t,extensions:r}=await n.json();return{...$("data",t),...$("extensions",r),headers:n.headers,...e||!t?{errors:{networkStatusCode:n.status,message:H(e?et:nt),...$("graphQLErrors",e),response:n}}:{}}}s(ln,"processJSONResponse");function Br(n,{url:e,headers:t,retries:r}){return async(i,o={})=>{let{variables:u,headers:a,url:l,retries:c,keepalive:p,signal:f}=o,m=JSON.stringify({query:i,variables:u});Le({client:ne,retries:c});let h=Object.entries({...t,...a}).reduce((y,[x,O])=>(y[x]=Array.isArray(O)?O.join(", "):O.toString(),y),{});return!h[rt]&&!h[it]&&(h[rt]=tn,h[it]=nn),n([l??e,{method:"POST",headers:h,body:m,signal:f,keepalive:p}],1,c??r)}}s(Br,"generateFetch");function Vr(n){return async(...e)=>{if(st.test(e[0]))throw new Error(H("This operation will result in a streamable response - use requestStream() instead."));let t=null;try{t=await n(...e);let{status:r,statusText:i}=t,o=t.headers.get("content-type")||"";return t.ok?o.includes(_e.json)?await ln(t):{errors:{networkStatusCode:r,message:H(`${tt} ${o}`),response:t}}:{errors:{networkStatusCode:r,message:H(i),response:t}}}catch(r){return{errors:{message:W(r),...t==null?{}:{networkStatusCode:t.status,response:t}}}}}}s(Vr,"generateRequest");async function*Ur(n){let e=new TextDecoder;if(n.body[Symbol.asyncIterator])for await(let t of n.body)yield e.decode(t);else{let t=n.body.getReader(),r;try{for(;!(r=await t.read()).done;)yield e.decode(r.value)}finally{t.cancel()}}}s(Ur,"getStreamBodyIterator");function Nr(n,e){return{async*[Symbol.asyncIterator](){try{let t="";for await(let r of n)if(t+=r,t.indexOf(e)>-1){let i=t.lastIndexOf(e),u=t.slice(0,i).split(e).filter(a=>a.trim().length>0).map(a=>a.slice(a.indexOf(ot)+ot.length).trim());u.length>0&&(yield u),t=t.slice(i+e.length),t.trim()==="--"&&(t="")}}catch(t){throw new Error(`Error occured while processing stream payload - ${W(t)}`)}}}}s(Nr,"readStreamChunk");function Gr(n){return{async*[Symbol.asyncIterator](){yield{...await ln(n),hasNext:!1}}}}s(Gr,"createJsonResponseAsyncIterator");function Mr(n){return n.map(e=>{try{return JSON.parse(e)}catch(t){throw new Error(`Error in parsing multipart response - ${W(t)}`)}}).map(e=>{let{data:t,incremental:r,hasNext:i,extensions:o,errors:u}=e;if(!r)return{data:t||{},...$("errors",u),...$("extensions",o),hasNext:i};let a=r.map(({data:l,path:c,errors:p})=>({data:l&&c?lt(c,l):{},...$("errors",p)}));return{data:a.length===1?a[0].data:ct([...a.map(({data:l})=>l)]),...$("errors",ut(a)),hasNext:i}})}s(Mr,"getResponseDataFromChunkBodies");function jr(n,e){if(n.length>0)throw new Error(et,{cause:{graphQLErrors:n}});if(Object.keys(e).length===0)throw new Error(nt)}s(jr,"validateResponseData");function Fr(n,e){let t=(e??"").match(sn),r=`--${t?t[1]:"-"}`;if(!n.body?.getReader&&!n.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:n});let i=Ur(n),o={},u;return{async*[Symbol.asyncIterator](){try{let a=!0;for await(let l of Nr(i,r)){let c=Mr(l);u=c.find(f=>f.extensions)?.extensions??u;let p=ut(c);o=ct([o,...c.map(({data:f})=>f)]),a=c.slice(-1)[0].hasNext,jr(p,o),yield{...$("data",o),...$("extensions",u),hasNext:a}}if(a)throw new Error("Response stream terminated unexpectedly")}catch(a){let l=at(a);yield{...$("data",o),...$("extensions",u),errors:{message:H(W(a)),networkStatusCode:n.status,...$("graphQLErrors",l?.graphQLErrors),response:n},hasNext:!1}}}}}s(Fr,"createMultipartResponseAsyncInterator");function Hr(n){return async(...e)=>{if(!st.test(e[0]))throw new Error(H("This operation does not result in a streamable response - use request() instead."));try{let t=await n(...e),{statusText:r}=t;if(!t.ok)throw new Error(r,{cause:t});let i=t.headers.get("content-type")||"";switch(!0){case i.includes(_e.json):return Gr(t);case i.includes(_e.multipart):return Fr(t,i);default:throw new Error(`${tt} ${i}`,{cause:t})}}catch(t){return{async*[Symbol.asyncIterator](){let r=at(t);yield{errors:{message:H(W(t)),...$("networkStatusCode",r?.status),...$("response",r)},hasNext:!1}}}}}}s(Hr,"generateRequestStream");function ft({client:n,storeDomain:e}){try{if(!e||typeof e!="string")throw new Error;let t=e.trim(),r=t.match(/^https?:/)?t:`https://${t}`,i=new URL(r);return i.protocol="https",i.origin}catch(t){throw new Error(`${n}: a valid store domain ("${e}") must be provided`,{cause:t})}}s(ft,"validateDomainAndGetStoreUrl");function $e({client:n,currentSupportedApiVersions:e,apiVersion:t,logger:r}){let i=`${n}: the provided apiVersion ("${t}")`,o=`Currently supported API versions: ${e.join(", ")}`;if(!t||typeof t!="string")throw new Error(`${i} is invalid. ${o}`);let u=t.trim();e.includes(u)||(r?r({type:"Unsupported_Api_Version",content:{apiVersion:t,supportedApiVersions:e}}):console.warn(`${i} is likely deprecated or not supported. ${o}`))}s($e,"validateApiVersion");function qe(n){let e=n*3-2;return e===10?e:`0${e}`}s(qe,"getQuarterMonth");function ht(n,e,t){let r=e-t;return r<=0?`${n-1}-${qe(r+4)}`:`${n}-${qe(r)}`}s(ht,"getPrevousVersion");function cn(){let n=new Date,e=n.getUTCMonth(),t=n.getUTCFullYear(),r=Math.floor(e/3+1);return{year:t,quarter:r,version:`${t}-${qe(r)}`}}s(cn,"getCurrentApiVersion");function yt(){let{year:n,quarter:e,version:t}=cn(),r=e===4?`${n+1}-01`:`${n}-${qe(e+1)}`;return[ht(n,e,3),ht(n,e,2),ht(n,e,1),t,r,"unstable"]}s(yt,"getCurrentSupportedApiVersions");function mt(n){return e=>({...e??{},...n.headers})}s(mt,"generateGetHeaders");function vt({getHeaders:n,getApiUrl:e}){return(t,r)=>{let i=[t];if(r&&Object.keys(r).length>0){let{variables:o,apiVersion:u,headers:a,retries:l,signal:c}=r;i.push({...o?{variables:o}:{},...a?{headers:n(a)}:{},...u?{url:e(u)}:{},...l?{retries:l}:{},...c?{signal:c}:{}})}return i}}s(vt,"generateGetGQLClientParams");var gt="application/json",pn="storefront-api-client",dn="1.0.9",fn="X-Shopify-Storefront-Access-Token",hn="Shopify-Storefront-Private-Token",yn="X-SDK-Variant",mn="X-SDK-Version",vn="X-SDK-Variant-Source",re="Storefront API Client";function gn(n){if(n&&typeof window<"u")throw new Error(`${re}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}s(gn,"validatePrivateAccessTokenUsage");function In(n,e){if(!n&&!e)throw new Error(`${re}: a public or private access token must be provided`);if(n&&e)throw new Error(`${re}: only provide either a public or private access token`)}s(In,"validateRequiredAccessTokens");function It({storeDomain:n,apiVersion:e,publicAccessToken:t,privateAccessToken:r,clientName:i,retries:o=0,customFetchApi:u,logger:a}){let l=yt(),c=ft({client:re,storeDomain:n}),p={client:re,currentSupportedApiVersions:l,logger:a};$e({...p,apiVersion:e}),In(t,r),gn(r);let f=Qr(c,e,p),m={storeDomain:c,apiVersion:e,...t?{publicAccessToken:t}:{privateAccessToken:r},headers:{"Content-Type":gt,Accept:gt,[yn]:pn,[mn]:dn,...i?{[vn]:i}:{},...t?{[fn]:t}:{[hn]:r}},apiUrl:f(),clientName:i},h=dt({headers:m.headers,url:m.apiUrl,retries:o,customFetchApi:u,logger:a}),D=mt(m),y=zr(m,f),x=vt({getHeaders:D,getApiUrl:y});return Object.freeze({config:m,getHeaders:D,getApiUrl:y,fetch:s((...k)=>h.fetch(...x(...k)),"fetch"),request:s((...k)=>h.request(...x(...k)),"request"),requestStream:s((...k)=>h.requestStream(...x(...k)),"requestStream")})}s(It,"createStorefrontApiClient");function Qr(n,e,t){return r=>{r&&$e({...t,apiVersion:r});let i=(r??e).trim();return`${n}/api/${i}/graphql.json`}}s(Qr,"generateApiUrlFormatter");function zr(n,e){return t=>t?e(t):n.apiUrl}s(zr,"generateGetApiUrl");var B=`
9
9
  fragment productImageFields on Image {
10
10
  id
11
11
  altText
@@ -123,7 +123,7 @@ Values:
123
123
  value
124
124
  }
125
125
  }
126
- `,Ct=`
126
+ `,St=`
127
127
  fragment selectedVariantFields on Product {
128
128
  id
129
129
  availableForSale
@@ -190,7 +190,7 @@ Values:
190
190
  }
191
191
  }
192
192
  }
193
- `,xt=`
193
+ `,Ct=`
194
194
  fragment productImagesFields on Product {
195
195
  images(first: 20) {
196
196
  nodes {
@@ -198,7 +198,7 @@ Values:
198
198
  }
199
199
  }
200
200
  }
201
- `;var gr=`
201
+ `;var wn=`
202
202
  query GetSaveIntentData(
203
203
  $productId: ID!
204
204
  $country: CountryCode!
@@ -209,8 +209,8 @@ Values:
209
209
  }
210
210
  }
211
211
  ${wt}
212
- ${q}
213
- `,Ir=`
212
+ ${B}
213
+ `,bn=`
214
214
  query GetSaveIntentDataWithVariant(
215
215
  $productId: ID!
216
216
  $variantId: ID!
@@ -225,8 +225,8 @@ Values:
225
225
  }
226
226
  }
227
227
  ${wt}
228
- ${q}
229
- `,wr=`
228
+ ${B}
229
+ `,En=`
230
230
  query GetProductCardData(
231
231
  $productId: ID!
232
232
  $productMetafields: [HasMetafieldsIdentifier!]!
@@ -238,8 +238,8 @@ Values:
238
238
  }
239
239
  }
240
240
  ${de}
241
- ${q}
242
- `,br=`
241
+ ${B}
242
+ `,Sn=`
243
243
  query GetProductCardDataWithVariant(
244
244
  $productId: ID!
245
245
  $variantId: ID!
@@ -257,8 +257,8 @@ Values:
257
257
  }
258
258
  ${de}
259
259
  ${bt}
260
- ${q}
261
- `,Er=`
260
+ ${B}
261
+ `,Cn=`
262
262
  query GetProductOptions(
263
263
  $productId: ID!
264
264
  $country: CountryCode!
@@ -269,8 +269,8 @@ Values:
269
269
  }
270
270
  }
271
271
  ${ie}
272
- ${q}
273
- `,Cr=`
272
+ ${B}
273
+ `,xn=`
274
274
  query GetProductOptionsByHandle(
275
275
  $handle: String!
276
276
  $country: CountryCode!
@@ -281,8 +281,8 @@ Values:
281
281
  }
282
282
  }
283
283
  ${ie}
284
- ${q}
285
- `,xr=`
284
+ ${B}
285
+ `,An=`
286
286
  query GetProductOptionsWithVariant(
287
287
  $productId: ID!
288
288
  $variantId: ID!
@@ -298,8 +298,8 @@ Values:
298
298
  }
299
299
  ${ie}
300
300
  ${Et}
301
- ${q}
302
- `,Sr=`
301
+ ${B}
302
+ `,kn=`
303
303
  query GetProductOptionsByHandleWithVariant(
304
304
  $handle: String!
305
305
  $variantId: ID!
@@ -315,8 +315,8 @@ Values:
315
315
  }
316
316
  ${ie}
317
317
  ${Et}
318
- ${q}
319
- `,Ar=`
318
+ ${B}
319
+ `,Rn=`
320
320
  query GetSelectedVariant(
321
321
  $productId: ID!
322
322
  $selectedOptions: [SelectedOptionInput!]!
@@ -327,9 +327,9 @@ Values:
327
327
  ...selectedVariantFields
328
328
  }
329
329
  }
330
- ${Ct}
331
- ${q}
332
- `,kr=`
330
+ ${St}
331
+ ${B}
332
+ `,Dn=`
333
333
  query GetSelectedVariantByHandle(
334
334
  $handle: String!
335
335
  $selectedOptions: [SelectedOptionInput!]!
@@ -340,9 +340,9 @@ Values:
340
340
  ...selectedVariantFields
341
341
  }
342
342
  }
343
- ${Ct}
344
- ${q}
345
- `,Rr=`
343
+ ${St}
344
+ ${B}
345
+ `,Tn=`
346
346
  query GetProductDetailData(
347
347
  $productId: ID!
348
348
  $productMetafields: [HasMetafieldsIdentifier!]!
@@ -357,9 +357,9 @@ Values:
357
357
  }
358
358
  ${de}
359
359
  ${ie}
360
- ${xt}
361
- ${q}
362
- `,Dr=`
360
+ ${Ct}
361
+ ${B}
362
+ `,Pn=`
363
363
  query GetProductDetailDataWithVariant(
364
364
  $productId: ID!
365
365
  $variantId: ID!
@@ -380,9 +380,9 @@ Values:
380
380
  ${de}
381
381
  ${ie}
382
382
  ${bt}
383
- ${xt}
384
- ${q}
385
- `,Pr=`
383
+ ${Ct}
384
+ ${B}
385
+ `,_n=`
386
386
  query GetProductImagesById(
387
387
  $ids: [ID!]!
388
388
  $country: CountryCode!
@@ -406,8 +406,8 @@ Values:
406
406
  }
407
407
  }
408
408
  }
409
- ${q}
410
- `,Tr=`
409
+ ${B}
410
+ `,On=`
411
411
  query GetProductRecommendationsById(
412
412
  $productId: ID!
413
413
  $intent: ProductRecommendationIntent
@@ -418,7 +418,7 @@ Values:
418
418
  id
419
419
  }
420
420
  }
421
- `,_r=`
421
+ `,Ln=`
422
422
  query GetProductRecommendationsByHandle(
423
423
  $handle: String!
424
424
  $intent: ProductRecommendationIntent
@@ -429,20 +429,20 @@ Values:
429
429
  id
430
430
  }
431
431
  }
432
- `,Or=`
432
+ `,$n=`
433
433
  query GetProductIdByHandle($handle: String!) {
434
434
  product(handle: $handle) {
435
435
  id
436
436
  }
437
437
  }
438
- `;var Lr=s(async(r,{productId:e,variantId:t,productMetafields:n=[],variantMetafields:i=[],country:o,language:a})=>{if(!e)throw new Error("A productId must be provided");let u=s(()=>{if(e&&!t)return wr;if(e&&t)return br},"getProductOptionsQuery"),l=s(()=>{if(e&&!t)return{productId:w("Product",e),productMetafields:n,country:o,language:a};if(e&&t)return{productId:w("Product",e),variantId:w("ProductVariant",t),productMetafields:n,variantMetafields:i,country:o,language:a}},"getVariables"),c=u(),p=l();if(!p||!c)throw new Error("Invalid query arguments");return r.query(c,p)},"loadProductCardData");var $r=s(async(r,{productId:e,variantId:t,productMetafields:n=[],variantMetafields:i=[],country:o,language:a})=>{if(!e)throw new Error("A productId must be provided");let u=s(()=>{if(e&&!t)return Rr;if(e&&t)return Dr},"getProductOptionsQuery"),l=s(()=>{if(e&&!t)return{productId:w("Product",e),productMetafields:n,country:o,language:a};if(e&&t)return{productId:w("Product",e),variantId:w("ProductVariant",t),productMetafields:n,variantMetafields:i,country:o,language:a}},"getVariables"),c=u(),p=l();if(!p||!c)throw new Error("Invalid query arguments");return r.query(c,p)},"loadProductDetailData");var Br=s(async(r,{productHandle:e})=>{if(!e)throw new Error("A product handle must be provided");return r.query(Or,{handle:e})},"loadProductId");var qr=s(async(r,{items:e,country:t,language:n})=>{if(!e?.length)throw new Error("A list of items must be provided");let i={ids:e.map(o=>o.variantId?w("ProductVariant",o.variantId.toString()):w("Product",o.productId.toString())),country:t,language:n};try{return{data:(await r.query(Pr,i)).data?.nodes.map(u=>u===null?null:"image"in u?u.image:"featuredImage"in u?u.featuredImage:null).filter(u=>u!==null)??[],error:null}}catch(o){return console.error(o),{data:null,error:o}}},"loadProductImages");var Vr=s(async(r,{productId:e,productHandle:t,variantId:n,country:i,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let a=s(()=>{if(e&&!n)return Er;if(t&&!n)return Cr;if(e&&n)return xr;if(t&&n)return Sr},"getProductOptionsQuery"),u=s(()=>{if(e&&!n)return{productId:w("Product",e),country:i,language:o};if(t&&!n)return{handle:t,country:i,language:o};if(e&&n)return{productId:w("Product",e),variantId:w("ProductVariant",n),country:i,language:o};if(t&&n)return{handle:t,variantId:w("ProductVariant",n),country:i,language:o}},"getVariables"),l=a(),c=u();if(!c||!l)throw new Error("Invalid query arguments");return r.query(l,c)},"loadProductOptions");var Ur=s(async(r,{productId:e,productHandle:t,intent:n,country:i,language:o})=>{if(!e&&!t)throw new Error("Either productId or productHandle must be provided");if(e){let u={productId:w("Product",e),intent:n,country:i,language:o};return r.query(Tr,u)}let a={handle:t,intent:n,country:i,language:o};return r.query(_r,a)},"loadProductRecommendations");var Nr=s(async(r,{productId:e,variantId:t,country:n,language:i})=>{let o=s(()=>{if(e&&!t)return gr;if(e&&t)return Ir},"getProductOptionsQuery"),a=s(()=>{if(e&&!t)return{productId:w("Product",R(e)),country:n,language:i};if(e&&t)return{productId:w("Product",R(e)),variantId:w("ProductVariant",R(t)),country:n,language:i}},"getVariables"),u=o(),l=a();if(!l||!u)throw new Error("Invalid query arguments");return r.query(u,l)},"loadSaveIntentData");var Gr=s(async(r,{productId:e,productHandle:t,selectedOptions:n,country:i,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let a=e?Ar:kr,u=e?{productId:`gid://shopify/Product/${e}`,selectedOptions:n,country:i,language:o}:{handle:t,selectedOptions:n,country:i,language:o};return r.query(a,u)},"loadSelectedVariant");var Jn="2025-10",Zn=["GetProductIdByHandle"],Ve=class{constructor(e,t,n,i){this.client=null;this.query=s(async(e,t)=>{if(!this.client)throw new Error("Storefront API client not initialized");let n=await this.client.request(e,{variables:t});return{data:n.data,errors:n.errors??null}},"query");this.loadProductOptions=s(async e=>Vr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductOptions");this.loadSelectedVariant=s(async e=>Gr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSelectedVariant");this.loadProductCardData=s(async e=>Lr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product})}}:t),"loadProductCardData");this.loadProductDetailData=s(async e=>$r(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product})}}:t),"loadProductDetailData");this.loadProductImages=s(async e=>qr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=s(async e=>Ur(this,{...e,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=s(async e=>Br(this,e),"loadProductId");this.loadSaveIntentData=s(async e=>Nr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSaveIntentData");this.options=e,this.context=t,this.badges=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]}))??[]},this.shortCache=new Q("storefront-api-short","max-age=60, stale-while-revalidate=3600"),this.longCache=new Q("storefront-api-long","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=It({apiVersion:Jn,customFetchApi:s((o,a)=>a?.method==="OPTIONS"?this.fetch(o,a):Zn.some(u=>a?.body?.toString().includes(`query ${u}`))?this.longCache.fetchWithCache(o,a):this.shortCache.fetchWithCache(o,a),"customFetchApi"),publicAccessToken:this.options.accessToken,storeDomain:this.options.storeDomain})}static{s(this,"StorefrontApiClient")}fetch(e,t){return t?.method==="OPTIONS"?fetch(e,t):this.shortCache.fetchWithCache(e,t)}async clearCache(){await this.shortCache.clear()}};var ei=Object.defineProperty,f=s((r,e)=>ei(r,"name",{value:e,configurable:!0}),"n"),ti={bodySerializer:f(r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")},ri={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Gu=Object.entries(ri),ni=f(({onRequest:r,onSseError:e,onSseEvent:t,responseTransformer:n,responseValidator:i,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:u,sseSleepFn:l,url:c,...p})=>{let d,m=l??(h=>new Promise(D=>setTimeout(D,h)));return{stream:f(async function*(){let h=o??3e3,D=0,y=p.signal??new AbortController().signal;for(;!y.aborted;){D++;let S=p.headers instanceof Headers?p.headers:new Headers(p.headers);d!==void 0&&S.set("Last-Event-ID",d);try{let O={redirect:"follow",...p,body:p.serializedBody,headers:S,signal:y},k=new Request(c,O);r&&(k=await r(c,O));let F=await(p.fetch??globalThis.fetch)(k);if(!F.ok)throw new Error(`SSE failed: ${F.status} ${F.statusText}`);if(!F.body)throw new Error("No body in SSE response");let I=F.body.pipeThrough(new TextDecoderStream).getReader(),v="",P=f(()=>{try{I.cancel()}catch{}},"abortHandler");y.addEventListener("abort",P);try{for(;;){let{done:T,value:ce}=await I.read();if(T)break;v+=ce;let Ot=v.split(`
438
+ `;var qn=s(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:i=[],country:o,language:u})=>{if(!e)throw new Error("A productId must be provided");let a=s(()=>{if(e&&!t)return En;if(e&&t)return Sn},"getProductOptionsQuery"),l=s(()=>{if(e&&!t)return{productId:b("Product",e),productMetafields:r,country:o,language:u};if(e&&t)return{productId:b("Product",e),variantId:b("ProductVariant",t),productMetafields:r,variantMetafields:i,country:o,language:u}},"getVariables"),c=a(),p=l();if(!p||!c)throw new Error("Invalid query arguments");return n.query(c,p)},"loadProductCardData");var Bn=s(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:i=[],country:o,language:u})=>{if(!e)throw new Error("A productId must be provided");let a=s(()=>{if(e&&!t)return Tn;if(e&&t)return Pn},"getProductOptionsQuery"),l=s(()=>{if(e&&!t)return{productId:b("Product",e),productMetafields:r,country:o,language:u};if(e&&t)return{productId:b("Product",e),variantId:b("ProductVariant",t),productMetafields:r,variantMetafields:i,country:o,language:u}},"getVariables"),c=a(),p=l();if(!p||!c)throw new Error("Invalid query arguments");return n.query(c,p)},"loadProductDetailData");var Vn=s(async(n,{productHandle:e})=>{if(!e)throw new Error("A product handle must be provided");return n.query($n,{handle:e})},"loadProductId");var Un=s(async(n,{items:e,country:t,language:r})=>{if(!e?.length)throw new Error("A list of items must be provided");let i={ids:e.map(o=>o.variantId?b("ProductVariant",o.variantId.toString()):b("Product",o.productId.toString())),country:t,language:r};try{return{data:(await n.query(_n,i)).data?.nodes.map(a=>a===null?null:"image"in a?a.image:"featuredImage"in a?a.featuredImage:null).filter(a=>a!==null)??[],error:null}}catch(o){return console.error(o),{data:null,error:o}}},"loadProductImages");var Nn=s(async(n,{productId:e,productHandle:t,variantId:r,country:i,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let u=s(()=>{if(e&&!r)return Cn;if(t&&!r)return xn;if(e&&r)return An;if(t&&r)return kn},"getProductOptionsQuery"),a=s(()=>{if(e&&!r)return{productId:b("Product",e),country:i,language:o};if(t&&!r)return{handle:t,country:i,language:o};if(e&&r)return{productId:b("Product",e),variantId:b("ProductVariant",r),country:i,language:o};if(t&&r)return{handle:t,variantId:b("ProductVariant",r),country:i,language:o}},"getVariables"),l=u(),c=a();if(!c||!l)throw new Error("Invalid query arguments");return n.query(l,c)},"loadProductOptions");var Gn=s(async(n,{productId:e,productHandle:t,intent:r,country:i,language:o})=>{if(!e&&!t)throw new Error("Either productId or productHandle must be provided");if(e){let a={productId:b("Product",e),intent:r,country:i,language:o};return n.query(On,a)}let u={handle:t,intent:r,country:i,language:o};return n.query(Ln,u)},"loadProductRecommendations");var Mn=s(async(n,{productId:e,variantId:t,country:r,language:i})=>{let o=s(()=>{if(e&&!t)return wn;if(e&&t)return bn},"getProductOptionsQuery"),u=s(()=>{if(e&&!t)return{productId:b("Product",R(e)),country:r,language:i};if(e&&t)return{productId:b("Product",R(e)),variantId:b("ProductVariant",R(t)),country:r,language:i}},"getVariables"),a=o(),l=u();if(!l||!a)throw new Error("Invalid query arguments");return n.query(a,l)},"loadSaveIntentData");var jn=s(async(n,{productId:e,productHandle:t,selectedOptions:r,country:i,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let u=e?Rn:Dn,a=e?{productId:`gid://shopify/Product/${e}`,selectedOptions:r,country:i,language:o}:{handle:t,selectedOptions:r,country:i,language:o};return n.query(u,a)},"loadSelectedVariant");var Wr="2025-10",Xr=["GetProductIdByHandle"],Be=class{constructor(e,t,r,i){this.client=null;this.query=s(async(e,t)=>{if(!this.client)throw new Error("Storefront API client not initialized");let r=await this.client.request(e,{variables:t});return{data:r.data,errors:r.errors??null}},"query");this.loadProductOptions=s(async e=>Nn(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductOptions");this.loadSelectedVariant=s(async e=>jn(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSelectedVariant");this.loadProductCardData=s(async e=>qn(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product})}}:t),"loadProductCardData");this.loadProductDetailData=s(async e=>Bn(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product})}}:t),"loadProductDetailData");this.loadProductImages=s(async e=>Un(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=s(async e=>Gn(this,{...e,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=s(async e=>Vn(this,e),"loadProductId");this.loadSaveIntentData=s(async e=>Mn(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSaveIntentData");this.options=e,this.context=t,this.badges=r,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]}))??[]},this.shortCache=new Q("storefront-api-short","max-age=60, stale-while-revalidate=3600"),this.longCache=new Q("storefront-api-long","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=It({apiVersion:Wr,customFetchApi:s((o,u)=>u?.method==="OPTIONS"?this.fetch(o,u):Xr.some(a=>u?.body?.toString().includes(`query ${a}`))?this.longCache.fetchWithCache(o,u):this.shortCache.fetchWithCache(o,u),"customFetchApi"),publicAccessToken:this.options.accessToken,storeDomain:this.options.storeDomain})}static{s(this,"StorefrontApiClient")}fetch(e,t){return t?.method==="OPTIONS"?fetch(e,t):this.shortCache.fetchWithCache(e,t)}async clearCache(){await this.shortCache.clear()}};var Kr=Object.defineProperty,d=s((n,e)=>Kr(n,"name",{value:e,configurable:!0}),"n"),Yr={bodySerializer:d(n=>JSON.stringify(n,(e,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")},Jr={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},zu=Object.entries(Jr),Zr=d(({onRequest:n,onSseError:e,onSseEvent:t,responseTransformer:r,responseValidator:i,sseDefaultRetryDelay:o,sseMaxRetryAttempts:u,sseMaxRetryDelay:a,sseSleepFn:l,url:c,...p})=>{let f,m=l??(h=>new Promise(D=>setTimeout(D,h)));return{stream:d(async function*(){let h=o??3e3,D=0,y=p.signal??new AbortController().signal;for(;!y.aborted;){D++;let x=p.headers instanceof Headers?p.headers:new Headers(p.headers);f!==void 0&&x.set("Last-Event-ID",f);try{let O={redirect:"follow",...p,body:p.serializedBody,headers:x,signal:y},k=new Request(c,O);n&&(k=await n(c,O));let F=await(p.fetch??globalThis.fetch)(k);if(!F.ok)throw new Error(`SSE failed: ${F.status} ${F.statusText}`);if(!F.body)throw new Error("No body in SSE response");let w=F.body.pipeThrough(new TextDecoderStream).getReader(),v="",T=d(()=>{try{w.cancel()}catch{}},"abortHandler");y.addEventListener("abort",T);try{for(;;){let{done:P,value:le}=await w.read();if(P)break;v+=le;let Ot=v.split(`
439
439
 
440
- `);v=Ot.pop()??"";for(let ln of Ot){let cn=ln.split(`
441
- `),he=[],Lt;for(let M of cn)if(M.startsWith("data:"))he.push(M.replace(/^data:\s*/,""));else if(M.startsWith("event:"))Lt=M.replace(/^event:\s*/,"");else if(M.startsWith("id:"))d=M.replace(/^id:\s*/,"");else if(M.startsWith("retry:")){let Bt=Number.parseInt(M.replace(/^retry:\s*/,""),10);Number.isNaN(Bt)||(h=Bt)}let J,$t=!1;if(he.length){let M=he.join(`
442
- `);try{J=JSON.parse(M),$t=!0}catch{J=M}}$t&&(i&&await i(J),n&&(J=await n(J))),t?.({data:J,event:Lt,id:d,retry:h}),he.length&&(yield J)}}}finally{y.removeEventListener("abort",P),I.releaseLock()}break}catch(O){if(e?.(O),a!==void 0&&D>=a)break;let k=Math.min(h*2**(D-1),u??3e4);await m(k)}}},"createStream")()}},"createSseClient"),ii=f(r=>{switch(r){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),si=f(r=>{switch(r){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),oi=f(r=>{switch(r){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),Hr=f(({allowReserved:r,explode:e,name:t,style:n,value:i})=>{if(!e){let u=(r?i:i.map(l=>encodeURIComponent(l))).join(si(n));switch(n){case"label":return`.${u}`;case"matrix":return`;${t}=${u}`;case"simple":return u;default:return`${t}=${u}`}}let o=ii(n),a=i.map(u=>n==="label"||n==="simple"?r?u:encodeURIComponent(u):Ne({allowReserved:r,name:t,value:u})).join(o);return n==="label"||n==="matrix"?o+a:a},"serializeArrayParam"),Ne=f(({allowReserved:r,name:e,value:t})=>{if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${r?t:encodeURIComponent(t)}`},"serializePrimitiveParam"),Qr=f(({allowReserved:r,explode:e,name:t,style:n,value:i,valueOnly:o})=>{if(i instanceof Date)return o?i.toISOString():`${t}=${i.toISOString()}`;if(n!=="deepObject"&&!e){let l=[];Object.entries(i).forEach(([p,d])=>{l=[...l,p,r?d:encodeURIComponent(d)]});let c=l.join(",");switch(n){case"form":return`${t}=${c}`;case"label":return`.${c}`;case"matrix":return`;${t}=${c}`;default:return c}}let a=oi(n),u=Object.entries(i).map(([l,c])=>Ne({allowReserved:r,name:n==="deepObject"?`${t}[${l}]`:l,value:c})).join(a);return n==="label"||n==="matrix"?a+u:u},"serializeObjectParam"),ai=/\{[^{}]+\}/g,ui=f(({path:r,url:e})=>{let t=e,n=e.match(ai);if(n)for(let i of n){let o=!1,a=i.substring(1,i.length-1),u="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),u="label"):a.startsWith(";")&&(a=a.substring(1),u="matrix");let l=r[a];if(l==null)continue;if(Array.isArray(l)){t=t.replace(i,Hr({explode:o,name:a,style:u,value:l}));continue}if(typeof l=="object"){t=t.replace(i,Qr({explode:o,name:a,style:u,value:l,valueOnly:!0}));continue}if(u==="matrix"){t=t.replace(i,`;${Ne({name:a,value:l})}`);continue}let c=encodeURIComponent(u==="label"?`.${l}`:l);t=t.replace(i,c)}return t},"defaultPathSerializer"),li=f(({baseUrl:r,path:e,query:t,querySerializer:n,url:i})=>{let o=i.startsWith("/")?i:`/${i}`,a=(r??"")+o;e&&(a=ui({path:e,url:a}));let u=t?n(t):"";return u.startsWith("?")&&(u=u.substring(1)),u&&(a+=`?${u}`),a},"getUrl");function zr(r){let e=r.body!==void 0;if(e&&r.bodySerializer)return"serializedBody"in r?r.serializedBody!==void 0&&r.serializedBody!==""?r.serializedBody:null:r.body!==""?r.body:null;if(e)return r.body}s(zr,"G");f(zr,"getValidRequestBody");var ci=f(async(r,e)=>{let t=typeof e=="function"?await e(r):e;if(t)return r.scheme==="bearer"?`Bearer ${t}`:r.scheme==="basic"?`Basic ${btoa(t)}`:t},"getAuthToken"),Wr=f(({allowReserved:r,array:e,object:t}={})=>f(n=>{let i=[];if(n&&typeof n=="object")for(let o in n){let a=n[o];if(a!=null)if(Array.isArray(a)){let u=Hr({allowReserved:r,explode:!0,name:o,style:"form",value:a,...e});u&&i.push(u)}else if(typeof a=="object"){let u=Qr({allowReserved:r,explode:!0,name:o,style:"deepObject",value:a,...t});u&&i.push(u)}else{let u=Ne({allowReserved:r,name:o,value:a});u&&i.push(u)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),pi=f(r=>{var e;if(!r)return"stream";let t=(e=r.split(";")[0])==null?void 0:e.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(n=>t.startsWith(n)))return"blob";if(t.startsWith("text/"))return"text"}},"getParseAs"),fi=f((r,e)=>{var t,n;return e?!!(r.headers.has(e)||(t=r.query)!=null&&t[e]||(n=r.headers.get("Cookie"))!=null&&n.includes(`${e}=`)):!1},"checkForExistence"),di=f(async({security:r,...e})=>{for(let t of r){if(fi(e,t.name))continue;let n=await ci(t,e.auth);if(!n)continue;let i=t.name??"Authorization";switch(t.in){case"query":e.query||(e.query={}),e.query[i]=n;break;case"cookie":e.headers.append("Cookie",`${i}=${n}`);break;case"header":default:e.headers.set(i,n);break}}},"setAuthParams"),Mr=f(r=>li({baseUrl:r.baseUrl,path:r.path,query:r.query,querySerializer:typeof r.querySerializer=="function"?r.querySerializer:Wr(r.querySerializer),url:r.url}),"buildUrl"),jr=f((r,e)=>{var t;let n={...r,...e};return(t=n.baseUrl)!=null&&t.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=Xr(r.headers,e.headers),n},"mergeConfigs"),hi=f(r=>{let e=[];return r.forEach((t,n)=>{e.push([n,t])}),e},"headersEntries"),Xr=f((...r)=>{let e=new Headers;for(let t of r){if(!t)continue;let n=t instanceof Headers?hi(t):Object.entries(t);for(let[i,o]of n)if(o===null)e.delete(i);else if(Array.isArray(o))for(let a of o)e.append(i,a);else o!==void 0&&e.set(i,typeof o=="object"?JSON.stringify(o):o)}return e},"mergeHeaders"),Kr=class{static{s(this,"$")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e=="number"?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let n=this.getInterceptorIndex(e);return this.fns[n]?(this.fns[n]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};f(Kr,"Interceptors");var St=Kr,yi=f(()=>({error:new St,request:new St,response:new St}),"createInterceptors"),mi=Wr({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),vi={"Content-Type":"application/json"},Ue=f((r={})=>({...ti,headers:vi,parseAs:"auto",querySerializer:mi,...r}),"createConfig"),At=f((r={})=>{let e=jr(Ue(),r),t=f(()=>({...e}),"getConfig"),n=f(c=>(e=jr(e,c),t()),"setConfig"),i=yi(),o=f(async c=>{let p={...e,...c,fetch:c.fetch??e.fetch??globalThis.fetch,headers:Xr(e.headers,c.headers),serializedBody:void 0};p.security&&await di({...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 d=Mr(p);return{opts:p,url:d}},"beforeRequest"),a=f(async c=>{let{opts:p,url:d}=await o(c),m={redirect:"follow",...p,body:zr(p)},h=new Request(d,m);for(let v of i.request.fns)v&&(h=await v(h,p));let D=p.fetch,y=await D(h);for(let v of i.response.fns)v&&(y=await v(y,h,p));let S={request:h,response:y};if(y.ok){let v=(p.parseAs==="auto"?pi(y.headers.get("Content-Type")):p.parseAs)??"json";if(y.status===204||y.headers.get("Content-Length")==="0"){let T;switch(v){case"arrayBuffer":case"blob":case"text":T=await y[v]();break;case"formData":T=new FormData;break;case"stream":T=y.body;break;case"json":default:T={};break}return p.responseStyle==="data"?T:{data:T,...S}}let P;switch(v){case"arrayBuffer":case"blob":case"formData":case"json":case"text":P=await y[v]();break;case"stream":return p.responseStyle==="data"?y.body:{data:y.body,...S}}return v==="json"&&(p.responseValidator&&await p.responseValidator(P),p.responseTransformer&&(P=await p.responseTransformer(P))),p.responseStyle==="data"?P:{data:P,...S}}let O=await y.text(),k;try{k=JSON.parse(O)}catch{}let F=k??O,I=F;for(let v of i.error.fns)v&&(I=await v(F,y,h,p));if(I=I||{},p.throwOnError)throw I;return p.responseStyle==="data"?void 0:{error:I,...S}},"request"),u=f(c=>p=>a({...p,method:c}),"makeMethodFn"),l=f(c=>async p=>{let{opts:d,url:m}=await o(p);return ni({...d,body:d.body,headers:d.headers,method:c,onRequest:f(async(h,D)=>{let y=new Request(h,D);for(let S of i.request.fns)S&&(y=await S(y,d));return y},"onRequest"),url:m})},"makeSseFn");return{buildUrl:Mr,connect:u("CONNECT"),delete:u("DELETE"),get:u("GET"),getConfig:t,head:u("HEAD"),interceptors:i,options:u("OPTIONS"),patch:u("PATCH"),post:u("POST"),put:u("PUT"),request:a,setConfig:n,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:u("TRACE")}},"createClient"),x=At(Ue({baseUrl:"https://swish.app/api/2026-01"})),gi=f(r=>(r?.client??x).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...r}),"listControllerFind"),Ii=f(r=>(r.client??x).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...r,headers:{"Content-Type":"application/json",...r.headers}}),"listControllerCreate"),wi=f(r=>(r.client??x).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...r}),"listControllerDeleteById"),bi=f(r=>(r.client??x).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...r}),"listControllerFindById"),Ei=f(r=>(r.client??x).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...r,headers:{"Content-Type":"application/json",...r.headers}}),"listControllerUpdateById"),Ci=f(r=>(r.client??x).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...r,headers:{"Content-Type":"application/json",...r.headers}}),"listControllerSetListItemsOrder"),xi=f(r=>(r.client??x).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...r,headers:{"Content-Type":"application/json",...r.headers}}),"listControllerAddItemsToList"),Si=f(r=>(r.client??x).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...r}),"listControllerRemoveItemFromList"),Ai=f(r=>(r.client??x).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...r,headers:{"Content-Type":"application/json",...r.headers}}),"itemControllerDelete"),ki=f(r=>(r?.client??x).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...r}),"itemControllerFind"),Ri=f(r=>(r.client??x).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...r,headers:{"Content-Type":"application/json",...r.headers}}),"itemControllerCreate"),Di=f(r=>(r?.client??x).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...r}),"itemControllerCount"),Pi=f(r=>(r.client??x).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...r}),"itemControllerDeleteById"),Ti=f(r=>(r.client??x).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...r}),"itemControllerFindById"),_i=f(r=>(r.client??x).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...r,headers:{"Content-Type":"application/json",...r.headers}}),"itemControllerUpdateById"),Oi=f(r=>(r.client??x).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...r,headers:{"Content-Type":"application/json",...r.headers}}),"itemControllerSetListsById"),Li=f(r=>(r?.client??x).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles/accounts-version",...r}),"profileControllerCustomerAccountsVersion"),$i=f(r=>(r.client??x).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...r,headers:{"Content-Type":"application/json",...r.headers}}),"profileControllerIdentify"),Bi=f(r=>(r.client??x).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...r,headers:{"Content-Type":"application/json",...r.headers}}),"profileControllerCreateToken"),qi=f(r=>(r?.client??x).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...r}),"ordersControllerFind"),Vi=f(r=>(r.client??x).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...r}),"ordersControllerFindOne"),kt="2026-01",Fr="/apps/wishlist/api",Yr=f(r=>new Ui(r),"createApiClient"),Jr=class{static{s(this,"H")}constructor(e){this.useProxy=!1,this.version=kt,this.items={list:f(n=>this.handlePaginatedRequest(ki({query:n,client:this.useProxy?this.proxyClient:this.directClient})),"list"),create:f(n=>this.handleRequest(Ri({body:n,client:this.useProxy?this.proxyClient:this.directClient})),"create"),delete:f(n=>this.handleRequest(Ai({body:{itemIds:n},client:this.useProxy?this.proxyClient:this.directClient})),"delete"),findById:f(n=>this.handleRequest(Ti({path:{itemId:n},client:this.useProxy?this.proxyClient:this.directClient})),"findById"),updateById:f((n,i)=>this.handleRequest(_i({body:i,path:{itemId:n},client:this.useProxy?this.proxyClient:this.directClient})),"updateById"),deleteById:f(n=>this.handleRequest(Pi({path:{itemId:n},client:this.useProxy?this.proxyClient:this.directClient})),"deleteById"),setListsById:f((n,i)=>this.handleRequest(Oi({body:{listIds:i},path:{itemId:n},client:this.useProxy?this.proxyClient:this.directClient})),"setListsById"),count:f(()=>this.handleRequest(Di({client:this.useProxy?this.proxyClient:this.directClient})),"count")},this.lists={list:f(n=>this.handlePaginatedRequest(gi({query:n,client:this.useProxy?this.proxyClient:this.directClient})),"list"),create:f(n=>this.handleRequest(Ii({body:n,client:this.useProxy?this.proxyClient:this.directClient})),"create"),findById:f(n=>this.handleRequest(bi({path:{listId:n},client:this.useProxy?this.proxyClient:this.directClient})),"findById"),updateById:f((n,i)=>this.handleRequest(Ei({body:i,path:{listId:n},client:this.useProxy?this.proxyClient:this.directClient})),"updateById"),deleteById:f(n=>this.handleRequest(wi({path:{listId:n},client:this.useProxy?this.proxyClient:this.directClient})),"deleteById"),orderItems:f((n,i)=>this.handleRequest(Ci({body:{itemIds:i},path:{listId:n},client:this.useProxy?this.proxyClient:this.directClient})),"orderItems"),addItemsToList:f((n,i)=>this.handleRequest(xi({body:{itemIds:i},path:{listId:n},client:this.useProxy?this.proxyClient:this.directClient})),"addItemsToList"),removeItemFromList:f((n,i)=>this.handleRequest(Si({path:{listId:n,itemId:i},client:this.useProxy?this.proxyClient:this.directClient})),"removeItemFromList")},this.profiles={customerAccountsVersion:f(()=>this.handleRequest(Li({client:this.useProxy?this.proxyClient:this.directClient})),"customerAccountsVersion"),createToken:f((n={},i)=>this.handleRequest(Bi({body:n,client:this.useProxy||i!=null&&i.useProxy?this.proxyClient:this.directClient})),"createToken"),identify:f(n=>this.handleRequest($i({body:n,client:this.useProxy?this.proxyClient:this.directClient})),"identify")},this.orders={list:f(n=>this.handlePaginatedRequest(qi({query:n,client:this.useProxy?this.proxyClient:this.directClient})),"list"),findById:f(n=>this.handleRequest(Vi({path:{orderId:n},client:this.useProxy?this.proxyClient:this.directClient})),"findById")},this.handleRequest=f(async n=>{let{data:i,error:o}=await n;return o!=null&&o.error?{error:o.error}:{data:i?.data}},"handleRequest"),this.handlePaginatedRequest=f(async n=>{var i;let{data:o,error:a}=await n;return a!=null&&a.error?{error:a.error}:{data:o?.data??[],pageInfo:o?.pageInfo??{next:null,previous:null,totalCount:((i=o?.data)==null?void 0:i.length)??0}}},"handlePaginatedRequest");var t;this.profile=e.profile,(t=e.config)!=null&&t.version&&(this.version=e.config.version),this.directClient=At(Ue({baseUrl:`https://swish.app/api/${this.version}`})),this.proxyClient=At(Ue({baseUrl:Fr})),e.authToken&&(this.authToken=e.authToken),e.config&&this.setConfig(e.config),e.requestInterceptor&&(this.proxyClient.interceptors.request.use(e.requestInterceptor),this.directClient.interceptors.request.use(e.requestInterceptor)),e.responseInterceptor&&(this.proxyClient.interceptors.response.use(e.responseInterceptor),this.directClient.interceptors.response.use(e.responseInterceptor)),this.proxyClient.interceptors.request.use(this.proxyRequestInterceptor.bind(this)),this.directClient.interceptors.request.use(this.directRequestInterceptor.bind(this))}setProfile(e){this.profile=e}getProfile(){return this.profile}setAuthToken(e){this.authToken=e}setConfig({proxyBaseUrl:e=Fr,baseUrl:t,useProxy:n=!1,...i}){this.useProxy=n,this.proxyClient.setConfig({...i,baseUrl:e}),this.directClient.setConfig({...i})}proxyRequestInterceptor(e){return this.profile&&(e.headers.set("Profile",this.profile),e.headers.set("Swish-Api-Version",this.version)),e}directRequestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),e}};f(Jr,"SwishClient");var Ui=Jr;var Zr=s(r=>r?JSON.parse(atob(r.split(".")[1])):null,"getTokenData"),en=s((r,e=60)=>{let t=Zr(r);return t?t.exp&&t.exp<Date.now()/1e3+e:!1},"isTokenExpired"),tn=s(r=>{let e=Zr(r);return e?e.sub.startsWith("gid://shopify/Customer/"):!1},"isCustomerToken");var on=gn(sn(),1);var an=s(r=>new on.default(async e=>{let t=[...new Set(e)].sort((i,o)=>i.localeCompare(o)),n=await r.items.list({query:t.join(" "),limit:200});return"error"in n?(console.error("Failed to load items",n.error),e.map(()=>({data:[],pageInfo:{next:null,previous:null,totalCount:0}}))):e.map(i=>{let o=n.data.find(a=>i===`variant:${a.variantId}`||i===`product:${a.productId}`);return{data:o?[o]:[],pageInfo:{next:null,previous:null,totalCount:o?1:0}}})},{batchScheduleFn:s(e=>setTimeout(e,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var se={profile:{get:s(()=>localStorage.getItem("swish-profile")??void 0,"get"),set:s(r=>localStorage.setItem("swish-profile",r),"set"),delete:s(()=>localStorage.removeItem("swish-profile"),"delete")},authToken:{get:s(()=>sessionStorage.getItem("swish-token")??void 0,"get"),set:s(r=>sessionStorage.setItem("swish-token",r),"set"),delete:s(()=>sessionStorage.removeItem("swish-token"),"delete")}},Ge=class{static{s(this,"SwishApi")}constructor(e,t,n){this.config=e,this.context=t,this.cache=new Q("swish-api","max-age=60, stale-while-revalidate=3600",n+(e.version??kt)),this.cache.cleanupExpiredEntries().catch(a=>{console.warn("Swish API cache initialization cleanup error:",a)});let i=se.profile.get(),o=se.authToken.get();this.apiClient=Yr({profile:i,authToken:o,proxyMode:this.config.proxyMode,config:{...e,fetch:s((a,u)=>(a instanceof Request?a.method:u?.method??"GET")==="GET"?this.cache.fetchWithCache(a,u):fetch(a,u),"fetch")},requestInterceptor:s(async a=>{let u=new URL(a.url,window.location.origin),l=this.config.proxyBaseUrl??"/apps/wishlist/api",c=u.pathname==="/profiles/token";return!u.pathname.startsWith(l)&&!c&&await this.bootstrapAuth(),a},"requestInterceptor"),responseInterceptor:s(async(a,u)=>(this.processProfileHeader(a),u.method!=="GET"&&await this.cache.clear(),await this.config.responseInterceptor?.(a,u),a),"responseInterceptor")}),this.itemsLoader=an(this)}async bootstrapAuth(){if(this._bootstrapAuthPromise)return this._bootstrapAuthPromise;this._bootstrapAuthPromise=(async()=>{let e=se.authToken.get();if(e)try{if(en(e,60))throw new Error("TOKEN_EXPIRED")}catch(o){(!(o instanceof Error)||o.message!=="TOKEN_EXPIRED")&&console.error("Failed to decode cached auth token",{cause:o}),se.authToken.delete(),e=void 0}if(e){this.apiClient.setAuthToken(e);return}let t=this.apiClient.getProfile(),n=this.config.customerId,i=await this.apiClient.profiles.createToken({customer:n,session:t},{useProxy:!0});if("error"in i){console.error("Failed to bootstrap auth with error",i.error);return}if(!i.data?.token){console.error("Failed to bootstrap auth with no token");return}se.authToken.set(i.data.token),this.apiClient.setAuthToken(i.data.token)})();try{return await this._bootstrapAuthPromise}finally{this._bootstrapAuthPromise=void 0}}processProfileHeader(e){let t=e.headers.get("Set-Profile");t?(this.apiClient.setProfile(t),se.profile.set(t)):t===""&&se.profile.delete()}get items(){return{...this.apiClient.items,list:s(async(e,t)=>{if(!this.config.customerId&&!this.apiClient.getProfile())return{data:[],pageInfo:{next:null,previous:null,totalCount:0}};if(t?.batch&&e?.query){e.limit!==1&&console.warn("Batching will always limit to 1 item");let n=e.query.split(" ");n.length>1&&console.warn("Batching will only support one query parameter");let i=n[0];if(!i.match(/^product:\d+$/)&&!i.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(i)}return this.apiClient.items.list(e)},"list"),findById:s(async e=>!this.config.customerId&&!this.apiClient.getProfile()?{data:null}:this.apiClient.items.findById(e),"findById")}}get lists(){return{...this.apiClient.lists,list:s(async e=>!this.config.customerId&&!this.apiClient.getProfile()?{data:[],pageInfo:{next:null,previous:null,totalCount:0}}:this.apiClient.lists.list(e),"list"),findById:s(async e=>!this.config.customerId&&!this.apiClient.getProfile()?{data:null}:this.apiClient.lists.findById(e),"findById")}}get orders(){return{...this.apiClient.orders,list:s(async e=>!this.context.customer.id&&!this.apiClient.getProfile()?{data:[],pageInfo:{next:null,previous:null,totalCount:0}}:this.apiClient.orders.list(e),"list"),findById:s(async e=>!this.context.customer.id&&!this.apiClient.getProfile()?{data:null}:this.apiClient.orders.findById(e),"findById")}}get profiles(){return this.apiClient.profiles}async clearCache(){await this.cache.clear()}};var Me=class{constructor(e){this.eventMap={"POST /items\\/?$":"item-create","DELETE /items\\/?$":"item-delete","PATCH /items\\/([^/]+)\\/?$":"item-update","DELETE /items\\/([^/]+)\\/?$":"item-delete","PUT /items\\/([^/]+)\\/lists\\/?$":"item-lists-update","POST /lists\\/?$":"list-create","DELETE /lists\\/?$":"list-delete","PATCH /lists\\/([^/]+)\\/?$":"list-update","DELETE /lists\\/([^/]+)\\/?$":"list-delete"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{s(this,"SwishApiPublisher")}async processFetchResponse(e,t){try{let n=this.getEventName(t.method,e.status,t.url);if(!n)return;let i=await e.clone().text();if(e.headers.get("Content-Type")?.includes("application/json"))try{i=JSON.parse(i).data}catch(o){console.warn(o)}this.eventBus.publish(n,i)}catch(n){console.warn(n)}}getEventName(e,t,n){e=e.toUpperCase();let i=new URL(n).pathname;return e==="GET"||t<200||t>=300?void 0:Object.entries(this.eventMap).find(([a])=>{let[u,l]=a.split(" ");return u!==e?!1:new RegExp(l).test(i)})?.[1]}};var Xi=typeof HTMLElement<"u"?HTMLElement:class{},je=class extends Xi{constructor(){super();this.getComponentRef=s(()=>this.componentRef,"getComponentRef");this.setComponentRef=s(t=>{this.componentRef=t},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let t=this.querySelector("template");t&&this.shadowRoot&&(this.shadowRoot.appendChild(t.content),t.remove())}static{s(this,"SwishUiElement")}};var Fe=class{static{s(this,"ShopifyBadgesUtils")}#e;constructor({getBadges:e}){this.#e=e?.bind(this)}getBadges({product:e,variant:t}){try{let n=this.getDefaultBadges({product:e,variant:t});return this.#e?this.mapBadges(this.#e({product:e,variant:t,defaultBadges:n})??[]):this.mapBadges(n)}catch(n){return console.error("Error getting badges",n),[]}}getDefaultBadges({product:e,variant:t}){let n=[];if(e?.availableForSale===!1||t?.availableForSale===!1)return n.push("Sold out"),n;let i=t?t.price.amount:e?.priceRange?.minVariantPrice.amount,o=t?t.compareAtPrice?.amount:e?.compareAtPriceRange?.minVariantPrice.amount;return o&&parseFloat(o)>parseFloat(i)&&n.push("Sale"),n}mapBadges(e){return e.map(t=>typeof t=="string"?{id:t.toLowerCase().replace(/[^a-z0-9]/g,"_"),label:t}:t)}};var un=s(r=>{let e=r.proxy?.baseUrl??"/apps/wishlist";return{proxy:{baseUrl:e},storefrontApi:{storeDomain:r.storefrontApi?.storeDomain??"",accessToken:r.storefrontApi?.accessToken??""},storefrontContext:{...r.storefrontContext,localization:{country:r.storefrontContext.localization.country.toUpperCase(),language:r.storefrontContext.localization.language.toUpperCase(),market:r.storefrontContext.localization.market}},badges:{getBadges:r.badges?.getBadges??(({defaultBadges:t})=>t)},metafields:{product:r.metafields?.product??[],productVariant:r.metafields?.productVariant??[]},swishApi:{version:r.swishApi?.version??"2026-01"},swishUi:{baseUrl:r.swishUi?.baseUrl??`${e}/assets`,components:{productRow:{showVariantTitle:r.swishUi?.components?.productRow?.showVariantTitle??!1},productDetail:{descriptionMaxLines:r.swishUi?.components?.productDetail?.descriptionMaxLines??4},variantSelect:{displayType:r.swishUi?.components?.variantSelect?.displayType??"pills"},imageSlider:{flush:r.swishUi?.components?.imageSlider?.flush??!1,loop:r.swishUi?.components?.imageSlider?.loop??!1},images:{baseTint:r.swishUi?.components?.images?.baseTint??!1},buyButtons:{shopPay:r.swishUi?.components?.buyButtons?.shopPay??!1},listDetailPage:{desktopColumns:r.swishUi?.components?.listDetailPage?.desktopColumns??4,showBuyButton:r.swishUi?.components?.listDetailPage?.showBuyButton??!0},drawer:{title:r.swishUi?.components?.drawer?.title??"",logo:{url:r.swishUi?.components?.drawer?.logo?.url??"",altText:r.swishUi?.components?.drawer?.logo?.altText??""},navigation:{variant:r.swishUi?.components?.drawer?.navigation?.variant??"floating",items:r.swishUi?.components?.drawer?.navigation?.items??[{id:"home",enabled:!0,href:"/"},{id:"items",enabled:!0,href:"/items"},{id:"lists",enabled:!0,href:"/lists"},{id:"chat",enabled:!1,href:"/chat"},{id:"orders",enabled:!0,href:"/orders"},{id:"profile",enabled:!0,href:"/profile"}]},miniMenu:{items:r.swishUi?.components?.drawer?.miniMenu?.items??[]}}},css:r.swishUi?.css??[],intents:{save:{requireVariant:r.swishUi?.intents?.save?.requireVariant??!1,showToast:r.swishUi?.intents?.save?.showToast??!1},edit:{showToast:r.swishUi?.intents?.edit?.showToast??!1},unsave:{requireConfirmation:r.swishUi?.intents?.unsave?.requireConfirmation??!1,openEditor:r.swishUi?.intents?.unsave?.openEditor??!1,showToast:r.swishUi?.intents?.unsave?.showToast??!1}},theme:r.swishUi?.theme??{},version:r.swishUi?.version??"0.40.0"}}},"createSwishOptions");var Ki=".swish-shop-bridge{position:absolute!important;top:0!important;left:0!important;padding:0!important;border:0!important;margin:0!important;pointer-events:none!important}.swish-shop-bridge input{appearance:none!important;border:none!important;width:1px!important;height:1px!important;padding:0!important;margin:0!important;background:rgba(0,0,0,0)!important}",Yi=s(()=>{let r="/";return typeof window<"u"&&(r=window.location.pathname),`<form class=swish-shop-bridge data-login-with-shop-sign-in=true id=customer_login><input name=customer[email] id=customer_login_email> <input name=return_url type=hidden value=${r}></form>`},"getHtml"),Ji=typeof HTMLElement<"u"?HTMLElement:class{},Tt=class extends Ji{static{s(this,"ShopBridge")}get swish(){return typeof window<"u"?window.swish:void 0}constructor(){super(),this.emailInput=this.querySelector('form[data-login-with-shop-sign-in] input[type="email"],form[data-login-with-shop-sign-in] input[name="customer[email]"'),this.emailInput||(this.innerHTML=`
443
- <style>${Ki}</style>
444
- ${Yi()}
445
- `,this.emailInput=this.querySelector("#customer_login_email")),this.shopModalObserver=new MutationObserver(e=>{e.forEach(t=>{t.attributeName==="style"&&document.documentElement.style.overflow==="hidden"&&this.dispatchEvent(new CustomEvent("shop-modal-open"))})}),this.shopModalObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["style"]})}disconnectedCallback(){this.shopModalObserver?.disconnect()}async load(){try{(window.Shopify?.featureAssets?.["shop-js"]?.["init-customer-accounts"]?.[0]??"").includes("init-customer-accounts")&&window.Shopify?.SignInWithShop?.initCustomerAccounts?.(!0,{fedCMEnabled:!0,windoidEnabled:!1})}catch(e){console.warn("Failed to initialize Shop JS",e)}}update(e){if(e.email&&(this.emailInput.value=e.email,this.emailInput.dispatchEvent(new Event("input"))),e.returnTo){let t=this.querySelector("input[name='return_url']");t&&(t.value=e.returnTo)}}};typeof customElements<"u"&&customElements.define("swish-shop-bridge",Tt);var He=class{constructor(e,t){this.inflightModals=new Map;this.eventListeners=new Map;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this._lockScroll=s(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=s(()=>this.unlockScroll(),"_unlockScroll");this.swishUiOptions=e,this.storefrontContext=t}static{s(this,"SwishUi")}async hideModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{typeof e=="string"&&(e=await this.requireUiComponent(e)),!(!e||e.getAttribute("open")!=="true")&&e.setAttribute("open","false")})().finally(()=>{this.inflightModals.delete(e)});return this.unlockScroll(),this.inflightModals.set(e,t),t}async showModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{typeof e=="string"&&(e=await this.requireUiComponent(e)),!(!e||e.getAttribute("open")==="true")&&e.setAttribute("open","true")})().finally(()=>{this.inflightModals.delete(e)});return this.lockScroll(),this.inflightModals.set(e,t),t}async showSignIn(e){let t=await this.requireUiComponent("sign-in",{listeners:{close:s(()=>e?.onClose?.(),"close")}});t.setAttribute("return-to",e?.returnTo??window.location.pathname),await this.showModal(t)}async showUnsaveAlert(e){if(!e.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let t=await this.requireUiComponent("unsave-alert",{listeners:{submit:s(n=>{n instanceof CustomEvent?e.onSubmit?.(n.detail):console.warn("Unsave alert submitted without detail",n)},"submit"),close:s(()=>{e.onClose?.()},"close")}});t.setAttribute("item-id",e.itemId),await this.showModal(t)}async showDeleteListAlert(e){if(!e.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let t=await this.requireUiComponent("delete-list-alert",{listeners:{submit:s(()=>{e.onSubmit?.()},"submit"),close:s(()=>{e.onClose?.()},"close")}});t.setAttribute("list-id",e.listId),await this.showModal(t)}async showDrawer(e){await this.hideAllToasts();let t=await this.requireUiComponent("drawer",{listeners:{close:s(()=>{e?.onClose?.()},"close")}});t.setAttribute("account-url",this.storefrontContext.routes.accountUrl),this.storefrontContext.customer.id&&t.setAttribute("customer-id",this.storefrontContext.customer.id),await this.showModal(t)}async showListMenu(e){if(!e.listId)throw new Error("listId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-menu",{listeners:{close:s(n=>{e.onClose?.()},"close"),edit:s(n=>{n instanceof CustomEvent?e.onEdit?.(n.detail):console.warn("List menu submitted without detail",n)},"edit"),delete:s(n=>{n instanceof CustomEvent?e.onDelete?.():console.warn("List menu deleted without detail",n)},"delete")}});t.setAttribute("list-id",e.listId),await this.showModal(t)}async showListSelect(e){if(!e.itemId)throw new Error("itemId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-select",{listeners:{submit:s(async n=>{"detail"in n&&n.detail?e?.onSubmit?.(n.detail):console.warn("List select form submitted without detail",n)},"submit"),close:s(()=>{e.onClose?.()},"close"),unsave:s(n=>{n instanceof CustomEvent?e.onUnsave?.(n.detail):console.warn("List select unsave without detail",n)},"unsave")}});t.setAttribute("item-id",e.itemId),await this.showModal(t)}async initListDetailPage(e,t){let n=await this.requireUiComponent("list-detail-page",{refElement:t});e.listId&&n.setAttribute("list-id",e.listId)}async showToast(e){await this.requireUiComponent("toast-manager",{onHydrated:s(t=>{t.current.show(e)},"onHydrated")})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{onHydrated:s(e=>{e.current.clear()},"onHydrated")})}async showVariantSelect(e){await this.hideAllToasts();let t=await this.requireUiComponent("variant-select",{listeners:{submit:s(async n=>{"detail"in n&&n.detail?e?.onSubmit?.(n.detail):console.warn("Variant select form submitted without detail",n)},"submit"),close:s(()=>{e?.onClose?.()},"close")}});if(e?.productId)t.setAttribute("product-id",e.productId);else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("Either productId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId),e?.displayType&&t.setAttribute("display-type",e.displayType),await this.showModal(t)}async showQuickBuy(e){await this.hideAllToasts();let t=await this.requireUiComponent("quick-buy",{listeners:{submit:s(async n=>{"detail"in n&&n.detail?e?.onSubmit?.(n.detail):console.warn("Quick buy form submitted without detail",n)},"submit"),close:s(()=>{e?.onClose?.()},"close")}});if(e?.productId)t.setAttribute("product-id",e.productId);else throw new Error("ProductId must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId),await this.showModal(t)}async showListEditor(e){let t=await this.requireUiComponent("list-editor",{listeners:{submit:s(async n=>{"detail"in n&&n.detail?e?.onSubmit?.(n.detail):console.warn("List editor form submitted without detail",n)},"submit"),close:s(()=>{e?.onClose?.()},"close")}});e?.listId&&t.setAttribute("list-id",e.listId),await this.showModal(t)}async initShopBridge({onShopModalOpen:e}){let t=document.querySelector("swish-shop-bridge");if(t||(document.body.insertAdjacentHTML("beforeend","<swish-shop-bridge></swish-shop-bridge>"),t=document.querySelector("swish-shop-bridge")),!t)throw new Error("Failed to initialize Shop Bridge");return t.addEventListener("shop-modal-open",()=>e(),{once:!0}),await t.load(),t}async requireUiComponent(e,t){this.loadCricalResources();let n=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.html`,i=await fetch(n).then(l=>l.text()),o=t?.instance,a=t?.listeners,u=this.queryComponent(e,o)??await this.insertComponent({name:e,template:i,refElement:t?.refElement??document.body,position:"beforeend",instance:o});if(u.shadowRoot&&!u.hasAttribute("hydrated")){let l=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.js`;Promise.all([this.loadNonCriticalResources(),import(l)]).then(([{bundleCssStylesheet:c,customCssStylesheets:p},{hydrate:d}])=>{u.shadowRoot&&c&&(u.shadowRoot.adoptedStyleSheets=[...u.shadowRoot.adoptedStyleSheets,...p,c],u.shadowRoot?.querySelector(":host > style")?.remove()),d(u),u.setAttribute("hydrated",""),t?.onHydrated?.(u.getComponentRef())})}else u.hasAttribute("hydrated")&&t?.onHydrated?.(u.getComponentRef());for(let{event:l,listener:c}of this.eventListeners.values())u.removeEventListener(l,c);for(let[l,c]of Object.entries(a??{}))this.eventListeners.set(`${e}-${o}-${l}`,{event:l,listener:c}),u.addEventListener(l,c);return u}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/theme.css`,t=await fetch(e).then(i=>i.text()),n=new CSSStyleSheet;return n.replaceSync(t),this.swishUiOptions.theme&&Object.entries(this.swishUiOptions.theme).forEach(([i,o])=>{n.cssRules[0].cssRules[0].style.setProperty(i,o)}),{themeVariablesStylesheet:n}})(),this._loadCricalResourcesPromise)}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/bundle.css`,t=s(o=>{let a=new CSSStyleSheet;return a.replaceSync(o),a},"createCssStylesheet"),[n,...i]=await Promise.all([fetch(e).then(o=>o.text()).then(t),...this.swishUiOptions.css.map(async o=>o instanceof URL?t(await fetch(o).then(a=>a.text())):t(o))]);return{bundleCssStylesheet:n,customCssStylesheets:i}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:e,instance:t,template:n,position:i,refElement:o}){let{themeVariablesStylesheet:a}=await this.loadCricalResources();o.insertAdjacentHTML(i,n.replace(' shadowrootmode="open"',""));let u=this.queryComponent(e,t);if(!u)throw new Error(`Element ${e} not found in DOM`);return u.shadowRoot&&(u.shadowRoot.adoptedStyleSheets=[a]),u}queryComponent(e,t){let n=`swish-ui[ref="${e}${t?`-${t}`:""}"]`;return document.querySelector(n)}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(`
440
+ `);v=Ot.pop()??"";for(let sr of Ot){let or=sr.split(`
441
+ `),fe=[],Lt;for(let M of or)if(M.startsWith("data:"))fe.push(M.replace(/^data:\s*/,""));else if(M.startsWith("event:"))Lt=M.replace(/^event:\s*/,"");else if(M.startsWith("id:"))f=M.replace(/^id:\s*/,"");else if(M.startsWith("retry:")){let qt=Number.parseInt(M.replace(/^retry:\s*/,""),10);Number.isNaN(qt)||(h=qt)}let J,$t=!1;if(fe.length){let M=fe.join(`
442
+ `);try{J=JSON.parse(M),$t=!0}catch{J=M}}$t&&(i&&await i(J),r&&(J=await r(J))),t?.({data:J,event:Lt,id:f,retry:h}),fe.length&&(yield J)}}}finally{y.removeEventListener("abort",T),w.releaseLock()}break}catch(O){if(e?.(O),u!==void 0&&D>=u)break;let k=Math.min(h*2**(D-1),a??3e4);await m(k)}}},"createStream")()}},"createSseClient"),ei=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),ti=d(n=>{switch(n){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),ni=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),Qn=d(({allowReserved:n,explode:e,name:t,style:r,value:i})=>{if(!e){let a=(n?i:i.map(l=>encodeURIComponent(l))).join(ti(r));switch(r){case"label":return`.${a}`;case"matrix":return`;${t}=${a}`;case"simple":return a;default:return`${t}=${a}`}}let o=ei(r),u=i.map(a=>r==="label"||r==="simple"?n?a:encodeURIComponent(a):Ue({allowReserved:n,name:t,value:a})).join(o);return r==="label"||r==="matrix"?o+u:u},"serializeArrayParam"),Ue=d(({allowReserved:n,name:e,value:t})=>{if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?t:encodeURIComponent(t)}`},"serializePrimitiveParam"),zn=d(({allowReserved:n,explode:e,name:t,style:r,value:i,valueOnly:o})=>{if(i instanceof Date)return o?i.toISOString():`${t}=${i.toISOString()}`;if(r!=="deepObject"&&!e){let l=[];Object.entries(i).forEach(([p,f])=>{l=[...l,p,n?f:encodeURIComponent(f)]});let c=l.join(",");switch(r){case"form":return`${t}=${c}`;case"label":return`.${c}`;case"matrix":return`;${t}=${c}`;default:return c}}let u=ni(r),a=Object.entries(i).map(([l,c])=>Ue({allowReserved:n,name:r==="deepObject"?`${t}[${l}]`:l,value:c})).join(u);return r==="label"||r==="matrix"?u+a:a},"serializeObjectParam"),ri=/\{[^{}]+\}/g,ii=d(({path:n,url:e})=>{let t=e,r=e.match(ri);if(r)for(let i of r){let o=!1,u=i.substring(1,i.length-1),a="simple";u.endsWith("*")&&(o=!0,u=u.substring(0,u.length-1)),u.startsWith(".")?(u=u.substring(1),a="label"):u.startsWith(";")&&(u=u.substring(1),a="matrix");let l=n[u];if(l==null)continue;if(Array.isArray(l)){t=t.replace(i,Qn({explode:o,name:u,style:a,value:l}));continue}if(typeof l=="object"){t=t.replace(i,zn({explode:o,name:u,style:a,value:l,valueOnly:!0}));continue}if(a==="matrix"){t=t.replace(i,`;${Ue({name:u,value:l})}`);continue}let c=encodeURIComponent(a==="label"?`.${l}`:l);t=t.replace(i,c)}return t},"defaultPathSerializer"),si=d(({baseUrl:n,path:e,query:t,querySerializer:r,url:i})=>{let o=i.startsWith("/")?i:`/${i}`,u=(n??"")+o;e&&(u=ii({path:e,url:u}));let a=t?r(t):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(u+=`?${a}`),u},"getUrl");function Wn(n){let e=n.body!==void 0;if(e&&n.bodySerializer)return"serializedBody"in n?n.serializedBody!==void 0&&n.serializedBody!==""?n.serializedBody:null:n.body!==""?n.body:null;if(e)return n.body}s(Wn,"K");d(Wn,"getValidRequestBody");var oi=d(async(n,e)=>{let t=typeof e=="function"?await e(n):e;if(t)return n.scheme==="bearer"?`Bearer ${t}`:n.scheme==="basic"?`Basic ${btoa(t)}`:t},"getAuthToken"),Xn=d(({allowReserved:n,array:e,object:t}={})=>d(r=>{let i=[];if(r&&typeof r=="object")for(let o in r){let u=r[o];if(u!=null)if(Array.isArray(u)){let a=Qn({allowReserved:n,explode:!0,name:o,style:"form",value:u,...e});a&&i.push(a)}else if(typeof u=="object"){let a=zn({allowReserved:n,explode:!0,name:o,style:"deepObject",value:u,...t});a&&i.push(a)}else{let a=Ue({allowReserved:n,name:o,value:u});a&&i.push(a)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),ai=d(n=>{var e;if(!n)return"stream";let t=(e=n.split(";")[0])==null?void 0:e.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},"getParseAs"),ui=d((n,e)=>{var t,r;return e?!!(n.headers.has(e)||(t=n.query)!=null&&t[e]||(r=n.headers.get("Cookie"))!=null&&r.includes(`${e}=`)):!1},"checkForExistence"),li=d(async({security:n,...e})=>{for(let t of n){if(ui(e,t.name))continue;let r=await oi(t,e.auth);if(!r)continue;let i=t.name??"Authorization";switch(t.in){case"query":e.query||(e.query={}),e.query[i]=r;break;case"cookie":e.headers.append("Cookie",`${i}=${r}`);break;case"header":default:e.headers.set(i,r);break}}},"setAuthParams"),Fn=d(n=>si({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:Xn(n.querySerializer),url:n.url}),"buildUrl"),Hn=d((n,e)=>{var t;let r={...n,...e};return(t=r.baseUrl)!=null&&t.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=Kn(n.headers,e.headers),r},"mergeConfigs"),ci=d(n=>{let e=[];return n.forEach((t,r)=>{e.push([r,t])}),e},"headersEntries"),Kn=d((...n)=>{let e=new Headers;for(let t of n){if(!t)continue;let r=t instanceof Headers?ci(t):Object.entries(t);for(let[i,o]of r)if(o===null)e.delete(i);else if(Array.isArray(o))for(let u of o)e.append(i,u);else o!==void 0&&e.set(i,typeof o=="object"?JSON.stringify(o):o)}return e},"mergeHeaders"),Yn=class{static{s(this,"$")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e=="number"?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let r=this.getInterceptorIndex(e);return this.fns[r]?(this.fns[r]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};d(Yn,"Interceptors");var xt=Yn,pi=d(()=>({error:new xt,request:new xt,response:new xt}),"createInterceptors"),di=Xn({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),fi={"Content-Type":"application/json"},Ve=d((n={})=>({...Yr,headers:fi,parseAs:"auto",querySerializer:di,...n}),"createConfig"),At=d((n={})=>{let e=Hn(Ve(),n),t=d(()=>({...e}),"getConfig"),r=d(c=>(e=Hn(e,c),t()),"setConfig"),i=pi(),o=d(async c=>{let p={...e,...c,fetch:c.fetch??e.fetch??globalThis.fetch,headers:Kn(e.headers,c.headers),serializedBody:void 0};p.security&&await li({...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=Fn(p);return{opts:p,url:f}},"beforeRequest"),u=d(async c=>{let{opts:p,url:f}=await o(c),m={redirect:"follow",...p,body:Wn(p)},h=new Request(f,m);for(let v of i.request.fns)v&&(h=await v(h,p));let D=p.fetch,y=await D(h);for(let v of i.response.fns)v&&(y=await v(y,h,p));let x={request:h,response:y};if(y.ok){let v=(p.parseAs==="auto"?ai(y.headers.get("Content-Type")):p.parseAs)??"json";if(y.status===204||y.headers.get("Content-Length")==="0"){let P;switch(v){case"arrayBuffer":case"blob":case"text":P=await y[v]();break;case"formData":P=new FormData;break;case"stream":P=y.body;break;case"json":default:P={};break}return p.responseStyle==="data"?P:{data:P,...x}}let T;switch(v){case"arrayBuffer":case"blob":case"formData":case"json":case"text":T=await y[v]();break;case"stream":return p.responseStyle==="data"?y.body:{data:y.body,...x}}return v==="json"&&(p.responseValidator&&await p.responseValidator(T),p.responseTransformer&&(T=await p.responseTransformer(T))),p.responseStyle==="data"?T:{data:T,...x}}let O=await y.text(),k;try{k=JSON.parse(O)}catch{}let F=k??O,w=F;for(let v of i.error.fns)v&&(w=await v(F,y,h,p));if(w=w||{},p.throwOnError)throw w;return p.responseStyle==="data"?void 0:{error:w,...x}},"request"),a=d(c=>p=>u({...p,method:c}),"makeMethodFn"),l=d(c=>async p=>{let{opts:f,url:m}=await o(p);return Zr({...f,body:f.body,headers:f.headers,method:c,onRequest:d(async(h,D)=>{let y=new Request(h,D);for(let x of i.request.fns)x&&(y=await x(y,f));return y},"onRequest"),url:m})},"makeSseFn");return{buildUrl:Fn,connect:a("CONNECT"),delete:a("DELETE"),get:a("GET"),getConfig:t,head:a("HEAD"),interceptors:i,options:a("OPTIONS"),patch:a("PATCH"),post:a("POST"),put:a("PUT"),request:u,setConfig:r,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:a("TRACE")}},"createClient"),I=At(Ve({baseUrl:"https://swish.app/api/2026-01"})),hi=d(n=>(n?.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n}),"listControllerFind"),yi=d(n=>(n.client??I).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerCreate"),mi=d(n=>(n.client??I).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerDeleteById"),vi=d(n=>(n.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerFindById"),gi=d(n=>(n.client??I).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerUpdateById"),Ii=d(n=>(n.client??I).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerSetListItemsOrder"),wi=d(n=>(n.client??I).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerAddItemsToList"),bi=d(n=>(n.client??I).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...n}),"listControllerRemoveItemFromList"),Ei=d(n=>(n.client??I).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerDelete"),Si=d(n=>(n?.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...n}),"itemControllerFind"),Ci=d(n=>(n.client??I).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerCreate"),xi=d(n=>(n?.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...n}),"itemControllerCount"),Ai=d(n=>(n.client??I).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerDeleteById"),ki=d(n=>(n.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerFindById"),Ri=d(n=>(n.client??I).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerUpdateById"),Di=d(n=>(n.client??I).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerSetListsById"),Ti=d(n=>(n.client??I).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerIdentify"),Pi=d(n=>(n.client??I).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerCreateToken"),_i=d(n=>(n?.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...n}),"profileControllerGetProfile"),Oi=d(n=>(n.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...n}),"analyticsControllerLoadSavedItems"),Li=d(n=>(n.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...n}),"analyticsControllerLoadSessions"),$i=d(n=>(n.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...n}),"analyticsControllerLoadNewLists"),qi=d(n=>(n.client??I).post({security:[{scheme:"bearer",type:"http"}],url:"/tracking",...n,headers:{"Content-Type":"application/json",...n.headers}}),"trackingControllerTrack"),Bi=d(n=>(n?.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...n}),"ordersControllerFind"),Vi=d(n=>(n.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...n}),"ordersControllerFindOne"),Ui=d(n=>(n.client??I).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}/save",...n}),"sharedListsControllerSave"),Ni=d(n=>(n.client??I).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerDeleteById"),Gi=d(n=>(n.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerFindById"),Mi=d(n=>(n?.client??I).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...n}),"sharedListsControllerFindAll"),kt="2026-01",Jn=d(n=>new ji(n),"createApiClient"),Zn=class{static{s(this,"H")}constructor(e){this.version=kt,this.items={list:d(a=>this.handlePaginatedRequest(Si({query:a,client:this.directClient})),"list"),create:d(a=>this.handleRequest(Ci({body:a,client:this.directClient})),"create"),delete:d(a=>this.handleRequest(Ei({body:{itemIds:a},client:this.directClient})),"delete"),findById:d(a=>this.handleRequest(ki({path:{itemId:a},client:this.directClient})),"findById"),updateById:d((a,l)=>this.handleRequest(Ri({body:l,path:{itemId:a},client:this.directClient})),"updateById"),deleteById:d(a=>this.handleRequest(Ai({path:{itemId:a},client:this.directClient})),"deleteById"),setListsById:d((a,l)=>this.handleRequest(Di({body:{listIds:l},path:{itemId:a},client:this.directClient})),"setListsById"),count:d(()=>this.handleRequest(xi({client:this.directClient})),"count")},this.lists={list:d(a=>this.handlePaginatedRequest(hi({query:a,client:this.directClient})),"list"),create:d(a=>this.handleRequest(yi({body:a,client:this.directClient})),"create"),findById:d(a=>this.handleRequest(vi({path:{listId:a},client:this.directClient})),"findById"),updateById:d((a,l)=>this.handleRequest(gi({body:l,path:{listId:a},client:this.directClient})),"updateById"),deleteById:d(a=>this.handleRequest(mi({path:{listId:a},client:this.directClient})),"deleteById"),orderItems:d((a,l)=>this.handleRequest(Ii({body:{itemIds:l},path:{listId:a},client:this.directClient})),"orderItems"),addItemsToList:d((a,l)=>this.handleRequest(wi({body:{itemIds:l},path:{listId:a},client:this.directClient})),"addItemsToList"),removeItemFromList:d((a,l)=>this.handleRequest(bi({path:{listId:a,itemId:l},client:this.directClient})),"removeItemFromList")},this.profiles={createToken:d((a={})=>this.handleRequest(Pi({body:a,client:this.proxyClient??this.directClient})),"createToken"),identify:d(a=>this.handleRequest(Ti({body:a,client:this.directClient})),"identify"),getProfile:d(()=>this.handleRequest(_i({client:this.directClient})),"getProfile")},this.orders={list:d(a=>this.handlePaginatedRequest(Bi({query:a,client:this.directClient})),"list"),findById:d(a=>this.handleRequest(Vi({path:{orderId:a},client:this.directClient})),"findById")},this.sharedLists={list:d(a=>this.handlePaginatedRequest(Mi({query:a,client:this.directClient})),"list"),save:d(a=>this.handleRequest(Ui({path:{listId:a},client:this.directClient})),"save"),findById:d(a=>this.handleRequest(Gi({path:{listId:a},client:this.directClient})),"findById"),deleteById:d(a=>this.handleRequest(Ni({path:{listId:a},client:this.directClient})),"deleteById")},this.analytics={savedItems:d(a=>this.handleRequest(Oi({query:a,client:this.directClient})),"savedItems"),sessions:d(a=>this.handleRequest(Li({query:a,client:this.directClient})),"sessions"),newLists:d(a=>this.handleRequest($i({query:a,client:this.directClient})),"newLists")},this.tracking={track:d((a,l)=>this.handleRequest(qi({body:a,headers:l,client:this.directClient})),"track")},this.handleRequest=d(async a=>{let{data:l,error:c}=await a;return c!=null&&c.error?{error:c.error}:{data:l?.data}},"handleRequest"),this.handlePaginatedRequest=d(async a=>{var l;let{data:c,error:p}=await a;return p!=null&&p.error?{error:p.error}:{data:c?.data??[],pageInfo:c?.pageInfo??{next:null,previous:null,totalCount:((l=c?.data)==null?void 0:l.length)??0}}},"handlePaginatedRequest");var t,r,i,o,u;(t=e.config)!=null&&t.version&&(this.version=e.config.version),this.directClient=At(Ve({baseUrl:`https://swish.app/api/${this.version}`,...e.config})),(r=e.config)!=null&&r.authProxy&&(this.proxyClient=At(Ve({...e.config,baseUrl:e.config.authProxy}))),e.authToken&&(this.authToken=e.authToken),e.requestInterceptor&&((i=this.proxyClient)==null||i.interceptors.request.use(e.requestInterceptor),this.directClient.interceptors.request.use(e.requestInterceptor)),e.responseInterceptor&&((o=this.proxyClient)==null||o.interceptors.response.use(e.responseInterceptor),this.directClient.interceptors.response.use(e.responseInterceptor)),(u=this.proxyClient)==null||u.interceptors.request.use(this.proxyRequestInterceptor.bind(this)),this.directClient.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(e){this.authToken=e}proxyRequestInterceptor(e){return this.version&&e.headers.set("Swish-Api-Version",this.version),e}directRequestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),e}};d(Zn,"SwishClient");var ji=Zn;var rr=hr(nr(),1);var ir=s(n=>new rr.default(async e=>{let t=[...new Set(e)].sort((i,o)=>i.localeCompare(o)),r=await n.items.list({query:t.join(" "),limit:200});return"error"in r?(console.error("Failed to load items",r.error),e.map(()=>({data:[],pageInfo:{next:null,previous:null,totalCount:0}}))):e.map(i=>{let o=r.data.find(u=>i===`variant:${u.variantId}`||i===`product:${u.productId}`);return{data:o?[o]:[],pageInfo:{next:null,previous:null,totalCount:o?1:0}}})},{batchScheduleFn:s(e=>setTimeout(e,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var Ne=class{constructor(e,t){this.tokenHasProfile=!1;this.api=e,this.context=t}static{s(this,"SwishApiAuth")}hasProfile(){return this.tokenHasProfile}hasToken(){return!!this.getSwishToken()}async init(){this.migrateLegacySession();let e=this.context.customer.id;e?await this.initCustomer(e):(this.hasCustomerToken()&&await this.resetSession(),await this.initSession())}async initCustomer(e){let t=`gid://shopify/Customer/${e}`,r=this.getTokenBySub(t);if(r){this.initToken(r);return}let i=this.getSessionId();await this.acquireToken(i,t)}async initSession(){let e=this.getSessionId(),t=e?this.getTokenBySub(e):null;if(t){this.initToken(t);return}await this.acquireToken(e)}initToken(e){let t=this.getTokenData(e);if(!t)throw new Error("Invalid Swish token.");this.tokenHasProfile=t.has_profile!==!1,this.api.setAuthToken(e)}async acquireToken(e,t){let r=await this.api.profiles.createToken({customer:t,session:e});if("error"in r)throw console.error("Failed to create customer token",r.error),new Error("Failed to create customer token");if(!r.data?.token)throw console.error("Failed to create customer token empty response"),new Error("Failed to create customer token");r.data.profile.startsWith("gid://swish/Session/")&&this.setSessionId(r.data.profile),this.setSwishToken(r.data.token),this.initToken(r.data.token)}async resetSession(){this.deleteSessionId(),this.deleteSwishToken(),await this.api.clearCache()}getTokenData(e){try{return JSON.parse(atob(e.split(".")[1]))}catch(t){return console.error("Failed to parse Swish token",{cause:t}),null}}willTokenExpire(e,t=60){let r=this.getTokenData(e);return!!(r&&r.exp&&r.exp<Date.now()/1e3+t)}hasCustomerToken(){let e=this.getSwishToken();if(!e)return!1;let t=this.getTokenData(e);return t?t.sub.startsWith("gid://shopify/Customer/"):!1}getTokenBySub(e){if(!e)return null;let t=this.getSwishToken();if(!t)return null;let r=this.getTokenData(t);return!r||r.sub!==e||this.willTokenExpire(t,60)?null:t}getSessionId(){let e=this.context.myshopifyDomain.split(".")[0];return localStorage.getItem(`swish-session-${e}`)??void 0}setSessionId(e){let t=this.context.myshopifyDomain.split(".")[0];localStorage.setItem(`swish-session-${t}`,e)}deleteSessionId(){let e=this.context.myshopifyDomain.split(".")[0];localStorage.removeItem(`swish-session-${e}`)}getSwishToken(){return sessionStorage.getItem("swish-token")??void 0}setSwishToken(e){sessionStorage.setItem("swish-token",e)}deleteSwishToken(){sessionStorage.removeItem("swish-token")}migrateLegacySession(){try{let e=localStorage.getItem("wk_session_id")??localStorage.getItem("swish-profile")?.split("/").pop();e&&(this.setSessionId(`gid://swish/Session/${e}`),localStorage.removeItem("wk_session_id"),localStorage.removeItem("swish-profile"))}catch(e){console.warn("Failed to migrate legacy session id to Swish session",{cause:e})}}};var Ge=class{static{s(this,"SwishApi")}constructor(e,t,r){this.config=e,this.cache=new Q("swish-api","max-age=60, stale-while-revalidate=3600",r+(e.version??kt)),this.cache.cleanupExpiredEntries().catch(i=>{console.warn("Swish API cache initialization cleanup error:",i)}),this.auth=new Ne(this,t),this.apiClient=Jn({authToken:this.auth.getSwishToken(),config:{...e,fetch:s((i,o)=>(i instanceof Request?i.method:o?.method??"GET")==="GET"?this.cache.fetchWithCache(i,o):fetch(i,o),"fetch")},requestInterceptor:s(async i=>{let o=new URL(i.url,window.location.origin);return!!e.authProxy&&o.pathname.startsWith(e.authProxy)||await this.initAuth(),this.config.requestInterceptor&&(i=await this.config.requestInterceptor(i)),i},"requestInterceptor"),responseInterceptor:s(async(i,o)=>{let u=o.method!=="GET",a=o.url.includes("/profiles/token");if(u&&!a){let l=this.auth.hasToken(),c=!this.auth.hasProfile(),p=i.ok;await this.cache.clear(),l&&c&&p&&(this._initAuthPromise=void 0,this.initAuth())}return await this.config.responseInterceptor?.(i,o),i},"responseInterceptor")}),this.itemsLoader=ir(this)}async initAuth(){return this._initAuthPromise?this._initAuthPromise:(this._initAuthPromise=this.auth.init(),this._initAuthPromise)}setAuthToken(e){this.apiClient.setAuthToken(e)}withFallback(e,t){return this.auth.hasProfile()?e():Promise.resolve(t)}get items(){return{...this.apiClient.items,list:s(async(e,t)=>this.withFallback(()=>{if(t?.batch&&e?.query){e.limit!==1&&console.warn("Batching will always limit to 1 item");let r=e.query.split(" ");r.length>1&&console.warn("Batching will only support one query parameter");let i=r[0];if(!i.match(/^product:\d+$/)&&!i.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(i)}return this.apiClient.items.list(e)},{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:s(async e=>this.withFallback(()=>this.apiClient.items.findById(e),{data:null}),"findById")}}get lists(){return{...this.apiClient.lists,list:s(async e=>this.withFallback(()=>this.apiClient.lists.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:s(async e=>this.withFallback(()=>this.apiClient.lists.findById(e),{data:null}),"findById")}}get orders(){return{...this.apiClient.orders,list:s(async e=>this.withFallback(()=>this.apiClient.orders.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:s(async e=>this.withFallback(()=>(typeof e=="string"&&(e=parseInt(e.split("/").pop()??e)),this.apiClient.orders.findById(e)),{data:null}),"findById")}}get profiles(){return this.apiClient.profiles}async clearCache(){await this.cache.clear()}};var Me=class{constructor(e){this.eventMap={"POST /items\\/?$":"item-create","DELETE /items\\/?$":"item-delete","PATCH /items\\/([^/]+)\\/?$":"item-update","DELETE /items\\/([^/]+)\\/?$":"item-delete","PUT /items\\/([^/]+)\\/lists\\/?$":"item-lists-update","POST /lists\\/?$":"list-create","DELETE /lists\\/?$":"list-delete","PATCH /lists\\/([^/]+)\\/?$":"list-update","DELETE /lists\\/([^/]+)\\/?$":"list-delete"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{s(this,"SwishApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.method,e.status,t.url);if(!r)return;let i=await e.clone().text();if(e.headers.get("Content-Type")?.includes("application/json"))try{i=JSON.parse(i).data}catch(o){console.warn(o)}this.eventBus.publish(r,i)}catch(r){console.warn(r)}}getEventName(e,t,r){e=e.toUpperCase();let i=new URL(r).pathname;return e==="GET"||t<200||t>=300?void 0:Object.entries(this.eventMap).find(([u])=>{let[a,l]=u.split(" ");return a!==e?!1:new RegExp(l).test(i)})?.[1]}};var Zi=".swish-shop-bridge{position:absolute!important;top:0!important;left:0!important;padding:0!important;border:0!important;margin:0!important;pointer-events:none!important}.swish-shop-bridge input{appearance:none!important;border:none!important;width:1px!important;height:1px!important;padding:0!important;margin:0!important;background:rgba(0,0,0,0)!important}",es=s(()=>{let n="/";return typeof window<"u"&&(n=window.location.pathname),`<form class=swish-shop-bridge data-login-with-shop-sign-in=true id=customer_login><input name=customer[email] id=customer_login_email> <input name=return_url type=hidden value=${n}></form>`},"getHtml"),ts=typeof HTMLElement<"u"?HTMLElement:class{},Pt=class extends ts{static{s(this,"ShopBridge")}get swish(){return typeof window<"u"?window.swish:void 0}constructor(){super(),this.emailInput=this.querySelector('form[data-login-with-shop-sign-in] input[type="email"],form[data-login-with-shop-sign-in] input[name="customer[email]"'),this.emailInput||(this.innerHTML=`
443
+ <style>${Zi}</style>
444
+ ${es()}
445
+ `,this.emailInput=this.querySelector("#customer_login_email")),this.shopModalObserver=new MutationObserver(e=>{e.forEach(t=>{t.attributeName==="style"&&document.documentElement.style.overflow==="hidden"&&this.dispatchEvent(new CustomEvent("shop-modal-open"))})}),this.shopModalObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["style"]})}disconnectedCallback(){this.shopModalObserver?.disconnect()}async load(){try{(window.Shopify?.featureAssets?.["shop-js"]?.["init-customer-accounts"]?.[0]??"").includes("init-customer-accounts")&&window.Shopify?.SignInWithShop?.initCustomerAccounts?.(!0,{fedCMEnabled:!0,windoidEnabled:!1})}catch(e){console.warn("Failed to initialize Shop JS",e)}}update(e){if(e.email&&(this.emailInput.value=e.email,this.emailInput.dispatchEvent(new Event("input"))),e.returnTo){let t=this.querySelector("input[name='return_url']");t&&(t.value=e.returnTo)}}};typeof customElements<"u"&&customElements.define("swish-shop-bridge",Pt);var je=class{constructor(e,t){this.inflightModals=new Map;this.eventListeners=new Map;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this._lockScroll=s(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=s(()=>this.unlockScroll(),"_unlockScroll");this.swishUiOptions=e,this.storefrontContext=t}static{s(this,"SwishUi")}async hideModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{typeof e=="string"&&(e=await this.requireUiComponent(e)),!(!e||e.getAttribute("open")!=="true")&&e.setAttribute("open","false")})().finally(()=>{this.inflightModals.delete(e)});return this.unlockScroll(),this.inflightModals.set(e,t),t}async showModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{typeof e=="string"&&(e=await this.requireUiComponent(e)),!(!e||e.getAttribute("open")==="true")&&e.setAttribute("open","true")})().finally(()=>{this.inflightModals.delete(e)});return this.lockScroll(),this.inflightModals.set(e,t),t}async showSignIn(e){let t=await this.requireUiComponent("sign-in",{listeners:{close:s(()=>e?.onClose?.(),"close")}});t.setAttribute("return-to",e?.returnTo??window.location.pathname),await this.showModal(t)}async showUnsaveAlert(e){if(!e.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let t=await this.requireUiComponent("unsave-alert",{listeners:{submit:s(r=>{r instanceof CustomEvent?e.onSubmit?.(r.detail):console.warn("Unsave alert submitted without detail",r)},"submit"),close:s(()=>{e.onClose?.()},"close")}});t.setAttribute("item-id",e.itemId),await this.showModal(t)}async showDeleteListAlert(e){if(!e.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let t=await this.requireUiComponent("delete-list-alert",{listeners:{submit:s(()=>{e.onSubmit?.()},"submit"),close:s(()=>{e.onClose?.()},"close")}});t.setAttribute("list-id",e.listId),await this.showModal(t)}async showDrawer(e){await this.hideAllToasts();let t=await this.requireUiComponent("drawer",{listeners:{close:s(()=>{e?.onClose?.()},"close")}});t.setAttribute("account-url",this.storefrontContext.routes.accountUrl),this.storefrontContext.customer.id&&t.setAttribute("customer-id",this.storefrontContext.customer.id),await this.showModal(t)}async showListMenu(e){if(!e.listId)throw new Error("listId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-menu",{listeners:{close:s(r=>{e.onClose?.()},"close"),edit:s(r=>{r instanceof CustomEvent?e.onEdit?.(r.detail):console.warn("List menu submitted without detail",r)},"edit"),delete:s(r=>{r instanceof CustomEvent?e.onDelete?.():console.warn("List menu deleted without detail",r)},"delete")}});t.setAttribute("list-id",e.listId),await this.showModal(t)}async showListSelect(e){if(!e.itemId)throw new Error("itemId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-select",{listeners:{submit:s(async r=>{"detail"in r&&r.detail?e?.onSubmit?.(r.detail):console.warn("List select form submitted without detail",r)},"submit"),close:s(()=>{e.onClose?.()},"close"),unsave:s(r=>{r instanceof CustomEvent?e.onUnsave?.(r.detail):console.warn("List select unsave without detail",r)},"unsave")}});t.setAttribute("item-id",e.itemId),await this.showModal(t)}async initListDetailPage(e,t){let r=await this.requireUiComponent("list-detail-page",{refElement:t});e.listId&&r.setAttribute("list-id",e.listId)}async showToast(e){await this.requireUiComponent("toast-manager",{onHydrated:s(t=>{t.current.show(e)},"onHydrated")})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{onHydrated:s(e=>{e.current.clear()},"onHydrated")})}async showVariantSelect(e){await this.hideAllToasts();let t=await this.requireUiComponent("variant-select",{listeners:{submit:s(async r=>{"detail"in r&&r.detail?e?.onSubmit?.(r.detail):console.warn("Variant select form submitted without detail",r)},"submit"),close:s(()=>{e?.onClose?.()},"close")}});if(e?.productId)t.setAttribute("product-id",e.productId);else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("Either productId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId),e?.displayType&&t.setAttribute("display-type",e.displayType),await this.showModal(t)}async showQuickBuy(e){await this.hideAllToasts();let t=await this.requireUiComponent("quick-buy",{listeners:{submit:s(async r=>{"detail"in r&&r.detail?e?.onSubmit?.(r.detail):console.warn("Quick buy form submitted without detail",r)},"submit"),close:s(()=>{e?.onClose?.()},"close")}});if(e?.productId)t.setAttribute("product-id",e.productId);else throw new Error("ProductId must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId),await this.showModal(t)}async showListEditor(e){let t=await this.requireUiComponent("list-editor",{listeners:{submit:s(async r=>{"detail"in r&&r.detail?e?.onSubmit?.(r.detail):console.warn("List editor form submitted without detail",r)},"submit"),close:s(()=>{e?.onClose?.()},"close")}});e?.listId&&t.setAttribute("list-id",e.listId),await this.showModal(t)}async initShopBridge({onShopModalOpen:e}){let t=document.querySelector("swish-shop-bridge");if(t||(document.body.insertAdjacentHTML("beforeend","<swish-shop-bridge></swish-shop-bridge>"),t=document.querySelector("swish-shop-bridge")),!t)throw new Error("Failed to initialize Shop Bridge");return t.addEventListener("shop-modal-open",()=>e(),{once:!0}),await t.load(),t}async requireUiComponent(e,t){this.loadCricalResources();let r=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.html`,i=await fetch(r).then(l=>l.text()),o=t?.instance,u=t?.listeners,a=this.queryComponent(e,o)??await this.insertComponent({name:e,template:i,refElement:t?.refElement??document.body,position:"beforeend",instance:o});if(a.shadowRoot&&!a.hasAttribute("hydrated")){let l=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.js`;Promise.all([this.loadNonCriticalResources(),import(l)]).then(([{bundleCssStylesheet:c,customCssStylesheets:p},{hydrate:f}])=>{a.shadowRoot&&c&&(a.shadowRoot.adoptedStyleSheets=[...a.shadowRoot.adoptedStyleSheets,...p,c],a.shadowRoot?.querySelector(":host > style")?.remove()),f(a),a.setAttribute("hydrated",""),t?.onHydrated?.(a.getComponentRef())})}else a.hasAttribute("hydrated")&&t?.onHydrated?.(a.getComponentRef());for(let{event:l,listener:c}of this.eventListeners.values())a.removeEventListener(l,c);for(let[l,c]of Object.entries(u??{}))this.eventListeners.set(`${e}-${o}-${l}`,{event:l,listener:c}),a.addEventListener(l,c);return a}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/theme.css`,t=await fetch(e).then(i=>i.text()),r=new CSSStyleSheet;return r.replaceSync(t),this.swishUiOptions.theme&&Object.entries(this.swishUiOptions.theme).forEach(([i,o])=>{r.cssRules[0].cssRules[0].style.setProperty(i,o)}),{themeVariablesStylesheet:r}})(),this._loadCricalResourcesPromise)}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/bundle.css`,t=s(o=>{let u=new CSSStyleSheet;return u.replaceSync(o),u},"createCssStylesheet"),[r,...i]=await Promise.all([fetch(e).then(o=>o.text()).then(t),...this.swishUiOptions.css.map(async o=>o instanceof URL?t(await fetch(o).then(u=>u.text())):t(o))]);return{bundleCssStylesheet:r,customCssStylesheets:i}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:e,instance:t,template:r,position:i,refElement:o}){let{themeVariablesStylesheet:u}=await this.loadCricalResources();o.insertAdjacentHTML(i,r.replace(' shadowrootmode="open"',""));let a=this.queryComponent(e,t);if(!a)throw new Error(`Element ${e} not found in DOM`);return a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[u]),a}queryComponent(e,t){let r=`swish-ui[ref="${e}${t?`-${t}`:""}"]`;return document.querySelector(r)}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(`
446
446
  html[swish-locked] body {
447
447
  overflow: hidden;
448
448
  position: fixed;
@@ -450,4 +450,4 @@ Values:
450
450
  left: 0px;
451
451
  right: 0px;
452
452
  }
453
- `),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"))}};var Zi="0.73.0",Hl=s(async r=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;try{let n=localStorage.getItem("wk_session_id");n&&(localStorage.setItem("swish-profile",`gid://swish/Session/${n}`),localStorage.removeItem("wk_session_id"))}catch(n){console.warn("Failed to migrate legacy session id to Swish profile",{cause:n})}let e=un(r),t=new _t(e);try{let n=sessionStorage.getItem("swish-token"),i=n&&tn(n),o=!!e.storefrontContext.customer.id;o!==i&&sessionStorage.removeItem("swish-token");let u=!!localStorage.getItem("swish-profile");o===u&&await t.api.clearCache()}catch(n){console.warn("Could not check if customer logged out.",{cause:n})}return window.swish=t,document.dispatchEvent(new Event("swish-ready")),typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish("swish-ready",{proxyUrl:e.proxy.baseUrl,market:e.storefrontContext.localization.market,country:e.storefrontContext.localization.country,language:e.storefrontContext.localization.language,rootUrl:e.storefrontContext.routes.rootUrl}),t},"createSwish"),_t=class{constructor(e){this.dom={createElementLocator:pe,createQueryParamsObserver:oe};this.state={itemContext:Xt(this),itemState:Kt(this),itemCount:Yt(this),swishQuery:Jt(this),effect:V,signal:C,computed:B};this.swishOptions=e,this.events=new ve,this.swishBadges=new Fe({getBadges:this.swishOptions.badges?.getBadges});let t={proxyBaseUrl:`${this.swishOptions.proxy.baseUrl}/api`,...this.swishOptions.swishApi??{}};this.swishApiPublisher=new Me(this.events);let n=[Zi,e.swishUi?.version].join("-");this.swishApi=new Ge({...t,customerId:e.storefrontContext.customer.id??void 0,responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.storefrontContext,n),this.ajaxApiPublisher=new me(this.events),this.ajaxApi=new ye({storeDomain:this.swishOptions.storefrontApi.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new Ve(this.swishOptions.storefrontApi,this.swishOptions.storefrontContext,this.swishBadges,this.swishOptions.metafields),this.swishUi=new He(this.swishOptions.swishUi,this.swishOptions.storefrontContext),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",je),this.intents=new Pe(this,this.swishUi)}static{s(this,"SwishApp")}get options(){return this.swishOptions}get customer(){return this.swishOptions.storefrontContext.customer}get localization(){return this.swishOptions.storefrontContext.localization}get routes(){return this.swishOptions.storefrontContext.routes}get badges(){return this.swishBadges}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.swishOptions.storefrontApi.storeDomain}`}get ui(){return this.swishUi}};export{_t as SwishApp,Zi as VERSION,Hl as createSwish};
453
+ `),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"))}};var ns=typeof HTMLElement<"u"?HTMLElement:class{},Fe=class extends ns{constructor(){super();this.getComponentRef=s(()=>this.componentRef,"getComponentRef");this.setComponentRef=s(t=>{this.componentRef=t},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let t=this.querySelector("template");t&&this.shadowRoot&&(this.shadowRoot.appendChild(t.content),t.remove())}static{s(this,"SwishUiElement")}};var He=class{static{s(this,"ShopifyBadgesUtils")}#e;constructor({getBadges:e}){this.#e=e?.bind(this)}getBadges({product:e,variant:t}){try{let r=this.getDefaultBadges({product:e,variant:t});return this.#e?this.mapBadges(this.#e({product:e,variant:t,defaultBadges:r})??[]):this.mapBadges(r)}catch(r){return console.error("Error getting badges",r),[]}}getDefaultBadges({product:e,variant:t}){let r=[];if(e?.availableForSale===!1||t?.availableForSale===!1)return r.push("Sold out"),r;let i=t?t.price.amount:e?.priceRange?.minVariantPrice.amount,o=t?t.compareAtPrice?.amount:e?.compareAtPriceRange?.minVariantPrice.amount;return o&&parseFloat(o)>parseFloat(i)&&r.push("Sale"),r}mapBadges(e){return e.map(t=>typeof t=="string"?{id:t.toLowerCase().replace(/[^a-z0-9]/g,"_"),label:t}:t)}};var rs="0.80.1",Wl=s(async n=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;let e=Mt(n),t=new _t(e);return window.swish=t,document.dispatchEvent(new Event("swish-ready")),t.api.initAuth().then(()=>{typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish("swish-ready",{market:e.storefrontContext.localization.market,country:e.storefrontContext.localization.country,language:e.storefrontContext.localization.language,rootUrl:e.storefrontContext.routes.rootUrl})}),t},"createSwish"),_t=class{constructor(e){this.dom={createElementLocator:ce,createQueryParamsObserver:se};this.state={itemContext:Kt(this),itemState:Yt(this),itemCount:Jt(this),swishQuery:Zt(this),effect:V,signal:C,computed:q};this.swishOptions=e,this.events=new me,this.swishBadges=new He({getBadges:this.swishOptions.badges?.getBadges}),this.swishApiPublisher=new Me(this.events);let t=[rs,e.swishUi?.version].join("-");this.swishApi=new Ge({...this.swishOptions.swishApi,responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.storefrontContext,t),this.ajaxApiPublisher=new ye(this.events),this.ajaxApi=new he({storeDomain:this.swishOptions.storefrontApi.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new Be(this.swishOptions.storefrontApi,this.swishOptions.storefrontContext,this.swishBadges,this.swishOptions.metafields),this.swishUi=new je(this.swishOptions.swishUi,this.swishOptions.storefrontContext),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",Fe),this.intents=new De(this,this.swishUi)}static{s(this,"SwishApp")}get options(){return this.swishOptions}get customer(){return this.swishOptions.storefrontContext.customer}get localization(){return this.swishOptions.storefrontContext.localization}get routes(){return this.swishOptions.storefrontContext.routes}get badges(){return this.swishBadges}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.swishOptions.storefrontApi.storeDomain}`}get ui(){return this.swishUi}};export{rs as VERSION,Wl as createSwish};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swishapp/sdk",
3
- "version": "0.73.0",
3
+ "version": "0.80.1",
4
4
  "description": "JS SDK for Swish.",
5
5
  "author": "Swish",
6
6
  "license": "UNLICENSED",
@@ -21,16 +21,16 @@
21
21
  "dependencies": {
22
22
  "@preact/signals-core": "1.12.1",
23
23
  "@shopify/storefront-api-client": "1.0.9",
24
- "@swishapp/api-client": "0.27.0",
24
+ "@swishapp/api-client": "0.40.0",
25
25
  "dataloader": "2.2.3",
26
26
  "valibot": "1.1.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@shopify/api-codegen-preset": "1.2.0",
30
30
  "concurrently": "9.2.1",
31
- "esbuild": "0.25.11",
31
+ "esbuild": "0.27.0",
32
32
  "graphql-config": "5.1.5",
33
- "rimraf": "6.0.1",
33
+ "rimraf": "6.1.2",
34
34
  "typescript": "5.9.3"
35
35
  },
36
36
  "main": "./dist/swish.js",
@@ -1,4 +0,0 @@
1
- export declare const getTokenData: (token: string) => any;
2
- export declare const isTokenExpired: (token: string, leeway?: number) => any;
3
- export declare const isCustomerToken: (token: string) => any;
4
- export declare const isSessionToken: (token: string) => any;