@magicx-eng/ai-autocomplete-react 0.33.2 → 0.33.4

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END as gn,DATE_RANGE_META_START as fn,DEFAULT_OPTION_COUNT_UNIT as bn,dateCellMarks as vn,formatDate as wn,formatDateRange as xn,formatOptionCount as yn,isoDate as kn,monthLabel as Cn,optionCountLabel as Pn,optionHasImage as Sn,optionImageSources as In,optionImageSrc as En,optionLabel as Tn,PRODUCT_PATH_PREFIX as An,parseDate as Rn,parseLooseDate as On,parseLooseDateRange as Dn,productFromMatchedItem as Ln,productImageSources as zn,productsFromCustomFields as Mn,sanitizeOptionIconSvg as Nn,selectedRangeFor as Bn,visibleDateRange as Hn,WEEKDAY_LABELS as Fn,withSkippedParams as Kn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as ui,useCallback as lt,useEffect as Wt,useImperativeHandle as mi,useLayoutEffect as gi,useRef as Ne}from"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
+ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END as xn,DATE_RANGE_META_START as yn,DEFAULT_OPTION_COUNT_UNIT as kn,dateCellMarks as Cn,formatDate as Pn,formatDateRange as Sn,formatOptionCount as In,isoDate as En,monthLabel as Tn,optionCountLabel as An,optionHasImage as Rn,optionImageSources as On,optionImageSrc as Dn,optionLabel as Ln,PRODUCT_PATH_PREFIX as zn,parseDate as Mn,parseLooseDate as Nn,parseLooseDateRange as Bn,productFromMatchedItem as Hn,productImageSources as Fn,productsFromCustomFields as Kn,sanitizeOptionIconSvg as Gn,selectedRangeFor as Wn,visibleDateRange as _n,WEEKDAY_LABELS as qn,withSkippedParams as Un}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as fi,useCallback as lt,useEffect as Wt,useImperativeHandle as bi,useLayoutEffect as vi,useRef as Ne}from"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 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
262
262
  opacity: 0;
263
263
  }
264
264
  }
265
- `,document.head.appendChild(e)}var Ce={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"};import{attachScrollArrow as Ya,containScroll as Za,isCalendarFormat as $a,SCROLL_ARROW_LABEL as Va}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as je,useRef as Ue,useState as Xa}from"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 ke={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"};import{attachScrollArrow as $a,containScroll as Va,isCalendarFormat as Xa,uiStringsFor as Ja}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as je,useRef as Ue,useState as ei}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
266
266
  * Built-in appearance defaults \u2014 zero specificity via :where().
267
267
  * Consumer CSS always wins without !important.
268
268
  *
@@ -1045,7 +1045,7 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
1045
1045
  opacity: 0.25;
1046
1046
  }
1047
1047
  }
1048
- `,document.head.appendChild(e)}var se={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"};import{cellDay as ea,cellIso as Ee,dateCellMarks as ta,isoDate as aa,monthLabel as ia,visibleDateRange as oa,WEEKDAY_LABELS as na}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as ra}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
1048
+ `,document.head.appendChild(e)}var de={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"};import{cellDay as ea,cellIso as Ie,dateCellMarks as ta,isoDate as aa,monthLabel as ia,visibleDateRange as oa,WEEKDAY_LABELS as na}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as ra}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
1049
1049
 
1050
1050
  One of three hand-maintained copies (vanilla styles.css, this file, Angular's
1051
1051
  date-grid.component.css). Only the class-naming layer differs \u2014 the
@@ -1208,7 +1208,7 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
1208
1208
  opacity: 0.8;
1209
1209
  background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
1210
1210
  }
1211
- `,document.head.appendChild(e)}var A={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"};import{jsx as J,jsxs as gt}from"react/jsx-runtime";var sa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ft({options:e,activeIndex:o,listboxId:t,view:n,selection:r,onSelect:i,onHighlight:a,onUnhighlight:s,onPreviousMonth:v,onNextMonth:y}){let w=aa(new Date),P=oa({pendingStart:r.rangeStart,highlightedIso:Ee(e[o]),selected:r.selectedRange});return gt("div",{className:A.datepicker,"data-aia-datepicker":"",children:[gt("div",{className:A.header,children:[J("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:v,children:"\u2039"}),J("span",{className:A.month,"data-aia-date-month":"","aria-live":"polite",children:ia(n)}),J("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:y,children:"\u203A"})]}),J("div",{className:A.weekdays,"aria-hidden":"true",children:na.map((u,f)=>J("span",{className:A.weekday,children:u},sa[f]))}),J("div",{className:A.grid,"data-aia-date-grid":"",children:e.map((u,f)=>J(la,{option:u,id:`${t}-option-${f}`,index:f,isHighlighted:f===o&&u.is_tappable,isToday:Ee(u)===w,isPast:Ee(u)!=null&&Ee(u)<w,marks:ta(Ee(u),{selectedIso:r.selectedIso,range:P}),onSelect:i,onHighlight:a,onUnhighlight:s},Ee(u)??`pad-${f}`))})]})}function la({option:e,id:o,index:t,isHighlighted:n,isToday:r,isPast:i,marks:a,onSelect:s,onHighlight:v,onUnhighlight:y}){let[w,P]=ra(!1),u=ea(e);if(u==null)return J("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${A.cell} ${A.blank}`});let f=()=>{P(!0),s(e),setTimeout(()=>P(!1),170)},I=[A.cell,A.day,i?A.past:"",n?A.highlighted:"",r?A.today:"",a.inRange?A.inRange:"",a.selected?A.selected:"",w?A.pressed:""].filter(Boolean).join(" ");return J("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:I,onClick:f,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),f())},onMouseEnter:()=>v(t),onMouseLeave:y?()=>y(t):void 0,children:J("span",{className:A.number,children:u})})}import{ATTRIBUTION_URL as da,buildAttributionUrl as ca,getFooterHint as pa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ha,useState as ua}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
1211
+ `,document.head.appendChild(e)}var A={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"};import{jsx as te,jsxs as mt}from"react/jsx-runtime";var sa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ft({options:e,activeIndex:n,listboxId:t,view:i,selection:r,onSelect:o,onHighlight:a,onUnhighlight:d,onPreviousMonth:l,onNextMonth:w}){let C=aa(new Date),P=oa({pendingStart:r.rangeStart,highlightedIso:Ie(e[n]),selected:r.selectedRange});return mt("div",{className:A.datepicker,"data-aia-datepicker":"",children:[mt("div",{className:A.header,children:[te("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:l,children:"\u2039"}),te("span",{className:A.month,"data-aia-date-month":"","aria-live":"polite",children:ia(i)}),te("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:w,children:"\u203A"})]}),te("div",{className:A.weekdays,"aria-hidden":"true",children:na.map((u,b)=>te("span",{className:A.weekday,children:u},sa[b]))}),te("div",{className:A.grid,"data-aia-date-grid":"",children:e.map((u,b)=>te(la,{option:u,id:`${t}-option-${b}`,index:b,isHighlighted:b===n&&u.is_tappable,isToday:Ie(u)===C,isPast:Ie(u)!=null&&Ie(u)<C,marks:ta(Ie(u),{selectedIso:r.selectedIso,range:P}),onSelect:o,onHighlight:a,onUnhighlight:d},Ie(u)??`pad-${b}`))})]})}function la({option:e,id:n,index:t,isHighlighted:i,isToday:r,isPast:o,marks:a,onSelect:d,onHighlight:l,onUnhighlight:w}){let[C,P]=ra(!1),u=ea(e);if(u==null)return te("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${A.cell} ${A.blank}`});let b=()=>{P(!0),d(e),setTimeout(()=>P(!1),170)},I=[A.cell,A.day,o?A.past:"",i?A.highlighted:"",r?A.today:"",a.inRange?A.inRange:"",a.selected?A.selected:"",C?A.pressed:""].filter(Boolean).join(" ");return te("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:I,onClick:b,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),b())},onMouseEnter:()=>l(t),onMouseLeave:w?()=>w(t):void 0,children:te("span",{className:A.number,children:u})})}import{ATTRIBUTION_URL as da,buildAttributionUrl as ca,getFooterHint as pa,uiStringsFor as ha}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ua,useState as ga}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
1212
1212
  display: flex;
1213
1213
  flex-wrap: wrap;
1214
1214
  gap: var(--aia-cluster-gap, 0.5rem);
@@ -1248,7 +1248,7 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
1248
1248
  .aia-cluster[data-justify="around"] {
1249
1249
  justify-content: space-around;
1250
1250
  }
1251
- `,document.head.appendChild(e)}import{jsx as bt}from"react/jsx-runtime";function Le({gap:e,align:o="center",justify:t="start",noWrap:n=!1,inline:r=!1,className:i,children:a,...s}){let v=e?{"--aia-cluster-gap":e}:void 0,y={className:i?`aia-cluster ${i}`:"aia-cluster","data-align":o,"data-justify":t,"data-nowrap":n||void 0,"data-inline":r||void 0,style:v,...s};return r?bt("span",{...y,children:a}):bt("div",{...y,children:a})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
1251
+ `,document.head.appendChild(e)}import{jsx as bt}from"react/jsx-runtime";function Le({gap:e,align:n="center",justify:t="start",noWrap:i=!1,inline:r=!1,className:o,children:a,...d}){let l=e?{"--aia-cluster-gap":e}:void 0,w={className:o?`aia-cluster ${o}`:"aia-cluster","data-align":n,"data-justify":t,"data-nowrap":i||void 0,"data-inline":r||void 0,style:l,...d};return r?bt("span",{...w,children:a}):bt("div",{...w,children:a})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
1252
1252
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
1253
1253
  room above the hint/branding row so the footer doesn't butt against the last
1254
1254
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -1395,7 +1395,7 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
1395
1395
  justify-content: flex-end;
1396
1396
  }
1397
1397
  }
1398
- `,document.head.appendChild(e)}var le={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"};import{jsx as ze,jsxs as Je}from"react/jsx-runtime";function vt({isOptionHighlighted:e=!1,isInputEmpty:o=!1}){let{key:t,hint:n}=pa(e,o),[r,i]=ua(da);return ha(()=>{i(ca())},[]),ze("footer",{className:le.footer,"data-aia-footer":"",children:Je(Le,{justify:"between",noWrap:!0,className:le.row,children:[Je(Le,{gap:"5px",className:le.hintGroup,children:[ze("kbd",{className:le.key,children:t}),ze("span",{className:le.hint,children:n})]}),Je("a",{className:le.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[ze("span",{className:le.brand,children:"AI"}),ze("span",{className:le.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
1398
+ `,document.head.appendChild(e)}var 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"};import{jsx as ze,jsxs as Je}from"react/jsx-runtime";function vt({isOptionHighlighted:e=!1,isInputEmpty:n=!1,strings:t=ha()}){let{key:i,hint:r}=pa(e,n,t),[o,a]=ga(da);return ua(()=>{a(ca())},[]),ze("footer",{className:ce.footer,"data-aia-footer":"",children:Je(Le,{justify:"between",noWrap:!0,className:ce.row,children:[Je(Le,{gap:"5px",className:ce.hintGroup,children:[ze("kbd",{className:ce.key,children:i}),ze("span",{className:ce.hint,children:r})]}),Je("a",{className:ce.brandLink,href:o,target:"_blank",rel:"noopener noreferrer",children:[ze("span",{className:ce.brand,children:"AI"}),ze("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,
1399
1399
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
1400
1400
  The border is kept as a 1px transparent line so the box stays the same size
1401
1401
  as it was when the outline was dashed. */
@@ -1471,7 +1471,7 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
1471
1471
  opacity: 0;
1472
1472
  }
1473
1473
  }
1474
- `,document.head.appendChild(e)}var we={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"};import{jsx as ma}from"react/jsx-runtime";var et={selected:1,first:.7,next:.4,last:.2};function wt({label:e,state:o,rounded:t,loading:n,onClick:r}){let i=[we.pill,t?we.rounded:"",n?we.skeleton:""].filter(Boolean).join(" ");return ma("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:i,style:{opacity:et[o]},onMouseDown:a=>a.preventDefault(),onClick:n?void 0:r,disabled:n,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
1474
+ `,document.head.appendChild(e)}var we={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"};import{jsx as ma}from"react/jsx-runtime";var et={selected:1,first:.7,next:.4,last:.2};function wt({label:e,state:n,rounded:t,loading:i,onClick:r}){let o=[we.pill,t?we.rounded:"",i?we.skeleton:""].filter(Boolean).join(" ");return ma("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:o,style:{opacity:et[n]},onMouseDown:a=>a.preventDefault(),onClick:i?void 0:r,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 {
1475
1475
  position: relative;
1476
1476
  z-index: 1;
1477
1477
  pointer-events: auto;
@@ -1481,7 +1481,7 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
1481
1481
  align-items: center;
1482
1482
  vertical-align: middle;
1483
1483
  }
1484
- `,document.head.appendChild(e)}var tt={list:"aia-list-qvLqO"};import{jsx as We}from"react/jsx-runtime";var ga=[125,69];function xt(e){return e===0?"first":e===1?"next":"last"}function _e({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:n,rounded:r,loading:i}){return i&&e.length===0?We("span",{className:tt.list,"data-aia-pill-list-loading":"",children:ga.map((a,s)=>We("span",{"data-aia-pill-skeleton":"",className:`${we.pill} ${r?we.rounded:""} ${we.skeleton}`,style:{width:a,opacity:et[xt(s)]}},`skel-${a}`))}):We("span",{className:tt.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((a,s)=>{let v=!!n&&s===o;return We(wt,{label:a.text,state:v?"selected":xt(s),selected:v,rounded:r,loading:i,onClick:()=>t(s)},`${a.parameter}-${a.text}`)})})}import{attachProductRowWheel as fa,productImageSources as ba,productImageSrc as va,productInitial as wa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as xa,useRef as ya,useState as ka}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-fef1688d")){let e=document.createElement("style");e.id="ac-style-fef1688d",e.textContent=`/* Product strip \u2014 the React counterpart of the vanilla core's strip rules
1484
+ `,document.head.appendChild(e)}var tt={list:"aia-list-qvLqO"};import{jsx as We}from"react/jsx-runtime";var fa=[125,69];function xt(e){return e===0?"first":e===1?"next":"last"}function _e({pills:e,activePillIndex:n,onSelectPill:t,activeSelected:i,rounded:r,loading:o}){return o&&e.length===0?We("span",{className:tt.list,"data-aia-pill-list-loading":"",children:fa.map((a,d)=>We("span",{"data-aia-pill-skeleton":"",className:`${we.pill} ${r?we.rounded:""} ${we.skeleton}`,style:{width:a,opacity:et[xt(d)]}},`skel-${a}`))}):We("span",{className:tt.list,"data-aia-pill-list-loading":o?"":void 0,children:e.map((a,d)=>{let l=!!i&&d===n;return We(wt,{label:a.text,state:l?"selected":xt(d),selected:l,rounded:r,loading:o,onClick:()=>t(d)},`${a.parameter}-${a.text}`)})})}import{attachProductRowWheel as ba,productImageSources as va,productImageSrc as wa,productInitial as xa,uiStringsFor as ya}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ka,useRef as Ca,useState as Pa}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-fef1688d")){let e=document.createElement("style");e.id="ac-style-fef1688d",e.textContent=`/* Product strip \u2014 the React counterpart of the vanilla core's strip rules
1485
1485
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
1486
1486
  theming one package sees the same result in the other.
1487
1487
 
@@ -1765,7 +1765,7 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
1765
1765
  letter-spacing: 0.02em;
1766
1766
  text-align: center;
1767
1767
  }
1768
- `,document.head.appendChild(e)}var U={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"};import{jsx as de,jsxs as qe}from"react/jsx-runtime";function yt({products:e,listboxId:o,onSelect:t,onFocusChange:n,focusable:r=!0,layout:i="row",imageFallback:a="image"}){let s=e.length>0,v=ya(null);if(xa(()=>{let w=v.current;if(!(!s||!w))return fa(w)},[s]),!s)return null;let y=`${o}-products-label`;return qe("section",{className:U.section,"data-aia-products":"","data-aia-products-layout":i,role:"group","aria-labelledby":y,children:[de("div",{className:U.label,id:y,"data-aia-products-label":"",children:"Products"}),de("div",{ref:v,className:U.row,"data-aia-products-row":"",children:e.map((w,P)=>de(Ca,{product:w,id:`${o}-product-${P}`,onSelect:t,onFocusChange:n,focusable:r,imageFallback:a},w.id))})]})}function Ca({product:e,id:o,onSelect:t,onFocusChange:n,focusable:r,imageFallback:i}){let a=s=>{s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.button!==0||(s.preventDefault(),t(e))};return qe("a",{id:o,className:U.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:r?0:-1,onClick:a,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),t(e))},onFocus:()=>n?.(!0),onBlur:s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[de(Pa,{sources:ba(e.imageUrl),title:e.title,fallback:i},va(e.imageUrl)??""),qe("span",{className:U.body,children:[e.vendor?de("span",{className:U.vendor,children:e.vendor}):null,de("span",{className:U.title,children:e.title}),e.price?de("span",{className:U.price,children:e.price}):null,e.available===!1?de("span",{className:U.badge,children:"Sold out"}):null]})]})}function Pa({sources:e,title:o,fallback:t}){let[n,r]=ka(0),i=e[n],a=!!i,s=!a&&t==="initial";return qe("span",{className:U.media,"aria-hidden":"true","data-aia-product-placeholder":!a&&!s?"":void 0,"data-aia-product-initial":s?"":void 0,children:[a?de("img",{className:U.image,src:i,alt:"",loading:"lazy",decoding:"async",onError:()=>r(v=>v+1)}):null,s?wa(o):null]})}import{isOptionsGridMobileViewport as Ha,measureOptionsGrid as Fa,needsOptionsGridMeasurement as Ka,OPTIONS_GRID_MOBILE_QUERY as Ga,optionEnterDelayMs as Wa,planOptionsGrid as Pt,sameOptionRows as _a}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as qa,useLayoutEffect as Ua,useRef as St,useState as Et}from"react";import{optionsGridTemplateColumns as Sa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Ia,useRef as Ea}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
1768
+ `,document.head.appendChild(e)}var 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",badge:"aia-badge-j9Hcd"};import{jsx as pe,jsxs as qe}from"react/jsx-runtime";function yt({products:e,listboxId:n,onSelect:t,onFocusChange:i,focusable:r=!0,layout:o="row",imageFallback:a="image",strings:d=ya()}){let l=e.length>0,w=Ca(null);if(ka(()=>{let P=w.current;if(!(!l||!P))return ba(P)},[l]),!l)return null;let C=`${n}-products-label`;return qe("section",{className:Z.section,"data-aia-products":"","data-aia-products-layout":o,role:"group","aria-labelledby":C,children:[pe("div",{className:Z.label,id:C,"data-aia-products-label":"",children:d.products}),pe("div",{ref:w,className:Z.row,"data-aia-products-row":"",children:e.map((P,u)=>pe(Sa,{product:P,id:`${n}-product-${u}`,onSelect:t,onFocusChange:i,focusable:r,imageFallback:a,soldOut:d.soldOut},P.id))})]})}function Sa({product:e,id:n,onSelect:t,onFocusChange:i,focusable:r,imageFallback:o,soldOut:a}){let d=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),t(e))};return qe("a",{id:n,className:Z.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:r?0:-1,onClick:d,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[pe(Ia,{sources:va(e.imageUrl),title:e.title,fallback:o},wa(e.imageUrl)??""),qe("span",{className:Z.body,children:[e.vendor?pe("span",{className:Z.vendor,children:e.vendor}):null,pe("span",{className:Z.title,children:e.title}),e.price?pe("span",{className:Z.price,children:e.price}):null,e.available===!1?pe("span",{className:Z.badge,children:a}):null]})]})}function Ia({sources:e,title:n,fallback:t}){let[i,r]=Pa(0),o=e[i],a=!!o,d=!a&&t==="initial";return qe("span",{className:Z.media,"aria-hidden":"true","data-aia-product-placeholder":!a&&!d?"":void 0,"data-aia-product-initial":d?"":void 0,children:[a?pe("img",{className:Z.image,src:o,alt:"",loading:"lazy",decoding:"async",onError:()=>r(l=>l+1)}):null,d?xa(n):null]})}import{isOptionsGridMobileViewport as Ka,measureOptionsGrid as Ga,needsOptionsGridMeasurement as Wa,OPTIONS_GRID_MOBILE_QUERY as _a,optionEnterDelayMs as qa,planOptionsGrid as Pt,sameOptionRows as Ua}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ja,useLayoutEffect as Qa,useRef as St,useState as Et}from"react";import{optionsGridTemplateColumns as Ea}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Ta,useRef as Aa}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
1769
1769
  display: grid;
1770
1770
  grid-template-columns: repeat(
1771
1771
  auto-fit,
@@ -1801,7 +1801,7 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
1801
1801
  .aia-grid[data-scroll]::-webkit-scrollbar {
1802
1802
  display: none;
1803
1803
  }
1804
- `,document.head.appendChild(e)}import{jsx as Ta}from"react/jsx-runtime";function kt({min:e="16rem",max:o,gap:t,scroll:n=!1,maxHeight:r,scrollResetKey:i,cols:a,template:s,innerRef:v,className:y,children:w,...P}){let u=Ea(null);Ia(()=>{if(i===void 0)return;let I=u.current;I&&(I.scrollTop=0)},[i]);let f={"--aia-grid-min":e};return o&&(f["--aia-grid-max"]=o),t&&(f["--aia-grid-gap"]=t),r&&(f["--aia-grid-max-height"]=r),a&&(f.gridTemplateColumns=Sa(a)),s&&(f.gridTemplateColumns=s),Ta("div",{ref:I=>{u.current=I,v?.(I)},className:y?`aia-grid ${y}`:"aia-grid","data-scroll":n||void 0,style:f,...P,children:w})}import{formatOptionCount as Aa,OPTION_ENTER_DELAY_VAR as Ra,optionImageSources as Oa,optionLabel as Da,sanitizeOptionIconSvg as La}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as za,useMemo as Ma,useRef as Na,useState as at}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
1804
+ `,document.head.appendChild(e)}import{jsx as Ra}from"react/jsx-runtime";function kt({min:e="16rem",max:n,gap:t,scroll:i=!1,maxHeight:r,scrollResetKey:o,cols:a,template:d,innerRef:l,className:w,children:C,...P}){let u=Aa(null);Ta(()=>{if(o===void 0)return;let I=u.current;I&&(I.scrollTop=0)},[o]);let b={"--aia-grid-min":e};return n&&(b["--aia-grid-max"]=n),t&&(b["--aia-grid-gap"]=t),r&&(b["--aia-grid-max-height"]=r),a&&(b.gridTemplateColumns=Ea(a)),d&&(b.gridTemplateColumns=d),Ra("div",{ref:I=>{u.current=I,l?.(I)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":i||void 0,style:b,...P,children:C})}import{formatOptionCount as Oa,OPTION_ENTER_DELAY_VAR as Da,optionImageSources as La,optionLabel as za,sanitizeOptionIconSvg as Ma}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Na,useMemo as Ba,useRef as Ha,useState as at}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
1805
1805
  position: relative;
1806
1806
  /* Clip, not visible: the entrance rise below runs on the inner content,
1807
1807
  and a transformed box extends its scroll container's scrollable area.
@@ -2198,7 +2198,7 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
2198
2198
  opacity: 0;
2199
2199
  }
2200
2200
  }
2201
- `,document.head.appendChild(e)}var W={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"};import{jsx as Pe,jsxs as Ba}from"react/jsx-runtime";function Ct({option:e,isHighlighted:o,onSelect:t,onHighlight:n,onUnhighlight:r,id:i,loading:a,showIcon:s=!0,showImage:v=!0,showCount:y=!0,scrollHint:w,enterDelayMs:P=0}){let[u]=at(P),[f,I]=at(!1),D=v?Oa(e.image_url):[],L=D[0]??null,[H,E]=at([]),S=D.find(N=>!H.includes(N))??null,z=Ma(()=>!L&&s&&e.icon_svg?La(e.icon_svg):null,[L,s,e.icon_svg]),R=y?Aa(e.item_count):null,k=Na(void 0);za(()=>()=>clearTimeout(k.current),[]);let M=()=>{a||!e.is_tappable||f||(I(!0),t(e),clearTimeout(k.current),k.current=setTimeout(()=>I(!1),170))},Q=[W.item,o&&!a?W.highlighted:"",e.is_tappable?W.tappable:W.nonTappable,f?W.pressed:"",w?W.scrollHint:""].filter(Boolean).join(" ");return Pe("div",{id:i,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":z&&e.icon?e.icon:void 0,"data-aia-image":L?"":void 0,"data-aia-item-count":R!==null?e.item_count:void 0,"aria-selected":o,className:Q,style:{[Ra]:`${u}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:M,onKeyDown:N=>{!a&&e.is_tappable&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),M())},onMouseEnter:!a&&e.is_tappable?n:void 0,onMouseLeave:r,children:Ba("span",{className:W.content,children:[L&&Pe("span",{className:`${W.image} magicx-aia-option-image`,"aria-hidden":"true",children:Pe("img",{src:S??L,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:S===null,onError:()=>{S!==null&&E(N=>[...N,S])}})}),z&&Pe("span",{className:`${W.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:z}}),Pe("span",{className:W.text,children:Da(e)}),e.tag&&Pe("span",{className:W.tag,children:e.tag}),R!==null&&Pe("span",{className:`${W.count} magicx-aia-option-count`,children:R})]})})}import{jsx as It}from"react/jsx-runtime";function ja(){let[e,o]=Et(Ha);return qa(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Ga),n=()=>o(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]),e}function Tt({options:e,activeIndex:o,onSelect:t,onHighlight:n,onUnhighlight:r,listboxId:i,loading:a,groupKey:s="",optionsPosition:v="below",showIcons:y=!0,showImages:w=!0,showCounts:P=!0}){let u=ja(),f=St(null),[I,D]=Et(null),L=St(null);Ua(()=>{if(a&&_a(L.current,e))return;L.current=a?null:e;let E=f.current,z=E&&!a&&Ka(e.length,u)?Fa(E):null;D(z?Pt(e.length,u,z.rowWidths,z.gridWidth):null)},[e,u,a]);let H=I??Pt(e.length,u,null,null);return It(kt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:s,template:H.template,maxHeight:H.maxHeight,innerRef:E=>{f.current=E},"data-aia-group":s,children:e.map((E,S)=>It(Ct,{option:E,isHighlighted:S===o,onSelect:t,onHighlight:()=>n(S),onUnhighlight:r?()=>r(S):void 0,id:`${i}-option-${S}`,loading:a,showIcon:y,showImage:w,showCount:P,scrollHint:!a&&H.scrollHintIndices.includes(S),enterDelayMs:a?0:Wa(S,H.cols,e.length,v)},`${s}\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 {
2201
+ `,document.head.appendChild(e)}var _={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"};import{jsx as Ce,jsxs as Fa}from"react/jsx-runtime";function Ct({option:e,isHighlighted:n,onSelect:t,onHighlight:i,onUnhighlight:r,id:o,loading:a,showIcon:d=!0,showImage:l=!0,showCount:w=!0,scrollHint:C,enterDelayMs:P=0}){let[u]=at(P),[b,I]=at(!1),D=l?La(e.image_url):[],L=D[0]??null,[F,E]=at([]),S=D.find(B=>!F.includes(B))??null,z=Ba(()=>!L&&d&&e.icon_svg?Ma(e.icon_svg):null,[L,d,e.icon_svg]),M=w?Oa(e.item_count):null,x=Ha(void 0);Na(()=>()=>clearTimeout(x.current),[]);let N=()=>{a||!e.is_tappable||b||(I(!0),t(e),clearTimeout(x.current),x.current=setTimeout(()=>I(!1),170))},V=[_.item,n&&!a?_.highlighted:"",e.is_tappable?_.tappable:_.nonTappable,b?_.pressed:"",C?_.scrollHint:""].filter(Boolean).join(" ");return Ce("div",{id:o,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":z&&e.icon?e.icon:void 0,"data-aia-image":L?"":void 0,"data-aia-item-count":M!==null?e.item_count:void 0,"aria-selected":n,className:V,style:{[Da]:`${u}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:N,onKeyDown:B=>{!a&&e.is_tappable&&(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),N())},onMouseEnter:!a&&e.is_tappable?i:void 0,onMouseLeave:r,children:Fa("span",{className:_.content,children:[L&&Ce("span",{className:`${_.image} magicx-aia-option-image`,"aria-hidden":"true",children:Ce("img",{src:S??L,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:S===null,onError:()=>{S!==null&&E(B=>[...B,S])}})}),z&&Ce("span",{className:`${_.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:z}}),Ce("span",{className:_.text,children:za(e)}),e.tag&&Ce("span",{className:_.tag,children:e.tag}),M!==null&&Ce("span",{className:`${_.count} magicx-aia-option-count`,children:M})]})})}import{jsx as It}from"react/jsx-runtime";function Ya(){let[e,n]=Et(Ka);return ja(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(_a),i=()=>n(t.matches);return i(),t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function Tt({options:e,activeIndex:n,onSelect:t,onHighlight:i,onUnhighlight:r,listboxId:o,loading:a,groupKey:d="",optionsPosition:l="below",showIcons:w=!0,showImages:C=!0,showCounts:P=!0}){let u=Ya(),b=St(null),[I,D]=Et(null),L=St(null);Qa(()=>{if(a&&Ua(L.current,e))return;L.current=a?null:e;let E=b.current,z=E&&!a&&Wa(e.length,u)?Ga(E):null;D(z?Pt(e.length,u,z.rowWidths,z.gridWidth):null)},[e,u,a]);let F=I??Pt(e.length,u,null,null);return It(kt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:d,template:F.template,maxHeight:F.maxHeight,innerRef:E=>{b.current=E},"data-aia-group":d,children:e.map((E,S)=>It(Ct,{option:E,isHighlighted:S===n,onSelect:t,onHighlight:()=>i(S),onUnhighlight:r?()=>r(S):void 0,id:`${o}-option-${S}`,loading:a,showIcon:w,showImage:C,showCount:P,scrollHint:!a&&F.scrollHintIndices.includes(S),enterDelayMs:a?0:qa(S,F.cols,e.length,l)},`${d}\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 {
2202
2202
  display: flex;
2203
2203
  flex-direction: column;
2204
2204
  gap: var(--aia-stack-space, 0.5rem);
@@ -2213,7 +2213,7 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
2213
2213
  align-items: end;
2214
2214
  }
2215
2215
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
2216
- `,document.head.appendChild(e)}import{jsx as Qa}from"react/jsx-runtime";function At({space:e,align:o="stretch",className:t,children:n,...r}){let i=e?{"--aia-stack-space":e}:void 0;return Qa("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:i,...r,children:n})}import{jsx as j,jsxs as it}from"react/jsx-runtime";var Ja=[159,119,164],ei=()=>{},Rt=()=>{};function ti(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,n]=Xa(o);if(je(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>n(r.matches);return r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function ai(e,o){let t=Ue(null);je(()=>{let n=e.current,r=o.current;if(!n||!r)return;let i=n.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==i&&(t.current.controller.destroy(),t.current=null),i&&!t.current){t.current={grid:i,controller:Ya({dropdown:n,grid:i,button:r})};return}t.current?.controller.update()}),je(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function ot({suggestions:e,activeIndex:o,onSelect:t,onHighlight:n,onUnhighlight:r,isOpen:i,id:a,className:s,pills:v,onPillClick:y,showPills:w=!0,onSkip:P,showSkipButton:u=!0,showOptionIcons:f=!0,showOptionImages:I=!0,showOptionCounts:D=!0,skipDisabled:L=!1,activeSelected:H=!1,isLoading:E=!1,skeletonExiting:S=!1,isInputEmpty:z=!1,products:R,onProductSelect:k,onProductFocusChange:M,productsLayout:Q="row",productImageFallback:N="image",formatType:ce="options",dateView:ee=null,selectedDateIso:_=null,selectedDateRange:pe=null,dateRangeStart:m=null,onPreviousMonth:xe,onNextMonth:he,optionsPosition:te="below",mode:ue}){let ae=ti(ue),me=ae!==void 0,G=Ue(null),Z=Ue(null);ai(G,Z),je(()=>{if(G.current)return Za(G.current)},[]);let ge=e[0]?.options??[],d=!!(v&&v.length>0&&y),h=!!(R&&R.length>0),g=i&&(ge.length>0||w&&d||E||h),b={suggestions:e,activeIndex:o,pills:v,showPills:w,showSkipButton:u,showOptionIcons:f,showOptionImages:I,showOptionCounts:D,skipDisabled:L,activeSelected:H,isLoading:E,skeletonExiting:S,isInputEmpty:z,products:R,formatType:ce,dateView:ee,selectedDateIso:_,selectedDateRange:pe,dateRangeStart:m},C=Ue(b);g&&(C.current=b);let l=g?b:C.current,F=l.suggestions[0],B=F?.options??[],ie=l.activeIndex>=0&&!!B[l.activeIndex]?.is_tappable,$=!!(l.pills&&l.pills.length>0&&y),x=l.showPills&&$,ye=l.showPills&&!$&&l.isLoading,Se=x||ye,oe=$&&l.showSkipButton&&!l.isInputEmpty&&!!P,c=l.pills?.[0]?.text,ne=$a(l.formatType)&&l.dateView!=null,ke=B.length>0&&!ne,fe=B.length>0&&ne&&!l.isLoading,Re=l.isLoading&&!ke&&!fe,re=l.products??[];return it("div",{ref:G,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":te,"data-mode":ae,"data-aia-loading":l.isLoading?"":void 0,"data-aia-skeleton-exiting":l.skeletonExiting?"":void 0,"data-aia-has-products":re.length>0?"":void 0,className:`${me?"magicx-aia ":""}${se.dropdown} ${g?se.visible:""} ${s??""}`,onMouseDown:be=>be.preventDefault(),children:[it(At,{space:"8px",children:[(Se||oe)&&it(Le,{noWrap:!0,className:se.pillBar,"data-aia-pillbar":"",children:[Se&&j("span",{className:se.pillScroll,"data-aia-pill-scroll":"",children:j(_e,{pills:l.pills??[],activePillIndex:0,activeSelected:l.activeSelected,onSelectPill:y??(()=>{}),rounded:!0,loading:l.isLoading})}),oe&&j("button",{type:"button",tabIndex:-1,className:se.skip,"data-aia-skip":"",disabled:l.isLoading||l.skipDisabled,"aria-label":c?`Skip ${c}`:"Skip",onClick:P,children:"skip"})]}),ke&&j(Tt,{options:B,activeIndex:l.activeIndex,onSelect:t,onHighlight:n,onUnhighlight:r,listboxId:a,loading:l.isLoading,groupKey:F?`${F.parameter} ${F.text}`:"",optionsPosition:te,showIcons:l.showOptionIcons,showImages:l.showOptionImages,showCounts:l.showOptionCounts}),fe&&l.dateView&&j(ft,{options:B,activeIndex:l.activeIndex,listboxId:a,view:l.dateView,selection:{selectedIso:l.selectedDateIso??null,selectedRange:l.selectedDateRange??null,rangeStart:l.dateRangeStart??null},onSelect:t,onHighlight:n,onUnhighlight:r,onPreviousMonth:xe??Rt,onNextMonth:he??Rt}),Re&&j("div",{className:se.skeletonBars,"data-aia-skeleton-bars":"",children:Ja.map(be=>j("span",{className:se.skeletonBar,style:{width:be}},`bar-${be}`))}),j(yt,{products:re,listboxId:a,onSelect:k??ei,onFocusChange:M,focusable:g,layout:Q,imageFallback:N}),j(vt,{isOptionHighlighted:ie,isInputEmpty:l.isInputEmpty})]}),j("button",{ref:Z,type:"button",tabIndex:-1,className:se.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Va,"aria-hidden":"true",children:j("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:j("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as fi,ModeController as bi,setCursorOffset as vi}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.aia-submitButton-otz7H {
2216
+ `,document.head.appendChild(e)}import{jsx as Za}from"react/jsx-runtime";function At({space:e,align:n="stretch",className:t,children:i,...r}){let o=e?{"--aia-stack-space":e}:void 0;return Za("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":n,style:o,...r,children:i})}import{jsx as $,jsxs as it}from"react/jsx-runtime";var ti=[159,119,164],ai=()=>{},Rt=()=>{};function ii(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,i]=ei(n);if(je(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>i(r.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function oi(e,n){let t=Ue(null);je(()=>{let i=e.current,r=n.current;if(!i||!r)return;let o=i.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==o&&(t.current.controller.destroy(),t.current=null),o&&!t.current){t.current={grid:o,controller:$a({dropdown:i,grid:o,button:r})};return}t.current?.controller.update()}),je(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function ot({suggestions:e,activeIndex:n,onSelect:t,onHighlight:i,onUnhighlight:r,isOpen:o,id:a,className:d,pills:l,onPillClick:w,showPills:C=!0,onSkip:P,showSkipButton:u=!0,showOptionIcons:b=!0,showOptionImages:I=!0,showOptionCounts:D=!0,skipDisabled:L=!1,activeSelected:F=!1,isLoading:E=!1,skeletonExiting:S=!1,isInputEmpty:z=!1,language:M,products:x,onProductSelect:N,onProductFocusChange:V,productsLayout:B="row",productImageFallback:he="image",formatType:ae="options",dateView:q=null,selectedDateIso:ue=null,selectedDateRange:m=null,dateRangeStart:xe=null,onPreviousMonth:ge,onNextMonth:me,optionsPosition:ie="below",mode:fe}){let oe=ii(fe),J=oe!==void 0,U=Ue(null),ne=Ue(null);oi(U,ne),je(()=>{if(U.current)return Va(U.current)},[]);let s=e[0]?.options??[],g=!!(l&&l.length>0&&w),v=!!(x&&x.length>0),f=o&&(s.length>0||C&&g||E||v),y={suggestions:e,activeIndex:n,pills:l,showPills:C,showSkipButton:u,showOptionIcons:b,showOptionImages:I,showOptionCounts:D,skipDisabled:L,activeSelected:F,isLoading:E,skeletonExiting:S,isInputEmpty:z,products:x,formatType:ae,dateView:q,selectedDateIso:ue,selectedDateRange:m,dateRangeStart:xe},R=Ue(y);f&&(R.current=y);let c=f?y:R.current,H=Ja(M),j=c.suggestions[0],Q=j?.options??[],k=c.activeIndex>=0&&!!Q[c.activeIndex]?.is_tappable,re=!!(c.pills&&c.pills.length>0&&w),Ae=c.showPills&&re,be=c.showPills&&!re&&c.isLoading,p=Ae||be,se=re&&c.showSkipButton&&!c.isInputEmpty&&!!P,ye=c.pills?.[0]?.text,ve=Xa(c.formatType)&&c.dateView!=null,Pe=Q.length>0&&!ve,le=Q.length>0&&ve&&!c.isLoading,Re=c.isLoading&&!Pe&&!le,G=c.products??[];return it("div",{ref:U,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":ie,"data-mode":oe,"data-aia-loading":c.isLoading?"":void 0,"data-aia-skeleton-exiting":c.skeletonExiting?"":void 0,"data-aia-has-products":G.length>0?"":void 0,className:`${J?"magicx-aia ":""}${de.dropdown} ${f?de.visible:""} ${d??""}`,onMouseDown:W=>W.preventDefault(),children:[it(At,{space:"8px",children:[(p||se)&&it(Le,{noWrap:!0,className:de.pillBar,"data-aia-pillbar":"",children:[p&&$("span",{className:de.pillScroll,"data-aia-pill-scroll":"",children:$(_e,{pills:c.pills??[],activePillIndex:0,activeSelected:c.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:c.isLoading})}),se&&$("button",{type:"button",tabIndex:-1,className:de.skip,"data-aia-skip":"",disabled:c.isLoading||c.skipDisabled,"aria-label":ye?`${H.skipLabel} ${ye}`:H.skipLabel,onClick:P,children:H.skip})]}),Pe&&$(Tt,{options:Q,activeIndex:c.activeIndex,onSelect:t,onHighlight:i,onUnhighlight:r,listboxId:a,loading:c.isLoading,groupKey:j?`${j.parameter} ${j.text}`:"",optionsPosition:ie,showIcons:c.showOptionIcons,showImages:c.showOptionImages,showCounts:c.showOptionCounts}),le&&c.dateView&&$(ft,{options:Q,activeIndex:c.activeIndex,listboxId:a,view:c.dateView,selection:{selectedIso:c.selectedDateIso??null,selectedRange:c.selectedDateRange??null,rangeStart:c.dateRangeStart??null},onSelect:t,onHighlight:i,onUnhighlight:r,onPreviousMonth:ge??Rt,onNextMonth:me??Rt}),Re&&$("div",{className:de.skeletonBars,"data-aia-skeleton-bars":"",children:ti.map(W=>$("span",{className:de.skeletonBar,style:{width:W}},`bar-${W}`))}),$(yt,{products:G,listboxId:a,onSelect:N??ai,onFocusChange:V,focusable:f,layout:B,imageFallback:he,strings:H}),$(vt,{isOptionHighlighted:k,isInputEmpty:c.isInputEmpty,strings:H})]}),$("button",{ref:ne,type:"button",tabIndex:-1,className:de.scrollArrow,"data-aia-scroll-arrow":"","aria-label":H.scrollArrow,"aria-hidden":"true",children:$("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:$("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as wi,ModeController as xi,setCursorOffset as yi,uiStringsFor as ki}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as ni}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.aia-submitButton-otz7H {
2217
2217
  flex-shrink: 0;
2218
2218
  width: 32px;
2219
2219
  height: 32px;
@@ -2266,5 +2266,5 @@ import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END a
2266
2266
  );
2267
2267
  cursor: default;
2268
2268
  }
2269
- `,document.head.appendChild(e)}var Ot={submitButton:"aia-submitButton-otz7H"};import{jsx as nt}from"react/jsx-runtime";function Dt({disabled:e,onClick:o}){return nt("button",{type:"button","data-aia-submit":"",className:Ot.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),o()},"aria-label":"Submit",children:nt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:nt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ii,dateSelectionFor as oi,identifiedParamLabel as ni}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Bt,useEffect as Me,useRef as K,useState as ri}from"react";import{useRef as Lt}from"react";function zt(e){let o=Lt(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),n=Lt({key:"",overrides:void 0});if(n.current.key!==t){let r={};for(let i of Object.keys(e??{})){let a=(s,v,y)=>{let w=o.current?.[i];return w?w(s,v,y):[]};r[i]=a}n.current={key:t,overrides:e?r:void 0}}return{overrides:n.current.overrides,key:t}}import{useRef as Mt}from"react";function Nt(e){let o=Mt(e);o.current=e;let t=Mt(null);t.current===null&&(t.current={fetch:(r,i)=>{let a=o.current;return a?a.fetch(r,i):Promise.reject(new Error("products config removed"))},transform:r=>o.current?.transform(r)??[],get limit(){return o.current?.limit}});let n=e!==void 0;return{config:n?t.current:void 0,enabled:n}}var si={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 rt({onSubmit:e,onResult:o,onError:t,optionOverrides:n,maskCompletedText:r,apiConfig:i,additionalContext:a,language:s,visitorId:v,columns:y=2,dropdownTrigger:w,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:f,showOptionIcons:I,showOptionImages:D,showOptionCounts:L,showSkipButton:H,showProducts:E,productImageFallback:S="image",onFocus:z,onBlur:R,value:k,completedParams:M,onChange:Q,onParamsChange:N,products:ce,onProductSelect:ee,source:_,setCursor:pe}){let m=K(null),[xe,he]=ri(null),te=K(e);te.current=e;let ue=K(o);ue.current=o;let ae=K(t);ae.current=t;let me=K(Q);me.current=Q;let G=K(N);G.current=N;let Z=K(z);Z.current=z;let ge=K(R);ge.current=R;let d=K(pe);d.current=pe;let h=K(ee);h.current=ee;let g=K(v);g.current=v;let b=K(()=>{let p=g.current;return typeof p=="function"?p():p}).current,C=Nt(ce),l=zt(n);Me(()=>{if(typeof document>"u")return;let p=new ii(document.createElement("div"),{renderMode:"headless",apiConfig:i,additionalContext:a,language:s,visitorId:b,optionOverrides:l.overrides,maskCompletedText:r,columns:y,dropdownTrigger:w,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:f,showProducts:E,source:_,value:k,completedParams:M,onSubmit:(...O)=>te.current?.(...O),onResult:(...O)=>ue.current?.(...O),onError:(...O)=>ae.current?.(...O),onChange:(...O)=>me.current?.(...O),onParamsChange:(...O)=>G.current?.(...O),onFocus:()=>Z.current?.(),onBlur:()=>ge.current?.(),onProductSelect:O=>h.current?.(O),setCursor:O=>d.current?.(O),products:C.config});m.current=p,he(p.getState());let q=p.subscribe(O=>he(O));return()=>{q(),p.destroy(),m.current===p&&(m.current=null)}},[]),Me(()=>{k!==void 0&&m.current?.setValue(k)},[k]),Me(()=>{M!==void 0&&m.current?.setCompletedParams(M)},[M]);let F=JSON.stringify(i??null),B;try{B=JSON.stringify(a??null)}catch{B="[unstringifiable]"}Me(()=>{m.current?.update({apiConfig:i,additionalContext:a,language:s,optionOverrides:l.overrides,dropdownTrigger:w,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:f,showProducts:E})},[F,B,s,l.key,w,P,u,f,E]);let ie=K(!1);Me(()=>{if(!ie.current){ie.current=!0;return}m.current?.update({products:C.config})},[C.enabled]);let $=K(null);$.current===null&&($.current={handleTextChange:p=>m.current?.handleTextChange(p),handleKeyDown:p=>{let q="nativeEvent"in p?p.nativeEvent:p;m.current?.handleKeyDown(q)},setFocused:p=>m.current?.setFocused(p),startEditingParam:p=>m.current?.startEditingParam(p),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:p=>m.current?.handleCaretAfterInput(p),handleCaretMove:p=>m.current?.handleCaretMove(p),replaceEditingRange:p=>m.current?.replaceEditingRange(p)??!1,setActivePill:p=>m.current?.setActivePill(p),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),recordSubmit:p=>m.current?.recordSubmit(p),selectOption:p=>m.current?.selectOption(p),selectProduct:p=>m.current?.selectProduct(p),setActiveDropdownIndex:p=>m.current?.setActiveDropdownIndex(p),clearHighlight:p=>m.current?.clearHighlight(p),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let x=$.current,ye=Bt(p=>{let q=p.target.value,$e=q.length>0&&!p.nativeEvent?.isComposing&&q[0]!==q[0].toUpperCase()?q[0].toUpperCase()+q.slice(1):q;m.current?.handleTextChange($e)},[]),Se=Bt(p=>{m.current?.handleKeyDown(p.nativeEvent)},[]),oe=m.current,c=xe??si,ne=k!==void 0?k:c.text,ke=M!==void 0?M:c.completedParams,fe=c.actionableSuggestions,Re=fe[0],re=oe?.listboxId??"",be=c.activeDropdownIndex>=0&&oe?`${re}-option-${c.activeDropdownIndex}`:void 0,V=c.editingParam,ve=c.editingIdentified,Ie=V?{parameter:V.suggestionParameter,text:V.suggestionPlaceholder,required:!0,options:V.options}:ve?{parameter:ve.parameter,text:ni(ve.parameter),required:!0,options:[]}:null,Be=c.dropdownSuggestion??Ie??Re,Ze=Ie?[Ie]:fe,Oe=oi(c),He=!oe||c.dropdownLoading;return{completedParams:ke,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:fe,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:x.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:He,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:re,error:c.error,products:c.products,customFields:c.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:V,editingIdentified:ve,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:ne,placeholder:c.placeholderText||void 0,onChange:ye,onKeyDown:Se,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":be,"aria-autocomplete":"list","aria-controls":re},reset:x.reset,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:Be?[{...Be,options:c.dropdownOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:c.isDropdownOpen,id:re,pills:Ze,activeSelected:c.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(H??!0)&&!V&&!ve,showOptionIcons:I??!0,showOptionImages:D??!0,showOptionCounts:L??!0,skipDisabled:c.inSelectionAnimation,isLoading:He,skeletonExiting:c.skeletonExiting,isInputEmpty:ne.trim().length===0,products:c.products,productImageFallback:S,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:c.activeFormatType,dateView:c.dateView,selectedDateIso:Oe.selectedIso,selectedDateRange:Oe.selectedRange,dateRangeStart:Oe.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:P??"below"}}}import{chipIdFromTap as li,extractPlainText as Ht,getCursorOffset as Ft,keepCaretOnChip as di,plainTextLength as ci,renderEditableContent as pi,setCursorOffset as Kt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Y,useEffect as Qe,useLayoutEffect as st,useRef as Te}from"react";var Ye;function hi(){if(Ye!==void 0)return Ye;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ye=e.contentEditable==="plaintext-only",Ye}function Gt(e){let{segments:o,showChipIcons:t=!0,showChipImages:n=!0,newParamId:r,editingParam:i,editingIdentified:a,editingAnchor:s,caretOffset:v,placeholderText:y,isFocused:w,isDropdownOpen:P,listboxId:u,activeDescendantId:f,autoFocus:I,handleTextChange:D,handleKeyDown:L,handleCaretAfterInput:H,handleCaretMove:E,startEditingParam:S,replaceEditingRange:z,setFocused:R}=e,k=Te(null),M=Te(!1),Q=Te(""),N=Te(""),ce=Te(null),ee=Te(0);ce.current=v,Qe(()=>{if(!I)return;let d=k.current;if(!d)return;document.activeElement===d?R(!0):d.focus();let h=d.ownerDocument??document,g=h.getSelection(),b=g&&g.rangeCount>0&&d.contains(g.anchorNode);if(g&&!b){let C=h.createRange();C.selectNodeContents(d),C.collapse(!0),g.removeAllRanges(),g.addRange(C)}},[I,R]),Qe(()=>{let d=k.current;if(!d)return;let h=d.ownerDocument??document,g=()=>{let b=h.getSelection();if(!b||b.rangeCount===0||!b.anchorNode||!d.contains(b.anchorNode))return;let C=b.anchorNode,l=C.nodeType===Node.ELEMENT_NODE?C:C.parentElement,B=(b.isCollapsed?l?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ie=i?.id??a?.id??null;if(B&&B!==ie){S(B);return}performance.now()-ee.current<50||E(Ft(d))};return h.addEventListener("selectionchange",g),()=>h.removeEventListener("selectionchange",g)},[i,a,S,E]),Qe(()=>{let d=k.current;if(!d)return;let h=g=>{let b=li(d,g.target);b&&(S(b),di(d,b))};return d.addEventListener("click",h),()=>d.removeEventListener("click",h)},[S]),st(()=>{let d=k.current;d&&pi({input:d,segments:o,newParamId:r,editingParamId:i?.id??null,placeholderText:y??"",isFocused:w,showChipIcons:t,showChipImages:n})},[o,r,i,y,w,t,n]),st(()=>{let d=Q.current,h=r??"";if(Q.current=h,!h||h===d)return;let g=k.current;if(!g)return;g.focus();let b=ce.current??ci(g);Kt(g,b)},[r]),st(()=>{let d=N.current,h=i?.id??"";if(N.current=h,!h||h===d||s==null)return;let g=k.current;g&&Kt(g,s)},[i,s]);let _=Y(()=>{if(M.current)return;let d=k.current;if(!d)return;let h=Ht(d),b=h.length>0&&h[0]!==h[0].toUpperCase()?h[0].toUpperCase()+h.slice(1):h;D(b)},[D]),pe=Y(()=>{ee.current=performance.now(),_();let d=k.current;d&&H(Ft(d))},[_,H]);Qe(()=>{let d=k.current;if(!d)return;let h=g=>{let b=g,C=b.inputType;if(C==="insertParagraph"||C==="insertLineBreak"||C==="insertFromDrop"){g.preventDefault();return}if(C.startsWith("insert")||C.startsWith("delete")){let l=C.startsWith("delete")?"":b.data??"";z(l)&&g.preventDefault()}};return d.addEventListener("beforeinput",h),()=>d.removeEventListener("beforeinput",h)},[z]);let m=Y(()=>{M.current=!0},[]),xe=Y(()=>{M.current=!1,_()},[_]),he=Y(d=>{d.preventDefault();let h=k.current;if(!h)return;let g=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!g)return;let b=h.ownerDocument??document,C=b.getSelection();if(!C||C.rangeCount===0)return;let l=C.getRangeAt(0);if(!h.contains(l.startContainer))return;l.deleteContents();let F=b.createTextNode(g);l.insertNode(F),l.setStartAfter(F),l.collapse(!0),C.removeAllRanges(),C.addRange(l),_()},[_]),te=Y(d=>L(d),[L]),ue=Y(()=>R(!0),[R]),ae=Y(()=>R(!1),[R]),me=Y(()=>k.current?.focus(),[]),G=Y(()=>k.current?.blur(),[]),Z=Y(()=>{let d=k.current;return d?Ht(d):""},[]),ge=hi()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:ge,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":P,"aria-activedescendant":f,spellCheck:!0,enterKeyHint:"send",onInput:pe,onKeyDown:te,onCompositionStart:m,onCompositionEnd:xe,onPaste:he,onFocus:ue,onBlur:ae},getPlainText:Z,focus:me,blur:G}}import{jsx as Ae,jsxs as dt}from"react/jsx-runtime";function wi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var xi=ui(function({onSubmit:o,onResult:t,onError:n,optionOverrides:r,maskCompletedText:i,className:a,apiConfig:s,additionalContext:v,language:y,visitorId:w,columns:P,pillPlacement:u="dropdown",mode:f="auto",optionsPosition:I="below",animations:D=!0,dropdownTrigger:L,closeDropdownOnBlur:H,showNonTappableOptions:E,showOptionIcons:S=!0,showChipIcons:z=!0,showChipImages:R=!0,showOptionImages:k=!0,showOptionCounts:M=!0,showSkipButton:Q,showProducts:N,productsLayout:ce,productImageFallback:ee,autoFocus:_=!0,onFocus:pe,onBlur:m,value:xe,completedParams:he,onChange:te,onParamsChange:ue,products:ae,onProductSelect:me,submitButton:G,resetOnSubmit:Z=!0},ge){let d=Ne(null),h=Ne(null),g=Ne(()=>{}),b=Ne(null),C=Ne(null);Wt(()=>{let T=d.current;if(T)return b.current?b.current.setMode(f):b.current=new bi(T,f),()=>{b.current?.destroy(),b.current=null}},[f]);let l=lt(T=>{let X=C.current?.current;X&&(X.focus(),vi(X,T))},[]),{completedParams:F,skippedParams:B,identifiedParams:ie,isReady:$,customFields:x,suggestionPills:ye,setActivePill:Se,skipActivePill:oe,segments:c,newParamId:ne,clearNewParamId:ke,placeholderText:fe,isFocused:Re,isDropdownOpen:re,isActivePillSelected:be,isLoading:V,activeIndex:ve,listboxId:Ie,handleTextChange:Be,handleKeyDown:Ze,setFocused:Oe,editingParam:He,editingIdentified:p,editingAnchor:q,caretOffset:O,startEditingParam:$e,handleCaretAfterInput:_t,handleCaretMove:qt,replaceEditingRange:Ut,dropdownProps:jt,reset:Fe,recordSubmit:ct}=rt({onSubmit:T=>g.current(T),onResult:t,onError:n,optionOverrides:r,maskCompletedText:i,apiConfig:s,additionalContext:v,language:y,visitorId:w,columns:P,dropdownTrigger:L,optionsPosition:I,closeDropdownOnBlur:H,showNonTappableOptions:E,showOptionIcons:S,showOptionImages:k,showOptionCounts:M,showSkipButton:Q,showProducts:N,onFocus:pe,onBlur:m,value:xe,completedParams:he,onChange:te,onParamsChange:ue,products:ae,onProductSelect:me,source:"full-sdk",setCursor:l});Wt(()=>{if(!ne)return;let T=window.setTimeout(()=>ke(),650);return()=>window.clearTimeout(T)},[ne,ke]);let Qt=ve>=0?`${Ie}-option-${ve}`:void 0,{inputRef:Ve,editorProps:Yt,focus:Ke,blur:pt,getPlainText:ht}=Gt({segments:c,newParamId:ne,editingParam:He,editingIdentified:p,editingAnchor:q,caretOffset:O,placeholderText:fe,isFocused:Re,showChipIcons:z,showChipImages:R,isDropdownOpen:re,listboxId:Ie,activeDescendantId:Qt,autoFocus:_,handleTextChange:Be,handleKeyDown:Ze,handleCaretAfterInput:_t,handleCaretMove:qt,startEditingParam:$e,replaceEditingRange:Ut,setFocused:Oe});C.current=Ve,gi(()=>{let T=h.current,X=Ve.current;if(!T||!X)return;let De=()=>{let mt=T.firstElementChild;if(!mt)return;let Xt=mt.getBoundingClientRect(),Jt=X.getBoundingClientRect();Xt.top>=Jt.bottom-2?T.setAttribute("data-aia-pill-wrapped",""):T.removeAttribute("data-aia-pill-wrapped")};De();let ut=new ResizeObserver(De);return ut.observe(X),()=>ut.disconnect()},[c,ye.length,V,Ve]),mi(ge,()=>({focus:Ke,blur:pt,reset:Fe,setMode:T=>b.current?.setMode(T),skipActivePill:oe}),[Ke,pt,Fe,oe]);let Ge=!!c.length||F.length>0,Xe=lt(T=>{if(!Ge)return;let X=ht(),De=fi(X,F,B,{identifiedParams:ie,isReady:$,customFields:x});T&&ct(De),o(De),Z&&Fe()},[ct,Z,Ge,F,B,ie,$,x,o,Fe,ht]);g.current=()=>Xe(!1);let Zt=lt(T=>{T.target?.closest("[data-aia-pill]")||Ke()},[Ke]),$t=u==="inline",Vt=u==="dropdown";return dt("div",{ref:d,className:`magicx-aia ${Ce.container} ${a??""}`,"data-pill-placement":u,"data-options-position":I,"data-animations":D?"on":"off","data-mode":wi(f),children:[Ae(ot,{...jt,showPills:Vt,productsLayout:ce,productImageFallback:ee}),dt("div",{className:Ce.inputWrapper,"data-aia-input-wrapper":"",onClick:Zt,children:[dt("div",{className:Ce.editorArea,"data-aia-editor":"",children:[Ae("div",{...Yt,className:Ce.input,"data-aia-input":""}),$t&&(V||ye.length>0)&&Ae("span",{ref:h,className:Ce.pillListContainer,"data-aia-pill-list-container":"",children:Ae(_e,{pills:ye,activePillIndex:0,activeSelected:be,onSelectPill:Se,loading:V})})]}),G===null?null:G===void 0?Ae(Dt,{disabled:!Ge,onClick:()=>Xe(!0)}):Ae("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ce.submitSlot,onClick:T=>{Ge&&(T.stopPropagation(),Xe(!0))},children:G})]})]})});export{xi as AIAutocomplete,ot as AIAutocompleteDropdown,gn as DATE_RANGE_META_END,fn as DATE_RANGE_META_START,bn as DEFAULT_OPTION_COUNT_UNIT,An as PRODUCT_PATH_PREFIX,Fn as WEEKDAY_LABELS,hn as buildSubmitResult,un as cellDay,mn as cellIso,vn as dateCellMarks,wn as formatDate,xn as formatDateRange,yn as formatOptionCount,kn as isoDate,Cn as monthLabel,Pn as optionCountLabel,Sn as optionHasImage,In as optionImageSources,En as optionImageSrc,Tn as optionLabel,Rn as parseDate,On as parseLooseDate,Dn as parseLooseDateRange,Ln as productFromMatchedItem,zn as productImageSources,Mn as productsFromCustomFields,Nn as sanitizeOptionIconSvg,Bn as selectedRangeFor,rt as useAIAutocomplete,Hn as visibleDateRange,Kn as withSkippedParams};
2269
+ `,document.head.appendChild(e)}var Ot={submitButton:"aia-submitButton-otz7H"};import{jsx as nt}from"react/jsx-runtime";function Dt({disabled:e,onClick:n,label:t=ni().submit}){return nt("button",{type:"button","data-aia-submit":"",className:Ot.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),n()},"aria-label":t,children:nt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:nt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ri,dateSelectionFor as si,identifiedParamLabel as li}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Bt,useEffect as Me,useRef as K,useState as di}from"react";import{useRef as Lt}from"react";function zt(e){let n=Lt(e);n.current=e;let t=Object.keys(e??{}).sort().join("\0"),i=Lt({key:"",overrides:void 0});if(i.current.key!==t){let r={};for(let o of Object.keys(e??{})){let a=(d,l,w)=>{let C=n.current?.[o];return C?C(d,l,w):[]};r[o]=a}i.current={key:t,overrides:e?r:void 0}}return{overrides:i.current.overrides,key:t}}import{useRef as Mt}from"react";function Nt(e){let n=Mt(e);n.current=e;let t=Mt(null);t.current===null&&(t.current={fetch:(r,o)=>{let a=n.current;return a?a.fetch(r,o):Promise.reject(new Error("products config removed"))},transform:r=>n.current?.transform(r)??[],get limit(){return n.current?.limit}});let i=e!==void 0;return{config:i?t.current:void 0,enabled:i}}var ci={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 rt({onSubmit:e,onResult:n,onError:t,optionOverrides:i,maskCompletedText:r,apiConfig:o,additionalContext:a,language:d,visitorId:l,columns:w=2,dropdownTrigger:C,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:b,showOptionIcons:I,showOptionImages:D,showOptionCounts:L,showSkipButton:F,showProducts:E,productImageFallback:S="image",onFocus:z,onBlur:M,value:x,completedParams:N,onChange:V,onParamsChange:B,products:he,onProductSelect:ae,source:q,setCursor:ue}){let m=K(null),[xe,ge]=di(null),me=K(e);me.current=e;let ie=K(n);ie.current=n;let fe=K(t);fe.current=t;let oe=K(V);oe.current=V;let J=K(B);J.current=B;let U=K(z);U.current=z;let ne=K(M);ne.current=M;let s=K(ue);s.current=ue;let g=K(ae);g.current=ae;let v=K(l);v.current=l;let f=K(()=>{let h=v.current;return typeof h=="function"?h():h}).current,y=Nt(he),R=zt(i);Me(()=>{if(typeof document>"u")return;let h=new ri(document.createElement("div"),{renderMode:"headless",apiConfig:o,additionalContext:a,language:d,visitorId:f,optionOverrides:R.overrides,maskCompletedText:r,columns:w,dropdownTrigger:C,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:b,showProducts:E,source:q,value:x,completedParams:N,onSubmit:(...O)=>me.current?.(...O),onResult:(...O)=>ie.current?.(...O),onError:(...O)=>fe.current?.(...O),onChange:(...O)=>oe.current?.(...O),onParamsChange:(...O)=>J.current?.(...O),onFocus:()=>U.current?.(),onBlur:()=>ne.current?.(),onProductSelect:O=>g.current?.(O),setCursor:O=>s.current?.(O),products:y.config});m.current=h,ge(h.getState());let Y=h.subscribe(O=>ge(O));return()=>{Y(),h.destroy(),m.current===h&&(m.current=null)}},[]),Me(()=>{x!==void 0&&m.current?.setValue(x)},[x]),Me(()=>{N!==void 0&&m.current?.setCompletedParams(N)},[N]);let c=JSON.stringify(o??null),H;try{H=JSON.stringify(a??null)}catch{H="[unstringifiable]"}Me(()=>{m.current?.update({apiConfig:o,additionalContext:a,language:d,optionOverrides:R.overrides,dropdownTrigger:C,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:b,showProducts:E})},[c,H,d,R.key,C,P,u,b,E]);let j=K(!1);Me(()=>{if(!j.current){j.current=!0;return}m.current?.update({products:y.config})},[y.enabled]);let Q=K(null);Q.current===null&&(Q.current={handleTextChange:h=>m.current?.handleTextChange(h),handleKeyDown:h=>{let Y="nativeEvent"in h?h.nativeEvent:h;m.current?.handleKeyDown(Y)},setFocused:h=>m.current?.setFocused(h),startEditingParam:h=>m.current?.startEditingParam(h),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:h=>m.current?.handleCaretAfterInput(h),handleCaretMove:h=>m.current?.handleCaretMove(h),replaceEditingRange:h=>m.current?.replaceEditingRange(h)??!1,setActivePill:h=>m.current?.setActivePill(h),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),recordSubmit:h=>m.current?.recordSubmit(h),selectOption:h=>m.current?.selectOption(h),selectProduct:h=>m.current?.selectProduct(h),setActiveDropdownIndex:h=>m.current?.setActiveDropdownIndex(h),clearHighlight:h=>m.current?.clearHighlight(h),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let k=Q.current,re=Bt(h=>{let Y=h.target.value,$e=Y.length>0&&!h.nativeEvent?.isComposing&&Y[0]!==Y[0].toUpperCase()?Y[0].toUpperCase()+Y.slice(1):Y;m.current?.handleTextChange($e)},[]),Ae=Bt(h=>{m.current?.handleKeyDown(h.nativeEvent)},[]),be=m.current,p=xe??ci,se=x!==void 0?x:p.text,ye=N!==void 0?N:p.completedParams,ve=p.actionableSuggestions,Pe=ve[0],le=be?.listboxId??"",Re=p.activeDropdownIndex>=0&&be?`${le}-option-${p.activeDropdownIndex}`:void 0,G=p.editingParam,W=p.editingIdentified,Se=G?{parameter:G.suggestionParameter,text:G.suggestionPlaceholder,required:!0,options:G.options}:W?{parameter:W.parameter,text:li(W.parameter),required:!0,options:[]}:null,Be=p.dropdownSuggestion??Se??Pe,Ze=Se?[Se]:ve,Oe=si(p),He=!be||p.dropdownLoading;return{completedParams:ye,skippedParams:p.skippedParams,identifiedParams:p.identifiedParams,suggestionPills:ve,setActivePill:k.setActivePill,skipActivePill:k.skipActivePill,removeLastParam:k.removeLastParam,segments:p.segments,newParamId:p.newParamId,clearNewParamId:k.clearNewParamId,suggestions:p.suggestions,activeIndex:p.activeDropdownIndex,isReady:p.isReady,isLoading:He,isFocused:p.isFocused,isDropdownOpen:p.isDropdownOpen,isActivePillSelected:p.isActivePillSelected,placeholderText:p.placeholderText,listboxId:le,error:p.error,products:p.products,customFields:p.customFields,selectProduct:k.selectProduct,handleTextChange:k.handleTextChange,handleKeyDown:k.handleKeyDown,setFocused:k.setFocused,editingParam:G,editingIdentified:W,editingAnchor:p.editingAnchor,caretOffset:p.caretOffset,startEditingParam:k.startEditingParam,exitEditMode:k.exitEditMode,handleCaretAfterInput:k.handleCaretAfterInput,handleCaretMove:k.handleCaretMove,replaceEditingRange:k.replaceEditingRange,inputProps:{value:se,placeholder:p.placeholderText||void 0,onChange:re,onKeyDown:Ae,onFocus:k.handleFocus,onBlur:k.handleBlur,role:"combobox","aria-expanded":p.isDropdownOpen,"aria-activedescendant":Re,"aria-autocomplete":"list","aria-controls":le},reset:k.reset,recordSubmit:k.recordSubmit,dropdownProps:{suggestions:Be?[{...Be,options:p.dropdownOptions}]:[],activeIndex:p.activeDropdownIndex,onSelect:k.selectOption,onHighlight:k.setActiveDropdownIndex,onUnhighlight:k.clearHighlight,isOpen:p.isDropdownOpen,id:le,pills:Ze,activeSelected:p.isActivePillSelected,onPillClick:k.setActivePill,onSkip:k.skipActivePill,showSkipButton:(F??!0)&&!G&&!W,showOptionIcons:I??!0,showOptionImages:D??!0,showOptionCounts:L??!0,skipDisabled:p.inSelectionAnimation,isLoading:He,skeletonExiting:p.skeletonExiting,isInputEmpty:se.trim().length===0,language:d,products:p.products,productImageFallback:S,onProductSelect:k.selectProduct,onProductFocusChange:k.setFocused,formatType:p.activeFormatType,dateView:p.dateView,selectedDateIso:Oe.selectedIso,selectedDateRange:Oe.selectedRange,dateRangeStart:Oe.rangeStart,onPreviousMonth:k.showPreviousMonth,onNextMonth:k.showNextMonth,optionsPosition:P??"below"}}}import{chipIdFromTap as pi,extractPlainText as Ht,getCursorOffset as Ft,keepCaretOnChip as hi,plainTextLength as ui,renderEditableContent as gi,setCursorOffset as Kt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as X,useEffect as Qe,useLayoutEffect as st,useRef as Ee}from"react";var Ye;function mi(){if(Ye!==void 0)return Ye;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ye=e.contentEditable==="plaintext-only",Ye}function Gt(e){let{segments:n,showChipIcons:t=!0,showChipImages:i=!0,newParamId:r,editingParam:o,editingIdentified:a,editingAnchor:d,caretOffset:l,placeholderText:w,isFocused:C,isDropdownOpen:P,listboxId:u,activeDescendantId:b,autoFocus:I,handleTextChange:D,handleKeyDown:L,handleCaretAfterInput:F,handleCaretMove:E,startEditingParam:S,replaceEditingRange:z,setFocused:M}=e,x=Ee(null),N=Ee(!1),V=Ee(""),B=Ee(""),he=Ee(null),ae=Ee(0);he.current=l,Qe(()=>{if(!I)return;let s=x.current;if(!s)return;document.activeElement===s?M(!0):s.focus();let g=s.ownerDocument??document,v=g.getSelection(),f=v&&v.rangeCount>0&&s.contains(v.anchorNode);if(v&&!f){let y=g.createRange();y.selectNodeContents(s),y.collapse(!0),v.removeAllRanges(),v.addRange(y)}},[I,M]),Qe(()=>{let s=x.current;if(!s)return;let g=s.ownerDocument??document,v=()=>{let f=g.getSelection();if(!f||f.rangeCount===0||!f.anchorNode||!s.contains(f.anchorNode))return;let y=f.anchorNode,R=y.nodeType===Node.ELEMENT_NODE?y:y.parentElement,H=(f.isCollapsed?R?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,j=o?.id??a?.id??null;if(H&&H!==j){S(H);return}performance.now()-ae.current<50||E(Ft(s))};return g.addEventListener("selectionchange",v),()=>g.removeEventListener("selectionchange",v)},[o,a,S,E]),Qe(()=>{let s=x.current;if(!s)return;let g=v=>{let f=pi(s,v.target);f&&(S(f),hi(s,f))};return s.addEventListener("click",g),()=>s.removeEventListener("click",g)},[S]),st(()=>{let s=x.current;s&&gi({input:s,segments:n,newParamId:r,editingParamId:o?.id??null,placeholderText:w??"",isFocused:C,showChipIcons:t,showChipImages:i})},[n,r,o,w,C,t,i]),st(()=>{let s=V.current,g=r??"";if(V.current=g,!g||g===s)return;let v=x.current;if(!v)return;v.focus();let f=he.current??ui(v);Kt(v,f)},[r]),st(()=>{let s=B.current,g=o?.id??"";if(B.current=g,!g||g===s||d==null)return;let v=x.current;v&&Kt(v,d)},[o,d]);let q=X(()=>{if(N.current)return;let s=x.current;if(!s)return;let g=Ht(s),f=g.length>0&&g[0]!==g[0].toUpperCase()?g[0].toUpperCase()+g.slice(1):g;D(f)},[D]),ue=X(()=>{ae.current=performance.now(),q();let s=x.current;s&&F(Ft(s))},[q,F]);Qe(()=>{let s=x.current;if(!s)return;let g=v=>{let f=v,y=f.inputType;if(y==="insertParagraph"||y==="insertLineBreak"||y==="insertFromDrop"){v.preventDefault();return}if(y.startsWith("insert")||y.startsWith("delete")){let R=y.startsWith("delete")?"":f.data??"";z(R)&&v.preventDefault()}};return s.addEventListener("beforeinput",g),()=>s.removeEventListener("beforeinput",g)},[z]);let m=X(()=>{N.current=!0},[]),xe=X(()=>{N.current=!1,q()},[q]),ge=X(s=>{s.preventDefault();let g=x.current;if(!g)return;let v=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!v)return;let f=g.ownerDocument??document,y=f.getSelection();if(!y||y.rangeCount===0)return;let R=y.getRangeAt(0);if(!g.contains(R.startContainer))return;R.deleteContents();let c=f.createTextNode(v);R.insertNode(c),R.setStartAfter(c),R.collapse(!0),y.removeAllRanges(),y.addRange(R),q()},[q]),me=X(s=>L(s),[L]),ie=X(()=>M(!0),[M]),fe=X(()=>M(!1),[M]),oe=X(()=>x.current?.focus(),[]),J=X(()=>x.current?.blur(),[]),U=X(()=>{let s=x.current;return s?Ht(s):""},[]),ne=mi()?"plaintext-only":"true";return{inputRef:x,editorProps:{ref:x,contentEditable:ne,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":P,"aria-activedescendant":b,spellCheck:!0,enterKeyHint:"send",onInput:ue,onKeyDown:me,onCompositionStart:m,onCompositionEnd:xe,onPaste:ge,onFocus:ie,onBlur:fe},getPlainText:U,focus:oe,blur:J}}import{jsx as Te,jsxs as dt}from"react/jsx-runtime";function Ci(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Pi=fi(function({onSubmit:n,onResult:t,onError:i,optionOverrides:r,maskCompletedText:o,className:a,apiConfig:d,additionalContext:l,language:w,visitorId:C,columns:P,pillPlacement:u="dropdown",mode:b="auto",optionsPosition:I="below",animations:D=!0,dropdownTrigger:L,closeDropdownOnBlur:F,showNonTappableOptions:E,showOptionIcons:S=!0,showChipIcons:z=!0,showChipImages:M=!0,showOptionImages:x=!0,showOptionCounts:N=!0,showSkipButton:V,showProducts:B,productsLayout:he,productImageFallback:ae,autoFocus:q=!0,onFocus:ue,onBlur:m,value:xe,completedParams:ge,onChange:me,onParamsChange:ie,products:fe,onProductSelect:oe,submitButton:J,resetOnSubmit:U=!0},ne){let s=Ne(null),g=Ne(null),v=Ne(()=>{}),f=Ne(null),y=Ne(null);Wt(()=>{let T=s.current;if(T)return f.current?f.current.setMode(b):f.current=new xi(T,b),()=>{f.current?.destroy(),f.current=null}},[b]);let R=lt(T=>{let ee=y.current?.current;ee&&(ee.focus(),yi(ee,T))},[]),{completedParams:c,skippedParams:H,identifiedParams:j,isReady:Q,customFields:k,suggestionPills:re,setActivePill:Ae,skipActivePill:be,segments:p,newParamId:se,clearNewParamId:ye,placeholderText:ve,isFocused:Pe,isDropdownOpen:le,isActivePillSelected:Re,isLoading:G,activeIndex:W,listboxId:Se,handleTextChange:Be,handleKeyDown:Ze,setFocused:Oe,editingParam:He,editingIdentified:h,editingAnchor:Y,caretOffset:O,startEditingParam:$e,handleCaretAfterInput:_t,handleCaretMove:qt,replaceEditingRange:Ut,dropdownProps:jt,reset:Fe,recordSubmit:ct}=rt({onSubmit:T=>v.current(T),onResult:t,onError:i,optionOverrides:r,maskCompletedText:o,apiConfig:d,additionalContext:l,language:w,visitorId:C,columns:P,dropdownTrigger:L,optionsPosition:I,closeDropdownOnBlur:F,showNonTappableOptions:E,showOptionIcons:S,showOptionImages:x,showOptionCounts:N,showSkipButton:V,showProducts:B,onFocus:ue,onBlur:m,value:xe,completedParams:ge,onChange:me,onParamsChange:ie,products:fe,onProductSelect:oe,source:"full-sdk",setCursor:R});Wt(()=>{if(!se)return;let T=window.setTimeout(()=>ye(),650);return()=>window.clearTimeout(T)},[se,ye]);let Qt=W>=0?`${Se}-option-${W}`:void 0,{inputRef:Ve,editorProps:Yt,focus:Ke,blur:pt,getPlainText:ht}=Gt({segments:p,newParamId:se,editingParam:He,editingIdentified:h,editingAnchor:Y,caretOffset:O,placeholderText:ve,isFocused:Pe,showChipIcons:z,showChipImages:M,isDropdownOpen:le,listboxId:Se,activeDescendantId:Qt,autoFocus:q,handleTextChange:Be,handleKeyDown:Ze,handleCaretAfterInput:_t,handleCaretMove:qt,startEditingParam:$e,replaceEditingRange:Ut,setFocused:Oe});y.current=Ve,vi(()=>{let T=g.current,ee=Ve.current;if(!T||!ee)return;let De=()=>{let gt=T.firstElementChild;if(!gt)return;let Xt=gt.getBoundingClientRect(),Jt=ee.getBoundingClientRect();Xt.top>=Jt.bottom-2?T.setAttribute("data-aia-pill-wrapped",""):T.removeAttribute("data-aia-pill-wrapped")};De();let ut=new ResizeObserver(De);return ut.observe(ee),()=>ut.disconnect()},[p,re.length,G,Ve]),bi(ne,()=>({focus:Ke,blur:pt,reset:Fe,setMode:T=>f.current?.setMode(T),skipActivePill:be}),[Ke,pt,Fe,be]);let Ge=!!p.length||c.length>0,Xe=lt(T=>{if(!Ge)return;let ee=ht(),De=wi(ee,c,H,{identifiedParams:j,isReady:Q,customFields:k});T&&ct(De),n(De),U&&Fe()},[ct,U,Ge,c,H,j,Q,k,n,Fe,ht]);v.current=()=>Xe(!1);let Zt=lt(T=>{T.target?.closest("[data-aia-pill]")||Ke()},[Ke]),$t=u==="inline",Vt=u==="dropdown";return dt("div",{ref:s,className:`magicx-aia ${ke.container} ${a??""}`,"data-pill-placement":u,"data-options-position":I,"data-animations":D?"on":"off","data-mode":Ci(b),children:[Te(ot,{...jt,showPills:Vt,productsLayout:he,productImageFallback:ae}),dt("div",{className:ke.inputWrapper,"data-aia-input-wrapper":"",onClick:Zt,children:[dt("div",{className:ke.editorArea,"data-aia-editor":"",children:[Te("div",{...Yt,className:ke.input,"data-aia-input":""}),$t&&(G||re.length>0)&&Te("span",{ref:g,className:ke.pillListContainer,"data-aia-pill-list-container":"",children:Te(_e,{pills:re,activePillIndex:0,activeSelected:Re,onSelectPill:Ae,loading:G})})]}),J===null?null:J===void 0?Te(Dt,{disabled:!Ge,onClick:()=>Xe(!0),label:ki(w).submit}):Te("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ke.submitSlot,onClick:T=>{Ge&&(T.stopPropagation(),Xe(!0))},children:J})]})]})});export{Pi as AIAutocomplete,ot as AIAutocompleteDropdown,xn as DATE_RANGE_META_END,yn as DATE_RANGE_META_START,kn as DEFAULT_OPTION_COUNT_UNIT,zn as PRODUCT_PATH_PREFIX,qn as WEEKDAY_LABELS,bn as buildSubmitResult,vn as cellDay,wn as cellIso,Cn as dateCellMarks,Pn as formatDate,Sn as formatDateRange,In as formatOptionCount,En as isoDate,Tn as monthLabel,An as optionCountLabel,Rn as optionHasImage,On as optionImageSources,Dn as optionImageSrc,Ln as optionLabel,Mn as parseDate,Nn as parseLooseDate,Bn as parseLooseDateRange,Hn as productFromMatchedItem,Fn as productImageSources,Kn as productsFromCustomFields,Gn as sanitizeOptionIconSvg,Wn as selectedRangeFor,rt as useAIAutocomplete,_n as visibleDateRange,Un as withSkippedParams};
2270
2270
  //# sourceMappingURL=index.mjs.map