ai12z 3.3.2 → 3.3.4

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 (66) hide show
  1. package/dist/cjs/ai12z-bot-f357d89d.js +2613 -0
  2. package/dist/cjs/ai12z-bot-f357d89d.js.map +1 -0
  3. package/dist/cjs/ai12z-bot.cjs.entry.js +1 -1
  4. package/dist/cjs/ai12z-chat_3.cjs.entry.js +46 -36
  5. package/dist/cjs/ai12z-chat_3.cjs.entry.js.map +1 -1
  6. package/dist/cjs/ai12z-knowledge-box-005b5b85.js +384 -0
  7. package/dist/cjs/ai12z-knowledge-box-005b5b85.js.map +1 -0
  8. package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +1 -1
  9. package/dist/cjs/dynamic-form.cjs.entry.js +35 -31
  10. package/dist/cjs/dynamic-form.cjs.entry.js.map +1 -1
  11. package/dist/cjs/index.cjs.js +2 -2
  12. package/dist/collection/components/ai12z-bot/ai12z-bot.js +51 -30
  13. package/dist/collection/components/ai12z-bot/ai12z-bot.js.map +1 -1
  14. package/dist/collection/components/ai12z-cta/components/Chat.js +46 -36
  15. package/dist/collection/components/ai12z-cta/components/Chat.js.map +1 -1
  16. package/dist/collection/components/ai12z-cta/components/DynamicForm.js +35 -31
  17. package/dist/collection/components/ai12z-cta/components/DynamicForm.js.map +1 -1
  18. package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +45 -30
  19. package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js.map +1 -1
  20. package/dist/collection/global/survey-core.min.css +6 -0
  21. package/dist/esm/ai12z-bot-77e7fbec.js +2611 -0
  22. package/dist/esm/ai12z-bot-77e7fbec.js.map +1 -0
  23. package/dist/esm/ai12z-bot.entry.js +1 -1
  24. package/dist/esm/ai12z-chat_3.entry.js +46 -36
  25. package/dist/esm/ai12z-chat_3.entry.js.map +1 -1
  26. package/dist/esm/ai12z-knowledge-box-71a10937.js +382 -0
  27. package/dist/esm/ai12z-knowledge-box-71a10937.js.map +1 -0
  28. package/dist/esm/ai12z-knowledge-box.entry.js +1 -1
  29. package/dist/esm/dynamic-form.entry.js +35 -31
  30. package/dist/esm/dynamic-form.entry.js.map +1 -1
  31. package/dist/esm/index.js +2 -2
  32. package/dist/library/index.esm.js +1 -1
  33. package/dist/library/library.esm.js +1 -1
  34. package/dist/library/{p-3e968bf1.entry.js → p-03269530.entry.js} +2 -2
  35. package/dist/library/p-08bbb4b8.entry.js +2 -0
  36. package/dist/library/p-08bbb4b8.entry.js.map +1 -0
  37. package/dist/library/{p-af76a7c6.entry.js → p-32558909.entry.js} +2 -2
  38. package/dist/library/{p-d567093b.entry.js → p-706e3933.entry.js} +2 -2
  39. package/dist/library/p-706e3933.entry.js.map +1 -0
  40. package/dist/library/p-a8e4dffd.js +2 -0
  41. package/dist/library/p-a8e4dffd.js.map +1 -0
  42. package/dist/library/p-c5f0d025.js +2 -0
  43. package/dist/library/p-c5f0d025.js.map +1 -0
  44. package/dist/types/components/ai12z-bot/ai12z-bot.d.ts +4 -0
  45. package/dist/types/components/ai12z-cta/components/Chat.d.ts +3 -0
  46. package/dist/types/components/ai12z-cta/components/DynamicForm.d.ts +3 -5
  47. package/dist/types/components/ai12z-knowledge-box/ai12z-knowledge-box.d.ts +3 -1
  48. package/package.json +6 -6
  49. package/dist/cjs/ai12z-bot-74f5836f.js +0 -2592
  50. package/dist/cjs/ai12z-bot-74f5836f.js.map +0 -1
  51. package/dist/cjs/ai12z-knowledge-box-30117a83.js +0 -369
  52. package/dist/cjs/ai12z-knowledge-box-30117a83.js.map +0 -1
  53. package/dist/collection/global/survey.min.css +0 -6
  54. package/dist/esm/ai12z-bot-6f64c1b4.js +0 -2590
  55. package/dist/esm/ai12z-bot-6f64c1b4.js.map +0 -1
  56. package/dist/esm/ai12z-knowledge-box-f0962b9a.js +0 -367
  57. package/dist/esm/ai12z-knowledge-box-f0962b9a.js.map +0 -1
  58. package/dist/library/p-03ec5034.js +0 -2
  59. package/dist/library/p-03ec5034.js.map +0 -1
  60. package/dist/library/p-28892eb0.entry.js +0 -2
  61. package/dist/library/p-28892eb0.entry.js.map +0 -1
  62. package/dist/library/p-a6392d09.js +0 -2
  63. package/dist/library/p-a6392d09.js.map +0 -1
  64. package/dist/library/p-d567093b.entry.js.map +0 -1
  65. /package/dist/library/{p-3e968bf1.entry.js.map → p-03269530.entry.js.map} +0 -0
  66. /package/dist/library/{p-af76a7c6.entry.js.map → p-32558909.entry.js.map} +0 -0
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const ai12zBot = require('./ai12z-bot-74f5836f.js');
5
+ const ai12zBot = require('./ai12z-bot-f357d89d.js');
6
6
  const ai12zCta = require('./ai12z-cta-3d6f0243.js');
7
- const ai12zKnowledgeBox = require('./ai12z-knowledge-box-30117a83.js');
7
+ const ai12zKnowledgeBox = require('./ai12z-knowledge-box-005b5b85.js');
8
8
  const ai12zSearchPanel = require('./ai12z-search-panel-2c065bf9.js');
9
9
  const searchResultsView = require('./search-results-view-9698b826.js');
10
10
  const ai12zInlineSearch = require('./ai12z-inline-search-5af28d9d.js');
@@ -11,10 +11,12 @@ import { ChatEventBus } from "../../utils/liveagents/chateventbus";
11
11
  export class Ai12zBot {
12
12
  constructor() {
13
13
  this.cdnPath = "https://cdn.ai12z.net/assets/bot";
14
+ this.surveyCDNPath = "https://cdn.ai12z.net/pkg/surveyjs";
14
15
  this.styles = [
15
16
  // `${this.cdnPath}/v1/survey.min.css`,
16
17
  // `https://unpkg.com/survey-core/defaultV2.min.css`,
17
18
  // `${this.cdnPath}/v1/survey-core.min.css`,
19
+ // `https://unpkg.com/survey-core@2.3.4/survey-core.min.css`,
18
20
  `https://unpkg.com/@highlightjs/cdn-assets@11.9.0/styles/default.min.css`,
19
21
  ];
20
22
  this.liveAgentEventHandler = new LiveAgentEventHandler();
@@ -37,6 +39,7 @@ export class Ai12zBot {
37
39
  // console.log("showHistory", this.showHistory)
38
40
  };
39
41
  this.alertResults = sender => {
42
+ var _a, _b, _c;
40
43
  // console.log("Survey results", sender.keyName)
41
44
  this.formSubmitted.emit(sender.data);
42
45
  // console.log("survey results", sender.jsonObj)
@@ -52,7 +55,7 @@ export class Ai12zBot {
52
55
  // console.log("sender", results)
53
56
  // const query = "Here is the data you requested:" + results
54
57
  // this.query = query
55
- const domId = sender.implementor.renderedElement.id;
58
+ const domId = (_c = (_b = (_a = sender.implementor) === null || _a === void 0 ? void 0 : _a.renderedElement) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : sender.domId;
56
59
  // const surveyDataId = domId.replace("surveyElement-", "")
57
60
  // sender.implementor.renderedElement.innerHTML = `<p><b>Thank you</b></p>`
58
61
  // console.log("messages", this.messages)
@@ -123,7 +126,9 @@ export class Ai12zBot {
123
126
  }
124
127
  const domELe = (_f = this.el.shadowRoot) === null || _f === void 0 ? void 0 : _f.querySelector(`#${this.surveyDomId}`);
125
128
  if (domELe) {
126
- window["jQuery"](domELe).Survey({ model: survey });
129
+ survey.domId = this.surveyDomId;
130
+ survey.render(domELe);
131
+ // window["jQuery"](domELe).Survey({ model: survey })
127
132
  }
128
133
  else {
129
134
  console.error("Survey Element not found");
@@ -421,35 +426,47 @@ export class Ai12zBot {
421
426
  window.addEventListener("resize", this.updateScreenSize.bind(this));
422
427
  // debugger;
423
428
  document.addEventListener("click", this.handleClickOutside.bind(this));
424
- // Load jQuery first
425
- const jQueryScript = document.createElement("script");
426
- jQueryScript.src = this.cdnPath + "/v1/jquery.min.js"; // Path relative to the www root
427
- jQueryScript.onload = () => {
428
- // console.log("jQuery loaded")
429
- // Load the script that loads and exposes SurveyJS
430
- const loadSurveyScript = document.createElement("script");
431
- loadSurveyScript.src = this.cdnPath + "/v1/survey.jquery.min.js"; // Path relative to the www root
432
- loadSurveyScript.onload = () => {
433
- // console.log("SurveyJS loaded and SurveyModel exposed")
434
- };
435
- loadSurveyScript.onerror = err => {
436
- console.error("Failed to load Forms:", err);
437
- };
438
- document.head.appendChild(loadSurveyScript);
439
- this.el.shadowRoot.appendChild(loadSurveyScript);
440
- };
441
- jQueryScript.onerror = err => {
442
- console.error("Failed to load jQuery:", err);
443
- };
444
- document.head.appendChild(jQueryScript);
445
429
  const ai12zHeading = document.createElement("script");
446
430
  ai12zHeading.text = `
447
431
  var ai12zChat = window["ai12z"] = {}
448
432
  `;
449
433
  document.head.appendChild(ai12zHeading);
450
434
  this.el.shadowRoot.appendChild(ai12zHeading);
451
- this.el.shadowRoot.appendChild(jQueryScript);
452
- this.loadStyles();
435
+ // this.loadStyles()
436
+ this.loadScriptsSequentially();
437
+ }
438
+ async loadScriptsSequentially() {
439
+ try {
440
+ // 2. Load Survey Core
441
+ await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/survey.core.min.js`);
442
+ // 3. Load Survey i18n
443
+ await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/survey.i18n.min.js`);
444
+ // 4. Load Survey themes
445
+ await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/themes/index.min.js`);
446
+ // 6. Load Survey UI
447
+ await this.loadScript(`${this.surveyCDNPath}/survey-js-ui@2.3.4/survey-js-ui.min.js`);
448
+ console.log("All Survey.js scripts loaded successfully");
449
+ this.loadStyles();
450
+ }
451
+ catch (error) {
452
+ console.error("Failed to load Survey.js scripts:", error);
453
+ }
454
+ }
455
+ loadScript(src) {
456
+ return new Promise((resolve, reject) => {
457
+ if (document.querySelector(`script[src="${src}"]`)) {
458
+ resolve();
459
+ return;
460
+ }
461
+ const script = document.createElement("script");
462
+ script.src = src;
463
+ script.async = false;
464
+ script.onload = () => resolve();
465
+ script.onerror = () => reject(new Error(`Failed to load script: ${src}`));
466
+ // Load in document head for global access
467
+ // document.head.appendChild(script)
468
+ this.el.shadowRoot.appendChild(script);
469
+ });
453
470
  }
454
471
  loadStyles() {
455
472
  for (const style of this.styles) {
@@ -1009,7 +1026,7 @@ export class Ai12zBot {
1009
1026
  switch (data.controlType) {
1010
1027
  case "form":
1011
1028
  this.surveyDomId = "surveyElement-" + generateUUID();
1012
- finalHtml = finalHtml.replace(RegExp(/\[[^>]*]/gm), `<div id=${this.surveyDomId} style="width:${this.botSettings.botVersion === "v1" ? "330px" : "100%"}"></div>`);
1029
+ finalHtml = finalHtml.replace(RegExp(/\[[^>]*]/gm), `<div id=${this.surveyDomId} style="width:${this.botSettings.botVersion === "v1" ? "330px" : "100%"}" class="survey-container"></div>`);
1013
1030
  // finalHtml = `<div id=${this.surveyDomId} style="width:${this.botSettings.botVersion === "v1" ? "330px" : "100%"}"></div>`
1014
1031
  this.el.shadowRoot.querySelector(`#${this.currentDomId}`).innerHTML = finalHtml;
1015
1032
  this.updateConversations(finalHtml, data);
@@ -1112,6 +1129,7 @@ export class Ai12zBot {
1112
1129
  conversationId: this.conversationId,
1113
1130
  formModel: (_d = (_c = (_b = (_a = data.controlData) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.source) !== null && _c !== void 0 ? _c : data.controlData) !== null && _d !== void 0 ? _d : {},
1114
1131
  surveyDomId: this.surveyDomId,
1132
+ controlType: data.controlType,
1115
1133
  thumbsId: `${generateUUID()}`,
1116
1134
  showIcon: data.controlType ? false : true,
1117
1135
  insightId: (_f = data === null || data === void 0 ? void 0 : data.insightId) !== null && _f !== void 0 ? _f : null,
@@ -1154,7 +1172,10 @@ export class Ai12zBot {
1154
1172
  });
1155
1173
  }
1156
1174
  else {
1157
- container.classList.add("prose");
1175
+ if (this.messages[this.messages.length - 1].controlType !== "form") {
1176
+ container.classList.add("prose");
1177
+ }
1178
+ // container.classList.add("prose")
1158
1179
  // this.isProse = true
1159
1180
  }
1160
1181
  }
@@ -1844,7 +1865,7 @@ export class Ai12zBot {
1844
1865
  ${message.isUser ? "justify-end" : ""} end-user-message message-item`, style: { opacity: "1", transform: "none" } }, message.isUser && (h("div", { class: "flex flex-col items-end" }, h("div", { "data-testid": "message", class: "break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg py-2 px-4 user-msg text-body3", innerHTML: message.text }, (_a = message === null || message === void 0 ? void 0 : message.images) === null || _a === void 0 ? void 0 : _a.map(img => {
1845
1866
  return h("img", { src: img, class: "thumbnail", alt: "thumbnail" });
1846
1867
  })), h("div", { class: "text-gray-30 pt-2 text-right text-body4" }, "Sent ", message.timestamp))), !message.isUser && (h("div", { class: "avatar-column" }, h("chat-avatar", { id: `la${message.id}`, senderType: (message === null || message === void 0 ? void 0 : message.sender) ? "agent" : "bot", avatarUrl: (_b = this.botSettings) === null || _b === void 0 ? void 0 : _b.botAvatar }))), !message.isUser && (h("div", { class: "flex flex-col", style: { width: "100%" } }, h("div", { "data-testid": "message", class: {
1847
- "prose": true,
1868
+ "prose": message.controlType === "form" ? false : true,
1848
1869
  "transition-all": true,
1849
1870
  "duration-300": true,
1850
1871
  "opacity-100": this.isProse,
@@ -1935,12 +1956,12 @@ export class Ai12zBot {
1935
1956
  static get encapsulation() { return "shadow"; }
1936
1957
  static get originalStyleUrls() {
1937
1958
  return {
1938
- "$": ["./ai12z-bot.css", "../../global/tailwind.min.css", "../../global/survey.min.css", "./ai12z-chatbot.css"]
1959
+ "$": ["./ai12z-bot.css", "../../global/tailwind.min.css", "./ai12z-chatbot.css", "../../global/survey-core.min.css"]
1939
1960
  };
1940
1961
  }
1941
1962
  static get styleUrls() {
1942
1963
  return {
1943
- "$": ["ai12z-bot.css", "../../global/tailwind.min.css", "../../global/survey.min.css", "ai12z-chatbot.css"]
1964
+ "$": ["ai12z-bot.css", "../../global/tailwind.min.css", "ai12z-chatbot.css", "../../global/survey-core.min.css"]
1944
1965
  };
1945
1966
  }
1946
1967
  static get properties() {