@appmate/wishlist
Advanced tools
Comparing version 4.14.5 to 4.14.6
@@ -1,2 +0,2 @@ | ||
var ae=Object.create;var gt=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var Ct=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var ce=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of oe(e))!he.call(a,s)&&s!==t&>(a,s,{get:()=>e[s],enumerable:!(i=At(e,s))||i.enumerable});return a};var yt=(a,e,t)=>(t=a!=null?ae(le(a)):{},ce(e||!a||!a.__esModule?gt(t,"default",{value:a,enumerable:!0}):t,a));var Tt=(a,e,t,i)=>{for(var s=i>1?void 0:i?At(e,t):e,r=a.length-1,n;r>=0;r--)(n=a[r])&&(s=(i?n(e,t,s):n(s))||s);return i&&s&>(e,t,s),s};var Ft=Ct((fi,Mt)=>{"use strict";var me=function(){function a(t,i){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=we(i),this._batchScheduleFn=Ie(i),this._cacheKeyFn=be(i),this._cacheMap=ve(i),this._batch=null}var e=a.prototype;return e.load=function(i){if(i==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(i)+"."));var s=ge(this),r=this._cacheMap,n=this._cacheKeyFn(i);if(r){var o=r.get(n);if(o){var l=s.cacheHits||(s.cacheHits=[]);return new Promise(function(c){l.push(function(){c(o)})})}}s.keys.push(i);var h=new Promise(function(c,d){s.callbacks.push({resolve:c,reject:d})});return r&&r.set(n,h),h},e.loadMany=function(i){if(!kt(i))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+i+"."));for(var s=[],r=0;r<i.length;r++)s.push(this.load(i[r]).catch(function(n){return n}));return Promise.all(s)},e.clear=function(i){var s=this._cacheMap;if(s){var r=this._cacheKeyFn(i);s.delete(r)}return this},e.clearAll=function(){var i=this._cacheMap;return i&&i.clear(),this},e.prime=function(i,s){var r=this._cacheMap;if(r){var n=this._cacheKeyFn(i);if(r.get(n)===void 0){var o;s instanceof Error?(o=Promise.reject(s),o.catch(function(){})):o=Promise.resolve(s),r.set(n,o)}}return this},a}(),fe=typeof process=="object"&&typeof process.nextTick=="function"?function(a){wt||(wt=Promise.resolve()),wt.then(function(){process.nextTick(a)})}:typeof setImmediate=="function"?function(a){setImmediate(a)}:function(a){setTimeout(a)},wt;function ge(a){var e=a._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<a._maxBatchSize&&(!e.cacheHits||e.cacheHits.length<a._maxBatchSize))return e;var t={hasDispatched:!1,keys:[],callbacks:[]};return a._batch=t,a._batchScheduleFn(function(){ye(a,t)}),t}function ye(a,e){if(e.hasDispatched=!0,e.keys.length===0){It(e);return}var t=a._batchLoadFn(e.keys);if(!t||typeof t.then!="function")return Ot(a,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(i){if(!kt(i))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(i)+"."));if(i.length!==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."+(` | ||
var oe=Object.create;var yt=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var Ct=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var pe=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of le(e))!ce.call(a,s)&&s!==t&&yt(a,s,{get:()=>e[s],enumerable:!(i=Ut(e,s))||i.enumerable});return a};var wt=(a,e,t)=>(t=a!=null?oe(he(a)):{},pe(e||!a||!a.__esModule?yt(t,"default",{value:a,enumerable:!0}):t,a));var Tt=(a,e,t,i)=>{for(var s=i>1?void 0:i?Ut(e,t):e,r=a.length-1,n;r>=0;r--)(n=a[r])&&(s=(i?n(e,t,s):n(s))||s);return i&&s&&yt(e,t,s),s};var Ft=Ct((fi,Mt)=>{"use strict";var fe=function(){function a(t,i){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=Ie(i),this._batchScheduleFn=be(i),this._cacheKeyFn=ve(i),this._cacheMap=Pe(i),this._batch=null}var e=a.prototype;return e.load=function(i){if(i==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(i)+"."));var s=ye(this),r=this._cacheMap,n=this._cacheKeyFn(i);if(r){var o=r.get(n);if(o){var l=s.cacheHits||(s.cacheHits=[]);return new Promise(function(c){l.push(function(){c(o)})})}}s.keys.push(i);var h=new Promise(function(c,d){s.callbacks.push({resolve:c,reject:d})});return r&&r.set(n,h),h},e.loadMany=function(i){if(!kt(i))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+i+"."));for(var s=[],r=0;r<i.length;r++)s.push(this.load(i[r]).catch(function(n){return n}));return Promise.all(s)},e.clear=function(i){var s=this._cacheMap;if(s){var r=this._cacheKeyFn(i);s.delete(r)}return this},e.clearAll=function(){var i=this._cacheMap;return i&&i.clear(),this},e.prime=function(i,s){var r=this._cacheMap;if(r){var n=this._cacheKeyFn(i);if(r.get(n)===void 0){var o;s instanceof Error?(o=Promise.reject(s),o.catch(function(){})):o=Promise.resolve(s),r.set(n,o)}}return this},a}(),ge=typeof process=="object"&&typeof process.nextTick=="function"?function(a){It||(It=Promise.resolve()),It.then(function(){process.nextTick(a)})}:typeof setImmediate=="function"?function(a){setImmediate(a)}:function(a){setTimeout(a)},It;function ye(a){var e=a._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<a._maxBatchSize&&(!e.cacheHits||e.cacheHits.length<a._maxBatchSize))return e;var t={hasDispatched:!1,keys:[],callbacks:[]};return a._batch=t,a._batchScheduleFn(function(){we(a,t)}),t}function we(a,e){if(e.hasDispatched=!0,e.keys.length===0){bt(e);return}var t=a._batchLoadFn(e.keys);if(!t||typeof t.then!="function")return Ot(a,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(i){if(!kt(i))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(i)+"."));if(i.length!==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."+(` | ||
@@ -7,2 +7,2 @@ Keys: | ||
Values: | ||
`+String(i)));It(e);for(var s=0;s<e.callbacks.length;s++){var r=i[s];r instanceof Error?e.callbacks[s].reject(r):e.callbacks[s].resolve(r)}}).catch(function(i){Ot(a,e,i)})}function Ot(a,e,t){It(e);for(var i=0;i<e.keys.length;i++)a.clear(e.keys[i]),e.callbacks[i].reject(t)}function It(a){if(a.cacheHits)for(var e=0;e<a.cacheHits.length;e++)a.cacheHits[e]()}function we(a){var e=!a||a.batch!==!1;if(!e)return 1;var t=a&&a.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}function Ie(a){var e=a&&a.batchScheduleFn;if(e===void 0)return fe;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}function be(a){var e=a&&a.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}function ve(a){var e=!a||a.cache!==!1;if(!e)return null;var t=a&&a.cacheMap;if(t===void 0)return new Map;if(t!==null){var i=["get","set","delete","clear"],s=i.filter(function(r){return t&&typeof t[r]!="function"});if(s.length!==0)throw new TypeError("Custom cacheMap missing methods: "+s.join(", "))}return t}function kt(a){return typeof a=="object"&&a!==null&&typeof a.length=="number"&&(a.length===0||a.length>0&&Object.prototype.hasOwnProperty.call(a,a.length-1))}Mt.exports=me});var St=Ct((Li,Wt)=>{var Pt=(()=>{var a=Object.defineProperty,e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(y,m,f)=>m in y?a(y,m,{enumerable:!0,configurable:!0,writable:!0,value:f}):y[m]=f,r=(y,m)=>{for(var f in m||(m={}))t.call(m,f)&&s(y,f,m[f]);if(e)for(var f of e(m))i.call(m,f)&&s(y,f,m[f]);return y},n=y=>a(y,"__esModule",{value:!0}),o=(y,m)=>{n(y);for(var f in m)a(y,f,{get:m[f],enumerable:!0})},l={};o(l,{DEFAULT_UUID_LENGTH:()=>c,default:()=>v});var h="4.4.4",c=6,d={dictionary:"alphanum",shuffle:!0,debug:!1,length:c},I=class extends Function{constructor(y={}){super(),this.dictIndex=0,this.dictRange=[],this.lowerBound=0,this.upperBound=0,this.dictLength=0,this._digit_first_ascii=48,this._digit_last_ascii=58,this._alpha_lower_first_ascii=97,this._alpha_lower_last_ascii=123,this._hex_last_ascii=103,this._alpha_upper_first_ascii=65,this._alpha_upper_last_ascii=91,this._number_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii]},this._alpha_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alpha_lower_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alpha_upper_dict_ranges={upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_lower_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alphanum_upper_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._hex_dict_ranges={decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]},this.log=(...u)=>{let p=[...u];if(p[0]=`[short-unique-id] ${u[0]}`,this.debug===!0&&typeof console!="undefined"&&console!==null)return console.log(...p)},this.setDictionary=(u,p)=>{let b;if(u&&Array.isArray(u)&&u.length>1)b=u;else{b=[];let g;this.dictIndex=g=0;let E=`_${u}_dict_ranges`,A=this[E];Object.keys(A).forEach(q=>{let V=q;for(this.dictRange=A[V],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=g=this.lowerBound;this.lowerBound<=this.upperBound?g<this.upperBound:g>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?g+=1:g-=1)b.push(String.fromCharCode(this.dictIndex))})}p&&(b=b.sort(()=>Math.random()-.5)),this.dict=b,this.dictLength=this.dict.length,this.counter=0},this.seq=()=>this.sequentialUUID(),this.sequentialUUID=()=>{let u,p,b="";u=this.counter;do p=u%this.dictLength,u=Math.trunc(u/this.dictLength),b+=this.dict[p];while(u!==0);return this.counter+=1,b},this.randomUUID=(u=this.uuidLength||c)=>{let p,b,g;if(u===null||typeof u=="undefined"||u<1)throw new Error("Invalid UUID Length Provided");let E=u>=0;for(p="",g=0;g<u;g+=1)b=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,p+=this.dict[b];return p},this.availableUUIDs=(u=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,u).toFixed(0)),this.approxMaxBeforeCollision=(u=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*u).toFixed(20)),this.collisionProbability=(u=this.availableUUIDs(this.uuidLength),p=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(u)/this.availableUUIDs(p)).toFixed(20)),this.uniqueness=(u=this.availableUUIDs(this.uuidLength))=>{let p=parseFloat((1-this.approxMaxBeforeCollision(u)/u).toFixed(20));return p>1?1:p<0?0:p},this.getVersion=()=>this.version,this.stamp=u=>{if(typeof u!="number"||u<10)throw new Error("Param finalLength must be number greater than 10");let p=Math.floor(+new Date/1e3).toString(16),b=u-9,g=Math.round(Math.random()*(b>15?15:b)),E=this.randomUUID(b);return`${E.substr(0,g)}${p}${E.substr(g)}${g.toString(16)}`},this.parseStamp=u=>{if(u.length<10)throw new Error("Stamp length invalid");let p=parseInt(u.substr(u.length-1,1),16);return new Date(parseInt(u.substr(p,8),16)*1e3)};let m=r(r({},d),y);this.counter=0,this.debug=!1,this.dict=[],this.version=h;let{dictionary:f,shuffle:S,length:k}=m;return this.uuidLength=k,this.setDictionary(f,S),this.debug=m.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength}`),new Proxy(this,{apply:(u,p,b)=>this.randomUUID(...b)})}},v=I;return v.default=I,l})();typeof Wt!="undefined"&&(Wt.exports=Pt.default),typeof window!="undefined"&&(Pt=Pt.default)});import{lastValueFrom as U}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{fromFetch as pe}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/fetch/+esm";import{switchMap as ue}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";var F=class{constructor(e){this.host=e.host,this.headers={"content-type":"application/json"}}fetch({path:e,method:t="GET",query:i,body:s,headers:r={}}){return pe(this.host+e+this.getQuerystring(i),{method:t,headers:{...this.headers,...r},body:s}).pipe(ue(n=>{if(n.ok)return n.json();throw Error(`Error ${n.status}`)}))}getQuerystring(e){if(!e)return"";let t=new URLSearchParams;return Object.entries(e).forEach(([i,s])=>{Array.isArray(s)?s.forEach(r=>t.append(i,r)):s&&t.append(i,s)}),"?"+t.toString()}get({path:e,query:t,headers:i}){return this.fetch({method:"GET",path:e,query:t,headers:i})}post({path:e,query:t,body:i,headers:s}){return this.fetch({method:"POST",path:e,query:t,body:i?JSON.stringify(i):void 0,headers:s})}put({path:e,query:t,body:i,headers:s}){return this.fetch({method:"PUT",path:e,query:t,body:i?JSON.stringify(i):void 0,headers:s})}delete({path:e,query:t,body:i,headers:s}){return this.fetch({method:"DELETE",path:e,query:t,body:i?JSON.stringify(i):void 0,headers:s})}};var K=class extends F{loadProduct({productHandle:e}){return this.get({path:`/products/${e}.js`})}addToCart(e){return this.post({path:"/cart/add.js",body:e})}};var Rt="4.14.5";var J=yt(Ft());import{from as bt,lastValueFrom as vt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var Q=class extends F{constructor(t){var i,s,r;super(t);this.headers={"content-type":"application/json","x-appmate-shp":t.shop,"x-appmate-tkv":Rt,"x-appmate-sid":t.sessionId,"x-appmate-cid":(s=(i=t.customerId)==null?void 0:i.toString())!=null?s:"","x-appmate-src":(r=t.trackingSource)!=null?r:""},this.wishlistLoader=this.createWishlistLoader(),this.productInfoLoader=this.createProductInfoLoader(),this.wishlistItemLoader=this.createWishlistItemLoader()}createWishlistLoader(){return new J.default(async t=>{let i=t.map(r=>r.split("-")).reduce((r,[n,o])=>(r[n]||(r[n]=[]),r[n].push(o),r),{}),s=await Promise.all(Object.entries(i).map(([r,n])=>vt(this.get({path:`/wishlists/${r}`,query:{format:n.includes("all")?"all":"minimal"}})))).then(r=>r.map(n=>n.wishlist));return t.map((r,n)=>{var l;let[o]=r.split("-");return(l=s.find(h=>o==="mine"?h.isMine:h.publicId===o))!=null?l:new Error("Wishlist not found")})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}createProductInfoLoader(){return new J.default(async t=>{let{productInfo:i}=await vt(this.get({path:"/wishlists/mine/product-info",headers:{"X-Appmate-IDS":t.join(",")}}));return t.map(s=>{var r;return(r=i.find(n=>n.productId===s))!=null?r:{productId:s,wishlistItems:[]}})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}createWishlistItemLoader(){return new J.default(async t=>{let i=t.map(r=>r.split("-")).reduce((r,[n,o])=>(r[n]||(r[n]=[]),r[n].push(o),r),{}),s=await Promise.all(Object.entries(i).map(([r,n])=>vt(this.get({path:`/wishlists/${r}/items`,headers:{"X-Appmate-IDS":n.join(",")}})))).then(r=>r.flatMap(n=>n.items));return t.map(r=>{var o;let[,n]=r.split("-");return(o=s.find(l=>l.id===n))!=null?o:new Error("Wishlist item not found")})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}loadWishlist({wishlistId:t,format:i}){return bt(this.wishlistLoader.load([t,i].join("-")).then(s=>({wishlist:s})))}loadProductInfo({productId:t}){return bt(this.productInfoLoader.load(t).then(i=>({productInfo:i})))}loadWishlistItem({wishlistId:t,wishlistItemId:i}){return bt(this.wishlistItemLoader.load([t,i].join("-")).then(s=>({wishlistItem:s})))}addItem({productId:t,variantId:i}){return typeof t=="string"&&(t=parseInt(t)),typeof i=="string"&&(i=parseInt(i)),this.post({path:"/wishlists/mine/items",body:{productId:t,variantId:i}})}updateItem({wishlistItemId:t,changes:i}){return this.put({path:"/wishlists/mine/items",body:{changes:{...i,wishlistItemId:t}}})}removeItem({wishlistId:t,wishlistItemId:i}){return this.delete({path:`/wishlists/${t}/items`,body:{wishlistItemId:i}})}clearWishlist(){return this.delete({path:"/wishlists/mine"})}};import{forkJoin as _e,lastValueFrom as xe,of as Ee}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{catchError as Pe,map as We,of as Lt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{fromFetch as Se}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/fetch/+esm";var G=class{constructor({host:e,shop:t,sessionId:i,customerId:s}){this.host=e,this.shop=t,this.customerId=s,this.sessionId=i,this.eventNames=new Map([["viewWishlist","wishlist_viewed"],["addToCart","product_added_to_cart"],["shareWishlist","wishlist_shared"]])}track({eventName:e,wishlist:t,product:i,variant:s,quantity:r,source:n}){var l,h;let o=this.eventNames.get(e);return!o||!t?Lt(!1):Se(this.host+"/notify",{method:"POST",headers:{"content-type":"application/json","x-appmate-shp":this.shop,"x-appmate-sid":this.sessionId,"x-appmate-cid":(h=(l=this.customerId)==null?void 0:l.toString())!=null?h:""},body:JSON.stringify({event:o,wid:t.publicId,pid:i==null?void 0:i.id,vid:s==null?void 0:s.id,qty:r,src:n})}).pipe(We(()=>!0),Pe(()=>Lt(!1)))}getQuerystring(e){if(!e)return"";let t=new URLSearchParams;return Object.entries(e).forEach(([i,s])=>{Array.isArray(s)?s.forEach(r=>t.append(i,r)):s&&t.append(i,s)}),"?"+t.toString()}};import{of as Dt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var{ga:j}=window,z=class{constructor(){this.eventNames=new Map([["addToWishlist","WK Added Product"],["removeFromWishlist","WK Removed Product"],["addToCart","WK Added to Cart"],["shareWishlist","WK Shared Wishlist"],["clearWishlist","WK Cleared Wishlist"]])}track({eventName:e,product:t,variant:i,quantity:s=1}){var n;let r=this.eventNames.get(e);return!r||!(j!=null&&j.loaded)||!t?Dt(!1):(j("ec:addProduct",{id:(n=(i==null?void 0:i.sku)||(i==null?void 0:i.id))!=null?n:t.id,name:t.title,category:t.type,brand:t.vendor,variant:i==null?void 0:i.title,quantity:s}),j("send",{eventAction:r,hitType:"event",eventCategory:"Wishlist",eventLabel:"Wishlist King"}),Dt(!0))}};import{of as Nt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var X=class{constructor({urlUtil:e,moneyUtil:t}){this.urlUtil=e,this.moneyUtil=t,this.eventNames=new Map([["addToWishlist","Added To Wishlist"],["removeFromWishlist","Removed From Wishlist"],["clearWishlist","Cleared Wishlist"]])}track({eventName:e,wishlist:t,product:i,variant:s,quantity:r=1}){let n=this.eventNames.get(e);return!n||!t||!i?Nt(!1):(window._learnq||(window._learnq=[]),window._learnq.push(["track",n,{URL:this.urlUtil.getVariantUrl(i.url,s==null?void 0:s.id),Name:i.title,ProductID:i.id,VariantID:s==null?void 0:s.id,SKU:s==null?void 0:s.sku,Tags:i.tags,Brand:i.vendor,ImageURL:this.urlUtil.getImageUrl(i,{width:1e3}),Price:s==null?void 0:s.price,PriceFormatted:s?this.moneyUtil.formatMoney(s.price):null,CompareAtPrice:s==null?void 0:s.compare_at_price,CompareAtPriceFormatted:s!=null&&s.compare_at_price?this.moneyUtil.formatMoney(s.compare_at_price):null,Quantity:r,WishlistUrl:this.urlUtil.getPublicWishlistUrl(t.id)}]),Nt(!0))}};import{of as qt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var{fbq:Vt}=window,Y=class{constructor({currency:e}){this.currency=e,this.eventNames=new Map([["addToWishlist","AddToWishlist"]])}track({eventName:e,product:t,variant:i}){let s=this.eventNames.get(e);return!s||typeof Vt!="function"||!t?qt(!1):(Vt("track",s,{value:i==null?void 0:i.price,currency:this.currency,content_ids:[t.id],content_name:[t.title,i==null?void 0:i.title].filter(r=>!!r).join(" - "),content_category:t.type,content_type:"product_group",num_items:1}),qt(!0))}};var Z=class{constructor({settings:e,events:t,notifyHost:i,utils:s,shop:r,sessionId:n,customerId:o}){this.utils=s,this.services=[],e.appmateAnalytics&&this.services.push(new G({host:i,shop:r,customerId:o,sessionId:n})),e.klaviyo&&this.services.push(new X({urlUtil:this.utils.url,moneyUtil:this.utils.money})),e.facebookPixel&&this.services.push(new Y({currency:window.Shopify.currency.active})),e.googleAnalytics&&this.services.push(new z);let l=this.utils.route.parse(window.location.pathname).pageType,h=c=>d=>{var I,v,y,m;return xe(this.track({eventName:c,source:l,wishlist:(I=d.data)==null?void 0:I.wishlist,product:(v=d.data)==null?void 0:v.product,variant:(y=d.data)==null?void 0:y.variant,quantity:(m=d.data)==null?void 0:m.quantity}))};t.subscribeMany({"wk:wishlist:add-to-cart:success":h("addToCart"),"wk:wishlist:add:success":h("addToWishlist"),"wk:wishlist:change-variant:success":h("changeVariant"),"wk:wishlist:clear:success":h("clearWishlist"),"wk:wishlist:remove:success":h("removeFromWishlist"),"wk:wishlist:share:success":h("shareWishlist"),"wk:wishlist:page-view":h("viewWishlist")})}track(e){return this.services.length?_e(this.services.map(t=>t.track(e))):Ee([])}};import{defer as Qt,forkJoin as xt,from as Gt,of as x,throwError as Ve}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{switchMap as w,map as W,catchError as R,mergeWith as it,startWith as zt,distinctUntilChanged as B,shareReplay as st,tap as Xt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";var Jt=yt(St());import{catchError as Re,defer as _,forkJoin as H,from as P,map as M,Observable as Oe,of as ke,switchMap as D}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{Dexie as Me,liveQuery as Fe}from"https://cdn.jsdelivr.net/npm/dexie@3.2.2/+esm";var jt=yt(St());import{filter as Ue,pipe as Ae}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var Ce=new jt.default({length:10}),_t=()=>{if(localStorage.getItem("wk_session_id"))return localStorage.getItem("wk_session_id");let a=localStorage.getItem("appmate-session");if(a)try{let t=JSON.parse(a).state.sid;return localStorage.setItem("wk_session_id",t),t}catch(t){console.error(t)}let e=Ce();return localStorage.setItem("wk_session_id",e),e};function $t(a,e){return{id:a.isMine?"mine":a.id,publicId:a.publicId,isMine:a.isMine,numItems:a.numItems,items:e==="all"?a.items:void 0}}function tt({productInfo:a,variantId:e,wishlistMode:t="product"}){let i=e&&t==="variant"?a.wishlistItems.find(s=>s.variantId===e):a.wishlistItems[0];return{productId:a.productId,variantId:e,inWishlist:!!i,wishlistItemId:i==null?void 0:i.id}}function L({productInfo:a}){let e=a.wishlistItems.map(t=>t.id);return{...a,wishlistItemIds:e.length?e:void 0}}function Ht(a,e){return{...a,product:{...e,hidden:!1}}}function Bt(a,e){return a.variants.find(t=>t.id===e)}function Te(a,e){return a.id===e.wishlistItemId}function Kt(a,e){return a==null?void 0:a.filter(t=>!Te(t,e))}function $(){return Ae(Ue(a=>a!=null))}var Le=new Jt.default({length:10}),et=class extends Me{constructor(){super("WishlistKing");this.version(1).stores({shopifyProducts:"handle",wishlists:"id",wishlistItems:"id",productInfo:"productId,*wishlistItemIds"})}storeShopifyProduct({product:t}){return P(_(()=>this.shopifyProducts.put(t)).pipe(M(()=>t)))}storeWishlist({wishlist:t}){return this.getWishlist({wishlistId:t.id}).pipe(Re(()=>ke(null)),D(i=>{var s;return P(this.wishlists.put({...t,items:(s=t.items)!=null?s:i==null?void 0:i.items}))}),M(()=>t))}storeProductInfo({productInfo:t}){return P(_(()=>this.productInfo.put(L({productInfo:t}))))}storeWishlistItem({wishlistItem:t}){return P(_(()=>this.wishlistItems.put(t)))}getProductInfo({productId:t}){return P(_(()=>this.productInfo.get(t)))}getProductInfoByItemId({wishlistItemId:t}){return P(_(()=>this.productInfo.where("wishlistItemIds").equals(t).first()))}getProductInfos(){return P(_(()=>this.productInfo.toArray()))}getWishlist({wishlistId:t}){return P(_(()=>this.wishlists.get(t)))}getWishlistItems(){return P(_(()=>this.wishlistItems.toArray()))}getShopifyProduct({productHandle:t}){return P(_(()=>this.shopifyProducts.get(t)))}getWishlistItem({wishlistItemId:t}){return P(_(()=>this.wishlistItems.get(t)))}addItemToWishlist({productId:t,variantId:i}){return H([this.getWishlist({wishlistId:"mine"}),this.getProductInfo({productId:t})]).pipe(D(([s,r])=>{let n={id:`temp-${Le()}`},o=De({wishlistId:"mine",item:n},s),l=()=>this.wishlists.put(o),h=()=>s?this.wishlists.put(s):this.wishlists.delete("mine"),c=()=>this.productInfo.put(L({productInfo:{productId:t,wishlistItems:r?[...r.wishlistItems,{id:n.id,variantId:i}]:[{id:n.id,variantId:i}]}})),d=()=>r?this.productInfo.put(r):this.productInfo.delete(t);return P(_(()=>this.transaction("rw",this.wishlists,this.productInfo,()=>Promise.all([l(),c()])))).pipe(M(()=>({wishlist:o,item:n,revertStateUpdate:()=>P(this.transaction("rw",this.wishlists,this.productInfo,()=>Promise.all([h(),d()])))})))}))}removeItemFromWishlist({wishlistItemId:t}){return H([this.getWishlist({wishlistId:"mine"}),this.getProductInfoByItemId({wishlistItemId:t}),this.getWishlistItem({wishlistItemId:t})]).pipe(D(([i,s,r])=>{let n=Ne({wishlistItemId:t},i),o=()=>this.wishlists.put(n),l=()=>i?this.wishlists.put(i):this.wishlists.delete("mine"),h=()=>{if(s)return this.productInfo.put(L({productInfo:{productId:s.productId,wishlistItems:s.wishlistItems.filter(v=>v.id!==t)}}))},c=()=>{if(s)return this.productInfo.put(s)},d=()=>{if(r)return this.wishlistItems.delete(r.id)},I=()=>{if(r)return this.wishlistItems.put(r)};return P(_(()=>this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([o(),h(),d()])))).pipe(M(()=>({wishlist:n,revertStateUpdate:()=>P(this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([l(),c(),I()])))})))}))}clearWishlist(){return H([this.getWishlist({wishlistId:"mine"}),this.getProductInfos(),this.getWishlistItems()]).pipe(D(([t,i,s])=>{let r=qe(t),n=()=>{if(r)return this.wishlists.put(r)},o=()=>{var I;return t?this.wishlists.put(t):this.wishlists.delete((I=r==null?void 0:r.id)!=null?I:"mine")},l=()=>this.productInfo.clear(),h=()=>{if(i)return this.productInfo.bulkPut(i)},c=()=>this.wishlistItems.clear(),d=()=>{if(s)return this.wishlistItems.bulkPut(s)};return P(_(()=>this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([n(),l(),c()])))).pipe(M(()=>({wishlist:r,revertStateUpdate:()=>P(this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([o(),h(),d()])))})))}))}updateWishlistItem({wishlistItemId:t,changes:i}){return H([this.getWishlistItem({wishlistItemId:t}),this.getProductInfoByItemId({wishlistItemId:t})]).pipe(D(([s,r])=>{let n=()=>{if(s)return this.wishlistItems.put({...s,selectedVariantId:i.variantId})},o=()=>{if(s)return this.wishlistItems.put(s)},l=()=>{if(r)return this.productInfo.put(L({productInfo:{...r,wishlistItems:r.wishlistItems.map(c=>c.id===t?{...c,variantId:i.variantId}:c)}}))},h=()=>{if(r)return this.productInfo.put(r)};return P(_(()=>this.transaction("rw",this.wishlistItems,this.productInfo,()=>Promise.all([n(),l()])))).pipe(M(()=>({revertStateUpdate:()=>P(this.transaction("rw",this.wishlistItems,this.productInfo,()=>Promise.all([o(),h()])))})))}))}changeWishlistItemRef({wishlistItemId:t,changes:i}){return H([this.getWishlist({wishlistId:"mine"}),this.getProductInfoByItemId({wishlistItemId:t})]).pipe(D(([s,r])=>{let n={id:i.id},o=()=>{var h;if(s)return this.wishlists.put({...s,items:(h=s.items)==null?void 0:h.map(c=>c.id===t?n:c)})},l=()=>{if(r)return this.productInfo.put(L({productInfo:{...r,wishlistItems:r.wishlistItems.map(h=>h.id===t?{...h,id:i.id}:h)}}))};return P(Promise.all([o(),l()])).pipe(M(()=>({item:n})))}))}liveQuery(t){return new Oe(i=>{Fe(t).subscribe({error:i.error.bind(i),next:i.next.bind(i),complete:i.complete.bind(i)})})}},De=(a,e)=>e?{...e,numItems:e.numItems+1,items:e.items?[...e.items,a.item]:[a.item]}:{id:a.wishlistId,publicId:void 0,isMine:!0,numItems:1,items:[a.item]},Ne=(a,e)=>e?{...e,numItems:e.numItems-1,items:e.items?Kt(e.items,a):[]}:{id:"mine",publicId:void 0,isMine:!0,numItems:0},qe=a=>{if(!!a)return{...a,numItems:0,items:[]}};var rt=class{constructor({wishlistApi:e,shopifyApi:t,settings:i,events:s,utils:r}){this.cacheDb=new et;this.cacheDb.open(),this.wishlistApi=e,this.shopifyApi=t,this.settings=i,this.loadWishlistCache=new Map,this.loadWishlistItemCache=new Map,this.loadProductInfoCache=new Map,this.loadShopifyProductCache=new Map,this.events=s,this.utils=r}loadWishlist({wishlistId:e,format:t,strategy:i="network-only"}){let s=[e,t].join("-");if(!this.loadWishlistCache.has(s)){let n=this.wishlistApi.loadWishlist({wishlistId:e,format:t}),o=l=>this.cacheDb.storeWishlist({wishlist:l}).pipe(W(()=>$t(l,t)));this.loadWishlistCache.set(s,n.pipe(w(({wishlist:l})=>o(l)),st()))}let r=this.loadWishlistCache.get(s);return i==="cache-first"?this.cacheDb.getWishlist({wishlistId:e}).pipe(w(n=>n?x(n):r)):r}observeWishlist({wishlistId:e,format:t}){let i={id:e,isMine:e==="mine",numItems:0,items:void 0};try{e==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load")}catch(n){return x(i)}let s=this.loadWishlist({wishlistId:e,format:t}),r=this.cacheDb.liveQuery(()=>this.cacheDb.wishlists.get(e));return s.pipe(it(r),zt(t==="minimal"?i:null),$(),B((n,o)=>JSON.stringify(n)===JSON.stringify(o)))}loadProductInfo({productId:e,variantId:t=0,strategy:i}){if(this.throwIfLoginRequired("wishlist:private:load"),!this.loadProductInfoCache.has(e)){let r=this.wishlistApi.loadProductInfo({productId:e}),n=o=>this.cacheDb.storeProductInfo({productInfo:o});this.loadProductInfoCache.set(e,r.pipe(w(({productInfo:o})=>n(o).pipe(W(()=>tt({productInfo:o,variantId:t,wishlistMode:this.settings.wishlistMode})))),st()))}let s=this.loadProductInfoCache.get(e);return i==="cache-first"?this.cacheDb.getProductInfo({productId:e}).pipe(w(r=>r?x(tt({productInfo:r,variantId:t,wishlistMode:this.settings.wishlistMode})):s)):s}observeProductInfo({productHandle:e,productId:t,variantId:i,strategy:s}){let r={productId:t!=null?t:0,variantId:i,inWishlist:!1};try{this.throwIfLoginRequired("wishlist:private:load")}catch(h){return x(r)}let n=t?x(t):this.loadShopifyProduct({productHandle:e,strategy:"cache-first"}).pipe(W(h=>h.id)),o=n.pipe(w(h=>this.loadProductInfo({productId:h,strategy:s}))),l=n.pipe(w(h=>this.cacheDb.liveQuery(()=>this.cacheDb.productInfo.get(h)).pipe(W(c=>c?tt({productInfo:c,variantId:i,wishlistMode:this.settings.wishlistMode}):r))));return s==="cache-first"?l.pipe(w(h=>h?x(h):o),B((h,c)=>JSON.stringify(h)===JSON.stringify(c)),R(h=>(console.error(h),x(r)))):o.pipe(it(l),$(),B((h,c)=>JSON.stringify(h)===JSON.stringify(c)),R(h=>(console.error(h),x(r))))}loadWishlistItem({wishlistId:e,wishlistItemId:t,strategy:i}){let s=t;if(!this.loadWishlistItemCache.has(s)){let n=this.wishlistApi.loadWishlistItem({wishlistId:e,wishlistItemId:t}),o=l=>this.cacheDb.storeWishlistItem({wishlistItem:l}).pipe(W(()=>l));this.loadWishlistItemCache.set(s,n.pipe(w(({wishlistItem:l})=>o(l)),st()))}let r=this.loadWishlistItemCache.get(s);return i==="cache-first"?this.cacheDb.getWishlistItem({wishlistItemId:t}).pipe(w(n=>n?x(n):r)):r}observeWishlistItem({wishlistId:e,wishlistItemId:t}){let i={id:t,product:{id:0,handle:"",hidden:!1}};try{e==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load")}catch(o){return x(i)}let s=this.loadWishlistItem({wishlistId:e,wishlistItemId:t}),r=this.cacheDb.liveQuery(()=>this.cacheDb.wishlistItems.get(t)).pipe(W(o=>o?o:null)),n=o=>!o.product.handle||o.product.hidden?x(o):this.observeShopifyProduct({productHandle:o.product.handle}).pipe(W(l=>Ht(o,l)));return s.pipe(zt(i),it(r),$(),w(o=>n(o)),B((o,l)=>JSON.stringify(o)===JSON.stringify(l)))}loadShopifyProduct({productHandle:e,strategy:t}){let i=e;if(!this.loadShopifyProductCache.has(i)){let r=this.shopifyApi.loadProduct({productHandle:e}),n=o=>this.cacheDb.storeShopifyProduct({product:o}).pipe(W(()=>o));this.loadShopifyProductCache.set(i,r.pipe(w(o=>n(o)),st()))}let s=this.loadShopifyProductCache.get(i);return t==="cache-first"?this.cacheDb.getShopifyProduct({productHandle:e}).pipe(w(r=>r?x(r):s)):s}observeShopifyProduct({productHandle:e}){let t=this.loadShopifyProduct({productHandle:e}),i=this.cacheDb.liveQuery(()=>this.cacheDb.shopifyProducts.get(e));return t.pipe(it(i),$(),B((s,r)=>JSON.stringify(s)===JSON.stringify(r)))}loadWishlistProduct({wishlistId:e,wishlistItemId:t}){return e==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load"),this.loadWishlistItem({wishlistId:e,wishlistItemId:t}).pipe(w(i=>this.loadShopifyProduct({productHandle:i.product.handle})))}addWishlistItem(e){this.throwIfLoginRequired("wishlist:private:add");let t=typeof e.productId=="string"?parseInt(e.productId):e.productId,i=typeof e.variantId=="string"?parseInt(e.variantId):e.variantId,s=this.cacheDb.addItemToWishlist({productId:t,variantId:i}),r=this.wishlistApi.addItem({productId:t,variantId:i});return s.pipe(w(({item:n,revertStateUpdate:o})=>r.pipe(w(({wishlistItem:l})=>xt([this.cacheDb.storeWishlistItem({wishlistItem:l}),this.cacheDb.changeWishlistItemRef({wishlistItemId:n.id,changes:{id:l.id}})]).pipe(W(()=>({wishlistItem:l})))),w(l=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:add:success",productHandle:l.wishlistItem.product.handle,variantId:l.wishlistItem.selectedVariantId}).pipe(W(()=>l))),R(l=>(console.error(l),this.events.publish({name:"wk:wishlist:add:error",error:l}),o())))))}updateWishlistItem(e){this.throwIfLoginRequired("wishlist:private:change-variant");let t={variantId:typeof e.changes.variantId=="string"?parseInt(e.changes.variantId):e.changes.variantId},i=this.cacheDb.updateWishlistItem({wishlistItemId:e.wishlistItemId,changes:t}),s=this.wishlistApi.updateItem({wishlistItemId:e.wishlistItemId,changes:t});return i.pipe(w(({revertStateUpdate:r})=>s.pipe(w(n=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:change-variant:success",productHandle:n.wishlistItem.product.handle,variantId:n.wishlistItem.selectedVariantId}).pipe(W(()=>n))),R(n=>(console.error(n),this.events.publish({name:"wk:wishlist:change-variant:error",error:n}),r())))))}removeWishlistItem({wishlistItemId:e}){this.throwIfLoginRequired("wishlist:private:remove");let t=this.cacheDb.removeItemFromWishlist({wishlistItemId:e}),i=this.wishlistApi.removeItem({wishlistId:"mine",wishlistItemId:e});return t.pipe(w(({wishlist:s,revertStateUpdate:r})=>i.pipe(W(({wishlistItem:n})=>({wishlist:s,wishlistItem:n})),w(n=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:remove:success",productHandle:n.wishlistItem.product.handle,variantId:n.wishlistItem.selectedVariantId}).pipe(W(()=>n))),R(n=>(console.error(n),this.events.publish({name:"wk:wishlist:remove:error",error:n}),r())))))}clearWishlist(){this.throwIfLoginRequired("wishlist:private:clear");let e=this.cacheDb.clearWishlist(),t=this.wishlistApi.clearWishlist();return e.pipe(w(({revertStateUpdate:i})=>t.pipe(w(()=>this.publishWishlistEvent({wishlistId:"mine",eventName:"wk:wishlist:clear:success"})),R(s=>(console.error(s),this.events.publish({name:"wk:wishlist:clear:error",error:s}),i())))))}addToCart({wishlistId:e,wishlistItemId:t,variantId:i,quantity:s=1,sectionsToRender:r,sectionsUrl:n}){return e==="mine"?this.throwIfLoginRequired("wishlist:private:add-to-cart"):this.throwIfLoginRequired("wishlist:public:add-to-cart"),this.shopifyApi.addToCart({id:i,quantity:s,sections:r,sections_url:n}).pipe(w(o=>xt([this.loadWishlist({wishlistId:e,format:"minimal"}),this.loadWishlistItem({wishlistId:e,wishlistItemId:t})]).pipe(W(([l,h])=>({wishlistItem:h,cartResponse:o,wishlist:l})))),w(o=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:add-to-cart:success",productHandle:o.wishlistItem.product.handle,variantId:o.wishlistItem.selectedVariantId}).pipe(W(()=>o))),R(o=>(this.events.publish({name:"wk:wishlist:add-to-cart:error",error:o}),Ve(()=>o))),w(o=>this.settings.moveToCart&&o.wishlist.isMine?this.removeWishlistItem({wishlistItemId:t}).pipe(W(()=>o)):x(o)))}shareWishlist({wishlistId:e,title:t,text:i}){e==="mine"?this.throwIfLoginRequired("wishlist:private:share"):this.throwIfLoginRequired("wishlist:public:share");let s={url:this.utils.url.getPublicWishlistUrl(e),title:t,text:i},r=Gt(Qt(async()=>{try{await navigator.share(s)}catch(o){throw new Error("Web share api not available")}}).pipe(w(()=>this.publishWishlistEvent({wishlistId:e,eventName:"wk:wishlist:share:success"})),W(()=>({webShare:!0,clipboard:!1})))),n=Gt(Qt(async()=>{try{await navigator.clipboard.writeText(s.url)}catch(o){throw new Error("Web clipboard api not available")}}).pipe(w(()=>this.publishWishlistEvent({wishlistId:e,eventName:"wk:wishlist:share:success"})),W(()=>({webShare:!1,clipboard:!0}))));return r.pipe(R(()=>n.pipe(R(o=>(this.events.publish({name:"wk:wishlist:share:error",error:o}),x({webShare:!1,clipboard:!1}))))))}publishWishlistItemEvent({eventName:e,wishlistId:t,productHandle:i,variantId:s}){return xt([this.loadWishlist({wishlistId:t,format:"minimal",strategy:"cache-first"}),this.loadShopifyProduct({productHandle:i,strategy:"cache-first"})]).pipe(Xt(([r,n])=>this.events.publish({name:e,data:{wishlist:r,product:n,variant:Bt(n,s),quantity:1}})))}publishWishlistEvent({eventName:e,wishlistId:t}){return this.loadWishlist({wishlistId:t,format:"minimal",strategy:"cache-first"}).pipe(Xt(i=>this.events.publish({name:e,data:{wishlist:i}})))}throwIfLoginRequired(e){var i;if(!this.settings.loginRequired)return;if(!this.settings.loginActions&&e.includes("private")||((i=this.settings.loginActions)==null?void 0:i.includes(e)))throw this.events.publish({name:"wk:wishlist:login-required",data:{action:e}}),new Error("Wishlist requires login")}};function je(a){for(var e=[],t=0;t<a.length;){var i=a[t];if(i==="*"||i==="+"||i==="?"){e.push({type:"MODIFIER",index:t,value:a[t++]});continue}if(i==="\\"){e.push({type:"ESCAPED_CHAR",index:t++,value:a[t++]});continue}if(i==="{"){e.push({type:"OPEN",index:t,value:a[t++]});continue}if(i==="}"){e.push({type:"CLOSE",index:t,value:a[t++]});continue}if(i===":"){for(var s="",r=t+1;r<a.length;){var n=a.charCodeAt(r);if(n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122||n===95){s+=a[r++];continue}break}if(!s)throw new TypeError("Missing parameter name at ".concat(t));e.push({type:"NAME",index:t,value:s}),t=r;continue}if(i==="("){var o=1,l="",r=t+1;if(a[r]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(r));for(;r<a.length;){if(a[r]==="\\"){l+=a[r++]+a[r++];continue}if(a[r]===")"){if(o--,o===0){r++;break}}else if(a[r]==="("&&(o++,a[r+1]!=="?"))throw new TypeError("Capturing groups are not allowed at ".concat(r));l+=a[r++]}if(o)throw new TypeError("Unbalanced pattern at ".concat(t));if(!l)throw new TypeError("Missing pattern at ".concat(t));e.push({type:"PATTERN",index:t,value:l}),t=r;continue}e.push({type:"CHAR",index:t,value:a[t++]})}return e.push({type:"END",index:t,value:""}),e}function $e(a,e){e===void 0&&(e={});for(var t=je(a),i=e.prefixes,s=i===void 0?"./":i,r="[^".concat(N(e.delimiter||"/#?"),"]+?"),n=[],o=0,l=0,h="",c=function(g){if(l<t.length&&t[l].type===g)return t[l++].value},d=function(g){var E=c(g);if(E!==void 0)return E;var A=t[l],q=A.type,V=A.index;throw new TypeError("Unexpected ".concat(q," at ").concat(V,", expected ").concat(g))},I=function(){for(var g="",E;E=c("CHAR")||c("ESCAPED_CHAR");)g+=E;return g};l<t.length;){var v=c("CHAR"),y=c("NAME"),m=c("PATTERN");if(y||m){var f=v||"";s.indexOf(f)===-1&&(h+=f,f=""),h&&(n.push(h),h=""),n.push({name:y||o++,prefix:f,suffix:"",pattern:m||r,modifier:c("MODIFIER")||""});continue}var S=v||c("ESCAPED_CHAR");if(S){h+=S;continue}h&&(n.push(h),h="");var k=c("OPEN");if(k){var f=I(),u=c("NAME")||"",p=c("PATTERN")||"",b=I();d("CLOSE"),n.push({name:u||(p?o++:""),pattern:u&&!p?r:p,prefix:f,suffix:b,modifier:c("MODIFIER")||""});continue}d("END")}return n}function C(a,e){var t=[],i=Zt(a,t,e);return He(i,t,e)}function He(a,e,t){t===void 0&&(t={});var i=t.decode,s=i===void 0?function(r){return r}:i;return function(r){var n=a.exec(r);if(!n)return!1;for(var o=n[0],l=n.index,h=Object.create(null),c=function(I){if(n[I]===void 0)return"continue";var v=e[I-1];v.modifier==="*"||v.modifier==="+"?h[v.name]=n[I].split(v.prefix+v.suffix).map(function(y){return s(y,v)}):h[v.name]=s(n[I],v)},d=1;d<n.length;d++)c(d);return{path:o,index:l,params:h}}}function N(a){return a.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function Yt(a){return a&&a.sensitive?"":"i"}function Be(a,e){if(!e)return a;for(var t=/\((?:\?<(.*?)>)?(?!\?)/g,i=0,s=t.exec(a.source);s;)e.push({name:s[1]||i++,prefix:"",suffix:"",modifier:"",pattern:""}),s=t.exec(a.source);return a}function Ke(a,e,t){var i=a.map(function(s){return Zt(s,e,t).source});return new RegExp("(?:".concat(i.join("|"),")"),Yt(t))}function Je(a,e,t){return Qe($e(a,t),e,t)}function Qe(a,e,t){t===void 0&&(t={});for(var i=t.strict,s=i===void 0?!1:i,r=t.start,n=r===void 0?!0:r,o=t.end,l=o===void 0?!0:o,h=t.encode,c=h===void 0?function(V){return V}:h,d=t.delimiter,I=d===void 0?"/#?":d,v=t.endsWith,y=v===void 0?"":v,m="[".concat(N(y),"]|$"),f="[".concat(N(I),"]"),S=n?"^":"",k=0,u=a;k<u.length;k++){var p=u[k];if(typeof p=="string")S+=N(c(p));else{var b=N(c(p.prefix)),g=N(c(p.suffix));if(p.pattern)if(e&&e.push(p),b||g)if(p.modifier==="+"||p.modifier==="*"){var E=p.modifier==="*"?"?":"";S+="(?:".concat(b,"((?:").concat(p.pattern,")(?:").concat(g).concat(b,"(?:").concat(p.pattern,"))*)").concat(g,")").concat(E)}else S+="(?:".concat(b,"(").concat(p.pattern,")").concat(g,")").concat(p.modifier);else p.modifier==="+"||p.modifier==="*"?S+="((?:".concat(p.pattern,")").concat(p.modifier,")"):S+="(".concat(p.pattern,")").concat(p.modifier);else S+="(?:".concat(b).concat(g,")").concat(p.modifier)}}if(l)s||(S+="".concat(f,"?")),S+=t.endsWith?"(?=".concat(m,")"):"$";else{var A=a[a.length-1],q=typeof A=="string"?f.indexOf(A[A.length-1])>-1:A===void 0;s||(S+="(?:".concat(f,"(?=").concat(m,"))?")),q||(S+="(?=".concat(f,"|").concat(m,")"))}return new RegExp(S,Yt(t))}function Zt(a,e,t){return a instanceof RegExp?Be(a,e):Array.isArray(a)?Ke(a,e,t):Je(a,e,t)}var O={isHome:C("/:locale?"),isCollection:C("/:locale?/collections/(.*)"),isProduct:C("/:locale?/products/:product"),isNestedProduct:C("/:locale?/collections/:collection?/products/:product"),isPage:C("/:locale?/pages/:page/:rest?"),isAccount:C("/:locale?/account/:account?"),isBlog:C("/:locale?/blog/:blog?"),isCart:C("/:locale?/cart/:cart?"),isProxy:C("/:locale?/apps/(.*)")},Ge=[{pageType:"product",match:a=>O.isProduct(a)||O.isNestedProduct(a)},{pageType:"collection",match:a=>O.isCollection(a)},{pageType:"page",match:a=>O.isPage(a)},{pageType:"account",match:a=>O.isAccount(a)},{pageType:"blog",match:a=>O.isBlog(a)},{pageType:"cart",match:a=>O.isCart(a)},{pageType:"home",match:a=>O.isHome(a)},{pageType:"proxy",match:a=>O.isProxy(a)}],nt=class{constructor({wishlistUrl:e}){this.wishlistUrl=e}parse(e){for(let t of Ge){let i=t.match(e);if(i)return e.startsWith(this.wishlistUrl)?{pageType:"wishlist",handle:i.params.page}:{pageType:t.pageType,handle:i.params.page}}return{pageType:void 0}}};var at=class{constructor(e){this.locale=this.decodeLocale(e.locale)}decodeHtmlEntities(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'")}decodeLocale(e){let t={};for(let i in e){t[i]={};for(let s in e[i])t[i][s]=this.decodeHtmlEntities(e[i][s])}return t}translate(e){var s,r;let[t,i]=e.split(".");return(r=(s=this.locale[t])==null?void 0:s[i])!=null?r:`translation missing: ${e}`}};var ze="${{amount}}";function te(a,e){typeof a=="string"&&(a=a.replace(".",""));let t="",i=/\{\{\s*(\w+)\s*\}\}/,s=e||ze;function r(n,o=2,l=",",h="."){if(isNaN(n)||n==null)return 0;n=(n/100).toFixed(o);let c=n.split("."),d=c[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${l}`),I=c[1]?h+c[1]:"";return d+I}switch(s.match(i)[1]){case"amount":t=r(a,2);break;case"amount_no_decimals":t=r(a,0);break;case"amount_with_comma_separator":t=r(a,2,".",",");break;case"amount_no_decimals_with_comma_separator":t=r(a,0,".",",");break}return s.replace(i,t)}var ot=class{constructor(e){this.moneyFormat=e.moneyFormat,this.currencyRate=e.currencyRate,this.activeCurrency=e.activeCurrency}formatMoney(e){return typeof e=="string"&&(e=parseFloat(e)),te(e,this.moneyFormat)}};var lt=class{constructor(e){this.rootUrl=e.rootUrl,this.shopDomain=e.shopDomain,this.wishlistUrl=e.wishlistUrl,this.placeholderImageUrl=e.placeholderImageUrl,this.fileUrl=e.fileUrl}getWishlistIdFromUrl(e){if(!e)return;let t=e.replace(this.rootUrl,"/").split("/");return t.length===4?t.pop():"mine"}getProductHandleFromUrl(e){var t;if(!!e)return e instanceof URL&&(e=e.pathname),(t=e.split("/").pop())==null?void 0:t.split("?")[0]}getVariantIdFromUrl(e){return new URLSearchParams(e.split("?")[1]).get("variant")}getPublicWishlistUrl(e){return`https://${this.shopDomain}${this.wishlistUrl}/${e}`}getFileUrl(e=""){return`https:${this.fileUrl.split("?")[0]}${e}`}getImageUrl(e,t){var s,r;if(!e)return(s=this.placeholderImageUrl)!=null?s:"";let i=this.getImage(e);return i!=null&&i.src?this.appendSize(i.src,t):(r=this.placeholderImageUrl)!=null?r:""}getImage(e){var t,i,s,r,n,o;if(e.hasOwnProperty("sku"))return{src:(i=(t=e.featured_image)==null?void 0:t.src)!=null?i:""};if(e!=null&&e.selected_or_first_available_variant){let l=e;return(s=l.selected_or_first_available_variant)!=null&&s.featured_image?this.getImage(l.selected_or_first_available_variant):{src:(r=l.featured_image)!=null?r:l.images[0]}}else if((n=e==null?void 0:e.images)!=null&&n.length){let l=e;return{src:(o=l.featured_image)!=null?o:l.images[0]}}else if(e.hasOwnProperty("src"))return{src:e.src};return null}appendSize(e,t){let i=new URL(e.startsWith("//")?`https://${e}`:e);return t!=null&&t.width&&i.searchParams.set("width",t==null?void 0:t.width.toString()),t!=null&&t.height&&i.searchParams.set("height",t==null?void 0:t.height.toString()),i.href}getVariantUrl(e,t){if(!!e)return t?e+`?variant=${t}`:e}};var ht=class{constructor(){}getFormState({product:e,options:t,autoSelect:i=!1,change:s}){let r=this.getSelectedOptions({product:e,options:t,change:s,autoSelect:i}),n=r&&Object.values(r).every(h=>!!h),o=this.getOptionsWithValues({product:e,selectedOptions:r});return{selectedVariant:this.getVariantByOptions({product:e,options:r}),selectedOptions:r,hasSelection:n,optionsWithValues:o}}getSelectedOptions({product:e,options:t,autoSelect:i,change:s={}}){let r={...t,...s};if(!i)return r;i===!0&&(i="unavailable");let n=this.getVariantByOptions({product:e,options:r});if(i==="unavailable"&&n||i==="soldout"&&(n==null?void 0:n.available))return r;let o=Object.keys(s).pop(),l=Object.fromEntries(Object.entries(r).filter(([d])=>!o||d<=o)),h=Object.fromEntries(Object.entries(r).filter(([d])=>!(d in l)));return Object.entries(h).reduce((d,[I,v])=>{var m;let y=this.getAllVariantsByOptions({product:e,options:d});return y.length?{...d,[I]:((m=y.find(f=>f.available))!=null?m:y[0])[I]}:{...d,[I]:null}},l)}getVariantOptions({variant:e}){var t,i,s;return{option1:(t=e==null?void 0:e.option1)!=null?t:null,option2:(i=e==null?void 0:e.option2)!=null?i:null,option3:(s=e==null?void 0:e.option3)!=null?s:null}}getOptionsWithValues({product:e,selectedOptions:t={}}){return e.options.map(i=>{var l;let s=`option${i.position}`,r=this.getUnavailableOptionValues({product:e,optionKey:s,selectedOptions:t,values:i.values}),n=this.getSoldoutOptionValues({product:e,optionKey:s,selectedOptions:t,values:i.values}),o=(l=t==null?void 0:t[s])!=null?l:null;return{...i,selectedValue:o,soldoutValues:n,unavailableValues:r}})}getSoldoutOptionValues({product:e,optionKey:t,values:i,selectedOptions:s={}}){let r=Object.fromEntries(Object.entries(s).filter(([n])=>n<t));return i.filter(n=>{let o=e.variants.filter(l=>this.matchesVariant({variant:l,options:{...r,[t]:n}}));return o.length?o.every(l=>!l.available):!1})}getUnavailableOptionValues({product:e,optionKey:t,values:i,selectedOptions:s={}}){let r=Object.fromEntries(Object.entries(s).filter(([n])=>n<t));return i.filter(n=>e.variants.every(o=>!this.matchesVariant({variant:o,options:{...r,[t]:n}})))}getFirstAvailableVariant({product:e}){var t;return(t=e.variants.find(i=>i.available))!=null?t:null}getSelectedVariant({product:e,selectedVariantId:t}){var i;return(i=e.variants.find(s=>s.id===t))!=null?i:null}matchesVariant({variant:e,options:t}){return(!(t!=null&&t.option1)||t.option1===e.option1)&&(!(t!=null&&t.option2)||t.option2===e.option2)&&(!(t!=null&&t.option3)||t.option3===e.option3)}getFormData({form:e,product:t}){let i=new FormData(e);return{quantity:this.getFormQuantity({form:e}),options:this.getFormOptions({formData:i,product:t})}}getFormQuantity({form:e}){var s;let i=(s=new FormData(e).get("quantity"))==null?void 0:s.toString();return i?parseInt(i):1}getVariantByOptions({product:e,options:t}){var s;let i=Object.entries(t).reduce((r,[,n],o)=>(r[o]=n,r),new Array(3).fill(null));return(s=e.variants.find(r=>i.every((n,o)=>r[`option${o+1}`]===n)))!=null?s:null}getAllVariantsByOptions({product:e,options:t}){var s;let i=Object.entries(t).reduce((r,[,n],o)=>(r[o]=n,r),new Array(3).fill(null));return(s=e.variants.filter(r=>i.every((n,o)=>!n||r[`option${o+1}`]===n)))!=null?s:[]}getFormOptions({formData:e,product:t}){return Array.from(e.entries()).reduce((i,[s,r])=>{var l;let n=(l=s.match(/\[(.*?)\]/))==null?void 0:l[1];if(!n)return i;let o=t.options.findIndex(h=>h.name===n)+1;if(o>0){let h=`option${o}`;i[h]=r.toString()||null}return i},{})}getInputOption({input:e,product:t}){var r;let i=(r=e.name.match(/\[(.*?)\]/))==null?void 0:r[1];if(!i)return null;let s=t.options.findIndex(n=>n.name===i)+1;return s>0?{[`option${s}`]:e.value.toString()}:null}};import{fromEvent as Ye,map as Ze}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var ct=class{constructor(){this.dispatcher=document}publish(e){this.dispatcher.dispatchEvent(new CustomEvent(e.name,{detail:e,bubbles:!1,cancelable:!1}))}subscribe(e,t){return Ye(this.dispatcher,e).pipe(Ze(i=>{let s=i;return{name:s.type,data:s.detail.data}})).subscribe(t)}subscribeMany(e){return Object.entries(e).map(([t,i])=>this.subscribe(t,i))}};var pt=class{constructor({routeUtil:e}){this.subscriber=[],this.routeUtil=e,this.observer=new MutationObserver(t=>{t.reduce((i,s)=>i.concat(Array.from(s.addedNodes)),[]).filter(i=>i instanceof Element&&!i.hasAttribute("data-appmate")).forEach(i=>this.scan(i))}),this.observer.observe(document.body,{subtree:!0,childList:!0,attributes:!1})}watch(e,t){if(!e.pageType&&e.handle)throw new Error("Template required when watching for handle.");let i={target:e,callback:t};this.subscriber.push(i),ee(i,this.routeUtil.parse(window.location.pathname))&&this.scan(document.body)}shouldSkip(e,{skipHidden:t}){return t&&e instanceof HTMLElement?e.offsetParent===null:!1}scan(e){this.subscriber.filter(t=>ee(t,this.routeUtil.parse(window.location.pathname))).forEach(t=>{let i=e.matches(t.target.selector)&&!this.shouldSkip(e,{skipHidden:!!t.target.skipHidden});if(i&&this.notify(t,e),i&&t.target.firstMatch)return;let s=e.querySelectorAll(t.target.selector);for(let r of s)if(!this.shouldSkip(r,{skipHidden:!!t.target.skipHidden})&&(this.notify(t,r),t.target.firstMatch))break})}notify(e,t){if(!t.hasAttribute("data-appmate")){t.setAttribute("data-appmate","");let i=new T(t);e.callback(i)}}};function ee({target:a},e){if(!a.pageType)return!0;if(!e.pageType)return!1;if(a.handle)return a.handle===e.handle;let t=Array.isArray(a.pageType)?a.pageType:[a.pageType];return t.includes("all")?!0:t.includes(e.pageType)}var T=class{constructor(e){this.element=e}replace(e){var t;return(t=this.element)==null||t.replaceWith(e),e}append(e){var t;return(t=this.element)==null||t.append(e),e}prepend(e){var t;return(t=this.element)==null||t.prepend(e),e}insertBefore(e){var t;return(t=this.element)==null||t.before(e),e}insertAfter(e){var t;return(t=this.element)==null||t.after(e),e}closest(e,t=5){if(!this.element)return new T;if(typeof e=="object")return this.searchByStyle(e,this.element,s=>s.parentElement,t);let i=this.element.closest(e);return i?new T(i):new T}find(e){var i;let t=(i=this.element)==null?void 0:i.querySelector(e);return t?new T(t):new T}searchByStyle(e,t,i,s=5){if(s<0||!t)return null;let r=getComputedStyle(t);if(Object.entries(e).every(([l,h])=>r.getPropertyValue(l)===h))return new T(t);let o=i(t);return o?this.searchByStyle(e,o,i,s-1):null}};var ut=class{constructor({routeUtil:e}){this.observer=new pt({routeUtil:e}),this.watch=this.observer.watch.bind(this.observer)}createComponent(e,t){let i=document.createElement(e);return t!=null&&t.dataset&&Object.entries(t==null?void 0:t.dataset).forEach(([s,r])=>{!r||(typeof r=="boolean"?i.dataset[s]="":typeof r=="object"?i.dataset[s]=JSON.stringify(r):i.dataset[s]=r)}),t!=null&&t.props&&Object.entries(t==null?void 0:t.props).forEach(([s,r])=>{i[s]=r}),i}createElement(e,t={},...i){let s=Object.assign(document.createElement(e),t);return i&&s.append(...i),s}};var Et=class{constructor({settings:e,stylesheets:t,...i}){this.stylesLoaded=!1;var s,r;this.config=this.parseConfig(i),this.settings={...e,loginRequired:!!e.loginRequired&&!this.config.customer.id},this.events=new ct,this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.utils=this.initUtils(),this.apis={wishlist:new Q({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(s=this.config.customer.id)!=null?s:void 0,sessionId:_t(),trackingSource:this.utils.route.parse(window.location.pathname).pageType}),shopify:new K({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new Z({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,sessionId:_t(),utils:this.utils,settings:e})},this.state=new rt({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils}),this.addToCart=(...n)=>U(this.state.addToCart(...n)),this.addWishlistItem=(...n)=>U(this.state.addWishlistItem(...n)),this.clearWishlist=(...n)=>U(this.state.clearWishlist(...n)),this.loadProductInfo=(...n)=>U(this.state.loadProductInfo(...n)),this.loadShopifyProduct=(...n)=>U(this.state.loadShopifyProduct(...n)),this.loadWishlist=(...n)=>U(this.state.loadWishlist(...n)),this.loadWishlistItem=(...n)=>U(this.state.loadWishlistItem(...n)),this.loadWishlistProduct=(...n)=>U(this.state.loadWishlistProduct(...n)),this.publishWishlistEvent=(...n)=>U(this.state.publishWishlistEvent(...n)),this.publishWishlistItemEvent=(...n)=>U(this.state.publishWishlistItemEvent(...n)),this.removeWishlistItem=(...n)=>U(this.state.removeWishlistItem(...n)),this.shareWishlist=(...n)=>U(this.state.shareWishlist(...n)),this.updateWishlistItem=(...n)=>U(this.state.updateWishlistItem(...n)),this.initStyles(t),this.initUrlChangeEvents(),this.trackCurrentPage(),requestAnimationFrame(()=>{this.events.publish({name:"wk:app:ready"})})}async initStyles(e){if(!(e!=null&&e.length)){this.onStylesLoaded();return}try{await Promise.all(e.map(t=>new Promise((i,s)=>{let r=document.createElement("link");r.rel="stylesheet",r.href=t,r.onload=i,r.onerror=s,document.head.appendChild(r)}))),this.onStylesLoaded()}catch(t){console.warn(t),this.events.publish({name:"wk:app:load-styles:error"})}}trackCurrentPage(){let e=this.utils.route.parse(window.location.pathname).pageType;if(e!=null&&e.includes("wishlist")){let t=this.utils.url.getWishlistIdFromUrl(window.location.pathname);t&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:t})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success"})}initUtils(){let e=this.config.shop.domain,t=this.config.products.fallbackImage,i=this.config.shop.moneyFormat,s=this.config.locale,r=new nt({wishlistUrl:this.routes.wishlistUrl});return{url:new lt({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:e,placeholderImageUrl:t,fileUrl:this.routes.fileUrl}),money:new ot({moneyFormat:i,currencyRate:parseFloat(window.Shopify.currency.rate),activeCurrency:window.Shopify.currency.active}),product:new ht,locale:new at({locale:s}),route:r,dom:new ut({routeUtil:r})}}initUrlChangeEvents(){let e=history.replaceState,t=({productHandle:i,variantId:s})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:i,variantId:s}})};history.replaceState=(...i)=>{let s=`${window.location.protocol}//${window.location.host}`,r=typeof i[2]=="string"?new URL(i[2],s):i[2],n=e.apply(history,i);if(!r)return n;let o=this.utils.url.getProductHandleFromUrl(r),l=r.searchParams.get("variant");if(!o||!l)return n;t({productHandle:o,variantId:parseInt(l)})}}parseConfig({config:e,locale:t}){var i,s,r,n,o,l,h,c;return{customer:{id:e.customerId?parseInt(e.customerId):null,email:(i=e.customerEmail)!=null?i:""},shop:{name:(s=e.shopName)!=null?s:"",domain:(r=e.shopDomain)!=null?r:"",permanentDomain:(n=e.shopPermanentDomain)!=null?n:"",currency:(o=e.shopCurrency)!=null?o:"",moneyFormat:(l=e.shopMoneyFormat)!=null?l:"",customerAccountsEnabled:e.shopCustomerAccountsEnabled?e.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(h=e.apiHost)!=null?h:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:e.fileUrl},products:{fallbackImage:(c=e.productFallbackImage)!=null?c:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081"},locale:t}}parseRoutes(){var i;let e=this.config.routes.rootUrl,t=(i=this.settings.wishlistPath)!=null?i:"/apps/wishlist";return{rootUrl:e,fileUrl:this.config.routes.fileUrl,wishlistUrl:e+t.split("/").filter(s=>!!s).join("/"),accountUrl:e+"account",accountLoginUrl:e+"account/login",accountLogoutUrl:e+"account/logout",accountRegisterUrl:e+"account/register",accountAddressesUrl:e+"account/addresses",collectionsUrl:e+"collections",allProductsCollectionUrl:e+"collections/all",searchUrl:e+"search",predictiveSearchUrl:e+"search/suggest",cartUrl:e+"cart",cartAddUrl:e+"cart/add",cartChangeUrl:e+"cart/change",cartClearUrl:e+"cart/clear",cartUpdateUrl:e+"cart/update",productRecommendationsUrl:e+"recommendations/products"}}};import{from as si,fromEvent as Ut,isObservable as ie,of as se}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{filter as ri,first as re,switchMap as ni,tap as ne}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";import{LitElement as ai}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/+esm";import{state as oi}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/decorators.js/+esm";import{combineLatest as ti,distinctUntilChanged as ei,map as dt,of as ii}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var mt=class{constructor(e){this.stateConfig={loading:"eager"};(this.host=e).addController(this)}get app(){if(!window.WishlistKing)throw new Error("Wishlist King SDK not initialized");return window.WishlistKing}hostConnected(){}hostDisconnected(){}parseStateConfig(e){var t;return{loading:(t=e.loading)!=null?t:"eager",wishlist:this.parseWishlistStateConfig(e),wishlistItem:this.parseWishlistItemStateConfig(e),productInfo:this.parseProductInfoStateConfig(e)}}parseWishlistStateConfig({wishlist:e}){var i;let t=(i=this.host.dataset.wishlistId)!=null?i:"mine";if(!!e)return{format:typeof e=="string"?e:"minimal",params:{wishlistId:t}}}parseWishlistItemStateConfig({wishlistItem:e}){let{wishlistId:t="mine",wishlistItemId:i}=this.host.dataset;if(!(!e||!i))return{params:{wishlistId:t,wishlistItemId:i}}}parseProductInfoStateConfig({productInfo:e}){let{wishlistId:t="mine",productHandle:i,productId:s,variantId:r}=this.host.dataset;if(!!e)return{params:{wishlistId:t,productHandle:i,productId:s?parseInt(s):void 0,variantId:r?parseInt(r):void 0}}}observe(e){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let t=[];if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;t.push(this.app.state.observeWishlist({format:this.stateConfig.wishlist.format,wishlistId:i}).pipe(dt(s=>({wishlist:s}))))}if(this.stateConfig.productInfo){let{productId:i,productHandle:s,variantId:r}=this.stateConfig.productInfo.params;if(!i&&!s)throw new Error("Product id or handle is required");t.push(this.app.state.observeProductInfo({productHandle:s,productId:i,variantId:r,strategy:e}).pipe(dt(n=>({productInfo:n}))))}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:s}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!s)throw new Error("Wishlist item id is required");t.push(this.app.state.observeWishlistItem({wishlistId:i,wishlistItemId:s}).pipe(dt(r=>({wishlistItem:r}))))}return t.length||t.push(ii({})),ti(t).pipe(dt(i=>i.reduce((s,r)=>r.wishlist?{...s,wishlist:r.wishlist}:r.wishlistItem?{...s,wishlistItem:r.wishlistItem}:r.productInfo?{...s,productInfo:r.productInfo}:s,{})),ei((i,s)=>JSON.stringify(i)===JSON.stringify(s)))}getFallback(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e={};if(this.stateConfig.wishlist){let{wishlistId:t="mine"}=this.stateConfig.wishlist.params;e.wishlist={id:t,isMine:t==="mine",numItems:0,items:void 0}}if(this.stateConfig.productInfo){let{productId:t=0,variantId:i=0}=this.stateConfig.productInfo.params;e.productInfo={productId:t,variantId:i,inWishlist:!1}}if(this.stateConfig.wishlistItem){let{wishlistId:t,wishlistItemId:i}=this.stateConfig.wishlistItem.params;if(!t)throw new Error("Wishlist id is required");if(!i)throw new Error("Wishlist item id is required");e.wishlistItem={id:i,product:{id:0,handle:"",hidden:!1}}}return e}};var ft=class extends ai{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.state={};this.stateCtrl=new mt(this)}get app(){return this.stateCtrl.app}static get observedAttributes(){return[...super.observedAttributes,"data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}appReadyCallback(){}beforeNextState(t){}connect(){if(!this.connected){if(!window.WishlistKing){Ut(document,"wk:app:ready").pipe(re()).subscribe(()=>this.connect());return}if(!this.app.stylesLoaded){Ut(document,"wk:app:load-styles:success").pipe(re()).subscribe(()=>this.connect());return}this.connected=!0,this.init(),this.appReadyCallback()}}getStateConfig(){return{}}getTranslation(t){var i;return(i=window.WishlistKing)!=null&&i.utils.locale?window.WishlistKing.utils.locale.translate(t):t}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):this.initState()}updateState(t){var i;this.state={...(i=this.state)!=null?i:{},...t}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML="",this.initEvents(),this.connect()}disconnectedCallback(){var t,i;super.disconnectedCallback(),this.connected=!1,this.cleanupMethods.forEach(s=>s()),(t=this.subscription)==null||t.unsubscribe(),(i=this.observer)==null||i.disconnect()}attributeChangedCallback(t,i,s){super.attributeChangedCallback(t,i,s),this.connected&&this.initState("cache-first")}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(t){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe(t).subscribe(i=>{this.updateState(i)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.updateState(t)}initObserver(){this.observer=new IntersectionObserver(t=>this.handleIntersect(t),{root:null,rootMargin:"0px"}),this.observer.observe(this)}handleIntersect([t]){var i;t.isIntersecting&&((i=this.observer)==null||i.disconnect(),this.initState())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let i=Object.entries(t).map(([s,r])=>{let[n,o]=s.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:o,handler:r})});this.cleanupMethods.push(()=>i.forEach(s=>s.unsubscribe()))}subscribeToEvent({eventName:t,handler:i,selector:s}){return Ut(this,t).pipe(ne(r=>{this.eventPending&&r.preventDefault()}),ri(()=>!this.eventPending),ne(()=>{this.eventPending=!0}),ni(r=>{let n=null;if(s&&r.target instanceof HTMLElement&&(n=r.target.closest(s)),s&&!n)return se(null);let o=i.bind(this)(r,s?n:r.currentTarget);return ie(o)?o:typeof(o==null?void 0:o.then)=="function"?si(o):se(o)})).subscribe(()=>{this.eventPending=!1})}unlessEventPending(t){let i=()=>this.eventPending=!0,s=()=>this.eventPending=!1;return r=>{if(this.eventPending){t.preventDefault();return}i();let n=r.bind(this)(t);ie(n)?n.subscribe(()=>s()):typeof(n==null?void 0:n.then)=="function"?n.then(()=>s()).catch(o=>{throw s(),o}):s()}}};Tt([oi()],ft.prototype,"state",2);export{Et as WishlistApp,ft as WishlistElement}; | ||
`+String(i)));bt(e);for(var s=0;s<e.callbacks.length;s++){var r=i[s];r instanceof Error?e.callbacks[s].reject(r):e.callbacks[s].resolve(r)}}).catch(function(i){Ot(a,e,i)})}function Ot(a,e,t){bt(e);for(var i=0;i<e.keys.length;i++)a.clear(e.keys[i]),e.callbacks[i].reject(t)}function bt(a){if(a.cacheHits)for(var e=0;e<a.cacheHits.length;e++)a.cacheHits[e]()}function Ie(a){var e=!a||a.batch!==!1;if(!e)return 1;var t=a&&a.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}function be(a){var e=a&&a.batchScheduleFn;if(e===void 0)return ge;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}function ve(a){var e=a&&a.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}function Pe(a){var e=!a||a.cache!==!1;if(!e)return null;var t=a&&a.cacheMap;if(t===void 0)return new Map;if(t!==null){var i=["get","set","delete","clear"],s=i.filter(function(r){return t&&typeof t[r]!="function"});if(s.length!==0)throw new TypeError("Custom cacheMap missing methods: "+s.join(", "))}return t}function kt(a){return typeof a=="object"&&a!==null&&typeof a.length=="number"&&(a.length===0||a.length>0&&Object.prototype.hasOwnProperty.call(a,a.length-1))}Mt.exports=fe});var St=Ct((Li,Wt)=>{var Pt=(()=>{var a=Object.defineProperty,e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(m,g,w)=>g in m?a(m,g,{enumerable:!0,configurable:!0,writable:!0,value:w}):m[g]=w,r=(m,g)=>{for(var w in g||(g={}))t.call(g,w)&&s(m,w,g[w]);if(e)for(var w of e(g))i.call(g,w)&&s(m,w,g[w]);return m},n=m=>a(m,"__esModule",{value:!0}),o=(m,g)=>{n(m);for(var w in g)a(m,w,{get:g[w],enumerable:!0})},l={};o(l,{DEFAULT_UUID_LENGTH:()=>c,default:()=>b});var h="4.4.4",c=6,d={dictionary:"alphanum",shuffle:!0,debug:!1,length:c},y=class extends Function{constructor(m={}){super(),this.dictIndex=0,this.dictRange=[],this.lowerBound=0,this.upperBound=0,this.dictLength=0,this._digit_first_ascii=48,this._digit_last_ascii=58,this._alpha_lower_first_ascii=97,this._alpha_lower_last_ascii=123,this._hex_last_ascii=103,this._alpha_upper_first_ascii=65,this._alpha_upper_last_ascii=91,this._number_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii]},this._alpha_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alpha_lower_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alpha_upper_dict_ranges={upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_lower_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alphanum_upper_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._hex_dict_ranges={decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]},this.log=(...u)=>{let p=[...u];if(p[0]=`[short-unique-id] ${u[0]}`,this.debug===!0&&typeof console!="undefined"&&console!==null)return console.log(...p)},this.setDictionary=(u,p)=>{let v;if(u&&Array.isArray(u)&&u.length>1)v=u;else{v=[];let I;this.dictIndex=I=0;let E=`_${u}_dict_ranges`,U=this[E];Object.keys(U).forEach(q=>{let V=q;for(this.dictRange=U[V],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=I=this.lowerBound;this.lowerBound<=this.upperBound?I<this.upperBound:I>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?I+=1:I-=1)v.push(String.fromCharCode(this.dictIndex))})}p&&(v=v.sort(()=>Math.random()-.5)),this.dict=v,this.dictLength=this.dict.length,this.counter=0},this.seq=()=>this.sequentialUUID(),this.sequentialUUID=()=>{let u,p,v="";u=this.counter;do p=u%this.dictLength,u=Math.trunc(u/this.dictLength),v+=this.dict[p];while(u!==0);return this.counter+=1,v},this.randomUUID=(u=this.uuidLength||c)=>{let p,v,I;if(u===null||typeof u=="undefined"||u<1)throw new Error("Invalid UUID Length Provided");let E=u>=0;for(p="",I=0;I<u;I+=1)v=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,p+=this.dict[v];return p},this.availableUUIDs=(u=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,u).toFixed(0)),this.approxMaxBeforeCollision=(u=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*u).toFixed(20)),this.collisionProbability=(u=this.availableUUIDs(this.uuidLength),p=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(u)/this.availableUUIDs(p)).toFixed(20)),this.uniqueness=(u=this.availableUUIDs(this.uuidLength))=>{let p=parseFloat((1-this.approxMaxBeforeCollision(u)/u).toFixed(20));return p>1?1:p<0?0:p},this.getVersion=()=>this.version,this.stamp=u=>{if(typeof u!="number"||u<10)throw new Error("Param finalLength must be number greater than 10");let p=Math.floor(+new Date/1e3).toString(16),v=u-9,I=Math.round(Math.random()*(v>15?15:v)),E=this.randomUUID(v);return`${E.substr(0,I)}${p}${E.substr(I)}${I.toString(16)}`},this.parseStamp=u=>{if(u.length<10)throw new Error("Stamp length invalid");let p=parseInt(u.substr(u.length-1,1),16);return new Date(parseInt(u.substr(p,8),16)*1e3)};let g=r(r({},d),m);this.counter=0,this.debug=!1,this.dict=[],this.version=h;let{dictionary:w,shuffle:S,length:k}=g;return this.uuidLength=k,this.setDictionary(w,S),this.debug=g.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength}`),new Proxy(this,{apply:(u,p,v)=>this.randomUUID(...v)})}},b=y;return b.default=y,l})();typeof Wt!="undefined"&&(Wt.exports=Pt.default),typeof window!="undefined"&&(Pt=Pt.default)});import{lastValueFrom as A}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{fromFetch as ue}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/fetch/+esm";import{switchMap as de}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";var F=class{constructor(e){this.host=e.host,this.headers={"content-type":"application/json"}}fetch({path:e,method:t="GET",query:i,body:s,headers:r={}}){return ue(this.host+e+this.getQuerystring(i),{method:t,headers:{...this.headers,...r},body:s}).pipe(de(n=>{if(n.ok)return n.json();throw Error(`Error ${n.status}`)}))}getQuerystring(e){if(!e)return"";let t=new URLSearchParams;return Object.entries(e).forEach(([i,s])=>{Array.isArray(s)?s.forEach(r=>t.append(i,r)):s&&t.append(i,s)}),"?"+t.toString()}get({path:e,query:t,headers:i}){return this.fetch({method:"GET",path:e,query:t,headers:i})}post({path:e,query:t,body:i,headers:s}){return this.fetch({method:"POST",path:e,query:t,body:i?JSON.stringify(i):void 0,headers:s})}put({path:e,query:t,body:i,headers:s}){return this.fetch({method:"PUT",path:e,query:t,body:i?JSON.stringify(i):void 0,headers:s})}delete({path:e,query:t,body:i,headers:s}){return this.fetch({method:"DELETE",path:e,query:t,body:i?JSON.stringify(i):void 0,headers:s})}};var K=class extends F{loadProduct({productHandle:e}){return this.get({path:`/products/${e}.js`})}addToCart(e){return this.post({path:"/cart/add.js",body:e})}};var Rt="4.14.6";var Q=wt(Ft());import{from as vt,lastValueFrom as J}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var G=class extends F{constructor(t){var i,s,r;super(t);this.headers={"content-type":"application/json","x-appmate-shp":t.shop,"x-appmate-tkv":Rt,"x-appmate-sid":t.sessionId,"x-appmate-cid":(s=(i=t.customerId)==null?void 0:i.toString())!=null?s:"","x-appmate-src":(r=t.trackingSource)!=null?r:""},this.wishlistLoader=this.createWishlistLoader(),this.productInfoLoader=this.createProductInfoLoader(),this.wishlistItemLoader=this.createWishlistItemLoader()}createWishlistLoader(){return new Q.default(async t=>{let i=t.map(r=>r.split("-")).reduce((r,[n,o])=>(r[n]||(r[n]=[]),r[n].push(o),r),{}),s=await Promise.all(Object.entries(i).map(([r,n])=>J(this.get({path:`/wishlists/${r}`,query:{format:n.includes("all")?"all":"minimal"}})))).then(r=>r.map(n=>n.wishlist));return t.map((r,n)=>{var l;let[o]=r.split("-");return(l=s.find(h=>o==="mine"?h.isMine:h.publicId===o))!=null?l:new Error("Wishlist not found")})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}createProductInfoLoader(){return new Q.default(async t=>{let{productInfo:i}=await J(this.get({path:"/wishlists/mine/product-info",headers:{"X-Appmate-IDS":t.join(",")}}));return t.map(s=>{var r;return(r=i.find(n=>n.productId===s))!=null?r:{productId:s,wishlistItems:[]}})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}createWishlistItemLoader(){return new Q.default(async t=>{let i=t.map(r=>r.split("-")).reduce((r,[n,o])=>(r[n]||(r[n]=[]),r[n].push(o),r),{}),s=await Promise.all(Object.entries(i).map(([r,n])=>J(this.get({path:`/wishlists/${r}/items`,headers:{"X-Appmate-IDS":n.join(",")}})))).then(r=>r.flatMap(n=>n.items));return t.map(r=>{var o;let[,n]=r.split("-");return(o=s.find(l=>l.id===n))!=null?o:new Error("Wishlist item not found")})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}loadWishlist({wishlistId:t,format:i}){return vt(this.wishlistLoader.load([t,i].join("-")).then(s=>({wishlist:s})))}loadProductInfo({productId:t}){return vt(this.productInfoLoader.load(t).then(i=>({productInfo:i})))}loadWishlistItem({wishlistId:t,wishlistItemId:i}){return vt(this.wishlistItemLoader.load([t,i].join("-")).then(s=>({wishlistItem:s})))}loadWishlistItems({wishlistId:t,wishlistItemIds:i}){return J(this.get({path:`/wishlists/${t}/items`,headers:{"X-Appmate-IDS":i.join(",")}}))}addItem({productId:t,variantId:i}){return typeof t=="string"&&(t=parseInt(t)),typeof i=="string"&&(i=parseInt(i)),this.post({path:"/wishlists/mine/items",body:{productId:t,variantId:i}})}updateItem({wishlistItemId:t,changes:i}){return this.put({path:"/wishlists/mine/items",body:{changes:{...i,wishlistItemId:t}}})}removeItem({wishlistId:t,wishlistItemId:i}){return this.delete({path:`/wishlists/${t}/items`,body:{wishlistItemId:i}})}clearWishlist(){return this.delete({path:"/wishlists/mine"})}};import{forkJoin as xe,lastValueFrom as Ae,of as Ee}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{catchError as We,map as Se,of as Lt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{fromFetch as _e}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/fetch/+esm";var X=class{constructor({host:e,shop:t,sessionId:i,customerId:s}){this.host=e,this.shop=t,this.customerId=s,this.sessionId=i,this.eventNames=new Map([["viewWishlist","wishlist_viewed"],["addToCart","product_added_to_cart"],["shareWishlist","wishlist_shared"]])}track({eventName:e,wishlist:t,product:i,variant:s,quantity:r,source:n}){var l,h;let o=this.eventNames.get(e);return!o||!t?Lt(!1):_e(this.host+"/notify",{method:"POST",headers:{"content-type":"application/json","x-appmate-shp":this.shop,"x-appmate-sid":this.sessionId,"x-appmate-cid":(h=(l=this.customerId)==null?void 0:l.toString())!=null?h:""},body:JSON.stringify({event:o,wid:t.publicId,pid:i==null?void 0:i.id,vid:s==null?void 0:s.id,qty:r,src:n})}).pipe(Se(()=>!0),We(()=>Lt(!1)))}getQuerystring(e){if(!e)return"";let t=new URLSearchParams;return Object.entries(e).forEach(([i,s])=>{Array.isArray(s)?s.forEach(r=>t.append(i,r)):s&&t.append(i,s)}),"?"+t.toString()}};import{of as Dt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var{ga:j}=window,z=class{constructor(){this.eventNames=new Map([["addToWishlist","WK Added Product"],["removeFromWishlist","WK Removed Product"],["addToCart","WK Added to Cart"],["shareWishlist","WK Shared Wishlist"],["clearWishlist","WK Cleared Wishlist"]])}track({eventName:e,product:t,variant:i,quantity:s=1}){var n;let r=this.eventNames.get(e);return!r||!(j!=null&&j.loaded)||!t?Dt(!1):(j("ec:addProduct",{id:(n=(i==null?void 0:i.sku)||(i==null?void 0:i.id))!=null?n:t.id,name:t.title,category:t.type,brand:t.vendor,variant:i==null?void 0:i.title,quantity:s}),j("send",{eventAction:r,hitType:"event",eventCategory:"Wishlist",eventLabel:"Wishlist King"}),Dt(!0))}};import{of as Nt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var Y=class{constructor({urlUtil:e,moneyUtil:t}){this.urlUtil=e,this.moneyUtil=t,this.eventNames=new Map([["addToWishlist","Added To Wishlist"],["removeFromWishlist","Removed From Wishlist"],["clearWishlist","Cleared Wishlist"]])}track({eventName:e,wishlist:t,product:i,variant:s,quantity:r=1}){let n=this.eventNames.get(e);return!n||!t||!i?Nt(!1):(window._learnq||(window._learnq=[]),window._learnq.push(["track",n,{URL:this.urlUtil.getVariantUrl(i.url,s==null?void 0:s.id),Name:i.title,ProductID:i.id,VariantID:s==null?void 0:s.id,SKU:s==null?void 0:s.sku,Tags:i.tags,Brand:i.vendor,ImageURL:this.urlUtil.getImageUrl(i,{width:1e3}),Price:s==null?void 0:s.price,PriceFormatted:s?this.moneyUtil.formatMoney(s.price):null,CompareAtPrice:s==null?void 0:s.compare_at_price,CompareAtPriceFormatted:s!=null&&s.compare_at_price?this.moneyUtil.formatMoney(s.compare_at_price):null,Quantity:r,WishlistUrl:this.urlUtil.getPublicWishlistUrl(t.id)}]),Nt(!0))}};import{of as qt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var{fbq:Vt}=window,Z=class{constructor({currency:e}){this.currency=e,this.eventNames=new Map([["addToWishlist","AddToWishlist"]])}track({eventName:e,product:t,variant:i}){let s=this.eventNames.get(e);return!s||typeof Vt!="function"||!t?qt(!1):(Vt("track",s,{value:i==null?void 0:i.price,currency:this.currency,content_ids:[t.id],content_name:[t.title,i==null?void 0:i.title].filter(r=>!!r).join(" - "),content_category:t.type,content_type:"product_group",num_items:1}),qt(!0))}};var tt=class{constructor({settings:e,events:t,notifyHost:i,utils:s,shop:r,sessionId:n,customerId:o}){this.utils=s,this.services=[],e.appmateAnalytics&&this.services.push(new X({host:i,shop:r,customerId:o,sessionId:n})),e.klaviyo&&this.services.push(new Y({urlUtil:this.utils.url,moneyUtil:this.utils.money})),e.facebookPixel&&this.services.push(new Z({currency:window.Shopify.currency.active})),e.googleAnalytics&&this.services.push(new z);let l=this.utils.route.parse(window.location.pathname).pageType,h=c=>d=>{var y,b,m,g;return Ae(this.track({eventName:c,source:l,wishlist:(y=d.data)==null?void 0:y.wishlist,product:(b=d.data)==null?void 0:b.product,variant:(m=d.data)==null?void 0:m.variant,quantity:(g=d.data)==null?void 0:g.quantity}))};t.subscribeMany({"wk:wishlist:add-to-cart:success":h("addToCart"),"wk:wishlist:add:success":h("addToWishlist"),"wk:wishlist:change-variant:success":h("changeVariant"),"wk:wishlist:clear:success":h("clearWishlist"),"wk:wishlist:remove:success":h("removeFromWishlist"),"wk:wishlist:share:success":h("shareWishlist"),"wk:wishlist:page-view":h("viewWishlist")})}track(e){return this.services.length?xe(this.services.map(t=>t.track(e))):Ee([])}};import{defer as Qt,forkJoin as xt,from as Gt,of as _,throwError as Xt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{switchMap as f,map as W,catchError as C,mergeWith as st,startWith as zt,distinctUntilChanged as B,shareReplay as rt,tap as Yt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";var Jt=wt(St());import{catchError as Oe,defer as x,forkJoin as H,from as P,map as M,Observable as ke,of as Me,switchMap as D}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{Dexie as Fe,liveQuery as Le}from"https://cdn.jsdelivr.net/npm/dexie@3.2.2/+esm";var jt=wt(St());import{filter as Ue,pipe as Ce}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var Te=new jt.default({length:10}),_t=()=>{if(localStorage.getItem("wk_session_id"))return localStorage.getItem("wk_session_id");let a=localStorage.getItem("appmate-session");if(a)try{let t=JSON.parse(a).state.sid;return localStorage.setItem("wk_session_id",t),t}catch(t){console.error(t)}let e=Te();return localStorage.setItem("wk_session_id",e),e};function $t(a,e){return{id:a.isMine?"mine":a.id,publicId:a.publicId,isMine:a.isMine,numItems:a.numItems,items:e==="all"?a.items:void 0}}function et({productInfo:a,variantId:e,wishlistMode:t="product"}){let i=e&&t==="variant"?a.wishlistItems.find(s=>s.variantId===e):a.wishlistItems[0];return{productId:a.productId,variantId:e,inWishlist:!!i,wishlistItemId:i==null?void 0:i.id}}function L({productInfo:a}){let e=a.wishlistItems.map(t=>t.id);return{...a,wishlistItemIds:e.length?e:void 0}}function Ht(a,e){return{...a,product:{...e,hidden:!1}}}function Bt(a,e){return a.variants.find(t=>t.id===e)}function Re(a,e){return a.id===e.wishlistItemId}function Kt(a,e){return a==null?void 0:a.filter(t=>!Re(t,e))}function $(){return Ce(Ue(a=>a!=null))}var De=new Jt.default({length:10}),it=class extends Fe{constructor(){super("WishlistKing");this.version(1).stores({shopifyProducts:"handle",wishlists:"id",wishlistItems:"id",productInfo:"productId,*wishlistItemIds"})}storeShopifyProduct({product:t}){return P(x(()=>this.shopifyProducts.put(t)).pipe(M(()=>t)))}storeWishlist({wishlist:t}){return this.getWishlist({wishlistId:t.id}).pipe(Oe(()=>Me(null)),D(i=>{var s;return P(this.wishlists.put({...t,items:(s=t.items)!=null?s:i==null?void 0:i.items}))}),M(()=>t))}storeProductInfo({productInfo:t}){return P(x(()=>this.productInfo.put(L({productInfo:t}))))}storeWishlistItem({wishlistItem:t}){return P(x(()=>this.wishlistItems.put(t)))}getProductInfo({productId:t}){return P(x(()=>this.productInfo.get(t)))}getProductInfoByItemId({wishlistItemId:t}){return P(x(()=>this.productInfo.where("wishlistItemIds").equals(t).first()))}getProductInfos(){return P(x(()=>this.productInfo.toArray()))}getWishlist({wishlistId:t}){return P(x(()=>this.wishlists.get(t)))}getWishlistItems(){return P(x(()=>this.wishlistItems.toArray()))}getShopifyProduct({productHandle:t}){return P(x(()=>this.shopifyProducts.get(t)))}getWishlistItem({wishlistItemId:t}){return P(x(()=>this.wishlistItems.get(t)))}addItemToWishlist({productId:t,variantId:i}){return H([this.getWishlist({wishlistId:"mine"}),this.getProductInfo({productId:t})]).pipe(D(([s,r])=>{let n={id:`temp-${De()}`},o=Ne({wishlistId:"mine",item:n},s),l=()=>this.wishlists.put(o),h=()=>s?this.wishlists.put(s):this.wishlists.delete("mine"),c=()=>this.productInfo.put(L({productInfo:{productId:t,wishlistItems:r?[...r.wishlistItems,{id:n.id,variantId:i}]:[{id:n.id,variantId:i}]}})),d=()=>r?this.productInfo.put(r):this.productInfo.delete(t);return P(x(()=>this.transaction("rw",this.wishlists,this.productInfo,()=>Promise.all([l(),c()])))).pipe(M(()=>({wishlist:o,item:n,revertStateUpdate:()=>P(this.transaction("rw",this.wishlists,this.productInfo,()=>Promise.all([h(),d()])))})))}))}removeItemFromWishlist({wishlistItemId:t}){return H([this.getWishlist({wishlistId:"mine"}),this.getProductInfoByItemId({wishlistItemId:t}),this.getWishlistItem({wishlistItemId:t})]).pipe(D(([i,s,r])=>{let n=qe({wishlistItemId:t},i),o=()=>this.wishlists.put(n),l=()=>i?this.wishlists.put(i):this.wishlists.delete("mine"),h=()=>{if(s)return this.productInfo.put(L({productInfo:{productId:s.productId,wishlistItems:s.wishlistItems.filter(b=>b.id!==t)}}))},c=()=>{if(s)return this.productInfo.put(s)},d=()=>{if(r)return this.wishlistItems.delete(r.id)},y=()=>{if(r)return this.wishlistItems.put(r)};return P(x(()=>this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([o(),h(),d()])))).pipe(M(()=>({wishlist:n,revertStateUpdate:()=>P(this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([l(),c(),y()])))})))}))}clearWishlist(){return H([this.getWishlist({wishlistId:"mine"}),this.getProductInfos(),this.getWishlistItems()]).pipe(D(([t,i,s])=>{let r=Ve(t),n=()=>{if(r)return this.wishlists.put(r)},o=()=>{var y;return t?this.wishlists.put(t):this.wishlists.delete((y=r==null?void 0:r.id)!=null?y:"mine")},l=()=>this.productInfo.clear(),h=()=>{if(i)return this.productInfo.bulkPut(i)},c=()=>this.wishlistItems.clear(),d=()=>{if(s)return this.wishlistItems.bulkPut(s)};return P(x(()=>this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([n(),l(),c()])))).pipe(M(()=>({wishlist:r,revertStateUpdate:()=>P(this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([o(),h(),d()])))})))}))}updateWishlistItem({wishlistItemId:t,changes:i}){return H([this.getWishlistItem({wishlistItemId:t}),this.getProductInfoByItemId({wishlistItemId:t})]).pipe(D(([s,r])=>{let n=()=>{if(s)return this.wishlistItems.put({...s,selectedVariantId:i.variantId})},o=()=>{if(s)return this.wishlistItems.put(s)},l=()=>{if(r)return this.productInfo.put(L({productInfo:{...r,wishlistItems:r.wishlistItems.map(c=>c.id===t?{...c,variantId:i.variantId}:c)}}))},h=()=>{if(r)return this.productInfo.put(r)};return P(x(()=>this.transaction("rw",this.wishlistItems,this.productInfo,()=>Promise.all([n(),l()])))).pipe(M(()=>({revertStateUpdate:()=>P(this.transaction("rw",this.wishlistItems,this.productInfo,()=>Promise.all([o(),h()])))})))}))}changeWishlistItemRef({wishlistItemId:t,changes:i}){return H([this.getWishlist({wishlistId:"mine"}),this.getProductInfoByItemId({wishlistItemId:t})]).pipe(D(([s,r])=>{let n={id:i.id},o=()=>{var h;if(s)return this.wishlists.put({...s,items:(h=s.items)==null?void 0:h.map(c=>c.id===t?n:c)})},l=()=>{if(r)return this.productInfo.put(L({productInfo:{...r,wishlistItems:r.wishlistItems.map(h=>h.id===t?{...h,id:i.id}:h)}}))};return P(Promise.all([o(),l()])).pipe(M(()=>({item:n})))}))}liveQuery(t){return new ke(i=>{Le(t).subscribe({error:i.error.bind(i),next:i.next.bind(i),complete:i.complete.bind(i)})})}},Ne=(a,e)=>e?{...e,numItems:e.numItems+1,items:e.items?[...e.items,a.item]:[a.item]}:{id:a.wishlistId,publicId:void 0,isMine:!0,numItems:1,items:[a.item]},qe=(a,e)=>e?{...e,numItems:e.numItems-1,items:e.items?Kt(e.items,a):[]}:{id:"mine",publicId:void 0,isMine:!0,numItems:0},Ve=a=>{if(!!a)return{...a,numItems:0,items:[]}};var nt=class{constructor({wishlistApi:e,shopifyApi:t,settings:i,events:s,utils:r}){this.cacheDb=new it;this.cacheDb.open(),this.wishlistApi=e,this.shopifyApi=t,this.settings=i,this.loadWishlistCache=new Map,this.loadWishlistItemCache=new Map,this.loadProductInfoCache=new Map,this.loadShopifyProductCache=new Map,this.events=s,this.utils=r}loadWishlist({wishlistId:e,format:t,strategy:i="network-only"}){let s=[e,t].join("-");if(!this.loadWishlistCache.has(s)){let n=this.wishlistApi.loadWishlist({wishlistId:e,format:t}),o=l=>this.cacheDb.storeWishlist({wishlist:l}).pipe(W(()=>$t(l,t)));this.loadWishlistCache.set(s,n.pipe(f(({wishlist:l})=>o(l)),rt()))}let r=this.loadWishlistCache.get(s);return i==="cache-first"?this.cacheDb.getWishlist({wishlistId:e}).pipe(f(n=>n?_(n):r)):r}observeWishlist({wishlistId:e,format:t}){let i={id:e,isMine:e==="mine",numItems:0,items:void 0};try{e==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load")}catch(n){return _(i)}let s=this.loadWishlist({wishlistId:e,format:t}),r=this.cacheDb.liveQuery(()=>this.cacheDb.wishlists.get(e));return s.pipe(st(r),zt(t==="minimal"?i:null),$(),B((n,o)=>JSON.stringify(n)===JSON.stringify(o)))}loadProductInfo({productId:e,variantId:t=0,strategy:i}){if(this.throwIfLoginRequired("wishlist:private:load"),!this.loadProductInfoCache.has(e)){let r=this.wishlistApi.loadProductInfo({productId:e}),n=o=>this.cacheDb.storeProductInfo({productInfo:o});this.loadProductInfoCache.set(e,r.pipe(f(({productInfo:o})=>n(o).pipe(W(()=>et({productInfo:o,variantId:t,wishlistMode:this.settings.wishlistMode})))),rt()))}let s=this.loadProductInfoCache.get(e);return i==="cache-first"?this.cacheDb.getProductInfo({productId:e}).pipe(f(r=>r?_(et({productInfo:r,variantId:t,wishlistMode:this.settings.wishlistMode})):s)):s}observeProductInfo({productHandle:e,productId:t,variantId:i,strategy:s}){let r={productId:t!=null?t:0,variantId:i,inWishlist:!1};try{this.throwIfLoginRequired("wishlist:private:load")}catch(h){return _(r)}let n=t?_(t):this.loadShopifyProduct({productHandle:e,strategy:"cache-first"}).pipe(W(h=>h.id)),o=n.pipe(f(h=>this.loadProductInfo({productId:h,strategy:s}))),l=n.pipe(f(h=>this.cacheDb.liveQuery(()=>this.cacheDb.productInfo.get(h)).pipe(W(c=>c?et({productInfo:c,variantId:i,wishlistMode:this.settings.wishlistMode}):r))));return s==="cache-first"?l.pipe(f(h=>h?_(h):o),B((h,c)=>JSON.stringify(h)===JSON.stringify(c)),C(h=>(console.error(h),_(r)))):o.pipe(st(l),$(),B((h,c)=>JSON.stringify(h)===JSON.stringify(c)),C(h=>(console.error(h),_(r))))}loadWishlistItem({wishlistId:e,wishlistItemId:t,strategy:i}){let s=t;if(!this.loadWishlistItemCache.has(s)){let n=this.wishlistApi.loadWishlistItem({wishlistId:e,wishlistItemId:t}),o=l=>this.cacheDb.storeWishlistItem({wishlistItem:l}).pipe(W(()=>l));this.loadWishlistItemCache.set(s,n.pipe(f(({wishlistItem:l})=>o(l)),rt()))}let r=this.loadWishlistItemCache.get(s);return i==="cache-first"?this.cacheDb.getWishlistItem({wishlistItemId:t}).pipe(f(n=>n?_(n):r)):r}observeWishlistItem({wishlistId:e,wishlistItemId:t}){let i={id:t,product:{id:0,handle:"",hidden:!1}};try{e==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load")}catch(o){return _(i)}let s=this.loadWishlistItem({wishlistId:e,wishlistItemId:t}),r=this.cacheDb.liveQuery(()=>this.cacheDb.wishlistItems.get(t)).pipe(W(o=>o?o:null)),n=o=>!o.product.handle||o.product.hidden?_(o):this.observeShopifyProduct({productHandle:o.product.handle}).pipe(W(l=>Ht(o,l)));return s.pipe(zt(i),st(r),$(),f(o=>n(o)),B((o,l)=>JSON.stringify(o)===JSON.stringify(l)))}loadShopifyProduct({productHandle:e,strategy:t}){let i=e;if(!this.loadShopifyProductCache.has(i)){let r=this.shopifyApi.loadProduct({productHandle:e}),n=o=>this.cacheDb.storeShopifyProduct({product:o}).pipe(W(()=>o));this.loadShopifyProductCache.set(i,r.pipe(f(o=>n(o)),rt()))}let s=this.loadShopifyProductCache.get(i);return t==="cache-first"?this.cacheDb.getShopifyProduct({productHandle:e}).pipe(f(r=>r?_(r):s)):s}observeShopifyProduct({productHandle:e}){let t=this.loadShopifyProduct({productHandle:e}),i=this.cacheDb.liveQuery(()=>this.cacheDb.shopifyProducts.get(e));return t.pipe(st(i),$(),B((s,r)=>JSON.stringify(s)===JSON.stringify(r)))}loadWishlistProduct({wishlistId:e,wishlistItemId:t}){return e==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load"),this.loadWishlistItem({wishlistId:e,wishlistItemId:t}).pipe(f(i=>this.loadShopifyProduct({productHandle:i.product.handle})))}addWishlistItem(e){this.throwIfLoginRequired("wishlist:private:add");let t=typeof e.productId=="string"?parseInt(e.productId):e.productId,i=typeof e.variantId=="string"?parseInt(e.variantId):e.variantId,s=this.cacheDb.addItemToWishlist({productId:t,variantId:i}),r=this.wishlistApi.addItem({productId:t,variantId:i});return s.pipe(f(({item:n,revertStateUpdate:o})=>r.pipe(f(({wishlistItem:l})=>xt([this.cacheDb.storeWishlistItem({wishlistItem:l}),this.cacheDb.changeWishlistItemRef({wishlistItemId:n.id,changes:{id:l.id}})]).pipe(W(()=>({wishlistItem:l})))),f(l=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:add:success",productHandle:l.wishlistItem.product.handle,variantId:l.wishlistItem.selectedVariantId}).pipe(W(()=>l))),C(l=>(console.error(l),this.events.publish({name:"wk:wishlist:add:error",error:l}),o())))))}updateWishlistItem(e){this.throwIfLoginRequired("wishlist:private:change-variant");let t={variantId:typeof e.changes.variantId=="string"?parseInt(e.changes.variantId):e.changes.variantId},i=this.cacheDb.updateWishlistItem({wishlistItemId:e.wishlistItemId,changes:t}),s=this.wishlistApi.updateItem({wishlistItemId:e.wishlistItemId,changes:t});return i.pipe(f(({revertStateUpdate:r})=>s.pipe(f(n=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:change-variant:success",productHandle:n.wishlistItem.product.handle,variantId:n.wishlistItem.selectedVariantId}).pipe(W(()=>n))),C(n=>(console.error(n),this.events.publish({name:"wk:wishlist:change-variant:error",error:n}),r())))))}removeWishlistItem({wishlistItemId:e}){this.throwIfLoginRequired("wishlist:private:remove");let t=this.cacheDb.removeItemFromWishlist({wishlistItemId:e}),i=this.wishlistApi.removeItem({wishlistId:"mine",wishlistItemId:e});return t.pipe(f(({wishlist:s,revertStateUpdate:r})=>i.pipe(W(({wishlistItem:n})=>({wishlist:s,wishlistItem:n})),f(n=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:remove:success",productHandle:n.wishlistItem.product.handle,variantId:n.wishlistItem.selectedVariantId}).pipe(W(()=>n))),C(n=>(console.error(n),this.events.publish({name:"wk:wishlist:remove:error",error:n}),r())))))}clearWishlist(){this.throwIfLoginRequired("wishlist:private:clear");let e=this.cacheDb.clearWishlist(),t=this.wishlistApi.clearWishlist();return e.pipe(f(({revertStateUpdate:i})=>t.pipe(f(()=>this.publishWishlistEvent({wishlistId:"mine",eventName:"wk:wishlist:clear:success"})),C(s=>(console.error(s),this.events.publish({name:"wk:wishlist:clear:error",error:s}),i())))))}addToCart({wishlistId:e,wishlistItemId:t,variantId:i,quantity:s=1,sectionsToRender:r,sectionsUrl:n}){return e==="mine"?this.throwIfLoginRequired("wishlist:private:add-to-cart"):this.throwIfLoginRequired("wishlist:public:add-to-cart"),this.shopifyApi.addToCart({id:i,quantity:s,sections:r,sections_url:n}).pipe(f(o=>xt([this.loadWishlist({wishlistId:e,format:"minimal"}),this.loadWishlistItem({wishlistId:e,wishlistItemId:t})]).pipe(W(([l,h])=>({wishlistItem:h,cartResponse:o,wishlist:l})))),f(o=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:add-to-cart:success",productHandle:o.wishlistItem.product.handle,variantId:o.wishlistItem.selectedVariantId}).pipe(W(()=>o))),C(o=>(this.events.publish({name:"wk:wishlist:add-to-cart:error",error:o}),Xt(()=>o))),f(o=>this.settings.moveToCart&&o.wishlist.isMine?this.removeWishlistItem({wishlistItemId:t}).pipe(W(()=>o)):_(o)))}addAllToCart({wishlistId:e,sectionsToRender:t,sectionsUrl:i}){let s=e==="mine";return s?this.throwIfLoginRequired("wishlist:private:add-to-cart"):this.throwIfLoginRequired("wishlist:public:add-to-cart"),this.loadWishlist({wishlistId:e,format:"all"}).pipe(f(r=>{var n,o;return this.wishlistApi.loadWishlistItems({wishlistId:r.id,wishlistItemIds:(o=(n=r.items)==null?void 0:n.map(l=>l.id))!=null?o:[]})}),f(({items:r})=>{var n;return this.shopifyApi.addToCart({items:(n=r.filter(o=>!o.hidden&&!!o.selectedVariantId).map(o=>({id:o.selectedVariantId,quantity:1})))!=null?n:[],sections:t,sections_url:i})}),f(r=>this.settings.moveToCart&&s?this.clearWishlist().pipe(W(()=>({cartResponse:r}))):_({cartResponse:r}))).pipe(f(r=>this.publishWishlistEvent({wishlistId:"mine",eventName:"wk:wishlist:add-all-to-cart:success"}).pipe(W(()=>r))),C(r=>(this.events.publish({name:"wk:wishlist:add-all-to-cart:error",error:r}),Xt(()=>r))))}shareWishlist({wishlistId:e,title:t,text:i}){e==="mine"?this.throwIfLoginRequired("wishlist:private:share"):this.throwIfLoginRequired("wishlist:public:share");let s={url:this.utils.url.getPublicWishlistUrl(e),title:t,text:i},r=Gt(Qt(async()=>{try{await navigator.share(s)}catch(o){throw new Error("Web share api not available")}}).pipe(f(()=>this.publishWishlistEvent({wishlistId:e,eventName:"wk:wishlist:share:success"})),W(()=>({webShare:!0,clipboard:!1})))),n=Gt(Qt(async()=>{try{await navigator.clipboard.writeText(s.url)}catch(o){throw new Error("Web clipboard api not available")}}).pipe(f(()=>this.publishWishlistEvent({wishlistId:e,eventName:"wk:wishlist:share:success"})),W(()=>({webShare:!1,clipboard:!0}))));return r.pipe(C(()=>n.pipe(C(o=>(this.events.publish({name:"wk:wishlist:share:error",error:o}),_({webShare:!1,clipboard:!1}))))))}publishWishlistItemEvent({eventName:e,wishlistId:t,productHandle:i,variantId:s}){return xt([this.loadWishlist({wishlistId:t,format:"minimal",strategy:"cache-first"}),this.loadShopifyProduct({productHandle:i,strategy:"cache-first"})]).pipe(Yt(([r,n])=>this.events.publish({name:e,data:{wishlist:r,product:n,variant:Bt(n,s),quantity:1}})))}publishWishlistEvent({eventName:e,wishlistId:t}){return this.loadWishlist({wishlistId:t,format:"minimal",strategy:"cache-first"}).pipe(Yt(i=>this.events.publish({name:e,data:{wishlist:i}})))}throwIfLoginRequired(e){var i;if(!this.settings.loginRequired)return;if(!this.settings.loginActions&&e.includes("private")||((i=this.settings.loginActions)==null?void 0:i.includes(e)))throw this.events.publish({name:"wk:wishlist:login-required",data:{action:e}}),new Error("Wishlist requires login")}};function je(a){for(var e=[],t=0;t<a.length;){var i=a[t];if(i==="*"||i==="+"||i==="?"){e.push({type:"MODIFIER",index:t,value:a[t++]});continue}if(i==="\\"){e.push({type:"ESCAPED_CHAR",index:t++,value:a[t++]});continue}if(i==="{"){e.push({type:"OPEN",index:t,value:a[t++]});continue}if(i==="}"){e.push({type:"CLOSE",index:t,value:a[t++]});continue}if(i===":"){for(var s="",r=t+1;r<a.length;){var n=a.charCodeAt(r);if(n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122||n===95){s+=a[r++];continue}break}if(!s)throw new TypeError("Missing parameter name at ".concat(t));e.push({type:"NAME",index:t,value:s}),t=r;continue}if(i==="("){var o=1,l="",r=t+1;if(a[r]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(r));for(;r<a.length;){if(a[r]==="\\"){l+=a[r++]+a[r++];continue}if(a[r]===")"){if(o--,o===0){r++;break}}else if(a[r]==="("&&(o++,a[r+1]!=="?"))throw new TypeError("Capturing groups are not allowed at ".concat(r));l+=a[r++]}if(o)throw new TypeError("Unbalanced pattern at ".concat(t));if(!l)throw new TypeError("Missing pattern at ".concat(t));e.push({type:"PATTERN",index:t,value:l}),t=r;continue}e.push({type:"CHAR",index:t,value:a[t++]})}return e.push({type:"END",index:t,value:""}),e}function $e(a,e){e===void 0&&(e={});for(var t=je(a),i=e.prefixes,s=i===void 0?"./":i,r="[^".concat(N(e.delimiter||"/#?"),"]+?"),n=[],o=0,l=0,h="",c=function(I){if(l<t.length&&t[l].type===I)return t[l++].value},d=function(I){var E=c(I);if(E!==void 0)return E;var U=t[l],q=U.type,V=U.index;throw new TypeError("Unexpected ".concat(q," at ").concat(V,", expected ").concat(I))},y=function(){for(var I="",E;E=c("CHAR")||c("ESCAPED_CHAR");)I+=E;return I};l<t.length;){var b=c("CHAR"),m=c("NAME"),g=c("PATTERN");if(m||g){var w=b||"";s.indexOf(w)===-1&&(h+=w,w=""),h&&(n.push(h),h=""),n.push({name:m||o++,prefix:w,suffix:"",pattern:g||r,modifier:c("MODIFIER")||""});continue}var S=b||c("ESCAPED_CHAR");if(S){h+=S;continue}h&&(n.push(h),h="");var k=c("OPEN");if(k){var w=y(),u=c("NAME")||"",p=c("PATTERN")||"",v=y();d("CLOSE"),n.push({name:u||(p?o++:""),pattern:u&&!p?r:p,prefix:w,suffix:v,modifier:c("MODIFIER")||""});continue}d("END")}return n}function T(a,e){var t=[],i=te(a,t,e);return He(i,t,e)}function He(a,e,t){t===void 0&&(t={});var i=t.decode,s=i===void 0?function(r){return r}:i;return function(r){var n=a.exec(r);if(!n)return!1;for(var o=n[0],l=n.index,h=Object.create(null),c=function(y){if(n[y]===void 0)return"continue";var b=e[y-1];b.modifier==="*"||b.modifier==="+"?h[b.name]=n[y].split(b.prefix+b.suffix).map(function(m){return s(m,b)}):h[b.name]=s(n[y],b)},d=1;d<n.length;d++)c(d);return{path:o,index:l,params:h}}}function N(a){return a.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function Zt(a){return a&&a.sensitive?"":"i"}function Be(a,e){if(!e)return a;for(var t=/\((?:\?<(.*?)>)?(?!\?)/g,i=0,s=t.exec(a.source);s;)e.push({name:s[1]||i++,prefix:"",suffix:"",modifier:"",pattern:""}),s=t.exec(a.source);return a}function Ke(a,e,t){var i=a.map(function(s){return te(s,e,t).source});return new RegExp("(?:".concat(i.join("|"),")"),Zt(t))}function Je(a,e,t){return Qe($e(a,t),e,t)}function Qe(a,e,t){t===void 0&&(t={});for(var i=t.strict,s=i===void 0?!1:i,r=t.start,n=r===void 0?!0:r,o=t.end,l=o===void 0?!0:o,h=t.encode,c=h===void 0?function(V){return V}:h,d=t.delimiter,y=d===void 0?"/#?":d,b=t.endsWith,m=b===void 0?"":b,g="[".concat(N(m),"]|$"),w="[".concat(N(y),"]"),S=n?"^":"",k=0,u=a;k<u.length;k++){var p=u[k];if(typeof p=="string")S+=N(c(p));else{var v=N(c(p.prefix)),I=N(c(p.suffix));if(p.pattern)if(e&&e.push(p),v||I)if(p.modifier==="+"||p.modifier==="*"){var E=p.modifier==="*"?"?":"";S+="(?:".concat(v,"((?:").concat(p.pattern,")(?:").concat(I).concat(v,"(?:").concat(p.pattern,"))*)").concat(I,")").concat(E)}else S+="(?:".concat(v,"(").concat(p.pattern,")").concat(I,")").concat(p.modifier);else p.modifier==="+"||p.modifier==="*"?S+="((?:".concat(p.pattern,")").concat(p.modifier,")"):S+="(".concat(p.pattern,")").concat(p.modifier);else S+="(?:".concat(v).concat(I,")").concat(p.modifier)}}if(l)s||(S+="".concat(w,"?")),S+=t.endsWith?"(?=".concat(g,")"):"$";else{var U=a[a.length-1],q=typeof U=="string"?w.indexOf(U[U.length-1])>-1:U===void 0;s||(S+="(?:".concat(w,"(?=").concat(g,"))?")),q||(S+="(?=".concat(w,"|").concat(g,")"))}return new RegExp(S,Zt(t))}function te(a,e,t){return a instanceof RegExp?Be(a,e):Array.isArray(a)?Ke(a,e,t):Je(a,e,t)}var O={isHome:T("/:locale?"),isCollection:T("/:locale?/collections/(.*)"),isProduct:T("/:locale?/products/:product"),isNestedProduct:T("/:locale?/collections/:collection?/products/:product"),isPage:T("/:locale?/pages/:page/:rest?"),isAccount:T("/:locale?/account/:account?"),isBlog:T("/:locale?/blog/:blog?"),isCart:T("/:locale?/cart/:cart?"),isProxy:T("/:locale?/apps/(.*)")},Ge=[{pageType:"product",match:a=>O.isProduct(a)||O.isNestedProduct(a)},{pageType:"collection",match:a=>O.isCollection(a)},{pageType:"page",match:a=>O.isPage(a)},{pageType:"account",match:a=>O.isAccount(a)},{pageType:"blog",match:a=>O.isBlog(a)},{pageType:"cart",match:a=>O.isCart(a)},{pageType:"home",match:a=>O.isHome(a)},{pageType:"proxy",match:a=>O.isProxy(a)}],at=class{constructor({wishlistUrl:e}){this.wishlistUrl=e}parse(e){for(let t of Ge){let i=t.match(e);if(i)return e.startsWith(this.wishlistUrl)?{pageType:"wishlist",handle:i.params.page}:{pageType:t.pageType,handle:i.params.page}}return{pageType:void 0}}};var ot=class{constructor(e){this.locale=this.decodeLocale(e.locale)}decodeHtmlEntities(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'")}decodeLocale(e){let t={};for(let i in e){t[i]={};for(let s in e[i])t[i][s]=this.decodeHtmlEntities(e[i][s])}return t}translate(e){var s,r;let[t,i]=e.split(".");return(r=(s=this.locale[t])==null?void 0:s[i])!=null?r:`translation missing: ${e}`}};var Xe="${{amount}}";function ee(a,e){typeof a=="string"&&(a=a.replace(".",""));let t="",i=/\{\{\s*(\w+)\s*\}\}/,s=e||Xe;function r(n,o=2,l=",",h="."){if(isNaN(n)||n==null)return 0;n=(n/100).toFixed(o);let c=n.split("."),d=c[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${l}`),y=c[1]?h+c[1]:"";return d+y}switch(s.match(i)[1]){case"amount":t=r(a,2);break;case"amount_no_decimals":t=r(a,0);break;case"amount_with_comma_separator":t=r(a,2,".",",");break;case"amount_no_decimals_with_comma_separator":t=r(a,0,".",",");break}return s.replace(i,t)}var lt=class{constructor(e){this.moneyFormat=e.moneyFormat,this.currencyRate=e.currencyRate,this.activeCurrency=e.activeCurrency}formatMoney(e){return typeof e=="string"&&(e=parseFloat(e)),ee(e,this.moneyFormat)}};var ht=class{constructor(e){this.rootUrl=e.rootUrl,this.shopDomain=e.shopDomain,this.wishlistUrl=e.wishlistUrl,this.placeholderImageUrl=e.placeholderImageUrl,this.fileUrl=e.fileUrl}getWishlistIdFromUrl(e){if(!e)return;let t=e.replace(this.rootUrl,"/").split("/");return t.length===4?t.pop():"mine"}getProductHandleFromUrl(e){var t;if(!!e)return e instanceof URL&&(e=e.pathname),(t=e.split("/").pop())==null?void 0:t.split("?")[0]}getVariantIdFromUrl(e){return new URLSearchParams(e.split("?")[1]).get("variant")}getPublicWishlistUrl(e){return`https://${this.shopDomain}${this.wishlistUrl}/${e}`}getFileUrl(e=""){return`https:${this.fileUrl.split("?")[0]}${e}`}getImageUrl(e,t){var s,r;if(!e)return(s=this.placeholderImageUrl)!=null?s:"";let i=this.getImage(e);return i!=null&&i.src?this.appendSize(i.src,t):(r=this.placeholderImageUrl)!=null?r:""}getImage(e){var t,i,s,r,n,o;if(e.hasOwnProperty("sku"))return{src:(i=(t=e.featured_image)==null?void 0:t.src)!=null?i:""};if(e!=null&&e.selected_or_first_available_variant){let l=e;return(s=l.selected_or_first_available_variant)!=null&&s.featured_image?this.getImage(l.selected_or_first_available_variant):{src:(r=l.featured_image)!=null?r:l.images[0]}}else if((n=e==null?void 0:e.images)!=null&&n.length){let l=e;return{src:(o=l.featured_image)!=null?o:l.images[0]}}else if(e.hasOwnProperty("src"))return{src:e.src};return null}appendSize(e,t){let i=new URL(e.startsWith("//")?`https://${e}`:e);return t!=null&&t.width&&i.searchParams.set("width",t==null?void 0:t.width.toString()),t!=null&&t.height&&i.searchParams.set("height",t==null?void 0:t.height.toString()),i.href}getVariantUrl(e,t){if(!!e)return t?e+`?variant=${t}`:e}};var ct=class{constructor(){}getFormState({product:e,options:t,autoSelect:i=!1,change:s}){let r=this.getSelectedOptions({product:e,options:t,change:s,autoSelect:i}),n=r&&Object.values(r).every(h=>!!h),o=this.getOptionsWithValues({product:e,selectedOptions:r});return{selectedVariant:this.getVariantByOptions({product:e,options:r}),selectedOptions:r,hasSelection:n,optionsWithValues:o}}getSelectedOptions({product:e,options:t,autoSelect:i,change:s={}}){let r=Object.fromEntries(Object.entries({...t,...s}).map(([d,y],b)=>{var m;return!y&&((m=e.options[b])==null?void 0:m.values.length)===1?[d,e.options[b].values[0]]:[d,y]}));if(!i)return r;i===!0&&(i="unavailable");let n=this.getVariantByOptions({product:e,options:r});if(i==="unavailable"&&n||i==="soldout"&&(n==null?void 0:n.available))return r;let o=Object.keys(s).pop(),l=Object.fromEntries(Object.entries(r).filter(([d])=>!o||d<=o)),h=Object.fromEntries(Object.entries(r).filter(([d])=>!(d in l)));return Object.entries(h).reduce((d,[y,b])=>{var g;let m=this.getAllVariantsByOptions({product:e,options:d});return m.length?{...d,[y]:((g=m.find(w=>w.available))!=null?g:m[0])[y]}:{...d,[y]:null}},l)}getVariantOptions({variant:e}){var t,i,s;return{option1:(t=e==null?void 0:e.option1)!=null?t:null,option2:(i=e==null?void 0:e.option2)!=null?i:null,option3:(s=e==null?void 0:e.option3)!=null?s:null}}getOptionsWithValues({product:e,selectedOptions:t={}}){return e.options.map(i=>{var l;let s=`option${i.position}`,r=this.getUnavailableOptionValues({product:e,optionKey:s,selectedOptions:t,values:i.values}),n=this.getSoldoutOptionValues({product:e,optionKey:s,selectedOptions:t,values:i.values}),o=(l=t==null?void 0:t[s])!=null?l:null;return{...i,selectedValue:o,soldoutValues:n,unavailableValues:r}})}getSoldoutOptionValues({product:e,optionKey:t,values:i,selectedOptions:s={}}){let r=Object.fromEntries(Object.entries(s).filter(([n])=>n<t));return i.filter(n=>{let o=e.variants.filter(l=>this.matchesVariant({variant:l,options:{...r,[t]:n}}));return o.length?o.every(l=>!l.available):!1})}getUnavailableOptionValues({product:e,optionKey:t,values:i,selectedOptions:s={}}){let r=Object.fromEntries(Object.entries(s).filter(([n])=>n<t));return i.filter(n=>e.variants.every(o=>!this.matchesVariant({variant:o,options:{...r,[t]:n}})))}getFirstAvailableVariant({product:e}){var t;return(t=e.variants.find(i=>i.available))!=null?t:null}getSelectedVariant({product:e,selectedVariantId:t}){var i;return(i=e.variants.find(s=>s.id===t))!=null?i:null}matchesVariant({variant:e,options:t}){return(!(t!=null&&t.option1)||t.option1===e.option1)&&(!(t!=null&&t.option2)||t.option2===e.option2)&&(!(t!=null&&t.option3)||t.option3===e.option3)}getFormData({form:e,product:t}){let i=new FormData(e);return{quantity:this.getFormQuantity({form:e}),options:this.getFormOptions({formData:i,product:t})}}getFormQuantity({form:e}){var s;let i=(s=new FormData(e).get("quantity"))==null?void 0:s.toString();return i?parseInt(i):1}getVariantByOptions({product:e,options:t}){var s;let i=Object.entries(t).reduce((r,[,n],o)=>(r[o]=n,r),new Array(3).fill(null));return(s=e.variants.find(r=>i.every((n,o)=>r[`option${o+1}`]===n)))!=null?s:null}getAllVariantsByOptions({product:e,options:t}){var s;let i=Object.entries(t).reduce((r,[,n],o)=>(r[o]=n,r),new Array(3).fill(null));return(s=e.variants.filter(r=>i.every((n,o)=>!n||r[`option${o+1}`]===n)))!=null?s:[]}getFormOptions({formData:e,product:t}){return Array.from(e.entries()).reduce((i,[s,r])=>{var l;let n=(l=s.match(/\[(.*?)\]/))==null?void 0:l[1];if(!n)return i;let o=t.options.findIndex(h=>h.name===n)+1;if(o>0){let h=`option${o}`;i[h]=r.toString()||null}return i},{})}getInputOption({input:e,product:t}){var r;let i=(r=e.name.match(/\[(.*?)\]/))==null?void 0:r[1];if(!i)return null;let s=t.options.findIndex(n=>n.name===i)+1;return s>0?{[`option${s}`]:e.value.toString()}:null}};import{fromEvent as Ye,map as Ze}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var pt=class{constructor(){this.dispatcher=document}publish(e){this.dispatcher.dispatchEvent(new CustomEvent(e.name,{detail:e,bubbles:!1,cancelable:!1}))}subscribe(e,t){return Ye(this.dispatcher,e).pipe(Ze(i=>{let s=i;return{name:s.type,data:s.detail.data}})).subscribe(t)}subscribeMany(e){return Object.entries(e).map(([t,i])=>this.subscribe(t,i))}};var ut=class{constructor({routeUtil:e}){this.subscriber=[],this.routeUtil=e,this.observer=new MutationObserver(t=>{t.reduce((i,s)=>i.concat(Array.from(s.addedNodes)),[]).filter(i=>i instanceof Element&&!i.hasAttribute("data-appmate")).forEach(i=>this.scan(i))}),this.observer.observe(document.body,{subtree:!0,childList:!0,attributes:!1})}watch(e,t){if(!e.pageType&&e.handle)throw new Error("Template required when watching for handle.");let i={target:e,callback:t};this.subscriber.push(i),ie(i,this.routeUtil.parse(window.location.pathname))&&this.scan(document.body)}shouldSkip(e,{skipHidden:t}){return t&&e instanceof HTMLElement?e.offsetParent===null:!1}scan(e){this.subscriber.filter(t=>ie(t,this.routeUtil.parse(window.location.pathname))).forEach(t=>{let i=e.matches(t.target.selector)&&!this.shouldSkip(e,{skipHidden:!!t.target.skipHidden});if(i&&this.notify(t,e),i&&t.target.firstMatch)return;let s=e.querySelectorAll(t.target.selector);for(let r of s)if(!this.shouldSkip(r,{skipHidden:!!t.target.skipHidden})&&(this.notify(t,r),t.target.firstMatch))break})}notify(e,t){if(!t.hasAttribute("data-appmate")){t.setAttribute("data-appmate","");let i=new R(t);e.callback(i)}}};function ie({target:a},e){if(!a.pageType)return!0;if(!e.pageType)return!1;if(a.handle)return a.handle===e.handle;let t=Array.isArray(a.pageType)?a.pageType:[a.pageType];return t.includes("all")?!0:t.includes(e.pageType)}var R=class{constructor(e){this.element=e}replace(e){var t;return(t=this.element)==null||t.replaceWith(e),e}append(e){var t;return(t=this.element)==null||t.append(e),e}prepend(e){var t;return(t=this.element)==null||t.prepend(e),e}insertBefore(e){var t;return(t=this.element)==null||t.before(e),e}insertAfter(e){var t;return(t=this.element)==null||t.after(e),e}closest(e,t=5){if(!this.element)return new R;if(typeof e=="object")return this.searchByStyle(e,this.element,s=>s.parentElement,t);let i=this.element.closest(e);return i?new R(i):new R}find(e){var i;let t=(i=this.element)==null?void 0:i.querySelector(e);return t?new R(t):new R}searchByStyle(e,t,i,s=5){if(s<0||!t)return null;let r=getComputedStyle(t);if(Object.entries(e).every(([l,h])=>r.getPropertyValue(l)===h))return new R(t);let o=i(t);return o?this.searchByStyle(e,o,i,s-1):null}};var dt=class{constructor({routeUtil:e}){this.observer=new ut({routeUtil:e}),this.watch=this.observer.watch.bind(this.observer)}createComponent(e,t){let i=document.createElement(e);return t!=null&&t.dataset&&Object.entries(t==null?void 0:t.dataset).forEach(([s,r])=>{!r||(typeof r=="boolean"?i.dataset[s]="":typeof r=="object"?i.dataset[s]=JSON.stringify(r):i.dataset[s]=r)}),t!=null&&t.props&&Object.entries(t==null?void 0:t.props).forEach(([s,r])=>{i[s]=r}),i}createElement(e,t={},...i){let s=Object.assign(document.createElement(e),t);return i&&s.append(...i),s}};var At=class{constructor({settings:e,stylesheets:t,...i}){this.stylesLoaded=!1;var s,r;this.config=this.parseConfig(i),this.settings={...e,loginRequired:!!e.loginRequired&&!this.config.customer.id},this.events=new pt,this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.utils=this.initUtils(),this.apis={wishlist:new G({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(s=this.config.customer.id)!=null?s:void 0,sessionId:_t(),trackingSource:this.utils.route.parse(window.location.pathname).pageType}),shopify:new K({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new tt({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,sessionId:_t(),utils:this.utils,settings:e})},this.state=new nt({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils}),this.addToCart=(...n)=>A(this.state.addToCart(...n)),this.addAllToCart=(...n)=>A(this.state.addAllToCart(...n)),this.addWishlistItem=(...n)=>A(this.state.addWishlistItem(...n)),this.clearWishlist=(...n)=>A(this.state.clearWishlist(...n)),this.loadProductInfo=(...n)=>A(this.state.loadProductInfo(...n)),this.loadShopifyProduct=(...n)=>A(this.state.loadShopifyProduct(...n)),this.loadWishlist=(...n)=>A(this.state.loadWishlist(...n)),this.loadWishlistItem=(...n)=>A(this.state.loadWishlistItem(...n)),this.loadWishlistProduct=(...n)=>A(this.state.loadWishlistProduct(...n)),this.publishWishlistEvent=(...n)=>A(this.state.publishWishlistEvent(...n)),this.publishWishlistItemEvent=(...n)=>A(this.state.publishWishlistItemEvent(...n)),this.removeWishlistItem=(...n)=>A(this.state.removeWishlistItem(...n)),this.shareWishlist=(...n)=>A(this.state.shareWishlist(...n)),this.updateWishlistItem=(...n)=>A(this.state.updateWishlistItem(...n)),this.initStyles(t),this.initUrlChangeEvents(),this.trackCurrentPage(),requestAnimationFrame(()=>{this.events.publish({name:"wk:app:ready"})})}async initStyles(e){if(!(e!=null&&e.length)){this.onStylesLoaded();return}try{await Promise.all(e.map(t=>new Promise((i,s)=>{let r=document.createElement("link");r.rel="stylesheet",r.href=t,r.onload=i,r.onerror=s,document.head.appendChild(r)}))),this.onStylesLoaded()}catch(t){console.warn(t),this.events.publish({name:"wk:app:load-styles:error"})}}trackCurrentPage(){let e=this.utils.route.parse(window.location.pathname).pageType;if(e!=null&&e.includes("wishlist")){let t=this.utils.url.getWishlistIdFromUrl(window.location.pathname);t&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:t})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success"})}initUtils(){let e=this.config.shop.domain,t=this.config.products.fallbackImage,i=this.config.shop.moneyFormat,s=this.config.locale,r=new at({wishlistUrl:this.routes.wishlistUrl});return{url:new ht({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:e,placeholderImageUrl:t,fileUrl:this.routes.fileUrl}),money:new lt({moneyFormat:i,currencyRate:parseFloat(window.Shopify.currency.rate),activeCurrency:window.Shopify.currency.active}),product:new ct,locale:new ot({locale:s}),route:r,dom:new dt({routeUtil:r})}}initUrlChangeEvents(){let e=history.replaceState,t=({productHandle:i,variantId:s})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:i,variantId:s}})};history.replaceState=(...i)=>{let s=`${window.location.protocol}//${window.location.host}`,r=typeof i[2]=="string"?new URL(i[2],s):i[2],n=e.apply(history,i);if(!r)return n;let o=this.utils.url.getProductHandleFromUrl(r),l=r.searchParams.get("variant");if(!o||!l)return n;t({productHandle:o,variantId:parseInt(l)})}}parseConfig({config:e,locale:t}){var i,s,r,n,o,l,h,c;return{customer:{id:e.customerId?parseInt(e.customerId):null,email:(i=e.customerEmail)!=null?i:""},shop:{name:(s=e.shopName)!=null?s:"",domain:(r=e.shopDomain)!=null?r:"",permanentDomain:(n=e.shopPermanentDomain)!=null?n:"",currency:(o=e.shopCurrency)!=null?o:"",moneyFormat:(l=e.shopMoneyFormat)!=null?l:"",customerAccountsEnabled:e.shopCustomerAccountsEnabled?e.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(h=e.apiHost)!=null?h:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:e.fileUrl},products:{fallbackImage:(c=e.productFallbackImage)!=null?c:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081"},locale:t}}parseRoutes(){var i;let e=this.config.routes.rootUrl,t=(i=this.settings.wishlistPath)!=null?i:"/apps/wishlist";return{rootUrl:e,fileUrl:this.config.routes.fileUrl,wishlistUrl:e+t.split("/").filter(s=>!!s).join("/"),accountUrl:e+"account",accountLoginUrl:e+"account/login",accountLogoutUrl:e+"account/logout",accountRegisterUrl:e+"account/register",accountAddressesUrl:e+"account/addresses",collectionsUrl:e+"collections",allProductsCollectionUrl:e+"collections/all",searchUrl:e+"search",predictiveSearchUrl:e+"search/suggest",cartUrl:e+"cart",cartAddUrl:e+"cart/add",cartChangeUrl:e+"cart/change",cartClearUrl:e+"cart/clear",cartUpdateUrl:e+"cart/update",productRecommendationsUrl:e+"recommendations/products"}}};import{from as si,fromEvent as Et,isObservable as se,of as re}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{filter as ri,first as ne,switchMap as ni,tap as ae}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";import{LitElement as ai}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/+esm";import{state as oi}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/decorators.js/+esm";import{combineLatest as ti,distinctUntilChanged as ei,map as mt,of as ii}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var ft=class{constructor(e){this.stateConfig={loading:"eager"};(this.host=e).addController(this)}get app(){if(!window.WishlistKing)throw new Error("Wishlist King SDK not initialized");return window.WishlistKing}hostConnected(){}hostDisconnected(){}parseStateConfig(e){var t;return{loading:(t=e.loading)!=null?t:"eager",wishlist:this.parseWishlistStateConfig(e),wishlistItem:this.parseWishlistItemStateConfig(e),productInfo:this.parseProductInfoStateConfig(e)}}parseWishlistStateConfig({wishlist:e}){var i;let t=(i=this.host.dataset.wishlistId)!=null?i:"mine";if(!!e)return{format:typeof e=="string"?e:"minimal",params:{wishlistId:t}}}parseWishlistItemStateConfig({wishlistItem:e}){let{wishlistId:t="mine",wishlistItemId:i}=this.host.dataset;if(!(!e||!i))return{params:{wishlistId:t,wishlistItemId:i}}}parseProductInfoStateConfig({productInfo:e}){let{wishlistId:t="mine",productHandle:i,productId:s,variantId:r}=this.host.dataset;if(!!e)return{params:{wishlistId:t,productHandle:i,productId:s?parseInt(s):void 0,variantId:r?parseInt(r):void 0}}}observe(e){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let t=[];if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;t.push(this.app.state.observeWishlist({format:this.stateConfig.wishlist.format,wishlistId:i}).pipe(mt(s=>({wishlist:s}))))}if(this.stateConfig.productInfo){let{productId:i,productHandle:s,variantId:r}=this.stateConfig.productInfo.params;if(!i&&!s)throw new Error("Product id or handle is required");t.push(this.app.state.observeProductInfo({productHandle:s,productId:i,variantId:r,strategy:e}).pipe(mt(n=>({productInfo:n}))))}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:s}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!s)throw new Error("Wishlist item id is required");t.push(this.app.state.observeWishlistItem({wishlistId:i,wishlistItemId:s}).pipe(mt(r=>({wishlistItem:r}))))}return t.length||t.push(ii({})),ti(t).pipe(mt(i=>i.reduce((s,r)=>r.wishlist?{...s,wishlist:r.wishlist}:r.wishlistItem?{...s,wishlistItem:r.wishlistItem}:r.productInfo?{...s,productInfo:r.productInfo}:s,{})),ei((i,s)=>JSON.stringify(i)===JSON.stringify(s)))}getFallback(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e={};if(this.stateConfig.wishlist){let{wishlistId:t="mine"}=this.stateConfig.wishlist.params;e.wishlist={id:t,isMine:t==="mine",numItems:0,items:void 0}}if(this.stateConfig.productInfo){let{productId:t=0,variantId:i=0}=this.stateConfig.productInfo.params;e.productInfo={productId:t,variantId:i,inWishlist:!1}}if(this.stateConfig.wishlistItem){let{wishlistId:t,wishlistItemId:i}=this.stateConfig.wishlistItem.params;if(!t)throw new Error("Wishlist id is required");if(!i)throw new Error("Wishlist item id is required");e.wishlistItem={id:i,product:{id:0,handle:"",hidden:!1}}}return e}};var gt=class extends ai{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.state={};this.stateCtrl=new ft(this)}get app(){return this.stateCtrl.app}static get observedAttributes(){return[...super.observedAttributes,"data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}appReadyCallback(){}beforeNextState(t){}connect(){if(!this.connected){if(!window.WishlistKing){Et(document,"wk:app:ready").pipe(ne()).subscribe(()=>this.connect());return}if(!this.app.stylesLoaded){Et(document,"wk:app:load-styles:success").pipe(ne()).subscribe(()=>this.connect());return}this.connected=!0,this.init(),this.appReadyCallback()}}getStateConfig(){return{}}getTranslation(t){var i;return(i=window.WishlistKing)!=null&&i.utils.locale?window.WishlistKing.utils.locale.translate(t):t}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):this.initState()}updateState(t){var i;this.state={...(i=this.state)!=null?i:{},...t}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML="",this.initEvents(),this.connect()}disconnectedCallback(){var t,i;super.disconnectedCallback(),this.connected=!1,this.cleanupMethods.forEach(s=>s()),(t=this.subscription)==null||t.unsubscribe(),(i=this.observer)==null||i.disconnect()}attributeChangedCallback(t,i,s){super.attributeChangedCallback(t,i,s),this.connected&&this.initState("cache-first")}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(t){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe(t).subscribe(i=>{this.updateState(i)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.updateState(t)}initObserver(){this.observer=new IntersectionObserver(t=>this.handleIntersect(t),{root:null,rootMargin:"0px"}),this.observer.observe(this)}handleIntersect([t]){var i;t.isIntersecting&&((i=this.observer)==null||i.disconnect(),this.initState())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let i=Object.entries(t).map(([s,r])=>{let[n,o]=s.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:o,handler:r})});this.cleanupMethods.push(()=>i.forEach(s=>s.unsubscribe()))}subscribeToEvent({eventName:t,handler:i,selector:s}){return Et(this,t).pipe(ae(r=>{this.eventPending&&r.preventDefault()}),ri(()=>!this.eventPending),ae(()=>{this.eventPending=!0}),ni(r=>{let n=null;if(s&&r.target instanceof HTMLElement&&(n=r.target.closest(s)),s&&!n)return re(null);let o=i.bind(this)(r,s?n:r.currentTarget);return se(o)?o:typeof(o==null?void 0:o.then)=="function"?si(o):re(o)})).subscribe(()=>{this.eventPending=!1})}unlessEventPending(t){let i=()=>this.eventPending=!0,s=()=>this.eventPending=!1;return r=>{if(this.eventPending){t.preventDefault();return}i();let n=r.bind(this)(t);se(n)?n.subscribe(()=>s()):typeof(n==null?void 0:n.then)=="function"?n.then(()=>s()).catch(o=>{throw s(),o}):s()}}};Tt([oi()],gt.prototype,"state",2);export{At as WishlistApp,gt as WishlistElement}; |
{ | ||
"name": "@appmate/wishlist", | ||
"version": "4.14.5", | ||
"version": "4.14.6", | ||
"description": "Wishlist King SDK", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
184877
1339