@swishapp/sdk 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +50 -0
  2. package/dist/ajax-api/ajax-api-client.d.ts +81 -0
  3. package/dist/ajax-api/ajax-api-publisher.d.ts +9 -0
  4. package/dist/cache/fetch-cache.d.ts +87 -0
  5. package/dist/dom/dom-utils.d.ts +16 -0
  6. package/dist/events/event-bus.d.ts +7 -0
  7. package/dist/index.d.ts +8 -0
  8. package/dist/state/index.d.ts +4 -0
  9. package/dist/state/item-context-signal.d.ts +11 -0
  10. package/dist/state/item-count-signal.d.ts +7 -0
  11. package/dist/state/item-state-signal.d.ts +19 -0
  12. package/dist/state/swish-query-signals.d.ts +21 -0
  13. package/dist/storefront-api/load-product-card-data.d.ts +15 -0
  14. package/dist/storefront-api/load-product-detail-data.d.ts +15 -0
  15. package/dist/storefront-api/load-product-id.d.ts +11 -0
  16. package/dist/storefront-api/load-product-images.d.ts +20 -0
  17. package/dist/storefront-api/load-product-options.d.ts +13 -0
  18. package/dist/storefront-api/load-product-recommendations.d.ts +17 -0
  19. package/dist/storefront-api/load-selected-variant.d.ts +14 -0
  20. package/dist/storefront-api/queries/fragments.d.ts +7 -0
  21. package/dist/storefront-api/queries/index.d.ts +14 -0
  22. package/dist/storefront-api/storefront-api-client.d.ts +67 -0
  23. package/dist/storefront-api/types/storefront.generated.d.ts +461 -0
  24. package/dist/storefront-api/types/storefront.types.d.ts +8460 -0
  25. package/dist/swish-api/items-batch-loader.d.ts +4 -0
  26. package/dist/swish-api/swish-api-client.d.ts +43 -0
  27. package/dist/swish-api/swish-api-publisher.d.ts +8 -0
  28. package/dist/swish-ui/swish-ui-element.d.ts +9 -0
  29. package/dist/swish-ui/swish-ui-utils.d.ts +112 -0
  30. package/dist/swish.d.ts +124 -0
  31. package/dist/swish.js +403 -0
  32. package/dist/types.d.ts +57 -0
  33. package/dist/utils/shop-bridge.d.ts +26 -0
  34. package/dist/utils/shopify-gid.d.ts +2 -0
  35. package/dist/utils/shopify-url-utils.d.ts +13 -0
  36. package/package.json +60 -0
package/dist/swish.js ADDED
@@ -0,0 +1,403 @@
1
+ var jr=Object.create;var Le=Object.defineProperty;var Qr=Object.getOwnPropertyDescriptor;var zr=Object.getOwnPropertyNames;var Wr=Object.getPrototypeOf,Yr=Object.prototype.hasOwnProperty;var a=(t,e)=>Le(t,"name",{value:e,configurable:!0});var Kr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Jr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of zr(e))!Yr.call(t,o)&&o!==r&&Le(t,o,{get:()=>e[o],enumerable:!(n=Qr(e,o))||n.enumerable});return t};var Xr=(t,e,r)=>(r=t!=null?jr(Wr(t)):{},Jr(e||!t||!t.__esModule?Le(r,"default",{value:t,enumerable:!0}):r,t));var Dr=Kr((ts,Pr)=>{"use strict";var oo=(function(){function t(r,n){if(typeof r!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+r+"."));this._batchLoadFn=r,this._maxBatchSize=co(n),this._batchScheduleFn=lo(n),this._cacheKeyFn=uo(n),this._cacheMap=po(n),this._batch=null,this.name=ho(n)}a(t,"DataLoader");var e=t.prototype;return e.load=a(function(n){if(n==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(n)+"."));var o=io(this),i=this._cacheMap,s;if(i){s=this._cacheKeyFn(n);var c=i.get(s);if(c){var l=o.cacheHits||(o.cacheHits=[]);return new Promise(function(d){l.push(function(){d(c)})})}}o.keys.push(n);var p=new Promise(function(d,h){o.callbacks.push({resolve:d,reject:h})});return i&&i.set(s,p),p},"load"),e.loadMany=a(function(n){if(!Tr(n))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+n+"."));for(var o=[],i=0;i<n.length;i++)o.push(this.load(n[i]).catch(function(s){return s}));return Promise.all(o)},"loadMany"),e.clear=a(function(n){var o=this._cacheMap;if(o){var i=this._cacheKeyFn(n);o.delete(i)}return this},"clear"),e.clearAll=a(function(){var n=this._cacheMap;return n&&n.clear(),this},"clearAll"),e.prime=a(function(n,o){var i=this._cacheMap;if(i){var s=this._cacheKeyFn(n);if(i.get(s)===void 0){var c;o instanceof Error?(c=Promise.reject(o),c.catch(function(){})):c=Promise.resolve(o),i.set(s,c)}}return this},"prime"),t})(),ao=typeof process=="object"&&typeof process.nextTick=="function"?function(t){ct||(ct=Promise.resolve()),ct.then(function(){process.nextTick(t)})}:typeof setImmediate=="function"?function(t){setImmediate(t)}:function(t){setTimeout(t)},ct;function io(t){var e=t._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<t._maxBatchSize)return e;var r={hasDispatched:!1,keys:[],callbacks:[]};return t._batch=r,t._batchScheduleFn(function(){so(t,r)}),r}a(io,"getCurrentBatch");function so(t,e){if(e.hasDispatched=!0,e.keys.length===0){dt(e);return}var r;try{r=t._batchLoadFn(e.keys)}catch(n){return lt(t,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(!r||typeof r.then!="function")return lt(t,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(r)+".")));r.then(function(n){if(!Tr(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."+(`
2
+
3
+ Keys:
4
+ `+String(e.keys))+(`
5
+
6
+ Values:
7
+ `+String(n)));dt(e);for(var o=0;o<e.callbacks.length;o++){var i=n[o];i instanceof Error?e.callbacks[o].reject(i):e.callbacks[o].resolve(i)}}).catch(function(n){lt(t,e,n)})}a(so,"dispatchBatch");function lt(t,e,r){dt(e);for(var n=0;n<e.keys.length;n++)t.clear(e.keys[n]),e.callbacks[n].reject(r)}a(lt,"failedDispatch");function dt(t){if(t.cacheHits)for(var e=0;e<t.cacheHits.length;e++)t.cacheHits[e]()}a(dt,"resolveCacheHits");function co(t){var e=!t||t.batch!==!1;if(!e)return 1;var r=t&&t.maxBatchSize;if(r===void 0)return 1/0;if(typeof r!="number"||r<1)throw new TypeError("maxBatchSize must be a positive number: "+r);return r}a(co,"getValidMaxBatchSize");function lo(t){var e=t&&t.batchScheduleFn;if(e===void 0)return ao;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}a(lo,"getValidBatchScheduleFn");function uo(t){var e=t&&t.cacheKeyFn;if(e===void 0)return function(r){return r};if(typeof e!="function")throw new TypeError("cacheKeyFn must be a function: "+e);return e}a(uo,"getValidCacheKeyFn");function po(t){var e=!t||t.cache!==!1;if(!e)return null;var r=t&&t.cacheMap;if(r===void 0)return new Map;if(r!==null){var n=["get","set","delete","clear"],o=n.filter(function(i){return r&&typeof r[i]!="function"});if(o.length!==0)throw new TypeError("Custom cacheMap missing methods: "+o.join(", "))}return r}a(po,"getValidCacheMap");function ho(t){return t&&t.name?t.name:null}a(ho,"getValidName");function Tr(t){return typeof t=="object"&&t!==null&&typeof t.length=="number"&&(t.length===0||t.length>0&&Object.prototype.hasOwnProperty.call(t,t.length-1))}a(Tr,"isArrayLike");Pr.exports=oo});var Q=a(t=>t.split("/").pop(),"shopifyGidToId"),R=a((t,e)=>`gid://shopify/${t}/${e}`,"shopifyIdToGid");var M=class{constructor(e,r,n=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.cacheName=e,this.defaultCacheControl=r,this.keyPrefix=n}static{a(this,"FetchCache")}async get(e){try{let r=await caches.open(this.cacheName),n=await r.match(e);if(n&&this.isExpired(n)){await r.delete(e);return}return n}catch(r){console.warn("Cache get error:",r);return}}async set(e,r,n){try{if(n?.includes("no-cache"))return;let o=this.createCacheableResponse(r,n);await(await caches.open(this.cacheName)).put(e,o)}catch(o){console.warn("Cache set error:",o)}}async fetchWithCache(e,r,n){let o=await this.getCacheKey(e,r);if(this.inFlightRequests.has(o))return this.inFlightRequests.get(o).then(s=>s.clone());let i=(async()=>{let s=await this.get(o);if(s)return this.isStaleButRevalidatable(s)&&this.revalidateInBackground(o,e,r,n),s.clone();let c=await fetch(e,r);return c.ok&&await this.set(o,c.clone(),n??this.defaultCacheControl),c})().finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,i),i}async delete(e){try{return await(await caches.open(this.cacheName)).delete(e)}catch(r){return console.warn("Cache delete error:",r),!1}}async clear(){try{let e=await caches.open(this.cacheName),r=await e.keys();await Promise.all(r.map(n=>e.delete(n)))}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 r=await caches.open(this.cacheName),n=await r.match(e);return n&&this.isExpired(n)?(await r.delete(e),!1):n!==void 0}catch(r){return console.warn("Cache has error:",r),!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),r=await e.keys(),n=0;for(let i of r){let s=await e.match(i);s&&this.isExpired(s)&&(await e.delete(i),n++)}let o=r.length-n;return{removed:n,remaining:o}}catch(e){return console.warn("Cache cleanup error:",e),{removed:0,remaining:0}}}async getCacheKey(e,r){let n=this.getInputUrl(e),o=`${this.keyPrefix}${n}/${JSON.stringify(r)}`,s=new TextEncoder().encode(o),c=await crypto.subtle.digest("SHA-256",s);return`/${Array.from(new Uint8Array(c)).map(d=>d.toString(16).padStart(2,"0")).join("")}`}getInputUrl(e){return e instanceof URL?e.toString():typeof e=="string"?e:e.url}isExpired(e){let r=e.headers.get("Cache-Control");if(!r)return!1;let n=this.parseMaxAge(r),o=this.parseStaleWhileRevalidate(r);if(n===null)return!1;let i=e.headers.get("Date");if(!i)return!1;let s=new Date(i).getTime(),l=(Date.now()-s)/1e3,p=n+(o??0);return l>p}isStaleButRevalidatable(e){let r=e.headers.get("Cache-Control");if(!r)return!1;let n=this.parseMaxAge(r),o=this.parseStaleWhileRevalidate(r);if(n===null||o===null)return!1;let i=e.headers.get("Date");if(!i)return!1;let s=new Date(i).getTime(),l=(Date.now()-s)/1e3;return l>n&&l<=n+o}async revalidateInBackground(e,r,n,o){if(this.revalidationPromises.has(e))return;let i=(async()=>{try{let s=await fetch(r,n);s.ok&&await this.set(e,s.clone(),o??this.defaultCacheControl)}catch(s){console.warn("Background revalidation error:",s)}finally{this.revalidationPromises.delete(e)}})();this.revalidationPromises.set(e,i)}parseMaxAge(e){let r=new RegExp(/max-age=(\d+)/).exec(e);return r?parseInt(r[1],10):null}parseStaleWhileRevalidate(e){let r=new RegExp(/stale-while-revalidate=(\d+)/).exec(e);return r?parseInt(r[1],10):null}createCacheableResponse(e,r){let n=new Headers(e.headers);return n.set("Cache-Control",r),n.has("Date")||n.set("Date",new Date().toUTCString()),new Response(e.body,{status:e.status,statusText:e.statusText,headers:n})}};var ue=class{static{a(this,"AjaxApiClient")}constructor(e){this.config=e,this.cache=new M("ajax-api","max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(r=>{console.warn("Ajax API cache initialization cleanup error:",r)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let e=window.fetch,r=this.config.responseInterceptor,n=this.getFetchRequest.bind(this);window.fetch=function(...o){let i=e.apply(this,o);if(typeof r=="function"){let s=n(o[0]);i.then(c=>r(c,s))}return i}}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,r){return r?.method==="OPTIONS"?fetch(e,r):(e instanceof Request?e.method:r?.method??"GET")==="GET"?this.cache.fetchWithCache(e,r):fetch(e,r)}async request(e,r={}){let n=`${this.getBaseUrl()}${e}`,o={"Content-Type":"application/json",Accept:"application/json"};if(r.method==="GET"||!r.method){let s=await this.cache.fetchWithCache(n,{...r,headers:{...o,...r.headers}});if(!s.ok){let c;try{c=await s.json()}catch{c={message:`HTTP ${s.status}: ${s.statusText}`,status:s.status.toString(),description:s.statusText}}throw new Error(c.message||c.description)}return s.json()}let i=await this.fetch(n,{...r,headers:{...o,...r.headers}});if(!i.ok){let s;try{s=await i.json()}catch{s={message:`HTTP ${i.status}: ${i.statusText}`,status:i.status.toString(),description:i.statusText}}throw new Error(s.message||s.description)}return i.json()}async fetchCart(){return this.request("/cart.js")}async addToCart(e){let r={...e,items:e.items.map(n=>{let o=Q(n.id);if(!o)throw new Error(`Invalid Shopify GID format: ${n.id}`);let i=parseInt(o,10);if(isNaN(i))throw new Error(`Invalid numeric ID extracted from GID: ${n.id}`);return{...n,id:i}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(r)})}async clearCache(){await this.cache.clear()}};var pe=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{a(this,"AjaxApiPublisher")}async processFetchResponse(e,r){try{let n=this.getEventName(r.url);if(n){let o=await e.clone().json();this.eventBus.publish(n,o)}}catch(n){console.warn(n)}}getEventName(e){for(let[r,n]of Object.entries(this.eventMap))if(e.includes(r))return n;return null}};function Zr(){let t=document.body||document.documentElement;return t?Promise.resolve(t):new Promise(e=>{window.addEventListener("DOMContentLoaded",()=>e(t))})}a(Zr,"waitForDOM");function gt({onElementFound:t,selector:e,observerOptions:r}){let n=new WeakSet,o=new MutationObserver(l=>{let p=!1;for(let d of l)if(d.addedNodes.length>0){p=!0;break}p&&i()}),i=a(()=>{document.querySelectorAll(e).forEach(l=>{n.has(l)||(s(l),n.add(l))})},"locateElements"),s=a(l=>{if(!r){t(l);return}let p=new IntersectionObserver(d=>{for(let h of d)h.isIntersecting&&(p.disconnect(),t(l))},r);p.observe(l)},"observeElement");return a(async()=>{let l=await Zr();i(),o.observe(l,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}a(gt,"createElementLocator");function he({onLocationChange:t}){let e=a(()=>{t(window.location)},"handleChange");window.addEventListener("popstate",e);let r=history.pushState,n=history.replaceState;return history.pushState=function(...o){r.apply(this,o),e()},history.replaceState=function(...o){n.apply(this,o),e()},()=>{window.removeEventListener("popstate",e),history.pushState=r,history.replaceState=n}}a(he,"createLocationObserver");function vt({element:t,onHrefChange:e}){let r=a(()=>{e(t.href)},"handleChange"),n=new MutationObserver(()=>{r()});return n.observe(t,{attributes:!0,attributeFilter:["href"]}),()=>{n.disconnect()}}a(vt,"createHrefObserver");var fe=class{constructor(){this.eventBus=new EventTarget}static{a(this,"EventBus")}subscribe(e,r,n){return Array.isArray(e)||(e=[e]),e.forEach(o=>{this.eventBus.addEventListener(o,r,n)}),()=>{e.forEach(o=>{this.eventBus.removeEventListener(o,r,n)})}}unsubscribe(e,r,n){this.eventBus.removeEventListener(e,r,n)}publish(e,r){this.eventBus.dispatchEvent(new CustomEvent(e,{detail:r}))}};var en=Symbol.for("preact-signals");function ye(){if(z>1)z--;else{for(var t,e=!1;se!==void 0;){var r=se;for(se=void 0,Oe++;r!==void 0;){var n=r.o;if(r.o=void 0,r.f&=-3,!(8&r.f)&&It(r))try{r.c()}catch(o){e||(t=o,e=!0)}r=n}}if(Oe=0,z--,e)throw t}}a(ye,"t");function W(t){if(z>0)return t();z++;try{return t()}finally{ye()}}a(W,"r");var v=void 0;function Ct(t){var e=v;v=void 0;try{return t()}finally{v=e}}a(Ct,"n");var se=void 0,z=0,Oe=0,me=0;function wt(t){if(v!==void 0){var e=t.n;if(e===void 0||e.t!==v)return e={i:0,S:t,p:v.s,n:void 0,t:v,e:void 0,x:void 0,r:e},v.s!==void 0&&(v.s.n=e),v.s=e,t.n=e,32&v.f&&t.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=v.s,e.n=void 0,v.s.n=e,v.s=e),e}}a(wt,"e");function D(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}a(D,"u");D.prototype.brand=en;D.prototype.h=function(){return!0};D.prototype.S=function(t){var e=this,r=this.t;r!==t&&t.e===void 0&&(t.x=r,this.t=t,r!==void 0?r.e=t:Ct(function(){var n;(n=e.W)==null||n.call(e)}))};D.prototype.U=function(t){var e=this;if(this.t!==void 0){var r=t.e,n=t.x;r!==void 0&&(r.x=n,t.e=void 0),n!==void 0&&(n.e=r,t.x=void 0),t===this.t&&(this.t=n,n===void 0&&Ct(function(){var o;(o=e.Z)==null||o.call(e)}))}};D.prototype.subscribe=function(t){var e=this;return $(function(){var r=e.value,n=v;v=void 0;try{t(r)}finally{v=n}},{name:"sub"})};D.prototype.valueOf=function(){return this.value};D.prototype.toString=function(){return this.value+""};D.prototype.toJSON=function(){return this.value};D.prototype.peek=function(){var t=v;v=void 0;try{return this.value}finally{v=t}};Object.defineProperty(D.prototype,"value",{get:a(function(){var t=wt(this);return t!==void 0&&(t.i=this.i),this.v},"get"),set:a(function(t){if(t!==this.v){if(Oe>100)throw new Error("Cycle detected");this.v=t,this.i++,me++,z++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{ye()}}},"set")});function b(t,e){return new D(t,e)}a(b,"d");function It(t){for(var e=t.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}a(It,"c");function bt(t){for(var e=t.s;e!==void 0;e=e.n){var r=e.S.n;if(r!==void 0&&(e.r=r),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}a(bt,"a");function Et(t){for(var e=t.s,r=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)):r=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=n}t.s=r}a(Et,"l");function Z(t,e){D.call(this,void 0),this.x=t,this.s=void 0,this.g=me-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}a(Z,"y");Z.prototype=new D;Z.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===me))return!0;if(this.g=me,this.f|=1,this.i>0&&!It(this))return this.f&=-2,!0;var t=v;try{bt(this),v=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(r){this.v=r,this.f|=16,this.i++}return v=t,Et(this),this.f&=-2,!0};Z.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}D.prototype.S.call(this,t)};Z.prototype.U=function(t){if(this.t!==void 0&&(D.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};Z.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(Z.prototype,"value",{get:a(function(){if(1&this.f)throw new Error("Cycle detected");var t=wt(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v},"get")});function q(t,e){return new Z(t,e)}a(q,"w");function St(t){var e=t.u;if(t.u=void 0,typeof e=="function"){z++;var r=v;v=void 0;try{e()}catch(n){throw t.f&=-2,t.f|=8,$e(t),n}finally{v=r,ye()}}}a(St,"_");function $e(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,St(t)}a($e,"b");function tn(t){if(v!==this)throw new Error("Out-of-order effect");Et(this),v=t,this.f&=-2,8&this.f&&$e(this),ye()}a(tn,"g");function ae(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}a(ae,"p");ae.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}};ae.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,St(this),bt(this),z++;var t=v;return v=this,tn.bind(this,t)};ae.prototype.N=function(){2&this.f||(this.f|=2,this.o=se,se=this)};ae.prototype.d=function(){this.f|=8,1&this.f||$e(this)};ae.prototype.dispose=function(){this.d()};function $(t,e){var r=new ae(t,e);try{r.c()}catch(o){throw r.d(),o}var n=r.d.bind(r);return n[Symbol.dispose]=n,n}a($,"E");var rn=/^(?:https?:\/\/[^/]+)?(?:\/[a-z]{2})?\/products\/([^/?#]+)(?:\?variant=(\d+))?/,Ve=a(t=>{let e=t.match(rn);return e?{productHandle:e[1],variantId:e[2]}:null},"parseProductUrl"),At=a(({source:t,onProductUrlChange:e})=>{let r=a(n=>{let o=Ve(n);o?.productHandle&&e(o)},"handleChange");if(t instanceof HTMLAnchorElement)return vt({element:t,onHrefChange:a(n=>r(n),"onHrefChange")});if(t instanceof Location)return he({onLocationChange:a(n=>r(n.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Rt=a(t=>e=>{let{productHandle:r,productId:n,variantId:o,itemId:i,defaultVariantId:s}=e?.dataset??{},c=e?.hasAttribute("skip-variant-select"),d=!!(n||r)||!!i,h=b({loading:!1,productId:n,variantId:o,itemId:i,skipVariantSelect:c,defaultVariantId:s});if(!d){let C=e instanceof HTMLAnchorElement?e:window.location,m=Ve(C.href);m?.productHandle&&m.productHandle!==h.value.productHandle&&(h.value={...h.value,...m,productId:void 0},At({source:C,onProductUrlChange:a(I=>{h.value={...h.value,...I,productId:I.productHandle!==h.value.productHandle?void 0:h.value.productId}},"onProductUrlChange")}))}return $(()=>{h.value.loading||!h.value.productId&&h.value.productHandle&&(h.value={...h.value,loading:!0},t.storefront.loadProductId({productHandle:h.value.productHandle}).then(C=>{C.errors&&console.error("Error loading product id",C.errors),h.value={...h.value,productId:C.data?.product?.id?Q(C.data.product.id):void 0,loading:!1}}))}),h},"itemContextSignal");var Tt=a(t=>e=>{let r=q(()=>{let{productId:y,variantId:w,loading:E}=e.value;return!y||E?null:w?`variant:${Q(w)}`:`product:${Q(y)}`}),n=q(()=>e.value.loading||!!e.value.itemId||!e.value.productId),o=q(()=>({limit:1,query:r.value??void 0})),i=b(!n.value),s=b(null),c=b(!1),l=b(!1),{data:p,loading:d,error:h,refetching:C}=t.state.swishQuery(y=>t.api.items.list(y),{refetch:["item-create","item-update","item-delete"],variables:o,skip:n}),m=b(e.value.itemId??null);$(()=>{W(()=>{if(i.value=d.value,s.value=h.value,!e.value.itemId){let y=p.value?.[0]?.id??null;y!==m.value&&(m.value=y)}})});function I(y){t.ui.showListSelect({itemId:y,onSubmit:a(({item:w,product:E,variant:H})=>{t.ui.showNotification({title:"Saved",text:E.title,image:H?.image?.url??E.featuredImage?.url,action:{label:"Add to List",onAction:a(()=>{I(w.id)},"onAction")}})},"onSubmit"),onUnsave:a(()=>{m.value=null},"onUnsave")})}a(I,"showListSelect");function g(){m.value&&t.ui.showUnsaveAlert({itemId:m.value,onSubmit:a(()=>{m.value=null},"onSubmit")})}a(g,"unsave");function A(){m.value&&I(m.value)}a(A,"update");async function P(){let{productId:y,variantId:w,skipVariantSelect:E,defaultVariantId:H}=e.value;if(!e.value.variantId&&!E){t.ui.showVariantSelect({productId:e.value.productId,action:"save",onSubmit:a(async({item:L,product:F,variant:j})=>{m.value=L.id,t.ui.showNotification({title:"Saved",text:F.title,image:j?.image?.url??F.featuredImage?.url,action:{label:"Add to List",onAction:a(()=>{I(L.id)},"onAction")}})},"onSubmit")});return}E&&H&&(w=H),c.value=!0,l.value=!0;try{let L=await t.api.items.create({productId:Number(y),variantId:w?Number(Q(w)):void 0});if("error"in L)throw new Error(L.error.message);if(!L.data)throw new Error("API response missing data");let F=L.data;m.value=F.id;let{data:j}=await t.storefront.loadProductCardData({productId:F.productId.toString(),variantId:F.variantId?.toString()});if(j&&"variant"in j&&j.product){let{product:J,variant:de}=j;t.ui.showNotification({title:"Saved",text:J.title,image:de?.image?.url??J.featuredImage?.url,action:{label:"Add to List",onAction:a(()=>{I(F.id)},"onAction")}})}c.value=!1}catch(L){console.error("Failed to create item",L),W(()=>{c.value=!1,l.value=!1})}}a(P,"save");let T=q(()=>i.value||c.value||e.value.loading);$(()=>{l.value&&!c.value&&!C.value&&(l.value=!1)});let _=q(()=>{let y=C.value&&l.value,w=!!m.value,E=!w&&(c.value||y),H=w&&(c.value||y),L=q(()=>E?"saving":H?"unsaving":w?"saved":"unsaved");return{error:s.value,status:L.value,savedItemId:m.value,loading:T.value,submitting:c.value,saved:w,saving:E,unsaving:H}});async function N(){T.value||(_.value.saved&&_.value.savedItemId?I(_.value.savedItemId):_.value.saved||await P())}return a(N,"toggle"),Object.assign(_,{save:P,unsave:g,update:A,toggle:N})},"itemStateSignal");var Pt=a(t=>()=>{let{data:e,loading:r,error:n}=t.state.swishQuery(()=>t.api.items.count(),{refetch:["item-create","item-delete"]}),o=b(0),i=b(!0),s=b(null);return $(()=>{W(()=>{i.value=r.value,s.value=n.value,o.value=e.value?.count??0})}),q(()=>({count:o.value,loading:i.value,error:s.value}))},"itemCountSignal");var Dt=a(t=>(e,r)=>{let n=b(null),o=b(null),i=b(null),s=b(!r?.skip),c=b(!1),l=q(()=>s.value&&c.value);async function p(){if(!r?.skip?.value)try{s.value=!0;let d=await e(r?.variables?.value);W(()=>{i.value="error"in d?d.error:null,n.value="data"in d?d.data:null,o.value="pageInfo"in d?d.pageInfo:null,s.value=!1,c.value=!0})}catch(d){W(()=>{i.value=d,s.value=!1,c.value=!0})}}return a(p,"executeFetch"),$(()=>{if(p(),r?.refetch?.length)return t.events.subscribe(r.refetch,p)}),{data:n,pageInfo:o,error:i,loading:s,refetching:l}},"swishQuerySignals");var ee="GraphQL Client";var Ne="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",Ue="Response returned unexpected Content-Type:",qe="An unknown error has occurred. The API did not return a data object or any errors in its response.",ge={json:"application/json",multipart:"multipart/mixed"},Be="X-SDK-Variant",Ge="X-SDK-Version",_t="shopify-graphql-client",Lt="1.4.1",ve=1e3,Ot=[429,503],He=/@(defer)\b/i,xt=`\r
8
+ `,$t=/boundary="?([^=";]+)"?/i,Fe=xt+xt;function B(t,e=ee){return t.startsWith(`${e}`)?t:`${e}: ${t}`}a(B,"formatErrorMessage");function k(t){return t instanceof Error?t.message:JSON.stringify(t)}a(k,"getErrorMessage");function Me(t){return t instanceof Error&&t.cause?t.cause:void 0}a(Me,"getErrorCause");function ke(t){return t.flatMap(({errors:e})=>e??[])}a(ke,"combineErrors");function Ce({client:t,retries:e}){if(e!==void 0&&(typeof e!="number"||e<0||e>3))throw new Error(`${t}: The provided "retries" value (${e}) is invalid - it cannot be less than ${0} or greater than ${3}`)}a(Ce,"validateRetries");function x(t,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[t]:e}:{}}a(x,"getKeyValueIfValid");function je(t,e){if(t.length===0)return e;let n={[t.pop()]:e};return t.length===0?n:je(t,n)}a(je,"buildDataObjectByPath");function Ut(t,e){return Object.keys(e||{}).reduce((r,n)=>(typeof e[n]=="object"||Array.isArray(e[n]))&&t[n]?(r[n]=Ut(t[n],e[n]),r):(r[n]=e[n],r),Array.isArray(t)?[...t]:{...t})}a(Ut,"combineObjects");function Qe([t,...e]){return e.reduce(Ut,{...t})}a(Qe,"buildCombinedDataObject");function ze({clientLogger:t,customFetchApi:e=fetch,client:r=ee,defaultRetryWaitTime:n=ve,retriableCodes:o=Ot}){let i=a(async(s,c,l)=>{let p=c+1,d=l+1,h;try{if(h=await e(...s),t({type:"HTTP-Response",content:{requestParams:s,response:h}}),!h.ok&&o.includes(h.status)&&p<=d)throw new Error;let C=h?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return C&&t({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:s,deprecationNotice:C}}),h}catch(C){if(p<=d){let m=h?.headers.get("Retry-After");return await nn(m?parseInt(m,10):n),t({type:"HTTP-Retry",content:{requestParams:s,lastResponse:h,retryAttempt:c,maxRetries:l}}),i(s,p,l)}throw new Error(B(`${l>0?`Attempted maximum number of ${l} network retries. Last message - `:""}${k(C)}`,r))}},"httpFetch");return i}a(ze,"generateHttpFetch");async function nn(t){return new Promise(e=>setTimeout(e,t))}a(nn,"sleep");function We({headers:t,url:e,customFetchApi:r=fetch,retries:n=0,logger:o}){Ce({client:ee,retries:n});let i={headers:t,url:e,retries:n},s=on(o),c=ze({customFetchApi:r,clientLogger:s,defaultRetryWaitTime:ve}),l=an(c,i),p=sn(l),d=fn(l);return{config:i,fetch:l,request:p,requestStream:d}}a(We,"createGraphQLClient");function on(t){return e=>{t&&t(e)}}a(on,"generateClientLogger");async function qt(t){let{errors:e,data:r,extensions:n}=await t.json();return{...x("data",r),...x("extensions",n),headers:t.headers,...e||!r?{errors:{networkStatusCode:t.status,message:B(e?Ne:qe),...x("graphQLErrors",e),response:t}}:{}}}a(qt,"processJSONResponse");function an(t,{url:e,headers:r,retries:n}){return async(o,i={})=>{let{variables:s,headers:c,url:l,retries:p,keepalive:d,signal:h}=i,C=JSON.stringify({query:o,variables:s});Ce({client:ee,retries:p});let m=Object.entries({...r,...c}).reduce((g,[A,P])=>(g[A]=Array.isArray(P)?P.join(", "):P.toString(),g),{});return!m[Be]&&!m[Ge]&&(m[Be]=_t,m[Ge]=Lt),t([l??e,{method:"POST",headers:m,body:C,signal:h,keepalive:d}],1,p??n)}}a(an,"generateFetch");function sn(t){return async(...e)=>{if(He.test(e[0]))throw new Error(B("This operation will result in a streamable response - use requestStream() instead."));let r=null;try{r=await t(...e);let{status:n,statusText:o}=r,i=r.headers.get("content-type")||"";return r.ok?i.includes(ge.json)?await qt(r):{errors:{networkStatusCode:n,message:B(`${Ue} ${i}`),response:r}}:{errors:{networkStatusCode:n,message:B(o),response:r}}}catch(n){return{errors:{message:k(n),...r==null?{}:{networkStatusCode:r.status,response:r}}}}}}a(sn,"generateRequest");async function*cn(t){let e=new TextDecoder;if(t.body[Symbol.asyncIterator])for await(let r of t.body)yield e.decode(r);else{let r=t.body.getReader(),n;try{for(;!(n=await r.read()).done;)yield e.decode(n.value)}finally{r.cancel()}}}a(cn,"getStreamBodyIterator");function ln(t,e){return{async*[Symbol.asyncIterator](){try{let r="";for await(let n of t)if(r+=n,r.indexOf(e)>-1){let o=r.lastIndexOf(e),s=r.slice(0,o).split(e).filter(c=>c.trim().length>0).map(c=>c.slice(c.indexOf(Fe)+Fe.length).trim());s.length>0&&(yield s),r=r.slice(o+e.length),r.trim()==="--"&&(r="")}}catch(r){throw new Error(`Error occured while processing stream payload - ${k(r)}`)}}}}a(ln,"readStreamChunk");function dn(t){return{async*[Symbol.asyncIterator](){yield{...await qt(t),hasNext:!1}}}}a(dn,"createJsonResponseAsyncIterator");function un(t){return t.map(e=>{try{return JSON.parse(e)}catch(r){throw new Error(`Error in parsing multipart response - ${k(r)}`)}}).map(e=>{let{data:r,incremental:n,hasNext:o,extensions:i,errors:s}=e;if(!n)return{data:r||{},...x("errors",s),...x("extensions",i),hasNext:o};let c=n.map(({data:l,path:p,errors:d})=>({data:l&&p?je(p,l):{},...x("errors",d)}));return{data:c.length===1?c[0].data:Qe([...c.map(({data:l})=>l)]),...x("errors",ke(c)),hasNext:o}})}a(un,"getResponseDataFromChunkBodies");function pn(t,e){if(t.length>0)throw new Error(Ne,{cause:{graphQLErrors:t}});if(Object.keys(e).length===0)throw new Error(qe)}a(pn,"validateResponseData");function hn(t,e){let r=(e??"").match($t),n=`--${r?r[1]:"-"}`;if(!t.body?.getReader&&!t.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:t});let o=cn(t),i={},s;return{async*[Symbol.asyncIterator](){try{let c=!0;for await(let l of ln(o,n)){let p=un(l);s=p.find(h=>h.extensions)?.extensions??s;let d=ke(p);i=Qe([i,...p.map(({data:h})=>h)]),c=p.slice(-1)[0].hasNext,pn(d,i),yield{...x("data",i),...x("extensions",s),hasNext:c}}if(c)throw new Error("Response stream terminated unexpectedly")}catch(c){let l=Me(c);yield{...x("data",i),...x("extensions",s),errors:{message:B(k(c)),networkStatusCode:t.status,...x("graphQLErrors",l?.graphQLErrors),response:t},hasNext:!1}}}}}a(hn,"createMultipartResponseAsyncInterator");function fn(t){return async(...e)=>{if(!He.test(e[0]))throw new Error(B("This operation does not result in a streamable response - use request() instead."));try{let r=await t(...e),{statusText:n}=r;if(!r.ok)throw new Error(n,{cause:r});let o=r.headers.get("content-type")||"";switch(!0){case o.includes(ge.json):return dn(r);case o.includes(ge.multipart):return hn(r,o);default:throw new Error(`${Ue} ${o}`,{cause:r})}}catch(r){return{async*[Symbol.asyncIterator](){let n=Me(r);yield{errors:{message:B(k(r)),...x("networkStatusCode",n?.status),...x("response",n)},hasNext:!1}}}}}}a(fn,"generateRequestStream");function Ye({client:t,storeDomain:e}){try{if(!e||typeof e!="string")throw new Error;let r=e.trim(),n=r.match(/^https?:/)?r:`https://${r}`,o=new URL(n);return o.protocol="https",o.origin}catch(r){throw new Error(`${t}: a valid store domain ("${e}") must be provided`,{cause:r})}}a(Ye,"validateDomainAndGetStoreUrl");function we({client:t,currentSupportedApiVersions:e,apiVersion:r,logger:n}){let o=`${t}: the provided apiVersion ("${r}")`,i=`Currently supported API versions: ${e.join(", ")}`;if(!r||typeof r!="string")throw new Error(`${o} is invalid. ${i}`);let s=r.trim();e.includes(s)||(n?n({type:"Unsupported_Api_Version",content:{apiVersion:r,supportedApiVersions:e}}):console.warn(`${o} is likely deprecated or not supported. ${i}`))}a(we,"validateApiVersion");function Ie(t){let e=t*3-2;return e===10?e:`0${e}`}a(Ie,"getQuarterMonth");function Ke(t,e,r){let n=e-r;return n<=0?`${t-1}-${Ie(n+4)}`:`${t}-${Ie(n)}`}a(Ke,"getPrevousVersion");function Bt(){let t=new Date,e=t.getUTCMonth(),r=t.getUTCFullYear(),n=Math.floor(e/3+1);return{year:r,quarter:n,version:`${r}-${Ie(n)}`}}a(Bt,"getCurrentApiVersion");function Je(){let{year:t,quarter:e,version:r}=Bt(),n=e===4?`${t+1}-01`:`${t}-${Ie(e+1)}`;return[Ke(t,e,3),Ke(t,e,2),Ke(t,e,1),r,n,"unstable"]}a(Je,"getCurrentSupportedApiVersions");function Xe(t){return e=>({...e??{},...t.headers})}a(Xe,"generateGetHeaders");function Ze({getHeaders:t,getApiUrl:e}){return(r,n)=>{let o=[r];if(n&&Object.keys(n).length>0){let{variables:i,apiVersion:s,headers:c,retries:l,signal:p}=n;o.push({...i?{variables:i}:{},...c?{headers:t(c)}:{},...s?{url:e(s)}:{},...l?{retries:l}:{},...p?{signal:p}:{}})}return o}}a(Ze,"generateGetGQLClientParams");var et="application/json",Gt="storefront-api-client",Ht="1.0.9",Ft="X-Shopify-Storefront-Access-Token",Mt="Shopify-Storefront-Private-Token",kt="X-SDK-Variant",jt="X-SDK-Version",Qt="X-SDK-Variant-Source",te="Storefront API Client";function zt(t){if(t&&typeof window<"u")throw new Error(`${te}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}a(zt,"validatePrivateAccessTokenUsage");function Wt(t,e){if(!t&&!e)throw new Error(`${te}: a public or private access token must be provided`);if(t&&e)throw new Error(`${te}: only provide either a public or private access token`)}a(Wt,"validateRequiredAccessTokens");function tt({storeDomain:t,apiVersion:e,publicAccessToken:r,privateAccessToken:n,clientName:o,retries:i=0,customFetchApi:s,logger:c}){let l=Je(),p=Ye({client:te,storeDomain:t}),d={client:te,currentSupportedApiVersions:l,logger:c};we({...d,apiVersion:e}),Wt(r,n),zt(n);let h=mn(p,e,d),C={storeDomain:p,apiVersion:e,...r?{publicAccessToken:r}:{privateAccessToken:n},headers:{"Content-Type":et,Accept:et,[kt]:Gt,[jt]:Ht,...o?{[Qt]:o}:{},...r?{[Ft]:r}:{[Mt]:n}},apiUrl:h(),clientName:o},m=We({headers:C.headers,url:C.apiUrl,retries:i,customFetchApi:s,logger:c}),I=Xe(C),g=yn(C,h),A=Ze({getHeaders:I,getApiUrl:g});return Object.freeze({config:C,getHeaders:I,getApiUrl:g,fetch:a((...T)=>m.fetch(...A(...T)),"fetch"),request:a((...T)=>m.request(...A(...T)),"request"),requestStream:a((...T)=>m.requestStream(...A(...T)),"requestStream")})}a(tt,"createStorefrontApiClient");function mn(t,e,r){return n=>{n&&we({...r,apiVersion:n});let o=(n??e).trim();return`${t}/api/${o}/graphql.json`}}a(mn,"generateApiUrlFormatter");function yn(t,e){return r=>r?e(r):t.apiUrl}a(yn,"generateGetApiUrl");var O=`
9
+ fragment productImageFields on Image {
10
+ id
11
+ altText
12
+ url
13
+ thumbhash
14
+ }
15
+ `,re=`
16
+ fragment productCardDataFields on Product {
17
+ id
18
+ availableForSale
19
+ category {
20
+ id
21
+ name
22
+ }
23
+ compareAtPriceRange {
24
+ maxVariantPrice {
25
+ amount
26
+ currencyCode
27
+ }
28
+ minVariantPrice {
29
+ amount
30
+ currencyCode
31
+ }
32
+ }
33
+ featuredImage {
34
+ ...productImageFields
35
+ }
36
+ isGiftCard
37
+ onlineStoreUrl
38
+ description
39
+ handle
40
+ priceRange {
41
+ maxVariantPrice {
42
+ amount
43
+ currencyCode
44
+ }
45
+ minVariantPrice {
46
+ amount
47
+ currencyCode
48
+ }
49
+ }
50
+ productType
51
+ tags
52
+ title
53
+ variantsCount {
54
+ count
55
+ }
56
+ # totalInventory
57
+ metafields(identifiers: $productMetafields) {
58
+ key
59
+ namespace
60
+ value
61
+ }
62
+ }
63
+ `,rt=`
64
+ fragment productVariantDataFields on ProductVariant {
65
+ id
66
+ availableForSale
67
+ compareAtPrice {
68
+ amount
69
+ currencyCode
70
+ }
71
+ currentlyNotInStock
72
+ image {
73
+ ...productImageFields
74
+ }
75
+ price {
76
+ amount
77
+ currencyCode
78
+ }
79
+ # quantityAvailable
80
+ selectedOptions {
81
+ name
82
+ value
83
+ }
84
+ sku
85
+ title
86
+ metafields(identifiers: $variantMetafields) {
87
+ key
88
+ namespace
89
+ value
90
+ }
91
+ }
92
+ `,nt=`
93
+ fragment productOptionsVariantFields on ProductVariant {
94
+ id
95
+ selectedOptions {
96
+ name
97
+ value
98
+ }
99
+ }
100
+ `,ot=`
101
+ fragment selectedVariantFields on Product {
102
+ id
103
+ title
104
+ handle
105
+ featuredImage {
106
+ ...productImageFields
107
+ }
108
+ variantBySelectedOptions(selectedOptions: $selectedOptions) {
109
+ id
110
+ availableForSale
111
+ compareAtPrice {
112
+ amount
113
+ currencyCode
114
+ }
115
+ currentlyNotInStock
116
+ image {
117
+ ...productImageFields
118
+ }
119
+ price {
120
+ amount
121
+ currencyCode
122
+ }
123
+ title
124
+ selectedOptions {
125
+ name
126
+ value
127
+ }
128
+ }
129
+ }
130
+ `,ne=`
131
+ fragment productOptionsFields on Product {
132
+ id
133
+ title
134
+ featuredImage {
135
+ ...productImageFields
136
+ }
137
+ encodedVariantAvailability
138
+ encodedVariantExistence
139
+ variantsCount {
140
+ count
141
+ precision
142
+ }
143
+ options {
144
+ id
145
+ name
146
+ optionValues {
147
+ name
148
+ swatch {
149
+ color
150
+ image {
151
+ previewImage {
152
+ url
153
+ }
154
+ }
155
+ }
156
+ firstSelectableVariant {
157
+ id
158
+ image {
159
+ ...productImageFields
160
+ }
161
+ }
162
+ }
163
+ }
164
+ }
165
+ `,at=`
166
+ fragment productImagesFields on Product {
167
+ images(first: 20) {
168
+ nodes {
169
+ ...productImageFields
170
+ }
171
+ }
172
+ }
173
+ `;var Yt=`
174
+ query GetProductCardData(
175
+ $productId: ID!
176
+ $productMetafields: [HasMetafieldsIdentifier!]!
177
+ $country: CountryCode!
178
+ $language: LanguageCode!
179
+ ) @inContext(country: $country, language: $language) {
180
+ product(id: $productId) {
181
+ ...productCardDataFields
182
+ }
183
+ }
184
+ ${re}
185
+ ${O}
186
+ `,Kt=`
187
+ query GetProductCardDataWithVariant(
188
+ $productId: ID!
189
+ $variantId: ID!
190
+ $productMetafields: [HasMetafieldsIdentifier!]!
191
+ $variantMetafields: [HasMetafieldsIdentifier!]!
192
+ $country: CountryCode!
193
+ $language: LanguageCode!
194
+ ) @inContext(country: $country, language: $language) {
195
+ product(id: $productId) {
196
+ ...productCardDataFields
197
+ }
198
+ variant: node(id: $variantId) {
199
+ ...productVariantDataFields
200
+ }
201
+ }
202
+ ${re}
203
+ ${rt}
204
+ ${O}
205
+ `,Jt=`
206
+ query GetProductOptions(
207
+ $productId: ID!
208
+ $country: CountryCode!
209
+ $language: LanguageCode!
210
+ ) @inContext(country: $country, language: $language) {
211
+ product(id: $productId) {
212
+ ...productOptionsFields
213
+ }
214
+ }
215
+ ${ne}
216
+ ${O}
217
+ `,Xt=`
218
+ query GetProductOptionsByHandle(
219
+ $handle: String!
220
+ $country: CountryCode!
221
+ $language: LanguageCode!
222
+ ) @inContext(country: $country, language: $language) {
223
+ product(handle: $handle) {
224
+ ...productOptionsFields
225
+ }
226
+ }
227
+ ${ne}
228
+ ${O}
229
+ `,Zt=`
230
+ query GetProductOptionsWithVariant(
231
+ $productId: ID!
232
+ $variantId: ID!
233
+ $country: CountryCode!
234
+ $language: LanguageCode!
235
+ ) @inContext(country: $country, language: $language) {
236
+ product(id: $productId) {
237
+ ...productOptionsFields
238
+ }
239
+ variant: node(id: $variantId) {
240
+ ...productOptionsVariantFields
241
+ }
242
+ }
243
+ ${ne}
244
+ ${nt}
245
+ ${O}
246
+ `,er=`
247
+ query GetProductOptionsByHandleWithVariant(
248
+ $handle: String!
249
+ $variantId: ID!
250
+ $country: CountryCode!
251
+ $language: LanguageCode!
252
+ ) @inContext(country: $country, language: $language) {
253
+ product(handle: $handle) {
254
+ ...productOptionsFields
255
+ }
256
+ variant: node(id: $variantId) {
257
+ ...productOptionsVariantFields
258
+ }
259
+ }
260
+ ${ne}
261
+ ${nt}
262
+ ${O}
263
+ `,tr=`
264
+ query GetSelectedVariant(
265
+ $productId: ID!
266
+ $selectedOptions: [SelectedOptionInput!]!
267
+ $country: CountryCode!
268
+ $language: LanguageCode!
269
+ ) @inContext(country: $country, language: $language) {
270
+ product(id: $productId) {
271
+ ...selectedVariantFields
272
+ }
273
+ }
274
+ ${ot}
275
+ ${O}
276
+ `,rr=`
277
+ query GetSelectedVariantByHandle(
278
+ $handle: String!
279
+ $selectedOptions: [SelectedOptionInput!]!
280
+ $country: CountryCode!
281
+ $language: LanguageCode!
282
+ ) @inContext(country: $country, language: $language) {
283
+ product(handle: $handle) {
284
+ ...selectedVariantFields
285
+ }
286
+ }
287
+ ${ot}
288
+ ${O}
289
+ `,nr=`
290
+ query GetProductDetailData(
291
+ $productId: ID!
292
+ $productMetafields: [HasMetafieldsIdentifier!]!
293
+ $country: CountryCode!
294
+ $language: LanguageCode!
295
+ ) @inContext(country: $country, language: $language) {
296
+ product(id: $productId) {
297
+ ...productCardDataFields
298
+ ...productOptionsFields
299
+ ...productImagesFields
300
+ }
301
+ }
302
+ ${re}
303
+ ${ne}
304
+ ${at}
305
+ ${O}
306
+ `,or=`
307
+ query GetProductDetailDataWithVariant(
308
+ $productId: ID!
309
+ $variantId: ID!
310
+ $productMetafields: [HasMetafieldsIdentifier!]!
311
+ $variantMetafields: [HasMetafieldsIdentifier!]!
312
+ $country: CountryCode!
313
+ $language: LanguageCode!
314
+ ) @inContext(country: $country, language: $language) {
315
+ product(id: $productId) {
316
+ ...productCardDataFields
317
+ ...productOptionsFields
318
+ ...productImagesFields
319
+ }
320
+ variant: node(id: $variantId) {
321
+ ...productVariantDataFields
322
+ }
323
+ }
324
+ ${re}
325
+ ${ne}
326
+ ${rt}
327
+ ${at}
328
+ ${O}
329
+ `,ar=`
330
+ query GetProductImagesById(
331
+ $ids: [ID!]!
332
+ $country: CountryCode!
333
+ $language: LanguageCode!
334
+ ) @inContext(country: $country, language: $language) {
335
+ nodes(ids: $ids) {
336
+ ... on Product {
337
+ featuredImage {
338
+ ...productImageFields
339
+ }
340
+ }
341
+ ... on ProductVariant {
342
+ image {
343
+ ...productImageFields
344
+ }
345
+ product {
346
+ featuredImage {
347
+ ...productImageFields
348
+ }
349
+ }
350
+ }
351
+ }
352
+ }
353
+ ${O}
354
+ `,ir=`
355
+ query GetProductRecommendationsById(
356
+ $productId: ID!
357
+ $intent: ProductRecommendationIntent
358
+ $productMetafields: [HasMetafieldsIdentifier!]!
359
+ $country: CountryCode!
360
+ $language: LanguageCode!
361
+ ) @inContext(country: $country, language: $language) {
362
+ productRecommendations(productId: $productId, intent: $intent) {
363
+ ...productCardDataFields
364
+ }
365
+ }
366
+ ${re}
367
+ ${O}
368
+ `,sr=`
369
+ query GetProductRecommendationsByHandle(
370
+ $handle: String!
371
+ $intent: ProductRecommendationIntent
372
+ $productMetafields: [HasMetafieldsIdentifier!]!
373
+ $country: CountryCode!
374
+ $language: LanguageCode!
375
+ ) @inContext(country: $country, language: $language) {
376
+ productRecommendations(productHandle: $handle, intent: $intent) {
377
+ ...productCardDataFields
378
+ }
379
+ }
380
+ ${re}
381
+ ${O}
382
+ `,cr=`
383
+ query GetProductIdByHandle($handle: String!) {
384
+ product(handle: $handle) {
385
+ id
386
+ }
387
+ }
388
+ `;var lr=a(async(t,{productId:e,variantId:r,productMetafields:n=[],variantMetafields:o=[]})=>{if(!e)throw new Error("A productId must be provided");let i=a(()=>{if(e&&!r)return Yt;if(e&&r)return Kt},"getProductOptionsQuery"),s=a(()=>{if(e&&!r)return{productId:R("Product",e),productMetafields:n,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};if(e&&r)return{productId:R("Product",e),variantId:R("ProductVariant",r),productMetafields:n,variantMetafields:o,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()}},"getVariables"),c=i(),l=s();if(!l||!c)throw new Error("Invalid query arguments");return t.query(c,l)},"loadProductCardData");var dr=a(async(t,{productId:e,variantId:r,productMetafields:n=[],variantMetafields:o=[]})=>{if(!e)throw new Error("A productId must be provided");let i=a(()=>{if(e&&!r)return nr;if(e&&r)return or},"getProductOptionsQuery"),s=a(()=>{if(e&&!r)return{productId:R("Product",e),productMetafields:n,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};if(e&&r)return{productId:R("Product",e),variantId:R("ProductVariant",r),productMetafields:n,variantMetafields:o,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()}},"getVariables"),c=i(),l=s();if(!l||!c)throw new Error("Invalid query arguments");return t.query(c,l)},"loadProductDetailData");var ur=a(async(t,{items:e})=>{if(!e?.length)throw new Error("A list of items must be provided");let r={ids:e.map(n=>n.variantId?R("ProductVariant",n.variantId.toString()):R("Product",n.productId.toString())),country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};try{return{data:(await t.query(ar,r)).data?.nodes.map(i=>i===null?null:"image"in i?i.image:"featuredImage"in i?i.featuredImage:null).filter(i=>i!==null)??[],error:null}}catch(n){return console.error(n),{data:null,error:n}}},"loadProductImages");var pr=a(async(t,{productId:e,productHandle:r,variantId:n})=>{if(!e&&!r)throw new Error("Either productId or handle must be provided");let o=a(()=>{if(e&&!n)return Jt;if(r&&!n)return Xt;if(e&&n)return Zt;if(r&&n)return er},"getProductOptionsQuery"),i=a(()=>{if(e&&!n)return{productId:R("Product",e),country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};if(r&&!n)return{handle:r,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};if(e&&n)return{productId:R("Product",e),variantId:R("ProductVariant",n),country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};if(r&&n)return{handle:r,variantId:R("ProductVariant",n),country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()}},"getVariables"),s=o(),c=i();if(!c||!s)throw new Error("Invalid query arguments");return t.query(s,c)},"loadProductOptions");var hr=a(async(t,{productId:e,productHandle:r,selectedOptions:n})=>{if(!e&&!r)throw new Error("Either productId or handle must be provided");let o=e?tr:rr,i=e?{productId:`gid://shopify/Product/${e}`,selectedOptions:n,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()}:{handle:r,selectedOptions:n,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};return t.query(o,i)},"loadSelectedVariant");var fr=a(async(t,{productId:e,productHandle:r,intent:n,productMetafields:o=[]})=>{if(!e&&!r)throw new Error("Either productId or productHandle must be provided");let i=f.localization.country.toUpperCase(),s=f.localization.language.toUpperCase();if(e){let l={productId:R("Product",e),intent:n,productMetafields:o,country:i,language:s};return t.query(ir,l)}let c={handle:r,intent:n,productMetafields:o,country:i,language:s};return t.query(sr,c)},"loadProductRecommendations");var mr=a(async(t,{productHandle:e})=>{if(!e)throw new Error("A product handle must be provided");return t.query(cr,{handle:e})},"loadProductId");var gn="2025-07",vn=["GetProductIdByHandle"],be=class{constructor(e){this.client=null;this.query=a(async(e,r)=>{if(!this.client)throw new Error("Storefront API client not initialized");let n=await this.client.request(e,{variables:r});return{data:n.data,errors:n.errors??null}},"query");this.loadProductOptions=a(async e=>pr(this,e),"loadProductOptions");this.loadSelectedVariant=a(async e=>hr(this,e),"loadSelectedVariant");this.loadProductCardData=a(async e=>lr(this,e),"loadProductCardData");this.loadProductDetailData=a(async e=>dr(this,e),"loadProductDetailData");this.loadProductImages=a(async e=>ur(this,e),"loadProductImages");this.loadProductRecommendations=a(async e=>fr(this,e),"loadProductRecommendations");this.loadProductId=a(async e=>mr(this,e),"loadProductId");this.shortCache=new M("storefront-api-short","max-age=60, stale-while-revalidate=3600"),this.longCache=new M("storefront-api-long","max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(r=>{console.warn("Storefront API cache initialization cleanup error:",r)}),this.longCache.cleanupExpiredEntries().catch(r=>{console.warn("Storefront API cache initialization cleanup error:",r)}),this.client=tt({apiVersion:gn,customFetchApi:a((r,n)=>n?.method==="OPTIONS"?this.fetch(r,n):vn.some(o=>n?.body?.toString().includes(`query ${o}`))?this.longCache.fetchWithCache(r,n):this.shortCache.fetchWithCache(r,n),"customFetchApi"),publicAccessToken:e.accessToken,storeDomain:e.storeDomain})}static{a(this,"StorefrontApiClient")}fetch(e,r){return r?.method==="OPTIONS"?fetch(e,r):this.shortCache.fetchWithCache(e,r)}async clearCache(){await this.shortCache.clear()}};var Cn=Object.defineProperty,u=a((t,e)=>Cn(t,"name",{value:e,configurable:!0}),"n"),wn={bodySerializer:u(t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString():r),"bodySerializer")},In={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Ki=Object.entries(In),bn=u(({onRequest:t,onSseError:e,onSseEvent:r,responseTransformer:n,responseValidator:o,sseDefaultRetryDelay:i,sseMaxRetryAttempts:s,sseMaxRetryDelay:c,sseSleepFn:l,url:p,...d})=>{let h,C=l??(m=>new Promise(I=>setTimeout(I,m)));return{stream:u(async function*(){let m=i??3e3,I=0,g=d.signal??new AbortController().signal;for(;!g.aborted;){I++;let A=d.headers instanceof Headers?d.headers:new Headers(d.headers);h!==void 0&&A.set("Last-Event-ID",h);try{let P={redirect:"follow",...d,body:d.serializedBody,headers:A,signal:g},T=new Request(p,P);t&&(T=await t(p,P));let _=await(d.fetch??globalThis.fetch)(T);if(!_.ok)throw new Error(`SSE failed: ${_.status} ${_.statusText}`);if(!_.body)throw new Error("No body in SSE response");let N=_.body.pipeThrough(new TextDecoderStream).getReader(),y="",w=u(()=>{try{N.cancel()}catch{}},"abortHandler");g.addEventListener("abort",w);try{for(;;){let{done:E,value:H}=await N.read();if(E)break;y+=H;let L=y.split(`
389
+
390
+ `);y=L.pop()??"";for(let F of L){let j=F.split(`
391
+ `),J=[],de;for(let U of j)if(U.startsWith("data:"))J.push(U.replace(/^data:\s*/,""));else if(U.startsWith("event:"))de=U.replace(/^event:\s*/,"");else if(U.startsWith("id:"))h=U.replace(/^id:\s*/,"");else if(U.startsWith("retry:")){let mt=Number.parseInt(U.replace(/^retry:\s*/,""),10);Number.isNaN(mt)||(m=mt)}let X,ft=!1;if(J.length){let U=J.join(`
392
+ `);try{X=JSON.parse(U),ft=!0}catch{X=U}}ft&&(o&&await o(X),n&&(X=await n(X))),r?.({data:X,event:de,id:h,retry:m}),J.length&&(yield X)}}}finally{g.removeEventListener("abort",w),N.releaseLock()}break}catch(P){if(e?.(P),s!==void 0&&I>=s)break;let T=Math.min(m*2**(I-1),c??3e4);await C(T)}}},"createStream")()}},"createSseClient"),En=u(t=>{switch(t){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),Sn=u(t=>{switch(t){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),An=u(t=>{switch(t){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),vr=u(({allowReserved:t,explode:e,name:r,style:n,value:o})=>{if(!e){let c=(t?o:o.map(l=>encodeURIComponent(l))).join(Sn(n));switch(n){case"label":return`.${c}`;case"matrix":return`;${r}=${c}`;case"simple":return c;default:return`${r}=${c}`}}let i=En(n),s=o.map(c=>n==="label"||n==="simple"?t?c:encodeURIComponent(c):Ee({allowReserved:t,name:r,value:c})).join(i);return n==="label"||n==="matrix"?i+s:s},"serializeArrayParam"),Ee=u(({allowReserved:t,name:e,value:r})=>{if(r==null)return"";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${t?r:encodeURIComponent(r)}`},"serializePrimitiveParam"),Cr=u(({allowReserved:t,explode:e,name:r,style:n,value:o,valueOnly:i})=>{if(o instanceof Date)return i?o.toISOString():`${r}=${o.toISOString()}`;if(n!=="deepObject"&&!e){let l=[];Object.entries(o).forEach(([d,h])=>{l=[...l,d,t?h:encodeURIComponent(h)]});let p=l.join(",");switch(n){case"form":return`${r}=${p}`;case"label":return`.${p}`;case"matrix":return`;${r}=${p}`;default:return p}}let s=An(n),c=Object.entries(o).map(([l,p])=>Ee({allowReserved:t,name:n==="deepObject"?`${r}[${l}]`:l,value:p})).join(s);return n==="label"||n==="matrix"?s+c:c},"serializeObjectParam"),Rn=/\{[^{}]+\}/g,Tn=u(({path:t,url:e})=>{let r=e,n=e.match(Rn);if(n)for(let o of n){let i=!1,s=o.substring(1,o.length-1),c="simple";s.endsWith("*")&&(i=!0,s=s.substring(0,s.length-1)),s.startsWith(".")?(s=s.substring(1),c="label"):s.startsWith(";")&&(s=s.substring(1),c="matrix");let l=t[s];if(l==null)continue;if(Array.isArray(l)){r=r.replace(o,vr({explode:i,name:s,style:c,value:l}));continue}if(typeof l=="object"){r=r.replace(o,Cr({explode:i,name:s,style:c,value:l,valueOnly:!0}));continue}if(c==="matrix"){r=r.replace(o,`;${Ee({name:s,value:l})}`);continue}let p=encodeURIComponent(c==="label"?`.${l}`:l);r=r.replace(o,p)}return r},"defaultPathSerializer"),Pn=u(({baseUrl:t,path:e,query:r,querySerializer:n,url:o})=>{let i=o.startsWith("/")?o:`/${o}`,s=(t??"")+i;e&&(s=Tn({path:e,url:s}));let c=r?n(r):"";return c.startsWith("?")&&(c=c.substring(1)),c&&(s+=`?${c}`),s},"getUrl");function wr(t){let e=t.body!==void 0;if(e&&t.bodySerializer)return"serializedBody"in t?t.serializedBody!==void 0&&t.serializedBody!==""?t.serializedBody:null:t.body!==""?t.body:null;if(e)return t.body}a(wr,"G");u(wr,"getValidRequestBody");var Dn=u(async(t,e)=>{let r=typeof e=="function"?await e(t):e;if(r)return t.scheme==="bearer"?`Bearer ${r}`:t.scheme==="basic"?`Basic ${btoa(r)}`:r},"getAuthToken"),Ir=u(({allowReserved:t,array:e,object:r}={})=>u(n=>{let o=[];if(n&&typeof n=="object")for(let i in n){let s=n[i];if(s!=null)if(Array.isArray(s)){let c=vr({allowReserved:t,explode:!0,name:i,style:"form",value:s,...e});c&&o.push(c)}else if(typeof s=="object"){let c=Cr({allowReserved:t,explode:!0,name:i,style:"deepObject",value:s,...r});c&&o.push(c)}else{let c=Ee({allowReserved:t,name:i,value:s});c&&o.push(c)}}return o.join("&")},"querySerializer"),"createQuerySerializer"),xn=u(t=>{var e;if(!t)return"stream";let r=(e=t.split(";")[0])==null?void 0:e.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return"json";if(r==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(n=>r.startsWith(n)))return"blob";if(r.startsWith("text/"))return"text"}},"getParseAs"),_n=u((t,e)=>{var r,n;return e?!!(t.headers.has(e)||(r=t.query)!=null&&r[e]||(n=t.headers.get("Cookie"))!=null&&n.includes(`${e}=`)):!1},"checkForExistence"),Ln=u(async({security:t,...e})=>{for(let r of t){if(_n(e,r.name))continue;let n=await Dn(r,e.auth);if(!n)continue;let o=r.name??"Authorization";switch(r.in){case"query":e.query||(e.query={}),e.query[o]=n;break;case"cookie":e.headers.append("Cookie",`${o}=${n}`);break;case"header":default:e.headers.set(o,n);break}}},"setAuthParams"),yr=u(t=>Pn({baseUrl:t.baseUrl,path:t.path,query:t.query,querySerializer:typeof t.querySerializer=="function"?t.querySerializer:Ir(t.querySerializer),url:t.url}),"buildUrl"),gr=u((t,e)=>{var r;let n={...t,...e};return(r=n.baseUrl)!=null&&r.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=br(t.headers,e.headers),n},"mergeConfigs"),On=u(t=>{let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e},"headersEntries"),br=u((...t)=>{let e=new Headers;for(let r of t){if(!r)continue;let n=r instanceof Headers?On(r):Object.entries(r);for(let[o,i]of n)if(i===null)e.delete(o);else if(Array.isArray(i))for(let s of i)e.append(o,s);else i!==void 0&&e.set(o,typeof i=="object"?JSON.stringify(i):i)}return e},"mergeHeaders"),Er=class{static{a(this,"$")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(e){let r=this.getInterceptorIndex(e);this.fns[r]&&(this.fns[r]=null)}exists(e){let r=this.getInterceptorIndex(e);return!!this.fns[r]}getInterceptorIndex(e){return typeof e=="number"?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,r){let n=this.getInterceptorIndex(e);return this.fns[n]?(this.fns[n]=r,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};u(Er,"Interceptors");var it=Er,$n=u(()=>({error:new it,request:new it,response:new it}),"createInterceptors"),Vn=Ir({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Nn={"Content-Type":"application/json"},st=u((t={})=>({...wn,headers:Nn,parseAs:"auto",querySerializer:Vn,...t}),"createConfig"),Sr=u((t={})=>{let e=gr(st(),t),r=u(()=>({...e}),"getConfig"),n=u(p=>(e=gr(e,p),r()),"setConfig"),o=$n(),i=u(async p=>{let d={...e,...p,fetch:p.fetch??e.fetch??globalThis.fetch,headers:br(e.headers,p.headers),serializedBody:void 0};d.security&&await Ln({...d,security:d.security}),d.requestValidator&&await d.requestValidator(d),d.body!==void 0&&d.bodySerializer&&(d.serializedBody=d.bodySerializer(d.body)),(d.body===void 0||d.serializedBody==="")&&d.headers.delete("Content-Type");let h=yr(d);return{opts:d,url:h}},"beforeRequest"),s=u(async p=>{let{opts:d,url:h}=await i(p),C={redirect:"follow",...d,body:wr(d)},m=new Request(h,C);for(let y of o.request.fns)y&&(m=await y(m,d));let I=d.fetch,g=await I(m);for(let y of o.response.fns)y&&(g=await y(g,m,d));let A={request:m,response:g};if(g.ok){let y=(d.parseAs==="auto"?xn(g.headers.get("Content-Type")):d.parseAs)??"json";if(g.status===204||g.headers.get("Content-Length")==="0"){let E;switch(y){case"arrayBuffer":case"blob":case"text":E=await g[y]();break;case"formData":E=new FormData;break;case"stream":E=g.body;break;case"json":default:E={};break}return d.responseStyle==="data"?E:{data:E,...A}}let w;switch(y){case"arrayBuffer":case"blob":case"formData":case"json":case"text":w=await g[y]();break;case"stream":return d.responseStyle==="data"?g.body:{data:g.body,...A}}return y==="json"&&(d.responseValidator&&await d.responseValidator(w),d.responseTransformer&&(w=await d.responseTransformer(w))),d.responseStyle==="data"?w:{data:w,...A}}let P=await g.text(),T;try{T=JSON.parse(P)}catch{}let _=T??P,N=_;for(let y of o.error.fns)y&&(N=await y(_,g,m,d));if(N=N||{},d.throwOnError)throw N;return d.responseStyle==="data"?void 0:{error:N,...A}},"request"),c=u(p=>d=>s({...d,method:p}),"makeMethodFn"),l=u(p=>async d=>{let{opts:h,url:C}=await i(d);return bn({...h,body:h.body,headers:h.headers,method:p,onRequest:u(async(m,I)=>{let g=new Request(m,I);for(let A of o.request.fns)A&&(g=await A(g,h));return g},"onRequest"),url:C})},"makeSseFn");return{buildUrl:yr,connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),getConfig:r,head:c("HEAD"),interceptors:o,options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),request:s,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:c("TRACE")}},"createClient"),S=Sr(st({baseUrl:"https://swish.app/api/2025-10"})),Un=u(t=>(t?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...t}),"listControllerFind"),qn=u(t=>(t.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...t,headers:{"Content-Type":"application/json",...t.headers}}),"listControllerCreate"),Bn=u(t=>(t.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...t}),"listControllerDeleteById"),Gn=u(t=>(t.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...t}),"listControllerFindById"),Hn=u(t=>(t.client??S).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...t,headers:{"Content-Type":"application/json",...t.headers}}),"listControllerUpdateById"),Fn=u(t=>(t.client??S).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...t,headers:{"Content-Type":"application/json",...t.headers}}),"listControllerSetListItemsOrder"),Mn=u(t=>(t.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...t,headers:{"Content-Type":"application/json",...t.headers}}),"listControllerAddItemsToList"),kn=u(t=>(t.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...t}),"listControllerRemoveItemFromList"),jn=u(t=>(t.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...t,headers:{"Content-Type":"application/json",...t.headers}}),"itemControllerDelete"),Qn=u(t=>(t?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...t}),"itemControllerFind"),zn=u(t=>(t.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...t,headers:{"Content-Type":"application/json",...t.headers}}),"itemControllerCreate"),Wn=u(t=>(t?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...t}),"itemControllerCount"),Yn=u(t=>(t.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...t}),"itemControllerDeleteById"),Kn=u(t=>(t.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...t}),"itemControllerFindById"),Jn=u(t=>(t.client??S).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...t,headers:{"Content-Type":"application/json",...t.headers}}),"itemControllerUpdateById"),Xn=u(t=>(t.client??S).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...t,headers:{"Content-Type":"application/json",...t.headers}}),"itemControllerSetListsById"),Zn=u(t=>(t?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles/accounts-version",...t}),"profileControllerCustomerAccountsVersion"),eo=u(t=>(t.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...t,headers:{"Content-Type":"application/json",...t.headers}}),"profileControllerIdentify"),to=u(t=>(t.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...t,headers:{"Content-Type":"application/json",...t.headers}}),"profileControllerCreateToken"),Se="2025-10",ro=`https://swish.app/api/${Se}`,Ar=u(t=>new no(t),"createApiClient"),Rr=class{static{a(this,"H")}constructor(e){this.client=Sr(st({baseUrl:ro})),this.items={list:u(r=>this.handlePaginatedRequest(Qn({query:r,client:this.client})),"list"),create:u(r=>this.handleRequest(zn({body:r,client:this.client})),"create"),delete:u(r=>this.handleRequest(jn({body:{itemIds:r},client:this.client})),"delete"),findById:u(r=>this.handleRequest(Kn({path:{itemId:r},client:this.client})),"findById"),updateById:u((r,n)=>this.handleRequest(Jn({body:n,path:{itemId:r},client:this.client})),"updateById"),deleteById:u(r=>this.handleRequest(Yn({path:{itemId:r},client:this.client})),"deleteById"),setListsById:u((r,n)=>this.handleRequest(Xn({body:{listIds:n},path:{itemId:r},client:this.client})),"setListsById"),count:u(()=>this.handleRequest(Wn({client:this.client})),"count")},this.lists={list:u(r=>this.handlePaginatedRequest(Un({query:r,client:this.client})),"list"),create:u(r=>this.handleRequest(qn({body:r,client:this.client})),"create"),findById:u(r=>this.handleRequest(Gn({path:{listId:r},client:this.client})),"findById"),updateById:u((r,n)=>this.handleRequest(Hn({body:n,path:{listId:r},client:this.client})),"updateById"),deleteById:u(r=>this.handleRequest(Bn({path:{listId:r},client:this.client})),"deleteById"),orderItems:u((r,n)=>this.handleRequest(Fn({body:{itemIds:n},path:{listId:r},client:this.client})),"orderItems"),addItemsToList:u((r,n)=>this.handleRequest(Mn({body:{itemIds:n},path:{listId:r},client:this.client})),"addItemsToList"),removeItemFromList:u((r,n)=>this.handleRequest(kn({path:{listId:r,itemId:n},client:this.client})),"removeItemFromList")},this.profiles={customerAccountsVersion:u(()=>this.handleRequest(Zn({client:this.client})),"customerAccountsVersion"),createToken:u((r={})=>this.handleRequest(to({body:r,client:this.client})),"createToken"),identify:u(r=>this.handleRequest(eo({body:r,client:this.client})),"identify")},this.handleRequest=u(async r=>{let{data:n,error:o}=await r;return o!=null&&o.error?{error:o.error}:{data:n?.data}},"handleRequest"),this.handlePaginatedRequest=u(async r=>{var n;let{data:o,error:i}=await r;return i!=null&&i.error?{error:i.error}:{data:o?.data??[],pageInfo:o?.pageInfo??{next:null,previous:null,totalCount:((n=o?.data)==null?void 0:n.length)??0}}},"handlePaginatedRequest"),this.profile=e.profile,e.authToken&&(this.authToken=e.authToken),e.config&&this.client.setConfig(e.config),this.client.interceptors.request.use(this.requestInterceptor.bind(this)),e.requestInterceptor&&this.client.interceptors.request.use(e.requestInterceptor),e.responseInterceptor&&this.client.interceptors.response.use(e.responseInterceptor)}setProfile(e){this.profile=e}getProfile(){return this.profile}setAuthToken(e){this.authToken=e}setConfig(e){this.client.setConfig(e)}requestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),this.profile&&e.headers.set("Profile",this.profile),e}};u(Rr,"SwishClient");var no=Rr;var xr=Xr(Dr(),1);var _r=a(t=>new xr.default(async e=>{let r=[...new Set(e)].sort((o,i)=>o.localeCompare(i)),n=await t.items.list({query:r.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(o=>{let i=n.data.find(s=>o===`variant:${s.variantId}`||o===`product:${s.productId}`);return{data:i?[i]:[],pageInfo:{next:null,previous:null,totalCount:i?1:0}}})},{batchScheduleFn:a(e=>setTimeout(e,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var Ae=class{static{a(this,"SwishApi")}constructor(e,r){this.config=e,this.cache=new M("swish-api","max-age=60, stale-while-revalidate=3600",r+Se),this.cache.cleanupExpiredEntries().catch(o=>{console.warn("Swish API cache initialization cleanup error:",o)});let n=this.config.loadProfile?.();this.apiClient=Ar({profile:n,config:{...e,fetch:a((o,i)=>(o instanceof Request?o.method:i?.method??"GET")==="GET"?this.cache.fetchWithCache(o,i):fetch(o,i),"fetch")},requestInterceptor:a(async o=>(o.headers.set("Swish-Api-Version",Se),o),"requestInterceptor"),responseInterceptor:a(async(o,i)=>(this.processProfileHeader(o),i.method!=="GET"&&await this.cache.clear(),await this.config.responseInterceptor?.(o,i),o),"responseInterceptor")}),this.itemsLoader=_r(this)}processProfileHeader(e){let r=e.headers.get("Set-Profile");r?(this.apiClient.setProfile(r),this.config.storeProfile?.(r)):r===""&&this.config.deleteProfile?.()}get items(){return{...this.apiClient.items,list:a(async(e,r)=>{if(!f.customer.id&&!this.apiClient.getProfile())return{data:[],pageInfo:{next:null,previous:null,totalCount:0}};if(r?.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 o=n[0];if(!o.match(/^product:\d+$/)&&!o.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(o)}return this.apiClient.items.list(e)},"list"),findById:a(async e=>!f.customer.id&&!this.apiClient.getProfile()?{data:null}:this.apiClient.items.findById(e),"findById")}}get lists(){return{...this.apiClient.lists,list:a(async e=>!f.customer.id&&!this.apiClient.getProfile()?{data:[],pageInfo:{next:null,previous:null,totalCount:0}}:this.apiClient.lists.list(e),"list"),findById:a(async e=>!f.customer.id&&!this.apiClient.getProfile()?{data:null}:this.apiClient.lists.findById(e),"findById")}}get profiles(){return this.apiClient.profiles}async clearCache(){await this.cache.clear()}};var Re=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{a(this,"SwishApiPublisher")}async processFetchResponse(e,r){try{let n=this.getEventName(r.method,e.status,r.url);if(!n)return;let o=await e.clone().text();if(e.headers.get("Content-Type")?.includes("application/json"))try{o=JSON.parse(o).data}catch(i){console.warn(i)}this.eventBus.publish(n,o)}catch(n){console.warn(n)}}getEventName(e,r,n){e=e.toUpperCase();let o=new URL(n).pathname;return e==="GET"||r<200||r>=300?void 0:Object.entries(this.eventMap).find(([s])=>{let[c,l]=s.split(" ");return c!==e?!1:new RegExp(l).test(o)})?.[1]}};var Te=class extends HTMLElement{constructor(){super();this.getComponentRef=a(()=>this.componentRef,"getComponentRef");this.setComponentRef=a(r=>{this.componentRef=r},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let r=this.querySelector("template");r&&this.shadowRoot&&(this.shadowRoot.appendChild(r.content),r.remove())}static{a(this,"SwishUiElement")}};var fo=".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}",mo=`<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=${window.location.pathname}></form>`,ut=class extends HTMLElement{constructor(){super();this.swish=window.swish;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=`
393
+ <style>${fo}</style>
394
+ ${mo}
395
+ `,this.emailInput=this.querySelector("#customer_login_email")),this.shopModalObserver=new MutationObserver(r=>{r.forEach(n=>{n.attributeName==="style"&&document.documentElement.style.overflow==="hidden"&&this.dispatchEvent(new CustomEvent("shop-modal-open"))})}),this.shopModalObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["style"]})}static{a(this,"ShopBridge")}disconnectedCallback(){this.shopModalObserver?.disconnect()}async load(){try{(window.Shopify?.featureAssets?.["shop-js"]?.["init-customer-accounts"]?.[0]??"").includes("init-customer-accounts")&&(await Promise.all(window.Shopify?.featureAssets?.["shop-js"]?.["init-customer-accounts"]?.map(n=>import(`/cdn/shopifycloud/shop-js/${n}`))??[]),window.Shopify?.SignInWithShop?.initCustomerAccounts?.(!0,{fedCMEnabled:!0,windoidEnabled:!1}))}catch(r){console.warn("Failed to initialize Shop JS",r)}}update(r){if(r.email&&(this.emailInput.value=r.email,this.emailInput.dispatchEvent(new Event("input"))),r.returnTo){let n=this.querySelector("input[name='return_url']");n&&(n.value=r.returnTo)}}};customElements.define("swish-shop-bridge",ut);var oe={baseUrl:"/apps/wishlist",version:"0.0.0"},Pe,De,xe,Or=a(t=>{oe=t},"setConfig"),Y=new Map,$r=a(async t=>{if(Y.has(t))return Y.get(t);let e=(async()=>{typeof t=="string"&&(t=await V(t)),!(!t||t.getAttribute("open")!=="true")&&t.setAttribute("open","false")})().finally(()=>{Y.delete(t)});return Co(),Y.set(t,e),e},"hideModal"),G=a(async t=>{if(Y.has(t))return Y.get(t);let e=(async()=>{typeof t=="string"&&(t=await V(t)),!(!t||t.getAttribute("open")==="true")&&t.setAttribute("open","true")})().finally(()=>{Y.delete(t)});return vo(),Y.set(t,e),e},"showModal"),Vr=a(async t=>{let e=await V("sign-in");e.setAttribute("return-to",t?.returnTo??window.location.pathname),await G(e)},"showSignIn"),Nr=a(async t=>{if(!t.itemId)throw new Error("An itemId is required to show the unsave alert");K();let e=await V("unsave-alert",{listeners:{submit:a(r=>{r instanceof CustomEvent?t.onSubmit?.(r.detail):console.warn("Unsave alert submitted without detail",r)},"submit"),cancel:a(()=>{t.onCancel?.()},"cancel")}});e.setAttribute("item-id",t.itemId),await G(e)},"showUnsaveAlert"),Ur=a(async t=>{if(!t.listId)throw new Error("A listId is required to show the delete list alert");K();let e=await V("delete-list-alert",{listeners:{submit:a(()=>{t.onSubmit?.()},"submit"),cancel:a(()=>{t.onCancel?.()},"cancel")}});e.setAttribute("list-id",t.listId),await G(e)},"showDeleteListAlert"),qr=a(async()=>{K();let t=await V("drawer");t.setAttribute("account-url",f.routes.accountUrl),f.customer.id&&t.setAttribute("customer-id",f.customer.id),await G(t)},"showDrawer"),Br=a(async t=>{if(!t.listId)throw new Error("listId is required");K();let e=await V("list-menu",{listeners:{close:a(r=>{"detail"in r&&r.detail?t.onClose?.(r.detail):(console.warn("List menu closed without detail",r),t.onClose?.({reason:"unknown"}))},"close")}});e.setAttribute("list-id",t.listId),await G(e)},"showListMenu"),Gr=a(async t=>{if(!t.itemId)throw new Error("itemId is required");K();let e=await V("list-select",{listeners:{submit:a(async r=>{"detail"in r&&r.detail?t?.onSubmit?.(r.detail):console.warn("List select form submitted without detail",r)},"submit"),close:a(()=>{t.onClose?.()},"close"),unsave:a(r=>{r instanceof CustomEvent?t.onUnsave?.(r.detail):console.warn("List select unsave without detail",r)},"unsave")}});e.setAttribute("item-id",t.itemId),await G(e)},"showListSelect"),Hr=a(async t=>{await V("notifications",{onHydrated:a(e=>{e.current.pushNotification(t)},"onHydrated")})},"showNotification"),K=a(async()=>{pt("notifications")&&await V("notifications",{onHydrated:a(t=>{t.current.clearAllNotifications()},"onHydrated")})},"hideAllNotifications"),Fr=a(async t=>{K();let e=await V("variant-select",{listeners:{submit:a(async r=>{"detail"in r&&r.detail?t?.onSubmit?.(r.detail):console.warn("Variant select form submitted without detail",r)},"submit")}});if(t?.productId)e.setAttribute("product-id",t.productId);else if(t?.productHandle)e.setAttribute("product-handle",t.productHandle);else throw new Error("Either productId or productHandle must be provided");t?.variantId&&e.setAttribute("variant-id",t.variantId),t?.action&&e.setAttribute("action",t.action),e.setAttribute("display-type",t?.displayType??"pills"),await G(e)},"showVariantSelect"),Mr=a(async t=>{let e=await V("list-editor",{listeners:{submit:a(async r=>{"detail"in r&&r.detail?t?.onSubmit?.(r.detail):console.warn("List editor form submitted without detail",r)},"submit")}});t?.listId&&e.setAttribute("list-id",t.listId),await G(e)},"showListEditor"),kr=a(async({onShopModalOpen:t})=>{let e=document.querySelector("swish-shop-bridge");if(e||(document.body.insertAdjacentHTML("beforeend","<swish-shop-bridge></swish-shop-bridge>"),e=document.querySelector("swish-shop-bridge")),!e)throw new Error("Failed to initialize Shop Bridge");return e.addEventListener("shop-modal-open",()=>t(),{once:!0}),await e.load(),e},"initShopBridge"),le=a(async()=>xe||(xe=fetch(`${oe?.baseUrl??""}/ui@${oe.version}/manifest.json`).then(t=>t.json()),xe),"loadManifest"),Lr=new Map,V=a(async(t,e)=>{let r=await le(),n=r.prerender[t],o=`${oe?.baseUrl??""}/ui@${oe?.version}/${r.scripts[t]}`,i=e?.instance,s=e?.listeners,c=pt(t,i)??await go({name:t,template:n,refElement:document.body,position:"beforeend",instance:i});c.shadowRoot&&!c.hasAttribute("hydrated")?Promise.all([yo(),import(o)]).then(([l,{hydrate:p}])=>{c.shadowRoot&&l&&(c.shadowRoot.adoptedStyleSheets=[...c.shadowRoot.adoptedStyleSheets,l]),p(c),c.setAttribute("hydrated",""),e?.onHydrated?.(c.getComponentRef())}):c.hasAttribute("hydrated")&&e?.onHydrated?.(c.getComponentRef());for(let{event:l,listener:p}of Lr.values())c.removeEventListener(l,p);for(let[l,p]of Object.entries(s??{}))Lr.set(`${t}-${i}-${l}`,{event:l,listener:p}),c.addEventListener(l,p);return c},"requireUiComponent");async function yo(){return De||(De=new Promise((t,e)=>le().then(r=>r.stylesheets.nonCritical?fetch(`${oe?.baseUrl??""}/ui@${oe?.version}/${r.stylesheets.nonCritical}`):new Response("")).then(r=>r.text()).then(r=>{let n=new CSSStyleSheet;n.replaceSync(r),t(n)}).catch(e)),De)}a(yo,"loadNonCriticalStylesheet");var go=a(async({name:t,instance:e,template:r,position:n,refElement:o})=>{o.insertAdjacentHTML(n,r.replace(' shadowrootmode="open"',""));let i=pt(t,e);if(!i)throw new Error(`Element ${t} not found in DOM`);if(!Pe){let s=await le();Pe=new CSSStyleSheet,Pe.replaceSync(s.css.critical)}return i.shadowRoot&&(i.shadowRoot.adoptedStyleSheets=[Pe]),i},"insertComponent"),pt=a((t,e)=>{let r=`swish-ui[ref="${t}${e?`-${e}`:""}"]`;return document.querySelector(r)},"queryComponent"),ie,ce=0,_e=0,vo=a(()=>{ce++,ce===1&&(_e=window.scrollY,ie||(ie=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,ie]),ie.replaceSync(`
396
+ html[locked] body {
397
+ overflow: hidden;
398
+ position: fixed;
399
+ top: -${_e}px;
400
+ left: 0px;
401
+ right: 0px;
402
+ }
403
+ `),document.documentElement.setAttribute("locked",""))},"lockScroll"),Co=a(()=>{ce>0&&ce--,ce===0&&(ie&&ie.replaceSync(""),window.scrollTo({top:_e,behavior:"instant"}),_e=0,document.documentElement.removeAttribute("locked"))},"unlockScroll");typeof requestIdleCallback=="function"?requestIdleCallback(()=>{le()}):setTimeout(()=>{le()},1e3);var wo="0.52.0",f={customer:{id:null,email:null,firstName:null,lastName:null,b2b:null},localization:{country:"",language:"",market:0},routes:{accountUrl:"/account",accountLoginUrl:"/account/login",rootUrl:"/"}},Gs=a(async t=>{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})}try{let n=document.getElementById("swishEmbedData");if(!n)throw new Error("Swish embed data not found");Object.assign(f,JSON.parse(n.innerText))}catch(n){console.warn("Could not read Swish embed data.",{cause:n})}let e=t.proxy?.baseUrl??"/apps/wishlist",r=new ht({loadProfile:a(()=>localStorage.getItem("swish-profile")??void 0,"loadProfile"),storeProfile:a(n=>localStorage.setItem("swish-profile",n),"storeProfile"),deleteProfile:a(()=>localStorage.removeItem("swish-profile"),"deleteProfile"),proxy:{baseUrl:e},ui:t.ui,storefront:t.storefront});try{let n=localStorage.getItem("swish-profile");n&&f.customer.id?await r.api.clearCache():!n&&!f.customer.id&&await r.api.clearCache()}catch(n){console.warn("Could not check if customer logged out.",{cause:n})}return window.swish=r,document.dispatchEvent(new Event("swish-ready")),r},"swishApp"),ht=class{constructor(e){this.ui={showSignIn:Vr,showVariantSelect:Fr,initShopBridge:kr,showNotification:Hr,hideAllNotifications:K,showListSelect:Gr,showDrawer:qr,showListEditor:Mr,showUnsaveAlert:Nr,hideModal:$r,showModal:G,showListMenu:Br,showDeleteListAlert:Ur};this.dom={createElementLocator:gt,createQueryParamsObserver:he};this.state={itemContext:Rt(this),itemState:Tt(this),itemCount:Pt(this),swishQuery:Dt(this),effect:$,signal:b};this.options=e,this.events=new fe;let r={baseUrl:`${this.options.proxy.baseUrl}/api`,...this.options.swishApi??{}};this.swishApiPublisher=new Re(this.events);let n=[wo,e.ui?.version].join("-");this.swishApi=new Ae({...r,responseInterceptor:this.swishApiPublisher.processFetchResponse,loadProfile:e.loadProfile,storeProfile:e.storeProfile,deleteProfile:e.deleteProfile},n),this.ajaxApiPublisher=new pe(this.events),this.ajaxApi=new ue({storeDomain:this.options.storefront.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.storefrontApi=new be(this.options.storefront),this.options.ui&&Or(this.options.ui),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",Te)}static{a(this,"SwishApp")}get customer(){return f.customer}get localization(){return f.localization}get shopifyRoutes(){return f.routes}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.options.storefront.storeDomain}`}};export{ht as SwishApp,wo as VERSION,Gs as swishApp,f as swishEmbedData};
@@ -0,0 +1,57 @@
1
+ import type { SwishClientConfig } from "@swishapp/api-client";
2
+ import type { SwishApp } from "./swish";
3
+ import type { StorefrontConfig } from "./storefront-api/storefront-api-client";
4
+ export interface SwishAppOptions {
5
+ loadProfile?: () => string | undefined;
6
+ storeProfile?: (profile: string) => void;
7
+ deleteProfile?: () => void;
8
+ proxy: {
9
+ baseUrl: string;
10
+ };
11
+ swishApi?: SwishClientConfig;
12
+ ui?: SwishUiOptions;
13
+ storefront: StorefrontConfig;
14
+ }
15
+ export interface SwishUiOptions {
16
+ baseUrl: string;
17
+ version: string;
18
+ }
19
+ export interface SwishUiManifest {
20
+ scripts: Record<string, string>;
21
+ prerender: Record<string, string>;
22
+ css: {
23
+ critical: string;
24
+ };
25
+ stylesheets: {
26
+ nonCritical: string;
27
+ };
28
+ version: string;
29
+ }
30
+ export interface SwishUiElementSpec {
31
+ script: string;
32
+ template: string;
33
+ }
34
+ export interface SwishEmbedData {
35
+ customer: {
36
+ id: string | null;
37
+ email: string | null;
38
+ firstName: string | null;
39
+ lastName: string | null;
40
+ b2b: boolean | null;
41
+ };
42
+ localization: {
43
+ country: string;
44
+ language: string;
45
+ market: number;
46
+ };
47
+ routes: {
48
+ accountUrl: string;
49
+ accountLoginUrl: string;
50
+ rootUrl: string;
51
+ };
52
+ }
53
+ declare global {
54
+ interface Window {
55
+ swish: SwishApp;
56
+ }
57
+ }
@@ -0,0 +1,26 @@
1
+ export declare class ShopBridge extends HTMLElement {
2
+ readonly swish: import("..").SwishApp;
3
+ private readonly emailInput;
4
+ private readonly shopModalObserver;
5
+ constructor();
6
+ disconnectedCallback(): void;
7
+ load(): Promise<void>;
8
+ update(changes: any): void;
9
+ }
10
+ declare global {
11
+ interface Window {
12
+ Shopify?: {
13
+ featureAssets?: {
14
+ "shop-js"?: {
15
+ "init-customer-accounts"?: string[];
16
+ };
17
+ };
18
+ SignInWithShop?: {
19
+ initCustomerAccounts?: (enabled: boolean, options: {
20
+ fedCMEnabled: boolean;
21
+ windoidEnabled: boolean;
22
+ }) => void;
23
+ };
24
+ };
25
+ }
26
+ }
@@ -0,0 +1,2 @@
1
+ export declare const shopifyGidToId: (gid: string) => string | undefined;
2
+ export declare const shopifyIdToGid: (type: string, id: string) => string;