@magicx-eng/ai-autocomplete-react 0.57.0 → 0.57.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/REFERENCE.md +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +72 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -294,7 +294,7 @@ function App() {
|
|
|
294
294
|
| `showOptionIcons?` | `boolean` | `true` | When `true`, an option that carries an `icon_svg` draws its icon before its text in the dropdown. Set to `false` to render option rows as text only. |
|
|
295
295
|
| `showChipIcons?` | `boolean` | `true` | When `true`, a completed chip in the input draws the icon of the option that answered it. Set to `false` to render chips as text only. |
|
|
296
296
|
| `showChipImages?` | `boolean` | `true` | When `true`, a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to `false` to render chips without pictures. |
|
|
297
|
-
| `showChipRemove?` | `boolean` | `false` | When `true`, every
|
|
297
|
+
| `showChipRemove?` | `boolean` | `false` | When `true`, every chip in the input ends in a small, faint "×" that removes that chip in one tap or click, the same result as Backspace at the chip's trailing edge. Chips the server identified in typed text get one too. The × reads `--aia-chip-remove-opacity` (0.32) and `--aia-chip-remove-opacity-hover` (0.7). |
|
|
298
298
|
| `showOptionImages?` | `boolean` | `true` | When `true`, an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown, in place of its icon. Set to `false` to render option rows without pictures. |
|
|
299
299
|
| `showOptionCounts?` | `boolean` | `true` | When `true`, an option that carries an `item_count` shows it as a muted label at the row's trailing edge (`"12 items"`). Set to `false` to hide the counts. |
|
|
300
300
|
| `autoFocus?` | `boolean` | `true` | Focus the input on mount. Set to `false` to leave focus to the consumer. |
|
|
@@ -422,7 +422,7 @@ The headless hook for Tier 2 and Tier 3. Accepts the same options as `<AIAutocom
|
|
|
422
422
|
| `setActivePill` | `(index: number) => void` | Move pill at `index` to front (active). |
|
|
423
423
|
| `skipActivePill` | `() => void` | Skip the active pill — same action as → / the dropdown's skip button. Records it in `skippedParams`; no-ops during re-edit and the post-selection window. Already wired into `dropdownProps.onSkip`; call it directly for a custom skip affordance (e.g. with `showSkipButton: false`). Also exposed on the Tier 1 imperative handle. |
|
|
424
424
|
| `removeLastParam` | `() => void` | Remove the last completed param from state. The text stays in the input as plain text. |
|
|
425
|
-
| `removeParam` | `(paramId: string) => boolean` | Remove the
|
|
425
|
+
| `removeParam` | `(paramId: string) => boolean` | Remove the chip with that id (completed or identified), the same result as Backspace at the chip's trailing edge; the chip's × (`showChipRemove`) calls it. Any value's id of one multi-select answer removes its joined chip. Returns `false`, changing nothing, when no chip has that id. |
|
|
426
426
|
| `clearNewParamId` | `() => void` | Clear shimmer animation state. |
|
|
427
427
|
| `reset` | `() => void` | Clear all state, re-fetch, and start a new session (rotates `session_id`). Call this after handling submit. |
|
|
428
428
|
| `recordSubmit` | `(result: AutocompleteResult) => void` | Record a submit from a button you render. Enter is recorded for you; call this once per button submit. |
|
package/REFERENCE.md
CHANGED
|
@@ -587,7 +587,7 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
|
|
|
587
587
|
| `--aia-date-today-ring` | `--aia-option-color` | `--aia-option-color` | Outline drawn around today's date. |
|
|
588
588
|
| `--aia-date-selected-bg` | white at 12% | white at 12% | Fill behind the date a re-edited parameter already holds. |
|
|
589
589
|
| `--aia-date-range-bg` | white at 6% | white at 6% | Band across the days between the two ends of a picked date range. The ends themselves use `--aia-date-selected-bg`. |
|
|
590
|
-
| `--aia-date-reference-bg` |
|
|
590
|
+
| `--aia-date-reference-bg` | the day's text colour at 14% | the day's text colour at 14% | Fill behind a day another answer already holds (the pickup date while the return date is asked), shown for reference with the number in the selected text colour and a heavier weight; the day stays pickable. |
|
|
591
591
|
| `--aia-time-panel-width` | `240px` | `240px` | Max width of the whole dropdown panel while the time wheel is up. |
|
|
592
592
|
| `--aia-time-font-size` | `15px` | `15px` | The time wheel's numbers and its `:` separator. |
|
|
593
593
|
| `--aia-time-band-bg` | white at 8% | white at 8% | The band behind the wheels' top rows — the chosen time. |
|
|
@@ -606,7 +606,7 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
|
|
|
606
606
|
| `--aia-location-font-size` | `15px` | `15px` | The location field's text and the place names. |
|
|
607
607
|
| `--aia-location-row-bg-highlighted` | `--aia-streak-rgb` at 8% (indigo) | `--aia-streak-rgb` at 8% (white) | The highlighted (or hovered) place. |
|
|
608
608
|
| `--aia-skeleton-bg` | `rgba(189, 189, 189, 0.083)` | `#1a1b1d` | Fill color of the option and chip image tiles while their picture loads (unless `--aia-option-image-bg` / `--aia-chip-image-bg` are set). |
|
|
609
|
-
| `--aia-chip-remove-opacity` | `0.32` | `0.32` | Opacity of a
|
|
609
|
+
| `--aia-chip-remove-opacity` | `0.32` | `0.32` | Opacity of a chip's remove × (`showChipRemove`). The × is for a mouse or a tap and is hidden from assistive technology; from the keyboard, Backspace at the end of a chip removes it. |
|
|
610
610
|
| `--aia-chip-remove-opacity-hover` | `0.7` | `0.7` | Opacity of that × under a hovering pointer (never on touch). |
|
|
611
611
|
|
|
612
612
|
Legacy `--aia-color-*` variables are still supported as fallbacks.
|
package/dist/index.d.mts
CHANGED
|
@@ -110,7 +110,7 @@ interface AIAutocompleteProps {
|
|
|
110
110
|
showChipIcons?: boolean;
|
|
111
111
|
/** When true (default), a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to false to render chips without pictures. */
|
|
112
112
|
showChipImages?: boolean;
|
|
113
|
-
/** When true, every
|
|
113
|
+
/** When true, every chip in the input (completed, or identified by the server in typed text) ends in a small, faint "×" that removes the chip in one tap (the same result as Backspace at the chip's trailing edge). Default: false. */
|
|
114
114
|
showChipRemove?: boolean;
|
|
115
115
|
/** When true (default), an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown (in place of its `icon_svg`). Set to false to render option rows without pictures. */
|
|
116
116
|
showOptionImages?: boolean;
|
|
@@ -526,7 +526,7 @@ interface UseAIAutocompleteReturn {
|
|
|
526
526
|
caretOffset: number | null;
|
|
527
527
|
/** Tier 1 re-edit: enter re-edit mode for the bold param with the given id. */
|
|
528
528
|
startEditingParam: (paramId: string) => void;
|
|
529
|
-
/** Remove the completed
|
|
529
|
+
/** Remove the chip (completed or identified) with the given id (the chip's "×", `showChipRemove`); the same result as Backspace at the chip's trailing edge. Returns false when no chip has that id. */
|
|
530
530
|
removeParam: (paramId: string) => boolean;
|
|
531
531
|
/** Tier 1 re-edit: exit re-edit mode. */
|
|
532
532
|
exitEditMode: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -110,7 +110,7 @@ interface AIAutocompleteProps {
|
|
|
110
110
|
showChipIcons?: boolean;
|
|
111
111
|
/** When true (default), a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to false to render chips without pictures. */
|
|
112
112
|
showChipImages?: boolean;
|
|
113
|
-
/** When true, every
|
|
113
|
+
/** When true, every chip in the input (completed, or identified by the server in typed text) ends in a small, faint "×" that removes the chip in one tap (the same result as Backspace at the chip's trailing edge). Default: false. */
|
|
114
114
|
showChipRemove?: boolean;
|
|
115
115
|
/** When true (default), an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown (in place of its `icon_svg`). Set to false to render option rows without pictures. */
|
|
116
116
|
showOptionImages?: boolean;
|
|
@@ -526,7 +526,7 @@ interface UseAIAutocompleteReturn {
|
|
|
526
526
|
caretOffset: number | null;
|
|
527
527
|
/** Tier 1 re-edit: enter re-edit mode for the bold param with the given id. */
|
|
528
528
|
startEditingParam: (paramId: string) => void;
|
|
529
|
-
/** Remove the completed
|
|
529
|
+
/** Remove the chip (completed or identified) with the given id (the chip's "×", `showChipRemove`); the same result as Backspace at the chip's trailing edge. Returns false when no chip has that id. */
|
|
530
530
|
removeParam: (paramId: string) => boolean;
|
|
531
531
|
/** Tier 1 re-edit: exit re-edit mode. */
|
|
532
532
|
exitEditMode: () => void;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Lt=Object.defineProperty;var Ea=Object.getOwnPropertyDescriptor;var Aa=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var Lt=Object.defineProperty;var Ea=Object.getOwnPropertyDescriptor;var Aa=Object.getOwnPropertyNames;var Oa=Object.prototype.hasOwnProperty;var Ra=(e,a)=>{for(var t in a)Lt(e,t,{get:a[t],enumerable:!0})},La=(e,a,t,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of Aa(a))!Oa.call(e,o)&&o!==t&&Lt(e,o,{get:()=>a[o],enumerable:!(i=Ea(a,o))||i.enumerable});return e};var za=e=>La(Lt({},"__esModule",{value:!0}),e);var si={};Ra(si,{AIAutocomplete:()=>xa,AIAutocompleteDropdown:()=>Pt,DATE_RANGE_META_END:()=>d.DATE_RANGE_META_END,DATE_RANGE_META_START:()=>d.DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT:()=>d.DEFAULT_OPTION_COUNT_UNIT,LOCATION_META_KEY:()=>d.LOCATION_META_KEY,PRODUCT_PATH_PREFIX:()=>d.PRODUCT_PATH_PREFIX,TIME_META_KEY:()=>d.TIME_META_KEY,WEEKDAY_LABELS:()=>d.WEEKDAY_LABELS,buildSubmitResult:()=>d.buildSubmitResult,cellDay:()=>d.cellDay,cellIso:()=>d.cellIso,dateCellMarks:()=>d.dateCellMarks,formatDate:()=>d.formatDate,formatDateRange:()=>d.formatDateRange,formatOptionCount:()=>d.formatOptionCount,formatPlace:()=>d.formatPlace,formatTime:()=>d.formatTime,isoDate:()=>d.isoDate,monthLabel:()=>d.monthLabel,optionCountLabel:()=>d.optionCountLabel,optionHasImage:()=>d.optionHasImage,optionImageSources:()=>d.optionImageSources,optionImageSrc:()=>d.optionImageSrc,optionLabel:()=>d.optionLabel,optionsShowLeadingVisuals:()=>d.optionsShowLeadingVisuals,parseDate:()=>d.parseDate,parseLooseDate:()=>d.parseLooseDate,parseLooseDateRange:()=>d.parseLooseDateRange,parseTime:()=>d.parseTime,productFromMatchedItem:()=>d.productFromMatchedItem,productImageSources:()=>d.productImageSources,productsFromCustomFields:()=>d.productsFromCustomFields,sanitizeOptionIconSvg:()=>d.sanitizeOptionIconSvg,selectedRangeFor:()=>d.selectedRangeFor,useAIAutocomplete:()=>Et,visibleDateRange:()=>d.visibleDateRange,withSkippedParams:()=>d.withSkippedParams});module.exports=za(si);var d=require("@magicx-eng/ai-autocomplete-vanilla");var ee=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
|
|
@@ -1594,7 +1594,35 @@
|
|
|
1594
1594
|
transition-delay: 0s;
|
|
1595
1595
|
}
|
|
1596
1596
|
}
|
|
1597
|
-
|
|
1597
|
+
|
|
1598
|
+
/* The multi-select Done row stays mounted while a request loads, so it leaves
|
|
1599
|
+
and returns with the options on the same 160ms instead of standing at full
|
|
1600
|
+
strength over rows that are gone (vanilla's styles.css does the same). */
|
|
1601
|
+
.aia-dropdown-yz2KC[data-aia-loading] [data-aia-multi-actions] {
|
|
1602
|
+
pointer-events: none;
|
|
1603
|
+
animation: aia-multiActionsLoadingOut-lSdMh 160ms ease-in forwards;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
.aia-dropdown-yz2KC:not([data-aia-loading]) [data-aia-multi-actions] {
|
|
1607
|
+
animation: aia-multiActionsFadeIn-zbGTG 160ms ease-out;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/* Ends and starts a hair above zero: iOS cancels a tap on an element at 0. */
|
|
1611
|
+
@keyframes aia-multiActionsLoadingOut-lSdMh {
|
|
1612
|
+
to {
|
|
1613
|
+
opacity: 0.01;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
@keyframes aia-multiActionsFadeIn-zbGTG {
|
|
1618
|
+
from {
|
|
1619
|
+
opacity: 0.01;
|
|
1620
|
+
}
|
|
1621
|
+
to {
|
|
1622
|
+
opacity: 1;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
`,document.head.appendChild(e)}var Ne={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",skeletonBar:"aia-skeletonBar-O3xIx",multiDone:"aia-multiDone-y12U7",multiActionsLoadingOut:"aia-multiActionsLoadingOut-lSdMh",multiActionsFadeIn:"aia-multiActionsFadeIn-zbGTG"};var ie=require("@magicx-eng/ai-autocomplete-vanilla"),Qt=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) ---
|
|
1598
1626
|
|
|
1599
1627
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1600
1628
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1778,17 +1806,20 @@
|
|
|
1778
1806
|
}
|
|
1779
1807
|
|
|
1780
1808
|
/* A day another answer already holds (the pickup date while the return date is
|
|
1781
|
-
asked): a
|
|
1782
|
-
|
|
1809
|
+
asked): a filled box for reference, still pickable. The fill is mixed from
|
|
1810
|
+
the day's own text colour, not the streak tint, so it shows on a light panel
|
|
1811
|
+
and a dark one alike, whatever the theme sets. */
|
|
1783
1812
|
.aia-reference-Q5bXf .aia-number-aoT01 {
|
|
1784
|
-
|
|
1813
|
+
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
1814
|
+
background: var(--aia-date-reference-bg, color-mix(in srgb, currentColor 14%, transparent));
|
|
1815
|
+
font-weight: 500;
|
|
1785
1816
|
}
|
|
1786
1817
|
|
|
1787
1818
|
.aia-pressed-bEyyN .aia-number-aoT01 {
|
|
1788
1819
|
opacity: 0.8;
|
|
1789
1820
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1790
1821
|
}
|
|
1791
|
-
`,document.head.appendChild(e)}var $={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",reference:"aia-reference-Q5bXf",pressed:"aia-pressed-bEyyN"};var we=require("react/jsx-runtime"),Da=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Yt({options:e,activeIndex:a,listboxId:t,view:i,selection:o,onSelect:s,onHighlight:r,onUnhighlight:l,onPreviousMonth:
|
|
1822
|
+
`,document.head.appendChild(e)}var $={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",reference:"aia-reference-Q5bXf",pressed:"aia-pressed-bEyyN"};var we=require("react/jsx-runtime"),Da=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Yt({options:e,activeIndex:a,listboxId:t,view:i,selection:o,onSelect:s,onHighlight:r,onUnhighlight:l,onPreviousMonth:b,onNextMonth:v}){let k=(0,ie.isoDate)(new Date),f=(0,ie.visibleDateRange)({pendingStart:o.rangeStart,highlightedIso:(0,ie.cellIso)(e[a]),selected:o.selectedRange,floor:o.floor});return(0,we.jsxs)("div",{className:$.datepicker,"data-aia-datepicker":"",children:[(0,we.jsxs)("div",{className:$.header,children:[(0,we.jsx)("button",{type:"button",tabIndex:-1,className:$.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:b,children:"\u2039"}),(0,we.jsx)("span",{className:$.month,"data-aia-date-month":"","aria-live":"polite",children:(0,ie.monthLabel)(i)}),(0,we.jsx)("button",{type:"button",tabIndex:-1,className:$.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:v,children:"\u203A"})]}),(0,we.jsx)("div",{className:$.weekdays,"aria-hidden":"true",children:ie.WEEKDAY_LABELS.map((u,p)=>(0,we.jsx)("span",{className:$.weekday,children:u},Da[p]))}),(0,we.jsx)("div",{className:$.grid,"data-aia-date-grid":"",children:e.map((u,p)=>(0,we.jsx)(Ma,{option:u,id:`${t}-option-${p}`,index:p,isHighlighted:p===a&&u.is_tappable,isToday:(0,ie.cellIso)(u)===k,isPast:(0,ie.isDimmedDay)((0,ie.cellIso)(u),k,o.floor),marks:(0,ie.dateCellMarks)((0,ie.cellIso)(u),{selectedIso:o.selectedIso,range:f,references:o.references}),onSelect:s,onHighlight:r,onUnhighlight:l},(0,ie.cellIso)(u)??`pad-${p}`))})]})}function Ma({option:e,id:a,index:t,isHighlighted:i,isToday:o,isPast:s,marks:r,onSelect:l,onHighlight:b,onUnhighlight:v}){let[k,f]=(0,Qt.useState)(!1),u=(0,ie.cellDay)(e);if(u==null)return(0,we.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${$.cell} ${$.blank}`});let p=()=>{f(!0),l(e),setTimeout(()=>f(!1),170)},x=[$.cell,$.day,s?$.past:"",i?$.highlighted:"",o?$.today:"",r.inRange?$.inRange:"",r.selected?$.selected:"",r.reference?$.reference:"",k?$.pressed:""].filter(Boolean).join(" ");return(0,we.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:x,onClick:p,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),p())},onMouseEnter:()=>b(t),onMouseLeave:v?()=>v(t):void 0,children:(0,we.jsx)("span",{className:$.number,children:u})})}var Xe=require("@magicx-eng/ai-autocomplete-vanilla"),kt=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 {
|
|
1792
1823
|
display: flex;
|
|
1793
1824
|
flex-wrap: wrap;
|
|
1794
1825
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1828,7 +1859,7 @@
|
|
|
1828
1859
|
.aia-cluster[data-justify="around"] {
|
|
1829
1860
|
justify-content: space-around;
|
|
1830
1861
|
}
|
|
1831
|
-
`,document.head.appendChild(e)}var zt=require("react/jsx-runtime");function bt({gap:e,align:a="center",justify:t="start",noWrap:i=!1,inline:o=!1,className:s,children:r,...l}){let
|
|
1862
|
+
`,document.head.appendChild(e)}var zt=require("react/jsx-runtime");function bt({gap:e,align:a="center",justify:t="start",noWrap:i=!1,inline:o=!1,className:s,children:r,...l}){let b=e?{"--aia-cluster-gap":e}:void 0,v={className:s?`aia-cluster ${s}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":i||void 0,"data-inline":o||void 0,style:b,...l};return o?(0,zt.jsx)("span",{...v,children:r}):(0,zt.jsx)("div",{...v,children:r})}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
|
|
1832
1863
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1833
1864
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1834
1865
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1975,7 +2006,7 @@
|
|
|
1975
2006
|
justify-content: flex-end;
|
|
1976
2007
|
}
|
|
1977
2008
|
}
|
|
1978
|
-
`,document.head.appendChild(e)}var Ke={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
|
|
2009
|
+
`,document.head.appendChild(e)}var Ke={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 Fe=require("react/jsx-runtime");function jt({isOptionHighlighted:e=!1,isInputEmpty:a=!1,strings:t=(0,Xe.uiStringsFor)()}){let{key:i,hint:o}=(0,Xe.getFooterHint)(e,a,t),[s,r]=(0,kt.useState)(Xe.ATTRIBUTION_URL);return(0,kt.useEffect)(()=>{r((0,Xe.buildAttributionUrl)())},[]),(0,Fe.jsx)("footer",{className:Ke.footer,"data-aia-footer":"",children:(0,Fe.jsxs)(bt,{justify:"between",noWrap:!0,className:Ke.row,children:[(0,Fe.jsxs)(bt,{gap:"5px",className:Ke.hintGroup,children:[(0,Fe.jsx)("kbd",{className:Ke.key,children:i}),(0,Fe.jsx)("span",{className:Ke.hint,children:o})]}),(0,Fe.jsxs)("a",{className:Ke.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[(0,Fe.jsx)("span",{className:Ke.brand,children:"AI"}),(0,Fe.jsx)("span",{className:Ke.badge,children:"Autocomplete"})]})]})})}var de=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-2feec02e")){let e=document.createElement("style");e.id="ac-style-2feec02e",e.textContent=`/* Location search \u2014 React copy of the vanilla rules in styles.css (and of the
|
|
1979
2010
|
Angular copy). The three are kept identical by
|
|
1980
2011
|
packages/vanilla/tests/render/locationFieldParity.test.ts. */
|
|
1981
2012
|
.aia-location-6-fsr {
|
|
@@ -2109,7 +2140,7 @@
|
|
|
2109
2140
|
.aia-loadingBar-OLCr4:nth-child(3) {
|
|
2110
2141
|
width: 60%;
|
|
2111
2142
|
}
|
|
2112
|
-
`,document.head.appendChild(e)}var oe={location:"aia-location-6-fsr",field:"aia-field-xEzwi",icon:"aia-icon-czx6C",input:"aia-input-Yi9V-",results:"aia-results-C3O0V",row:"aia-row-Q9y8g",highlighted:"aia-highlighted-RJjPx",pin:"aia-pin-OjabL",text:"aia-text-Xs84O",name:"aia-name-Z-WJR",secondary:"aia-secondary-4sCT1",note:"aia-note-xCSvY",empty:"aia-empty-SYBzi",loading:"aia-loading-Ih1gi",loadingBar:"aia-loadingBar-OLCr4"};var G=require("react/jsx-runtime"),Na=0;function wt(e){return e.getRootNode().activeElement??null}function Xt(e){return e.getRootNode().getSelection?.()??document.getSelection()}function $t(e){if(!e.isContentEditable)return null;let a=Xt(e);if(!a||a.rangeCount===0)return null;let t=a.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function Zt(e,a){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=Xt(e);if(!t)return;let i=a;(!i||!i.startContainer.isConnected||!e.contains(i.startContainer))&&(i=document.createRange(),i.selectNodeContents(e),i.collapse(!1)),t.removeAllRanges(),t.addRange(i)}var
|
|
2143
|
+
`,document.head.appendChild(e)}var oe={location:"aia-location-6-fsr",field:"aia-field-xEzwi",icon:"aia-icon-czx6C",input:"aia-input-Yi9V-",results:"aia-results-C3O0V",row:"aia-row-Q9y8g",highlighted:"aia-highlighted-RJjPx",pin:"aia-pin-OjabL",text:"aia-text-Xs84O",name:"aia-name-Z-WJR",secondary:"aia-secondary-4sCT1",note:"aia-note-xCSvY",empty:"aia-empty-SYBzi",loading:"aia-loading-Ih1gi",loadingBar:"aia-loadingBar-OLCr4"};var G=require("react/jsx-runtime"),Na=0;function wt(e){return e.getRootNode().activeElement??null}function Xt(e){return e.getRootNode().getSelection?.()??document.getSelection()}function $t(e){if(!e.isContentEditable)return null;let a=Xt(e);if(!a||a.rangeCount===0)return null;let t=a.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function Zt(e,a){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=Xt(e);if(!t)return;let i=a;(!i||!i.startContainer.isConnected||!e.contains(i.startContainer))&&(i=document.createRange(),i.selectNodeContents(e),i.collapse(!1)),t.removeAllRanges(),t.addRange(i)}var Fa=(0,G.jsxs)("svg",{className:oe.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,G.jsx)("path",{d:"M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"}),(0,G.jsx)("circle",{cx:"12",cy:"9.5",r:"2.5"})]}),Ha=(0,G.jsxs)("svg",{className:oe.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[(0,G.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,G.jsx)("path",{d:"m20 20-3.5-3.5"})]});function Jt({view:e,searchLabel:a,noResultsLabel:t,useTypedLabel:i,widgetFocused:o,reediting:s=!1,visible:r=!0,interactive:l=!0,onQuery:b,onMove:v,onCommit:k,onFocusChange:f}){let u=(0,de.useRef)(null),p=(0,de.useRef)(null),x=(0,de.useRef)(null),A=(0,de.useRef)(null),te=(0,de.useRef)(null),F=(0,de.useRef)(!1),D=(0,de.useRef)(!1),he=(0,de.useRef)(!1),T=(0,de.useRef)(!1),W=(0,de.useRef)(o);W.current=o;let V=(0,de.useRef)(f);V.current=f;let K=c=>{T.current=c,f(c)},U=()=>{let c=u.current;return c!=null&&wt(c)===c},P=()=>{let c=p.current;if(!c)return;let I=wt(c);I instanceof HTMLElement&&I!==u.current&&I!==document.body&&!c.contains(I)&&(A.current=I,te.current=$t(I))},ae=c=>{let I=p.current;!I||!(c instanceof HTMLElement)||c===A.current||c===document.body||I.contains(c)||(A.current=c,te.current=$t(c))},re=(0,de.useRef)(null);re.current===null&&(re.current=`aia-location-${++Na}`);let O=`${re.current}-row-`;(0,de.useEffect)(()=>{let c=u.current;c&&c.value!==e.query&&wt(c)!==c&&(c.value=e.query)},[e.query]),(0,de.useEffect)(()=>{o&&(s&&!he.current&&(D.current=!1),he.current=s);let c=u.current;if(c){if(!r&&U()){D.current=!0,j();return}if(!o){setTimeout(()=>{if(W.current)return;let I=A.current;I&&wt(I)===I||(D.current=!1)},0);return}if(!(!s||D.current||!l||U())){if(P(),K(!0),c.focus({preventScroll:!0}),!U()){D.current=!0,K(!1);return}c.value&&c.select()}}}),(0,de.useLayoutEffect)(()=>()=>{if(!T.current)return;let c=u.current,I=A.current;I?.isConnected&&c&&wt(c)===c&&(F.current=!0,Zt(I,te.current),F.current=!1),T.current=!1,V.current(!1)},[]);let j=(c=!1)=>{c&&(D.current=!0);let I=A.current;I?.isConnected&&U()&&(F.current=!0,Zt(I,te.current),F.current=!1),K(!1)},Se=e.query.trim(),ue=e.highlighted>=0&&e.highlighted<e.places.length?`${O}${e.highlighted}`:void 0,xe=null;return e.places.length>0?xe=e.places.map((c,I)=>(0,G.jsxs)("div",{id:`${O}${I}`,role:"option","aria-selected":I===e.highlighted,className:I===e.highlighted?`${oe.row} ${oe.highlighted}`:oe.row,"data-aia-location-row":"","data-aia-index":I,onClick:()=>{l&&(j(!0),k(I))},children:[(0,G.jsx)("span",{className:oe.pin,children:Fa}),(0,G.jsxs)("span",{className:oe.text,children:[(0,G.jsx)("span",{className:oe.name,children:c.name}),c.secondary&&(0,G.jsx)("span",{className:oe.secondary,children:c.secondary})]})]},c.id)):e.status==="loading"?xe=(0,G.jsxs)("div",{className:oe.loading,"data-aia-location-loading":"",children:[(0,G.jsx)("span",{className:oe.loadingBar}),(0,G.jsx)("span",{className:oe.loadingBar}),(0,G.jsx)("span",{className:oe.loadingBar})]}):Se&&(xe=(0,G.jsxs)("div",{className:oe.note,"data-aia-location-note":"",children:[e.status==="done"&&(0,G.jsx)("span",{className:oe.empty,children:t}),(0,G.jsx)("span",{children:i})]})),(0,G.jsxs)("div",{ref:p,className:oe.location,"data-aia-location":"",onMouseDown:c=>{!(c.target instanceof Node)||!x.current?.contains(c.target)||(c.stopPropagation(),P(),K(!0))},children:[(0,G.jsxs)("label",{ref:x,className:oe.field,children:[Ha,(0,G.jsx)("input",{ref:u,type:"text",className:oe.input,"data-aia-location-input":"",defaultValue:e.query,placeholder:a,"aria-label":a,"aria-activedescendant":ue,autoComplete:"off",autoCapitalize:"words",enterKeyHint:"done",spellCheck:!1,tabIndex:r?0:-1,onChange:c=>b(c.target.value),onFocus:c=>{ae(c.relatedTarget),K(!0)},onBlur:()=>{F.current||(D.current=!0,K(!1))},onKeyDown:c=>{if(!c.nativeEvent.isComposing)switch(c.key){case"ArrowDown":case"ArrowUp":c.preventDefault(),v(c.key==="ArrowDown"?1:-1);return;case"Enter":if(c.preventDefault(),!l)return;j(!0),k();return;case"Escape":c.preventDefault(),c.stopPropagation(),D.current=!0,j();return;case"Backspace":if(c.currentTarget.value!=="")return;c.preventDefault(),D.current=!0,j();return}}})]}),(0,G.jsx)("div",{className:oe.results,"data-aia-location-results":"","aria-live":"polite",children:xe})]})}var Ct=require("@magicx-eng/ai-autocomplete-vanilla");var ea=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,
|
|
2113
2144
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
2114
2145
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
2115
2146
|
as it was when the outline was dashed. */
|
|
@@ -2267,7 +2298,7 @@
|
|
|
2267
2298
|
opacity: 0;
|
|
2268
2299
|
}
|
|
2269
2300
|
}
|
|
2270
|
-
`,document.head.appendChild(e)}var
|
|
2301
|
+
`,document.head.appendChild(e)}var He={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",loadingOut:"aia-loadingOut-Aj9xO"};var Je=require("react/jsx-runtime"),Dt={selected:1,first:.7,next:.4,last:.2};function ta({label:e,state:a,active:t,rounded:i,loading:o,smartSuggestion:s,completionHeader:r,onClick:l}){let b=[He.pill,i?He.rounded:"",o?He.skeleton:""].filter(Boolean).join(" ");return(0,Je.jsx)("button",{type:"button","data-aia-pill":"","data-aia-pill-active":t?"":void 0,"data-aia-loading":o?"":void 0,"data-aia-smart-suggestion":s?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:b,style:{"--aia-pill-opacity":Dt[a]},onMouseDown:v=>v.preventDefault(),onClick:o?void 0:l,disabled:o,children:s?(0,Je.jsxs)(Je.Fragment,{children:[(0,Je.jsx)("span",{className:`${He.smartText} magicx-aia-smart-suggestion-text`,children:e}),(0,Je.jsx)("span",{className:`${He.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:ea.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 {
|
|
2271
2302
|
position: relative;
|
|
2272
2303
|
z-index: 1;
|
|
2273
2304
|
pointer-events: auto;
|
|
@@ -2277,7 +2308,7 @@
|
|
|
2277
2308
|
align-items: center;
|
|
2278
2309
|
vertical-align: middle;
|
|
2279
2310
|
}
|
|
2280
|
-
`,document.head.appendChild(e)}var Mt={list:"aia-list-qvLqO"};var vt=require("react/jsx-runtime"),Ba=[125,69];function aa(e){return e===0?"first":e===1?"next":"last"}function St({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:i,rounded:o,loading:s}){return s&&e.length===0?(0,vt.jsx)("span",{className:Mt.list,"data-aia-pill-list-loading":"",children:Ba.map((r,l)=>(0,vt.jsx)("span",{"data-aia-pill-skeleton":"",className:`${
|
|
2311
|
+
`,document.head.appendChild(e)}var Mt={list:"aia-list-qvLqO"};var vt=require("react/jsx-runtime"),Ba=[125,69];function aa(e){return e===0?"first":e===1?"next":"last"}function St({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:i,rounded:o,loading:s}){return s&&e.length===0?(0,vt.jsx)("span",{className:Mt.list,"data-aia-pill-list-loading":"",children:Ba.map((r,l)=>(0,vt.jsx)("span",{"data-aia-pill-skeleton":"",className:`${He.pill} ${o?He.rounded:""} ${He.skeleton}`,style:{width:r,"--aia-pill-opacity":Dt[aa(l)]}},`skel-${r}`))}):(0,vt.jsx)("span",{className:Mt.list,"data-aia-pill-list-loading":s?"":void 0,children:e.map((r,l)=>{let b=!!i&&l===a;return(0,vt.jsx)(ta,{label:r.text,state:b?"selected":aa(l),selected:b,active:l===a,rounded:o,loading:s,smartSuggestion:(0,Ct.isSmartSuggestion)(r),completionHeader:(0,Ct.isTraditionalAutocompleteSuggestion)(r),onClick:()=>t(l)},`${r.parameter}-${r.text}`)})})}var ke=require("@magicx-eng/ai-autocomplete-vanilla"),ve=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
|
|
2281
2312
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
2282
2313
|
theming one package sees the same result in the other.
|
|
2283
2314
|
|
|
@@ -2846,7 +2877,31 @@
|
|
|
2846
2877
|
.aia-card-JBGYT[data-aia-product-has-cart] {
|
|
2847
2878
|
padding-right: calc(var(--aia-product-cart-size, 28px) + 16px);
|
|
2848
2879
|
}
|
|
2849
|
-
|
|
2880
|
+
|
|
2881
|
+
/* The strip leaves and returns with the options: it fades out on the same
|
|
2882
|
+
160ms while a request loads and fades back when the response lands, so a
|
|
2883
|
+
step change never leaves it at full strength over rows that are gone. */
|
|
2884
|
+
.aia-section-Hugfg[data-aia-loading] {
|
|
2885
|
+
pointer-events: none;
|
|
2886
|
+
animation: aia-stripLoadingOut-0jOOQ 160ms ease-in forwards;
|
|
2887
|
+
}
|
|
2888
|
+
|
|
2889
|
+
.aia-section-Hugfg:not([data-aia-loading]) {
|
|
2890
|
+
animation: aia-stripFadeIn-0p9qx 160ms ease-out;
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
@keyframes aia-stripLoadingOut-0jOOQ {
|
|
2894
|
+
to {
|
|
2895
|
+
opacity: 0.01;
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2899
|
+
@keyframes aia-stripFadeIn-0p9qx {
|
|
2900
|
+
from {
|
|
2901
|
+
opacity: 0.01;
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
`,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",compareAt:"aia-compareAt-ewE54",badge:"aia-badge-j9Hcd",cart:"aia-cart-kSlqU",cartCheck:"aia-cartCheck-YTTQ6",cartGlyph:"aia-cartGlyph-cmqAk",cartSpinner:"aia-cartSpinner-442rc","magicx-aia-product-cart-spin":"aia-magicx-aia-product-cart-spin-x8mgr",stripLoadingOut:"aia-stripLoadingOut-0jOOQ",stripFadeIn:"aia-stripFadeIn-0p9qx"};var B=require("react/jsx-runtime");function ia({products:e,listboxId:a,onSelect:t,onAddToCart:i,onFocusChange:o,focusable:s=!0,loading:r=!1,layout:l="row",imageFallback:b="image",strings:v=(0,ke.uiStringsFor)()}){let k=e.length>0,f=(0,ve.useRef)(null);if((0,ve.useEffect)(()=>{let p=f.current;if(!(!k||!p))return(0,ke.attachProductRowWheel)(p)},[k]),!k)return null;let u=`${a}-products-label`;return(0,B.jsxs)("section",{className:ne.section,"data-aia-products":"","data-aia-loading":r?"":void 0,"data-aia-products-layout":l,role:"group","aria-labelledby":u,children:[(0,B.jsx)("div",{className:ne.label,id:u,"data-aia-products-label":"",children:v.products}),(0,B.jsx)("div",{ref:f,className:ne.row,"data-aia-products-row":"",children:e.map((p,x)=>(0,B.jsx)(Wa,{product:p,id:`${a}-product-${x}`,onSelect:t,onAddToCart:i,onFocusChange:o,focusable:s,imageFallback:b,soldOut:v.soldOut,addToCart:v.addToCart},p.id))})]})}function Wa({product:e,id:a,onSelect:t,onAddToCart:i,onFocusChange:o,focusable:s,imageFallback:r,soldOut:l,addToCart:b}){let v=!!i&&e.available!==!1,[k,f]=(0,ve.useState)(null),u=x=>{x.relatedTarget?.closest("[data-aia-dropdown]")||o?.(!1)},p=x=>{x.metaKey||x.ctrlKey||x.shiftKey||x.altKey||x.button!==0||(x.preventDefault(),t(e))};return(0,B.jsxs)("a",{id:a,className:ne.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":v?"":void 0,role:"option","aria-selected":!1,style:k?{"--aia-product-photo-fill-x":String(k.x),"--aia-product-photo-fill-y":String(k.y)}:void 0,href:e.url,tabIndex:s?0:-1,onClick:p,onKeyDown:x=>{x.key!=="Enter"&&x.key!==" "||(x.preventDefault(),t(e))},onFocus:()=>o?.(!0),onBlur:u,children:[(0,B.jsx)(qa,{sources:(0,ke.productImageSources)(e.imageUrl),title:e.title,fallback:r,onPhotoFill:f},(0,ke.productImageSrc)(e.imageUrl)??""),(0,B.jsxs)("span",{className:ne.body,children:[e.vendor?(0,B.jsx)("span",{className:ne.vendor,children:e.vendor}):null,(0,B.jsx)("span",{className:ne.title,children:e.title}),e.price?(0,B.jsxs)("span",{className:ne.price,children:[e.price,e.compareAtPrice?(0,B.jsx)("s",{className:ne.compareAt,children:e.compareAtPrice}):null]}):null,e.available===!1?(0,B.jsx)("span",{className:ne.badge,children:l}):null]}),v&&i?(0,B.jsx)(Ka,{product:e,label:`${b}: ${e.title}`,focusable:s,onAddToCart:i,onFocus:()=>o?.(!0),onBlur:u},Ga(e)):null]})}function Ga(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(a=>a??"").join("\0")}function Ka({product:e,label:a,focusable:t,onAddToCart:i,onFocus:o,onBlur:s}){let[r,l]=(0,ve.useState)(null),b=(0,ve.useRef)(null),v=(0,ve.useRef)(e);v.current=e;let k=(0,ve.useRef)(!0);(0,ve.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let f=p=>{b.current=p,k.current&&l(p)},u=p=>{if(p.preventDefault(),p.stopPropagation(),b.current==="adding")return;f("adding");let x;try{x=Promise.resolve(i(v.current))}catch(A){x=Promise.reject(A)}x.then(()=>f("added"),()=>f(null))};return(0,B.jsx)("span",{className:ne.cart,"data-aia-product-cart":"","data-aia-cart-state":r??void 0,"aria-busy":r==="adding"?!0:void 0,role:"button","aria-label":a,tabIndex:t?0:-1,onClick:u,onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||u(p)},onFocus:p=>{p.stopPropagation(),o()},onBlur:p=>{p.stopPropagation(),s(p)},children:(0,B.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[(0,B.jsx)("path",{className:ne.cartGlyph,d:"M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"}),(0,B.jsx)("path",{className:ne.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),(0,B.jsx)("path",{className:ne.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),(0,B.jsx)("path",{className:ne.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),(0,B.jsx)("circle",{className:ne.cartGlyph,cx:"9",cy:"20",r:"1.3"}),(0,B.jsx)("circle",{className:ne.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function qa({sources:e,title:a,fallback:t,onPhotoFill:i}){let[o,s]=(0,ve.useState)(0),r=e[o],l=!!r,[b,v]=(0,ve.useState)(null),k=!l&&t==="initial";return(0,ve.useEffect)(()=>()=>i(null),[i]),(0,B.jsxs)("span",{className:ne.media,"aria-hidden":"true","data-aia-product-placeholder":!l&&!k?"":void 0,"data-aia-product-initial":k?"":void 0,"data-aia-image-loaded":l&&b===r?"":void 0,children:[l?(0,B.jsx)("img",{className:ne.image,src:r,alt:"",loading:"lazy",decoding:"async",onLoad:f=>{v(r),i((0,ke.productPhotoFill)(f.currentTarget.naturalWidth,f.currentTarget.naturalHeight))},onError:()=>{o+1>=e.length&&i(null),s(f=>f+1)}}):null,k?(0,ke.productInitial)(a):null]})}var Z=require("@magicx-eng/ai-autocomplete-vanilla"),Ae=require("react");var oa=require("@magicx-eng/ai-autocomplete-vanilla"),Tt=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 {
|
|
2850
2905
|
display: grid;
|
|
2851
2906
|
grid-template-columns: repeat(
|
|
2852
2907
|
auto-fit,
|
|
@@ -2890,7 +2945,7 @@
|
|
|
2890
2945
|
:where([data-aia-options-style="classic"]) .aia-grid[data-scroll] {
|
|
2891
2946
|
max-height: var(--aia-grid-max-height, 120px);
|
|
2892
2947
|
}
|
|
2893
|
-
`,document.head.appendChild(e)}var ra=require("react/jsx-runtime");function na({min:e="16rem",max:a,gap:t,scroll:i=!1,maxHeight:o,scrollResetKey:s,cols:r,template:l,innerRef:
|
|
2948
|
+
`,document.head.appendChild(e)}var ra=require("react/jsx-runtime");function na({min:e="16rem",max:a,gap:t,scroll:i=!1,maxHeight:o,scrollResetKey:s,cols:r,template:l,innerRef:b,className:v,children:k,...f}){let u=(0,Tt.useRef)(null);(0,Tt.useLayoutEffect)(()=>{if(s===void 0)return;let x=u.current;x&&(x.scrollTop=0)},[s]);let p={"--aia-grid-min":e};return a&&(p["--aia-grid-max"]=a),t&&(p["--aia-grid-gap"]=t),o&&(p["--aia-grid-max-height"]=o),r&&(p.gridTemplateColumns=(0,oa.optionsGridTemplateColumns)(r)),l&&(p.gridTemplateColumns=l),(0,ra.jsx)("div",{ref:x=>{u.current=x,b?.(x)},className:v?`aia-grid ${v}`:"aia-grid","data-scroll":i||void 0,style:p,...f,children:k})}var fe=require("@magicx-eng/ai-autocomplete-vanilla"),Ee=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 {
|
|
2894
2949
|
position: relative;
|
|
2895
2950
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
2896
2951
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -3410,7 +3465,7 @@
|
|
|
3410
3465
|
border-radius: 6px;
|
|
3411
3466
|
font-size: 11px;
|
|
3412
3467
|
}
|
|
3413
|
-
`,document.head.appendChild(e)}var pe={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",liveMatch:"aia-liveMatch--eYfs",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",loadingOut:"aia-loadingOut-hI-qI",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",text:"aia-text-yqoh9",checkbox:"aia-checkbox-KGRhg"};var me=require("react/jsx-runtime");function sa({option:e,isHighlighted:a,checked:t,onSelect:i,onHighlight:o,onUnhighlight:s,id:r,loading:l,showIcon:
|
|
3468
|
+
`,document.head.appendChild(e)}var pe={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",liveMatch:"aia-liveMatch--eYfs",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",loadingOut:"aia-loadingOut-hI-qI",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",text:"aia-text-yqoh9",checkbox:"aia-checkbox-KGRhg"};var me=require("react/jsx-runtime");function sa({option:e,isHighlighted:a,checked:t,onSelect:i,onHighlight:o,onUnhighlight:s,id:r,loading:l,showIcon:b=!0,showImage:v=!0,showCount:k=!0,scrollHint:f,enterDelayMs:u=0}){let[p]=(0,Ee.useState)(u),[x,A]=(0,Ee.useState)(!1),te=v?(0,fe.optionImageSources)(e.image_url):[],F=te[0]??null,[D,he]=(0,Ee.useState)([]),T=te.find(O=>!D.includes(O))??null,[W,V]=(0,Ee.useState)(null),K=(0,Ee.useMemo)(()=>!F&&b&&e.icon_svg?(0,fe.sanitizeOptionIconSvg)(e.icon_svg):null,[F,b,e.icon_svg]),U=k?(0,fe.formatOptionCount)(e.item_count):null,P=(0,Ee.useRef)(void 0);(0,Ee.useEffect)(()=>()=>clearTimeout(P.current),[]);let ae=O=>{if(l||!e.is_tappable||x&&t===void 0)return;A(!0);let j=O?.currentTarget;t!==void 0&&j!==void 0&&O!==void 0&&!(0,fe.isMultiSelectToggleTap)(j,j.querySelector("[data-aia-checkbox]"),O)?i(e,{commit:!0}):i(e),clearTimeout(P.current),P.current=setTimeout(()=>A(!1),170)},re=[pe.item,a&&!l?pe.highlighted:"",e.liveMatch&&!l?pe.liveMatch:"",e.is_tappable?pe.tappable:pe.nonTappable,x?pe.pressed:"",f?pe.scrollHint:""].filter(Boolean).join(" ");return(0,me.jsx)("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"data-aia-icon":K&&e.icon?e.icon:void 0,"data-aia-image":F?"":void 0,"data-aia-item-count":U!==null?e.item_count:void 0,"aria-selected":t??a,className:re,style:{[fe.OPTION_ENTER_DELAY_VAR]:`${p}ms`},tabIndex:l||!e.is_tappable?-1:0,onClick:ae,onKeyDown:O=>{!l&&e.is_tappable&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),ae())},onMouseEnter:!l&&e.is_tappable?o:void 0,onMouseLeave:s,children:(0,me.jsxs)("span",{className:pe.content,children:[t!==void 0&&e.is_tappable&&(0,me.jsx)("span",{className:pe.checkbox,"aria-hidden":"true","data-aia-checkbox":"","data-checked":t,children:t?"\u2713":""}),F&&(0,me.jsx)("span",{className:`${pe.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":T!==null&&W===T?"":void 0,children:(0,me.jsx)("img",{src:T??F,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:T===null,onLoad:()=>V(T),onError:()=>{T!==null&&he(O=>[...O,T])}})}),K&&(0,me.jsx)("span",{className:`${pe.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:K}}),(0,me.jsxs)("span",{className:pe.text,children:[e.matchedText?(0,fe.highlightParts)((0,fe.optionLabel)(e),e.matchedText).map((O,j)=>O.bold?(0,me.jsx)("strong",{className:`${pe.match} magicx-aia-option-match`,children:O.text},j):O.text):(0,fe.optionLabel)(e),e.parameterLabel&&(0,me.jsxs)(me.Fragment,{children:[" ",(0,me.jsx)("span",{className:`${pe.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&(0,me.jsx)("span",{className:pe.tag,children:e.tag}),U!==null&&(0,me.jsx)("span",{className:`${pe.count} magicx-aia-option-count`,children:U})]})})}var Nt=require("react/jsx-runtime");function _a(){let[e,a]=(0,Ae.useState)(Z.isOptionsGridMobileViewport);return(0,Ae.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Z.OPTIONS_GRID_MOBILE_QUERY),i=()=>a(t.matches);return i(),t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function la({options:e,activeIndex:a,picked:t,onSelect:i,onHighlight:o,onUnhighlight:s,listboxId:r,loading:l,groupKey:b="",optionsPosition:v="below",showIcons:k=!0,showImages:f=!0,showCounts:u=!0}){let p=_a(),x=(0,Ae.useRef)(null),[A,te]=(0,Ae.useState)(null),F=(0,Ae.useRef)(null);(0,Ae.useLayoutEffect)(()=>{if(l&&(0,Z.sameOptionRows)(F.current,e))return;F.current=l?null:e;let T=x.current,W=T&&!l&&(0,Z.needsOptionsGridMeasurement)(e.length,p),V=T?.closest("[data-aia-dropdown]");W&&V&&(0,Z.releasePanelHug)(V);let K=W?(0,Z.measureOptionsGrid)(T):null;te(K?(0,Z.planOptionsGrid)(e.length,p,K.rowWidths,K.gridWidth):null)},[e,p,l]);let D=A??(0,Z.planOptionsGrid)(e.length,p,null,null);(0,Ae.useLayoutEffect)(()=>{let T=x.current?.closest("[data-aia-dropdown]");T&&(0,Z.syncPanelHug)(T)},[D.template,p]);let he=(0,Z.optionsShowLeadingVisuals)(e,k,f);return(0,Nt.jsx)(na,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:b,template:D.template,maxHeight:D.maxHeight,innerRef:T=>{x.current=T},"data-aia-group":b,children:e.map((T,W)=>(0,Nt.jsx)(sa,{option:T,isHighlighted:W===a,checked:t?t.includes(T.text):void 0,onSelect:i,onHighlight:()=>o(W),onUnhighlight:s?()=>s(W):void 0,id:`${r}-option-${W}`,loading:l,showIcon:k&&he,showImage:f&&he,showCount:u,scrollHint:!l&&D.scrollHintIndices.includes(W),enterDelayMs:l?0:(0,Z.optionEnterDelayMs)(W,D.cols,e.length,v)},`${b}\0${T.text}`))})}var ge=require("@magicx-eng/ai-autocomplete-vanilla"),Re=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-52a922cb")){let e=document.createElement("style");e.id="ac-style-52a922cb",e.textContent=`/* --- Time wheel (replaces the options grid for time suggestions) ---
|
|
3414
3469
|
|
|
3415
3470
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
3416
3471
|
time-wheel.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -3532,7 +3587,7 @@
|
|
|
3532
3587
|
.aia-done-llNY5:hover {
|
|
3533
3588
|
background: var(--aia-time-done-bg-hover, var(--aia-done-bg-hover, #d8dde8));
|
|
3534
3589
|
}
|
|
3535
|
-
`,document.head.appendChild(e)}var
|
|
3590
|
+
`,document.head.appendChild(e)}var Oe={timeWheel:"aia-timeWheel-KdR4A",value:"aia-value--wqvm",columns:"aia-columns-TaD-f",band:"aia-band-pVy-f",column:"aia-column-lwtdd",row:"aia-row-A3pAx",selected:"aia-selected-xgOWY",separator:"aia-separator-kX9WO",done:"aia-done-llNY5"};var Ce=require("react/jsx-runtime"),Va=120;function da({view:e,label:a,doneLabel:t,interactive:i=!0,onTimeChange:o,onTimeCommit:s}){return(0,Ce.jsxs)("div",{className:Oe.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":a,onMouseDown:r=>r.preventDefault(),children:[(0,Ce.jsx)("span",{className:Oe.value,"data-aia-time-value":"","aria-live":"polite",children:(0,ge.formatTime)(e.minutes)}),(0,Ce.jsxs)("div",{className:Oe.columns,"aria-hidden":"true",children:[(0,Ce.jsx)("div",{className:Oe.band}),ge.TIME_WHEEL_COLUMNS.map(r=>(0,Ce.jsxs)(Re.Fragment,{children:[r==="minute"&&(0,Ce.jsx)("span",{className:Oe.separator,children:":"}),(0,Ce.jsx)(Ua,{column:r,minutes:e.minutes,interactive:i,onTimeChange:o})]},r))]}),(0,Ce.jsx)("button",{type:"button",tabIndex:-1,className:Oe.done,"data-aia-time-done":"",onClick:()=>{i&&s()},children:t})]})}function Ua({column:e,minutes:a,interactive:t,onTimeChange:i}){let o=(0,Re.useRef)(null),s=(0,Re.useRef)(null),r=(0,Re.useRef)(null),l=(0,Re.useRef)({minutes:a,interactive:t,onTimeChange:i});l.current={minutes:a,interactive:t,onTimeChange:i};let b=(0,ge.timeWheelIndex)(e,a);(0,Re.useLayoutEffect)(()=>{let f=o.current;if(!f||r.current)return;let u=b*ge.TIME_WHEEL_ROW_HEIGHT;Math.abs(f.scrollTop-u)<1||(s.current=u,f.scrollTop=u)},[b]),(0,Re.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]);let v=()=>{r.current=null;let f=o.current,u=l.current;if(!f||!u.interactive)return;let p=(0,ge.timeWheelIndexFromScroll)(e,f.scrollTop);p!==(0,ge.timeWheelIndex)(e,u.minutes)&&u.onTimeChange((0,ge.withTimeWheelIndex)(e,u.minutes,p))},k=()=>{let f=o.current;if(f){if(s.current!=null&&Math.abs(f.scrollTop-s.current)<1){s.current=null;return}s.current=null,r.current&&clearTimeout(r.current),r.current=setTimeout(v,Va)}};return(0,Ce.jsx)("div",{ref:o,className:Oe.column,"data-aia-time-column":e,onScroll:k,children:(0,ge.timeWheelRows)(e).map((f,u)=>(0,Ce.jsx)("div",{className:u===b?`${Oe.row} ${Oe.selected}`:Oe.row,"data-aia-time-row":"","data-aia-index":u,onClick:()=>{l.current.interactive&&i((0,ge.withTimeWheelIndex)(e,l.current.minutes,u))},children:f.label},f.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
3536
3591
|
display: flex;
|
|
3537
3592
|
flex-direction: column;
|
|
3538
3593
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -3547,7 +3602,7 @@
|
|
|
3547
3602
|
align-items: end;
|
|
3548
3603
|
}
|
|
3549
3604
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
3550
|
-
`,document.head.appendChild(e)}var pa=require("react/jsx-runtime");function ca({space:e,align:a="stretch",className:t,children:i,...o}){let s=e?{"--aia-stack-space":e}:void 0;return(0,pa.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:s,...o,children:i})}var X=require("react/jsx-runtime"),Qa=typeof window>"u"?J.useEffect:J.useLayoutEffect,Ya=[159,119,164],ja=()=>{},ha=()=>{},$a=e=>{},Za=()=>{},Xa=e=>{},Ja=e=>{},ei=e=>{},ti=e=>{};function ai(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,i]=(0,J.useState)(a);if((0,J.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 ii(e,a){let t=(0,J.useRef)(null);(0,J.useEffect)(()=>{let i=e.current,o=a.current;if(!i||!o)return;let s=(0,L.queryLive)(i,".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,L.attachScrollArrow)({dropdown:i,grid:s,button:o})};return}t.current?.controller.update()}),(0,J.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function oi(e,a){let t=(0,J.useRef)(a);t.current=a;let i=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>{let o=e.current;if(o){if(!i.current){i.current=(0,L.attachViewportFit)({dropdown:o,isOpen:()=>t.current});return}i.current.update()}}),(0,J.useEffect)(()=>()=>{i.current?.destroy(),i.current=null},[])}function Pt({suggestions:e,activeIndex:a,onSelect:t,onHighlight:i,onUnhighlight:o,isOpen:s,id:r,className:l,pills:
|
|
3605
|
+
`,document.head.appendChild(e)}var pa=require("react/jsx-runtime");function ca({space:e,align:a="stretch",className:t,children:i,...o}){let s=e?{"--aia-stack-space":e}:void 0;return(0,pa.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:s,...o,children:i})}var X=require("react/jsx-runtime"),Qa=typeof window>"u"?J.useEffect:J.useLayoutEffect,Ya=[159,119,164],ja=()=>{},ha=()=>{},$a=e=>{},Za=()=>{},Xa=e=>{},Ja=e=>{},ei=e=>{},ti=e=>{};function ai(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,i]=(0,J.useState)(a);if((0,J.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 ii(e,a){let t=(0,J.useRef)(null);(0,J.useEffect)(()=>{let i=e.current,o=a.current;if(!i||!o)return;let s=(0,L.queryLive)(i,".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,L.attachScrollArrow)({dropdown:i,grid:s,button:o})};return}t.current?.controller.update()}),(0,J.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function oi(e,a){let t=(0,J.useRef)(a);t.current=a;let i=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>{let o=e.current;if(o){if(!i.current){i.current=(0,L.attachViewportFit)({dropdown:o,isOpen:()=>t.current});return}i.current.update()}}),(0,J.useEffect)(()=>()=>{i.current?.destroy(),i.current=null},[])}function Pt({suggestions:e,activeIndex:a,onSelect:t,onHighlight:i,onUnhighlight:o,isOpen:s,id:r,className:l,pills:b,onPillClick:v,showPills:k=!0,onSkip:f,showSkipButton:u=!0,showOptionIcons:p=!0,showOptionImages:x=!0,showOptionCounts:A=!0,skipDisabled:te=!1,activeSelected:F=!1,isLoading:D=!1,skeletonExiting:he=!1,isInputEmpty:T=!1,language:W,products:V,onProductSelect:K,onProductAddToCart:U,onProductFocusChange:P,productsLayout:ae="row",productImageFallback:re="image",formatType:O="options",dateView:j=null,selectedDateIso:Se=null,selectedDateRange:ue=null,dateRangeStart:xe=null,dateReferences:c,onPreviousMonth:I,onNextMonth:qe,timeView:g=null,multiSelectView:tt=null,onMultiSelectCommit:_e,onTimeChange:Ve,onTimeCommit:Ue,locationView:We=null,isReediting:Qe=!1,onLocationQuery:m,onLocationMove:C,onLocationCommit:S,onLocationFocusChange:R,isFocused:M=!1,optionsPosition:Q="below",mode:Te}){let Pe=ai(Te),ze=Pe!==void 0,se=(0,J.useRef)(null),at=(0,J.useRef)(null);ii(se,at),(0,J.useEffect)(()=>{if(se.current)return(0,L.containScroll)(se.current)},[]);let it=e[0]?.options??[],ot=!!(b&&b.length>0&&v),Ye=!!(V&&V.length>0),nt=O==="time"&&g!=null,rt=O==="location"&&We!=null,ce=s&&(it.length>0||k&&ot||D||Ye||nt||rt);oi(se,ce),Qa(()=>{let q=se.current;q&&((0,L.fitMultiSelectDone)(q,(0,L.findMultiSelectDone)(q)),(0,L.syncPanelHug)(q))});let y={suggestions:e,activeIndex:a,pills:b,showPills:k,showSkipButton:u,showOptionIcons:p,showOptionImages:x,showOptionCounts:A,skipDisabled:te,activeSelected:F,isLoading:D,skeletonExiting:he,isInputEmpty:T,products:V,formatType:O,dateView:j,selectedDateIso:Se,selectedDateRange:ue,dateRangeStart:xe,dateReferences:c,timeView:g,multiSelectView:tt,locationView:We,isReediting:Qe},st=(0,J.useRef)(y);ce&&(st.current=y);let n=ce?y:st.current,le=(0,L.uiStringsFor)(W),w=n.suggestions[0],De=w?.options??[],lt=n.activeIndex>=0&&!!De[n.activeIndex]?.is_tappable,ye=(0,L.labelTraditionalAutocomplete)(n.pills??[],le.keepTyping),je=!!(ye.length>0&&v),dt=n.showPills&&je,$e=n.showPills&&!je&&n.isLoading,ut=dt||$e,Ie=je&&(0,L.hasSkippablePill)(ye)&&n.showSkipButton&&!n.isInputEmpty&&!!f,Me=ye[0]?.text,Ze=(0,L.isCalendarFormat)(n.formatType)&&n.dateView!=null,ct=De.length>0&&!Ze,mt=De.length>0&&Ze&&!n.isLoading,Ge=n.formatType==="time"&&n.timeView!=null&&!n.isLoading,pt=n.formatType==="location"&&n.locationView!=null&&!n.isLoading,h=n.isLoading&&!ct&&!mt&&!Ge&&!pt,Y=n.products??[],N=(0,L.panelMorphKey)(dt?ye:[]);return(0,J.useLayoutEffect)(()=>{se.current&&(0,L.settlePanelMorph)(se.current,N,{visible:ce,anchorBottom:Q==="above"})},[N,ce,Q,n.suggestions,n.pills,n.isLoading,n.skeletonExiting,n.isInputEmpty,n.products,n.formatType,n.dateView,n.selectedDateIso,n.selectedDateRange,n.dateRangeStart,n.dateReferences,n.timeView,n.multiSelectView,n.locationView,n.showPills,n.showSkipButton,n.showOptionIcons,n.showOptionImages,n.showOptionCounts,ae,W]),(0,J.useEffect)(()=>{let q=se.current;return()=>{q&&(0,L.destroyPanelMorph)(q)}},[]),(0,X.jsxs)("div",{ref:se,id:r,role:"listbox","aria-multiselectable":!!n.multiSelectView,"data-aia-dropdown":"","data-options-position":Q,"data-mode":Pe,"data-aia-loading":n.isLoading?"":void 0,"data-aia-skeleton-exiting":n.skeletonExiting?"":void 0,"data-aia-has-products":Y.length>0?"":void 0,className:`${ze?"magicx-aia ":""}${Ne.dropdown} ${ce?Ne.visible:""} ${l??""}`,onMouseDown:q=>q.preventDefault(),children:[(0,X.jsxs)(ca,{space:"8px",children:[(ut||Ie)&&(0,X.jsxs)(bt,{noWrap:!0,className:Ne.pillBar,"data-aia-pillbar":"",children:[ut&&(0,X.jsx)("span",{className:Ne.pillScroll,"data-aia-pill-scroll":"",children:(0,X.jsx)(St,{pills:ye,activePillIndex:0,activeSelected:n.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:n.isLoading})}),Ie&&(0,X.jsx)("button",{type:"button",tabIndex:-1,className:Ne.skip,"data-aia-skip":"",disabled:n.isLoading||n.skipDisabled,"aria-label":Me?`${le.skipLabel} ${Me}`:le.skipLabel,onClick:f,children:le.skip})]}),ct&&(0,X.jsx)(la,{options:De,activeIndex:n.activeIndex,onSelect:t,onHighlight:i,onUnhighlight:o,listboxId:r,loading:n.isLoading,groupKey:w?`${w.parameter} ${w.text}`:"",optionsPosition:Q,showIcons:n.showOptionIcons,showImages:n.showOptionImages,showCounts:n.showOptionCounts,picked:n.multiSelectView?.picked}),n.multiSelectView&&(0,X.jsx)("div",{"data-aia-multi-actions":"",onClick:q=>{q.target.closest("[data-aia-multi-done]")&&!n.skipDisabled&&!n.isLoading&&_e?.()},children:(0,X.jsx)("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:Ne.multiDone,ref:q=>{q&&(q.disabled=!0,q.offsetHeight,q.disabled=n.skipDisabled||n.isLoading)},children:le.done})}),mt&&n.dateView&&(0,X.jsx)(Yt,{options:De,activeIndex:n.activeIndex,listboxId:r,view:n.dateView,selection:{selectedIso:n.selectedDateIso??null,selectedRange:n.selectedDateRange??null,rangeStart:n.dateRangeStart??null,floor:(0,L.dateFloorFor)(n.formatType,n.dateRangeStart),references:n.dateReferences??[]},onSelect:t,onHighlight:i,onUnhighlight:o,onPreviousMonth:I??ha,onNextMonth:qe??ha}),Ge&&n.timeView&&(0,X.jsx)(da,{view:n.timeView,label:le.timeLabel,doneLabel:le.done,interactive:!n.skipDisabled,onTimeChange:Ve??$a,onTimeCommit:Ue??Za}),pt&&n.locationView&&(0,X.jsx)(Jt,{view:n.locationView,searchLabel:le.locationSearch,noResultsLabel:le.locationNoResults,useTypedLabel:le.locationUseTyped,widgetFocused:M&&ce,reediting:n.isReediting,visible:ce,interactive:!n.skipDisabled,onQuery:m??Xa,onMove:C??Ja,onCommit:S??ei,onFocusChange:R??ti}),h&&(0,X.jsx)("div",{className:Ne.skeletonBars,"data-aia-skeleton-bars":"",children:Ya.map(q=>(0,X.jsx)("span",{className:Ne.skeletonBar,style:{width:q}},`bar-${q}`))}),(0,X.jsx)(ia,{products:Y,listboxId:r,onSelect:K??ja,onAddToCart:U,onFocusChange:P,focusable:ce&&!n.isLoading,loading:n.isLoading,layout:ae,imageFallback:re,strings:le}),(0,X.jsx)(jt,{isOptionHighlighted:lt,isInputEmpty:n.isInputEmpty,strings:le})]}),(0,X.jsx)("button",{ref:at,type:"button",tabIndex:-1,className:Ne.scrollArrow,"data-aia-scroll-arrow":"","aria-label":le.scrollArrow,"aria-hidden":"true",children:(0,X.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,X.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Be=require("@magicx-eng/ai-autocomplete-vanilla");var ma=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 {
|
|
3551
3606
|
flex-shrink: 0;
|
|
3552
3607
|
width: 32px;
|
|
3553
3608
|
height: 32px;
|
|
@@ -3618,5 +3673,5 @@
|
|
|
3618
3673
|
transition: none;
|
|
3619
3674
|
}
|
|
3620
3675
|
}
|
|
3621
|
-
`,document.head.appendChild(e)}var ua={submitButton:"aia-submitButton-otz7H"};var It=require("react/jsx-runtime");function ga({disabled:e,ready:a,onClick:t,label:i=(0,ma.uiStringsFor)().submit}){return(0,It.jsx)("button",{type:"button","data-aia-submit":"",className:ua.submitButton,disabled:e,"data-aia-ready":a?"":void 0,onClick:o=>{o.stopPropagation(),t()},"aria-label":i,children:(0,It.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":i,children:(0,It.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var et=require("@magicx-eng/ai-autocomplete-vanilla"),E=require("react");var Ht=require("react");function fa(e){let a=(0,Ht.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),i=(0,Ht.useRef)({key:"",overrides:void 0});if(i.current.key!==t){let o={};for(let s of Object.keys(e??{})){let r=(l,g,v)=>{let k=a.current?.[s];return k?k(l,g,v):[]};o[s]=r}i.current={key:t,overrides:e?o:void 0}}return{overrides:i.current.overrides,key:t}}var Ft=require("react");function ba(e){let a=(0,Ft.useRef)(e);a.current=e;let t=(0,Ft.useRef)(null);t.current===null&&(t.current={fetch:(o,s)=>{let r=a.current;return r?r.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 wa={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,dateReferences:[],dateFloor:null,timeView:null,multiSelectView:null,multiSelectDraft:null,locationView:null,locationSearch:null,locationAutocomplete:!0,locationFieldFocused:!1,placeholderText:"",leadInText:"",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,timeDraft:null};function Et({onSubmit:e,onResult:a,onError:t,optionOverrides:i,maskCompletedText:o,apiConfig:s,additionalContext:r,language:l,currency:g,productId:v,visitorId:k,columns:b=2,dropdownTrigger:p,optionsPosition:u,closeDropdownOnBlur:y,prependPlaceholder:A,showNonTappableOptions:te,locationSearch:H,showOptionIcons:D,showOptionImages:he,showOptionCounts:T,showSkipButton:W,showProducts:V,productImageFallback:K="image",onFocus:U,onBlur:P,value:ae,completedParams:re,onChange:R,onParamsChange:j,products:Se,mapProducts:ue,onProductSelect:xe,onProductAddToCart:c,source:I,setCursor:qe}){let f=(0,E.useRef)(null),[tt,_e]=(0,E.useState)(null),Ve=(0,E.useRef)(e);Ve.current=e;let Ue=(0,E.useRef)(a);Ue.current=a;let We=(0,E.useRef)(t);We.current=t;let Qe=(0,E.useRef)(R);Qe.current=R;let m=(0,E.useRef)(j);m.current=j;let C=(0,E.useRef)(U);C.current=U;let S=(0,E.useRef)(P);S.current=P;let O=(0,E.useRef)(qe);O.current=qe;let M=(0,E.useRef)(xe);M.current=xe;let Q=(0,E.useRef)(c);Q.current=c;let Te=(0,E.useRef)(k);Te.current=k;let Pe=(0,E.useRef)(()=>{let h=Te.current;return typeof h=="function"?h():h}).current,ze=ba(Se),se=(0,E.useRef)(ue);se.current=ue;let at=(0,E.useRef)((h,Y)=>{let N=se.current;return N?N(h,Y):h}).current,it=ue?at:void 0,ot=fa(i);(0,E.useEffect)(()=>{if(typeof document>"u")return;let h=new et.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:g,productId:v,visitorId:Pe,optionOverrides:ot.overrides,maskCompletedText:o,columns:b,dropdownTrigger:p,optionsPosition:u,closeDropdownOnBlur:y,prependPlaceholder:A,showNonTappableOptions:te,locationSearch:H,showProducts:V,source:I,value:ae,completedParams:re,onSubmit:(...N)=>Ve.current?.(...N),onResult:(...N)=>Ue.current?.(...N),onError:(...N)=>We.current?.(...N),onChange:(...N)=>Qe.current?.(...N),onParamsChange:(...N)=>m.current?.(...N),onFocus:()=>C.current?.(),onBlur:()=>S.current?.(),onProductSelect:N=>M.current?.(N),onProductAddToCart:N=>Q.current?.(N),setCursor:N=>O.current?.(N),products:ze.config,mapProducts:it});f.current=h,_e(h.getState());let Y=h.subscribe(N=>_e(N));return()=>{Y(),h.destroy(),f.current===h&&(f.current=null)}},[]),(0,E.useEffect)(()=>{ae!==void 0&&f.current?.setValue(ae)},[ae]),(0,E.useEffect)(()=>{re!==void 0&&f.current?.setCompletedParams(re)},[re]);let Ye=JSON.stringify(s??null),nt;try{nt=JSON.stringify(r??null)}catch{nt="[unstringifiable]"}(0,E.useEffect)(()=>{f.current?.update({apiConfig:s,additionalContext:r,language:l,currency:g,productId:v,optionOverrides:ot.overrides,dropdownTrigger:p,optionsPosition:u,closeDropdownOnBlur:y,prependPlaceholder:A,showNonTappableOptions:te,locationSearch:H,showProducts:V})},[Ye,nt,l,g?.code,g?.rate,g?.country,v,ot.key,p,u,y,A,te,H,V]);let rt=(0,E.useRef)(!1);(0,E.useEffect)(()=>{if(!rt.current){rt.current=!0;return}f.current?.update({products:ze.config})},[ze.enabled]),(0,E.useEffect)(()=>{f.current?.update({mapProducts:it})},[it]);let ce=(0,E.useRef)(null);ce.current===null&&(ce.current={handleTextChange:h=>f.current?.handleTextChange(h),handleKeyDown:h=>{let Y="nativeEvent"in h?h.nativeEvent:h;f.current?.handleKeyDown(Y)},setFocused:h=>f.current?.setFocused(h),startEditingParam:h=>f.current?.startEditingParam(h),removeParam:h=>f.current?.removeParam(h)??!1,exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:h=>f.current?.handleCaretAfterInput(h),handleCaretMove:h=>f.current?.handleCaretMove(h),replaceEditingRange:h=>f.current?.replaceEditingRange(h)??!1,setActivePill:h=>f.current?.setActivePill(h),skipActivePill:()=>f.current?.skipActivePill(),removeLastParam:()=>f.current?.removeLastParam(),clearNewParamId:()=>f.current?.clearNewParamId(),reset:()=>f.current?.reset(),refreshProducts:()=>f.current?.refreshProducts(),prepareSubmit:()=>f.current?.prepareSubmit(),getState:()=>f.current?.getState()??wa,recordSubmit:h=>f.current?.recordSubmit(h),selectOption:(h,Y)=>f.current?.selectOption(h,Y),selectProduct:h=>f.current?.selectProduct(h),addProductToCart:h=>{let Y=f.current;return!Y||!Q.current?Promise.resolve():Y.addProductToCart(h)},setActiveDropdownIndex:h=>f.current?.setActiveDropdownIndex(h),clearHighlight:h=>f.current?.clearHighlight(h),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),setTime:h=>f.current?.setTime(h),commitTime:()=>f.current?.commitTime(),toggleMultiSelectOption:h=>f.current?.toggleMultiSelectOption(h),commitMultiSelect:()=>f.current?.commitMultiSelect(),setLocationQuery:h=>f.current?.setLocationQuery(h),moveLocationHighlight:h=>f.current?.moveLocationHighlight(h),commitLocation:h=>f.current?.commitLocation(h),setLocationFieldFocused:h=>f.current?.setLocationFieldFocused(h),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let x=ce.current,st=(0,E.useCallback)(h=>{let Y=h.target.value,q=Y.length>0&&!h.nativeEvent?.isComposing&&Y[0]!==Y[0].toUpperCase()?Y[0].toUpperCase()+Y.slice(1):Y;f.current?.handleTextChange(q)},[]),n=(0,E.useCallback)(h=>{f.current?.handleKeyDown(h.nativeEvent)},[]),le=f.current,w=tt??wa,De=ae!==void 0?ae:w.text,lt=re!==void 0?re:w.completedParams,ye=w.actionableSuggestions,je=ye[0],dt=(0,E.useMemo)(()=>(0,et.withoutTraditionalAutocomplete)(ye),[ye]),$e=le?.listboxId??"",ut=w.activeDropdownIndex>=0&&le?`${$e}-option-${w.activeDropdownIndex}`:void 0,Ie=w.editingParam,Me=w.editingIdentified,Ze=Ie?{parameter:Ie.suggestionParameter,text:Ie.suggestionPlaceholder,required:!0,options:Ie.options}:Me?{parameter:Me.parameter,text:(0,et.identifiedParamLabel)(Me.parameter),required:!0,options:[]}:null,ct=w.dropdownSuggestion??Ze??je,mt=Ze?[Ze]:ye,Ge=(0,et.dateSelectionFor)(w),pt=!le||w.dropdownLoading;return{completedParams:lt,multiSelectView:w.multiSelectView,toggleMultiSelectOption:x.toggleMultiSelectOption,commitMultiSelect:x.commitMultiSelect,skippedParams:w.skippedParams,identifiedParams:w.identifiedParams,suggestionPills:dt,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:w.segments,newParamId:w.newParamId,clearNewParamId:x.clearNewParamId,suggestions:w.suggestions,activeIndex:w.activeDropdownIndex,isReady:w.isReady,isLoading:pt,isFocused:w.isFocused,isDropdownOpen:w.isDropdownOpen,isActivePillSelected:w.isActivePillSelected,placeholderText:w.placeholderText,listboxId:$e,error:w.error,products:w.products,customFields:w.customFields,selectProduct:x.selectProduct,addProductToCart:x.addProductToCart,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:Ie,editingIdentified:Me,editingAnchor:w.editingAnchor,caretOffset:w.caretOffset,startEditingParam:x.startEditingParam,removeParam:x.removeParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:De,placeholder:w.placeholderText||void 0,onChange:st,onKeyDown:n,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":w.isDropdownOpen,"aria-activedescendant":ut,"aria-autocomplete":"list","aria-controls":$e},reset:x.reset,refreshProducts:x.refreshProducts,prepareSubmit:x.prepareSubmit,getState:x.getState,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:ct?[{...ct,options:w.dropdownOptions}]:[],activeIndex:w.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:w.isDropdownOpen,id:$e,pills:mt,activeSelected:w.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(W??!0)&&!Ie&&!Me,showOptionIcons:D??!0,showOptionImages:he??!0,showOptionCounts:T??!0,skipDisabled:w.inSelectionAnimation,isLoading:pt,skeletonExiting:w.skeletonExiting,isInputEmpty:De.trim().length===0,language:l,products:w.products,productImageFallback:K,onProductSelect:x.selectProduct,onProductAddToCart:c?x.addProductToCart:void 0,onProductFocusChange:x.setFocused,formatType:w.activeFormatType,dateView:w.dateView,selectedDateIso:Ge.selectedIso,selectedDateRange:Ge.selectedRange,dateRangeStart:Ge.rangeStart,dateReferences:Ge.references,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,timeView:w.timeView,multiSelectView:w.multiSelectView,onMultiSelectCommit:x.commitMultiSelect,onTimeChange:x.setTime,onTimeCommit:x.commitTime,locationView:w.locationView,isReediting:w.editingParam!=null,onLocationQuery:x.setLocationQuery,onLocationMove:x.moveLocationHighlight,onLocationCommit:x.commitLocation,onLocationFocusChange:x.setLocationFieldFocused,isFocused:w.isFocused||w.locationFieldFocused,optionsPosition:u??"below"}}}var _=require("@magicx-eng/ai-autocomplete-vanilla"),z=require("react"),At;function ni(){if(At!==void 0)return At;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),At=e.contentEditable==="plaintext-only",At}function va(e){let{segments:a,showChipIcons:t=!0,showChipImages:i=!0,showChipRemove:o=!1,removeParam:s,newParamId:r,editingParam:l,editingIdentified:g,editingAnchor:v,caretOffset:k,placeholderText:b,hintSuggestions:p,isFocused:u,isDropdownOpen:y,listboxId:A,activeDescendantId:te,autoFocus:H,handleTextChange:D,handleKeyDown:he,handleCaretAfterInput:T,handleCaretMove:W,startEditingParam:V,replaceEditingRange:K,setFocused:U}=e,P=(0,z.useRef)(null),ae=(0,z.useRef)(!1),re=(0,z.useRef)(""),R=(0,z.useRef)(""),j=(0,z.useRef)(null),Se=(0,z.useRef)(0);j.current=k,(0,z.useEffect)(()=>{if(!H)return;let m=P.current;if(!m)return;document.activeElement===m?U(!0):m.focus();let C=m.ownerDocument??document,S=C.getSelection(),O=S&&S.rangeCount>0&&m.contains(S.anchorNode);if(S&&!O){let M=C.createRange();M.selectNodeContents(m),M.collapse(!0),S.removeAllRanges(),S.addRange(M)}},[H,U]),(0,z.useEffect)(()=>{let m=P.current;if(!m)return;let C=m.ownerDocument??document,S=()=>{let O=C.getSelection();if(!O||O.rangeCount===0||!O.anchorNode||!m.contains(O.anchorNode))return;let M=O.anchorNode,Q=M.nodeType===Node.ELEMENT_NODE?M:M.parentElement,Pe=(O.isCollapsed?Q?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ze=l?.id??g?.id??null;if(Pe&&Pe!==ze){V(Pe);return}performance.now()-Se.current<50||W((0,_.getCursorOffset)(m))};return C.addEventListener("selectionchange",S),()=>C.removeEventListener("selectionchange",S)},[l,g,V,W]),(0,z.useEffect)(()=>{let m=P.current;if(!m)return;let C=S=>{let O=(0,_.chipIdFromTap)(m,S.target);O&&(V(O),(0,_.keepCaretOnChip)(m,O))};return m.addEventListener("click",C),()=>m.removeEventListener("click",C)},[V]),(0,z.useEffect)(()=>{let m=P.current;if(!(!m||!s||!o))return(0,_.attachChipRemove)(m,s)},[s,o]),(0,z.useLayoutEffect)(()=>{let m=P.current;m&&(0,_.renderEditableContent)({input:m,segments:a,newParamId:r,editingParamId:l?.id??null,placeholderText:b??"",isFocused:u,showChipIcons:t,showChipImages:i,showChipRemove:o,hintOptions:(0,_.startingHintOptions)(p??[])})},[a,r,l,b,p,u,t,i,o]),(0,z.useEffect)(()=>{let m=P.current;return()=>{m&&(0,_.cancelStartingHint)(m)}},[]),(0,z.useLayoutEffect)(()=>{let m=re.current,C=r??"";if(re.current=C,!C||C===m)return;let S=P.current;if(!S)return;S.focus();let O=j.current??(0,_.plainTextLength)(S);(0,_.setCursorOffset)(S,O)},[r]),(0,z.useLayoutEffect)(()=>{let m=R.current,C=l?.id??"";if(R.current=C,!C||C===m||v==null)return;let S=P.current;S&&(0,_.setCursorOffset)(S,v)},[l,v]);let ue=(0,z.useCallback)(()=>{if(ae.current)return;let m=P.current;if(!m)return;let C=(0,_.extractPlainText)(m),O=C.length>0&&C[0]!==C[0].toUpperCase()?C[0].toUpperCase()+C.slice(1):C;D(O)},[D]),xe=(0,z.useCallback)(()=>{Se.current=performance.now(),ue();let m=P.current;m&&T((0,_.getCursorOffset)(m))},[ue,T]);(0,z.useEffect)(()=>{let m=P.current;if(!m)return;let C=S=>{let O=S,M=O.inputType;if(M==="insertParagraph"||M==="insertLineBreak"||M==="insertFromDrop"){S.preventDefault();return}if(M.startsWith("insert")||M.startsWith("delete")){let Q=M.startsWith("delete")?"":O.data??"";K(Q)&&S.preventDefault()}};return m.addEventListener("beforeinput",C),()=>m.removeEventListener("beforeinput",C)},[K]);let c=(0,z.useCallback)(()=>{ae.current=!0,P.current?.setAttribute("data-aia-composing","true")},[]),I=(0,z.useCallback)(()=>{ae.current=!1,P.current?.removeAttribute("data-aia-composing"),ue()},[ue]),qe=(0,z.useCallback)(m=>{m.preventDefault();let C=P.current;if(!C)return;let S=(m.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!S)return;let O=C.ownerDocument??document,M=O.getSelection();if(!M||M.rangeCount===0)return;let Q=M.getRangeAt(0);if(!C.contains(Q.startContainer))return;Q.deleteContents();let Te=O.createTextNode(S);Q.insertNode(Te),Q.setStartAfter(Te),Q.collapse(!0),M.removeAllRanges(),M.addRange(Q),ue()},[ue]),f=(0,z.useCallback)(m=>he(m),[he]),tt=(0,z.useCallback)(()=>U(!0),[U]),_e=(0,z.useCallback)(()=>U(!1),[U]),Ve=(0,z.useCallback)(()=>P.current?.focus(),[]),Ue=(0,z.useCallback)(()=>P.current?.blur(),[]),We=(0,z.useCallback)(()=>{let m=P.current;return m?(0,_.extractPlainText)(m):""},[]),Qe=ni()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:Qe,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":A,"aria-expanded":y,"aria-activedescendant":te,spellCheck:!0,enterKeyHint:"send",onInput:xe,onKeyDown:f,onCompositionStart:c,onCompositionEnd:I,onPaste:qe,onFocus:tt,onBlur:_e},getPlainText:We,focus:Ve,blur:Ue}}var Le=require("react/jsx-runtime");function ri(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var xa=(0,ee.forwardRef)(function({onSubmit:a,onResult:t,onError:i,optionOverrides:o,maskCompletedText:s,className:r,apiConfig:l,additionalContext:g,language:v,currency:k,productId:b,visitorId:p,columns:u,pillPlacement:y="dropdown",mode:A="auto",optionsPosition:te="below",animations:H=!0,optionsStyle:D="floating",dropdownTrigger:he,closeDropdownOnBlur:T,prependPlaceholder:W,showNonTappableOptions:V,locationSearch:K,showOptionIcons:U=!0,showChipIcons:P=!0,showChipImages:ae=!0,showChipRemove:re=!1,showOptionImages:R=!0,showOptionCounts:j=!0,showSkipButton:Se,showProducts:ue,productsLayout:xe,productImageFallback:c,autoFocus:I=!0,onFocus:qe,onBlur:f,value:tt,completedParams:_e,onChange:Ve,onParamsChange:Ue,products:We,mapProducts:Qe,onProductSelect:m,onProductAddToCart:C,submitButton:S,resetOnSubmit:O=!0},M){let Q=(0,ee.useRef)(null),Te=(0,ee.useRef)(null),Pe=(0,ee.useRef)(null),ze=(0,ee.useRef)(()=>{}),se=(0,ee.useRef)(null),at=(0,ee.useRef)(null);(0,ee.useEffect)(()=>{let F=Q.current;if(F)return se.current?se.current.setMode(A):se.current=new Be.ModeController(F,A),()=>{se.current?.destroy(),se.current=null}},[A]);let it=(0,ee.useCallback)(F=>{let be=at.current?.current;be&&(be.focus(),(0,Be.setCursorOffset)(be,F))},[]),{completedParams:ot,suggestionPills:Ye,setActivePill:nt,skipActivePill:rt,segments:ce,newParamId:x,clearNewParamId:st,placeholderText:n,isFocused:le,isDropdownOpen:w,isActivePillSelected:De,isLoading:lt,isReady:ye,activeIndex:je,listboxId:dt,handleTextChange:$e,handleKeyDown:ut,setFocused:Ie,editingParam:Me,editingIdentified:Ze,editingAnchor:ct,caretOffset:mt,startEditingParam:Ge,removeParam:pt,handleCaretAfterInput:h,handleCaretMove:Y,replaceEditingRange:N,dropdownProps:q,reset:xt,refreshProducts:Bt,prepareSubmit:Wt,getState:Gt,recordSubmit:Kt}=Et({onSubmit:F=>ze.current(F),onResult:t,onError:i,optionOverrides:o,maskCompletedText:s,apiConfig:l,additionalContext:g,language:v,currency:k,productId:b,visitorId:p,columns:u,dropdownTrigger:he,optionsPosition:te,closeDropdownOnBlur:T,prependPlaceholder:W,showNonTappableOptions:V,locationSearch:K,showOptionIcons:U,showOptionImages:R,showOptionCounts:j,showSkipButton:Se,showProducts:ue,onFocus:qe,onBlur:f,value:tt,completedParams:_e,onChange:Ve,onParamsChange:Ue,products:We,mapProducts:Qe,onProductSelect:m,onProductAddToCart:C,source:"full-sdk",setCursor:it});(0,ee.useEffect)(()=>{if(!x)return;let F=window.setTimeout(()=>st(),650);return()=>window.clearTimeout(F)},[x,st]);let ya=je>=0?`${dt}-option-${je}`:void 0,{inputRef:Rt,editorProps:ka,focus:yt,blur:qt,getPlainText:_t}=va({segments:ce,newParamId:x,editingParam:Me,editingIdentified:Ze,editingAnchor:ct,caretOffset:mt,placeholderText:n,hintSuggestions:y==="inline"?[]:Ye,isFocused:le,showChipIcons:P,showChipImages:ae,showChipRemove:re,removeParam:pt,isDropdownOpen:w,listboxId:dt,activeDescendantId:ya,autoFocus:I,handleTextChange:$e,handleKeyDown:ut,handleCaretAfterInput:h,handleCaretMove:Y,startEditingParam:Ge,replaceEditingRange:N,setFocused:Ie});at.current=Rt,(0,ee.useLayoutEffect)(()=>{let F=Te.current,be=Rt.current;if(!F||!be)return;let ft=()=>{let Ut=F.firstElementChild;if(!Ut)return;let Pa=Ut.getBoundingClientRect(),Ia=be.getBoundingClientRect();Pa.top>=Ia.bottom-2?F.setAttribute("data-aia-pill-wrapped",""):F.removeAttribute("data-aia-pill-wrapped")};ft();let Vt=new ResizeObserver(ft);return Vt.observe(be),()=>Vt.disconnect()},[ce,Ye.length,lt,Rt]),(0,ee.useEffect)(()=>{let F=Pe.current;if(F)return(0,Be.watchEditorHeight)(F)},[]),(0,ee.useImperativeHandle)(M,()=>({focus:yt,blur:qt,reset:xt,refreshProducts:Bt,setMode:F=>se.current?.setMode(F),skipActivePill:rt}),[yt,qt,xt,Bt,rt]);let gt=!!ce.length||ot.length>0,Ot=(0,ee.useCallback)(F=>{if(!gt)return;F&&Wt();let be=Gt(),ft=(0,Be.buildSubmitResult)(_t(),be.completedParams,be.skippedParams,{identifiedParams:be.identifiedParams,isReady:be.isReady,customFields:be.customFields});F&&Kt(ft),a(ft),O&&xt()},[Kt,O,gt,Wt,Gt,a,xt,_t]);ze.current=()=>Ot(!1);let Ca=(0,ee.useCallback)(F=>{F.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||yt()},[yt]),Sa=y==="inline",Ta=y==="dropdown";return(0,Le.jsxs)("div",{ref:Q,className:`magicx-aia ${ht.container} ${r??""}`,"data-pill-placement":y,"data-options-position":te,"data-animations":H?"on":"off","data-aia-options-style":D,"data-mode":ri(A),children:[(0,Le.jsx)(Pt,{...q,showPills:Ta,productsLayout:xe,productImageFallback:c}),(0,Le.jsxs)("div",{className:ht.inputWrapper,"data-aia-input-wrapper":"",onClick:Ca,children:[(0,Le.jsxs)("div",{ref:Pe,className:ht.editorArea,"data-aia-editor":"",children:[(0,Le.jsx)("div",{...ka,className:ht.input,"data-aia-input":""}),Sa&&(lt||Ye.length>0)&&(0,Le.jsx)("span",{ref:Te,className:ht.pillListContainer,"data-aia-pill-list-container":"",children:(0,Le.jsx)(St,{pills:Ye,activePillIndex:0,activeSelected:De,onSelectPill:nt,loading:lt})})]}),S===null?null:S===void 0?(0,Le.jsx)(ga,{disabled:!gt,ready:gt&&ye,onClick:()=>Ot(!0),label:(0,Be.uiStringsFor)(v).submit}):(0,Le.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ht.submitSlot,onClick:F=>{gt&&(F.stopPropagation(),Ot(!0))},children:S})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,LOCATION_META_KEY,PRODUCT_PATH_PREFIX,TIME_META_KEY,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,parseTime,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
3676
|
+
`,document.head.appendChild(e)}var ua={submitButton:"aia-submitButton-otz7H"};var It=require("react/jsx-runtime");function ga({disabled:e,ready:a,onClick:t,label:i=(0,ma.uiStringsFor)().submit}){return(0,It.jsx)("button",{type:"button","data-aia-submit":"",className:ua.submitButton,disabled:e,"data-aia-ready":a?"":void 0,onClick:o=>{o.stopPropagation(),t()},"aria-label":i,children:(0,It.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":i,children:(0,It.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var et=require("@magicx-eng/ai-autocomplete-vanilla"),E=require("react");var Ft=require("react");function fa(e){let a=(0,Ft.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),i=(0,Ft.useRef)({key:"",overrides:void 0});if(i.current.key!==t){let o={};for(let s of Object.keys(e??{})){let r=(l,b,v)=>{let k=a.current?.[s];return k?k(l,b,v):[]};o[s]=r}i.current={key:t,overrides:e?o:void 0}}return{overrides:i.current.overrides,key:t}}var Ht=require("react");function ba(e){let a=(0,Ht.useRef)(e);a.current=e;let t=(0,Ht.useRef)(null);t.current===null&&(t.current={fetch:(o,s)=>{let r=a.current;return r?r.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 wa={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,skeletonPicked:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,dateReferences:[],dateFloor:null,timeView:null,multiSelectView:null,dropdownMultiSelect:null,multiSelectDraft:null,locationView:null,locationSearch:null,locationAutocomplete:!0,locationFieldFocused:!1,placeholderText:"",leadInText:"",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,timeDraft:null};function Et({onSubmit:e,onResult:a,onError:t,optionOverrides:i,maskCompletedText:o,apiConfig:s,additionalContext:r,language:l,currency:b,productId:v,visitorId:k,columns:f=2,dropdownTrigger:u,optionsPosition:p,closeDropdownOnBlur:x,prependPlaceholder:A,showNonTappableOptions:te,locationSearch:F,showOptionIcons:D,showOptionImages:he,showOptionCounts:T,showSkipButton:W,showProducts:V,productImageFallback:K="image",onFocus:U,onBlur:P,value:ae,completedParams:re,onChange:O,onParamsChange:j,products:Se,mapProducts:ue,onProductSelect:xe,onProductAddToCart:c,source:I,setCursor:qe}){let g=(0,E.useRef)(null),[tt,_e]=(0,E.useState)(null),Ve=(0,E.useRef)(e);Ve.current=e;let Ue=(0,E.useRef)(a);Ue.current=a;let We=(0,E.useRef)(t);We.current=t;let Qe=(0,E.useRef)(O);Qe.current=O;let m=(0,E.useRef)(j);m.current=j;let C=(0,E.useRef)(U);C.current=U;let S=(0,E.useRef)(P);S.current=P;let R=(0,E.useRef)(qe);R.current=qe;let M=(0,E.useRef)(xe);M.current=xe;let Q=(0,E.useRef)(c);Q.current=c;let Te=(0,E.useRef)(k);Te.current=k;let Pe=(0,E.useRef)(()=>{let h=Te.current;return typeof h=="function"?h():h}).current,ze=ba(Se),se=(0,E.useRef)(ue);se.current=ue;let at=(0,E.useRef)((h,Y)=>{let N=se.current;return N?N(h,Y):h}).current,it=ue?at:void 0,ot=fa(i);(0,E.useEffect)(()=>{if(typeof document>"u")return;let h=new et.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:b,productId:v,visitorId:Pe,optionOverrides:ot.overrides,maskCompletedText:o,columns:f,dropdownTrigger:u,optionsPosition:p,closeDropdownOnBlur:x,prependPlaceholder:A,showNonTappableOptions:te,locationSearch:F,showProducts:V,source:I,value:ae,completedParams:re,onSubmit:(...N)=>Ve.current?.(...N),onResult:(...N)=>Ue.current?.(...N),onError:(...N)=>We.current?.(...N),onChange:(...N)=>Qe.current?.(...N),onParamsChange:(...N)=>m.current?.(...N),onFocus:()=>C.current?.(),onBlur:()=>S.current?.(),onProductSelect:N=>M.current?.(N),onProductAddToCart:N=>Q.current?.(N),setCursor:N=>R.current?.(N),products:ze.config,mapProducts:it});g.current=h,_e(h.getState());let Y=h.subscribe(N=>_e(N));return()=>{Y(),h.destroy(),g.current===h&&(g.current=null)}},[]),(0,E.useEffect)(()=>{ae!==void 0&&g.current?.setValue(ae)},[ae]),(0,E.useEffect)(()=>{re!==void 0&&g.current?.setCompletedParams(re)},[re]);let Ye=JSON.stringify(s??null),nt;try{nt=JSON.stringify(r??null)}catch{nt="[unstringifiable]"}(0,E.useEffect)(()=>{g.current?.update({apiConfig:s,additionalContext:r,language:l,currency:b,productId:v,optionOverrides:ot.overrides,dropdownTrigger:u,optionsPosition:p,closeDropdownOnBlur:x,prependPlaceholder:A,showNonTappableOptions:te,locationSearch:F,showProducts:V})},[Ye,nt,l,b?.code,b?.rate,b?.country,v,ot.key,u,p,x,A,te,F,V]);let rt=(0,E.useRef)(!1);(0,E.useEffect)(()=>{if(!rt.current){rt.current=!0;return}g.current?.update({products:ze.config})},[ze.enabled]),(0,E.useEffect)(()=>{g.current?.update({mapProducts:it})},[it]);let ce=(0,E.useRef)(null);ce.current===null&&(ce.current={handleTextChange:h=>g.current?.handleTextChange(h),handleKeyDown:h=>{let Y="nativeEvent"in h?h.nativeEvent:h;g.current?.handleKeyDown(Y)},setFocused:h=>g.current?.setFocused(h),startEditingParam:h=>g.current?.startEditingParam(h),removeParam:h=>g.current?.removeParam(h)??!1,exitEditMode:()=>g.current?.exitEditMode(),handleCaretAfterInput:h=>g.current?.handleCaretAfterInput(h),handleCaretMove:h=>g.current?.handleCaretMove(h),replaceEditingRange:h=>g.current?.replaceEditingRange(h)??!1,setActivePill:h=>g.current?.setActivePill(h),skipActivePill:()=>g.current?.skipActivePill(),removeLastParam:()=>g.current?.removeLastParam(),clearNewParamId:()=>g.current?.clearNewParamId(),reset:()=>g.current?.reset(),refreshProducts:()=>g.current?.refreshProducts(),prepareSubmit:()=>g.current?.prepareSubmit(),getState:()=>g.current?.getState()??wa,recordSubmit:h=>g.current?.recordSubmit(h),selectOption:(h,Y)=>g.current?.selectOption(h,Y),selectProduct:h=>g.current?.selectProduct(h),addProductToCart:h=>{let Y=g.current;return!Y||!Q.current?Promise.resolve():Y.addProductToCart(h)},setActiveDropdownIndex:h=>g.current?.setActiveDropdownIndex(h),clearHighlight:h=>g.current?.clearHighlight(h),showPreviousMonth:()=>g.current?.showPreviousMonth(),showNextMonth:()=>g.current?.showNextMonth(),setTime:h=>g.current?.setTime(h),commitTime:()=>g.current?.commitTime(),toggleMultiSelectOption:h=>g.current?.toggleMultiSelectOption(h),commitMultiSelect:()=>g.current?.commitMultiSelect(),setLocationQuery:h=>g.current?.setLocationQuery(h),moveLocationHighlight:h=>g.current?.moveLocationHighlight(h),commitLocation:h=>g.current?.commitLocation(h),setLocationFieldFocused:h=>g.current?.setLocationFieldFocused(h),handleFocus:()=>g.current?.setFocused(!0),handleBlur:()=>g.current?.setFocused(!1)});let y=ce.current,st=(0,E.useCallback)(h=>{let Y=h.target.value,q=Y.length>0&&!h.nativeEvent?.isComposing&&Y[0]!==Y[0].toUpperCase()?Y[0].toUpperCase()+Y.slice(1):Y;g.current?.handleTextChange(q)},[]),n=(0,E.useCallback)(h=>{g.current?.handleKeyDown(h.nativeEvent)},[]),le=g.current,w=tt??wa,De=ae!==void 0?ae:w.text,lt=re!==void 0?re:w.completedParams,ye=w.actionableSuggestions,je=ye[0],dt=(0,E.useMemo)(()=>(0,et.withoutTraditionalAutocomplete)(ye),[ye]),$e=le?.listboxId??"",ut=w.activeDropdownIndex>=0&&le?`${$e}-option-${w.activeDropdownIndex}`:void 0,Ie=w.editingParam,Me=w.editingIdentified,Ze=Ie?{parameter:Ie.suggestionParameter,text:Ie.suggestionPlaceholder,required:!0,options:Ie.options}:Me?{parameter:Me.parameter,text:(0,et.identifiedParamLabel)(Me.parameter),required:!0,options:[]}:null,ct=w.dropdownSuggestion??Ze??je,mt=Ze?[Ze]:ye,Ge=(0,et.dateSelectionFor)(w),pt=!le||w.dropdownLoading;return{completedParams:lt,multiSelectView:w.multiSelectView,toggleMultiSelectOption:y.toggleMultiSelectOption,commitMultiSelect:y.commitMultiSelect,skippedParams:w.skippedParams,identifiedParams:w.identifiedParams,suggestionPills:dt,setActivePill:y.setActivePill,skipActivePill:y.skipActivePill,removeLastParam:y.removeLastParam,segments:w.segments,newParamId:w.newParamId,clearNewParamId:y.clearNewParamId,suggestions:w.suggestions,activeIndex:w.activeDropdownIndex,isReady:w.isReady,isLoading:pt,isFocused:w.isFocused,isDropdownOpen:w.isDropdownOpen,isActivePillSelected:w.isActivePillSelected,placeholderText:w.placeholderText,listboxId:$e,error:w.error,products:w.products,customFields:w.customFields,selectProduct:y.selectProduct,addProductToCart:y.addProductToCart,handleTextChange:y.handleTextChange,handleKeyDown:y.handleKeyDown,setFocused:y.setFocused,editingParam:Ie,editingIdentified:Me,editingAnchor:w.editingAnchor,caretOffset:w.caretOffset,startEditingParam:y.startEditingParam,removeParam:y.removeParam,exitEditMode:y.exitEditMode,handleCaretAfterInput:y.handleCaretAfterInput,handleCaretMove:y.handleCaretMove,replaceEditingRange:y.replaceEditingRange,inputProps:{value:De,placeholder:w.placeholderText||void 0,onChange:st,onKeyDown:n,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":w.isDropdownOpen,"aria-activedescendant":ut,"aria-autocomplete":"list","aria-controls":$e},reset:y.reset,refreshProducts:y.refreshProducts,prepareSubmit:y.prepareSubmit,getState:y.getState,recordSubmit:y.recordSubmit,dropdownProps:{suggestions:ct?[{...ct,options:w.dropdownOptions}]:[],activeIndex:w.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,onUnhighlight:y.clearHighlight,isOpen:w.isDropdownOpen,id:$e,pills:mt,activeSelected:w.isActivePillSelected,onPillClick:y.setActivePill,onSkip:y.skipActivePill,showSkipButton:(W??!0)&&!Ie&&!Me,showOptionIcons:D??!0,showOptionImages:he??!0,showOptionCounts:T??!0,skipDisabled:w.inSelectionAnimation,isLoading:pt,skeletonExiting:w.skeletonExiting,isInputEmpty:De.trim().length===0,language:l,products:w.products,productImageFallback:K,onProductSelect:y.selectProduct,onProductAddToCart:c?y.addProductToCart:void 0,onProductFocusChange:y.setFocused,formatType:w.activeFormatType,dateView:w.dateView,selectedDateIso:Ge.selectedIso,selectedDateRange:Ge.selectedRange,dateRangeStart:Ge.rangeStart,dateReferences:Ge.references,onPreviousMonth:y.showPreviousMonth,onNextMonth:y.showNextMonth,timeView:w.timeView,multiSelectView:w.dropdownMultiSelect,onMultiSelectCommit:y.commitMultiSelect,onTimeChange:y.setTime,onTimeCommit:y.commitTime,locationView:w.locationView,isReediting:w.editingParam!=null,onLocationQuery:y.setLocationQuery,onLocationMove:y.moveLocationHighlight,onLocationCommit:y.commitLocation,onLocationFocusChange:y.setLocationFieldFocused,isFocused:w.isFocused||w.locationFieldFocused,optionsPosition:p??"below"}}}var _=require("@magicx-eng/ai-autocomplete-vanilla"),z=require("react"),At;function ni(){if(At!==void 0)return At;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),At=e.contentEditable==="plaintext-only",At}function va(e){let{segments:a,showChipIcons:t=!0,showChipImages:i=!0,showChipRemove:o=!1,removeParam:s,newParamId:r,editingParam:l,editingIdentified:b,editingAnchor:v,caretOffset:k,placeholderText:f,hintSuggestions:u,isFocused:p,isDropdownOpen:x,listboxId:A,activeDescendantId:te,autoFocus:F,handleTextChange:D,handleKeyDown:he,handleCaretAfterInput:T,handleCaretMove:W,startEditingParam:V,replaceEditingRange:K,setFocused:U}=e,P=(0,z.useRef)(null),ae=(0,z.useRef)(!1),re=(0,z.useRef)(""),O=(0,z.useRef)(""),j=(0,z.useRef)(null),Se=(0,z.useRef)(0);j.current=k,(0,z.useEffect)(()=>{if(!F)return;let m=P.current;if(!m)return;document.activeElement===m?U(!0):m.focus();let C=m.ownerDocument??document,S=C.getSelection(),R=S&&S.rangeCount>0&&m.contains(S.anchorNode);if(S&&!R){let M=C.createRange();M.selectNodeContents(m),M.collapse(!0),S.removeAllRanges(),S.addRange(M)}},[F,U]),(0,z.useEffect)(()=>{let m=P.current;if(!m)return;let C=m.ownerDocument??document,S=()=>{let R=C.getSelection();if(!R||R.rangeCount===0||!R.anchorNode||!m.contains(R.anchorNode))return;let M=R.anchorNode,Q=M.nodeType===Node.ELEMENT_NODE?M:M.parentElement,Pe=(R.isCollapsed?Q?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ze=l?.id??b?.id??null;if(Pe&&Pe!==ze){V(Pe);return}performance.now()-Se.current<50||W((0,_.getCursorOffset)(m))};return C.addEventListener("selectionchange",S),()=>C.removeEventListener("selectionchange",S)},[l,b,V,W]),(0,z.useEffect)(()=>{let m=P.current;if(!m)return;let C=S=>{let R=(0,_.chipIdFromTap)(m,S.target);R&&(V(R),(0,_.keepCaretOnChip)(m,R))};return m.addEventListener("click",C),()=>m.removeEventListener("click",C)},[V]),(0,z.useEffect)(()=>{let m=P.current;if(!(!m||!s||!o))return(0,_.attachChipRemove)(m,s)},[s,o]),(0,z.useLayoutEffect)(()=>{let m=P.current;m&&(0,_.renderEditableContent)({input:m,segments:a,newParamId:r,editingParamId:l?.id??null,placeholderText:f??"",isFocused:p,showChipIcons:t,showChipImages:i,showChipRemove:o,hintOptions:(0,_.startingHintOptions)(u??[])})},[a,r,l,f,u,p,t,i,o]),(0,z.useEffect)(()=>{let m=P.current;return()=>{m&&(0,_.cancelStartingHint)(m)}},[]),(0,z.useLayoutEffect)(()=>{let m=re.current,C=r??"";if(re.current=C,!C||C===m)return;let S=P.current;if(!S)return;S.focus();let R=j.current??(0,_.plainTextLength)(S);(0,_.setCursorOffset)(S,R)},[r]),(0,z.useLayoutEffect)(()=>{let m=O.current,C=l?.id??"";if(O.current=C,!C||C===m||v==null)return;let S=P.current;S&&(0,_.setCursorOffset)(S,v)},[l,v]);let ue=(0,z.useCallback)(()=>{if(ae.current)return;let m=P.current;if(!m)return;let C=(0,_.extractPlainText)(m),R=C.length>0&&C[0]!==C[0].toUpperCase()?C[0].toUpperCase()+C.slice(1):C;D(R)},[D]),xe=(0,z.useCallback)(()=>{Se.current=performance.now(),ue();let m=P.current;m&&T((0,_.getCursorOffset)(m))},[ue,T]);(0,z.useEffect)(()=>{let m=P.current;if(!m)return;let C=S=>{let R=S,M=R.inputType;if(M==="insertParagraph"||M==="insertLineBreak"||M==="insertFromDrop"){S.preventDefault();return}if(M.startsWith("insert")||M.startsWith("delete")){let Q=M.startsWith("delete")?"":R.data??"";K(Q)&&S.preventDefault()}};return m.addEventListener("beforeinput",C),()=>m.removeEventListener("beforeinput",C)},[K]);let c=(0,z.useCallback)(()=>{ae.current=!0,P.current?.setAttribute("data-aia-composing","true")},[]),I=(0,z.useCallback)(()=>{ae.current=!1,P.current?.removeAttribute("data-aia-composing"),ue()},[ue]),qe=(0,z.useCallback)(m=>{m.preventDefault();let C=P.current;if(!C)return;let S=(m.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!S)return;let R=C.ownerDocument??document,M=R.getSelection();if(!M||M.rangeCount===0)return;let Q=M.getRangeAt(0);if(!C.contains(Q.startContainer))return;Q.deleteContents();let Te=R.createTextNode(S);Q.insertNode(Te),Q.setStartAfter(Te),Q.collapse(!0),M.removeAllRanges(),M.addRange(Q),ue()},[ue]),g=(0,z.useCallback)(m=>he(m),[he]),tt=(0,z.useCallback)(()=>U(!0),[U]),_e=(0,z.useCallback)(()=>U(!1),[U]),Ve=(0,z.useCallback)(()=>P.current?.focus(),[]),Ue=(0,z.useCallback)(()=>P.current?.blur(),[]),We=(0,z.useCallback)(()=>{let m=P.current;return m?(0,_.extractPlainText)(m):""},[]),Qe=ni()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:Qe,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":A,"aria-expanded":x,"aria-activedescendant":te,spellCheck:!0,enterKeyHint:"send",onInput:xe,onKeyDown:g,onCompositionStart:c,onCompositionEnd:I,onPaste:qe,onFocus:tt,onBlur:_e},getPlainText:We,focus:Ve,blur:Ue}}var Le=require("react/jsx-runtime");function ri(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var xa=(0,ee.forwardRef)(function({onSubmit:a,onResult:t,onError:i,optionOverrides:o,maskCompletedText:s,className:r,apiConfig:l,additionalContext:b,language:v,currency:k,productId:f,visitorId:u,columns:p,pillPlacement:x="dropdown",mode:A="auto",optionsPosition:te="below",animations:F=!0,optionsStyle:D="floating",dropdownTrigger:he,closeDropdownOnBlur:T,prependPlaceholder:W,showNonTappableOptions:V,locationSearch:K,showOptionIcons:U=!0,showChipIcons:P=!0,showChipImages:ae=!0,showChipRemove:re=!1,showOptionImages:O=!0,showOptionCounts:j=!0,showSkipButton:Se,showProducts:ue,productsLayout:xe,productImageFallback:c,autoFocus:I=!0,onFocus:qe,onBlur:g,value:tt,completedParams:_e,onChange:Ve,onParamsChange:Ue,products:We,mapProducts:Qe,onProductSelect:m,onProductAddToCart:C,submitButton:S,resetOnSubmit:R=!0},M){let Q=(0,ee.useRef)(null),Te=(0,ee.useRef)(null),Pe=(0,ee.useRef)(null),ze=(0,ee.useRef)(()=>{}),se=(0,ee.useRef)(null),at=(0,ee.useRef)(null);(0,ee.useEffect)(()=>{let H=Q.current;if(H)return se.current?se.current.setMode(A):se.current=new Be.ModeController(H,A),()=>{se.current?.destroy(),se.current=null}},[A]);let it=(0,ee.useCallback)(H=>{let be=at.current?.current;be&&(be.focus(),(0,Be.setCursorOffset)(be,H))},[]),{completedParams:ot,suggestionPills:Ye,setActivePill:nt,skipActivePill:rt,segments:ce,newParamId:y,clearNewParamId:st,placeholderText:n,isFocused:le,isDropdownOpen:w,isActivePillSelected:De,isLoading:lt,isReady:ye,activeIndex:je,listboxId:dt,handleTextChange:$e,handleKeyDown:ut,setFocused:Ie,editingParam:Me,editingIdentified:Ze,editingAnchor:ct,caretOffset:mt,startEditingParam:Ge,removeParam:pt,handleCaretAfterInput:h,handleCaretMove:Y,replaceEditingRange:N,dropdownProps:q,reset:xt,refreshProducts:Bt,prepareSubmit:Wt,getState:Gt,recordSubmit:Kt}=Et({onSubmit:H=>ze.current(H),onResult:t,onError:i,optionOverrides:o,maskCompletedText:s,apiConfig:l,additionalContext:b,language:v,currency:k,productId:f,visitorId:u,columns:p,dropdownTrigger:he,optionsPosition:te,closeDropdownOnBlur:T,prependPlaceholder:W,showNonTappableOptions:V,locationSearch:K,showOptionIcons:U,showOptionImages:O,showOptionCounts:j,showSkipButton:Se,showProducts:ue,onFocus:qe,onBlur:g,value:tt,completedParams:_e,onChange:Ve,onParamsChange:Ue,products:We,mapProducts:Qe,onProductSelect:m,onProductAddToCart:C,source:"full-sdk",setCursor:it});(0,ee.useEffect)(()=>{if(!y)return;let H=window.setTimeout(()=>st(),650);return()=>window.clearTimeout(H)},[y,st]);let ya=je>=0?`${dt}-option-${je}`:void 0,{inputRef:Ot,editorProps:ka,focus:yt,blur:qt,getPlainText:_t}=va({segments:ce,newParamId:y,editingParam:Me,editingIdentified:Ze,editingAnchor:ct,caretOffset:mt,placeholderText:n,hintSuggestions:x==="inline"?[]:Ye,isFocused:le,showChipIcons:P,showChipImages:ae,showChipRemove:re,removeParam:pt,isDropdownOpen:w,listboxId:dt,activeDescendantId:ya,autoFocus:I,handleTextChange:$e,handleKeyDown:ut,handleCaretAfterInput:h,handleCaretMove:Y,startEditingParam:Ge,replaceEditingRange:N,setFocused:Ie});at.current=Ot,(0,ee.useLayoutEffect)(()=>{let H=Te.current,be=Ot.current;if(!H||!be)return;let ft=()=>{let Ut=H.firstElementChild;if(!Ut)return;let Pa=Ut.getBoundingClientRect(),Ia=be.getBoundingClientRect();Pa.top>=Ia.bottom-2?H.setAttribute("data-aia-pill-wrapped",""):H.removeAttribute("data-aia-pill-wrapped")};ft();let Vt=new ResizeObserver(ft);return Vt.observe(be),()=>Vt.disconnect()},[ce,Ye.length,lt,Ot]),(0,ee.useEffect)(()=>{let H=Pe.current;if(H)return(0,Be.watchEditorHeight)(H)},[]),(0,ee.useImperativeHandle)(M,()=>({focus:yt,blur:qt,reset:xt,refreshProducts:Bt,setMode:H=>se.current?.setMode(H),skipActivePill:rt}),[yt,qt,xt,Bt,rt]);let gt=!!ce.length||ot.length>0,Rt=(0,ee.useCallback)(H=>{if(!gt)return;H&&Wt();let be=Gt(),ft=(0,Be.buildSubmitResult)(_t(),be.completedParams,be.skippedParams,{identifiedParams:be.identifiedParams,isReady:be.isReady,customFields:be.customFields});H&&Kt(ft),a(ft),R&&xt()},[Kt,R,gt,Wt,Gt,a,xt,_t]);ze.current=()=>Rt(!1);let Ca=(0,ee.useCallback)(H=>{H.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||yt()},[yt]),Sa=x==="inline",Ta=x==="dropdown";return(0,Le.jsxs)("div",{ref:Q,className:`magicx-aia ${ht.container} ${r??""}`,"data-pill-placement":x,"data-options-position":te,"data-animations":F?"on":"off","data-aia-options-style":D,"data-mode":ri(A),children:[(0,Le.jsx)(Pt,{...q,showPills:Ta,productsLayout:xe,productImageFallback:c}),(0,Le.jsxs)("div",{className:ht.inputWrapper,"data-aia-input-wrapper":"",onClick:Ca,children:[(0,Le.jsxs)("div",{ref:Pe,className:ht.editorArea,"data-aia-editor":"",children:[(0,Le.jsx)("div",{...ka,className:ht.input,"data-aia-input":""}),Sa&&(lt||Ye.length>0)&&(0,Le.jsx)("span",{ref:Te,className:ht.pillListContainer,"data-aia-pill-list-container":"",children:(0,Le.jsx)(St,{pills:Ye,activePillIndex:0,activeSelected:De,onSelectPill:nt,loading:lt})})]}),S===null?null:S===void 0?(0,Le.jsx)(ga,{disabled:!gt,ready:gt&&ye,onClick:()=>Rt(!0),label:(0,Be.uiStringsFor)(v).submit}):(0,Le.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ht.submitSlot,onClick:H=>{gt&&(H.stopPropagation(),Rt(!0))},children:S})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,LOCATION_META_KEY,PRODUCT_PATH_PREFIX,TIME_META_KEY,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,parseTime,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
3622
3677
|
//# sourceMappingURL=index.js.map
|