@molin.ai/shop-ai 0.6.45 → 0.6.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -229,7 +229,7 @@ var ep=Object.defineProperty;var ha=n=>{throw TypeError(n)};var tp=(n,e,t)=>e in
|
|
|
229
229
|
</div>
|
|
230
230
|
|
|
231
231
|
<mw-chat-background
|
|
232
|
-
class="mx-auto
|
|
232
|
+
class="mx-auto flex-grow"
|
|
233
233
|
.examples="${this.messages.length>0?[]:this.config.examples}"
|
|
234
234
|
color="${this.config.color}"
|
|
235
235
|
@mw:example-click="${$(this,se,zl)}"></mw-chat-background>
|
|
@@ -371,7 +371,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
371
371
|
:host {
|
|
372
372
|
all: initial; /* reset all properties that can pierce the shadow DOM */
|
|
373
373
|
}
|
|
374
|
-
`),C(Li,"properties",{cdn:{type:String},widgetId:{type:String,attribute:"widget"},state:{type:String}});customElements.define("molin-shop-ai-launcher",Li);var us,Hn,zn,dn,Ni,ji,ls=class{constructor(e,t,i,r=window.history){b(this,us);b(this,Hn);b(this,zn);b(this,dn);b(this,Ni,!1);b(this,ji,()=>{h(this,Hn).test(window.location.pathname)&&h(this,zn).navigated()});S(this,us,e),S(this,Hn,t),S(this,zn,i),S(this,dn,r),e.addController(this)}hostConnected(){window.addEventListener("pageshow",h(this,ji));let e=h(this,dn).pushState;h(this,dn).pushState=(...t)=>{if(e.call(h(this,dn),...t),!h(this,Ni))try{let i=new URL(t[2],window.location.origin);h(this,Hn).test(i.pathname)&&h(this,zn).navigated()}catch{}}}hostDisconnected(){window.removeEventListener("pageshow",h(this,ji)),S(this,Ni,!0)}};us=new WeakMap,Hn=new WeakMap,zn=new WeakMap,dn=new WeakMap,Ni=new WeakMap,ji=new WeakMap;function zc({min:n,max:e}){return Math.floor(Math.random()*(e-n+1))+n*1e3}var zt,dt,aa,qi,oa=class{constructor(e=window.localStorage){b(this,dt);b(this,zt);S(this,zt,e)}setex(e,t,i){return h(this,zt).setItem(e,$(this,dt,qi).call(this,{value:$(this,dt,qi).call(this,t),expiresAt:Date.now()+i*1e3})||"")}set(e,t){return h(this,zt).setItem(e,$(this,dt,qi).call(this,{value:$(this,dt,qi).call(this,t)})||"")}get(e){let t=h(this,zt).getItem(e);if(!t)return;let i=$(this,dt,aa).call(this,t);if(i){if(i.expiresAt&&i.expiresAt<Date.now()){h(this,zt).removeItem(e);return}return $(this,dt,aa).call(this,i.value)}}};zt=new WeakMap,dt=new WeakSet,aa=function(e){if(!(typeof e!="string"||e===""))try{return JSON.parse(e)}catch{return}},qi=function(e){if(e!==void 0)try{return JSON.stringify(e)}catch{return}};var la=new oa;function cs(n,e=""){return Object.entries(n).filter(([t,i])=>i).map(([t,i])=>`${e}${t}-[${i}]`).join(" ")}var Wc="molin-shop-ai-widget-open",ps,Hi,ua,Ae,fs,le,Bi,Vc,Gc,Xc,Jc,Wn,Ui=class extends z(U){constructor(){super();b(this,le);b(this,ps,new Dt(this,{onError:console.error}));b(this,Hi);b(this,ua,new ls(this,/checkout|order|thank-you|thank_you/i,{navigated:()=>{let t=h(this,le,Vc);t&&De("ShopAssistant: user visited checkout page",{widgetId:this.widgetId,conversationId:t.conversationId,hasSentMessage:t.messages.length>0})}}));b(this,Ae,!1);b(this,fs,{onError:t=>{alert(t.error),console.error(t.widgetId,t.error),De("ShopAssistant: error",t)},onNewMessageStartedStreaming:t=>De("ShopAssistant: user received bot message (streaming started)",t),onMessageEndedStreaming:t=>De("ShopAssistant: user received bot message (streaming ended)",t),onUserCanceledStreaming:t=>De("ShopAssistant: user canceled streaming",t),onUserClickedLink:t=>De("ShopAssistant: user clicked link",t),onUserSentInput:t=>De("ShopAssistant: user sent input",t)});this.cdn="https://widget.molin.ai",this.widgetId="",this._dialogAlreadyShown=!1}get config(){return h(this,Hi)||h(this,ps).data}render(){if(!this.config)return N;let t=this.config.bubble.position;"left"in t&&"right"in t&&delete t.right;let i=[cs(this.config.bubble.position),cs(this.config.bubble.mobilePosition||{},"max-sm:")].join(" "),r=cs(this.config.bubble.position),s=Object.entries(this.config.bubble.position).filter(([a,l])=>l).map(([a,l])=>{let u=`sm:${a}-[${l}]`;return a==="left"&&(u+=" sm:right-auto"),a==="right"&&(u+=" sm:left-auto"),u}).join(" "),o=s;return this.config.hidden?N:D`
|
|
374
|
+
`),C(Li,"properties",{cdn:{type:String},widgetId:{type:String,attribute:"widget"},state:{type:String}});customElements.define("molin-shop-ai-launcher",Li);var us,Hn,zn,dn,Ni,ji,ls=class{constructor(e,t,i,r=window.history){b(this,us);b(this,Hn);b(this,zn);b(this,dn);b(this,Ni,!1);b(this,ji,()=>{h(this,Hn).test(window.location.pathname)&&h(this,zn).navigated()});S(this,us,e),S(this,Hn,t),S(this,zn,i),S(this,dn,r),e.addController(this)}hostConnected(){window.addEventListener("pageshow",h(this,ji));let e=h(this,dn).pushState;h(this,dn).pushState=(...t)=>{if(e.call(h(this,dn),...t),!h(this,Ni))try{let i=new URL(t[2],window.location.origin);h(this,Hn).test(i.pathname)&&h(this,zn).navigated()}catch{}}}hostDisconnected(){window.removeEventListener("pageshow",h(this,ji)),S(this,Ni,!0)}};us=new WeakMap,Hn=new WeakMap,zn=new WeakMap,dn=new WeakMap,Ni=new WeakMap,ji=new WeakMap;function zc({min:n,max:e}){return Math.floor(Math.random()*(e-n+1))+n*1e3}var zt,dt,aa,qi,oa=class{constructor(e=window.localStorage){b(this,dt);b(this,zt);S(this,zt,e)}setex(e,t,i){return h(this,zt).setItem(e,$(this,dt,qi).call(this,{value:$(this,dt,qi).call(this,t),expiresAt:Date.now()+i*1e3})||"")}set(e,t){return h(this,zt).setItem(e,$(this,dt,qi).call(this,{value:$(this,dt,qi).call(this,t)})||"")}get(e){let t=h(this,zt).getItem(e);if(!t)return;let i=$(this,dt,aa).call(this,t);if(i){if(i.expiresAt&&i.expiresAt<Date.now()){h(this,zt).removeItem(e);return}return $(this,dt,aa).call(this,i.value)}}};zt=new WeakMap,dt=new WeakSet,aa=function(e){if(!(typeof e!="string"||e===""))try{return JSON.parse(e)}catch{return}},qi=function(e){if(e!==void 0)try{return JSON.stringify(e)}catch{return}};var la=new oa;function cs(n,e=""){return Object.entries(n).filter(([t,i])=>i).map(([t,i])=>`${e}${t}-[${i}]`).join(" ")}var Wc="molin-shop-ai-widget-open",ps,Hi,ua,Ae,fs,le,Bi,Vc,Gc,Xc,Jc,Wn,Ui=class extends z(U){constructor(){super();b(this,le);b(this,ps,new Dt(this,{onError:console.error}));b(this,Hi);b(this,ua,new ls(this,/checkout|order|thank-you|thank_you/i,{navigated:()=>{let t=h(this,le,Vc);t&&De("ShopAssistant: user visited checkout page",{widgetId:this.widgetId,conversationId:t.conversationId,hasSentMessage:t.messages.length>0})}}));b(this,Ae,!1);b(this,fs,{onError:t=>{alert(t.error),console.error(t.widgetId,t.error),De("ShopAssistant: error",t)},onNewMessageStartedStreaming:t=>De("ShopAssistant: user received bot message (streaming started)",t),onMessageEndedStreaming:t=>De("ShopAssistant: user received bot message (streaming ended)",t),onUserCanceledStreaming:t=>De("ShopAssistant: user canceled streaming",t),onUserClickedLink:t=>De("ShopAssistant: user clicked link",t),onUserSentInput:t=>De("ShopAssistant: user sent input",t)});this.cdn="https://widget.molin.ai",this.widgetId="",this._dialogAlreadyShown=!1}get config(){return h(this,Hi)||h(this,ps).data}render(){if(!this.config)return N;let t=this.config.bubble.position;"left"in t&&"right"in t&&delete t.right;let i=[cs(this.config.bubble.position),cs(this.config.bubble.mobilePosition||{},"max-sm:")].join(" "),r=cs(this.config.bubble.position),s=Object.entries(this.config.bubble.position).filter(([a,l])=>l).filter(([a])=>a==="left"||a==="right").map(([a,l])=>{let u=`sm:${a}-[${l}]`;return a==="left"&&(u+=" sm:right-auto"),a==="right"&&(u+=" sm:left-auto"),u}).join(" "),o=s;return this.config.hidden?N:D`
|
|
375
375
|
<mw-bubble class="${i} ${h(this,Ae)?"opacity-0":"opacity-100"} fixed z-[2147483647] transition-opacity" @click="${$(this,le,Xc)}" state="${h(this,Ae)?"close":"open"}" src="${this.config.bubble?.imageUrl||""}"></mw-bubble>
|
|
376
376
|
|
|
377
377
|
<!-- only load the component if enabled on any platform -->
|
|
@@ -389,7 +389,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
389
389
|
|
|
390
390
|
<!-- On first render, do not render the dialog, so it does not connect to backend. Once it's rendered once, it's never removed from the DOM. -->
|
|
391
391
|
${this._dialogAlreadyShown?D`
|
|
392
|
-
<div
|
|
392
|
+
<div
|
|
393
|
+
class="${h(this,Ae)?"visible opacity-100 translate-y-0":"invisible opacity-0 translate-y-3"} ${s} fixed inset-0 z-[2147483647] bg-white font-sans text-[16px] leading-normal text-gray-800 shadow-2xl transition-all sm:bottom-[1.5rem] sm:top-auto sm:h-[92%] sm:max-h-[800px] sm:w-[calc(100dvh*0.50)] sm:min-w-[300px] sm:max-w-[400px] sm:rounded-[36px] 2xl:max-w-[420px]">
|
|
393
394
|
<mw-chat .config="${{...this.config,widgetId:this.widgetId}}" .callbacks="${h(this,fs)}" ?show-close="${!0}" @mw:close-click="${$(this,le,Jc)}">
|
|
394
395
|
<slot name="banner" slot="banner"></slot>
|
|
395
396
|
</mw-chat>
|