@magicx-eng/ai-autocomplete-react 0.33.5 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/index.d.mts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -506,6 +506,32 @@ const { customFields } = useAIAutocomplete({ ... });
|
|
|
506
506
|
news", not an empty catalog. The strip clears on such a response rather than
|
|
507
507
|
keeping an older query's items.
|
|
508
508
|
|
|
509
|
+
#### Change product cards before display
|
|
510
|
+
|
|
511
|
+
- `mapProducts(products, items)` synchronously returns the cards to show.
|
|
512
|
+
- The SDK calls it once per response with its default cards and their matched items in the same order.
|
|
513
|
+
- The returned array becomes the product state and the displayed strip.
|
|
514
|
+
- A thrown error or a non-array result keeps the default cards. A thrown error warns once per instance.
|
|
515
|
+
- `refreshProducts()` maps the current items again without a request. Call it when your own data arrives.
|
|
516
|
+
- Both APIs leave a custom `products` integration unchanged.
|
|
517
|
+
|
|
518
|
+
```tsx
|
|
519
|
+
const { actions } = useAIAutocomplete({
|
|
520
|
+
mapProducts: (products, items) =>
|
|
521
|
+
products.map((product, index) => ({
|
|
522
|
+
...product,
|
|
523
|
+
price: shopperPrices[items[index].source_id] ?? "",
|
|
524
|
+
})),
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
// After updating shopperPrices:
|
|
528
|
+
actions.refreshProducts();
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
- `<AIAutocomplete mapProducts={mapProducts} />` accepts the same callback.
|
|
532
|
+
- Call `ref.current?.refreshProducts()` through the component's imperative handle.
|
|
533
|
+
- Inline callbacks do not trigger repeated mapping on each render. A refresh uses the latest callback.
|
|
534
|
+
|
|
509
535
|
#### Your own product search (`products`)
|
|
510
536
|
|
|
511
537
|
To source the cards from your own search instead — a platform with its own
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutocompleteResult, OptionOverrides, APIConfig, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, Suggestion, SuggestionOption, FormatType, DateMonthView, DateRange, SkippedParamState, IdentifiedParamState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
1
|
+
import { AutocompleteResult, OptionOverrides, APIConfig, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, MatchedItem, Suggestion, SuggestionOption, FormatType, DateMonthView, DateRange, SkippedParamState, IdentifiedParamState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
2
|
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, DateMonthView, DateRange, ExpressedFilter, FilterOp, FormatType, IdentifiedParam, IdentifiedParamState, MatchedItem, MatchedItems, OptionOverrides, PRODUCT_PATH_PREFIX, Product, ProductImageFallback, ProductsConfig, ProductsLayout, Segment, SkippedParamState, SubmitResultExtras, Suggestion, SuggestionOption, TaskKind, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSources, optionImageSrc, optionLabel, parseDate, parseLooseDate, parseLooseDateRange, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode, KeyboardEvent, ChangeEvent } from 'react';
|
|
@@ -8,6 +8,12 @@ interface AIAutocompleteHandle {
|
|
|
8
8
|
focus: () => void;
|
|
9
9
|
blur: () => void;
|
|
10
10
|
reset: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Runs mapProducts synchronously on the shown items again without a request.
|
|
13
|
+
* Keeps the same cards while updating their content.
|
|
14
|
+
* Does nothing without mapProducts or with a custom products integration.
|
|
15
|
+
*/
|
|
16
|
+
refreshProducts: () => void;
|
|
11
17
|
setMode: (mode: AppearanceMode) => void;
|
|
12
18
|
/**
|
|
13
19
|
* Skip the active pill — same action as the dropdown's skip button / →.
|
|
@@ -149,6 +155,13 @@ interface AIAutocompleteProps {
|
|
|
149
155
|
* the config restores the server's items at once.
|
|
150
156
|
*/
|
|
151
157
|
products?: ProductsConfig;
|
|
158
|
+
/**
|
|
159
|
+
* Runs synchronously with the SDK's cards and their response items in the same order.
|
|
160
|
+
* The product strip shows the returned array.
|
|
161
|
+
* Does not apply to a custom products integration.
|
|
162
|
+
* A throw or a result that is not an array keeps the SDK's cards.
|
|
163
|
+
*/
|
|
164
|
+
mapProducts?: (products: Product[], items: MatchedItem[]) => Product[];
|
|
152
165
|
/**
|
|
153
166
|
* Called when the user activates a product card. The SDK does not navigate —
|
|
154
167
|
* you decide what a selection means. Modifier / middle clicks are left to the
|
|
@@ -293,6 +306,13 @@ interface UseAIAutocompleteOptions {
|
|
|
293
306
|
* the config restores the server's items at once.
|
|
294
307
|
*/
|
|
295
308
|
products?: ProductsConfig;
|
|
309
|
+
/**
|
|
310
|
+
* Runs synchronously with the SDK's cards and their response items in the same order.
|
|
311
|
+
* The product strip shows the returned array.
|
|
312
|
+
* Does not apply to a custom products integration.
|
|
313
|
+
* A throw or a result that is not an array keeps the SDK's cards.
|
|
314
|
+
*/
|
|
315
|
+
mapProducts?: (products: Product[], items: MatchedItem[]) => Product[];
|
|
296
316
|
/**
|
|
297
317
|
* Called when the user activates a product card. The SDK does not navigate —
|
|
298
318
|
* you decide what a selection means. Modifier / middle clicks are left to the
|
|
@@ -339,6 +359,12 @@ interface UseAIAutocompleteReturn {
|
|
|
339
359
|
skipActivePill: () => void;
|
|
340
360
|
removeLastParam: () => void;
|
|
341
361
|
reset: () => void;
|
|
362
|
+
/**
|
|
363
|
+
* Runs mapProducts synchronously on the shown items again without a request.
|
|
364
|
+
* Keeps the same cards while updating their content.
|
|
365
|
+
* Does nothing without mapProducts or with a custom products integration.
|
|
366
|
+
*/
|
|
367
|
+
refreshProducts: () => void;
|
|
342
368
|
/**
|
|
343
369
|
* Records a submit in telemetry. Enter is recorded by the SDK; call this
|
|
344
370
|
* from a submit button you render, so each submit is counted once.
|
|
@@ -567,6 +593,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
|
|
|
567
593
|
|
|
568
594
|
declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, onUnhighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, showOptionIcons, showOptionImages, showOptionCounts, skipDisabled, activeSelected, isLoading, skeletonExiting, isInputEmpty, language, products, onProductSelect, onProductFocusChange, productsLayout, productImageFallback, formatType, dateView, selectedDateIso, selectedDateRange, dateRangeStart, onPreviousMonth, onNextMonth, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
569
595
|
|
|
570
|
-
declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showOptionIcons, showOptionImages, showOptionCounts, showSkipButton, showProducts, productImageFallback, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, onProductSelect, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
596
|
+
declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showOptionIcons, showOptionImages, showOptionCounts, showSkipButton, showProducts, productImageFallback, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, mapProducts, onProductSelect, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
571
597
|
|
|
572
598
|
export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutocompleteResult, OptionOverrides, APIConfig, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, Suggestion, SuggestionOption, FormatType, DateMonthView, DateRange, SkippedParamState, IdentifiedParamState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
1
|
+
import { AutocompleteResult, OptionOverrides, APIConfig, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, MatchedItem, Suggestion, SuggestionOption, FormatType, DateMonthView, DateRange, SkippedParamState, IdentifiedParamState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
2
|
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, DateMonthView, DateRange, ExpressedFilter, FilterOp, FormatType, IdentifiedParam, IdentifiedParamState, MatchedItem, MatchedItems, OptionOverrides, PRODUCT_PATH_PREFIX, Product, ProductImageFallback, ProductsConfig, ProductsLayout, Segment, SkippedParamState, SubmitResultExtras, Suggestion, SuggestionOption, TaskKind, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSources, optionImageSrc, optionLabel, parseDate, parseLooseDate, parseLooseDateRange, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode, KeyboardEvent, ChangeEvent } from 'react';
|
|
@@ -8,6 +8,12 @@ interface AIAutocompleteHandle {
|
|
|
8
8
|
focus: () => void;
|
|
9
9
|
blur: () => void;
|
|
10
10
|
reset: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Runs mapProducts synchronously on the shown items again without a request.
|
|
13
|
+
* Keeps the same cards while updating their content.
|
|
14
|
+
* Does nothing without mapProducts or with a custom products integration.
|
|
15
|
+
*/
|
|
16
|
+
refreshProducts: () => void;
|
|
11
17
|
setMode: (mode: AppearanceMode) => void;
|
|
12
18
|
/**
|
|
13
19
|
* Skip the active pill — same action as the dropdown's skip button / →.
|
|
@@ -149,6 +155,13 @@ interface AIAutocompleteProps {
|
|
|
149
155
|
* the config restores the server's items at once.
|
|
150
156
|
*/
|
|
151
157
|
products?: ProductsConfig;
|
|
158
|
+
/**
|
|
159
|
+
* Runs synchronously with the SDK's cards and their response items in the same order.
|
|
160
|
+
* The product strip shows the returned array.
|
|
161
|
+
* Does not apply to a custom products integration.
|
|
162
|
+
* A throw or a result that is not an array keeps the SDK's cards.
|
|
163
|
+
*/
|
|
164
|
+
mapProducts?: (products: Product[], items: MatchedItem[]) => Product[];
|
|
152
165
|
/**
|
|
153
166
|
* Called when the user activates a product card. The SDK does not navigate —
|
|
154
167
|
* you decide what a selection means. Modifier / middle clicks are left to the
|
|
@@ -293,6 +306,13 @@ interface UseAIAutocompleteOptions {
|
|
|
293
306
|
* the config restores the server's items at once.
|
|
294
307
|
*/
|
|
295
308
|
products?: ProductsConfig;
|
|
309
|
+
/**
|
|
310
|
+
* Runs synchronously with the SDK's cards and their response items in the same order.
|
|
311
|
+
* The product strip shows the returned array.
|
|
312
|
+
* Does not apply to a custom products integration.
|
|
313
|
+
* A throw or a result that is not an array keeps the SDK's cards.
|
|
314
|
+
*/
|
|
315
|
+
mapProducts?: (products: Product[], items: MatchedItem[]) => Product[];
|
|
296
316
|
/**
|
|
297
317
|
* Called when the user activates a product card. The SDK does not navigate —
|
|
298
318
|
* you decide what a selection means. Modifier / middle clicks are left to the
|
|
@@ -339,6 +359,12 @@ interface UseAIAutocompleteReturn {
|
|
|
339
359
|
skipActivePill: () => void;
|
|
340
360
|
removeLastParam: () => void;
|
|
341
361
|
reset: () => void;
|
|
362
|
+
/**
|
|
363
|
+
* Runs mapProducts synchronously on the shown items again without a request.
|
|
364
|
+
* Keeps the same cards while updating their content.
|
|
365
|
+
* Does nothing without mapProducts or with a custom products integration.
|
|
366
|
+
*/
|
|
367
|
+
refreshProducts: () => void;
|
|
342
368
|
/**
|
|
343
369
|
* Records a submit in telemetry. Enter is recorded by the SDK; call this
|
|
344
370
|
* from a submit button you render, so each submit is counted once.
|
|
@@ -567,6 +593,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
|
|
|
567
593
|
|
|
568
594
|
declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, onUnhighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, showOptionIcons, showOptionImages, showOptionCounts, skipDisabled, activeSelected, isLoading, skeletonExiting, isInputEmpty, language, products, onProductSelect, onProductFocusChange, productsLayout, productImageFallback, formatType, dateView, selectedDateIso, selectedDateRange, dateRangeStart, onPreviousMonth, onNextMonth, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
569
595
|
|
|
570
|
-
declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showOptionIcons, showOptionImages, showOptionCounts, showSkipButton, showProducts, productImageFallback, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, onProductSelect, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
596
|
+
declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showOptionIcons, showOptionImages, showOptionCounts, showSkipButton, showProducts, productImageFallback, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, mapProducts, onProductSelect, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
571
597
|
|
|
572
598
|
export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var gt=Object.defineProperty;var oa=Object.getOwnPropertyDescriptor;var na=Object.getOwnPropertyNames;var ra=Object.prototype.hasOwnProperty;var sa=(e,a)=>{for(var t in a)gt(e,t,{get:a[t],enumerable:!0})},la=(e,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of na(a))!ra.call(e,i)&&i!==t&>(e,i,{get:()=>a[i],enumerable:!(n=oa(a,i))||n.enumerable});return e};var da=e=>la(gt({},"__esModule",{value:!0}),e);var Ca={};sa(Ca,{AIAutocomplete:()=>Zt,AIAutocompleteDropdown:()=>st,DATE_RANGE_META_END:()=>s.DATE_RANGE_META_END,DATE_RANGE_META_START:()=>s.DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT:()=>s.DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX:()=>s.PRODUCT_PATH_PREFIX,WEEKDAY_LABELS:()=>s.WEEKDAY_LABELS,buildSubmitResult:()=>s.buildSubmitResult,cellDay:()=>s.cellDay,cellIso:()=>s.cellIso,dateCellMarks:()=>s.dateCellMarks,formatDate:()=>s.formatDate,formatDateRange:()=>s.formatDateRange,formatOptionCount:()=>s.formatOptionCount,isoDate:()=>s.isoDate,monthLabel:()=>s.monthLabel,optionCountLabel:()=>s.optionCountLabel,optionHasImage:()=>s.optionHasImage,optionImageSources:()=>s.optionImageSources,optionImageSrc:()=>s.optionImageSrc,optionLabel:()=>s.optionLabel,parseDate:()=>s.parseDate,parseLooseDate:()=>s.parseLooseDate,parseLooseDateRange:()=>s.parseLooseDateRange,productFromMatchedItem:()=>s.productFromMatchedItem,productImageSources:()=>s.productImageSources,productsFromCustomFields:()=>s.productsFromCustomFields,sanitizeOptionIconSvg:()=>s.sanitizeOptionIconSvg,selectedRangeFor:()=>s.selectedRangeFor,useAIAutocomplete:()=>dt,visibleDateRange:()=>s.visibleDateRange,withSkippedParams:()=>s.withSkippedParams});module.exports=da(Ca);var s=require("@magicx-eng/ai-autocomplete-vanilla");var N=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-container-KKjFU {
|
|
2
2
|
position: relative;
|
|
3
3
|
/* Inherits the host page's font by default. Consumers can pin a specific
|
|
4
4
|
font on the library via \`--aia-font-family: 'Custom Font'\` without
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
opacity: 0;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
`,document.head.appendChild(e)}var
|
|
265
|
+
`,document.head.appendChild(e)}var We={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};var ze=require("@magicx-eng/ai-autocomplete-vanilla"),ie=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
266
266
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
267
267
|
* Consumer CSS always wins without !important.
|
|
268
268
|
*
|
|
@@ -1045,7 +1045,7 @@
|
|
|
1045
1045
|
opacity: 0.25;
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
|
-
`,document.head.appendChild(e)}var
|
|
1048
|
+
`,document.head.appendChild(e)}var xe={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};var M=require("@magicx-eng/ai-autocomplete-vanilla"),Tt=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
|
|
1049
1049
|
|
|
1050
1050
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1051
1051
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1208,7 +1208,7 @@
|
|
|
1208
1208
|
opacity: 0.8;
|
|
1209
1209
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1210
1210
|
}
|
|
1211
|
-
`,document.head.appendChild(e)}var
|
|
1211
|
+
`,document.head.appendChild(e)}var z={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};var $=require("react/jsx-runtime"),ca=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function At({options:e,activeIndex:a,listboxId:t,view:n,selection:i,onSelect:r,onHighlight:o,onUnhighlight:p,onPreviousMonth:c,onNextMonth:k}){let S=(0,M.isoDate)(new Date),I=(0,M.visibleDateRange)({pendingStart:i.rangeStart,highlightedIso:(0,M.cellIso)(e[a]),selected:i.selectedRange});return(0,$.jsxs)("div",{className:z.datepicker,"data-aia-datepicker":"",children:[(0,$.jsxs)("div",{className:z.header,children:[(0,$.jsx)("button",{type:"button",tabIndex:-1,className:z.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:c,children:"\u2039"}),(0,$.jsx)("span",{className:z.month,"data-aia-date-month":"","aria-live":"polite",children:(0,M.monthLabel)(n)}),(0,$.jsx)("button",{type:"button",tabIndex:-1,className:z.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:k,children:"\u203A"})]}),(0,$.jsx)("div",{className:z.weekdays,"aria-hidden":"true",children:M.WEEKDAY_LABELS.map((m,b)=>(0,$.jsx)("span",{className:z.weekday,children:m},ca[b]))}),(0,$.jsx)("div",{className:z.grid,"data-aia-date-grid":"",children:e.map((m,b)=>(0,$.jsx)(pa,{option:m,id:`${t}-option-${b}`,index:b,isHighlighted:b===a&&m.is_tappable,isToday:(0,M.cellIso)(m)===S,isPast:(0,M.cellIso)(m)!=null&&(0,M.cellIso)(m)<S,marks:(0,M.dateCellMarks)((0,M.cellIso)(m),{selectedIso:i.selectedIso,range:I}),onSelect:r,onHighlight:o,onUnhighlight:p},(0,M.cellIso)(m)??`pad-${b}`))})]})}function pa({option:e,id:a,index:t,isHighlighted:n,isToday:i,isPast:r,marks:o,onSelect:p,onHighlight:c,onUnhighlight:k}){let[S,I]=(0,Tt.useState)(!1),m=(0,M.cellDay)(e);if(m==null)return(0,$.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${z.cell} ${z.blank}`});let b=()=>{I(!0),p(e),setTimeout(()=>I(!1),170)},A=[z.cell,z.day,r?z.past:"",n?z.highlighted:"",i?z.today:"",o.inRange?z.inRange:"",o.selected?z.selected:"",S?z.pressed:""].filter(Boolean).join(" ");return(0,$.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:A,onClick:b,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),b())},onMouseEnter:()=>c(t),onMouseLeave:k?()=>k(t):void 0,children:(0,$.jsx)("span",{className:z.number,children:m})})}var De=require("@magicx-eng/ai-autocomplete-vanilla"),ot=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
|
|
1212
1212
|
display: flex;
|
|
1213
1213
|
flex-wrap: wrap;
|
|
1214
1214
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1248,7 +1248,7 @@
|
|
|
1248
1248
|
.aia-cluster[data-justify="around"] {
|
|
1249
1249
|
justify-content: space-around;
|
|
1250
1250
|
}
|
|
1251
|
-
`,document.head.appendChild(e)}var
|
|
1251
|
+
`,document.head.appendChild(e)}var ft=require("react/jsx-runtime");function $e({gap:e,align:a="center",justify:t="start",noWrap:n=!1,inline:i=!1,className:r,children:o,...p}){let c=e?{"--aia-cluster-gap":e}:void 0,k={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":n||void 0,"data-inline":i||void 0,style:c,...p};return i?(0,ft.jsx)("span",{...k,children:o}):(0,ft.jsx)("div",{...k,children:o})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
|
|
1252
1252
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1253
1253
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1254
1254
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1395,7 +1395,7 @@
|
|
|
1395
1395
|
justify-content: flex-end;
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
|
-
`,document.head.appendChild(e)}var
|
|
1398
|
+
`,document.head.appendChild(e)}var ye={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};var pe=require("react/jsx-runtime");function Rt({isOptionHighlighted:e=!1,isInputEmpty:a=!1,strings:t=(0,De.uiStringsFor)()}){let{key:n,hint:i}=(0,De.getFooterHint)(e,a,t),[r,o]=(0,ot.useState)(De.ATTRIBUTION_URL);return(0,ot.useEffect)(()=>{o((0,De.buildAttributionUrl)())},[]),(0,pe.jsx)("footer",{className:ye.footer,"data-aia-footer":"",children:(0,pe.jsxs)($e,{justify:"between",noWrap:!0,className:ye.row,children:[(0,pe.jsxs)($e,{gap:"5px",className:ye.hintGroup,children:[(0,pe.jsx)("kbd",{className:ye.key,children:n}),(0,pe.jsx)("span",{className:ye.hint,children:i})]}),(0,pe.jsxs)("a",{className:ye.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[(0,pe.jsx)("span",{className:ye.brand,children:"AI"}),(0,pe.jsx)("span",{className:ye.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
|
|
1399
1399
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1400
1400
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1401
1401
|
as it was when the outline was dashed. */
|
|
@@ -1471,7 +1471,7 @@
|
|
|
1471
1471
|
opacity: 0;
|
|
1472
1472
|
}
|
|
1473
1473
|
}
|
|
1474
|
-
`,document.head.appendChild(e)}var Le={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};var
|
|
1474
|
+
`,document.head.appendChild(e)}var Le={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};var Dt=require("react/jsx-runtime"),bt={selected:1,first:.7,next:.4,last:.2};function Ot({label:e,state:a,rounded:t,loading:n,onClick:i}){let r=[Le.pill,t?Le.rounded:"",n?Le.skeleton:""].filter(Boolean).join(" ");return(0,Dt.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:bt[a]},onMouseDown:o=>o.preventDefault(),onClick:n?void 0:i,disabled:n,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
|
|
1475
1475
|
position: relative;
|
|
1476
1476
|
z-index: 1;
|
|
1477
1477
|
pointer-events: auto;
|
|
@@ -1481,7 +1481,7 @@
|
|
|
1481
1481
|
align-items: center;
|
|
1482
1482
|
vertical-align: middle;
|
|
1483
1483
|
}
|
|
1484
|
-
`,document.head.appendChild(e)}var
|
|
1484
|
+
`,document.head.appendChild(e)}var vt={list:"aia-list-qvLqO"};var Ve=require("react/jsx-runtime"),ha=[125,69];function Lt(e){return e===0?"first":e===1?"next":"last"}function nt({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:n,rounded:i,loading:r}){return r&&e.length===0?(0,Ve.jsx)("span",{className:vt.list,"data-aia-pill-list-loading":"",children:ha.map((o,p)=>(0,Ve.jsx)("span",{"data-aia-pill-skeleton":"",className:`${Le.pill} ${i?Le.rounded:""} ${Le.skeleton}`,style:{width:o,opacity:bt[Lt(p)]}},`skel-${o}`))}):(0,Ve.jsx)("span",{className:vt.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((o,p)=>{let c=!!n&&p===a;return(0,Ve.jsx)(Ot,{label:o.text,state:c?"selected":Lt(p),selected:c,rounded:i,loading:r,onClick:()=>t(p)},`${o.parameter}-${o.text}`)})})}var he=require("@magicx-eng/ai-autocomplete-vanilla"),Ue=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-fef1688d")){let e=document.createElement("style");e.id="ac-style-fef1688d",e.textContent=`/* Product strip \u2014 the React counterpart of the vanilla core's strip rules
|
|
1485
1485
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1486
1486
|
theming one package sees the same result in the other.
|
|
1487
1487
|
|
|
@@ -1765,7 +1765,7 @@
|
|
|
1765
1765
|
letter-spacing: 0.02em;
|
|
1766
1766
|
text-align: center;
|
|
1767
1767
|
}
|
|
1768
|
-
`,document.head.appendChild(e)}var
|
|
1768
|
+
`,document.head.appendChild(e)}var ae={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",badge:"aia-badge-j9Hcd"};var Q=require("react/jsx-runtime");function zt({products:e,listboxId:a,onSelect:t,onFocusChange:n,focusable:i=!0,layout:r="row",imageFallback:o="image",strings:p=(0,he.uiStringsFor)()}){let c=e.length>0,k=(0,Ue.useRef)(null);if((0,Ue.useEffect)(()=>{let I=k.current;if(!(!c||!I))return(0,he.attachProductRowWheel)(I)},[c]),!c)return null;let S=`${a}-products-label`;return(0,Q.jsxs)("section",{className:ae.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":S,children:[(0,Q.jsx)("div",{className:ae.label,id:S,"data-aia-products-label":"",children:p.products}),(0,Q.jsx)("div",{ref:k,className:ae.row,"data-aia-products-row":"",children:e.map((I,m)=>(0,Q.jsx)(ua,{product:I,id:`${a}-product-${m}`,onSelect:t,onFocusChange:n,focusable:i,imageFallback:o,soldOut:p.soldOut},I.id))})]})}function ua({product:e,id:a,onSelect:t,onFocusChange:n,focusable:i,imageFallback:r,soldOut:o}){let p=c=>{c.metaKey||c.ctrlKey||c.shiftKey||c.altKey||c.button!==0||(c.preventDefault(),t(e))};return(0,Q.jsxs)("a",{id:a,className:ae.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:i?0:-1,onClick:p,onKeyDown:c=>{c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),t(e))},onFocus:()=>n?.(!0),onBlur:c=>{c.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[(0,Q.jsx)(ma,{sources:(0,he.productImageSources)(e.imageUrl),title:e.title,fallback:r},(0,he.productImageSrc)(e.imageUrl)??""),(0,Q.jsxs)("span",{className:ae.body,children:[e.vendor?(0,Q.jsx)("span",{className:ae.vendor,children:e.vendor}):null,(0,Q.jsx)("span",{className:ae.title,children:e.title}),e.price?(0,Q.jsx)("span",{className:ae.price,children:e.price}):null,e.available===!1?(0,Q.jsx)("span",{className:ae.badge,children:o}):null]})]})}function ma({sources:e,title:a,fallback:t}){let[n,i]=(0,Ue.useState)(0),r=e[n],o=!!r,p=!o&&t==="initial";return(0,Q.jsxs)("span",{className:ae.media,"aria-hidden":"true","data-aia-product-placeholder":!o&&!p?"":void 0,"data-aia-product-initial":p?"":void 0,children:[o?(0,Q.jsx)("img",{className:ae.image,src:r,alt:"",loading:"lazy",decoding:"async",onError:()=>i(c=>c+1)}):null,p?(0,he.productInitial)(a):null]})}var Y=require("@magicx-eng/ai-autocomplete-vanilla"),fe=require("react");var Mt=require("@magicx-eng/ai-autocomplete-vanilla"),rt=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
|
|
1769
1769
|
display: grid;
|
|
1770
1770
|
grid-template-columns: repeat(
|
|
1771
1771
|
auto-fit,
|
|
@@ -1801,7 +1801,7 @@
|
|
|
1801
1801
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
1802
1802
|
display: none;
|
|
1803
1803
|
}
|
|
1804
|
-
`,document.head.appendChild(e)}var
|
|
1804
|
+
`,document.head.appendChild(e)}var Bt=require("react/jsx-runtime");function Nt({min:e="16rem",max:a,gap:t,scroll:n=!1,maxHeight:i,scrollResetKey:r,cols:o,template:p,innerRef:c,className:k,children:S,...I}){let m=(0,rt.useRef)(null);(0,rt.useLayoutEffect)(()=>{if(r===void 0)return;let A=m.current;A&&(A.scrollTop=0)},[r]);let b={"--aia-grid-min":e};return a&&(b["--aia-grid-max"]=a),t&&(b["--aia-grid-gap"]=t),i&&(b["--aia-grid-max-height"]=i),o&&(b.gridTemplateColumns=(0,Mt.optionsGridTemplateColumns)(o)),p&&(b.gridTemplateColumns=p),(0,Bt.jsx)("div",{ref:A=>{m.current=A,c?.(A)},className:k?`aia-grid ${k}`:"aia-grid","data-scroll":n||void 0,style:b,...I,children:S})}var ge=require("@magicx-eng/ai-autocomplete-vanilla"),me=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
|
|
1805
1805
|
position: relative;
|
|
1806
1806
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1807
1807
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2198,7 +2198,7 @@
|
|
|
2198
2198
|
opacity: 0;
|
|
2199
2199
|
}
|
|
2200
2200
|
}
|
|
2201
|
-
`,document.head.appendChild(e)}var
|
|
2201
|
+
`,document.head.appendChild(e)}var ee={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",skeletonBarIn:"aia-skeletonBarIn-ZlEM0",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};var ue=require("react/jsx-runtime");function Ht({option:e,isHighlighted:a,onSelect:t,onHighlight:n,onUnhighlight:i,id:r,loading:o,showIcon:p=!0,showImage:c=!0,showCount:k=!0,scrollHint:S,enterDelayMs:I=0}){let[m]=(0,me.useState)(I),[b,A]=(0,me.useState)(!1),B=c?(0,ge.optionImageSources)(e.image_url):[],H=B[0]??null,[j,R]=(0,me.useState)([]),T=B.find(W=>!j.includes(W))??null,F=(0,me.useMemo)(()=>!H&&p&&e.icon_svg?(0,ge.sanitizeOptionIconSvg)(e.icon_svg):null,[H,p,e.icon_svg]),K=k?(0,ge.formatOptionCount)(e.item_count):null,C=(0,me.useRef)(void 0);(0,me.useEffect)(()=>()=>clearTimeout(C.current),[]);let G=()=>{o||!e.is_tappable||b||(A(!0),t(e),clearTimeout(C.current),C.current=setTimeout(()=>A(!1),170))},oe=[ee.item,a&&!o?ee.highlighted:"",e.is_tappable?ee.tappable:ee.nonTappable,b?ee.pressed:"",S?ee.scrollHint:""].filter(Boolean).join(" ");return(0,ue.jsx)("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":o?"":void 0,"data-aia-icon":F&&e.icon?e.icon:void 0,"data-aia-image":H?"":void 0,"data-aia-item-count":K!==null?e.item_count:void 0,"aria-selected":a,className:oe,style:{[ge.OPTION_ENTER_DELAY_VAR]:`${m}ms`},tabIndex:o||!e.is_tappable?-1:0,onClick:G,onKeyDown:W=>{!o&&e.is_tappable&&(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),G())},onMouseEnter:!o&&e.is_tappable?n:void 0,onMouseLeave:i,children:(0,ue.jsxs)("span",{className:ee.content,children:[H&&(0,ue.jsx)("span",{className:`${ee.image} magicx-aia-option-image`,"aria-hidden":"true",children:(0,ue.jsx)("img",{src:T??H,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:T===null,onError:()=>{T!==null&&R(W=>[...W,T])}})}),F&&(0,ue.jsx)("span",{className:`${ee.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:F}}),(0,ue.jsx)("span",{className:ee.text,children:(0,ge.optionLabel)(e)}),e.tag&&(0,ue.jsx)("span",{className:ee.tag,children:e.tag}),K!==null&&(0,ue.jsx)("span",{className:`${ee.count} magicx-aia-option-count`,children:K})]})})}var wt=require("react/jsx-runtime");function ga(){let[e,a]=(0,fe.useState)(Y.isOptionsGridMobileViewport);return(0,fe.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Y.OPTIONS_GRID_MOBILE_QUERY),n=()=>a(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]),e}function Ft({options:e,activeIndex:a,onSelect:t,onHighlight:n,onUnhighlight:i,listboxId:r,loading:o,groupKey:p="",optionsPosition:c="below",showIcons:k=!0,showImages:S=!0,showCounts:I=!0}){let m=ga(),b=(0,fe.useRef)(null),[A,B]=(0,fe.useState)(null),H=(0,fe.useRef)(null);(0,fe.useLayoutEffect)(()=>{if(o&&(0,Y.sameOptionRows)(H.current,e))return;H.current=o?null:e;let R=b.current,F=R&&!o&&(0,Y.needsOptionsGridMeasurement)(e.length,m)?(0,Y.measureOptionsGrid)(R):null;B(F?(0,Y.planOptionsGrid)(e.length,m,F.rowWidths,F.gridWidth):null)},[e,m,o]);let j=A??(0,Y.planOptionsGrid)(e.length,m,null,null);return(0,wt.jsx)(Nt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:p,template:j.template,maxHeight:j.maxHeight,innerRef:R=>{b.current=R},"data-aia-group":p,children:e.map((R,T)=>(0,wt.jsx)(Ht,{option:R,isHighlighted:T===a,onSelect:t,onHighlight:()=>n(T),onUnhighlight:i?()=>i(T):void 0,id:`${r}-option-${T}`,loading:o,showIcon:k,showImage:S,showCount:I,scrollHint:!o&&j.scrollHintIndices.includes(T),enterDelayMs:o?0:(0,Y.optionEnterDelayMs)(T,j.cols,e.length,c)},`${p}\0${R.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
2202
2202
|
display: flex;
|
|
2203
2203
|
flex-direction: column;
|
|
2204
2204
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2213,7 +2213,7 @@
|
|
|
2213
2213
|
align-items: end;
|
|
2214
2214
|
}
|
|
2215
2215
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2216
|
-
`,document.head.appendChild(e)}var
|
|
2216
|
+
`,document.head.appendChild(e)}var Gt=require("react/jsx-runtime");function Kt({space:e,align:a="stretch",className:t,children:n,...i}){let r=e?{"--aia-stack-space":e}:void 0;return(0,Gt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:r,...i,children:n})}var _=require("react/jsx-runtime"),fa=[159,119,164],ba=()=>{},Wt=()=>{};function va(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,n]=(0,ie.useState)(a);if((0,ie.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>n(i.matches);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function wa(e,a){let t=(0,ie.useRef)(null);(0,ie.useEffect)(()=>{let n=e.current,i=a.current;if(!n||!i)return;let r=n.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==r&&(t.current.controller.destroy(),t.current=null),r&&!t.current){t.current={grid:r,controller:(0,ze.attachScrollArrow)({dropdown:n,grid:r,button:i})};return}t.current?.controller.update()}),(0,ie.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function st({suggestions:e,activeIndex:a,onSelect:t,onHighlight:n,onUnhighlight:i,isOpen:r,id:o,className:p,pills:c,onPillClick:k,showPills:S=!0,onSkip:I,showSkipButton:m=!0,showOptionIcons:b=!0,showOptionImages:A=!0,showOptionCounts:B=!0,skipDisabled:H=!1,activeSelected:j=!1,isLoading:R=!1,skeletonExiting:T=!1,isInputEmpty:F=!1,language:K,products:C,onProductSelect:G,onProductFocusChange:oe,productsLayout:W="row",productImageFallback:ke="image",formatType:re="options",dateView:V=null,selectedDateIso:Ne=null,selectedDateRange:Ce=null,dateRangeStart:g=null,onPreviousMonth:Be,onNextMonth:Pe,optionsPosition:be="below",mode:Se}){let ve=va(Se),Ie=ve!==void 0,X=(0,ie.useRef)(null),se=(0,ie.useRef)(null);wa(X,se),(0,ie.useEffect)(()=>{if(X.current)return(0,ze.containScroll)(X.current)},[]);let l=e[0]?.options??[],f=!!(c&&c.length>0&&k),v=!!(C&&C.length>0),w=r&&(l.length>0||S&&f||R||v),x={suggestions:e,activeIndex:a,pills:c,showPills:S,showSkipButton:m,showOptionIcons:b,showOptionImages:A,showOptionCounts:B,skipDisabled:H,activeSelected:j,isLoading:R,skeletonExiting:T,isInputEmpty:F,products:C,formatType:re,dateView:V,selectedDateIso:Ne,selectedDateRange:Ce,dateRangeStart:g},L=(0,ie.useRef)(x);w&&(L.current=x);let h=w?x:L.current,q=(0,ze.uiStringsFor)(K),J=h.suggestions[0],te=J?.options??[],_e=h.activeIndex>=0&&!!te[h.activeIndex]?.is_tappable,le=!!(h.pills&&h.pills.length>0&&k),Ee=h.showPills&&le,He=h.showPills&&!le&&h.isLoading,y=Ee||He,Te=le&&h.showSkipButton&&!h.isInputEmpty&&!!I,Ae=h.pills?.[0]?.text,we=(0,ze.isCalendarFormat)(h.formatType)&&h.dateView!=null,u=te.length>0&&!we,Fe=te.length>0&&we&&!h.isLoading,je=h.isLoading&&!u&&!Fe,Re=h.products??[];return(0,_.jsxs)("div",{ref:X,id:o,role:"listbox","data-aia-dropdown":"","data-options-position":be,"data-mode":ve,"data-aia-loading":h.isLoading?"":void 0,"data-aia-skeleton-exiting":h.skeletonExiting?"":void 0,"data-aia-has-products":Re.length>0?"":void 0,className:`${Ie?"magicx-aia ":""}${xe.dropdown} ${w?xe.visible:""} ${p??""}`,onMouseDown:de=>de.preventDefault(),children:[(0,_.jsxs)(Kt,{space:"8px",children:[(y||Te)&&(0,_.jsxs)($e,{noWrap:!0,className:xe.pillBar,"data-aia-pillbar":"",children:[y&&(0,_.jsx)("span",{className:xe.pillScroll,"data-aia-pill-scroll":"",children:(0,_.jsx)(nt,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:k??(()=>{}),rounded:!0,loading:h.isLoading})}),Te&&(0,_.jsx)("button",{type:"button",tabIndex:-1,className:xe.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":Ae?`${q.skipLabel} ${Ae}`:q.skipLabel,onClick:I,children:q.skip})]}),u&&(0,_.jsx)(Ft,{options:te,activeIndex:h.activeIndex,onSelect:t,onHighlight:n,onUnhighlight:i,listboxId:o,loading:h.isLoading,groupKey:J?`${J.parameter} ${J.text}`:"",optionsPosition:be,showIcons:h.showOptionIcons,showImages:h.showOptionImages,showCounts:h.showOptionCounts}),Fe&&h.dateView&&(0,_.jsx)(At,{options:te,activeIndex:h.activeIndex,listboxId:o,view:h.dateView,selection:{selectedIso:h.selectedDateIso??null,selectedRange:h.selectedDateRange??null,rangeStart:h.dateRangeStart??null},onSelect:t,onHighlight:n,onUnhighlight:i,onPreviousMonth:Be??Wt,onNextMonth:Pe??Wt}),je&&(0,_.jsx)("div",{className:xe.skeletonBars,"data-aia-skeleton-bars":"",children:fa.map(de=>(0,_.jsx)("span",{className:xe.skeletonBar,style:{width:de}},`bar-${de}`))}),(0,_.jsx)(zt,{products:Re,listboxId:o,onSelect:G??ba,onFocusChange:oe,focusable:w,layout:W,imageFallback:ke,strings:q}),(0,_.jsx)(Rt,{isOptionHighlighted:_e,isInputEmpty:h.isInputEmpty,strings:q})]}),(0,_.jsx)("button",{ref:se,type:"button",tabIndex:-1,className:xe.scrollArrow,"data-aia-scroll-arrow":"","aria-label":q.scrollArrow,"aria-hidden":"true",children:(0,_.jsx)("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:(0,_.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Me=require("@magicx-eng/ai-autocomplete-vanilla");var Ut=require("@magicx-eng/ai-autocomplete-vanilla");if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.aia-submitButton-otz7H {
|
|
2217
2217
|
flex-shrink: 0;
|
|
2218
2218
|
width: 32px;
|
|
2219
2219
|
height: 32px;
|
|
@@ -2266,5 +2266,5 @@
|
|
|
2266
2266
|
);
|
|
2267
2267
|
cursor: default;
|
|
2268
2268
|
}
|
|
2269
|
-
`,document.head.appendChild(e)}var Ht={submitButton:"aia-submitButton-otz7H"};var ot=require("react/jsx-runtime");function Kt({disabled:e,onClick:a,label:t=(0,Ft.uiStringsFor)().submit}){return(0,ot.jsx)("button",{type:"button","data-aia-submit":"",className:Ht.submitButton,disabled:e,onClick:n=>{n.stopPropagation(),a()},"aria-label":t,children:(0,ot.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:(0,ot.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var We=require("@magicx-eng/ai-autocomplete-vanilla"),E=require("react");var ft=require("react");function Gt(e){let a=(0,ft.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),n=(0,ft.useRef)({key:"",overrides:void 0});if(n.current.key!==t){let i={};for(let r of Object.keys(e??{})){let o=(c,d,x)=>{let P=a.current?.[r];return P?P(c,d,x):[]};i[r]=o}n.current={key:t,overrides:e?i:void 0}}return{overrides:n.current.overrides,key:t}}var bt=require("react");function Wt(e){let a=(0,bt.useRef)(e);a.current=e;let t=(0,bt.useRef)(null);t.current===null&&(t.current={fetch:(i,r)=>{let o=a.current;return o?o.fetch(i,r):Promise.reject(new Error("products config removed"))},transform:i=>a.current?.transform(i)??[],get limit(){return a.current?.limit}});let n=e!==void 0;return{config:n?t.current:void 0,enabled:n}}var va={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function nt({onSubmit:e,onResult:a,onError:t,optionOverrides:n,maskCompletedText:i,apiConfig:r,additionalContext:o,language:c,visitorId:d,columns:x=2,dropdownTrigger:P,optionsPosition:S,closeDropdownOnBlur:g,showNonTappableOptions:v,showOptionIcons:A,showOptionImages:B,showOptionCounts:H,showSkipButton:j,showProducts:R,productImageFallback:T="image",onFocus:F,onBlur:K,value:y,completedParams:G,onChange:re,onParamsChange:W,products:Se,onProductSelect:fe,source:J,setCursor:Ie}){let f=(0,E.useRef)(null),[Ne,Ee]=(0,E.useState)(null),Te=(0,E.useRef)(e);Te.current=e;let be=(0,E.useRef)(a);be.current=a;let Ae=(0,E.useRef)(t);Ae.current=t;let ve=(0,E.useRef)(re);ve.current=re;let le=(0,E.useRef)(W);le.current=W;let ee=(0,E.useRef)(F);ee.current=F;let we=(0,E.useRef)(K);we.current=K;let l=(0,E.useRef)(Ie);l.current=Ie;let m=(0,E.useRef)(fe);m.current=fe;let w=(0,E.useRef)(d);w.current=d;let b=(0,E.useRef)(()=>{let u=w.current;return typeof u=="function"?u():u}).current,k=Wt(Se),L=Gt(n);(0,E.useEffect)(()=>{if(typeof document>"u")return;let u=new We.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:o,language:c,visitorId:b,optionOverrides:L.overrides,maskCompletedText:i,columns:x,dropdownTrigger:P,optionsPosition:S,closeDropdownOnBlur:g,showNonTappableOptions:v,showProducts:R,source:J,value:y,completedParams:G,onSubmit:(...N)=>Te.current?.(...N),onResult:(...N)=>be.current?.(...N),onError:(...N)=>Ae.current?.(...N),onChange:(...N)=>ve.current?.(...N),onParamsChange:(...N)=>le.current?.(...N),onFocus:()=>ee.current?.(),onBlur:()=>we.current?.(),onProductSelect:N=>m.current?.(N),setCursor:N=>l.current?.(N),products:k.config});f.current=u,Ee(u.getState());let ie=u.subscribe(N=>Ee(N));return()=>{ie(),u.destroy(),f.current===u&&(f.current=null)}},[]),(0,E.useEffect)(()=>{y!==void 0&&f.current?.setValue(y)},[y]),(0,E.useEffect)(()=>{G!==void 0&&f.current?.setCompletedParams(G)},[G]);let p=JSON.stringify(r??null),_;try{_=JSON.stringify(o??null)}catch{_="[unstringifiable]"}(0,E.useEffect)(()=>{f.current?.update({apiConfig:r,additionalContext:o,language:c,optionOverrides:L.overrides,dropdownTrigger:P,optionsPosition:S,closeDropdownOnBlur:g,showNonTappableOptions:v,showProducts:R})},[p,_,c,L.key,P,S,g,v,R]);let te=(0,E.useRef)(!1);(0,E.useEffect)(()=>{if(!te.current){te.current=!0;return}f.current?.update({products:k.config})},[k.enabled]);let ae=(0,E.useRef)(null);ae.current===null&&(ae.current={handleTextChange:u=>f.current?.handleTextChange(u),handleKeyDown:u=>{let ie="nativeEvent"in u?u.nativeEvent:u;f.current?.handleKeyDown(ie)},setFocused:u=>f.current?.setFocused(u),startEditingParam:u=>f.current?.startEditingParam(u),exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:u=>f.current?.handleCaretAfterInput(u),handleCaretMove:u=>f.current?.handleCaretMove(u),replaceEditingRange:u=>f.current?.replaceEditingRange(u)??!1,setActivePill:u=>f.current?.setActivePill(u),skipActivePill:()=>f.current?.skipActivePill(),removeLastParam:()=>f.current?.removeLastParam(),clearNewParamId:()=>f.current?.clearNewParamId(),reset:()=>f.current?.reset(),recordSubmit:u=>f.current?.recordSubmit(u),selectOption:u=>f.current?.selectOption(u),selectProduct:u=>f.current?.selectProduct(u),setActiveDropdownIndex:u=>f.current?.setActiveDropdownIndex(u),clearHighlight:u=>f.current?.clearHighlight(u),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let C=ae.current,xe=(0,E.useCallback)(u=>{let ie=u.target.value,lt=ie.length>0&&!u.nativeEvent?.isComposing&&ie[0]!==ie[0].toUpperCase()?ie[0].toUpperCase()+ie.slice(1):ie;f.current?.handleTextChange(lt)},[]),_e=(0,E.useCallback)(u=>{f.current?.handleKeyDown(u.nativeEvent)},[]),Re=f.current,h=Ne??va,ye=y!==void 0?y:h.text,Be=G!==void 0?G:h.completedParams,Oe=h.actionableSuggestions,Fe=Oe[0],ke=Re?.listboxId??"",qe=h.activeDropdownIndex>=0&&Re?`${ke}-option-${h.activeDropdownIndex}`:void 0,$=h.editingParam,V=h.editingIdentified,Ke=$?{parameter:$.suggestionParameter,text:$.suggestionPlaceholder,required:!0,options:$.options}:V?{parameter:V.parameter,text:(0,We.identifiedParamLabel)(V.parameter),required:!0,options:[]}:null,Ze=h.dropdownSuggestion??Ke??Fe,st=Ke?[Ke]:Oe,Ue=(0,We.dateSelectionFor)(h),$e=!Re||h.dropdownLoading;return{completedParams:Be,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:Oe,setActivePill:C.setActivePill,skipActivePill:C.skipActivePill,removeLastParam:C.removeLastParam,segments:h.segments,newParamId:h.newParamId,clearNewParamId:C.clearNewParamId,suggestions:h.suggestions,activeIndex:h.activeDropdownIndex,isReady:h.isReady,isLoading:$e,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:ke,error:h.error,products:h.products,customFields:h.customFields,selectProduct:C.selectProduct,handleTextChange:C.handleTextChange,handleKeyDown:C.handleKeyDown,setFocused:C.setFocused,editingParam:$,editingIdentified:V,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:C.startEditingParam,exitEditMode:C.exitEditMode,handleCaretAfterInput:C.handleCaretAfterInput,handleCaretMove:C.handleCaretMove,replaceEditingRange:C.replaceEditingRange,inputProps:{value:ye,placeholder:h.placeholderText||void 0,onChange:xe,onKeyDown:_e,onFocus:C.handleFocus,onBlur:C.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":qe,"aria-autocomplete":"list","aria-controls":ke},reset:C.reset,recordSubmit:C.recordSubmit,dropdownProps:{suggestions:Ze?[{...Ze,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:C.selectOption,onHighlight:C.setActiveDropdownIndex,onUnhighlight:C.clearHighlight,isOpen:h.isDropdownOpen,id:ke,pills:st,activeSelected:h.isActivePillSelected,onPillClick:C.setActivePill,onSkip:C.skipActivePill,showSkipButton:(j??!0)&&!$&&!V,showOptionIcons:A??!0,showOptionImages:B??!0,showOptionCounts:H??!0,skipDisabled:h.inSelectionAnimation,isLoading:$e,skeletonExiting:h.skeletonExiting,isInputEmpty:ye.trim().length===0,language:c,products:h.products,productImageFallback:T,onProductSelect:C.selectProduct,onProductFocusChange:C.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Ue.selectedIso,selectedDateRange:Ue.selectedRange,dateRangeStart:Ue.rangeStart,onPreviousMonth:C.showPreviousMonth,onNextMonth:C.showNextMonth,optionsPosition:S??"below"}}}var U=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react"),rt;function wa(){if(rt!==void 0)return rt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),rt=e.contentEditable==="plaintext-only",rt}function _t(e){let{segments:a,showChipIcons:t=!0,showChipImages:n=!0,newParamId:i,editingParam:r,editingIdentified:o,editingAnchor:c,caretOffset:d,placeholderText:x,isFocused:P,isDropdownOpen:S,listboxId:g,activeDescendantId:v,autoFocus:A,handleTextChange:B,handleKeyDown:H,handleCaretAfterInput:j,handleCaretMove:R,startEditingParam:T,replaceEditingRange:F,setFocused:K}=e,y=(0,I.useRef)(null),G=(0,I.useRef)(!1),re=(0,I.useRef)(""),W=(0,I.useRef)(""),Se=(0,I.useRef)(null),fe=(0,I.useRef)(0);Se.current=d,(0,I.useEffect)(()=>{if(!A)return;let l=y.current;if(!l)return;document.activeElement===l?K(!0):l.focus();let m=l.ownerDocument??document,w=m.getSelection(),b=w&&w.rangeCount>0&&l.contains(w.anchorNode);if(w&&!b){let k=m.createRange();k.selectNodeContents(l),k.collapse(!0),w.removeAllRanges(),w.addRange(k)}},[A,K]),(0,I.useEffect)(()=>{let l=y.current;if(!l)return;let m=l.ownerDocument??document,w=()=>{let b=m.getSelection();if(!b||b.rangeCount===0||!b.anchorNode||!l.contains(b.anchorNode))return;let k=b.anchorNode,L=k.nodeType===Node.ELEMENT_NODE?k:k.parentElement,_=(b.isCollapsed?L?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,te=r?.id??o?.id??null;if(_&&_!==te){T(_);return}performance.now()-fe.current<50||R((0,U.getCursorOffset)(l))};return m.addEventListener("selectionchange",w),()=>m.removeEventListener("selectionchange",w)},[r,o,T,R]),(0,I.useEffect)(()=>{let l=y.current;if(!l)return;let m=w=>{let b=(0,U.chipIdFromTap)(l,w.target);b&&(T(b),(0,U.keepCaretOnChip)(l,b))};return l.addEventListener("click",m),()=>l.removeEventListener("click",m)},[T]),(0,I.useLayoutEffect)(()=>{let l=y.current;l&&(0,U.renderEditableContent)({input:l,segments:a,newParamId:i,editingParamId:r?.id??null,placeholderText:x??"",isFocused:P,showChipIcons:t,showChipImages:n})},[a,i,r,x,P,t,n]),(0,I.useLayoutEffect)(()=>{let l=re.current,m=i??"";if(re.current=m,!m||m===l)return;let w=y.current;if(!w)return;w.focus();let b=Se.current??(0,U.plainTextLength)(w);(0,U.setCursorOffset)(w,b)},[i]),(0,I.useLayoutEffect)(()=>{let l=W.current,m=r?.id??"";if(W.current=m,!m||m===l||c==null)return;let w=y.current;w&&(0,U.setCursorOffset)(w,c)},[r,c]);let J=(0,I.useCallback)(()=>{if(G.current)return;let l=y.current;if(!l)return;let m=(0,U.extractPlainText)(l),b=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;B(b)},[B]),Ie=(0,I.useCallback)(()=>{fe.current=performance.now(),J();let l=y.current;l&&j((0,U.getCursorOffset)(l))},[J,j]);(0,I.useEffect)(()=>{let l=y.current;if(!l)return;let m=w=>{let b=w,k=b.inputType;if(k==="insertParagraph"||k==="insertLineBreak"||k==="insertFromDrop"){w.preventDefault();return}if(k.startsWith("insert")||k.startsWith("delete")){let L=k.startsWith("delete")?"":b.data??"";F(L)&&w.preventDefault()}};return l.addEventListener("beforeinput",m),()=>l.removeEventListener("beforeinput",m)},[F]);let f=(0,I.useCallback)(()=>{G.current=!0},[]),Ne=(0,I.useCallback)(()=>{G.current=!1,J()},[J]),Ee=(0,I.useCallback)(l=>{l.preventDefault();let m=y.current;if(!m)return;let w=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!w)return;let b=m.ownerDocument??document,k=b.getSelection();if(!k||k.rangeCount===0)return;let L=k.getRangeAt(0);if(!m.contains(L.startContainer))return;L.deleteContents();let p=b.createTextNode(w);L.insertNode(p),L.setStartAfter(p),L.collapse(!0),k.removeAllRanges(),k.addRange(L),J()},[J]),Te=(0,I.useCallback)(l=>H(l),[H]),be=(0,I.useCallback)(()=>K(!0),[K]),Ae=(0,I.useCallback)(()=>K(!1),[K]),ve=(0,I.useCallback)(()=>y.current?.focus(),[]),le=(0,I.useCallback)(()=>y.current?.blur(),[]),ee=(0,I.useCallback)(()=>{let l=y.current;return l?(0,U.extractPlainText)(l):""},[]),we=wa()?"plaintext-only":"true";return{inputRef:y,editorProps:{ref:y,contentEditable:we,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":g,"aria-expanded":S,"aria-activedescendant":v,spellCheck:!0,enterKeyHint:"send",onInput:Ie,onKeyDown:Te,onCompositionStart:f,onCompositionEnd:Ne,onPaste:Ee,onFocus:be,onBlur:Ae},getPlainText:ee,focus:ve,blur:le}}var se=require("react/jsx-runtime");function xa(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var qt=(0,M.forwardRef)(function({onSubmit:a,onResult:t,onError:n,optionOverrides:i,maskCompletedText:r,className:o,apiConfig:c,additionalContext:d,language:x,visitorId:P,columns:S,pillPlacement:g="dropdown",mode:v="auto",optionsPosition:A="below",animations:B=!0,dropdownTrigger:H,closeDropdownOnBlur:j,showNonTappableOptions:R,showOptionIcons:T=!0,showChipIcons:F=!0,showChipImages:K=!0,showOptionImages:y=!0,showOptionCounts:G=!0,showSkipButton:re,showProducts:W,productsLayout:Se,productImageFallback:fe,autoFocus:J=!0,onFocus:Ie,onBlur:f,value:Ne,completedParams:Ee,onChange:Te,onParamsChange:be,products:Ae,onProductSelect:ve,submitButton:le,resetOnSubmit:ee=!0},we){let l=(0,M.useRef)(null),m=(0,M.useRef)(null),w=(0,M.useRef)(()=>{}),b=(0,M.useRef)(null),k=(0,M.useRef)(null);(0,M.useEffect)(()=>{let O=l.current;if(O)return b.current?b.current.setMode(v):b.current=new Me.ModeController(O,v),()=>{b.current?.destroy(),b.current=null}},[v]);let L=(0,M.useCallback)(O=>{let de=k.current?.current;de&&(de.focus(),(0,Me.setCursorOffset)(de,O))},[]),{completedParams:p,skippedParams:_,identifiedParams:te,isReady:ae,customFields:C,suggestionPills:xe,setActivePill:_e,skipActivePill:Re,segments:h,newParamId:ye,clearNewParamId:Be,placeholderText:Oe,isFocused:Fe,isDropdownOpen:ke,isActivePillSelected:qe,isLoading:$,activeIndex:V,listboxId:Ke,handleTextChange:Ze,handleKeyDown:st,setFocused:Ue,editingParam:$e,editingIdentified:u,editingAnchor:ie,caretOffset:N,startEditingParam:lt,handleCaretAfterInput:Ut,handleCaretMove:jt,replaceEditingRange:Qt,dropdownProps:Yt,reset:Ve,recordSubmit:vt}=nt({onSubmit:O=>w.current(O),onResult:t,onError:n,optionOverrides:i,maskCompletedText:r,apiConfig:c,additionalContext:d,language:x,visitorId:P,columns:S,dropdownTrigger:H,optionsPosition:A,closeDropdownOnBlur:j,showNonTappableOptions:R,showOptionIcons:T,showOptionImages:y,showOptionCounts:G,showSkipButton:re,showProducts:W,onFocus:Ie,onBlur:f,value:Ne,completedParams:Ee,onChange:Te,onParamsChange:be,products:Ae,onProductSelect:ve,source:"full-sdk",setCursor:L});(0,M.useEffect)(()=>{if(!ye)return;let O=window.setTimeout(()=>Be(),650);return()=>window.clearTimeout(O)},[ye,Be]);let Zt=V>=0?`${Ke}-option-${V}`:void 0,{inputRef:dt,editorProps:$t,focus:Xe,blur:wt,getPlainText:xt}=_t({segments:h,newParamId:ye,editingParam:$e,editingIdentified:u,editingAnchor:ie,caretOffset:N,placeholderText:Oe,isFocused:Fe,showChipIcons:F,showChipImages:K,isDropdownOpen:ke,listboxId:Ke,activeDescendantId:Zt,autoFocus:J,handleTextChange:Ze,handleKeyDown:st,handleCaretAfterInput:Ut,handleCaretMove:jt,startEditingParam:lt,replaceEditingRange:Qt,setFocused:Ue});k.current=dt,(0,M.useLayoutEffect)(()=>{let O=m.current,de=dt.current;if(!O||!de)return;let je=()=>{let kt=O.firstElementChild;if(!kt)return;let ea=kt.getBoundingClientRect(),ta=de.getBoundingClientRect();ea.top>=ta.bottom-2?O.setAttribute("data-aia-pill-wrapped",""):O.removeAttribute("data-aia-pill-wrapped")};je();let yt=new ResizeObserver(je);return yt.observe(de),()=>yt.disconnect()},[h,xe.length,$,dt]),(0,M.useImperativeHandle)(we,()=>({focus:Xe,blur:wt,reset:Ve,setMode:O=>b.current?.setMode(O),skipActivePill:Re}),[Xe,wt,Ve,Re]);let Je=!!h.length||p.length>0,ct=(0,M.useCallback)(O=>{if(!Je)return;let de=xt(),je=(0,Me.buildSubmitResult)(de,p,_,{identifiedParams:te,isReady:ae,customFields:C});O&&vt(je),a(je),ee&&Ve()},[vt,ee,Je,p,_,te,ae,C,a,Ve,xt]);w.current=()=>ct(!1);let Vt=(0,M.useCallback)(O=>{O.target?.closest("[data-aia-pill]")||Xe()},[Xe]),Xt=g==="inline",Jt=g==="dropdown";return(0,se.jsxs)("div",{ref:l,className:`magicx-aia ${He.container} ${o??""}`,"data-pill-placement":g,"data-options-position":A,"data-animations":B?"on":"off","data-mode":xa(v),children:[(0,se.jsx)(it,{...Yt,showPills:Jt,productsLayout:Se,productImageFallback:fe}),(0,se.jsxs)("div",{className:He.inputWrapper,"data-aia-input-wrapper":"",onClick:Vt,children:[(0,se.jsxs)("div",{className:He.editorArea,"data-aia-editor":"",children:[(0,se.jsx)("div",{...$t,className:He.input,"data-aia-input":""}),Xt&&($||xe.length>0)&&(0,se.jsx)("span",{ref:m,className:He.pillListContainer,"data-aia-pill-list-container":"",children:(0,se.jsx)(tt,{pills:xe,activePillIndex:0,activeSelected:qe,onSelectPill:_e,loading:$})})]}),le===null?null:le===void 0?(0,se.jsx)(Kt,{disabled:!Je,onClick:()=>ct(!0),label:(0,Me.uiStringsFor)(x).submit}):(0,se.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:He.submitSlot,onClick:O=>{Je&&(O.stopPropagation(),ct(!0))},children:le})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2269
|
+
`,document.head.appendChild(e)}var _t={submitButton:"aia-submitButton-otz7H"};var lt=require("react/jsx-runtime");function qt({disabled:e,onClick:a,label:t=(0,Ut.uiStringsFor)().submit}){return(0,lt.jsx)("button",{type:"button","data-aia-submit":"",className:_t.submitButton,disabled:e,onClick:n=>{n.stopPropagation(),a()},"aria-label":t,children:(0,lt.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:(0,lt.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var qe=require("@magicx-eng/ai-autocomplete-vanilla"),P=require("react");var xt=require("react");function jt(e){let a=(0,xt.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),n=(0,xt.useRef)({key:"",overrides:void 0});if(n.current.key!==t){let i={};for(let r of Object.keys(e??{})){let o=(p,c,k)=>{let S=a.current?.[r];return S?S(p,c,k):[]};i[r]=o}n.current={key:t,overrides:e?i:void 0}}return{overrides:n.current.overrides,key:t}}var yt=require("react");function Qt(e){let a=(0,yt.useRef)(e);a.current=e;let t=(0,yt.useRef)(null);t.current===null&&(t.current={fetch:(i,r)=>{let o=a.current;return o?o.fetch(i,r):Promise.reject(new Error("products config removed"))},transform:i=>a.current?.transform(i)??[],get limit(){return a.current?.limit}});let n=e!==void 0;return{config:n?t.current:void 0,enabled:n}}var xa={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function dt({onSubmit:e,onResult:a,onError:t,optionOverrides:n,maskCompletedText:i,apiConfig:r,additionalContext:o,language:p,visitorId:c,columns:k=2,dropdownTrigger:S,optionsPosition:I,closeDropdownOnBlur:m,showNonTappableOptions:b,showOptionIcons:A,showOptionImages:B,showOptionCounts:H,showSkipButton:j,showProducts:R,productImageFallback:T="image",onFocus:F,onBlur:K,value:C,completedParams:G,onChange:oe,onParamsChange:W,products:ke,mapProducts:re,onProductSelect:V,source:Ne,setCursor:Ce}){let g=(0,P.useRef)(null),[Be,Pe]=(0,P.useState)(null),be=(0,P.useRef)(e);be.current=e;let Se=(0,P.useRef)(a);Se.current=a;let ve=(0,P.useRef)(t);ve.current=t;let Ie=(0,P.useRef)(oe);Ie.current=oe;let X=(0,P.useRef)(W);X.current=W;let se=(0,P.useRef)(F);se.current=F;let l=(0,P.useRef)(K);l.current=K;let f=(0,P.useRef)(Ce);f.current=Ce;let v=(0,P.useRef)(V);v.current=V;let w=(0,P.useRef)(c);w.current=c;let x=(0,P.useRef)(()=>{let d=w.current;return typeof d=="function"?d():d}).current,L=Qt(ke),h=(0,P.useRef)(re);h.current=re;let q=(0,P.useRef)((d,Z)=>{let O=h.current;return O?O(d,Z):d}).current,J=re?q:void 0,te=jt(n);(0,P.useEffect)(()=>{if(typeof document>"u")return;let d=new qe.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:o,language:p,visitorId:x,optionOverrides:te.overrides,maskCompletedText:i,columns:k,dropdownTrigger:S,optionsPosition:I,closeDropdownOnBlur:m,showNonTappableOptions:b,showProducts:R,source:Ne,value:C,completedParams:G,onSubmit:(...O)=>be.current?.(...O),onResult:(...O)=>Se.current?.(...O),onError:(...O)=>ve.current?.(...O),onChange:(...O)=>Ie.current?.(...O),onParamsChange:(...O)=>X.current?.(...O),onFocus:()=>se.current?.(),onBlur:()=>l.current?.(),onProductSelect:O=>v.current?.(O),setCursor:O=>f.current?.(O),products:L.config,mapProducts:J});g.current=d,Pe(d.getState());let Z=d.subscribe(O=>Pe(O));return()=>{Z(),d.destroy(),g.current===d&&(g.current=null)}},[]),(0,P.useEffect)(()=>{C!==void 0&&g.current?.setValue(C)},[C]),(0,P.useEffect)(()=>{G!==void 0&&g.current?.setCompletedParams(G)},[G]);let _e=JSON.stringify(r??null),le;try{le=JSON.stringify(o??null)}catch{le="[unstringifiable]"}(0,P.useEffect)(()=>{g.current?.update({apiConfig:r,additionalContext:o,language:p,optionOverrides:te.overrides,dropdownTrigger:S,optionsPosition:I,closeDropdownOnBlur:m,showNonTappableOptions:b,showProducts:R})},[_e,le,p,te.key,S,I,m,b,R]);let Ee=(0,P.useRef)(!1);(0,P.useEffect)(()=>{if(!Ee.current){Ee.current=!0;return}g.current?.update({products:L.config})},[L.enabled]),(0,P.useEffect)(()=>{g.current?.update({mapProducts:J})},[J]);let He=(0,P.useRef)(null);He.current===null&&(He.current={handleTextChange:d=>g.current?.handleTextChange(d),handleKeyDown:d=>{let Z="nativeEvent"in d?d.nativeEvent:d;g.current?.handleKeyDown(Z)},setFocused:d=>g.current?.setFocused(d),startEditingParam:d=>g.current?.startEditingParam(d),exitEditMode:()=>g.current?.exitEditMode(),handleCaretAfterInput:d=>g.current?.handleCaretAfterInput(d),handleCaretMove:d=>g.current?.handleCaretMove(d),replaceEditingRange:d=>g.current?.replaceEditingRange(d)??!1,setActivePill:d=>g.current?.setActivePill(d),skipActivePill:()=>g.current?.skipActivePill(),removeLastParam:()=>g.current?.removeLastParam(),clearNewParamId:()=>g.current?.clearNewParamId(),reset:()=>g.current?.reset(),refreshProducts:()=>g.current?.refreshProducts(),recordSubmit:d=>g.current?.recordSubmit(d),selectOption:d=>g.current?.selectOption(d),selectProduct:d=>g.current?.selectProduct(d),setActiveDropdownIndex:d=>g.current?.setActiveDropdownIndex(d),clearHighlight:d=>g.current?.clearHighlight(d),showPreviousMonth:()=>g.current?.showPreviousMonth(),showNextMonth:()=>g.current?.showNextMonth(),handleFocus:()=>g.current?.setFocused(!0),handleBlur:()=>g.current?.setFocused(!1)});let y=He.current,Te=(0,P.useCallback)(d=>{let Z=d.target.value,ht=Z.length>0&&!d.nativeEvent?.isComposing&&Z[0]!==Z[0].toUpperCase()?Z[0].toUpperCase()+Z.slice(1):Z;g.current?.handleTextChange(ht)},[]),Ae=(0,P.useCallback)(d=>{g.current?.handleKeyDown(d.nativeEvent)},[]),we=g.current,u=Be??xa,Fe=C!==void 0?C:u.text,je=G!==void 0?G:u.completedParams,Re=u.actionableSuggestions,de=Re[0],Ke=we?.listboxId??"",Xe=u.activeDropdownIndex>=0&&we?`${Ke}-option-${u.activeDropdownIndex}`:void 0,Oe=u.editingParam,Ge=u.editingIdentified,Qe=Oe?{parameter:Oe.suggestionParameter,text:Oe.suggestionPlaceholder,required:!0,options:Oe.options}:Ge?{parameter:Ge.parameter,text:(0,qe.identifiedParamLabel)(Ge.parameter),required:!0,options:[]}:null,Je=u.dropdownSuggestion??Qe??de,pt=Qe?[Qe]:Re,Ye=(0,qe.dateSelectionFor)(u),et=!we||u.dropdownLoading;return{completedParams:je,skippedParams:u.skippedParams,identifiedParams:u.identifiedParams,suggestionPills:Re,setActivePill:y.setActivePill,skipActivePill:y.skipActivePill,removeLastParam:y.removeLastParam,segments:u.segments,newParamId:u.newParamId,clearNewParamId:y.clearNewParamId,suggestions:u.suggestions,activeIndex:u.activeDropdownIndex,isReady:u.isReady,isLoading:et,isFocused:u.isFocused,isDropdownOpen:u.isDropdownOpen,isActivePillSelected:u.isActivePillSelected,placeholderText:u.placeholderText,listboxId:Ke,error:u.error,products:u.products,customFields:u.customFields,selectProduct:y.selectProduct,handleTextChange:y.handleTextChange,handleKeyDown:y.handleKeyDown,setFocused:y.setFocused,editingParam:Oe,editingIdentified:Ge,editingAnchor:u.editingAnchor,caretOffset:u.caretOffset,startEditingParam:y.startEditingParam,exitEditMode:y.exitEditMode,handleCaretAfterInput:y.handleCaretAfterInput,handleCaretMove:y.handleCaretMove,replaceEditingRange:y.replaceEditingRange,inputProps:{value:Fe,placeholder:u.placeholderText||void 0,onChange:Te,onKeyDown:Ae,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":u.isDropdownOpen,"aria-activedescendant":Xe,"aria-autocomplete":"list","aria-controls":Ke},reset:y.reset,refreshProducts:y.refreshProducts,recordSubmit:y.recordSubmit,dropdownProps:{suggestions:Je?[{...Je,options:u.dropdownOptions}]:[],activeIndex:u.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,onUnhighlight:y.clearHighlight,isOpen:u.isDropdownOpen,id:Ke,pills:pt,activeSelected:u.isActivePillSelected,onPillClick:y.setActivePill,onSkip:y.skipActivePill,showSkipButton:(j??!0)&&!Oe&&!Ge,showOptionIcons:A??!0,showOptionImages:B??!0,showOptionCounts:H??!0,skipDisabled:u.inSelectionAnimation,isLoading:et,skeletonExiting:u.skeletonExiting,isInputEmpty:Fe.trim().length===0,language:p,products:u.products,productImageFallback:T,onProductSelect:y.selectProduct,onProductFocusChange:y.setFocused,formatType:u.activeFormatType,dateView:u.dateView,selectedDateIso:Ye.selectedIso,selectedDateRange:Ye.selectedRange,dateRangeStart:Ye.rangeStart,onPreviousMonth:y.showPreviousMonth,onNextMonth:y.showNextMonth,optionsPosition:I??"below"}}}var U=require("@magicx-eng/ai-autocomplete-vanilla"),E=require("react"),ct;function ya(){if(ct!==void 0)return ct;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),ct=e.contentEditable==="plaintext-only",ct}function Yt(e){let{segments:a,showChipIcons:t=!0,showChipImages:n=!0,newParamId:i,editingParam:r,editingIdentified:o,editingAnchor:p,caretOffset:c,placeholderText:k,isFocused:S,isDropdownOpen:I,listboxId:m,activeDescendantId:b,autoFocus:A,handleTextChange:B,handleKeyDown:H,handleCaretAfterInput:j,handleCaretMove:R,startEditingParam:T,replaceEditingRange:F,setFocused:K}=e,C=(0,E.useRef)(null),G=(0,E.useRef)(!1),oe=(0,E.useRef)(""),W=(0,E.useRef)(""),ke=(0,E.useRef)(null),re=(0,E.useRef)(0);ke.current=c,(0,E.useEffect)(()=>{if(!A)return;let l=C.current;if(!l)return;document.activeElement===l?K(!0):l.focus();let f=l.ownerDocument??document,v=f.getSelection(),w=v&&v.rangeCount>0&&l.contains(v.anchorNode);if(v&&!w){let x=f.createRange();x.selectNodeContents(l),x.collapse(!0),v.removeAllRanges(),v.addRange(x)}},[A,K]),(0,E.useEffect)(()=>{let l=C.current;if(!l)return;let f=l.ownerDocument??document,v=()=>{let w=f.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!l.contains(w.anchorNode))return;let x=w.anchorNode,L=x.nodeType===Node.ELEMENT_NODE?x:x.parentElement,q=(w.isCollapsed?L?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,J=r?.id??o?.id??null;if(q&&q!==J){T(q);return}performance.now()-re.current<50||R((0,U.getCursorOffset)(l))};return f.addEventListener("selectionchange",v),()=>f.removeEventListener("selectionchange",v)},[r,o,T,R]),(0,E.useEffect)(()=>{let l=C.current;if(!l)return;let f=v=>{let w=(0,U.chipIdFromTap)(l,v.target);w&&(T(w),(0,U.keepCaretOnChip)(l,w))};return l.addEventListener("click",f),()=>l.removeEventListener("click",f)},[T]),(0,E.useLayoutEffect)(()=>{let l=C.current;l&&(0,U.renderEditableContent)({input:l,segments:a,newParamId:i,editingParamId:r?.id??null,placeholderText:k??"",isFocused:S,showChipIcons:t,showChipImages:n})},[a,i,r,k,S,t,n]),(0,E.useLayoutEffect)(()=>{let l=oe.current,f=i??"";if(oe.current=f,!f||f===l)return;let v=C.current;if(!v)return;v.focus();let w=ke.current??(0,U.plainTextLength)(v);(0,U.setCursorOffset)(v,w)},[i]),(0,E.useLayoutEffect)(()=>{let l=W.current,f=r?.id??"";if(W.current=f,!f||f===l||p==null)return;let v=C.current;v&&(0,U.setCursorOffset)(v,p)},[r,p]);let V=(0,E.useCallback)(()=>{if(G.current)return;let l=C.current;if(!l)return;let f=(0,U.extractPlainText)(l),w=f.length>0&&f[0]!==f[0].toUpperCase()?f[0].toUpperCase()+f.slice(1):f;B(w)},[B]),Ne=(0,E.useCallback)(()=>{re.current=performance.now(),V();let l=C.current;l&&j((0,U.getCursorOffset)(l))},[V,j]);(0,E.useEffect)(()=>{let l=C.current;if(!l)return;let f=v=>{let w=v,x=w.inputType;if(x==="insertParagraph"||x==="insertLineBreak"||x==="insertFromDrop"){v.preventDefault();return}if(x.startsWith("insert")||x.startsWith("delete")){let L=x.startsWith("delete")?"":w.data??"";F(L)&&v.preventDefault()}};return l.addEventListener("beforeinput",f),()=>l.removeEventListener("beforeinput",f)},[F]);let Ce=(0,E.useCallback)(()=>{G.current=!0},[]),g=(0,E.useCallback)(()=>{G.current=!1,V()},[V]),Be=(0,E.useCallback)(l=>{l.preventDefault();let f=C.current;if(!f)return;let v=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!v)return;let w=f.ownerDocument??document,x=w.getSelection();if(!x||x.rangeCount===0)return;let L=x.getRangeAt(0);if(!f.contains(L.startContainer))return;L.deleteContents();let h=w.createTextNode(v);L.insertNode(h),L.setStartAfter(h),L.collapse(!0),x.removeAllRanges(),x.addRange(L),V()},[V]),Pe=(0,E.useCallback)(l=>H(l),[H]),be=(0,E.useCallback)(()=>K(!0),[K]),Se=(0,E.useCallback)(()=>K(!1),[K]),ve=(0,E.useCallback)(()=>C.current?.focus(),[]),Ie=(0,E.useCallback)(()=>C.current?.blur(),[]),X=(0,E.useCallback)(()=>{let l=C.current;return l?(0,U.extractPlainText)(l):""},[]),se=ya()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:se,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":I,"aria-activedescendant":b,spellCheck:!0,enterKeyHint:"send",onInput:Ne,onKeyDown:Pe,onCompositionStart:Ce,onCompositionEnd:g,onPaste:Be,onFocus:be,onBlur:Se},getPlainText:X,focus:ve,blur:Ie}}var ne=require("react/jsx-runtime");function ka(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Zt=(0,N.forwardRef)(function({onSubmit:a,onResult:t,onError:n,optionOverrides:i,maskCompletedText:r,className:o,apiConfig:p,additionalContext:c,language:k,visitorId:S,columns:I,pillPlacement:m="dropdown",mode:b="auto",optionsPosition:A="below",animations:B=!0,dropdownTrigger:H,closeDropdownOnBlur:j,showNonTappableOptions:R,showOptionIcons:T=!0,showChipIcons:F=!0,showChipImages:K=!0,showOptionImages:C=!0,showOptionCounts:G=!0,showSkipButton:oe,showProducts:W,productsLayout:ke,productImageFallback:re,autoFocus:V=!0,onFocus:Ne,onBlur:Ce,value:g,completedParams:Be,onChange:Pe,onParamsChange:be,products:Se,mapProducts:ve,onProductSelect:Ie,submitButton:X,resetOnSubmit:se=!0},l){let f=(0,N.useRef)(null),v=(0,N.useRef)(null),w=(0,N.useRef)(()=>{}),x=(0,N.useRef)(null),L=(0,N.useRef)(null);(0,N.useEffect)(()=>{let D=f.current;if(D)return x.current?x.current.setMode(b):x.current=new Me.ModeController(D,b),()=>{x.current?.destroy(),x.current=null}},[b]);let h=(0,N.useCallback)(D=>{let ce=L.current?.current;ce&&(ce.focus(),(0,Me.setCursorOffset)(ce,D))},[]),{completedParams:q,skippedParams:J,identifiedParams:te,isReady:_e,customFields:le,suggestionPills:Ee,setActivePill:He,skipActivePill:y,segments:Te,newParamId:Ae,clearNewParamId:we,placeholderText:u,isFocused:Fe,isDropdownOpen:je,isActivePillSelected:Re,isLoading:de,activeIndex:Ke,listboxId:Xe,handleTextChange:Oe,handleKeyDown:Ge,setFocused:Qe,editingParam:Je,editingIdentified:pt,editingAnchor:Ye,caretOffset:et,startEditingParam:d,handleCaretAfterInput:Z,handleCaretMove:O,replaceEditingRange:ht,dropdownProps:$t,reset:tt,refreshProducts:kt,recordSubmit:Ct}=dt({onSubmit:D=>w.current(D),onResult:t,onError:n,optionOverrides:i,maskCompletedText:r,apiConfig:p,additionalContext:c,language:k,visitorId:S,columns:I,dropdownTrigger:H,optionsPosition:A,closeDropdownOnBlur:j,showNonTappableOptions:R,showOptionIcons:T,showOptionImages:C,showOptionCounts:G,showSkipButton:oe,showProducts:W,onFocus:Ne,onBlur:Ce,value:g,completedParams:Be,onChange:Pe,onParamsChange:be,products:Se,mapProducts:ve,onProductSelect:Ie,source:"full-sdk",setCursor:h});(0,N.useEffect)(()=>{if(!Ae)return;let D=window.setTimeout(()=>we(),650);return()=>window.clearTimeout(D)},[Ae,we]);let Vt=Ke>=0?`${Xe}-option-${Ke}`:void 0,{inputRef:ut,editorProps:Xt,focus:at,blur:Pt,getPlainText:St}=Yt({segments:Te,newParamId:Ae,editingParam:Je,editingIdentified:pt,editingAnchor:Ye,caretOffset:et,placeholderText:u,isFocused:Fe,showChipIcons:F,showChipImages:K,isDropdownOpen:je,listboxId:Xe,activeDescendantId:Vt,autoFocus:V,handleTextChange:Oe,handleKeyDown:Ge,handleCaretAfterInput:Z,handleCaretMove:O,startEditingParam:d,replaceEditingRange:ht,setFocused:Qe});L.current=ut,(0,N.useLayoutEffect)(()=>{let D=v.current,ce=ut.current;if(!D||!ce)return;let Ze=()=>{let Et=D.firstElementChild;if(!Et)return;let aa=Et.getBoundingClientRect(),ia=ce.getBoundingClientRect();aa.top>=ia.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};Ze();let It=new ResizeObserver(Ze);return It.observe(ce),()=>It.disconnect()},[Te,Ee.length,de,ut]),(0,N.useImperativeHandle)(l,()=>({focus:at,blur:Pt,reset:tt,refreshProducts:kt,setMode:D=>x.current?.setMode(D),skipActivePill:y}),[at,Pt,tt,kt,y]);let it=!!Te.length||q.length>0,mt=(0,N.useCallback)(D=>{if(!it)return;let ce=St(),Ze=(0,Me.buildSubmitResult)(ce,q,J,{identifiedParams:te,isReady:_e,customFields:le});D&&Ct(Ze),a(Ze),se&&tt()},[Ct,se,it,q,J,te,_e,le,a,tt,St]);w.current=()=>mt(!1);let Jt=(0,N.useCallback)(D=>{D.target?.closest("[data-aia-pill]")||at()},[at]),ea=m==="inline",ta=m==="dropdown";return(0,ne.jsxs)("div",{ref:f,className:`magicx-aia ${We.container} ${o??""}`,"data-pill-placement":m,"data-options-position":A,"data-animations":B?"on":"off","data-mode":ka(b),children:[(0,ne.jsx)(st,{...$t,showPills:ta,productsLayout:ke,productImageFallback:re}),(0,ne.jsxs)("div",{className:We.inputWrapper,"data-aia-input-wrapper":"",onClick:Jt,children:[(0,ne.jsxs)("div",{className:We.editorArea,"data-aia-editor":"",children:[(0,ne.jsx)("div",{...Xt,className:We.input,"data-aia-input":""}),ea&&(de||Ee.length>0)&&(0,ne.jsx)("span",{ref:v,className:We.pillListContainer,"data-aia-pill-list-container":"",children:(0,ne.jsx)(nt,{pills:Ee,activePillIndex:0,activeSelected:Re,onSelectPill:He,loading:de})})]}),X===null?null:X===void 0?(0,ne.jsx)(qt,{disabled:!it,onClick:()=>mt(!0),label:(0,Me.uiStringsFor)(k).submit}):(0,ne.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:We.submitSlot,onClick:D=>{it&&(D.stopPropagation(),mt(!0))},children:X})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2270
2270
|
//# sourceMappingURL=index.js.map
|