@magicx-eng/ai-autocomplete-react 0.53.2 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/REFERENCE.md +3 -2
- package/dist/index.js +26 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -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 is,cellDay as os,cellIso as ns,DATE_RANGE_META_END as rs,DATE_RANGE_META_START as ss,DEFAULT_OPTION_COUNT_UNIT as ls,dateCellMarks as ds,formatDate as cs,formatDateRange as ps,formatOptionCount as hs,formatPlace as us,formatTime as ms,isoDate as gs,LOCATION_META_KEY as fs,monthLabel as bs,optionCountLabel as ws,optionHasImage as vs,optionImageSources as xs,optionImageSrc as ys,optionLabel as ks,optionsShowLeadingVisuals as Cs,PRODUCT_PATH_PREFIX as Ss,parseDate as Ts,parseLooseDate as Ps,parseLooseDateRange as Is,parseTime as Es,productFromMatchedItem as As,productImageSources as Rs,productsFromCustomFields as Os,sanitizeOptionIconSvg as Ls,selectedRangeFor as zs,TIME_META_KEY as Ds,visibleDateRange as Ms,WEEKDAY_LABELS as Ns,withSkippedParams as Hs}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Go,useCallback as zt,useEffect as Dt,useImperativeHandle as Ko,useLayoutEffect as qo,useRef as Ze}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
|
|
@@ -236,6 +236,18 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
236
236
|
opacity: 0;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
/* The empty box's hint (the lead word and the starting options, swapping
|
|
240
|
+
one at a time) is a sibling laid over the input; while it shows, the
|
|
241
|
+
input's own placeholder steps aside, and during IME composition the hint
|
|
242
|
+
steps aside for the composing text. */
|
|
243
|
+
.aia-input-IW-P-[data-aia-empty="true"][data-placeholder][data-aia-hint]::before {
|
|
244
|
+
content: none;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
[data-aia-hint-el]:has(+ .aia-input-IW-P-[data-aia-composing]) {
|
|
248
|
+
visibility: hidden;
|
|
249
|
+
}
|
|
250
|
+
|
|
239
251
|
@media (prefers-reduced-motion: reduce) {
|
|
240
252
|
.aia-input-IW-P-[data-aia-empty="true"][data-placeholder]::before {
|
|
241
253
|
transition-duration: 0s;
|
|
@@ -1534,7 +1546,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
1534
1546
|
transition-delay: 0s;
|
|
1535
1547
|
}
|
|
1536
1548
|
}
|
|
1537
|
-
`,document.head.appendChild(e)}var
|
|
1549
|
+
`,document.head.appendChild(e)}var ve={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",skeletonBar:"aia-skeletonBar-O3xIx",multiDone:"aia-multiDone-y12U7"};import{cellDay as Da,cellIso as ot,dateCellMarks as Ma,isDimmedDay as Na,isoDate as Ha,monthLabel as Fa,visibleDateRange as Ba,WEEKDAY_LABELS as Wa}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Ga}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) ---
|
|
1538
1550
|
|
|
1539
1551
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1540
1552
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1721,7 +1733,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
1721
1733
|
opacity: 0.8;
|
|
1722
1734
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1723
1735
|
}
|
|
1724
|
-
`,document.head.appendChild(e)}var G={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
|
|
1736
|
+
`,document.head.appendChild(e)}var G={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 xe,jsxs as qt}from"react/jsx-runtime";var Ka=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function _t({options:e,activeIndex:o,listboxId:t,view:a,selection:i,onSelect:s,onHighlight:r,onUnhighlight:l,onPreviousMonth:u,onNextMonth:w}){let k=Ha(new Date),m=Ba({pendingStart:i.rangeStart,highlightedIso:ot(e[o]),selected:i.selectedRange,floor:i.floor});return qt("div",{className:G.datepicker,"data-aia-datepicker":"",children:[qt("div",{className:G.header,children:[xe("button",{type:"button",tabIndex:-1,className:G.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:c=>c.preventDefault(),onClick:u,children:"\u2039"}),xe("span",{className:G.month,"data-aia-date-month":"","aria-live":"polite",children:Fa(a)}),xe("button",{type:"button",tabIndex:-1,className:G.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:c=>c.preventDefault(),onClick:w,children:"\u203A"})]}),xe("div",{className:G.weekdays,"aria-hidden":"true",children:Wa.map((c,h)=>xe("span",{className:G.weekday,children:c},Ka[h]))}),xe("div",{className:G.grid,"data-aia-date-grid":"",children:e.map((c,h)=>xe(qa,{option:c,id:`${t}-option-${h}`,index:h,isHighlighted:h===o&&c.is_tappable,isToday:ot(c)===k,isPast:Na(ot(c),k,i.floor),marks:Ma(ot(c),{selectedIso:i.selectedIso,range:m}),onSelect:s,onHighlight:r,onUnhighlight:l},ot(c)??`pad-${h}`))})]})}function qa({option:e,id:o,index:t,isHighlighted:a,isToday:i,isPast:s,marks:r,onSelect:l,onHighlight:u,onUnhighlight:w}){let[k,m]=Ga(!1),c=Da(e);if(c==null)return xe("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${G.cell} ${G.blank}`});let h=()=>{m(!0),l(e),setTimeout(()=>m(!1),170)},v=[G.cell,G.day,s?G.past:"",a?G.highlighted:"",i?G.today:"",r.inRange?G.inRange:"",r.selected?G.selected:"",k?G.pressed:""].filter(Boolean).join(" ");return xe("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:v,onClick:h,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),h())},onMouseEnter:()=>u(t),onMouseLeave:w?()=>w(t):void 0,children:xe("span",{className:G.number,children:c})})}import{ATTRIBUTION_URL as _a,buildAttributionUrl as Va,getFooterHint as Ua,uiStringsFor as Ya}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Qa,useState as ja}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 {
|
|
1725
1737
|
display: flex;
|
|
1726
1738
|
flex-wrap: wrap;
|
|
1727
1739
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1908,7 +1920,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
1908
1920
|
justify-content: flex-end;
|
|
1909
1921
|
}
|
|
1910
1922
|
}
|
|
1911
|
-
`,document.head.appendChild(e)}var
|
|
1923
|
+
`,document.head.appendChild(e)}var Pe={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 rt,jsxs as xt}from"react/jsx-runtime";function Ut({isOptionHighlighted:e=!1,isInputEmpty:o=!1,strings:t=Ya()}){let{key:a,hint:i}=Ua(e,o,t),[s,r]=ja(_a);return Qa(()=>{r(Va())},[]),rt("footer",{className:Pe.footer,"data-aia-footer":"",children:xt(nt,{justify:"between",noWrap:!0,className:Pe.row,children:[xt(nt,{gap:"5px",className:Pe.hintGroup,children:[rt("kbd",{className:Pe.key,children:a}),rt("span",{className:Pe.hint,children:i})]}),xt("a",{className:Pe.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[rt("span",{className:Pe.brand,children:"AI"}),rt("span",{className:Pe.badge,children:"Autocomplete"})]})]})})}import{useEffect as Yt,useLayoutEffect as $a,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
|
|
1912
1924
|
Angular copy). The three are kept identical by
|
|
1913
1925
|
packages/vanilla/tests/render/locationFieldParity.test.ts. */
|
|
1914
1926
|
.aia-location-6-fsr {
|
|
@@ -2042,7 +2054,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
2042
2054
|
.aia-loadingBar-OLCr4:nth-child(3) {
|
|
2043
2055
|
width: 60%;
|
|
2044
2056
|
}
|
|
2045
|
-
`,document.head.appendChild(e)}var K={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 oe,jsxs as Me}from"react/jsx-runtime";var Za=0;function st(e){return e.getRootNode().activeElement??null}function $t(e){return e.getRootNode().getSelection?.()??document.getSelection()}function Qt(e){if(!e.isContentEditable)return null;let o=$t(e);if(!o||o.rangeCount===0)return null;let t=o.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function jt(e,o){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=$t(e);if(!t)return;let a=o;(!a||!a.startContainer.isConnected||!e.contains(a.startContainer))&&(a=document.createRange(),a.selectNodeContents(e),a.collapse(!1)),t.removeAllRanges(),t.addRange(a)}var Xa=Me("svg",{className:K.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[oe("path",{d:"M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"}),oe("circle",{cx:"12",cy:"9.5",r:"2.5"})]}),Ja=Me("svg",{className:K.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[oe("circle",{cx:"11",cy:"11",r:"7"}),oe("path",{d:"m20 20-3.5-3.5"})]});function Zt({view:e,searchLabel:o,noResultsLabel:t,useTypedLabel:a,widgetFocused:i,reediting:s=!1,visible:r=!0,interactive:l=!0,onQuery:u,onMove:w,onCommit:k,onFocusChange:
|
|
2057
|
+
`,document.head.appendChild(e)}var K={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 oe,jsxs as Me}from"react/jsx-runtime";var Za=0;function st(e){return e.getRootNode().activeElement??null}function $t(e){return e.getRootNode().getSelection?.()??document.getSelection()}function Qt(e){if(!e.isContentEditable)return null;let o=$t(e);if(!o||o.rangeCount===0)return null;let t=o.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function jt(e,o){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=$t(e);if(!t)return;let a=o;(!a||!a.startContainer.isConnected||!e.contains(a.startContainer))&&(a=document.createRange(),a.selectNodeContents(e),a.collapse(!1)),t.removeAllRanges(),t.addRange(a)}var Xa=Me("svg",{className:K.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[oe("path",{d:"M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"}),oe("circle",{cx:"12",cy:"9.5",r:"2.5"})]}),Ja=Me("svg",{className:K.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[oe("circle",{cx:"11",cy:"11",r:"7"}),oe("path",{d:"m20 20-3.5-3.5"})]});function Zt({view:e,searchLabel:o,noResultsLabel:t,useTypedLabel:a,widgetFocused:i,reediting:s=!1,visible:r=!0,interactive:l=!0,onQuery:u,onMove:w,onCommit:k,onFocusChange:m}){let c=se(null),h=se(null),v=se(null),E=se(null),B=se(null),z=se(!1),L=se(!1),X=se(!1),T=se(!1),N=se(i);N.current=i;let H=se(m);H.current=m;let C=d=>{T.current=d,m(d)},_=()=>{let d=c.current;return d!=null&&st(d)===d},J=()=>{let d=h.current;if(!d)return;let I=st(d);I instanceof HTMLElement&&I!==c.current&&I!==document.body&&!d.contains(I)&&(E.current=I,B.current=Qt(I))},V=d=>{let I=h.current;!I||!(d instanceof HTMLElement)||d===E.current||d===document.body||I.contains(d)||(E.current=d,B.current=Qt(d))},U=se(null);U.current===null&&(U.current=`aia-location-${++Za}`);let R=`${U.current}-row-`;Yt(()=>{let d=c.current;d&&d.value!==e.query&&st(d)!==d&&(d.value=e.query)},[e.query]),Yt(()=>{i&&(s&&!X.current&&(L.current=!1),X.current=s);let d=c.current;if(d){if(!r&&_()){L.current=!0,D();return}if(!i){setTimeout(()=>{if(N.current)return;let I=E.current;I&&st(I)===I||(L.current=!1)},0);return}if(!(!s||L.current||!l||_())){if(J(),C(!0),d.focus({preventScroll:!0}),!_()){L.current=!0,C(!1);return}d.value&&d.select()}}}),$a(()=>()=>{if(!T.current)return;let d=c.current,I=E.current;I?.isConnected&&d&&st(d)===d&&(z.current=!0,jt(I,B.current),z.current=!1),T.current=!1,H.current(!1)},[]);let D=(d=!1)=>{d&&(L.current=!0);let I=E.current;I?.isConnected&&_()&&(z.current=!0,jt(I,B.current),z.current=!1),C(!1)},me=e.query.trim(),le=e.highlighted>=0&&e.highlighted<e.places.length?`${R}${e.highlighted}`:void 0,ne=null;return e.places.length>0?ne=e.places.map((d,I)=>Me("div",{id:`${R}${I}`,role:"option","aria-selected":I===e.highlighted,className:I===e.highlighted?`${K.row} ${K.highlighted}`:K.row,"data-aia-location-row":"","data-aia-index":I,onClick:()=>{l&&(D(!0),k(I))},children:[oe("span",{className:K.pin,children:Xa}),Me("span",{className:K.text,children:[oe("span",{className:K.name,children:d.name}),d.secondary&&oe("span",{className:K.secondary,children:d.secondary})]})]},d.id)):e.status==="loading"?ne=Me("div",{className:K.loading,"data-aia-location-loading":"",children:[oe("span",{className:K.loadingBar}),oe("span",{className:K.loadingBar}),oe("span",{className:K.loadingBar})]}):me&&(ne=Me("div",{className:K.note,"data-aia-location-note":"",children:[e.status==="done"&&oe("span",{className:K.empty,children:t}),oe("span",{children:a})]})),Me("div",{ref:h,className:K.location,"data-aia-location":"",onMouseDown:d=>{!(d.target instanceof Node)||!v.current?.contains(d.target)||(d.stopPropagation(),J(),C(!0))},children:[Me("label",{ref:v,className:K.field,children:[Ja,oe("input",{ref:c,type:"text",className:K.input,"data-aia-location-input":"",defaultValue:e.query,placeholder:o,"aria-label":o,"aria-activedescendant":le,autoComplete:"off",autoCapitalize:"words",enterKeyHint:"done",spellCheck:!1,tabIndex:r?0:-1,onChange:d=>u(d.target.value),onFocus:d=>{V(d.relatedTarget),C(!0)},onBlur:()=>{z.current||(L.current=!0,C(!1))},onKeyDown:d=>{if(!d.nativeEvent.isComposing)switch(d.key){case"ArrowDown":case"ArrowUp":d.preventDefault(),w(d.key==="ArrowDown"?1:-1);return;case"Enter":if(d.preventDefault(),!l)return;D(!0),k();return;case"Escape":d.preventDefault(),d.stopPropagation(),L.current=!0,D();return;case"Backspace":if(d.currentTarget.value!=="")return;d.preventDefault(),L.current=!0,D();return}}})]}),oe("div",{className:K.results,"data-aia-location-results":"","aria-live":"polite",children:ne})]})}import{isSmartSuggestion as ii,isTraditionalAutocompleteSuggestion as oi}from"@magicx-eng/ai-autocomplete-vanilla";import{SMART_SUGGESTION_SPARKLE_SVG as ei}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,
|
|
2046
2058
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
2047
2059
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
2048
2060
|
as it was when the outline was dashed. */
|
|
@@ -2200,7 +2212,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
2200
2212
|
opacity: 0;
|
|
2201
2213
|
}
|
|
2202
2214
|
}
|
|
2203
|
-
`,document.head.appendChild(e)}var
|
|
2215
|
+
`,document.head.appendChild(e)}var ye={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",loadingOut:"aia-loadingOut-Aj9xO"};import{Fragment as ti,jsx as yt,jsxs as ai}from"react/jsx-runtime";var kt={selected:1,first:.7,next:.4,last:.2};function Xt({label:e,state:o,active:t,rounded:a,loading:i,smartSuggestion:s,completionHeader:r,onClick:l}){let u=[ye.pill,a?ye.rounded:"",i?ye.skeleton:""].filter(Boolean).join(" ");return yt("button",{type:"button","data-aia-pill":"","data-aia-pill-active":t?"":void 0,"data-aia-loading":i?"":void 0,"data-aia-smart-suggestion":s?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:u,style:{"--aia-pill-opacity":kt[o]},onMouseDown:w=>w.preventDefault(),onClick:i?void 0:l,disabled:i,children:s?ai(ti,{children:[yt("span",{className:`${ye.smartText} magicx-aia-smart-suggestion-text`,children:e}),yt("span",{className:`${ye.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:ei}})]}):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 {
|
|
2204
2216
|
position: relative;
|
|
2205
2217
|
z-index: 1;
|
|
2206
2218
|
pointer-events: auto;
|
|
@@ -2210,7 +2222,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
2210
2222
|
align-items: center;
|
|
2211
2223
|
vertical-align: middle;
|
|
2212
2224
|
}
|
|
2213
|
-
`,document.head.appendChild(e)}var Ct={list:"aia-list-qvLqO"};import{jsx as
|
|
2225
|
+
`,document.head.appendChild(e)}var Ct={list:"aia-list-qvLqO"};import{jsx as pt}from"react/jsx-runtime";var ni=[125,69];function Jt(e){return e===0?"first":e===1?"next":"last"}function ht({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:a,rounded:i,loading:s}){return s&&e.length===0?pt("span",{className:Ct.list,"data-aia-pill-list-loading":"",children:ni.map((r,l)=>pt("span",{"data-aia-pill-skeleton":"",className:`${ye.pill} ${i?ye.rounded:""} ${ye.skeleton}`,style:{width:r,"--aia-pill-opacity":kt[Jt(l)]}},`skel-${r}`))}):pt("span",{className:Ct.list,"data-aia-pill-list-loading":s?"":void 0,children:e.map((r,l)=>{let u=!!a&&l===o;return pt(Xt,{label:r.text,state:u?"selected":Jt(l),selected:u,active:l===o,rounded:i,loading:s,smartSuggestion:ii(r),completionHeader:oi(r),onClick:()=>t(l)},`${r.parameter}-${r.text}`)})})}import{attachProductRowWheel as ri,productImageSources as si,productImageSrc as li,productInitial as di,productPhotoFill as ci,uiStringsFor as pi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as St,useRef as ut,useState as mt}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
|
|
2214
2226
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
2215
2227
|
theming one package sees the same result in the other.
|
|
2216
2228
|
|
|
@@ -2779,7 +2791,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
2779
2791
|
.aia-card-JBGYT[data-aia-product-has-cart] {
|
|
2780
2792
|
padding-right: calc(var(--aia-product-cart-size, 28px) + 16px);
|
|
2781
2793
|
}
|
|
2782
|
-
`,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",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
|
|
2794
|
+
`,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",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 Ye}from"react/jsx-runtime";function ea({products:e,listboxId:o,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s=!0,layout:r="row",imageFallback:l="image",strings:u=pi()}){let w=e.length>0,k=ut(null);if(St(()=>{let c=k.current;if(!(!w||!c))return ri(c)},[w]),!w)return null;let m=`${o}-products-label`;return Ye("section",{className:q.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":m,children:[j("div",{className:q.label,id:m,"data-aia-products-label":"",children:u.products}),j("div",{ref:k,className:q.row,"data-aia-products-row":"",children:e.map((c,h)=>j(hi,{product:c,id:`${o}-product-${h}`,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s,imageFallback:l,soldOut:u.soldOut,addToCart:u.addToCart},c.id))})]})}function hi({product:e,id:o,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s,imageFallback:r,soldOut:l,addToCart:u}){let w=!!a&&e.available!==!1,[k,m]=mt(null),c=v=>{v.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},h=v=>{v.metaKey||v.ctrlKey||v.shiftKey||v.altKey||v.button!==0||(v.preventDefault(),t(e))};return Ye("a",{id:o,className:q.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":w?"":void 0,role:"option","aria-selected":!1,style:k?{"--aia-product-photo-fill-x":String(k.x),"--aia-product-photo-fill-y":String(k.y)}:void 0,href:e.url,tabIndex:s?0:-1,onClick:h,onKeyDown:v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:c,children:[j(gi,{sources:si(e.imageUrl),title:e.title,fallback:r,onPhotoFill:m},li(e.imageUrl)??""),Ye("span",{className:q.body,children:[e.vendor?j("span",{className:q.vendor,children:e.vendor}):null,j("span",{className:q.title,children:e.title}),e.price?Ye("span",{className:q.price,children:[e.price,e.compareAtPrice?j("s",{className:q.compareAt,children:e.compareAtPrice}):null]}):null,e.available===!1?j("span",{className:q.badge,children:l}):null]}),w&&a?j(mi,{product:e,label:`${u}: ${e.title}`,focusable:s,onAddToCart:a,onFocus:()=>i?.(!0),onBlur:c},ui(e)):null]})}function ui(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(o=>o??"").join("\0")}function mi({product:e,label:o,focusable:t,onAddToCart:a,onFocus:i,onBlur:s}){let[r,l]=mt(null),u=ut(null),w=ut(e);w.current=e;let k=ut(!0);St(()=>(k.current=!0,()=>{k.current=!1}),[]);let m=h=>{u.current=h,k.current&&l(h)},c=h=>{if(h.preventDefault(),h.stopPropagation(),u.current==="adding")return;m("adding");let v;try{v=Promise.resolve(a(w.current))}catch(E){v=Promise.reject(E)}v.then(()=>m("added"),()=>m(null))};return j("span",{className:q.cart,"data-aia-product-cart":"","data-aia-cart-state":r??void 0,"aria-busy":r==="adding"?!0:void 0,role:"button","aria-label":o,tabIndex:t?0:-1,onClick:c,onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||c(h)},onFocus:h=>{h.stopPropagation(),i()},onBlur:h=>{h.stopPropagation(),s(h)},children:Ye("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[j("path",{className:q.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:q.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),j("path",{className:q.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),j("path",{className:q.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),j("circle",{className:q.cartGlyph,cx:"9",cy:"20",r:"1.3"}),j("circle",{className:q.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function gi({sources:e,title:o,fallback:t,onPhotoFill:a}){let[i,s]=mt(0),r=e[i],l=!!r,[u,w]=mt(null),k=!l&&t==="initial";return St(()=>()=>a(null),[a]),Ye("span",{className:q.media,"aria-hidden":"true","data-aia-product-placeholder":!l&&!k?"":void 0,"data-aia-product-initial":k?"":void 0,"data-aia-image-loaded":l&&u===r?"":void 0,children:[l?j("img",{className:q.image,src:r,alt:"",loading:"lazy",decoding:"async",onLoad:m=>{w(r),a(ci(m.currentTarget.naturalWidth,m.currentTarget.naturalHeight))},onError:()=>{i+1>=e.length&&a(null),s(m=>m+1)}}):null,k?di(o):null]})}import{isOptionsGridMobileViewport as Ri,measureOptionsGrid as Oi,needsOptionsGridMeasurement as Li,OPTIONS_GRID_MOBILE_QUERY as zi,optionEnterDelayMs as Di,optionsShowLeadingVisuals as Mi,planOptionsGrid as oa,releasePanelHug as Ni,sameOptionRows as Hi,syncPanelHug as Fi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Bi,useLayoutEffect as na,useRef as ra,useState as la}from"react";import{optionsGridTemplateColumns as fi}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as bi,useRef as wi}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 {
|
|
2783
2795
|
display: grid;
|
|
2784
2796
|
grid-template-columns: repeat(
|
|
2785
2797
|
auto-fit,
|
|
@@ -2823,7 +2835,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
2823
2835
|
:where([data-aia-options-style="classic"]) .aia-grid[data-scroll] {
|
|
2824
2836
|
max-height: var(--aia-grid-max-height, 120px);
|
|
2825
2837
|
}
|
|
2826
|
-
`,document.head.appendChild(e)}import{jsx as vi}from"react/jsx-runtime";function ta({min:e="16rem",max:o,gap:t,scroll:a=!1,maxHeight:i,scrollResetKey:s,cols:r,template:l,innerRef:u,className:w,children:k,...
|
|
2838
|
+
`,document.head.appendChild(e)}import{jsx as vi}from"react/jsx-runtime";function ta({min:e="16rem",max:o,gap:t,scroll:a=!1,maxHeight:i,scrollResetKey:s,cols:r,template:l,innerRef:u,className:w,children:k,...m}){let c=wi(null);bi(()=>{if(s===void 0)return;let v=c.current;v&&(v.scrollTop=0)},[s]);let h={"--aia-grid-min":e};return o&&(h["--aia-grid-max"]=o),t&&(h["--aia-grid-gap"]=t),i&&(h["--aia-grid-max-height"]=i),r&&(h.gridTemplateColumns=fi(r)),l&&(h.gridTemplateColumns=l),vi("div",{ref:v=>{c.current=v,u?.(v)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":a||void 0,style:h,...m,children:k})}import{formatOptionCount as xi,highlightParts as yi,isMultiSelectToggleTap as ki,OPTION_ENTER_DELAY_VAR as Ci,optionImageSources as Si,optionLabel as aa,sanitizeOptionIconSvg as Ti}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Pi,useMemo as Ii,useRef as Ei,useState as gt}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 {
|
|
2827
2839
|
position: relative;
|
|
2828
2840
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
2829
2841
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -3343,7 +3355,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
3343
3355
|
border-radius: 6px;
|
|
3344
3356
|
font-size: 11px;
|
|
3345
3357
|
}
|
|
3346
|
-
`,document.head.appendChild(e)}var
|
|
3358
|
+
`,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",loadingOut:"aia-loadingOut-hI-qI",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",text:"aia-text-yqoh9",checkbox:"aia-checkbox-KGRhg"};import{Fragment as Ai,jsx as Ie,jsxs as Tt}from"react/jsx-runtime";function ia({option:e,isHighlighted:o,checked:t,onSelect:a,onHighlight:i,onUnhighlight:s,id:r,loading:l,showIcon:u=!0,showImage:w=!0,showCount:k=!0,scrollHint:m,enterDelayMs:c=0}){let[h]=gt(c),[v,E]=gt(!1),B=w?Si(e.image_url):[],z=B[0]??null,[L,X]=gt([]),T=B.find(R=>!L.includes(R))??null,[N,H]=gt(null),C=Ii(()=>!z&&u&&e.icon_svg?Ti(e.icon_svg):null,[z,u,e.icon_svg]),_=k?xi(e.item_count):null,J=Ei(void 0);Pi(()=>()=>clearTimeout(J.current),[]);let V=R=>{if(l||!e.is_tappable||v&&t===void 0)return;E(!0);let D=R?.currentTarget;t!==void 0&&D!==void 0&&R!==void 0&&!ki(D,D.querySelector("[data-aia-checkbox]"),R)?a(e,{commit:!0}):a(e),clearTimeout(J.current),J.current=setTimeout(()=>E(!1),170)},U=[$.item,o&&!l?$.highlighted:"",e.liveMatch&&!l?$.liveMatch:"",e.is_tappable?$.tappable:$.nonTappable,v?$.pressed:"",m?$.scrollHint:""].filter(Boolean).join(" ");return Ie("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"data-aia-icon":C&&e.icon?e.icon:void 0,"data-aia-image":z?"":void 0,"data-aia-item-count":_!==null?e.item_count:void 0,"aria-selected":t??o,className:U,style:{[Ci]:`${h}ms`},tabIndex:l||!e.is_tappable?-1:0,onClick:V,onKeyDown:R=>{!l&&e.is_tappable&&(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),V())},onMouseEnter:!l&&e.is_tappable?i:void 0,onMouseLeave:s,children:Tt("span",{className:$.content,children:[t!==void 0&&e.is_tappable&&Ie("span",{className:$.checkbox,"aria-hidden":"true","data-aia-checkbox":"","data-checked":t,children:t?"\u2713":""}),z&&Ie("span",{className:`${$.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":T!==null&&N===T?"":void 0,children:Ie("img",{src:T??z,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:T===null,onLoad:()=>H(T),onError:()=>{T!==null&&X(R=>[...R,T])}})}),C&&Ie("span",{className:`${$.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:C}}),Tt("span",{className:$.text,children:[e.matchedText?yi(aa(e),e.matchedText).map((R,D)=>R.bold?Ie("strong",{className:`${$.match} magicx-aia-option-match`,children:R.text},D):R.text):aa(e),e.parameterLabel&&Tt(Ai,{children:[" ",Ie("span",{className:`${$.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&Ie("span",{className:$.tag,children:e.tag}),_!==null&&Ie("span",{className:`${$.count} magicx-aia-option-count`,children:_})]})})}import{jsx as sa}from"react/jsx-runtime";function Wi(){let[e,o]=la(Ri);return Bi(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(zi),a=()=>o(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function da({options:e,activeIndex:o,picked:t,onSelect:a,onHighlight:i,onUnhighlight:s,listboxId:r,loading:l,groupKey:u="",optionsPosition:w="below",showIcons:k=!0,showImages:m=!0,showCounts:c=!0}){let h=Wi(),v=ra(null),[E,B]=la(null),z=ra(null);na(()=>{if(l&&Hi(z.current,e))return;z.current=l?null:e;let T=v.current,N=T&&!l&&Li(e.length,h),H=T?.closest("[data-aia-dropdown]");N&&H&&Ni(H);let C=N?Oi(T):null;B(C?oa(e.length,h,C.rowWidths,C.gridWidth):null)},[e,h,l]);let L=E??oa(e.length,h,null,null);na(()=>{let T=v.current?.closest("[data-aia-dropdown]");T&&Fi(T)},[L.template,h]);let X=Mi(e,k,m);return sa(ta,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:u,template:L.template,maxHeight:L.maxHeight,innerRef:T=>{v.current=T},"data-aia-group":u,children:e.map((T,N)=>sa(ia,{option:T,isHighlighted:N===o,checked:t?t.includes(T.text):void 0,onSelect:a,onHighlight:()=>i(N),onUnhighlight:s?()=>s(N):void 0,id:`${r}-option-${N}`,loading:l,showIcon:k&&X,showImage:m&&X,showCount:c,scrollHint:!l&&L.scrollHintIndices.includes(N),enterDelayMs:l?0:Di(N,L.cols,e.length,w)},`${u}\0${T.text}`))})}import{formatTime as Gi,TIME_WHEEL_COLUMNS as Ki,TIME_WHEEL_ROW_HEIGHT as qi,timeWheelIndex as ca,timeWheelIndexFromScroll as _i,timeWheelRows as Vi,withTimeWheelIndex as pa}from"@magicx-eng/ai-autocomplete-vanilla";import{Fragment as Ui,useEffect as Yi,useLayoutEffect as Qi,useRef as ft}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) ---
|
|
3347
3359
|
|
|
3348
3360
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
3349
3361
|
time-wheel.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -3465,7 +3477,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
3465
3477
|
.aia-done-llNY5:hover {
|
|
3466
3478
|
background: var(--aia-time-done-bg-hover, var(--aia-done-bg-hover, #d8dde8));
|
|
3467
3479
|
}
|
|
3468
|
-
`,document.head.appendChild(e)}var
|
|
3480
|
+
`,document.head.appendChild(e)}var he={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 Ge,jsxs as Pt}from"react/jsx-runtime";var ji=120;function ha({view:e,label:o,doneLabel:t,interactive:a=!0,onTimeChange:i,onTimeCommit:s}){return Pt("div",{className:he.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":o,onMouseDown:r=>r.preventDefault(),children:[Ge("span",{className:he.value,"data-aia-time-value":"","aria-live":"polite",children:Gi(e.minutes)}),Pt("div",{className:he.columns,"aria-hidden":"true",children:[Ge("div",{className:he.band}),Ki.map(r=>Pt(Ui,{children:[r==="minute"&&Ge("span",{className:he.separator,children:":"}),Ge($i,{column:r,minutes:e.minutes,interactive:a,onTimeChange:i})]},r))]}),Ge("button",{type:"button",tabIndex:-1,className:he.done,"data-aia-time-done":"",onClick:()=>{a&&s()},children:t})]})}function $i({column:e,minutes:o,interactive:t,onTimeChange:a}){let i=ft(null),s=ft(null),r=ft(null),l=ft({minutes:o,interactive:t,onTimeChange:a});l.current={minutes:o,interactive:t,onTimeChange:a};let u=ca(e,o);Qi(()=>{let m=i.current;if(!m||r.current)return;let c=u*qi;Math.abs(m.scrollTop-c)<1||(s.current=c,m.scrollTop=c)},[u]),Yi(()=>()=>{r.current&&clearTimeout(r.current)},[]);let w=()=>{r.current=null;let m=i.current,c=l.current;if(!m||!c.interactive)return;let h=_i(e,m.scrollTop);h!==ca(e,c.minutes)&&c.onTimeChange(pa(e,c.minutes,h))},k=()=>{let m=i.current;if(m){if(s.current!=null&&Math.abs(m.scrollTop-s.current)<1){s.current=null;return}s.current=null,r.current&&clearTimeout(r.current),r.current=setTimeout(w,ji)}};return Ge("div",{ref:i,className:he.column,"data-aia-time-column":e,onScroll:k,children:Vi(e).map((m,c)=>Ge("div",{className:c===u?`${he.row} ${he.selected}`:he.row,"data-aia-time-row":"","data-aia-index":c,onClick:()=>{l.current.interactive&&a(pa(e,l.current.minutes,c))},children:m.label},m.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
3469
3481
|
display: flex;
|
|
3470
3482
|
flex-direction: column;
|
|
3471
3483
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -3480,7 +3492,7 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
3480
3492
|
align-items: end;
|
|
3481
3493
|
}
|
|
3482
3494
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
3483
|
-
`,document.head.appendChild(e)}import{jsx as Zi}from"react/jsx-runtime";function ua({space:e,align:o="stretch",className:t,children:a,...i}){let s=e?{"--aia-stack-space":e}:void 0;return Zi("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:s,...i,children:a})}import{jsx as te,jsxs as It}from"react/jsx-runtime";var go=typeof window>"u"?Ke:Et,fo=[159,119,164],bo=()=>{},ma=()=>{},wo=e=>{},vo=()=>{},xo=e=>{},yo=e=>{},ko=e=>{},Co=e=>{};function So(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=mo(o);if(Ke(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>a(i.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function To(e,o){let t=Qe(null);Ke(()=>{let a=e.current,i=o.current;if(!a||!i)return;let s=co(a,".aia-grid[data-scroll]");if(t.current&&t.current.grid!==s&&(t.current.controller.destroy(),t.current=null),s&&!t.current){t.current={grid:s,controller:Xi({dropdown:a,grid:s,button:i})};return}t.current?.controller.update()}),Ke(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Po(e,o){let t=Qe(o);t.current=o;let a=Qe(null);Et(()=>{let i=e.current;if(i){if(!a.current){a.current=Ji({dropdown:i,isOpen:()=>t.current});return}a.current.update()}}),Ke(()=>()=>{a.current?.destroy(),a.current=null},[])}function At({suggestions:e,activeIndex:o,onSelect:t,onHighlight:a,onUnhighlight:i,isOpen:s,id:r,className:l,pills:u,onPillClick:w,showPills:k=!0,onSkip:
|
|
3495
|
+
`,document.head.appendChild(e)}import{jsx as Zi}from"react/jsx-runtime";function ua({space:e,align:o="stretch",className:t,children:a,...i}){let s=e?{"--aia-stack-space":e}:void 0;return Zi("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:s,...i,children:a})}import{jsx as te,jsxs as It}from"react/jsx-runtime";var go=typeof window>"u"?Ke:Et,fo=[159,119,164],bo=()=>{},ma=()=>{},wo=e=>{},vo=()=>{},xo=e=>{},yo=e=>{},ko=e=>{},Co=e=>{};function So(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=mo(o);if(Ke(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>a(i.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function To(e,o){let t=Qe(null);Ke(()=>{let a=e.current,i=o.current;if(!a||!i)return;let s=co(a,".aia-grid[data-scroll]");if(t.current&&t.current.grid!==s&&(t.current.controller.destroy(),t.current=null),s&&!t.current){t.current={grid:s,controller:Xi({dropdown:a,grid:s,button:i})};return}t.current?.controller.update()}),Ke(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Po(e,o){let t=Qe(o);t.current=o;let a=Qe(null);Et(()=>{let i=e.current;if(i){if(!a.current){a.current=Ji({dropdown:i,isOpen:()=>t.current});return}a.current.update()}}),Ke(()=>()=>{a.current?.destroy(),a.current=null},[])}function At({suggestions:e,activeIndex:o,onSelect:t,onHighlight:a,onUnhighlight:i,isOpen:s,id:r,className:l,pills:u,onPillClick:w,showPills:k=!0,onSkip:m,showSkipButton:c=!0,showOptionIcons:h=!0,showOptionImages:v=!0,showOptionCounts:E=!0,skipDisabled:B=!1,activeSelected:z=!1,isLoading:L=!1,skeletonExiting:X=!1,isInputEmpty:T=!1,language:N,products:H,onProductSelect:C,onProductAddToCart:_,onProductFocusChange:J,productsLayout:V="row",productImageFallback:U="image",formatType:R="options",dateView:D=null,selectedDateIso:me=null,selectedDateRange:le=null,dateRangeStart:ne=null,onPreviousMonth:d,onNextMonth:I,timeView:ke=null,multiSelectView:b=null,onMultiSelectCommit:Ne,onTimeChange:Ee,onTimeCommit:Ae,locationView:Ce=null,isReediting:g=!1,onLocationQuery:S,onLocationMove:P,onLocationCommit:A,onLocationFocusChange:O,isFocused:Y=!1,optionsPosition:ae="below",mode:re}){let ge=So(re),qe=ge!==void 0,W=Qe(null),Re=Qe(null);To(W,Re),Ke(()=>{if(W.current)return eo(W.current)},[]);let Je=e[0]?.options??[],He=!!(u&&u.length>0&&w),fe=!!(H&&H.length>0),et=R==="time"&&ke!=null,Oe=R==="location"&&Ce!=null,ee=s&&(Je.length>0||k&&He||L||fe||et||Oe);Po(W,ee),go(()=>{let y=W.current;y&&(oo(y,io(y)),ho(y))});let de={suggestions:e,activeIndex:o,pills:u,showPills:k,showSkipButton:c,showOptionIcons:h,showOptionImages:v,showOptionCounts:E,skipDisabled:B,activeSelected:z,isLoading:L,skeletonExiting:X,isInputEmpty:T,products:H,formatType:R,dateView:D,selectedDateIso:me,selectedDateRange:le,dateRangeStart:ne,timeView:ke,multiSelectView:b,locationView:Ce,isReediting:g},x=Qe(de);ee&&(x.current=de);let n=ee?de:x.current,Q=uo(N),be=n.suggestions[0],f=be?.options??[],Le=n.activeIndex>=0&&!!f[n.activeIndex]?.is_tappable,Se=so(n.pills??[],Q.keepTyping),ce=!!(Se.length>0&&w),Fe=n.showPills&&ce,tt=n.showPills&&!ce&&n.isLoading,Te=Fe||tt,_e=ce&&no(Se)&&n.showSkipButton&&!n.isInputEmpty&&!!m,pe=Se[0]?.text,we=ro(n.formatType)&&n.dateView!=null,ze=f.length>0&&!we,Be=f.length>0&&we&&!n.isLoading,Ve=n.formatType==="time"&&n.timeView!=null&&!n.isLoading,De=n.formatType==="location"&&n.locationView!=null&&!n.isLoading,Ue=n.isLoading&&!ze&&!Be&&!Ve&&!De,p=n.products??[],F=lo(Fe?Se:[]);return Et(()=>{W.current&&po(W.current,F,{visible:ee,anchorBottom:ae==="above"})},[F,ee,ae,n.suggestions,n.pills,n.isLoading,n.skeletonExiting,n.isInputEmpty,n.products,n.formatType,n.dateView,n.selectedDateIso,n.selectedDateRange,n.dateRangeStart,n.timeView,n.multiSelectView,n.locationView,n.showPills,n.showSkipButton,n.showOptionIcons,n.showOptionImages,n.showOptionCounts,V,N]),Ke(()=>{let y=W.current;return()=>{y&&ao(y)}},[]),It("div",{ref:W,id:r,role:"listbox","aria-multiselectable":!!n.multiSelectView,"data-aia-dropdown":"","data-options-position":ae,"data-mode":ge,"data-aia-loading":n.isLoading?"":void 0,"data-aia-skeleton-exiting":n.skeletonExiting?"":void 0,"data-aia-has-products":p.length>0?"":void 0,className:`${qe?"magicx-aia ":""}${ve.dropdown} ${ee?ve.visible:""} ${l??""}`,onMouseDown:y=>y.preventDefault(),children:[It(ua,{space:"8px",children:[(Te||_e)&&It(nt,{noWrap:!0,className:ve.pillBar,"data-aia-pillbar":"",children:[Te&&te("span",{className:ve.pillScroll,"data-aia-pill-scroll":"",children:te(ht,{pills:Se,activePillIndex:0,activeSelected:n.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:n.isLoading})}),_e&&te("button",{type:"button",tabIndex:-1,className:ve.skip,"data-aia-skip":"",disabled:n.isLoading||n.skipDisabled,"aria-label":pe?`${Q.skipLabel} ${pe}`:Q.skipLabel,onClick:m,children:Q.skip})]}),ze&&te(da,{options:f,activeIndex:n.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:i,listboxId:r,loading:n.isLoading,groupKey:be?`${be.parameter} ${be.text}`:"",optionsPosition:ae,showIcons:n.showOptionIcons,showImages:n.showOptionImages,showCounts:n.showOptionCounts,picked:n.isLoading?void 0:n.multiSelectView?.picked}),n.multiSelectView&&!n.isLoading&&te("div",{"data-aia-multi-actions":"",onClick:y=>{y.target.closest("[data-aia-multi-done]")&&!n.skipDisabled&&Ne?.()},children:te("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:ve.multiDone,ref:y=>{y&&(y.disabled=!0,y.offsetHeight,y.disabled=n.skipDisabled)},children:Q.done})}),Be&&n.dateView&&te(_t,{options:f,activeIndex:n.activeIndex,listboxId:r,view:n.dateView,selection:{selectedIso:n.selectedDateIso??null,selectedRange:n.selectedDateRange??null,rangeStart:n.dateRangeStart??null,floor:to(n.formatType,n.dateRangeStart)},onSelect:t,onHighlight:a,onUnhighlight:i,onPreviousMonth:d??ma,onNextMonth:I??ma}),Ve&&n.timeView&&te(ha,{view:n.timeView,label:Q.timeLabel,doneLabel:Q.done,interactive:!n.skipDisabled,onTimeChange:Ee??wo,onTimeCommit:Ae??vo}),De&&n.locationView&&te(Zt,{view:n.locationView,searchLabel:Q.locationSearch,noResultsLabel:Q.locationNoResults,useTypedLabel:Q.locationUseTyped,widgetFocused:Y&&ee,reediting:n.isReediting,visible:ee,interactive:!n.skipDisabled,onQuery:S??xo,onMove:P??yo,onCommit:A??ko,onFocusChange:O??Co}),Ue&&te("div",{className:ve.skeletonBars,"data-aia-skeleton-bars":"",children:fo.map(y=>te("span",{className:ve.skeletonBar,style:{width:y}},`bar-${y}`))}),te(ea,{products:p,listboxId:r,onSelect:C??bo,onAddToCart:_,onFocusChange:J,focusable:ee,layout:V,imageFallback:U,strings:Q}),te(Ut,{isOptionHighlighted:Le,isInputEmpty:n.isInputEmpty,strings:Q})]}),te("button",{ref:Re,type:"button",tabIndex:-1,className:ve.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Q.scrollArrow,"aria-hidden":"true",children:te("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:te("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as _o,ModeController as Vo,setCursorOffset as Uo,uiStringsFor as Yo,watchEditorHeight as Qo}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as Io}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 {
|
|
3484
3496
|
flex-shrink: 0;
|
|
3485
3497
|
width: 32px;
|
|
3486
3498
|
height: 32px;
|
|
@@ -3551,5 +3563,5 @@ import{buildSubmitResult as es,cellDay as ts,cellIso as as,DATE_RANGE_META_END a
|
|
|
3551
3563
|
transition: none;
|
|
3552
3564
|
}
|
|
3553
3565
|
}
|
|
3554
|
-
`,document.head.appendChild(e)}var ga={submitButton:"aia-submitButton-otz7H"};import{jsx as Rt}from"react/jsx-runtime";function fa({disabled:e,ready:o,onClick:t,label:a=Io().submit}){return Rt("button",{type:"button","data-aia-submit":"",className:ga.submitButton,disabled:e,"data-aia-ready":o?"":void 0,onClick:i=>{i.stopPropagation(),t()},"aria-label":a,children:Rt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":a,children:Rt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Eo,dateSelectionFor as Ao,identifiedParamLabel as Ro,withoutTraditionalAutocomplete as Oo}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as ya,useEffect as je,useRef as X,useState as Lo}from"react";import{useRef as ba}from"react";function wa(e){let o=ba(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=ba({key:"",overrides:void 0});if(a.current.key!==t){let i={};for(let s of Object.keys(e??{})){let r=(l,u,w)=>{let k=o.current?.[s];return k?k(l,u,w):[]};i[s]=r}a.current={key:t,overrides:e?i:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as va}from"react";function xa(e){let o=va(e);o.current=e;let t=va(null);t.current===null&&(t.current={fetch:(i,s)=>{let r=o.current;return r?r.fetch(i,s):Promise.reject(new Error("products config removed"))},transform:i=>o.current?.transform(i)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var ka={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:"",leadInText:"",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 Ot({onSubmit:e,onResult:o,onError:t,optionOverrides:a,maskCompletedText:i,apiConfig:s,additionalContext:r,language:l,currency:u,productId:w,visitorId:k,columns:g=2,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:v,prependPlaceholder:A,showNonTappableOptions:F,locationSearch:D,showOptionIcons:z,showOptionImages:U,showOptionCounts:I,showSkipButton:L,showProducts:S,productImageFallback:N="image",onFocus:Y,onBlur:J,value:_,completedParams:V,onChange:T,onParamsChange:B,products:he,mapProducts:se,onProductSelect:ne,onProductAddToCart:d,source:E,setCursor:ye}){let f=X(null),[Ne,Ie]=Lo(null),Ee=X(e);Ee.current=e;let b=X(o);b.current=o;let C=X(t);C.current=t;let P=X(T);P.current=T;let R=X(B);R.current=B;let O=X(Y);O.current=Y;let Q=X(J);Q.current=J;let ue=X(ye);ue.current=ye;let ae=X(ne);ae.current=ne;let me=X(d);me.current=d;let Ae=X(k);Ae.current=k;let qe=X(()=>{let p=Ae.current;return typeof p=="function"?p():p}).current,W=xa(he),Re=X(se);Re.current=se;let Je=X((p,H)=>{let y=Re.current;return y?y(p,H):p}).current,He=se?Je:void 0,ke=wa(a);je(()=>{if(typeof document>"u")return;let p=new Eo(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:u,productId:w,visitorId:qe,optionOverrides:ke.overrides,maskCompletedText:i,columns:g,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:v,prependPlaceholder:A,showNonTappableOptions:F,locationSearch:D,showProducts:S,source:E,value:_,completedParams:V,onSubmit:(...y)=>Ee.current?.(...y),onResult:(...y)=>b.current?.(...y),onError:(...y)=>C.current?.(...y),onChange:(...y)=>P.current?.(...y),onParamsChange:(...y)=>R.current?.(...y),onFocus:()=>O.current?.(),onBlur:()=>Q.current?.(),onProductSelect:y=>ae.current?.(y),onProductAddToCart:y=>me.current?.(y),setCursor:y=>ue.current?.(y),products:W.config,mapProducts:He});f.current=p,Ie(p.getState());let H=p.subscribe(y=>Ie(y));return()=>{H(),p.destroy(),f.current===p&&(f.current=null)}},[]),je(()=>{_!==void 0&&f.current?.setValue(_)},[_]),je(()=>{V!==void 0&&f.current?.setCompletedParams(V)},[V]);let et=JSON.stringify(s??null),Oe;try{Oe=JSON.stringify(r??null)}catch{Oe="[unstringifiable]"}je(()=>{f.current?.update({apiConfig:s,additionalContext:r,language:l,currency:u,productId:w,optionOverrides:ke.overrides,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:v,prependPlaceholder:A,showNonTappableOptions:F,locationSearch:D,showProducts:S})},[et,Oe,l,u?.code,u?.rate,u?.country,w,ke.key,c,h,v,A,F,D,S]);let ee=X(!1);je(()=>{if(!ee.current){ee.current=!0;return}f.current?.update({products:W.config})},[W.enabled]),je(()=>{f.current?.update({mapProducts:He})},[He]);let le=X(null);le.current===null&&(le.current={handleTextChange:p=>f.current?.handleTextChange(p),handleKeyDown:p=>{let H="nativeEvent"in p?p.nativeEvent:p;f.current?.handleKeyDown(H)},setFocused:p=>f.current?.setFocused(p),startEditingParam:p=>f.current?.startEditingParam(p),exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:p=>f.current?.handleCaretAfterInput(p),handleCaretMove:p=>f.current?.handleCaretMove(p),replaceEditingRange:p=>f.current?.replaceEditingRange(p)??!1,setActivePill:p=>f.current?.setActivePill(p),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()??ka,recordSubmit:p=>f.current?.recordSubmit(p),selectOption:(p,H)=>f.current?.selectOption(p,H),selectProduct:p=>f.current?.selectProduct(p),addProductToCart:p=>{let H=f.current;return!H||!me.current?Promise.resolve():H.addProductToCart(p)},setActiveDropdownIndex:p=>f.current?.setActiveDropdownIndex(p),clearHighlight:p=>f.current?.clearHighlight(p),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),setTime:p=>f.current?.setTime(p),commitTime:()=>f.current?.commitTime(),toggleMultiSelectOption:p=>f.current?.toggleMultiSelectOption(p),commitMultiSelect:()=>f.current?.commitMultiSelect(),setLocationQuery:p=>f.current?.setLocationQuery(p),moveLocationHighlight:p=>f.current?.moveLocationHighlight(p),commitLocation:p=>f.current?.commitLocation(p),setLocationFieldFocused:p=>f.current?.setLocationFieldFocused(p),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let x=le.current,n=ya(p=>{let H=p.target.value,lt=H.length>0&&!p.nativeEvent?.isComposing&&H[0]!==H[0].toUpperCase()?H[0].toUpperCase()+H.slice(1):H;f.current?.handleTextChange(lt)},[]),j=ya(p=>{f.current?.handleKeyDown(p.nativeEvent)},[]),ge=f.current,m=Ne??ka,Le=_!==void 0?_:m.text,Ce=V!==void 0?V:m.completedParams,fe=m.actionableSuggestions,Fe=fe[0],tt=Oo(fe),Se=ge?.listboxId??"",_e=m.activeDropdownIndex>=0&&ge?`${Se}-option-${m.activeDropdownIndex}`:void 0,de=m.editingParam,be=m.editingIdentified,ze=de?{parameter:de.suggestionParameter,text:de.suggestionPlaceholder,required:!0,options:de.options}:be?{parameter:be.parameter,text:Ro(be.parameter),required:!0,options:[]}:null,Be=m.dropdownSuggestion??ze??Fe,Ve=ze?[ze]:fe,De=Ao(m),Ue=!ge||m.dropdownLoading;return{completedParams:Ce,multiSelectView:m.multiSelectView,toggleMultiSelectOption:x.toggleMultiSelectOption,commitMultiSelect:x.commitMultiSelect,skippedParams:m.skippedParams,identifiedParams:m.identifiedParams,suggestionPills:tt,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:m.segments,newParamId:m.newParamId,clearNewParamId:x.clearNewParamId,suggestions:m.suggestions,activeIndex:m.activeDropdownIndex,isReady:m.isReady,isLoading:Ue,isFocused:m.isFocused,isDropdownOpen:m.isDropdownOpen,isActivePillSelected:m.isActivePillSelected,placeholderText:m.placeholderText,listboxId:Se,error:m.error,products:m.products,customFields:m.customFields,selectProduct:x.selectProduct,addProductToCart:x.addProductToCart,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:de,editingIdentified:be,editingAnchor:m.editingAnchor,caretOffset:m.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Le,placeholder:m.placeholderText||void 0,onChange:n,onKeyDown:j,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":m.isDropdownOpen,"aria-activedescendant":_e,"aria-autocomplete":"list","aria-controls":Se},reset:x.reset,refreshProducts:x.refreshProducts,prepareSubmit:x.prepareSubmit,getState:x.getState,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:Be?[{...Be,options:m.dropdownOptions}]:[],activeIndex:m.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:m.isDropdownOpen,id:Se,pills:Ve,activeSelected:m.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(L??!0)&&!de&&!be,showOptionIcons:z??!0,showOptionImages:U??!0,showOptionCounts:I??!0,skipDisabled:m.inSelectionAnimation,isLoading:Ue,skeletonExiting:m.skeletonExiting,isInputEmpty:Le.trim().length===0,language:l,products:m.products,productImageFallback:N,onProductSelect:x.selectProduct,onProductAddToCart:d?x.addProductToCart:void 0,onProductFocusChange:x.setFocused,formatType:m.activeFormatType,dateView:m.dateView,selectedDateIso:De.selectedIso,selectedDateRange:De.selectedRange,dateRangeStart:De.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,timeView:m.timeView,multiSelectView:m.multiSelectView,onMultiSelectCommit:x.commitMultiSelect,onTimeChange:x.setTime,onTimeCommit:x.commitTime,locationView:m.locationView,isReediting:m.editingParam!=null,onLocationQuery:x.setLocationQuery,onLocationMove:x.moveLocationHighlight,onLocationCommit:x.commitLocation,onLocationFocusChange:x.setLocationFieldFocused,isFocused:m.isFocused||m.locationFieldFocused,optionsPosition:h??"below"}}}import{chipIdFromTap as zo,extractPlainText as Ca,getCursorOffset as Sa,keepCaretOnChip as Do,plainTextLength as Mo,renderEditableContent as No,setCursorOffset as Ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as pe,useEffect as ft,useLayoutEffect as Lt,useRef as $e}from"react";var bt;function Ho(){if(bt!==void 0)return bt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),bt=e.contentEditable==="plaintext-only",bt}function Pa(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,newParamId:i,editingParam:s,editingIdentified:r,editingAnchor:l,caretOffset:u,placeholderText:w,isFocused:k,isDropdownOpen:g,listboxId:c,activeDescendantId:h,autoFocus:v,handleTextChange:A,handleKeyDown:F,handleCaretAfterInput:D,handleCaretMove:z,startEditingParam:U,replaceEditingRange:I,setFocused:L}=e,S=$e(null),N=$e(!1),Y=$e(""),J=$e(""),_=$e(null),V=$e(0);_.current=u,ft(()=>{if(!v)return;let b=S.current;if(!b)return;document.activeElement===b?L(!0):b.focus();let C=b.ownerDocument??document,P=C.getSelection(),R=P&&P.rangeCount>0&&b.contains(P.anchorNode);if(P&&!R){let O=C.createRange();O.selectNodeContents(b),O.collapse(!0),P.removeAllRanges(),P.addRange(O)}},[v,L]),ft(()=>{let b=S.current;if(!b)return;let C=b.ownerDocument??document,P=()=>{let R=C.getSelection();if(!R||R.rangeCount===0||!R.anchorNode||!b.contains(R.anchorNode))return;let O=R.anchorNode,Q=O.nodeType===Node.ELEMENT_NODE?O:O.parentElement,ae=(R.isCollapsed?Q?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,me=s?.id??r?.id??null;if(ae&&ae!==me){U(ae);return}performance.now()-V.current<50||z(Sa(b))};return C.addEventListener("selectionchange",P),()=>C.removeEventListener("selectionchange",P)},[s,r,U,z]),ft(()=>{let b=S.current;if(!b)return;let C=P=>{let R=zo(b,P.target);R&&(U(R),Do(b,R))};return b.addEventListener("click",C),()=>b.removeEventListener("click",C)},[U]),Lt(()=>{let b=S.current;b&&No({input:b,segments:o,newParamId:i,editingParamId:s?.id??null,placeholderText:w??"",isFocused:k,showChipIcons:t,showChipImages:a})},[o,i,s,w,k,t,a]),Lt(()=>{let b=Y.current,C=i??"";if(Y.current=C,!C||C===b)return;let P=S.current;if(!P)return;P.focus();let R=_.current??Mo(P);Ta(P,R)},[i]),Lt(()=>{let b=J.current,C=s?.id??"";if(J.current=C,!C||C===b||l==null)return;let P=S.current;P&&Ta(P,l)},[s,l]);let T=pe(()=>{if(N.current)return;let b=S.current;if(!b)return;let C=Ca(b),R=C.length>0&&C[0]!==C[0].toUpperCase()?C[0].toUpperCase()+C.slice(1):C;A(R)},[A]),B=pe(()=>{V.current=performance.now(),T();let b=S.current;b&&D(Sa(b))},[T,D]);ft(()=>{let b=S.current;if(!b)return;let C=P=>{let R=P,O=R.inputType;if(O==="insertParagraph"||O==="insertLineBreak"||O==="insertFromDrop"){P.preventDefault();return}if(O.startsWith("insert")||O.startsWith("delete")){let Q=O.startsWith("delete")?"":R.data??"";I(Q)&&P.preventDefault()}};return b.addEventListener("beforeinput",C),()=>b.removeEventListener("beforeinput",C)},[I]);let he=pe(()=>{N.current=!0,S.current?.setAttribute("data-aia-composing","true")},[]),se=pe(()=>{N.current=!1,S.current?.removeAttribute("data-aia-composing"),T()},[T]),ne=pe(b=>{b.preventDefault();let C=S.current;if(!C)return;let P=(b.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!P)return;let R=C.ownerDocument??document,O=R.getSelection();if(!O||O.rangeCount===0)return;let Q=O.getRangeAt(0);if(!C.contains(Q.startContainer))return;Q.deleteContents();let ue=R.createTextNode(P);Q.insertNode(ue),Q.setStartAfter(ue),Q.collapse(!0),O.removeAllRanges(),O.addRange(Q),T()},[T]),d=pe(b=>F(b),[F]),E=pe(()=>L(!0),[L]),ye=pe(()=>L(!1),[L]),f=pe(()=>S.current?.focus(),[]),Ne=pe(()=>S.current?.blur(),[]),Ie=pe(()=>{let b=S.current;return b?Ca(b):""},[]),Ee=Ho()?"plaintext-only":"true";return{inputRef:S,editorProps:{ref:S,contentEditable:Ee,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":c,"aria-expanded":g,"aria-activedescendant":h,spellCheck:!0,enterKeyHint:"send",onInput:B,onKeyDown:d,onCompositionStart:he,onCompositionEnd:se,onPaste:ne,onFocus:E,onBlur:ye},getPlainText:Ie,focus:f,blur:Ne}}import{jsx as Xe,jsxs as Mt}from"react/jsx-runtime";function Uo(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Yo=Fo(function({onSubmit:o,onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,className:r,apiConfig:l,additionalContext:u,language:w,currency:k,productId:g,visitorId:c,columns:h,pillPlacement:v="dropdown",mode:A="auto",optionsPosition:F="below",animations:D=!0,optionsStyle:z="floating",dropdownTrigger:U,closeDropdownOnBlur:I,prependPlaceholder:L,showNonTappableOptions:S,locationSearch:N,showOptionIcons:Y=!0,showChipIcons:J=!0,showChipImages:_=!0,showOptionImages:V=!0,showOptionCounts:T=!0,showSkipButton:B,showProducts:he,productsLayout:se,productImageFallback:ne,autoFocus:d=!0,onFocus:E,onBlur:ye,value:f,completedParams:Ne,onChange:Ie,onParamsChange:Ee,products:b,mapProducts:C,onProductSelect:P,onProductAddToCart:R,submitButton:O,resetOnSubmit:Q=!0},ue){let ae=Ze(null),me=Ze(null),Ae=Ze(null),qe=Ze(()=>{}),W=Ze(null),Re=Ze(null);Dt(()=>{let M=ae.current;if(M)return W.current?W.current.setMode(A):W.current=new Ko(M,A),()=>{W.current?.destroy(),W.current=null}},[A]);let Je=zt(M=>{let ie=Re.current?.current;ie&&(ie.focus(),qo(ie,M))},[]),{completedParams:He,suggestionPills:ke,setActivePill:et,skipActivePill:Oe,segments:ee,newParamId:le,clearNewParamId:x,placeholderText:n,isFocused:j,isDropdownOpen:ge,isActivePillSelected:m,isLoading:Le,isReady:Ce,activeIndex:fe,listboxId:Fe,handleTextChange:tt,handleKeyDown:Se,setFocused:_e,editingParam:de,editingIdentified:be,editingAnchor:ze,caretOffset:Be,startEditingParam:Ve,handleCaretAfterInput:De,handleCaretMove:Ue,replaceEditingRange:p,dropdownProps:H,reset:y,refreshProducts:lt,prepareSubmit:Nt,getState:Ht,recordSubmit:Ft}=Ot({onSubmit:M=>qe.current(M),onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,apiConfig:l,additionalContext:u,language:w,currency:k,productId:g,visitorId:c,columns:h,dropdownTrigger:U,optionsPosition:F,closeDropdownOnBlur:I,prependPlaceholder:L,showNonTappableOptions:S,locationSearch:N,showOptionIcons:Y,showOptionImages:V,showOptionCounts:T,showSkipButton:B,showProducts:he,onFocus:E,onBlur:ye,value:f,completedParams:Ne,onChange:Ie,onParamsChange:Ee,products:b,mapProducts:C,onProductSelect:P,onProductAddToCart:R,source:"full-sdk",setCursor:Je});Dt(()=>{if(!le)return;let M=window.setTimeout(()=>x(),650);return()=>window.clearTimeout(M)},[le,x]);let Ia=fe>=0?`${Fe}-option-${fe}`:void 0,{inputRef:wt,editorProps:Ea,focus:dt,blur:Bt,getPlainText:Wt}=Pa({segments:ee,newParamId:le,editingParam:de,editingIdentified:be,editingAnchor:ze,caretOffset:Be,placeholderText:n,isFocused:j,showChipIcons:J,showChipImages:_,isDropdownOpen:ge,listboxId:Fe,activeDescendantId:Ia,autoFocus:d,handleTextChange:tt,handleKeyDown:Se,handleCaretAfterInput:De,handleCaretMove:Ue,startEditingParam:Ve,replaceEditingRange:p,setFocused:_e});Re.current=wt,Wo(()=>{let M=me.current,ie=wt.current;if(!M||!ie)return;let it=()=>{let Kt=M.firstElementChild;if(!Kt)return;let La=Kt.getBoundingClientRect(),za=ie.getBoundingClientRect();La.top>=za.bottom-2?M.setAttribute("data-aia-pill-wrapped",""):M.removeAttribute("data-aia-pill-wrapped")};it();let Gt=new ResizeObserver(it);return Gt.observe(ie),()=>Gt.disconnect()},[ee,ke.length,Le,wt]),Dt(()=>{let M=Ae.current;if(M)return Vo(M)},[]),Bo(ue,()=>({focus:dt,blur:Bt,reset:y,refreshProducts:lt,setMode:M=>W.current?.setMode(M),skipActivePill:Oe}),[dt,Bt,y,lt,Oe]);let at=!!ee.length||He.length>0,vt=zt(M=>{if(!at)return;M&&Nt();let ie=Ht(),it=Go(Wt(),ie.completedParams,ie.skippedParams,{identifiedParams:ie.identifiedParams,isReady:ie.isReady,customFields:ie.customFields});M&&Ft(it),o(it),Q&&y()},[Ft,Q,at,Nt,Ht,o,y,Wt]);qe.current=()=>vt(!1);let Aa=zt(M=>{M.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||dt()},[dt]),Ra=v==="inline",Oa=v==="dropdown";return Mt("div",{ref:ae,className:`magicx-aia ${We.container} ${r??""}`,"data-pill-placement":v,"data-options-position":F,"data-animations":D?"on":"off","data-aia-options-style":z,"data-mode":Uo(A),children:[Xe(At,{...H,showPills:Oa,productsLayout:se,productImageFallback:ne}),Mt("div",{className:We.inputWrapper,"data-aia-input-wrapper":"",onClick:Aa,children:[Mt("div",{ref:Ae,className:We.editorArea,"data-aia-editor":"",children:[Xe("div",{...Ea,className:We.input,"data-aia-input":""}),Ra&&(Le||ke.length>0)&&Xe("span",{ref:me,className:We.pillListContainer,"data-aia-pill-list-container":"",children:Xe(pt,{pills:ke,activePillIndex:0,activeSelected:m,onSelectPill:et,loading:Le})})]}),O===null?null:O===void 0?Xe(fa,{disabled:!at,ready:at&&Ce,onClick:()=>vt(!0),label:_o(w).submit}):Xe("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:We.submitSlot,onClick:M=>{at&&(M.stopPropagation(),vt(!0))},children:O})]})]})});export{Yo as AIAutocomplete,At as AIAutocompleteDropdown,is as DATE_RANGE_META_END,os as DATE_RANGE_META_START,ns as DEFAULT_OPTION_COUNT_UNIT,us as LOCATION_META_KEY,ys as PRODUCT_PATH_PREFIX,Os as TIME_META_KEY,zs as WEEKDAY_LABELS,es as buildSubmitResult,ts as cellDay,as as cellIso,rs as dateCellMarks,ss as formatDate,ls as formatDateRange,ds as formatOptionCount,cs as formatPlace,ps as formatTime,hs as isoDate,ms as monthLabel,gs as optionCountLabel,fs as optionHasImage,bs as optionImageSources,ws as optionImageSrc,vs as optionLabel,xs as optionsShowLeadingVisuals,ks as parseDate,Cs as parseLooseDate,Ss as parseLooseDateRange,Ts as parseTime,Ps as productFromMatchedItem,Is as productImageSources,Es as productsFromCustomFields,As as sanitizeOptionIconSvg,Rs as selectedRangeFor,Ot as useAIAutocomplete,Ls as visibleDateRange,Ds as withSkippedParams};
|
|
3566
|
+
`,document.head.appendChild(e)}var ga={submitButton:"aia-submitButton-otz7H"};import{jsx as Rt}from"react/jsx-runtime";function fa({disabled:e,ready:o,onClick:t,label:a=Io().submit}){return Rt("button",{type:"button","data-aia-submit":"",className:ga.submitButton,disabled:e,"data-aia-ready":o?"":void 0,onClick:i=>{i.stopPropagation(),t()},"aria-label":a,children:Rt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":a,children:Rt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Eo,dateSelectionFor as Ao,identifiedParamLabel as Ro,withoutTraditionalAutocomplete as Oo}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as ya,useEffect as je,useMemo as Lo,useRef as Z,useState as zo}from"react";import{useRef as ba}from"react";function wa(e){let o=ba(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=ba({key:"",overrides:void 0});if(a.current.key!==t){let i={};for(let s of Object.keys(e??{})){let r=(l,u,w)=>{let k=o.current?.[s];return k?k(l,u,w):[]};i[s]=r}a.current={key:t,overrides:e?i:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as va}from"react";function xa(e){let o=va(e);o.current=e;let t=va(null);t.current===null&&(t.current={fetch:(i,s)=>{let r=o.current;return r?r.fetch(i,s):Promise.reject(new Error("products config removed"))},transform:i=>o.current?.transform(i)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var ka={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:"",leadInText:"",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 Ot({onSubmit:e,onResult:o,onError:t,optionOverrides:a,maskCompletedText:i,apiConfig:s,additionalContext:r,language:l,currency:u,productId:w,visitorId:k,columns:m=2,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:v,prependPlaceholder:E,showNonTappableOptions:B,locationSearch:z,showOptionIcons:L,showOptionImages:X,showOptionCounts:T,showSkipButton:N,showProducts:H,productImageFallback:C="image",onFocus:_,onBlur:J,value:V,completedParams:U,onChange:R,onParamsChange:D,products:me,mapProducts:le,onProductSelect:ne,onProductAddToCart:d,source:I,setCursor:ke}){let b=Z(null),[Ne,Ee]=zo(null),Ae=Z(e);Ae.current=e;let Ce=Z(o);Ce.current=o;let g=Z(t);g.current=t;let S=Z(R);S.current=R;let P=Z(D);P.current=D;let A=Z(_);A.current=_;let O=Z(J);O.current=J;let Y=Z(ke);Y.current=ke;let ae=Z(ne);ae.current=ne;let re=Z(d);re.current=d;let ge=Z(k);ge.current=k;let qe=Z(()=>{let p=ge.current;return typeof p=="function"?p():p}).current,W=xa(me),Re=Z(le);Re.current=le;let Je=Z((p,F)=>{let y=Re.current;return y?y(p,F):p}).current,He=le?Je:void 0,fe=wa(a);je(()=>{if(typeof document>"u")return;let p=new Eo(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:u,productId:w,visitorId:qe,optionOverrides:fe.overrides,maskCompletedText:i,columns:m,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:v,prependPlaceholder:E,showNonTappableOptions:B,locationSearch:z,showProducts:H,source:I,value:V,completedParams:U,onSubmit:(...y)=>Ae.current?.(...y),onResult:(...y)=>Ce.current?.(...y),onError:(...y)=>g.current?.(...y),onChange:(...y)=>S.current?.(...y),onParamsChange:(...y)=>P.current?.(...y),onFocus:()=>A.current?.(),onBlur:()=>O.current?.(),onProductSelect:y=>ae.current?.(y),onProductAddToCart:y=>re.current?.(y),setCursor:y=>Y.current?.(y),products:W.config,mapProducts:He});b.current=p,Ee(p.getState());let F=p.subscribe(y=>Ee(y));return()=>{F(),p.destroy(),b.current===p&&(b.current=null)}},[]),je(()=>{V!==void 0&&b.current?.setValue(V)},[V]),je(()=>{U!==void 0&&b.current?.setCompletedParams(U)},[U]);let et=JSON.stringify(s??null),Oe;try{Oe=JSON.stringify(r??null)}catch{Oe="[unstringifiable]"}je(()=>{b.current?.update({apiConfig:s,additionalContext:r,language:l,currency:u,productId:w,optionOverrides:fe.overrides,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:v,prependPlaceholder:E,showNonTappableOptions:B,locationSearch:z,showProducts:H})},[et,Oe,l,u?.code,u?.rate,u?.country,w,fe.key,c,h,v,E,B,z,H]);let ee=Z(!1);je(()=>{if(!ee.current){ee.current=!0;return}b.current?.update({products:W.config})},[W.enabled]),je(()=>{b.current?.update({mapProducts:He})},[He]);let de=Z(null);de.current===null&&(de.current={handleTextChange:p=>b.current?.handleTextChange(p),handleKeyDown:p=>{let F="nativeEvent"in p?p.nativeEvent:p;b.current?.handleKeyDown(F)},setFocused:p=>b.current?.setFocused(p),startEditingParam:p=>b.current?.startEditingParam(p),exitEditMode:()=>b.current?.exitEditMode(),handleCaretAfterInput:p=>b.current?.handleCaretAfterInput(p),handleCaretMove:p=>b.current?.handleCaretMove(p),replaceEditingRange:p=>b.current?.replaceEditingRange(p)??!1,setActivePill:p=>b.current?.setActivePill(p),skipActivePill:()=>b.current?.skipActivePill(),removeLastParam:()=>b.current?.removeLastParam(),clearNewParamId:()=>b.current?.clearNewParamId(),reset:()=>b.current?.reset(),refreshProducts:()=>b.current?.refreshProducts(),prepareSubmit:()=>b.current?.prepareSubmit(),getState:()=>b.current?.getState()??ka,recordSubmit:p=>b.current?.recordSubmit(p),selectOption:(p,F)=>b.current?.selectOption(p,F),selectProduct:p=>b.current?.selectProduct(p),addProductToCart:p=>{let F=b.current;return!F||!re.current?Promise.resolve():F.addProductToCart(p)},setActiveDropdownIndex:p=>b.current?.setActiveDropdownIndex(p),clearHighlight:p=>b.current?.clearHighlight(p),showPreviousMonth:()=>b.current?.showPreviousMonth(),showNextMonth:()=>b.current?.showNextMonth(),setTime:p=>b.current?.setTime(p),commitTime:()=>b.current?.commitTime(),toggleMultiSelectOption:p=>b.current?.toggleMultiSelectOption(p),commitMultiSelect:()=>b.current?.commitMultiSelect(),setLocationQuery:p=>b.current?.setLocationQuery(p),moveLocationHighlight:p=>b.current?.moveLocationHighlight(p),commitLocation:p=>b.current?.commitLocation(p),setLocationFieldFocused:p=>b.current?.setLocationFieldFocused(p),handleFocus:()=>b.current?.setFocused(!0),handleBlur:()=>b.current?.setFocused(!1)});let x=de.current,n=ya(p=>{let F=p.target.value,dt=F.length>0&&!p.nativeEvent?.isComposing&&F[0]!==F[0].toUpperCase()?F[0].toUpperCase()+F.slice(1):F;b.current?.handleTextChange(dt)},[]),Q=ya(p=>{b.current?.handleKeyDown(p.nativeEvent)},[]),be=b.current,f=Ne??ka,Le=V!==void 0?V:f.text,Se=U!==void 0?U:f.completedParams,ce=f.actionableSuggestions,Fe=ce[0],tt=Lo(()=>Oo(ce),[ce]),Te=be?.listboxId??"",_e=f.activeDropdownIndex>=0&&be?`${Te}-option-${f.activeDropdownIndex}`:void 0,pe=f.editingParam,we=f.editingIdentified,ze=pe?{parameter:pe.suggestionParameter,text:pe.suggestionPlaceholder,required:!0,options:pe.options}:we?{parameter:we.parameter,text:Ro(we.parameter),required:!0,options:[]}:null,Be=f.dropdownSuggestion??ze??Fe,Ve=ze?[ze]:ce,De=Ao(f),Ue=!be||f.dropdownLoading;return{completedParams:Se,multiSelectView:f.multiSelectView,toggleMultiSelectOption:x.toggleMultiSelectOption,commitMultiSelect:x.commitMultiSelect,skippedParams:f.skippedParams,identifiedParams:f.identifiedParams,suggestionPills:tt,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:f.segments,newParamId:f.newParamId,clearNewParamId:x.clearNewParamId,suggestions:f.suggestions,activeIndex:f.activeDropdownIndex,isReady:f.isReady,isLoading:Ue,isFocused:f.isFocused,isDropdownOpen:f.isDropdownOpen,isActivePillSelected:f.isActivePillSelected,placeholderText:f.placeholderText,listboxId:Te,error:f.error,products:f.products,customFields:f.customFields,selectProduct:x.selectProduct,addProductToCart:x.addProductToCart,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:pe,editingIdentified:we,editingAnchor:f.editingAnchor,caretOffset:f.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Le,placeholder:f.placeholderText||void 0,onChange:n,onKeyDown:Q,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":f.isDropdownOpen,"aria-activedescendant":_e,"aria-autocomplete":"list","aria-controls":Te},reset:x.reset,refreshProducts:x.refreshProducts,prepareSubmit:x.prepareSubmit,getState:x.getState,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:Be?[{...Be,options:f.dropdownOptions}]:[],activeIndex:f.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:f.isDropdownOpen,id:Te,pills:Ve,activeSelected:f.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(N??!0)&&!pe&&!we,showOptionIcons:L??!0,showOptionImages:X??!0,showOptionCounts:T??!0,skipDisabled:f.inSelectionAnimation,isLoading:Ue,skeletonExiting:f.skeletonExiting,isInputEmpty:Le.trim().length===0,language:l,products:f.products,productImageFallback:C,onProductSelect:x.selectProduct,onProductAddToCart:d?x.addProductToCart:void 0,onProductFocusChange:x.setFocused,formatType:f.activeFormatType,dateView:f.dateView,selectedDateIso:De.selectedIso,selectedDateRange:De.selectedRange,dateRangeStart:De.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,timeView:f.timeView,multiSelectView:f.multiSelectView,onMultiSelectCommit:x.commitMultiSelect,onTimeChange:x.setTime,onTimeCommit:x.commitTime,locationView:f.locationView,isReediting:f.editingParam!=null,onLocationQuery:x.setLocationQuery,onLocationMove:x.moveLocationHighlight,onLocationCommit:x.commitLocation,onLocationFocusChange:x.setLocationFieldFocused,isFocused:f.isFocused||f.locationFieldFocused,optionsPosition:h??"below"}}}import{cancelStartingHint as Do,chipIdFromTap as Mo,extractPlainText as Ca,getCursorOffset as Sa,keepCaretOnChip as No,plainTextLength as Ho,renderEditableContent as Fo,setCursorOffset as Ta,startingHintOptions as Bo}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as ue,useEffect as lt,useLayoutEffect as Lt,useRef as $e}from"react";var bt;function Wo(){if(bt!==void 0)return bt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),bt=e.contentEditable==="plaintext-only",bt}function Pa(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,newParamId:i,editingParam:s,editingIdentified:r,editingAnchor:l,caretOffset:u,placeholderText:w,hintSuggestions:k,isFocused:m,isDropdownOpen:c,listboxId:h,activeDescendantId:v,autoFocus:E,handleTextChange:B,handleKeyDown:z,handleCaretAfterInput:L,handleCaretMove:X,startEditingParam:T,replaceEditingRange:N,setFocused:H}=e,C=$e(null),_=$e(!1),J=$e(""),V=$e(""),U=$e(null),R=$e(0);U.current=u,lt(()=>{if(!E)return;let g=C.current;if(!g)return;document.activeElement===g?H(!0):g.focus();let S=g.ownerDocument??document,P=S.getSelection(),A=P&&P.rangeCount>0&&g.contains(P.anchorNode);if(P&&!A){let O=S.createRange();O.selectNodeContents(g),O.collapse(!0),P.removeAllRanges(),P.addRange(O)}},[E,H]),lt(()=>{let g=C.current;if(!g)return;let S=g.ownerDocument??document,P=()=>{let A=S.getSelection();if(!A||A.rangeCount===0||!A.anchorNode||!g.contains(A.anchorNode))return;let O=A.anchorNode,Y=O.nodeType===Node.ELEMENT_NODE?O:O.parentElement,re=(A.isCollapsed?Y?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ge=s?.id??r?.id??null;if(re&&re!==ge){T(re);return}performance.now()-R.current<50||X(Sa(g))};return S.addEventListener("selectionchange",P),()=>S.removeEventListener("selectionchange",P)},[s,r,T,X]),lt(()=>{let g=C.current;if(!g)return;let S=P=>{let A=Mo(g,P.target);A&&(T(A),No(g,A))};return g.addEventListener("click",S),()=>g.removeEventListener("click",S)},[T]),Lt(()=>{let g=C.current;g&&Fo({input:g,segments:o,newParamId:i,editingParamId:s?.id??null,placeholderText:w??"",isFocused:m,showChipIcons:t,showChipImages:a,hintOptions:Bo(k??[])})},[o,i,s,w,k,m,t,a]),lt(()=>{let g=C.current;return()=>{g&&Do(g)}},[]),Lt(()=>{let g=J.current,S=i??"";if(J.current=S,!S||S===g)return;let P=C.current;if(!P)return;P.focus();let A=U.current??Ho(P);Ta(P,A)},[i]),Lt(()=>{let g=V.current,S=s?.id??"";if(V.current=S,!S||S===g||l==null)return;let P=C.current;P&&Ta(P,l)},[s,l]);let D=ue(()=>{if(_.current)return;let g=C.current;if(!g)return;let S=Ca(g),A=S.length>0&&S[0]!==S[0].toUpperCase()?S[0].toUpperCase()+S.slice(1):S;B(A)},[B]),me=ue(()=>{R.current=performance.now(),D();let g=C.current;g&&L(Sa(g))},[D,L]);lt(()=>{let g=C.current;if(!g)return;let S=P=>{let A=P,O=A.inputType;if(O==="insertParagraph"||O==="insertLineBreak"||O==="insertFromDrop"){P.preventDefault();return}if(O.startsWith("insert")||O.startsWith("delete")){let Y=O.startsWith("delete")?"":A.data??"";N(Y)&&P.preventDefault()}};return g.addEventListener("beforeinput",S),()=>g.removeEventListener("beforeinput",S)},[N]);let le=ue(()=>{_.current=!0,C.current?.setAttribute("data-aia-composing","true")},[]),ne=ue(()=>{_.current=!1,C.current?.removeAttribute("data-aia-composing"),D()},[D]),d=ue(g=>{g.preventDefault();let S=C.current;if(!S)return;let P=(g.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!P)return;let A=S.ownerDocument??document,O=A.getSelection();if(!O||O.rangeCount===0)return;let Y=O.getRangeAt(0);if(!S.contains(Y.startContainer))return;Y.deleteContents();let ae=A.createTextNode(P);Y.insertNode(ae),Y.setStartAfter(ae),Y.collapse(!0),O.removeAllRanges(),O.addRange(Y),D()},[D]),I=ue(g=>z(g),[z]),ke=ue(()=>H(!0),[H]),b=ue(()=>H(!1),[H]),Ne=ue(()=>C.current?.focus(),[]),Ee=ue(()=>C.current?.blur(),[]),Ae=ue(()=>{let g=C.current;return g?Ca(g):""},[]),Ce=Wo()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:Ce,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":h,"aria-expanded":c,"aria-activedescendant":v,spellCheck:!0,enterKeyHint:"send",onInput:me,onKeyDown:I,onCompositionStart:le,onCompositionEnd:ne,onPaste:d,onFocus:ke,onBlur:b},getPlainText:Ae,focus:Ne,blur:Ee}}import{jsx as Xe,jsxs as Mt}from"react/jsx-runtime";function jo(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var $o=Go(function({onSubmit:o,onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,className:r,apiConfig:l,additionalContext:u,language:w,currency:k,productId:m,visitorId:c,columns:h,pillPlacement:v="dropdown",mode:E="auto",optionsPosition:B="below",animations:z=!0,optionsStyle:L="floating",dropdownTrigger:X,closeDropdownOnBlur:T,prependPlaceholder:N,showNonTappableOptions:H,locationSearch:C,showOptionIcons:_=!0,showChipIcons:J=!0,showChipImages:V=!0,showOptionImages:U=!0,showOptionCounts:R=!0,showSkipButton:D,showProducts:me,productsLayout:le,productImageFallback:ne,autoFocus:d=!0,onFocus:I,onBlur:ke,value:b,completedParams:Ne,onChange:Ee,onParamsChange:Ae,products:Ce,mapProducts:g,onProductSelect:S,onProductAddToCart:P,submitButton:A,resetOnSubmit:O=!0},Y){let ae=Ze(null),re=Ze(null),ge=Ze(null),qe=Ze(()=>{}),W=Ze(null),Re=Ze(null);Dt(()=>{let M=ae.current;if(M)return W.current?W.current.setMode(E):W.current=new Vo(M,E),()=>{W.current?.destroy(),W.current=null}},[E]);let Je=zt(M=>{let ie=Re.current?.current;ie&&(ie.focus(),Uo(ie,M))},[]),{completedParams:He,suggestionPills:fe,setActivePill:et,skipActivePill:Oe,segments:ee,newParamId:de,clearNewParamId:x,placeholderText:n,isFocused:Q,isDropdownOpen:be,isActivePillSelected:f,isLoading:Le,isReady:Se,activeIndex:ce,listboxId:Fe,handleTextChange:tt,handleKeyDown:Te,setFocused:_e,editingParam:pe,editingIdentified:we,editingAnchor:ze,caretOffset:Be,startEditingParam:Ve,handleCaretAfterInput:De,handleCaretMove:Ue,replaceEditingRange:p,dropdownProps:F,reset:y,refreshProducts:dt,prepareSubmit:Nt,getState:Ht,recordSubmit:Ft}=Ot({onSubmit:M=>qe.current(M),onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,apiConfig:l,additionalContext:u,language:w,currency:k,productId:m,visitorId:c,columns:h,dropdownTrigger:X,optionsPosition:B,closeDropdownOnBlur:T,prependPlaceholder:N,showNonTappableOptions:H,locationSearch:C,showOptionIcons:_,showOptionImages:U,showOptionCounts:R,showSkipButton:D,showProducts:me,onFocus:I,onBlur:ke,value:b,completedParams:Ne,onChange:Ee,onParamsChange:Ae,products:Ce,mapProducts:g,onProductSelect:S,onProductAddToCart:P,source:"full-sdk",setCursor:Je});Dt(()=>{if(!de)return;let M=window.setTimeout(()=>x(),650);return()=>window.clearTimeout(M)},[de,x]);let Ia=ce>=0?`${Fe}-option-${ce}`:void 0,{inputRef:wt,editorProps:Ea,focus:ct,blur:Bt,getPlainText:Wt}=Pa({segments:ee,newParamId:de,editingParam:pe,editingIdentified:we,editingAnchor:ze,caretOffset:Be,placeholderText:n,hintSuggestions:v==="inline"?[]:fe,isFocused:Q,showChipIcons:J,showChipImages:V,isDropdownOpen:be,listboxId:Fe,activeDescendantId:Ia,autoFocus:d,handleTextChange:tt,handleKeyDown:Te,handleCaretAfterInput:De,handleCaretMove:Ue,startEditingParam:Ve,replaceEditingRange:p,setFocused:_e});Re.current=wt,qo(()=>{let M=re.current,ie=wt.current;if(!M||!ie)return;let it=()=>{let Kt=M.firstElementChild;if(!Kt)return;let La=Kt.getBoundingClientRect(),za=ie.getBoundingClientRect();La.top>=za.bottom-2?M.setAttribute("data-aia-pill-wrapped",""):M.removeAttribute("data-aia-pill-wrapped")};it();let Gt=new ResizeObserver(it);return Gt.observe(ie),()=>Gt.disconnect()},[ee,fe.length,Le,wt]),Dt(()=>{let M=ge.current;if(M)return Qo(M)},[]),Ko(Y,()=>({focus:ct,blur:Bt,reset:y,refreshProducts:dt,setMode:M=>W.current?.setMode(M),skipActivePill:Oe}),[ct,Bt,y,dt,Oe]);let at=!!ee.length||He.length>0,vt=zt(M=>{if(!at)return;M&&Nt();let ie=Ht(),it=_o(Wt(),ie.completedParams,ie.skippedParams,{identifiedParams:ie.identifiedParams,isReady:ie.isReady,customFields:ie.customFields});M&&Ft(it),o(it),O&&y()},[Ft,O,at,Nt,Ht,o,y,Wt]);qe.current=()=>vt(!1);let Aa=zt(M=>{M.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||ct()},[ct]),Ra=v==="inline",Oa=v==="dropdown";return Mt("div",{ref:ae,className:`magicx-aia ${We.container} ${r??""}`,"data-pill-placement":v,"data-options-position":B,"data-animations":z?"on":"off","data-aia-options-style":L,"data-mode":jo(E),children:[Xe(At,{...F,showPills:Oa,productsLayout:le,productImageFallback:ne}),Mt("div",{className:We.inputWrapper,"data-aia-input-wrapper":"",onClick:Aa,children:[Mt("div",{ref:ge,className:We.editorArea,"data-aia-editor":"",children:[Xe("div",{...Ea,className:We.input,"data-aia-input":""}),Ra&&(Le||fe.length>0)&&Xe("span",{ref:re,className:We.pillListContainer,"data-aia-pill-list-container":"",children:Xe(ht,{pills:fe,activePillIndex:0,activeSelected:f,onSelectPill:et,loading:Le})})]}),A===null?null:A===void 0?Xe(fa,{disabled:!at,ready:at&&Se,onClick:()=>vt(!0),label:Yo(w).submit}):Xe("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:We.submitSlot,onClick:M=>{at&&(M.stopPropagation(),vt(!0))},children:A})]})]})});export{$o as AIAutocomplete,At as AIAutocompleteDropdown,rs as DATE_RANGE_META_END,ss as DATE_RANGE_META_START,ls as DEFAULT_OPTION_COUNT_UNIT,fs as LOCATION_META_KEY,Ss as PRODUCT_PATH_PREFIX,Ds as TIME_META_KEY,Ns as WEEKDAY_LABELS,is as buildSubmitResult,os as cellDay,ns as cellIso,ds as dateCellMarks,cs as formatDate,ps as formatDateRange,hs as formatOptionCount,us as formatPlace,ms as formatTime,gs as isoDate,bs as monthLabel,ws as optionCountLabel,vs as optionHasImage,xs as optionImageSources,ys as optionImageSrc,ks as optionLabel,Cs as optionsShowLeadingVisuals,Ts as parseDate,Ps as parseLooseDate,Is as parseLooseDateRange,Es as parseTime,As as productFromMatchedItem,Rs as productImageSources,Os as productsFromCustomFields,Ls as sanitizeOptionIconSvg,zs as selectedRangeFor,Ot as useAIAutocomplete,Ms as visibleDateRange,Hs as withSkippedParams};
|
|
3555
3567
|
//# sourceMappingURL=index.mjs.map
|