@magicx-eng/ai-autocomplete-react 0.33.5 → 0.35.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 CHANGED
@@ -335,6 +335,7 @@ function App() {
335
335
  | `visitorId?` | `string \| (() => string \| undefined)` | — | Stable UUID v4 for this visitor, kept across page loads, or a function returning it. See [Visitor id and submits](#visitor-id-and-submits). |
336
336
  | `additionalContext?` | `Record<string, unknown>` | — | Optional user context. Include whatever you know about the user (a profile, preferences, workspace, anything) to personalize suggested parameters and options to them. |
337
337
  | `language?` | `string` | browser language | BCP 47 language tag of the shopper (e.g. `"es"`), sent with every suggestion request. Default: the browser language (`navigator.language`), else `"en-US"`. |
338
+ | `productId?` | `string` | — | Your product id. When set, what the dropdown offers before anything is typed is read from a cacheable URL for your product, with no credential, instead of a suggestion request; it falls back to a suggestion request when it cannot be read. |
338
339
  | `optionOverrides?` | `OptionOverrides` | — | Supply the options for a parameter yourself, per suggestion type — fixed, computed, or fetched as the user types. See [Option Overrides](#option-overrides). |
339
340
  | `maskCompletedText?` | `boolean` | `false` | When `true`, omits completed params' literal text from API requests (for masking PII/sensitive values from the server). |
340
341
  | `className?` | `string` | — | CSS class applied to the container. |
@@ -506,6 +507,32 @@ const { customFields } = useAIAutocomplete({ ... });
506
507
  news", not an empty catalog. The strip clears on such a response rather than
507
508
  keeping an older query's items.
508
509
 
510
+ #### Change product cards before display
511
+
512
+ - `mapProducts(products, items)` synchronously returns the cards to show.
513
+ - The SDK calls it once per response with its default cards and their matched items in the same order.
514
+ - The returned array becomes the product state and the displayed strip.
515
+ - A thrown error or a non-array result keeps the default cards. A thrown error warns once per instance.
516
+ - `refreshProducts()` maps the current items again without a request. Call it when your own data arrives.
517
+ - Both APIs leave a custom `products` integration unchanged.
518
+
519
+ ```tsx
520
+ const { actions } = useAIAutocomplete({
521
+ mapProducts: (products, items) =>
522
+ products.map((product, index) => ({
523
+ ...product,
524
+ price: shopperPrices[items[index].source_id] ?? "",
525
+ })),
526
+ });
527
+
528
+ // After updating shopperPrices:
529
+ actions.refreshProducts();
530
+ ```
531
+
532
+ - `<AIAutocomplete mapProducts={mapProducts} />` accepts the same callback.
533
+ - Call `ref.current?.refreshProducts()` through the component's imperative handle.
534
+ - Inline callbacks do not trigger repeated mapping on each render. A refresh uses the latest callback.
535
+
509
536
  #### Your own product search (`products`)
510
537
 
511
538
  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 / →.
@@ -50,6 +56,13 @@ interface AIAutocompleteProps {
50
56
  * Default: the browser language (`navigator.language`), else `"en-US"`.
51
57
  */
52
58
  language?: string;
59
+ /**
60
+ * Your product id. When set, what the dropdown offers before anything is
61
+ * typed is read from a cacheable URL for your product, with no credential,
62
+ * instead of a suggestion request; it falls back to a suggestion request
63
+ * when it cannot be read.
64
+ */
65
+ productId?: string;
53
66
  /**
54
67
  * Stable id for this visitor, kept by the host across page loads. Rides on
55
68
  * telemetry events so searches can be joined to what the visitor does
@@ -149,6 +162,13 @@ interface AIAutocompleteProps {
149
162
  * the config restores the server's items at once.
150
163
  */
151
164
  products?: ProductsConfig;
165
+ /**
166
+ * Runs synchronously with the SDK's cards and their response items in the same order.
167
+ * The product strip shows the returned array.
168
+ * Does not apply to a custom products integration.
169
+ * A throw or a result that is not an array keeps the SDK's cards.
170
+ */
171
+ mapProducts?: (products: Product[], items: MatchedItem[]) => Product[];
152
172
  /**
153
173
  * Called when the user activates a product card. The SDK does not navigate —
154
174
  * you decide what a selection means. Modifier / middle clicks are left to the
@@ -197,6 +217,13 @@ interface UseAIAutocompleteOptions {
197
217
  * Default: the browser language (`navigator.language`), else `"en-US"`.
198
218
  */
199
219
  language?: string;
220
+ /**
221
+ * Your product id. When set, what the dropdown offers before anything is
222
+ * typed is read from a cacheable URL for your product, with no credential,
223
+ * instead of a suggestion request; it falls back to a suggestion request
224
+ * when it cannot be read.
225
+ */
226
+ productId?: string;
200
227
  /**
201
228
  * Stable id for this visitor, kept by the host across page loads. Rides on
202
229
  * telemetry events so searches can be joined to what the visitor does
@@ -293,6 +320,13 @@ interface UseAIAutocompleteOptions {
293
320
  * the config restores the server's items at once.
294
321
  */
295
322
  products?: ProductsConfig;
323
+ /**
324
+ * Runs synchronously with the SDK's cards and their response items in the same order.
325
+ * The product strip shows the returned array.
326
+ * Does not apply to a custom products integration.
327
+ * A throw or a result that is not an array keeps the SDK's cards.
328
+ */
329
+ mapProducts?: (products: Product[], items: MatchedItem[]) => Product[];
296
330
  /**
297
331
  * Called when the user activates a product card. The SDK does not navigate —
298
332
  * you decide what a selection means. Modifier / middle clicks are left to the
@@ -339,6 +373,12 @@ interface UseAIAutocompleteReturn {
339
373
  skipActivePill: () => void;
340
374
  removeLastParam: () => void;
341
375
  reset: () => void;
376
+ /**
377
+ * Runs mapProducts synchronously on the shown items again without a request.
378
+ * Keeps the same cards while updating their content.
379
+ * Does nothing without mapProducts or with a custom products integration.
380
+ */
381
+ refreshProducts: () => void;
342
382
  /**
343
383
  * Records a submit in telemetry. Enter is recorded by the SDK; call this
344
384
  * from a submit button you render, so each submit is counted once.
@@ -567,6 +607,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
567
607
 
568
608
  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
609
 
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;
610
+ declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, productId, 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
611
 
572
612
  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 / →.
@@ -50,6 +56,13 @@ interface AIAutocompleteProps {
50
56
  * Default: the browser language (`navigator.language`), else `"en-US"`.
51
57
  */
52
58
  language?: string;
59
+ /**
60
+ * Your product id. When set, what the dropdown offers before anything is
61
+ * typed is read from a cacheable URL for your product, with no credential,
62
+ * instead of a suggestion request; it falls back to a suggestion request
63
+ * when it cannot be read.
64
+ */
65
+ productId?: string;
53
66
  /**
54
67
  * Stable id for this visitor, kept by the host across page loads. Rides on
55
68
  * telemetry events so searches can be joined to what the visitor does
@@ -149,6 +162,13 @@ interface AIAutocompleteProps {
149
162
  * the config restores the server's items at once.
150
163
  */
151
164
  products?: ProductsConfig;
165
+ /**
166
+ * Runs synchronously with the SDK's cards and their response items in the same order.
167
+ * The product strip shows the returned array.
168
+ * Does not apply to a custom products integration.
169
+ * A throw or a result that is not an array keeps the SDK's cards.
170
+ */
171
+ mapProducts?: (products: Product[], items: MatchedItem[]) => Product[];
152
172
  /**
153
173
  * Called when the user activates a product card. The SDK does not navigate —
154
174
  * you decide what a selection means. Modifier / middle clicks are left to the
@@ -197,6 +217,13 @@ interface UseAIAutocompleteOptions {
197
217
  * Default: the browser language (`navigator.language`), else `"en-US"`.
198
218
  */
199
219
  language?: string;
220
+ /**
221
+ * Your product id. When set, what the dropdown offers before anything is
222
+ * typed is read from a cacheable URL for your product, with no credential,
223
+ * instead of a suggestion request; it falls back to a suggestion request
224
+ * when it cannot be read.
225
+ */
226
+ productId?: string;
200
227
  /**
201
228
  * Stable id for this visitor, kept by the host across page loads. Rides on
202
229
  * telemetry events so searches can be joined to what the visitor does
@@ -293,6 +320,13 @@ interface UseAIAutocompleteOptions {
293
320
  * the config restores the server's items at once.
294
321
  */
295
322
  products?: ProductsConfig;
323
+ /**
324
+ * Runs synchronously with the SDK's cards and their response items in the same order.
325
+ * The product strip shows the returned array.
326
+ * Does not apply to a custom products integration.
327
+ * A throw or a result that is not an array keeps the SDK's cards.
328
+ */
329
+ mapProducts?: (products: Product[], items: MatchedItem[]) => Product[];
296
330
  /**
297
331
  * Called when the user activates a product card. The SDK does not navigate —
298
332
  * you decide what a selection means. Modifier / middle clicks are left to the
@@ -339,6 +373,12 @@ interface UseAIAutocompleteReturn {
339
373
  skipActivePill: () => void;
340
374
  removeLastParam: () => void;
341
375
  reset: () => void;
376
+ /**
377
+ * Runs mapProducts synchronously on the shown items again without a request.
378
+ * Keeps the same cards while updating their content.
379
+ * Does nothing without mapProducts or with a custom products integration.
380
+ */
381
+ refreshProducts: () => void;
342
382
  /**
343
383
  * Records a submit in telemetry. Enter is recorded by the SDK; call this
344
384
  * from a submit button you render, so each submit is counted once.
@@ -567,6 +607,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
567
607
 
568
608
  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
609
 
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;
610
+ declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, productId, 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
611
 
572
612
  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 pt=Object.defineProperty;var aa=Object.getOwnPropertyDescriptor;var ia=Object.getOwnPropertyNames;var oa=Object.prototype.hasOwnProperty;var na=(e,a)=>{for(var t in a)pt(e,t,{get:a[t],enumerable:!0})},ra=(e,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of ia(a))!oa.call(e,i)&&i!==t&&pt(e,i,{get:()=>a[i],enumerable:!(n=aa(a,i))||n.enumerable});return e};var sa=e=>ra(pt({},"__esModule",{value:!0}),e);var ya={};na(ya,{AIAutocomplete:()=>qt,AIAutocompleteDropdown:()=>it,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:()=>nt,visibleDateRange:()=>s.visibleDateRange,withSkippedParams:()=>s.withSkippedParams});module.exports=sa(ya);var s=require("@magicx-eng/ai-autocomplete-vanilla");var M=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 {
1
+ "use strict";var ft=Object.defineProperty;var na=Object.getOwnPropertyDescriptor;var ra=Object.getOwnPropertyNames;var sa=Object.prototype.hasOwnProperty;var la=(e,a)=>{for(var t in a)ft(e,t,{get:a[t],enumerable:!0})},da=(e,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of ra(a))!sa.call(e,i)&&i!==t&&ft(e,i,{get:()=>a[i],enumerable:!(n=na(a,i))||n.enumerable});return e};var ca=e=>da(ft({},"__esModule",{value:!0}),e);var Pa={};la(Pa,{AIAutocomplete:()=>$t,AIAutocompleteDropdown:()=>lt,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:()=>ct,visibleDateRange:()=>s.visibleDateRange,withSkippedParams:()=>s.withSkippedParams});module.exports=ca(Pa);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 He={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"),ne=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
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 Ne=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 Ce={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 z=require("@magicx-eng/ai-autocomplete-vanilla"),Ct=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) ---
1048
+ `,document.head.appendChild(e)}var we={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"),At=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 D={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 Z=require("react/jsx-runtime"),la=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Pt({options:e,activeIndex:a,listboxId:t,view:n,selection:i,onSelect:r,onHighlight:o,onUnhighlight:c,onPreviousMonth:d,onNextMonth:x}){let P=(0,z.isoDate)(new Date),S=(0,z.visibleDateRange)({pendingStart:i.rangeStart,highlightedIso:(0,z.cellIso)(e[a]),selected:i.selectedRange});return(0,Z.jsxs)("div",{className:D.datepicker,"data-aia-datepicker":"",children:[(0,Z.jsxs)("div",{className:D.header,children:[(0,Z.jsx)("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:g=>g.preventDefault(),onClick:d,children:"\u2039"}),(0,Z.jsx)("span",{className:D.month,"data-aia-date-month":"","aria-live":"polite",children:(0,z.monthLabel)(n)}),(0,Z.jsx)("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:g=>g.preventDefault(),onClick:x,children:"\u203A"})]}),(0,Z.jsx)("div",{className:D.weekdays,"aria-hidden":"true",children:z.WEEKDAY_LABELS.map((g,v)=>(0,Z.jsx)("span",{className:D.weekday,children:g},la[v]))}),(0,Z.jsx)("div",{className:D.grid,"data-aia-date-grid":"",children:e.map((g,v)=>(0,Z.jsx)(da,{option:g,id:`${t}-option-${v}`,index:v,isHighlighted:v===a&&g.is_tappable,isToday:(0,z.cellIso)(g)===P,isPast:(0,z.cellIso)(g)!=null&&(0,z.cellIso)(g)<P,marks:(0,z.dateCellMarks)((0,z.cellIso)(g),{selectedIso:i.selectedIso,range:S}),onSelect:r,onHighlight:o,onUnhighlight:c},(0,z.cellIso)(g)??`pad-${v}`))})]})}function da({option:e,id:a,index:t,isHighlighted:n,isToday:i,isPast:r,marks:o,onSelect:c,onHighlight:d,onUnhighlight:x}){let[P,S]=(0,Ct.useState)(!1),g=(0,z.cellDay)(e);if(g==null)return(0,Z.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${D.cell} ${D.blank}`});let v=()=>{S(!0),c(e),setTimeout(()=>S(!1),170)},A=[D.cell,D.day,r?D.past:"",n?D.highlighted:"",i?D.today:"",o.inRange?D.inRange:"",o.selected?D.selected:"",P?D.pressed:""].filter(Boolean).join(" ");return(0,Z.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:v,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),v())},onMouseEnter:()=>d(t),onMouseLeave:x?()=>x(t):void 0,children:(0,Z.jsx)("span",{className:D.number,children:g})})}var De=require("@magicx-eng/ai-autocomplete-vanilla"),et=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 {
1211
+ `,document.head.appendChild(e)}var L={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 X=require("react/jsx-runtime"),pa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Rt({options:e,activeIndex:a,listboxId:t,view:n,selection:i,onSelect:r,onHighlight:o,onUnhighlight:h,onPreviousMonth:d,onNextMonth:w}){let E=(0,M.isoDate)(new Date),I=(0,M.visibleDateRange)({pendingStart:i.rangeStart,highlightedIso:(0,M.cellIso)(e[a]),selected:i.selectedRange});return(0,X.jsxs)("div",{className:L.datepicker,"data-aia-datepicker":"",children:[(0,X.jsxs)("div",{className:L.header,children:[(0,X.jsx)("button",{type:"button",tabIndex:-1,className:L.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:g=>g.preventDefault(),onClick:d,children:"\u2039"}),(0,X.jsx)("span",{className:L.month,"data-aia-date-month":"","aria-live":"polite",children:(0,M.monthLabel)(n)}),(0,X.jsx)("button",{type:"button",tabIndex:-1,className:L.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:g=>g.preventDefault(),onClick:w,children:"\u203A"})]}),(0,X.jsx)("div",{className:L.weekdays,"aria-hidden":"true",children:M.WEEKDAY_LABELS.map((g,v)=>(0,X.jsx)("span",{className:L.weekday,children:g},pa[v]))}),(0,X.jsx)("div",{className:L.grid,"data-aia-date-grid":"",children:e.map((g,v)=>(0,X.jsx)(ha,{option:g,id:`${t}-option-${v}`,index:v,isHighlighted:v===a&&g.is_tappable,isToday:(0,M.cellIso)(g)===E,isPast:(0,M.cellIso)(g)!=null&&(0,M.cellIso)(g)<E,marks:(0,M.dateCellMarks)((0,M.cellIso)(g),{selectedIso:i.selectedIso,range:I}),onSelect:r,onHighlight:o,onUnhighlight:h},(0,M.cellIso)(g)??`pad-${v}`))})]})}function ha({option:e,id:a,index:t,isHighlighted:n,isToday:i,isPast:r,marks:o,onSelect:h,onHighlight:d,onUnhighlight:w}){let[E,I]=(0,At.useState)(!1),g=(0,M.cellDay)(e);if(g==null)return(0,X.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${L.cell} ${L.blank}`});let v=()=>{I(!0),h(e),setTimeout(()=>I(!1),170)},T=[L.cell,L.day,r?L.past:"",n?L.highlighted:"",i?L.today:"",o.inRange?L.inRange:"",o.selected?L.selected:"",E?L.pressed:""].filter(Boolean).join(" ");return(0,X.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:T,onClick:v,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),v())},onMouseEnter:()=>d(t),onMouseLeave:w?()=>w(t):void 0,children:(0,X.jsx)("span",{className:L.number,children:g})})}var ze=require("@magicx-eng/ai-autocomplete-vanilla"),nt=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 ht=require("react/jsx-runtime");function Qe({gap:e,align:a="center",justify:t="start",noWrap:n=!1,inline:i=!1,className:r,children:o,...c}){let d=e?{"--aia-cluster-gap":e}:void 0,x={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":n||void 0,"data-inline":i||void 0,style:d,...c};return i?(0,ht.jsx)("span",{...x,children:o}):(0,ht.jsx)("div",{...x,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
1251
+ `,document.head.appendChild(e)}var bt=require("react/jsx-runtime");function Ve({gap:e,align:a="center",justify:t="start",noWrap:n=!1,inline:i=!1,className:r,children:o,...h}){let d=e?{"--aia-cluster-gap":e}:void 0,w={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":n||void 0,"data-inline":i||void 0,style:d,...h};return i?(0,bt.jsx)("span",{...w,children:o}):(0,bt.jsx)("div",{...w,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 Pe={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 ce=require("react/jsx-runtime");function St({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,et.useState)(De.ATTRIBUTION_URL);return(0,et.useEffect)(()=>{o((0,De.buildAttributionUrl)())},[]),(0,ce.jsx)("footer",{className:Pe.footer,"data-aia-footer":"",children:(0,ce.jsxs)(Qe,{justify:"between",noWrap:!0,className:Pe.row,children:[(0,ce.jsxs)(Qe,{gap:"5px",className:Pe.hintGroup,children:[(0,ce.jsx)("kbd",{className:Pe.key,children:n}),(0,ce.jsx)("span",{className:Pe.hint,children:i})]}),(0,ce.jsxs)("a",{className:Pe.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[(0,ce.jsx)("span",{className:Pe.brand,children:"AI"}),(0,ce.jsx)("span",{className:Pe.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,
1398
+ `,document.head.appendChild(e)}var xe={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 de=require("react/jsx-runtime");function Ot({isOptionHighlighted:e=!1,isInputEmpty:a=!1,strings:t=(0,ze.uiStringsFor)()}){let{key:n,hint:i}=(0,ze.getFooterHint)(e,a,t),[r,o]=(0,nt.useState)(ze.ATTRIBUTION_URL);return(0,nt.useEffect)(()=>{o((0,ze.buildAttributionUrl)())},[]),(0,de.jsx)("footer",{className:xe.footer,"data-aia-footer":"",children:(0,de.jsxs)(Ve,{justify:"between",noWrap:!0,className:xe.row,children:[(0,de.jsxs)(Ve,{gap:"5px",className:xe.hintGroup,children:[(0,de.jsx)("kbd",{className:xe.key,children:n}),(0,de.jsx)("span",{className:xe.hint,children:i})]}),(0,de.jsxs)("a",{className:xe.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[(0,de.jsx)("span",{className:xe.brand,children:"AI"}),(0,de.jsx)("span",{className:xe.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 Et=require("react/jsx-runtime"),ut={selected:1,first:.7,next:.4,last:.2};function It({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,Et.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:ut[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 {
1474
+ `,document.head.appendChild(e)}var Me={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 Lt=require("react/jsx-runtime"),vt={selected:1,first:.7,next:.4,last:.2};function Dt({label:e,state:a,rounded:t,loading:n,onClick:i}){let r=[Me.pill,t?Me.rounded:"",n?Me.skeleton:""].filter(Boolean).join(" ");return(0,Lt.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:vt[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 gt={list:"aia-list-qvLqO"};var Ye=require("react/jsx-runtime"),ca=[125,69];function Tt(e){return e===0?"first":e===1?"next":"last"}function tt({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:n,rounded:i,loading:r}){return r&&e.length===0?(0,Ye.jsx)("span",{className:gt.list,"data-aia-pill-list-loading":"",children:ca.map((o,c)=>(0,Ye.jsx)("span",{"data-aia-pill-skeleton":"",className:`${Le.pill} ${i?Le.rounded:""} ${Le.skeleton}`,style:{width:o,opacity:ut[Tt(c)]}},`skel-${o}`))}):(0,Ye.jsx)("span",{className:gt.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((o,c)=>{let d=!!n&&c===a;return(0,Ye.jsx)(It,{label:o.text,state:d?"selected":Tt(c),selected:d,rounded:i,loading:r,onClick:()=>t(c)},`${o.parameter}-${o.text}`)})})}var pe=require("@magicx-eng/ai-autocomplete-vanilla"),Ge=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
1484
+ `,document.head.appendChild(e)}var wt={list:"aia-list-qvLqO"};var Xe=require("react/jsx-runtime"),ua=[125,69];function zt(e){return e===0?"first":e===1?"next":"last"}function rt({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:n,rounded:i,loading:r}){return r&&e.length===0?(0,Xe.jsx)("span",{className:wt.list,"data-aia-pill-list-loading":"",children:ua.map((o,h)=>(0,Xe.jsx)("span",{"data-aia-pill-skeleton":"",className:`${Me.pill} ${i?Me.rounded:""} ${Me.skeleton}`,style:{width:o,opacity:vt[zt(h)]}},`skel-${o}`))}):(0,Xe.jsx)("span",{className:wt.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((o,h)=>{let d=!!n&&h===a;return(0,Xe.jsx)(Dt,{label:o.text,state:d?"selected":zt(h),selected:d,rounded:i,loading:r,onClick:()=>t(h)},`${o.parameter}-${o.text}`)})})}var ce=require("@magicx-eng/ai-autocomplete-vanilla"),qe=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 oe={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 At({products:e,listboxId:a,onSelect:t,onFocusChange:n,focusable:i=!0,layout:r="row",imageFallback:o="image",strings:c=(0,pe.uiStringsFor)()}){let d=e.length>0,x=(0,Ge.useRef)(null);if((0,Ge.useEffect)(()=>{let S=x.current;if(!(!d||!S))return(0,pe.attachProductRowWheel)(S)},[d]),!d)return null;let P=`${a}-products-label`;return(0,Q.jsxs)("section",{className:oe.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":P,children:[(0,Q.jsx)("div",{className:oe.label,id:P,"data-aia-products-label":"",children:c.products}),(0,Q.jsx)("div",{ref:x,className:oe.row,"data-aia-products-row":"",children:e.map((S,g)=>(0,Q.jsx)(pa,{product:S,id:`${a}-product-${g}`,onSelect:t,onFocusChange:n,focusable:i,imageFallback:o,soldOut:c.soldOut},S.id))})]})}function pa({product:e,id:a,onSelect:t,onFocusChange:n,focusable:i,imageFallback:r,soldOut:o}){let c=d=>{d.metaKey||d.ctrlKey||d.shiftKey||d.altKey||d.button!==0||(d.preventDefault(),t(e))};return(0,Q.jsxs)("a",{id:a,className:oe.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:c,onKeyDown:d=>{d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),t(e))},onFocus:()=>n?.(!0),onBlur:d=>{d.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[(0,Q.jsx)(ha,{sources:(0,pe.productImageSources)(e.imageUrl),title:e.title,fallback:r},(0,pe.productImageSrc)(e.imageUrl)??""),(0,Q.jsxs)("span",{className:oe.body,children:[e.vendor?(0,Q.jsx)("span",{className:oe.vendor,children:e.vendor}):null,(0,Q.jsx)("span",{className:oe.title,children:e.title}),e.price?(0,Q.jsx)("span",{className:oe.price,children:e.price}):null,e.available===!1?(0,Q.jsx)("span",{className:oe.badge,children:o}):null]})]})}function ha({sources:e,title:a,fallback:t}){let[n,i]=(0,Ge.useState)(0),r=e[n],o=!!r,c=!o&&t==="initial";return(0,Q.jsxs)("span",{className:oe.media,"aria-hidden":"true","data-aia-product-placeholder":!o&&!c?"":void 0,"data-aia-product-initial":c?"":void 0,children:[o?(0,Q.jsx)("img",{className:oe.image,src:r,alt:"",loading:"lazy",decoding:"async",onError:()=>i(d=>d+1)}):null,c?(0,pe.productInitial)(a):null]})}var Y=require("@magicx-eng/ai-autocomplete-vanilla"),me=require("react");var Rt=require("@magicx-eng/ai-autocomplete-vanilla"),at=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 {
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 Y=require("react/jsx-runtime");function Mt({products:e,listboxId:a,onSelect:t,onFocusChange:n,focusable:i=!0,layout:r="row",imageFallback:o="image",strings:h=(0,ce.uiStringsFor)()}){let d=e.length>0,w=(0,qe.useRef)(null);if((0,qe.useEffect)(()=>{let I=w.current;if(!(!d||!I))return(0,ce.attachProductRowWheel)(I)},[d]),!d)return null;let E=`${a}-products-label`;return(0,Y.jsxs)("section",{className:ae.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":E,children:[(0,Y.jsx)("div",{className:ae.label,id:E,"data-aia-products-label":"",children:h.products}),(0,Y.jsx)("div",{ref:w,className:ae.row,"data-aia-products-row":"",children:e.map((I,g)=>(0,Y.jsx)(ma,{product:I,id:`${a}-product-${g}`,onSelect:t,onFocusChange:n,focusable:i,imageFallback:o,soldOut:h.soldOut},I.id))})]})}function ma({product:e,id:a,onSelect:t,onFocusChange:n,focusable:i,imageFallback:r,soldOut:o}){let h=d=>{d.metaKey||d.ctrlKey||d.shiftKey||d.altKey||d.button!==0||(d.preventDefault(),t(e))};return(0,Y.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:h,onKeyDown:d=>{d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),t(e))},onFocus:()=>n?.(!0),onBlur:d=>{d.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[(0,Y.jsx)(ga,{sources:(0,ce.productImageSources)(e.imageUrl),title:e.title,fallback:r},(0,ce.productImageSrc)(e.imageUrl)??""),(0,Y.jsxs)("span",{className:ae.body,children:[e.vendor?(0,Y.jsx)("span",{className:ae.vendor,children:e.vendor}):null,(0,Y.jsx)("span",{className:ae.title,children:e.title}),e.price?(0,Y.jsx)("span",{className:ae.price,children:e.price}):null,e.available===!1?(0,Y.jsx)("span",{className:ae.badge,children:o}):null]})]})}function ga({sources:e,title:a,fallback:t}){let[n,i]=(0,qe.useState)(0),r=e[n],o=!!r,h=!o&&t==="initial";return(0,Y.jsxs)("span",{className:ae.media,"aria-hidden":"true","data-aia-product-placeholder":!o&&!h?"":void 0,"data-aia-product-initial":h?"":void 0,children:[o?(0,Y.jsx)("img",{className:ae.image,src:r,alt:"",loading:"lazy",decoding:"async",onError:()=>i(d=>d+1)}):null,h?(0,ce.productInitial)(a):null]})}var Z=require("@magicx-eng/ai-autocomplete-vanilla"),me=require("react");var Nt=require("@magicx-eng/ai-autocomplete-vanilla"),st=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 Dt=require("react/jsx-runtime");function Ot({min:e="16rem",max:a,gap:t,scroll:n=!1,maxHeight:i,scrollResetKey:r,cols:o,template:c,innerRef:d,className:x,children:P,...S}){let g=(0,at.useRef)(null);(0,at.useLayoutEffect)(()=>{if(r===void 0)return;let A=g.current;A&&(A.scrollTop=0)},[r]);let v={"--aia-grid-min":e};return a&&(v["--aia-grid-max"]=a),t&&(v["--aia-grid-gap"]=t),i&&(v["--aia-grid-max-height"]=i),o&&(v.gridTemplateColumns=(0,Rt.optionsGridTemplateColumns)(o)),c&&(v.gridTemplateColumns=c),(0,Dt.jsx)("div",{ref:A=>{g.current=A,d?.(A)},className:x?`aia-grid ${x}`:"aia-grid","data-scroll":n||void 0,style:v,...S,children:P})}var ge=require("@magicx-eng/ai-autocomplete-vanilla"),ue=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 {
1804
+ `,document.head.appendChild(e)}var Ht=require("react/jsx-runtime");function Bt({min:e="16rem",max:a,gap:t,scroll:n=!1,maxHeight:i,scrollResetKey:r,cols:o,template:h,innerRef:d,className:w,children:E,...I}){let g=(0,st.useRef)(null);(0,st.useLayoutEffect)(()=>{if(r===void 0)return;let T=g.current;T&&(T.scrollTop=0)},[r]);let v={"--aia-grid-min":e};return a&&(v["--aia-grid-max"]=a),t&&(v["--aia-grid-gap"]=t),i&&(v["--aia-grid-max-height"]=i),o&&(v.gridTemplateColumns=(0,Nt.optionsGridTemplateColumns)(o)),h&&(v.gridTemplateColumns=h),(0,Ht.jsx)("div",{ref:T=>{g.current=T,d?.(T)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":n||void 0,style:v,...I,children:E})}var ue=require("@magicx-eng/ai-autocomplete-vanilla"),he=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 X={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 he=require("react/jsx-runtime");function Lt({option:e,isHighlighted:a,onSelect:t,onHighlight:n,onUnhighlight:i,id:r,loading:o,showIcon:c=!0,showImage:d=!0,showCount:x=!0,scrollHint:P,enterDelayMs:S=0}){let[g]=(0,ue.useState)(S),[v,A]=(0,ue.useState)(!1),B=d?(0,ge.optionImageSources)(e.image_url):[],H=B[0]??null,[j,R]=(0,ue.useState)([]),T=B.find(W=>!j.includes(W))??null,F=(0,ue.useMemo)(()=>!H&&c&&e.icon_svg?(0,ge.sanitizeOptionIconSvg)(e.icon_svg):null,[H,c,e.icon_svg]),K=x?(0,ge.formatOptionCount)(e.item_count):null,y=(0,ue.useRef)(void 0);(0,ue.useEffect)(()=>()=>clearTimeout(y.current),[]);let G=()=>{o||!e.is_tappable||v||(A(!0),t(e),clearTimeout(y.current),y.current=setTimeout(()=>A(!1),170))},re=[X.item,a&&!o?X.highlighted:"",e.is_tappable?X.tappable:X.nonTappable,v?X.pressed:"",P?X.scrollHint:""].filter(Boolean).join(" ");return(0,he.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:re,style:{[ge.OPTION_ENTER_DELAY_VAR]:`${g}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,he.jsxs)("span",{className:X.content,children:[H&&(0,he.jsx)("span",{className:`${X.image} magicx-aia-option-image`,"aria-hidden":"true",children:(0,he.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,he.jsx)("span",{className:`${X.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:F}}),(0,he.jsx)("span",{className:X.text,children:(0,ge.optionLabel)(e)}),e.tag&&(0,he.jsx)("span",{className:X.tag,children:e.tag}),K!==null&&(0,he.jsx)("span",{className:`${X.count} magicx-aia-option-count`,children:K})]})})}var mt=require("react/jsx-runtime");function ua(){let[e,a]=(0,me.useState)(Y.isOptionsGridMobileViewport);return(0,me.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 zt({options:e,activeIndex:a,onSelect:t,onHighlight:n,onUnhighlight:i,listboxId:r,loading:o,groupKey:c="",optionsPosition:d="below",showIcons:x=!0,showImages:P=!0,showCounts:S=!0}){let g=ua(),v=(0,me.useRef)(null),[A,B]=(0,me.useState)(null),H=(0,me.useRef)(null);(0,me.useLayoutEffect)(()=>{if(o&&(0,Y.sameOptionRows)(H.current,e))return;H.current=o?null:e;let R=v.current,F=R&&!o&&(0,Y.needsOptionsGridMeasurement)(e.length,g)?(0,Y.measureOptionsGrid)(R):null;B(F?(0,Y.planOptionsGrid)(e.length,g,F.rowWidths,F.gridWidth):null)},[e,g,o]);let j=A??(0,Y.planOptionsGrid)(e.length,g,null,null);return(0,mt.jsx)(Ot,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:c,template:j.template,maxHeight:j.maxHeight,innerRef:R=>{v.current=R},"data-aia-group":c,children:e.map((R,T)=>(0,mt.jsx)(Lt,{option:R,isHighlighted:T===a,onSelect:t,onHighlight:()=>n(T),onUnhighlight:i?()=>i(T):void 0,id:`${r}-option-${T}`,loading:o,showIcon:x,showImage:P,showCount:S,scrollHint:!o&&j.scrollHintIndices.includes(T),enterDelayMs:o?0:(0,Y.optionEnterDelayMs)(T,j.cols,e.length,d)},`${c}\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 {
2201
+ `,document.head.appendChild(e)}var J={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 pe=require("react/jsx-runtime");function Ft({option:e,isHighlighted:a,onSelect:t,onHighlight:n,onUnhighlight:i,id:r,loading:o,showIcon:h=!0,showImage:d=!0,showCount:w=!0,scrollHint:E,enterDelayMs:I=0}){let[g]=(0,he.useState)(I),[v,T]=(0,he.useState)(!1),B=d?(0,ue.optionImageSources)(e.image_url):[],H=B[0]??null,[q,z]=(0,he.useState)([]),A=B.find(G=>!q.includes(G))??null,U=(0,he.useMemo)(()=>!H&&h&&e.icon_svg?(0,ue.sanitizeOptionIconSvg)(e.icon_svg):null,[H,h,e.icon_svg]),F=w?(0,ue.formatOptionCount)(e.item_count):null,P=(0,he.useRef)(void 0);(0,he.useEffect)(()=>()=>clearTimeout(P.current),[]);let K=()=>{o||!e.is_tappable||v||(T(!0),t(e),clearTimeout(P.current),P.current=setTimeout(()=>T(!1),170))},j=[J.item,a&&!o?J.highlighted:"",e.is_tappable?J.tappable:J.nonTappable,v?J.pressed:"",E?J.scrollHint:""].filter(Boolean).join(" ");return(0,pe.jsx)("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":o?"":void 0,"data-aia-icon":U&&e.icon?e.icon:void 0,"data-aia-image":H?"":void 0,"data-aia-item-count":F!==null?e.item_count:void 0,"aria-selected":a,className:j,style:{[ue.OPTION_ENTER_DELAY_VAR]:`${g}ms`},tabIndex:o||!e.is_tappable?-1:0,onClick:K,onKeyDown:G=>{!o&&e.is_tappable&&(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),K())},onMouseEnter:!o&&e.is_tappable?n:void 0,onMouseLeave:i,children:(0,pe.jsxs)("span",{className:J.content,children:[H&&(0,pe.jsx)("span",{className:`${J.image} magicx-aia-option-image`,"aria-hidden":"true",children:(0,pe.jsx)("img",{src:A??H,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:A===null,onError:()=>{A!==null&&z(G=>[...G,A])}})}),U&&(0,pe.jsx)("span",{className:`${J.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:U}}),(0,pe.jsx)("span",{className:J.text,children:(0,ue.optionLabel)(e)}),e.tag&&(0,pe.jsx)("span",{className:J.tag,children:e.tag}),F!==null&&(0,pe.jsx)("span",{className:`${J.count} magicx-aia-option-count`,children:F})]})})}var xt=require("react/jsx-runtime");function fa(){let[e,a]=(0,me.useState)(Z.isOptionsGridMobileViewport);return(0,me.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Z.OPTIONS_GRID_MOBILE_QUERY),n=()=>a(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]),e}function Kt({options:e,activeIndex:a,onSelect:t,onHighlight:n,onUnhighlight:i,listboxId:r,loading:o,groupKey:h="",optionsPosition:d="below",showIcons:w=!0,showImages:E=!0,showCounts:I=!0}){let g=fa(),v=(0,me.useRef)(null),[T,B]=(0,me.useState)(null),H=(0,me.useRef)(null);(0,me.useLayoutEffect)(()=>{if(o&&(0,Z.sameOptionRows)(H.current,e))return;H.current=o?null:e;let z=v.current,U=z&&!o&&(0,Z.needsOptionsGridMeasurement)(e.length,g)?(0,Z.measureOptionsGrid)(z):null;B(U?(0,Z.planOptionsGrid)(e.length,g,U.rowWidths,U.gridWidth):null)},[e,g,o]);let q=T??(0,Z.planOptionsGrid)(e.length,g,null,null);return(0,xt.jsx)(Bt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:h,template:q.template,maxHeight:q.maxHeight,innerRef:z=>{v.current=z},"data-aia-group":h,children:e.map((z,A)=>(0,xt.jsx)(Ft,{option:z,isHighlighted:A===a,onSelect:t,onHighlight:()=>n(A),onUnhighlight:i?()=>i(A):void 0,id:`${r}-option-${A}`,loading:o,showIcon:w,showImage:E,showCount:I,scrollHint:!o&&q.scrollHintIndices.includes(A),enterDelayMs:o?0:(0,Z.optionEnterDelayMs)(A,q.cols,e.length,d)},`${h}\0${z.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 Nt=require("react/jsx-runtime");function Mt({space:e,align:a="stretch",className:t,children:n,...i}){let r=e?{"--aia-stack-space":e}:void 0;return(0,Nt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:r,...i,children:n})}var q=require("react/jsx-runtime"),ga=[159,119,164],ma=()=>{},Bt=()=>{};function fa(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,n]=(0,ne.useState)(a);if((0,ne.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 ba(e,a){let t=(0,ne.useRef)(null);(0,ne.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,ne.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function it({suggestions:e,activeIndex:a,onSelect:t,onHighlight:n,onUnhighlight:i,isOpen:r,id:o,className:c,pills:d,onPillClick:x,showPills:P=!0,onSkip:S,showSkipButton:g=!0,showOptionIcons:v=!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:y,onProductSelect:G,onProductFocusChange:re,productsLayout:W="row",productImageFallback:Se="image",formatType:fe="options",dateView:J=null,selectedDateIso:Ie=null,selectedDateRange:f=null,dateRangeStart:Ne=null,onPreviousMonth:Ee,onNextMonth:Te,optionsPosition:be="below",mode:Ae}){let ve=fa(Ae),le=ve!==void 0,ee=(0,ne.useRef)(null),we=(0,ne.useRef)(null);ba(ee,we),(0,ne.useEffect)(()=>{if(ee.current)return(0,ze.containScroll)(ee.current)},[]);let l=e[0]?.options??[],m=!!(d&&d.length>0&&x),w=!!(y&&y.length>0),b=r&&(l.length>0||P&&m||R||w),k={suggestions:e,activeIndex:a,pills:d,showPills:P,showSkipButton:g,showOptionIcons:v,showOptionImages:A,showOptionCounts:B,skipDisabled:H,activeSelected:j,isLoading:R,skeletonExiting:T,isInputEmpty:F,products:y,formatType:fe,dateView:J,selectedDateIso:Ie,selectedDateRange:f,dateRangeStart:Ne},L=(0,ne.useRef)(k);b&&(L.current=k);let p=b?k:L.current,_=(0,ze.uiStringsFor)(K),te=p.suggestions[0],ae=te?.options??[],C=p.activeIndex>=0&&!!ae[p.activeIndex]?.is_tappable,xe=!!(p.pills&&p.pills.length>0&&x),_e=p.showPills&&xe,Re=p.showPills&&!xe&&p.isLoading,h=_e||Re,ye=xe&&p.showSkipButton&&!p.isInputEmpty&&!!S,Be=p.pills?.[0]?.text,Oe=(0,ze.isCalendarFormat)(p.formatType)&&p.dateView!=null,Fe=ae.length>0&&!Oe,ke=ae.length>0&&Oe&&!p.isLoading,qe=p.isLoading&&!Fe&&!ke,$=p.products??[];return(0,q.jsxs)("div",{ref:ee,id:o,role:"listbox","data-aia-dropdown":"","data-options-position":be,"data-mode":ve,"data-aia-loading":p.isLoading?"":void 0,"data-aia-skeleton-exiting":p.skeletonExiting?"":void 0,"data-aia-has-products":$.length>0?"":void 0,className:`${le?"magicx-aia ":""}${Ce.dropdown} ${b?Ce.visible:""} ${c??""}`,onMouseDown:V=>V.preventDefault(),children:[(0,q.jsxs)(Mt,{space:"8px",children:[(h||ye)&&(0,q.jsxs)(Qe,{noWrap:!0,className:Ce.pillBar,"data-aia-pillbar":"",children:[h&&(0,q.jsx)("span",{className:Ce.pillScroll,"data-aia-pill-scroll":"",children:(0,q.jsx)(tt,{pills:p.pills??[],activePillIndex:0,activeSelected:p.activeSelected,onSelectPill:x??(()=>{}),rounded:!0,loading:p.isLoading})}),ye&&(0,q.jsx)("button",{type:"button",tabIndex:-1,className:Ce.skip,"data-aia-skip":"",disabled:p.isLoading||p.skipDisabled,"aria-label":Be?`${_.skipLabel} ${Be}`:_.skipLabel,onClick:S,children:_.skip})]}),Fe&&(0,q.jsx)(zt,{options:ae,activeIndex:p.activeIndex,onSelect:t,onHighlight:n,onUnhighlight:i,listboxId:o,loading:p.isLoading,groupKey:te?`${te.parameter} ${te.text}`:"",optionsPosition:be,showIcons:p.showOptionIcons,showImages:p.showOptionImages,showCounts:p.showOptionCounts}),ke&&p.dateView&&(0,q.jsx)(Pt,{options:ae,activeIndex:p.activeIndex,listboxId:o,view:p.dateView,selection:{selectedIso:p.selectedDateIso??null,selectedRange:p.selectedDateRange??null,rangeStart:p.dateRangeStart??null},onSelect:t,onHighlight:n,onUnhighlight:i,onPreviousMonth:Ee??Bt,onNextMonth:Te??Bt}),qe&&(0,q.jsx)("div",{className:Ce.skeletonBars,"data-aia-skeleton-bars":"",children:ga.map(V=>(0,q.jsx)("span",{className:Ce.skeletonBar,style:{width:V}},`bar-${V}`))}),(0,q.jsx)(At,{products:$,listboxId:o,onSelect:G??ma,onFocusChange:re,focusable:b,layout:W,imageFallback:Se,strings:_}),(0,q.jsx)(St,{isOptionHighlighted:C,isInputEmpty:p.isInputEmpty,strings:_})]}),(0,q.jsx)("button",{ref:we,type:"button",tabIndex:-1,className:Ce.scrollArrow,"data-aia-scroll-arrow":"","aria-label":_.scrollArrow,"aria-hidden":"true",children:(0,q.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,q.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Me=require("@magicx-eng/ai-autocomplete-vanilla");var Ft=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 {
2216
+ `,document.head.appendChild(e)}var Wt=require("react/jsx-runtime");function Gt({space:e,align:a="stretch",className:t,children:n,...i}){let r=e?{"--aia-stack-space":e}:void 0;return(0,Wt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:r,...i,children:n})}var W=require("react/jsx-runtime"),ba=[159,119,164],va=()=>{},_t=()=>{};function wa(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 xa(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,Ne.attachScrollArrow)({dropdown:n,grid:r,button:i})};return}t.current?.controller.update()}),(0,ie.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function lt({suggestions:e,activeIndex:a,onSelect:t,onHighlight:n,onUnhighlight:i,isOpen:r,id:o,className:h,pills:d,onPillClick:w,showPills:E=!0,onSkip:I,showSkipButton:g=!0,showOptionIcons:v=!0,showOptionImages:T=!0,showOptionCounts:B=!0,skipDisabled:H=!1,activeSelected:q=!1,isLoading:z=!1,skeletonExiting:A=!1,isInputEmpty:U=!1,language:F,products:P,onProductSelect:K,onProductFocusChange:j,productsLayout:G="row",productImageFallback:ge="image",formatType:ye="options",dateView:$=null,selectedDateIso:ke=null,selectedDateRange:He=null,dateRangeStart:Ce=null,onPreviousMonth:m,onNextMonth:Fe,optionsPosition:fe="below",mode:Pe}){let be=wa(Pe),Se=be!==void 0,oe=(0,ie.useRef)(null),ne=(0,ie.useRef)(null);xa(oe,ne),(0,ie.useEffect)(()=>{if(oe.current)return(0,Ne.containScroll)(oe.current)},[]);let l=e[0]?.options??[],f=!!(d&&d.length>0&&w),b=!!(P&&P.length>0),x=r&&(l.length>0||E&&f||z||b),k={suggestions:e,activeIndex:a,pills:d,showPills:E,showSkipButton:g,showOptionIcons:v,showOptionImages:T,showOptionCounts:B,skipDisabled:H,activeSelected:q,isLoading:z,skeletonExiting:A,isInputEmpty:U,products:P,formatType:ye,dateView:$,selectedDateIso:ke,selectedDateRange:He,dateRangeStart:Ce},R=(0,ie.useRef)(k);x&&(R.current=k);let p=x?k:R.current,Q=(0,Ne.uiStringsFor)(F),ee=p.suggestions[0],te=ee?.options??[],Ie=p.activeIndex>=0&&!!te[p.activeIndex]?.is_tappable,Ee=!!(p.pills&&p.pills.length>0&&w),Te=p.showPills&&Ee,Ae=p.showPills&&!Ee&&p.isLoading,Re=Te||Ae,y=Ee&&p.showSkipButton&&!p.isInputEmpty&&!!I,Oe=p.pills?.[0]?.text,De=(0,Ne.isCalendarFormat)(p.formatType)&&p.dateView!=null,ve=te.length>0&&!De,u=te.length>0&&De&&!p.isLoading,_e=p.isLoading&&!ve&&!u,Ue=p.products??[];return(0,W.jsxs)("div",{ref:oe,id:o,role:"listbox","data-aia-dropdown":"","data-options-position":fe,"data-mode":be,"data-aia-loading":p.isLoading?"":void 0,"data-aia-skeleton-exiting":p.skeletonExiting?"":void 0,"data-aia-has-products":Ue.length>0?"":void 0,className:`${Se?"magicx-aia ":""}${we.dropdown} ${x?we.visible:""} ${h??""}`,onMouseDown:se=>se.preventDefault(),children:[(0,W.jsxs)(Gt,{space:"8px",children:[(Re||y)&&(0,W.jsxs)(Ve,{noWrap:!0,className:we.pillBar,"data-aia-pillbar":"",children:[Re&&(0,W.jsx)("span",{className:we.pillScroll,"data-aia-pill-scroll":"",children:(0,W.jsx)(rt,{pills:p.pills??[],activePillIndex:0,activeSelected:p.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:p.isLoading})}),y&&(0,W.jsx)("button",{type:"button",tabIndex:-1,className:we.skip,"data-aia-skip":"",disabled:p.isLoading||p.skipDisabled,"aria-label":Oe?`${Q.skipLabel} ${Oe}`:Q.skipLabel,onClick:I,children:Q.skip})]}),ve&&(0,W.jsx)(Kt,{options:te,activeIndex:p.activeIndex,onSelect:t,onHighlight:n,onUnhighlight:i,listboxId:o,loading:p.isLoading,groupKey:ee?`${ee.parameter} ${ee.text}`:"",optionsPosition:fe,showIcons:p.showOptionIcons,showImages:p.showOptionImages,showCounts:p.showOptionCounts}),u&&p.dateView&&(0,W.jsx)(Rt,{options:te,activeIndex:p.activeIndex,listboxId:o,view:p.dateView,selection:{selectedIso:p.selectedDateIso??null,selectedRange:p.selectedDateRange??null,rangeStart:p.dateRangeStart??null},onSelect:t,onHighlight:n,onUnhighlight:i,onPreviousMonth:m??_t,onNextMonth:Fe??_t}),_e&&(0,W.jsx)("div",{className:we.skeletonBars,"data-aia-skeleton-bars":"",children:ba.map(se=>(0,W.jsx)("span",{className:we.skeletonBar,style:{width:se}},`bar-${se}`))}),(0,W.jsx)(Mt,{products:Ue,listboxId:o,onSelect:K??va,onFocusChange:j,focusable:x,layout:G,imageFallback:ge,strings:Q}),(0,W.jsx)(Ot,{isOptionHighlighted:Ie,isInputEmpty:p.isInputEmpty,strings:Q})]}),(0,W.jsx)("button",{ref:ne,type:"button",tabIndex:-1,className:we.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Q.scrollArrow,"aria-hidden":"true",children:(0,W.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,W.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Be=require("@magicx-eng/ai-autocomplete-vanilla");var qt=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 Ut={submitButton:"aia-submitButton-otz7H"};var dt=require("react/jsx-runtime");function jt({disabled:e,onClick:a,label:t=(0,qt.uiStringsFor)().submit}){return(0,dt.jsx)("button",{type:"button","data-aia-submit":"",className:Ut.submitButton,disabled:e,onClick:n=>{n.stopPropagation(),a()},"aria-label":t,children:(0,dt.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:(0,dt.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var je=require("@magicx-eng/ai-autocomplete-vanilla"),C=require("react");var yt=require("react");function Qt(e){let a=(0,yt.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),n=(0,yt.useRef)({key:"",overrides:void 0});if(n.current.key!==t){let i={};for(let r of Object.keys(e??{})){let o=(h,d,w)=>{let E=a.current?.[r];return E?E(h,d,w):[]};i[r]=o}n.current={key:t,overrides:e?i:void 0}}return{overrides:n.current.overrides,key:t}}var kt=require("react");function Yt(e){let a=(0,kt.useRef)(e);a.current=e;let t=(0,kt.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 ya={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 ct({onSubmit:e,onResult:a,onError:t,optionOverrides:n,maskCompletedText:i,apiConfig:r,additionalContext:o,language:h,productId:d,visitorId:w,columns:E=2,dropdownTrigger:I,optionsPosition:g,closeDropdownOnBlur:v,showNonTappableOptions:T,showOptionIcons:B,showOptionImages:H,showOptionCounts:q,showSkipButton:z,showProducts:A,productImageFallback:U="image",onFocus:F,onBlur:P,value:K,completedParams:j,onChange:G,onParamsChange:ge,products:ye,mapProducts:$,onProductSelect:ke,source:He,setCursor:Ce}){let m=(0,C.useRef)(null),[Fe,fe]=(0,C.useState)(null),Pe=(0,C.useRef)(e);Pe.current=e;let be=(0,C.useRef)(a);be.current=a;let Se=(0,C.useRef)(t);Se.current=t;let oe=(0,C.useRef)(G);oe.current=G;let ne=(0,C.useRef)(ge);ne.current=ge;let l=(0,C.useRef)(F);l.current=F;let f=(0,C.useRef)(P);f.current=P;let b=(0,C.useRef)(Ce);b.current=Ce;let x=(0,C.useRef)(ke);x.current=ke;let k=(0,C.useRef)(w);k.current=w;let R=(0,C.useRef)(()=>{let c=k.current;return typeof c=="function"?c():c}).current,p=Yt(ye),Q=(0,C.useRef)($);Q.current=$;let ee=(0,C.useRef)((c,V)=>{let O=Q.current;return O?O(c,V):c}).current,te=$?ee:void 0,Ie=Qt(n);(0,C.useEffect)(()=>{if(typeof document>"u")return;let c=new je.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:o,language:h,productId:d,visitorId:R,optionOverrides:Ie.overrides,maskCompletedText:i,columns:E,dropdownTrigger:I,optionsPosition:g,closeDropdownOnBlur:v,showNonTappableOptions:T,showProducts:A,source:He,value:K,completedParams:j,onSubmit:(...O)=>Pe.current?.(...O),onResult:(...O)=>be.current?.(...O),onError:(...O)=>Se.current?.(...O),onChange:(...O)=>oe.current?.(...O),onParamsChange:(...O)=>ne.current?.(...O),onFocus:()=>l.current?.(),onBlur:()=>f.current?.(),onProductSelect:O=>x.current?.(O),setCursor:O=>b.current?.(O),products:p.config,mapProducts:te});m.current=c,fe(c.getState());let V=c.subscribe(O=>fe(O));return()=>{V(),c.destroy(),m.current===c&&(m.current=null)}},[]),(0,C.useEffect)(()=>{K!==void 0&&m.current?.setValue(K)},[K]),(0,C.useEffect)(()=>{j!==void 0&&m.current?.setCompletedParams(j)},[j]);let Ee=JSON.stringify(r??null),Te;try{Te=JSON.stringify(o??null)}catch{Te="[unstringifiable]"}(0,C.useEffect)(()=>{m.current?.update({apiConfig:r,additionalContext:o,language:h,productId:d,optionOverrides:Ie.overrides,dropdownTrigger:I,optionsPosition:g,closeDropdownOnBlur:v,showNonTappableOptions:T,showProducts:A})},[Ee,Te,h,d,Ie.key,I,g,v,T,A]);let Ae=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!Ae.current){Ae.current=!0;return}m.current?.update({products:p.config})},[p.enabled]),(0,C.useEffect)(()=>{m.current?.update({mapProducts:te})},[te]);let Re=(0,C.useRef)(null);Re.current===null&&(Re.current={handleTextChange:c=>m.current?.handleTextChange(c),handleKeyDown:c=>{let V="nativeEvent"in c?c.nativeEvent:c;m.current?.handleKeyDown(V)},setFocused:c=>m.current?.setFocused(c),startEditingParam:c=>m.current?.startEditingParam(c),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:c=>m.current?.handleCaretAfterInput(c),handleCaretMove:c=>m.current?.handleCaretMove(c),replaceEditingRange:c=>m.current?.replaceEditingRange(c)??!1,setActivePill:c=>m.current?.setActivePill(c),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),refreshProducts:()=>m.current?.refreshProducts(),recordSubmit:c=>m.current?.recordSubmit(c),selectOption:c=>m.current?.selectOption(c),selectProduct:c=>m.current?.selectProduct(c),setActiveDropdownIndex:c=>m.current?.setActiveDropdownIndex(c),clearHighlight:c=>m.current?.clearHighlight(c),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let y=Re.current,Oe=(0,C.useCallback)(c=>{let V=c.target.value,ut=V.length>0&&!c.nativeEvent?.isComposing&&V[0]!==V[0].toUpperCase()?V[0].toUpperCase()+V.slice(1):V;m.current?.handleTextChange(ut)},[]),De=(0,C.useCallback)(c=>{m.current?.handleKeyDown(c.nativeEvent)},[]),ve=m.current,u=Fe??ya,_e=K!==void 0?K:u.text,Ue=j!==void 0?j:u.completedParams,se=u.actionableSuggestions,Qe=se[0],Ke=ve?.listboxId??"",Je=u.activeDropdownIndex>=0&&ve?`${Ke}-option-${u.activeDropdownIndex}`:void 0,Le=u.editingParam,Ge=u.editingIdentified,Ye=Le?{parameter:Le.suggestionParameter,text:Le.suggestionPlaceholder,required:!0,options:Le.options}:Ge?{parameter:Ge.parameter,text:(0,je.identifiedParamLabel)(Ge.parameter),required:!0,options:[]}:null,et=u.dropdownSuggestion??Ye??Qe,ht=Ye?[Ye]:se,Ze=(0,je.dateSelectionFor)(u),tt=!ve||u.dropdownLoading;return{completedParams:Ue,skippedParams:u.skippedParams,identifiedParams:u.identifiedParams,suggestionPills:se,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:tt,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:Le,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:_e,placeholder:u.placeholderText||void 0,onChange:Oe,onKeyDown:De,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":u.isDropdownOpen,"aria-activedescendant":Je,"aria-autocomplete":"list","aria-controls":Ke},reset:y.reset,refreshProducts:y.refreshProducts,recordSubmit:y.recordSubmit,dropdownProps:{suggestions:et?[{...et,options:u.dropdownOptions}]:[],activeIndex:u.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,onUnhighlight:y.clearHighlight,isOpen:u.isDropdownOpen,id:Ke,pills:ht,activeSelected:u.isActivePillSelected,onPillClick:y.setActivePill,onSkip:y.skipActivePill,showSkipButton:(z??!0)&&!Le&&!Ge,showOptionIcons:B??!0,showOptionImages:H??!0,showOptionCounts:q??!0,skipDisabled:u.inSelectionAnimation,isLoading:tt,skeletonExiting:u.skeletonExiting,isInputEmpty:_e.trim().length===0,language:h,products:u.products,productImageFallback:U,onProductSelect:y.selectProduct,onProductFocusChange:y.setFocused,formatType:u.activeFormatType,dateView:u.dateView,selectedDateIso:Ze.selectedIso,selectedDateRange:Ze.selectedRange,dateRangeStart:Ze.rangeStart,onPreviousMonth:y.showPreviousMonth,onNextMonth:y.showNextMonth,optionsPosition:g??"below"}}}var _=require("@magicx-eng/ai-autocomplete-vanilla"),S=require("react"),pt;function ka(){if(pt!==void 0)return pt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),pt=e.contentEditable==="plaintext-only",pt}function Zt(e){let{segments:a,showChipIcons:t=!0,showChipImages:n=!0,newParamId:i,editingParam:r,editingIdentified:o,editingAnchor:h,caretOffset:d,placeholderText:w,isFocused:E,isDropdownOpen:I,listboxId:g,activeDescendantId:v,autoFocus:T,handleTextChange:B,handleKeyDown:H,handleCaretAfterInput:q,handleCaretMove:z,startEditingParam:A,replaceEditingRange:U,setFocused:F}=e,P=(0,S.useRef)(null),K=(0,S.useRef)(!1),j=(0,S.useRef)(""),G=(0,S.useRef)(""),ge=(0,S.useRef)(null),ye=(0,S.useRef)(0);ge.current=d,(0,S.useEffect)(()=>{if(!T)return;let l=P.current;if(!l)return;document.activeElement===l?F(!0):l.focus();let f=l.ownerDocument??document,b=f.getSelection(),x=b&&b.rangeCount>0&&l.contains(b.anchorNode);if(b&&!x){let k=f.createRange();k.selectNodeContents(l),k.collapse(!0),b.removeAllRanges(),b.addRange(k)}},[T,F]),(0,S.useEffect)(()=>{let l=P.current;if(!l)return;let f=l.ownerDocument??document,b=()=>{let x=f.getSelection();if(!x||x.rangeCount===0||!x.anchorNode||!l.contains(x.anchorNode))return;let k=x.anchorNode,R=k.nodeType===Node.ELEMENT_NODE?k:k.parentElement,Q=(x.isCollapsed?R?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ee=r?.id??o?.id??null;if(Q&&Q!==ee){A(Q);return}performance.now()-ye.current<50||z((0,_.getCursorOffset)(l))};return f.addEventListener("selectionchange",b),()=>f.removeEventListener("selectionchange",b)},[r,o,A,z]),(0,S.useEffect)(()=>{let l=P.current;if(!l)return;let f=b=>{let x=(0,_.chipIdFromTap)(l,b.target);x&&(A(x),(0,_.keepCaretOnChip)(l,x))};return l.addEventListener("click",f),()=>l.removeEventListener("click",f)},[A]),(0,S.useLayoutEffect)(()=>{let l=P.current;l&&(0,_.renderEditableContent)({input:l,segments:a,newParamId:i,editingParamId:r?.id??null,placeholderText:w??"",isFocused:E,showChipIcons:t,showChipImages:n})},[a,i,r,w,E,t,n]),(0,S.useLayoutEffect)(()=>{let l=j.current,f=i??"";if(j.current=f,!f||f===l)return;let b=P.current;if(!b)return;b.focus();let x=ge.current??(0,_.plainTextLength)(b);(0,_.setCursorOffset)(b,x)},[i]),(0,S.useLayoutEffect)(()=>{let l=G.current,f=r?.id??"";if(G.current=f,!f||f===l||h==null)return;let b=P.current;b&&(0,_.setCursorOffset)(b,h)},[r,h]);let $=(0,S.useCallback)(()=>{if(K.current)return;let l=P.current;if(!l)return;let f=(0,_.extractPlainText)(l),x=f.length>0&&f[0]!==f[0].toUpperCase()?f[0].toUpperCase()+f.slice(1):f;B(x)},[B]),ke=(0,S.useCallback)(()=>{ye.current=performance.now(),$();let l=P.current;l&&q((0,_.getCursorOffset)(l))},[$,q]);(0,S.useEffect)(()=>{let l=P.current;if(!l)return;let f=b=>{let x=b,k=x.inputType;if(k==="insertParagraph"||k==="insertLineBreak"||k==="insertFromDrop"){b.preventDefault();return}if(k.startsWith("insert")||k.startsWith("delete")){let R=k.startsWith("delete")?"":x.data??"";U(R)&&b.preventDefault()}};return l.addEventListener("beforeinput",f),()=>l.removeEventListener("beforeinput",f)},[U]);let He=(0,S.useCallback)(()=>{K.current=!0},[]),Ce=(0,S.useCallback)(()=>{K.current=!1,$()},[$]),m=(0,S.useCallback)(l=>{l.preventDefault();let f=P.current;if(!f)return;let b=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let x=f.ownerDocument??document,k=x.getSelection();if(!k||k.rangeCount===0)return;let R=k.getRangeAt(0);if(!f.contains(R.startContainer))return;R.deleteContents();let p=x.createTextNode(b);R.insertNode(p),R.setStartAfter(p),R.collapse(!0),k.removeAllRanges(),k.addRange(R),$()},[$]),Fe=(0,S.useCallback)(l=>H(l),[H]),fe=(0,S.useCallback)(()=>F(!0),[F]),Pe=(0,S.useCallback)(()=>F(!1),[F]),be=(0,S.useCallback)(()=>P.current?.focus(),[]),Se=(0,S.useCallback)(()=>P.current?.blur(),[]),oe=(0,S.useCallback)(()=>{let l=P.current;return l?(0,_.extractPlainText)(l):""},[]),ne=ka()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:ne,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":g,"aria-expanded":I,"aria-activedescendant":v,spellCheck:!0,enterKeyHint:"send",onInput:ke,onKeyDown:Fe,onCompositionStart:He,onCompositionEnd:Ce,onPaste:m,onFocus:fe,onBlur:Pe},getPlainText:oe,focus:be,blur:Se}}var re=require("react/jsx-runtime");function Ca(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var $t=(0,N.forwardRef)(function({onSubmit:a,onResult:t,onError:n,optionOverrides:i,maskCompletedText:r,className:o,apiConfig:h,additionalContext:d,language:w,productId:E,visitorId:I,columns:g,pillPlacement:v="dropdown",mode:T="auto",optionsPosition:B="below",animations:H=!0,dropdownTrigger:q,closeDropdownOnBlur:z,showNonTappableOptions:A,showOptionIcons:U=!0,showChipIcons:F=!0,showChipImages:P=!0,showOptionImages:K=!0,showOptionCounts:j=!0,showSkipButton:G,showProducts:ge,productsLayout:ye,productImageFallback:$,autoFocus:ke=!0,onFocus:He,onBlur:Ce,value:m,completedParams:Fe,onChange:fe,onParamsChange:Pe,products:be,mapProducts:Se,onProductSelect:oe,submitButton:ne,resetOnSubmit:l=!0},f){let b=(0,N.useRef)(null),x=(0,N.useRef)(null),k=(0,N.useRef)(()=>{}),R=(0,N.useRef)(null),p=(0,N.useRef)(null);(0,N.useEffect)(()=>{let D=b.current;if(D)return R.current?R.current.setMode(T):R.current=new Be.ModeController(D,T),()=>{R.current?.destroy(),R.current=null}},[T]);let Q=(0,N.useCallback)(D=>{let le=p.current?.current;le&&(le.focus(),(0,Be.setCursorOffset)(le,D))},[]),{completedParams:ee,skippedParams:te,identifiedParams:Ie,isReady:Ee,customFields:Te,suggestionPills:Ae,setActivePill:Re,skipActivePill:y,segments:Oe,newParamId:De,clearNewParamId:ve,placeholderText:u,isFocused:_e,isDropdownOpen:Ue,isActivePillSelected:se,isLoading:Qe,activeIndex:Ke,listboxId:Je,handleTextChange:Le,handleKeyDown:Ge,setFocused:Ye,editingParam:et,editingIdentified:ht,editingAnchor:Ze,caretOffset:tt,startEditingParam:c,handleCaretAfterInput:V,handleCaretMove:O,replaceEditingRange:ut,dropdownProps:Vt,reset:at,refreshProducts:Ct,recordSubmit:Pt}=ct({onSubmit:D=>k.current(D),onResult:t,onError:n,optionOverrides:i,maskCompletedText:r,apiConfig:h,additionalContext:d,language:w,productId:E,visitorId:I,columns:g,dropdownTrigger:q,optionsPosition:B,closeDropdownOnBlur:z,showNonTappableOptions:A,showOptionIcons:U,showOptionImages:K,showOptionCounts:j,showSkipButton:G,showProducts:ge,onFocus:He,onBlur:Ce,value:m,completedParams:Fe,onChange:fe,onParamsChange:Pe,products:be,mapProducts:Se,onProductSelect:oe,source:"full-sdk",setCursor:Q});(0,N.useEffect)(()=>{if(!De)return;let D=window.setTimeout(()=>ve(),650);return()=>window.clearTimeout(D)},[De,ve]);let Xt=Ke>=0?`${Je}-option-${Ke}`:void 0,{inputRef:mt,editorProps:Jt,focus:it,blur:St,getPlainText:It}=Zt({segments:Oe,newParamId:De,editingParam:et,editingIdentified:ht,editingAnchor:Ze,caretOffset:tt,placeholderText:u,isFocused:_e,showChipIcons:F,showChipImages:P,isDropdownOpen:Ue,listboxId:Je,activeDescendantId:Xt,autoFocus:ke,handleTextChange:Le,handleKeyDown:Ge,handleCaretAfterInput:V,handleCaretMove:O,startEditingParam:c,replaceEditingRange:ut,setFocused:Ye});p.current=mt,(0,N.useLayoutEffect)(()=>{let D=x.current,le=mt.current;if(!D||!le)return;let $e=()=>{let Tt=D.firstElementChild;if(!Tt)return;let ia=Tt.getBoundingClientRect(),oa=le.getBoundingClientRect();ia.top>=oa.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};$e();let Et=new ResizeObserver($e);return Et.observe(le),()=>Et.disconnect()},[Oe,Ae.length,Qe,mt]),(0,N.useImperativeHandle)(f,()=>({focus:it,blur:St,reset:at,refreshProducts:Ct,setMode:D=>R.current?.setMode(D),skipActivePill:y}),[it,St,at,Ct,y]);let ot=!!Oe.length||ee.length>0,gt=(0,N.useCallback)(D=>{if(!ot)return;let le=It(),$e=(0,Be.buildSubmitResult)(le,ee,te,{identifiedParams:Ie,isReady:Ee,customFields:Te});D&&Pt($e),a($e),l&&at()},[Pt,l,ot,ee,te,Ie,Ee,Te,a,at,It]);k.current=()=>gt(!1);let ea=(0,N.useCallback)(D=>{D.target?.closest("[data-aia-pill]")||it()},[it]),ta=v==="inline",aa=v==="dropdown";return(0,re.jsxs)("div",{ref:b,className:`magicx-aia ${We.container} ${o??""}`,"data-pill-placement":v,"data-options-position":B,"data-animations":H?"on":"off","data-mode":Ca(T),children:[(0,re.jsx)(lt,{...Vt,showPills:aa,productsLayout:ye,productImageFallback:$}),(0,re.jsxs)("div",{className:We.inputWrapper,"data-aia-input-wrapper":"",onClick:ea,children:[(0,re.jsxs)("div",{className:We.editorArea,"data-aia-editor":"",children:[(0,re.jsx)("div",{...Jt,className:We.input,"data-aia-input":""}),ta&&(Qe||Ae.length>0)&&(0,re.jsx)("span",{ref:x,className:We.pillListContainer,"data-aia-pill-list-container":"",children:(0,re.jsx)(rt,{pills:Ae,activePillIndex:0,activeSelected:se,onSelectPill:Re,loading:Qe})})]}),ne===null?null:ne===void 0?(0,re.jsx)(jt,{disabled:!ot,onClick:()=>gt(!0),label:(0,Be.uiStringsFor)(w).submit}):(0,re.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:We.submitSlot,onClick:D=>{ot&&(D.stopPropagation(),gt(!0))},children:ne})]})]})});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