@docsearch/js 5.0.0-beta.1 → 5.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! @docsearch/js 5.0.0-beta.1 (UNRELEASED cc75f9a) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
1
+ /*! @docsearch/js 5.0.0-beta.3 (UNRELEASED b044250) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
2
2
  //#region \0rolldown/runtime.js
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1182,7 +1182,7 @@ function DocSearchButtonKey({ reactsToKey, children }) {
1182
1182
 
1183
1183
  //#endregion
1184
1184
  //#region ../docsearch-react/dist/esm/version.js
1185
- const version$1 = "5.0.0-beta.0";
1185
+ const version$1 = "5.0.0-beta.3";
1186
1186
 
1187
1187
  //#endregion
1188
1188
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/OverloadYield.js
@@ -12159,7 +12159,7 @@ function useMixedToggleClickHandler(params) {
12159
12159
  //#endregion
12160
12160
  //#region ../../node_modules/.bun/@base-ui+react@1.6.0+fce4ea6354698f9c/node_modules/@base-ui/react/menu/trigger/MenuTrigger.mjs
12161
12161
  init_compat();
12162
- const _excluded$10 = [
12162
+ const _excluded$9 = [
12163
12163
  "render",
12164
12164
  "className",
12165
12165
  "style",
@@ -12179,9 +12179,9 @@ const BOUNDARY_OFFSET = 2;
12179
12179
  *
12180
12180
  * Documentation: [Base UI Menu](https://base-ui.com/react/components/menu)
12181
12181
  */
12182
- const MenuTrigger$1 = fastComponentRef(function MenuTrigger(componentProps, forwardedRef) {
12182
+ const MenuTrigger = fastComponentRef(function MenuTrigger(componentProps, forwardedRef) {
12183
12183
  var _handle$store;
12184
- 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$10);
12184
+ 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$9);
12185
12185
  const rootContext = useMenuRootContext(true);
12186
12186
  const store = (_handle$store = handle === null || handle === void 0 ? void 0 : handle.store) !== null && _handle$store !== void 0 ? _handle$store : rootContext === null || rootContext === void 0 ? void 0 : rootContext.store;
12187
12187
  if (!store) throw new Error(formatErrorMessage(85));
@@ -12380,7 +12380,7 @@ function useMenuParent() {
12380
12380
  }
12381
12381
 
12382
12382
  //#endregion
12383
- //#region ../docsearch-react/dist/esm/normalizeDocSearchIndexes-DAzlMybx.js
12383
+ //#region ../docsearch-react/dist/esm/normalizeDocSearchIndexes-ChnVvoVt.js
12384
12384
  init_compat();
12385
12385
  function capitalize(text) {
12386
12386
  return `${text.charAt(0).toLocaleUpperCase()}${text.substring(1)}`;
@@ -12441,6 +12441,10 @@ function identity(x) {
12441
12441
  function isModifierEvent(event) {
12442
12442
  return event.button === 1 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
12443
12443
  }
12444
+ function isQueryEmpty(query) {
12445
+ if (!query || query.trim().length === 0) return true;
12446
+ return false;
12447
+ }
12444
12448
  function noop$1(..._args) {}
12445
12449
  const regexHighlightTags = /(<mark>|<\/mark>)/g;
12446
12450
  const regexHasHighlightTags = RegExp(regexHighlightTags.source);
@@ -12556,6 +12560,22 @@ function getFacetLabel(facet) {
12556
12560
  if (facet.label) return facet.label;
12557
12561
  return facet.key.replace(/[._-]+/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
12558
12562
  }
12563
+ function deriveDefaultSelectedFacetsFromIndex(indices) {
12564
+ const defaultFacets = {};
12565
+ for (const index of indices) {
12566
+ var _index$searchParamete;
12567
+ const facetFilters = (_index$searchParamete = index.searchParameters) === null || _index$searchParamete === void 0 ? void 0 : _index$searchParamete.facetFilters;
12568
+ for (const facetFilter of Array.isArray(facetFilters) ? facetFilters : [facetFilters]) {
12569
+ if (typeof facetFilter !== "string") continue;
12570
+ const separatorIndex = facetFilter.indexOf(":");
12571
+ if (separatorIndex <= 0) continue;
12572
+ const key = facetFilter.slice(0, separatorIndex);
12573
+ const value = facetFilter.slice(separatorIndex + 1);
12574
+ if (key && value) defaultFacets[key] = value;
12575
+ }
12576
+ }
12577
+ return defaultFacets;
12578
+ }
12559
12579
  const _excluded$6$4 = ["className", "type"];
12560
12580
  function Chip({ children }) {
12561
12581
  return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Chip" }, children);
@@ -12585,12 +12605,14 @@ function Menu$1(_ref) {
12585
12605
  let props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
12586
12606
  return /* @__PURE__ */ En.createElement(MenuRoot, props);
12587
12607
  }
12588
- function MenuTrigger(_ref2) {
12608
+ Menu$1.Trigger = En.forwardRef((_ref2, ref) => {
12589
12609
  let { className } = _ref2, props = _objectWithoutProperties$6(_ref2, _excluded$5$4);
12590
12610
  const cn = `DocSearch-Menu-Trigger${className ? ` ${className}` : ""}`;
12591
- return /* @__PURE__ */ En.createElement(MenuTrigger$1, _objectSpread2$2({ className: cn }, props));
12592
- }
12593
- Menu$1.Trigger = MenuTrigger;
12611
+ return /* @__PURE__ */ En.createElement(MenuTrigger, _objectSpread2$2({
12612
+ className: cn,
12613
+ ref
12614
+ }, props));
12615
+ });
12594
12616
  function MenuPopup(_ref3) {
12595
12617
  let { align = "start", alignOffset = 0, side = "bottom", sideOffset = 4, collisionBoundary = "clipping-ancestors", container } = _ref3, props = _objectWithoutProperties$6(_ref3, _excluded2$3);
12596
12618
  return /* @__PURE__ */ En.createElement(MenuPortal, { container }, /* @__PURE__ */ En.createElement(MenuPositioner, {
@@ -12658,9 +12680,10 @@ const SelectedFacetChip = En.memo(function SelectedFacetChip({ facetKey, facetLa
12658
12680
  });
12659
12681
  const FacetBar = En.memo(function FacetBar({ facets, selections, onSelectionChange, clearSelections, translations = {} }) {
12660
12682
  const { defaultValueLabel = "All", facetMenuTriggerAriaLabel = "selected", clearAllLabel = "Clear all", facetsAriaLabel = "Search filters", selectedFacetsAriaLabel = "Selected search filters", clearFacetAriaLabel = "Clear filter:" } = translations;
12683
+ const visibleFacetKeys = En.useMemo(() => new Set(facets.map((f) => f.key)), [facets]);
12661
12684
  const selectionsToDisplay = En.useMemo(() => {
12662
- return Object.entries(selections).filter(([_, value]) => Boolean(value));
12663
- }, [selections]);
12685
+ return Object.entries(selections).filter(([key, value]) => Boolean(value) && visibleFacetKeys.has(key));
12686
+ }, [selections, visibleFacetKeys]);
12664
12687
  const triggerRefs = En.useRef(/* @__PURE__ */ new Map());
12665
12688
  const registerTrigger = En.useCallback((facetKey, el) => {
12666
12689
  if (el) triggerRefs.current.set(facetKey, el);
@@ -12813,12 +12836,13 @@ function CommandIcon(props) {
12813
12836
  strokeWidth: "1.4"
12814
12837
  }, props.children));
12815
12838
  }
12816
- function Footer({ translations = {}, isAskAiActive = false }) {
12839
+ function Footer({ translations = {}, isAskAiActive = false, footerAction }) {
12817
12840
  const { selectText = "Select", selectKeyAriaLabel = "Enter key", submitQuestionText = "Submit question", navigateText = "Navigate", navigateUpKeyAriaLabel = "Arrow up", navigateDownKeyAriaLabel = "Arrow down", closeText = "Close", backToSearchText = "Back to search", closeKeyAriaLabel = "Escape key", poweredByText = "Powered by" } = translations;
12818
- return /* @__PURE__ */ En.createElement(En.Fragment, null, /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Logo" }, /* @__PURE__ */ En.createElement(AlgoliaLogo, { translations: { poweredByText } })), /* @__PURE__ */ En.createElement("ul", { className: "DocSearch-Commands" }, /* @__PURE__ */ En.createElement("li", null, /* @__PURE__ */ En.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ En.createElement(CommandIcon, { ariaLabel: navigateDownKeyAriaLabel }, /* @__PURE__ */ En.createElement("path", { d: "M12 5v14" }), /* @__PURE__ */ En.createElement("path", { d: "m19 12-7 7-7-7" }))), /* @__PURE__ */ En.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ En.createElement(CommandIcon, { ariaLabel: navigateUpKeyAriaLabel }, /* @__PURE__ */ En.createElement("path", { d: "m5 12 7-7 7 7" }), /* @__PURE__ */ En.createElement("path", { d: "M12 19V5" }))), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-Label" }, navigateText)), /* @__PURE__ */ En.createElement("li", null, /* @__PURE__ */ En.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ En.createElement(CommandIcon, { ariaLabel: selectKeyAriaLabel }, /* @__PURE__ */ En.createElement("polyline", { points: "9 10 4 15 9 20" }), /* @__PURE__ */ En.createElement("path", { d: "M20 4v7a4 4 0 0 1-4 4H4" }))), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-Label" }, isAskAiActive ? submitQuestionText : selectText)), /* @__PURE__ */ En.createElement("li", null, /* @__PURE__ */ En.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ En.createElement("span", { className: "DocSearch-Escape-Key" }, "ESC")), /* @__PURE__ */ En.createElement("span", {
12841
+ const hasFooterAction = footerAction !== null && footerAction !== void 0 && typeof footerAction !== "boolean";
12842
+ return /* @__PURE__ */ En.createElement(En.Fragment, null, /* @__PURE__ */ En.createElement("ul", { className: "DocSearch-Commands" }, /* @__PURE__ */ En.createElement("li", null, /* @__PURE__ */ En.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ En.createElement(CommandIcon, { ariaLabel: navigateDownKeyAriaLabel }, /* @__PURE__ */ En.createElement("path", { d: "M12 5v14" }), /* @__PURE__ */ En.createElement("path", { d: "m19 12-7 7-7-7" }))), /* @__PURE__ */ En.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ En.createElement(CommandIcon, { ariaLabel: navigateUpKeyAriaLabel }, /* @__PURE__ */ En.createElement("path", { d: "m5 12 7-7 7 7" }), /* @__PURE__ */ En.createElement("path", { d: "M12 19V5" }))), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-Label" }, navigateText)), /* @__PURE__ */ En.createElement("li", null, /* @__PURE__ */ En.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ En.createElement(CommandIcon, { ariaLabel: selectKeyAriaLabel }, /* @__PURE__ */ En.createElement("polyline", { points: "9 10 4 15 9 20" }), /* @__PURE__ */ En.createElement("path", { d: "M20 4v7a4 4 0 0 1-4 4H4" }))), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-Label" }, isAskAiActive ? submitQuestionText : selectText)), /* @__PURE__ */ En.createElement("li", null, /* @__PURE__ */ En.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ En.createElement("span", { className: "DocSearch-Escape-Key" }, "ESC")), /* @__PURE__ */ En.createElement("span", {
12819
12843
  className: "DocSearch-Label",
12820
12844
  "aria-label": closeKeyAriaLabel
12821
- }, isAskAiActive ? backToSearchText : closeText))));
12845
+ }, isAskAiActive ? backToSearchText : closeText))), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Footer-Actions" }, hasFooterAction && /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Footer-Action" }, footerAction), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Logo" }, /* @__PURE__ */ En.createElement(AlgoliaLogo, { translations: { poweredByText } }))));
12822
12846
  }
12823
12847
  function Hit({ hit, children }) {
12824
12848
  return /* @__PURE__ */ En.createElement("a", { href: hit.url }, children);
@@ -12833,21 +12857,15 @@ function useFacetValues({ facets, indexes, searchClient }) {
12833
12857
  En.useEffect(() => {
12834
12858
  let isMounted = true;
12835
12859
  const facetKeys = stableFacetKeys ? stableFacetKeys.split(",") : [];
12836
- if (facetKeys.length === 0 || indexes.length === 0) {
12837
- setFacetValues({});
12838
- return () => {
12839
- isMounted = false;
12840
- };
12841
- }
12842
- searchClient.search({ requests: indexes.map((index) => {
12843
- var _index$searchParamete2;
12844
- return _objectSpread2$2(_objectSpread2$2({}, (_index$searchParamete2 = index.searchParameters) !== null && _index$searchParamete2 !== void 0 ? _index$searchParamete2 : {}), {}, {
12845
- indexName: index.name,
12846
- query: "",
12847
- hitsPerPage: 0,
12848
- facets: facetKeys
12849
- });
12850
- }) }).then(({ results }) => {
12860
+ if (facetKeys.length === 0 || indexes.length === 0) return () => {
12861
+ isMounted = false;
12862
+ };
12863
+ searchClient.search({ requests: indexes.map((index) => ({
12864
+ indexName: index.name,
12865
+ query: "",
12866
+ hitsPerPage: 0,
12867
+ facets: facetKeys
12868
+ })) }).then(({ results }) => {
12851
12869
  if (!isMounted) return;
12852
12870
  const valuesByFacet = facetKeys.reduce((acc, facet) => {
12853
12871
  acc[facet] = [];
@@ -12876,19 +12894,23 @@ function useFacetValues({ facets, indexes, searchClient }) {
12876
12894
  }
12877
12895
  function useDocSearchFacets({ facets, indexes, searchClient, onSelectionsChange }) {
12878
12896
  const normalizedFacets = En.useMemo(() => normalizeFacets(facets), [facets]);
12897
+ const normalizedFacetsRef = En.useRef(normalizedFacets);
12879
12898
  const facetValues = useFacetValues({
12880
12899
  facets: normalizedFacets,
12881
12900
  indexes,
12882
12901
  searchClient
12883
12902
  });
12884
- const [facetSelections, setFacetSelections] = En.useState({});
12903
+ const [facetSelections, setFacetSelections] = En.useState(() => deriveDefaultSelectedFacetsFromIndex(indexes));
12885
12904
  const facetSelectionsRef = En.useRef(facetSelections);
12886
12905
  const onSelectionsChangeRef = En.useRef(onSelectionsChange);
12887
- onSelectionsChangeRef.current = onSelectionsChange;
12888
12906
  const visibleFacets = En.useMemo(() => normalizedFacets.map((facet) => {
12889
12907
  var _facetValues$facet$ke;
12890
12908
  return _objectSpread2$2(_objectSpread2$2({}, facet), {}, { values: (_facetValues$facet$ke = facetValues[facet.key]) !== null && _facetValues$facet$ke !== void 0 ? _facetValues$facet$ke : [] });
12891
12909
  }).filter((facet) => facet.values.length > 0), [facetValues, normalizedFacets]);
12910
+ En.useLayoutEffect(() => {
12911
+ normalizedFacetsRef.current = normalizedFacets;
12912
+ onSelectionsChangeRef.current = onSelectionsChange;
12913
+ });
12892
12914
  const applySelections = En.useCallback((next) => {
12893
12915
  var _onSelectionsChangeRe;
12894
12916
  facetSelectionsRef.current = next;
@@ -12902,13 +12924,14 @@ function useDocSearchFacets({ facets, indexes, searchClient, onSelectionsChange
12902
12924
  handleFacetSelectionChange: En.useCallback((facet, value) => {
12903
12925
  if (facetSelectionsRef.current[facet] === value) return;
12904
12926
  const next = _objectSpread2$2({}, facetSelectionsRef.current);
12905
- if (value === "") delete next[facet];
12906
- else next[facet] = value;
12927
+ next[facet] = value;
12907
12928
  applySelections(next);
12908
12929
  }, [applySelections]),
12909
12930
  clearFacetSelections: En.useCallback(() => {
12910
12931
  if (Object.keys(facetSelectionsRef.current).length === 0) return;
12911
- applySelections({});
12932
+ const next = {};
12933
+ for (const facet of normalizedFacetsRef.current) if (facetSelectionsRef.current[facet.key]) next[facet.key] = "";
12934
+ applySelections(next);
12912
12935
  }, [applySelections])
12913
12936
  };
12914
12937
  }
@@ -12977,7 +13000,7 @@ function useTrapFocus({ container }) {
12977
13000
  };
12978
13001
  }, [container]);
12979
13002
  }
12980
- function useDocSearchModalEffects({ initialScrollY, modalRef, snippetLength, theme }) {
13003
+ function useDocSearchModalEffects({ initialScrollY, modalRef, theme }) {
12981
13004
  useTheme({ theme });
12982
13005
  En.useEffect(() => {
12983
13006
  document.body.classList.add("DocSearch--active");
@@ -12997,9 +13020,6 @@ function useDocSearchModalEffects({ initialScrollY, modalRef, snippetLength, the
12997
13020
  document.body.style.marginInlineEnd = "0px";
12998
13021
  };
12999
13022
  }, []);
13000
- En.useEffect(() => {
13001
- if (window.matchMedia("(max-width: 768px)").matches) snippetLength.current = 5;
13002
- }, [snippetLength]);
13003
13023
  En.useEffect(() => {
13004
13024
  function setFullViewportHeight() {
13005
13025
  if (modalRef.current) {
@@ -13014,7 +13034,7 @@ function useDocSearchModalEffects({ initialScrollY, modalRef, snippetLength, the
13014
13034
  };
13015
13035
  }, [modalRef]);
13016
13036
  }
13017
- function useModalEnvironment({ getEnvironmentProps, containerRef, dropdownRef, formElementRef, inputRef, initialScrollY, modalRef, snippetLength, theme }) {
13037
+ function useModalEnvironment({ getEnvironmentProps, containerRef, dropdownRef, formElementRef, inputRef, initialScrollY, modalRef, theme }) {
13018
13038
  useTouchEvents({
13019
13039
  getEnvironmentProps,
13020
13040
  panelElement: dropdownRef.current,
@@ -13025,7 +13045,6 @@ function useModalEnvironment({ getEnvironmentProps, containerRef, dropdownRef, f
13025
13045
  useDocSearchModalEffects({
13026
13046
  initialScrollY,
13027
13047
  modalRef,
13028
- snippetLength,
13029
13048
  theme
13030
13049
  });
13031
13050
  }
@@ -13035,8 +13054,7 @@ function useModalRefs() {
13035
13054
  modalRef: En.useRef(null),
13036
13055
  formElementRef: En.useRef(null),
13037
13056
  dropdownRef: En.useRef(null),
13038
- inputRef: En.useRef(null),
13039
- snippetLength: En.useRef(15)
13057
+ inputRef: En.useRef(null)
13040
13058
  };
13041
13059
  }
13042
13060
  function useRefreshOnInitialQuery({ initialQuery, inputRef, refresh }) {
@@ -13270,9 +13288,9 @@ function ErrorScreen({ translations = {} }) {
13270
13288
  const { titleText = "Unable to fetch results", helpText = "You might want to check your network connection." } = translations;
13271
13289
  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));
13272
13290
  }
13273
- const _excluded$1$8 = ["translations"];
13291
+ const _excluded$1$7 = ["translations"];
13274
13292
  function NoResultsScreen(_ref) {
13275
- let { translations = {} } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$1$8);
13293
+ let { translations = {} } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$1$7);
13276
13294
  const { noResultsText = "No results found for", suggestedQueryText = "Try searching for", reportMissingResultsText = "Believe this query should return results?", reportMissingResultsLinkText = "Let us know." } = translations;
13277
13295
  const searchSuggestions = props.state.context.searchSuggestions;
13278
13296
  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", {
@@ -13307,13 +13325,9 @@ function HitResultBadge({ item, resultBadgeKey, translations = {} }) {
13307
13325
  if (badgeValue === null || badgeValue.length === 0) return null;
13308
13326
  return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-badge" }, /* @__PURE__ */ En.createElement("span", { className: "DocSearch-VisuallyHiddenForAccessibility" }, `${resultBadgeLabelText}: ${badgeValue}`), /* @__PURE__ */ En.createElement("span", { "aria-hidden": "true" }, badgeValue));
13309
13327
  }
13310
- const _excluded$9 = ["translations", "resultBadgeKey"];
13328
+ const _excluded$10 = ["translations", "resultBadgeKey"];
13311
13329
  function ResultsScreen(_ref) {
13312
- let { translations = {}, resultBadgeKey } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$9);
13313
- const { resultsSectionTitle = "Results" } = translations;
13314
- const renderIcon = En.useCallback(({ item }) => {
13315
- return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-icon" }, /* @__PURE__ */ En.createElement(SourceIcon, { type: item.type }));
13316
- }, []);
13330
+ let { translations = {}, resultBadgeKey } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$10);
13317
13331
  const renderAction = En.useCallback(() => {
13318
13332
  return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Hit-action" }, /* @__PURE__ */ En.createElement(SelectIcon, null));
13319
13333
  }, []);
@@ -13326,22 +13340,45 @@ function ResultsScreen(_ref) {
13326
13340
  }, [resultBadgeKey, translations.resultBadgeLabelText]);
13327
13341
  return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Dropdown-Container" }, props.state.collections.map((collection) => {
13328
13342
  if (collection.items.length === 0) return null;
13343
+ const title = removeHighlightTags(collection.items[0]);
13329
13344
  return /* @__PURE__ */ En.createElement(Results, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
13330
13345
  key: collection.source.sourceId,
13331
13346
  translations,
13332
- title: resultsSectionTitle,
13347
+ title,
13333
13348
  collection,
13334
- renderIcon,
13349
+ renderIcon: ({ item, index }) => {
13350
+ var _collection$items;
13351
+ return /* @__PURE__ */ En.createElement(En.Fragment, null, item.__docsearch_parent && /* @__PURE__ */ En.createElement("svg", {
13352
+ className: "DocSearch-Hit-Tree",
13353
+ viewBox: "0 0 24 54"
13354
+ }, /* @__PURE__ */ En.createElement("g", {
13355
+ stroke: "currentColor",
13356
+ fill: "none",
13357
+ fillRule: "evenodd",
13358
+ strokeLinecap: "round",
13359
+ strokeLinejoin: "round"
13360
+ }, 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 })));
13361
+ },
13335
13362
  renderAction,
13336
13363
  renderResultBadge
13337
13364
  }));
13338
13365
  }), props.resultsFooterComponent && /* @__PURE__ */ En.createElement("section", { className: "DocSearch-HitsFooter" }, /* @__PURE__ */ En.createElement(props.resultsFooterComponent, { state: props.state })));
13339
13366
  }
13340
13367
  function createFacetFilters(searchParametersFacetFilters, facetSelections) {
13341
- const dynamicFacetFilters = Object.entries(facetSelections).filter(([, value]) => value).map(([facet, value]) => `${facet}:${value}`);
13342
- if (dynamicFacetFilters.length === 0) return searchParametersFacetFilters;
13343
- if (!searchParametersFacetFilters) return dynamicFacetFilters;
13344
- return [...searchParametersFacetFilters, ...dynamicFacetFilters];
13368
+ const selections = Object.entries(facetSelections);
13369
+ const selectedFacets = new Set(selections.map(([facet]) => facet));
13370
+ const dynamicFacetFilters = [];
13371
+ for (const [facet, selection] of selections) if (selection !== "") dynamicFacetFilters.push(`${facet}:${selection}`);
13372
+ if (selectedFacets.size === 0) return searchParametersFacetFilters;
13373
+ let configuredFacetFilters = [];
13374
+ if (searchParametersFacetFilters && Array.isArray(searchParametersFacetFilters)) configuredFacetFilters = searchParametersFacetFilters;
13375
+ else if (searchParametersFacetFilters) configuredFacetFilters = [searchParametersFacetFilters];
13376
+ return [...configuredFacetFilters.filter((facetFilter) => {
13377
+ if (typeof facetFilter !== "string") return true;
13378
+ const separatorIndex = facetFilter.indexOf(":");
13379
+ const facet = facetFilter.slice(0, separatorIndex);
13380
+ return separatorIndex <= 0 || !selectedFacets.has(facet);
13381
+ }), ...dynamicFacetFilters];
13345
13382
  }
13346
13383
  function buildNoQuerySources({ recentSearches, favoriteSearches, saveRecentSearch, onClose, disableUserPersonalization }) {
13347
13384
  if (disableUserPersonalization) return [];
@@ -13371,7 +13408,7 @@ function buildNoQuerySources({ recentSearches, favoriteSearches, saveRecentSearc
13371
13408
  }
13372
13409
  }];
13373
13410
  }
13374
- async function buildQuerySources({ query, state: sourcesState, setContext, setStatus, searchClient, indexes, snippetLength, insights, appId, apiKey, maxResultsPerGroup, transformItems = identity, saveRecentSearch, onClose, facetSelections }) {
13411
+ async function buildQuerySources({ query, state: sourcesState, setContext, setStatus, searchClient, indexes, insights, appId, apiKey, maxResultsPerGroup, transformItems = identity, saveRecentSearch, onClose, facetSelections }) {
13375
13412
  const insightsActive = insights;
13376
13413
  try {
13377
13414
  const { results } = await searchClient.search({ requests: indexes.map((index) => {
@@ -13395,20 +13432,20 @@ async function buildQuerySources({ query, state: sourcesState, setContext, setSt
13395
13432
  "url"
13396
13433
  ],
13397
13434
  attributesToSnippet: (_searchParams$attribu2 = searchParams === null || searchParams === void 0 ? void 0 : searchParams.attributesToSnippet) !== null && _searchParams$attribu2 !== void 0 ? _searchParams$attribu2 : [
13398
- `hierarchy.lvl1:${snippetLength.current}`,
13399
- `hierarchy.lvl2:${snippetLength.current}`,
13400
- `hierarchy.lvl3:${snippetLength.current}`,
13401
- `hierarchy.lvl4:${snippetLength.current}`,
13402
- `hierarchy.lvl5:${snippetLength.current}`,
13403
- `hierarchy.lvl6:${snippetLength.current}`,
13404
- `content:${snippetLength.current}`
13435
+ `hierarchy.lvl1:15`,
13436
+ `hierarchy.lvl2:15`,
13437
+ `hierarchy.lvl3:15`,
13438
+ `hierarchy.lvl4:15`,
13439
+ `hierarchy.lvl5:15`,
13440
+ `hierarchy.lvl6:15`,
13441
+ `content:15`
13405
13442
  ],
13406
13443
  snippetEllipsisText: (_searchParams$snippet = searchParams === null || searchParams === void 0 ? void 0 : searchParams.snippetEllipsisText) !== null && _searchParams$snippet !== void 0 ? _searchParams$snippet : "…",
13407
13444
  highlightPreTag: (_searchParams$highlig = searchParams === null || searchParams === void 0 ? void 0 : searchParams.highlightPreTag) !== null && _searchParams$highlig !== void 0 ? _searchParams$highlig : "<mark>",
13408
13445
  highlightPostTag: (_searchParams$highlig2 = searchParams === null || searchParams === void 0 ? void 0 : searchParams.highlightPostTag) !== null && _searchParams$highlig2 !== void 0 ? _searchParams$highlig2 : "</mark>",
13409
13446
  hitsPerPage: (_searchParams$hitsPer = searchParams === null || searchParams === void 0 ? void 0 : searchParams.hitsPerPage) !== null && _searchParams$hitsPer !== void 0 ? _searchParams$hitsPer : 20,
13410
13447
  clickAnalytics: (_searchParams$clickAn = searchParams === null || searchParams === void 0 ? void 0 : searchParams.clickAnalytics) !== null && _searchParams$clickAn !== void 0 ? _searchParams$clickAn : insightsActive
13411
- }, searchParams !== null && searchParams !== void 0 ? searchParams : {}), facetFilters ? { facetFilters } : {});
13448
+ }, searchParams), facetFilters ? { facetFilters } : {});
13412
13449
  }) });
13413
13450
  return results.flatMap((res) => {
13414
13451
  const result = res;
@@ -13431,9 +13468,8 @@ async function buildQuerySources({ query, state: sourcesState, setContext, setSt
13431
13468
  apiKey
13432
13469
  }
13433
13470
  };
13434
- const items = Object.values(sources).flat();
13435
- return {
13436
- sourceId: `hits_${result.index}`,
13471
+ return Object.values(sources).map((items, index) => ({
13472
+ sourceId: `hits_${result.index}_${index}`,
13437
13473
  onSelect({ item, event }) {
13438
13474
  saveRecentSearch(item);
13439
13475
  if (!isModifierEvent(event)) onClose();
@@ -13447,26 +13483,18 @@ async function buildQuerySources({ query, state: sourcesState, setContext, setSt
13447
13483
  const potentialParent = groupedHits.find((siblingItem) => siblingItem.type === "lvl1" && siblingItem.hierarchy.lvl1 === item.hierarchy.lvl1);
13448
13484
  if (item.type !== "lvl1" && potentialParent) parent = potentialParent;
13449
13485
  return _objectSpread2$2(_objectSpread2$2({}, item), {}, { __docsearch_parent: parent }, insightsParams);
13450
- }).flat()).flat();
13486
+ })).flat();
13451
13487
  }
13452
- };
13488
+ }));
13453
13489
  });
13454
13490
  } catch (error) {
13455
13491
  if (error.name === "RetryError") setStatus("error");
13456
13492
  throw error;
13457
13493
  }
13458
13494
  }
13459
- function normalizeDocSearchIndexes({ indexName, indices = [], searchParameters }) {
13460
- const indexes = [];
13461
- if (indexName && indexName !== "") indexes.push({
13462
- name: indexName,
13463
- searchParameters
13464
- });
13465
- if (indices.length > 0) indices.forEach((index) => {
13466
- indexes.push(typeof index === "string" ? { name: index } : index);
13467
- });
13468
- if (indexes.length < 1) throw new Error("Must supply either `indexName` or `indices` for DocSearch to work");
13469
- return indexes;
13495
+ function normalizeDocSearchIndexes({ indices }) {
13496
+ if (!Array.isArray(indices) || indices.length < 1) throw new Error("Must supply at least one `indices` entry for DocSearch");
13497
+ return indices.map((index) => typeof index === "string" ? { name: index } : index);
13470
13498
  }
13471
13499
 
13472
13500
  //#endregion
@@ -16277,7 +16305,7 @@ function createAutocomplete(options) {
16277
16305
  }
16278
16306
 
16279
16307
  //#endregion
16280
- //#region ../docsearch-react/dist/esm/DocSearchModal-CpvDjo1O.js
16308
+ //#region ../docsearch-react/dist/esm/DocSearchModal-CITTG0fe.js
16281
16309
  init_compat();
16282
16310
  const _excluded$3 = ["translations"];
16283
16311
  function KeywordSearchBox(_ref) {
@@ -16301,9 +16329,9 @@ function KeywordSearchBox(_ref) {
16301
16329
  actionsBeforeClose
16302
16330
  }));
16303
16331
  }
16304
- const _excluded$2 = ["translations"];
16332
+ const _excluded$2$1 = ["translations"];
16305
16333
  function KeywordStartScreen(_ref) {
16306
- let { translations = {} } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$2);
16334
+ let { translations = {} } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$2$1);
16307
16335
  return /* @__PURE__ */ En.createElement("div", { className: "DocSearch-Dropdown-Container" }, /* @__PURE__ */ En.createElement(StoredSearchesSections, _objectSpread2$2(_objectSpread2$2({}, props), {}, { translations })));
16308
16336
  }
16309
16337
  const _excluded$1$1 = ["translations"];
@@ -16311,14 +16339,16 @@ const ScreenState = En.memo((_ref) => {
16311
16339
  var _props$state;
16312
16340
  let { translations = {} } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$1$1);
16313
16341
  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 });
16314
- if (!props.state.query) return /* @__PURE__ */ En.createElement(KeywordStartScreen, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
16342
+ if (isQueryEmpty(props.state.query)) return /* @__PURE__ */ En.createElement(KeywordStartScreen, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
16315
16343
  hasCollections: props.hasCollections,
16316
16344
  translations: translations === null || translations === void 0 ? void 0 : translations.startScreen
16317
16345
  }));
16318
16346
  if (!props.hasCollections) return /* @__PURE__ */ En.createElement(NoResultsScreen, _objectSpread2$2(_objectSpread2$2({}, props), {}, { translations: translations === null || translations === void 0 ? void 0 : translations.noResultsScreen }));
16319
16347
  return /* @__PURE__ */ En.createElement(ResultsScreen, _objectSpread2$2(_objectSpread2$2({}, props), {}, { translations: translations === null || translations === void 0 ? void 0 : translations.resultsScreen }));
16320
- }, function areEqual(_prevProps, nextProps) {
16321
- return nextProps.state.status === "loading" || nextProps.state.status === "stalled";
16348
+ }, function areEqual(prevProps, nextProps) {
16349
+ const isLoading = nextProps.state.status === "loading" || nextProps.state.status === "stalled";
16350
+ const isWaitingForCollections = nextProps.state.status === "idle" && !isQueryEmpty(nextProps.state.query) && prevProps.state.query !== nextProps.state.query && prevProps.state.collections === nextProps.state.collections;
16351
+ return isLoading || isWaitingForCollections;
16322
16352
  });
16323
16353
  const _excluded$4 = [
16324
16354
  "appId",
@@ -16340,9 +16370,8 @@ const _excluded$4 = [
16340
16370
  "recentSearchesLimit",
16341
16371
  "recentSearchesWithFavoritesLimit",
16342
16372
  "indices",
16343
- "indexName",
16344
- "searchParameters",
16345
- "facets"
16373
+ "facets",
16374
+ "footerAction"
16346
16375
  ];
16347
16376
  const _excluded2 = [
16348
16377
  "footer",
@@ -16351,7 +16380,7 @@ const _excluded2 = [
16351
16380
  ];
16352
16381
  function DocSearchModal(_ref) {
16353
16382
  var _translations$searchB;
16354
- let { appId, apiKey, maxResultsPerGroup, theme, onClose = noop$1, transformItems = identity, hitComponent = Hit, resultsFooterComponent = () => null, navigator, initialScrollY = 0, transformSearchClient = identity, disableUserPersonalization = false, initialQuery: initialQueryFromProp = "", translations = {}, getMissingResultsUrl, insights = false, recentSearchesLimit = 7, recentSearchesWithFavoritesLimit = 4, indices = [], indexName, searchParameters, facets } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$4);
16383
+ let { appId, apiKey, maxResultsPerGroup, theme, onClose = noop$1, transformItems = identity, hitComponent = Hit, resultsFooterComponent = () => null, navigator, initialScrollY = 0, transformSearchClient = identity, disableUserPersonalization = false, initialQuery: initialQueryFromProp = "", translations = {}, getMissingResultsUrl, insights = false, recentSearchesLimit = 7, recentSearchesWithFavoritesLimit = 4, indices, facets, footerAction } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$4);
16355
16384
  const { footer: footerTranslations, searchBox: searchBoxTranslations, facets: facetBarTranslations } = translations, screenStateTranslations = _objectWithoutProperties$6(translations, _excluded2);
16356
16385
  const [state, setState] = En.useState({
16357
16386
  query: "",
@@ -16363,18 +16392,10 @@ function DocSearchModal(_ref) {
16363
16392
  status: "idle"
16364
16393
  });
16365
16394
  const placeholder = (translations === null || translations === void 0 || (_translations$searchB = translations.searchBox) === null || _translations$searchB === void 0 ? void 0 : _translations$searchB.placeholderText) || props.placeholder || "Search docs";
16366
- const { containerRef, modalRef, formElementRef, dropdownRef, inputRef, snippetLength } = useModalRefs();
16395
+ const { containerRef, modalRef, formElementRef, dropdownRef, inputRef } = useModalRefs();
16367
16396
  const { initialQuery, initialQueryFromSelection } = useInitialModalQuery(initialQueryFromProp);
16368
16397
  const searchClient = useSearchClient(appId, apiKey, transformSearchClient);
16369
- const indexes = En.useMemo(() => normalizeDocSearchIndexes({
16370
- indexName,
16371
- indices,
16372
- searchParameters
16373
- }), [
16374
- indexName,
16375
- indices,
16376
- searchParameters
16377
- ]);
16398
+ const indexes = En.useMemo(() => normalizeDocSearchIndexes({ indices }), [indices]);
16378
16399
  const defaultIndexName = indexes[0].name;
16379
16400
  const autocompleteRef = En.useRef(void 0);
16380
16401
  const { visibleFacets, facetSelections, facetSelectionsRef, handleFacetSelectionChange, clearFacetSelections } = useDocSearchFacets({
@@ -16411,7 +16432,7 @@ function DocSearchModal(_ref) {
16411
16432
  setState(changes.state);
16412
16433
  },
16413
16434
  getSources({ query, state: sourcesState, setContext, setStatus }) {
16414
- if (!query) return buildNoQuerySources({
16435
+ if (isQueryEmpty(query)) return buildNoQuerySources({
16415
16436
  recentSearches,
16416
16437
  favoriteSearches,
16417
16438
  saveRecentSearch,
@@ -16425,7 +16446,6 @@ function DocSearchModal(_ref) {
16425
16446
  setStatus,
16426
16447
  searchClient,
16427
16448
  indexes,
16428
- snippetLength,
16429
16449
  insights: Boolean(insights),
16430
16450
  appId,
16431
16451
  apiKey,
@@ -16447,7 +16467,6 @@ function DocSearchModal(_ref) {
16447
16467
  inputRef,
16448
16468
  initialScrollY,
16449
16469
  modalRef,
16450
- snippetLength,
16451
16470
  theme
16452
16471
  });
16453
16472
  En.useEffect(() => {
@@ -16460,7 +16479,7 @@ function DocSearchModal(_ref) {
16460
16479
  });
16461
16480
  let showDocsearchDropdown = true;
16462
16481
  const hasCollections = state.collections.some((collection) => collection.items.length > 0);
16463
- if (state.status === "idle" && hasCollections === false && state.query.length === 0) showDocsearchDropdown = false;
16482
+ if (state.status === "idle" && hasCollections === false && isQueryEmpty(state.query)) showDocsearchDropdown = false;
16464
16483
  return /* @__PURE__ */ En.createElement(ModalShell, {
16465
16484
  state,
16466
16485
  containerRef,
@@ -16472,13 +16491,13 @@ function DocSearchModal(_ref) {
16472
16491
  searchBox: /* @__PURE__ */ En.createElement(KeywordSearchBox, _objectSpread2$2(_objectSpread2$2({}, autocomplete), {}, {
16473
16492
  state,
16474
16493
  placeholder: placeholder || "Search docs",
16475
- autoFocus: initialQuery.length === 0,
16494
+ autoFocus: isQueryEmpty(initialQuery),
16476
16495
  inputRef,
16477
16496
  isFromSelection: Boolean(initialQuery) && initialQuery === initialQueryFromSelection,
16478
16497
  translations: searchBoxTranslations,
16479
16498
  onClose
16480
16499
  })),
16481
- filterBar: state.query !== "" ? /* @__PURE__ */ En.createElement(FacetBar, {
16500
+ filterBar: !isQueryEmpty(state.query) ? /* @__PURE__ */ En.createElement(FacetBar, {
16482
16501
  facets: visibleFacets,
16483
16502
  selections: facetSelections,
16484
16503
  translations: facetBarTranslations,
@@ -16504,7 +16523,10 @@ function DocSearchModal(_ref) {
16504
16523
  if (!isModifierEvent(event)) onClose();
16505
16524
  }
16506
16525
  })),
16507
- footer: /* @__PURE__ */ En.createElement(Footer, { translations: footerTranslations }),
16526
+ footer: /* @__PURE__ */ En.createElement(Footer, {
16527
+ translations: footerTranslations,
16528
+ footerAction
16529
+ }),
16508
16530
  onClose
16509
16531
  });
16510
16532
  }
@@ -16588,7 +16610,7 @@ init_compat();
16588
16610
  function isEditingContent(event) {
16589
16611
  const element = event.composedPath()[0];
16590
16612
  const tagName = element.tagName;
16591
- return element.isContentEditable || tagName === "INPUT" || tagName === "SELECT" || tagName === "TEXTAREA";
16613
+ return element.isContentEditable || tagName === "INPUT" || tagName === "SELECT" || tagName === "TEXTAREA" || tagName === "BUTTON";
16592
16614
  }
16593
16615
  function useDocSearchKeyboardEvents({ isOpen, isAskAiActive, onAskAiToggle, onClose, onOpen, keyboardShortcuts = DEFAULT_KEYBOARD_SHORTCUTS }) {
16594
16616
  En.useEffect(() => {
@@ -16656,8 +16678,10 @@ function _objectWithoutProperties(e, t) {
16656
16678
  }
16657
16679
  return i;
16658
16680
  }
16659
- const _excluded$1 = [
16681
+ const _excluded$2 = [
16660
16682
  "children",
16683
+ "appId",
16684
+ "apiKey",
16661
16685
  "theme",
16662
16686
  "onReady",
16663
16687
  "onOpen",
@@ -16668,7 +16692,7 @@ const _excluded$1 = [
16668
16692
  const Context = En.createContext(void 0);
16669
16693
  Context.displayName = "DocSearchContext";
16670
16694
  function DocSearchInner$1(_ref, ref) {
16671
- let { children, theme, onReady, onOpen, onClose, onSidepanelOpen, onSidepanelClose } = _ref, props = _objectWithoutProperties(_ref, _excluded$1);
16695
+ let { children, appId, apiKey, theme, onReady, onOpen, onClose, onSidepanelOpen, onSidepanelClose } = _ref, props = _objectWithoutProperties(_ref, _excluded$2);
16672
16696
  const [docsearchState, setDocsearchState] = En.useState("ready");
16673
16697
  const [initialQuery, setInitialQuery] = En.useState(props.initialQuery || "");
16674
16698
  const searchButtonRef = En.useRef(null);
@@ -16775,6 +16799,8 @@ function DocSearchInner$1(_ref, ref) {
16775
16799
  keyboardShortcuts
16776
16800
  });
16777
16801
  const value = En.useMemo(() => ({
16802
+ appId,
16803
+ apiKey,
16778
16804
  docsearchState,
16779
16805
  setDocsearchState,
16780
16806
  searchButtonRef,
@@ -16789,6 +16815,8 @@ function DocSearchInner$1(_ref, ref) {
16789
16815
  registerView,
16790
16816
  isHybridModeSupported
16791
16817
  }), [
16818
+ appId,
16819
+ apiKey,
16792
16820
  docsearchState,
16793
16821
  searchButtonRef,
16794
16822
  initialQuery,
@@ -16815,19 +16843,28 @@ function useDocSearch() {
16815
16843
  //#endregion
16816
16844
  //#region ../docsearch-react/dist/esm/index.js
16817
16845
  init_compat();
16818
- function DocSearchComponent(props, ref) {
16819
- return /* @__PURE__ */ En.createElement(DocSearch$1, _objectSpread2$2(_objectSpread2$2({}, props), {}, { ref }), /* @__PURE__ */ En.createElement(DocSearchInner, props));
16846
+ const _excluded$1 = ["appId", "apiKey"];
16847
+ function DocSearchComponent(_ref, ref) {
16848
+ let { appId, apiKey } = _ref, props = _objectWithoutProperties$6(_ref, _excluded$1);
16849
+ return /* @__PURE__ */ En.createElement(DocSearch$1, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
16850
+ appId,
16851
+ apiKey,
16852
+ ref
16853
+ }), /* @__PURE__ */ En.createElement(DocSearchInner, props));
16820
16854
  }
16821
16855
  const DocSearch = En.forwardRef(DocSearchComponent);
16822
16856
  function DocSearchInner(props) {
16823
16857
  var _props$translations, _props$translations2, _props$portalContaine;
16824
- const { searchButtonRef, keyboardShortcuts, isModalActive, initialQuery, openModal, closeModal } = useDocSearch();
16858
+ const { searchButtonRef, keyboardShortcuts, isModalActive, initialQuery, openModal, closeModal, appId, apiKey } = useDocSearch();
16859
+ if (!appId || !apiKey) throw new Error("`DocSearch` requires `appId` and `apiKey` props.");
16825
16860
  return /* @__PURE__ */ En.createElement(En.Fragment, null, /* @__PURE__ */ En.createElement(DocSearchButton, {
16826
16861
  keyboardShortcuts,
16827
16862
  ref: searchButtonRef,
16828
16863
  translations: (_props$translations = props.translations) === null || _props$translations === void 0 ? void 0 : _props$translations.button,
16829
16864
  onClick: openModal
16830
16865
  }), isModalActive && H(/* @__PURE__ */ En.createElement(DocSearchModal, _objectSpread2$2(_objectSpread2$2({}, props), {}, {
16866
+ appId,
16867
+ apiKey,
16831
16868
  initialScrollY: window.scrollY,
16832
16869
  initialQuery,
16833
16870
  translations: props === null || props === void 0 || (_props$translations2 = props.translations) === null || _props$translations2 === void 0 ? void 0 : _props$translations2.modal,
@@ -16868,7 +16905,8 @@ const _excluded = [
16868
16905
  "environment",
16869
16906
  "transformSearchClient",
16870
16907
  "hitComponent",
16871
- "resultsFooterComponent"
16908
+ "resultsFooterComponent",
16909
+ "footerAction"
16872
16910
  ];
16873
16911
  function getHTMLElement(value, env) {
16874
16912
  if (typeof value !== "string") return value;
@@ -16891,14 +16929,16 @@ function createTemplateFunction(original) {
16891
16929
  function createDocSearch(Component, version) {
16892
16930
  return (allProps) => {
16893
16931
  const input = allProps;
16894
- const { container, environment, transformSearchClient, hitComponent, resultsFooterComponent } = input, rest = _objectWithoutProperties$5(input, _excluded);
16932
+ const { container, environment, transformSearchClient, hitComponent, resultsFooterComponent, footerAction } = input, rest = _objectWithoutProperties$5(input, _excluded);
16895
16933
  const containerElement = getHTMLElement(container, environment || (typeof window !== "undefined" ? window : void 0));
16896
16934
  const ref = b$1();
16897
16935
  let isReady = false;
16936
+ const FooterAction = createTemplateFunction(footerAction);
16898
16937
  J(_$1(Component, _objectSpread2$1(_objectSpread2$1({}, rest), {}, {
16899
16938
  ref,
16900
16939
  hitComponent: createTemplateFunction(hitComponent),
16901
16940
  resultsFooterComponent: createTemplateFunction(resultsFooterComponent),
16941
+ footerAction: FooterAction ? _$1(FooterAction, null) : void 0,
16902
16942
  transformSearchClient: (searchClient) => {
16903
16943
  if (typeof searchClient === "object" && searchClient !== null && "addAlgoliaAgent" in searchClient && typeof searchClient.addAlgoliaAgent === "function") searchClient.addAlgoliaAgent("docsearch.js", version);
16904
16944
  return typeof transformSearchClient === "function" ? transformSearchClient(searchClient) : searchClient;