@magicx-eng/ai-autocomplete-react 0.12.0 → 0.13.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 Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as ra,useCallback as We,useEffect as bt,useImperativeHandle as na,useLayoutEffect as sa,useRef as xe}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 pi,cellDay as ci,cellIso as ui,formatDate as mi,isoDate as hi,monthLabel as gi,parseDate as fi,parseLooseDate as bi,WEEKDAY_LABELS as vi,withSkippedParams as xi}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as xa,useCallback as qe,useEffect as _t,useImperativeHandle as wa,useLayoutEffect as ya,useRef as _e}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 Wo,withSkippedParams as Uo}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 $t,useRef as jt,useState as Qt}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 ge={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 na,useRef as sa,useState as la}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,154 @@ import{buildSubmitResult as Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autoc
665
665
  opacity: 0.25;
666
666
  }
667
667
  }
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 It,buildAttributionUrl as St,getFooterHint as At}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ct,useState as Et}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 ce={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{cellDay as Tt,cellIso as Me,isoDate as Rt,monthLabel as Lt,WEEKDAY_LABELS as zt}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Nt}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) ---
669
+
670
+ One of three hand-maintained copies (vanilla styles.css, this file, Angular's
671
+ date-grid.component.css). Only the class-naming layer differs \u2014 the
672
+ declarations must match, and \`datepickerParity.test.ts\` fails the build if
673
+ they drift. See CLAUDE.md's duplicated-stylesheet rule.
674
+
675
+ Every colour resolves through the same --aia-option-* chain the option rows
676
+ use. The dropdown paints a background but sets no \`color\`, so anything here
677
+ relying on \`color: inherit\` would pick up the HOST page's text colour and go
678
+ black on a dark panel \u2014 and \`prefers-color-scheme\` can't be used to guess,
679
+ because the panel's darkness comes from --aia-surface, which the media query
680
+ says nothing about. Going through the option chain means one consumer
681
+ override restyles the calendar and the options together. */
682
+ .DateGrid-module_datepicker_6RrTs {
683
+ display: flex;
684
+ flex-direction: column;
685
+ gap: 4px;
686
+ padding: 4px 2px 8px;
687
+ }
688
+
689
+ .DateGrid-module_header_z4LRk {
690
+ display: flex;
691
+ align-items: center;
692
+ justify-content: space-between;
693
+ gap: 8px;
694
+ padding: 2px 6px 6px;
695
+ }
696
+
697
+ .DateGrid-module_month_urB2T {
698
+ font-family: inherit;
699
+ font-size: var(--aia-date-month-font-size, 14px);
700
+ font-weight: 500;
701
+ line-height: 20px;
702
+ color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
703
+ }
704
+
705
+ .DateGrid-module_nav_ap4AN {
706
+ display: inline-flex;
707
+ align-items: center;
708
+ justify-content: center;
709
+ width: 24px;
710
+ height: 24px;
711
+ padding: 0;
712
+ border: none;
713
+ border-radius: 6px;
714
+ background: transparent;
715
+ font-family: inherit;
716
+ font-size: 16px;
717
+ line-height: 1;
718
+ color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
719
+ cursor: pointer;
720
+ transition:
721
+ color 150ms ease-out,
722
+ background-color 150ms ease-out;
723
+ }
724
+
725
+ .DateGrid-module_nav_ap4AN:hover {
726
+ color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
727
+ background: var(--aia-option-bg, transparent);
728
+ }
729
+
730
+ .DateGrid-module_weekdays_3EA3q,
731
+ .DateGrid-module_grid_mQCgw {
732
+ display: grid;
733
+ /* The 7 columns live on the cell container itself, not on an ancestor:
734
+ KeyboardController.getEffectiveColumns() measures grid-template-columns by
735
+ walking up from option-0's PARENT, and it is this number that makes
736
+ ArrowDown mean "+1 week". */
737
+ grid-template-columns: repeat(7, minmax(0, 1fr));
738
+ }
739
+
740
+ .DateGrid-module_weekday_3lF4B {
741
+ padding: 2px 0;
742
+ text-align: center;
743
+ font-family: inherit;
744
+ font-size: var(--aia-date-weekday-font-size, 11px);
745
+ font-weight: 500;
746
+ line-height: 16px;
747
+ color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
748
+ opacity: 0.7;
749
+ }
750
+
751
+ .DateGrid-module_cell_59k0y {
752
+ display: flex;
753
+ align-items: center;
754
+ justify-content: center;
755
+ /* Deliberately NOT sized here. Giving the grid item a definite size (an
756
+ aspect-ratio, a width) stops it stretching to its track, so it parks at
757
+ the track's start edge and the whole month drifts left of the weekday
758
+ header above it \u2014 the two grids agree on their columns, and only the
759
+ items disagree, which makes it look like a column-count bug. The cell
760
+ fills its track; the square is the number span inside it. */
761
+ min-width: 0;
762
+ /* Keeps a month readable in a narrow dropdown without letting a 6-row month
763
+ grow the panel past the options grid it replaces. */
764
+ height: var(--aia-date-row-height, 40px);
765
+ font-family: inherit;
766
+ font-size: var(--aia-date-cell-font-size, 14px);
767
+ font-weight: 450;
768
+ line-height: 20px;
769
+ color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
770
+ }
771
+
772
+ /* The visual box: everything a cell paints \u2014 fill, ring, press \u2014 lands here so
773
+ it reads as a square centred in its column rather than a full-width band. */
774
+ .DateGrid-module_number_aoT01 {
775
+ display: flex;
776
+ align-items: center;
777
+ justify-content: center;
778
+ width: var(--aia-date-cell-size, 36px);
779
+ height: var(--aia-date-cell-size, 36px);
780
+ border-radius: 8px;
781
+ }
782
+
783
+ .DateGrid-module_day_cB3u9 {
784
+ cursor: pointer;
785
+ }
786
+
787
+ .DateGrid-module_blank_ivgRC {
788
+ cursor: default;
789
+ }
790
+
791
+ .DateGrid-module_day_cB3u9:hover .DateGrid-module_number_aoT01,
792
+ .DateGrid-module_highlighted_YIdtK .DateGrid-module_number_aoT01 {
793
+ color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
794
+ background: var(--aia-option-bg, transparent);
795
+ font-weight: 500;
796
+ }
797
+
798
+ /* Today reads as an outline, the committed answer as a fill \u2014 so a re-edited
799
+ date can show both at once without either being ambiguous. */
800
+ .DateGrid-module_today_iI3ME .DateGrid-module_number_aoT01 {
801
+ box-shadow: inset 0 0 0 1px
802
+ var(--aia-date-today-ring, var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb)));
803
+ }
804
+
805
+ .DateGrid-module_selected_28KDn .DateGrid-module_number_aoT01 {
806
+ color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
807
+ background: var(--aia-date-selected-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.12));
808
+ font-weight: 500;
809
+ }
810
+
811
+ .DateGrid-module_pressed_bEyyN .DateGrid-module_number_aoT01 {
812
+ opacity: 0.8;
813
+ background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
814
+ }
815
+ `,document.head.appendChild(e)}var I={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",highlighted:"DateGrid-module_highlighted_YIdtK",today:"DateGrid-module_today_iI3ME",selected:"DateGrid-module_selected_28KDn",pressed:"DateGrid-module_pressed_bEyyN"};import{jsx as $,jsxs as Ze}from"react/jsx-runtime";var Mt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function et({options:e,activeIndex:n,listboxId:a,view:i,selectedIso:s,onSelect:o,onHighlight:r,onPreviousMonth:g,onNextMonth:b}){let v=Rt(new Date);return Ze("div",{className:I.datepicker,"data-aia-datepicker":"",children:[Ze("div",{className:I.header,children:[$("button",{type:"button",tabIndex:-1,className:I.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:g,children:"\u2039"}),$("span",{className:I.month,"data-aia-date-month":"","aria-live":"polite",children:Lt(i)}),$("button",{type:"button",tabIndex:-1,className:I.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:b,children:"\u203A"})]}),$("div",{className:I.weekdays,"aria-hidden":"true",children:zt.map((m,f)=>$("span",{className:I.weekday,children:m},Mt[f]))}),$("div",{className:I.grid,"data-aia-date-grid":"",children:e.map((m,f)=>$(Bt,{option:m,id:`${a}-option-${f}`,index:f,isHighlighted:f===n&&m.is_tappable,isToday:Me(m)===v,isSelected:s!=null&&Me(m)===s,onSelect:o,onHighlight:r},Me(m)??`pad-${f}`))})]})}function Bt({option:e,id:n,index:a,isHighlighted:i,isToday:s,isSelected:o,onSelect:r,onHighlight:g}){let[b,v]=Nt(!1),m=Tt(e);if(m==null)return $("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${I.cell} ${I.blank}`});let f=()=>{v(!0),r(e),setTimeout(()=>v(!1),500)},E=[I.cell,I.day,i?I.highlighted:"",s?I.today:"",o?I.selected:"",b?I.pressed:""].filter(Boolean).join(" ");return $("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:E,onClick:f,onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),f())},onMouseEnter:()=>g(a),children:$("span",{className:I.number,children:m})})}import{ATTRIBUTION_URL as Gt,buildAttributionUrl as Ot,getFooterHint as Ft}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ht,useState as Kt}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
816
  .aia-cluster {
670
817
  display: flex;
671
818
  flex-wrap: wrap;
@@ -707,7 +854,7 @@ import{buildSubmitResult as Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autoc
707
854
  justify-content: space-around;
708
855
  }
709
856
  }
710
- `,document.head.appendChild(e)}import{jsx as Je}from"react/jsx-runtime";function fe({gap:e,align:s="center",justify:t="start",noWrap:n=!1,inline:l=!1,className:r,children:o,...g}){let v=e?{"--aia-cluster-gap":e}:void 0,x={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":s,"data-justify":t,"data-nowrap":n||void 0,"data-inline":l||void 0,style:v,...g};return l?Je("span",{...x,children:o}):Je("div",{...x,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
857
+ `,document.head.appendChild(e)}import{jsx as tt}from"react/jsx-runtime";function we({gap:e,align:n="center",justify:a="start",noWrap:i=!1,inline:s=!1,className:o,children:r,...g}){let b=e?{"--aia-cluster-gap":e}:void 0,v={className:o?`aia-cluster ${o}`:"aia-cluster","data-align":n,"data-justify":a,"data-nowrap":i||void 0,"data-inline":s||void 0,style:b,...g};return s?tt("span",{...v,children:r}):tt("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
711
858
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
712
859
  room above the hint/branding row so the footer doesn't butt against the last
713
860
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -837,7 +984,7 @@ import{buildSubmitResult as Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autoc
837
984
  justify-content: flex-end;
838
985
  }
839
986
  }
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 be,jsxs as ze}from"react/jsx-runtime";function Xe({isOptionHighlighted:e=!1,isInputEmpty:s=!1}){let{key:t,hint:n}=At(e,s),[l,r]=Et(It);return Ct(()=>{r(St())},[]),be("footer",{className:Z.footer,"data-aia-footer":"",children:ze(fe,{justify:"between",noWrap:!0,className:Z.row,children:[ze(fe,{gap:"5px",className:Z.hintGroup,children:[be("kbd",{className:Z.key,children:t}),be("span",{className:Z.hint,children:n})]}),ze("a",{className:Z.brandLink,href:l,target:"_blank",rel:"noopener noreferrer",children:[be("span",{className:Z.brand,children:"AI"}),be("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,
987
+ `,document.head.appendChild(e)}var oe={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 ye,jsxs as Be}from"react/jsx-runtime";function at({isOptionHighlighted:e=!1,isInputEmpty:n=!1}){let{key:a,hint:i}=Ft(e,n),[s,o]=Kt(Gt);return Ht(()=>{o(Ot())},[]),ye("footer",{className:oe.footer,"data-aia-footer":"",children:Be(we,{justify:"between",noWrap:!0,className:oe.row,children:[Be(we,{gap:"5px",className:oe.hintGroup,children:[ye("kbd",{className:oe.key,children:a}),ye("span",{className:oe.hint,children:i})]}),Be("a",{className:oe.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[ye("span",{className:oe.brand,children:"AI"}),ye("span",{className:oe.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
988
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
842
989
  The border is kept as a 1px transparent line so the box stays the same size
843
990
  as it was when the outline was dashed. */
@@ -894,7 +1041,7 @@ import{buildSubmitResult as Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autoc
894
1041
  opacity: 0;
895
1042
  }
896
1043
  }
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 Dt}from"react/jsx-runtime";var Be={selected:1,first:.7,next:.4,last:.2};function Ze({label:e,state:s,rounded:t,loading:n,onClick:l}){let r=[re.pill,t?re.rounded:"",n?re.skeleton:""].filter(Boolean).join(" ");return Dt("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:Be[s]},onMouseDown:o=>o.preventDefault(),onClick:n?void 0:l,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 {
1044
+ `,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 Wt}from"react/jsx-runtime";var Ge={selected:1,first:.7,next:.4,last:.2};function ot({label:e,state:n,rounded:a,loading:i,onClick:s}){let o=[ue.pill,a?ue.rounded:"",i?ue.skeleton:""].filter(Boolean).join(" ");return Wt("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:o,style:{opacity:Ge[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 {
898
1045
  position: relative;
899
1046
  z-index: 1;
900
1047
  pointer-events: auto;
@@ -904,7 +1051,7 @@ import{buildSubmitResult as Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autoc
904
1051
  align-items: center;
905
1052
  vertical-align: middle;
906
1053
  }
907
- `,document.head.appendChild(e)}var Fe={list:"PillList-module_list_qvLqO"};import{jsx as Se}from"react/jsx-runtime";var Rt=[125,69];function Ye(e){return e===0?"first":e===1?"next":"last"}function Ae({pills:e,activePillIndex:s,onSelectPill:t,activeSelected:n,rounded:l,loading:r}){return r&&e.length===0?Se("span",{className:Fe.list,"data-aia-pill-list-loading":"",children:Rt.map((o,g)=>Se("span",{"data-aia-pill-skeleton":"",className:`${re.pill} ${l?re.rounded:""} ${re.skeleton}`,style:{width:o,opacity:Be[Ye(g)]}},`skel-${o}`))}):Se("span",{className:Fe.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((o,g)=>{let v=!!n&&g===s;return Se(Ze,{label:o.text,state:v?"selected":Ye(g),selected:v,rounded:l,loading:r,onClick:()=>t(g)},`${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
1054
+ `,document.head.appendChild(e)}var Oe={list:"PillList-module_list_qvLqO"};import{jsx as De}from"react/jsx-runtime";var Ut=[125,69];function it(e){return e===0?"first":e===1?"next":"last"}function Ce({pills:e,activePillIndex:n,onSelectPill:a,activeSelected:i,rounded:s,loading:o}){return o&&e.length===0?De("span",{className:Oe.list,"data-aia-pill-list-loading":"",children:Ut.map((r,g)=>De("span",{"data-aia-pill-skeleton":"",className:`${ue.pill} ${s?ue.rounded:""} ${ue.skeleton}`,style:{width:r,opacity:Ge[it(g)]}},`skel-${r}`))}):De("span",{className:Oe.list,"data-aia-pill-list-loading":o?"":void 0,children:e.map((r,g)=>{let b=!!i&&g===n;return De(ot,{label:r.text,state:b?"selected":it(g),selected:b,rounded:s,loading:o,onClick:()=>a(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
908
1055
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
909
1056
  theming one package sees the same result in the other.
910
1057
 
@@ -1071,7 +1218,7 @@ import{buildSubmitResult as Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autoc
1071
1218
  var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
1072
1219
  );
1073
1220
  }
1074
- `,document.head.appendChild(e)}var O={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 Me}from"react/jsx-runtime";function et({products:e,listboxId:s,onSelect:t,onFocusChange:n,focusable:l=!0}){if(e.length===0)return null;let r=`${s}-products-label`;return Me("section",{className:O.section,"data-aia-products":"",role:"group","aria-labelledby":r,children:[ne("div",{className:O.label,id:r,children:"Products"}),ne("div",{className:O.row,"data-aia-products-row":"",children:e.map((o,g)=>ne(Tt,{product:o,id:`${s}-product-${g}`,onSelect:t,onFocusChange:n,focusable:l},o.id))})]})}function Tt({product:e,id:s,onSelect:t,onFocusChange:n,focusable:l}){let r=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),t(e))};return Me("a",{id:s,className:O.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:l?0:-1,onClick:r,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),t(e))},onFocus:()=>n?.(!0),onBlur:o=>{o.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[ne("span",{className:O.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?ne("img",{className:O.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Me("span",{className:O.body,children:[e.vendor?ne("span",{className:O.vendor,children:e.vendor}):null,ne("span",{className:O.title,children:e.title}),e.price?ne("span",{className:O.price,children:e.price}):null]})]})}import{computeOptionsGridLayout as Ht,isOptionsGridMobileViewport as Gt,OPTIONS_GRID_MOBILE_QUERY as Kt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Wt,useState as Ut}from"react";import{optionsGridTemplateColumns as Lt}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as zt,useRef as Bt}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 {
1221
+ `,document.head.appendChild(e)}var H={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 Fe}from"react/jsx-runtime";function rt({products:e,listboxId:n,onSelect:a,onFocusChange:i,focusable:s=!0}){if(e.length===0)return null;let o=`${n}-products-label`;return Fe("section",{className:H.section,"data-aia-products":"",role:"group","aria-labelledby":o,children:[me("div",{className:H.label,id:o,children:"Products"}),me("div",{className:H.row,"data-aia-products-row":"",children:e.map((r,g)=>me(Vt,{product:r,id:`${n}-product-${g}`,onSelect:a,onFocusChange:i,focusable:s},r.id))})]})}function Vt({product:e,id:n,onSelect:a,onFocusChange:i,focusable:s}){let o=r=>{r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||r.button!==0||(r.preventDefault(),a(e))};return Fe("a",{id:n,className:H.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:o,onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),a(e))},onFocus:()=>i?.(!0),onBlur:r=>{r.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[me("span",{className:H.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?me("img",{className:H.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Fe("span",{className:H.body,children:[e.vendor?me("span",{className:H.vendor,children:e.vendor}):null,me("span",{className:H.title,children:e.title}),e.price?me("span",{className:H.price,children:e.price}):null]})]})}import{computeOptionsGridLayout as Zt,isOptionsGridMobileViewport as ea,OPTIONS_GRID_MOBILE_QUERY as ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as aa,useState as oa}from"react";import{optionsGridTemplateColumns as qt}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as $t,useRef as jt}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
1222
  .aia-grid {
1076
1223
  display: grid;
1077
1224
  grid-template-columns: repeat(
@@ -1106,7 +1253,7 @@ import{buildSubmitResult as Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autoc
1106
1253
  border-radius: 3px;
1107
1254
  }
1108
1255
  }
1109
- `,document.head.appendChild(e)}import{jsx as Ft}from"react/jsx-runtime";function tt({min:e="16rem",max:s,gap:t,scroll:n=!1,maxHeight:l,scrollResetKey:r,cols:o,className:g,children:v,...x}){let y=Bt(null);zt(()=>{if(r===void 0)return;let T=y.current;T&&(T.scrollTop=0)},[r]);let b={"--aia-grid-min":e};return s&&(b["--aia-grid-max"]=s),t&&(b["--aia-grid-gap"]=t),l&&(b["--aia-grid-max-height"]=l),o&&(b.gridTemplateColumns=Lt(o)),Ft("div",{ref:y,className:g?`aia-grid ${g}`:"aia-grid","data-scroll":n||void 0,style:b,...x,children:v})}import{useEffect as Mt,useRef as Nt,useState as Ot}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 {
1256
+ `,document.head.appendChild(e)}import{jsx as Qt}from"react/jsx-runtime";function nt({min:e="16rem",max:n,gap:a,scroll:i=!1,maxHeight:s,scrollResetKey:o,cols:r,className:g,children:b,...v}){let m=jt(null);$t(()=>{if(o===void 0)return;let E=m.current;E&&(E.scrollTop=0)},[o]);let f={"--aia-grid-min":e};return n&&(f["--aia-grid-max"]=n),a&&(f["--aia-grid-gap"]=a),s&&(f["--aia-grid-max-height"]=s),r&&(f.gridTemplateColumns=qt(r)),Qt("div",{ref:m,className:g?`aia-grid ${g}`:"aia-grid","data-scroll":i||void 0,style:f,...v,children:b})}import{useEffect as Yt,useRef as Jt,useState as Xt}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
1257
  position: relative;
1111
1258
  overflow: visible;
1112
1259
  display: flex;
@@ -1456,7 +1603,7 @@ import{buildSubmitResult as Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autoc
1456
1603
  filter: brightness(0.55);
1457
1604
  }
1458
1605
  }
1459
- `,document.head.appendChild(e)}var H={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 Ce,jsxs as at}from"react/jsx-runtime";function ot({option:e,isHighlighted:s,onSelect:t,onHighlight:n,id:l,loading:r}){let[o,g]=Ot(!1),v=Nt(void 0);Mt(()=>()=>clearTimeout(v.current),[]);let x=()=>{r||!e.is_tappable||o||(g(!0),t(e),clearTimeout(v.current),v.current=setTimeout(()=>g(!1),500))},y=[H.item,s&&!r?H.highlighted:"",e.is_tappable?H.tappable:H.nonTappable,o?H.pressed:""].filter(Boolean).join(" ");return at("div",{id:l,role:"option","data-aia-option":"","data-aia-loading":r?"":void 0,"aria-selected":s,className:y,tabIndex:r||!e.is_tappable?-1:0,onClick:x,onKeyDown:b=>{!r&&e.is_tappable&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),x())},onMouseEnter:!r&&e.is_tappable?n:void 0,children:[Ce("div",{className:H.streaks}),Ce("div",{className:H.streaksVert}),at("span",{className:H.content,children:[Ce("span",{className:H.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&Ce("span",{className:H.tag,children:e.tag})]})]})}import{jsx as it}from"react/jsx-runtime";function Vt(){let[e,s]=Ut(Gt);return Wt(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Kt),n=()=>s(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]),e}function rt({options:e,activeIndex:s,onSelect:t,onHighlight:n,listboxId:l,loading:r,groupKey:o}){let g=Vt(),{cols:v,maxHeight:x}=Ht(e.length,g);return it(tt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,cols:v,maxHeight:x,children:e.map((y,b)=>it(ot,{option:y,isHighlighted:b===s,onSelect:t,onHighlight:()=>n(b),id:`${l}-option-${b}`,loading:r},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 {
1606
+ `,document.head.appendChild(e)}var K={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 Ee,jsxs as st}from"react/jsx-runtime";function lt({option:e,isHighlighted:n,onSelect:a,onHighlight:i,id:s,loading:o}){let[r,g]=Xt(!1),b=Jt(void 0);Yt(()=>()=>clearTimeout(b.current),[]);let v=()=>{o||!e.is_tappable||r||(g(!0),a(e),clearTimeout(b.current),b.current=setTimeout(()=>g(!1),500))},m=[K.item,n&&!o?K.highlighted:"",e.is_tappable?K.tappable:K.nonTappable,r?K.pressed:""].filter(Boolean).join(" ");return st("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":o?"":void 0,"aria-selected":n,className:m,tabIndex:o||!e.is_tappable?-1:0,onClick:v,onKeyDown:f=>{!o&&e.is_tappable&&(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),v())},onMouseEnter:!o&&e.is_tappable?i:void 0,children:[Ee("div",{className:K.streaks}),Ee("div",{className:K.streaksVert}),st("span",{className:K.content,children:[Ee("span",{className:K.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&Ee("span",{className:K.tag,children:e.tag})]})]})}import{jsx as dt}from"react/jsx-runtime";function ia(){let[e,n]=oa(ea);return aa(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(ta),i=()=>n(a.matches);return i(),a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[]),e}function pt({options:e,activeIndex:n,onSelect:a,onHighlight:i,listboxId:s,loading:o,groupKey:r}){let g=ia(),{cols:b,maxHeight:v}=Zt(e.length,g);return dt(nt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:r,cols:b,maxHeight:v,children:e.map((m,f)=>dt(lt,{option:m,isHighlighted:f===n,onSelect:a,onHighlight:()=>i(f),id:`${s}-option-${f}`,loading:o},m.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
1460
1607
  .aia-stack {
1461
1608
  display: flex;
1462
1609
  flex-direction: column;
@@ -1473,7 +1620,7 @@ import{buildSubmitResult as Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autoc
1473
1620
  }
1474
1621
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
1475
1622
  }
1476
- `,document.head.appendChild(e)}import{jsx as qt}from"react/jsx-runtime";function nt({space:e,align:s="stretch",className:t,children:n,...l}){let r=e?{"--aia-stack-space":e}:void 0;return qt("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":s,style:r,...l,children:n})}import{jsx as Y,jsxs as st}from"react/jsx-runtime";var Jt=[159,119,164],Xt=()=>{};function Zt(e){let s=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,n]=Qt(s);if($t(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let l=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>n(l.matches);return l.addEventListener("change",r),()=>l.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Ne({suggestions:e,activeIndex:s,onSelect:t,onHighlight:n,isOpen:l,id:r,className:o,pills:g,onPillClick:v,showPills:x=!0,onSkip:y,showSkipButton:b=!0,skipDisabled:T=!1,activeSelected:U=!1,isLoading:K=!1,isInputEmpty:A=!1,products:I,onProductSelect:V,onProductFocusChange:C,optionsPosition:k="below",mode:W}){let q=Zt(W),$=q!==void 0,c=e[0]?.options??[],ee=!!(g&&g.length>0&&v),E=!!(I&&I.length>0),B=l&&(c.length>0||x&&ee||K||E),L={suggestions:e,activeIndex:s,pills:g,showPills:x,showSkipButton:b,skipDisabled:T,activeSelected:U,isLoading:K,isInputEmpty:A,products:I},j=jt(L);B&&(j.current=L);let h=B?L:j.current,z=h.suggestions[0],F=z?.options??[],D=h.activeIndex>=0&&!!F[h.activeIndex]?.is_tappable,M=!!(h.pills&&h.pills.length>0&&v),Q=h.showPills&&M,J=h.showPills&&!M&&h.isLoading,N=Q||J,i=M&&h.showSkipButton&&!h.isInputEmpty&&!!y,p=h.pills?.[0]?.text,u=F.length>0,f=h.isLoading&&!u,a=h.products??[];return Y("div",{id:r,role:"listbox","data-aia-dropdown":"","data-options-position":k,"data-mode":q,"data-aia-loading":h.isLoading?"":void 0,"data-aia-has-products":a.length>0?"":void 0,className:`${$?"magicx-aia ":""}${ie.dropdown} ${B?ie.visible:""} ${o??""}`,onMouseDown:_=>_.preventDefault(),children:st(nt,{space:"8px",children:[(N||i)&&st(fe,{noWrap:!0,className:ie.pillBar,"data-aia-pillbar":"",children:[N&&Y("span",{className:ie.pillScroll,"data-aia-pill-scroll":"",children:Y(Ae,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:h.isLoading})}),i&&Y("button",{type:"button",tabIndex:-1,className:ie.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":p?`Skip ${p}`:"Skip",onClick:y,children:"skip"})]}),u&&Y(rt,{options:F,activeIndex:h.activeIndex,onSelect:t,onHighlight:n,listboxId:r,loading:h.isLoading,groupKey:z?`${z.type} ${z.text}`:""}),f&&Y("div",{className:ie.skeletonBars,"data-aia-skeleton-bars":"",children:Jt.map(_=>Y("span",{className:ie.skeletonBar,style:{width:_}},`bar-${_}`))}),Y(et,{products:a,listboxId:r,onSelect:V??Xt,onFocusChange:C,focusable:B}),Y(Xe,{isOptionHighlighted:D,isInputEmpty:h.isInputEmpty})]})})}import{buildSubmitResult as la,ModeController as da,setCursorOffset as pa}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 {
1623
+ `,document.head.appendChild(e)}import{jsx as ra}from"react/jsx-runtime";function ct({space:e,align:n="stretch",className:a,children:i,...s}){let o=e?{"--aia-stack-space":e}:void 0;return ra("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":n,style:o,...s,children:i})}import{jsx as j,jsxs as mt}from"react/jsx-runtime";var da=[159,119,164],pa=()=>{},ut=()=>{};function ca(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,i]=la(n);if(na(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>i(s.matches);return s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function He({suggestions:e,activeIndex:n,onSelect:a,onHighlight:i,isOpen:s,id:o,className:r,pills:g,onPillClick:b,showPills:v=!0,onSkip:m,showSkipButton:f=!0,skipDisabled:E=!1,activeSelected:R=!1,isLoading:T=!1,isInputEmpty:L=!1,products:B,onProductSelect:Q,onProductFocusChange:ie,formatType:z="options",dateView:k=null,selectedDateIso:U=null,onPreviousMonth:u,onNextMonth:re,optionsPosition:Y="below",mode:J}){let S=ca(J),ne=S!==void 0,X=e[0]?.options??[],Z=!!(g&&g.length>0&&b),ee=!!(B&&B.length>0),A=s&&(X.length>0||v&&Z||T||ee),G={suggestions:e,activeIndex:n,pills:g,showPills:v,showSkipButton:f,skipDisabled:E,activeSelected:R,isLoading:T,isInputEmpty:L,products:B,formatType:z,dateView:k,selectedDateIso:U},V=sa(G);A&&(V.current=G);let h=A?G:V.current,N=h.suggestions[0],D=N?.options??[],se=h.activeIndex>=0&&!!D[h.activeIndex]?.is_tappable,l=!!(h.pills&&h.pills.length>0&&b),c=h.showPills&&l,t=h.showPills&&!l&&h.isLoading,w=c||t,x=l&&h.showSkipButton&&!h.isInputEmpty&&!!m,_=h.pills?.[0]?.text,d=h.formatType==="date"&&h.dateView!=null,O=D.length>0&&!d,q=D.length>0&&d,le=h.isLoading&&!O&&!q,he=h.products??[];return j("div",{id:o,role:"listbox","data-aia-dropdown":"","data-options-position":Y,"data-mode":S,"data-aia-loading":h.isLoading?"":void 0,"data-aia-has-products":he.length>0?"":void 0,className:`${ne?"magicx-aia ":""}${ce.dropdown} ${A?ce.visible:""} ${r??""}`,onMouseDown:F=>F.preventDefault(),children:mt(ct,{space:"8px",children:[(w||x)&&mt(we,{noWrap:!0,className:ce.pillBar,"data-aia-pillbar":"",children:[w&&j("span",{className:ce.pillScroll,"data-aia-pill-scroll":"",children:j(Ce,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:h.isLoading})}),x&&j("button",{type:"button",tabIndex:-1,className:ce.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":_?`Skip ${_}`:"Skip",onClick:m,children:"skip"})]}),O&&j(pt,{options:D,activeIndex:h.activeIndex,onSelect:a,onHighlight:i,listboxId:o,loading:h.isLoading,groupKey:N?`${N.type} ${N.text}`:""}),q&&h.dateView&&j(et,{options:D,activeIndex:h.activeIndex,listboxId:o,view:h.dateView,selectedIso:h.selectedDateIso??null,onSelect:a,onHighlight:i,onPreviousMonth:u??ut,onNextMonth:re??ut}),le&&j("div",{className:ce.skeletonBars,"data-aia-skeleton-bars":"",children:da.map(F=>j("span",{className:ce.skeletonBar,style:{width:F}},`bar-${F}`))}),j(rt,{products:he,listboxId:o,onSelect:Q??pa,onFocusChange:ie,focusable:A}),j(at,{isOptionHighlighted:se,isInputEmpty:h.isInputEmpty})]})})}import{buildSubmitResult as ka,ModeController as _a,setCursorOffset as Pa}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
1624
  flex-shrink: 0;
1478
1625
  width: 32px;
1479
1626
  height: 32px;
@@ -1508,5 +1655,5 @@ import{buildSubmitResult as Wo,withSkippedParams as Uo}from"@magicx-eng/ai-autoc
1508
1655
  );
1509
1656
  cursor: default;
1510
1657
  }
1511
- `,document.head.appendChild(e)}var lt={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Oe}from"react/jsx-runtime";function dt({disabled:e,onClick:s}){return Oe("button",{type:"button","data-aia-submit":"",className:lt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),s()},"aria-label":"Submit",children:Oe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Oe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Yt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as ut,useEffect as ve,useRef as R,useState as ea}from"react";import{useRef as pt}from"react";function ct(e){let s=pt(e);s.current=e;let t=pt(null);t.current===null&&(t.current={fetch:(l,r)=>{let o=s.current;return o?o.fetch(l,r):Promise.reject(new Error("products config removed"))},transform:l=>s.current?.transform(l)??[],get limit(){return s.current?.limit}});let n=e!==void 0;return{config:n?t.current:void 0,enabled:n}}var ta={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 He({onSubmit:e,onError:s,optionOverrides:t,maskCompletedText:n,apiConfig:l,additionalContext:r,generateStartingStateOptions:o,columns:g=2,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:y,showNonTappableOptions:b,showSkipButton:T,onFocus:U,onBlur:K,value:A,completedParams:I,onChange:V,onParamsChange:C,products:k,onProductSelect:W,source:q,setCursor:$}){let c=R(null),[ee,E]=ea(null),B=R(e);B.current=e;let L=R(s);L.current=s;let j=R(V);j.current=V;let h=R(C);h.current=C;let z=R(U);z.current=U;let F=R(K);F.current=K;let D=R($);D.current=$;let M=R(W);M.current=W;let Q=ct(k);ve(()=>{if(typeof document>"u")return;let d=new Yt(document.createElement("div"),{renderMode:"headless",apiConfig:l,additionalContext:r,generateStartingStateOptions:o,optionOverrides:t,maskCompletedText:n,columns:g,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:y,showNonTappableOptions:b,source:q,value:A,completedParams:I,onSubmit:(...P)=>B.current?.(...P),onError:(...P)=>L.current?.(...P),onChange:(...P)=>j.current?.(...P),onParamsChange:(...P)=>h.current?.(...P),onFocus:()=>z.current?.(),onBlur:()=>F.current?.(),onProductSelect:P=>M.current?.(P),setCursor:P=>D.current?.(P),products:Q.config});c.current=d,E(d.getState());let S=d.subscribe(P=>E(P));return()=>{S(),d.destroy(),c.current===d&&(c.current=null)}},[]),ve(()=>{A!==void 0&&c.current?.setValue(A)},[A]),ve(()=>{I!==void 0&&c.current?.setCompletedParams(I)},[I]);let J=JSON.stringify(l??null),N;try{N=JSON.stringify(r??null)}catch{N="[unstringifiable]"}let i=R(t),p=R(0);if(t!==i.current){let d=i.current,S=t,P=Object.keys(d??{}),ce=Object.keys(S??{});(P.length!==ce.length||ce.some(ae=>!d?.[ae]||S[ae]!==d[ae]))&&p.current++,i.current=t}ve(()=>{c.current?.update({apiConfig:l,additionalContext:r,generateStartingStateOptions:o,optionOverrides:t,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:y,showNonTappableOptions:b})},[J,N,o,p.current,v,x,y,b]);let u=R(!1);ve(()=>{if(!u.current){u.current=!0;return}c.current?.update({products:Q.config})},[Q.enabled]);let f=R(null);f.current===null&&(f.current={handleTextChange:d=>c.current?.handleTextChange(d),handleKeyDown:d=>{let S="nativeEvent"in d?d.nativeEvent:d;c.current?.handleKeyDown(S)},setFocused:d=>c.current?.setFocused(d),startEditingParam:d=>c.current?.startEditingParam(d),exitEditMode:()=>c.current?.exitEditMode(),handleCaretAfterInput:d=>c.current?.handleCaretAfterInput(d),handleCaretMove:d=>c.current?.handleCaretMove(d),replaceEditingRange:d=>c.current?.replaceEditingRange(d)??!1,setActivePill:d=>c.current?.setActivePill(d),skipActivePill:()=>c.current?.skipActivePill(),removeLastParam:()=>c.current?.removeLastParam(),clearNewParamId:()=>c.current?.clearNewParamId(),reset:()=>c.current?.reset(),selectOption:d=>c.current?.selectOption(d),selectProduct:d=>c.current?.selectProduct(d),setActiveDropdownIndex:d=>c.current?.setActiveDropdownIndex(d),handleFocus:()=>c.current?.setFocused(!0),handleBlur:()=>c.current?.setFocused(!1)});let a=f.current,_=ut(d=>{let S=d.target.value,ce=S.length>0&&!d.nativeEvent?.isComposing&&S[0]!==S[0].toUpperCase()?S[0].toUpperCase()+S.slice(1):S;c.current?.handleTextChange(ce)},[]),se=ut(d=>{c.current?.handleKeyDown(d.nativeEvent)},[]),X=c.current,m=ee??ta,we=A!==void 0?A:m.text,he=I!==void 0?I:m.completedParams,de=m.actionableSuggestions,ye=de[0],pe=X?.listboxId??"",De=m.activeDropdownIndex>=0&&X?`${pe}-option-${m.activeDropdownIndex}`:void 0,te=m.editingParam,ge=te?{type:te.suggestionType,text:te.suggestionPlaceholder,required:!0,options:te.options}:null,ke=ge??ye,Re=ge?[ge]:de,_e=!X||m.isLoading&&!m.editingParam&&!m.inSelectionAnimation;return{completedParams:he,skippedParams:m.skippedParams,suggestionPills:de,setActivePill:a.setActivePill,skipActivePill:a.skipActivePill,removeLastParam:a.removeLastParam,segments:m.segments,newParamId:m.newParamId,clearNewParamId:a.clearNewParamId,suggestions:m.suggestions,activeIndex:m.activeDropdownIndex,isReady:m.isReady,isLoading:_e,isFocused:m.isFocused,isDropdownOpen:m.isDropdownOpen,isActivePillSelected:m.isActivePillSelected,placeholderText:m.placeholderText,listboxId:pe,error:m.error,products:m.products,selectProduct:a.selectProduct,handleTextChange:a.handleTextChange,handleKeyDown:a.handleKeyDown,setFocused:a.setFocused,editingParam:te,editingAnchor:m.editingAnchor,caretOffset:m.caretOffset,startEditingParam:a.startEditingParam,exitEditMode:a.exitEditMode,handleCaretAfterInput:a.handleCaretAfterInput,handleCaretMove:a.handleCaretMove,replaceEditingRange:a.replaceEditingRange,inputProps:{value:we,placeholder:m.placeholderText||void 0,onChange:_,onKeyDown:se,onFocus:a.handleFocus,onBlur:a.handleBlur,role:"combobox","aria-expanded":m.isDropdownOpen,"aria-activedescendant":De,"aria-autocomplete":"list","aria-controls":pe},reset:a.reset,dropdownProps:{suggestions:ke?[{...ke,options:m.filteredOptions}]:[],activeIndex:m.activeDropdownIndex,onSelect:a.selectOption,onHighlight:a.setActiveDropdownIndex,isOpen:m.isDropdownOpen,id:pe,pills:Re,activeSelected:m.isActivePillSelected,onPillClick:a.setActivePill,onSkip:a.skipActivePill,showSkipButton:(T??!0)&&!te,skipDisabled:m.inSelectionAnimation,isLoading:_e,isInputEmpty:we.trim().length===0,products:m.products,onProductSelect:a.selectProduct,onProductFocusChange:a.setFocused,optionsPosition:x??"below"}}}import{extractPlainText as mt,getCursorOffset as ht,plainTextLength as aa,renderEditableContent as oa,setCursorOffset as gt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as G,useEffect as Ge,useLayoutEffect as Ke,useRef as ue}from"react";var Ee;function ia(){if(Ee!==void 0)return Ee;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ee=e.contentEditable==="plaintext-only",Ee}function ft(e){let{segments:s,newParamId:t,editingParam:n,editingAnchor:l,caretOffset:r,placeholderText:o,isFocused:g,isDropdownOpen:v,listboxId:x,activeDescendantId:y,autoFocus:b,handleTextChange:T,handleKeyDown:U,handleCaretAfterInput:K,handleCaretMove:A,startEditingParam:I,replaceEditingRange:V,setFocused:C}=e,k=ue(null),W=ue(!1),q=ue(""),$=ue(""),c=ue(null),ee=ue(0);c.current=r,Ge(()=>{if(!b)return;let i=k.current;if(!i)return;document.activeElement===i?C(!0):i.focus();let p=i.ownerDocument??document,u=p.getSelection(),f=u&&u.rangeCount>0&&i.contains(u.anchorNode);if(u&&!f){let a=p.createRange();a.selectNodeContents(i),a.collapse(!0),u.removeAllRanges(),u.addRange(a)}},[b,C]),Ge(()=>{let i=k.current;if(!i)return;let p=i.ownerDocument??document,u=()=>{let f=p.getSelection();if(!f||f.rangeCount===0||!f.anchorNode||!i.contains(f.anchorNode))return;let a=f.anchorNode,_=a.nodeType===Node.ELEMENT_NODE?a:a.parentElement,X=(f.isCollapsed?_?.closest('strong[data-seg="completed"][data-param-id]'):null)?.dataset.paramId??null;if(X&&X!==n?.id){I(X);return}performance.now()-ee.current<50||A(ht(i))};return p.addEventListener("selectionchange",u),()=>p.removeEventListener("selectionchange",u)},[n,I,A]),Ke(()=>{let i=k.current;i&&oa({input:i,segments:s,newParamId:t,editingParamId:n?.id??null,placeholderText:o??"",isFocused:g})},[s,t,n,o,g]),Ke(()=>{let i=q.current,p=t??"";if(q.current=p,!p||p===i)return;let u=k.current;if(!u)return;u.focus();let f=c.current??aa(u);gt(u,f)},[t]),Ke(()=>{let i=$.current,p=n?.id??"";if($.current=p,!p||p===i||l==null)return;let u=k.current;u&&gt(u,l)},[n,l]);let E=G(()=>{if(W.current)return;let i=k.current;if(!i)return;let p=mt(i),f=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;T(f)},[T]),B=G(()=>{ee.current=performance.now(),E();let i=k.current;i&&K(ht(i))},[E,K]);Ge(()=>{let i=k.current;if(!i)return;let p=u=>{let f=u,a=f.inputType;if(a==="insertParagraph"||a==="insertLineBreak"||a==="insertFromDrop"){u.preventDefault();return}if(a.startsWith("insert")||a.startsWith("delete")){let _=a.startsWith("delete")?"":f.data??"";V(_)&&u.preventDefault()}};return i.addEventListener("beforeinput",p),()=>i.removeEventListener("beforeinput",p)},[V]);let L=G(()=>{W.current=!0},[]),j=G(()=>{W.current=!1,E()},[E]),h=G(i=>{i.preventDefault();let p=k.current;if(!p)return;let u=(i.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let f=p.ownerDocument??document,a=f.getSelection();if(!a||a.rangeCount===0)return;let _=a.getRangeAt(0);if(!p.contains(_.startContainer))return;_.deleteContents();let se=f.createTextNode(u);_.insertNode(se),_.setStartAfter(se),_.collapse(!0),a.removeAllRanges(),a.addRange(_),E()},[E]),z=G(i=>U(i),[U]),F=G(()=>C(!0),[C]),D=G(()=>C(!1),[C]),M=G(()=>k.current?.focus(),[]),Q=G(()=>k.current?.blur(),[]),J=G(()=>{let i=k.current;return i?mt(i):""},[]),N=ia()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:N,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":x,"aria-expanded":v,"aria-activedescendant":y,spellCheck:!0,enterKeyHint:"send",onInput:B,onKeyDown:z,onCompositionStart:L,onCompositionEnd:j,onPaste:h,onFocus:F,onBlur:D},getPlainText:J,focus:M,blur:Q}}import{jsx as me,jsxs as Ue}from"react/jsx-runtime";function ca(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ua=ra(function({onSubmit:s,onError:t,optionOverrides:n,maskCompletedText:l,className:r,apiConfig:o,additionalContext:g,generateStartingStateOptions:v,columns:x,pillPlacement:y="dropdown",mode:b="auto",optionsPosition:T="below",animations:U=!0,dropdownTrigger:K,closeDropdownOnBlur:A,showNonTappableOptions:I,showSkipButton:V,autoFocus:C=!0,onFocus:k,onBlur:W,value:q,completedParams:$,onChange:c,onParamsChange:ee,products:E,onProductSelect:B,submitButton:L},j){let h=xe(null),z=xe(null),F=xe(()=>{}),D=xe(null),M=xe(null);bt(()=>{let w=h.current;if(w)return D.current?D.current.setMode(b):D.current=new da(w,b),()=>{D.current?.destroy(),D.current=null}},[b]);let Q=We(w=>{let oe=M.current?.current;oe&&(oe.focus(),pa(oe,w))},[]),{completedParams:J,skippedParams:N,suggestionPills:i,setActivePill:p,skipActivePill:u,segments:f,newParamId:a,clearNewParamId:_,placeholderText:se,isFocused:X,isDropdownOpen:m,isActivePillSelected:we,isLoading:he,activeIndex:de,listboxId:ye,handleTextChange:pe,handleKeyDown:De,setFocused:te,editingParam:ge,editingAnchor:ke,caretOffset:Re,startEditingParam:_e,handleCaretAfterInput:d,handleCaretMove:S,replaceEditingRange:P,dropdownProps:ce,reset:ae}=He({onSubmit:w=>F.current(w),onError:t,optionOverrides:n,maskCompletedText:l,apiConfig:o,additionalContext:g,generateStartingStateOptions:v,columns:x,dropdownTrigger:K,optionsPosition:T,closeDropdownOnBlur:A,showNonTappableOptions:I,showSkipButton:V,onFocus:k,onBlur:W,value:q,completedParams:$,onChange:c,onParamsChange:ee,products:E,onProductSelect:B,source:"full-sdk",setCursor:Q});bt(()=>{if(!a)return;let w=window.setTimeout(()=>_(),650);return()=>window.clearTimeout(w)},[a,_]);let vt=de>=0?`${ye}-option-${de}`:void 0,{inputRef:Te,editorProps:xt,focus:Pe,blur:Ve,getPlainText:qe}=ft({segments:f,newParamId:a,editingParam:ge,editingAnchor:ke,caretOffset:Re,placeholderText:se,isFocused:X,isDropdownOpen:m,listboxId:ye,activeDescendantId:vt,autoFocus:C,handleTextChange:pe,handleKeyDown:De,handleCaretAfterInput:d,handleCaretMove:S,startEditingParam:_e,replaceEditingRange:P,setFocused:te});M.current=Te,sa(()=>{let w=z.current,oe=Te.current;if(!w||!oe)return;let $e=()=>{let Qe=w.firstElementChild;if(!Qe)return;let _t=Qe.getBoundingClientRect(),Pt=oe.getBoundingClientRect();_t.top>=Pt.bottom-2?w.setAttribute("data-aia-pill-wrapped",""):w.removeAttribute("data-aia-pill-wrapped")};$e();let je=new ResizeObserver($e);return je.observe(oe),()=>je.disconnect()},[f,i.length,he,Te]),na(j,()=>({focus:Pe,blur:Ve,reset:ae,setMode:w=>D.current?.setMode(w),skipActivePill:u}),[Pe,Ve,ae,u]);let Ie=!!f.length||J.length>0,Le=We(()=>{if(!Ie)return;let w=qe();s(la(w,J,N)),ae()},[Ie,J,N,s,ae,qe]);F.current=Le;let wt=We(w=>{w.target?.closest("[data-aia-pill]")||Pe()},[Pe]),yt=y==="inline",kt=y==="dropdown";return Ue("div",{ref:h,className:`magicx-aia ${le.container} ${r??""}`,"data-pill-placement":y,"data-options-position":T,"data-animations":U?"on":"off","data-mode":ca(b),children:[me(Ne,{...ce,showPills:kt}),Ue("div",{className:le.inputWrapper,onClick:wt,children:[Ue("div",{className:le.editorArea,"data-aia-editor":"",children:[me("div",{...xt,className:le.input,"data-aia-input":""}),yt&&(he||i.length>0)&&me("span",{ref:z,className:le.pillListContainer,"data-aia-pill-list-container":"",children:me(Ae,{pills:i,activePillIndex:0,activeSelected:we,onSelectPill:p,loading:he})})]}),L===null?null:L===void 0?me(dt,{disabled:!Ie,onClick:Le}):me("span",{"data-aia-submit":"",className:le.submitSlot,onClick:w=>{Ie&&(w.stopPropagation(),Le())},children:L})]})]})});export{ua as AIAutocomplete,Ne as AIAutocompleteDropdown,Wo as buildSubmitResult,He as useAIAutocomplete,Uo as withSkippedParams};
1658
+ `,document.head.appendChild(e)}var ht={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ke}from"react/jsx-runtime";function gt({disabled:e,onClick:n}){return Ke("button",{type:"button","data-aia-submit":"",className:ht.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),n()},"aria-label":"Submit",children:Ke("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Ke("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ua,selectedIsoFromText as ma}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as vt,useEffect as ke,useRef as M,useState as ha}from"react";import{useRef as ft}from"react";function bt(e){let n=ft(e);n.current=e;let a=ft(null);a.current===null&&(a.current={fetch:(s,o)=>{let r=n.current;return r?r.fetch(s,o):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?a.current:void 0,enabled:i}}var ga={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 We({onSubmit:e,onError:n,optionOverrides:a,maskCompletedText:i,apiConfig:s,additionalContext:o,columns:r=2,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m,showSkipButton:f,onFocus:E,onBlur:R,value:T,completedParams:L,onChange:B,onParamsChange:Q,products:ie,onProductSelect:z,source:k,setCursor:U}){let u=M(null),[re,Y]=ha(null),J=M(e);J.current=e;let S=M(n);S.current=n;let ne=M(B);ne.current=B;let X=M(Q);X.current=Q;let Z=M(E);Z.current=E;let ee=M(R);ee.current=R;let A=M(U);A.current=U;let G=M(z);G.current=z;let V=bt(ie);ke(()=>{if(typeof document>"u")return;let p=new ua(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:o,optionOverrides:a,maskCompletedText:i,columns:r,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m,source:k,value:T,completedParams:L,onSubmit:(...P)=>J.current?.(...P),onError:(...P)=>S.current?.(...P),onChange:(...P)=>ne.current?.(...P),onParamsChange:(...P)=>X.current?.(...P),onFocus:()=>Z.current?.(),onBlur:()=>ee.current?.(),onProductSelect:P=>G.current?.(P),setCursor:P=>A.current?.(P),products:V.config});u.current=p,Y(p.getState());let C=p.subscribe(P=>Y(P));return()=>{C(),p.destroy(),u.current===p&&(u.current=null)}},[]),ke(()=>{T!==void 0&&u.current?.setValue(T)},[T]),ke(()=>{L!==void 0&&u.current?.setCompletedParams(L)},[L]);let h=JSON.stringify(s??null),N;try{N=JSON.stringify(o??null)}catch{N="[unstringifiable]"}let D=M(a),se=M(0);if(a!==D.current){let p=D.current,C=a,P=Object.keys(p??{}),fe=Object.keys(C??{});(P.length!==fe.length||fe.some(de=>!p?.[de]||C[de]!==p[de]))&&se.current++,D.current=a}ke(()=>{u.current?.update({apiConfig:s,additionalContext:o,optionOverrides:a,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m})},[h,N,se.current,g,b,v,m]);let l=M(!1);ke(()=>{if(!l.current){l.current=!0;return}u.current?.update({products:V.config})},[V.enabled]);let c=M(null);c.current===null&&(c.current={handleTextChange:p=>u.current?.handleTextChange(p),handleKeyDown:p=>{let C="nativeEvent"in p?p.nativeEvent:p;u.current?.handleKeyDown(C)},setFocused:p=>u.current?.setFocused(p),startEditingParam:p=>u.current?.startEditingParam(p),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:p=>u.current?.handleCaretAfterInput(p),handleCaretMove:p=>u.current?.handleCaretMove(p),replaceEditingRange:p=>u.current?.replaceEditingRange(p)??!1,setActivePill:p=>u.current?.setActivePill(p),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),selectOption:p=>u.current?.selectOption(p),selectProduct:p=>u.current?.selectProduct(p),setActiveDropdownIndex:p=>u.current?.setActiveDropdownIndex(p),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let t=c.current,w=vt(p=>{let C=p.target.value,fe=C.length>0&&!p.nativeEvent?.isComposing&&C[0]!==C[0].toUpperCase()?C[0].toUpperCase()+C.slice(1):C;u.current?.handleTextChange(fe)},[]),x=vt(p=>{u.current?.handleKeyDown(p.nativeEvent)},[]),_=u.current,d=re??ga,O=T!==void 0?T:d.text,q=L!==void 0?L:d.completedParams,le=d.actionableSuggestions,he=le[0],F=_?.listboxId??"",Re=d.activeDropdownIndex>=0&&_?`${F}-option-${d.activeDropdownIndex}`:void 0,te=d.editingParam,ae=d.editingIdentified,xe=te?{type:te.suggestionType,text:te.suggestionPlaceholder,required:!0,options:te.options}:ae?{type:ae.type,text:ae.type,required:!0,options:[]}:null,Pe=xe??he,Le=xe?[xe]:le,Ie=!_||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation;return{completedParams:q,skippedParams:d.skippedParams,suggestionPills:le,setActivePill:t.setActivePill,skipActivePill:t.skipActivePill,removeLastParam:t.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:t.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Ie,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:F,error:d.error,products:d.products,selectProduct:t.selectProduct,handleTextChange:t.handleTextChange,handleKeyDown:t.handleKeyDown,setFocused:t.setFocused,editingParam:te,editingIdentified:ae,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:t.startEditingParam,exitEditMode:t.exitEditMode,handleCaretAfterInput:t.handleCaretAfterInput,handleCaretMove:t.handleCaretMove,replaceEditingRange:t.replaceEditingRange,inputProps:{value:O,placeholder:d.placeholderText||void 0,onChange:w,onKeyDown:x,onFocus:t.handleFocus,onBlur:t.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":Re,"aria-autocomplete":"list","aria-controls":F},reset:t.reset,dropdownProps:{suggestions:Pe?[{...Pe,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:t.selectOption,onHighlight:t.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:F,pills:Le,activeSelected:d.isActivePillSelected,onPillClick:t.setActivePill,onSkip:t.skipActivePill,showSkipButton:(f??!0)&&!te&&!ae,skipDisabled:d.inSelectionAnimation,isLoading:Ie,isInputEmpty:O.trim().length===0,products:d.products,onProductSelect:t.selectProduct,onProductFocusChange:t.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:ae?ae.iso:ma(te?.text),onPreviousMonth:t.showPreviousMonth,onNextMonth:t.showNextMonth,optionsPosition:b??"below"}}}import{extractPlainText as xt,getCursorOffset as wt,plainTextLength as fa,renderEditableContent as ba,setCursorOffset as yt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as W,useEffect as Ue,useLayoutEffect as Ve,useRef as be}from"react";var Te;function va(){if(Te!==void 0)return Te;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Te=e.contentEditable==="plaintext-only",Te}function kt(e){let{segments:n,newParamId:a,editingParam:i,editingIdentified:s,editingAnchor:o,caretOffset:r,placeholderText:g,isFocused:b,isDropdownOpen:v,listboxId:m,activeDescendantId:f,autoFocus:E,handleTextChange:R,handleKeyDown:T,handleCaretAfterInput:L,handleCaretMove:B,startEditingParam:Q,replaceEditingRange:ie,setFocused:z}=e,k=be(null),U=be(!1),u=be(""),re=be(""),Y=be(null),J=be(0);Y.current=r,Ue(()=>{if(!E)return;let l=k.current;if(!l)return;document.activeElement===l?z(!0):l.focus();let c=l.ownerDocument??document,t=c.getSelection(),w=t&&t.rangeCount>0&&l.contains(t.anchorNode);if(t&&!w){let x=c.createRange();x.selectNodeContents(l),x.collapse(!0),t.removeAllRanges(),t.addRange(x)}},[E,z]),Ue(()=>{let l=k.current;if(!l)return;let c=l.ownerDocument??document,t=()=>{let w=c.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!l.contains(w.anchorNode))return;let x=w.anchorNode,_=x.nodeType===Node.ELEMENT_NODE?x:x.parentElement,O=(w.isCollapsed?_?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,q=i?.id??s?.id??null;if(O&&O!==q){Q(O);return}performance.now()-J.current<50||B(wt(l))};return c.addEventListener("selectionchange",t),()=>c.removeEventListener("selectionchange",t)},[i,s,Q,B]),Ve(()=>{let l=k.current;l&&ba({input:l,segments:n,newParamId:a,editingParamId:i?.id??null,placeholderText:g??"",isFocused:b})},[n,a,i,g,b]),Ve(()=>{let l=u.current,c=a??"";if(u.current=c,!c||c===l)return;let t=k.current;if(!t)return;t.focus();let w=Y.current??fa(t);yt(t,w)},[a]),Ve(()=>{let l=re.current,c=i?.id??"";if(re.current=c,!c||c===l||o==null)return;let t=k.current;t&&yt(t,o)},[i,o]);let S=W(()=>{if(U.current)return;let l=k.current;if(!l)return;let c=xt(l),w=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;R(w)},[R]),ne=W(()=>{J.current=performance.now(),S();let l=k.current;l&&L(wt(l))},[S,L]);Ue(()=>{let l=k.current;if(!l)return;let c=t=>{let w=t,x=w.inputType;if(x==="insertParagraph"||x==="insertLineBreak"||x==="insertFromDrop"){t.preventDefault();return}if(x.startsWith("insert")||x.startsWith("delete")){let _=x.startsWith("delete")?"":w.data??"";ie(_)&&t.preventDefault()}};return l.addEventListener("beforeinput",c),()=>l.removeEventListener("beforeinput",c)},[ie]);let X=W(()=>{U.current=!0},[]),Z=W(()=>{U.current=!1,S()},[S]),ee=W(l=>{l.preventDefault();let c=k.current;if(!c)return;let t=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!t)return;let w=c.ownerDocument??document,x=w.getSelection();if(!x||x.rangeCount===0)return;let _=x.getRangeAt(0);if(!c.contains(_.startContainer))return;_.deleteContents();let d=w.createTextNode(t);_.insertNode(d),_.setStartAfter(d),_.collapse(!0),x.removeAllRanges(),x.addRange(_),S()},[S]),A=W(l=>T(l),[T]),G=W(()=>z(!0),[z]),V=W(()=>z(!1),[z]),h=W(()=>k.current?.focus(),[]),N=W(()=>k.current?.blur(),[]),D=W(()=>{let l=k.current;return l?xt(l):""},[]),se=va()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:se,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":v,"aria-activedescendant":f,spellCheck:!0,enterKeyHint:"send",onInput:ne,onKeyDown:A,onCompositionStart:X,onCompositionEnd:Z,onPaste:ee,onFocus:G,onBlur:V},getPlainText:D,focus:h,blur:N}}import{jsx as ve,jsxs as $e}from"react/jsx-runtime";function Ia(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Sa=xa(function({onSubmit:n,onError:a,optionOverrides:i,maskCompletedText:s,className:o,apiConfig:r,additionalContext:g,columns:b,pillPlacement:v="dropdown",mode:m="auto",optionsPosition:f="below",animations:E=!0,dropdownTrigger:R,closeDropdownOnBlur:T,showNonTappableOptions:L,showSkipButton:B,autoFocus:Q=!0,onFocus:ie,onBlur:z,value:k,completedParams:U,onChange:u,onParamsChange:re,products:Y,onProductSelect:J,submitButton:S},ne){let X=_e(null),Z=_e(null),ee=_e(()=>{}),A=_e(null),G=_e(null);_t(()=>{let y=X.current;if(y)return A.current?A.current.setMode(m):A.current=new _a(y,m),()=>{A.current?.destroy(),A.current=null}},[m]);let V=qe(y=>{let pe=G.current?.current;pe&&(pe.focus(),Pa(pe,y))},[]),{completedParams:h,skippedParams:N,suggestionPills:D,setActivePill:se,skipActivePill:l,segments:c,newParamId:t,clearNewParamId:w,placeholderText:x,isFocused:_,isDropdownOpen:d,isActivePillSelected:O,isLoading:q,activeIndex:le,listboxId:he,handleTextChange:F,handleKeyDown:Re,setFocused:te,editingParam:ae,editingIdentified:xe,editingAnchor:Pe,caretOffset:Le,startEditingParam:Ie,handleCaretAfterInput:p,handleCaretMove:C,replaceEditingRange:P,dropdownProps:fe,reset:de}=We({onSubmit:y=>ee.current(y),onError:a,optionOverrides:i,maskCompletedText:s,apiConfig:r,additionalContext:g,columns:b,dropdownTrigger:R,optionsPosition:f,closeDropdownOnBlur:T,showNonTappableOptions:L,showSkipButton:B,onFocus:ie,onBlur:z,value:k,completedParams:U,onChange:u,onParamsChange:re,products:Y,onProductSelect:J,source:"full-sdk",setCursor:V});_t(()=>{if(!t)return;let y=window.setTimeout(()=>w(),650);return()=>window.clearTimeout(y)},[t,w]);let Pt=le>=0?`${he}-option-${le}`:void 0,{inputRef:ze,editorProps:It,focus:Se,blur:je,getPlainText:Qe}=kt({segments:c,newParamId:t,editingParam:ae,editingIdentified:xe,editingAnchor:Pe,caretOffset:Le,placeholderText:x,isFocused:_,isDropdownOpen:d,listboxId:he,activeDescendantId:Pt,autoFocus:Q,handleTextChange:F,handleKeyDown:Re,handleCaretAfterInput:p,handleCaretMove:C,startEditingParam:Ie,replaceEditingRange:P,setFocused:te});G.current=ze,ya(()=>{let y=Z.current,pe=ze.current;if(!y||!pe)return;let Ye=()=>{let Xe=y.firstElementChild;if(!Xe)return;let Ct=Xe.getBoundingClientRect(),Et=pe.getBoundingClientRect();Ct.top>=Et.bottom-2?y.setAttribute("data-aia-pill-wrapped",""):y.removeAttribute("data-aia-pill-wrapped")};Ye();let Je=new ResizeObserver(Ye);return Je.observe(pe),()=>Je.disconnect()},[c,D.length,q,ze]),wa(ne,()=>({focus:Se,blur:je,reset:de,setMode:y=>A.current?.setMode(y),skipActivePill:l}),[Se,je,de,l]);let Ae=!!c.length||h.length>0,Ne=qe(()=>{if(!Ae)return;let y=Qe();n(ka(y,h,N)),de()},[Ae,h,N,n,de,Qe]);ee.current=Ne;let St=qe(y=>{y.target?.closest("[data-aia-pill]")||Se()},[Se]),At=v==="inline",Dt=v==="dropdown";return $e("div",{ref:X,className:`magicx-aia ${ge.container} ${o??""}`,"data-pill-placement":v,"data-options-position":f,"data-animations":E?"on":"off","data-mode":Ia(m),children:[ve(He,{...fe,showPills:Dt}),$e("div",{className:ge.inputWrapper,onClick:St,children:[$e("div",{className:ge.editorArea,"data-aia-editor":"",children:[ve("div",{...It,className:ge.input,"data-aia-input":""}),At&&(q||D.length>0)&&ve("span",{ref:Z,className:ge.pillListContainer,"data-aia-pill-list-container":"",children:ve(Ce,{pills:D,activePillIndex:0,activeSelected:O,onSelectPill:se,loading:q})})]}),S===null?null:S===void 0?ve(gt,{disabled:!Ae,onClick:Ne}):ve("span",{"data-aia-submit":"",className:ge.submitSlot,onClick:y=>{Ae&&(y.stopPropagation(),Ne())},children:S})]})]})});export{Sa as AIAutocomplete,He as AIAutocompleteDropdown,vi as WEEKDAY_LABELS,pi as buildSubmitResult,ci as cellDay,ui as cellIso,mi as formatDate,hi as isoDate,gi as monthLabel,fi as parseDate,bi as parseLooseDate,We as useAIAutocomplete,xi as withSkippedParams};
1512
1659
  //# sourceMappingURL=index.mjs.map