@magicx-eng/ai-autocomplete-react 0.40.2 → 0.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
-
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, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
1
|
+
import { AutocompleteResult, OptionOverrides, APIConfig, CurrencyOptions, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, MatchedItem, Suggestion, SuggestionOption, FormatType, DateMonthView, DateRange, SkippedParamState, IdentifiedParamState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
|
+
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CurrencyOptions, 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, optionsShowLeadingVisuals, 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';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -56,6 +56,8 @@ interface AIAutocompleteProps {
|
|
|
56
56
|
* Default: the browser language (`navigator.language`), else `"en-US"`.
|
|
57
57
|
*/
|
|
58
58
|
language?: string;
|
|
59
|
+
/** Sends currency context with suggestions when the code and a finite positive rate are set. */
|
|
60
|
+
currency?: CurrencyOptions;
|
|
59
61
|
/**
|
|
60
62
|
* Your product id. When set, what the dropdown offers before anything is
|
|
61
63
|
* typed is read from a cacheable URL for your product, with no credential,
|
|
@@ -217,6 +219,8 @@ interface UseAIAutocompleteOptions {
|
|
|
217
219
|
* Default: the browser language (`navigator.language`), else `"en-US"`.
|
|
218
220
|
*/
|
|
219
221
|
language?: string;
|
|
222
|
+
/** Sends currency context with suggestions when the code and a finite positive rate are set. */
|
|
223
|
+
currency?: CurrencyOptions;
|
|
220
224
|
/**
|
|
221
225
|
* Your product id. When set, what the dropdown offers before anything is
|
|
222
226
|
* typed is read from a cacheable URL for your product, with no credential,
|
|
@@ -611,6 +615,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
|
|
|
611
615
|
|
|
612
616
|
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;
|
|
613
617
|
|
|
614
|
-
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;
|
|
618
|
+
declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, currency, 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;
|
|
615
619
|
|
|
616
620
|
export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
-
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, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
1
|
+
import { AutocompleteResult, OptionOverrides, APIConfig, CurrencyOptions, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, MatchedItem, Suggestion, SuggestionOption, FormatType, DateMonthView, DateRange, SkippedParamState, IdentifiedParamState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
|
+
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CurrencyOptions, 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, optionsShowLeadingVisuals, 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';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -56,6 +56,8 @@ interface AIAutocompleteProps {
|
|
|
56
56
|
* Default: the browser language (`navigator.language`), else `"en-US"`.
|
|
57
57
|
*/
|
|
58
58
|
language?: string;
|
|
59
|
+
/** Sends currency context with suggestions when the code and a finite positive rate are set. */
|
|
60
|
+
currency?: CurrencyOptions;
|
|
59
61
|
/**
|
|
60
62
|
* Your product id. When set, what the dropdown offers before anything is
|
|
61
63
|
* typed is read from a cacheable URL for your product, with no credential,
|
|
@@ -217,6 +219,8 @@ interface UseAIAutocompleteOptions {
|
|
|
217
219
|
* Default: the browser language (`navigator.language`), else `"en-US"`.
|
|
218
220
|
*/
|
|
219
221
|
language?: string;
|
|
222
|
+
/** Sends currency context with suggestions when the code and a finite positive rate are set. */
|
|
223
|
+
currency?: CurrencyOptions;
|
|
220
224
|
/**
|
|
221
225
|
* Your product id. When set, what the dropdown offers before anything is
|
|
222
226
|
* typed is read from a cacheable URL for your product, with no credential,
|
|
@@ -611,6 +615,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
|
|
|
611
615
|
|
|
612
616
|
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;
|
|
613
617
|
|
|
614
|
-
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;
|
|
618
|
+
declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, currency, 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;
|
|
615
619
|
|
|
616
620
|
export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var xt=Object.defineProperty;var la=Object.getOwnPropertyDescriptor;var da=Object.getOwnPropertyNames;var ca=Object.prototype.hasOwnProperty;var pa=(e,a)=>{for(var t in a)xt(e,t,{get:a[t],enumerable:!0})},ha=(e,a,t,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of da(a))!ca.call(e,o)&&o!==t&&xt(e,o,{get:()=>a[o],enumerable:!(i=la(a,o))||i.enumerable});return e};var ua=e=>ha(xt({},"__esModule",{value:!0}),e);var Ea={};pa(Ea,{AIAutocomplete:()=>ea,AIAutocompleteDropdown:()=>pt,DATE_RANGE_META_END:()=>r.DATE_RANGE_META_END,DATE_RANGE_META_START:()=>r.DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT:()=>r.DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX:()=>r.PRODUCT_PATH_PREFIX,WEEKDAY_LABELS:()=>r.WEEKDAY_LABELS,buildSubmitResult:()=>r.buildSubmitResult,cellDay:()=>r.cellDay,cellIso:()=>r.cellIso,dateCellMarks:()=>r.dateCellMarks,formatDate:()=>r.formatDate,formatDateRange:()=>r.formatDateRange,formatOptionCount:()=>r.formatOptionCount,isoDate:()=>r.isoDate,monthLabel:()=>r.monthLabel,optionCountLabel:()=>r.optionCountLabel,optionHasImage:()=>r.optionHasImage,optionImageSources:()=>r.optionImageSources,optionImageSrc:()=>r.optionImageSrc,optionLabel:()=>r.optionLabel,optionsShowLeadingVisuals:()=>r.optionsShowLeadingVisuals,parseDate:()=>r.parseDate,parseLooseDate:()=>r.parseLooseDate,parseLooseDateRange:()=>r.parseLooseDateRange,productFromMatchedItem:()=>r.productFromMatchedItem,productImageSources:()=>r.productImageSources,productsFromCustomFields:()=>r.productsFromCustomFields,sanitizeOptionIconSvg:()=>r.sanitizeOptionIconSvg,selectedRangeFor:()=>r.selectedRangeFor,useAIAutocomplete:()=>ut,visibleDateRange:()=>r.visibleDateRange,withSkippedParams:()=>r.withSkippedParams});module.exports=ua(Ea);var r=require("@magicx-eng/ai-autocomplete-vanilla");var B=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
|
|
@@ -268,7 +268,7 @@
|
|
|
268
268
|
opacity: 0;
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
`,document.head.appendChild(e)}var
|
|
271
|
+
`,document.head.appendChild(e)}var Ue={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 ee=require("@magicx-eng/ai-autocomplete-vanilla"),U=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
272
272
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
273
273
|
* Consumer CSS always wins without !important.
|
|
274
274
|
*
|
|
@@ -1120,7 +1120,7 @@
|
|
|
1120
1120
|
opacity: 0.25;
|
|
1121
1121
|
}
|
|
1122
1122
|
}
|
|
1123
|
-
`,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
|
|
1123
|
+
`,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 H=require("@magicx-eng/ai-autocomplete-vanilla"),Lt=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) ---
|
|
1124
1124
|
|
|
1125
1125
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1126
1126
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1283,7 +1283,7 @@
|
|
|
1283
1283
|
opacity: 0.8;
|
|
1284
1284
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1285
1285
|
}
|
|
1286
|
-
`,document.head.appendChild(e)}var N={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
|
|
1286
|
+
`,document.head.appendChild(e)}var N={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 J=require("react/jsx-runtime"),ma=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function zt({options:e,activeIndex:a,listboxId:t,view:i,selection:o,onSelect:s,onHighlight:n,onUnhighlight:c,onPreviousMonth:l,onNextMonth:b}){let P=(0,H.isoDate)(new Date),T=(0,H.visibleDateRange)({pendingStart:o.rangeStart,highlightedIso:(0,H.cellIso)(e[a]),selected:o.selectedRange});return(0,J.jsxs)("div",{className:N.datepicker,"data-aia-datepicker":"",children:[(0,J.jsxs)("div",{className:N.header,children:[(0,J.jsx)("button",{type:"button",tabIndex:-1,className:N.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:f=>f.preventDefault(),onClick:l,children:"\u2039"}),(0,J.jsx)("span",{className:N.month,"data-aia-date-month":"","aria-live":"polite",children:(0,H.monthLabel)(i)}),(0,J.jsx)("button",{type:"button",tabIndex:-1,className:N.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:f=>f.preventDefault(),onClick:b,children:"\u203A"})]}),(0,J.jsx)("div",{className:N.weekdays,"aria-hidden":"true",children:H.WEEKDAY_LABELS.map((f,x)=>(0,J.jsx)("span",{className:N.weekday,children:f},ma[x]))}),(0,J.jsx)("div",{className:N.grid,"data-aia-date-grid":"",children:e.map((f,x)=>(0,J.jsx)(ga,{option:f,id:`${t}-option-${x}`,index:x,isHighlighted:x===a&&f.is_tappable,isToday:(0,H.cellIso)(f)===P,isPast:(0,H.cellIso)(f)!=null&&(0,H.cellIso)(f)<P,marks:(0,H.dateCellMarks)((0,H.cellIso)(f),{selectedIso:o.selectedIso,range:T}),onSelect:s,onHighlight:n,onUnhighlight:c},(0,H.cellIso)(f)??`pad-${x}`))})]})}function ga({option:e,id:a,index:t,isHighlighted:i,isToday:o,isPast:s,marks:n,onSelect:c,onHighlight:l,onUnhighlight:b}){let[P,T]=(0,Lt.useState)(!1),f=(0,H.cellDay)(e);if(f==null)return(0,J.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${N.cell} ${N.blank}`});let x=()=>{T(!0),c(e),setTimeout(()=>T(!1),170)},E=[N.cell,N.day,s?N.past:"",i?N.highlighted:"",o?N.today:"",n.inRange?N.inRange:"",n.selected?N.selected:"",P?N.pressed:""].filter(Boolean).join(" ");return(0,J.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:E,onClick:x,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),x())},onMouseEnter:()=>l(t),onMouseLeave:b?()=>b(t):void 0,children:(0,J.jsx)("span",{className:N.number,children:f})})}var He=require("@magicx-eng/ai-autocomplete-vanilla"),st=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 {
|
|
1287
1287
|
display: flex;
|
|
1288
1288
|
flex-wrap: wrap;
|
|
1289
1289
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1323,7 +1323,7 @@
|
|
|
1323
1323
|
.aia-cluster[data-justify="around"] {
|
|
1324
1324
|
justify-content: space-around;
|
|
1325
1325
|
}
|
|
1326
|
-
`,document.head.appendChild(e)}var
|
|
1326
|
+
`,document.head.appendChild(e)}var yt=require("react/jsx-runtime");function Je({gap:e,align:a="center",justify:t="start",noWrap:i=!1,inline:o=!1,className:s,children:n,...c}){let l=e?{"--aia-cluster-gap":e}:void 0,b={className:s?`aia-cluster ${s}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":i||void 0,"data-inline":o||void 0,style:l,...c};return o?(0,yt.jsx)("span",{...b,children:n}):(0,yt.jsx)("div",{...b,children:n})}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
|
|
1327
1327
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1328
1328
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1329
1329
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1470,7 +1470,7 @@
|
|
|
1470
1470
|
justify-content: flex-end;
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
1473
|
-
`,document.head.appendChild(e)}var Se={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
|
|
1473
|
+
`,document.head.appendChild(e)}var Se={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 ue=require("react/jsx-runtime");function Mt({isOptionHighlighted:e=!1,isInputEmpty:a=!1,strings:t=(0,He.uiStringsFor)()}){let{key:i,hint:o}=(0,He.getFooterHint)(e,a,t),[s,n]=(0,st.useState)(He.ATTRIBUTION_URL);return(0,st.useEffect)(()=>{n((0,He.buildAttributionUrl)())},[]),(0,ue.jsx)("footer",{className:Se.footer,"data-aia-footer":"",children:(0,ue.jsxs)(Je,{justify:"between",noWrap:!0,className:Se.row,children:[(0,ue.jsxs)(Je,{gap:"5px",className:Se.hintGroup,children:[(0,ue.jsx)("kbd",{className:Se.key,children:i}),(0,ue.jsx)("span",{className:Se.hint,children:o})]}),(0,ue.jsxs)("a",{className:Se.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[(0,ue.jsx)("span",{className:Se.brand,children:"AI"}),(0,ue.jsx)("span",{className:Se.badge,children:"Autocomplete"})]})]})})}var lt=require("@magicx-eng/ai-autocomplete-vanilla");var Nt=require("@magicx-eng/ai-autocomplete-vanilla");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,
|
|
1474
1474
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1475
1475
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1476
1476
|
as it was when the outline was dashed. */
|
|
@@ -1650,7 +1650,7 @@
|
|
|
1650
1650
|
opacity: 0;
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
|
-
`,document.head.appendChild(e)}var
|
|
1653
|
+
`,document.head.appendChild(e)}var me={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",smartText:"aia-smartText-R0cfw","smartSuggestion-shimmer":"aia-smartSuggestion-shimmer-F-yoD",smartSparkle:"aia-smartSparkle-IVabG","smartSuggestion-sparkle":"aia-smartSuggestion-sparkle-Wfj-4","smartSuggestion-sparkle-small":"aia-smartSuggestion-sparkle-small-3VsWJ",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};var Be=require("react/jsx-runtime"),kt={selected:1,first:.7,next:.4,last:.2};function Ft({label:e,state:a,rounded:t,loading:i,smartSuggestion:o,completionHeader:s,onClick:n}){let c=[me.pill,t?me.rounded:"",i?me.skeleton:""].filter(Boolean).join(" ");return(0,Be.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,"data-aia-smart-suggestion":o?s?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:c,style:{opacity:kt[a]},onMouseDown:l=>l.preventDefault(),onClick:i?void 0:n,disabled:i,children:o?(0,Be.jsxs)(Be.Fragment,{children:[(0,Be.jsx)("span",{className:`${me.smartText} magicx-aia-smart-suggestion-text`,children:e}),(0,Be.jsx)("span",{className:`${me.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:Nt.SMART_SUGGESTION_SPARKLE_SVG}})]}):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 {
|
|
1654
1654
|
position: relative;
|
|
1655
1655
|
z-index: 1;
|
|
1656
1656
|
pointer-events: auto;
|
|
@@ -1660,7 +1660,7 @@
|
|
|
1660
1660
|
align-items: center;
|
|
1661
1661
|
vertical-align: middle;
|
|
1662
1662
|
}
|
|
1663
|
-
`,document.head.appendChild(e)}var
|
|
1663
|
+
`,document.head.appendChild(e)}var Ct={list:"aia-list-qvLqO"};var et=require("react/jsx-runtime"),fa=[125,69];function Ht(e){return e===0?"first":e===1?"next":"last"}function dt({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:i,rounded:o,loading:s}){return s&&e.length===0?(0,et.jsx)("span",{className:Ct.list,"data-aia-pill-list-loading":"",children:fa.map((n,c)=>(0,et.jsx)("span",{"data-aia-pill-skeleton":"",className:`${me.pill} ${o?me.rounded:""} ${me.skeleton}`,style:{width:n,opacity:kt[Ht(c)]}},`skel-${n}`))}):(0,et.jsx)("span",{className:Ct.list,"data-aia-pill-list-loading":s?"":void 0,children:e.map((n,c)=>{let l=!!i&&c===a;return(0,et.jsx)(Ft,{label:n.text,state:l?"selected":Ht(c),selected:l,rounded:o,loading:s,smartSuggestion:(0,lt.isSmartSuggestion)(n),completionHeader:(0,lt.isTraditionalAutocompleteSuggestion)(n),onClick:()=>t(c)},`${n.parameter}-${n.text}`)})})}var ge=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
|
|
1664
1664
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1665
1665
|
theming one package sees the same result in the other.
|
|
1666
1666
|
|
|
@@ -1947,7 +1947,7 @@
|
|
|
1947
1947
|
letter-spacing: 0.02em;
|
|
1948
1948
|
text-align: center;
|
|
1949
1949
|
}
|
|
1950
|
-
`,document.head.appendChild(e)}var
|
|
1950
|
+
`,document.head.appendChild(e)}var ne={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 Bt({products:e,listboxId:a,onSelect:t,onFocusChange:i,focusable:o=!0,layout:s="row",imageFallback:n="image",strings:c=(0,ge.uiStringsFor)()}){let l=e.length>0,b=(0,Qe.useRef)(null);if((0,Qe.useEffect)(()=>{let T=b.current;if(!(!l||!T))return(0,ge.attachProductRowWheel)(T)},[l]),!l)return null;let P=`${a}-products-label`;return(0,Q.jsxs)("section",{className:ne.section,"data-aia-products":"","data-aia-products-layout":s,role:"group","aria-labelledby":P,children:[(0,Q.jsx)("div",{className:ne.label,id:P,"data-aia-products-label":"",children:c.products}),(0,Q.jsx)("div",{ref:b,className:ne.row,"data-aia-products-row":"",children:e.map((T,f)=>(0,Q.jsx)(ba,{product:T,id:`${a}-product-${f}`,onSelect:t,onFocusChange:i,focusable:o,imageFallback:n,soldOut:c.soldOut},T.id))})]})}function ba({product:e,id:a,onSelect:t,onFocusChange:i,focusable:o,imageFallback:s,soldOut:n}){let c=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),t(e))};return(0,Q.jsxs)("a",{id:a,className:ne.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:o?0:-1,onClick:c,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[(0,Q.jsx)(wa,{sources:(0,ge.productImageSources)(e.imageUrl),title:e.title,fallback:s},(0,ge.productImageSrc)(e.imageUrl)??""),(0,Q.jsxs)("span",{className:ne.body,children:[e.vendor?(0,Q.jsx)("span",{className:ne.vendor,children:e.vendor}):null,(0,Q.jsx)("span",{className:ne.title,children:e.title}),e.price?(0,Q.jsx)("span",{className:ne.price,children:e.price}):null,e.available===!1?(0,Q.jsx)("span",{className:ne.badge,children:n}):null]})]})}function wa({sources:e,title:a,fallback:t}){let[i,o]=(0,Qe.useState)(0),s=e[i],n=!!s,c=!n&&t==="initial";return(0,Q.jsxs)("span",{className:ne.media,"aria-hidden":"true","data-aia-product-placeholder":!n&&!c?"":void 0,"data-aia-product-initial":c?"":void 0,children:[n?(0,Q.jsx)("img",{className:ne.image,src:s,alt:"",loading:"lazy",decoding:"async",onError:()=>o(l=>l+1)}):null,c?(0,ge.productInitial)(a):null]})}var W=require("@magicx-eng/ai-autocomplete-vanilla"),be=require("react");var Kt=require("@magicx-eng/ai-autocomplete-vanilla"),ct=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 {
|
|
1951
1951
|
display: grid;
|
|
1952
1952
|
grid-template-columns: repeat(
|
|
1953
1953
|
auto-fit,
|
|
@@ -1983,7 +1983,7 @@
|
|
|
1983
1983
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
1984
1984
|
display: none;
|
|
1985
1985
|
}
|
|
1986
|
-
`,document.head.appendChild(e)}var
|
|
1986
|
+
`,document.head.appendChild(e)}var Wt=require("react/jsx-runtime");function Gt({min:e="16rem",max:a,gap:t,scroll:i=!1,maxHeight:o,scrollResetKey:s,cols:n,template:c,innerRef:l,className:b,children:P,...T}){let f=(0,ct.useRef)(null);(0,ct.useLayoutEffect)(()=>{if(s===void 0)return;let E=f.current;E&&(E.scrollTop=0)},[s]);let x={"--aia-grid-min":e};return a&&(x["--aia-grid-max"]=a),t&&(x["--aia-grid-gap"]=t),o&&(x["--aia-grid-max-height"]=o),n&&(x.gridTemplateColumns=(0,Kt.optionsGridTemplateColumns)(n)),c&&(x.gridTemplateColumns=c),(0,Wt.jsx)("div",{ref:E=>{f.current=E,l?.(E)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":i||void 0,style:x,...T,children:P})}var ae=require("@magicx-eng/ai-autocomplete-vanilla"),fe=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 {
|
|
1987
1987
|
position: relative;
|
|
1988
1988
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1989
1989
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2421,7 +2421,7 @@
|
|
|
2421
2421
|
opacity: 0;
|
|
2422
2422
|
}
|
|
2423
2423
|
}
|
|
2424
|
-
`,document.head.appendChild(e)}var
|
|
2424
|
+
`,document.head.appendChild(e)}var Y={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",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};var $=require("react/jsx-runtime");function _t({option:e,isHighlighted:a,onSelect:t,onHighlight:i,onUnhighlight:o,id:s,loading:n,showIcon:c=!0,showImage:l=!0,showCount:b=!0,scrollHint:P,enterDelayMs:T=0}){let[f]=(0,fe.useState)(T),[x,E]=(0,fe.useState)(!1),D=l?(0,ae.optionImageSources)(e.image_url):[],K=D[0]??null,[V,Z]=(0,fe.useState)([]),R=D.find(A=>!V.includes(A))??null,O=(0,fe.useMemo)(()=>!K&&c&&e.icon_svg?(0,ae.sanitizeOptionIconSvg)(e.icon_svg):null,[K,c,e.icon_svg]),M=b?(0,ae.formatOptionCount)(e.item_count):null,k=(0,fe.useRef)(void 0);(0,fe.useEffect)(()=>()=>clearTimeout(k.current),[]);let te=()=>{n||!e.is_tappable||x||(E(!0),t(e),clearTimeout(k.current),k.current=setTimeout(()=>E(!1),170))},j=[Y.item,a&&!n?Y.highlighted:"",e.is_tappable?Y.tappable:Y.nonTappable,x?Y.pressed:"",P?Y.scrollHint:""].filter(Boolean).join(" ");return(0,$.jsx)("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":n?"":void 0,"data-aia-icon":O&&e.icon?e.icon:void 0,"data-aia-image":K?"":void 0,"data-aia-item-count":M!==null?e.item_count:void 0,"aria-selected":a,className:j,style:{[ae.OPTION_ENTER_DELAY_VAR]:`${f}ms`},tabIndex:n||!e.is_tappable?-1:0,onClick:te,onKeyDown:A=>{!n&&e.is_tappable&&(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),te())},onMouseEnter:!n&&e.is_tappable?i:void 0,onMouseLeave:o,children:(0,$.jsxs)("span",{className:Y.content,children:[K&&(0,$.jsx)("span",{className:`${Y.image} magicx-aia-option-image`,"aria-hidden":"true",children:(0,$.jsx)("img",{src:R??K,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:R===null,onError:()=>{R!==null&&Z(A=>[...A,R])}})}),O&&(0,$.jsx)("span",{className:`${Y.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:O}}),(0,$.jsxs)("span",{className:Y.text,children:[e.matchedText?(0,ae.highlightParts)((0,ae.optionLabel)(e),e.matchedText).map((A,re)=>A.bold?(0,$.jsx)("strong",{className:`${Y.match} magicx-aia-option-match`,children:A.text},re):A.text):(0,ae.optionLabel)(e),e.parameterLabel&&(0,$.jsxs)($.Fragment,{children:[" ",(0,$.jsx)("span",{className:`${Y.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&(0,$.jsx)("span",{className:Y.tag,children:e.tag}),M!==null&&(0,$.jsx)("span",{className:`${Y.count} magicx-aia-option-count`,children:M})]})})}var St=require("react/jsx-runtime");function va(){let[e,a]=(0,be.useState)(W.isOptionsGridMobileViewport);return(0,be.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(W.OPTIONS_GRID_MOBILE_QUERY),i=()=>a(t.matches);return i(),t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function qt({options:e,activeIndex:a,onSelect:t,onHighlight:i,onUnhighlight:o,listboxId:s,loading:n,groupKey:c="",optionsPosition:l="below",showIcons:b=!0,showImages:P=!0,showCounts:T=!0}){let f=va(),x=(0,be.useRef)(null),[E,D]=(0,be.useState)(null),K=(0,be.useRef)(null);(0,be.useLayoutEffect)(()=>{if(n&&(0,W.sameOptionRows)(K.current,e))return;K.current=n?null:e;let R=x.current,M=R&&!n&&(0,W.needsOptionsGridMeasurement)(e.length,f)?(0,W.measureOptionsGrid)(R):null;D(M?(0,W.planOptionsGrid)(e.length,f,M.rowWidths,M.gridWidth):null)},[e,f,n]);let V=E??(0,W.planOptionsGrid)(e.length,f,null,null),Z=(0,W.optionsShowLeadingVisuals)(e,b,P);return(0,St.jsx)(Gt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:c,template:V.template,maxHeight:V.maxHeight,innerRef:R=>{x.current=R},"data-aia-group":c,children:e.map((R,O)=>(0,St.jsx)(_t,{option:R,isHighlighted:O===a,onSelect:t,onHighlight:()=>i(O),onUnhighlight:o?()=>o(O):void 0,id:`${s}-option-${O}`,loading:n,showIcon:b&&Z,showImage:P&&Z,showCount:T,scrollHint:!n&&V.scrollHintIndices.includes(O),enterDelayMs:n?0:(0,W.optionEnterDelayMs)(O,V.cols,e.length,l)},`${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 {
|
|
2425
2425
|
display: flex;
|
|
2426
2426
|
flex-direction: column;
|
|
2427
2427
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2436,7 +2436,7 @@
|
|
|
2436
2436
|
align-items: end;
|
|
2437
2437
|
}
|
|
2438
2438
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2439
|
-
`,document.head.appendChild(e)}var
|
|
2439
|
+
`,document.head.appendChild(e)}var Vt=require("react/jsx-runtime");function Ut({space:e,align:a="stretch",className:t,children:i,...o}){let s=e?{"--aia-stack-space":e}:void 0;return(0,Vt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:s,...o,children:i})}var _=require("react/jsx-runtime"),xa=[159,119,164],ya=()=>{},jt=()=>{};function ka(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,i]=(0,U.useState)(a);if((0,U.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>i(o.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Ca(e,a){let t=(0,U.useRef)(null);(0,U.useEffect)(()=>{let i=e.current,o=a.current;if(!i||!o)return;let s=i.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==s&&(t.current.controller.destroy(),t.current=null),s&&!t.current){t.current={grid:s,controller:(0,ee.attachScrollArrow)({dropdown:i,grid:s,button:o})};return}t.current?.controller.update()}),(0,U.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Sa(e,a){let t=(0,U.useRef)(a);t.current=a;let i=(0,U.useRef)(null);(0,U.useEffect)(()=>{let o=e.current;if(o){if(!i.current){i.current=(0,ee.attachViewportFit)({dropdown:o,isOpen:()=>t.current});return}i.current.update()}}),(0,U.useEffect)(()=>()=>{i.current?.destroy(),i.current=null},[])}function pt({suggestions:e,activeIndex:a,onSelect:t,onHighlight:i,onUnhighlight:o,isOpen:s,id:n,className:c,pills:l,onPillClick:b,showPills:P=!0,onSkip:T,showSkipButton:f=!0,showOptionIcons:x=!0,showOptionImages:E=!0,showOptionCounts:D=!0,skipDisabled:K=!1,activeSelected:V=!1,isLoading:Z=!1,skeletonExiting:R=!1,isInputEmpty:O=!1,language:M,products:k,onProductSelect:te,onProductFocusChange:j,productsLayout:A="row",productImageFallback:re="image",formatType:we="options",dateView:ie=null,selectedDateIso:ve=null,selectedDateRange:Pe=null,dateRangeStart:We=null,onPreviousMonth:Ie,onNextMonth:m,optionsPosition:Te="below",mode:Ee}){let xe=ka(Ee),Ae=xe!==void 0,oe=(0,U.useRef)(null),ye=(0,U.useRef)(null);Ca(oe,ye),(0,U.useEffect)(()=>{if(oe.current)return(0,ee.containScroll)(oe.current)},[]);let d=e[0]?.options??[],g=!!(l&&l.length>0&&b),w=!!(k&&k.length>0),v=s&&(d.length>0||P&&g||Z||w);Sa(oe,v);let C={suggestions:e,activeIndex:a,pills:l,showPills:P,showSkipButton:f,showOptionIcons:x,showOptionImages:E,showOptionCounts:D,skipDisabled:K,activeSelected:V,isLoading:Z,skeletonExiting:R,isInputEmpty:O,products:k,formatType:we,dateView:ie,selectedDateIso:ve,selectedDateRange:Pe,dateRangeStart:We},F=(0,U.useRef)(C);v&&(F.current=C);let h=v?C:F.current,G=(0,ee.uiStringsFor)(M),se=h.suggestions[0],le=se?.options??[],Re=h.activeIndex>=0&&!!le[h.activeIndex]?.is_tappable,de=(0,ee.labelTraditionalAutocomplete)(h.pills??[],G.keepTyping),De=!!(de.length>0&&b),Oe=h.showPills&&De,Le=h.showPills&&!De&&h.isLoading,ze=Oe||Le,y=De&&(0,ee.hasSkippablePill)(de)&&h.showSkipButton&&!h.isInputEmpty&&!!T,Me=de[0]?.text,Ne=(0,ee.isCalendarFormat)(h.formatType)&&h.dateView!=null,ke=le.length>0&&!Ne,u=le.length>0&&Ne&&!h.isLoading,Ve=h.isLoading&&!ke&&!u,je=h.products??[];return(0,_.jsxs)("div",{ref:oe,id:n,role:"listbox","data-aia-dropdown":"","data-options-position":Te,"data-mode":xe,"data-aia-loading":h.isLoading?"":void 0,"data-aia-skeleton-exiting":h.skeletonExiting?"":void 0,"data-aia-has-products":je.length>0?"":void 0,className:`${Ae?"magicx-aia ":""}${Ce.dropdown} ${v?Ce.visible:""} ${c??""}`,onMouseDown:pe=>pe.preventDefault(),children:[(0,_.jsxs)(Ut,{space:"8px",children:[(ze||y)&&(0,_.jsxs)(Je,{noWrap:!0,className:Ce.pillBar,"data-aia-pillbar":"",children:[ze&&(0,_.jsx)("span",{className:Ce.pillScroll,"data-aia-pill-scroll":"",children:(0,_.jsx)(dt,{pills:de,activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:h.isLoading})}),y&&(0,_.jsx)("button",{type:"button",tabIndex:-1,className:Ce.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":Me?`${G.skipLabel} ${Me}`:G.skipLabel,onClick:T,children:G.skip})]}),ke&&(0,_.jsx)(qt,{options:le,activeIndex:h.activeIndex,onSelect:t,onHighlight:i,onUnhighlight:o,listboxId:n,loading:h.isLoading,groupKey:se?`${se.parameter} ${se.text}`:"",optionsPosition:Te,showIcons:h.showOptionIcons,showImages:h.showOptionImages,showCounts:h.showOptionCounts}),u&&h.dateView&&(0,_.jsx)(zt,{options:le,activeIndex:h.activeIndex,listboxId:n,view:h.dateView,selection:{selectedIso:h.selectedDateIso??null,selectedRange:h.selectedDateRange??null,rangeStart:h.dateRangeStart??null},onSelect:t,onHighlight:i,onUnhighlight:o,onPreviousMonth:Ie??jt,onNextMonth:m??jt}),Ve&&(0,_.jsx)("div",{className:Ce.skeletonBars,"data-aia-skeleton-bars":"",children:xa.map(pe=>(0,_.jsx)("span",{className:Ce.skeletonBar,style:{width:pe}},`bar-${pe}`))}),(0,_.jsx)(Bt,{products:je,listboxId:n,onSelect:te??ya,onFocusChange:j,focusable:v,layout:A,imageFallback:re,strings:G}),(0,_.jsx)(Mt,{isOptionHighlighted:Re,isInputEmpty:h.isInputEmpty,strings:G})]}),(0,_.jsx)("button",{ref:ye,type:"button",tabIndex:-1,className:Ce.scrollArrow,"data-aia-scroll-arrow":"","aria-label":G.scrollArrow,"aria-hidden":"true",children:(0,_.jsx)("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:(0,_.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Ge=require("@magicx-eng/ai-autocomplete-vanilla");var Yt=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 {
|
|
2440
2440
|
flex-shrink: 0;
|
|
2441
2441
|
width: 32px;
|
|
2442
2442
|
height: 32px;
|
|
@@ -2489,5 +2489,5 @@
|
|
|
2489
2489
|
);
|
|
2490
2490
|
cursor: default;
|
|
2491
2491
|
}
|
|
2492
|
-
`,document.head.appendChild(e)}var jt={submitButton:"aia-submitButton-otz7H"};var pt=require("react/jsx-runtime");function Yt({disabled:e,onClick:a,label:t=(0,Qt.uiStringsFor)().submit}){return(0,pt.jsx)("button",{type:"button","data-aia-submit":"",className:jt.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),a()},"aria-label":t,children:(0,pt.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:(0,pt.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var He=require("@magicx-eng/ai-autocomplete-vanilla"),S=require("react");var St=require("react");function $t(e){let a=(0,St.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),i=(0,St.useRef)({key:"",overrides:void 0});if(i.current.key!==t){let o={};for(let s of Object.keys(e??{})){let n=(c,d,w)=>{let I=a.current?.[s];return I?I(c,d,w):[]};o[s]=n}i.current={key:t,overrides:e?o:void 0}}return{overrides:i.current.overrides,key:t}}var Pt=require("react");function Zt(e){let a=(0,Pt.useRef)(e);a.current=e;let t=(0,Pt.useRef)(null);t.current===null&&(t.current={fetch:(o,s)=>{let n=a.current;return n?n.fetch(o,s):Promise.reject(new Error("products config removed"))},transform:o=>a.current?.transform(o)??[],get limit(){return a.current?.limit}});let i=e!==void 0;return{config:i?t.current:void 0,enabled:i}}var Sa={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,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,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function ht({onSubmit:e,onResult:a,onError:t,optionOverrides:i,maskCompletedText:o,apiConfig:s,additionalContext:n,language:c,productId:d,visitorId:w,columns:I=2,dropdownTrigger:T,optionsPosition:g,closeDropdownOnBlur:v,showNonTappableOptions:E,showOptionIcons:B,showOptionImages:K,showOptionCounts:j,showSkipButton:X,showProducts:A,productImageFallback:M="image",onFocus:D,onBlur:k,value:G,completedParams:Q,onChange:O,onParamsChange:le,products:Pe,mapProducts:J,onProductSelect:Ie,source:Ke,setCursor:Te}){let m=(0,S.useRef)(null),[Ge,ve]=(0,S.useState)(null),Ee=(0,S.useRef)(e);Ee.current=e;let xe=(0,S.useRef)(a);xe.current=a;let Ae=(0,S.useRef)(t);Ae.current=t;let oe=(0,S.useRef)(O);oe.current=O;let de=(0,S.useRef)(le);de.current=le;let l=(0,S.useRef)(D);l.current=D;let f=(0,S.useRef)(k);f.current=k;let b=(0,S.useRef)(Te);b.current=Te;let x=(0,S.useRef)(Ie);x.current=Ie;let C=(0,S.useRef)(w);C.current=w;let R=(0,S.useRef)(()=>{let p=C.current;return typeof p=="function"?p():p}).current,h=Zt(Pe),U=(0,S.useRef)(J);U.current=J;let ne=(0,S.useRef)((p,ee)=>{let L=U.current;return L?L(p,ee):p}).current,re=J?ne:void 0,Re=$t(i);(0,S.useEffect)(()=>{if(typeof document>"u")return;let p=new He.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:n,language:c,productId:d,visitorId:R,optionOverrides:Re.overrides,maskCompletedText:o,columns:I,dropdownTrigger:T,optionsPosition:g,closeDropdownOnBlur:v,showNonTappableOptions:E,showProducts:A,source:Ke,value:G,completedParams:Q,onSubmit:(...L)=>Ee.current?.(...L),onResult:(...L)=>xe.current?.(...L),onError:(...L)=>Ae.current?.(...L),onChange:(...L)=>oe.current?.(...L),onParamsChange:(...L)=>de.current?.(...L),onFocus:()=>l.current?.(),onBlur:()=>f.current?.(),onProductSelect:L=>x.current?.(L),setCursor:L=>b.current?.(L),products:h.config,mapProducts:re});m.current=p,ve(p.getState());let ee=p.subscribe(L=>ve(L));return()=>{ee(),p.destroy(),m.current===p&&(m.current=null)}},[]),(0,S.useEffect)(()=>{G!==void 0&&m.current?.setValue(G)},[G]),(0,S.useEffect)(()=>{Q!==void 0&&m.current?.setCompletedParams(Q)},[Q]);let ye=JSON.stringify(s??null),pe;try{pe=JSON.stringify(n??null)}catch{pe="[unstringifiable]"}(0,S.useEffect)(()=>{m.current?.update({apiConfig:s,additionalContext:n,language:c,productId:d,optionOverrides:Re.overrides,dropdownTrigger:T,optionsPosition:g,closeDropdownOnBlur:v,showNonTappableOptions:E,showProducts:A})},[ye,pe,c,d,Re.key,T,g,v,E,A]);let De=(0,S.useRef)(!1);(0,S.useEffect)(()=>{if(!De.current){De.current=!0;return}m.current?.update({products:h.config})},[h.enabled]),(0,S.useEffect)(()=>{m.current?.update({mapProducts:re})},[re]);let We=(0,S.useRef)(null);We.current===null&&(We.current={handleTextChange:p=>m.current?.handleTextChange(p),handleKeyDown:p=>{let ee="nativeEvent"in p?p.nativeEvent:p;m.current?.handleKeyDown(ee)},setFocused:p=>m.current?.setFocused(p),startEditingParam:p=>m.current?.startEditingParam(p),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:p=>m.current?.handleCaretAfterInput(p),handleCaretMove:p=>m.current?.handleCaretMove(p),replaceEditingRange:p=>m.current?.replaceEditingRange(p)??!1,setActivePill:p=>m.current?.setActivePill(p),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),refreshProducts:()=>m.current?.refreshProducts(),recordSubmit:p=>m.current?.recordSubmit(p),selectOption:p=>m.current?.selectOption(p),selectProduct:p=>m.current?.selectProduct(p),setActiveDropdownIndex:p=>m.current?.setActiveDropdownIndex(p),clearHighlight:p=>m.current?.clearHighlight(p),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let y=We.current,Oe=(0,S.useCallback)(p=>{let ee=p.target.value,ft=ee.length>0&&!p.nativeEvent?.isComposing&&ee[0]!==ee[0].toUpperCase()?ee[0].toUpperCase()+ee.slice(1):ee;m.current?.handleTextChange(ft)},[]),Le=(0,S.useCallback)(p=>{m.current?.handleKeyDown(p.nativeEvent)},[]),ke=m.current,u=Ge??Sa,_e=G!==void 0?G:u.text,Qe=Q!==void 0?Q:u.completedParams,ze=u.actionableSuggestions,he=ze[0],et=(0,He.withoutTraditionalAutocomplete)(ze),qe=ke?.listboxId??"",mt=u.activeDropdownIndex>=0&&ke?`${qe}-option-${u.activeDropdownIndex}`:void 0,Me=u.editingParam,Ue=u.editingIdentified,Ye=Me?{parameter:Me.suggestionParameter,text:Me.suggestionPlaceholder,required:!0,options:Me.options}:Ue?{parameter:Ue.parameter,text:(0,He.identifiedParamLabel)(Ue.parameter),required:!0,options:[]}:null,tt=u.dropdownSuggestion??Ye??he,gt=Ye?[Ye]:ze,$e=(0,He.dateSelectionFor)(u),at=!ke||u.dropdownLoading;return{completedParams:Qe,skippedParams:u.skippedParams,identifiedParams:u.identifiedParams,suggestionPills:et,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:at,isFocused:u.isFocused,isDropdownOpen:u.isDropdownOpen,isActivePillSelected:u.isActivePillSelected,placeholderText:u.placeholderText,listboxId:qe,error:u.error,products:u.products,customFields:u.customFields,selectProduct:y.selectProduct,handleTextChange:y.handleTextChange,handleKeyDown:y.handleKeyDown,setFocused:y.setFocused,editingParam:Me,editingIdentified:Ue,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:Le,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":u.isDropdownOpen,"aria-activedescendant":mt,"aria-autocomplete":"list","aria-controls":qe},reset:y.reset,refreshProducts:y.refreshProducts,recordSubmit:y.recordSubmit,dropdownProps:{suggestions:tt?[{...tt,options:u.dropdownOptions}]:[],activeIndex:u.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,onUnhighlight:y.clearHighlight,isOpen:u.isDropdownOpen,id:qe,pills:gt,activeSelected:u.isActivePillSelected,onPillClick:y.setActivePill,onSkip:y.skipActivePill,showSkipButton:(X??!0)&&!Me&&!Ue,showOptionIcons:B??!0,showOptionImages:K??!0,showOptionCounts:j??!0,skipDisabled:u.inSelectionAnimation,isLoading:at,skeletonExiting:u.skeletonExiting,isInputEmpty:_e.trim().length===0,language:c,products:u.products,productImageFallback:M,onProductSelect:y.selectProduct,onProductFocusChange:y.setFocused,formatType:u.activeFormatType,dateView:u.dateView,selectedDateIso:$e.selectedIso,selectedDateRange:$e.selectedRange,dateRangeStart:$e.rangeStart,onPreviousMonth:y.showPreviousMonth,onNextMonth:y.showNextMonth,optionsPosition:g??"below"}}}var q=require("@magicx-eng/ai-autocomplete-vanilla"),P=require("react"),ut;function Pa(){if(ut!==void 0)return ut;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),ut=e.contentEditable==="plaintext-only",ut}function Xt(e){let{segments:a,showChipIcons:t=!0,showChipImages:i=!0,newParamId:o,editingParam:s,editingIdentified:n,editingAnchor:c,caretOffset:d,placeholderText:w,isFocused:I,isDropdownOpen:T,listboxId:g,activeDescendantId:v,autoFocus:E,handleTextChange:B,handleKeyDown:K,handleCaretAfterInput:j,handleCaretMove:X,startEditingParam:A,replaceEditingRange:M,setFocused:D}=e,k=(0,P.useRef)(null),G=(0,P.useRef)(!1),Q=(0,P.useRef)(""),O=(0,P.useRef)(""),le=(0,P.useRef)(null),Pe=(0,P.useRef)(0);le.current=d,(0,P.useEffect)(()=>{if(!E)return;let l=k.current;if(!l)return;document.activeElement===l?D(!0):l.focus();let f=l.ownerDocument??document,b=f.getSelection(),x=b&&b.rangeCount>0&&l.contains(b.anchorNode);if(b&&!x){let C=f.createRange();C.selectNodeContents(l),C.collapse(!0),b.removeAllRanges(),b.addRange(C)}},[E,D]),(0,P.useEffect)(()=>{let l=k.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 C=x.anchorNode,R=C.nodeType===Node.ELEMENT_NODE?C:C.parentElement,U=(x.isCollapsed?R?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ne=s?.id??n?.id??null;if(U&&U!==ne){A(U);return}performance.now()-Pe.current<50||X((0,q.getCursorOffset)(l))};return f.addEventListener("selectionchange",b),()=>f.removeEventListener("selectionchange",b)},[s,n,A,X]),(0,P.useEffect)(()=>{let l=k.current;if(!l)return;let f=b=>{let x=(0,q.chipIdFromTap)(l,b.target);x&&(A(x),(0,q.keepCaretOnChip)(l,x))};return l.addEventListener("click",f),()=>l.removeEventListener("click",f)},[A]),(0,P.useLayoutEffect)(()=>{let l=k.current;l&&(0,q.renderEditableContent)({input:l,segments:a,newParamId:o,editingParamId:s?.id??null,placeholderText:w??"",isFocused:I,showChipIcons:t,showChipImages:i})},[a,o,s,w,I,t,i]),(0,P.useLayoutEffect)(()=>{let l=Q.current,f=o??"";if(Q.current=f,!f||f===l)return;let b=k.current;if(!b)return;b.focus();let x=le.current??(0,q.plainTextLength)(b);(0,q.setCursorOffset)(b,x)},[o]),(0,P.useLayoutEffect)(()=>{let l=O.current,f=s?.id??"";if(O.current=f,!f||f===l||c==null)return;let b=k.current;b&&(0,q.setCursorOffset)(b,c)},[s,c]);let J=(0,P.useCallback)(()=>{if(G.current)return;let l=k.current;if(!l)return;let f=(0,q.extractPlainText)(l),x=f.length>0&&f[0]!==f[0].toUpperCase()?f[0].toUpperCase()+f.slice(1):f;B(x)},[B]),Ie=(0,P.useCallback)(()=>{Pe.current=performance.now(),J();let l=k.current;l&&j((0,q.getCursorOffset)(l))},[J,j]);(0,P.useEffect)(()=>{let l=k.current;if(!l)return;let f=b=>{let x=b,C=x.inputType;if(C==="insertParagraph"||C==="insertLineBreak"||C==="insertFromDrop"){b.preventDefault();return}if(C.startsWith("insert")||C.startsWith("delete")){let R=C.startsWith("delete")?"":x.data??"";M(R)&&b.preventDefault()}};return l.addEventListener("beforeinput",f),()=>l.removeEventListener("beforeinput",f)},[M]);let Ke=(0,P.useCallback)(()=>{G.current=!0,k.current?.setAttribute("data-aia-composing","true")},[]),Te=(0,P.useCallback)(()=>{G.current=!1,k.current?.removeAttribute("data-aia-composing"),J()},[J]),m=(0,P.useCallback)(l=>{l.preventDefault();let f=k.current;if(!f)return;let b=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let x=f.ownerDocument??document,C=x.getSelection();if(!C||C.rangeCount===0)return;let R=C.getRangeAt(0);if(!f.contains(R.startContainer))return;R.deleteContents();let h=x.createTextNode(b);R.insertNode(h),R.setStartAfter(h),R.collapse(!0),C.removeAllRanges(),C.addRange(R),J()},[J]),Ge=(0,P.useCallback)(l=>K(l),[K]),ve=(0,P.useCallback)(()=>D(!0),[D]),Ee=(0,P.useCallback)(()=>D(!1),[D]),xe=(0,P.useCallback)(()=>k.current?.focus(),[]),Ae=(0,P.useCallback)(()=>k.current?.blur(),[]),oe=(0,P.useCallback)(()=>{let l=k.current;return l?(0,q.extractPlainText)(l):""},[]),de=Pa()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:de,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":g,"aria-expanded":T,"aria-activedescendant":v,spellCheck:!0,enterKeyHint:"send",onInput:Ie,onKeyDown:Ge,onCompositionStart:Ke,onCompositionEnd:Te,onPaste:m,onFocus:ve,onBlur:Ee},getPlainText:oe,focus:xe,blur:Ae}}var ce=require("react/jsx-runtime");function Ia(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Jt=(0,H.forwardRef)(function({onSubmit:a,onResult:t,onError:i,optionOverrides:o,maskCompletedText:s,className:n,apiConfig:c,additionalContext:d,language:w,productId:I,visitorId:T,columns:g,pillPlacement:v="dropdown",mode:E="auto",optionsPosition:B="below",animations:K=!0,dropdownTrigger:j,closeDropdownOnBlur:X,showNonTappableOptions:A,showOptionIcons:M=!0,showChipIcons:D=!0,showChipImages:k=!0,showOptionImages:G=!0,showOptionCounts:Q=!0,showSkipButton:O,showProducts:le,productsLayout:Pe,productImageFallback:J,autoFocus:Ie=!0,onFocus:Ke,onBlur:Te,value:m,completedParams:Ge,onChange:ve,onParamsChange:Ee,products:xe,mapProducts:Ae,onProductSelect:oe,submitButton:de,resetOnSubmit:l=!0},f){let b=(0,H.useRef)(null),x=(0,H.useRef)(null),C=(0,H.useRef)(()=>{}),R=(0,H.useRef)(null),h=(0,H.useRef)(null);(0,H.useEffect)(()=>{let z=b.current;if(z)return R.current?R.current.setMode(E):R.current=new Be.ModeController(z,E),()=>{R.current?.destroy(),R.current=null}},[E]);let U=(0,H.useCallback)(z=>{let ue=h.current?.current;ue&&(ue.focus(),(0,Be.setCursorOffset)(ue,z))},[]),{completedParams:ne,skippedParams:re,identifiedParams:Re,isReady:ye,customFields:pe,suggestionPills:De,setActivePill:We,skipActivePill:y,segments:Oe,newParamId:Le,clearNewParamId:ke,placeholderText:u,isFocused:_e,isDropdownOpen:Qe,isActivePillSelected:ze,isLoading:he,activeIndex:et,listboxId:qe,handleTextChange:mt,handleKeyDown:Me,setFocused:Ue,editingParam:Ye,editingIdentified:tt,editingAnchor:gt,caretOffset:$e,startEditingParam:at,handleCaretAfterInput:p,handleCaretMove:ee,replaceEditingRange:L,dropdownProps:ft,reset:it,refreshProducts:It,recordSubmit:Tt}=ht({onSubmit:z=>C.current(z),onResult:t,onError:i,optionOverrides:o,maskCompletedText:s,apiConfig:c,additionalContext:d,language:w,productId:I,visitorId:T,columns:g,dropdownTrigger:j,optionsPosition:B,closeDropdownOnBlur:X,showNonTappableOptions:A,showOptionIcons:M,showOptionImages:G,showOptionCounts:Q,showSkipButton:O,showProducts:le,onFocus:Ke,onBlur:Te,value:m,completedParams:Ge,onChange:ve,onParamsChange:Ee,products:xe,mapProducts:Ae,onProductSelect:oe,source:"full-sdk",setCursor:U});(0,H.useEffect)(()=>{if(!Le)return;let z=window.setTimeout(()=>ke(),650);return()=>window.clearTimeout(z)},[Le,ke]);let ea=et>=0?`${qe}-option-${et}`:void 0,{inputRef:bt,editorProps:ta,focus:ot,blur:Et,getPlainText:At}=Xt({segments:Oe,newParamId:Le,editingParam:Ye,editingIdentified:tt,editingAnchor:gt,caretOffset:$e,placeholderText:u,isFocused:_e,showChipIcons:D,showChipImages:k,isDropdownOpen:Qe,listboxId:qe,activeDescendantId:ea,autoFocus:Ie,handleTextChange:mt,handleKeyDown:Me,handleCaretAfterInput:p,handleCaretMove:ee,startEditingParam:at,replaceEditingRange:L,setFocused:Ue});h.current=bt,(0,H.useLayoutEffect)(()=>{let z=x.current,ue=bt.current;if(!z||!ue)return;let Ze=()=>{let Dt=z.firstElementChild;if(!Dt)return;let na=Dt.getBoundingClientRect(),ra=ue.getBoundingClientRect();na.top>=ra.bottom-2?z.setAttribute("data-aia-pill-wrapped",""):z.removeAttribute("data-aia-pill-wrapped")};Ze();let Rt=new ResizeObserver(Ze);return Rt.observe(ue),()=>Rt.disconnect()},[Oe,De.length,he,bt]),(0,H.useImperativeHandle)(f,()=>({focus:ot,blur:Et,reset:it,refreshProducts:It,setMode:z=>R.current?.setMode(z),skipActivePill:y}),[ot,Et,it,It,y]);let nt=!!Oe.length||ne.length>0,wt=(0,H.useCallback)(z=>{if(!nt)return;let ue=At(),Ze=(0,Be.buildSubmitResult)(ue,ne,re,{identifiedParams:Re,isReady:ye,customFields:pe});z&&Tt(Ze),a(Ze),l&&it()},[Tt,l,nt,ne,re,Re,ye,pe,a,it,At]);C.current=()=>wt(!1);let aa=(0,H.useCallback)(z=>{z.target?.closest("[data-aia-pill]")||ot()},[ot]),ia=v==="inline",oa=v==="dropdown";return(0,ce.jsxs)("div",{ref:b,className:`magicx-aia ${Ve.container} ${n??""}`,"data-pill-placement":v,"data-options-position":B,"data-animations":K?"on":"off","data-mode":Ia(E),children:[(0,ce.jsx)(ct,{...ft,showPills:oa,productsLayout:Pe,productImageFallback:J}),(0,ce.jsxs)("div",{className:Ve.inputWrapper,"data-aia-input-wrapper":"",onClick:aa,children:[(0,ce.jsxs)("div",{className:Ve.editorArea,"data-aia-editor":"",children:[(0,ce.jsx)("div",{...ta,className:Ve.input,"data-aia-input":""}),ia&&(he||De.length>0)&&(0,ce.jsx)("span",{ref:x,className:Ve.pillListContainer,"data-aia-pill-list-container":"",children:(0,ce.jsx)(lt,{pills:De,activePillIndex:0,activeSelected:ze,onSelectPill:We,loading:he})})]}),de===null?null:de===void 0?(0,ce.jsx)(Yt,{disabled:!nt,onClick:()=>wt(!0),label:(0,Be.uiStringsFor)(w).submit}):(0,ce.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ve.submitSlot,onClick:z=>{nt&&(z.stopPropagation(),wt(!0))},children:de})]})]})});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,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2492
|
+
`,document.head.appendChild(e)}var Qt={submitButton:"aia-submitButton-otz7H"};var ht=require("react/jsx-runtime");function $t({disabled:e,onClick:a,label:t=(0,Yt.uiStringsFor)().submit}){return(0,ht.jsx)("button",{type:"button","data-aia-submit":"",className:Qt.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),a()},"aria-label":t,children:(0,ht.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:(0,ht.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ke=require("@magicx-eng/ai-autocomplete-vanilla"),S=require("react");var Pt=require("react");function Zt(e){let a=(0,Pt.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),i=(0,Pt.useRef)({key:"",overrides:void 0});if(i.current.key!==t){let o={};for(let s of Object.keys(e??{})){let n=(c,l,b)=>{let P=a.current?.[s];return P?P(c,l,b):[]};o[s]=n}i.current={key:t,overrides:e?o:void 0}}return{overrides:i.current.overrides,key:t}}var It=require("react");function Xt(e){let a=(0,It.useRef)(e);a.current=e;let t=(0,It.useRef)(null);t.current===null&&(t.current={fetch:(o,s)=>{let n=a.current;return n?n.fetch(o,s):Promise.reject(new Error("products config removed"))},transform:o=>a.current?.transform(o)??[],get limit(){return a.current?.limit}});let i=e!==void 0;return{config:i?t.current:void 0,enabled:i}}var Pa={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,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,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function ut({onSubmit:e,onResult:a,onError:t,optionOverrides:i,maskCompletedText:o,apiConfig:s,additionalContext:n,language:c,currency:l,productId:b,visitorId:P,columns:T=2,dropdownTrigger:f,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:D,showOptionIcons:K,showOptionImages:V,showOptionCounts:Z,showSkipButton:R,showProducts:O,productImageFallback:M="image",onFocus:k,onBlur:te,value:j,completedParams:A,onChange:re,onParamsChange:we,products:ie,mapProducts:ve,onProductSelect:Pe,source:We,setCursor:Ie}){let m=(0,S.useRef)(null),[Te,Ee]=(0,S.useState)(null),xe=(0,S.useRef)(e);xe.current=e;let Ae=(0,S.useRef)(a);Ae.current=a;let oe=(0,S.useRef)(t);oe.current=t;let ye=(0,S.useRef)(re);ye.current=re;let d=(0,S.useRef)(we);d.current=we;let g=(0,S.useRef)(k);g.current=k;let w=(0,S.useRef)(te);w.current=te;let v=(0,S.useRef)(Ie);v.current=Ie;let C=(0,S.useRef)(Pe);C.current=Pe;let F=(0,S.useRef)(P);F.current=P;let h=(0,S.useRef)(()=>{let p=F.current;return typeof p=="function"?p():p}).current,G=Xt(ie),se=(0,S.useRef)(ve);se.current=ve;let le=(0,S.useRef)((p,X)=>{let L=se.current;return L?L(p,X):p}).current,Re=ve?le:void 0,de=Zt(i);(0,S.useEffect)(()=>{if(typeof document>"u")return;let p=new Ke.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:n,language:c,currency:l,productId:b,visitorId:h,optionOverrides:de.overrides,maskCompletedText:o,columns:T,dropdownTrigger:f,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:D,showProducts:O,source:We,value:j,completedParams:A,onSubmit:(...L)=>xe.current?.(...L),onResult:(...L)=>Ae.current?.(...L),onError:(...L)=>oe.current?.(...L),onChange:(...L)=>ye.current?.(...L),onParamsChange:(...L)=>d.current?.(...L),onFocus:()=>g.current?.(),onBlur:()=>w.current?.(),onProductSelect:L=>C.current?.(L),setCursor:L=>v.current?.(L),products:G.config,mapProducts:Re});m.current=p,Ee(p.getState());let X=p.subscribe(L=>Ee(L));return()=>{X(),p.destroy(),m.current===p&&(m.current=null)}},[]),(0,S.useEffect)(()=>{j!==void 0&&m.current?.setValue(j)},[j]),(0,S.useEffect)(()=>{A!==void 0&&m.current?.setCompletedParams(A)},[A]);let De=JSON.stringify(s??null),Oe;try{Oe=JSON.stringify(n??null)}catch{Oe="[unstringifiable]"}(0,S.useEffect)(()=>{m.current?.update({apiConfig:s,additionalContext:n,language:c,currency:l,productId:b,optionOverrides:de.overrides,dropdownTrigger:f,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:D,showProducts:O})},[De,Oe,c,l?.code,l?.rate,l?.country,b,de.key,f,x,E,D,O]);let Le=(0,S.useRef)(!1);(0,S.useEffect)(()=>{if(!Le.current){Le.current=!0;return}m.current?.update({products:G.config})},[G.enabled]),(0,S.useEffect)(()=>{m.current?.update({mapProducts:Re})},[Re]);let ze=(0,S.useRef)(null);ze.current===null&&(ze.current={handleTextChange:p=>m.current?.handleTextChange(p),handleKeyDown:p=>{let X="nativeEvent"in p?p.nativeEvent:p;m.current?.handleKeyDown(X)},setFocused:p=>m.current?.setFocused(p),startEditingParam:p=>m.current?.startEditingParam(p),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:p=>m.current?.handleCaretAfterInput(p),handleCaretMove:p=>m.current?.handleCaretMove(p),replaceEditingRange:p=>m.current?.replaceEditingRange(p)??!1,setActivePill:p=>m.current?.setActivePill(p),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),refreshProducts:()=>m.current?.refreshProducts(),recordSubmit:p=>m.current?.recordSubmit(p),selectOption:p=>m.current?.selectOption(p),selectProduct:p=>m.current?.selectProduct(p),setActiveDropdownIndex:p=>m.current?.setActiveDropdownIndex(p),clearHighlight:p=>m.current?.clearHighlight(p),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let y=ze.current,Me=(0,S.useCallback)(p=>{let X=p.target.value,bt=X.length>0&&!p.nativeEvent?.isComposing&&X[0]!==X[0].toUpperCase()?X[0].toUpperCase()+X.slice(1):X;m.current?.handleTextChange(bt)},[]),Ne=(0,S.useCallback)(p=>{m.current?.handleKeyDown(p.nativeEvent)},[]),ke=m.current,u=Te??Pa,Ve=j!==void 0?j:u.text,je=A!==void 0?A:u.completedParams,pe=u.actionableSuggestions,Ye=pe[0],tt=(0,Ke.withoutTraditionalAutocomplete)(pe),_e=ke?.listboxId??"",gt=u.activeDropdownIndex>=0&&ke?`${_e}-option-${u.activeDropdownIndex}`:void 0,Fe=u.editingParam,qe=u.editingIdentified,$e=Fe?{parameter:Fe.suggestionParameter,text:Fe.suggestionPlaceholder,required:!0,options:Fe.options}:qe?{parameter:qe.parameter,text:(0,Ke.identifiedParamLabel)(qe.parameter),required:!0,options:[]}:null,at=u.dropdownSuggestion??$e??Ye,ft=$e?[$e]:pe,Ze=(0,Ke.dateSelectionFor)(u),it=!ke||u.dropdownLoading;return{completedParams:je,skippedParams:u.skippedParams,identifiedParams:u.identifiedParams,suggestionPills:tt,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:it,isFocused:u.isFocused,isDropdownOpen:u.isDropdownOpen,isActivePillSelected:u.isActivePillSelected,placeholderText:u.placeholderText,listboxId:_e,error:u.error,products:u.products,customFields:u.customFields,selectProduct:y.selectProduct,handleTextChange:y.handleTextChange,handleKeyDown:y.handleKeyDown,setFocused:y.setFocused,editingParam:Fe,editingIdentified:qe,editingAnchor:u.editingAnchor,caretOffset:u.caretOffset,startEditingParam:y.startEditingParam,exitEditMode:y.exitEditMode,handleCaretAfterInput:y.handleCaretAfterInput,handleCaretMove:y.handleCaretMove,replaceEditingRange:y.replaceEditingRange,inputProps:{value:Ve,placeholder:u.placeholderText||void 0,onChange:Me,onKeyDown:Ne,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":u.isDropdownOpen,"aria-activedescendant":gt,"aria-autocomplete":"list","aria-controls":_e},reset:y.reset,refreshProducts:y.refreshProducts,recordSubmit:y.recordSubmit,dropdownProps:{suggestions:at?[{...at,options:u.dropdownOptions}]:[],activeIndex:u.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,onUnhighlight:y.clearHighlight,isOpen:u.isDropdownOpen,id:_e,pills:ft,activeSelected:u.isActivePillSelected,onPillClick:y.setActivePill,onSkip:y.skipActivePill,showSkipButton:(R??!0)&&!Fe&&!qe,showOptionIcons:K??!0,showOptionImages:V??!0,showOptionCounts:Z??!0,skipDisabled:u.inSelectionAnimation,isLoading:it,skeletonExiting:u.skeletonExiting,isInputEmpty:Ve.trim().length===0,language:c,products:u.products,productImageFallback:M,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:x??"below"}}}var q=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react"),mt;function Ia(){if(mt!==void 0)return mt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),mt=e.contentEditable==="plaintext-only",mt}function Jt(e){let{segments:a,showChipIcons:t=!0,showChipImages:i=!0,newParamId:o,editingParam:s,editingIdentified:n,editingAnchor:c,caretOffset:l,placeholderText:b,isFocused:P,isDropdownOpen:T,listboxId:f,activeDescendantId:x,autoFocus:E,handleTextChange:D,handleKeyDown:K,handleCaretAfterInput:V,handleCaretMove:Z,startEditingParam:R,replaceEditingRange:O,setFocused:M}=e,k=(0,I.useRef)(null),te=(0,I.useRef)(!1),j=(0,I.useRef)(""),A=(0,I.useRef)(""),re=(0,I.useRef)(null),we=(0,I.useRef)(0);re.current=l,(0,I.useEffect)(()=>{if(!E)return;let d=k.current;if(!d)return;document.activeElement===d?M(!0):d.focus();let g=d.ownerDocument??document,w=g.getSelection(),v=w&&w.rangeCount>0&&d.contains(w.anchorNode);if(w&&!v){let C=g.createRange();C.selectNodeContents(d),C.collapse(!0),w.removeAllRanges(),w.addRange(C)}},[E,M]),(0,I.useEffect)(()=>{let d=k.current;if(!d)return;let g=d.ownerDocument??document,w=()=>{let v=g.getSelection();if(!v||v.rangeCount===0||!v.anchorNode||!d.contains(v.anchorNode))return;let C=v.anchorNode,F=C.nodeType===Node.ELEMENT_NODE?C:C.parentElement,G=(v.isCollapsed?F?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,se=s?.id??n?.id??null;if(G&&G!==se){R(G);return}performance.now()-we.current<50||Z((0,q.getCursorOffset)(d))};return g.addEventListener("selectionchange",w),()=>g.removeEventListener("selectionchange",w)},[s,n,R,Z]),(0,I.useEffect)(()=>{let d=k.current;if(!d)return;let g=w=>{let v=(0,q.chipIdFromTap)(d,w.target);v&&(R(v),(0,q.keepCaretOnChip)(d,v))};return d.addEventListener("click",g),()=>d.removeEventListener("click",g)},[R]),(0,I.useLayoutEffect)(()=>{let d=k.current;d&&(0,q.renderEditableContent)({input:d,segments:a,newParamId:o,editingParamId:s?.id??null,placeholderText:b??"",isFocused:P,showChipIcons:t,showChipImages:i})},[a,o,s,b,P,t,i]),(0,I.useLayoutEffect)(()=>{let d=j.current,g=o??"";if(j.current=g,!g||g===d)return;let w=k.current;if(!w)return;w.focus();let v=re.current??(0,q.plainTextLength)(w);(0,q.setCursorOffset)(w,v)},[o]),(0,I.useLayoutEffect)(()=>{let d=A.current,g=s?.id??"";if(A.current=g,!g||g===d||c==null)return;let w=k.current;w&&(0,q.setCursorOffset)(w,c)},[s,c]);let ie=(0,I.useCallback)(()=>{if(te.current)return;let d=k.current;if(!d)return;let g=(0,q.extractPlainText)(d),v=g.length>0&&g[0]!==g[0].toUpperCase()?g[0].toUpperCase()+g.slice(1):g;D(v)},[D]),ve=(0,I.useCallback)(()=>{we.current=performance.now(),ie();let d=k.current;d&&V((0,q.getCursorOffset)(d))},[ie,V]);(0,I.useEffect)(()=>{let d=k.current;if(!d)return;let g=w=>{let v=w,C=v.inputType;if(C==="insertParagraph"||C==="insertLineBreak"||C==="insertFromDrop"){w.preventDefault();return}if(C.startsWith("insert")||C.startsWith("delete")){let F=C.startsWith("delete")?"":v.data??"";O(F)&&w.preventDefault()}};return d.addEventListener("beforeinput",g),()=>d.removeEventListener("beforeinput",g)},[O]);let Pe=(0,I.useCallback)(()=>{te.current=!0,k.current?.setAttribute("data-aia-composing","true")},[]),We=(0,I.useCallback)(()=>{te.current=!1,k.current?.removeAttribute("data-aia-composing"),ie()},[ie]),Ie=(0,I.useCallback)(d=>{d.preventDefault();let g=k.current;if(!g)return;let w=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!w)return;let v=g.ownerDocument??document,C=v.getSelection();if(!C||C.rangeCount===0)return;let F=C.getRangeAt(0);if(!g.contains(F.startContainer))return;F.deleteContents();let h=v.createTextNode(w);F.insertNode(h),F.setStartAfter(h),F.collapse(!0),C.removeAllRanges(),C.addRange(F),ie()},[ie]),m=(0,I.useCallback)(d=>K(d),[K]),Te=(0,I.useCallback)(()=>M(!0),[M]),Ee=(0,I.useCallback)(()=>M(!1),[M]),xe=(0,I.useCallback)(()=>k.current?.focus(),[]),Ae=(0,I.useCallback)(()=>k.current?.blur(),[]),oe=(0,I.useCallback)(()=>{let d=k.current;return d?(0,q.extractPlainText)(d):""},[]),ye=Ia()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:ye,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":f,"aria-expanded":T,"aria-activedescendant":x,spellCheck:!0,enterKeyHint:"send",onInput:ve,onKeyDown:m,onCompositionStart:Pe,onCompositionEnd:We,onPaste:Ie,onFocus:Te,onBlur:Ee},getPlainText:oe,focus:xe,blur:Ae}}var ce=require("react/jsx-runtime");function Ta(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ea=(0,B.forwardRef)(function({onSubmit:a,onResult:t,onError:i,optionOverrides:o,maskCompletedText:s,className:n,apiConfig:c,additionalContext:l,language:b,currency:P,productId:T,visitorId:f,columns:x,pillPlacement:E="dropdown",mode:D="auto",optionsPosition:K="below",animations:V=!0,dropdownTrigger:Z,closeDropdownOnBlur:R,showNonTappableOptions:O,showOptionIcons:M=!0,showChipIcons:k=!0,showChipImages:te=!0,showOptionImages:j=!0,showOptionCounts:A=!0,showSkipButton:re,showProducts:we,productsLayout:ie,productImageFallback:ve,autoFocus:Pe=!0,onFocus:We,onBlur:Ie,value:m,completedParams:Te,onChange:Ee,onParamsChange:xe,products:Ae,mapProducts:oe,onProductSelect:ye,submitButton:d,resetOnSubmit:g=!0},w){let v=(0,B.useRef)(null),C=(0,B.useRef)(null),F=(0,B.useRef)(()=>{}),h=(0,B.useRef)(null),G=(0,B.useRef)(null);(0,B.useEffect)(()=>{let z=v.current;if(z)return h.current?h.current.setMode(D):h.current=new Ge.ModeController(z,D),()=>{h.current?.destroy(),h.current=null}},[D]);let se=(0,B.useCallback)(z=>{let he=G.current?.current;he&&(he.focus(),(0,Ge.setCursorOffset)(he,z))},[]),{completedParams:le,skippedParams:Re,identifiedParams:de,isReady:De,customFields:Oe,suggestionPills:Le,setActivePill:ze,skipActivePill:y,segments:Me,newParamId:Ne,clearNewParamId:ke,placeholderText:u,isFocused:Ve,isDropdownOpen:je,isActivePillSelected:pe,isLoading:Ye,activeIndex:tt,listboxId:_e,handleTextChange:gt,handleKeyDown:Fe,setFocused:qe,editingParam:$e,editingIdentified:at,editingAnchor:ft,caretOffset:Ze,startEditingParam:it,handleCaretAfterInput:p,handleCaretMove:X,replaceEditingRange:L,dropdownProps:bt,reset:ot,refreshProducts:Tt,recordSubmit:Et}=ut({onSubmit:z=>F.current(z),onResult:t,onError:i,optionOverrides:o,maskCompletedText:s,apiConfig:c,additionalContext:l,language:b,currency:P,productId:T,visitorId:f,columns:x,dropdownTrigger:Z,optionsPosition:K,closeDropdownOnBlur:R,showNonTappableOptions:O,showOptionIcons:M,showOptionImages:j,showOptionCounts:A,showSkipButton:re,showProducts:we,onFocus:We,onBlur:Ie,value:m,completedParams:Te,onChange:Ee,onParamsChange:xe,products:Ae,mapProducts:oe,onProductSelect:ye,source:"full-sdk",setCursor:se});(0,B.useEffect)(()=>{if(!Ne)return;let z=window.setTimeout(()=>ke(),650);return()=>window.clearTimeout(z)},[Ne,ke]);let ta=tt>=0?`${_e}-option-${tt}`:void 0,{inputRef:wt,editorProps:aa,focus:nt,blur:At,getPlainText:Rt}=Jt({segments:Me,newParamId:Ne,editingParam:$e,editingIdentified:at,editingAnchor:ft,caretOffset:Ze,placeholderText:u,isFocused:Ve,showChipIcons:k,showChipImages:te,isDropdownOpen:je,listboxId:_e,activeDescendantId:ta,autoFocus:Pe,handleTextChange:gt,handleKeyDown:Fe,handleCaretAfterInput:p,handleCaretMove:X,startEditingParam:it,replaceEditingRange:L,setFocused:qe});G.current=wt,(0,B.useLayoutEffect)(()=>{let z=C.current,he=wt.current;if(!z||!he)return;let Xe=()=>{let Ot=z.firstElementChild;if(!Ot)return;let ra=Ot.getBoundingClientRect(),sa=he.getBoundingClientRect();ra.top>=sa.bottom-2?z.setAttribute("data-aia-pill-wrapped",""):z.removeAttribute("data-aia-pill-wrapped")};Xe();let Dt=new ResizeObserver(Xe);return Dt.observe(he),()=>Dt.disconnect()},[Me,Le.length,Ye,wt]),(0,B.useImperativeHandle)(w,()=>({focus:nt,blur:At,reset:ot,refreshProducts:Tt,setMode:z=>h.current?.setMode(z),skipActivePill:y}),[nt,At,ot,Tt,y]);let rt=!!Me.length||le.length>0,vt=(0,B.useCallback)(z=>{if(!rt)return;let he=Rt(),Xe=(0,Ge.buildSubmitResult)(he,le,Re,{identifiedParams:de,isReady:De,customFields:Oe});z&&Et(Xe),a(Xe),g&&ot()},[Et,g,rt,le,Re,de,De,Oe,a,ot,Rt]);F.current=()=>vt(!1);let ia=(0,B.useCallback)(z=>{z.target?.closest("[data-aia-pill]")||nt()},[nt]),oa=E==="inline",na=E==="dropdown";return(0,ce.jsxs)("div",{ref:v,className:`magicx-aia ${Ue.container} ${n??""}`,"data-pill-placement":E,"data-options-position":K,"data-animations":V?"on":"off","data-mode":Ta(D),children:[(0,ce.jsx)(pt,{...bt,showPills:na,productsLayout:ie,productImageFallback:ve}),(0,ce.jsxs)("div",{className:Ue.inputWrapper,"data-aia-input-wrapper":"",onClick:ia,children:[(0,ce.jsxs)("div",{className:Ue.editorArea,"data-aia-editor":"",children:[(0,ce.jsx)("div",{...aa,className:Ue.input,"data-aia-input":""}),oa&&(Ye||Le.length>0)&&(0,ce.jsx)("span",{ref:C,className:Ue.pillListContainer,"data-aia-pill-list-container":"",children:(0,ce.jsx)(dt,{pills:Le,activePillIndex:0,activeSelected:pe,onSelectPill:ze,loading:Ye})})]}),d===null?null:d===void 0?(0,ce.jsx)($t,{disabled:!rt,onClick:()=>vt(!0),label:(0,Ge.uiStringsFor)(b).submit}):(0,ce.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ue.submitSlot,onClick:z=>{rt&&(z.stopPropagation(),vt(!0))},children:d})]})]})});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,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2493
2493
|
//# sourceMappingURL=index.js.map
|