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.19 to 4.25.20

2

components/button.js

@@ -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.19/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.19/components/counter.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.19/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.20/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.20/components/counter.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.20/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.19/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.20/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.19/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.20/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.19/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.20/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.19",
"version": "4.25.20",
"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.19/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.19/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.19/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.19/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.20/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.20/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.20/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.20/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{catchError as p,delayWhen as u,from as o,fromEvent as h,isObservable as f,map as b,of as a}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as l,first as v,switchMap as g,tap as c}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{WishlistStateController as m}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.19/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 m(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,r,e;if(this.host.dataset.productHandle===((i=t.data)==null?void 0:i.productHandle)&&((r=t.data)!=null&&r.variantId)){let n=this.productInfo?this.productInfo.wishlistItemId:void 0,s=this.productInfo?this.productInfo.variantId:void 0;n&&!s&&this.app.updateWishlistItem({wishlistItemId:n,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){h(document,"wk:app:load-styles:success").pipe(v()).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(([r,e])=>{let[n,s]=r.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:s,handler:e})});this.cleanupMethods.push(()=>i.forEach(r=>r.unsubscribe()))}subscribeToEvent({eventName:t,handler:i,selector:r}){return h(this.host,t).pipe(c(e=>{this.eventPending&&e.preventDefault()}),l(()=>!this.eventPending),c(()=>{this.eventPending=!0}),b(e=>e.target instanceof Element?{event:e,target:r?e.target.closest(r):e.currentTarget}:{event:e,target:null}),l(({target:e})=>!!e),u(e=>this.app.hasSession?a(e):o(this.app.load())),g(({event:e,target:n})=>{let s=i.bind(this)(e,n);return f(s)?s:typeof(s==null?void 0:s.then)=="function"?o(s):a(s)}),p(e=>(console.error(e),a()))).subscribe(()=>{this.eventPending=!1})}};export{d as WishlistElementHeadless};
import{delayWhen as u,from as o,fromEvent as h,isObservable as f,map as b,of as l}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as c,first as v,switchMap as g,tap as d}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{WishlistStateController as m}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.20/controllers.js";var p=class{constructor(t){this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;if(this.host=t,this.stateCtrl=new m(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 s,r,e;if(this.host.dataset.productHandle===((s=t.data)==null?void 0:s.productHandle)&&((r=t.data)!=null&&r.variantId)){let n=this.productInfo?this.productInfo.wishlistItemId:void 0,i=this.productInfo?this.productInfo.variantId:void 0;n&&!i&&this.app.updateWishlistItem({wishlistItemId:n,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){h(document,"wk:app:load-styles:success").pipe(v()).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(s=>this.handleIntersect(s),{root:null,rootMargin:"0px"}),this.host.setAttribute("wk-lazy",""),this.observer.observe(this.host)}handleIntersect([t]){var s;t.isIntersecting&&(this.host.removeAttribute("wk-lazy"),(s=this.observer)==null||s.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let s=Object.entries(t).map(([r,e])=>{let[n,i]=r.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:i,handler:e})});this.cleanupMethods.push(()=>s.forEach(r=>r.unsubscribe()))}subscribeToEvent({eventName:t,handler:s,selector:r}){return h(this.host,t).pipe(d(e=>{this.eventPending&&e.preventDefault()}),c(()=>!this.eventPending),d(()=>{this.eventPending=!0}),b(e=>e.target instanceof Element?{event:e,target:r?e.target.closest(r):e.currentTarget}:{event:e,target:null}),c(({target:e})=>!!e),u(e=>this.app.hasSession?l(e):o(this.app.load())),g(({event:e,target:n})=>{let i;try{i=s.bind(this)(e,n)}catch(a){console.error(a),i=a}return f(i)?i:typeof(i==null?void 0:i.then)=="function"?o(i):l(i)})).subscribe(()=>{this.eventPending=!1})}};export{p as WishlistElementHeadless};

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

import{catchError as d,delayWhen as f,from as c,fromEvent as l,isObservable as b,map as g,of as a}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as h,first as m,switchMap as y,tap as u}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{LitElement as v}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 C}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.19/controllers.js";var o=class extends v{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.loadWithoutSession=!1;this.stateCtrl=new C(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){l(document,"wk:app:load-styles:success").pipe(m()).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 l(this,t).pipe(u(s=>{this.eventPending&&s.preventDefault()}),h(()=>!this.eventPending),u(()=>{this.eventPending=!0}),g(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),h(({target:s})=>!!s),f(s=>this.app.hasSession?a(s):c(this.app.load())),y(({event:s,target:n})=>{let r=e.bind(this)(s,n);return b(r)?r:typeof(r==null?void 0:r.then)=="function"?c(r):a(r)}),d(s=>(console.error(s),a()))).subscribe(()=>{this.eventPending=!1})}};o.properties={wishlist:{state:!0},productInfo:{state:!0},wishlistItem:{state:!0},cart:{state:!0},loadWithoutSession:{type:Boolean,attribute:"load-without-session"}};export{o as WishlistElement};
import{delayWhen as f,from as c,fromEvent as l,isObservable as b,map as g,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as u,first as m,switchMap as y,tap as p}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{LitElement as v}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{unsafeHTML as d}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{WishlistStateController as C}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.20/controllers.js";var a=class extends v{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.loadWithoutSession=!1;this.stateCtrl=new C(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){l(document,"wk:app:load-styles:success").pipe(m()).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")?d(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 d(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 l(this,t).pipe(p(s=>{this.eventPending&&s.preventDefault()}),u(()=>!this.eventPending),p(()=>{this.eventPending=!0}),g(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),u(({target:s})=>!!s),f(s=>this.app.hasSession?h(s):c(this.app.load())),y(({event:s,target:n})=>{let r;try{r=e.bind(this)(s,n)}catch(o){console.error(o),r=o}return b(r)?r:typeof(r==null?void 0:r.then)=="function"?c(r):h(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

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