@blotoutio/providers-shop-gpt-sdk 1.2.1 → 1.4.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.
Files changed (4) hide show
  1. package/index.cjs.js +732 -329
  2. package/index.js +732 -329
  3. package/index.mjs +732 -329
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -384,6 +384,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
384
384
  message: data.message,
385
385
  products: (_a = data.products) === null || _a === void 0 ? void 0 : _a.filter((item) => !!item).map((item) => ({ ...item, quantity: 1 })),
386
386
  chatTitle: data.chatTitle,
387
+ welcomePrompts: data.welcomePrompts,
387
388
  };
388
389
  };
389
390
  const fetchChatHistory = async (threadId) => {
@@ -490,7 +491,7 @@ const init = (params) => {
490
491
  // exit if not in top window
491
492
  return;
492
493
  }
493
- const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
494
+ const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
494
495
  let shouldShowUI = enabled;
495
496
  if (!enabled && hasPreviewKey()) {
496
497
  logger.log('Enabling UI in preview mode');
@@ -516,6 +517,9 @@ const init = (params) => {
516
517
  profiles,
517
518
  productHandles,
518
519
  path: targetPath,
520
+ brandName,
521
+ quickPrompts,
522
+ merchantImage,
519
523
  });
520
524
  }
521
525
  };
@@ -549,7 +553,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
549
553
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
550
554
  PERFORMANCE OF THIS SOFTWARE.
551
555
  ***************************************************************************** */
552
- /* global Reflect, Promise, SuppressedError, Symbol */
556
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
553
557
 
554
558
 
555
559
  function __decorate(decorators, target, key, desc) {
@@ -573,60 +577,53 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
573
577
  * Copyright 2019 Google LLC
574
578
  * SPDX-License-Identifier: BSD-3-Clause
575
579
  */
576
- const t$4=globalThis,e$8=t$4.ShadowRoot&&(void 0===t$4.ShadyCSS||t$4.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$5=new WeakMap;let n$4 = class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s$2)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$8&&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$6=t=>new n$4("string"==typeof t?t:t+"",void 0,s$2),i$3=(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$4(o,t,s$2)},S$1=(s,o)=>{if(e$8)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$4.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$8?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$6(e)})(t):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;
577
581
 
578
582
  /**
579
583
  * @license
580
584
  * Copyright 2017 Google LLC
581
585
  * SPDX-License-Identifier: BSD-3-Clause
582
- */const{is:i$2,defineProperty:e$7,getOwnPropertyDescriptor:r$5,getOwnPropertyNames:h$1,getOwnPropertySymbols:o$4,getPrototypeOf:n$3}=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$2(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$7(this.prototype,t,r);}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r$5(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$3(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");
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");
583
587
 
584
588
  /**
585
589
  * @license
586
590
  * Copyright 2017 Google LLC
587
591
  * SPDX-License-Identifier: BSD-3-Clause
588
592
  */
589
- const t$3=globalThis,i$1=t$3.trustedTypes,s$1=i$1?i$1.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$6="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$2=`<${o$3}>`,r$4=document,l=()=>r$4.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),w=Symbol.for("lit-noChange"),T=Symbol.for("lit-nothing"),A=new WeakMap,E=r$4.createTreeWalker(r$4,129);function C(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$1?s$1.createHTML(i):i}const P=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":"",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$2:d>=0?(o.push(a),s.slice(0,d)+e$6+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [C(t,l+(t[s]||"<?>")+(2===i?"</svg>":"")),o]};class V{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]=P(t,s);if(this.el=V.createElement(f,n),E.currentNode=this.el.content,2===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=E.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$6)){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]?k:"?"===e[1]?H:"@"===e[1]?I:R}),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$1?i$1.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),E.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$4.createElement("template");return s.innerHTML=t,s}}function N(t,i,s=t,e){if(i===w)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=N(t,h._$AS(t,i.values),h,e)),i}class S{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$4).importNode(i,!0);E.currentNode=e;let h=E.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new M(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new L(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=E.nextNode(),o++);}return E.currentNode=r$4,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 M{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=T,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=N(this,t,i),c(t)?t===T||null==t||""===t?(this._$AH!==T&&this._$AR(),this._$AH=T):t!==this._$AH&&t!==w&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}S(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t));}_(t){this._$AH!==T&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$4.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=V.createElement(C(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new S(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 V(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 M(this.S(l()),this.S(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 R{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=T,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=T;}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=N(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==w,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=N(this,e[s+n],i,n),r===w&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===T?t=T:t!==T&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===T?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class k extends R{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===T?void 0:t;}}class H extends R{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==T);}}class I extends R{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=N(this,t,i,0)??T)===w)return;const s=this._$AH,e=t===T&&s!==T||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==T&&(s===T||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 L{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){N(this,t);}}const Z=t$3.litHtmlPolyfillSupport;Z?.(V,M),(t$3.litHtmlVersions??=[]).push("3.1.3");const j=(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 M(i.insertBefore(l(),t),t,void 0,s??{});}return h._$AI(t),h};
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};
590
594
 
591
595
  /**
592
596
  * @license
593
597
  * Copyright 2017 Google LLC
594
598
  * SPDX-License-Identifier: BSD-3-Clause
595
- */class s 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 i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=j(i,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return w}}s._$litElement$=!0,s[("finalized")]=!0,globalThis.litElementHydrateSupport?.({LitElement:s});const r$3=globalThis.litElementPolyfillSupport;r$3?.({LitElement:s});(globalThis.litElementVersions??=[]).push("4.0.5");
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");
596
600
 
597
601
  /**
598
602
  * @license
599
603
  * Copyright 2017 Google LLC
600
604
  * SPDX-License-Identifier: BSD-3-Clause
601
- */
602
- 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)}
603
606
 
604
607
  /**
605
608
  * @license
606
609
  * Copyright 2017 Google LLC
607
610
  * SPDX-License-Identifier: BSD-3-Clause
608
- */const o$2={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1},r$2=(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$1(t){return (e,o)=>"object"==typeof o?r$2(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)}
609
-
610
- /**
611
- * @license
612
- * Copyright 2017 Google LLC
613
- * SPDX-License-Identifier: BSD-3-Clause
614
- */function r$1(r){return n$1({...r,state:!0,attribute:!1})}
611
+ */function r(r){return n({...r,state:!0,attribute:!1})}
615
612
 
616
613
  /**
617
614
  * @license
618
615
  * Copyright 2017 Google LLC
619
616
  * SPDX-License-Identifier: BSD-3-Clause
620
617
  */
621
- const e$5=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
618
+ const e$4=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
622
619
 
623
620
  /**
624
621
  * @license
625
622
  * Copyright 2017 Google LLC
626
623
  * SPDX-License-Identifier: BSD-3-Clause
627
- */function e$4(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$5(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$5(n,s,{get(){return o(this)}})}}
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)}})}}
628
625
 
629
- const scrollBarStyles = i$3 `
626
+ const scrollBarStyles = i$4 `
630
627
  ::-webkit-scrollbar {
631
628
  width: 20px;
632
629
  }
@@ -646,7 +643,7 @@ const scrollBarStyles = i$3 `
646
643
  background-color: #a8bbbf;
647
644
  }
648
645
  `;
649
- const shopGPTStyles = i$3 `
646
+ const shopGPTStyles = i$4 `
650
647
  ${scrollBarStyles}
651
648
 
652
649
  * {
@@ -710,6 +707,35 @@ const shopGPTStyles = i$3 `
710
707
  align-items: center;
711
708
  box-shadow: 0 0 4px 1px #ffffff;
712
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
+ }
713
739
  }
714
740
 
715
741
  .mobile-version {
@@ -757,13 +783,13 @@ const shopGPTStyles = i$3 `
757
783
  * Copyright 2017 Google LLC
758
784
  * SPDX-License-Identifier: BSD-3-Clause
759
785
  */
760
- const t$1={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e$3=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)}}
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)}}
761
787
 
762
788
  /**
763
789
  * @license
764
790
  * Copyright 2018 Google LLC
765
791
  * SPDX-License-Identifier: BSD-3-Clause
766
- */const e$2=e$3(class extends i{constructor(t){if(super(t),t.type!==t$1.ATTRIBUTE||"class"!==t.name||t.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 w}});
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}});
767
793
 
768
794
  /**
769
795
  * @license
@@ -843,7 +869,7 @@ const shopGPTIcon = b `<svg xmlns="http://www.w3.org/2000/svg" width="105" heigh
843
869
  <path d="M90.323 25.7117C90.2401 25.7117 90.1986 25.7117 90.1669 25.7281C90.1391 25.7424 90.1165 25.7653 90.1022 25.7934C90.0861 25.8255 90.0861 25.8674 90.0861 25.9512V26.9203H89.7359C89.6558 26.9203 89.6148 26.9205 89.5836 26.9366C89.5558 26.9509 89.5331 26.9738 89.5189 27.002C89.5028 27.034 89.5028 27.0759 89.5028 27.1597V27.717C89.5028 27.8008 89.5028 27.8427 89.5189 27.8748C89.5331 27.9029 89.5558 27.9258 89.5836 27.9402C89.6153 27.9565 89.6568 27.9565 89.7397 27.9565H90.0861V32.1113H90.0847C90.0843 32.1182 90.0838 32.1251 90.0835 32.1319C90.0841 32.1478 90.085 32.1637 90.0861 32.1795V32.2192L90.0883 32.2191C90.1341 33.0885 90.844 33.7701 91.7052 33.7715C91.8727 33.7713 92.0388 33.745 92.1978 33.6936C92.2668 33.6713 92.321 33.5887 92.3208 33.5154L92.3225 32.749C92.3226 32.7376 92.3205 32.7194 92.3176 32.7084C92.317 32.7064 92.3165 32.7043 92.3159 32.7022C92.3113 32.6856 92.297 32.6611 92.283 32.651C92.2793 32.6484 92.2311 32.6207 92.1908 32.6453C92.1477 32.6656 92.147 32.6659 92.1463 32.6662C92.1353 32.6715 92.0981 32.6856 92.0807 32.6958C91.9299 32.7603 91.9074 32.7589 91.8631 32.7651C91.8328 32.7694 91.8023 32.7716 91.7716 32.7716C91.7139 32.7716 91.6565 32.7639 91.6007 32.7488C91.5449 32.7337 91.4914 32.7113 91.4414 32.6821C91.4146 32.6643 91.3891 32.6445 91.3652 32.623C91.3511 32.613 91.3375 32.6024 91.3243 32.5912C91.3176 32.5863 91.3111 32.5812 91.3046 32.576C91.3029 32.5738 91.3012 32.5715 91.2995 32.5692C91.1797 32.456 91.1115 32.2977 91.1112 32.1319C91.1116 32.1265 91.1121 32.1212 91.1127 32.1158C91.1122 32.1118 91.1116 32.1079 91.1112 32.1039V27.9565H92.0702C92.1531 27.9565 92.1946 27.9565 92.2262 27.9402C92.2541 27.9258 92.2767 27.9029 92.2909 27.8748C92.3071 27.8427 92.3071 27.8008 92.3071 27.717V27.1597C92.3071 27.0759 92.3071 27.034 92.2909 27.002C92.2767 26.9738 92.2541 26.9509 92.2262 26.9366C92.1946 26.9203 92.1531 26.9203 92.0702 26.9203H91.1112V25.9512C91.1112 25.8674 91.1112 25.8255 91.095 25.7934C91.0808 25.7653 91.0582 25.7424 91.0303 25.7281C90.9986 25.7117 90.9572 25.7117 90.8743 25.7117H90.323Z" fill="#F25C2B"/>
844
870
  </svg>`;
845
871
 
846
- const chatThreadsStyles = i$3 `
872
+ const chatThreadsStyles = i$4 `
847
873
  :host {
848
874
  padding: 24px 24px 21px;
849
875
  font-family: 'Inter', sans-serif;
@@ -918,11 +944,35 @@ const chatThreadsStyles = i$3 `
918
944
  color: #677c95;
919
945
  font-weight: 500;
920
946
  text-transform: uppercase;
921
- margin: 0 0 12px;
947
+ margin: 0;
922
948
  max-height: 18px;
923
949
  padding-left: 12px;
924
950
  }
925
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
+
926
976
  .threads {
927
977
  flex: 1;
928
978
  overflow-y: auto;
@@ -935,17 +985,6 @@ const chatThreadsStyles = i$3 `
935
985
 
936
986
  .trash-icon {
937
987
  display: none;
938
- padding: 2px;
939
- cursor: pointer;
940
-
941
- &:hover {
942
- border-radius: 5px;
943
- background: #dc3545;
944
-
945
- path {
946
- fill: white;
947
- }
948
- }
949
988
  }
950
989
 
951
990
  &:hover {
@@ -994,15 +1033,13 @@ const chatThreadsStyles = i$3 `
994
1033
  }
995
1034
  `;
996
1035
 
997
- let LoadSpinner =
998
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
999
- class LoadSpinner extends s {
1036
+ class LoadSpinner extends r$2 {
1000
1037
  render() {
1001
1038
  return x ` <div class="loader"><div class="spinner"></div></div> `;
1002
1039
  }
1003
- };
1040
+ }
1004
1041
  LoadSpinner.styles = [
1005
- i$3 `
1042
+ i$4 `
1006
1043
  .loader {
1007
1044
  display: flex;
1008
1045
  flex: 1;
@@ -1034,14 +1071,15 @@ LoadSpinner.styles = [
1034
1071
  }
1035
1072
  `,
1036
1073
  ];
1037
- LoadSpinner = __decorate([
1038
- t$2('load-spinner')
1039
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1040
- ], LoadSpinner);
1041
-
1042
- let ChatThreads =
1043
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1044
- class ChatThreads extends s {
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
+ }
1045
1083
  getDomain() {
1046
1084
  var _a;
1047
1085
  if ((_a = this.merchantUrl) === null || _a === void 0 ? void 0 : _a.startsWith('https://')) {
@@ -1050,6 +1088,14 @@ class ChatThreads extends s {
1050
1088
  return `https://${this.merchantUrl}`;
1051
1089
  }
1052
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
+ }
1053
1099
  if (!this.deleteThreadId) {
1054
1100
  return;
1055
1101
  }
@@ -1069,12 +1115,27 @@ class ChatThreads extends s {
1069
1115
  }
1070
1116
  return x `
1071
1117
  <div class="history">
1072
- <p class="title">History</p>
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>
1073
1134
  ${this.chatThreads.size
1074
1135
  ? x `<div class="threads">
1075
1136
  ${o$1(this.chatThreads.values(), (thread) => x `
1076
1137
  <div
1077
- class=${e$2({
1138
+ class=${e$1({
1078
1139
  'thread-wrapper': true,
1079
1140
  active: this.selectedThreadId === thread.threadId,
1080
1141
  disabled: this.isTyping,
@@ -1105,7 +1166,7 @@ class ChatThreads extends s {
1105
1166
  </div>
1106
1167
  `)}
1107
1168
  </div>`
1108
- : T}
1169
+ : E}
1109
1170
  </div>
1110
1171
  `;
1111
1172
  }
@@ -1127,55 +1188,69 @@ class ChatThreads extends s {
1127
1188
  ${this.getDomain().replace('https://', '')}
1128
1189
  </a>
1129
1190
  </div>`
1130
- : T}
1131
- ${this.deleteThreadId
1191
+ : E}
1192
+ ${this.deleteThreadId || this.deleteAllThreads
1132
1193
  ? x `
1133
1194
  <confirm-dialog
1134
1195
  @accept=${this.handleThreadDelete}
1135
- @decline=${() => (this.deleteThreadId = '')}
1196
+ @decline=${() => {
1197
+ this.deleteThreadId = '';
1198
+ this.deleteAllThreads = false;
1199
+ }}
1136
1200
  >
1137
- <h2 slot="title">Delete Thread?</h2>
1201
+ <h2 slot="title">
1202
+ ${this.deleteAllThreads
1203
+ ? 'Delete Entire Chat History?'
1204
+ : 'Delete Chat?'}
1205
+ </h2>
1138
1206
  <p slot="content">
1139
1207
  This action cannot be undone. Are you sure you want to delete
1140
- <b>"${this.chatThreads.get(this.deleteThreadId).title}"</b>?
1208
+ ${this.deleteAllThreads
1209
+ ? ' the entire chat history'
1210
+ : x `<b
1211
+ >"${this.chatThreads.get(this.deleteThreadId).title}"</b
1212
+ >`}?
1141
1213
  </p>
1142
1214
  </confirm-dialog>
1143
1215
  `
1144
- : T}
1216
+ : E}
1145
1217
  `;
1146
1218
  }
1147
- };
1219
+ }
1148
1220
  ChatThreads.styles = [chatThreadsStyles];
1149
1221
  __decorate([
1150
- n$1({ type: Object }),
1222
+ n({ type: Object }),
1151
1223
  __metadata("design:type", Map)
1152
1224
  ], ChatThreads.prototype, "chatThreads", void 0);
1153
1225
  __decorate([
1154
- n$1({ type: String }),
1226
+ n({ type: String }),
1155
1227
  __metadata("design:type", Object)
1156
1228
  ], ChatThreads.prototype, "merchantUrl", void 0);
1157
1229
  __decorate([
1158
- n$1({ type: Boolean }),
1230
+ n({ type: Boolean }),
1159
1231
  __metadata("design:type", Boolean)
1160
1232
  ], ChatThreads.prototype, "isLoading", void 0);
1161
1233
  __decorate([
1162
- n$1({ type: Boolean }),
1234
+ n({ type: Boolean }),
1163
1235
  __metadata("design:type", Boolean)
1164
1236
  ], ChatThreads.prototype, "isTyping", void 0);
1165
1237
  __decorate([
1166
- n$1({ type: String }),
1238
+ n({ type: String }),
1167
1239
  __metadata("design:type", String)
1168
1240
  ], ChatThreads.prototype, "selectedThreadId", void 0);
1169
1241
  __decorate([
1170
- r$1(),
1242
+ r(),
1171
1243
  __metadata("design:type", String)
1172
1244
  ], ChatThreads.prototype, "deleteThreadId", void 0);
1173
- ChatThreads = __decorate([
1174
- t$2('chat-threads')
1175
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1176
- ], 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
+ }
1177
1252
 
1178
- const productsSectionStyles = i$3 `
1253
+ const productsSectionStyles = i$4 `
1179
1254
  :host {
1180
1255
  padding: 24px 16px;
1181
1256
  background-color: #fff;
@@ -1211,9 +1286,14 @@ const productsSectionStyles = i$3 `
1211
1286
  justify-content: center;
1212
1287
  height: 100%;
1213
1288
  }
1289
+
1290
+ .merchant-image {
1291
+ width: 100%;
1292
+ object-fit: contain;
1293
+ }
1214
1294
  `;
1215
1295
 
1216
- const productItemStyles = i$3 `
1296
+ const productItemStyles = i$4 `
1217
1297
  :host {
1218
1298
  font-family: 'Inter', sans-serif;
1219
1299
  font-size: 16px;
@@ -1356,9 +1436,7 @@ const productItemStyles = i$3 `
1356
1436
  }
1357
1437
  `;
1358
1438
 
1359
- let ProductItem =
1360
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1361
- class ProductItem extends s {
1439
+ class ProductItem extends r$2 {
1362
1440
  getLocalPrice(price) {
1363
1441
  if (!this.siteCurrency) {
1364
1442
  return price;
@@ -1366,6 +1444,16 @@ class ProductItem extends s {
1366
1444
  const localPrice = parseFloat(price) * this.siteCurrency.rate;
1367
1445
  return formatMoney(localPrice, this.siteCurrency.currency);
1368
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
+ }
1369
1457
  redirect(url) {
1370
1458
  var _a;
1371
1459
  if (!url) {
@@ -1374,8 +1462,8 @@ class ProductItem extends s {
1374
1462
  (_a = open(url, '_blank')) === null || _a === void 0 ? void 0 : _a.focus();
1375
1463
  }
1376
1464
  renderVariantTitles() {
1377
- if (!this.product.hasVariantsThatRequiresComponents) {
1378
- return T;
1465
+ if (this.product.hasOnlyDefaultVariant) {
1466
+ return E;
1379
1467
  }
1380
1468
  return this.product.variants[0].selectedOptions.map((option) => x `
1381
1469
  <p class="product-variation-details">${option.name}: ${option.value}</p>
@@ -1399,13 +1487,7 @@ class ProductItem extends s {
1399
1487
  </p>
1400
1488
  ${this.renderVariantTitles()}
1401
1489
  <div class="prices">
1402
- ${this.product.variants[0].comparedAtPrice &&
1403
- this.product.variants[0].comparedAtPrice !==
1404
- this.product.variants[0].price
1405
- ? x `<p class="price-compared">
1406
- ${this.getLocalPrice(this.product.variants[0].comparedAtPrice)}
1407
- </p>`
1408
- : T}
1490
+ ${this.getComparedAtPrice(this.product.variants[0].comparedAtPrice, this.product.variants[0].price)}
1409
1491
  <p>${this.getLocalPrice(this.product.variants[0].price)}</p>
1410
1492
  </div>
1411
1493
  <button
@@ -1418,22 +1500,21 @@ class ProductItem extends s {
1418
1500
  </div>
1419
1501
  `;
1420
1502
  }
1421
- };
1503
+ }
1422
1504
  ProductItem.styles = [productItemStyles];
1423
1505
  __decorate([
1424
- n$1({ type: Object }),
1506
+ n({ type: Object }),
1425
1507
  __metadata("design:type", Object)
1426
1508
  ], ProductItem.prototype, "product", void 0);
1427
1509
  __decorate([
1428
- n$1({ type: Object }),
1510
+ n({ type: Object }),
1429
1511
  __metadata("design:type", Object)
1430
1512
  ], ProductItem.prototype, "siteCurrency", void 0);
1431
- ProductItem = __decorate([
1432
- t$2('product-item')
1433
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1434
- ], ProductItem);
1513
+ if (!customElements.get('product-item')) {
1514
+ customElements.define('product-item', ProductItem);
1515
+ }
1435
1516
 
1436
- const productsListStyles = i$3 `
1517
+ const productsListStyles = i$4 `
1437
1518
  .products::-webkit-scrollbar {
1438
1519
  display: none;
1439
1520
  }
@@ -1459,6 +1540,8 @@ const productsListStyles = i$3 `
1459
1540
  gap: 24px;
1460
1541
  overflow-x: auto;
1461
1542
  scrollbar-width: none;
1543
+ margin-left: -10px;
1544
+ padding-left: 10px;
1462
1545
  }
1463
1546
 
1464
1547
  .scroll-btns {
@@ -1493,19 +1576,34 @@ const productsListStyles = i$3 `
1493
1576
  }
1494
1577
  `;
1495
1578
 
1496
- let ProductsList =
1497
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1498
- class ProductsList extends s {
1579
+ class ProductsList extends r$2 {
1580
+ constructor() {
1581
+ super(...arguments);
1582
+ this.showButtons = true;
1583
+ this.updateButtonsState = () => {
1584
+ if (!this.leftBtnEle || !this.productsEle || !this.rightBtnEle) {
1585
+ return;
1586
+ }
1587
+ const { scrollWidth, clientWidth } = this.productsEle;
1588
+ this.showButtons = scrollWidth > clientWidth;
1589
+ this.leftBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft === 0);
1590
+ const maxScroll = this.productsEle.scrollWidth - this.productsEle.clientWidth;
1591
+ this.rightBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft >= maxScroll - 1);
1592
+ };
1593
+ }
1499
1594
  connectedCallback() {
1500
1595
  super.connectedCallback();
1596
+ this.updateButtonsState();
1597
+ window.addEventListener('resize', this.updateButtonsState);
1501
1598
  }
1502
- updateButtonsState() {
1503
- if (!this.leftBtnEle || !this.productsEle || !this.rightBtnEle) {
1504
- return;
1599
+ disconnectedCallback() {
1600
+ window.removeEventListener('resize', this.updateButtonsState);
1601
+ super.disconnectedCallback();
1602
+ }
1603
+ updated(_changedProperties) {
1604
+ if (_changedProperties.has('products')) {
1605
+ this.updateButtonsState();
1505
1606
  }
1506
- this.leftBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft === 0);
1507
- const maxScroll = this.productsEle.scrollWidth - this.productsEle.clientWidth;
1508
- this.rightBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft >= maxScroll - 1);
1509
1607
  }
1510
1608
  scrollToLeft(e) {
1511
1609
  var _a;
@@ -1519,14 +1617,14 @@ class ProductsList extends s {
1519
1617
  }
1520
1618
  render() {
1521
1619
  if (!this.products.length) {
1522
- return T;
1620
+ return E;
1523
1621
  }
1524
1622
  return x `
1525
1623
  <div class="products-wrapper">
1526
1624
  <div class="products" @scroll=${this.updateButtonsState}>
1527
1625
  ${o$1(this.products, (product) => x `
1528
1626
  <div
1529
- class=${e$2({
1627
+ class=${e$1({
1530
1628
  'product-container': true,
1531
1629
  modal: this.viewType === 'modal',
1532
1630
  })}
@@ -1538,60 +1636,71 @@ class ProductsList extends s {
1538
1636
  </div>
1539
1637
  `)}
1540
1638
  </div>
1541
- <div class="scroll-btns">
1542
- <div class="left-btn disabled" @click=${this.scrollToLeft}>
1543
- ${leftBtn}
1544
- </div>
1545
- <div class="right-btn" @click=${this.scrollToRight}>${rightBtn}</div>
1546
- </div>
1639
+ ${this.showButtons
1640
+ ? x ` <div class="scroll-btns">
1641
+ <div class="left-btn disabled" @click=${this.scrollToLeft}>
1642
+ ${leftBtn}
1643
+ </div>
1644
+ <div class="right-btn" @click=${this.scrollToRight}>
1645
+ ${rightBtn}
1646
+ </div>
1647
+ </div>`
1648
+ : E}
1547
1649
  </div>
1548
1650
  `;
1549
1651
  }
1550
- };
1652
+ }
1551
1653
  ProductsList.styles = [productsListStyles];
1552
1654
  __decorate([
1553
- n$1({ type: Array }),
1655
+ n({ type: Array }),
1554
1656
  __metadata("design:type", Array)
1555
1657
  ], ProductsList.prototype, "products", void 0);
1556
1658
  __decorate([
1557
- n$1({ type: Object }),
1659
+ n({ type: Object }),
1558
1660
  __metadata("design:type", Object)
1559
1661
  ], ProductsList.prototype, "siteCurrency", void 0);
1560
1662
  __decorate([
1561
- e$4('.left-btn'),
1663
+ r(),
1664
+ __metadata("design:type", Object)
1665
+ ], ProductsList.prototype, "showButtons", void 0);
1666
+ __decorate([
1667
+ e$3('.left-btn'),
1562
1668
  __metadata("design:type", Object)
1563
1669
  ], ProductsList.prototype, "leftBtnEle", void 0);
1564
1670
  __decorate([
1565
- e$4('.right-btn'),
1671
+ e$3('.right-btn'),
1566
1672
  __metadata("design:type", Object)
1567
1673
  ], ProductsList.prototype, "rightBtnEle", void 0);
1568
1674
  __decorate([
1569
- e$4('.products'),
1675
+ e$3('.products'),
1570
1676
  __metadata("design:type", Object)
1571
1677
  ], ProductsList.prototype, "productsEle", void 0);
1572
- ProductsList = __decorate([
1573
- t$2('products-list')
1574
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1575
- ], ProductsList);
1576
-
1577
- let ProductsSection =
1578
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1579
- class ProductsSection extends s {
1678
+ if (!customElements.get('products-list')) {
1679
+ customElements.define('products-list', ProductsList);
1680
+ }
1681
+
1682
+ class ProductsSection extends r$2 {
1580
1683
  connectedCallback() {
1581
1684
  super.connectedCallback();
1582
1685
  }
1686
+ renderMerchantImage() {
1687
+ if (this.merchantImage) {
1688
+ return x ` <img class="merchant-image" src=${this.merchantImage} /> `;
1689
+ }
1690
+ return x `
1691
+ <div>${searchIcon}</div>
1692
+ <p>
1693
+ Start exploring by typing your query in the search bar on the right.
1694
+ </p>
1695
+ `;
1696
+ }
1583
1697
  render() {
1584
- if (this.isLoadingHistory) {
1698
+ if (this.isLoadingHistory || this.isLoadingThreads) {
1585
1699
  return x ` <load-spinner></load-spinner> `;
1586
1700
  }
1587
1701
  if (!this.products.length) {
1588
1702
  return x `
1589
- <div class="no-products">
1590
- <div>${searchIcon}</div>
1591
- <p>
1592
- Start exploring by typing your query in the search bar on the right.
1593
- </p>
1594
- </div>
1703
+ <div class="no-products">${this.renderMerchantImage()}</div>
1595
1704
  `;
1596
1705
  }
1597
1706
  const topResult = this.products[0];
@@ -1615,38 +1724,45 @@ class ProductsSection extends s {
1615
1724
  </div>
1616
1725
  `;
1617
1726
  }
1618
- };
1727
+ }
1619
1728
  ProductsSection.styles = [productsSectionStyles];
1620
1729
  __decorate([
1621
- n$1({ type: Array }),
1730
+ n({ type: String }),
1731
+ __metadata("design:type", Object)
1732
+ ], ProductsSection.prototype, "merchantImage", void 0);
1733
+ __decorate([
1734
+ n({ type: Array }),
1622
1735
  __metadata("design:type", Array)
1623
1736
  ], ProductsSection.prototype, "products", void 0);
1624
1737
  __decorate([
1625
- n$1({ type: Boolean }),
1738
+ n({ type: Boolean }),
1626
1739
  __metadata("design:type", Boolean)
1627
1740
  ], ProductsSection.prototype, "isLoadingHistory", void 0);
1628
1741
  __decorate([
1629
- n$1({ type: Object }),
1742
+ n({ type: Object }),
1630
1743
  __metadata("design:type", Object)
1631
1744
  ], ProductsSection.prototype, "siteCurrency", void 0);
1632
1745
  __decorate([
1633
- e$4('.left-btn'),
1746
+ n({ type: Boolean }),
1747
+ __metadata("design:type", Boolean)
1748
+ ], ProductsSection.prototype, "isLoadingThreads", void 0);
1749
+ __decorate([
1750
+ e$3('.left-btn'),
1634
1751
  __metadata("design:type", Object)
1635
1752
  ], ProductsSection.prototype, "leftBtnEle", void 0);
1636
1753
  __decorate([
1637
- e$4('.right-btn'),
1754
+ e$3('.right-btn'),
1638
1755
  __metadata("design:type", Object)
1639
1756
  ], ProductsSection.prototype, "rightBtnEle", void 0);
1640
1757
  __decorate([
1641
- e$4('.products'),
1758
+ e$3('.products'),
1642
1759
  __metadata("design:type", Object)
1643
1760
  ], ProductsSection.prototype, "productsEle", void 0);
1644
- ProductsSection = __decorate([
1645
- t$2('products-section')
1646
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1647
- ], ProductsSection);
1761
+ if (!customElements.get('products-section')) {
1762
+ customElements.define('products-section', ProductsSection);
1763
+ }
1648
1764
 
1649
- const chatSectionStyles = i$3 `
1765
+ const chatSectionStyles = i$4 `
1650
1766
  :host {
1651
1767
  font-family: 'Inter', sans-serif;
1652
1768
  font-size: 16px;
@@ -1824,6 +1940,20 @@ const chatSectionStyles = i$3 `
1824
1940
  gap: 28px;
1825
1941
  padding-bottom: 10px;
1826
1942
  margin-bottom: -10px;
1943
+ margin-right: -10px;
1944
+ padding-right: 10px;
1945
+ margin-left: -10px;
1946
+ padding-left: 10px;
1947
+ background: linear-gradient(#f7f8fa80, #f7f8fa80),
1948
+ var(--shopgpt-merchant-img-url);
1949
+ background-position: center;
1950
+ background-repeat: no-repeat;
1951
+ background-size: contain;
1952
+
1953
+ &.loading {
1954
+ justify-content: center;
1955
+ align-items: center;
1956
+ }
1827
1957
 
1828
1958
  .message:last-child {
1829
1959
  margin-top: 10px;
@@ -1994,7 +2124,7 @@ const chatSectionStyles = i$3 `
1994
2124
  .prompts {
1995
2125
  display: flex;
1996
2126
  justify-content: center;
1997
- gap: 23px 10px;
2127
+ gap: 10px;
1998
2128
  flex-wrap: wrap;
1999
2129
 
2000
2130
  .prompt {
@@ -2030,13 +2160,19 @@ const chatSectionStyles = i$3 `
2030
2160
  0px 20px 20px 0px rgba(0, 0, 0, 0.08);
2031
2161
  border-radius: 0px 0px 10px 10px;
2032
2162
 
2033
- h2 {
2034
- padding: 10px 16px;
2035
- color: #172a41;
2036
- font-size: 16px;
2037
- font-weight: 700;
2038
- line-height: 20px;
2163
+ .title-wrapper {
2164
+ display: flex;
2165
+ justify-content: space-between;
2166
+ align-items: center;
2039
2167
  border-bottom: 1px solid #dbe2eb;
2168
+ padding: 10px 16px;
2169
+
2170
+ h2 {
2171
+ color: #172a41;
2172
+ font-size: 16px;
2173
+ font-weight: 700;
2174
+ line-height: 20px;
2175
+ }
2040
2176
  }
2041
2177
 
2042
2178
  .thread-titles-wrapper {
@@ -2120,7 +2256,7 @@ const crossBtn = b `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="2
2120
2256
  <path d="M18 7.05L16.95 6L12 10.95L7.05 6L6 7.05L10.95 12L6 16.95L7.05 18L12 13.05L16.95 18L18 16.95L13.05 12L18 7.05Z" fill="white"/>
2121
2257
  </svg>`;
2122
2258
 
2123
- const personalizeDialogStyles = i$3 `
2259
+ const personalizeDialogStyles = i$4 `
2124
2260
  :host {
2125
2261
  font-family: 'Inter', sans-serif;
2126
2262
  font-size: 16px;
@@ -2358,9 +2494,7 @@ const profilePlusIcon = b `<svg xmlns="http://www.w3.org/2000/svg" width="56" he
2358
2494
  <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"/>
2359
2495
  </svg>`;
2360
2496
 
2361
- let PersonalizeDialog =
2362
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2363
- class PersonalizeDialog extends s {
2497
+ class PersonalizeDialog extends r$2 {
2364
2498
  constructor() {
2365
2499
  super(...arguments);
2366
2500
  this.isLoading = false;
@@ -2383,7 +2517,7 @@ class PersonalizeDialog extends s {
2383
2517
  return this.selectProductHandle();
2384
2518
  }
2385
2519
  }
2386
- return T;
2520
+ return E;
2387
2521
  };
2388
2522
  }
2389
2523
  showModal() {
@@ -2567,7 +2701,7 @@ class PersonalizeDialog extends s {
2567
2701
  : 'Select Product'}
2568
2702
  </div>
2569
2703
  <ul class="dropdown-list">
2570
- ${(_a = this.defaultProductHandles) === null || _a === void 0 ? void 0 : _a.map((productHandle) => x `<li
2704
+ ${(_a = this.defaultProductHandles) === null || _a === void 0 ? void 0 : _a.map((productHandle) => x ` <li
2571
2705
  class="dropdown-item"
2572
2706
  @click=${() => {
2573
2707
  this.productHandle = productHandle;
@@ -2579,10 +2713,10 @@ class PersonalizeDialog extends s {
2579
2713
  </ul>
2580
2714
  </div>
2581
2715
  ${this.productHandle
2582
- ? x `<button class="finish-btn" @click=${this.handleSubmit}>
2716
+ ? x ` <button class="finish-btn" @click=${this.handleSubmit}>
2583
2717
  Finish
2584
2718
  </button>`
2585
- : T}
2719
+ : E}
2586
2720
  `;
2587
2721
  }
2588
2722
  render() {
@@ -2590,10 +2724,10 @@ class PersonalizeDialog extends s {
2590
2724
  <dialog>
2591
2725
  <div class="dialog-title">
2592
2726
  ${this.state !== 'profile-type'
2593
- ? x `<div class="back-btn btn" @click=${this.handleBackStep}>
2727
+ ? x ` <div class="back-btn btn" @click=${this.handleBackStep}>
2594
2728
  ${backBtn}
2595
2729
  </div>`
2596
- : T}
2730
+ : E}
2597
2731
  <h2>Personalize your search</h2>
2598
2732
  <div class="close-btn btn" @click=${() => this.dialogModal.close()}>
2599
2733
  ${closeBtn}
@@ -2603,75 +2737,174 @@ class PersonalizeDialog extends s {
2603
2737
  </dialog>
2604
2738
  `;
2605
2739
  }
2606
- };
2740
+ }
2607
2741
  PersonalizeDialog.styles = [personalizeDialogStyles];
2608
2742
  __decorate([
2609
- e$4('dialog'),
2743
+ e$3('dialog'),
2610
2744
  __metadata("design:type", HTMLDialogElement)
2611
2745
  ], PersonalizeDialog.prototype, "dialogModal", void 0);
2612
2746
  __decorate([
2613
- e$4('.dropdown-list'),
2747
+ e$3('.dropdown-list'),
2614
2748
  __metadata("design:type", HTMLUListElement)
2615
2749
  ], PersonalizeDialog.prototype, "dropdownList", void 0);
2616
2750
  __decorate([
2617
- e$4('.dropdown-trigger'),
2751
+ e$3('.dropdown-trigger'),
2618
2752
  __metadata("design:type", HTMLDivElement)
2619
2753
  ], PersonalizeDialog.prototype, "dropdownTrigger", void 0);
2620
2754
  __decorate([
2621
- n$1({ type: Array }),
2755
+ n({ type: Array }),
2622
2756
  __metadata("design:type", Array)
2623
2757
  ], PersonalizeDialog.prototype, "defaultProductHandles", void 0);
2624
2758
  __decorate([
2625
- n$1({ type: Array }),
2759
+ n({ type: Array }),
2626
2760
  __metadata("design:type", Array)
2627
2761
  ], PersonalizeDialog.prototype, "defaultProfiles", void 0);
2628
2762
  __decorate([
2629
- n$1({ type: Boolean }),
2630
- __metadata("design:type", Boolean)
2763
+ n({ type: Boolean }),
2764
+ __metadata("design:type", Object)
2631
2765
  ], PersonalizeDialog.prototype, "isLoading", void 0);
2632
2766
  __decorate([
2633
- n$1({ type: String }),
2767
+ n({ type: String }),
2634
2768
  __metadata("design:type", Object)
2635
2769
  ], PersonalizeDialog.prototype, "state", void 0);
2636
2770
  __decorate([
2637
- n$1({ type: String }),
2771
+ n({ type: String }),
2638
2772
  __metadata("design:type", Object)
2639
2773
  ], PersonalizeDialog.prototype, "profileType", void 0);
2640
2774
  __decorate([
2641
- n$1({ type: String }),
2775
+ n({ type: String }),
2642
2776
  __metadata("design:type", Object)
2643
2777
  ], PersonalizeDialog.prototype, "selectedProfile", void 0);
2644
2778
  __decorate([
2645
- n$1({ type: String }),
2779
+ n({ type: String }),
2646
2780
  __metadata("design:type", Object)
2647
2781
  ], PersonalizeDialog.prototype, "visitorType", void 0);
2648
2782
  __decorate([
2649
- n$1({ type: String }),
2783
+ n({ type: String }),
2650
2784
  __metadata("design:type", Object)
2651
2785
  ], PersonalizeDialog.prototype, "productHandle", void 0);
2652
- PersonalizeDialog = __decorate([
2653
- t$2('personalize-dialog')
2654
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2655
- ], PersonalizeDialog);
2786
+ if (!customElements.get('personalize-dialog')) {
2787
+ customElements.define('personalize-dialog', PersonalizeDialog);
2788
+ }
2656
2789
 
2657
2790
  /**
2658
2791
  * @license
2659
2792
  * Copyright 2017 Google LLC
2660
2793
  * SPDX-License-Identifier: BSD-3-Clause
2661
- */let e$1 = class e extends i{constructor(i){if(super(i),this.it=T,i.type!==t$1.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===T||null==r)return this._t=void 0,this.it=r;if(r===w)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$1.directiveName="unsafeHTML",e$1.resultType=1;const o=e$3(e$1);
2662
-
2663
- var e={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function n(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function r(e){return (e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function t(a,c){var o,l,g,s,p,u=/((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,m=[],h="",i=c||{},d=0;function f(n){var r=e[n[1]||""],t=m[m.length-1]==n;return r?r[1]?(t?m.pop():m.push(n),r[0|t]):r[0]:n}function $(){for(var e="";m.length;)e+=f(m[m.length-1]);return e}for(a=a.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(e,n,r){return i[n.toLowerCase()]=r,""}).replace(/^\n+|\n+$/g,"");g=u.exec(a);)l=a.substring(d,g.index),d=u.lastIndex,o=g[0],l.match(/[^\\](\\\\)*\\$/)||((p=g[3]||g[4])?o='<pre class="code '+(g[4]?"poetry":g[2].toLowerCase())+'"><code'+(g[2]?' class="language-'+g[2].toLowerCase()+'"':"")+">"+n(r(p).replace(/^\n+|\n+$/g,""))+"</code></pre>":(p=g[6])?(p.match(/\./)&&(g[5]=g[5].replace(/^\d+/gm,"")),s=t(n(g[5].replace(/^\s*[>*+.-]/gm,""))),">"==p?p="blockquote":(p=p.match(/\./)?"ol":"ul",s=s.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),o="<"+p+">"+s+"</"+p+">"):g[8]?o='<img src="'+r(g[8])+'" alt="'+r(g[7])+'">':g[10]?(h=h.replace("<a>",'<a href="'+r(g[11]||i[l.toLowerCase()])+'">'),o=$()+"</a>"):g[9]?o="<a>":g[12]||g[14]?o="<"+(p="h"+(g[14]?g[14].length:g[13]>"="?1:2))+">"+t(g[12]||g[15],i)+"</"+p+">":g[16]?o="<code>"+r(g[16])+"</code>":(g[17]||g[1])&&(o=f(g[17]||"--"))),h+=l,h+=o;return (h+a.substring(d)+$()).replace(/^\n+|\n+$/g,"")}
2794
+ */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);
2795
+
2796
+ const markdown = (text) => {
2797
+ let src = text;
2798
+ const rx_space = /\t|\r|\uf8ff/g;
2799
+ const rx_hr = /^([*\-=_] *){3,}$/gm;
2800
+ const rx_blockquote = /\n *> *([^]*?)(?=(\n|$){2})/g;
2801
+ const rx_list = /\n( *)(?:[*\-+]|((\d+)|([a-z])|[A-Z])[.)]) +([^]*?)(?=(\n|$){2})/g;
2802
+ const rx_listjoin = /<\/(ol|ul)>\n\n<\1>/g;
2803
+ const rx_highlight = /(^|[^A-Za-z\d\\])(([*_])|(~)|(\^)|(--)|(\+\+)|`)(\2?)([^<]*?)\2\8(?!\2)(?=\W|_|$)/g;
2804
+ const rx_code = /\n((```|~~~).*\n?([^]*?)\n?\2|(( {4}.*?\n)+))/g;
2805
+ const rx_link = /((!?)\[(.*?)\]\((.*?)( ".*")?\)|\\([\\`*_{}[\]()#+\-.!~]))/g;
2806
+ const rx_table = /\n(( *\|.*?\| *\n)+)/g;
2807
+ const rx_thead = /^.*\n( *\|( *:?-+:?-+:? *\|)* *\n|)/;
2808
+ const rx_row = /.*\n/g;
2809
+ const rx_cell = /\|(.*?[^\\])\|/g;
2810
+ const rx_heading = /(?=^|>|\n)([>\s]*?)(#{1,6}) (.*?)( #*)? *(?=\n|$)/g;
2811
+ const rx_para = /(?=^|>|\n)\s*\n+([^<]+?)\n+\s*(?=\n|<|$)/g;
2812
+ const rx_stash = /-\d+\uf8ff/g;
2813
+ const stash = {};
2814
+ let si = 0;
2815
+ function replace(rex, fn) {
2816
+ src = src.replace(rex, fn);
2817
+ }
2818
+ function element(tag, content) {
2819
+ return `<${tag}>${content}</${tag}>`;
2820
+ }
2821
+ function blockquote(src) {
2822
+ return src.replace(rx_blockquote, (_, content) => {
2823
+ return element('blockquote', blockquote(highlight(content.replace(/^ *> */gm, ''))));
2824
+ });
2825
+ }
2826
+ function list(src) {
2827
+ return src.replace(rx_list, (all, ind, ol, num, low, content) => {
2828
+ const entry = element('li', highlight(content
2829
+ .split(new RegExp(`\n ?${ind}(?:(?:\\d+|[a-zA-Z])[.)]|[*\\-+]) +`, 'g'))
2830
+ .map(list)
2831
+ .join('</li><li>')));
2832
+ return `\n${ol
2833
+ ? `<ol start="${num
2834
+ ? ol + '">'
2835
+ : `${parseInt(ol, 36) - 9}" style="list-style-type:${low ? 'low' : 'upp'}er-alpha">`}${entry}</ol>`
2836
+ : element('ul', entry)}`;
2837
+ });
2838
+ }
2839
+ function highlight(src) {
2840
+ return src.replace(rx_highlight, function (all, _, p1, emp, sub, sup, small, big, p2, content) {
2841
+ return (_ +
2842
+ element(emp
2843
+ ? p2
2844
+ ? 'strong'
2845
+ : 'em'
2846
+ : sub
2847
+ ? p2
2848
+ ? 's'
2849
+ : 'sub'
2850
+ : sup
2851
+ ? 'sup'
2852
+ : small
2853
+ ? 'small'
2854
+ : big
2855
+ ? 'big'
2856
+ : 'code', highlight(content)));
2857
+ });
2858
+ }
2859
+ src = `\n${src}\n`;
2860
+ replace(rx_space, ' ');
2861
+ src = blockquote(src);
2862
+ replace(rx_hr, '<hr/>');
2863
+ src = list(src);
2864
+ replace(rx_listjoin, '');
2865
+ replace(rx_code, (_, p1, p2, p3, p4) => {
2866
+ stash[--si] = element('pre', element('code', p3 || p4.replace(/^ {4}/gm, '')));
2867
+ return `${si}\uf8ff`;
2868
+ });
2869
+ replace(rx_link, (_, p1, p2, p3, p4, p5, p6) => {
2870
+ stash[--si] = p4
2871
+ ? p2
2872
+ ? `<img src="${p4}" alt="${p3}"/>`
2873
+ : `<a href="${p4}">${highlight(p3)}</a>`
2874
+ : p6;
2875
+ return `${si}\uf8ff`;
2876
+ });
2877
+ replace(rx_table, (_, table) => {
2878
+ var _a;
2879
+ const sep = ((_a = table.match(rx_thead)) === null || _a === void 0 ? void 0 : _a[1]) || '';
2880
+ return `\n${element('table', table.replace(rx_row, (row, ri) => {
2881
+ return row === sep
2882
+ ? ''
2883
+ : element('tr', row.replace(rx_cell, (_, cell, ci) => ci
2884
+ ? element(sep && !ri ? 'th' : 'td', highlight(cell || ''))
2885
+ : ''));
2886
+ }))}`;
2887
+ });
2888
+ replace(rx_heading, (_, prefix, p1, p2) => {
2889
+ return prefix + element(`h${p1.length}`, highlight(p2));
2890
+ });
2891
+ replace(rx_para, (_, content) => {
2892
+ return element('p', highlight(content));
2893
+ });
2894
+ replace(rx_stash, (all) => stash[parseInt(all)]);
2895
+ return src.trim();
2896
+ };
2664
2897
 
2665
- let MarkdownRenderer =
2666
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2667
- class MarkdownRenderer extends s {
2898
+ class MarkdownRenderer extends r$2 {
2668
2899
  render() {
2669
- const slotContent = this.innerHTML.trim();
2670
- const parsedContent = t(slotContent);
2671
- return o(parsedContent);
2900
+ // Remove lit markers from slot content
2901
+ const slotContent = this.innerHTML
2902
+ .trim()
2903
+ .replace(/<!--\?lit\$[\d$]+-->/g, '');
2904
+ return o(markdown(slotContent));
2672
2905
  }
2673
- };
2674
- MarkdownRenderer.styles = i$3 `
2906
+ }
2907
+ MarkdownRenderer.styles = i$4 `
2675
2908
  :host {
2676
2909
  font-family: 'Inter', sans-serif;
2677
2910
  font-size: 16px;
@@ -2682,14 +2915,11 @@ MarkdownRenderer.styles = i$3 `
2682
2915
  }
2683
2916
  }
2684
2917
  `;
2685
- MarkdownRenderer = __decorate([
2686
- t$2('markdown-renderer')
2687
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2688
- ], MarkdownRenderer);
2689
-
2690
- let TooltipComponent =
2691
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2692
- class TooltipComponent extends s {
2918
+ if (!customElements.get('markdown-renderer')) {
2919
+ customElements.define('markdown-renderer', MarkdownRenderer);
2920
+ }
2921
+
2922
+ class TooltipComponent extends r$2 {
2693
2923
  constructor() {
2694
2924
  super(...arguments);
2695
2925
  this.position = 'bottom-left';
@@ -2701,18 +2931,18 @@ class TooltipComponent extends s {
2701
2931
  <div class="tooltip ${this.position}">${this.text}</div>
2702
2932
  `;
2703
2933
  }
2704
- };
2934
+ }
2705
2935
  TooltipComponent.styles = [
2706
- i$3 `
2936
+ i$4 `
2707
2937
  :host {
2708
2938
  position: relative;
2709
2939
  display: inline-block;
2710
2940
  }
2941
+
2711
2942
  .tooltip {
2712
2943
  position: absolute;
2713
2944
  color: #172a41;
2714
2945
  padding: 4px 8px;
2715
- border-radius: 4px;
2716
2946
  white-space: nowrap;
2717
2947
  font-size: 12px;
2718
2948
  opacity: 0;
@@ -2728,57 +2958,70 @@ TooltipComponent.styles = [
2728
2958
  font-weight: 400;
2729
2959
  line-height: 150%;
2730
2960
  }
2961
+
2731
2962
  :host(:hover) .tooltip {
2732
2963
  opacity: 1;
2733
2964
  }
2965
+
2734
2966
  .top-center {
2735
2967
  bottom: calc(100% + 2px);
2736
2968
  left: 50%;
2737
2969
  transform: translateX(-50%);
2738
2970
  }
2971
+
2739
2972
  .top-left {
2740
2973
  bottom: calc(100% + 2px);
2741
2974
  left: 0;
2742
2975
  }
2976
+
2743
2977
  .top-right {
2744
2978
  bottom: calc(100% + 2px);
2745
2979
  right: 0;
2746
2980
  }
2981
+
2747
2982
  .bottom-center {
2748
2983
  top: calc(100% + 2px);
2749
2984
  left: 50%;
2750
2985
  transform: translateX(-50%);
2751
2986
  }
2987
+
2752
2988
  .bottom-left {
2753
2989
  top: calc(100% + 2px);
2754
2990
  left: 0;
2755
2991
  }
2992
+
2756
2993
  .bottom-right {
2757
2994
  top: calc(100% + 2px);
2758
2995
  right: 0;
2759
2996
  }
2997
+
2760
2998
  .left-center {
2761
2999
  right: calc(100% + 2px);
2762
3000
  top: 50%;
2763
3001
  transform: translateY(-50%);
2764
3002
  }
3003
+
2765
3004
  .left-top {
2766
3005
  right: calc(100% + 2px);
2767
3006
  top: 0;
2768
3007
  }
3008
+
2769
3009
  .left-bottom {
2770
3010
  right: calc(100% + 2px);
2771
3011
  bottom: 0;
2772
3012
  }
3013
+
2773
3014
  .right-center {
2774
3015
  left: calc(100% + 2px);
2775
3016
  top: 50%;
2776
3017
  transform: translateY(-50%);
2777
3018
  }
3019
+
2778
3020
  .right-top {
2779
3021
  left: calc(100% + 2px);
2780
3022
  top: 0;
2781
3023
  }
3024
+
2782
3025
  .right-bottom {
2783
3026
  left: calc(100% + 2px);
2784
3027
  bottom: 0;
@@ -2786,19 +3029,18 @@ TooltipComponent.styles = [
2786
3029
  `,
2787
3030
  ];
2788
3031
  __decorate([
2789
- n$1({ type: String }),
3032
+ n({ type: String }),
2790
3033
  __metadata("design:type", String)
2791
3034
  ], TooltipComponent.prototype, "position", void 0);
2792
3035
  __decorate([
2793
- n$1({ type: String }),
2794
- __metadata("design:type", String)
3036
+ n({ type: String }),
3037
+ __metadata("design:type", Object)
2795
3038
  ], TooltipComponent.prototype, "text", void 0);
2796
- TooltipComponent = __decorate([
2797
- t$2('tooltip-component')
2798
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2799
- ], TooltipComponent);
3039
+ if (!customElements.get('tooltip-component')) {
3040
+ customElements.define('tooltip-component', TooltipComponent);
3041
+ }
2800
3042
 
2801
- const confirmDialogStyles = i$3 `
3043
+ const confirmDialogStyles = i$4 `
2802
3044
  :host {
2803
3045
  font-family: 'Inter', sans-serif;
2804
3046
  font-size: 16px;
@@ -2877,9 +3119,7 @@ const confirmDialogStyles = i$3 `
2877
3119
  }
2878
3120
  `;
2879
3121
 
2880
- let ConfirmDialog =
2881
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2882
- class ConfirmDialog extends s {
3122
+ class ConfirmDialog extends r$2 {
2883
3123
  onAcceptClick(e) {
2884
3124
  e.preventDefault();
2885
3125
  this.dispatchEvent(new CustomEvent('accept', {
@@ -2912,19 +3152,17 @@ class ConfirmDialog extends s {
2912
3152
  </div>
2913
3153
  `;
2914
3154
  }
2915
- };
3155
+ }
2916
3156
  ConfirmDialog.styles = [confirmDialogStyles];
2917
- ConfirmDialog = __decorate([
2918
- t$2('confirm-dialog')
2919
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2920
- ], ConfirmDialog);
2921
-
2922
- let ChatSection =
2923
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2924
- class ChatSection extends s {
3157
+ if (!customElements.get('confirm-dialog')) {
3158
+ customElements.define('confirm-dialog', ConfirmDialog);
3159
+ }
3160
+
3161
+ class ChatSection extends r$2 {
2925
3162
  constructor() {
2926
3163
  super(...arguments);
2927
3164
  this.showChatThreads = false;
3165
+ this.deleteAllThreads = false;
2928
3166
  this.userQuery = '';
2929
3167
  }
2930
3168
  scrollToBottom() {
@@ -2949,6 +3187,14 @@ class ChatSection extends s {
2949
3187
  await this.processMessage(e, message);
2950
3188
  }
2951
3189
  handleThreadDelete() {
3190
+ if (this.deleteAllThreads) {
3191
+ this.dispatchEvent(new CustomEvent('delete-all-threads', {
3192
+ composed: true,
3193
+ bubbles: true,
3194
+ }));
3195
+ this.deleteAllThreads = false;
3196
+ return;
3197
+ }
2952
3198
  if (!this.deleteThreadId) {
2953
3199
  return;
2954
3200
  }
@@ -2960,7 +3206,7 @@ class ChatSection extends s {
2960
3206
  this.deleteThreadId = '';
2961
3207
  }
2962
3208
  typingIndicator() {
2963
- return x `<div class="typing-dots">
3209
+ return x ` <div class="typing-dots">
2964
3210
  <div class="dot"></div>
2965
3211
  <div class="dot"></div>
2966
3212
  <div class="dot"></div>
@@ -2976,8 +3222,8 @@ class ChatSection extends s {
2976
3222
  </div>
2977
3223
  <div>
2978
3224
  ${message.message
2979
- ? x `<markdown-renderer>${message.message}</markdown-renderer>`
2980
- : T}
3225
+ ? x ` <markdown-renderer>${message.message}</markdown-renderer>`
3226
+ : E}
2981
3227
  ${this.viewType !== 'modal' && ((_a = message.products) === null || _a === void 0 ? void 0 : _a[0])
2982
3228
  ? x `
2983
3229
  <span class="line"></span>
@@ -2988,27 +3234,29 @@ class ChatSection extends s {
2988
3234
  ></product-item>
2989
3235
  </div>
2990
3236
  `
2991
- : T}
3237
+ : E}
2992
3238
  </div>
2993
3239
  </div>
2994
3240
  ${this.viewType === 'modal' && message.products
2995
- ? x `<products-list
3241
+ ? x ` <products-list
2996
3242
  .products=${message.products}
2997
3243
  .siteCurrency=${this.siteCurrency}
2998
3244
  .viewType=${this.viewType}
2999
3245
  ></products-list>`
3000
- : T}
3246
+ : E}
3001
3247
  </div>
3002
3248
  `;
3003
3249
  }
3004
3250
  chatWindow() {
3005
- if (this.isLoadingHistory) {
3006
- return x ` <load-spinner></load-spinner> `;
3251
+ if (this.isLoadingHistory || this.isLoadingThreads) {
3252
+ return x `<div class="messages loading">
3253
+ <load-spinner></load-spinner>
3254
+ </div>`;
3007
3255
  }
3008
3256
  return x `
3009
3257
  <div class="messages">
3010
3258
  ${this.isTyping
3011
- ? x `<div class="message bot">
3259
+ ? x ` <div class="message bot">
3012
3260
  <div>
3013
3261
  <div class="bot-icon">${botIcon}</div>
3014
3262
  </div>
@@ -3020,7 +3268,7 @@ class ChatSection extends s {
3020
3268
  sender: 'bot',
3021
3269
  message: "Uh-oh! Looks like I tripped over some alpha-stage wires. Things are still a bit wobbly here, buy hey, that's what testing is for, Let's try that again; or feel free to throw another challenge my way!",
3022
3270
  })
3023
- : T}
3271
+ : E}
3024
3272
  ${this.messages.map((message) => {
3025
3273
  if (message.sender === 'bot') {
3026
3274
  return this.botMessage(message);
@@ -3033,11 +3281,10 @@ class ChatSection extends s {
3033
3281
  </div>
3034
3282
  <div>
3035
3283
  <p>
3036
- Welcome to the personalized search! How can we help?
3037
- <br />
3038
- <br />
3039
- Type your search query or select one of the prompts to get
3040
- started:
3284
+ Hi,
3285
+ ${this.brandName ? x `Welcome to ${this.brandName}.` : E}
3286
+ I'm here to help you find the perfect product? What are you
3287
+ looking to resolve today?
3041
3288
  </p>
3042
3289
  </div>
3043
3290
  </div>
@@ -3045,14 +3292,20 @@ class ChatSection extends s {
3045
3292
  `;
3046
3293
  }
3047
3294
  quickPrompts() {
3048
- var _a;
3049
- if (((_a = this.thread) === null || _a === void 0 ? void 0 : _a.threadId) || this.messages.length) {
3050
- return T;
3295
+ if (this.isLoadingHistory || this.isTyping || this.isLoadingThreads) {
3296
+ return E;
3297
+ }
3298
+ const prompts = this.messages.length
3299
+ ? this.messages[0].welcomePrompts
3300
+ : this.prompts
3301
+ ? this.prompts.split(',').map((prompt) => prompt.trim())
3302
+ : ['Best Selling Items', 'Hot Sales'];
3303
+ if (!prompts) {
3304
+ return E;
3051
3305
  }
3052
- const defaultPrompts = ['Best Selling Items', 'Hot Sales'];
3053
3306
  return x `
3054
3307
  <div class="prompts btn">
3055
- ${defaultPrompts.map((prompt) => x `
3308
+ ${prompts.map((prompt) => x `
3056
3309
  <div
3057
3310
  class="prompt"
3058
3311
  @click=${(e) => this.processMessage(e, prompt)}
@@ -3119,8 +3372,8 @@ class ChatSection extends s {
3119
3372
  <span class="context-type-value"> ${profileType} </span>
3120
3373
  </div>
3121
3374
  ${userDetails
3122
- ? x `<div class="context user-details">${userDetails}</div>`
3123
- : T}
3375
+ ? x ` <div class="context user-details">${userDetails}</div>`
3376
+ : E}
3124
3377
  </div>
3125
3378
  <div>
3126
3379
  <div class="context">
@@ -3128,10 +3381,10 @@ class ChatSection extends s {
3128
3381
  <span class="context-type-value">${visitationType}</span>
3129
3382
  </div>
3130
3383
  ${devContext.productHandle
3131
- ? x `<div class="context product-handle">
3384
+ ? x ` <div class="context product-handle">
3132
3385
  ${devContext.productHandle}
3133
3386
  </div>`
3134
- : T}
3387
+ : E}
3135
3388
  </div>
3136
3389
  </div>
3137
3390
  `;
@@ -3156,10 +3409,10 @@ class ChatSection extends s {
3156
3409
  </tooltip-component>
3157
3410
  <tooltip-component
3158
3411
  .position=${'bottom-right'}
3159
- .text=${'Your Search History'}
3412
+ .text=${'Search History'}
3160
3413
  >
3161
3414
  <button
3162
- class=${e$2({
3415
+ class=${e$1({
3163
3416
  btn: true,
3164
3417
  'btn-icon': true,
3165
3418
  'threads-btn': true,
@@ -3227,15 +3480,31 @@ class ChatSection extends s {
3227
3480
  }
3228
3481
  renderChatThreads() {
3229
3482
  if (!this.chatThreads || !this.showChatThreads) {
3230
- return T;
3483
+ return E;
3231
3484
  }
3232
- return x `<div id="modal-chat-threads">
3485
+ return x ` <div id="modal-chat-threads">
3233
3486
  <div class="chat-threads">
3234
- <h2>Your Search History</h2>
3487
+ <div class="title-wrapper">
3488
+ <h2>Search History</h2>
3489
+ ${this.chatThreads.size
3490
+ ? x `<div
3491
+ class="trash-icon"
3492
+ @click=${() => {
3493
+ if (this.isTyping) {
3494
+ return;
3495
+ }
3496
+ this.deleteAllThreads = true;
3497
+ this.showChatThreads = false;
3498
+ }}
3499
+ >
3500
+ ${trashIcon}
3501
+ </div>`
3502
+ : E}
3503
+ </div>
3235
3504
  <div class="thread-titles-wrapper">
3236
3505
  ${o$1(this.chatThreads.values(), (thread) => x `
3237
3506
  <div
3238
- class=${e$2({
3507
+ class=${e$1({
3239
3508
  'thread-title': true,
3240
3509
  disabled: this.isTyping,
3241
3510
  })}
@@ -3275,10 +3544,17 @@ class ChatSection extends s {
3275
3544
  </div>`;
3276
3545
  }
3277
3546
  render() {
3547
+ if (this.merchantImage) {
3548
+ // set the merchant image as a css variable
3549
+ this.style.setProperty('--shopgpt-merchant-img-url', `url('${this.merchantImage}')`);
3550
+ }
3551
+ else {
3552
+ this.style.removeProperty('--shopgpt-merchant-img-url');
3553
+ }
3278
3554
  return x `
3279
3555
  <div class="chat-header">${this.contextButton()}</div>
3280
3556
  <div
3281
- class=${e$2({
3557
+ class=${e$1({
3282
3558
  'chatbot-section': true,
3283
3559
  'modal-view': this.viewType === 'modal',
3284
3560
  })}
@@ -3292,7 +3568,7 @@ class ChatSection extends s {
3292
3568
  placeholder="Type your search here..."
3293
3569
  />
3294
3570
  <button
3295
- class=${e$2({
3571
+ class=${e$1({
3296
3572
  btn: true,
3297
3573
  modal: this.viewType === 'modal',
3298
3574
  })}
@@ -3309,96 +3585,128 @@ class ChatSection extends s {
3309
3585
  .defaultProfiles=${this.profiles}
3310
3586
  ></personalize-dialog>
3311
3587
  ${this.renderChatThreads()}
3312
- ${this.deleteThreadId
3588
+ ${this.deleteThreadId || this.deleteAllThreads
3313
3589
  ? x `
3314
3590
  <confirm-dialog
3315
3591
  @accept=${this.handleThreadDelete}
3316
- @decline=${() => (this.deleteThreadId = '')}
3592
+ @decline=${() => {
3593
+ this.deleteThreadId = '';
3594
+ this.deleteAllThreads = false;
3595
+ }}
3317
3596
  >
3318
- <h2 slot="title">Delete Thread?</h2>
3597
+ <h2 slot="title">
3598
+ ${this.deleteAllThreads
3599
+ ? 'Delete Entire Chat History?'
3600
+ : 'Delete Chat?'}
3601
+ </h2>
3319
3602
  <p slot="content">
3320
3603
  This action cannot be undone. Are you sure you want to delete
3321
- <b>"${this.chatThreads.get(this.deleteThreadId).title}"</b>?
3604
+ ${this.deleteAllThreads
3605
+ ? ' the entire chat history'
3606
+ : x `<b
3607
+ >"${this.chatThreads.get(this.deleteThreadId)
3608
+ .title}"</b
3609
+ >`}?
3322
3610
  </p>
3323
3611
  </confirm-dialog>
3324
3612
  `
3325
- : T}
3613
+ : E}
3326
3614
  `;
3327
3615
  }
3328
- };
3616
+ }
3329
3617
  ChatSection.styles = [chatSectionStyles];
3330
3618
  __decorate([
3331
- n$1({ type: Object }),
3619
+ n({ type: String }),
3620
+ __metadata("design:type", Object)
3621
+ ], ChatSection.prototype, "merchantImage", void 0);
3622
+ __decorate([
3623
+ n({ type: String }),
3624
+ __metadata("design:type", Object)
3625
+ ], ChatSection.prototype, "brandName", void 0);
3626
+ __decorate([
3627
+ n({ type: String }),
3628
+ __metadata("design:type", Object)
3629
+ ], ChatSection.prototype, "prompts", void 0);
3630
+ __decorate([
3631
+ n({ type: Boolean }),
3632
+ __metadata("design:type", Boolean)
3633
+ ], ChatSection.prototype, "isLoadingThreads", void 0);
3634
+ __decorate([
3635
+ n({ type: Object }),
3332
3636
  __metadata("design:type", Map)
3333
3637
  ], ChatSection.prototype, "chatThreads", void 0);
3334
3638
  __decorate([
3335
- r$1(),
3639
+ r(),
3336
3640
  __metadata("design:type", String)
3337
3641
  ], ChatSection.prototype, "deleteThreadId", void 0);
3338
3642
  __decorate([
3339
- n$1({ type: Boolean }),
3340
- __metadata("design:type", Boolean)
3643
+ n({ type: Boolean }),
3644
+ __metadata("design:type", Object)
3341
3645
  ], ChatSection.prototype, "showChatThreads", void 0);
3342
3646
  __decorate([
3343
- n$1({ type: Boolean }),
3647
+ n({ type: Boolean }),
3344
3648
  __metadata("design:type", Boolean)
3345
3649
  ], ChatSection.prototype, "isLoadingHistory", void 0);
3346
3650
  __decorate([
3347
- n$1({ type: Boolean }),
3651
+ n({ type: Boolean }),
3348
3652
  __metadata("design:type", Object)
3349
3653
  ], ChatSection.prototype, "devMode", void 0);
3350
3654
  __decorate([
3351
- n$1({ type: Boolean }),
3655
+ n({ type: Boolean }),
3352
3656
  __metadata("design:type", Boolean)
3353
3657
  ], ChatSection.prototype, "isTyping", void 0);
3354
3658
  __decorate([
3355
- n$1({ type: Boolean }),
3659
+ n({ type: Boolean }),
3356
3660
  __metadata("design:type", Boolean)
3357
3661
  ], ChatSection.prototype, "isFailed", void 0);
3358
3662
  __decorate([
3359
- n$1({ type: Array }),
3663
+ n({ type: Array }),
3360
3664
  __metadata("design:type", Array)
3361
3665
  ], ChatSection.prototype, "messages", void 0);
3362
3666
  __decorate([
3363
- n$1({ type: Array }),
3667
+ n({ type: Array }),
3364
3668
  __metadata("design:type", Array)
3365
3669
  ], ChatSection.prototype, "profiles", void 0);
3366
3670
  __decorate([
3367
- n$1({ type: Array }),
3671
+ n({ type: Array }),
3368
3672
  __metadata("design:type", Array)
3369
3673
  ], ChatSection.prototype, "productHandles", void 0);
3370
3674
  __decorate([
3371
- n$1({ type: Object }),
3675
+ n({ type: Object }),
3372
3676
  __metadata("design:type", Object)
3373
3677
  ], ChatSection.prototype, "thread", void 0);
3374
3678
  __decorate([
3375
- n$1({ type: Object }),
3679
+ n({ type: Object }),
3376
3680
  __metadata("design:type", Object)
3377
3681
  ], ChatSection.prototype, "siteCurrency", void 0);
3378
3682
  __decorate([
3379
- e$4('.context-container'),
3683
+ r(),
3684
+ __metadata("design:type", Object)
3685
+ ], ChatSection.prototype, "deleteAllThreads", void 0);
3686
+ __decorate([
3687
+ e$3('.context-container'),
3380
3688
  __metadata("design:type", Object)
3381
3689
  ], ChatSection.prototype, "contextContainerElement", void 0);
3382
3690
  __decorate([
3383
- e$4('.chat-window'),
3691
+ e$3('.chat-window'),
3384
3692
  __metadata("design:type", Object)
3385
3693
  ], ChatSection.prototype, "chatWindowElement", void 0);
3386
3694
  __decorate([
3387
- e$4('personalize-dialog'),
3695
+ e$3('personalize-dialog'),
3388
3696
  __metadata("design:type", Object)
3389
3697
  ], ChatSection.prototype, "personalizeDialogElement", void 0);
3390
3698
  __decorate([
3391
- n$1({ type: String }),
3392
- __metadata("design:type", String)
3699
+ n({ type: String }),
3700
+ __metadata("design:type", Object)
3393
3701
  ], ChatSection.prototype, "userQuery", void 0);
3394
- ChatSection = __decorate([
3395
- t$2('chat-section')
3396
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3397
- ], ChatSection);
3702
+ if (!customElements.get('chat-section')) {
3703
+ customElements.define('chat-section', ChatSection);
3704
+ }
3398
3705
 
3399
3706
  const DIALOG_DELAY = 1000;
3707
+ const LATEST_THREAD_LOAD_DAYS = 14;
3400
3708
  const normalizePath = (path) => path.replace(/\/$/, '');
3401
- let ShopGPT = class ShopGPT extends s {
3709
+ class ShopGPT extends r$2 {
3402
3710
  constructor() {
3403
3711
  super(...arguments);
3404
3712
  this.modalState = 'close';
@@ -3410,6 +3718,18 @@ let ShopGPT = class ShopGPT extends s {
3410
3718
  this.products = [];
3411
3719
  this.messages = [];
3412
3720
  this.chatThreads = new Map();
3721
+ this.loadData = async () => {
3722
+ if (!this.shopGPTAPI) {
3723
+ return;
3724
+ }
3725
+ await this.loadChatThreads();
3726
+ this.selectLatestThread();
3727
+ };
3728
+ this.onPopState = () => {
3729
+ var _a;
3730
+ this.modalState = 'close';
3731
+ (_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
3732
+ };
3413
3733
  this.submitQuery = (message) => {
3414
3734
  if (!message) {
3415
3735
  return;
@@ -3433,14 +3753,14 @@ let ShopGPT = class ShopGPT extends s {
3433
3753
  }
3434
3754
  this.init();
3435
3755
  }
3756
+ disconnectedCallback() {
3757
+ window.removeEventListener('edgetag-initialized', this.loadData);
3758
+ window.removeEventListener('popstate', this.onPopState);
3759
+ super.disconnectedCallback();
3760
+ }
3436
3761
  init() {
3437
- window.addEventListener('edgetag-initialized', async () => {
3438
- if (!this.shopGPTAPI) {
3439
- return;
3440
- }
3441
- await this.loadChatThreads();
3442
- await this.loadInitialQuery();
3443
- });
3762
+ window.addEventListener('edgetag-initialized', this.loadData);
3763
+ window.addEventListener('popstate', this.onPopState);
3444
3764
  if (!this.uiMode || this.uiMode === 'overlay') {
3445
3765
  delay(DIALOG_DELAY).then(() => {
3446
3766
  var _a;
@@ -3455,6 +3775,19 @@ let ShopGPT = class ShopGPT extends s {
3455
3775
  });
3456
3776
  }
3457
3777
  }
3778
+ setChatTitle(threadId, title) {
3779
+ if (!title || !threadId) {
3780
+ return;
3781
+ }
3782
+ const thread = this.chatThreads.get(threadId);
3783
+ if (thread) {
3784
+ this.chatThreads.set(thread.threadId, {
3785
+ ...thread,
3786
+ title,
3787
+ });
3788
+ this.chatThreads = new Map(this.chatThreads);
3789
+ }
3790
+ }
3458
3791
  async loadInitialQuery() {
3459
3792
  var _a;
3460
3793
  if (!this.selectedThreadId) {
@@ -3467,14 +3800,26 @@ let ShopGPT = class ShopGPT extends s {
3467
3800
  if (!thread) {
3468
3801
  return;
3469
3802
  }
3803
+ const searchParam = new URLSearchParams(window.location.search);
3804
+ const fromAd = searchParam.get('shopGPT') === '1';
3470
3805
  const productHandle = this.devMode
3471
3806
  ? (_a = thread === null || thread === void 0 ? void 0 : thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle
3472
- : this.storeAPI.getCurrentProductHandle();
3807
+ : fromAd
3808
+ ? this.storeAPI.getCurrentProductHandle()
3809
+ : undefined;
3473
3810
  try {
3474
3811
  this.isTyping = true;
3475
3812
  const reply = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
3813
+ if (reply.chatTitle) {
3814
+ this.setChatTitle(this.selectedThreadId, reply.chatTitle);
3815
+ }
3476
3816
  this.messages = [
3477
- { sender: 'bot', message: reply.message, products: reply.products },
3817
+ {
3818
+ sender: 'bot',
3819
+ message: reply.message,
3820
+ products: reply.products,
3821
+ welcomePrompts: reply.welcomePrompts,
3822
+ },
3478
3823
  ...this.messages,
3479
3824
  ];
3480
3825
  this.products = reply.products || [];
@@ -3500,8 +3845,24 @@ let ShopGPT = class ShopGPT extends s {
3500
3845
  this.isLoadingThreads = false;
3501
3846
  }
3502
3847
  }
3848
+ selectLatestThread() {
3849
+ const cutoffTime = Date.now() - LATEST_THREAD_LOAD_DAYS * 24 * 60 * 60 * 1000;
3850
+ // If the latest thread is not older than cutoff we should load the thread
3851
+ let latestThread;
3852
+ for (const thread of this.chatThreads.values()) {
3853
+ if (thread.createdAt >= cutoffTime &&
3854
+ (!latestThread || latestThread.createdAt < thread.createdAt)) {
3855
+ latestThread = thread;
3856
+ }
3857
+ }
3858
+ if (latestThread) {
3859
+ this.setSelectedThreadId(latestThread.threadId);
3860
+ }
3861
+ else if (!this.devMode) {
3862
+ this.createChatThread({ title: '' }, true);
3863
+ }
3864
+ }
3503
3865
  async loadHistory(threadId) {
3504
- var _a, _b, _c;
3505
3866
  try {
3506
3867
  if (!threadId) {
3507
3868
  this.messages = [];
@@ -3510,22 +3871,24 @@ let ShopGPT = class ShopGPT extends s {
3510
3871
  }
3511
3872
  this.isLoadingHistory = true;
3512
3873
  const data = await this.shopGPTAPI.fetchChatHistory(threadId);
3874
+ let latestAvailableProducts = [];
3513
3875
  this.messages = data.map((message) => {
3514
3876
  var _a;
3515
- return ({
3877
+ const products = (_a = message.products) === null || _a === void 0 ? void 0 : _a.map((product) => ({
3878
+ ...product,
3879
+ quantity: 1,
3880
+ }));
3881
+ if (!latestAvailableProducts.length && (products === null || products === void 0 ? void 0 : products.length)) {
3882
+ latestAvailableProducts = products;
3883
+ }
3884
+ return {
3516
3885
  message: message.message,
3517
3886
  sender: message.sender,
3518
- products: (_a = message.products) === null || _a === void 0 ? void 0 : _a.map((product) => ({
3519
- ...product,
3520
- quantity: 1,
3521
- })),
3522
- });
3887
+ products,
3888
+ welcomePrompts: message.welcomePrompts,
3889
+ };
3523
3890
  });
3524
- this.products =
3525
- (_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) => ({
3526
- ...product,
3527
- quantity: 1,
3528
- }))) !== null && _c !== void 0 ? _c : [];
3891
+ this.products = latestAvailableProducts;
3529
3892
  }
3530
3893
  catch (e) {
3531
3894
  logger.error(e);
@@ -3566,6 +3929,21 @@ let ShopGPT = class ShopGPT extends s {
3566
3929
  this.shopGPTAPI
3567
3930
  .deleteSingleThread(threadId)
3568
3931
  .then(this.loadChatThreads.bind(this))
3932
+ .then(() => {
3933
+ if (this.selectedThreadId === threadId) {
3934
+ this.setSelectedThreadId('');
3935
+ }
3936
+ })
3937
+ .catch(logger.error)
3938
+ .finally(() => (this.isLoadingThreads = false));
3939
+ }
3940
+ handleAllThreadsDelete(e) {
3941
+ e.stopPropagation();
3942
+ this.isLoadingThreads = true;
3943
+ this.shopGPTAPI
3944
+ .deleteAllThreads()
3945
+ .then(this.loadChatThreads.bind(this))
3946
+ .then(() => this.setSelectedThreadId(''))
3569
3947
  .catch(logger.error)
3570
3948
  .finally(() => (this.isLoadingThreads = false));
3571
3949
  }
@@ -3584,21 +3962,20 @@ let ShopGPT = class ShopGPT extends s {
3584
3962
  return;
3585
3963
  }
3586
3964
  if (reply.chatTitle) {
3587
- // Alternatively we can fetch the chatThreads once again which would cost another network request
3588
- const thread = this.chatThreads.get(this.selectedThreadId);
3589
- if (thread) {
3590
- this.chatThreads.set(thread.threadId, {
3591
- ...thread,
3592
- title: reply.chatTitle,
3593
- });
3594
- this.chatThreads = new Map(this.chatThreads);
3595
- }
3965
+ this.setChatTitle(this.selectedThreadId, reply.chatTitle);
3596
3966
  }
3597
3967
  this.messages = [
3598
- { sender: 'bot', message: reply.message, products: reply.products },
3968
+ {
3969
+ sender: 'bot',
3970
+ message: reply.message,
3971
+ products: reply.products,
3972
+ welcomePrompts: reply.welcomePrompts,
3973
+ },
3599
3974
  ...this.messages,
3600
3975
  ];
3601
- this.products = reply.products || [];
3976
+ if (reply.products && reply.products.length > 0) {
3977
+ this.products = reply.products;
3978
+ }
3602
3979
  }
3603
3980
  catch (err) {
3604
3981
  logger.error(err);
@@ -3623,6 +4000,7 @@ let ShopGPT = class ShopGPT extends s {
3623
4000
  <dialog
3624
4001
  id="shop-gpt-dialog-overlay"
3625
4002
  @delete-thread=${this.handleThreadDelete}
4003
+ @delete-all-threads=${this.handleAllThreadsDelete}
3626
4004
  >
3627
4005
  <div class="mobile-version">
3628
4006
  Please switch to the desktop version for the best experience.
@@ -3637,11 +4015,15 @@ let ShopGPT = class ShopGPT extends s {
3637
4015
  .merchantUrl=${this.merchantUrl}
3638
4016
  ></chat-threads>
3639
4017
  <products-section
4018
+ .merchantImage=${this.merchantImage}
3640
4019
  .products=${this.products}
3641
4020
  .isLoadingHistory=${this.isLoadingHistory}
3642
4021
  .siteCurrency=${this.getSiteCurrency()}
4022
+ .isLoadingThreads=${this.isLoadingThreads}
3643
4023
  ></products-section>
3644
4024
  <chat-section
4025
+ .prompts=${this.quickPrompts}
4026
+ .brandName=${this.brandName}
3645
4027
  .isFailed=${this.isFailed}
3646
4028
  .isLoadingHistory=${this.isLoadingHistory}
3647
4029
  .isTyping=${this.isTyping}
@@ -3654,6 +4036,7 @@ let ShopGPT = class ShopGPT extends s {
3654
4036
  .productHandles=${this.productHandles}
3655
4037
  .profiles=${this.profiles}
3656
4038
  .viewType=${'overlay'}
4039
+ .isLoadingThreads=${this.isLoadingThreads}
3657
4040
  ></chat-section>
3658
4041
  </div>
3659
4042
  </dialog>
@@ -3665,7 +4048,7 @@ let ShopGPT = class ShopGPT extends s {
3665
4048
  this.modalState = 'close';
3666
4049
  };
3667
4050
  if (this.modalState === 'close') {
3668
- return x `<div class="chatbot-widget">
4051
+ return x ` <div class="chatbot-widget">
3669
4052
  <button
3670
4053
  @click=${(e) => {
3671
4054
  e.preventDefault();
@@ -3674,11 +4057,18 @@ let ShopGPT = class ShopGPT extends s {
3674
4057
  >
3675
4058
  ${chatIcon}
3676
4059
  </button>
4060
+ <div class="chatbot-hover-text">What are you looking for today?</div>
3677
4061
  </div>`;
3678
4062
  }
3679
4063
  return x `
3680
- <div id="shop-gpt-modal" @delete-thread=${this.handleThreadDelete}>
4064
+ <div
4065
+ id="shop-gpt-modal"
4066
+ @delete-thread=${this.handleThreadDelete}
4067
+ @delete-all-threads=${this.handleAllThreadsDelete}
4068
+ >
3681
4069
  <chat-section
4070
+ .prompts=${this.quickPrompts}
4071
+ .brandName=${this.brandName}
3682
4072
  .isFailed=${this.isFailed}
3683
4073
  .isLoadingHistory=${this.isLoadingHistory}
3684
4074
  .isTyping=${this.isTyping}
@@ -3694,55 +4084,57 @@ let ShopGPT = class ShopGPT extends s {
3694
4084
  .closeModal=${closeModal}
3695
4085
  .setSelectedThreadId=${this.setSelectedThreadId.bind(this)}
3696
4086
  .chatThreads=${this.chatThreads}
4087
+ .isLoadingThreads=${this.isLoadingThreads}
4088
+ .merchantImage=${this.merchantImage}
3697
4089
  ></chat-section>
3698
4090
  </div>
3699
4091
  `;
3700
4092
  }
3701
- };
4093
+ }
3702
4094
  ShopGPT.styles = [shopGPTStyles];
3703
4095
  __decorate([
3704
- e$4('#shop-gpt-dialog-overlay'),
4096
+ e$3('#shop-gpt-dialog-overlay'),
3705
4097
  __metadata("design:type", Object)
3706
4098
  ], ShopGPT.prototype, "shopGPTDialog", void 0);
3707
4099
  __decorate([
3708
- n$1({ type: String }),
4100
+ n({ type: String }),
3709
4101
  __metadata("design:type", String)
3710
4102
  ], ShopGPT.prototype, "modalState", void 0);
3711
4103
  __decorate([
3712
- n$1({ type: Boolean }),
3713
- __metadata("design:type", Boolean)
4104
+ n({ type: Boolean }),
4105
+ __metadata("design:type", Object)
3714
4106
  ], ShopGPT.prototype, "isLoadingHistory", void 0);
3715
4107
  __decorate([
3716
- n$1({ type: Boolean }),
3717
- __metadata("design:type", Boolean)
4108
+ n({ type: Boolean }),
4109
+ __metadata("design:type", Object)
3718
4110
  ], ShopGPT.prototype, "isLoadingThreads", void 0);
3719
4111
  __decorate([
3720
- n$1({ type: Boolean }),
3721
- __metadata("design:type", Boolean)
4112
+ n({ type: Boolean }),
4113
+ __metadata("design:type", Object)
3722
4114
  ], ShopGPT.prototype, "isTyping", void 0);
3723
4115
  __decorate([
3724
- n$1({ type: Boolean }),
3725
- __metadata("design:type", Boolean)
4116
+ n({ type: Boolean }),
4117
+ __metadata("design:type", Object)
3726
4118
  ], ShopGPT.prototype, "isFailed", void 0);
3727
4119
  __decorate([
3728
- n$1({ type: String }),
3729
- __metadata("design:type", String)
4120
+ n({ type: String }),
4121
+ __metadata("design:type", Object)
3730
4122
  ], ShopGPT.prototype, "selectedThreadId", void 0);
3731
4123
  __decorate([
3732
- n$1({ type: Array }),
4124
+ n({ type: Array }),
3733
4125
  __metadata("design:type", Array)
3734
4126
  ], ShopGPT.prototype, "products", void 0);
3735
4127
  __decorate([
3736
- n$1({ type: Array }),
4128
+ n({ type: Array }),
3737
4129
  __metadata("design:type", Array)
3738
4130
  ], ShopGPT.prototype, "messages", void 0);
3739
4131
  __decorate([
3740
- n$1({ type: Object }),
4132
+ n({ type: Object }),
3741
4133
  __metadata("design:type", Map)
3742
4134
  ], ShopGPT.prototype, "chatThreads", void 0);
3743
- ShopGPT = __decorate([
3744
- t$2('shop-gpt')
3745
- ], ShopGPT);
4135
+ if (!customElements.get('shop-gpt')) {
4136
+ customElements.define('shop-gpt', ShopGPT);
4137
+ }
3746
4138
 
3747
4139
  var _a, _b;
3748
4140
  var _c;
@@ -3763,8 +4155,19 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
3763
4155
  shopGPT.productHandles = params.productHandles;
3764
4156
  shopGPT.uiMode = params.uiMode;
3765
4157
  shopGPT.path = params.path;
4158
+ shopGPT.brandName = params.brandName;
4159
+ shopGPT.quickPrompts = params.quickPrompts;
4160
+ shopGPT.merchantImage = params.merchantImage;
3766
4161
  document.body.append(shopGPT);
3767
4162
  },
4163
+ destroy() {
4164
+ if (!shopGPT) {
4165
+ return;
4166
+ }
4167
+ shopGPT.remove();
4168
+ shopGPT = undefined;
4169
+ delete window[registryKey];
4170
+ },
3768
4171
  });
3769
4172
  }
3770
4173