@docsearch/js 5.0.0-beta.0 → 5.0.0-beta.2

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.
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @docsearch/js 5.0.0-beta.0 (UNRELEASED 1b6607c) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
1
+ /*! @docsearch/js 5.0.0-beta.2 (UNRELEASED c7e1a88) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
2
2
  //#region \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp$1 = Object.defineProperty;
@@ -1188,7 +1188,7 @@ function DocSearchButtonKey({ reactsToKey, children }) {
1188
1188
 
1189
1189
  //#endregion
1190
1190
  //#region ../docsearch-react/dist/esm/version.js
1191
- const version$2 = "5.0.0-beta.0";
1191
+ const version$2 = "5.0.0-beta.2";
1192
1192
 
1193
1193
  //#endregion
1194
1194
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/OverloadYield.js
@@ -12295,7 +12295,7 @@ const BOUNDARY_OFFSET = 2;
12295
12295
  *
12296
12296
  * Documentation: [Base UI Menu](https://base-ui.com/react/components/menu)
12297
12297
  */
12298
- const MenuTrigger$2 = fastComponentRef(function MenuTrigger(componentProps, forwardedRef) {
12298
+ const MenuTrigger$1 = fastComponentRef(function MenuTrigger(componentProps, forwardedRef) {
12299
12299
  var _handle$store;
12300
12300
  const { render, className, style, disabled: disabledProp = false, nativeButton = true, id: idProp, openOnHover: openOnHoverProp, delay = 100, closeDelay = 0, handle, payload } = componentProps, elementProps = _objectWithoutProperties$5(componentProps, _excluded$23);
12301
12301
  const rootContext = useMenuRootContext(true);
@@ -12496,7 +12496,7 @@ function useMenuParent() {
12496
12496
  }
12497
12497
 
12498
12498
  //#endregion
12499
- //#region ../docsearch-react/dist/esm/normalizeDocSearchIndexes-DAzlMybx.js
12499
+ //#region ../docsearch-react/dist/esm/normalizeDocSearchIndexes-D8P3VEXa.js
12500
12500
  init_compat();
12501
12501
  function capitalize(text) {
12502
12502
  return `${text.charAt(0).toLocaleUpperCase()}${text.substring(1)}`;
@@ -12557,6 +12557,10 @@ function identity(x) {
12557
12557
  function isModifierEvent(event) {
12558
12558
  return event.button === 1 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
12559
12559
  }
12560
+ function isQueryEmpty(query) {
12561
+ if (!query || query.trim().length === 0) return true;
12562
+ return false;
12563
+ }
12560
12564
  function noop$2(..._args) {}
12561
12565
  const regexHighlightTags = /(<mark>|<\/mark>)/g;
12562
12566
  const regexHasHighlightTags = RegExp(regexHighlightTags.source);
@@ -12672,12 +12676,28 @@ function getFacetLabel(facet) {
12672
12676
  if (facet.label) return facet.label;
12673
12677
  return facet.key.replace(/[._-]+/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
12674
12678
  }
12675
- const _excluded$6$12 = ["className", "type"];
12679
+ function deriveDefaultSelectedFacetsFromIndex(indices) {
12680
+ const defaultFacets = {};
12681
+ for (const index of indices) {
12682
+ var _index$searchParamete;
12683
+ const facetFilters = (_index$searchParamete = index.searchParameters) === null || _index$searchParamete === void 0 ? void 0 : _index$searchParamete.facetFilters;
12684
+ for (const facetFilter of Array.isArray(facetFilters) ? facetFilters : [facetFilters]) {
12685
+ if (typeof facetFilter !== "string") continue;
12686
+ const separatorIndex = facetFilter.indexOf(":");
12687
+ if (separatorIndex <= 0) continue;
12688
+ const key = facetFilter.slice(0, separatorIndex);
12689
+ const value = facetFilter.slice(separatorIndex + 1);
12690
+ if (key && value) defaultFacets[key] = value;
12691
+ }
12692
+ }
12693
+ return defaultFacets;
12694
+ }
12695
+ const _excluded$6$11 = ["className", "type"];
12676
12696
  function Chip({ children }) {
12677
12697
  return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Chip" }, children);
12678
12698
  }
12679
12699
  function ChipDismiss(_ref) {
12680
- let { className, type = "button" } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$6$12);
12700
+ let { className, type = "button" } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$6$11);
12681
12701
  const cn = `DocSearch-Chip-Dismiss${className ? ` ${className}` : ""}`;
12682
12702
  return /* @__PURE__ */ En.createElement("button", _objectSpread2$2({
12683
12703
  type,
@@ -12701,12 +12721,14 @@ function Menu$1(_ref) {
12701
12721
  let props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
12702
12722
  return /* @__PURE__ */ En.createElement(MenuRoot, props);
12703
12723
  }
12704
- function MenuTrigger$1(_ref2) {
12724
+ Menu$1.Trigger = En.forwardRef((_ref2, ref) => {
12705
12725
  let { className } = _ref2, props = _objectWithoutProperties$6(_ref2, _excluded$5$13);
12706
12726
  const cn = `DocSearch-Menu-Trigger${className ? ` ${className}` : ""}`;
12707
- return /* @__PURE__ */ En.createElement(MenuTrigger$2, _objectSpread2$2({ className: cn }, props));
12708
- }
12709
- Menu$1.Trigger = MenuTrigger$1;
12727
+ return /* @__PURE__ */ En.createElement(MenuTrigger$1, _objectSpread2$2({
12728
+ className: cn,
12729
+ ref
12730
+ }, props));
12731
+ });
12710
12732
  function MenuPopup(_ref3) {
12711
12733
  let { align = "start", alignOffset = 0, side = "bottom", sideOffset = 4, collisionBoundary = "clipping-ancestors", container } = _ref3, props = _objectWithoutProperties$6(_ref3, _excluded2$5);
12712
12734
  return /* @__PURE__ */ En.createElement(MenuPortal, { container }, /* @__PURE__ */ En.createElement(MenuPositioner, {
@@ -12774,9 +12796,10 @@ const SelectedFacetChip = En.memo(function SelectedFacetChip({ facetKey, facetLa
12774
12796
  });
12775
12797
  const FacetBar = En.memo(function FacetBar({ facets, selections, onSelectionChange, clearSelections, translations = {} }) {
12776
12798
  const { defaultValueLabel = "All", facetMenuTriggerAriaLabel = "selected", clearAllLabel = "Clear all", facetsAriaLabel = "Search filters", selectedFacetsAriaLabel = "Selected search filters", clearFacetAriaLabel = "Clear filter:" } = translations;
12799
+ const visibleFacetKeys = En.useMemo(() => new Set(facets.map((f) => f.key)), [facets]);
12777
12800
  const selectionsToDisplay = En.useMemo(() => {
12778
- return Object.entries(selections).filter(([_, value]) => Boolean(value));
12779
- }, [selections]);
12801
+ return Object.entries(selections).filter(([key, value]) => Boolean(value) && visibleFacetKeys.has(key));
12802
+ }, [selections, visibleFacetKeys]);
12780
12803
  const triggerRefs = En.useRef(/* @__PURE__ */ new Map());
12781
12804
  const registerTrigger = En.useCallback((facetKey, el) => {
12782
12805
  if (el) triggerRefs.current.set(facetKey, el);
@@ -12837,7 +12860,7 @@ const FacetBar = En.memo(function FacetBar({ facets, selections, onSelectionChan
12837
12860
  onClick: handleClearAll
12838
12861
  }, clearAllLabel)));
12839
12862
  });
12840
- const _excluded$4$18 = [
12863
+ const _excluded$4$19 = [
12841
12864
  "actionsBeforeClose",
12842
12865
  "autoFocus",
12843
12866
  "clearButtonAriaLabel",
@@ -12856,7 +12879,7 @@ const _excluded$4$18 = [
12856
12879
  "state"
12857
12880
  ];
12858
12881
  function SearchBoxForm(_ref) {
12859
- let { actionsBeforeClose, autoFocus, clearButtonAriaLabel, clearButtonTitle, closeButtonAriaLabel, closeButtonText, hideInput, inputOverlay, inputProps, inputRef, isFromSelection, leadingElement, onClose, placeholder, searchInputLabel, state } = _ref, autocomplete = _objectWithoutProperties$6(_ref, _excluded$4$18);
12882
+ let { actionsBeforeClose, autoFocus, clearButtonAriaLabel, clearButtonTitle, closeButtonAriaLabel, closeButtonText, hideInput, inputOverlay, inputProps, inputRef, isFromSelection, leadingElement, onClose, placeholder, searchInputLabel, state } = _ref, autocomplete = _objectWithoutProperties$6(_ref, _excluded$4$19);
12860
12883
  const { onReset } = autocomplete.getFormProps({ inputElement: inputRef.current });
12861
12884
  En.useEffect(() => {
12862
12885
  if (autoFocus && inputRef.current) inputRef.current.focus();
@@ -12949,21 +12972,15 @@ function useFacetValues({ facets, indexes, searchClient }) {
12949
12972
  En.useEffect(() => {
12950
12973
  let isMounted = true;
12951
12974
  const facetKeys = stableFacetKeys ? stableFacetKeys.split(",") : [];
12952
- if (facetKeys.length === 0 || indexes.length === 0) {
12953
- setFacetValues({});
12954
- return () => {
12955
- isMounted = false;
12956
- };
12957
- }
12958
- searchClient.search({ requests: indexes.map((index) => {
12959
- var _index$searchParamete2;
12960
- return _objectSpread2$2(_objectSpread2$2({}, (_index$searchParamete2 = index.searchParameters) !== null && _index$searchParamete2 !== void 0 ? _index$searchParamete2 : {}), {}, {
12961
- indexName: index.name,
12962
- query: "",
12963
- hitsPerPage: 0,
12964
- facets: facetKeys
12965
- });
12966
- }) }).then(({ results }) => {
12975
+ if (facetKeys.length === 0 || indexes.length === 0) return () => {
12976
+ isMounted = false;
12977
+ };
12978
+ searchClient.search({ requests: indexes.map((index) => ({
12979
+ indexName: index.name,
12980
+ query: "",
12981
+ hitsPerPage: 0,
12982
+ facets: facetKeys
12983
+ })) }).then(({ results }) => {
12967
12984
  if (!isMounted) return;
12968
12985
  const valuesByFacet = facetKeys.reduce((acc, facet) => {
12969
12986
  acc[facet] = [];
@@ -12992,19 +13009,23 @@ function useFacetValues({ facets, indexes, searchClient }) {
12992
13009
  }
12993
13010
  function useDocSearchFacets({ facets, indexes, searchClient, onSelectionsChange }) {
12994
13011
  const normalizedFacets = En.useMemo(() => normalizeFacets(facets), [facets]);
13012
+ const normalizedFacetsRef = En.useRef(normalizedFacets);
12995
13013
  const facetValues = useFacetValues({
12996
13014
  facets: normalizedFacets,
12997
13015
  indexes,
12998
13016
  searchClient
12999
13017
  });
13000
- const [facetSelections, setFacetSelections] = En.useState({});
13018
+ const [facetSelections, setFacetSelections] = En.useState(() => deriveDefaultSelectedFacetsFromIndex(indexes));
13001
13019
  const facetSelectionsRef = En.useRef(facetSelections);
13002
13020
  const onSelectionsChangeRef = En.useRef(onSelectionsChange);
13003
- onSelectionsChangeRef.current = onSelectionsChange;
13004
13021
  const visibleFacets = En.useMemo(() => normalizedFacets.map((facet) => {
13005
13022
  var _facetValues$facet$ke;
13006
13023
  return _objectSpread2$2(_objectSpread2$2({}, facet), {}, { values: (_facetValues$facet$ke = facetValues[facet.key]) !== null && _facetValues$facet$ke !== void 0 ? _facetValues$facet$ke : [] });
13007
13024
  }).filter((facet) => facet.values.length > 0), [facetValues, normalizedFacets]);
13025
+ En.useLayoutEffect(() => {
13026
+ normalizedFacetsRef.current = normalizedFacets;
13027
+ onSelectionsChangeRef.current = onSelectionsChange;
13028
+ });
13008
13029
  const applySelections = En.useCallback((next) => {
13009
13030
  var _onSelectionsChangeRe;
13010
13031
  facetSelectionsRef.current = next;
@@ -13018,13 +13039,14 @@ function useDocSearchFacets({ facets, indexes, searchClient, onSelectionsChange
13018
13039
  handleFacetSelectionChange: En.useCallback((facet, value) => {
13019
13040
  if (facetSelectionsRef.current[facet] === value) return;
13020
13041
  const next = _objectSpread2$2({}, facetSelectionsRef.current);
13021
- if (value === "") delete next[facet];
13022
- else next[facet] = value;
13042
+ next[facet] = value;
13023
13043
  applySelections(next);
13024
13044
  }, [applySelections]),
13025
13045
  clearFacetSelections: En.useCallback(() => {
13026
13046
  if (Object.keys(facetSelectionsRef.current).length === 0) return;
13027
- applySelections({});
13047
+ const next = {};
13048
+ for (const facet of normalizedFacetsRef.current) if (facetSelectionsRef.current[facet.key]) next[facet.key] = "";
13049
+ applySelections(next);
13028
13050
  }, [applySelections])
13029
13051
  };
13030
13052
  }
@@ -13233,7 +13255,7 @@ function useRelativeFormattedDate(start, end = Date.now()) {
13233
13255
  }, [diff]);
13234
13256
  return start ? formattedDate : null;
13235
13257
  }
13236
- const _excluded$3$19 = [
13258
+ const _excluded$3$20 = [
13237
13259
  "hit",
13238
13260
  "attribute",
13239
13261
  "tagName"
@@ -13246,7 +13268,7 @@ function getPropertyByPath(object, path) {
13246
13268
  }
13247
13269
  function Snippet(_ref) {
13248
13270
  let { hit, attribute, tagName = "span" } = _ref;
13249
- return _$2(tagName, _objectSpread2$2(_objectSpread2$2({}, _objectWithoutProperties$6(_ref, _excluded$3$19)), {}, { dangerouslySetInnerHTML: { __html: getPropertyByPath(hit, `_snippetResult.${attribute}.value`) || getPropertyByPath(hit, attribute) } }));
13271
+ return _$2(tagName, _objectSpread2$2(_objectSpread2$2({}, _objectWithoutProperties$6(_ref, _excluded$3$20)), {}, { dangerouslySetInnerHTML: { __html: getPropertyByPath(hit, `_snippetResult.${attribute}.value`) || getPropertyByPath(hit, attribute) } }));
13250
13272
  }
13251
13273
  function Results(props) {
13252
13274
  var _props$sourceIcon;
@@ -13331,9 +13353,9 @@ function AskAiButton({ item, getItemProps, onItemClick, collection }) {
13331
13353
  }
13332
13354
  })), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit--AskAI" }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-AskAIButton DocSearch-Hit-Container" }, /* @__PURE__ */ En.createElement("div", { className: " DocSearch-Hit-AskAIButton-icon DocSearch-Hit-icon" }, /* @__PURE__ */ En.createElement(SparklesIcon, null)), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-AskAIButton-title" }, /* @__PURE__ */ En.createElement("span", { className: "DocSearch-Hit-AskAIButton-title-query" }, item.query)))));
13333
13355
  }
13334
- const _excluded$2$21 = ["translations"];
13356
+ const _excluded$2$22 = ["translations"];
13335
13357
  function StoredSearchesSections(_ref) {
13336
- let { translations = {} } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$2$21);
13358
+ let { translations = {} } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$2$22);
13337
13359
  const { recentSearchesTitle = "Recently viewed docs", saveRecentSearchButtonTitle = "Pin this search", removeRecentSearchButtonTitle = "Remove this search from history", favoriteSearchesTitle = "Pinned", removeFavoriteSearchButtonTitle = "Remove this saved search" } = translations;
13338
13360
  const favoriteSearches = getCollection(props.state, "favoriteSearches");
13339
13361
  const recentSearchesCollection = getCollection(props.state, "recentSearches");
@@ -13386,9 +13408,9 @@ function ErrorScreen({ translations = {} }) {
13386
13408
  const { titleText = "Unable to fetch results", helpText = "You might want to check your network connection." } = translations;
13387
13409
  return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-ErrorScreen" }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Screen-Icon" }, /* @__PURE__ */ En.createElement(ErrorIcon, null)), /* @__PURE__ */ En.createElement("p", { className: "DocSearch-Title" }, titleText), /* @__PURE__ */ En.createElement("p", { className: "DocSearch-Help" }, helpText));
13388
13410
  }
13389
- const _excluded$1$22 = ["translations"];
13411
+ const _excluded$1$20 = ["translations"];
13390
13412
  function NoResultsScreen(_ref) {
13391
- let { translations = {} } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$1$22);
13413
+ let { translations = {} } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$1$20);
13392
13414
  const { noResultsText = "No results found for", suggestedQueryText = "Try searching for", reportMissingResultsText = "Believe this query should return results?", reportMissingResultsLinkText = "Let us know." } = translations;
13393
13415
  const searchSuggestions = props.state.context.searchSuggestions;
13394
13416
  return /* @__PURE__ */ En.createElement("div", { className: `DocSearch-NoResults ${props.canHandleAskAi ? "DocSearch-NoResults--withAskAi" : ""}` }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Screen-Icon" }, /* @__PURE__ */ En.createElement(NoResultsIcon, null)), /* @__PURE__ */ En.createElement("p", { className: "DocSearch-Title" }, noResultsText, " \"", /* @__PURE__ */ En.createElement("strong", null, props.state.query), "\""), searchSuggestions && searchSuggestions.length > 0 && /* @__PURE__ */ En.createElement("div", { className: "DocSearch-NoResults-Prefill-List" }, /* @__PURE__ */ En.createElement("p", { className: "DocSearch-Help" }, suggestedQueryText, ":"), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-NoResults-Prefill-List-Items" }, searchSuggestions.slice(0, 3).reduce((acc, search) => [...acc, /* @__PURE__ */ En.createElement("p", { key: search }, /* @__PURE__ */ En.createElement(SearchIcon, { size: 16 }), /* @__PURE__ */ En.createElement("button", {
@@ -13426,10 +13448,6 @@ function HitResultBadge({ item, resultBadgeKey, translations = {} }) {
13426
13448
  const _excluded$22 = ["translations", "resultBadgeKey"];
13427
13449
  function ResultsScreen(_ref) {
13428
13450
  let { translations = {}, resultBadgeKey } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$22);
13429
- const { resultsSectionTitle = "Results" } = translations;
13430
- const renderIcon = En.useCallback(({ item }) => {
13431
- return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-icon" }, /* @__PURE__ */ En.createElement(SourceIcon, { type: item.type }));
13432
- }, []);
13433
13451
  const renderAction = En.useCallback(() => {
13434
13452
  return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-action" }, /* @__PURE__ */ En.createElement(SelectIcon, null));
13435
13453
  }, []);
@@ -13442,22 +13460,45 @@ function ResultsScreen(_ref) {
13442
13460
  }, [resultBadgeKey, translations.resultBadgeLabelText]);
13443
13461
  return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Dropdown-Container" }, props.state.collections.map((collection) => {
13444
13462
  if (collection.items.length === 0) return null;
13463
+ const title = removeHighlightTags(collection.items[0]);
13445
13464
  return /* @__PURE__ */ En.createElement(Results, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
13446
13465
  key: collection.source.sourceId,
13447
13466
  translations,
13448
- title: resultsSectionTitle,
13467
+ title,
13449
13468
  collection,
13450
- renderIcon,
13469
+ renderIcon: ({ item, index }) => {
13470
+ var _collection$items;
13471
+ return /* @__PURE__ */ En.createElement(En.Fragment, null, item.__docsearch_parent && /* @__PURE__ */ En.createElement("svg", {
13472
+ className: "DocSearch-Hit-Tree",
13473
+ viewBox: "0 0 24 54"
13474
+ }, /* @__PURE__ */ En.createElement("g", {
13475
+ stroke: "currentColor",
13476
+ fill: "none",
13477
+ fillRule: "evenodd",
13478
+ strokeLinecap: "round",
13479
+ strokeLinejoin: "round"
13480
+ }, item.__docsearch_parent !== ((_collection$items = collection.items[index + 1]) === null || _collection$items === void 0 ? void 0 : _collection$items.__docsearch_parent) ? /* @__PURE__ */ En.createElement("path", { d: "M8 6v21M20 27H8.3" }) : /* @__PURE__ */ En.createElement("path", { d: "M8 6v42M20 27H8.3" }))), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-icon" }, /* @__PURE__ */ En.createElement(SourceIcon, { type: item.type })));
13481
+ },
13451
13482
  renderAction,
13452
13483
  renderResultBadge
13453
13484
  }));
13454
13485
  }), props.resultsFooterComponent && /* @__PURE__ */ En.createElement("section", { className: "DocSearch-HitsFooter" }, /* @__PURE__ */ En.createElement(props.resultsFooterComponent, { state: props.state })));
13455
13486
  }
13456
13487
  function createFacetFilters(searchParametersFacetFilters, facetSelections) {
13457
- const dynamicFacetFilters = Object.entries(facetSelections).filter(([, value]) => value).map(([facet, value]) => `${facet}:${value}`);
13458
- if (dynamicFacetFilters.length === 0) return searchParametersFacetFilters;
13459
- if (!searchParametersFacetFilters) return dynamicFacetFilters;
13460
- return [...searchParametersFacetFilters, ...dynamicFacetFilters];
13488
+ const selections = Object.entries(facetSelections);
13489
+ const selectedFacets = new Set(selections.map(([facet]) => facet));
13490
+ const dynamicFacetFilters = [];
13491
+ for (const [facet, selection] of selections) if (selection !== "") dynamicFacetFilters.push(`${facet}:${selection}`);
13492
+ if (selectedFacets.size === 0) return searchParametersFacetFilters;
13493
+ let configuredFacetFilters = [];
13494
+ if (searchParametersFacetFilters && Array.isArray(searchParametersFacetFilters)) configuredFacetFilters = searchParametersFacetFilters;
13495
+ else if (searchParametersFacetFilters) configuredFacetFilters = [searchParametersFacetFilters];
13496
+ return [...configuredFacetFilters.filter((facetFilter) => {
13497
+ if (typeof facetFilter !== "string") return true;
13498
+ const separatorIndex = facetFilter.indexOf(":");
13499
+ const facet = facetFilter.slice(0, separatorIndex);
13500
+ return separatorIndex <= 0 || !selectedFacets.has(facet);
13501
+ }), ...dynamicFacetFilters];
13461
13502
  }
13462
13503
  function buildNoQuerySources({ recentSearches, favoriteSearches, saveRecentSearch, onClose, disableUserPersonalization }) {
13463
13504
  if (disableUserPersonalization) return [];
@@ -13524,7 +13565,7 @@ async function buildQuerySources({ query, state: sourcesState, setContext, setSt
13524
13565
  highlightPostTag: (_searchParams$highlig2 = searchParams === null || searchParams === void 0 ? void 0 : searchParams.highlightPostTag) !== null && _searchParams$highlig2 !== void 0 ? _searchParams$highlig2 : "</mark>",
13525
13566
  hitsPerPage: (_searchParams$hitsPer = searchParams === null || searchParams === void 0 ? void 0 : searchParams.hitsPerPage) !== null && _searchParams$hitsPer !== void 0 ? _searchParams$hitsPer : 20,
13526
13567
  clickAnalytics: (_searchParams$clickAn = searchParams === null || searchParams === void 0 ? void 0 : searchParams.clickAnalytics) !== null && _searchParams$clickAn !== void 0 ? _searchParams$clickAn : insightsActive
13527
- }, searchParams !== null && searchParams !== void 0 ? searchParams : {}), facetFilters ? { facetFilters } : {});
13568
+ }, searchParams), facetFilters ? { facetFilters } : {});
13528
13569
  }) });
13529
13570
  return results.flatMap((res) => {
13530
13571
  const result = res;
@@ -13547,9 +13588,8 @@ async function buildQuerySources({ query, state: sourcesState, setContext, setSt
13547
13588
  apiKey
13548
13589
  }
13549
13590
  };
13550
- const items = Object.values(sources).flat();
13551
- return {
13552
- sourceId: `hits_${result.index}`,
13591
+ return Object.values(sources).map((items, index) => ({
13592
+ sourceId: `hits_${result.index}_${index}`,
13553
13593
  onSelect({ item, event }) {
13554
13594
  saveRecentSearch(item);
13555
13595
  if (!isModifierEvent(event)) onClose();
@@ -13563,26 +13603,18 @@ async function buildQuerySources({ query, state: sourcesState, setContext, setSt
13563
13603
  const potentialParent = groupedHits.find((siblingItem) => siblingItem.type === "lvl1" && siblingItem.hierarchy.lvl1 === item.hierarchy.lvl1);
13564
13604
  if (item.type !== "lvl1" && potentialParent) parent = potentialParent;
13565
13605
  return _objectSpread2$2(_objectSpread2$2({}, item), {}, { __docsearch_parent: parent }, insightsParams);
13566
- }).flat()).flat();
13606
+ })).flat();
13567
13607
  }
13568
- };
13608
+ }));
13569
13609
  });
13570
13610
  } catch (error) {
13571
13611
  if (error.name === "RetryError") setStatus("error");
13572
13612
  throw error;
13573
13613
  }
13574
13614
  }
13575
- function normalizeDocSearchIndexes({ indexName, indices = [], searchParameters }) {
13576
- const indexes = [];
13577
- if (indexName && indexName !== "") indexes.push({
13578
- name: indexName,
13579
- searchParameters
13580
- });
13581
- if (indices.length > 0) indices.forEach((index) => {
13582
- indexes.push(typeof index === "string" ? { name: index } : index);
13583
- });
13584
- if (indexes.length < 1) throw new Error("Must supply either `indexName` or `indices` for DocSearch to work");
13585
- return indexes;
13615
+ function normalizeDocSearchIndexes({ indices }) {
13616
+ if (!Array.isArray(indices) || indices.length < 1) throw new Error("Must supply at least one `indices` entry for DocSearch");
13617
+ return indices.map((index) => typeof index === "string" ? { name: index } : index);
13586
13618
  }
13587
13619
 
13588
13620
  //#endregion
@@ -13789,7 +13821,7 @@ const _excluded$21 = [
13789
13821
  "closeDelay",
13790
13822
  "id"
13791
13823
  ];
13792
- const PopoverTrigger$1 = /*#__PURE__*/ M$1(function PopoverTrigger(componentProps, forwardedRef) {
13824
+ const PopoverTrigger = /*#__PURE__*/ M$1(function PopoverTrigger(componentProps, forwardedRef) {
13793
13825
  var _handle$store;
13794
13826
  const { render, className, style, disabled = false, nativeButton = true, handle, payload, openOnHover = false, delay = 300, closeDelay = 0, id: idProp } = componentProps, elementProps = _objectWithoutProperties$5(componentProps, _excluded$21);
13795
13827
  const rootContext = usePopoverRootContext(true);
@@ -27212,7 +27244,7 @@ var require_throttleit = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27212
27244
  //#region ../../node_modules/.bun/@ai-sdk+react@2.0.215+38ec045d21336c81/node_modules/@ai-sdk/react/dist/index.mjs
27213
27245
  init_compat();
27214
27246
  var import_throttleit = /* @__PURE__ */ __toESM(require_throttleit(), 1);
27215
- const _excluded$13 = ["messages"];
27247
+ const _excluded$12 = ["messages"];
27216
27248
  const _excluded2$4 = ["experimental_throttle", "resume"];
27217
27249
  var __accessCheck = (obj, member, msg) => {
27218
27250
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
@@ -27331,7 +27363,7 @@ _callErrorCallbacks = /* @__PURE__ */ new WeakMap();
27331
27363
  var _state;
27332
27364
  var Chat = class extends AbstractChat {
27333
27365
  constructor(_ref) {
27334
- let { messages } = _ref, init = _objectWithoutProperties$5(_ref, _excluded$13);
27366
+ let { messages } = _ref, init = _objectWithoutProperties$5(_ref, _excluded$12);
27335
27367
  const state = new ReactChatState(messages);
27336
27368
  super(_objectSpread2$1(_objectSpread2$1({}, init), {}, { state }));
27337
27369
  __privateAdd(this, _state, void 0);
@@ -27376,7 +27408,7 @@ function useChat(_ref2 = {}) {
27376
27408
  }
27377
27409
 
27378
27410
  //#endregion
27379
- //#region ../docsearch-react/dist/esm/useSuggestedQuestions-D2TGVPsI.js
27411
+ //#region ../docsearch-react/dist/esm/useSuggestedQuestions-Ds7H1JCr.js
27380
27412
  init_compat();
27381
27413
  function AlertIcon(props) {
27382
27414
  return /* @__PURE__ */ En.createElement("svg", _objectSpread2$2({
@@ -27602,7 +27634,7 @@ function FeedbackActions({ id, showActions, latestAssistantMessageContent, trans
27602
27634
  translations,
27603
27635
  onClick: () => navigator.clipboard.writeText(latestAssistantMessageContent)
27604
27636
  });
27605
- return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Actions" }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Actions-Controls" }, isSidepanel ? copyButton : null, view === "thanks" ? /* @__PURE__ */ En.createElement("p", { className: "DocSearch-AskAiScreen-FeedbackText DocSearch-AskAiScreen-FeedbackText--visible" }, thanksForFeedbackText) : /* @__PURE__ */ En.createElement(En.Fragment, null, saving && view === "actions" ? /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }) : /* @__PURE__ */ En.createElement(En.Fragment, null, /* @__PURE__ */ En.createElement(LikeButton, {
27637
+ return /* @__PURE__ */ En.createElement(En.Fragment, null, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Actions-Controls" }, isSidepanel ? copyButton : null, view === "thanks" ? /* @__PURE__ */ En.createElement("p", { className: "DocSearch-AskAiScreen-FeedbackText DocSearch-AskAiScreen-FeedbackText--visible" }, thanksForFeedbackText) : /* @__PURE__ */ En.createElement(En.Fragment, null, saving && view === "actions" ? /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }) : /* @__PURE__ */ En.createElement(En.Fragment, null, /* @__PURE__ */ En.createElement(LikeButton, {
27606
27638
  title: likeButtonTitle,
27607
27639
  onClick: handleLike
27608
27640
  }), /* @__PURE__ */ En.createElement(DislikeButton, {
@@ -27621,18 +27653,22 @@ function FeedbackActions({ id, showActions, latestAssistantMessageContent, trans
27621
27653
  }) : null);
27622
27654
  }
27623
27655
  function NegativeFeedbackPanel({ translations, tags, notes, saving, savingError, onToggleTag, onNotesChange, onSubmit, onClose }) {
27656
+ const feedbackTitleId = En.useId();
27624
27657
  const { feedbackPanelTitle = "What went wrong? (optional)", feedbackDetailsPlaceholder = "Share some details...", feedbackSubmitButtonText = "Submit", feedbackCancelButtonText = "Cancel" } = translations;
27625
27658
  return /* @__PURE__ */ En.createElement("div", {
27626
27659
  className: "DocSearch-Feedback-Panel",
27627
27660
  role: "group",
27628
- "aria-label": feedbackPanelTitle
27629
- }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Feedback-Panel-Header" }, /* @__PURE__ */ En.createElement("p", { className: "DocSearch-Feedback-Panel-Title" }, feedbackPanelTitle)), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Feedback-Panel-Reasons" }, FEEDBACK_REASONS.map((reason) => {
27661
+ "aria-labelledby": feedbackTitleId
27662
+ }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Feedback-Panel-Header" }, /* @__PURE__ */ En.createElement("p", {
27663
+ className: "DocSearch-Feedback-Panel-Title",
27664
+ id: feedbackTitleId
27665
+ }, feedbackPanelTitle)), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Feedback-Panel-Reasons" }, FEEDBACK_REASONS.map((reason) => {
27630
27666
  var _translations$reason$;
27631
27667
  const isSelected = tags.includes(reason.value);
27632
27668
  return /* @__PURE__ */ En.createElement("button", {
27633
27669
  key: reason.value,
27634
27670
  type: "button",
27635
- className: `DocSearch-Feedback-Panel-Reason${isSelected ? " DocSearch-Feedback-Panel-Reason--selected" : ""}`,
27671
+ className: "DocSearch-Feedback-Panel-Reason",
27636
27672
  "aria-pressed": isSelected,
27637
27673
  onClick: () => onToggleTag(reason.value)
27638
27674
  }, /* @__PURE__ */ En.createElement("span", null, (_translations$reason$ = translations[reason.translationKey]) !== null && _translations$reason$ !== void 0 ? _translations$reason$ : reason.defaultLabel));
@@ -27757,12 +27793,14 @@ function Popover$1(_ref) {
27757
27793
  let props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
27758
27794
  return /* @__PURE__ */ En.createElement(PopoverRoot, props);
27759
27795
  }
27760
- function PopoverTrigger(_ref2) {
27796
+ Popover$1.Trigger = En.forwardRef((_ref2, ref) => {
27761
27797
  let { className } = _ref2, props = _objectWithoutProperties$6(_ref2, _excluded$2$12);
27762
27798
  const cn = `DocSearch-Popover-Trigger${className ? ` ${className}` : ""}`;
27763
- return /* @__PURE__ */ En.createElement(PopoverTrigger$1, _objectSpread2$2({ className: cn }, props));
27764
- }
27765
- Popover$1.Trigger = PopoverTrigger;
27799
+ return /* @__PURE__ */ En.createElement(PopoverTrigger, _objectSpread2$2({
27800
+ className: cn,
27801
+ ref
27802
+ }, props));
27803
+ });
27766
27804
  function PopoverPopup(_ref3) {
27767
27805
  let { align = "center", alignOffset = 0, side = "bottom", sideOffset = 4, collisionBoundary = "clipping-ancestors", container, children } = _ref3, props = _objectWithoutProperties$6(_ref3, _excluded2$3);
27768
27806
  return /* @__PURE__ */ En.createElement(PopoverPortal, { container }, /* @__PURE__ */ En.createElement(PopoverPositioner, {
@@ -27780,10 +27818,11 @@ function PopoverTitle(_ref4) {
27780
27818
  return /* @__PURE__ */ En.createElement(PopoverTitle$1, _objectSpread2$2({ className: "DocSearch-Popover-Title" }, props));
27781
27819
  }
27782
27820
  Popover$1.Title = PopoverTitle;
27783
- function SourcesPanel({ links, titleText = "Sources" }) {
27821
+ function SourcesPanel({ links, titleText = "Source", pluralTitleText = "Sources" }) {
27784
27822
  const [open, setOpen] = En.useState(false);
27785
27823
  const triggerRef = En.useRef(null);
27786
27824
  const [boundary, setBoundary] = En.useState(null);
27825
+ const sourcesTitle = links.length > 1 ? pluralTitleText : titleText;
27787
27826
  _$1(() => {
27788
27827
  var _ref, _trigger$closest;
27789
27828
  if (!open) return;
@@ -27810,13 +27849,13 @@ function SourcesPanel({ links, titleText = "Sources" }) {
27810
27849
  }, /* @__PURE__ */ En.createElement(Popover$1.Trigger, {
27811
27850
  ref: triggerRef,
27812
27851
  className: "DocSearch-AskAiScreen-Sources-Action"
27813
- }, /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAiScreen-Sources-Action-icon" }, /* @__PURE__ */ En.createElement(ContentIcon, null)), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAiScreen-Sources-Action-text" }, links.length, " sources")), /* @__PURE__ */ En.createElement(Popover$1.Popup, {
27852
+ }, /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAiScreen-Sources-Action-icon" }, /* @__PURE__ */ En.createElement(ContentIcon, null)), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAiScreen-Sources-Action-text" }, links.length, " ", sourcesTitle)), /* @__PURE__ */ En.createElement(Popover$1.Popup, {
27814
27853
  container: boundary,
27815
27854
  sideOffset: 10,
27816
27855
  align: "start",
27817
27856
  alignOffset: -16,
27818
27857
  collisionBoundary: boundary !== null && boundary !== void 0 ? boundary : "clipping-ancestors"
27819
- }, /* @__PURE__ */ En.createElement(Popover$1.Title, null, titleText), /* @__PURE__ */ En.createElement("ul", { className: "DocSearch-AskAiScreen-Sources" }, links.map((l) => /* @__PURE__ */ En.createElement("li", {
27858
+ }, /* @__PURE__ */ En.createElement(Popover$1.Title, null, sourcesTitle), /* @__PURE__ */ En.createElement("ul", { className: "DocSearch-AskAiScreen-Sources" }, links.map((l) => /* @__PURE__ */ En.createElement("li", {
27820
27859
  key: l.url,
27821
27860
  className: "DocSearch-AskAiScreen-Sources-source"
27822
27861
  }, /* @__PURE__ */ En.createElement("a", {
@@ -27896,7 +27935,10 @@ const buildDummyAskAiHit = (query, messages, chatId) => {
27896
27935
  url_without_anchor: ""
27897
27936
  };
27898
27937
  };
27899
- const getMessageContent = (message) => message === null || message === void 0 ? void 0 : message.parts.find((part) => part.type === "text");
27938
+ const getMessageContent = (message) => {
27939
+ var _message$parts;
27940
+ return ((_message$parts = message === null || message === void 0 ? void 0 : message.parts) !== null && _message$parts !== void 0 ? _message$parts : []).filter((part) => part.type === "text").map((part) => part.text).join("\n\n");
27941
+ };
27900
27942
  /** Helper function to check if error is a thread depth error (AI-217). */
27901
27943
  function isThreadDepthError(error) {
27902
27944
  var _error$message;
@@ -27910,9 +27952,6 @@ function isAIToolPart(part) {
27910
27952
  function isSearchToolPart(part) {
27911
27953
  return part.type === "tool-searchIndex" || part.type === "tool-algolia_search_index" || part.type.startsWith("tool-algolia_search_index_");
27912
27954
  }
27913
- function isSearchIndexOutputPart(part) {
27914
- return part.type === "tool-searchIndex" && part.state === "output-available";
27915
- }
27916
27955
  function isSearchOutputPart(part) {
27917
27956
  return isAIToolPart(part) && isSearchToolPart(part) && part.state === "output-available";
27918
27957
  }
@@ -27935,8 +27974,22 @@ function getAgentPromptSuggestions(parts) {
27935
27974
  if (!suggestionsPart) return [];
27936
27975
  return suggestionsPart.data.suggestions;
27937
27976
  }
27977
+ function getSearchToolQueries(part) {
27978
+ if (part.state !== "input-available" && part.state !== "output-available") return [];
27979
+ if (part.type === "tool-searchIndex") {
27980
+ var _ref, _part$output$query, _part$output, _part$input;
27981
+ const query = ((_ref = (_part$output$query = (_part$output = part.output) === null || _part$output === void 0 ? void 0 : _part$output.query) !== null && _part$output$query !== void 0 ? _part$output$query : (_part$input = part.input) === null || _part$input === void 0 ? void 0 : _part$input.query) !== null && _ref !== void 0 ? _ref : "").trim();
27982
+ return query ? [query] : [];
27983
+ }
27984
+ if ("queries" in part.input && Array.isArray(part.input.queries)) return part.input.queries.map(({ query }) => query.trim()).filter(Boolean);
27985
+ if ("query" in part.input && typeof part.input.query === "string") {
27986
+ const query = part.input.query.trim();
27987
+ return query ? [query] : [];
27988
+ }
27989
+ return [];
27990
+ }
27938
27991
  function ToolState({ icon, shimmer = false, children, variant }) {
27939
- const className = `DocSearch-AskAiScreen-MessageContent-Tool Tool--${variant}${shimmer ? " shimmer" : ""}`;
27992
+ const className = `DocSearch-AskAiScreen-MessageContent-Tool Tool--${variant}${shimmer ? " DocSearch-shimmer" : ""}`;
27940
27993
  return /* @__PURE__ */ En.createElement("div", { className }, icon, children);
27941
27994
  }
27942
27995
  function SearchTool({ part, translations, onSearchQueryClick }) {
@@ -27947,14 +28000,19 @@ function SearchTool({ part, translations, onSearchQueryClick }) {
27947
28000
  icon: /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }),
27948
28001
  variant: "PartialCall"
27949
28002
  }, /* @__PURE__ */ En.createElement("span", null, searchingText));
27950
- case "input-available": return /* @__PURE__ */ En.createElement(ToolState, {
27951
- shimmer: true,
27952
- icon: /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }),
27953
- variant: "Call"
27954
- }, /* @__PURE__ */ En.createElement("span", null, preToolCallText, " ", `"${part.input.query || ""}" ...`));
28003
+ case "input-available": {
28004
+ const queries = getSearchToolQueries(part);
28005
+ return /* @__PURE__ */ En.createElement(En.Fragment, null, queries.map((q, index) => /* @__PURE__ */ En.createElement(ToolState, {
28006
+ key: `${part.toolCallId}-call-${index}`,
28007
+ shimmer: true,
28008
+ icon: /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }),
28009
+ variant: "Call"
28010
+ }, /* @__PURE__ */ En.createElement("span", null, preToolCallText, " ", `"${q}" ...`))));
28011
+ }
27955
28012
  case "output-available": {
27956
- const query = part.type === "tool-searchIndex" ? part.output.query : part.input.query;
27957
- return /* @__PURE__ */ En.createElement(ToolState, {
28013
+ const queries = getSearchToolQueries(part);
28014
+ return /* @__PURE__ */ En.createElement(En.Fragment, null, queries.map((q, index) => /* @__PURE__ */ En.createElement(ToolState, {
28015
+ key: `${part.toolCallId}-result-${index}`,
27958
28016
  icon: /* @__PURE__ */ En.createElement(SearchIcon, null),
27959
28017
  variant: "Result"
27960
28018
  }, /* @__PURE__ */ En.createElement("span", null, toolCallResultText, " ", onSearchQueryClick ? /* @__PURE__ */ En.createElement("span", {
@@ -27964,11 +28022,11 @@ function SearchTool({ part, translations, onSearchQueryClick }) {
27964
28022
  onKeyDown: (e) => {
27965
28023
  if (e.key === "Enter" || e.key === " ") {
27966
28024
  e.preventDefault();
27967
- onSearchQueryClick(query || "");
28025
+ onSearchQueryClick(q);
27968
28026
  }
27969
28027
  },
27970
- onClick: () => onSearchQueryClick(query || "")
27971
- }, " ", "\"", query || "", "\"") : /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAiScreen-MessageContent-Tool-Query" }, " ", "\"", query || "", "\"")));
28028
+ onClick: () => onSearchQueryClick(q)
28029
+ }, " ", "\"", q, "\"") : /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAiScreen-MessageContent-Tool-Query" }, " ", "\"", q, "\"")))));
27972
28030
  }
27973
28031
  default: return null;
27974
28032
  }
@@ -28099,16 +28157,6 @@ const MemoizedMarkdown = D$1(({ content, copyButtonText, copyButtonCopiedText, i
28099
28157
  });
28100
28158
  MemoizedMarkdown.displayName = "MemoizedMarkdown";
28101
28159
  /**
28102
- * Extracts the search query from a search tool result part. `searchIndex`
28103
- * exposes the query on its output, while the Algolia MCP search tools expose it
28104
- * on their input.
28105
- */
28106
- function getSearchQuery(part) {
28107
- var _part$output, _part$input;
28108
- const query = isSearchIndexOutputPart(part) ? (_part$output = part.output) === null || _part$output === void 0 ? void 0 : _part$output.query : (_part$input = part.input) === null || _part$input === void 0 ? void 0 : _part$input.query;
28109
- return (query !== null && query !== void 0 ? query : "").trim();
28110
- }
28111
- /**
28112
28160
  * Groups consecutive search tool invocation result parts together. Both the
28113
28161
  * `searchIndex` tool and the Algolia MCP search tools (`algolia_search_index`
28114
28162
  * and `algolia_search_index_*`) are aggregated. Empty or falsy queries are
@@ -28125,11 +28173,9 @@ function groupConsecutiveToolResults(parts) {
28125
28173
  while (j < parts.length) {
28126
28174
  const candidate = parts[j];
28127
28175
  if (isSearchOutputPart(candidate)) {
28128
- const q = getSearchQuery(candidate);
28129
- if (q && q.length > 0) {
28130
- queries.push(q);
28131
- singleQueryPart = candidate;
28132
- }
28176
+ const queriesForPart = getSearchToolQueries(candidate);
28177
+ queries.push(...queriesForPart);
28178
+ if (queriesForPart.length > 0) singleQueryPart = candidate;
28133
28179
  j++;
28134
28180
  } else break;
28135
28181
  }
@@ -28143,7 +28189,7 @@ function groupConsecutiveToolResults(parts) {
28143
28189
  }
28144
28190
  return aggregatedParts;
28145
28191
  }
28146
- const _excluded$1$11 = [
28192
+ const _excluded$1$10 = [
28147
28193
  "children",
28148
28194
  "className",
28149
28195
  "onClick"
@@ -28193,7 +28239,7 @@ function MenuContent({ children }) {
28193
28239
  }
28194
28240
  Menu.Content = MenuContent;
28195
28241
  function MenuItem(_ref) {
28196
- let { children, className = "", onClick } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$1$11);
28242
+ let { children, className = "", onClick } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$1$10);
28197
28243
  const { setOpen } = En.useContext(MenuContext);
28198
28244
  const handleClick = (e) => {
28199
28245
  if (onClick) {
@@ -28240,24 +28286,24 @@ const postAgentStudioFeedback = ({ agentId, vote, messageId, appId, apiKey, abor
28240
28286
  signal: abortSignal
28241
28287
  });
28242
28288
  };
28243
- const _excluded$12 = [
28289
+ const _excluded$13 = [
28244
28290
  "id",
28245
28291
  "messages",
28246
28292
  "body"
28247
28293
  ];
28248
- const getAgentStudioTransport = ({ appId, apiKey, assistantId, searchParameters, userToken, indices }) => {
28294
+ const getAgentStudioTransport = ({ appId, apiKey, agentId, searchParameters, userToken, indices }) => {
28249
28295
  const algoliaParams = {};
28250
28296
  if (searchParameters) algoliaParams.searchParameters = searchParameters;
28251
28297
  if (indices && indices.length > 0) algoliaParams.indices = indices;
28252
28298
  return new DefaultChatTransport({
28253
- api: `${agentStudioBaseUrl(appId)}/agents/${assistantId}/completions?stream=true&compatibilityMode=ai-sdk-5`,
28299
+ api: `${agentStudioBaseUrl(appId)}/agents/${agentId}/completions?stream=true&compatibilityMode=ai-sdk-5`,
28254
28300
  headers: _objectSpread2$2({
28255
28301
  "x-algolia-application-id": appId,
28256
28302
  "x-algolia-api-key": apiKey
28257
28303
  }, userToken ? { "x-algolia-secure-user-token": userToken } : {}),
28258
28304
  body: { algolia: algoliaParams },
28259
28305
  prepareSendMessagesRequest(_ref) {
28260
- let { id, messages, body } = _ref, rest = _objectWithoutProperties$6(_ref, _excluded$12);
28306
+ let { id, messages, body } = _ref, rest = _objectWithoutProperties$6(_ref, _excluded$13);
28261
28307
  const sanitizedMessages = sanitizeMessagesForRequest(messages);
28262
28308
  return _objectSpread2$2(_objectSpread2$2({}, rest), {}, { body: _objectSpread2$2({
28263
28309
  id,
@@ -28266,19 +28312,19 @@ const getAgentStudioTransport = ({ appId, apiKey, assistantId, searchParameters,
28266
28312
  }
28267
28313
  });
28268
28314
  };
28269
- const useAskAi = ({ assistantId, apiKey, appId, indexName, tools = EMPTY_TOOLS, searchParameters, memory, indices }) => {
28315
+ const useAskAi = ({ agentId, apiKey, appId, tools = EMPTY_TOOLS, searchParameters, memory, indices }) => {
28270
28316
  const abortControllerRef = F$2(new AbortController());
28271
28317
  const askAiTransport = q$2(() => getAgentStudioTransport({
28272
28318
  apiKey,
28273
28319
  appId,
28274
- assistantId,
28320
+ agentId,
28275
28321
  searchParameters,
28276
28322
  userToken: memory === null || memory === void 0 ? void 0 : memory.userToken,
28277
28323
  indices
28278
28324
  }), [
28279
28325
  apiKey,
28280
28326
  appId,
28281
- assistantId,
28327
+ agentId,
28282
28328
  searchParameters,
28283
28329
  memory === null || memory === void 0 ? void 0 : memory.userToken,
28284
28330
  indices
@@ -28315,14 +28361,14 @@ const useAskAi = ({ assistantId, apiKey, appId, indexName, tools = EMPTY_TOOLS,
28315
28361
  addToolOutputRef.current = addToolOutput;
28316
28362
  }, [addToolOutput]);
28317
28363
  const conversations = F$2(createStoredConversations({
28318
- key: `__DOCSEARCH_ASKAI_CONVERSATIONS__${indexName}`,
28364
+ key: `__DOCSEARCH_ASKAI_CONVERSATIONS__${appId}`,
28319
28365
  limit: 10
28320
28366
  })).current;
28321
28367
  const sendFeedback = b$1(async (messageId, { thumbs, tags, notes }) => {
28322
28368
  var _conversations$addFee;
28323
- if (!assistantId) return;
28369
+ if (!agentId) return;
28324
28370
  if ((await postAgentStudioFeedback({
28325
- agentId: assistantId,
28371
+ agentId,
28326
28372
  vote: thumbs,
28327
28373
  messageId,
28328
28374
  appId,
@@ -28336,7 +28382,7 @@ const useAskAi = ({ assistantId, apiKey, appId, indexName, tools = EMPTY_TOOLS,
28336
28382
  notes
28337
28383
  });
28338
28384
  }, [
28339
- assistantId,
28385
+ agentId,
28340
28386
  appId,
28341
28387
  apiKey,
28342
28388
  conversations
@@ -28393,22 +28439,22 @@ const useAskAi = ({ assistantId, apiKey, appId, indexName, tools = EMPTY_TOOLS,
28393
28439
  restoreConversation
28394
28440
  };
28395
28441
  };
28396
- const useSuggestedQuestions = ({ assistantId, searchClient, suggestedQuestionsEnabled = false }) => {
28442
+ const useSuggestedQuestions = ({ agentId, searchClient, suggestedQuestionsEnabled = false }) => {
28397
28443
  const [suggestedQuestions, setSuggestedQuestions] = h([]);
28398
28444
  _$1(() => {
28399
28445
  const getSuggestedQuestions = async () => {
28400
28446
  const { results } = await searchClient.search({ requests: [{
28401
28447
  indexName: SUGGESTED_QUETIONS_INDEX_NAME,
28402
- filters: `state:published AND assistantId:${assistantId}`,
28448
+ filters: `state:published AND assistantId:${agentId}`,
28403
28449
  hitsPerPage: 3
28404
28450
  }] });
28405
28451
  const result = results[0];
28406
28452
  setSuggestedQuestions(result.hits);
28407
28453
  };
28408
- if (suggestedQuestionsEnabled && assistantId && assistantId !== "") getSuggestedQuestions();
28454
+ if (suggestedQuestionsEnabled && agentId && agentId !== "") getSuggestedQuestions();
28409
28455
  }, [
28410
28456
  suggestedQuestionsEnabled,
28411
- assistantId,
28457
+ agentId,
28412
28458
  searchClient
28413
28459
  ]);
28414
28460
  return suggestedQuestions;
@@ -31222,7 +31268,7 @@ function createAutocomplete(options) {
31222
31268
  }
31223
31269
 
31224
31270
  //#endregion
31225
- //#region ../docsearch-react/dist/esm/DocSearchAskAiModal-CCrk6YLb.js
31271
+ //#region ../docsearch-react/dist/esm/DocSearchAskAiModal-BczGFkvR.js
31226
31272
  init_compat();
31227
31273
  function MessageIcon() {
31228
31274
  return /* @__PURE__ */ En.createElement("svg", {
@@ -31252,7 +31298,7 @@ function AggregatedSearchBlock({ queries, translations, onSearchQueryClick }) {
31252
31298
  tabIndex: 0,
31253
31299
  className: "DocSearch-AskAiScreen-MessageContent-Tool-Query",
31254
31300
  onKeyDown: (e) => {
31255
- if (e.key === "enter" || e.key === " ") {
31301
+ if (e.key === "Enter" || e.key === " ") {
31256
31302
  e.preventDefault();
31257
31303
  onSearchQueryClick(q);
31258
31304
  }
@@ -31280,9 +31326,9 @@ function AskAiScreenDisclaimer({ disclaimerText }) {
31280
31326
  return /* @__PURE__ */ En.createElement("p", { className: "DocSearch-AskAiScreen-Disclaimer" }, /* @__PURE__ */ En.createElement(SparklesIcon, null), " ", disclaimerText);
31281
31327
  }
31282
31328
  function AskAiExchangeCard({ exchange, askAiError, isLastExchange, loadingStatus, onSearchQueryClick, translations, tools, conversations, onFeedback, memoryEnabled, onSelectPromptSuggestion }) {
31283
- var _userMessage$metadata, _assistantMessage$met, _userContent$text;
31329
+ var _userMessage$metadata, _assistantMessage$met;
31284
31330
  const { userMessage, assistantMessage } = exchange;
31285
- const { stoppedStreamingText = "You stopped this response", errorTitleText = "Chat error", relatedSourcesText, suggestedPromptsTitleText = "Suggested prompts" } = translations;
31331
+ const { stoppedStreamingText = "You stopped this response", errorTitleText = "Chat error", relatedSourcesText, relatedSourcesTextPlural, suggestedPromptsTitleText = "Suggested prompts" } = translations;
31286
31332
  const toolCallTranslations = q$2(() => toToolCallTranslations(translations), [translations]);
31287
31333
  const isThreadDepth = isThreadDepthError(askAiError);
31288
31334
  const assistantContent = q$2(() => getMessageContent(assistantMessage), [assistantMessage]);
@@ -31299,7 +31345,7 @@ function AskAiExchangeCard({ exchange, askAiError, isLastExchange, loadingStatus
31299
31345
  const showActions = !wasStopped && (!isLastExchange || isLastExchange && loadingStatus === "ready" && Boolean(assistantMessage));
31300
31346
  const isThinking = ["submitted", "streaming"].includes(loadingStatus) && isLastExchange && !displayParts.some((part) => part.type !== "step-start");
31301
31347
  const messageId = (assistantMessage === null || assistantMessage === void 0 ? void 0 : assistantMessage.id) || exchange.id;
31302
- return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Response-Container" }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Response" }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Message DocSearch-AskAiScreen-Message--user" }, /* @__PURE__ */ En.createElement("p", { className: "DocSearch-AskAiScreen-Query" }, (_userContent$text = userContent === null || userContent === void 0 ? void 0 : userContent.text) !== null && _userContent$text !== void 0 ? _userContent$text : "")), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Message DocSearch-AskAiScreen-Message--assistant" }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-MessageContent" }, loadingStatus === "error" && askAiError && isLastExchange && !isThreadDepth && /* @__PURE__ */ En.createElement("div", {
31348
+ return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Response-Container" }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Response" }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Message DocSearch-AskAiScreen-Message--user" }, /* @__PURE__ */ En.createElement("p", { className: "DocSearch-AskAiScreen-Query" }, userContent !== null && userContent !== void 0 ? userContent : "")), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Message DocSearch-AskAiScreen-Message--assistant" }, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-MessageContent" }, loadingStatus === "error" && askAiError && isLastExchange && !isThreadDepth && /* @__PURE__ */ En.createElement("div", {
31303
31349
  className: "DocSearch-AskAiScreen-Error",
31304
31350
  role: "alert"
31305
31351
  }, /* @__PURE__ */ En.createElement(AlertIcon, { "aria-hidden": "true" }), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Error-Content" }, /* @__PURE__ */ En.createElement("h4", { className: "DocSearch-AskAiScreen-Error-Title" }, errorTitleText), /* @__PURE__ */ En.createElement(MemoizedMarkdown, {
@@ -31310,7 +31356,7 @@ function AskAiExchangeCard({ exchange, askAiError, isLastExchange, loadingStatus
31310
31356
  }))), isThinking && /* @__PURE__ */ En.createElement("div", {
31311
31357
  className: "DocSearch-AskAiScreen-MessageContent-Thinking",
31312
31358
  role: "status"
31313
- }, /* @__PURE__ */ En.createElement("span", { className: "shimmer" }, translations.thinkingText || "Thinking..."), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAi-Thinking-Skeleton shimmer" }), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAi-Thinking-Skeleton DocSearch-AskAi-Thinking-Skeleton--short shimmer" })), displayParts.map((part, idx) => {
31359
+ }, /* @__PURE__ */ En.createElement("span", { className: "DocSearch-shimmer" }, translations.thinkingText || "Thinking..."), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAi-Thinking-Skeleton DocSearch-shimmer" }), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAi-Thinking-Skeleton DocSearch-AskAi-Thinking-Skeleton--short DocSearch-shimmer" })), displayParts.map((part, idx) => {
31314
31360
  const index = idx;
31315
31361
  if (typeof part === "string") return /* @__PURE__ */ En.createElement(MemoizedMarkdown, {
31316
31362
  key: index,
@@ -31335,8 +31381,8 @@ function AskAiExchangeCard({ exchange, askAiError, isLastExchange, loadingStatus
31335
31381
  });
31336
31382
  if (part.type === "reasoning" && part.state === "streaming") return /* @__PURE__ */ En.createElement("div", {
31337
31383
  key: index,
31338
- className: "DocSearch-AskAiScreen-MessageContent-Reasoning shimmer"
31339
- }, /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }), /* @__PURE__ */ En.createElement("span", { className: "shimmer" }, "Reasoning..."));
31384
+ className: "DocSearch-AskAiScreen-MessageContent-Reasoning DocSearch-shimmer"
31385
+ }, /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-shimmer" }, "Reasoning..."));
31340
31386
  if (part.type === "text") return /* @__PURE__ */ En.createElement(MemoizedMarkdown, {
31341
31387
  key: index,
31342
31388
  content: part.text,
@@ -31345,13 +31391,14 @@ function AskAiExchangeCard({ exchange, askAiError, isLastExchange, loadingStatus
31345
31391
  isStreaming: part.state === "streaming"
31346
31392
  });
31347
31393
  return null;
31348
- })), wasStopped && /* @__PURE__ */ En.createElement("p", { className: "DocSearck-AskAiScreen-MessageContent-Stopped" }, stoppedStreamingText)), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Answer-Footer" }, /* @__PURE__ */ En.createElement(SourcesPanel, {
31394
+ })), wasStopped && /* @__PURE__ */ En.createElement("p", { className: "DocSearch-AskAiScreen-MessageContent-Stopped" }, stoppedStreamingText)), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Answer-Footer" }, /* @__PURE__ */ En.createElement(SourcesPanel, {
31349
31395
  links: urlsToDisplay,
31350
- titleText: relatedSourcesText
31396
+ titleText: relatedSourcesText,
31397
+ pluralTitleText: relatedSourcesTextPlural
31351
31398
  }), /* @__PURE__ */ En.createElement(FeedbackActions, {
31352
31399
  id: messageId,
31353
31400
  showActions,
31354
- latestAssistantMessageContent: (assistantContent === null || assistantContent === void 0 ? void 0 : assistantContent.text) || null,
31401
+ latestAssistantMessageContent: assistantContent || null,
31355
31402
  translations,
31356
31403
  conversations,
31357
31404
  onFeedback
@@ -31419,7 +31466,7 @@ function RecentConversationsResults(_ref) {
31419
31466
  return /* @__PURE__ */ En.createElement(Results, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
31420
31467
  title: recentConversationsTitle,
31421
31468
  collection: recentConversations,
31422
- renderIcon: () => /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-icon DocSearch-Hit-icon--small" }, /* @__PURE__ */ En.createElement(MessageIcon, null)),
31469
+ renderIcon: () => /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-icon DocSearch-Hit-icon--start" }, /* @__PURE__ */ En.createElement(MessageIcon, null)),
31423
31470
  renderAction: ({ item }) => /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-action" }, /* @__PURE__ */ En.createElement("button", {
31424
31471
  className: "DocSearch-Hit-action-button",
31425
31472
  title: removeRecentConversationButtonTitle,
@@ -31473,10 +31520,10 @@ function NewConversationScreen({ translations = {}, suggestedQuestions = [], sel
31473
31520
  onClick: () => selectSuggestedQuestion(question)
31474
31521
  }, question.question))));
31475
31522
  }
31476
- const _excluded$2 = ["translations", "selectAskAiQuestion"];
31523
+ const _excluded$2$1 = ["translations", "selectAskAiQuestion"];
31477
31524
  const AskAiScreenState = En.memo((_ref) => {
31478
31525
  var _props$state;
31479
- let { translations = {}, selectAskAiQuestion } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$2);
31526
+ let { translations = {}, selectAskAiQuestion } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$2$1);
31480
31527
  const handleSelectPromptSuggestion = En.useCallback((prompt) => {
31481
31528
  selectAskAiQuestion(true, prompt);
31482
31529
  }, [selectAskAiQuestion]);
@@ -31497,18 +31544,21 @@ const AskAiScreenState = En.memo((_ref) => {
31497
31544
  onSelectPromptSuggestion: handleSelectPromptSuggestion
31498
31545
  }));
31499
31546
  if (((_props$state = props.state) === null || _props$state === void 0 ? void 0 : _props$state.status) === "error") return /* @__PURE__ */ En.createElement(ErrorScreen, { translations: translations === null || translations === void 0 ? void 0 : translations.errorScreen });
31500
- if (!props.state.query) return /* @__PURE__ */ En.createElement(AskAiStartScreen, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
31547
+ if (isQueryEmpty(props.state.query)) return /* @__PURE__ */ En.createElement(AskAiStartScreen, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
31501
31548
  hasCollections: props.hasCollections,
31502
31549
  translations: translations === null || translations === void 0 ? void 0 : translations.startScreen,
31503
31550
  selectAskAiQuestion
31504
31551
  }));
31505
31552
  if (!props.hasCollections && !props.canHandleAskAi) return /* @__PURE__ */ En.createElement(NoResultsScreen, _objectSpread2$2(_objectSpread2$2({}, props), {}, { translations: translations === null || translations === void 0 ? void 0 : translations.noResultsScreen }));
31506
31553
  return /* @__PURE__ */ En.createElement(En.Fragment, null, /* @__PURE__ */ En.createElement(ResultsScreen, _objectSpread2$2(_objectSpread2$2({}, props), {}, { translations: translations === null || translations === void 0 ? void 0 : translations.resultsScreen })), props.canHandleAskAi && !props.hasCollections && /* @__PURE__ */ En.createElement(NoResultsScreen, _objectSpread2$2(_objectSpread2$2({}, props), {}, { translations: translations === null || translations === void 0 ? void 0 : translations.noResultsScreen })));
31507
- }, function areEqual(_prevProps, nextProps) {
31508
- return nextProps.state.status === "loading" || nextProps.state.status === "stalled";
31554
+ }, function areEqual(prevProps, nextProps) {
31555
+ if (prevProps.isAskAiActive !== nextProps.isAskAiActive || prevProps.askAiState !== nextProps.askAiState || prevProps.canHandleAskAi !== nextProps.canHandleAskAi) return false;
31556
+ const isLoading = nextProps.state.status === "loading" || nextProps.state.status === "stalled";
31557
+ const isWaitingForCollections = nextProps.state.status === "idle" && !isQueryEmpty(nextProps.state.query) && prevProps.state.query !== nextProps.state.query && prevProps.state.collections === nextProps.state.collections;
31558
+ return isLoading || isWaitingForCollections;
31509
31559
  });
31510
31560
  function ModalHeading({ heading, shimmer = false }) {
31511
- return /* @__PURE__ */ En.createElement("span", { className: `DocSearch-Modal-heading${shimmer ? " shimmer" : ""}` }, heading);
31561
+ return /* @__PURE__ */ En.createElement("span", { className: `DocSearch-Modal-heading${shimmer ? " DocSearch-shimmer" : ""}` }, heading);
31512
31562
  }
31513
31563
  const _excluded$1$1 = [
31514
31564
  "translations",
@@ -31560,7 +31610,7 @@ function AskAiSearchBox(_ref) {
31560
31610
  onKeyDown: (e) => {
31561
31611
  let askAiHandled = false;
31562
31612
  if (props.isAskAiActive && blockedKeys.has(e.key)) {
31563
- if (e.key === "Enter" && !isAskAiStreaming && props.state.query) props.onAskAgain(props.state.query);
31613
+ if (e.key === "Enter" && !isAskAiStreaming && !isQueryEmpty(props.state.query)) props.onAskAgain(props.state.query);
31564
31614
  askAiHandled = true;
31565
31615
  }
31566
31616
  if (askAiHandled) {
@@ -31762,8 +31812,6 @@ const _excluded$7 = [
31762
31812
  "recentSearchesLimit",
31763
31813
  "recentSearchesWithFavoritesLimit",
31764
31814
  "indices",
31765
- "indexName",
31766
- "searchParameters",
31767
31815
  "facets",
31768
31816
  "isHybridModeSupported"
31769
31817
  ];
@@ -31774,7 +31822,7 @@ const _excluded2 = [
31774
31822
  ];
31775
31823
  function DocSearchAskAiModal(_ref) {
31776
31824
  var _translations$searchB, _askAiConfig$memory$e, _askAiConfig$memory, _askAiConfig$tools;
31777
- let { appId, apiKey, askAi, maxResultsPerGroup, theme, onClose = noop$2, transformItems = identity, hitComponent = Hit, resultsFooterComponent = () => null, navigator, initialScrollY = 0, transformSearchClient = identity, disableUserPersonalization = false, initialQuery: initialQueryFromProp = "", translations = {}, getMissingResultsUrl, insights = false, onAskAiToggle, interceptAskAiEvent, isAskAiActive = false, recentSearchesLimit = 7, recentSearchesWithFavoritesLimit = 4, indices = [], indexName, searchParameters, facets, isHybridModeSupported = false } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$7);
31825
+ let { appId, apiKey, askAi, maxResultsPerGroup, theme, onClose = noop$2, transformItems = identity, hitComponent = Hit, resultsFooterComponent = () => null, navigator, initialScrollY = 0, transformSearchClient = identity, disableUserPersonalization = false, initialQuery: initialQueryFromProp = "", translations = {}, getMissingResultsUrl, insights = false, onAskAiToggle, interceptAskAiEvent, isAskAiActive = false, recentSearchesLimit = 7, recentSearchesWithFavoritesLimit = 4, indices, facets, isHybridModeSupported = false } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$7);
31778
31826
  const { footer: footerTranslations, searchBox: searchBoxTranslations, facets: facetBarTranslations } = translations, screenStateTranslations = _objectWithoutProperties$6(translations, _excluded2);
31779
31827
  const [state, setState] = En.useState({
31780
31828
  query: "",
@@ -31799,25 +31847,17 @@ function DocSearchAskAiModal(_ref) {
31799
31847
  const { initialQuery, initialQueryFromSelection } = useInitialModalQuery(initialQueryFromProp);
31800
31848
  const searchClient = useSearchClient(appId, apiKey, transformSearchClient);
31801
31849
  const askAiConfig = typeof askAi === "object" ? askAi : null;
31802
- const askAiConfigurationId = askAiConfig ? askAiConfig.assistantId : askAi;
31850
+ const askAiConfigurationId = askAiConfig ? askAiConfig.agentId : askAi;
31803
31851
  const askAiSearchParameters = askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.searchParameters;
31804
31852
  const [askAiState, setAskAiState] = En.useState("initial");
31805
31853
  const suggestedQuestions = useSuggestedQuestions({
31806
- assistantId: askAiConfigurationId,
31854
+ agentId: askAiConfigurationId,
31807
31855
  searchClient,
31808
31856
  suggestedQuestionsEnabled: askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.suggestedQuestions
31809
31857
  });
31810
31858
  const memoryEnabled = (_askAiConfig$memory$e = askAiConfig === null || askAiConfig === void 0 || (_askAiConfig$memory = askAiConfig.memory) === null || _askAiConfig$memory === void 0 ? void 0 : _askAiConfig$memory.enabled) !== null && _askAiConfig$memory$e !== void 0 ? _askAiConfig$memory$e : false;
31811
31859
  const tools = (_askAiConfig$tools = askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.tools) !== null && _askAiConfig$tools !== void 0 ? _askAiConfig$tools : EMPTY_TOOLS;
31812
- const indexes = En.useMemo(() => normalizeDocSearchIndexes({
31813
- indexName,
31814
- indices,
31815
- searchParameters
31816
- }), [
31817
- indexName,
31818
- indices,
31819
- searchParameters
31820
- ]);
31860
+ const indexes = En.useMemo(() => normalizeDocSearchIndexes({ indices }), [indices]);
31821
31861
  const defaultIndexName = indexes[0].name;
31822
31862
  const autocompleteRef = En.useRef(void 0);
31823
31863
  const { visibleFacets, facetSelections, facetSelectionsRef, handleFacetSelectionChange, clearFacetSelections } = useDocSearchFacets({
@@ -31836,10 +31876,9 @@ function DocSearchAskAiModal(_ref) {
31836
31876
  });
31837
31877
  const [stoppedStream, setStoppedStream] = En.useState(false);
31838
31878
  const { chatId, messages, status, setMessages, sendMessage, stopAskAiStreaming, askAiError, sendFeedback, conversations, startNewConversation, restoreConversation } = useAskAi({
31839
- assistantId: askAiConfigurationId,
31879
+ agentId: askAiConfigurationId,
31840
31880
  apiKey: (askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.apiKey) || apiKey,
31841
31881
  appId: (askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.appId) || appId,
31842
- indexName: (askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.indexName) || defaultIndexName,
31843
31882
  searchParameters: askAiSearchParameters,
31844
31883
  tools,
31845
31884
  memory: askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.memory,
@@ -31936,7 +31975,7 @@ function DocSearchAskAiModal(_ref) {
31936
31975
  setState(changes.state);
31937
31976
  },
31938
31977
  async getSources({ query, state: sourcesState, setContext, setStatus }) {
31939
- if (!query) {
31978
+ if (isQueryEmpty(query)) {
31940
31979
  const noQuerySources = buildNoQuerySources({
31941
31980
  recentSearches,
31942
31981
  favoriteSearches,
@@ -32034,7 +32073,7 @@ function DocSearchAskAiModal(_ref) {
32034
32073
  };
32035
32074
  let showDocsearchDropdown = true;
32036
32075
  const hasCollections = state.collections.some((collection) => collection.source.sourceId !== SOURCE_IDS.askAI && collection.items.length > 0);
32037
- if (state.status === "idle" && hasCollections === false && state.query.length === 0 && !isAskAiActive) showDocsearchDropdown = false;
32076
+ if (state.status === "idle" && hasCollections === false && isQueryEmpty(state.query) && !isAskAiActive) showDocsearchDropdown = false;
32038
32077
  return /* @__PURE__ */ En.createElement(ModalShell, {
32039
32078
  state,
32040
32079
  containerRef,
@@ -32046,7 +32085,7 @@ function DocSearchAskAiModal(_ref) {
32046
32085
  searchBox: /* @__PURE__ */ En.createElement(AskAiSearchBox, _objectSpread2$2(_objectSpread2$2({}, autocomplete), {}, {
32047
32086
  state,
32048
32087
  placeholder: placeholder || "Search docs",
32049
- autoFocus: initialQuery.length === 0,
32088
+ autoFocus: isQueryEmpty(initialQuery),
32050
32089
  inputRef,
32051
32090
  isFromSelection: Boolean(initialQuery) && initialQuery === initialQueryFromSelection,
32052
32091
  translations: searchBoxTranslations,
@@ -32065,7 +32104,7 @@ function DocSearchAskAiModal(_ref) {
32065
32104
  onNewConversation: handleNewConversation,
32066
32105
  onViewConversationHistory: handleViewConversationHistory
32067
32106
  })),
32068
- filterBar: !isAskAiActive && state.query !== "" ? /* @__PURE__ */ En.createElement(FacetBar, {
32107
+ filterBar: !isAskAiActive && !isQueryEmpty(state.query) ? /* @__PURE__ */ En.createElement(FacetBar, {
32069
32108
  facets: visibleFacets,
32070
32109
  selections: facetSelections,
32071
32110
  translations: facetBarTranslations,
@@ -32280,8 +32319,10 @@ function _objectWithoutProperties(e, t) {
32280
32319
  }
32281
32320
  return i;
32282
32321
  }
32283
- const _excluded$1 = [
32322
+ const _excluded$2 = [
32284
32323
  "children",
32324
+ "appId",
32325
+ "apiKey",
32285
32326
  "theme",
32286
32327
  "onReady",
32287
32328
  "onOpen",
@@ -32292,7 +32333,7 @@ const _excluded$1 = [
32292
32333
  const Context = En.createContext(void 0);
32293
32334
  Context.displayName = "DocSearchContext";
32294
32335
  function DocSearchInner(_ref, ref) {
32295
- let { children, theme, onReady, onOpen, onClose, onSidepanelOpen, onSidepanelClose } = _ref, props = _objectWithoutProperties(_ref, _excluded$1);
32336
+ let { children, appId, apiKey, theme, onReady, onOpen, onClose, onSidepanelOpen, onSidepanelClose } = _ref, props = _objectWithoutProperties(_ref, _excluded$2);
32296
32337
  const [docsearchState, setDocsearchState] = En.useState("ready");
32297
32338
  const [initialQuery, setInitialQuery] = En.useState(props.initialQuery || "");
32298
32339
  const searchButtonRef = En.useRef(null);
@@ -32399,6 +32440,8 @@ function DocSearchInner(_ref, ref) {
32399
32440
  keyboardShortcuts
32400
32441
  });
32401
32442
  const value = En.useMemo(() => ({
32443
+ appId,
32444
+ apiKey,
32402
32445
  docsearchState,
32403
32446
  setDocsearchState,
32404
32447
  searchButtonRef,
@@ -32413,6 +32456,8 @@ function DocSearchInner(_ref, ref) {
32413
32456
  registerView,
32414
32457
  isHybridModeSupported
32415
32458
  }), [
32459
+ appId,
32460
+ apiKey,
32416
32461
  docsearchState,
32417
32462
  searchButtonRef,
32418
32463
  initialQuery,
@@ -32439,19 +32484,28 @@ function useDocSearch() {
32439
32484
  //#endregion
32440
32485
  //#region ../docsearch-react/dist/esm/docsearchAi.js
32441
32486
  init_compat();
32442
- function DocSearchAIComponent(props, ref) {
32443
- return /* @__PURE__ */ En.createElement(DocSearch, _objectSpread2$2(_objectSpread2$2({}, props), {}, { ref }), /* @__PURE__ */ En.createElement(DocSearchAIInner, props));
32487
+ const _excluded$1 = ["appId", "apiKey"];
32488
+ function DocSearchAIComponent(_ref, ref) {
32489
+ let { appId, apiKey } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$1);
32490
+ return /* @__PURE__ */ En.createElement(DocSearch, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
32491
+ appId,
32492
+ apiKey,
32493
+ ref
32494
+ }), /* @__PURE__ */ En.createElement(DocSearchAIInner, props));
32444
32495
  }
32445
32496
  const DocSearchAI = En.forwardRef(DocSearchAIComponent);
32446
32497
  function DocSearchAIInner(props) {
32447
32498
  var _props$translations, _props$translations2, _props$portalContaine;
32448
- const { searchButtonRef, keyboardShortcuts, isModalActive, isAskAiActive, initialQuery, onAskAiToggle, openModal, closeModal, isHybridModeSupported } = useDocSearch();
32499
+ const { searchButtonRef, keyboardShortcuts, isModalActive, isAskAiActive, initialQuery, onAskAiToggle, openModal, closeModal, isHybridModeSupported, appId, apiKey } = useDocSearch();
32500
+ if (!appId || !apiKey) throw new Error("`DocSearchAI` requires `appId` and `apiKey` props.");
32449
32501
  return /* @__PURE__ */ En.createElement(En.Fragment, null, /* @__PURE__ */ En.createElement(DocSearchButton, {
32450
32502
  keyboardShortcuts,
32451
32503
  ref: searchButtonRef,
32452
32504
  translations: (_props$translations = props.translations) === null || _props$translations === void 0 ? void 0 : _props$translations.button,
32453
32505
  onClick: openModal
32454
32506
  }), isModalActive && H(/* @__PURE__ */ En.createElement(DocSearchAskAiModal, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
32507
+ appId,
32508
+ apiKey,
32455
32509
  initialScrollY: window.scrollY,
32456
32510
  initialQuery,
32457
32511
  translations: props === null || props === void 0 || (_props$translations2 = props.translations) === null || _props$translations2 === void 0 ? void 0 : _props$translations2.modal,