@magicx-eng/ai-autocomplete-react 0.48.2 → 0.49.1
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/REFERENCE.md +5 -3
- package/dist/index.js +44 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -28
- 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 Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END as _r,DATE_RANGE_META_START as
|
|
1
|
+
import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END as _r,DATE_RANGE_META_START as Ur,DEFAULT_OPTION_COUNT_UNIT as Vr,dateCellMarks as Qr,formatDate as Yr,formatDateRange as jr,formatOptionCount as $r,formatPlace as Zr,formatTime as Xr,isoDate as Jr,LOCATION_META_KEY as es,monthLabel as ts,optionCountLabel as as,optionHasImage as is,optionImageSources as os,optionImageSrc as ns,optionLabel as rs,optionsShowLeadingVisuals as ss,PRODUCT_PATH_PREFIX as ls,parseDate as ds,parseLooseDate as cs,parseLooseDateRange as ps,parseTime as hs,productFromMatchedItem as us,productImageSources as ms,productsFromCustomFields as gs,sanitizeOptionIconSvg as fs,selectedRangeFor as bs,TIME_META_KEY as ws,visibleDateRange as vs,WEEKDAY_LABELS as xs,withSkippedParams as ys}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as To,useCallback as Rt,useEffect as Ot,useImperativeHandle as Po,useLayoutEffect as Io,useRef as $e}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.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
|
|
@@ -346,7 +346,7 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
346
346
|
transition: none;
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
|
-
`,document.head.appendChild(e)}var He={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",aiaChipForm:"aia-aiaChipForm-tKbNc",aiaTileGrow:"aia-aiaTileGrow-j9Pat",aiaTileSpring:"aia-aiaTileSpring-FEwNg",aiaTileFade:"aia-aiaTileFade-H1LDQ",aiaImageGrow:"aia-aiaImageGrow-i9yw8"};import{attachScrollArrow as Qi,attachViewportFit as Yi,containScroll as ji,dateFloorFor as $i,hasSkippablePill as Zi,isCalendarFormat as Xi,labelTraditionalAutocomplete as Ji,uiStringsFor as eo}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Qe,useRef as
|
|
349
|
+
`,document.head.appendChild(e)}var He={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",aiaChipForm:"aia-aiaChipForm-tKbNc",aiaTileGrow:"aia-aiaTileGrow-j9Pat",aiaTileSpring:"aia-aiaTileSpring-FEwNg",aiaTileFade:"aia-aiaTileFade-H1LDQ",aiaImageGrow:"aia-aiaImageGrow-i9yw8"};import{attachScrollArrow as Qi,attachViewportFit as Yi,containScroll as ji,dateFloorFor as $i,hasSkippablePill as Zi,isCalendarFormat as Xi,labelTraditionalAutocomplete as Ji,uiStringsFor as eo}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Qe,useRef as Ve,useState as to}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
350
350
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
351
351
|
* Consumer CSS always wins without !important.
|
|
352
352
|
*
|
|
@@ -579,6 +579,11 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
579
579
|
--aia-skeleton-bg: var(--aia-primitive-neutral-750-a8);
|
|
580
580
|
|
|
581
581
|
--aia-streak-rgb: 99, 102, 241; /* off shared palette (indigo effect) */
|
|
582
|
+
/* Solid confirm fill: the pickers' Done buttons and a ticked multi-select
|
|
583
|
+
checkbox. A near-black gray on light, so white reads on it. */
|
|
584
|
+
--aia-confirm-bg: #262626;
|
|
585
|
+
--aia-confirm-bg-hover: #404040;
|
|
586
|
+
--aia-confirm-color: #ffffff;
|
|
582
587
|
|
|
583
588
|
--aia-footer-hint-color: var(--aia-primitive-neutral-500);
|
|
584
589
|
--aia-footer-brand-color: var(--aia-primitive-neutral-700);
|
|
@@ -634,6 +639,11 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
634
639
|
--aia-skeleton-bg: var(--aia-primitive-neutral-150);
|
|
635
640
|
|
|
636
641
|
--aia-streak-rgb: 255, 255, 255;
|
|
642
|
+
/* The light theme's solid confirm fill, inverted: a soft gray (not white,
|
|
643
|
+
which glares on the dark surface) under dark text. */
|
|
644
|
+
--aia-confirm-bg: #a6a6a6;
|
|
645
|
+
--aia-confirm-bg-hover: #b8b8b8;
|
|
646
|
+
--aia-confirm-color: #000000;
|
|
637
647
|
|
|
638
648
|
--aia-footer-hint-color: var(--aia-primitive-neutral-700);
|
|
639
649
|
--aia-footer-brand-color: var(--aia-primitive-neutral-500);
|
|
@@ -1249,20 +1259,33 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
1249
1259
|
}
|
|
1250
1260
|
}
|
|
1251
1261
|
|
|
1262
|
+
/* A picker with its own Done button (multi-select, time wheel) ends on that
|
|
1263
|
+
button: the footer is not shown under it. */
|
|
1264
|
+
.aia-dropdown-yz2KC:has([data-aia-multi-done]) [data-aia-footer],
|
|
1265
|
+
.aia-dropdown-yz2KC:has([data-aia-time-wheel]) [data-aia-footer] {
|
|
1266
|
+
display: none;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/* The multi-select Done button: the time wheel's Done, full width and solid. */
|
|
1252
1270
|
.aia-multiDone-y12U7 {
|
|
1253
1271
|
display: block;
|
|
1254
|
-
width:
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
padding: 0 18px;
|
|
1272
|
+
width: 100%;
|
|
1273
|
+
height: 36px;
|
|
1274
|
+
padding: 0 12px;
|
|
1258
1275
|
border: none;
|
|
1259
|
-
border-radius:
|
|
1260
|
-
background: var(--aia-
|
|
1261
|
-
color: var(--aia-
|
|
1276
|
+
border-radius: 8px;
|
|
1277
|
+
background: var(--aia-multi-done-bg, var(--aia-confirm-bg, #262626));
|
|
1278
|
+
color: var(--aia-multi-done-color, var(--aia-confirm-color, #ffffff));
|
|
1262
1279
|
font-family: inherit;
|
|
1263
|
-
font-size:
|
|
1264
|
-
font-weight:
|
|
1280
|
+
font-size: 13px;
|
|
1281
|
+
font-weight: 500;
|
|
1282
|
+
line-height: 20px;
|
|
1265
1283
|
cursor: pointer;
|
|
1284
|
+
transition: background-color 150ms ease-out;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
.aia-multiDone-y12U7:hover {
|
|
1288
|
+
background: var(--aia-multi-done-bg-hover, var(--aia-confirm-bg-hover, #404040));
|
|
1266
1289
|
}
|
|
1267
1290
|
`,document.head.appendChild(e)}var fe={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",multiDone:"aia-multiDone-y12U7"};import{cellDay as Aa,cellIso as it,dateCellMarks as La,isDimmedDay as Ra,isoDate as Oa,monthLabel as Da,visibleDateRange as Ma,WEEKDAY_LABELS as za}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Na}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) ---
|
|
1268
1291
|
|
|
@@ -1638,7 +1661,7 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
1638
1661
|
justify-content: flex-end;
|
|
1639
1662
|
}
|
|
1640
1663
|
}
|
|
1641
|
-
`,document.head.appendChild(e)}var Se={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 nt,jsxs as vt}from"react/jsx-runtime";function qt({isOptionHighlighted:e=!1,isInputEmpty:i=!1,strings:t=Ka()}){let{key:a,hint:o}=Ga(e,i,t),[r,n]=_a(Ba);return qa(()=>{n(Wa())},[]),nt("footer",{className:Se.footer,"data-aia-footer":"",children:vt(ot,{justify:"between",noWrap:!0,className:Se.row,children:[vt(ot,{gap:"5px",className:Se.hintGroup,children:[nt("kbd",{className:Se.key,children:a}),nt("span",{className:Se.hint,children:o})]}),vt("a",{className:Se.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[nt("span",{className:Se.brand,children:"AI"}),nt("span",{className:Se.badge,children:"Autocomplete"})]})]})})}import{useEffect as _t,useLayoutEffect as
|
|
1664
|
+
`,document.head.appendChild(e)}var Se={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 nt,jsxs as vt}from"react/jsx-runtime";function qt({isOptionHighlighted:e=!1,isInputEmpty:i=!1,strings:t=Ka()}){let{key:a,hint:o}=Ga(e,i,t),[r,n]=_a(Ba);return qa(()=>{n(Wa())},[]),nt("footer",{className:Se.footer,"data-aia-footer":"",children:vt(ot,{justify:"between",noWrap:!0,className:Se.row,children:[vt(ot,{gap:"5px",className:Se.hintGroup,children:[nt("kbd",{className:Se.key,children:a}),nt("span",{className:Se.hint,children:o})]}),vt("a",{className:Se.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[nt("span",{className:Se.brand,children:"AI"}),nt("span",{className:Se.badge,children:"Autocomplete"})]})]})})}import{useEffect as _t,useLayoutEffect as Ua,useRef as se}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-2feec02e")){let e=document.createElement("style");e.id="ac-style-2feec02e",e.textContent=`/* Location search \u2014 React copy of the vanilla rules in styles.css (and of the
|
|
1642
1665
|
Angular copy). The three are kept identical by
|
|
1643
1666
|
packages/vanilla/tests/render/locationFieldParity.test.ts. */
|
|
1644
1667
|
.aia-location-6-fsr {
|
|
@@ -1765,7 +1788,7 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
1765
1788
|
.aia-loadingBar-OLCr4:nth-child(3) {
|
|
1766
1789
|
width: 60%;
|
|
1767
1790
|
}
|
|
1768
|
-
`,document.head.appendChild(e)}var G={location:"aia-location-6-fsr",field:"aia-field-xEzwi",icon:"aia-icon-czx6C",input:"aia-input-Yi9V-",results:"aia-results-C3O0V",row:"aia-row-Q9y8g",highlighted:"aia-highlighted-RJjPx",pin:"aia-pin-OjabL",text:"aia-text-Xs84O",name:"aia-name-Z-WJR",secondary:"aia-secondary-4sCT1",note:"aia-note-xCSvY",empty:"aia-empty-SYBzi",loading:"aia-loading-Ih1gi",loadingBar:"aia-loadingBar-OLCr4"};import{jsx as te,jsxs as Oe}from"react/jsx-runtime";var
|
|
1791
|
+
`,document.head.appendChild(e)}var G={location:"aia-location-6-fsr",field:"aia-field-xEzwi",icon:"aia-icon-czx6C",input:"aia-input-Yi9V-",results:"aia-results-C3O0V",row:"aia-row-Q9y8g",highlighted:"aia-highlighted-RJjPx",pin:"aia-pin-OjabL",text:"aia-text-Xs84O",name:"aia-name-Z-WJR",secondary:"aia-secondary-4sCT1",note:"aia-note-xCSvY",empty:"aia-empty-SYBzi",loading:"aia-loading-Ih1gi",loadingBar:"aia-loadingBar-OLCr4"};import{jsx as te,jsxs as Oe}from"react/jsx-runtime";var Va=0;function rt(e){return e.getRootNode().activeElement??null}function Vt(e){return e.getRootNode().getSelection?.()??document.getSelection()}function Qa(e){if(!e.isContentEditable)return null;let i=Vt(e);if(!i||i.rangeCount===0)return null;let t=i.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function Ut(e,i){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=Vt(e);if(!t)return;let a=i;(!a||!a.startContainer.isConnected||!e.contains(a.startContainer))&&(a=document.createRange(),a.selectNodeContents(e),a.collapse(!1)),t.removeAllRanges(),t.addRange(a)}var Ya=Oe("svg",{className:G.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[te("path",{d:"M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"}),te("circle",{cx:"12",cy:"9.5",r:"2.5"})]}),ja=Oe("svg",{className:G.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[te("circle",{cx:"11",cy:"11",r:"7"}),te("path",{d:"m20 20-3.5-3.5"})]});function Qt({view:e,searchLabel:i,noResultsLabel:t,useTypedLabel:a,widgetFocused:o,visible:r=!0,interactive:n=!0,onQuery:s,onMove:g,onCommit:v,onFocusChange:x}){let u=se(null),d=se(null),c=se(null),w=se(null),L=se(null),N=se(!1),D=se(!1),H=se(!1),q=se(o);q.current=o;let R=se(x);R.current=x;let I=p=>{H.current=p,x(p)},C=()=>{let p=u.current;return p!=null&&rt(p)===p},V=()=>{let p=d.current;if(!p)return;let E=rt(p);E instanceof HTMLElement&&E!==u.current&&E!==document.body&&!p.contains(E)&&(w.current=E,L.current=Qa(E))},Q=se(null);Q.current===null&&(Q.current=`aia-location-${++Va}`);let B=`${Q.current}-row-`;_t(()=>{let p=u.current;p&&p.value!==e.query&&rt(p)!==p&&(p.value=e.query)},[e.query]),_t(()=>{let p=u.current;if(p){if(!r&&C()){D.current=!0,F();return}if(!o){setTimeout(()=>{if(q.current)return;let E=w.current;E&&rt(E)===E||(D.current=!1)},0);return}if(!(D.current||!n||C())){if(V(),I(!0),p.focus({preventScroll:!0}),!C()){D.current=!0,I(!1);return}p.value&&p.select()}}}),Ua(()=>()=>{if(!H.current)return;let p=u.current,E=w.current;E?.isConnected&&p&&rt(p)===p&&(N.current=!0,Ut(E,L.current),N.current=!1),H.current=!1,R.current(!1)},[]);let F=(p=!1)=>{p&&(D.current=!0);let E=w.current;E?.isConnected&&C()&&(N.current=!0,Ut(E,L.current),N.current=!1),I(!1)},ae=e.query.trim(),P=e.highlighted>=0&&e.highlighted<e.places.length?`${B}${e.highlighted}`:void 0,_=null;return e.places.length>0?_=e.places.map((p,E)=>Oe("div",{id:`${B}${E}`,role:"option","aria-selected":E===e.highlighted,className:E===e.highlighted?`${G.row} ${G.highlighted}`:G.row,"data-aia-location-row":"","data-aia-index":E,onClick:()=>{n&&(F(!0),v(E))},children:[te("span",{className:G.pin,children:Ya}),Oe("span",{className:G.text,children:[te("span",{className:G.name,children:p.name}),p.secondary&&te("span",{className:G.secondary,children:p.secondary})]})]},p.id)):e.status==="loading"?_=Oe("div",{className:G.loading,"data-aia-location-loading":"",children:[te("span",{className:G.loadingBar}),te("span",{className:G.loadingBar}),te("span",{className:G.loadingBar})]}):ae&&(_=Oe("div",{className:G.note,"data-aia-location-note":"",children:[e.status==="done"&&te("span",{className:G.empty,children:t}),te("span",{children:a})]})),Oe("div",{ref:d,className:G.location,"data-aia-location":"",onMouseDown:p=>{!(p.target instanceof Node)||!c.current?.contains(p.target)||(p.stopPropagation(),V(),I(!0))},children:[Oe("label",{ref:c,className:G.field,children:[ja,te("input",{ref:u,type:"text",className:G.input,"data-aia-location-input":"",defaultValue:e.query,placeholder:i,"aria-label":i,"aria-activedescendant":P,autoComplete:"off",autoCapitalize:"words",enterKeyHint:"done",spellCheck:!1,tabIndex:r?0:-1,onChange:p=>s(p.target.value),onFocus:()=>I(!0),onBlur:()=>{N.current||(D.current=!0,I(!1))},onKeyDown:p=>{if(!p.nativeEvent.isComposing)switch(p.key){case"ArrowDown":case"ArrowUp":p.preventDefault(),g(p.key==="ArrowDown"?1:-1);return;case"Enter":if(p.preventDefault(),!n)return;F(!0),v();return;case"Escape":p.preventDefault(),p.stopPropagation(),D.current=!0,F();return;case"Backspace":if(p.currentTarget.value!=="")return;p.preventDefault(),D.current=!0,F();return}}})]}),te("div",{className:G.results,"data-aia-location-results":"","aria-live":"polite",children:_})]})}import{isSmartSuggestion as Ja,isTraditionalAutocompleteSuggestion as ei}from"@magicx-eng/ai-autocomplete-vanilla";import{SMART_SUGGESTION_SPARKLE_SVG as $a}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,
|
|
1769
1792
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1770
1793
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1771
1794
|
as it was when the outline was dashed. */
|
|
@@ -2411,7 +2434,7 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
2411
2434
|
.aia-section-Hugfg[data-aia-products-layout="list"] .aia-card-JBGYT[data-aia-product-has-cart] {
|
|
2412
2435
|
padding-right: calc(var(--aia-product-cart-size, 28px) + 16px);
|
|
2413
2436
|
}
|
|
2414
|
-
`,document.head.appendChild(e)}var K={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",compareAt:"aia-compareAt-ewE54",badge:"aia-badge-j9Hcd",cart:"aia-cart-kSlqU",cartCheck:"aia-cartCheck-YTTQ6",cartGlyph:"aia-cartGlyph-cmqAk",cartSpinner:"aia-cartSpinner-442rc","magicx-aia-product-cart-spin":"aia-magicx-aia-product-cart-spin-x8mgr"};import{jsx as j,jsxs as
|
|
2437
|
+
`,document.head.appendChild(e)}var K={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",compareAt:"aia-compareAt-ewE54",badge:"aia-badge-j9Hcd",cart:"aia-cart-kSlqU",cartCheck:"aia-cartCheck-YTTQ6",cartGlyph:"aia-cartGlyph-cmqAk",cartSpinner:"aia-cartSpinner-442rc","magicx-aia-product-cart-spin":"aia-magicx-aia-product-cart-spin-x8mgr"};import{jsx as j,jsxs as Ue}from"react/jsx-runtime";function $t({products:e,listboxId:i,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r=!0,layout:n="row",imageFallback:s="image",strings:g=si()}){let v=e.length>0,x=pt(null);if(Ct(()=>{let d=x.current;if(!(!v||!d))return ai(d)},[v]),!v)return null;let u=`${i}-products-label`;return Ue("section",{className:K.section,"data-aia-products":"","data-aia-products-layout":n,role:"group","aria-labelledby":u,children:[j("div",{className:K.label,id:u,"data-aia-products-label":"",children:g.products}),j("div",{ref:x,className:K.row,"data-aia-products-row":"",children:e.map((d,c)=>j(li,{product:d,id:`${i}-product-${c}`,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r,imageFallback:s,soldOut:g.soldOut,addToCart:g.addToCart},d.id))})]})}function li({product:e,id:i,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r,imageFallback:n,soldOut:s,addToCart:g}){let v=!!a&&e.available!==!1,[x,u]=ht(null),d=w=>{w.relatedTarget?.closest("[data-aia-dropdown]")||o?.(!1)},c=w=>{w.metaKey||w.ctrlKey||w.shiftKey||w.altKey||w.button!==0||(w.preventDefault(),t(e))};return Ue("a",{id:i,className:K.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":v?"":void 0,role:"option","aria-selected":!1,style:x?{"--aia-product-photo-fill-x":String(x.x),"--aia-product-photo-fill-y":String(x.y)}:void 0,href:e.url,tabIndex:r?0:-1,onClick:c,onKeyDown:w=>{w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),t(e))},onFocus:()=>o?.(!0),onBlur:d,children:[j(pi,{sources:ii(e.imageUrl),title:e.title,fallback:n,onPhotoFill:u},oi(e.imageUrl)??""),Ue("span",{className:K.body,children:[e.vendor?j("span",{className:K.vendor,children:e.vendor}):null,j("span",{className:K.title,children:e.title}),e.price?Ue("span",{className:K.price,children:[e.price,e.compareAtPrice?j("s",{className:K.compareAt,children:e.compareAtPrice}):null]}):null,e.available===!1?j("span",{className:K.badge,children:s}):null]}),v&&a?j(ci,{product:e,label:`${g}: ${e.title}`,focusable:r,onAddToCart:a,onFocus:()=>o?.(!0),onBlur:d},di(e)):null]})}function di(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(i=>i??"").join("\0")}function ci({product:e,label:i,focusable:t,onAddToCart:a,onFocus:o,onBlur:r}){let[n,s]=ht(null),g=pt(null),v=pt(e);v.current=e;let x=pt(!0);Ct(()=>(x.current=!0,()=>{x.current=!1}),[]);let u=c=>{g.current=c,x.current&&s(c)},d=c=>{if(c.preventDefault(),c.stopPropagation(),g.current==="adding")return;u("adding");let w;try{w=Promise.resolve(a(v.current))}catch(L){w=Promise.reject(L)}w.then(()=>u("added"),()=>u(null))};return j("span",{className:K.cart,"data-aia-product-cart":"","data-aia-cart-state":n??void 0,"aria-busy":n==="adding"?!0:void 0,role:"button","aria-label":i,tabIndex:t?0:-1,onClick:d,onKeyDown:c=>{c.key!=="Enter"&&c.key!==" "||d(c)},onFocus:c=>{c.stopPropagation(),o()},onBlur:c=>{c.stopPropagation(),r(c)},children:Ue("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[j("path",{className:K.cartGlyph,d:"M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"}),j("path",{className:K.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),j("path",{className:K.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),j("path",{className:K.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),j("circle",{className:K.cartGlyph,cx:"9",cy:"20",r:"1.3"}),j("circle",{className:K.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function pi({sources:e,title:i,fallback:t,onPhotoFill:a}){let[o,r]=ht(0),n=e[o],s=!!n,[g,v]=ht(null),x=!s&&t==="initial";return Ct(()=>()=>a(null),[a]),Ue("span",{className:K.media,"aria-hidden":"true","data-aia-product-placeholder":!s&&!x?"":void 0,"data-aia-product-initial":x?"":void 0,"data-aia-image-loaded":s&&g===n?"":void 0,children:[s?j("img",{className:K.image,src:n,alt:"",loading:"lazy",decoding:"async",onLoad:u=>{v(n),a(ri(u.currentTarget.naturalWidth,u.currentTarget.naturalHeight))},onError:()=>{o+1>=e.length&&a(null),r(u=>u+1)}}):null,x?ni(i):null]})}import{isOptionsGridMobileViewport as Pi,measureOptionsGrid as Ii,needsOptionsGridMeasurement as Ei,OPTIONS_GRID_MOBILE_QUERY as Ai,optionEnterDelayMs as Li,optionsShowLeadingVisuals as Ri,planOptionsGrid as ea,sameOptionRows as Oi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Di,useLayoutEffect as Mi,useRef as ta,useState as ia}from"react";import{optionsGridTemplateColumns as hi}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as ui,useRef as mi}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 {
|
|
2415
2438
|
display: grid;
|
|
2416
2439
|
grid-template-columns: repeat(
|
|
2417
2440
|
auto-fit,
|
|
@@ -2965,15 +2988,15 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
2965
2988
|
}
|
|
2966
2989
|
|
|
2967
2990
|
.aia-checkbox-KGRhg[data-checked="true"] {
|
|
2968
|
-
background:
|
|
2969
|
-
border-color:
|
|
2970
|
-
color:
|
|
2991
|
+
background: var(--aia-confirm-bg, #262626);
|
|
2992
|
+
border-color: var(--aia-confirm-bg, #262626);
|
|
2993
|
+
color: var(--aia-confirm-color, #ffffff);
|
|
2971
2994
|
}
|
|
2972
2995
|
|
|
2973
2996
|
.aia-item-d4vpD:has(.aia-checkbox-KGRhg[data-checked="true"]) {
|
|
2974
2997
|
background: var(--aia-option-bg, transparent);
|
|
2975
2998
|
}
|
|
2976
|
-
`,document.head.appendChild(e)}var $={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",liveMatch:"aia-liveMatch--eYfs",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",checkbox:"aia-checkbox-KGRhg"};import{Fragment as Ti,jsx as Te,jsxs as St}from"react/jsx-runtime";function Jt({option:e,isHighlighted:i,checked:t,onSelect:a,onHighlight:o,onUnhighlight:r,id:n,loading:s,showIcon:g=!0,showImage:v=!0,showCount:x=!0,scrollHint:u,enterDelayMs:d=0}){let[c]=ut(d),[w,L]=ut(!1),N=v?xi(e.image_url):[],D=N[0]??null,[H,q]=ut([]),R=N.find(P=>!H.includes(P))??null,[I,C]=ut(null),
|
|
2999
|
+
`,document.head.appendChild(e)}var $={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",liveMatch:"aia-liveMatch--eYfs",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",checkbox:"aia-checkbox-KGRhg"};import{Fragment as Ti,jsx as Te,jsxs as St}from"react/jsx-runtime";function Jt({option:e,isHighlighted:i,checked:t,onSelect:a,onHighlight:o,onUnhighlight:r,id:n,loading:s,showIcon:g=!0,showImage:v=!0,showCount:x=!0,scrollHint:u,enterDelayMs:d=0}){let[c]=ut(d),[w,L]=ut(!1),N=v?xi(e.image_url):[],D=N[0]??null,[H,q]=ut([]),R=N.find(P=>!H.includes(P))??null,[I,C]=ut(null),V=Ci(()=>!D&&g&&e.icon_svg?yi(e.icon_svg):null,[D,g,e.icon_svg]),Q=x?fi(e.item_count):null,B=Si(void 0);ki(()=>()=>clearTimeout(B.current),[]);let F=P=>{if(s||!e.is_tappable||w&&t===void 0)return;L(!0);let _=P?.currentTarget;t!==void 0&&_!==void 0&&P!==void 0&&!wi(_,_.querySelector("[data-aia-checkbox]"),P)?a(e,{commit:!0}):a(e),clearTimeout(B.current),B.current=setTimeout(()=>L(!1),170)},ae=[$.item,i&&!s?$.highlighted:"",e.liveMatch&&!s?$.liveMatch:"",e.is_tappable?$.tappable:$.nonTappable,w?$.pressed:"",u?$.scrollHint:""].filter(Boolean).join(" ");return Te("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":s?"":void 0,"data-aia-icon":V&&e.icon?e.icon:void 0,"data-aia-image":D?"":void 0,"data-aia-item-count":Q!==null?e.item_count:void 0,"aria-selected":t??i,className:ae,style:{[vi]:`${c}ms`},tabIndex:s||!e.is_tappable?-1:0,onClick:F,onKeyDown:P=>{!s&&e.is_tappable&&(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),F())},onMouseEnter:!s&&e.is_tappable?o:void 0,onMouseLeave:r,children:St("span",{className:$.content,children:[t!==void 0&&e.is_tappable&&Te("span",{className:$.checkbox,"aria-hidden":"true","data-aia-checkbox":"","data-checked":t,children:t?"\u2713":""}),D&&Te("span",{className:`${$.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":R!==null&&I===R?"":void 0,children:Te("img",{src:R??D,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:R===null,onLoad:()=>C(R),onError:()=>{R!==null&&q(P=>[...P,R])}})}),V&&Te("span",{className:`${$.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:V}}),St("span",{className:$.text,children:[e.matchedText?bi(Xt(e),e.matchedText).map((P,_)=>P.bold?Te("strong",{className:`${$.match} magicx-aia-option-match`,children:P.text},_):P.text):Xt(e),e.parameterLabel&&St(Ti,{children:[" ",Te("span",{className:`${$.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&Te("span",{className:$.tag,children:e.tag}),Q!==null&&Te("span",{className:`${$.count} magicx-aia-option-count`,children:Q})]})})}import{jsx as aa}from"react/jsx-runtime";function zi(){let[e,i]=ia(Pi);return Di(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Ai),a=()=>i(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function oa({options:e,activeIndex:i,picked:t,onSelect:a,onHighlight:o,onUnhighlight:r,listboxId:n,loading:s,groupKey:g="",optionsPosition:v="below",showIcons:x=!0,showImages:u=!0,showCounts:d=!0}){let c=zi(),w=ta(null),[L,N]=ia(null),D=ta(null);Mi(()=>{if(s&&Oi(D.current,e))return;D.current=s?null:e;let R=w.current,C=R&&!s&&Ei(e.length,c)?Ii(R):null;N(C?ea(e.length,c,C.rowWidths,C.gridWidth):null)},[e,c,s]);let H=L??ea(e.length,c,null,null),q=Ri(e,x,u);return aa(Zt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:g,template:H.template,maxHeight:H.maxHeight,innerRef:R=>{w.current=R},"data-aia-group":g,children:e.map((R,I)=>aa(Jt,{option:R,isHighlighted:I===i,checked:t?t.includes(R.text):void 0,onSelect:a,onHighlight:()=>o(I),onUnhighlight:r?()=>r(I):void 0,id:`${n}-option-${I}`,loading:s,showIcon:x&&q,showImage:u&&q,showCount:d,scrollHint:!s&&H.scrollHintIndices.includes(I),enterDelayMs:s?0:Li(I,H.cols,e.length,v)},`${g}\0${R.text}`))})}import{formatTime as Ni,TIME_WHEEL_COLUMNS as Fi,TIME_WHEEL_ROW_HEIGHT as Hi,timeWheelIndex as na,timeWheelIndexFromScroll as Bi,timeWheelRows as Wi,withTimeWheelIndex as ra}from"@magicx-eng/ai-autocomplete-vanilla";import{Fragment as Gi,useEffect as Ki,useLayoutEffect as qi,useRef as mt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-52a922cb")){let e=document.createElement("style");e.id="ac-style-52a922cb",e.textContent=`/* --- Time wheel (replaces the options grid for time suggestions) ---
|
|
2977
3000
|
|
|
2978
3001
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
2979
3002
|
time-wheel.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -3078,27 +3101,24 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
3078
3101
|
|
|
3079
3102
|
.aia-done-llNY5 {
|
|
3080
3103
|
align-self: stretch;
|
|
3081
|
-
height:
|
|
3104
|
+
height: 36px;
|
|
3082
3105
|
padding: 0 12px;
|
|
3083
3106
|
border: none;
|
|
3084
3107
|
border-radius: 8px;
|
|
3085
|
-
background: var(--aia-time-done-bg,
|
|
3108
|
+
background: var(--aia-time-done-bg, var(--aia-confirm-bg, #262626));
|
|
3086
3109
|
font-family: inherit;
|
|
3087
3110
|
font-size: 13px;
|
|
3088
3111
|
font-weight: 500;
|
|
3089
3112
|
line-height: 20px;
|
|
3090
|
-
color: var(
|
|
3091
|
-
--aia-time-done-color,
|
|
3092
|
-
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
3093
|
-
);
|
|
3113
|
+
color: var(--aia-time-done-color, var(--aia-confirm-color, #ffffff));
|
|
3094
3114
|
cursor: pointer;
|
|
3095
3115
|
transition: background-color 150ms ease-out;
|
|
3096
3116
|
}
|
|
3097
3117
|
|
|
3098
3118
|
.aia-done-llNY5:hover {
|
|
3099
|
-
background: var(--aia-time-done-bg-hover,
|
|
3119
|
+
background: var(--aia-time-done-bg-hover, var(--aia-confirm-bg-hover, #404040));
|
|
3100
3120
|
}
|
|
3101
|
-
`,document.head.appendChild(e)}var le={timeWheel:"aia-timeWheel-KdR4A",value:"aia-value--wqvm",columns:"aia-columns-TaD-f",band:"aia-band-pVy-f",column:"aia-column-lwtdd",row:"aia-row-A3pAx",selected:"aia-selected-xgOWY",separator:"aia-separator-kX9WO",done:"aia-done-llNY5"};import{jsx as Be,jsxs as Tt}from"react/jsx-runtime";var _i=120;function sa({view:e,label:i,doneLabel:t,interactive:a=!0,onTimeChange:o,onTimeCommit:r}){return Tt("div",{className:le.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":i,onMouseDown:n=>n.preventDefault(),children:[Be("span",{className:le.value,"data-aia-time-value":"","aria-live":"polite",children:Ni(e.minutes)}),Tt("div",{className:le.columns,"aria-hidden":"true",children:[Be("div",{className:le.band}),Fi.map(n=>Tt(Gi,{children:[n==="minute"&&Be("span",{className:le.separator,children:":"}),Be(
|
|
3121
|
+
`,document.head.appendChild(e)}var le={timeWheel:"aia-timeWheel-KdR4A",value:"aia-value--wqvm",columns:"aia-columns-TaD-f",band:"aia-band-pVy-f",column:"aia-column-lwtdd",row:"aia-row-A3pAx",selected:"aia-selected-xgOWY",separator:"aia-separator-kX9WO",done:"aia-done-llNY5"};import{jsx as Be,jsxs as Tt}from"react/jsx-runtime";var _i=120;function sa({view:e,label:i,doneLabel:t,interactive:a=!0,onTimeChange:o,onTimeCommit:r}){return Tt("div",{className:le.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":i,onMouseDown:n=>n.preventDefault(),children:[Be("span",{className:le.value,"data-aia-time-value":"","aria-live":"polite",children:Ni(e.minutes)}),Tt("div",{className:le.columns,"aria-hidden":"true",children:[Be("div",{className:le.band}),Fi.map(n=>Tt(Gi,{children:[n==="minute"&&Be("span",{className:le.separator,children:":"}),Be(Ui,{column:n,minutes:e.minutes,interactive:a,onTimeChange:o})]},n))]}),Be("button",{type:"button",tabIndex:-1,className:le.done,"data-aia-time-done":"",onClick:()=>{a&&r()},children:t})]})}function Ui({column:e,minutes:i,interactive:t,onTimeChange:a}){let o=mt(null),r=mt(null),n=mt(null),s=mt({minutes:i,interactive:t,onTimeChange:a});s.current={minutes:i,interactive:t,onTimeChange:a};let g=na(e,i);qi(()=>{let u=o.current;if(!u||n.current)return;let d=g*Hi;Math.abs(u.scrollTop-d)<1||(r.current=d,u.scrollTop=d)},[g]),Ki(()=>()=>{n.current&&clearTimeout(n.current)},[]);let v=()=>{n.current=null;let u=o.current,d=s.current;if(!u||!d.interactive)return;let c=Bi(e,u.scrollTop);c!==na(e,d.minutes)&&d.onTimeChange(ra(e,d.minutes,c))},x=()=>{let u=o.current;if(u){if(r.current!=null&&Math.abs(u.scrollTop-r.current)<1){r.current=null;return}r.current=null,n.current&&clearTimeout(n.current),n.current=setTimeout(v,_i)}};return Be("div",{ref:o,className:le.column,"data-aia-time-column":e,onScroll:x,children:Wi(e).map((u,d)=>Be("div",{className:d===g?`${le.row} ${le.selected}`:le.row,"data-aia-time-row":"","data-aia-index":d,onClick:()=>{s.current.interactive&&a(ra(e,s.current.minutes,d))},children:u.label},u.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
3102
3122
|
display: flex;
|
|
3103
3123
|
flex-direction: column;
|
|
3104
3124
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -3113,7 +3133,7 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
3113
3133
|
align-items: end;
|
|
3114
3134
|
}
|
|
3115
3135
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
3116
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
3136
|
+
`,document.head.appendChild(e)}import{jsx as Vi}from"react/jsx-runtime";function la({space:e,align:i="stretch",className:t,children:a,...o}){let r=e?{"--aia-stack-space":e}:void 0;return Vi("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":i,style:r,...o,children:a})}import{jsx as X,jsxs as Pt}from"react/jsx-runtime";var ao=[159,119,164],io=()=>{},da=()=>{},oo=e=>{},no=()=>{},ro=e=>{},so=e=>{},lo=e=>{},co=e=>{};function po(e){let i=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=to(i);if(Qe(()=>{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 ho(e,i){let t=Ve(null);Qe(()=>{let a=e.current,o=i.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:Qi({dropdown:a,grid:r,button:o})};return}t.current?.controller.update()}),Qe(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function uo(e,i){let t=Ve(i);t.current=i;let a=Ve(null);Qe(()=>{let o=e.current;if(o){if(!a.current){a.current=Yi({dropdown:o,isOpen:()=>t.current});return}a.current.update()}}),Qe(()=>()=>{a.current?.destroy(),a.current=null},[])}function It({suggestions:e,activeIndex:i,onSelect:t,onHighlight:a,onUnhighlight:o,isOpen:r,id:n,className:s,pills:g,onPillClick:v,showPills:x=!0,onSkip:u,showSkipButton:d=!0,showOptionIcons:c=!0,showOptionImages:w=!0,showOptionCounts:L=!0,skipDisabled:N=!1,activeSelected:D=!1,isLoading:H=!1,skeletonExiting:q=!1,isInputEmpty:R=!1,language:I,products:C,onProductSelect:V,onProductAddToCart:Q,onProductFocusChange:B,productsLayout:F="row",productImageFallback:ae="image",formatType:P="options",dateView:_=null,selectedDateIso:p=null,selectedDateRange:E=null,dateRangeStart:ve=null,onPreviousMonth:De,onNextMonth:Pe,timeView:f=null,multiSelectView:Me=null,onMultiSelectCommit:Ie,onTimeChange:Ee,onTimeCommit:Ae,locationView:b=null,onLocationQuery:k,onLocationMove:S,onLocationCommit:A,onLocationFocusChange:O,isFocused:U=!1,optionsPosition:ie="below",mode:oe}){let ce=po(oe),pe=ce!==void 0,ne=Ve(null),ze=Ve(null);ho(ne,ze),Qe(()=>{if(ne.current)return ji(ne.current)},[]);let Xe=e[0]?.options??[],xe=!!(g&&g.length>0&&v),Ne=!!(C&&C.length>0),We=P==="time"&&f!=null,ye=P==="location"&&b!=null,J=r&&(Xe.length>0||x&&xe||H||Ne||We||ye);uo(ne,J);let he={suggestions:e,activeIndex:i,pills:g,showPills:x,showSkipButton:d,showOptionIcons:c,showOptionImages:w,showOptionCounts:L,skipDisabled:N,activeSelected:D,isLoading:H,skeletonExiting:q,isInputEmpty:R,products:C,formatType:P,dateView:_,selectedDateIso:p,selectedDateRange:E,dateRangeStart:ve,timeView:f,multiSelectView:Me,locationView:b},y=Ve(he);J&&(y.current=he);let h=J?he:y.current,Y=eo(I),ue=h.suggestions[0],m=ue?.options??[],Ge=h.activeIndex>=0&&!!m[h.activeIndex]?.is_tappable,ke=Ji(h.pills??[],Y.keepTyping),me=!!(ke.length>0&&v),Je=h.showPills&&me,et=h.showPills&&!me&&h.isLoading,Ce=Je||et,Ke=me&&Zi(ke)&&h.showSkipButton&&!h.isInputEmpty&&!!u,re=ke[0]?.text,ge=Xi(h.formatType)&&h.dateView!=null,Le=m.length>0&&!ge,Fe=m.length>0&&ge&&!h.isLoading,qe=h.formatType==="time"&&h.timeView!=null&&!h.isLoading,Re=h.formatType==="location"&&h.locationView!=null&&!h.isLoading,_e=h.isLoading&&!Le&&!Fe&&!qe&&!Re,l=h.products??[];return Pt("div",{ref:ne,id:n,role:"listbox","aria-multiselectable":!!h.multiSelectView,"data-aia-dropdown":"","data-options-position":ie,"data-mode":ce,"data-aia-loading":h.isLoading?"":void 0,"data-aia-skeleton-exiting":h.skeletonExiting?"":void 0,"data-aia-has-products":l.length>0?"":void 0,className:`${pe?"magicx-aia ":""}${fe.dropdown} ${J?fe.visible:""} ${s??""}`,onMouseDown:T=>T.preventDefault(),children:[Pt(la,{space:"8px",children:[(Ce||Ke)&&Pt(ot,{noWrap:!0,className:fe.pillBar,"data-aia-pillbar":"",children:[Ce&&X("span",{className:fe.pillScroll,"data-aia-pill-scroll":"",children:X(ct,{pills:ke,activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:h.isLoading})}),Ke&&X("button",{type:"button",tabIndex:-1,className:fe.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":re?`${Y.skipLabel} ${re}`:Y.skipLabel,onClick:u,children:Y.skip})]}),Le&&X(oa,{options:m,activeIndex:h.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:o,listboxId:n,loading:h.isLoading,groupKey:ue?`${ue.parameter} ${ue.text}`:"",optionsPosition:ie,showIcons:h.showOptionIcons,showImages:h.showOptionImages,showCounts:h.showOptionCounts,picked:h.isLoading?void 0:h.multiSelectView?.picked}),h.multiSelectView&&!h.isLoading&&X("div",{onClick:T=>{T.target.closest("[data-aia-multi-done]")&&!h.skipDisabled&&Ie?.()},children:X("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:fe.multiDone,ref:T=>{T&&(T.disabled=!0,T.offsetHeight,T.disabled=h.skipDisabled)},children:Y.done})}),Fe&&h.dateView&&X(Gt,{options:m,activeIndex:h.activeIndex,listboxId:n,view:h.dateView,selection:{selectedIso:h.selectedDateIso??null,selectedRange:h.selectedDateRange??null,rangeStart:h.dateRangeStart??null,floor:$i(h.formatType,h.dateRangeStart)},onSelect:t,onHighlight:a,onUnhighlight:o,onPreviousMonth:De??da,onNextMonth:Pe??da}),qe&&h.timeView&&X(sa,{view:h.timeView,label:Y.timeLabel,doneLabel:Y.done,interactive:!h.skipDisabled,onTimeChange:Ee??oo,onTimeCommit:Ae??no}),Re&&h.locationView&&X(Qt,{view:h.locationView,searchLabel:Y.locationSearch,noResultsLabel:Y.locationNoResults,useTypedLabel:Y.locationUseTyped,widgetFocused:U&&J,visible:J,interactive:!h.skipDisabled,onQuery:k??ro,onMove:S??so,onCommit:A??lo,onFocusChange:O??co}),_e&&X("div",{className:fe.skeletonBars,"data-aia-skeleton-bars":"",children:ao.map(T=>X("span",{className:fe.skeletonBar,style:{width:T}},`bar-${T}`))}),X($t,{products:l,listboxId:n,onSelect:V??io,onAddToCart:Q,onFocusChange:B,focusable:J,layout:F,imageFallback:ae,strings:Y}),X(qt,{isOptionHighlighted:Ge,isInputEmpty:h.isInputEmpty,strings:Y})]}),X("button",{ref:ze,type:"button",tabIndex:-1,className:fe.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Y.scrollArrow,"aria-hidden":"true",children:X("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:X("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Eo,ModeController as Ao,setCursorOffset as Lo,uiStringsFor as Ro,watchEditorHeight as Oo}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as mo}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 {
|
|
3117
3137
|
flex-shrink: 0;
|
|
3118
3138
|
width: 32px;
|
|
3119
3139
|
height: 32px;
|
|
@@ -3184,5 +3204,5 @@ import{buildSubmitResult as Gr,cellDay as Kr,cellIso as qr,DATE_RANGE_META_END a
|
|
|
3184
3204
|
transition: none;
|
|
3185
3205
|
}
|
|
3186
3206
|
}
|
|
3187
|
-
`,document.head.appendChild(e)}var ca={submitButton:"aia-submitButton-otz7H"};import{jsx as Et}from"react/jsx-runtime";function pa({disabled:e,ready:i,onClick:t,label:a=mo().submit}){return Et("button",{type:"button","data-aia-submit":"",className:ca.submitButton,disabled:e,"data-aia-ready":i?"":void 0,onClick:o=>{o.stopPropagation(),t()},"aria-label":a,children:Et("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":a,children:Et("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as go,dateSelectionFor as fo,identifiedParamLabel as bo,withoutTraditionalAutocomplete as wo}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as fa,useEffect as Ye,useRef as Z,useState as vo}from"react";import{useRef as ha}from"react";function ua(e){let i=ha(e);i.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=ha({key:"",overrides:void 0});if(a.current.key!==t){let o={};for(let r of Object.keys(e??{})){let n=(s,g,v)=>{let x=i.current?.[r];return x?x(s,g,v):[]};o[r]=n}a.current={key:t,overrides:e?o:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as ma}from"react";function ga(e){let i=ma(e);i.current=e;let t=ma(null);t.current===null&&(t.current={fetch:(o,r)=>{let n=i.current;return n?n.fetch(o,r):Promise.reject(new Error("products config removed"))},transform:o=>i.current?.transform(o)??[],get limit(){return i.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var ba={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,dateFloor:null,timeView:null,multiSelectView:null,multiSelectDraft:null,locationView:null,locationSearch:null,locationAutocomplete:!0,locationFieldFocused:!1,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,timeDraft:null};function At({onSubmit:e,onResult:i,onError:t,optionOverrides:a,maskCompletedText:o,apiConfig:r,additionalContext:n,language:s,currency:g,productId:v,visitorId:x,columns:u=2,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:w,showNonTappableOptions:L,locationSearch:N,showOptionIcons:D,showOptionImages:H,showOptionCounts:q,showSkipButton:R,showProducts:I,productImageFallback:C="image",onFocus:U,onBlur:Q,value:B,completedParams:F,onChange:ae,onParamsChange:P,products:_,mapProducts:p,onProductSelect:E,onProductAddToCart:ve,source:De,setCursor:Pe}){let f=Z(null),[Me,Ie]=vo(null),Ee=Z(e);Ee.current=e;let Ae=Z(i);Ae.current=i;let b=Z(t);b.current=t;let k=Z(ae);k.current=ae;let S=Z(P);S.current=P;let A=Z(U);A.current=U;let O=Z(Q);O.current=Q;let V=Z(Pe);V.current=Pe;let ie=Z(E);ie.current=E;let oe=Z(ve);oe.current=ve;let ce=Z(x);ce.current=x;let pe=Z(()=>{let l=ce.current;return typeof l=="function"?l():l}).current,ne=ga(_),ze=Z(p);ze.current=p;let Xe=Z((l,T)=>{let z=ze.current;return z?z(l,T):l}).current,xe=p?Xe:void 0,Ne=ua(a);Ye(()=>{if(typeof document>"u")return;let l=new go(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:n,language:s,currency:g,productId:v,visitorId:pe,optionOverrides:Ne.overrides,maskCompletedText:o,columns:u,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:w,showNonTappableOptions:L,locationSearch:N,showProducts:I,source:De,value:B,completedParams:F,onSubmit:(...z)=>Ee.current?.(...z),onResult:(...z)=>Ae.current?.(...z),onError:(...z)=>b.current?.(...z),onChange:(...z)=>k.current?.(...z),onParamsChange:(...z)=>S.current?.(...z),onFocus:()=>A.current?.(),onBlur:()=>O.current?.(),onProductSelect:z=>ie.current?.(z),onProductAddToCart:z=>oe.current?.(z),setCursor:z=>V.current?.(z),products:ne.config,mapProducts:xe});f.current=l,Ie(l.getState());let T=l.subscribe(z=>Ie(z));return()=>{T(),l.destroy(),f.current===l&&(f.current=null)}},[]),Ye(()=>{B!==void 0&&f.current?.setValue(B)},[B]),Ye(()=>{F!==void 0&&f.current?.setCompletedParams(F)},[F]);let We=JSON.stringify(r??null),ye;try{ye=JSON.stringify(n??null)}catch{ye="[unstringifiable]"}Ye(()=>{f.current?.update({apiConfig:r,additionalContext:n,language:s,currency:g,productId:v,optionOverrides:Ne.overrides,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:w,showNonTappableOptions:L,locationSearch:N,showProducts:I})},[We,ye,s,g?.code,g?.rate,g?.country,v,Ne.key,d,c,w,L,N,I]);let J=Z(!1);Ye(()=>{if(!J.current){J.current=!0;return}f.current?.update({products:ne.config})},[ne.enabled]),Ye(()=>{f.current?.update({mapProducts:xe})},[xe]);let he=Z(null);he.current===null&&(he.current={handleTextChange:l=>f.current?.handleTextChange(l),handleKeyDown:l=>{let T="nativeEvent"in l?l.nativeEvent:l;f.current?.handleKeyDown(T)},setFocused:l=>f.current?.setFocused(l),startEditingParam:l=>f.current?.startEditingParam(l),exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:l=>f.current?.handleCaretAfterInput(l),handleCaretMove:l=>f.current?.handleCaretMove(l),replaceEditingRange:l=>f.current?.replaceEditingRange(l)??!1,setActivePill:l=>f.current?.setActivePill(l),skipActivePill:()=>f.current?.skipActivePill(),removeLastParam:()=>f.current?.removeLastParam(),clearNewParamId:()=>f.current?.clearNewParamId(),reset:()=>f.current?.reset(),refreshProducts:()=>f.current?.refreshProducts(),prepareSubmit:()=>f.current?.prepareSubmit(),getState:()=>f.current?.getState()??ba,recordSubmit:l=>f.current?.recordSubmit(l),selectOption:(l,T)=>f.current?.selectOption(l,T),selectProduct:l=>f.current?.selectProduct(l),addProductToCart:l=>{let T=f.current;return!T||!oe.current?Promise.resolve():T.addProductToCart(l)},setActiveDropdownIndex:l=>f.current?.setActiveDropdownIndex(l),clearHighlight:l=>f.current?.clearHighlight(l),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),setTime:l=>f.current?.setTime(l),commitTime:()=>f.current?.commitTime(),toggleMultiSelectOption:l=>f.current?.toggleMultiSelectOption(l),commitMultiSelect:()=>f.current?.commitMultiSelect(),setLocationQuery:l=>f.current?.setLocationQuery(l),moveLocationHighlight:l=>f.current?.moveLocationHighlight(l),commitLocation:l=>f.current?.commitLocation(l),setLocationFieldFocused:l=>f.current?.setLocationFieldFocused(l),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let y=he.current,h=fa(l=>{let T=l.target.value,st=T.length>0&&!l.nativeEvent?.isComposing&&T[0]!==T[0].toUpperCase()?T[0].toUpperCase()+T.slice(1):T;f.current?.handleTextChange(st)},[]),Y=fa(l=>{f.current?.handleKeyDown(l.nativeEvent)},[]),ue=f.current,m=Me??ba,Ge=B!==void 0?B:m.text,ke=F!==void 0?F:m.completedParams,me=m.actionableSuggestions,Je=me[0],et=wo(me),Ce=ue?.listboxId??"",Ke=m.activeDropdownIndex>=0&&ue?`${Ce}-option-${m.activeDropdownIndex}`:void 0,re=m.editingParam,ge=m.editingIdentified,Le=re?{parameter:re.suggestionParameter,text:re.suggestionPlaceholder,required:!0,options:re.options}:ge?{parameter:ge.parameter,text:bo(ge.parameter),required:!0,options:[]}:null,Fe=m.dropdownSuggestion??Le??Je,qe=Le?[Le]:me,Re=fo(m),_e=!ue||m.dropdownLoading;return{completedParams:ke,multiSelectView:m.multiSelectView,toggleMultiSelectOption:y.toggleMultiSelectOption,commitMultiSelect:y.commitMultiSelect,skippedParams:m.skippedParams,identifiedParams:m.identifiedParams,suggestionPills:et,setActivePill:y.setActivePill,skipActivePill:y.skipActivePill,removeLastParam:y.removeLastParam,segments:m.segments,newParamId:m.newParamId,clearNewParamId:y.clearNewParamId,suggestions:m.suggestions,activeIndex:m.activeDropdownIndex,isReady:m.isReady,isLoading:_e,isFocused:m.isFocused,isDropdownOpen:m.isDropdownOpen,isActivePillSelected:m.isActivePillSelected,placeholderText:m.placeholderText,listboxId:Ce,error:m.error,products:m.products,customFields:m.customFields,selectProduct:y.selectProduct,addProductToCart:y.addProductToCart,handleTextChange:y.handleTextChange,handleKeyDown:y.handleKeyDown,setFocused:y.setFocused,editingParam:re,editingIdentified:ge,editingAnchor:m.editingAnchor,caretOffset:m.caretOffset,startEditingParam:y.startEditingParam,exitEditMode:y.exitEditMode,handleCaretAfterInput:y.handleCaretAfterInput,handleCaretMove:y.handleCaretMove,replaceEditingRange:y.replaceEditingRange,inputProps:{value:Ge,placeholder:m.placeholderText||void 0,onChange:h,onKeyDown:Y,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":m.isDropdownOpen,"aria-activedescendant":Ke,"aria-autocomplete":"list","aria-controls":Ce},reset:y.reset,refreshProducts:y.refreshProducts,prepareSubmit:y.prepareSubmit,getState:y.getState,recordSubmit:y.recordSubmit,dropdownProps:{suggestions:Fe?[{...Fe,options:m.dropdownOptions}]:[],activeIndex:m.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,onUnhighlight:y.clearHighlight,isOpen:m.isDropdownOpen,id:Ce,pills:qe,activeSelected:m.isActivePillSelected,onPillClick:y.setActivePill,onSkip:y.skipActivePill,showSkipButton:(R??!0)&&!re&&!ge,showOptionIcons:D??!0,showOptionImages:H??!0,showOptionCounts:q??!0,skipDisabled:m.inSelectionAnimation,isLoading:_e,skeletonExiting:m.skeletonExiting,isInputEmpty:Ge.trim().length===0,language:s,products:m.products,productImageFallback:C,onProductSelect:y.selectProduct,onProductAddToCart:ve?y.addProductToCart:void 0,onProductFocusChange:y.setFocused,formatType:m.activeFormatType,dateView:m.dateView,selectedDateIso:Re.selectedIso,selectedDateRange:Re.selectedRange,dateRangeStart:Re.rangeStart,onPreviousMonth:y.showPreviousMonth,onNextMonth:y.showNextMonth,timeView:m.timeView,multiSelectView:m.multiSelectView,onMultiSelectCommit:y.commitMultiSelect,onTimeChange:y.setTime,onTimeCommit:y.commitTime,locationView:m.locationView,onLocationQuery:y.setLocationQuery,onLocationMove:y.moveLocationHighlight,onLocationCommit:y.commitLocation,onLocationFocusChange:y.setLocationFieldFocused,isFocused:m.isFocused||m.locationFieldFocused,optionsPosition:c??"below"}}}import{chipIdFromTap as xo,extractPlainText as wa,getCursorOffset as va,keepCaretOnChip as yo,plainTextLength as ko,renderEditableContent as Co,setCursorOffset as xa}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as de,useEffect as gt,useLayoutEffect as Lt,useRef as je}from"react";var ft;function So(){if(ft!==void 0)return ft;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),ft=e.contentEditable==="plaintext-only",ft}function ya(e){let{segments:i,showChipIcons:t=!0,showChipImages:a=!0,newParamId:o,editingParam:r,editingIdentified:n,editingAnchor:s,caretOffset:g,placeholderText:v,isFocused:x,isDropdownOpen:u,listboxId:d,activeDescendantId:c,autoFocus:w,handleTextChange:L,handleKeyDown:N,handleCaretAfterInput:D,handleCaretMove:H,startEditingParam:q,replaceEditingRange:R,setFocused:I}=e,C=je(null),U=je(!1),Q=je(""),B=je(""),F=je(null),ae=je(0);F.current=g,gt(()=>{if(!w)return;let b=C.current;if(!b)return;document.activeElement===b?I(!0):b.focus();let k=b.ownerDocument??document,S=k.getSelection(),A=S&&S.rangeCount>0&&b.contains(S.anchorNode);if(S&&!A){let O=k.createRange();O.selectNodeContents(b),O.collapse(!0),S.removeAllRanges(),S.addRange(O)}},[w,I]),gt(()=>{let b=C.current;if(!b)return;let k=b.ownerDocument??document,S=()=>{let A=k.getSelection();if(!A||A.rangeCount===0||!A.anchorNode||!b.contains(A.anchorNode))return;let O=A.anchorNode,V=O.nodeType===Node.ELEMENT_NODE?O:O.parentElement,oe=(A.isCollapsed?V?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ce=r?.id??n?.id??null;if(oe&&oe!==ce){q(oe);return}performance.now()-ae.current<50||H(va(b))};return k.addEventListener("selectionchange",S),()=>k.removeEventListener("selectionchange",S)},[r,n,q,H]),gt(()=>{let b=C.current;if(!b)return;let k=S=>{let A=xo(b,S.target);A&&(q(A),yo(b,A))};return b.addEventListener("click",k),()=>b.removeEventListener("click",k)},[q]),Lt(()=>{let b=C.current;b&&Co({input:b,segments:i,newParamId:o,editingParamId:r?.id??null,placeholderText:v??"",isFocused:x,showChipIcons:t,showChipImages:a})},[i,o,r,v,x,t,a]),Lt(()=>{let b=Q.current,k=o??"";if(Q.current=k,!k||k===b)return;let S=C.current;if(!S)return;S.focus();let A=F.current??ko(S);xa(S,A)},[o]),Lt(()=>{let b=B.current,k=r?.id??"";if(B.current=k,!k||k===b||s==null)return;let S=C.current;S&&xa(S,s)},[r,s]);let P=de(()=>{if(U.current)return;let b=C.current;if(!b)return;let k=wa(b),A=k.length>0&&k[0]!==k[0].toUpperCase()?k[0].toUpperCase()+k.slice(1):k;L(A)},[L]),_=de(()=>{ae.current=performance.now(),P();let b=C.current;b&&D(va(b))},[P,D]);gt(()=>{let b=C.current;if(!b)return;let k=S=>{let A=S,O=A.inputType;if(O==="insertParagraph"||O==="insertLineBreak"||O==="insertFromDrop"){S.preventDefault();return}if(O.startsWith("insert")||O.startsWith("delete")){let V=O.startsWith("delete")?"":A.data??"";R(V)&&S.preventDefault()}};return b.addEventListener("beforeinput",k),()=>b.removeEventListener("beforeinput",k)},[R]);let p=de(()=>{U.current=!0,C.current?.setAttribute("data-aia-composing","true")},[]),E=de(()=>{U.current=!1,C.current?.removeAttribute("data-aia-composing"),P()},[P]),ve=de(b=>{b.preventDefault();let k=C.current;if(!k)return;let S=(b.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!S)return;let A=k.ownerDocument??document,O=A.getSelection();if(!O||O.rangeCount===0)return;let V=O.getRangeAt(0);if(!k.contains(V.startContainer))return;V.deleteContents();let ie=A.createTextNode(S);V.insertNode(ie),V.setStartAfter(ie),V.collapse(!0),O.removeAllRanges(),O.addRange(V),P()},[P]),De=de(b=>N(b),[N]),Pe=de(()=>I(!0),[I]),f=de(()=>I(!1),[I]),Me=de(()=>C.current?.focus(),[]),Ie=de(()=>C.current?.blur(),[]),Ee=de(()=>{let b=C.current;return b?wa(b):""},[]),Ae=So()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:Ae,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":d,"aria-expanded":u,"aria-activedescendant":c,spellCheck:!0,enterKeyHint:"send",onInput:_,onKeyDown:De,onCompositionStart:p,onCompositionEnd:E,onPaste:ve,onFocus:Pe,onBlur:f},getPlainText:Ee,focus:Me,blur:Ie}}import{jsx as Ze,jsxs as Dt}from"react/jsx-runtime";function Do(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Mo=To(function({onSubmit:i,onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,className:n,apiConfig:s,additionalContext:g,language:v,currency:x,productId:u,visitorId:d,columns:c,pillPlacement:w="dropdown",mode:L="auto",optionsPosition:N="below",animations:D=!0,dropdownTrigger:H,closeDropdownOnBlur:q,showNonTappableOptions:R,locationSearch:I,showOptionIcons:C=!0,showChipIcons:U=!0,showChipImages:Q=!0,showOptionImages:B=!0,showOptionCounts:F=!0,showSkipButton:ae,showProducts:P,productsLayout:_,productImageFallback:p,autoFocus:E=!0,onFocus:ve,onBlur:De,value:Pe,completedParams:f,onChange:Me,onParamsChange:Ie,products:Ee,mapProducts:Ae,onProductSelect:b,onProductAddToCart:k,submitButton:S,resetOnSubmit:A=!0},O){let V=$e(null),ie=$e(null),oe=$e(null),ce=$e(()=>{}),pe=$e(null),ne=$e(null);Ot(()=>{let M=V.current;if(M)return pe.current?pe.current.setMode(L):pe.current=new Ao(M,L),()=>{pe.current?.destroy(),pe.current=null}},[L]);let ze=Rt(M=>{let ee=ne.current?.current;ee&&(ee.focus(),Lo(ee,M))},[]),{completedParams:Xe,suggestionPills:xe,setActivePill:Ne,skipActivePill:We,segments:ye,newParamId:J,clearNewParamId:he,placeholderText:y,isFocused:h,isDropdownOpen:Y,isActivePillSelected:ue,isLoading:m,isReady:Ge,activeIndex:ke,listboxId:me,handleTextChange:Je,handleKeyDown:et,setFocused:Ce,editingParam:Ke,editingIdentified:re,editingAnchor:ge,caretOffset:Le,startEditingParam:Fe,handleCaretAfterInput:qe,handleCaretMove:Re,replaceEditingRange:_e,dropdownProps:l,reset:T,refreshProducts:z,prepareSubmit:st,getState:Mt,recordSubmit:zt}=At({onSubmit:M=>ce.current(M),onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,apiConfig:s,additionalContext:g,language:v,currency:x,productId:u,visitorId:d,columns:c,dropdownTrigger:H,optionsPosition:N,closeDropdownOnBlur:q,showNonTappableOptions:R,locationSearch:I,showOptionIcons:C,showOptionImages:B,showOptionCounts:F,showSkipButton:ae,showProducts:P,onFocus:ve,onBlur:De,value:Pe,completedParams:f,onChange:Me,onParamsChange:Ie,products:Ee,mapProducts:Ae,onProductSelect:b,onProductAddToCart:k,source:"full-sdk",setCursor:ze});Ot(()=>{if(!J)return;let M=window.setTimeout(()=>he(),650);return()=>window.clearTimeout(M)},[J,he]);let ka=ke>=0?`${me}-option-${ke}`:void 0,{inputRef:bt,editorProps:Ca,focus:lt,blur:Nt,getPlainText:Ft}=ya({segments:ye,newParamId:J,editingParam:Ke,editingIdentified:re,editingAnchor:ge,caretOffset:Le,placeholderText:y,isFocused:h,showChipIcons:U,showChipImages:Q,isDropdownOpen:Y,listboxId:me,activeDescendantId:ka,autoFocus:E,handleTextChange:Je,handleKeyDown:et,handleCaretAfterInput:qe,handleCaretMove:Re,startEditingParam:Fe,replaceEditingRange:_e,setFocused:Ce});ne.current=bt,Io(()=>{let M=ie.current,ee=bt.current;if(!M||!ee)return;let at=()=>{let Bt=M.firstElementChild;if(!Bt)return;let Ia=Bt.getBoundingClientRect(),Ea=ee.getBoundingClientRect();Ia.top>=Ea.bottom-2?M.setAttribute("data-aia-pill-wrapped",""):M.removeAttribute("data-aia-pill-wrapped")};at();let Ht=new ResizeObserver(at);return Ht.observe(ee),()=>Ht.disconnect()},[ye,xe.length,m,bt]),Ot(()=>{let M=oe.current;if(M)return Oo(M)},[]),Po(O,()=>({focus:lt,blur:Nt,reset:T,refreshProducts:z,setMode:M=>pe.current?.setMode(M),skipActivePill:We}),[lt,Nt,T,z,We]);let tt=!!ye.length||Xe.length>0,wt=Rt(M=>{if(!tt)return;M&&st();let ee=Mt(),at=Eo(Ft(),ee.completedParams,ee.skippedParams,{identifiedParams:ee.identifiedParams,isReady:ee.isReady,customFields:ee.customFields});M&&zt(at),i(at),A&&T()},[zt,A,tt,st,Mt,i,T,Ft]);ce.current=()=>wt(!1);let Sa=Rt(M=>{M.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||lt()},[lt]),Ta=w==="inline",Pa=w==="dropdown";return Dt("div",{ref:V,className:`magicx-aia ${He.container} ${n??""}`,"data-pill-placement":w,"data-options-position":N,"data-animations":D?"on":"off","data-mode":Do(L),children:[Ze(It,{...l,showPills:Pa,productsLayout:_,productImageFallback:p}),Dt("div",{className:He.inputWrapper,"data-aia-input-wrapper":"",onClick:Sa,children:[Dt("div",{ref:oe,className:He.editorArea,"data-aia-editor":"",children:[Ze("div",{...Ca,className:He.input,"data-aia-input":""}),Ta&&(m||xe.length>0)&&Ze("span",{ref:ie,className:He.pillListContainer,"data-aia-pill-list-container":"",children:Ze(ct,{pills:xe,activePillIndex:0,activeSelected:ue,onSelectPill:Ne,loading:m})})]}),S===null?null:S===void 0?Ze(pa,{disabled:!tt,ready:tt&&Ge,onClick:()=>wt(!0),label:Ro(v).submit}):Ze("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:He.submitSlot,onClick:M=>{tt&&(M.stopPropagation(),wt(!0))},children:S})]})]})});export{Mo as AIAutocomplete,It as AIAutocompleteDropdown,_r as DATE_RANGE_META_END,Vr as DATE_RANGE_META_START,Ur as DEFAULT_OPTION_COUNT_UNIT,es as LOCATION_META_KEY,ls as PRODUCT_PATH_PREFIX,ws as TIME_META_KEY,xs as WEEKDAY_LABELS,Gr as buildSubmitResult,Kr as cellDay,qr as cellIso,Qr as dateCellMarks,Yr as formatDate,jr as formatDateRange,$r as formatOptionCount,Zr as formatPlace,Xr as formatTime,Jr as isoDate,ts as monthLabel,as as optionCountLabel,is as optionHasImage,os as optionImageSources,ns as optionImageSrc,rs as optionLabel,ss as optionsShowLeadingVisuals,ds as parseDate,cs as parseLooseDate,ps as parseLooseDateRange,hs as parseTime,us as productFromMatchedItem,ms as productImageSources,gs as productsFromCustomFields,fs as sanitizeOptionIconSvg,bs as selectedRangeFor,At as useAIAutocomplete,vs as visibleDateRange,ys as withSkippedParams};
|
|
3207
|
+
`,document.head.appendChild(e)}var ca={submitButton:"aia-submitButton-otz7H"};import{jsx as Et}from"react/jsx-runtime";function pa({disabled:e,ready:i,onClick:t,label:a=mo().submit}){return Et("button",{type:"button","data-aia-submit":"",className:ca.submitButton,disabled:e,"data-aia-ready":i?"":void 0,onClick:o=>{o.stopPropagation(),t()},"aria-label":a,children:Et("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":a,children:Et("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as go,dateSelectionFor as fo,identifiedParamLabel as bo,withoutTraditionalAutocomplete as wo}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as fa,useEffect as Ye,useRef as Z,useState as vo}from"react";import{useRef as ha}from"react";function ua(e){let i=ha(e);i.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=ha({key:"",overrides:void 0});if(a.current.key!==t){let o={};for(let r of Object.keys(e??{})){let n=(s,g,v)=>{let x=i.current?.[r];return x?x(s,g,v):[]};o[r]=n}a.current={key:t,overrides:e?o:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as ma}from"react";function ga(e){let i=ma(e);i.current=e;let t=ma(null);t.current===null&&(t.current={fetch:(o,r)=>{let n=i.current;return n?n.fetch(o,r):Promise.reject(new Error("products config removed"))},transform:o=>i.current?.transform(o)??[],get limit(){return i.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var ba={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,dateFloor:null,timeView:null,multiSelectView:null,multiSelectDraft:null,locationView:null,locationSearch:null,locationAutocomplete:!0,locationFieldFocused:!1,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,timeDraft:null};function At({onSubmit:e,onResult:i,onError:t,optionOverrides:a,maskCompletedText:o,apiConfig:r,additionalContext:n,language:s,currency:g,productId:v,visitorId:x,columns:u=2,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:w,showNonTappableOptions:L,locationSearch:N,showOptionIcons:D,showOptionImages:H,showOptionCounts:q,showSkipButton:R,showProducts:I,productImageFallback:C="image",onFocus:V,onBlur:Q,value:B,completedParams:F,onChange:ae,onParamsChange:P,products:_,mapProducts:p,onProductSelect:E,onProductAddToCart:ve,source:De,setCursor:Pe}){let f=Z(null),[Me,Ie]=vo(null),Ee=Z(e);Ee.current=e;let Ae=Z(i);Ae.current=i;let b=Z(t);b.current=t;let k=Z(ae);k.current=ae;let S=Z(P);S.current=P;let A=Z(V);A.current=V;let O=Z(Q);O.current=Q;let U=Z(Pe);U.current=Pe;let ie=Z(E);ie.current=E;let oe=Z(ve);oe.current=ve;let ce=Z(x);ce.current=x;let pe=Z(()=>{let l=ce.current;return typeof l=="function"?l():l}).current,ne=ga(_),ze=Z(p);ze.current=p;let Xe=Z((l,T)=>{let z=ze.current;return z?z(l,T):l}).current,xe=p?Xe:void 0,Ne=ua(a);Ye(()=>{if(typeof document>"u")return;let l=new go(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:n,language:s,currency:g,productId:v,visitorId:pe,optionOverrides:Ne.overrides,maskCompletedText:o,columns:u,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:w,showNonTappableOptions:L,locationSearch:N,showProducts:I,source:De,value:B,completedParams:F,onSubmit:(...z)=>Ee.current?.(...z),onResult:(...z)=>Ae.current?.(...z),onError:(...z)=>b.current?.(...z),onChange:(...z)=>k.current?.(...z),onParamsChange:(...z)=>S.current?.(...z),onFocus:()=>A.current?.(),onBlur:()=>O.current?.(),onProductSelect:z=>ie.current?.(z),onProductAddToCart:z=>oe.current?.(z),setCursor:z=>U.current?.(z),products:ne.config,mapProducts:xe});f.current=l,Ie(l.getState());let T=l.subscribe(z=>Ie(z));return()=>{T(),l.destroy(),f.current===l&&(f.current=null)}},[]),Ye(()=>{B!==void 0&&f.current?.setValue(B)},[B]),Ye(()=>{F!==void 0&&f.current?.setCompletedParams(F)},[F]);let We=JSON.stringify(r??null),ye;try{ye=JSON.stringify(n??null)}catch{ye="[unstringifiable]"}Ye(()=>{f.current?.update({apiConfig:r,additionalContext:n,language:s,currency:g,productId:v,optionOverrides:Ne.overrides,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:w,showNonTappableOptions:L,locationSearch:N,showProducts:I})},[We,ye,s,g?.code,g?.rate,g?.country,v,Ne.key,d,c,w,L,N,I]);let J=Z(!1);Ye(()=>{if(!J.current){J.current=!0;return}f.current?.update({products:ne.config})},[ne.enabled]),Ye(()=>{f.current?.update({mapProducts:xe})},[xe]);let he=Z(null);he.current===null&&(he.current={handleTextChange:l=>f.current?.handleTextChange(l),handleKeyDown:l=>{let T="nativeEvent"in l?l.nativeEvent:l;f.current?.handleKeyDown(T)},setFocused:l=>f.current?.setFocused(l),startEditingParam:l=>f.current?.startEditingParam(l),exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:l=>f.current?.handleCaretAfterInput(l),handleCaretMove:l=>f.current?.handleCaretMove(l),replaceEditingRange:l=>f.current?.replaceEditingRange(l)??!1,setActivePill:l=>f.current?.setActivePill(l),skipActivePill:()=>f.current?.skipActivePill(),removeLastParam:()=>f.current?.removeLastParam(),clearNewParamId:()=>f.current?.clearNewParamId(),reset:()=>f.current?.reset(),refreshProducts:()=>f.current?.refreshProducts(),prepareSubmit:()=>f.current?.prepareSubmit(),getState:()=>f.current?.getState()??ba,recordSubmit:l=>f.current?.recordSubmit(l),selectOption:(l,T)=>f.current?.selectOption(l,T),selectProduct:l=>f.current?.selectProduct(l),addProductToCart:l=>{let T=f.current;return!T||!oe.current?Promise.resolve():T.addProductToCart(l)},setActiveDropdownIndex:l=>f.current?.setActiveDropdownIndex(l),clearHighlight:l=>f.current?.clearHighlight(l),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),setTime:l=>f.current?.setTime(l),commitTime:()=>f.current?.commitTime(),toggleMultiSelectOption:l=>f.current?.toggleMultiSelectOption(l),commitMultiSelect:()=>f.current?.commitMultiSelect(),setLocationQuery:l=>f.current?.setLocationQuery(l),moveLocationHighlight:l=>f.current?.moveLocationHighlight(l),commitLocation:l=>f.current?.commitLocation(l),setLocationFieldFocused:l=>f.current?.setLocationFieldFocused(l),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let y=he.current,h=fa(l=>{let T=l.target.value,st=T.length>0&&!l.nativeEvent?.isComposing&&T[0]!==T[0].toUpperCase()?T[0].toUpperCase()+T.slice(1):T;f.current?.handleTextChange(st)},[]),Y=fa(l=>{f.current?.handleKeyDown(l.nativeEvent)},[]),ue=f.current,m=Me??ba,Ge=B!==void 0?B:m.text,ke=F!==void 0?F:m.completedParams,me=m.actionableSuggestions,Je=me[0],et=wo(me),Ce=ue?.listboxId??"",Ke=m.activeDropdownIndex>=0&&ue?`${Ce}-option-${m.activeDropdownIndex}`:void 0,re=m.editingParam,ge=m.editingIdentified,Le=re?{parameter:re.suggestionParameter,text:re.suggestionPlaceholder,required:!0,options:re.options}:ge?{parameter:ge.parameter,text:bo(ge.parameter),required:!0,options:[]}:null,Fe=m.dropdownSuggestion??Le??Je,qe=Le?[Le]:me,Re=fo(m),_e=!ue||m.dropdownLoading;return{completedParams:ke,multiSelectView:m.multiSelectView,toggleMultiSelectOption:y.toggleMultiSelectOption,commitMultiSelect:y.commitMultiSelect,skippedParams:m.skippedParams,identifiedParams:m.identifiedParams,suggestionPills:et,setActivePill:y.setActivePill,skipActivePill:y.skipActivePill,removeLastParam:y.removeLastParam,segments:m.segments,newParamId:m.newParamId,clearNewParamId:y.clearNewParamId,suggestions:m.suggestions,activeIndex:m.activeDropdownIndex,isReady:m.isReady,isLoading:_e,isFocused:m.isFocused,isDropdownOpen:m.isDropdownOpen,isActivePillSelected:m.isActivePillSelected,placeholderText:m.placeholderText,listboxId:Ce,error:m.error,products:m.products,customFields:m.customFields,selectProduct:y.selectProduct,addProductToCart:y.addProductToCart,handleTextChange:y.handleTextChange,handleKeyDown:y.handleKeyDown,setFocused:y.setFocused,editingParam:re,editingIdentified:ge,editingAnchor:m.editingAnchor,caretOffset:m.caretOffset,startEditingParam:y.startEditingParam,exitEditMode:y.exitEditMode,handleCaretAfterInput:y.handleCaretAfterInput,handleCaretMove:y.handleCaretMove,replaceEditingRange:y.replaceEditingRange,inputProps:{value:Ge,placeholder:m.placeholderText||void 0,onChange:h,onKeyDown:Y,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":m.isDropdownOpen,"aria-activedescendant":Ke,"aria-autocomplete":"list","aria-controls":Ce},reset:y.reset,refreshProducts:y.refreshProducts,prepareSubmit:y.prepareSubmit,getState:y.getState,recordSubmit:y.recordSubmit,dropdownProps:{suggestions:Fe?[{...Fe,options:m.dropdownOptions}]:[],activeIndex:m.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,onUnhighlight:y.clearHighlight,isOpen:m.isDropdownOpen,id:Ce,pills:qe,activeSelected:m.isActivePillSelected,onPillClick:y.setActivePill,onSkip:y.skipActivePill,showSkipButton:(R??!0)&&!re&&!ge,showOptionIcons:D??!0,showOptionImages:H??!0,showOptionCounts:q??!0,skipDisabled:m.inSelectionAnimation,isLoading:_e,skeletonExiting:m.skeletonExiting,isInputEmpty:Ge.trim().length===0,language:s,products:m.products,productImageFallback:C,onProductSelect:y.selectProduct,onProductAddToCart:ve?y.addProductToCart:void 0,onProductFocusChange:y.setFocused,formatType:m.activeFormatType,dateView:m.dateView,selectedDateIso:Re.selectedIso,selectedDateRange:Re.selectedRange,dateRangeStart:Re.rangeStart,onPreviousMonth:y.showPreviousMonth,onNextMonth:y.showNextMonth,timeView:m.timeView,multiSelectView:m.multiSelectView,onMultiSelectCommit:y.commitMultiSelect,onTimeChange:y.setTime,onTimeCommit:y.commitTime,locationView:m.locationView,onLocationQuery:y.setLocationQuery,onLocationMove:y.moveLocationHighlight,onLocationCommit:y.commitLocation,onLocationFocusChange:y.setLocationFieldFocused,isFocused:m.isFocused||m.locationFieldFocused,optionsPosition:c??"below"}}}import{chipIdFromTap as xo,extractPlainText as wa,getCursorOffset as va,keepCaretOnChip as yo,plainTextLength as ko,renderEditableContent as Co,setCursorOffset as xa}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as de,useEffect as gt,useLayoutEffect as Lt,useRef as je}from"react";var ft;function So(){if(ft!==void 0)return ft;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),ft=e.contentEditable==="plaintext-only",ft}function ya(e){let{segments:i,showChipIcons:t=!0,showChipImages:a=!0,newParamId:o,editingParam:r,editingIdentified:n,editingAnchor:s,caretOffset:g,placeholderText:v,isFocused:x,isDropdownOpen:u,listboxId:d,activeDescendantId:c,autoFocus:w,handleTextChange:L,handleKeyDown:N,handleCaretAfterInput:D,handleCaretMove:H,startEditingParam:q,replaceEditingRange:R,setFocused:I}=e,C=je(null),V=je(!1),Q=je(""),B=je(""),F=je(null),ae=je(0);F.current=g,gt(()=>{if(!w)return;let b=C.current;if(!b)return;document.activeElement===b?I(!0):b.focus();let k=b.ownerDocument??document,S=k.getSelection(),A=S&&S.rangeCount>0&&b.contains(S.anchorNode);if(S&&!A){let O=k.createRange();O.selectNodeContents(b),O.collapse(!0),S.removeAllRanges(),S.addRange(O)}},[w,I]),gt(()=>{let b=C.current;if(!b)return;let k=b.ownerDocument??document,S=()=>{let A=k.getSelection();if(!A||A.rangeCount===0||!A.anchorNode||!b.contains(A.anchorNode))return;let O=A.anchorNode,U=O.nodeType===Node.ELEMENT_NODE?O:O.parentElement,oe=(A.isCollapsed?U?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ce=r?.id??n?.id??null;if(oe&&oe!==ce){q(oe);return}performance.now()-ae.current<50||H(va(b))};return k.addEventListener("selectionchange",S),()=>k.removeEventListener("selectionchange",S)},[r,n,q,H]),gt(()=>{let b=C.current;if(!b)return;let k=S=>{let A=xo(b,S.target);A&&(q(A),yo(b,A))};return b.addEventListener("click",k),()=>b.removeEventListener("click",k)},[q]),Lt(()=>{let b=C.current;b&&Co({input:b,segments:i,newParamId:o,editingParamId:r?.id??null,placeholderText:v??"",isFocused:x,showChipIcons:t,showChipImages:a})},[i,o,r,v,x,t,a]),Lt(()=>{let b=Q.current,k=o??"";if(Q.current=k,!k||k===b)return;let S=C.current;if(!S)return;S.focus();let A=F.current??ko(S);xa(S,A)},[o]),Lt(()=>{let b=B.current,k=r?.id??"";if(B.current=k,!k||k===b||s==null)return;let S=C.current;S&&xa(S,s)},[r,s]);let P=de(()=>{if(V.current)return;let b=C.current;if(!b)return;let k=wa(b),A=k.length>0&&k[0]!==k[0].toUpperCase()?k[0].toUpperCase()+k.slice(1):k;L(A)},[L]),_=de(()=>{ae.current=performance.now(),P();let b=C.current;b&&D(va(b))},[P,D]);gt(()=>{let b=C.current;if(!b)return;let k=S=>{let A=S,O=A.inputType;if(O==="insertParagraph"||O==="insertLineBreak"||O==="insertFromDrop"){S.preventDefault();return}if(O.startsWith("insert")||O.startsWith("delete")){let U=O.startsWith("delete")?"":A.data??"";R(U)&&S.preventDefault()}};return b.addEventListener("beforeinput",k),()=>b.removeEventListener("beforeinput",k)},[R]);let p=de(()=>{V.current=!0,C.current?.setAttribute("data-aia-composing","true")},[]),E=de(()=>{V.current=!1,C.current?.removeAttribute("data-aia-composing"),P()},[P]),ve=de(b=>{b.preventDefault();let k=C.current;if(!k)return;let S=(b.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!S)return;let A=k.ownerDocument??document,O=A.getSelection();if(!O||O.rangeCount===0)return;let U=O.getRangeAt(0);if(!k.contains(U.startContainer))return;U.deleteContents();let ie=A.createTextNode(S);U.insertNode(ie),U.setStartAfter(ie),U.collapse(!0),O.removeAllRanges(),O.addRange(U),P()},[P]),De=de(b=>N(b),[N]),Pe=de(()=>I(!0),[I]),f=de(()=>I(!1),[I]),Me=de(()=>C.current?.focus(),[]),Ie=de(()=>C.current?.blur(),[]),Ee=de(()=>{let b=C.current;return b?wa(b):""},[]),Ae=So()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:Ae,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":d,"aria-expanded":u,"aria-activedescendant":c,spellCheck:!0,enterKeyHint:"send",onInput:_,onKeyDown:De,onCompositionStart:p,onCompositionEnd:E,onPaste:ve,onFocus:Pe,onBlur:f},getPlainText:Ee,focus:Me,blur:Ie}}import{jsx as Ze,jsxs as Dt}from"react/jsx-runtime";function Do(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Mo=To(function({onSubmit:i,onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,className:n,apiConfig:s,additionalContext:g,language:v,currency:x,productId:u,visitorId:d,columns:c,pillPlacement:w="dropdown",mode:L="auto",optionsPosition:N="below",animations:D=!0,dropdownTrigger:H,closeDropdownOnBlur:q,showNonTappableOptions:R,locationSearch:I,showOptionIcons:C=!0,showChipIcons:V=!0,showChipImages:Q=!0,showOptionImages:B=!0,showOptionCounts:F=!0,showSkipButton:ae,showProducts:P,productsLayout:_,productImageFallback:p,autoFocus:E=!0,onFocus:ve,onBlur:De,value:Pe,completedParams:f,onChange:Me,onParamsChange:Ie,products:Ee,mapProducts:Ae,onProductSelect:b,onProductAddToCart:k,submitButton:S,resetOnSubmit:A=!0},O){let U=$e(null),ie=$e(null),oe=$e(null),ce=$e(()=>{}),pe=$e(null),ne=$e(null);Ot(()=>{let M=U.current;if(M)return pe.current?pe.current.setMode(L):pe.current=new Ao(M,L),()=>{pe.current?.destroy(),pe.current=null}},[L]);let ze=Rt(M=>{let ee=ne.current?.current;ee&&(ee.focus(),Lo(ee,M))},[]),{completedParams:Xe,suggestionPills:xe,setActivePill:Ne,skipActivePill:We,segments:ye,newParamId:J,clearNewParamId:he,placeholderText:y,isFocused:h,isDropdownOpen:Y,isActivePillSelected:ue,isLoading:m,isReady:Ge,activeIndex:ke,listboxId:me,handleTextChange:Je,handleKeyDown:et,setFocused:Ce,editingParam:Ke,editingIdentified:re,editingAnchor:ge,caretOffset:Le,startEditingParam:Fe,handleCaretAfterInput:qe,handleCaretMove:Re,replaceEditingRange:_e,dropdownProps:l,reset:T,refreshProducts:z,prepareSubmit:st,getState:Mt,recordSubmit:zt}=At({onSubmit:M=>ce.current(M),onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,apiConfig:s,additionalContext:g,language:v,currency:x,productId:u,visitorId:d,columns:c,dropdownTrigger:H,optionsPosition:N,closeDropdownOnBlur:q,showNonTappableOptions:R,locationSearch:I,showOptionIcons:C,showOptionImages:B,showOptionCounts:F,showSkipButton:ae,showProducts:P,onFocus:ve,onBlur:De,value:Pe,completedParams:f,onChange:Me,onParamsChange:Ie,products:Ee,mapProducts:Ae,onProductSelect:b,onProductAddToCart:k,source:"full-sdk",setCursor:ze});Ot(()=>{if(!J)return;let M=window.setTimeout(()=>he(),650);return()=>window.clearTimeout(M)},[J,he]);let ka=ke>=0?`${me}-option-${ke}`:void 0,{inputRef:bt,editorProps:Ca,focus:lt,blur:Nt,getPlainText:Ft}=ya({segments:ye,newParamId:J,editingParam:Ke,editingIdentified:re,editingAnchor:ge,caretOffset:Le,placeholderText:y,isFocused:h,showChipIcons:V,showChipImages:Q,isDropdownOpen:Y,listboxId:me,activeDescendantId:ka,autoFocus:E,handleTextChange:Je,handleKeyDown:et,handleCaretAfterInput:qe,handleCaretMove:Re,startEditingParam:Fe,replaceEditingRange:_e,setFocused:Ce});ne.current=bt,Io(()=>{let M=ie.current,ee=bt.current;if(!M||!ee)return;let at=()=>{let Bt=M.firstElementChild;if(!Bt)return;let Ia=Bt.getBoundingClientRect(),Ea=ee.getBoundingClientRect();Ia.top>=Ea.bottom-2?M.setAttribute("data-aia-pill-wrapped",""):M.removeAttribute("data-aia-pill-wrapped")};at();let Ht=new ResizeObserver(at);return Ht.observe(ee),()=>Ht.disconnect()},[ye,xe.length,m,bt]),Ot(()=>{let M=oe.current;if(M)return Oo(M)},[]),Po(O,()=>({focus:lt,blur:Nt,reset:T,refreshProducts:z,setMode:M=>pe.current?.setMode(M),skipActivePill:We}),[lt,Nt,T,z,We]);let tt=!!ye.length||Xe.length>0,wt=Rt(M=>{if(!tt)return;M&&st();let ee=Mt(),at=Eo(Ft(),ee.completedParams,ee.skippedParams,{identifiedParams:ee.identifiedParams,isReady:ee.isReady,customFields:ee.customFields});M&&zt(at),i(at),A&&T()},[zt,A,tt,st,Mt,i,T,Ft]);ce.current=()=>wt(!1);let Sa=Rt(M=>{M.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||lt()},[lt]),Ta=w==="inline",Pa=w==="dropdown";return Dt("div",{ref:U,className:`magicx-aia ${He.container} ${n??""}`,"data-pill-placement":w,"data-options-position":N,"data-animations":D?"on":"off","data-mode":Do(L),children:[Ze(It,{...l,showPills:Pa,productsLayout:_,productImageFallback:p}),Dt("div",{className:He.inputWrapper,"data-aia-input-wrapper":"",onClick:Sa,children:[Dt("div",{ref:oe,className:He.editorArea,"data-aia-editor":"",children:[Ze("div",{...Ca,className:He.input,"data-aia-input":""}),Ta&&(m||xe.length>0)&&Ze("span",{ref:ie,className:He.pillListContainer,"data-aia-pill-list-container":"",children:Ze(ct,{pills:xe,activePillIndex:0,activeSelected:ue,onSelectPill:Ne,loading:m})})]}),S===null?null:S===void 0?Ze(pa,{disabled:!tt,ready:tt&&Ge,onClick:()=>wt(!0),label:Ro(v).submit}):Ze("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:He.submitSlot,onClick:M=>{tt&&(M.stopPropagation(),wt(!0))},children:S})]})]})});export{Mo as AIAutocomplete,It as AIAutocompleteDropdown,_r as DATE_RANGE_META_END,Ur as DATE_RANGE_META_START,Vr as DEFAULT_OPTION_COUNT_UNIT,es as LOCATION_META_KEY,ls as PRODUCT_PATH_PREFIX,ws as TIME_META_KEY,xs as WEEKDAY_LABELS,Gr as buildSubmitResult,Kr as cellDay,qr as cellIso,Qr as dateCellMarks,Yr as formatDate,jr as formatDateRange,$r as formatOptionCount,Zr as formatPlace,Xr as formatTime,Jr as isoDate,ts as monthLabel,as as optionCountLabel,is as optionHasImage,os as optionImageSources,ns as optionImageSrc,rs as optionLabel,ss as optionsShowLeadingVisuals,ds as parseDate,cs as parseLooseDate,ps as parseLooseDateRange,hs as parseTime,us as productFromMatchedItem,ms as productImageSources,gs as productsFromCustomFields,fs as sanitizeOptionIconSvg,bs as selectedRangeFor,At as useAIAutocomplete,vs as visibleDateRange,ys as withSkippedParams};
|
|
3188
3208
|
//# sourceMappingURL=index.mjs.map
|