@magicx-eng/ai-autocomplete-react 0.37.0 → 0.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ft=Object.defineProperty;var na=Object.getOwnPropertyDescriptor;var ra=Object.getOwnPropertyNames;var sa=Object.prototype.hasOwnProperty;var la=(e,a)=>{for(var t in a)ft(e,t,{get:a[t],enumerable:!0})},da=(e,a,t,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of ra(a))!sa.call(e,o)&&o!==t&&ft(e,o,{get:()=>a[o],enumerable:!(i=na(a,o))||i.enumerable});return e};var ca=e=>da(ft({},"__esModule",{value:!0}),e);var Sa={};la(Sa,{AIAutocomplete:()=>Vt,AIAutocompleteDropdown:()=>lt,DATE_RANGE_META_END:()=>s.DATE_RANGE_META_END,DATE_RANGE_META_START:()=>s.DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT:()=>s.DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX:()=>s.PRODUCT_PATH_PREFIX,WEEKDAY_LABELS:()=>s.WEEKDAY_LABELS,buildSubmitResult:()=>s.buildSubmitResult,cellDay:()=>s.cellDay,cellIso:()=>s.cellIso,dateCellMarks:()=>s.dateCellMarks,formatDate:()=>s.formatDate,formatDateRange:()=>s.formatDateRange,formatOptionCount:()=>s.formatOptionCount,isoDate:()=>s.isoDate,monthLabel:()=>s.monthLabel,optionCountLabel:()=>s.optionCountLabel,optionHasImage:()=>s.optionHasImage,optionImageSources:()=>s.optionImageSources,optionImageSrc:()=>s.optionImageSrc,optionLabel:()=>s.optionLabel,parseDate:()=>s.parseDate,parseLooseDate:()=>s.parseLooseDate,parseLooseDateRange:()=>s.parseLooseDateRange,productFromMatchedItem:()=>s.productFromMatchedItem,productImageSources:()=>s.productImageSources,productsFromCustomFields:()=>s.productsFromCustomFields,sanitizeOptionIconSvg:()=>s.sanitizeOptionIconSvg,selectedRangeFor:()=>s.selectedRangeFor,useAIAutocomplete:()=>ct,visibleDateRange:()=>s.visibleDateRange,withSkippedParams:()=>s.withSkippedParams});module.exports=ca(Sa);var s=require("@magicx-eng/ai-autocomplete-vanilla");var N=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-container-KKjFU {
1
+ "use strict";var bt=Object.defineProperty;var na=Object.getOwnPropertyDescriptor;var ra=Object.getOwnPropertyNames;var sa=Object.prototype.hasOwnProperty;var la=(e,a)=>{for(var t in a)bt(e,t,{get:a[t],enumerable:!0})},da=(e,a,t,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of ra(a))!sa.call(e,o)&&o!==t&&bt(e,o,{get:()=>a[o],enumerable:!(i=na(a,o))||i.enumerable});return e};var ca=e=>da(bt({},"__esModule",{value:!0}),e);var Sa={};la(Sa,{AIAutocomplete:()=>$t,AIAutocompleteDropdown:()=>lt,DATE_RANGE_META_END:()=>s.DATE_RANGE_META_END,DATE_RANGE_META_START:()=>s.DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT:()=>s.DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX:()=>s.PRODUCT_PATH_PREFIX,WEEKDAY_LABELS:()=>s.WEEKDAY_LABELS,buildSubmitResult:()=>s.buildSubmitResult,cellDay:()=>s.cellDay,cellIso:()=>s.cellIso,dateCellMarks:()=>s.dateCellMarks,formatDate:()=>s.formatDate,formatDateRange:()=>s.formatDateRange,formatOptionCount:()=>s.formatOptionCount,isoDate:()=>s.isoDate,monthLabel:()=>s.monthLabel,optionCountLabel:()=>s.optionCountLabel,optionHasImage:()=>s.optionHasImage,optionImageSources:()=>s.optionImageSources,optionImageSrc:()=>s.optionImageSrc,optionLabel:()=>s.optionLabel,parseDate:()=>s.parseDate,parseLooseDate:()=>s.parseLooseDate,parseLooseDateRange:()=>s.parseLooseDateRange,productFromMatchedItem:()=>s.productFromMatchedItem,productImageSources:()=>s.productImageSources,productsFromCustomFields:()=>s.productsFromCustomFields,sanitizeOptionIconSvg:()=>s.sanitizeOptionIconSvg,selectedRangeFor:()=>s.selectedRangeFor,useAIAutocomplete:()=>ct,visibleDateRange:()=>s.visibleDateRange,withSkippedParams:()=>s.withSkippedParams});module.exports=ca(Sa);var s=require("@magicx-eng/ai-autocomplete-vanilla");var F=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-container-KKjFU {
2
2
  position: relative;
3
3
  /* Inherits the host page's font by default. Consumers can pin a specific
4
4
  font on the library via \`--aia-font-family: 'Custom Font'\` without
@@ -262,7 +262,7 @@
262
262
  opacity: 0;
263
263
  }
264
264
  }
265
- `,document.head.appendChild(e)}var We={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};var me=require("@magicx-eng/ai-autocomplete-vanilla"),q=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
265
+ `,document.head.appendChild(e)}var Ue={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};var ee=require("@magicx-eng/ai-autocomplete-vanilla"),j=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
266
266
  * Built-in appearance defaults \u2014 zero specificity via :where().
267
267
  * Consumer CSS always wins without !important.
268
268
  *
@@ -1098,7 +1098,7 @@
1098
1098
  opacity: 0.25;
1099
1099
  }
1100
1100
  }
1101
- `,document.head.appendChild(e)}var xe={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};var M=require("@magicx-eng/ai-autocomplete-vanilla"),At=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
1101
+ `,document.head.appendChild(e)}var ke={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};var N=require("@magicx-eng/ai-autocomplete-vanilla"),Rt=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) ---
1102
1102
 
1103
1103
  One of three hand-maintained copies (vanilla styles.css, this file, Angular's
1104
1104
  date-grid.component.css). Only the class-naming layer differs \u2014 the
@@ -1261,7 +1261,7 @@
1261
1261
  opacity: 0.8;
1262
1262
  background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
1263
1263
  }
1264
- `,document.head.appendChild(e)}var L={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};var J=require("react/jsx-runtime"),pa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Rt({options:e,activeIndex:a,listboxId:t,view:i,selection:o,onSelect:r,onHighlight:n,onUnhighlight:h,onPreviousMonth:d,onNextMonth:x}){let E=(0,M.isoDate)(new Date),I=(0,M.visibleDateRange)({pendingStart:o.rangeStart,highlightedIso:(0,M.cellIso)(e[a]),selected:o.selectedRange});return(0,J.jsxs)("div",{className:L.datepicker,"data-aia-datepicker":"",children:[(0,J.jsxs)("div",{className:L.header,children:[(0,J.jsx)("button",{type:"button",tabIndex:-1,className:L.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:d,children:"\u2039"}),(0,J.jsx)("span",{className:L.month,"data-aia-date-month":"","aria-live":"polite",children:(0,M.monthLabel)(i)}),(0,J.jsx)("button",{type:"button",tabIndex:-1,className:L.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:x,children:"\u203A"})]}),(0,J.jsx)("div",{className:L.weekdays,"aria-hidden":"true",children:M.WEEKDAY_LABELS.map((m,w)=>(0,J.jsx)("span",{className:L.weekday,children:m},pa[w]))}),(0,J.jsx)("div",{className:L.grid,"data-aia-date-grid":"",children:e.map((m,w)=>(0,J.jsx)(ha,{option:m,id:`${t}-option-${w}`,index:w,isHighlighted:w===a&&m.is_tappable,isToday:(0,M.cellIso)(m)===E,isPast:(0,M.cellIso)(m)!=null&&(0,M.cellIso)(m)<E,marks:(0,M.dateCellMarks)((0,M.cellIso)(m),{selectedIso:o.selectedIso,range:I}),onSelect:r,onHighlight:n,onUnhighlight:h},(0,M.cellIso)(m)??`pad-${w}`))})]})}function ha({option:e,id:a,index:t,isHighlighted:i,isToday:o,isPast:r,marks:n,onSelect:h,onHighlight:d,onUnhighlight:x}){let[E,I]=(0,At.useState)(!1),m=(0,M.cellDay)(e);if(m==null)return(0,J.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${L.cell} ${L.blank}`});let w=()=>{I(!0),h(e),setTimeout(()=>I(!1),170)},T=[L.cell,L.day,r?L.past:"",i?L.highlighted:"",o?L.today:"",n.inRange?L.inRange:"",n.selected?L.selected:"",E?L.pressed:""].filter(Boolean).join(" ");return(0,J.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:T,onClick:w,onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),w())},onMouseEnter:()=>d(t),onMouseLeave:x?()=>x(t):void 0,children:(0,J.jsx)("span",{className:L.number,children:m})})}var Me=require("@magicx-eng/ai-autocomplete-vanilla"),nt=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
1264
+ `,document.head.appendChild(e)}var z={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};var J=require("react/jsx-runtime"),pa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Ot({options:e,activeIndex:a,listboxId:t,view:i,selection:o,onSelect:r,onHighlight:n,onUnhighlight:p,onPreviousMonth:d,onNextMonth:x}){let T=(0,N.isoDate)(new Date),I=(0,N.visibleDateRange)({pendingStart:o.rangeStart,highlightedIso:(0,N.cellIso)(e[a]),selected:o.selectedRange});return(0,J.jsxs)("div",{className:z.datepicker,"data-aia-datepicker":"",children:[(0,J.jsxs)("div",{className:z.header,children:[(0,J.jsx)("button",{type:"button",tabIndex:-1,className:z.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:d,children:"\u2039"}),(0,J.jsx)("span",{className:z.month,"data-aia-date-month":"","aria-live":"polite",children:(0,N.monthLabel)(i)}),(0,J.jsx)("button",{type:"button",tabIndex:-1,className:z.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:x,children:"\u203A"})]}),(0,J.jsx)("div",{className:z.weekdays,"aria-hidden":"true",children:N.WEEKDAY_LABELS.map((m,w)=>(0,J.jsx)("span",{className:z.weekday,children:m},pa[w]))}),(0,J.jsx)("div",{className:z.grid,"data-aia-date-grid":"",children:e.map((m,w)=>(0,J.jsx)(ha,{option:m,id:`${t}-option-${w}`,index:w,isHighlighted:w===a&&m.is_tappable,isToday:(0,N.cellIso)(m)===T,isPast:(0,N.cellIso)(m)!=null&&(0,N.cellIso)(m)<T,marks:(0,N.dateCellMarks)((0,N.cellIso)(m),{selectedIso:o.selectedIso,range:I}),onSelect:r,onHighlight:n,onUnhighlight:p},(0,N.cellIso)(m)??`pad-${w}`))})]})}function ha({option:e,id:a,index:t,isHighlighted:i,isToday:o,isPast:r,marks:n,onSelect:p,onHighlight:d,onUnhighlight:x}){let[T,I]=(0,Rt.useState)(!1),m=(0,N.cellDay)(e);if(m==null)return(0,J.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${z.cell} ${z.blank}`});let w=()=>{I(!0),p(e),setTimeout(()=>I(!1),170)},E=[z.cell,z.day,r?z.past:"",i?z.highlighted:"",o?z.today:"",n.inRange?z.inRange:"",n.selected?z.selected:"",T?z.pressed:""].filter(Boolean).join(" ");return(0,J.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:E,onClick:w,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),w())},onMouseEnter:()=>d(t),onMouseLeave:x?()=>x(t):void 0,children:(0,J.jsx)("span",{className:z.number,children:m})})}var Me=require("@magicx-eng/ai-autocomplete-vanilla"),nt=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
1265
1265
  display: flex;
1266
1266
  flex-wrap: wrap;
1267
1267
  gap: var(--aia-cluster-gap, 0.5rem);
@@ -1301,7 +1301,7 @@
1301
1301
  .aia-cluster[data-justify="around"] {
1302
1302
  justify-content: space-around;
1303
1303
  }
1304
- `,document.head.appendChild(e)}var bt=require("react/jsx-runtime");function $e({gap:e,align:a="center",justify:t="start",noWrap:i=!1,inline:o=!1,className:r,children:n,...h}){let d=e?{"--aia-cluster-gap":e}:void 0,x={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":i||void 0,"data-inline":o||void 0,style:d,...h};return o?(0,bt.jsx)("span",{...x,children:n}):(0,bt.jsx)("div",{...x,children:n})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
1304
+ `,document.head.appendChild(e)}var wt=require("react/jsx-runtime");function $e({gap:e,align:a="center",justify:t="start",noWrap:i=!1,inline:o=!1,className:r,children:n,...p}){let d=e?{"--aia-cluster-gap":e}:void 0,x={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":i||void 0,"data-inline":o||void 0,style:d,...p};return o?(0,wt.jsx)("span",{...x,children:n}):(0,wt.jsx)("div",{...x,children:n})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
1305
1305
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
1306
1306
  room above the hint/branding row so the footer doesn't butt against the last
1307
1307
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -1448,7 +1448,7 @@
1448
1448
  justify-content: flex-end;
1449
1449
  }
1450
1450
  }
1451
- `,document.head.appendChild(e)}var ye={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};var de=require("react/jsx-runtime");function Ot({isOptionHighlighted:e=!1,isInputEmpty:a=!1,strings:t=(0,Me.uiStringsFor)()}){let{key:i,hint:o}=(0,Me.getFooterHint)(e,a,t),[r,n]=(0,nt.useState)(Me.ATTRIBUTION_URL);return(0,nt.useEffect)(()=>{n((0,Me.buildAttributionUrl)())},[]),(0,de.jsx)("footer",{className:ye.footer,"data-aia-footer":"",children:(0,de.jsxs)($e,{justify:"between",noWrap:!0,className:ye.row,children:[(0,de.jsxs)($e,{gap:"5px",className:ye.hintGroup,children:[(0,de.jsx)("kbd",{className:ye.key,children:i}),(0,de.jsx)("span",{className:ye.hint,children:o})]}),(0,de.jsxs)("a",{className:ye.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[(0,de.jsx)("span",{className:ye.brand,children:"AI"}),(0,de.jsx)("span",{className:ye.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
1451
+ `,document.head.appendChild(e)}var Ce={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 ge=require("react/jsx-runtime");function Dt({isOptionHighlighted:e=!1,isInputEmpty:a=!1,strings:t=(0,Me.uiStringsFor)()}){let{key:i,hint:o}=(0,Me.getFooterHint)(e,a,t),[r,n]=(0,nt.useState)(Me.ATTRIBUTION_URL);return(0,nt.useEffect)(()=>{n((0,Me.buildAttributionUrl)())},[]),(0,ge.jsx)("footer",{className:Ce.footer,"data-aia-footer":"",children:(0,ge.jsxs)($e,{justify:"between",noWrap:!0,className:Ce.row,children:[(0,ge.jsxs)($e,{gap:"5px",className:Ce.hintGroup,children:[(0,ge.jsx)("kbd",{className:Ce.key,children:i}),(0,ge.jsx)("span",{className:Ce.hint,children:o})]}),(0,ge.jsxs)("a",{className:Ce.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[(0,ge.jsx)("span",{className:Ce.brand,children:"AI"}),(0,ge.jsx)("span",{className:Ce.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
1452
1452
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
1453
1453
  The border is kept as a 1px transparent line so the box stays the same size
1454
1454
  as it was when the outline was dashed. */
@@ -1524,7 +1524,7 @@
1524
1524
  opacity: 0;
1525
1525
  }
1526
1526
  }
1527
- `,document.head.appendChild(e)}var Ne={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};var Lt=require("react/jsx-runtime"),wt={selected:1,first:.7,next:.4,last:.2};function Dt({label:e,state:a,rounded:t,loading:i,onClick:o}){let r=[Ne.pill,t?Ne.rounded:"",i?Ne.skeleton:""].filter(Boolean).join(" ");return(0,Lt.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:wt[a]},onMouseDown:n=>n.preventDefault(),onClick:i?void 0:o,disabled:i,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
1527
+ `,document.head.appendChild(e)}var Ne={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};var zt=require("react/jsx-runtime"),vt={selected:1,first:.7,next:.4,last:.2};function Lt({label:e,state:a,rounded:t,loading:i,onClick:o}){let r=[Ne.pill,t?Ne.rounded:"",i?Ne.skeleton:""].filter(Boolean).join(" ");return(0,zt.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:vt[a]},onMouseDown:n=>n.preventDefault(),onClick:i?void 0:o,disabled:i,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
1528
1528
  position: relative;
1529
1529
  z-index: 1;
1530
1530
  pointer-events: auto;
@@ -1534,7 +1534,7 @@
1534
1534
  align-items: center;
1535
1535
  vertical-align: middle;
1536
1536
  }
1537
- `,document.head.appendChild(e)}var vt={list:"aia-list-qvLqO"};var Xe=require("react/jsx-runtime"),ua=[125,69];function zt(e){return e===0?"first":e===1?"next":"last"}function rt({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:i,rounded:o,loading:r}){return r&&e.length===0?(0,Xe.jsx)("span",{className:vt.list,"data-aia-pill-list-loading":"",children:ua.map((n,h)=>(0,Xe.jsx)("span",{"data-aia-pill-skeleton":"",className:`${Ne.pill} ${o?Ne.rounded:""} ${Ne.skeleton}`,style:{width:n,opacity:wt[zt(h)]}},`skel-${n}`))}):(0,Xe.jsx)("span",{className:vt.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((n,h)=>{let d=!!i&&h===a;return(0,Xe.jsx)(Dt,{label:n.text,state:d?"selected":zt(h),selected:d,rounded:o,loading:r,onClick:()=>t(h)},`${n.parameter}-${n.text}`)})})}var ce=require("@magicx-eng/ai-autocomplete-vanilla"),qe=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-fef1688d")){let e=document.createElement("style");e.id="ac-style-fef1688d",e.textContent=`/* Product strip \u2014 the React counterpart of the vanilla core's strip rules
1537
+ `,document.head.appendChild(e)}var xt={list:"aia-list-qvLqO"};var Xe=require("react/jsx-runtime"),ua=[125,69];function Mt(e){return e===0?"first":e===1?"next":"last"}function rt({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:i,rounded:o,loading:r}){return r&&e.length===0?(0,Xe.jsx)("span",{className:xt.list,"data-aia-pill-list-loading":"",children:ua.map((n,p)=>(0,Xe.jsx)("span",{"data-aia-pill-skeleton":"",className:`${Ne.pill} ${o?Ne.rounded:""} ${Ne.skeleton}`,style:{width:n,opacity:vt[Mt(p)]}},`skel-${n}`))}):(0,Xe.jsx)("span",{className:xt.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((n,p)=>{let d=!!i&&p===a;return(0,Xe.jsx)(Lt,{label:n.text,state:d?"selected":Mt(p),selected:d,rounded:o,loading:r,onClick:()=>t(p)},`${n.parameter}-${n.text}`)})})}var me=require("@magicx-eng/ai-autocomplete-vanilla"),je=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
1538
1538
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
1539
1539
  theming one package sees the same result in the other.
1540
1540
 
@@ -1640,11 +1640,14 @@
1640
1640
  background: var(--aia-product-media-bg, var(--aia-skeleton-bg, rgba(189, 189, 189, 0.25)));
1641
1641
  }
1642
1642
 
1643
+ /* \`contain\`, not \`cover\`: catalog photos come in any aspect ratio, and a
1644
+ square crop cuts the top and bottom off a tall one (a gallon jug). The
1645
+ picture scales by its longer side and the media fill shows around it. */
1643
1646
  .aia-image-5pNL7 {
1644
1647
  display: block;
1645
1648
  width: 100%;
1646
1649
  height: 100%;
1647
- object-fit: cover;
1650
+ object-fit: contain;
1648
1651
  }
1649
1652
 
1650
1653
  /* Placeholder tile for a product with no image \u2014 a storefront pictogram on
@@ -1818,7 +1821,7 @@
1818
1821
  letter-spacing: 0.02em;
1819
1822
  text-align: center;
1820
1823
  }
1821
- `,document.head.appendChild(e)}var oe={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",badge:"aia-badge-j9Hcd"};var Z=require("react/jsx-runtime");function Mt({products:e,listboxId:a,onSelect:t,onFocusChange:i,focusable:o=!0,layout:r="row",imageFallback:n="image",strings:h=(0,ce.uiStringsFor)()}){let d=e.length>0,x=(0,qe.useRef)(null);if((0,qe.useEffect)(()=>{let I=x.current;if(!(!d||!I))return(0,ce.attachProductRowWheel)(I)},[d]),!d)return null;let E=`${a}-products-label`;return(0,Z.jsxs)("section",{className:oe.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":E,children:[(0,Z.jsx)("div",{className:oe.label,id:E,"data-aia-products-label":"",children:h.products}),(0,Z.jsx)("div",{ref:x,className:oe.row,"data-aia-products-row":"",children:e.map((I,m)=>(0,Z.jsx)(ga,{product:I,id:`${a}-product-${m}`,onSelect:t,onFocusChange:i,focusable:o,imageFallback:n,soldOut:h.soldOut},I.id))})]})}function ga({product:e,id:a,onSelect:t,onFocusChange:i,focusable:o,imageFallback:r,soldOut:n}){let h=d=>{d.metaKey||d.ctrlKey||d.shiftKey||d.altKey||d.button!==0||(d.preventDefault(),t(e))};return(0,Z.jsxs)("a",{id:a,className:oe.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:o?0:-1,onClick:h,onKeyDown:d=>{d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:d=>{d.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[(0,Z.jsx)(ma,{sources:(0,ce.productImageSources)(e.imageUrl),title:e.title,fallback:r},(0,ce.productImageSrc)(e.imageUrl)??""),(0,Z.jsxs)("span",{className:oe.body,children:[e.vendor?(0,Z.jsx)("span",{className:oe.vendor,children:e.vendor}):null,(0,Z.jsx)("span",{className:oe.title,children:e.title}),e.price?(0,Z.jsx)("span",{className:oe.price,children:e.price}):null,e.available===!1?(0,Z.jsx)("span",{className:oe.badge,children:n}):null]})]})}function ma({sources:e,title:a,fallback:t}){let[i,o]=(0,qe.useState)(0),r=e[i],n=!!r,h=!n&&t==="initial";return(0,Z.jsxs)("span",{className:oe.media,"aria-hidden":"true","data-aia-product-placeholder":!n&&!h?"":void 0,"data-aia-product-initial":h?"":void 0,children:[n?(0,Z.jsx)("img",{className:oe.image,src:r,alt:"",loading:"lazy",decoding:"async",onError:()=>o(d=>d+1)}):null,h?(0,ce.productInitial)(a):null]})}var V=require("@magicx-eng/ai-autocomplete-vanilla"),ge=require("react");var Nt=require("@magicx-eng/ai-autocomplete-vanilla"),st=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
1824
+ `,document.head.appendChild(e)}var re={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",badge:"aia-badge-j9Hcd"};var Z=require("react/jsx-runtime");function Nt({products:e,listboxId:a,onSelect:t,onFocusChange:i,focusable:o=!0,layout:r="row",imageFallback:n="image",strings:p=(0,me.uiStringsFor)()}){let d=e.length>0,x=(0,je.useRef)(null);if((0,je.useEffect)(()=>{let I=x.current;if(!(!d||!I))return(0,me.attachProductRowWheel)(I)},[d]),!d)return null;let T=`${a}-products-label`;return(0,Z.jsxs)("section",{className:re.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":T,children:[(0,Z.jsx)("div",{className:re.label,id:T,"data-aia-products-label":"",children:p.products}),(0,Z.jsx)("div",{ref:x,className:re.row,"data-aia-products-row":"",children:e.map((I,m)=>(0,Z.jsx)(ga,{product:I,id:`${a}-product-${m}`,onSelect:t,onFocusChange:i,focusable:o,imageFallback:n,soldOut:p.soldOut},I.id))})]})}function ga({product:e,id:a,onSelect:t,onFocusChange:i,focusable:o,imageFallback:r,soldOut:n}){let p=d=>{d.metaKey||d.ctrlKey||d.shiftKey||d.altKey||d.button!==0||(d.preventDefault(),t(e))};return(0,Z.jsxs)("a",{id:a,className:re.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:o?0:-1,onClick:p,onKeyDown:d=>{d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:d=>{d.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[(0,Z.jsx)(ma,{sources:(0,me.productImageSources)(e.imageUrl),title:e.title,fallback:r},(0,me.productImageSrc)(e.imageUrl)??""),(0,Z.jsxs)("span",{className:re.body,children:[e.vendor?(0,Z.jsx)("span",{className:re.vendor,children:e.vendor}):null,(0,Z.jsx)("span",{className:re.title,children:e.title}),e.price?(0,Z.jsx)("span",{className:re.price,children:e.price}):null,e.available===!1?(0,Z.jsx)("span",{className:re.badge,children:n}):null]})]})}function ma({sources:e,title:a,fallback:t}){let[i,o]=(0,je.useState)(0),r=e[i],n=!!r,p=!n&&t==="initial";return(0,Z.jsxs)("span",{className:re.media,"aria-hidden":"true","data-aia-product-placeholder":!n&&!p?"":void 0,"data-aia-product-initial":p?"":void 0,children:[n?(0,Z.jsx)("img",{className:re.image,src:r,alt:"",loading:"lazy",decoding:"async",onError:()=>o(d=>d+1)}):null,p?(0,me.productInitial)(a):null]})}var V=require("@magicx-eng/ai-autocomplete-vanilla"),be=require("react");var Ft=require("@magicx-eng/ai-autocomplete-vanilla"),st=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
1822
1825
  display: grid;
1823
1826
  grid-template-columns: repeat(
1824
1827
  auto-fit,
@@ -1854,7 +1857,7 @@
1854
1857
  .aia-grid[data-scroll]::-webkit-scrollbar {
1855
1858
  display: none;
1856
1859
  }
1857
- `,document.head.appendChild(e)}var Bt=require("react/jsx-runtime");function Ft({min:e="16rem",max:a,gap:t,scroll:i=!1,maxHeight:o,scrollResetKey:r,cols:n,template:h,innerRef:d,className:x,children:E,...I}){let m=(0,st.useRef)(null);(0,st.useLayoutEffect)(()=>{if(r===void 0)return;let T=m.current;T&&(T.scrollTop=0)},[r]);let w={"--aia-grid-min":e};return a&&(w["--aia-grid-max"]=a),t&&(w["--aia-grid-gap"]=t),o&&(w["--aia-grid-max-height"]=o),n&&(w.gridTemplateColumns=(0,Nt.optionsGridTemplateColumns)(n)),h&&(w.gridTemplateColumns=h),(0,Bt.jsx)("div",{ref:T=>{m.current=T,d?.(T)},className:x?`aia-grid ${x}`:"aia-grid","data-scroll":i||void 0,style:w,...I,children:E})}var ue=require("@magicx-eng/ai-autocomplete-vanilla"),he=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
1860
+ `,document.head.appendChild(e)}var Ht=require("react/jsx-runtime");function Bt({min:e="16rem",max:a,gap:t,scroll:i=!1,maxHeight:o,scrollResetKey:r,cols:n,template:p,innerRef:d,className:x,children:T,...I}){let m=(0,st.useRef)(null);(0,st.useLayoutEffect)(()=>{if(r===void 0)return;let E=m.current;E&&(E.scrollTop=0)},[r]);let w={"--aia-grid-min":e};return a&&(w["--aia-grid-max"]=a),t&&(w["--aia-grid-gap"]=t),o&&(w["--aia-grid-max-height"]=o),n&&(w.gridTemplateColumns=(0,Ft.optionsGridTemplateColumns)(n)),p&&(w.gridTemplateColumns=p),(0,Ht.jsx)("div",{ref:E=>{m.current=E,d?.(E)},className:x?`aia-grid ${x}`:"aia-grid","data-scroll":i||void 0,style:w,...I,children:T})}var ae=require("@magicx-eng/ai-autocomplete-vanilla"),fe=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
1858
1861
  position: relative;
1859
1862
  /* Clip, not visible: the entrance rise below runs on the inner content,
1860
1863
  and a transformed box extends its scroll container's scrollable area.
@@ -2258,7 +2261,7 @@
2258
2261
  opacity: 0;
2259
2262
  }
2260
2263
  }
2261
- `,document.head.appendChild(e)}var ee={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",skeletonBarIn:"aia-skeletonBarIn-ZlEM0",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};var pe=require("react/jsx-runtime");function Ht({option:e,isHighlighted:a,onSelect:t,onHighlight:i,onUnhighlight:o,id:r,loading:n,showIcon:h=!0,showImage:d=!0,showCount:x=!0,scrollHint:E,enterDelayMs:I=0}){let[m]=(0,he.useState)(I),[w,T]=(0,he.useState)(!1),F=d?(0,ue.optionImageSources)(e.image_url):[],B=F[0]??null,[j,z]=(0,he.useState)([]),A=F.find(G=>!j.includes(G))??null,U=(0,he.useMemo)(()=>!B&&h&&e.icon_svg?(0,ue.sanitizeOptionIconSvg)(e.icon_svg):null,[B,h,e.icon_svg]),H=x?(0,ue.formatOptionCount)(e.item_count):null,P=(0,he.useRef)(void 0);(0,he.useEffect)(()=>()=>clearTimeout(P.current),[]);let K=()=>{n||!e.is_tappable||w||(T(!0),t(e),clearTimeout(P.current),P.current=setTimeout(()=>T(!1),170))},Q=[ee.item,a&&!n?ee.highlighted:"",e.is_tappable?ee.tappable:ee.nonTappable,w?ee.pressed:"",E?ee.scrollHint:""].filter(Boolean).join(" ");return(0,pe.jsx)("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":n?"":void 0,"data-aia-icon":U&&e.icon?e.icon:void 0,"data-aia-image":B?"":void 0,"data-aia-item-count":H!==null?e.item_count:void 0,"aria-selected":a,className:Q,style:{[ue.OPTION_ENTER_DELAY_VAR]:`${m}ms`},tabIndex:n||!e.is_tappable?-1:0,onClick:K,onKeyDown:G=>{!n&&e.is_tappable&&(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),K())},onMouseEnter:!n&&e.is_tappable?i:void 0,onMouseLeave:o,children:(0,pe.jsxs)("span",{className:ee.content,children:[B&&(0,pe.jsx)("span",{className:`${ee.image} magicx-aia-option-image`,"aria-hidden":"true",children:(0,pe.jsx)("img",{src:A??B,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:A===null,onError:()=>{A!==null&&z(G=>[...G,A])}})}),U&&(0,pe.jsx)("span",{className:`${ee.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:U}}),(0,pe.jsx)("span",{className:ee.text,children:(0,ue.optionLabel)(e)}),e.tag&&(0,pe.jsx)("span",{className:ee.tag,children:e.tag}),H!==null&&(0,pe.jsx)("span",{className:`${ee.count} magicx-aia-option-count`,children:H})]})})}var xt=require("react/jsx-runtime");function fa(){let[e,a]=(0,ge.useState)(V.isOptionsGridMobileViewport);return(0,ge.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(V.OPTIONS_GRID_MOBILE_QUERY),i=()=>a(t.matches);return i(),t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function Kt({options:e,activeIndex:a,onSelect:t,onHighlight:i,onUnhighlight:o,listboxId:r,loading:n,groupKey:h="",optionsPosition:d="below",showIcons:x=!0,showImages:E=!0,showCounts:I=!0}){let m=fa(),w=(0,ge.useRef)(null),[T,F]=(0,ge.useState)(null),B=(0,ge.useRef)(null);(0,ge.useLayoutEffect)(()=>{if(n&&(0,V.sameOptionRows)(B.current,e))return;B.current=n?null:e;let z=w.current,U=z&&!n&&(0,V.needsOptionsGridMeasurement)(e.length,m)?(0,V.measureOptionsGrid)(z):null;F(U?(0,V.planOptionsGrid)(e.length,m,U.rowWidths,U.gridWidth):null)},[e,m,n]);let j=T??(0,V.planOptionsGrid)(e.length,m,null,null);return(0,xt.jsx)(Ft,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:h,template:j.template,maxHeight:j.maxHeight,innerRef:z=>{w.current=z},"data-aia-group":h,children:e.map((z,A)=>(0,xt.jsx)(Ht,{option:z,isHighlighted:A===a,onSelect:t,onHighlight:()=>i(A),onUnhighlight:o?()=>o(A):void 0,id:`${r}-option-${A}`,loading:n,showIcon:x,showImage:E,showCount:I,scrollHint:!n&&j.scrollHintIndices.includes(A),enterDelayMs:n?0:(0,V.optionEnterDelayMs)(A,j.cols,e.length,d)},`${h}\0${z.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
2264
+ `,document.head.appendChild(e)}var te={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",skeletonBarIn:"aia-skeletonBarIn-ZlEM0",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};var de=require("react/jsx-runtime");function Kt({option:e,isHighlighted:a,onSelect:t,onHighlight:i,onUnhighlight:o,id:r,loading:n,showIcon:p=!0,showImage:d=!0,showCount:x=!0,scrollHint:T,enterDelayMs:I=0}){let[m]=(0,fe.useState)(I),[w,E]=(0,fe.useState)(!1),B=d?(0,ae.optionImageSources)(e.image_url):[],H=B[0]??null,[Q,M]=(0,fe.useState)([]),A=B.find(O=>!Q.includes(O))??null,q=(0,fe.useMemo)(()=>!H&&p&&e.icon_svg?(0,ae.sanitizeOptionIconSvg)(e.icon_svg):null,[H,p,e.icon_svg]),K=x?(0,ae.formatOptionCount)(e.item_count):null,P=(0,fe.useRef)(void 0);(0,fe.useEffect)(()=>()=>clearTimeout(P.current),[]);let G=()=>{n||!e.is_tappable||w||(E(!0),t(e),clearTimeout(P.current),P.current=setTimeout(()=>E(!1),170))},Y=[te.item,a&&!n?te.highlighted:"",e.is_tappable?te.tappable:te.nonTappable,w?te.pressed:"",T?te.scrollHint:""].filter(Boolean).join(" ");return(0,de.jsx)("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":n?"":void 0,"data-aia-icon":q&&e.icon?e.icon:void 0,"data-aia-image":H?"":void 0,"data-aia-item-count":K!==null?e.item_count:void 0,"aria-selected":a,className:Y,style:{[ae.OPTION_ENTER_DELAY_VAR]:`${m}ms`},tabIndex:n||!e.is_tappable?-1:0,onClick:G,onKeyDown:O=>{!n&&e.is_tappable&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),G())},onMouseEnter:!n&&e.is_tappable?i:void 0,onMouseLeave:o,children:(0,de.jsxs)("span",{className:te.content,children:[H&&(0,de.jsx)("span",{className:`${te.image} magicx-aia-option-image`,"aria-hidden":"true",children:(0,de.jsx)("img",{src:A??H,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:A===null,onError:()=>{A!==null&&M(O=>[...O,A])}})}),q&&(0,de.jsx)("span",{className:`${te.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:q}}),(0,de.jsx)("span",{className:te.text,children:e.matchedText?(0,ae.highlightParts)((0,ae.optionLabel)(e),e.matchedText).map((O,se)=>O.bold?(0,de.jsx)("strong",{children:O.text},se):O.text):(0,ae.optionLabel)(e)}),e.tag&&(0,de.jsx)("span",{className:te.tag,children:e.tag}),K!==null&&(0,de.jsx)("span",{className:`${te.count} magicx-aia-option-count`,children:K})]})})}var yt=require("react/jsx-runtime");function fa(){let[e,a]=(0,be.useState)(V.isOptionsGridMobileViewport);return(0,be.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(V.OPTIONS_GRID_MOBILE_QUERY),i=()=>a(t.matches);return i(),t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function Gt({options:e,activeIndex:a,onSelect:t,onHighlight:i,onUnhighlight:o,listboxId:r,loading:n,groupKey:p="",optionsPosition:d="below",showIcons:x=!0,showImages:T=!0,showCounts:I=!0}){let m=fa(),w=(0,be.useRef)(null),[E,B]=(0,be.useState)(null),H=(0,be.useRef)(null);(0,be.useLayoutEffect)(()=>{if(n&&(0,V.sameOptionRows)(H.current,e))return;H.current=n?null:e;let M=w.current,q=M&&!n&&(0,V.needsOptionsGridMeasurement)(e.length,m)?(0,V.measureOptionsGrid)(M):null;B(q?(0,V.planOptionsGrid)(e.length,m,q.rowWidths,q.gridWidth):null)},[e,m,n]);let Q=E??(0,V.planOptionsGrid)(e.length,m,null,null);return(0,yt.jsx)(Bt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:p,template:Q.template,maxHeight:Q.maxHeight,innerRef:M=>{w.current=M},"data-aia-group":p,children:e.map((M,A)=>(0,yt.jsx)(Kt,{option:M,isHighlighted:A===a,onSelect:t,onHighlight:()=>i(A),onUnhighlight:o?()=>o(A):void 0,id:`${r}-option-${A}`,loading:n,showIcon:x,showImage:T,showCount:I,scrollHint:!n&&Q.scrollHintIndices.includes(A),enterDelayMs:n?0:(0,V.optionEnterDelayMs)(A,Q.cols,e.length,d)},`${p}\0${M.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
2262
2265
  display: flex;
2263
2266
  flex-direction: column;
2264
2267
  gap: var(--aia-stack-space, 0.5rem);
@@ -2273,7 +2276,7 @@
2273
2276
  align-items: end;
2274
2277
  }
2275
2278
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
2276
- `,document.head.appendChild(e)}var Wt=require("react/jsx-runtime");function Gt({space:e,align:a="stretch",className:t,children:i,...o}){let r=e?{"--aia-stack-space":e}:void 0;return(0,Wt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:r,...o,children:i})}var W=require("react/jsx-runtime"),ba=[159,119,164],wa=()=>{},_t=()=>{};function va(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,i]=(0,q.useState)(a);if((0,q.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>i(o.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function xa(e,a){let t=(0,q.useRef)(null);(0,q.useEffect)(()=>{let i=e.current,o=a.current;if(!i||!o)return;let r=i.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==r&&(t.current.controller.destroy(),t.current=null),r&&!t.current){t.current={grid:r,controller:(0,me.attachScrollArrow)({dropdown:i,grid:r,button:o})};return}t.current?.controller.update()}),(0,q.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function ya(e,a){let t=(0,q.useRef)(a);t.current=a;let i=(0,q.useRef)(null);(0,q.useEffect)(()=>{let o=e.current;if(o){if(!i.current){i.current=(0,me.attachViewportFit)({dropdown:o,isOpen:()=>t.current});return}i.current.update()}}),(0,q.useEffect)(()=>()=>{i.current?.destroy(),i.current=null},[])}function lt({suggestions:e,activeIndex:a,onSelect:t,onHighlight:i,onUnhighlight:o,isOpen:r,id:n,className:h,pills:d,onPillClick:x,showPills:E=!0,onSkip:I,showSkipButton:m=!0,showOptionIcons:w=!0,showOptionImages:T=!0,showOptionCounts:F=!0,skipDisabled:B=!1,activeSelected:j=!1,isLoading:z=!1,skeletonExiting:A=!1,isInputEmpty:U=!1,language:H,products:P,onProductSelect:K,onProductFocusChange:Q,productsLayout:G="row",productImageFallback:fe="image",formatType:ke="options",dateView:$=null,selectedDateIso:Ce=null,selectedDateRange:Be=null,dateRangeStart:Pe=null,onPreviousMonth:g,onNextMonth:He,optionsPosition:be="below",mode:Se}){let we=va(Se),Ie=we!==void 0,te=(0,q.useRef)(null),ne=(0,q.useRef)(null);xa(te,ne),(0,q.useEffect)(()=>{if(te.current)return(0,me.containScroll)(te.current)},[]);let l=e[0]?.options??[],f=!!(d&&d.length>0&&x),b=!!(P&&P.length>0),v=r&&(l.length>0||E&&f||z||b);ya(te,v);let k={suggestions:e,activeIndex:a,pills:d,showPills:E,showSkipButton:m,showOptionIcons:w,showOptionImages:T,showOptionCounts:F,skipDisabled:B,activeSelected:j,isLoading:z,skeletonExiting:A,isInputEmpty:U,products:P,formatType:ke,dateView:$,selectedDateIso:Ce,selectedDateRange:Be,dateRangeStart:Pe},R=(0,q.useRef)(k);v&&(R.current=k);let p=v?k:R.current,Y=(0,me.uiStringsFor)(H),ae=p.suggestions[0],ie=ae?.options??[],Ee=p.activeIndex>=0&&!!ie[p.activeIndex]?.is_tappable,Te=!!(p.pills&&p.pills.length>0&&x),Ae=p.showPills&&Te,Re=p.showPills&&!Te&&p.isLoading,Oe=Ae||Re,y=Te&&p.showSkipButton&&!p.isInputEmpty&&!!I,De=p.pills?.[0]?.text,Le=(0,me.isCalendarFormat)(p.formatType)&&p.dateView!=null,ve=ie.length>0&&!Le,u=ie.length>0&&Le&&!p.isLoading,_e=p.isLoading&&!ve&&!u,Ue=p.products??[];return(0,W.jsxs)("div",{ref:te,id:n,role:"listbox","data-aia-dropdown":"","data-options-position":be,"data-mode":we,"data-aia-loading":p.isLoading?"":void 0,"data-aia-skeleton-exiting":p.skeletonExiting?"":void 0,"data-aia-has-products":Ue.length>0?"":void 0,className:`${Ie?"magicx-aia ":""}${xe.dropdown} ${v?xe.visible:""} ${h??""}`,onMouseDown:se=>se.preventDefault(),children:[(0,W.jsxs)(Gt,{space:"8px",children:[(Oe||y)&&(0,W.jsxs)($e,{noWrap:!0,className:xe.pillBar,"data-aia-pillbar":"",children:[Oe&&(0,W.jsx)("span",{className:xe.pillScroll,"data-aia-pill-scroll":"",children:(0,W.jsx)(rt,{pills:p.pills??[],activePillIndex:0,activeSelected:p.activeSelected,onSelectPill:x??(()=>{}),rounded:!0,loading:p.isLoading})}),y&&(0,W.jsx)("button",{type:"button",tabIndex:-1,className:xe.skip,"data-aia-skip":"",disabled:p.isLoading||p.skipDisabled,"aria-label":De?`${Y.skipLabel} ${De}`:Y.skipLabel,onClick:I,children:Y.skip})]}),ve&&(0,W.jsx)(Kt,{options:ie,activeIndex:p.activeIndex,onSelect:t,onHighlight:i,onUnhighlight:o,listboxId:n,loading:p.isLoading,groupKey:ae?`${ae.parameter} ${ae.text}`:"",optionsPosition:be,showIcons:p.showOptionIcons,showImages:p.showOptionImages,showCounts:p.showOptionCounts}),u&&p.dateView&&(0,W.jsx)(Rt,{options:ie,activeIndex:p.activeIndex,listboxId:n,view:p.dateView,selection:{selectedIso:p.selectedDateIso??null,selectedRange:p.selectedDateRange??null,rangeStart:p.dateRangeStart??null},onSelect:t,onHighlight:i,onUnhighlight:o,onPreviousMonth:g??_t,onNextMonth:He??_t}),_e&&(0,W.jsx)("div",{className:xe.skeletonBars,"data-aia-skeleton-bars":"",children:ba.map(se=>(0,W.jsx)("span",{className:xe.skeletonBar,style:{width:se}},`bar-${se}`))}),(0,W.jsx)(Mt,{products:Ue,listboxId:n,onSelect:K??wa,onFocusChange:Q,focusable:v,layout:G,imageFallback:fe,strings:Y}),(0,W.jsx)(Ot,{isOptionHighlighted:Ee,isInputEmpty:p.isInputEmpty,strings:Y})]}),(0,W.jsx)("button",{ref:ne,type:"button",tabIndex:-1,className:xe.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Y.scrollArrow,"aria-hidden":"true",children:(0,W.jsx)("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:(0,W.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Fe=require("@magicx-eng/ai-autocomplete-vanilla");var qt=require("@magicx-eng/ai-autocomplete-vanilla");if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.aia-submitButton-otz7H {
2279
+ `,document.head.appendChild(e)}var _t=require("react/jsx-runtime");function Wt({space:e,align:a="stretch",className:t,children:i,...o}){let r=e?{"--aia-stack-space":e}:void 0;return(0,_t.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:r,...o,children:i})}var W=require("react/jsx-runtime"),ba=[159,119,164],wa=()=>{},qt=()=>{};function va(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)"),r=()=>i(o.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function xa(e,a){let t=(0,j.useRef)(null);(0,j.useEffect)(()=>{let i=e.current,o=a.current;if(!i||!o)return;let r=i.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==r&&(t.current.controller.destroy(),t.current=null),r&&!t.current){t.current={grid:r,controller:(0,ee.attachScrollArrow)({dropdown:i,grid:r,button:o})};return}t.current?.controller.update()}),(0,j.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function ya(e,a){let t=(0,j.useRef)(a);t.current=a;let i=(0,j.useRef)(null);(0,j.useEffect)(()=>{let o=e.current;if(o){if(!i.current){i.current=(0,ee.attachViewportFit)({dropdown:o,isOpen:()=>t.current});return}i.current.update()}}),(0,j.useEffect)(()=>()=>{i.current?.destroy(),i.current=null},[])}function lt({suggestions:e,activeIndex:a,onSelect:t,onHighlight:i,onUnhighlight:o,isOpen:r,id:n,className:p,pills:d,onPillClick:x,showPills:T=!0,onSkip:I,showSkipButton:m=!0,showOptionIcons:w=!0,showOptionImages:E=!0,showOptionCounts:B=!0,skipDisabled:H=!1,activeSelected:Q=!1,isLoading:M=!1,skeletonExiting:A=!1,isInputEmpty:q=!1,language:K,products:P,onProductSelect:G,onProductFocusChange:Y,productsLayout:O="row",productImageFallback:se="image",formatType:Pe="options",dateView:$=null,selectedDateIso:Se=null,selectedDateRange:He=null,dateRangeStart:Ie=null,onPreviousMonth:g,onNextMonth:Ke,optionsPosition:we="below",mode:Te}){let ve=va(Te),Ee=ve!==void 0,ie=(0,j.useRef)(null),le=(0,j.useRef)(null);xa(ie,le),(0,j.useEffect)(()=>{if(ie.current)return(0,ee.containScroll)(ie.current)},[]);let l=e[0]?.options??[],f=!!(d&&d.length>0&&x),b=!!(P&&P.length>0),v=r&&(l.length>0||T&&f||M||b);ya(ie,v);let k={suggestions:e,activeIndex:a,pills:d,showPills:T,showSkipButton:m,showOptionIcons:w,showOptionImages:E,showOptionCounts:B,skipDisabled:H,activeSelected:Q,isLoading:M,skeletonExiting:A,isInputEmpty:q,products:P,formatType:Pe,dateView:$,selectedDateIso:Se,selectedDateRange:He,dateRangeStart:Ie},R=(0,j.useRef)(k);v&&(R.current=k);let h=v?k:R.current,U=(0,ee.uiStringsFor)(K),oe=h.suggestions[0],ne=oe?.options??[],Ae=h.activeIndex>=0&&!!ne[h.activeIndex]?.is_tappable,xe=(0,ee.labelTraditionalAutocomplete)(h.pills??[],U.keepTyping),pe=!!(xe.length>0&&x),Re=h.showPills&&pe,Ge=h.showPills&&!pe&&h.isLoading,y=Re||Ge,Oe=pe&&(0,ee.hasSkippablePill)(xe)&&h.showSkipButton&&!h.isInputEmpty&&!!I,De=xe[0]?.text,ye=(0,ee.isCalendarFormat)(h.formatType)&&h.dateView!=null,u=ne.length>0&&!ye,We=ne.length>0&&ye&&!h.isLoading,Qe=h.isLoading&&!u&&!We,Le=h.products??[];return(0,W.jsxs)("div",{ref:ie,id:n,role:"listbox","data-aia-dropdown":"","data-options-position":we,"data-mode":ve,"data-aia-loading":h.isLoading?"":void 0,"data-aia-skeleton-exiting":h.skeletonExiting?"":void 0,"data-aia-has-products":Le.length>0?"":void 0,className:`${Ee?"magicx-aia ":""}${ke.dropdown} ${v?ke.visible:""} ${p??""}`,onMouseDown:he=>he.preventDefault(),children:[(0,W.jsxs)(Wt,{space:"8px",children:[(y||Oe)&&(0,W.jsxs)($e,{noWrap:!0,className:ke.pillBar,"data-aia-pillbar":"",children:[y&&(0,W.jsx)("span",{className:ke.pillScroll,"data-aia-pill-scroll":"",children:(0,W.jsx)(rt,{pills:xe,activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:x??(()=>{}),rounded:!0,loading:h.isLoading})}),Oe&&(0,W.jsx)("button",{type:"button",tabIndex:-1,className:ke.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":De?`${U.skipLabel} ${De}`:U.skipLabel,onClick:I,children:U.skip})]}),u&&(0,W.jsx)(Gt,{options:ne,activeIndex:h.activeIndex,onSelect:t,onHighlight:i,onUnhighlight:o,listboxId:n,loading:h.isLoading,groupKey:oe?`${oe.parameter} ${oe.text}`:"",optionsPosition:we,showIcons:h.showOptionIcons,showImages:h.showOptionImages,showCounts:h.showOptionCounts}),We&&h.dateView&&(0,W.jsx)(Ot,{options:ne,activeIndex:h.activeIndex,listboxId:n,view:h.dateView,selection:{selectedIso:h.selectedDateIso??null,selectedRange:h.selectedDateRange??null,rangeStart:h.dateRangeStart??null},onSelect:t,onHighlight:i,onUnhighlight:o,onPreviousMonth:g??qt,onNextMonth:Ke??qt}),Qe&&(0,W.jsx)("div",{className:ke.skeletonBars,"data-aia-skeleton-bars":"",children:ba.map(he=>(0,W.jsx)("span",{className:ke.skeletonBar,style:{width:he}},`bar-${he}`))}),(0,W.jsx)(Nt,{products:Le,listboxId:n,onSelect:G??wa,onFocusChange:Y,focusable:v,layout:O,imageFallback:se,strings:U}),(0,W.jsx)(Dt,{isOptionHighlighted:Ae,isInputEmpty:h.isInputEmpty,strings:U})]}),(0,W.jsx)("button",{ref:le,type:"button",tabIndex:-1,className:ke.scrollArrow,"data-aia-scroll-arrow":"","aria-label":U.scrollArrow,"aria-hidden":"true",children:(0,W.jsx)("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:(0,W.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Be=require("@magicx-eng/ai-autocomplete-vanilla");var jt=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 {
2277
2280
  flex-shrink: 0;
2278
2281
  width: 32px;
2279
2282
  height: 32px;
@@ -2326,5 +2329,5 @@
2326
2329
  );
2327
2330
  cursor: default;
2328
2331
  }
2329
- `,document.head.appendChild(e)}var Ut={submitButton:"aia-submitButton-otz7H"};var dt=require("react/jsx-runtime");function jt({disabled:e,onClick:a,label:t=(0,qt.uiStringsFor)().submit}){return(0,dt.jsx)("button",{type:"button","data-aia-submit":"",className:Ut.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),a()},"aria-label":t,children:(0,dt.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:(0,dt.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var je=require("@magicx-eng/ai-autocomplete-vanilla"),C=require("react");var yt=require("react");function Qt(e){let a=(0,yt.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),i=(0,yt.useRef)({key:"",overrides:void 0});if(i.current.key!==t){let o={};for(let r of Object.keys(e??{})){let n=(h,d,x)=>{let E=a.current?.[r];return E?E(h,d,x):[]};o[r]=n}i.current={key:t,overrides:e?o:void 0}}return{overrides:i.current.overrides,key:t}}var kt=require("react");function Yt(e){let a=(0,kt.useRef)(e);a.current=e;let t=(0,kt.useRef)(null);t.current===null&&(t.current={fetch:(o,r)=>{let n=a.current;return n?n.fetch(o,r):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 ka={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function ct({onSubmit:e,onResult:a,onError:t,optionOverrides:i,maskCompletedText:o,apiConfig:r,additionalContext:n,language:h,productId:d,visitorId:x,columns:E=2,dropdownTrigger:I,optionsPosition:m,closeDropdownOnBlur:w,showNonTappableOptions:T,showOptionIcons:F,showOptionImages:B,showOptionCounts:j,showSkipButton:z,showProducts:A,productImageFallback:U="image",onFocus:H,onBlur:P,value:K,completedParams:Q,onChange:G,onParamsChange:fe,products:ke,mapProducts:$,onProductSelect:Ce,source:Be,setCursor:Pe}){let g=(0,C.useRef)(null),[He,be]=(0,C.useState)(null),Se=(0,C.useRef)(e);Se.current=e;let we=(0,C.useRef)(a);we.current=a;let Ie=(0,C.useRef)(t);Ie.current=t;let te=(0,C.useRef)(G);te.current=G;let ne=(0,C.useRef)(fe);ne.current=fe;let l=(0,C.useRef)(H);l.current=H;let f=(0,C.useRef)(P);f.current=P;let b=(0,C.useRef)(Pe);b.current=Pe;let v=(0,C.useRef)(Ce);v.current=Ce;let k=(0,C.useRef)(x);k.current=x;let R=(0,C.useRef)(()=>{let c=k.current;return typeof c=="function"?c():c}).current,p=Yt(ke),Y=(0,C.useRef)($);Y.current=$;let ae=(0,C.useRef)((c,X)=>{let O=Y.current;return O?O(c,X):c}).current,ie=$?ae:void 0,Ee=Qt(i);(0,C.useEffect)(()=>{if(typeof document>"u")return;let c=new je.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:n,language:h,productId:d,visitorId:R,optionOverrides:Ee.overrides,maskCompletedText:o,columns:E,dropdownTrigger:I,optionsPosition:m,closeDropdownOnBlur:w,showNonTappableOptions:T,showProducts:A,source:Be,value:K,completedParams:Q,onSubmit:(...O)=>Se.current?.(...O),onResult:(...O)=>we.current?.(...O),onError:(...O)=>Ie.current?.(...O),onChange:(...O)=>te.current?.(...O),onParamsChange:(...O)=>ne.current?.(...O),onFocus:()=>l.current?.(),onBlur:()=>f.current?.(),onProductSelect:O=>v.current?.(O),setCursor:O=>b.current?.(O),products:p.config,mapProducts:ie});g.current=c,be(c.getState());let X=c.subscribe(O=>be(O));return()=>{X(),c.destroy(),g.current===c&&(g.current=null)}},[]),(0,C.useEffect)(()=>{K!==void 0&&g.current?.setValue(K)},[K]),(0,C.useEffect)(()=>{Q!==void 0&&g.current?.setCompletedParams(Q)},[Q]);let Te=JSON.stringify(r??null),Ae;try{Ae=JSON.stringify(n??null)}catch{Ae="[unstringifiable]"}(0,C.useEffect)(()=>{g.current?.update({apiConfig:r,additionalContext:n,language:h,productId:d,optionOverrides:Ee.overrides,dropdownTrigger:I,optionsPosition:m,closeDropdownOnBlur:w,showNonTappableOptions:T,showProducts:A})},[Te,Ae,h,d,Ee.key,I,m,w,T,A]);let Re=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!Re.current){Re.current=!0;return}g.current?.update({products:p.config})},[p.enabled]),(0,C.useEffect)(()=>{g.current?.update({mapProducts:ie})},[ie]);let Oe=(0,C.useRef)(null);Oe.current===null&&(Oe.current={handleTextChange:c=>g.current?.handleTextChange(c),handleKeyDown:c=>{let X="nativeEvent"in c?c.nativeEvent:c;g.current?.handleKeyDown(X)},setFocused:c=>g.current?.setFocused(c),startEditingParam:c=>g.current?.startEditingParam(c),exitEditMode:()=>g.current?.exitEditMode(),handleCaretAfterInput:c=>g.current?.handleCaretAfterInput(c),handleCaretMove:c=>g.current?.handleCaretMove(c),replaceEditingRange:c=>g.current?.replaceEditingRange(c)??!1,setActivePill:c=>g.current?.setActivePill(c),skipActivePill:()=>g.current?.skipActivePill(),removeLastParam:()=>g.current?.removeLastParam(),clearNewParamId:()=>g.current?.clearNewParamId(),reset:()=>g.current?.reset(),refreshProducts:()=>g.current?.refreshProducts(),recordSubmit:c=>g.current?.recordSubmit(c),selectOption:c=>g.current?.selectOption(c),selectProduct:c=>g.current?.selectProduct(c),setActiveDropdownIndex:c=>g.current?.setActiveDropdownIndex(c),clearHighlight:c=>g.current?.clearHighlight(c),showPreviousMonth:()=>g.current?.showPreviousMonth(),showNextMonth:()=>g.current?.showNextMonth(),handleFocus:()=>g.current?.setFocused(!0),handleBlur:()=>g.current?.setFocused(!1)});let y=Oe.current,De=(0,C.useCallback)(c=>{let X=c.target.value,ut=X.length>0&&!c.nativeEvent?.isComposing&&X[0]!==X[0].toUpperCase()?X[0].toUpperCase()+X.slice(1):X;g.current?.handleTextChange(ut)},[]),Le=(0,C.useCallback)(c=>{g.current?.handleKeyDown(c.nativeEvent)},[]),ve=g.current,u=He??ka,_e=K!==void 0?K:u.text,Ue=Q!==void 0?Q:u.completedParams,se=u.actionableSuggestions,Qe=se[0],Ke=ve?.listboxId??"",Je=u.activeDropdownIndex>=0&&ve?`${Ke}-option-${u.activeDropdownIndex}`:void 0,ze=u.editingParam,Ge=u.editingIdentified,Ye=ze?{parameter:ze.suggestionParameter,text:ze.suggestionPlaceholder,required:!0,options:ze.options}:Ge?{parameter:Ge.parameter,text:(0,je.identifiedParamLabel)(Ge.parameter),required:!0,options:[]}:null,et=u.dropdownSuggestion??Ye??Qe,ht=Ye?[Ye]:se,Ze=(0,je.dateSelectionFor)(u),tt=!ve||u.dropdownLoading;return{completedParams:Ue,skippedParams:u.skippedParams,identifiedParams:u.identifiedParams,suggestionPills:se,setActivePill:y.setActivePill,skipActivePill:y.skipActivePill,removeLastParam:y.removeLastParam,segments:u.segments,newParamId:u.newParamId,clearNewParamId:y.clearNewParamId,suggestions:u.suggestions,activeIndex:u.activeDropdownIndex,isReady:u.isReady,isLoading:tt,isFocused:u.isFocused,isDropdownOpen:u.isDropdownOpen,isActivePillSelected:u.isActivePillSelected,placeholderText:u.placeholderText,listboxId:Ke,error:u.error,products:u.products,customFields:u.customFields,selectProduct:y.selectProduct,handleTextChange:y.handleTextChange,handleKeyDown:y.handleKeyDown,setFocused:y.setFocused,editingParam:ze,editingIdentified:Ge,editingAnchor:u.editingAnchor,caretOffset:u.caretOffset,startEditingParam:y.startEditingParam,exitEditMode:y.exitEditMode,handleCaretAfterInput:y.handleCaretAfterInput,handleCaretMove:y.handleCaretMove,replaceEditingRange:y.replaceEditingRange,inputProps:{value:_e,placeholder:u.placeholderText||void 0,onChange:De,onKeyDown:Le,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":u.isDropdownOpen,"aria-activedescendant":Je,"aria-autocomplete":"list","aria-controls":Ke},reset:y.reset,refreshProducts:y.refreshProducts,recordSubmit:y.recordSubmit,dropdownProps:{suggestions:et?[{...et,options:u.dropdownOptions}]:[],activeIndex:u.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,onUnhighlight:y.clearHighlight,isOpen:u.isDropdownOpen,id:Ke,pills:ht,activeSelected:u.isActivePillSelected,onPillClick:y.setActivePill,onSkip:y.skipActivePill,showSkipButton:(z??!0)&&!ze&&!Ge,showOptionIcons:F??!0,showOptionImages:B??!0,showOptionCounts:j??!0,skipDisabled:u.inSelectionAnimation,isLoading:tt,skeletonExiting:u.skeletonExiting,isInputEmpty:_e.trim().length===0,language:h,products:u.products,productImageFallback:U,onProductSelect:y.selectProduct,onProductFocusChange:y.setFocused,formatType:u.activeFormatType,dateView:u.dateView,selectedDateIso:Ze.selectedIso,selectedDateRange:Ze.selectedRange,dateRangeStart:Ze.rangeStart,onPreviousMonth:y.showPreviousMonth,onNextMonth:y.showNextMonth,optionsPosition:m??"below"}}}var _=require("@magicx-eng/ai-autocomplete-vanilla"),S=require("react"),pt;function Ca(){if(pt!==void 0)return pt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),pt=e.contentEditable==="plaintext-only",pt}function Zt(e){let{segments:a,showChipIcons:t=!0,showChipImages:i=!0,newParamId:o,editingParam:r,editingIdentified:n,editingAnchor:h,caretOffset:d,placeholderText:x,isFocused:E,isDropdownOpen:I,listboxId:m,activeDescendantId:w,autoFocus:T,handleTextChange:F,handleKeyDown:B,handleCaretAfterInput:j,handleCaretMove:z,startEditingParam:A,replaceEditingRange:U,setFocused:H}=e,P=(0,S.useRef)(null),K=(0,S.useRef)(!1),Q=(0,S.useRef)(""),G=(0,S.useRef)(""),fe=(0,S.useRef)(null),ke=(0,S.useRef)(0);fe.current=d,(0,S.useEffect)(()=>{if(!T)return;let l=P.current;if(!l)return;document.activeElement===l?H(!0):l.focus();let f=l.ownerDocument??document,b=f.getSelection(),v=b&&b.rangeCount>0&&l.contains(b.anchorNode);if(b&&!v){let k=f.createRange();k.selectNodeContents(l),k.collapse(!0),b.removeAllRanges(),b.addRange(k)}},[T,H]),(0,S.useEffect)(()=>{let l=P.current;if(!l)return;let f=l.ownerDocument??document,b=()=>{let v=f.getSelection();if(!v||v.rangeCount===0||!v.anchorNode||!l.contains(v.anchorNode))return;let k=v.anchorNode,R=k.nodeType===Node.ELEMENT_NODE?k:k.parentElement,Y=(v.isCollapsed?R?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ae=r?.id??n?.id??null;if(Y&&Y!==ae){A(Y);return}performance.now()-ke.current<50||z((0,_.getCursorOffset)(l))};return f.addEventListener("selectionchange",b),()=>f.removeEventListener("selectionchange",b)},[r,n,A,z]),(0,S.useEffect)(()=>{let l=P.current;if(!l)return;let f=b=>{let v=(0,_.chipIdFromTap)(l,b.target);v&&(A(v),(0,_.keepCaretOnChip)(l,v))};return l.addEventListener("click",f),()=>l.removeEventListener("click",f)},[A]),(0,S.useLayoutEffect)(()=>{let l=P.current;l&&(0,_.renderEditableContent)({input:l,segments:a,newParamId:o,editingParamId:r?.id??null,placeholderText:x??"",isFocused:E,showChipIcons:t,showChipImages:i})},[a,o,r,x,E,t,i]),(0,S.useLayoutEffect)(()=>{let l=Q.current,f=o??"";if(Q.current=f,!f||f===l)return;let b=P.current;if(!b)return;b.focus();let v=fe.current??(0,_.plainTextLength)(b);(0,_.setCursorOffset)(b,v)},[o]),(0,S.useLayoutEffect)(()=>{let l=G.current,f=r?.id??"";if(G.current=f,!f||f===l||h==null)return;let b=P.current;b&&(0,_.setCursorOffset)(b,h)},[r,h]);let $=(0,S.useCallback)(()=>{if(K.current)return;let l=P.current;if(!l)return;let f=(0,_.extractPlainText)(l),v=f.length>0&&f[0]!==f[0].toUpperCase()?f[0].toUpperCase()+f.slice(1):f;F(v)},[F]),Ce=(0,S.useCallback)(()=>{ke.current=performance.now(),$();let l=P.current;l&&j((0,_.getCursorOffset)(l))},[$,j]);(0,S.useEffect)(()=>{let l=P.current;if(!l)return;let f=b=>{let v=b,k=v.inputType;if(k==="insertParagraph"||k==="insertLineBreak"||k==="insertFromDrop"){b.preventDefault();return}if(k.startsWith("insert")||k.startsWith("delete")){let R=k.startsWith("delete")?"":v.data??"";U(R)&&b.preventDefault()}};return l.addEventListener("beforeinput",f),()=>l.removeEventListener("beforeinput",f)},[U]);let Be=(0,S.useCallback)(()=>{K.current=!0},[]),Pe=(0,S.useCallback)(()=>{K.current=!1,$()},[$]),g=(0,S.useCallback)(l=>{l.preventDefault();let f=P.current;if(!f)return;let b=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let v=f.ownerDocument??document,k=v.getSelection();if(!k||k.rangeCount===0)return;let R=k.getRangeAt(0);if(!f.contains(R.startContainer))return;R.deleteContents();let p=v.createTextNode(b);R.insertNode(p),R.setStartAfter(p),R.collapse(!0),k.removeAllRanges(),k.addRange(R),$()},[$]),He=(0,S.useCallback)(l=>B(l),[B]),be=(0,S.useCallback)(()=>H(!0),[H]),Se=(0,S.useCallback)(()=>H(!1),[H]),we=(0,S.useCallback)(()=>P.current?.focus(),[]),Ie=(0,S.useCallback)(()=>P.current?.blur(),[]),te=(0,S.useCallback)(()=>{let l=P.current;return l?(0,_.extractPlainText)(l):""},[]),ne=Ca()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:ne,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":I,"aria-activedescendant":w,spellCheck:!0,enterKeyHint:"send",onInput:Ce,onKeyDown:He,onCompositionStart:Be,onCompositionEnd:Pe,onPaste:g,onFocus:be,onBlur:Se},getPlainText:te,focus:we,blur:Ie}}var re=require("react/jsx-runtime");function Pa(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Vt=(0,N.forwardRef)(function({onSubmit:a,onResult:t,onError:i,optionOverrides:o,maskCompletedText:r,className:n,apiConfig:h,additionalContext:d,language:x,productId:E,visitorId:I,columns:m,pillPlacement:w="dropdown",mode:T="auto",optionsPosition:F="below",animations:B=!0,dropdownTrigger:j,closeDropdownOnBlur:z,showNonTappableOptions:A,showOptionIcons:U=!0,showChipIcons:H=!0,showChipImages:P=!0,showOptionImages:K=!0,showOptionCounts:Q=!0,showSkipButton:G,showProducts:fe,productsLayout:ke,productImageFallback:$,autoFocus:Ce=!0,onFocus:Be,onBlur:Pe,value:g,completedParams:He,onChange:be,onParamsChange:Se,products:we,mapProducts:Ie,onProductSelect:te,submitButton:ne,resetOnSubmit:l=!0},f){let b=(0,N.useRef)(null),v=(0,N.useRef)(null),k=(0,N.useRef)(()=>{}),R=(0,N.useRef)(null),p=(0,N.useRef)(null);(0,N.useEffect)(()=>{let D=b.current;if(D)return R.current?R.current.setMode(T):R.current=new Fe.ModeController(D,T),()=>{R.current?.destroy(),R.current=null}},[T]);let Y=(0,N.useCallback)(D=>{let le=p.current?.current;le&&(le.focus(),(0,Fe.setCursorOffset)(le,D))},[]),{completedParams:ae,skippedParams:ie,identifiedParams:Ee,isReady:Te,customFields:Ae,suggestionPills:Re,setActivePill:Oe,skipActivePill:y,segments:De,newParamId:Le,clearNewParamId:ve,placeholderText:u,isFocused:_e,isDropdownOpen:Ue,isActivePillSelected:se,isLoading:Qe,activeIndex:Ke,listboxId:Je,handleTextChange:ze,handleKeyDown:Ge,setFocused:Ye,editingParam:et,editingIdentified:ht,editingAnchor:Ze,caretOffset:tt,startEditingParam:c,handleCaretAfterInput:X,handleCaretMove:O,replaceEditingRange:ut,dropdownProps:$t,reset:at,refreshProducts:Ct,recordSubmit:Pt}=ct({onSubmit:D=>k.current(D),onResult:t,onError:i,optionOverrides:o,maskCompletedText:r,apiConfig:h,additionalContext:d,language:x,productId:E,visitorId:I,columns:m,dropdownTrigger:j,optionsPosition:F,closeDropdownOnBlur:z,showNonTappableOptions:A,showOptionIcons:U,showOptionImages:K,showOptionCounts:Q,showSkipButton:G,showProducts:fe,onFocus:Be,onBlur:Pe,value:g,completedParams:He,onChange:be,onParamsChange:Se,products:we,mapProducts:Ie,onProductSelect:te,source:"full-sdk",setCursor:Y});(0,N.useEffect)(()=>{if(!Le)return;let D=window.setTimeout(()=>ve(),650);return()=>window.clearTimeout(D)},[Le,ve]);let Xt=Ke>=0?`${Je}-option-${Ke}`:void 0,{inputRef:gt,editorProps:Jt,focus:it,blur:St,getPlainText:It}=Zt({segments:De,newParamId:Le,editingParam:et,editingIdentified:ht,editingAnchor:Ze,caretOffset:tt,placeholderText:u,isFocused:_e,showChipIcons:H,showChipImages:P,isDropdownOpen:Ue,listboxId:Je,activeDescendantId:Xt,autoFocus:Ce,handleTextChange:ze,handleKeyDown:Ge,handleCaretAfterInput:X,handleCaretMove:O,startEditingParam:c,replaceEditingRange:ut,setFocused:Ye});p.current=gt,(0,N.useLayoutEffect)(()=>{let D=v.current,le=gt.current;if(!D||!le)return;let Ve=()=>{let Tt=D.firstElementChild;if(!Tt)return;let ia=Tt.getBoundingClientRect(),oa=le.getBoundingClientRect();ia.top>=oa.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};Ve();let Et=new ResizeObserver(Ve);return Et.observe(le),()=>Et.disconnect()},[De,Re.length,Qe,gt]),(0,N.useImperativeHandle)(f,()=>({focus:it,blur:St,reset:at,refreshProducts:Ct,setMode:D=>R.current?.setMode(D),skipActivePill:y}),[it,St,at,Ct,y]);let ot=!!De.length||ae.length>0,mt=(0,N.useCallback)(D=>{if(!ot)return;let le=It(),Ve=(0,Fe.buildSubmitResult)(le,ae,ie,{identifiedParams:Ee,isReady:Te,customFields:Ae});D&&Pt(Ve),a(Ve),l&&at()},[Pt,l,ot,ae,ie,Ee,Te,Ae,a,at,It]);k.current=()=>mt(!1);let ea=(0,N.useCallback)(D=>{D.target?.closest("[data-aia-pill]")||it()},[it]),ta=w==="inline",aa=w==="dropdown";return(0,re.jsxs)("div",{ref:b,className:`magicx-aia ${We.container} ${n??""}`,"data-pill-placement":w,"data-options-position":F,"data-animations":B?"on":"off","data-mode":Pa(T),children:[(0,re.jsx)(lt,{...$t,showPills:aa,productsLayout:ke,productImageFallback:$}),(0,re.jsxs)("div",{className:We.inputWrapper,"data-aia-input-wrapper":"",onClick:ea,children:[(0,re.jsxs)("div",{className:We.editorArea,"data-aia-editor":"",children:[(0,re.jsx)("div",{...Jt,className:We.input,"data-aia-input":""}),ta&&(Qe||Re.length>0)&&(0,re.jsx)("span",{ref:v,className:We.pillListContainer,"data-aia-pill-list-container":"",children:(0,re.jsx)(rt,{pills:Re,activePillIndex:0,activeSelected:se,onSelectPill:Oe,loading:Qe})})]}),ne===null?null:ne===void 0?(0,re.jsx)(jt,{disabled:!ot,onClick:()=>mt(!0),label:(0,Fe.uiStringsFor)(x).submit}):(0,re.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:We.submitSlot,onClick:D=>{ot&&(D.stopPropagation(),mt(!0))},children:ne})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
2332
+ `,document.head.appendChild(e)}var Ut={submitButton:"aia-submitButton-otz7H"};var dt=require("react/jsx-runtime");function Qt({disabled:e,onClick:a,label:t=(0,jt.uiStringsFor)().submit}){return(0,dt.jsx)("button",{type:"button","data-aia-submit":"",className:Ut.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),a()},"aria-label":t,children:(0,dt.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:(0,dt.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Fe=require("@magicx-eng/ai-autocomplete-vanilla"),C=require("react");var kt=require("react");function Yt(e){let a=(0,kt.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),i=(0,kt.useRef)({key:"",overrides:void 0});if(i.current.key!==t){let o={};for(let r of Object.keys(e??{})){let n=(p,d,x)=>{let T=a.current?.[r];return T?T(p,d,x):[]};o[r]=n}i.current={key:t,overrides:e?o:void 0}}return{overrides:i.current.overrides,key:t}}var Ct=require("react");function Zt(e){let a=(0,Ct.useRef)(e);a.current=e;let t=(0,Ct.useRef)(null);t.current===null&&(t.current={fetch:(o,r)=>{let n=a.current;return n?n.fetch(o,r):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 ka={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function ct({onSubmit:e,onResult:a,onError:t,optionOverrides:i,maskCompletedText:o,apiConfig:r,additionalContext:n,language:p,productId:d,visitorId:x,columns:T=2,dropdownTrigger:I,optionsPosition:m,closeDropdownOnBlur:w,showNonTappableOptions:E,showOptionIcons:B,showOptionImages:H,showOptionCounts:Q,showSkipButton:M,showProducts:A,productImageFallback:q="image",onFocus:K,onBlur:P,value:G,completedParams:Y,onChange:O,onParamsChange:se,products:Pe,mapProducts:$,onProductSelect:Se,source:He,setCursor:Ie}){let g=(0,C.useRef)(null),[Ke,we]=(0,C.useState)(null),Te=(0,C.useRef)(e);Te.current=e;let ve=(0,C.useRef)(a);ve.current=a;let Ee=(0,C.useRef)(t);Ee.current=t;let ie=(0,C.useRef)(O);ie.current=O;let le=(0,C.useRef)(se);le.current=se;let l=(0,C.useRef)(K);l.current=K;let f=(0,C.useRef)(P);f.current=P;let b=(0,C.useRef)(Ie);b.current=Ie;let v=(0,C.useRef)(Se);v.current=Se;let k=(0,C.useRef)(x);k.current=x;let R=(0,C.useRef)(()=>{let c=k.current;return typeof c=="function"?c():c}).current,h=Zt(Pe),U=(0,C.useRef)($);U.current=$;let oe=(0,C.useRef)((c,X)=>{let D=U.current;return D?D(c,X):c}).current,ne=$?oe:void 0,Ae=Yt(i);(0,C.useEffect)(()=>{if(typeof document>"u")return;let c=new Fe.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:n,language:p,productId:d,visitorId:R,optionOverrides:Ae.overrides,maskCompletedText:o,columns:T,dropdownTrigger:I,optionsPosition:m,closeDropdownOnBlur:w,showNonTappableOptions:E,showProducts:A,source:He,value:G,completedParams:Y,onSubmit:(...D)=>Te.current?.(...D),onResult:(...D)=>ve.current?.(...D),onError:(...D)=>Ee.current?.(...D),onChange:(...D)=>ie.current?.(...D),onParamsChange:(...D)=>le.current?.(...D),onFocus:()=>l.current?.(),onBlur:()=>f.current?.(),onProductSelect:D=>v.current?.(D),setCursor:D=>b.current?.(D),products:h.config,mapProducts:ne});g.current=c,we(c.getState());let X=c.subscribe(D=>we(D));return()=>{X(),c.destroy(),g.current===c&&(g.current=null)}},[]),(0,C.useEffect)(()=>{G!==void 0&&g.current?.setValue(G)},[G]),(0,C.useEffect)(()=>{Y!==void 0&&g.current?.setCompletedParams(Y)},[Y]);let xe=JSON.stringify(r??null),pe;try{pe=JSON.stringify(n??null)}catch{pe="[unstringifiable]"}(0,C.useEffect)(()=>{g.current?.update({apiConfig:r,additionalContext:n,language:p,productId:d,optionOverrides:Ae.overrides,dropdownTrigger:I,optionsPosition:m,closeDropdownOnBlur:w,showNonTappableOptions:E,showProducts:A})},[xe,pe,p,d,Ae.key,I,m,w,E,A]);let Re=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!Re.current){Re.current=!0;return}g.current?.update({products:h.config})},[h.enabled]),(0,C.useEffect)(()=>{g.current?.update({mapProducts:ne})},[ne]);let Ge=(0,C.useRef)(null);Ge.current===null&&(Ge.current={handleTextChange:c=>g.current?.handleTextChange(c),handleKeyDown:c=>{let X="nativeEvent"in c?c.nativeEvent:c;g.current?.handleKeyDown(X)},setFocused:c=>g.current?.setFocused(c),startEditingParam:c=>g.current?.startEditingParam(c),exitEditMode:()=>g.current?.exitEditMode(),handleCaretAfterInput:c=>g.current?.handleCaretAfterInput(c),handleCaretMove:c=>g.current?.handleCaretMove(c),replaceEditingRange:c=>g.current?.replaceEditingRange(c)??!1,setActivePill:c=>g.current?.setActivePill(c),skipActivePill:()=>g.current?.skipActivePill(),removeLastParam:()=>g.current?.removeLastParam(),clearNewParamId:()=>g.current?.clearNewParamId(),reset:()=>g.current?.reset(),refreshProducts:()=>g.current?.refreshProducts(),recordSubmit:c=>g.current?.recordSubmit(c),selectOption:c=>g.current?.selectOption(c),selectProduct:c=>g.current?.selectProduct(c),setActiveDropdownIndex:c=>g.current?.setActiveDropdownIndex(c),clearHighlight:c=>g.current?.clearHighlight(c),showPreviousMonth:()=>g.current?.showPreviousMonth(),showNextMonth:()=>g.current?.showNextMonth(),handleFocus:()=>g.current?.setFocused(!0),handleBlur:()=>g.current?.setFocused(!1)});let y=Ge.current,Oe=(0,C.useCallback)(c=>{let X=c.target.value,gt=X.length>0&&!c.nativeEvent?.isComposing&&X[0]!==X[0].toUpperCase()?X[0].toUpperCase()+X.slice(1):X;g.current?.handleTextChange(gt)},[]),De=(0,C.useCallback)(c=>{g.current?.handleKeyDown(c.nativeEvent)},[]),ye=g.current,u=Ke??ka,We=G!==void 0?G:u.text,Qe=Y!==void 0?Y:u.completedParams,Le=u.actionableSuggestions,he=Le[0],Je=(0,Fe.withoutTraditionalAutocomplete)(Le),_e=ye?.listboxId??"",ht=u.activeDropdownIndex>=0&&ye?`${_e}-option-${u.activeDropdownIndex}`:void 0,ze=u.editingParam,qe=u.editingIdentified,Ye=ze?{parameter:ze.suggestionParameter,text:ze.suggestionPlaceholder,required:!0,options:ze.options}:qe?{parameter:qe.parameter,text:(0,Fe.identifiedParamLabel)(qe.parameter),required:!0,options:[]}:null,et=u.dropdownSuggestion??Ye??he,ut=Ye?[Ye]:Le,Ze=(0,Fe.dateSelectionFor)(u),tt=!ye||u.dropdownLoading;return{completedParams:Qe,skippedParams:u.skippedParams,identifiedParams:u.identifiedParams,suggestionPills:Je,setActivePill:y.setActivePill,skipActivePill:y.skipActivePill,removeLastParam:y.removeLastParam,segments:u.segments,newParamId:u.newParamId,clearNewParamId:y.clearNewParamId,suggestions:u.suggestions,activeIndex:u.activeDropdownIndex,isReady:u.isReady,isLoading:tt,isFocused:u.isFocused,isDropdownOpen:u.isDropdownOpen,isActivePillSelected:u.isActivePillSelected,placeholderText:u.placeholderText,listboxId:_e,error:u.error,products:u.products,customFields:u.customFields,selectProduct:y.selectProduct,handleTextChange:y.handleTextChange,handleKeyDown:y.handleKeyDown,setFocused:y.setFocused,editingParam:ze,editingIdentified:qe,editingAnchor:u.editingAnchor,caretOffset:u.caretOffset,startEditingParam:y.startEditingParam,exitEditMode:y.exitEditMode,handleCaretAfterInput:y.handleCaretAfterInput,handleCaretMove:y.handleCaretMove,replaceEditingRange:y.replaceEditingRange,inputProps:{value:We,placeholder:u.placeholderText||void 0,onChange:Oe,onKeyDown:De,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":u.isDropdownOpen,"aria-activedescendant":ht,"aria-autocomplete":"list","aria-controls":_e},reset:y.reset,refreshProducts:y.refreshProducts,recordSubmit:y.recordSubmit,dropdownProps:{suggestions:et?[{...et,options:u.dropdownOptions}]:[],activeIndex:u.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,onUnhighlight:y.clearHighlight,isOpen:u.isDropdownOpen,id:_e,pills:ut,activeSelected:u.isActivePillSelected,onPillClick:y.setActivePill,onSkip:y.skipActivePill,showSkipButton:(M??!0)&&!ze&&!qe,showOptionIcons:B??!0,showOptionImages:H??!0,showOptionCounts:Q??!0,skipDisabled:u.inSelectionAnimation,isLoading:tt,skeletonExiting:u.skeletonExiting,isInputEmpty:We.trim().length===0,language:p,products:u.products,productImageFallback:q,onProductSelect:y.selectProduct,onProductFocusChange:y.setFocused,formatType:u.activeFormatType,dateView:u.dateView,selectedDateIso:Ze.selectedIso,selectedDateRange:Ze.selectedRange,dateRangeStart:Ze.rangeStart,onPreviousMonth:y.showPreviousMonth,onNextMonth:y.showNextMonth,optionsPosition:m??"below"}}}var _=require("@magicx-eng/ai-autocomplete-vanilla"),S=require("react"),pt;function Ca(){if(pt!==void 0)return pt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),pt=e.contentEditable==="plaintext-only",pt}function Vt(e){let{segments:a,showChipIcons:t=!0,showChipImages:i=!0,newParamId:o,editingParam:r,editingIdentified:n,editingAnchor:p,caretOffset:d,placeholderText:x,isFocused:T,isDropdownOpen:I,listboxId:m,activeDescendantId:w,autoFocus:E,handleTextChange:B,handleKeyDown:H,handleCaretAfterInput:Q,handleCaretMove:M,startEditingParam:A,replaceEditingRange:q,setFocused:K}=e,P=(0,S.useRef)(null),G=(0,S.useRef)(!1),Y=(0,S.useRef)(""),O=(0,S.useRef)(""),se=(0,S.useRef)(null),Pe=(0,S.useRef)(0);se.current=d,(0,S.useEffect)(()=>{if(!E)return;let l=P.current;if(!l)return;document.activeElement===l?K(!0):l.focus();let f=l.ownerDocument??document,b=f.getSelection(),v=b&&b.rangeCount>0&&l.contains(b.anchorNode);if(b&&!v){let k=f.createRange();k.selectNodeContents(l),k.collapse(!0),b.removeAllRanges(),b.addRange(k)}},[E,K]),(0,S.useEffect)(()=>{let l=P.current;if(!l)return;let f=l.ownerDocument??document,b=()=>{let v=f.getSelection();if(!v||v.rangeCount===0||!v.anchorNode||!l.contains(v.anchorNode))return;let k=v.anchorNode,R=k.nodeType===Node.ELEMENT_NODE?k:k.parentElement,U=(v.isCollapsed?R?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,oe=r?.id??n?.id??null;if(U&&U!==oe){A(U);return}performance.now()-Pe.current<50||M((0,_.getCursorOffset)(l))};return f.addEventListener("selectionchange",b),()=>f.removeEventListener("selectionchange",b)},[r,n,A,M]),(0,S.useEffect)(()=>{let l=P.current;if(!l)return;let f=b=>{let v=(0,_.chipIdFromTap)(l,b.target);v&&(A(v),(0,_.keepCaretOnChip)(l,v))};return l.addEventListener("click",f),()=>l.removeEventListener("click",f)},[A]),(0,S.useLayoutEffect)(()=>{let l=P.current;l&&(0,_.renderEditableContent)({input:l,segments:a,newParamId:o,editingParamId:r?.id??null,placeholderText:x??"",isFocused:T,showChipIcons:t,showChipImages:i})},[a,o,r,x,T,t,i]),(0,S.useLayoutEffect)(()=>{let l=Y.current,f=o??"";if(Y.current=f,!f||f===l)return;let b=P.current;if(!b)return;b.focus();let v=se.current??(0,_.plainTextLength)(b);(0,_.setCursorOffset)(b,v)},[o]),(0,S.useLayoutEffect)(()=>{let l=O.current,f=r?.id??"";if(O.current=f,!f||f===l||p==null)return;let b=P.current;b&&(0,_.setCursorOffset)(b,p)},[r,p]);let $=(0,S.useCallback)(()=>{if(G.current)return;let l=P.current;if(!l)return;let f=(0,_.extractPlainText)(l),v=f.length>0&&f[0]!==f[0].toUpperCase()?f[0].toUpperCase()+f.slice(1):f;B(v)},[B]),Se=(0,S.useCallback)(()=>{Pe.current=performance.now(),$();let l=P.current;l&&Q((0,_.getCursorOffset)(l))},[$,Q]);(0,S.useEffect)(()=>{let l=P.current;if(!l)return;let f=b=>{let v=b,k=v.inputType;if(k==="insertParagraph"||k==="insertLineBreak"||k==="insertFromDrop"){b.preventDefault();return}if(k.startsWith("insert")||k.startsWith("delete")){let R=k.startsWith("delete")?"":v.data??"";q(R)&&b.preventDefault()}};return l.addEventListener("beforeinput",f),()=>l.removeEventListener("beforeinput",f)},[q]);let He=(0,S.useCallback)(()=>{G.current=!0},[]),Ie=(0,S.useCallback)(()=>{G.current=!1,$()},[$]),g=(0,S.useCallback)(l=>{l.preventDefault();let f=P.current;if(!f)return;let b=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let v=f.ownerDocument??document,k=v.getSelection();if(!k||k.rangeCount===0)return;let R=k.getRangeAt(0);if(!f.contains(R.startContainer))return;R.deleteContents();let h=v.createTextNode(b);R.insertNode(h),R.setStartAfter(h),R.collapse(!0),k.removeAllRanges(),k.addRange(R),$()},[$]),Ke=(0,S.useCallback)(l=>H(l),[H]),we=(0,S.useCallback)(()=>K(!0),[K]),Te=(0,S.useCallback)(()=>K(!1),[K]),ve=(0,S.useCallback)(()=>P.current?.focus(),[]),Ee=(0,S.useCallback)(()=>P.current?.blur(),[]),ie=(0,S.useCallback)(()=>{let l=P.current;return l?(0,_.extractPlainText)(l):""},[]),le=Ca()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:le,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":I,"aria-activedescendant":w,spellCheck:!0,enterKeyHint:"send",onInput:Se,onKeyDown:Ke,onCompositionStart:He,onCompositionEnd:Ie,onPaste:g,onFocus:we,onBlur:Te},getPlainText:ie,focus:ve,blur:Ee}}var ce=require("react/jsx-runtime");function Pa(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var $t=(0,F.forwardRef)(function({onSubmit:a,onResult:t,onError:i,optionOverrides:o,maskCompletedText:r,className:n,apiConfig:p,additionalContext:d,language:x,productId:T,visitorId:I,columns:m,pillPlacement:w="dropdown",mode:E="auto",optionsPosition:B="below",animations:H=!0,dropdownTrigger:Q,closeDropdownOnBlur:M,showNonTappableOptions:A,showOptionIcons:q=!0,showChipIcons:K=!0,showChipImages:P=!0,showOptionImages:G=!0,showOptionCounts:Y=!0,showSkipButton:O,showProducts:se,productsLayout:Pe,productImageFallback:$,autoFocus:Se=!0,onFocus:He,onBlur:Ie,value:g,completedParams:Ke,onChange:we,onParamsChange:Te,products:ve,mapProducts:Ee,onProductSelect:ie,submitButton:le,resetOnSubmit:l=!0},f){let b=(0,F.useRef)(null),v=(0,F.useRef)(null),k=(0,F.useRef)(()=>{}),R=(0,F.useRef)(null),h=(0,F.useRef)(null);(0,F.useEffect)(()=>{let L=b.current;if(L)return R.current?R.current.setMode(E):R.current=new Be.ModeController(L,E),()=>{R.current?.destroy(),R.current=null}},[E]);let U=(0,F.useCallback)(L=>{let ue=h.current?.current;ue&&(ue.focus(),(0,Be.setCursorOffset)(ue,L))},[]),{completedParams:oe,skippedParams:ne,identifiedParams:Ae,isReady:xe,customFields:pe,suggestionPills:Re,setActivePill:Ge,skipActivePill:y,segments:Oe,newParamId:De,clearNewParamId:ye,placeholderText:u,isFocused:We,isDropdownOpen:Qe,isActivePillSelected:Le,isLoading:he,activeIndex:Je,listboxId:_e,handleTextChange:ht,handleKeyDown:ze,setFocused:qe,editingParam:Ye,editingIdentified:et,editingAnchor:ut,caretOffset:Ze,startEditingParam:tt,handleCaretAfterInput:c,handleCaretMove:X,replaceEditingRange:D,dropdownProps:gt,reset:at,refreshProducts:Pt,recordSubmit:St}=ct({onSubmit:L=>k.current(L),onResult:t,onError:i,optionOverrides:o,maskCompletedText:r,apiConfig:p,additionalContext:d,language:x,productId:T,visitorId:I,columns:m,dropdownTrigger:Q,optionsPosition:B,closeDropdownOnBlur:M,showNonTappableOptions:A,showOptionIcons:q,showOptionImages:G,showOptionCounts:Y,showSkipButton:O,showProducts:se,onFocus:He,onBlur:Ie,value:g,completedParams:Ke,onChange:we,onParamsChange:Te,products:ve,mapProducts:Ee,onProductSelect:ie,source:"full-sdk",setCursor:U});(0,F.useEffect)(()=>{if(!De)return;let L=window.setTimeout(()=>ye(),650);return()=>window.clearTimeout(L)},[De,ye]);let Xt=Je>=0?`${_e}-option-${Je}`:void 0,{inputRef:mt,editorProps:Jt,focus:it,blur:It,getPlainText:Tt}=Vt({segments:Oe,newParamId:De,editingParam:Ye,editingIdentified:et,editingAnchor:ut,caretOffset:Ze,placeholderText:u,isFocused:We,showChipIcons:K,showChipImages:P,isDropdownOpen:Qe,listboxId:_e,activeDescendantId:Xt,autoFocus:Se,handleTextChange:ht,handleKeyDown:ze,handleCaretAfterInput:c,handleCaretMove:X,startEditingParam:tt,replaceEditingRange:D,setFocused:qe});h.current=mt,(0,F.useLayoutEffect)(()=>{let L=v.current,ue=mt.current;if(!L||!ue)return;let Ve=()=>{let At=L.firstElementChild;if(!At)return;let ia=At.getBoundingClientRect(),oa=ue.getBoundingClientRect();ia.top>=oa.bottom-2?L.setAttribute("data-aia-pill-wrapped",""):L.removeAttribute("data-aia-pill-wrapped")};Ve();let Et=new ResizeObserver(Ve);return Et.observe(ue),()=>Et.disconnect()},[Oe,Re.length,he,mt]),(0,F.useImperativeHandle)(f,()=>({focus:it,blur:It,reset:at,refreshProducts:Pt,setMode:L=>R.current?.setMode(L),skipActivePill:y}),[it,It,at,Pt,y]);let ot=!!Oe.length||oe.length>0,ft=(0,F.useCallback)(L=>{if(!ot)return;let ue=Tt(),Ve=(0,Be.buildSubmitResult)(ue,oe,ne,{identifiedParams:Ae,isReady:xe,customFields:pe});L&&St(Ve),a(Ve),l&&at()},[St,l,ot,oe,ne,Ae,xe,pe,a,at,Tt]);k.current=()=>ft(!1);let ea=(0,F.useCallback)(L=>{L.target?.closest("[data-aia-pill]")||it()},[it]),ta=w==="inline",aa=w==="dropdown";return(0,ce.jsxs)("div",{ref:b,className:`magicx-aia ${Ue.container} ${n??""}`,"data-pill-placement":w,"data-options-position":B,"data-animations":H?"on":"off","data-mode":Pa(E),children:[(0,ce.jsx)(lt,{...gt,showPills:aa,productsLayout:Pe,productImageFallback:$}),(0,ce.jsxs)("div",{className:Ue.inputWrapper,"data-aia-input-wrapper":"",onClick:ea,children:[(0,ce.jsxs)("div",{className:Ue.editorArea,"data-aia-editor":"",children:[(0,ce.jsx)("div",{...Jt,className:Ue.input,"data-aia-input":""}),ta&&(he||Re.length>0)&&(0,ce.jsx)("span",{ref:v,className:Ue.pillListContainer,"data-aia-pill-list-container":"",children:(0,ce.jsx)(rt,{pills:Re,activePillIndex:0,activeSelected:Le,onSelectPill:Ge,loading:he})})]}),le===null?null:le===void 0?(0,ce.jsx)(Qt,{disabled:!ot,onClick:()=>ft(!0),label:(0,Be.uiStringsFor)(x).submit}):(0,ce.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ue.submitSlot,onClick:L=>{ot&&(L.stopPropagation(),ft(!0))},children:le})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
2330
2333
  //# sourceMappingURL=index.js.map