@magicx-eng/ai-autocomplete-react 0.14.2 → 0.15.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 _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoDate as Ai,monthLabel as Si,parseDate as Ci,parseLooseDate as Di,WEEKDAY_LABELS as Ei,withSkippedParams as Ti}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Da,useCallback as Ye,useEffect as St,useImperativeHandle as Ea,useLayoutEffect as Ta,useRef as Ie}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 Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoDate as Di,monthLabel as Ei,parseDate as Ti,parseLooseDate as Ri,WEEKDAY_LABELS as Li,withSkippedParams as Mi}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Ra,useCallback as Ze,useEffect as Et,useImperativeHandle as La,useLayoutEffect as Ma,useRef as Ae}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
@@ -193,7 +193,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
193
193
  opacity: 0;
194
194
  }
195
195
  }
196
- `,document.head.appendChild(e)}var fe={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{attachScrollArrow as ha,SCROLL_ARROW_LABEL as fa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as We,useRef as Re,useState as ga}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
196
+ `,document.head.appendChild(e)}var fe={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{attachScrollArrow as ba,SCROLL_ARROW_LABEL as va}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as $e,useRef as Me,useState as wa}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
197
197
  * Built-in appearance defaults \u2014 zero specificity via :where().
198
198
  * Consumer CSS always wins without !important.
199
199
  *
@@ -780,7 +780,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
780
780
  opacity: 0.25;
781
781
  }
782
782
  }
783
- `,document.head.appendChild(e)}var ie={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",scrollArrow:"AIAutocompleteDropdown-module_scrollArrow_uUzV0",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{cellDay as Nt,cellIso as ye,isoDate as zt,monthLabel as Ot,WEEKDAY_LABELS as Bt}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Ft}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
783
+ `,document.head.appendChild(e)}var le={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",scrollArrow:"AIAutocompleteDropdown-module_scrollArrow_uUzV0",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{cellDay as Bt,cellIso as _e,isoDate as Ft,monthLabel as Gt,WEEKDAY_LABELS as Ht}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Kt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
784
784
 
785
785
  One of three hand-maintained copies (vanilla styles.css, this file, Angular's
786
786
  date-grid.component.css). Only the class-naming layer differs \u2014 the
@@ -936,7 +936,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
936
936
  opacity: 0.8;
937
937
  background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
938
938
  }
939
- `,document.head.appendChild(e)}var S={datepicker:"DateGrid-module_datepicker_6RrTs",header:"DateGrid-module_header_z4LRk",month:"DateGrid-module_month_urB2T",nav:"DateGrid-module_nav_ap4AN",weekdays:"DateGrid-module_weekdays_3EA3q",grid:"DateGrid-module_grid_mQCgw",weekday:"DateGrid-module_weekday_3lF4B",cell:"DateGrid-module_cell_59k0y",number:"DateGrid-module_number_aoT01",day:"DateGrid-module_day_cB3u9",blank:"DateGrid-module_blank_ivgRC",past:"DateGrid-module_past_CEZsj",highlighted:"DateGrid-module_highlighted_YIdtK",today:"DateGrid-module_today_iI3ME",selected:"DateGrid-module_selected_28KDn",pressed:"DateGrid-module_pressed_bEyyN"};import{jsx as Q,jsxs as at}from"react/jsx-runtime";var Gt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ot({options:e,activeIndex:n,listboxId:t,view:i,selectedIso:s,onSelect:a,onHighlight:r,onPreviousMonth:g,onNextMonth:b}){let v=zt(new Date);return at("div",{className:S.datepicker,"data-aia-datepicker":"",children:[at("div",{className:S.header,children:[Q("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:g,children:"\u2039"}),Q("span",{className:S.month,"data-aia-date-month":"","aria-live":"polite",children:Ot(i)}),Q("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:b,children:"\u203A"})]}),Q("div",{className:S.weekdays,"aria-hidden":"true",children:Bt.map((m,x)=>Q("span",{className:S.weekday,children:m},Gt[x]))}),Q("div",{className:S.grid,"data-aia-date-grid":"",children:e.map((m,x)=>Q(Ht,{option:m,id:`${t}-option-${x}`,index:x,isHighlighted:x===n&&m.is_tappable,isToday:ye(m)===v,isPast:ye(m)!=null&&ye(m)<v,isSelected:s!=null&&ye(m)===s,onSelect:a,onHighlight:r},ye(m)??`pad-${x}`))})]})}function Ht({option:e,id:n,index:t,isHighlighted:i,isToday:s,isPast:a,isSelected:r,onSelect:g,onHighlight:b}){let[v,m]=Ft(!1),x=Nt(e);if(x==null)return Q("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${S.cell} ${S.blank}`});let k=()=>{m(!0),g(e),setTimeout(()=>m(!1),500)},w=[S.cell,S.day,a?S.past:"",i?S.highlighted:"",s?S.today:"",r?S.selected:"",v?S.pressed:""].filter(Boolean).join(" ");return Q("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:w,onClick:k,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),k())},onMouseEnter:()=>b(t),children:Q("span",{className:S.number,children:x})})}import{ATTRIBUTION_URL as Kt,buildAttributionUrl as Wt,getFooterHint as Ut}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as qt,useState as $t}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 {
939
+ `,document.head.appendChild(e)}var C={datepicker:"DateGrid-module_datepicker_6RrTs",header:"DateGrid-module_header_z4LRk",month:"DateGrid-module_month_urB2T",nav:"DateGrid-module_nav_ap4AN",weekdays:"DateGrid-module_weekdays_3EA3q",grid:"DateGrid-module_grid_mQCgw",weekday:"DateGrid-module_weekday_3lF4B",cell:"DateGrid-module_cell_59k0y",number:"DateGrid-module_number_aoT01",day:"DateGrid-module_day_cB3u9",blank:"DateGrid-module_blank_ivgRC",past:"DateGrid-module_past_CEZsj",highlighted:"DateGrid-module_highlighted_YIdtK",today:"DateGrid-module_today_iI3ME",selected:"DateGrid-module_selected_28KDn",pressed:"DateGrid-module_pressed_bEyyN"};import{jsx as V,jsxs as nt}from"react/jsx-runtime";var Wt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function rt({options:e,activeIndex:n,listboxId:a,view:o,selectedIso:l,onSelect:t,onHighlight:i,onPreviousMonth:g,onNextMonth:v}){let x=Ft(new Date);return nt("div",{className:C.datepicker,"data-aia-datepicker":"",children:[nt("div",{className:C.header,children:[V("button",{type:"button",tabIndex:-1,className:C.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:g,children:"\u2039"}),V("span",{className:C.month,"data-aia-date-month":"","aria-live":"polite",children:Gt(o)}),V("button",{type:"button",tabIndex:-1,className:C.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:v,children:"\u203A"})]}),V("div",{className:C.weekdays,"aria-hidden":"true",children:Ht.map((m,w)=>V("span",{className:C.weekday,children:m},Wt[w]))}),V("div",{className:C.grid,"data-aia-date-grid":"",children:e.map((m,w)=>V(Ut,{option:m,id:`${a}-option-${w}`,index:w,isHighlighted:w===n&&m.is_tappable,isToday:_e(m)===x,isPast:_e(m)!=null&&_e(m)<x,isSelected:l!=null&&_e(m)===l,onSelect:t,onHighlight:i},_e(m)??`pad-${w}`))})]})}function Ut({option:e,id:n,index:a,isHighlighted:o,isToday:l,isPast:t,isSelected:i,onSelect:g,onHighlight:v}){let[x,m]=Kt(!1),w=Bt(e);if(w==null)return V("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${C.cell} ${C.blank}`});let k=()=>{m(!0),g(e),setTimeout(()=>m(!1),500)},y=[C.cell,C.day,t?C.past:"",o?C.highlighted:"",l?C.today:"",i?C.selected:"",x?C.pressed:""].filter(Boolean).join(" ");return V("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":o,"aria-label":e.text,tabIndex:0,className:y,onClick:k,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),k())},onMouseEnter:()=>v(a),children:V("span",{className:C.number,children:w})})}import{ATTRIBUTION_URL as qt,buildAttributionUrl as $t,getFooterHint as jt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Vt,useState as Yt}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 {
940
940
  .aia-cluster {
941
941
  display: flex;
942
942
  flex-wrap: wrap;
@@ -978,7 +978,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
978
978
  justify-content: space-around;
979
979
  }
980
980
  }
981
- `,document.head.appendChild(e)}import{jsx as it}from"react/jsx-runtime";function _e({gap:e,align:n="center",justify:t="start",noWrap:i=!1,inline:s=!1,className:a,children:r,...g}){let b=e?{"--aia-cluster-gap":e}:void 0,v={className:a?`aia-cluster ${a}`:"aia-cluster","data-align":n,"data-justify":t,"data-nowrap":i||void 0,"data-inline":s||void 0,style:b,...g};return s?it("span",{...v,children:r}):it("div",{...v,children:r})}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
981
+ `,document.head.appendChild(e)}import{jsx as st}from"react/jsx-runtime";function ke({gap:e,align:n="center",justify:a="start",noWrap:o=!1,inline:l=!1,className:t,children:i,...g}){let v=e?{"--aia-cluster-gap":e}:void 0,x={className:t?`aia-cluster ${t}`:"aia-cluster","data-align":n,"data-justify":a,"data-nowrap":o||void 0,"data-inline":l||void 0,style:v,...g};return l?st("span",{...x,children:i}):st("div",{...x,children:i})}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
982
982
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
983
983
  room above the hint/branding row so the footer doesn't butt against the last
984
984
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -1112,7 +1112,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
1112
1112
  justify-content: flex-end;
1113
1113
  }
1114
1114
  }
1115
- `,document.head.appendChild(e)}var ne={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 ke,jsxs as Oe}from"react/jsx-runtime";function nt({isOptionHighlighted:e=!1,isInputEmpty:n=!1}){let{key:t,hint:i}=Ut(e,n),[s,a]=$t(Kt);return qt(()=>{a(Wt())},[]),ke("footer",{className:ne.footer,"data-aia-footer":"",children:Oe(_e,{justify:"between",noWrap:!0,className:ne.row,children:[Oe(_e,{gap:"5px",className:ne.hintGroup,children:[ke("kbd",{className:ne.key,children:t}),ke("span",{className:ne.hint,children:i})]}),Oe("a",{className:ne.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[ke("span",{className:ne.brand,children:"AI"}),ke("span",{className:ne.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,
1115
+ `,document.head.appendChild(e)}var de={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 Pe,jsxs as Ge}from"react/jsx-runtime";function lt({isOptionHighlighted:e=!1,isInputEmpty:n=!1}){let{key:a,hint:o}=jt(e,n),[l,t]=Yt(qt);return Vt(()=>{t($t())},[]),Pe("footer",{className:de.footer,"data-aia-footer":"",children:Ge(ke,{justify:"between",noWrap:!0,className:de.row,children:[Ge(ke,{gap:"5px",className:de.hintGroup,children:[Pe("kbd",{className:de.key,children:a}),Pe("span",{className:de.hint,children:o})]}),Ge("a",{className:de.brandLink,href:l,target:"_blank",rel:"noopener noreferrer",children:[Pe("span",{className:de.brand,children:"AI"}),Pe("span",{className:de.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
1116
1116
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
1117
1117
  The border is kept as a 1px transparent line so the box stays the same size
1118
1118
  as it was when the outline was dashed. */
@@ -1169,7 +1169,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
1169
1169
  opacity: 0;
1170
1170
  }
1171
1171
  }
1172
- `,document.head.appendChild(e)}var ue={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 jt}from"react/jsx-runtime";var Be={selected:1,first:.7,next:.4,last:.2};function rt({label:e,state:n,rounded:t,loading:i,onClick:s}){let a=[ue.pill,t?ue.rounded:"",i?ue.skeleton:""].filter(Boolean).join(" ");return jt("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:a,style:{opacity:Be[n]},onMouseDown:r=>r.preventDefault(),onClick:i?void 0:s,disabled:i,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.PillList-module_list_qvLqO {
1172
+ `,document.head.appendChild(e)}var pe={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 Qt}from"react/jsx-runtime";var He={selected:1,first:.7,next:.4,last:.2};function dt({label:e,state:n,rounded:a,loading:o,onClick:l}){let t=[pe.pill,a?pe.rounded:"",o?pe.skeleton:""].filter(Boolean).join(" ");return Qt("button",{type:"button","data-aia-pill":"","data-aia-loading":o?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:t,style:{opacity:He[n]},onMouseDown:i=>i.preventDefault(),onClick:o?void 0:l,disabled:o,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 {
1173
1173
  position: relative;
1174
1174
  z-index: 1;
1175
1175
  pointer-events: auto;
@@ -1179,7 +1179,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
1179
1179
  align-items: center;
1180
1180
  vertical-align: middle;
1181
1181
  }
1182
- `,document.head.appendChild(e)}var Fe={list:"PillList-module_list_qvLqO"};import{jsx as Ee}from"react/jsx-runtime";var Vt=[125,69];function st(e){return e===0?"first":e===1?"next":"last"}function Te({pills:e,activePillIndex:n,onSelectPill:t,activeSelected:i,rounded:s,loading:a}){return a&&e.length===0?Ee("span",{className:Fe.list,"data-aia-pill-list-loading":"",children:Vt.map((r,g)=>Ee("span",{"data-aia-pill-skeleton":"",className:`${ue.pill} ${s?ue.rounded:""} ${ue.skeleton}`,style:{width:r,opacity:Be[st(g)]}},`skel-${r}`))}):Ee("span",{className:Fe.list,"data-aia-pill-list-loading":a?"":void 0,children:e.map((r,g)=>{let b=!!i&&g===n;return Ee(rt,{label:r.text,state:b?"selected":st(g),selected:b,rounded:s,loading:a,onClick:()=>t(g)},`${r.type}-${r.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
1182
+ `,document.head.appendChild(e)}var Ke={list:"PillList-module_list_qvLqO"};import{jsx as Re}from"react/jsx-runtime";var Xt=[125,69];function ct(e){return e===0?"first":e===1?"next":"last"}function Le({pills:e,activePillIndex:n,onSelectPill:a,activeSelected:o,rounded:l,loading:t}){return t&&e.length===0?Re("span",{className:Ke.list,"data-aia-pill-list-loading":"",children:Xt.map((i,g)=>Re("span",{"data-aia-pill-skeleton":"",className:`${pe.pill} ${l?pe.rounded:""} ${pe.skeleton}`,style:{width:i,opacity:He[ct(g)]}},`skel-${i}`))}):Re("span",{className:Ke.list,"data-aia-pill-list-loading":t?"":void 0,children:e.map((i,g)=>{let v=!!o&&g===n;return Re(dt,{label:i.text,state:v?"selected":ct(g),selected:v,rounded:l,loading:t,onClick:()=>a(g)},`${i.type}-${i.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
1183
1183
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
1184
1184
  theming one package sees the same result in the other.
1185
1185
 
@@ -1346,7 +1346,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
1346
1346
  var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
1347
1347
  );
1348
1348
  }
1349
- `,document.head.appendChild(e)}var W={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 me,jsxs as Ge}from"react/jsx-runtime";function lt({products:e,listboxId:n,onSelect:t,onFocusChange:i,focusable:s=!0}){if(e.length===0)return null;let a=`${n}-products-label`;return Ge("section",{className:W.section,"data-aia-products":"",role:"group","aria-labelledby":a,children:[me("div",{className:W.label,id:a,children:"Products"}),me("div",{className:W.row,"data-aia-products-row":"",children:e.map((r,g)=>me(Yt,{product:r,id:`${n}-product-${g}`,onSelect:t,onFocusChange:i,focusable:s},r.id))})]})}function Yt({product:e,id:n,onSelect:t,onFocusChange:i,focusable:s}){let a=r=>{r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||r.button!==0||(r.preventDefault(),t(e))};return Ge("a",{id:n,className:W.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:a,onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:r=>{r.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[me("span",{className:W.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?me("img",{className:W.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Ge("span",{className:W.body,children:[e.vendor?me("span",{className:W.vendor,children:e.vendor}):null,me("span",{className:W.title,children:e.title}),e.price?me("span",{className:W.price,children:e.price}):null]})]})}import{isOptionsGridMobileViewport as ia,measureOptionsGrid as na,needsOptionsGridMeasurement as ra,OPTIONS_GRID_MOBILE_QUERY as sa,optionEnterDelayMs as la,planOptionsGrid as ut}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as da,useLayoutEffect as ca,useRef as pa,useState as ht}from"react";import{optionsGridTemplateColumns as Qt}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Xt,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 {
1349
+ `,document.head.appendChild(e)}var W={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 ue,jsxs as We}from"react/jsx-runtime";function pt({products:e,listboxId:n,onSelect:a,onFocusChange:o,focusable:l=!0}){if(e.length===0)return null;let t=`${n}-products-label`;return We("section",{className:W.section,"data-aia-products":"",role:"group","aria-labelledby":t,children:[ue("div",{className:W.label,id:t,children:"Products"}),ue("div",{className:W.row,"data-aia-products-row":"",children:e.map((i,g)=>ue(Zt,{product:i,id:`${n}-product-${g}`,onSelect:a,onFocusChange:o,focusable:l},i.id))})]})}function Zt({product:e,id:n,onSelect:a,onFocusChange:o,focusable:l}){let t=i=>{i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||i.button!==0||(i.preventDefault(),a(e))};return We("a",{id:n,className:W.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:l?0:-1,onClick:t,onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),a(e))},onFocus:()=>o?.(!0),onBlur:i=>{i.relatedTarget?.closest("[data-aia-dropdown]")||o?.(!1)},children:[ue("span",{className:W.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?ue("img",{className:W.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),We("span",{className:W.body,children:[e.vendor?ue("span",{className:W.vendor,children:e.vendor}):null,ue("span",{className:W.title,children:e.title}),e.price?ue("span",{className:W.price,children:e.price}):null]})]})}import{isOptionsGridMobileViewport as sa,measureOptionsGrid as la,needsOptionsGridMeasurement as da,OPTIONS_GRID_MOBILE_QUERY as ca,optionEnterDelayMs as pa,planOptionsGrid as ft}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ua,useLayoutEffect as ma,useRef as ha,useState as bt}from"react";import{optionsGridTemplateColumns as Jt}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as ea,useRef as ta}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 {
1350
1350
  .aia-grid {
1351
1351
  display: grid;
1352
1352
  grid-template-columns: repeat(
@@ -1381,7 +1381,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
1381
1381
  border-radius: 3px;
1382
1382
  }
1383
1383
  }
1384
- `,document.head.appendChild(e)}import{jsx as Jt}from"react/jsx-runtime";function dt({min:e="16rem",max:n,gap:t,scroll:i=!1,maxHeight:s,scrollResetKey:a,cols:r,template:g,innerRef:b,className:v,children:m,...x}){let k=Zt(null);Xt(()=>{if(a===void 0)return;let f=k.current;f&&(f.scrollTop=0)},[a]);let w={"--aia-grid-min":e};return n&&(w["--aia-grid-max"]=n),t&&(w["--aia-grid-gap"]=t),s&&(w["--aia-grid-max-height"]=s),r&&(w.gridTemplateColumns=Qt(r)),g&&(w.gridTemplateColumns=g),Jt("div",{ref:f=>{k.current=f,b?.(f)},className:v?`aia-grid ${v}`:"aia-grid","data-scroll":i||void 0,style:w,...x,children:m})}import{OPTION_ENTER_DELAY_VAR as ea}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ta,useRef as aa,useState as ct}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 {
1384
+ `,document.head.appendChild(e)}import{jsx as aa}from"react/jsx-runtime";function ut({min:e="16rem",max:n,gap:a,scroll:o=!1,maxHeight:l,scrollResetKey:t,cols:i,template:g,innerRef:v,className:x,children:m,...w}){let k=ta(null);ea(()=>{if(t===void 0)return;let b=k.current;b&&(b.scrollTop=0)},[t]);let y={"--aia-grid-min":e};return n&&(y["--aia-grid-max"]=n),a&&(y["--aia-grid-gap"]=a),l&&(y["--aia-grid-max-height"]=l),i&&(y.gridTemplateColumns=Jt(i)),g&&(y.gridTemplateColumns=g),aa("div",{ref:b=>{k.current=b,v?.(b)},className:x?`aia-grid ${x}`:"aia-grid","data-scroll":o||void 0,style:y,...w,children:m})}import{OPTION_ENTER_DELAY_VAR as oa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ia,useRef as na,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 {
1385
1385
  position: relative;
1386
1386
  overflow: visible;
1387
1387
  display: flex;
@@ -1528,7 +1528,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
1528
1528
  filter: brightness(0.55);
1529
1529
  }
1530
1530
  }
1531
- `,document.head.appendChild(e)}var X={item:"SuggestionItem-module_item_d4vpD",fadeIn:"SuggestionItem-module_fadeIn_I8u35",riseIn:"SuggestionItem-module_riseIn_etXZT",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",pressCompress:"SuggestionItem-module_pressCompress_ICV3q",scrollHint:"SuggestionItem-module_scrollHint_xKXPt",skeletonPulse:"SuggestionItem-module_skeletonPulse_plvdD",text:"SuggestionItem-module_text_yqoh9"};import{jsx as He,jsxs as oa}from"react/jsx-runtime";function pt({option:e,isHighlighted:n,onSelect:t,onHighlight:i,id:s,loading:a,scrollHint:r,enterDelayMs:g=0}){let[b]=ct(g),[v,m]=ct(!1),x=aa(void 0);ta(()=>()=>clearTimeout(x.current),[]);let k=()=>{a||!e.is_tappable||v||(m(!0),t(e),clearTimeout(x.current),x.current=setTimeout(()=>m(!1),500))},w=[X.item,n&&!a?X.highlighted:"",e.is_tappable?X.tappable:X.nonTappable,v?X.pressed:"",r?X.scrollHint:""].filter(Boolean).join(" ");return He("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"aria-selected":n,className:w,style:{[ea]:`${b}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:k,onKeyDown:f=>{!a&&e.is_tappable&&(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),k())},onMouseEnter:!a&&e.is_tappable?i:void 0,children:oa("span",{className:X.content,children:[He("span",{className:X.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&He("span",{className:X.tag,children:e.tag})]})})}import{jsx as mt}from"react/jsx-runtime";function ua(){let[e,n]=ht(ia);return da(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(sa),i=()=>n(t.matches);return i(),t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function ft({options:e,activeIndex:n,onSelect:t,onHighlight:i,listboxId:s,loading:a,groupKey:r="",optionsPosition:g="below"}){let b=ua(),v=pa(null),[m,x]=ht(null);ca(()=>{let w=v.current,D=w&&!a&&ra(e.length,b)?na(w):null;x(D?ut(e.length,b,D.rowWidths,D.gridWidth):null)},[e,b,a]);let k=m??ut(e.length,b,null,null);return mt(dt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:r,template:k.template,maxHeight:k.maxHeight,innerRef:w=>{v.current=w},"data-aia-group":r,children:e.map((w,f)=>mt(pt,{option:w,isHighlighted:f===n,onSelect:t,onHighlight:()=>i(f),id:`${s}-option-${f}`,loading:a,scrollHint:!a&&k.scrollHintIndices.includes(f),enterDelayMs:a?0:la(f,k.cols,e.length,g)},`${r}\0${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 {
1531
+ `,document.head.appendChild(e)}var Y={item:"SuggestionItem-module_item_d4vpD",fadeIn:"SuggestionItem-module_fadeIn_I8u35",riseIn:"SuggestionItem-module_riseIn_etXZT",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",pressCompress:"SuggestionItem-module_pressCompress_ICV3q",scrollHint:"SuggestionItem-module_scrollHint_xKXPt",skeletonPulse:"SuggestionItem-module_skeletonPulse_plvdD",text:"SuggestionItem-module_text_yqoh9"};import{jsx as Ue,jsxs as ra}from"react/jsx-runtime";function ht({option:e,isHighlighted:n,onSelect:a,onHighlight:o,id:l,loading:t,scrollHint:i,enterDelayMs:g=0}){let[v]=mt(g),[x,m]=mt(!1),w=na(void 0);ia(()=>()=>clearTimeout(w.current),[]);let k=()=>{t||!e.is_tappable||x||(m(!0),a(e),clearTimeout(w.current),w.current=setTimeout(()=>m(!1),500))},y=[Y.item,n&&!t?Y.highlighted:"",e.is_tappable?Y.tappable:Y.nonTappable,x?Y.pressed:"",i?Y.scrollHint:""].filter(Boolean).join(" ");return Ue("div",{id:l,role:"option","data-aia-option":"","data-aia-loading":t?"":void 0,"aria-selected":n,className:y,style:{[oa]:`${v}ms`},tabIndex:t||!e.is_tappable?-1:0,onClick:k,onKeyDown:b=>{!t&&e.is_tappable&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),k())},onMouseEnter:!t&&e.is_tappable?o:void 0,children:ra("span",{className:Y.content,children:[Ue("span",{className:Y.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&Ue("span",{className:Y.tag,children:e.tag})]})})}import{jsx as gt}from"react/jsx-runtime";function fa(){let[e,n]=bt(sa);return ua(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(ca),o=()=>n(a.matches);return o(),a.addEventListener("change",o),()=>a.removeEventListener("change",o)},[]),e}function vt({options:e,activeIndex:n,onSelect:a,onHighlight:o,listboxId:l,loading:t,groupKey:i="",optionsPosition:g="below"}){let v=fa(),x=ha(null),[m,w]=bt(null);ma(()=>{let y=x.current,D=y&&!t&&da(e.length,v)?la(y):null;w(D?ft(e.length,v,D.rowWidths,D.gridWidth):null)},[e,v,t]);let k=m??ft(e.length,v,null,null);return gt(ut,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:i,template:k.template,maxHeight:k.maxHeight,innerRef:y=>{x.current=y},"data-aia-group":i,children:e.map((y,b)=>gt(ht,{option:y,isHighlighted:b===n,onSelect:a,onHighlight:()=>o(b),id:`${l}-option-${b}`,loading:t,scrollHint:!t&&k.scrollHintIndices.includes(b),enterDelayMs:t?0:pa(b,k.cols,e.length,g)},`${i}\0${y.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
1532
1532
  .aia-stack {
1533
1533
  display: flex;
1534
1534
  flex-direction: column;
@@ -1545,7 +1545,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
1545
1545
  }
1546
1546
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
1547
1547
  }
1548
- `,document.head.appendChild(e)}import{jsx as ma}from"react/jsx-runtime";function gt({space:e,align:n="stretch",className:t,children:i,...s}){let a=e?{"--aia-stack-space":e}:void 0;return ma("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":n,style:a,...s,children:i})}import{jsx as O,jsxs as Ke}from"react/jsx-runtime";var ba=[159,119,164],va=()=>{},bt=()=>{};function wa(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,i]=ga(n);if(We(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>i(s.matches);return s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function xa(e,n){let t=Re(null);We(()=>{let i=e.current,s=n.current;if(!i||!s)return;let a=i.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==a&&(t.current.controller.destroy(),t.current=null),a&&!t.current){t.current={grid:a,controller:ha({dropdown:i,grid:a,button:s})};return}t.current?.controller.update()}),We(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Ue({suggestions:e,activeIndex:n,onSelect:t,onHighlight:i,isOpen:s,id:a,className:r,pills:g,onPillClick:b,showPills:v=!0,onSkip:m,showSkipButton:x=!0,skipDisabled:k=!1,activeSelected:w=!1,isLoading:f=!1,isInputEmpty:D=!1,products:B,onProductSelect:Z,onProductFocusChange:re,formatType:L="options",dateView:I=null,selectedDateIso:q=null,onPreviousMonth:h,onNextMonth:se,optionsPosition:$="below",mode:J}){let E=wa(J),le=E!==void 0,j=Re(null),V=Re(null);xa(j,V);let ee=e[0]?.options??[],M=!!(g&&g.length>0&&b),te=!!(B&&B.length>0),z=s&&(ee.length>0||v&&M||f||te),F={suggestions:e,activeIndex:n,pills:g,showPills:v,showSkipButton:x,skipDisabled:k,activeSelected:w,isLoading:f,isInputEmpty:D,products:B,formatType:L,dateView:I,selectedDateIso:q},G=Re(F);z&&(G.current=F);let p=z?F:G.current,H=p.suggestions[0],l=H?.options??[],u=p.activeIndex>=0&&!!l[p.activeIndex]?.is_tappable,o=!!(p.pills&&p.pills.length>0&&b),_=p.showPills&&o,y=p.showPills&&!o&&p.isLoading,A=_||y,d=o&&p.showSkipButton&&!p.isInputEmpty&&!!m,K=p.pills?.[0]?.text,Y=p.formatType==="date"&&p.dateView!=null,ae=l.length>0&&!Y,he=l.length>0&&Y,de=p.isLoading&&!ae&&!he,ge=p.products??[];return Ke("div",{ref:j,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":$,"data-mode":E,"data-aia-loading":p.isLoading?"":void 0,"data-aia-has-products":ge.length>0?"":void 0,className:`${le?"magicx-aia ":""}${ie.dropdown} ${z?ie.visible:""} ${r??""}`,onMouseDown:R=>R.preventDefault(),children:[Ke(gt,{space:"8px",children:[(A||d)&&Ke(_e,{noWrap:!0,className:ie.pillBar,"data-aia-pillbar":"",children:[A&&O("span",{className:ie.pillScroll,"data-aia-pill-scroll":"",children:O(Te,{pills:p.pills??[],activePillIndex:0,activeSelected:p.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:p.isLoading})}),d&&O("button",{type:"button",tabIndex:-1,className:ie.skip,"data-aia-skip":"",disabled:p.isLoading||p.skipDisabled,"aria-label":K?`Skip ${K}`:"Skip",onClick:m,children:"skip"})]}),ae&&O(ft,{options:l,activeIndex:p.activeIndex,onSelect:t,onHighlight:i,listboxId:a,loading:p.isLoading,groupKey:H?`${H.type} ${H.text}`:"",optionsPosition:$}),he&&p.dateView&&O(ot,{options:l,activeIndex:p.activeIndex,listboxId:a,view:p.dateView,selectedIso:p.selectedDateIso??null,onSelect:t,onHighlight:i,onPreviousMonth:h??bt,onNextMonth:se??bt}),de&&O("div",{className:ie.skeletonBars,"data-aia-skeleton-bars":"",children:ba.map(R=>O("span",{className:ie.skeletonBar,style:{width:R}},`bar-${R}`))}),O(lt,{products:ge,listboxId:a,onSelect:Z??va,onFocusChange:re,focusable:z}),O(nt,{isOptionHighlighted:u,isInputEmpty:p.isInputEmpty})]}),O("button",{ref:V,type:"button",tabIndex:-1,className:ie.scrollArrow,"data-aia-scroll-arrow":"","aria-label":fa,"aria-hidden":"true",children:O("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:O("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Ra,ModeController as La,setCursorOffset as Ma}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 {
1548
+ `,document.head.appendChild(e)}import{jsx as ga}from"react/jsx-runtime";function wt({space:e,align:n="stretch",className:a,children:o,...l}){let t=e?{"--aia-stack-space":e}:void 0;return ga("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":n,style:t,...l,children:o})}import{jsx as H,jsxs as qe}from"react/jsx-runtime";var xa=[159,119,164],ya=()=>{},xt=()=>{};function _a(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,o]=wa(n);if($e(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let l=window.matchMedia("(prefers-color-scheme: dark)"),t=()=>o(l.matches);return l.addEventListener("change",t),()=>l.removeEventListener("change",t)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function ka(e,n){let a=Me(null);$e(()=>{let o=e.current,l=n.current;if(!o||!l)return;let t=o.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==t&&(a.current.controller.destroy(),a.current=null),t&&!a.current){a.current={grid:t,controller:ba({dropdown:o,grid:t,button:l})};return}a.current?.controller.update()}),$e(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function je({suggestions:e,activeIndex:n,onSelect:a,onHighlight:o,isOpen:l,id:t,className:i,pills:g,onPillClick:v,showPills:x=!0,onSkip:m,showSkipButton:w=!0,skipDisabled:k=!1,activeSelected:y=!1,isLoading:b=!1,isInputEmpty:D=!1,products:E,onProductSelect:Q,onProductFocusChange:X,formatType:z="options",dateView:P=null,selectedDateIso:Z=null,onPreviousMonth:J,onNextMonth:p,optionsPosition:ee="below",mode:te}){let R=_a(te),q=R!==void 0,ae=Me(null),$=Me(null);ka(ae,$);let oe=e[0]?.options??[],ie=!!(g&&g.length>0&&v),M=!!(E&&E.length>0),O=l&&(oe.length>0||x&&ie||b||M),j={suggestions:e,activeIndex:n,pills:g,showPills:x,showSkipButton:w,skipDisabled:k,activeSelected:y,isLoading:b,isInputEmpty:D,products:E,formatType:z,dateView:P,selectedDateIso:Z},B=Me(j);O&&(B.current=j);let h=O?j:B.current,N=h.suggestions[0],s=N?.options??[],u=h.activeIndex>=0&&!!s[h.activeIndex]?.is_tappable,f=!!(h.pills&&h.pills.length>0&&v),_=h.showPills&&f,r=h.showPills&&!f&&h.isLoading,S=_||r,K=f&&h.showSkipButton&&!h.isInputEmpty&&!!m,F=h.pills?.[0]?.text,d=h.formatType==="date"&&h.dateView!=null,me=s.length>0&&!d,ge=s.length>0&&d,ne=h.isLoading&&!me&&!ge,he=h.products??[];return qe("div",{ref:ae,id:t,role:"listbox","data-aia-dropdown":"","data-options-position":ee,"data-mode":R,"data-aia-loading":h.isLoading?"":void 0,"data-aia-has-products":he.length>0?"":void 0,className:`${q?"magicx-aia ":""}${le.dropdown} ${O?le.visible:""} ${i??""}`,onMouseDown:G=>G.preventDefault(),children:[qe(wt,{space:"8px",children:[(S||K)&&qe(ke,{noWrap:!0,className:le.pillBar,"data-aia-pillbar":"",children:[S&&H("span",{className:le.pillScroll,"data-aia-pill-scroll":"",children:H(Le,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:h.isLoading})}),K&&H("button",{type:"button",tabIndex:-1,className:le.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":F?`Skip ${F}`:"Skip",onClick:m,children:"skip"})]}),me&&H(vt,{options:s,activeIndex:h.activeIndex,onSelect:a,onHighlight:o,listboxId:t,loading:h.isLoading,groupKey:N?`${N.type} ${N.text}`:"",optionsPosition:ee}),ge&&h.dateView&&H(rt,{options:s,activeIndex:h.activeIndex,listboxId:t,view:h.dateView,selectedIso:h.selectedDateIso??null,onSelect:a,onHighlight:o,onPreviousMonth:J??xt,onNextMonth:p??xt}),ne&&H("div",{className:le.skeletonBars,"data-aia-skeleton-bars":"",children:xa.map(G=>H("span",{className:le.skeletonBar,style:{width:G}},`bar-${G}`))}),H(pt,{products:he,listboxId:t,onSelect:Q??ya,onFocusChange:X,focusable:O}),H(lt,{isOptionHighlighted:u,isInputEmpty:h.isInputEmpty})]}),H("button",{ref:$,type:"button",tabIndex:-1,className:le.scrollArrow,"data-aia-scroll-arrow":"","aria-label":va,"aria-hidden":"true",children:H("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:H("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Na,ModeController as za,setCursorOffset as Oa}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 {
1549
1549
  flex-shrink: 0;
1550
1550
  width: 32px;
1551
1551
  height: 32px;
@@ -1580,5 +1580,5 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
1580
1580
  );
1581
1581
  cursor: default;
1582
1582
  }
1583
- `,document.head.appendChild(e)}var vt={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as qe}from"react/jsx-runtime";function wt({disabled:e,onClick:n}){return qe("button",{type:"button","data-aia-submit":"",className:vt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),n()},"aria-label":"Submit",children:qe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:qe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ya,identifiedParamLabel as _a,selectedIsoFromText as ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as _t,useEffect as Pe,useRef as N,useState as Pa}from"react";import{useRef as xt}from"react";function yt(e){let n=xt(e);n.current=e;let t=xt(null);t.current===null&&(t.current={fetch:(s,a)=>{let r=n.current;return r?r.fetch(s,a):Promise.reject(new Error("products config removed"))},transform:s=>n.current?.transform(s)??[],get limit(){return n.current?.limit}});let i=e!==void 0;return{config:i?t.current:void 0,enabled:i}}var Ia={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],activeFormatType:"options",dateView:null,placeholderText:"",isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null};function $e({onSubmit:e,onError:n,optionOverrides:t,maskCompletedText:i,apiConfig:s,additionalContext:a,columns:r=2,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m,showSkipButton:x,onFocus:k,onBlur:w,value:f,completedParams:D,onChange:B,onParamsChange:Z,products:re,onProductSelect:L,source:I,setCursor:q}){let h=N(null),[se,$]=Pa(null),J=N(e);J.current=e;let E=N(n);E.current=n;let le=N(B);le.current=B;let j=N(Z);j.current=Z;let V=N(k);V.current=k;let ee=N(w);ee.current=w;let M=N(q);M.current=q;let te=N(L);te.current=L;let z=yt(re);Pe(()=>{if(typeof document>"u")return;let c=new ya(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:a,optionOverrides:t,maskCompletedText:i,columns:r,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m,source:I,value:f,completedParams:D,onSubmit:(...C)=>J.current?.(...C),onError:(...C)=>E.current?.(...C),onChange:(...C)=>le.current?.(...C),onParamsChange:(...C)=>j.current?.(...C),onFocus:()=>V.current?.(),onBlur:()=>ee.current?.(),onProductSelect:C=>te.current?.(C),setCursor:C=>M.current?.(C),products:z.config});h.current=c,$(c.getState());let T=c.subscribe(C=>$(C));return()=>{T(),c.destroy(),h.current===c&&(h.current=null)}},[]),Pe(()=>{f!==void 0&&h.current?.setValue(f)},[f]),Pe(()=>{D!==void 0&&h.current?.setCompletedParams(D)},[D]);let F=JSON.stringify(s??null),G;try{G=JSON.stringify(a??null)}catch{G="[unstringifiable]"}let p=N(t),H=N(0);if(t!==p.current){let c=p.current,T=t,C=Object.keys(c??{}),be=Object.keys(T??{});(C.length!==be.length||be.some(ce=>!c?.[ce]||T[ce]!==c[ce]))&&H.current++,p.current=t}Pe(()=>{h.current?.update({apiConfig:s,additionalContext:a,optionOverrides:t,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m})},[F,G,H.current,g,b,v,m]);let l=N(!1);Pe(()=>{if(!l.current){l.current=!0;return}h.current?.update({products:z.config})},[z.enabled]);let u=N(null);u.current===null&&(u.current={handleTextChange:c=>h.current?.handleTextChange(c),handleKeyDown:c=>{let T="nativeEvent"in c?c.nativeEvent:c;h.current?.handleKeyDown(T)},setFocused:c=>h.current?.setFocused(c),startEditingParam:c=>h.current?.startEditingParam(c),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:c=>h.current?.handleCaretAfterInput(c),handleCaretMove:c=>h.current?.handleCaretMove(c),replaceEditingRange:c=>h.current?.replaceEditingRange(c)??!1,setActivePill:c=>h.current?.setActivePill(c),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:c=>h.current?.selectOption(c),selectProduct:c=>h.current?.selectProduct(c),setActiveDropdownIndex:c=>h.current?.setActiveDropdownIndex(c),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let o=u.current,_=_t(c=>{let T=c.target.value,be=T.length>0&&!c.nativeEvent?.isComposing&&T[0]!==T[0].toUpperCase()?T[0].toUpperCase()+T.slice(1):T;h.current?.handleTextChange(be)},[]),y=_t(c=>{h.current?.handleKeyDown(c.nativeEvent)},[]),A=h.current,d=se??Ia,K=f!==void 0?f:d.text,Y=D!==void 0?D:d.completedParams,ae=d.actionableSuggestions,he=ae[0],de=A?.listboxId??"",ge=d.activeDropdownIndex>=0&&A?`${de}-option-${d.activeDropdownIndex}`:void 0,R=d.editingParam,oe=d.editingIdentified,xe=R?{type:R.suggestionType,text:R.suggestionPlaceholder,required:!0,options:R.options}:oe?{type:oe.type,text:_a(oe.type),required:!0,options:[]}:null,Ae=xe??he,Me=xe?[xe]:ae,Se=!A||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation;return{completedParams:Y,skippedParams:d.skippedParams,suggestionPills:ae,setActivePill:o.setActivePill,skipActivePill:o.skipActivePill,removeLastParam:o.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:o.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Se,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:de,error:d.error,products:d.products,selectProduct:o.selectProduct,handleTextChange:o.handleTextChange,handleKeyDown:o.handleKeyDown,setFocused:o.setFocused,editingParam:R,editingIdentified:oe,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:o.startEditingParam,exitEditMode:o.exitEditMode,handleCaretAfterInput:o.handleCaretAfterInput,handleCaretMove:o.handleCaretMove,replaceEditingRange:o.replaceEditingRange,inputProps:{value:K,placeholder:d.placeholderText||void 0,onChange:_,onKeyDown:y,onFocus:o.handleFocus,onBlur:o.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":ge,"aria-autocomplete":"list","aria-controls":de},reset:o.reset,dropdownProps:{suggestions:Ae?[{...Ae,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:o.selectOption,onHighlight:o.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:de,pills:Me,activeSelected:d.isActivePillSelected,onPillClick:o.setActivePill,onSkip:o.skipActivePill,showSkipButton:(x??!0)&&!R&&!oe,skipDisabled:d.inSelectionAnimation,isLoading:Se,isInputEmpty:K.trim().length===0,products:d.products,onProductSelect:o.selectProduct,onProductFocusChange:o.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:oe?oe.iso:ka(R?.text),onPreviousMonth:o.showPreviousMonth,onNextMonth:o.showNextMonth,optionsPosition:b??"below"}}}import{extractPlainText as kt,getCursorOffset as Pt,plainTextLength as Aa,renderEditableContent as Sa,setCursorOffset as It}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as je,useLayoutEffect as Ve,useRef as ve}from"react";var Le;function Ca(){if(Le!==void 0)return Le;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Le=e.contentEditable==="plaintext-only",Le}function At(e){let{segments:n,newParamId:t,editingParam:i,editingIdentified:s,editingAnchor:a,caretOffset:r,placeholderText:g,isFocused:b,isDropdownOpen:v,listboxId:m,activeDescendantId:x,autoFocus:k,handleTextChange:w,handleKeyDown:f,handleCaretAfterInput:D,handleCaretMove:B,startEditingParam:Z,replaceEditingRange:re,setFocused:L}=e,I=ve(null),q=ve(!1),h=ve(""),se=ve(""),$=ve(null),J=ve(0);$.current=r,je(()=>{if(!k)return;let l=I.current;if(!l)return;document.activeElement===l?L(!0):l.focus();let u=l.ownerDocument??document,o=u.getSelection(),_=o&&o.rangeCount>0&&l.contains(o.anchorNode);if(o&&!_){let y=u.createRange();y.selectNodeContents(l),y.collapse(!0),o.removeAllRanges(),o.addRange(y)}},[k,L]),je(()=>{let l=I.current;if(!l)return;let u=l.ownerDocument??document,o=()=>{let _=u.getSelection();if(!_||_.rangeCount===0||!_.anchorNode||!l.contains(_.anchorNode))return;let y=_.anchorNode,A=y.nodeType===Node.ELEMENT_NODE?y:y.parentElement,K=(_.isCollapsed?A?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,Y=i?.id??s?.id??null;if(K&&K!==Y){Z(K);return}performance.now()-J.current<50||B(Pt(l))};return u.addEventListener("selectionchange",o),()=>u.removeEventListener("selectionchange",o)},[i,s,Z,B]),Ve(()=>{let l=I.current;l&&Sa({input:l,segments:n,newParamId:t,editingParamId:i?.id??null,placeholderText:g??"",isFocused:b})},[n,t,i,g,b]),Ve(()=>{let l=h.current,u=t??"";if(h.current=u,!u||u===l)return;let o=I.current;if(!o)return;o.focus();let _=$.current??Aa(o);It(o,_)},[t]),Ve(()=>{let l=se.current,u=i?.id??"";if(se.current=u,!u||u===l||a==null)return;let o=I.current;o&&It(o,a)},[i,a]);let E=U(()=>{if(q.current)return;let l=I.current;if(!l)return;let u=kt(l),_=u.length>0&&u[0]!==u[0].toUpperCase()?u[0].toUpperCase()+u.slice(1):u;w(_)},[w]),le=U(()=>{J.current=performance.now(),E();let l=I.current;l&&D(Pt(l))},[E,D]);je(()=>{let l=I.current;if(!l)return;let u=o=>{let _=o,y=_.inputType;if(y==="insertParagraph"||y==="insertLineBreak"||y==="insertFromDrop"){o.preventDefault();return}if(y.startsWith("insert")||y.startsWith("delete")){let A=y.startsWith("delete")?"":_.data??"";re(A)&&o.preventDefault()}};return l.addEventListener("beforeinput",u),()=>l.removeEventListener("beforeinput",u)},[re]);let j=U(()=>{q.current=!0},[]),V=U(()=>{q.current=!1,E()},[E]),ee=U(l=>{l.preventDefault();let u=I.current;if(!u)return;let o=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!o)return;let _=u.ownerDocument??document,y=_.getSelection();if(!y||y.rangeCount===0)return;let A=y.getRangeAt(0);if(!u.contains(A.startContainer))return;A.deleteContents();let d=_.createTextNode(o);A.insertNode(d),A.setStartAfter(d),A.collapse(!0),y.removeAllRanges(),y.addRange(A),E()},[E]),M=U(l=>f(l),[f]),te=U(()=>L(!0),[L]),z=U(()=>L(!1),[L]),F=U(()=>I.current?.focus(),[]),G=U(()=>I.current?.blur(),[]),p=U(()=>{let l=I.current;return l?kt(l):""},[]),H=Ca()?"plaintext-only":"true";return{inputRef:I,editorProps:{ref:I,contentEditable:H,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":v,"aria-activedescendant":x,spellCheck:!0,enterKeyHint:"send",onInput:le,onKeyDown:M,onCompositionStart:j,onCompositionEnd:V,onPaste:ee,onFocus:te,onBlur:z},getPlainText:p,focus:F,blur:G}}import{jsx as we,jsxs as Qe}from"react/jsx-runtime";function Na(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var za=Da(function({onSubmit:n,onError:t,optionOverrides:i,maskCompletedText:s,className:a,apiConfig:r,additionalContext:g,columns:b,pillPlacement:v="dropdown",mode:m="auto",optionsPosition:x="below",animations:k=!0,dropdownTrigger:w,closeDropdownOnBlur:f,showNonTappableOptions:D,showSkipButton:B,autoFocus:Z=!0,onFocus:re,onBlur:L,value:I,completedParams:q,onChange:h,onParamsChange:se,products:$,onProductSelect:J,submitButton:E},le){let j=Ie(null),V=Ie(null),ee=Ie(()=>{}),M=Ie(null),te=Ie(null);St(()=>{let P=j.current;if(P)return M.current?M.current.setMode(m):M.current=new La(P,m),()=>{M.current?.destroy(),M.current=null}},[m]);let z=Ye(P=>{let pe=te.current?.current;pe&&(pe.focus(),Ma(pe,P))},[]),{completedParams:F,skippedParams:G,suggestionPills:p,setActivePill:H,skipActivePill:l,segments:u,newParamId:o,clearNewParamId:_,placeholderText:y,isFocused:A,isDropdownOpen:d,isActivePillSelected:K,isLoading:Y,activeIndex:ae,listboxId:he,handleTextChange:de,handleKeyDown:ge,setFocused:R,editingParam:oe,editingIdentified:xe,editingAnchor:Ae,caretOffset:Me,startEditingParam:Se,handleCaretAfterInput:c,handleCaretMove:T,replaceEditingRange:C,dropdownProps:be,reset:ce}=$e({onSubmit:P=>ee.current(P),onError:t,optionOverrides:i,maskCompletedText:s,apiConfig:r,additionalContext:g,columns:b,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:f,showNonTappableOptions:D,showSkipButton:B,onFocus:re,onBlur:L,value:I,completedParams:q,onChange:h,onParamsChange:se,products:$,onProductSelect:J,source:"full-sdk",setCursor:z});St(()=>{if(!o)return;let P=window.setTimeout(()=>_(),650);return()=>window.clearTimeout(P)},[o,_]);let Ct=ae>=0?`${he}-option-${ae}`:void 0,{inputRef:Ne,editorProps:Dt,focus:Ce,blur:Xe,getPlainText:Ze}=At({segments:u,newParamId:o,editingParam:oe,editingIdentified:xe,editingAnchor:Ae,caretOffset:Me,placeholderText:y,isFocused:A,isDropdownOpen:d,listboxId:he,activeDescendantId:Ct,autoFocus:Z,handleTextChange:de,handleKeyDown:ge,handleCaretAfterInput:c,handleCaretMove:T,startEditingParam:Se,replaceEditingRange:C,setFocused:R});te.current=Ne,Ta(()=>{let P=V.current,pe=Ne.current;if(!P||!pe)return;let Je=()=>{let tt=P.firstElementChild;if(!tt)return;let Lt=tt.getBoundingClientRect(),Mt=pe.getBoundingClientRect();Lt.top>=Mt.bottom-2?P.setAttribute("data-aia-pill-wrapped",""):P.removeAttribute("data-aia-pill-wrapped")};Je();let et=new ResizeObserver(Je);return et.observe(pe),()=>et.disconnect()},[u,p.length,Y,Ne]),Ea(le,()=>({focus:Ce,blur:Xe,reset:ce,setMode:P=>M.current?.setMode(P),skipActivePill:l}),[Ce,Xe,ce,l]);let De=!!u.length||F.length>0,ze=Ye(()=>{if(!De)return;let P=Ze();n(Ra(P,F,G)),ce()},[De,F,G,n,ce,Ze]);ee.current=ze;let Et=Ye(P=>{P.target?.closest("[data-aia-pill]")||Ce()},[Ce]),Tt=v==="inline",Rt=v==="dropdown";return Qe("div",{ref:j,className:`magicx-aia ${fe.container} ${a??""}`,"data-pill-placement":v,"data-options-position":x,"data-animations":k?"on":"off","data-mode":Na(m),children:[we(Ue,{...be,showPills:Rt}),Qe("div",{className:fe.inputWrapper,onClick:Et,children:[Qe("div",{className:fe.editorArea,"data-aia-editor":"",children:[we("div",{...Dt,className:fe.input,"data-aia-input":""}),Tt&&(Y||p.length>0)&&we("span",{ref:V,className:fe.pillListContainer,"data-aia-pill-list-container":"",children:we(Te,{pills:p,activePillIndex:0,activeSelected:K,onSelectPill:H,loading:Y})})]}),E===null?null:E===void 0?we(wt,{disabled:!De,onClick:ze}):we("span",{"data-aia-submit":"",className:fe.submitSlot,onClick:P=>{De&&(P.stopPropagation(),ze())},children:E})]})]})});export{za as AIAutocomplete,Ue as AIAutocompleteDropdown,Ei as WEEKDAY_LABELS,_i as buildSubmitResult,ki as cellDay,Pi as cellIso,Ii as formatDate,Ai as isoDate,Si as monthLabel,Ci as parseDate,Di as parseLooseDate,$e as useAIAutocomplete,Ti as withSkippedParams};
1583
+ `,document.head.appendChild(e)}var yt={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ve}from"react/jsx-runtime";function _t({disabled:e,onClick:n}){return Ve("button",{type:"button","data-aia-submit":"",className:yt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),n()},"aria-label":"Submit",children:Ve("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Ve("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Pa,identifiedParamLabel as Ia,selectedIsoFromText as Aa}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as It,useEffect as Ie,useRef as L,useState as Sa}from"react";import{useRef as kt}from"react";function Pt(e){let n=kt(e);n.current=e;let a=kt(null);a.current===null&&(a.current={fetch:(l,t)=>{let i=n.current;return i?i.fetch(l,t):Promise.reject(new Error("products config removed"))},transform:l=>n.current?.transform(l)??[],get limit(){return n.current?.limit}});let o=e!==void 0;return{config:o?a.current:void 0,enabled:o}}var Ca={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],activeFormatType:"options",dateView:null,placeholderText:"",isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null};function Ye({onSubmit:e,onResult:n,onError:a,optionOverrides:o,maskCompletedText:l,apiConfig:t,additionalContext:i,columns:g=2,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:m,showNonTappableOptions:w,showSkipButton:k,onFocus:y,onBlur:b,value:D,completedParams:E,onChange:Q,onParamsChange:X,products:z,onProductSelect:P,source:Z,setCursor:J}){let p=L(null),[ee,te]=Sa(null),R=L(e);R.current=e;let q=L(n);q.current=n;let ae=L(a);ae.current=a;let $=L(Q);$.current=Q;let oe=L(X);oe.current=X;let ie=L(y);ie.current=y;let M=L(b);M.current=b;let O=L(J);O.current=J;let j=L(P);j.current=P;let B=Pt(z);Ie(()=>{if(typeof document>"u")return;let c=new Pa(document.createElement("div"),{renderMode:"headless",apiConfig:t,additionalContext:i,optionOverrides:o,maskCompletedText:l,columns:g,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:m,showNonTappableOptions:w,source:Z,value:D,completedParams:E,onSubmit:(...A)=>R.current?.(...A),onResult:(...A)=>q.current?.(...A),onError:(...A)=>ae.current?.(...A),onChange:(...A)=>$.current?.(...A),onParamsChange:(...A)=>oe.current?.(...A),onFocus:()=>ie.current?.(),onBlur:()=>M.current?.(),onProductSelect:A=>j.current?.(A),setCursor:A=>O.current?.(A),products:B.config});p.current=c,te(c.getState());let T=c.subscribe(A=>te(A));return()=>{T(),c.destroy(),p.current===c&&(p.current=null)}},[]),Ie(()=>{D!==void 0&&p.current?.setValue(D)},[D]),Ie(()=>{E!==void 0&&p.current?.setCompletedParams(E)},[E]);let h=JSON.stringify(t??null),N;try{N=JSON.stringify(i??null)}catch{N="[unstringifiable]"}let s=L(o),u=L(0);if(o!==s.current){let c=s.current,T=o,A=Object.keys(c??{}),be=Object.keys(T??{});(A.length!==be.length||be.some(ye=>!c?.[ye]||T[ye]!==c[ye]))&&u.current++,s.current=o}Ie(()=>{p.current?.update({apiConfig:t,additionalContext:i,optionOverrides:o,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:m,showNonTappableOptions:w})},[h,N,u.current,v,x,m,w]);let f=L(!1);Ie(()=>{if(!f.current){f.current=!0;return}p.current?.update({products:B.config})},[B.enabled]);let _=L(null);_.current===null&&(_.current={handleTextChange:c=>p.current?.handleTextChange(c),handleKeyDown:c=>{let T="nativeEvent"in c?c.nativeEvent:c;p.current?.handleKeyDown(T)},setFocused:c=>p.current?.setFocused(c),startEditingParam:c=>p.current?.startEditingParam(c),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:c=>p.current?.handleCaretAfterInput(c),handleCaretMove:c=>p.current?.handleCaretMove(c),replaceEditingRange:c=>p.current?.replaceEditingRange(c)??!1,setActivePill:c=>p.current?.setActivePill(c),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:c=>p.current?.selectOption(c),selectProduct:c=>p.current?.selectProduct(c),setActiveDropdownIndex:c=>p.current?.setActiveDropdownIndex(c),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let r=_.current,S=It(c=>{let T=c.target.value,be=T.length>0&&!c.nativeEvent?.isComposing&&T[0]!==T[0].toUpperCase()?T[0].toUpperCase()+T.slice(1):T;p.current?.handleTextChange(be)},[]),K=It(c=>{p.current?.handleKeyDown(c.nativeEvent)},[]),F=p.current,d=ee??Ca,me=D!==void 0?D:d.text,ge=E!==void 0?E:d.completedParams,ne=d.actionableSuggestions,he=ne[0],G=F?.listboxId??"",ze=d.activeDropdownIndex>=0&&F?`${G}-option-${d.activeDropdownIndex}`:void 0,re=d.editingParam,se=d.editingIdentified,xe=re?{type:re.suggestionType,text:re.suggestionPlaceholder,required:!0,options:re.options}:se?{type:se.type,text:Ia(se.type),required:!0,options:[]}:null,Se=xe??he,Oe=xe?[xe]:ne,Ce=!F||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation;return{completedParams:ge,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:ne,setActivePill:r.setActivePill,skipActivePill:r.skipActivePill,removeLastParam:r.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:r.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Ce,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:G,error:d.error,products:d.products,selectProduct:r.selectProduct,handleTextChange:r.handleTextChange,handleKeyDown:r.handleKeyDown,setFocused:r.setFocused,editingParam:re,editingIdentified:se,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:r.startEditingParam,exitEditMode:r.exitEditMode,handleCaretAfterInput:r.handleCaretAfterInput,handleCaretMove:r.handleCaretMove,replaceEditingRange:r.replaceEditingRange,inputProps:{value:me,placeholder:d.placeholderText||void 0,onChange:S,onKeyDown:K,onFocus:r.handleFocus,onBlur:r.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":ze,"aria-autocomplete":"list","aria-controls":G},reset:r.reset,dropdownProps:{suggestions:Se?[{...Se,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:r.selectOption,onHighlight:r.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:G,pills:Oe,activeSelected:d.isActivePillSelected,onPillClick:r.setActivePill,onSkip:r.skipActivePill,showSkipButton:(k??!0)&&!re&&!se,skipDisabled:d.inSelectionAnimation,isLoading:Ce,isInputEmpty:me.trim().length===0,products:d.products,onProductSelect:r.selectProduct,onProductFocusChange:r.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:se?se.iso:Aa(re?.text),onPreviousMonth:r.showPreviousMonth,onNextMonth:r.showNextMonth,optionsPosition:x??"below"}}}import{extractPlainText as At,getCursorOffset as St,plainTextLength as Da,renderEditableContent as Ea,setCursorOffset as Ct}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as Qe,useLayoutEffect as Xe,useRef as ve}from"react";var Ne;function Ta(){if(Ne!==void 0)return Ne;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ne=e.contentEditable==="plaintext-only",Ne}function Dt(e){let{segments:n,newParamId:a,editingParam:o,editingIdentified:l,editingAnchor:t,caretOffset:i,placeholderText:g,isFocused:v,isDropdownOpen:x,listboxId:m,activeDescendantId:w,autoFocus:k,handleTextChange:y,handleKeyDown:b,handleCaretAfterInput:D,handleCaretMove:E,startEditingParam:Q,replaceEditingRange:X,setFocused:z}=e,P=ve(null),Z=ve(!1),J=ve(""),p=ve(""),ee=ve(null),te=ve(0);ee.current=i,Qe(()=>{if(!k)return;let s=P.current;if(!s)return;document.activeElement===s?z(!0):s.focus();let u=s.ownerDocument??document,f=u.getSelection(),_=f&&f.rangeCount>0&&s.contains(f.anchorNode);if(f&&!_){let r=u.createRange();r.selectNodeContents(s),r.collapse(!0),f.removeAllRanges(),f.addRange(r)}},[k,z]),Qe(()=>{let s=P.current;if(!s)return;let u=s.ownerDocument??document,f=()=>{let _=u.getSelection();if(!_||_.rangeCount===0||!_.anchorNode||!s.contains(_.anchorNode))return;let r=_.anchorNode,S=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement,F=(_.isCollapsed?S?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,d=o?.id??l?.id??null;if(F&&F!==d){Q(F);return}performance.now()-te.current<50||E(St(s))};return u.addEventListener("selectionchange",f),()=>u.removeEventListener("selectionchange",f)},[o,l,Q,E]),Xe(()=>{let s=P.current;s&&Ea({input:s,segments:n,newParamId:a,editingParamId:o?.id??null,placeholderText:g??"",isFocused:v})},[n,a,o,g,v]),Xe(()=>{let s=J.current,u=a??"";if(J.current=u,!u||u===s)return;let f=P.current;if(!f)return;f.focus();let _=ee.current??Da(f);Ct(f,_)},[a]),Xe(()=>{let s=p.current,u=o?.id??"";if(p.current=u,!u||u===s||t==null)return;let f=P.current;f&&Ct(f,t)},[o,t]);let R=U(()=>{if(Z.current)return;let s=P.current;if(!s)return;let u=At(s),_=u.length>0&&u[0]!==u[0].toUpperCase()?u[0].toUpperCase()+u.slice(1):u;y(_)},[y]),q=U(()=>{te.current=performance.now(),R();let s=P.current;s&&D(St(s))},[R,D]);Qe(()=>{let s=P.current;if(!s)return;let u=f=>{let _=f,r=_.inputType;if(r==="insertParagraph"||r==="insertLineBreak"||r==="insertFromDrop"){f.preventDefault();return}if(r.startsWith("insert")||r.startsWith("delete")){let S=r.startsWith("delete")?"":_.data??"";X(S)&&f.preventDefault()}};return s.addEventListener("beforeinput",u),()=>s.removeEventListener("beforeinput",u)},[X]);let ae=U(()=>{Z.current=!0},[]),$=U(()=>{Z.current=!1,R()},[R]),oe=U(s=>{s.preventDefault();let u=P.current;if(!u)return;let f=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let _=u.ownerDocument??document,r=_.getSelection();if(!r||r.rangeCount===0)return;let S=r.getRangeAt(0);if(!u.contains(S.startContainer))return;S.deleteContents();let K=_.createTextNode(f);S.insertNode(K),S.setStartAfter(K),S.collapse(!0),r.removeAllRanges(),r.addRange(S),R()},[R]),ie=U(s=>b(s),[b]),M=U(()=>z(!0),[z]),O=U(()=>z(!1),[z]),j=U(()=>P.current?.focus(),[]),B=U(()=>P.current?.blur(),[]),h=U(()=>{let s=P.current;return s?At(s):""},[]),N=Ta()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:N,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":x,"aria-activedescendant":w,spellCheck:!0,enterKeyHint:"send",onInput:q,onKeyDown:ie,onCompositionStart:ae,onCompositionEnd:$,onPaste:oe,onFocus:M,onBlur:O},getPlainText:h,focus:j,blur:B}}import{jsx as we,jsxs as Je}from"react/jsx-runtime";function Ba(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Fa=Ra(function({onSubmit:n,onResult:a,onError:o,optionOverrides:l,maskCompletedText:t,className:i,apiConfig:g,additionalContext:v,columns:x,pillPlacement:m="dropdown",mode:w="auto",optionsPosition:k="below",animations:y=!0,dropdownTrigger:b,closeDropdownOnBlur:D,showNonTappableOptions:E,showSkipButton:Q,autoFocus:X=!0,onFocus:z,onBlur:P,value:Z,completedParams:J,onChange:p,onParamsChange:ee,products:te,onProductSelect:R,submitButton:q},ae){let $=Ae(null),oe=Ae(null),ie=Ae(()=>{}),M=Ae(null),O=Ae(null);Et(()=>{let I=$.current;if(I)return M.current?M.current.setMode(w):M.current=new za(I,w),()=>{M.current?.destroy(),M.current=null}},[w]);let j=Ze(I=>{let ce=O.current?.current;ce&&(ce.focus(),Oa(ce,I))},[]),{completedParams:B,skippedParams:h,identifiedParams:N,isReady:s,suggestionPills:u,setActivePill:f,skipActivePill:_,segments:r,newParamId:S,clearNewParamId:K,placeholderText:F,isFocused:d,isDropdownOpen:me,isActivePillSelected:ge,isLoading:ne,activeIndex:he,listboxId:G,handleTextChange:ze,handleKeyDown:re,setFocused:se,editingParam:xe,editingIdentified:Se,editingAnchor:Oe,caretOffset:Ce,startEditingParam:c,handleCaretAfterInput:T,handleCaretMove:A,replaceEditingRange:be,dropdownProps:ye,reset:De}=Ye({onSubmit:I=>ie.current(I),onResult:a,onError:o,optionOverrides:l,maskCompletedText:t,apiConfig:g,additionalContext:v,columns:x,dropdownTrigger:b,optionsPosition:k,closeDropdownOnBlur:D,showNonTappableOptions:E,showSkipButton:Q,onFocus:z,onBlur:P,value:Z,completedParams:J,onChange:p,onParamsChange:ee,products:te,onProductSelect:R,source:"full-sdk",setCursor:j});Et(()=>{if(!S)return;let I=window.setTimeout(()=>K(),650);return()=>window.clearTimeout(I)},[S,K]);let Tt=he>=0?`${G}-option-${he}`:void 0,{inputRef:Be,editorProps:Rt,focus:Ee,blur:et,getPlainText:tt}=Dt({segments:r,newParamId:S,editingParam:xe,editingIdentified:Se,editingAnchor:Oe,caretOffset:Ce,placeholderText:F,isFocused:d,isDropdownOpen:me,listboxId:G,activeDescendantId:Tt,autoFocus:X,handleTextChange:ze,handleKeyDown:re,handleCaretAfterInput:T,handleCaretMove:A,startEditingParam:c,replaceEditingRange:be,setFocused:se});O.current=Be,Ma(()=>{let I=oe.current,ce=Be.current;if(!I||!ce)return;let at=()=>{let it=I.firstElementChild;if(!it)return;let zt=it.getBoundingClientRect(),Ot=ce.getBoundingClientRect();zt.top>=Ot.bottom-2?I.setAttribute("data-aia-pill-wrapped",""):I.removeAttribute("data-aia-pill-wrapped")};at();let ot=new ResizeObserver(at);return ot.observe(ce),()=>ot.disconnect()},[r,u.length,ne,Be]),La(ae,()=>({focus:Ee,blur:et,reset:De,setMode:I=>M.current?.setMode(I),skipActivePill:_}),[Ee,et,De,_]);let Te=!!r.length||B.length>0,Fe=Ze(()=>{if(!Te)return;let I=tt();n(Na(I,B,h,{identifiedParams:N,isReady:s})),De()},[Te,B,h,N,s,n,De,tt]);ie.current=Fe;let Lt=Ze(I=>{I.target?.closest("[data-aia-pill]")||Ee()},[Ee]),Mt=m==="inline",Nt=m==="dropdown";return Je("div",{ref:$,className:`magicx-aia ${fe.container} ${i??""}`,"data-pill-placement":m,"data-options-position":k,"data-animations":y?"on":"off","data-mode":Ba(w),children:[we(je,{...ye,showPills:Nt}),Je("div",{className:fe.inputWrapper,onClick:Lt,children:[Je("div",{className:fe.editorArea,"data-aia-editor":"",children:[we("div",{...Rt,className:fe.input,"data-aia-input":""}),Mt&&(ne||u.length>0)&&we("span",{ref:oe,className:fe.pillListContainer,"data-aia-pill-list-container":"",children:we(Le,{pills:u,activePillIndex:0,activeSelected:ge,onSelectPill:f,loading:ne})})]}),q===null?null:q===void 0?we(_t,{disabled:!Te,onClick:Fe}):we("span",{"data-aia-submit":"",className:fe.submitSlot,onClick:I=>{Te&&(I.stopPropagation(),Fe())},children:q})]})]})});export{Fa as AIAutocomplete,je as AIAutocompleteDropdown,Li as WEEKDAY_LABELS,Ii as buildSubmitResult,Ai as cellDay,Si as cellIso,Ci as formatDate,Di as isoDate,Ei as monthLabel,Ti as parseDate,Ri as parseLooseDate,Ye as useAIAutocomplete,Mi as withSkippedParams};
1584
1584
  //# sourceMappingURL=index.mjs.map