@magicx-eng/ai-autocomplete-react 0.40.1 → 0.40.2
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 +129 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{buildSubmitResult as
|
|
1
|
+
import{buildSubmitResult as Mn,cellDay as Nn,cellIso as Fn,DATE_RANGE_META_END as Hn,DATE_RANGE_META_START as Bn,DEFAULT_OPTION_COUNT_UNIT as Kn,dateCellMarks as Gn,formatDate as Wn,formatDateRange as _n,formatOptionCount as qn,isoDate as Un,monthLabel as Vn,optionCountLabel as jn,optionHasImage as Qn,optionImageSources as Yn,optionImageSrc as $n,optionLabel as Zn,optionsShowLeadingVisuals as Xn,PRODUCT_PATH_PREFIX as Jn,parseDate as er,parseLooseDate as tr,parseLooseDateRange as ar,productFromMatchedItem as ir,productImageSources as or,productsFromCustomFields as nr,sanitizeOptionIconSvg as rr,selectedRangeFor as sr,visibleDateRange as lr,WEEKDAY_LABELS as dr,withSkippedParams as cr}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Oi,useCallback as ft,useEffect as Xt,useImperativeHandle as Li,useLayoutEffect as zi,useRef as We}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-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
|
|
@@ -268,7 +268,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
268
268
|
opacity: 0;
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
`,document.head.appendChild(e)}var Ae={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};import{attachScrollArrow as
|
|
271
|
+
`,document.head.appendChild(e)}var Ae={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};import{attachScrollArrow as si,attachViewportFit as li,containScroll as di,hasSkippablePill as ci,isCalendarFormat as pi,labelTraditionalAutocomplete as hi,uiStringsFor as ui}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Oe,useRef as De,useState as mi}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
272
272
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
273
273
|
* Consumer CSS always wins without !important.
|
|
274
274
|
*
|
|
@@ -467,6 +467,9 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
467
467
|
--aia-pill-bg: var(--aia-primitive-neutral-750);
|
|
468
468
|
--aia-pill-color: var(--aia-primitive-neutral-300);
|
|
469
469
|
--aia-pill-font-size: 16px;
|
|
470
|
+
/* Smart Suggestion sparkle, matched text, and the shimmer's bright centre. */
|
|
471
|
+
--aia-smart-suggestion-accent: #b84549;
|
|
472
|
+
--aia-smart-suggestion-glint: #f3c4c5;
|
|
470
473
|
|
|
471
474
|
/* Completed params (Figma "RichTextPill"): compact faint-gray chip with
|
|
472
475
|
primary-color regular-weight text. -active is the hover / tapped (re-edit)
|
|
@@ -519,6 +522,9 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
519
522
|
--aia-pill-bg: var(--aia-primitive-neutral-750);
|
|
520
523
|
--aia-pill-color: var(--aia-primitive-neutral-700);
|
|
521
524
|
--aia-pill-font-size: 16px;
|
|
525
|
+
/* Smart Suggestion sparkle, matched text, and the shimmer's bright centre. */
|
|
526
|
+
--aia-smart-suggestion-accent: #e0787b;
|
|
527
|
+
--aia-smart-suggestion-glint: #ffe1e1;
|
|
522
528
|
|
|
523
529
|
/* Completed params (Figma "RichTextPill") \u2014 dark theme (design source):
|
|
524
530
|
white text on a faint-gray chip. -active is the hover / tapped highlight.
|
|
@@ -1114,7 +1120,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1114
1120
|
opacity: 0.25;
|
|
1115
1121
|
}
|
|
1116
1122
|
}
|
|
1117
|
-
`,document.head.appendChild(e)}var
|
|
1123
|
+
`,document.head.appendChild(e)}var le={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};import{cellDay as ra,cellIso as Re,dateCellMarks as sa,isoDate as la,monthLabel as da,visibleDateRange as ca,WEEKDAY_LABELS as pa}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as ha}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) ---
|
|
1118
1124
|
|
|
1119
1125
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1120
1126
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1277,7 +1283,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1277
1283
|
opacity: 0.8;
|
|
1278
1284
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1279
1285
|
}
|
|
1280
|
-
`,document.head.appendChild(e)}var L={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};import{jsx as ae,jsxs as
|
|
1286
|
+
`,document.head.appendChild(e)}var L={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};import{jsx as ae,jsxs as St}from"react/jsx-runtime";var ua=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Pt({options:e,activeIndex:n,listboxId:t,view:a,selection:o,onSelect:r,onHighlight:i,onUnhighlight:d,onPreviousMonth:l,onNextMonth:b}){let C=la(new Date),S=ca({pendingStart:o.rangeStart,highlightedIso:Re(e[n]),selected:o.selectedRange});return St("div",{className:L.datepicker,"data-aia-datepicker":"",children:[St("div",{className:L.header,children:[ae("button",{type:"button",tabIndex:-1,className:L.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:l,children:"\u2039"}),ae("span",{className:L.month,"data-aia-date-month":"","aria-live":"polite",children:da(a)}),ae("button",{type:"button",tabIndex:-1,className:L.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:b,children:"\u203A"})]}),ae("div",{className:L.weekdays,"aria-hidden":"true",children:pa.map((m,w)=>ae("span",{className:L.weekday,children:m},ua[w]))}),ae("div",{className:L.grid,"data-aia-date-grid":"",children:e.map((m,w)=>ae(ma,{option:m,id:`${t}-option-${w}`,index:w,isHighlighted:w===n&&m.is_tappable,isToday:Re(m)===C,isPast:Re(m)!=null&&Re(m)<C,marks:sa(Re(m),{selectedIso:o.selectedIso,range:S}),onSelect:r,onHighlight:i,onUnhighlight:d},Re(m)??`pad-${w}`))})]})}function ma({option:e,id:n,index:t,isHighlighted:a,isToday:o,isPast:r,marks:i,onSelect:d,onHighlight:l,onUnhighlight:b}){let[C,S]=ha(!1),m=ra(e);if(m==null)return ae("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${L.cell} ${L.blank}`});let w=()=>{S(!0),d(e),setTimeout(()=>S(!1),170)},P=[L.cell,L.day,r?L.past:"",a?L.highlighted:"",o?L.today:"",i.inRange?L.inRange:"",i.selected?L.selected:"",C?L.pressed:""].filter(Boolean).join(" ");return ae("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:P,onClick:w,onKeyDown:z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),w())},onMouseEnter:()=>l(t),onMouseLeave:b?()=>b(t):void 0,children:ae("span",{className:L.number,children:m})})}import{ATTRIBUTION_URL as ga,buildAttributionUrl as fa,getFooterHint as ba,uiStringsFor as wa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as va,useState as xa}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
|
|
1281
1287
|
display: flex;
|
|
1282
1288
|
flex-wrap: wrap;
|
|
1283
1289
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1317,7 +1323,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1317
1323
|
.aia-cluster[data-justify="around"] {
|
|
1318
1324
|
justify-content: space-around;
|
|
1319
1325
|
}
|
|
1320
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1326
|
+
`,document.head.appendChild(e)}import{jsx as It}from"react/jsx-runtime";function Ke({gap:e,align:n="center",justify:t="start",noWrap:a=!1,inline:o=!1,className:r,children:i,...d}){let l=e?{"--aia-cluster-gap":e}:void 0,b={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":n,"data-justify":t,"data-nowrap":a||void 0,"data-inline":o||void 0,style:l,...d};return o?It("span",{...b,children:i}):It("div",{...b,children:i})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
|
|
1321
1327
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1322
1328
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1323
1329
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1464,7 +1470,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1464
1470
|
justify-content: flex-end;
|
|
1465
1471
|
}
|
|
1466
1472
|
}
|
|
1467
|
-
`,document.head.appendChild(e)}var
|
|
1473
|
+
`,document.head.appendChild(e)}var de={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};import{jsx as Ge,jsxs as nt}from"react/jsx-runtime";function Tt({isOptionHighlighted:e=!1,isInputEmpty:n=!1,strings:t=wa()}){let{key:a,hint:o}=ba(e,n,t),[r,i]=xa(ga);return va(()=>{i(fa())},[]),Ge("footer",{className:de.footer,"data-aia-footer":"",children:nt(Ke,{justify:"between",noWrap:!0,className:de.row,children:[nt(Ke,{gap:"5px",className:de.hintGroup,children:[Ge("kbd",{className:de.key,children:a}),Ge("span",{className:de.hint,children:o})]}),nt("a",{className:de.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[Ge("span",{className:de.brand,children:"AI"}),Ge("span",{className:de.badge,children:"Autocomplete"})]})]})})}import{isSmartSuggestion as Sa,isTraditionalAutocompleteSuggestion as Pa}from"@magicx-eng/ai-autocomplete-vanilla";import{SMART_SUGGESTION_SPARKLE_SVG as ya}from"@magicx-eng/ai-autocomplete-vanilla";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,
|
|
1468
1474
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1469
1475
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1470
1476
|
as it was when the outline was dashed. */
|
|
@@ -1494,6 +1500,110 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1494
1500
|
border-radius: 999px;
|
|
1495
1501
|
}
|
|
1496
1502
|
|
|
1503
|
+
/* Smart Suggestion header: the question label's type, with a sparkle after
|
|
1504
|
+
it, over the completions of the word being typed or on a question the server
|
|
1505
|
+
marks. When it appears a glint of the accent sweeps the text twice and the
|
|
1506
|
+
sparkle twinkles as each lands. Only the header over completions
|
|
1507
|
+
("header") takes no pointer: a marked question is tapped like any pill. */
|
|
1508
|
+
.aia-pill-6Ga7S[data-aia-smart-suggestion] {
|
|
1509
|
+
gap: 0.35em;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
.aia-pill-6Ga7S[data-aia-smart-suggestion="header"] {
|
|
1513
|
+
cursor: default;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
.aia-smartText-R0cfw {
|
|
1517
|
+
background:
|
|
1518
|
+
linear-gradient(
|
|
1519
|
+
105deg,
|
|
1520
|
+
var(--aia-pill-color, var(--aia-color-text-muted, #c1c4cb)) 34%,
|
|
1521
|
+
var(--aia-smart-suggestion-accent, #b84549) 44%,
|
|
1522
|
+
var(--aia-smart-suggestion-glint, #f3c4c5) 50%,
|
|
1523
|
+
var(--aia-smart-suggestion-accent, #b84549) 56%,
|
|
1524
|
+
var(--aia-pill-color, var(--aia-color-text-muted, #c1c4cb)) 66%
|
|
1525
|
+
)
|
|
1526
|
+
100% 0 / 300% 100%;
|
|
1527
|
+
-webkit-background-clip: text;
|
|
1528
|
+
background-clip: text;
|
|
1529
|
+
-webkit-text-fill-color: transparent;
|
|
1530
|
+
animation: aia-smartSuggestion-shimmer-F-yoD 2.5s ease-in-out 2;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
.aia-smartSparkle-IVabG {
|
|
1534
|
+
display: inline-flex;
|
|
1535
|
+
color: var(--aia-smart-suggestion-accent, #b84549);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
.aia-smartSparkle-IVabG .aia-sparkle-large,
|
|
1539
|
+
.aia-smartSparkle-IVabG .aia-sparkle-small {
|
|
1540
|
+
transform-box: fill-box;
|
|
1541
|
+
transform-origin: center;
|
|
1542
|
+
animation: aia-smartSuggestion-sparkle-Wfj-4 2.5s ease-in-out 2;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
.aia-smartSparkle-IVabG .aia-sparkle-small {
|
|
1546
|
+
animation-name: aia-smartSuggestion-sparkle-small-3VsWJ;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
.aia-skeleton-57P0T .aia-smartText-R0cfw,
|
|
1550
|
+
.aia-skeleton-57P0T .aia-smartSparkle-IVabG {
|
|
1551
|
+
visibility: hidden;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
@keyframes aia-smartSuggestion-shimmer-F-yoD {
|
|
1555
|
+
0% {
|
|
1556
|
+
background-position: 100% 0;
|
|
1557
|
+
}
|
|
1558
|
+
60%,
|
|
1559
|
+
100% {
|
|
1560
|
+
background-position: 0 0;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
@keyframes aia-smartSuggestion-sparkle-Wfj-4 {
|
|
1565
|
+
0%,
|
|
1566
|
+
45%,
|
|
1567
|
+
75%,
|
|
1568
|
+
100% {
|
|
1569
|
+
transform: scale(1);
|
|
1570
|
+
}
|
|
1571
|
+
60% {
|
|
1572
|
+
transform: scale(1.12);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
@keyframes aia-smartSuggestion-sparkle-small-3VsWJ {
|
|
1577
|
+
0%,
|
|
1578
|
+
45%,
|
|
1579
|
+
75%,
|
|
1580
|
+
100% {
|
|
1581
|
+
transform: scale(1);
|
|
1582
|
+
opacity: 1;
|
|
1583
|
+
}
|
|
1584
|
+
60% {
|
|
1585
|
+
transform: scale(1.5);
|
|
1586
|
+
opacity: 0.55;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1591
|
+
.aia-smartText-R0cfw,
|
|
1592
|
+
.aia-smartSparkle-IVabG .aia-sparkle-large,
|
|
1593
|
+
.aia-smartSparkle-IVabG .aia-sparkle-small {
|
|
1594
|
+
animation: none;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
/* Forced colours drop the background-clip paint, so the text is drawn plainly. */
|
|
1599
|
+
@media (forced-colors: active) {
|
|
1600
|
+
.aia-smartText-R0cfw {
|
|
1601
|
+
background: none;
|
|
1602
|
+
-webkit-text-fill-color: currentColor;
|
|
1603
|
+
animation: none;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1497
1607
|
/* Loading skeleton \u2014 preserves the pill's exact box (same width and height)
|
|
1498
1608
|
and hides the text. The base pill is now transparent, so fill the interior
|
|
1499
1609
|
with the skeleton color (inside the dashed border) and pulse it so it still
|
|
@@ -1540,7 +1650,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1540
1650
|
opacity: 0;
|
|
1541
1651
|
}
|
|
1542
1652
|
}
|
|
1543
|
-
`,document.head.appendChild(e)}var
|
|
1653
|
+
`,document.head.appendChild(e)}var ie={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",smartText:"aia-smartText-R0cfw","smartSuggestion-shimmer":"aia-smartSuggestion-shimmer-F-yoD",smartSparkle:"aia-smartSparkle-IVabG","smartSuggestion-sparkle":"aia-smartSuggestion-sparkle-Wfj-4","smartSuggestion-sparkle-small":"aia-smartSuggestion-sparkle-small-3VsWJ",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};import{Fragment as ka,jsx as rt,jsxs as Ca}from"react/jsx-runtime";var st={selected:1,first:.7,next:.4,last:.2};function Et({label:e,state:n,rounded:t,loading:a,smartSuggestion:o,completionHeader:r,onClick:i}){let d=[ie.pill,t?ie.rounded:"",a?ie.skeleton:""].filter(Boolean).join(" ");return rt("button",{type:"button","data-aia-pill":"","data-aia-loading":a?"":void 0,"data-aia-smart-suggestion":o?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:d,style:{opacity:st[n]},onMouseDown:l=>l.preventDefault(),onClick:a?void 0:i,disabled:a,children:o?Ca(ka,{children:[rt("span",{className:`${ie.smartText} magicx-aia-smart-suggestion-text`,children:e}),rt("span",{className:`${ie.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:ya}})]}):e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
|
|
1544
1654
|
position: relative;
|
|
1545
1655
|
z-index: 1;
|
|
1546
1656
|
pointer-events: auto;
|
|
@@ -1550,7 +1660,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1550
1660
|
align-items: center;
|
|
1551
1661
|
vertical-align: middle;
|
|
1552
1662
|
}
|
|
1553
|
-
`,document.head.appendChild(e)}var
|
|
1663
|
+
`,document.head.appendChild(e)}var lt={list:"aia-list-qvLqO"};import{jsx as Ye}from"react/jsx-runtime";var Ia=[125,69];function At(e){return e===0?"first":e===1?"next":"last"}function $e({pills:e,activePillIndex:n,onSelectPill:t,activeSelected:a,rounded:o,loading:r}){return r&&e.length===0?Ye("span",{className:lt.list,"data-aia-pill-list-loading":"",children:Ia.map((i,d)=>Ye("span",{"data-aia-pill-skeleton":"",className:`${ie.pill} ${o?ie.rounded:""} ${ie.skeleton}`,style:{width:i,opacity:st[At(d)]}},`skel-${i}`))}):Ye("span",{className:lt.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((i,d)=>{let l=!!a&&d===n;return Ye(Et,{label:i.text,state:l?"selected":At(d),selected:l,rounded:o,loading:r,smartSuggestion:Sa(i),completionHeader:Pa(i),onClick:()=>t(d)},`${i.parameter}-${i.text}`)})})}import{attachProductRowWheel as Ta,productImageSources as Ea,productImageSrc as Aa,productInitial as Ra,uiStringsFor as Da}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Oa,useRef as La,useState as za}from"react";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
|
|
1554
1664
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1555
1665
|
theming one package sees the same result in the other.
|
|
1556
1666
|
|
|
@@ -1837,7 +1947,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1837
1947
|
letter-spacing: 0.02em;
|
|
1838
1948
|
text-align: center;
|
|
1839
1949
|
}
|
|
1840
|
-
`,document.head.appendChild(e)}var
|
|
1950
|
+
`,document.head.appendChild(e)}var Q={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",badge:"aia-badge-j9Hcd"};import{jsx as ce,jsxs as Ze}from"react/jsx-runtime";function Rt({products:e,listboxId:n,onSelect:t,onFocusChange:a,focusable:o=!0,layout:r="row",imageFallback:i="image",strings:d=Da()}){let l=e.length>0,b=La(null);if(Oa(()=>{let S=b.current;if(!(!l||!S))return Ta(S)},[l]),!l)return null;let C=`${n}-products-label`;return Ze("section",{className:Q.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":C,children:[ce("div",{className:Q.label,id:C,"data-aia-products-label":"",children:d.products}),ce("div",{ref:b,className:Q.row,"data-aia-products-row":"",children:e.map((S,m)=>ce(Ma,{product:S,id:`${n}-product-${m}`,onSelect:t,onFocusChange:a,focusable:o,imageFallback:i,soldOut:d.soldOut},S.id))})]})}function Ma({product:e,id:n,onSelect:t,onFocusChange:a,focusable:o,imageFallback:r,soldOut:i}){let d=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),t(e))};return Ze("a",{id:n,className:Q.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:o?0:-1,onClick:d,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),t(e))},onFocus:()=>a?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||a?.(!1)},children:[ce(Na,{sources:Ea(e.imageUrl),title:e.title,fallback:r},Aa(e.imageUrl)??""),Ze("span",{className:Q.body,children:[e.vendor?ce("span",{className:Q.vendor,children:e.vendor}):null,ce("span",{className:Q.title,children:e.title}),e.price?ce("span",{className:Q.price,children:e.price}):null,e.available===!1?ce("span",{className:Q.badge,children:i}):null]})]})}function Na({sources:e,title:n,fallback:t}){let[a,o]=za(0),r=e[a],i=!!r,d=!i&&t==="initial";return Ze("span",{className:Q.media,"aria-hidden":"true","data-aia-product-placeholder":!i&&!d?"":void 0,"data-aia-product-initial":d?"":void 0,children:[i?ce("img",{className:Q.image,src:r,alt:"",loading:"lazy",decoding:"async",onError:()=>o(l=>l+1)}):null,d?Ra(n):null]})}import{isOptionsGridMobileViewport as $a,measureOptionsGrid as Za,needsOptionsGridMeasurement as Xa,OPTIONS_GRID_MOBILE_QUERY as Ja,optionEnterDelayMs as ei,optionsShowLeadingVisuals as ti,planOptionsGrid as zt,sameOptionRows as ai}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ii,useLayoutEffect as oi,useRef as Mt,useState as Ft}from"react";import{optionsGridTemplateColumns as Fa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Ha,useRef as Ba}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
|
|
1841
1951
|
display: grid;
|
|
1842
1952
|
grid-template-columns: repeat(
|
|
1843
1953
|
auto-fit,
|
|
@@ -1873,7 +1983,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1873
1983
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
1874
1984
|
display: none;
|
|
1875
1985
|
}
|
|
1876
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1986
|
+
`,document.head.appendChild(e)}import{jsx as Ka}from"react/jsx-runtime";function Dt({min:e="16rem",max:n,gap:t,scroll:a=!1,maxHeight:o,scrollResetKey:r,cols:i,template:d,innerRef:l,className:b,children:C,...S}){let m=Ba(null);Ha(()=>{if(r===void 0)return;let P=m.current;P&&(P.scrollTop=0)},[r]);let w={"--aia-grid-min":e};return n&&(w["--aia-grid-max"]=n),t&&(w["--aia-grid-gap"]=t),o&&(w["--aia-grid-max-height"]=o),i&&(w.gridTemplateColumns=Fa(i)),d&&(w.gridTemplateColumns=d),Ka("div",{ref:P=>{m.current=P,l?.(P)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":a||void 0,style:w,...S,children:C})}import{formatOptionCount as Ga,highlightParts as Wa,OPTION_ENTER_DELAY_VAR as _a,optionImageSources as qa,optionLabel as Ot,sanitizeOptionIconSvg as Ua}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Va,useMemo as ja,useRef as Qa,useState as dt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
|
|
1877
1987
|
position: relative;
|
|
1878
1988
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1879
1989
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2054,6 +2164,12 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
2054
2164
|
opacity: var(--aia-option-parameter-opacity, 0.6);
|
|
2055
2165
|
}
|
|
2056
2166
|
|
|
2167
|
+
/* The part of a completion the typed text matches, in the Smart Suggestion accent. */
|
|
2168
|
+
.aia-match-pp-9v {
|
|
2169
|
+
color: var(--aia-smart-suggestion-accent, #b84549);
|
|
2170
|
+
font-weight: 600;
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2057
2173
|
.aia-item-d4vpD[data-aia-loading] .aia-parameter-Dt2zF {
|
|
2058
2174
|
display: none;
|
|
2059
2175
|
}
|
|
@@ -2305,7 +2421,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
2305
2421
|
opacity: 0;
|
|
2306
2422
|
}
|
|
2307
2423
|
}
|
|
2308
|
-
`,document.head.appendChild(e)}var
|
|
2424
|
+
`,document.head.appendChild(e)}var G={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",skeletonBarIn:"aia-skeletonBarIn-ZlEM0",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};import{Fragment as Ya,jsx as ke,jsxs as ct}from"react/jsx-runtime";function Lt({option:e,isHighlighted:n,onSelect:t,onHighlight:a,onUnhighlight:o,id:r,loading:i,showIcon:d=!0,showImage:l=!0,showCount:b=!0,scrollHint:C,enterDelayMs:S=0}){let[m]=dt(S),[w,P]=dt(!1),z=l?qa(e.image_url):[],M=z[0]??null,[B,W]=dt([]),I=z.find(A=>!B.includes(A))??null,O=ja(()=>!M&&d&&e.icon_svg?Ua(e.icon_svg):null,[M,d,e.icon_svg]),E=b?Ga(e.item_count):null,y=Qa(void 0);Va(()=>()=>clearTimeout(y.current),[]);let N=()=>{i||!e.is_tappable||w||(P(!0),t(e),clearTimeout(y.current),y.current=setTimeout(()=>P(!1),170))},K=[G.item,n&&!i?G.highlighted:"",e.is_tappable?G.tappable:G.nonTappable,w?G.pressed:"",C?G.scrollHint:""].filter(Boolean).join(" ");return ke("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"data-aia-icon":O&&e.icon?e.icon:void 0,"data-aia-image":M?"":void 0,"data-aia-item-count":E!==null?e.item_count:void 0,"aria-selected":n,className:K,style:{[_a]:`${m}ms`},tabIndex:i||!e.is_tappable?-1:0,onClick:N,onKeyDown:A=>{!i&&e.is_tappable&&(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),N())},onMouseEnter:!i&&e.is_tappable?a:void 0,onMouseLeave:o,children:ct("span",{className:G.content,children:[M&&ke("span",{className:`${G.image} magicx-aia-option-image`,"aria-hidden":"true",children:ke("img",{src:I??M,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:I===null,onError:()=>{I!==null&&W(A=>[...A,I])}})}),O&&ke("span",{className:`${G.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:O}}),ct("span",{className:G.text,children:[e.matchedText?Wa(Ot(e),e.matchedText).map((A,$)=>A.bold?ke("strong",{className:`${G.match} magicx-aia-option-match`,children:A.text},$):A.text):Ot(e),e.parameterLabel&&ct(Ya,{children:[" ",ke("span",{className:`${G.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&ke("span",{className:G.tag,children:e.tag}),E!==null&&ke("span",{className:`${G.count} magicx-aia-option-count`,children:E})]})})}import{jsx as Nt}from"react/jsx-runtime";function ni(){let[e,n]=Ft($a);return ii(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Ja),a=()=>n(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function Ht({options:e,activeIndex:n,onSelect:t,onHighlight:a,onUnhighlight:o,listboxId:r,loading:i,groupKey:d="",optionsPosition:l="below",showIcons:b=!0,showImages:C=!0,showCounts:S=!0}){let m=ni(),w=Mt(null),[P,z]=Ft(null),M=Mt(null);oi(()=>{if(i&&ai(M.current,e))return;M.current=i?null:e;let I=w.current,E=I&&!i&&Xa(e.length,m)?Za(I):null;z(E?zt(e.length,m,E.rowWidths,E.gridWidth):null)},[e,m,i]);let B=P??zt(e.length,m,null,null),W=ti(e,b,C);return Nt(Dt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:d,template:B.template,maxHeight:B.maxHeight,innerRef:I=>{w.current=I},"data-aia-group":d,children:e.map((I,O)=>Nt(Lt,{option:I,isHighlighted:O===n,onSelect:t,onHighlight:()=>a(O),onUnhighlight:o?()=>o(O):void 0,id:`${r}-option-${O}`,loading:i,showIcon:b&&W,showImage:C&&W,showCount:S,scrollHint:!i&&B.scrollHintIndices.includes(O),enterDelayMs:i?0:ei(O,B.cols,e.length,l)},`${d}\0${I.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
2309
2425
|
display: flex;
|
|
2310
2426
|
flex-direction: column;
|
|
2311
2427
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2320,7 +2436,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
2320
2436
|
align-items: end;
|
|
2321
2437
|
}
|
|
2322
2438
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2323
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
2439
|
+
`,document.head.appendChild(e)}import{jsx as ri}from"react/jsx-runtime";function Bt({space:e,align:n="stretch",className:t,children:a,...o}){let r=e?{"--aia-stack-space":e}:void 0;return ri("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":n,style:r,...o,children:a})}import{jsx as Y,jsxs as pt}from"react/jsx-runtime";var gi=[159,119,164],fi=()=>{},Kt=()=>{};function bi(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=mi(n);if(Oe(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>a(o.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function wi(e,n){let t=De(null);Oe(()=>{let a=e.current,o=n.current;if(!a||!o)return;let r=a.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==r&&(t.current.controller.destroy(),t.current=null),r&&!t.current){t.current={grid:r,controller:si({dropdown:a,grid:r,button:o})};return}t.current?.controller.update()}),Oe(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function vi(e,n){let t=De(n);t.current=n;let a=De(null);Oe(()=>{let o=e.current;if(o){if(!a.current){a.current=li({dropdown:o,isOpen:()=>t.current});return}a.current.update()}}),Oe(()=>()=>{a.current?.destroy(),a.current=null},[])}function ht({suggestions:e,activeIndex:n,onSelect:t,onHighlight:a,onUnhighlight:o,isOpen:r,id:i,className:d,pills:l,onPillClick:b,showPills:C=!0,onSkip:S,showSkipButton:m=!0,showOptionIcons:w=!0,showOptionImages:P=!0,showOptionCounts:z=!0,skipDisabled:M=!1,activeSelected:B=!1,isLoading:W=!1,skeletonExiting:I=!1,isInputEmpty:O=!1,language:E,products:y,onProductSelect:N,onProductFocusChange:K,productsLayout:A="row",productImageFallback:$="image",formatType:pe="options",dateView:_=null,selectedDateIso:he=null,selectedDateRange:Ce=null,dateRangeStart:ue=null,onPreviousMonth:u,onNextMonth:Se,optionsPosition:oe="below",mode:me}){let ne=bi(me),ge=ne!==void 0,U=De(null),Z=De(null);wi(U,Z),Oe(()=>{if(U.current)return di(U.current)},[]);let s=e[0]?.options??[],g=!!(l&&l.length>0&&b),f=!!(y&&y.length>0),v=r&&(s.length>0||C&&g||W||f);vi(U,v);let k={suggestions:e,activeIndex:n,pills:l,showPills:C,showSkipButton:m,showOptionIcons:w,showOptionImages:P,showOptionCounts:z,skipDisabled:M,activeSelected:B,isLoading:W,skeletonExiting:I,isInputEmpty:O,products:y,formatType:pe,dateView:_,selectedDateIso:he,selectedDateRange:Ce,dateRangeStart:ue},T=De(k);v&&(T.current=k);let p=v?k:T.current,F=ui(E),V=p.suggestions[0],j=V?.options??[],fe=p.activeIndex>=0&&!!j[p.activeIndex]?.is_tappable,re=hi(p.pills??[],F.keepTyping),J=!!(re.length>0&&b),be=p.showPills&&J,Pe=p.showPills&&!J&&p.isLoading,x=be||Pe,we=J&&ci(re)&&p.showSkipButton&&!p.isInputEmpty&&!!S,ve=re[0]?.text,se=pi(p.formatType)&&p.dateView!=null,h=j.length>0&&!se,Ie=j.length>0&&se&&!p.isLoading,Ne=p.isLoading&&!h&&!Ie,xe=p.products??[];return pt("div",{ref:U,id:i,role:"listbox","data-aia-dropdown":"","data-options-position":oe,"data-mode":ne,"data-aia-loading":p.isLoading?"":void 0,"data-aia-skeleton-exiting":p.skeletonExiting?"":void 0,"data-aia-has-products":xe.length>0?"":void 0,className:`${ge?"magicx-aia ":""}${le.dropdown} ${v?le.visible:""} ${d??""}`,onMouseDown:ee=>ee.preventDefault(),children:[pt(Bt,{space:"8px",children:[(x||we)&&pt(Ke,{noWrap:!0,className:le.pillBar,"data-aia-pillbar":"",children:[x&&Y("span",{className:le.pillScroll,"data-aia-pill-scroll":"",children:Y($e,{pills:re,activePillIndex:0,activeSelected:p.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:p.isLoading})}),we&&Y("button",{type:"button",tabIndex:-1,className:le.skip,"data-aia-skip":"",disabled:p.isLoading||p.skipDisabled,"aria-label":ve?`${F.skipLabel} ${ve}`:F.skipLabel,onClick:S,children:F.skip})]}),h&&Y(Ht,{options:j,activeIndex:p.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:o,listboxId:i,loading:p.isLoading,groupKey:V?`${V.parameter} ${V.text}`:"",optionsPosition:oe,showIcons:p.showOptionIcons,showImages:p.showOptionImages,showCounts:p.showOptionCounts}),Ie&&p.dateView&&Y(Pt,{options:j,activeIndex:p.activeIndex,listboxId:i,view:p.dateView,selection:{selectedIso:p.selectedDateIso??null,selectedRange:p.selectedDateRange??null,rangeStart:p.dateRangeStart??null},onSelect:t,onHighlight:a,onUnhighlight:o,onPreviousMonth:u??Kt,onNextMonth:Se??Kt}),Ne&&Y("div",{className:le.skeletonBars,"data-aia-skeleton-bars":"",children:gi.map(ee=>Y("span",{className:le.skeletonBar,style:{width:ee}},`bar-${ee}`))}),Y(Rt,{products:xe,listboxId:i,onSelect:N??fi,onFocusChange:K,focusable:v,layout:A,imageFallback:$,strings:F}),Y(Tt,{isOptionHighlighted:fe,isInputEmpty:p.isInputEmpty,strings:F})]}),Y("button",{ref:Z,type:"button",tabIndex:-1,className:le.scrollArrow,"data-aia-scroll-arrow":"","aria-label":F.scrollArrow,"aria-hidden":"true",children:Y("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:Y("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Mi,ModeController as Ni,setCursorOffset as Fi,uiStringsFor as Hi}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as xi}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=`.aia-submitButton-otz7H {
|
|
2324
2440
|
flex-shrink: 0;
|
|
2325
2441
|
width: 32px;
|
|
2326
2442
|
height: 32px;
|
|
@@ -2373,5 +2489,5 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
2373
2489
|
);
|
|
2374
2490
|
cursor: default;
|
|
2375
2491
|
}
|
|
2376
|
-
`,document.head.appendChild(e)}var Kt={submitButton:"aia-submitButton-otz7H"};import{jsx as ht}from"react/jsx-runtime";function Gt({disabled:e,onClick:o,label:t=mi().submit}){return ht("button",{type:"button","data-aia-submit":"",className:Kt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),o()},"aria-label":t,children:ht("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:ht("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as fi,dateSelectionFor as bi,identifiedParamLabel as wi,withoutTraditionalAutocomplete as vi}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as jt,useEffect as Le,useRef as B,useState as xi}from"react";import{useRef as Wt}from"react";function _t(e){let o=Wt(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=Wt({key:"",overrides:void 0});if(a.current.key!==t){let n={};for(let r of Object.keys(e??{})){let i=(c,l,b)=>{let C=o.current?.[r];return C?C(c,l,b):[]};n[r]=i}a.current={key:t,overrides:e?n:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as qt}from"react";function Ut(e){let o=qt(e);o.current=e;let t=qt(null);t.current===null&&(t.current={fetch:(n,r)=>{let i=o.current;return i?i.fetch(n,r):Promise.reject(new Error("products config removed"))},transform:n=>o.current?.transform(n)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var yi={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function ut({onSubmit:e,onResult:o,onError:t,optionOverrides:a,maskCompletedText:n,apiConfig:r,additionalContext:i,language:c,productId:l,visitorId:b,columns:C=2,dropdownTrigger:P,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:S,showOptionIcons:z,showOptionImages:M,showOptionCounts:H,showSkipButton:G,showProducts:I,productImageFallback:O="image",onFocus:E,onBlur:y,value:N,completedParams:K,onChange:A,onParamsChange:Z,products:ce,mapProducts:W,onProductSelect:pe,source:Ce,setCursor:he}){let u=B(null),[Pe,ie]=xi(null),ue=B(e);ue.current=e;let oe=B(o);oe.current=o;let ge=B(t);ge.current=t;let U=B(A);U.current=A;let $=B(Z);$.current=Z;let s=B(E);s.current=E;let m=B(y);m.current=y;let f=B(he);f.current=he;let v=B(pe);v.current=pe;let k=B(b);k.current=b;let T=B(()=>{let d=k.current;return typeof d=="function"?d():d}).current,p=Ut(ce),F=B(W);F.current=W;let j=B((d,_)=>{let R=F.current;return R?R(d,_):d}).current,Q=W?j:void 0,me=_t(a);Le(()=>{if(typeof document>"u")return;let d=new fi(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:i,language:c,productId:l,visitorId:T,optionOverrides:me.overrides,maskCompletedText:n,columns:C,dropdownTrigger:P,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:S,showProducts:I,source:Ce,value:N,completedParams:K,onSubmit:(...R)=>ue.current?.(...R),onResult:(...R)=>oe.current?.(...R),onError:(...R)=>ge.current?.(...R),onChange:(...R)=>U.current?.(...R),onParamsChange:(...R)=>$.current?.(...R),onFocus:()=>s.current?.(),onBlur:()=>m.current?.(),onProductSelect:R=>v.current?.(R),setCursor:R=>f.current?.(R),products:p.config,mapProducts:Q});u.current=d,ie(d.getState());let _=d.subscribe(R=>ie(R));return()=>{_(),d.destroy(),u.current===d&&(u.current=null)}},[]),Le(()=>{N!==void 0&&u.current?.setValue(N)},[N]),Le(()=>{K!==void 0&&u.current?.setCompletedParams(K)},[K]);let ne=JSON.stringify(r??null),J;try{J=JSON.stringify(i??null)}catch{J="[unstringifiable]"}Le(()=>{u.current?.update({apiConfig:r,additionalContext:i,language:c,productId:l,optionOverrides:me.overrides,dropdownTrigger:P,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:S,showProducts:I})},[ne,J,c,l,me.key,P,g,w,S,I]);let fe=B(!1);Le(()=>{if(!fe.current){fe.current=!0;return}u.current?.update({products:p.config})},[p.enabled]),Le(()=>{u.current?.update({mapProducts:Q})},[Q]);let Se=B(null);Se.current===null&&(Se.current={handleTextChange:d=>u.current?.handleTextChange(d),handleKeyDown:d=>{let _="nativeEvent"in d?d.nativeEvent:d;u.current?.handleKeyDown(_)},setFocused:d=>u.current?.setFocused(d),startEditingParam:d=>u.current?.startEditingParam(d),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:d=>u.current?.handleCaretAfterInput(d),handleCaretMove:d=>u.current?.handleCaretMove(d),replaceEditingRange:d=>u.current?.replaceEditingRange(d)??!1,setActivePill:d=>u.current?.setActivePill(d),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),refreshProducts:()=>u.current?.refreshProducts(),recordSubmit:d=>u.current?.recordSubmit(d),selectOption:d=>u.current?.selectOption(d),selectProduct:d=>u.current?.selectProduct(d),setActiveDropdownIndex:d=>u.current?.setActiveDropdownIndex(d),clearHighlight:d=>u.current?.clearHighlight(d),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let x=Se.current,be=jt(d=>{let _=d.target.value,at=_.length>0&&!d.nativeEvent?.isComposing&&_[0]!==_[0].toUpperCase()?_[0].toUpperCase()+_.slice(1):_;u.current?.handleTextChange(at)},[]),we=jt(d=>{u.current?.handleKeyDown(d.nativeEvent)},[]),re=u.current,h=Pe??yi,Ie=N!==void 0?N:h.text,Ne=K!==void 0?K:h.completedParams,ve=h.actionableSuggestions,ee=ve[0],_e=vi(ve),Te=re?.listboxId??"",et=h.activeDropdownIndex>=0&&re?`${Te}-option-${h.activeDropdownIndex}`:void 0,xe=h.editingParam,Ee=h.editingIdentified,Fe=xe?{parameter:xe.suggestionParameter,text:xe.suggestionPlaceholder,required:!0,options:xe.options}:Ee?{parameter:Ee.parameter,text:wi(Ee.parameter),required:!0,options:[]}:null,qe=h.dropdownSuggestion??Fe??ee,tt=Fe?[Fe]:ve,Be=bi(h),Ue=!re||h.dropdownLoading;return{completedParams:Ne,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:_e,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:h.segments,newParamId:h.newParamId,clearNewParamId:x.clearNewParamId,suggestions:h.suggestions,activeIndex:h.activeDropdownIndex,isReady:h.isReady,isLoading:Ue,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:Te,error:h.error,products:h.products,customFields:h.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:xe,editingIdentified:Ee,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Ie,placeholder:h.placeholderText||void 0,onChange:be,onKeyDown:we,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":et,"aria-autocomplete":"list","aria-controls":Te},reset:x.reset,refreshProducts:x.refreshProducts,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:qe?[{...qe,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:h.isDropdownOpen,id:Te,pills:tt,activeSelected:h.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(G??!0)&&!xe&&!Ee,showOptionIcons:z??!0,showOptionImages:M??!0,showOptionCounts:H??!0,skipDisabled:h.inSelectionAnimation,isLoading:Ue,skeletonExiting:h.skeletonExiting,isInputEmpty:Ie.trim().length===0,language:c,products:h.products,productImageFallback:O,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Be.selectedIso,selectedDateRange:Be.selectedRange,dateRangeStart:Be.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:g??"below"}}}import{chipIdFromTap as ki,extractPlainText as Qt,getCursorOffset as Yt,keepCaretOnChip as Ci,plainTextLength as Pi,renderEditableContent as Si,setCursorOffset as Vt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as X,useEffect as Xe,useLayoutEffect as gt,useRef as ze}from"react";var Je;function Ii(){if(Je!==void 0)return Je;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Je=e.contentEditable==="plaintext-only",Je}function Zt(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,newParamId:n,editingParam:r,editingIdentified:i,editingAnchor:c,caretOffset:l,placeholderText:b,isFocused:C,isDropdownOpen:P,listboxId:g,activeDescendantId:w,autoFocus:S,handleTextChange:z,handleKeyDown:M,handleCaretAfterInput:H,handleCaretMove:G,startEditingParam:I,replaceEditingRange:O,setFocused:E}=e,y=ze(null),N=ze(!1),K=ze(""),A=ze(""),Z=ze(null),ce=ze(0);Z.current=l,Xe(()=>{if(!S)return;let s=y.current;if(!s)return;document.activeElement===s?E(!0):s.focus();let m=s.ownerDocument??document,f=m.getSelection(),v=f&&f.rangeCount>0&&s.contains(f.anchorNode);if(f&&!v){let k=m.createRange();k.selectNodeContents(s),k.collapse(!0),f.removeAllRanges(),f.addRange(k)}},[S,E]),Xe(()=>{let s=y.current;if(!s)return;let m=s.ownerDocument??document,f=()=>{let v=m.getSelection();if(!v||v.rangeCount===0||!v.anchorNode||!s.contains(v.anchorNode))return;let k=v.anchorNode,T=k.nodeType===Node.ELEMENT_NODE?k:k.parentElement,F=(v.isCollapsed?T?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,j=r?.id??i?.id??null;if(F&&F!==j){I(F);return}performance.now()-ce.current<50||G(Yt(s))};return m.addEventListener("selectionchange",f),()=>m.removeEventListener("selectionchange",f)},[r,i,I,G]),Xe(()=>{let s=y.current;if(!s)return;let m=f=>{let v=ki(s,f.target);v&&(I(v),Ci(s,v))};return s.addEventListener("click",m),()=>s.removeEventListener("click",m)},[I]),gt(()=>{let s=y.current;s&&Si({input:s,segments:o,newParamId:n,editingParamId:r?.id??null,placeholderText:b??"",isFocused:C,showChipIcons:t,showChipImages:a})},[o,n,r,b,C,t,a]),gt(()=>{let s=K.current,m=n??"";if(K.current=m,!m||m===s)return;let f=y.current;if(!f)return;f.focus();let v=Z.current??Pi(f);Vt(f,v)},[n]),gt(()=>{let s=A.current,m=r?.id??"";if(A.current=m,!m||m===s||c==null)return;let f=y.current;f&&Vt(f,c)},[r,c]);let W=X(()=>{if(N.current)return;let s=y.current;if(!s)return;let m=Qt(s),v=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;z(v)},[z]),pe=X(()=>{ce.current=performance.now(),W();let s=y.current;s&&H(Yt(s))},[W,H]);Xe(()=>{let s=y.current;if(!s)return;let m=f=>{let v=f,k=v.inputType;if(k==="insertParagraph"||k==="insertLineBreak"||k==="insertFromDrop"){f.preventDefault();return}if(k.startsWith("insert")||k.startsWith("delete")){let T=k.startsWith("delete")?"":v.data??"";O(T)&&f.preventDefault()}};return s.addEventListener("beforeinput",m),()=>s.removeEventListener("beforeinput",m)},[O]);let Ce=X(()=>{N.current=!0,y.current?.setAttribute("data-aia-composing","true")},[]),he=X(()=>{N.current=!1,y.current?.removeAttribute("data-aia-composing"),W()},[W]),u=X(s=>{s.preventDefault();let m=y.current;if(!m)return;let f=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let v=m.ownerDocument??document,k=v.getSelection();if(!k||k.rangeCount===0)return;let T=k.getRangeAt(0);if(!m.contains(T.startContainer))return;T.deleteContents();let p=v.createTextNode(f);T.insertNode(p),T.setStartAfter(p),T.collapse(!0),k.removeAllRanges(),k.addRange(T),W()},[W]),Pe=X(s=>M(s),[M]),ie=X(()=>E(!0),[E]),ue=X(()=>E(!1),[E]),oe=X(()=>y.current?.focus(),[]),ge=X(()=>y.current?.blur(),[]),U=X(()=>{let s=y.current;return s?Qt(s):""},[]),$=Ii()?"plaintext-only":"true";return{inputRef:y,editorProps:{ref:y,contentEditable:$,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":g,"aria-expanded":P,"aria-activedescendant":w,spellCheck:!0,enterKeyHint:"send",onInput:pe,onKeyDown:Pe,onCompositionStart:Ce,onCompositionEnd:he,onPaste:u,onFocus:ie,onBlur:ue},getPlainText:U,focus:oe,blur:ge}}import{jsx as Me,jsxs as ft}from"react/jsx-runtime";function zi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Mi=Ti(function({onSubmit:o,onResult:t,onError:a,optionOverrides:n,maskCompletedText:r,className:i,apiConfig:c,additionalContext:l,language:b,productId:C,visitorId:P,columns:g,pillPlacement:w="dropdown",mode:S="auto",optionsPosition:z="below",animations:M=!0,dropdownTrigger:H,closeDropdownOnBlur:G,showNonTappableOptions:I,showOptionIcons:O=!0,showChipIcons:E=!0,showChipImages:y=!0,showOptionImages:N=!0,showOptionCounts:K=!0,showSkipButton:A,showProducts:Z,productsLayout:ce,productImageFallback:W,autoFocus:pe=!0,onFocus:Ce,onBlur:he,value:u,completedParams:Pe,onChange:ie,onParamsChange:ue,products:oe,mapProducts:ge,onProductSelect:U,submitButton:$,resetOnSubmit:s=!0},m){let f=We(null),v=We(null),k=We(()=>{}),T=We(null),p=We(null);$t(()=>{let D=f.current;if(D)return T.current?T.current.setMode(S):T.current=new Di(D,S),()=>{T.current?.destroy(),T.current=null}},[S]);let F=mt(D=>{let te=p.current?.current;te&&(te.focus(),Oi(te,D))},[]),{completedParams:j,skippedParams:Q,identifiedParams:me,isReady:ne,customFields:J,suggestionPills:fe,setActivePill:Se,skipActivePill:x,segments:be,newParamId:we,clearNewParamId:re,placeholderText:h,isFocused:Ie,isDropdownOpen:Ne,isActivePillSelected:ve,isLoading:ee,activeIndex:_e,listboxId:Te,handleTextChange:et,handleKeyDown:xe,setFocused:Ee,editingParam:Fe,editingIdentified:qe,editingAnchor:tt,caretOffset:Be,startEditingParam:Ue,handleCaretAfterInput:d,handleCaretMove:_,replaceEditingRange:R,dropdownProps:at,reset:je,refreshProducts:bt,recordSubmit:wt}=ut({onSubmit:D=>k.current(D),onResult:t,onError:a,optionOverrides:n,maskCompletedText:r,apiConfig:c,additionalContext:l,language:b,productId:C,visitorId:P,columns:g,dropdownTrigger:H,optionsPosition:z,closeDropdownOnBlur:G,showNonTappableOptions:I,showOptionIcons:O,showOptionImages:N,showOptionCounts:K,showSkipButton:A,showProducts:Z,onFocus:Ce,onBlur:he,value:u,completedParams:Pe,onChange:ie,onParamsChange:ue,products:oe,mapProducts:ge,onProductSelect:U,source:"full-sdk",setCursor:F});$t(()=>{if(!we)return;let D=window.setTimeout(()=>re(),650);return()=>window.clearTimeout(D)},[we,re]);let Xt=_e>=0?`${Te}-option-${_e}`:void 0,{inputRef:it,editorProps:Jt,focus:Qe,blur:vt,getPlainText:xt}=Zt({segments:be,newParamId:we,editingParam:Fe,editingIdentified:qe,editingAnchor:tt,caretOffset:Be,placeholderText:h,isFocused:Ie,showChipIcons:E,showChipImages:y,isDropdownOpen:Ne,listboxId:Te,activeDescendantId:Xt,autoFocus:pe,handleTextChange:et,handleKeyDown:xe,handleCaretAfterInput:d,handleCaretMove:_,startEditingParam:Ue,replaceEditingRange:R,setFocused:Ee});p.current=it,Ai(()=>{let D=v.current,te=it.current;if(!D||!te)return;let He=()=>{let kt=D.firstElementChild;if(!kt)return;let ia=kt.getBoundingClientRect(),oa=te.getBoundingClientRect();ia.top>=oa.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};He();let yt=new ResizeObserver(He);return yt.observe(te),()=>yt.disconnect()},[be,fe.length,ee,it]),Ei(m,()=>({focus:Qe,blur:vt,reset:je,refreshProducts:bt,setMode:D=>T.current?.setMode(D),skipActivePill:x}),[Qe,vt,je,bt,x]);let Ye=!!be.length||j.length>0,ot=mt(D=>{if(!Ye)return;let te=xt(),He=Ri(te,j,Q,{identifiedParams:me,isReady:ne,customFields:J});D&&wt(He),o(He),s&&je()},[wt,s,Ye,j,Q,me,ne,J,o,je,xt]);k.current=()=>ot(!1);let ea=mt(D=>{D.target?.closest("[data-aia-pill]")||Qe()},[Qe]),ta=w==="inline",aa=w==="dropdown";return ft("div",{ref:f,className:`magicx-aia ${Ae.container} ${i??""}`,"data-pill-placement":w,"data-options-position":z,"data-animations":M?"on":"off","data-mode":zi(S),children:[Me(pt,{...at,showPills:aa,productsLayout:ce,productImageFallback:W}),ft("div",{className:Ae.inputWrapper,"data-aia-input-wrapper":"",onClick:ea,children:[ft("div",{className:Ae.editorArea,"data-aia-editor":"",children:[Me("div",{...Jt,className:Ae.input,"data-aia-input":""}),ta&&(ee||fe.length>0)&&Me("span",{ref:v,className:Ae.pillListContainer,"data-aia-pill-list-container":"",children:Me(Ze,{pills:fe,activePillIndex:0,activeSelected:ve,onSelectPill:Se,loading:ee})})]}),$===null?null:$===void 0?Me(Gt,{disabled:!Ye,onClick:()=>ot(!0),label:Li(b).submit}):Me("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ae.submitSlot,onClick:D=>{Ye&&(D.stopPropagation(),ot(!0))},children:$})]})]})});export{Mi as AIAutocomplete,pt as AIAutocompleteDropdown,Dn as DATE_RANGE_META_END,On as DATE_RANGE_META_START,Ln as DEFAULT_OPTION_COUNT_UNIT,jn as PRODUCT_PATH_PREFIX,ar as WEEKDAY_LABELS,En as buildSubmitResult,An as cellDay,Rn as cellIso,zn as dateCellMarks,Mn as formatDate,Nn as formatDateRange,Fn as formatOptionCount,Bn as isoDate,Hn as monthLabel,Kn as optionCountLabel,Gn as optionHasImage,Wn as optionImageSources,_n as optionImageSrc,qn as optionLabel,Un as optionsShowLeadingVisuals,Qn as parseDate,Yn as parseLooseDate,Vn as parseLooseDateRange,Zn as productFromMatchedItem,$n as productImageSources,Xn as productsFromCustomFields,Jn as sanitizeOptionIconSvg,er as selectedRangeFor,ut as useAIAutocomplete,tr as visibleDateRange,ir as withSkippedParams};
|
|
2492
|
+
`,document.head.appendChild(e)}var Gt={submitButton:"aia-submitButton-otz7H"};import{jsx as ut}from"react/jsx-runtime";function Wt({disabled:e,onClick:n,label:t=xi().submit}){return ut("button",{type:"button","data-aia-submit":"",className:Gt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),n()},"aria-label":t,children:ut("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:ut("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as yi,dateSelectionFor as ki,identifiedParamLabel as Ci,withoutTraditionalAutocomplete as Si}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as jt,useEffect as Le,useRef as H,useState as Pi}from"react";import{useRef as _t}from"react";function qt(e){let n=_t(e);n.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=_t({key:"",overrides:void 0});if(a.current.key!==t){let o={};for(let r of Object.keys(e??{})){let i=(d,l,b)=>{let C=n.current?.[r];return C?C(d,l,b):[]};o[r]=i}a.current={key:t,overrides:e?o:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as Ut}from"react";function Vt(e){let n=Ut(e);n.current=e;let t=Ut(null);t.current===null&&(t.current={fetch:(o,r)=>{let i=n.current;return i?i.fetch(o,r):Promise.reject(new Error("products config removed"))},transform:o=>n.current?.transform(o)??[],get limit(){return n.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var Ii={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function mt({onSubmit:e,onResult:n,onError:t,optionOverrides:a,maskCompletedText:o,apiConfig:r,additionalContext:i,language:d,productId:l,visitorId:b,columns:C=2,dropdownTrigger:S,optionsPosition:m,closeDropdownOnBlur:w,showNonTappableOptions:P,showOptionIcons:z,showOptionImages:M,showOptionCounts:B,showSkipButton:W,showProducts:I,productImageFallback:O="image",onFocus:E,onBlur:y,value:N,completedParams:K,onChange:A,onParamsChange:$,products:pe,mapProducts:_,onProductSelect:he,source:Ce,setCursor:ue}){let u=H(null),[Se,oe]=Pi(null),me=H(e);me.current=e;let ne=H(n);ne.current=n;let ge=H(t);ge.current=t;let U=H(A);U.current=A;let Z=H($);Z.current=$;let s=H(E);s.current=E;let g=H(y);g.current=y;let f=H(ue);f.current=ue;let v=H(he);v.current=he;let k=H(b);k.current=b;let T=H(()=>{let c=k.current;return typeof c=="function"?c():c}).current,p=Vt(pe),F=H(_);F.current=_;let V=H((c,q)=>{let R=F.current;return R?R(c,q):c}).current,j=_?V:void 0,fe=qt(a);Le(()=>{if(typeof document>"u")return;let c=new yi(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:i,language:d,productId:l,visitorId:T,optionOverrides:fe.overrides,maskCompletedText:o,columns:C,dropdownTrigger:S,optionsPosition:m,closeDropdownOnBlur:w,showNonTappableOptions:P,showProducts:I,source:Ce,value:N,completedParams:K,onSubmit:(...R)=>me.current?.(...R),onResult:(...R)=>ne.current?.(...R),onError:(...R)=>ge.current?.(...R),onChange:(...R)=>U.current?.(...R),onParamsChange:(...R)=>Z.current?.(...R),onFocus:()=>s.current?.(),onBlur:()=>g.current?.(),onProductSelect:R=>v.current?.(R),setCursor:R=>f.current?.(R),products:p.config,mapProducts:j});u.current=c,oe(c.getState());let q=c.subscribe(R=>oe(R));return()=>{q(),c.destroy(),u.current===c&&(u.current=null)}},[]),Le(()=>{N!==void 0&&u.current?.setValue(N)},[N]),Le(()=>{K!==void 0&&u.current?.setCompletedParams(K)},[K]);let re=JSON.stringify(r??null),J;try{J=JSON.stringify(i??null)}catch{J="[unstringifiable]"}Le(()=>{u.current?.update({apiConfig:r,additionalContext:i,language:d,productId:l,optionOverrides:fe.overrides,dropdownTrigger:S,optionsPosition:m,closeDropdownOnBlur:w,showNonTappableOptions:P,showProducts:I})},[re,J,d,l,fe.key,S,m,w,P,I]);let be=H(!1);Le(()=>{if(!be.current){be.current=!0;return}u.current?.update({products:p.config})},[p.enabled]),Le(()=>{u.current?.update({mapProducts:j})},[j]);let Pe=H(null);Pe.current===null&&(Pe.current={handleTextChange:c=>u.current?.handleTextChange(c),handleKeyDown:c=>{let q="nativeEvent"in c?c.nativeEvent:c;u.current?.handleKeyDown(q)},setFocused:c=>u.current?.setFocused(c),startEditingParam:c=>u.current?.startEditingParam(c),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:c=>u.current?.handleCaretAfterInput(c),handleCaretMove:c=>u.current?.handleCaretMove(c),replaceEditingRange:c=>u.current?.replaceEditingRange(c)??!1,setActivePill:c=>u.current?.setActivePill(c),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),refreshProducts:()=>u.current?.refreshProducts(),recordSubmit:c=>u.current?.recordSubmit(c),selectOption:c=>u.current?.selectOption(c),selectProduct:c=>u.current?.selectProduct(c),setActiveDropdownIndex:c=>u.current?.setActiveDropdownIndex(c),clearHighlight:c=>u.current?.clearHighlight(c),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let x=Pe.current,we=jt(c=>{let q=c.target.value,at=q.length>0&&!c.nativeEvent?.isComposing&&q[0]!==q[0].toUpperCase()?q[0].toUpperCase()+q.slice(1):q;u.current?.handleTextChange(at)},[]),ve=jt(c=>{u.current?.handleKeyDown(c.nativeEvent)},[]),se=u.current,h=Se??Ii,Ie=N!==void 0?N:h.text,Ne=K!==void 0?K:h.completedParams,xe=h.actionableSuggestions,ee=xe[0],_e=Si(xe),Te=se?.listboxId??"",et=h.activeDropdownIndex>=0&&se?`${Te}-option-${h.activeDropdownIndex}`:void 0,ye=h.editingParam,Ee=h.editingIdentified,Fe=ye?{parameter:ye.suggestionParameter,text:ye.suggestionPlaceholder,required:!0,options:ye.options}:Ee?{parameter:Ee.parameter,text:Ci(Ee.parameter),required:!0,options:[]}:null,qe=h.dropdownSuggestion??Fe??ee,tt=Fe?[Fe]:xe,He=ki(h),Ue=!se||h.dropdownLoading;return{completedParams:Ne,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:_e,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:h.segments,newParamId:h.newParamId,clearNewParamId:x.clearNewParamId,suggestions:h.suggestions,activeIndex:h.activeDropdownIndex,isReady:h.isReady,isLoading:Ue,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:Te,error:h.error,products:h.products,customFields:h.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:ye,editingIdentified:Ee,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Ie,placeholder:h.placeholderText||void 0,onChange:we,onKeyDown:ve,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":et,"aria-autocomplete":"list","aria-controls":Te},reset:x.reset,refreshProducts:x.refreshProducts,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:qe?[{...qe,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:h.isDropdownOpen,id:Te,pills:tt,activeSelected:h.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(W??!0)&&!ye&&!Ee,showOptionIcons:z??!0,showOptionImages:M??!0,showOptionCounts:B??!0,skipDisabled:h.inSelectionAnimation,isLoading:Ue,skeletonExiting:h.skeletonExiting,isInputEmpty:Ie.trim().length===0,language:d,products:h.products,productImageFallback:O,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:He.selectedIso,selectedDateRange:He.selectedRange,dateRangeStart:He.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:m??"below"}}}import{chipIdFromTap as Ti,extractPlainText as Qt,getCursorOffset as Yt,keepCaretOnChip as Ei,plainTextLength as Ai,renderEditableContent as Ri,setCursorOffset as $t}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as X,useEffect as Xe,useLayoutEffect as gt,useRef as ze}from"react";var Je;function Di(){if(Je!==void 0)return Je;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Je=e.contentEditable==="plaintext-only",Je}function Zt(e){let{segments:n,showChipIcons:t=!0,showChipImages:a=!0,newParamId:o,editingParam:r,editingIdentified:i,editingAnchor:d,caretOffset:l,placeholderText:b,isFocused:C,isDropdownOpen:S,listboxId:m,activeDescendantId:w,autoFocus:P,handleTextChange:z,handleKeyDown:M,handleCaretAfterInput:B,handleCaretMove:W,startEditingParam:I,replaceEditingRange:O,setFocused:E}=e,y=ze(null),N=ze(!1),K=ze(""),A=ze(""),$=ze(null),pe=ze(0);$.current=l,Xe(()=>{if(!P)return;let s=y.current;if(!s)return;document.activeElement===s?E(!0):s.focus();let g=s.ownerDocument??document,f=g.getSelection(),v=f&&f.rangeCount>0&&s.contains(f.anchorNode);if(f&&!v){let k=g.createRange();k.selectNodeContents(s),k.collapse(!0),f.removeAllRanges(),f.addRange(k)}},[P,E]),Xe(()=>{let s=y.current;if(!s)return;let g=s.ownerDocument??document,f=()=>{let v=g.getSelection();if(!v||v.rangeCount===0||!v.anchorNode||!s.contains(v.anchorNode))return;let k=v.anchorNode,T=k.nodeType===Node.ELEMENT_NODE?k:k.parentElement,F=(v.isCollapsed?T?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,V=r?.id??i?.id??null;if(F&&F!==V){I(F);return}performance.now()-pe.current<50||W(Yt(s))};return g.addEventListener("selectionchange",f),()=>g.removeEventListener("selectionchange",f)},[r,i,I,W]),Xe(()=>{let s=y.current;if(!s)return;let g=f=>{let v=Ti(s,f.target);v&&(I(v),Ei(s,v))};return s.addEventListener("click",g),()=>s.removeEventListener("click",g)},[I]),gt(()=>{let s=y.current;s&&Ri({input:s,segments:n,newParamId:o,editingParamId:r?.id??null,placeholderText:b??"",isFocused:C,showChipIcons:t,showChipImages:a})},[n,o,r,b,C,t,a]),gt(()=>{let s=K.current,g=o??"";if(K.current=g,!g||g===s)return;let f=y.current;if(!f)return;f.focus();let v=$.current??Ai(f);$t(f,v)},[o]),gt(()=>{let s=A.current,g=r?.id??"";if(A.current=g,!g||g===s||d==null)return;let f=y.current;f&&$t(f,d)},[r,d]);let _=X(()=>{if(N.current)return;let s=y.current;if(!s)return;let g=Qt(s),v=g.length>0&&g[0]!==g[0].toUpperCase()?g[0].toUpperCase()+g.slice(1):g;z(v)},[z]),he=X(()=>{pe.current=performance.now(),_();let s=y.current;s&&B(Yt(s))},[_,B]);Xe(()=>{let s=y.current;if(!s)return;let g=f=>{let v=f,k=v.inputType;if(k==="insertParagraph"||k==="insertLineBreak"||k==="insertFromDrop"){f.preventDefault();return}if(k.startsWith("insert")||k.startsWith("delete")){let T=k.startsWith("delete")?"":v.data??"";O(T)&&f.preventDefault()}};return s.addEventListener("beforeinput",g),()=>s.removeEventListener("beforeinput",g)},[O]);let Ce=X(()=>{N.current=!0,y.current?.setAttribute("data-aia-composing","true")},[]),ue=X(()=>{N.current=!1,y.current?.removeAttribute("data-aia-composing"),_()},[_]),u=X(s=>{s.preventDefault();let g=y.current;if(!g)return;let f=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let v=g.ownerDocument??document,k=v.getSelection();if(!k||k.rangeCount===0)return;let T=k.getRangeAt(0);if(!g.contains(T.startContainer))return;T.deleteContents();let p=v.createTextNode(f);T.insertNode(p),T.setStartAfter(p),T.collapse(!0),k.removeAllRanges(),k.addRange(T),_()},[_]),Se=X(s=>M(s),[M]),oe=X(()=>E(!0),[E]),me=X(()=>E(!1),[E]),ne=X(()=>y.current?.focus(),[]),ge=X(()=>y.current?.blur(),[]),U=X(()=>{let s=y.current;return s?Qt(s):""},[]),Z=Di()?"plaintext-only":"true";return{inputRef:y,editorProps:{ref:y,contentEditable:Z,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":S,"aria-activedescendant":w,spellCheck:!0,enterKeyHint:"send",onInput:he,onKeyDown:Se,onCompositionStart:Ce,onCompositionEnd:ue,onPaste:u,onFocus:oe,onBlur:me},getPlainText:U,focus:ne,blur:ge}}import{jsx as Me,jsxs as bt}from"react/jsx-runtime";function Bi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ki=Oi(function({onSubmit:n,onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,className:i,apiConfig:d,additionalContext:l,language:b,productId:C,visitorId:S,columns:m,pillPlacement:w="dropdown",mode:P="auto",optionsPosition:z="below",animations:M=!0,dropdownTrigger:B,closeDropdownOnBlur:W,showNonTappableOptions:I,showOptionIcons:O=!0,showChipIcons:E=!0,showChipImages:y=!0,showOptionImages:N=!0,showOptionCounts:K=!0,showSkipButton:A,showProducts:$,productsLayout:pe,productImageFallback:_,autoFocus:he=!0,onFocus:Ce,onBlur:ue,value:u,completedParams:Se,onChange:oe,onParamsChange:me,products:ne,mapProducts:ge,onProductSelect:U,submitButton:Z,resetOnSubmit:s=!0},g){let f=We(null),v=We(null),k=We(()=>{}),T=We(null),p=We(null);Xt(()=>{let D=f.current;if(D)return T.current?T.current.setMode(P):T.current=new Ni(D,P),()=>{T.current?.destroy(),T.current=null}},[P]);let F=ft(D=>{let te=p.current?.current;te&&(te.focus(),Fi(te,D))},[]),{completedParams:V,skippedParams:j,identifiedParams:fe,isReady:re,customFields:J,suggestionPills:be,setActivePill:Pe,skipActivePill:x,segments:we,newParamId:ve,clearNewParamId:se,placeholderText:h,isFocused:Ie,isDropdownOpen:Ne,isActivePillSelected:xe,isLoading:ee,activeIndex:_e,listboxId:Te,handleTextChange:et,handleKeyDown:ye,setFocused:Ee,editingParam:Fe,editingIdentified:qe,editingAnchor:tt,caretOffset:He,startEditingParam:Ue,handleCaretAfterInput:c,handleCaretMove:q,replaceEditingRange:R,dropdownProps:at,reset:Ve,refreshProducts:wt,recordSubmit:vt}=mt({onSubmit:D=>k.current(D),onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,apiConfig:d,additionalContext:l,language:b,productId:C,visitorId:S,columns:m,dropdownTrigger:B,optionsPosition:z,closeDropdownOnBlur:W,showNonTappableOptions:I,showOptionIcons:O,showOptionImages:N,showOptionCounts:K,showSkipButton:A,showProducts:$,onFocus:Ce,onBlur:ue,value:u,completedParams:Se,onChange:oe,onParamsChange:me,products:ne,mapProducts:ge,onProductSelect:U,source:"full-sdk",setCursor:F});Xt(()=>{if(!ve)return;let D=window.setTimeout(()=>se(),650);return()=>window.clearTimeout(D)},[ve,se]);let Jt=_e>=0?`${Te}-option-${_e}`:void 0,{inputRef:it,editorProps:ea,focus:je,blur:xt,getPlainText:yt}=Zt({segments:we,newParamId:ve,editingParam:Fe,editingIdentified:qe,editingAnchor:tt,caretOffset:He,placeholderText:h,isFocused:Ie,showChipIcons:E,showChipImages:y,isDropdownOpen:Ne,listboxId:Te,activeDescendantId:Jt,autoFocus:he,handleTextChange:et,handleKeyDown:ye,handleCaretAfterInput:c,handleCaretMove:q,startEditingParam:Ue,replaceEditingRange:R,setFocused:Ee});p.current=it,zi(()=>{let D=v.current,te=it.current;if(!D||!te)return;let Be=()=>{let Ct=D.firstElementChild;if(!Ct)return;let oa=Ct.getBoundingClientRect(),na=te.getBoundingClientRect();oa.top>=na.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};Be();let kt=new ResizeObserver(Be);return kt.observe(te),()=>kt.disconnect()},[we,be.length,ee,it]),Li(g,()=>({focus:je,blur:xt,reset:Ve,refreshProducts:wt,setMode:D=>T.current?.setMode(D),skipActivePill:x}),[je,xt,Ve,wt,x]);let Qe=!!we.length||V.length>0,ot=ft(D=>{if(!Qe)return;let te=yt(),Be=Mi(te,V,j,{identifiedParams:fe,isReady:re,customFields:J});D&&vt(Be),n(Be),s&&Ve()},[vt,s,Qe,V,j,fe,re,J,n,Ve,yt]);k.current=()=>ot(!1);let ta=ft(D=>{D.target?.closest("[data-aia-pill]")||je()},[je]),aa=w==="inline",ia=w==="dropdown";return bt("div",{ref:f,className:`magicx-aia ${Ae.container} ${i??""}`,"data-pill-placement":w,"data-options-position":z,"data-animations":M?"on":"off","data-mode":Bi(P),children:[Me(ht,{...at,showPills:ia,productsLayout:pe,productImageFallback:_}),bt("div",{className:Ae.inputWrapper,"data-aia-input-wrapper":"",onClick:ta,children:[bt("div",{className:Ae.editorArea,"data-aia-editor":"",children:[Me("div",{...ea,className:Ae.input,"data-aia-input":""}),aa&&(ee||be.length>0)&&Me("span",{ref:v,className:Ae.pillListContainer,"data-aia-pill-list-container":"",children:Me($e,{pills:be,activePillIndex:0,activeSelected:xe,onSelectPill:Pe,loading:ee})})]}),Z===null?null:Z===void 0?Me(Wt,{disabled:!Qe,onClick:()=>ot(!0),label:Hi(b).submit}):Me("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ae.submitSlot,onClick:D=>{Qe&&(D.stopPropagation(),ot(!0))},children:Z})]})]})});export{Ki as AIAutocomplete,ht as AIAutocompleteDropdown,Hn as DATE_RANGE_META_END,Bn as DATE_RANGE_META_START,Kn as DEFAULT_OPTION_COUNT_UNIT,Jn as PRODUCT_PATH_PREFIX,dr as WEEKDAY_LABELS,Mn as buildSubmitResult,Nn as cellDay,Fn as cellIso,Gn as dateCellMarks,Wn as formatDate,_n as formatDateRange,qn as formatOptionCount,Un as isoDate,Vn as monthLabel,jn as optionCountLabel,Qn as optionHasImage,Yn as optionImageSources,$n as optionImageSrc,Zn as optionLabel,Xn as optionsShowLeadingVisuals,er as parseDate,tr as parseLooseDate,ar as parseLooseDateRange,ir as productFromMatchedItem,or as productImageSources,nr as productsFromCustomFields,rr as sanitizeOptionIconSvg,sr as selectedRangeFor,mt as useAIAutocomplete,lr as visibleDateRange,cr as withSkippedParams};
|
|
2377
2493
|
//# sourceMappingURL=index.mjs.map
|