@nuskin/react-search-components 1.0.0-comx-3067.7 → 1.0.0-widget-integration.1
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.d.mts +90 -163
- package/dist/index.d.ts +90 -163
- package/dist/index.js +419 -1375
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +419 -1367
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -11
package/dist/index.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var
|
|
4
|
+
var styled4 = require('@emotion/styled');
|
|
5
5
|
var foundationTheme = require('@nuskin/foundation-theme');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
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
|
|
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,
|
|
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 =
|
|
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
|
|
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: () =>
|
|
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
|
|
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(
|
|
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 =
|
|
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 =
|
|
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
|
|
12055
|
-
[ICON_TYPES.ARROW_DOWN]: "
|
|
12056
|
-
[ICON_TYPES.ARROW_LEFT]: "
|
|
12057
|
-
[ICON_TYPES.ARROW_RIGHT]: "
|
|
12058
|
-
[ICON_TYPES.ARROW_UP]: "
|
|
12059
|
-
[ICON_TYPES.CHECK_VERIFIED]: "
|
|
12060
|
-
[ICON_TYPES.CLOSE]: "
|
|
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
|
|
12070
|
+
function FoundationIcon({
|
|
12070
12071
|
className,
|
|
12071
12072
|
color: color2,
|
|
12072
12073
|
cursor,
|
|
12073
|
-
|
|
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
|
-
|
|
12079
|
+
foundationUiComponents.NsIcon,
|
|
12080
12080
|
{
|
|
12081
|
-
"aria-hidden":
|
|
12082
|
-
className,
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
12087
|
-
|
|
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
|
|
12465
|
-
if (
|
|
12466
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
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 =
|
|
12464
|
+
var SearchMessageInputRoot = styled4__default.default.form`
|
|
12474
12465
|
&& {
|
|
12475
12466
|
align-items: end;
|
|
12476
12467
|
background-color: ${colors2.primary.white};
|
|
@@ -12493,7 +12484,7 @@ var SearchMessageInputRoot = styled6__default.default.form`
|
|
|
12493
12484
|
}
|
|
12494
12485
|
}
|
|
12495
12486
|
`;
|
|
12496
|
-
var SearchMessageInputField =
|
|
12487
|
+
var SearchMessageInputField = styled4__default.default.textarea`
|
|
12497
12488
|
appearance: none;
|
|
12498
12489
|
background: transparent;
|
|
12499
12490
|
border: 0;
|
|
@@ -12512,12 +12503,12 @@ var SearchMessageInputField = styled6__default.default.textarea`
|
|
|
12512
12503
|
opacity: 1;
|
|
12513
12504
|
}
|
|
12514
12505
|
`;
|
|
12515
|
-
var SearchMessageInputActions =
|
|
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 =
|
|
12511
|
+
var SearchMessageInputActionButton = styled4__default.default.button`
|
|
12521
12512
|
&&&& {
|
|
12522
12513
|
align-items: center;
|
|
12523
12514
|
appearance: none;
|
|
@@ -12661,7 +12652,7 @@ function SearchMessageInput({
|
|
|
12661
12652
|
] });
|
|
12662
12653
|
}
|
|
12663
12654
|
var { colors: colors3 } = foundationTheme.nuskinTheme;
|
|
12664
|
-
|
|
12655
|
+
styled4__default.default.div`
|
|
12665
12656
|
position: fixed;
|
|
12666
12657
|
inset: 0;
|
|
12667
12658
|
z-index: 10000;
|
|
@@ -12669,7 +12660,7 @@ var SearchModalOverlay = styled6__default.default.div`
|
|
|
12669
12660
|
display: flex;
|
|
12670
12661
|
flex-direction: column;
|
|
12671
12662
|
`;
|
|
12672
|
-
var SearchPanelRoot =
|
|
12663
|
+
var SearchPanelRoot = styled4__default.default.section`
|
|
12673
12664
|
background-color: ${colors3.primary.white};
|
|
12674
12665
|
border-block-end: 1px solid ${colors3.neutral[30]};
|
|
12675
12666
|
color: ${colors3.primary.black};
|
|
@@ -12677,11 +12668,15 @@ var SearchPanelRoot = styled6__default.default.section`
|
|
|
12677
12668
|
${({ $chatMode }) => $chatMode && `
|
|
12678
12669
|
display: flex;
|
|
12679
12670
|
flex-direction: column;
|
|
12680
|
-
max-
|
|
12671
|
+
max-block-size: 92dvh;
|
|
12681
12672
|
overflow: hidden;
|
|
12682
12673
|
`}
|
|
12674
|
+
${({ $agentMode }) => $agentMode && `
|
|
12675
|
+
/* a definite height, so an embedded agent that fills its host has room to lay out */
|
|
12676
|
+
block-size: 92dvh;
|
|
12677
|
+
`}
|
|
12683
12678
|
`;
|
|
12684
|
-
var SearchPanelInner =
|
|
12679
|
+
var SearchPanelInner = styled4__default.default.div`
|
|
12685
12680
|
display: grid;
|
|
12686
12681
|
gap: 1.5rem;
|
|
12687
12682
|
inline-size: min(100%, 75rem);
|
|
@@ -12695,7 +12690,7 @@ var SearchPanelInner = styled6__default.default.div`
|
|
|
12695
12690
|
overflow: hidden;
|
|
12696
12691
|
`}
|
|
12697
12692
|
`;
|
|
12698
|
-
var SearchPanelScrollContent =
|
|
12693
|
+
var SearchPanelScrollContent = styled4__default.default.div`
|
|
12699
12694
|
flex: 1;
|
|
12700
12695
|
min-block-size: 0;
|
|
12701
12696
|
overflow-y: auto;
|
|
@@ -12705,7 +12700,14 @@ var SearchPanelScrollContent = styled6__default.default.div`
|
|
|
12705
12700
|
display: none;
|
|
12706
12701
|
}
|
|
12707
12702
|
`;
|
|
12708
|
-
var
|
|
12703
|
+
var SearchPanelAgentContent = styled4__default.default.div`
|
|
12704
|
+
flex: 1;
|
|
12705
|
+
min-block-size: 0;
|
|
12706
|
+
min-inline-size: 0;
|
|
12707
|
+
overflow: hidden;
|
|
12708
|
+
position: relative;
|
|
12709
|
+
`;
|
|
12710
|
+
var SearchPanelHeader = styled4__default.default.header`
|
|
12709
12711
|
display: flex;
|
|
12710
12712
|
justify-content: space-between;
|
|
12711
12713
|
align-items: center;
|
|
@@ -12714,12 +12716,12 @@ var SearchPanelHeader = styled6__default.default.header`
|
|
|
12714
12716
|
justify-content: flex-end;
|
|
12715
12717
|
`}
|
|
12716
12718
|
`;
|
|
12717
|
-
var SearchPanelLogoSlot =
|
|
12719
|
+
var SearchPanelLogoSlot = styled4__default.default.div`
|
|
12718
12720
|
flex: 0 0 auto;
|
|
12719
12721
|
/* when header is flex-end (chat mode), push the logo to the far left */
|
|
12720
12722
|
margin-inline-end: auto;
|
|
12721
12723
|
`;
|
|
12722
|
-
var SearchPanelCloseButton =
|
|
12724
|
+
var SearchPanelCloseButton = styled4__default.default.button`
|
|
12723
12725
|
align-items: center;
|
|
12724
12726
|
appearance: none;
|
|
12725
12727
|
background: transparent;
|
|
@@ -12736,16 +12738,17 @@ var SearchPanelCloseButton = styled6__default.default.button`
|
|
|
12736
12738
|
outline-offset: 2px;
|
|
12737
12739
|
}
|
|
12738
12740
|
`;
|
|
12739
|
-
var SearchPanelContent =
|
|
12741
|
+
var SearchPanelContent = styled4__default.default.div`
|
|
12740
12742
|
min-inline-size: 0;
|
|
12741
12743
|
`;
|
|
12742
|
-
var SearchPanelMessageInput =
|
|
12744
|
+
var SearchPanelMessageInput = styled4__default.default.div`
|
|
12743
12745
|
inline-size: min(100%, 44rem);
|
|
12744
12746
|
justify-self: center;
|
|
12745
12747
|
width: 100%;
|
|
12746
12748
|
`;
|
|
12747
12749
|
function SearchPanel({
|
|
12748
12750
|
"aria-label": ariaLabel,
|
|
12751
|
+
agentMode = false,
|
|
12749
12752
|
children,
|
|
12750
12753
|
chatMode = false,
|
|
12751
12754
|
closeLabel,
|
|
@@ -12756,83 +12759,243 @@ function SearchPanel({
|
|
|
12756
12759
|
onClose,
|
|
12757
12760
|
...props
|
|
12758
12761
|
}) {
|
|
12759
|
-
const
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12762
|
+
const flexLayout = chatMode || agentMode;
|
|
12763
|
+
let content3;
|
|
12764
|
+
if (agentMode) {
|
|
12765
|
+
content3 = /* @__PURE__ */ jsxRuntime.jsx(SearchPanelAgentContent, { "data-agent-container": "", children });
|
|
12766
|
+
} else if (chatMode) {
|
|
12767
|
+
content3 = /* @__PURE__ */ jsxRuntime.jsx(SearchPanelScrollContent, { "data-scroll-container": "", children });
|
|
12768
|
+
} else {
|
|
12769
|
+
content3 = /* @__PURE__ */ jsxRuntime.jsx(SearchPanelContent, { children });
|
|
12770
|
+
}
|
|
12771
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12772
|
+
SearchPanelRoot,
|
|
12773
|
+
{
|
|
12774
|
+
...props,
|
|
12775
|
+
"aria-label": ariaLabel,
|
|
12776
|
+
$chatMode: flexLayout,
|
|
12777
|
+
$agentMode: agentMode,
|
|
12778
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(SearchPanelInner, { $chatMode: flexLayout, children: [
|
|
12779
|
+
/* @__PURE__ */ jsxRuntime.jsxs(SearchPanelHeader, { $chatMode: flexLayout, children: [
|
|
12780
|
+
logoSlot && /* @__PURE__ */ jsxRuntime.jsx(SearchPanelLogoSlot, { children: logoSlot }),
|
|
12781
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12782
|
+
SearchPanelCloseButton,
|
|
12783
|
+
{
|
|
12784
|
+
type: "button",
|
|
12785
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
12786
|
+
onClick: onClose,
|
|
12787
|
+
children: [
|
|
12788
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { cursor: ICON_CURSORS.POINTER, size: ICON_SIZES.SMALL, type: ICON_TYPES.CLOSE }),
|
|
12789
|
+
closeLabel
|
|
12790
|
+
]
|
|
12791
|
+
}
|
|
12792
|
+
)
|
|
12793
|
+
] }),
|
|
12794
|
+
!flexLayout && inputSlot && /* @__PURE__ */ jsxRuntime.jsx(SearchPanelMessageInput, { children: inputSlot }),
|
|
12795
|
+
!agentMode && initialPrompt && /* @__PURE__ */ jsxRuntime.jsx(SearchMessage, { sender: SEARCH_MESSAGE_SENDERS.USER, text: initialPrompt }),
|
|
12796
|
+
content3,
|
|
12797
|
+
!agentMode && (chatMode || !inputSlot && messageInputProps) && messageInputProps && /* @__PURE__ */ jsxRuntime.jsx(SearchPanelMessageInput, { children: /* @__PURE__ */ jsxRuntime.jsx(SearchMessageInput, { ...messageInputProps }) })
|
|
12798
|
+
] })
|
|
12799
|
+
}
|
|
12800
|
+
);
|
|
12801
|
+
}
|
|
12802
|
+
var MOBILE_MAX_PX = 1024;
|
|
12803
|
+
var colors4 = {
|
|
12804
|
+
text: "#111827",
|
|
12805
|
+
muted: "#6b7280",
|
|
12806
|
+
hover: "#f3f4f6",
|
|
12807
|
+
surface: "#ffffff",
|
|
12808
|
+
borderLight: "#e5e7eb"
|
|
12809
|
+
};
|
|
12810
|
+
var SearchModalBackdropRoot = styled4__default.default.div`
|
|
12811
|
+
-webkit-tap-highlight-color: transparent;
|
|
12812
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
12813
|
+
inset: 0;
|
|
12814
|
+
position: fixed;
|
|
12815
|
+
`;
|
|
12816
|
+
var SearchModalSurface = styled4__default.default.div`
|
|
12817
|
+
inline-size: 100%;
|
|
12818
|
+
outline: none;
|
|
12819
|
+
`;
|
|
12820
|
+
var SearchSuggestionsPanel = styled4__default.default.div`
|
|
12821
|
+
position: relative;
|
|
12822
|
+
width: 100%;
|
|
12823
|
+
margin-top: 8px;
|
|
12824
|
+
`;
|
|
12825
|
+
var SearchSuggestionsList = styled4__default.default.ul`
|
|
12826
|
+
display: flex;
|
|
12827
|
+
flex-direction: column;
|
|
12828
|
+
list-style: none;
|
|
12829
|
+
margin: 0;
|
|
12830
|
+
padding: 0;
|
|
12831
|
+
`;
|
|
12832
|
+
var SearchSuggestionOption = styled4__default.default.li`
|
|
12833
|
+
display: flex;
|
|
12834
|
+
align-items: center;
|
|
12835
|
+
width: 100%;
|
|
12836
|
+
min-height: 58px;
|
|
12837
|
+
padding: 4px 24px;
|
|
12838
|
+
box-sizing: border-box;
|
|
12839
|
+
color: ${colors4.text};
|
|
12840
|
+
`;
|
|
12841
|
+
var PassiveSuggestionOption = styled4__default.default(SearchSuggestionOption)`
|
|
12842
|
+
cursor: default;
|
|
12843
|
+
color: ${colors4.muted};
|
|
12844
|
+
`;
|
|
12845
|
+
var SuggestionSectionHeading = styled4__default.default.div`
|
|
12846
|
+
padding: 12px 24px 8px;
|
|
12847
|
+
margin-bottom: 4px;
|
|
12848
|
+
font-size: 16px;
|
|
12849
|
+
font-weight: 700;
|
|
12850
|
+
color: ${colors4.text};
|
|
12851
|
+
background: ${colors4.surface};
|
|
12852
|
+
border-bottom: 1px solid ${colors4.borderLight};
|
|
12853
|
+
`;
|
|
12854
|
+
var RecentSearchesSection = styled4__default.default.section`
|
|
12855
|
+
padding: 24px 35px 18px;
|
|
12856
|
+
background: ${colors4.surface};
|
|
12857
|
+
|
|
12858
|
+
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
12859
|
+
padding: 18px 20px 16px;
|
|
12860
|
+
}
|
|
12861
|
+
`;
|
|
12862
|
+
var RecentSearchesHeader = styled4__default.default.div`
|
|
12863
|
+
display: flex;
|
|
12864
|
+
align-items: center;
|
|
12865
|
+
justify-content: space-between;
|
|
12866
|
+
gap: 16px;
|
|
12867
|
+
margin-bottom: 13px;
|
|
12868
|
+
`;
|
|
12869
|
+
var RecentSearchesTitle = styled4__default.default.h3`
|
|
12870
|
+
margin: 0;
|
|
12871
|
+
font-size: 16px;
|
|
12872
|
+
font-weight: 700;
|
|
12873
|
+
color: ${colors4.text};
|
|
12874
|
+
|
|
12875
|
+
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
12876
|
+
font-size: 15px;
|
|
12877
|
+
line-height: 1.35;
|
|
12878
|
+
}
|
|
12879
|
+
`;
|
|
12880
|
+
var RecentSearchesClearButton = styled4__default.default.button`
|
|
12881
|
+
margin: 0;
|
|
12882
|
+
padding: 0;
|
|
12883
|
+
border: none;
|
|
12884
|
+
background: transparent;
|
|
12885
|
+
color: ${colors4.text};
|
|
12886
|
+
font-size: 16px;
|
|
12887
|
+
cursor: pointer;
|
|
12888
|
+
|
|
12889
|
+
&:focus-visible {
|
|
12890
|
+
outline: 2px solid ${colors4.text};
|
|
12891
|
+
outline-offset: 2px;
|
|
12892
|
+
border-radius: 4px;
|
|
12893
|
+
}
|
|
12894
|
+
|
|
12895
|
+
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
12896
|
+
font-size: 14px;
|
|
12897
|
+
}
|
|
12898
|
+
`;
|
|
12899
|
+
var RecentSearchesList = styled4__default.default.div`
|
|
12900
|
+
display: flex;
|
|
12901
|
+
flex-wrap: wrap;
|
|
12902
|
+
gap: 10px;
|
|
12903
|
+
`;
|
|
12904
|
+
var RecentSearchChip = styled4__default.default.button`
|
|
12905
|
+
display: inline-flex;
|
|
12906
|
+
align-items: center;
|
|
12907
|
+
justify-content: center;
|
|
12908
|
+
min-height: 40px;
|
|
12909
|
+
padding: 8px 16px;
|
|
12910
|
+
border: 1px solid ${colors4.borderLight};
|
|
12911
|
+
border-radius: 999px;
|
|
12912
|
+
background: ${colors4.surface};
|
|
12913
|
+
color: ${colors4.text};
|
|
12914
|
+
font-size: 16px;
|
|
12915
|
+
cursor: pointer;
|
|
12916
|
+
|
|
12917
|
+
&:hover {
|
|
12918
|
+
background: ${colors4.hover};
|
|
12919
|
+
}
|
|
12920
|
+
|
|
12921
|
+
&:focus-visible {
|
|
12922
|
+
outline: 2px solid ${colors4.text};
|
|
12923
|
+
outline-offset: 2px;
|
|
12924
|
+
}
|
|
12925
|
+
|
|
12926
|
+
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
12927
|
+
min-height: 36px;
|
|
12928
|
+
padding: 6px 14px;
|
|
12929
|
+
font-size: 14px;
|
|
12930
|
+
border-radius: 10px;
|
|
12931
|
+
}
|
|
12932
|
+
`;
|
|
12933
|
+
var MAX_RECENT = 6;
|
|
12934
|
+
function RecentSearches({
|
|
12935
|
+
items,
|
|
12936
|
+
title,
|
|
12937
|
+
clearLabel,
|
|
12938
|
+
onSelect,
|
|
12939
|
+
onClear
|
|
12940
|
+
}) {
|
|
12941
|
+
const [showAll, setShowAll] = React.useState(false);
|
|
12942
|
+
const visible = showAll ? items : items.slice(0, MAX_RECENT);
|
|
12943
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RecentSearchesSection, { "aria-label": title, children: [
|
|
12944
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RecentSearchesHeader, { children: [
|
|
12945
|
+
/* @__PURE__ */ jsxRuntime.jsx(RecentSearchesTitle, { children: title }),
|
|
12946
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12947
|
+
RecentSearchesClearButton,
|
|
12948
|
+
{
|
|
12949
|
+
type: "button",
|
|
12950
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
12951
|
+
onClick: onClear,
|
|
12952
|
+
children: clearLabel
|
|
12953
|
+
}
|
|
12954
|
+
)
|
|
12955
|
+
] }),
|
|
12956
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RecentSearchesList, { children: [
|
|
12957
|
+
visible.map((query) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
12958
|
+
RecentSearchChip,
|
|
12959
|
+
{
|
|
12960
|
+
type: "button",
|
|
12961
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
12962
|
+
onClick: () => onSelect(query),
|
|
12963
|
+
children: query
|
|
12964
|
+
},
|
|
12965
|
+
query
|
|
12966
|
+
)),
|
|
12967
|
+
!showAll && items.length > MAX_RECENT && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12968
|
+
RecentSearchChip,
|
|
12765
12969
|
{
|
|
12766
12970
|
type: "button",
|
|
12767
12971
|
onMouseDown: (e) => e.preventDefault(),
|
|
12768
|
-
onClick:
|
|
12972
|
+
onClick: () => setShowAll(true),
|
|
12769
12973
|
children: [
|
|
12770
|
-
|
|
12771
|
-
|
|
12974
|
+
"+",
|
|
12975
|
+
items.length - MAX_RECENT,
|
|
12976
|
+
" More"
|
|
12772
12977
|
]
|
|
12773
12978
|
}
|
|
12774
12979
|
)
|
|
12775
|
-
] })
|
|
12776
|
-
|
|
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
|
-
};
|
|
12980
|
+
] })
|
|
12981
|
+
] });
|
|
12819
12982
|
}
|
|
12820
12983
|
var SUGGESTION_MOBILE_MAX_PX = 1024;
|
|
12821
|
-
var
|
|
12984
|
+
var colors5 = {
|
|
12822
12985
|
text: "#111827",
|
|
12823
12986
|
muted: "#6b7280",
|
|
12824
12987
|
accent: "rgb(15, 118, 110)"
|
|
12825
12988
|
};
|
|
12826
|
-
var SuggestionOption =
|
|
12989
|
+
var SuggestionOption = styled4__default.default.li`
|
|
12827
12990
|
display: flex;
|
|
12828
12991
|
align-items: center;
|
|
12829
12992
|
width: 100%;
|
|
12830
12993
|
min-height: 58px;
|
|
12831
12994
|
padding: 4px 24px;
|
|
12832
12995
|
box-sizing: border-box;
|
|
12833
|
-
color: ${
|
|
12996
|
+
color: ${colors5.text};
|
|
12834
12997
|
`;
|
|
12835
|
-
var SuggestionRow =
|
|
12998
|
+
var SuggestionRow = styled4__default.default(SuggestionOption)`
|
|
12836
12999
|
display: grid;
|
|
12837
13000
|
grid-template-columns: minmax(0, 1fr) 18px;
|
|
12838
13001
|
align-items: center;
|
|
@@ -12842,7 +13005,7 @@ var SuggestionRow = styled6__default.default(SuggestionOption)`
|
|
|
12842
13005
|
|
|
12843
13006
|
&[data-selected='true'] {
|
|
12844
13007
|
background: rgba(15, 118, 110, 0.08);
|
|
12845
|
-
box-shadow: inset 3px 0 0 ${
|
|
13008
|
+
box-shadow: inset 3px 0 0 ${colors5.accent};
|
|
12846
13009
|
}
|
|
12847
13010
|
|
|
12848
13011
|
&[data-highlighted='true'],
|
|
@@ -12853,7 +13016,7 @@ var SuggestionRow = styled6__default.default(SuggestionOption)`
|
|
|
12853
13016
|
&[data-highlighted='true'][data-selected='true'] {
|
|
12854
13017
|
background: rgba(15, 118, 110, 0.12);
|
|
12855
13018
|
box-shadow:
|
|
12856
|
-
inset 3px 0 0 ${
|
|
13019
|
+
inset 3px 0 0 ${colors5.accent},
|
|
12857
13020
|
inset 0 0 0 2px rgba(17, 24, 39, 0.12);
|
|
12858
13021
|
}
|
|
12859
13022
|
|
|
@@ -12870,7 +13033,7 @@ var SuggestionRow = styled6__default.default(SuggestionOption)`
|
|
|
12870
13033
|
column-gap: 8px;
|
|
12871
13034
|
}
|
|
12872
13035
|
`;
|
|
12873
|
-
var SuggestionContentWrapper =
|
|
13036
|
+
var SuggestionContentWrapper = styled4__default.default.div`
|
|
12874
13037
|
display: grid;
|
|
12875
13038
|
grid-template-columns: 50px minmax(0, 1fr);
|
|
12876
13039
|
align-items: center;
|
|
@@ -12892,7 +13055,7 @@ var SuggestionContentWrapper = styled6__default.default.div`
|
|
|
12892
13055
|
}
|
|
12893
13056
|
|
|
12894
13057
|
&:focus-visible {
|
|
12895
|
-
outline: 2px solid ${
|
|
13058
|
+
outline: 2px solid ${colors5.text};
|
|
12896
13059
|
outline-offset: 3px;
|
|
12897
13060
|
}
|
|
12898
13061
|
|
|
@@ -12900,14 +13063,14 @@ var SuggestionContentWrapper = styled6__default.default.div`
|
|
|
12900
13063
|
grid-template-columns: minmax(0, 1fr);
|
|
12901
13064
|
}
|
|
12902
13065
|
`;
|
|
12903
|
-
var SuggestionThumbnail =
|
|
13066
|
+
var SuggestionThumbnail = styled4__default.default.img`
|
|
12904
13067
|
width: 50px;
|
|
12905
13068
|
height: 50px;
|
|
12906
13069
|
object-fit: contain;
|
|
12907
13070
|
flex-shrink: 0;
|
|
12908
13071
|
align-self: center;
|
|
12909
13072
|
`;
|
|
12910
|
-
var SuggestionLabel =
|
|
13073
|
+
var SuggestionLabel = styled4__default.default.span`
|
|
12911
13074
|
display: block;
|
|
12912
13075
|
min-width: 0;
|
|
12913
13076
|
line-height: 24px;
|
|
@@ -12915,25 +13078,25 @@ var SuggestionLabel = styled6__default.default.span`
|
|
|
12915
13078
|
overflow-wrap: anywhere;
|
|
12916
13079
|
word-break: break-word;
|
|
12917
13080
|
font-size: 16px;
|
|
12918
|
-
color: ${
|
|
13081
|
+
color: ${colors5.text};
|
|
12919
13082
|
|
|
12920
13083
|
@media (max-width: ${SUGGESTION_MOBILE_MAX_PX}px) {
|
|
12921
13084
|
font-size: 14px;
|
|
12922
13085
|
line-height: 20px;
|
|
12923
13086
|
}
|
|
12924
13087
|
`;
|
|
12925
|
-
var SuggestionActionIcon =
|
|
13088
|
+
var SuggestionActionIcon = styled4__default.default.span`
|
|
12926
13089
|
display: inline-flex;
|
|
12927
13090
|
align-items: center;
|
|
12928
13091
|
justify-content: center;
|
|
12929
13092
|
width: 24px;
|
|
12930
13093
|
height: 24px;
|
|
12931
|
-
color: var(--suggestion-icon-color, ${
|
|
13094
|
+
color: var(--suggestion-icon-color, ${colors5.text});
|
|
12932
13095
|
flex-shrink: 0;
|
|
12933
13096
|
align-self: center;
|
|
12934
13097
|
|
|
12935
13098
|
&[data-cart-disabled='true'] {
|
|
12936
|
-
color: var(--suggestion-muted, ${
|
|
13099
|
+
color: var(--suggestion-muted, ${colors5.muted});
|
|
12937
13100
|
}
|
|
12938
13101
|
|
|
12939
13102
|
svg {
|
|
@@ -12942,7 +13105,7 @@ var SuggestionActionIcon = styled6__default.default.span`
|
|
|
12942
13105
|
display: block;
|
|
12943
13106
|
}
|
|
12944
13107
|
`;
|
|
12945
|
-
var SuggestionActionButton =
|
|
13108
|
+
var SuggestionActionButton = styled4__default.default.button`
|
|
12946
13109
|
display: inline-flex;
|
|
12947
13110
|
align-items: center;
|
|
12948
13111
|
justify-content: center;
|
|
@@ -12952,13 +13115,13 @@ var SuggestionActionButton = styled6__default.default.button`
|
|
|
12952
13115
|
padding: 0;
|
|
12953
13116
|
border: none;
|
|
12954
13117
|
background: transparent;
|
|
12955
|
-
color: var(--suggestion-icon-color, ${
|
|
13118
|
+
color: var(--suggestion-icon-color, ${colors5.text});
|
|
12956
13119
|
flex-shrink: 0;
|
|
12957
13120
|
align-self: center;
|
|
12958
13121
|
cursor: pointer;
|
|
12959
13122
|
|
|
12960
13123
|
&:focus-visible {
|
|
12961
|
-
outline: 2px solid ${
|
|
13124
|
+
outline: 2px solid ${colors5.text};
|
|
12962
13125
|
outline-offset: 3px;
|
|
12963
13126
|
border-radius: 4px;
|
|
12964
13127
|
}
|
|
@@ -12969,6 +13132,38 @@ var SuggestionActionButton = styled6__default.default.button`
|
|
|
12969
13132
|
display: block;
|
|
12970
13133
|
}
|
|
12971
13134
|
`;
|
|
13135
|
+
|
|
13136
|
+
// src/components/SuggestionRow/helpers.ts
|
|
13137
|
+
var CART_DISABLED_PRODUCT_STATUSES = /* @__PURE__ */ new Set([
|
|
13138
|
+
"discontinued",
|
|
13139
|
+
"preview",
|
|
13140
|
+
"previewproduct",
|
|
13141
|
+
"test",
|
|
13142
|
+
"stopped",
|
|
13143
|
+
"replacement",
|
|
13144
|
+
"bundleonly",
|
|
13145
|
+
"inactive",
|
|
13146
|
+
"notavailable"
|
|
13147
|
+
]);
|
|
13148
|
+
function normalizeProductStatusValue(value) {
|
|
13149
|
+
const text4 = typeof value === "string" || typeof value === "number" ? String(value) : "";
|
|
13150
|
+
return text4.trim().toLowerCase().replace(/\s+/g, "");
|
|
13151
|
+
}
|
|
13152
|
+
function isNonSellableStatusValue(statusValue) {
|
|
13153
|
+
if (CART_DISABLED_PRODUCT_STATUSES.has(statusValue)) return true;
|
|
13154
|
+
return statusValue !== "sellable" && statusValue !== "active";
|
|
13155
|
+
}
|
|
13156
|
+
function isCartActionDisabled(option) {
|
|
13157
|
+
var _a;
|
|
13158
|
+
if ((_a = option["out_of_stock"]) != null ? _a : option["outOfStock"]) return true;
|
|
13159
|
+
const statusValues = [
|
|
13160
|
+
option["productStatus"],
|
|
13161
|
+
option["product_status"],
|
|
13162
|
+
option["status"],
|
|
13163
|
+
option["sku_status"]
|
|
13164
|
+
].map(normalizeProductStatusValue).filter(Boolean);
|
|
13165
|
+
return statusValues.some(isNonSellableStatusValue);
|
|
13166
|
+
}
|
|
12972
13167
|
function resolveImageSrc(option, isDidYouMean) {
|
|
12973
13168
|
var _a, _b, _c;
|
|
12974
13169
|
if (isDidYouMean) return "";
|
|
@@ -12985,7 +13180,7 @@ function getSuggestionDisplayData(option) {
|
|
|
12985
13180
|
const productType = (_a = option["product_type"]) != null ? _a : option["productType"];
|
|
12986
13181
|
const outOfStock = (_b = option["out_of_stock"]) != null ? _b : option["outOfStock"];
|
|
12987
13182
|
const cartDisabledRaw = (_c = option["cartActionDisabled"]) != null ? _c : option["cart_action_disabled"];
|
|
12988
|
-
const cartActionDisabled = cartDisabledRaw != null ? Boolean(cartDisabledRaw) :
|
|
13183
|
+
const cartActionDisabled = cartDisabledRaw != null ? Boolean(cartDisabledRaw) : isCartActionDisabled(option);
|
|
12989
13184
|
return {
|
|
12990
13185
|
imageSrc: resolveImageSrc(option, isDidYouMean),
|
|
12991
13186
|
displayLabel: resolveDisplayLabel(option),
|
|
@@ -13161,12 +13356,12 @@ function SuggestionRow2({
|
|
|
13161
13356
|
}
|
|
13162
13357
|
);
|
|
13163
13358
|
}
|
|
13164
|
-
var
|
|
13359
|
+
var colors6 = {
|
|
13165
13360
|
text: "#111827",
|
|
13166
13361
|
surface: "#ffffff",
|
|
13167
13362
|
borderLight: "#e5e7eb"
|
|
13168
13363
|
};
|
|
13169
|
-
var SeeMoreLinkContainer =
|
|
13364
|
+
var SeeMoreLinkContainer = styled4__default.default.div`
|
|
13170
13365
|
position: relative;
|
|
13171
13366
|
display: flex;
|
|
13172
13367
|
align-items: center;
|
|
@@ -13175,7 +13370,7 @@ var SeeMoreLinkContainer = styled6__default.default.div`
|
|
|
13175
13370
|
min-height: 48px;
|
|
13176
13371
|
padding: 0 16px;
|
|
13177
13372
|
box-sizing: border-box;
|
|
13178
|
-
background: ${
|
|
13373
|
+
background: ${colors6.surface};
|
|
13179
13374
|
|
|
13180
13375
|
&::before {
|
|
13181
13376
|
content: '';
|
|
@@ -13183,12 +13378,12 @@ var SeeMoreLinkContainer = styled6__default.default.div`
|
|
|
13183
13378
|
top: 0;
|
|
13184
13379
|
left: 50%;
|
|
13185
13380
|
width: 100vw;
|
|
13186
|
-
border-top: 1px solid ${
|
|
13381
|
+
border-top: 1px solid ${colors6.borderLight};
|
|
13187
13382
|
transform: translateX(-50%);
|
|
13188
13383
|
pointer-events: none;
|
|
13189
13384
|
}
|
|
13190
13385
|
`;
|
|
13191
|
-
var SeeMoreLinkText =
|
|
13386
|
+
var SeeMoreLinkText = styled4__default.default.button`
|
|
13192
13387
|
width: auto;
|
|
13193
13388
|
height: auto;
|
|
13194
13389
|
padding: 8px 0;
|
|
@@ -13200,7 +13395,7 @@ var SeeMoreLinkText = styled6__default.default.button`
|
|
|
13200
13395
|
text-decoration: underline;
|
|
13201
13396
|
text-underline-offset: 2px;
|
|
13202
13397
|
cursor: pointer;
|
|
13203
|
-
color: ${
|
|
13398
|
+
color: ${colors6.text};
|
|
13204
13399
|
|
|
13205
13400
|
&:hover {
|
|
13206
13401
|
opacity: 0.8;
|
|
@@ -13211,7 +13406,7 @@ var SeeMoreLinkText = styled6__default.default.button`
|
|
|
13211
13406
|
}
|
|
13212
13407
|
|
|
13213
13408
|
&:focus-visible {
|
|
13214
|
-
outline: 2px solid ${
|
|
13409
|
+
outline: 2px solid ${colors6.text};
|
|
13215
13410
|
outline-offset: 2px;
|
|
13216
13411
|
border-radius: 4px;
|
|
13217
13412
|
}
|
|
@@ -13258,600 +13453,27 @@ function SeeMoreLink({
|
|
|
13258
13453
|
}
|
|
13259
13454
|
) });
|
|
13260
13455
|
}
|
|
13261
|
-
|
|
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
|
-
padding: 0;
|
|
13336
|
-
position: sticky;
|
|
13337
|
-
inset-block-end: 0.75rem;
|
|
13338
|
-
z-index: 1;
|
|
13339
|
-
|
|
13340
|
-
&:hover {
|
|
13341
|
-
background: ${colors6.borderLight};
|
|
13342
|
-
}
|
|
13343
|
-
|
|
13344
|
-
&:focus-visible {
|
|
13345
|
-
outline: 2px solid ${colors6.text};
|
|
13346
|
-
outline-offset: 2px;
|
|
13347
|
-
}
|
|
13348
|
-
`;
|
|
13349
|
-
var SuggestionSectionHeading = styled6__default.default.div`
|
|
13350
|
-
padding: 12px 24px 8px;
|
|
13351
|
-
margin-bottom: 4px;
|
|
13352
|
-
font-size: 16px;
|
|
13353
|
-
font-weight: 700;
|
|
13354
|
-
color: ${colors6.text};
|
|
13355
|
-
background: ${colors6.surface};
|
|
13356
|
-
border-bottom: 1px solid ${colors6.borderLight};
|
|
13357
|
-
`;
|
|
13358
|
-
var RecentSearchesSection = styled6__default.default.section`
|
|
13359
|
-
padding: 24px 35px 18px;
|
|
13360
|
-
background: ${colors6.surface};
|
|
13361
|
-
|
|
13362
|
-
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
13363
|
-
padding: 18px 20px 16px;
|
|
13364
|
-
}
|
|
13365
|
-
`;
|
|
13366
|
-
var RecentSearchesHeader = styled6__default.default.div`
|
|
13367
|
-
display: flex;
|
|
13368
|
-
align-items: center;
|
|
13369
|
-
justify-content: space-between;
|
|
13370
|
-
gap: 16px;
|
|
13371
|
-
margin-bottom: 13px;
|
|
13372
|
-
`;
|
|
13373
|
-
var RecentSearchesTitle = styled6__default.default.h3`
|
|
13374
|
-
margin: 0;
|
|
13375
|
-
font-size: 16px;
|
|
13376
|
-
font-weight: 700;
|
|
13377
|
-
color: ${colors6.text};
|
|
13378
|
-
|
|
13379
|
-
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
13380
|
-
font-size: 15px;
|
|
13381
|
-
line-height: 1.35;
|
|
13382
|
-
}
|
|
13383
|
-
`;
|
|
13384
|
-
var RecentSearchesClearButton = styled6__default.default.button`
|
|
13385
|
-
margin: 0;
|
|
13386
|
-
padding: 0;
|
|
13387
|
-
border: none;
|
|
13388
|
-
background: transparent;
|
|
13389
|
-
color: ${colors6.text};
|
|
13390
|
-
font-size: 16px;
|
|
13391
|
-
cursor: pointer;
|
|
13392
|
-
|
|
13393
|
-
&:focus-visible {
|
|
13394
|
-
outline: 2px solid ${colors6.text};
|
|
13395
|
-
outline-offset: 2px;
|
|
13396
|
-
border-radius: 4px;
|
|
13397
|
-
}
|
|
13398
|
-
|
|
13399
|
-
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
13400
|
-
font-size: 14px;
|
|
13401
|
-
}
|
|
13402
|
-
`;
|
|
13403
|
-
var RecentSearchesList = styled6__default.default.div`
|
|
13404
|
-
display: flex;
|
|
13405
|
-
flex-wrap: wrap;
|
|
13406
|
-
gap: 10px;
|
|
13407
|
-
`;
|
|
13408
|
-
var RecentSearchChip = styled6__default.default.button`
|
|
13409
|
-
display: inline-flex;
|
|
13410
|
-
align-items: center;
|
|
13411
|
-
justify-content: center;
|
|
13412
|
-
min-height: 40px;
|
|
13413
|
-
padding: 8px 16px;
|
|
13414
|
-
border: 1px solid ${colors6.borderLight};
|
|
13415
|
-
border-radius: 999px;
|
|
13416
|
-
background: ${colors6.surface};
|
|
13417
|
-
color: ${colors6.text};
|
|
13418
|
-
font-size: 16px;
|
|
13419
|
-
cursor: pointer;
|
|
13420
|
-
|
|
13421
|
-
&:hover {
|
|
13422
|
-
background: ${colors6.hover};
|
|
13423
|
-
}
|
|
13424
|
-
|
|
13425
|
-
&:focus-visible {
|
|
13426
|
-
outline: 2px solid ${colors6.text};
|
|
13427
|
-
outline-offset: 2px;
|
|
13428
|
-
}
|
|
13429
|
-
|
|
13430
|
-
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
13431
|
-
min-height: 36px;
|
|
13432
|
-
padding: 6px 14px;
|
|
13433
|
-
font-size: 14px;
|
|
13434
|
-
border-radius: 10px;
|
|
13435
|
-
}
|
|
13436
|
-
`;
|
|
13437
|
-
var { colors: colors7 } = foundationTheme.nuskinTheme;
|
|
13438
|
-
var ChatResultRoot = styled6__default.default.div`
|
|
13439
|
-
display: flex;
|
|
13440
|
-
flex-direction: column;
|
|
13441
|
-
gap: 1.5rem;
|
|
13442
|
-
min-block-size: 0;
|
|
13443
|
-
overflow-y: auto;
|
|
13444
|
-
padding-block-end: 2rem;
|
|
13445
|
-
position: relative;
|
|
13446
|
-
`;
|
|
13447
|
-
var ProductCarouselWrapper = styled6__default.default.div`
|
|
13448
|
-
display: flex;
|
|
13449
|
-
flex-direction: column;
|
|
13450
|
-
gap: 0.75rem;
|
|
13451
|
-
`;
|
|
13452
|
-
styled6__default.default.div`
|
|
13453
|
-
display: flex;
|
|
13454
|
-
gap: 1rem;
|
|
13455
|
-
overflow-x: auto;
|
|
13456
|
-
padding-block-end: 0.5rem;
|
|
13457
|
-
scroll-snap-type: x mandatory;
|
|
13458
|
-
-webkit-overflow-scrolling: touch;
|
|
13459
|
-
scrollbar-width: none;
|
|
13460
|
-
&::-webkit-scrollbar {
|
|
13461
|
-
display: none;
|
|
13462
|
-
}
|
|
13463
|
-
`;
|
|
13464
|
-
styled6__default.default.a`
|
|
13465
|
-
display: flex;
|
|
13466
|
-
flex: 0 0 auto;
|
|
13467
|
-
flex-direction: column;
|
|
13468
|
-
gap: 0.5rem;
|
|
13469
|
-
scroll-snap-align: start;
|
|
13470
|
-
text-decoration: none;
|
|
13471
|
-
width: 9rem;
|
|
13472
|
-
`;
|
|
13473
|
-
styled6__default.default.img`
|
|
13474
|
-
background: ${colors7.primary.gray};
|
|
13475
|
-
border-radius: 0.5rem;
|
|
13476
|
-
block-size: 9rem;
|
|
13477
|
-
inline-size: 9rem;
|
|
13478
|
-
object-fit: contain;
|
|
13479
|
-
padding: 0.5rem;
|
|
13480
|
-
`;
|
|
13481
|
-
styled6__default.default.span`
|
|
13482
|
-
color: ${colors7.primary.black};
|
|
13483
|
-
display: -webkit-box;
|
|
13484
|
-
font-size: 0.8125rem;
|
|
13485
|
-
line-height: 1.4;
|
|
13486
|
-
overflow: hidden;
|
|
13487
|
-
-webkit-box-orient: vertical;
|
|
13488
|
-
-webkit-line-clamp: 2;
|
|
13489
|
-
`;
|
|
13490
|
-
styled6__default.default.span`
|
|
13491
|
-
color: ${colors7.neutral[70]};
|
|
13492
|
-
font-size: 0.8125rem;
|
|
13493
|
-
font-weight: 600;
|
|
13494
|
-
`;
|
|
13495
|
-
styled6__default.default.button`
|
|
13496
|
-
align-items: center;
|
|
13497
|
-
align-self: center;
|
|
13498
|
-
appearance: none;
|
|
13499
|
-
background: ${colors7.neutral[30]};
|
|
13500
|
-
border: 0;
|
|
13501
|
-
border-radius: 50%;
|
|
13502
|
-
bottom: 0.75rem;
|
|
13503
|
-
color: ${colors7.primary.black};
|
|
13504
|
-
cursor: pointer;
|
|
13505
|
-
display: inline-flex;
|
|
13506
|
-
justify-content: center;
|
|
13507
|
-
block-size: 2rem;
|
|
13508
|
-
inline-size: 2rem;
|
|
13509
|
-
padding: 0;
|
|
13510
|
-
position: sticky;
|
|
13511
|
-
|
|
13512
|
-
&:hover {
|
|
13513
|
-
background: ${colors7.neutral[40]};
|
|
13514
|
-
}
|
|
13515
|
-
`;
|
|
13516
|
-
function isDigit(char) {
|
|
13517
|
-
return char !== void 0 && char >= "0" && char <= "9";
|
|
13518
|
-
}
|
|
13519
|
-
function isLetter(char) {
|
|
13520
|
-
if (char === void 0) return false;
|
|
13521
|
-
const lower = char.toLowerCase();
|
|
13522
|
-
return lower >= "a" && lower <= "z";
|
|
13523
|
-
}
|
|
13524
|
-
function isPricingSpace(char) {
|
|
13525
|
-
return char === " " || char === "\n" || char === "\r" || char === " " || char === "\f";
|
|
13526
|
-
}
|
|
13527
|
-
function findNumberEnd(text4, start, allowCommas) {
|
|
13528
|
-
let cursor = start;
|
|
13529
|
-
let hasDigit = false;
|
|
13530
|
-
while (cursor < text4.length && (isDigit(text4[cursor]) || allowCommas && text4[cursor] === ",")) {
|
|
13531
|
-
hasDigit = hasDigit || isDigit(text4[cursor]);
|
|
13532
|
-
cursor += 1;
|
|
13533
|
-
}
|
|
13534
|
-
if (text4[cursor] === "." && isDigit(text4[cursor + 1])) {
|
|
13535
|
-
cursor += 1;
|
|
13536
|
-
while (cursor < text4.length && isDigit(text4[cursor])) {
|
|
13537
|
-
cursor += 1;
|
|
13538
|
-
}
|
|
13539
|
-
}
|
|
13540
|
-
return hasDigit ? cursor : start;
|
|
13541
|
-
}
|
|
13542
|
-
function removeCurrencyAmounts(text4) {
|
|
13543
|
-
let result = "";
|
|
13544
|
-
let cursor = 0;
|
|
13545
|
-
while (cursor < text4.length) {
|
|
13546
|
-
if (text4[cursor] === "$") {
|
|
13547
|
-
const amountEnd = findNumberEnd(text4, cursor + 1, true);
|
|
13548
|
-
if (amountEnd > cursor + 1) {
|
|
13549
|
-
cursor = amountEnd;
|
|
13550
|
-
continue;
|
|
13551
|
-
}
|
|
13552
|
-
}
|
|
13553
|
-
result += text4[cursor];
|
|
13554
|
-
cursor += 1;
|
|
13555
|
-
}
|
|
13556
|
-
return result;
|
|
13557
|
-
}
|
|
13558
|
-
function removeUnitAmounts(text4, unit) {
|
|
13559
|
-
let result = "";
|
|
13560
|
-
let cursor = 0;
|
|
13561
|
-
while (cursor < text4.length) {
|
|
13562
|
-
if (isDigit(text4[cursor])) {
|
|
13563
|
-
const numberEnd = findNumberEnd(text4, cursor, false);
|
|
13564
|
-
let unitStart = numberEnd;
|
|
13565
|
-
while (isPricingSpace(text4[unitStart])) {
|
|
13566
|
-
unitStart += 1;
|
|
13567
|
-
}
|
|
13568
|
-
const unitEnd = unitStart + unit.length;
|
|
13569
|
-
if (text4.slice(unitStart, unitEnd).toUpperCase() === unit && !isLetter(text4[unitEnd])) {
|
|
13570
|
-
cursor = unitEnd;
|
|
13571
|
-
continue;
|
|
13572
|
-
}
|
|
13573
|
-
}
|
|
13574
|
-
result += text4[cursor];
|
|
13575
|
-
cursor += 1;
|
|
13576
|
-
}
|
|
13577
|
-
return result;
|
|
13578
|
-
}
|
|
13579
|
-
function removeEmptyPricingParentheses(text4) {
|
|
13580
|
-
let result = "";
|
|
13581
|
-
let cursor = 0;
|
|
13582
|
-
while (cursor < text4.length) {
|
|
13583
|
-
if (text4[cursor] === "(") {
|
|
13584
|
-
const candidateStart = cursor;
|
|
13585
|
-
cursor += 1;
|
|
13586
|
-
while (isPricingSpace(text4[cursor]) || text4[cursor] === "," || text4[cursor] === ";") {
|
|
13587
|
-
cursor += 1;
|
|
13588
|
-
}
|
|
13589
|
-
if (text4[cursor] === ")") {
|
|
13590
|
-
cursor += 1;
|
|
13591
|
-
continue;
|
|
13592
|
-
}
|
|
13593
|
-
result += text4.slice(candidateStart, cursor);
|
|
13594
|
-
continue;
|
|
13595
|
-
}
|
|
13596
|
-
result += text4[cursor];
|
|
13597
|
-
cursor += 1;
|
|
13598
|
-
}
|
|
13599
|
-
return result;
|
|
13600
|
-
}
|
|
13601
|
-
function normalizePricingSpace(text4) {
|
|
13602
|
-
let result = "";
|
|
13603
|
-
let previousWasWhitespace = false;
|
|
13604
|
-
for (const char of text4) {
|
|
13605
|
-
if (isPricingSpace(char)) {
|
|
13606
|
-
if (!previousWasWhitespace) {
|
|
13607
|
-
result += " ";
|
|
13608
|
-
previousWasWhitespace = true;
|
|
13609
|
-
}
|
|
13610
|
-
continue;
|
|
13611
|
-
}
|
|
13612
|
-
result += char;
|
|
13613
|
-
previousWasWhitespace = false;
|
|
13614
|
-
}
|
|
13615
|
-
return result.trim();
|
|
13616
|
-
}
|
|
13617
|
-
function stripPricingText(text4) {
|
|
13618
|
-
return normalizePricingSpace(
|
|
13619
|
-
removeEmptyPricingParentheses(
|
|
13620
|
-
removeUnitAmounts(removeUnitAmounts(removeCurrencyAmounts(text4), "PV"), "CV")
|
|
13621
|
-
)
|
|
13622
|
-
);
|
|
13623
|
-
}
|
|
13624
|
-
function toCarouselItem(product, index2, showPricing, history) {
|
|
13625
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
13626
|
-
const slotKey = `ai-${(_b = (_a = product.id) != null ? _a : product.sku) != null ? _b : index2}-${index2}`;
|
|
13627
|
-
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}`;
|
|
13628
|
-
if (!productName) {
|
|
13629
|
-
return {
|
|
13630
|
-
status: "error",
|
|
13631
|
-
slotKey,
|
|
13632
|
-
productId: String((_h = (_g = product.id) != null ? _g : product.sku) != null ? _h : index2),
|
|
13633
|
-
error: {
|
|
13634
|
-
code: reactProductComponents.PRODUCT_CAROUSEL_ERROR_CODES.PRODUCT_NOT_FOUND,
|
|
13635
|
-
technicalMessage: "Missing product name"
|
|
13636
|
-
}
|
|
13637
|
-
};
|
|
13638
|
-
}
|
|
13639
|
-
const href = (_i = product.url) != null ? _i : "#";
|
|
13640
|
-
const routeHref = (_j = product.routeUrl) != null ? _j : product.sku ? `/product/${product.sku}` : href;
|
|
13641
|
-
const imageUrl = (_k = product.imageUrl) != null ? _k : product.image_url;
|
|
13642
|
-
const priceText = (_l = product.price) != null ? _l : product.pv != null ? `${product.pv} PV` : void 0;
|
|
13643
|
-
return {
|
|
13644
|
-
status: "ready",
|
|
13645
|
-
slotKey,
|
|
13646
|
-
productId: String((_n = (_m = product.id) != null ? _m : product.sku) != null ? _n : index2),
|
|
13647
|
-
cardProps: {
|
|
13648
|
-
mode: "cta",
|
|
13649
|
-
title: productName,
|
|
13650
|
-
images: imageUrl ? [{ url: imageUrl, alt: productName }] : [],
|
|
13651
|
-
productHref: href,
|
|
13652
|
-
productAriaLabel: productName,
|
|
13653
|
-
price: showPricing ? priceText : void 0,
|
|
13654
|
-
addToCartLabel: "View Product",
|
|
13655
|
-
addToCartAriaLabel: `View ${productName}`,
|
|
13656
|
-
onProductClick: ({ event } = {}) => {
|
|
13657
|
-
if (href === "#") return;
|
|
13658
|
-
event == null ? void 0 : event.preventDefault();
|
|
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({
|
|
13456
|
+
function SearchSuggestions({
|
|
13824
13457
|
listboxId,
|
|
13825
13458
|
ariaLabel,
|
|
13459
|
+
items,
|
|
13826
13460
|
loading,
|
|
13461
|
+
showNoResults,
|
|
13827
13462
|
showDidYouMean,
|
|
13463
|
+
hasMore,
|
|
13464
|
+
query,
|
|
13828
13465
|
didYouMeanText,
|
|
13829
|
-
visibleSuggestions,
|
|
13830
|
-
highlightedIndex,
|
|
13831
|
-
setHighlightedIndex,
|
|
13832
|
-
runSuggestionAction,
|
|
13833
|
-
selectOption,
|
|
13834
|
-
suggestionRowRefs,
|
|
13835
|
-
fallbackImageUrl,
|
|
13836
|
-
showNoResults,
|
|
13837
13466
|
noSuggestionsText,
|
|
13838
|
-
showInlineAILoading,
|
|
13839
|
-
typedStatus,
|
|
13840
|
-
analyzingLabel,
|
|
13841
|
-
hasMoreResults,
|
|
13842
|
-
footerRef,
|
|
13843
|
-
handleSeeMore,
|
|
13844
13467
|
seeMoreText,
|
|
13845
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
13848
|
-
|
|
13849
|
-
showAllRecent,
|
|
13850
|
-
recentSearches,
|
|
13851
|
-
handleRecentSearchSelect,
|
|
13852
|
-
setShowAllRecent
|
|
13468
|
+
fallbackImageUrl,
|
|
13469
|
+
onSelect,
|
|
13470
|
+
onRunAction,
|
|
13471
|
+
onSeeMore
|
|
13853
13472
|
}) {
|
|
13854
|
-
|
|
13473
|
+
const [highlightedIndex, setHighlightedIndex] = React.useState(-1);
|
|
13474
|
+
const footerRef = React.useRef(null);
|
|
13475
|
+
const suggestionRowRefs = React.useRef({});
|
|
13476
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
13855
13477
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
13856
13478
|
SearchSuggestionsList,
|
|
13857
13479
|
{
|
|
@@ -13861,15 +13483,15 @@ function SearchModalSuggestionsContent({
|
|
|
13861
13483
|
"data-testid": "autocomplete-results-list",
|
|
13862
13484
|
children: [
|
|
13863
13485
|
showDidYouMean && /* @__PURE__ */ jsxRuntime.jsx(SuggestionSectionHeading, { "data-testid": "autocomplete-did-you-mean-heading", children: didYouMeanText }),
|
|
13864
|
-
!loading &&
|
|
13486
|
+
!loading && items.map((option, index2) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
13865
13487
|
SuggestionRow2,
|
|
13866
13488
|
{
|
|
13867
13489
|
inputRef: { current: null },
|
|
13868
13490
|
isHighlighted: index2 === highlightedIndex,
|
|
13869
13491
|
isSelected: false,
|
|
13870
13492
|
onHighlightSuggestion: setHighlightedIndex,
|
|
13871
|
-
onRunSuggestionAction:
|
|
13872
|
-
onSelectSuggestion:
|
|
13493
|
+
onRunSuggestionAction: onRunAction,
|
|
13494
|
+
onSelectSuggestion: onSelect,
|
|
13873
13495
|
registerSuggestionNode: (node2) => {
|
|
13874
13496
|
if (node2) suggestionRowRefs.current[option.id] = node2;
|
|
13875
13497
|
else delete suggestionRowRefs.current[option.id];
|
|
@@ -13881,15 +13503,11 @@ function SearchModalSuggestionsContent({
|
|
|
13881
13503
|
},
|
|
13882
13504
|
option.id
|
|
13883
13505
|
)),
|
|
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
|
-
] })
|
|
13506
|
+
showNoResults && /* @__PURE__ */ jsxRuntime.jsx(PassiveSuggestionOption, { "data-highlighted": "false", children: noSuggestionsText })
|
|
13889
13507
|
]
|
|
13890
13508
|
}
|
|
13891
13509
|
),
|
|
13892
|
-
!loading &&
|
|
13510
|
+
!loading && hasMore && !showDidYouMean && /* @__PURE__ */ jsxRuntime.jsx(
|
|
13893
13511
|
SeeMoreLink,
|
|
13894
13512
|
{
|
|
13895
13513
|
seeMoreLinkRef: footerRef,
|
|
@@ -13899,7 +13517,7 @@ function SearchModalSuggestionsContent({
|
|
|
13899
13517
|
},
|
|
13900
13518
|
onFocusSeeMoreLink: () => {
|
|
13901
13519
|
},
|
|
13902
|
-
onSeeMoreResults:
|
|
13520
|
+
onSeeMoreResults: onSeeMore,
|
|
13903
13521
|
resetSeeMoreLinkFocus: () => {
|
|
13904
13522
|
},
|
|
13905
13523
|
restoreLastSuggestion: () => {
|
|
@@ -13907,667 +13525,102 @@ function SearchModalSuggestionsContent({
|
|
|
13907
13525
|
seeMoreResultsText: seeMoreText,
|
|
13908
13526
|
searchQuery: query
|
|
13909
13527
|
}
|
|
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
|
-
] })
|
|
13528
|
+
)
|
|
13950
13529
|
] });
|
|
13951
13530
|
}
|
|
13531
|
+
var SEARCH_MODAL_Z_INDEX = 1e4;
|
|
13532
|
+
var BACKDROP_PROPS = { "data-testid": "search-modal-backdrop" };
|
|
13533
|
+
var SearchModalBackdrop = React__default.default.forwardRef(function SearchModalBackdrop2({ open: _open, transitionDuration: _duration, ...rest }, ref) {
|
|
13534
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SearchModalBackdropRoot, { ref, ...rest });
|
|
13535
|
+
});
|
|
13952
13536
|
function SearchModal({
|
|
13953
13537
|
isOpen,
|
|
13954
13538
|
onClose,
|
|
13955
|
-
service,
|
|
13956
|
-
history,
|
|
13957
|
-
copy = {},
|
|
13958
13539
|
logo,
|
|
13959
13540
|
cancelLabel = "Cancel",
|
|
13960
13541
|
fallbackImageUrl = "",
|
|
13961
|
-
|
|
13962
|
-
|
|
13963
|
-
|
|
13964
|
-
|
|
13965
|
-
|
|
13542
|
+
copy = {},
|
|
13543
|
+
input,
|
|
13544
|
+
suggestions,
|
|
13545
|
+
recentSearches,
|
|
13546
|
+
agentPanel
|
|
13966
13547
|
}) {
|
|
13967
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
13548
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13968
13549
|
const listboxId = React.useId();
|
|
13969
|
-
const
|
|
13970
|
-
const
|
|
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
|
-
);
|
|
14087
|
-
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]);
|
|
13550
|
+
const surfaceRef = React.useRef(null);
|
|
13551
|
+
const hasAgent = agentPanel != null;
|
|
14187
13552
|
React.useEffect(() => {
|
|
14188
|
-
if (!isOpen) return void 0;
|
|
14189
|
-
const
|
|
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) => {
|
|
13553
|
+
if (!isOpen || hasAgent) return void 0;
|
|
13554
|
+
const frame = requestAnimationFrame(() => {
|
|
14325
13555
|
var _a2, _b2;
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
|
|
14329
|
-
|
|
14330
|
-
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
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;
|
|
13556
|
+
(_b2 = (_a2 = surfaceRef.current) == null ? void 0 : _a2.querySelector("textarea, input")) == null ? void 0 : _b2.focus();
|
|
13557
|
+
});
|
|
13558
|
+
return () => cancelAnimationFrame(frame);
|
|
13559
|
+
}, [isOpen, hasAgent]);
|
|
13560
|
+
const placeholder = (_a = copy.extended_search_textbox_desktop) != null ? _a : "Search";
|
|
13561
|
+
const ariaLabel = (_b = copy.extended_search_box_aria_label) != null ? _b : placeholder;
|
|
13562
|
+
const hasQuery = input.value.trim() !== "";
|
|
13563
|
+
const hasRecentSearches = ((_c = recentSearches == null ? void 0 : recentSearches.items.length) != null ? _c : 0) > 0;
|
|
14398
13564
|
const searchInput = /* @__PURE__ */ jsxRuntime.jsx(
|
|
14399
13565
|
SearchMessageInput,
|
|
14400
13566
|
{
|
|
14401
13567
|
inputLabel: ariaLabel,
|
|
14402
|
-
onChange:
|
|
14403
|
-
onSubmit:
|
|
13568
|
+
onChange: input.onChange,
|
|
13569
|
+
onSubmit: input.onSubmit,
|
|
14404
13570
|
placeholder,
|
|
14405
13571
|
submitLabel: placeholder,
|
|
14406
|
-
value:
|
|
13572
|
+
value: input.value,
|
|
14407
13573
|
clearOnSubmit: false,
|
|
14408
|
-
"data-testid": "search-modal-input"
|
|
14409
|
-
...voiceSearchProps()
|
|
13574
|
+
"data-testid": "search-modal-input"
|
|
14410
13575
|
}
|
|
14411
13576
|
);
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
|
|
14421
|
-
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
|
|
14427
|
-
|
|
14428
|
-
|
|
14429
|
-
|
|
14430
|
-
|
|
14431
|
-
|
|
14432
|
-
|
|
14433
|
-
|
|
14434
|
-
|
|
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,
|
|
13577
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13578
|
+
material.Modal,
|
|
13579
|
+
{
|
|
13580
|
+
open: isOpen,
|
|
13581
|
+
onClose,
|
|
13582
|
+
style: { zIndex: SEARCH_MODAL_Z_INDEX },
|
|
13583
|
+
slots: { backdrop: SearchModalBackdrop },
|
|
13584
|
+
slotProps: { backdrop: BACKDROP_PROPS },
|
|
13585
|
+
"data-testid": "search-modal-overlay",
|
|
13586
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(SearchModalSurface, { ref: surfaceRef, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13587
|
+
SearchPanel,
|
|
13588
|
+
{
|
|
13589
|
+
role: "dialog",
|
|
13590
|
+
"aria-modal": "true",
|
|
13591
|
+
"aria-label": ariaLabel,
|
|
13592
|
+
closeLabel: cancelLabel,
|
|
13593
|
+
onClose,
|
|
13594
|
+
logoSlot: logo,
|
|
13595
|
+
agentMode: hasAgent,
|
|
13596
|
+
inputSlot: hasAgent ? void 0 : searchInput,
|
|
13597
|
+
children: agentPanel != null ? agentPanel : /* @__PURE__ */ jsxRuntime.jsxs(SearchSuggestionsPanel, { "data-testid": "autocomplete-suggestions-panel", children: [
|
|
13598
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13599
|
+
SearchSuggestions,
|
|
14458
13600
|
{
|
|
13601
|
+
...suggestions,
|
|
14459
13602
|
listboxId,
|
|
14460
13603
|
ariaLabel,
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
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
|
|
13604
|
+
didYouMeanText: (_d = copy.did_you_mean_text) != null ? _d : "Did You Mean?",
|
|
13605
|
+
noSuggestionsText: (_e = copy.no_suggestions_text) != null ? _e : "No suggestions",
|
|
13606
|
+
seeMoreText: (_f = copy.see_more_results_text) != null ? _f : "See More Results",
|
|
13607
|
+
fallbackImageUrl
|
|
13608
|
+
}
|
|
13609
|
+
),
|
|
13610
|
+
!hasQuery && recentSearches && hasRecentSearches && /* @__PURE__ */ jsxRuntime.jsx(
|
|
13611
|
+
RecentSearches,
|
|
13612
|
+
{
|
|
13613
|
+
...recentSearches,
|
|
13614
|
+
title: (_g = copy.recent_searches_label) != null ? _g : "Recent searches",
|
|
13615
|
+
clearLabel: (_h = copy.clear_all_label) != null ? _h : "Clear all"
|
|
14488
13616
|
}
|
|
14489
13617
|
)
|
|
14490
|
-
}
|
|
14491
|
-
|
|
14492
|
-
}
|
|
14493
|
-
|
|
14494
|
-
document.body
|
|
13618
|
+
] })
|
|
13619
|
+
}
|
|
13620
|
+
) })
|
|
13621
|
+
}
|
|
14495
13622
|
);
|
|
14496
13623
|
}
|
|
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
13624
|
/*! Bundled license information:
|
|
14572
13625
|
|
|
14573
13626
|
is-buffer/index.js:
|
|
@@ -14607,22 +13660,13 @@ react-is/cjs/react-is.development.js:
|
|
|
14607
13660
|
*)
|
|
14608
13661
|
*/
|
|
14609
13662
|
|
|
14610
|
-
Object.defineProperty(exports, "createSearchService", {
|
|
14611
|
-
enumerable: true,
|
|
14612
|
-
get: function () { return reactSearchSdk.createSearchService; }
|
|
14613
|
-
});
|
|
14614
|
-
exports.ChatLoading = ChatLoading;
|
|
14615
13663
|
exports.SEARCH_MESSAGE_SENDERS = SEARCH_MESSAGE_SENDERS;
|
|
14616
|
-
exports.SearchChatResult = SearchChatResult;
|
|
14617
13664
|
exports.SearchMessage = SearchMessage;
|
|
14618
13665
|
exports.SearchMessageInput = SearchMessageInput;
|
|
14619
13666
|
exports.SearchModal = SearchModal;
|
|
14620
13667
|
exports.SearchPanel = SearchPanel;
|
|
14621
13668
|
exports.SeeMoreLink = SeeMoreLink;
|
|
14622
13669
|
exports.SuggestionRow = SuggestionRow2;
|
|
14623
|
-
exports.callAICommerceChat = callAICommerceChat;
|
|
14624
|
-
exports.fetchAIChatHeaderContent = fetchAIChatHeaderContent;
|
|
14625
13670
|
exports.getSuggestionDisplayData = getSuggestionDisplayData;
|
|
14626
|
-
exports.useAIChatHeaderContent = useAIChatHeaderContent;
|
|
14627
13671
|
//# sourceMappingURL=index.js.map
|
|
14628
13672
|
//# sourceMappingURL=index.js.map
|