@nuskin/react-search-components 1.0.0-comx-3067.8 → 1.0.0-widget-integration.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/index.js CHANGED
@@ -1,19 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var styled6 = require('@emotion/styled');
4
+ var styled4 = require('@emotion/styled');
5
5
  var foundationTheme = require('@nuskin/foundation-theme');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
- var reactSearchSdk = require('@nuskin/react-search-sdk');
8
- var reactDom = require('react-dom');
9
- var reactProductComponents = require('@nuskin/react-product-components');
10
- var nsContentstackLib = require('@ns/ns-contentstack-lib');
11
- var react = require('@emotion/react');
7
+ var foundationUiComponents = require('@nuskin/foundation-ui-components');
8
+ var material = require('@mui/material');
12
9
 
13
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
11
 
15
12
  var React__default = /*#__PURE__*/_interopDefault(React);
16
- var styled6__default = /*#__PURE__*/_interopDefault(styled6);
13
+ var styled4__default = /*#__PURE__*/_interopDefault(styled4);
17
14
 
18
15
  var __create = Object.create;
19
16
  var __defProp = Object.defineProperty;
@@ -413,7 +410,7 @@ var require_checkPropTypes = __commonJS({
413
410
  var ReactPropTypesSecret;
414
411
  var loggedTypeFailures;
415
412
  var has;
416
- function checkPropTypes(typeSpecs, values, location, componentName, getStack2) {
413
+ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
417
414
  {
418
415
  for (var typeSpecName in typeSpecs) {
419
416
  if (has(typeSpecs, typeSpecName)) {
@@ -437,7 +434,7 @@ var require_checkPropTypes = __commonJS({
437
434
  }
438
435
  if (error instanceof Error && !(error.message in loggedTypeFailures)) {
439
436
  loggedTypeFailures[error.message] = true;
440
- var stack = getStack2 ? getStack2() : "";
437
+ var stack = getStack ? getStack() : "";
441
438
  printWarning(
442
439
  "Failed " + location + " type: " + error.message + (stack != null ? stack : "")
443
440
  );
@@ -2574,7 +2571,7 @@ function initializeContent(effects) {
2574
2571
  }
2575
2572
 
2576
2573
  // node_modules/micromark/lib/initialize/document.js
2577
- var document2 = {
2574
+ var document = {
2578
2575
  tokenize: initializeDocument
2579
2576
  };
2580
2577
  var containerConstruct = {
@@ -8268,14 +8265,14 @@ __export(constructs_exports, {
8268
8265
  attentionMarkers: () => attentionMarkers,
8269
8266
  contentInitial: () => contentInitial,
8270
8267
  disable: () => disable,
8271
- document: () => document3,
8268
+ document: () => document2,
8272
8269
  flow: () => flow2,
8273
8270
  flowInitial: () => flowInitial,
8274
8271
  insideSpan: () => insideSpan,
8275
8272
  string: () => string2,
8276
8273
  text: () => text2
8277
8274
  });
8278
- var document3 = {
8275
+ var document2 = {
8279
8276
  [42]: list,
8280
8277
  [43]: list,
8281
8278
  [45]: list,
@@ -8349,7 +8346,7 @@ function parse(options) {
8349
8346
  lazy: {},
8350
8347
  constructs: constructs2,
8351
8348
  content: create2(content),
8352
- document: create2(document2),
8349
+ document: create2(document),
8353
8350
  flow: create2(flow),
8354
8351
  string: create2(string),
8355
8352
  text: create2(text)
@@ -11979,13 +11976,13 @@ var SEARCH_MESSAGE_SENDERS = {
11979
11976
 
11980
11977
  // src/components/SearchMessage/SearchMessage.styled.tsx
11981
11978
  var { colors } = foundationTheme.nuskinTheme;
11982
- var SearchMessageRoot = styled6__default.default.div`
11979
+ var SearchMessageRoot = styled4__default.default.div`
11983
11980
  display: flex;
11984
11981
  inline-size: 100%;
11985
11982
  justify-content: ${({ $sender }) => $sender === SEARCH_MESSAGE_SENDERS.USER ? "flex-end" : "flex-start"};
11986
11983
  min-inline-size: 0;
11987
11984
  `;
11988
- var SearchMessageContent = styled6__default.default.div`
11985
+ var SearchMessageContent = styled4__default.default.div`
11989
11986
  background-color: ${({ $sender }) => $sender === SEARCH_MESSAGE_SENDERS.USER ? colors.neutral[30] : "transparent"};
11990
11987
  border-radius: ${({ $sender }) => $sender === SEARCH_MESSAGE_SENDERS.USER ? "999px" : "0"};
11991
11988
  max-inline-size: ${({ $sender }) => $sender === SEARCH_MESSAGE_SENDERS.USER ? "min(100%, 40rem)" : "100%"};
@@ -12051,13 +12048,17 @@ var ICON_COLOR_BY_TYPE = {
12051
12048
  [ICON_TYPES.CHECK_VERIFIED]: "#5f86ad",
12052
12049
  [ICON_TYPES.STAR_GREY]: "#c9c9c9"
12053
12050
  };
12054
- var TEMPORARY_GLYPH_BY_ICON_TYPE = {
12055
- [ICON_TYPES.ARROW_DOWN]: "\u2193",
12056
- [ICON_TYPES.ARROW_LEFT]: "\u2190",
12057
- [ICON_TYPES.ARROW_RIGHT]: "\u2192",
12058
- [ICON_TYPES.ARROW_UP]: "\u2191",
12059
- [ICON_TYPES.CHECK_VERIFIED]: "\u2713",
12060
- [ICON_TYPES.CLOSE]: "\xD7"
12051
+ var FOUNDATION_ICON_NAME_BY_ICON_TYPE = {
12052
+ [ICON_TYPES.ARROW_DOWN]: "arrowDown",
12053
+ [ICON_TYPES.ARROW_LEFT]: "arrowLeft",
12054
+ [ICON_TYPES.ARROW_RIGHT]: "arrowRight",
12055
+ [ICON_TYPES.ARROW_UP]: "arrowUp",
12056
+ [ICON_TYPES.CHECK_VERIFIED]: "checkVerified",
12057
+ [ICON_TYPES.CLOSE]: "close"
12058
+ };
12059
+ var FOUNDATION_SIZE_BY_ICON_SIZE = {
12060
+ [ICON_SIZES.LARGE]: "large",
12061
+ [ICON_SIZES.SMALL]: "small"
12061
12062
  };
12062
12063
  function iconStyle(color2, cursor) {
12063
12064
  return {
@@ -12066,34 +12067,24 @@ function iconStyle(color2, cursor) {
12066
12067
  display: "block"
12067
12068
  };
12068
12069
  }
12069
- function TemporaryGlyphIcon({
12070
+ function FoundationIcon({
12070
12071
  className,
12071
12072
  color: color2,
12072
12073
  cursor,
12073
- glyph,
12074
+ name,
12074
12075
  size,
12075
12076
  testId
12076
12077
  }) {
12077
- const dimensions = SQUARE_SIZE_BY_ICON_SIZE[size];
12078
12078
  return /* @__PURE__ */ jsxRuntime.jsx(
12079
- "span",
12079
+ foundationUiComponents.NsIcon,
12080
12080
  {
12081
- "aria-hidden": "true",
12082
- className,
12083
- "data-testid": testId,
12084
- style: {
12085
- ...iconStyle(color2, cursor),
12086
- alignItems: "center",
12087
- display: "inline-flex",
12088
- fontSize: dimensions,
12089
- fontWeight: 300,
12090
- height: dimensions,
12091
- justifyContent: "center",
12092
- lineHeight: 1,
12093
- textAlign: "center",
12094
- width: dimensions
12095
- },
12096
- children: glyph
12081
+ "aria-hidden": true,
12082
+ ...className === void 0 ? {} : { className },
12083
+ colorOverride: color2,
12084
+ cursor,
12085
+ name,
12086
+ size: FOUNDATION_SIZE_BY_ICON_SIZE[size],
12087
+ testId
12097
12088
  }
12098
12089
  );
12099
12090
  }
@@ -12461,16 +12452,16 @@ function Icon({
12461
12452
  size,
12462
12453
  testId: resolvedTestId
12463
12454
  };
12464
- const temporaryGlyph = TEMPORARY_GLYPH_BY_ICON_TYPE[type];
12465
- if (temporaryGlyph !== void 0) {
12466
- return /* @__PURE__ */ jsxRuntime.jsx(TemporaryGlyphIcon, { ...customProps, glyph: temporaryGlyph });
12455
+ const foundationName = FOUNDATION_ICON_NAME_BY_ICON_TYPE[type];
12456
+ if (foundationName !== void 0) {
12457
+ return /* @__PURE__ */ jsxRuntime.jsx(FoundationIcon, { ...customProps, name: foundationName });
12467
12458
  }
12468
12459
  const IconView = ICON_VIEW_BY_TYPE[type];
12469
12460
  return IconView === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(IconView, { ...customProps });
12470
12461
  }
12471
12462
  var { colors: colors2 } = foundationTheme.nuskinTheme;
12472
12463
  var voiceListeningColor = "#6964f1";
12473
- var SearchMessageInputRoot = styled6__default.default.form`
12464
+ var SearchMessageInputRoot = styled4__default.default.form`
12474
12465
  && {
12475
12466
  align-items: end;
12476
12467
  background-color: ${colors2.primary.white};
@@ -12478,7 +12469,7 @@ var SearchMessageInputRoot = styled6__default.default.form`
12478
12469
  border-radius: 1.5rem;
12479
12470
  display: grid;
12480
12471
  gap: 0.5rem;
12481
- grid-template-columns: minmax(0, 1fr) auto;
12472
+ grid-template-columns: ${({ $hasActions = true }) => $hasActions ? "minmax(0, 1fr) auto" : "minmax(0, 1fr)"};
12482
12473
  inline-size: 100%;
12483
12474
  padding: 0.5rem;
12484
12475
 
@@ -12493,7 +12484,7 @@ var SearchMessageInputRoot = styled6__default.default.form`
12493
12484
  }
12494
12485
  }
12495
12486
  `;
12496
- var SearchMessageInputField = styled6__default.default.textarea`
12487
+ var SearchMessageInputField = styled4__default.default.textarea`
12497
12488
  appearance: none;
12498
12489
  background: transparent;
12499
12490
  border: 0;
@@ -12512,19 +12503,19 @@ var SearchMessageInputField = styled6__default.default.textarea`
12512
12503
  opacity: 1;
12513
12504
  }
12514
12505
  `;
12515
- var SearchMessageInputActions = styled6__default.default.div`
12506
+ var SearchMessageInputActions = styled4__default.default.div`
12516
12507
  align-items: center;
12517
12508
  display: flex;
12518
12509
  gap: 0.375rem;
12519
12510
  `;
12520
- var SearchMessageInputActionButton = styled6__default.default.button`
12511
+ var SearchMessageInputActionButton = styled4__default.default.button`
12521
12512
  &&&& {
12522
12513
  align-items: center;
12523
12514
  appearance: none;
12524
- background-color: ${({ $active, $voiceListening }) => $voiceListening ? voiceListeningColor : $active ? colors2.neutral[30] : "transparent"};
12515
+ background-color: ${({ $voiceListening }) => $voiceListening ? voiceListeningColor : "transparent"};
12525
12516
  border: 0;
12526
12517
  border-radius: 50% !important;
12527
- color: ${({ $active, $voiceListening }) => $voiceListening ? colors2.primary.white : $active ? colors2.neutral[20] : "inherit"};
12518
+ color: ${({ $voiceListening }) => $voiceListening ? colors2.primary.white : "inherit"};
12528
12519
  cursor: pointer;
12529
12520
  display: inline-flex;
12530
12521
  flex: 0 0 auto;
@@ -12581,7 +12572,6 @@ function SearchMessageInput({
12581
12572
  onVoiceInput,
12582
12573
  placeholder,
12583
12574
  showVoiceInput = false,
12584
- submitLabel,
12585
12575
  value,
12586
12576
  voiceInputLabel,
12587
12577
  voiceListening = false,
@@ -12614,62 +12604,45 @@ function SearchMessageInput({
12614
12604
  submitMessage();
12615
12605
  }
12616
12606
  }
12617
- return /* @__PURE__ */ jsxRuntime.jsxs(SearchMessageInputRoot, { ...props, $voiceListening: voiceListening, onSubmit: handleSubmit, children: [
12618
- /* @__PURE__ */ jsxRuntime.jsx(
12619
- SearchMessageInputField,
12620
- {
12621
- "aria-label": inputLabel,
12622
- onChange: (event) => {
12623
- setDraft(event.target.value);
12624
- onChange == null ? void 0 : onChange(event.target.value);
12625
- },
12626
- onKeyDown: handleKeyDown,
12627
- placeholder: voiceListening && !draft ? voiceListeningLabel : placeholder,
12628
- rows: 1,
12629
- value: draft
12630
- }
12631
- ),
12632
- /* @__PURE__ */ jsxRuntime.jsxs(SearchMessageInputActions, { children: [
12633
- showVoiceInput ? /* @__PURE__ */ jsxRuntime.jsx(
12634
- SearchMessageInputActionButton,
12635
- {
12636
- "aria-label": voiceInputLabel,
12637
- "aria-pressed": voiceListening,
12638
- $voiceListening: voiceListening,
12639
- onClick: onVoiceInput,
12640
- type: "button",
12641
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { cursor: ICON_CURSORS.POINTER, type: ICON_TYPES.VOICE })
12642
- }
12643
- ) : null,
12644
- /* @__PURE__ */ jsxRuntime.jsx(
12645
- SearchMessageInputActionButton,
12646
- {
12647
- $active: message.length > 0,
12648
- "aria-label": submitLabel,
12649
- disabled: message.length === 0,
12650
- type: "submit",
12651
- children: /* @__PURE__ */ jsxRuntime.jsx(
12652
- Icon,
12653
- {
12654
- cursor: ICON_CURSORS.POINTER,
12655
- type: message.length > 0 ? ICON_TYPES.ARROW_UP : ICON_TYPES.ASK_NUI
12656
- }
12657
- )
12658
- }
12659
- )
12660
- ] })
12661
- ] });
12607
+ return /* @__PURE__ */ jsxRuntime.jsxs(
12608
+ SearchMessageInputRoot,
12609
+ {
12610
+ ...props,
12611
+ $hasActions: showVoiceInput,
12612
+ $voiceListening: voiceListening,
12613
+ onSubmit: handleSubmit,
12614
+ children: [
12615
+ /* @__PURE__ */ jsxRuntime.jsx(
12616
+ SearchMessageInputField,
12617
+ {
12618
+ "aria-label": inputLabel,
12619
+ onChange: (event) => {
12620
+ setDraft(event.target.value);
12621
+ onChange == null ? void 0 : onChange(event.target.value);
12622
+ },
12623
+ onKeyDown: handleKeyDown,
12624
+ placeholder: voiceListening && !draft ? voiceListeningLabel : placeholder,
12625
+ rows: 1,
12626
+ value: draft
12627
+ }
12628
+ ),
12629
+ showVoiceInput ? /* @__PURE__ */ jsxRuntime.jsx(SearchMessageInputActions, { children: /* @__PURE__ */ jsxRuntime.jsx(
12630
+ SearchMessageInputActionButton,
12631
+ {
12632
+ "aria-label": voiceInputLabel,
12633
+ "aria-pressed": voiceListening,
12634
+ $voiceListening: voiceListening,
12635
+ onClick: onVoiceInput,
12636
+ type: "button",
12637
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { cursor: ICON_CURSORS.POINTER, type: ICON_TYPES.VOICE })
12638
+ }
12639
+ ) }) : null
12640
+ ]
12641
+ }
12642
+ );
12662
12643
  }
12663
12644
  var { colors: colors3 } = foundationTheme.nuskinTheme;
12664
- var SearchModalOverlay = styled6__default.default.div`
12665
- position: fixed;
12666
- inset: 0;
12667
- z-index: 10000;
12668
- background: rgba(0, 0, 0, 0.3);
12669
- display: flex;
12670
- flex-direction: column;
12671
- `;
12672
- var SearchPanelRoot = styled6__default.default.section`
12645
+ var SearchPanelRoot = styled4__default.default.section`
12673
12646
  background-color: ${colors3.primary.white};
12674
12647
  border-block-end: 1px solid ${colors3.neutral[30]};
12675
12648
  color: ${colors3.primary.black};
@@ -12680,8 +12653,12 @@ var SearchPanelRoot = styled6__default.default.section`
12680
12653
  max-block-size: 92dvh;
12681
12654
  overflow: hidden;
12682
12655
  `}
12656
+ ${({ $agentMode }) => $agentMode && `
12657
+ /* a definite height, so an embedded agent that fills its host has room to lay out */
12658
+ block-size: 92dvh;
12659
+ `}
12683
12660
  `;
12684
- var SearchPanelInner = styled6__default.default.div`
12661
+ var SearchPanelInner = styled4__default.default.div`
12685
12662
  display: grid;
12686
12663
  gap: 1.5rem;
12687
12664
  inline-size: min(100%, 75rem);
@@ -12695,7 +12672,7 @@ var SearchPanelInner = styled6__default.default.div`
12695
12672
  overflow: hidden;
12696
12673
  `}
12697
12674
  `;
12698
- var SearchPanelScrollContent = styled6__default.default.div`
12675
+ var SearchPanelScrollContent = styled4__default.default.div`
12699
12676
  flex: 1;
12700
12677
  min-block-size: 0;
12701
12678
  overflow-y: auto;
@@ -12705,7 +12682,14 @@ var SearchPanelScrollContent = styled6__default.default.div`
12705
12682
  display: none;
12706
12683
  }
12707
12684
  `;
12708
- var SearchPanelHeader = styled6__default.default.header`
12685
+ var SearchPanelAgentContent = styled4__default.default.div`
12686
+ flex: 1;
12687
+ min-block-size: 0;
12688
+ min-inline-size: 0;
12689
+ overflow: hidden;
12690
+ position: relative;
12691
+ `;
12692
+ var SearchPanelHeader = styled4__default.default.header`
12709
12693
  display: flex;
12710
12694
  justify-content: space-between;
12711
12695
  align-items: center;
@@ -12714,12 +12698,12 @@ var SearchPanelHeader = styled6__default.default.header`
12714
12698
  justify-content: flex-end;
12715
12699
  `}
12716
12700
  `;
12717
- var SearchPanelLogoSlot = styled6__default.default.div`
12701
+ var SearchPanelLogoSlot = styled4__default.default.div`
12718
12702
  flex: 0 0 auto;
12719
12703
  /* when header is flex-end (chat mode), push the logo to the far left */
12720
12704
  margin-inline-end: auto;
12721
12705
  `;
12722
- var SearchPanelCloseButton = styled6__default.default.button`
12706
+ var SearchPanelCloseButton = styled4__default.default.button`
12723
12707
  align-items: center;
12724
12708
  appearance: none;
12725
12709
  background: transparent;
@@ -12736,16 +12720,17 @@ var SearchPanelCloseButton = styled6__default.default.button`
12736
12720
  outline-offset: 2px;
12737
12721
  }
12738
12722
  `;
12739
- var SearchPanelContent = styled6__default.default.div`
12723
+ var SearchPanelContent = styled4__default.default.div`
12740
12724
  min-inline-size: 0;
12741
12725
  `;
12742
- var SearchPanelMessageInput = styled6__default.default.div`
12726
+ var SearchPanelMessageInput = styled4__default.default.div`
12743
12727
  inline-size: min(100%, 44rem);
12744
12728
  justify-self: center;
12745
12729
  width: 100%;
12746
12730
  `;
12747
12731
  function SearchPanel({
12748
12732
  "aria-label": ariaLabel,
12733
+ agentMode = false,
12749
12734
  children,
12750
12735
  chatMode = false,
12751
12736
  closeLabel,
@@ -12756,83 +12741,245 @@ function SearchPanel({
12756
12741
  onClose,
12757
12742
  ...props
12758
12743
  }) {
12759
- const content3 = chatMode ? /* @__PURE__ */ jsxRuntime.jsx(SearchPanelScrollContent, { "data-scroll-container": "", children }) : /* @__PURE__ */ jsxRuntime.jsx(SearchPanelContent, { children });
12760
- return /* @__PURE__ */ jsxRuntime.jsx(SearchPanelRoot, { ...props, "aria-label": ariaLabel, $chatMode: chatMode, children: /* @__PURE__ */ jsxRuntime.jsxs(SearchPanelInner, { $chatMode: chatMode, children: [
12761
- /* @__PURE__ */ jsxRuntime.jsxs(SearchPanelHeader, { $chatMode: chatMode, children: [
12762
- logoSlot && /* @__PURE__ */ jsxRuntime.jsx(SearchPanelLogoSlot, { children: logoSlot }),
12763
- /* @__PURE__ */ jsxRuntime.jsxs(
12764
- SearchPanelCloseButton,
12744
+ const flexLayout = chatMode || agentMode;
12745
+ let content3;
12746
+ if (agentMode) {
12747
+ content3 = /* @__PURE__ */ jsxRuntime.jsx(SearchPanelAgentContent, { "data-agent-container": "", children });
12748
+ } else if (chatMode) {
12749
+ content3 = /* @__PURE__ */ jsxRuntime.jsx(SearchPanelScrollContent, { "data-scroll-container": "", children });
12750
+ } else {
12751
+ content3 = /* @__PURE__ */ jsxRuntime.jsx(SearchPanelContent, { children });
12752
+ }
12753
+ return /* @__PURE__ */ jsxRuntime.jsx(
12754
+ SearchPanelRoot,
12755
+ {
12756
+ ...props,
12757
+ "aria-label": ariaLabel,
12758
+ $chatMode: flexLayout,
12759
+ $agentMode: agentMode,
12760
+ children: /* @__PURE__ */ jsxRuntime.jsxs(SearchPanelInner, { $chatMode: flexLayout, children: [
12761
+ /* @__PURE__ */ jsxRuntime.jsxs(SearchPanelHeader, { $chatMode: flexLayout, children: [
12762
+ logoSlot && /* @__PURE__ */ jsxRuntime.jsx(SearchPanelLogoSlot, { children: logoSlot }),
12763
+ /* @__PURE__ */ jsxRuntime.jsxs(
12764
+ SearchPanelCloseButton,
12765
+ {
12766
+ type: "button",
12767
+ onMouseDown: (e) => e.preventDefault(),
12768
+ onClick: onClose,
12769
+ children: [
12770
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { cursor: ICON_CURSORS.POINTER, size: ICON_SIZES.SMALL, type: ICON_TYPES.CLOSE }),
12771
+ closeLabel
12772
+ ]
12773
+ }
12774
+ )
12775
+ ] }),
12776
+ !flexLayout && inputSlot && /* @__PURE__ */ jsxRuntime.jsx(SearchPanelMessageInput, { children: inputSlot }),
12777
+ !agentMode && initialPrompt && /* @__PURE__ */ jsxRuntime.jsx(SearchMessage, { sender: SEARCH_MESSAGE_SENDERS.USER, text: initialPrompt }),
12778
+ content3,
12779
+ !agentMode && (chatMode || !inputSlot && messageInputProps) && messageInputProps && /* @__PURE__ */ jsxRuntime.jsx(SearchPanelMessageInput, { children: /* @__PURE__ */ jsxRuntime.jsx(SearchMessageInput, { ...messageInputProps }) })
12780
+ ] })
12781
+ }
12782
+ );
12783
+ }
12784
+ var MOBILE_MAX_PX = 1024;
12785
+ var colors4 = {
12786
+ text: "#111827",
12787
+ muted: "#6b7280",
12788
+ hover: "#f3f4f6",
12789
+ surface: "#ffffff",
12790
+ borderLight: "#e5e7eb"
12791
+ };
12792
+ var SearchModalBackdropRoot = styled4__default.default.div`
12793
+ -webkit-tap-highlight-color: transparent;
12794
+ background-color: transparent;
12795
+ inset: 0;
12796
+ position: fixed;
12797
+ `;
12798
+ var SearchModalSurface = styled4__default.default.div`
12799
+ inline-size: 100%;
12800
+ outline: none;
12801
+ position: relative;
12802
+ z-index: 1;
12803
+ `;
12804
+ var SearchSuggestionsPanel = styled4__default.default.div`
12805
+ position: relative;
12806
+ width: 100%;
12807
+ margin-top: 8px;
12808
+ `;
12809
+ var SearchSuggestionsList = styled4__default.default.ul`
12810
+ display: flex;
12811
+ flex-direction: column;
12812
+ list-style: none;
12813
+ margin: 0;
12814
+ padding: 0;
12815
+ `;
12816
+ var SearchSuggestionOption = styled4__default.default.li`
12817
+ display: flex;
12818
+ align-items: center;
12819
+ width: 100%;
12820
+ min-height: 58px;
12821
+ padding: 4px 24px;
12822
+ box-sizing: border-box;
12823
+ color: ${colors4.text};
12824
+ `;
12825
+ var PassiveSuggestionOption = styled4__default.default(SearchSuggestionOption)`
12826
+ cursor: default;
12827
+ color: ${colors4.muted};
12828
+ `;
12829
+ var SuggestionSectionHeading = styled4__default.default.div`
12830
+ padding: 12px 24px 8px;
12831
+ margin-bottom: 4px;
12832
+ font-size: 16px;
12833
+ font-weight: 700;
12834
+ color: ${colors4.text};
12835
+ background: ${colors4.surface};
12836
+ border-bottom: 1px solid ${colors4.borderLight};
12837
+ `;
12838
+ var RecentSearchesSection = styled4__default.default.section`
12839
+ padding: 24px 35px 18px;
12840
+ background: ${colors4.surface};
12841
+
12842
+ @media (max-width: ${MOBILE_MAX_PX}px) {
12843
+ padding: 18px 20px 16px;
12844
+ }
12845
+ `;
12846
+ var RecentSearchesHeader = styled4__default.default.div`
12847
+ display: flex;
12848
+ align-items: center;
12849
+ justify-content: space-between;
12850
+ gap: 16px;
12851
+ margin-bottom: 13px;
12852
+ `;
12853
+ var RecentSearchesTitle = styled4__default.default.h3`
12854
+ margin: 0;
12855
+ font-size: 16px;
12856
+ font-weight: 700;
12857
+ color: ${colors4.text};
12858
+
12859
+ @media (max-width: ${MOBILE_MAX_PX}px) {
12860
+ font-size: 15px;
12861
+ line-height: 1.35;
12862
+ }
12863
+ `;
12864
+ var RecentSearchesClearButton = styled4__default.default.button`
12865
+ margin: 0;
12866
+ padding: 0;
12867
+ border: none;
12868
+ background: transparent;
12869
+ color: ${colors4.text};
12870
+ font-size: 16px;
12871
+ cursor: pointer;
12872
+
12873
+ &:focus-visible {
12874
+ outline: 2px solid ${colors4.text};
12875
+ outline-offset: 2px;
12876
+ border-radius: 4px;
12877
+ }
12878
+
12879
+ @media (max-width: ${MOBILE_MAX_PX}px) {
12880
+ font-size: 14px;
12881
+ }
12882
+ `;
12883
+ var RecentSearchesList = styled4__default.default.div`
12884
+ display: flex;
12885
+ flex-wrap: wrap;
12886
+ gap: 10px;
12887
+ `;
12888
+ var RecentSearchChip = styled4__default.default.button`
12889
+ display: inline-flex;
12890
+ align-items: center;
12891
+ justify-content: center;
12892
+ min-height: 40px;
12893
+ padding: 8px 16px;
12894
+ border: 1px solid ${colors4.borderLight};
12895
+ border-radius: 999px;
12896
+ background: ${colors4.surface};
12897
+ color: ${colors4.text};
12898
+ font-size: 16px;
12899
+ cursor: pointer;
12900
+
12901
+ &:hover {
12902
+ background: ${colors4.hover};
12903
+ }
12904
+
12905
+ &:focus-visible {
12906
+ outline: 2px solid ${colors4.text};
12907
+ outline-offset: 2px;
12908
+ }
12909
+
12910
+ @media (max-width: ${MOBILE_MAX_PX}px) {
12911
+ min-height: 36px;
12912
+ padding: 6px 14px;
12913
+ font-size: 14px;
12914
+ border-radius: 10px;
12915
+ }
12916
+ `;
12917
+ var MAX_RECENT = 6;
12918
+ function RecentSearches({
12919
+ items,
12920
+ title,
12921
+ clearLabel,
12922
+ onSelect,
12923
+ onClear
12924
+ }) {
12925
+ const [showAll, setShowAll] = React.useState(false);
12926
+ const visible = showAll ? items : items.slice(0, MAX_RECENT);
12927
+ return /* @__PURE__ */ jsxRuntime.jsxs(RecentSearchesSection, { "aria-label": title, children: [
12928
+ /* @__PURE__ */ jsxRuntime.jsxs(RecentSearchesHeader, { children: [
12929
+ /* @__PURE__ */ jsxRuntime.jsx(RecentSearchesTitle, { children: title }),
12930
+ /* @__PURE__ */ jsxRuntime.jsx(
12931
+ RecentSearchesClearButton,
12932
+ {
12933
+ type: "button",
12934
+ onMouseDown: (e) => e.preventDefault(),
12935
+ onClick: onClear,
12936
+ children: clearLabel
12937
+ }
12938
+ )
12939
+ ] }),
12940
+ /* @__PURE__ */ jsxRuntime.jsxs(RecentSearchesList, { children: [
12941
+ visible.map((query) => /* @__PURE__ */ jsxRuntime.jsx(
12942
+ RecentSearchChip,
12943
+ {
12944
+ type: "button",
12945
+ onMouseDown: (e) => e.preventDefault(),
12946
+ onClick: () => onSelect(query),
12947
+ children: query
12948
+ },
12949
+ query
12950
+ )),
12951
+ !showAll && items.length > MAX_RECENT && /* @__PURE__ */ jsxRuntime.jsxs(
12952
+ RecentSearchChip,
12765
12953
  {
12766
12954
  type: "button",
12767
12955
  onMouseDown: (e) => e.preventDefault(),
12768
- onClick: onClose,
12956
+ onClick: () => setShowAll(true),
12769
12957
  children: [
12770
- /* @__PURE__ */ jsxRuntime.jsx(Icon, { cursor: ICON_CURSORS.POINTER, size: ICON_SIZES.SMALL, type: ICON_TYPES.CLOSE }),
12771
- closeLabel
12958
+ "+",
12959
+ items.length - MAX_RECENT,
12960
+ " More"
12772
12961
  ]
12773
12962
  }
12774
12963
  )
12775
- ] }),
12776
- !chatMode && inputSlot && /* @__PURE__ */ jsxRuntime.jsx(SearchPanelMessageInput, { children: inputSlot }),
12777
- initialPrompt && /* @__PURE__ */ jsxRuntime.jsx(SearchMessage, { sender: SEARCH_MESSAGE_SENDERS.USER, text: initialPrompt }),
12778
- content3,
12779
- (chatMode || !inputSlot && messageInputProps) && messageInputProps && /* @__PURE__ */ jsxRuntime.jsx(SearchPanelMessageInput, { children: /* @__PURE__ */ jsxRuntime.jsx(SearchMessageInput, { ...messageInputProps }) })
12780
- ] }) });
12781
- }
12782
- var AI_CHAT_CONVERSATION_ID_KEY = "ai_chat_conversation_id";
12783
- function getStoredConversationId() {
12784
- try {
12785
- const raw = typeof window !== "undefined" ? window.sessionStorage.getItem(AI_CHAT_CONVERSATION_ID_KEY) : null;
12786
- if (!raw) return null;
12787
- const id = parseInt(raw, 10);
12788
- return Number.isNaN(id) ? null : id;
12789
- } catch {
12790
- return null;
12791
- }
12792
- }
12793
- function storeConversationId(id) {
12794
- try {
12795
- if (typeof window !== "undefined")
12796
- window.sessionStorage.setItem(AI_CHAT_CONVERSATION_ID_KEY, String(id));
12797
- } catch {
12798
- }
12799
- }
12800
- async function callAICommerceChat(config) {
12801
- var _a, _b;
12802
- const { searchTerm, market, language, salesAiAppKey, salesAiParentOrigin } = config;
12803
- const chatService = reactSearchSdk.createChatService({
12804
- salesAiAppKey,
12805
- salesAiParentOrigin,
12806
- market,
12807
- language
12808
- });
12809
- let conversationId = getStoredConversationId();
12810
- if (conversationId === null) {
12811
- conversationId = await chatService.createConversation("Search Session");
12812
- storeConversationId(conversationId);
12813
- }
12814
- const result = await chatService.sendMessage(conversationId, searchTerm.trim());
12815
- return {
12816
- products: (_a = result == null ? void 0 : result.products) != null ? _a : [],
12817
- summary: (_b = result == null ? void 0 : result.summary) != null ? _b : ""
12818
- };
12964
+ ] })
12965
+ ] });
12819
12966
  }
12820
12967
  var SUGGESTION_MOBILE_MAX_PX = 1024;
12821
- var colors4 = {
12968
+ var colors5 = {
12822
12969
  text: "#111827",
12823
12970
  muted: "#6b7280",
12824
12971
  accent: "rgb(15, 118, 110)"
12825
12972
  };
12826
- var SuggestionOption = styled6__default.default.li`
12973
+ var SuggestionOption = styled4__default.default.li`
12827
12974
  display: flex;
12828
12975
  align-items: center;
12829
12976
  width: 100%;
12830
12977
  min-height: 58px;
12831
12978
  padding: 4px 24px;
12832
12979
  box-sizing: border-box;
12833
- color: ${colors4.text};
12980
+ color: ${colors5.text};
12834
12981
  `;
12835
- var SuggestionRow = styled6__default.default(SuggestionOption)`
12982
+ var SuggestionRow = styled4__default.default(SuggestionOption)`
12836
12983
  display: grid;
12837
12984
  grid-template-columns: minmax(0, 1fr) 18px;
12838
12985
  align-items: center;
@@ -12842,7 +12989,7 @@ var SuggestionRow = styled6__default.default(SuggestionOption)`
12842
12989
 
12843
12990
  &[data-selected='true'] {
12844
12991
  background: rgba(15, 118, 110, 0.08);
12845
- box-shadow: inset 3px 0 0 ${colors4.accent};
12992
+ box-shadow: inset 3px 0 0 ${colors5.accent};
12846
12993
  }
12847
12994
 
12848
12995
  &[data-highlighted='true'],
@@ -12853,7 +13000,7 @@ var SuggestionRow = styled6__default.default(SuggestionOption)`
12853
13000
  &[data-highlighted='true'][data-selected='true'] {
12854
13001
  background: rgba(15, 118, 110, 0.12);
12855
13002
  box-shadow:
12856
- inset 3px 0 0 ${colors4.accent},
13003
+ inset 3px 0 0 ${colors5.accent},
12857
13004
  inset 0 0 0 2px rgba(17, 24, 39, 0.12);
12858
13005
  }
12859
13006
 
@@ -12870,7 +13017,7 @@ var SuggestionRow = styled6__default.default(SuggestionOption)`
12870
13017
  column-gap: 8px;
12871
13018
  }
12872
13019
  `;
12873
- var SuggestionContentWrapper = styled6__default.default.div`
13020
+ var SuggestionContentWrapper = styled4__default.default.div`
12874
13021
  display: grid;
12875
13022
  grid-template-columns: 50px minmax(0, 1fr);
12876
13023
  align-items: center;
@@ -12892,7 +13039,7 @@ var SuggestionContentWrapper = styled6__default.default.div`
12892
13039
  }
12893
13040
 
12894
13041
  &:focus-visible {
12895
- outline: 2px solid ${colors4.text};
13042
+ outline: 2px solid ${colors5.text};
12896
13043
  outline-offset: 3px;
12897
13044
  }
12898
13045
 
@@ -12900,14 +13047,14 @@ var SuggestionContentWrapper = styled6__default.default.div`
12900
13047
  grid-template-columns: minmax(0, 1fr);
12901
13048
  }
12902
13049
  `;
12903
- var SuggestionThumbnail = styled6__default.default.img`
13050
+ var SuggestionThumbnail = styled4__default.default.img`
12904
13051
  width: 50px;
12905
13052
  height: 50px;
12906
13053
  object-fit: contain;
12907
13054
  flex-shrink: 0;
12908
13055
  align-self: center;
12909
13056
  `;
12910
- var SuggestionLabel = styled6__default.default.span`
13057
+ var SuggestionLabel = styled4__default.default.span`
12911
13058
  display: block;
12912
13059
  min-width: 0;
12913
13060
  line-height: 24px;
@@ -12915,25 +13062,25 @@ var SuggestionLabel = styled6__default.default.span`
12915
13062
  overflow-wrap: anywhere;
12916
13063
  word-break: break-word;
12917
13064
  font-size: 16px;
12918
- color: ${colors4.text};
13065
+ color: ${colors5.text};
12919
13066
 
12920
13067
  @media (max-width: ${SUGGESTION_MOBILE_MAX_PX}px) {
12921
13068
  font-size: 14px;
12922
13069
  line-height: 20px;
12923
13070
  }
12924
13071
  `;
12925
- var SuggestionActionIcon = styled6__default.default.span`
13072
+ var SuggestionActionIcon = styled4__default.default.span`
12926
13073
  display: inline-flex;
12927
13074
  align-items: center;
12928
13075
  justify-content: center;
12929
13076
  width: 24px;
12930
13077
  height: 24px;
12931
- color: var(--suggestion-icon-color, ${colors4.text});
13078
+ color: var(--suggestion-icon-color, ${colors5.text});
12932
13079
  flex-shrink: 0;
12933
13080
  align-self: center;
12934
13081
 
12935
13082
  &[data-cart-disabled='true'] {
12936
- color: var(--suggestion-muted, ${colors4.muted});
13083
+ color: var(--suggestion-muted, ${colors5.muted});
12937
13084
  }
12938
13085
 
12939
13086
  svg {
@@ -12942,7 +13089,7 @@ var SuggestionActionIcon = styled6__default.default.span`
12942
13089
  display: block;
12943
13090
  }
12944
13091
  `;
12945
- var SuggestionActionButton = styled6__default.default.button`
13092
+ var SuggestionActionButton = styled4__default.default.button`
12946
13093
  display: inline-flex;
12947
13094
  align-items: center;
12948
13095
  justify-content: center;
@@ -12952,13 +13099,13 @@ var SuggestionActionButton = styled6__default.default.button`
12952
13099
  padding: 0;
12953
13100
  border: none;
12954
13101
  background: transparent;
12955
- color: var(--suggestion-icon-color, ${colors4.text});
13102
+ color: var(--suggestion-icon-color, ${colors5.text});
12956
13103
  flex-shrink: 0;
12957
13104
  align-self: center;
12958
13105
  cursor: pointer;
12959
13106
 
12960
13107
  &:focus-visible {
12961
- outline: 2px solid ${colors4.text};
13108
+ outline: 2px solid ${colors5.text};
12962
13109
  outline-offset: 3px;
12963
13110
  border-radius: 4px;
12964
13111
  }
@@ -12969,6 +13116,38 @@ var SuggestionActionButton = styled6__default.default.button`
12969
13116
  display: block;
12970
13117
  }
12971
13118
  `;
13119
+
13120
+ // src/components/SuggestionRow/helpers.ts
13121
+ var CART_DISABLED_PRODUCT_STATUSES = /* @__PURE__ */ new Set([
13122
+ "discontinued",
13123
+ "preview",
13124
+ "previewproduct",
13125
+ "test",
13126
+ "stopped",
13127
+ "replacement",
13128
+ "bundleonly",
13129
+ "inactive",
13130
+ "notavailable"
13131
+ ]);
13132
+ function normalizeProductStatusValue(value) {
13133
+ const text4 = typeof value === "string" || typeof value === "number" ? String(value) : "";
13134
+ return text4.trim().toLowerCase().replace(/\s+/g, "");
13135
+ }
13136
+ function isNonSellableStatusValue(statusValue) {
13137
+ if (CART_DISABLED_PRODUCT_STATUSES.has(statusValue)) return true;
13138
+ return statusValue !== "sellable" && statusValue !== "active";
13139
+ }
13140
+ function isCartActionDisabled(option) {
13141
+ var _a;
13142
+ if ((_a = option["out_of_stock"]) != null ? _a : option["outOfStock"]) return true;
13143
+ const statusValues = [
13144
+ option["productStatus"],
13145
+ option["product_status"],
13146
+ option["status"],
13147
+ option["sku_status"]
13148
+ ].map(normalizeProductStatusValue).filter(Boolean);
13149
+ return statusValues.some(isNonSellableStatusValue);
13150
+ }
12972
13151
  function resolveImageSrc(option, isDidYouMean) {
12973
13152
  var _a, _b, _c;
12974
13153
  if (isDidYouMean) return "";
@@ -12985,7 +13164,7 @@ function getSuggestionDisplayData(option) {
12985
13164
  const productType = (_a = option["product_type"]) != null ? _a : option["productType"];
12986
13165
  const outOfStock = (_b = option["out_of_stock"]) != null ? _b : option["outOfStock"];
12987
13166
  const cartDisabledRaw = (_c = option["cartActionDisabled"]) != null ? _c : option["cart_action_disabled"];
12988
- const cartActionDisabled = cartDisabledRaw != null ? Boolean(cartDisabledRaw) : reactSearchSdk.isCartActionDisabled(option);
13167
+ const cartActionDisabled = cartDisabledRaw != null ? Boolean(cartDisabledRaw) : isCartActionDisabled(option);
12989
13168
  return {
12990
13169
  imageSrc: resolveImageSrc(option, isDidYouMean),
12991
13170
  displayLabel: resolveDisplayLabel(option),
@@ -13161,12 +13340,12 @@ function SuggestionRow2({
13161
13340
  }
13162
13341
  );
13163
13342
  }
13164
- var colors5 = {
13343
+ var colors6 = {
13165
13344
  text: "#111827",
13166
13345
  surface: "#ffffff",
13167
13346
  borderLight: "#e5e7eb"
13168
13347
  };
13169
- var SeeMoreLinkContainer = styled6__default.default.div`
13348
+ var SeeMoreLinkContainer = styled4__default.default.div`
13170
13349
  position: relative;
13171
13350
  display: flex;
13172
13351
  align-items: center;
@@ -13175,7 +13354,7 @@ var SeeMoreLinkContainer = styled6__default.default.div`
13175
13354
  min-height: 48px;
13176
13355
  padding: 0 16px;
13177
13356
  box-sizing: border-box;
13178
- background: ${colors5.surface};
13357
+ background: ${colors6.surface};
13179
13358
 
13180
13359
  &::before {
13181
13360
  content: '';
@@ -13183,12 +13362,12 @@ var SeeMoreLinkContainer = styled6__default.default.div`
13183
13362
  top: 0;
13184
13363
  left: 50%;
13185
13364
  width: 100vw;
13186
- border-top: 1px solid ${colors5.borderLight};
13365
+ border-top: 1px solid ${colors6.borderLight};
13187
13366
  transform: translateX(-50%);
13188
13367
  pointer-events: none;
13189
13368
  }
13190
13369
  `;
13191
- var SeeMoreLinkText = styled6__default.default.button`
13370
+ var SeeMoreLinkText = styled4__default.default.button`
13192
13371
  width: auto;
13193
13372
  height: auto;
13194
13373
  padding: 8px 0;
@@ -13200,7 +13379,7 @@ var SeeMoreLinkText = styled6__default.default.button`
13200
13379
  text-decoration: underline;
13201
13380
  text-underline-offset: 2px;
13202
13381
  cursor: pointer;
13203
- color: ${colors5.text};
13382
+ color: ${colors6.text};
13204
13383
 
13205
13384
  &:hover {
13206
13385
  opacity: 0.8;
@@ -13211,7 +13390,7 @@ var SeeMoreLinkText = styled6__default.default.button`
13211
13390
  }
13212
13391
 
13213
13392
  &:focus-visible {
13214
- outline: 2px solid ${colors5.text};
13393
+ outline: 2px solid ${colors6.text};
13215
13394
  outline-offset: 2px;
13216
13395
  border-radius: 4px;
13217
13396
  }
@@ -13258,600 +13437,27 @@ function SeeMoreLink({
13258
13437
  }
13259
13438
  ) });
13260
13439
  }
13261
- var MOBILE_MAX_PX = 1024;
13262
- var colors6 = {
13263
- text: "#111827",
13264
- muted: "#6b7280",
13265
- hover: "#f3f4f6",
13266
- surface: "#ffffff",
13267
- borderLight: "#e5e7eb"
13268
- };
13269
- var SearchSuggestionsPanel = styled6__default.default.div`
13270
- position: relative;
13271
- width: 100%;
13272
- margin-top: 8px;
13273
- `;
13274
- var SearchSuggestionsList = styled6__default.default.ul`
13275
- display: flex;
13276
- flex-direction: column;
13277
- list-style: none;
13278
- margin: 0;
13279
- padding: 0;
13280
- `;
13281
- var SearchSuggestionOption = styled6__default.default.li`
13282
- display: flex;
13283
- align-items: center;
13284
- width: 100%;
13285
- min-height: 58px;
13286
- padding: 4px 24px;
13287
- box-sizing: border-box;
13288
- color: ${colors6.text};
13289
- `;
13290
- var PassiveSuggestionOption = styled6__default.default(SearchSuggestionOption)`
13291
- cursor: default;
13292
- color: ${colors6.muted};
13293
- `;
13294
- var AIStatusMessage = styled6__default.default.div`
13295
- padding: 12px 24px;
13296
- font-size: 14px;
13297
- font-style: italic;
13298
- color: ${colors6.muted};
13299
- min-height: 44px;
13300
- display: flex;
13301
- align-items: center;
13302
- gap: 4px;
13303
- `;
13304
- var AIStatusCursor = styled6__default.default.span`
13305
- display: inline-block;
13306
- width: 2px;
13307
- height: 1em;
13308
- background: currentColor;
13309
- margin-left: 1px;
13310
- vertical-align: text-bottom;
13311
- animation: blink 0.8s step-end infinite;
13312
- @keyframes blink {
13313
- 0%,
13314
- 100% {
13315
- opacity: 1;
13316
- }
13317
- 50% {
13318
- opacity: 0;
13319
- }
13320
- }
13321
- `;
13322
- var ChatScrollIndicator = styled6__default.default.button`
13323
- align-self: center;
13324
- appearance: none;
13325
- background: ${colors6.hover};
13326
- border: 0;
13327
- border-radius: 50%;
13328
- color: ${colors6.text};
13329
- cursor: pointer;
13330
- display: grid;
13331
- place-items: center;
13332
- block-size: 2rem;
13333
- inline-size: 2rem;
13334
- margin-block: 0.25rem 0.75rem;
13335
- margin-inline: auto;
13336
- padding: 0;
13337
- position: sticky;
13338
- inset-block-end: 0.75rem;
13339
- z-index: 1;
13340
-
13341
- &:hover {
13342
- background: ${colors6.borderLight};
13343
- }
13344
-
13345
- &:focus-visible {
13346
- outline: 2px solid ${colors6.text};
13347
- outline-offset: 2px;
13348
- }
13349
- `;
13350
- var SuggestionSectionHeading = styled6__default.default.div`
13351
- padding: 12px 24px 8px;
13352
- margin-bottom: 4px;
13353
- font-size: 16px;
13354
- font-weight: 700;
13355
- color: ${colors6.text};
13356
- background: ${colors6.surface};
13357
- border-bottom: 1px solid ${colors6.borderLight};
13358
- `;
13359
- var RecentSearchesSection = styled6__default.default.section`
13360
- padding: 24px 35px 18px;
13361
- background: ${colors6.surface};
13362
-
13363
- @media (max-width: ${MOBILE_MAX_PX}px) {
13364
- padding: 18px 20px 16px;
13365
- }
13366
- `;
13367
- var RecentSearchesHeader = styled6__default.default.div`
13368
- display: flex;
13369
- align-items: center;
13370
- justify-content: space-between;
13371
- gap: 16px;
13372
- margin-bottom: 13px;
13373
- `;
13374
- var RecentSearchesTitle = styled6__default.default.h3`
13375
- margin: 0;
13376
- font-size: 16px;
13377
- font-weight: 700;
13378
- color: ${colors6.text};
13379
-
13380
- @media (max-width: ${MOBILE_MAX_PX}px) {
13381
- font-size: 15px;
13382
- line-height: 1.35;
13383
- }
13384
- `;
13385
- var RecentSearchesClearButton = styled6__default.default.button`
13386
- margin: 0;
13387
- padding: 0;
13388
- border: none;
13389
- background: transparent;
13390
- color: ${colors6.text};
13391
- font-size: 16px;
13392
- cursor: pointer;
13393
-
13394
- &:focus-visible {
13395
- outline: 2px solid ${colors6.text};
13396
- outline-offset: 2px;
13397
- border-radius: 4px;
13398
- }
13399
-
13400
- @media (max-width: ${MOBILE_MAX_PX}px) {
13401
- font-size: 14px;
13402
- }
13403
- `;
13404
- var RecentSearchesList = styled6__default.default.div`
13405
- display: flex;
13406
- flex-wrap: wrap;
13407
- gap: 10px;
13408
- `;
13409
- var RecentSearchChip = styled6__default.default.button`
13410
- display: inline-flex;
13411
- align-items: center;
13412
- justify-content: center;
13413
- min-height: 40px;
13414
- padding: 8px 16px;
13415
- border: 1px solid ${colors6.borderLight};
13416
- border-radius: 999px;
13417
- background: ${colors6.surface};
13418
- color: ${colors6.text};
13419
- font-size: 16px;
13420
- cursor: pointer;
13421
-
13422
- &:hover {
13423
- background: ${colors6.hover};
13424
- }
13425
-
13426
- &:focus-visible {
13427
- outline: 2px solid ${colors6.text};
13428
- outline-offset: 2px;
13429
- }
13430
-
13431
- @media (max-width: ${MOBILE_MAX_PX}px) {
13432
- min-height: 36px;
13433
- padding: 6px 14px;
13434
- font-size: 14px;
13435
- border-radius: 10px;
13436
- }
13437
- `;
13438
- var { colors: colors7 } = foundationTheme.nuskinTheme;
13439
- var ChatResultRoot = styled6__default.default.div`
13440
- display: flex;
13441
- flex-direction: column;
13442
- gap: 1.5rem;
13443
- min-block-size: 0;
13444
- overflow-y: auto;
13445
- padding-block-end: 2rem;
13446
- position: relative;
13447
- `;
13448
- var ProductCarouselWrapper = styled6__default.default.div`
13449
- display: flex;
13450
- flex-direction: column;
13451
- gap: 0.75rem;
13452
- `;
13453
- styled6__default.default.div`
13454
- display: flex;
13455
- gap: 1rem;
13456
- overflow-x: auto;
13457
- padding-block-end: 0.5rem;
13458
- scroll-snap-type: x mandatory;
13459
- -webkit-overflow-scrolling: touch;
13460
- scrollbar-width: none;
13461
- &::-webkit-scrollbar {
13462
- display: none;
13463
- }
13464
- `;
13465
- styled6__default.default.a`
13466
- display: flex;
13467
- flex: 0 0 auto;
13468
- flex-direction: column;
13469
- gap: 0.5rem;
13470
- scroll-snap-align: start;
13471
- text-decoration: none;
13472
- width: 9rem;
13473
- `;
13474
- styled6__default.default.img`
13475
- background: ${colors7.primary.gray};
13476
- border-radius: 0.5rem;
13477
- block-size: 9rem;
13478
- inline-size: 9rem;
13479
- object-fit: contain;
13480
- padding: 0.5rem;
13481
- `;
13482
- styled6__default.default.span`
13483
- color: ${colors7.primary.black};
13484
- display: -webkit-box;
13485
- font-size: 0.8125rem;
13486
- line-height: 1.4;
13487
- overflow: hidden;
13488
- -webkit-box-orient: vertical;
13489
- -webkit-line-clamp: 2;
13490
- `;
13491
- styled6__default.default.span`
13492
- color: ${colors7.neutral[70]};
13493
- font-size: 0.8125rem;
13494
- font-weight: 600;
13495
- `;
13496
- styled6__default.default.button`
13497
- align-items: center;
13498
- align-self: center;
13499
- appearance: none;
13500
- background: ${colors7.neutral[30]};
13501
- border: 0;
13502
- border-radius: 50%;
13503
- bottom: 0.75rem;
13504
- color: ${colors7.primary.black};
13505
- cursor: pointer;
13506
- display: inline-flex;
13507
- justify-content: center;
13508
- block-size: 2rem;
13509
- inline-size: 2rem;
13510
- padding: 0;
13511
- position: sticky;
13512
-
13513
- &:hover {
13514
- background: ${colors7.neutral[40]};
13515
- }
13516
- `;
13517
- function isDigit(char) {
13518
- return char !== void 0 && char >= "0" && char <= "9";
13519
- }
13520
- function isLetter(char) {
13521
- if (char === void 0) return false;
13522
- const lower = char.toLowerCase();
13523
- return lower >= "a" && lower <= "z";
13524
- }
13525
- function isPricingSpace(char) {
13526
- return char === " " || char === "\n" || char === "\r" || char === " " || char === "\f";
13527
- }
13528
- function findNumberEnd(text4, start, allowCommas) {
13529
- let cursor = start;
13530
- let hasDigit = false;
13531
- while (cursor < text4.length && (isDigit(text4[cursor]) || allowCommas && text4[cursor] === ",")) {
13532
- hasDigit = hasDigit || isDigit(text4[cursor]);
13533
- cursor += 1;
13534
- }
13535
- if (text4[cursor] === "." && isDigit(text4[cursor + 1])) {
13536
- cursor += 1;
13537
- while (cursor < text4.length && isDigit(text4[cursor])) {
13538
- cursor += 1;
13539
- }
13540
- }
13541
- return hasDigit ? cursor : start;
13542
- }
13543
- function removeCurrencyAmounts(text4) {
13544
- let result = "";
13545
- let cursor = 0;
13546
- while (cursor < text4.length) {
13547
- if (text4[cursor] === "$") {
13548
- const amountEnd = findNumberEnd(text4, cursor + 1, true);
13549
- if (amountEnd > cursor + 1) {
13550
- cursor = amountEnd;
13551
- continue;
13552
- }
13553
- }
13554
- result += text4[cursor];
13555
- cursor += 1;
13556
- }
13557
- return result;
13558
- }
13559
- function removeUnitAmounts(text4, unit) {
13560
- let result = "";
13561
- let cursor = 0;
13562
- while (cursor < text4.length) {
13563
- if (isDigit(text4[cursor])) {
13564
- const numberEnd = findNumberEnd(text4, cursor, false);
13565
- let unitStart = numberEnd;
13566
- while (isPricingSpace(text4[unitStart])) {
13567
- unitStart += 1;
13568
- }
13569
- const unitEnd = unitStart + unit.length;
13570
- if (text4.slice(unitStart, unitEnd).toUpperCase() === unit && !isLetter(text4[unitEnd])) {
13571
- cursor = unitEnd;
13572
- continue;
13573
- }
13574
- }
13575
- result += text4[cursor];
13576
- cursor += 1;
13577
- }
13578
- return result;
13579
- }
13580
- function removeEmptyPricingParentheses(text4) {
13581
- let result = "";
13582
- let cursor = 0;
13583
- while (cursor < text4.length) {
13584
- if (text4[cursor] === "(") {
13585
- const candidateStart = cursor;
13586
- cursor += 1;
13587
- while (isPricingSpace(text4[cursor]) || text4[cursor] === "," || text4[cursor] === ";") {
13588
- cursor += 1;
13589
- }
13590
- if (text4[cursor] === ")") {
13591
- cursor += 1;
13592
- continue;
13593
- }
13594
- result += text4.slice(candidateStart, cursor);
13595
- continue;
13596
- }
13597
- result += text4[cursor];
13598
- cursor += 1;
13599
- }
13600
- return result;
13601
- }
13602
- function normalizePricingSpace(text4) {
13603
- let result = "";
13604
- let previousWasWhitespace = false;
13605
- for (const char of text4) {
13606
- if (isPricingSpace(char)) {
13607
- if (!previousWasWhitespace) {
13608
- result += " ";
13609
- previousWasWhitespace = true;
13610
- }
13611
- continue;
13612
- }
13613
- result += char;
13614
- previousWasWhitespace = false;
13615
- }
13616
- return result.trim();
13617
- }
13618
- function stripPricingText(text4) {
13619
- return normalizePricingSpace(
13620
- removeEmptyPricingParentheses(
13621
- removeUnitAmounts(removeUnitAmounts(removeCurrencyAmounts(text4), "PV"), "CV")
13622
- )
13623
- );
13624
- }
13625
- function toCarouselItem(product, index2, showPricing, history) {
13626
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
13627
- const slotKey = `ai-${(_b = (_a = product.id) != null ? _a : product.sku) != null ? _b : index2}-${index2}`;
13628
- const productName = (_f = (_d = (_c = product.name) == null ? void 0 : _c.trim()) != null ? _d : product.sku) != null ? _f : `Product ${(_e = product.id) != null ? _e : index2}`;
13629
- if (!productName) {
13630
- return {
13631
- status: "error",
13632
- slotKey,
13633
- productId: String((_h = (_g = product.id) != null ? _g : product.sku) != null ? _h : index2),
13634
- error: {
13635
- code: reactProductComponents.PRODUCT_CAROUSEL_ERROR_CODES.PRODUCT_NOT_FOUND,
13636
- technicalMessage: "Missing product name"
13637
- }
13638
- };
13639
- }
13640
- const href = (_i = product.url) != null ? _i : "#";
13641
- const routeHref = (_j = product.routeUrl) != null ? _j : product.sku ? `/product/${product.sku}` : href;
13642
- const imageUrl = (_k = product.imageUrl) != null ? _k : product.image_url;
13643
- const priceText = (_l = product.price) != null ? _l : product.pv != null ? `${product.pv} PV` : void 0;
13644
- return {
13645
- status: "ready",
13646
- slotKey,
13647
- productId: String((_n = (_m = product.id) != null ? _m : product.sku) != null ? _n : index2),
13648
- cardProps: {
13649
- mode: "cta",
13650
- title: productName,
13651
- images: imageUrl ? [{ url: imageUrl, alt: productName }] : [],
13652
- productHref: href,
13653
- productAriaLabel: productName,
13654
- price: showPricing ? priceText : void 0,
13655
- addToCartLabel: "View Product",
13656
- addToCartAriaLabel: `View ${productName}`,
13657
- onProductClick: () => {
13658
- if (href === "#") return;
13659
- if (history && typeof history.push === "function") {
13660
- history.push(routeHref);
13661
- }
13662
- }
13663
- }
13664
- };
13665
- }
13666
- function SearchChatResult({
13667
- result,
13668
- showPricing = true,
13669
- history,
13670
- productsAriaLabel = "AI recommended products"
13671
- }) {
13672
- var _a;
13673
- const products = (_a = result.products) != null ? _a : [];
13674
- const carouselItems = products.map((p, i) => toCarouselItem(p, i, showPricing, history));
13675
- const summaryText = showPricing ? result.aiResponseText : stripPricingText(result.aiResponseText);
13676
- return /* @__PURE__ */ jsxRuntime.jsxs(ChatResultRoot, { "data-testid": "search-chat-result", children: [
13677
- /* @__PURE__ */ jsxRuntime.jsx(
13678
- SearchMessage,
13679
- {
13680
- sender: SEARCH_MESSAGE_SENDERS.USER,
13681
- text: result.userQuery,
13682
- "data-testid": "chat-user-query"
13683
- }
13684
- ),
13685
- /* @__PURE__ */ jsxRuntime.jsx(
13686
- SearchMessage,
13687
- {
13688
- sender: SEARCH_MESSAGE_SENDERS.AGENT,
13689
- text: summaryText,
13690
- "data-testid": "chat-ai-response"
13691
- }
13692
- ),
13693
- carouselItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ProductCarouselWrapper, { "data-testid": "chat-product-carousel", children: /* @__PURE__ */ jsxRuntime.jsx(reactProductComponents.ProductCarousel, { items: carouselItems, ariaLabel: productsAriaLabel }) })
13694
- ] });
13695
- }
13696
-
13697
- // src/components/SearchModal/SearchModalConstants.ts
13698
- var DEFAULT_AI_STATUS_LABELS = {
13699
- analyzing: "Analyzing your question...",
13700
- pulling: "Pulling up your analytics...",
13701
- routing: "Routing to specialist agents...",
13702
- thinking: "Thinking..."
13703
- };
13704
- var AI_CONV_KEY = "ai_chat_conversation_id";
13705
- function getSessionConversationId() {
13706
- try {
13707
- const raw = typeof window !== "undefined" ? window.sessionStorage.getItem(AI_CONV_KEY) : null;
13708
- if (!raw) return null;
13709
- const id = Number.parseInt(raw, 10);
13710
- return Number.isNaN(id) ? null : id;
13711
- } catch {
13712
- return null;
13713
- }
13714
- }
13715
- function storeSessionConversationId(id) {
13716
- try {
13717
- if (typeof window !== "undefined") window.sessionStorage.setItem(AI_CONV_KEY, String(id));
13718
- } catch (e) {
13719
- console.error("Error while setting key", e);
13720
- }
13721
- }
13722
- var MAX_RECENT = 6;
13723
- function getAIStatusLabels(copy) {
13724
- var _a, _b, _c, _d;
13725
- return {
13726
- analyzing: (_a = copy == null ? void 0 : copy.analyzing_label) != null ? _a : DEFAULT_AI_STATUS_LABELS.analyzing,
13727
- pulling: (_b = copy == null ? void 0 : copy.pulling_label) != null ? _b : DEFAULT_AI_STATUS_LABELS.pulling,
13728
- routing: (_c = copy == null ? void 0 : copy.routing_label) != null ? _c : DEFAULT_AI_STATUS_LABELS.routing,
13729
- thinking: (_d = copy == null ? void 0 : copy.thinking_label) != null ? _d : DEFAULT_AI_STATUS_LABELS.thinking
13730
- };
13731
- }
13732
- function getAIStatusLabel(text4, aiStatusLabels) {
13733
- const normalizedText = text4.trim().toLowerCase();
13734
- const defaultStatus = Object.entries(DEFAULT_AI_STATUS_LABELS).find(([, label]) => label.toLowerCase() === normalizedText);
13735
- return defaultStatus ? aiStatusLabels[defaultStatus[0]] : text4;
13736
- }
13737
- function getUniqueRecentSearches(entries) {
13738
- return entries.filter(
13739
- (entry, idx, arr) => arr.findIndex(
13740
- (e) => e.query.toLowerCase() === entry.query.toLowerCase()
13741
- ) === idx
13742
- );
13743
- }
13744
- function getProductId(rawId) {
13745
- return typeof rawId === "string" || typeof rawId === "number" ? String(rawId) : JSON.stringify(rawId);
13746
- }
13747
- function getProductName(product, productId) {
13748
- var _a;
13749
- return ((_a = product.name) == null ? void 0 : _a.trim()) || (typeof product.sku === "string" ? product.sku.trim() : "") || `Product ${productId}`;
13750
- }
13751
- function isVoiceSearchState(value) {
13752
- if (!value || typeof value !== "object") return false;
13753
- const candidate = value;
13754
- return typeof candidate.listening === "boolean" && typeof candidate.supported === "boolean" && typeof candidate.start === "function" && typeof candidate.stop === "function";
13755
- }
13756
- function SearchModalChatContent({
13757
- aiChatHistory,
13758
- resolvedShowPricing,
13759
- history,
13760
- chatResultRefs,
13761
- pendingQuery,
13762
- pendingQueryRef,
13763
- aiLoading,
13764
- typedStatus,
13765
- analyzingLabel,
13766
- chatEndRef
13767
- }) {
13768
- const hasChatResults = aiChatHistory.length > 0;
13769
- function scrollToBottom() {
13770
- var _a;
13771
- (_a = chatEndRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "end" });
13772
- }
13773
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13774
- aiChatHistory.map((result, idx) => /* @__PURE__ */ jsxRuntime.jsx(
13775
- "div",
13776
- {
13777
- ref: (el) => {
13778
- if (el) chatResultRefs.current.set(result.userQuery, el);
13779
- else chatResultRefs.current.delete(result.userQuery);
13780
- },
13781
- style: { marginBottom: "1.5rem" },
13782
- children: /* @__PURE__ */ jsxRuntime.jsx(
13783
- SearchChatResult,
13784
- {
13785
- result,
13786
- showPricing: resolvedShowPricing,
13787
- history: history != null ? history : null
13788
- }
13789
- )
13790
- },
13791
- `${result.userQuery}-${idx}`
13792
- )),
13793
- pendingQuery && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: pendingQueryRef, children: /* @__PURE__ */ jsxRuntime.jsx(SearchMessage, { sender: SEARCH_MESSAGE_SENDERS.USER, text: pendingQuery }) }),
13794
- aiLoading && /* @__PURE__ */ jsxRuntime.jsxs(AIStatusMessage, { "aria-live": "polite", children: [
13795
- typedStatus || analyzingLabel,
13796
- /* @__PURE__ */ jsxRuntime.jsx(AIStatusCursor, { "aria-hidden": "true" })
13797
- ] }),
13798
- hasChatResults && /* @__PURE__ */ jsxRuntime.jsx(
13799
- ChatScrollIndicator,
13800
- {
13801
- type: "button",
13802
- "aria-label": "Scroll to bottom",
13803
- onClick: scrollToBottom,
13804
- "data-testid": "chat-scroll-indicator",
13805
- children: /* @__PURE__ */ jsxRuntime.jsx(
13806
- Icon,
13807
- {
13808
- cursor: ICON_CURSORS.POINTER,
13809
- size: ICON_SIZES.SMALL,
13810
- type: ICON_TYPES.ARROW_DOWN
13811
- }
13812
- )
13813
- }
13814
- ),
13815
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: chatEndRef })
13816
- ] });
13817
- }
13818
- function pushSearchPath(history, path2) {
13819
- if (path2 && path2 !== "action-handled" && path2 !== "action-pending" && history && typeof history.push === "function") {
13820
- history.push(path2);
13821
- }
13822
- }
13823
- function SearchModalSuggestionsContent({
13440
+ function SearchSuggestions({
13824
13441
  listboxId,
13825
13442
  ariaLabel,
13443
+ items,
13826
13444
  loading,
13445
+ showNoResults,
13827
13446
  showDidYouMean,
13447
+ hasMore,
13448
+ query,
13828
13449
  didYouMeanText,
13829
- visibleSuggestions,
13830
- highlightedIndex,
13831
- setHighlightedIndex,
13832
- runSuggestionAction,
13833
- selectOption,
13834
- suggestionRowRefs,
13835
- fallbackImageUrl,
13836
- showNoResults,
13837
13450
  noSuggestionsText,
13838
- showInlineAILoading,
13839
- typedStatus,
13840
- analyzingLabel,
13841
- hasMoreResults,
13842
- footerRef,
13843
- handleSeeMore,
13844
13451
  seeMoreText,
13845
- query,
13846
- showRecentSearches,
13847
- handleClearRecentSearches,
13848
- clearAllLabel,
13849
- showAllRecent,
13850
- recentSearches,
13851
- handleRecentSearchSelect,
13852
- setShowAllRecent
13452
+ fallbackImageUrl,
13453
+ onSelect,
13454
+ onRunAction,
13455
+ onSeeMore
13853
13456
  }) {
13854
- return /* @__PURE__ */ jsxRuntime.jsxs(SearchSuggestionsPanel, { "data-testid": "autocomplete-suggestions-panel", children: [
13457
+ const [highlightedIndex, setHighlightedIndex] = React.useState(-1);
13458
+ const footerRef = React.useRef(null);
13459
+ const suggestionRowRefs = React.useRef({});
13460
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13855
13461
  /* @__PURE__ */ jsxRuntime.jsxs(
13856
13462
  SearchSuggestionsList,
13857
13463
  {
@@ -13861,15 +13467,15 @@ function SearchModalSuggestionsContent({
13861
13467
  "data-testid": "autocomplete-results-list",
13862
13468
  children: [
13863
13469
  showDidYouMean && /* @__PURE__ */ jsxRuntime.jsx(SuggestionSectionHeading, { "data-testid": "autocomplete-did-you-mean-heading", children: didYouMeanText }),
13864
- !loading && visibleSuggestions.map((option, index2) => /* @__PURE__ */ jsxRuntime.jsx(
13470
+ !loading && items.map((option, index2) => /* @__PURE__ */ jsxRuntime.jsx(
13865
13471
  SuggestionRow2,
13866
13472
  {
13867
13473
  inputRef: { current: null },
13868
13474
  isHighlighted: index2 === highlightedIndex,
13869
13475
  isSelected: false,
13870
13476
  onHighlightSuggestion: setHighlightedIndex,
13871
- onRunSuggestionAction: runSuggestionAction,
13872
- onSelectSuggestion: selectOption,
13477
+ onRunSuggestionAction: onRunAction,
13478
+ onSelectSuggestion: onSelect,
13873
13479
  registerSuggestionNode: (node2) => {
13874
13480
  if (node2) suggestionRowRefs.current[option.id] = node2;
13875
13481
  else delete suggestionRowRefs.current[option.id];
@@ -13881,15 +13487,11 @@ function SearchModalSuggestionsContent({
13881
13487
  },
13882
13488
  option.id
13883
13489
  )),
13884
- showNoResults && /* @__PURE__ */ jsxRuntime.jsx(PassiveSuggestionOption, { "data-highlighted": "false", children: noSuggestionsText }),
13885
- showInlineAILoading && /* @__PURE__ */ jsxRuntime.jsxs(AIStatusMessage, { "aria-live": "polite", children: [
13886
- typedStatus || analyzingLabel,
13887
- /* @__PURE__ */ jsxRuntime.jsx(AIStatusCursor, { "aria-hidden": "true" })
13888
- ] })
13490
+ showNoResults && /* @__PURE__ */ jsxRuntime.jsx(PassiveSuggestionOption, { "data-highlighted": "false", children: noSuggestionsText })
13889
13491
  ]
13890
13492
  }
13891
13493
  ),
13892
- !loading && hasMoreResults && !showDidYouMean && /* @__PURE__ */ jsxRuntime.jsx(
13494
+ !loading && hasMore && !showDidYouMean && /* @__PURE__ */ jsxRuntime.jsx(
13893
13495
  SeeMoreLink,
13894
13496
  {
13895
13497
  seeMoreLinkRef: footerRef,
@@ -13899,7 +13501,7 @@ function SearchModalSuggestionsContent({
13899
13501
  },
13900
13502
  onFocusSeeMoreLink: () => {
13901
13503
  },
13902
- onSeeMoreResults: handleSeeMore,
13504
+ onSeeMoreResults: onSeeMore,
13903
13505
  resetSeeMoreLinkFocus: () => {
13904
13506
  },
13905
13507
  restoreLastSuggestion: () => {
@@ -13907,667 +13509,101 @@ function SearchModalSuggestionsContent({
13907
13509
  seeMoreResultsText: seeMoreText,
13908
13510
  searchQuery: query
13909
13511
  }
13910
- ),
13911
- showRecentSearches && /* @__PURE__ */ jsxRuntime.jsxs(RecentSearchesSection, { "aria-label": "Recent searches", children: [
13912
- /* @__PURE__ */ jsxRuntime.jsxs(RecentSearchesHeader, { children: [
13913
- /* @__PURE__ */ jsxRuntime.jsx(RecentSearchesTitle, { children: "Recent searches" }),
13914
- /* @__PURE__ */ jsxRuntime.jsx(
13915
- RecentSearchesClearButton,
13916
- {
13917
- type: "button",
13918
- onMouseDown: (e) => e.preventDefault(),
13919
- onClick: handleClearRecentSearches,
13920
- children: clearAllLabel
13921
- }
13922
- )
13923
- ] }),
13924
- /* @__PURE__ */ jsxRuntime.jsxs(RecentSearchesList, { children: [
13925
- (showAllRecent ? recentSearches : recentSearches.slice(0, MAX_RECENT)).map((entry) => /* @__PURE__ */ jsxRuntime.jsx(
13926
- RecentSearchChip,
13927
- {
13928
- type: "button",
13929
- onMouseDown: (e) => e.preventDefault(),
13930
- onClick: () => handleRecentSearchSelect(entry),
13931
- children: entry.query
13932
- },
13933
- `${entry.query}-${entry.timestamp}`
13934
- )),
13935
- !showAllRecent && recentSearches.length > MAX_RECENT && /* @__PURE__ */ jsxRuntime.jsxs(
13936
- RecentSearchChip,
13937
- {
13938
- type: "button",
13939
- onMouseDown: (e) => e.preventDefault(),
13940
- onClick: () => setShowAllRecent(true),
13941
- children: [
13942
- "+",
13943
- recentSearches.length - MAX_RECENT,
13944
- " More"
13945
- ]
13946
- }
13947
- )
13948
- ] })
13949
- ] })
13512
+ )
13950
13513
  ] });
13951
13514
  }
13515
+ var SEARCH_MODAL_Z_INDEX = 1e4;
13516
+ var BACKDROP_PROPS = { "data-testid": "search-modal-backdrop" };
13517
+ var SearchModalBackdrop = React__default.default.forwardRef(function SearchModalBackdrop2({ open: _open, transitionDuration: _duration, ...rest }, ref) {
13518
+ return /* @__PURE__ */ jsxRuntime.jsx(SearchModalBackdropRoot, { ref, ...rest });
13519
+ });
13952
13520
  function SearchModal({
13953
13521
  isOpen,
13954
13522
  onClose,
13955
- service,
13956
- history,
13957
- copy = {},
13958
13523
  logo,
13959
13524
  cancelLabel = "Cancel",
13960
13525
  fallbackImageUrl = "",
13961
- enableAIChat = false,
13962
- aiChatConfig,
13963
- gtmContext,
13964
- showPricing = true,
13965
- aiChatHeaderContent
13526
+ copy = {},
13527
+ input,
13528
+ suggestions,
13529
+ recentSearches,
13530
+ agentPanel
13966
13531
  }) {
13967
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
13532
+ var _a, _b, _c, _d, _e, _f, _g, _h;
13968
13533
  const listboxId = React.useId();
13969
- const footerRef = React.useRef(null);
13970
- const suggestionRowRefs = React.useRef({});
13971
- const historyEntries = reactSearchSdk.useSearchHistory().entries;
13972
- const selectHistory = reactSearchSdk.useSearchHistoryStore;
13973
- const historyAddEntry = selectHistory((s) => s.addEntry);
13974
- const historyClearAll = selectHistory((s) => s.clearAll);
13975
- const [legacyRecentSearches, setLegacyRecentSearches] = React.useState([]);
13976
- const legacyEntries = legacyRecentSearches.map((q) => ({
13977
- query: q,
13978
- isAI: false,
13979
- timestamp: 0
13980
- }));
13981
- const recentSearches = getUniqueRecentSearches(enableAIChat ? historyEntries : legacyEntries);
13982
- const clearRecentSearches = React.useCallback(() => {
13983
- var _a2;
13984
- if (enableAIChat) {
13985
- historyClearAll();
13986
- setAiChatHistory([]);
13987
- } else {
13988
- (_a2 = service.clearRecentSearches) == null ? void 0 : _a2.call(service);
13989
- setLegacyRecentSearches([]);
13990
- }
13991
- }, [enableAIChat, historyClearAll, service]);
13992
- const [highlightedIndex, setHighlightedIndex] = React.useState(-1);
13993
- const [aiChatHistory, setAiChatHistory] = React.useState([]);
13994
- const [pendingQuery, setPendingQuery] = React.useState("");
13995
- const [aiLoading, setAiLoading] = React.useState(false);
13996
- const isInChatMode = aiChatHistory.length > 0 || pendingQuery !== "" || aiLoading;
13997
- const [aiStatus, setAiStatus] = React.useState("");
13998
- const [typedStatus, setTypedStatus] = React.useState("");
13999
- const [showAllRecent, setShowAllRecent] = React.useState(false);
14000
- const [highlightedQuery, setHighlightedQuery] = React.useState(null);
14001
- const chatResultRefs = React.useRef(/* @__PURE__ */ new Map());
14002
- const pendingQueryRef = React.useRef(null);
14003
- const aiChatConfigRef = React.useRef(aiChatConfig);
14004
- aiChatConfigRef.current = aiChatConfig;
14005
- const aiChatHeaderContentRef = React.useRef(aiChatHeaderContent);
14006
- aiChatHeaderContentRef.current = aiChatHeaderContent;
14007
- const gtmContextRef = React.useRef(gtmContext);
14008
- gtmContextRef.current = gtmContext;
14009
- const historyEntriesRef = React.useRef(historyEntries);
14010
- historyEntriesRef.current = historyEntries;
14011
- const chatEndRef = React.useRef(null);
14012
- const aiRequestCounterRef = React.useRef(0);
14013
- const [suggestionsRequestFailed, setSuggestionsRequestFailed] = React.useState(false);
14014
- const suggestionAwareService = React.useMemo(
14015
- () => ({
14016
- ...service,
14017
- async fetchSuggestions(searchTerm) {
14018
- setSuggestionsRequestFailed(false);
14019
- try {
14020
- const response = await service.fetchSuggestions(searchTerm);
14021
- setSuggestionsRequestFailed(false);
14022
- return response;
14023
- } catch (error) {
14024
- setSuggestionsRequestFailed(true);
14025
- throw error;
14026
- }
14027
- }
14028
- }),
14029
- [service]
14030
- );
14031
- const searchSuggestions = reactSearchSdk.useSearchSuggestions({
14032
- service: suggestionAwareService,
14033
- enabled: isOpen && !isInChatMode
14034
- });
14035
- const {
14036
- didYouMean,
14037
- emptyFetched,
14038
- hasMoreResults,
14039
- hasQuery,
14040
- loading,
14041
- query,
14042
- suggestions,
14043
- updateQuery
14044
- } = searchSuggestions;
14045
- const suggestionFetchFailed = ((_a = searchSuggestions.suggestionFetchFailed) != null ? _a : false) || suggestionsRequestFailed;
14046
- const [searchInputValue, setSearchInputValue] = React.useState(query);
14047
- const searchInputValueRef = React.useRef(query);
14048
- const voiceInputBaseValueRef = React.useRef(query);
14049
- const setSearchInput = React.useCallback(
14050
- (value, updateVoiceBase = true, resetSuggestionFailure = true) => {
14051
- if (resetSuggestionFailure) {
14052
- setSuggestionsRequestFailed(false);
14053
- }
14054
- searchInputValueRef.current = value;
14055
- if (updateVoiceBase) {
14056
- voiceInputBaseValueRef.current = value;
14057
- }
14058
- setSearchInputValue(value);
14059
- updateQuery(value);
14060
- },
14061
- [updateQuery]
14062
- );
14063
- const getVoiceInputValue = React.useCallback((value) => {
14064
- const transcript = value.trim();
14065
- if (!transcript) return voiceInputBaseValueRef.current;
14066
- const currentValue = voiceInputBaseValueRef.current.trimEnd();
14067
- return currentValue ? `${currentValue} ${transcript}` : transcript;
14068
- }, []);
14069
- const previewVoiceResult = React.useCallback(
14070
- (value) => {
14071
- const nextValue = getVoiceInputValue(value);
14072
- if (!nextValue) return;
14073
- searchInputValueRef.current = nextValue;
14074
- setSearchInputValue(nextValue);
14075
- },
14076
- [getVoiceInputValue]
14077
- );
14078
- const appendVoiceResult = React.useCallback(
14079
- (value) => {
14080
- const nextValue = getVoiceInputValue(value);
14081
- if (!nextValue) return;
14082
- voiceInputBaseValueRef.current = nextValue;
14083
- setSearchInput(nextValue);
14084
- },
14085
- [getVoiceInputValue, setSearchInput]
14086
- );
13534
+ const surfaceRef = React.useRef(null);
13535
+ const hasAgent = agentPanel != null;
14087
13536
  React.useEffect(() => {
14088
- searchInputValueRef.current = query;
14089
- voiceInputBaseValueRef.current = query;
14090
- setSearchInputValue(query);
14091
- }, [query]);
14092
- const hasDidYouMean = didYouMean.length > 0;
14093
- const showDidYouMean = hasDidYouMean && !enableAIChat;
14094
- const visibleSuggestions = enableAIChat ? suggestions : reactSearchSdk.getVisibleSuggestions({ didYouMean, suggestions });
14095
- const safeUseVoiceSearch = reactSearchSdk.useVoiceSearch;
14096
- const voiceSearchRaw = safeUseVoiceSearch({
14097
- onInterimResult: previewVoiceResult,
14098
- onResult: appendVoiceResult
14099
- });
14100
- const voiceSearch = isVoiceSearchState(voiceSearchRaw) ? voiceSearchRaw : null;
14101
- const voiceListening = (_b = voiceSearch == null ? void 0 : voiceSearch.listening) != null ? _b : false;
14102
- const voiceSupported = (_c = voiceSearch == null ? void 0 : voiceSearch.supported) != null ? _c : false;
14103
- const startVoice = voiceSearch == null ? void 0 : voiceSearch.start;
14104
- const stopVoice = voiceSearch == null ? void 0 : voiceSearch.stop;
14105
- const toggleVoice = React.useCallback(() => {
14106
- if (voiceListening) {
14107
- stopVoice == null ? void 0 : stopVoice();
14108
- return;
14109
- }
14110
- voiceInputBaseValueRef.current = searchInputValueRef.current.trimEnd();
14111
- startVoice == null ? void 0 : startVoice();
14112
- }, [startVoice, stopVoice, voiceListening]);
14113
- const showPricingFromHeader = ((_e = (_d = aiChatHeaderContentRef.current) == null ? void 0 : _d.configurations) == null ? void 0 : _e.enablepricingpvsv) !== "false";
14114
- const resolvedShowPricing = aiChatHeaderContent ? showPricingFromHeader : showPricing;
14115
- const aiStatusLabels = getAIStatusLabels(copy);
14116
- function voiceSearchProps() {
14117
- var _a2;
14118
- if (!voiceSupported || !startVoice) return {};
14119
- return {
14120
- showVoiceInput: true,
14121
- voiceInputLabel: voiceListening ? "Listening\u2026" : "Search by voice",
14122
- voiceListening,
14123
- voiceListeningLabel: (_a2 = copy == null ? void 0 : copy.listening_label) != null ? _a2 : "Listening...",
14124
- onVoiceInput: toggleVoice
14125
- };
14126
- }
14127
- const buildGtmContext = React.useCallback(() => {
14128
- var _a2;
14129
- return (_a2 = gtmContextRef.current) != null ? _a2 : {};
14130
- }, []);
14131
- const chatEntryFiredRef = React.useRef(false);
14132
- React.useEffect(() => {
14133
- if (!isOpen) {
14134
- chatEntryFiredRef.current = false;
14135
- return;
14136
- }
14137
- if (!enableAIChat || chatEntryFiredRef.current) return;
14138
- chatEntryFiredRef.current = true;
14139
- reactSearchSdk.trackChatEntryPoint(buildGtmContext());
14140
- }, [isOpen, enableAIChat, buildGtmContext]);
14141
- React.useEffect(() => {
14142
- if (isOpen) return;
14143
- updateQuery("");
14144
- setAiChatHistory([]);
14145
- setPendingQuery("");
14146
- setAiLoading(false);
14147
- setAiStatus("");
14148
- setTypedStatus("");
14149
- setShowAllRecent(false);
14150
- aiRequestCounterRef.current += 1;
14151
- }, [isOpen, updateQuery]);
14152
- React.useEffect(() => {
14153
- if (!aiStatus) {
14154
- setTypedStatus("");
14155
- return;
14156
- }
14157
- let i = 0;
14158
- setTypedStatus("");
14159
- const id = setInterval(() => {
14160
- i += 1;
14161
- setTypedStatus(aiStatus.slice(0, i));
14162
- if (i >= aiStatus.length) clearInterval(id);
14163
- }, 25);
14164
- return () => clearInterval(id);
14165
- }, [aiStatus]);
14166
- React.useEffect(() => {
14167
- var _a2;
14168
- if (!isInChatMode) return;
14169
- (_a2 = chatEndRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "smooth" });
14170
- }, [aiChatHistory.length, isInChatMode]);
14171
- React.useEffect(() => {
14172
- var _a2;
14173
- if (!pendingQuery) return;
14174
- (_a2 = pendingQueryRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "smooth", block: "start" });
14175
- }, [pendingQuery]);
14176
- React.useEffect(() => {
14177
- if (!highlightedQuery || aiChatHistory.length === 0) return;
14178
- const el = chatResultRefs.current.get(highlightedQuery);
14179
- el == null ? void 0 : el.scrollIntoView({ behavior: "smooth", block: "start" });
14180
- setHighlightedQuery(null);
14181
- }, [highlightedQuery, aiChatHistory]);
14182
- React.useEffect(() => {
14183
- var _a2, _b2;
14184
- if (enableAIChat || !isOpen) return;
14185
- setLegacyRecentSearches((_b2 = (_a2 = service.getRecentSearches) == null ? void 0 : _a2.call(service)) != null ? _b2 : []);
14186
- }, [enableAIChat, isOpen, service]);
14187
- React.useEffect(() => {
14188
- if (!isOpen) return void 0;
14189
- const onKeyDown = (e) => {
14190
- if (e.key === "Escape") onClose();
14191
- };
14192
- document.addEventListener("keydown", onKeyDown);
14193
- document.body.style.overflow = "hidden";
14194
- return () => {
14195
- document.removeEventListener("keydown", onKeyDown);
14196
- document.body.style.overflow = "";
14197
- };
14198
- }, [isOpen, onClose]);
14199
- const sendAIMessage = React.useCallback(
14200
- (queryText) => {
14201
- const config = aiChatConfigRef.current;
14202
- if (!config || !queryText.trim()) return;
14203
- setSearchInput("", true, false);
14204
- setPendingQuery(queryText.trim());
14205
- setAiStatus(aiStatusLabels.analyzing);
14206
- const trimmedQuery = queryText.trim();
14207
- reactSearchSdk.trackSearchType({
14208
- ...buildGtmContext(),
14209
- searchType: reactSearchSdk.SEARCH_GTM_SEARCH_TYPES.AI_AGENT,
14210
- searchResponse: trimmedQuery
14211
- });
14212
- const requestId = aiRequestCounterRef.current;
14213
- const productBasePath = `/${config.market.toLowerCase()}/${config.language.toLowerCase()}/product`;
14214
- const chatService = reactSearchSdk.createChatService({
14215
- conversationsUrl: config.conversationsUrl,
14216
- messagesUrl: config.messagesUrl,
14217
- salesAiAppKey: config.salesAiAppKey,
14218
- salesAiParentOrigin: config.salesAiParentOrigin,
14219
- market: config.market,
14220
- language: config.language
14221
- });
14222
- setAiLoading(true);
14223
- const onChunk = (type, text4) => {
14224
- if (type === "status") setAiStatus(getAIStatusLabel(text4, aiStatusLabels));
14225
- };
14226
- const existingConvId = getSessionConversationId();
14227
- const conversationPromise = existingConvId !== null ? Promise.resolve(existingConvId) : chatService.createConversation("Search Session").then((id) => {
14228
- storeSessionConversationId(id);
14229
- return id;
14230
- });
14231
- conversationPromise.then(
14232
- (conversationId) => {
14233
- if (requestId !== aiRequestCounterRef.current) return Promise.resolve(null);
14234
- return chatService.sendMessage(conversationId, queryText.trim(), onChunk);
14235
- }
14236
- ).then((result) => {
14237
- if (!result || requestId !== aiRequestCounterRef.current) return;
14238
- const products = result.products.map((p, i) => {
14239
- var _a2, _b2;
14240
- const productId = getProductId((_b2 = (_a2 = p.id) != null ? _a2 : p.sku) != null ? _b2 : i);
14241
- const productName = getProductName(p, productId);
14242
- return {
14243
- id: productId,
14244
- sku: p.sku,
14245
- name: String(productName),
14246
- ...p.image_url ? { imageUrl: p.image_url, image_url: p.image_url } : {},
14247
- ...p.pv != null ? { pv: p.pv } : {},
14248
- ...p.retail_price != null ? { retail_price: p.retail_price } : {},
14249
- ...p.description ? { description: p.description } : {},
14250
- ...p.badge ? { badge: p.badge } : {},
14251
- ...p.sku != null ? {
14252
- url: `${productBasePath}/${p.sku}`,
14253
- routeUrl: `/product/${p.sku}`
14254
- } : {}
14255
- };
14256
- });
14257
- setAiStatus("");
14258
- setPendingQuery("");
14259
- const newResult = {
14260
- userQuery: queryText.trim(),
14261
- aiResponseText: result.summary,
14262
- products
14263
- };
14264
- const priorHistory = historyEntriesRef.current.filter((e) => e.isAI && e.aiResult != null).slice().reverse().map((e) => e.aiResult);
14265
- setAiChatHistory([...priorHistory, newResult]);
14266
- historyAddEntry({ query: queryText.trim(), isAI: true, aiResult: newResult });
14267
- reactSearchSdk.trackProductSearch({
14268
- ...buildGtmContext(),
14269
- searchType: reactSearchSdk.SEARCH_GTM_SEARCH_TYPES.AI_AGENT,
14270
- productResults: products.length,
14271
- productResultsData: products
14272
- });
14273
- }).catch(() => {
14274
- setPendingQuery("");
14275
- setAiStatus("");
14276
- reactSearchSdk.trackErrorPopup({
14277
- ...buildGtmContext(),
14278
- searchType: reactSearchSdk.SEARCH_GTM_SEARCH_TYPES.AI_AGENT
14279
- });
14280
- }).finally(() => {
14281
- if (requestId === aiRequestCounterRef.current) setAiLoading(false);
14282
- });
14283
- },
14284
- [aiStatusLabels, historyAddEntry, setSearchInput, buildGtmContext]
14285
- );
14286
- const selectOption = React.useCallback(
14287
- (option) => {
14288
- var _a2, _b2, _c2, _d2;
14289
- if (reactSearchSdk.isSuggestionDisabled(option)) return;
14290
- const term = String((_b2 = (_a2 = option["value"]) != null ? _a2 : option["label"]) != null ? _b2 : "");
14291
- historyAddEntry({ query: term, isAI: false });
14292
- if (term.trim()) {
14293
- reactSearchSdk.trackProductSearch({
14294
- ...buildGtmContext(),
14295
- searchType: reactSearchSdk.SEARCH_GTM_SEARCH_TYPES.SEMANTIC,
14296
- productResultsData: [option]
14297
- });
14298
- }
14299
- const optionHref = service.getSuggestionHref(option);
14300
- if (optionHref) {
14301
- pushSearchPath(history, optionHref);
14302
- onClose();
14303
- return;
14304
- }
14305
- pushSearchPath(
14306
- history,
14307
- service.submitProductSearch(term, option)
14308
- );
14309
- if (!enableAIChat) setLegacyRecentSearches((_d2 = (_c2 = service.getRecentSearches) == null ? void 0 : _c2.call(service)) != null ? _d2 : []);
14310
- onClose();
14311
- },
14312
- [buildGtmContext, enableAIChat, service, onClose, historyAddEntry, history]
14313
- );
14314
- const runSuggestionAction = React.useCallback(
14315
- (option) => {
14316
- if (reactSearchSdk.isSuggestionDisabled(option)) return;
14317
- const result = service.activateSuggestionAction(option);
14318
- void Promise.resolve(result).then((path2) => pushSearchPath(history, path2)).catch(() => {
14319
- });
14320
- },
14321
- [history, service]
14322
- );
14323
- const handleRecentSearchSelect = React.useCallback(
14324
- (entry) => {
13537
+ if (!isOpen || hasAgent) return void 0;
13538
+ const frame = requestAnimationFrame(() => {
14325
13539
  var _a2, _b2;
14326
- if (entry.isAI && entry.aiResult != null) {
14327
- const allAI = historyEntriesRef.current.filter((e) => e.isAI && e.aiResult != null).slice().reverse();
14328
- setAiChatHistory(allAI.map((e) => e.aiResult));
14329
- setHighlightedQuery(entry.query);
14330
- } else {
14331
- historyAddEntry({ query: entry.query, isAI: false });
14332
- if (entry.query.trim()) {
14333
- reactSearchSdk.trackProductSearch({
14334
- ...buildGtmContext(),
14335
- searchType: reactSearchSdk.SEARCH_GTM_SEARCH_TYPES.SEMANTIC,
14336
- productResultsData: { query: entry.query.trim() }
14337
- });
14338
- }
14339
- const url = service.submitProductSearch(entry.query);
14340
- if (url && history && typeof history.push === "function") {
14341
- history.push(url);
14342
- }
14343
- if (!enableAIChat) setLegacyRecentSearches((_b2 = (_a2 = service.getRecentSearches) == null ? void 0 : _a2.call(service)) != null ? _b2 : []);
14344
- onClose();
14345
- }
14346
- },
14347
- [buildGtmContext, enableAIChat, service, onClose, historyAddEntry, history]
14348
- );
14349
- const handleClearRecentSearches = React.useCallback(() => {
14350
- clearRecentSearches();
14351
- }, [clearRecentSearches]);
14352
- const handleSeeMore = React.useCallback(() => {
14353
- if (query.trim()) {
14354
- pushSearchPath(history, service.viewMoreResults({ query: query.trim() }));
14355
- }
14356
- }, [history, service, query]);
14357
- const handleSearchSubmit = React.useCallback(
14358
- (value) => {
14359
- var _a2, _b2;
14360
- if (enableAIChat && suggestionFetchFailed) {
14361
- sendAIMessage(value);
14362
- return;
14363
- }
14364
- historyAddEntry({ query: value, isAI: false });
14365
- const trimmed = value.trim();
14366
- if (trimmed) {
14367
- reactSearchSdk.trackProductSearch({
14368
- ...buildGtmContext(),
14369
- searchType: reactSearchSdk.SEARCH_GTM_SEARCH_TYPES.SEMANTIC,
14370
- productResultsData: visibleSuggestions.length > 0 ? visibleSuggestions : { query: trimmed }
14371
- });
14372
- }
14373
- const url = service.submitProductSearch(value);
14374
- pushSearchPath(history, url);
14375
- if (!enableAIChat) setLegacyRecentSearches((_b2 = (_a2 = service.getRecentSearches) == null ? void 0 : _a2.call(service)) != null ? _b2 : []);
14376
- onClose();
14377
- },
14378
- [
14379
- buildGtmContext,
14380
- enableAIChat,
14381
- history,
14382
- historyAddEntry,
14383
- onClose,
14384
- sendAIMessage,
14385
- service,
14386
- suggestionFetchFailed,
14387
- visibleSuggestions
14388
- ]
14389
- );
14390
- if (!isOpen) return null;
14391
- const placeholder = (_f = copy == null ? void 0 : copy.extended_search_textbox_desktop) != null ? _f : "Search";
14392
- const ariaLabel = (_g = copy == null ? void 0 : copy.extended_search_box_aria_label) != null ? _g : placeholder;
14393
- const didYouMeanText = (_h = copy == null ? void 0 : copy.did_you_mean_text) != null ? _h : "Did You Mean?";
14394
- const noSuggestionsText = (_i = copy == null ? void 0 : copy.no_suggestions_text) != null ? _i : "No suggestions";
14395
- const seeMoreText = (_j = copy == null ? void 0 : copy.see_more_results_text) != null ? _j : "See More Results";
14396
- const showRecentSearches = !hasQuery && !aiLoading && !isInChatMode && recentSearches.length > 0;
14397
- const showNoResults = !isInChatMode && !loading && emptyFetched && visibleSuggestions.length === 0 && !aiLoading;
13540
+ (_b2 = (_a2 = surfaceRef.current) == null ? void 0 : _a2.querySelector("textarea, input")) == null ? void 0 : _b2.focus();
13541
+ });
13542
+ return () => cancelAnimationFrame(frame);
13543
+ }, [isOpen, hasAgent]);
13544
+ const placeholder = (_a = copy.extended_search_textbox_desktop) != null ? _a : "Search";
13545
+ const ariaLabel = (_b = copy.extended_search_box_aria_label) != null ? _b : placeholder;
13546
+ const hasQuery = input.value.trim() !== "";
13547
+ const hasRecentSearches = ((_c = recentSearches == null ? void 0 : recentSearches.items.length) != null ? _c : 0) > 0;
14398
13548
  const searchInput = /* @__PURE__ */ jsxRuntime.jsx(
14399
13549
  SearchMessageInput,
14400
13550
  {
14401
13551
  inputLabel: ariaLabel,
14402
- onChange: setSearchInput,
14403
- onSubmit: handleSearchSubmit,
13552
+ onChange: input.onChange,
13553
+ onSubmit: input.onSubmit,
14404
13554
  placeholder,
14405
- submitLabel: placeholder,
14406
- value: searchInputValue,
13555
+ value: input.value,
14407
13556
  clearOnSubmit: false,
14408
- "data-testid": "search-modal-input",
14409
- ...voiceSearchProps()
13557
+ "data-testid": "search-modal-input"
14410
13558
  }
14411
13559
  );
14412
- const panelInputProps = isInChatMode ? {
14413
- messageInputProps: {
14414
- inputLabel: ariaLabel,
14415
- onChange: setSearchInput,
14416
- // triggers messages API on Enter / arrow click
14417
- onSubmit: sendAIMessage,
14418
- placeholder,
14419
- submitLabel: placeholder,
14420
- value: searchInputValue,
14421
- clearOnSubmit: true,
14422
- ...voiceSearchProps()
14423
- }
14424
- } : { inputSlot: searchInput };
14425
- return reactDom.createPortal(
14426
- /* @__PURE__ */ jsxRuntime.jsx(
14427
- SearchModalOverlay,
14428
- {
14429
- onClick: (e) => {
14430
- if (e.target === e.currentTarget) onClose();
14431
- },
14432
- "data-testid": "search-modal-overlay",
14433
- children: /* @__PURE__ */ jsxRuntime.jsx(
14434
- SearchPanel,
14435
- {
14436
- "aria-label": ariaLabel,
14437
- closeLabel: cancelLabel,
14438
- onClose,
14439
- logoSlot: logo,
14440
- chatMode: isInChatMode,
14441
- ...panelInputProps,
14442
- children: isInChatMode ? /* @__PURE__ */ jsxRuntime.jsx(
14443
- SearchModalChatContent,
14444
- {
14445
- aiChatHistory,
14446
- resolvedShowPricing,
14447
- history,
14448
- chatResultRefs,
14449
- pendingQuery,
14450
- pendingQueryRef,
14451
- aiLoading,
14452
- typedStatus,
14453
- analyzingLabel: aiStatusLabels.analyzing,
14454
- chatEndRef
14455
- }
14456
- ) : /* @__PURE__ */ jsxRuntime.jsx(
14457
- SearchModalSuggestionsContent,
13560
+ return /* @__PURE__ */ jsxRuntime.jsx(
13561
+ material.Modal,
13562
+ {
13563
+ open: isOpen,
13564
+ onClose,
13565
+ style: { zIndex: SEARCH_MODAL_Z_INDEX },
13566
+ slots: { backdrop: SearchModalBackdrop },
13567
+ slotProps: { backdrop: BACKDROP_PROPS },
13568
+ "data-testid": "search-modal-overlay",
13569
+ children: /* @__PURE__ */ jsxRuntime.jsx(SearchModalSurface, { ref: surfaceRef, children: /* @__PURE__ */ jsxRuntime.jsx(
13570
+ SearchPanel,
13571
+ {
13572
+ role: "dialog",
13573
+ "aria-modal": "true",
13574
+ "aria-label": ariaLabel,
13575
+ closeLabel: cancelLabel,
13576
+ onClose,
13577
+ logoSlot: logo,
13578
+ agentMode: hasAgent,
13579
+ inputSlot: hasAgent ? void 0 : searchInput,
13580
+ children: agentPanel != null ? agentPanel : /* @__PURE__ */ jsxRuntime.jsxs(SearchSuggestionsPanel, { "data-testid": "autocomplete-suggestions-panel", children: [
13581
+ /* @__PURE__ */ jsxRuntime.jsx(
13582
+ SearchSuggestions,
14458
13583
  {
13584
+ ...suggestions,
14459
13585
  listboxId,
14460
13586
  ariaLabel,
14461
- loading,
14462
- showDidYouMean,
14463
- didYouMeanText,
14464
- visibleSuggestions,
14465
- highlightedIndex,
14466
- setHighlightedIndex,
14467
- runSuggestionAction,
14468
- selectOption,
14469
- suggestionRowRefs,
14470
- fallbackImageUrl,
14471
- showNoResults,
14472
- noSuggestionsText,
14473
- showInlineAILoading: !isInChatMode && aiLoading,
14474
- typedStatus,
14475
- analyzingLabel: aiStatusLabels.analyzing,
14476
- hasMoreResults,
14477
- footerRef,
14478
- handleSeeMore,
14479
- seeMoreText,
14480
- query,
14481
- showRecentSearches,
14482
- handleClearRecentSearches,
14483
- clearAllLabel: (_k = copy == null ? void 0 : copy.clear_all_label) != null ? _k : "Clear all",
14484
- showAllRecent,
14485
- recentSearches,
14486
- handleRecentSearchSelect,
14487
- setShowAllRecent
13587
+ didYouMeanText: (_d = copy.did_you_mean_text) != null ? _d : "Did You Mean?",
13588
+ noSuggestionsText: (_e = copy.no_suggestions_text) != null ? _e : "No suggestions",
13589
+ seeMoreText: (_f = copy.see_more_results_text) != null ? _f : "See More Results",
13590
+ fallbackImageUrl
13591
+ }
13592
+ ),
13593
+ !hasQuery && recentSearches && hasRecentSearches && /* @__PURE__ */ jsxRuntime.jsx(
13594
+ RecentSearches,
13595
+ {
13596
+ ...recentSearches,
13597
+ title: (_g = copy.recent_searches_label) != null ? _g : "Recent searches",
13598
+ clearLabel: (_h = copy.clear_all_label) != null ? _h : "Clear all"
14488
13599
  }
14489
13600
  )
14490
- }
14491
- )
14492
- }
14493
- ),
14494
- document.body
13601
+ ] })
13602
+ }
13603
+ ) })
13604
+ }
14495
13605
  );
14496
13606
  }
14497
- async function fetchAIChatHeaderContent(config) {
14498
- const { environment = "prod", country, language } = config;
14499
- if (!country || !language) {
14500
- throw new Error("country and language are required to fetch ai_chat_nuskin_header");
14501
- }
14502
- const stack = nsContentstackLib.getStack(environment);
14503
- const entries = await stack.getSingletonEntries({
14504
- contentTypeUIDs: ["ai_chat_nuskin_header"],
14505
- country: country.toUpperCase(),
14506
- language: language.toLowerCase(),
14507
- camelcase: true
14508
- });
14509
- const [aiChatHeader] = entries;
14510
- return aiChatHeader != null ? aiChatHeader : null;
14511
- }
14512
- function useAIChatHeaderContent(config) {
14513
- const [content3, setContent] = React.useState(null);
14514
- const [loading, setLoading] = React.useState(false);
14515
- const [error, setError] = React.useState(null);
14516
- const country = config == null ? void 0 : config.country;
14517
- const language = config == null ? void 0 : config.language;
14518
- const environment = config == null ? void 0 : config.environment;
14519
- React.useEffect(() => {
14520
- if (!country || !language) return;
14521
- let cancelled = false;
14522
- setLoading(true);
14523
- setError(null);
14524
- fetchAIChatHeaderContent({
14525
- country,
14526
- language,
14527
- ...environment !== void 0 && { environment }
14528
- }).then((result) => {
14529
- if (!cancelled) setContent(result);
14530
- }).catch((err) => {
14531
- if (!cancelled) setError(err instanceof Error ? err : new Error(String(err)));
14532
- }).finally(() => {
14533
- if (!cancelled) setLoading(false);
14534
- });
14535
- return () => {
14536
- cancelled = true;
14537
- };
14538
- }, [country, language, environment]);
14539
- return { content: content3, loading, error };
14540
- }
14541
- var bounce = react.keyframes`
14542
- 0%, 60%, 100% {
14543
- transform: translateY(0);
14544
- opacity: 0.4;
14545
- }
14546
- 30% {
14547
- transform: translateY(-6px);
14548
- opacity: 1;
14549
- }
14550
- `;
14551
- var ChatLoadingRoot = styled6__default.default.div`
14552
- display: flex;
14553
- align-items: center;
14554
- gap: 6px;
14555
- padding: 10px 4px;
14556
- `;
14557
- var ChatLoadingDot = styled6__default.default.span`
14558
- display: block;
14559
- width: 10px;
14560
- height: 10px;
14561
- border-radius: 50%;
14562
- background-color: currentColor;
14563
- opacity: 0.4;
14564
- animation: ${bounce} 1.2s ease-in-out infinite;
14565
- animation-delay: ${({ $delay }) => $delay}ms;
14566
- `;
14567
- var DOTS = [0, 160, 320];
14568
- function ChatLoading({ label = "Loading\u2026", ...props }) {
14569
- return /* @__PURE__ */ jsxRuntime.jsx(ChatLoadingRoot, { ...props, "aria-label": label, children: DOTS.map((delay) => /* @__PURE__ */ jsxRuntime.jsx(ChatLoadingDot, { $delay: delay, "aria-hidden": "true" }, delay)) });
14570
- }
14571
13607
  /*! Bundled license information:
14572
13608
 
14573
13609
  is-buffer/index.js:
@@ -14607,22 +13643,13 @@ react-is/cjs/react-is.development.js:
14607
13643
  *)
14608
13644
  */
14609
13645
 
14610
- Object.defineProperty(exports, "createSearchService", {
14611
- enumerable: true,
14612
- get: function () { return reactSearchSdk.createSearchService; }
14613
- });
14614
- exports.ChatLoading = ChatLoading;
14615
13646
  exports.SEARCH_MESSAGE_SENDERS = SEARCH_MESSAGE_SENDERS;
14616
- exports.SearchChatResult = SearchChatResult;
14617
13647
  exports.SearchMessage = SearchMessage;
14618
13648
  exports.SearchMessageInput = SearchMessageInput;
14619
13649
  exports.SearchModal = SearchModal;
14620
13650
  exports.SearchPanel = SearchPanel;
14621
13651
  exports.SeeMoreLink = SeeMoreLink;
14622
13652
  exports.SuggestionRow = SuggestionRow2;
14623
- exports.callAICommerceChat = callAICommerceChat;
14624
- exports.fetchAIChatHeaderContent = fetchAIChatHeaderContent;
14625
13653
  exports.getSuggestionDisplayData = getSuggestionDisplayData;
14626
- exports.useAIChatHeaderContent = useAIChatHeaderContent;
14627
13654
  //# sourceMappingURL=index.js.map
14628
13655
  //# sourceMappingURL=index.js.map