ai12z 3.7.1-alpha.2 → 3.7.1-alpha.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 (33) hide show
  1. package/dist/cjs/{ai12z-bot-f536d432.js → ai12z-bot-22c9e619.js} +4 -7
  2. package/dist/cjs/ai12z-bot-22c9e619.js.map +1 -0
  3. package/dist/cjs/ai12z-bot.cjs.entry.js +2 -2
  4. package/dist/cjs/ai12z-chat_2.cjs.entry.js +1 -1
  5. package/dist/cjs/{endResponseHelper-aedf327c.js → endResponseHelper-3a252947.js} +27 -12
  6. package/dist/cjs/{endResponseHelper-aedf327c.js.map → endResponseHelper-3a252947.js.map} +1 -1
  7. package/dist/cjs/index.cjs.js +2 -2
  8. package/dist/collection/components/ai12z-bot/ai12z-bot.js +2 -5
  9. package/dist/collection/components/ai12z-bot/ai12z-bot.js.map +1 -1
  10. package/dist/collection/utils/endResponseHelper.js +26 -11
  11. package/dist/collection/utils/endResponseHelper.js.map +1 -1
  12. package/dist/esm/{ai12z-bot-60210b29.js → ai12z-bot-f05b1bae.js} +4 -7
  13. package/dist/esm/ai12z-bot-f05b1bae.js.map +1 -0
  14. package/dist/esm/ai12z-bot.entry.js +2 -2
  15. package/dist/esm/ai12z-chat_2.entry.js +1 -1
  16. package/dist/esm/{endResponseHelper-0a8350cd.js → endResponseHelper-1e5c18bc.js} +27 -12
  17. package/dist/esm/{endResponseHelper-0a8350cd.js.map → endResponseHelper-1e5c18bc.js.map} +1 -1
  18. package/dist/esm/index.js +2 -2
  19. package/dist/library/index.esm.js +1 -1
  20. package/dist/library/library.esm.js +1 -1
  21. package/dist/library/{p-1a65f5ce.js → p-27024128.js} +2 -2
  22. package/dist/library/p-27024128.js.map +1 -0
  23. package/dist/library/{p-28b7f8c0.entry.js → p-7fc447f6.entry.js} +2 -2
  24. package/dist/library/p-aa15d703.entry.js +2 -0
  25. package/dist/library/{p-a1af8611.js → p-b2ad7339.js} +2 -2
  26. package/dist/library/{p-a1af8611.js.map → p-b2ad7339.js.map} +1 -1
  27. package/package.json +2 -2
  28. package/dist/cjs/ai12z-bot-f536d432.js.map +0 -1
  29. package/dist/esm/ai12z-bot-60210b29.js.map +0 -1
  30. package/dist/library/p-1a65f5ce.js.map +0 -1
  31. package/dist/library/p-4626e0e6.entry.js +0 -2
  32. /package/dist/library/{p-28b7f8c0.entry.js.map → p-7fc447f6.entry.js.map} +0 -0
  33. /package/dist/library/{p-4626e0e6.entry.js.map → p-aa15d703.entry.js.map} +0 -0
@@ -1,9 +1,9 @@
1
- export { A as ai12z_bot } from './ai12z-bot-60210b29.js';
1
+ export { A as ai12z_bot } from './ai12z-bot-f05b1bae.js';
2
2
  import './index-9f7965fd.js';
3
3
  import './index-a2a24524.js';
4
4
  import './showdown-bfc2ff79.js';
5
5
  import './_commonjsHelpers-1789f0cf.js';
6
- import './endResponseHelper-0a8350cd.js';
6
+ import './endResponseHelper-1e5c18bc.js';
7
7
  import './utils-75c1493f.js';
8
8
  import './logger-2e094dec.js';
9
9
  import './index-04121734.js';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, E as Env, h, g as getElement } from './index-9f7965fd.js';
2
2
  import { s as showdown } from './showdown-bfc2ff79.js';
3
- import { r as renderSurvey, h as handleEndResponse, a as hljs, p as processChatData } from './endResponseHelper-0a8350cd.js';
3
+ import { r as renderSurvey, h as handleEndResponse, a as hljs, p as processChatData } from './endResponseHelper-1e5c18bc.js';
4
4
  import { a as generateUUID, e as getMetaInfo, D as getAudioContent, F as debounce } from './utils-75c1493f.js';
5
5
  import { H as Handlebars } from './index-04121734.js';
6
6
  import { S as SocketService } from './socket-service-b2161df4.js';
@@ -58549,7 +58549,6 @@ async function renderSurvey(options) {
58549
58549
 
58550
58550
  async function handleEndResponse(params) {
58551
58551
  var _a;
58552
- console.log("Handling end response with params:");
58553
58552
  const { data, currentDomId, setMessages, setSurveyDomId, config, setButtons, inputType } = params;
58554
58553
  try {
58555
58554
  const converter = new showdown.Converter();
@@ -58576,7 +58575,6 @@ async function handleEndResponse(params) {
58576
58575
  }
58577
58576
  async function handleControlTypes(finalHtml, data, currentDomId, setMessages, controlMatches, config, setSurveyDomId, inputType) {
58578
58577
  if (controlMatches.length === 0) {
58579
- console.log("No control matches found in the final HTML.");
58580
58578
  await handleRegularContent(finalHtml, currentDomId, config);
58581
58579
  }
58582
58580
  else if (controlMatches.length > 0) {
@@ -58584,27 +58582,44 @@ async function handleControlTypes(finalHtml, data, currentDomId, setMessages, co
58584
58582
  await handleMultipleControls(finalHtml, data, currentDomId, setMessages, config, setSurveyDomId, inputType);
58585
58583
  }
58586
58584
  }
58587
- async function handleFormControl(finalHtml, data, currentDomId, config, setSurveyDomId, output) {
58585
+ async function handleFormControl(data, config, setSurveyDomId, inputType, setMessages, output, currentDomId, index) {
58588
58586
  var _a, _b, _c;
58589
- console.log("Handling form control", currentDomId);
58590
58587
  const newSurveyDomId = `surveyElement-${generateUUID()}`;
58591
58588
  if (setSurveyDomId) {
58592
58589
  setSurveyDomId(newSurveyDomId);
58593
58590
  }
58594
- const formHtml = finalHtml.replace(RegExp(/\[[^>]*]/gm), `<div id=${newSurveyDomId} style="width:${((_a = config.controlSettings) === null || _a === void 0 ? void 0 : _a.botVersion) === "v1" ? "330px" : "100%"}" class="survey-container"></div>`);
58595
- const element = config.element.shadowRoot.querySelector(`#${currentDomId}`);
58591
+ let newCtrlMessage;
58592
+ if (index !== 0) {
58593
+ if (inputType === "bot") {
58594
+ // Create new control message
58595
+ newCtrlMessage = generateMessage(config.conversationId);
58596
+ newCtrlMessage.surveyDomId = newSurveyDomId;
58597
+ setMessages(newCtrlMessage);
58598
+ }
58599
+ else if (inputType === "cta") {
58600
+ newCtrlMessage = config.getUpdatedChat("", data);
58601
+ newCtrlMessage.surveyDomId = newSurveyDomId;
58602
+ setMessages(newCtrlMessage);
58603
+ }
58604
+ // Wait for DOM render
58605
+ await waitForElementRender(`#${newCtrlMessage.id}`, config.element);
58606
+ }
58607
+ const formHtml = `<div id=${newSurveyDomId} style="width:${((_a = config.controlSettings) === null || _a === void 0 ? void 0 : _a.botVersion) === "v1" ? "330px" : "100%"}" class="survey-container"></div>`;
58608
+ (_b = config.updateConversations) === null || _b === void 0 ? void 0 : _b.call(config, formHtml, data);
58609
+ // const formHtml = finalHtml.replace(
58610
+ // RegExp(/\[[^>]*]/gm),
58611
+ // `<div id=${newSurveyDomId} style="width:${config.controlSettings?.botVersion === "v1" ? "330px" : "100%"}" class="survey-container"></div>`
58612
+ // )
58613
+ const element = config.element.shadowRoot.querySelector(`#${index === 0 ? currentDomId : newCtrlMessage.id}`);
58596
58614
  if (element) {
58597
58615
  element["style"].width = "100%";
58598
58616
  element.parentElement["style"].width = "100%";
58599
58617
  element.innerHTML = formHtml;
58600
58618
  // config.getUpdatedChat?.(formHtml, data)(null)
58601
- (_b = config.updateConversations) === null || _b === void 0 ? void 0 : _b.call(config, formHtml, data);
58602
58619
  // Filter data by agentDataId if available
58603
58620
  if (output.agentDataId && ((_c = data.controls) === null || _c === void 0 ? void 0 : _c.length) > 0) {
58604
58621
  const filteredItems = data.controls.filter(item => item.agent_data_id === output.agentDataId);
58605
- console.log("Filtered Items for Form Control:", filteredItems);
58606
58622
  data.controlData = filteredItems.length > 0 ? filteredItems[0] : null;
58607
- console.log(`✅ Filtered ${filteredItems.length} items for agentDataId: ${output.agentDataId}`);
58608
58623
  }
58609
58624
  }
58610
58625
  // Render the survey
@@ -58645,10 +58660,9 @@ async function handleMultipleControls(finalHtml, data, currentDomId, setMessages
58645
58660
  }
58646
58661
  }
58647
58662
  if (output.type === 'control' && output.controlType) {
58648
- console.log(`Processing control of type: ${output.controlType}`);
58649
58663
  switch (output.controlType) {
58650
58664
  case "form":
58651
- await handleFormControl(finalHtml, data, currentDomId, config, setSurveyDomId, output);
58665
+ await handleFormControl(data, config, setSurveyDomId, inputType, setMessages, output, currentDomId, index);
58652
58666
  break;
58653
58667
  case "carousel":
58654
58668
  case "list":
@@ -58715,6 +58729,7 @@ async function handleRegularContent(finalHtml, currentDomId, config) {
58715
58729
  element.innerHTML = finalHtml;
58716
58730
  config.checkHighlightcode(currentDomId);
58717
58731
  (_a = config.updateConversations) === null || _a === void 0 ? void 0 : _a.call(config, finalHtml, {});
58732
+ config.addEventListeners(`#${currentDomId}`);
58718
58733
  }
58719
58734
  }
58720
58735
  // Helper function to wait for element to render
@@ -58736,4 +58751,4 @@ function waitForElementRender(selector, element) {
58736
58751
 
58737
58752
  export { hljs$1 as a, handleEndResponse as h, processChatData as p, renderSurvey as r };
58738
58753
 
58739
- //# sourceMappingURL=endResponseHelper-0a8350cd.js.map
58754
+ //# sourceMappingURL=endResponseHelper-1e5c18bc.js.map