@appbaseio/reactivesearch-vue 3.0.0-rc.17 → 3.0.0-rc.18

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.
@@ -808,7 +808,7 @@ var HorizontalSkeletonLoader = vue.defineComponent({
808
808
  });
809
809
 
810
810
  var _templateObject$7, _templateObject2$2, _templateObject3$1, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
811
- var Chatbox = vueEmotion.styled('div')(_templateObject$7 || (_templateObject$7 = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tposition: relative;\n\tmargin: 0 auto;\n\tpadding: 10px;\n\tbackground-color: #fafafa;\n\twidth: 100%;\n\tbox-shadow: rgb(0 0 0 / 20%) 0px 0px 6px;\n\tborder-radius: 6px;\n\tmargin-bottom: 20px;\n\tbackground-color: ", ";\n"])), function (props) {
811
+ var Chatbox = vueEmotion.styled('div')(_templateObject$7 || (_templateObject$7 = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tposition: relative;\n\tmargin: 0 auto;\n\tpadding: 10px;\n\tbackground-color: #fafafa;\n\twidth: 100%;\n\tbox-shadow: rgb(0 0 0 / 20%) 0px 0px 6px;\n\tborder-radius: 6px;\n\tmargin-bottom: 20px;\n\tbackground-color: ", ";\n\n\t.--trigger-message-wrapper {\n\t\tcursor: pointer;\n\t}\n"])), function (props) {
812
812
  return props.theme && props.theme.colors ? props.theme.colors.backgroundColor : '#fff';
813
813
  });
814
814
  var ChatContainer = vueEmotion.styled('div')(_templateObject2$2 || (_templateObject2$2 = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-direction: column;\n\theight: 100%;\n\tposition: relative;\n\t.--ai-answer-error-container {\n\t\ttext-align: center;\n\t\tposition: absolute;\n\t\tbottom: 0px;\n\t\t", ";\n\t\tz-index: 1;\n\t\tleft: 50%;\n\t\ttransform: translateX(-50%);\n\t\twidth: 100%;\n\n\t\t.--default-error-element {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\talign-items: center;\n\t\t\tpadding: 10px;\n\t\t\tbackground-color: ", ";\n\t\t\tbox-shadow: 0 -5px 5px -2px\n\t\t\t\t", ";\n\n\t\t\tspan {\n\t\t\t\tmargin-bottom: 5px;\n\t\t\t}\n\n\t\t\tbutton {\n\t\t\t}\n\t\t}\n\t}\n\n\t", ";\n"])), function (props) {
@@ -833,11 +833,15 @@ var TypingDot = vueEmotion.styled('div')(_templateObject6 || (_templateObject6 =
833
833
  return finalColor;
834
834
  }, typingDots);
835
835
  var resetCSS = function resetCSS(props) {
836
- return "\n\thtml,\n\tbody,\n\tdiv,\n\tspan,\n\tapplet,\n\tobject,\n\tiframe,\n\th1,\n\th2,\n\th3,\n\th4,\n\th5,\n\th6,\n\tp,\n\tblockquote,\n\tpre,\n\ta,\n\tabbr,\n\tacronym,\n\taddress,\n\tbig,\n\tcite,\n\tcode,\n\tdel,\n\tdfn,\n\tem,\n\timg,\n\tins,\n\tkbd,\n\tq,\n\ts,\n\tsamp,\n\tsmall,\n\tstrike,\n\tstrong,\n\tsub,\n\tsup,\n\ttt,\n\tvar,\n\tb,\n\tu,\n\ti,\n\tcenter,\n\tdl,\n\tdt,\n\tdd,\n\tol,\n\tul,\n\tli,\n\tfieldset,\n\tform,\n\tlabel,\n\tlegend,\n\ttable,\n\tcaption,\n\ttbody,\n\ttfoot,\n\tthead,\n\ttr,\n\tth,\n\ttd,\n\tarticle,\n\taside,\n\tcanvas,\n\tdetails,\n\tembed,\n\tfigure,\n\tfigcaption,\n\tfooter,\n\theader,\n\thgroup,\n\tmenu,\n\tnav,\n\toutput,\n\truby,\n\tsection,\n\tsummary,\n\ttime,\n\tmark,\n\taudio,\n\tvideo {\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tfont-size: 100%;\n\t\tfont: inherit;\n\t\tvertical-align: baseline;\n\t\toverflow-wrap: anywhere;\n\t}\n\tpre {\n\t\tmargin: 10px auto;\n\t}\n\ttable {\n\t\tmargin: 10px auto;\n\t\tborder-collapse: collapse;\n\t\tborder-spacing: 0;\n\t}\n\ttr {\n\t\tborder-bottom: 1px solid #ccc;\n\t}\n\tth,\n\ttd {\n\t\ttext-align: left;\n\t\tpadding: 4px;\n\t\tborder: 1px solid;\n\t\tborder-collapse: collapse;\n\t}\n\tpre,\n\tcode {\n\t\tpadding: 0.6em 0.4em;\n\t\tbackground: " + (
836
+ return "\n\thtml,\n\tbody,\n\tdiv,\n\tspan,\n\tapplet,\n\tobject,\n\tiframe,\n\th1,\n\th2,\n\th3,\n\th4,\n\th5,\n\th6,\n\tp,\n\tblockquote,\n\tpre,\n\ta,\n\tabbr,\n\tacronym,\n\taddress,\n\tbig,\n\tcite,\n\tcode,\n\tdel,\n\tdfn,\n\tem,\n\timg,\n\tins,\n\tkbd,\n\tq,\n\ts,\n\tsamp,\n\tsmall,\n\tstrike,\n\tstrong,\n\tsub,\n\tsup,\n\ttt,\n\tvar,\n\tb,\n\tu,\n\ti,\n\tcenter,\n\tdl,\n\tdt,\n\tdd,\n\tol,\n\tul,\n\tli,\n\tfieldset,\n\tform,\n\tlabel,\n\tlegend,\n\ttable,\n\tcaption,\n\ttbody,\n\ttfoot,\n\tthead,\n\ttr,\n\tth,\n\ttd,\n\tarticle,\n\taside,\n\tcanvas,\n\tdetails,\n\tembed,\n\tfigure,\n\tfigcaption,\n\tfooter,\n\theader,\n\thgroup,\n\tmenu,\n\tnav,\n\toutput,\n\truby,\n\tsection,\n\tsummary,\n\ttime,\n\tmark,\n\taudio,\n\tvideo {\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tfont-size: 100%;\n\t\tfont: inherit;\n\t\tvertical-align: baseline;\n\t\toverflow-wrap: anywhere;\n\t}\n\tpre {\n\t\tmargin: 10px auto;\n\t\twhite-space: pre-wrap;\n\n\t}\n\ttable {\n\t\tmargin: 10px auto;\n\t\tborder-collapse: collapse;\n\t\tborder-spacing: 0;\n\t}\n\ttr {\n\t\tborder-bottom: 1px solid #ccc;\n\t}\n\tth,\n\ttd {\n\t\ttext-align: left;\n\t\tpadding: 4px;\n\t\tborder: 1px solid;\n\t\tborder-collapse: collapse;\n\t}\n\tpre,\n\tcode {\n\t\tpadding: 0.6em 0.4em;\n\t\tbackground: " + (
837
837
  // eslint-disable-next-line no-nested-ternary
838
- props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryColor : props.theme.colors.borderColor : props.theme.colors.borderColor) + ";\n\t}\n\n\tcode {\n\t\tline-height: normal;\n\n\t\tcolor: " + (
838
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryColor : props.theme.colors.borderColor : props.theme.colors.borderColor) + ";\n\n\t}\n\n\tpre{\n\t\tcolor: " + (
839
839
  // eslint-disable-next-line no-nested-ternary
840
- props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\tborder-radius: 3px;\n\t\tfont-size: 85%;\n\t\tpadding: 0.2em 0.4em;\n\t\tmargin-top: 5px;\n\t\tdisplay: inline-block;\n\t\toverflow: auto;\n\t\twidth: fit-content;\n\t\tmax-width: 100%;\n\t}\n\tul,\n\tol {\n\t\tlist-style-position: inside;\n\t\tpadding-left: 10px;\n\n\t}\n\n\tli{\n\t\tdisplay: list-item;\n\t\tcursor: default;\n\t\tpadding: initial;\n\n\t\t&:hover{\n\t\t\tbackground-color: initial;\n\t\t}\n\t}\n\tp {\n\t\tmargin: inherit;\n\t}\n";
840
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";}\n\n\tcode {\n\t\tline-height: normal;\n\n\t\tcolor: " + (
841
+ // eslint-disable-next-line no-nested-ternary
842
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\tborder-radius: 3px;\n\t\tfont-size: 85%;\n\t\tpadding: 0.2em 0.4em;\n\t\tmargin-top: 5px;\n\t\tdisplay: inline-block;\n\t\toverflow: auto;\n\t\twidth: fit-content;\n\t\tmax-width: 100%;\n\t}\n\ncode[class*='language-'],\n\tpre[class*='language-'] {\n\t\tcolor: " + (
843
+ // eslint-disable-next-line no-nested-ternary
844
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\ttext-shadow: none;\n\t}\n\n\tul,\n\tol {\n\t\tlist-style-position: inside;\n\t\tpadding-left: 10px;\n\n\t}\n\n\tli{\n\t\tdisplay: list-item;\n\t\tcursor: default;\n\t\tpadding: initial;\n\n\t\t&:hover{\n\t\t\tbackground-color: initial;\n\t\t}\n\t}\n\tp {\n\t\tmargin: inherit;\n\t}\n";
841
845
  };
842
846
  var messageBGColor = function messageBGColor(props) {
843
847
  var finalBGColor;
@@ -1156,6 +1160,9 @@ var SearchBox = vue.defineComponent({
1156
1160
  }
1157
1161
  },
1158
1162
  computed: {
1163
+ currentTriggerMode: function currentTriggerMode() {
1164
+ return this.$props.AIUIConfig && this.$props.AIUIConfig.triggerOn || constants.AI_TRIGGER_MODES.MANUAL;
1165
+ },
1159
1166
  hasCustomRenderer: function hasCustomRenderer() {
1160
1167
  return index.hasCustomRenderer(this);
1161
1168
  },
@@ -1173,6 +1180,13 @@ var SearchBox = vue.defineComponent({
1173
1180
  if (Array.isArray(this.suggestions) && this.suggestions.length) {
1174
1181
  suggestionsArray = [].concat(withClickIds(this.suggestions));
1175
1182
  }
1183
+ if (this.renderTriggerMessage() && this.currentValue && !this.isLoading) {
1184
+ suggestionsArray.unshift({
1185
+ label: this.renderTriggerMessage(),
1186
+ value: 'AI_TRIGGER_MESSAGE',
1187
+ _suggestion_type: '_internal_a_i_trigger'
1188
+ });
1189
+ }
1176
1190
  suggestionsArray = suggestionsArray.map(function (s) {
1177
1191
  if (s.sectionId) {
1178
1192
  return s;
@@ -1446,6 +1460,20 @@ var SearchBox = vue.defineComponent({
1446
1460
  }
1447
1461
  },
1448
1462
  methods: {
1463
+ renderTriggerMessage: function renderTriggerMessage() {
1464
+ if (this.$props.enableAI) {
1465
+ if (this.$props.AIUIConfig && this.$props.AIUIConfig.renderTriggerMessage) {
1466
+ return this.$props.AIUIConfig.renderTriggerMessage;
1467
+ }
1468
+ if (this.$slots.renderTriggerMessage) {
1469
+ return this.$slots.renderTriggerMessage();
1470
+ }
1471
+ if (this.currentTriggerMode === constants.AI_TRIGGER_MODES.MANUAL && (this.$props.AIUIConfig ? !this.$props.AIUIConfig.askButton : true)) {
1472
+ return 'Click to trigger AIAnswer';
1473
+ }
1474
+ }
1475
+ return null;
1476
+ },
1449
1477
  handleText: function handleText(value, cause) {
1450
1478
  if (cause === reactivecore.causes.CLEAR_VALUE) {
1451
1479
  this.triggerCustomQuery(value);
@@ -1558,7 +1586,7 @@ var SearchBox = vue.defineComponent({
1558
1586
  if (toggleIsOpen) {
1559
1587
  _this2.isOpen = false;
1560
1588
  }
1561
- if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI ? {
1589
+ if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI && _this2.currentTriggerMode === constants.AI_TRIGGER_MODES.QUESTION && _this2.currentValue.endsWith('?') ? {
1562
1590
  enableAI: true
1563
1591
  } : {}, shouldExecuteQuery);
1564
1592
  } // in case of strict selection only SUGGESTION_SELECT should be able
@@ -1713,9 +1741,10 @@ var SearchBox = vue.defineComponent({
1713
1741
  } else if (highlightedIndex === null) {
1714
1742
  this.setValue(event.target.value, true, this.$props, this.$options.isTagsMode ? reactivecore.causes.SUGGESTION_SELECT : undefined,
1715
1743
  // to handle tags
1716
- !this.$props.enableAI);
1717
- if (this.$props.enableAI && !this.showAIScreen) {
1744
+ !(this.$props.enableAI && this.currentTriggerMode === constants.AI_TRIGGER_MODES.QUESTION && event.target.value.endsWith('?')));
1745
+ if (this.$props.enableAI && !this.showAIScreen && this.currentTriggerMode === constants.AI_TRIGGER_MODES.QUESTION && event.target.value.endsWith('?')) {
1718
1746
  this.showAIScreen = true;
1747
+ this.isOpen = true;
1719
1748
  }
1720
1749
  this.onValueSelectedHandler(event.target.value, reactivecore.causes.ENTER_PRESS);
1721
1750
  }
@@ -1800,6 +1829,11 @@ var SearchBox = vue.defineComponent({
1800
1829
  this.onValueSelectedHandler(suggestion.value);
1801
1830
  return;
1802
1831
  }
1832
+ if (suggestion && suggestion._suggestion_type === '_internal_a_i_trigger') {
1833
+ this.showAIScreen = true;
1834
+ this.askButtonOnClick();
1835
+ return;
1836
+ }
1803
1837
 
1804
1838
  // handle featured suggestions click event
1805
1839
  if (suggestion._suggestion_type === helper.suggestionTypes.Featured) {
@@ -1839,7 +1873,7 @@ var SearchBox = vue.defineComponent({
1839
1873
  this.onValueSelectedHandler(suggestion.value, reactivecore.causes.SUGGESTION_SELECT, suggestion.source);
1840
1874
 
1841
1875
  // Handle AI
1842
- if (!this.$props.enableAI) this.isOpen = false;else {
1876
+ if (!this.$props.enableAI) this.isOpen = false;else if (this.currentTriggerMode === constants.AI_TRIGGER_MODES.QUESTION && suggestion.value.endsWith('?')) {
1843
1877
  this.showAIScreen = true;
1844
1878
  }
1845
1879
  },
@@ -2509,18 +2543,38 @@ var SearchBox = vue.defineComponent({
2509
2543
  var suggestionsHaveIcon = item.some(function (s) {
2510
2544
  return s.icon || s.iconURL;
2511
2545
  });
2512
- return renderItem ? vue.createVNode("li", vue.mergeProps(getItemProps({
2513
- item: sectionItem
2514
- }), _transformOn(getItemEvents({
2515
- item: sectionItem
2516
- })), {
2517
- "key": sectionItem._id + "_" + index + "_" + sectionIndex,
2518
- "style": {
2519
- justifyContent: 'flex-start',
2520
- alignItems: 'center'
2521
- },
2522
- "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
2523
- }), [renderItem(sectionItem)]) : vue.createVNode("li", vue.mergeProps(getItemProps({
2546
+ if (renderItem) {
2547
+ return vue.createVNode("li", vue.mergeProps(getItemProps({
2548
+ item: sectionItem
2549
+ }), _transformOn(getItemEvents({
2550
+ item: sectionItem
2551
+ })), {
2552
+ "key": sectionItem._id + "_" + index + "_" + sectionIndex,
2553
+ "style": {
2554
+ justifyContent: 'flex-start',
2555
+ alignItems: 'center'
2556
+ },
2557
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
2558
+ }), [renderItem(sectionItem)]);
2559
+ }
2560
+ if (sectionItem._suggestion_type === '_internal_a_i_trigger') {
2561
+ return vue.createVNode("li", vue.mergeProps(getItemProps({
2562
+ item: sectionItem
2563
+ }), _transformOn(getItemEvents({
2564
+ item: sectionItem
2565
+ })), {
2566
+ "key": sectionItem._id + "_" + index + "_" + sectionIndex,
2567
+ "style": {
2568
+ justifyContent: 'flex-start',
2569
+ alignItems: 'center'
2570
+ },
2571
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
2572
+ }), [vue.createVNode(SuggestionItem, {
2573
+ "currentValue": _this16.currentValue,
2574
+ "suggestion": sectionItem
2575
+ }, null)]);
2576
+ }
2577
+ return vue.createVNode("li", vue.mergeProps(getItemProps({
2524
2578
  item: sectionItem
2525
2579
  }), _transformOn(getItemEvents({
2526
2580
  item: sectionItem
@@ -2740,6 +2794,7 @@ SBConnected.install = function (Vue) {
2740
2794
  // Add componentType for SSR
2741
2795
  SBConnected.componentType = constants.componentTypes.searchBox;
2742
2796
 
2797
+ var _excluded$1 = ["_source"];
2743
2798
  function _isSlot$1(s) {
2744
2799
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
2745
2800
  }
@@ -2762,7 +2817,10 @@ var AIAnswer = vue.defineComponent({
2762
2817
  messages: [],
2763
2818
  inputMessage: '',
2764
2819
  AISessionId: '',
2765
- error: null
2820
+ error: null,
2821
+ sourceDocIds: null,
2822
+ initialHits: null,
2823
+ isTriggered: false
2766
2824
  };
2767
2825
  this.internalComponent = props.componentId + "__internal";
2768
2826
  return this.__state;
@@ -2772,7 +2830,16 @@ var AIAnswer = vue.defineComponent({
2772
2830
  from: 'theme_reactivesearch'
2773
2831
  }
2774
2832
  },
2775
- created: function created() {},
2833
+ created: function created() {
2834
+ if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.ALWAYS) {
2835
+ this.isTriggered = true;
2836
+ } else if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?')) {
2837
+ this.isTriggered = true;
2838
+ if (this.AISessionId) {
2839
+ this.handleSendMessage(null, false, '', true);
2840
+ }
2841
+ }
2842
+ },
2776
2843
  computed: {
2777
2844
  hasCustomRenderer: function hasCustomRenderer() {
2778
2845
  return index.hasCustomRenderer(this);
@@ -2785,6 +2852,9 @@ var AIAnswer = vue.defineComponent({
2785
2852
  },
2786
2853
  errorMessageForMissingSessionId: function errorMessageForMissingSessionId() {
2787
2854
  return "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.";
2855
+ },
2856
+ hasTriggered: function hasTriggered() {
2857
+ return this.isTriggered;
2788
2858
  }
2789
2859
  },
2790
2860
  props: {
@@ -2823,13 +2893,26 @@ var AIAnswer = vue.defineComponent({
2823
2893
  sessionIdFromStore: VueTypes.string,
2824
2894
  showComponent: vueTypes.types.boolRequired,
2825
2895
  componentError: vueTypes.types.componentObject,
2826
- style: vueTypes.types.style
2896
+ style: vueTypes.types.style,
2897
+ showSourceDocuments: VueTypes.bool.def(false),
2898
+ renderSourceDocument: vueTypes.types.func,
2899
+ onSourceClick: vueTypes.types.func,
2900
+ isAITyping: vueTypes.types.boolRequired,
2901
+ triggerOn: VueTypes.string.def(constants.AI_TRIGGER_MODES.ALWAYS),
2902
+ renderTriggerMessage: vueTypes.types.func
2827
2903
  },
2828
2904
  mounted: function mounted() {},
2829
2905
  watch: {
2830
2906
  AIResponse: function AIResponse(newVal) {
2831
2907
  if (newVal) {
2832
- this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2908
+ if (this.$props.showSourceDocuments && newVal.response && newVal.response.answer && Array.isArray(newVal.response.answer.documentIds)) {
2909
+ this.sourceDocIds = newVal.response.answer.documentIds;
2910
+ var localCache = helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) && helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY)[this.$props.componentId];
2911
+ if (localCache && localCache.meta && localCache.meta.hits) {
2912
+ this.initialHits = localCache.meta.hits;
2913
+ }
2914
+ }
2915
+ this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
2833
2916
  var messagesHistory = newVal.messages,
2834
2917
  response = newVal.response;
2835
2918
  var finalMessages = [];
@@ -2840,7 +2923,7 @@ var AIAnswer = vue.defineComponent({
2840
2923
  }
2841
2924
 
2842
2925
  // pushing message history so far
2843
- if (messagesHistory && messagesHistory && Array.isArray(messagesHistory)) {
2926
+ if (messagesHistory && Array.isArray(messagesHistory)) {
2844
2927
  finalMessages.push.apply(finalMessages, messagesHistory.filter(function (msg) {
2845
2928
  return msg.role !== constants.AI_ROLES.SYSTEM;
2846
2929
  }));
@@ -2865,6 +2948,9 @@ var AIAnswer = vue.defineComponent({
2865
2948
  loading: this.$props.isAIResponseLoading || this.$props.isLoading,
2866
2949
  error: this.$props.AIResponseError
2867
2950
  });
2951
+ if (newVal && newVal.hits && newVal.hits.hits) {
2952
+ this.initialHits = newVal.hits.hits;
2953
+ }
2868
2954
  },
2869
2955
  isAIResponseLoading: function isAIResponseLoading(newVal) {
2870
2956
  this.$emit('on-data', {
@@ -2889,7 +2975,7 @@ var AIAnswer = vue.defineComponent({
2889
2975
  },
2890
2976
  AIResponseError: function AIResponseError(newVal) {
2891
2977
  this.error = newVal;
2892
- this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2978
+ this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
2893
2979
  if (this.error && !this.AISessionId) {
2894
2980
  var errorMessage = this.errorMessageForMissingSessionId;
2895
2981
  this.error = {
@@ -2910,7 +2996,7 @@ var AIAnswer = vue.defineComponent({
2910
2996
  componentError: function componentError(newVal) {
2911
2997
  var _this = this;
2912
2998
  if (newVal && newVal._bodyBlob) {
2913
- this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2999
+ this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
2914
3000
  if (!this.AISessionId) {
2915
3001
  this.generateNewSessionId();
2916
3002
  }
@@ -2933,23 +3019,154 @@ var AIAnswer = vue.defineComponent({
2933
3019
  console.error('Error reading component error text data:', error);
2934
3020
  });
2935
3021
  }
3022
+ },
3023
+ showComponent: function showComponent() {
3024
+ if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && this.$props.dependentComponentValue.endsWith('?')) {
3025
+ this.isTriggered = true;
3026
+ }
3027
+ },
3028
+ dependentComponentValue: function dependentComponentValue(newVal) {
3029
+ if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && newVal && newVal.endsWith('?')) {
3030
+ this.isTriggered = true;
3031
+ if (this.AISessionId) {
3032
+ this.handleSendMessage(null, false, '', true);
3033
+ }
3034
+ } else if (this.hasTriggered && this.$props.triggerOn !== constants.AI_TRIGGER_MODES.ALWAYS) {
3035
+ this.isTriggered = false;
3036
+ }
3037
+ },
3038
+ AISessionId: function AISessionId(newVal) {
3039
+ if (newVal) {
3040
+ if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?') || this.$props.triggerOn === constants.AI_TRIGGER_MODES.ALWAYS) {
3041
+ this.handleSendMessage(null, false, '', true);
3042
+ }
3043
+ }
3044
+ },
3045
+ triggerOn: function triggerOn(newVal) {
3046
+ if (newVal === constants.AI_TRIGGER_MODES.ALWAYS) {
3047
+ this.isTriggered = true;
3048
+ }
2936
3049
  }
2937
3050
  },
2938
3051
  methods: {
2939
- generateNewSessionId: function generateNewSessionId() {
3052
+ renderTriggerMessageFunc: function renderTriggerMessageFunc() {
3053
+ var triggerOn = this.$props.triggerOn;
3054
+ if (this.$props.renderTriggerMessage) {
3055
+ return this.$props.renderTriggerMessage;
3056
+ }
3057
+ if (this.$slots.renderTriggerMessage) {
3058
+ return this.$slots.renderTriggerMessage();
3059
+ }
3060
+ if (triggerOn === constants.AI_TRIGGER_MODES.QUESTION) {
3061
+ if (!this.dependentComponentValue.endsWith('?')) {
3062
+ return vue.createVNode("span", null, [vue.createVNode("span", {
3063
+ "role": "img",
3064
+ "aria-label": "bulb"
3065
+ }, [vue.createTextVNode("\uD83D\uDCA1")]), vue.createTextVNode("End your question with a question mark (?)")]);
3066
+ }
3067
+ } else if (triggerOn === constants.AI_TRIGGER_MODES.MANUAL) {
3068
+ return vue.createVNode("span", null, [vue.createTextVNode("Click here to ask AI"), ' ', vue.createVNode("span", {
3069
+ "role": "img",
3070
+ "aria-label": "bulb"
3071
+ }, [vue.createTextVNode("\uD83E\uDD16")])]);
3072
+ }
3073
+ return null;
3074
+ },
3075
+ handleTriggerClick: function handleTriggerClick() {
3076
+ if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.MANUAL) {
3077
+ this.handleSendMessage(null, false, '', true);
3078
+ this.isTriggered = true;
3079
+ }
3080
+ },
3081
+ getAISourceObjects: function getAISourceObjects() {
2940
3082
  var _this2 = this;
3083
+ var sourceObjects = [];
3084
+ if (!this.AIResponse) return sourceObjects;
3085
+ var docIds = this.sourceDocIds || [];
3086
+ if (this.initialHits) {
3087
+ docIds.forEach(function (id) {
3088
+ var foundSourceObj = _this2.initialHits.find(function (hit) {
3089
+ return hit._id === id;
3090
+ }) || {};
3091
+ if (foundSourceObj) {
3092
+ var _foundSourceObj$_sour = foundSourceObj._source,
3093
+ _source = _foundSourceObj$_sour === void 0 ? {} : _foundSourceObj$_sour,
3094
+ rest = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(foundSourceObj, _excluded$1);
3095
+ sourceObjects.push(_rollupPluginBabelHelpers._extends({}, rest, _source));
3096
+ }
3097
+ });
3098
+ } else {
3099
+ sourceObjects.push.apply(sourceObjects, docIds.map(function (id) {
3100
+ return {
3101
+ _id: id
3102
+ };
3103
+ }));
3104
+ }
3105
+ return sourceObjects;
3106
+ },
3107
+ renderAIScreenFooter: function renderAIScreenFooter() {
3108
+ var _slot2;
3109
+ var _this3 = this;
3110
+ var _ref = this.$props || {},
3111
+ _ref$showSourceDocume = _ref.showSourceDocuments,
3112
+ showSourceDocuments = _ref$showSourceDocume === void 0 ? true : _ref$showSourceDocume,
3113
+ _ref$onSourceClick = _ref.onSourceClick,
3114
+ onSourceClick = _ref$onSourceClick === void 0 ? function () {} : _ref$onSourceClick,
3115
+ renderSourceDocument = _ref.renderSourceDocument;
3116
+ var customRenderSourceDoc = renderSourceDocument || this.$slots.renderSourceDocument;
3117
+ if (this.isLoadingState || this.isAITyping) {
3118
+ return null;
3119
+ }
3120
+ var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
3121
+ if (customRenderSourceDoc) {
3122
+ return customRenderSourceDoc(sourceObj);
3123
+ }
3124
+ return sourceObj._id;
3125
+ };
3126
+ return showSourceDocuments && Array.isArray(this.sourceDocIds) && this.sourceDocIds.length ? vue.createVNode(Footer, {
3127
+ "themePreset": this.$props.themePreset,
3128
+ "style": {
3129
+ marginTop: '1.5rem',
3130
+ background: 'inherit'
3131
+ }
3132
+ }, {
3133
+ "default": function _default() {
3134
+ return [vue.createTextVNode("Summary generated using the following sources:"), ' ', vue.createVNode(SourceTags, null, _isSlot$1(_slot2 = _this3.getAISourceObjects().map(function (el) {
3135
+ var _slot;
3136
+ return vue.createVNode(Button.Button, {
3137
+ "class": "--ai-source-tag " + (helper.getClassName(_this3.$props.innerClass, 'ai-source-tag') || ''),
3138
+ "info": true,
3139
+ "onClick": function onClick() {
3140
+ return onSourceClick && onSourceClick(el);
3141
+ },
3142
+ "key": el._id
3143
+ }, _isSlot$1(_slot = renderSourceDocumentLabel(el)) ? _slot : {
3144
+ "default": function _default() {
3145
+ return [_slot];
3146
+ }
3147
+ });
3148
+ })) ? _slot2 : {
3149
+ "default": function _default() {
3150
+ return [_slot2];
3151
+ }
3152
+ })];
3153
+ }
3154
+ }) : null;
3155
+ },
3156
+ generateNewSessionId: function generateNewSessionId() {
3157
+ var _this4 = this;
2941
3158
  var newSessionPromise = this.createAISession();
2942
3159
  newSessionPromise.then(function (res) {
2943
- _this2.AISessionId = res.AIsessionId;
3160
+ _this4.AISessionId = res.AIsessionId;
2944
3161
  })["catch"](function (e) {
2945
3162
  console.error(e);
2946
3163
  });
2947
3164
  },
2948
3165
  scrollToBottom: function scrollToBottom() {
2949
- var _this3 = this;
3166
+ var _this5 = this;
2950
3167
  this.$nextTick(function () {
2951
- var _this3$$refs;
2952
- var messageContainer = (_this3$$refs = _this3.$refs) == null ? void 0 : _this3$$refs[_this3.$props.innerRef];
3168
+ var _this5$$refs;
3169
+ var messageContainer = (_this5$$refs = _this5.$refs) == null ? void 0 : _this5$$refs[_this5.$props.innerRef];
2953
3170
  if (messageContainer && messageContainer.$el) {
2954
3171
  messageContainer.$el.scrollTo({
2955
3172
  top: messageContainer.$el.scrollHeight,
@@ -2962,24 +3179,33 @@ var AIAnswer = vue.defineComponent({
2962
3179
  this.inputMessage = e.target.value;
2963
3180
  this.handleTextAreaHeightChange();
2964
3181
  },
2965
- handleSendMessage: function handleSendMessage(e, isRetry, text) {
3182
+ handleSendMessage: function handleSendMessage(e, isRetry, text, fetchMeta) {
2966
3183
  if (isRetry === void 0) {
2967
3184
  isRetry = false;
2968
3185
  }
2969
3186
  if (text === void 0) {
2970
3187
  text = this.inputMessage;
2971
3188
  }
3189
+ if (fetchMeta === void 0) {
3190
+ fetchMeta = false;
3191
+ }
2972
3192
  if (typeof e === 'object' && e !== null) e.preventDefault();
2973
- if (text.trim()) {
3193
+ if (text.trim() || !text && !e) {
2974
3194
  if (this.isLoadingState) {
2975
3195
  return;
2976
3196
  }
2977
3197
  if (this.AISessionId) {
2978
- if (!isRetry) this.messages = [].concat(this.messages, [{
2979
- content: text,
2980
- role: constants.AI_ROLES.USER
2981
- }]);
2982
- this.getAIResponse(this.AISessionId, this.componentId, text);
3198
+ if (!isRetry) {
3199
+ var finalMessages = [].concat(this.messages);
3200
+ if (text) {
3201
+ finalMessages.push({
3202
+ content: text,
3203
+ role: constants.AI_ROLES.USER
3204
+ });
3205
+ }
3206
+ this.messages = [].concat(finalMessages);
3207
+ }
3208
+ this.getAIResponse(this.AISessionId, this.componentId, text, fetchMeta);
2983
3209
  } else {
2984
3210
  console.error(this.errorMessageForMissingSessionId);
2985
3211
  this.error = {
@@ -3028,7 +3254,6 @@ var AIAnswer = vue.defineComponent({
3028
3254
  return null;
3029
3255
  },
3030
3256
  handleKeyPress: function handleKeyPress(e) {
3031
- window.console.log('e', e);
3032
3257
  if (e.key === 'Enter') {
3033
3258
  this.handleSendMessage(e);
3034
3259
  this.inputMessage = '';
@@ -3060,15 +3285,15 @@ var AIAnswer = vue.defineComponent({
3060
3285
  if (typeof window === 'undefined') return false;
3061
3286
  return showVoiceSearch && (window.webkitSpeechRecognition || window.SpeechRecognition);
3062
3287
  },
3063
- handleVoiceResults: function handleVoiceResults(_ref) {
3064
- var results = _ref.results;
3288
+ handleVoiceResults: function handleVoiceResults(_ref2) {
3289
+ var results = _ref2.results;
3065
3290
  if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
3066
3291
  this.handleSendMessage(null, false, results[0][0].transcript.trim());
3067
3292
  }
3068
3293
  },
3069
3294
  renderIcons: function renderIcons() {
3070
- var _this4 = this;
3071
- var _slot, _slot2;
3295
+ var _this6 = this;
3296
+ var _slot3, _slot4;
3072
3297
  var _this$$props = this.$props,
3073
3298
  getMicInstance = _this$$props.getMicInstance,
3074
3299
  showVoiceInput = _this$$props.showVoiceInput,
@@ -3081,14 +3306,14 @@ var AIAnswer = vue.defineComponent({
3081
3306
  "positionType": "absolute"
3082
3307
  }, {
3083
3308
  "default": function _default() {
3084
- return [!_this4.isLoadingState && _this4.AISessionId && _this4.shouldMicRender(showVoiceInput) && vue.createVNode(Mic, {
3309
+ return [!_this6.isLoadingState && _this6.AISessionId && _this6.shouldMicRender(showVoiceInput) && vue.createVNode(Mic, {
3085
3310
  "getInstance": getMicInstance,
3086
3311
  "render": renderMic,
3087
- "handleResult": _this4.handleVoiceResults,
3312
+ "handleResult": _this6.handleVoiceResults,
3088
3313
  "class": helper.getClassName(innerClass, 'ai-search-mic') || null
3089
- }, null), iconPosition === 'right' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot = _this4.renderIcon()) ? _slot : {
3314
+ }, null), iconPosition === 'right' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot3 = _this6.renderIcon()) ? _slot3 : {
3090
3315
  "default": function _default() {
3091
- return [_slot];
3316
+ return [_slot3];
3092
3317
  }
3093
3318
  })];
3094
3319
  }
@@ -3098,9 +3323,9 @@ var AIAnswer = vue.defineComponent({
3098
3323
  "positionType": "absolute"
3099
3324
  }, {
3100
3325
  "default": function _default() {
3101
- return [iconPosition === 'left' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot2 = _this4.renderIcon()) ? _slot2 : {
3326
+ return [iconPosition === 'left' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot4 = _this6.renderIcon()) ? _slot4 : {
3102
3327
  "default": function _default() {
3103
- return [_slot2];
3328
+ return [_slot4];
3104
3329
  }
3105
3330
  })];
3106
3331
  }
@@ -3110,7 +3335,7 @@ var AIAnswer = vue.defineComponent({
3110
3335
  this.handleSendMessage(e);
3111
3336
  },
3112
3337
  renderEnterButtonElement: function renderEnterButtonElement() {
3113
- var _this5 = this;
3338
+ var _this7 = this;
3114
3339
  var _this$$props2 = this.$props,
3115
3340
  enterButton = _this$$props2.enterButton,
3116
3341
  innerClass = _this$$props2.innerClass;
@@ -3118,16 +3343,16 @@ var AIAnswer = vue.defineComponent({
3118
3343
  if (enterButton) {
3119
3344
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
3120
3345
  if (renderEnterButton) {
3121
- return renderEnterButton(_this5.enterButtonOnClick);
3346
+ return renderEnterButton(_this7.enterButtonOnClick);
3122
3347
  }
3123
3348
  return vue.createVNode(SendButton, {
3124
3349
  "primary": true,
3125
3350
  "type": "submit",
3126
3351
  "tabIndex": 0,
3127
- "onClick": _this5.handleSendMessage,
3128
- "onKeyPress": _this5.handleKeyPress,
3352
+ "onClick": _this7.handleSendMessage,
3353
+ "onKeyPress": _this7.handleKeyPress,
3129
3354
  "class": "ask-btn " + helper.getClassName(innerClass, 'ai-enter-button'),
3130
- "disabled": _this5.isLoadingState || !_this5.AISessionId
3355
+ "disabled": _this7.isLoadingState || !_this7.AISessionId
3131
3356
  }, {
3132
3357
  "default": function _default() {
3133
3358
  return [vue.createTextVNode("Send")];
@@ -3170,6 +3395,20 @@ var AIAnswer = vue.defineComponent({
3170
3395
  }
3171
3396
  this.$forceUpdate();
3172
3397
  }
3398
+ },
3399
+ getTitle: function getTitle() {
3400
+ var _this8 = this;
3401
+ var hasTitle = this.$props.title || this.$slots.title || null;
3402
+ if (hasTitle) {
3403
+ return vue.createVNode(Title.Title, {
3404
+ "class": helper.getClassName(this.$props.innerClass, 'ai-title') || null
3405
+ }, {
3406
+ "default": function _default() {
3407
+ return [_this8.$props.title || _this8.$slots.title()];
3408
+ }
3409
+ });
3410
+ }
3411
+ return null;
3173
3412
  }
3174
3413
  },
3175
3414
  beforeUnmount: function beforeUnmount() {
@@ -3184,55 +3423,62 @@ var AIAnswer = vue.defineComponent({
3184
3423
  }
3185
3424
  },
3186
3425
  render: function render() {
3187
- var _slot3;
3188
- var _this6 = this;
3426
+ var _slot5;
3427
+ var _this9 = this;
3189
3428
  var props = this.$props;
3190
3429
  if (!this.shouldShowComponent) {
3191
3430
  return null;
3192
3431
  }
3432
+ if (!this.isTriggered) {
3433
+ return vue.createVNode(Chatbox, {
3434
+ "style": props.style || {}
3435
+ }, {
3436
+ "default": function _default() {
3437
+ return [_this9.getTitle(), vue.createVNode("div", {
3438
+ "class": "--trigger-message-wrapper",
3439
+ "onClick": _this9.handleTriggerClick,
3440
+ "aria-hidden": "true"
3441
+ }, [_this9.renderTriggerMessageFunc()])];
3442
+ }
3443
+ });
3444
+ }
3193
3445
  return vue.createVNode(Chatbox, {
3194
3446
  "style": props.style || {}
3195
3447
  }, {
3196
3448
  "default": function _default() {
3197
- return [_this6.$props.title && vue.createVNode(Title.Title, {
3198
- "class": helper.getClassName(_this6.$props.innerClass, 'title') || ''
3199
- }, {
3200
- "default": function _default() {
3201
- return [_this6.$props.title];
3202
- }
3203
- }), vue.createVNode(ChatContainer, {
3449
+ return [_this9.getTitle(), vue.createVNode(ChatContainer, {
3204
3450
  "class": "--ai-chat-container",
3205
3451
  "theme": props.theme,
3206
3452
  "showInput": props.showInput
3207
3453
  }, {
3208
3454
  "default": function _default() {
3209
- return [_this6.hasCustomRenderer && vue.createVNode(MessagesContainer, {
3210
- "themePreset": _this6.themePreset,
3455
+ return [_this9.hasCustomRenderer && vue.createVNode(MessagesContainer, {
3456
+ "themePreset": _this9.themePreset,
3211
3457
  "theme": props.theme,
3212
- "ref": _this6.$props.innerRef,
3458
+ "ref": _this9.$props.innerRef,
3213
3459
  "class": "--ai-message-container " + (helper.getClassName(props.innerClass, 'ai-message-container') || '')
3214
- }, _isSlot$1(_slot3 = _this6.getComponent()) ? _slot3 : {
3460
+ }, _isSlot$1(_slot5 = _this9.getComponent()) ? _slot5 : {
3215
3461
  "default": function _default() {
3216
- return [_slot3];
3462
+ return [_slot5];
3217
3463
  }
3218
- }), !_this6.hasCustomRenderer && vue.createVNode(MessagesContainer, {
3219
- "themePreset": _this6.themePreset,
3464
+ }), !_this9.hasCustomRenderer && vue.createVNode(MessagesContainer, {
3465
+ "themePreset": _this9.themePreset,
3220
3466
  "theme": props.theme,
3221
- "ref": _this6.$props.innerRef,
3467
+ "ref": _this9.$props.innerRef,
3222
3468
  "class": "--ai-message-container " + (helper.getClassName(props.innerClass, 'ai-message-container') || '')
3223
3469
  }, {
3224
3470
  "default": function _default() {
3225
- return [_this6.messages.map(function (message, index) {
3471
+ return [_this9.messages.map(function (message, index) {
3226
3472
  return vue.createVNode(Message, {
3227
3473
  "key": index,
3228
3474
  "isSender": message.role === constants.AI_ROLES.USER,
3229
3475
  "innerHTML": md$1.render(message.content),
3230
- "themePreset": _this6.themePreset,
3476
+ "themePreset": _this9.themePreset,
3231
3477
  "theme": props.theme,
3232
3478
  "class": "--ai-answer-message " + (helper.getClassName(props.innerClass, 'ai-message') || '')
3233
3479
  }, null);
3234
- }), _this6.isLoadingState && vue.createVNode(Message, {
3235
- "themePreset": _this6.themePreset,
3480
+ }), _this9.isLoadingState && vue.createVNode(Message, {
3481
+ "themePreset": _this9.themePreset,
3236
3482
  "theme": props.theme,
3237
3483
  "isSender": false,
3238
3484
  "class": "--ai-answer-message " + (helper.getClassName(props.innerClass, 'ai-message') || null)
@@ -3241,31 +3487,31 @@ var AIAnswer = vue.defineComponent({
3241
3487
  return [vue.createVNode(TypingIndicator, null, {
3242
3488
  "default": function _default() {
3243
3489
  return [vue.createVNode(TypingDot, {
3244
- "themePreset": _this6.themePreset
3490
+ "themePreset": _this9.themePreset
3245
3491
  }, null), vue.createVNode(TypingDot, {
3246
- "themePreset": _this6.themePreset
3492
+ "themePreset": _this9.themePreset
3247
3493
  }, null), vue.createVNode(TypingDot, {
3248
- "themePreset": _this6.themePreset
3494
+ "themePreset": _this9.themePreset
3249
3495
  }, null)];
3250
3496
  }
3251
3497
  })];
3252
3498
  }
3253
3499
  })];
3254
3500
  }
3255
- }), _this6.renderErrorComponent(), ' ', props.showFeedback && vue.createVNode("div", {
3501
+ }), _this9.renderErrorComponent(), ' ', props.showFeedback && !_this9.isLoadingState && !_this9.isAITyping && vue.createVNode("div", {
3256
3502
  "class": "--ai-answer-feedback-container " + (helper.getClassName(props.innerClass, 'ai-feedback') || '')
3257
3503
  }, [vue.createVNode(AIFeedback, {
3258
- "hideUI": _this6.isLoadingState || !_this6.sessionId,
3259
- "key": _this6.sessionId,
3504
+ "hideUI": _this9.isLoadingState || !_this9.sessionId,
3505
+ "key": _this9.sessionId,
3260
3506
  "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
3261
- _this6.trackUsefullness(_this6.sessionId, {
3507
+ _this9.trackUsefullness(_this9.sessionId, {
3262
3508
  useful: useful,
3263
3509
  reason: reason
3264
3510
  });
3265
3511
  }
3266
- }, null)]), props.showInput && vue.createVNode(MessageInputContainer, {
3512
+ }, null)]), ' ', _this9.renderAIScreenFooter(), props.showInput && !_this9.isLoadingState && !_this9.isAITyping && vue.createVNode(MessageInputContainer, {
3267
3513
  "class": "--ai-input-container",
3268
- "onSubmit": _this6.handleSendMessage
3514
+ "onSubmit": _this9.handleSendMessage
3269
3515
  }, {
3270
3516
  "default": function _default() {
3271
3517
  return [vue.createVNode(InputGroup, {
@@ -3281,19 +3527,19 @@ var AIAnswer = vue.defineComponent({
3281
3527
  "ref": _inputRef,
3282
3528
  "placeholder": props.placeholder,
3283
3529
  "enterButton": props.enterButton,
3284
- "value": _this6.inputMessage,
3285
- "onInput": _this6.handleMessageInputChange,
3530
+ "value": _this9.inputMessage,
3531
+ "onInput": _this9.handleMessageInputChange,
3286
3532
  "id": props.componentId + "-ai-input",
3287
3533
  "showIcon": props.showIcon,
3288
3534
  "iconPosition": props.iconPosition,
3289
- "themePreset": _this6.themePreset,
3290
- "disabled": _this6.isLoadingState || !_this6.AISessionId,
3535
+ "themePreset": _this9.themePreset,
3536
+ "disabled": _this9.isLoadingState || !_this9.AISessionId,
3291
3537
  "class": helper.getClassName(props.innerClass, 'ai-input') || null
3292
- }, null), ' ', _this6.renderIcons()];
3538
+ }, null), ' ', _this9.renderIcons()];
3293
3539
  }
3294
3540
  })];
3295
3541
  }
3296
- }), _this6.renderEnterButtonElement()];
3542
+ }), _this9.renderEnterButtonElement()];
3297
3543
  }
3298
3544
  }), ' '];
3299
3545
  }
@@ -3311,9 +3557,11 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
3311
3557
  // eslint-disable-next-line prefer-destructuring
3312
3558
  dependencyComponent = dependencyComponent[0];
3313
3559
  }
3314
- var showComponent = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value;
3560
+ var showComponent = !!(state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value);
3561
+ var dependentComponentValue = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value || '';
3315
3562
  return {
3316
3563
  showComponent: showComponent,
3564
+ dependentComponentValue: dependentComponentValue,
3317
3565
  AIResponse: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response,
3318
3566
  isAIResponseLoading: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].isLoading,
3319
3567
  AIResponseError: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].error,
@@ -3321,11 +3569,17 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
3321
3569
  themePreset: state.config.themePreset,
3322
3570
  isLoading: state.isLoading[props.componentId] || false,
3323
3571
  sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
3324
- componentError: state.error[props.componentId]
3572
+ componentError: state.error[props.componentId] || null,
3573
+ isAITyping: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.isTyping || false
3325
3574
  };
3326
3575
  };
3327
3576
  var mapDispatchToProps$1 = {
3328
- getAIResponse: query.fetchAIResponse,
3577
+ getAIResponse: function getAIResponse(sessionId, componentId, message, shouldFetchMeta) {
3578
+ if (shouldFetchMeta === void 0) {
3579
+ shouldFetchMeta = false;
3580
+ }
3581
+ return query.fetchAIResponse(sessionId, componentId, message, null, shouldFetchMeta);
3582
+ },
3329
3583
  trackUsefullness: analytics.recordAISessionUsefulness,
3330
3584
  createAISession: query.createAISession
3331
3585
  };