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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END as en,DATE_RANGE_META_START as tn,DEFAULT_OPTION_COUNT_UNIT as an,dateCellMarks as on,formatDate as nn,formatDateRange as rn,formatOptionCount as sn,isoDate as ln,monthLabel as dn,optionCountLabel as cn,optionHasImage as pn,optionImageSrc as hn,optionLabel as un,PRODUCT_PATH_PREFIX as mn,parseDate as fn,parseLooseDate as gn,parseLooseDateRange as bn,productFromMatchedItem as vn,productsFromCustomFields as wn,sanitizeOptionIconSvg as xn,selectedRangeFor as yn,visibleDateRange as kn,WEEKDAY_LABELS as Cn,withSkippedParams as Pn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Ja,useCallback as at,useEffect as zt,useImperativeHandle as ei,useLayoutEffect as ti,useRef as De}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 Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END as tn,DATE_RANGE_META_START as an,DEFAULT_OPTION_COUNT_UNIT as on,dateCellMarks as nn,formatDate as rn,formatDateRange as sn,formatOptionCount as ln,isoDate as dn,monthLabel as cn,optionCountLabel as pn,optionHasImage as hn,optionImageSrc as un,optionLabel as mn,PRODUCT_PATH_PREFIX as fn,parseDate as gn,parseLooseDate as bn,parseLooseDateRange as vn,productFromMatchedItem as wn,productsFromCustomFields as xn,sanitizeOptionIconSvg as yn,selectedRangeFor as kn,visibleDateRange as Cn,WEEKDAY_LABELS as Pn,withSkippedParams as Sn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as ei,useCallback as at,useEffect as Nt,useImperativeHandle as ti,useLayoutEffect as ai,useRef as De}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
@@ -167,7 +167,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
167
167
  border-radius: var(--aia-chip-image-radius, 4px);
168
168
  background:
169
169
  var(--aia-chip-image, none) center / cover no-repeat,
170
- var(--aia-chip-image-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.25)));
170
+ var(--aia-chip-image-bg, var(--aia-skeleton-bg, rgba(189, 189, 189, 0.083)));
171
171
  pointer-events: none;
172
172
  user-select: none;
173
173
  }
@@ -262,7 +262,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
262
262
  opacity: 0;
263
263
  }
264
264
  }
265
- `,document.head.appendChild(e)}var ve={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 Ha,isCalendarFormat as Ba,SCROLL_ARROW_LABEL as Fa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ve,useRef as Be,useState as Ka}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 we={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};import{attachScrollArrow as Ha,isCalendarFormat as Fa,SCROLL_ARROW_LABEL as Ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ve,useRef as He,useState as Ga}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
  *
@@ -427,6 +427,8 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
427
427
  --aia-primitive-blue-50: #eef2ff;
428
428
  --aia-primitive-neutral-750-a50: rgba(189, 189, 189, 0.51);
429
429
  --aia-primitive-neutral-750-a25: rgba(189, 189, 189, 0.25);
430
+ /* One third of a25's alpha: the light-mode skeleton fill. */
431
+ --aia-primitive-neutral-750-a8: rgba(189, 189, 189, 0.083);
430
432
  --aia-primitive-neutral-750-a35: rgba(189, 189, 189, 0.35);
431
433
  --aia-primitive-neutral-750-a30: rgba(189, 189, 189, 0.3);
432
434
  --aia-primitive-neutral-750-a15: rgba(189, 189, 189, 0.15);
@@ -487,7 +489,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
487
489
 
488
490
  /* Loading bars sit at half the contrast of the surrounding chrome so they
489
491
  read as a placeholder, not as content (a50 -> a25 over the light surface). */
490
- --aia-skeleton-bg: var(--aia-primitive-neutral-750-a25);
492
+ --aia-skeleton-bg: var(--aia-primitive-neutral-750-a8);
491
493
 
492
494
  --aia-streak-rgb: 99, 102, 241; /* off shared palette (indigo effect) */
493
495
 
@@ -993,6 +995,24 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
993
995
  flex-direction: column;
994
996
  gap: 20px;
995
997
  padding: 7px 8px;
998
+ animation: aia-skeletonBarsIn-BdPrL 100ms ease-out;
999
+ }
1000
+
1001
+ /* Fades out with the option skeleton \u2014 see SuggestionItem.module.css. */
1002
+ .aia-dropdown-yz2KC[data-aia-skeleton-exiting] .aia-skeletonBars-HVr9C {
1003
+ animation: aia-skeletonBarsOut-TqKeD 100ms ease-in forwards;
1004
+ }
1005
+
1006
+ @keyframes aia-skeletonBarsOut-TqKeD {
1007
+ to {
1008
+ opacity: 0;
1009
+ }
1010
+ }
1011
+
1012
+ @keyframes aia-skeletonBarsIn-BdPrL {
1013
+ from {
1014
+ opacity: 0;
1015
+ }
996
1016
  }
997
1017
 
998
1018
  .aia-skeletonBar-O3xIx {
@@ -1021,7 +1041,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1021
1041
  opacity: 0.25;
1022
1042
  }
1023
1043
  }
1024
- `,document.head.appendChild(e)}var le={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};import{cellDay as Yt,cellIso as ke,dateCellMarks as $t,isoDate as Vt,monthLabel as Zt,visibleDateRange as Xt,WEEKDAY_LABELS as Jt}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as ea}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) ---
1044
+ `,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 $t,cellIso as Ce,dateCellMarks as Vt,isoDate as Zt,monthLabel as Xt,visibleDateRange as Jt,WEEKDAY_LABELS as ea}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as ta}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) ---
1025
1045
 
1026
1046
  One of three hand-maintained copies (vanilla styles.css, this file, Angular's
1027
1047
  date-grid.component.css). Only the class-naming layer differs \u2014 the
@@ -1184,7 +1204,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1184
1204
  opacity: 0.8;
1185
1205
  background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
1186
1206
  }
1187
- `,document.head.appendChild(e)}var T={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 Y,jsxs as dt}from"react/jsx-runtime";var ta=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ct({options:e,activeIndex:n,listboxId:i,view:r,selection:s,onSelect:a,onHighlight:o,onPreviousMonth:u,onNextMonth:v}){let f=Vt(new Date),w=Xt({pendingStart:s.rangeStart,highlightedIso:ke(e[n]),selected:s.selectedRange});return dt("div",{className:T.datepicker,"data-aia-datepicker":"",children:[dt("div",{className:T.header,children:[Y("button",{type:"button",tabIndex:-1,className:T.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:p=>p.preventDefault(),onClick:u,children:"\u2039"}),Y("span",{className:T.month,"data-aia-date-month":"","aria-live":"polite",children:Zt(r)}),Y("button",{type:"button",tabIndex:-1,className:T.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:p=>p.preventDefault(),onClick:v,children:"\u203A"})]}),Y("div",{className:T.weekdays,"aria-hidden":"true",children:Jt.map((p,k)=>Y("span",{className:T.weekday,children:p},ta[k]))}),Y("div",{className:T.grid,"data-aia-date-grid":"",children:e.map((p,k)=>Y(aa,{option:p,id:`${i}-option-${k}`,index:k,isHighlighted:k===n&&p.is_tappable,isToday:ke(p)===f,isPast:ke(p)!=null&&ke(p)<f,marks:$t(ke(p),{selectedIso:s.selectedIso,range:w}),onSelect:a,onHighlight:o},ke(p)??`pad-${k}`))})]})}function aa({option:e,id:n,index:i,isHighlighted:r,isToday:s,isPast:a,marks:o,onSelect:u,onHighlight:v}){let[f,w]=ea(!1),p=Yt(e);if(p==null)return Y("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${T.cell} ${T.blank}`});let k=()=>{w(!0),u(e),setTimeout(()=>w(!1),170)},P=[T.cell,T.day,a?T.past:"",r?T.highlighted:"",s?T.today:"",o.inRange?T.inRange:"",o.selected?T.selected:"",f?T.pressed:""].filter(Boolean).join(" ");return Y("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":r,"aria-label":e.text,tabIndex:0,className:P,onClick:k,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),k())},onMouseEnter:()=>v(i),children:Y("span",{className:T.number,children:p})})}import{ATTRIBUTION_URL as ia,buildAttributionUrl as oa,getFooterHint as na}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ra,useState as sa}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 {
1207
+ `,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 V,jsxs as dt}from"react/jsx-runtime";var aa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ct({options:e,activeIndex:n,listboxId:a,view:r,selection:s,onSelect:t,onHighlight:o,onPreviousMonth:u,onNextMonth:w}){let b=Zt(new Date),x=Jt({pendingStart:s.rangeStart,highlightedIso:Ce(e[n]),selected:s.selectedRange});return dt("div",{className:A.datepicker,"data-aia-datepicker":"",children:[dt("div",{className:A.header,children:[V("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:p=>p.preventDefault(),onClick:u,children:"\u2039"}),V("span",{className:A.month,"data-aia-date-month":"","aria-live":"polite",children:Xt(r)}),V("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:p=>p.preventDefault(),onClick:w,children:"\u203A"})]}),V("div",{className:A.weekdays,"aria-hidden":"true",children:ea.map((p,k)=>V("span",{className:A.weekday,children:p},aa[k]))}),V("div",{className:A.grid,"data-aia-date-grid":"",children:e.map((p,k)=>V(ia,{option:p,id:`${a}-option-${k}`,index:k,isHighlighted:k===n&&p.is_tappable,isToday:Ce(p)===b,isPast:Ce(p)!=null&&Ce(p)<b,marks:Vt(Ce(p),{selectedIso:s.selectedIso,range:x}),onSelect:t,onHighlight:o},Ce(p)??`pad-${k}`))})]})}function ia({option:e,id:n,index:a,isHighlighted:r,isToday:s,isPast:t,marks:o,onSelect:u,onHighlight:w}){let[b,x]=ta(!1),p=$t(e);if(p==null)return V("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 k=()=>{x(!0),u(e),setTimeout(()=>x(!1),170)},S=[A.cell,A.day,t?A.past:"",r?A.highlighted:"",s?A.today:"",o.inRange?A.inRange:"",o.selected?A.selected:"",b?A.pressed:""].filter(Boolean).join(" ");return V("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":r,"aria-label":e.text,tabIndex:0,className:S,onClick:k,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),k())},onMouseEnter:()=>w(a),children:V("span",{className:A.number,children:p})})}import{ATTRIBUTION_URL as oa,buildAttributionUrl as na,getFooterHint as ra}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as sa,useState as la}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 {
1188
1208
  display: flex;
1189
1209
  flex-wrap: wrap;
1190
1210
  gap: var(--aia-cluster-gap, 0.5rem);
@@ -1224,7 +1244,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1224
1244
  .aia-cluster[data-justify="around"] {
1225
1245
  justify-content: space-around;
1226
1246
  }
1227
- `,document.head.appendChild(e)}import{jsx as pt}from"react/jsx-runtime";function Te({gap:e,align:n="center",justify:i="start",noWrap:r=!1,inline:s=!1,className:a,children:o,...u}){let v=e?{"--aia-cluster-gap":e}:void 0,f={className:a?`aia-cluster ${a}`:"aia-cluster","data-align":n,"data-justify":i,"data-nowrap":r||void 0,"data-inline":s||void 0,style:v,...u};return s?pt("span",{...f,children:o}):pt("div",{...f,children:o})}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)}import{jsx as pt}from"react/jsx-runtime";function Te({gap:e,align:n="center",justify:a="start",noWrap:r=!1,inline:s=!1,className:t,children:o,...u}){let w=e?{"--aia-cluster-gap":e}:void 0,b={className:t?`aia-cluster ${t}`:"aia-cluster","data-align":n,"data-justify":a,"data-nowrap":r||void 0,"data-inline":s||void 0,style:w,...u};return s?pt("span",{...b,children:o}):pt("div",{...b,children:o})}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
1228
1248
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
1229
1249
  room above the hint/branding row so the footer doesn't butt against the last
1230
1250
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -1358,7 +1378,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1358
1378
  justify-content: flex-end;
1359
1379
  }
1360
1380
  }
1361
- `,document.head.appendChild(e)}var de={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"};import{jsx as Ae,jsxs as qe}from"react/jsx-runtime";function ht({isOptionHighlighted:e=!1,isInputEmpty:n=!1}){let{key:i,hint:r}=na(e,n),[s,a]=sa(ia);return ra(()=>{a(oa())},[]),Ae("footer",{className:de.footer,"data-aia-footer":"",children:qe(Te,{justify:"between",noWrap:!0,className:de.row,children:[qe(Te,{gap:"5px",className:de.hintGroup,children:[Ae("kbd",{className:de.key,children:i}),Ae("span",{className:de.hint,children:r})]}),qe("a",{className:de.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[Ae("span",{className:de.brand,children:"AI"}),Ae("span",{className:de.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 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"};import{jsx as Ae,jsxs as qe}from"react/jsx-runtime";function ht({isOptionHighlighted:e=!1,isInputEmpty:n=!1}){let{key:a,hint:r}=ra(e,n),[s,t]=la(oa);return sa(()=>{t(na())},[]),Ae("footer",{className:ce.footer,"data-aia-footer":"",children:qe(Te,{justify:"between",noWrap:!0,className:ce.row,children:[qe(Te,{gap:"5px",className:ce.hintGroup,children:[Ae("kbd",{className:ce.key,children:a}),Ae("span",{className:ce.hint,children:r})]}),qe("a",{className:ce.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[Ae("span",{className:ce.brand,children:"AI"}),Ae("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,
1362
1382
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
1363
1383
  The border is kept as a 1px transparent line so the box stays the same size
1364
1384
  as it was when the outline was dashed. */
@@ -1397,7 +1417,26 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1397
1417
  cursor: default;
1398
1418
  color: transparent;
1399
1419
  background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.25)));
1400
- animation: aia-skeletonPulse-xGcUy 1.4s ease-in-out infinite;
1420
+ animation:
1421
+ aia-skeletonIn-54kMv 100ms ease-out,
1422
+ aia-skeletonPulse-xGcUy 1.4s ease-in-out infinite;
1423
+ }
1424
+
1425
+ /* Fades out with the option skeleton \u2014 see SuggestionItem.module.css. */
1426
+ [data-aia-skeleton-exiting] .aia-skeleton-57P0T {
1427
+ animation: aia-skeletonOut-1sJ-r 100ms ease-in forwards;
1428
+ }
1429
+
1430
+ @keyframes aia-skeletonIn-54kMv {
1431
+ from {
1432
+ opacity: 0;
1433
+ }
1434
+ }
1435
+
1436
+ @keyframes aia-skeletonOut-1sJ-r {
1437
+ to {
1438
+ opacity: 0;
1439
+ }
1401
1440
  }
1402
1441
 
1403
1442
  @keyframes aia-skeletonPulse-xGcUy {
@@ -1415,7 +1454,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1415
1454
  opacity: 0;
1416
1455
  }
1417
1456
  }
1418
- `,document.head.appendChild(e)}var ge={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonPulse:"aia-skeletonPulse-xGcUy"};import{jsx as la}from"react/jsx-runtime";var Ue={selected:1,first:.7,next:.4,last:.2};function ut({label:e,state:n,rounded:i,loading:r,onClick:s}){let a=[ge.pill,i?ge.rounded:"",r?ge.skeleton:""].filter(Boolean).join(" ");return la("button",{type:"button","data-aia-pill":"","data-aia-loading":r?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:a,style:{opacity:Ue[n]},onMouseDown:o=>o.preventDefault(),onClick:r?void 0:s,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 {
1457
+ `,document.head.appendChild(e)}var be={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 da}from"react/jsx-runtime";var Ue={selected:1,first:.7,next:.4,last:.2};function ut({label:e,state:n,rounded:a,loading:r,onClick:s}){let t=[be.pill,a?be.rounded:"",r?be.skeleton:""].filter(Boolean).join(" ");return da("button",{type:"button","data-aia-pill":"","data-aia-loading":r?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:t,style:{opacity:Ue[n]},onMouseDown:o=>o.preventDefault(),onClick:r?void 0:s,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 {
1419
1458
  position: relative;
1420
1459
  z-index: 1;
1421
1460
  pointer-events: auto;
@@ -1425,7 +1464,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1425
1464
  align-items: center;
1426
1465
  vertical-align: middle;
1427
1466
  }
1428
- `,document.head.appendChild(e)}var je={list:"aia-list-qvLqO"};import{jsx as Ne}from"react/jsx-runtime";var da=[125,69];function mt(e){return e===0?"first":e===1?"next":"last"}function He({pills:e,activePillIndex:n,onSelectPill:i,activeSelected:r,rounded:s,loading:a}){return a&&e.length===0?Ne("span",{className:je.list,"data-aia-pill-list-loading":"",children:da.map((o,u)=>Ne("span",{"data-aia-pill-skeleton":"",className:`${ge.pill} ${s?ge.rounded:""} ${ge.skeleton}`,style:{width:o,opacity:Ue[mt(u)]}},`skel-${o}`))}):Ne("span",{className:je.list,"data-aia-pill-list-loading":a?"":void 0,children:e.map((o,u)=>{let v=!!r&&u===n;return Ne(ut,{label:o.text,state:v?"selected":mt(u),selected:v,rounded:s,loading:a,onClick:()=>i(u)},`${o.type}-${o.text}`)})})}import{attachProductRowWheel as ca}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as pa,useRef as ha}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
1467
+ `,document.head.appendChild(e)}var je={list:"aia-list-qvLqO"};import{jsx as Ne}from"react/jsx-runtime";var ca=[125,69];function mt(e){return e===0?"first":e===1?"next":"last"}function Be({pills:e,activePillIndex:n,onSelectPill:a,activeSelected:r,rounded:s,loading:t}){return t&&e.length===0?Ne("span",{className:je.list,"data-aia-pill-list-loading":"",children:ca.map((o,u)=>Ne("span",{"data-aia-pill-skeleton":"",className:`${be.pill} ${s?be.rounded:""} ${be.skeleton}`,style:{width:o,opacity:Ue[mt(u)]}},`skel-${o}`))}):Ne("span",{className:je.list,"data-aia-pill-list-loading":t?"":void 0,children:e.map((o,u)=>{let w=!!r&&u===n;return Ne(ut,{label:o.text,state:w?"selected":mt(u),selected:w,rounded:s,loading:t,onClick:()=>a(u)},`${o.type}-${o.text}`)})})}import{attachProductRowWheel as pa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ha,useRef as ua}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
1429
1468
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
1430
1469
  theming one package sees the same result in the other.
1431
1470
 
@@ -1643,7 +1682,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1643
1682
  .aia-section-Hugfg[data-aia-products-layout="list"] .aia-body-ly032 {
1644
1683
  flex: 1 1 auto;
1645
1684
  }
1646
- `,document.head.appendChild(e)}var j={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"};import{jsx as be,jsxs as Qe}from"react/jsx-runtime";function ft({products:e,listboxId:n,onSelect:i,onFocusChange:r,focusable:s=!0,layout:a="row"}){let o=e.length>0,u=ha(null);if(pa(()=>{let f=u.current;if(!(!o||!f))return ca(f)},[o]),!o)return null;let v=`${n}-products-label`;return Qe("section",{className:j.section,"data-aia-products":"","data-aia-products-layout":a,role:"group","aria-labelledby":v,children:[be("div",{className:j.label,id:v,"data-aia-products-label":"",children:"Products"}),be("div",{ref:u,className:j.row,"data-aia-products-row":"",children:e.map((f,w)=>be(ua,{product:f,id:`${n}-product-${w}`,onSelect:i,onFocusChange:r,focusable:s},f.id))})]})}function ua({product:e,id:n,onSelect:i,onFocusChange:r,focusable:s}){let a=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),i(e))};return Qe("a",{id:n,className:j.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:a,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),i(e))},onFocus:()=>r?.(!0),onBlur:o=>{o.relatedTarget?.closest("[data-aia-dropdown]")||r?.(!1)},children:[be("span",{className:j.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?be("img",{className:j.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Qe("span",{className:j.body,children:[e.vendor?be("span",{className:j.vendor,children:e.vendor}):null,be("span",{className:j.title,children:e.title}),e.price?be("span",{className:j.price,children:e.price}):null]})]})}import{isOptionsGridMobileViewport as Ea,measureOptionsGrid as Ta,needsOptionsGridMeasurement as Aa,OPTIONS_GRID_MOBILE_QUERY as Ra,optionEnterDelayMs as Da,planOptionsGrid as vt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as La,useLayoutEffect as Oa,useRef as Ma,useState as xt}from"react";import{optionsGridTemplateColumns as ma}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as fa,useRef as ga}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 {
1685
+ `,document.head.appendChild(e)}var q={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"};import{jsx as ve,jsxs as Qe}from"react/jsx-runtime";function ft({products:e,listboxId:n,onSelect:a,onFocusChange:r,focusable:s=!0,layout:t="row"}){let o=e.length>0,u=ua(null);if(ha(()=>{let b=u.current;if(!(!o||!b))return pa(b)},[o]),!o)return null;let w=`${n}-products-label`;return Qe("section",{className:q.section,"data-aia-products":"","data-aia-products-layout":t,role:"group","aria-labelledby":w,children:[ve("div",{className:q.label,id:w,"data-aia-products-label":"",children:"Products"}),ve("div",{ref:u,className:q.row,"data-aia-products-row":"",children:e.map((b,x)=>ve(ma,{product:b,id:`${n}-product-${x}`,onSelect:a,onFocusChange:r,focusable:s},b.id))})]})}function ma({product:e,id:n,onSelect:a,onFocusChange:r,focusable:s}){let t=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),a(e))};return Qe("a",{id:n,className:q.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:t,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),a(e))},onFocus:()=>r?.(!0),onBlur:o=>{o.relatedTarget?.closest("[data-aia-dropdown]")||r?.(!1)},children:[ve("span",{className:q.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?ve("img",{className:q.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Qe("span",{className:q.body,children:[e.vendor?ve("span",{className:q.vendor,children:e.vendor}):null,ve("span",{className:q.title,children:e.title}),e.price?ve("span",{className:q.price,children:e.price}):null]})]})}import{isOptionsGridMobileViewport as Ta,measureOptionsGrid as Aa,needsOptionsGridMeasurement as Ra,OPTIONS_GRID_MOBILE_QUERY as Da,optionEnterDelayMs as Oa,planOptionsGrid as vt,sameOptionRows as La}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ma,useLayoutEffect as za,useRef as wt,useState as yt}from"react";import{optionsGridTemplateColumns as fa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as ga,useRef as ba}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 {
1647
1686
  display: grid;
1648
1687
  grid-template-columns: repeat(
1649
1688
  auto-fit,
@@ -1676,7 +1715,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1676
1715
  background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
1677
1716
  border-radius: 3px;
1678
1717
  }
1679
- `,document.head.appendChild(e)}import{jsx as ba}from"react/jsx-runtime";function gt({min:e="16rem",max:n,gap:i,scroll:r=!1,maxHeight:s,scrollResetKey:a,cols:o,template:u,innerRef:v,className:f,children:w,...p}){let k=ga(null);fa(()=>{if(a===void 0)return;let y=k.current;y&&(y.scrollTop=0)},[a]);let P={"--aia-grid-min":e};return n&&(P["--aia-grid-max"]=n),i&&(P["--aia-grid-gap"]=i),s&&(P["--aia-grid-max-height"]=s),o&&(P.gridTemplateColumns=ma(o)),u&&(P.gridTemplateColumns=u),ba("div",{ref:y=>{k.current=y,v?.(y)},className:f?`aia-grid ${f}`:"aia-grid","data-scroll":r||void 0,style:P,...p,children:w})}import{formatOptionCount as va,OPTION_ENTER_DELAY_VAR as wa,optionImageSrc as xa,optionLabel as ya,sanitizeOptionIconSvg as ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ca,useMemo as Pa,useRef as Sa,useState as Ye}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 {
1718
+ `,document.head.appendChild(e)}import{jsx as va}from"react/jsx-runtime";function gt({min:e="16rem",max:n,gap:a,scroll:r=!1,maxHeight:s,scrollResetKey:t,cols:o,template:u,innerRef:w,className:b,children:x,...p}){let k=ba(null);ga(()=>{if(t===void 0)return;let y=k.current;y&&(y.scrollTop=0)},[t]);let S={"--aia-grid-min":e};return n&&(S["--aia-grid-max"]=n),a&&(S["--aia-grid-gap"]=a),s&&(S["--aia-grid-max-height"]=s),o&&(S.gridTemplateColumns=fa(o)),u&&(S.gridTemplateColumns=u),va("div",{ref:y=>{k.current=y,w?.(y)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":r||void 0,style:S,...p,children:x})}import{formatOptionCount as wa,OPTION_ENTER_DELAY_VAR as xa,optionImageSrc as ya,optionLabel as ka,sanitizeOptionIconSvg as Ca}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Pa,useMemo as Sa,useRef as Ia,useState as Ye}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 {
1680
1719
  position: relative;
1681
1720
  /* Clip, not visible: the entrance rise below runs on the inner content,
1682
1721
  and a transformed box extends its scroll container's scrollable area.
@@ -1830,6 +1869,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1830
1869
  border-radius: 999px;
1831
1870
  -webkit-box-decoration-break: clone;
1832
1871
  box-decoration-break: clone;
1872
+ animation: aia-skeletonBarIn-ZlEM0 100ms ease-out;
1833
1873
  }
1834
1874
 
1835
1875
  .aia-item-d4vpD[data-aia-loading] .aia-tag-e3Fwe {
@@ -1902,6 +1942,15 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1902
1942
  min-width: 0;
1903
1943
  }
1904
1944
 
1945
+ /* A skeleton bar hugs its text. The rules above let the text grow to fill a
1946
+ picture / count row (so the count sits at the trailing edge); a loading row
1947
+ hides the count, and a growing text box would paint the bar across the
1948
+ whole column. One compound deeper than those rules, so it wins in every
1949
+ copy regardless of source order. */
1950
+ .aia-item-d4vpD[data-aia-loading] .aia-content-T-Qba .aia-text-yqoh9 {
1951
+ flex: 0 1 auto;
1952
+ }
1953
+
1905
1954
  /* The picture: a square tile, centred on the text beside it (a one-line
1906
1955
  option reads as the reference row; a wrapped one keeps the tile on its
1907
1956
  vertical middle). Sized and rounded by token so a consumer can shrink it
@@ -1919,7 +1968,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1919
1968
  height: var(--aia-option-image-size, 40px);
1920
1969
  border-radius: var(--aia-option-image-radius, 12px);
1921
1970
  overflow: hidden;
1922
- background: var(--aia-option-image-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.25)));
1971
+ background: var(--aia-option-image-bg, var(--aia-skeleton-bg, rgba(189, 189, 189, 0.083)));
1923
1972
  }
1924
1973
 
1925
1974
  .aia-image-YZAbO img {
@@ -1993,7 +2042,40 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1993
2042
  filter: brightness(0.55);
1994
2043
  }
1995
2044
  }
1996
- `,document.head.appendChild(e)}var H={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",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO"};import{jsx as we,jsxs as Ia}from"react/jsx-runtime";function bt({option:e,isHighlighted:n,onSelect:i,onHighlight:r,id:s,loading:a,showIcon:o=!0,showImage:u=!0,showCount:v=!0,scrollHint:f,enterDelayMs:w=0}){let[p]=Ye(w),[k,P]=Ye(!1),y=u?xa(e.image_url):null,[M,E]=Ye(null),S=Pa(()=>!y&&o&&e.icon_svg?ka(e.icon_svg):null,[y,o,e.icon_svg]),D=v?va(e.item_count):null,A=Sa(void 0);Ca(()=>()=>clearTimeout(A.current),[]);let O=()=>{a||!e.is_tappable||k||(P(!0),i(e),clearTimeout(A.current),A.current=setTimeout(()=>P(!1),170))},z=[H.item,n&&!a?H.highlighted:"",e.is_tappable?H.tappable:H.nonTappable,k?H.pressed:"",f?H.scrollHint:""].filter(Boolean).join(" ");return we("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":S&&e.icon?e.icon:void 0,"data-aia-image":y?"":void 0,"data-aia-item-count":D!==null?e.item_count:void 0,"aria-selected":n,className:z,style:{[wa]:`${p}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:O,onKeyDown:C=>{!a&&e.is_tappable&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),O())},onMouseEnter:!a&&e.is_tappable?r:void 0,children:Ia("span",{className:H.content,children:[y&&we("span",{className:`${H.image} magicx-aia-option-image`,"aria-hidden":"true",children:we("img",{src:y,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:M===y,onError:()=>E(y)})}),S&&we("span",{className:`${H.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:S}}),we("span",{className:H.text,children:ya(e)}),e.tag&&we("span",{className:H.tag,children:e.tag}),D!==null&&we("span",{className:`${H.count} magicx-aia-option-count`,children:D})]})})}import{jsx as wt}from"react/jsx-runtime";function za(){let[e,n]=xt(Ea);return La(()=>{if(typeof window>"u"||!window.matchMedia)return;let i=window.matchMedia(Ra),r=()=>n(i.matches);return r(),i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),e}function yt({options:e,activeIndex:n,onSelect:i,onHighlight:r,listboxId:s,loading:a,groupKey:o="",optionsPosition:u="below",showIcons:v=!0,showImages:f=!0,showCounts:w=!0}){let p=za(),k=Ma(null),[P,y]=xt(null);Oa(()=>{let E=k.current,D=E&&!a&&Aa(e.length,p)?Ta(E):null;y(D?vt(e.length,p,D.rowWidths,D.gridWidth):null)},[e,p,a]);let M=P??vt(e.length,p,null,null);return wt(gt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,template:M.template,maxHeight:M.maxHeight,innerRef:E=>{k.current=E},"data-aia-group":o,children:e.map((E,S)=>wt(bt,{option:E,isHighlighted:S===n,onSelect:i,onHighlight:()=>r(S),id:`${s}-option-${S}`,loading:a,showIcon:v,showImage:f,showCount:w,scrollHint:!a&&M.scrollHintIndices.includes(S),enterDelayMs:a?0:Da(S,M.cols,e.length,u)},`${o}\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 {
2045
+ /* --- Loading skeleton fades ---
2046
+ Skeletons ease in and out over 100ms instead of popping. In: an option's
2047
+ text crossfades into its bar (the row element persists in React / Angular
2048
+ and is rebuilt in vanilla \u2014 a keyframe plays either way). Out: while the
2049
+ dropdown carries data-aia-skeleton-exiting (the core holds the skeleton for
2050
+ SKELETON_FADE_MS after the response lands) the skeleton rows and pills fade
2051
+ to nothing before the response's options replace them. Keep 100ms in step
2052
+ with SKELETON_FADE_MS in AIAutocomplete.ts. */
2053
+ /* During the fade-out the skeleton rows play nothing but the fade: no
2054
+ entrance, no text crossfade. Rows keep their identity through it (the core's
2055
+ dropdownSuggestion), but if one were ever remounted here, replaying either
2056
+ animation would bring the previous option's text back on screen. */
2057
+ [data-aia-skeleton-exiting] .aia-item-d4vpD[data-aia-loading] .aia-content-T-Qba,
2058
+ [data-aia-skeleton-exiting] .aia-item-d4vpD[data-aia-loading] .aia-text-yqoh9 {
2059
+ animation: none;
2060
+ }
2061
+
2062
+ [data-aia-skeleton-exiting] .aia-item-d4vpD[data-aia-loading] {
2063
+ animation: aia-skeletonOut-x6NRd 100ms ease-in forwards;
2064
+ }
2065
+
2066
+ @keyframes aia-skeletonBarIn-ZlEM0 {
2067
+ from {
2068
+ background-color: transparent;
2069
+ color: inherit;
2070
+ }
2071
+ }
2072
+
2073
+ @keyframes aia-skeletonOut-x6NRd {
2074
+ to {
2075
+ opacity: 0;
2076
+ }
2077
+ }
2078
+ `,document.head.appendChild(e)}var B={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 xe,jsxs as Ea}from"react/jsx-runtime";function bt({option:e,isHighlighted:n,onSelect:a,onHighlight:r,id:s,loading:t,showIcon:o=!0,showImage:u=!0,showCount:w=!0,scrollHint:b,enterDelayMs:x=0}){let[p]=Ye(x),[k,S]=Ye(!1),y=u?ya(e.image_url):null,[z,O]=Ye(null),P=Sa(()=>!y&&o&&e.icon_svg?Ca(e.icon_svg):null,[y,o,e.icon_svg]),T=w?wa(e.item_count):null,I=Ia(void 0);Pa(()=>()=>clearTimeout(I.current),[]);let R=()=>{t||!e.is_tappable||k||(S(!0),a(e),clearTimeout(I.current),I.current=setTimeout(()=>S(!1),170))},L=[B.item,n&&!t?B.highlighted:"",e.is_tappable?B.tappable:B.nonTappable,k?B.pressed:"",b?B.scrollHint:""].filter(Boolean).join(" ");return xe("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":t?"":void 0,"data-aia-icon":P&&e.icon?e.icon:void 0,"data-aia-image":y?"":void 0,"data-aia-item-count":T!==null?e.item_count:void 0,"aria-selected":n,className:L,style:{[xa]:`${p}ms`},tabIndex:t||!e.is_tappable?-1:0,onClick:R,onKeyDown:C=>{!t&&e.is_tappable&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),R())},onMouseEnter:!t&&e.is_tappable?r:void 0,children:Ea("span",{className:B.content,children:[y&&xe("span",{className:`${B.image} magicx-aia-option-image`,"aria-hidden":"true",children:xe("img",{src:y,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:z===y,onError:()=>O(y)})}),P&&xe("span",{className:`${B.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:P}}),xe("span",{className:B.text,children:ka(e)}),e.tag&&xe("span",{className:B.tag,children:e.tag}),T!==null&&xe("span",{className:`${B.count} magicx-aia-option-count`,children:T})]})})}import{jsx as xt}from"react/jsx-runtime";function Na(){let[e,n]=yt(Ta);return Ma(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(Da),r=()=>n(a.matches);return r(),a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[]),e}function kt({options:e,activeIndex:n,onSelect:a,onHighlight:r,listboxId:s,loading:t,groupKey:o="",optionsPosition:u="below",showIcons:w=!0,showImages:b=!0,showCounts:x=!0}){let p=Na(),k=wt(null),[S,y]=yt(null),z=wt(null);za(()=>{if(t&&La(z.current,e))return;z.current=t?null:e;let P=k.current,I=P&&!t&&Ra(e.length,p)?Aa(P):null;y(I?vt(e.length,p,I.rowWidths,I.gridWidth):null)},[e,p,t]);let O=S??vt(e.length,p,null,null);return xt(gt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,template:O.template,maxHeight:O.maxHeight,innerRef:P=>{k.current=P},"data-aia-group":o,children:e.map((P,T)=>xt(bt,{option:P,isHighlighted:T===n,onSelect:a,onHighlight:()=>r(T),id:`${s}-option-${T}`,loading:t,showIcon:w,showImage:b,showCount:x,scrollHint:!t&&O.scrollHintIndices.includes(T),enterDelayMs:t?0:Oa(T,O.cols,e.length,u)},`${o}\0${P.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
1997
2079
  display: flex;
1998
2080
  flex-direction: column;
1999
2081
  gap: var(--aia-stack-space, 0.5rem);
@@ -2008,7 +2090,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
2008
2090
  align-items: end;
2009
2091
  }
2010
2092
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
2011
- `,document.head.appendChild(e)}import{jsx as Na}from"react/jsx-runtime";function kt({space:e,align:n="stretch",className:i,children:r,...s}){let a=e?{"--aia-stack-space":e}:void 0;return Na("div",{className:i?`aia-stack ${i}`:"aia-stack","data-align":n,style:a,...s,children:r})}import{jsx as G,jsxs as $e}from"react/jsx-runtime";var Ga=[159,119,164],Wa=()=>{},Ct=()=>{};function _a(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[i,r]=Ka(n);if(Ve(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>r(s.matches);return s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e]),e!==void 0)return e==="auto"?i?"dark":"light":e}function qa(e,n){let i=Be(null);Ve(()=>{let r=e.current,s=n.current;if(!r||!s)return;let a=r.querySelector(".aia-grid[data-scroll]");if(i.current&&i.current.grid!==a&&(i.current.controller.destroy(),i.current=null),a&&!i.current){i.current={grid:a,controller:Ha({dropdown:r,grid:a,button:s})};return}i.current?.controller.update()}),Ve(()=>()=>{i.current?.controller.destroy(),i.current=null},[])}function Ze({suggestions:e,activeIndex:n,onSelect:i,onHighlight:r,isOpen:s,id:a,className:o,pills:u,onPillClick:v,showPills:f=!0,onSkip:w,showSkipButton:p=!0,showOptionIcons:k=!0,showOptionImages:P=!0,showOptionCounts:y=!0,skipDisabled:M=!1,activeSelected:E=!1,isLoading:S=!1,isInputEmpty:D=!1,products:A,onProductSelect:O,onProductFocusChange:z,productsLayout:C="row",formatType:$="options",dateView:V=null,selectedDateIso:ce=null,selectedDateRange:Z=null,dateRangeStart:h=null,onPreviousMonth:B,onNextMonth:pe,optionsPosition:X="below",mode:he}){let J=_a(he),ue=J!==void 0,_=Be(null),ee=Be(null);qa(_,ee);let te=e[0]?.options??[],ae=!!(u&&u.length>0&&v),ie=!!(A&&A.length>0),L=s&&(te.length>0||f&&ae||S||ie),l={suggestions:e,activeIndex:n,pills:u,showPills:f,showSkipButton:p,showOptionIcons:k,showOptionImages:P,showOptionCounts:y,skipDisabled:M,activeSelected:E,isLoading:S,isInputEmpty:D,products:A,formatType:$,dateView:V,selectedDateIso:ce,selectedDateRange:Z,dateRangeStart:h},g=Be(l);L&&(g.current=l);let t=L?l:g.current,x=t.suggestions[0],b=x?.options??[],c=t.activeIndex>=0&&!!b[t.activeIndex]?.is_tappable,F=!!(t.pills&&t.pills.length>0&&v),q=t.showPills&&F,oe=t.showPills&&!F&&t.isLoading,d=q||oe,ne=F&&t.showSkipButton&&!t.isInputEmpty&&!!w,me=t.pills?.[0]?.text,re=Ba(t.formatType)&&t.dateView!=null,xe=b.length>0&&!re,se=b.length>0&&re&&!t.isLoading,Se=t.isLoading&&!xe&&!se,U=t.products??[];return $e("div",{ref:_,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":X,"data-mode":J,"data-aia-loading":t.isLoading?"":void 0,"data-aia-has-products":U.length>0?"":void 0,className:`${ue?"magicx-aia ":""}${le.dropdown} ${L?le.visible:""} ${o??""}`,onMouseDown:N=>N.preventDefault(),children:[$e(kt,{space:"8px",children:[(d||ne)&&$e(Te,{noWrap:!0,className:le.pillBar,"data-aia-pillbar":"",children:[d&&G("span",{className:le.pillScroll,"data-aia-pill-scroll":"",children:G(He,{pills:t.pills??[],activePillIndex:0,activeSelected:t.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:t.isLoading})}),ne&&G("button",{type:"button",tabIndex:-1,className:le.skip,"data-aia-skip":"",disabled:t.isLoading||t.skipDisabled,"aria-label":me?`Skip ${me}`:"Skip",onClick:w,children:"skip"})]}),xe&&G(yt,{options:b,activeIndex:t.activeIndex,onSelect:i,onHighlight:r,listboxId:a,loading:t.isLoading,groupKey:x?`${x.type} ${x.text}`:"",optionsPosition:X,showIcons:t.showOptionIcons,showImages:t.showOptionImages,showCounts:t.showOptionCounts}),se&&t.dateView&&G(ct,{options:b,activeIndex:t.activeIndex,listboxId:a,view:t.dateView,selection:{selectedIso:t.selectedDateIso??null,selectedRange:t.selectedDateRange??null,rangeStart:t.dateRangeStart??null},onSelect:i,onHighlight:r,onPreviousMonth:B??Ct,onNextMonth:pe??Ct}),Se&&G("div",{className:le.skeletonBars,"data-aia-skeleton-bars":"",children:Ga.map(N=>G("span",{className:le.skeletonBar,style:{width:N}},`bar-${N}`))}),G(ft,{products:U,listboxId:a,onSelect:O??Wa,onFocusChange:z,focusable:L,layout:C}),G(ht,{isOptionHighlighted:c,isInputEmpty:t.isInputEmpty})]}),G("button",{ref:ee,type:"button",tabIndex:-1,className:le.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Fa,"aria-hidden":"true",children:G("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:G("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as ai,ModeController as ii,setCursorOffset as oi}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 {
2093
+ `,document.head.appendChild(e)}import{jsx as Ba}from"react/jsx-runtime";function Ct({space:e,align:n="stretch",className:a,children:r,...s}){let t=e?{"--aia-stack-space":e}:void 0;return Ba("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":n,style:t,...s,children:r})}import{jsx as G,jsxs as $e}from"react/jsx-runtime";var Wa=[159,119,164],_a=()=>{},Pt=()=>{};function qa(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,r]=Ga(n);if(Ve(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),t=()=>r(s.matches);return s.addEventListener("change",t),()=>s.removeEventListener("change",t)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function Ua(e,n){let a=He(null);Ve(()=>{let r=e.current,s=n.current;if(!r||!s)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:Ha({dropdown:r,grid:t,button:s})};return}a.current?.controller.update()}),Ve(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function Ze({suggestions:e,activeIndex:n,onSelect:a,onHighlight:r,isOpen:s,id:t,className:o,pills:u,onPillClick:w,showPills:b=!0,onSkip:x,showSkipButton:p=!0,showOptionIcons:k=!0,showOptionImages:S=!0,showOptionCounts:y=!0,skipDisabled:z=!1,activeSelected:O=!1,isLoading:P=!1,skeletonExiting:T=!1,isInputEmpty:I=!1,products:R,onProductSelect:L,onProductFocusChange:C,productsLayout:Z="row",formatType:X="options",dateView:pe=null,selectedDateIso:J=null,selectedDateRange:h=null,dateRangeStart:H=null,onPreviousMonth:he,onNextMonth:ue,optionsPosition:ee="below",mode:me}){let te=qa(me),j=te!==void 0,ae=He(null),Q=He(null);Ua(ae,Q);let ie=e[0]?.options??[],oe=!!(u&&u.length>0&&w),M=!!(R&&R.length>0),l=s&&(ie.length>0||b&&oe||P||M),m={suggestions:e,activeIndex:n,pills:u,showPills:b,showSkipButton:p,showOptionIcons:k,showOptionImages:S,showOptionCounts:y,skipDisabled:z,activeSelected:O,isLoading:P,skeletonExiting:T,isInputEmpty:I,products:R,formatType:X,dateView:pe,selectedDateIso:J,selectedDateRange:h,dateRangeStart:H},f=He(m);l&&(f.current=m);let i=l?m:f.current,v=i.suggestions[0],d=v?.options??[],Y=i.activeIndex>=0&&!!d[i.activeIndex]?.is_tappable,N=!!(i.pills&&i.pills.length>0&&w),ne=i.showPills&&N,c=i.showPills&&!N&&i.isLoading,re=ne||c,fe=N&&i.showSkipButton&&!i.isInputEmpty&&!!x,se=i.pills?.[0]?.text,ye=Fa(i.formatType)&&i.dateView!=null,le=d.length>0&&!ye,ke=d.length>0&&ye&&!i.isLoading,$=i.isLoading&&!le&&!ke,F=i.products??[];return $e("div",{ref:ae,id:t,role:"listbox","data-aia-dropdown":"","data-options-position":ee,"data-mode":te,"data-aia-loading":i.isLoading?"":void 0,"data-aia-skeleton-exiting":i.skeletonExiting?"":void 0,"data-aia-has-products":F.length>0?"":void 0,className:`${j?"magicx-aia ":""}${de.dropdown} ${l?de.visible:""} ${o??""}`,onMouseDown:_=>_.preventDefault(),children:[$e(Ct,{space:"8px",children:[(re||fe)&&$e(Te,{noWrap:!0,className:de.pillBar,"data-aia-pillbar":"",children:[re&&G("span",{className:de.pillScroll,"data-aia-pill-scroll":"",children:G(Be,{pills:i.pills??[],activePillIndex:0,activeSelected:i.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:i.isLoading})}),fe&&G("button",{type:"button",tabIndex:-1,className:de.skip,"data-aia-skip":"",disabled:i.isLoading||i.skipDisabled,"aria-label":se?`Skip ${se}`:"Skip",onClick:x,children:"skip"})]}),le&&G(kt,{options:d,activeIndex:i.activeIndex,onSelect:a,onHighlight:r,listboxId:t,loading:i.isLoading,groupKey:v?`${v.type} ${v.text}`:"",optionsPosition:ee,showIcons:i.showOptionIcons,showImages:i.showOptionImages,showCounts:i.showOptionCounts}),ke&&i.dateView&&G(ct,{options:d,activeIndex:i.activeIndex,listboxId:t,view:i.dateView,selection:{selectedIso:i.selectedDateIso??null,selectedRange:i.selectedDateRange??null,rangeStart:i.dateRangeStart??null},onSelect:a,onHighlight:r,onPreviousMonth:he??Pt,onNextMonth:ue??Pt}),$&&G("div",{className:de.skeletonBars,"data-aia-skeleton-bars":"",children:Wa.map(_=>G("span",{className:de.skeletonBar,style:{width:_}},`bar-${_}`))}),G(ft,{products:F,listboxId:t,onSelect:L??_a,onFocusChange:C,focusable:l,layout:Z}),G(ht,{isOptionHighlighted:Y,isInputEmpty:i.isInputEmpty})]}),G("button",{ref:Q,type:"button",tabIndex:-1,className:de.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Ka,"aria-hidden":"true",children:G("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:G("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as ii,ModeController as oi,setCursorOffset 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 {
2012
2094
  flex-shrink: 0;
2013
2095
  width: 32px;
2014
2096
  height: 32px;
@@ -2061,5 +2143,5 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
2061
2143
  );
2062
2144
  cursor: default;
2063
2145
  }
2064
- `,document.head.appendChild(e)}var Pt={submitButton:"aia-submitButton-otz7H"};import{jsx as Xe}from"react/jsx-runtime";function St({disabled:e,onClick:n}){return Xe("button",{type:"button","data-aia-submit":"",className:Pt.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),n()},"aria-label":"Submit",children:Xe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Xe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Ua,dateSelectionFor as ja,identifiedParamLabel as Qa}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Rt,useEffect as Re,useRef as W,useState as Ya}from"react";import{useRef as It}from"react";function Et(e){let n=It(e);n.current=e;let i=Object.keys(e??{}).sort().join("\0"),r=It({key:"",overrides:void 0});if(r.current.key!==i){let s={};for(let a of Object.keys(e??{})){let o=(u,v,f)=>{let w=n.current?.[a];return w?w(u,v,f):[]};s[a]=o}r.current={key:i,overrides:e?s:void 0}}return{overrides:r.current.overrides,key:i}}import{useRef as Tt}from"react";function At(e){let n=Tt(e);n.current=e;let i=Tt(null);i.current===null&&(i.current={fetch:(s,a)=>{let o=n.current;return o?o.fetch(s,a):Promise.reject(new Error("products config removed"))},transform:s=>n.current?.transform(s)??[],get limit(){return n.current?.limit}});let r=e!==void 0;return{config:r?i.current:void 0,enabled:r}}var $a={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:[],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 Je({onSubmit:e,onResult:n,onError:i,optionOverrides:r,maskCompletedText:s,apiConfig:a,additionalContext:o,columns:u=2,dropdownTrigger:v,optionsPosition:f,closeDropdownOnBlur:w,showNonTappableOptions:p,showOptionIcons:k,showOptionImages:P,showOptionCounts:y,showSkipButton:M,showProducts:E,onFocus:S,onBlur:D,value:A,completedParams:O,onChange:z,onParamsChange:C,products:$,onProductSelect:V,source:ce,setCursor:Z}){let h=W(null),[B,pe]=Ya(null),X=W(e);X.current=e;let he=W(n);he.current=n;let J=W(i);J.current=i;let ue=W(z);ue.current=z;let _=W(C);_.current=C;let ee=W(S);ee.current=S;let te=W(D);te.current=D;let ae=W(Z);ae.current=Z;let ie=W(V);ie.current=V;let L=At($),l=Et(r);Re(()=>{if(typeof document>"u")return;let m=new Ua(document.createElement("div"),{renderMode:"headless",apiConfig:a,additionalContext:o,optionOverrides:l.overrides,maskCompletedText:s,columns:u,dropdownTrigger:v,optionsPosition:f,closeDropdownOnBlur:w,showNonTappableOptions:p,showProducts:E,source:ce,value:A,completedParams:O,onSubmit:(...R)=>X.current?.(...R),onResult:(...R)=>he.current?.(...R),onError:(...R)=>J.current?.(...R),onChange:(...R)=>ue.current?.(...R),onParamsChange:(...R)=>_.current?.(...R),onFocus:()=>ee.current?.(),onBlur:()=>te.current?.(),onProductSelect:R=>ie.current?.(R),setCursor:R=>ae.current?.(R),products:L.config});h.current=m,pe(m.getState());let K=m.subscribe(R=>pe(R));return()=>{K(),m.destroy(),h.current===m&&(h.current=null)}},[]),Re(()=>{A!==void 0&&h.current?.setValue(A)},[A]),Re(()=>{O!==void 0&&h.current?.setCompletedParams(O)},[O]);let g=JSON.stringify(a??null),t;try{t=JSON.stringify(o??null)}catch{t="[unstringifiable]"}Re(()=>{h.current?.update({apiConfig:a,additionalContext:o,optionOverrides:l.overrides,dropdownTrigger:v,optionsPosition:f,closeDropdownOnBlur:w,showNonTappableOptions:p,showProducts:E})},[g,t,l.key,v,f,w,p,E]);let x=W(!1);Re(()=>{if(!x.current){x.current=!0;return}h.current?.update({products:L.config})},[L.enabled]);let b=W(null);b.current===null&&(b.current={handleTextChange:m=>h.current?.handleTextChange(m),handleKeyDown:m=>{let K="nativeEvent"in m?m.nativeEvent:m;h.current?.handleKeyDown(K)},setFocused:m=>h.current?.setFocused(m),startEditingParam:m=>h.current?.startEditingParam(m),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:m=>h.current?.handleCaretAfterInput(m),handleCaretMove:m=>h.current?.handleCaretMove(m),replaceEditingRange:m=>h.current?.replaceEditingRange(m)??!1,setActivePill:m=>h.current?.setActivePill(m),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:m=>h.current?.selectOption(m),selectProduct:m=>h.current?.selectProduct(m),setActiveDropdownIndex:m=>h.current?.setActiveDropdownIndex(m),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let c=b.current,F=Rt(m=>{let K=m.target.value,Ge=K.length>0&&!m.nativeEvent?.isComposing&&K[0]!==K[0].toUpperCase()?K[0].toUpperCase()+K.slice(1):K;h.current?.handleTextChange(Ge)},[]),q=Rt(m=>{h.current?.handleKeyDown(m.nativeEvent)},[]),oe=h.current,d=B??$a,ne=A!==void 0?A:d.text,me=O!==void 0?O:d.completedParams,re=d.actionableSuggestions,xe=re[0],se=oe?.listboxId??"",Se=d.activeDropdownIndex>=0&&oe?`${se}-option-${d.activeDropdownIndex}`:void 0,U=d.editingParam,N=d.editingIdentified,ye=U?{type:U.suggestionType,text:U.suggestionPlaceholder,required:!0,options:U.options}:N?{type:N.type,text:Qa(N.type),required:!0,options:[]}:null,Ie=ye??xe,Ke=ye?[ye]:re,Ee=ja(d),Le=!oe||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:me,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:re,setActivePill:c.setActivePill,skipActivePill:c.skipActivePill,removeLastParam:c.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:c.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Le,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:se,error:d.error,products:d.products,customFields:d.customFields,selectProduct:c.selectProduct,handleTextChange:c.handleTextChange,handleKeyDown:c.handleKeyDown,setFocused:c.setFocused,editingParam:U,editingIdentified:N,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:c.startEditingParam,exitEditMode:c.exitEditMode,handleCaretAfterInput:c.handleCaretAfterInput,handleCaretMove:c.handleCaretMove,replaceEditingRange:c.replaceEditingRange,inputProps:{value:ne,placeholder:d.placeholderText||void 0,onChange:F,onKeyDown:q,onFocus:c.handleFocus,onBlur:c.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":Se,"aria-autocomplete":"list","aria-controls":se},reset:c.reset,dropdownProps:{suggestions:Ie?[{...Ie,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:c.selectOption,onHighlight:c.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:se,pills:Ke,activeSelected:d.isActivePillSelected,onPillClick:c.setActivePill,onSkip:c.skipActivePill,showSkipButton:(M??!0)&&!U&&!N,showOptionIcons:k??!0,showOptionImages:P??!0,showOptionCounts:y??!0,skipDisabled:d.inSelectionAnimation,isLoading:Le,isInputEmpty:ne.trim().length===0,products:d.products,onProductSelect:c.selectProduct,onProductFocusChange:c.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Ee.selectedIso,selectedDateRange:Ee.selectedRange,dateRangeStart:Ee.rangeStart,onPreviousMonth:c.showPreviousMonth,onNextMonth:c.showNextMonth,optionsPosition:f??"below"}}}import{extractPlainText as Dt,getCursorOffset as Lt,plainTextLength as Va,renderEditableContent as Za,setCursorOffset as Ot}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Q,useEffect as et,useLayoutEffect as tt,useRef as Ce}from"react";var Fe;function Xa(){if(Fe!==void 0)return Fe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Fe=e.contentEditable==="plaintext-only",Fe}function Mt(e){let{segments:n,showChipIcons:i=!0,showChipImages:r=!0,newParamId:s,editingParam:a,editingIdentified:o,editingAnchor:u,caretOffset:v,placeholderText:f,isFocused:w,isDropdownOpen:p,listboxId:k,activeDescendantId:P,autoFocus:y,handleTextChange:M,handleKeyDown:E,handleCaretAfterInput:S,handleCaretMove:D,startEditingParam:A,replaceEditingRange:O,setFocused:z}=e,C=Ce(null),$=Ce(!1),V=Ce(""),ce=Ce(""),Z=Ce(null),h=Ce(0);Z.current=v,et(()=>{if(!y)return;let l=C.current;if(!l)return;document.activeElement===l?z(!0):l.focus();let g=l.ownerDocument??document,t=g.getSelection(),x=t&&t.rangeCount>0&&l.contains(t.anchorNode);if(t&&!x){let b=g.createRange();b.selectNodeContents(l),b.collapse(!0),t.removeAllRanges(),t.addRange(b)}},[y,z]),et(()=>{let l=C.current;if(!l)return;let g=l.ownerDocument??document,t=()=>{let x=g.getSelection();if(!x||x.rangeCount===0||!x.anchorNode||!l.contains(x.anchorNode))return;let b=x.anchorNode,c=b.nodeType===Node.ELEMENT_NODE?b:b.parentElement,q=(x.isCollapsed?c?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,oe=a?.id??o?.id??null;if(q&&q!==oe){A(q);return}performance.now()-h.current<50||D(Lt(l))};return g.addEventListener("selectionchange",t),()=>g.removeEventListener("selectionchange",t)},[a,o,A,D]),tt(()=>{let l=C.current;l&&Za({input:l,segments:n,newParamId:s,editingParamId:a?.id??null,placeholderText:f??"",isFocused:w,showChipIcons:i,showChipImages:r})},[n,s,a,f,w,i,r]),tt(()=>{let l=V.current,g=s??"";if(V.current=g,!g||g===l)return;let t=C.current;if(!t)return;t.focus();let x=Z.current??Va(t);Ot(t,x)},[s]),tt(()=>{let l=ce.current,g=a?.id??"";if(ce.current=g,!g||g===l||u==null)return;let t=C.current;t&&Ot(t,u)},[a,u]);let B=Q(()=>{if($.current)return;let l=C.current;if(!l)return;let g=Dt(l),x=g.length>0&&g[0]!==g[0].toUpperCase()?g[0].toUpperCase()+g.slice(1):g;M(x)},[M]),pe=Q(()=>{h.current=performance.now(),B();let l=C.current;l&&S(Lt(l))},[B,S]);et(()=>{let l=C.current;if(!l)return;let g=t=>{let x=t,b=x.inputType;if(b==="insertParagraph"||b==="insertLineBreak"||b==="insertFromDrop"){t.preventDefault();return}if(b.startsWith("insert")||b.startsWith("delete")){let c=b.startsWith("delete")?"":x.data??"";O(c)&&t.preventDefault()}};return l.addEventListener("beforeinput",g),()=>l.removeEventListener("beforeinput",g)},[O]);let X=Q(()=>{$.current=!0},[]),he=Q(()=>{$.current=!1,B()},[B]),J=Q(l=>{l.preventDefault();let g=C.current;if(!g)return;let t=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!t)return;let x=g.ownerDocument??document,b=x.getSelection();if(!b||b.rangeCount===0)return;let c=b.getRangeAt(0);if(!g.contains(c.startContainer))return;c.deleteContents();let F=x.createTextNode(t);c.insertNode(F),c.setStartAfter(F),c.collapse(!0),b.removeAllRanges(),b.addRange(c),B()},[B]),ue=Q(l=>E(l),[E]),_=Q(()=>z(!0),[z]),ee=Q(()=>z(!1),[z]),te=Q(()=>C.current?.focus(),[]),ae=Q(()=>C.current?.blur(),[]),ie=Q(()=>{let l=C.current;return l?Dt(l):""},[]),L=Xa()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:L,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":k,"aria-expanded":p,"aria-activedescendant":P,spellCheck:!0,enterKeyHint:"send",onInput:pe,onKeyDown:ue,onCompositionStart:X,onCompositionEnd:he,onPaste:J,onFocus:_,onBlur:ee},getPlainText:ie,focus:te,blur:ae}}import{jsx as Pe,jsxs as it}from"react/jsx-runtime";function ni(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ri=Ja(function({onSubmit:n,onResult:i,onError:r,optionOverrides:s,maskCompletedText:a,className:o,apiConfig:u,additionalContext:v,columns:f,pillPlacement:w="dropdown",mode:p="auto",optionsPosition:k="below",animations:P=!0,dropdownTrigger:y,closeDropdownOnBlur:M,showNonTappableOptions:E,showOptionIcons:S=!0,showChipIcons:D=!0,showChipImages:A=!0,showOptionImages:O=!0,showOptionCounts:z=!0,showSkipButton:C,showProducts:$,productsLayout:V,autoFocus:ce=!0,onFocus:Z,onBlur:h,value:B,completedParams:pe,onChange:X,onParamsChange:he,products:J,onProductSelect:ue,submitButton:_},ee){let te=De(null),ae=De(null),ie=De(()=>{}),L=De(null),l=De(null);zt(()=>{let I=te.current;if(I)return L.current?L.current.setMode(p):L.current=new ii(I,p),()=>{L.current?.destroy(),L.current=null}},[p]);let g=at(I=>{let fe=l.current?.current;fe&&(fe.focus(),oi(fe,I))},[]),{completedParams:t,skippedParams:x,identifiedParams:b,isReady:c,customFields:F,suggestionPills:q,setActivePill:oe,skipActivePill:d,segments:ne,newParamId:me,clearNewParamId:re,placeholderText:xe,isFocused:se,isDropdownOpen:Se,isActivePillSelected:U,isLoading:N,activeIndex:ye,listboxId:Ie,handleTextChange:Ke,handleKeyDown:Ee,setFocused:Le,editingParam:m,editingIdentified:K,editingAnchor:R,caretOffset:Ge,startEditingParam:Nt,handleCaretAfterInput:Ht,handleCaretMove:Bt,replaceEditingRange:Ft,dropdownProps:Kt,reset:Oe}=Je({onSubmit:I=>ie.current(I),onResult:i,onError:r,optionOverrides:s,maskCompletedText:a,apiConfig:u,additionalContext:v,columns:f,dropdownTrigger:y,optionsPosition:k,closeDropdownOnBlur:M,showNonTappableOptions:E,showOptionIcons:S,showOptionImages:O,showOptionCounts:z,showSkipButton:C,showProducts:$,onFocus:Z,onBlur:h,value:B,completedParams:pe,onChange:X,onParamsChange:he,products:J,onProductSelect:ue,source:"full-sdk",setCursor:g});zt(()=>{if(!me)return;let I=window.setTimeout(()=>re(),650);return()=>window.clearTimeout(I)},[me,re]);let Gt=ye>=0?`${Ie}-option-${ye}`:void 0,{inputRef:We,editorProps:Wt,focus:Me,blur:ot,getPlainText:nt}=Mt({segments:ne,newParamId:me,editingParam:m,editingIdentified:K,editingAnchor:R,caretOffset:Ge,placeholderText:xe,isFocused:se,showChipIcons:D,showChipImages:A,isDropdownOpen:Se,listboxId:Ie,activeDescendantId:Gt,autoFocus:ce,handleTextChange:Ke,handleKeyDown:Ee,handleCaretAfterInput:Ht,handleCaretMove:Bt,startEditingParam:Nt,replaceEditingRange:Ft,setFocused:Le});l.current=We,ti(()=>{let I=ae.current,fe=We.current;if(!I||!fe)return;let rt=()=>{let lt=I.firstElementChild;if(!lt)return;let jt=lt.getBoundingClientRect(),Qt=fe.getBoundingClientRect();jt.top>=Qt.bottom-2?I.setAttribute("data-aia-pill-wrapped",""):I.removeAttribute("data-aia-pill-wrapped")};rt();let st=new ResizeObserver(rt);return st.observe(fe),()=>st.disconnect()},[ne,q.length,N,We]),ei(ee,()=>({focus:Me,blur:ot,reset:Oe,setMode:I=>L.current?.setMode(I),skipActivePill:d}),[Me,ot,Oe,d]);let ze=!!ne.length||t.length>0,_e=at(()=>{if(!ze)return;let I=nt();n(ai(I,t,x,{identifiedParams:b,isReady:c,customFields:F})),Oe()},[ze,t,x,b,c,F,n,Oe,nt]);ie.current=_e;let _t=at(I=>{I.target?.closest("[data-aia-pill]")||Me()},[Me]),qt=w==="inline",Ut=w==="dropdown";return it("div",{ref:te,className:`magicx-aia ${ve.container} ${o??""}`,"data-pill-placement":w,"data-options-position":k,"data-animations":P?"on":"off","data-mode":ni(p),children:[Pe(Ze,{...Kt,showPills:Ut,productsLayout:V}),it("div",{className:ve.inputWrapper,"data-aia-input-wrapper":"",onClick:_t,children:[it("div",{className:ve.editorArea,"data-aia-editor":"",children:[Pe("div",{...Wt,className:ve.input,"data-aia-input":""}),qt&&(N||q.length>0)&&Pe("span",{ref:ae,className:ve.pillListContainer,"data-aia-pill-list-container":"",children:Pe(He,{pills:q,activePillIndex:0,activeSelected:U,onSelectPill:oe,loading:N})})]}),_===null?null:_===void 0?Pe(St,{disabled:!ze,onClick:_e}):Pe("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ve.submitSlot,onClick:I=>{ze&&(I.stopPropagation(),_e())},children:_})]})]})});export{ri as AIAutocomplete,Ze as AIAutocompleteDropdown,en as DATE_RANGE_META_END,tn as DATE_RANGE_META_START,an as DEFAULT_OPTION_COUNT_UNIT,mn as PRODUCT_PATH_PREFIX,Cn as WEEKDAY_LABELS,Zo as buildSubmitResult,Xo as cellDay,Jo as cellIso,on as dateCellMarks,nn as formatDate,rn as formatDateRange,sn as formatOptionCount,ln as isoDate,dn as monthLabel,cn as optionCountLabel,pn as optionHasImage,hn as optionImageSrc,un as optionLabel,fn as parseDate,gn as parseLooseDate,bn as parseLooseDateRange,vn as productFromMatchedItem,wn as productsFromCustomFields,xn as sanitizeOptionIconSvg,yn as selectedRangeFor,Je as useAIAutocomplete,kn as visibleDateRange,Pn as withSkippedParams};
2146
+ `,document.head.appendChild(e)}var St={submitButton:"aia-submitButton-otz7H"};import{jsx as Xe}from"react/jsx-runtime";function It({disabled:e,onClick:n}){return Xe("button",{type:"button","data-aia-submit":"",className:St.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),n()},"aria-label":"Submit",children:Xe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Xe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ja,dateSelectionFor as Qa,identifiedParamLabel as Ya}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Dt,useEffect as Re,useRef as W,useState as $a}from"react";import{useRef as Et}from"react";function Tt(e){let n=Et(e);n.current=e;let a=Object.keys(e??{}).sort().join("\0"),r=Et({key:"",overrides:void 0});if(r.current.key!==a){let s={};for(let t of Object.keys(e??{})){let o=(u,w,b)=>{let x=n.current?.[t];return x?x(u,w,b):[]};s[t]=o}r.current={key:a,overrides:e?s:void 0}}return{overrides:r.current.overrides,key:a}}import{useRef as At}from"react";function Rt(e){let n=At(e);n.current=e;let a=At(null);a.current===null&&(a.current={fetch:(s,t)=>{let o=n.current;return o?o.fetch(s,t):Promise.reject(new Error("products config removed"))},transform:s=>n.current?.transform(s)??[],get limit(){return n.current?.limit}});let r=e!==void 0;return{config:r?a.current:void 0,enabled:r}}var Va={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 Je({onSubmit:e,onResult:n,onError:a,optionOverrides:r,maskCompletedText:s,apiConfig:t,additionalContext:o,columns:u=2,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:p,showOptionIcons:k,showOptionImages:S,showOptionCounts:y,showSkipButton:z,showProducts:O,onFocus:P,onBlur:T,value:I,completedParams:R,onChange:L,onParamsChange:C,products:Z,onProductSelect:X,source:pe,setCursor:J}){let h=W(null),[H,he]=$a(null),ue=W(e);ue.current=e;let ee=W(n);ee.current=n;let me=W(a);me.current=a;let te=W(L);te.current=L;let j=W(C);j.current=C;let ae=W(P);ae.current=P;let Q=W(T);Q.current=T;let ie=W(J);ie.current=J;let oe=W(X);oe.current=X;let M=Rt(Z),l=Tt(r);Re(()=>{if(typeof document>"u")return;let g=new ja(document.createElement("div"),{renderMode:"headless",apiConfig:t,additionalContext:o,optionOverrides:l.overrides,maskCompletedText:s,columns:u,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:p,showProducts:O,source:pe,value:I,completedParams:R,onSubmit:(...D)=>ue.current?.(...D),onResult:(...D)=>ee.current?.(...D),onError:(...D)=>me.current?.(...D),onChange:(...D)=>te.current?.(...D),onParamsChange:(...D)=>j.current?.(...D),onFocus:()=>ae.current?.(),onBlur:()=>Q.current?.(),onProductSelect:D=>oe.current?.(D),setCursor:D=>ie.current?.(D),products:M.config});h.current=g,he(g.getState());let K=g.subscribe(D=>he(D));return()=>{K(),g.destroy(),h.current===g&&(h.current=null)}},[]),Re(()=>{I!==void 0&&h.current?.setValue(I)},[I]),Re(()=>{R!==void 0&&h.current?.setCompletedParams(R)},[R]);let m=JSON.stringify(t??null),f;try{f=JSON.stringify(o??null)}catch{f="[unstringifiable]"}Re(()=>{h.current?.update({apiConfig:t,additionalContext:o,optionOverrides:l.overrides,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:p,showProducts:O})},[m,f,l.key,w,b,x,p,O]);let i=W(!1);Re(()=>{if(!i.current){i.current=!0;return}h.current?.update({products:M.config})},[M.enabled]);let v=W(null);v.current===null&&(v.current={handleTextChange:g=>h.current?.handleTextChange(g),handleKeyDown:g=>{let K="nativeEvent"in g?g.nativeEvent:g;h.current?.handleKeyDown(K)},setFocused:g=>h.current?.setFocused(g),startEditingParam:g=>h.current?.startEditingParam(g),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:g=>h.current?.handleCaretAfterInput(g),handleCaretMove:g=>h.current?.handleCaretMove(g),replaceEditingRange:g=>h.current?.replaceEditingRange(g)??!1,setActivePill:g=>h.current?.setActivePill(g),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:g=>h.current?.selectOption(g),selectProduct:g=>h.current?.selectProduct(g),setActiveDropdownIndex:g=>h.current?.setActiveDropdownIndex(g),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let d=v.current,Y=Dt(g=>{let K=g.target.value,Ge=K.length>0&&!g.nativeEvent?.isComposing&&K[0]!==K[0].toUpperCase()?K[0].toUpperCase()+K.slice(1):K;h.current?.handleTextChange(Ge)},[]),N=Dt(g=>{h.current?.handleKeyDown(g.nativeEvent)},[]),ne=h.current,c=H??Va,re=I!==void 0?I:c.text,fe=R!==void 0?R:c.completedParams,se=c.actionableSuggestions,ye=se[0],le=ne?.listboxId??"",ke=c.activeDropdownIndex>=0&&ne?`${le}-option-${c.activeDropdownIndex}`:void 0,$=c.editingParam,F=c.editingIdentified,_=$?{type:$.suggestionType,text:$.suggestionPlaceholder,required:!0,options:$.options}:F?{type:F.type,text:Ya(F.type),required:!0,options:[]}:null,Ie=c.dropdownSuggestion??_??ye,Ke=_?[_]:se,Ee=Qa(c),Oe=!ne||c.dropdownLoading;return{completedParams:fe,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:se,setActivePill:d.setActivePill,skipActivePill:d.skipActivePill,removeLastParam:d.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:d.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:Oe,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:le,error:c.error,products:c.products,customFields:c.customFields,selectProduct:d.selectProduct,handleTextChange:d.handleTextChange,handleKeyDown:d.handleKeyDown,setFocused:d.setFocused,editingParam:$,editingIdentified:F,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:d.startEditingParam,exitEditMode:d.exitEditMode,handleCaretAfterInput:d.handleCaretAfterInput,handleCaretMove:d.handleCaretMove,replaceEditingRange:d.replaceEditingRange,inputProps:{value:re,placeholder:c.placeholderText||void 0,onChange:Y,onKeyDown:N,onFocus:d.handleFocus,onBlur:d.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":ke,"aria-autocomplete":"list","aria-controls":le},reset:d.reset,dropdownProps:{suggestions:Ie?[{...Ie,options:c.dropdownOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:d.selectOption,onHighlight:d.setActiveDropdownIndex,isOpen:c.isDropdownOpen,id:le,pills:Ke,activeSelected:c.isActivePillSelected,onPillClick:d.setActivePill,onSkip:d.skipActivePill,showSkipButton:(z??!0)&&!$&&!F,showOptionIcons:k??!0,showOptionImages:S??!0,showOptionCounts:y??!0,skipDisabled:c.inSelectionAnimation,isLoading:Oe,skeletonExiting:c.skeletonExiting,isInputEmpty:re.trim().length===0,products:c.products,onProductSelect:d.selectProduct,onProductFocusChange:d.setFocused,formatType:c.activeFormatType,dateView:c.dateView,selectedDateIso:Ee.selectedIso,selectedDateRange:Ee.selectedRange,dateRangeStart:Ee.rangeStart,onPreviousMonth:d.showPreviousMonth,onNextMonth:d.showNextMonth,optionsPosition:b??"below"}}}import{extractPlainText as Ot,getCursorOffset as Lt,plainTextLength as Za,renderEditableContent as Xa,setCursorOffset as Mt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as et,useLayoutEffect as tt,useRef as Pe}from"react";var Fe;function Ja(){if(Fe!==void 0)return Fe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Fe=e.contentEditable==="plaintext-only",Fe}function zt(e){let{segments:n,showChipIcons:a=!0,showChipImages:r=!0,newParamId:s,editingParam:t,editingIdentified:o,editingAnchor:u,caretOffset:w,placeholderText:b,isFocused:x,isDropdownOpen:p,listboxId:k,activeDescendantId:S,autoFocus:y,handleTextChange:z,handleKeyDown:O,handleCaretAfterInput:P,handleCaretMove:T,startEditingParam:I,replaceEditingRange:R,setFocused:L}=e,C=Pe(null),Z=Pe(!1),X=Pe(""),pe=Pe(""),J=Pe(null),h=Pe(0);J.current=w,et(()=>{if(!y)return;let l=C.current;if(!l)return;document.activeElement===l?L(!0):l.focus();let m=l.ownerDocument??document,f=m.getSelection(),i=f&&f.rangeCount>0&&l.contains(f.anchorNode);if(f&&!i){let v=m.createRange();v.selectNodeContents(l),v.collapse(!0),f.removeAllRanges(),f.addRange(v)}},[y,L]),et(()=>{let l=C.current;if(!l)return;let m=l.ownerDocument??document,f=()=>{let i=m.getSelection();if(!i||i.rangeCount===0||!i.anchorNode||!l.contains(i.anchorNode))return;let v=i.anchorNode,d=v.nodeType===Node.ELEMENT_NODE?v:v.parentElement,N=(i.isCollapsed?d?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ne=t?.id??o?.id??null;if(N&&N!==ne){I(N);return}performance.now()-h.current<50||T(Lt(l))};return m.addEventListener("selectionchange",f),()=>m.removeEventListener("selectionchange",f)},[t,o,I,T]),tt(()=>{let l=C.current;l&&Xa({input:l,segments:n,newParamId:s,editingParamId:t?.id??null,placeholderText:b??"",isFocused:x,showChipIcons:a,showChipImages:r})},[n,s,t,b,x,a,r]),tt(()=>{let l=X.current,m=s??"";if(X.current=m,!m||m===l)return;let f=C.current;if(!f)return;f.focus();let i=J.current??Za(f);Mt(f,i)},[s]),tt(()=>{let l=pe.current,m=t?.id??"";if(pe.current=m,!m||m===l||u==null)return;let f=C.current;f&&Mt(f,u)},[t,u]);let H=U(()=>{if(Z.current)return;let l=C.current;if(!l)return;let m=Ot(l),i=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;z(i)},[z]),he=U(()=>{h.current=performance.now(),H();let l=C.current;l&&P(Lt(l))},[H,P]);et(()=>{let l=C.current;if(!l)return;let m=f=>{let i=f,v=i.inputType;if(v==="insertParagraph"||v==="insertLineBreak"||v==="insertFromDrop"){f.preventDefault();return}if(v.startsWith("insert")||v.startsWith("delete")){let d=v.startsWith("delete")?"":i.data??"";R(d)&&f.preventDefault()}};return l.addEventListener("beforeinput",m),()=>l.removeEventListener("beforeinput",m)},[R]);let ue=U(()=>{Z.current=!0},[]),ee=U(()=>{Z.current=!1,H()},[H]),me=U(l=>{l.preventDefault();let m=C.current;if(!m)return;let f=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let i=m.ownerDocument??document,v=i.getSelection();if(!v||v.rangeCount===0)return;let d=v.getRangeAt(0);if(!m.contains(d.startContainer))return;d.deleteContents();let Y=i.createTextNode(f);d.insertNode(Y),d.setStartAfter(Y),d.collapse(!0),v.removeAllRanges(),v.addRange(d),H()},[H]),te=U(l=>O(l),[O]),j=U(()=>L(!0),[L]),ae=U(()=>L(!1),[L]),Q=U(()=>C.current?.focus(),[]),ie=U(()=>C.current?.blur(),[]),oe=U(()=>{let l=C.current;return l?Ot(l):""},[]),M=Ja()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:M,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":k,"aria-expanded":p,"aria-activedescendant":S,spellCheck:!0,enterKeyHint:"send",onInput:he,onKeyDown:te,onCompositionStart:ue,onCompositionEnd:ee,onPaste:me,onFocus:j,onBlur:ae},getPlainText:oe,focus:Q,blur:ie}}import{jsx as Se,jsxs as it}from"react/jsx-runtime";function ri(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var si=ei(function({onSubmit:n,onResult:a,onError:r,optionOverrides:s,maskCompletedText:t,className:o,apiConfig:u,additionalContext:w,columns:b,pillPlacement:x="dropdown",mode:p="auto",optionsPosition:k="below",animations:S=!0,dropdownTrigger:y,closeDropdownOnBlur:z,showNonTappableOptions:O,showOptionIcons:P=!0,showChipIcons:T=!0,showChipImages:I=!0,showOptionImages:R=!0,showOptionCounts:L=!0,showSkipButton:C,showProducts:Z,productsLayout:X,autoFocus:pe=!0,onFocus:J,onBlur:h,value:H,completedParams:he,onChange:ue,onParamsChange:ee,products:me,onProductSelect:te,submitButton:j},ae){let Q=De(null),ie=De(null),oe=De(()=>{}),M=De(null),l=De(null);Nt(()=>{let E=Q.current;if(E)return M.current?M.current.setMode(p):M.current=new oi(E,p),()=>{M.current?.destroy(),M.current=null}},[p]);let m=at(E=>{let ge=l.current?.current;ge&&(ge.focus(),ni(ge,E))},[]),{completedParams:f,skippedParams:i,identifiedParams:v,isReady:d,customFields:Y,suggestionPills:N,setActivePill:ne,skipActivePill:c,segments:re,newParamId:fe,clearNewParamId:se,placeholderText:ye,isFocused:le,isDropdownOpen:ke,isActivePillSelected:$,isLoading:F,activeIndex:_,listboxId:Ie,handleTextChange:Ke,handleKeyDown:Ee,setFocused:Oe,editingParam:g,editingIdentified:K,editingAnchor:D,caretOffset:Ge,startEditingParam:Bt,handleCaretAfterInput:Ht,handleCaretMove:Ft,replaceEditingRange:Kt,dropdownProps:Gt,reset:Le}=Je({onSubmit:E=>oe.current(E),onResult:a,onError:r,optionOverrides:s,maskCompletedText:t,apiConfig:u,additionalContext:w,columns:b,dropdownTrigger:y,optionsPosition:k,closeDropdownOnBlur:z,showNonTappableOptions:O,showOptionIcons:P,showOptionImages:R,showOptionCounts:L,showSkipButton:C,showProducts:Z,onFocus:J,onBlur:h,value:H,completedParams:he,onChange:ue,onParamsChange:ee,products:me,onProductSelect:te,source:"full-sdk",setCursor:m});Nt(()=>{if(!fe)return;let E=window.setTimeout(()=>se(),650);return()=>window.clearTimeout(E)},[fe,se]);let Wt=_>=0?`${Ie}-option-${_}`:void 0,{inputRef:We,editorProps:_t,focus:Me,blur:ot,getPlainText:nt}=zt({segments:re,newParamId:fe,editingParam:g,editingIdentified:K,editingAnchor:D,caretOffset:Ge,placeholderText:ye,isFocused:le,showChipIcons:T,showChipImages:I,isDropdownOpen:ke,listboxId:Ie,activeDescendantId:Wt,autoFocus:pe,handleTextChange:Ke,handleKeyDown:Ee,handleCaretAfterInput:Ht,handleCaretMove:Ft,startEditingParam:Bt,replaceEditingRange:Kt,setFocused:Oe});l.current=We,ai(()=>{let E=ie.current,ge=We.current;if(!E||!ge)return;let rt=()=>{let lt=E.firstElementChild;if(!lt)return;let Qt=lt.getBoundingClientRect(),Yt=ge.getBoundingClientRect();Qt.top>=Yt.bottom-2?E.setAttribute("data-aia-pill-wrapped",""):E.removeAttribute("data-aia-pill-wrapped")};rt();let st=new ResizeObserver(rt);return st.observe(ge),()=>st.disconnect()},[re,N.length,F,We]),ti(ae,()=>({focus:Me,blur:ot,reset:Le,setMode:E=>M.current?.setMode(E),skipActivePill:c}),[Me,ot,Le,c]);let ze=!!re.length||f.length>0,_e=at(()=>{if(!ze)return;let E=nt();n(ii(E,f,i,{identifiedParams:v,isReady:d,customFields:Y})),Le()},[ze,f,i,v,d,Y,n,Le,nt]);oe.current=_e;let qt=at(E=>{E.target?.closest("[data-aia-pill]")||Me()},[Me]),Ut=x==="inline",jt=x==="dropdown";return it("div",{ref:Q,className:`magicx-aia ${we.container} ${o??""}`,"data-pill-placement":x,"data-options-position":k,"data-animations":S?"on":"off","data-mode":ri(p),children:[Se(Ze,{...Gt,showPills:jt,productsLayout:X}),it("div",{className:we.inputWrapper,"data-aia-input-wrapper":"",onClick:qt,children:[it("div",{className:we.editorArea,"data-aia-editor":"",children:[Se("div",{..._t,className:we.input,"data-aia-input":""}),Ut&&(F||N.length>0)&&Se("span",{ref:ie,className:we.pillListContainer,"data-aia-pill-list-container":"",children:Se(Be,{pills:N,activePillIndex:0,activeSelected:$,onSelectPill:ne,loading:F})})]}),j===null?null:j===void 0?Se(It,{disabled:!ze,onClick:_e}):Se("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:we.submitSlot,onClick:E=>{ze&&(E.stopPropagation(),_e())},children:j})]})]})});export{si as AIAutocomplete,Ze as AIAutocompleteDropdown,tn as DATE_RANGE_META_END,an as DATE_RANGE_META_START,on as DEFAULT_OPTION_COUNT_UNIT,fn as PRODUCT_PATH_PREFIX,Pn as WEEKDAY_LABELS,Xo as buildSubmitResult,Jo as cellDay,en as cellIso,nn as dateCellMarks,rn as formatDate,sn as formatDateRange,ln as formatOptionCount,dn as isoDate,cn as monthLabel,pn as optionCountLabel,hn as optionHasImage,un as optionImageSrc,mn as optionLabel,gn as parseDate,bn as parseLooseDate,vn as parseLooseDateRange,wn as productFromMatchedItem,xn as productsFromCustomFields,yn as sanitizeOptionIconSvg,kn as selectedRangeFor,Je as useAIAutocomplete,Cn as visibleDateRange,Sn as withSkippedParams};
2065
2147
  //# sourceMappingURL=index.mjs.map