@blotoutio/providers-shop-gpt-sdk 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +579 -263
- package/index.js +579 -263
- package/index.mjs +579 -263
- package/package.json +1 -1
package/index.mjs
CHANGED
@@ -300,6 +300,7 @@ const isoCountries = new Map([
|
|
300
300
|
new Set(isoCountries.keys());
|
301
301
|
|
302
302
|
const packageName = 'shopGPT';
|
303
|
+
const DEFAULT_MAX_THREAD_AGE = 14;
|
303
304
|
const previewKeyName = 'previewShopGPT';
|
304
305
|
|
305
306
|
const canLog = () => {
|
@@ -382,6 +383,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
|
|
382
383
|
message: data.message,
|
383
384
|
products: (_a = data.products) === null || _a === void 0 ? void 0 : _a.filter((item) => !!item).map((item) => ({ ...item, quantity: 1 })),
|
384
385
|
chatTitle: data.chatTitle,
|
386
|
+
welcomePrompts: data.welcomePrompts,
|
385
387
|
};
|
386
388
|
};
|
387
389
|
const fetchChatHistory = async (threadId) => {
|
@@ -488,7 +490,7 @@ const init = (params) => {
|
|
488
490
|
// exit if not in top window
|
489
491
|
return;
|
490
492
|
}
|
491
|
-
const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
|
493
|
+
const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, latestThreadLoad, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
|
492
494
|
let shouldShowUI = enabled;
|
493
495
|
if (!enabled && hasPreviewKey()) {
|
494
496
|
logger.log('Enabling UI in preview mode');
|
@@ -517,6 +519,7 @@ const init = (params) => {
|
|
517
519
|
brandName,
|
518
520
|
quickPrompts,
|
519
521
|
merchantImage,
|
522
|
+
latestThreadLoad: latestThreadLoad !== null && latestThreadLoad !== void 0 ? latestThreadLoad : DEFAULT_MAX_THREAD_AGE,
|
520
523
|
});
|
521
524
|
}
|
522
525
|
};
|
@@ -574,58 +577,51 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
574
577
|
* Copyright 2019 Google LLC
|
575
578
|
* SPDX-License-Identifier: BSD-3-Clause
|
576
579
|
*/
|
577
|
-
const t$
|
580
|
+
const t$2=globalThis,e$7=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$1=Symbol(),o$5=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s$1)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$7&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$5=t=>new n$3("string"==typeof t?t:t+"",void 0,s$1),i$4=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$3(o,t,s$1)},S$1=(s,o)=>{if(e$7)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$2.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$7?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$5(e)})(t):t;
|
578
581
|
|
579
582
|
/**
|
580
583
|
* @license
|
581
584
|
* Copyright 2017 Google LLC
|
582
585
|
* SPDX-License-Identifier: BSD-3-Clause
|
583
|
-
*/const{is:i$3,defineProperty:e$
|
586
|
+
*/const{is:i$3,defineProperty:e$6,getOwnPropertyDescriptor:r$4,getOwnPropertyNames:h$1,getOwnPropertySymbols:o$4,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$3(t,s),y$1={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let b$1 = class b extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=y$1){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,s);void 0!==r&&e$6(this.prototype,t,r);}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r$4(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get(){return e?.call(this)},set(s){const r=e?.call(this);h.call(this,s),this.requestUpdate(t,r,i);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y$1}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...h$1(t),...o$4(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return !1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$EC(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==r?this.removeAttribute(e):this.setAttribute(e,r),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e,this[e]=r.fromAttribute(s,t.type),this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??f$1)(this[t],s))return;this.P(t,s,i);}!1===this.isUpdatePending&&(this._$ES=this._$ET());}P(t,s,i){this._$AL.has(t)||this._$AL.set(t,s),!0===i.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t);}async _$ET(){this.isUpdatePending=!0;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t)!0!==i.wrapped||this._$AL.has(s)||void 0===this[s]||this.P(s,this[s],i);}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EU();}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t);}_$EU(){this._$AL=new Map,this.isUpdatePending=!1;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return !0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU();}updated(t){}firstUpdated(t){}};b$1.elementStyles=[],b$1.shadowRootOptions={mode:"open"},b$1[d$1("elementProperties")]=new Map,b$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:b$1}),(a$1.reactiveElementVersions??=[]).push("2.0.4");
|
584
587
|
|
585
588
|
/**
|
586
589
|
* @license
|
587
590
|
* Copyright 2017 Google LLC
|
588
591
|
* SPDX-License-Identifier: BSD-3-Clause
|
589
592
|
*/
|
590
|
-
const t$
|
593
|
+
const t$1=globalThis,i$2=t$1.trustedTypes,s=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$5="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$1=`<${o$3}>`,r$3=document,l=()=>r$3.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),b=y(2),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r$3.createTreeWalker(r$3,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n$1:d>=0?(o.push(a),s.slice(0,d)+e$5+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$5)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$2?i$2.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$3)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r$3.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r$3).importNode(i,!0);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r$3,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$3.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t$1.litHtmlPolyfillSupport;j?.(N,R),(t$1.litHtmlVersions??=[]).push("3.2.1");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l(),t),t,void 0,s??{});}return h._$AI(t),h};
|
591
594
|
|
592
595
|
/**
|
593
596
|
* @license
|
594
597
|
* Copyright 2017 Google LLC
|
595
598
|
* SPDX-License-Identifier: BSD-3-Clause
|
596
|
-
*/let r$
|
599
|
+
*/let r$2 = class r extends b$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(s,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return T}};r$2._$litElement$=!0,r$2["finalized"]=!0,globalThis.litElementHydrateSupport?.({LitElement:r$2});const i$1=globalThis.litElementPolyfillSupport;i$1?.({LitElement:r$2});(globalThis.litElementVersions??=[]).push("4.1.1");
|
597
600
|
|
598
601
|
/**
|
599
602
|
* @license
|
600
603
|
* Copyright 2017 Google LLC
|
601
604
|
* SPDX-License-Identifier: BSD-3-Clause
|
602
|
-
*/
|
603
|
-
const t$2=t=>(e,o)=>{void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
|
605
|
+
*/const o$2={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1},r$1=(t=o$2,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.P(o,void 0,t),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,r?{...t,wrapped:!0}:t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
|
604
606
|
|
605
607
|
/**
|
606
608
|
* @license
|
607
609
|
* Copyright 2017 Google LLC
|
608
610
|
* SPDX-License-Identifier: BSD-3-Clause
|
609
|
-
*/
|
610
|
-
|
611
|
-
/**
|
612
|
-
* @license
|
613
|
-
* Copyright 2017 Google LLC
|
614
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
615
|
-
*/function r$1(r){return n$1({...r,state:!0,attribute:!1})}
|
611
|
+
*/function r(r){return n({...r,state:!0,attribute:!1})}
|
616
612
|
|
617
613
|
/**
|
618
614
|
* @license
|
619
615
|
* Copyright 2017 Google LLC
|
620
616
|
* SPDX-License-Identifier: BSD-3-Clause
|
621
617
|
*/
|
622
|
-
const e$
|
618
|
+
const e$4=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
623
619
|
|
624
620
|
/**
|
625
621
|
* @license
|
626
622
|
* Copyright 2017 Google LLC
|
627
623
|
* SPDX-License-Identifier: BSD-3-Clause
|
628
|
-
*/function e$
|
624
|
+
*/function e$3(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;if(r){const{get:e,set:r}="object"==typeof s?n:i??(()=>{const t=Symbol();return {get(){return this[t]},set(e){this[t]=e;}}})();return e$4(n,s,{get(){let t=e.call(this);return void 0===t&&(t=o(this),(null!==t||this.hasUpdated)&&r.call(this,t)),t}})}return e$4(n,s,{get(){return o(this)}})}}
|
629
625
|
|
630
626
|
const scrollBarStyles = i$4 `
|
631
627
|
::-webkit-scrollbar {
|
@@ -711,6 +707,35 @@ const shopGPTStyles = i$4 `
|
|
711
707
|
align-items: center;
|
712
708
|
box-shadow: 0 0 4px 1px #ffffff;
|
713
709
|
}
|
710
|
+
|
711
|
+
.chatbot-hover-text {
|
712
|
+
position: absolute;
|
713
|
+
color: #172a41;
|
714
|
+
padding: 8px;
|
715
|
+
white-space: nowrap;
|
716
|
+
font-size: 16px;
|
717
|
+
line-height: 21px;
|
718
|
+
opacity: 0;
|
719
|
+
transition: opacity 0.2s;
|
720
|
+
pointer-events: none;
|
721
|
+
|
722
|
+
top: calc(0% - 30%);
|
723
|
+
right: calc(100% + 5px);
|
724
|
+
|
725
|
+
border-radius: 5px 5px 0px;
|
726
|
+
background: #ffcc81;
|
727
|
+
box-shadow: 0px 4px 6px -1px rgba(0, 0, 0, 0.1),
|
728
|
+
0px 2px 4px -1px rgba(0, 0, 0, 0.06);
|
729
|
+
|
730
|
+
font-weight: 400;
|
731
|
+
line-height: 150%;
|
732
|
+
}
|
733
|
+
|
734
|
+
&:hover {
|
735
|
+
.chatbot-hover-text {
|
736
|
+
opacity: 1;
|
737
|
+
}
|
738
|
+
}
|
714
739
|
}
|
715
740
|
|
716
741
|
.mobile-version {
|
@@ -758,13 +783,13 @@ const shopGPTStyles = i$4 `
|
|
758
783
|
* Copyright 2017 Google LLC
|
759
784
|
* SPDX-License-Identifier: BSD-3-Clause
|
760
785
|
*/
|
761
|
-
const t
|
786
|
+
const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e$2=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
762
787
|
|
763
788
|
/**
|
764
789
|
* @license
|
765
790
|
* Copyright 2018 Google LLC
|
766
791
|
* SPDX-License-Identifier: BSD-3-Clause
|
767
|
-
*/const e$
|
792
|
+
*/const e$1=e$2(class extends i{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter((s=>t[s])).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return T}});
|
768
793
|
|
769
794
|
/**
|
770
795
|
* @license
|
@@ -919,11 +944,35 @@ const chatThreadsStyles = i$4 `
|
|
919
944
|
color: #677c95;
|
920
945
|
font-weight: 500;
|
921
946
|
text-transform: uppercase;
|
922
|
-
margin: 0
|
947
|
+
margin: 0;
|
923
948
|
max-height: 18px;
|
924
949
|
padding-left: 12px;
|
925
950
|
}
|
926
951
|
|
952
|
+
.trash-icon {
|
953
|
+
display: flex;
|
954
|
+
padding: 2px;
|
955
|
+
border-radius: 5px;
|
956
|
+
cursor: pointer;
|
957
|
+
align-items: center;
|
958
|
+
justify-content: center;
|
959
|
+
|
960
|
+
&:hover {
|
961
|
+
background: #dc3545;
|
962
|
+
|
963
|
+
path {
|
964
|
+
fill: white;
|
965
|
+
}
|
966
|
+
}
|
967
|
+
}
|
968
|
+
|
969
|
+
.title-wrapper {
|
970
|
+
display: flex;
|
971
|
+
justify-content: space-between;
|
972
|
+
align-items: center;
|
973
|
+
margin: 0 0 12px;
|
974
|
+
}
|
975
|
+
|
927
976
|
.threads {
|
928
977
|
flex: 1;
|
929
978
|
overflow-y: auto;
|
@@ -936,17 +985,6 @@ const chatThreadsStyles = i$4 `
|
|
936
985
|
|
937
986
|
.trash-icon {
|
938
987
|
display: none;
|
939
|
-
padding: 2px;
|
940
|
-
cursor: pointer;
|
941
|
-
|
942
|
-
&:hover {
|
943
|
-
border-radius: 5px;
|
944
|
-
background: #dc3545;
|
945
|
-
|
946
|
-
path {
|
947
|
-
fill: white;
|
948
|
-
}
|
949
|
-
}
|
950
988
|
}
|
951
989
|
|
952
990
|
&:hover {
|
@@ -995,13 +1033,11 @@ const chatThreadsStyles = i$4 `
|
|
995
1033
|
}
|
996
1034
|
`;
|
997
1035
|
|
998
|
-
|
999
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1000
|
-
class LoadSpinner extends r$3 {
|
1036
|
+
class LoadSpinner extends r$2 {
|
1001
1037
|
render() {
|
1002
1038
|
return x ` <div class="loader"><div class="spinner"></div></div> `;
|
1003
1039
|
}
|
1004
|
-
}
|
1040
|
+
}
|
1005
1041
|
LoadSpinner.styles = [
|
1006
1042
|
i$4 `
|
1007
1043
|
.loader {
|
@@ -1035,14 +1071,15 @@ LoadSpinner.styles = [
|
|
1035
1071
|
}
|
1036
1072
|
`,
|
1037
1073
|
];
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1074
|
+
if (!customElements.get('load-spinner')) {
|
1075
|
+
customElements.define('load-spinner', LoadSpinner);
|
1076
|
+
}
|
1077
|
+
|
1078
|
+
class ChatThreads extends r$2 {
|
1079
|
+
constructor() {
|
1080
|
+
super(...arguments);
|
1081
|
+
this.deleteAllThreads = false;
|
1082
|
+
}
|
1046
1083
|
getDomain() {
|
1047
1084
|
var _a;
|
1048
1085
|
if ((_a = this.merchantUrl) === null || _a === void 0 ? void 0 : _a.startsWith('https://')) {
|
@@ -1051,6 +1088,14 @@ class ChatThreads extends r$3 {
|
|
1051
1088
|
return `https://${this.merchantUrl}`;
|
1052
1089
|
}
|
1053
1090
|
handleThreadDelete() {
|
1091
|
+
if (this.deleteAllThreads) {
|
1092
|
+
this.dispatchEvent(new CustomEvent('delete-all-threads', {
|
1093
|
+
composed: true,
|
1094
|
+
bubbles: true,
|
1095
|
+
}));
|
1096
|
+
this.deleteAllThreads = false;
|
1097
|
+
return;
|
1098
|
+
}
|
1054
1099
|
if (!this.deleteThreadId) {
|
1055
1100
|
return;
|
1056
1101
|
}
|
@@ -1070,12 +1115,27 @@ class ChatThreads extends r$3 {
|
|
1070
1115
|
}
|
1071
1116
|
return x `
|
1072
1117
|
<div class="history">
|
1073
|
-
<
|
1118
|
+
<div class="title-wrapper">
|
1119
|
+
<p class="title">History</p>
|
1120
|
+
${this.chatThreads.size
|
1121
|
+
? x `<div
|
1122
|
+
class="trash-icon"
|
1123
|
+
@click=${() => {
|
1124
|
+
if (this.isLoading || this.isTyping) {
|
1125
|
+
return;
|
1126
|
+
}
|
1127
|
+
this.deleteAllThreads = true;
|
1128
|
+
}}
|
1129
|
+
>
|
1130
|
+
${trashIcon}
|
1131
|
+
</div>`
|
1132
|
+
: E}
|
1133
|
+
</div>
|
1074
1134
|
${this.chatThreads.size
|
1075
1135
|
? x `<div class="threads">
|
1076
1136
|
${o$1(this.chatThreads.values(), (thread) => x `
|
1077
1137
|
<div
|
1078
|
-
class=${e$
|
1138
|
+
class=${e$1({
|
1079
1139
|
'thread-wrapper': true,
|
1080
1140
|
active: this.selectedThreadId === thread.threadId,
|
1081
1141
|
disabled: this.isTyping,
|
@@ -1129,52 +1189,66 @@ class ChatThreads extends r$3 {
|
|
1129
1189
|
</a>
|
1130
1190
|
</div>`
|
1131
1191
|
: E}
|
1132
|
-
${this.deleteThreadId
|
1192
|
+
${this.deleteThreadId || this.deleteAllThreads
|
1133
1193
|
? x `
|
1134
1194
|
<confirm-dialog
|
1135
1195
|
@accept=${this.handleThreadDelete}
|
1136
|
-
@decline=${() =>
|
1196
|
+
@decline=${() => {
|
1197
|
+
this.deleteThreadId = '';
|
1198
|
+
this.deleteAllThreads = false;
|
1199
|
+
}}
|
1137
1200
|
>
|
1138
|
-
<h2 slot="title">
|
1201
|
+
<h2 slot="title">
|
1202
|
+
${this.deleteAllThreads
|
1203
|
+
? 'Delete Entire Chat History?'
|
1204
|
+
: 'Delete Chat?'}
|
1205
|
+
</h2>
|
1139
1206
|
<p slot="content">
|
1140
1207
|
This action cannot be undone. Are you sure you want to delete
|
1141
|
-
|
1208
|
+
${this.deleteAllThreads
|
1209
|
+
? ' the entire chat history'
|
1210
|
+
: x `<b
|
1211
|
+
>"${this.chatThreads.get(this.deleteThreadId).title}"</b
|
1212
|
+
>`}?
|
1142
1213
|
</p>
|
1143
1214
|
</confirm-dialog>
|
1144
1215
|
`
|
1145
1216
|
: E}
|
1146
1217
|
`;
|
1147
1218
|
}
|
1148
|
-
}
|
1219
|
+
}
|
1149
1220
|
ChatThreads.styles = [chatThreadsStyles];
|
1150
1221
|
__decorate([
|
1151
|
-
n
|
1222
|
+
n({ type: Object }),
|
1152
1223
|
__metadata("design:type", Map)
|
1153
1224
|
], ChatThreads.prototype, "chatThreads", void 0);
|
1154
1225
|
__decorate([
|
1155
|
-
n
|
1226
|
+
n({ type: String }),
|
1156
1227
|
__metadata("design:type", Object)
|
1157
1228
|
], ChatThreads.prototype, "merchantUrl", void 0);
|
1158
1229
|
__decorate([
|
1159
|
-
n
|
1230
|
+
n({ type: Boolean }),
|
1160
1231
|
__metadata("design:type", Boolean)
|
1161
1232
|
], ChatThreads.prototype, "isLoading", void 0);
|
1162
1233
|
__decorate([
|
1163
|
-
n
|
1234
|
+
n({ type: Boolean }),
|
1164
1235
|
__metadata("design:type", Boolean)
|
1165
1236
|
], ChatThreads.prototype, "isTyping", void 0);
|
1166
1237
|
__decorate([
|
1167
|
-
n
|
1238
|
+
n({ type: String }),
|
1168
1239
|
__metadata("design:type", String)
|
1169
1240
|
], ChatThreads.prototype, "selectedThreadId", void 0);
|
1170
1241
|
__decorate([
|
1171
|
-
r
|
1242
|
+
r(),
|
1172
1243
|
__metadata("design:type", String)
|
1173
1244
|
], ChatThreads.prototype, "deleteThreadId", void 0);
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
], ChatThreads);
|
1245
|
+
__decorate([
|
1246
|
+
r(),
|
1247
|
+
__metadata("design:type", Object)
|
1248
|
+
], ChatThreads.prototype, "deleteAllThreads", void 0);
|
1249
|
+
if (!customElements.get('chat-threads')) {
|
1250
|
+
customElements.define('chat-threads', ChatThreads);
|
1251
|
+
}
|
1178
1252
|
|
1179
1253
|
const productsSectionStyles = i$4 `
|
1180
1254
|
:host {
|
@@ -1362,9 +1436,7 @@ const productItemStyles = i$4 `
|
|
1362
1436
|
}
|
1363
1437
|
`;
|
1364
1438
|
|
1365
|
-
|
1366
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1367
|
-
class ProductItem extends r$3 {
|
1439
|
+
class ProductItem extends r$2 {
|
1368
1440
|
getLocalPrice(price) {
|
1369
1441
|
if (!this.siteCurrency) {
|
1370
1442
|
return price;
|
@@ -1372,6 +1444,16 @@ class ProductItem extends r$3 {
|
|
1372
1444
|
const localPrice = parseFloat(price) * this.siteCurrency.rate;
|
1373
1445
|
return formatMoney(localPrice, this.siteCurrency.currency);
|
1374
1446
|
}
|
1447
|
+
getComparedAtPrice(comparedAtPrice, price) {
|
1448
|
+
if (!comparedAtPrice ||
|
1449
|
+
comparedAtPrice === price ||
|
1450
|
+
parseFloat(comparedAtPrice) <= parseFloat(price)) {
|
1451
|
+
return E;
|
1452
|
+
}
|
1453
|
+
return x `<p class="price-compared">
|
1454
|
+
${this.getLocalPrice(comparedAtPrice)}
|
1455
|
+
</p>`;
|
1456
|
+
}
|
1375
1457
|
redirect(url) {
|
1376
1458
|
var _a;
|
1377
1459
|
if (!url) {
|
@@ -1405,13 +1487,7 @@ class ProductItem extends r$3 {
|
|
1405
1487
|
</p>
|
1406
1488
|
${this.renderVariantTitles()}
|
1407
1489
|
<div class="prices">
|
1408
|
-
${this.product.variants[0].comparedAtPrice
|
1409
|
-
this.product.variants[0].comparedAtPrice !==
|
1410
|
-
this.product.variants[0].price
|
1411
|
-
? x `<p class="price-compared">
|
1412
|
-
${this.getLocalPrice(this.product.variants[0].comparedAtPrice)}
|
1413
|
-
</p>`
|
1414
|
-
: E}
|
1490
|
+
${this.getComparedAtPrice(this.product.variants[0].comparedAtPrice, this.product.variants[0].price)}
|
1415
1491
|
<p>${this.getLocalPrice(this.product.variants[0].price)}</p>
|
1416
1492
|
</div>
|
1417
1493
|
<button
|
@@ -1424,20 +1500,19 @@ class ProductItem extends r$3 {
|
|
1424
1500
|
</div>
|
1425
1501
|
`;
|
1426
1502
|
}
|
1427
|
-
}
|
1503
|
+
}
|
1428
1504
|
ProductItem.styles = [productItemStyles];
|
1429
1505
|
__decorate([
|
1430
|
-
n
|
1506
|
+
n({ type: Object }),
|
1431
1507
|
__metadata("design:type", Object)
|
1432
1508
|
], ProductItem.prototype, "product", void 0);
|
1433
1509
|
__decorate([
|
1434
|
-
n
|
1510
|
+
n({ type: Object }),
|
1435
1511
|
__metadata("design:type", Object)
|
1436
1512
|
], ProductItem.prototype, "siteCurrency", void 0);
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
], ProductItem);
|
1513
|
+
if (!customElements.get('product-item')) {
|
1514
|
+
customElements.define('product-item', ProductItem);
|
1515
|
+
}
|
1441
1516
|
|
1442
1517
|
const productsListStyles = i$4 `
|
1443
1518
|
.products::-webkit-scrollbar {
|
@@ -1465,6 +1540,8 @@ const productsListStyles = i$4 `
|
|
1465
1540
|
gap: 24px;
|
1466
1541
|
overflow-x: auto;
|
1467
1542
|
scrollbar-width: none;
|
1543
|
+
margin-left: -10px;
|
1544
|
+
padding-left: 10px;
|
1468
1545
|
}
|
1469
1546
|
|
1470
1547
|
.scroll-btns {
|
@@ -1499,21 +1576,23 @@ const productsListStyles = i$4 `
|
|
1499
1576
|
}
|
1500
1577
|
`;
|
1501
1578
|
|
1502
|
-
|
1503
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1504
|
-
class ProductsList extends r$3 {
|
1579
|
+
class ProductsList extends r$2 {
|
1505
1580
|
constructor() {
|
1506
1581
|
super(...arguments);
|
1507
1582
|
this.showButtons = true;
|
1508
1583
|
this.updateButtonsState = () => {
|
1509
|
-
if (!this.
|
1584
|
+
if (!this.productsEle) {
|
1510
1585
|
return;
|
1511
1586
|
}
|
1512
1587
|
const { scrollWidth, clientWidth } = this.productsEle;
|
1513
1588
|
this.showButtons = scrollWidth > clientWidth;
|
1514
|
-
this.leftBtnEle
|
1589
|
+
if (this.leftBtnEle) {
|
1590
|
+
this.leftBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft === 0);
|
1591
|
+
}
|
1515
1592
|
const maxScroll = this.productsEle.scrollWidth - this.productsEle.clientWidth;
|
1516
|
-
this.rightBtnEle
|
1593
|
+
if (this.rightBtnEle) {
|
1594
|
+
this.rightBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft >= maxScroll - 1);
|
1595
|
+
}
|
1517
1596
|
};
|
1518
1597
|
}
|
1519
1598
|
connectedCallback() {
|
@@ -1549,7 +1628,7 @@ class ProductsList extends r$3 {
|
|
1549
1628
|
<div class="products" @scroll=${this.updateButtonsState}>
|
1550
1629
|
${o$1(this.products, (product) => x `
|
1551
1630
|
<div
|
1552
|
-
class=${e$
|
1631
|
+
class=${e$1({
|
1553
1632
|
'product-container': true,
|
1554
1633
|
modal: this.viewType === 'modal',
|
1555
1634
|
})}
|
@@ -1574,40 +1653,37 @@ class ProductsList extends r$3 {
|
|
1574
1653
|
</div>
|
1575
1654
|
`;
|
1576
1655
|
}
|
1577
|
-
}
|
1656
|
+
}
|
1578
1657
|
ProductsList.styles = [productsListStyles];
|
1579
1658
|
__decorate([
|
1580
|
-
n
|
1659
|
+
n({ type: Array }),
|
1581
1660
|
__metadata("design:type", Array)
|
1582
1661
|
], ProductsList.prototype, "products", void 0);
|
1583
1662
|
__decorate([
|
1584
|
-
n
|
1663
|
+
n({ type: Object }),
|
1585
1664
|
__metadata("design:type", Object)
|
1586
1665
|
], ProductsList.prototype, "siteCurrency", void 0);
|
1587
1666
|
__decorate([
|
1588
|
-
r
|
1667
|
+
r(),
|
1589
1668
|
__metadata("design:type", Object)
|
1590
1669
|
], ProductsList.prototype, "showButtons", void 0);
|
1591
1670
|
__decorate([
|
1592
|
-
e$
|
1671
|
+
e$3('.left-btn'),
|
1593
1672
|
__metadata("design:type", Object)
|
1594
1673
|
], ProductsList.prototype, "leftBtnEle", void 0);
|
1595
1674
|
__decorate([
|
1596
|
-
e$
|
1675
|
+
e$3('.right-btn'),
|
1597
1676
|
__metadata("design:type", Object)
|
1598
1677
|
], ProductsList.prototype, "rightBtnEle", void 0);
|
1599
1678
|
__decorate([
|
1600
|
-
e$
|
1679
|
+
e$3('.products'),
|
1601
1680
|
__metadata("design:type", Object)
|
1602
1681
|
], ProductsList.prototype, "productsEle", void 0);
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
let ProductsSection =
|
1609
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1610
|
-
class ProductsSection extends r$3 {
|
1682
|
+
if (!customElements.get('products-list')) {
|
1683
|
+
customElements.define('products-list', ProductsList);
|
1684
|
+
}
|
1685
|
+
|
1686
|
+
class ProductsSection extends r$2 {
|
1611
1687
|
connectedCallback() {
|
1612
1688
|
super.connectedCallback();
|
1613
1689
|
}
|
@@ -1623,7 +1699,7 @@ class ProductsSection extends r$3 {
|
|
1623
1699
|
`;
|
1624
1700
|
}
|
1625
1701
|
render() {
|
1626
|
-
if (this.isLoadingHistory) {
|
1702
|
+
if (this.isLoadingHistory || this.isLoadingThreads) {
|
1627
1703
|
return x ` <load-spinner></load-spinner> `;
|
1628
1704
|
}
|
1629
1705
|
if (!this.products.length) {
|
@@ -1652,40 +1728,43 @@ class ProductsSection extends r$3 {
|
|
1652
1728
|
</div>
|
1653
1729
|
`;
|
1654
1730
|
}
|
1655
|
-
}
|
1731
|
+
}
|
1656
1732
|
ProductsSection.styles = [productsSectionStyles];
|
1657
1733
|
__decorate([
|
1658
|
-
n
|
1734
|
+
n({ type: String }),
|
1659
1735
|
__metadata("design:type", Object)
|
1660
1736
|
], ProductsSection.prototype, "merchantImage", void 0);
|
1661
1737
|
__decorate([
|
1662
|
-
n
|
1738
|
+
n({ type: Array }),
|
1663
1739
|
__metadata("design:type", Array)
|
1664
1740
|
], ProductsSection.prototype, "products", void 0);
|
1665
1741
|
__decorate([
|
1666
|
-
n
|
1742
|
+
n({ type: Boolean }),
|
1667
1743
|
__metadata("design:type", Boolean)
|
1668
1744
|
], ProductsSection.prototype, "isLoadingHistory", void 0);
|
1669
1745
|
__decorate([
|
1670
|
-
n
|
1746
|
+
n({ type: Object }),
|
1671
1747
|
__metadata("design:type", Object)
|
1672
1748
|
], ProductsSection.prototype, "siteCurrency", void 0);
|
1673
1749
|
__decorate([
|
1674
|
-
|
1750
|
+
n({ type: Boolean }),
|
1751
|
+
__metadata("design:type", Boolean)
|
1752
|
+
], ProductsSection.prototype, "isLoadingThreads", void 0);
|
1753
|
+
__decorate([
|
1754
|
+
e$3('.left-btn'),
|
1675
1755
|
__metadata("design:type", Object)
|
1676
1756
|
], ProductsSection.prototype, "leftBtnEle", void 0);
|
1677
1757
|
__decorate([
|
1678
|
-
e$
|
1758
|
+
e$3('.right-btn'),
|
1679
1759
|
__metadata("design:type", Object)
|
1680
1760
|
], ProductsSection.prototype, "rightBtnEle", void 0);
|
1681
1761
|
__decorate([
|
1682
|
-
e$
|
1762
|
+
e$3('.products'),
|
1683
1763
|
__metadata("design:type", Object)
|
1684
1764
|
], ProductsSection.prototype, "productsEle", void 0);
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
], ProductsSection);
|
1765
|
+
if (!customElements.get('products-section')) {
|
1766
|
+
customElements.define('products-section', ProductsSection);
|
1767
|
+
}
|
1689
1768
|
|
1690
1769
|
const chatSectionStyles = i$4 `
|
1691
1770
|
:host {
|
@@ -1865,6 +1944,20 @@ const chatSectionStyles = i$4 `
|
|
1865
1944
|
gap: 28px;
|
1866
1945
|
padding-bottom: 10px;
|
1867
1946
|
margin-bottom: -10px;
|
1947
|
+
margin-right: -10px;
|
1948
|
+
padding-right: 10px;
|
1949
|
+
margin-left: -10px;
|
1950
|
+
padding-left: 10px;
|
1951
|
+
background: linear-gradient(#f7f8fa80, #f7f8fa80),
|
1952
|
+
var(--shopgpt-merchant-img-url);
|
1953
|
+
background-position: center;
|
1954
|
+
background-repeat: no-repeat;
|
1955
|
+
background-size: contain;
|
1956
|
+
|
1957
|
+
&.loading {
|
1958
|
+
justify-content: center;
|
1959
|
+
align-items: center;
|
1960
|
+
}
|
1868
1961
|
|
1869
1962
|
.message:last-child {
|
1870
1963
|
margin-top: 10px;
|
@@ -2035,7 +2128,7 @@ const chatSectionStyles = i$4 `
|
|
2035
2128
|
.prompts {
|
2036
2129
|
display: flex;
|
2037
2130
|
justify-content: center;
|
2038
|
-
gap:
|
2131
|
+
gap: 10px;
|
2039
2132
|
flex-wrap: wrap;
|
2040
2133
|
|
2041
2134
|
.prompt {
|
@@ -2071,13 +2164,19 @@ const chatSectionStyles = i$4 `
|
|
2071
2164
|
0px 20px 20px 0px rgba(0, 0, 0, 0.08);
|
2072
2165
|
border-radius: 0px 0px 10px 10px;
|
2073
2166
|
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
font-weight: 700;
|
2079
|
-
line-height: 20px;
|
2167
|
+
.title-wrapper {
|
2168
|
+
display: flex;
|
2169
|
+
justify-content: space-between;
|
2170
|
+
align-items: center;
|
2080
2171
|
border-bottom: 1px solid #dbe2eb;
|
2172
|
+
padding: 10px 16px;
|
2173
|
+
|
2174
|
+
h2 {
|
2175
|
+
color: #172a41;
|
2176
|
+
font-size: 16px;
|
2177
|
+
font-weight: 700;
|
2178
|
+
line-height: 20px;
|
2179
|
+
}
|
2081
2180
|
}
|
2082
2181
|
|
2083
2182
|
.thread-titles-wrapper {
|
@@ -2399,9 +2498,7 @@ const profilePlusIcon = b `<svg xmlns="http://www.w3.org/2000/svg" width="56" he
|
|
2399
2498
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M21 7C22.7306 7 24.4223 7.51318 25.8612 8.47464C27.3002 9.4361 28.4217 10.8027 29.084 12.4015C29.7462 14.0004 29.9195 15.7597 29.5819 17.457C29.2443 19.1544 28.4109 20.7135 27.1872 21.9372C25.9635 23.1609 24.4044 23.9942 22.707 24.3319C21.0097 24.6695 19.2504 24.4962 17.6515 23.8339C16.0527 23.1717 14.6861 22.0502 13.7246 20.6112C12.7632 19.1723 12.25 17.4806 12.25 15.75C12.25 13.4294 13.1719 11.2038 14.8128 9.56282C16.4538 7.92187 18.6794 7 21 7ZM21 3.5C18.5772 3.5 16.2088 4.21845 14.1943 5.5645C12.1798 6.91054 10.6097 8.82373 9.68248 11.0621C8.75531 13.3005 8.51272 15.7636 8.98539 18.1399C9.45805 20.5161 10.6248 22.6989 12.3379 24.4121C14.0511 26.1252 16.2339 27.2919 18.6101 27.7646C20.9864 28.2373 23.4495 27.9947 25.6879 27.0675C27.9263 26.1403 29.8395 24.5702 31.1855 22.5557C32.5316 20.5412 33.25 18.1728 33.25 15.75C33.25 12.5011 31.9594 9.38526 29.6621 7.08794C27.3647 4.79062 24.2489 3.5 21 3.5ZM56 24.5H49V17.5H45.5V24.5H38.5V28H45.5V35H49V28H56V24.5ZM35 52.5H38.5V43.75C38.5 40.5011 37.2094 37.3853 34.9121 35.0879C32.6147 32.7906 29.4989 31.5 26.25 31.5H15.75C12.5011 31.5 9.38526 32.7906 7.08794 35.0879C4.79062 37.3853 3.5 40.5011 3.5 43.75V52.5H7V43.75C7 41.4294 7.92187 39.2038 9.56282 37.5628C11.2038 35.9219 13.4294 35 15.75 35H26.25C28.5706 35 30.7962 35.9219 32.4372 37.5628C34.0781 39.2038 35 41.4294 35 43.75V52.5Z" fill="#172A41"/>
|
2400
2499
|
</svg>`;
|
2401
2500
|
|
2402
|
-
|
2403
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2404
|
-
class PersonalizeDialog extends r$3 {
|
2501
|
+
class PersonalizeDialog extends r$2 {
|
2405
2502
|
constructor() {
|
2406
2503
|
super(...arguments);
|
2407
2504
|
this.isLoading = false;
|
@@ -2644,74 +2741,173 @@ class PersonalizeDialog extends r$3 {
|
|
2644
2741
|
</dialog>
|
2645
2742
|
`;
|
2646
2743
|
}
|
2647
|
-
}
|
2744
|
+
}
|
2648
2745
|
PersonalizeDialog.styles = [personalizeDialogStyles];
|
2649
2746
|
__decorate([
|
2650
|
-
e$
|
2747
|
+
e$3('dialog'),
|
2651
2748
|
__metadata("design:type", HTMLDialogElement)
|
2652
2749
|
], PersonalizeDialog.prototype, "dialogModal", void 0);
|
2653
2750
|
__decorate([
|
2654
|
-
e$
|
2751
|
+
e$3('.dropdown-list'),
|
2655
2752
|
__metadata("design:type", HTMLUListElement)
|
2656
2753
|
], PersonalizeDialog.prototype, "dropdownList", void 0);
|
2657
2754
|
__decorate([
|
2658
|
-
e$
|
2755
|
+
e$3('.dropdown-trigger'),
|
2659
2756
|
__metadata("design:type", HTMLDivElement)
|
2660
2757
|
], PersonalizeDialog.prototype, "dropdownTrigger", void 0);
|
2661
2758
|
__decorate([
|
2662
|
-
n
|
2759
|
+
n({ type: Array }),
|
2663
2760
|
__metadata("design:type", Array)
|
2664
2761
|
], PersonalizeDialog.prototype, "defaultProductHandles", void 0);
|
2665
2762
|
__decorate([
|
2666
|
-
n
|
2763
|
+
n({ type: Array }),
|
2667
2764
|
__metadata("design:type", Array)
|
2668
2765
|
], PersonalizeDialog.prototype, "defaultProfiles", void 0);
|
2669
2766
|
__decorate([
|
2670
|
-
n
|
2767
|
+
n({ type: Boolean }),
|
2671
2768
|
__metadata("design:type", Object)
|
2672
2769
|
], PersonalizeDialog.prototype, "isLoading", void 0);
|
2673
2770
|
__decorate([
|
2674
|
-
n
|
2771
|
+
n({ type: String }),
|
2675
2772
|
__metadata("design:type", Object)
|
2676
2773
|
], PersonalizeDialog.prototype, "state", void 0);
|
2677
2774
|
__decorate([
|
2678
|
-
n
|
2775
|
+
n({ type: String }),
|
2679
2776
|
__metadata("design:type", Object)
|
2680
2777
|
], PersonalizeDialog.prototype, "profileType", void 0);
|
2681
2778
|
__decorate([
|
2682
|
-
n
|
2779
|
+
n({ type: String }),
|
2683
2780
|
__metadata("design:type", Object)
|
2684
2781
|
], PersonalizeDialog.prototype, "selectedProfile", void 0);
|
2685
2782
|
__decorate([
|
2686
|
-
n
|
2783
|
+
n({ type: String }),
|
2687
2784
|
__metadata("design:type", Object)
|
2688
2785
|
], PersonalizeDialog.prototype, "visitorType", void 0);
|
2689
2786
|
__decorate([
|
2690
|
-
n
|
2787
|
+
n({ type: String }),
|
2691
2788
|
__metadata("design:type", Object)
|
2692
2789
|
], PersonalizeDialog.prototype, "productHandle", void 0);
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
], PersonalizeDialog);
|
2790
|
+
if (!customElements.get('personalize-dialog')) {
|
2791
|
+
customElements.define('personalize-dialog', PersonalizeDialog);
|
2792
|
+
}
|
2697
2793
|
|
2698
2794
|
/**
|
2699
2795
|
* @license
|
2700
2796
|
* Copyright 2017 Google LLC
|
2701
2797
|
* SPDX-License-Identifier: BSD-3-Clause
|
2702
|
-
*/
|
2703
|
-
|
2704
|
-
|
2798
|
+
*/class e extends i{constructor(i){if(super(i),this.it=E,i.type!==t.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===E||null==r)return this._t=void 0,this.it=r;if(r===T)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName="unsafeHTML",e.resultType=1;const o=e$2(e);
|
2799
|
+
|
2800
|
+
const markdown = (text) => {
|
2801
|
+
let src = text;
|
2802
|
+
const rx_space = /\t|\r|\uf8ff/g;
|
2803
|
+
const rx_hr = /^([*\-=_] *){3,}$/gm;
|
2804
|
+
const rx_blockquote = /\n *> *([^]*?)(?=(\n|$){2})/g;
|
2805
|
+
const rx_list = /\n( *)(?:[*\-+]|((\d+)|([a-z])|[A-Z])[.)]) +([^]*?)(?=(\n|$){2})/g;
|
2806
|
+
const rx_listjoin = /<\/(ol|ul)>\n\n<\1>/g;
|
2807
|
+
const rx_highlight = /(^|[^A-Za-z\d\\])(([*_])|(~)|(\^)|(--)|(\+\+)|`)(\2?)([^<]*?)\2\8(?!\2)(?=\W|_|$)/g;
|
2808
|
+
const rx_code = /\n((```|~~~).*\n?([^]*?)\n?\2|(( {4}.*?\n)+))/g;
|
2809
|
+
const rx_link = /((!?)\[(.*?)\]\((.*?)( ".*")?\)|\\([\\`*_{}[\]()#+\-.!~]))/g;
|
2810
|
+
const rx_table = /\n(( *\|.*?\| *\n)+)/g;
|
2811
|
+
const rx_thead = /^.*\n( *\|( *:?-+:?-+:? *\|)* *\n|)/;
|
2812
|
+
const rx_row = /.*\n/g;
|
2813
|
+
const rx_cell = /\|(.*?[^\\])\|/g;
|
2814
|
+
const rx_heading = /(?=^|>|\n)([>\s]*?)(#{1,6}) (.*?)( #*)? *(?=\n|$)/g;
|
2815
|
+
const rx_para = /(?=^|>|\n)\s*\n+([^<]+?)\n+\s*(?=\n|<|$)/g;
|
2816
|
+
const rx_stash = /-\d+\uf8ff/g;
|
2817
|
+
const stash = {};
|
2818
|
+
let si = 0;
|
2819
|
+
function replace(rex, fn) {
|
2820
|
+
src = src.replace(rex, fn);
|
2821
|
+
}
|
2822
|
+
function element(tag, content) {
|
2823
|
+
return `<${tag}>${content}</${tag}>`;
|
2824
|
+
}
|
2825
|
+
function blockquote(src) {
|
2826
|
+
return src.replace(rx_blockquote, (_, content) => {
|
2827
|
+
return element('blockquote', blockquote(highlight(content.replace(/^ *> */gm, ''))));
|
2828
|
+
});
|
2829
|
+
}
|
2830
|
+
function list(src) {
|
2831
|
+
return src.replace(rx_list, (all, ind, ol, num, low, content) => {
|
2832
|
+
const entry = element('li', highlight(content
|
2833
|
+
.split(new RegExp(`\n ?${ind}(?:(?:\\d+|[a-zA-Z])[.)]|[*\\-+]) +`, 'g'))
|
2834
|
+
.map(list)
|
2835
|
+
.join('</li><li>')));
|
2836
|
+
return `\n${ol
|
2837
|
+
? `<ol start="${num
|
2838
|
+
? ol + '">'
|
2839
|
+
: `${parseInt(ol, 36) - 9}" style="list-style-type:${low ? 'low' : 'upp'}er-alpha">`}${entry}</ol>`
|
2840
|
+
: element('ul', entry)}`;
|
2841
|
+
});
|
2842
|
+
}
|
2843
|
+
function highlight(src) {
|
2844
|
+
return src.replace(rx_highlight, function (all, _, p1, emp, sub, sup, small, big, p2, content) {
|
2845
|
+
return (_ +
|
2846
|
+
element(emp
|
2847
|
+
? p2
|
2848
|
+
? 'strong'
|
2849
|
+
: 'em'
|
2850
|
+
: sub
|
2851
|
+
? p2
|
2852
|
+
? 's'
|
2853
|
+
: 'sub'
|
2854
|
+
: sup
|
2855
|
+
? 'sup'
|
2856
|
+
: small
|
2857
|
+
? 'small'
|
2858
|
+
: big
|
2859
|
+
? 'big'
|
2860
|
+
: 'code', highlight(content)));
|
2861
|
+
});
|
2862
|
+
}
|
2863
|
+
src = `\n${src}\n`;
|
2864
|
+
replace(rx_space, ' ');
|
2865
|
+
src = blockquote(src);
|
2866
|
+
replace(rx_hr, '<hr/>');
|
2867
|
+
src = list(src);
|
2868
|
+
replace(rx_listjoin, '');
|
2869
|
+
replace(rx_code, (_, p1, p2, p3, p4) => {
|
2870
|
+
stash[--si] = element('pre', element('code', p3 || p4.replace(/^ {4}/gm, '')));
|
2871
|
+
return `${si}\uf8ff`;
|
2872
|
+
});
|
2873
|
+
replace(rx_link, (_, p1, p2, p3, p4, p5, p6) => {
|
2874
|
+
stash[--si] = p4
|
2875
|
+
? p2
|
2876
|
+
? `<img src="${p4}" alt="${p3}"/>`
|
2877
|
+
: `<a href="${p4}">${highlight(p3)}</a>`
|
2878
|
+
: p6;
|
2879
|
+
return `${si}\uf8ff`;
|
2880
|
+
});
|
2881
|
+
replace(rx_table, (_, table) => {
|
2882
|
+
var _a;
|
2883
|
+
const sep = ((_a = table.match(rx_thead)) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
2884
|
+
return `\n${element('table', table.replace(rx_row, (row, ri) => {
|
2885
|
+
return row === sep
|
2886
|
+
? ''
|
2887
|
+
: element('tr', row.replace(rx_cell, (_, cell, ci) => ci
|
2888
|
+
? element(sep && !ri ? 'th' : 'td', highlight(cell || ''))
|
2889
|
+
: ''));
|
2890
|
+
}))}`;
|
2891
|
+
});
|
2892
|
+
replace(rx_heading, (_, prefix, p1, p2) => {
|
2893
|
+
return prefix + element(`h${p1.length}`, highlight(p2));
|
2894
|
+
});
|
2895
|
+
replace(rx_para, (_, content) => {
|
2896
|
+
return element('p', highlight(content));
|
2897
|
+
});
|
2898
|
+
replace(rx_stash, (all) => stash[parseInt(all)]);
|
2899
|
+
return src.trim();
|
2900
|
+
};
|
2705
2901
|
|
2706
|
-
|
2707
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2708
|
-
class MarkdownRenderer extends r$3 {
|
2902
|
+
class MarkdownRenderer extends r$2 {
|
2709
2903
|
render() {
|
2710
|
-
|
2711
|
-
const
|
2712
|
-
|
2904
|
+
// Remove lit markers from slot content
|
2905
|
+
const slotContent = this.innerHTML
|
2906
|
+
.trim()
|
2907
|
+
.replace(/<!--\?lit\$[\d$]+-->/g, '');
|
2908
|
+
return o(markdown(slotContent));
|
2713
2909
|
}
|
2714
|
-
}
|
2910
|
+
}
|
2715
2911
|
MarkdownRenderer.styles = i$4 `
|
2716
2912
|
:host {
|
2717
2913
|
font-family: 'Inter', sans-serif;
|
@@ -2723,14 +2919,11 @@ MarkdownRenderer.styles = i$4 `
|
|
2723
2919
|
}
|
2724
2920
|
}
|
2725
2921
|
`;
|
2726
|
-
|
2727
|
-
|
2728
|
-
|
2729
|
-
|
2730
|
-
|
2731
|
-
let TooltipComponent =
|
2732
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2733
|
-
class TooltipComponent extends r$3 {
|
2922
|
+
if (!customElements.get('markdown-renderer')) {
|
2923
|
+
customElements.define('markdown-renderer', MarkdownRenderer);
|
2924
|
+
}
|
2925
|
+
|
2926
|
+
class TooltipComponent extends r$2 {
|
2734
2927
|
constructor() {
|
2735
2928
|
super(...arguments);
|
2736
2929
|
this.position = 'bottom-left';
|
@@ -2742,7 +2935,7 @@ class TooltipComponent extends r$3 {
|
|
2742
2935
|
<div class="tooltip ${this.position}">${this.text}</div>
|
2743
2936
|
`;
|
2744
2937
|
}
|
2745
|
-
}
|
2938
|
+
}
|
2746
2939
|
TooltipComponent.styles = [
|
2747
2940
|
i$4 `
|
2748
2941
|
:host {
|
@@ -2754,7 +2947,6 @@ TooltipComponent.styles = [
|
|
2754
2947
|
position: absolute;
|
2755
2948
|
color: #172a41;
|
2756
2949
|
padding: 4px 8px;
|
2757
|
-
border-radius: 4px;
|
2758
2950
|
white-space: nowrap;
|
2759
2951
|
font-size: 12px;
|
2760
2952
|
opacity: 0;
|
@@ -2841,17 +3033,16 @@ TooltipComponent.styles = [
|
|
2841
3033
|
`,
|
2842
3034
|
];
|
2843
3035
|
__decorate([
|
2844
|
-
n
|
3036
|
+
n({ type: String }),
|
2845
3037
|
__metadata("design:type", String)
|
2846
3038
|
], TooltipComponent.prototype, "position", void 0);
|
2847
3039
|
__decorate([
|
2848
|
-
n
|
3040
|
+
n({ type: String }),
|
2849
3041
|
__metadata("design:type", Object)
|
2850
3042
|
], TooltipComponent.prototype, "text", void 0);
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
], TooltipComponent);
|
3043
|
+
if (!customElements.get('tooltip-component')) {
|
3044
|
+
customElements.define('tooltip-component', TooltipComponent);
|
3045
|
+
}
|
2855
3046
|
|
2856
3047
|
const confirmDialogStyles = i$4 `
|
2857
3048
|
:host {
|
@@ -2932,9 +3123,7 @@ const confirmDialogStyles = i$4 `
|
|
2932
3123
|
}
|
2933
3124
|
`;
|
2934
3125
|
|
2935
|
-
|
2936
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2937
|
-
class ConfirmDialog extends r$3 {
|
3126
|
+
class ConfirmDialog extends r$2 {
|
2938
3127
|
onAcceptClick(e) {
|
2939
3128
|
e.preventDefault();
|
2940
3129
|
this.dispatchEvent(new CustomEvent('accept', {
|
@@ -2967,19 +3156,17 @@ class ConfirmDialog extends r$3 {
|
|
2967
3156
|
</div>
|
2968
3157
|
`;
|
2969
3158
|
}
|
2970
|
-
}
|
3159
|
+
}
|
2971
3160
|
ConfirmDialog.styles = [confirmDialogStyles];
|
2972
|
-
|
2973
|
-
|
2974
|
-
|
2975
|
-
|
2976
|
-
|
2977
|
-
let ChatSection =
|
2978
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2979
|
-
class ChatSection extends r$3 {
|
3161
|
+
if (!customElements.get('confirm-dialog')) {
|
3162
|
+
customElements.define('confirm-dialog', ConfirmDialog);
|
3163
|
+
}
|
3164
|
+
|
3165
|
+
class ChatSection extends r$2 {
|
2980
3166
|
constructor() {
|
2981
3167
|
super(...arguments);
|
2982
3168
|
this.showChatThreads = false;
|
3169
|
+
this.deleteAllThreads = false;
|
2983
3170
|
this.userQuery = '';
|
2984
3171
|
}
|
2985
3172
|
scrollToBottom() {
|
@@ -3004,6 +3191,14 @@ class ChatSection extends r$3 {
|
|
3004
3191
|
await this.processMessage(e, message);
|
3005
3192
|
}
|
3006
3193
|
handleThreadDelete() {
|
3194
|
+
if (this.deleteAllThreads) {
|
3195
|
+
this.dispatchEvent(new CustomEvent('delete-all-threads', {
|
3196
|
+
composed: true,
|
3197
|
+
bubbles: true,
|
3198
|
+
}));
|
3199
|
+
this.deleteAllThreads = false;
|
3200
|
+
return;
|
3201
|
+
}
|
3007
3202
|
if (!this.deleteThreadId) {
|
3008
3203
|
return;
|
3009
3204
|
}
|
@@ -3057,8 +3252,10 @@ class ChatSection extends r$3 {
|
|
3057
3252
|
`;
|
3058
3253
|
}
|
3059
3254
|
chatWindow() {
|
3060
|
-
if (this.isLoadingHistory) {
|
3061
|
-
return x
|
3255
|
+
if (this.isLoadingHistory || this.isLoadingThreads) {
|
3256
|
+
return x `<div class="messages loading">
|
3257
|
+
<load-spinner></load-spinner>
|
3258
|
+
</div>`;
|
3062
3259
|
}
|
3063
3260
|
return x `
|
3064
3261
|
<div class="messages">
|
@@ -3099,16 +3296,20 @@ class ChatSection extends r$3 {
|
|
3099
3296
|
`;
|
3100
3297
|
}
|
3101
3298
|
quickPrompts() {
|
3102
|
-
|
3103
|
-
|
3299
|
+
if (this.isLoadingHistory || this.isTyping || this.isLoadingThreads) {
|
3300
|
+
return E;
|
3301
|
+
}
|
3302
|
+
const prompts = this.messages.length
|
3303
|
+
? this.messages[0].welcomePrompts
|
3304
|
+
: this.prompts
|
3305
|
+
? this.prompts.split(',').map((prompt) => prompt.trim())
|
3306
|
+
: ['Best Sellers'];
|
3307
|
+
if (!prompts) {
|
3104
3308
|
return E;
|
3105
3309
|
}
|
3106
|
-
const defaultPrompts = this.prompts
|
3107
|
-
? this.prompts.split(',').map((prompt) => prompt.trim())
|
3108
|
-
: ['Best Selling Items', 'Hot Sales'];
|
3109
3310
|
return x `
|
3110
3311
|
<div class="prompts btn">
|
3111
|
-
${
|
3312
|
+
${prompts.map((prompt) => x `
|
3112
3313
|
<div
|
3113
3314
|
class="prompt"
|
3114
3315
|
@click=${(e) => this.processMessage(e, prompt)}
|
@@ -3212,10 +3413,10 @@ class ChatSection extends r$3 {
|
|
3212
3413
|
</tooltip-component>
|
3213
3414
|
<tooltip-component
|
3214
3415
|
.position=${'bottom-right'}
|
3215
|
-
.text=${'
|
3416
|
+
.text=${'Search History'}
|
3216
3417
|
>
|
3217
3418
|
<button
|
3218
|
-
class=${e$
|
3419
|
+
class=${e$1({
|
3219
3420
|
btn: true,
|
3220
3421
|
'btn-icon': true,
|
3221
3422
|
'threads-btn': true,
|
@@ -3287,11 +3488,27 @@ class ChatSection extends r$3 {
|
|
3287
3488
|
}
|
3288
3489
|
return x ` <div id="modal-chat-threads">
|
3289
3490
|
<div class="chat-threads">
|
3290
|
-
<
|
3491
|
+
<div class="title-wrapper">
|
3492
|
+
<h2>Search History</h2>
|
3493
|
+
${this.chatThreads.size
|
3494
|
+
? x `<div
|
3495
|
+
class="trash-icon"
|
3496
|
+
@click=${() => {
|
3497
|
+
if (this.isTyping) {
|
3498
|
+
return;
|
3499
|
+
}
|
3500
|
+
this.deleteAllThreads = true;
|
3501
|
+
this.showChatThreads = false;
|
3502
|
+
}}
|
3503
|
+
>
|
3504
|
+
${trashIcon}
|
3505
|
+
</div>`
|
3506
|
+
: E}
|
3507
|
+
</div>
|
3291
3508
|
<div class="thread-titles-wrapper">
|
3292
3509
|
${o$1(this.chatThreads.values(), (thread) => x `
|
3293
3510
|
<div
|
3294
|
-
class=${e$
|
3511
|
+
class=${e$1({
|
3295
3512
|
'thread-title': true,
|
3296
3513
|
disabled: this.isTyping,
|
3297
3514
|
})}
|
@@ -3331,10 +3548,17 @@ class ChatSection extends r$3 {
|
|
3331
3548
|
</div>`;
|
3332
3549
|
}
|
3333
3550
|
render() {
|
3551
|
+
if (this.merchantImage) {
|
3552
|
+
// set the merchant image as a css variable
|
3553
|
+
this.style.setProperty('--shopgpt-merchant-img-url', `url('${this.merchantImage}')`);
|
3554
|
+
}
|
3555
|
+
else {
|
3556
|
+
this.style.removeProperty('--shopgpt-merchant-img-url');
|
3557
|
+
}
|
3334
3558
|
return x `
|
3335
3559
|
<div class="chat-header">${this.contextButton()}</div>
|
3336
3560
|
<div
|
3337
|
-
class=${e$
|
3561
|
+
class=${e$1({
|
3338
3562
|
'chatbot-section': true,
|
3339
3563
|
'modal-view': this.viewType === 'modal',
|
3340
3564
|
})}
|
@@ -3348,7 +3572,7 @@ class ChatSection extends r$3 {
|
|
3348
3572
|
placeholder="Type your search here..."
|
3349
3573
|
/>
|
3350
3574
|
<button
|
3351
|
-
class=${e$
|
3575
|
+
class=${e$1({
|
3352
3576
|
btn: true,
|
3353
3577
|
modal: this.viewType === 'modal',
|
3354
3578
|
})}
|
@@ -3365,107 +3589,130 @@ class ChatSection extends r$3 {
|
|
3365
3589
|
.defaultProfiles=${this.profiles}
|
3366
3590
|
></personalize-dialog>
|
3367
3591
|
${this.renderChatThreads()}
|
3368
|
-
${this.deleteThreadId
|
3592
|
+
${this.deleteThreadId || this.deleteAllThreads
|
3369
3593
|
? x `
|
3370
3594
|
<confirm-dialog
|
3371
3595
|
@accept=${this.handleThreadDelete}
|
3372
|
-
@decline=${() =>
|
3596
|
+
@decline=${() => {
|
3597
|
+
this.deleteThreadId = '';
|
3598
|
+
this.deleteAllThreads = false;
|
3599
|
+
}}
|
3373
3600
|
>
|
3374
|
-
<h2 slot="title">
|
3601
|
+
<h2 slot="title">
|
3602
|
+
${this.deleteAllThreads
|
3603
|
+
? 'Delete Entire Chat History?'
|
3604
|
+
: 'Delete Chat?'}
|
3605
|
+
</h2>
|
3375
3606
|
<p slot="content">
|
3376
3607
|
This action cannot be undone. Are you sure you want to delete
|
3377
|
-
|
3608
|
+
${this.deleteAllThreads
|
3609
|
+
? ' the entire chat history'
|
3610
|
+
: x `<b
|
3611
|
+
>"${this.chatThreads.get(this.deleteThreadId)
|
3612
|
+
.title}"</b
|
3613
|
+
>`}?
|
3378
3614
|
</p>
|
3379
3615
|
</confirm-dialog>
|
3380
3616
|
`
|
3381
3617
|
: E}
|
3382
3618
|
`;
|
3383
3619
|
}
|
3384
|
-
}
|
3620
|
+
}
|
3385
3621
|
ChatSection.styles = [chatSectionStyles];
|
3386
3622
|
__decorate([
|
3387
|
-
n
|
3623
|
+
n({ type: String }),
|
3624
|
+
__metadata("design:type", Object)
|
3625
|
+
], ChatSection.prototype, "merchantImage", void 0);
|
3626
|
+
__decorate([
|
3627
|
+
n({ type: String }),
|
3388
3628
|
__metadata("design:type", Object)
|
3389
3629
|
], ChatSection.prototype, "brandName", void 0);
|
3390
3630
|
__decorate([
|
3391
|
-
n
|
3631
|
+
n({ type: String }),
|
3392
3632
|
__metadata("design:type", Object)
|
3393
3633
|
], ChatSection.prototype, "prompts", void 0);
|
3394
3634
|
__decorate([
|
3395
|
-
n
|
3635
|
+
n({ type: Boolean }),
|
3636
|
+
__metadata("design:type", Boolean)
|
3637
|
+
], ChatSection.prototype, "isLoadingThreads", void 0);
|
3638
|
+
__decorate([
|
3639
|
+
n({ type: Object }),
|
3396
3640
|
__metadata("design:type", Map)
|
3397
3641
|
], ChatSection.prototype, "chatThreads", void 0);
|
3398
3642
|
__decorate([
|
3399
|
-
r
|
3643
|
+
r(),
|
3400
3644
|
__metadata("design:type", String)
|
3401
3645
|
], ChatSection.prototype, "deleteThreadId", void 0);
|
3402
3646
|
__decorate([
|
3403
|
-
n
|
3647
|
+
n({ type: Boolean }),
|
3404
3648
|
__metadata("design:type", Object)
|
3405
3649
|
], ChatSection.prototype, "showChatThreads", void 0);
|
3406
3650
|
__decorate([
|
3407
|
-
n
|
3651
|
+
n({ type: Boolean }),
|
3408
3652
|
__metadata("design:type", Boolean)
|
3409
3653
|
], ChatSection.prototype, "isLoadingHistory", void 0);
|
3410
3654
|
__decorate([
|
3411
|
-
n
|
3655
|
+
n({ type: Boolean }),
|
3412
3656
|
__metadata("design:type", Object)
|
3413
3657
|
], ChatSection.prototype, "devMode", void 0);
|
3414
3658
|
__decorate([
|
3415
|
-
n
|
3659
|
+
n({ type: Boolean }),
|
3416
3660
|
__metadata("design:type", Boolean)
|
3417
3661
|
], ChatSection.prototype, "isTyping", void 0);
|
3418
3662
|
__decorate([
|
3419
|
-
n
|
3663
|
+
n({ type: Boolean }),
|
3420
3664
|
__metadata("design:type", Boolean)
|
3421
3665
|
], ChatSection.prototype, "isFailed", void 0);
|
3422
3666
|
__decorate([
|
3423
|
-
n
|
3667
|
+
n({ type: Array }),
|
3424
3668
|
__metadata("design:type", Array)
|
3425
3669
|
], ChatSection.prototype, "messages", void 0);
|
3426
3670
|
__decorate([
|
3427
|
-
n
|
3671
|
+
n({ type: Array }),
|
3428
3672
|
__metadata("design:type", Array)
|
3429
3673
|
], ChatSection.prototype, "profiles", void 0);
|
3430
3674
|
__decorate([
|
3431
|
-
n
|
3675
|
+
n({ type: Array }),
|
3432
3676
|
__metadata("design:type", Array)
|
3433
3677
|
], ChatSection.prototype, "productHandles", void 0);
|
3434
3678
|
__decorate([
|
3435
|
-
n
|
3679
|
+
n({ type: Object }),
|
3436
3680
|
__metadata("design:type", Object)
|
3437
3681
|
], ChatSection.prototype, "thread", void 0);
|
3438
3682
|
__decorate([
|
3439
|
-
n
|
3683
|
+
n({ type: Object }),
|
3440
3684
|
__metadata("design:type", Object)
|
3441
3685
|
], ChatSection.prototype, "siteCurrency", void 0);
|
3442
3686
|
__decorate([
|
3443
|
-
|
3687
|
+
r(),
|
3688
|
+
__metadata("design:type", Object)
|
3689
|
+
], ChatSection.prototype, "deleteAllThreads", void 0);
|
3690
|
+
__decorate([
|
3691
|
+
e$3('.context-container'),
|
3444
3692
|
__metadata("design:type", Object)
|
3445
3693
|
], ChatSection.prototype, "contextContainerElement", void 0);
|
3446
3694
|
__decorate([
|
3447
|
-
e$
|
3695
|
+
e$3('.chat-window'),
|
3448
3696
|
__metadata("design:type", Object)
|
3449
3697
|
], ChatSection.prototype, "chatWindowElement", void 0);
|
3450
3698
|
__decorate([
|
3451
|
-
e$
|
3699
|
+
e$3('personalize-dialog'),
|
3452
3700
|
__metadata("design:type", Object)
|
3453
3701
|
], ChatSection.prototype, "personalizeDialogElement", void 0);
|
3454
3702
|
__decorate([
|
3455
|
-
n
|
3703
|
+
n({ type: String }),
|
3456
3704
|
__metadata("design:type", Object)
|
3457
3705
|
], ChatSection.prototype, "userQuery", void 0);
|
3458
|
-
|
3459
|
-
|
3460
|
-
|
3461
|
-
], ChatSection);
|
3706
|
+
if (!customElements.get('chat-section')) {
|
3707
|
+
customElements.define('chat-section', ChatSection);
|
3708
|
+
}
|
3462
3709
|
|
3463
3710
|
const DIALOG_DELAY = 1000;
|
3464
|
-
const LATEST_THREAD_LOAD_DAYS = 14;
|
3465
3711
|
const normalizePath = (path) => path.replace(/\/$/, '');
|
3466
|
-
|
3712
|
+
class ShopGPT extends r$2 {
|
3467
3713
|
constructor() {
|
3468
3714
|
super(...arguments);
|
3715
|
+
this.latestThreadLoad = DEFAULT_MAX_THREAD_AGE;
|
3469
3716
|
this.modalState = 'close';
|
3470
3717
|
this.isLoadingHistory = false;
|
3471
3718
|
this.isLoadingThreads = false;
|
@@ -3480,9 +3727,13 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3480
3727
|
return;
|
3481
3728
|
}
|
3482
3729
|
await this.loadChatThreads();
|
3483
|
-
await this.loadInitialQuery();
|
3484
3730
|
this.selectLatestThread();
|
3485
3731
|
};
|
3732
|
+
this.onPopState = () => {
|
3733
|
+
var _a;
|
3734
|
+
this.modalState = 'close';
|
3735
|
+
(_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
|
3736
|
+
};
|
3486
3737
|
this.submitQuery = (message) => {
|
3487
3738
|
if (!message) {
|
3488
3739
|
return;
|
@@ -3508,10 +3759,12 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3508
3759
|
}
|
3509
3760
|
disconnectedCallback() {
|
3510
3761
|
window.removeEventListener('edgetag-initialized', this.loadData);
|
3762
|
+
window.removeEventListener('popstate', this.onPopState);
|
3511
3763
|
super.disconnectedCallback();
|
3512
3764
|
}
|
3513
3765
|
init() {
|
3514
3766
|
window.addEventListener('edgetag-initialized', this.loadData);
|
3767
|
+
window.addEventListener('popstate', this.onPopState);
|
3515
3768
|
if (!this.uiMode || this.uiMode === 'overlay') {
|
3516
3769
|
delay(DIALOG_DELAY).then(() => {
|
3517
3770
|
var _a;
|
@@ -3526,6 +3779,19 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3526
3779
|
});
|
3527
3780
|
}
|
3528
3781
|
}
|
3782
|
+
setChatTitle(threadId, title) {
|
3783
|
+
if (!title || !threadId) {
|
3784
|
+
return;
|
3785
|
+
}
|
3786
|
+
const thread = this.chatThreads.get(threadId);
|
3787
|
+
if (thread) {
|
3788
|
+
this.chatThreads.set(thread.threadId, {
|
3789
|
+
...thread,
|
3790
|
+
title,
|
3791
|
+
});
|
3792
|
+
this.chatThreads = new Map(this.chatThreads);
|
3793
|
+
}
|
3794
|
+
}
|
3529
3795
|
async loadInitialQuery() {
|
3530
3796
|
var _a;
|
3531
3797
|
if (!this.selectedThreadId) {
|
@@ -3538,14 +3804,26 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3538
3804
|
if (!thread) {
|
3539
3805
|
return;
|
3540
3806
|
}
|
3807
|
+
const searchParam = new URLSearchParams(window.location.search);
|
3808
|
+
const fromAd = searchParam.get('shopGPT') === '1';
|
3541
3809
|
const productHandle = this.devMode
|
3542
3810
|
? (_a = thread === null || thread === void 0 ? void 0 : thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle
|
3543
|
-
:
|
3811
|
+
: fromAd
|
3812
|
+
? this.storeAPI.getCurrentProductHandle()
|
3813
|
+
: undefined;
|
3544
3814
|
try {
|
3545
3815
|
this.isTyping = true;
|
3546
3816
|
const reply = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
|
3817
|
+
if (reply.chatTitle) {
|
3818
|
+
this.setChatTitle(this.selectedThreadId, reply.chatTitle);
|
3819
|
+
}
|
3547
3820
|
this.messages = [
|
3548
|
-
{
|
3821
|
+
{
|
3822
|
+
sender: 'bot',
|
3823
|
+
message: reply.message,
|
3824
|
+
products: reply.products,
|
3825
|
+
welcomePrompts: reply.welcomePrompts,
|
3826
|
+
},
|
3549
3827
|
...this.messages,
|
3550
3828
|
];
|
3551
3829
|
this.products = reply.products || [];
|
@@ -3572,10 +3850,7 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3572
3850
|
}
|
3573
3851
|
}
|
3574
3852
|
selectLatestThread() {
|
3575
|
-
|
3576
|
-
return;
|
3577
|
-
}
|
3578
|
-
const cutoffTime = Date.now() - LATEST_THREAD_LOAD_DAYS * 24 * 60 * 60 * 1000;
|
3853
|
+
const cutoffTime = Date.now() - this.latestThreadLoad * 24 * 60 * 60 * 1000;
|
3579
3854
|
// If the latest thread is not older than cutoff we should load the thread
|
3580
3855
|
let latestThread;
|
3581
3856
|
for (const thread of this.chatThreads.values()) {
|
@@ -3587,9 +3862,11 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3587
3862
|
if (latestThread) {
|
3588
3863
|
this.setSelectedThreadId(latestThread.threadId);
|
3589
3864
|
}
|
3865
|
+
else if (!this.devMode) {
|
3866
|
+
this.createChatThread({ title: '' }, true);
|
3867
|
+
}
|
3590
3868
|
}
|
3591
3869
|
async loadHistory(threadId) {
|
3592
|
-
var _a, _b, _c;
|
3593
3870
|
try {
|
3594
3871
|
if (!threadId) {
|
3595
3872
|
this.messages = [];
|
@@ -3598,22 +3875,24 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3598
3875
|
}
|
3599
3876
|
this.isLoadingHistory = true;
|
3600
3877
|
const data = await this.shopGPTAPI.fetchChatHistory(threadId);
|
3878
|
+
let latestAvailableProducts = [];
|
3601
3879
|
this.messages = data.map((message) => {
|
3602
3880
|
var _a;
|
3603
|
-
|
3881
|
+
const products = (_a = message.products) === null || _a === void 0 ? void 0 : _a.map((product) => ({
|
3882
|
+
...product,
|
3883
|
+
quantity: 1,
|
3884
|
+
}));
|
3885
|
+
if (!latestAvailableProducts.length && (products === null || products === void 0 ? void 0 : products.length)) {
|
3886
|
+
latestAvailableProducts = products;
|
3887
|
+
}
|
3888
|
+
return {
|
3604
3889
|
message: message.message,
|
3605
3890
|
sender: message.sender,
|
3606
|
-
products
|
3607
|
-
|
3608
|
-
|
3609
|
-
})),
|
3610
|
-
});
|
3891
|
+
products,
|
3892
|
+
welcomePrompts: message.welcomePrompts,
|
3893
|
+
};
|
3611
3894
|
});
|
3612
|
-
this.products =
|
3613
|
-
(_c = (_b = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.products) === null || _b === void 0 ? void 0 : _b.map((product) => ({
|
3614
|
-
...product,
|
3615
|
-
quantity: 1,
|
3616
|
-
}))) !== null && _c !== void 0 ? _c : [];
|
3895
|
+
this.products = latestAvailableProducts;
|
3617
3896
|
}
|
3618
3897
|
catch (e) {
|
3619
3898
|
logger.error(e);
|
@@ -3654,6 +3933,21 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3654
3933
|
this.shopGPTAPI
|
3655
3934
|
.deleteSingleThread(threadId)
|
3656
3935
|
.then(this.loadChatThreads.bind(this))
|
3936
|
+
.then(() => {
|
3937
|
+
if (this.selectedThreadId === threadId) {
|
3938
|
+
this.setSelectedThreadId('');
|
3939
|
+
}
|
3940
|
+
})
|
3941
|
+
.catch(logger.error)
|
3942
|
+
.finally(() => (this.isLoadingThreads = false));
|
3943
|
+
}
|
3944
|
+
handleAllThreadsDelete(e) {
|
3945
|
+
e.stopPropagation();
|
3946
|
+
this.isLoadingThreads = true;
|
3947
|
+
this.shopGPTAPI
|
3948
|
+
.deleteAllThreads()
|
3949
|
+
.then(this.loadChatThreads.bind(this))
|
3950
|
+
.then(() => this.setSelectedThreadId(''))
|
3657
3951
|
.catch(logger.error)
|
3658
3952
|
.finally(() => (this.isLoadingThreads = false));
|
3659
3953
|
}
|
@@ -3672,21 +3966,20 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3672
3966
|
return;
|
3673
3967
|
}
|
3674
3968
|
if (reply.chatTitle) {
|
3675
|
-
|
3676
|
-
const thread = this.chatThreads.get(this.selectedThreadId);
|
3677
|
-
if (thread) {
|
3678
|
-
this.chatThreads.set(thread.threadId, {
|
3679
|
-
...thread,
|
3680
|
-
title: reply.chatTitle,
|
3681
|
-
});
|
3682
|
-
this.chatThreads = new Map(this.chatThreads);
|
3683
|
-
}
|
3969
|
+
this.setChatTitle(this.selectedThreadId, reply.chatTitle);
|
3684
3970
|
}
|
3685
3971
|
this.messages = [
|
3686
|
-
{
|
3972
|
+
{
|
3973
|
+
sender: 'bot',
|
3974
|
+
message: reply.message,
|
3975
|
+
products: reply.products,
|
3976
|
+
welcomePrompts: reply.welcomePrompts,
|
3977
|
+
},
|
3687
3978
|
...this.messages,
|
3688
3979
|
];
|
3689
|
-
|
3980
|
+
if (reply.products && reply.products.length > 0) {
|
3981
|
+
this.products = reply.products;
|
3982
|
+
}
|
3690
3983
|
}
|
3691
3984
|
catch (err) {
|
3692
3985
|
logger.error(err);
|
@@ -3711,6 +4004,7 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3711
4004
|
<dialog
|
3712
4005
|
id="shop-gpt-dialog-overlay"
|
3713
4006
|
@delete-thread=${this.handleThreadDelete}
|
4007
|
+
@delete-all-threads=${this.handleAllThreadsDelete}
|
3714
4008
|
>
|
3715
4009
|
<div class="mobile-version">
|
3716
4010
|
Please switch to the desktop version for the best experience.
|
@@ -3729,6 +4023,7 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3729
4023
|
.products=${this.products}
|
3730
4024
|
.isLoadingHistory=${this.isLoadingHistory}
|
3731
4025
|
.siteCurrency=${this.getSiteCurrency()}
|
4026
|
+
.isLoadingThreads=${this.isLoadingThreads}
|
3732
4027
|
></products-section>
|
3733
4028
|
<chat-section
|
3734
4029
|
.prompts=${this.quickPrompts}
|
@@ -3745,6 +4040,7 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3745
4040
|
.productHandles=${this.productHandles}
|
3746
4041
|
.profiles=${this.profiles}
|
3747
4042
|
.viewType=${'overlay'}
|
4043
|
+
.isLoadingThreads=${this.isLoadingThreads}
|
3748
4044
|
></chat-section>
|
3749
4045
|
</div>
|
3750
4046
|
</dialog>
|
@@ -3765,10 +4061,15 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3765
4061
|
>
|
3766
4062
|
${chatIcon}
|
3767
4063
|
</button>
|
4064
|
+
<div class="chatbot-hover-text">What are you looking for today?</div>
|
3768
4065
|
</div>`;
|
3769
4066
|
}
|
3770
4067
|
return x `
|
3771
|
-
<div
|
4068
|
+
<div
|
4069
|
+
id="shop-gpt-modal"
|
4070
|
+
@delete-thread=${this.handleThreadDelete}
|
4071
|
+
@delete-all-threads=${this.handleAllThreadsDelete}
|
4072
|
+
>
|
3772
4073
|
<chat-section
|
3773
4074
|
.prompts=${this.quickPrompts}
|
3774
4075
|
.brandName=${this.brandName}
|
@@ -3787,55 +4088,61 @@ let ShopGPT = class ShopGPT extends r$3 {
|
|
3787
4088
|
.closeModal=${closeModal}
|
3788
4089
|
.setSelectedThreadId=${this.setSelectedThreadId.bind(this)}
|
3789
4090
|
.chatThreads=${this.chatThreads}
|
4091
|
+
.isLoadingThreads=${this.isLoadingThreads}
|
4092
|
+
.merchantImage=${this.merchantImage}
|
3790
4093
|
></chat-section>
|
3791
4094
|
</div>
|
3792
4095
|
`;
|
3793
4096
|
}
|
3794
|
-
}
|
4097
|
+
}
|
3795
4098
|
ShopGPT.styles = [shopGPTStyles];
|
3796
4099
|
__decorate([
|
3797
|
-
|
4100
|
+
n({ type: Number }),
|
4101
|
+
__metadata("design:type", Number)
|
4102
|
+
], ShopGPT.prototype, "latestThreadLoad", void 0);
|
4103
|
+
__decorate([
|
4104
|
+
e$3('#shop-gpt-dialog-overlay'),
|
3798
4105
|
__metadata("design:type", Object)
|
3799
4106
|
], ShopGPT.prototype, "shopGPTDialog", void 0);
|
3800
4107
|
__decorate([
|
3801
|
-
n
|
4108
|
+
n({ type: String }),
|
3802
4109
|
__metadata("design:type", String)
|
3803
4110
|
], ShopGPT.prototype, "modalState", void 0);
|
3804
4111
|
__decorate([
|
3805
|
-
n
|
4112
|
+
n({ type: Boolean }),
|
3806
4113
|
__metadata("design:type", Object)
|
3807
4114
|
], ShopGPT.prototype, "isLoadingHistory", void 0);
|
3808
4115
|
__decorate([
|
3809
|
-
n
|
4116
|
+
n({ type: Boolean }),
|
3810
4117
|
__metadata("design:type", Object)
|
3811
4118
|
], ShopGPT.prototype, "isLoadingThreads", void 0);
|
3812
4119
|
__decorate([
|
3813
|
-
n
|
4120
|
+
n({ type: Boolean }),
|
3814
4121
|
__metadata("design:type", Object)
|
3815
4122
|
], ShopGPT.prototype, "isTyping", void 0);
|
3816
4123
|
__decorate([
|
3817
|
-
n
|
4124
|
+
n({ type: Boolean }),
|
3818
4125
|
__metadata("design:type", Object)
|
3819
4126
|
], ShopGPT.prototype, "isFailed", void 0);
|
3820
4127
|
__decorate([
|
3821
|
-
n
|
4128
|
+
n({ type: String }),
|
3822
4129
|
__metadata("design:type", Object)
|
3823
4130
|
], ShopGPT.prototype, "selectedThreadId", void 0);
|
3824
4131
|
__decorate([
|
3825
|
-
n
|
4132
|
+
n({ type: Array }),
|
3826
4133
|
__metadata("design:type", Array)
|
3827
4134
|
], ShopGPT.prototype, "products", void 0);
|
3828
4135
|
__decorate([
|
3829
|
-
n
|
4136
|
+
n({ type: Array }),
|
3830
4137
|
__metadata("design:type", Array)
|
3831
4138
|
], ShopGPT.prototype, "messages", void 0);
|
3832
4139
|
__decorate([
|
3833
|
-
n
|
4140
|
+
n({ type: Object }),
|
3834
4141
|
__metadata("design:type", Map)
|
3835
4142
|
], ShopGPT.prototype, "chatThreads", void 0);
|
3836
|
-
|
3837
|
-
|
3838
|
-
|
4143
|
+
if (!customElements.get('shop-gpt')) {
|
4144
|
+
customElements.define('shop-gpt', ShopGPT);
|
4145
|
+
}
|
3839
4146
|
|
3840
4147
|
var _a, _b;
|
3841
4148
|
var _c;
|
@@ -3859,8 +4166,17 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
|
|
3859
4166
|
shopGPT.brandName = params.brandName;
|
3860
4167
|
shopGPT.quickPrompts = params.quickPrompts;
|
3861
4168
|
shopGPT.merchantImage = params.merchantImage;
|
4169
|
+
shopGPT.latestThreadLoad = params.latestThreadLoad;
|
3862
4170
|
document.body.append(shopGPT);
|
3863
4171
|
},
|
4172
|
+
destroy() {
|
4173
|
+
if (!shopGPT) {
|
4174
|
+
return;
|
4175
|
+
}
|
4176
|
+
shopGPT.remove();
|
4177
|
+
shopGPT = undefined;
|
4178
|
+
delete window[registryKey];
|
4179
|
+
},
|
3864
4180
|
});
|
3865
4181
|
}
|
3866
4182
|
|