react-instantsearch 7.29.0 → 7.30.0

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 (41) hide show
  1. package/dist/cjs/components/AutocompleteSearch.js +3 -3
  2. package/dist/cjs/components/ChatGreeting.js +16 -0
  3. package/dist/cjs/components/ChatSidePanelLayout.js +17 -0
  4. package/dist/cjs/components/index.js +2 -0
  5. package/dist/cjs/ui/SearchBox.js +38 -2
  6. package/dist/cjs/widgets/Autocomplete.js +24 -8
  7. package/dist/cjs/widgets/Chat.js +21 -3
  8. package/dist/cjs/widgets/SearchBox.js +18 -2
  9. package/dist/cjs/widgets/TrendingFacets.js +55 -0
  10. package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +7 -3
  11. package/dist/cjs/widgets/index.js +1 -0
  12. package/dist/es/components/AutocompleteSearch.d.ts +2 -2
  13. package/dist/es/components/AutocompleteSearch.js +3 -3
  14. package/dist/es/components/ChatGreeting.d.ts +1 -0
  15. package/dist/es/components/ChatGreeting.js +8 -0
  16. package/dist/es/components/ChatOverlayLayout.d.ts +1 -3
  17. package/dist/es/components/ChatSidePanelLayout.d.ts +1 -0
  18. package/dist/es/components/ChatSidePanelLayout.js +9 -0
  19. package/dist/es/components/index.d.ts +2 -0
  20. package/dist/es/components/index.js +2 -0
  21. package/dist/es/index.js +3 -0
  22. package/dist/es/ui/SearchBox.d.ts +15 -1
  23. package/dist/es/ui/SearchBox.js +38 -2
  24. package/dist/es/widgets/Autocomplete.d.ts +6 -0
  25. package/dist/es/widgets/Autocomplete.js +24 -8
  26. package/dist/es/widgets/Chat.d.ts +12 -2
  27. package/dist/es/widgets/Chat.js +35 -17
  28. package/dist/es/widgets/RefinementList.d.ts +3 -2
  29. package/dist/es/widgets/SearchBox.d.ts +8 -2
  30. package/dist/es/widgets/SearchBox.js +19 -3
  31. package/dist/es/widgets/TrendingFacets.d.ts +11 -0
  32. package/dist/es/widgets/TrendingFacets.js +46 -0
  33. package/dist/es/widgets/chat/tools/SearchIndexTool.js +7 -3
  34. package/dist/es/widgets/index.d.ts +1 -0
  35. package/dist/es/widgets/index.js +1 -0
  36. package/dist/umd/ReactInstantSearch.js +646 -136
  37. package/dist/umd/ReactInstantSearch.min.js +3 -3
  38. package/package.json +5 -5
  39. package/dist/cjs/widgets/index.umd.js +0 -69
  40. package/dist/es/widgets/index.umd.d.ts +0 -32
  41. package/dist/es/widgets/index.umd.js +0 -37
@@ -1,4 +1,4 @@
1
- /*! React InstantSearch 7.29.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! React InstantSearch 7.30.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
@@ -24,7 +24,7 @@
24
24
 
25
25
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
26
26
 
27
- var version$2 = '7.29.0';
27
+ var version$2 = '7.30.0';
28
28
 
29
29
  function _define_property(obj, key, value) {
30
30
  if (key in obj) {
@@ -5938,7 +5938,7 @@
5938
5938
  }
5939
5939
  }
5940
5940
 
5941
- var withUsage$s = createDocumentationMessageGenerator({
5941
+ var withUsage$t = createDocumentationMessageGenerator({
5942
5942
  name: 'configure',
5943
5943
  connector: true
5944
5944
  });
@@ -5954,7 +5954,7 @@
5954
5954
  var renderFn = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : noop, unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
5955
5955
  return function(widgetParams) {
5956
5956
  if (!widgetParams || !isPlainObject(widgetParams.searchParameters)) {
5957
- throw new Error(withUsage$s('The `searchParameters` option expects an object.'));
5957
+ throw new Error(withUsage$t('The `searchParameters` option expects an object.'));
5958
5958
  }
5959
5959
  var connectorState = {};
5960
5960
  function refine(helper) {
@@ -6499,13 +6499,13 @@
6499
6499
  }
6500
6500
  }
6501
6501
 
6502
- var withUsage$r = createDocumentationMessageGenerator({
6502
+ var withUsage$s = createDocumentationMessageGenerator({
6503
6503
  name: 'dynamic-widgets',
6504
6504
  connector: true
6505
6505
  });
6506
6506
  var connectDynamicWidgets = function connectDynamicWidgets(renderFn) {
6507
6507
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
6508
- checkRendering(renderFn, withUsage$r());
6508
+ checkRendering(renderFn, withUsage$s());
6509
6509
  return function(widgetParams) {
6510
6510
  var widgets = widgetParams.widgets, _widgetParams_maxValuesPerFacet = widgetParams.maxValuesPerFacet, maxValuesPerFacet = _widgetParams_maxValuesPerFacet === void 0 ? 20 : _widgetParams_maxValuesPerFacet, _widgetParams_facets = widgetParams.facets, facets = _widgetParams_facets === void 0 ? [
6511
6511
  '*'
@@ -6515,10 +6515,10 @@
6515
6515
  if (!(widgets && Array.isArray(widgets) && widgets.every(function(widget) {
6516
6516
  return (typeof widget === "undefined" ? "undefined" : _type_of(widget)) === 'object';
6517
6517
  }))) {
6518
- throw new Error(withUsage$r('The `widgets` option expects an array of widgets.'));
6518
+ throw new Error(withUsage$s('The `widgets` option expects an array of widgets.'));
6519
6519
  }
6520
6520
  if (!Array.isArray(facets)) {
6521
- throw new Error(withUsage$r("The `facets` option only accepts an array of facets, you passed ".concat(JSON.stringify(facets))));
6521
+ throw new Error(withUsage$s("The `facets` option only accepts an array of facets, you passed ".concat(JSON.stringify(facets))));
6522
6522
  }
6523
6523
  var localWidgets = new Map();
6524
6524
  return {
@@ -6620,7 +6620,7 @@
6620
6620
  results: results
6621
6621
  });
6622
6622
  if (!Array.isArray(attributesToRender)) {
6623
- throw new Error(withUsage$r('The `transformItems` option expects a function that returns an Array.'));
6623
+ throw new Error(withUsage$s('The `transformItems` option expects a function that returns an Array.'));
6624
6624
  }
6625
6625
  return {
6626
6626
  attributesToRender: attributesToRender,
@@ -6801,7 +6801,7 @@
6801
6801
  };
6802
6802
  }
6803
6803
 
6804
- var withUsage$q = createDocumentationMessageGenerator({
6804
+ var withUsage$r = createDocumentationMessageGenerator({
6805
6805
  name: 'index-widget'
6806
6806
  });
6807
6807
  /**
@@ -6895,7 +6895,7 @@
6895
6895
  }
6896
6896
  var index = function index(widgetParams) {
6897
6897
  if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.EXPERIMENTAL_isolated) {
6898
- throw new Error(withUsage$q('The `indexName` option is required.'));
6898
+ throw new Error(withUsage$r('The `indexName` option is required.'));
6899
6899
  }
6900
6900
  // When isolated=true, we use an empty string as the default indexName.
6901
6901
  // This is intentional: isolated indices do not require a real index name.
@@ -6985,7 +6985,7 @@
6985
6985
  addWidgets: function addWidgets(widgets) {
6986
6986
  var _this = this;
6987
6987
  if (!Array.isArray(widgets)) {
6988
- throw new Error(withUsage$q('The `addWidgets` method expects an array of widgets.'));
6988
+ throw new Error(withUsage$r('The `addWidgets` method expects an array of widgets.'));
6989
6989
  }
6990
6990
  var flatWidgets = widgets.reduce(function(acc, w) {
6991
6991
  return acc.concat(Array.isArray(w) ? w : [
@@ -6995,7 +6995,7 @@
6995
6995
  if (flatWidgets.some(function(widget) {
6996
6996
  return typeof widget.init !== 'function' && typeof widget.render !== 'function';
6997
6997
  })) {
6998
- throw new Error(withUsage$q('The widget definition expects a `render` and/or an `init` method.'));
6998
+ throw new Error(withUsage$r('The widget definition expects a `render` and/or an `init` method.'));
6999
6999
  }
7000
7000
  flatWidgets.forEach(function(widget) {
7001
7001
  widget.parent = _this;
@@ -7055,7 +7055,7 @@
7055
7055
  removeWidgets: function removeWidgets(widgets) {
7056
7056
  var _this = this;
7057
7057
  if (!Array.isArray(widgets)) {
7058
- throw new Error(withUsage$q('The `removeWidgets` method expects an array of widgets.'));
7058
+ throw new Error(withUsage$r('The `removeWidgets` method expects an array of widgets.'));
7059
7059
  }
7060
7060
  var flatWidgets = widgets.reduce(function(acc, w) {
7061
7061
  return acc.concat(Array.isArray(w) ? w : [
@@ -7065,7 +7065,7 @@
7065
7065
  if (flatWidgets.some(function(widget) {
7066
7066
  return typeof widget.dispose !== 'function';
7067
7067
  })) {
7068
- throw new Error(withUsage$q('The widget definition expects a `dispose` method.'));
7068
+ throw new Error(withUsage$r('The widget definition expects a `dispose` method.'));
7069
7069
  }
7070
7070
  localWidgets = localWidgets.filter(function(widget) {
7071
7071
  return flatWidgets.indexOf(widget) === -1;
@@ -9684,7 +9684,7 @@
9684
9684
  };
9685
9685
  }
9686
9686
 
9687
- var version = '4.93.0';
9687
+ var version = '4.94.0';
9688
9688
 
9689
9689
  function hydrateSearchClient(client, results) {
9690
9690
  if (!results) {
@@ -9819,7 +9819,7 @@
9819
9819
  });
9820
9820
  }
9821
9821
 
9822
- var withUsage$p = createDocumentationMessageGenerator({
9822
+ var withUsage$q = createDocumentationMessageGenerator({
9823
9823
  name: 'instantsearch'
9824
9824
  });
9825
9825
  function defaultCreateURL() {
@@ -9875,7 +9875,7 @@
9875
9875
  _this.setMaxListeners(100);
9876
9876
  var _options_indexName = options.indexName, indexName = _options_indexName === void 0 ? '' : _options_indexName, compositionID = options.compositionID, numberLocale = options.numberLocale, _options_initialUiState = options.initialUiState, initialUiState = _options_initialUiState === void 0 ? {} : _options_initialUiState, _options_routing = options.routing, routing = _options_routing === void 0 ? null : _options_routing, _options_insights = options.insights, insights = _options_insights === void 0 ? undefined : _options_insights, searchFunction = options.searchFunction, _options_stalledSearchDelay = options.stalledSearchDelay, stalledSearchDelay = _options_stalledSearchDelay === void 0 ? 200 : _options_stalledSearchDelay, _options_searchClient = options.searchClient, searchClient = _options_searchClient === void 0 ? null : _options_searchClient, _options_insightsClient = options.insightsClient, insightsClient = _options_insightsClient === void 0 ? null : _options_insightsClient, _options_onStateChange = options.onStateChange, onStateChange = _options_onStateChange === void 0 ? null : _options_onStateChange, _options_future1 = options.future, future = _options_future1 === void 0 ? _object_spread({}, INSTANTSEARCH_FUTURE_DEFAULTS, options.future || {}) : _options_future1;
9877
9877
  if (searchClient === null) {
9878
- throw new Error(withUsage$p('The `searchClient` option is required.'));
9878
+ throw new Error(withUsage$q('The `searchClient` option is required.'));
9879
9879
  }
9880
9880
  if (typeof searchClient.search !== 'function') {
9881
9881
  throw new Error("The `searchClient` must implement a `search` method.\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/js/");
@@ -9884,7 +9884,7 @@
9884
9884
  searchClient.addAlgoliaAgent("instantsearch.js (".concat(version, ")"));
9885
9885
  }
9886
9886
  if (insightsClient && typeof insightsClient !== 'function') {
9887
- throw new Error(withUsage$p('The `insightsClient` option should be a function.'));
9887
+ throw new Error(withUsage$q('The `insightsClient` option should be a function.'));
9888
9888
  }
9889
9889
  _this.client = searchClient;
9890
9890
  _this.future = future;
@@ -10032,12 +10032,12 @@
10032
10032
  * @param widgets The array of widgets to add to InstantSearch.
10033
10033
  */ function addWidgets(widgets) {
10034
10034
  if (!Array.isArray(widgets)) {
10035
- throw new Error(withUsage$p('The `addWidgets` method expects an array of widgets. Please use `addWidget`.'));
10035
+ throw new Error(withUsage$q('The `addWidgets` method expects an array of widgets. Please use `addWidget`.'));
10036
10036
  }
10037
10037
  if (this.compositionID && widgets.some(function(w) {
10038
10038
  return !Array.isArray(w) && isIndexWidget(w) && !w._isolated;
10039
10039
  })) {
10040
- throw new Error(withUsage$p('The `index` widget cannot be used with a composition-based InstantSearch implementation.'));
10040
+ throw new Error(withUsage$q('The `index` widget cannot be used with a composition-based InstantSearch implementation.'));
10041
10041
  }
10042
10042
  this.mainIndex.addWidgets(widgets);
10043
10043
  return this;
@@ -10066,7 +10066,7 @@
10066
10066
  * The widgets must implement a `dispose()` method to clear their states.
10067
10067
  */ function removeWidgets(widgets) {
10068
10068
  if (!Array.isArray(widgets)) {
10069
- throw new Error(withUsage$p('The `removeWidgets` method expects an array of widgets. Please use `removeWidget`.'));
10069
+ throw new Error(withUsage$q('The `removeWidgets` method expects an array of widgets. Please use `removeWidget`.'));
10070
10070
  }
10071
10071
  this.mainIndex.removeWidgets(widgets);
10072
10072
  return this;
@@ -10080,7 +10080,7 @@
10080
10080
  */ function start() {
10081
10081
  var _this = this;
10082
10082
  if (this.started) {
10083
- throw new Error(withUsage$p('The `start` method has already been called once.'));
10083
+ throw new Error(withUsage$q('The `start` method has already been called once.'));
10084
10084
  }
10085
10085
  // This Helper is used for the queries, we don't care about its state. The
10086
10086
  // states are managed at the `index` level. We use this Helper to create
@@ -10282,7 +10282,7 @@
10282
10282
  var _this = this;
10283
10283
  var callOnStateChange = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
10284
10284
  if (!this.mainHelper) {
10285
- throw new Error(withUsage$p('The `start` method needs to be called before `setUiState`.'));
10285
+ throw new Error(withUsage$q('The `start` method needs to be called before `setUiState`.'));
10286
10286
  }
10287
10287
  // We refresh the index UI state to update the local UI state that the
10288
10288
  // main index passes to the function form of `setUiState`.
@@ -10319,7 +10319,7 @@
10319
10319
  value: function createURL() {
10320
10320
  var nextState = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
10321
10321
  if (!this.started) {
10322
- throw new Error(withUsage$p('The `start` method needs to be called before `createURL`.'));
10322
+ throw new Error(withUsage$q('The `start` method needs to be called before `createURL`.'));
10323
10323
  }
10324
10324
  return this._createURL(nextState);
10325
10325
  }
@@ -10328,7 +10328,7 @@
10328
10328
  key: "refresh",
10329
10329
  value: function refresh() {
10330
10330
  if (!this.mainHelper) {
10331
- throw new Error(withUsage$p('The `start` method needs to be called before `refresh`.'));
10331
+ throw new Error(withUsage$q('The `start` method needs to be called before `refresh`.'));
10332
10332
  }
10333
10333
  this.mainHelper.clearCache().search();
10334
10334
  }
@@ -10990,17 +10990,17 @@
10990
10990
  return bindEventForHits;
10991
10991
  }
10992
10992
 
10993
- var withUsage$o = createDocumentationMessageGenerator({
10993
+ var withUsage$p = createDocumentationMessageGenerator({
10994
10994
  name: 'autocomplete',
10995
10995
  connector: true
10996
10996
  });
10997
10997
  var connectAutocomplete = function connectAutocomplete(renderFn) {
10998
10998
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
10999
- checkRendering(renderFn, withUsage$o());
10999
+ checkRendering(renderFn, withUsage$p());
11000
11000
  return function(widgetParams) {
11001
11001
  var _ref = widgetParams || {}, _ref_escapeHTML = _ref.escapeHTML, escapeHTML = _ref_escapeHTML === void 0 ? true : _ref_escapeHTML, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(indices) {
11002
11002
  return indices;
11003
- } : _ref_transformItems;
11003
+ } : _ref_transformItems, tmp = _ref.future, _ref1 = tmp === void 0 ? {} : tmp, _ref_undefinedEmptyQuery = _ref1.undefinedEmptyQuery, undefinedEmptyQuery = _ref_undefinedEmptyQuery === void 0 ? false : _ref_undefinedEmptyQuery;
11004
11004
  var connectorState = {};
11005
11005
  return {
11006
11006
  $$type: 'ais.autocomplete',
@@ -11055,7 +11055,7 @@
11055
11055
  };
11056
11056
  });
11057
11057
  return {
11058
- currentRefinement: state.query || '',
11058
+ currentRefinement: undefinedEmptyQuery ? state.query : state.query || '',
11059
11059
  indices: transformItems(indices).map(function(transformedIndex) {
11060
11060
  return _object_spread_props(_object_spread({}, transformedIndex), {
11061
11061
  sendEvent: sendEventMap[transformedIndex.indexId]
@@ -11067,8 +11067,8 @@
11067
11067
  },
11068
11068
  getWidgetUiState: function getWidgetUiState(uiState, param) {
11069
11069
  var searchParameters = param.searchParameters;
11070
- var query = searchParameters.query || '';
11071
- if (query === '' || uiState && uiState.query === query) {
11070
+ var query = undefinedEmptyQuery ? searchParameters.query : searchParameters.query || '';
11071
+ if (!query || query === '' || uiState && uiState.query === query) {
11072
11072
  return uiState;
11073
11073
  }
11074
11074
  return _object_spread_props(_object_spread({}, uiState), {
@@ -11078,7 +11078,7 @@
11078
11078
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, param) {
11079
11079
  var uiState = param.uiState;
11080
11080
  var parameters = {
11081
- query: uiState.query || ''
11081
+ query: undefinedEmptyQuery ? uiState.query : uiState.query || ''
11082
11082
  };
11083
11083
  if (!escapeHTML) {
11084
11084
  return searchParameters.setQueryParameters(parameters);
@@ -11104,20 +11104,20 @@
11104
11104
  return useConnector(connectAutocomplete, props, additionalWidgetProperties);
11105
11105
  }
11106
11106
 
11107
- var withUsage$n = createDocumentationMessageGenerator({
11107
+ var withUsage$o = createDocumentationMessageGenerator({
11108
11108
  name: 'breadcrumb',
11109
11109
  connector: true
11110
11110
  });
11111
11111
  var connectBreadcrumb = function connectBreadcrumb(renderFn) {
11112
11112
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
11113
- checkRendering(renderFn, withUsage$n());
11113
+ checkRendering(renderFn, withUsage$o());
11114
11114
  var connectorState = {};
11115
11115
  return function(widgetParams) {
11116
11116
  var _ref = widgetParams || {}, attributes = _ref.attributes, _ref_separator = _ref.separator, separator = _ref_separator === void 0 ? ' > ' : _ref_separator, _ref_rootPath = _ref.rootPath, rootPath = _ref_rootPath === void 0 ? null : _ref_rootPath, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
11117
11117
  return items;
11118
11118
  } : _ref_transformItems;
11119
11119
  if (!attributes || !Array.isArray(attributes) || attributes.length === 0) {
11120
- throw new Error(withUsage$n('The `attributes` option expects an array of strings.'));
11120
+ throw new Error(withUsage$o('The `attributes` option expects an array of strings.'));
11121
11121
  }
11122
11122
  var _attributes = _sliced_to_array(attributes, 1), hierarchicalFacetName = _attributes[0];
11123
11123
  function getRefinedState(state, facetValue) {
@@ -12754,7 +12754,7 @@
12754
12754
  return refinements;
12755
12755
  }
12756
12756
 
12757
- var withUsage$m = createDocumentationMessageGenerator({
12757
+ var withUsage$n = createDocumentationMessageGenerator({
12758
12758
  name: 'chat',
12759
12759
  connector: true
12760
12760
  });
@@ -12805,12 +12805,14 @@
12805
12805
  }
12806
12806
  var connectChat = function connectChat(renderFn) {
12807
12807
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
12808
- checkRendering(renderFn, withUsage$m());
12808
+ checkRendering(renderFn, withUsage$n());
12809
12809
  return function(widgetParams) {
12810
- var _ref = widgetParams || {}, _ref_resume = _ref.resume, resume = _ref_resume === void 0 ? false : _ref_resume, _ref_tools = _ref.tools, tools = _ref_tools === void 0 ? {} : _ref_tools, _ref_type = _ref.type, type = _ref_type === void 0 ? 'chat' : _ref_type, options = _object_without_properties(_ref, [
12810
+ var _ref = widgetParams || {}, _ref_resume = _ref.resume, resume = _ref_resume === void 0 ? false : _ref_resume, _ref_tools = _ref.tools, tools = _ref_tools === void 0 ? {} : _ref_tools, _ref_type = _ref.type, type = _ref_type === void 0 ? 'chat' : _ref_type, context = _ref.context, initialUserMessage = _ref.initialUserMessage, options = _object_without_properties(_ref, [
12811
12811
  "resume",
12812
12812
  "tools",
12813
- "type"
12813
+ "type",
12814
+ "context",
12815
+ "initialUserMessage"
12814
12816
  ]);
12815
12817
  var _chatInstance;
12816
12818
  var input = '';
@@ -12852,6 +12854,10 @@
12852
12854
  if (!_chatInstance.messages || _chatInstance.messages.length === 0) {
12853
12855
  return;
12854
12856
  }
12857
+ var status = _chatInstance.status;
12858
+ if (status === 'submitted' || status === 'streaming') {
12859
+ _chatInstance.stop();
12860
+ }
12855
12861
  setIsClearing(true);
12856
12862
  };
12857
12863
  var onClearTransitionEnd = function onClearTransitionEnd() {
@@ -12901,7 +12907,7 @@
12901
12907
  }
12902
12908
  if ('agentId' in options && options.agentId) {
12903
12909
  if (!appId || !apiKey) {
12904
- throw new Error(withUsage$m('Could not extract Algolia credentials from the search client.'));
12910
+ throw new Error(withUsage$n('Could not extract Algolia credentials from the search client.'));
12905
12911
  }
12906
12912
  var baseApi = "https://".concat(appId, ".algolia.net/agent-studio/1/agents/").concat(agentId, "/completions?compatibilityMode=ai-sdk-5");
12907
12913
  transport = new DefaultChatTransport({
@@ -12927,7 +12933,7 @@
12927
12933
  });
12928
12934
  }
12929
12935
  if (!transport) {
12930
- throw new Error(withUsage$m('You need to provide either an `agentId` or a `transport`.'));
12936
+ throw new Error(withUsage$n('You need to provide either an `agentId` or a `transport`.'));
12931
12937
  }
12932
12938
  if ('chat' in options) {
12933
12939
  return options.chat;
@@ -13000,7 +13006,7 @@
13000
13006
  if (agentId && feedback) {
13001
13007
  var _getAppIdAndApiKey = _sliced_to_array(getAppIdAndApiKey(initOptions.instantSearchInstance.client), 2), appId = _getAppIdAndApiKey[0], apiKey = _getAppIdAndApiKey[1];
13002
13008
  if (!appId || !apiKey) {
13003
- throw new Error(withUsage$m('Could not extract Algolia credentials from the search client.'));
13009
+ throw new Error(withUsage$n('Could not extract Algolia credentials from the search client.'));
13004
13010
  }
13005
13011
  feedbackAbortController = new AbortController();
13006
13012
  _sendChatMessageFeedback = function _sendChatMessageFeedback(messageId, vote) {
@@ -13025,6 +13031,11 @@
13025
13031
  if (resume) {
13026
13032
  _chatInstance.resumeStream();
13027
13033
  }
13034
+ if (initialUserMessage && !resume && _chatInstance.messages.length === 0) {
13035
+ _chatInstance.sendMessage({
13036
+ text: initialUserMessage
13037
+ });
13038
+ }
13028
13039
  renderFn(_object_spread_props(_object_spread({}, this.getWidgetRenderState(initOptions)), {
13029
13040
  instantSearchInstance: instantSearchInstance
13030
13041
  }), true);
@@ -13060,10 +13071,65 @@
13060
13071
  var _param = _sliced_to_array(param, 2), key = _param[0], tool = _param[1];
13061
13072
  var toolWithAddToolResult = _object_spread_props(_object_spread({}, tool), {
13062
13073
  addToolResult: _chatInstance.addToolResult,
13063
- applyFilters: applyFilters
13074
+ applyFilters: applyFilters,
13075
+ sendEvent: sendEvent
13064
13076
  });
13065
13077
  toolsWithAddToolResult[key] = toolWithAddToolResult;
13066
13078
  });
13079
+ var sendMessageWithContext = function sendMessageWithContext(message) {
13080
+ for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
13081
+ rest[_key - 1] = arguments[_key];
13082
+ }
13083
+ var _chatInstance1;
13084
+ if (!context || !message) {
13085
+ var _chatInstance2;
13086
+ return (_chatInstance2 = _chatInstance).sendMessage.apply(_chatInstance2, [
13087
+ message
13088
+ ].concat(_to_consumable_array(rest)));
13089
+ }
13090
+ var resolvedContext = typeof context === 'function' ? context() : context;
13091
+ var serializedContext;
13092
+ try {
13093
+ serializedContext = JSON.stringify(resolvedContext);
13094
+ } catch (unused) {
13095
+ var _chatInstance3;
13096
+ return (_chatInstance3 = _chatInstance).sendMessage.apply(_chatInstance3, [
13097
+ message
13098
+ ].concat(_to_consumable_array(rest)));
13099
+ }
13100
+ var contextTextPart = {
13101
+ type: 'text',
13102
+ text: '<context>'.concat(serializedContext).concat('</context>')
13103
+ };
13104
+ if ('parts' in message && message.parts) {
13105
+ var _chatInstance4;
13106
+ return (_chatInstance4 = _chatInstance).sendMessage.apply(_chatInstance4, [
13107
+ _object_spread_props(_object_spread({}, message), {
13108
+ parts: [
13109
+ contextTextPart
13110
+ ].concat(_to_consumable_array(message.parts)),
13111
+ text: undefined,
13112
+ files: undefined
13113
+ })
13114
+ ].concat(_to_consumable_array(rest)));
13115
+ }
13116
+ var textContent = 'text' in message && message.text ? message.text : '';
13117
+ return (_chatInstance1 = _chatInstance).sendMessage.apply(_chatInstance1, [
13118
+ {
13119
+ parts: [
13120
+ contextTextPart,
13121
+ {
13122
+ type: 'text',
13123
+ text: textContent
13124
+ }
13125
+ ],
13126
+ metadata: message.metadata,
13127
+ messageId: message.messageId,
13128
+ files: undefined,
13129
+ text: undefined
13130
+ }
13131
+ ].concat(_to_consumable_array(rest)));
13132
+ };
13067
13133
  return {
13068
13134
  indexUiState: instantSearchInstance.getUiState()[parent.getIndexId()],
13069
13135
  input: input,
@@ -13090,7 +13156,7 @@
13090
13156
  messages: _chatInstance.messages,
13091
13157
  regenerate: _chatInstance.regenerate,
13092
13158
  resumeStream: _chatInstance.resumeStream,
13093
- sendMessage: _chatInstance.sendMessage,
13159
+ sendMessage: sendMessageWithContext,
13094
13160
  status: _chatInstance.status,
13095
13161
  stop: _chatInstance.stop
13096
13162
  };
@@ -13113,13 +13179,13 @@
13113
13179
  return useConnector(connectChat, props, additionalWidgetProperties);
13114
13180
  }
13115
13181
 
13116
- var withUsage$l = createDocumentationMessageGenerator({
13182
+ var withUsage$m = createDocumentationMessageGenerator({
13117
13183
  name: 'clear-refinements',
13118
13184
  connector: true
13119
13185
  });
13120
13186
  var connectClearRefinements = function connectClearRefinements(renderFn) {
13121
13187
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
13122
- checkRendering(renderFn, withUsage$l());
13188
+ checkRendering(renderFn, withUsage$m());
13123
13189
  return function(widgetParams) {
13124
13190
  var _ref = widgetParams || {}, _ref_includedAttributes = _ref.includedAttributes, includedAttributes = _ref_includedAttributes === void 0 ? [] : _ref_includedAttributes, _ref_excludedAttributes = _ref.excludedAttributes, excludedAttributes = _ref_excludedAttributes === void 0 ? [
13125
13191
  'query'
@@ -13127,7 +13193,7 @@
13127
13193
  return items;
13128
13194
  } : _ref_transformItems;
13129
13195
  if (widgetParams && widgetParams.includedAttributes && widgetParams.excludedAttributes) {
13130
- throw new Error(withUsage$l('The options `includedAttributes` and `excludedAttributes` cannot be used together.'));
13196
+ throw new Error(withUsage$m('The options `includedAttributes` and `excludedAttributes` cannot be used together.'));
13131
13197
  }
13132
13198
  var connectorState = {
13133
13199
  refine: noop,
@@ -13230,16 +13296,16 @@
13230
13296
  return useConnector(connectClearRefinements, props, additionalWidgetProperties);
13231
13297
  }
13232
13298
 
13233
- var withUsage$k = createDocumentationMessageGenerator({
13299
+ var withUsage$l = createDocumentationMessageGenerator({
13234
13300
  name: 'current-refinements',
13235
13301
  connector: true
13236
13302
  });
13237
13303
  var connectCurrentRefinements = function connectCurrentRefinements(renderFn) {
13238
13304
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
13239
- checkRendering(renderFn, withUsage$k());
13305
+ checkRendering(renderFn, withUsage$l());
13240
13306
  return function(widgetParams) {
13241
13307
  if ((widgetParams || {}).includedAttributes && (widgetParams || {}).excludedAttributes) {
13242
- throw new Error(withUsage$k('The options `includedAttributes` and `excludedAttributes` cannot be used together.'));
13308
+ throw new Error(withUsage$l('The options `includedAttributes` and `excludedAttributes` cannot be used together.'));
13243
13309
  }
13244
13310
  var _ref = widgetParams || {}, includedAttributes = _ref.includedAttributes, _ref_excludedAttributes = _ref.excludedAttributes, excludedAttributes = _ref_excludedAttributes === void 0 ? [
13245
13311
  'query'
@@ -13428,19 +13494,19 @@
13428
13494
  });
13429
13495
  }
13430
13496
 
13431
- var withUsage$j = createDocumentationMessageGenerator({
13497
+ var withUsage$k = createDocumentationMessageGenerator({
13432
13498
  name: 'frequently-bought-together',
13433
13499
  connector: true
13434
13500
  });
13435
13501
  var connectFrequentlyBoughtTogether = function connectFrequentlyBoughtTogether(renderFn) {
13436
13502
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
13437
- checkRendering(renderFn, withUsage$j());
13503
+ checkRendering(renderFn, withUsage$k());
13438
13504
  return function(widgetParams) {
13439
13505
  var _ref = widgetParams || {}, _ref_escapeHTML = _ref.escapeHTML, escapeHTML = _ref_escapeHTML === void 0 ? true : _ref_escapeHTML, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
13440
13506
  return items;
13441
13507
  } : _ref_transformItems, objectIDs = _ref.objectIDs, limit = _ref.limit, threshold = _ref.threshold, fallbackParameters = _ref.fallbackParameters, queryParameters = _ref.queryParameters;
13442
13508
  if (!objectIDs || objectIDs.length === 0) {
13443
- throw new Error(withUsage$j('The `objectIDs` option is required.'));
13509
+ throw new Error(withUsage$k('The `objectIDs` option is required.'));
13444
13510
  }
13445
13511
  var sendEvent;
13446
13512
  return {
@@ -13578,7 +13644,7 @@
13578
13644
  return insideBoundingBoxStringToBoundingBox(value);
13579
13645
  }
13580
13646
 
13581
- var withUsage$i = createDocumentationMessageGenerator({
13647
+ var withUsage$j = createDocumentationMessageGenerator({
13582
13648
  name: 'geo-search',
13583
13649
  connector: true
13584
13650
  });
@@ -13602,7 +13668,7 @@
13602
13668
  * Currently, the feature is not compatible with multiple values in the _geoloc attribute.
13603
13669
  */ var connectGeoSearch = function connectGeoSearch(renderFn) {
13604
13670
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
13605
- checkRendering(renderFn, withUsage$i());
13671
+ checkRendering(renderFn, withUsage$j());
13606
13672
  return function(widgetParams) {
13607
13673
  var _ref = widgetParams || {}, _ref_enableRefineOnMapMove = _ref.enableRefineOnMapMove, enableRefineOnMapMove = _ref_enableRefineOnMapMove === void 0 ? true : _ref_enableRefineOnMapMove, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
13608
13674
  return items;
@@ -13820,7 +13886,7 @@
13820
13886
  return sendEventForFacet;
13821
13887
  }
13822
13888
 
13823
- var withUsage$h = createDocumentationMessageGenerator({
13889
+ var withUsage$i = createDocumentationMessageGenerator({
13824
13890
  name: 'hierarchical-menu',
13825
13891
  connector: true
13826
13892
  });
@@ -13841,16 +13907,16 @@
13841
13907
  * @return {function(CustomHierarchicalMenuWidgetParams)} Re-usable widget factory for a custom **HierarchicalMenu** widget.
13842
13908
  */ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
13843
13909
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
13844
- checkRendering(renderFn, withUsage$h());
13910
+ checkRendering(renderFn, withUsage$i());
13845
13911
  return function(widgetParams) {
13846
13912
  var _ref = widgetParams || {}, attributes = _ref.attributes, _ref_separator = _ref.separator, separator = _ref_separator === void 0 ? ' > ' : _ref_separator, _ref_rootPath = _ref.rootPath, rootPath = _ref_rootPath === void 0 ? null : _ref_rootPath, _ref_showParentLevel = _ref.showParentLevel, showParentLevel = _ref_showParentLevel === void 0 ? true : _ref_showParentLevel, _ref_limit = _ref.limit, limit = _ref_limit === void 0 ? 10 : _ref_limit, _ref_showMore = _ref.showMore, showMore = _ref_showMore === void 0 ? false : _ref_showMore, _ref_showMoreLimit = _ref.showMoreLimit, showMoreLimit = _ref_showMoreLimit === void 0 ? 20 : _ref_showMoreLimit, _ref_sortBy = _ref.sortBy, sortBy = _ref_sortBy === void 0 ? DEFAULT_SORT$2 : _ref_sortBy, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
13847
13913
  return items;
13848
13914
  } : _ref_transformItems;
13849
13915
  if (!attributes || !Array.isArray(attributes) || attributes.length === 0) {
13850
- throw new Error(withUsage$h('The `attributes` option expects an array of strings.'));
13916
+ throw new Error(withUsage$i('The `attributes` option expects an array of strings.'));
13851
13917
  }
13852
13918
  if (showMore === true && showMoreLimit <= limit) {
13853
- throw new Error(withUsage$h('The `showMoreLimit` option must be greater than `limit`.'));
13919
+ throw new Error(withUsage$i('The `showMoreLimit` option must be greater than `limit`.'));
13854
13920
  }
13855
13921
  // we need to provide a hierarchicalFacet name for the search state
13856
13922
  // so that we can always map $hierarchicalFacetName => real attributes
@@ -14042,13 +14108,13 @@
14042
14108
  return useConnector(connectHierarchicalMenu, props, additionalWidgetProperties);
14043
14109
  }
14044
14110
 
14045
- var withUsage$g = createDocumentationMessageGenerator({
14111
+ var withUsage$h = createDocumentationMessageGenerator({
14046
14112
  name: 'hits',
14047
14113
  connector: true
14048
14114
  });
14049
14115
  var connectHits = function connectHits(renderFn) {
14050
14116
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
14051
- checkRendering(renderFn, withUsage$g());
14117
+ checkRendering(renderFn, withUsage$h());
14052
14118
  return function(widgetParams) {
14053
14119
  var _ref = widgetParams || {}, _ref_escapeHTML = _ref.escapeHTML, escapeHTML = _ref_escapeHTML === void 0 ? true : _ref_escapeHTML, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
14054
14120
  return items;
@@ -14146,29 +14212,29 @@
14146
14212
  return useConnector(connectHits, props, additionalWidgetProperties);
14147
14213
  }
14148
14214
 
14149
- var withUsage$f = createDocumentationMessageGenerator({
14215
+ var withUsage$g = createDocumentationMessageGenerator({
14150
14216
  name: 'hits-per-page',
14151
14217
  connector: true
14152
14218
  });
14153
14219
  var connectHitsPerPage = function connectHitsPerPage(renderFn) {
14154
14220
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
14155
- checkRendering(renderFn, withUsage$f());
14221
+ checkRendering(renderFn, withUsage$g());
14156
14222
  return function(widgetParams) {
14157
14223
  var _ref = widgetParams || {}, userItems = _ref.items, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
14158
14224
  return items;
14159
14225
  } : _ref_transformItems;
14160
14226
  if (!Array.isArray(userItems)) {
14161
- throw new Error(withUsage$f('The `items` option expects an array of objects.'));
14227
+ throw new Error(withUsage$g('The `items` option expects an array of objects.'));
14162
14228
  }
14163
14229
  var items = userItems;
14164
14230
  var defaultItems = items.filter(function(item) {
14165
14231
  return item.default === true;
14166
14232
  });
14167
14233
  if (defaultItems.length === 0) {
14168
- throw new Error(withUsage$f("A default value must be specified in `items`."));
14234
+ throw new Error(withUsage$g("A default value must be specified in `items`."));
14169
14235
  }
14170
14236
  if (defaultItems.length > 1) {
14171
- throw new Error(withUsage$f('More than one default value is specified in `items`.'));
14237
+ throw new Error(withUsage$g('More than one default value is specified in `items`.'));
14172
14238
  }
14173
14239
  var defaultItem = defaultItems[0];
14174
14240
  var normalizeItems = function normalizeItems(param) {
@@ -14287,7 +14353,7 @@
14287
14353
  });
14288
14354
  }
14289
14355
 
14290
- var withUsage$e = createDocumentationMessageGenerator({
14356
+ var withUsage$f = createDocumentationMessageGenerator({
14291
14357
  name: 'infinite-hits',
14292
14358
  connector: true
14293
14359
  });
@@ -14333,7 +14399,7 @@
14333
14399
  }
14334
14400
  var connectInfiniteHits = function connectInfiniteHits(renderFn) {
14335
14401
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
14336
- checkRendering(renderFn, withUsage$e());
14402
+ checkRendering(renderFn, withUsage$f());
14337
14403
  return function(widgetParams) {
14338
14404
  var _ref = widgetParams || {}, _ref_escapeHTML = _ref.escapeHTML, escapeHTML = _ref_escapeHTML === void 0 ? true : _ref_escapeHTML, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
14339
14405
  return items;
@@ -14539,7 +14605,7 @@
14539
14605
  return useConnector(connectInfiniteHits, props, additionalWidgetProperties);
14540
14606
  }
14541
14607
 
14542
- var withUsage$d = createDocumentationMessageGenerator({
14608
+ var withUsage$e = createDocumentationMessageGenerator({
14543
14609
  name: 'menu',
14544
14610
  connector: true
14545
14611
  });
@@ -14557,16 +14623,16 @@
14557
14623
  * **Requirement:** the attribute passed as `attribute` must be present in "attributes for faceting" on the Algolia dashboard or configured as attributesForFaceting via a set settings call to the Algolia API.
14558
14624
  */ var connectMenu = function connectMenu(renderFn) {
14559
14625
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
14560
- checkRendering(renderFn, withUsage$d());
14626
+ checkRendering(renderFn, withUsage$e());
14561
14627
  return function(widgetParams) {
14562
14628
  var _ref = widgetParams || {}, attribute = _ref.attribute, _ref_limit = _ref.limit, limit = _ref_limit === void 0 ? 10 : _ref_limit, _ref_showMore = _ref.showMore, showMore = _ref_showMore === void 0 ? false : _ref_showMore, _ref_showMoreLimit = _ref.showMoreLimit, showMoreLimit = _ref_showMoreLimit === void 0 ? 20 : _ref_showMoreLimit, _ref_sortBy = _ref.sortBy, sortBy = _ref_sortBy === void 0 ? DEFAULT_SORT$1 : _ref_sortBy, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
14563
14629
  return items;
14564
14630
  } : _ref_transformItems;
14565
14631
  if (!attribute) {
14566
- throw new Error(withUsage$d('The `attribute` option is required.'));
14632
+ throw new Error(withUsage$e('The `attribute` option is required.'));
14567
14633
  }
14568
14634
  if (showMore === true && showMoreLimit <= limit) {
14569
- throw new Error(withUsage$d('The `showMoreLimit` option must be greater than `limit`.'));
14635
+ throw new Error(withUsage$e('The `showMoreLimit` option must be greater than `limit`.'));
14570
14636
  }
14571
14637
  var sendEvent;
14572
14638
  var _createURL;
@@ -14736,7 +14802,7 @@
14736
14802
  return typeof value === 'number' && isFinite(value);
14737
14803
  }
14738
14804
 
14739
- var withUsage$c = createDocumentationMessageGenerator({
14805
+ var withUsage$d = createDocumentationMessageGenerator({
14740
14806
  name: 'numeric-menu',
14741
14807
  connector: true
14742
14808
  });
@@ -14755,16 +14821,16 @@
14755
14821
  };
14756
14822
  var connectNumericMenu = function connectNumericMenu(renderFn) {
14757
14823
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
14758
- checkRendering(renderFn, withUsage$c());
14824
+ checkRendering(renderFn, withUsage$d());
14759
14825
  return function(widgetParams) {
14760
14826
  var _ref = widgetParams || {}, _ref_attribute = _ref.attribute, attribute = _ref_attribute === void 0 ? '' : _ref_attribute, _ref_items = _ref.items, items = _ref_items === void 0 ? [] : _ref_items, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(item) {
14761
14827
  return item;
14762
14828
  } : _ref_transformItems;
14763
14829
  if (attribute === '') {
14764
- throw new Error(withUsage$c('The `attribute` option is required.'));
14830
+ throw new Error(withUsage$d('The `attribute` option is required.'));
14765
14831
  }
14766
14832
  if (!items || items.length === 0) {
14767
- throw new Error(withUsage$c('The `items` option expects an array of objects.'));
14833
+ throw new Error(withUsage$d('The `items` option expects an array of objects.'));
14768
14834
  }
14769
14835
  var prepareItems = function prepareItems(state) {
14770
14836
  return items.map(function(param) {
@@ -15079,7 +15145,7 @@
15079
15145
  return Paginator;
15080
15146
  }();
15081
15147
 
15082
- var withUsage$b = createDocumentationMessageGenerator({
15148
+ var withUsage$c = createDocumentationMessageGenerator({
15083
15149
  name: 'pagination',
15084
15150
  connector: true
15085
15151
  });
@@ -15091,7 +15157,7 @@
15091
15157
  * beyond the 1000th hits by default. You can find more information on the [Algolia documentation](https://www.algolia.com/doc/guides/searching/pagination/#pagination-limitations).
15092
15158
  */ var connectPagination = function connectPagination(renderFn) {
15093
15159
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
15094
- checkRendering(renderFn, withUsage$b());
15160
+ checkRendering(renderFn, withUsage$c());
15095
15161
  return function(widgetParams) {
15096
15162
  var _ref = widgetParams || {}, totalPages = _ref.totalPages, _ref_padding = _ref.padding, padding = _ref_padding === void 0 ? 3 : _ref_padding;
15097
15163
  var pager = new Paginator({
@@ -15213,7 +15279,7 @@
15213
15279
  };
15214
15280
  }
15215
15281
 
15216
- var withUsage$a = createDocumentationMessageGenerator({
15282
+ var withUsage$b = createDocumentationMessageGenerator({
15217
15283
  name: 'query-rules',
15218
15284
  connector: true
15219
15285
  });
@@ -15269,7 +15335,7 @@
15269
15335
  }
15270
15336
  var connectQueryRules = function connectQueryRules(render) {
15271
15337
  var unmount = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
15272
- checkRendering(render, withUsage$a());
15338
+ checkRendering(render, withUsage$b());
15273
15339
  return function(widgetParams) {
15274
15340
  var _ref = widgetParams || {}, _ref_trackedFilters = _ref.trackedFilters, trackedFilters = _ref_trackedFilters === void 0 ? {} : _ref_trackedFilters, _ref_transformRuleContexts = _ref.transformRuleContexts, transformRuleContexts = _ref_transformRuleContexts === void 0 ? function(rules) {
15275
15341
  return rules;
@@ -15278,7 +15344,7 @@
15278
15344
  } : _ref_transformItems;
15279
15345
  Object.keys(trackedFilters).forEach(function(facetName) {
15280
15346
  if (typeof trackedFilters[facetName] !== 'function') {
15281
- throw new Error(withUsage$a("'The \"".concat(facetName, '" filter value in the `trackedFilters` option expects a function.')));
15347
+ throw new Error(withUsage$b("'The \"".concat(facetName, '" filter value in the `trackedFilters` option expects a function.')));
15282
15348
  }
15283
15349
  });
15284
15350
  var hasTrackedFilters = Object.keys(trackedFilters).length > 0;
@@ -15354,7 +15420,7 @@
15354
15420
  return useConnector(connectQueryRules, props, additionalWidgetProperties);
15355
15421
  }
15356
15422
 
15357
- var withUsage$9 = createDocumentationMessageGenerator({
15423
+ var withUsage$a = createDocumentationMessageGenerator({
15358
15424
  name: 'range-input',
15359
15425
  connector: true
15360
15426
  }, {
@@ -15378,14 +15444,14 @@
15378
15444
  * information about the min and max bounds for the current result set.
15379
15445
  */ var connectRange = function connectRange(renderFn) {
15380
15446
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
15381
- checkRendering(renderFn, withUsage$9());
15447
+ checkRendering(renderFn, withUsage$a());
15382
15448
  return function(widgetParams) {
15383
15449
  var _ref = widgetParams || {}, _ref_attribute = _ref.attribute, attribute = _ref_attribute === void 0 ? '' : _ref_attribute, minBound = _ref.min, maxBound = _ref.max, _ref_precision = _ref.precision, precision = _ref_precision === void 0 ? 0 : _ref_precision;
15384
15450
  if (!attribute) {
15385
- throw new Error(withUsage$9('The `attribute` option is required.'));
15451
+ throw new Error(withUsage$a('The `attribute` option is required.'));
15386
15452
  }
15387
15453
  if (isFiniteNumber(minBound) && isFiniteNumber(maxBound) && minBound > maxBound) {
15388
- throw new Error(withUsage$9("The `max` option can't be lower than `min`."));
15454
+ throw new Error(withUsage$a("The `max` option can't be lower than `min`."));
15389
15455
  }
15390
15456
  var formatToNumber = function formatToNumber(v) {
15391
15457
  return Number(Number(v).toFixed(precision));
@@ -15605,7 +15671,7 @@
15605
15671
  return useConnector(connectRange, props, additionalWidgetProperties);
15606
15672
  }
15607
15673
 
15608
- var withUsage$8 = createDocumentationMessageGenerator({
15674
+ var withUsage$9 = createDocumentationMessageGenerator({
15609
15675
  name: 'refinement-list',
15610
15676
  connector: true
15611
15677
  });
@@ -15627,19 +15693,19 @@
15627
15693
  * - a `searchForItems()` function to search within the items.
15628
15694
  */ var connectRefinementList = function connectRefinementList(renderFn) {
15629
15695
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
15630
- checkRendering(renderFn, withUsage$8());
15696
+ checkRendering(renderFn, withUsage$9());
15631
15697
  return function(widgetParams) {
15632
15698
  var _ref = widgetParams || {}, attribute = _ref.attribute, _ref_operator = _ref.operator, operator = _ref_operator === void 0 ? 'or' : _ref_operator, _ref_limit = _ref.limit, limit = _ref_limit === void 0 ? 10 : _ref_limit, _ref_showMore = _ref.showMore, showMore = _ref_showMore === void 0 ? false : _ref_showMore, _ref_showMoreLimit = _ref.showMoreLimit, showMoreLimit = _ref_showMoreLimit === void 0 ? 20 : _ref_showMoreLimit, _ref_sortBy = _ref.sortBy, sortBy = _ref_sortBy === void 0 ? DEFAULT_SORT : _ref_sortBy, _ref_escapeFacetValues = _ref.escapeFacetValues, escapeFacetValues = _ref_escapeFacetValues === void 0 ? true : _ref_escapeFacetValues, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
15633
15699
  return items;
15634
15700
  } : _ref_transformItems;
15635
15701
  if (!attribute) {
15636
- throw new Error(withUsage$8('The `attribute` option is required.'));
15702
+ throw new Error(withUsage$9('The `attribute` option is required.'));
15637
15703
  }
15638
15704
  if (!/^(and|or)$/.test(operator)) {
15639
- throw new Error(withUsage$8('The `operator` must one of: `"and"`, `"or"` (got "'.concat(operator, '").')));
15705
+ throw new Error(withUsage$9('The `operator` must one of: `"and"`, `"or"` (got "'.concat(operator, '").')));
15640
15706
  }
15641
15707
  if (showMore === true && showMoreLimit <= limit) {
15642
- throw new Error(withUsage$8('`showMoreLimit` should be greater than `limit`.'));
15708
+ throw new Error(withUsage$9('`showMoreLimit` should be greater than `limit`.'));
15643
15709
  }
15644
15710
  var formatItems = function formatItems(_0) {
15645
15711
  var label = _0.name, value = _0.escapedValue, item = _object_without_properties(_0, [
@@ -15867,19 +15933,19 @@
15867
15933
  return useConnector(connectRefinementList, props, additionalWidgetProperties);
15868
15934
  }
15869
15935
 
15870
- var withUsage$7 = createDocumentationMessageGenerator({
15936
+ var withUsage$8 = createDocumentationMessageGenerator({
15871
15937
  name: 'related-products',
15872
15938
  connector: true
15873
15939
  });
15874
15940
  var connectRelatedProducts = function connectRelatedProducts(renderFn) {
15875
15941
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
15876
- checkRendering(renderFn, withUsage$7());
15942
+ checkRendering(renderFn, withUsage$8());
15877
15943
  return function(widgetParams) {
15878
15944
  var _ref = widgetParams || {}, _ref_escapeHTML = _ref.escapeHTML, escapeHTML = _ref_escapeHTML === void 0 ? true : _ref_escapeHTML, objectIDs = _ref.objectIDs, limit = _ref.limit, threshold = _ref.threshold, fallbackParameters = _ref.fallbackParameters, queryParameters = _ref.queryParameters, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
15879
15945
  return items;
15880
15946
  } : _ref_transformItems;
15881
15947
  if (!objectIDs || objectIDs.length === 0) {
15882
- throw new Error(withUsage$7('The `objectIDs` option is required.'));
15948
+ throw new Error(withUsage$8('The `objectIDs` option is required.'));
15883
15949
  }
15884
15950
  var sendEvent;
15885
15951
  return {
@@ -15955,7 +16021,7 @@
15955
16021
  return useConnector(connectRelatedProducts, props, additionalWidgetProperties);
15956
16022
  }
15957
16023
 
15958
- var withUsage$6 = createDocumentationMessageGenerator({
16024
+ var withUsage$7 = createDocumentationMessageGenerator({
15959
16025
  name: 'search-box',
15960
16026
  connector: true
15961
16027
  });
@@ -15969,7 +16035,7 @@
15969
16035
  * may be impacted by the `queryHook` widget parameter.
15970
16036
  */ var connectSearchBox = function connectSearchBox(renderFn) {
15971
16037
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
15972
- checkRendering(renderFn, withUsage$6());
16038
+ checkRendering(renderFn, withUsage$7());
15973
16039
  return function(widgetParams) {
15974
16040
  var _ref = widgetParams || {}, _ref_queryHook = _ref.queryHook, queryHook = _ref_queryHook === void 0 ? defaultQueryHook : _ref_queryHook;
15975
16041
  var _refine;
@@ -16040,7 +16106,7 @@
16040
16106
  return useConnector(connectSearchBox, props, additionalWidgetProperties);
16041
16107
  }
16042
16108
 
16043
- var withUsage$5 = createDocumentationMessageGenerator({
16109
+ var withUsage$6 = createDocumentationMessageGenerator({
16044
16110
  name: 'sort-by',
16045
16111
  connector: true
16046
16112
  });
@@ -16060,14 +16126,14 @@
16060
16126
  }
16061
16127
  var connectSortBy = function connectSortBy(renderFn) {
16062
16128
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
16063
- checkRendering(renderFn, withUsage$5());
16129
+ checkRendering(renderFn, withUsage$6());
16064
16130
  var connectorState = {};
16065
16131
  return function(widgetParams) {
16066
16132
  var _ref = widgetParams || {}, items = _ref.items, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(x) {
16067
16133
  return x;
16068
16134
  } : _ref_transformItems;
16069
16135
  if (!Array.isArray(items)) {
16070
- throw new Error(withUsage$5('The `items` option expects an array of objects.'));
16136
+ throw new Error(withUsage$6('The `items` option expects an array of objects.'));
16071
16137
  }
16072
16138
  var itemsLookup = {};
16073
16139
  items.forEach(function(item, index) {
@@ -16075,10 +16141,10 @@
16075
16141
  var hasStrategy = 'strategy' in item && item.strategy !== undefined;
16076
16142
  // Validate mutual exclusivity
16077
16143
  if (hasValue && hasStrategy) {
16078
- throw new Error(withUsage$5("Item at index ".concat(index, ' cannot have both "value" and "strategy" properties.')));
16144
+ throw new Error(withUsage$6("Item at index ".concat(index, ' cannot have both "value" and "strategy" properties.')));
16079
16145
  }
16080
16146
  if (!hasValue && !hasStrategy) {
16081
- throw new Error(withUsage$5("Item at index ".concat(index, ' must have either a "value" or "strategy" property.')));
16147
+ throw new Error(withUsage$6("Item at index ".concat(index, ' must have either a "value" or "strategy" property.')));
16082
16148
  }
16083
16149
  var itemValue = getItemValue(item);
16084
16150
  itemsLookup[itemValue] = item;
@@ -16093,7 +16159,7 @@
16093
16159
  return 'strategy' in item && item.strategy;
16094
16160
  });
16095
16161
  if (hasStrategyItems && !instantSearchInstance.compositionID) {
16096
- throw new Error(withUsage$5('Sorting strategies can only be used in composition mode. Please provide a "compositionID" to your InstantSearch instance.'));
16162
+ throw new Error(withUsage$6('Sorting strategies can only be used in composition mode. Please provide a "compositionID" to your InstantSearch instance.'));
16097
16163
  }
16098
16164
  var widgetRenderState = this.getWidgetRenderState(initOptions);
16099
16165
  var currentIndex = widgetRenderState.currentRefinement;
@@ -16206,13 +16272,13 @@
16206
16272
  return useConnector(connectSortBy, props, additionalWidgetProperties);
16207
16273
  }
16208
16274
 
16209
- var withUsage$4 = createDocumentationMessageGenerator({
16275
+ var withUsage$5 = createDocumentationMessageGenerator({
16210
16276
  name: 'stats',
16211
16277
  connector: true
16212
16278
  });
16213
16279
  var connectStats = function connectStats(renderFn) {
16214
16280
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
16215
- checkRendering(renderFn, withUsage$4());
16281
+ checkRendering(renderFn, withUsage$5());
16216
16282
  return function(widgetParams) {
16217
16283
  return {
16218
16284
  $$type: 'ais.stats',
@@ -16271,7 +16337,7 @@
16271
16337
  return useConnector(connectStats, props, additionalWidgetProperties);
16272
16338
  }
16273
16339
 
16274
- var withUsage$3 = createDocumentationMessageGenerator({
16340
+ var withUsage$4 = createDocumentationMessageGenerator({
16275
16341
  name: 'toggle-refinement',
16276
16342
  connector: true
16277
16343
  });
@@ -16322,11 +16388,11 @@
16322
16388
  * - switch between two values.
16323
16389
  */ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
16324
16390
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
16325
- checkRendering(renderFn, withUsage$3());
16391
+ checkRendering(renderFn, withUsage$4());
16326
16392
  return function(widgetParams) {
16327
16393
  var _ref = widgetParams || {}, attribute = _ref.attribute, tmp = _ref.on, userOn = tmp === void 0 ? true : tmp, userOff = _ref.off;
16328
16394
  if (!attribute) {
16329
- throw new Error(withUsage$3('The `attribute` option is required.'));
16395
+ throw new Error(withUsage$4('The `attribute` option is required.'));
16330
16396
  }
16331
16397
  var hasAnOffValue = userOff !== undefined;
16332
16398
  // even though facet values can be numbers and boolean,
@@ -16547,19 +16613,19 @@
16547
16613
  return useConnector(connectToggleRefinement, props, additionalWidgetProperties);
16548
16614
  }
16549
16615
 
16550
- var withUsage$2 = createDocumentationMessageGenerator({
16616
+ var withUsage$3 = createDocumentationMessageGenerator({
16551
16617
  name: 'trending-items',
16552
16618
  connector: true
16553
16619
  });
16554
16620
  var connectTrendingItems = function connectTrendingItems(renderFn) {
16555
16621
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
16556
- checkRendering(renderFn, withUsage$2());
16622
+ checkRendering(renderFn, withUsage$3());
16557
16623
  return function(widgetParams) {
16558
16624
  var _ref = widgetParams || {}, facetName = _ref.facetName, facetValue = _ref.facetValue, limit = _ref.limit, threshold = _ref.threshold, fallbackParameters = _ref.fallbackParameters, queryParameters = _ref.queryParameters, _ref_escapeHTML = _ref.escapeHTML, escapeHTML = _ref_escapeHTML === void 0 ? true : _ref_escapeHTML, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
16559
16625
  return items;
16560
16626
  } : _ref_transformItems;
16561
16627
  if (facetName && !facetValue || !facetName && facetValue) {
16562
- throw new Error(withUsage$2("When you provide facetName (received type ".concat(getObjectType(facetName), "), you must also provide facetValue (received type ").concat(getObjectType(facetValue), ").")));
16628
+ throw new Error(withUsage$3("When you provide facetName (received type ".concat(getObjectType(facetName), "), you must also provide facetValue (received type ").concat(getObjectType(facetValue), ").")));
16563
16629
  }
16564
16630
  var sendEvent;
16565
16631
  return {
@@ -16633,6 +16699,94 @@
16633
16699
  return useConnector(connectTrendingItems, props, additionalWidgetProperties);
16634
16700
  }
16635
16701
 
16702
+ var withUsage$2 = createDocumentationMessageGenerator({
16703
+ name: 'trending-facets',
16704
+ connector: true
16705
+ });
16706
+ var connectTrendingFacets = function connectTrendingFacets(renderFn) {
16707
+ var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
16708
+ checkRendering(renderFn, withUsage$2());
16709
+ return function(widgetParams) {
16710
+ var _ref = widgetParams || {}, facetName = _ref.facetName, limit = _ref.limit, threshold = _ref.threshold, fallbackParameters = _ref.fallbackParameters, queryParameters = _ref.queryParameters, _ref_escapeHTML = _ref.escapeHTML, escapeHTML = _ref_escapeHTML === void 0 ? true : _ref_escapeHTML, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
16711
+ return items;
16712
+ } : _ref_transformItems;
16713
+ if (!facetName) {
16714
+ throw new Error(withUsage$2('The `facetName` option is required.'));
16715
+ }
16716
+ return {
16717
+ dependsOn: 'recommend',
16718
+ $$type: 'ais.trendingFacets',
16719
+ init: function init(initOptions) {
16720
+ renderFn(_object_spread_props(_object_spread({}, this.getWidgetRenderState(initOptions)), {
16721
+ instantSearchInstance: initOptions.instantSearchInstance
16722
+ }), true);
16723
+ },
16724
+ render: function render(renderOptions) {
16725
+ var renderState = this.getWidgetRenderState(renderOptions);
16726
+ renderFn(_object_spread_props(_object_spread({}, renderState), {
16727
+ instantSearchInstance: renderOptions.instantSearchInstance
16728
+ }), false);
16729
+ },
16730
+ getRenderState: function getRenderState(renderState) {
16731
+ return renderState;
16732
+ },
16733
+ getWidgetRenderState: function getWidgetRenderState(param) {
16734
+ var results = param.results;
16735
+ param.helper;
16736
+ param.instantSearchInstance;
16737
+ if (results === null || results === undefined) {
16738
+ return {
16739
+ items: [],
16740
+ widgetParams: widgetParams
16741
+ };
16742
+ }
16743
+ var items = (results.hits || []).map(function(hit) {
16744
+ return {
16745
+ facetName: hit.facetName,
16746
+ facetValue: hit.facetValue,
16747
+ _score: hit._score
16748
+ };
16749
+ });
16750
+ if (escapeHTML) {
16751
+ items = items.map(function(item) {
16752
+ return _object_spread_props(_object_spread({}, item), {
16753
+ facetValue: escape$1(item.facetValue)
16754
+ });
16755
+ });
16756
+ }
16757
+ items = transformItems(items, {
16758
+ results: results
16759
+ });
16760
+ return {
16761
+ items: items,
16762
+ widgetParams: widgetParams
16763
+ };
16764
+ },
16765
+ dispose: function dispose(param) {
16766
+ var recommendState = param.recommendState;
16767
+ unmountFn();
16768
+ return recommendState.removeParams(this.$$id);
16769
+ },
16770
+ getWidgetParameters: function getWidgetParameters(state) {
16771
+ // v4 TrendingFacetsQuery doesn't include queryParameters or
16772
+ // fallbackParameters, but the v5 API and the helper support them.
16773
+ return state.removeParams(this.$$id).addTrendingFacets({
16774
+ facetName: facetName,
16775
+ maxRecommendations: limit,
16776
+ threshold: threshold,
16777
+ fallbackParameters: fallbackParameters ? _object_spread({}, fallbackParameters, escapeHTML ? TAG_PLACEHOLDER : {}) : undefined,
16778
+ queryParameters: _object_spread({}, queryParameters, escapeHTML ? TAG_PLACEHOLDER : {}),
16779
+ $$id: this.$$id
16780
+ });
16781
+ }
16782
+ };
16783
+ };
16784
+ };
16785
+
16786
+ function useTrendingFacets(props, additionalWidgetProperties) {
16787
+ return useConnector(connectTrendingFacets, props, additionalWidgetProperties);
16788
+ }
16789
+
16636
16790
  var withUsage$1 = createDocumentationMessageGenerator({
16637
16791
  name: 'looking-similar',
16638
16792
  connector: true
@@ -17475,6 +17629,28 @@
17475
17629
  d: "M8 17v-7.586l8.293 8.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-8.293-8.293h7.586c0.552 0 1-0.448 1-1s-0.448-1-1-1h-10c-0.552 0-1 0.448-1 1v10c0 0.552 0.448 1 1 1s1-0.448 1-1z"
17476
17630
  }));
17477
17631
  }
17632
+ function AiModeIcon(param) {
17633
+ var createElement = param.createElement;
17634
+ return /*#__PURE__*/ createElement("svg", {
17635
+ className: "ais-AiModeButton-icon",
17636
+ xmlns: "http://www.w3.org/2000/svg",
17637
+ fill: "none",
17638
+ viewBox: "0 0 20 20",
17639
+ width: "16",
17640
+ height: "16",
17641
+ "aria-hidden": "true"
17642
+ }, /*#__PURE__*/ createElement("path", {
17643
+ fill: "currentColor",
17644
+ fillRule: "evenodd",
17645
+ d: "M10 1.875c.27 0 .51.173.594.43l1.593 4.844a1.043 1.043 0 0 0 .664.664l4.844 1.593a.625.625 0 0 1 0 1.188l-4.844 1.593a1.043 1.043 0 0 0-.664.664l-1.593 4.844a.625.625 0 0 1-1.188 0l-1.593-4.844a1.042 1.042 0 0 0-.664-.664l-4.844-1.593a.625.625 0 0 1 0-1.188l4.844-1.593a1.042 1.042 0 0 0 .664-.664l1.593-4.844a.625.625 0 0 1 .594-.43ZM9 7.539A2.292 2.292 0 0 1 7.54 9L4.5 10l3.04 1A2.292 2.292 0 0 1 9 12.46l1 3.04 1-3.04A2.293 2.293 0 0 1 12.46 11l3.04-1-3.04-1A2.292 2.292 0 0 1 11 7.54L10 4.5 9 7.54ZM4.167 1.875c.345 0 .625.28.625.625v3.333a.625.625 0 0 1-1.25 0V2.5c0-.345.28-.625.625-.625ZM15.833 13.542c.345 0 .625.28.625.625V17.5a.625.625 0 1 1-1.25 0v-3.333c0-.345.28-.625.625-.625Z",
17646
+ clipRule: "evenodd"
17647
+ }), /*#__PURE__*/ createElement("path", {
17648
+ fill: "currentColor",
17649
+ fillRule: "evenodd",
17650
+ d: "M1.875 4.167c0-.346.28-.625.625-.625h3.333a.625.625 0 1 1 0 1.25H2.5a.625.625 0 0 1-.625-.625ZM13.542 15.833c0-.345.28-.625.625-.625H17.5a.625.625 0 0 1 0 1.25h-3.333a.625.625 0 0 1-.625-.625Z",
17651
+ clipRule: "evenodd"
17652
+ }));
17653
+ }
17478
17654
  function SearchIcon(param) {
17479
17655
  var createElement = param.createElement;
17480
17656
  return /*#__PURE__*/ createElement("svg", {
@@ -17942,7 +18118,7 @@
17942
18118
  function createAutocompleteSearchComponent(param) {
17943
18119
  var createElement = param.createElement;
17944
18120
  return function AutocompleteSearch(userProps) {
17945
- var inputProps = userProps.inputProps, onClear = userProps.onClear, query = userProps.query, isSearchStalled = userProps.isSearchStalled;
18121
+ var inputProps = userProps.inputProps, onClear = userProps.onClear, query = userProps.query, isSearchStalled = userProps.isSearchStalled, onAiModeClick = userProps.onAiModeClick;
17946
18122
  var inputRef = inputProps.ref;
17947
18123
  return /*#__PURE__*/ createElement("form", {
17948
18124
  className: "ais-AutocompleteForm",
@@ -18000,7 +18176,19 @@
18000
18176
  onClick: onClear
18001
18177
  }, /*#__PURE__*/ createElement(ClearIcon, {
18002
18178
  createElement: createElement
18003
- }))));
18179
+ })), onAiModeClick && /*#__PURE__*/ createElement("button", {
18180
+ className: "ais-AiModeButton",
18181
+ type: "button",
18182
+ title: "AI Mode",
18183
+ onClick: function onClick(e) {
18184
+ e.preventDefault();
18185
+ onAiModeClick();
18186
+ }
18187
+ }, /*#__PURE__*/ createElement(AiModeIcon, {
18188
+ createElement: createElement
18189
+ }), /*#__PURE__*/ createElement("span", {
18190
+ className: "ais-AiModeButton-label"
18191
+ }, "AI Mode"))));
18004
18192
  };
18005
18193
  }
18006
18194
 
@@ -18112,7 +18300,7 @@
18112
18300
  (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.blur();
18113
18301
  }
18114
18302
  var actualDescendant = (_override_activeDescendant = override.activeDescendant) !== null && _override_activeDescendant !== void 0 ? _override_activeDescendant : activeDescendant;
18115
- if (!actualDescendant && override.query) {
18303
+ if (!actualDescendant && override.query !== undefined) {
18116
18304
  onRefine(override.query);
18117
18305
  }
18118
18306
  if (actualDescendant && items.has(actualDescendant)) {
@@ -18765,6 +18953,9 @@
18765
18953
  return null;
18766
18954
  }
18767
18955
  if (part.type === 'text') {
18956
+ if (part.text.startsWith('<context>') && part.text.endsWith('</context>')) {
18957
+ return null;
18958
+ }
18768
18959
  var markdown = We(part.text, {
18769
18960
  createElement: createElement,
18770
18961
  disableParsingRawHTML: true
@@ -18803,6 +18994,7 @@
18803
18994
  setIndexUiState: setIndexUiState,
18804
18995
  addToolResult: boundAddToolResult,
18805
18996
  applyFilters: tool.applyFilters,
18997
+ sendEvent: tool.sendEvent || function() {},
18806
18998
  onClose: onClose
18807
18999
  }));
18808
19000
  }
@@ -19052,7 +19244,7 @@
19052
19244
  });
19053
19245
  return function ChatMessages(userProps) {
19054
19246
  var _lastMessage_parts;
19055
- var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, _userProps_messageClassNames = userProps.messageClassNames, messageClassNames = _userProps_messageClassNames === void 0 ? {} : _userProps_messageClassNames, messageTranslations = userProps.messageTranslations, _userProps_messages = userProps.messages, messages = _userProps_messages === void 0 ? [] : _userProps_messages, MessageComponent = userProps.messageComponent, LoaderComponent = userProps.loaderComponent, ErrorComponent = userProps.errorComponent, ActionsComponent = userProps.actionsComponent, tools = userProps.tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, _userProps_status = userProps.status, status = _userProps_status === void 0 ? 'ready' : _userProps_status, _userProps_hideScrollToBottom = userProps.hideScrollToBottom, hideScrollToBottom = _userProps_hideScrollToBottom === void 0 ? false : _userProps_hideScrollToBottom, onReload = userProps.onReload, onClose = userProps.onClose, userTranslations = userProps.translations, userMessageProps = userProps.userMessageProps, assistantMessageProps = userProps.assistantMessageProps, _userProps_isClearing = userProps.isClearing, isClearing = _userProps_isClearing === void 0 ? false : _userProps_isClearing, onClearTransitionEnd = userProps.onClearTransitionEnd, isScrollAtBottom = userProps.isScrollAtBottom, scrollRef = userProps.scrollRef, contentRef = userProps.contentRef, onScrollToBottom = userProps.onScrollToBottom, suggestionsElement = userProps.suggestionsElement, onFeedback = userProps.onFeedback, feedbackState = userProps.feedbackState, props = _object_without_properties(userProps, [
19247
+ var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, _userProps_messageClassNames = userProps.messageClassNames, messageClassNames = _userProps_messageClassNames === void 0 ? {} : _userProps_messageClassNames, messageTranslations = userProps.messageTranslations, _userProps_messages = userProps.messages, messages = _userProps_messages === void 0 ? [] : _userProps_messages, MessageComponent = userProps.messageComponent, LoaderComponent = userProps.loaderComponent, ErrorComponent = userProps.errorComponent, EmptyComponent = userProps.emptyComponent, ActionsComponent = userProps.actionsComponent, tools = userProps.tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, _userProps_status = userProps.status, status = _userProps_status === void 0 ? 'ready' : _userProps_status, _userProps_hideScrollToBottom = userProps.hideScrollToBottom, hideScrollToBottom = _userProps_hideScrollToBottom === void 0 ? false : _userProps_hideScrollToBottom, onReload = userProps.onReload, onClose = userProps.onClose, sendMessage = userProps.sendMessage, setInput = userProps.setInput, userTranslations = userProps.translations, userMessageProps = userProps.userMessageProps, assistantMessageProps = userProps.assistantMessageProps, _userProps_isClearing = userProps.isClearing, isClearing = _userProps_isClearing === void 0 ? false : _userProps_isClearing, onClearTransitionEnd = userProps.onClearTransitionEnd, isScrollAtBottom = userProps.isScrollAtBottom, scrollRef = userProps.scrollRef, contentRef = userProps.contentRef, onScrollToBottom = userProps.onScrollToBottom, suggestionsElement = userProps.suggestionsElement, onFeedback = userProps.onFeedback, feedbackState = userProps.feedbackState, props = _object_without_properties(userProps, [
19056
19248
  "classNames",
19057
19249
  "messageClassNames",
19058
19250
  "messageTranslations",
@@ -19060,6 +19252,7 @@
19060
19252
  "messageComponent",
19061
19253
  "loaderComponent",
19062
19254
  "errorComponent",
19255
+ "emptyComponent",
19063
19256
  "actionsComponent",
19064
19257
  "tools",
19065
19258
  "indexUiState",
@@ -19068,6 +19261,8 @@
19068
19261
  "hideScrollToBottom",
19069
19262
  "onReload",
19070
19263
  "onClose",
19264
+ "sendMessage",
19265
+ "setInput",
19071
19266
  "translations",
19072
19267
  "userMessageProps",
19073
19268
  "assistantMessageProps",
@@ -19103,6 +19298,7 @@
19103
19298
  var isStreamingWithNoContent = status === 'streaming' && !lastPart;
19104
19299
  var isStreamingNonTextContent = status === 'streaming' && lastPart && !isPartText(lastPart);
19105
19300
  var showLoader = isWaitingForResponse || isStreamingWithNoContent || isStreamingNonTextContent;
19301
+ var showEmpty = messages.length === 0 && !showLoader && !isClearing && status !== 'error';
19106
19302
  var DefaultMessage = MessageComponent || DefaultMessageComponent;
19107
19303
  var DefaultLoader = LoaderComponent || DefaultLoaderComponent;
19108
19304
  var DefaultError = ErrorComponent || DefaultErrorComponent;
@@ -19121,7 +19317,12 @@
19121
19317
  onClearTransitionEnd === null || onClearTransitionEnd === void 0 ? void 0 : onClearTransitionEnd();
19122
19318
  }
19123
19319
  }
19124
- }, messages.map(function(message, index) {
19320
+ }, showEmpty && EmptyComponent && /*#__PURE__*/ createElement(EmptyComponent, {
19321
+ sendMessage: sendMessage,
19322
+ setInput: setInput,
19323
+ status: status,
19324
+ onClose: onClose
19325
+ }), messages.map(function(message, index) {
19125
19326
  return /*#__PURE__*/ createElement(DefaultMessage, {
19126
19327
  key: message.id,
19127
19328
  message: message,
@@ -19568,6 +19769,107 @@
19568
19769
  };
19569
19770
  }
19570
19771
 
19772
+ function createChatSidePanelLayoutComponent(param) {
19773
+ var createElement = param.createElement;
19774
+ var originalMargins = new WeakMap();
19775
+ return function ChatSidePanelLayout(userProps) {
19776
+ var open = userProps.open, maximized = userProps.maximized, headerComponent = userProps.headerComponent, messagesComponent = userProps.messagesComponent, promptComponent = userProps.promptComponent, toggleButtonComponent = userProps.toggleButtonComponent, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, className = userProps.className, parentElement = userProps.parentElement; // Chat state props (destructured to avoid spreading on div)
19777
+ userProps.messages;
19778
+ userProps.status;
19779
+ userProps.isClearing;
19780
+ userProps.clearMessages;
19781
+ userProps.onClearTransitionEnd;
19782
+ userProps.suggestions;
19783
+ userProps.tools;
19784
+ userProps.sendMessage;
19785
+ userProps.regenerate;
19786
+ userProps.stop;
19787
+ userProps.error;
19788
+ var rest = _object_without_properties(userProps, [
19789
+ "open",
19790
+ "maximized",
19791
+ "headerComponent",
19792
+ "messagesComponent",
19793
+ "promptComponent",
19794
+ "toggleButtonComponent",
19795
+ "classNames",
19796
+ "className",
19797
+ "parentElement",
19798
+ "messages",
19799
+ "status",
19800
+ "isClearing",
19801
+ "clearMessages",
19802
+ "onClearTransitionEnd",
19803
+ "suggestions",
19804
+ "tools",
19805
+ "sendMessage",
19806
+ "regenerate",
19807
+ "stop",
19808
+ "error"
19809
+ ]);
19810
+ var element = typeof document !== 'undefined' ? parentElement ? document.querySelector(parentElement) : document.body : null;
19811
+ if (element) {
19812
+ if (open && !originalMargins.has(element)) {
19813
+ originalMargins.set(element, element.style.marginRight);
19814
+ var chatWidth = getComputedStyle(document.documentElement).getPropertyValue('--ais-chat-width').trim() || '22.5rem';
19815
+ var original = originalMargins.get(element);
19816
+ element.style.marginRight = original ? "calc(".concat(original, " + ").concat(chatWidth, ")") : chatWidth;
19817
+ } else if (!open && originalMargins.has(element)) {
19818
+ var saved = originalMargins.get(element);
19819
+ if (saved) {
19820
+ element.style.marginRight = saved;
19821
+ } else {
19822
+ element.style.removeProperty('margin-right');
19823
+ }
19824
+ originalMargins.delete(element);
19825
+ }
19826
+ }
19827
+ return /*#__PURE__*/ createElement("div", _object_spread_props(_object_spread({}, rest), {
19828
+ className: cx('ais-Chat', 'ais-ChatSidePanelLayout', maximized && 'ais-ChatSidePanelLayout--maximized', classNames.root, className)
19829
+ }), /*#__PURE__*/ createElement("div", {
19830
+ className: cx('ais-Chat-container', open && 'ais-Chat-container--open', maximized && 'ais-Chat-container--maximized', classNames.container)
19831
+ }, headerComponent, messagesComponent, promptComponent), /*#__PURE__*/ createElement("div", {
19832
+ className: "ais-Chat-toggleButtonWrapper"
19833
+ }, toggleButtonComponent));
19834
+ };
19835
+ }
19836
+
19837
+ function createChatGreetingComponent(param) {
19838
+ var createElement = param.createElement;
19839
+ return function ChatGreeting(userProps) {
19840
+ var _ref, _ref1;
19841
+ var userTranslations = userProps.translations, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames;
19842
+ userProps.sendMessage;
19843
+ userProps.status;
19844
+ userProps.onClose;
19845
+ userProps.setInput;
19846
+ var banner = userProps.banner, props = _object_without_properties(userProps, [
19847
+ "translations",
19848
+ "classNames",
19849
+ "sendMessage",
19850
+ "status",
19851
+ "onClose",
19852
+ "setInput",
19853
+ "banner"
19854
+ ]);
19855
+ var translations = {
19856
+ heading: (_ref = userTranslations === null || userTranslations === void 0 ? void 0 : userTranslations.heading) !== null && _ref !== void 0 ? _ref : 'How can I help you today?',
19857
+ subheading: (_ref1 = userTranslations === null || userTranslations === void 0 ? void 0 : userTranslations.subheading) !== null && _ref1 !== void 0 ? _ref1 : "Ask me anything about our products, and I'll do my best to assist you."
19858
+ };
19859
+ return /*#__PURE__*/ createElement("div", _object_spread_props(_object_spread({}, props), {
19860
+ className: cx('ais-ChatGreeting', classNames.root, props.className)
19861
+ }), banner && /*#__PURE__*/ createElement("img", {
19862
+ className: cx('ais-ChatGreeting-banner', classNames.banner),
19863
+ src: banner,
19864
+ alt: ""
19865
+ }), /*#__PURE__*/ createElement("h2", {
19866
+ className: cx('ais-ChatGreeting-heading', classNames.heading)
19867
+ }, translations.heading), /*#__PURE__*/ createElement("p", {
19868
+ className: cx('ais-ChatGreeting-subheading', classNames.subheading)
19869
+ }, translations.subheading));
19870
+ };
19871
+ }
19872
+
19571
19873
  function createDefaultEmptyComponent(param) {
19572
19874
  var createElement = param.createElement, Fragment = param.Fragment;
19573
19875
  return function DefaultEmpty() {
@@ -19962,6 +20264,74 @@
19962
20264
  };
19963
20265
  }
19964
20266
 
20267
+ function createTrendingFacetsComponent(param) {
20268
+ var createElement = param.createElement, Fragment = param.Fragment;
20269
+ function DefaultHeader(param) {
20270
+ var _param_classNames = param.classNames, classNames = _param_classNames === void 0 ? {} : _param_classNames, items = param.items, translations = param.translations;
20271
+ if (!items || items.length < 1) {
20272
+ return null;
20273
+ }
20274
+ if (!translations.title) {
20275
+ return null;
20276
+ }
20277
+ return /*#__PURE__*/ createElement("h3", {
20278
+ className: classNames.title
20279
+ }, translations.title);
20280
+ }
20281
+ function DefaultItem(param) {
20282
+ var item = param.item;
20283
+ return /*#__PURE__*/ createElement(Fragment, null, item.facetValue);
20284
+ }
20285
+ function DefaultEmpty() {
20286
+ return /*#__PURE__*/ createElement(Fragment, null, "No results");
20287
+ }
20288
+ return function TrendingFacets(userProps) {
20289
+ var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, tmp = userProps.emptyComponent, EmptyComponent = tmp === void 0 ? DefaultEmpty : tmp, tmp1 = userProps.headerComponent, HeaderComponent = tmp1 === void 0 ? DefaultHeader : tmp1, tmp2 = userProps.itemComponent, ItemComponent = tmp2 === void 0 ? DefaultItem : tmp2, items = userProps.items, status = userProps.status, userTranslations = userProps.translations, props = _object_without_properties(userProps, [
20290
+ "classNames",
20291
+ "emptyComponent",
20292
+ "headerComponent",
20293
+ "itemComponent",
20294
+ "items",
20295
+ "status",
20296
+ "translations"
20297
+ ]);
20298
+ var translations = _object_spread({
20299
+ title: 'Trending'
20300
+ }, userTranslations);
20301
+ var cssClasses = {
20302
+ root: cx('ais-TrendingFacets', classNames.root),
20303
+ emptyRoot: cx('ais-TrendingFacets', classNames.root, 'ais-TrendingFacets--empty', classNames.emptyRoot, props.className),
20304
+ title: cx('ais-TrendingFacets-title', classNames.title),
20305
+ container: cx('ais-TrendingFacets-container', classNames.container),
20306
+ list: cx('ais-TrendingFacets-list', classNames.list),
20307
+ item: cx('ais-TrendingFacets-item', classNames.item)
20308
+ };
20309
+ if (items.length === 0 && status === 'idle') {
20310
+ return /*#__PURE__*/ createElement("section", _object_spread_props(_object_spread({}, props), {
20311
+ className: cssClasses.emptyRoot
20312
+ }), /*#__PURE__*/ createElement(EmptyComponent, null));
20313
+ }
20314
+ return /*#__PURE__*/ createElement("section", _object_spread_props(_object_spread({}, props), {
20315
+ className: cssClasses.root
20316
+ }), /*#__PURE__*/ createElement(HeaderComponent, {
20317
+ classNames: cssClasses,
20318
+ items: items,
20319
+ translations: translations
20320
+ }), /*#__PURE__*/ createElement("div", {
20321
+ className: cssClasses.container
20322
+ }, /*#__PURE__*/ createElement("ol", {
20323
+ className: cssClasses.list
20324
+ }, items.map(function(item, index) {
20325
+ return /*#__PURE__*/ createElement("li", {
20326
+ key: "".concat(item.facetName, ":").concat(item.facetValue, ":").concat(index),
20327
+ className: cssClasses.item
20328
+ }, /*#__PURE__*/ createElement(ItemComponent, {
20329
+ item: item
20330
+ }));
20331
+ }))));
20332
+ };
20333
+ }
20334
+
19965
20335
  function createFilterSuggestionsComponent(param) {
19966
20336
  var createElement = param.createElement;
19967
20337
  var Button = createButtonComponent({
@@ -20525,18 +20895,18 @@
20525
20895
  Fragment: React.Fragment
20526
20896
  });
20527
20897
  function AutocompleteSearch(param) {
20528
- var inputProps = param.inputProps, clearQuery = param.clearQuery, onQueryChange = param.onQueryChange, query = param.query, refine = param.refine, isSearchStalled = param.isSearchStalled;
20898
+ var inputProps = param.inputProps, clearQuery = param.clearQuery, onQueryChange = param.onQueryChange, query = param.query, isSearchStalled = param.isSearchStalled, onAiModeClick = param.onAiModeClick;
20529
20899
  return /*#__PURE__*/ React.createElement(AutocompleteSearchComponent, {
20530
20900
  inputProps: _object_spread_props(_object_spread({}, inputProps), {
20531
20901
  onChange: function onChange(event) {
20532
20902
  var value = event.currentTarget.value;
20533
- refine(value);
20534
20903
  onQueryChange === null || onQueryChange === void 0 ? void 0 : onQueryChange(value);
20535
20904
  }
20536
20905
  }),
20537
20906
  onClear: clearQuery,
20538
20907
  query: query,
20539
- isSearchStalled: isSearchStalled
20908
+ isSearchStalled: isSearchStalled,
20909
+ onAiModeClick: onAiModeClick
20540
20910
  });
20541
20911
  }
20542
20912
 
@@ -20922,7 +21292,7 @@
20922
21292
  }))));
20923
21293
  }
20924
21294
  function InnerAutocomplete(_0) {
20925
- var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, autoFocus = _0.autoFocus, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, props = _object_without_properties(_0, [
21295
+ var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, autoFocus = _0.autoFocus, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, aiMode = _0.aiMode, props = _object_without_properties(_0, [
20926
21296
  "indicesConfig",
20927
21297
  "refineSearchBox",
20928
21298
  "isSearchStalled",
@@ -20941,13 +21311,18 @@
20941
21311
  "autoFocus",
20942
21312
  "detachedMediaQuery",
20943
21313
  "translations",
20944
- "classNames"
21314
+ "classNames",
21315
+ "aiMode"
20945
21316
  ]);
20946
- var _ref;
21317
+ var _indexUiState_query, _ref;
20947
21318
  var _showPromptSuggestions_searchParameters;
20948
21319
  var _useAutocomplete = useAutocomplete({
20949
- transformItems: transformItems
21320
+ transformItems: transformItems,
21321
+ future: {
21322
+ undefinedEmptyQuery: true
21323
+ }
20950
21324
  }), indices = _useAutocomplete.indices, refineAutocomplete = _useAutocomplete.refine, currentRefinement = _useAutocomplete.currentRefinement;
21325
+ var resolvedQuery = currentRefinement !== undefined ? currentRefinement : (_indexUiState_query = indexUiState.query) !== null && _indexUiState_query !== void 0 ? _indexUiState_query : '';
20951
21326
  var _useDetachedMode = useDetachedMode(detachedMediaQuery), isDetached = _useDetachedMode.isDetached, isModalDetached = _useDetachedMode.isModalDetached, isModalOpen = _useDetachedMode.isModalOpen, setIsModalOpen = _useDetachedMode.setIsModalOpen;
20952
21327
  var previousIsDetachedRef = React.useRef(isDetached);
20953
21328
  var _useStorage = useStorage({
@@ -21155,9 +21530,20 @@
21155
21530
  onQueryChange: function onQueryChange(query) {
21156
21531
  refineAutocomplete(query);
21157
21532
  },
21158
- query: currentRefinement || indexUiState.query || '',
21159
- refine: refineSearchBox,
21160
- isSearchStalled: isSearchStalled
21533
+ query: resolvedQuery,
21534
+ isSearchStalled: isSearchStalled,
21535
+ onAiModeClick: aiMode ? function() {
21536
+ if (chatRenderState) {
21537
+ var _chatRenderState_setOpen;
21538
+ (_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
21539
+ if (resolvedQuery.trim()) {
21540
+ var _chatRenderState_sendMessage;
21541
+ (_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
21542
+ text: resolvedQuery
21543
+ });
21544
+ }
21545
+ }
21546
+ } : undefined
21161
21547
  });
21162
21548
  var panelContent = /*#__PURE__*/ React.createElement(AutocompletePanel, getPanelProps(), PanelComponent ? /*#__PURE__*/ React.createElement(PanelComponent, {
21163
21549
  elements: elements,
@@ -21176,7 +21562,7 @@
21176
21562
  rootRef: rootRef,
21177
21563
  classNames: classNames
21178
21564
  }), /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
21179
- query: currentRefinement || indexUiState.query || '',
21565
+ query: resolvedQuery,
21180
21566
  placeholder: placeholder,
21181
21567
  classNames: classNames,
21182
21568
  onClick: function onClick() {
@@ -21350,15 +21736,27 @@
21350
21736
  Fragment: React.Fragment
21351
21737
  });
21352
21738
 
21739
+ var ChatSidePanelLayout = createChatSidePanelLayoutComponent({
21740
+ createElement: React.createElement,
21741
+ Fragment: React.Fragment
21742
+ });
21743
+
21744
+ var ChatGreeting = createChatGreetingComponent({
21745
+ createElement: React.createElement
21746
+ });
21747
+
21353
21748
  function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
21354
21749
  var Button = createButtonComponent({
21355
21750
  createElement: React.createElement
21356
21751
  });
21357
21752
  function SearchLayoutComponent(param) {
21358
- var message = param.message, applyFilters = param.applyFilters, onClose = param.onClose;
21753
+ var message = param.message, applyFilters = param.applyFilters, onClose = param.onClose, sendEvent = param.sendEvent;
21754
+ var _ref;
21755
+ var _output_hits;
21359
21756
  var input = message === null || message === void 0 ? void 0 : message.input;
21360
21757
  var output = message === null || message === void 0 ? void 0 : message.output;
21361
- var items = (output === null || output === void 0 ? void 0 : output.hits) || [];
21758
+ var hitsWithAbsolutePosition = addAbsolutePosition((output === null || output === void 0 ? void 0 : output.hits) || [], 0, ((_ref = input === null || input === void 0 ? void 0 : input.number_of_results) !== null && _ref !== void 0 ? _ref : output === null || output === void 0 ? void 0 : (_output_hits = output.hits) === null || _output_hits === void 0 ? void 0 : _output_hits.length) || 5);
21759
+ var items = addQueryID(hitsWithAbsolutePosition, output === null || output === void 0 ? void 0 : output.queryID);
21362
21760
  var MemoedHeaderComponent = React.useMemo(function() {
21363
21761
  return function(props) {
21364
21762
  return /*#__PURE__*/ React.createElement(HeaderComponent, _object_spread({
@@ -21379,7 +21777,7 @@
21379
21777
  return /*#__PURE__*/ React.createElement(Carousel, {
21380
21778
  items: items,
21381
21779
  itemComponent: itemComponent,
21382
- sendEvent: function sendEvent() {},
21780
+ sendEvent: sendEvent,
21383
21781
  showNavigation: false,
21384
21782
  headerComponent: MemoedHeaderComponent
21385
21783
  });
@@ -21447,8 +21845,11 @@
21447
21845
  var _obj;
21448
21846
  return _obj = {}, _define_property(_obj, SearchIndexToolType$1, createCarouselTool(true, itemComponent, getSearchPageURL)), _define_property(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _define_property(_obj, MemorizeToolType, {}), _define_property(_obj, MemorySearchToolType, {}), _define_property(_obj, PonderToolType, {}), _obj;
21449
21847
  }
21450
- function Chat(_0) {
21451
- var userTools = _0.tools, toggleButtonProps = _0.toggleButtonProps, headerProps = _0.headerProps, messagesProps = _0.messagesProps, promptProps = _0.promptProps, itemComponent = _0.itemComponent, layoutComponent = _0.layoutComponent, toggleButtonComponent = _0.toggleButtonComponent, toggleButtonIconComponent = _0.toggleButtonIconComponent, headerComponent = _0.headerComponent, headerTitleIconComponent = _0.headerTitleIconComponent, headerCloseIconComponent = _0.headerCloseIconComponent, headerMinimizeIconComponent = _0.headerMinimizeIconComponent, headerMaximizeIconComponent = _0.headerMaximizeIconComponent, messagesLoaderComponent = _0.messagesLoaderComponent, messagesErrorComponent = _0.messagesErrorComponent, promptComponent = _0.promptComponent, promptHeaderComponent = _0.promptHeaderComponent, promptFooterComponent = _0.promptFooterComponent, assistantMessageLeadingComponent = _0.assistantMessageLeadingComponent, assistantMessageFooterComponent = _0.assistantMessageFooterComponent, userMessageLeadingComponent = _0.userMessageLeadingComponent, userMessageFooterComponent = _0.userMessageFooterComponent, actionsComponent = _0.actionsComponent, suggestionsComponent = _0.suggestionsComponent, classNames = _0.classNames, _0_translations = _0.translations, translations = _0_translations === void 0 ? {} : _0_translations, title = _0.title, getSearchPageURL = _0.getSearchPageURL, props = _object_without_properties(_0, [
21848
+ function ChatInner(_0, _1) {
21849
+ var _ref = [
21850
+ _0,
21851
+ _1
21852
+ ], _ref1 = _to_array(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, toggleButtonProps = _ref2.toggleButtonProps, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, toggleButtonComponent = _ref2.toggleButtonComponent, toggleButtonIconComponent = _ref2.toggleButtonIconComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent, messagesLoaderComponent = _ref2.messagesLoaderComponent, messagesErrorComponent = _ref2.messagesErrorComponent, promptComponent = _ref2.promptComponent, promptHeaderComponent = _ref2.promptHeaderComponent, promptFooterComponent = _ref2.promptFooterComponent, assistantMessageLeadingComponent = _ref2.assistantMessageLeadingComponent, assistantMessageFooterComponent = _ref2.assistantMessageFooterComponent, userMessageLeadingComponent = _ref2.userMessageLeadingComponent, userMessageFooterComponent = _ref2.userMessageFooterComponent, emptyComponent = _ref2.emptyComponent, actionsComponent = _ref2.actionsComponent, suggestionsComponent = _ref2.suggestionsComponent, classNames = _ref2.classNames, _ref_translations = _ref2.translations, translations = _ref_translations === void 0 ? {} : _ref_translations, title = _ref2.title, getSearchPageURL = _ref2.getSearchPageURL, props = _object_without_properties(_ref2, [
21452
21853
  "tools",
21453
21854
  "toggleButtonProps",
21454
21855
  "headerProps",
@@ -21472,13 +21873,14 @@
21472
21873
  "assistantMessageFooterComponent",
21473
21874
  "userMessageLeadingComponent",
21474
21875
  "userMessageFooterComponent",
21876
+ "emptyComponent",
21475
21877
  "actionsComponent",
21476
21878
  "suggestionsComponent",
21477
21879
  "classNames",
21478
21880
  "translations",
21479
21881
  "title",
21480
21882
  "getSearchPageURL"
21481
- ]);
21883
+ ]), _rest1 = _sliced_to_array(_rest, 1), ref = _rest1[0];
21482
21884
  var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
21483
21885
  var _useInstantSearch = useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, setIndexUiState = _useInstantSearch.setIndexUiState;
21484
21886
  var _useState = _sliced_to_array(React.useState(false), 2), maximized = _useState[0], setMaximized = _useState[1];
@@ -21499,6 +21901,15 @@
21499
21901
  tools: tools
21500
21902
  }));
21501
21903
  var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, isClearing = chatState.isClearing, clearMessages = chatState.clearMessages, onClearTransitionEnd = chatState.onClearTransitionEnd, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState;
21904
+ React.useImperativeHandle(ref, function() {
21905
+ return {
21906
+ setOpen: setOpen,
21907
+ sendMessage: function sendMessage1(params) {
21908
+ return sendMessage(params);
21909
+ },
21910
+ setInput: setInput
21911
+ };
21912
+ });
21502
21913
  var wasOpenRef = React.useRef(false);
21503
21914
  React.useEffect(function() {
21504
21915
  var shouldFocusPrompt = !wasOpenRef.current && open;
@@ -21561,6 +21972,8 @@
21561
21972
  onClose: function onClose() {
21562
21973
  return setOpen(false);
21563
21974
  },
21975
+ sendMessage: sendMessage,
21976
+ setInput: setInput,
21564
21977
  onFeedback: onFeedback,
21565
21978
  feedbackState: feedbackState,
21566
21979
  messages: messages,
@@ -21575,6 +21988,7 @@
21575
21988
  onScrollToBottom: scrollToBottom,
21576
21989
  loaderComponent: messagesLoaderComponent,
21577
21990
  errorComponent: messagesErrorComponent,
21991
+ emptyComponent: emptyComponent,
21578
21992
  actionsComponent: actionsComponent,
21579
21993
  assistantMessageProps: _object_spread({
21580
21994
  leadingComponent: assistantMessageLeadingComponent,
@@ -21618,6 +22032,7 @@
21618
22032
  classNames: classNames
21619
22033
  });
21620
22034
  }
22035
+ var Chat = /*#__PURE__*/ React.forwardRef(ChatInner);
21621
22036
 
21622
22037
  function ClearRefinements$1(_0) {
21623
22038
  var _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, _0_disabled = _0.disabled, disabled = _0_disabled === void 0 ? false : _0_disabled, _0_onClick = _0.onClick, onClick = _0_onClick === void 0 ? function() {} : _0_onClick, translations = _0.translations, props = _object_without_properties(_0, [
@@ -22696,8 +23111,30 @@
22696
23111
  repeatCount: "indefinite"
22697
23112
  })))));
22698
23113
  }
23114
+ function DefaultAiModeIcon(param) {
23115
+ var classNames = param.classNames;
23116
+ return /*#__PURE__*/ React.createElement("svg", {
23117
+ className: cx('ais-AiModeButton-icon', classNames.aiModeIcon),
23118
+ xmlns: "http://www.w3.org/2000/svg",
23119
+ fill: "none",
23120
+ viewBox: "0 0 20 20",
23121
+ width: "16",
23122
+ height: "16",
23123
+ "aria-hidden": "true"
23124
+ }, /*#__PURE__*/ React.createElement("path", {
23125
+ fill: "currentColor",
23126
+ fillRule: "evenodd",
23127
+ d: "M10 1.875c.27 0 .51.173.594.43l1.593 4.844a1.043 1.043 0 0 0 .664.664l4.844 1.593a.625.625 0 0 1 0 1.188l-4.844 1.593a1.043 1.043 0 0 0-.664.664l-1.593 4.844a.625.625 0 0 1-1.188 0l-1.593-4.844a1.042 1.042 0 0 0-.664-.664l-4.844-1.593a.625.625 0 0 1 0-1.188l4.844-1.593a1.042 1.042 0 0 0 .664-.664l1.593-4.844a.625.625 0 0 1 .594-.43ZM9 7.539A2.292 2.292 0 0 1 7.54 9L4.5 10l3.04 1A2.292 2.292 0 0 1 9 12.46l1 3.04 1-3.04A2.293 2.293 0 0 1 12.46 11l3.04-1-3.04-1A2.292 2.292 0 0 1 11 7.54L10 4.5 9 7.54ZM4.167 1.875c.345 0 .625.28.625.625v3.333a.625.625 0 0 1-1.25 0V2.5c0-.345.28-.625.625-.625ZM15.833 13.542c.345 0 .625.28.625.625V17.5a.625.625 0 1 1-1.25 0v-3.333c0-.345.28-.625.625-.625Z",
23128
+ clipRule: "evenodd"
23129
+ }), /*#__PURE__*/ React.createElement("path", {
23130
+ fill: "currentColor",
23131
+ fillRule: "evenodd",
23132
+ d: "M1.875 4.167c0-.346.28-.625.625-.625h3.333a.625.625 0 1 1 0 1.25H2.5a.625.625 0 0 1-.625-.625ZM13.542 15.833c0-.345.28-.625.625-.625H17.5a.625.625 0 0 1 0 1.25h-3.333a.625.625 0 0 1-.625-.625Z",
23133
+ clipRule: "evenodd"
23134
+ }));
23135
+ }
22699
23136
  function SearchBox$1(_0) {
22700
- var formRef = _0.formRef, inputRef = _0.inputRef, inputProps = _0.inputProps, isSearchStalled = _0.isSearchStalled, onChange = _0.onChange, onReset = _0.onReset, onSubmit = _0.onSubmit, _0_placeholder = _0.placeholder, placeholder = _0_placeholder === void 0 ? '' : _0_placeholder, value = _0.value, autoFocus = _0.autoFocus, tmp = _0.resetIconComponent, ResetIcon = tmp === void 0 ? DefaultResetIcon : tmp, tmp1 = _0.submitIconComponent, SubmitIcon = tmp1 === void 0 ? DefaultSubmitIcon : tmp1, tmp2 = _0.loadingIconComponent, LoadingIcon = tmp2 === void 0 ? DefaultLoadingIcon : tmp2, _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, translations = _0.translations, props = _object_without_properties(_0, [
23137
+ var formRef = _0.formRef, inputRef = _0.inputRef, inputProps = _0.inputProps, isSearchStalled = _0.isSearchStalled, onChange = _0.onChange, onReset = _0.onReset, onSubmit = _0.onSubmit, _0_placeholder = _0.placeholder, placeholder = _0_placeholder === void 0 ? '' : _0_placeholder, value = _0.value, autoFocus = _0.autoFocus, tmp = _0.resetIconComponent, ResetIcon = tmp === void 0 ? DefaultResetIcon : tmp, tmp1 = _0.submitIconComponent, SubmitIcon = tmp1 === void 0 ? DefaultSubmitIcon : tmp1, tmp2 = _0.loadingIconComponent, LoadingIcon = tmp2 === void 0 ? DefaultLoadingIcon : tmp2, tmp3 = _0.aiModeIconComponent, AiModeIcon = tmp3 === void 0 ? DefaultAiModeIcon : tmp3, onAiModeClick = _0.onAiModeClick, _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, translations = _0.translations, props = _object_without_properties(_0, [
22701
23138
  "formRef",
22702
23139
  "inputRef",
22703
23140
  "inputProps",
@@ -22711,6 +23148,8 @@
22711
23148
  "resetIconComponent",
22712
23149
  "submitIconComponent",
22713
23150
  "loadingIconComponent",
23151
+ "aiModeIconComponent",
23152
+ "onAiModeClick",
22714
23153
  "classNames",
22715
23154
  "translations"
22716
23155
  ]);
@@ -22770,7 +23209,19 @@
22770
23209
  hidden: value.length === 0 || isSearchStalled
22771
23210
  }, /*#__PURE__*/ React.createElement(ResetIcon, {
22772
23211
  classNames: classNames
22773
- })), /*#__PURE__*/ React.createElement("span", {
23212
+ })), onAiModeClick && /*#__PURE__*/ React.createElement("button", {
23213
+ className: cx('ais-AiModeButton', classNames.aiModeButton),
23214
+ type: "button",
23215
+ title: translations.aiModeButtonTitle || 'AI Mode',
23216
+ onClick: function onClick(e) {
23217
+ e.preventDefault();
23218
+ onAiModeClick();
23219
+ }
23220
+ }, /*#__PURE__*/ React.createElement(AiModeIcon, {
23221
+ classNames: classNames
23222
+ }), /*#__PURE__*/ React.createElement("span", {
23223
+ className: "ais-AiModeButton-label"
23224
+ }, translations.aiModeButtonTitle || 'AI Mode')), /*#__PURE__*/ React.createElement("span", {
22774
23225
  className: cx('ais-SearchBox-loadingIndicator', classNames.loadingIndicator),
22775
23226
  hidden: !isSearchStalled
22776
23227
  }, /*#__PURE__*/ React.createElement(LoadingIcon, {
@@ -22934,10 +23385,11 @@
22934
23385
  }
22935
23386
 
22936
23387
  function SearchBox(_0) {
22937
- var queryHook = _0.queryHook, _0_searchAsYouType = _0.searchAsYouType, searchAsYouType = _0_searchAsYouType === void 0 ? true : _0_searchAsYouType, _0_ignoreCompositionEvents = _0.ignoreCompositionEvents, ignoreCompositionEvents = _0_ignoreCompositionEvents === void 0 ? false : _0_ignoreCompositionEvents, translations = _0.translations, props = _object_without_properties(_0, [
23388
+ var queryHook = _0.queryHook, _0_searchAsYouType = _0.searchAsYouType, searchAsYouType = _0_searchAsYouType === void 0 ? true : _0_searchAsYouType, _0_ignoreCompositionEvents = _0.ignoreCompositionEvents, ignoreCompositionEvents = _0_ignoreCompositionEvents === void 0 ? false : _0_ignoreCompositionEvents, aiMode = _0.aiMode, translations = _0.translations, props = _object_without_properties(_0, [
22938
23389
  "queryHook",
22939
23390
  "searchAsYouType",
22940
23391
  "ignoreCompositionEvents",
23392
+ "aiMode",
22941
23393
  "translations"
22942
23394
  ]);
22943
23395
  var _useSearchBox = useSearchBox({
@@ -22945,6 +23397,7 @@
22945
23397
  }, {
22946
23398
  $$widgetType: 'ais.searchBox'
22947
23399
  }), query = _useSearchBox.query, refine = _useSearchBox.refine, isSearchStalled = _useSearchBox.isSearchStalled;
23400
+ var indexRenderState = useInstantSearch().indexRenderState;
22948
23401
  var _useState = _sliced_to_array(React.useState(query), 2), inputValue = _useState[0], setInputValue = _useState[1];
22949
23402
  var inputRef = React.useRef(null);
22950
23403
  function setQuery(newQuery) {
@@ -22984,10 +23437,24 @@
22984
23437
  onChange: onChange,
22985
23438
  onReset: onReset,
22986
23439
  onSubmit: onSubmit,
23440
+ onAiModeClick: aiMode ? function() {
23441
+ var chatRenderState = indexRenderState.chat;
23442
+ if (chatRenderState) {
23443
+ var _chatRenderState_setOpen;
23444
+ (_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
23445
+ if (inputValue.trim()) {
23446
+ var _chatRenderState_sendMessage;
23447
+ (_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
23448
+ text: inputValue
23449
+ });
23450
+ }
23451
+ }
23452
+ } : undefined,
22987
23453
  value: inputValue,
22988
23454
  translations: _object_spread({
22989
23455
  submitButtonTitle: 'Submit the search query',
22990
- resetButtonTitle: 'Clear the search query'
23456
+ resetButtonTitle: 'Clear the search query',
23457
+ aiModeButtonTitle: 'AI Mode'
22991
23458
  }, translations)
22992
23459
  };
22993
23460
  return /*#__PURE__*/ React.createElement(SearchBox$1, _object_spread({}, props, uiProps));
@@ -23257,6 +23724,45 @@
23257
23724
  return /*#__PURE__*/ React.createElement(TrendingItemsUiComponent, _object_spread({}, props, uiProps));
23258
23725
  }
23259
23726
 
23727
+ var TrendingFacetsUiComponent = createTrendingFacetsComponent({
23728
+ createElement: React.createElement,
23729
+ Fragment: React.Fragment
23730
+ });
23731
+ function TrendingFacets(_0) {
23732
+ var facetName = _0.facetName, limit = _0.limit, threshold = _0.threshold, fallbackParameters = _0.fallbackParameters, queryParameters = _0.queryParameters, escapeHTML = _0.escapeHTML, transformItems = _0.transformItems, itemComponent = _0.itemComponent, headerComponent = _0.headerComponent, emptyComponent = _0.emptyComponent, props = _object_without_properties(_0, [
23733
+ "facetName",
23734
+ "limit",
23735
+ "threshold",
23736
+ "fallbackParameters",
23737
+ "queryParameters",
23738
+ "escapeHTML",
23739
+ "transformItems",
23740
+ "itemComponent",
23741
+ "headerComponent",
23742
+ "emptyComponent"
23743
+ ]);
23744
+ var status = useInstantSearch().status;
23745
+ var items = useTrendingFacets({
23746
+ facetName: facetName,
23747
+ limit: limit,
23748
+ threshold: threshold,
23749
+ fallbackParameters: fallbackParameters,
23750
+ queryParameters: queryParameters,
23751
+ escapeHTML: escapeHTML,
23752
+ transformItems: transformItems
23753
+ }, {
23754
+ $$widgetType: 'ais.trendingFacets'
23755
+ }).items;
23756
+ var uiProps = {
23757
+ items: items,
23758
+ itemComponent: itemComponent,
23759
+ headerComponent: headerComponent,
23760
+ emptyComponent: emptyComponent,
23761
+ status: status
23762
+ };
23763
+ return /*#__PURE__*/ React.createElement(TrendingFacetsUiComponent, _object_spread({}, props, uiProps));
23764
+ }
23765
+
23260
23766
  var FilterSuggestionsUiComponent = createFilterSuggestionsComponent({
23261
23767
  createElement: React.createElement,
23262
23768
  Fragment: React.Fragment
@@ -23300,8 +23806,10 @@
23300
23806
  exports.Breadcrumb = Breadcrumb;
23301
23807
  exports.Carousel = Carousel;
23302
23808
  exports.Chat = Chat;
23809
+ exports.ChatGreeting = ChatGreeting;
23303
23810
  exports.ChatInlineLayout = ChatInlineLayout;
23304
23811
  exports.ChatOverlayLayout = ChatOverlayLayout;
23812
+ exports.ChatSidePanelLayout = ChatSidePanelLayout;
23305
23813
  exports.ClearRefinements = ClearRefinements;
23306
23814
  exports.Configure = Configure;
23307
23815
  exports.CurrentRefinements = CurrentRefinements;
@@ -23338,6 +23846,7 @@
23338
23846
  exports.SortBy = SortBy;
23339
23847
  exports.Stats = Stats;
23340
23848
  exports.ToggleRefinement = ToggleRefinement;
23849
+ exports.TrendingFacets = TrendingFacets;
23341
23850
  exports.TrendingItems = TrendingItems;
23342
23851
  exports.createDefaultTools = createDefaultTools;
23343
23852
  exports.getServerState = getServerState;
@@ -23373,6 +23882,7 @@
23373
23882
  exports.useStats = useStats;
23374
23883
  exports.useStickToBottom = useStickToBottom;
23375
23884
  exports.useToggleRefinement = useToggleRefinement;
23885
+ exports.useTrendingFacets = useTrendingFacets;
23376
23886
  exports.useTrendingItems = useTrendingItems;
23377
23887
  exports.version = version$2;
23378
23888
  exports.wrapPromiseWithState = wrapPromiseWithState;