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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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 an,cellDay as on,cellIso as nn,DATE_RANGE_META_END as rn,DATE_RANGE_META_START as sn,DEFAULT_OPTION_COUNT_UNIT as ln,dateCellMarks as dn,formatDate as cn,formatDateRange as pn,formatOptionCount as hn,isoDate as un,monthLabel as mn,optionCountLabel as gn,optionHasImage as fn,optionImageSrc as bn,optionLabel as vn,PRODUCT_PATH_PREFIX as wn,parseDate as xn,parseLooseDate as yn,parseLooseDateRange as kn,productFromMatchedItem as Cn,productsFromCustomFields as Pn,sanitizeOptionIconSvg as Sn,selectedRangeFor as In,visibleDateRange as En,WEEKDAY_LABELS as Tn,withSkippedParams as An}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as oi,useCallback as it,useEffect as Bt,useImperativeHandle as ni,useLayoutEffect as ri,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 xe={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 Wa,isCalendarFormat as _a,SCROLL_ARROW_LABEL as qa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ve,useRef as Ke,useState as Ua}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 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 $t,cellIso as Pe,dateCellMarks as Vt,isoDate as Xt,monthLabel as Jt,visibleDateRange as ea,WEEKDAY_LABELS as ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as aa}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 $,jsxs as ct}from"react/jsx-runtime";var ia=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function pt({options:e,activeIndex:o,listboxId:a,view:n,selection:r,onSelect:t,onHighlight:s,onPreviousMonth:l,onNextMonth:v}){let w=Xt(new Date),f=ea({pendingStart:r.rangeStart,highlightedIso:Pe(e[o]),selected:r.selectedRange});return ct("div",{className:A.datepicker,"data-aia-datepicker":"",children:[ct("div",{className:A.header,children:[$("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:h=>h.preventDefault(),onClick:l,children:"\u2039"}),$("span",{className:A.month,"data-aia-date-month":"","aria-live":"polite",children:Jt(n)}),$("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:h=>h.preventDefault(),onClick:v,children:"\u203A"})]}),$("div",{className:A.weekdays,"aria-hidden":"true",children:ta.map((h,k)=>$("span",{className:A.weekday,children:h},ia[k]))}),$("div",{className:A.grid,"data-aia-date-grid":"",children:e.map((h,k)=>$(oa,{option:h,id:`${a}-option-${k}`,index:k,isHighlighted:k===o&&h.is_tappable,isToday:Pe(h)===w,isPast:Pe(h)!=null&&Pe(h)<w,marks:Vt(Pe(h),{selectedIso:r.selectedIso,range:f}),onSelect:t,onHighlight:s},Pe(h)??`pad-${k}`))})]})}function oa({option:e,id:o,index:a,isHighlighted:n,isToday:r,isPast:t,marks:s,onSelect:l,onHighlight:v}){let[w,f]=aa(!1),h=$t(e);if(h==null)return $("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 k=()=>{f(!0),l(e),setTimeout(()=>f(!1),170)},S=[A.cell,A.day,t?A.past:"",n?A.highlighted:"",r?A.today:"",s.inRange?A.inRange:"",s.selected?A.selected:"",w?A.pressed:""].filter(Boolean).join(" ");return $("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:S,onClick:k,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),k())},onMouseEnter:()=>v(a),children:$("span",{className:A.number,children:h})})}import{ATTRIBUTION_URL as na,buildAttributionUrl as ra,getFooterHint as sa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as la,useState as da}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 ht}from"react/jsx-runtime";function Ae({gap:e,align:o="center",justify:a="start",noWrap:n=!1,inline:r=!1,className:t,children:s,...l}){let v=e?{"--aia-cluster-gap":e}:void 0,w={className:t?`aia-cluster ${t}`:"aia-cluster","data-align":o,"data-justify":a,"data-nowrap":n||void 0,"data-inline":r||void 0,style:v,...l};return r?ht("span",{...w,children:s}):ht("div",{...w,children:s})}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 le={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 Re,jsxs as Qe}from"react/jsx-runtime";function ut({isOptionHighlighted:e=!1,isInputEmpty:o=!1}){let{key:a,hint:n}=sa(e,o),[r,t]=da(na);return la(()=>{t(ra())},[]),Re("footer",{className:le.footer,"data-aia-footer":"",children:Qe(Ae,{justify:"between",noWrap:!0,className:le.row,children:[Qe(Ae,{gap:"5px",className:le.hintGroup,children:[Re("kbd",{className:le.key,children:a}),Re("span",{className:le.hint,children:n})]}),Qe("a",{className:le.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[Re("span",{className:le.brand,children:"AI"}),Re("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,
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 fe={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 ca}from"react/jsx-runtime";var Ye={selected:1,first:.7,next:.4,last:.2};function mt({label:e,state:o,rounded:a,loading:n,onClick:r}){let t=[fe.pill,a?fe.rounded:"",n?fe.skeleton:""].filter(Boolean).join(" ");return ca("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:t,style:{opacity:Ye[o]},onMouseDown:s=>s.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 {
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 Be}from"react/jsx-runtime";var pa=[125,69];function gt(e){return e===0?"first":e===1?"next":"last"}function He({pills:e,activePillIndex:o,onSelectPill:a,activeSelected:n,rounded:r,loading:t}){return t&&e.length===0?Be("span",{className:je.list,"data-aia-pill-list-loading":"",children:pa.map((s,l)=>Be("span",{"data-aia-pill-skeleton":"",className:`${fe.pill} ${r?fe.rounded:""} ${fe.skeleton}`,style:{width:s,opacity:Ye[gt(l)]}},`skel-${s}`))}):Be("span",{className:je.list,"data-aia-pill-list-loading":t?"":void 0,children:e.map((s,l)=>{let v=!!n&&l===o;return Be(mt,{label:s.text,state:v?"selected":gt(l),selected:v,rounded:r,loading:t,onClick:()=>a(l)},`${s.type}-${s.text}`)})})}import{attachProductRowWheel as ha,productInitial as ua}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ma,useRef as ga,useState as fa}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
 
@@ -1540,6 +1579,16 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1540
1579
  the same media fill, so a card without art reads as "no photo" instead of
1541
1580
  broken. The pictogram is inlined as a data URI so the placeholder needs no
1542
1581
  network and no asset pipeline; --aia-product-placeholder-image swaps it. */
1582
+ .aia-media-RrbGe:where([data-aia-product-initial]) {
1583
+ display: flex;
1584
+ align-items: center;
1585
+ justify-content: center;
1586
+ color: var(--aia-product-title-color, var(--aia-option-color-selected, currentColor));
1587
+ font-size: 24px;
1588
+ font-weight: 600;
1589
+ line-height: 1;
1590
+ }
1591
+
1543
1592
  .aia-media-RrbGe[data-aia-product-placeholder]::after {
1544
1593
  content: "";
1545
1594
  position: absolute;
@@ -1643,7 +1692,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1643
1692
  .aia-section-Hugfg[data-aia-products-layout="list"] .aia-body-ly032 {
1644
1693
  flex: 1 1 auto;
1645
1694
  }
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 {
1695
+ `,document.head.appendChild(e)}var _={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 Fe}from"react/jsx-runtime";function ft({products:e,listboxId:o,onSelect:a,onFocusChange:n,focusable:r=!0,layout:t="row",imageFallback:s="image"}){let l=e.length>0,v=ga(null);if(ma(()=>{let f=v.current;if(!(!l||!f))return ha(f)},[l]),!l)return null;let w=`${o}-products-label`;return Fe("section",{className:_.section,"data-aia-products":"","data-aia-products-layout":t,role:"group","aria-labelledby":w,children:[be("div",{className:_.label,id:w,"data-aia-products-label":"",children:"Products"}),be("div",{ref:v,className:_.row,"data-aia-products-row":"",children:e.map((f,h)=>be(ba,{product:f,id:`${o}-product-${h}`,onSelect:a,onFocusChange:n,focusable:r,imageFallback:s},f.id))})]})}function ba({product:e,id:o,onSelect:a,onFocusChange:n,focusable:r,imageFallback:t}){let s=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),a(e))};return Fe("a",{id:o,className:_.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:r?0:-1,onClick:s,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),a(e))},onFocus:()=>n?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[be(va,{src:e.imageUrl?.trim(),title:e.title,fallback:t},e.imageUrl?.trim()??""),Fe("span",{className:_.body,children:[e.vendor?be("span",{className:_.vendor,children:e.vendor}):null,be("span",{className:_.title,children:e.title}),e.price?be("span",{className:_.price,children:e.price}):null]})]})}function va({src:e,title:o,fallback:a}){let[n,r]=fa(!1),t=!!e&&!n,s=!t&&a==="initial";return Fe("span",{className:_.media,"aria-hidden":"true","data-aia-product-placeholder":!t&&!s?"":void 0,"data-aia-product-initial":s?"":void 0,children:[t?be("img",{className:_.image,src:e,alt:"",loading:"lazy",decoding:"async",onError:()=>r(!0)}):null,s?ua(o):null]})}import{isOptionsGridMobileViewport as Da,measureOptionsGrid as La,needsOptionsGridMeasurement as Ma,OPTIONS_GRID_MOBILE_QUERY as za,optionEnterDelayMs as Na,planOptionsGrid as wt,sameOptionRows as Ba}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ha,useLayoutEffect as Fa,useRef as xt,useState as kt}from"react";import{optionsGridTemplateColumns as wa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as xa,useRef as ya}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
1696
  display: grid;
1648
1697
  grid-template-columns: repeat(
1649
1698
  auto-fit,
@@ -1676,7 +1725,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1676
1725
  background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
1677
1726
  border-radius: 3px;
1678
1727
  }
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 {
1728
+ `,document.head.appendChild(e)}import{jsx as ka}from"react/jsx-runtime";function bt({min:e="16rem",max:o,gap:a,scroll:n=!1,maxHeight:r,scrollResetKey:t,cols:s,template:l,innerRef:v,className:w,children:f,...h}){let k=ya(null);xa(()=>{if(t===void 0)return;let y=k.current;y&&(y.scrollTop=0)},[t]);let S={"--aia-grid-min":e};return o&&(S["--aia-grid-max"]=o),a&&(S["--aia-grid-gap"]=a),r&&(S["--aia-grid-max-height"]=r),s&&(S.gridTemplateColumns=wa(s)),l&&(S.gridTemplateColumns=l),ka("div",{ref:y=>{k.current=y,v?.(y)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":n||void 0,style:S,...h,children:f})}import{formatOptionCount as Ca,OPTION_ENTER_DELAY_VAR as Pa,optionImageSrc as Sa,optionLabel as Ia,sanitizeOptionIconSvg as Ea}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ta,useMemo as Aa,useRef as Ra,useState as Ze}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
1729
  position: relative;
1681
1730
  /* Clip, not visible: the entrance rise below runs on the inner content,
1682
1731
  and a transformed box extends its scroll container's scrollable area.
@@ -1830,6 +1879,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1830
1879
  border-radius: 999px;
1831
1880
  -webkit-box-decoration-break: clone;
1832
1881
  box-decoration-break: clone;
1882
+ animation: aia-skeletonBarIn-ZlEM0 100ms ease-out;
1833
1883
  }
1834
1884
 
1835
1885
  .aia-item-d4vpD[data-aia-loading] .aia-tag-e3Fwe {
@@ -1902,6 +1952,15 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1902
1952
  min-width: 0;
1903
1953
  }
1904
1954
 
1955
+ /* A skeleton bar hugs its text. The rules above let the text grow to fill a
1956
+ picture / count row (so the count sits at the trailing edge); a loading row
1957
+ hides the count, and a growing text box would paint the bar across the
1958
+ whole column. One compound deeper than those rules, so it wins in every
1959
+ copy regardless of source order. */
1960
+ .aia-item-d4vpD[data-aia-loading] .aia-content-T-Qba .aia-text-yqoh9 {
1961
+ flex: 0 1 auto;
1962
+ }
1963
+
1905
1964
  /* The picture: a square tile, centred on the text beside it (a one-line
1906
1965
  option reads as the reference row; a wrapped one keeps the tile on its
1907
1966
  vertical middle). Sized and rounded by token so a consumer can shrink it
@@ -1919,7 +1978,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1919
1978
  height: var(--aia-option-image-size, 40px);
1920
1979
  border-radius: var(--aia-option-image-radius, 12px);
1921
1980
  overflow: hidden;
1922
- background: var(--aia-option-image-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.25)));
1981
+ background: var(--aia-option-image-bg, var(--aia-skeleton-bg, rgba(189, 189, 189, 0.083)));
1923
1982
  }
1924
1983
 
1925
1984
  .aia-image-YZAbO img {
@@ -1984,6 +2043,36 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1984
2043
  --aia-option-row-height: calc(var(--aia-option-image-size, 40px) + 16px);
1985
2044
  }
1986
2045
 
2046
+ /* A row without a picture, in a grid where other rows have one, lines up
2047
+ with them: it becomes the same centred flex row, its icon sits centred in a
2048
+ tile-sized box, and a row with no icon either is indented by the tile and
2049
+ its gap, so every option's text starts at the same x. Grids with no
2050
+ pictures keep the inline icon and hanging indent above. The text is left
2051
+ to size itself: letting it grow here would out-rank the loading-bar rule
2052
+ that makes a skeleton bar hug its text. */
2053
+ [data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)) {
2054
+ display: flex;
2055
+ flex: 1 1 auto;
2056
+ align-items: center;
2057
+ gap: var(--aia-option-image-gap, 12px);
2058
+ min-width: 0;
2059
+ min-height: var(--aia-option-image-size, 40px);
2060
+ padding-left: 0;
2061
+ text-indent: 0;
2062
+ }
2063
+
2064
+ [data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)) .aia-icon-Qw938 {
2065
+ flex: 0 0 auto;
2066
+ justify-content: center;
2067
+ width: var(--aia-option-image-size, 40px);
2068
+ height: var(--aia-option-image-size, 40px);
2069
+ margin-right: 0;
2070
+ }
2071
+
2072
+ [data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)):not(:has(.aia-icon-Qw938)) {
2073
+ padding-left: calc(var(--aia-option-image-size, 40px) + var(--aia-option-image-gap, 12px));
2074
+ }
2075
+
1987
2076
  @keyframes aia-skeletonPulse-plvdD {
1988
2077
  0%,
1989
2078
  100% {
@@ -1993,7 +2082,40 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
1993
2082
  filter: brightness(0.55);
1994
2083
  }
1995
2084
  }
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 {
2085
+ /* --- Loading skeleton fades ---
2086
+ Skeletons ease in and out over 100ms instead of popping. In: an option's
2087
+ text crossfades into its bar (the row element persists in React / Angular
2088
+ and is rebuilt in vanilla \u2014 a keyframe plays either way). Out: while the
2089
+ dropdown carries data-aia-skeleton-exiting (the core holds the skeleton for
2090
+ SKELETON_FADE_MS after the response lands) the skeleton rows and pills fade
2091
+ to nothing before the response's options replace them. Keep 100ms in step
2092
+ with SKELETON_FADE_MS in AIAutocomplete.ts. */
2093
+ /* During the fade-out the skeleton rows play nothing but the fade: no
2094
+ entrance, no text crossfade. Rows keep their identity through it (the core's
2095
+ dropdownSuggestion), but if one were ever remounted here, replaying either
2096
+ animation would bring the previous option's text back on screen. */
2097
+ [data-aia-skeleton-exiting] .aia-item-d4vpD[data-aia-loading] .aia-content-T-Qba,
2098
+ [data-aia-skeleton-exiting] .aia-item-d4vpD[data-aia-loading] .aia-text-yqoh9 {
2099
+ animation: none;
2100
+ }
2101
+
2102
+ [data-aia-skeleton-exiting] .aia-item-d4vpD[data-aia-loading] {
2103
+ animation: aia-skeletonOut-x6NRd 100ms ease-in forwards;
2104
+ }
2105
+
2106
+ @keyframes aia-skeletonBarIn-ZlEM0 {
2107
+ from {
2108
+ background-color: transparent;
2109
+ color: inherit;
2110
+ }
2111
+ }
2112
+
2113
+ @keyframes aia-skeletonOut-x6NRd {
2114
+ to {
2115
+ opacity: 0;
2116
+ }
2117
+ }
2118
+ `,document.head.appendChild(e)}var N={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 ye,jsxs as Oa}from"react/jsx-runtime";function vt({option:e,isHighlighted:o,onSelect:a,onHighlight:n,id:r,loading:t,showIcon:s=!0,showImage:l=!0,showCount:v=!0,scrollHint:w,enterDelayMs:f=0}){let[h]=Ze(f),[k,S]=Ze(!1),y=l?Sa(e.image_url):null,[z,L]=Ze(null),I=Aa(()=>!y&&s&&e.icon_svg?Ea(e.icon_svg):null,[y,s,e.icon_svg]),T=v?Ca(e.item_count):null,M=Ra(void 0);Ta(()=>()=>clearTimeout(M.current),[]);let O=()=>{t||!e.is_tappable||k||(S(!0),a(e),clearTimeout(M.current),M.current=setTimeout(()=>S(!1),170))},R=[N.item,o&&!t?N.highlighted:"",e.is_tappable?N.tappable:N.nonTappable,k?N.pressed:"",w?N.scrollHint:""].filter(Boolean).join(" ");return ye("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":t?"":void 0,"data-aia-icon":I&&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":o,className:R,style:{[Pa]:`${h}ms`},tabIndex:t||!e.is_tappable?-1:0,onClick:O,onKeyDown:C=>{!t&&e.is_tappable&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),O())},onMouseEnter:!t&&e.is_tappable?n:void 0,children:Oa("span",{className:N.content,children:[y&&ye("span",{className:`${N.image} magicx-aia-option-image`,"aria-hidden":"true",children:ye("img",{src:y,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:z===y,onError:()=>L(y)})}),I&&ye("span",{className:`${N.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:I}}),ye("span",{className:N.text,children:Ia(e)}),e.tag&&ye("span",{className:N.tag,children:e.tag}),T!==null&&ye("span",{className:`${N.count} magicx-aia-option-count`,children:T})]})})}import{jsx as yt}from"react/jsx-runtime";function Ka(){let[e,o]=kt(Da);return Ha(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(za),n=()=>o(a.matches);return n(),a.addEventListener("change",n),()=>a.removeEventListener("change",n)},[]),e}function Ct({options:e,activeIndex:o,onSelect:a,onHighlight:n,listboxId:r,loading:t,groupKey:s="",optionsPosition:l="below",showIcons:v=!0,showImages:w=!0,showCounts:f=!0}){let h=Ka(),k=xt(null),[S,y]=kt(null),z=xt(null);Fa(()=>{if(t&&Ba(z.current,e))return;z.current=t?null:e;let I=k.current,M=I&&!t&&Ma(e.length,h)?La(I):null;y(M?wt(e.length,h,M.rowWidths,M.gridWidth):null)},[e,h,t]);let L=S??wt(e.length,h,null,null);return yt(bt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:s,template:L.template,maxHeight:L.maxHeight,innerRef:I=>{k.current=I},"data-aia-group":s,children:e.map((I,T)=>yt(vt,{option:I,isHighlighted:T===o,onSelect:a,onHighlight:()=>n(T),id:`${r}-option-${T}`,loading:t,showIcon:v,showImage:w,showCount:f,scrollHint:!t&&L.scrollHintIndices.includes(T),enterDelayMs:t?0:Na(T,L.cols,e.length,l)},`${s}\0${I.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
2119
  display: flex;
1998
2120
  flex-direction: column;
1999
2121
  gap: var(--aia-stack-space, 0.5rem);
@@ -2008,7 +2130,7 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
2008
2130
  align-items: end;
2009
2131
  }
2010
2132
  /* 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 {
2133
+ `,document.head.appendChild(e)}import{jsx as Ga}from"react/jsx-runtime";function Pt({space:e,align:o="stretch",className:a,children:n,...r}){let t=e?{"--aia-stack-space":e}:void 0;return Ga("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":o,style:t,...r,children:n})}import{jsx as F,jsxs as $e}from"react/jsx-runtime";var Qa=[159,119,164],Ya=()=>{},St=()=>{};function ja(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,n]=Ua(o);if(Ve(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),t=()=>n(r.matches);return r.addEventListener("change",t),()=>r.removeEventListener("change",t)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function Za(e,o){let a=Ke(null);Ve(()=>{let n=e.current,r=o.current;if(!n||!r)return;let t=n.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:Wa({dropdown:n,grid:t,button:r})};return}a.current?.controller.update()}),Ve(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function Xe({suggestions:e,activeIndex:o,onSelect:a,onHighlight:n,isOpen:r,id:t,className:s,pills:l,onPillClick:v,showPills:w=!0,onSkip:f,showSkipButton:h=!0,showOptionIcons:k=!0,showOptionImages:S=!0,showOptionCounts:y=!0,skipDisabled:z=!1,activeSelected:L=!1,isLoading:I=!1,skeletonExiting:T=!1,isInputEmpty:M=!1,products:O,onProductSelect:R,onProductFocusChange:C,productsLayout:U="row",productImageFallback:de="image",formatType:V="options",dateView:ce=null,selectedDateIso:X=null,selectedDateRange:p=null,dateRangeStart:ve=null,onPreviousMonth:pe,onNextMonth:he,optionsPosition:J="below",mode:ue}){let ee=ja(ue),Q=ee!==void 0,te=Ke(null),Y=Ke(null);Za(te,Y);let ae=e[0]?.options??[],ie=!!(l&&l.length>0&&v),d=!!(O&&O.length>0),u=r&&(ae.length>0||w&&ie||I||d),b={suggestions:e,activeIndex:o,pills:l,showPills:w,showSkipButton:h,showOptionIcons:k,showOptionImages:S,showOptionCounts:y,skipDisabled:z,activeSelected:L,isLoading:I,skeletonExiting:T,isInputEmpty:M,products:O,formatType:V,dateView:ce,selectedDateIso:X,selectedDateRange:p,dateRangeStart:ve},x=Ke(b);u&&(x.current=b);let i=u?b:x.current,P=i.suggestions[0],m=P?.options??[],j=i.activeIndex>=0&&!!m[i.activeIndex]?.is_tappable,G=!!(i.pills&&i.pills.length>0&&v),we=i.showPills&&G,c=i.showPills&&!G&&i.isLoading,oe=we||c,me=G&&i.showSkipButton&&!i.isInputEmpty&&!!f,ne=i.pills?.[0]?.text,ke=_a(i.formatType)&&i.dateView!=null,re=m.length>0&&!ke,Ce=m.length>0&&ke&&!i.isLoading,Z=i.isLoading&&!re&&!Ce,B=i.products??[];return $e("div",{ref:te,id:t,role:"listbox","data-aia-dropdown":"","data-options-position":J,"data-mode":ee,"data-aia-loading":i.isLoading?"":void 0,"data-aia-skeleton-exiting":i.skeletonExiting?"":void 0,"data-aia-has-products":B.length>0?"":void 0,className:`${Q?"magicx-aia ":""}${se.dropdown} ${u?se.visible:""} ${s??""}`,onMouseDown:W=>W.preventDefault(),children:[$e(Pt,{space:"8px",children:[(oe||me)&&$e(Ae,{noWrap:!0,className:se.pillBar,"data-aia-pillbar":"",children:[oe&&F("span",{className:se.pillScroll,"data-aia-pill-scroll":"",children:F(He,{pills:i.pills??[],activePillIndex:0,activeSelected:i.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:i.isLoading})}),me&&F("button",{type:"button",tabIndex:-1,className:se.skip,"data-aia-skip":"",disabled:i.isLoading||i.skipDisabled,"aria-label":ne?`Skip ${ne}`:"Skip",onClick:f,children:"skip"})]}),re&&F(Ct,{options:m,activeIndex:i.activeIndex,onSelect:a,onHighlight:n,listboxId:t,loading:i.isLoading,groupKey:P?`${P.type} ${P.text}`:"",optionsPosition:J,showIcons:i.showOptionIcons,showImages:i.showOptionImages,showCounts:i.showOptionCounts}),Ce&&i.dateView&&F(pt,{options:m,activeIndex:i.activeIndex,listboxId:t,view:i.dateView,selection:{selectedIso:i.selectedDateIso??null,selectedRange:i.selectedDateRange??null,rangeStart:i.dateRangeStart??null},onSelect:a,onHighlight:n,onPreviousMonth:pe??St,onNextMonth:he??St}),Z&&F("div",{className:se.skeletonBars,"data-aia-skeleton-bars":"",children:Qa.map(W=>F("span",{className:se.skeletonBar,style:{width:W}},`bar-${W}`))}),F(ft,{products:B,listboxId:t,onSelect:R??Ya,onFocusChange:C,focusable:u,layout:U,imageFallback:de}),F(ut,{isOptionHighlighted:j,isInputEmpty:i.isInputEmpty})]}),F("button",{ref:Y,type:"button",tabIndex:-1,className:se.scrollArrow,"data-aia-scroll-arrow":"","aria-label":qa,"aria-hidden":"true",children:F("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:F("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as si,ModeController as li,setCursorOffset as di}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
2134
  flex-shrink: 0;
2013
2135
  width: 32px;
2014
2136
  height: 32px;
@@ -2061,5 +2183,5 @@ import{buildSubmitResult as Zo,cellDay as Xo,cellIso as Jo,DATE_RANGE_META_END a
2061
2183
  );
2062
2184
  cursor: default;
2063
2185
  }
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};
2186
+ `,document.head.appendChild(e)}var It={submitButton:"aia-submitButton-otz7H"};import{jsx as Je}from"react/jsx-runtime";function Et({disabled:e,onClick:o}){return Je("button",{type:"button","data-aia-submit":"",className:It.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),o()},"aria-label":"Submit",children:Je("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Je("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as $a,dateSelectionFor as Va,identifiedParamLabel as Xa}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Dt,useEffect as Oe,useRef as K,useState as Ja}from"react";import{useRef as Tt}from"react";function At(e){let o=Tt(e);o.current=e;let a=Object.keys(e??{}).sort().join("\0"),n=Tt({key:"",overrides:void 0});if(n.current.key!==a){let r={};for(let t of Object.keys(e??{})){let s=(l,v,w)=>{let f=o.current?.[t];return f?f(l,v,w):[]};r[t]=s}n.current={key:a,overrides:e?r:void 0}}return{overrides:n.current.overrides,key:a}}import{useRef as Rt}from"react";function Ot(e){let o=Rt(e);o.current=e;let a=Rt(null);a.current===null&&(a.current={fetch:(r,t)=>{let s=o.current;return s?s.fetch(r,t):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?a.current:void 0,enabled:n}}var ei={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 et({onSubmit:e,onResult:o,onError:a,optionOverrides:n,maskCompletedText:r,apiConfig:t,additionalContext:s,columns:l=2,dropdownTrigger:v,optionsPosition:w,closeDropdownOnBlur:f,showNonTappableOptions:h,showOptionIcons:k,showOptionImages:S,showOptionCounts:y,showSkipButton:z,showProducts:L,productImageFallback:I="image",onFocus:T,onBlur:M,value:O,completedParams:R,onChange:C,onParamsChange:U,products:de,onProductSelect:V,source:ce,setCursor:X}){let p=K(null),[ve,pe]=Ja(null),he=K(e);he.current=e;let J=K(o);J.current=o;let ue=K(a);ue.current=a;let ee=K(C);ee.current=C;let Q=K(U);Q.current=U;let te=K(T);te.current=T;let Y=K(M);Y.current=M;let ae=K(X);ae.current=X;let ie=K(V);ie.current=V;let d=Ot(de),u=At(n);Oe(()=>{if(typeof document>"u")return;let g=new $a(document.createElement("div"),{renderMode:"headless",apiConfig:t,additionalContext:s,optionOverrides:u.overrides,maskCompletedText:r,columns:l,dropdownTrigger:v,optionsPosition:w,closeDropdownOnBlur:f,showNonTappableOptions:h,showProducts:L,source:ce,value:O,completedParams:R,onSubmit:(...D)=>he.current?.(...D),onResult:(...D)=>J.current?.(...D),onError:(...D)=>ue.current?.(...D),onChange:(...D)=>ee.current?.(...D),onParamsChange:(...D)=>Q.current?.(...D),onFocus:()=>te.current?.(),onBlur:()=>Y.current?.(),onProductSelect:D=>ie.current?.(D),setCursor:D=>ae.current?.(D),products:d.config});p.current=g,pe(g.getState());let H=g.subscribe(D=>pe(D));return()=>{H(),g.destroy(),p.current===g&&(p.current=null)}},[]),Oe(()=>{O!==void 0&&p.current?.setValue(O)},[O]),Oe(()=>{R!==void 0&&p.current?.setCompletedParams(R)},[R]);let b=JSON.stringify(t??null),x;try{x=JSON.stringify(s??null)}catch{x="[unstringifiable]"}Oe(()=>{p.current?.update({apiConfig:t,additionalContext:s,optionOverrides:u.overrides,dropdownTrigger:v,optionsPosition:w,closeDropdownOnBlur:f,showNonTappableOptions:h,showProducts:L})},[b,x,u.key,v,w,f,h,L]);let i=K(!1);Oe(()=>{if(!i.current){i.current=!0;return}p.current?.update({products:d.config})},[d.enabled]);let P=K(null);P.current===null&&(P.current={handleTextChange:g=>p.current?.handleTextChange(g),handleKeyDown:g=>{let H="nativeEvent"in g?g.nativeEvent:g;p.current?.handleKeyDown(H)},setFocused:g=>p.current?.setFocused(g),startEditingParam:g=>p.current?.startEditingParam(g),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:g=>p.current?.handleCaretAfterInput(g),handleCaretMove:g=>p.current?.handleCaretMove(g),replaceEditingRange:g=>p.current?.replaceEditingRange(g)??!1,setActivePill:g=>p.current?.setActivePill(g),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:g=>p.current?.selectOption(g),selectProduct:g=>p.current?.selectProduct(g),setActiveDropdownIndex:g=>p.current?.setActiveDropdownIndex(g),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let m=P.current,j=Dt(g=>{let H=g.target.value,_e=H.length>0&&!g.nativeEvent?.isComposing&&H[0]!==H[0].toUpperCase()?H[0].toUpperCase()+H.slice(1):H;p.current?.handleTextChange(_e)},[]),G=Dt(g=>{p.current?.handleKeyDown(g.nativeEvent)},[]),we=p.current,c=ve??ei,oe=O!==void 0?O:c.text,me=R!==void 0?R:c.completedParams,ne=c.actionableSuggestions,ke=ne[0],re=we?.listboxId??"",Ce=c.activeDropdownIndex>=0&&we?`${re}-option-${c.activeDropdownIndex}`:void 0,Z=c.editingParam,B=c.editingIdentified,W=Z?{type:Z.suggestionType,text:Z.suggestionPlaceholder,required:!0,options:Z.options}:B?{type:B.type,text:Xa(B.type),required:!0,options:[]}:null,Ee=c.dropdownSuggestion??W??ke,We=W?[W]:ne,Te=Va(c),Le=!we||c.dropdownLoading;return{completedParams:me,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:ne,setActivePill:m.setActivePill,skipActivePill:m.skipActivePill,removeLastParam:m.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:m.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:Le,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:re,error:c.error,products:c.products,customFields:c.customFields,selectProduct:m.selectProduct,handleTextChange:m.handleTextChange,handleKeyDown:m.handleKeyDown,setFocused:m.setFocused,editingParam:Z,editingIdentified:B,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:m.startEditingParam,exitEditMode:m.exitEditMode,handleCaretAfterInput:m.handleCaretAfterInput,handleCaretMove:m.handleCaretMove,replaceEditingRange:m.replaceEditingRange,inputProps:{value:oe,placeholder:c.placeholderText||void 0,onChange:j,onKeyDown:G,onFocus:m.handleFocus,onBlur:m.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":Ce,"aria-autocomplete":"list","aria-controls":re},reset:m.reset,dropdownProps:{suggestions:Ee?[{...Ee,options:c.dropdownOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:m.selectOption,onHighlight:m.setActiveDropdownIndex,isOpen:c.isDropdownOpen,id:re,pills:We,activeSelected:c.isActivePillSelected,onPillClick:m.setActivePill,onSkip:m.skipActivePill,showSkipButton:(z??!0)&&!Z&&!B,showOptionIcons:k??!0,showOptionImages:S??!0,showOptionCounts:y??!0,skipDisabled:c.inSelectionAnimation,isLoading:Le,skeletonExiting:c.skeletonExiting,isInputEmpty:oe.trim().length===0,products:c.products,productImageFallback:I,onProductSelect:m.selectProduct,onProductFocusChange:m.setFocused,formatType:c.activeFormatType,dateView:c.dateView,selectedDateIso:Te.selectedIso,selectedDateRange:Te.selectedRange,dateRangeStart:Te.rangeStart,onPreviousMonth:m.showPreviousMonth,onNextMonth:m.showNextMonth,optionsPosition:w??"below"}}}import{extractPlainText as Lt,getCursorOffset as Mt,plainTextLength as ti,renderEditableContent as ai,setCursorOffset as zt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as q,useEffect as tt,useLayoutEffect as at,useRef as Se}from"react";var Ge;function ii(){if(Ge!==void 0)return Ge;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ge=e.contentEditable==="plaintext-only",Ge}function Nt(e){let{segments:o,showChipIcons:a=!0,showChipImages:n=!0,newParamId:r,editingParam:t,editingIdentified:s,editingAnchor:l,caretOffset:v,placeholderText:w,isFocused:f,isDropdownOpen:h,listboxId:k,activeDescendantId:S,autoFocus:y,handleTextChange:z,handleKeyDown:L,handleCaretAfterInput:I,handleCaretMove:T,startEditingParam:M,replaceEditingRange:O,setFocused:R}=e,C=Se(null),U=Se(!1),de=Se(""),V=Se(""),ce=Se(null),X=Se(0);ce.current=v,tt(()=>{if(!y)return;let d=C.current;if(!d)return;document.activeElement===d?R(!0):d.focus();let u=d.ownerDocument??document,b=u.getSelection(),x=b&&b.rangeCount>0&&d.contains(b.anchorNode);if(b&&!x){let i=u.createRange();i.selectNodeContents(d),i.collapse(!0),b.removeAllRanges(),b.addRange(i)}},[y,R]),tt(()=>{let d=C.current;if(!d)return;let u=d.ownerDocument??document,b=()=>{let x=u.getSelection();if(!x||x.rangeCount===0||!x.anchorNode||!d.contains(x.anchorNode))return;let i=x.anchorNode,P=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement,j=(x.isCollapsed?P?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,G=t?.id??s?.id??null;if(j&&j!==G){M(j);return}performance.now()-X.current<50||T(Mt(d))};return u.addEventListener("selectionchange",b),()=>u.removeEventListener("selectionchange",b)},[t,s,M,T]),at(()=>{let d=C.current;d&&ai({input:d,segments:o,newParamId:r,editingParamId:t?.id??null,placeholderText:w??"",isFocused:f,showChipIcons:a,showChipImages:n})},[o,r,t,w,f,a,n]),at(()=>{let d=de.current,u=r??"";if(de.current=u,!u||u===d)return;let b=C.current;if(!b)return;b.focus();let x=ce.current??ti(b);zt(b,x)},[r]),at(()=>{let d=V.current,u=t?.id??"";if(V.current=u,!u||u===d||l==null)return;let b=C.current;b&&zt(b,l)},[t,l]);let p=q(()=>{if(U.current)return;let d=C.current;if(!d)return;let u=Lt(d),x=u.length>0&&u[0]!==u[0].toUpperCase()?u[0].toUpperCase()+u.slice(1):u;z(x)},[z]),ve=q(()=>{X.current=performance.now(),p();let d=C.current;d&&I(Mt(d))},[p,I]);tt(()=>{let d=C.current;if(!d)return;let u=b=>{let x=b,i=x.inputType;if(i==="insertParagraph"||i==="insertLineBreak"||i==="insertFromDrop"){b.preventDefault();return}if(i.startsWith("insert")||i.startsWith("delete")){let P=i.startsWith("delete")?"":x.data??"";O(P)&&b.preventDefault()}};return d.addEventListener("beforeinput",u),()=>d.removeEventListener("beforeinput",u)},[O]);let pe=q(()=>{U.current=!0},[]),he=q(()=>{U.current=!1,p()},[p]),J=q(d=>{d.preventDefault();let u=C.current;if(!u)return;let b=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let x=u.ownerDocument??document,i=x.getSelection();if(!i||i.rangeCount===0)return;let P=i.getRangeAt(0);if(!u.contains(P.startContainer))return;P.deleteContents();let m=x.createTextNode(b);P.insertNode(m),P.setStartAfter(m),P.collapse(!0),i.removeAllRanges(),i.addRange(P),p()},[p]),ue=q(d=>L(d),[L]),ee=q(()=>R(!0),[R]),Q=q(()=>R(!1),[R]),te=q(()=>C.current?.focus(),[]),Y=q(()=>C.current?.blur(),[]),ae=q(()=>{let d=C.current;return d?Lt(d):""},[]),ie=ii()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:ie,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":k,"aria-expanded":h,"aria-activedescendant":S,spellCheck:!0,enterKeyHint:"send",onInput:ve,onKeyDown:ue,onCompositionStart:pe,onCompositionEnd:he,onPaste:J,onFocus:ee,onBlur:Q},getPlainText:ae,focus:te,blur:Y}}import{jsx as Ie,jsxs as ot}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=oi(function({onSubmit:o,onResult:a,onError:n,optionOverrides:r,maskCompletedText:t,className:s,apiConfig:l,additionalContext:v,columns:w,pillPlacement:f="dropdown",mode:h="auto",optionsPosition:k="below",animations:S=!0,dropdownTrigger:y,closeDropdownOnBlur:z,showNonTappableOptions:L,showOptionIcons:I=!0,showChipIcons:T=!0,showChipImages:M=!0,showOptionImages:O=!0,showOptionCounts:R=!0,showSkipButton:C,showProducts:U,productsLayout:de,productImageFallback:V,autoFocus:ce=!0,onFocus:X,onBlur:p,value:ve,completedParams:pe,onChange:he,onParamsChange:J,products:ue,onProductSelect:ee,submitButton:Q},te){let Y=De(null),ae=De(null),ie=De(()=>{}),d=De(null),u=De(null);Bt(()=>{let E=Y.current;if(E)return d.current?d.current.setMode(h):d.current=new li(E,h),()=>{d.current?.destroy(),d.current=null}},[h]);let b=it(E=>{let ge=u.current?.current;ge&&(ge.focus(),di(ge,E))},[]),{completedParams:x,skippedParams:i,identifiedParams:P,isReady:m,customFields:j,suggestionPills:G,setActivePill:we,skipActivePill:c,segments:oe,newParamId:me,clearNewParamId:ne,placeholderText:ke,isFocused:re,isDropdownOpen:Ce,isActivePillSelected:Z,isLoading:B,activeIndex:W,listboxId:Ee,handleTextChange:We,handleKeyDown:Te,setFocused:Le,editingParam:g,editingIdentified:H,editingAnchor:D,caretOffset:_e,startEditingParam:Ht,handleCaretAfterInput:Ft,handleCaretMove:Kt,replaceEditingRange:Gt,dropdownProps:Wt,reset:Me}=et({onSubmit:E=>ie.current(E),onResult:a,onError:n,optionOverrides:r,maskCompletedText:t,apiConfig:l,additionalContext:v,columns:w,dropdownTrigger:y,optionsPosition:k,closeDropdownOnBlur:z,showNonTappableOptions:L,showOptionIcons:I,showOptionImages:O,showOptionCounts:R,showSkipButton:C,showProducts:U,onFocus:X,onBlur:p,value:ve,completedParams:pe,onChange:he,onParamsChange:J,products:ue,onProductSelect:ee,source:"full-sdk",setCursor:b});Bt(()=>{if(!me)return;let E=window.setTimeout(()=>ne(),650);return()=>window.clearTimeout(E)},[me,ne]);let _t=W>=0?`${Ee}-option-${W}`:void 0,{inputRef:qe,editorProps:qt,focus:ze,blur:nt,getPlainText:rt}=Nt({segments:oe,newParamId:me,editingParam:g,editingIdentified:H,editingAnchor:D,caretOffset:_e,placeholderText:ke,isFocused:re,showChipIcons:T,showChipImages:M,isDropdownOpen:Ce,listboxId:Ee,activeDescendantId:_t,autoFocus:ce,handleTextChange:We,handleKeyDown:Te,handleCaretAfterInput:Ft,handleCaretMove:Kt,startEditingParam:Ht,replaceEditingRange:Gt,setFocused:Le});u.current=qe,ri(()=>{let E=ae.current,ge=qe.current;if(!E||!ge)return;let st=()=>{let dt=E.firstElementChild;if(!dt)return;let jt=dt.getBoundingClientRect(),Zt=ge.getBoundingClientRect();jt.top>=Zt.bottom-2?E.setAttribute("data-aia-pill-wrapped",""):E.removeAttribute("data-aia-pill-wrapped")};st();let lt=new ResizeObserver(st);return lt.observe(ge),()=>lt.disconnect()},[oe,G.length,B,qe]),ni(te,()=>({focus:ze,blur:nt,reset:Me,setMode:E=>d.current?.setMode(E),skipActivePill:c}),[ze,nt,Me,c]);let Ne=!!oe.length||x.length>0,Ue=it(()=>{if(!Ne)return;let E=rt();o(si(E,x,i,{identifiedParams:P,isReady:m,customFields:j})),Me()},[Ne,x,i,P,m,j,o,Me,rt]);ie.current=Ue;let Ut=it(E=>{E.target?.closest("[data-aia-pill]")||ze()},[ze]),Qt=f==="inline",Yt=f==="dropdown";return ot("div",{ref:Y,className:`magicx-aia ${xe.container} ${s??""}`,"data-pill-placement":f,"data-options-position":k,"data-animations":S?"on":"off","data-mode":ci(h),children:[Ie(Xe,{...Wt,showPills:Yt,productsLayout:de,productImageFallback:V}),ot("div",{className:xe.inputWrapper,"data-aia-input-wrapper":"",onClick:Ut,children:[ot("div",{className:xe.editorArea,"data-aia-editor":"",children:[Ie("div",{...qt,className:xe.input,"data-aia-input":""}),Qt&&(B||G.length>0)&&Ie("span",{ref:ae,className:xe.pillListContainer,"data-aia-pill-list-container":"",children:Ie(He,{pills:G,activePillIndex:0,activeSelected:Z,onSelectPill:we,loading:B})})]}),Q===null?null:Q===void 0?Ie(Et,{disabled:!Ne,onClick:Ue}):Ie("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:xe.submitSlot,onClick:E=>{Ne&&(E.stopPropagation(),Ue())},children:Q})]})]})});export{pi as AIAutocomplete,Xe as AIAutocompleteDropdown,rn as DATE_RANGE_META_END,sn as DATE_RANGE_META_START,ln as DEFAULT_OPTION_COUNT_UNIT,wn as PRODUCT_PATH_PREFIX,Tn as WEEKDAY_LABELS,an as buildSubmitResult,on as cellDay,nn as cellIso,dn as dateCellMarks,cn as formatDate,pn as formatDateRange,hn as formatOptionCount,un as isoDate,mn as monthLabel,gn as optionCountLabel,fn as optionHasImage,bn as optionImageSrc,vn as optionLabel,xn as parseDate,yn as parseLooseDate,kn as parseLooseDateRange,Cn as productFromMatchedItem,Pn as productsFromCustomFields,Sn as sanitizeOptionIconSvg,In as selectedRangeFor,et as useAIAutocomplete,En as visibleDateRange,An as withSkippedParams};
2065
2187
  //# sourceMappingURL=index.mjs.map