@magicx-eng/ai-autocomplete-react 0.10.1 → 0.11.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 Go,withSkippedParams as Ko}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as oa,useCallback as Ge,useEffect as gt,useImperativeHandle as ia,useLayoutEffect as ra,useRef as be}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 Ko,withSkippedParams as Wo}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as ia,useCallback as Ke,useEffect as ft,useImperativeHandle as ra,useLayoutEffect as na,useRef as ve}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
@@ -179,7 +179,7 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
179
179
  opacity: 0;
180
180
  }
181
181
  }
182
- `,document.head.appendChild(e)}var le={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 Vt,useRef as qt,useState as $t}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
182
+ `,document.head.appendChild(e)}var se={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 qt,useRef as $t,useState as jt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
183
183
  * Built-in appearance defaults \u2014 zero specificity via :where().
184
184
  * Consumer CSS always wins without !important.
185
185
  *
@@ -665,7 +665,7 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
665
665
  opacity: 0.25;
666
666
  }
667
667
  }
668
- `,document.head.appendChild(e)}var ae={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",pillBar:"AIAutocompleteDropdown-module_pillBar_pwTXe",pillScroll:"AIAutocompleteDropdown-module_pillScroll_Tpzus",skip:"AIAutocompleteDropdown-module_skip_7-olS",skeletonBars:"AIAutocompleteDropdown-module_skeletonBars_HVr9C",skeletonBar:"AIAutocompleteDropdown-module_skeletonBar_O3xIx",aiaSkeletonPulse:"AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q"};import{ATTRIBUTION_URL as _t,buildAttributionUrl as Pt,getFooterHint as It}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as St,useState as At}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 {
668
+ `,document.head.appendChild(e)}var ie={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",pillBar:"AIAutocompleteDropdown-module_pillBar_pwTXe",pillScroll:"AIAutocompleteDropdown-module_pillScroll_Tpzus",skip:"AIAutocompleteDropdown-module_skip_7-olS",skeletonBars:"AIAutocompleteDropdown-module_skeletonBars_HVr9C",skeletonBar:"AIAutocompleteDropdown-module_skeletonBar_O3xIx",aiaSkeletonPulse:"AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q"};import{ATTRIBUTION_URL as Pt,buildAttributionUrl as It,getFooterHint as St}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as At,useState as Ct}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 {
669
669
  .aia-cluster {
670
670
  display: flex;
671
671
  flex-wrap: wrap;
@@ -707,7 +707,7 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
707
707
  justify-content: space-around;
708
708
  }
709
709
  }
710
- `,document.head.appendChild(e)}import{jsx as je}from"react/jsx-runtime";function he({gap:e,align:s="center",justify:a="start",noWrap:n=!1,inline:d=!1,className:l,children:o,...m}){let f=e?{"--aia-cluster-gap":e}:void 0,v={className:l?`aia-cluster ${l}`:"aia-cluster","data-align":s,"data-justify":a,"data-nowrap":n||void 0,"data-inline":d||void 0,style:f,...m};return d?je("span",{...v,children:o}):je("div",{...v,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
710
+ `,document.head.appendChild(e)}import{jsx as Qe}from"react/jsx-runtime";function ge({gap:e,align:n="center",justify:t="start",noWrap:r=!1,inline:l=!1,className:i,children:a,...h}){let b=e?{"--aia-cluster-gap":e}:void 0,x={className:i?`aia-cluster ${i}`:"aia-cluster","data-align":n,"data-justify":t,"data-nowrap":r||void 0,"data-inline":l||void 0,style:b,...h};return l?Qe("span",{...x,children:a}):Qe("div",{...x,children:a})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
711
711
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
712
712
  room above the hint/branding row so the footer doesn't butt against the last
713
713
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -837,7 +837,7 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
837
837
  justify-content: flex-end;
838
838
  }
839
839
  }
840
- `,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 ge,jsxs as Te}from"react/jsx-runtime";function Qe({isOptionHighlighted:e=!1,isInputEmpty:s=!1}){let{key:a,hint:n}=It(e,s),[d,l]=At(_t);return St(()=>{l(Pt())},[]),ge("footer",{className:Q.footer,"data-aia-footer":"",children:Te(he,{justify:"between",noWrap:!0,className:Q.row,children:[Te(he,{gap:"5px",className:Q.hintGroup,children:[ge("kbd",{className:Q.key,children:a}),ge("span",{className:Q.hint,children:n})]}),Te("a",{className:Q.brandLink,href:d,target:"_blank",rel:"noopener noreferrer",children:[ge("span",{className:Q.brand,children:"AI"}),ge("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,
840
+ `,document.head.appendChild(e)}var Z={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 fe,jsxs as Le}from"react/jsx-runtime";function Je({isOptionHighlighted:e=!1,isInputEmpty:n=!1}){let{key:t,hint:r}=St(e,n),[l,i]=Ct(Pt);return At(()=>{i(It())},[]),fe("footer",{className:Z.footer,"data-aia-footer":"",children:Le(ge,{justify:"between",noWrap:!0,className:Z.row,children:[Le(ge,{gap:"5px",className:Z.hintGroup,children:[fe("kbd",{className:Z.key,children:t}),fe("span",{className:Z.hint,children:r})]}),Le("a",{className:Z.brandLink,href:l,target:"_blank",rel:"noopener noreferrer",children:[fe("span",{className:Z.brand,children:"AI"}),fe("span",{className:Z.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,
841
841
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
842
842
  The border is kept as a 1px transparent line so the box stays the same size
843
843
  as it was when the outline was dashed. */
@@ -894,7 +894,7 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
894
894
  opacity: 0;
895
895
  }
896
896
  }
897
- `,document.head.appendChild(e)}var oe={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 Ct}from"react/jsx-runtime";var Le={selected:1,first:.7,next:.4,last:.2};function Je({label:e,state:s,rounded:a,loading:n,onClick:d}){let l=[oe.pill,a?oe.rounded:"",n?oe.skeleton:""].filter(Boolean).join(" ");return Ct("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:l,style:{opacity:Le[s]},onMouseDown:o=>o.preventDefault(),onClick:n?void 0:d,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=`.PillList-module_list_qvLqO {
897
+ `,document.head.appendChild(e)}var re={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 Et}from"react/jsx-runtime";var ze={selected:1,first:.7,next:.4,last:.2};function Xe({label:e,state:n,rounded:t,loading:r,onClick:l}){let i=[re.pill,t?re.rounded:"",r?re.skeleton:""].filter(Boolean).join(" ");return Et("button",{type:"button","data-aia-pill":"","data-aia-loading":r?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:i,style:{opacity:ze[n]},onMouseDown:a=>a.preventDefault(),onClick:r?void 0:l,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=`.PillList-module_list_qvLqO {
898
898
  position: relative;
899
899
  z-index: 1;
900
900
  pointer-events: auto;
@@ -904,7 +904,7 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
904
904
  align-items: center;
905
905
  vertical-align: middle;
906
906
  }
907
- `,document.head.appendChild(e)}var ze={list:"PillList-module_list_qvLqO"};import{jsx as Pe}from"react/jsx-runtime";var Et=[125,69];function Xe(e){return e===0?"first":e===1?"next":"last"}function Ie({pills:e,activePillIndex:s,onSelectPill:a,activeSelected:n,rounded:d,loading:l}){return l&&e.length===0?Pe("span",{className:ze.list,"data-aia-pill-list-loading":"",children:Et.map((o,m)=>Pe("span",{"data-aia-pill-skeleton":"",className:`${oe.pill} ${d?oe.rounded:""} ${oe.skeleton}`,style:{width:o,opacity:Le[Xe(m)]}},`skel-${o}`))}):Pe("span",{className:ze.list,"data-aia-pill-list-loading":l?"":void 0,children:e.map((o,m)=>{let f=!!n&&m===s;return Pe(Je,{label:o.text,state:f?"selected":Xe(m),selected:f,rounded:d,loading:l,onClick:()=>a(m)},`${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
907
+ `,document.head.appendChild(e)}var Be={list:"PillList-module_list_qvLqO"};import{jsx as Ie}from"react/jsx-runtime";var Dt=[125,69];function Ze(e){return e===0?"first":e===1?"next":"last"}function Se({pills:e,activePillIndex:n,onSelectPill:t,activeSelected:r,rounded:l,loading:i}){return i&&e.length===0?Ie("span",{className:Be.list,"data-aia-pill-list-loading":"",children:Dt.map((a,h)=>Ie("span",{"data-aia-pill-skeleton":"",className:`${re.pill} ${l?re.rounded:""} ${re.skeleton}`,style:{width:a,opacity:ze[Ze(h)]}},`skel-${a}`))}):Ie("span",{className:Be.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((a,h)=>{let b=!!r&&h===n;return Ie(Xe,{label:a.text,state:b?"selected":Ze(h),selected:b,rounded:l,loading:i,onClick:()=>t(h)},`${a.type}-${a.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
908
908
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
909
909
  theming one package sees the same result in the other.
910
910
 
@@ -1071,7 +1071,7 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
1071
1071
  var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
1072
1072
  );
1073
1073
  }
1074
- `,document.head.appendChild(e)}var M={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 ie,jsxs as Be}from"react/jsx-runtime";function Ze({products:e,listboxId:s,onSelect:a,onFocusChange:n,focusable:d=!0}){if(e.length===0)return null;let l=`${s}-products-label`;return Be("section",{className:M.section,"data-aia-products":"",role:"group","aria-labelledby":l,children:[ie("div",{className:M.label,id:l,children:"Products"}),ie("div",{className:M.row,"data-aia-products-row":"",children:e.map((o,m)=>ie(Dt,{product:o,id:`${s}-product-${m}`,onSelect:a,onFocusChange:n,focusable:d},o.id))})]})}function Dt({product:e,id:s,onSelect:a,onFocusChange:n,focusable:d}){let l=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),a(e))};return Be("a",{id:s,className:M.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:d?0:-1,onClick:l,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),a(e))},onFocus:()=>n?.(!0),onBlur:o=>{o.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[ie("span",{className:M.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?ie("img",{className:M.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Be("span",{className:M.body,children:[e.vendor?ie("span",{className:M.vendor,children:e.vendor}):null,ie("span",{className:M.title,children:e.title}),e.price?ie("span",{className:M.price,children:e.price}):null]})]})}import{computeOptionsGridLayout as Nt,isOptionsGridMobileViewport as Ot,OPTIONS_GRID_MOBILE_QUERY as Ht}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Gt,useState as Kt}from"react";import{optionsGridTemplateColumns as Rt}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Tt,useRef as Lt}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 {
1074
+ `,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 ne,jsxs as Fe}from"react/jsx-runtime";function Ye({products:e,listboxId:n,onSelect:t,onFocusChange:r,focusable:l=!0}){if(e.length===0)return null;let i=`${n}-products-label`;return Fe("section",{className:N.section,"data-aia-products":"",role:"group","aria-labelledby":i,children:[ne("div",{className:N.label,id:i,children:"Products"}),ne("div",{className:N.row,"data-aia-products-row":"",children:e.map((a,h)=>ne(Rt,{product:a,id:`${n}-product-${h}`,onSelect:t,onFocusChange:r,focusable:l},a.id))})]})}function Rt({product:e,id:n,onSelect:t,onFocusChange:r,focusable:l}){let i=a=>{a.metaKey||a.ctrlKey||a.shiftKey||a.altKey||a.button!==0||(a.preventDefault(),t(e))};return Fe("a",{id:n,className:N.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:l?0:-1,onClick:i,onKeyDown:a=>{a.key!=="Enter"&&a.key!==" "||(a.preventDefault(),t(e))},onFocus:()=>r?.(!0),onBlur:a=>{a.relatedTarget?.closest("[data-aia-dropdown]")||r?.(!1)},children:[ne("span",{className:N.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?ne("img",{className:N.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Fe("span",{className:N.body,children:[e.vendor?ne("span",{className:N.vendor,children:e.vendor}):null,ne("span",{className:N.title,children:e.title}),e.price?ne("span",{className:N.price,children:e.price}):null]})]})}import{computeOptionsGridLayout as Ot,isOptionsGridMobileViewport as Ht,OPTIONS_GRID_MOBILE_QUERY as Gt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Kt,useState as Wt}from"react";import{optionsGridTemplateColumns as Tt}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Lt,useRef as zt}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 {
1075
1075
  .aia-grid {
1076
1076
  display: grid;
1077
1077
  grid-template-columns: repeat(
@@ -1106,7 +1106,7 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
1106
1106
  border-radius: 3px;
1107
1107
  }
1108
1108
  }
1109
- `,document.head.appendChild(e)}import{jsx as zt}from"react/jsx-runtime";function Ye({min:e="16rem",max:s,gap:a,scroll:n=!1,maxHeight:d,scrollResetKey:l,cols:o,className:m,children:f,...v}){let _=Lt(null);Tt(()=>{if(l===void 0)return;let R=_.current;R&&(R.scrollTop=0)},[l]);let x={"--aia-grid-min":e};return s&&(x["--aia-grid-max"]=s),a&&(x["--aia-grid-gap"]=a),d&&(x["--aia-grid-max-height"]=d),o&&(x.gridTemplateColumns=Rt(o)),zt("div",{ref:_,className:m?`aia-grid ${m}`:"aia-grid","data-scroll":n||void 0,style:x,...v,children:f})}import{useEffect as Bt,useRef as Ft,useState as Mt}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 {
1109
+ `,document.head.appendChild(e)}import{jsx as Bt}from"react/jsx-runtime";function et({min:e="16rem",max:n,gap:t,scroll:r=!1,maxHeight:l,scrollResetKey:i,cols:a,className:h,children:b,...x}){let w=zt(null);Lt(()=>{if(i===void 0)return;let T=w.current;T&&(T.scrollTop=0)},[i]);let v={"--aia-grid-min":e};return n&&(v["--aia-grid-max"]=n),t&&(v["--aia-grid-gap"]=t),l&&(v["--aia-grid-max-height"]=l),a&&(v.gridTemplateColumns=Tt(a)),Bt("div",{ref:w,className:h?`aia-grid ${h}`:"aia-grid","data-scroll":r||void 0,style:v,...x,children:b})}import{useEffect as Ft,useRef as Mt,useState as Nt}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 {
1110
1110
  position: relative;
1111
1111
  overflow: visible;
1112
1112
  display: flex;
@@ -1456,7 +1456,7 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
1456
1456
  filter: brightness(0.55);
1457
1457
  }
1458
1458
  }
1459
- `,document.head.appendChild(e)}var N={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 Se,jsxs as et}from"react/jsx-runtime";function tt({option:e,isHighlighted:s,onSelect:a,onHighlight:n,id:d,loading:l}){let[o,m]=Mt(!1),f=Ft(void 0);Bt(()=>()=>clearTimeout(f.current),[]);let v=()=>{l||!e.is_tappable||o||(m(!0),a(e),clearTimeout(f.current),f.current=setTimeout(()=>m(!1),500))},_=[N.item,s&&!l?N.highlighted:"",e.is_tappable?N.tappable:N.nonTappable,o?N.pressed:""].filter(Boolean).join(" ");return et("div",{id:d,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"aria-selected":s,className:_,tabIndex:l||!e.is_tappable?-1:0,onClick:v,onKeyDown:x=>{!l&&e.is_tappable&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),v())},onMouseEnter:!l&&e.is_tappable?n:void 0,children:[Se("div",{className:N.streaks}),Se("div",{className:N.streaksVert}),et("span",{className:N.content,children:[Se("span",{className:N.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&Se("span",{className:N.tag,children:e.tag})]})]})}import{jsx as at}from"react/jsx-runtime";function Wt(){let[e,s]=Kt(Ot);return Gt(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(Ht),n=()=>s(a.matches);return n(),a.addEventListener("change",n),()=>a.removeEventListener("change",n)},[]),e}function ot({options:e,activeIndex:s,onSelect:a,onHighlight:n,listboxId:d,loading:l,groupKey:o}){let m=Wt(),{cols:f,maxHeight:v}=Nt(e.length,m);return at(Ye,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,cols:f,maxHeight:v,children:e.map((_,x)=>at(tt,{option:_,isHighlighted:x===s,onSelect:a,onHighlight:()=>n(x),id:`${d}-option-${x}`,loading:l},_.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
1459
+ `,document.head.appendChild(e)}var O={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 Ae,jsxs as tt}from"react/jsx-runtime";function at({option:e,isHighlighted:n,onSelect:t,onHighlight:r,id:l,loading:i}){let[a,h]=Nt(!1),b=Mt(void 0);Ft(()=>()=>clearTimeout(b.current),[]);let x=()=>{i||!e.is_tappable||a||(h(!0),t(e),clearTimeout(b.current),b.current=setTimeout(()=>h(!1),500))},w=[O.item,n&&!i?O.highlighted:"",e.is_tappable?O.tappable:O.nonTappable,a?O.pressed:""].filter(Boolean).join(" ");return tt("div",{id:l,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"aria-selected":n,className:w,tabIndex:i||!e.is_tappable?-1:0,onClick:x,onKeyDown:v=>{!i&&e.is_tappable&&(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),x())},onMouseEnter:!i&&e.is_tappable?r:void 0,children:[Ae("div",{className:O.streaks}),Ae("div",{className:O.streaksVert}),tt("span",{className:O.content,children:[Ae("span",{className:O.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&Ae("span",{className:O.tag,children:e.tag})]})]})}import{jsx as ot}from"react/jsx-runtime";function Ut(){let[e,n]=Wt(Ht);return Kt(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Gt),r=()=>n(t.matches);return r(),t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[]),e}function it({options:e,activeIndex:n,onSelect:t,onHighlight:r,listboxId:l,loading:i,groupKey:a}){let h=Ut(),{cols:b,maxHeight:x}=Ot(e.length,h);return ot(et,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:a,cols:b,maxHeight:x,children:e.map((w,v)=>ot(at,{option:w,isHighlighted:v===n,onSelect:t,onHighlight:()=>r(v),id:`${l}-option-${v}`,loading:i},w.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
1460
1460
  .aia-stack {
1461
1461
  display: flex;
1462
1462
  flex-direction: column;
@@ -1473,7 +1473,7 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
1473
1473
  }
1474
1474
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
1475
1475
  }
1476
- `,document.head.appendChild(e)}import{jsx as Ut}from"react/jsx-runtime";function it({space:e,align:s="stretch",className:a,children:n,...d}){let l=e?{"--aia-stack-space":e}:void 0;return Ut("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":s,style:l,...d,children:n})}import{jsx as J,jsxs as rt}from"react/jsx-runtime";var jt=[159,119,164],Qt=()=>{};function Jt(e){let s=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,n]=$t(s);if(Vt(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let d=window.matchMedia("(prefers-color-scheme: dark)"),l=()=>n(d.matches);return d.addEventListener("change",l),()=>d.removeEventListener("change",l)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function Fe({suggestions:e,activeIndex:s,onSelect:a,onHighlight:n,isOpen:d,id:l,className:o,pills:m,onPillClick:f,showPills:v=!0,onSkip:_,showSkipButton:x=!0,skipDisabled:R=!1,activeSelected:C=!1,isLoading:A=!1,isInputEmpty:U=!1,products:T,onProductSelect:X,onProductFocusChange:E,optionsPosition:y="below",mode:H}){let c=Jt(H),Z=c!==void 0,V=e[0]?.options??[],q=!!(m&&m.length>0&&f),I=!!(T&&T.length>0),L=d&&(V.length>0||v&&q||A||I),z={suggestions:e,activeIndex:s,pills:m,showPills:v,showSkipButton:x,skipDisabled:R,activeSelected:C,isLoading:A,isInputEmpty:U,products:T},G=qt(z);L&&(G.current=z);let h=L?z:G.current,P=h.suggestions[0],B=P?.options??[],$=h.activeIndex>=0&&!!B[h.activeIndex]?.is_tappable,F=!!(h.pills&&h.pills.length>0&&f),K=h.showPills&&F,W=h.showPills&&!F&&h.isLoading,j=K||W,r=F&&h.showSkipButton&&!h.isInputEmpty&&!!_,t=h.pills?.[0]?.text,u=B.length>0,b=h.isLoading&&!u,g=h.products??[];return J("div",{id:l,role:"listbox","data-aia-dropdown":"","data-options-position":y,"data-mode":c,"data-aia-loading":h.isLoading?"":void 0,"data-aia-has-products":g.length>0?"":void 0,className:`${Z?"magicx-aia ":""}${ae.dropdown} ${L?ae.visible:""} ${o??""}`,onMouseDown:i=>i.preventDefault(),children:rt(it,{space:"8px",children:[(j||r)&&rt(he,{noWrap:!0,className:ae.pillBar,"data-aia-pillbar":"",children:[j&&J("span",{className:ae.pillScroll,"data-aia-pill-scroll":"",children:J(Ie,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:f??(()=>{}),rounded:!0,loading:h.isLoading})}),r&&J("button",{type:"button",tabIndex:-1,className:ae.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":t?`Skip ${t}`:"Skip",onClick:_,children:"skip"})]}),u&&J(ot,{options:B,activeIndex:h.activeIndex,onSelect:a,onHighlight:n,listboxId:l,loading:h.isLoading,groupKey:P?`${P.type} ${P.text}`:""}),b&&J("div",{className:ae.skeletonBars,"data-aia-skeleton-bars":"",children:jt.map(i=>J("span",{className:ae.skeletonBar,style:{width:i}},`bar-${i}`))}),J(Ze,{products:g,listboxId:l,onSelect:X??Qt,onFocusChange:E,focusable:L}),J(Qe,{isOptionHighlighted:$,isInputEmpty:h.isInputEmpty})]})})}import{buildSubmitResult as na,ModeController as sa,setCursorOffset as la}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 {
1476
+ `,document.head.appendChild(e)}import{jsx as Vt}from"react/jsx-runtime";function rt({space:e,align:n="stretch",className:t,children:r,...l}){let i=e?{"--aia-stack-space":e}:void 0;return Vt("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":n,style:i,...l,children:r})}import{jsx as Y,jsxs as nt}from"react/jsx-runtime";var Qt=[159,119,164],Jt=()=>{};function Xt(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,r]=jt(n);if(qt(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let l=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(l.matches);return l.addEventListener("change",i),()=>l.removeEventListener("change",i)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Me({suggestions:e,activeIndex:n,onSelect:t,onHighlight:r,isOpen:l,id:i,className:a,pills:h,onPillClick:b,showPills:x=!0,onSkip:w,showSkipButton:v=!0,skipDisabled:T=!1,activeSelected:V=!1,isLoading:A=!1,isInputEmpty:C=!1,products:F,onProductSelect:q,onProductFocusChange:L,optionsPosition:y="below",mode:$}){let G=Xt($),m=G!==void 0,ee=e[0]?.options??[],j=!!(h&&h.length>0&&b),E=!!(F&&F.length>0),D=l&&(ee.length>0||x&&j||A||E),K={suggestions:e,activeIndex:n,pills:h,showPills:x,showSkipButton:v,skipDisabled:T,activeSelected:V,isLoading:A,isInputEmpty:C,products:F},W=$t(K);D&&(W.current=K);let g=D?K:W.current,z=g.suggestions[0],I=z?.options??[],Q=g.activeIndex>=0&&!!I[g.activeIndex]?.is_tappable,M=!!(g.pills&&g.pills.length>0&&b),J=g.showPills&&M,U=g.showPills&&!M&&g.isLoading,B=J||U,s=M&&g.showSkipButton&&!g.isInputEmpty&&!!w,p=g.pills?.[0]?.text,u=I.length>0,o=g.isLoading&&!u,f=g.products??[];return Y("div",{id:i,role:"listbox","data-aia-dropdown":"","data-options-position":y,"data-mode":G,"data-aia-loading":g.isLoading?"":void 0,"data-aia-has-products":f.length>0?"":void 0,className:`${m?"magicx-aia ":""}${ie.dropdown} ${D?ie.visible:""} ${a??""}`,onMouseDown:_=>_.preventDefault(),children:nt(rt,{space:"8px",children:[(B||s)&&nt(ge,{noWrap:!0,className:ie.pillBar,"data-aia-pillbar":"",children:[B&&Y("span",{className:ie.pillScroll,"data-aia-pill-scroll":"",children:Y(Se,{pills:g.pills??[],activePillIndex:0,activeSelected:g.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:g.isLoading})}),s&&Y("button",{type:"button",tabIndex:-1,className:ie.skip,"data-aia-skip":"",disabled:g.isLoading||g.skipDisabled,"aria-label":p?`Skip ${p}`:"Skip",onClick:w,children:"skip"})]}),u&&Y(it,{options:I,activeIndex:g.activeIndex,onSelect:t,onHighlight:r,listboxId:i,loading:g.isLoading,groupKey:z?`${z.type} ${z.text}`:""}),o&&Y("div",{className:ie.skeletonBars,"data-aia-skeleton-bars":"",children:Qt.map(_=>Y("span",{className:ie.skeletonBar,style:{width:_}},`bar-${_}`))}),Y(Ye,{products:f,listboxId:i,onSelect:q??Jt,onFocusChange:L,focusable:D}),Y(Je,{isOptionHighlighted:Q,isInputEmpty:g.isInputEmpty})]})})}import{buildSubmitResult as sa,ModeController as la,setCursorOffset as da}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 {
1477
1477
  flex-shrink: 0;
1478
1478
  width: 32px;
1479
1479
  height: 32px;
@@ -1508,5 +1508,5 @@ import{buildSubmitResult as Go,withSkippedParams as Ko}from"@magicx-eng/ai-autoc
1508
1508
  );
1509
1509
  cursor: default;
1510
1510
  }
1511
- `,document.head.appendChild(e)}var nt={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Me}from"react/jsx-runtime";function st({disabled:e,onClick:s}){return Me("button",{type:"button","data-aia-submit":"",className:nt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),s()},"aria-label":"Submit",children:Me("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Me("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Xt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as pt,useEffect as fe,useRef as D,useState as Zt}from"react";import{useRef as lt}from"react";function dt(e){let s=lt(e);s.current=e;let a=lt(null);a.current===null&&(a.current={fetch:(d,l)=>{let o=s.current;return o?o.fetch(d,l):Promise.reject(new Error("products config removed"))},transform:d=>s.current?.transform(d)??[],get limit(){return s.current?.limit}});let n=e!==void 0;return{config:n?a.current:void 0,enabled:n}}var Yt={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 Ne({onSubmit:e,onError:s,optionOverrides:a,maskCompletedText:n,apiConfig:d,columns:l=2,dropdownTrigger:o,optionsPosition:m,closeDropdownOnBlur:f,showNonTappableOptions:v,showSkipButton:_,onFocus:x,onBlur:R,value:C,completedParams:A,onChange:U,onParamsChange:T,products:X,onProductSelect:E,source:y,setCursor:H}){let c=D(null),[Z,V]=Zt(null),q=D(e);q.current=e;let I=D(s);I.current=s;let L=D(U);L.current=U;let z=D(T);z.current=T;let G=D(x);G.current=x;let h=D(R);h.current=R;let P=D(H);P.current=H;let B=D(E);B.current=E;let $=dt(X);fe(()=>{if(typeof document>"u")return;let p=new Xt(document.createElement("div"),{renderMode:"headless",apiConfig:d,optionOverrides:a,maskCompletedText:n,columns:l,dropdownTrigger:o,optionsPosition:m,closeDropdownOnBlur:f,showNonTappableOptions:v,source:y,value:C,completedParams:A,onSubmit:(...k)=>q.current?.(...k),onError:(...k)=>I.current?.(...k),onChange:(...k)=>L.current?.(...k),onParamsChange:(...k)=>z.current?.(...k),onFocus:()=>G.current?.(),onBlur:()=>h.current?.(),onProductSelect:k=>B.current?.(k),setCursor:k=>P.current?.(k),products:$.config});c.current=p,V(p.getState());let S=p.subscribe(k=>V(k));return()=>{S(),p.destroy(),c.current===p&&(c.current=null)}},[]),fe(()=>{C!==void 0&&c.current?.setValue(C)},[C]),fe(()=>{A!==void 0&&c.current?.setCompletedParams(A)},[A]);let F=JSON.stringify(d??null),K=D(a),W=D(0);if(a!==K.current){let p=K.current,S=a,k=Object.keys(p??{}),de=Object.keys(S??{});(k.length!==de.length||de.some(me=>!p?.[me]||S[me]!==p[me]))&&W.current++,K.current=a}fe(()=>{c.current?.update({apiConfig:d,optionOverrides:a,dropdownTrigger:o,optionsPosition:m,closeDropdownOnBlur:f,showNonTappableOptions:v})},[F,W.current,o,m,f,v]);let j=D(!1);fe(()=>{if(!j.current){j.current=!0;return}c.current?.update({products:$.config})},[$.enabled]);let r=D(null);r.current===null&&(r.current={handleTextChange:p=>c.current?.handleTextChange(p),handleKeyDown:p=>{let S="nativeEvent"in p?p.nativeEvent:p;c.current?.handleKeyDown(S)},setFocused:p=>c.current?.setFocused(p),startEditingParam:p=>c.current?.startEditingParam(p),exitEditMode:()=>c.current?.exitEditMode(),handleCaretAfterInput:p=>c.current?.handleCaretAfterInput(p),handleCaretMove:p=>c.current?.handleCaretMove(p),replaceEditingRange:p=>c.current?.replaceEditingRange(p)??!1,setActivePill:p=>c.current?.setActivePill(p),skipActivePill:()=>c.current?.skipActivePill(),removeLastParam:()=>c.current?.removeLastParam(),clearNewParamId:()=>c.current?.clearNewParamId(),reset:()=>c.current?.reset(),selectOption:p=>c.current?.selectOption(p),selectProduct:p=>c.current?.selectProduct(p),setActiveDropdownIndex:p=>c.current?.setActiveDropdownIndex(p),handleFocus:()=>c.current?.setFocused(!0),handleBlur:()=>c.current?.setFocused(!1)});let t=r.current,u=pt(p=>{let S=p.target.value,de=S.length>0&&!p.nativeEvent?.isComposing&&S[0]!==S[0].toUpperCase()?S[0].toUpperCase()+S.slice(1):S;c.current?.handleTextChange(de)},[]),b=pt(p=>{c.current?.handleKeyDown(p.nativeEvent)},[]),g=c.current,i=Z??Yt,Y=C!==void 0?C:i.text,re=A!==void 0?A:i.completedParams,ne=i.actionableSuggestions,ve=ne[0],se=g?.listboxId??"",Ce=i.activeDropdownIndex>=0&&g?`${se}-option-${i.activeDropdownIndex}`:void 0,ee=i.editingParam,ue=ee?{type:ee.suggestionType,text:ee.suggestionPlaceholder,required:!0,options:ee.options}:null,xe=ue??ve,Ee=ue?[ue]:ne,we=!g||i.isLoading&&!i.editingParam&&!i.inSelectionAnimation;return{completedParams:re,skippedParams:i.skippedParams,suggestionPills:ne,setActivePill:t.setActivePill,skipActivePill:t.skipActivePill,removeLastParam:t.removeLastParam,segments:i.segments,newParamId:i.newParamId,clearNewParamId:t.clearNewParamId,suggestions:i.suggestions,activeIndex:i.activeDropdownIndex,isReady:i.isReady,isLoading:we,isFocused:i.isFocused,isDropdownOpen:i.isDropdownOpen,isActivePillSelected:i.isActivePillSelected,placeholderText:i.placeholderText,listboxId:se,error:i.error,products:i.products,selectProduct:t.selectProduct,handleTextChange:t.handleTextChange,handleKeyDown:t.handleKeyDown,setFocused:t.setFocused,editingParam:ee,editingAnchor:i.editingAnchor,caretOffset:i.caretOffset,startEditingParam:t.startEditingParam,exitEditMode:t.exitEditMode,handleCaretAfterInput:t.handleCaretAfterInput,handleCaretMove:t.handleCaretMove,replaceEditingRange:t.replaceEditingRange,inputProps:{value:Y,placeholder:i.placeholderText||void 0,onChange:u,onKeyDown:b,onFocus:t.handleFocus,onBlur:t.handleBlur,role:"combobox","aria-expanded":i.isDropdownOpen,"aria-activedescendant":Ce,"aria-autocomplete":"list","aria-controls":se},reset:t.reset,dropdownProps:{suggestions:xe?[{...xe,options:i.filteredOptions}]:[],activeIndex:i.activeDropdownIndex,onSelect:t.selectOption,onHighlight:t.setActiveDropdownIndex,isOpen:i.isDropdownOpen,id:se,pills:Ee,activeSelected:i.isActivePillSelected,onPillClick:t.setActivePill,onSkip:t.skipActivePill,showSkipButton:(_??!0)&&!ee,skipDisabled:i.inSelectionAnimation,isLoading:we,isInputEmpty:Y.trim().length===0,products:i.products,onProductSelect:t.selectProduct,onProductFocusChange:t.setFocused,optionsPosition:m??"below"}}}import{extractPlainText as ct,getCursorOffset as ut,plainTextLength as ea,renderEditableContent as ta,setCursorOffset as mt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as O,useEffect as Oe,useLayoutEffect as He,useRef as pe}from"react";var Ae;function aa(){if(Ae!==void 0)return Ae;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ae=e.contentEditable==="plaintext-only",Ae}function ht(e){let{segments:s,newParamId:a,editingParam:n,editingAnchor:d,caretOffset:l,placeholderText:o,isFocused:m,isDropdownOpen:f,listboxId:v,activeDescendantId:_,autoFocus:x,handleTextChange:R,handleKeyDown:C,handleCaretAfterInput:A,handleCaretMove:U,startEditingParam:T,replaceEditingRange:X,setFocused:E}=e,y=pe(null),H=pe(!1),c=pe(""),Z=pe(""),V=pe(null),q=pe(0);V.current=l,Oe(()=>{if(!x)return;let r=y.current;if(!r)return;document.activeElement===r?E(!0):r.focus();let t=r.ownerDocument??document,u=t.getSelection(),b=u&&u.rangeCount>0&&r.contains(u.anchorNode);if(u&&!b){let g=t.createRange();g.selectNodeContents(r),g.collapse(!0),u.removeAllRanges(),u.addRange(g)}},[x,E]),Oe(()=>{let r=y.current;if(!r)return;let t=r.ownerDocument??document,u=()=>{let b=t.getSelection();if(!b||b.rangeCount===0||!b.anchorNode||!r.contains(b.anchorNode))return;let g=b.anchorNode,i=g.nodeType===Node.ELEMENT_NODE?g:g.parentElement,re=(b.isCollapsed?i?.closest('strong[data-seg="completed"][data-param-id]'):null)?.dataset.paramId??null;if(re&&re!==n?.id){T(re);return}performance.now()-q.current<50||U(ut(r))};return t.addEventListener("selectionchange",u),()=>t.removeEventListener("selectionchange",u)},[n,T,U]),He(()=>{let r=y.current;r&&ta({input:r,segments:s,newParamId:a,editingParamId:n?.id??null,placeholderText:o??"",isFocused:m})},[s,a,n,o,m]),He(()=>{let r=c.current,t=a??"";if(c.current=t,!t||t===r)return;let u=y.current;if(!u)return;u.focus();let b=V.current??ea(u);mt(u,b)},[a]),He(()=>{let r=Z.current,t=n?.id??"";if(Z.current=t,!t||t===r||d==null)return;let u=y.current;u&&mt(u,d)},[n,d]);let I=O(()=>{if(H.current)return;let r=y.current;if(!r)return;let t=ct(r),b=t.length>0&&t[0]!==t[0].toUpperCase()?t[0].toUpperCase()+t.slice(1):t;R(b)},[R]),L=O(()=>{q.current=performance.now(),I();let r=y.current;r&&A(ut(r))},[I,A]);Oe(()=>{let r=y.current;if(!r)return;let t=u=>{let b=u,g=b.inputType;if(g==="insertParagraph"||g==="insertLineBreak"||g==="insertFromDrop"){u.preventDefault();return}if(g.startsWith("insert")||g.startsWith("delete")){let i=g.startsWith("delete")?"":b.data??"";X(i)&&u.preventDefault()}};return r.addEventListener("beforeinput",t),()=>r.removeEventListener("beforeinput",t)},[X]);let z=O(()=>{H.current=!0},[]),G=O(()=>{H.current=!1,I()},[I]),h=O(r=>{r.preventDefault();let t=y.current;if(!t)return;let u=(r.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let b=t.ownerDocument??document,g=b.getSelection();if(!g||g.rangeCount===0)return;let i=g.getRangeAt(0);if(!t.contains(i.startContainer))return;i.deleteContents();let Y=b.createTextNode(u);i.insertNode(Y),i.setStartAfter(Y),i.collapse(!0),g.removeAllRanges(),g.addRange(i),I()},[I]),P=O(r=>C(r),[C]),B=O(()=>E(!0),[E]),$=O(()=>E(!1),[E]),F=O(()=>y.current?.focus(),[]),K=O(()=>y.current?.blur(),[]),W=O(()=>{let r=y.current;return r?ct(r):""},[]),j=aa()?"plaintext-only":"true";return{inputRef:y,editorProps:{ref:y,contentEditable:j,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":v,"aria-expanded":f,"aria-activedescendant":_,spellCheck:!0,enterKeyHint:"send",onInput:L,onKeyDown:P,onCompositionStart:z,onCompositionEnd:G,onPaste:h,onFocus:B,onBlur:$},getPlainText:W,focus:F,blur:K}}import{jsx as ce,jsxs as Ke}from"react/jsx-runtime";function da(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var pa=oa(function({onSubmit:s,onError:a,optionOverrides:n,maskCompletedText:d,className:l,apiConfig:o,columns:m,pillPlacement:f="dropdown",mode:v="auto",optionsPosition:_="below",animations:x=!0,dropdownTrigger:R,closeDropdownOnBlur:C,showNonTappableOptions:A,showSkipButton:U,autoFocus:T=!0,onFocus:X,onBlur:E,value:y,completedParams:H,onChange:c,onParamsChange:Z,products:V,onProductSelect:q,submitButton:I},L){let z=be(null),G=be(null),h=be(()=>{}),P=be(null),B=be(null);gt(()=>{let w=z.current;if(w)return P.current?P.current.setMode(v):P.current=new sa(w,v),()=>{P.current?.destroy(),P.current=null}},[v]);let $=Ge(w=>{let te=B.current?.current;te&&(te.focus(),la(te,w))},[]),{completedParams:F,skippedParams:K,suggestionPills:W,setActivePill:j,skipActivePill:r,segments:t,newParamId:u,clearNewParamId:b,placeholderText:g,isFocused:i,isDropdownOpen:Y,isActivePillSelected:re,isLoading:ne,activeIndex:ve,listboxId:se,handleTextChange:Ce,handleKeyDown:ee,setFocused:ue,editingParam:xe,editingAnchor:Ee,caretOffset:we,startEditingParam:p,handleCaretAfterInput:S,handleCaretMove:k,replaceEditingRange:de,dropdownProps:me,reset:ye}=Ne({onSubmit:w=>h.current(w),onError:a,optionOverrides:n,maskCompletedText:d,apiConfig:o,columns:m,dropdownTrigger:R,optionsPosition:_,closeDropdownOnBlur:C,showNonTappableOptions:A,showSkipButton:U,onFocus:X,onBlur:E,value:y,completedParams:H,onChange:c,onParamsChange:Z,products:V,onProductSelect:q,source:"full-sdk",setCursor:$});gt(()=>{if(!u)return;let w=window.setTimeout(()=>b(),650);return()=>window.clearTimeout(w)},[u,b]);let ft=ve>=0?`${se}-option-${ve}`:void 0,{inputRef:De,editorProps:bt,focus:ke,blur:We,getPlainText:Ue}=ht({segments:t,newParamId:u,editingParam:xe,editingAnchor:Ee,caretOffset:we,placeholderText:g,isFocused:i,isDropdownOpen:Y,listboxId:se,activeDescendantId:ft,autoFocus:T,handleTextChange:Ce,handleKeyDown:ee,handleCaretAfterInput:S,handleCaretMove:k,startEditingParam:p,replaceEditingRange:de,setFocused:ue});B.current=De,ra(()=>{let w=G.current,te=De.current;if(!w||!te)return;let Ve=()=>{let $e=w.firstElementChild;if(!$e)return;let yt=$e.getBoundingClientRect(),kt=te.getBoundingClientRect();yt.top>=kt.bottom-2?w.setAttribute("data-aia-pill-wrapped",""):w.removeAttribute("data-aia-pill-wrapped")};Ve();let qe=new ResizeObserver(Ve);return qe.observe(te),()=>qe.disconnect()},[t,W.length,ne,De]),ia(L,()=>({focus:ke,blur:We,reset:ye,setMode:w=>P.current?.setMode(w),skipActivePill:r}),[ke,We,ye,r]);let _e=!!t.length||F.length>0,Re=Ge(()=>{if(!_e)return;let w=Ue();s(na(w,F,K)),ye()},[_e,F,K,s,ye,Ue]);h.current=Re;let vt=Ge(w=>{w.target?.closest("[data-aia-pill]")||ke()},[ke]),xt=f==="inline",wt=f==="dropdown";return Ke("div",{ref:z,className:`magicx-aia ${le.container} ${l??""}`,"data-pill-placement":f,"data-options-position":_,"data-animations":x?"on":"off","data-mode":da(v),children:[ce(Fe,{...me,showPills:wt}),Ke("div",{className:le.inputWrapper,onClick:vt,children:[Ke("div",{className:le.editorArea,"data-aia-editor":"",children:[ce("div",{...bt,className:le.input,"data-aia-input":""}),xt&&(ne||W.length>0)&&ce("span",{ref:G,className:le.pillListContainer,"data-aia-pill-list-container":"",children:ce(Ie,{pills:W,activePillIndex:0,activeSelected:re,onSelectPill:j,loading:ne})})]}),I===null?null:I===void 0?ce(st,{disabled:!_e,onClick:Re}):ce("span",{"data-aia-submit":"",className:le.submitSlot,onClick:w=>{_e&&(w.stopPropagation(),Re())},children:I})]})]})});export{pa as AIAutocomplete,Fe as AIAutocompleteDropdown,Go as buildSubmitResult,Ne as useAIAutocomplete,Ko as withSkippedParams};
1511
+ `,document.head.appendChild(e)}var st={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ne}from"react/jsx-runtime";function lt({disabled:e,onClick:n}){return Ne("button",{type:"button","data-aia-submit":"",className:st.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),n()},"aria-label":"Submit",children:Ne("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Ne("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Zt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as ct,useEffect as be,useRef as R,useState as Yt}from"react";import{useRef as dt}from"react";function pt(e){let n=dt(e);n.current=e;let t=dt(null);t.current===null&&(t.current={fetch:(l,i)=>{let a=n.current;return a?a.fetch(l,i):Promise.reject(new Error("products config removed"))},transform:l=>n.current?.transform(l)??[],get limit(){return n.current?.limit}});let r=e!==void 0;return{config:r?t.current:void 0,enabled:r}}var ea={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 Oe({onSubmit:e,onError:n,optionOverrides:t,maskCompletedText:r,apiConfig:l,additionalContext:i,columns:a=2,dropdownTrigger:h,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:w,showSkipButton:v,onFocus:T,onBlur:V,value:A,completedParams:C,onChange:F,onParamsChange:q,products:L,onProductSelect:y,source:$,setCursor:G}){let m=R(null),[ee,j]=Yt(null),E=R(e);E.current=e;let D=R(n);D.current=n;let K=R(F);K.current=F;let W=R(q);W.current=q;let g=R(T);g.current=T;let z=R(V);z.current=V;let I=R(G);I.current=G;let Q=R(y);Q.current=y;let M=pt(L);be(()=>{if(typeof document>"u")return;let d=new Zt(document.createElement("div"),{renderMode:"headless",apiConfig:l,additionalContext:i,optionOverrides:t,maskCompletedText:r,columns:a,dropdownTrigger:h,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:w,source:$,value:A,completedParams:C,onSubmit:(...P)=>E.current?.(...P),onError:(...P)=>D.current?.(...P),onChange:(...P)=>K.current?.(...P),onParamsChange:(...P)=>W.current?.(...P),onFocus:()=>g.current?.(),onBlur:()=>z.current?.(),onProductSelect:P=>Q.current?.(P),setCursor:P=>I.current?.(P),products:M.config});m.current=d,j(d.getState());let S=d.subscribe(P=>j(P));return()=>{S(),d.destroy(),m.current===d&&(m.current=null)}},[]),be(()=>{A!==void 0&&m.current?.setValue(A)},[A]),be(()=>{C!==void 0&&m.current?.setCompletedParams(C)},[C]);let J=JSON.stringify(l??null),U;try{U=JSON.stringify(i??null)}catch{U="[unstringifiable]"}let B=R(t),s=R(0);if(t!==B.current){let d=B.current,S=t,P=Object.keys(d??{}),pe=Object.keys(S??{});(P.length!==pe.length||pe.some(ae=>!d?.[ae]||S[ae]!==d[ae]))&&s.current++,B.current=t}be(()=>{m.current?.update({apiConfig:l,additionalContext:i,optionOverrides:t,dropdownTrigger:h,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:w})},[J,U,s.current,h,b,x,w]);let p=R(!1);be(()=>{if(!p.current){p.current=!0;return}m.current?.update({products:M.config})},[M.enabled]);let u=R(null);u.current===null&&(u.current={handleTextChange:d=>m.current?.handleTextChange(d),handleKeyDown:d=>{let S="nativeEvent"in d?d.nativeEvent:d;m.current?.handleKeyDown(S)},setFocused:d=>m.current?.setFocused(d),startEditingParam:d=>m.current?.startEditingParam(d),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:d=>m.current?.handleCaretAfterInput(d),handleCaretMove:d=>m.current?.handleCaretMove(d),replaceEditingRange:d=>m.current?.replaceEditingRange(d)??!1,setActivePill:d=>m.current?.setActivePill(d),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),selectOption:d=>m.current?.selectOption(d),selectProduct:d=>m.current?.selectProduct(d),setActiveDropdownIndex:d=>m.current?.setActiveDropdownIndex(d),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let o=u.current,f=ct(d=>{let S=d.target.value,pe=S.length>0&&!d.nativeEvent?.isComposing&&S[0]!==S[0].toUpperCase()?S[0].toUpperCase()+S.slice(1):S;m.current?.handleTextChange(pe)},[]),_=ct(d=>{m.current?.handleKeyDown(d.nativeEvent)},[]),X=m.current,c=ee??ea,xe=A!==void 0?A:c.text,me=C!==void 0?C:c.completedParams,le=c.actionableSuggestions,we=le[0],de=X?.listboxId??"",Ee=c.activeDropdownIndex>=0&&X?`${de}-option-${c.activeDropdownIndex}`:void 0,te=c.editingParam,he=te?{type:te.suggestionType,text:te.suggestionPlaceholder,required:!0,options:te.options}:null,ye=he??we,De=he?[he]:le,ke=!X||c.isLoading&&!c.editingParam&&!c.inSelectionAnimation;return{completedParams:me,skippedParams:c.skippedParams,suggestionPills:le,setActivePill:o.setActivePill,skipActivePill:o.skipActivePill,removeLastParam:o.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:o.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:ke,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:de,error:c.error,products:c.products,selectProduct:o.selectProduct,handleTextChange:o.handleTextChange,handleKeyDown:o.handleKeyDown,setFocused:o.setFocused,editingParam:te,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:o.startEditingParam,exitEditMode:o.exitEditMode,handleCaretAfterInput:o.handleCaretAfterInput,handleCaretMove:o.handleCaretMove,replaceEditingRange:o.replaceEditingRange,inputProps:{value:xe,placeholder:c.placeholderText||void 0,onChange:f,onKeyDown:_,onFocus:o.handleFocus,onBlur:o.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":Ee,"aria-autocomplete":"list","aria-controls":de},reset:o.reset,dropdownProps:{suggestions:ye?[{...ye,options:c.filteredOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:o.selectOption,onHighlight:o.setActiveDropdownIndex,isOpen:c.isDropdownOpen,id:de,pills:De,activeSelected:c.isActivePillSelected,onPillClick:o.setActivePill,onSkip:o.skipActivePill,showSkipButton:(v??!0)&&!te,skipDisabled:c.inSelectionAnimation,isLoading:ke,isInputEmpty:xe.trim().length===0,products:c.products,onProductSelect:o.selectProduct,onProductFocusChange:o.setFocused,optionsPosition:b??"below"}}}import{extractPlainText as ut,getCursorOffset as mt,plainTextLength as ta,renderEditableContent as aa,setCursorOffset as ht}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as H,useEffect as He,useLayoutEffect as Ge,useRef as ce}from"react";var Ce;function oa(){if(Ce!==void 0)return Ce;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ce=e.contentEditable==="plaintext-only",Ce}function gt(e){let{segments:n,newParamId:t,editingParam:r,editingAnchor:l,caretOffset:i,placeholderText:a,isFocused:h,isDropdownOpen:b,listboxId:x,activeDescendantId:w,autoFocus:v,handleTextChange:T,handleKeyDown:V,handleCaretAfterInput:A,handleCaretMove:C,startEditingParam:F,replaceEditingRange:q,setFocused:L}=e,y=ce(null),$=ce(!1),G=ce(""),m=ce(""),ee=ce(null),j=ce(0);ee.current=i,He(()=>{if(!v)return;let s=y.current;if(!s)return;document.activeElement===s?L(!0):s.focus();let p=s.ownerDocument??document,u=p.getSelection(),o=u&&u.rangeCount>0&&s.contains(u.anchorNode);if(u&&!o){let f=p.createRange();f.selectNodeContents(s),f.collapse(!0),u.removeAllRanges(),u.addRange(f)}},[v,L]),He(()=>{let s=y.current;if(!s)return;let p=s.ownerDocument??document,u=()=>{let o=p.getSelection();if(!o||o.rangeCount===0||!o.anchorNode||!s.contains(o.anchorNode))return;let f=o.anchorNode,_=f.nodeType===Node.ELEMENT_NODE?f:f.parentElement,c=(o.isCollapsed?_?.closest('strong[data-seg="completed"][data-param-id]'):null)?.dataset.paramId??null;if(c&&c!==r?.id){F(c);return}performance.now()-j.current<50||C(mt(s))};return p.addEventListener("selectionchange",u),()=>p.removeEventListener("selectionchange",u)},[r,F,C]),Ge(()=>{let s=y.current;s&&aa({input:s,segments:n,newParamId:t,editingParamId:r?.id??null,placeholderText:a??"",isFocused:h})},[n,t,r,a,h]),Ge(()=>{let s=G.current,p=t??"";if(G.current=p,!p||p===s)return;let u=y.current;if(!u)return;u.focus();let o=ee.current??ta(u);ht(u,o)},[t]),Ge(()=>{let s=m.current,p=r?.id??"";if(m.current=p,!p||p===s||l==null)return;let u=y.current;u&&ht(u,l)},[r,l]);let E=H(()=>{if($.current)return;let s=y.current;if(!s)return;let p=ut(s),o=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;T(o)},[T]),D=H(()=>{j.current=performance.now(),E();let s=y.current;s&&A(mt(s))},[E,A]);He(()=>{let s=y.current;if(!s)return;let p=u=>{let o=u,f=o.inputType;if(f==="insertParagraph"||f==="insertLineBreak"||f==="insertFromDrop"){u.preventDefault();return}if(f.startsWith("insert")||f.startsWith("delete")){let _=f.startsWith("delete")?"":o.data??"";q(_)&&u.preventDefault()}};return s.addEventListener("beforeinput",p),()=>s.removeEventListener("beforeinput",p)},[q]);let K=H(()=>{$.current=!0},[]),W=H(()=>{$.current=!1,E()},[E]),g=H(s=>{s.preventDefault();let p=y.current;if(!p)return;let u=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let o=p.ownerDocument??document,f=o.getSelection();if(!f||f.rangeCount===0)return;let _=f.getRangeAt(0);if(!p.contains(_.startContainer))return;_.deleteContents();let X=o.createTextNode(u);_.insertNode(X),_.setStartAfter(X),_.collapse(!0),f.removeAllRanges(),f.addRange(_),E()},[E]),z=H(s=>V(s),[V]),I=H(()=>L(!0),[L]),Q=H(()=>L(!1),[L]),M=H(()=>y.current?.focus(),[]),J=H(()=>y.current?.blur(),[]),U=H(()=>{let s=y.current;return s?ut(s):""},[]),B=oa()?"plaintext-only":"true";return{inputRef:y,editorProps:{ref:y,contentEditable:B,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":x,"aria-expanded":b,"aria-activedescendant":w,spellCheck:!0,enterKeyHint:"send",onInput:D,onKeyDown:z,onCompositionStart:K,onCompositionEnd:W,onPaste:g,onFocus:I,onBlur:Q},getPlainText:U,focus:M,blur:J}}import{jsx as ue,jsxs as We}from"react/jsx-runtime";function pa(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ca=ia(function({onSubmit:n,onError:t,optionOverrides:r,maskCompletedText:l,className:i,apiConfig:a,additionalContext:h,columns:b,pillPlacement:x="dropdown",mode:w="auto",optionsPosition:v="below",animations:T=!0,dropdownTrigger:V,closeDropdownOnBlur:A,showNonTappableOptions:C,showSkipButton:F,autoFocus:q=!0,onFocus:L,onBlur:y,value:$,completedParams:G,onChange:m,onParamsChange:ee,products:j,onProductSelect:E,submitButton:D},K){let W=ve(null),g=ve(null),z=ve(()=>{}),I=ve(null),Q=ve(null);ft(()=>{let k=W.current;if(k)return I.current?I.current.setMode(w):I.current=new la(k,w),()=>{I.current?.destroy(),I.current=null}},[w]);let M=Ke(k=>{let oe=Q.current?.current;oe&&(oe.focus(),da(oe,k))},[]),{completedParams:J,skippedParams:U,suggestionPills:B,setActivePill:s,skipActivePill:p,segments:u,newParamId:o,clearNewParamId:f,placeholderText:_,isFocused:X,isDropdownOpen:c,isActivePillSelected:xe,isLoading:me,activeIndex:le,listboxId:we,handleTextChange:de,handleKeyDown:Ee,setFocused:te,editingParam:he,editingAnchor:ye,caretOffset:De,startEditingParam:ke,handleCaretAfterInput:d,handleCaretMove:S,replaceEditingRange:P,dropdownProps:pe,reset:ae}=Oe({onSubmit:k=>z.current(k),onError:t,optionOverrides:r,maskCompletedText:l,apiConfig:a,additionalContext:h,columns:b,dropdownTrigger:V,optionsPosition:v,closeDropdownOnBlur:A,showNonTappableOptions:C,showSkipButton:F,onFocus:L,onBlur:y,value:$,completedParams:G,onChange:m,onParamsChange:ee,products:j,onProductSelect:E,source:"full-sdk",setCursor:M});ft(()=>{if(!o)return;let k=window.setTimeout(()=>f(),650);return()=>window.clearTimeout(k)},[o,f]);let bt=le>=0?`${we}-option-${le}`:void 0,{inputRef:Re,editorProps:vt,focus:_e,blur:Ue,getPlainText:Ve}=gt({segments:u,newParamId:o,editingParam:he,editingAnchor:ye,caretOffset:De,placeholderText:_,isFocused:X,isDropdownOpen:c,listboxId:we,activeDescendantId:bt,autoFocus:q,handleTextChange:de,handleKeyDown:Ee,handleCaretAfterInput:d,handleCaretMove:S,startEditingParam:ke,replaceEditingRange:P,setFocused:te});Q.current=Re,na(()=>{let k=g.current,oe=Re.current;if(!k||!oe)return;let qe=()=>{let je=k.firstElementChild;if(!je)return;let kt=je.getBoundingClientRect(),_t=oe.getBoundingClientRect();kt.top>=_t.bottom-2?k.setAttribute("data-aia-pill-wrapped",""):k.removeAttribute("data-aia-pill-wrapped")};qe();let $e=new ResizeObserver(qe);return $e.observe(oe),()=>$e.disconnect()},[u,B.length,me,Re]),ra(K,()=>({focus:_e,blur:Ue,reset:ae,setMode:k=>I.current?.setMode(k),skipActivePill:p}),[_e,Ue,ae,p]);let Pe=!!u.length||J.length>0,Te=Ke(()=>{if(!Pe)return;let k=Ve();n(sa(k,J,U)),ae()},[Pe,J,U,n,ae,Ve]);z.current=Te;let xt=Ke(k=>{k.target?.closest("[data-aia-pill]")||_e()},[_e]),wt=x==="inline",yt=x==="dropdown";return We("div",{ref:W,className:`magicx-aia ${se.container} ${i??""}`,"data-pill-placement":x,"data-options-position":v,"data-animations":T?"on":"off","data-mode":pa(w),children:[ue(Me,{...pe,showPills:yt}),We("div",{className:se.inputWrapper,onClick:xt,children:[We("div",{className:se.editorArea,"data-aia-editor":"",children:[ue("div",{...vt,className:se.input,"data-aia-input":""}),wt&&(me||B.length>0)&&ue("span",{ref:g,className:se.pillListContainer,"data-aia-pill-list-container":"",children:ue(Se,{pills:B,activePillIndex:0,activeSelected:xe,onSelectPill:s,loading:me})})]}),D===null?null:D===void 0?ue(lt,{disabled:!Pe,onClick:Te}):ue("span",{"data-aia-submit":"",className:se.submitSlot,onClick:k=>{Pe&&(k.stopPropagation(),Te())},children:D})]})]})});export{ca as AIAutocomplete,Me as AIAutocompleteDropdown,Ko as buildSubmitResult,Oe as useAIAutocomplete,Wo as withSkippedParams};
1512
1512
  //# sourceMappingURL=index.mjs.map