@magicx-eng/ai-autocomplete-react 0.26.2 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ot=Object.defineProperty;var Vt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames;var Xt=Object.prototype.hasOwnProperty;var Jt=(e,i)=>{for(var a in i)ot(e,a,{get:i[a],enumerable:!0})},ea=(e,i,a,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of Zt(i))!Xt.call(e,n)&&n!==a&&ot(e,n,{get:()=>i[n],enumerable:!(s=Vt(i,n))||s.enumerable});return e};var ta=e=>ea(ot({},"__esModule",{value:!0}),e);var ma={};Jt(ma,{AIAutocomplete:()=>Bt,AIAutocompleteDropdown:()=>Ve,DATE_RANGE_META_END:()=>l.DATE_RANGE_META_END,DATE_RANGE_META_START:()=>l.DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT:()=>l.DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX:()=>l.PRODUCT_PATH_PREFIX,WEEKDAY_LABELS:()=>l.WEEKDAY_LABELS,buildSubmitResult:()=>l.buildSubmitResult,cellDay:()=>l.cellDay,cellIso:()=>l.cellIso,dateCellMarks:()=>l.dateCellMarks,formatDate:()=>l.formatDate,formatDateRange:()=>l.formatDateRange,formatOptionCount:()=>l.formatOptionCount,isoDate:()=>l.isoDate,monthLabel:()=>l.monthLabel,optionCountLabel:()=>l.optionCountLabel,optionHasImage:()=>l.optionHasImage,optionImageSrc:()=>l.optionImageSrc,optionLabel:()=>l.optionLabel,parseDate:()=>l.parseDate,parseLooseDate:()=>l.parseLooseDate,parseLooseDateRange:()=>l.parseLooseDateRange,productFromMatchedItem:()=>l.productFromMatchedItem,productsFromCustomFields:()=>l.productsFromCustomFields,sanitizeOptionIconSvg:()=>l.sanitizeOptionIconSvg,selectedRangeFor:()=>l.selectedRangeFor,useAIAutocomplete:()=>Xe,visibleDateRange:()=>l.visibleDateRange,withSkippedParams:()=>l.withSkippedParams});module.exports=ta(ma);var l=require("@magicx-eng/ai-autocomplete-vanilla");var M=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-container-KKjFU {
1
+ "use strict";var rt=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var ea=Object.prototype.hasOwnProperty;var ta=(e,i)=>{for(var a in i)rt(e,a,{get:i[a],enumerable:!0})},aa=(e,i,a,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of Jt(i))!ea.call(e,n)&&n!==a&&rt(e,n,{get:()=>i[n],enumerable:!(r=Xt(i,n))||r.enumerable});return e};var ia=e=>aa(rt({},"__esModule",{value:!0}),e);var ba={};ta(ba,{AIAutocomplete:()=>Ht,AIAutocompleteDropdown:()=>Je,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,optionImageSrc:()=>s.optionImageSrc,optionLabel:()=>s.optionLabel,parseDate:()=>s.parseDate,parseLooseDate:()=>s.parseLooseDate,parseLooseDateRange:()=>s.parseLooseDateRange,productFromMatchedItem:()=>s.productFromMatchedItem,productsFromCustomFields:()=>s.productsFromCustomFields,sanitizeOptionIconSvg:()=>s.sanitizeOptionIconSvg,selectedRangeFor:()=>s.selectedRangeFor,useAIAutocomplete:()=>tt,visibleDateRange:()=>s.visibleDateRange,withSkippedParams:()=>s.withSkippedParams});module.exports=ia(ba);var s=require("@magicx-eng/ai-autocomplete-vanilla");var z=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 De={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};var ze=require("@magicx-eng/ai-autocomplete-vanilla"),J=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 Le={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 Be=require("@magicx-eng/ai-autocomplete-vanilla"),$=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
  *
@@ -1041,7 +1041,7 @@
1041
1041
  opacity: 0.25;
1042
1042
  }
1043
1043
  }
1044
- `,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 L=require("@magicx-eng/ai-autocomplete-vanilla"),gt=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) ---
1044
+ `,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"),vt=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) ---
1045
1045
 
1046
1046
  One of three hand-maintained copies (vanilla styles.css, this file, Angular's
1047
1047
  date-grid.component.css). Only the class-naming layer differs \u2014 the
@@ -1204,7 +1204,7 @@
1204
1204
  opacity: 0.8;
1205
1205
  background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
1206
1206
  }
1207
- `,document.head.appendChild(e)}var O={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 W=require("react/jsx-runtime"),aa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function bt({options:e,activeIndex:i,listboxId:a,view:s,selection:n,onSelect:t,onHighlight:r,onPreviousMonth:m,onNextMonth:x}){let v=(0,L.isoDate)(new Date),y=(0,L.visibleDateRange)({pendingStart:n.rangeStart,highlightedIso:(0,L.cellIso)(e[i]),selected:n.selectedRange});return(0,W.jsxs)("div",{className:O.datepicker,"data-aia-datepicker":"",children:[(0,W.jsxs)("div",{className:O.header,children:[(0,W.jsx)("button",{type:"button",tabIndex:-1,className:O.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:h=>h.preventDefault(),onClick:m,children:"\u2039"}),(0,W.jsx)("span",{className:O.month,"data-aia-date-month":"","aria-live":"polite",children:(0,L.monthLabel)(s)}),(0,W.jsx)("button",{type:"button",tabIndex:-1,className:O.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:h=>h.preventDefault(),onClick:x,children:"\u203A"})]}),(0,W.jsx)("div",{className:O.weekdays,"aria-hidden":"true",children:L.WEEKDAY_LABELS.map((h,C)=>(0,W.jsx)("span",{className:O.weekday,children:h},aa[C]))}),(0,W.jsx)("div",{className:O.grid,"data-aia-date-grid":"",children:e.map((h,C)=>(0,W.jsx)(ia,{option:h,id:`${a}-option-${C}`,index:C,isHighlighted:C===i&&h.is_tappable,isToday:(0,L.cellIso)(h)===v,isPast:(0,L.cellIso)(h)!=null&&(0,L.cellIso)(h)<v,marks:(0,L.dateCellMarks)((0,L.cellIso)(h),{selectedIso:n.selectedIso,range:y}),onSelect:t,onHighlight:r},(0,L.cellIso)(h)??`pad-${C}`))})]})}function ia({option:e,id:i,index:a,isHighlighted:s,isToday:n,isPast:t,marks:r,onSelect:m,onHighlight:x}){let[v,y]=(0,gt.useState)(!1),h=(0,L.cellDay)(e);if(h==null)return(0,W.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${O.cell} ${O.blank}`});let C=()=>{y(!0),m(e),setTimeout(()=>y(!1),170)},T=[O.cell,O.day,t?O.past:"",s?O.highlighted:"",n?O.today:"",r.inRange?O.inRange:"",r.selected?O.selected:"",v?O.pressed:""].filter(Boolean).join(" ");return(0,W.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":s,"aria-label":e.text,tabIndex:0,className:T,onClick:C,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),C())},onMouseEnter:()=>x(a),children:(0,W.jsx)("span",{className:O.number,children:h})})}var Me=require("@magicx-eng/ai-autocomplete-vanilla"),je=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 {
1207
+ `,document.head.appendChild(e)}var D={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};var W=require("react/jsx-runtime"),oa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function wt({options:e,activeIndex:i,listboxId:a,view:r,selection:n,onSelect:t,onHighlight:l,onPreviousMonth:d,onNextMonth:w}){let x=(0,M.isoDate)(new Date),v=(0,M.visibleDateRange)({pendingStart:n.rangeStart,highlightedIso:(0,M.cellIso)(e[i]),selected:n.selectedRange});return(0,W.jsxs)("div",{className:D.datepicker,"data-aia-datepicker":"",children:[(0,W.jsxs)("div",{className:D.header,children:[(0,W.jsx)("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:d,children:"\u2039"}),(0,W.jsx)("span",{className:D.month,"data-aia-date-month":"","aria-live":"polite",children:(0,M.monthLabel)(r)}),(0,W.jsx)("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:w,children:"\u203A"})]}),(0,W.jsx)("div",{className:D.weekdays,"aria-hidden":"true",children:M.WEEKDAY_LABELS.map((m,k)=>(0,W.jsx)("span",{className:D.weekday,children:m},oa[k]))}),(0,W.jsx)("div",{className:D.grid,"data-aia-date-grid":"",children:e.map((m,k)=>(0,W.jsx)(na,{option:m,id:`${a}-option-${k}`,index:k,isHighlighted:k===i&&m.is_tappable,isToday:(0,M.cellIso)(m)===x,isPast:(0,M.cellIso)(m)!=null&&(0,M.cellIso)(m)<x,marks:(0,M.dateCellMarks)((0,M.cellIso)(m),{selectedIso:n.selectedIso,range:v}),onSelect:t,onHighlight:l},(0,M.cellIso)(m)??`pad-${k}`))})]})}function na({option:e,id:i,index:a,isHighlighted:r,isToday:n,isPast:t,marks:l,onSelect:d,onHighlight:w}){let[x,v]=(0,vt.useState)(!1),m=(0,M.cellDay)(e);if(m==null)return(0,W.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${D.cell} ${D.blank}`});let k=()=>{v(!0),d(e),setTimeout(()=>v(!1),170)},T=[D.cell,D.day,t?D.past:"",r?D.highlighted:"",n?D.today:"",l.inRange?D.inRange:"",l.selected?D.selected:"",x?D.pressed:""].filter(Boolean).join(" ");return(0,W.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":r,"aria-label":e.text,tabIndex:0,className:T,onClick:k,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),k())},onMouseEnter:()=>w(a),children:(0,W.jsx)("span",{className:D.number,children:m})})}var ze=require("@magicx-eng/ai-autocomplete-vanilla"),Ze=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 {
1208
1208
  display: flex;
1209
1209
  flex-wrap: wrap;
1210
1210
  gap: var(--aia-cluster-gap, 0.5rem);
@@ -1244,7 +1244,7 @@
1244
1244
  .aia-cluster[data-justify="around"] {
1245
1245
  justify-content: space-around;
1246
1246
  }
1247
- `,document.head.appendChild(e)}var nt=require("react/jsx-runtime");function Ke({gap:e,align:i="center",justify:a="start",noWrap:s=!1,inline:n=!1,className:t,children:r,...m}){let x=e?{"--aia-cluster-gap":e}:void 0,v={className:t?`aia-cluster ${t}`:"aia-cluster","data-align":i,"data-justify":a,"data-nowrap":s||void 0,"data-inline":n||void 0,style:x,...m};return n?(0,nt.jsx)("span",{...v,children:r}):(0,nt.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
1247
+ `,document.head.appendChild(e)}var st=require("react/jsx-runtime");function We({gap:e,align:i="center",justify:a="start",noWrap:r=!1,inline:n=!1,className:t,children:l,...d}){let w=e?{"--aia-cluster-gap":e}:void 0,x={className:t?`aia-cluster ${t}`:"aia-cluster","data-align":i,"data-justify":a,"data-nowrap":r||void 0,"data-inline":n||void 0,style:w,...d};return n?(0,st.jsx)("span",{...x,children:l}):(0,st.jsx)("div",{...x,children:l})}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
1248
1248
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
1249
1249
  room above the hint/branding row so the footer doesn't butt against the last
1250
1250
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -1378,7 +1378,7 @@
1378
1378
  justify-content: flex-end;
1379
1379
  }
1380
1380
  }
1381
- `,document.head.appendChild(e)}var Ce={footer:"aia-footer-qQQ7x",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",row:"aia-row-BgZ6Q"};var ne=require("react/jsx-runtime");function vt({isOptionHighlighted:e=!1,isInputEmpty:i=!1}){let{key:a,hint:s}=(0,Me.getFooterHint)(e,i),[n,t]=(0,je.useState)(Me.ATTRIBUTION_URL);return(0,je.useEffect)(()=>{t((0,Me.buildAttributionUrl)())},[]),(0,ne.jsx)("footer",{className:Ce.footer,"data-aia-footer":"",children:(0,ne.jsxs)(Ke,{justify:"between",noWrap:!0,className:Ce.row,children:[(0,ne.jsxs)(Ke,{gap:"5px",className:Ce.hintGroup,children:[(0,ne.jsx)("kbd",{className:Ce.key,children:a}),(0,ne.jsx)("span",{className:Ce.hint,children:s})]}),(0,ne.jsxs)("a",{className:Ce.brandLink,href:n,target:"_blank",rel:"noopener noreferrer",children:[(0,ne.jsx)("span",{className:Ce.brand,children:"AI"}),(0,ne.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,
1381
+ `,document.head.appendChild(e)}var ye={footer:"aia-footer-qQQ7x",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",row:"aia-row-BgZ6Q"};var re=require("react/jsx-runtime");function xt({isOptionHighlighted:e=!1,isInputEmpty:i=!1}){let{key:a,hint:r}=(0,ze.getFooterHint)(e,i),[n,t]=(0,Ze.useState)(ze.ATTRIBUTION_URL);return(0,Ze.useEffect)(()=>{t((0,ze.buildAttributionUrl)())},[]),(0,re.jsx)("footer",{className:ye.footer,"data-aia-footer":"",children:(0,re.jsxs)(We,{justify:"between",noWrap:!0,className:ye.row,children:[(0,re.jsxs)(We,{gap:"5px",className:ye.hintGroup,children:[(0,re.jsx)("kbd",{className:ye.key,children:a}),(0,re.jsx)("span",{className:ye.hint,children:r})]}),(0,re.jsxs)("a",{className:ye.brandLink,href:n,target:"_blank",rel:"noopener noreferrer",children:[(0,re.jsx)("span",{className:ye.brand,children:"AI"}),(0,re.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,
1382
1382
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
1383
1383
  The border is kept as a 1px transparent line so the box stays the same size
1384
1384
  as it was when the outline was dashed. */
@@ -1454,7 +1454,7 @@
1454
1454
  opacity: 0;
1455
1455
  }
1456
1456
  }
1457
- `,document.head.appendChild(e)}var Re={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 xt=require("react/jsx-runtime"),rt={selected:1,first:.7,next:.4,last:.2};function wt({label:e,state:i,rounded:a,loading:s,onClick:n}){let t=[Re.pill,a?Re.rounded:"",s?Re.skeleton:""].filter(Boolean).join(" ");return(0,xt.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":s?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:t,style:{opacity:rt[i]},onMouseDown:r=>r.preventDefault(),onClick:s?void 0:n,disabled:s,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 {
1457
+ `,document.head.appendChild(e)}var Re={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 kt=require("react/jsx-runtime"),lt={selected:1,first:.7,next:.4,last:.2};function yt({label:e,state:i,rounded:a,loading:r,onClick:n}){let t=[Re.pill,a?Re.rounded:"",r?Re.skeleton:""].filter(Boolean).join(" ");return(0,kt.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":r?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:t,style:{opacity:lt[i]},onMouseDown:l=>l.preventDefault(),onClick:r?void 0:n,disabled:r,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 {
1458
1458
  position: relative;
1459
1459
  z-index: 1;
1460
1460
  pointer-events: auto;
@@ -1464,7 +1464,7 @@
1464
1464
  align-items: center;
1465
1465
  vertical-align: middle;
1466
1466
  }
1467
- `,document.head.appendChild(e)}var st={list:"aia-list-qvLqO"};var Ge=require("react/jsx-runtime"),oa=[125,69];function yt(e){return e===0?"first":e===1?"next":"last"}function Qe({pills:e,activePillIndex:i,onSelectPill:a,activeSelected:s,rounded:n,loading:t}){return t&&e.length===0?(0,Ge.jsx)("span",{className:st.list,"data-aia-pill-list-loading":"",children:oa.map((r,m)=>(0,Ge.jsx)("span",{"data-aia-pill-skeleton":"",className:`${Re.pill} ${n?Re.rounded:""} ${Re.skeleton}`,style:{width:r,opacity:rt[yt(m)]}},`skel-${r}`))}):(0,Ge.jsx)("span",{className:st.list,"data-aia-pill-list-loading":t?"":void 0,children:e.map((r,m)=>{let x=!!s&&m===i;return(0,Ge.jsx)(wt,{label:r.text,state:x?"selected":yt(m),selected:x,rounded:n,loading:t,onClick:()=>a(m)},`${r.type}-${r.text}`)})})}var kt=require("@magicx-eng/ai-autocomplete-vanilla"),Ye=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
1467
+ `,document.head.appendChild(e)}var dt={list:"aia-list-qvLqO"};var _e=require("react/jsx-runtime"),ra=[125,69];function Ct(e){return e===0?"first":e===1?"next":"last"}function $e({pills:e,activePillIndex:i,onSelectPill:a,activeSelected:r,rounded:n,loading:t}){return t&&e.length===0?(0,_e.jsx)("span",{className:dt.list,"data-aia-pill-list-loading":"",children:ra.map((l,d)=>(0,_e.jsx)("span",{"data-aia-pill-skeleton":"",className:`${Re.pill} ${n?Re.rounded:""} ${Re.skeleton}`,style:{width:l,opacity:lt[Ct(d)]}},`skel-${l}`))}):(0,_e.jsx)("span",{className:dt.list,"data-aia-pill-list-loading":t?"":void 0,children:e.map((l,d)=>{let w=!!r&&d===i;return(0,_e.jsx)(yt,{label:l.text,state:w?"selected":Ct(d),selected:w,rounded:n,loading:t,onClick:()=>a(d)},`${l.type}-${l.text}`)})})}var Ve=require("@magicx-eng/ai-autocomplete-vanilla"),Ne=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
1468
1468
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
1469
1469
  theming one package sees the same result in the other.
1470
1470
 
@@ -1579,6 +1579,16 @@
1579
1579
  the same media fill, so a card without art reads as "no photo" instead of
1580
1580
  broken. The pictogram is inlined as a data URI so the placeholder needs no
1581
1581
  network and no asset pipeline; --aia-product-placeholder-image swaps it. */
1582
+ .aia-media-RrbGe:where([data-aia-product-initial]) {
1583
+ display: flex;
1584
+ align-items: center;
1585
+ justify-content: center;
1586
+ color: var(--aia-product-title-color, var(--aia-option-color-selected, currentColor));
1587
+ font-size: 24px;
1588
+ font-weight: 600;
1589
+ line-height: 1;
1590
+ }
1591
+
1582
1592
  .aia-media-RrbGe[data-aia-product-placeholder]::after {
1583
1593
  content: "";
1584
1594
  position: absolute;
@@ -1682,7 +1692,7 @@
1682
1692
  .aia-section-Hugfg[data-aia-products-layout="list"] .aia-body-ly032 {
1683
1693
  flex: 1 1 auto;
1684
1694
  }
1685
- `,document.head.appendChild(e)}var X={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"};var U=require("react/jsx-runtime");function Ct({products:e,listboxId:i,onSelect:a,onFocusChange:s,focusable:n=!0,layout:t="row"}){let r=e.length>0,m=(0,Ye.useRef)(null);if((0,Ye.useEffect)(()=>{let v=m.current;if(!(!r||!v))return(0,kt.attachProductRowWheel)(v)},[r]),!r)return null;let x=`${i}-products-label`;return(0,U.jsxs)("section",{className:X.section,"data-aia-products":"","data-aia-products-layout":t,role:"group","aria-labelledby":x,children:[(0,U.jsx)("div",{className:X.label,id:x,"data-aia-products-label":"",children:"Products"}),(0,U.jsx)("div",{ref:m,className:X.row,"data-aia-products-row":"",children:e.map((v,y)=>(0,U.jsx)(na,{product:v,id:`${i}-product-${y}`,onSelect:a,onFocusChange:s,focusable:n},v.id))})]})}function na({product:e,id:i,onSelect:a,onFocusChange:s,focusable:n}){let t=r=>{r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||r.button!==0||(r.preventDefault(),a(e))};return(0,U.jsxs)("a",{id:i,className:X.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:n?0:-1,onClick:t,onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),a(e))},onFocus:()=>s?.(!0),onBlur:r=>{r.relatedTarget?.closest("[data-aia-dropdown]")||s?.(!1)},children:[(0,U.jsx)("span",{className:X.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?(0,U.jsx)("img",{className:X.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),(0,U.jsxs)("span",{className:X.body,children:[e.vendor?(0,U.jsx)("span",{className:X.vendor,children:e.vendor}):null,(0,U.jsx)("span",{className:X.title,children:e.title}),e.price?(0,U.jsx)("span",{className:X.price,children:e.price}):null]})]})}var K=require("@magicx-eng/ai-autocomplete-vanilla"),de=require("react");var Pt=require("@magicx-eng/ai-autocomplete-vanilla"),$e=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 {
1695
+ `,document.head.appendChild(e)}var Z={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"};var _=require("react/jsx-runtime");function Pt({products:e,listboxId:i,onSelect:a,onFocusChange:r,focusable:n=!0,layout:t="row",imageFallback:l="image"}){let d=e.length>0,w=(0,Ne.useRef)(null);if((0,Ne.useEffect)(()=>{let v=w.current;if(!(!d||!v))return(0,Ve.attachProductRowWheel)(v)},[d]),!d)return null;let x=`${i}-products-label`;return(0,_.jsxs)("section",{className:Z.section,"data-aia-products":"","data-aia-products-layout":t,role:"group","aria-labelledby":x,children:[(0,_.jsx)("div",{className:Z.label,id:x,"data-aia-products-label":"",children:"Products"}),(0,_.jsx)("div",{ref:w,className:Z.row,"data-aia-products-row":"",children:e.map((v,m)=>(0,_.jsx)(sa,{product:v,id:`${i}-product-${m}`,onSelect:a,onFocusChange:r,focusable:n,imageFallback:l},v.id))})]})}function sa({product:e,id:i,onSelect:a,onFocusChange:r,focusable:n,imageFallback:t}){let l=d=>{d.metaKey||d.ctrlKey||d.shiftKey||d.altKey||d.button!==0||(d.preventDefault(),a(e))};return(0,_.jsxs)("a",{id:i,className:Z.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:n?0:-1,onClick:l,onKeyDown:d=>{d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),a(e))},onFocus:()=>r?.(!0),onBlur:d=>{d.relatedTarget?.closest("[data-aia-dropdown]")||r?.(!1)},children:[(0,_.jsx)(la,{src:e.imageUrl?.trim(),title:e.title,fallback:t},e.imageUrl?.trim()??""),(0,_.jsxs)("span",{className:Z.body,children:[e.vendor?(0,_.jsx)("span",{className:Z.vendor,children:e.vendor}):null,(0,_.jsx)("span",{className:Z.title,children:e.title}),e.price?(0,_.jsx)("span",{className:Z.price,children:e.price}):null]})]})}function la({src:e,title:i,fallback:a}){let[r,n]=(0,Ne.useState)(!1),t=!!e&&!r,l=!t&&a==="initial";return(0,_.jsxs)("span",{className:Z.media,"aria-hidden":"true","data-aia-product-placeholder":!t&&!l?"":void 0,"data-aia-product-initial":l?"":void 0,children:[t?(0,_.jsx)("img",{className:Z.image,src:e,alt:"",loading:"lazy",decoding:"async",onError:()=>n(!0)}):null,l?(0,Ve.productInitial)(i):null]})}var G=require("@magicx-eng/ai-autocomplete-vanilla"),ce=require("react");var St=require("@magicx-eng/ai-autocomplete-vanilla"),Xe=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 {
1686
1696
  display: grid;
1687
1697
  grid-template-columns: repeat(
1688
1698
  auto-fit,
@@ -1715,7 +1725,7 @@
1715
1725
  background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
1716
1726
  border-radius: 3px;
1717
1727
  }
1718
- `,document.head.appendChild(e)}var It=require("react/jsx-runtime");function St({min:e="16rem",max:i,gap:a,scroll:s=!1,maxHeight:n,scrollResetKey:t,cols:r,template:m,innerRef:x,className:v,children:y,...h}){let C=(0,$e.useRef)(null);(0,$e.useLayoutEffect)(()=>{if(t===void 0)return;let k=C.current;k&&(k.scrollTop=0)},[t]);let T={"--aia-grid-min":e};return i&&(T["--aia-grid-max"]=i),a&&(T["--aia-grid-gap"]=a),n&&(T["--aia-grid-max-height"]=n),r&&(T.gridTemplateColumns=(0,Pt.optionsGridTemplateColumns)(r)),m&&(T.gridTemplateColumns=m),(0,It.jsx)("div",{ref:k=>{C.current=k,x?.(k)},className:v?`aia-grid ${v}`:"aia-grid","data-scroll":s||void 0,style:T,...h,children:y})}var le=require("@magicx-eng/ai-autocomplete-vanilla"),se=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 {
1728
+ `,document.head.appendChild(e)}var Et=require("react/jsx-runtime");function It({min:e="16rem",max:i,gap:a,scroll:r=!1,maxHeight:n,scrollResetKey:t,cols:l,template:d,innerRef:w,className:x,children:v,...m}){let k=(0,Xe.useRef)(null);(0,Xe.useLayoutEffect)(()=>{if(t===void 0)return;let y=k.current;y&&(y.scrollTop=0)},[t]);let T={"--aia-grid-min":e};return i&&(T["--aia-grid-max"]=i),a&&(T["--aia-grid-gap"]=a),n&&(T["--aia-grid-max-height"]=n),l&&(T.gridTemplateColumns=(0,St.optionsGridTemplateColumns)(l)),d&&(T.gridTemplateColumns=d),(0,Et.jsx)("div",{ref:y=>{k.current=y,w?.(y)},className:x?`aia-grid ${x}`:"aia-grid","data-scroll":r||void 0,style:T,...m,children:v})}var de=require("@magicx-eng/ai-autocomplete-vanilla"),le=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 {
1719
1729
  position: relative;
1720
1730
  /* Clip, not visible: the entrance rise below runs on the inner content,
1721
1731
  and a transformed box extends its scroll container's scrollable area.
@@ -2033,6 +2043,36 @@
2033
2043
  --aia-option-row-height: calc(var(--aia-option-image-size, 40px) + 16px);
2034
2044
  }
2035
2045
 
2046
+ /* A row without a picture, in a grid where other rows have one, lines up
2047
+ with them: it becomes the same centred flex row, its icon sits centred in a
2048
+ tile-sized box, and a row with no icon either is indented by the tile and
2049
+ its gap, so every option's text starts at the same x. Grids with no
2050
+ pictures keep the inline icon and hanging indent above. The text is left
2051
+ to size itself: letting it grow here would out-rank the loading-bar rule
2052
+ that makes a skeleton bar hug its text. */
2053
+ [data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)) {
2054
+ display: flex;
2055
+ flex: 1 1 auto;
2056
+ align-items: center;
2057
+ gap: var(--aia-option-image-gap, 12px);
2058
+ min-width: 0;
2059
+ min-height: var(--aia-option-image-size, 40px);
2060
+ padding-left: 0;
2061
+ text-indent: 0;
2062
+ }
2063
+
2064
+ [data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)) .aia-icon-Qw938 {
2065
+ flex: 0 0 auto;
2066
+ justify-content: center;
2067
+ width: var(--aia-option-image-size, 40px);
2068
+ height: var(--aia-option-image-size, 40px);
2069
+ margin-right: 0;
2070
+ }
2071
+
2072
+ [data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)):not(:has(.aia-icon-Qw938)) {
2073
+ padding-left: calc(var(--aia-option-image-size, 40px) + var(--aia-option-image-gap, 12px));
2074
+ }
2075
+
2036
2076
  @keyframes aia-skeletonPulse-plvdD {
2037
2077
  0%,
2038
2078
  100% {
@@ -2075,7 +2115,7 @@
2075
2115
  opacity: 0;
2076
2116
  }
2077
2117
  }
2078
- `,document.head.appendChild(e)}var j={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",skeletonBarIn:"aia-skeletonBarIn-ZlEM0",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};var re=require("react/jsx-runtime");function Et({option:e,isHighlighted:i,onSelect:a,onHighlight:s,id:n,loading:t,showIcon:r=!0,showImage:m=!0,showCount:x=!0,scrollHint:v,enterDelayMs:y=0}){let[h]=(0,se.useState)(y),[C,T]=(0,se.useState)(!1),k=m?(0,le.optionImageSrc)(e.image_url):null,[_,B]=(0,se.useState)(null),E=(0,se.useMemo)(()=>!k&&r&&e.icon_svg?(0,le.sanitizeOptionIconSvg)(e.icon_svg):null,[k,r,e.icon_svg]),D=x?(0,le.formatOptionCount)(e.item_count):null,A=(0,se.useRef)(void 0);(0,se.useEffect)(()=>()=>clearTimeout(A.current),[]);let z=()=>{t||!e.is_tappable||C||(T(!0),a(e),clearTimeout(A.current),A.current=setTimeout(()=>T(!1),170))},F=[j.item,i&&!t?j.highlighted:"",e.is_tappable?j.tappable:j.nonTappable,C?j.pressed:"",v?j.scrollHint:""].filter(Boolean).join(" ");return(0,re.jsx)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":t?"":void 0,"data-aia-icon":E&&e.icon?e.icon:void 0,"data-aia-image":k?"":void 0,"data-aia-item-count":D!==null?e.item_count:void 0,"aria-selected":i,className:F,style:{[le.OPTION_ENTER_DELAY_VAR]:`${h}ms`},tabIndex:t||!e.is_tappable?-1:0,onClick:z,onKeyDown:S=>{!t&&e.is_tappable&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),z())},onMouseEnter:!t&&e.is_tappable?s:void 0,children:(0,re.jsxs)("span",{className:j.content,children:[k&&(0,re.jsx)("span",{className:`${j.image} magicx-aia-option-image`,"aria-hidden":"true",children:(0,re.jsx)("img",{src:k,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:_===k,onError:()=>B(k)})}),E&&(0,re.jsx)("span",{className:`${j.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:E}}),(0,re.jsx)("span",{className:j.text,children:(0,le.optionLabel)(e)}),e.tag&&(0,re.jsx)("span",{className:j.tag,children:e.tag}),D!==null&&(0,re.jsx)("span",{className:`${j.count} magicx-aia-option-count`,children:D})]})})}var lt=require("react/jsx-runtime");function ra(){let[e,i]=(0,de.useState)(K.isOptionsGridMobileViewport);return(0,de.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(K.OPTIONS_GRID_MOBILE_QUERY),s=()=>i(a.matches);return s(),a.addEventListener("change",s),()=>a.removeEventListener("change",s)},[]),e}function Tt({options:e,activeIndex:i,onSelect:a,onHighlight:s,listboxId:n,loading:t,groupKey:r="",optionsPosition:m="below",showIcons:x=!0,showImages:v=!0,showCounts:y=!0}){let h=ra(),C=(0,de.useRef)(null),[T,k]=(0,de.useState)(null),_=(0,de.useRef)(null);(0,de.useLayoutEffect)(()=>{if(t&&(0,K.sameOptionRows)(_.current,e))return;_.current=t?null:e;let E=C.current,A=E&&!t&&(0,K.needsOptionsGridMeasurement)(e.length,h)?(0,K.measureOptionsGrid)(E):null;k(A?(0,K.planOptionsGrid)(e.length,h,A.rowWidths,A.gridWidth):null)},[e,h,t]);let B=T??(0,K.planOptionsGrid)(e.length,h,null,null);return(0,lt.jsx)(St,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:r,template:B.template,maxHeight:B.maxHeight,innerRef:E=>{C.current=E},"data-aia-group":r,children:e.map((E,D)=>(0,lt.jsx)(Et,{option:E,isHighlighted:D===i,onSelect:a,onHighlight:()=>s(D),id:`${n}-option-${D}`,loading:t,showIcon:x,showImage:v,showCount:y,scrollHint:!t&&B.scrollHintIndices.includes(D),enterDelayMs:t?0:(0,K.optionEnterDelayMs)(D,B.cols,e.length,m)},`${r}\0${E.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
2118
+ `,document.head.appendChild(e)}var U={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 se=require("react/jsx-runtime");function Tt({option:e,isHighlighted:i,onSelect:a,onHighlight:r,id:n,loading:t,showIcon:l=!0,showImage:d=!0,showCount:w=!0,scrollHint:x,enterDelayMs:v=0}){let[m]=(0,le.useState)(v),[k,T]=(0,le.useState)(!1),y=d?(0,de.optionImageSrc)(e.image_url):null,[q,H]=(0,le.useState)(null),A=(0,le.useMemo)(()=>!y&&l&&e.icon_svg?(0,de.sanitizeOptionIconSvg)(e.icon_svg):null,[y,l,e.icon_svg]),O=w?(0,de.formatOptionCount)(e.item_count):null,F=(0,le.useRef)(void 0);(0,le.useEffect)(()=>()=>clearTimeout(F.current),[]);let N=()=>{t||!e.is_tappable||k||(T(!0),a(e),clearTimeout(F.current),F.current=setTimeout(()=>T(!1),170))},L=[U.item,i&&!t?U.highlighted:"",e.is_tappable?U.tappable:U.nonTappable,k?U.pressed:"",x?U.scrollHint:""].filter(Boolean).join(" ");return(0,se.jsx)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":t?"":void 0,"data-aia-icon":A&&e.icon?e.icon:void 0,"data-aia-image":y?"":void 0,"data-aia-item-count":O!==null?e.item_count:void 0,"aria-selected":i,className:L,style:{[de.OPTION_ENTER_DELAY_VAR]:`${m}ms`},tabIndex:t||!e.is_tappable?-1:0,onClick:N,onKeyDown:S=>{!t&&e.is_tappable&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),N())},onMouseEnter:!t&&e.is_tappable?r:void 0,children:(0,se.jsxs)("span",{className:U.content,children:[y&&(0,se.jsx)("span",{className:`${U.image} magicx-aia-option-image`,"aria-hidden":"true",children:(0,se.jsx)("img",{src:y,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:q===y,onError:()=>H(y)})}),A&&(0,se.jsx)("span",{className:`${U.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:A}}),(0,se.jsx)("span",{className:U.text,children:(0,de.optionLabel)(e)}),e.tag&&(0,se.jsx)("span",{className:U.tag,children:e.tag}),O!==null&&(0,se.jsx)("span",{className:`${U.count} magicx-aia-option-count`,children:O})]})})}var ct=require("react/jsx-runtime");function da(){let[e,i]=(0,ce.useState)(G.isOptionsGridMobileViewport);return(0,ce.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(G.OPTIONS_GRID_MOBILE_QUERY),r=()=>i(a.matches);return r(),a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[]),e}function At({options:e,activeIndex:i,onSelect:a,onHighlight:r,listboxId:n,loading:t,groupKey:l="",optionsPosition:d="below",showIcons:w=!0,showImages:x=!0,showCounts:v=!0}){let m=da(),k=(0,ce.useRef)(null),[T,y]=(0,ce.useState)(null),q=(0,ce.useRef)(null);(0,ce.useLayoutEffect)(()=>{if(t&&(0,G.sameOptionRows)(q.current,e))return;q.current=t?null:e;let A=k.current,F=A&&!t&&(0,G.needsOptionsGridMeasurement)(e.length,m)?(0,G.measureOptionsGrid)(A):null;y(F?(0,G.planOptionsGrid)(e.length,m,F.rowWidths,F.gridWidth):null)},[e,m,t]);let H=T??(0,G.planOptionsGrid)(e.length,m,null,null);return(0,ct.jsx)(It,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:l,template:H.template,maxHeight:H.maxHeight,innerRef:A=>{k.current=A},"data-aia-group":l,children:e.map((A,O)=>(0,ct.jsx)(Tt,{option:A,isHighlighted:O===i,onSelect:a,onHighlight:()=>r(O),id:`${n}-option-${O}`,loading:t,showIcon:w,showImage:x,showCount:v,scrollHint:!t&&H.scrollHintIndices.includes(O),enterDelayMs:t?0:(0,G.optionEnterDelayMs)(O,H.cols,e.length,d)},`${l}\0${A.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
2079
2119
  display: flex;
2080
2120
  flex-direction: column;
2081
2121
  gap: var(--aia-stack-space, 0.5rem);
@@ -2090,7 +2130,7 @@
2090
2130
  align-items: end;
2091
2131
  }
2092
2132
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
2093
- `,document.head.appendChild(e)}var Rt=require("react/jsx-runtime");function At({space:e,align:i="stretch",className:a,children:s,...n}){let t=e?{"--aia-stack-space":e}:void 0;return(0,Rt.jsx)("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":i,style:t,...n,children:s})}var H=require("react/jsx-runtime"),sa=[159,119,164],la=()=>{},Dt=()=>{};function da(e){let i=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,s]=(0,J.useState)(i);if((0,J.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),t=()=>s(n.matches);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function ca(e,i){let a=(0,J.useRef)(null);(0,J.useEffect)(()=>{let s=e.current,n=i.current;if(!s||!n)return;let t=s.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==t&&(a.current.controller.destroy(),a.current=null),t&&!a.current){a.current={grid:t,controller:(0,ze.attachScrollArrow)({dropdown:s,grid:t,button:n})};return}a.current?.controller.update()}),(0,J.useEffect)(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function Ve({suggestions:e,activeIndex:i,onSelect:a,onHighlight:s,isOpen:n,id:t,className:r,pills:m,onPillClick:x,showPills:v=!0,onSkip:y,showSkipButton:h=!0,showOptionIcons:C=!0,showOptionImages:T=!0,showOptionCounts:k=!0,skipDisabled:_=!1,activeSelected:B=!1,isLoading:E=!1,skeletonExiting:D=!1,isInputEmpty:A=!1,products:z,onProductSelect:F,onProductFocusChange:S,productsLayout:ce="row",formatType:pe="options",dateView:Pe=null,selectedDateIso:he=null,selectedDateRange:u=null,dateRangeStart:Y=null,onPreviousMonth:Se,onNextMonth:Ie,optionsPosition:ue="below",mode:Ee}){let me=da(Ee),te=me!==void 0,fe=(0,J.useRef)(null),ae=(0,J.useRef)(null);ca(fe,ae);let ge=e[0]?.options??[],be=!!(m&&m.length>0&&x),G=!!(z&&z.length>0),d=n&&(ge.length>0||v&&be||E||G),f={suggestions:e,activeIndex:i,pills:m,showPills:v,showSkipButton:h,showOptionIcons:C,showOptionImages:T,showOptionCounts:k,skipDisabled:_,activeSelected:B,isLoading:E,skeletonExiting:D,isInputEmpty:A,products:z,formatType:pe,dateView:Pe,selectedDateIso:he,selectedDateRange:u,dateRangeStart:Y},g=(0,J.useRef)(f);d&&(g.current=f);let o=d?f:g.current,w=o.suggestions[0],c=w?.options??[],ie=o.activeIndex>=0&&!!c[o.activeIndex]?.is_tappable,q=!!(o.pills&&o.pills.length>0&&x),ve=o.showPills&&q,p=o.showPills&&!q&&o.isLoading,we=ve||p,Te=q&&o.showSkipButton&&!o.isInputEmpty&&!!y,xe=o.pills?.[0]?.text,Oe=(0,ze.isCalendarFormat)(o.formatType)&&o.dateView!=null,ye=c.length>0&&!Oe,Le=c.length>0&&Oe&&!o.isLoading,oe=o.isLoading&&!ye&&!Le,$=o.products??[];return(0,H.jsxs)("div",{ref:fe,id:t,role:"listbox","data-aia-dropdown":"","data-options-position":ue,"data-mode":me,"data-aia-loading":o.isLoading?"":void 0,"data-aia-skeleton-exiting":o.skeletonExiting?"":void 0,"data-aia-has-products":$.length>0?"":void 0,className:`${te?"magicx-aia ":""}${ke.dropdown} ${d?ke.visible:""} ${r??""}`,onMouseDown:Z=>Z.preventDefault(),children:[(0,H.jsxs)(At,{space:"8px",children:[(we||Te)&&(0,H.jsxs)(Ke,{noWrap:!0,className:ke.pillBar,"data-aia-pillbar":"",children:[we&&(0,H.jsx)("span",{className:ke.pillScroll,"data-aia-pill-scroll":"",children:(0,H.jsx)(Qe,{pills:o.pills??[],activePillIndex:0,activeSelected:o.activeSelected,onSelectPill:x??(()=>{}),rounded:!0,loading:o.isLoading})}),Te&&(0,H.jsx)("button",{type:"button",tabIndex:-1,className:ke.skip,"data-aia-skip":"",disabled:o.isLoading||o.skipDisabled,"aria-label":xe?`Skip ${xe}`:"Skip",onClick:y,children:"skip"})]}),ye&&(0,H.jsx)(Tt,{options:c,activeIndex:o.activeIndex,onSelect:a,onHighlight:s,listboxId:t,loading:o.isLoading,groupKey:w?`${w.type} ${w.text}`:"",optionsPosition:ue,showIcons:o.showOptionIcons,showImages:o.showOptionImages,showCounts:o.showOptionCounts}),Le&&o.dateView&&(0,H.jsx)(bt,{options:c,activeIndex:o.activeIndex,listboxId:t,view:o.dateView,selection:{selectedIso:o.selectedDateIso??null,selectedRange:o.selectedDateRange??null,rangeStart:o.dateRangeStart??null},onSelect:a,onHighlight:s,onPreviousMonth:Se??Dt,onNextMonth:Ie??Dt}),oe&&(0,H.jsx)("div",{className:ke.skeletonBars,"data-aia-skeleton-bars":"",children:sa.map(Z=>(0,H.jsx)("span",{className:ke.skeletonBar,style:{width:Z}},`bar-${Z}`))}),(0,H.jsx)(Ct,{products:$,listboxId:t,onSelect:F??la,onFocusChange:S,focusable:d,layout:ce}),(0,H.jsx)(vt,{isOptionHighlighted:ie,isInputEmpty:o.isInputEmpty})]}),(0,H.jsx)("button",{ref:ae,type:"button",tabIndex:-1,className:ke.scrollArrow,"data-aia-scroll-arrow":"","aria-label":ze.SCROLL_ARROW_LABEL,"aria-hidden":"true",children:(0,H.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,H.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Be=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 {
2133
+ `,document.head.appendChild(e)}var Ot=require("react/jsx-runtime");function Rt({space:e,align:i="stretch",className:a,children:r,...n}){let t=e?{"--aia-stack-space":e}:void 0;return(0,Ot.jsx)("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":i,style:t,...n,children:r})}var K=require("react/jsx-runtime"),ca=[159,119,164],pa=()=>{},Dt=()=>{};function ha(e){let i=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,r]=(0,$.useState)(i);if((0,$.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),t=()=>r(n.matches);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function ua(e,i){let a=(0,$.useRef)(null);(0,$.useEffect)(()=>{let r=e.current,n=i.current;if(!r||!n)return;let t=r.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==t&&(a.current.controller.destroy(),a.current=null),t&&!a.current){a.current={grid:t,controller:(0,Be.attachScrollArrow)({dropdown:r,grid:t,button:n})};return}a.current?.controller.update()}),(0,$.useEffect)(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function Je({suggestions:e,activeIndex:i,onSelect:a,onHighlight:r,isOpen:n,id:t,className:l,pills:d,onPillClick:w,showPills:x=!0,onSkip:v,showSkipButton:m=!0,showOptionIcons:k=!0,showOptionImages:T=!0,showOptionCounts:y=!0,skipDisabled:q=!1,activeSelected:H=!1,isLoading:A=!1,skeletonExiting:O=!1,isInputEmpty:F=!1,products:N,onProductSelect:L,onProductFocusChange:S,productsLayout:X="row",productImageFallback:ke="image",formatType:pe="options",dateView:Ce=null,selectedDateIso:he=null,selectedDateRange:h=null,dateRangeStart:Oe=null,onPreviousMonth:Pe,onNextMonth:Se,optionsPosition:ue="below",mode:Ie}){let me=ha(Ie),J=me!==void 0,ee=(0,$.useRef)(null),ge=(0,$.useRef)(null);ua(ee,ge);let fe=e[0]?.options??[],be=!!(d&&d.length>0&&w),c=!!(N&&N.length>0),p=n&&(fe.length>0||x&&be||A||c),b={suggestions:e,activeIndex:i,pills:d,showPills:x,showSkipButton:m,showOptionIcons:k,showOptionImages:T,showOptionCounts:y,skipDisabled:q,activeSelected:H,isLoading:A,skeletonExiting:O,isInputEmpty:F,products:N,formatType:pe,dateView:Ce,selectedDateIso:he,selectedDateRange:h,dateRangeStart:Oe},C=(0,$.useRef)(b);p&&(C.current=b);let o=p?b:C.current,E=o.suggestions[0],g=E?.options??[],te=o.activeIndex>=0&&!!g[o.activeIndex]?.is_tappable,ae=!!(o.pills&&o.pills.length>0&&w),ve=o.showPills&&ae,u=o.showPills&&!ae&&o.isLoading,Ee=ve||u,Te=ae&&o.showSkipButton&&!o.isInputEmpty&&!!v,ie=o.pills?.[0]?.text,De=(0,Be.isCalendarFormat)(o.formatType)&&o.dateView!=null,we=g.length>0&&!De,Me=g.length>0&&De&&!o.isLoading,oe=o.isLoading&&!we&&!Me,ne=o.products??[];return(0,K.jsxs)("div",{ref:ee,id:t,role:"listbox","data-aia-dropdown":"","data-options-position":ue,"data-mode":me,"data-aia-loading":o.isLoading?"":void 0,"data-aia-skeleton-exiting":o.skeletonExiting?"":void 0,"data-aia-has-products":ne.length>0?"":void 0,className:`${J?"magicx-aia ":""}${xe.dropdown} ${p?xe.visible:""} ${l??""}`,onMouseDown:Y=>Y.preventDefault(),children:[(0,K.jsxs)(Rt,{space:"8px",children:[(Ee||Te)&&(0,K.jsxs)(We,{noWrap:!0,className:xe.pillBar,"data-aia-pillbar":"",children:[Ee&&(0,K.jsx)("span",{className:xe.pillScroll,"data-aia-pill-scroll":"",children:(0,K.jsx)($e,{pills:o.pills??[],activePillIndex:0,activeSelected:o.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:o.isLoading})}),Te&&(0,K.jsx)("button",{type:"button",tabIndex:-1,className:xe.skip,"data-aia-skip":"",disabled:o.isLoading||o.skipDisabled,"aria-label":ie?`Skip ${ie}`:"Skip",onClick:v,children:"skip"})]}),we&&(0,K.jsx)(At,{options:g,activeIndex:o.activeIndex,onSelect:a,onHighlight:r,listboxId:t,loading:o.isLoading,groupKey:E?`${E.type} ${E.text}`:"",optionsPosition:ue,showIcons:o.showOptionIcons,showImages:o.showOptionImages,showCounts:o.showOptionCounts}),Me&&o.dateView&&(0,K.jsx)(wt,{options:g,activeIndex:o.activeIndex,listboxId:t,view:o.dateView,selection:{selectedIso:o.selectedDateIso??null,selectedRange:o.selectedDateRange??null,rangeStart:o.dateRangeStart??null},onSelect:a,onHighlight:r,onPreviousMonth:Pe??Dt,onNextMonth:Se??Dt}),oe&&(0,K.jsx)("div",{className:xe.skeletonBars,"data-aia-skeleton-bars":"",children:ca.map(Y=>(0,K.jsx)("span",{className:xe.skeletonBar,style:{width:Y}},`bar-${Y}`))}),(0,K.jsx)(Pt,{products:ne,listboxId:t,onSelect:L??pa,onFocusChange:S,focusable:p,layout:X,imageFallback:ke}),(0,K.jsx)(xt,{isOptionHighlighted:te,isInputEmpty:o.isInputEmpty})]}),(0,K.jsx)("button",{ref:ge,type:"button",tabIndex:-1,className:xe.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Be.SCROLL_ARROW_LABEL,"aria-hidden":"true",children:(0,K.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,K.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Fe=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 {
2094
2134
  flex-shrink: 0;
2095
2135
  width: 32px;
2096
2136
  height: 32px;
@@ -2143,5 +2183,5 @@
2143
2183
  );
2144
2184
  cursor: default;
2145
2185
  }
2146
- `,document.head.appendChild(e)}var Ot={submitButton:"aia-submitButton-otz7H"};var Ze=require("react/jsx-runtime");function Lt({disabled:e,onClick:i}){return(0,Ze.jsx)("button",{type:"button","data-aia-submit":"",className:Ot.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),i()},"aria-label":"Submit",children:(0,Ze.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Ze.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ne=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react");var dt=require("react");function Mt(e){let i=(0,dt.useRef)(e);i.current=e;let a=Object.keys(e??{}).sort().join("\0"),s=(0,dt.useRef)({key:"",overrides:void 0});if(s.current.key!==a){let n={};for(let t of Object.keys(e??{})){let r=(m,x,v)=>{let y=i.current?.[t];return y?y(m,x,v):[]};n[t]=r}s.current={key:a,overrides:e?n:void 0}}return{overrides:s.current.overrides,key:a}}var ct=require("react");function zt(e){let i=(0,ct.useRef)(e);i.current=e;let a=(0,ct.useRef)(null);a.current===null&&(a.current={fetch:(n,t)=>{let r=i.current;return r?r.fetch(n,t):Promise.reject(new Error("products config removed"))},transform:n=>i.current?.transform(n)??[],get limit(){return i.current?.limit}});let s=e!==void 0;return{config:s?a.current:void 0,enabled:s}}var pa={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function Xe({onSubmit:e,onResult:i,onError:a,optionOverrides:s,maskCompletedText:n,apiConfig:t,additionalContext:r,columns:m=2,dropdownTrigger:x,optionsPosition:v,closeDropdownOnBlur:y,showNonTappableOptions:h,showOptionIcons:C,showOptionImages:T,showOptionCounts:k,showSkipButton:_,showProducts:B,onFocus:E,onBlur:D,value:A,completedParams:z,onChange:F,onParamsChange:S,products:ce,onProductSelect:pe,source:Pe,setCursor:he}){let u=(0,I.useRef)(null),[Y,Se]=(0,I.useState)(null),Ie=(0,I.useRef)(e);Ie.current=e;let ue=(0,I.useRef)(i);ue.current=i;let Ee=(0,I.useRef)(a);Ee.current=a;let me=(0,I.useRef)(F);me.current=F;let te=(0,I.useRef)(S);te.current=S;let fe=(0,I.useRef)(E);fe.current=E;let ae=(0,I.useRef)(D);ae.current=D;let ge=(0,I.useRef)(he);ge.current=he;let be=(0,I.useRef)(pe);be.current=pe;let G=zt(ce),d=Mt(s);(0,I.useEffect)(()=>{if(typeof document>"u")return;let b=new Ne.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:t,additionalContext:r,optionOverrides:d.overrides,maskCompletedText:n,columns:m,dropdownTrigger:x,optionsPosition:v,closeDropdownOnBlur:y,showNonTappableOptions:h,showProducts:B,source:Pe,value:A,completedParams:z,onSubmit:(...N)=>Ie.current?.(...N),onResult:(...N)=>ue.current?.(...N),onError:(...N)=>Ee.current?.(...N),onChange:(...N)=>me.current?.(...N),onParamsChange:(...N)=>te.current?.(...N),onFocus:()=>fe.current?.(),onBlur:()=>ae.current?.(),onProductSelect:N=>be.current?.(N),setCursor:N=>ge.current?.(N),products:G.config});u.current=b,Se(b.getState());let V=b.subscribe(N=>Se(N));return()=>{V(),b.destroy(),u.current===b&&(u.current=null)}},[]),(0,I.useEffect)(()=>{A!==void 0&&u.current?.setValue(A)},[A]),(0,I.useEffect)(()=>{z!==void 0&&u.current?.setCompletedParams(z)},[z]);let f=JSON.stringify(t??null),g;try{g=JSON.stringify(r??null)}catch{g="[unstringifiable]"}(0,I.useEffect)(()=>{u.current?.update({apiConfig:t,additionalContext:r,optionOverrides:d.overrides,dropdownTrigger:x,optionsPosition:v,closeDropdownOnBlur:y,showNonTappableOptions:h,showProducts:B})},[f,g,d.key,x,v,y,h,B]);let o=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!o.current){o.current=!0;return}u.current?.update({products:G.config})},[G.enabled]);let w=(0,I.useRef)(null);w.current===null&&(w.current={handleTextChange:b=>u.current?.handleTextChange(b),handleKeyDown:b=>{let V="nativeEvent"in b?b.nativeEvent:b;u.current?.handleKeyDown(V)},setFocused:b=>u.current?.setFocused(b),startEditingParam:b=>u.current?.startEditingParam(b),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:b=>u.current?.handleCaretAfterInput(b),handleCaretMove:b=>u.current?.handleCaretMove(b),replaceEditingRange:b=>u.current?.replaceEditingRange(b)??!1,setActivePill:b=>u.current?.setActivePill(b),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),selectOption:b=>u.current?.selectOption(b),selectProduct:b=>u.current?.selectProduct(b),setActiveDropdownIndex:b=>u.current?.setActiveDropdownIndex(b),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let c=w.current,ie=(0,I.useCallback)(b=>{let V=b.target.value,tt=V.length>0&&!b.nativeEvent?.isComposing&&V[0]!==V[0].toUpperCase()?V[0].toUpperCase()+V.slice(1):V;u.current?.handleTextChange(tt)},[]),q=(0,I.useCallback)(b=>{u.current?.handleKeyDown(b.nativeEvent)},[]),ve=u.current,p=Y??pa,we=A!==void 0?A:p.text,Te=z!==void 0?z:p.completedParams,xe=p.actionableSuggestions,Oe=xe[0],ye=ve?.listboxId??"",Le=p.activeDropdownIndex>=0&&ve?`${ye}-option-${p.activeDropdownIndex}`:void 0,oe=p.editingParam,$=p.editingIdentified,Z=oe?{type:oe.suggestionType,text:oe.suggestionPlaceholder,required:!0,options:oe.options}:$?{type:$.type,text:(0,Ne.identifiedParamLabel)($.type),required:!0,options:[]}:null,He=p.dropdownSuggestion??Z??Oe,et=Z?[Z]:xe,Fe=(0,Ne.dateSelectionFor)(p),We=!ve||p.dropdownLoading;return{completedParams:Te,skippedParams:p.skippedParams,identifiedParams:p.identifiedParams,suggestionPills:xe,setActivePill:c.setActivePill,skipActivePill:c.skipActivePill,removeLastParam:c.removeLastParam,segments:p.segments,newParamId:p.newParamId,clearNewParamId:c.clearNewParamId,suggestions:p.suggestions,activeIndex:p.activeDropdownIndex,isReady:p.isReady,isLoading:We,isFocused:p.isFocused,isDropdownOpen:p.isDropdownOpen,isActivePillSelected:p.isActivePillSelected,placeholderText:p.placeholderText,listboxId:ye,error:p.error,products:p.products,customFields:p.customFields,selectProduct:c.selectProduct,handleTextChange:c.handleTextChange,handleKeyDown:c.handleKeyDown,setFocused:c.setFocused,editingParam:oe,editingIdentified:$,editingAnchor:p.editingAnchor,caretOffset:p.caretOffset,startEditingParam:c.startEditingParam,exitEditMode:c.exitEditMode,handleCaretAfterInput:c.handleCaretAfterInput,handleCaretMove:c.handleCaretMove,replaceEditingRange:c.replaceEditingRange,inputProps:{value:we,placeholder:p.placeholderText||void 0,onChange:ie,onKeyDown:q,onFocus:c.handleFocus,onBlur:c.handleBlur,role:"combobox","aria-expanded":p.isDropdownOpen,"aria-activedescendant":Le,"aria-autocomplete":"list","aria-controls":ye},reset:c.reset,dropdownProps:{suggestions:He?[{...He,options:p.dropdownOptions}]:[],activeIndex:p.activeDropdownIndex,onSelect:c.selectOption,onHighlight:c.setActiveDropdownIndex,isOpen:p.isDropdownOpen,id:ye,pills:et,activeSelected:p.isActivePillSelected,onPillClick:c.setActivePill,onSkip:c.skipActivePill,showSkipButton:(_??!0)&&!oe&&!$,showOptionIcons:C??!0,showOptionImages:T??!0,showOptionCounts:k??!0,skipDisabled:p.inSelectionAnimation,isLoading:We,skeletonExiting:p.skeletonExiting,isInputEmpty:we.trim().length===0,products:p.products,onProductSelect:c.selectProduct,onProductFocusChange:c.setFocused,formatType:p.activeFormatType,dateView:p.dateView,selectedDateIso:Fe.selectedIso,selectedDateRange:Fe.selectedRange,dateRangeStart:Fe.rangeStart,onPreviousMonth:c.showPreviousMonth,onNextMonth:c.showNextMonth,optionsPosition:v??"below"}}}var Q=require("@magicx-eng/ai-autocomplete-vanilla"),P=require("react"),Je;function ha(){if(Je!==void 0)return Je;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Je=e.contentEditable==="plaintext-only",Je}function Nt(e){let{segments:i,showChipIcons:a=!0,showChipImages:s=!0,newParamId:n,editingParam:t,editingIdentified:r,editingAnchor:m,caretOffset:x,placeholderText:v,isFocused:y,isDropdownOpen:h,listboxId:C,activeDescendantId:T,autoFocus:k,handleTextChange:_,handleKeyDown:B,handleCaretAfterInput:E,handleCaretMove:D,startEditingParam:A,replaceEditingRange:z,setFocused:F}=e,S=(0,P.useRef)(null),ce=(0,P.useRef)(!1),pe=(0,P.useRef)(""),Pe=(0,P.useRef)(""),he=(0,P.useRef)(null),u=(0,P.useRef)(0);he.current=x,(0,P.useEffect)(()=>{if(!k)return;let d=S.current;if(!d)return;document.activeElement===d?F(!0):d.focus();let f=d.ownerDocument??document,g=f.getSelection(),o=g&&g.rangeCount>0&&d.contains(g.anchorNode);if(g&&!o){let w=f.createRange();w.selectNodeContents(d),w.collapse(!0),g.removeAllRanges(),g.addRange(w)}},[k,F]),(0,P.useEffect)(()=>{let d=S.current;if(!d)return;let f=d.ownerDocument??document,g=()=>{let o=f.getSelection();if(!o||o.rangeCount===0||!o.anchorNode||!d.contains(o.anchorNode))return;let w=o.anchorNode,c=w.nodeType===Node.ELEMENT_NODE?w:w.parentElement,q=(o.isCollapsed?c?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ve=t?.id??r?.id??null;if(q&&q!==ve){A(q);return}performance.now()-u.current<50||D((0,Q.getCursorOffset)(d))};return f.addEventListener("selectionchange",g),()=>f.removeEventListener("selectionchange",g)},[t,r,A,D]),(0,P.useLayoutEffect)(()=>{let d=S.current;d&&(0,Q.renderEditableContent)({input:d,segments:i,newParamId:n,editingParamId:t?.id??null,placeholderText:v??"",isFocused:y,showChipIcons:a,showChipImages:s})},[i,n,t,v,y,a,s]),(0,P.useLayoutEffect)(()=>{let d=pe.current,f=n??"";if(pe.current=f,!f||f===d)return;let g=S.current;if(!g)return;g.focus();let o=he.current??(0,Q.plainTextLength)(g);(0,Q.setCursorOffset)(g,o)},[n]),(0,P.useLayoutEffect)(()=>{let d=Pe.current,f=t?.id??"";if(Pe.current=f,!f||f===d||m==null)return;let g=S.current;g&&(0,Q.setCursorOffset)(g,m)},[t,m]);let Y=(0,P.useCallback)(()=>{if(ce.current)return;let d=S.current;if(!d)return;let f=(0,Q.extractPlainText)(d),o=f.length>0&&f[0]!==f[0].toUpperCase()?f[0].toUpperCase()+f.slice(1):f;_(o)},[_]),Se=(0,P.useCallback)(()=>{u.current=performance.now(),Y();let d=S.current;d&&E((0,Q.getCursorOffset)(d))},[Y,E]);(0,P.useEffect)(()=>{let d=S.current;if(!d)return;let f=g=>{let o=g,w=o.inputType;if(w==="insertParagraph"||w==="insertLineBreak"||w==="insertFromDrop"){g.preventDefault();return}if(w.startsWith("insert")||w.startsWith("delete")){let c=w.startsWith("delete")?"":o.data??"";z(c)&&g.preventDefault()}};return d.addEventListener("beforeinput",f),()=>d.removeEventListener("beforeinput",f)},[z]);let Ie=(0,P.useCallback)(()=>{ce.current=!0},[]),ue=(0,P.useCallback)(()=>{ce.current=!1,Y()},[Y]),Ee=(0,P.useCallback)(d=>{d.preventDefault();let f=S.current;if(!f)return;let g=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!g)return;let o=f.ownerDocument??document,w=o.getSelection();if(!w||w.rangeCount===0)return;let c=w.getRangeAt(0);if(!f.contains(c.startContainer))return;c.deleteContents();let ie=o.createTextNode(g);c.insertNode(ie),c.setStartAfter(ie),c.collapse(!0),w.removeAllRanges(),w.addRange(c),Y()},[Y]),me=(0,P.useCallback)(d=>B(d),[B]),te=(0,P.useCallback)(()=>F(!0),[F]),fe=(0,P.useCallback)(()=>F(!1),[F]),ae=(0,P.useCallback)(()=>S.current?.focus(),[]),ge=(0,P.useCallback)(()=>S.current?.blur(),[]),be=(0,P.useCallback)(()=>{let d=S.current;return d?(0,Q.extractPlainText)(d):""},[]),G=ha()?"plaintext-only":"true";return{inputRef:S,editorProps:{ref:S,contentEditable:G,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":C,"aria-expanded":h,"aria-activedescendant":T,spellCheck:!0,enterKeyHint:"send",onInput:Se,onKeyDown:me,onCompositionStart:Ie,onCompositionEnd:ue,onPaste:Ee,onFocus:te,onBlur:fe},getPlainText:be,focus:ae,blur:ge}}var ee=require("react/jsx-runtime");function ua(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Bt=(0,M.forwardRef)(function({onSubmit:i,onResult:a,onError:s,optionOverrides:n,maskCompletedText:t,className:r,apiConfig:m,additionalContext:x,columns:v,pillPlacement:y="dropdown",mode:h="auto",optionsPosition:C="below",animations:T=!0,dropdownTrigger:k,closeDropdownOnBlur:_,showNonTappableOptions:B,showOptionIcons:E=!0,showChipIcons:D=!0,showChipImages:A=!0,showOptionImages:z=!0,showOptionCounts:F=!0,showSkipButton:S,showProducts:ce,productsLayout:pe,autoFocus:Pe=!0,onFocus:he,onBlur:u,value:Y,completedParams:Se,onChange:Ie,onParamsChange:ue,products:Ee,onProductSelect:me,submitButton:te},fe){let ae=(0,M.useRef)(null),ge=(0,M.useRef)(null),be=(0,M.useRef)(()=>{}),G=(0,M.useRef)(null),d=(0,M.useRef)(null);(0,M.useEffect)(()=>{let R=ae.current;if(R)return G.current?G.current.setMode(h):G.current=new Be.ModeController(R,h),()=>{G.current?.destroy(),G.current=null}},[h]);let f=(0,M.useCallback)(R=>{let Ae=d.current?.current;Ae&&(Ae.focus(),(0,Be.setCursorOffset)(Ae,R))},[]),{completedParams:g,skippedParams:o,identifiedParams:w,isReady:c,customFields:ie,suggestionPills:q,setActivePill:ve,skipActivePill:p,segments:we,newParamId:Te,clearNewParamId:xe,placeholderText:Oe,isFocused:ye,isDropdownOpen:Le,isActivePillSelected:oe,isLoading:$,activeIndex:Z,listboxId:He,handleTextChange:et,handleKeyDown:Fe,setFocused:We,editingParam:b,editingIdentified:V,editingAnchor:N,caretOffset:tt,startEditingParam:Ht,handleCaretAfterInput:Ft,handleCaretMove:Kt,replaceEditingRange:Gt,dropdownProps:Wt,reset:_e}=Xe({onSubmit:R=>be.current(R),onResult:a,onError:s,optionOverrides:n,maskCompletedText:t,apiConfig:m,additionalContext:x,columns:v,dropdownTrigger:k,optionsPosition:C,closeDropdownOnBlur:_,showNonTappableOptions:B,showOptionIcons:E,showOptionImages:z,showOptionCounts:F,showSkipButton:S,showProducts:ce,onFocus:he,onBlur:u,value:Y,completedParams:Se,onChange:Ie,onParamsChange:ue,products:Ee,onProductSelect:me,source:"full-sdk",setCursor:f});(0,M.useEffect)(()=>{if(!Te)return;let R=window.setTimeout(()=>xe(),650);return()=>window.clearTimeout(R)},[Te,xe]);let _t=Z>=0?`${He}-option-${Z}`:void 0,{inputRef:at,editorProps:qt,focus:qe,blur:pt,getPlainText:ht}=Nt({segments:we,newParamId:Te,editingParam:b,editingIdentified:V,editingAnchor:N,caretOffset:tt,placeholderText:Oe,isFocused:ye,showChipIcons:D,showChipImages:A,isDropdownOpen:Le,listboxId:He,activeDescendantId:_t,autoFocus:Pe,handleTextChange:et,handleKeyDown:Fe,handleCaretAfterInput:Ft,handleCaretMove:Kt,startEditingParam:Ht,replaceEditingRange:Gt,setFocused:We});d.current=at,(0,M.useLayoutEffect)(()=>{let R=ge.current,Ae=at.current;if(!R||!Ae)return;let ut=()=>{let ft=R.firstElementChild;if(!ft)return;let Yt=ft.getBoundingClientRect(),$t=Ae.getBoundingClientRect();Yt.top>=$t.bottom-2?R.setAttribute("data-aia-pill-wrapped",""):R.removeAttribute("data-aia-pill-wrapped")};ut();let mt=new ResizeObserver(ut);return mt.observe(Ae),()=>mt.disconnect()},[we,q.length,$,at]),(0,M.useImperativeHandle)(fe,()=>({focus:qe,blur:pt,reset:_e,setMode:R=>G.current?.setMode(R),skipActivePill:p}),[qe,pt,_e,p]);let Ue=!!we.length||g.length>0,it=(0,M.useCallback)(()=>{if(!Ue)return;let R=ht();i((0,Be.buildSubmitResult)(R,g,o,{identifiedParams:w,isReady:c,customFields:ie})),_e()},[Ue,g,o,w,c,ie,i,_e,ht]);be.current=it;let Ut=(0,M.useCallback)(R=>{R.target?.closest("[data-aia-pill]")||qe()},[qe]),jt=y==="inline",Qt=y==="dropdown";return(0,ee.jsxs)("div",{ref:ae,className:`magicx-aia ${De.container} ${r??""}`,"data-pill-placement":y,"data-options-position":C,"data-animations":T?"on":"off","data-mode":ua(h),children:[(0,ee.jsx)(Ve,{...Wt,showPills:Qt,productsLayout:pe}),(0,ee.jsxs)("div",{className:De.inputWrapper,"data-aia-input-wrapper":"",onClick:Ut,children:[(0,ee.jsxs)("div",{className:De.editorArea,"data-aia-editor":"",children:[(0,ee.jsx)("div",{...qt,className:De.input,"data-aia-input":""}),jt&&($||q.length>0)&&(0,ee.jsx)("span",{ref:ge,className:De.pillListContainer,"data-aia-pill-list-container":"",children:(0,ee.jsx)(Qe,{pills:q,activePillIndex:0,activeSelected:oe,onSelectPill:ve,loading:$})})]}),te===null?null:te===void 0?(0,ee.jsx)(Lt,{disabled:!Ue,onClick:it}):(0,ee.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:De.submitSlot,onClick:R=>{Ue&&(R.stopPropagation(),it())},children:te})]})]})});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,optionImageSrc,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
2186
+ `,document.head.appendChild(e)}var Lt={submitButton:"aia-submitButton-otz7H"};var et=require("react/jsx-runtime");function Mt({disabled:e,onClick:i}){return(0,et.jsx)("button",{type:"button","data-aia-submit":"",className:Lt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),i()},"aria-label":"Submit",children:(0,et.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,et.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var He=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react");var pt=require("react");function zt(e){let i=(0,pt.useRef)(e);i.current=e;let a=Object.keys(e??{}).sort().join("\0"),r=(0,pt.useRef)({key:"",overrides:void 0});if(r.current.key!==a){let n={};for(let t of Object.keys(e??{})){let l=(d,w,x)=>{let v=i.current?.[t];return v?v(d,w,x):[]};n[t]=l}r.current={key:a,overrides:e?n:void 0}}return{overrides:r.current.overrides,key:a}}var ht=require("react");function Nt(e){let i=(0,ht.useRef)(e);i.current=e;let a=(0,ht.useRef)(null);a.current===null&&(a.current={fetch:(n,t)=>{let l=i.current;return l?l.fetch(n,t):Promise.reject(new Error("products config removed"))},transform:n=>i.current?.transform(n)??[],get limit(){return i.current?.limit}});let r=e!==void 0;return{config:r?a.current:void 0,enabled:r}}var ma={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function tt({onSubmit:e,onResult:i,onError:a,optionOverrides:r,maskCompletedText:n,apiConfig:t,additionalContext:l,columns:d=2,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:v,showNonTappableOptions:m,showOptionIcons:k,showOptionImages:T,showOptionCounts:y,showSkipButton:q,showProducts:H,productImageFallback:A="image",onFocus:O,onBlur:F,value:N,completedParams:L,onChange:S,onParamsChange:X,products:ke,onProductSelect:pe,source:Ce,setCursor:he}){let h=(0,I.useRef)(null),[Oe,Pe]=(0,I.useState)(null),Se=(0,I.useRef)(e);Se.current=e;let ue=(0,I.useRef)(i);ue.current=i;let Ie=(0,I.useRef)(a);Ie.current=a;let me=(0,I.useRef)(S);me.current=S;let J=(0,I.useRef)(X);J.current=X;let ee=(0,I.useRef)(O);ee.current=O;let ge=(0,I.useRef)(F);ge.current=F;let fe=(0,I.useRef)(he);fe.current=he;let be=(0,I.useRef)(pe);be.current=pe;let c=Nt(ke),p=zt(r);(0,I.useEffect)(()=>{if(typeof document>"u")return;let f=new He.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:t,additionalContext:l,optionOverrides:p.overrides,maskCompletedText:n,columns:d,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:v,showNonTappableOptions:m,showProducts:H,source:Ce,value:N,completedParams:L,onSubmit:(...B)=>Se.current?.(...B),onResult:(...B)=>ue.current?.(...B),onError:(...B)=>Ie.current?.(...B),onChange:(...B)=>me.current?.(...B),onParamsChange:(...B)=>J.current?.(...B),onFocus:()=>ee.current?.(),onBlur:()=>ge.current?.(),onProductSelect:B=>be.current?.(B),setCursor:B=>fe.current?.(B),products:c.config});h.current=f,Pe(f.getState());let j=f.subscribe(B=>Pe(B));return()=>{j(),f.destroy(),h.current===f&&(h.current=null)}},[]),(0,I.useEffect)(()=>{N!==void 0&&h.current?.setValue(N)},[N]),(0,I.useEffect)(()=>{L!==void 0&&h.current?.setCompletedParams(L)},[L]);let b=JSON.stringify(t??null),C;try{C=JSON.stringify(l??null)}catch{C="[unstringifiable]"}(0,I.useEffect)(()=>{h.current?.update({apiConfig:t,additionalContext:l,optionOverrides:p.overrides,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:v,showNonTappableOptions:m,showProducts:H})},[b,C,p.key,w,x,v,m,H]);let o=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!o.current){o.current=!0;return}h.current?.update({products:c.config})},[c.enabled]);let E=(0,I.useRef)(null);E.current===null&&(E.current={handleTextChange:f=>h.current?.handleTextChange(f),handleKeyDown:f=>{let j="nativeEvent"in f?f.nativeEvent:f;h.current?.handleKeyDown(j)},setFocused:f=>h.current?.setFocused(f),startEditingParam:f=>h.current?.startEditingParam(f),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:f=>h.current?.handleCaretAfterInput(f),handleCaretMove:f=>h.current?.handleCaretMove(f),replaceEditingRange:f=>h.current?.replaceEditingRange(f)??!1,setActivePill:f=>h.current?.setActivePill(f),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:f=>h.current?.selectOption(f),selectProduct:f=>h.current?.selectProduct(f),setActiveDropdownIndex:f=>h.current?.setActiveDropdownIndex(f),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let g=E.current,te=(0,I.useCallback)(f=>{let j=f.target.value,it=j.length>0&&!f.nativeEvent?.isComposing&&j[0]!==j[0].toUpperCase()?j[0].toUpperCase()+j.slice(1):j;h.current?.handleTextChange(it)},[]),ae=(0,I.useCallback)(f=>{h.current?.handleKeyDown(f.nativeEvent)},[]),ve=h.current,u=Oe??ma,Ee=N!==void 0?N:u.text,Te=L!==void 0?L:u.completedParams,ie=u.actionableSuggestions,De=ie[0],we=ve?.listboxId??"",Me=u.activeDropdownIndex>=0&&ve?`${we}-option-${u.activeDropdownIndex}`:void 0,oe=u.editingParam,ne=u.editingIdentified,Y=oe?{type:oe.suggestionType,text:oe.suggestionPlaceholder,required:!0,options:oe.options}:ne?{type:ne.type,text:(0,He.identifiedParamLabel)(ne.type),required:!0,options:[]}:null,Ke=u.dropdownSuggestion??Y??De,qe=Y?[Y]:ie,Ge=(0,He.dateSelectionFor)(u),Ue=!ve||u.dropdownLoading;return{completedParams:Te,skippedParams:u.skippedParams,identifiedParams:u.identifiedParams,suggestionPills:ie,setActivePill:g.setActivePill,skipActivePill:g.skipActivePill,removeLastParam:g.removeLastParam,segments:u.segments,newParamId:u.newParamId,clearNewParamId:g.clearNewParamId,suggestions:u.suggestions,activeIndex:u.activeDropdownIndex,isReady:u.isReady,isLoading:Ue,isFocused:u.isFocused,isDropdownOpen:u.isDropdownOpen,isActivePillSelected:u.isActivePillSelected,placeholderText:u.placeholderText,listboxId:we,error:u.error,products:u.products,customFields:u.customFields,selectProduct:g.selectProduct,handleTextChange:g.handleTextChange,handleKeyDown:g.handleKeyDown,setFocused:g.setFocused,editingParam:oe,editingIdentified:ne,editingAnchor:u.editingAnchor,caretOffset:u.caretOffset,startEditingParam:g.startEditingParam,exitEditMode:g.exitEditMode,handleCaretAfterInput:g.handleCaretAfterInput,handleCaretMove:g.handleCaretMove,replaceEditingRange:g.replaceEditingRange,inputProps:{value:Ee,placeholder:u.placeholderText||void 0,onChange:te,onKeyDown:ae,onFocus:g.handleFocus,onBlur:g.handleBlur,role:"combobox","aria-expanded":u.isDropdownOpen,"aria-activedescendant":Me,"aria-autocomplete":"list","aria-controls":we},reset:g.reset,dropdownProps:{suggestions:Ke?[{...Ke,options:u.dropdownOptions}]:[],activeIndex:u.activeDropdownIndex,onSelect:g.selectOption,onHighlight:g.setActiveDropdownIndex,isOpen:u.isDropdownOpen,id:we,pills:qe,activeSelected:u.isActivePillSelected,onPillClick:g.setActivePill,onSkip:g.skipActivePill,showSkipButton:(q??!0)&&!oe&&!ne,showOptionIcons:k??!0,showOptionImages:T??!0,showOptionCounts:y??!0,skipDisabled:u.inSelectionAnimation,isLoading:Ue,skeletonExiting:u.skeletonExiting,isInputEmpty:Ee.trim().length===0,products:u.products,productImageFallback:A,onProductSelect:g.selectProduct,onProductFocusChange:g.setFocused,formatType:u.activeFormatType,dateView:u.dateView,selectedDateIso:Ge.selectedIso,selectedDateRange:Ge.selectedRange,dateRangeStart:Ge.rangeStart,onPreviousMonth:g.showPreviousMonth,onNextMonth:g.showNextMonth,optionsPosition:x??"below"}}}var Q=require("@magicx-eng/ai-autocomplete-vanilla"),P=require("react"),at;function ga(){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 Bt(e){let{segments:i,showChipIcons:a=!0,showChipImages:r=!0,newParamId:n,editingParam:t,editingIdentified:l,editingAnchor:d,caretOffset:w,placeholderText:x,isFocused:v,isDropdownOpen:m,listboxId:k,activeDescendantId:T,autoFocus:y,handleTextChange:q,handleKeyDown:H,handleCaretAfterInput:A,handleCaretMove:O,startEditingParam:F,replaceEditingRange:N,setFocused:L}=e,S=(0,P.useRef)(null),X=(0,P.useRef)(!1),ke=(0,P.useRef)(""),pe=(0,P.useRef)(""),Ce=(0,P.useRef)(null),he=(0,P.useRef)(0);Ce.current=w,(0,P.useEffect)(()=>{if(!y)return;let c=S.current;if(!c)return;document.activeElement===c?L(!0):c.focus();let p=c.ownerDocument??document,b=p.getSelection(),C=b&&b.rangeCount>0&&c.contains(b.anchorNode);if(b&&!C){let o=p.createRange();o.selectNodeContents(c),o.collapse(!0),b.removeAllRanges(),b.addRange(o)}},[y,L]),(0,P.useEffect)(()=>{let c=S.current;if(!c)return;let p=c.ownerDocument??document,b=()=>{let C=p.getSelection();if(!C||C.rangeCount===0||!C.anchorNode||!c.contains(C.anchorNode))return;let o=C.anchorNode,E=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement,te=(C.isCollapsed?E?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ae=t?.id??l?.id??null;if(te&&te!==ae){F(te);return}performance.now()-he.current<50||O((0,Q.getCursorOffset)(c))};return p.addEventListener("selectionchange",b),()=>p.removeEventListener("selectionchange",b)},[t,l,F,O]),(0,P.useLayoutEffect)(()=>{let c=S.current;c&&(0,Q.renderEditableContent)({input:c,segments:i,newParamId:n,editingParamId:t?.id??null,placeholderText:x??"",isFocused:v,showChipIcons:a,showChipImages:r})},[i,n,t,x,v,a,r]),(0,P.useLayoutEffect)(()=>{let c=ke.current,p=n??"";if(ke.current=p,!p||p===c)return;let b=S.current;if(!b)return;b.focus();let C=Ce.current??(0,Q.plainTextLength)(b);(0,Q.setCursorOffset)(b,C)},[n]),(0,P.useLayoutEffect)(()=>{let c=pe.current,p=t?.id??"";if(pe.current=p,!p||p===c||d==null)return;let b=S.current;b&&(0,Q.setCursorOffset)(b,d)},[t,d]);let h=(0,P.useCallback)(()=>{if(X.current)return;let c=S.current;if(!c)return;let p=(0,Q.extractPlainText)(c),C=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;q(C)},[q]),Oe=(0,P.useCallback)(()=>{he.current=performance.now(),h();let c=S.current;c&&A((0,Q.getCursorOffset)(c))},[h,A]);(0,P.useEffect)(()=>{let c=S.current;if(!c)return;let p=b=>{let C=b,o=C.inputType;if(o==="insertParagraph"||o==="insertLineBreak"||o==="insertFromDrop"){b.preventDefault();return}if(o.startsWith("insert")||o.startsWith("delete")){let E=o.startsWith("delete")?"":C.data??"";N(E)&&b.preventDefault()}};return c.addEventListener("beforeinput",p),()=>c.removeEventListener("beforeinput",p)},[N]);let Pe=(0,P.useCallback)(()=>{X.current=!0},[]),Se=(0,P.useCallback)(()=>{X.current=!1,h()},[h]),ue=(0,P.useCallback)(c=>{c.preventDefault();let p=S.current;if(!p)return;let b=(c.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let C=p.ownerDocument??document,o=C.getSelection();if(!o||o.rangeCount===0)return;let E=o.getRangeAt(0);if(!p.contains(E.startContainer))return;E.deleteContents();let g=C.createTextNode(b);E.insertNode(g),E.setStartAfter(g),E.collapse(!0),o.removeAllRanges(),o.addRange(E),h()},[h]),Ie=(0,P.useCallback)(c=>H(c),[H]),me=(0,P.useCallback)(()=>L(!0),[L]),J=(0,P.useCallback)(()=>L(!1),[L]),ee=(0,P.useCallback)(()=>S.current?.focus(),[]),ge=(0,P.useCallback)(()=>S.current?.blur(),[]),fe=(0,P.useCallback)(()=>{let c=S.current;return c?(0,Q.extractPlainText)(c):""},[]),be=ga()?"plaintext-only":"true";return{inputRef:S,editorProps:{ref:S,contentEditable:be,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":k,"aria-expanded":m,"aria-activedescendant":T,spellCheck:!0,enterKeyHint:"send",onInput:Oe,onKeyDown:Ie,onCompositionStart:Pe,onCompositionEnd:Se,onPaste:ue,onFocus:me,onBlur:J},getPlainText:fe,focus:ee,blur:ge}}var V=require("react/jsx-runtime");function fa(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ht=(0,z.forwardRef)(function({onSubmit:i,onResult:a,onError:r,optionOverrides:n,maskCompletedText:t,className:l,apiConfig:d,additionalContext:w,columns:x,pillPlacement:v="dropdown",mode:m="auto",optionsPosition:k="below",animations:T=!0,dropdownTrigger:y,closeDropdownOnBlur:q,showNonTappableOptions:H,showOptionIcons:A=!0,showChipIcons:O=!0,showChipImages:F=!0,showOptionImages:N=!0,showOptionCounts:L=!0,showSkipButton:S,showProducts:X,productsLayout:ke,productImageFallback:pe,autoFocus:Ce=!0,onFocus:he,onBlur:h,value:Oe,completedParams:Pe,onChange:Se,onParamsChange:ue,products:Ie,onProductSelect:me,submitButton:J,resetOnSubmit:ee=!0},ge){let fe=(0,z.useRef)(null),be=(0,z.useRef)(null),c=(0,z.useRef)(()=>{}),p=(0,z.useRef)(null),b=(0,z.useRef)(null);(0,z.useEffect)(()=>{let R=fe.current;if(R)return p.current?p.current.setMode(m):p.current=new Fe.ModeController(R,m),()=>{p.current?.destroy(),p.current=null}},[m]);let C=(0,z.useCallback)(R=>{let Ae=b.current?.current;Ae&&(Ae.focus(),(0,Fe.setCursorOffset)(Ae,R))},[]),{completedParams:o,skippedParams:E,identifiedParams:g,isReady:te,customFields:ae,suggestionPills:ve,setActivePill:u,skipActivePill:Ee,segments:Te,newParamId:ie,clearNewParamId:De,placeholderText:we,isFocused:Me,isDropdownOpen:oe,isActivePillSelected:ne,isLoading:Y,activeIndex:Ke,listboxId:qe,handleTextChange:Ge,handleKeyDown:Ue,setFocused:f,editingParam:j,editingIdentified:B,editingAnchor:it,caretOffset:Ft,startEditingParam:Kt,handleCaretAfterInput:Gt,handleCaretMove:Wt,replaceEditingRange:_t,dropdownProps:qt,reset:Qe}=tt({onSubmit:R=>c.current(R),onResult:a,onError:r,optionOverrides:n,maskCompletedText:t,apiConfig:d,additionalContext:w,columns:x,dropdownTrigger:y,optionsPosition:k,closeDropdownOnBlur:q,showNonTappableOptions:H,showOptionIcons:A,showOptionImages:N,showOptionCounts:L,showSkipButton:S,showProducts:X,onFocus:he,onBlur:h,value:Oe,completedParams:Pe,onChange:Se,onParamsChange:ue,products:Ie,onProductSelect:me,source:"full-sdk",setCursor:C});(0,z.useEffect)(()=>{if(!ie)return;let R=window.setTimeout(()=>De(),650);return()=>window.clearTimeout(R)},[ie,De]);let Ut=Ke>=0?`${qe}-option-${Ke}`:void 0,{inputRef:ot,editorProps:Qt,focus:Ye,blur:ut,getPlainText:mt}=Bt({segments:Te,newParamId:ie,editingParam:j,editingIdentified:B,editingAnchor:it,caretOffset:Ft,placeholderText:we,isFocused:Me,showChipIcons:O,showChipImages:F,isDropdownOpen:oe,listboxId:qe,activeDescendantId:Ut,autoFocus:Ce,handleTextChange:Ge,handleKeyDown:Ue,handleCaretAfterInput:Gt,handleCaretMove:Wt,startEditingParam:Kt,replaceEditingRange:_t,setFocused:f});b.current=ot,(0,z.useLayoutEffect)(()=>{let R=be.current,Ae=ot.current;if(!R||!Ae)return;let gt=()=>{let bt=R.firstElementChild;if(!bt)return;let $t=bt.getBoundingClientRect(),Vt=Ae.getBoundingClientRect();$t.top>=Vt.bottom-2?R.setAttribute("data-aia-pill-wrapped",""):R.removeAttribute("data-aia-pill-wrapped")};gt();let ft=new ResizeObserver(gt);return ft.observe(Ae),()=>ft.disconnect()},[Te,ve.length,Y,ot]),(0,z.useImperativeHandle)(ge,()=>({focus:Ye,blur:ut,reset:Qe,setMode:R=>p.current?.setMode(R),skipActivePill:Ee}),[Ye,ut,Qe,Ee]);let je=!!Te.length||o.length>0,nt=(0,z.useCallback)(()=>{if(!je)return;let R=mt();i((0,Fe.buildSubmitResult)(R,o,E,{identifiedParams:g,isReady:te,customFields:ae})),ee&&Qe()},[ee,je,o,E,g,te,ae,i,Qe,mt]);c.current=nt;let Yt=(0,z.useCallback)(R=>{R.target?.closest("[data-aia-pill]")||Ye()},[Ye]),jt=v==="inline",Zt=v==="dropdown";return(0,V.jsxs)("div",{ref:fe,className:`magicx-aia ${Le.container} ${l??""}`,"data-pill-placement":v,"data-options-position":k,"data-animations":T?"on":"off","data-mode":fa(m),children:[(0,V.jsx)(Je,{...qt,showPills:Zt,productsLayout:ke,productImageFallback:pe}),(0,V.jsxs)("div",{className:Le.inputWrapper,"data-aia-input-wrapper":"",onClick:Yt,children:[(0,V.jsxs)("div",{className:Le.editorArea,"data-aia-editor":"",children:[(0,V.jsx)("div",{...Qt,className:Le.input,"data-aia-input":""}),jt&&(Y||ve.length>0)&&(0,V.jsx)("span",{ref:be,className:Le.pillListContainer,"data-aia-pill-list-container":"",children:(0,V.jsx)($e,{pills:ve,activePillIndex:0,activeSelected:ne,onSelectPill:u,loading:Y})})]}),J===null?null:J===void 0?(0,V.jsx)(Mt,{disabled:!je,onClick:nt}):(0,V.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Le.submitSlot,onClick:R=>{je&&(R.stopPropagation(),nt())},children:J})]})]})});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,optionImageSrc,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
2147
2187
  //# sourceMappingURL=index.js.map