@appbaseio/reactivesearch-vue 3.0.5 → 3.1.0-alpha

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.
@@ -1,10 +1,10 @@
1
1
  import { helper, Actions, causes } from '@appbaseio/reactivecore';
2
- import { SEARCH_COMPONENTS_MODES, AI_TRIGGER_MODES, AI_LOCAL_CACHE_KEY, componentTypes, AI_ROLES, TREELIST_VALUES_PATH_SEPARATOR } from '@appbaseio/reactivecore/lib/utils/constants';
2
+ import { SEARCH_COMPONENTS_MODES, AI_TRIGGER_MODES, componentTypes, AI_LOCAL_CACHE_KEY, AI_ROLES, TREELIST_VALUES_PATH_SEPARATOR } from '@appbaseio/reactivecore/lib/utils/constants';
3
3
  import _transformOn from '@vue/babel-helper-vue-transform-on';
4
4
  import { _ as _taggedTemplateLiteralLoose, a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-ded08042.js';
5
5
  import { createVNode, createTextVNode, defineComponent, ref, watch, isVNode, mergeProps, h } from 'vue';
6
6
  import VueTypes from 'vue-types';
7
- import { getObjectFromLocalStorage, getQueryOptions, featuredSuggestionsActionTypes, suggestionTypes, getClassName as getClassName$2, setObjectInLocalStorage, recLookup, updateCustomQuery as updateCustomQuery$1, updateDefaultQuery as updateDefaultQuery$1, transformTreeListLocalStateIntoQueryComptaibleFormat, isEqual as isEqual$1, transformRawTreeListData, setDeep, getComponent as getComponent$1, getOptionsFromQuery, checkValueChange as checkValueChange$1, getAggsQuery, updateInternalQuery, isFunction as isFunction$1 } from '@appbaseio/reactivecore/lib/utils/helper';
7
+ import { getQueryOptions, featuredSuggestionsActionTypes, suggestionTypes, getObjectFromLocalStorage, getClassName as getClassName$2, setObjectInLocalStorage, recLookup, updateCustomQuery as updateCustomQuery$1, updateDefaultQuery as updateDefaultQuery$1, transformTreeListLocalStateIntoQueryComptaibleFormat, isEqual as isEqual$1, transformRawTreeListData, setDeep, getComponent as getComponent$1, getOptionsFromQuery, checkValueChange as checkValueChange$1, getAggsQuery, updateInternalQuery, isFunction as isFunction$1 } from '@appbaseio/reactivecore/lib/utils/helper';
8
8
  import { styled } from '@appbaseio/vue-emotion';
9
9
  import { css, keyframes } from '@emotion/css';
10
10
  import { lighten } from 'polished';
@@ -23,8 +23,8 @@ import ReactiveBase from './ReactiveBase.js';
23
23
  import hotkeys from 'hotkeys-js';
24
24
  import xss from 'xss';
25
25
  import { Remarkable } from 'remarkable';
26
- import { I as IconWrapper, C as CancelSvg, a as IconGroup, B as ButtonIconWrapper, D as Downshift, b as InputWrapper } from './DropDown-6d1dddde.js';
27
- import { n as noSuggestions, T as TextArea, I as Input, s as suggestionsContainer, A as Actions$1, a as suggestions, b as searchboxSuggestions } from './Input-1f6207bc.js';
26
+ import { I as IconWrapper, C as CancelSvg, a as IconGroup, B as ButtonIconWrapper, D as Downshift, b as InputWrapper } from './DropDown-48045fde.js';
27
+ import { n as noSuggestions, T as TextArea, I as Input, s as suggestionsContainer, A as Actions$1, a as suggestions, b as searchboxSuggestions } from './Input-83dee8c5.js';
28
28
  import { C as Container } from './Container-d00219f7.js';
29
29
  import Highlight from 'vue-highlight-words';
30
30
  import { fetchAIResponse, createAISession } from '@appbaseio/reactivecore/lib/actions/query';
@@ -61,7 +61,7 @@ InputGroup.defaultProps = {
61
61
  };
62
62
 
63
63
  var _templateObject$1;
64
- var InputAddon = styled('span')(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: #fafafa;\n border: 1px solid transparent;\n border-radius: 6px;\n color: rgba(0, 0, 0, 0.85);\n font-size: 14px;\n font-weight: 400;\n padding: 0 11px;\n position: relative;\n transition: all 0.3s;\n box-sizing: border-box;\n overflow: hidden;\n\n &:first-of-type {\n border-right: none;\n }\n &:last-of-type {\n border-left: none;\n }\n"])));
64
+ var InputAddon = styled('span')(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: #fafafa;\n border: 1px solid #ccc;\n border-radius: 2px;\n color: rgba(0, 0, 0, 0.85);\n font-size: 14px;\n font-weight: 400;\n padding: 0 11px;\n position: relative;\n transition: all 0.3s;\n box-sizing: border-box;\n overflow: hidden;\n\n &:first-of-type {\n border-right: none;\n }\n &:last-of-type {\n border-left: none;\n }\n"])));
65
65
  InputAddon.defaultProps = {
66
66
  className: 'input-addon'
67
67
  };
@@ -97,7 +97,30 @@ var SuggestionItem = {
97
97
  name: 'SuggestionItem',
98
98
  props: {
99
99
  currentValue: types.string,
100
- suggestion: types.any
100
+ suggestion: types.any,
101
+ innerHTML: types.string.isRequired
102
+ },
103
+ data: function data() {
104
+ return {
105
+ isOverflowing: false
106
+ };
107
+ },
108
+ methods: {
109
+ updateOverflowing: function updateOverflowing() {
110
+ if (this.$refs.container && this.$refs.content) {
111
+ var _this$$refs = this.$refs,
112
+ container = _this$$refs.container,
113
+ content = _this$$refs.content;
114
+ var containerWidth = container.offsetWidth;
115
+ var contentWidth = content.scrollWidth;
116
+ this.isOverflowing = contentWidth > containerWidth;
117
+ } else {
118
+ this.isOverflowing = false;
119
+ }
120
+ }
121
+ },
122
+ mounted: function mounted() {
123
+ this.updateOverflowing();
101
124
  },
102
125
  render: function render() {
103
126
  var _this = this;
@@ -113,7 +136,11 @@ var SuggestionItem = {
113
136
  if (label) {
114
137
  // label has highest precedence
115
138
  return typeof label === 'string' ? createVNode("div", {
116
- "class": "trim"
139
+ "ref": "container",
140
+ "class": "trim",
141
+ "title": this.isOverflowing ? label : ''
142
+ }, [createVNode("div", {
143
+ "ref": "content"
117
144
  }, [(_category ? false : isPredictiveSuggestion
118
145
  // eslint-disable-next-line
119
146
  || !!_suggestion_type) ? createVNode(PredictiveSuggestion, {
@@ -123,7 +150,7 @@ var SuggestionItem = {
123
150
  "textToHighlight": label,
124
151
  "autoEscape": true,
125
152
  "highlightStyle": highlightStyle
126
- }, null)]) : label;
153
+ }, null)])]) : label;
127
154
  }
128
155
  if (title || image || description) {
129
156
  return createVNode(Flex, {
@@ -805,7 +832,7 @@ var HorizontalSkeletonLoader = defineComponent({
805
832
 
806
833
  var _templateObject$7, _templateObject2$2, _templateObject3$1, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
807
834
  var Chatbox = styled('div')(_templateObject$7 || (_templateObject$7 = _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) {
808
- return props.theme && props.theme.colors && props.theme.colors.backgroundColor ? lighten(0.1, props.theme.colors.backgroundColor) : '#fff';
835
+ return props.theme && props.theme.colors ? props.theme.colors.backgroundColor : '#fff';
809
836
  });
810
837
  var ChatContainer = styled('div')(_templateObject2$2 || (_templateObject2$2 = _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) {
811
838
  return props.showInput ? 'bottom: 48px;' : '';
@@ -837,7 +864,7 @@ var resetCSS = function resetCSS(props) {
837
864
  // eslint-disable-next-line no-nested-ternary
838
865
  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: " + (
839
866
  // 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\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\n\t" + (props.themePreset === 'dark' && "a{\n\t\tcolor: cornflowerblue\n\t\t}") + ";\n";
867
+ 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
868
  };
842
869
  var messageBGColor = function messageBGColor(props) {
843
870
  var finalBGColor;
@@ -866,10 +893,16 @@ var Message = styled('div')(_templateObject7 || (_templateObject7 = _taggedTempl
866
893
  return resetCSS(props);
867
894
  });
868
895
  var MessageInputContainer = styled('form')(_templateObject8 || (_templateObject8 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tpadding-top: 12px;\n\talign-items: stretch;\n\tmargin-top: 10px;\n\t.ai-enter-button-wrapper {\n\t\talign-self: baseline;\n\t\theight: 41px;\n\t}\n"])));
869
- var MessageInput = styled(TextArea)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tborder-radius: 5px;\n\tborder: 1px solid #ccc;\n\tbackground-color: ", ";\n\tcolor: ", ";\n\n\t", "\n\tpadding-left: 35px;\n"])), function (props) {
896
+ var MessageInput = styled(TextArea)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tborder-radius: 5px;\n\tborder: 1px solid #ccc;\n\tbackground-color: ", ";\n\tcolor: ", ";\n\n\t::placeholder {\n\t\tcolor: ", ";\n\t}\n\n\t:-ms-input-placeholder {\n\t\tcolor: ", ";\n\t}\n\n\t::-ms-input-placeholder {\n\t\tcolor: ", ";\n\t}\n\t", "\n\tpadding-left: 35px;\n"])), function (props) {
870
897
  return props.themePreset === 'dark' ? props.theme.colors.borderColor : '#fff';
871
898
  }, function (props) {
872
899
  return props.themePreset === 'dark' ? props.theme.colors.titleColor : props.theme.colors.textColor;
900
+ }, function (props) {
901
+ return props.theme.colors.textColor;
902
+ }, function (props) {
903
+ return props.theme.colors.textColor;
904
+ }, function (props) {
905
+ return props.theme.colors.textColor;
873
906
  }, function (_ref) {
874
907
  var enterButton = _ref.enterButton;
875
908
  return enterButton && "\n\t\t border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n\t";
@@ -1074,6 +1107,42 @@ var AIFeedback = defineComponent({
1074
1107
  }
1075
1108
  });
1076
1109
 
1110
+ // eslint-disable-next-line import/prefer-default-export
1111
+ var innerText = function innerText(jsx) {
1112
+ // Empty
1113
+ if (jsx === null || typeof jsx === 'boolean' || typeof jsx === 'undefined') {
1114
+ return '';
1115
+ }
1116
+
1117
+ // Numeric children.
1118
+ if (typeof jsx === 'number') {
1119
+ return jsx.toString();
1120
+ }
1121
+
1122
+ // String literals.
1123
+ if (typeof jsx === 'string') {
1124
+ return jsx;
1125
+ }
1126
+
1127
+ // Array of JSX.
1128
+ if (Array.isArray(jsx)) {
1129
+ // eslint-disable-next-line no-use-before-define
1130
+ return jsx.reduce(reduceJsxToString, '');
1131
+ }
1132
+
1133
+ // Children prop.
1134
+ if (Object.prototype.hasOwnProperty.call(jsx, 'children')) {
1135
+ return innerText(jsx.children);
1136
+ }
1137
+
1138
+ // Default
1139
+ return '';
1140
+ };
1141
+ innerText["default"] = innerText;
1142
+ function reduceJsxToString(previous, current) {
1143
+ return previous + innerText(current);
1144
+ }
1145
+
1077
1146
  var _excluded = ["_source"];
1078
1147
  function _isSlot(s) {
1079
1148
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
@@ -1114,8 +1183,7 @@ var SearchBox = defineComponent({
1114
1183
  showFeedbackComponent: false,
1115
1184
  feedbackState: null,
1116
1185
  faqAnswer: '',
1117
- faqQuestion: '',
1118
- initialHits: null
1186
+ faqQuestion: ''
1119
1187
  };
1120
1188
  this.internalComponent = props.componentId + "__internal";
1121
1189
  return this.__state;
@@ -1167,11 +1235,12 @@ var SearchBox = defineComponent({
1167
1235
  return this.faqAnswer || this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text;
1168
1236
  },
1169
1237
  parsedSuggestions: function parsedSuggestions() {
1238
+ var _this = this;
1170
1239
  var suggestionsArray = [];
1171
1240
  if (Array.isArray(this.suggestions) && this.suggestions.length) {
1172
1241
  suggestionsArray = [].concat(withClickIds(this.suggestions));
1173
1242
  }
1174
- if (this.renderTriggerMessage() && this.currentValue) {
1243
+ if (this.renderTriggerMessage() && this.currentValue && !this.isLoading) {
1175
1244
  suggestionsArray.unshift({
1176
1245
  label: this.renderTriggerMessage(),
1177
1246
  value: 'AI_TRIGGER_MESSAGE',
@@ -1185,6 +1254,20 @@ var SearchBox = defineComponent({
1185
1254
  return _extends({}, s, {
1186
1255
  sectionId: s._suggestion_type
1187
1256
  });
1257
+ }).map(function (suggestion) {
1258
+ if (suggestion._suggestion_type === 'document') {
1259
+ // Document suggestions don't have a meaningful label and value
1260
+ var newSuggestion = _extends({}, suggestion);
1261
+ newSuggestion.label = 'For recent document suggestion, please implement a renderItem method to display label.';
1262
+ var renderItem = _this.$slots.renderItem || _this.$props.renderItem;
1263
+ if (typeof renderItem === 'function') {
1264
+ var jsxEl = renderItem(newSuggestion);
1265
+ var innerValue = innerText(jsxEl);
1266
+ newSuggestion.value = xss(innerValue);
1267
+ }
1268
+ return newSuggestion;
1269
+ }
1270
+ return suggestion;
1188
1271
  });
1189
1272
  var sectionsAccumulated = [];
1190
1273
  var sectionisedSuggestions = suggestionsArray.reduce(function (acc, d, currentIndex) {
@@ -1233,6 +1316,12 @@ var SearchBox = defineComponent({
1233
1316
  enablePopularSuggestions: VueTypes.bool.def(false),
1234
1317
  enableRecentSuggestions: VueTypes.bool.def(false),
1235
1318
  enableFAQSuggestions: VueTypes.bool.def(false),
1319
+ enableDocumentSuggestions: VueTypes.bool.def(false),
1320
+ documentSuggestionsConfig: VueTypes.shape({
1321
+ size: VueTypes.number,
1322
+ from: VueTypes.number,
1323
+ maxChars: VueTypes.number
1324
+ }),
1236
1325
  FAQSuggestionsConfig: VueTypes.shape({
1237
1326
  sectionLabel: VueTypes.string,
1238
1327
  size: VueTypes.number
@@ -1301,47 +1390,9 @@ var SearchBox = defineComponent({
1301
1390
  AIUIConfig: types.AIUIConfig
1302
1391
  },
1303
1392
  mounted: function mounted() {
1304
- var _this = this;
1305
1393
  this.listenForFocusShortcuts();
1306
- var dropdownEle = this.$refs[_dropdownULRef];
1307
- if (dropdownEle) {
1308
- var handleScroll = function handleScroll() {
1309
- var scrollTop = dropdownEle.scrollTop;
1310
- _this.lastScrollTop = scrollTop;
1311
- if (scrollTop < _this.lastScrollTop) {
1312
- // User is scrolling up
1313
- clearInterval(_this.scrollTimerRef);
1314
- _this.isUserScrolling = true;
1315
- }
1316
- // Update lastScrollTop with the current scroll position
1317
- _this.lastScrollTop = scrollTop;
1318
- };
1319
- dropdownEle.addEventListener('scroll', handleScroll);
1320
- }
1321
- },
1322
- updated: function updated() {
1323
- if (this.$props.mode === SEARCH_COMPONENTS_MODES.SELECT && this.$options.isTagsMode === true) {
1324
- this.$options.isTagsMode = false;
1325
- this.selectedTags = [];
1326
- } else if (this.$props.mode === SEARCH_COMPONENTS_MODES.TAG && this.$options.isTagsMode === false) {
1327
- this.$options.isTagsMode = true;
1328
- }
1329
1394
  },
1330
1395
  watch: {
1331
- AIResponse: function AIResponse(newVal) {
1332
- if (newVal) {
1333
- if (this.$props.AIUIConfig && this.$props.AIUIConfig.showSourceDocuments && newVal.response && newVal.response.answer && Array.isArray(newVal.response.answer.documentIds)) {
1334
- this.sourceDocIds = newVal.response.answer.documentIds;
1335
- var localCache = getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) && getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY)[this.$props.componentId];
1336
- if (localCache && localCache.meta && localCache.meta.hits && localCache.meta.hits.hits) {
1337
- this.initialHits = localCache.meta.hits.hits;
1338
- }
1339
- if (!this.showAIScreenFooter) {
1340
- this.showAIScreenFooter = true;
1341
- }
1342
- }
1343
- }
1344
- },
1345
1396
  dataField: function dataField(newVal, oldVal) {
1346
1397
  if (!isEqual(newVal, oldVal)) {
1347
1398
  this.triggerCustomQuery(this.$data.currentValue);
@@ -1416,9 +1467,6 @@ var SearchBox = defineComponent({
1416
1467
  loading: this.isLoading,
1417
1468
  error: this.isError
1418
1469
  });
1419
- if (newVal && newVal.hits && newVal.hits.hits) {
1420
- this.initialHits = newVal.hits.hits;
1421
- }
1422
1470
  },
1423
1471
  aggregationData: function aggregationData(newVal) {
1424
1472
  this.$emit('on-data', {
@@ -1455,7 +1503,6 @@ var SearchBox = defineComponent({
1455
1503
  isAITyping: function isAITyping(newVal, oldVal) {
1456
1504
  var _this2 = this;
1457
1505
  var scrollAIContainer = function scrollAIContainer() {
1458
- if (_this2.isUserScrolling) return;
1459
1506
  var dropdownEle = _this2.$refs[_dropdownULRef];
1460
1507
  if (dropdownEle) {
1461
1508
  dropdownEle.scrollTo({
@@ -1465,7 +1512,6 @@ var SearchBox = defineComponent({
1465
1512
  }
1466
1513
  };
1467
1514
  if (!newVal && oldVal) {
1468
- clearInterval(this.scrollTimerRef);
1469
1515
  this.showAIScreenFooter = true;
1470
1516
  if (this.$props.AIUIConfig && typeof this.$props.AIUIConfig.showFeedback === 'boolean' ? this.$props.AIUIConfig.showFeedback : true) {
1471
1517
  this.showFeedbackComponent = true;
@@ -1474,7 +1520,7 @@ var SearchBox = defineComponent({
1474
1520
  scrollAIContainer();
1475
1521
  }, 500);
1476
1522
  } else if (newVal) {
1477
- this.scrollTimerRef = setInterval(function () {
1523
+ this.scrollTimerRef = setTimeout(function () {
1478
1524
  scrollAIContainer();
1479
1525
  }, 2000);
1480
1526
  }
@@ -1491,7 +1537,7 @@ var SearchBox = defineComponent({
1491
1537
  }
1492
1538
  },
1493
1539
  currentValue: function currentValue() {
1494
- this.$nextTick(this.handleTextAreaHeightChange);
1540
+ this.handleTextAreaHeightChange();
1495
1541
  }
1496
1542
  },
1497
1543
  methods: {
@@ -2293,13 +2339,13 @@ var SearchBox = defineComponent({
2293
2339
  });
2294
2340
  },
2295
2341
  getAISourceObjects: function getAISourceObjects() {
2296
- var _this14 = this;
2342
+ var localCache = getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) && getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY)[this.componentId];
2297
2343
  var sourceObjects = [];
2298
2344
  if (!this.AIResponse) return sourceObjects;
2299
2345
  var docIds = this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [];
2300
- if (this.initialHits) {
2346
+ if (localCache && localCache.meta && localCache.meta.hits && localCache.meta.hits.hits) {
2301
2347
  docIds.forEach(function (id) {
2302
- var foundSourceObj = _this14.initialHits.find(function (hit) {
2348
+ var foundSourceObj = localCache.meta.hits.hits.find(function (hit) {
2303
2349
  return hit._id === id;
2304
2350
  }) || {};
2305
2351
  if (foundSourceObj) {
@@ -2333,20 +2379,20 @@ var SearchBox = defineComponent({
2333
2379
  },
2334
2380
  renderAIScreenFooter: function renderAIScreenFooter() {
2335
2381
  var _slot8;
2336
- var _this15 = this;
2382
+ var _this14 = this;
2337
2383
  var _this$$props$AIUIConf2 = this.$props.AIUIConfig,
2338
2384
  AIUIConfig = _this$$props$AIUIConf2 === void 0 ? {} : _this$$props$AIUIConf2;
2339
2385
  var _ref6 = AIUIConfig || {},
2340
2386
  _ref6$showSourceDocum = _ref6.showSourceDocuments,
2341
- showSourceDocuments = _ref6$showSourceDocum === void 0 ? false : _ref6$showSourceDocum,
2387
+ showSourceDocuments = _ref6$showSourceDocum === void 0 ? true : _ref6$showSourceDocum,
2342
2388
  _ref6$onSourceClick = _ref6.onSourceClick,
2343
2389
  onSourceClick = _ref6$onSourceClick === void 0 ? function () {} : _ref6$onSourceClick;
2344
2390
  var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
2345
- if (_this15.$props.AIUIConfig && _this15.$props.AIUIConfig.renderSourceDocument) {
2346
- return _this15.$props.AIUIConfig.renderSourceDocument(sourceObj);
2391
+ if (_this14.$props.AIUIConfig && _this14.$props.AIUIConfig.renderSourceDocument) {
2392
+ return _this14.$props.AIUIConfig.renderSourceDocument(sourceObj);
2347
2393
  }
2348
- if (_this15.$slots.renderSourceDocument) {
2349
- return _this15.$slots.renderSourceDocument(sourceObj);
2394
+ if (_this14.$slots.renderSourceDocument) {
2395
+ return _this14.$slots.renderSourceDocument(sourceObj);
2350
2396
  }
2351
2397
  return sourceObj._id;
2352
2398
  };
@@ -2354,10 +2400,10 @@ var SearchBox = defineComponent({
2354
2400
  "themePreset": this.$props.themePreset
2355
2401
  }, {
2356
2402
  "default": function _default() {
2357
- return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot(_slot8 = _this15.getAISourceObjects().map(function (el) {
2403
+ return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot(_slot8 = _this14.getAISourceObjects().map(function (el) {
2358
2404
  var _slot7;
2359
2405
  return createVNode(Button, {
2360
- "class": "--ai-source-tag " + (getClassName$1(_this15.$props.innerClass, 'ai-source-tag') || ''),
2406
+ "class": "--ai-source-tag " + (getClassName$1(_this14.$props.innerClass, 'ai-source-tag') || ''),
2361
2407
  "info": true,
2362
2408
  "onClick": function onClick() {
2363
2409
  return onSourceClick && onSourceClick(el);
@@ -2376,7 +2422,7 @@ var SearchBox = defineComponent({
2376
2422
  }) : null;
2377
2423
  },
2378
2424
  renderAIScreen: function renderAIScreen() {
2379
- var _this16 = this;
2425
+ var _this15 = this;
2380
2426
  var customAIRenderer = this.$props.renderAIAnswer || this.$slots.renderAIAnswer;
2381
2427
  if (customAIRenderer) {
2382
2428
  return customAIRenderer({
@@ -2400,11 +2446,11 @@ var SearchBox = defineComponent({
2400
2446
  "hideUI": this.isAIResponseLoading || this.isLoading || !this.sessionIdFromStore,
2401
2447
  "key": this.sessionIdFromStore,
2402
2448
  "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
2403
- _this16.feedbackState = {
2449
+ _this15.feedbackState = {
2404
2450
  isRecorded: true,
2405
2451
  feedbackType: useful ? 'positive' : 'negative'
2406
2452
  };
2407
- _this16.recordAISessionUsefulness(_this16.sessionIdFromStore, {
2453
+ _this15.recordAISessionUsefulness(_this15.sessionIdFromStore, {
2408
2454
  useful: useful,
2409
2455
  reason: reason
2410
2456
  });
@@ -2439,7 +2485,7 @@ var SearchBox = defineComponent({
2439
2485
  });
2440
2486
  },
2441
2487
  renderAskButtonElement: function renderAskButtonElement() {
2442
- var _this17 = this;
2488
+ var _this16 = this;
2443
2489
  var _this$$props5 = this.$props,
2444
2490
  AIUIConfig = _this$$props5.AIUIConfig,
2445
2491
  innerClass = _this$$props5.innerClass;
@@ -2449,12 +2495,12 @@ var SearchBox = defineComponent({
2449
2495
  if (askButton) {
2450
2496
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
2451
2497
  if (renderAskButton) {
2452
- return renderAskButton(_this17.askButtonOnClick);
2498
+ return renderAskButton(_this16.askButtonOnClick);
2453
2499
  }
2454
2500
  return createVNode(Button, {
2455
2501
  "class": "enter-btn " + getClassName$1(innerClass, 'ask-button'),
2456
2502
  "info": true,
2457
- "onClick": _this17.askButtonOnClick
2503
+ "onClick": _this16.askButtonOnClick
2458
2504
  }, {
2459
2505
  "default": function _default() {
2460
2506
  return [createTextVNode("Ask")];
@@ -2469,28 +2515,28 @@ var SearchBox = defineComponent({
2469
2515
  }
2470
2516
  },
2471
2517
  render: function render() {
2472
- var _this18 = this;
2518
+ var _this17 = this;
2473
2519
  var expandSuggestionsContainer = this.$props.expandSuggestionsContainer;
2474
2520
  var _this$$slots = this.$slots,
2475
2521
  recentSearchesIcon = _this$$slots.recentSearchesIcon,
2476
2522
  popularSearchesIcon = _this$$slots.popularSearchesIcon;
2477
- var hasSuggestions = Array.isArray(this.parsedSuggestions) && this.parsedSuggestions.length;
2523
+ var hasSuggestions = Array.isArray(this.normalizedSuggestions) && this.normalizedSuggestions.length;
2478
2524
  var renderItem = this.$slots.renderItem || this.$props.renderItem;
2479
2525
  return createVNode(Container, {
2480
2526
  "class": this.$props.className
2481
2527
  }, {
2482
2528
  "default": function _default() {
2483
- return [_this18.$props.title && createVNode(Title, {
2484
- "class": getClassName$1(_this18.$props.innerClass, 'title') || ''
2529
+ return [_this17.$props.title && createVNode(Title, {
2530
+ "class": getClassName$1(_this17.$props.innerClass, 'title') || ''
2485
2531
  }, {
2486
2532
  "default": function _default() {
2487
- return [_this18.$props.title];
2533
+ return [_this17.$props.title];
2488
2534
  }
2489
- }), _this18.$props.autosuggest ? createVNode(Downshift, {
2490
- "id": _this18.$props.componentId + "-downshift",
2491
- "handleChange": _this18.onSuggestionSelected,
2492
- "handleMouseup": _this18.handleStateChange,
2493
- "isOpen": _this18.$data.isOpen
2535
+ }), _this17.$props.autosuggest ? createVNode(Downshift, {
2536
+ "id": _this17.$props.componentId + "-downshift",
2537
+ "handleChange": _this17.onSuggestionSelected,
2538
+ "handleMouseup": _this17.handleStateChange,
2539
+ "isOpen": _this17.$data.isOpen
2494
2540
  }, {
2495
2541
  "default": function _default(_ref8) {
2496
2542
  var getInputEvents = _ref8.getInputEvents,
@@ -2546,21 +2592,21 @@ var SearchBox = defineComponent({
2546
2592
  }
2547
2593
  };
2548
2594
  var indexOffset = 0;
2549
- return createVNode("div", null, [_this18.hasCustomRenderer && _this18.getComponent({
2595
+ return createVNode("div", null, [_this17.hasCustomRenderer && _this17.getComponent({
2550
2596
  isOpen: isOpen,
2551
2597
  getItemProps: getItemProps,
2552
2598
  getItemEvents: getItemEvents,
2553
2599
  highlightedIndex: highlightedIndex
2554
- }), _this18.renderErrorComponent(), !_this18.hasCustomRenderer && isOpen && hasSuggestions ? createVNode("ul", {
2555
- "class": suggestions(_this18.themePreset, _this18.theme) + " " + getClassName$1(_this18.$props.innerClass, 'list') + " " + searchboxSuggestions(_this18.themePreset, _this18.theme) + "\n\t\t\t\t\t\t\t\t\t\t\t\t\t",
2600
+ }), _this17.renderErrorComponent(), !_this17.hasCustomRenderer && isOpen && hasSuggestions ? createVNode("ul", {
2601
+ "class": suggestions(_this17.themePreset, _this17.theme) + " " + getClassName$1(_this17.$props.innerClass, 'list') + " " + searchboxSuggestions(_this17.themePreset, _this17.theme) + "\n\t\t\t\t\t\t\t\t\t\t\t\t\t",
2556
2602
  "ref": _dropdownULRef
2557
- }, [_this18.showAIScreen && createVNode(SearchBoxAISection, {
2558
- "themePreset": _this18.$props.themePreset
2603
+ }, [_this17.showAIScreen && createVNode(SearchBoxAISection, {
2604
+ "themePreset": _this17.$props.themePreset
2559
2605
  }, {
2560
2606
  "default": function _default() {
2561
- return [_this18.renderAIScreen(), ' ', _this18.renderErrorComponent(true)];
2607
+ return [_this17.renderAIScreen(), ' ', _this17.renderErrorComponent(true)];
2562
2608
  }
2563
- }), !_this18.showAIScreen && _this18.parsedSuggestions.map(function (item, itemIndex) {
2609
+ }), !_this17.showAIScreen && _this17.parsedSuggestions.map(function (item, itemIndex) {
2564
2610
  var index = indexOffset + itemIndex;
2565
2611
  if (Array.isArray(item)) {
2566
2612
  var sectionHtml = xss(item[0].sectionLabel);
@@ -2569,7 +2615,7 @@ var SearchBox = defineComponent({
2569
2615
  "key": "section-" + itemIndex,
2570
2616
  "class": "section-container"
2571
2617
  }, [sectionHtml ? createVNode("div", {
2572
- "class": "section-header " + getClassName$1(_this18.$props.innerClass, 'section-label'),
2618
+ "class": "section-header " + getClassName$1(_this17.$props.innerClass, 'section-label'),
2573
2619
  "key": "" + item[0].sectionId,
2574
2620
  "innerHTML": sectionHtml
2575
2621
  }, null) : null, createVNode("ul", {
@@ -2589,7 +2635,7 @@ var SearchBox = defineComponent({
2589
2635
  justifyContent: 'flex-start',
2590
2636
  alignItems: 'center'
2591
2637
  },
2592
- "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this18.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this18.$props.innerClass, 'suggestion-item'))
2638
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this17.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this17.$props.innerClass, 'suggestion-item'))
2593
2639
  }), [renderItem(sectionItem)]);
2594
2640
  }
2595
2641
  if (sectionItem._suggestion_type === '_internal_a_i_trigger') {
@@ -2603,9 +2649,9 @@ var SearchBox = defineComponent({
2603
2649
  justifyContent: 'flex-start',
2604
2650
  alignItems: 'center'
2605
2651
  },
2606
- "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this18.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this18.$props.innerClass, 'suggestion-item'))
2652
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this17.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this17.$props.innerClass, 'suggestion-item'))
2607
2653
  }), [createVNode(SuggestionItem, {
2608
- "currentValue": _this18.currentValue,
2654
+ "currentValue": _this17.currentValue,
2609
2655
  "suggestion": sectionItem
2610
2656
  }, null)]);
2611
2657
  }
@@ -2619,7 +2665,7 @@ var SearchBox = defineComponent({
2619
2665
  justifyContent: 'flex-start',
2620
2666
  alignItems: 'center'
2621
2667
  },
2622
- "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this18.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this18.$props.innerClass, 'suggestion-item'))
2668
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this17.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this17.$props.innerClass, 'suggestion-item'))
2623
2669
  }), [createVNode("div", {
2624
2670
  "style": {
2625
2671
  padding: '0 10px 0 0',
@@ -2627,74 +2673,74 @@ var SearchBox = defineComponent({
2627
2673
  }
2628
2674
  }, [createVNode(CustomSvg, {
2629
2675
  "key": sectionItem._suggestion_type + "-" + sectionIndex,
2630
- "className": getClassName$1(_this18.$props.innerClass, sectionItem._suggestion_type + "-search-icon") || null,
2676
+ "className": getClassName$1(_this17.$props.innerClass, sectionItem._suggestion_type + "-search-icon") || null,
2631
2677
  "icon": getIcon(sectionItem._suggestion_type, sectionItem, suggestionsHaveIcon),
2632
2678
  "type": sectionItem._suggestion_type + "-search-icon"
2633
2679
  }, null)]), createVNode(SuggestionItem, {
2634
- "currentValue": _this18.currentValue,
2680
+ "currentValue": _this17.currentValue,
2635
2681
  "suggestion": sectionItem
2636
- }, null), _this18.renderActionIcon(sectionItem)]);
2682
+ }, null), _this17.renderActionIcon(sectionItem)]);
2637
2683
  })])]);
2638
2684
  }
2639
2685
  return createVNode("div", null, [createTextVNode("No suggestions")]);
2640
- }), !_this18.showAIScreen && _this18.parsedSuggestions.length && _this18.$props.showSuggestionsFooter ? _this18.suggestionsFooter() : null]) : _this18.renderNoSuggestions(_this18.normalizedSuggestions)]);
2686
+ }), !_this17.showAIScreen && _this17.parsedSuggestions.length && _this17.$props.showSuggestionsFooter ? _this17.suggestionsFooter() : null]) : _this17.renderNoSuggestions(_this17.normalizedSuggestions)]);
2641
2687
  };
2642
2688
  return createVNode("div", {
2643
2689
  "class": suggestionsContainer
2644
2690
  }, [createVNode(InputGroup, {
2645
2691
  "searchBox": true,
2646
2692
  "ref": _inputGroupRef,
2647
- "isOpen": _this18.$data.isOpen
2693
+ "isOpen": _this17.$data.isOpen
2648
2694
  }, {
2649
2695
  "default": function _default() {
2650
2696
  return [createVNode(Actions$1, null, {
2651
2697
  "default": function _default() {
2652
- return [_this18.renderInputAddonBefore(), _this18.renderLeftIcons()];
2698
+ return [_this17.renderInputAddonBefore(), _this17.renderLeftIcons()];
2653
2699
  }
2654
2700
  }), createVNode(InputWrapper, null, {
2655
2701
  "default": function _default() {
2656
2702
  return [createVNode(TextArea, mergeProps(_transformOn(getInputEvents({
2657
- onInput: _this18.onInputChange,
2703
+ onInput: _this17.onInputChange,
2658
2704
  onBlur: function onBlur(e) {
2659
- _this18.$emit('blur', e, _this18.triggerQuery);
2705
+ _this17.$emit('blur', e, _this17.triggerQuery);
2660
2706
  },
2661
- onFocus: _this18.handleFocus,
2707
+ onFocus: _this17.handleFocus,
2662
2708
  onKeyPress: function onKeyPress(e) {
2663
- _this18.$emit('keyPress', e, _this18.triggerQuery);
2664
- _this18.$emit('key-press', e, _this18.triggerQuery);
2709
+ _this17.$emit('keyPress', e, _this17.triggerQuery);
2710
+ _this17.$emit('key-press', e, _this17.triggerQuery);
2665
2711
  },
2666
2712
  onKeyDown: function onKeyDown(e) {
2667
- return _this18.handleKeyDown(e, highlightedIndex);
2713
+ return _this17.handleKeyDown(e, highlightedIndex);
2668
2714
  },
2669
2715
  onKeyUp: function onKeyUp(e) {
2670
- _this18.$emit('keyUp', e, _this18.triggerQuery);
2671
- _this18.$emit('key-up', e, _this18.triggerQuery);
2716
+ _this17.$emit('keyUp', e, _this17.triggerQuery);
2717
+ _this17.$emit('key-up', e, _this17.triggerQuery);
2672
2718
  },
2673
2719
  onClick: function onClick() {
2674
2720
  setHighlightedIndex(null);
2675
2721
  }
2676
2722
  })), {
2677
2723
  "searchBox": true,
2678
- "isOpen": _this18.$data.isOpen,
2679
- "id": _this18.$props.componentId + "-input",
2680
- "ref": _this18.$props.innerRef,
2681
- "class": getClassName$1(_this18.$props.innerClass, 'input'),
2682
- "placeholder": _this18.$props.placeholder,
2683
- "autoFocus": _this18.$props.autoFocus
2724
+ "isOpen": _this17.$data.isOpen,
2725
+ "id": _this17.$props.componentId + "-input",
2726
+ "ref": _this17.$props.innerRef,
2727
+ "class": getClassName$1(_this17.$props.innerClass, 'input'),
2728
+ "placeholder": _this17.$props.placeholder,
2729
+ "autoFocus": _this17.$props.autoFocus
2684
2730
  }, getInputProps({
2685
- value: _this18.$data.currentValue === null ? '' : _this18.$data.currentValue
2731
+ value: _this17.$data.currentValue === null ? '' : _this17.$data.currentValue
2686
2732
  }), {
2687
- "themePreset": _this18.themePreset,
2733
+ "themePreset": _this17.themePreset,
2688
2734
  "autocomplete": "off"
2689
2735
  }), null), !expandSuggestionsContainer && renderSuggestionsDropdown()];
2690
2736
  }
2691
2737
  }), createVNode(Actions$1, null, {
2692
2738
  "default": function _default() {
2693
- return [_this18.renderRightIcons(), _this18.renderInputAddonAfter(), _this18.renderAskButtonElement(), _this18.renderEnterButtonElement()];
2739
+ return [_this17.renderRightIcons(), _this17.renderInputAddonAfter(), _this17.renderAskButtonElement(), _this17.renderEnterButtonElement()];
2694
2740
  }
2695
2741
  })];
2696
2742
  }
2697
- }), expandSuggestionsContainer && renderSuggestionsDropdown(), _this18.renderTags()]);
2743
+ }), expandSuggestionsContainer && renderSuggestionsDropdown(), _this17.renderTags()]);
2698
2744
  }
2699
2745
  }) : createVNode("div", {
2700
2746
  "class": suggestionsContainer
@@ -2705,43 +2751,43 @@ var SearchBox = defineComponent({
2705
2751
  "default": function _default() {
2706
2752
  return [createVNode(Actions$1, null, {
2707
2753
  "default": function _default() {
2708
- return [_this18.renderInputAddonBefore(), _this18.renderLeftIcons()];
2754
+ return [_this17.renderInputAddonBefore(), _this17.renderLeftIcons()];
2709
2755
  }
2710
2756
  }), createVNode(InputWrapper, null, {
2711
2757
  "default": function _default() {
2712
2758
  return [createVNode(TextArea, mergeProps(_transformOn({
2713
2759
  blur: function blur(e) {
2714
- _this18.$emit('blur', e, _this18.triggerQuery);
2760
+ _this17.$emit('blur', e, _this17.triggerQuery);
2715
2761
  },
2716
2762
  keypress: function keypress(e) {
2717
- _this18.$emit('keyPress', e, _this18.triggerQuery);
2718
- _this18.$emit('key-press', e, _this18.triggerQuery);
2763
+ _this17.$emit('keyPress', e, _this17.triggerQuery);
2764
+ _this17.$emit('key-press', e, _this17.triggerQuery);
2719
2765
  },
2720
- input: _this18.onInputChange,
2766
+ input: _this17.onInputChange,
2721
2767
  focus: function focus(e) {
2722
- _this18.$emit('focus', e, _this18.triggerQuery);
2768
+ _this17.$emit('focus', e, _this17.triggerQuery);
2723
2769
  },
2724
- keydown: _this18.handleKeyDown,
2770
+ keydown: _this17.handleKeyDown,
2725
2771
  keyup: function keyup(e) {
2726
- _this18.$emit('keyUp', e, _this18.triggerQuery);
2727
- _this18.$emit('key-up', e, _this18.triggerQuery);
2772
+ _this17.$emit('keyUp', e, _this17.triggerQuery);
2773
+ _this17.$emit('key-up', e, _this17.triggerQuery);
2728
2774
  }
2729
2775
  }), {
2730
2776
  "searchBox": true,
2731
- "class": getClassName$1(_this18.$props.innerClass, 'input') || '',
2732
- "placeholder": _this18.$props.placeholder,
2733
- "autofocus": _this18.$props.autoFocus,
2734
- "value": _this18.$data.currentValue ? _this18.$data.currentValue : '',
2735
- "iconPosition": _this18.$props.iconPosition,
2736
- "showIcon": _this18.$props.showIcon,
2737
- "showClear": _this18.$props.showClear,
2738
- "ref": _this18.$props.innerRef,
2739
- "themePreset": _this18.themePreset
2777
+ "class": getClassName$1(_this17.$props.innerClass, 'input') || '',
2778
+ "placeholder": _this17.$props.placeholder,
2779
+ "autofocus": _this17.$props.autoFocus,
2780
+ "value": _this17.$data.currentValue ? _this17.$data.currentValue : '',
2781
+ "iconPosition": _this17.$props.iconPosition,
2782
+ "showIcon": _this17.$props.showIcon,
2783
+ "showClear": _this17.$props.showClear,
2784
+ "ref": _this17.$props.innerRef,
2785
+ "themePreset": _this17.themePreset
2740
2786
  }), null)];
2741
2787
  }
2742
2788
  }), createVNode(Actions$1, null, {
2743
2789
  "default": function _default() {
2744
- return [_this18.renderRightIcons(), _this18.renderInputAddonAfter(), _this18.renderEnterButtonElement()];
2790
+ return [_this17.renderRightIcons(), _this17.renderInputAddonAfter(), _this17.renderEnterButtonElement()];
2745
2791
  }
2746
2792
  })];
2747
2793
  }
@@ -2956,14 +3002,12 @@ var AIAnswer = defineComponent({
2956
3002
  message: response.error
2957
3003
  };
2958
3004
  }
3005
+
2959
3006
  // pushing message history so far
2960
3007
  if (messagesHistory && Array.isArray(messagesHistory)) {
2961
3008
  finalMessages.push.apply(finalMessages, messagesHistory.filter(function (msg) {
2962
3009
  return msg.role !== AI_ROLES.SYSTEM;
2963
3010
  }));
2964
- if (finalMessages[0].role === AI_ROLES.USER) {
2965
- finalMessages.shift();
2966
- }
2967
3011
  } else if (response && response.answer && response.answer.text) {
2968
3012
  finalMessages.push({
2969
3013
  role: AI_ROLES.ASSISTANT,