@blotoutio/providers-shop-gpt-sdk 1.10.2 → 1.11.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 +152 -39
  2. package/index.js +152 -39
  3. package/index.mjs +152 -39
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -408,13 +408,24 @@ const createExperiment = (props) => {
408
408
  }
409
409
  };
410
410
 
411
+ /** Action length should not exceed 42 */
411
412
  const uiActions = new Set([
412
413
  'shopGPTInitialized',
413
414
  'chatbotOpened',
415
+ 'chatbotClosed',
416
+ 'singleThreadDelete',
417
+ 'allThreadsDelete',
418
+ 'switchThread',
419
+ 'newSearch',
420
+ 'thumbsUp',
421
+ 'thumbsDown',
422
+ 'showThreads',
414
423
  'queryInteractions',
415
424
  'promptClicked',
416
425
  'productRecommendationClicked',
426
+ 'blotoutLinkClicked',
417
427
  ]);
428
+ /** Action length should not exceed 42 */
418
429
  new Set([
419
430
  ...uiActions,
420
431
  'pageView',
@@ -767,10 +778,11 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
767
778
  const data = (await response.json());
768
779
  return data.customPrompts;
769
780
  };
770
- const sendEvent = async (action, currency, actionData) => {
781
+ const sendEvent = (action, currency, actionData) => {
771
782
  var _a;
772
783
  const storageData = (_a = getProductActions(baseURL, sessionId)) !== null && _a !== void 0 ? _a : {};
773
- const response = await fetchImpl(getURL('/user/event'), {
784
+ // This endpoint sends user events to the server, we don't need to wait for the response
785
+ fetchImpl(getURL('/user/event'), {
774
786
  method: 'POST',
775
787
  headers: getHeaders(true),
776
788
  body: JSON.stringify({
@@ -784,10 +796,13 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
784
796
  },
785
797
  }),
786
798
  credentials: 'include',
787
- });
788
- if (!response.ok) {
789
- throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
790
- }
799
+ })
800
+ .then(async (response) => {
801
+ if (!response.ok) {
802
+ throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
803
+ }
804
+ })
805
+ .catch(logger.error);
791
806
  };
792
807
  return {
793
808
  processQuery,
@@ -823,8 +838,8 @@ const init = (params) => {
823
838
  // exit if not in top window
824
839
  return;
825
840
  }
826
- const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUiManually, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
827
- setShopGPTLoaded(params.baseUrl, (_d = params.session) === null || _d === void 0 ? void 0 : _d.sessionId, !loadUiManually);
841
+ const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
842
+ setShopGPTLoaded(params.baseUrl, (_d = params.session) === null || _d === void 0 ? void 0 : _d.sessionId, !loadUIManually);
828
843
  const experiment = createExperiment({
829
844
  name: getExperimentName(mode),
830
845
  userId: params.userId,
@@ -864,8 +879,9 @@ const init = (params) => {
864
879
  css,
865
880
  nudge,
866
881
  sessionId: (_f = params.session) === null || _f === void 0 ? void 0 : _f.sessionId,
882
+ loadUIManually,
867
883
  });
868
- if (!loadUiManually) {
884
+ if (!loadUIManually) {
869
885
  uiImplementation.loadUI();
870
886
  }
871
887
  }
@@ -1088,6 +1104,7 @@ const shopGPTStyles = i$4 `
1088
1104
  height: 56px;
1089
1105
  background-color: var(--shopgpt-primary);
1090
1106
  border-radius: 50%;
1107
+ display: flex;
1091
1108
  justify-content: center;
1092
1109
  align-items: center;
1093
1110
  box-shadow: 0 0 4px 1px var(--shopgpt-white);
@@ -1520,6 +1537,13 @@ class ChatThreads extends r$2 {
1520
1537
  }
1521
1538
  return `https://${this.merchantUrl}`;
1522
1539
  }
1540
+ sendEvent(action, actionData) {
1541
+ this.dispatchEvent(new CustomEvent('send-event', {
1542
+ detail: { action, actionData },
1543
+ composed: true,
1544
+ bubbles: true,
1545
+ }));
1546
+ }
1523
1547
  handleThreadDelete() {
1524
1548
  if (this.deleteAllThreads) {
1525
1549
  this.dispatchEvent(new CustomEvent('delete-all-threads', {
@@ -1554,7 +1578,7 @@ class ChatThreads extends r$2 {
1554
1578
  ? x `<div
1555
1579
  class="trash-icon"
1556
1580
  @click=${() => {
1557
- if (this.isLoading || this.isTyping) {
1581
+ if (this.isLoading || this.isStreaming) {
1558
1582
  return;
1559
1583
  }
1560
1584
  this.deleteAllThreads = true;
@@ -1571,13 +1595,15 @@ class ChatThreads extends r$2 {
1571
1595
  class=${e$1({
1572
1596
  'thread-wrapper': true,
1573
1597
  active: this.selectedThreadId === thread.threadId,
1574
- disabled: this.isTyping,
1598
+ disabled: this.isStreaming,
1575
1599
  })}
1576
1600
  >
1577
1601
  <div
1578
1602
  class="thread-title"
1579
1603
  @click=${async () => {
1580
- if (this.isLoading || this.isTyping) {
1604
+ if (this.isLoading ||
1605
+ this.isStreaming ||
1606
+ this.selectedThreadId === thread.threadId) {
1581
1607
  return;
1582
1608
  }
1583
1609
  await this.setSelectedThreadId(thread.threadId);
@@ -1588,7 +1614,7 @@ class ChatThreads extends r$2 {
1588
1614
  <div
1589
1615
  class="trash-icon"
1590
1616
  @click=${() => {
1591
- if (this.isLoading || this.isTyping) {
1617
+ if (this.isLoading || this.isStreaming) {
1592
1618
  return;
1593
1619
  }
1594
1620
  this.deleteThreadId = thread.threadId;
@@ -1609,8 +1635,13 @@ class ChatThreads extends r$2 {
1609
1635
  <span class="line"></span>
1610
1636
  <button
1611
1637
  class="btn-new-search"
1612
- ?disabled=${this.isLoading || this.isTyping}
1613
- @click=${() => this.setSelectedThreadId('')}
1638
+ ?disabled=${this.isLoading || this.isStreaming}
1639
+ @click=${() => {
1640
+ if (this.selectedThreadId) {
1641
+ this.sendEvent('newSearch');
1642
+ }
1643
+ this.setSelectedThreadId('');
1644
+ }}
1614
1645
  >
1615
1646
  New Search
1616
1647
  </button>
@@ -1667,7 +1698,7 @@ __decorate([
1667
1698
  __decorate([
1668
1699
  n({ type: Boolean }),
1669
1700
  __metadata("design:type", Boolean)
1670
- ], ChatThreads.prototype, "isTyping", void 0);
1701
+ ], ChatThreads.prototype, "isStreaming", void 0);
1671
1702
  __decorate([
1672
1703
  n({ type: String }),
1673
1704
  __metadata("design:type", String)
@@ -2338,6 +2369,12 @@ const chatSectionStyles = i$4 `
2338
2369
  background: #2b65cf;
2339
2370
  opacity: 1;
2340
2371
  }
2372
+
2373
+ .new-search-btn:disabled {
2374
+ background: #808080;
2375
+ cursor: not-allowed;
2376
+ opacity: 0.5;
2377
+ }
2341
2378
  }
2342
2379
  }
2343
2380
 
@@ -2370,6 +2407,7 @@ const chatSectionStyles = i$4 `
2370
2407
  line-height: 150%;
2371
2408
  letter-spacing: -0.32px;
2372
2409
 
2410
+ box-sizing: border-box;
2373
2411
  background: #fff;
2374
2412
  border-radius: 10px;
2375
2413
  border: 1px solid #dbe2eb;
@@ -2488,6 +2526,11 @@ const chatSectionStyles = i$4 `
2488
2526
  color: rgb(140, 137, 156);
2489
2527
  border-radius: 50%;
2490
2528
 
2529
+ & > svg {
2530
+ height: 22px;
2531
+ width: 22px;
2532
+ }
2533
+
2491
2534
  &:hover {
2492
2535
  background-color: rgba(47, 43, 61, 0.08);
2493
2536
  }
@@ -3981,6 +4024,7 @@ class ChatSection extends r$2 {
3981
4024
  handleFeedback(rating, messageId, comment) {
3982
4025
  var _a, _b;
3983
4026
  if (rating === 'bad') {
4027
+ this.sendEvent('thumbsDown');
3984
4028
  this.feedbackDetails = {
3985
4029
  messageId,
3986
4030
  threadId: ((_a = this.thread) === null || _a === void 0 ? void 0 : _a.threadId) || '',
@@ -3988,6 +4032,7 @@ class ChatSection extends r$2 {
3988
4032
  };
3989
4033
  return;
3990
4034
  }
4035
+ this.sendEvent('thumbsUp');
3991
4036
  this.dispatchEvent(new CustomEvent('submit-feedback', {
3992
4037
  detail: {
3993
4038
  messageId: messageId,
@@ -4104,22 +4149,26 @@ class ChatSection extends r$2 {
4104
4149
  }
4105
4150
  return x ` <div class="message user">${message.message}</div> `;
4106
4151
  })}
4152
+ ${!this.fromAd || !this.thread
4153
+ ? x `
4107
4154
  <div class="message bot">
4108
4155
  <div>${this.renderBotIcon()}</div>
4109
4156
  <div>
4110
4157
  <p>
4111
4158
  Hi,
4112
4159
  ${this.brandName ? x `Welcome to ${this.brandName}.` : E}
4113
- I'm here to help you find the perfect product? What are you
4114
- looking to resolve today?
4160
+ I'm here to help you find the perfect product. Pick a suggested
4161
+ prompt from below, or enter your own query.
4115
4162
  </p>
4116
4163
  </div>
4117
4164
  </div>
4165
+ </div>`
4166
+ : E}
4118
4167
  </div>
4119
4168
  `;
4120
4169
  }
4121
4170
  renderPrompts() {
4122
- if (this.isLoadingHistory || this.isTyping || this.isLoadingThreads) {
4171
+ if (this.isLoadingHistory || this.isStreaming || this.isLoadingThreads) {
4123
4172
  return E;
4124
4173
  }
4125
4174
  const isWelcomeMessage = this.messages.length === 1 && this.messages[0].sender === 'bot';
@@ -4250,10 +4299,14 @@ class ChatSection extends r$2 {
4250
4299
  <button
4251
4300
  class="btn btn-icon new-search-btn"
4252
4301
  @click=${(e) => {
4253
- var _a;
4302
+ var _a, _b;
4254
4303
  e.preventDefault();
4255
- (_a = this.setSelectedThreadId) === null || _a === void 0 ? void 0 : _a.call(this, '');
4304
+ if ((_a = this.thread) === null || _a === void 0 ? void 0 : _a.threadId) {
4305
+ this.sendEvent('newSearch');
4306
+ }
4307
+ (_b = this.setSelectedThreadId) === null || _b === void 0 ? void 0 : _b.call(this, '');
4256
4308
  }}
4309
+ ?disabled=${this.isStreaming}
4257
4310
  >
4258
4311
  ${plusBtn}
4259
4312
  </button>
@@ -4272,6 +4325,9 @@ class ChatSection extends r$2 {
4272
4325
  @click=${(e) => {
4273
4326
  e.preventDefault();
4274
4327
  this.showChatThreads = !this.showChatThreads;
4328
+ if (this.showChatThreads) {
4329
+ this.sendEvent('showThreads');
4330
+ }
4275
4331
  }}
4276
4332
  >
4277
4333
  ${timerBtn}
@@ -4341,7 +4397,7 @@ class ChatSection extends r$2 {
4341
4397
  ? x `<div
4342
4398
  class="trash-icon"
4343
4399
  @click=${() => {
4344
- if (this.isTyping) {
4400
+ if (this.isStreaming) {
4345
4401
  return;
4346
4402
  }
4347
4403
  this.deleteAllThreads = true;
@@ -4357,17 +4413,18 @@ class ChatSection extends r$2 {
4357
4413
  <div
4358
4414
  class=${e$1({
4359
4415
  'thread-title': true,
4360
- disabled: this.isTyping,
4416
+ disabled: this.isStreaming,
4361
4417
  })}
4362
4418
  >
4363
4419
  <p
4364
4420
  @click=${() => {
4365
- var _a;
4366
- if (this.isTyping) {
4421
+ var _a, _b;
4422
+ if (this.isStreaming ||
4423
+ ((_a = this.thread) === null || _a === void 0 ? void 0 : _a.threadId) === thread.threadId) {
4367
4424
  return;
4368
4425
  }
4369
4426
  this.showChatThreads = false;
4370
- (_a = this.setSelectedThreadId) === null || _a === void 0 ? void 0 : _a.call(this, thread.threadId);
4427
+ (_b = this.setSelectedThreadId) === null || _b === void 0 ? void 0 : _b.call(this, thread.threadId);
4371
4428
  }}
4372
4429
  >
4373
4430
  ${thread.title || 'New Search'}
@@ -4375,7 +4432,7 @@ class ChatSection extends r$2 {
4375
4432
  <div
4376
4433
  class="trash-icon"
4377
4434
  @click=${() => {
4378
- if (this.isTyping) {
4435
+ if (this.isStreaming) {
4379
4436
  return;
4380
4437
  }
4381
4438
  this.deleteThreadId = thread.threadId;
@@ -4424,7 +4481,7 @@ class ChatSection extends r$2 {
4424
4481
  modal: this.viewType === 'modal',
4425
4482
  })}
4426
4483
  type="submit"
4427
- ?disabled=${this.isTyping || this.isLoadingHistory}
4484
+ ?disabled=${this.isStreaming || this.isLoadingHistory}
4428
4485
  >
4429
4486
  ${sendFilledIcon}
4430
4487
  </button>
@@ -4432,9 +4489,15 @@ class ChatSection extends r$2 {
4432
4489
  ${this.viewType === 'modal'
4433
4490
  ? x ` <footer>
4434
4491
  Powered by
4435
- <a target="_blank" href="https://shopgpt.edgeagents.ai"
4436
- >Blotout</a
4492
+ <a
4493
+ target="_blank"
4494
+ href="https://shopgpt.edgeagents.ai"
4495
+ @click=${() => {
4496
+ this.sendEvent('blotoutLinkClicked');
4497
+ }}
4437
4498
  >
4499
+ Blotout
4500
+ </a>
4438
4501
  </footer>`
4439
4502
  : E}
4440
4503
  </div>
@@ -4538,6 +4601,10 @@ __decorate([
4538
4601
  n({ type: Boolean }),
4539
4602
  __metadata("design:type", Boolean)
4540
4603
  ], ChatSection.prototype, "isTyping", void 0);
4604
+ __decorate([
4605
+ n({ type: Boolean }),
4606
+ __metadata("design:type", Boolean)
4607
+ ], ChatSection.prototype, "isStreaming", void 0);
4541
4608
  __decorate([
4542
4609
  n({ type: Boolean }),
4543
4610
  __metadata("design:type", Boolean)
@@ -4590,6 +4657,10 @@ __decorate([
4590
4657
  n({ type: String }),
4591
4658
  __metadata("design:type", String)
4592
4659
  ], ChatSection.prototype, "css", void 0);
4660
+ __decorate([
4661
+ n({ type: Boolean }),
4662
+ __metadata("design:type", Boolean)
4663
+ ], ChatSection.prototype, "fromAd", void 0);
4593
4664
  if (!customElements.get('chat-section')) {
4594
4665
  customElements.define('chat-section', ChatSection);
4595
4666
  }
@@ -4666,6 +4737,7 @@ class ShopGPT extends r$2 {
4666
4737
  this.isLoadingHistory = false;
4667
4738
  this.isLoadingThreads = false;
4668
4739
  this.isTyping = false;
4740
+ this.isStreaming = false;
4669
4741
  this.isFailed = false;
4670
4742
  this.selectedThreadId = '';
4671
4743
  this.products = [];
@@ -4686,6 +4758,16 @@ class ShopGPT extends r$2 {
4686
4758
  this.modalState = 'close';
4687
4759
  (_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
4688
4760
  };
4761
+ this.isFromAd = () => {
4762
+ var _a;
4763
+ if (this.devMode) {
4764
+ const thread = this.chatThreads.get(this.selectedThreadId);
4765
+ return thread ? !!((_a = thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle) : false;
4766
+ }
4767
+ const searchParams = new URLSearchParams(window.location.search);
4768
+ return ((isFromAd(searchParams) || searchParams.get('shopGPT') === '1') &&
4769
+ !!this.storeAPI.getCurrentProductHandle());
4770
+ };
4689
4771
  this.submitQuery = (message) => {
4690
4772
  if (!message) {
4691
4773
  return;
@@ -4717,7 +4799,9 @@ class ShopGPT extends r$2 {
4717
4799
  this.startNudgeTimer();
4718
4800
  }
4719
4801
  disconnectedCallback() {
4720
- window.removeEventListener('edgetag-initialized', this.loadData);
4802
+ if (!this.loadUIManually) {
4803
+ window.removeEventListener('edgetag-initialized', this.loadData);
4804
+ }
4721
4805
  window.removeEventListener('popstate', this.onPopState);
4722
4806
  if (this.nudgeTimer) {
4723
4807
  window.clearTimeout(this.nudgeTimer);
@@ -4725,7 +4809,14 @@ class ShopGPT extends r$2 {
4725
4809
  super.disconnectedCallback();
4726
4810
  }
4727
4811
  init() {
4728
- window.addEventListener('edgetag-initialized', this.loadData);
4812
+ if (this.loadUIManually) {
4813
+ // this is because edgetag-initialized will already be
4814
+ // triggered before the loadUI function is called to load the UI
4815
+ this.loadData();
4816
+ }
4817
+ else {
4818
+ window.addEventListener('edgetag-initialized', this.loadData);
4819
+ }
4729
4820
  window.addEventListener('popstate', this.onPopState);
4730
4821
  this.shopGPTAPI.sendEvent('shopGPTInitialized', this.getSiteCurrency().currency);
4731
4822
  if (!this.view || this.view === 'overlay') {
@@ -4769,15 +4860,18 @@ class ShopGPT extends r$2 {
4769
4860
  if (!thread) {
4770
4861
  return;
4771
4862
  }
4772
- const searchParams = new URLSearchParams(window.location.search);
4773
- const fromAd = isFromAd(searchParams) || searchParams.get('shopGPT') === '1';
4863
+ const fromAd = this.isFromAd();
4774
4864
  const productHandle = this.devMode
4775
4865
  ? (_a = thread === null || thread === void 0 ? void 0 : thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle
4776
4866
  : fromAd
4777
4867
  ? this.storeAPI.getCurrentProductHandle()
4778
4868
  : undefined;
4869
+ if (!fromAd) {
4870
+ return;
4871
+ }
4779
4872
  try {
4780
4873
  this.isTyping = true;
4874
+ this.isStreaming = true;
4781
4875
  const response = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
4782
4876
  this.processMessageResponse(response);
4783
4877
  }
@@ -4785,6 +4879,7 @@ class ShopGPT extends r$2 {
4785
4879
  logger.error(error);
4786
4880
  this.isFailed = true;
4787
4881
  this.isTyping = false;
4882
+ this.isStreaming = false;
4788
4883
  }
4789
4884
  }
4790
4885
  async loadChatThreads() {
@@ -4811,9 +4906,9 @@ class ShopGPT extends r$2 {
4811
4906
  }
4812
4907
  }
4813
4908
  if (latestThread) {
4814
- this.setSelectedThreadId(latestThread.threadId);
4909
+ this.setSelectedThreadId(latestThread.threadId, true);
4815
4910
  }
4816
- else if (!this.devMode) {
4911
+ else if (!this.devMode && this.isFromAd()) {
4817
4912
  this.createChatThread({ title: '' }, true);
4818
4913
  }
4819
4914
  }
@@ -4866,9 +4961,12 @@ class ShopGPT extends r$2 {
4866
4961
  logger.error(e);
4867
4962
  }
4868
4963
  }
4869
- async setSelectedThreadId(threadId) {
4964
+ async setSelectedThreadId(threadId, silent) {
4870
4965
  this.isFailed = false;
4871
4966
  this.selectedThreadId = threadId;
4967
+ if (threadId && !silent) {
4968
+ this.shopGPTAPI.sendEvent('switchThread');
4969
+ }
4872
4970
  await Promise.all([
4873
4971
  this.loadHistory(threadId),
4874
4972
  this.loadCustomPrompts(threadId),
@@ -4900,6 +4998,7 @@ class ShopGPT extends r$2 {
4900
4998
  logger.error('ThreadId is missing to delete the thread!');
4901
4999
  return;
4902
5000
  }
5001
+ this.shopGPTAPI.sendEvent('singleThreadDelete');
4903
5002
  this.shopGPTAPI
4904
5003
  .deleteSingleThread(threadId)
4905
5004
  .then(this.loadChatThreads.bind(this))
@@ -4914,6 +5013,7 @@ class ShopGPT extends r$2 {
4914
5013
  handleAllThreadsDelete(e) {
4915
5014
  e.stopPropagation();
4916
5015
  this.isLoadingThreads = true;
5016
+ this.shopGPTAPI.sendEvent('allThreadsDelete');
4917
5017
  this.shopGPTAPI
4918
5018
  .deleteAllThreads()
4919
5019
  .then(this.loadChatThreads.bind(this))
@@ -4991,6 +5091,7 @@ class ShopGPT extends r$2 {
4991
5091
  }
4992
5092
  else if (eventName === 'MessageComplete') {
4993
5093
  isMessageCompleted = true;
5094
+ this.isStreaming = false;
4994
5095
  this.handleProductsComplete(products, isMessageCompleted);
4995
5096
  this.handleCompleteMessage(data);
4996
5097
  }
@@ -5010,7 +5111,7 @@ class ShopGPT extends r$2 {
5010
5111
  async sendMessageToServer(e, message, isPrompt = false) {
5011
5112
  e.preventDefault();
5012
5113
  e.stopPropagation();
5013
- if (!message || this.isTyping || this.isLoadingHistory) {
5114
+ if (!message || this.isStreaming || this.isLoadingHistory) {
5014
5115
  return;
5015
5116
  }
5016
5117
  this.isFailed = false;
@@ -5021,6 +5122,7 @@ class ShopGPT extends r$2 {
5021
5122
  }
5022
5123
  this.messages = [{ sender: 'user', message }, ...this.messages];
5023
5124
  this.isTyping = true;
5125
+ this.isStreaming = true;
5024
5126
  const response = await this.submitQuery(message);
5025
5127
  this.processMessageResponse(response);
5026
5128
  }
@@ -5028,6 +5130,7 @@ class ShopGPT extends r$2 {
5028
5130
  logger.error(err);
5029
5131
  this.isFailed = true;
5030
5132
  this.isTyping = false;
5133
+ this.isStreaming = false;
5031
5134
  }
5032
5135
  }
5033
5136
  submitFeedback(e) {
@@ -5081,7 +5184,7 @@ class ShopGPT extends r$2 {
5081
5184
  .selectedThreadId=${this.selectedThreadId}
5082
5185
  .setSelectedThreadId=${this.setSelectedThreadId.bind(this)}
5083
5186
  .isLoading=${this.isLoadingThreads}
5084
- .isTyping=${this.isTyping}
5187
+ .isStreaming=${this.isStreaming}
5085
5188
  .merchantUrl=${this.merchantUrl}
5086
5189
  .css=${this.css}
5087
5190
  ></chat-threads>
@@ -5099,6 +5202,7 @@ class ShopGPT extends r$2 {
5099
5202
  .isFailed=${this.isFailed}
5100
5203
  .isLoadingHistory=${this.isLoadingHistory}
5101
5204
  .isTyping=${this.isTyping}
5205
+ .isStreaming=${this.isStreaming}
5102
5206
  .messages=${this.messages}
5103
5207
  .siteCurrency=${this.getSiteCurrency()}
5104
5208
  .sendMessageToServer=${this.sendMessageToServer.bind(this)}
@@ -5112,6 +5216,7 @@ class ShopGPT extends r$2 {
5112
5216
  .customPrompts=${this.customPrompts}
5113
5217
  .botIconUrl=${this.botIconUrl}
5114
5218
  .css=${this.css}
5219
+ .fromAd=${this.isFromAd()}
5115
5220
  ></chat-section>
5116
5221
  </div>
5117
5222
  </dialog>
@@ -5122,6 +5227,7 @@ class ShopGPT extends r$2 {
5122
5227
  const thread = this.chatThreads.get(this.selectedThreadId);
5123
5228
  const closeModal = () => {
5124
5229
  this.modalState = 'close';
5230
+ this.shopGPTAPI.sendEvent('chatbotClosed');
5125
5231
  };
5126
5232
  if (this.modalState === 'close') {
5127
5233
  return x ` <div class="chatbot-widget">
@@ -5168,6 +5274,7 @@ class ShopGPT extends r$2 {
5168
5274
  .isFailed=${this.isFailed}
5169
5275
  .isLoadingHistory=${this.isLoadingHistory}
5170
5276
  .isTyping=${this.isTyping}
5277
+ .isStreaming=${this.isStreaming}
5171
5278
  .messages=${this.messages}
5172
5279
  .siteCurrency=${this.getSiteCurrency()}
5173
5280
  .sendMessageToServer=${this.sendMessageToServer.bind(this)}
@@ -5185,6 +5292,7 @@ class ShopGPT extends r$2 {
5185
5292
  .customPrompts=${this.customPrompts}
5186
5293
  .botIconUrl=${this.botIconUrl}
5187
5294
  .css=${this.css}
5295
+ .fromAd=${this.isFromAd()}
5188
5296
  ></chat-section>
5189
5297
  </div>
5190
5298
  `;
@@ -5257,6 +5365,10 @@ __decorate([
5257
5365
  n({ type: Boolean }),
5258
5366
  __metadata("design:type", Object)
5259
5367
  ], ShopGPT.prototype, "isTyping", void 0);
5368
+ __decorate([
5369
+ n({ type: Boolean }),
5370
+ __metadata("design:type", Object)
5371
+ ], ShopGPT.prototype, "isStreaming", void 0);
5260
5372
  __decorate([
5261
5373
  n({ type: Boolean }),
5262
5374
  __metadata("design:type", Object)
@@ -5321,6 +5433,7 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
5321
5433
  shopGPT.css = params.css;
5322
5434
  shopGPT.nudge = params.nudge;
5323
5435
  shopGPT.sessionId = params.sessionId;
5436
+ shopGPT.loadUIManually = params.loadUIManually;
5324
5437
  },
5325
5438
  loadUI() {
5326
5439
  if (!shopGPT) {