@magicx-eng/ai-autocomplete-react 0.12.1 → 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.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Ue=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Ct=Object.prototype.hasOwnProperty;var Et=(e,a)=>{for(var t in a)Ue(e,t,{get:a[t],enumerable:!0})},Dt=(e,a,t,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of At(a))!Ct.call(e,i)&&i!==t&&Ue(e,i,{get:()=>a[i],enumerable:!(o=St(a,i))||o.enumerable});return e};var Rt=e=>Dt(Ue({},"__esModule",{value:!0}),e);var Gt={};Et(Gt,{AIAutocomplete:()=>vt,AIAutocompleteDropdown:()=>Be,buildSubmitResult:()=>Oe.buildSubmitResult,useAIAutocomplete:()=>Me,withSkippedParams:()=>Oe.withSkippedParams});module.exports=Rt(Gt);var Oe=require("@magicx-eng/ai-autocomplete-vanilla");var S=require("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
+ "use strict";var Qe=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var Nt=Object.prototype.hasOwnProperty;var Mt=(e,a)=>{for(var t in a)Qe(e,t,{get:a[t],enumerable:!0})},Bt=(e,a,t,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of zt(a))!Nt.call(e,n)&&n!==t&&Qe(e,n,{get:()=>a[n],enumerable:!(i=Lt(a,n))||i.enumerable});return e};var Gt=e=>Bt(Qe({},"__esModule",{value:!0}),e);var Yt={};Mt(Yt,{AIAutocomplete:()=>It,AIAutocompleteDropdown:()=>Fe,WEEKDAY_LABELS:()=>I.WEEKDAY_LABELS,buildSubmitResult:()=>I.buildSubmitResult,cellDay:()=>I.cellDay,cellIso:()=>I.cellIso,formatDate:()=>I.formatDate,isoDate:()=>I.isoDate,monthLabel:()=>I.monthLabel,parseDate:()=>I.parseDate,parseLooseDate:()=>I.parseLooseDate,useAIAutocomplete:()=>We,withSkippedParams:()=>I.withSkippedParams});module.exports=Gt(Yt);var I=require("@magicx-eng/ai-autocomplete-vanilla");var A=require("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 @@
179
179
  opacity: 0;
180
180
  }
181
181
  }
182
- `,document.head.appendChild(e)}var ue={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"};var xe=require("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 ke={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"};var Ae=require("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 @@
665
665
  opacity: 0.25;
666
666
  }
667
667
  }
668
- `,document.head.appendChild(e)}var de={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"};var fe=require("@magicx-eng/ai-autocomplete-vanilla"),Re=require("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 ve={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"};var U=require("@magicx-eng/ai-autocomplete-vanilla"),nt=require("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 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",highlighted:"DateGrid-module_highlighted_YIdtK",today:"DateGrid-module_today_iI3ME",selected:"DateGrid-module_selected_28KDn",pressed:"DateGrid-module_pressed_bEyyN"};var M=require("react/jsx-runtime"),Ot=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function st({options:e,activeIndex:a,listboxId:t,view:i,selectedIso:n,onSelect:r,onHighlight:s,onPreviousMonth:g,onNextMonth:b}){let v=(0,U.isoDate)(new Date);return(0,M.jsxs)("div",{className:C.datepicker,"data-aia-datepicker":"",children:[(0,M.jsxs)("div",{className:C.header,children:[(0,M.jsx)("button",{type:"button",tabIndex:-1,className:C.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:g,children:"\u2039"}),(0,M.jsx)("span",{className:C.month,"data-aia-date-month":"","aria-live":"polite",children:(0,U.monthLabel)(i)}),(0,M.jsx)("button",{type:"button",tabIndex:-1,className:C.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:b,children:"\u203A"})]}),(0,M.jsx)("div",{className:C.weekdays,"aria-hidden":"true",children:U.WEEKDAY_LABELS.map((m,f)=>(0,M.jsx)("span",{className:C.weekday,children:m},Ot[f]))}),(0,M.jsx)("div",{className:C.grid,"data-aia-date-grid":"",children:e.map((m,f)=>(0,M.jsx)(Ft,{option:m,id:`${t}-option-${f}`,index:f,isHighlighted:f===a&&m.is_tappable,isToday:(0,U.cellIso)(m)===v,isSelected:n!=null&&(0,U.cellIso)(m)===n,onSelect:r,onHighlight:s},(0,U.cellIso)(m)??`pad-${f}`))})]})}function Ft({option:e,id:a,index:t,isHighlighted:i,isToday:n,isSelected:r,onSelect:s,onHighlight:g}){let[b,v]=(0,nt.useState)(!1),m=(0,U.cellDay)(e);if(m==null)return(0,M.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${C.cell} ${C.blank}`});let f=()=>{v(!0),s(e),setTimeout(()=>v(!1),500)},z=[C.cell,C.day,i?C.highlighted:"",n?C.today:"",r?C.selected:"",b?C.pressed:""].filter(Boolean).join(" ");return(0,M.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:z,onClick:f,onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),f())},onMouseEnter:()=>g(t),children:(0,M.jsx)("span",{className:C.number,children:m})})}var Pe=require("@magicx-eng/ai-autocomplete-vanilla"),Me=require("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 @@
707
854
  justify-content: space-around;
708
855
  }
709
856
  }
710
- `,document.head.appendChild(e)}var Ve=require("react/jsx-runtime");function _e({gap:e,align:a="center",justify:t="start",noWrap:o=!1,inline:i=!1,className:s,children:r,...h}){let v=e?{"--aia-cluster-gap":e}:void 0,y={className:s?`aia-cluster ${s}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":o||void 0,"data-inline":i||void 0,style:v,...h};return i?(0,Ve.jsx)("span",{...y,children:r}):(0,Ve.jsx)("div",{...y,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
857
+ `,document.head.appendChild(e)}var Ye=require("react/jsx-runtime");function Ee({gap:e,align:a="center",justify:t="start",noWrap:i=!1,inline:n=!1,className:r,children:s,...g}){let b=e?{"--aia-cluster-gap":e}:void 0,v={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":i||void 0,"data-inline":n||void 0,style:b,...g};return n?(0,Ye.jsx)("span",{...v,children:s}):(0,Ye.jsx)("div",{...v,children:s})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
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 @@
837
984
  justify-content: flex-end;
838
985
  }
839
986
  }
840
- `,document.head.appendChild(e)}var ie={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"};var J=require("react/jsx-runtime");function tt({isOptionHighlighted:e=!1,isInputEmpty:a=!1}){let{key:t,hint:o}=(0,fe.getFooterHint)(e,a),[i,s]=(0,Re.useState)(fe.ATTRIBUTION_URL);return(0,Re.useEffect)(()=>{s((0,fe.buildAttributionUrl)())},[]),(0,J.jsx)("footer",{className:ie.footer,"data-aia-footer":"",children:(0,J.jsxs)(_e,{justify:"between",noWrap:!0,className:ie.row,children:[(0,J.jsxs)(_e,{gap:"5px",className:ie.hintGroup,children:[(0,J.jsx)("kbd",{className:ie.key,children:t}),(0,J.jsx)("span",{className:ie.hint,children:o})]}),(0,J.jsxs)("a",{className:ie.brandLink,href:i,target:"_blank",rel:"noopener noreferrer",children:[(0,J.jsx)("span",{className:ie.brand,children:"AI"}),(0,J.jsx)("span",{className:ie.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 pe={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"};var te=require("react/jsx-runtime");function lt({isOptionHighlighted:e=!1,isInputEmpty:a=!1}){let{key:t,hint:i}=(0,Pe.getFooterHint)(e,a),[n,r]=(0,Me.useState)(Pe.ATTRIBUTION_URL);return(0,Me.useEffect)(()=>{r((0,Pe.buildAttributionUrl)())},[]),(0,te.jsx)("footer",{className:pe.footer,"data-aia-footer":"",children:(0,te.jsxs)(Ee,{justify:"between",noWrap:!0,className:pe.row,children:[(0,te.jsxs)(Ee,{gap:"5px",className:pe.hintGroup,children:[(0,te.jsx)("kbd",{className:pe.key,children:t}),(0,te.jsx)("span",{className:pe.hint,children:i})]}),(0,te.jsxs)("a",{className:pe.brandLink,href:n,target:"_blank",rel:"noopener noreferrer",children:[(0,te.jsx)("span",{className:pe.brand,children:"AI"}),(0,te.jsx)("span",{className:pe.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 @@
894
1041
  opacity: 0;
895
1042
  }
896
1043
  }
897
- `,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"};var ot=require("react/jsx-runtime"),qe={selected:1,first:.7,next:.4,last:.2};function at({label:e,state:a,rounded:t,loading:o,onClick:i}){let s=[pe.pill,t?pe.rounded:"",o?pe.skeleton:""].filter(Boolean).join(" ");return(0,ot.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":o?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:s,style:{opacity:qe[a]},onMouseDown:r=>r.preventDefault(),onClick:o?void 0:i,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 {
1044
+ `,document.head.appendChild(e)}var xe={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"};var pt=require("react/jsx-runtime"),Je={selected:1,first:.7,next:.4,last:.2};function dt({label:e,state:a,rounded:t,loading:i,onClick:n}){let r=[xe.pill,t?xe.rounded:"",i?xe.skeleton:""].filter(Boolean).join(" ");return(0,pt.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:Je[a]},onMouseDown:s=>s.preventDefault(),onClick:i?void 0:n,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 @@
904
1051
  align-items: center;
905
1052
  vertical-align: middle;
906
1053
  }
907
- `,document.head.appendChild(e)}var $e={list:"PillList-module_list_qvLqO"};var Pe=require("react/jsx-runtime"),Tt=[125,69];function it(e){return e===0?"first":e===1?"next":"last"}function Te({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:o,rounded:i,loading:s}){return s&&e.length===0?(0,Pe.jsx)("span",{className:$e.list,"data-aia-pill-list-loading":"",children:Tt.map((r,h)=>(0,Pe.jsx)("span",{"data-aia-pill-skeleton":"",className:`${pe.pill} ${i?pe.rounded:""} ${pe.skeleton}`,style:{width:r,opacity:qe[it(h)]}},`skel-${r}`))}):(0,Pe.jsx)("span",{className:$e.list,"data-aia-pill-list-loading":s?"":void 0,children:e.map((r,h)=>{let v=!!o&&h===a;return(0,Pe.jsx)(at,{label:r.text,state:v?"selected":it(h),selected:v,rounded:i,loading:s,onClick:()=>t(h)},`${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
1054
+ `,document.head.appendChild(e)}var Xe={list:"PillList-module_list_qvLqO"};var Te=require("react/jsx-runtime"),Ht=[125,69];function ct(e){return e===0?"first":e===1?"next":"last"}function Be({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:i,rounded:n,loading:r}){return r&&e.length===0?(0,Te.jsx)("span",{className:Xe.list,"data-aia-pill-list-loading":"",children:Ht.map((s,g)=>(0,Te.jsx)("span",{"data-aia-pill-skeleton":"",className:`${xe.pill} ${n?xe.rounded:""} ${xe.skeleton}`,style:{width:s,opacity:Je[ct(g)]}},`skel-${s}`))}):(0,Te.jsx)("span",{className:Xe.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((s,g)=>{let b=!!i&&g===a;return(0,Te.jsx)(dt,{label:s.text,state:b?"selected":ct(g),selected:b,rounded:n,loading:r,onClick:()=>t(g)},`${s.type}-${s.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 @@
1071
1218
  var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
1072
1219
  );
1073
1220
  }
1074
- `,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"};var z=require("react/jsx-runtime");function rt({products:e,listboxId:a,onSelect:t,onFocusChange:o,focusable:i=!0}){if(e.length===0)return null;let s=`${a}-products-label`;return(0,z.jsxs)("section",{className:W.section,"data-aia-products":"",role:"group","aria-labelledby":s,children:[(0,z.jsx)("div",{className:W.label,id:s,children:"Products"}),(0,z.jsx)("div",{className:W.row,"data-aia-products-row":"",children:e.map((r,h)=>(0,z.jsx)(Lt,{product:r,id:`${a}-product-${h}`,onSelect:t,onFocusChange:o,focusable:i},r.id))})]})}function Lt({product:e,id:a,onSelect:t,onFocusChange:o,focusable:i}){let s=r=>{r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||r.button!==0||(r.preventDefault(),t(e))};return(0,z.jsxs)("a",{id:a,className:W.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:i?0:-1,onClick:s,onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),t(e))},onFocus:()=>o?.(!0),onBlur:r=>{r.relatedTarget?.closest("[data-aia-dropdown]")||o?.(!1)},children:[(0,z.jsx)("span",{className:W.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?(0,z.jsx)("img",{className:W.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),(0,z.jsxs)("span",{className:W.body,children:[e.vendor?(0,z.jsx)("span",{className:W.vendor,children:e.vendor}):null,(0,z.jsx)("span",{className:W.title,children:e.title}),e.price?(0,z.jsx)("span",{className:W.price,children:e.price}):null]})]})}var ve=require("@magicx-eng/ai-autocomplete-vanilla"),ze=require("react");var nt=require("@magicx-eng/ai-autocomplete-vanilla"),Le=require("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 Q={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"};var K=require("react/jsx-runtime");function ut({products:e,listboxId:a,onSelect:t,onFocusChange:i,focusable:n=!0}){if(e.length===0)return null;let r=`${a}-products-label`;return(0,K.jsxs)("section",{className:Q.section,"data-aia-products":"",role:"group","aria-labelledby":r,children:[(0,K.jsx)("div",{className:Q.label,id:r,children:"Products"}),(0,K.jsx)("div",{className:Q.row,"data-aia-products-row":"",children:e.map((s,g)=>(0,K.jsx)(Kt,{product:s,id:`${a}-product-${g}`,onSelect:t,onFocusChange:i,focusable:n},s.id))})]})}function Kt({product:e,id:a,onSelect:t,onFocusChange:i,focusable:n}){let r=s=>{s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.button!==0||(s.preventDefault(),t(e))};return(0,K.jsxs)("a",{id:a,className:Q.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:n?0:-1,onClick:r,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[(0,K.jsx)("span",{className:Q.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?(0,K.jsx)("img",{className:Q.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),(0,K.jsxs)("span",{className:Q.body,children:[e.vendor?(0,K.jsx)("span",{className:Q.vendor,children:e.vendor}):null,(0,K.jsx)("span",{className:Q.title,children:e.title}),e.price?(0,K.jsx)("span",{className:Q.price,children:e.price}):null]})]})}var Se=require("@magicx-eng/ai-autocomplete-vanilla"),Oe=require("react");var mt=require("@magicx-eng/ai-autocomplete-vanilla"),Ge=require("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 @@
1106
1253
  border-radius: 3px;
1107
1254
  }
1108
1255
  }
1109
- `,document.head.appendChild(e)}var lt=require("react/jsx-runtime");function st({min:e="16rem",max:a,gap:t,scroll:o=!1,maxHeight:i,scrollResetKey:s,cols:r,className:h,children:v,...y}){let k=(0,Le.useRef)(null);(0,Le.useLayoutEffect)(()=>{if(s===void 0)return;let M=k.current;M&&(M.scrollTop=0)},[s]);let w={"--aia-grid-min":e};return a&&(w["--aia-grid-max"]=a),t&&(w["--aia-grid-gap"]=t),i&&(w["--aia-grid-max-height"]=i),r&&(w.gridTemplateColumns=(0,nt.optionsGridTemplateColumns)(r)),(0,lt.jsx)("div",{ref:k,className:h?`aia-grid ${h}`:"aia-grid","data-scroll":o||void 0,style:w,...y,children:v})}var be=require("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)}var gt=require("react/jsx-runtime");function ht({min:e="16rem",max:a,gap:t,scroll:i=!1,maxHeight:n,scrollResetKey:r,cols:s,className:g,children:b,...v}){let m=(0,Ge.useRef)(null);(0,Ge.useLayoutEffect)(()=>{if(r===void 0)return;let z=m.current;z&&(z.scrollTop=0)},[r]);let f={"--aia-grid-min":e};return a&&(f["--aia-grid-max"]=a),t&&(f["--aia-grid-gap"]=t),n&&(f["--aia-grid-max-height"]=n),s&&(f.gridTemplateColumns=(0,mt.optionsGridTemplateColumns)(s)),(0,gt.jsx)("div",{ref:m,className:g?`aia-grid ${g}`:"aia-grid","data-scroll":i||void 0,style:f,...v,children:b})}var Ie=require("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 @@
1456
1603
  filter: brightness(0.55);
1457
1604
  }
1458
1605
  }
1459
- `,document.head.appendChild(e)}var U={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"};var ce=require("react/jsx-runtime");function dt({option:e,isHighlighted:a,onSelect:t,onHighlight:o,id:i,loading:s}){let[r,h]=(0,be.useState)(!1),v=(0,be.useRef)(void 0);(0,be.useEffect)(()=>()=>clearTimeout(v.current),[]);let y=()=>{s||!e.is_tappable||r||(h(!0),t(e),clearTimeout(v.current),v.current=setTimeout(()=>h(!1),500))},k=[U.item,a&&!s?U.highlighted:"",e.is_tappable?U.tappable:U.nonTappable,r?U.pressed:""].filter(Boolean).join(" ");return(0,ce.jsxs)("div",{id:i,role:"option","data-aia-option":"","data-aia-loading":s?"":void 0,"aria-selected":a,className:k,tabIndex:s||!e.is_tappable?-1:0,onClick:y,onKeyDown:w=>{!s&&e.is_tappable&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),y())},onMouseEnter:!s&&e.is_tappable?o:void 0,children:[(0,ce.jsx)("div",{className:U.streaks}),(0,ce.jsx)("div",{className:U.streaksVert}),(0,ce.jsxs)("span",{className:U.content,children:[(0,ce.jsx)("span",{className:U.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&(0,ce.jsx)("span",{className:U.tag,children:e.tag})]})]})}var je=require("react/jsx-runtime");function zt(){let[e,a]=(0,ze.useState)(ve.isOptionsGridMobileViewport);return(0,ze.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(ve.OPTIONS_GRID_MOBILE_QUERY),o=()=>a(t.matches);return o(),t.addEventListener("change",o),()=>t.removeEventListener("change",o)},[]),e}function pt({options:e,activeIndex:a,onSelect:t,onHighlight:o,listboxId:i,loading:s,groupKey:r}){let h=zt(),{cols:v,maxHeight:y}=(0,ve.computeOptionsGridLayout)(e.length,h);return(0,je.jsx)(st,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:r,cols:v,maxHeight:y,children:e.map((k,w)=>(0,je.jsx)(dt,{option:k,isHighlighted:w===a,onSelect:t,onHighlight:()=>o(w),id:`${i}-option-${w}`,loading:s},k.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 Y={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"};var we=require("react/jsx-runtime");function ft({option:e,isHighlighted:a,onSelect:t,onHighlight:i,id:n,loading:r}){let[s,g]=(0,Ie.useState)(!1),b=(0,Ie.useRef)(void 0);(0,Ie.useEffect)(()=>()=>clearTimeout(b.current),[]);let v=()=>{r||!e.is_tappable||s||(g(!0),t(e),clearTimeout(b.current),b.current=setTimeout(()=>g(!1),500))},m=[Y.item,a&&!r?Y.highlighted:"",e.is_tappable?Y.tappable:Y.nonTappable,s?Y.pressed:""].filter(Boolean).join(" ");return(0,we.jsxs)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":r?"":void 0,"aria-selected":a,className:m,tabIndex:r||!e.is_tappable?-1:0,onClick:v,onKeyDown:f=>{!r&&e.is_tappable&&(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),v())},onMouseEnter:!r&&e.is_tappable?i:void 0,children:[(0,we.jsx)("div",{className:Y.streaks}),(0,we.jsx)("div",{className:Y.streaksVert}),(0,we.jsxs)("span",{className:Y.content,children:[(0,we.jsx)("span",{className:Y.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&(0,we.jsx)("span",{className:Y.tag,children:e.tag})]})]})}var Ze=require("react/jsx-runtime");function Wt(){let[e,a]=(0,Oe.useState)(Se.isOptionsGridMobileViewport);return(0,Oe.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Se.OPTIONS_GRID_MOBILE_QUERY),i=()=>a(t.matches);return i(),t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function bt({options:e,activeIndex:a,onSelect:t,onHighlight:i,listboxId:n,loading:r,groupKey:s}){let g=Wt(),{cols:b,maxHeight:v}=(0,Se.computeOptionsGridLayout)(e.length,g);return(0,Ze.jsx)(ht,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:s,cols:b,maxHeight:v,children:e.map((m,f)=>(0,Ze.jsx)(ft,{option:m,isHighlighted:f===a,onSelect:t,onHighlight:()=>i(f),id:`${n}-option-${f}`,loading:r},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 @@
1473
1620
  }
1474
1621
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
1475
1622
  }
1476
- `,document.head.appendChild(e)}var ut=require("react/jsx-runtime");function ct({space:e,align:a="stretch",className:t,children:o,...i}){let s=e?{"--aia-stack-space":e}:void 0;return(0,ut.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:s,...i,children:o})}var B=require("react/jsx-runtime"),Bt=[159,119,164],Ft=()=>{};function Mt(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,o]=(0,xe.useState)(a);if((0,xe.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>o(i.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Be({suggestions:e,activeIndex:a,onSelect:t,onHighlight:o,isOpen:i,id:s,className:r,pills:h,onPillClick:v,showPills:y=!0,onSkip:k,showSkipButton:w=!0,skipDisabled:M=!1,activeSelected:X=!1,isLoading:D=!1,isInputEmpty:R=!1,products:G,onProductSelect:Z,onProductFocusChange:N,optionsPosition:_="below",mode:Y}){let q=Mt(Y),m=q!==void 0,re=e[0]?.options??[],ee=!!(h&&h.length>0&&v),T=!!(G&&G.length>0),L=i&&(re.length>0||y&&ee||D||T),$={suggestions:e,activeIndex:a,pills:h,showPills:y,showSkipButton:w,skipDisabled:M,activeSelected:X,isLoading:D,isInputEmpty:R,products:G},j=(0,xe.useRef)($);L&&(j.current=$);let g=L?$:j.current,O=g.suggestions[0],C=O?.options??[],te=g.activeIndex>=0&&!!C[g.activeIndex]?.is_tappable,K=!!(g.pills&&g.pills.length>0&&v),ae=g.showPills&&K,Q=g.showPills&&!K&&g.isLoading,H=ae||Q,l=K&&g.showSkipButton&&!g.isInputEmpty&&!!k,p=g.pills?.[0]?.text,u=C.length>0,n=g.isLoading&&!u,f=g.products??[];return(0,B.jsx)("div",{id:s,role:"listbox","data-aia-dropdown":"","data-options-position":_,"data-mode":q,"data-aia-loading":g.isLoading?"":void 0,"data-aia-has-products":f.length>0?"":void 0,className:`${m?"magicx-aia ":""}${de.dropdown} ${L?de.visible:""} ${r??""}`,onMouseDown:I=>I.preventDefault(),children:(0,B.jsxs)(ct,{space:"8px",children:[(H||l)&&(0,B.jsxs)(_e,{noWrap:!0,className:de.pillBar,"data-aia-pillbar":"",children:[H&&(0,B.jsx)("span",{className:de.pillScroll,"data-aia-pill-scroll":"",children:(0,B.jsx)(Te,{pills:g.pills??[],activePillIndex:0,activeSelected:g.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:g.isLoading})}),l&&(0,B.jsx)("button",{type:"button",tabIndex:-1,className:de.skip,"data-aia-skip":"",disabled:g.isLoading||g.skipDisabled,"aria-label":p?`Skip ${p}`:"Skip",onClick:k,children:"skip"})]}),u&&(0,B.jsx)(pt,{options:C,activeIndex:g.activeIndex,onSelect:t,onHighlight:o,listboxId:s,loading:g.isLoading,groupKey:O?`${O.type} ${O.text}`:""}),n&&(0,B.jsx)("div",{className:de.skeletonBars,"data-aia-skeleton-bars":"",children:Bt.map(I=>(0,B.jsx)("span",{className:de.skeletonBar,style:{width:I}},`bar-${I}`))}),(0,B.jsx)(rt,{products:f,listboxId:s,onSelect:Z??Ft,onFocusChange:N,focusable:L}),(0,B.jsx)(tt,{isOptionHighlighted:te,isInputEmpty:g.isInputEmpty})]})})}var we=require("@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)}var xt=require("react/jsx-runtime");function vt({space:e,align:a="stretch",className:t,children:i,...n}){let r=e?{"--aia-stack-space":e}:void 0;return(0,xt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:r,...n,children:i})}var B=require("react/jsx-runtime"),Ut=[159,119,164],Vt=()=>{},wt=()=>{};function qt(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,i]=(0,Ae.useState)(a);if((0,Ae.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>i(n.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Fe({suggestions:e,activeIndex:a,onSelect:t,onHighlight:i,isOpen:n,id:r,className:s,pills:g,onPillClick:b,showPills:v=!0,onSkip:m,showSkipButton:f=!0,skipDisabled:z=!1,activeSelected:G=!1,isLoading:N=!1,isInputEmpty:O=!1,products:V,onProductSelect:ae,onProductFocusChange:ce,formatType:F="options",dateView:P=null,selectedDateIso:X=null,onPreviousMonth:u,onNextMonth:ue,optionsPosition:oe="below",mode:ie}){let E=qt(ie),me=E!==void 0,re=e[0]?.options??[],ne=!!(g&&g.length>0&&b),se=!!(V&&V.length>0),T=n&&(re.length>0||v&&ne||N||se),q={suggestions:e,activeIndex:a,pills:g,showPills:v,showSkipButton:f,skipDisabled:z,activeSelected:G,isLoading:N,isInputEmpty:O,products:V,formatType:F,dateView:P,selectedDateIso:X},Z=(0,Ae.useRef)(q);T&&(Z.current=q);let h=T?q:Z.current,H=h.suggestions[0],R=H?.options??[],he=h.activeIndex>=0&&!!R[h.activeIndex]?.is_tappable,l=!!(h.pills&&h.pills.length>0&&b),c=h.showPills&&l,o=h.showPills&&!l&&h.isLoading,y=c||o,x=l&&h.showSkipButton&&!h.isInputEmpty&&!!m,S=h.pills?.[0]?.text,d=h.formatType==="date"&&h.dateView!=null,$=R.length>0&&!d,ee=R.length>0&&d,ge=h.isLoading&&!$&&!ee,ye=h.products??[];return(0,B.jsx)("div",{id:r,role:"listbox","data-aia-dropdown":"","data-options-position":oe,"data-mode":E,"data-aia-loading":h.isLoading?"":void 0,"data-aia-has-products":ye.length>0?"":void 0,className:`${me?"magicx-aia ":""}${ve.dropdown} ${T?ve.visible:""} ${s??""}`,onMouseDown:j=>j.preventDefault(),children:(0,B.jsxs)(vt,{space:"8px",children:[(y||x)&&(0,B.jsxs)(Ee,{noWrap:!0,className:ve.pillBar,"data-aia-pillbar":"",children:[y&&(0,B.jsx)("span",{className:ve.pillScroll,"data-aia-pill-scroll":"",children:(0,B.jsx)(Be,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:h.isLoading})}),x&&(0,B.jsx)("button",{type:"button",tabIndex:-1,className:ve.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":S?`Skip ${S}`:"Skip",onClick:m,children:"skip"})]}),$&&(0,B.jsx)(bt,{options:R,activeIndex:h.activeIndex,onSelect:t,onHighlight:i,listboxId:r,loading:h.isLoading,groupKey:H?`${H.type} ${H.text}`:""}),ee&&h.dateView&&(0,B.jsx)(st,{options:R,activeIndex:h.activeIndex,listboxId:r,view:h.dateView,selectedIso:h.selectedDateIso??null,onSelect:t,onHighlight:i,onPreviousMonth:u??wt,onNextMonth:ue??wt}),ge&&(0,B.jsx)("div",{className:ve.skeletonBars,"data-aia-skeleton-bars":"",children:Ut.map(j=>(0,B.jsx)("span",{className:ve.skeletonBar,style:{width:j}},`bar-${j}`))}),(0,B.jsx)(ut,{products:ye,listboxId:r,onSelect:ae??Vt,onFocusChange:ce,focusable:T}),(0,B.jsx)(lt,{isOptionHighlighted:he,isInputEmpty:h.isInputEmpty})]})})}var De=require("@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 @@
1508
1655
  );
1509
1656
  cursor: default;
1510
1657
  }
1511
- `,document.head.appendChild(e)}var mt={submitButton:"SubmitButton-module_submitButton_otz7H"};var Fe=require("react/jsx-runtime");function ht({disabled:e,onClick:a}){return(0,Fe.jsx)("button",{type:"button","data-aia-submit":"",className:mt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),a()},"aria-label":"Submit",children:(0,Fe.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Fe.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var ft=require("@magicx-eng/ai-autocomplete-vanilla"),x=require("react");var Qe=require("react");function gt(e){let a=(0,Qe.useRef)(e);a.current=e;let t=(0,Qe.useRef)(null);t.current===null&&(t.current={fetch:(i,s)=>{let r=a.current;return r?r.fetch(i,s):Promise.reject(new Error("products config removed"))},transform:i=>a.current?.transform(i)??[],get limit(){return a.current?.limit}});let o=e!==void 0;return{config:o?t.current:void 0,enabled:o}}var Nt={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 Me({onSubmit:e,onError:a,optionOverrides:t,maskCompletedText:o,apiConfig:i,additionalContext:s,columns:r=2,dropdownTrigger:h,optionsPosition:v,closeDropdownOnBlur:y,showNonTappableOptions:k,showSkipButton:w,onFocus:M,onBlur:X,value:D,completedParams:R,onChange:G,onParamsChange:Z,products:N,onProductSelect:_,source:Y,setCursor:q}){let m=(0,x.useRef)(null),[re,ee]=(0,x.useState)(null),T=(0,x.useRef)(e);T.current=e;let L=(0,x.useRef)(a);L.current=a;let $=(0,x.useRef)(G);$.current=G;let j=(0,x.useRef)(Z);j.current=Z;let g=(0,x.useRef)(M);g.current=M;let O=(0,x.useRef)(X);O.current=X;let C=(0,x.useRef)(q);C.current=q;let te=(0,x.useRef)(_);te.current=_;let K=gt(N);(0,x.useEffect)(()=>{if(typeof document>"u")return;let d=new ft.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:i,additionalContext:s,optionOverrides:t,maskCompletedText:o,columns:r,dropdownTrigger:h,optionsPosition:v,closeDropdownOnBlur:y,showNonTappableOptions:k,source:Y,value:D,completedParams:R,onSubmit:(...A)=>T.current?.(...A),onError:(...A)=>L.current?.(...A),onChange:(...A)=>$.current?.(...A),onParamsChange:(...A)=>j.current?.(...A),onFocus:()=>g.current?.(),onBlur:()=>O.current?.(),onProductSelect:A=>te.current?.(A),setCursor:A=>C.current?.(A),products:K.config});m.current=d,ee(d.getState());let E=d.subscribe(A=>ee(A));return()=>{E(),d.destroy(),m.current===d&&(m.current=null)}},[]),(0,x.useEffect)(()=>{D!==void 0&&m.current?.setValue(D)},[D]),(0,x.useEffect)(()=>{R!==void 0&&m.current?.setCompletedParams(R)},[R]);let ae=JSON.stringify(i??null),Q;try{Q=JSON.stringify(s??null)}catch{Q="[unstringifiable]"}let H=(0,x.useRef)(t),l=(0,x.useRef)(0);if(t!==H.current){let d=H.current,E=t,A=Object.keys(d??{}),ge=Object.keys(E??{});(A.length!==ge.length||ge.some(se=>!d?.[se]||E[se]!==d[se]))&&l.current++,H.current=t}(0,x.useEffect)(()=>{m.current?.update({apiConfig:i,additionalContext:s,optionOverrides:t,dropdownTrigger:h,optionsPosition:v,closeDropdownOnBlur:y,showNonTappableOptions:k})},[ae,Q,l.current,h,v,y,k]);let p=(0,x.useRef)(!1);(0,x.useEffect)(()=>{if(!p.current){p.current=!0;return}m.current?.update({products:K.config})},[K.enabled]);let u=(0,x.useRef)(null);u.current===null&&(u.current={handleTextChange:d=>m.current?.handleTextChange(d),handleKeyDown:d=>{let E="nativeEvent"in d?d.nativeEvent:d;m.current?.handleKeyDown(E)},setFocused:d=>m.current?.setFocused(d),startEditingParam:d=>m.current?.startEditingParam(d),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:d=>m.current?.handleCaretAfterInput(d),handleCaretMove:d=>m.current?.handleCaretMove(d),replaceEditingRange:d=>m.current?.replaceEditingRange(d)??!1,setActivePill:d=>m.current?.setActivePill(d),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),selectOption:d=>m.current?.selectOption(d),selectProduct:d=>m.current?.selectProduct(d),setActiveDropdownIndex:d=>m.current?.setActiveDropdownIndex(d),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let n=u.current,f=(0,x.useCallback)(d=>{let E=d.target.value,ge=E.length>0&&!d.nativeEvent?.isComposing&&E[0]!==E[0].toUpperCase()?E[0].toUpperCase()+E.slice(1):E;m.current?.handleTextChange(ge)},[]),I=(0,x.useCallback)(d=>{m.current?.handleKeyDown(d.nativeEvent)},[]),oe=m.current,c=re??Nt,Ie=D!==void 0?D:c.text,ye=R!==void 0?R:c.completedParams,me=c.actionableSuggestions,Se=me[0],he=oe?.listboxId??"",He=c.activeDropdownIndex>=0&&oe?`${he}-option-${c.activeDropdownIndex}`:void 0,ne=c.editingParam,ke=ne?{type:ne.suggestionType,text:ne.suggestionPlaceholder,required:!0,options:ne.options}:null,Ae=ke??Se,Ge=ke?[ke]:me,Ce=!oe||c.isLoading&&!c.editingParam&&!c.inSelectionAnimation;return{completedParams:ye,skippedParams:c.skippedParams,suggestionPills:me,setActivePill:n.setActivePill,skipActivePill:n.skipActivePill,removeLastParam:n.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:n.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:Ce,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:he,error:c.error,products:c.products,selectProduct:n.selectProduct,handleTextChange:n.handleTextChange,handleKeyDown:n.handleKeyDown,setFocused:n.setFocused,editingParam:ne,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:n.startEditingParam,exitEditMode:n.exitEditMode,handleCaretAfterInput:n.handleCaretAfterInput,handleCaretMove:n.handleCaretMove,replaceEditingRange:n.replaceEditingRange,inputProps:{value:Ie,placeholder:c.placeholderText||void 0,onChange:f,onKeyDown:I,onFocus:n.handleFocus,onBlur:n.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":He,"aria-autocomplete":"list","aria-controls":he},reset:n.reset,dropdownProps:{suggestions:Ae?[{...Ae,options:c.filteredOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:n.selectOption,onHighlight:n.setActiveDropdownIndex,isOpen:c.isDropdownOpen,id:he,pills:Ge,activeSelected:c.isActivePillSelected,onPillClick:n.setActivePill,onSkip:n.skipActivePill,showSkipButton:(w??!0)&&!ne,skipDisabled:c.inSelectionAnimation,isLoading:Ce,isInputEmpty:Ie.trim().length===0,products:c.products,onProductSelect:n.selectProduct,onProductFocusChange:n.setFocused,optionsPosition:v??"below"}}}var F=require("@magicx-eng/ai-autocomplete-vanilla"),b=require("react"),Ne;function Ot(){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 bt(e){let{segments:a,newParamId:t,editingParam:o,editingAnchor:i,caretOffset:s,placeholderText:r,isFocused:h,isDropdownOpen:v,listboxId:y,activeDescendantId:k,autoFocus:w,handleTextChange:M,handleKeyDown:X,handleCaretAfterInput:D,handleCaretMove:R,startEditingParam:G,replaceEditingRange:Z,setFocused:N}=e,_=(0,b.useRef)(null),Y=(0,b.useRef)(!1),q=(0,b.useRef)(""),m=(0,b.useRef)(""),re=(0,b.useRef)(null),ee=(0,b.useRef)(0);re.current=s,(0,b.useEffect)(()=>{if(!w)return;let l=_.current;if(!l)return;document.activeElement===l?N(!0):l.focus();let p=l.ownerDocument??document,u=p.getSelection(),n=u&&u.rangeCount>0&&l.contains(u.anchorNode);if(u&&!n){let f=p.createRange();f.selectNodeContents(l),f.collapse(!0),u.removeAllRanges(),u.addRange(f)}},[w,N]),(0,b.useEffect)(()=>{let l=_.current;if(!l)return;let p=l.ownerDocument??document,u=()=>{let n=p.getSelection();if(!n||n.rangeCount===0||!n.anchorNode||!l.contains(n.anchorNode))return;let f=n.anchorNode,I=f.nodeType===Node.ELEMENT_NODE?f:f.parentElement,c=(n.isCollapsed?I?.closest('strong[data-seg="completed"][data-param-id]'):null)?.dataset.paramId??null;if(c&&c!==o?.id){G(c);return}performance.now()-ee.current<50||R((0,F.getCursorOffset)(l))};return p.addEventListener("selectionchange",u),()=>p.removeEventListener("selectionchange",u)},[o,G,R]),(0,b.useLayoutEffect)(()=>{let l=_.current;l&&(0,F.renderEditableContent)({input:l,segments:a,newParamId:t,editingParamId:o?.id??null,placeholderText:r??"",isFocused:h})},[a,t,o,r,h]),(0,b.useLayoutEffect)(()=>{let l=q.current,p=t??"";if(q.current=p,!p||p===l)return;let u=_.current;if(!u)return;u.focus();let n=re.current??(0,F.plainTextLength)(u);(0,F.setCursorOffset)(u,n)},[t]),(0,b.useLayoutEffect)(()=>{let l=m.current,p=o?.id??"";if(m.current=p,!p||p===l||i==null)return;let u=_.current;u&&(0,F.setCursorOffset)(u,i)},[o,i]);let T=(0,b.useCallback)(()=>{if(Y.current)return;let l=_.current;if(!l)return;let p=(0,F.extractPlainText)(l),n=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;M(n)},[M]),L=(0,b.useCallback)(()=>{ee.current=performance.now(),T();let l=_.current;l&&D((0,F.getCursorOffset)(l))},[T,D]);(0,b.useEffect)(()=>{let l=_.current;if(!l)return;let p=u=>{let n=u,f=n.inputType;if(f==="insertParagraph"||f==="insertLineBreak"||f==="insertFromDrop"){u.preventDefault();return}if(f.startsWith("insert")||f.startsWith("delete")){let I=f.startsWith("delete")?"":n.data??"";Z(I)&&u.preventDefault()}};return l.addEventListener("beforeinput",p),()=>l.removeEventListener("beforeinput",p)},[Z]);let $=(0,b.useCallback)(()=>{Y.current=!0},[]),j=(0,b.useCallback)(()=>{Y.current=!1,T()},[T]),g=(0,b.useCallback)(l=>{l.preventDefault();let p=_.current;if(!p)return;let u=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let n=p.ownerDocument??document,f=n.getSelection();if(!f||f.rangeCount===0)return;let I=f.getRangeAt(0);if(!p.contains(I.startContainer))return;I.deleteContents();let oe=n.createTextNode(u);I.insertNode(oe),I.setStartAfter(oe),I.collapse(!0),f.removeAllRanges(),f.addRange(I),T()},[T]),O=(0,b.useCallback)(l=>X(l),[X]),C=(0,b.useCallback)(()=>N(!0),[N]),te=(0,b.useCallback)(()=>N(!1),[N]),K=(0,b.useCallback)(()=>_.current?.focus(),[]),ae=(0,b.useCallback)(()=>_.current?.blur(),[]),Q=(0,b.useCallback)(()=>{let l=_.current;return l?(0,F.extractPlainText)(l):""},[]),H=Ot()?"plaintext-only":"true";return{inputRef:_,editorProps:{ref:_,contentEditable:H,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":y,"aria-expanded":v,"aria-activedescendant":k,spellCheck:!0,enterKeyHint:"send",onInput:L,onKeyDown:O,onCompositionStart:$,onCompositionEnd:j,onPaste:g,onFocus:C,onBlur:te},getPlainText:Q,focus:K,blur:ae}}var V=require("react/jsx-runtime");function Ht(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var vt=(0,S.forwardRef)(function({onSubmit:a,onError:t,optionOverrides:o,maskCompletedText:i,className:s,apiConfig:r,additionalContext:h,columns:v,pillPlacement:y="dropdown",mode:k="auto",optionsPosition:w="below",animations:M=!0,dropdownTrigger:X,closeDropdownOnBlur:D,showNonTappableOptions:R,showSkipButton:G,autoFocus:Z=!0,onFocus:N,onBlur:_,value:Y,completedParams:q,onChange:m,onParamsChange:re,products:ee,onProductSelect:T,submitButton:L},$){let j=(0,S.useRef)(null),g=(0,S.useRef)(null),O=(0,S.useRef)(()=>{}),C=(0,S.useRef)(null),te=(0,S.useRef)(null);(0,S.useEffect)(()=>{let P=j.current;if(P)return C.current?C.current.setMode(k):C.current=new we.ModeController(P,k),()=>{C.current?.destroy(),C.current=null}},[k]);let K=(0,S.useCallback)(P=>{let le=te.current?.current;le&&(le.focus(),(0,we.setCursorOffset)(le,P))},[]),{completedParams:ae,skippedParams:Q,suggestionPills:H,setActivePill:l,skipActivePill:p,segments:u,newParamId:n,clearNewParamId:f,placeholderText:I,isFocused:oe,isDropdownOpen:c,isActivePillSelected:Ie,isLoading:ye,activeIndex:me,listboxId:Se,handleTextChange:he,handleKeyDown:He,setFocused:ne,editingParam:ke,editingAnchor:Ae,caretOffset:Ge,startEditingParam:Ce,handleCaretAfterInput:d,handleCaretMove:E,replaceEditingRange:A,dropdownProps:ge,reset:se}=Me({onSubmit:P=>O.current(P),onError:t,optionOverrides:o,maskCompletedText:i,apiConfig:r,additionalContext:h,columns:v,dropdownTrigger:X,optionsPosition:w,closeDropdownOnBlur:D,showNonTappableOptions:R,showSkipButton:G,onFocus:N,onBlur:_,value:Y,completedParams:q,onChange:m,onParamsChange:re,products:ee,onProductSelect:T,source:"full-sdk",setCursor:K});(0,S.useEffect)(()=>{if(!n)return;let P=window.setTimeout(()=>f(),650);return()=>window.clearTimeout(P)},[n,f]);let xt=me>=0?`${Se}-option-${me}`:void 0,{inputRef:Ke,editorProps:wt,focus:Ee,blur:Je,getPlainText:Xe}=bt({segments:u,newParamId:n,editingParam:ke,editingAnchor:Ae,caretOffset:Ge,placeholderText:I,isFocused:oe,isDropdownOpen:c,listboxId:Se,activeDescendantId:xt,autoFocus:Z,handleTextChange:he,handleKeyDown:He,handleCaretAfterInput:d,handleCaretMove:E,startEditingParam:Ce,replaceEditingRange:A,setFocused:ne});te.current=Ke,(0,S.useLayoutEffect)(()=>{let P=g.current,le=Ke.current;if(!P||!le)return;let Ze=()=>{let et=P.firstElementChild;if(!et)return;let Pt=et.getBoundingClientRect(),It=le.getBoundingClientRect();Pt.top>=It.bottom-2?P.setAttribute("data-aia-pill-wrapped",""):P.removeAttribute("data-aia-pill-wrapped")};Ze();let Ye=new ResizeObserver(Ze);return Ye.observe(le),()=>Ye.disconnect()},[u,H.length,ye,Ke]),(0,S.useImperativeHandle)($,()=>({focus:Ee,blur:Je,reset:se,setMode:P=>C.current?.setMode(P),skipActivePill:p}),[Ee,Je,se,p]);let De=!!u.length||ae.length>0,We=(0,S.useCallback)(()=>{if(!De)return;let P=Xe();a((0,we.buildSubmitResult)(P,ae,Q)),se()},[De,ae,Q,a,se,Xe]);O.current=We;let yt=(0,S.useCallback)(P=>{P.target?.closest("[data-aia-pill]")||Ee()},[Ee]),kt=y==="inline",_t=y==="dropdown";return(0,V.jsxs)("div",{ref:j,className:`magicx-aia ${ue.container} ${s??""}`,"data-pill-placement":y,"data-options-position":w,"data-animations":M?"on":"off","data-mode":Ht(k),children:[(0,V.jsx)(Be,{...ge,showPills:_t}),(0,V.jsxs)("div",{className:ue.inputWrapper,onClick:yt,children:[(0,V.jsxs)("div",{className:ue.editorArea,"data-aia-editor":"",children:[(0,V.jsx)("div",{...wt,className:ue.input,"data-aia-input":""}),kt&&(ye||H.length>0)&&(0,V.jsx)("span",{ref:g,className:ue.pillListContainer,"data-aia-pill-list-container":"",children:(0,V.jsx)(Te,{pills:H,activePillIndex:0,activeSelected:Ie,onSelectPill:l,loading:ye})})]}),L===null?null:L===void 0?(0,V.jsx)(ht,{disabled:!De,onClick:We}):(0,V.jsx)("span",{"data-aia-submit":"",className:ue.submitSlot,onClick:P=>{De&&(P.stopPropagation(),We())},children:L})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,buildSubmitResult,useAIAutocomplete,withSkippedParams});
1658
+ `,document.head.appendChild(e)}var yt={submitButton:"SubmitButton-module_submitButton_otz7H"};var He=require("react/jsx-runtime");function kt({disabled:e,onClick:a}){return(0,He.jsx)("button",{type:"button","data-aia-submit":"",className:yt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),a()},"aria-label":"Submit",children:(0,He.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,He.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ke=require("@magicx-eng/ai-autocomplete-vanilla"),k=require("react");var et=require("react");function _t(e){let a=(0,et.useRef)(e);a.current=e;let t=(0,et.useRef)(null);t.current===null&&(t.current={fetch:(n,r)=>{let s=a.current;return s?s.fetch(n,r):Promise.reject(new Error("products config removed"))},transform:n=>a.current?.transform(n)??[],get limit(){return a.current?.limit}});let i=e!==void 0;return{config:i?t.current:void 0,enabled:i}}var $t={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:a,optionOverrides:t,maskCompletedText:i,apiConfig:n,additionalContext:r,columns:s=2,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m,showSkipButton:f,onFocus:z,onBlur:G,value:N,completedParams:O,onChange:V,onParamsChange:ae,products:ce,onProductSelect:F,source:P,setCursor:X}){let u=(0,k.useRef)(null),[ue,oe]=(0,k.useState)(null),ie=(0,k.useRef)(e);ie.current=e;let E=(0,k.useRef)(a);E.current=a;let me=(0,k.useRef)(V);me.current=V;let re=(0,k.useRef)(ae);re.current=ae;let ne=(0,k.useRef)(z);ne.current=z;let se=(0,k.useRef)(G);se.current=G;let T=(0,k.useRef)(X);T.current=X;let q=(0,k.useRef)(F);q.current=F;let Z=_t(ce);(0,k.useEffect)(()=>{if(typeof document>"u")return;let p=new Ke.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:n,additionalContext:r,optionOverrides:t,maskCompletedText:i,columns:s,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m,source:P,value:N,completedParams:O,onSubmit:(...D)=>ie.current?.(...D),onError:(...D)=>E.current?.(...D),onChange:(...D)=>me.current?.(...D),onParamsChange:(...D)=>re.current?.(...D),onFocus:()=>ne.current?.(),onBlur:()=>se.current?.(),onProductSelect:D=>q.current?.(D),setCursor:D=>T.current?.(D),products:Z.config});u.current=p,oe(p.getState());let L=p.subscribe(D=>oe(D));return()=>{L(),p.destroy(),u.current===p&&(u.current=null)}},[]),(0,k.useEffect)(()=>{N!==void 0&&u.current?.setValue(N)},[N]),(0,k.useEffect)(()=>{O!==void 0&&u.current?.setCompletedParams(O)},[O]);let h=JSON.stringify(n??null),H;try{H=JSON.stringify(r??null)}catch{H="[unstringifiable]"}let R=(0,k.useRef)(t),he=(0,k.useRef)(0);if(t!==R.current){let p=R.current,L=t,D=Object.keys(p??{}),_e=Object.keys(L??{});(D.length!==_e.length||_e.some(fe=>!p?.[fe]||L[fe]!==p[fe]))&&he.current++,R.current=t}(0,k.useEffect)(()=>{u.current?.update({apiConfig:n,additionalContext:r,optionOverrides:t,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m})},[h,H,he.current,g,b,v,m]);let l=(0,k.useRef)(!1);(0,k.useEffect)(()=>{if(!l.current){l.current=!0;return}u.current?.update({products:Z.config})},[Z.enabled]);let c=(0,k.useRef)(null);c.current===null&&(c.current={handleTextChange:p=>u.current?.handleTextChange(p),handleKeyDown:p=>{let L="nativeEvent"in p?p.nativeEvent:p;u.current?.handleKeyDown(L)},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 o=c.current,y=(0,k.useCallback)(p=>{let L=p.target.value,_e=L.length>0&&!p.nativeEvent?.isComposing&&L[0]!==L[0].toUpperCase()?L[0].toUpperCase()+L.slice(1):L;u.current?.handleTextChange(_e)},[]),x=(0,k.useCallback)(p=>{u.current?.handleKeyDown(p.nativeEvent)},[]),S=u.current,d=ue??$t,$=N!==void 0?N:d.text,ee=O!==void 0?O:d.completedParams,ge=d.actionableSuggestions,ye=ge[0],j=S?.listboxId??"",Ve=d.activeDropdownIndex>=0&&S?`${j}-option-${d.activeDropdownIndex}`:void 0,le=d.editingParam,de=d.editingIdentified,Ce=le?{type:le.suggestionType,text:le.suggestionPlaceholder,required:!0,options:le.options}:de?{type:de.type,text:de.type,required:!0,options:[]}:null,Re=Ce??ye,qe=Ce?[Ce]:ge,Le=!S||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation;return{completedParams:ee,skippedParams:d.skippedParams,suggestionPills:ge,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:Le,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:j,error:d.error,products:d.products,selectProduct:o.selectProduct,handleTextChange:o.handleTextChange,handleKeyDown:o.handleKeyDown,setFocused:o.setFocused,editingParam:le,editingIdentified:de,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:o.startEditingParam,exitEditMode:o.exitEditMode,handleCaretAfterInput:o.handleCaretAfterInput,handleCaretMove:o.handleCaretMove,replaceEditingRange:o.replaceEditingRange,inputProps:{value:$,placeholder:d.placeholderText||void 0,onChange:y,onKeyDown:x,onFocus:o.handleFocus,onBlur:o.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":Ve,"aria-autocomplete":"list","aria-controls":j},reset:o.reset,dropdownProps:{suggestions:Re?[{...Re,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:o.selectOption,onHighlight:o.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:j,pills:qe,activeSelected:d.isActivePillSelected,onPillClick:o.setActivePill,onSkip:o.skipActivePill,showSkipButton:(f??!0)&&!le&&!de,skipDisabled:d.inSelectionAnimation,isLoading:Le,isInputEmpty:$.trim().length===0,products:d.products,onProductSelect:o.selectProduct,onProductFocusChange:o.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:de?de.iso:(0,Ke.selectedIsoFromText)(le?.text),onPreviousMonth:o.showPreviousMonth,onNextMonth:o.showNextMonth,optionsPosition:b??"below"}}}var W=require("@magicx-eng/ai-autocomplete-vanilla"),w=require("react"),Ue;function jt(){if(Ue!==void 0)return Ue;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ue=e.contentEditable==="plaintext-only",Ue}function Pt(e){let{segments:a,newParamId:t,editingParam:i,editingIdentified:n,editingAnchor:r,caretOffset:s,placeholderText:g,isFocused:b,isDropdownOpen:v,listboxId:m,activeDescendantId:f,autoFocus:z,handleTextChange:G,handleKeyDown:N,handleCaretAfterInput:O,handleCaretMove:V,startEditingParam:ae,replaceEditingRange:ce,setFocused:F}=e,P=(0,w.useRef)(null),X=(0,w.useRef)(!1),u=(0,w.useRef)(""),ue=(0,w.useRef)(""),oe=(0,w.useRef)(null),ie=(0,w.useRef)(0);oe.current=s,(0,w.useEffect)(()=>{if(!z)return;let l=P.current;if(!l)return;document.activeElement===l?F(!0):l.focus();let c=l.ownerDocument??document,o=c.getSelection(),y=o&&o.rangeCount>0&&l.contains(o.anchorNode);if(o&&!y){let x=c.createRange();x.selectNodeContents(l),x.collapse(!0),o.removeAllRanges(),o.addRange(x)}},[z,F]),(0,w.useEffect)(()=>{let l=P.current;if(!l)return;let c=l.ownerDocument??document,o=()=>{let y=c.getSelection();if(!y||y.rangeCount===0||!y.anchorNode||!l.contains(y.anchorNode))return;let x=y.anchorNode,S=x.nodeType===Node.ELEMENT_NODE?x:x.parentElement,$=(y.isCollapsed?S?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ee=i?.id??n?.id??null;if($&&$!==ee){ae($);return}performance.now()-ie.current<50||V((0,W.getCursorOffset)(l))};return c.addEventListener("selectionchange",o),()=>c.removeEventListener("selectionchange",o)},[i,n,ae,V]),(0,w.useLayoutEffect)(()=>{let l=P.current;l&&(0,W.renderEditableContent)({input:l,segments:a,newParamId:t,editingParamId:i?.id??null,placeholderText:g??"",isFocused:b})},[a,t,i,g,b]),(0,w.useLayoutEffect)(()=>{let l=u.current,c=t??"";if(u.current=c,!c||c===l)return;let o=P.current;if(!o)return;o.focus();let y=oe.current??(0,W.plainTextLength)(o);(0,W.setCursorOffset)(o,y)},[t]),(0,w.useLayoutEffect)(()=>{let l=ue.current,c=i?.id??"";if(ue.current=c,!c||c===l||r==null)return;let o=P.current;o&&(0,W.setCursorOffset)(o,r)},[i,r]);let E=(0,w.useCallback)(()=>{if(X.current)return;let l=P.current;if(!l)return;let c=(0,W.extractPlainText)(l),y=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;G(y)},[G]),me=(0,w.useCallback)(()=>{ie.current=performance.now(),E();let l=P.current;l&&O((0,W.getCursorOffset)(l))},[E,O]);(0,w.useEffect)(()=>{let l=P.current;if(!l)return;let c=o=>{let y=o,x=y.inputType;if(x==="insertParagraph"||x==="insertLineBreak"||x==="insertFromDrop"){o.preventDefault();return}if(x.startsWith("insert")||x.startsWith("delete")){let S=x.startsWith("delete")?"":y.data??"";ce(S)&&o.preventDefault()}};return l.addEventListener("beforeinput",c),()=>l.removeEventListener("beforeinput",c)},[ce]);let re=(0,w.useCallback)(()=>{X.current=!0},[]),ne=(0,w.useCallback)(()=>{X.current=!1,E()},[E]),se=(0,w.useCallback)(l=>{l.preventDefault();let c=P.current;if(!c)return;let o=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!o)return;let y=c.ownerDocument??document,x=y.getSelection();if(!x||x.rangeCount===0)return;let S=x.getRangeAt(0);if(!c.contains(S.startContainer))return;S.deleteContents();let d=y.createTextNode(o);S.insertNode(d),S.setStartAfter(d),S.collapse(!0),x.removeAllRanges(),x.addRange(S),E()},[E]),T=(0,w.useCallback)(l=>N(l),[N]),q=(0,w.useCallback)(()=>F(!0),[F]),Z=(0,w.useCallback)(()=>F(!1),[F]),h=(0,w.useCallback)(()=>P.current?.focus(),[]),H=(0,w.useCallback)(()=>P.current?.blur(),[]),R=(0,w.useCallback)(()=>{let l=P.current;return l?(0,W.extractPlainText)(l):""},[]),he=jt()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:he,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:me,onKeyDown:T,onCompositionStart:re,onCompositionEnd:ne,onPaste:se,onFocus:q,onBlur:Z},getPlainText:R,focus:h,blur:H}}var J=require("react/jsx-runtime");function Qt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var It=(0,A.forwardRef)(function({onSubmit:a,onError:t,optionOverrides:i,maskCompletedText:n,className:r,apiConfig:s,additionalContext:g,columns:b,pillPlacement:v="dropdown",mode:m="auto",optionsPosition:f="below",animations:z=!0,dropdownTrigger:G,closeDropdownOnBlur:N,showNonTappableOptions:O,showSkipButton:V,autoFocus:ae=!0,onFocus:ce,onBlur:F,value:P,completedParams:X,onChange:u,onParamsChange:ue,products:oe,onProductSelect:ie,submitButton:E},me){let re=(0,A.useRef)(null),ne=(0,A.useRef)(null),se=(0,A.useRef)(()=>{}),T=(0,A.useRef)(null),q=(0,A.useRef)(null);(0,A.useEffect)(()=>{let _=re.current;if(_)return T.current?T.current.setMode(m):T.current=new De.ModeController(_,m),()=>{T.current?.destroy(),T.current=null}},[m]);let Z=(0,A.useCallback)(_=>{let be=q.current?.current;be&&(be.focus(),(0,De.setCursorOffset)(be,_))},[]),{completedParams:h,skippedParams:H,suggestionPills:R,setActivePill:he,skipActivePill:l,segments:c,newParamId:o,clearNewParamId:y,placeholderText:x,isFocused:S,isDropdownOpen:d,isActivePillSelected:$,isLoading:ee,activeIndex:ge,listboxId:ye,handleTextChange:j,handleKeyDown:Ve,setFocused:le,editingParam:de,editingIdentified:Ce,editingAnchor:Re,caretOffset:qe,startEditingParam:Le,handleCaretAfterInput:p,handleCaretMove:L,replaceEditingRange:D,dropdownProps:_e,reset:fe}=We({onSubmit:_=>se.current(_),onError:t,optionOverrides:i,maskCompletedText:n,apiConfig:s,additionalContext:g,columns:b,dropdownTrigger:G,optionsPosition:f,closeDropdownOnBlur:N,showNonTappableOptions:O,showSkipButton:V,onFocus:ce,onBlur:F,value:P,completedParams:X,onChange:u,onParamsChange:ue,products:oe,onProductSelect:ie,source:"full-sdk",setCursor:Z});(0,A.useEffect)(()=>{if(!o)return;let _=window.setTimeout(()=>y(),650);return()=>window.clearTimeout(_)},[o,y]);let St=ge>=0?`${ye}-option-${ge}`:void 0,{inputRef:$e,editorProps:At,focus:ze,blur:tt,getPlainText:at}=Pt({segments:c,newParamId:o,editingParam:de,editingIdentified:Ce,editingAnchor:Re,caretOffset:qe,placeholderText:x,isFocused:S,isDropdownOpen:d,listboxId:ye,activeDescendantId:St,autoFocus:ae,handleTextChange:j,handleKeyDown:Ve,handleCaretAfterInput:p,handleCaretMove:L,startEditingParam:Le,replaceEditingRange:D,setFocused:le});q.current=$e,(0,A.useLayoutEffect)(()=>{let _=ne.current,be=$e.current;if(!_||!be)return;let ot=()=>{let rt=_.firstElementChild;if(!rt)return;let Tt=rt.getBoundingClientRect(),Rt=be.getBoundingClientRect();Tt.top>=Rt.bottom-2?_.setAttribute("data-aia-pill-wrapped",""):_.removeAttribute("data-aia-pill-wrapped")};ot();let it=new ResizeObserver(ot);return it.observe(be),()=>it.disconnect()},[c,R.length,ee,$e]),(0,A.useImperativeHandle)(me,()=>({focus:ze,blur:tt,reset:fe,setMode:_=>T.current?.setMode(_),skipActivePill:l}),[ze,tt,fe,l]);let Ne=!!c.length||h.length>0,je=(0,A.useCallback)(()=>{if(!Ne)return;let _=at();a((0,De.buildSubmitResult)(_,h,H)),fe()},[Ne,h,H,a,fe,at]);se.current=je;let Dt=(0,A.useCallback)(_=>{_.target?.closest("[data-aia-pill]")||ze()},[ze]),Ct=v==="inline",Et=v==="dropdown";return(0,J.jsxs)("div",{ref:re,className:`magicx-aia ${ke.container} ${r??""}`,"data-pill-placement":v,"data-options-position":f,"data-animations":z?"on":"off","data-mode":Qt(m),children:[(0,J.jsx)(Fe,{..._e,showPills:Et}),(0,J.jsxs)("div",{className:ke.inputWrapper,onClick:Dt,children:[(0,J.jsxs)("div",{className:ke.editorArea,"data-aia-editor":"",children:[(0,J.jsx)("div",{...At,className:ke.input,"data-aia-input":""}),Ct&&(ee||R.length>0)&&(0,J.jsx)("span",{ref:ne,className:ke.pillListContainer,"data-aia-pill-list-container":"",children:(0,J.jsx)(Be,{pills:R,activePillIndex:0,activeSelected:$,onSelectPill:he,loading:ee})})]}),E===null?null:E===void 0?(0,J.jsx)(kt,{disabled:!Ne,onClick:je}):(0,J.jsx)("span",{"data-aia-submit":"",className:ke.submitSlot,onClick:_=>{Ne&&(_.stopPropagation(),je())},children:E})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,formatDate,isoDate,monthLabel,parseDate,parseLooseDate,useAIAutocomplete,withSkippedParams});
1512
1659
  //# sourceMappingURL=index.js.map