New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@appmate/wishlist

Package Overview
Dependencies
Maintainers
1
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appmate/wishlist - npm Package Compare versions

Comparing version 4.25.17 to 4.25.18

6

api.js

@@ -1,7 +0,7 @@

var z=Object.create;var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(s,i)=>()=>(i||s((i={exports:{}}).exports,i),i.exports);var Z=(s,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of J(i))!X.call(s,r)&&r!==e&&U(s,r,{get:()=>i[r],enumerable:!(t=G(i,r))||t.enumerable});return s};var ee=(s,i,e)=>(e=s!=null?z(Q(s)):{},Z(i||!s||!s.__esModule?U(e,"default",{value:s,enumerable:!0}):e,s));var q=Y((qe,V)=>{"use strict";var he=function(){function s(e,t){if(typeof e!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+e+"."));this._batchLoadFn=e,this._maxBatchSize=de(t),this._batchScheduleFn=me(t),this._cacheKeyFn=fe(t),this._cacheMap=ge(t),this._batch=null,this.name=ye(t)}var i=s.prototype;return i.load=function(t){if(t==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(t)+"."));var r=pe(this),n=this._cacheMap,a=this._cacheKeyFn(t);if(n){var o=n.get(a);if(o){var c=r.cacheHits||(r.cacheHits=[]);return new Promise(function(p){c.push(function(){p(o)})})}}r.keys.push(t);var l=new Promise(function(p,h){r.callbacks.push({resolve:p,reject:h})});return n&&n.set(a,l),l},i.loadMany=function(t){if(!D(t))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+t+"."));for(var r=[],n=0;n<t.length;n++)r.push(this.load(t[n]).catch(function(a){return a}));return Promise.all(r)},i.clear=function(t){var r=this._cacheMap;if(r){var n=this._cacheKeyFn(t);r.delete(n)}return this},i.clearAll=function(){var t=this._cacheMap;return t&&t.clear(),this},i.prime=function(t,r){var n=this._cacheMap;if(n){var a=this._cacheKeyFn(t);if(n.get(a)===void 0){var o;r instanceof Error?(o=Promise.reject(r),o.catch(function(){})):o=Promise.resolve(r),n.set(a,o)}}return this},s}(),le=typeof process=="object"&&typeof process.nextTick=="function"?function(s){W||(W=Promise.resolve()),W.then(function(){process.nextTick(s)})}:typeof setImmediate=="function"?function(s){setImmediate(s)}:function(s){setTimeout(s)},W;function pe(s){var i=s._batch;if(i!==null&&!i.hasDispatched&&i.keys.length<s._maxBatchSize)return i;var e={hasDispatched:!1,keys:[],callbacks:[]};return s._batch=e,s._batchScheduleFn(function(){ue(s,e)}),e}function ue(s,i){if(i.hasDispatched=!0,i.keys.length===0){A(i);return}var e;try{e=s._batchLoadFn(i.keys)}catch(t){return x(s,i,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(t)+".")))}if(!e||typeof e.then!="function")return x(s,i,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(e)+".")));e.then(function(t){if(!D(t))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(t)+"."));if(t.length!==i.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 ye=Object.create;var J=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty;var W=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var _e=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of we(t))!ve.call(i,s)&&s!==e&&J(i,s,{get:()=>t[s],enumerable:!(r=be(t,s))||r.enumerable});return i};var L=(i,t,e)=>(e=i!=null?ye(Ce(i)):{},_e(t||!i||!i.__esModule?J(e,"default",{value:i,enumerable:!0}):e,i));var X=W((st,Z)=>{var k=1e3,I=k*60,T=I*60,C=T*24,ke=C*7,Ie=C*365.25;Z.exports=function(i,t){t=t||{};var e=typeof i;if(e==="string"&&i.length>0)return Te(i);if(e==="number"&&isFinite(i))return t.long?Se(i):Fe(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function Te(i){if(i=String(i),!(i.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(t){var e=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return e*Ie;case"weeks":case"week":case"w":return e*ke;case"days":case"day":case"d":return e*C;case"hours":case"hour":case"hrs":case"hr":case"h":return e*T;case"minutes":case"minute":case"mins":case"min":case"m":return e*I;case"seconds":case"second":case"secs":case"sec":case"s":return e*k;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Fe(i){var t=Math.abs(i);return t>=C?Math.round(i/C)+"d":t>=T?Math.round(i/T)+"h":t>=I?Math.round(i/I)+"m":t>=k?Math.round(i/k)+"s":i+"ms"}function Se(i){var t=Math.abs(i);return t>=C?M(i,t,C,"day"):t>=T?M(i,t,T,"hour"):t>=I?M(i,t,I,"minute"):t>=k?M(i,t,k,"second"):i+" ms"}function M(i,t,e,r){var s=t>=e*1.5;return Math.round(i/e)+" "+r+(s?"s":"")}});var ee=W((nt,Y)=>{function Pe(i){e.debug=e,e.default=e,e.coerce=d,e.disable=n,e.enable=s,e.enabled=c,e.humanize=X(),e.destroy=m,Object.keys(i).forEach(o=>{e[o]=i[o]}),e.names=[],e.skips=[],e.formatters={};function t(o){let a=0;for(let l=0;l<o.length;l++)a=(a<<5)-a+o.charCodeAt(l),a|=0;return e.colors[Math.abs(a)%e.colors.length]}e.selectColor=t;function e(o){let a,l=null,y,b;function p(...h){if(!p.enabled)return;let f=p,w=Number(new Date),E=w-(a||w);f.diff=E,f.prev=a,f.curr=w,a=w,h[0]=e.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let _=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(N,fe)=>{if(N==="%%")return"%";_++;let z=e.formatters[fe];if(typeof z=="function"){let ge=h[_];N=z.call(f,ge),h.splice(_,1),_--}return N}),e.formatArgs.call(f,h),(f.log||e.log).apply(f,h)}return p.namespace=o,p.useColors=e.useColors(),p.color=e.selectColor(o),p.extend=r,p.destroy=e.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>l!==null?l:(y!==e.namespaces&&(y=e.namespaces,b=e.enabled(o)),b),set:h=>{l=h}}),typeof e.init=="function"&&e.init(p),p}function r(o,a){let l=e(this.namespace+(typeof a=="undefined"?":":a)+o);return l.log=this.log,l}function s(o){e.save(o),e.namespaces=o,e.names=[],e.skips=[];let a,l=(typeof o=="string"?o:"").split(/[\s,]+/),y=l.length;for(a=0;a<y;a++)l[a]&&(o=l[a].replace(/\*/g,".*?"),o[0]==="-"?e.skips.push(new RegExp("^"+o.slice(1)+"$")):e.names.push(new RegExp("^"+o+"$")))}function n(){let o=[...e.names.map(u),...e.skips.map(u).map(a=>"-"+a)].join(",");return e.enable(""),o}function c(o){if(o[o.length-1]==="*")return!0;let a,l;for(a=0,l=e.skips.length;a<l;a++)if(e.skips[a].test(o))return!1;for(a=0,l=e.names.length;a<l;a++)if(e.names[a].test(o))return!0;return!1}function u(o){return o.toString().substring(2,o.toString().length-2).replace(/\.\*\?$/,"*")}function d(o){return o instanceof Error?o.stack||o.message:o}function m(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.enable(e.load()),e}Y.exports=Pe});var O=W((g,U)=>{g.formatArgs=Ae;g.save=Ee;g.load=We;g.useColors=xe;g.storage=Me();g.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();g.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function xe(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Ae(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+U.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;i.splice(1,0,t,"color: inherit");let e=0,r=0;i[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(e++,s==="%c"&&(r=e))}),i.splice(r,0,t)}g.log=console.debug||console.log||(()=>{});function Ee(i){try{i?g.storage.setItem("debug",i):g.storage.removeItem("debug")}catch(t){}}function We(){let i;try{i=g.storage.getItem("debug")}catch(t){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Me(){try{return localStorage}catch(i){}}U.exports=ee()(g);var{formatters:Ue}=U.exports;Ue.j=function(i){try{return JSON.stringify(i)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var he=W((Tt,le)=>{"use strict";var Be=function(){function i(e,r){if(typeof e!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+e+"."));this._batchLoadFn=e,this._maxBatchSize=ze(r),this._batchScheduleFn=Je(r),this._cacheKeyFn=Ge(r),this._cacheMap=Qe(r),this._batch=null,this.name=Ze(r)}var t=i.prototype;return t.load=function(r){if(r==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(r)+"."));var s=$e(this),n=this._cacheMap,c=this._cacheKeyFn(r);if(n){var u=n.get(c);if(u){var d=s.cacheHits||(s.cacheHits=[]);return new Promise(function(o){d.push(function(){o(u)})})}}s.keys.push(r);var m=new Promise(function(o,a){s.callbacks.push({resolve:o,reject:a})});return n&&n.set(c,m),m},t.loadMany=function(r){if(!ue(r))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+r+"."));for(var s=[],n=0;n<r.length;n++)s.push(this.load(r[n]).catch(function(c){return c}));return Promise.all(s)},t.clear=function(r){var s=this._cacheMap;if(s){var n=this._cacheKeyFn(r);s.delete(n)}return this},t.clearAll=function(){var r=this._cacheMap;return r&&r.clear(),this},t.prime=function(r,s){var n=this._cacheMap;if(n){var c=this._cacheKeyFn(r);if(n.get(c)===void 0){var u;s instanceof Error?(u=Promise.reject(s),u.catch(function(){})):u=Promise.resolve(s),n.set(c,u)}}return this},i}(),Ke=typeof process=="object"&&typeof process.nextTick=="function"?function(i){V||(V=Promise.resolve()),V.then(function(){process.nextTick(i)})}:typeof setImmediate=="function"?function(i){setImmediate(i)}:function(i){setTimeout(i)},V;function $e(i){var t=i._batch;if(t!==null&&!t.hasDispatched&&t.keys.length<i._maxBatchSize)return t;var e={hasDispatched:!1,keys:[],callbacks:[]};return i._batch=e,i._batchScheduleFn(function(){He(i,e)}),e}function He(i,t){if(t.hasDispatched=!0,t.keys.length===0){K(t);return}var e;try{e=i._batchLoadFn(t.keys)}catch(r){return B(i,t,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(r)+".")))}if(!e||typeof e.then!="function")return B(i,t,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise: "+String(e)+".")));e.then(function(r){if(!ue(r))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(r)+"."));if(r.length!==t.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys."+(`
Keys:
`+String(i.keys))+(`
`+String(t.keys))+(`
Values:
`+String(t)));A(i);for(var r=0;r<i.callbacks.length;r++){var n=t[r];n instanceof Error?i.callbacks[r].reject(n):i.callbacks[r].resolve(n)}}).catch(function(t){x(s,i,t)})}function x(s,i,e){A(i);for(var t=0;t<i.keys.length;t++)s.clear(i.keys[t]),i.callbacks[t].reject(e)}function A(s){if(s.cacheHits)for(var i=0;i<s.cacheHits.length;i++)s.cacheHits[i]()}function de(s){var i=!s||s.batch!==!1;if(!i)return 1;var e=s&&s.maxBatchSize;if(e===void 0)return 1/0;if(typeof e!="number"||e<1)throw new TypeError("maxBatchSize must be a positive number: "+e);return e}function me(s){var i=s&&s.batchScheduleFn;if(i===void 0)return le;if(typeof i!="function")throw new TypeError("batchScheduleFn must be a function: "+i);return i}function fe(s){var i=s&&s.cacheKeyFn;if(i===void 0)return function(e){return e};if(typeof i!="function")throw new TypeError("cacheKeyFn must be a function: "+i);return i}function ge(s){var i=!s||s.cache!==!1;if(!i)return null;var e=s&&s.cacheMap;if(e===void 0)return new Map;if(e!==null){var t=["get","set","delete","clear"],r=t.filter(function(n){return e&&typeof e[n]!="function"});if(r.length!==0)throw new TypeError("Custom cacheMap missing methods: "+r.join(", "))}return e}function ye(s){return s&&s.name?s.name:null}function D(s){return typeof s=="object"&&s!==null&&typeof s.length=="number"&&(s.length===0||s.length>0&&Object.prototype.hasOwnProperty.call(s,s.length-1))}V.exports=he});import{of as R}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var{gtag:N}=window,w=class{constructor({tracker:i}){this.tracker=i||"t0",this.eventNames=new Map([["addToWishlist","add_to_wishlist"]])}track({eventName:i,product:e,variant:t,quantity:r=1}){var o,c;let n=this.eventNames.get(i);if(!n||!N||!e)return R(!1);let a=(o=t==null?void 0:t.price)!=null?o:e.variants[0].price;return N("event",n,{currency:a,value:t==null?void 0:t.price,items:[{item_id:(c=(t==null?void 0:t.sku)||(t==null?void 0:t.id))!=null?c:e.id,item_name:e.title,affiliation:"Wishlist King",item_category:e.type,item_brand:e.vendor,item_variant:t==null?void 0:t.title,item_quantity:r,item_price:a}]}),R(!0)}};import{of as C}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var _=class{constructor({customerEmail:i,urlUtil:e,moneyUtil:t}){this.customerEmail=i,this.urlUtil=e,this.moneyUtil=t,this.eventNames=new Map([["addToWishlist","Added To Wishlist"],["removeFromWishlist","Removed From Wishlist"],["clearWishlist","Cleared Wishlist"]])}track({eventName:i,wishlist:e,product:t,variant:r,quantity:n=1}){var l,p,h,v,u,f,g,y,b;let a=this.eventNames.get(i);if(!a||!e||!t)return C(!1);let o=e.items.slice().reverse().map($=>$.productId);(l=window.klaviyo)==null||l.push(["identify",{$email:this.customerEmail,WishlistUrl:this.urlUtil.getPublicWishlistUrl(e.id),WishlistProductIDs:o}]);let c=((p=r==null?void 0:r.price)!=null?p:!t.price_varies)?t.price:void 0;return(b=window.klaviyo)==null||b.push(["track",a,{URL:this.urlUtil.getVariantUrl(t.url,r==null?void 0:r.id),Name:t.title,ProductID:t.id,VariantID:(h=r==null?void 0:r.id)!=null?h:null,SKU:(v=r==null?void 0:r.sku)!=null?v:null,Tags:t.tags,Brand:t.vendor,ImageURL:this.urlUtil.getImageUrl((u=r==null?void 0:r.featured_image)!=null&&u.src?r:t,{width:1e3}),Price:c?c/100:null,PriceFormatted:c?this.moneyUtil.formatMoney(c):null,CurrencyCode:(y=(g=(f=window.Shopify)==null?void 0:f.currency)==null?void 0:g.active)!=null?y:null,Quantity:n,WishlistUrl:this.urlUtil.getPublicWishlistUrl(e.id),WishlistProductIDs:o}]),C(!0)}};import{of as L}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var{fbq:O}=window,T=class{constructor({currency:i}){this.currency=i,this.eventNames=new Map([["addToWishlist","AddToWishlist"]])}track({eventName:i,product:e,variant:t}){let r=this.eventNames.get(i);return!r||typeof O!="function"||!e?L(!1):(O("track",r,{value:t==null?void 0:t.price,currency:this.currency,content_ids:[e.id],content_name:[e.title,t==null?void 0:t.title].filter(n=>!!n).join(" - "),content_category:e.type,content_type:"product_group",num_items:1}),L(!0))}};import{catchError as te,from as ie,map as re,of as S}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var m=class{constructor({host:i,shop:e,sessionId:t,customerId:r}){this.host=i,this.shop=e,this.customerId=r,this.sessionId=t,this.eventNames=new Map([["viewWishlist","wishlist_viewed"],["addToCart","product_added_to_cart"],["shareWishlist","wishlist_shared"]])}setSessionId(i){this.sessionId=i}track({eventName:i,wishlist:e,product:t,variant:r,quantity:n,source:a}){var c,l;if(!this.sessionId)return S(!1);let o=this.eventNames.get(i);return!o||!e?S(!1):ie(window.fetch(this.host+"/notify",{method:"POST",headers:{"content-type":"application/json","x-appmate-shp":this.shop,"x-appmate-sid":(c=this.sessionId)!=null?c:"","x-appmate-cid":(l=this.customerId)!=null?l:""},body:JSON.stringify({event:o,wid:e.publicId,pid:t==null?void 0:t.id,vid:r==null?void 0:r.id,qty:n,src:a})})).pipe(re(()=>!0),te(()=>S(!1)))}getQuerystring(i){if(!i)return"";let e=new URLSearchParams;return Object.entries(i).forEach(([t,r])=>{Array.isArray(r)?r.forEach(n=>e.append(t,n)):r&&e.append(t,r)}),"?"+e.toString()}};import{from as se,switchMap as ne}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var d=class{constructor(i){this.host=i.host,this.headers={"content-type":"application/json"}}fetch({path:i,method:e="GET",query:t,body:r,headers:n={}}){return se(window.fetch(this.host+i+this.getQuerystring(t),{method:e,headers:{...this.headers,...n},body:r})).pipe(ne(a=>{if(a.ok)return a.json();throw Error(`Error ${a.status}`)}))}getQuerystring(i){if(!i)return"";let e=new URLSearchParams;return Object.entries(i).forEach(([t,r])=>{Array.isArray(r)?r.forEach(n=>e.append(t,n)):r&&e.append(t,r)}),"?"+e.toString()}get({path:i,query:e,headers:t}){return this.fetch({method:"GET",path:i,query:e,headers:t})}post({path:i,query:e,body:t,headers:r}){return this.fetch({method:"POST",path:i,query:e,body:t?JSON.stringify(t):void 0,headers:r})}put({path:i,query:e,body:t,headers:r}){return this.fetch({method:"PUT",path:i,query:e,body:t?JSON.stringify(t):void 0,headers:r})}delete({path:i,query:e,body:t,headers:r}){return this.fetch({method:"DELETE",path:i,query:e,body:t?JSON.stringify(t):void 0,headers:r})}};import{shareReplay as j,tap as F}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var k=class extends d{constructor(){super(...arguments);this.pendingProducts=new Map}loadProduct({productHandle:e}){let t=`/products/${e}.js`,r=this.pendingProducts.get(t);if(r)return r;let n=this.get({path:t}).pipe(F(()=>{this.pendingProducts.delete(t)}),j());return this.pendingProducts.set(t,n),n}loadCart(){if(this.pendingCart)return this.pendingCart;let e=this.get({path:"/cart.js"}).pipe(F(()=>{this.pendingCart=void 0}),j());return this.pendingCart=e,e}addToCart(e){return this.post({path:"/cart/add.js",body:e})}};import{forkJoin as ae,lastValueFrom as oe,of as ce}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var P=class{constructor({settings:i,events:e,notifyHost:t,utils:r,theme:n,shop:a,sessionId:o,customerId:c,customerEmail:l}){this.utils=r,this.theme=n,this.services=[],i.integrations.wishlistAnalytics.enabled&&this.services.push(new m({host:t,shop:a,customerId:c,sessionId:o})),i.integrations.klaviyo.enabled&&l&&this.services.push(new _({urlUtil:this.utils.url,moneyUtil:this.utils.money,customerEmail:l})),i.integrations.metaPixel.enabled&&this.services.push(new T({currency:window.Shopify.currency.active})),i.integrations.googleAnalytics.enabled&&this.services.push(new w({tracker:i.integrations.googleAnalytics.tracker}));let p=this.theme.getPageType(),h=v=>u=>{var f,g,y,b;return oe(this.track({eventName:v,source:p,wishlist:(f=u.data)==null?void 0:f.wishlist,product:(g=u.data)==null?void 0:g.product,variant:(y=u.data)==null?void 0:y.variant,quantity:(b=u.data)==null?void 0:b.quantity}))};e.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(i){return this.services.length?ae(this.services.map(e=>e.track(i))):ce([])}setSessionId(i){let e=this.services.find(t=>t instanceof m);e&&e.setSessionId(i)}};var E=ee(q());import{defer as B,from as K,lastValueFrom as H,shareReplay as I,switchMap as be,tap as we}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var M=class extends d{constructor(e){super(e);this.productMetafields=!1;this.headers={"content-type":"application/json","x-appmate-api":"2022-11"},e.shop&&(this.headers["x-appmate-shp"]=e.shop),e.sessionId&&(this.headers["x-appmate-sid"]=e.sessionId),e.customerId&&(this.headers["x-appmate-cid"]=e.customerId.toString()),e.trackingSource&&(this.headers["x-appmate-src"]=e.trackingSource),this.productMetafields=!!e.productMetafields,this.wishlistLoader=this.createWishlistLoader(),this.wishlistItemLoader=this.createWishlistItemLoader()}get hasSession(){return!!this.headers["x-appmate-sid"]||!!this.headers["x-appmate-cid"]}get hasCustomer(){return!!this.headers["x-appmate-cid"]}setSessionId(e){this.headers["x-appmate-sid"]=e}createWishlistLoader(){return new E.default(async e=>{let t=await Promise.all(e.map(r=>H(this.get({path:`/wishlists/${r}`})))).then(r=>r.map(n=>n.wishlist));return e.map(r=>{var n;return(n=t.find(a=>r==="mine"?a.isMine:a.publicId===r))!=null?n:new Error("Wishlist not found")})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}createWishlistItemLoader(){return new E.default(async e=>{let t=e.map(n=>n.split("-")).reduce((n,[a,o])=>(n[a]||(n[a]=[]),n[a].push(o),n),{}),r=await Promise.all(Object.entries(t).map(([n,a])=>H(this.get({path:`/wishlists/${n}/items`,headers:{"x-appmate-ids":a.join(","),...this.productMetafields?{"x-appmate-pmf":!0}:{}}})))).then(n=>n.flatMap(a=>a.items));return e.map(n=>{var o;let[,a]=n.split("-");return(o=r.find(c=>c.id===a))!=null?o:new Error("Wishlist item not found")})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}loadWishlist({wishlistId:e}){return K(B(()=>this.wishlistLoader.load(e).then(t=>({wishlist:t}))))}loadWishlistItem({wishlistId:e,wishlistItemId:t}){return K(B(()=>this.wishlistItemLoader.load([e,t].join("-")).then(({selectedVariantId:r,...n})=>({wishlistItem:n}))))}addItem({productId:e,variantId:t}){if(typeof e=="string"&&(e=parseInt(e)),typeof t=="string"&&(t=parseInt(t)),!this.hasSession&&this._pendingSessionId)return this._pendingSessionId.pipe(be(()=>this.addItem({productId:e,variantId:t})));let r=this.post({path:"/wishlists/mine/items",body:{productId:e,variantId:t}}).pipe(we(n=>{n.sessionId&&(this.setSessionId(n.sessionId),this._pendingSessionId=void 0)}),I());return this.hasSession||(this._pendingSessionId=r),r}updateItem({wishlistItemId:e,changes:t}){return this.put({path:"/wishlists/mine/items",body:{changes:{...t,wishlistItemId:e}}}).pipe(I())}removeItem({wishlistId:e,wishlistItemId:t}){return this.delete({path:`/wishlists/${e}/items`,body:{wishlistItemId:t}}).pipe(I())}clearWishlist(){return this.delete({path:"/wishlists/mine"}).pipe(I())}};export{w as GoogleAnalytics,_ as KlaviyoTracking,T as MetaPixel,m as NotifyApi,d as RestApi,k as ShopifyApi,P as TrackingApi,M as WishlistApi};
`+String(r)));K(t);for(var s=0;s<t.callbacks.length;s++){var n=r[s];n instanceof Error?t.callbacks[s].reject(n):t.callbacks[s].resolve(n)}}).catch(function(r){B(i,t,r)})}function B(i,t,e){K(t);for(var r=0;r<t.keys.length;r++)i.clear(t.keys[r]),t.callbacks[r].reject(e)}function K(i){if(i.cacheHits)for(var t=0;t<i.cacheHits.length;t++)i.cacheHits[t]()}function ze(i){var t=!i||i.batch!==!1;if(!t)return 1;var e=i&&i.maxBatchSize;if(e===void 0)return 1/0;if(typeof e!="number"||e<1)throw new TypeError("maxBatchSize must be a positive number: "+e);return e}function Je(i){var t=i&&i.batchScheduleFn;if(t===void 0)return Ke;if(typeof t!="function")throw new TypeError("batchScheduleFn must be a function: "+t);return t}function Ge(i){var t=i&&i.cacheKeyFn;if(t===void 0)return function(e){return e};if(typeof t!="function")throw new TypeError("cacheKeyFn must be a function: "+t);return t}function Qe(i){var t=!i||i.cache!==!1;if(!t)return null;var e=i&&i.cacheMap;if(e===void 0)return new Map;if(e!==null){var r=["get","set","delete","clear"],s=r.filter(function(n){return e&&typeof e[n]!="function"});if(s.length!==0)throw new TypeError("Custom cacheMap missing methods: "+s.join(", "))}return e}function Ze(i){return i&&i.name?i.name:null}function ue(i){return typeof i=="object"&&i!==null&&typeof i.length=="number"&&(i.length===0||i.length>0&&Object.prototype.hasOwnProperty.call(i,i.length-1))}le.exports=Be});import{of as G}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var{gtag:Q}=window,S=class{constructor({tracker:t}){this.tracker=t||"t0",this.eventNames=new Map([["addToWishlist","add_to_wishlist"]])}track({eventName:t,product:e,variant:r,quantity:s=1}){var u,d;let n=this.eventNames.get(t);if(!n||!Q||!e)return G(!1);let c=(u=r==null?void 0:r.price)!=null?u:e.variants[0].price;return Q("event",n,{currency:c,value:r==null?void 0:r.price,items:[{item_id:(d=(r==null?void 0:r.sku)||(r==null?void 0:r.id))!=null?d:e.id,item_name:e.title,affiliation:"Wishlist King",item_category:e.type,item_brand:e.vendor,item_variant:r==null?void 0:r.title,item_quantity:s,item_price:c}]}),G(!0)}};var ie=L(O());import{of as te}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var re=(0,ie.default)("wk:tracking:klaviyo"),P=class{constructor({customerEmail:t,urlUtil:e,moneyUtil:r}){this.customerEmail=t,this.urlUtil=e,this.moneyUtil=r,this.eventNames=new Map([["addToWishlist","Added To Wishlist"],["removeFromWishlist","Removed From Wishlist"],["clearWishlist","Cleared Wishlist"]])}track({eventName:t,wishlist:e,product:r,variant:s,quantity:n=1}){var a,l,y,b,p,h,f,w,E;let c=this.eventNames.get(t);if(!c||!e||!r)return te(!1);let u=e.items.slice().reverse().map(_=>_.productId),d={$email:this.customerEmail,WishlistUrl:this.urlUtil.getPublicWishlistUrl(e.id),WishlistProductIDs:u};re("Identify",d),(a=window.klaviyo)==null||a.push(["identify",d]);let m=((l=s==null?void 0:s.price)!=null?l:!r.price_varies)?r.price:void 0,o={URL:this.urlUtil.getVariantUrl(r.url,s==null?void 0:s.id),Name:r.title,ProductID:r.id,VariantID:(y=s==null?void 0:s.id)!=null?y:null,SKU:(b=s==null?void 0:s.sku)!=null?b:null,Tags:r.tags,Brand:r.vendor,ImageURL:this.urlUtil.getImageUrl((p=s==null?void 0:s.featured_image)!=null&&p.src?s:r,{width:1e3}),Price:m?m/100:null,PriceFormatted:m?this.moneyUtil.formatMoney(m):null,CurrencyCode:(w=(f=(h=window.Shopify)==null?void 0:h.currency)==null?void 0:f.active)!=null?w:null,Quantity:n,WishlistUrl:this.urlUtil.getPublicWishlistUrl(e.id),WishlistProductIDs:u};return re("Track",c,o),(E=window.klaviyo)==null||E.push(["track",c,o]),te(!0)}};import{of as se}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var{fbq:ne}=window,x=class{constructor({currency:t}){this.currency=t,this.eventNames=new Map([["addToWishlist","AddToWishlist"]])}track({eventName:t,product:e,variant:r}){let s=this.eventNames.get(t);return!s||typeof ne!="function"||!e?se(!1):(ne("track",s,{value:r==null?void 0:r.price,currency:this.currency,content_ids:[e.id],content_name:[e.title,r==null?void 0:r.title].filter(n=>!!n).join(" - "),content_category:e.type,content_type:"product_group",num_items:1}),se(!0))}};import{catchError as Re,from as Ne,map as Le,of as j}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var F=class{constructor({host:t,shop:e,sessionId:r,customerId:s}){this.host=t,this.shop=e,this.customerId=s,this.sessionId=r,this.eventNames=new Map([["viewWishlist","wishlist_viewed"],["addToCart","product_added_to_cart"],["shareWishlist","wishlist_shared"]])}setSessionId(t){this.sessionId=t}track({eventName:t,wishlist:e,product:r,variant:s,quantity:n,source:c}){var d,m;if(!this.sessionId)return j(!1);let u=this.eventNames.get(t);return!u||!e?j(!1):Ne(window.fetch(this.host+"/notify",{method:"POST",headers:{"content-type":"application/json","x-appmate-shp":this.shop,"x-appmate-sid":(d=this.sessionId)!=null?d:"","x-appmate-cid":(m=this.customerId)!=null?m:""},body:JSON.stringify({event:u,wid:e.publicId,pid:r==null?void 0:r.id,vid:s==null?void 0:s.id,qty:n,src:c})})).pipe(Le(()=>!0),Re(()=>j(!1)))}getQuerystring(t){if(!t)return"";let e=new URLSearchParams;return Object.entries(t).forEach(([r,s])=>{Array.isArray(s)?s.forEach(n=>e.append(r,n)):s&&e.append(r,s)}),"?"+e.toString()}};import{from as Oe,switchMap as je}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var v=class{constructor(t){this.host=t.host,this.headers={"content-type":"application/json"}}fetch({path:t,method:e="GET",query:r,body:s,headers:n={}}){return Oe(window.fetch(this.host+t+this.getQuerystring(r),{method:e,headers:{...this.headers,...n},body:s})).pipe(je(c=>{if(c.ok)return c.json();throw Error(`Error ${c.status}`)}))}getQuerystring(t){if(!t)return"";let e=new URLSearchParams;return Object.entries(t).forEach(([r,s])=>{Array.isArray(s)?s.forEach(n=>e.append(r,n)):s&&e.append(r,s)}),"?"+e.toString()}get({path:t,query:e,headers:r}){return this.fetch({method:"GET",path:t,query:e,headers:r})}post({path:t,query:e,body:r,headers:s}){return this.fetch({method:"POST",path:t,query:e,body:r?JSON.stringify(r):void 0,headers:s})}put({path:t,query:e,body:r,headers:s}){return this.fetch({method:"PUT",path:t,query:e,body:r?JSON.stringify(r):void 0,headers:s})}delete({path:t,query:e,body:r,headers:s}){return this.fetch({method:"DELETE",path:t,query:e,body:r?JSON.stringify(r):void 0,headers:s})}};import{shareReplay as oe,tap as ae}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var D=class extends v{constructor(){super(...arguments);this.pendingProducts=new Map}loadProduct({productHandle:e}){let r=`/products/${e}.js`,s=this.pendingProducts.get(r);if(s)return s;let n=this.get({path:r}).pipe(ae(()=>{this.pendingProducts.delete(r)}),oe());return this.pendingProducts.set(r,n),n}loadCart(){if(this.pendingCart)return this.pendingCart;let e=this.get({path:"/cart.js"}).pipe(ae(()=>{this.pendingCart=void 0}),oe());return this.pendingCart=e,e}addToCart(e){return this.post({path:"/cart/add.js",body:e})}};var ce=L(O());import{forkJoin as De,lastValueFrom as qe,of as Ve}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var A=(0,ce.default)("wk:tracking"),q=class{constructor({settings:t,events:e,notifyHost:r,utils:s,theme:n,shop:c,sessionId:u,customerId:d,customerEmail:m}){this.utils=s,this.theme=n,this.services=[],A("Init tracking"),t.integrations.wishlistAnalytics.enabled&&this.services.push(new F({host:r,shop:c,customerId:d,sessionId:u})),t.integrations.klaviyo.enabled&&m&&(A("Add Klaviyo integration"),this.services.push(new P({urlUtil:this.utils.url,moneyUtil:this.utils.money,customerEmail:m}))),t.integrations.metaPixel.enabled&&(A("Add Meta Pixel integration"),this.services.push(new x({currency:window.Shopify.currency.active}))),t.integrations.googleAnalytics.enabled&&(A("Add Google Analytics integration"),this.services.push(new S({tracker:t.integrations.googleAnalytics.tracker})));let o=this.theme.getPageType(),a=l=>y=>{var b,p,h,f;return qe(this.track({eventName:l,source:o,wishlist:(b=y.data)==null?void 0:b.wishlist,product:(p=y.data)==null?void 0:p.product,variant:(h=y.data)==null?void 0:h.variant,quantity:(f=y.data)==null?void 0:f.quantity}))};e.subscribeMany({"wk:wishlist:add-to-cart:success":a("addToCart"),"wk:wishlist:add:success":a("addToWishlist"),"wk:wishlist:change-variant:success":a("changeVariant"),"wk:wishlist:clear:success":a("clearWishlist"),"wk:wishlist:remove:success":a("removeFromWishlist"),"wk:wishlist:share:success":a("shareWishlist"),"wk:wishlist:page-view":a("viewWishlist")})}track(t){return A("Track",t),this.services.length?De(this.services.map(e=>e.track(t))):Ve([])}setSessionId(t){let e=this.services.find(r=>r instanceof F);e&&e.setSessionId(t)}};var $=L(he());import{defer as de,from as pe,lastValueFrom as me,shareReplay as R,switchMap as Xe,tap as Ye}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var H=class extends v{constructor(e){super(e);this.productMetafields=!1;this.headers={"content-type":"application/json","x-appmate-api":"2022-11"},e.shop&&(this.headers["x-appmate-shp"]=e.shop),e.sessionId&&(this.headers["x-appmate-sid"]=e.sessionId),e.customerId&&(this.headers["x-appmate-cid"]=e.customerId.toString()),e.trackingSource&&(this.headers["x-appmate-src"]=e.trackingSource),this.productMetafields=!!e.productMetafields,this.wishlistLoader=this.createWishlistLoader(),this.wishlistItemLoader=this.createWishlistItemLoader()}get hasSession(){return!!this.headers["x-appmate-sid"]||!!this.headers["x-appmate-cid"]}get hasCustomer(){return!!this.headers["x-appmate-cid"]}setSessionId(e){this.headers["x-appmate-sid"]=e}createWishlistLoader(){return new $.default(async e=>{let r=await Promise.all(e.map(s=>me(this.get({path:`/wishlists/${s}`})))).then(s=>s.map(n=>n.wishlist));return e.map(s=>{var n;return(n=r.find(c=>s==="mine"?c.isMine:c.publicId===s))!=null?n:new Error("Wishlist not found")})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}createWishlistItemLoader(){return new $.default(async e=>{let r=e.map(n=>n.split("-")).reduce((n,[c,u])=>(n[c]||(n[c]=[]),n[c].push(u),n),{}),s=await Promise.all(Object.entries(r).map(([n,c])=>me(this.get({path:`/wishlists/${n}/items`,headers:{"x-appmate-ids":c.join(","),...this.productMetafields?{"x-appmate-pmf":!0}:{}}})))).then(n=>n.flatMap(c=>c.items));return e.map(n=>{var u;let[,c]=n.split("-");return(u=s.find(d=>d.id===c))!=null?u:new Error("Wishlist item not found")})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}loadWishlist({wishlistId:e}){return pe(de(()=>this.wishlistLoader.load(e).then(r=>({wishlist:r}))))}loadWishlistItem({wishlistId:e,wishlistItemId:r}){return pe(de(()=>this.wishlistItemLoader.load([e,r].join("-")).then(({selectedVariantId:s,...n})=>({wishlistItem:n}))))}addItem({productId:e,variantId:r}){if(typeof e=="string"&&(e=parseInt(e)),typeof r=="string"&&(r=parseInt(r)),!this.hasSession&&this._pendingSessionId)return this._pendingSessionId.pipe(Xe(()=>this.addItem({productId:e,variantId:r})));let s=this.post({path:"/wishlists/mine/items",body:{productId:e,variantId:r}}).pipe(Ye(n=>{n.sessionId&&(this.setSessionId(n.sessionId),this._pendingSessionId=void 0)}),R());return this.hasSession||(this._pendingSessionId=s),s}updateItem({wishlistItemId:e,changes:r}){return this.put({path:"/wishlists/mine/items",body:{changes:{...r,wishlistItemId:e}}}).pipe(R())}removeItem({wishlistId:e,wishlistItemId:r}){return this.delete({path:`/wishlists/${e}/items`,body:{wishlistItemId:r}}).pipe(R())}clearWishlist(){return this.delete({path:"/wishlists/mine"}).pipe(R())}};export{S as GoogleAnalytics,P as KlaviyoTracking,x as MetaPixel,F as NotifyApi,v as RestApi,D as ShopifyApi,q as TrackingApi,H as WishlistApi};

@@ -1,2 +0,2 @@

import{LitElement as h,html as o}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as u}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/components/counter.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/components/icon.js";var l=class extends h{constructor(){super(...arguments);this.text="";this.hint="";this.selected=!1;this.disabled=!1;this.showIcon=!1;this.showText=!1;this.iconUnstyled=!1;this.fullWidth=!1;this.alignSelf="center";this.alignContent="center";this.floatingUi=new u(this);this.getCounterFloating=()=>{var i,e,n,r;if(!((i=this.counter)!=null&&i.floating))return;let t=((n=(e=this.counter)==null?void 0:e.floating)==null?void 0:n.reference)==="icon"?(r=this.iconElement)!=null?r:this:this;return{...this.counter.floating,reference:t}}}get iconElement(){return this.querySelector(".wk-icon")}render(){var n,r,s,a;let t=(n=this.alignSelf)!=null?n:"center",i=(r=this.alignContent)!=null?r:"center",e=["wk-button",`wk-align-${t}`,`wk-align-content-${i}`,this.selected&&"wk-selected",this.fullWidth&&"wk-full-width"].filter(c=>!!c).join(" ");return this.href?o`
import{LitElement as h,html as o}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as u}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/components/counter.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/components/icon.js";var l=class extends h{constructor(){super(...arguments);this.text="";this.hint="";this.selected=!1;this.disabled=!1;this.showIcon=!1;this.showText=!1;this.iconUnstyled=!1;this.fullWidth=!1;this.alignSelf="center";this.alignContent="center";this.floatingUi=new u(this);this.getCounterFloating=()=>{var i,e,n,r;if(!((i=this.counter)!=null&&i.floating))return;let t=((n=(e=this.counter)==null?void 0:e.floating)==null?void 0:n.reference)==="icon"?(r=this.iconElement)!=null?r:this:this;return{...this.counter.floating,reference:t}}}get iconElement(){return this.querySelector(".wk-icon")}render(){var n,r,s,a;let t=(n=this.alignSelf)!=null?n:"center",i=(r=this.alignContent)!=null?r:"center",e=["wk-button",`wk-align-${t}`,`wk-align-content-${i}`,this.selected&&"wk-selected",this.fullWidth&&"wk-full-width"].filter(c=>!!c).join(" ");return this.href?o`
<a

@@ -3,0 +3,0 @@ href=${this.href}

@@ -1,1 +0,1 @@

import{LitElement as s,html as a}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as l}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/controllers.js";var t=class extends s{constructor(){super(...arguments);this.value=0;this.showNumber=!1;this.showBrackets=!1;this.floatingUi=new l(this)}render(){let e=this.showNumber?this.value:"",o=["wk-counter",this.showBrackets&&"wk-brackets",this.floating&&"wk-bubble",this.floating&&!this.showNumber&&"wk-dot"].filter(r=>!!r).join(" ");return a`<span class=${o}>${e}</span>`}createRenderRoot(){return this}};t.properties={value:{type:Number},floating:{type:Object},showNumber:{type:Boolean,attribute:"show-number"},showBrackets:{type:Boolean,attribute:"show-brackets"}};customElements.get("wk-counter")||customElements.define("wk-counter",t);export{t as Counter};
import{LitElement as s,html as a}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as l}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/controllers.js";var t=class extends s{constructor(){super(...arguments);this.value=0;this.showNumber=!1;this.showBrackets=!1;this.floatingUi=new l(this)}render(){let e=this.showNumber?this.value:"",o=["wk-counter",this.showBrackets&&"wk-brackets",this.floating&&"wk-bubble",this.floating&&!this.showNumber&&"wk-dot"].filter(r=>!!r).join(" ");return a`<span class=${o}>${e}</span>`}createRenderRoot(){return this}};t.properties={value:{type:Number},floating:{type:Object},showNumber:{type:Boolean,attribute:"show-number"},showBrackets:{type:Boolean,attribute:"show-brackets"}};customElements.get("wk-counter")||customElements.define("wk-counter",t);export{t as Counter};

@@ -1,2 +0,2 @@

import{LitElement as l,html as s}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{Icon as a}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/components/icon.js";var i=class extends l{constructor(){super();this.icon="caret"}get app(){if(!window.WishlistKing)throw new Error("Wishlist King SDK not initialized");return window.WishlistKing}render(){if(!this.option)return;let t=this.option,e=`options[${this.option.name}]`,n=`${this.app.utils.url.handlelize(this.id)}-select`;return s`
import{LitElement as l,html as s}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{Icon as a}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/components/icon.js";var i=class extends l{constructor(){super();this.icon="caret"}get app(){if(!window.WishlistKing)throw new Error("Wishlist King SDK not initialized");return window.WishlistKing}render(){if(!this.option)return;let t=this.option,e=`options[${this.option.name}]`,n=`${this.app.utils.url.handlelize(this.id)}-select`;return s`
<div class="wk-option-select">

@@ -3,0 +3,0 @@ <label class="wk-label" for=${n}>${t.name}</label>

@@ -1,2 +0,2 @@

import{LitElement as s,html as o}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as r}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/controllers.js";var n=class extends s{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1;this.floatingUi=new r(this)}get added(){return!!this.parentElement}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}render(){var e;let t=["wk-popover",this.transition?`wk-${this.transition}`:"",this.elementClass].filter(i=>!!i).join(" ");return o`
import{LitElement as s,html as o}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as r}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/controllers.js";var n=class extends s{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1;this.floatingUi=new r(this)}get added(){return!!this.parentElement}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}render(){var e;let t=["wk-popover",this.transition?`wk-${this.transition}`:"",this.elementClass].filter(i=>!!i).join(" ");return o`
<div class=${t}>

@@ -3,0 +3,0 @@ <div class="wk-text">${this.getText()}</div>

{
"name": "@appmate/wishlist",
"version": "4.25.17",
"version": "4.25.18",
"description": "Wishlist King SDK",

@@ -5,0 +5,0 @@ "main": "wishlist-app.js",

@@ -1,1 +0,1 @@

var x=(a=21)=>crypto.getRandomValues(new Uint8Array(a)).reduce((t,e)=>(e&=63,e<36?t+=e.toString(36):e<62?t+=(e-26).toString(36).toUpperCase():e>62?t+="-":t+="_",t),"");var c=class{constructor(t){this.element=t}replace(t){var e;return(e=this.element)==null||e.replaceWith(t),t}append(t){var e;return(e=this.element)==null||e.append(t),t}prepend(t){var e;return(e=this.element)==null||e.prepend(t),t}insertBefore(t){var e;return(e=this.element)==null||e.before(t),t}insertAfter(t){var e;return(e=this.element)==null||e.after(t),t}closest(t,e=5){if(!this.element)return new c;if(typeof t=="object")return this.searchByStyle(t,this.element,i=>i.parentElement,e);let s=this.element.closest(t);return s?new c(s):new c}find(t){var s;let e=(s=this.element)==null?void 0:s.querySelector(t);return e?new c(e):new c}searchByStyle(t,e,s,i=5){if(i<0||!e)return null;let r=getComputedStyle(e);if(Object.entries(t).every(([l,h])=>r.getPropertyValue(l)===h))return new c(e);let n=s(e);return n?this.searchByStyle(t,n,s,i-1):null}};var u=class{constructor({routeUtil:t}){this.subscriber=[],this.routeUtil=t,this.observer=new MutationObserver(e=>{e.reduce((s,i)=>s.concat(Array.from(i.addedNodes)),[]).filter(s=>s instanceof Element&&!s.hasAttribute("wk-skip")).forEach(s=>{s instanceof Element&&this.scan(s)})}),this.observer.observe(document,{subtree:!0,childList:!0,attributes:!1})}watch(t,e){let s={target:t,callback:e};this.subscriber.push(s),D(s,this.routeUtil.parse(window.location.pathname))&&this.scan(document)}shouldSkip(t,{skipHidden:e}){return e&&t instanceof HTMLElement?t.offsetParent===null:!1}scan(t){t&&this.subscriber.filter(e=>D(e,this.routeUtil.parse(window.location.pathname))).forEach(e=>{let s=t instanceof Element&&t.matches(e.target.selector)&&!this.shouldSkip(t,{skipHidden:!!e.target.skipHidden});if(s&&this.notify(e,t),s&&e.target.firstMatch)return;let i=t.querySelectorAll(e.target.selector);for(let r of i)if(!this.shouldSkip(r,{skipHidden:!!e.target.skipHidden})&&(this.notify(e,r),e.target.firstMatch))break})}notify(t,e){if(!e.hasAttribute("wk-skip")){e.setAttribute("wk-skip","");let s=new c(e);t.callback(s)}}};function D({target:a},t){if(!a.pageType)return!0;if(!t.pageType)return!1;let e=Array.isArray(a.pageType)?a.pageType:[a.pageType];return e.includes("all")?!0:e.includes(t.pageType)}var N=[{pageType:"product",match:a=>a.includes("/products/")},{pageType:"collection",match:a=>a.includes("/collections/")&&!a.includes("/products/")},{pageType:"account",match:a=>a.includes("/account/")||a.endsWith("/account")},{pageType:"challenge",match:a=>a.endsWith("/account")},{pageType:"blog",match:a=>a.includes("/blog/")},{pageType:"cart",match:a=>a.includes("/cart/")||a.endsWith("/cart")},{pageType:"wishlist",match:(a,{wishlistUrl:t})=>a.includes(t)},{pageType:"page",match:a=>a.includes("/pages/")},{pageType:"search",match:a=>a.includes("/search")},{pageType:"home",match:a=>a.length<4}],g=class{constructor({wishlistUrl:t}){this.wishlistUrl=t}parse(t){for(let e of N)if(e.match(t,{wishlistUrl:this.wishlistUrl}))return{pageType:e.pageType};return{pageType:"unknown"}}};var w=class{constructor(t){this.locale={};var e;this.initLocale((e=t==null?void 0:t.locale)!=null?e:{})}initLocale(t){this.locale=this.decodeLocale(t)}decodeHtmlEntities(t){return t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/g,"'")}decodeLocale(t){let e={};for(let s in t){e[s]={};for(let i in t[s])e[s][i]=this.decodeHtmlEntities(t[s][i])}return e}translate(t,e){var o;let[s,i]=t.split("."),r=(o=this.locale[s])==null?void 0:o[i];return r?e?Object.entries(e).reduce((n,[l,h])=>n.replace(new RegExp(`{{\\s*${l}\\s*}}`,"g"),h),r):r:`translation missing: ${t}`}};var m=class{constructor({rootUrl:t,wishlistUrl:e}){this._rootUrl=t,this.route=new g({wishlistUrl:e}),this.observer=new u({routeUtil:this.route}),this.locale=new w,this.watch=this.observer.watch.bind(this.observer)}getPageType(t=window.location.pathname){return this.route.parse(t).pageType}getWishlistId(t){if(!t)return null;t instanceof URL&&(t=t.pathname);let e=t.replace(this._rootUrl,"/").split("/");return e.length===4?e.pop():"mine"}getProductHandle(t){var e;return t?(t instanceof URL&&(t=t.pathname),(e=t.split("/").pop())==null?void 0:e.split("?")[0]):null}getVariantId(t,e){var i;let s=null;if(t&&(t instanceof URL&&(t=t.pathname),s=new URLSearchParams(t.split("?")[1]).get("variant")),!s&&e)try{s=new FormData((i=e.element)!=null?i:e).get("id")}catch(r){console.warn("Failed to parse variant from product form.",r)}return s}translate(t,e){return this.locale.translate(t,e)}createComponent(t,e){var i;let s=document.createElement(t);if(e!=null&&e.dataset&&Object.entries(e==null?void 0:e.dataset).forEach(([r,o])=>{o&&(typeof o=="boolean"?s.dataset[r]="":typeof o=="object"?s.dataset[r]=JSON.stringify(o):s.dataset[r]=o)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([r,o])=>{if(r==="floating"&&o){let n=o,l=(n==null?void 0:n.reference)instanceof c?n.reference.element:n.reference;if(typeof l=="object"&&"id"in l){l.setAttribute("wk-id",x()),s[r]={...n,reference:`[wk-id="${l.getAttribute("wk-id")}"]`};return}}s[r]=o}),(i=e==null?void 0:e.wrap)!=null&&i.name){let r=this.createElement(e.wrap.name,e.wrap.props,s);return r.setAttribute("wk-skip",""),r}return s}createHeadlessComponent(t,e){var r;let s=e.host.element?e.host.element:e.host;if(!s)throw new Error("Headless host is undefined");e.dataset&&Object.entries(e.dataset).forEach(([o,n])=>{n&&(typeof n=="boolean"?s.dataset[o]="":typeof n=="object"?s.dataset[o]=JSON.stringify(n):s.dataset[o]=n)});let i=(r=window.headlessElements)==null?void 0:r.store.get(t);if(!i)throw new Error(`Headless element not found: ${t}`);return new i(s)}createElement(t,e={},...s){let i=Object.assign(document.createElement(t),e);return s&&i.append(...s),i}};var f=class{constructor(){this.dispatcher=document}publish(t){this.dispatcher.dispatchEvent(new CustomEvent(t.name,{detail:t,bubbles:!1,cancelable:!1}))}once(t,e){let s=i=>{this.dispatcher.removeEventListener(t,s),e(i)};this.subscribe(t,s)}subscribe(t,e){this.dispatcher.addEventListener(t,s=>{let i=s;e({name:i.type,data:i.detail.data})})}subscribeMany(t){return Object.entries(t).map(([e,s])=>this.subscribe(e,s))}};window.headlessElements||(window.headlessElements={store:new Map,define(a,t){var e;(e=window.headlessElements)==null||e.store.set(a,t)}});var j=class{constructor({dependencies:t=[],...e}){this.stylesLoaded=!1;this._loaded=!1;this.addToCart=t=>this.state.promise.addToCart(t);this.addAllToCart=t=>this.state.promise.addAllToCart(t);this.addWishlistItem=t=>this.state.promise.addWishlistItem(t);this.clearWishlist=()=>this.state.promise.clearWishlist();this.loadProductInfo=t=>this.state.promise.loadProductInfo(t);this.loadShopifyProduct=t=>this.state.promise.loadShopifyProduct(t);this.loadWishlist=t=>this.state.promise.loadWishlist(t);this.loadWishlistItem=t=>this.state.promise.loadWishlistItem(t);this.publishWishlistEvent=t=>this.state.promise.publishWishlistEvent(t);this.publishWishlistProductEvent=t=>this.state.promise.publishWishlistProductEvent(t);this.removeWishlistItem=t=>this.state.promise.removeWishlistItem(t);this.shareWishlist=t=>this.state.promise.shareWishlist(t);this.updateWishlistItem=t=>this.state.promise.updateWishlistItem(t);this.config=this.parseConfig(e),this.settings=this.parseSettings(e),this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.events=new f,this.theme=new m({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl}),this.initDevMode();let{stylesheets:s,scripts:i,iconSetUrl:r,localeUrl:o}=this.parseDependencies(t);this.initStyles({stylesheets:s,iconSetUrl:r,localeUrl:o}),this.initScripts(i),this.initLoginActionQueue(),(this.hasSession||this.settings.general.appLoading==="EAGER")&&this.load(),window.WishlistKing=this,this.events.publish({name:"wk:app:created",data:{}})}get loaded(){return this._loaded}get state(){return y(this._state)}get apis(){return y(this._apis)}get utils(){return y(this._utils)}get hasSession(){return!!this.getSessionId()||!!this.customer}get isLoggedIn(){var t;return!!((t=this.customer)!=null&&t.id)}getSessionId(){let t=window.localStorage.getItem("wk_session_id");if(t)return t;let e=window.localStorage.getItem("appmate-session");if(e)try{let s=JSON.parse(e).state.sid;return this.setSessionId(s)}catch(s){console.error(s)}}setSessionId(t){var e;return window.localStorage.setItem("wk_session_id",t),(e=this._apis)==null||e.tracking.setSessionId(t),t}async load(){return this._loadPromise?this._loadPromise:this._loadPromise=(async()=>{let[{WishlistState:t},{ShopifyApi:e,WishlistApi:s,TrackingApi:i},{MoneyUtil:r,UrlUtil:o,ProductUtil:n}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/utils.js")]);this.initUtils({MoneyUtil:r,UrlUtil:o,ProductUtil:n}),this.initApis({WishlistApi:s,ShopifyApi:e,TrackingApi:i}),await this.initState({WishlistState:t}),this.initCustomerSession(),this.initUrlChangeEvents(),this.trackCurrentPage(),this._loaded=!0,this.events.publish({name:"wk:app:loaded",data:{}})})()}initUtils({UrlUtil:t,MoneyUtil:e,ProductUtil:s}){this._utils={url:new t({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:this.config.shop.domain,placeholderImageUrl:this.config.products.fallbackImage,fileUrl:this.routes.fileUrl}),money:new e({moneyFormat:this.config.shop.moneyFormat,moneyFormatWithCurrency:this.config.shop.moneyFormatWithCurrency}),product:new s}}initApis({WishlistApi:t,ShopifyApi:e,TrackingApi:s}){var i,r,o;this._apis={wishlist:new t({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(i=this.config.customer.id)!=null?i:void 0,sessionId:this.getSessionId(),trackingSource:this.theme.getPageType(),productMetafields:this.config.products.metafields}),shopify:new e({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new s({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,customerEmail:(o=this.config.customer.email)!=null?o:void 0,sessionId:this.getSessionId(),utils:this.utils,theme:this.theme,settings:this.settings})}}initState({WishlistState:t}){return this._state=new t({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils}),this._state.init()}async initStyles({stylesheets:t,iconSetUrl:e,localeUrl:s}){if(!(t!=null&&t.length)&&!e){this.onStylesLoaded();return}try{await Promise.all([...(t!=null?t:[]).map(i=>new Promise((r,o)=>{let n=document.createElement("link");n.rel="stylesheet",n.href=i,n.onload=r,n.onerror=o,document.head.appendChild(n)})),e?Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/components/icon.js"),import(e)]).then(([{Icon:i},{icons:r}])=>{if(typeof r!="object")throw new Error("Icon set must export icons object.");i.addIcons(r)}):Promise.resolve(),s?fetch(s).then(i=>i.json()).then(i=>{this.theme.locale.initLocale(i)}):Promise.resolve()]),this.onStylesLoaded()}catch(i){console.warn(i),this.events.publish({name:"wk:app:load-styles:error",data:{}})}}async initScripts(t){if(!(t!=null&&t.length)){this.initDefaultEventSubscribers(),this.events.publish({name:"wk:app:load-scripts:success",data:{}});return}try{await Promise.all(t.map(e=>import(e).then(({setup:s})=>{typeof s=="function"&&s({app:this})}))),t.some(e=>e.includes("event-subscribers.js"))||this.initDefaultEventSubscribers(),this.events.publish({name:"wk:app:load-scripts:success",data:{}})}catch(e){console.warn(e),this.events.publish({name:"wk:app:load-scripts:error",data:{}})}}initDefaultEventSubscribers(){this.events.subscribe("wk:wishlist:login-required",t=>{window.location.href=this.routes.accountLoginUrl}),this.events.subscribe("wk:customer:login",t=>{if(t.data.pending)switch(t.data.pending.action){case"wishlist:add":this.addWishlistItem(t.data.pending)}}),this.events.subscribe("wk:customer:logout",async t=>{this.clearCustomerSession()})}trackCurrentPage(){if(this.theme.getPageType()==="wishlist"){let e=this.theme.getWishlistId(window.location.pathname);e&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:e})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success",data:{}})}async initLoginActionQueue(){let t=!!window.localStorage.getItem("wk_logged_in");if(this.events.subscribe("wk:wishlist:login-required",e=>{var i;let s=["wishlist:add","wishlist:view"];(i=e.data)!=null&&i.action&&s.includes(e.data.action)&&window.localStorage.setItem("wk_pending",JSON.stringify({...e.data}))}),!t&&this.isLoggedIn){window.localStorage.setItem("wk_logged_in","1"),await this.load(),await this.loadWishlist({wishlistId:"mine",strategy:"cache-or-network"});let e=this.getPendingWishlistAction();this.events.publish({name:"wk:customer:login",data:{pending:e}})}else t&&!this.isLoggedIn&&(await this.load(),window.localStorage.removeItem("wk_logged_in"),this.events.publish({name:"wk:customer:logout",data:{}}));["challenge","account"].includes(this.theme.getPageType())||window.localStorage.removeItem("wk_pending")}async initCustomerSession(){this.hasSession||(await this.clearCustomerSession(),this.events.once("wk:app:init-sid",t=>{var e,s;(e=t.data)!=null&&e.sessionId&&this.setSessionId((s=t.data)==null?void 0:s.sessionId)}))}async clearCustomerSession(){window.localStorage.removeItem("wk_session_id"),window.localStorage.removeItem("wk_pending"),await this.state.promise.clearCache()}getPendingWishlistAction(){try{let t=window.localStorage.getItem("wk_pending");if(t)return JSON.parse(t)}catch(t){console.warn("Could not parse pending wishlist action",t)}}initUrlChangeEvents(){let t=({productHandle:s,variantId:i})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:s,variantId:i}})},e=s=>(...i)=>{var d;let r=s.apply(history,i),o=typeof i[2]=="string"?i[2]:(d=i[2])==null?void 0:d.toString();if(!o)return r;o.startsWith("?")&&(o=window.location.pathname+o);let n=`${window.location.protocol}//${window.location.host}`,l=new URL(o,n),h=this.theme.getProductHandle(l),p=l.searchParams.get("variant");if(!h)return r;t({productHandle:h,variantId:p?parseInt(p):void 0})};history.replaceState=e(history.replaceState),history.pushState=e(history.pushState)}parseConfig({config:t}){var e,s,i,r,o,n,l,h;return{customer:{id:t.customerId?t.customerId:null,email:(e=t.customerEmail)!=null?e:""},shop:{name:(s=t.shopName)!=null?s:"",domain:(i=t.shopDomain)!=null?i:"",permanentDomain:(r=t.shopPermanentDomain)!=null?r:"",moneyFormat:(o=t.shopMoneyFormat)!=null?o:"",moneyFormatWithCurrency:(n=t.shopMoneyFormatWithCurrency)!=null?n:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(l=t.apiHost)!=null?l:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(h=t.productFallbackImage)!=null?h:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081",metafields:!!t.productMetafields}}}parseSettings({settings:t}){var e,s,i,r,o,n,l,h,p,d,b,v,U,S,W,k,E,P,T,I,A,L,M,R,_,C,H;return{general:{appLoading:(s=(e=t==null?void 0:t.general)==null?void 0:e.appLoading)!=null?s:"LAZY",wishlistAccessMode:(r=(i=t==null?void 0:t.general)==null?void 0:i.wishlistAccessMode)!=null?r:"UNRESTRICTED",wishlistMode:(n=(o=t==null?void 0:t.general)==null?void 0:o.wishlistMode)!=null?n:"PRODUCT",wishlistPath:(h=(l=t==null?void 0:t.general)==null?void 0:l.wishlistPath)!=null?h:"/apps/wishlist"},money:{withCurrency:(d=(p=t==null?void 0:t.money)==null?void 0:p.withCurrency)!=null?d:!1},integrations:{googleAnalytics:{enabled:(U=(v=(b=t.integrations)==null?void 0:b.googleAnalytics)==null?void 0:v.enabled)!=null?U:!1,tracker:(k=(W=(S=t.integrations)==null?void 0:S.googleAnalytics)==null?void 0:W.tracker)!=null?k:""},klaviyo:{enabled:(T=(P=(E=t.integrations)==null?void 0:E.klaviyo)==null?void 0:P.enabled)!=null?T:!1},metaPixel:{enabled:(L=(A=(I=t.integrations)==null?void 0:I.metaPixel)==null?void 0:A.enabled)!=null?L:!1},wishlistAnalytics:{enabled:(_=(R=(M=t.integrations)==null?void 0:M.metaPixel)==null?void 0:R.enabled)!=null?_:!0}},cache:{wishlist:{ttl:6e4},wishlistItem:{ttl:6e4},productInfo:{ttl:6e4},product:{ttl:3e4},cart:{ttl:1e3}},colorMap:(C=t.colorMap)!=null?C:{},collectionButtons:(H=t.collectionButtons)!=null?H:{}}}parseRoutes(){let t=this.config.routes.rootUrl;return{rootUrl:t,fileUrl:this.config.routes.fileUrl,wishlistUrl:t+this.settings.general.wishlistPath.split("/").filter(e=>!!e).join("/"),accountUrl:t+"account",accountLoginUrl:t+"account/login",accountLogoutUrl:t+"account/logout",accountRegisterUrl:t+"account/register",accountAddressesUrl:t+"account/addresses",collectionsUrl:t+"collections",allProductsCollectionUrl:t+"collections/all",searchUrl:t+"search",predictiveSearchUrl:t+"search/suggest",cartUrl:t+"cart",cartAddUrl:t+"cart/add",cartChangeUrl:t+"cart/change",cartClearUrl:t+"cart/clear",cartUpdateUrl:t+"cart/update",productRecommendationsUrl:t+"recommendations/products"}}parseDependencies(t){let e=this.isDevMode();return t.map(s=>this.parseDependencyUrl({url:s,noCache:e})).reduce(({stylesheets:s,scripts:i,iconSetUrl:r,localeUrl:o},n)=>{let[l]=n.split("?");return l.endsWith(".css")?s.push(n):l.endsWith("icons.js")?r=n:l.endsWith(".js")?i.push(n):l.endsWith(".json")&&(o=n),{stylesheets:s,scripts:i,iconSetUrl:r,localeUrl:o}},{stylesheets:[],scripts:[],iconSetUrl:"",localeUrl:""})}parseDependencyUrl({url:t,noCache:e}){return e&&!t.includes("/_templates/")?t.replace("cdn.appmate.io","storage.googleapis.com/appmate-cdn").replace(/v=\d*/,`v=${Date.now()}`):t}isDevMode(){if(!!!document.getElementById("preview-bar-iframe"))return!1;let e=window.localStorage.getItem("wk_dev_mode");return e?Date.now()-parseInt(e)<8*36e5:!1}initDevMode(){window.location.search.includes("wk_dev_mode=on")?window.localStorage.setItem("wk_dev_mode",Date.now().toString()):window.location.search.includes("wk_dev_mode=off")&&window.localStorage.removeItem("wk_dev_mode"),this.isDevMode()&&window.addEventListener("message",t=>{switch(t.data){case"WK_THEME_RELOAD":window.localStorage.setItem("wk_dev_mode",Date.now().toString()),window.location.reload();break}},!1)}},y=a=>{if(!a)throw new Error("Wishlist app not loaded.");return a};export{j as WishlistApp};
var x=(a=21)=>crypto.getRandomValues(new Uint8Array(a)).reduce((t,e)=>(e&=63,e<36?t+=e.toString(36):e<62?t+=(e-26).toString(36).toUpperCase():e>62?t+="-":t+="_",t),"");var c=class{constructor(t){this.element=t}replace(t){var e;return(e=this.element)==null||e.replaceWith(t),t}append(t){var e;return(e=this.element)==null||e.append(t),t}prepend(t){var e;return(e=this.element)==null||e.prepend(t),t}insertBefore(t){var e;return(e=this.element)==null||e.before(t),t}insertAfter(t){var e;return(e=this.element)==null||e.after(t),t}closest(t,e=5){if(!this.element)return new c;if(typeof t=="object")return this.searchByStyle(t,this.element,i=>i.parentElement,e);let s=this.element.closest(t);return s?new c(s):new c}find(t){var s;let e=(s=this.element)==null?void 0:s.querySelector(t);return e?new c(e):new c}searchByStyle(t,e,s,i=5){if(i<0||!e)return null;let r=getComputedStyle(e);if(Object.entries(t).every(([l,h])=>r.getPropertyValue(l)===h))return new c(e);let n=s(e);return n?this.searchByStyle(t,n,s,i-1):null}};var u=class{constructor({routeUtil:t}){this.subscriber=[],this.routeUtil=t,this.observer=new MutationObserver(e=>{e.reduce((s,i)=>s.concat(Array.from(i.addedNodes)),[]).filter(s=>s instanceof Element&&!s.hasAttribute("wk-skip")).forEach(s=>{s instanceof Element&&this.scan(s)})}),this.observer.observe(document,{subtree:!0,childList:!0,attributes:!1})}watch(t,e){let s={target:t,callback:e};this.subscriber.push(s),D(s,this.routeUtil.parse(window.location.pathname))&&this.scan(document)}shouldSkip(t,{skipHidden:e}){return e&&t instanceof HTMLElement?t.offsetParent===null:!1}scan(t){t&&this.subscriber.filter(e=>D(e,this.routeUtil.parse(window.location.pathname))).forEach(e=>{let s=t instanceof Element&&t.matches(e.target.selector)&&!this.shouldSkip(t,{skipHidden:!!e.target.skipHidden});if(s&&this.notify(e,t),s&&e.target.firstMatch)return;let i=t.querySelectorAll(e.target.selector);for(let r of i)if(!this.shouldSkip(r,{skipHidden:!!e.target.skipHidden})&&(this.notify(e,r),e.target.firstMatch))break})}notify(t,e){if(!e.hasAttribute("wk-skip")){e.setAttribute("wk-skip","");let s=new c(e);t.callback(s)}}};function D({target:a},t){if(!a.pageType)return!0;if(!t.pageType)return!1;let e=Array.isArray(a.pageType)?a.pageType:[a.pageType];return e.includes("all")?!0:e.includes(t.pageType)}var N=[{pageType:"product",match:a=>a.includes("/products/")},{pageType:"collection",match:a=>a.includes("/collections/")&&!a.includes("/products/")},{pageType:"account",match:a=>a.includes("/account/")||a.endsWith("/account")},{pageType:"challenge",match:a=>a.endsWith("/account")},{pageType:"blog",match:a=>a.includes("/blog/")},{pageType:"cart",match:a=>a.includes("/cart/")||a.endsWith("/cart")},{pageType:"wishlist",match:(a,{wishlistUrl:t})=>a.includes(t)},{pageType:"page",match:a=>a.includes("/pages/")},{pageType:"search",match:a=>a.includes("/search")},{pageType:"home",match:a=>a.length<4}],g=class{constructor({wishlistUrl:t}){this.wishlistUrl=t}parse(t){for(let e of N)if(e.match(t,{wishlistUrl:this.wishlistUrl}))return{pageType:e.pageType};return{pageType:"unknown"}}};var w=class{constructor(t){this.locale={};var e;this.initLocale((e=t==null?void 0:t.locale)!=null?e:{})}initLocale(t){this.locale=this.decodeLocale(t)}decodeHtmlEntities(t){return t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/g,"'")}decodeLocale(t){let e={};for(let s in t){e[s]={};for(let i in t[s])e[s][i]=this.decodeHtmlEntities(t[s][i])}return e}translate(t,e){var o;let[s,i]=t.split("."),r=(o=this.locale[s])==null?void 0:o[i];return r?e?Object.entries(e).reduce((n,[l,h])=>n.replace(new RegExp(`{{\\s*${l}\\s*}}`,"g"),h),r):r:`translation missing: ${t}`}};var m=class{constructor({rootUrl:t,wishlistUrl:e}){this._rootUrl=t,this.route=new g({wishlistUrl:e}),this.observer=new u({routeUtil:this.route}),this.locale=new w,this.watch=this.observer.watch.bind(this.observer)}getPageType(t=window.location.pathname){return this.route.parse(t).pageType}getWishlistId(t){if(!t)return null;t instanceof URL&&(t=t.pathname);let e=t.replace(this._rootUrl,"/").split("/");return e.length===4?e.pop():"mine"}getProductHandle(t){var e;return t?(t instanceof URL&&(t=t.pathname),(e=t.split("/").pop())==null?void 0:e.split("?")[0]):null}getVariantId(t,e){var i;let s=null;if(t&&(t instanceof URL&&(t=t.pathname),s=new URLSearchParams(t.split("?")[1]).get("variant")),!s&&e)try{s=new FormData((i=e.element)!=null?i:e).get("id")}catch(r){console.warn("Failed to parse variant from product form.",r)}return s}translate(t,e){return this.locale.translate(t,e)}createComponent(t,e){var i;let s=document.createElement(t);if(e!=null&&e.dataset&&Object.entries(e==null?void 0:e.dataset).forEach(([r,o])=>{o&&(typeof o=="boolean"?s.dataset[r]="":typeof o=="object"?s.dataset[r]=JSON.stringify(o):s.dataset[r]=o)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([r,o])=>{if(r==="floating"&&o){let n=o,l=(n==null?void 0:n.reference)instanceof c?n.reference.element:n.reference;if(typeof l=="object"&&"id"in l){l.setAttribute("wk-id",x()),s[r]={...n,reference:`[wk-id="${l.getAttribute("wk-id")}"]`};return}}s[r]=o}),(i=e==null?void 0:e.wrap)!=null&&i.name){let r=this.createElement(e.wrap.name,e.wrap.props,s);return r.setAttribute("wk-skip",""),r}return s}createHeadlessComponent(t,e){var r;let s=e.host.element?e.host.element:e.host;if(!s)throw new Error("Headless host is undefined");e.dataset&&Object.entries(e.dataset).forEach(([o,n])=>{n&&(typeof n=="boolean"?s.dataset[o]="":typeof n=="object"?s.dataset[o]=JSON.stringify(n):s.dataset[o]=n)});let i=(r=window.headlessElements)==null?void 0:r.store.get(t);if(!i)throw new Error(`Headless element not found: ${t}`);return new i(s)}createElement(t,e={},...s){let i=Object.assign(document.createElement(t),e);return s&&i.append(...s),i}};var f=class{constructor(){this.dispatcher=document}publish(t){this.dispatcher.dispatchEvent(new CustomEvent(t.name,{detail:t,bubbles:!1,cancelable:!1}))}once(t,e){let s=i=>{this.dispatcher.removeEventListener(t,s),e(i)};this.subscribe(t,s)}subscribe(t,e){this.dispatcher.addEventListener(t,s=>{let i=s;e({name:i.type,data:i.detail.data})})}subscribeMany(t){return Object.entries(t).map(([e,s])=>this.subscribe(e,s))}};window.headlessElements||(window.headlessElements={store:new Map,define(a,t){var e;(e=window.headlessElements)==null||e.store.set(a,t)}});var j=class{constructor({dependencies:t=[],...e}){this.stylesLoaded=!1;this._loaded=!1;this.addToCart=t=>this.state.promise.addToCart(t);this.addAllToCart=t=>this.state.promise.addAllToCart(t);this.addWishlistItem=t=>this.state.promise.addWishlistItem(t);this.clearWishlist=()=>this.state.promise.clearWishlist();this.loadProductInfo=t=>this.state.promise.loadProductInfo(t);this.loadShopifyProduct=t=>this.state.promise.loadShopifyProduct(t);this.loadWishlist=t=>this.state.promise.loadWishlist(t);this.loadWishlistItem=t=>this.state.promise.loadWishlistItem(t);this.publishWishlistEvent=t=>this.state.promise.publishWishlistEvent(t);this.publishWishlistProductEvent=t=>this.state.promise.publishWishlistProductEvent(t);this.removeWishlistItem=t=>this.state.promise.removeWishlistItem(t);this.shareWishlist=t=>this.state.promise.shareWishlist(t);this.updateWishlistItem=t=>this.state.promise.updateWishlistItem(t);this.config=this.parseConfig(e),this.settings=this.parseSettings(e),this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.events=new f,this.theme=new m({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl}),this.initDevMode();let{stylesheets:s,scripts:i,iconSetUrl:r,localeUrl:o}=this.parseDependencies(t);this.initStyles({stylesheets:s,iconSetUrl:r,localeUrl:o}),this.initScripts(i),this.initLoginActionQueue(),(this.hasSession||this.settings.general.appLoading==="EAGER")&&this.load(),window.WishlistKing=this,this.events.publish({name:"wk:app:created",data:{}})}get loaded(){return this._loaded}get state(){return y(this._state)}get apis(){return y(this._apis)}get utils(){return y(this._utils)}get hasSession(){return!!this.getSessionId()||!!this.customer}get isLoggedIn(){var t;return!!((t=this.customer)!=null&&t.id)}getSessionId(){let t=window.localStorage.getItem("wk_session_id");if(t)return t;let e=window.localStorage.getItem("appmate-session");if(e)try{let s=JSON.parse(e).state.sid;return this.setSessionId(s)}catch(s){console.error(s)}}setSessionId(t){var e;return window.localStorage.setItem("wk_session_id",t),(e=this._apis)==null||e.tracking.setSessionId(t),t}async load(){return this._loadPromise?this._loadPromise:this._loadPromise=(async()=>{let[{WishlistState:t},{ShopifyApi:e,WishlistApi:s,TrackingApi:i},{MoneyUtil:r,UrlUtil:o,ProductUtil:n}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/utils.js")]);this.initUtils({MoneyUtil:r,UrlUtil:o,ProductUtil:n}),this.initApis({WishlistApi:s,ShopifyApi:e,TrackingApi:i}),await this.initState({WishlistState:t}),this.initCustomerSession(),this.initUrlChangeEvents(),this.trackCurrentPage(),this._loaded=!0,this.events.publish({name:"wk:app:loaded",data:{}})})()}initUtils({UrlUtil:t,MoneyUtil:e,ProductUtil:s}){this._utils={url:new t({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:this.config.shop.domain,placeholderImageUrl:this.config.products.fallbackImage,fileUrl:this.routes.fileUrl}),money:new e({moneyFormat:this.config.shop.moneyFormat,moneyFormatWithCurrency:this.config.shop.moneyFormatWithCurrency}),product:new s}}initApis({WishlistApi:t,ShopifyApi:e,TrackingApi:s}){var i,r,o;this._apis={wishlist:new t({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(i=this.config.customer.id)!=null?i:void 0,sessionId:this.getSessionId(),trackingSource:this.theme.getPageType(),productMetafields:this.config.products.metafields}),shopify:new e({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new s({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,customerEmail:(o=this.config.customer.email)!=null?o:void 0,sessionId:this.getSessionId(),utils:this.utils,theme:this.theme,settings:this.settings})}}initState({WishlistState:t}){return this._state=new t({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils}),this._state.init()}async initStyles({stylesheets:t,iconSetUrl:e,localeUrl:s}){if(!(t!=null&&t.length)&&!e){this.onStylesLoaded();return}try{await Promise.all([...(t!=null?t:[]).map(i=>new Promise((r,o)=>{let n=document.createElement("link");n.rel="stylesheet",n.href=i,n.onload=r,n.onerror=o,document.head.appendChild(n)})),e?Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/components/icon.js"),import(e)]).then(([{Icon:i},{icons:r}])=>{if(typeof r!="object")throw new Error("Icon set must export icons object.");i.addIcons(r)}):Promise.resolve(),s?fetch(s).then(i=>i.json()).then(i=>{this.theme.locale.initLocale(i)}):Promise.resolve()]),this.onStylesLoaded()}catch(i){console.warn(i),this.events.publish({name:"wk:app:load-styles:error",data:{}})}}async initScripts(t){if(!(t!=null&&t.length)){this.initDefaultEventSubscribers(),this.events.publish({name:"wk:app:load-scripts:success",data:{}});return}try{await Promise.all(t.map(e=>import(e).then(({setup:s})=>{typeof s=="function"&&s({app:this})}))),t.some(e=>e.includes("event-subscribers.js"))||this.initDefaultEventSubscribers(),this.events.publish({name:"wk:app:load-scripts:success",data:{}})}catch(e){console.warn(e),this.events.publish({name:"wk:app:load-scripts:error",data:{}})}}initDefaultEventSubscribers(){this.events.subscribe("wk:wishlist:login-required",t=>{window.location.href=this.routes.accountLoginUrl}),this.events.subscribe("wk:customer:login",t=>{if(t.data.pending)switch(t.data.pending.action){case"wishlist:add":this.addWishlistItem(t.data.pending)}}),this.events.subscribe("wk:customer:logout",async t=>{this.clearCustomerSession()})}trackCurrentPage(){if(this.theme.getPageType()==="wishlist"){let e=this.theme.getWishlistId(window.location.pathname);e&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:e})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success",data:{}})}async initLoginActionQueue(){let t=!!window.localStorage.getItem("wk_logged_in");if(this.events.subscribe("wk:wishlist:login-required",e=>{var i;let s=["wishlist:add","wishlist:view"];(i=e.data)!=null&&i.action&&s.includes(e.data.action)&&window.localStorage.setItem("wk_pending",JSON.stringify({...e.data}))}),!t&&this.isLoggedIn){window.localStorage.setItem("wk_logged_in","1"),await this.load(),await this.loadWishlist({wishlistId:"mine",strategy:"cache-or-network"});let e=this.getPendingWishlistAction();this.events.publish({name:"wk:customer:login",data:{pending:e}})}else t&&!this.isLoggedIn&&(await this.load(),window.localStorage.removeItem("wk_logged_in"),this.events.publish({name:"wk:customer:logout",data:{}}));["challenge","account"].includes(this.theme.getPageType())||window.localStorage.removeItem("wk_pending")}async initCustomerSession(){this.hasSession||(await this.clearCustomerSession(),this.events.once("wk:app:init-sid",t=>{var e,s;(e=t.data)!=null&&e.sessionId&&this.setSessionId((s=t.data)==null?void 0:s.sessionId)}))}async clearCustomerSession(){window.localStorage.removeItem("wk_session_id"),window.localStorage.removeItem("wk_pending"),await this.state.promise.clearCache()}getPendingWishlistAction(){try{let t=window.localStorage.getItem("wk_pending");if(t)return JSON.parse(t)}catch(t){console.warn("Could not parse pending wishlist action",t)}}initUrlChangeEvents(){let t=({productHandle:s,variantId:i})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:s,variantId:i}})},e=s=>(...i)=>{var d;let r=s.apply(history,i),o=typeof i[2]=="string"?i[2]:(d=i[2])==null?void 0:d.toString();if(!o)return r;o.startsWith("?")&&(o=window.location.pathname+o);let n=`${window.location.protocol}//${window.location.host}`,l=new URL(o,n),h=this.theme.getProductHandle(l),p=l.searchParams.get("variant");if(!h)return r;t({productHandle:h,variantId:p?parseInt(p):void 0})};history.replaceState=e(history.replaceState),history.pushState=e(history.pushState)}parseConfig({config:t}){var e,s,i,r,o,n,l,h;return{customer:{id:t.customerId?t.customerId:null,email:(e=t.customerEmail)!=null?e:""},shop:{name:(s=t.shopName)!=null?s:"",domain:(i=t.shopDomain)!=null?i:"",permanentDomain:(r=t.shopPermanentDomain)!=null?r:"",moneyFormat:(o=t.shopMoneyFormat)!=null?o:"",moneyFormatWithCurrency:(n=t.shopMoneyFormatWithCurrency)!=null?n:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(l=t.apiHost)!=null?l:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(h=t.productFallbackImage)!=null?h:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081",metafields:!!t.productMetafields}}}parseSettings({settings:t}){var e,s,i,r,o,n,l,h,p,d,b,v,U,S,W,k,E,P,T,I,A,L,M,R,_,C,H;return{general:{appLoading:(s=(e=t==null?void 0:t.general)==null?void 0:e.appLoading)!=null?s:"LAZY",wishlistAccessMode:(r=(i=t==null?void 0:t.general)==null?void 0:i.wishlistAccessMode)!=null?r:"UNRESTRICTED",wishlistMode:(n=(o=t==null?void 0:t.general)==null?void 0:o.wishlistMode)!=null?n:"PRODUCT",wishlistPath:(h=(l=t==null?void 0:t.general)==null?void 0:l.wishlistPath)!=null?h:"/apps/wishlist"},money:{withCurrency:(d=(p=t==null?void 0:t.money)==null?void 0:p.withCurrency)!=null?d:!1},integrations:{googleAnalytics:{enabled:(U=(v=(b=t.integrations)==null?void 0:b.googleAnalytics)==null?void 0:v.enabled)!=null?U:!1,tracker:(k=(W=(S=t.integrations)==null?void 0:S.googleAnalytics)==null?void 0:W.tracker)!=null?k:""},klaviyo:{enabled:(T=(P=(E=t.integrations)==null?void 0:E.klaviyo)==null?void 0:P.enabled)!=null?T:!1},metaPixel:{enabled:(L=(A=(I=t.integrations)==null?void 0:I.metaPixel)==null?void 0:A.enabled)!=null?L:!1},wishlistAnalytics:{enabled:(_=(R=(M=t.integrations)==null?void 0:M.metaPixel)==null?void 0:R.enabled)!=null?_:!0}},cache:{wishlist:{ttl:6e4},wishlistItem:{ttl:6e4},productInfo:{ttl:6e4},product:{ttl:3e4},cart:{ttl:1e3}},colorMap:(C=t.colorMap)!=null?C:{},collectionButtons:(H=t.collectionButtons)!=null?H:{}}}parseRoutes(){let t=this.config.routes.rootUrl;return{rootUrl:t,fileUrl:this.config.routes.fileUrl,wishlistUrl:t+this.settings.general.wishlistPath.split("/").filter(e=>!!e).join("/"),accountUrl:t+"account",accountLoginUrl:t+"account/login",accountLogoutUrl:t+"account/logout",accountRegisterUrl:t+"account/register",accountAddressesUrl:t+"account/addresses",collectionsUrl:t+"collections",allProductsCollectionUrl:t+"collections/all",searchUrl:t+"search",predictiveSearchUrl:t+"search/suggest",cartUrl:t+"cart",cartAddUrl:t+"cart/add",cartChangeUrl:t+"cart/change",cartClearUrl:t+"cart/clear",cartUpdateUrl:t+"cart/update",productRecommendationsUrl:t+"recommendations/products"}}parseDependencies(t){let e=this.isDevMode();return t.map(s=>this.parseDependencyUrl({url:s,noCache:e})).reduce(({stylesheets:s,scripts:i,iconSetUrl:r,localeUrl:o},n)=>{let[l]=n.split("?");return l.endsWith(".css")?s.push(n):l.endsWith("icons.js")?r=n:l.endsWith(".js")?i.push(n):l.endsWith(".json")&&(o=n),{stylesheets:s,scripts:i,iconSetUrl:r,localeUrl:o}},{stylesheets:[],scripts:[],iconSetUrl:"",localeUrl:""})}parseDependencyUrl({url:t,noCache:e}){return e&&!t.includes("/_templates/")?t.replace("cdn.appmate.io","storage.googleapis.com/appmate-cdn").replace(/v=\d*/,`v=${Date.now()}`):t}isDevMode(){if(!!!document.getElementById("preview-bar-iframe"))return!1;let e=window.localStorage.getItem("wk_dev_mode");return e?Date.now()-parseInt(e)<8*36e5:!1}initDevMode(){window.location.search.includes("wk_dev_mode=on")?window.localStorage.setItem("wk_dev_mode",Date.now().toString()):window.location.search.includes("wk_dev_mode=off")&&window.localStorage.removeItem("wk_dev_mode"),this.isDevMode()&&window.addEventListener("message",t=>{switch(t.data){case"WK_THEME_RELOAD":window.localStorage.setItem("wk_dev_mode",Date.now().toString()),window.location.reload();break}},!1)}},y=a=>{if(!a)throw new Error("Wishlist app not loaded.");return a};export{j as WishlistApp};

@@ -1,1 +0,1 @@

import{delayWhen as p,from as a,fromEvent as o,isObservable as u,map as f,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as l,first as b,switchMap as v,tap as c}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{WishlistStateController as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/controllers.js";var d=class{constructor(t){this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;if(this.host=t,this.stateCtrl=new g(this),this.host.hasAttribute("wk-headless"))throw new Error("Headless component already initialised");this.host.setAttribute("wk-headless",""),this.host.setAttribute("wk-skip",""),this.initEvents(),this.connect(),this.firstConnect=!1}get app(){return this.stateCtrl.app}static get observedAttributes(){return["data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}addController(t){}appReadyCallback(){this.host.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var i,n,e;if(this.host.dataset.productHandle===((i=t.data)==null?void 0:i.productHandle)&&((n=t.data)!=null&&n.variantId)){let r=this.productInfo?this.productInfo.wishlistItemId:void 0,s=this.productInfo?this.productInfo.variantId:void 0;r&&!s&&this.app.updateWishlistItem({wishlistItemId:r,changes:{variantId:(e=t.data)==null?void 0:e.variantId}}),this.host.dataset.variantId=t.data.variantId.toString(),this.connected&&this.initState()}})}async connect(){if(!this.connected){if(!this.app.stylesLoaded){o(document,"wk:app:load-styles:success").pipe(b()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:loaded",()=>{this.init()}))}}getStateConfig(){return{}}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}updated(){}setState(t){this.wishlist=t.wishlist,this.wishlistItem=t.wishlistItem,this.productInfo=t.productInfo,this.updated()}createRenderRoot(){return this}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.host.setAttribute("wk-lazy",""),this.observer.observe(this.host)}handleIntersect([t]){var i;t.isIntersecting&&(this.host.removeAttribute("wk-lazy"),(i=this.observer)==null||i.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let i=Object.entries(t).map(([n,e])=>{let[r,s]=n.split(/ (.*)/s);return this.subscribeToEvent({eventName:r,selector:s,handler:e})});this.cleanupMethods.push(()=>i.forEach(n=>n.unsubscribe()))}subscribeToEvent({eventName:t,handler:i,selector:n}){return o(this.host,t).pipe(c(e=>{this.eventPending&&e.preventDefault()}),l(()=>!this.eventPending),c(()=>{this.eventPending=!0}),f(e=>e.target instanceof Element?{event:e,target:n?e.target.closest(n):e.currentTarget}:{event:e,target:null}),l(({target:e})=>!!e),p(e=>this.app.hasSession?h(e):a(this.app.load())),v(({event:e,target:r})=>{let s=i.bind(this)(e,r);return u(s)?s:typeof(s==null?void 0:s.then)=="function"?a(s):h(s)})).subscribe(()=>{this.eventPending=!1})}};export{d as WishlistElementHeadless};
import{delayWhen as p,from as a,fromEvent as o,isObservable as u,map as f,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as l,first as b,switchMap as v,tap as c}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{WishlistStateController as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/controllers.js";var d=class{constructor(t){this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;if(this.host=t,this.stateCtrl=new g(this),this.host.hasAttribute("wk-headless"))throw new Error("Headless component already initialised");this.host.setAttribute("wk-headless",""),this.host.setAttribute("wk-skip",""),this.initEvents(),this.connect(),this.firstConnect=!1}get app(){return this.stateCtrl.app}static get observedAttributes(){return["data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}addController(t){}appReadyCallback(){this.host.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var i,n,e;if(this.host.dataset.productHandle===((i=t.data)==null?void 0:i.productHandle)&&((n=t.data)!=null&&n.variantId)){let r=this.productInfo?this.productInfo.wishlistItemId:void 0,s=this.productInfo?this.productInfo.variantId:void 0;r&&!s&&this.app.updateWishlistItem({wishlistItemId:r,changes:{variantId:(e=t.data)==null?void 0:e.variantId}}),this.host.dataset.variantId=t.data.variantId.toString(),this.connected&&this.initState()}})}async connect(){if(!this.connected){if(!this.app.stylesLoaded){o(document,"wk:app:load-styles:success").pipe(b()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:loaded",()=>{this.init()}))}}getStateConfig(){return{}}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}updated(){}setState(t){this.wishlist=t.wishlist,this.wishlistItem=t.wishlistItem,this.productInfo=t.productInfo,this.updated()}createRenderRoot(){return this}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.host.setAttribute("wk-lazy",""),this.observer.observe(this.host)}handleIntersect([t]){var i;t.isIntersecting&&(this.host.removeAttribute("wk-lazy"),(i=this.observer)==null||i.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let i=Object.entries(t).map(([n,e])=>{let[r,s]=n.split(/ (.*)/s);return this.subscribeToEvent({eventName:r,selector:s,handler:e})});this.cleanupMethods.push(()=>i.forEach(n=>n.unsubscribe()))}subscribeToEvent({eventName:t,handler:i,selector:n}){return o(this.host,t).pipe(c(e=>{this.eventPending&&e.preventDefault()}),l(()=>!this.eventPending),c(()=>{this.eventPending=!0}),f(e=>e.target instanceof Element?{event:e,target:n?e.target.closest(n):e.currentTarget}:{event:e,target:null}),l(({target:e})=>!!e),p(e=>this.app.hasSession?h(e):a(this.app.load())),v(({event:e,target:r})=>{let s=i.bind(this)(e,r);return u(s)?s:typeof(s==null?void 0:s.then)=="function"?a(s):h(s)})).subscribe(()=>{this.eventPending=!1})}};export{d as WishlistElementHeadless};

@@ -1,1 +0,1 @@

import{delayWhen as d,from as o,fromEvent as c,isObservable as f,map as b,of as l}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as h,first as g,switchMap as m,tap as u}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{LitElement as y}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{unsafeHTML as p}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{WishlistStateController as v}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.17/controllers.js";var a=class extends y{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.loadWithoutSession=!1;this.stateCtrl=new v(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"]}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),this.connected&&this.app.loaded&&this.initState()}appReadyCallback(){this.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var e,i;this.dataset.productHandle===((e=t.data)==null?void 0:e.productHandle)&&((i=t.data)!=null&&i.variantId)&&(this.dataset.variantId=t.data.variantId.toString())})}async connect(){if(!this.connected){if(!window.WishlistKing){window.document.addEventListener("wk:app:created",()=>{this.connect()},{once:!0});return}if(!this.app.stylesLoaded){c(document,"wk:app:load-styles:success").pipe(g()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession||this.loadWithoutSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:loaded",()=>{this.init()}))}}getStateConfig(){return{}}getTranslation(t,e){if(!this.app.theme)return t;let i=this.app.theme.translate(t,e);return t.endsWith("_html")?p(i):i}formatMoney(t,e){var i;return this.app.utils.money.formatMoney(t,{withCurrency:(i=e==null?void 0:e.withCurrency)!=null?i:this.app.settings.money.withCurrency})}renderMoney(t,e){return p(this.formatMoney(t,e))}getProductUrl(t,e){return this.app.utils.url.getVariantUrl(t.url,e==null?void 0:e.id)}getImageUrl(t,e,i){var s;return this.app.utils.url.getImageUrl((s=e==null?void 0:e.featured_image)!=null&&s.src?e:t,i)}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}setState(t){t.wishlist&&(this.wishlist=t.wishlist),t.wishlistItem&&(this.wishlistItem=t.wishlistItem),t.productInfo&&(this.productInfo=t.productInfo),t.cart&&(this.cart=t.cart)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML&&this.firstConnect&&(this.innerHTML=""),this.initEvents(),this.connect(),this.firstConnect=!1}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.cleanupMethods.forEach(i=>i()),this.connected=!1,(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t,e;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.setAttribute("wk-lazy",""),this.observer.observe((e=this.firstElementChild)!=null?e:this)}handleIntersect([t]){var e;t.isIntersecting&&(this.removeAttribute("wk-lazy"),(e=this.observer)==null||e.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([i,s])=>{let[n,r]=i.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:r,handler:s})});this.cleanupMethods.push(()=>e.forEach(i=>i.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:i}){return c(this,t).pipe(u(s=>{this.eventPending&&s.preventDefault()}),h(()=>!this.eventPending),u(()=>{this.eventPending=!0}),b(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),h(({target:s})=>!!s),d(s=>this.app.hasSession?l(s):o(this.app.load())),m(({event:s,target:n})=>{let r=e.bind(this)(s,n);return f(r)?r:typeof(r==null?void 0:r.then)=="function"?o(r):l(r)})).subscribe(()=>{this.eventPending=!1})}};a.properties={wishlist:{state:!0},productInfo:{state:!0},wishlistItem:{state:!0},cart:{state:!0},loadWithoutSession:{type:Boolean,attribute:"load-without-session"}};export{a as WishlistElement};
import{delayWhen as d,from as o,fromEvent as c,isObservable as f,map as b,of as l}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as h,first as g,switchMap as m,tap as u}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{LitElement as y}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{unsafeHTML as p}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{WishlistStateController as v}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.18/controllers.js";var a=class extends y{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.loadWithoutSession=!1;this.stateCtrl=new v(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"]}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),this.connected&&this.app.loaded&&this.initState()}appReadyCallback(){this.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var e,i;this.dataset.productHandle===((e=t.data)==null?void 0:e.productHandle)&&((i=t.data)!=null&&i.variantId)&&(this.dataset.variantId=t.data.variantId.toString())})}async connect(){if(!this.connected){if(!window.WishlistKing){window.document.addEventListener("wk:app:created",()=>{this.connect()},{once:!0});return}if(!this.app.stylesLoaded){c(document,"wk:app:load-styles:success").pipe(g()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession||this.loadWithoutSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:loaded",()=>{this.init()}))}}getStateConfig(){return{}}getTranslation(t,e){if(!this.app.theme)return t;let i=this.app.theme.translate(t,e);return t.endsWith("_html")?p(i):i}formatMoney(t,e){var i;return this.app.utils.money.formatMoney(t,{withCurrency:(i=e==null?void 0:e.withCurrency)!=null?i:this.app.settings.money.withCurrency})}renderMoney(t,e){return p(this.formatMoney(t,e))}getProductUrl(t,e){return this.app.utils.url.getVariantUrl(t.url,e==null?void 0:e.id)}getImageUrl(t,e,i){var s;return this.app.utils.url.getImageUrl((s=e==null?void 0:e.featured_image)!=null&&s.src?e:t,i)}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}setState(t){t.wishlist&&(this.wishlist=t.wishlist),t.wishlistItem&&(this.wishlistItem=t.wishlistItem),t.productInfo&&(this.productInfo=t.productInfo),t.cart&&(this.cart=t.cart)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML&&this.firstConnect&&(this.innerHTML=""),this.initEvents(),this.connect(),this.firstConnect=!1}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.cleanupMethods.forEach(i=>i()),this.connected=!1,(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t,e;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.setAttribute("wk-lazy",""),this.observer.observe((e=this.firstElementChild)!=null?e:this)}handleIntersect([t]){var e;t.isIntersecting&&(this.removeAttribute("wk-lazy"),(e=this.observer)==null||e.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([i,s])=>{let[n,r]=i.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:r,handler:s})});this.cleanupMethods.push(()=>e.forEach(i=>i.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:i}){return c(this,t).pipe(u(s=>{this.eventPending&&s.preventDefault()}),h(()=>!this.eventPending),u(()=>{this.eventPending=!0}),b(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),h(({target:s})=>!!s),d(s=>this.app.hasSession?l(s):o(this.app.load())),m(({event:s,target:n})=>{let r=e.bind(this)(s,n);return f(r)?r:typeof(r==null?void 0:r.then)=="function"?o(r):l(r)})).subscribe(()=>{this.eventPending=!1})}};a.properties={wishlist:{state:!0},productInfo:{state:!0},wishlistItem:{state:!0},cart:{state:!0},loadWithoutSession:{type:Boolean,attribute:"load-without-session"}};export{a as WishlistElement};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc