@alan-ai/alan-sdk-web 1.8.73 → 1.8.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/alan_lib.js CHANGED
@@ -341,7 +341,7 @@
341
341
  this._cleanups.push(f);
342
342
  };
343
343
 
344
- function fillAuth(values, ext, config) {
344
+ function fillAuth(values, ext, connectionConfig) {
345
345
  var auth = {};
346
346
  for (var k in ext) {
347
347
  auth[k] = ext[k];
@@ -365,7 +365,8 @@
365
365
  }
366
366
 
367
367
  if (auth && auth.withEdgeUrl) {
368
- auth.edgeUrl = config ? config.url : undefined;
368
+ delete auth.withEdgeUrl;
369
+ auth.edgeUrl = connectionConfig ? connectionConfig.url : undefined;
369
370
  }
370
371
  return auth;
371
372
  }
@@ -89614,11 +89615,17 @@
89614
89615
  <path d="M2.375 12.875C2.375 15.1141 2.375 16.2337 3.07062 16.9294C3.76624 17.625 4.88583 17.625 7.125 17.625H11.875C14.1142 17.625 15.2337 17.625 15.9294 16.9294C16.625 16.2337 16.625 15.1141 16.625 12.875" stroke="#1C274C" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
89615
89616
  <path d="M9.50001 3.375V13.6667M9.50001 13.6667L12.6667 10.2031M9.50001 13.6667L6.33334 10.2031" stroke="#1C274C" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
89616
89617
  </svg>
89617
- `
89618
+ `,
89619
+ minimize: `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
89620
+ <path d="M3 17.25L18 17.25" stroke="none" stroke-width="1.5" stroke-linecap="round"/>
89621
+ </svg>`
89618
89622
  };
89619
89623
  function getCloseChatIcon(textChatOptions) {
89620
89624
  return textChatOptions?.popup?.icons?.close?.svg || chatIcons.closeChat;
89621
89625
  }
89626
+ function getMinimizeChatIcon(textChatOptions) {
89627
+ return textChatOptions?.popup?.icons?.minimize?.svg || chatIcons.minimize;
89628
+ }
89622
89629
  function getExpandChatIcon(textChatOptions) {
89623
89630
  return textChatOptions?.popup?.icons?.fullScreen?.svgExpand || chatIcons.expandChat;
89624
89631
  }
@@ -91095,6 +91102,21 @@
91095
91102
  fill: ${textChatOptions?.popup?.icons?.close?.hover?.fill || `#97989c`};
91096
91103
  }`;
91097
91104
  }
91105
+ keyFrames += getStyleSheetMarker() + `.alan-btn__minimize-chat-btn {
91106
+ height: 100%;
91107
+ display: ${textChatOptions?.popup?.minimizeMode?.enabled ? "flex" : `none`};
91108
+ align-items: center;
91109
+ cursor: pointer;
91110
+ pointer-events: all;
91111
+ }`;
91112
+ keyFrames += getStyleSheetMarker() + `.alan-btn__minimize-chat-btn svg path {
91113
+ stroke: ${textChatOptions?.popup?.icons?.minimize?.default?.fill || `#969EB0`};
91114
+ }`;
91115
+ if (!isMobile()) {
91116
+ keyFrames += getStyleSheetMarker() + `.alan-btn__minimize-chat-btn:hover svg path {
91117
+ stroke: ${textChatOptions?.popup?.icons?.minimize?.hover?.fill || `#0046ff`};
91118
+ }`;
91119
+ }
91098
91120
  keyFrames += getStyleSheetMarker() + `.alan-btn__save-chat-state-btn {
91099
91121
  height: 100%;
91100
91122
  display: ${textChatOptions?.popup?.saveChatState?.enabled ? "flex" : `none`};
@@ -92418,7 +92440,6 @@
92418
92440
  const tagRegex = new RegExp(tag.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g");
92419
92441
  result = result.replace(tagRegex, replacement);
92420
92442
  }
92421
- console.info("result", result);
92422
92443
  return result;
92423
92444
  }
92424
92445
  function sanitize(str) {
@@ -92634,10 +92655,6 @@
92634
92655
  }`,
92635
92656
  `* + pre {
92636
92657
  margin-top: 8px!important;
92637
- }`,
92638
- `pre + * {
92639
- margin-top: 16px!important;
92640
- font-size: ${responseBubbleFontSize}px!important;
92641
92658
  }`,
92642
92659
  `* + ul {
92643
92660
  margin-top: 8px!important;
@@ -93969,7 +93986,7 @@ code.hljs {
93969
93986
 
93970
93987
  // alan_btn/alan_btn.ts
93971
93988
  (function(ns) {
93972
- uiState.lib.version = "alan-version.1.8.73".replace("alan-version.", "");
93989
+ uiState.lib.version = "alan-version.1.8.75".replace("alan-version.", "");
93973
93990
  if (window.alanBtn) {
93974
93991
  console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
93975
93992
  }
@@ -93995,6 +94012,7 @@ code.hljs {
93995
94012
  var dragAndDropEnabled = true;
93996
94013
  var curDialogId = null;
93997
94014
  var textChatIsHidden = true;
94015
+ var textChatWasClosedManually = false;
93998
94016
  var voiceEnabledInTextChat = true;
93999
94017
  var textChatMessages = [];
94000
94018
  var canceledRequests = [];
@@ -95506,7 +95524,9 @@ code.hljs {
95506
95524
  }
95507
95525
  initTextChat();
95508
95526
  if (isInlinedMode() || data.web.chatOptions?.textChat?.popup?.openByDefualt === true || isTextChatSavedStateOpened()) {
95509
- showTextChat(true);
95527
+ if (!textChatWasClosedManually) {
95528
+ showTextChat(true);
95529
+ }
95510
95530
  }
95511
95531
  } else {
95512
95532
  uiState.textChat.available = false;
@@ -96201,6 +96221,14 @@ ${LEARN_MORE_LABEL}
96201
96221
  return "";
96202
96222
  }
96203
96223
  var progressUpdateIntervalId = null;
96224
+ function hideLoadingMessages() {
96225
+ document.querySelectorAll(".alan-incoming-msg").forEach((div) => {
96226
+ const parent = div.closest("[data-msg-index]");
96227
+ if (parent) {
96228
+ parent.classList.add("alan-hide-msg-immidiatelly");
96229
+ }
96230
+ });
96231
+ }
96204
96232
  function renderMessageInTextChat(msg, noAnimation, immidiateScroll) {
96205
96233
  if (!uiState.textChat.available)
96206
96234
  return;
@@ -96444,6 +96472,9 @@ ${LEARN_MORE_LABEL}
96444
96472
  }
96445
96473
  }
96446
96474
  function onClearTextChatBtnClick() {
96475
+ if (options.onEvent) {
96476
+ options.onEvent({ name: "textChatCleared" });
96477
+ }
96447
96478
  clearDialogId();
96448
96479
  if (window.tutorProject) {
96449
96480
  window.tutorProject.close();
@@ -96463,7 +96494,6 @@ ${LEARN_MORE_LABEL}
96463
96494
  manageSaveChatHistoryBtn();
96464
96495
  }
96465
96496
  function onNewDialogAutoReconnect() {
96466
- console.info("onNewDialogAutoReconnect");
96467
96497
  if (textChatMessages?.length === 0)
96468
96498
  return;
96469
96499
  if (textChatMessages?.at(-1)?.type === "connection-separator")
@@ -96471,6 +96501,7 @@ ${LEARN_MORE_LABEL}
96471
96501
  const event = {
96472
96502
  type: "connection-separator"
96473
96503
  };
96504
+ hideLoadingMessages();
96474
96505
  renderMessageInTextChat(event);
96475
96506
  }
96476
96507
  window.onNewDialogAutoReconnect = onNewDialogAutoReconnect;
@@ -96894,6 +96925,7 @@ ${LEARN_MORE_LABEL}
96894
96925
  var rightHeaderIconsHolder = document.getElementById("chat-header-right-icons");
96895
96926
  var leftHeaderIconsHolder = document.getElementById("chat-header-left-icons");
96896
96927
  var closeChatBtnImg = document.getElementById("alan-btn-chat-close-btn");
96928
+ var minimizeChatBtnImg = document.getElementById("alan-btn-chat-minimize-btn");
96897
96929
  var expandCollapseChatBtnImg = document.getElementById("alan-btn-expand-collapse-chat-btn");
96898
96930
  var saveChatStateBtnImg = document.getElementById("alan-btn-save-chat-state-btn");
96899
96931
  const title = uiState.textChat.options?.header?.label || "Alan AI Assistant";
@@ -96965,6 +96997,11 @@ ${LEARN_MORE_LABEL}
96965
96997
  addNeedClassesToExpandCollapseBtn(expandCollapseChatBtnImg);
96966
96998
  }
96967
96999
  if (!isInlinedMode()) {
97000
+ if (uiState.textChat.options?.popup?.minimizeMode?.enabled === true) {
97001
+ minimizeChatBtnImg = createDivWithSvg(getMinimizeChatIcon(uiState.textChat.options), { class: "alan-btn__minimize-chat-btn", id: "alan-btn-chat-minimize-btn" });
97002
+ rightHeaderIconsHolder.appendChild(minimizeChatBtnImg);
97003
+ minimizeChatBtnImg.addEventListener("click", minimizeTextChat);
97004
+ }
96968
97005
  closeChatBtnImg = createDivWithSvg(getCloseChatIcon(uiState.textChat.options), { class: "alan-btn__close-chat-btn", id: "alan-btn-chat-close-btn" });
96969
97006
  rightHeaderIconsHolder.appendChild(closeChatBtnImg);
96970
97007
  closeChatBtnImg.addEventListener("click", closeTextChat);
@@ -97012,6 +97049,9 @@ ${LEARN_MORE_LABEL}
97012
97049
  const icon = uiState.textChat.options?.header?.icon?.svg;
97013
97050
  headerTille.innerHTML = `${icon ? `<span class="alan-btn__chat-header-title-icon">${icon}</span>` : ""}<span class="alan-btn__chat-header-title-label" title="${title}">${title}</span>`;
97014
97051
  }
97052
+ if (minimizeChatBtnImg) {
97053
+ minimizeChatBtnImg.innerHTML = getMinimizeChatIcon(uiState.textChat.options);
97054
+ }
97015
97055
  if (closeChatBtnImg) {
97016
97056
  closeChatBtnImg.innerHTML = getCloseChatIcon(uiState.textChat.options);
97017
97057
  }
@@ -97098,6 +97138,10 @@ ${LEARN_MORE_LABEL}
97098
97138
  }
97099
97139
  }
97100
97140
  function showTextChat(noAnimation) {
97141
+ textChatWasClosedManually = false;
97142
+ if (options.onEvent) {
97143
+ options.onEvent({ name: "textChatOpened" });
97144
+ }
97101
97145
  fixPopupScrollOnMobileForTextChat(true);
97102
97146
  hideChatNotifications();
97103
97147
  hidePopup();
@@ -97143,6 +97187,19 @@ ${LEARN_MORE_LABEL}
97143
97187
  return false;
97144
97188
  }
97145
97189
  function closeTextChat() {
97190
+ textChatWasClosedManually = true;
97191
+ if (options.onEvent) {
97192
+ options.onEvent({ name: "textChatClosed" });
97193
+ }
97194
+ hideTextChat();
97195
+ if (uiState.textChat.options?.popup?.clearChatOnClose === true) {
97196
+ onClearTextChatBtnClick();
97197
+ }
97198
+ }
97199
+ function minimizeTextChat() {
97200
+ if (options.onEvent) {
97201
+ options.onEvent({ name: "textChatMinimized" });
97202
+ }
97146
97203
  hideTextChat();
97147
97204
  }
97148
97205
  function expandCollapseChatSidePanel() {