@magicx-eng/ai-autocomplete-react 0.7.0 → 0.8.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 co,withSkippedParams as uo}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Ot,useCallback as Te,useEffect as at,useImperativeHandle as Ht,useLayoutEffect as Nt,useRef as pe}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.AIAutocomplete-module_container_KKjFU {
1
+ import{buildSubmitResult as Eo,withSkippedParams as Ro}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as qt,useCallback as He,useEffect as ut,useImperativeHandle as Qt,useLayoutEffect as Xt,useRef as fe}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.AIAutocomplete-module_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
@@ -57,7 +57,7 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
57
57
  display: inline-block;
58
58
  padding: 4px 6px;
59
59
  border-radius: 999px;
60
- background: var(--aia-completed-pill-bg, rgba(189, 189, 189, 0.15));
60
+ background: var(--aia-completed-pill-bg, rgba(189, 189, 189, 0.105));
61
61
  color: var(--aia-completed-pill-color, var(--aia-written-text-color, #fff));
62
62
  font-size: var(--aia-pill-font-size, 14px);
63
63
  font-weight: 400;
@@ -158,7 +158,7 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
158
158
  opacity: 0;
159
159
  }
160
160
  }
161
- `,document.head.appendChild(e)}var ee={container:"AIAutocomplete-module_container_KKjFU",inputWrapper:"AIAutocomplete-module_inputWrapper_FLq1b",editorArea:"AIAutocomplete-module_editorArea_7rBWq",input:"AIAutocomplete-module_input_IW-P-",pillListContainer:"AIAutocomplete-module_pillListContainer_h92IA",submitSlot:"AIAutocomplete-module_submitSlot_GhuCM",aiaPillReveal:"AIAutocomplete-module_aiaPillReveal_wf05b"};import{useEffect as St,useRef as At,useState as Ct}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
161
+ `,document.head.appendChild(e)}var ne={container:"AIAutocomplete-module_container_KKjFU",inputWrapper:"AIAutocomplete-module_inputWrapper_FLq1b",editorArea:"AIAutocomplete-module_editorArea_7rBWq",input:"AIAutocomplete-module_input_IW-P-",pillListContainer:"AIAutocomplete-module_pillListContainer_h92IA",submitSlot:"AIAutocomplete-module_submitSlot_GhuCM",aiaPillReveal:"AIAutocomplete-module_aiaPillReveal_wf05b"};import{useEffect as Ft,useRef as Bt,useState as Nt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
162
162
  * Built-in appearance defaults \u2014 zero specificity via :where().
163
163
  * Consumer CSS always wins without !important.
164
164
  *
@@ -202,7 +202,15 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
202
202
  --aia-primitive-neutral-750-a35: rgba(189, 189, 189, 0.35);
203
203
  --aia-primitive-neutral-750-a30: rgba(189, 189, 189, 0.3);
204
204
  --aia-primitive-neutral-750-a15: rgba(189, 189, 189, 0.15);
205
+ /* a105 is a15 lightened 30% (0.15 -> 0.105) \u2014 a fainter tint of the same
206
+ gray, not a new color. Light mode only: over a WHITE surface a weaker
207
+ tint is lighter, but over the dark theme's black surface it would be
208
+ darker, so dark mode keeps a15. */
209
+ --aia-primitive-neutral-750-a105: rgba(189, 189, 189, 0.105);
205
210
  --aia-primitive-neutral-700-a40: rgba(176, 176, 176, 0.4);
211
+ /* Exactly 0.5, unlike the older 750-a50 above (0.51). */
212
+ --aia-primitive-neutral-900-a50: rgba(231, 231, 231, 0.5);
213
+ --aia-primitive-neutral-400-a50: rgba(74, 74, 74, 0.5);
206
214
  }
207
215
 
208
216
  /* Light mode defaults (base) \u2014 public --aia-* vars resolve to primitives */
@@ -214,10 +222,11 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
214
222
  --aia-shadow:
215
223
  inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(16, 24, 40, 0.1),
216
224
  0 8px 24px rgba(16, 24, 40, 0.16);
217
- --aia-dropdown-border: var(
218
- --aia-primitive-neutral-900
219
- ); /* was #e5e7eb \u2014 snapped to palette (\u03942) */
220
- --aia-dropdown-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
225
+ /* Half-strength stroke: neutral-900 (was #e5e7eb \u2014 snapped to palette,
226
+ \u03942) at 50% alpha over the surface, so the hairline lands exactly
227
+ halfway between its old value and the white behind it. */
228
+ --aia-dropdown-border: var(--aia-primitive-neutral-900-a50);
229
+ --aia-dropdown-shadow: 0 8px 12px rgba(0, 0, 0, 0.05);
221
230
  /* Suggestion pills (Figma "ParamPill"): transparent fill + dashed border;
222
231
  per-pill opacity via getPillOpacity. */
223
232
  --aia-pill-bg: var(--aia-primitive-neutral-750);
@@ -229,7 +238,7 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
229
238
  primary-color regular-weight text. -active is the hover / tapped (re-edit)
230
239
  highlight \u2014 an alpha over the input background, so one value works in both
231
240
  themes. */
232
- --aia-completed-pill-bg: var(--aia-primitive-neutral-750-a15);
241
+ --aia-completed-pill-bg: var(--aia-primitive-neutral-750-a105);
233
242
  --aia-completed-pill-bg-active: var(--aia-primitive-neutral-750-a35);
234
243
  --aia-completed-pill-color: var(--aia-primitive-neutral-0);
235
244
 
@@ -268,10 +277,10 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
268
277
  --aia-shadow:
269
278
  inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.4),
270
279
  0 8px 24px rgba(0, 0, 0, 0.5);
271
- --aia-dropdown-border: var(
272
- --aia-primitive-neutral-400
273
- ); /* was #484848 \u2014 snapped to palette (\u03942) */
274
- --aia-dropdown-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
280
+ /* Half-strength stroke \u2014 neutral-400 (was #484848 \u2014 snapped to palette,
281
+ \u03942) at 50% alpha; see the light-mode note above. */
282
+ --aia-dropdown-border: var(--aia-primitive-neutral-400-a50);
283
+ --aia-dropdown-shadow: 0 8px 12px rgba(0, 0, 0, 0.05);
275
284
  /* Suggestion pills (Figma "ParamPill"): transparent fill + dashed border. */
276
285
  --aia-pill-bg: var(--aia-primitive-neutral-750);
277
286
  --aia-pill-color: var(--aia-primitive-neutral-700);
@@ -279,7 +288,11 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
279
288
  --aia-pill-font-size: 14px;
280
289
 
281
290
  /* Completed params (Figma "RichTextPill") \u2014 dark theme (design source):
282
- white text on a faint-gray chip. -active is the hover / tapped highlight. */
291
+ white text on a faint-gray chip. -active is the hover / tapped highlight.
292
+ Deliberately still a15 while light mode moved to a105: the fill is a light
293
+ gray tinting the surface, so thinning it lightens over white but DARKENS
294
+ over this theme's black. Lightening the dark chip means a stronger tint,
295
+ which is a design call, not a mechanical one \u2014 left for design to make. */
283
296
  --aia-completed-pill-bg: var(--aia-primitive-neutral-750-a15);
284
297
  --aia-completed-pill-bg-active: var(--aia-primitive-neutral-750-a35);
285
298
  --aia-completed-pill-color: var(--aia-primitive-neutral-1000);
@@ -400,6 +413,27 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
400
413
  margin-bottom: var(--aia-dropdown-offset, 13px);
401
414
  }
402
415
 
416
+ /* Declared after the optionsPosition="above" block on purpose: that rule's
417
+ second selector ([data-aia-dropdown][data-options-position="above"]) has the
418
+ same two-attribute specificity as this one, so source order is what decides
419
+ which wins when a strip is present in an above-positioned dropdown. */
420
+ /* Product strip present: the footer no longer sits on the scrolling option
421
+ list \u2014 the strip is between them \u2014 so there is nothing to ride up over and
422
+ nothing to reserve. Zeroing the band HERE, where it is defined, is the fix:
423
+ the pull is a property of "footer directly over the list", not of the grid,
424
+ and any section rendered after the grid would otherwise inherit it and land
425
+ on top of the last option row. Both edges are zeroed because
426
+ optionsPosition="above" flips which one is in play. */
427
+ [data-aia-dropdown][data-aia-has-products] {
428
+ --aia-grid-scroll-bottom: 0px;
429
+ --aia-grid-overlap-bottom: 0px;
430
+ --aia-grid-scroll-top: 0px;
431
+ --aia-grid-overlap-top: 0px;
432
+ /* The fade exists to dissolve rows sliding under the footer. With the strip
433
+ in between it has nothing to dissolve and would just wash over the cards. */
434
+ --aia-footer-fade-lead: 0px;
435
+ }
436
+
403
437
  :where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown] .aia-stack,
404
438
  [data-aia-dropdown][data-options-position="above"] .aia-stack {
405
439
  flex-direction: column-reverse;
@@ -446,9 +480,9 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
446
480
  /* Solid surface is the default (matches the Figma components). Opt into the
447
481
  frosted-glass look with data-aia-surface="glass". */
448
482
  background: var(--aia-surface, #ffffff);
449
- border: 1px solid var(--aia-dropdown-border, #e5e7eb);
483
+ border: 1px solid var(--aia-dropdown-border, rgba(231, 231, 231, 0.5));
450
484
  border-radius: 18px;
451
- box-shadow: var(--aia-dropdown-shadow, 0 8px 12px rgba(0, 0, 0, 0.1));
485
+ box-shadow: var(--aia-dropdown-shadow, 0 8px 12px rgba(0, 0, 0, 0.05));
452
486
  }
453
487
 
454
488
  .AIAutocompleteDropdown-module_dropdown_yz2KC[data-aia-surface="glass"] {
@@ -521,7 +555,7 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
521
555
  opacity: 0.25;
522
556
  }
523
557
  }
524
- `,document.head.appendChild(e)}var oe={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",pillBar:"AIAutocompleteDropdown-module_pillBar_pwTXe",skeletonBars:"AIAutocompleteDropdown-module_skeletonBars_HVr9C",skeletonBar:"AIAutocompleteDropdown-module_skeletonBar_O3xIx",aiaSkeletonPulse:"AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q"};import{ATTRIBUTION_URL as ut,buildAttributionUrl as mt,getFooterHint as gt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ht,useState as ft}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`@layer layout {
558
+ `,document.head.appendChild(e)}var de={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",pillBar:"AIAutocompleteDropdown-module_pillBar_pwTXe",skeletonBars:"AIAutocompleteDropdown-module_skeletonBars_HVr9C",skeletonBar:"AIAutocompleteDropdown-module_skeletonBar_O3xIx",aiaSkeletonPulse:"AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q"};import{ATTRIBUTION_URL as wt,buildAttributionUrl as yt,getFooterHint as kt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as _t,useState as Pt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`@layer layout {
525
559
  .aia-cluster {
526
560
  display: flex;
527
561
  flex-wrap: wrap;
@@ -563,7 +597,7 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
563
597
  justify-content: space-around;
564
598
  }
565
599
  }
566
- `,document.head.appendChild(e)}import{jsx as He}from"react/jsx-runtime";function le({gap:e,align:d="center",justify:o="start",noWrap:s=!1,inline:r=!1,className:i,children:u,...m}){let h=e?{"--aia-cluster-gap":e}:void 0,v={className:i?`aia-cluster ${i}`:"aia-cluster","data-align":d,"data-justify":o,"data-nowrap":s||void 0,"data-inline":r||void 0,style:h,...m};return r?He("span",{...v,children:u}):He("div",{...v,children:u})}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
600
+ `,document.head.appendChild(e)}import{jsx as $e}from"react/jsx-runtime";function me({gap:e,align:n="center",justify:i="start",noWrap:l=!1,inline:s=!1,className:r,children:o,...u}){let g=e?{"--aia-cluster-gap":e}:void 0,b={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":n,"data-justify":i,"data-nowrap":l||void 0,"data-inline":s||void 0,style:g,...u};return s?$e("span",{...b,children:o}):$e("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
567
601
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
568
602
  room above the hint/branding row so the footer doesn't butt against the last
569
603
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -682,7 +716,7 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
682
716
  justify-content: flex-end;
683
717
  }
684
718
  }
685
- `,document.head.appendChild(e)}var q={footer:"DropdownFooter-module_footer_qQQ7x",hintGroup:"DropdownFooter-module_hintGroup_ZzbPf",brandLink:"DropdownFooter-module_brandLink_r4f3R",key:"DropdownFooter-module_key_Bz1H-",hint:"DropdownFooter-module_hint_GKEOH",brand:"DropdownFooter-module_brand_Al-lR",badge:"DropdownFooter-module_badge_Fk9vg",row:"DropdownFooter-module_row_BgZ6Q"};import{jsx as de,jsxs as Ie}from"react/jsx-runtime";function Ne({isOptionHighlighted:e=!1,isInputEmpty:d=!1}){let{key:o,hint:s}=gt(e,d),[r,i]=ft(ut);return ht(()=>{i(mt())},[]),de("footer",{className:q.footer,"data-aia-footer":"",children:Ie(le,{justify:"between",noWrap:!0,className:q.row,children:[Ie(le,{gap:"5px",className:q.hintGroup,children:[de("kbd",{className:q.key,children:o}),de("span",{className:q.hint,children:s})]}),Ie("a",{className:q.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[de("span",{className:q.brand,children:"AI"}),de("span",{className:q.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
719
+ `,document.head.appendChild(e)}var X={footer:"DropdownFooter-module_footer_qQQ7x",hintGroup:"DropdownFooter-module_hintGroup_ZzbPf",brandLink:"DropdownFooter-module_brandLink_r4f3R",key:"DropdownFooter-module_key_Bz1H-",hint:"DropdownFooter-module_hint_GKEOH",brand:"DropdownFooter-module_brand_Al-lR",badge:"DropdownFooter-module_badge_Fk9vg",row:"DropdownFooter-module_row_BgZ6Q"};import{jsx as ge,jsxs as Re}from"react/jsx-runtime";function je({isOptionHighlighted:e=!1,isInputEmpty:n=!1}){let{key:i,hint:l}=kt(e,n),[s,r]=Pt(wt);return _t(()=>{r(yt())},[]),ge("footer",{className:X.footer,"data-aia-footer":"",children:Re(me,{justify:"between",noWrap:!0,className:X.row,children:[Re(me,{gap:"5px",className:X.hintGroup,children:[ge("kbd",{className:X.key,children:i}),ge("span",{className:X.hint,children:l})]}),Re("a",{className:X.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[ge("span",{className:X.brand,children:"AI"}),ge("span",{className:X.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
686
720
  with a dashed border. ~28px via 6px padding + 14px text + the 1px border
687
721
  (border-box). */
688
722
  .ParamPill-module_pill_6Ga7S {
@@ -734,7 +768,7 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
734
768
  opacity: 0;
735
769
  }
736
770
  }
737
- `,document.head.appendChild(e)}var J={pill:"ParamPill-module_pill_6Ga7S",fadeIn:"ParamPill-module_fadeIn_Ux4eQ",rounded:"ParamPill-module_rounded_y7xA9",skeleton:"ParamPill-module_skeleton_57P0T",skeletonPulse:"ParamPill-module_skeletonPulse_xGcUy"};import{jsx as bt}from"react/jsx-runtime";var Pe={selected:1,first:.7,next:.4,last:.2};function Ke({label:e,state:d,rounded:o,loading:s,onClick:r}){let i=[J.pill,o?J.rounded:"",s?J.skeleton:""].filter(Boolean).join(" ");return bt("button",{type:"button","data-aia-pill":"","data-aia-loading":s?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:i,style:{opacity:Pe[d]},onMouseDown:u=>u.preventDefault(),onClick:s?void 0:r,disabled:s,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.PillList-module_list_qvLqO {
771
+ `,document.head.appendChild(e)}var ae={pill:"ParamPill-module_pill_6Ga7S",fadeIn:"ParamPill-module_fadeIn_Ux4eQ",rounded:"ParamPill-module_rounded_y7xA9",skeleton:"ParamPill-module_skeleton_57P0T",skeletonPulse:"ParamPill-module_skeletonPulse_xGcUy"};import{jsx as It}from"react/jsx-runtime";var De={selected:1,first:.7,next:.4,last:.2};function qe({label:e,state:n,rounded:i,loading:l,onClick:s}){let r=[ae.pill,i?ae.rounded:"",l?ae.skeleton:""].filter(Boolean).join(" ");return It("button",{type:"button","data-aia-pill":"","data-aia-loading":l?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:De[n]},onMouseDown:o=>o.preventDefault(),onClick:l?void 0:s,disabled:l,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.PillList-module_list_qvLqO {
738
772
  position: relative;
739
773
  z-index: 1;
740
774
  pointer-events: auto;
@@ -744,7 +778,174 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
744
778
  align-items: center;
745
779
  vertical-align: middle;
746
780
  }
747
- `,document.head.appendChild(e)}var Se={list:"PillList-module_list_qvLqO"};import{jsx as fe}from"react/jsx-runtime";var vt=[125,69];function We(e){return e===0?"first":e===1?"next":"last"}function be({pills:e,activePillIndex:d,onSelectPill:o,activeSelected:s,rounded:r,loading:i}){return i&&e.length===0?fe("span",{className:Se.list,"data-aia-pill-list-loading":"",children:vt.map((u,m)=>fe("span",{"data-aia-pill-skeleton":"",className:`${J.pill} ${r?J.rounded:""} ${J.skeleton}`,style:{width:u,opacity:Pe[We(m)]}},`skel-${u}`))}):fe("span",{className:Se.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((u,m)=>{let h=!!s&&m===d;return fe(Ke,{label:u.text,state:h?"selected":We(m),selected:h,rounded:r,loading:i,onClick:()=>o(m)},`${u.type}-${u.text}`)})})}import{useLayoutEffect as xt,useRef as wt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`@layer layout {
781
+ `,document.head.appendChild(e)}var Te={list:"PillList-module_list_qvLqO"};import{jsx as ke}from"react/jsx-runtime";var St=[125,69];function Qe(e){return e===0?"first":e===1?"next":"last"}function _e({pills:e,activePillIndex:n,onSelectPill:i,activeSelected:l,rounded:s,loading:r}){return r&&e.length===0?ke("span",{className:Te.list,"data-aia-pill-list-loading":"",children:St.map((o,u)=>ke("span",{"data-aia-pill-skeleton":"",className:`${ae.pill} ${s?ae.rounded:""} ${ae.skeleton}`,style:{width:o,opacity:De[Qe(u)]}},`skel-${o}`))}):ke("span",{className:Te.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((o,u)=>{let g=!!l&&u===n;return ke(qe,{label:o.text,state:g?"selected":Qe(u),selected:g,rounded:s,loading:r,onClick:()=>i(u)},`${o.type}-${o.text}`)})})}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
782
+ (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
783
+ theming one package sees the same result in the other.
784
+
785
+ Nothing here is allowed to say \`color: inherit\`: the dropdown paints a
786
+ background but never sets a \`color\`, so an inheriting node would pick up the
787
+ HOST PAGE's text colour and render black text on a dark panel. For the same
788
+ reason there is no \`prefers-color-scheme\` rule in this file \u2014 the panel's
789
+ darkness comes from --aia-surface, which is independent of the OS setting. */
790
+
791
+ .ProductStrip-module_section_Hugfg {
792
+ display: flex;
793
+ flex-direction: column;
794
+ gap: 6px;
795
+ /* Matches the grid's own 8px inline padding so the section label lines up
796
+ with the option text above it. */
797
+ padding: 0 8px;
798
+ min-width: 0;
799
+ }
800
+
801
+ .ProductStrip-module_label_nuc93 {
802
+ font-family: inherit;
803
+ font-size: var(--aia-products-label-font-size, 11px);
804
+ font-weight: 500;
805
+ line-height: 18px;
806
+ letter-spacing: 0.02em;
807
+ color: var(
808
+ --aia-products-label-color,
809
+ var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb))
810
+ );
811
+ }
812
+
813
+ /* The scroll container. Horizontal overflow is confined here \u2014 the dropdown
814
+ itself is \`overflow: hidden\`, so the page can never gain a sideways
815
+ scrollbar no matter how many cards there are. \`overscroll-behavior-x\` stops
816
+ a trackpad fling at either end from chaining out to the page. */
817
+ .ProductStrip-module_row_WDVBX {
818
+ display: flex;
819
+ gap: var(--aia-product-gap, 8px);
820
+ min-width: 0;
821
+ overflow-x: auto;
822
+ overflow-y: hidden;
823
+ overscroll-behavior-x: contain;
824
+ padding-bottom: 2px;
825
+ /* Hide the scrollbar chrome across all three engines while leaving the box
826
+ scrollable by trackpad, wheel, touch and keyboard. */
827
+ scrollbar-width: none;
828
+ -ms-overflow-style: none;
829
+ }
830
+
831
+ .ProductStrip-module_row_WDVBX::-webkit-scrollbar {
832
+ display: none;
833
+ }
834
+
835
+ .ProductStrip-module_card_JBGYT {
836
+ flex: 0 0 auto;
837
+ display: flex;
838
+ flex-direction: column;
839
+ gap: 6px;
840
+ width: var(--aia-product-card-width, 116px);
841
+ padding: 6px;
842
+ border-radius: 10px;
843
+ background: var(--aia-product-bg, transparent);
844
+ /* Explicit, never inherited \u2014 see the file header. */
845
+ color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
846
+ text-decoration: none;
847
+ cursor: pointer;
848
+ transition: background-color 150ms ease;
849
+ }
850
+
851
+ .ProductStrip-module_card_JBGYT:hover {
852
+ background: var(--aia-product-bg-active, var(--aia-option-bg, transparent));
853
+ }
854
+
855
+ /* Focus is the only cue a keyboard user gets, so it is a real ring rather than
856
+ a background change. Drawn INSIDE the card (negative offset): the row is a
857
+ scroll container with clipped overflow, so an outset ring is cut off on the
858
+ first and last cards and on every card's top and bottom edge. */
859
+ .ProductStrip-module_card_JBGYT:focus-visible {
860
+ outline: 2px solid var(--aia-product-focus-ring, var(--aia-option-color-selected, currentColor));
861
+ outline-offset: -2px;
862
+ }
863
+
864
+ /* Square media tile. aspect-ratio (not a fixed height) keeps it square at any
865
+ --aia-product-card-width a consumer sets. */
866
+ .ProductStrip-module_media_RrbGe {
867
+ display: block;
868
+ position: relative;
869
+ width: 100%;
870
+ aspect-ratio: 1 / 1;
871
+ border-radius: 8px;
872
+ overflow: hidden;
873
+ background: var(--aia-product-media-bg, var(--aia-skeleton-bg, rgba(189, 189, 189, 0.25)));
874
+ }
875
+
876
+ .ProductStrip-module_image_5pNL7 {
877
+ display: block;
878
+ width: 100%;
879
+ height: 100%;
880
+ object-fit: cover;
881
+ }
882
+
883
+ /* Placeholder tile for a product with no image \u2014 a faint glyph on the same
884
+ media fill, so a card without art reads as "no photo" instead of broken. */
885
+ .ProductStrip-module_media_RrbGe[data-aia-product-placeholder]::after {
886
+ content: "";
887
+ position: absolute;
888
+ inset: 30%;
889
+ border-radius: 3px;
890
+ border: 1.5px solid var(--aia-product-placeholder-color, var(--aia-option-color, #c1c4cb));
891
+ opacity: 0.35;
892
+ }
893
+
894
+ /* The text column. Only the title is guaranteed; vendor and price render no
895
+ element at all when absent, so the gap can't reserve space for a missing
896
+ line. */
897
+ .ProductStrip-module_body_ly032 {
898
+ display: flex;
899
+ flex-direction: column;
900
+ gap: 2px;
901
+ min-width: 0;
902
+ }
903
+
904
+ .ProductStrip-module_vendor_Gvu7G {
905
+ font-family: inherit;
906
+ font-size: var(--aia-product-vendor-font-size, 10px);
907
+ line-height: 14px;
908
+ color: var(
909
+ --aia-product-vendor-color,
910
+ var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb))
911
+ );
912
+ opacity: 0.8;
913
+ /* Vendor names are frequently long \u2014 one line, clipped. */
914
+ overflow: hidden;
915
+ white-space: nowrap;
916
+ text-overflow: ellipsis;
917
+ }
918
+
919
+ .ProductStrip-module_title_gCNmq {
920
+ font-family: inherit;
921
+ font-size: var(--aia-product-title-font-size, 12px);
922
+ font-weight: 400;
923
+ line-height: 16px;
924
+ /* The card's most prominent text uses the same token the *highlighted*
925
+ option text does, so it stays legible on any --aia-surface a consumer
926
+ sets \u2014 light or dark \u2014 without a second theming control. */
927
+ color: var(
928
+ --aia-product-title-color,
929
+ var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
930
+ );
931
+ display: -webkit-box;
932
+ -webkit-line-clamp: 2;
933
+ line-clamp: 2;
934
+ -webkit-box-orient: vertical;
935
+ overflow: hidden;
936
+ }
937
+
938
+ .ProductStrip-module_price_gULcE {
939
+ font-family: inherit;
940
+ font-size: var(--aia-product-price-font-size, 11px);
941
+ font-weight: 500;
942
+ line-height: 15px;
943
+ color: var(
944
+ --aia-product-price-color,
945
+ var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
946
+ );
947
+ }
948
+ `,document.head.appendChild(e)}var N={section:"ProductStrip-module_section_Hugfg",label:"ProductStrip-module_label_nuc93",row:"ProductStrip-module_row_WDVBX",card:"ProductStrip-module_card_JBGYT",media:"ProductStrip-module_media_RrbGe",image:"ProductStrip-module_image_5pNL7",body:"ProductStrip-module_body_ly032",vendor:"ProductStrip-module_vendor_Gvu7G",title:"ProductStrip-module_title_gCNmq",price:"ProductStrip-module_price_gULcE"};import{jsx as oe,jsxs as Le}from"react/jsx-runtime";function Xe({products:e,listboxId:n,onSelect:i,onFocusChange:l,focusable:s=!0}){if(e.length===0)return null;let r=`${n}-products-label`;return Le("section",{className:N.section,"data-aia-products":"",role:"group","aria-labelledby":r,children:[oe("div",{className:N.label,id:r,children:"Products"}),oe("div",{className:N.row,"data-aia-products-row":"",children:e.map((o,u)=>oe(At,{product:o,id:`${n}-product-${u}`,onSelect:i,onFocusChange:l,focusable:s},o.id))})]})}function At({product:e,id:n,onSelect:i,onFocusChange:l,focusable:s}){let r=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),i(e))};return Le("a",{id:n,className:N.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:r,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),i(e))},onFocus:()=>l?.(!0),onBlur:o=>{o.relatedTarget?.closest("[data-aia-dropdown]")||l?.(!1)},children:[oe("span",{className:N.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?oe("img",{className:N.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Le("span",{className:N.body,children:[e.vendor?oe("span",{className:N.vendor,children:e.vendor}):null,oe("span",{className:N.title,children:e.title}),e.price?oe("span",{className:N.price,children:e.price}):null]})]})}import{useLayoutEffect as Ct,useRef as Et}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`@layer layout {
748
949
  .aia-grid {
749
950
  display: grid;
750
951
  grid-template-columns: repeat(
@@ -779,7 +980,7 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
779
980
  border-radius: 3px;
780
981
  }
781
982
  }
782
- `,document.head.appendChild(e)}import{jsx as yt}from"react/jsx-runtime";function Ge({min:e="16rem",max:d,gap:o,scroll:s=!1,maxHeight:r,scrollResetKey:i,className:u,children:m,...h}){let v=wt(null);xt(()=>{if(i===void 0)return;let k=v.current;k&&(k.scrollTop=0)},[i]);let _={"--aia-grid-min":e};return d&&(_["--aia-grid-max"]=d),o&&(_["--aia-grid-gap"]=o),r&&(_["--aia-grid-max-height"]=r),yt("div",{ref:v,className:u?`aia-grid ${u}`:"aia-grid","data-scroll":s||void 0,style:_,...h,children:m})}import{useEffect as kt,useRef as _t,useState as It}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.SuggestionItem-module_item_d4vpD {
983
+ `,document.head.appendChild(e)}import{jsx as Rt}from"react/jsx-runtime";function Je({min:e="16rem",max:n,gap:i,scroll:l=!1,maxHeight:s,scrollResetKey:r,className:o,children:u,...g}){let b=Et(null);Ct(()=>{if(r===void 0)return;let y=b.current;y&&(y.scrollTop=0)},[r]);let k={"--aia-grid-min":e};return n&&(k["--aia-grid-max"]=n),i&&(k["--aia-grid-gap"]=i),s&&(k["--aia-grid-max-height"]=s),Rt("div",{ref:b,className:o?`aia-grid ${o}`:"aia-grid","data-scroll":l||void 0,style:k,...g,children:u})}import{useEffect as Dt,useRef as Tt,useState as Lt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.SuggestionItem-module_item_d4vpD {
783
984
  position: relative;
784
985
  overflow: visible;
785
986
  display: flex;
@@ -1129,7 +1330,7 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
1129
1330
  filter: brightness(0.55);
1130
1331
  }
1131
1332
  }
1132
- `,document.head.appendChild(e)}var B={item:"SuggestionItem-module_item_d4vpD",fadeIn:"SuggestionItem-module_fadeIn_I8u35",content:"SuggestionItem-module_content_T-Qba",tappable:"SuggestionItem-module_tappable_70KcX",nonTappable:"SuggestionItem-module_nonTappable_xSZM-",highlighted:"SuggestionItem-module_highlighted_Hb0SU",tag:"SuggestionItem-module_tag_e3Fwe",pressed:"SuggestionItem-module_pressed_98o-r",glassFade:"SuggestionItem-module_glassFade_oyiSj",tapDown:"SuggestionItem-module_tapDown_G3WGz",streaks:"SuggestionItem-module_streaks_d9PEB",streaksVert:"SuggestionItem-module_streaksVert_ERlV1",streakHorizRight:"SuggestionItem-module_streakHorizRight_aboGz",streakHorizLeft:"SuggestionItem-module_streakHorizLeft_BreWJ",streakVertUp:"SuggestionItem-module_streakVertUp_to1GD",streakVertDown:"SuggestionItem-module_streakVertDown_OrcLh",skeletonPulse:"SuggestionItem-module_skeletonPulse_plvdD",text:"SuggestionItem-module_text_yqoh9"};import{jsx as ve,jsxs as Ue}from"react/jsx-runtime";function je({option:e,isHighlighted:d,onSelect:o,onHighlight:s,id:r,loading:i}){let[u,m]=It(!1),h=_t(void 0);kt(()=>()=>clearTimeout(h.current),[]);let v=()=>{i||!e.is_tappable||u||(m(!0),o(e),clearTimeout(h.current),h.current=setTimeout(()=>m(!1),500))},_=[B.item,d&&!i?B.highlighted:"",e.is_tappable?B.tappable:B.nonTappable,u?B.pressed:""].filter(Boolean).join(" ");return Ue("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"aria-selected":d,className:_,tabIndex:i||!e.is_tappable?-1:0,onClick:v,onKeyDown:k=>{!i&&e.is_tappable&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),v())},onMouseEnter:!i&&e.is_tappable?s:void 0,children:[ve("div",{className:B.streaks}),ve("div",{className:B.streaksVert}),Ue("span",{className:B.content,children:[ve("span",{className:B.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&ve("span",{className:B.tag,children:e.tag})]})]})}import{jsx as Ve}from"react/jsx-runtime";function $e({options:e,activeIndex:d,onSelect:o,onHighlight:s,listboxId:r,loading:i,groupKey:u}){return Ve(Ge,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:u,children:e.map((m,h)=>Ve(je,{option:m,isHighlighted:h===d,onSelect:o,onHighlight:()=>s(h),id:`${r}-option-${h}`,loading:i},m.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
1333
+ `,document.head.appendChild(e)}var M={item:"SuggestionItem-module_item_d4vpD",fadeIn:"SuggestionItem-module_fadeIn_I8u35",content:"SuggestionItem-module_content_T-Qba",tappable:"SuggestionItem-module_tappable_70KcX",nonTappable:"SuggestionItem-module_nonTappable_xSZM-",highlighted:"SuggestionItem-module_highlighted_Hb0SU",tag:"SuggestionItem-module_tag_e3Fwe",pressed:"SuggestionItem-module_pressed_98o-r",glassFade:"SuggestionItem-module_glassFade_oyiSj",tapDown:"SuggestionItem-module_tapDown_G3WGz",streaks:"SuggestionItem-module_streaks_d9PEB",streaksVert:"SuggestionItem-module_streaksVert_ERlV1",streakHorizRight:"SuggestionItem-module_streakHorizRight_aboGz",streakHorizLeft:"SuggestionItem-module_streakHorizLeft_BreWJ",streakVertUp:"SuggestionItem-module_streakVertUp_to1GD",streakVertDown:"SuggestionItem-module_streakVertDown_OrcLh",skeletonPulse:"SuggestionItem-module_skeletonPulse_plvdD",text:"SuggestionItem-module_text_yqoh9"};import{jsx as Pe,jsxs as Ze}from"react/jsx-runtime";function Ye({option:e,isHighlighted:n,onSelect:i,onHighlight:l,id:s,loading:r}){let[o,u]=Lt(!1),g=Tt(void 0);Dt(()=>()=>clearTimeout(g.current),[]);let b=()=>{r||!e.is_tappable||o||(u(!0),i(e),clearTimeout(g.current),g.current=setTimeout(()=>u(!1),500))},k=[M.item,n&&!r?M.highlighted:"",e.is_tappable?M.tappable:M.nonTappable,o?M.pressed:""].filter(Boolean).join(" ");return Ze("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":r?"":void 0,"aria-selected":n,className:k,tabIndex:r||!e.is_tappable?-1:0,onClick:b,onKeyDown:y=>{!r&&e.is_tappable&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),b())},onMouseEnter:!r&&e.is_tappable?l:void 0,children:[Pe("div",{className:M.streaks}),Pe("div",{className:M.streaksVert}),Ze("span",{className:M.content,children:[Pe("span",{className:M.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&Pe("span",{className:M.tag,children:e.tag})]})]})}import{jsx as et}from"react/jsx-runtime";function tt({options:e,activeIndex:n,onSelect:i,onHighlight:l,listboxId:s,loading:r,groupKey:o}){return et(Je,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,children:e.map((u,g)=>et(Ye,{option:u,isHighlighted:g===n,onSelect:i,onHighlight:()=>l(g),id:`${s}-option-${g}`,loading:r},u.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
1133
1334
  .aia-stack {
1134
1335
  display: flex;
1135
1336
  flex-direction: column;
@@ -1146,7 +1347,7 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
1146
1347
  }
1147
1348
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
1148
1349
  }
1149
- `,document.head.appendChild(e)}import{jsx as Pt}from"react/jsx-runtime";function qe({space:e,align:d="stretch",className:o,children:s,...r}){let i=e?{"--aia-stack-space":e}:void 0;return Pt("div",{className:o?`aia-stack ${o}`:"aia-stack","data-align":d,style:i,...r,children:s})}import{jsx as te,jsxs as Dt}from"react/jsx-runtime";var Et=[159,119,164];function Rt(e){let d=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[o,s]=Ct(d);if(St(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>s(r.matches);return r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[e]),e!==void 0)return e==="auto"?o?"dark":"light":e}function Ae({suggestions:e,activeIndex:d,onSelect:o,onHighlight:s,isOpen:r,id:i,className:u,pills:m,onPillClick:h,showPills:v=!0,activeSelected:_=!1,isLoading:k=!1,isInputEmpty:C=!1,optionsPosition:E="below",mode:G}){let H=Rt(G),Q=H!==void 0,U=e[0]?.options??[],n=!!(m&&m.length>0&&h),x=r&&(U.length>0||v&&n||k),D={suggestions:e,activeIndex:d,pills:m,showPills:v,activeSelected:_,isLoading:k,isInputEmpty:C},N=At(D);x&&(N.current=D);let b=x?D:N.current,T=b.suggestions[0],L=T?.options??[],S=b.activeIndex>=0&&!!L[b.activeIndex]?.is_tappable,K=!!(b.pills&&b.pills.length>0&&h),R=b.showPills&&K,Z=b.showPills&&!K&&b.isLoading,j=R||Z,F=L.length>0,W=b.isLoading&&!F;return te("div",{id:i,role:"listbox","data-aia-dropdown":"","data-options-position":E,"data-mode":H,"data-aia-loading":b.isLoading?"":void 0,className:`${Q?"magicx-aia ":""}${oe.dropdown} ${x?oe.visible:""} ${u??""}`,onMouseDown:f=>f.preventDefault(),children:Dt(qe,{space:"8px",children:[j&&te(le,{noWrap:!0,className:oe.pillBar,"data-aia-pillbar":"",children:te(be,{pills:b.pills??[],activePillIndex:0,activeSelected:b.activeSelected,onSelectPill:h??(()=>{}),rounded:!0,loading:b.isLoading})}),F&&te($e,{options:L,activeIndex:b.activeIndex,onSelect:o,onHighlight:s,listboxId:i,loading:b.isLoading,groupKey:T?`${T.type} ${T.text}`:""}),W&&te("div",{className:oe.skeletonBars,"data-aia-skeleton-bars":"",children:Et.map(f=>te("span",{className:oe.skeletonBar,style:{width:f}},`bar-${f}`))}),te(Ne,{isOptionHighlighted:S,isInputEmpty:b.isInputEmpty})]})})}import{buildSubmitResult as Kt,ModeController as Wt,setCursorOffset as Gt}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=`.SubmitButton-module_submitButton_otz7H {
1350
+ `,document.head.appendChild(e)}import{jsx as zt}from"react/jsx-runtime";function at({space:e,align:n="stretch",className:i,children:l,...s}){let r=e?{"--aia-stack-space":e}:void 0;return zt("div",{className:i?`aia-stack ${i}`:"aia-stack","data-align":n,style:r,...s,children:l})}import{jsx as ie,jsxs as Kt}from"react/jsx-runtime";var Mt=[159,119,164],Ht=()=>{};function Ot(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[i,l]=Nt(n);if(Ft(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>l(s.matches);return s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?i?"dark":"light":e}function ze({suggestions:e,activeIndex:n,onSelect:i,onHighlight:l,isOpen:s,id:r,className:o,pills:u,onPillClick:g,showPills:b=!0,activeSelected:k=!1,isLoading:y=!1,isInputEmpty:A=!1,products:_,onProductSelect:W,onProductFocusChange:U,optionsPosition:J="below",mode:V}){let C=Ot(V),v=C!==void 0,p=e[0]?.options??[],Z=!!(u&&u.length>0&&g),$=!!(_&&_.length>0),T=s&&(p.length>0||b&&Z||y||$),E={suggestions:e,activeIndex:n,pills:u,showPills:b,activeSelected:k,isLoading:y,isInputEmpty:A,products:_},I=Bt(E);T&&(I.current=E);let h=T?E:I.current,L=h.suggestions[0],F=L?.options??[],R=h.activeIndex>=0&&!!F[h.activeIndex]?.is_tappable,O=!!(h.pills&&h.pills.length>0&&g),j=h.showPills&&O,q=h.showPills&&!O&&h.isLoading,K=j||q,B=F.length>0,Y=h.isLoading&&!B,z=h.products??[];return ie("div",{id:r,role:"listbox","data-aia-dropdown":"","data-options-position":J,"data-mode":C,"data-aia-loading":h.isLoading?"":void 0,"data-aia-has-products":z.length>0?"":void 0,className:`${v?"magicx-aia ":""}${de.dropdown} ${T?de.visible:""} ${o??""}`,onMouseDown:t=>t.preventDefault(),children:Kt(at,{space:"8px",children:[K&&ie(me,{noWrap:!0,className:de.pillBar,"data-aia-pillbar":"",children:ie(_e,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:g??(()=>{}),rounded:!0,loading:h.isLoading})}),B&&ie(tt,{options:F,activeIndex:h.activeIndex,onSelect:i,onHighlight:l,listboxId:r,loading:h.isLoading,groupKey:L?`${L.type} ${L.text}`:""}),Y&&ie("div",{className:de.skeletonBars,"data-aia-skeleton-bars":"",children:Mt.map(t=>ie("span",{className:de.skeletonBar,style:{width:t}},`bar-${t}`))}),ie(Xe,{products:z,listboxId:r,onSelect:W??Ht,onFocusChange:U,focusable:T}),ie(je,{isOptionHighlighted:R,isInputEmpty:h.isInputEmpty})]})})}import{buildSubmitResult as Jt,ModeController as Zt,setCursorOffset as Yt}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=`.SubmitButton-module_submitButton_otz7H {
1150
1351
  flex-shrink: 0;
1151
1352
  width: 32px;
1152
1353
  height: 32px;
@@ -1181,5 +1382,5 @@ import{buildSubmitResult as co,withSkippedParams as uo}from"@magicx-eng/ai-autoc
1181
1382
  );
1182
1383
  cursor: default;
1183
1384
  }
1184
- `,document.head.appendChild(e)}var Qe={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ce}from"react/jsx-runtime";function Ze({disabled:e,onClick:d}){return Ce("button",{type:"button","data-aia-submit":"",className:Qe.submitButton,disabled:e,onClick:o=>{o.stopPropagation(),d()},"aria-label":"Submit",children:Ce("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Ce("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Tt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Xe,useEffect as xe,useRef as M,useState as Lt}from"react";var zt={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],placeholderText:"",isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1};function Ee({onSubmit:e,onError:d,optionOverrides:o,maskCompletedText:s,apiConfig:r,columns:i=2,dropdownTrigger:u,optionsPosition:m,closeDropdownOnBlur:h,showNonTappableOptions:v,onFocus:_,onBlur:k,value:C,completedParams:E,onChange:G,onParamsChange:H,source:Q,setCursor:U}){let n=M(null),[x,D]=Lt(null),N=M(e);N.current=e;let b=M(d);b.current=d;let T=M(G);T.current=G;let L=M(H);L.current=H;let S=M(_);S.current=_;let K=M(k);K.current=k;let R=M(U);R.current=U,xe(()=>{if(typeof document>"u")return;let a=new Tt(document.createElement("div"),{renderMode:"headless",apiConfig:r,optionOverrides:o,maskCompletedText:s,columns:i,dropdownTrigger:u,optionsPosition:m,closeDropdownOnBlur:h,showNonTappableOptions:v,source:Q,value:C,completedParams:E,onSubmit:(...I)=>N.current?.(...I),onError:(...I)=>b.current?.(...I),onChange:(...I)=>T.current?.(...I),onParamsChange:(...I)=>L.current?.(...I),onFocus:()=>S.current?.(),onBlur:()=>K.current?.(),setCursor:I=>R.current?.(I)});n.current=a,D(a.getState());let P=a.subscribe(I=>D(I));return()=>{P(),a.destroy(),n.current===a&&(n.current=null)}},[]),xe(()=>{C!==void 0&&n.current?.setValue(C)},[C]),xe(()=>{E!==void 0&&n.current?.setCompletedParams(E)},[E]);let Z=JSON.stringify(r??null),j=M(o),F=M(0);if(o!==j.current){let a=j.current,P=o,I=Object.keys(a??{}),ae=Object.keys(P??{});(I.length!==ae.length||ae.some(se=>!a?.[se]||P[se]!==a[se]))&&F.current++,j.current=o}xe(()=>{n.current?.update({apiConfig:r,optionOverrides:o,dropdownTrigger:u,optionsPosition:m,closeDropdownOnBlur:h,showNonTappableOptions:v})},[Z,F.current,u,m,h,v]);let W=M(null);W.current===null&&(W.current={handleTextChange:a=>n.current?.handleTextChange(a),handleKeyDown:a=>{let P="nativeEvent"in a?a.nativeEvent:a;n.current?.handleKeyDown(P)},setFocused:a=>n.current?.setFocused(a),startEditingParam:a=>n.current?.startEditingParam(a),exitEditMode:()=>n.current?.exitEditMode(),handleCaretAfterInput:a=>n.current?.handleCaretAfterInput(a),handleCaretMove:a=>n.current?.handleCaretMove(a),replaceEditingRange:a=>n.current?.replaceEditingRange(a)??!1,setActivePill:a=>n.current?.setActivePill(a),removeLastParam:()=>n.current?.removeLastParam(),clearNewParamId:()=>n.current?.clearNewParamId(),reset:()=>n.current?.reset(),selectOption:a=>n.current?.selectOption(a),setActiveDropdownIndex:a=>n.current?.setActiveDropdownIndex(a),handleFocus:()=>n.current?.setFocused(!0),handleBlur:()=>n.current?.setFocused(!1)});let f=W.current,re=Xe(a=>{let P=a.target.value,ae=P.length>0&&!a.nativeEvent?.isComposing&&P[0]!==P[0].toUpperCase()?P[0].toUpperCase()+P.slice(1):P;n.current?.handleTextChange(ae)},[]),Y=Xe(a=>{n.current?.handleKeyDown(a.nativeEvent)},[]),V=n.current,l=x??zt,t=C!==void 0?C:l.text,p=E!==void 0?E:l.completedParams,c=l.actionableSuggestions,w=c[0],g=V?.listboxId??"",A=l.activeDropdownIndex>=0&&V?`${g}-option-${l.activeDropdownIndex}`:void 0,z=l.editingParam,$=z?{type:z.suggestionType,text:z.suggestionPlaceholder,required:!0,options:z.options}:null,ce=$??w,ye=$?[$]:c,ue=!V||l.isLoading&&!l.editingParam&&!l.inSelectionAnimation;return{completedParams:p,skippedParams:l.skippedParams,suggestionPills:c,setActivePill:f.setActivePill,removeLastParam:f.removeLastParam,segments:l.segments,newParamId:l.newParamId,clearNewParamId:f.clearNewParamId,suggestions:l.suggestions,activeIndex:l.activeDropdownIndex,isReady:l.isReady,isLoading:ue,isFocused:l.isFocused,isDropdownOpen:l.isDropdownOpen,isActivePillSelected:l.isActivePillSelected,placeholderText:l.placeholderText,listboxId:g,error:l.error,handleTextChange:f.handleTextChange,handleKeyDown:f.handleKeyDown,setFocused:f.setFocused,editingParam:z,editingAnchor:l.editingAnchor,caretOffset:l.caretOffset,startEditingParam:f.startEditingParam,exitEditMode:f.exitEditMode,handleCaretAfterInput:f.handleCaretAfterInput,handleCaretMove:f.handleCaretMove,replaceEditingRange:f.replaceEditingRange,inputProps:{value:t,placeholder:l.placeholderText||void 0,onChange:re,onKeyDown:Y,onFocus:f.handleFocus,onBlur:f.handleBlur,role:"combobox","aria-expanded":l.isDropdownOpen,"aria-activedescendant":A,"aria-autocomplete":"list","aria-controls":g},reset:f.reset,dropdownProps:{suggestions:ce?[{...ce,options:l.filteredOptions}]:[],activeIndex:l.activeDropdownIndex,onSelect:f.selectOption,onHighlight:f.setActiveDropdownIndex,isOpen:l.isDropdownOpen,id:g,pills:ye,activeSelected:l.isActivePillSelected,onPillClick:f.setActivePill,isLoading:ue,isInputEmpty:t.trim().length===0,optionsPosition:m??"below"}}}import{extractPlainText as Je,getCursorOffset as Ye,plainTextLength as Ft,renderEditableContent as Bt,setCursorOffset as et}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as O,useEffect as Re,useLayoutEffect as De,useRef as ie}from"react";var we;function Mt(){if(we!==void 0)return we;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),we=e.contentEditable==="plaintext-only",we}function tt(e){let{segments:d,newParamId:o,editingParam:s,editingAnchor:r,caretOffset:i,placeholderText:u,isFocused:m,isDropdownOpen:h,listboxId:v,activeDescendantId:_,autoFocus:k,handleTextChange:C,handleKeyDown:E,handleCaretAfterInput:G,handleCaretMove:H,startEditingParam:Q,replaceEditingRange:U,setFocused:n}=e,x=ie(null),D=ie(!1),N=ie(""),b=ie(""),T=ie(null),L=ie(0);T.current=i,Re(()=>{if(!k)return;let t=x.current;if(!t)return;document.activeElement===t?n(!0):t.focus();let p=t.ownerDocument??document,c=p.getSelection(),w=c&&c.rangeCount>0&&t.contains(c.anchorNode);if(c&&!w){let g=p.createRange();g.selectNodeContents(t),g.collapse(!0),c.removeAllRanges(),c.addRange(g)}},[k,n]),Re(()=>{let t=x.current;if(!t)return;let p=t.ownerDocument??document,c=()=>{let w=p.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!t.contains(w.anchorNode))return;let g=w.anchorNode,$=(g.nodeType===Node.ELEMENT_NODE?g:g.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if($&&$!==s?.id){Q($);return}performance.now()-L.current<50||H(Ye(t))};return p.addEventListener("selectionchange",c),()=>p.removeEventListener("selectionchange",c)},[s,Q,H]),De(()=>{let t=x.current;t&&Bt({input:t,segments:d,newParamId:o,editingParamId:s?.id??null,placeholderText:u??"",isFocused:m})},[d,o,s,u,m]),De(()=>{let t=N.current,p=o??"";if(N.current=p,!p||p===t)return;let c=x.current;if(!c)return;c.focus();let w=T.current??Ft(c);et(c,w)},[o]),De(()=>{let t=b.current,p=s?.id??"";if(b.current=p,!p||p===t||r==null)return;let c=x.current;c&&et(c,r)},[s,r]);let S=O(()=>{if(D.current)return;let t=x.current;if(!t)return;let p=Je(t),w=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;C(w)},[C]),K=O(()=>{L.current=performance.now(),S();let t=x.current;t&&G(Ye(t))},[S,G]);Re(()=>{let t=x.current;if(!t)return;let p=c=>{let w=c,g=w.inputType;if(g==="insertParagraph"||g==="insertLineBreak"||g==="insertFromDrop"){c.preventDefault();return}if(g.startsWith("insert")||g.startsWith("delete")){let A=g.startsWith("delete")?"":w.data??"";U(A)&&c.preventDefault()}};return t.addEventListener("beforeinput",p),()=>t.removeEventListener("beforeinput",p)},[U]);let R=O(()=>{D.current=!0},[]),Z=O(()=>{D.current=!1,S()},[S]),j=O(t=>{t.preventDefault();let p=x.current;if(!p)return;let c=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!c)return;let w=p.ownerDocument??document,g=w.getSelection();if(!g||g.rangeCount===0)return;let A=g.getRangeAt(0);if(!p.contains(A.startContainer))return;A.deleteContents();let z=w.createTextNode(c);A.insertNode(z),A.setStartAfter(z),A.collapse(!0),g.removeAllRanges(),g.addRange(A),S()},[S]),F=O(t=>E(t),[E]),W=O(()=>n(!0),[n]),f=O(()=>n(!1),[n]),re=O(()=>x.current?.focus(),[]),Y=O(()=>x.current?.blur(),[]),V=O(()=>{let t=x.current;return t?Je(t):""},[]),l=Mt()?"plaintext-only":"true";return{inputRef:x,editorProps:{ref:x,contentEditable:l,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":v,"aria-expanded":h,"aria-activedescendant":_,spellCheck:!0,enterKeyHint:"send",onInput:K,onKeyDown:F,onCompositionStart:R,onCompositionEnd:Z,onPaste:j,onFocus:W,onBlur:f},getPlainText:V,focus:re,blur:Y}}import{jsx as ne,jsxs as Le}from"react/jsx-runtime";function Ut(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var jt=Ot(function({onSubmit:d,onError:o,optionOverrides:s,maskCompletedText:r,className:i,apiConfig:u,columns:m,pillPlacement:h="dropdown",mode:v="auto",optionsPosition:_="below",animations:k=!0,dropdownTrigger:C,closeDropdownOnBlur:E,showNonTappableOptions:G,autoFocus:H=!0,onFocus:Q,onBlur:U,value:n,completedParams:x,onChange:D,onParamsChange:N,submitButton:b},T){let L=pe(null),S=pe(null),K=pe(()=>{}),R=pe(null),Z=pe(null);at(()=>{let y=L.current;if(y)return R.current?R.current.setMode(v):R.current=new Wt(y,v),()=>{R.current?.destroy(),R.current=null}},[v]);let j=Te(y=>{let X=Z.current?.current;X&&(X.focus(),Gt(X,y))},[]),{completedParams:F,skippedParams:W,suggestionPills:f,setActivePill:re,segments:Y,newParamId:V,clearNewParamId:l,placeholderText:t,isFocused:p,isDropdownOpen:c,isActivePillSelected:w,isLoading:g,activeIndex:A,listboxId:z,handleTextChange:$,handleKeyDown:ce,setFocused:ye,editingParam:ue,editingAnchor:a,caretOffset:P,startEditingParam:I,handleCaretAfterInput:ae,handleCaretMove:se,replaceEditingRange:ot,dropdownProps:it,reset:me}=Ee({onSubmit:y=>K.current(y),onError:o,optionOverrides:s,maskCompletedText:r,apiConfig:u,columns:m,dropdownTrigger:C,optionsPosition:_,closeDropdownOnBlur:E,showNonTappableOptions:G,onFocus:Q,onBlur:U,value:n,completedParams:x,onChange:D,onParamsChange:N,source:"full-sdk",setCursor:j});at(()=>{if(!V)return;let y=window.setTimeout(()=>l(),650);return()=>window.clearTimeout(y)},[V,l]);let nt=A>=0?`${z}-option-${A}`:void 0,{inputRef:ke,editorProps:rt,focus:ge,blur:ze,getPlainText:Fe}=tt({segments:Y,newParamId:V,editingParam:ue,editingAnchor:a,caretOffset:P,placeholderText:t,isFocused:p,isDropdownOpen:c,listboxId:z,activeDescendantId:nt,autoFocus:H,handleTextChange:$,handleKeyDown:ce,handleCaretAfterInput:ae,handleCaretMove:se,startEditingParam:I,replaceEditingRange:ot,setFocused:ye});Z.current=ke,Nt(()=>{let y=S.current,X=ke.current;if(!y||!X)return;let Be=()=>{let Oe=y.firstElementChild;if(!Oe)return;let pt=Oe.getBoundingClientRect(),ct=X.getBoundingClientRect();pt.top>=ct.bottom-2?y.setAttribute("data-aia-pill-wrapped",""):y.removeAttribute("data-aia-pill-wrapped")};Be();let Me=new ResizeObserver(Be);return Me.observe(X),()=>Me.disconnect()},[Y,f.length,g,ke]),Ht(T,()=>({focus:ge,blur:ze,reset:me,setMode:y=>R.current?.setMode(y)}),[ge,ze,me]);let he=!!Y.length||F.length>0,_e=Te(()=>{if(!he)return;let y=Fe();d(Kt(y,F,W)),me()},[he,F,W,d,me,Fe]);K.current=_e;let st=Te(y=>{y.target?.closest("[data-aia-pill]")||ge()},[ge]),lt=h==="inline",dt=h==="dropdown";return Le("div",{ref:L,className:`magicx-aia ${ee.container} ${i??""}`,"data-pill-placement":h,"data-options-position":_,"data-animations":k?"on":"off","data-mode":Ut(v),children:[ne(Ae,{...it,showPills:dt}),Le("div",{className:ee.inputWrapper,onClick:st,children:[Le("div",{className:ee.editorArea,"data-aia-editor":"",children:[ne("div",{...rt,className:ee.input,"data-aia-input":""}),lt&&(g||f.length>0)&&ne("span",{ref:S,className:ee.pillListContainer,"data-aia-pill-list-container":"",children:ne(be,{pills:f,activePillIndex:0,activeSelected:w,onSelectPill:re,loading:g})})]}),b===null?null:b===void 0?ne(Ze,{disabled:!he,onClick:_e}):ne("span",{"data-aia-submit":"",className:ee.submitSlot,onClick:y=>{he&&(y.stopPropagation(),_e())},children:b})]})]})});export{jt as AIAutocomplete,Ae as AIAutocompleteDropdown,co as buildSubmitResult,Ee as useAIAutocomplete,uo as withSkippedParams};
1385
+ `,document.head.appendChild(e)}var ot={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Fe}from"react/jsx-runtime";function it({disabled:e,onClick:n}){return Fe("button",{type:"button","data-aia-submit":"",className:ot.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),n()},"aria-label":"Submit",children:Fe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Fe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Gt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as st,useEffect as he,useRef as D,useState as Wt}from"react";import{useRef as rt}from"react";function nt(e){let n=rt(e);n.current=e;let i=rt(null);i.current===null&&(i.current={fetch:(s,r)=>{let o=n.current;return o?o.fetch(s,r):Promise.reject(new Error("products config removed"))},transform:s=>n.current?.transform(s)??[],get limit(){return n.current?.limit}});let l=e!==void 0;return{config:l?i.current:void 0,enabled:l}}var Ut={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],placeholderText:"",isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1};function Be({onSubmit:e,onError:n,optionOverrides:i,maskCompletedText:l,apiConfig:s,columns:r=2,dropdownTrigger:o,optionsPosition:u,closeDropdownOnBlur:g,showNonTappableOptions:b,onFocus:k,onBlur:y,value:A,completedParams:_,onChange:W,onParamsChange:U,products:J,onProductSelect:V,source:C,setCursor:v}){let p=D(null),[Z,$]=Wt(null),T=D(e);T.current=e;let E=D(n);E.current=n;let I=D(W);I.current=W;let h=D(U);h.current=U;let L=D(k);L.current=k;let F=D(y);F.current=y;let R=D(v);R.current=v;let O=D(V);O.current=V;let j=nt(J);he(()=>{if(typeof document>"u")return;let d=new Gt(document.createElement("div"),{renderMode:"headless",apiConfig:s,optionOverrides:i,maskCompletedText:l,columns:r,dropdownTrigger:o,optionsPosition:u,closeDropdownOnBlur:g,showNonTappableOptions:b,source:C,value:A,completedParams:_,onSubmit:(...w)=>T.current?.(...w),onError:(...w)=>E.current?.(...w),onChange:(...w)=>I.current?.(...w),onParamsChange:(...w)=>h.current?.(...w),onFocus:()=>L.current?.(),onBlur:()=>F.current?.(),onProductSelect:w=>O.current?.(w),setCursor:w=>R.current?.(w),products:j.config});p.current=d,$(d.getState());let P=d.subscribe(w=>$(w));return()=>{P(),d.destroy(),p.current===d&&(p.current=null)}},[]),he(()=>{A!==void 0&&p.current?.setValue(A)},[A]),he(()=>{_!==void 0&&p.current?.setCompletedParams(_)},[_]);let q=JSON.stringify(s??null),K=D(i),B=D(0);if(i!==K.current){let d=K.current,P=i,w=Object.keys(d??{}),le=Object.keys(P??{});(w.length!==le.length||le.some(ee=>!d?.[ee]||P[ee]!==d[ee]))&&B.current++,K.current=i}he(()=>{p.current?.update({apiConfig:s,optionOverrides:i,dropdownTrigger:o,optionsPosition:u,closeDropdownOnBlur:g,showNonTappableOptions:b})},[q,B.current,o,u,g,b]);let Y=D(!1);he(()=>{if(!Y.current){Y.current=!0;return}p.current?.update({products:j.config})},[j.enabled]);let z=D(null);z.current===null&&(z.current={handleTextChange:d=>p.current?.handleTextChange(d),handleKeyDown:d=>{let P="nativeEvent"in d?d.nativeEvent:d;p.current?.handleKeyDown(P)},setFocused:d=>p.current?.setFocused(d),startEditingParam:d=>p.current?.startEditingParam(d),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:d=>p.current?.handleCaretAfterInput(d),handleCaretMove:d=>p.current?.handleCaretMove(d),replaceEditingRange:d=>p.current?.replaceEditingRange(d)??!1,setActivePill:d=>p.current?.setActivePill(d),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:d=>p.current?.selectOption(d),selectProduct:d=>p.current?.selectProduct(d),setActiveDropdownIndex:d=>p.current?.setActiveDropdownIndex(d),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let t=z.current,c=st(d=>{let P=d.target.value,le=P.length>0&&!d.nativeEvent?.isComposing&&P[0]!==P[0].toUpperCase()?P[0].toUpperCase()+P.slice(1):P;p.current?.handleTextChange(le)},[]),m=st(d=>{p.current?.handleKeyDown(d.nativeEvent)},[]),f=p.current,a=Z??Ut,S=A!==void 0?A:a.text,Q=_!==void 0?_:a.completedParams,G=a.actionableSuggestions,be=G[0],se=f?.listboxId??"",Se=a.activeDropdownIndex>=0&&f?`${se}-option-${a.activeDropdownIndex}`:void 0,re=a.editingParam,ue=re?{type:re.suggestionType,text:re.suggestionPlaceholder,required:!0,options:re.options}:null,ve=ue??be,Ae=ue?[ue]:G,xe=!f||a.isLoading&&!a.editingParam&&!a.inSelectionAnimation;return{completedParams:Q,skippedParams:a.skippedParams,suggestionPills:G,setActivePill:t.setActivePill,removeLastParam:t.removeLastParam,segments:a.segments,newParamId:a.newParamId,clearNewParamId:t.clearNewParamId,suggestions:a.suggestions,activeIndex:a.activeDropdownIndex,isReady:a.isReady,isLoading:xe,isFocused:a.isFocused,isDropdownOpen:a.isDropdownOpen,isActivePillSelected:a.isActivePillSelected,placeholderText:a.placeholderText,listboxId:se,error:a.error,products:a.products,selectProduct:t.selectProduct,handleTextChange:t.handleTextChange,handleKeyDown:t.handleKeyDown,setFocused:t.setFocused,editingParam:re,editingAnchor:a.editingAnchor,caretOffset:a.caretOffset,startEditingParam:t.startEditingParam,exitEditMode:t.exitEditMode,handleCaretAfterInput:t.handleCaretAfterInput,handleCaretMove:t.handleCaretMove,replaceEditingRange:t.replaceEditingRange,inputProps:{value:S,placeholder:a.placeholderText||void 0,onChange:c,onKeyDown:m,onFocus:t.handleFocus,onBlur:t.handleBlur,role:"combobox","aria-expanded":a.isDropdownOpen,"aria-activedescendant":Se,"aria-autocomplete":"list","aria-controls":se},reset:t.reset,dropdownProps:{suggestions:ve?[{...ve,options:a.filteredOptions}]:[],activeIndex:a.activeDropdownIndex,onSelect:t.selectOption,onHighlight:t.setActiveDropdownIndex,isOpen:a.isDropdownOpen,id:se,pills:Ae,activeSelected:a.isActivePillSelected,onPillClick:t.setActivePill,isLoading:xe,isInputEmpty:S.trim().length===0,products:a.products,onProductSelect:t.selectProduct,onProductFocusChange:t.setFocused,optionsPosition:u??"below"}}}import{extractPlainText as lt,getCursorOffset as dt,plainTextLength as Vt,renderEditableContent as $t,setCursorOffset as pt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as H,useEffect as Ne,useLayoutEffect as Me,useRef as pe}from"react";var Ie;function jt(){if(Ie!==void 0)return Ie;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ie=e.contentEditable==="plaintext-only",Ie}function ct(e){let{segments:n,newParamId:i,editingParam:l,editingAnchor:s,caretOffset:r,placeholderText:o,isFocused:u,isDropdownOpen:g,listboxId:b,activeDescendantId:k,autoFocus:y,handleTextChange:A,handleKeyDown:_,handleCaretAfterInput:W,handleCaretMove:U,startEditingParam:J,replaceEditingRange:V,setFocused:C}=e,v=pe(null),p=pe(!1),Z=pe(""),$=pe(""),T=pe(null),E=pe(0);T.current=r,Ne(()=>{if(!y)return;let t=v.current;if(!t)return;document.activeElement===t?C(!0):t.focus();let c=t.ownerDocument??document,m=c.getSelection(),f=m&&m.rangeCount>0&&t.contains(m.anchorNode);if(m&&!f){let a=c.createRange();a.selectNodeContents(t),a.collapse(!0),m.removeAllRanges(),m.addRange(a)}},[y,C]),Ne(()=>{let t=v.current;if(!t)return;let c=t.ownerDocument??document,m=()=>{let f=c.getSelection();if(!f||f.rangeCount===0||!f.anchorNode||!t.contains(f.anchorNode))return;let a=f.anchorNode,G=(a.nodeType===Node.ELEMENT_NODE?a:a.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if(G&&G!==l?.id){J(G);return}performance.now()-E.current<50||U(dt(t))};return c.addEventListener("selectionchange",m),()=>c.removeEventListener("selectionchange",m)},[l,J,U]),Me(()=>{let t=v.current;t&&$t({input:t,segments:n,newParamId:i,editingParamId:l?.id??null,placeholderText:o??"",isFocused:u})},[n,i,l,o,u]),Me(()=>{let t=Z.current,c=i??"";if(Z.current=c,!c||c===t)return;let m=v.current;if(!m)return;m.focus();let f=T.current??Vt(m);pt(m,f)},[i]),Me(()=>{let t=$.current,c=l?.id??"";if($.current=c,!c||c===t||s==null)return;let m=v.current;m&&pt(m,s)},[l,s]);let I=H(()=>{if(p.current)return;let t=v.current;if(!t)return;let c=lt(t),f=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;A(f)},[A]),h=H(()=>{E.current=performance.now(),I();let t=v.current;t&&W(dt(t))},[I,W]);Ne(()=>{let t=v.current;if(!t)return;let c=m=>{let f=m,a=f.inputType;if(a==="insertParagraph"||a==="insertLineBreak"||a==="insertFromDrop"){m.preventDefault();return}if(a.startsWith("insert")||a.startsWith("delete")){let S=a.startsWith("delete")?"":f.data??"";V(S)&&m.preventDefault()}};return t.addEventListener("beforeinput",c),()=>t.removeEventListener("beforeinput",c)},[V]);let L=H(()=>{p.current=!0},[]),F=H(()=>{p.current=!1,I()},[I]),R=H(t=>{t.preventDefault();let c=v.current;if(!c)return;let m=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!m)return;let f=c.ownerDocument??document,a=f.getSelection();if(!a||a.rangeCount===0)return;let S=a.getRangeAt(0);if(!c.contains(S.startContainer))return;S.deleteContents();let Q=f.createTextNode(m);S.insertNode(Q),S.setStartAfter(Q),S.collapse(!0),a.removeAllRanges(),a.addRange(S),I()},[I]),O=H(t=>_(t),[_]),j=H(()=>C(!0),[C]),q=H(()=>C(!1),[C]),K=H(()=>v.current?.focus(),[]),B=H(()=>v.current?.blur(),[]),Y=H(()=>{let t=v.current;return t?lt(t):""},[]),z=jt()?"plaintext-only":"true";return{inputRef:v,editorProps:{ref:v,contentEditable:z,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":b,"aria-expanded":g,"aria-activedescendant":k,spellCheck:!0,enterKeyHint:"send",onInput:h,onKeyDown:O,onCompositionStart:L,onCompositionEnd:F,onPaste:R,onFocus:j,onBlur:q},getPlainText:Y,focus:K,blur:B}}import{jsx as ce,jsxs as Oe}from"react/jsx-runtime";function ea(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ta=qt(function({onSubmit:n,onError:i,optionOverrides:l,maskCompletedText:s,className:r,apiConfig:o,columns:u,pillPlacement:g="dropdown",mode:b="auto",optionsPosition:k="below",animations:y=!0,dropdownTrigger:A,closeDropdownOnBlur:_,showNonTappableOptions:W,autoFocus:U=!0,onFocus:J,onBlur:V,value:C,completedParams:v,onChange:p,onParamsChange:Z,products:$,onProductSelect:T,submitButton:E},I){let h=fe(null),L=fe(null),F=fe(()=>{}),R=fe(null),O=fe(null);ut(()=>{let x=h.current;if(x)return R.current?R.current.setMode(b):R.current=new Zt(x,b),()=>{R.current?.destroy(),R.current=null}},[b]);let j=He(x=>{let te=O.current?.current;te&&(te.focus(),Yt(te,x))},[]),{completedParams:q,skippedParams:K,suggestionPills:B,setActivePill:Y,segments:z,newParamId:t,clearNewParamId:c,placeholderText:m,isFocused:f,isDropdownOpen:a,isActivePillSelected:S,isLoading:Q,activeIndex:G,listboxId:be,handleTextChange:se,handleKeyDown:Se,setFocused:re,editingParam:ue,editingAnchor:ve,caretOffset:Ae,startEditingParam:xe,handleCaretAfterInput:d,handleCaretMove:P,replaceEditingRange:w,dropdownProps:le,reset:ee}=Be({onSubmit:x=>F.current(x),onError:i,optionOverrides:l,maskCompletedText:s,apiConfig:o,columns:u,dropdownTrigger:A,optionsPosition:k,closeDropdownOnBlur:_,showNonTappableOptions:W,onFocus:J,onBlur:V,value:C,completedParams:v,onChange:p,onParamsChange:Z,products:$,onProductSelect:T,source:"full-sdk",setCursor:j});ut(()=>{if(!t)return;let x=window.setTimeout(()=>c(),650);return()=>window.clearTimeout(x)},[t,c]);let mt=G>=0?`${be}-option-${G}`:void 0,{inputRef:Ce,editorProps:gt,focus:we,blur:Ke,getPlainText:Ge}=ct({segments:z,newParamId:t,editingParam:ue,editingAnchor:ve,caretOffset:Ae,placeholderText:m,isFocused:f,isDropdownOpen:a,listboxId:be,activeDescendantId:mt,autoFocus:U,handleTextChange:se,handleKeyDown:Se,handleCaretAfterInput:d,handleCaretMove:P,startEditingParam:xe,replaceEditingRange:w,setFocused:re});O.current=Ce,Xt(()=>{let x=L.current,te=Ce.current;if(!x||!te)return;let We=()=>{let Ve=x.firstElementChild;if(!Ve)return;let vt=Ve.getBoundingClientRect(),xt=te.getBoundingClientRect();vt.top>=xt.bottom-2?x.setAttribute("data-aia-pill-wrapped",""):x.removeAttribute("data-aia-pill-wrapped")};We();let Ue=new ResizeObserver(We);return Ue.observe(te),()=>Ue.disconnect()},[z,B.length,Q,Ce]),Qt(I,()=>({focus:we,blur:Ke,reset:ee,setMode:x=>R.current?.setMode(x)}),[we,Ke,ee]);let ye=!!z.length||q.length>0,Ee=He(()=>{if(!ye)return;let x=Ge();n(Jt(x,q,K)),ee()},[ye,q,K,n,ee,Ge]);F.current=Ee;let ht=He(x=>{x.target?.closest("[data-aia-pill]")||we()},[we]),ft=g==="inline",bt=g==="dropdown";return Oe("div",{ref:h,className:`magicx-aia ${ne.container} ${r??""}`,"data-pill-placement":g,"data-options-position":k,"data-animations":y?"on":"off","data-mode":ea(b),children:[ce(ze,{...le,showPills:bt}),Oe("div",{className:ne.inputWrapper,onClick:ht,children:[Oe("div",{className:ne.editorArea,"data-aia-editor":"",children:[ce("div",{...gt,className:ne.input,"data-aia-input":""}),ft&&(Q||B.length>0)&&ce("span",{ref:L,className:ne.pillListContainer,"data-aia-pill-list-container":"",children:ce(_e,{pills:B,activePillIndex:0,activeSelected:S,onSelectPill:Y,loading:Q})})]}),E===null?null:E===void 0?ce(it,{disabled:!ye,onClick:Ee}):ce("span",{"data-aia-submit":"",className:ne.submitSlot,onClick:x=>{ye&&(x.stopPropagation(),Ee())},children:E})]})]})});export{ta as AIAutocomplete,ze as AIAutocompleteDropdown,Eo as buildSubmitResult,Be as useAIAutocomplete,Ro as withSkippedParams};
1185
1386
  //# sourceMappingURL=index.mjs.map