@magicx-eng/ai-autocomplete-vanilla 0.57.1 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="options"}function K(t){return t?.type?.kind==="date"?"date":t?.type?.kind==="date_range"?"date-range":t?.type?.kind==="time"?"time":"options"}var Ne=class{constructor(e){this.config=e;this.current=null;this.expiresAt=null;this.inFlightRefresh=null;e.accessToken&&(this.current=e.accessToken)}async getToken(e=!1){if(!e&&this.current&&!this.isExpired())return this.current;if(!e&&this.inFlightRefresh)return this.inFlightRefresh;this.inFlightRefresh=this.refresh();try{return await this.inFlightRefresh}finally{this.inFlightRefresh=null}}async refresh(){let e=await this.config.getAccessToken();return this.current=e.accessToken,this.expiresAt=e.expiresAt??null,this.current}isExpired(){return this.expiresAt==null?!1:Date.now()>=this.expiresAt-3e4}};var Co="https://api.ai-autocomplete.com",J=`${Co}/api/suggest`,He=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),pr=new WeakMap;function Te(t){return t?.type==="accessToken"}function Io(t){if(!(!t||Te(t)))return t}function Fe(t){let e=pr.get(t.getAccessToken);return e||(e=new Ne(t),pr.set(t.getAccessToken,e)),e}function We(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function Be(t){let e=Io(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}function ve(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var mr="skipped";function Ee(t,e){if(t.some(i=>"group"in i)&&(t=t.map(i=>{let{group:o,...s}=i;return s})),e.length===0)return t;let n=new Set(t.map(i=>i.parameter)),r=e.filter(i=>!n.has(i.parameter)).map(i=>({placeholder:"",parameter:i.parameter,text:mr,kind:null}));return r.length>0?[...t,...r]:t}var Ao="0.57.1",hr="1.0",gr=!1;function Oo(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function ie(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function ko(t,e,n,r,i,o,s,a,l,d,c,u,m){let g=e.find(h=>h.parameter==="contact"&&h.metadata?.contact_account_count)?.metadata?.contact_account_count,p=typeof g=="number"?g:void 0;return{data:{raw_query:t,accepts_traditional_autocomplete:!0,client_option_parameters:m??[],completed_params:Ee(e.map(h=>Oo(h,n)),l??[]),...s&&s.length>0&&{identified_params:ve(s)},...a&&a.length>0&&{recently_suggested:a},...p!=null&&{contact_account_count:p},...d!==void 0&&{additional_context:d}},meta:{request_id:i,request_at:new Date().toISOString(),language:ie(c),...u?.code&&Number.isFinite(u.rate)&&u.rate>0&&{currency:u.code,currency_rate:u.rate,...u.country!==void 0&&{country:u.country}},client_version:Ao,session_id:r,source:o,schema_version:hr}}}async function fr(t,e,n,r,i){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:r,signal:i})}async function br(t,e,n){let r=n.apiConfig,i=!n.maskCompletedText,o=ko(t,e,i,n.sessionId,n.requestId??crypto.randomUUID(),n.source,n.identifiedParams,n.recentlySuggested,n.skippedParams,n.additionalContext,n.language,n.currency,n.clientOptionParameters),s=We(r),a=r?.endpoint??J,l=JSON.stringify(o);if(Te(r)){let u=Fe(r),m=await u.getToken(),g=await fr(a,s,m,l,n.signal);if(g.status===401){let p=await u.getToken(!0);g=await fr(a,s,p,l,n.signal)}if(!g.ok)throw new Error(`API error: ${g.status} ${g.statusText}`);return g.json()}let d=Be(r);!d&&!gr&&(gr=!0,console.warn("[AIAutocomplete] No apiKey in apiConfig. Requests will be sent without an Authorization header.")),d&&(s.Authorization=d);let c=await fetch(a,{method:"POST",headers:s,body:l,signal:n.signal});if(!c.ok)throw new Error(`API error: ${c.status} ${c.statusText}`);return c.json()}var Ve=/[\p{L}\p{N}]/u,Lo=/['\u2019-]/;function Sr(t,e,n){let r=t[e];if(r===void 0)return!1;if(Ve.test(r))return!0;let i=t[e+n];return Lo.test(r)&&i!==void 0&&Ve.test(i)}function Mo(t,e,n){let r=e+n.length;return!(Ve.test(n[0])&&Sr(t,e-1,-1)||Ve.test(n[n.length-1])&&Sr(t,r,1))}function z(t,e,n=0,r=()=>!0){if(e.length===0)return t.indexOf(e,n);let i=-1,o=t.indexOf(e,n);for(;o!==-1;){if(r(o)){if(Mo(t,o,e))return o;i===-1&&(i=o)}o=t.indexOf(e,o+1)}return i}function N(t,e){let n=t,r={},i=[],o=[],s=0;for(let a of e){let l=(r[a.parameter]??0)+1;r[a.parameter]=l;let c=`{{${a.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,u=g=>z(n,a.text,g,p=>!o.some(h=>p<h.end&&p+a.text.length>h.start)),m=u(s);if(m===-1&&(m=u(0)),m!==-1){n=n.slice(0,m)+c+n.slice(m+a.text.length);let g=c.length-a.text.length;for(let p of o)p.start>=m+a.text.length&&(p.start+=g,p.end+=g);o.push({start:m,end:m+c.length}),s=m>=s?m+c.length:s+g}i.push({...a,placeholder:c})}return{rawQuery:n,completedParams:i}}function Z(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function $e(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function Pe(t,e,n){let r=t.slice(e);if(n||e===0||t[e-1]===" ")return r;let i=r.indexOf(" ");return i===-1?"":r.slice(i+1)}function yr(t,e){let n=t.trimEnd().replace(/\s+/g," ");if(n.length===0||e.length===0)return 0;let r=n.split(" "),i=e.toLowerCase();for(let o=0;o<r.length;o++){let s=r.slice(o).join(" ");if(i.startsWith(s.toLowerCase())){let a=n.length-s.length;return t.length-a}}return 0}function xr(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function Ro(t,e){let n=xr(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function oe(t,e,n=!1){if(!t)return[];let r=e.trimStart();if(!r)return t;let i=n?xr(r).trimStart():"";if(i)return t.filter(s=>!s.is_tappable||Ro(s.text,i));let o=r.toLowerCase();return t.filter(s=>!s.is_tappable||s.text.toLowerCase().includes(o))}function Ue(t,e){if(!t)return null;let n=e.trim();if(!n)return null;let r=n.toLowerCase();return t.find(i=>i.is_tappable&&i.text.toLowerCase()===r)??null}function we(t,e,n,r,i){let o=Pe(e,n,r),s=Ue(t,o);if(s||!i||!o.trim())return s;if(o===e.slice(n))return null;let a=e.lastIndexOf(" ",n-1)+1;return Ue(t,e.slice(a))}function Tr(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function _o(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function j(t){let e=_o(t);return e.length>0?e.join(" "):t}function q(t,e){return t.parameter||e}function Ce(t){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:j(t)}}function Ge(t,e){let n=q(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?Ce(n):{parameter:n,suggestionParameter:t.suggestionParameter,suggestionValueType:t.suggestionValueType,suggestionPlaceholder:t.suggestionPlaceholder}}function P(t){return t?.type?.kind==="traditional_autocomplete"}function vr(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function qe(t){return P(t)||t?.smart_suggestion===!0}function Wt(t){return t.some(P)?t.filter(e=>!P(e)):t}function Bt(t,e){return t.some(n=>P(n)&&!n.text)?t.map(n=>P(n)&&!n.text?{...n,text:e}:n):t}var Vt='<svg viewBox="0 0 20 20" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false"><path class="aia-sparkle-large" d="M8 5C8.5 9.5 10.5 11.5 15 12C10.5 12.5 8.5 14.5 8 19C7.5 14.5 5.5 12.5 1 12C5.5 11.5 7.5 9.5 8 5Z"/><path class="aia-sparkle-small" d="M16 1C16.2 3 17 3.8 19 4C17 4.2 16.2 5 16 7C15.8 5 15 4.2 13 4C15 3.8 15.8 3 16 1Z"/></svg>';function Ut(t){return t.some(e=>!P(e))}function Er(t,e){let n=0,r=e;for(let i of t)n+=i.value.length,i.type!=="text"&&(r=Math.max(r,n));return r}function Pr(t,e){let n=0;for(let r of t){let i=n+r.value.length;if(r.type==="text"&&i>e&&r.value.slice(Math.max(e-n,0)).trim().length>0)return!1;n=i}return!0}function wr(t,e){let n=[],r=new Set;for(let i of[...t,...e])i.parameter==="placeholder"||P(i)||r.has(i.parameter)||(r.add(i.parameter),n.push({parameter:i.parameter,text:i.text}));return n}function Cr(t,e,n){if(t===e)return n;let r=Math.min(t.length,e.length),i=0;for(;i<r&&t[i]===e[i];)i++;if(i>=n)return n;let o=0;for(;o<r-i&&t[t.length-1-o]===e[e.length-1-o];)o++;return t.length-o<=n?n+(e.length-t.length):null}function Ke(t,e){let n=[],r=[],i=0;for(let o of e){let s=z(t,o.text,i);if(s===-1){r.push(o);continue}n.push({start:s,end:s+o.text.length,param:o}),i=s+o.text.length}return{located:n,missing:r}}function de(t,e){let{located:n}=Ke(t,e);return n.length>0?n[n.length-1].end:0}function Ir(t,e,n){let r=[],i=[],o=0;for(let s of n){let a=z(t,s.text,o,l=>!e.some(d=>l<d.end&&l+s.text.length>d.start));if(a===-1){i.push(s);continue}r.push({start:a,end:a+s.text.length,param:s}),o=a+s.text.length}return{located:r,missing:i}}function Ar(t,e,n=[]){let r=Ke(t,e).located,i=[];for(let c of r){let u=i[i.length-1];c.param.group&&u?.param.group===c.param.group?(u.end=c.end,u.params?.push(c.param)):i.push({...c,...c.param.group?{params:[c.param]}:{}})}let o=Ir(t,i,n).located,s=[...i.map(c=>({start:c.start,end:c.end,segment:{type:"completed",value:t.slice(c.start,c.end),param:c.param,...c.params?{params:c.params}:{}}})),...o.map(c=>({start:c.start,end:c.end,segment:{type:"identified",value:c.param.text,param:c.param}}))].sort((c,u)=>c.start-u.start),a=[],l=0;for(let c of s)c.start>l&&a.push({type:"text",value:t.slice(l,c.start)}),a.push(c.segment),l=c.end;let d=t.slice(l);return d&&a.push({type:"text",value:d}),a}function Or(t,e){let{located:n,missing:r}=Ke(t,e),i=new Set(r.map(s=>s.group).filter(Boolean)),o=n.map(s=>s.param).filter(s=>!i.has(s.group));return{valid:o,invalid:e.filter(s=>!o.includes(s))}}function Ie(t,e,n){let r=Ke(t,e).located,{located:i,missing:o}=Ir(t,r,n);return{valid:i.map(s=>s.param),invalid:o}}function kr(t,e,n){let r=e?.endpoint??J,i=r.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${Do(n)}`);if(i!==r)return i.replace(/^https:\/\/([^/?#]+)/,(o,s)=>{let a=He.get(s);return a?`https://${a}`:o})}function Do(t){let e=t?.replace(/_/g,"-").toLowerCase()??"",[n,r=""]=e.split("-");return n!=="zh"?/^[a-z]{2,3}$/.test(n)?`/${n}`:"":/^[a-z]{4}$/.test(r)?r==="hant"?"/zh-TW":"/zh":["tw","hk","mo"].includes(r)?"/zh-TW":"/zh"}async function Lr(t){try{let e=await t;if(!e.ok)return null;let n=await e.json();return Array.isArray(n?.data?.suggestions)?n:null}catch{return null}}function No(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var Ho=100,Fo=300,Wo=2,ze=class{constructor(e,n,r,i,o,s,a,l,d,c={}){this.store=e;this.getApiConfig=n;this.getOptionOverrides=r;this.getMaskCompletedText=i;this.getOnError=o;this.getSessionId=s;this.getSource=a;this.getAdditionalContext=l;this.getLanguage=d;this.callbacks=c;this.fetchVersion=0;this.abortController=null;this.debounceTimer=null;this.slowDebounceTimer=null;this.unsubscribe=null;this.phraseExactMatch=!1}start(){this.doFetch("",[]);let e=this.store.get().text,n=this.store.get().completedParams;this.unsubscribe=this.store.subscribe(r=>{(r.text!==e||r.completedParams!==n)&&(e=r.text,n=r.completedParams,this.scheduleFetch())})}isPhraseExactMatch(){return this.phraseExactMatch}dispose(){this.abortController?.abort(),this.clearTimers(),this.unsubscribe?.()}async doFetch(e,n){this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=++this.fetchVersion,o=this.store.get().text.length;try{this.callbacks.onRequest?.({query:this.store.get().text,signal:r.signal,isCurrent:()=>i===this.fetchVersion})}catch{}try{this.store.set({isLoading:!0,error:null});let s=this.store.get(),a=s.pendingSpan?wr(s.pendingSpan.snapshot,s.actionableSuggestions):void 0,l=crypto.randomUUID(),d=e===""&&n.length===0&&s.skippedParams.length===0&&s.identifiedParams.length===0?this.startingStateUrl():void 0,c=d?await Lr(fetch(d,{signal:r.signal})):null;if(i!==this.fetchVersion)return;let u=c??await br(e,n,{sessionId:this.getSessionId(),requestId:l,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:r.signal,apiConfig:this.getApiConfig(),identifiedParams:s.identifiedParams,recentlySuggested:a,skippedParams:s.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})});if(i!==this.fetchVersion)return;this.phraseExactMatch=u.meta?.phrase_exact_match===!0;let m=(u.data.suggestions??[]).find(P),g=m?[]:u.data.input??[],p=g.filter(T=>T.source==="identified").map(T=>({id:crypto.randomUUID(),parameter:T.parameter,text:T.text,...T.type?{type:T.type}:{}})),h=this.callbacks.isWordOpen?.()??!1,x=this.store.get().text.toLowerCase(),b=T=>h&&x.endsWith(T.text.toLowerCase()),f=p.filter(T=>!b(T));h&&this.callbacks.holdIdentified?.(p.filter(b));let S=m?[m]:Tr(u.data.suggestions??[],this.getOptionOverrides()),y=g,w=y[y.length-1],v=this.store.get().text,E,L;if(w?.state==="in_progress"){L=!0;let T=v.toLowerCase().lastIndexOf(w.text.toLowerCase());E=T!==-1?T:o}else L=!1,E=o;let O=S.filter(T=>T.parameter!=="placeholder")[0],W=null;if(O&&!P(O)&&!h&&O.type?.kind!=="multi_select"&&!_(K(O))){let T=we(O.options,v,E,L,this.phraseExactMatch);T&&(W={id:crypto.randomUUID(),placeholder:"",parameter:q(T,O.parameter),text:T.text,value:T.value,kind:T.kind,suggestionParameter:O.parameter,suggestionValueType:O.type,suggestionPlaceholder:O.text,options:O.options??[],metadata:T.metadata,icon:T.icon,icon_svg:T.icon_svg,image_url:T.image_url},S=S.filter(R=>R!==O),this.callbacks.onAutoMatch?.({active:O,matched:T,rawQuery:e}))}let D=u.data.custom_fields??null,Q=this.callbacks.productsForResponse?.(D);this.store.set(T=>{let R=W?[...T.completedParams,W]:T.completedParams,X=Ie(T.text,R,f).valid,Ft=new Set(s.skippedParams.map(A=>A.id)),De=new Set(T.skippedParams.filter(A=>!Ft.has(A.id)).map(A=>A.parameter));return{suggestions:De.size>0?S.filter(A=>A.parameter==="placeholder"||!De.has(A.parameter)):S,isLoading:!1,isReady:u.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:E,filterInProgress:L,identifiedParams:X,customFields:D,traditionalAutocomplete:u.meta?.traditional_autocomplete===!0,...Q!==void 0?{products:Q}:{},...W?{completedParams:R}:{}}}),this.callbacks.onResponse?.({requestId:l,funnelTelemetry:u.meta?.funnel_telemetry===!0,visibleImpression:u.meta?.visible_impression===!0})}catch(s){let a=No(s);i===this.fetchVersion&&(this.store.set({error:a,isLoading:!1}),this.getOnError()?.(a))}finally{if(i===this.fetchVersion&&this.store.get().isLoading)try{this.store.set({isLoading:!1})}catch{}}}startingStateUrl(){let e=this.callbacks.getProductId?.();return e?kr(e,this.getApiConfig(),ie(this.getLanguage())):void 0}attemptNow(){if(this.clearTimers(),this.store.get().skipNextFetch){this.store.set({skipNextFetch:!1});return}this.attemptFetch(1,!0)}scheduleFetch(){if(this.clearTimers(),this.store.get().skipNextFetch){this.store.set({skipNextFetch:!1});return}this.debounceTimer=setTimeout(()=>{this.attemptFetch(Wo)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},Ho),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),Fo)}attemptFetch(e,n=!1,r=!1){let i=this.store.get();if(!i.text&&i.completedParams.length===0)return this.doFetch("",[]),!0;let o=this.callbacks.consumerTick?.(i,e)??"no";if(o==="asked")return!0;if(o==="owns")return!1;let s=i.suggestions.filter(v=>v.parameter==="placeholder").map(v=>v.text).join(" "),a=Z(i.text,i.filterBase,s),l=Pe(i.text,a,i.filterInProgress),d=i.suggestions.filter(v=>v.parameter!=="placeholder"),c=P(d[0])?void 0:d[0],u=_(i.activeFormatType),m=c&&!u?oe(c.options,l,i.traditionalAutocomplete):[];if(i.multiSelectView&&l.trim().length>0&&m.length>0)return!1;let g=m.filter(v=>v.is_tappable),p=c&&!u&&!this.callbacks.isWordOpen?.()?we(c.options,i.text,a,i.filterInProgress,this.phraseExactMatch)!==null:!1,h=l.trim().length>0,x=r&&i.products.length>0;if(g.length>0&&!p&&h&&!x||$e(i.text,i.completedParams.length,s))return!1;let{rawQuery:b,completedParams:f}=N(i.text,i.completedParams),S=b.length<i.lastRawQuery.length,y=Math.abs(b.length-i.lastRawQuery.length),w=n&&b!==i.lastRawQuery;return S||y>=e||w?(this.doFetch(b,f),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var Bo="(hover: none) and (pointer: coarse)";var Vo="[data-aia-dropdown], [data-aia-input-wrapper]",Uo=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),je=class{constructor(e,n){this.store=e;this.container=n;this.listening=!1;this.declined=!1;this.pressOutside=!1;this.pressWhileFocused=!1;this.recheckTimer=null;this.releaseTimer=null;this.onPointerDown=e=>{let n=e.composedPath(),r=this.isInside(n);this.pressOutside=!r;let i=this.store.get();this.pressWhileFocused=i.isFocused,!(r||!i.isFocused)&&(this.declined=n.some(o=>o instanceof Element&&o.matches(Uo)),this.declined&&i.dropdownHeld?this.store.set({dropdownHeld:!1}):!this.declined&&!i.dropdownHeld&&i.isDropdownOpen&&this.store.set({dropdownHeld:!0}))};this.onPointerCancel=()=>{this.pressOutside=!1,this.pressWhileFocused&&this.declined&&this.scheduleRecheck(),this.pressWhileFocused=!1};this.onPointerUp=e=>{let n=this.pressOutside&&!this.isInside(e.composedPath()),r=this.pressWhileFocused;if(this.pressOutside=!1,this.pressWhileFocused=!1,r){this.declined&&this.scheduleRecheck();return}!n||this.store.get().isFocused||(this.cancelRelease(),this.releaseTimer=setTimeout(()=>{this.releaseTimer=null;let i=this.store.get();i.dropdownHeld&&!i.isFocused&&this.store.set({dropdownHeld:!1})},150))};this.touchPrimary=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(Bo):null,this.unsubscribe=e.subscribe(()=>this.sync())}dispose(){this.unsubscribe(),this.listen(!1),this.cancelRelease(),this.recheckTimer!==null&&clearTimeout(this.recheckTimer),this.recheckTimer=null}sync(){let e=this.store.get(),n=this.touchPrimary?.matches??!1;e.isFocused||(this.declined=!1),e.isDropdownOpen?e.isFocused&&!e.dropdownHeld&&!this.declined&&n&&this.store.set({dropdownHeld:!0}):e.dropdownHeld&&this.store.set({dropdownHeld:!1});let r=this.store.get();this.listen(n&&r.isDropdownOpen),r.isFocused&&this.cancelRelease()}listen(e){if(!(e===this.listening||typeof document>"u")){if(this.listening=e,e){document.addEventListener("pointerdown",this.onPointerDown,!0),document.addEventListener("pointerup",this.onPointerUp,!0),document.addEventListener("pointercancel",this.onPointerCancel,!0);return}document.removeEventListener("pointerdown",this.onPointerDown,!0),document.removeEventListener("pointerup",this.onPointerUp,!0),document.removeEventListener("pointercancel",this.onPointerCancel,!0),this.pressOutside=!1}}scheduleRecheck(){this.recheckTimer!==null&&clearTimeout(this.recheckTimer),this.recheckTimer=setTimeout(()=>{this.recheckTimer=null,!(!this.declined||!this.store.get().isFocused)&&(this.declined=!1,this.sync())},150)}cancelRelease(){this.releaseTimer!==null&&(clearTimeout(this.releaseTimer),this.releaseTimer=null)}isInside(e){let n=this.container,r=n?.getRootNode(),i=typeof ShadowRoot<"u"&&r instanceof ShadowRoot?r.host:null;for(let o of e)if(o===n||o===i||o instanceof Element&&o.matches(Vo))return!0;return!1}};var ue=["January","February","March","April","May","June","July","August","September","October","November","December"],Ye=["S","M","T","W","T","F","S"],_r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Dr="aiaDate",Nr="aiaDay",Mr=t=>String(t).padStart(2,"0");function B(t){return`${t.getFullYear()}-${Mr(t.getMonth()+1)}-${Mr(t.getDate())}`}function $t(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function $o(t){let e=$t(t).getTime()-$t(new Date).getTime();return Math.round(e/864e5)}function Hr(t){let e=$o(t);return e>=0&&e<7?_r[t.getDay()]:pe(t)}function pe(t){return t.getFullYear()===new Date().getFullYear()?`${ue[t.getMonth()]} ${t.getDate()}`:`${ue[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function Qe(t){if(!t)return null;let e=_r.findIndex(a=>a.toLowerCase()===t.trim().toLowerCase());if(e>=0){let a=$t(new Date),l=(e-a.getDay()+7)%7;return new Date(a.getFullYear(),a.getMonth(),a.getDate()+l)}let n=/^\s*([A-Za-z]+)\s+(\d{1,2})(?:\s+(\d{4}))?\s*$/.exec(t);if(!n)return null;let r=ue.findIndex(a=>a.toLowerCase()===n[1].toLowerCase());if(r<0)return null;let i=Number(n[2]),o=n[3]?Number(n[3]):new Date().getFullYear(),s=new Date(o,r,i);return s.getMonth()!==r||s.getDate()!==i?null:s}function Gt(t){return`${ue[t.month]} ${t.year}`}function qt(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function Fr(t){return{year:t.getFullYear(),month:t.getMonth()}}function Kt(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function Rr(){return{text:"",is_tappable:!1,kind:null}}function zt(t){let e=new Date(t.year,t.month,1).getDay(),n=new Date(t.year,t.month+1,0).getDate(),r=[];for(let i=0;i<e;i++)r.push(Rr());for(let i=1;i<=n;i++){let o=new Date(t.year,t.month,i);r.push({text:Hr(o),is_tappable:!0,kind:null,metadata:{[Dr]:B(o),[Nr]:i}})}for(;r.length%Ye.length!==0;)r.push(Rr());return r}function jt(t){let e=Qe(t);return e?B(e):null}function Y(t){let e=t?.metadata?.[Dr];return typeof e=="string"?e:null}function Yt(t){let e=t?.metadata?.[Nr];return typeof e=="number"?e:null}function Go(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function se(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&Go(e)?e:t.ownerDocument??t}function H(t){return t.ownerDocument??t}function qo(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Wr(t){let e=se(t);return!qo(e)||typeof e.getSelection=="function"?null:e}function Br(t){let e=Wr(t);if(!e)return null;let n=H(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function Vr(t,e){let n=t,r;try{r=n.getComposedRanges({shadowRoots:[e]})}catch{r=n.getComposedRanges(e)}return r.length>0?r[0]:null}function Qt(t){let n=se(t).getSelection?.();return n||(H(t).getSelection?.()??null)}function ee(t){let e=Qt(t);if(!e||e.rangeCount===0)return null;let n=Br(t);if(n){let r=Vr(e,n);return r?{node:r.startContainer,offset:r.startOffset,collapsed:r.startContainer===r.endContainer&&r.startOffset===r.endOffset}:null}return e.anchorNode?{node:e.anchorNode,offset:e.anchorOffset,collapsed:e.isCollapsed}:null}function Xe(t){let e=Qt(t);if(!e||e.rangeCount===0)return null;let n=Br(t);if(!n)return e.getRangeAt(0);let r=Vr(e,n);if(!r)return null;let i=H(t).createRange();return i.setStart(r.startContainer,r.startOffset),i.setEnd(r.endContainer,r.endOffset),i}function Ae(t,e,n){let r=Qt(t);if(!r)return null;if(Wr(t))return r.collapse(e,n),r;let i=H(t).createRange();return i.setStart(e,n),i.collapse(!0),r.removeAllRanges(),r.addRange(i),r}function Je(t,e){let n=t?se(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var Ze=2,Ko="magicx-aia";function Ur(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function zo(t){let e=H(t),n=e.defaultView;if(!n?.getComputedStyle)return null;let r=t;for(;r&&r!==e.body&&r!==e.documentElement;){let i=r.scrollWidth>r.clientWidth,o=r.scrollHeight>r.clientHeight;if(i||o){let s=n.getComputedStyle(r);if(i&&Ur(s.overflowX)||o&&Ur(s.overflowY))return r}if(r.classList.contains(Ko))return null;r=r.parentElement}return null}function Xt(t){let e=Xe(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=zo(t);if(!n||typeof e.getBoundingClientRect!="function")return;let r=e.getBoundingClientRect();if(r.height===0)return;let i=n.getBoundingClientRect();if(n.scrollWidth>n.clientWidth){let o=i.left+n.clientLeft,s=o+n.clientWidth;r.right>s?n.scrollLeft+=r.right-s+Ze:r.left<o&&(n.scrollLeft-=o-r.left+Ze)}if(n.scrollHeight>n.clientHeight){let o=i.top+n.clientTop,s=o+n.clientHeight;r.bottom>s?n.scrollTop+=r.bottom-s+Ze:r.top<o&&(n.scrollTop-=o-r.top+Ze)}}var Gr='[contenteditable="false"]',Zt="strong[data-param-id]",me;function jo(){if(me!==void 0)return me;let t=globalThis.Intl.Segmenter;if(!t)return me=null,null;try{me=new t(void 0,{granularity:"grapheme"})}catch{me=null}return me??null}function et(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(Gr))return!0;n=n.parentNode}return!1}function tt(t){return H(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return et(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function nt(t){let e=tt(t),n="",r=e.nextNode();for(;r;)n+=r.data,r=e.nextNode();return n}function en(t){let e=tt(t),n=0,r=e.nextNode();for(;r;)n+=r.data.length,r=e.nextNode();return n}function V(t){let e=ee(t);if(!e)return null;let n=e.node,r=e.offset;if(!t.contains(n))return null;if(n.nodeType===Node.ELEMENT_NODE){let i=n;if(et(i,t)&&i!==t)return null;let o=0;for(let s=0;s<r&&s<i.childNodes.length;s++)o+=tn(i.childNodes[s],t);return o+Jt(i,t)}return n.nodeType!==Node.TEXT_NODE||et(n,t)?null:Jt(n,t)+r}function tn(t,e){if(t.nodeType===Node.TEXT_NODE)return et(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(Gr))return 0;let r=0;for(let i of Array.from(n.childNodes))r+=tn(i,e);return r}function Jt(t,e){let n=tt(e),r=0,i=n.nextNode();for(;i;){if(i===t||t.nodeType===Node.ELEMENT_NODE&&t.contains(i))return r;r+=i.data.length,i=n.nextNode()}return r}function F(t,e){let n=H(t),r=Math.max(0,Math.min(e,en(t))),i=tt(t),o=0,s=null,a=0,l=i.nextNode(),d=null;for(;l;){let u=l.data.length;if(r<o+u){s=l,a=r-o;break}if(r===o+u){let m=i.nextNode();m?(s=m,a=0):(s=l,a=u);break}o+=u,d=l,l=i.nextNode()}let c=n.createRange();if(s){let u=s.parentElement?.closest('strong[data-seg="completed"]');u&&u!==t&&t.contains(u)?a===0?c.setStartBefore(u):a===s.data.length?c.setStartAfter(u):c.setStart(s,a):c.setStart(s,a)}else d?c.setStart(d,d.data.length):c.setStart(t,0);c.collapse(!0),Ae(t,c.startContainer,c.startOffset)&&(Yo(t,c,r),Xt(t))}function $r(t,e){if(!t||!e.contains(t))return null;let r=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(Zt)??null;return r&&e.contains(r)?r:null}function Yo(t,e,n){let r=$r(ee(t)?.node??null,t);if(r&&r!==$r(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${r.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function qr(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let r=V(t);return r!==null&&n===`${r}:${e}`}function Kr(t){return se(t).activeElement===t}function nn(t,e){if(!e||e.nodeType===void 0)return null;let n=e,i=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(Zt);if(!i||!t.contains(i))return null;let o=ee(t);return o&&!o.collapsed?null:i.dataset.paramId??null}function rn(t,e){let n=null;for(let s of t.querySelectorAll(Zt))if(s.dataset.paramId===e){n=s;break}if(!n)return;let r=Jt(n,t),i=r+tn(n,t),o=V(t);o!=null&&o>=r&&o<=i||F(t,r)}function on(t){let e=V(t);return e==null?!1:e>=en(t)}function sn(t,e){if(e<=0)return 0;let n=jo();if(!n)return e-1;let r=t.slice(0,e),i=0;for(let{index:o}of n.segment(r))o<e&&(i=o);return i}var zr="aiaTime",ln=5;var cn=[12,1,2,3,4,5,6,7,8,9,10,11],dn=Array.from({length:60/5},(t,e)=>e*5),un=["AM","PM"];function fe(t){return(Math.round(t)%1440+1440)%1440}function pn(t){let e=fe(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function rt(t){let e=t.hour%12+(t.period==="PM"?12:0);return fe(e*60+t.minute)}function it(t){let{hour:e,minute:n,period:r}=pn(t);return`${e}:${String(n).padStart(2,"0")} ${r}`}function jr(t){let e=fe(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function ge(t){return fe(Math.round(t/5)*5)}function Yr(t,e){return fe(t+e)}var Qo=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,Xo=/^(\d{1,2}):(\d{2})$/;function an(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=Qo.exec(e);if(n){let i=Number(n[1]),o=n[2]===void 0?0:Number(n[2]);return i<1||i>12||o>59?null:rt({hour:i,minute:o,period:n[3]==="a"?"AM":"PM"})}let r=Xo.exec(e);if(r){let i=Number(r[1]),o=Number(r[2]);return i>23||o>59?null:i*60+o}return null}function Qr(t){let e=an(t.editingText);if(e!=null)return ge(e);let n=(t.options??[]).filter(i=>i.is_tappable).map(i=>an(i.text)).filter(i=>i!=null);if(n.length>0)return ge(n[Math.floor((n.length-1)/2)]);let r=t.now??new Date;return fe((r.getHours()+1)*60)}function mn(t){return{text:it(t),is_tappable:!0,kind:null,metadata:{[zr]:jr(t)}}}var ot=30,st=["hour","minute","period"],gn={hour:cn.map(t=>({label:String(t)})),minute:dn.map(t=>({label:String(t).padStart(2,"0")})),period:un.map(t=>({label:t}))};function fn(t){return gn[t]}function at(t,e){let n=pn(ge(e));return t==="hour"?cn.indexOf(n.hour):t==="minute"?dn.indexOf(n.minute):un.indexOf(n.period)}function lt(t,e,n){let r=gn[t],i=Math.min(Math.max(n,0),r.length-1),o=pn(ge(e));return rt(t==="hour"?{...o,hour:cn[i]}:t==="minute"?{...o,minute:dn[i]}:{...o,period:un[i]})}function hn(t,e){let n=gn[t].length-1;return Math.min(Math.max(Math.round(e/ot),0),n)}function ae(t,e,n=[],r={}){let{rawQuery:i,completedParams:o}=N(t,e);return{query:t.trim(),raw_query:i,completed_params:Ee(o,n),identified_params:ve(r.identifiedParams??[]),is_ready:r.isReady??!1,...r.customFields?{custom_fields:r.customFields}:{}}}function ct(t,e){return t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement?t.selectionStart!=null&&t.selectionStart===t.value.length:t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?on(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function bn(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?V(t):null}var dt=class{constructor(e,n){this.store=e;this.ctx=n}handleKeyDown(e){if(e.isComposing||e.keyCode===229)return;let n=this.store.get(),{listboxId:r,getOnSubmit:i}=this.ctx,o=e.target instanceof Node?e.target:null,s=this.getEffectiveColumns(o),a=i(),l=this.getTappableIndices(s);if((e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)&&(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight"))return;let d=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let c=n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&c?.is_tappable){e.preventDefault(),this.ctx.selectOption(c);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&c?.is_tappable&&this.ctx.selectOption(c),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let c=ct(e.target,n),u=!!n.editingParam;if(!c&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(d)break;e.preventDefault();let p=M(n.activeFormatType)?this.dateEntryIndex(n,!1):l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:p});break}if(l.length===0)return;this.store.set({activeDropdownIndex:p});break}if(e.preventDefault(),l.length===0)return;if(M(n.activeFormatType)){this.stepDateWeek(n,7);break}if(n.filteredOptions.length>0){let p=Math.floor((n.filteredOptions.length-1)/s);if(Math.floor(n.activeDropdownIndex/s)===p){this.store.set({activeDropdownIndex:-1});break}}let m=l.indexOf(n.activeDropdownIndex),g=m<l.length-1?m+1:0;this.store.set({activeDropdownIndex:l[g]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!d)break;let m=ct(e.target,n),g=!!n.editingParam;if(!m&&!g)break;e.preventDefault();let p=M(n.activeFormatType)?this.dateEntryIndex(n,!0):this.firstTappableInBottomRow(s)??l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:p});break}if(l.length===0)return;this.store.set({activeDropdownIndex:p});break}if(l.length===0)break;if(e.preventDefault(),M(n.activeFormatType)){this.stepDateWeek(n,-7);break}if(n.activeDropdownIndex<s){this.store.set({activeDropdownIndex:-1});break}let c=l.indexOf(n.activeDropdownIndex),u=c>0?c-1:l.length-1;this.store.set({activeDropdownIndex:l[u]});break}case"ArrowRight":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),M(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%s<s-1){let m=n.activeDropdownIndex+1;m<n.filteredOptions.length&&n.filteredOptions[m]?.is_tappable&&this.store.set({activeDropdownIndex:m})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,m=n.editingTail;this.ctx.exitEditMode?.(),F(u,m);break}ct(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),M(n.activeFormatType)){this.stepDateDay(n,-1);break}if(n.activeDropdownIndex%s>0){let c=n.activeDropdownIndex-1;c>=0&&n.filteredOptions[c]?.is_tappable&&this.store.set({activeDropdownIndex:c});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let c=bn(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingAnchor!=null){e.preventDefault();let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingAnchor;this.ctx.exitEditMode?.(),F(c,u);break}if(this.ctx.startEditingParamAtCaret){let c=bn(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let c=bn(e.target);if(c==null)break;this.ctx.removeParamAtCaret(c)&&e.preventDefault();break}case"Enter":{if(e.preventDefault(),n.activeDropdownIndex>=0&&n.filteredOptions[n.activeDropdownIndex]?.is_tappable)this.clickOrSelect(n.activeDropdownIndex,n.filteredOptions,r,o);else if(a){this.ctx.endTypedWord?.(!0);let c=this.store.get();a(ae(c.text,c.completedParams,c.skippedParams,{identifiedParams:c.identifiedParams,isReady:c.isReady,customFields:c.customFields}))&&this.ctx.afterSubmit?.()}break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let c=n.filteredOptions.map((g,p)=>g.is_tappable?p:-1).filter(g=>g!==-1);if(c.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let g=e.shiftKey?c[c.length-1]:c[0];this.store.set({pillTapped:!0,activeDropdownIndex:g});break}e.preventDefault();let u=c.indexOf(n.activeDropdownIndex),m;if(u<0)m=e.shiftKey?c.length-1:0;else{let g=e.shiftKey?-1:1;m=(u+g+c.length)%c.length}this.store.set({activeDropdownIndex:c[m]});break}case"Escape":{if(n.dateRangeStart){this.store.set({pendingRangeStart:null});break}if(n.editingIdentified){this.ctx.exitEditingIdentified?.(),this.store.set({activeDropdownIndex:-1});break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingTail;this.ctx.exitEditMode?.(),F(c,u)}this.store.set({activeDropdownIndex:-1});break}}}handleTimeWheelKey(e,n){let r=n.timeView;if(n.activeFormatType!=="time"||!r||!n.isDropdownOpen)return!1;switch(e.key){case"ArrowDown":case"ArrowUp":return!ct(e.target,n)&&!n.editingParam?!1:(e.preventDefault(),this.ctx.stepTime?.(e.key==="ArrowDown"?5:-5),!0);case"Enter":return r.touched?(e.preventDefault(),this.ctx.commitTime?.(),!0):!1;case"Escape":return r.touched?(this.store.set({timeDraft:null}),!0):!1;default:return!1}}firstTappableInBottomRow(e){let n=this.store.get();if(n.filteredOptions.length===0)return null;let i=Math.floor((n.filteredOptions.length-1)/e)*e;for(let o=i;o<n.filteredOptions.length;o++)if(n.filteredOptions[o]?.is_tappable)return o;return null}dateEntryIndex(e,n){let r=B(new Date),i=e.filteredOptions.findIndex(s=>Y(s)===r);if(i>=0)return i;let o=e.filteredOptions.map((s,a)=>s.is_tappable?a:-1).filter(s=>s!==-1);return(n?o[o.length-1]:o[0])??0}stepDateDay(e,n){for(let r=e.activeDropdownIndex+n;r>=0&&r<e.filteredOptions.length;r+=n)if(e.filteredOptions[r]?.is_tappable){this.store.set({activeDropdownIndex:r});return}}stepDateWeek(e,n){let r=e.activeDropdownIndex+n;this.store.set({activeDropdownIndex:e.filteredOptions[r]?.is_tappable?r:-1})}getTappableIndices(e){let r=this.store.get().filteredOptions.map((o,s)=>o.is_tappable?s:-1).filter(o=>o!==-1),i=Array.from({length:e},()=>[]);for(let o of r)i[o%e].push(o);return i.flat()}getEffectiveColumns(e){let n=Je(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let i=Je(e,`${this.ctx.listboxId}-option-0`)?.parentElement??null;for(;i;){let o=getComputedStyle(i).gridTemplateColumns;if(o&&o!=="none"){let s=o.split(" ").filter(Boolean).length;if(s>0)return s}if(i===n)break;i=i.parentElement}return this.ctx.columns}clickOrSelect(e,n,r,i){let o=Je(i,`${r}-option-${e}`);o?o.click():this.ctx.selectOption(n[e])}};var ut=class{constructor(e,n,r={}){this.store=e;this.getOverrides=n;this.callbacks=r;this.unsubscribe=null;this.current=null;this.version=0;this.lastMiss=null;this.hasLoggedError=!1}start(){this.unsubscribe=this.store.subscribe(e=>this.sync(e)),this.sync(this.store.get())}dispose(){this.unsubscribe?.(),this.unsubscribe=null,this.cancel(),this.current=null}reset(){this.cancel(),this.current=null,this.lastMiss=null}refresh(){this.reset(),this.sync(this.store.get())}hasOverride(e){return!!this.getOverrides()?.[e]}owns(e,n){return this.hasOverride(e)&&!this.missCovers(e,n)}tick(e,n){let r=this.resolveTarget(e);if(!r||this.missCovers(r.parameter,r.query))return"no";let i=this.current;if(i&&i.key===r.key){if(i.query===r.query)return"owns";let o=Math.abs(r.query.length-i.query.length),s=r.query.length<i.query.length;if(n>1&&!s&&o<n)return"owns"}return this.ask(r),"asked"}sync(e){let n=this.resolveTarget(e);if(!n){this.current&&(this.cancel(),this.current=null),e.optionSearch&&this.store.set({optionSearch:null});return}this.current&&this.current.key===n.key||this.ask(n)}resolveTarget(e){if(_(e.activeFormatType)||e.editingIdentified)return null;let n=e.editingParam;if(n&&e.editingAnchor!=null)return this.hasOverride(n.suggestionParameter)?{mode:"edit",key:n.id,parameter:n.suggestionParameter,suggestion:{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options},query:e.optionQuery}:null;let r=e.actionableSuggestions[0];return!r||!this.hasOverride(r.parameter)?null:{mode:"pill",key:r,parameter:r.parameter,suggestion:r,query:e.optionQuery}}missCovers(e,n){return this.lastMiss!=null&&this.lastMiss.parameter===e&&this.lastMiss.query===n}ask(e){this.cancel();let n=this.getOverrides()?.[e.parameter],r=++this.version;if(!n||this.missCovers(e.parameter,e.query)){this.current={key:e.key,parameter:e.parameter,query:e.query,abort:null},this.setSearch(e,"done");return}let i=new AbortController;this.current={key:e.key,parameter:e.parameter,query:e.query,abort:i};let o;try{o=n(e.query,i.signal,e.suggestion)}catch(s){this.logOnce(s),this.commit(e,[],r);return}if(Array.isArray(o)){this.commit(e,o,r);return}this.setSearch(e,"loading"),this.await(e,o,i.signal,r)}async await(e,n,r,i){let o;try{let s=await n;if(r.aborted||i!==this.version)return;o=Array.isArray(s)?s:[]}catch(s){if(r.aborted||i!==this.version||Jo(s))return;this.logOnce(s),o=[]}this.commit(e,o,i)}commit(e,n,r){if(r!==this.version)return;let i=this.resolveTarget(this.store.get());if(!i||i.key!==e.key)return;n.length===0?this.lastMiss={parameter:e.parameter,query:e.query}:this.lastMiss?.parameter===e.parameter&&(this.lastMiss=null);let o={parameter:e.parameter,query:e.query,status:"done"};if(e.mode==="edit")this.store.set(s=>({editingParam:s.editingParam&&s.editingParam.id===e.key?{...s.editingParam,options:n}:s.editingParam,optionSearch:o}));else{let s={...e.suggestion,options:n};this.current&&this.current.key===e.key&&(this.current.key=s),this.store.set(a=>({suggestions:a.suggestions.map(l=>l===e.suggestion?s:l),optionSearch:o}))}n.length===0?this.callbacks.onMiss?.(e.mode,e.query):this.callbacks.onAnswer?.(e.mode,e.query)}setSearch(e,n){let r=this.store.get().optionSearch;r&&r.parameter===e.parameter&&r.query===e.query&&r.status===n||this.store.set({optionSearch:{parameter:e.parameter,query:e.query,status:n}})}cancel(){this.current?.abort?.abort(),this.version++}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] an optionOverrides entry threw or rejected \u2014 treated as no options. Later failures on this instance are not logged.",e))}};function Jo(t){return t instanceof Error&&t.name==="AbortError"}var pt=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),r=n.suggestions.filter(d=>d.parameter!=="placeholder");if(e<0||e>=r.length)return;let i=r[e];if(P(i))return;let o=r.filter((d,c)=>c!==e),s=n.suggestions.filter(d=>d.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:d}=N(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:d,selectedPill:i.text,otherPills:o.map(c=>c.text)})}let a=[...s,i,...o],l=this.store.peek({suggestions:a}).filteredOptions.findIndex(d=>d.is_tappable);this.store.set({suggestions:a,pillTapped:!0,activeDropdownIndex:l})}removeLastParam(){this.store.get().completedParams.length!==0&&this.store.set(n=>({completedParams:n.completedParams.slice(0,-1),activeDropdownIndex:-1}))}};var Zr="/products/",Xr="https://relative.invalid";function Zo(t){if(!t)return;let e;try{e=new URL(t,`${Xr}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===Xr?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function ei(t,e){let n=Zo(t.item_url)??ts(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:Jr(t.price,t.currency,e)},...es(t)&&{compareAtPrice:Jr(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function es(t){if(!t.price||!t.compare_at_price)return!1;let e=Number(t.price),n=Number(t.compare_at_price);return Number.isFinite(e)&&Number.isFinite(n)&&n>e}function Jr(t,e,n){if(n===void 0||!e||!/^\d+(\.\d+)?$/.test(t))return t;try{return new Intl.NumberFormat(n,{style:"currency",currency:e}).format(Number(t))}catch{return t}}function ts(t){if(!t.handle)return;let e=`${Zr}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function Sn(t,e){return(t?.items.matched??[]).map(n=>ei(n,e))}var mt=class{constructor(e,n,r=()=>!0,i=()=>{},o=()=>{}){this.store=e;this.getConfig=n;this.isEnabled=r;this.getLanguage=i;this.getMapper=o;this.hasLoggedError=!1;this.hasLoggedMapperError=!1}forResponse(e){if(!this.isEnabled())return[];if(this.getConfig())return;let n=Sn(e,ie(this.getLanguage())),r=this.getMapper();if(!r)return n;try{let i=r(n,e?.items.matched??[]);if(Array.isArray(i))return i}catch(i){this.hasLoggedMapperError||(this.hasLoggedMapperError=!0,console.warn("[AIAutocomplete] mapProducts failed. The original cards are shown.",i))}return n}async run(e,n,r){if(!this.isEnabled())return;let i=this.getConfig();if(!i)return;if(e.trim().length===0){this.clear(r);return}let o=()=>n.aborted||!r()||!this.owns(i);try{let s=await i.fetch(e,n);if(o())return;let a=i.transform(s),l=Array.isArray(a)?a:[],d=i.limit!=null?l.slice(0,i.limit):l;if(o())return;this.commit(d)}catch(s){if(n.aborted||ns(s)||(this.logOnce(s),o()))return;this.clear(r)}}owns(e){return this.isEnabled()&&this.getConfig()===e}resync(){let e=this.forResponse(this.store.get().customFields);this.commit(e??[])}refresh(){if(this.getConfig())return;let e=this.forResponse(this.store.get().customFields);e!==void 0&&this.commit(e)}clear(e){e()&&this.commit([])}commit(e){e.length===0&&this.store.get().products.length===0||this.store.set({products:e})}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] products.fetch/transform failed \u2014 the product strip is hidden. Later failures on this instance are not logged.",e))}};function ns(t){return t instanceof Error&&t.name==="AbortError"}function rs(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function ti(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:ue.findIndex(n=>n.toLowerCase().startsWith(e))}function is(t,e,n){let r=new Date(n.getFullYear(),t,e);if(r.getMonth()!==t||r.getDate()!==e)return null;let i=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(r>=i)return r;let o=new Date(n.getFullYear()+1,t,e);return o.getMonth()===t&&o.getDate()===e?o:null}function ni(t,e,n){let r=new Date(t,e,n);return r.getMonth()===e&&r.getDate()===n?r:null}function Oe(t,e={}){if(!t)return null;let n=e.today??new Date,r=rs(t.trim().toLowerCase()).replace(/\s+/g," "),i=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(r);if(i){let l=ni(Number(i[1]),Number(i[2])-1,Number(i[3]));return l?B(l):null}let o=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(r);if(o){let l=ti(o[1]);if(l>=0)return gt(l,Number(o[2]),o[3],n)}let s=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(r);if(s){let l=ti(s[2]);if(l>=0)return gt(l,Number(s[1]),s[3],n)}let a=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(r);if(a){let l=Number(a[1]),d=Number(a[2]);return l>12&&d<=12?gt(d-1,l,a[3],n):d>12&&l<=12?gt(l-1,d,a[3],n):null}return null}function gt(t,e,n,r){if(n){if(n.length!==4)return null;let o=ni(Number(n),t,e);return o?B(o):null}let i=is(t,e,r);return i?B(i):null}function yn(t,e={}){let n=t.isoDate;return typeof n=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(n)?n:Oe(t.text,e)}var ii=" - ",Tn="aiaDateRangeStart",vn="aiaDateRangeEnd";function ke(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var xn=/^\d{4}-\d{2}-\d{2}$/;function ri(t){if(!xn.test(t))return null;let[e,n,r]=t.split("-").map(Number),i=new Date(e,n-1,r);return i.getMonth()===n-1&&i.getDate()===r?i:null}var os=/\s+(?:to|through|thru|until|til|till)\s+/g,ss=/[-–—]/g;function as(t){let e=[];for(let n of[os,ss]){n.lastIndex=0;let r=n.exec(t);for(;r!==null;)e.push([t.slice(0,r.index),t.slice(r.index+r[0].length)]),r=n.exec(t)}return e}function ft(t,e={}){if(!t)return null;let n=new Set,r=null;for(let[i,o]of as(t.trim())){let s=Oe(i.trim(),e);if(!s)continue;let a=Oe(o.trim(),e);!a||a<s||(n.add(`${s}|${a}`),r={start:s,end:a})}return n.size===1?r:null}function oi(t){let e=ri(t.start),n=ri(t.end);return!e||!n?"":t.start===t.end?pe(e):`${pe(e)}${ii}${pe(n)}`}function si(t,e){let n=ke(t,e);return{text:oi(n),is_tappable:!0,kind:null,metadata:{[Tn]:n.start,[vn]:n.end}}}function Le(t,e={}){let n=t?.metadata?.[Tn],r=t?.metadata?.[vn];return typeof n=="string"&&typeof r=="string"&&xn.test(n)&&xn.test(r)?ke(n,r):ft(t?.text,e)}var ht="(max-width: 768px)";var ls="var(--aia-option-row-height, 37px)",cs="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function ai(t,e){return e?En(1,Math.min(t,5)):En(1,Math.min(t,4))}function En(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${ls} + ${cs})`}}function wn(t,e){return!e&&t>=5}function Cn(t,e,n,r){if(!(!e&&t>=5&&ds(n,r))){let s=ai(t,e);return{...s,template:Pn(s.cols),scrollHintIndices:!e&&t>s.rows?[s.rows-1]:[]}}let o=6;return{...En(2,3),template:Pn(2),scrollHintIndices:t>o?[o-2,o-1]:[]}}function ds(t,e){return!t||t.length===0||e==null||e<=0||t.some(r=>r<=0)?!1:Math.ceil(Math.max(...t))*2<=e}function In(t){if(typeof document>"u")return null;let e=Array.from(t.querySelectorAll("[data-aia-option]"));if(e.length===0)return null;let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:-9999px;top:0;";for(let s of e){let a=s.cloneNode(!0);a.removeAttribute("id"),a.removeAttribute("role"),a.removeAttribute("aria-selected"),a.style.whiteSpace="nowrap",a.style.width="max-content",n.appendChild(a)}t.appendChild(n);let r=Array.from(n.children).map(s=>s.offsetWidth);n.remove();let i=getComputedStyle(t),o=t.clientWidth-(Number.parseFloat(i.paddingLeft)||0)-(Number.parseFloat(i.paddingRight)||0)-(Number.parseFloat(i.columnGap)||0);return{rowWidths:r,gridWidth:o}}function Pn(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function An(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(ht).matches}function On(t,e){return!t||t.length!==e.length?!1:t.every((n,r)=>n.text===e[r].text)}function li(t,e){let n=e.dropdownTrigger??"auto",r=e.closeDropdownOnBlur??!0,s=t.filteredOptionsLength>0||t.activePillHasNoOptions||t.hasProducts;if(t.inEditMode){let a=r?t.isFocused||t.dropdownHeld:!0;return s&&a}if(n==="auto"){let a=r?t.isFocused||t.dropdownHeld:!0,l=t.text.replace(/\s+$/,"").length,d=t.caretOffset==null||t.caretOffset>=l;return(s||t.isLoading)&&a&&d}return n==="manual"?(s||t.isLoading)&&t.pillTapped:!1}function U(t){if(t.editingIdentified){let{parameter:n,anchor:r}=t.editingIdentified;return`identified:${n}@${r}`}return t.editingParam!=null&&t.editingAnchor!=null?`edit:${t.editingParam?.id}`:`pill:${t.actionableSuggestions[0]?.parameter??""}`}function ci(t){if(!t)return qt();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function us(t){let e=Qe(t);return e?Fr(e):qt()}function di(t,e){let n=Ar(t.text,t.completedParams,t.identifiedParams),r=t.suggestions.filter(C=>C.parameter!=="placeholder"),i=r[0],o=t.suggestions.filter(C=>C.parameter==="placeholder").map(C=>C.text).join(" "),s=Z(t.text,Math.min(t.filterBase,t.text.length),o),l=s===0&&$e(t.text,t.completedParams.length,o)?"":Pe(t.text,s,t.filterInProgress),d=i?.options??[],c=t.editingParam!=null&&t.editingAnchor!=null,u,m,g,p;if(c&&t.editingParam&&t.editingAnchor!=null){let C=t.editingParam.id,A=t.completedParams.some(wo=>wo.id===C),xe=t.caretOffset??t.editingAnchor,ur=A?"":t.text.slice(t.editingAnchor,xe);m=ur.trim(),g=t.editingParam.options,p=t.editingParam.suggestionParameter,u=oe(t.editingParam.options,ur)}else m=l.trim(),g=d,p=i?.parameter,u=P(i)?d.map(C=>({...C,matchedText:t.text.slice(de(t.text,t.completedParams)),parameterLabel:vr(C.parameter)})):oe(d,l,t.traditionalAutocomplete);let h=t.optionSearch,x=h!=null&&p!=null&&h.parameter===p;x&&h.status==="done"&&h.query===m&&(u=g);let b=x&&h.status==="loading",f=e.showNonTappableOptions===!1;f&&(u=u.filter(C=>C.is_tappable));let S=t.editingIdentified,y=c?t.editingParam&&{type:t.editingParam.suggestionValueType}:i,w=S?S.format:K(y),v=c&&w==="date-range"?Le(t.editingParam):null,E=null,L=null;if(M(w)){let C=U({...t,actionableSuggestions:r}),A=t.dateViewMonth;E=A&&A.key===C?{year:A.year,month:A.month}:S?ci(S.iso):v?ci(v.start):us(t.editingParam?.text),u=zt(E);let xe=t.pendingRangeStart;w==="date-range"&&xe&&xe.key===C&&(L=xe.iso)}let I=null;if(w==="time"){let C=U({...t,actionableSuggestions:r}),A=t.timeDraft;I=A&&A.key===C?{minutes:A.minutes,touched:!0}:{minutes:Qr({editingText:c?t.editingParam?.text:null,options:c?t.editingParam?.options:i?.options}),touched:!1},u=[]}let O=C=>f?C.is_tappable:!0,W;if(c){let C=t.editingParam?.options??[];W=t.editingParam!=null&&C.filter(O).length===0}else W=i!=null&&d.filter(O).length===0;I&&(W=!0);let D=li({inEditMode:c||S!=null,filteredOptionsLength:u.length,isFocused:t.isFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||b,pillTapped:t.pillTapped,activePillHasNoOptions:W,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),Q=D&&t.activeDropdownIndex>=0&&!!u[t.activeDropdownIndex]?.is_tappable,T=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,R=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||b||T,X=R&&t.skeletonOptions!==null,Ft=X&&t.skeletonOptions?t.skeletonOptions:u,De=X?t.skeletonSuggestion:null;return{segments:n,actionableSuggestions:r,filteredOptions:u,dropdownLoading:R,dropdownOptions:Ft,dropdownSuggestion:De,skeletonExiting:T,activeFormatType:w,dateView:E,dateRangeStart:L,timeView:I,multiSelectView:!c&&!S&&i?.type?.kind==="multi_select"?{picked:t.multiSelectDraft?.key===U({...t,actionableSuggestions:r})?t.multiSelectDraft.picked:[]}:null,placeholderText:o,optionQuery:m,isSearchingOptions:b,isDropdownOpen:D,isActivePillSelected:Q}}function bt(t){return t.mode!=="edit"?ms(t):gs(t)}function ps(t,e,n){let r=t.find(P);if(!r?.options)return null;let i=e.slice(de(e,n)).trim().toLowerCase();if(!i)return null;let o=r.options.filter(l=>l.is_tappable&&l.text.trim().toLowerCase()===i);if(new Set(o.map(l=>q(l,r.parameter))).size!==1)return null;let a=o[0];return{suggestion:r,option:a,matchText:a.text.trim()}}function ui(t){let{text:e,suggestions:n,filterBase:r,filterInProgress:i,phraseExactMatch:o}=t,s=n.find(c=>c.parameter!=="placeholder"&&!P(c));if(!s?.options||s.type?.kind==="multi_select")return null;let a=n.filter(c=>c.parameter==="placeholder").map(c=>c.text).join(" "),l=Z(e,r,a),d=we(s.options,e,l,i,o===!0);return d?{suggestion:s,option:d,matchText:d.text}:null}function ms(t){let{text:e,completedParams:n,suggestions:r}=t,i=t.mode==="submit"?(t.finishWord?ui(t):null)??ps(r,e,n):ui(t);if(!i)return null;let{suggestion:o,option:s,matchText:a}=i,l=a.toLowerCase(),d=e.toLowerCase().lastIndexOf(l),c=d>=0?d:Math.max(0,e.length-s.text.length),u=c+a.length,m=e.slice(c,u),p=u<e.length&&e[u]===" "?u+1:u,h={id:crypto.randomUUID(),placeholder:"",parameter:q(s,o.parameter),text:m,value:s.value,kind:s.kind,suggestionParameter:o.parameter,suggestionValueType:o.type,suggestionPlaceholder:o.text,...t.mode==="submit"&&P(o)?Ce(q(s,o.parameter)):{},options:o.options??[],metadata:s.metadata,icon:s.icon,icon_svg:s.icon_svg,image_url:s.image_url};return{patch:{text:e,completedParams:[...n,h],suggestions:r.filter(x=>x!==o),filterBase:p,newParamId:h.id,caretOffset:p,activeDropdownIndex:-1},caretPos:p,option:s,suggestion:o}}function gs(t){let{text:e,completedParams:n,editingParam:r,editingAnchor:i,editingTail:o}=t;if(n.some(S=>S.id===r.id))return null;let s=e.slice(i,o),a=Ue(r.options,s);if(!a)return null;let l=a.text.toLowerCase(),d=s.toLowerCase().lastIndexOf(l),c=i+Math.max(0,d),u=c+a.text.length,m=e.slice(c,u),g=u<e.length&&e[u]===" "?u+1:u,p=e.length,h={id:crypto.randomUUID(),placeholder:"",...Ge(r,a),text:m,value:a.value,kind:a.kind,options:r.options,metadata:a.metadata,icon:a.icon,icon_svg:a.icon_svg,image_url:a.image_url},x=n.length,b=0;for(let S=0;S<n.length;S++){let y=z(e,n[S].text,b);if(y!==-1){if(y>=g){x=S;break}b=y+n[S].text.length}}let f=[...n];return f.splice(x,0,h),{patch:{text:e,completedParams:f,newParamId:h.id,filterBase:p,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:p,activeDropdownIndex:-1},caretPos:p,option:a}}function pi(t){return t.slice(t.search(/\S*$/))}function mi(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function gi(t,e){let n="",r=0;for(let i of t){if(n+=mi(i),r+=i.length,n.length>=e.length)return n.startsWith(e)?r+(t.slice(r).match(/^\p{M}*/u)?.[0].length??0):0;if(!e.startsWith(n))return 0}return 0}function kn(t){return[...t].map(mi).join("")}function St(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(kn),r=[...t.matchAll(/\S+/g)].map(i=>({index:i.index??0,text:i[0],folded:kn(i[0])}));for(let i=n.length;i>=1;i--){let o=n.slice(n.length-i),s=o[i-1];for(let a=0;a+i<=r.length;a++){if(!o.slice(0,-1).every((u,m)=>r[a+m].folded===u))continue;let d=r[a+i-1],c=gi(d.text,s);if(c>0)return{typedWords:i,start:r[a].index,end:d.index+c}}}return null}function Ln(t,e){let n=e?St(t,e):null;if(n&&n.typedWords>1)return[{text:t.slice(0,n.start),bold:!1},{text:t.slice(n.start,n.end),bold:!0},{text:t.slice(n.end),bold:!1}].filter(s=>s.text!=="");let r=e?pi(e):"",i=kn(r);if(!i)return[{text:t,bold:!1}];let o=[];for(let s of t.split(/(\s+)/)){if(s==="")continue;let a=/^\s/.test(s)?0:gi(s,i);a>0&&o.push({text:s.slice(0,a),bold:!0});let l=a>0?s.slice(a):s;l&&o.push({text:l,bold:!1})}return o}var fs=6e4;function hs(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function bs(t){return(t??J).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function Ss(t){return Te(t)?`Bearer ${await Fe(t).getToken()}`:Be(t)}async function fi(t){try{let e=bs(t.apiConfig?.endpoint),n=We(t.apiConfig),r=await Ss(t.apiConfig);r&&(n.Authorization=r);let i=JSON.stringify({source:t.source,session_id:t.sessionId,...t.visitorId&&{visitor_id:t.visitorId},...t.requestId&&{request_id:t.requestId},type:t.type,...t.language&&{language:t.language},at:new Date().toISOString(),query_data:t.queryData});await fetch(e,{method:"POST",headers:n,body:i,...t.keepalive&&hs(i)<=fs&&{keepalive:!0}})}catch{}}function te(t,e){let n=t.findIndex(r=>r.text===e);return n>=0?n+1:null}var Mn=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function ys(t,e,n){let r=Mn(t??"");if(r.length===0)return"";let o=Mn(e).slice(-r.length),s=Mn(n).slice(0,r.length);return o.join(" ")===r.join(" ")||s.join(" ")===r.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function hi(t,e){let n=t.actionableSuggestions[0];if(!n)return null;let r=P(n),i=e.parameter;if(r&&!i)return null;let o=r&&i?i:q(e,n.parameter),s=r?t.text.length:t.filterBase,a=t.text.slice(0,s),l=a.length===0&&t.text.length===0,d=a.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||d)&&t.placeholderText&&(a=`${t.placeholderText} `);let c=Math.min(de(t.text,t.completedParams),a.length);if(r){let v=[...a.slice(c).matchAll(/\S+/g)],E=St(e.text,a.slice(c)),L=v[v.length-(E?.typedWords??1)];a=a.slice(0,L?c+(L.index??0):Math.max(a.lastIndexOf(" ")+1,c))}else if(n.completes_word===!0){let v=[...a.slice(c).matchAll(/\S+/g)],E=v[v.length-1];a=a.slice(0,E?c+(E.index??0):Math.max(a.lastIndexOf(" ")+1,c))}else if(n.completes_word!==!1){let v=yr(a.slice(c),e.text);v>0&&(a=a.slice(0,a.length-v))}let u=a.length>0&&a[a.length-1]!==" ",g=_(K(n))||n.type?.kind==="multi_select"?ys(n.lead_in,a,e.text):"",p=`${a}${u?" ":""}${g?`${g} `:""}${e.text} `,x=(l||d||r&&a.length===0)&&p.length>0?p[0].toUpperCase()+p.slice(1):p,b=x.toLowerCase().lastIndexOf(e.text.toLowerCase()),f=b>=0?x.slice(b,b+e.text.length):e.text,S=r?Ce(o):{parameter:o,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text},y={id:crypto.randomUUID(),placeholder:"",...S,text:f,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},w=t.actionableSuggestions.length-1;return{patch:{text:x,filterBase:x.length,completedParams:[...t.completedParams,y],newParamId:y.id,caretOffset:x.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(v=>v.text!==e.text).map(v=>v.text),key:r?o:n.parameter,position:te(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:w}}function yt(t){let e=_(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,n=t.editingParam,r=n?{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options}:t.actionableSuggestions[0]??null;return{skeletonOptions:e,skeletonSuggestion:e?r:null,skeletonRequested:!1}}function xt(t,e,n){let r=t.slice(0,e),i=t.slice(n),o=(r===""||r.endsWith(" "))&&i.startsWith(" ");return o&&(i=i.slice(1)),{text:r+i,removed:n-e+(o?1:0)}}var Tt=class{constructor(e){this.deps=e}start(e){let n=this.deps.store.get();if(n.editingParam?.id===e)return;let r=n.completedParams.find(s=>s.id===e);if(!r)return;let i=0,o=-1;for(let s of n.completedParams){let a=z(n.text,s.text,i);if(a!==-1){if(s.id===e){o=a;break}i=a+s.text.length}}o<0||this.deps.store.set({editingParam:r,editingAnchor:o,editingTail:o+r.text.length,caretOffset:o+r.text.length,activeDropdownIndex:-1,editingIdentified:null})}exit(){this.deps.store.get().editingParam&&this.deps.store.set({editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1})}replaceRange(e){let n=this.deps.store.get(),r=n.editingParam,i=n.editingAnchor,o=n.editingTail;if(!r||i==null||o==null||!n.completedParams.some(l=>l.id===r.id))return!1;let{text:s}=e===""?xt(n.text,i,o):{text:n.text.slice(0,i)+e+n.text.slice(o)},a=i+e.length;return this.deps.store.set(l=>({text:s,completedParams:l.completedParams.filter(d=>d.id!==r.id),editingTail:a,caretOffset:a,activeDropdownIndex:-1})),this.deps.scheduleSetCursor(a),this.promoteIfExact(),!0}caretAfterInput(e){let n=this.deps.store.get(),r={caretOffset:e};n.editingParam&&n.editingAnchor!=null&&e!=null&&(e<n.editingAnchor?(r.editingParam=null,r.editingAnchor=null,r.editingTail=null,r.activeDropdownIndex=-1):n.editingTail!=null&&(r.editingTail=Math.max(n.editingTail,e))),this.deps.store.set(r),this.promoteIfExact()}caretMove(e){let n=this.deps.store.get();if(n.editingParam&&n.editingAnchor!=null&&n.editingTail!=null&&e!=null&&(e<n.editingAnchor||e>n.editingTail)){this.deps.store.set({caretOffset:e,editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1});return}this.deps.store.set({caretOffset:e})}selectOption(e){let n=this.deps.store.get(),r=n.editingParam,i=n.editingAnchor,o=n.editingTail;if(!r||i==null||o==null)return;let s=Ge(r,e);this.deps.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:r.options.filter(f=>f.text!==e.text).map(f=>f.text),key:s.suggestionParameter,position:te(r.options,e.text),chip_origin:"tap"});let a=n.text.slice(0,i),l=n.text.slice(o),d=i===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,u=l.length===0||l[0]!==" "?`${d} `:d,m=a+u+l,g=m.length,p={id:crypto.randomUUID(),placeholder:"",...s,text:d,value:e.value,kind:e.kind,options:r.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},h=n.completedParams.findIndex(f=>f.id===r.id),x=n.completedParams.filter(f=>f.id!==r.id),b=h>=0?Math.min(h,x.length):x.length;x.splice(b,0,p),this.deps.store.set({text:m,completedParams:x,newParamId:p.id,filterBase:g,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:g,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...yt(n)}),this.deps.startSelectionAnimationTimer(),this.deps.scheduleSetCursor(g),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=bt({mode:"edit",text:e.text,completedParams:e.completedParams,editingParam:e.editingParam,editingAnchor:e.editingAnchor,editingTail:e.editingTail});n&&(this.deps.store.set(n.patch),this.deps.scheduleSetCursor(n.caretPos))}};var xs=33,Ts=70,vs=120,Es=50,he="data-aia-placeholder-leaving",be=new WeakMap;function vt(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function Ps(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Si(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function yi(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Si(t,e,e.shown+1),e.shown>=e.target.length))return;let n=e.target[e.shown-1],r=n===" "||n==="-"?70:0;e.timer=setTimeout(()=>yi(t,e),33+r)}function bi(t,e){Si(t,e,0),e.timer=setTimeout(()=>yi(t,e),33)}function xi(t,e){let n=be.get(t);if(e===""){n&&(vt(n),be.delete(t)),t.removeAttribute(he),delete t.dataset.placeholder;return}if(n?.target===e)return;if(Ps(t)){n&&vt(n),t.removeAttribute(he),be.set(t,{target:e,shown:e.length,timer:null}),t.dataset.placeholder=e;return}let r={target:e,shown:0,timer:null},i=n&&n.shown>0?n:null;if(n&&vt(n),be.set(t,r),i){t.setAttribute(he,""),r.timer=setTimeout(()=>{r.timer=null,t.removeAttribute(he),t.isConnected&&bi(t,r)},170);return}t.removeAttribute(he),bi(t,r)}function Ti(t){let e=be.get(t);e&&(vt(e),be.delete(t))}var vi="https://ai-autocomplete.com";function Rn(t=vi){try{if(typeof window>"u"||!window.location)return t;let e=window.location.hostname;if(!e)return t;let n=new URL(t);return n.searchParams.set("utm_source",e),n.toString()}catch{return t}}var Ei={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Products",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",timeLabel:"Time"},ws={language:"es",and:"y",proceed:"para continuar",select:"para seleccionar",skipHint:"para omitir",skip:"omitir",skipLabel:"Omitir",products:"Productos",soldOut:"Agotado",addToCart:"A\xF1adir al carrito",submit:"Buscar",scrollArrow:"Despl\xE1zate para ver m\xE1s opciones",keepTyping:"Sigue escribiendo",done:"Listo",timeLabel:"Hora"},_n={en:Ei,es:ws,fr:{language:"fr",and:"et",proceed:"pour continuer",select:"pour s\xE9lectionner",skipHint:"pour passer",skip:"passer",skipLabel:"Passer",products:"Produits",soldOut:"\xC9puis\xE9",addToCart:"Ajouter au panier",submit:"Rechercher",scrollArrow:"Faites d\xE9filer pour voir plus d\u2019options",keepTyping:"Continuez \xE0 taper",done:"Termin\xE9",timeLabel:"Heure"},"pt-BR":{language:"pt-BR",and:"e",proceed:"para continuar",select:"para selecionar",skipHint:"para pular",skip:"pular",skipLabel:"Pular",products:"Produtos",soldOut:"Esgotado",addToCart:"Adicionar ao carrinho",submit:"Buscar",scrollArrow:"Role para ver mais op\xE7\xF5es",keepTyping:"Continue digitando",done:"Conclu\xEDdo",timeLabel:"Hor\xE1rio"},it:{language:"it",and:"e",proceed:"per continuare",select:"per selezionare",skipHint:"per saltare",skip:"salta",skipLabel:"Salta",products:"Prodotti",soldOut:"Esaurito",addToCart:"Aggiungi al carrello",submit:"Cerca",scrollArrow:"Scorri per vedere altre opzioni",keepTyping:"Continua a scrivere",done:"Fatto",timeLabel:"Ora"},tr:{language:"tr",and:"ve",proceed:"devam etmek i\xE7in",select:"se\xE7mek i\xE7in",skipHint:"atlamak i\xE7in",skip:"atla",skipLabel:"Atla",products:"\xDCr\xFCnler",soldOut:"T\xFCkendi",addToCart:"Sepete ekle",submit:"Ara",scrollArrow:"Daha fazla se\xE7enek i\xE7in kayd\u0131r",keepTyping:"Yazmaya devam et",done:"Tamam",timeLabel:"Saat"},id:{language:"id",and:"dan",proceed:"untuk melanjutkan",select:"untuk memilih",skipHint:"untuk melewati",skip:"lewati",skipLabel:"Lewati",products:"Produk",soldOut:"Habis",addToCart:"Tambah ke keranjang",submit:"Cari",scrollArrow:"Gulir untuk melihat opsi lainnya",keepTyping:"Teruskan mengetik",done:"Selesai",timeLabel:"Waktu"},pl:{language:"pl",and:"i",proceed:"aby kontynuowa\u0107",select:"aby wybra\u0107",skipHint:"aby pomin\u0105\u0107",skip:"pomi\u0144",skipLabel:"Pomi\u0144",products:"Produkty",soldOut:"Wyprzedane",addToCart:"Dodaj do koszyka",submit:"Szukaj",scrollArrow:"Przewi\u0144, aby zobaczy\u0107 wi\u0119cej opcji",keepTyping:"Pisz dalej",done:"Gotowe",timeLabel:"Godzina"},de:{language:"de",and:"und",proceed:"zum Fortfahren",select:"zum Ausw\xE4hlen",skipHint:"zum \xDCberspringen",skip:"\xFCberspringen",skipLabel:"\xDCberspringen",products:"Produkte",soldOut:"Ausverkauft",addToCart:"In den Warenkorb",submit:"Suchen",scrollArrow:"Scrolle f\xFCr weitere Optionen",keepTyping:"Weitertippen",done:"Fertig",timeLabel:"Uhrzeit"},nl:{language:"nl",and:"en",proceed:"om door te gaan",select:"om te selecteren",skipHint:"om over te slaan",skip:"overslaan",skipLabel:"Overslaan",products:"Producten",soldOut:"Uitverkocht",addToCart:"In winkelwagen",submit:"Zoeken",scrollArrow:"Scrol voor meer opties",keepTyping:"Blijf typen",done:"Klaar",timeLabel:"Tijd"},sv:{language:"sv",and:"och",proceed:"f\xF6r att forts\xE4tta",select:"f\xF6r att v\xE4lja",skipHint:"f\xF6r att hoppa \xF6ver",skip:"hoppa \xF6ver",skipLabel:"Hoppa \xF6ver",products:"Produkter",soldOut:"Sluts\xE5ld",addToCart:"L\xE4gg i varukorgen",submit:"S\xF6k",scrollArrow:"Skrolla f\xF6r fler alternativ",keepTyping:"Forts\xE4tt skriva",done:"Klar",timeLabel:"Tid"},nb:{language:"nb",and:"og",proceed:"for \xE5 fortsette",select:"for \xE5 velge",skipHint:"for \xE5 hoppe over",skip:"hopp over",skipLabel:"Hopp over",products:"Produkter",soldOut:"Utsolgt",addToCart:"Legg i handlekurven",submit:"S\xF8k",scrollArrow:"Rull ned for \xE5 se flere alternativer",keepTyping:"Fortsett \xE5 skrive",done:"Ferdig",timeLabel:"Tid"},da:{language:"da",and:"og",proceed:"for at forts\xE6tte",select:"for at v\xE6lge",skipHint:"for at springe over",skip:"spring over",skipLabel:"Spring over",products:"Produkter",soldOut:"Udsolgt",addToCart:"L\xE6g i kurv",submit:"S\xF8g",scrollArrow:"Rul for flere muligheder",keepTyping:"Forts\xE6t med at skrive",done:"F\xE6rdig",timeLabel:"Tidspunkt"},fi:{language:"fi",and:"ja",proceed:"jatkaaksesi",select:"valitaksesi",skipHint:"ohittaaksesi",skip:"ohita",skipLabel:"Ohita",products:"Tuotteet",soldOut:"Loppuunmyyty",addToCart:"Lis\xE4\xE4 ostoskoriin",submit:"Hae",scrollArrow:"Vierit\xE4 n\xE4hd\xE4ksesi lis\xE4\xE4 vaihtoehtoja",keepTyping:"Jatka kirjoittamista",done:"Valmis",timeLabel:"Aika"},ja:{language:"ja",and:"\u3068",proceed:"\u3067\u6B21\u3078",select:"\u3067\u9078\u629E",skipHint:"\u3067\u30B9\u30AD\u30C3\u30D7",skip:"\u30B9\u30AD\u30C3\u30D7",skipLabel:"\u30B9\u30AD\u30C3\u30D7",products:"\u5546\u54C1",soldOut:"\u58F2\u308A\u5207\u308C",addToCart:"\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",submit:"\u691C\u7D22",scrollArrow:"\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u3066\u4ED6\u306E\u5019\u88DC\u3092\u898B\u308B",keepTyping:"\u5165\u529B\u3092\u7D9A\u3051\u308B",done:"\u5B8C\u4E86",timeLabel:"\u6642\u523B"},ko:{language:"ko",and:"\uBC0F",proceed:"\uACC4\uC18D",select:"\uC120\uD0DD",skipHint:"\uAC74\uB108\uB6F0\uAE30",skip:"\uAC74\uB108\uB6F0\uAE30",skipLabel:"\uAC74\uB108\uB6F0\uAE30",products:"\uC0C1\uD488",soldOut:"\uD488\uC808",addToCart:"\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uB2F4\uAE30",submit:"\uAC80\uC0C9",scrollArrow:"\uB354 \uB9CE\uC740 \uC635\uC158\uC744 \uBCF4\uB824\uBA74 \uC2A4\uD06C\uB864\uD558\uC138\uC694",keepTyping:"\uACC4\uC18D \uC785\uB825\uD558\uC138\uC694",done:"\uC644\uB8CC",timeLabel:"\uC2DC\uAC04"},"zh-CN":{language:"zh-CN",and:"\u548C",proceed:"\u7EE7\u7EED",select:"\u9009\u62E9",skipHint:"\u8DF3\u8FC7",skip:"\u8DF3\u8FC7",skipLabel:"\u8DF3\u8FC7",products:"\u5546\u54C1",soldOut:"\u552E\u7F44",addToCart:"\u52A0\u5165\u8D2D\u7269\u8F66",submit:"\u641C\u7D22",scrollArrow:"\u5411\u4E0B\u6EDA\u52A8\u67E5\u770B\u66F4\u591A\u9009\u9879",keepTyping:"\u7EE7\u7EED\u8F93\u5165",done:"\u5B8C\u6210",timeLabel:"\u65F6\u95F4"},"zh-TW":{language:"zh-TW",and:"\u548C",proceed:"\u7E7C\u7E8C",select:"\u9078\u64C7",skipHint:"\u7565\u904E",skip:"\u7565\u904E",skipLabel:"\u7565\u904E",products:"\u5546\u54C1",soldOut:"\u552E\u5B8C",addToCart:"\u52A0\u5165\u8CFC\u7269\u8ECA",submit:"\u641C\u5C0B",scrollArrow:"\u5411\u4E0B\u6372\u52D5\u67E5\u770B\u66F4\u591A\u9078\u9805",keepTyping:"\u7E7C\u7E8C\u8F38\u5165",done:"\u5B8C\u6210",timeLabel:"\u6642\u9593"}},Cs={pt:"pt-BR",no:"nb",nn:"nb"};function k(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let i=n.some(o=>["hant","tw","hk","mo"].includes(o));return _n[i?"zh-TW":"zh-CN"]}let r=Cs[e]??e;return Object.prototype.hasOwnProperty.call(_n,r)?_n[r]:Ei}function Dn(t,e,n=k()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function Nn(t){let e=s=>{s.ctrlKey||Pi(s.target,t,s.deltaX,s.deltaY)||s.preventDefault()},n=0,r=0,i=s=>{let a=s.touches[0];a&&(n=a.clientX,r=a.clientY)},o=s=>{if(s.touches.length!==1)return;let a=s.touches[0],l=n-a.clientX,d=r-a.clientY;n=a.clientX,r=a.clientY,s.cancelable&&!Pi(s.target,t,l,d)&&s.preventDefault()};return t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("touchstart",i,{passive:!0}),t.addEventListener("touchmove",o,{passive:!1}),()=>{t.removeEventListener("wheel",e),t.removeEventListener("touchstart",i),t.removeEventListener("touchmove",o)}}function Pi(t,e,n,r){let i=t instanceof Element?t:null;for(;i;){if(r!==0&&Is(i,r)||n!==0&&As(i,n))return!0;if(i===e)break;i=i.parentElement}return!1}var wi=/^(auto|scroll|overlay)$/;function Is(t,e){return t.scrollHeight<=t.clientHeight||!wi.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function As(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!wi.test(n.overflowX))return!1;let r=Math.abs(t.scrollLeft),i=t.scrollWidth-t.clientWidth;return(n.direction==="rtl"?e<0:e>0)?r<i-1:r>0}var Ci=new WeakMap,Ii=new WeakSet;function $(t,e,n){if(Ci.set(t,n),Ii.has(t))return;Ii.add(t);let r=()=>Ci.get(t),i=o=>{if(!(o instanceof Element))return null;let s=o.closest(e.itemSelector);return s&&t.contains(s)?s:null};e.onClick&&t.addEventListener("click",o=>{let s=i(o.target);s&&e.onClick?.(s,r(),o)}),e.onEnter&&t.addEventListener("mouseenter",o=>{let s=o.target;s instanceof HTMLElement&&s.matches(e.itemSelector)&&e.onEnter?.(s,r())},!0),e.onLeave&&t.addEventListener("mouseleave",o=>{let s=o.target;s instanceof HTMLElement&&s.matches(e.itemSelector)&&e.onLeave?.(s,r())},!0),e.preventMousedown&&t.addEventListener("mousedown",o=>o.preventDefault())}function ne(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function G(t){t.offsetWidth}var Os={selectedIso:null,selectedRange:null,rangeStart:null};function Me(t){if(!M(t.activeFormatType))return Os;let e=t.editingIdentified;if(e){let{iso:r,isoEnd:i}=e;return{selectedIso:i?null:r,selectedRange:r&&i?ke(r,i):null,rangeStart:t.dateRangeStart}}let n=Le(t.editingParam);return{selectedIso:n?null:jt(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart}}function Hn(t){return t.pendingStart?ke(t.pendingStart,t.highlightedIso??t.pendingStart):t.selected}function Fn(t,e){if(t==null)return{selected:!1,inRange:!1};let{selectedIso:n,range:r}=e,i=t===n||r!=null&&(t===r.start||t===r.end),o=r!=null&&t>r.start&&t<r.end;return{selected:i,inRange:o}}var Ai="data-aia-key";function re(t,e,n){let r=new Map;for(let s of Array.from(t.children)){let a=s.getAttribute(Ai);a!=null&&r.set(a,s)}let i=new Set,o=[];for(let s=0;s<e.length;s++){let a=e[s],l=n.keyOf(a,s);i.add(l);let d=r.get(l);d||(d=n.create(a,s),d.setAttribute(Ai,l)),n.update?.(d,a,s),t.children[s]!==d&&t.insertBefore(d,t.children[s]??null),o.push(d)}for(let[s,a]of r)i.has(s)||a.remove();return o}function Oi(t,e){if(!e.interactive)return null;let n=e.options[ne(t)];return n?.is_tappable?n:null}var ks={itemSelector:"[data-aia-date-cell], [data-aia-date-prev], [data-aia-date-next]",onClick:(t,e)=>{if(t.hasAttribute("data-aia-date-prev")){e.callbacks.onPreviousMonth();return}if(t.hasAttribute("data-aia-date-next")){e.callbacks.onNextMonth();return}let n=Oi(t,e);n&&(t.classList.add("magicx-aia-date-cell--pressed"),e.callbacks.onSelect(n),setTimeout(()=>t.classList.remove("magicx-aia-date-cell--pressed"),170))},onEnter:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&Oi(t,e)&&e.callbacks.onHighlight(ne(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,ne(t))}};function Li(t,e,n,r,i,o,s,a=!0){let l=t.querySelector(".magicx-aia-datepicker");if(!i||e.length===0){l?.remove();return}if(!l){l=Rs(),t.appendChild(l),G(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}$(l,ks,{options:e,callbacks:s,interactive:a});let d=l.querySelector(".magicx-aia-datepicker-month");d&&(d.textContent=Gt(i));let c=l.querySelector(".magicx-aia-datepicker-grid");c&&Ls(c,e,n,r,o)}function Ls(t,e,n,r,i){let o=B(new Date),s=Hn({pendingStart:i.rangeStart,highlightedIso:Y(e[n]),selected:i.selectedRange});re(t,e,{keyOf:(a,l)=>Y(a)??`pad-${l}`,create:a=>Ms(a),update:(a,l,d)=>{let c=Y(l),u=Fn(c,{selectedIso:i.selectedIso,range:s}),m=d===n&&l.is_tappable;a.id=`${r}-option-${d}`,a.dataset.aiaIndex=String(d),a.setAttribute("aria-selected",String(m)),a.classList.toggle("magicx-aia-date-cell--past",c!=null&&c<o),a.classList.toggle("magicx-aia-date-cell--highlighted",m),a.classList.toggle("magicx-aia-date-cell--today",c!=null&&c===o),a.classList.toggle("magicx-aia-date-cell--selected",u.selected),a.classList.toggle("magicx-aia-date-cell--in-range",u.inRange)}})}function Ms(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=Yt(t);if(n==null)return e.className="magicx-aia-date-cell magicx-aia-date-cell--blank",e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e;e.className="magicx-aia-date-cell magicx-aia-date-cell--day",e.tabIndex=0,e.setAttribute("aria-label",t.text);let r=document.createElement("span");return r.className="magicx-aia-date-cell-number",r.textContent=String(n),e.appendChild(r),e}function Rs(){let t=document.createElement("div");t.className="magicx-aia-datepicker",t.setAttribute("data-aia-datepicker","");let e=document.createElement("div");e.className="magicx-aia-datepicker-header";let n=document.createElement("span");n.className="magicx-aia-datepicker-month",n.setAttribute("data-aia-date-month",""),n.setAttribute("aria-live","polite"),e.append(ki("prev","Previous month","\u2039"),n,ki("next","Next month","\u203A"));let r=document.createElement("div");r.className="magicx-aia-datepicker-weekdays",r.setAttribute("aria-hidden","true");for(let o of Ye){let s=document.createElement("span");s.className="magicx-aia-datepicker-weekday",s.textContent=o,r.appendChild(s)}let i=document.createElement("div");return i.className="magicx-aia-datepicker-grid",i.setAttribute("data-aia-date-grid",""),t.append(e,r,i),t}function ki(t,e,n){let r=document.createElement("button");return r.type="button",r.tabIndex=-1,r.className="magicx-aia-datepicker-nav",r.setAttribute(`data-aia-date-${t}`,""),r.setAttribute("aria-label",e),r.textContent=n,r.disabled=!0,r}var _s={itemSelector:"[data-aia-pill]",onClick:(t,e)=>{if(e.loading||t.disabled)return;let n=Number.parseInt(t.dataset.aiaPillIndex??"-1",10);n>=0&&e.onSelectPill(n)},preventMousedown:!0},Mi=[125,69];function Ri(t,e){return e?1:t===0?.7:t===1?.4:.2}function Et(t,e,n,r,i=!1,o=!1,s=!1){let a=t.querySelector(".magicx-aia-pill-list");if(a||(a=document.createElement("span"),a.className="magicx-aia-pill-list",t.appendChild(a)),$(a,_s,{onSelectPill:r,loading:o}),o&&e.length===0){a.setAttribute("data-aia-pill-list-loading",""),a.innerHTML="";for(let l=0;l<Mi.length;l++){let d=Mi[l],c=document.createElement("span");c.setAttribute("data-aia-pill-skeleton",""),c.className=`magicx-aia-pill magicx-aia-pill--skeleton${i?" magicx-aia-pill--rounded":""}`,c.style.width=`${d}px`,c.style.opacity=String(Ri(l,!1)),a.appendChild(c)}return}o?a.setAttribute("data-aia-pill-list-loading",""):a.removeAttribute("data-aia-pill-list-loading");for(let l of a.querySelectorAll("[data-aia-pill-skeleton]"))l.remove();re(a,e,{keyOf:l=>`${l.type?.kind??""}|${qe(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let d=document.createElement("button");if(d.type="button",d.tabIndex=-1,d.setAttribute("data-aia-pill",""),d.setAttribute("contenteditable","false"),qe(l)){d.setAttribute("data-aia-smart-suggestion",P(l)?"header":"");let c=document.createElement("span");c.className="magicx-aia-smart-suggestion-text",c.textContent=l.text;let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-sparkle",u.innerHTML=Vt,d.append(c,u)}else d.textContent=l.text;return d.disabled=!0,d},update:(l,d,c)=>{let u=l,m=s&&c===n&&!o,g=["magicx-aia-pill"];i&&g.push("magicx-aia-pill--rounded"),o&&g.push("magicx-aia-pill--skeleton"),u.className=g.join(" "),u.style.width="",u.style.opacity=String(Ri(c,m)),u.dataset.aiaPillIndex=String(c),o?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),G(a);for(let l of a.querySelectorAll("[data-aia-pill]"))l.disabled=o}function Wn(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var Ds=32;function _i(t,e){if(e.ctrlKey)return null;let n=e.deltaY||0,r=e.deltaX||0;if(!n||Math.abs(r)>=Math.abs(n))return null;let i=t.scrollWidth-t.clientWidth;if(i<=1)return null;let o=t.scrollLeft,s=n;return e.deltaMode===1?s*=32:e.deltaMode===2&&(s*=t.clientWidth),Math.max(0,Math.min(i,o+s))}function Bn(t){let e=n=>{let r=_i(t,n);r!==null&&(n.preventDefault(),t.scrollLeft=r)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var Di=Intl.Segmenter,Ni=Di?new Di(void 0,{granularity:"grapheme"}):null;function Vn(t){let e=t.trim().normalize("NFC").toUpperCase();if(Ni)for(let n of Ni.segment(e))return n.segment;return Array.from(e)[0]??"?"}var Un=120,Ns=360;function Hs(t){let e=t.pathname;return t.hostname==="cdn.shopify.com"&&e.startsWith("/s/files/")||e.startsWith("/cdn/shop/")?/\.png$/i.test(e)?{format:"pjpg"}:/\.webp$/i.test(e)?{format:null}:null:null}function Hi(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let r=Hs(n);return r?(n.searchParams.set("width",String(e)),r.format&&n.searchParams.set("format",r.format),t.startsWith("/")&&!t.startsWith("//")?`${n.pathname}${n.search}${n.hash}`:n.href):t}function $n(t,e){let n=Hi(t,e);return n===t?[t]:[n,t]}function Gn(t,e){if(!(t>0)||!(e>0))return null;let n=t/e,r=i=>Math.round(i*1e3)/1e3;return{x:r(Math.min(n,1)),y:r(Math.min(1/n,1))}}function Pt(t){let e=t?.trim();return e?$n(e,360):[]}function Fs(t){return Pt(t)[0]}var wt=new WeakMap,Kn=new WeakMap,Wi=new WeakMap;function Bi(t,e,n,r,i,o="row",s="image",a=k(),l){let d=t.querySelector(".magicx-aia-products");if(e.length===0){d?.remove();return}if(!d){d=document.createElement("section"),d.className="magicx-aia-products",d.setAttribute("data-aia-products",""),d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${n}-products-label`);let m=document.createElement("div");m.className="magicx-aia-products-label",m.id=`${n}-products-label`,m.setAttribute("data-aia-products-label",""),m.textContent=a.products;let g=document.createElement("div");g.className="magicx-aia-products-row",g.setAttribute("data-aia-products-row",""),Bn(g),d.append(m,g),t.appendChild(d)}d.setAttribute("data-aia-products-layout",o);let c=d.querySelector(".magicx-aia-products-label");c&&c.textContent!==a.products&&(c.textContent=a.products);let u=d.querySelector(".magicx-aia-products-row");if(u){re(u,e,{keyOf:m=>Us(m,!!l),create:m=>$s(m,r,i,s,a,l),update:(m,g,p)=>{wt.set(m,g),Ws(m,g.price,g.compareAtPrice),m.id=`${n}-product-${p}`,m.dataset.aiaIndex=String(p),Wi.get(m)?.(s);let h=m.querySelector(".magicx-aia-product-badge");h&&h.textContent!==a.soldOut&&(h.textContent=a.soldOut);let x=m.querySelector(".magicx-aia-product-cart");x&&x.setAttribute("aria-label",Vi(g,a))}}),G(u);for(let m of u.querySelectorAll("[data-aia-product]")){let g=Kn.get(m);g&&(Kn.delete(m),g())}}}function zn(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let r of n)r.tabIndex=e?0:-1}function Ws(t,e,n){let r=t.querySelector(".magicx-aia-product-price");if(!e){r?.remove();return}r||(r=document.createElement("span"),r.className="magicx-aia-product-price",r.append(document.createTextNode("")),t.querySelector(".magicx-aia-product-title")?.after(r));let i=r.firstChild;i.data!==e&&(i.data=e);let o=r.querySelector(".magicx-aia-product-compare-at");if(!n){o?.remove();return}o||(o=document.createElement("s"),o.className="magicx-aia-product-compare-at",r.append(o)),o.textContent!==n&&(o.textContent=n)}function Fi(t,e){e?(t.style.setProperty("--aia-product-photo-fill-x",String(e.x)),t.style.setProperty("--aia-product-photo-fill-y",String(e.y))):(t.style.removeProperty("--aia-product-photo-fill-x"),t.style.removeProperty("--aia-product-photo-fill-y"))}function Vi(t,e){return`${e.addToCart}: ${t.title}`}var qn="http://www.w3.org/2000/svg";function Bs(){let t=document.createElementNS(qn,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false");let e=[["magicx-aia-product-cart-glyph","M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"],["magicx-aia-product-cart-glyph","M13.5 6.5v-4M11.5 4.5h4"],["magicx-aia-product-cart-check","M5 12.5l4.5 4.5L19 7.5"],["magicx-aia-product-cart-spinner","M12 4a8 8 0 1 0 8 8"]];for(let[n,r]of e){let i=document.createElementNS(qn,"path");i.setAttribute("class",n),i.setAttribute("d",r),t.appendChild(i)}for(let n of["9","17.5"]){let r=document.createElementNS(qn,"circle");r.setAttribute("class","magicx-aia-product-cart-glyph"),r.setAttribute("cx",n),r.setAttribute("cy","20"),r.setAttribute("r","1.3"),t.appendChild(r)}return t}function Vs(t,e,n,r,i){let o=document.createElement("span");o.className="magicx-aia-product-cart",o.setAttribute("data-aia-product-cart",""),o.setAttribute("role","button"),o.setAttribute("aria-label",Vi(e,i)),o.tabIndex=0,o.appendChild(Bs());let s=a=>{a.preventDefault(),a.stopPropagation(),o.getAttribute("data-aia-cart-state")!=="adding"&&(o.setAttribute("data-aia-cart-state","adding"),o.setAttribute("aria-busy","true"),n(wt.get(t)??e).then(()=>{o.removeAttribute("aria-busy"),o.setAttribute("data-aia-cart-state","added")},()=>{o.removeAttribute("aria-busy"),o.removeAttribute("data-aia-cart-state")}))};return o.addEventListener("keydown",a=>{a.key!=="Enter"&&a.key!==" "||s(a)}),o.addEventListener("focus",()=>r(!0)),o.addEventListener("blur",a=>{a.relatedTarget?.closest("[data-aia-dropdown]")||r(!1)}),{el:o,arm:()=>o.addEventListener("click",s)}}function Us(t,e){return[e?"cart":"",t.id,t.title,t.url,t.imageUrl,t.vendor,t.available===!1?"sold-out":""].map(n=>n??"").join("\0")}function $s(t,e,n,r,i,o){let s=document.createElement("a");s.className="magicx-aia-product",s.setAttribute("data-aia-product",""),s.setAttribute("role","option"),s.setAttribute("aria-selected","false"),s.tabIndex=0;let a=document.createElement("span");a.className="magicx-aia-product-media",a.setAttribute("aria-hidden","true");let l=Pt(t.imageUrl),d=l[0],c=!!d,u=()=>{a.replaceChildren(),a.removeAttribute("data-aia-image-loaded"),a.toggleAttribute("data-aia-product-placeholder",r==="image"),a.toggleAttribute("data-aia-product-initial",r==="initial"),r==="initial"&&(a.textContent=Vn(t.title))};if(Wi.set(s,h=>{h!==r&&(r=h,c||u())}),d){let h=document.createElement("img"),x=0;h.onload=()=>{a.setAttribute("data-aia-image-loaded",""),Fi(s,Gn(h.naturalWidth,h.naturalHeight))},h.onerror=()=>{let b=l[++x];if(b){h.src=b;return}c=!1,Fi(s,null),u()},h.className="magicx-aia-product-image",h.src=d,h.alt="",h.loading="lazy",h.decoding="async",a.appendChild(h)}else u();s.appendChild(a);let m=document.createElement("span");if(m.className="magicx-aia-product-body",t.vendor){let h=document.createElement("span");h.className="magicx-aia-product-vendor",h.textContent=t.vendor,m.appendChild(h)}let g=document.createElement("span");if(g.className="magicx-aia-product-title",g.textContent=t.title,m.appendChild(g),t.available===!1){s.setAttribute("data-aia-product-sold-out","");let h=document.createElement("span");h.className="magicx-aia-product-badge",h.textContent=i.soldOut,m.appendChild(h)}s.appendChild(m);let p=o&&t.available!==!1?Vs(s,t,o,n,i):null;return p&&(s.setAttribute("data-aia-product-has-cart",""),s.appendChild(p.el)),Kn.set(s,()=>{p?.arm(),t.url&&(s.href=t.url),s.addEventListener("click",h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.altKey||h.button!==0||(h.preventDefault(),e(wt.get(s)??t))})}),s.addEventListener("keydown",h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),e(wt.get(s)??t))}),s.addEventListener("focus",()=>n(!0)),s.addEventListener("blur",h=>{h.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),s}var Gs=80,qs=150,Ks=280,zs=16,jn="--aia-option-enter-delay";function Yn(t,e,n,r="below"){let i=Math.max(1,Math.floor(e)),o=Math.floor(Math.max(0,t)/i);if(r!=="above")return o*80;let s=Math.max(1,Math.ceil(Math.max(0,n)/i));return Math.max(0,s-1-o)*80}function Qn(t,e){let n=Math.max(1,Math.floor(e));return(Math.max(1,Math.ceil(Math.max(0,t)/n))-1)*80+280}var Ui="http://www.w3.org/2000/svg",js=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function Ys(t,e){let n=t.toLowerCase();return n.startsWith("on")||n.includes("href")||n==="style"||n==="xml:base"||n==="id"||n==="name"||/^\s*javascript:/i.test(e)||/url\s*\(\s*['"]?\s*[^#'"\s)]/i.test(e)}var Qs=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],Xs=/^[a-zA-Z0-9#.,%\s()-]+$/;function Js(t){let e=[];for(let n of Qs){let r=t.getAttribute(n);r===null||!Xs.test(r)||/url\s*\(/i.test(r)||e.push(`${n}: ${r.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function $i(t){for(let e of Array.from(t.attributes))Ys(e.name,e.value)&&t.removeAttribute(e.name);Js(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!js.has(n.localName)||n.namespaceURI!==Ui?n.remove():$i(n)}else e.remove()}function le(t){if(typeof DOMParser>"u"||typeof XMLSerializer>"u")return null;let e=new DOMParser().parseFromString(t,"image/svg+xml"),n=e.documentElement;return!n||n.localName!=="svg"||n.namespaceURI!==Ui||e.getElementsByTagName("parsererror").length>0?null:($i(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function Ct(t){return t.text}function ce(t){return At(t)[0]??null}function At(t){let e=Zs(t);return e?$n(e,120):[]}function Zs(t){if(!t)return null;let e=t.trim();if(e==="")return null;let n;try{n=new URL(e,typeof document>"u"?void 0:document.baseURI)}catch{return null}return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}function Re(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var Gi={one:"item",other:"items"};function ea(t,e=Gi){let n=Re(t);if(n===null)return null;let r=typeof e=="string"?e:t===1?e.one:e.other;return r===""?n:`${n} ${r}`}function qi(t){return ce(t.image_url)!==null}var It=new Map;function ta(t){let e=t.icon_svg;if(!e)return!1;let n=It.get(e);return n===void 0&&(n=le(e)!==null,It.size>=256&&It.clear(),It.set(e,n)),n}function Xn(t,e,n){return!e&&!n?!1:t.every(r=>!r.is_tappable||n&&qi(r)||e&&ta(r))}var Ki=new WeakMap;function na(t,e,n){let r=e.length,i=An(),o=Ki.get(t),s=n&&o&&On(o.options,e)?o.plan:null,a=!s&&!n&&wn(r,i)?In(t):null,l=s??Cn(r,i,a?.rowWidths??null,a?.gridWidth??null);return n||Ki.set(t,{options:e,plan:l}),t.style.gridTemplateColumns=l.template,t.style.setProperty("--aia-grid-max-height",l.maxHeight),t.querySelectorAll("[data-aia-option]").forEach((d,c)=>{d.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(c))}),l.cols}function zi(t,e){if(e.loading||!e.interactive)return null;let n=e.options[ne(t)];return n?.is_tappable?n:null}var ra={itemSelector:"[data-aia-option]",onClick:(t,e)=>{let n=zi(t,e);if(!n)return;t.classList.add("magicx-aia-option--pressed");let r=t.querySelector(".magicx-aia-checkbox");if(r){let i=t.getAttribute("aria-selected")!=="true";t.setAttribute("aria-selected",String(i)),r.dataset.checked=String(i),r.textContent=i?"\u2713":""}e.onSelect(n),setTimeout(()=>t.classList.remove("magicx-aia-option--pressed"),170)},onEnter:(t,e)=>{zi(t,e)&&e.onHighlight(ne(t))},onLeave:(t,e)=>e.onHighlight(-1,ne(t))};function ji(t,e,n,r,i,o,s,a="",l="below",d=!0,c=!0,u=!0,m=!0,g){let p=t.querySelector(".aia-grid");if(e.length===0){p?.remove();return}p||(p=document.createElement("div"),p.className="aia-grid magicx-aia-grid",p.setAttribute("data-scroll",""),p.style.setProperty("--aia-grid-min","250px"),p.style.setProperty("--aia-grid-max","1fr"),p.style.setProperty("--aia-grid-gap","0"),t.appendChild(p)),$(p,ra,{options:e,onSelect:r,onHighlight:i,loading:s,interactive:m});let h=p.dataset.aiaGroup!==a;p.dataset.aiaGroup=a;let x=Xn(e,d,c);ia(p,e,n,o,s,{showIcons:d&&x,showImages:c&&x,showCounts:u,picked:g});let b=na(p,e,s);oa(p,e.length,b,s,l),h&&(p.scrollTop=0)}function ia(t,e,n,r,i,o){let s=i?"1":"0",a=t.dataset.aiaGroup??"",{showIcons:l,showImages:d,showCounts:c}=o,u=l?p=>p.icon??p.icon_svg??"":()=>"",m=d?p=>ce(p.image_url)??"":()=>"",g=c?p=>Re(p.item_count)??"":()=>"";re(t,e,{keyOf:p=>`${p.text}\0${p.parameterLabel??""}\0${u(p)}\0${m(p)}\0${g(p)}\0${s}\0${a}`,create:(p,h)=>{let x=sa(p,i,o);return i||(x.dataset.aiaEntering=""),x},update:(p,h,x)=>{if(Jn.get(p)!==(h.matchedText??"")){let S=p.querySelector(".magicx-aia-option-text");S&&Yi(S,h),Jn.set(p,h.matchedText??"")}let b=x===n&&!i;p.id=`${r}-option-${x}`,p.dataset.aiaIndex=String(x),p.setAttribute("aria-selected",String(o.picked?o.picked.includes(h.text):b));let f=p.querySelector(".magicx-aia-checkbox");o.picked&&h.is_tappable?(f||(f=document.createElement("span"),f.className="magicx-aia-checkbox",f.setAttribute("aria-hidden","true"),p.querySelector(".magicx-aia-option-content")?.prepend(f)),f.dataset.checked=String(o.picked.includes(h.text)),f.textContent=o.picked.includes(h.text)?"\u2713":""):f?.remove(),p.classList.toggle("magicx-aia-option--highlighted",b)}})}function oa(t,e,n,r,i){for(let o of t.querySelectorAll("[data-aia-entering]")){if(!r){let s=Number.parseInt(o.dataset.aiaIndex??"-1",10);s>=0&&o.style.setProperty(jn,`${Yn(s,n,e,i)}ms`)}delete o.dataset.aiaEntering}}var Jn=new WeakMap;function Yi(t,e){if(t.replaceChildren(),e.matchedText)for(let n of Ln(Ct(e),e.matchedText))if(n.bold){let r=document.createElement("strong");r.className="magicx-aia-option-match",r.textContent=n.text,t.appendChild(r)}else t.appendChild(document.createTextNode(n.text));else t.appendChild(document.createTextNode(Ct(e)));if(e.parameterLabel){t.appendChild(document.createTextNode(" "));let n=document.createElement("span");n.className="magicx-aia-option-parameter",n.textContent=e.parameterLabel,t.appendChild(n)}}function sa(t,e,{showIcons:n,showImages:r,showCounts:i}){let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("data-aia-option",""),e&&o.setAttribute("data-aia-loading",""),o.tabIndex=e||!t.is_tappable?-1:0;let s=["magicx-aia-option"];t.is_tappable?s.push("magicx-aia-option--tappable"):s.push("magicx-aia-option--non-tappable"),o.className=s.join(" ");let a=document.createElement("span");a.className="magicx-aia-option-content";let l=r?At(t.image_url):[],d=l[0];if(d){let g=document.createElement("span");g.className="magicx-aia-option-image",g.setAttribute("aria-hidden","true");let p=document.createElement("img");p.setAttribute("alt",""),p.setAttribute("loading","lazy"),p.setAttribute("decoding","async"),p.setAttribute("referrerpolicy","no-referrer"),p.setAttribute("draggable","false");let h=0;p.onload=()=>g.setAttribute("data-aia-image-loaded",""),p.onerror=()=>{let x=l[++h];x?p.src=x:p.hidden=!0},p.src=d,g.appendChild(p),a.appendChild(g),o.dataset.aiaImage=""}let c=!d&&n&&t.icon_svg?le(t.icon_svg):null;if(c){let g=document.createElement("span");g.className="magicx-aia-option-icon",g.setAttribute("aria-hidden","true"),g.innerHTML=c,a.appendChild(g),t.icon&&(o.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",Yi(u,t),Jn.set(o,t.matchedText??""),a.appendChild(u),t.tag){let g=document.createElement("span");g.className="magicx-aia-option-tag",g.textContent=t.tag,a.appendChild(g)}let m=i?Re(t.item_count):null;if(m!==null){let g=document.createElement("span");g.className="magicx-aia-option-count",g.textContent=m,a.appendChild(g),o.dataset.aiaItemCount=String(t.item_count)}return o.appendChild(a),o}var aa=120,la={itemSelector:"[data-aia-time-row], [data-aia-time-done]",onClick:(t,e)=>{if(!e.interactive)return;if(t.hasAttribute("data-aia-time-done")){e.callbacks.onTimeCommit();return}let n=t.dataset.aiaTimeColumn;n&&e.callbacks.onTimeChange(lt(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},Xi=new WeakMap,Qi=new WeakMap;function Ji(t,e,n,r,i=!0){let o=t.querySelector(".magicx-aia-time-wheel");if(!e){o?.remove();return}if(!o){o=ua(),t.appendChild(o),G(o);let d=o.querySelector("[data-aia-time-done]");d&&(d.disabled=!1)}let s={view:e,callbacks:r,interactive:i};Xi.set(o,s),$(o,la,s),o.setAttribute("aria-label",n.timeLabel);let a=o.querySelector("[data-aia-time-done]");a&&(a.textContent=n.done);let l=o.querySelector("[data-aia-time-value]");l&&(l.textContent=it(e.minutes));for(let d of st){let c=o.querySelector(`[data-aia-time-column="${d}"]`);c&&ca(c,d,e.minutes)}}function ca(t,e,n){let r=at(e,n);for(let s of t.querySelectorAll("[data-aia-time-row]")){let a=Number(s.dataset.aiaIndex)===r;s.classList.toggle("magicx-aia-time-wheel-row--selected",a),s.setAttribute("aria-selected",String(a))}let i=Ot(t);if(i.settle)return;let o=r*ot;Math.abs(t.scrollTop-o)<1||(i.syncedTop=o,t.scrollTop=o)}function Ot(t){let e=Qi.get(t);return e||(e={syncedTop:null,settle:null},Qi.set(t,e)),e}function da(t,e,n){let r=Ot(e);if(r.syncedTop!=null&&Math.abs(e.scrollTop-r.syncedTop)<1){r.syncedTop=null;return}r.syncedTop=null,r.settle&&clearTimeout(r.settle),r.settle=setTimeout(()=>Zi(t,e,n),aa)}function Zi(t,e,n){let r=Ot(e);r.settle&&clearTimeout(r.settle),r.settle=null;let i=Xi.get(t);if(!i||!i.interactive)return;let o=hn(n,e.scrollTop);o!==at(n,i.view.minutes)&&i.callbacks.onTimeChange(lt(n,i.view.minutes,o))}function ua(){let t=document.createElement("div");t.className="magicx-aia-time-wheel",t.setAttribute("data-aia-time-wheel",""),t.setAttribute("role","group");let e=document.createElement("span");e.className="magicx-aia-time-wheel-value",e.setAttribute("data-aia-time-value",""),e.setAttribute("aria-live","polite");let n=document.createElement("div");n.className="magicx-aia-time-wheel-columns",n.setAttribute("aria-hidden","true");let r=document.createElement("div");r.className="magicx-aia-time-wheel-band",n.appendChild(r);for(let o of st){if(o==="minute"){let s=document.createElement("span");s.className="magicx-aia-time-wheel-separator",s.textContent=":",n.appendChild(s)}n.appendChild(pa(t,o))}let i=document.createElement("button");return i.type="button",i.tabIndex=-1,i.className="magicx-aia-time-wheel-done",i.setAttribute("data-aia-time-done",""),i.disabled=!0,t.append(e,n,i),t}function pa(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),fn(e).forEach((r,i)=>{let o=document.createElement("div");o.className="magicx-aia-time-wheel-row",o.setAttribute("data-aia-time-row",""),o.dataset.aiaTimeColumn=e,o.dataset.aiaIndex=String(i),o.textContent=r.label,n.appendChild(o)}),n.addEventListener("scroll",()=>da(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{Ot(n).settle&&Zi(t,n,e)}),n}var eo="magicx-aia-scroll-arrow",to="data-aia-scroll-arrow",Se="data-aia-visible",no=1e3,ro=160,io="--aia-scroll-arrow-bottom",ma="Scroll down for more options",ga="[data-aia-products-label]",fa=4,ha=8,ba=240;function Sa(t,e,n,r){let i=t.scrollTop,o=n?.requestAnimationFrame,s=t.ownerDocument?.visibilityState==="hidden";if(!o||s||Zn(t)){t.scrollTop=i+e,r();return}let a=n.performance?.now?.()??Date.now(),l=()=>n.performance?.now?.()??Date.now(),d=()=>{let c=Math.min(1,(l()-a)/ba),u=1-(1-c)*(1-c);t.scrollTop=i+e*u,c<1?o.call(n,d):r()};o.call(n,d)}function ya(t=document){let e="http://www.w3.org/2000/svg",n=t.createElementNS(e,"svg");n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.75"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false");let r=t.createElementNS(e,"path");return r.setAttribute("d","M4 6.5 8 10.5l4-4"),n.appendChild(r),n}function oo(t=document,e=k()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=eo,n.setAttribute(to,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(ya(t)),n}function xa(t){let e=t.style.gridTemplateColumns.trim();return e?Math.max(1,e.split(/\s+/).length):1}function Zn(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function er({dropdown:t,grid:e,button:n}){let r=e.ownerDocument?.defaultView??(typeof window<"u"?window:null),i=!1;n.disabled=!0;let o=null,s=null,a=null,l=null,d=f=>{if(f){if(n.hasAttribute(Se))return;if(n.setAttribute(Se,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),Zn(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!i&&n.hasAttribute(Se)&&(n.disabled=!1)},no)}else n.removeAttribute(Se),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},c=f=>{let S=0,y=f;for(;y&&y!==t;)S+=y.offsetTop,y=y.offsetParent instanceof HTMLElement?y.offsetParent:null;return S},u=()=>{let f=t.querySelector(ga),S;if(f){let y=c(f)+f.offsetHeight/2;S=t.clientHeight-y-n.offsetHeight/2}else{let y=c(e),w=r&&Number.parseFloat(r.getComputedStyle(e).paddingBottom)||0;S=t.clientHeight-(y+e.offsetHeight)+(w>0?0:ha)}n.style.setProperty(io,`${Math.max(0,Math.round(S))}px`)},m=()=>{if(i||s!==null||a!==null)return;let f=e.querySelector("[data-aia-option][data-aia-loading]")!==null,S=e.scrollHeight-e.clientHeight-e.scrollTop;d(!f&&S>fa)},g=()=>{if(i)return;u();let f=e.getAttribute("data-aia-group")??"";if(f!==o){o=f,d(!1),s!==null&&clearTimeout(s);let S=e.querySelectorAll("[data-aia-option]").length,y=Zn(e)?0:Qn(S,xa(e));s=setTimeout(()=>{s=null,m()},y);return}m()},p=()=>{i||s!==null||(d(!1),a!==null&&clearTimeout(a),a=setTimeout(()=>{a=null,m()},ro))};e.addEventListener("scroll",p,{passive:!0});let h=f=>f.preventDefault(),x=()=>{let f=r?(Number.parseFloat(r.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(r.getComputedStyle(e).paddingBottom)||0):0,S=Math.max(1,e.clientHeight-f);Sa(e,S,r,p)};n.addEventListener("mousedown",h),n.addEventListener("click",x);let b=null;return r&&typeof r.ResizeObserver=="function"&&(b=new r.ResizeObserver(()=>{u(),m()}),b.observe(e)),g(),{update:g,destroy(){i||(i=!0,s!==null&&clearTimeout(s),s=null,a!==null&&clearTimeout(a),a=null,l!==null&&clearTimeout(l),l=null,n.disabled=!0,e.removeEventListener("scroll",p),n.removeEventListener("mousedown",h),n.removeEventListener("click",x),b?.disconnect(),n.removeAttribute(Se),n.setAttribute("aria-hidden","true"))}}}var ye="data-aia-fit",kt="--aia-dropdown-fit-height";function tr({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,r=!1,i=!1,o=null,s=null,a=null,l=()=>{t.removeAttribute(ye),t.style.removeProperty(kt)},d=g=>{let h=`${o}|${(g??t).scrollHeight}|${t.offsetWidth}`;if(a?.key===h)return a.height;let x=g?.scrollTop??0;t.removeAttribute(ye);let b=t.offsetHeight;return t.setAttribute(ye,""),g&&x&&(g.scrollTop=x),a={key:h,height:b},b},c=()=>{if(r)return;if(!e()){i=!1;return}i||(i=!0,l());let g=t.hasAttribute(ye),p=t.querySelector(".aia-grid")?.getAttribute("data-aia-group")??null,h=p!==o;o=p;let x=va(t,n);if(x===null)return;let b=Ta(t);if(g){if(d(b)<=x){l();return}}else if(t.offsetHeight<=x)return;let f=`${Math.max(160,Math.floor(x))}px`;t.style.getPropertyValue(kt)!==f&&t.style.setProperty(kt,f),g?h&&b&&(b.scrollTop=0):t.setAttribute(ye,"")},u=()=>{r||s!==null||!n||(s=n.requestAnimationFrame(()=>{s=null,c()}))},m=n?.visualViewport??null;return m?.addEventListener("resize",u),m?.addEventListener("scroll",u),n?.addEventListener("resize",u),n?.addEventListener("scroll",u,{capture:!0,passive:!0}),c(),{update:c,destroy(){r||(r=!0,s!==null&&n?.cancelAnimationFrame(s),m?.removeEventListener("resize",u),m?.removeEventListener("scroll",u),n?.removeEventListener("resize",u),n?.removeEventListener("scroll",u,{capture:!0}))}}}function Ta(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function va(t,e){if(!e)return null;let n=e.visualViewport,r=n?n.offsetTop:0,i=n?n.height:e.innerHeight;if(!i)return null;let o=t.offsetParent,s=o?o.getBoundingClientRect().top:0,a=o?s+t.offsetTop:t.getBoundingClientRect().top;return t.closest("[data-options-position]")?.getAttribute("data-options-position")==="above"?(o?a+t.offsetHeight:t.getBoundingClientRect().bottom)-r-8:r+i-a-8}var Ea=[159,119,164];function Rt(t){let e=document.createElement("div");return e.id=t,e.setAttribute("role","listbox"),e.setAttribute("data-aia-dropdown",""),e.className="magicx-aia-dropdown",e.addEventListener("mousedown",n=>n.preventDefault()),Nn(e),e}var Lt=new WeakMap;function Pa(t,e,n){let r=Lt.get(t);if(r||(r={button:oo(t.ownerDocument,n),grid:null,controller:null},t.appendChild(r.button),Lt.set(t,r)),r.button.getAttribute("aria-label")!==n.scrollArrow&&r.button.setAttribute("aria-label",n.scrollArrow),r.grid!==e&&(r.controller?.destroy(),r.controller=null,r.grid=e,e)){r.controller=er({dropdown:t,grid:e,button:r.button});return}r.controller?.update()}var Mt=new WeakMap;function so(t){let e=Mt.get(t);if(e){e.update();return}Mt.set(t,tr({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function nr(t){Mt.get(t)?.destroy(),Mt.delete(t);let e=Lt.get(t);e&&(e.controller?.destroy(),Lt.delete(t))}function _t(t,e){let n=e.strings??k(),{filteredOptions:r,activeIndex:i,isOpen:o,isLoading:s,showPills:a,isActivePillSelected:l,onSelect:d,onHighlight:c,onPillClick:u,onSkip:m}=e,g=Bt(e.pills,n.keepTyping),p=Ut(g),h=a&&g.length>0,x=r.length>0,b=e.products.length>0,f=e.formatType==="time"&&e.timeView!=null,S=o&&(x||h||s||b||f);if(S?t.classList.add("magicx-aia-dropdown--visible"):t.classList.remove("magicx-aia-dropdown--visible"),s?t.setAttribute("data-aia-loading",""):t.removeAttribute("data-aia-loading"),!S){zn(t,!1),so(t);return}b?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let y=t.querySelector(".aia-stack");y||(y=document.createElement("div"),y.className="aia-stack",y.style.setProperty("--aia-stack-space","8px"),t.appendChild(y));let w=e.showSkipButton&&p&&!e.isInputEmpty,v=h||s&&a||w,E=y.querySelector(".magicx-aia-pill-bar");if(v){E||(E=document.createElement("div"),E.className="magicx-aia-pill-bar aia-cluster",E.setAttribute("data-nowrap",""),E.setAttribute("data-aia-pillbar",""),y.insertBefore(E,y.firstChild));let R=E.querySelector(".magicx-aia-pill-scroll");R||(R=document.createElement("span"),R.className="magicx-aia-pill-scroll",R.setAttribute("data-aia-pill-scroll",""),E.insertBefore(R,E.firstChild)),Et(R,a?g:[],0,u,!0,s&&a,l),Ia(E,w,s||e.skipDisabled,g[0],m,n)}else E&&E.remove();let L=e.suggestions[0],I=L?`${L.parameter} ${L.text}`:"",O=M(e.formatType),W=O&&!s;ji(y,O?[]:r,i,d,c,e.listboxId,s,I,e.optionsPosition??"below",e.showOptionIcons??!0,e.showOptionImages??!0,e.showOptionCounts??!0,!e.skipDisabled,s?void 0:e.multiSelectView?.picked),t.setAttribute("aria-multiselectable",String(!!e.multiSelectView)),La(y,!!e.multiSelectView&&!s,e.skipDisabled,e.onMultiSelectCommit,n.done),Pa(t,y.querySelector(".aia-grid"),n),Li(y,W?r:[],i,e.listboxId,W?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart},{onSelect:d,onHighlight:c,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),Ji(y,e.formatType==="time"&&!s?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled);let D=y.querySelector(".magicx-aia-skeleton-bars");if(s&&(!x||_(e.formatType))){if(!D){D=document.createElement("div"),D.className="magicx-aia-skeleton-bars",D.setAttribute("data-aia-skeleton-bars","");for(let R of Ea){let X=document.createElement("span");X.className="magicx-aia-skeleton-bar",X.style.width=`${R}px`,D.appendChild(X)}y.appendChild(D)}}else D&&D.remove();Bi(y,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart),zn(t,!0);let Q=y.querySelector(".magicx-aia-footer")??Oa(n),T=i>=0&&!!r[i]?.is_tappable;Aa(Q,Dn(T,e.isInputEmpty,n)),Q.isConnected||y.appendChild(Q),wa(y,[".magicx-aia-pill-bar",".aia-grid","[data-aia-multi-actions]",".magicx-aia-datepicker",".magicx-aia-skeleton-bars",".magicx-aia-products",".magicx-aia-footer"]),so(t)}function wa(t,e){let n=e.map(r=>t.querySelector(`:scope > ${r}`)).filter(r=>r!==null);for(let r=0;r<n.length;r++)t.children[r]!==n[r]&&t.insertBefore(n[r],t.children[r]??null)}var Ca={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function Ia(t,e,n,r,i,o){$(t,Ca,{onSkip:i,loading:n});let s=t.querySelector(".magicx-aia-skip");if(!e){s?.remove();return}s||(s=document.createElement("button"),s.type="button",s.tabIndex=-1,s.className="magicx-aia-skip",s.setAttribute("data-aia-skip",""),s.textContent=o.skip,s.disabled=!0,t.appendChild(s),G(s)),s.textContent!==o.skip&&(s.textContent=o.skip),s.setAttribute("aria-label",r?`${o.skipLabel} ${r.text}`:o.skipLabel),s.disabled=n}function Aa(t,{key:e,hint:n}){let r=t.querySelector(".magicx-aia-footer-key"),i=t.querySelector(".magicx-aia-footer-hint");!r||!i||(r.textContent!==e&&(r.textContent=e),i.textContent!==n&&(i.textContent=n))}function Oa(t){let e=document.createElement("footer");e.className="magicx-aia-footer",e.setAttribute("data-aia-footer","");let n=document.createElement("div");n.className="aia-cluster magicx-aia-footer-row",n.setAttribute("data-align","center"),n.setAttribute("data-justify","between"),n.setAttribute("data-nowrap","");let r=document.createElement("div");r.className="aia-cluster magicx-aia-footer-hint-group",r.setAttribute("data-align","center"),r.style.setProperty("--aia-cluster-gap","5px");let i=document.createElement("kbd");i.className="magicx-aia-footer-key",i.textContent="tab";let o=document.createElement("span");o.className="magicx-aia-footer-hint",o.textContent=t.select,r.append(i,o);let s=document.createElement("a");s.className="aia-cluster magicx-aia-footer-brand-link",s.setAttribute("data-align","center"),s.href=Rn(),s.target="_blank",s.rel="noopener noreferrer",s.style.setProperty("--aia-cluster-gap","2px");let a=document.createElement("span");a.className="magicx-aia-footer-brand",a.textContent="AI";let l=document.createElement("span");return l.className="magicx-aia-footer-badge",l.textContent="Autocomplete",s.append(a,l),n.append(r,s),e.append(n),e}var ka={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function La(t,e,n,r,i){let o=t.querySelector("[data-aia-multi-actions]");if(!e){o?.remove();return}if(!o){o=document.createElement("div"),o.dataset.aiaMultiActions="";let a=document.createElement("button");a.type="button",a.tabIndex=-1,a.className="magicx-aia-multi-done",a.disabled=!0,o.appendChild(a),t.appendChild(o),G(a)}$(o,ka,{commit:r,disabled:n});let s=o.querySelector("button");s&&(s.textContent=i,s.disabled=n)}function ao(t,e){let n=Rt(e.listboxId);return t.appendChild(n),{dropdown:n}}function rr(t,e,n){let r=Me(e);_t(t.dropdown,{strings:n.strings,suggestions:e.editingIdentified?[{parameter:e.editingIdentified.parameter,text:j(e.editingIdentified.parameter),required:!0,options:e.filteredOptions}]:e.dropdownSuggestion??e.actionableSuggestions[0]?[{...e.dropdownSuggestion??e.actionableSuggestions[0],options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:e.actionableSuggestions,showPills:!0,showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:r.selectedIso,selectedDateRange:r.selectedRange,dateRangeStart:r.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,optionsPosition:n.optionsPosition??"below",onSelect:n.selectOption,onHighlight:(i,o)=>{o!==void 0&&n.store.get().activeDropdownIndex!==o||n.store.set({activeDropdownIndex:i})},onPillClick:n.setActivePill,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onProductSelect:n.selectProduct,onProductFocusChange:i=>n.store.set({isFocused:i})})}var Ma=6,Ra=.3;function lo(t){return t<=0?"0px":`${(-Math.min(Ra,2*Ma/t)).toFixed(3)}px`}var co=new Map;function _a(t,e,n){let r=co.get(e);if(r!==void 0){t.style.setProperty("--aia-chip-image-fit",r),t.setAttribute("data-aia-image-loaded","");return}let i=n.createElement("img");i.setAttribute("referrerpolicy","no-referrer"),i.onload=()=>{if(!t.isConnected)return;t.setAttribute("data-aia-image-loaded","");let o=t.getBoundingClientRect().height,s=Number.parseFloat(getComputedStyle(t).fontSize);if(!(o>0&&s>0&&i.naturalWidth>0&&i.naturalHeight>0))return;let a=`${(o/s*(i.naturalWidth/i.naturalHeight)).toFixed(3)}em`;co.set(e,a),t.style.setProperty("--aia-chip-image-fit",a)},i.src=e}function ir(t){let{input:e,segments:n,newParamId:r,editingParamId:i,placeholderText:o,isFocused:s}=t,a=t.showChipIcons??!0,l=t.showChipImages??!0,d=n.length===0;e.dataset.aiaEmpty=d?"true":"false",xi(e,d?o:"");let c=n.map(f=>f.type==="completed"?`${f.type}:${f.value}${a?f.param.icon??f.param.icon_svg??"":""}${l?ce(f.param.image_url)??"":""}`:`${f.type}:${f.value}`).join("\0"),u=e.dataset.segKey??"",m=e.dataset.newParamId??"",g=e.dataset.editingParamId??"";if(c===u&&(r??"")===m&&(i??"")===g)return;if(c===u){e.dataset.newParamId=r??"",e.dataset.editingParamId=i??"";for(let f of e.querySelectorAll("strong[data-param-id]")){let S=f.dataset.paramId,y=f.dataset.seg==="completed"&&S===r;f.classList.toggle("magicx-aia-shimmer-revealed",y),f.classList.toggle("magicx-aia-shimmer-sweep",y),f.classList.toggle("magicx-aia-segment--editing",S===i)}return}let p=s?V(e):null;e.dataset.segKey=c,e.dataset.newParamId=r??"",e.dataset.editingParamId=i??"";let h=H(e),x=h.createDocumentFragment(),b=0;for(let f of n)if(b+=f.value.length,f.type==="completed"){let S=h.createElement("strong");S.dataset.seg="completed",S.dataset.paramId=f.param.id;let y=f.param.id===r,w=f.param.id===i,v=["magicx-aia-segment","magicx-aia-segment--completed"];y&&v.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),w&&v.push("magicx-aia-segment--editing"),S.className=v.join(" "),S.style.letterSpacing=lo(f.value.length);let E=l?ce(f.param.image_url):null;if(E){let I=h.createElement("span");I.className="magicx-aia-segment-image",I.setAttribute("contenteditable","false"),I.setAttribute("aria-hidden","true"),I.style.setProperty("--aia-chip-image",`url("${E}")`),_a(I,E,h),S.appendChild(I),S.dataset.aiaImage=""}let L=!E&&a&&f.param.icon_svg?le(f.param.icon_svg):null;if(L){let I=h.createElement("span");I.className="magicx-aia-segment-icon",I.setAttribute("contenteditable","false"),I.setAttribute("aria-hidden","true"),I.innerHTML=L,S.appendChild(I),f.param.icon&&(S.dataset.aiaIcon=f.param.icon)}S.appendChild(h.createTextNode(f.value)),x.appendChild(S)}else if(f.type==="identified"){let S=h.createElement("strong");S.dataset.seg="identified",S.dataset.paramId=f.param.id;let y=["magicx-aia-segment","magicx-aia-segment--completed"];f.param.id===i&&y.push("magicx-aia-segment--editing"),S.className=y.join(" "),S.style.letterSpacing=lo(f.value.length),S.textContent=f.value,x.appendChild(S)}else x.appendChild(h.createTextNode(f.value));e.replaceChildren(x),e.dataset.aiaTextLength=String(b),p!=null?F(e,Math.max(0,Math.min(p,b))):s&&Kr(e)&&F(e,b)}var Da='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" role="img" aria-label="Submit"><path d="M9 14V4M9 4L4 9M9 4L14 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function uo(t=k()){let e=document.createElement("button");return e.type="button",e.className="magicx-aia-submit",e.setAttribute("aria-label",t.submit),e.setAttribute("data-aia-submit",""),e.innerHTML=Da.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function Na(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function po(t,e){let n=e.firstElementChild;if(!n){e.removeAttribute("data-aia-pill-wrapped");return}let r=n.getBoundingClientRect(),i=t.getBoundingClientRect();r.top>=i.bottom-2?e.setAttribute("data-aia-pill-wrapped",""):e.removeAttribute("data-aia-pill-wrapped")}function mo(t,e){let{listboxId:n}=e,r=Rt(n);t.appendChild(r);let i=document.createElement("div");i.className="magicx-aia-input-wrapper",i.setAttribute("data-aia-input-wrapper",""),t.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-editor",o.setAttribute("data-aia-editor",""),i.appendChild(o);let s=document.createElement("div");s.className="magicx-aia-input",s.setAttribute("data-aia-input",""),s.setAttribute("contenteditable",Na()?"plaintext-only":"true"),s.setAttribute("role","combobox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-haspopup","listbox"),s.setAttribute("aria-controls",n),s.setAttribute("aria-expanded","false"),s.setAttribute("spellcheck","true"),s.setAttribute("enterkeyhint","send"),o.appendChild(s);let a=document.createElement("span");a.className="magicx-aia-pill-list-container",a.setAttribute("data-aia-pill-list-container",""),o.appendChild(a);let l=null,d=null;e.submitButton===void 0?(l=uo(e.strings),i.appendChild(l),d=l):e.submitButton!==null&&(d=e.submitButton,d.hasAttribute("data-aia-submit")||d.setAttribute("data-aia-submit",""),d.setAttribute("data-aia-submit-slot",""),i.appendChild(d));let c=new AbortController,{signal:u}=c,m=!1,g=0,p=()=>{let b=nt(s),S=b.length>0&&b[0]!==b[0].toUpperCase()?b[0].toUpperCase()+b.slice(1):b;e.handleChange(S)},h=()=>{let b=ee(s)?.node??null;if(!b||!s.contains(b))return null;let y=(b.nodeType===Node.ELEMENT_NODE?b:b.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return y&&qr(s,y)?null:y};if(i.addEventListener("click",b=>{b.target?.closest("[data-aia-pill]")||s.focus()},{signal:u}),s.addEventListener("input",()=>{m||(g=performance.now(),p(),e.handleCaretAfterInput(V(s)))},{signal:u}),H(s).addEventListener("selectionchange",()=>{let b=ee(s);if(!b||!s.contains(b.node))return;let f=b.collapsed?h():null,S=e.store.get(),y=S.editingParam?.id??S.editingIdentified?.id??null;if(f&&f!==y){e.startEditingParam(f);return}performance.now()-g<50||e.handleCaretMove(V(s))},{signal:u}),s.addEventListener("click",b=>{let f=nn(s,b.target);f&&(e.startEditingParam(f),rn(s,f))},{signal:u}),s.addEventListener("compositionstart",()=>{m=!0,s.setAttribute("data-aia-composing","true")},{signal:u}),s.addEventListener("compositionend",()=>{m=!1,s.removeAttribute("data-aia-composing"),p()},{signal:u}),s.addEventListener("beforeinput",b=>{let f=b,S=f.inputType;if(S==="insertParagraph"||S==="insertLineBreak"||S==="insertFromDrop"){b.preventDefault();return}if(S.startsWith("insert")||S.startsWith("delete")){let y=S.startsWith("delete")?"":f.data??"";e.replaceEditingRange(y)&&b.preventDefault()}},{signal:u}),s.addEventListener("paste",b=>{b.preventDefault();let f=(b.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let S=H(s),y=Xe(s);if(!y||!s.contains(y.startContainer))return;y.deleteContents();let w=S.createTextNode(f);y.insertNode(w),y.setStartAfter(w),Ae(s,y.startContainer,y.startOffset),p()},{signal:u}),s.addEventListener("keydown",b=>e.handleKeyDown(b),{signal:u}),s.addEventListener("focus",()=>e.store.set({isFocused:!0}),{signal:u}),s.addEventListener("blur",()=>e.store.set({isFocused:!1}),{signal:u}),d&&d.addEventListener("click",b=>{let f=e.store.get();if(!(!!f.text||f.completedParams.length>0)||!e.onSubmit)return;b.stopPropagation(),e.endTypedWord?.();let y=e.store.get();e.onSubmit(ae(y.text,y.completedParams,y.skippedParams,{identifiedParams:y.identifiedParams,isReady:y.isReady,customFields:y.customFields}))&&e.afterSubmit?.()},{signal:u}),e.autoFocus!==!1){s.focus();let b=ee(s);(!b||!s.contains(b.node))&&Ae(s,s,0)}if(typeof ResizeObserver<"u"){let b=new ResizeObserver(()=>po(s,a));b.observe(s),c.signal.addEventListener("abort",()=>b.disconnect(),{once:!0})}return{input:s,inlinePillContainer:a,dropdown:r,submitButton:l,abort:c}}function or(t,e,n){let{input:r,inlinePillContainer:i,dropdown:o,submitButton:s}=t,{pillPlacement:a,setActivePill:l,selectOption:d,store:c}=n;r.setAttribute("aria-expanded",String(e.isDropdownOpen));let u=e.activeDropdownIndex>=0?`${n.listboxId}-option-${e.activeDropdownIndex}`:"";if(u?r.setAttribute("aria-activedescendant",u):r.removeAttribute("aria-activedescendant"),s){let b=n.strings??k();s.getAttribute("aria-label")!==b.submit&&s.setAttribute("aria-label",b.submit);let f=s.querySelector("svg");f&&f.getAttribute("aria-label")!==b.submit&&f.setAttribute("aria-label",b.submit);let S=!!e.text||e.completedParams.length>0;s.disabled=!S}let m=r.dataset.newParamId??"",g=e.newParamId!==null&&e.newParamId!==m;if(ir({input:r,segments:e.segments,newParamId:e.newParamId,editingParamId:e.editingParam?.id??null,placeholderText:e.placeholderText,isFocused:e.isFocused,showChipIcons:n.showChipIcons??!0,showChipImages:n.showChipImages??!0}),a==="inline"){let b=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,f=Wt(e.actionableSuggestions);b||f.length>0?Et(i,f,0,l,!1,b,e.isActivePillSelected):Wn(i)}else Wn(i);po(r,i),g?(r.focus(),F(r,e.caretOffset??e.text.length)):e.isFocused&&nt(r)!==e.text&&F(r,e.text.length);let p=e.editingParam?{parameter:e.editingParam.suggestionParameter,text:e.editingParam.suggestionPlaceholder,required:!0,options:e.editingParam.options}:e.editingIdentified?{parameter:e.editingIdentified.parameter,text:j(e.editingIdentified.parameter),required:!0,options:[]}:null,h=e.dropdownSuggestion??p??e.actionableSuggestions[0],x=Me(e);_t(o,{strings:n.strings,suggestions:h?[{...h,options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:p?[p]:e.actionableSuggestions,showPills:a==="dropdown",showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:x.selectedIso,selectedDateRange:x.selectedRange,dateRangeStart:x.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,optionsPosition:n.optionsPosition??"below",onSelect:d,onHighlight:(b,f)=>{f!==void 0&&c.get().activeDropdownIndex!==f||c.set({activeDropdownIndex:b})},onPillClick:l,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onProductSelect:n.selectProduct,onProductFocusChange:b=>c.set({isFocused:b})})}function sr(t){let e=t,n=new Set,r=[],i=!1;return{get:()=>e,set:o=>{let s=typeof o=="function"?o(e):o,a=e;if(e={...e,...s},r.push([e,a]),!i){i=!0;try{let l=0;for(let d=r.shift();d;d=r.shift()){if(++l>1e4)throw r.length=0,new Error("createStore: notifications did not settle after 10000 deliveries \u2014 a listener is likely calling set() on every notification");let[c,u]=d;for(let m of n)m(c,u)}}catch(l){throw r.length=0,l}finally{i=!1}}},subscribe:o=>(n.add(o),()=>{n.delete(o)})}}function go(t,e){let n,r,i=o=>(o!==n&&(n=o,r=e(o)),r);return{get:()=>{let o=t.get();return{...o,...i(o)}},set:o=>{typeof o=="function"?t.set(s=>{let a={...s,...i(s)};return o(a)}):t.set(o)},peek:o=>{let s={...t.get(),...o};return{...s,...e(s)}},subscribe:o=>t.subscribe((s,a)=>{let l={...a,...i(a)},d={...s,...i(s)};o(d,l)})}}var ar=new WeakSet,fo=new WeakMap;function bo(t){return t.nodeType===Node.DOCUMENT_NODE}function Ha(t){return bo(t)?t:t.ownerDocument}function Fa(t){let e=fo.get(t);if(e)return e;let n=t.defaultView?.CSSStyleSheet;if(typeof n!="function")return null;try{let r=new n;return typeof r.replaceSync!="function"?null:(r.replaceSync(yo),fo.set(t,r),r)}catch{return null}}function ho(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=yo,e.appendChild(n)}function So(t){if(typeof document>"u")return;let e=t??document;if(ar.has(e))return;let n=Ha(e);if(bo(e)){let o=e.head??e.documentElement;if(!o)return;ho(n,o),ar.add(e);return}let r=Fa(n),i=e.adoptedStyleSheets;r&&Array.isArray(i)?i.includes(r)||(e.adoptedStyleSheets=[...i,r]):ho(n,e),ar.add(e)}var yo=`.aia-stack {
1
+ function k(t){return t==="date"||t==="date-range"}function D(t){return t!=="options"}function Q(t){return t?.type?.kind==="date"?"date":t?.type?.kind==="date_range"?"date-range":t?.type?.kind==="time"?"time":t?.type?.kind==="location"&&!t.options?.length?"location":"options"}var Ke=class{constructor(e){this.config=e;this.current=null;this.expiresAt=null;this.inFlightRefresh=null;e.accessToken&&(this.current=e.accessToken)}async getToken(e=!1){if(!e&&this.current&&!this.isExpired())return this.current;if(!e&&this.inFlightRefresh)return this.inFlightRefresh;this.inFlightRefresh=this.refresh();try{return await this.inFlightRefresh}finally{this.inFlightRefresh=null}}async refresh(){let e=await this.config.getAccessToken();return this.current=e.accessToken,this.expiresAt=e.expiresAt??null,this.current}isExpired(){return this.expiresAt==null?!1:Date.now()>=this.expiresAt-3e4}};var ta="https://api.ai-autocomplete.com",K=`${ta}/api/suggest`,ze=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),Li=new WeakMap;function Ie(t){return t?.type==="accessToken"}function na(t){if(!(!t||Ie(t)))return t}function je(t){let e=Li.get(t.getAccessToken);return e||(e=new Ke(t),Li.set(t.getAccessToken,e)),e}function Ye(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function Qe(t){let e=na(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var Ii="aiaPlace",Yt=2,Oi=250;function Ai(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function Qt(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:Ai(t),is_tappable:!0,kind:null,metadata:{[Ii]:{id:t.id}}}}function Xt(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??K,n=e.indexOf("?"),i=n<0?e:e.slice(0,n),o=n<0?"":e.slice(n+1);if(!/\/suggest\/?$/.test(i))return null;let r=i.replace(/\/suggest\/?$/,"/locations/autocomplete");return o?`${r}?${o}`:r}function ki(t){let e=t?.places;if(!Array.isArray(e))return[];let n=[];for(let i of e){let{id:o,name:r,secondary:a}=i??{};typeof o!="string"||!o||typeof r!="string"||!r.trim()||n.push({id:o,name:r.trim(),...typeof a=="string"&&a.trim()?{secondary:a.trim()}:{}})}return n}function Oe(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var Mi="skipped";function Ae(t,e){if(t.some(o=>"group"in o)&&(t=t.map(o=>{let{group:r,...a}=o;return a})),e.length===0)return t;let n=new Set(t.map(o=>o.parameter)),i=e.filter(o=>!n.has(o.parameter)).map(o=>({placeholder:"",parameter:o.parameter,text:Mi,kind:null}));return i.length>0?[...t,...i]:t}var ia="0.58.0",Di="1.0",Ri=!1;function oa(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function ie(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function ra(t,e,n,i,o,r,a,s,l,d,c,u,m){let h=e.find(f=>f.parameter==="contact"&&f.metadata?.contact_account_count)?.metadata?.contact_account_count,g=typeof h=="number"?h:void 0;return{data:{raw_query:t,accepts_traditional_autocomplete:!0,client_option_parameters:m??[],completed_params:Ae(e.map(f=>oa(f,n)),l??[]),...a&&a.length>0&&{identified_params:Oe(a)},...s&&s.length>0&&{recently_suggested:s},...g!=null&&{contact_account_count:g},...d!==void 0&&{additional_context:d}},meta:{request_id:o,request_at:new Date().toISOString(),language:ie(c),...u?.code&&Number.isFinite(u.rate)&&u.rate>0&&{currency:u.code,currency_rate:u.rate,...u.country!==void 0&&{country:u.country}},client_version:ia,session_id:i,source:r,schema_version:Di}}}async function _i(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function Ni(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=ra(t,e,o,n.sessionId,n.requestId??crypto.randomUUID(),n.source,n.identifiedParams,n.recentlySuggested,n.skippedParams,n.additionalContext,n.language,n.currency,n.clientOptionParameters),a=i?.endpoint??K,s=await Fi(a,JSON.stringify(r),i,n.signal);if(!s.ok)throw new Error(`API error: ${s.status} ${s.statusText}`);return s.json()}async function Fi(t,e,n,i){let o=Ye(n);if(Ie(n)){let a=je(n),s=await a.getToken(),l=await _i(t,o,s,e,i);if(l.status===401){let d=await a.getToken(!0);l=await _i(t,o,d,e,i)}return l}let r=Qe(n);return!r&&!Ri&&(Ri=!0,console.warn("[AIAutocomplete] No apiKey in apiConfig. Requests will be sent without an Authorization header.")),r&&(o.Authorization=r),fetch(t,{method:"POST",headers:o,body:e,signal:i})}var ke=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function Hi(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:ie(n.language)}),o=await Fi(t,i,n.apiConfig,n.signal);if(!o.ok)throw new ke(o.status);return ki(await o.json())}var Xe=/[\p{L}\p{N}]/u,aa=/['\u2019-]/;function Wi(t,e,n){let i=t[e];if(i===void 0)return!1;if(Xe.test(i))return!0;let o=t[e+n];return aa.test(i)&&o!==void 0&&Xe.test(o)}function sa(t,e,n){let i=e+n.length;return!(Xe.test(n[0])&&Wi(t,e-1,-1)||Xe.test(n[n.length-1])&&Wi(t,i,1))}function X(t,e,n=0,i=()=>!0){if(e.length===0)return t.indexOf(e,n);let o=-1,r=t.indexOf(e,n);for(;r!==-1;){if(i(r)){if(sa(t,r,e))return r;o===-1&&(o=r)}r=t.indexOf(e,r+1)}return o}function F(t,e){let n=t,i={},o=[],r=[],a=0;for(let s of e){let l=(i[s.parameter]??0)+1;i[s.parameter]=l;let c=`{{${s.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,u=h=>X(n,s.text,h,g=>!r.some(f=>g<f.end&&g+s.text.length>f.start)),m=u(a);if(m===-1&&(m=u(0)),m!==-1){n=n.slice(0,m)+c+n.slice(m+s.text.length);let h=c.length-s.text.length;for(let g of r)g.start>=m+s.text.length&&(g.start+=h,g.end+=h);r.push({start:m,end:m+c.length}),a=m>=a?m+c.length:a+h}o.push({...s,placeholder:c})}return{rawQuery:n,completedParams:o}}function oe(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function Ze(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function Me(t,e,n){let i=t.slice(e);if(n||e===0||t[e-1]===" ")return i;let o=i.indexOf(" ");return o===-1?"":i.slice(o+1)}function Ui(t,e){let n=t.trimEnd().replace(/\s+/g," ");if(n.length===0||e.length===0)return 0;let i=n.split(" "),o=e.toLowerCase();for(let r=0;r<i.length;r++){let a=i.slice(r).join(" ");if(o.startsWith(a.toLowerCase())){let s=n.length-a.length;return t.length-s}}return 0}function Bi(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function la(t,e){let n=Bi(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function ce(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?Bi(i).trimStart():"";if(o)return t.filter(a=>!a.is_tappable||la(a.text,o));let r=i.toLowerCase();return t.filter(a=>!a.is_tappable||a.text.toLowerCase().includes(r))}function Je(t,e){if(!t)return null;let n=e.trim();if(!n)return null;let i=n.toLowerCase();return t.find(o=>o.is_tappable&&o.text.toLowerCase()===i)??null}function Re(t,e,n,i,o){let r=Me(e,n,i),a=Je(t,r);if(a||!o||!r.trim())return a;if(r===e.slice(n))return null;let s=e.lastIndexOf(" ",n-1)+1;return Je(t,e.slice(s))}function Vi(t,e){let n=e.replace(/^\s+/,"").toLowerCase();for(let i=0;i<n.length;){let o=n.slice(i);if(o.trim().length>=2){let a=t.findIndex(s=>s.is_tappable&&s.text.toLowerCase().startsWith(o));if(a>=0)return t.map((s,l)=>l===a?{...s,liveMatch:!0}:s)}let r=n.indexOf(" ",i);if(r<0)break;i=r+1}return t}function Gi(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function ca(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function J(t){let e=ca(t);return e.length>0?e.join(" "):t}function z(t,e){return t.parameter||e}function _e(t){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:J(t)}}function et(t,e){let n=z(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?_e(n):{parameter:n,suggestionParameter:t.suggestionParameter,suggestionValueType:t.suggestionValueType,suggestionPlaceholder:t.suggestionPlaceholder}}function w(t){return t?.type?.kind==="traditional_autocomplete"}function $i(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function tt(t){return w(t)||t?.smart_suggestion===!0}function Jt(t){return t.some(w)?t.filter(e=>!w(e)):t}function Zt(t,e){return t.some(n=>w(n)&&!n.text)?t.map(n=>w(n)&&!n.text?{...n,text:e}:n):t}var en='<svg viewBox="0 0 20 20" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false"><path class="aia-sparkle-large" d="M8 5C8.5 9.5 10.5 11.5 15 12C10.5 12.5 8.5 14.5 8 19C7.5 14.5 5.5 12.5 1 12C5.5 11.5 7.5 9.5 8 5Z"/><path class="aia-sparkle-small" d="M16 1C16.2 3 17 3.8 19 4C17 4.2 16.2 5 16 7C15.8 5 15 4.2 13 4C15 3.8 15.8 3 16 1Z"/></svg>';function tn(t){return t.some(e=>!w(e))}function qi(t,e){let n=0,i=e;for(let o of t)n+=o.value.length,o.type!=="text"&&(i=Math.max(i,n));return i}function Ki(t,e){let n=0;for(let i of t){let o=n+i.value.length;if(i.type==="text"&&o>e&&i.value.slice(Math.max(e-n,0)).trim().length>0)return!1;n=o}return!0}function zi(t,e){let n=[],i=new Set;for(let o of[...t,...e])o.parameter==="placeholder"||w(o)||i.has(o.parameter)||(i.add(o.parameter),n.push({parameter:o.parameter,text:o.text}));return n}function ji(t,e,n){if(t===e)return n;let i=Math.min(t.length,e.length),o=0;for(;o<i&&t[o]===e[o];)o++;if(o>=n)return n;let r=0;for(;r<i-o&&t[t.length-1-r]===e[e.length-1-r];)r++;return t.length-r<=n?n+(e.length-t.length):null}function nt(t,e){let n=[],i=[],o=0;for(let r of e){let a=X(t,r.text,o);if(a===-1){i.push(r);continue}n.push({start:a,end:a+r.text.length,param:r}),o=a+r.text.length}return{located:n,missing:i}}function de(t,e){let{located:n}=nt(t,e);return n.length>0?n[n.length-1].end:0}function Yi(t,e,n){let i=[],o=[],r=0;for(let a of n){let s=X(t,a.text,r,l=>!e.some(d=>l<d.end&&l+a.text.length>d.start));if(s===-1){o.push(a);continue}i.push({start:s,end:s+a.text.length,param:a}),r=s+a.text.length}return{located:i,missing:o}}function Qi(t,e,n=[]){let i=nt(t,e).located,o=[];for(let c of i){let u=o[o.length-1];c.param.group&&u?.param.group===c.param.group?(u.end=c.end,u.params?.push(c.param)):o.push({...c,...c.param.group?{params:[c.param]}:{}})}let r=Yi(t,o,n).located,a=[...o.map(c=>({start:c.start,end:c.end,segment:{type:"completed",value:t.slice(c.start,c.end),param:c.param,...c.params?{params:c.params}:{}}})),...r.map(c=>({start:c.start,end:c.end,segment:{type:"identified",value:c.param.text,param:c.param}}))].sort((c,u)=>c.start-u.start),s=[],l=0;for(let c of a)c.start>l&&s.push({type:"text",value:t.slice(l,c.start)}),s.push(c.segment),l=c.end;let d=t.slice(l);return d&&s.push({type:"text",value:d}),s}function Xi(t,e){let{located:n,missing:i}=nt(t,e),o=new Set(i.map(a=>a.group).filter(Boolean)),r=n.map(a=>a.param).filter(a=>!o.has(a.group));return{valid:r,invalid:e.filter(a=>!r.includes(a))}}function De(t,e,n){let i=nt(t,e).located,{located:o,missing:r}=Yi(t,i,n);return{valid:o.map(a=>a.param),invalid:r}}function Ji(t,e,n){let i=e?.endpoint??K,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${da(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,a)=>{let s=ze.get(a);return s?`https://${s}`:r})}function da(t){let e=t?.replace(/_/g,"-").toLowerCase()??"",[n,i=""]=e.split("-");return n!=="zh"?/^[a-z]{2,3}$/.test(n)?`/${n}`:"":/^[a-z]{4}$/.test(i)?i==="hant"?"/zh-TW":"/zh":["tw","hk","mo"].includes(i)?"/zh-TW":"/zh"}async function Zi(t){try{let e=await t;if(!e.ok)return null;let n=await e.json();return Array.isArray(n?.data?.suggestions)?n:null}catch{return null}}function ua(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var pa=100,ma=300,ga=2,it=class{constructor(e,n,i,o,r,a,s,l,d,c={}){this.store=e;this.getApiConfig=n;this.getOptionOverrides=i;this.getMaskCompletedText=o;this.getOnError=r;this.getSessionId=a;this.getSource=s;this.getAdditionalContext=l;this.getLanguage=d;this.callbacks=c;this.fetchVersion=0;this.abortController=null;this.debounceTimer=null;this.slowDebounceTimer=null;this.unsubscribe=null;this.phraseExactMatch=!1}start(){this.doFetch("",[]);let e=this.store.get().text,n=this.store.get().completedParams;this.unsubscribe=this.store.subscribe(i=>{(i.text!==e||i.completedParams!==n)&&(e=i.text,n=i.completedParams,this.scheduleFetch())})}isPhraseExactMatch(){return this.phraseExactMatch}dispose(){this.abortController?.abort(),this.clearTimers(),this.unsubscribe?.()}async doFetch(e,n){this.abortController?.abort();let i=new AbortController;this.abortController=i;let o=++this.fetchVersion,r=this.store.get().text.length;try{this.callbacks.onRequest?.({query:this.store.get().text,signal:i.signal,isCurrent:()=>o===this.fetchVersion})}catch{}try{this.store.set({isLoading:!0,error:null});let a=this.store.get(),s=a.pendingSpan?zi(a.pendingSpan.snapshot,a.actionableSuggestions):void 0,l=crypto.randomUUID(),d=e===""&&n.length===0&&a.skippedParams.length===0&&a.identifiedParams.length===0?this.startingStateUrl():void 0,c=d?await Zi(fetch(d,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let u=c??await Ni(e,n,{sessionId:this.getSessionId(),requestId:l,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:i.signal,apiConfig:this.getApiConfig(),identifiedParams:a.identifiedParams,recentlySuggested:s,skippedParams:a.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})});if(o!==this.fetchVersion)return;this.phraseExactMatch=u.meta?.phrase_exact_match===!0;let m=(u.data.suggestions??[]).find(w),h=m?[]:u.data.input??[],g=h.filter(v=>v.source==="identified").map(v=>({id:crypto.randomUUID(),parameter:v.parameter,text:v.text,...v.type?{type:v.type}:{}})),f=this.callbacks.isWordOpen?.()??!1,S=this.store.get().text.toLowerCase(),y=v=>f&&S.endsWith(v.text.toLowerCase()),p=g.filter(v=>!y(v));f&&this.callbacks.holdIdentified?.(g.filter(y));let b=m?[m]:Gi(u.data.suggestions??[],this.getOptionOverrides()),T=h,x=T[T.length-1],L=this.store.get().text,P,E;if(x?.state==="in_progress"){E=!0;let v=L.toLowerCase().lastIndexOf(x.text.toLowerCase());P=v!==-1?v:r}else E=!1,P=r;let A=b.filter(v=>v.parameter!=="placeholder")[0],B=null;if(A&&!w(A)&&!f&&A.type?.kind!=="multi_select"&&!D(Q(A))){let v=Re(A.options,L,P,E,this.phraseExactMatch);v&&(B={id:crypto.randomUUID(),placeholder:"",parameter:z(v,A.parameter),text:v.text,value:v.value,kind:v.kind,suggestionParameter:A.parameter,suggestionValueType:A.type,suggestionPlaceholder:A.text,options:A.options??[],metadata:v.metadata,icon:v.icon,icon_svg:v.icon_svg,image_url:v.image_url},b=b.filter(Y=>Y!==A),this.callbacks.onAutoMatch?.({active:A,matched:v,rawQuery:e}))}let te=u.data.custom_fields??null,_=this.callbacks.productsForResponse?.(te);this.store.set(v=>{let Y=B?[...v.completedParams,B]:v.completedParams,R=De(v.text,Y,p).valid,ne=new Set(a.skippedParams.map(V=>V.id)),$e=new Set(v.skippedParams.filter(V=>!ne.has(V.id)).map(V=>V.parameter));return{suggestions:$e.size>0?b.filter(V=>V.parameter==="placeholder"||!$e.has(V.parameter)):b,isLoading:!1,isReady:u.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:P,filterInProgress:E,identifiedParams:R,customFields:te,traditionalAutocomplete:u.meta?.traditional_autocomplete===!0,..._!==void 0?{products:_}:{},...B?{completedParams:Y}:{}}}),this.callbacks.onResponse?.({requestId:l,funnelTelemetry:u.meta?.funnel_telemetry===!0,visibleImpression:u.meta?.visible_impression===!0})}catch(a){let s=ua(a);o===this.fetchVersion&&(this.store.set({error:s,isLoading:!1}),this.getOnError()?.(s))}finally{if(o===this.fetchVersion&&this.store.get().isLoading)try{this.store.set({isLoading:!1})}catch{}}}startingStateUrl(){let e=this.callbacks.getProductId?.();return e?Ji(e,this.getApiConfig(),ie(this.getLanguage())):void 0}attemptNow(){if(this.clearTimers(),this.store.get().skipNextFetch){this.store.set({skipNextFetch:!1});return}this.attemptFetch(1,!0)}scheduleFetch(){if(this.clearTimers(),this.store.get().skipNextFetch){this.store.set({skipNextFetch:!1});return}this.debounceTimer=setTimeout(()=>{this.attemptFetch(ga)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},pa),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),ma)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;let a=o.suggestions.filter(L=>L.parameter==="placeholder").map(L=>L.text).join(" "),s=oe(o.text,o.filterBase,a),l=Me(o.text,s,o.filterInProgress),d=o.suggestions.filter(L=>L.parameter!=="placeholder"),c=w(d[0])?void 0:d[0],u=D(o.activeFormatType),m=c&&!u?ce(c.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&m.length>0)return!1;let h=m.filter(L=>L.is_tappable),g=c&&!u&&!this.callbacks.isWordOpen?.()?Re(c.options,o.text,s,o.filterInProgress,this.phraseExactMatch)!==null:!1,f=l.trim().length>0,S=i&&o.products.length>0;if(h.length>0&&!g&&f&&!S||Ze(o.text,o.completedParams.length,a))return!1;let{rawQuery:y,completedParams:p}=F(o.text,o.completedParams),b=y.length<o.lastRawQuery.length,T=Math.abs(y.length-o.lastRawQuery.length),x=n&&y!==o.lastRawQuery;return b||T>=e||x?(this.doFetch(y,p),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var fa="(hover: none) and (pointer: coarse)";var ha="[data-aia-dropdown], [data-aia-input-wrapper]",ba=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),ot=class{constructor(e,n){this.store=e;this.container=n;this.listening=!1;this.declined=!1;this.pressOutside=!1;this.pressWhileFocused=!1;this.recheckTimer=null;this.releaseTimer=null;this.onPointerDown=e=>{let n=e.composedPath(),i=this.isInside(n);this.pressOutside=!i;let o=this.store.get();this.pressWhileFocused=o.isFocused,!(i||!o.isFocused)&&(this.declined=n.some(r=>r instanceof Element&&r.matches(ba)),this.declined&&o.dropdownHeld?this.store.set({dropdownHeld:!1}):!this.declined&&!o.dropdownHeld&&o.isDropdownOpen&&this.store.set({dropdownHeld:!0}))};this.onPointerCancel=()=>{this.pressOutside=!1,this.pressWhileFocused&&this.declined&&this.scheduleRecheck(),this.pressWhileFocused=!1};this.onPointerUp=e=>{let n=this.pressOutside&&!this.isInside(e.composedPath()),i=this.pressWhileFocused;if(this.pressOutside=!1,this.pressWhileFocused=!1,i){this.declined&&this.scheduleRecheck();return}!n||this.store.get().isFocused||(this.cancelRelease(),this.releaseTimer=setTimeout(()=>{this.releaseTimer=null;let o=this.store.get();o.dropdownHeld&&!o.isFocused&&this.store.set({dropdownHeld:!1})},150))};this.touchPrimary=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(fa):null,this.unsubscribe=e.subscribe(()=>this.sync())}dispose(){this.unsubscribe(),this.listen(!1),this.cancelRelease(),this.recheckTimer!==null&&clearTimeout(this.recheckTimer),this.recheckTimer=null}sync(){let e=this.store.get(),n=this.touchPrimary?.matches??!1;e.isFocused||(this.declined=!1),e.isDropdownOpen?e.isFocused&&!e.dropdownHeld&&!this.declined&&n&&this.store.set({dropdownHeld:!0}):e.dropdownHeld&&this.store.set({dropdownHeld:!1});let i=this.store.get();this.listen(n&&i.isDropdownOpen),i.isFocused&&this.cancelRelease()}listen(e){if(!(e===this.listening||typeof document>"u")){if(this.listening=e,e){document.addEventListener("pointerdown",this.onPointerDown,!0),document.addEventListener("pointerup",this.onPointerUp,!0),document.addEventListener("pointercancel",this.onPointerCancel,!0);return}document.removeEventListener("pointerdown",this.onPointerDown,!0),document.removeEventListener("pointerup",this.onPointerUp,!0),document.removeEventListener("pointercancel",this.onPointerCancel,!0),this.pressOutside=!1}}scheduleRecheck(){this.recheckTimer!==null&&clearTimeout(this.recheckTimer),this.recheckTimer=setTimeout(()=>{this.recheckTimer=null,!(!this.declined||!this.store.get().isFocused)&&(this.declined=!1,this.sync())},150)}cancelRelease(){this.releaseTimer!==null&&(clearTimeout(this.releaseTimer),this.releaseTimer=null)}isInside(e){let n=this.container,i=n?.getRootNode(),o=typeof ShadowRoot<"u"&&i instanceof ShadowRoot?i.host:null;for(let r of e)if(r===n||r===o||r instanceof Element&&r.matches(ha))return!0;return!1}};var be=["January","February","March","April","May","June","July","August","September","October","November","December"],rt=["S","M","T","W","T","F","S"],no=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],io="aiaDate",oo="aiaDay",eo=t=>String(t).padStart(2,"0");function G(t){return`${t.getFullYear()}-${eo(t.getMonth()+1)}-${eo(t.getDate())}`}function nn(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Sa(t){let e=nn(t).getTime()-nn(new Date).getTime();return Math.round(e/864e5)}function ro(t){let e=Sa(t);return e>=0&&e<7?no[t.getDay()]:Se(t)}function Se(t){return t.getFullYear()===new Date().getFullYear()?`${be[t.getMonth()]} ${t.getDate()}`:`${be[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function at(t){if(!t)return null;let e=no.findIndex(s=>s.toLowerCase()===t.trim().toLowerCase());if(e>=0){let s=nn(new Date),l=(e-s.getDay()+7)%7;return new Date(s.getFullYear(),s.getMonth(),s.getDate()+l)}let n=/^\s*([A-Za-z]+)\s+(\d{1,2})(?:\s+(\d{4}))?\s*$/.exec(t);if(!n)return null;let i=be.findIndex(s=>s.toLowerCase()===n[1].toLowerCase());if(i<0)return null;let o=Number(n[2]),r=n[3]?Number(n[3]):new Date().getFullYear(),a=new Date(r,i,o);return a.getMonth()!==i||a.getDate()!==o?null:a}function on(t){return`${be[t.month]} ${t.year}`}function rn(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function ao(t){return{year:t.getFullYear(),month:t.getMonth()}}function an(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function to(){return{text:"",is_tappable:!1,kind:null}}function sn(t){let e=new Date(t.year,t.month,1).getDay(),n=new Date(t.year,t.month+1,0).getDate(),i=[];for(let o=0;o<e;o++)i.push(to());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:ro(r),is_tappable:!0,kind:null,metadata:{[io]:G(r),[oo]:o}})}for(;i.length%rt.length!==0;)i.push(to());return i}function ln(t){let e=at(t);return e?G(e):null}function Z(t){let e=t?.metadata?.[io];return typeof e=="string"?e:null}function cn(t){let e=t?.metadata?.[oo];return typeof e=="number"?e:null}function ya(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function re(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&ya(e)?e:t.ownerDocument??t}function st(t){return re(t).activeElement??null}function M(t){return t.ownerDocument??t}function xa(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function so(t){let e=re(t);return!xa(e)||typeof e.getSelection=="function"?null:e}function lo(t){let e=so(t);if(!e)return null;let n=M(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function co(t,e){let n=t,i;try{i=n.getComposedRanges({shadowRoots:[e]})}catch{i=n.getComposedRanges(e)}return i.length>0?i[0]:null}function Ne(t){let n=re(t).getSelection?.();return n||(M(t).getSelection?.()??null)}function ae(t){let e=Ne(t);if(!e||e.rangeCount===0)return null;let n=lo(t);if(n){let i=co(e,n);return i?{node:i.startContainer,offset:i.startOffset,collapsed:i.startContainer===i.endContainer&&i.startOffset===i.endOffset}:null}return e.anchorNode?{node:e.anchorNode,offset:e.anchorOffset,collapsed:e.isCollapsed}:null}function ye(t){let e=Ne(t);if(!e||e.rangeCount===0)return null;let n=lo(t);if(!n)return e.getRangeAt(0);let i=co(e,n);if(!i)return null;let o=M(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function Fe(t,e,n){let i=Ne(t);if(!i)return null;if(so(t))return i.collapse(e,n),i;let o=M(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function lt(t,e){let n=t?re(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var ct=2,Ta="magicx-aia";function uo(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function va(t){let e=M(t),n=e.defaultView;if(!n?.getComputedStyle)return null;let i=t;for(;i&&i!==e.body&&i!==e.documentElement;){let o=i.scrollWidth>i.clientWidth,r=i.scrollHeight>i.clientHeight;if(o||r){let a=n.getComputedStyle(i);if(o&&uo(a.overflowX)||r&&uo(a.overflowY))return i}if(i.classList.contains(Ta))return null;i=i.parentElement}return null}function dn(t){let e=ye(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=va(t);if(!n||typeof e.getBoundingClientRect!="function")return;let i=e.getBoundingClientRect();if(i.height===0)return;let o=n.getBoundingClientRect();if(n.scrollWidth>n.clientWidth){let r=o.left+n.clientLeft,a=r+n.clientWidth;i.right>a?n.scrollLeft+=i.right-a+ct:i.left<r&&(n.scrollLeft-=r-i.left+ct)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,a=r+n.clientHeight;i.bottom>a?n.scrollTop+=i.bottom-a+ct:i.top<r&&(n.scrollTop-=r-i.top+ct)}}var mo='[contenteditable="false"]',pn="strong[data-param-id]",xe;function Ea(){if(xe!==void 0)return xe;let t=globalThis.Intl.Segmenter;if(!t)return xe=null,null;try{xe=new t(void 0,{granularity:"grapheme"})}catch{xe=null}return xe??null}function dt(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(mo))return!0;n=n.parentNode}return!1}function ut(t){return M(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return dt(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function pt(t){let e=ut(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function mn(t){let e=ut(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function $(t){let e=ae(t);if(!e)return null;let n=e.node,i=e.offset;if(!t.contains(n))return null;if(n.nodeType===Node.ELEMENT_NODE){let o=n;if(dt(o,t)&&o!==t)return null;let r=0;for(let a=0;a<i&&a<o.childNodes.length;a++)r+=gn(o.childNodes[a],t);return r+un(o,t)}return n.nodeType!==Node.TEXT_NODE||dt(n,t)?null:un(n,t)+i}function gn(t,e){if(t.nodeType===Node.TEXT_NODE)return dt(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(mo))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=gn(o,e);return i}function un(t,e){let n=ut(e),i=0,o=n.nextNode();for(;o;){if(o===t||t.nodeType===Node.ELEMENT_NODE&&t.contains(o))return i;i+=o.data.length,o=n.nextNode()}return i}function H(t,e){let n=M(t),i=Math.max(0,Math.min(e,mn(t))),o=ut(t),r=0,a=null,s=0,l=o.nextNode(),d=null;for(;l;){let u=l.data.length;if(i<r+u){a=l,s=i-r;break}if(i===r+u){let m=o.nextNode();m?(a=m,s=0):(a=l,s=u);break}r+=u,d=l,l=o.nextNode()}let c=n.createRange();if(a){let u=a.parentElement?.closest('strong[data-seg="completed"]');u&&u!==t&&t.contains(u)?s===0?c.setStartBefore(u):s===a.data.length?c.setStartAfter(u):c.setStart(a,s):c.setStart(a,s)}else d?c.setStart(d,d.data.length):c.setStart(t,0);c.collapse(!0),Fe(t,c.startContainer,c.startOffset)&&(wa(t,c,i),dn(t))}function po(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(pn)??null;return i&&e.contains(i)?i:null}function wa(t,e,n){let i=po(ae(t)?.node??null,t);if(i&&i!==po(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function go(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=$(t);return i!==null&&n===`${i}:${e}`}function fn(t){return re(t).activeElement===t}function hn(t,e){if(!e||e.nodeType===void 0)return null;let n=e,o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(pn);if(!o||!t.contains(o))return null;let r=ae(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function bn(t,e){let n=null;for(let a of t.querySelectorAll(pn))if(a.dataset.paramId===e){n=a;break}if(!n)return;let i=un(n,t),o=i+gn(n,t),r=$(t);r!=null&&r>=i&&r<=o||H(t,i)}function Sn(t){let e=$(t);return e==null?!1:e>=mn(t)}function yn(t,e){if(e<=0)return 0;let n=Ea();if(!n)return e-1;let i=t.slice(0,e),o=0;for(let{index:r}of n.segment(i))r<e&&(o=r);return o}var fo="aiaTime",Tn=5;var vn=[12,1,2,3,4,5,6,7,8,9,10,11],En=Array.from({length:60/5},(t,e)=>e*5),wn=["AM","PM"];function ve(t){return(Math.round(t)%1440+1440)%1440}function Pn(t){let e=ve(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function mt(t){let e=t.hour%12+(t.period==="PM"?12:0);return ve(e*60+t.minute)}function gt(t){let{hour:e,minute:n,period:i}=Pn(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function ho(t){let e=ve(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function Te(t){return ve(Math.round(t/5)*5)}function bo(t,e){return ve(t+e)}var Pa=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,Ca=/^(\d{1,2}):(\d{2})$/;function xn(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=Pa.exec(e);if(n){let o=Number(n[1]),r=n[2]===void 0?0:Number(n[2]);return o<1||o>12||r>59?null:mt({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=Ca.exec(e);if(i){let o=Number(i[1]),r=Number(i[2]);return o>23||r>59?null:o*60+r}return null}function So(t){let e=xn(t.editingText);if(e!=null)return Te(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>xn(o.text)).filter(o=>o!=null);if(n.length>0)return Te(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return ve((i.getHours()+1)*60)}function Cn(t){return{text:gt(t),is_tappable:!0,kind:null,metadata:{[fo]:ho(t)}}}var ft=30,ht=["hour","minute","period"],Ln={hour:vn.map(t=>({label:String(t)})),minute:En.map(t=>({label:String(t).padStart(2,"0")})),period:wn.map(t=>({label:t}))};function In(t){return Ln[t]}function bt(t,e){let n=Pn(Te(e));return t==="hour"?vn.indexOf(n.hour):t==="minute"?En.indexOf(n.minute):wn.indexOf(n.period)}function St(t,e,n){let i=Ln[t],o=Math.min(Math.max(n,0),i.length-1),r=Pn(Te(e));return mt(t==="hour"?{...r,hour:vn[o]}:t==="minute"?{...r,minute:En[o]}:{...r,period:wn[o]})}function On(t,e){let n=Ln[t].length-1;return Math.min(Math.max(Math.round(e/ft),0),n)}function ue(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=F(t,e);return{query:t.trim(),raw_query:o,completed_params:Ae(r,n),identified_params:Oe(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function yt(t,e){return t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement?t.selectionStart!=null&&t.selectionStart===t.value.length:t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?Sn(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function An(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?$(t):null}var xt=class{constructor(e,n){this.store=e;this.ctx=n}handleKeyDown(e){if(e.isComposing||e.keyCode===229)return;let n=this.store.get(),{listboxId:i,getOnSubmit:o}=this.ctx,r=e.target instanceof Node?e.target:null,a=this.getEffectiveColumns(r),s=o(),l=this.getTappableIndices(a);if((e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)&&(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight"))return;let d=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let c=n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&c?.is_tappable){e.preventDefault(),this.ctx.selectOption(c);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&c?.is_tappable&&this.ctx.selectOption(c),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let c=yt(e.target,n),u=!!n.editingParam;if(!c&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(d)break;e.preventDefault();let g=k(n.activeFormatType)?this.dateEntryIndex(n,!1):l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:g});break}if(l.length===0)return;this.store.set({activeDropdownIndex:g});break}if(e.preventDefault(),l.length===0)return;if(k(n.activeFormatType)){this.stepDateWeek(n,7);break}if(n.filteredOptions.length>0){let g=Math.floor((n.filteredOptions.length-1)/a);if(Math.floor(n.activeDropdownIndex/a)===g){this.store.set({activeDropdownIndex:-1});break}}let m=l.indexOf(n.activeDropdownIndex),h=m<l.length-1?m+1:0;this.store.set({activeDropdownIndex:l[h]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!d)break;let m=yt(e.target,n),h=!!n.editingParam;if(!m&&!h)break;e.preventDefault();let g=k(n.activeFormatType)?this.dateEntryIndex(n,!0):this.firstTappableInBottomRow(a)??l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:g});break}if(l.length===0)return;this.store.set({activeDropdownIndex:g});break}if(l.length===0)break;if(e.preventDefault(),k(n.activeFormatType)){this.stepDateWeek(n,-7);break}if(n.activeDropdownIndex<a){this.store.set({activeDropdownIndex:-1});break}let c=l.indexOf(n.activeDropdownIndex),u=c>0?c-1:l.length-1;this.store.set({activeDropdownIndex:l[u]});break}case"ArrowRight":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%a<a-1){let m=n.activeDropdownIndex+1;m<n.filteredOptions.length&&n.filteredOptions[m]?.is_tappable&&this.store.set({activeDropdownIndex:m})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,m=n.editingTail;this.ctx.exitEditMode?.(),H(u,m);break}yt(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,-1);break}if(n.activeDropdownIndex%a>0){let c=n.activeDropdownIndex-1;c>=0&&n.filteredOptions[c]?.is_tappable&&this.store.set({activeDropdownIndex:c});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let c=An(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingAnchor!=null){e.preventDefault();let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingAnchor;this.ctx.exitEditMode?.(),H(c,u);break}if(this.ctx.startEditingParamAtCaret){let c=An(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let c=An(e.target);if(c==null)break;this.ctx.removeParamAtCaret(c)&&e.preventDefault();break}case"Enter":{if(e.preventDefault(),n.activeDropdownIndex>=0&&n.filteredOptions[n.activeDropdownIndex]?.is_tappable)this.clickOrSelect(n.activeDropdownIndex,n.filteredOptions,i,r);else if(s){this.ctx.endTypedWord?.(!0);let c=this.store.get();s(ue(c.text,c.completedParams,c.skippedParams,{identifiedParams:c.identifiedParams,isReady:c.isReady,customFields:c.customFields}))&&this.ctx.afterSubmit?.()}break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let c=n.filteredOptions.map((h,g)=>h.is_tappable?g:-1).filter(h=>h!==-1);if(c.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let h=e.shiftKey?c[c.length-1]:c[0];this.store.set({pillTapped:!0,activeDropdownIndex:h});break}e.preventDefault();let u=c.indexOf(n.activeDropdownIndex),m;if(u<0)m=e.shiftKey?c.length-1:0;else{let h=e.shiftKey?-1:1;m=(u+h+c.length)%c.length}this.store.set({activeDropdownIndex:c[m]});break}case"Escape":{if(n.dateRangeStart){this.store.set({pendingRangeStart:null});break}if(n.editingIdentified){this.ctx.exitEditingIdentified?.(),this.store.set({activeDropdownIndex:-1});break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingTail;this.ctx.exitEditMode?.(),H(c,u)}this.store.set({activeDropdownIndex:-1});break}}}handleTimeWheelKey(e,n){let i=n.timeView;if(n.activeFormatType!=="time"||!i||!n.isDropdownOpen)return!1;switch(e.key){case"ArrowDown":case"ArrowUp":return!yt(e.target,n)&&!n.editingParam?!1:(e.preventDefault(),this.ctx.stepTime?.(e.key==="ArrowDown"?5:-5),!0);case"Enter":return i.touched?(e.preventDefault(),this.ctx.commitTime?.(),!0):!1;case"Escape":return i.touched?(this.store.set({timeDraft:null}),!0):!1;default:return!1}}firstTappableInBottomRow(e){let n=this.store.get();if(n.filteredOptions.length===0)return null;let o=Math.floor((n.filteredOptions.length-1)/e)*e;for(let r=o;r<n.filteredOptions.length;r++)if(n.filteredOptions[r]?.is_tappable)return r;return null}dateEntryIndex(e,n){let i=G(new Date),o=e.filteredOptions.findIndex(a=>Z(a)===i);if(o>=0)return o;let r=e.filteredOptions.map((a,s)=>a.is_tappable?s:-1).filter(a=>a!==-1);return(n?r[r.length-1]:r[0])??0}stepDateDay(e,n){for(let i=e.activeDropdownIndex+n;i>=0&&i<e.filteredOptions.length;i+=n)if(e.filteredOptions[i]?.is_tappable){this.store.set({activeDropdownIndex:i});return}}stepDateWeek(e,n){let i=e.activeDropdownIndex+n;this.store.set({activeDropdownIndex:e.filteredOptions[i]?.is_tappable?i:-1})}getTappableIndices(e){let i=this.store.get().filteredOptions.map((r,a)=>r.is_tappable?a:-1).filter(r=>r!==-1),o=Array.from({length:e},()=>[]);for(let r of i)o[r%e].push(r);return o.flat()}getEffectiveColumns(e){let n=lt(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=lt(e,`${this.ctx.listboxId}-option-0`)?.parentElement??null;for(;o;){let r=getComputedStyle(o).gridTemplateColumns;if(r&&r!=="none"){let a=r.split(" ").filter(Boolean).length;if(a>0)return a}if(o===n)break;o=o.parentElement}return this.ctx.columns}clickOrSelect(e,n,i,o){let r=lt(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var Tt=class{constructor(e,n,i={}){this.store=e;this.getOverrides=n;this.callbacks=i;this.unsubscribe=null;this.current=null;this.version=0;this.lastMiss=null;this.hasLoggedError=!1}start(){this.unsubscribe=this.store.subscribe(e=>this.sync(e)),this.sync(this.store.get())}dispose(){this.unsubscribe?.(),this.unsubscribe=null,this.cancel(),this.current=null}reset(){this.cancel(),this.current=null,this.lastMiss=null}refresh(){this.reset(),this.sync(this.store.get())}hasOverride(e){return!!this.getOverrides()?.[e]}owns(e,n){return this.hasOverride(e)&&!this.missCovers(e,n)}tick(e,n){let i=this.resolveTarget(e);if(!i||this.missCovers(i.parameter,i.query))return"no";let o=this.current;if(o&&o.key===i.key){if(o.query===i.query)return"owns";let r=Math.abs(i.query.length-o.query.length),a=i.query.length<o.query.length;if(n>1&&!a&&r<n)return"owns"}return this.ask(i),"asked"}sync(e){let n=this.resolveTarget(e);if(!n){this.current&&(this.cancel(),this.current=null),e.optionSearch&&this.store.set({optionSearch:null});return}this.current&&this.current.key===n.key||this.ask(n)}resolveTarget(e){if(D(e.activeFormatType)||e.editingIdentified)return null;let n=e.editingParam;if(n&&e.editingAnchor!=null)return this.hasOverride(n.suggestionParameter)?{mode:"edit",key:n.id,parameter:n.suggestionParameter,suggestion:{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options},query:e.optionQuery}:null;let i=e.actionableSuggestions[0];return!i||!this.hasOverride(i.parameter)?null:{mode:"pill",key:i,parameter:i.parameter,suggestion:i,query:e.optionQuery}}missCovers(e,n){return this.lastMiss!=null&&this.lastMiss.parameter===e&&this.lastMiss.query===n}ask(e){this.cancel();let n=this.getOverrides()?.[e.parameter],i=++this.version;if(!n||this.missCovers(e.parameter,e.query)){this.current={key:e.key,parameter:e.parameter,query:e.query,abort:null},this.setSearch(e,"done");return}let o=new AbortController;this.current={key:e.key,parameter:e.parameter,query:e.query,abort:o};let r;try{r=n(e.query,o.signal,e.suggestion)}catch(a){this.logOnce(a),this.commit(e,[],i);return}if(Array.isArray(r)){this.commit(e,r,i);return}this.setSearch(e,"loading"),this.await(e,r,o.signal,i)}async await(e,n,i,o){let r;try{let a=await n;if(i.aborted||o!==this.version)return;r=Array.isArray(a)?a:[]}catch(a){if(i.aborted||o!==this.version||La(a))return;this.logOnce(a),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=this.resolveTarget(this.store.get());if(!o||o.key!==e.key)return;n.length===0?this.lastMiss={parameter:e.parameter,query:e.query}:this.lastMiss?.parameter===e.parameter&&(this.lastMiss=null);let r={parameter:e.parameter,query:e.query,status:"done"};if(e.mode==="edit")this.store.set(a=>({editingParam:a.editingParam&&a.editingParam.id===e.key?{...a.editingParam,options:n}:a.editingParam,optionSearch:r}));else{let a={...e.suggestion,options:n};this.current&&this.current.key===e.key&&(this.current.key=a),this.store.set(s=>({suggestions:s.suggestions.map(l=>l===e.suggestion?a:l),optionSearch:r}))}n.length===0?this.callbacks.onMiss?.(e.mode,e.query):this.callbacks.onAnswer?.(e.mode,e.query)}setSearch(e,n){let i=this.store.get().optionSearch;i&&i.parameter===e.parameter&&i.query===e.query&&i.status===n||this.store.set({optionSearch:{parameter:e.parameter,query:e.query,status:n}})}cancel(){this.current?.abort?.abort(),this.version++}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] an optionOverrides entry threw or rejected \u2014 treated as no options. Later failures on this instance are not logged.",e))}};function La(t){return t instanceof Error&&t.name==="AbortError"}var vt=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(d=>d.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(w(o))return;let r=i.filter((d,c)=>c!==e),a=n.suggestions.filter(d=>d.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:d}=F(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:d,selectedPill:o.text,otherPills:r.map(c=>c.text)})}let s=[...a,o,...r],l=this.store.peek({suggestions:s}).filteredOptions.findIndex(d=>d.is_tappable);this.store.set({suggestions:s,pillTapped:!0,activeDropdownIndex:l})}removeLastParam(){this.store.get().completedParams.length!==0&&this.store.set(n=>({completedParams:n.completedParams.slice(0,-1),activeDropdownIndex:-1}))}};var To="/products/",yo="https://relative.invalid";function Ia(t){if(!t)return;let e;try{e=new URL(t,`${yo}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===yo?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function vo(t,e){let n=Ia(t.item_url)??Aa(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:xo(t.price,t.currency,e)},...Oa(t)&&{compareAtPrice:xo(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function Oa(t){if(!t.price||!t.compare_at_price)return!1;let e=Number(t.price),n=Number(t.compare_at_price);return Number.isFinite(e)&&Number.isFinite(n)&&n>e}function xo(t,e,n){if(n===void 0||!e||!/^\d+(\.\d+)?$/.test(t))return t;try{return new Intl.NumberFormat(n,{style:"currency",currency:e}).format(Number(t))}catch{return t}}function Aa(t){if(!t.handle)return;let e=`${To}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function kn(t,e){return(t?.items.matched??[]).map(n=>vo(n,e))}var Et=class{constructor(e,n,i=()=>!0,o=()=>{},r=()=>{}){this.store=e;this.getConfig=n;this.isEnabled=i;this.getLanguage=o;this.getMapper=r;this.hasLoggedError=!1;this.hasLoggedMapperError=!1}forResponse(e){if(!this.isEnabled())return[];if(this.getConfig())return;let n=kn(e,ie(this.getLanguage())),i=this.getMapper();if(!i)return n;try{let o=i(n,e?.items.matched??[]);if(Array.isArray(o))return o}catch(o){this.hasLoggedMapperError||(this.hasLoggedMapperError=!0,console.warn("[AIAutocomplete] mapProducts failed. The original cards are shown.",o))}return n}async run(e,n,i){if(!this.isEnabled())return;let o=this.getConfig();if(!o)return;if(e.trim().length===0){this.clear(i);return}let r=()=>n.aborted||!i()||!this.owns(o);try{let a=await o.fetch(e,n);if(r())return;let s=o.transform(a),l=Array.isArray(s)?s:[],d=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(d)}catch(a){if(n.aborted||ka(a)||(this.logOnce(a),r()))return;this.clear(i)}}owns(e){return this.isEnabled()&&this.getConfig()===e}resync(){let e=this.forResponse(this.store.get().customFields);this.commit(e??[])}refresh(){if(this.getConfig())return;let e=this.forResponse(this.store.get().customFields);e!==void 0&&this.commit(e)}clear(e){e()&&this.commit([])}commit(e){e.length===0&&this.store.get().products.length===0||this.store.set({products:e})}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] products.fetch/transform failed \u2014 the product strip is hidden. Later failures on this instance are not logged.",e))}};function ka(t){return t instanceof Error&&t.name==="AbortError"}function Ma(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function Eo(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:be.findIndex(n=>n.toLowerCase().startsWith(e))}function Ra(t,e,n){let i=new Date(n.getFullYear(),t,e);if(i.getMonth()!==t||i.getDate()!==e)return null;let o=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(i>=o)return i;let r=new Date(n.getFullYear()+1,t,e);return r.getMonth()===t&&r.getDate()===e?r:null}function wo(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function He(t,e={}){if(!t)return null;let n=e.today??new Date,i=Ma(t.trim().toLowerCase()).replace(/\s+/g," "),o=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(i);if(o){let l=wo(Number(o[1]),Number(o[2])-1,Number(o[3]));return l?G(l):null}let r=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(i);if(r){let l=Eo(r[1]);if(l>=0)return wt(l,Number(r[2]),r[3],n)}let a=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(i);if(a){let l=Eo(a[2]);if(l>=0)return wt(l,Number(a[1]),a[3],n)}let s=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(i);if(s){let l=Number(s[1]),d=Number(s[2]);return l>12&&d<=12?wt(d-1,l,s[3],n):d>12&&l<=12?wt(l-1,d,s[3],n):null}return null}function wt(t,e,n,i){if(n){if(n.length!==4)return null;let r=wo(Number(n),t,e);return r?G(r):null}let o=Ra(t,e,i);return o?G(o):null}function Mn(t,e={}){let n=t.isoDate;return typeof n=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(n)?n:He(t.text,e)}var Co=" - ",_n="aiaDateRangeStart",Dn="aiaDateRangeEnd";function We(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var Rn=/^\d{4}-\d{2}-\d{2}$/;function Po(t){if(!Rn.test(t))return null;let[e,n,i]=t.split("-").map(Number),o=new Date(e,n-1,i);return o.getMonth()===n-1&&o.getDate()===i?o:null}var _a=/\s+(?:to|through|thru|until|til|till)\s+/g,Da=/[-–—]/g;function Na(t){let e=[];for(let n of[_a,Da]){n.lastIndex=0;let i=n.exec(t);for(;i!==null;)e.push([t.slice(0,i.index),t.slice(i.index+i[0].length)]),i=n.exec(t)}return e}function Pt(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of Na(t.trim())){let a=He(o.trim(),e);if(!a)continue;let s=He(r.trim(),e);!s||s<a||(n.add(`${a}|${s}`),i={start:a,end:s})}return n.size===1?i:null}function Lo(t){let e=Po(t.start),n=Po(t.end);return!e||!n?"":t.start===t.end?Se(e):`${Se(e)}${Co}${Se(n)}`}function Io(t,e){let n=We(t,e);return{text:Lo(n),is_tappable:!0,kind:null,metadata:{[_n]:n.start,[Dn]:n.end}}}function Ue(t,e={}){let n=t?.metadata?.[_n],i=t?.metadata?.[Dn];return typeof n=="string"&&typeof i=="string"&&Rn.test(n)&&Rn.test(i)?We(n,i):Pt(t?.text,e)}var Ct="(max-width: 768px)";var Fa="var(--aia-option-row-height, 37px)",Ha="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function Oo(t,e){return e?Nn(1,Math.min(t,5)):Nn(1,Math.min(t,4))}function Nn(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${Fa} + ${Ha})`}}function Hn(t,e){return!e&&t>=5}function Wn(t,e,n,i){if(!(!e&&t>=5&&Wa(n,i))){let a=Oo(t,e);return{...a,template:Fn(a.cols),scrollHintIndices:!e&&t>a.rows?[a.rows-1]:[]}}let r=6;return{...Nn(2,3),template:Fn(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function Wa(t,e){return!t||t.length===0||e==null||e<=0||t.some(i=>i<=0)?!1:Math.ceil(Math.max(...t))*2<=e}function Un(t){if(typeof document>"u")return null;let e=Array.from(t.querySelectorAll("[data-aia-option]"));if(e.length===0)return null;let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:-9999px;top:0;";for(let a of e){let s=a.cloneNode(!0);s.removeAttribute("id"),s.removeAttribute("role"),s.removeAttribute("aria-selected"),s.style.whiteSpace="nowrap",s.style.width="max-content",n.appendChild(s)}t.appendChild(n);let i=Array.from(n.children).map(a=>a.offsetWidth);n.remove();let o=getComputedStyle(t),r=t.clientWidth-(Number.parseFloat(o.paddingLeft)||0)-(Number.parseFloat(o.paddingRight)||0)-(Number.parseFloat(o.columnGap)||0);return{rowWidths:i,gridWidth:r}}function Fn(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function Bn(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Ct).matches}function Vn(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}function Ao(t,e){let n=e.dropdownTrigger??"auto",i=e.closeDropdownOnBlur??!0,a=t.filteredOptionsLength>0||t.activePillHasNoOptions||t.hasProducts;if(t.inEditMode){let s=i?t.isFocused||t.dropdownHeld:!0;return a&&s}if(n==="auto"){let s=i?t.isFocused||t.dropdownHeld:!0,l=t.text.replace(/\s+$/,"").length,d=t.caretOffset==null||t.caretOffset>=l;return(a||t.isLoading)&&s&&d}return n==="manual"?(a||t.isLoading)&&t.pillTapped:!1}function W(t){if(t.editingIdentified){let{parameter:n,anchor:i}=t.editingIdentified;return`identified:${n}@${i}`}return t.editingParam!=null&&t.editingAnchor!=null?`edit:${t.editingParam?.id}`:`pill:${t.actionableSuggestions[0]?.parameter??""}`}function ko(t){if(!t)return rn();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function Ua(t){let e=at(t);return e?ao(e):rn()}function Mo(t,e){let n=Qi(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(I=>I.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(I=>I.parameter==="placeholder").map(I=>I.text).join(" "),a=oe(t.text,Math.min(t.filterBase,t.text.length),r),l=a===0&&Ze(t.text,t.completedParams.length,r)?"":Me(t.text,a,t.filterInProgress),d=o?.options??[],c=t.editingParam!=null&&t.editingAnchor!=null,u=!c&&!t.editingIdentified&&o?.type?.kind==="multi_select",m,h,g,f;if(c&&t.editingParam&&t.editingAnchor!=null){let I=t.editingParam.id,N=t.completedParams.some(ea=>ea.id===I),he=t.caretOffset??t.editingAnchor,qe=N?"":t.text.slice(t.editingAnchor,he);h=qe.trim(),g=t.editingParam.options,f=t.editingParam.suggestionParameter,m=ce(t.editingParam.options,qe)}else h=l.trim(),g=d,f=o?.parameter,m=w(o)?d.map(I=>({...I,matchedText:t.text.slice(de(t.text,t.completedParams)),parameterLabel:$i(I.parameter)})):ce(d,l,t.traditionalAutocomplete);let S=t.optionSearch,y=S!=null&&f!=null&&S.parameter===f;y&&S.status==="done"&&S.query===h&&(m=g);let p=y&&S.status==="loading",b=e.showNonTappableOptions===!1;b&&(m=m.filter(I=>I.is_tappable));let T=c?h:t.text.slice(de(t.text,t.completedParams));u||(m=Vi(m,T));let x=t.editingIdentified,L=c?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,P=x?x.format:Q(L),E=c?t.editingParam?.suggestionParameter:o?.parameter,C=P==="location"&&E&&e.optionOverrides?.[E]?"options":P,A=c&&C==="date-range"?Ue(t.editingParam):null,B=null,te=null;if(k(C)){let I=W({...t,actionableSuggestions:i}),N=t.dateViewMonth;B=N&&N.key===I?{year:N.year,month:N.month}:x?ko(x.iso):A?ko(A.start):Ua(t.editingParam?.text),m=sn(B);let he=t.pendingRangeStart;C==="date-range"&&he&&he.key===I&&(te=he.iso)}let _=null;if(C==="time"){let I=W({...t,actionableSuggestions:i}),N=t.timeDraft;_=N&&N.key===I?{minutes:N.minutes,touched:!0}:{minutes:So({editingText:c?t.editingParam?.text:null,options:c?t.editingParam?.options:o?.options}),touched:!1},m=[]}let v=null;if(C==="location"){let I=W({...t,actionableSuggestions:i}),N=t.locationSearch;if(N&&N.key===I){let{key:he,...qe}=N;v=qe}else v={query:c?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};m=[]}let Y=I=>b?I.is_tappable:!0,R;if(c){let I=t.editingParam?.options??[];R=t.editingParam!=null&&I.filter(Y).length===0}else R=o!=null&&d.filter(Y).length===0;_&&(R=!0),v&&(R=!0);let ne=Ao({inEditMode:c||x!=null,filteredOptionsLength:m.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||p,pillTapped:t.pillTapped,activePillHasNoOptions:R,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),$e=ne&&t.activeDropdownIndex>=0&&!!m[t.activeDropdownIndex]?.is_tappable,jt=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,V=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||p||jt,Ci=V&&t.skeletonOptions!==null,Jr=Ci&&t.skeletonOptions?t.skeletonOptions:m,Zr=Ci?t.skeletonSuggestion:null;return{segments:n,actionableSuggestions:i,filteredOptions:m,dropdownLoading:V,dropdownOptions:Jr,dropdownSuggestion:Zr,skeletonExiting:jt,activeFormatType:C,dateView:B,dateRangeStart:te,timeView:_,multiSelectView:u?{picked:t.multiSelectDraft?.key===W({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,locationView:v,placeholderText:r,optionQuery:h,isSearchingOptions:p,isDropdownOpen:ne,isActivePillSelected:$e}}function Lt(t){return t.mode!=="edit"?Va(t):Ga(t)}function Ba(t,e,n){let i=t.find(w);if(!i?.options)return null;let o=e.slice(de(e,n)).trim().toLowerCase();if(!o)return null;let r=i.options.filter(l=>l.is_tappable&&l.text.trim().toLowerCase()===o);if(new Set(r.map(l=>z(l,i.parameter))).size!==1)return null;let s=r[0];return{suggestion:i,option:s,matchText:s.text.trim()}}function Ro(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,a=n.find(c=>c.parameter!=="placeholder"&&!w(c));if(!a?.options||a.type?.kind==="multi_select")return null;let s=n.filter(c=>c.parameter==="placeholder").map(c=>c.text).join(" "),l=oe(e,i,s),d=Re(a.options,e,l,o,r===!0);return d?{suggestion:a,option:d,matchText:d.text}:null}function Va(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?Ro(t):null)??Ba(i,e,n):Ro(t);if(!o)return null;let{suggestion:r,option:a,matchText:s}=o,l=s.toLowerCase(),d=e.toLowerCase().lastIndexOf(l),c=d>=0?d:Math.max(0,e.length-a.text.length),u=c+s.length,m=e.slice(c,u),g=u<e.length&&e[u]===" "?u+1:u,f={id:crypto.randomUUID(),placeholder:"",parameter:z(a,r.parameter),text:m,value:a.value,kind:a.kind,suggestionParameter:r.parameter,suggestionValueType:r.type,suggestionPlaceholder:r.text,...t.mode==="submit"&&w(r)?_e(z(a,r.parameter)):{},options:r.options??[],metadata:a.metadata,icon:a.icon,icon_svg:a.icon_svg,image_url:a.image_url};return{patch:{text:e,completedParams:[...n,f],suggestions:i.filter(S=>S!==r),filterBase:g,newParamId:f.id,caretOffset:g,activeDropdownIndex:-1},caretPos:g,option:a,suggestion:r}}function Ga(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(b=>b.id===i.id))return null;let a=e.slice(o,r),s=Je(i.options,a);if(!s)return null;let l=s.text.toLowerCase(),d=a.toLowerCase().lastIndexOf(l),c=o+Math.max(0,d),u=c+s.text.length,m=e.slice(c,u),h=u<e.length&&e[u]===" "?u+1:u,g=e.length,f={id:crypto.randomUUID(),placeholder:"",...et(i,s),text:m,value:s.value,kind:s.kind,options:i.options,metadata:s.metadata,icon:s.icon,icon_svg:s.icon_svg,image_url:s.image_url},S=n.length,y=0;for(let b=0;b<n.length;b++){let T=X(e,n[b].text,y);if(T!==-1){if(T>=h){S=b;break}y=T+n[b].text.length}}let p=[...n];return p.splice(S,0,f),{patch:{text:e,completedParams:p,newParamId:f.id,filterBase:g,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:g,activeDropdownIndex:-1},caretPos:g,option:s}}function _o(t){return t.slice(t.search(/\S*$/))}function Do(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function No(t,e){let n="",i=0;for(let o of t){if(n+=Do(o),i+=o.length,n.length>=e.length)return n.startsWith(e)?i+(t.slice(i).match(/^\p{M}*/u)?.[0].length??0):0;if(!e.startsWith(n))return 0}return 0}function Gn(t){return[...t].map(Do).join("")}function It(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(Gn),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:Gn(o[0])}));for(let o=n.length;o>=1;o--){let r=n.slice(n.length-o),a=r[o-1];for(let s=0;s+o<=i.length;s++){if(!r.slice(0,-1).every((u,m)=>i[s+m].folded===u))continue;let d=i[s+o-1],c=No(d.text,a);if(c>0)return{typedWords:o,start:i[s].index,end:d.index+c}}}return null}function $n(t,e){let n=e?It(t,e):null;if(n&&n.typedWords>1)return[{text:t.slice(0,n.start),bold:!1},{text:t.slice(n.start,n.end),bold:!0},{text:t.slice(n.end),bold:!1}].filter(a=>a.text!=="");let i=e?_o(e):"",o=Gn(i);if(!o)return[{text:t,bold:!1}];let r=[];for(let a of t.split(/(\s+)/)){if(a==="")continue;let s=/^\s/.test(a)?0:No(a,o);s>0&&r.push({text:a.slice(0,s),bold:!0});let l=s>0?a.slice(s):a;l&&r.push({text:l,bold:!1})}return r}var $a=6e4;function qa(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function Ka(t){return(t??K).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function za(t){return Ie(t)?`Bearer ${await je(t).getToken()}`:Qe(t)}async function Fo(t){try{let e=Ka(t.apiConfig?.endpoint),n=Ye(t.apiConfig),i=await za(t.apiConfig);i&&(n.Authorization=i);let o=JSON.stringify({source:t.source,session_id:t.sessionId,...t.visitorId&&{visitor_id:t.visitorId},...t.requestId&&{request_id:t.requestId},type:t.type,...t.language&&{language:t.language},at:new Date().toISOString(),query_data:t.queryData});await fetch(e,{method:"POST",headers:n,body:o,...t.keepalive&&qa(o)<=$a&&{keepalive:!0}})}catch{}}function se(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var qn=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function ja(t,e,n){let i=qn(t??"");if(i.length===0)return"";let r=qn(e).slice(-i.length),a=qn(n).slice(0,i.length);return r.join(" ")===i.join(" ")||a.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function Ho(t,e){let n=t.actionableSuggestions[0];if(!n)return null;let i=w(n),o=e.parameter;if(i&&!o)return null;let r=i&&o?o:z(e,n.parameter),a=i?t.text.length:t.filterBase,s=t.text.slice(0,a),l=s.length===0&&t.text.length===0,d=s.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||d)&&t.placeholderText&&(s=`${t.placeholderText} `);let c=Math.min(de(t.text,t.completedParams),s.length);if(i){let P=[...s.slice(c).matchAll(/\S+/g)],E=It(e.text,s.slice(c)),C=P[P.length-(E?.typedWords??1)];s=s.slice(0,C?c+(C.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word===!0){let P=[...s.slice(c).matchAll(/\S+/g)],E=P[P.length-1];s=s.slice(0,E?c+(E.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word!==!1){let P=Ui(s.slice(c),e.text);P>0&&(s=s.slice(0,s.length-P))}let u=s.length>0&&s[s.length-1]!==" ",m=t.activeFormatType??Q(n),g=D(m)||n.type?.kind==="multi_select"?ja(n.lead_in,s,e.text):"",f=`${s}${u?" ":""}${g?`${g} `:""}${e.text} `,y=(l||d||i&&s.length===0)&&f.length>0?f[0].toUpperCase()+f.slice(1):f,p=y.toLowerCase().lastIndexOf(e.text.toLowerCase()),b=p>=0?y.slice(p,p+e.text.length):e.text,T=i?_e(r):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text},x={id:crypto.randomUUID(),placeholder:"",...T,text:b,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},L=t.actionableSuggestions.length-1;return{patch:{text:y,filterBase:y.length,completedParams:[...t.completedParams,x],newParamId:x.id,caretOffset:y.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(P=>P.text!==e.text).map(P=>P.text),key:i?r:n.parameter,position:se(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:L}}function Ot(t){let e=D(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,n=t.editingParam,i=n?{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options}:t.actionableSuggestions[0]??null;return{skeletonOptions:e,skeletonSuggestion:e?i:null,skeletonRequested:!1}}function At(t,e,n){let i=t.slice(0,e),o=t.slice(n),r=(i===""||i.endsWith(" "))&&o.startsWith(" ");return r&&(o=o.slice(1)),{text:i+o,removed:n-e+(r?1:0)}}var kt=class{constructor(e){this.deps=e}start(e){let n=this.deps.store.get();if(n.editingParam?.id===e)return;let i=n.completedParams.find(a=>a.id===e);if(!i)return;let o=0,r=-1;for(let a of n.completedParams){let s=X(n.text,a.text,o);if(s!==-1){if(a.id===e){r=s;break}o=s+a.text.length}}r<0||this.deps.store.set({editingParam:i,editingAnchor:r,editingTail:r+i.text.length,caretOffset:r+i.text.length,activeDropdownIndex:-1,editingIdentified:null})}exit(){this.deps.store.get().editingParam&&this.deps.store.set({editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1})}replaceRange(e){let n=this.deps.store.get(),i=n.editingParam,o=n.editingAnchor,r=n.editingTail;if(!i||o==null||r==null||!n.completedParams.some(l=>l.id===i.id))return!1;let{text:a}=e===""?At(n.text,o,r):{text:n.text.slice(0,o)+e+n.text.slice(r)},s=o+e.length;return this.deps.store.set(l=>({text:a,completedParams:l.completedParams.filter(d=>d.id!==i.id),editingTail:s,caretOffset:s,activeDropdownIndex:-1})),this.deps.scheduleSetCursor(s),this.promoteIfExact(),!0}caretAfterInput(e){let n=this.deps.store.get(),i={caretOffset:e};n.editingParam&&n.editingAnchor!=null&&e!=null&&(e<n.editingAnchor?(i.editingParam=null,i.editingAnchor=null,i.editingTail=null,i.activeDropdownIndex=-1):n.editingTail!=null&&(i.editingTail=Math.max(n.editingTail,e))),this.deps.store.set(i),this.promoteIfExact()}caretMove(e){let n=this.deps.store.get();if(n.editingParam&&n.editingAnchor!=null&&n.editingTail!=null&&e!=null&&(e<n.editingAnchor||e>n.editingTail)){this.deps.store.set({caretOffset:e,editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1});return}this.deps.store.set({caretOffset:e})}selectOption(e){let n=this.deps.store.get(),i=n.editingParam,o=n.editingAnchor,r=n.editingTail;if(!i||o==null||r==null)return;let a=et(i,e);this.deps.fireTelemetry("option",{raw_query:F(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(p=>p.text!==e.text).map(p=>p.text),key:a.suggestionParameter,position:se(i.options,e.text),chip_origin:"tap"});let s=n.text.slice(0,o),l=n.text.slice(r),d=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,u=l.length===0||l[0]!==" "?`${d} `:d,m=s+u+l,h=m.length,g={id:crypto.randomUUID(),placeholder:"",...a,text:d,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},f=n.completedParams.findIndex(p=>p.id===i.id),S=n.completedParams.filter(p=>p.id!==i.id),y=f>=0?Math.min(f,S.length):S.length;S.splice(y,0,g),this.deps.store.set({text:m,completedParams:S,newParamId:g.id,filterBase:h,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:h,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...Ot(n)}),this.deps.startSelectionAnimationTimer(),this.deps.scheduleSetCursor(h),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=Lt({mode:"edit",text:e.text,completedParams:e.completedParams,editingParam:e.editingParam,editingAnchor:e.editingAnchor,editingTail:e.editingTail});n&&(this.deps.store.set(n.patch),this.deps.scheduleSetCursor(n.caretPos))}};var Ya=33,Qa=70,Xa=120,Ja=50,Ee="data-aia-placeholder-leaving",we=new WeakMap;function Mt(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function Za(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Uo(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function Bo(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Uo(t,e,e.shown+1),e.shown>=e.target.length))return;let n=e.target[e.shown-1],i=n===" "||n==="-"?70:0;e.timer=setTimeout(()=>Bo(t,e),33+i)}function Wo(t,e){Uo(t,e,0),e.timer=setTimeout(()=>Bo(t,e),33)}function Vo(t,e){let n=we.get(t);if(e===""){n&&(Mt(n),we.delete(t)),t.removeAttribute(Ee),delete t.dataset.placeholder;return}if(n?.target===e)return;if(Za(t)){n&&Mt(n),t.removeAttribute(Ee),we.set(t,{target:e,shown:e.length,timer:null}),t.dataset.placeholder=e;return}let i={target:e,shown:0,timer:null},o=n&&n.shown>0?n:null;if(n&&Mt(n),we.set(t,i),o){t.setAttribute(Ee,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(Ee),t.isConnected&&Wo(t,i)},170);return}t.removeAttribute(Ee),Wo(t,i)}function Go(t){let e=we.get(t);e&&(Mt(e),we.delete(t))}var $o="https://ai-autocomplete.com";function Kn(t=$o){try{if(typeof window>"u"||!window.location)return t;let e=window.location.hostname;if(!e)return t;let n=new URL(t);return n.searchParams.set("utm_source",e),n.toString()}catch{return t}}var qo={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Best match",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",timeLabel:"Time",locationSearch:"Search a city or address",locationNoResults:"No places found",locationUseTyped:"Press Enter to use what you typed"},es={language:"es",and:"y",proceed:"para continuar",select:"para seleccionar",skipHint:"para omitir",skip:"omitir",skipLabel:"Omitir",products:"Mejor coincidencia",soldOut:"Agotado",addToCart:"A\xF1adir al carrito",submit:"Buscar",scrollArrow:"Despl\xE1zate para ver m\xE1s opciones",keepTyping:"Sigue escribiendo",done:"Listo",timeLabel:"Hora",locationSearch:"Busca una ciudad o direcci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},zn={en:qo,es,fr:{language:"fr",and:"et",proceed:"pour continuer",select:"pour s\xE9lectionner",skipHint:"pour passer",skip:"passer",skipLabel:"Passer",products:"Meilleure correspondance",soldOut:"\xC9puis\xE9",addToCart:"Ajouter au panier",submit:"Rechercher",scrollArrow:"Faites d\xE9filer pour voir plus d\u2019options",keepTyping:"Continuez \xE0 taper",done:"Termin\xE9",timeLabel:"Heure",locationSearch:"Rechercher une ville ou une adresse",locationNoResults:"Aucun lieu trouv\xE9",locationUseTyped:"Appuyez sur Entr\xE9e pour utiliser votre saisie"},"pt-BR":{language:"pt-BR",and:"e",proceed:"para continuar",select:"para selecionar",skipHint:"para pular",skip:"pular",skipLabel:"Pular",products:"Melhor correspond\xEAncia",soldOut:"Esgotado",addToCart:"Adicionar ao carrinho",submit:"Buscar",scrollArrow:"Role para ver mais op\xE7\xF5es",keepTyping:"Continue digitando",done:"Conclu\xEDdo",timeLabel:"Hor\xE1rio",locationSearch:"Pesquise uma cidade ou endere\xE7o",locationNoResults:"Nenhum lugar encontrado",locationUseTyped:"Pressione Enter para usar o que voc\xEA digitou"},it:{language:"it",and:"e",proceed:"per continuare",select:"per selezionare",skipHint:"per saltare",skip:"salta",skipLabel:"Salta",products:"Migliore corrispondenza",soldOut:"Esaurito",addToCart:"Aggiungi al carrello",submit:"Cerca",scrollArrow:"Scorri per vedere altre opzioni",keepTyping:"Continua a scrivere",done:"Fatto",timeLabel:"Ora",locationSearch:"Cerca una citt\xE0 o un indirizzo",locationNoResults:"Nessun luogo trovato",locationUseTyped:"Premi Invio per usare ci\xF2 che hai scritto"},tr:{language:"tr",and:"ve",proceed:"devam etmek i\xE7in",select:"se\xE7mek i\xE7in",skipHint:"atlamak i\xE7in",skip:"atla",skipLabel:"Atla",products:"En iyi e\u015Fle\u015Fme",soldOut:"T\xFCkendi",addToCart:"Sepete ekle",submit:"Ara",scrollArrow:"Daha fazla se\xE7enek i\xE7in kayd\u0131r",keepTyping:"Yazmaya devam et",done:"Tamam",timeLabel:"Saat",locationSearch:"\u015Eehir veya adres aray\u0131n",locationNoResults:"Yer bulunamad\u0131",locationUseTyped:"Yazd\u0131\u011F\u0131n\u0131z\u0131 kullanmak i\xE7in Enter'a bas\u0131n"},id:{language:"id",and:"dan",proceed:"untuk melanjutkan",select:"untuk memilih",skipHint:"untuk melewati",skip:"lewati",skipLabel:"Lewati",products:"Paling cocok",soldOut:"Habis",addToCart:"Tambah ke keranjang",submit:"Cari",scrollArrow:"Gulir untuk melihat opsi lainnya",keepTyping:"Teruskan mengetik",done:"Selesai",timeLabel:"Waktu",locationSearch:"Cari kota atau alamat",locationNoResults:"Tempat tidak ditemukan",locationUseTyped:"Tekan Enter untuk memakai yang Anda ketik"},pl:{language:"pl",and:"i",proceed:"aby kontynuowa\u0107",select:"aby wybra\u0107",skipHint:"aby pomin\u0105\u0107",skip:"pomi\u0144",skipLabel:"Pomi\u0144",products:"Najlepsze dopasowanie",soldOut:"Wyprzedane",addToCart:"Dodaj do koszyka",submit:"Szukaj",scrollArrow:"Przewi\u0144, aby zobaczy\u0107 wi\u0119cej opcji",keepTyping:"Pisz dalej",done:"Gotowe",timeLabel:"Godzina",locationSearch:"Szukaj miasta lub adresu",locationNoResults:"Nie znaleziono miejsc",locationUseTyped:"Naci\u015Bnij Enter, aby u\u017Cy\u0107 wpisanego tekstu"},de:{language:"de",and:"und",proceed:"zum Fortfahren",select:"zum Ausw\xE4hlen",skipHint:"zum \xDCberspringen",skip:"\xFCberspringen",skipLabel:"\xDCberspringen",products:"Beste Treffer",soldOut:"Ausverkauft",addToCart:"In den Warenkorb",submit:"Suchen",scrollArrow:"Scrolle f\xFCr weitere Optionen",keepTyping:"Weitertippen",done:"Fertig",timeLabel:"Uhrzeit",locationSearch:"Stadt oder Adresse suchen",locationNoResults:"Keine Orte gefunden",locationUseTyped:"Dr\xFCcke Enter, um deine Eingabe zu verwenden"},nl:{language:"nl",and:"en",proceed:"om door te gaan",select:"om te selecteren",skipHint:"om over te slaan",skip:"overslaan",skipLabel:"Overslaan",products:"Beste match",soldOut:"Uitverkocht",addToCart:"In winkelwagen",submit:"Zoeken",scrollArrow:"Scrol voor meer opties",keepTyping:"Blijf typen",done:"Klaar",timeLabel:"Tijd",locationSearch:"Zoek een stad of adres",locationNoResults:"Geen plaatsen gevonden",locationUseTyped:"Druk op Enter om je invoer te gebruiken"},sv:{language:"sv",and:"och",proceed:"f\xF6r att forts\xE4tta",select:"f\xF6r att v\xE4lja",skipHint:"f\xF6r att hoppa \xF6ver",skip:"hoppa \xF6ver",skipLabel:"Hoppa \xF6ver",products:"B\xE4sta matchning",soldOut:"Sluts\xE5ld",addToCart:"L\xE4gg i varukorgen",submit:"S\xF6k",scrollArrow:"Skrolla f\xF6r fler alternativ",keepTyping:"Forts\xE4tt skriva",done:"Klar",timeLabel:"Tid",locationSearch:"S\xF6k efter en stad eller adress",locationNoResults:"Inga platser hittades",locationUseTyped:"Tryck p\xE5 Enter f\xF6r att anv\xE4nda det du skrev"},nb:{language:"nb",and:"og",proceed:"for \xE5 fortsette",select:"for \xE5 velge",skipHint:"for \xE5 hoppe over",skip:"hopp over",skipLabel:"Hopp over",products:"Beste treff",soldOut:"Utsolgt",addToCart:"Legg i handlekurven",submit:"S\xF8k",scrollArrow:"Rull ned for \xE5 se flere alternativer",keepTyping:"Fortsett \xE5 skrive",done:"Ferdig",timeLabel:"Tid",locationSearch:"S\xF8k etter en by eller adresse",locationNoResults:"Fant ingen steder",locationUseTyped:"Trykk Enter for \xE5 bruke det du skrev"},da:{language:"da",and:"og",proceed:"for at forts\xE6tte",select:"for at v\xE6lge",skipHint:"for at springe over",skip:"spring over",skipLabel:"Spring over",products:"Bedste match",soldOut:"Udsolgt",addToCart:"L\xE6g i kurv",submit:"S\xF8g",scrollArrow:"Rul for flere muligheder",keepTyping:"Forts\xE6t med at skrive",done:"F\xE6rdig",timeLabel:"Tidspunkt",locationSearch:"S\xF8g efter en by eller adresse",locationNoResults:"Ingen steder fundet",locationUseTyped:"Tryk p\xE5 Enter for at bruge det, du skrev"},fi:{language:"fi",and:"ja",proceed:"jatkaaksesi",select:"valitaksesi",skipHint:"ohittaaksesi",skip:"ohita",skipLabel:"Ohita",products:"Paras vastaavuus",soldOut:"Loppuunmyyty",addToCart:"Lis\xE4\xE4 ostoskoriin",submit:"Hae",scrollArrow:"Vierit\xE4 n\xE4hd\xE4ksesi lis\xE4\xE4 vaihtoehtoja",keepTyping:"Jatka kirjoittamista",done:"Valmis",timeLabel:"Aika",locationSearch:"Hae kaupunkia tai osoitetta",locationNoResults:"Paikkoja ei l\xF6ytynyt",locationUseTyped:"Paina Enteri\xE4 k\xE4ytt\xE4\xE4ksesi kirjoittamaasi"},ja:{language:"ja",and:"\u3068",proceed:"\u3067\u6B21\u3078",select:"\u3067\u9078\u629E",skipHint:"\u3067\u30B9\u30AD\u30C3\u30D7",skip:"\u30B9\u30AD\u30C3\u30D7",skipLabel:"\u30B9\u30AD\u30C3\u30D7",products:"\u30D9\u30B9\u30C8\u30DE\u30C3\u30C1",soldOut:"\u58F2\u308A\u5207\u308C",addToCart:"\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",submit:"\u691C\u7D22",scrollArrow:"\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u3066\u4ED6\u306E\u5019\u88DC\u3092\u898B\u308B",keepTyping:"\u5165\u529B\u3092\u7D9A\u3051\u308B",done:"\u5B8C\u4E86",timeLabel:"\u6642\u523B",locationSearch:"\u90FD\u5E02\u540D\u3084\u4F4F\u6240\u3067\u691C\u7D22",locationNoResults:"\u5834\u6240\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",locationUseTyped:"\u5165\u529B\u3057\u305F\u5185\u5BB9\u3092\u4F7F\u3046\u306B\u306F Enter \u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044"},ko:{language:"ko",and:"\uBC0F",proceed:"\uACC4\uC18D",select:"\uC120\uD0DD",skipHint:"\uAC74\uB108\uB6F0\uAE30",skip:"\uAC74\uB108\uB6F0\uAE30",skipLabel:"\uAC74\uB108\uB6F0\uAE30",products:"\uCD5C\uC801 \uC77C\uCE58",soldOut:"\uD488\uC808",addToCart:"\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uB2F4\uAE30",submit:"\uAC80\uC0C9",scrollArrow:"\uB354 \uB9CE\uC740 \uC635\uC158\uC744 \uBCF4\uB824\uBA74 \uC2A4\uD06C\uB864\uD558\uC138\uC694",keepTyping:"\uACC4\uC18D \uC785\uB825\uD558\uC138\uC694",done:"\uC644\uB8CC",timeLabel:"\uC2DC\uAC04",locationSearch:"\uB3C4\uC2DC \uB610\uB294 \uC8FC\uC18C \uAC80\uC0C9",locationNoResults:"\uC7A5\uC18C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",locationUseTyped:"\uC785\uB825\uD55C \uB0B4\uC6A9\uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 Enter\uB97C \uB204\uB974\uC138\uC694"},"zh-CN":{language:"zh-CN",and:"\u548C",proceed:"\u7EE7\u7EED",select:"\u9009\u62E9",skipHint:"\u8DF3\u8FC7",skip:"\u8DF3\u8FC7",skipLabel:"\u8DF3\u8FC7",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u7F44",addToCart:"\u52A0\u5165\u8D2D\u7269\u8F66",submit:"\u641C\u7D22",scrollArrow:"\u5411\u4E0B\u6EDA\u52A8\u67E5\u770B\u66F4\u591A\u9009\u9879",keepTyping:"\u7EE7\u7EED\u8F93\u5165",done:"\u5B8C\u6210",timeLabel:"\u65F6\u95F4",locationSearch:"\u641C\u7D22\u57CE\u5E02\u6216\u5730\u5740",locationNoResults:"\u672A\u627E\u5230\u5730\u70B9",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F93\u5165\u7684\u5185\u5BB9"},"zh-TW":{language:"zh-TW",and:"\u548C",proceed:"\u7E7C\u7E8C",select:"\u9078\u64C7",skipHint:"\u7565\u904E",skip:"\u7565\u904E",skipLabel:"\u7565\u904E",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u5B8C",addToCart:"\u52A0\u5165\u8CFC\u7269\u8ECA",submit:"\u641C\u5C0B",scrollArrow:"\u5411\u4E0B\u6372\u52D5\u67E5\u770B\u66F4\u591A\u9078\u9805",keepTyping:"\u7E7C\u7E8C\u8F38\u5165",done:"\u5B8C\u6210",timeLabel:"\u6642\u9593",locationSearch:"\u641C\u5C0B\u57CE\u5E02\u6216\u5730\u5740",locationNoResults:"\u627E\u4E0D\u5230\u5730\u9EDE",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F38\u5165\u7684\u5167\u5BB9"}},ts={pt:"pt-BR",no:"nb",nn:"nb"};function O(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return zn[o?"zh-TW":"zh-CN"]}let i=ts[e]??e;return Object.prototype.hasOwnProperty.call(zn,i)?zn[i]:qo}function jn(t,e,n=O()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function Yn(t){let e=a=>{a.ctrlKey||Ko(a.target,t,a.deltaX,a.deltaY)||a.preventDefault()},n=0,i=0,o=a=>{let s=a.touches[0];s&&(n=s.clientX,i=s.clientY)},r=a=>{if(a.touches.length!==1)return;let s=a.touches[0],l=n-s.clientX,d=i-s.clientY;n=s.clientX,i=s.clientY,a.cancelable&&!Ko(a.target,t,l,d)&&a.preventDefault()};return t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("touchstart",o,{passive:!0}),t.addEventListener("touchmove",r,{passive:!1}),()=>{t.removeEventListener("wheel",e),t.removeEventListener("touchstart",o),t.removeEventListener("touchmove",r)}}function Ko(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&ns(o,i)||n!==0&&is(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var zo=/^(auto|scroll|overlay)$/;function ns(t,e){return t.scrollHeight<=t.clientHeight||!zo.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function is(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!zo.test(n.overflowX))return!1;let i=Math.abs(t.scrollLeft),o=t.scrollWidth-t.clientWidth;return(n.direction==="rtl"?e<0:e>0)?i<o-1:i>0}var jo=new WeakMap,Yo=new WeakSet;function U(t,e,n){if(jo.set(t,n),Yo.has(t))return;Yo.add(t);let i=()=>jo.get(t),o=r=>{if(!(r instanceof Element))return null;let a=r.closest(e.itemSelector);return a&&t.contains(a)?a:null};e.onClick&&t.addEventListener("click",r=>{let a=o(r.target);a&&e.onClick?.(a,i(),r)}),e.onEnter&&t.addEventListener("mouseenter",r=>{let a=r.target;a instanceof HTMLElement&&a.matches(e.itemSelector)&&e.onEnter?.(a,i())},!0),e.onLeave&&t.addEventListener("mouseleave",r=>{let a=r.target;a instanceof HTMLElement&&a.matches(e.itemSelector)&&e.onLeave?.(a,i())},!0),e.preventMousedown&&t.addEventListener("mousedown",r=>r.preventDefault())}function le(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function q(t){t.offsetWidth}var os={selectedIso:null,selectedRange:null,rangeStart:null};function Be(t){if(!k(t.activeFormatType))return os;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?We(i,o):null,rangeStart:t.dateRangeStart}}let n=Ue(t.editingParam);return{selectedIso:n?null:ln(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart}}function Qn(t){return t.pendingStart?We(t.pendingStart,t.highlightedIso??t.pendingStart):t.selected}function Xn(t,e){if(t==null)return{selected:!1,inRange:!1};let{selectedIso:n,range:i}=e,o=t===n||i!=null&&(t===i.start||t===i.end),r=i!=null&&t>i.start&&t<i.end;return{selected:o,inRange:r}}var Qo="data-aia-key";function j(t,e,n){let i=new Map;for(let a of Array.from(t.children)){let s=a.getAttribute(Qo);s!=null&&i.set(s,a)}let o=new Set,r=[];for(let a=0;a<e.length;a++){let s=e[a],l=n.keyOf(s,a);o.add(l);let d=i.get(l);d||(d=n.create(s,a),d.setAttribute(Qo,l)),n.update?.(d,s,a),t.children[a]!==d&&t.insertBefore(d,t.children[a]??null),r.push(d)}for(let[a,s]of i)o.has(a)||s.remove();return r}function Xo(t,e){if(!e.interactive)return null;let n=e.options[le(t)];return n?.is_tappable?n:null}var rs={itemSelector:"[data-aia-date-cell], [data-aia-date-prev], [data-aia-date-next]",onClick:(t,e)=>{if(t.hasAttribute("data-aia-date-prev")){e.callbacks.onPreviousMonth();return}if(t.hasAttribute("data-aia-date-next")){e.callbacks.onNextMonth();return}let n=Xo(t,e);n&&(t.classList.add("magicx-aia-date-cell--pressed"),e.callbacks.onSelect(n),setTimeout(()=>t.classList.remove("magicx-aia-date-cell--pressed"),170))},onEnter:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&Xo(t,e)&&e.callbacks.onHighlight(le(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,le(t))}};function Zo(t,e,n,i,o,r,a,s=!0){let l=t.querySelector(".magicx-aia-datepicker");if(!o||e.length===0){l?.remove();return}if(!l){l=ls(),t.appendChild(l),q(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}U(l,rs,{options:e,callbacks:a,interactive:s});let d=l.querySelector(".magicx-aia-datepicker-month");d&&(d.textContent=on(o));let c=l.querySelector(".magicx-aia-datepicker-grid");c&&as(c,e,n,i,r)}function as(t,e,n,i,o){let r=G(new Date),a=Qn({pendingStart:o.rangeStart,highlightedIso:Z(e[n]),selected:o.selectedRange});j(t,e,{keyOf:(s,l)=>Z(s)??`pad-${l}`,create:s=>ss(s),update:(s,l,d)=>{let c=Z(l),u=Xn(c,{selectedIso:o.selectedIso,range:a}),m=d===n&&l.is_tappable;s.id=`${i}-option-${d}`,s.dataset.aiaIndex=String(d),s.setAttribute("aria-selected",String(m)),s.classList.toggle("magicx-aia-date-cell--past",c!=null&&c<r),s.classList.toggle("magicx-aia-date-cell--highlighted",m),s.classList.toggle("magicx-aia-date-cell--today",c!=null&&c===r),s.classList.toggle("magicx-aia-date-cell--selected",u.selected),s.classList.toggle("magicx-aia-date-cell--in-range",u.inRange)}})}function ss(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=cn(t);if(n==null)return e.className="magicx-aia-date-cell magicx-aia-date-cell--blank",e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e;e.className="magicx-aia-date-cell magicx-aia-date-cell--day",e.tabIndex=0,e.setAttribute("aria-label",t.text);let i=document.createElement("span");return i.className="magicx-aia-date-cell-number",i.textContent=String(n),e.appendChild(i),e}function ls(){let t=document.createElement("div");t.className="magicx-aia-datepicker",t.setAttribute("data-aia-datepicker","");let e=document.createElement("div");e.className="magicx-aia-datepicker-header";let n=document.createElement("span");n.className="magicx-aia-datepicker-month",n.setAttribute("data-aia-date-month",""),n.setAttribute("aria-live","polite"),e.append(Jo("prev","Previous month","\u2039"),n,Jo("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of rt){let a=document.createElement("span");a.className="magicx-aia-datepicker-weekday",a.textContent=r,i.appendChild(a)}let o=document.createElement("div");return o.className="magicx-aia-datepicker-grid",o.setAttribute("data-aia-date-grid",""),t.append(e,i,o),t}function Jo(t,e,n){let i=document.createElement("button");return i.type="button",i.tabIndex=-1,i.className="magicx-aia-datepicker-nav",i.setAttribute(`data-aia-date-${t}`,""),i.setAttribute("aria-label",e),i.textContent=n,i.disabled=!0,i}var cs='<svg class="magicx-aia-location-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"/><circle cx="12" cy="9.5" r="2.5"/></svg>',er="data-aia-location-body";function ds(t){let e=document.createElement("div");e.className="magicx-aia-location-row",e.setAttribute("data-aia-location-row",""),e.setAttribute("role","option");let n=document.createElement("span");n.className="magicx-aia-location-pin",n.innerHTML=cs;let i=document.createElement("span");i.className="magicx-aia-location-text";let o=document.createElement("span");if(o.className="magicx-aia-location-name",o.textContent=t.name,i.appendChild(o),t.secondary){let r=document.createElement("span");r.className="magicx-aia-location-secondary",r.textContent=t.secondary,i.appendChild(r)}return e.append(n,i),e}function us(t,e){if(t==="loading"){let o=document.createElement("div");o.className="magicx-aia-location-loading",o.setAttribute("data-aia-location-loading","");for(let r=0;r<3;r++)o.appendChild(document.createElement("span")).className="magicx-aia-location-loading-bar";return o}if(t==="")return null;let n=document.createElement("div");if(n.className="magicx-aia-location-note",n.setAttribute("data-aia-location-note",""),t==="note-empty"){let o=document.createElement("span");o.className="magicx-aia-location-empty",o.textContent=e.locationNoResults,n.appendChild(o)}let i=document.createElement("span");return i.textContent=e.locationUseTyped,n.appendChild(i),n}function tr(t,e,n,i){let o=e.places,r="";if(o.length===0&&(e.status==="loading"?r="loading":e.query.trim()&&(r=e.status==="done"?"note-empty":"note")),t.getAttribute(er)!==r){for(let s of Array.from(t.children))s.hasAttribute("data-aia-location-row")||s.remove();let a=us(r,n);a&&t.appendChild(a),t.setAttribute(er,r)}j(t,o,{keyOf:(a,s)=>`${s}:${a.id}`,create:a=>ds(a),update:(a,s,l)=>{let d=l===e.highlighted;a.classList.toggle("magicx-aia-location-row--highlighted",d),a.setAttribute("aria-selected",String(d)),a.setAttribute("data-aia-index",String(l)),a.id=i(l)}})}var ee=new WeakMap,ps=0,pe=new WeakMap,ms='<svg class="magicx-aia-location-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>',me=t=>st(t.input)===t.input;function nr(t,e){let n=st(t);if(n instanceof HTMLElement&&n!==e.input&&n!==M(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=ye(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function gs(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=Ne(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=M(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var fs={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&Pe(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function Pe(t,e=!1){let n=pe.get(t),i=ee.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&me(n)&&(n.returning=!0,gs(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function hs(t){let e=pe.get(t),n=ee.get(t);if(!(!e||!n||me(e))){if(nr(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!me(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function bs(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++ps}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=ms;let i=document.createElement("input");i.type="text",i.className="magicx-aia-location-input",i.setAttribute("data-aia-location-input",""),i.setAttribute("autocomplete","off"),i.setAttribute("autocapitalize","words"),i.setAttribute("enterkeyhint","done"),i.spellcheck=!1,i.placeholder=e.locationSearch,i.setAttribute("aria-label",e.locationSearch),n.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-location-results",o.setAttribute("data-aia-location-results",""),o.setAttribute("aria-live","polite"),t.append(n,o);let r={input:i,field:n,results:o,returnTo:null,returnRange:null,returning:!1,declined:!1,widgetFocused:!1};return t.addEventListener("mousedown",a=>{!(a.target instanceof Node)||!n.contains(a.target)||(a.stopPropagation(),nr(t,r),ee.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>ee.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",()=>ee.get(t)?.callbacks.onLocationFocusChange(!0)),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,ee.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",a=>{let s=ee.get(t);if(!(!s||a.isComposing))switch(a.key){case"ArrowDown":case"ArrowUp":a.preventDefault(),s.callbacks.onLocationMove(a.key==="ArrowDown"?1:-1);return;case"Enter":if(a.preventDefault(),!s.interactive)return;Pe(t,!0),s.callbacks.onLocationCommit();return;case"Escape":a.preventDefault(),a.stopPropagation(),r.declined=!0,Pe(t);return;case"Backspace":if(i.value!=="")return;a.preventDefault(),r.declined=!0,Pe(t);return}}),pe.set(t,r),r}function ir(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=pe.get(e);n&&(me(n)&&Pe(e),n.declined=!1,n.input.tabIndex=-1)}}function or(t,e,n,i,o={}){let r=Array.from(t.children).find(l=>l.hasAttribute("data-aia-location"))??null;if(!e){if(r){let l=pe.get(r);l&&me(l)&&Pe(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let a=pe.get(r)??bs(r,n);a.input.tabIndex=0,ee.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),U(a.results,fs,ee.get(r)),a.input.value!==e.query&&!me(a)&&(a.input.value=e.query);let s=l=>`${r?.id}-row-${l}`;if(tr(a.results,e,n,s),e.highlighted>=0&&e.highlighted<e.places.length?a.input.setAttribute("aria-activedescendant",s(e.highlighted)):a.input.removeAttribute("aria-activedescendant"),a.widgetFocused=o.inputFocused??!1,o.inputFocused){if(!a.declined&&o.interactive!==!1&&!me(a)){let l=r;queueMicrotask(()=>{l.isConnected&&!pe.get(l)?.declined&&hs(l)})}}else{let l=a;setTimeout(()=>{if(l.widgetFocused)return;let d=l.returnTo;d&&st(d)===d||(l.declined=!1)},0)}}var Ss={itemSelector:"[data-aia-pill]",onClick:(t,e)=>{if(e.loading||t.disabled)return;let n=Number.parseInt(t.dataset.aiaPillIndex??"-1",10);n>=0&&e.onSelectPill(n)},preventMousedown:!0},rr=[125,69];function ar(t,e){return e?1:t===0?.7:t===1?.4:.2}function Rt(t,e,n,i,o=!1,r=!1,a=!1){let s=t.querySelector(".magicx-aia-pill-list");if(s||(s=document.createElement("span"),s.className="magicx-aia-pill-list",t.appendChild(s)),U(s,Ss,{onSelectPill:i,loading:r}),r&&e.length===0){s.setAttribute("data-aia-pill-list-loading",""),s.innerHTML="";for(let l=0;l<rr.length;l++){let d=rr[l],c=document.createElement("span");c.setAttribute("data-aia-pill-skeleton",""),c.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,c.style.width=`${d}px`,c.style.opacity=String(ar(l,!1)),s.appendChild(c)}return}r?s.setAttribute("data-aia-pill-list-loading",""):s.removeAttribute("data-aia-pill-list-loading");for(let l of s.querySelectorAll("[data-aia-pill-skeleton]"))l.remove();j(s,e,{keyOf:l=>`${l.type?.kind??""}|${tt(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let d=document.createElement("button");if(d.type="button",d.tabIndex=-1,d.setAttribute("data-aia-pill",""),d.setAttribute("contenteditable","false"),tt(l)){d.setAttribute("data-aia-smart-suggestion",w(l)?"header":"");let c=document.createElement("span");c.className="magicx-aia-smart-suggestion-text",c.textContent=l.text;let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-sparkle",u.innerHTML=en,d.append(c,u)}else d.textContent=l.text;return d.disabled=!0,d},update:(l,d,c)=>{let u=l,m=a&&c===n&&!r,h=["magicx-aia-pill"];o&&h.push("magicx-aia-pill--rounded"),r&&h.push("magicx-aia-pill--skeleton"),u.className=h.join(" "),u.style.width="",u.style.opacity=String(ar(c,m)),u.dataset.aiaPillIndex=String(c),r?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),q(s);for(let l of s.querySelectorAll("[data-aia-pill]"))l.disabled=r}function Jn(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var ys=32;function sr(t,e){if(e.ctrlKey)return null;let n=e.deltaY||0,i=e.deltaX||0;if(!n||Math.abs(i)>=Math.abs(n))return null;let o=t.scrollWidth-t.clientWidth;if(o<=1)return null;let r=t.scrollLeft,a=n;return e.deltaMode===1?a*=32:e.deltaMode===2&&(a*=t.clientWidth),Math.max(0,Math.min(o,r+a))}function Zn(t){let e=n=>{let i=sr(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var lr=Intl.Segmenter,cr=lr?new lr(void 0,{granularity:"grapheme"}):null;function ei(t){let e=t.trim().normalize("NFC").toUpperCase();if(cr)for(let n of cr.segment(e))return n.segment;return Array.from(e)[0]??"?"}var ti=120,xs=360;function Ts(t){let e=t.pathname;return t.hostname==="cdn.shopify.com"&&e.startsWith("/s/files/")||e.startsWith("/cdn/shop/")?/\.png$/i.test(e)?{format:"pjpg"}:/\.webp$/i.test(e)?{format:null}:null:null}function dr(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=Ts(n);return i?(n.searchParams.set("width",String(e)),i.format&&n.searchParams.set("format",i.format),t.startsWith("/")&&!t.startsWith("//")?`${n.pathname}${n.search}${n.hash}`:n.href):t}function ni(t,e){let n=dr(t,e);return n===t?[t]:[n,t]}function ii(t,e){if(!(t>0)||!(e>0))return null;let n=t/e,i=o=>Math.round(o*1e3)/1e3;return{x:i(Math.min(n,1)),y:i(Math.min(1/n,1))}}function _t(t){let e=t?.trim();return e?ni(e,360):[]}function vs(t){return _t(t)[0]}var Dt=new WeakMap,ri=new WeakMap,pr=new WeakMap;function mr(t,e,n,i,o,r="row",a="image",s=O(),l){let d=t.querySelector(".magicx-aia-products");if(e.length===0){d?.remove();return}if(!d){d=document.createElement("section"),d.className="magicx-aia-products",d.setAttribute("data-aia-products",""),d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${n}-products-label`);let m=document.createElement("div");m.className="magicx-aia-products-label",m.id=`${n}-products-label`,m.setAttribute("data-aia-products-label",""),m.textContent=s.products;let h=document.createElement("div");h.className="magicx-aia-products-row",h.setAttribute("data-aia-products-row",""),Zn(h),d.append(m,h),t.appendChild(d)}d.setAttribute("data-aia-products-layout",r);let c=d.querySelector(".magicx-aia-products-label");c&&c.textContent!==s.products&&(c.textContent=s.products);let u=d.querySelector(".magicx-aia-products-row");if(u){j(u,e,{keyOf:m=>Cs(m,!!l),create:m=>Ls(m,i,o,a,s,l),update:(m,h,g)=>{Dt.set(m,h),Es(m,h.price,h.compareAtPrice),m.id=`${n}-product-${g}`,m.dataset.aiaIndex=String(g),pr.get(m)?.(a);let f=m.querySelector(".magicx-aia-product-badge");f&&f.textContent!==s.soldOut&&(f.textContent=s.soldOut);let S=m.querySelector(".magicx-aia-product-cart");S&&S.setAttribute("aria-label",gr(h,s))}}),q(u);for(let m of u.querySelectorAll("[data-aia-product]")){let h=ri.get(m);h&&(ri.delete(m),h())}}}function ai(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)i.tabIndex=e?0:-1}function Es(t,e,n){let i=t.querySelector(".magicx-aia-product-price");if(!e){i?.remove();return}i||(i=document.createElement("span"),i.className="magicx-aia-product-price",i.append(document.createTextNode("")),t.querySelector(".magicx-aia-product-title")?.after(i));let o=i.firstChild;o.data!==e&&(o.data=e);let r=i.querySelector(".magicx-aia-product-compare-at");if(!n){r?.remove();return}r||(r=document.createElement("s"),r.className="magicx-aia-product-compare-at",i.append(r)),r.textContent!==n&&(r.textContent=n)}function ur(t,e){e?(t.style.setProperty("--aia-product-photo-fill-x",String(e.x)),t.style.setProperty("--aia-product-photo-fill-y",String(e.y))):(t.style.removeProperty("--aia-product-photo-fill-x"),t.style.removeProperty("--aia-product-photo-fill-y"))}function gr(t,e){return`${e.addToCart}: ${t.title}`}var oi="http://www.w3.org/2000/svg";function ws(){let t=document.createElementNS(oi,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false");let e=[["magicx-aia-product-cart-glyph","M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"],["magicx-aia-product-cart-glyph","M13.5 6.5v-4M11.5 4.5h4"],["magicx-aia-product-cart-check","M5 12.5l4.5 4.5L19 7.5"],["magicx-aia-product-cart-spinner","M12 4a8 8 0 1 0 8 8"]];for(let[n,i]of e){let o=document.createElementNS(oi,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(oi,"circle");i.setAttribute("class","magicx-aia-product-cart-glyph"),i.setAttribute("cx",n),i.setAttribute("cy","20"),i.setAttribute("r","1.3"),t.appendChild(i)}return t}function Ps(t,e,n,i,o){let r=document.createElement("span");r.className="magicx-aia-product-cart",r.setAttribute("data-aia-product-cart",""),r.setAttribute("role","button"),r.setAttribute("aria-label",gr(e,o)),r.tabIndex=0,r.appendChild(ws());let a=s=>{s.preventDefault(),s.stopPropagation(),r.getAttribute("data-aia-cart-state")!=="adding"&&(r.setAttribute("data-aia-cart-state","adding"),r.setAttribute("aria-busy","true"),n(Dt.get(t)??e).then(()=>{r.removeAttribute("aria-busy"),r.setAttribute("data-aia-cart-state","added")},()=>{r.removeAttribute("aria-busy"),r.removeAttribute("data-aia-cart-state")}))};return r.addEventListener("keydown",s=>{s.key!=="Enter"&&s.key!==" "||a(s)}),r.addEventListener("focus",()=>i(!0)),r.addEventListener("blur",s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||i(!1)}),{el:r,arm:()=>r.addEventListener("click",a)}}function Cs(t,e){return[e?"cart":"",t.id,t.title,t.url,t.imageUrl,t.vendor,t.available===!1?"sold-out":""].map(n=>n??"").join("\0")}function Ls(t,e,n,i,o,r){let a=document.createElement("a");a.className="magicx-aia-product",a.setAttribute("data-aia-product",""),a.setAttribute("role","option"),a.setAttribute("aria-selected","false"),a.tabIndex=0;let s=document.createElement("span");s.className="magicx-aia-product-media",s.setAttribute("aria-hidden","true");let l=_t(t.imageUrl),d=l[0],c=!!d,u=()=>{s.replaceChildren(),s.removeAttribute("data-aia-image-loaded"),s.toggleAttribute("data-aia-product-placeholder",i==="image"),s.toggleAttribute("data-aia-product-initial",i==="initial"),i==="initial"&&(s.textContent=ei(t.title))};if(pr.set(a,f=>{f!==i&&(i=f,c||u())}),d){let f=document.createElement("img"),S=0;f.onload=()=>{s.setAttribute("data-aia-image-loaded",""),ur(a,ii(f.naturalWidth,f.naturalHeight))},f.onerror=()=>{let y=l[++S];if(y){f.src=y;return}c=!1,ur(a,null),u()},f.className="magicx-aia-product-image",f.src=d,f.alt="",f.loading="lazy",f.decoding="async",s.appendChild(f)}else u();a.appendChild(s);let m=document.createElement("span");if(m.className="magicx-aia-product-body",t.vendor){let f=document.createElement("span");f.className="magicx-aia-product-vendor",f.textContent=t.vendor,m.appendChild(f)}let h=document.createElement("span");if(h.className="magicx-aia-product-title",h.textContent=t.title,m.appendChild(h),t.available===!1){a.setAttribute("data-aia-product-sold-out","");let f=document.createElement("span");f.className="magicx-aia-product-badge",f.textContent=o.soldOut,m.appendChild(f)}a.appendChild(m);let g=r&&t.available!==!1?Ps(a,t,r,n,o):null;return g&&(a.setAttribute("data-aia-product-has-cart",""),a.appendChild(g.el)),ri.set(a,()=>{g?.arm(),t.url&&(a.href=t.url),a.addEventListener("click",f=>{f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||f.button!==0||(f.preventDefault(),e(Dt.get(a)??t))})}),a.addEventListener("keydown",f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),e(Dt.get(a)??t))}),a.addEventListener("focus",()=>n(!0)),a.addEventListener("blur",f=>{f.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),a}var Is=40,Os=340,As=340,ks=7,si="--aia-option-enter-delay";function li(t,e,n,i="below"){let o=Math.max(1,Math.floor(e)),r=Math.floor(Math.max(0,t)/o);if(i!=="above")return r*40;let a=Math.max(1,Math.ceil(Math.max(0,n)/o));return Math.max(0,a-1-r)*40}function ci(t,e){let n=Math.max(1,Math.floor(e));return(Math.max(1,Math.ceil(Math.max(0,t)/n))-1)*40+340}var Ms=10,Rs=44;function di(t,e,n){if(!e||n.detail===0)return!0;let i=t.getBoundingClientRect(),o=e.getBoundingClientRect();if(t.ownerDocument.defaultView?.getComputedStyle(t).direction==="rtl"){let s=Math.min(o.left-10,i.right-44);return n.clientX>=s}let a=Math.max(o.right+10,i.left+44);return n.clientX<=a}var fr="http://www.w3.org/2000/svg",_s=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function Ds(t,e){let n=t.toLowerCase();return n.startsWith("on")||n.includes("href")||n==="style"||n==="xml:base"||n==="id"||n==="name"||/^\s*javascript:/i.test(e)||/url\s*\(\s*['"]?\s*[^#'"\s)]/i.test(e)}var Ns=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],Fs=/^[a-zA-Z0-9#.,%\s()-]+$/;function Hs(t){let e=[];for(let n of Ns){let i=t.getAttribute(n);i===null||!Fs.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function hr(t){for(let e of Array.from(t.attributes))Ds(e.name,e.value)&&t.removeAttribute(e.name);Hs(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!_s.has(n.localName)||n.namespaceURI!==fr?n.remove():hr(n)}else e.remove()}function ge(t){if(typeof DOMParser>"u"||typeof XMLSerializer>"u")return null;let e=new DOMParser().parseFromString(t,"image/svg+xml"),n=e.documentElement;return!n||n.localName!=="svg"||n.namespaceURI!==fr||e.getElementsByTagName("parsererror").length>0?null:(hr(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function Nt(t){return t.text}function fe(t){return Ht(t)[0]??null}function Ht(t){let e=Ws(t);return e?ni(e,120):[]}function Ws(t){if(!t)return null;let e=t.trim();if(e==="")return null;let n;try{n=new URL(e,typeof document>"u"?void 0:document.baseURI)}catch{return null}return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}function Ve(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var br={one:"item",other:"items"};function Us(t,e=br){let n=Ve(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function Sr(t){return fe(t.image_url)!==null}var Ft=new Map;function Bs(t){let e=t.icon_svg;if(!e)return!1;let n=Ft.get(e);return n===void 0&&(n=ge(e)!==null,Ft.size>=256&&Ft.clear(),Ft.set(e,n)),n}function ui(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&Sr(i)||e&&Bs(i))}var yr=new WeakMap;function Vs(t,e,n){let i=e.length,o=Bn(),r=yr.get(t),a=n&&r&&Vn(r.options,e)?r.plan:null,s=!a&&!n&&Hn(i,o)?Un(t):null,l=a??Wn(i,o,s?.rowWidths??null,s?.gridWidth??null);return n||yr.set(t,{options:e,plan:l}),t.style.gridTemplateColumns=l.template,t.style.setProperty("--aia-grid-max-height",l.maxHeight),t.querySelectorAll("[data-aia-option]").forEach((d,c)=>{d.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(c))}),l.cols}function xr(t,e){if(e.loading||!e.interactive)return null;let n=e.options[le(t)];return n?.is_tappable?n:null}var Gs={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=xr(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!di(t,o,n);if(o){let a=r||t.getAttribute("aria-selected")!=="true";t.setAttribute("aria-selected",String(a)),o.dataset.checked=String(a),o.textContent=a?"\u2713":""}r?e.onSelect(i,{commit:!0}):e.onSelect(i),setTimeout(()=>t.classList.remove("magicx-aia-option--pressed"),170)},onEnter:(t,e)=>{xr(t,e)&&e.onHighlight(le(t))},onLeave:(t,e)=>e.onHighlight(-1,le(t))};function Tr(t,e,n,i,o,r,a,s="",l="below",d=!0,c=!0,u=!0,m=!0,h){let g=t.querySelector(".aia-grid");if(e.length===0){g?.remove();return}g||(g=document.createElement("div"),g.className="aia-grid magicx-aia-grid",g.setAttribute("data-scroll",""),g.style.setProperty("--aia-grid-min","250px"),g.style.setProperty("--aia-grid-max","1fr"),g.style.setProperty("--aia-grid-gap","0"),t.appendChild(g)),U(g,Gs,{options:e,onSelect:i,onHighlight:o,loading:a,interactive:m});let f=g.dataset.aiaGroup!==s;g.dataset.aiaGroup=s;let S=ui(e,d,c);$s(g,e,n,r,a,{showIcons:d&&S,showImages:c&&S,showCounts:u,picked:h});let y=Vs(g,e,a);qs(g,e.length,y,a,l),f&&(g.scrollTop=0)}function $s(t,e,n,i,o,r){let a=o?"1":"0",s=t.dataset.aiaGroup??"",{showIcons:l,showImages:d,showCounts:c}=r,u=l?g=>g.icon??g.icon_svg??"":()=>"",m=d?g=>fe(g.image_url)??"":()=>"",h=c?g=>Ve(g.item_count)??"":()=>"";j(t,e,{keyOf:g=>`${g.text}\0${g.parameterLabel??""}\0${u(g)}\0${m(g)}\0${h(g)}\0${a}\0${s}`,create:(g,f)=>{let S=Ks(g,o,r);return o||(S.dataset.aiaEntering=""),S},update:(g,f,S)=>{if(pi.get(g)!==(f.matchedText??"")){let b=g.querySelector(".magicx-aia-option-text");b&&vr(b,f),pi.set(g,f.matchedText??"")}let y=S===n&&!o;g.id=`${i}-option-${S}`,g.dataset.aiaIndex=String(S),g.setAttribute("aria-selected",String(r.picked?r.picked.includes(f.text):y));let p=g.querySelector(".magicx-aia-checkbox");r.picked&&f.is_tappable?(p||(p=document.createElement("span"),p.className="magicx-aia-checkbox",p.setAttribute("aria-hidden","true"),g.querySelector(".magicx-aia-option-content")?.prepend(p)),p.dataset.checked=String(r.picked.includes(f.text)),p.textContent=r.picked.includes(f.text)?"\u2713":""):p?.remove(),g.classList.toggle("magicx-aia-option--highlighted",y),g.classList.toggle("magicx-aia-option--live-match",!!f.liveMatch&&!o)}})}function qs(t,e,n,i,o){for(let r of t.querySelectorAll("[data-aia-entering]")){if(!i){let a=Number.parseInt(r.dataset.aiaIndex??"-1",10);a>=0&&r.style.setProperty(si,`${li(a,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var pi=new WeakMap;function vr(t,e){if(t.replaceChildren(),e.matchedText)for(let n of $n(Nt(e),e.matchedText))if(n.bold){let i=document.createElement("strong");i.className="magicx-aia-option-match",i.textContent=n.text,t.appendChild(i)}else t.appendChild(document.createTextNode(n.text));else t.appendChild(document.createTextNode(Nt(e)));if(e.parameterLabel){t.appendChild(document.createTextNode(" "));let n=document.createElement("span");n.className="magicx-aia-option-parameter",n.textContent=e.parameterLabel,t.appendChild(n)}}function Ks(t,e,{showIcons:n,showImages:i,showCounts:o}){let r=document.createElement("div");r.setAttribute("role","option"),r.setAttribute("data-aia-option",""),e&&r.setAttribute("data-aia-loading",""),r.tabIndex=e||!t.is_tappable?-1:0;let a=["magicx-aia-option"];t.is_tappable?a.push("magicx-aia-option--tappable"):a.push("magicx-aia-option--non-tappable"),r.className=a.join(" ");let s=document.createElement("span");s.className="magicx-aia-option-content";let l=i?Ht(t.image_url):[],d=l[0];if(d){let h=document.createElement("span");h.className="magicx-aia-option-image",h.setAttribute("aria-hidden","true");let g=document.createElement("img");g.setAttribute("alt",""),g.setAttribute("loading","lazy"),g.setAttribute("decoding","async"),g.setAttribute("referrerpolicy","no-referrer"),g.setAttribute("draggable","false");let f=0;g.onload=()=>h.setAttribute("data-aia-image-loaded",""),g.onerror=()=>{let S=l[++f];S?g.src=S:g.hidden=!0},g.src=d,h.appendChild(g),s.appendChild(h),r.dataset.aiaImage=""}let c=!d&&n&&t.icon_svg?ge(t.icon_svg):null;if(c){let h=document.createElement("span");h.className="magicx-aia-option-icon",h.setAttribute("aria-hidden","true"),h.innerHTML=c,s.appendChild(h),t.icon&&(r.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",vr(u,t),pi.set(r,t.matchedText??""),s.appendChild(u),t.tag){let h=document.createElement("span");h.className="magicx-aia-option-tag",h.textContent=t.tag,s.appendChild(h)}let m=o?Ve(t.item_count):null;if(m!==null){let h=document.createElement("span");h.className="magicx-aia-option-count",h.textContent=m,s.appendChild(h),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(s),r}var zs=120,js={itemSelector:"[data-aia-time-row], [data-aia-time-done]",onClick:(t,e)=>{if(!e.interactive)return;if(t.hasAttribute("data-aia-time-done")){e.callbacks.onTimeCommit();return}let n=t.dataset.aiaTimeColumn;n&&e.callbacks.onTimeChange(St(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},wr=new WeakMap,Er=new WeakMap;function Pr(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=Xs(),t.appendChild(r),q(r);let d=r.querySelector("[data-aia-time-done]");d&&(d.disabled=!1)}let a={view:e,callbacks:i,interactive:o};wr.set(r,a),U(r,js,a),r.setAttribute("aria-label",n.timeLabel);let s=r.querySelector("[data-aia-time-done]");s&&(s.textContent=n.done);let l=r.querySelector("[data-aia-time-value]");l&&(l.textContent=gt(e.minutes));for(let d of ht){let c=r.querySelector(`[data-aia-time-column="${d}"]`);c&&Ys(c,d,e.minutes)}}function Ys(t,e,n){let i=bt(e,n);for(let a of t.querySelectorAll("[data-aia-time-row]")){let s=Number(a.dataset.aiaIndex)===i;a.classList.toggle("magicx-aia-time-wheel-row--selected",s),a.setAttribute("aria-selected",String(s))}let o=Wt(t);if(o.settle)return;let r=i*ft;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function Wt(t){let e=Er.get(t);return e||(e={syncedTop:null,settle:null},Er.set(t,e)),e}function Qs(t,e,n){let i=Wt(e);if(i.syncedTop!=null&&Math.abs(e.scrollTop-i.syncedTop)<1){i.syncedTop=null;return}i.syncedTop=null,i.settle&&clearTimeout(i.settle),i.settle=setTimeout(()=>Cr(t,e,n),zs)}function Cr(t,e,n){let i=Wt(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=wr.get(t);if(!o||!o.interactive)return;let r=On(n,e.scrollTop);r!==bt(n,o.view.minutes)&&o.callbacks.onTimeChange(St(n,o.view.minutes,r))}function Xs(){let t=document.createElement("div");t.className="magicx-aia-time-wheel",t.setAttribute("data-aia-time-wheel",""),t.setAttribute("role","group");let e=document.createElement("span");e.className="magicx-aia-time-wheel-value",e.setAttribute("data-aia-time-value",""),e.setAttribute("aria-live","polite");let n=document.createElement("div");n.className="magicx-aia-time-wheel-columns",n.setAttribute("aria-hidden","true");let i=document.createElement("div");i.className="magicx-aia-time-wheel-band",n.appendChild(i);for(let r of ht){if(r==="minute"){let a=document.createElement("span");a.className="magicx-aia-time-wheel-separator",a.textContent=":",n.appendChild(a)}n.appendChild(Js(t,r))}let o=document.createElement("button");return o.type="button",o.tabIndex=-1,o.className="magicx-aia-time-wheel-done",o.setAttribute("data-aia-time-done",""),o.disabled=!0,t.append(e,n,o),t}function Js(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),In(e).forEach((i,o)=>{let r=document.createElement("div");r.className="magicx-aia-time-wheel-row",r.setAttribute("data-aia-time-row",""),r.dataset.aiaTimeColumn=e,r.dataset.aiaIndex=String(o),r.textContent=i.label,n.appendChild(r)}),n.addEventListener("scroll",()=>Qs(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{Wt(n).settle&&Cr(t,n,e)}),n}var Lr="magicx-aia-scroll-arrow",Ir="data-aia-scroll-arrow",Ce="data-aia-visible",Or=1e3,Ar=160,kr="--aia-scroll-arrow-bottom",Zs="Scroll down for more options",el="[data-aia-products-label]",tl=4,nl=8,il=240;function ol(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,a=t.ownerDocument?.visibilityState==="hidden";if(!r||a||mi(t)){t.scrollTop=o+e,i();return}let s=n.performance?.now?.()??Date.now(),l=()=>n.performance?.now?.()??Date.now(),d=()=>{let c=Math.min(1,(l()-s)/il),u=1-(1-c)*(1-c);t.scrollTop=o+e*u,c<1?r.call(n,d):i()};r.call(n,d)}function rl(t=document){let e="http://www.w3.org/2000/svg",n=t.createElementNS(e,"svg");n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.75"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false");let i=t.createElementNS(e,"path");return i.setAttribute("d","M4 6.5 8 10.5l4-4"),n.appendChild(i),n}function Mr(t=document,e=O()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=Lr,n.setAttribute(Ir,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(rl(t)),n}function al(t){let e=t.style.gridTemplateColumns.trim();return e?Math.max(1,e.split(/\s+/).length):1}function mi(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function gi({dropdown:t,grid:e,button:n}){let i=e.ownerDocument?.defaultView??(typeof window<"u"?window:null),o=!1;n.disabled=!0;let r=null,a=null,s=null,l=null,d=p=>{if(p){if(n.hasAttribute(Ce))return;if(n.setAttribute(Ce,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),mi(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(Ce)&&(n.disabled=!1)},Or)}else n.removeAttribute(Ce),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},c=p=>{let b=0,T=p;for(;T&&T!==t;)b+=T.offsetTop,T=T.offsetParent instanceof HTMLElement?T.offsetParent:null;return b},u=()=>{let p=t.querySelector(el),b;if(p){let T=c(p)+p.offsetHeight/2;b=t.clientHeight-T-n.offsetHeight/2}else{let T=c(e),x=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;b=t.clientHeight-(T+e.offsetHeight)+(x>0?0:nl)}n.style.setProperty(kr,`${Math.max(0,Math.round(b))}px`)},m=()=>{if(o||a!==null||s!==null)return;let p=e.querySelector("[data-aia-option][data-aia-loading]")!==null,b=e.scrollHeight-e.clientHeight-e.scrollTop;d(!p&&b>tl)},h=()=>{if(o)return;u();let p=e.getAttribute("data-aia-group")??"";if(p!==r){r=p,d(!1),a!==null&&clearTimeout(a);let b=e.querySelectorAll("[data-aia-option]").length,T=mi(e)?0:ci(b,al(e));a=setTimeout(()=>{a=null,m()},T);return}m()},g=()=>{o||a!==null||(d(!1),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,m()},Ar))};e.addEventListener("scroll",g,{passive:!0});let f=p=>p.preventDefault(),S=()=>{let p=i?(Number.parseFloat(i.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0):0,b=Math.max(1,e.clientHeight-p);ol(e,b,i,g)};n.addEventListener("mousedown",f),n.addEventListener("click",S);let y=null;return i&&typeof i.ResizeObserver=="function"&&(y=new i.ResizeObserver(()=>{u(),m()}),y.observe(e)),h(),{update:h,destroy(){o||(o=!0,a!==null&&clearTimeout(a),a=null,s!==null&&clearTimeout(s),s=null,l!==null&&clearTimeout(l),l=null,n.disabled=!0,e.removeEventListener("scroll",g),n.removeEventListener("mousedown",f),n.removeEventListener("click",S),y?.disconnect(),n.removeAttribute(Ce),n.setAttribute("aria-hidden","true"))}}}var Le="data-aia-fit",Ut="--aia-dropdown-fit-height";function fi({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,a=null,s=null,l=()=>{t.removeAttribute(Le),t.style.removeProperty(Ut)},d=h=>{let f=`${r}|${(h??t).scrollHeight}|${t.offsetWidth}`;if(s?.key===f)return s.height;let S=h?.scrollTop??0;t.removeAttribute(Le);let y=t.offsetHeight;return t.setAttribute(Le,""),h&&S&&(h.scrollTop=S),s={key:f,height:y},y},c=()=>{if(i)return;if(!e()){o=!1;return}o||(o=!0,l());let h=t.hasAttribute(Le),g=t.querySelector(".aia-grid")?.getAttribute("data-aia-group")??null,f=g!==r;r=g;let S=ll(t,n);if(S===null)return;let y=sl(t);if(h){if(d(y)<=S){l();return}}else if(t.offsetHeight<=S)return;let p=`${Math.max(160,Math.floor(S))}px`;t.style.getPropertyValue(Ut)!==p&&t.style.setProperty(Ut,p),h?f&&y&&(y.scrollTop=0):t.setAttribute(Le,"")},u=()=>{i||a!==null||!n||(a=n.requestAnimationFrame(()=>{a=null,c()}))},m=n?.visualViewport??null;return m?.addEventListener("resize",u),m?.addEventListener("scroll",u),n?.addEventListener("resize",u),n?.addEventListener("scroll",u,{capture:!0,passive:!0}),c(),{update:c,destroy(){i||(i=!0,a!==null&&n?.cancelAnimationFrame(a),m?.removeEventListener("resize",u),m?.removeEventListener("scroll",u),n?.removeEventListener("resize",u),n?.removeEventListener("scroll",u,{capture:!0}))}}}function sl(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function ll(t,e){if(!e)return null;let n=e.visualViewport,i=n?n.offsetTop:0,o=n?n.height:e.innerHeight;if(!o)return null;let r=t.offsetParent,a=r?r.getBoundingClientRect().top:0,s=r?a+t.offsetTop:t.getBoundingClientRect().top;return t.closest("[data-options-position]")?.getAttribute("data-options-position")==="above"?(r?s+t.offsetHeight:t.getBoundingClientRect().bottom)-i-8:i+o-s-8}var cl=[159,119,164];function Gt(t){let e=document.createElement("div");return e.id=t,e.setAttribute("role","listbox"),e.setAttribute("data-aia-dropdown",""),e.className="magicx-aia-dropdown",e.addEventListener("mousedown",n=>n.preventDefault()),Yn(e),e}var Bt=new WeakMap;function dl(t,e,n){let i=Bt.get(t);if(i||(i={button:Mr(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),Bt.set(t,i)),i.button.getAttribute("aria-label")!==n.scrollArrow&&i.button.setAttribute("aria-label",n.scrollArrow),i.grid!==e&&(i.controller?.destroy(),i.controller=null,i.grid=e,e)){i.controller=gi({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var Vt=new WeakMap;function Rr(t){let e=Vt.get(t);if(e){e.update();return}Vt.set(t,fi({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function hi(t){Vt.get(t)?.destroy(),Vt.delete(t);let e=Bt.get(t);e&&(e.controller?.destroy(),Bt.delete(t))}function $t(t,e){let n=e.strings??O(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:a,showPills:s,isActivePillSelected:l,onSelect:d,onHighlight:c,onPillClick:u,onSkip:m}=e,h=Zt(e.pills,n.keepTyping),g=tn(h),f=s&&h.length>0,S=i.length>0,y=e.products.length>0,p=e.formatType==="time"&&e.timeView!=null,b=e.formatType==="location"&&e.locationView!=null,T=r&&(S||f||a||y||p||b);if(T?t.classList.add("magicx-aia-dropdown--visible"):t.classList.remove("magicx-aia-dropdown--visible"),a?t.setAttribute("data-aia-loading",""):t.removeAttribute("data-aia-loading"),!T){ai(t,!1),ir(t),Rr(t);return}y?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let x=t.querySelector(".aia-stack");x||(x=document.createElement("div"),x.className="aia-stack",x.style.setProperty("--aia-stack-space","8px"),t.appendChild(x));let L=e.showSkipButton&&g&&!e.isInputEmpty,P=f||a&&s||L,E=x.querySelector(".magicx-aia-pill-bar");if(P){E||(E=document.createElement("div"),E.className="magicx-aia-pill-bar aia-cluster",E.setAttribute("data-nowrap",""),E.setAttribute("data-aia-pillbar",""),x.insertBefore(E,x.firstChild));let R=E.querySelector(".magicx-aia-pill-scroll");R||(R=document.createElement("span"),R.className="magicx-aia-pill-scroll",R.setAttribute("data-aia-pill-scroll",""),E.insertBefore(R,E.firstChild)),Rt(R,s?h:[],0,u,!0,a&&s,l),ml(E,L,a||e.skipDisabled,h[0],m,n)}else E&&E.remove();let C=e.suggestions[0],A=C?`${C.parameter} ${C.text}`:"",B=k(e.formatType),te=B&&!a;Tr(x,B?[]:i,o,d,c,e.listboxId,a,A,e.optionsPosition??"below",e.showOptionIcons??!0,e.showOptionImages??!0,e.showOptionCounts??!0,!e.skipDisabled,a?void 0:e.multiSelectView?.picked),t.setAttribute("aria-multiselectable",String(!!e.multiSelectView)),bl(x,!!e.multiSelectView&&!a,e.skipDisabled,e.onMultiSelectCommit,n.done),dl(t,x.querySelector(".aia-grid"),n),Zo(x,te?i:[],o,e.listboxId,te?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart},{onSelect:d,onHighlight:c,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),Pr(x,e.formatType==="time"&&!a?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),or(x,e.formatType==="location"&&!a?e.locationView:null,n,{onLocationQuery:e.onLocationQuery,onLocationMove:e.onLocationMove,onLocationCommit:e.onLocationCommit,onLocationFocusChange:e.onLocationFocusChange},{interactive:!e.skipDisabled,inputFocused:e.isFocused??!1});let _=x.querySelector(".magicx-aia-skeleton-bars");if(a&&(!S||D(e.formatType))){if(!_){_=document.createElement("div"),_.className="magicx-aia-skeleton-bars",_.setAttribute("data-aia-skeleton-bars","");for(let R of cl){let ne=document.createElement("span");ne.className="magicx-aia-skeleton-bar",ne.style.width=`${R}px`,_.appendChild(ne)}x.appendChild(_)}}else _&&_.remove();mr(x,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart),ai(t,!0);let v=x.querySelector(".magicx-aia-footer")??fl(n),Y=o>=0&&!!i[o]?.is_tappable;gl(v,jn(Y,e.isInputEmpty,n)),v.isConnected||x.appendChild(v),ul(x,[".magicx-aia-pill-bar",".aia-grid","[data-aia-multi-actions]",".magicx-aia-datepicker",".magicx-aia-time-wheel","[data-aia-location]",".magicx-aia-skeleton-bars",".magicx-aia-products",".magicx-aia-footer"]),Rr(t)}function ul(t,e){let n=e.map(i=>t.querySelector(`:scope > ${i}`)).filter(i=>i!==null);for(let i=0;i<n.length;i++)t.children[i]!==n[i]&&t.insertBefore(n[i],t.children[i]??null)}var pl={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function ml(t,e,n,i,o,r){U(t,pl,{onSkip:o,loading:n});let a=t.querySelector(".magicx-aia-skip");if(!e){a?.remove();return}a||(a=document.createElement("button"),a.type="button",a.tabIndex=-1,a.className="magicx-aia-skip",a.setAttribute("data-aia-skip",""),a.textContent=r.skip,a.disabled=!0,t.appendChild(a),q(a)),a.textContent!==r.skip&&(a.textContent=r.skip),a.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),a.disabled=n}function gl(t,{key:e,hint:n}){let i=t.querySelector(".magicx-aia-footer-key"),o=t.querySelector(".magicx-aia-footer-hint");!i||!o||(i.textContent!==e&&(i.textContent=e),o.textContent!==n&&(o.textContent=n))}function fl(t){let e=document.createElement("footer");e.className="magicx-aia-footer",e.setAttribute("data-aia-footer","");let n=document.createElement("div");n.className="aia-cluster magicx-aia-footer-row",n.setAttribute("data-align","center"),n.setAttribute("data-justify","between"),n.setAttribute("data-nowrap","");let i=document.createElement("div");i.className="aia-cluster magicx-aia-footer-hint-group",i.setAttribute("data-align","center"),i.style.setProperty("--aia-cluster-gap","5px");let o=document.createElement("kbd");o.className="magicx-aia-footer-key",o.textContent="tab";let r=document.createElement("span");r.className="magicx-aia-footer-hint",r.textContent=t.select,i.append(o,r);let a=document.createElement("a");a.className="aia-cluster magicx-aia-footer-brand-link",a.setAttribute("data-align","center"),a.href=Kn(),a.target="_blank",a.rel="noopener noreferrer",a.style.setProperty("--aia-cluster-gap","2px");let s=document.createElement("span");s.className="magicx-aia-footer-brand",s.textContent="AI";let l=document.createElement("span");return l.className="magicx-aia-footer-badge",l.textContent="Autocomplete",a.append(s,l),n.append(i,a),e.append(n),e}var hl={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function bl(t,e,n,i,o){let r=t.querySelector("[data-aia-multi-actions]");if(!e){r?.remove();return}if(!r){r=document.createElement("div"),r.dataset.aiaMultiActions="";let s=document.createElement("button");s.type="button",s.tabIndex=-1,s.className="magicx-aia-multi-done",s.disabled=!0,r.appendChild(s),t.appendChild(r),q(s)}U(r,hl,{commit:i,disabled:n});let a=r.querySelector("button");a&&(a.textContent=o,a.disabled=n)}function _r(t,e){let n=Gt(e.listboxId);return t.appendChild(n),{dropdown:n}}function bi(t,e,n){let i=Be(e);$t(t.dropdown,{strings:n.strings,suggestions:e.editingIdentified?[{parameter:e.editingIdentified.parameter,text:J(e.editingIdentified.parameter),required:!0,options:e.filteredOptions}]:e.dropdownSuggestion??e.actionableSuggestions[0]?[{...e.dropdownSuggestion??e.actionableSuggestions[0],options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:e.actionableSuggestions,showPills:!0,showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:i.selectedIso,selectedDateRange:i.selectedRange,dateRangeStart:i.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,locationView:e.locationView,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:n.selectOption,onHighlight:(o,r)=>{r!==void 0&&n.store.get().activeDropdownIndex!==r||n.store.set({activeDropdownIndex:o})},onPillClick:n.setActivePill,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,onProductSelect:n.selectProduct,onProductFocusChange:o=>n.store.set({isFocused:o})})}var Sl=340;function Si(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let c=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let u=t.getBoundingClientRect().height;if(u!==0){if(c===0||Math.abs(u-c)<.5){t.style.height=`${u}px`;return}t.style.height=`${c}px`,t.getBoundingClientRect(),t.style.height=`${u}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(c=>{for(let m of c)if(m.target!==t){n();return}let u=t.getBoundingClientRect().width;Math.abs(u-i)<.5||(i=u,n())}):null,r=()=>{for(let c of Array.from(t.children))o?.observe(c)},a=0,s=()=>{r(),n(),e.clearTimeout(a),a=e.setTimeout(n,340)},l=new e.MutationObserver(s);l.observe(t,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["data-placeholder","data-aia-empty"]}),o?.observe(t),r(),t.addEventListener("load",s,!0);let d=!1;return t.ownerDocument.fonts?.ready.then(()=>{d||n()}),n(),()=>{d=!0,t.removeEventListener("load",s,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(a),t.style.height=""}}var yl=6,xl=.3;function Dr(t){return t<=0?"0px":`${(-Math.min(xl,2*yl/t)).toFixed(3)}px`}var Nr=new Map;function Tl(t,e,n){let i=Nr.get(e);if(i!==void 0){t.style.setProperty("--aia-chip-image-fit",i),t.setAttribute("data-aia-image-loaded","");return}let o=n.createElement("img");o.setAttribute("referrerpolicy","no-referrer"),o.onload=()=>{if(!t.isConnected)return;t.setAttribute("data-aia-image-loaded","");let r=t.getBoundingClientRect().height,a=Number.parseFloat(getComputedStyle(t).fontSize);if(!(r>0&&a>0&&o.naturalWidth>0&&o.naturalHeight>0))return;let s=`${(r/a*(o.naturalWidth/o.naturalHeight)).toFixed(3)}em`;Nr.set(e,s),t.style.setProperty("--aia-chip-image-fit",s)},o.src=e}function yi(t){let{input:e,segments:n,newParamId:i,editingParamId:o,placeholderText:r,isFocused:a}=t,s=t.showChipIcons??!0,l=t.showChipImages??!0,d=n.length===0;e.dataset.aiaEmpty=d?"true":"false",Vo(e,d?r:"");let c=n.map(p=>p.type==="completed"?`${p.type}:${p.value}${s?p.param.icon??p.param.icon_svg??"":""}${l?fe(p.param.image_url)??"":""}`:`${p.type}:${p.value}`).join("\0"),u=e.dataset.segKey??"",m=e.dataset.newParamId??"",h=e.dataset.editingParamId??"";if(c===u&&(i??"")===m&&(o??"")===h)return;if(c===u){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let p of e.querySelectorAll("strong[data-param-id]")){let b=p.dataset.paramId,T=p.dataset.seg==="completed"&&b===i;p.classList.toggle("magicx-aia-shimmer-revealed",T),p.classList.toggle("magicx-aia-shimmer-sweep",T),p.classList.toggle("magicx-aia-segment--editing",b===o)}return}let g=a&&fn(e)?$(e):null;e.dataset.segKey=c,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let f=M(e),S=f.createDocumentFragment(),y=0;for(let p of n)if(y+=p.value.length,p.type==="completed"){let b=f.createElement("strong");b.dataset.seg="completed",b.dataset.paramId=p.param.id;let T=p.param.id===i,x=p.param.id===o,L=["magicx-aia-segment","magicx-aia-segment--completed"];T&&L.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),x&&L.push("magicx-aia-segment--editing"),b.className=L.join(" "),b.style.letterSpacing=Dr(p.value.length);let P=l?fe(p.param.image_url):null;if(P){let C=f.createElement("span");C.className="magicx-aia-segment-image",C.setAttribute("contenteditable","false"),C.setAttribute("aria-hidden","true"),C.style.setProperty("--aia-chip-image",`url("${P}")`),Tl(C,P,f),b.appendChild(C),b.dataset.aiaImage=""}let E=!P&&s&&p.param.icon_svg?ge(p.param.icon_svg):null;if(E){let C=f.createElement("span");C.className="magicx-aia-segment-icon",C.setAttribute("contenteditable","false"),C.setAttribute("aria-hidden","true"),C.innerHTML=E,b.appendChild(C),p.param.icon&&(b.dataset.aiaIcon=p.param.icon)}b.appendChild(f.createTextNode(p.value)),S.appendChild(b)}else if(p.type==="identified"){let b=f.createElement("strong");b.dataset.seg="identified",b.dataset.paramId=p.param.id;let T=["magicx-aia-segment","magicx-aia-segment--completed"];p.param.id===o&&T.push("magicx-aia-segment--editing"),b.className=T.join(" "),b.style.letterSpacing=Dr(p.value.length),b.textContent=p.value,S.appendChild(b)}else S.appendChild(f.createTextNode(p.value));e.replaceChildren(S),e.dataset.aiaTextLength=String(y),g!=null?H(e,Math.max(0,Math.min(g,y))):a&&fn(e)&&H(e,y)}var vl='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" role="img" aria-label="Submit"><path d="M9 14V4M9 4L4 9M9 4L14 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function Fr(t=O()){let e=document.createElement("button");return e.type="button",e.className="magicx-aia-submit",e.setAttribute("aria-label",t.submit),e.setAttribute("data-aia-submit",""),e.innerHTML=vl.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function El(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function Hr(t,e){let n=e.firstElementChild;if(!n){e.removeAttribute("data-aia-pill-wrapped");return}let i=n.getBoundingClientRect(),o=t.getBoundingClientRect();i.top>=o.bottom-2?e.setAttribute("data-aia-pill-wrapped",""):e.removeAttribute("data-aia-pill-wrapped")}function Wr(t,e){let{listboxId:n}=e,i=Gt(n);t.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-input-wrapper",o.setAttribute("data-aia-input-wrapper",""),t.appendChild(o);let r=document.createElement("div");r.className="magicx-aia-editor",r.setAttribute("data-aia-editor",""),o.appendChild(r);let a=document.createElement("div");a.className="magicx-aia-input",a.setAttribute("data-aia-input",""),a.setAttribute("contenteditable",El()?"plaintext-only":"true"),a.setAttribute("role","combobox"),a.setAttribute("aria-autocomplete","list"),a.setAttribute("aria-haspopup","listbox"),a.setAttribute("aria-controls",n),a.setAttribute("aria-expanded","false"),a.setAttribute("spellcheck","true"),a.setAttribute("enterkeyhint","send"),r.appendChild(a);let s=document.createElement("span");s.className="magicx-aia-pill-list-container",s.setAttribute("data-aia-pill-list-container",""),r.appendChild(s);let l=null,d=null;e.submitButton===void 0?(l=Fr(e.strings),o.appendChild(l),d=l):e.submitButton!==null&&(d=e.submitButton,d.hasAttribute("data-aia-submit")||d.setAttribute("data-aia-submit",""),d.setAttribute("data-aia-submit-slot",""),o.appendChild(d));let c=new AbortController,{signal:u}=c,m=!1,h=0,g=()=>{let p=pt(a),T=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;e.handleChange(T)},f=()=>{let p=ae(a)?.node??null;if(!p||!a.contains(p))return null;let x=(p.nodeType===Node.ELEMENT_NODE?p:p.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return x&&go(a,x)?null:x};if(o.addEventListener("click",p=>{p.target?.closest("[data-aia-pill]")||a.getRootNode().activeElement?.closest("[data-aia-location]")||a.focus()},{signal:u}),a.addEventListener("input",()=>{m||(h=performance.now(),g(),e.handleCaretAfterInput($(a)))},{signal:u}),M(a).addEventListener("selectionchange",()=>{let p=ae(a);if(!p||!a.contains(p.node))return;let b=p.collapsed?f():null,T=e.store.get(),x=T.editingParam?.id??T.editingIdentified?.id??null;if(b&&b!==x){e.startEditingParam(b);return}performance.now()-h<50||e.handleCaretMove($(a))},{signal:u}),a.addEventListener("click",p=>{let b=hn(a,p.target);b&&(e.startEditingParam(b),bn(a,b))},{signal:u}),a.addEventListener("compositionstart",()=>{m=!0,a.setAttribute("data-aia-composing","true")},{signal:u}),a.addEventListener("compositionend",()=>{m=!1,a.removeAttribute("data-aia-composing"),g()},{signal:u}),a.addEventListener("beforeinput",p=>{let b=p,T=b.inputType;if(T==="insertParagraph"||T==="insertLineBreak"||T==="insertFromDrop"){p.preventDefault();return}if(T.startsWith("insert")||T.startsWith("delete")){let x=T.startsWith("delete")?"":b.data??"";e.replaceEditingRange(x)&&p.preventDefault()}},{signal:u}),a.addEventListener("paste",p=>{p.preventDefault();let b=(p.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let T=M(a),x=ye(a);if(!x||!a.contains(x.startContainer))return;x.deleteContents();let L=T.createTextNode(b);x.insertNode(L),x.setStartAfter(L),Fe(a,x.startContainer,x.startOffset),g()},{signal:u}),a.addEventListener("keydown",p=>e.handleKeyDown(p),{signal:u}),a.addEventListener("focus",()=>e.store.set({isFocused:!0}),{signal:u}),a.addEventListener("blur",()=>e.store.set({isFocused:!1}),{signal:u}),d&&d.addEventListener("click",p=>{let b=e.store.get();if(!(!!b.text||b.completedParams.length>0)||!e.onSubmit)return;p.stopPropagation(),e.endTypedWord?.();let x=e.store.get();e.onSubmit(ue(x.text,x.completedParams,x.skippedParams,{identifiedParams:x.identifiedParams,isReady:x.isReady,customFields:x.customFields}))&&e.afterSubmit?.()},{signal:u}),e.autoFocus!==!1){a.focus();let p=ae(a);(!p||!a.contains(p.node))&&Fe(a,a,0)}if(typeof ResizeObserver<"u"){let p=new ResizeObserver(()=>Hr(a,s));p.observe(a),c.signal.addEventListener("abort",()=>p.disconnect(),{once:!0})}let y=Si(r);return c.signal.addEventListener("abort",y,{once:!0}),{input:a,inlinePillContainer:s,dropdown:i,submitButton:l,abort:c}}function xi(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:a}=t,{pillPlacement:s,setActivePill:l,selectOption:d,store:c}=n;i.setAttribute("aria-expanded",String(e.isDropdownOpen));let u=e.activeDropdownIndex>=0?`${n.listboxId}-option-${e.activeDropdownIndex}`:"";if(u?i.setAttribute("aria-activedescendant",u):i.removeAttribute("aria-activedescendant"),a){let y=n.strings??O();a.getAttribute("aria-label")!==y.submit&&a.setAttribute("aria-label",y.submit);let p=a.querySelector("svg");p&&p.getAttribute("aria-label")!==y.submit&&p.setAttribute("aria-label",y.submit);let b=!!e.text||e.completedParams.length>0;a.disabled=!b,a.toggleAttribute("data-aia-ready",b&&e.isReady)}let m=i.dataset.newParamId??"",h=e.newParamId!==null&&e.newParamId!==m;if(yi({input:i,segments:e.segments,newParamId:e.newParamId,editingParamId:e.editingParam?.id??null,placeholderText:e.placeholderText,isFocused:e.isFocused,showChipIcons:n.showChipIcons??!0,showChipImages:n.showChipImages??!0}),s==="inline"){let y=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,p=Jt(e.actionableSuggestions);y||p.length>0?Rt(o,p,0,l,!1,y,e.isActivePillSelected):Jn(o)}else Jn(o);Hr(i,o),h?(i.focus(),H(i,e.caretOffset??e.text.length)):e.isFocused&&pt(i)!==e.text&&H(i,e.text.length);let g=e.editingParam?{parameter:e.editingParam.suggestionParameter,text:e.editingParam.suggestionPlaceholder,required:!0,options:e.editingParam.options}:e.editingIdentified?{parameter:e.editingIdentified.parameter,text:J(e.editingIdentified.parameter),required:!0,options:[]}:null,f=e.dropdownSuggestion??g??e.actionableSuggestions[0],S=Be(e);$t(r,{strings:n.strings,suggestions:f?[{...f,options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:g?[g]:e.actionableSuggestions,showPills:s==="dropdown",showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:S.selectedIso,selectedDateRange:S.selectedRange,dateRangeStart:S.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,locationView:e.locationView,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:d,onHighlight:(y,p)=>{p!==void 0&&c.get().activeDropdownIndex!==p||c.set({activeDropdownIndex:y})},onPillClick:l,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,onProductSelect:n.selectProduct,onProductFocusChange:y=>c.set({isFocused:y})})}function Ti(t){let e=t,n=new Set,i=[],o=!1;return{get:()=>e,set:r=>{let a=typeof r=="function"?r(e):r,s=e;if(e={...e,...a},i.push([e,s]),!o){o=!0;try{let l=0;for(let d=i.shift();d;d=i.shift()){if(++l>1e4)throw i.length=0,new Error("createStore: notifications did not settle after 10000 deliveries \u2014 a listener is likely calling set() on every notification");let[c,u]=d;for(let m of n)m(c,u)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function Ur(t,e){let n,i,o=r=>(r!==n&&(n=r,i=e(r)),i);return{get:()=>{let r=t.get();return{...r,...o(r)}},set:r=>{typeof r=="function"?t.set(a=>{let s={...a,...o(a)};return r(s)}):t.set(r)},peek:r=>{let a={...t.get(),...r};return{...a,...e(a)}},subscribe:r=>t.subscribe((a,s)=>{let l={...s,...o(s)},d={...a,...o(a)};r(d,l)})}}var vi=new WeakSet,Br=new WeakMap;function Gr(t){return t.nodeType===Node.DOCUMENT_NODE}function wl(t){return Gr(t)?t:t.ownerDocument}function Pl(t){let e=Br.get(t);if(e)return e;let n=t.defaultView?.CSSStyleSheet;if(typeof n!="function")return null;try{let i=new n;return typeof i.replaceSync!="function"?null:(i.replaceSync(qr),Br.set(t,i),i)}catch{return null}}function Vr(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=qr,e.appendChild(n)}function $r(t){if(typeof document>"u")return;let e=t??document;if(vi.has(e))return;let n=wl(e);if(Gr(e)){let r=e.head??e.documentElement;if(!r)return;Vr(n,r),vi.add(e);return}let i=Pl(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):Vr(n,e),vi.add(e)}var qr=`.aia-stack {
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: var(--aia-stack-space, 0.5rem);
@@ -378,7 +378,10 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
378
378
  align-items: center;
379
379
  justify-content: center;
380
380
  padding: 0;
381
- transition: opacity 0.2s ease;
381
+ transition:
382
+ opacity 0.2s ease,
383
+ background-color 250ms ease,
384
+ transform 250ms ease;
382
385
  }
383
386
 
384
387
  /* Size and paint by class as well as by attribute. A presentation attribute
@@ -420,6 +423,21 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
420
423
  cursor: default;
421
424
  }
422
425
 
426
+ /* Ready: the request is complete, so the button lifts slightly and takes its
427
+ ready color (--aia-submit-bg-ready, defaulting to the normal one). The state
428
+ sits in :where() so a theme's own \`.x .magicx-aia-submit { background }\`
429
+ still wins. */
430
+ .magicx-aia-submit:where([data-aia-ready]:not(:disabled)) {
431
+ background: var(--aia-submit-bg-ready, var(--aia-submit-bg, var(--aia-color-text-default, #fff)));
432
+ transform: scale(1.08);
433
+ }
434
+
435
+ @media (prefers-reduced-motion: reduce) {
436
+ .magicx-aia-submit {
437
+ transition: none;
438
+ }
439
+ }
440
+
423
441
  /* --- Dropdown (glassmorphism \u2014 matches the React build) --- */
424
442
  .magicx-aia-dropdown {
425
443
  position: absolute;
@@ -1070,7 +1088,7 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
1070
1088
  A bare down chevron at the bottom-centre of the option list, shown while
1071
1089
  there is more to scroll to \u2014 no disc, border or shadow around it. It rests
1072
1090
  just above the grid's reserved band, or \u2014 when a product strip follows the
1073
- grid \u2014 centred on the strip's "Products" label row, off the last option row
1091
+ grid \u2014 centred on the strip's "Best match" label row, off the last option row
1074
1092
  (--aia-scroll-arrow-bottom is measured and set inline by the controller so
1075
1093
  it tracks the layout). It never travels with the scroll: the controller toggles
1076
1094
  data-aia-visible and the only thing that transitions is opacity \u2014 a slow,
@@ -1956,7 +1974,7 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
1956
1974
  position: relative;
1957
1975
  /* Clip, not visible: the entrance rise below runs on the inner content,
1958
1976
  and a transformed box extends its scroll container's scrollable area.
1959
- Unclipped, the rows rising 16px from below made the option grid overflow
1977
+ Unclipped, the rows rising 7px from below made the option grid overflow
1960
1978
  for the length of the entrance whenever nothing sat under the grid to
1961
1979
  absorb it (product strip, optionsPosition="above"), so a scrollbar
1962
1980
  flashed in and out and the columns shifted sideways by its width. The
@@ -1997,7 +2015,7 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
1997
2015
 
1998
2016
  @keyframes magicx-aia-optionRiseIn {
1999
2017
  from {
2000
- transform: translateY(16px);
2018
+ transform: translateY(7px);
2001
2019
  }
2002
2020
  }
2003
2021
 
@@ -2013,8 +2031,8 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
2013
2031
  (see the row's own comment). The durations and distance mirror
2014
2032
  OPTION_ENTER_* in derive/optionsEntrance.ts \u2014 change both together. */
2015
2033
  animation:
2016
- magicx-aia-optionRiseIn 280ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both,
2017
- magicx-aia-optionFadeIn 150ms ease-out both;
2034
+ magicx-aia-optionRiseIn 340ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
2035
+ magicx-aia-optionFadeIn 340ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
2018
2036
  animation-delay: var(--aia-option-enter-delay, 0ms);
2019
2037
  }
2020
2038
 
@@ -2030,12 +2048,33 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
2030
2048
  cursor: default;
2031
2049
  }
2032
2050
 
2033
- .magicx-aia-option--highlighted {
2051
+ .magicx-aia-option--highlighted,
2052
+ .magicx-aia-option--live-match {
2034
2053
  color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
2035
2054
  background: var(--aia-option-bg, transparent);
2036
2055
  font-weight: 500;
2037
2056
  }
2038
2057
 
2058
+ /* Live match: while a word is typed, the row it is spelling out lights up
2059
+ (the rule above) and every other row steps back, so the choice reads as
2060
+ locked in before the word is finished. The core marks the row
2061
+ (\`liveMatch\`). The step back is a filter on the inner content: on iOS a tap
2062
+ on a row whose own opacity is changing is dropped (lessons.md), and the
2063
+ content's entrance already owns its opacity. */
2064
+ .magicx-aia-option {
2065
+ transition: background-color 180ms ease;
2066
+ }
2067
+
2068
+ .magicx-aia-option-content {
2069
+ transition: filter 180ms ease;
2070
+ }
2071
+
2072
+ [role="listbox"]:has(.magicx-aia-option--live-match)
2073
+ .magicx-aia-option:not(.magicx-aia-option--live-match):not(.magicx-aia-option--highlighted)
2074
+ .magicx-aia-option-content {
2075
+ filter: opacity(0.42);
2076
+ }
2077
+
2039
2078
  /* Press feedback: the picked option's text compresses down while every other
2040
2079
  option steps back in opacity \u2014 no fill, no glow, the hierarchy carries it. */
2041
2080
  .magicx-aia-option--pressed {
@@ -2080,17 +2119,87 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
2080
2119
  mask-image: none;
2081
2120
  }
2082
2121
 
2083
- /* --- Promotion reveal ---
2084
- A newly promoted completed param is stamped with the shimmer-revealed /
2085
- shimmer-sweep classes by renderEditable. Now that completed params are pills
2086
- (with a solid background), the old text-clip gradient shimmer can't be used \u2014
2087
- \`background-clip: text\` would wipe out the pill background. The reveal is a
2088
- simple fade-in of the whole pill instead (matching how unfilled pills enter
2089
- via magicx-aia-fadeIn). shimmer-revealed carries no styling on its own; the
2090
- fade rides on shimmer-sweep so it only plays on genuine promotions, not on
2091
- every re-render of the pill. */
2122
+ /* Word \u2192 chip. A newly recognised param (renderEditable stamps shimmer-sweep
2123
+ on it) keeps its text in place while the chip forms around it: the fill and
2124
+ padding grow in over 300ms, and the picked option's icon or picture grows in
2125
+ front of the word \u2014 its width opening the room (so the words slide over),
2126
+ a small spring on its scale, a quick fade. The text itself never fades, so
2127
+ a typed word turns into a chip rather than vanishing and coming back. */
2092
2128
  :where(.magicx-aia-input) strong.magicx-aia-shimmer-sweep {
2093
- animation: magicx-aia-fadeIn 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
2129
+ animation: magicx-aia-ChipForm 300ms ease both;
2130
+ }
2131
+
2132
+ :where(.magicx-aia-input) strong.magicx-aia-shimmer-sweep span.magicx-aia-segment-icon {
2133
+ animation:
2134
+ magicx-aia-TileGrow 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
2135
+ magicx-aia-TileSpring 380ms cubic-bezier(0.3, 1.5, 0.5, 1) both,
2136
+ magicx-aia-TileFade 200ms ease both;
2137
+ }
2138
+
2139
+ /* The picture tile is an inline box (see its own rule), which can't scale, so
2140
+ it opens and fades without the spring. */
2141
+ :where(.magicx-aia-input) strong.magicx-aia-shimmer-sweep span.magicx-aia-segment-image {
2142
+ animation:
2143
+ magicx-aia-ImageGrow 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
2144
+ magicx-aia-TileFade 200ms ease both;
2145
+ }
2146
+
2147
+ @keyframes magicx-aia-ChipForm {
2148
+ from {
2149
+ background-color: transparent;
2150
+ padding-left: 0;
2151
+ padding-right: 0;
2152
+ }
2153
+ }
2154
+
2155
+ @keyframes magicx-aia-TileGrow {
2156
+ from {
2157
+ width: 0;
2158
+ margin-right: 0;
2159
+ }
2160
+ }
2161
+
2162
+ @keyframes magicx-aia-TileSpring {
2163
+ from {
2164
+ transform: scale(0.4);
2165
+ }
2166
+ }
2167
+
2168
+ /* A hair above zero, like the other fades \u2014 see magicx-aia-fadeIn. */
2169
+ @keyframes magicx-aia-TileFade {
2170
+ from {
2171
+ opacity: 0.01;
2172
+ }
2173
+ }
2174
+
2175
+ @keyframes magicx-aia-ImageGrow {
2176
+ from {
2177
+ padding-left: 0;
2178
+ margin-right: 0;
2179
+ }
2180
+ }
2181
+
2182
+ /* Reduced motion: a word becomes a chip at once. */
2183
+ @media (prefers-reduced-motion: reduce) {
2184
+ :where(.magicx-aia-input) strong.magicx-aia-shimmer-sweep,
2185
+ :where(.magicx-aia-input) strong.magicx-aia-shimmer-sweep span.magicx-aia-segment-icon,
2186
+ :where(.magicx-aia-input) strong.magicx-aia-shimmer-sweep span.magicx-aia-segment-image {
2187
+ animation: none;
2188
+ }
2189
+ }
2190
+
2191
+ /* --- Text box growth ---
2192
+ watchEditorHeight writes the editor's height on every change, so a new line
2193
+ opens over EDITOR_GROW_MS (340ms) instead of popping in. Reduced motion and
2194
+ \`animations: false\` drop the slide; the height still follows the text. */
2195
+ .magicx-aia-editor {
2196
+ transition: height 340ms cubic-bezier(0.2, 0.8, 0.2, 1);
2197
+ }
2198
+
2199
+ @media (prefers-reduced-motion: reduce) {
2200
+ .magicx-aia-editor {
2201
+ transition: none;
2202
+ }
2094
2203
  }
2095
2204
 
2096
2205
  /* --- Datepicker (replaces the options grid for date suggestions) ---
@@ -2171,6 +2280,27 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
2171
2280
  grid-template-columns: repeat(7, minmax(0, 1fr));
2172
2281
  }
2173
2282
 
2283
+ /* The weeks. A row is --aia-date-row-height tall whenever there is room, which
2284
+ keeps a month readable in a narrow dropdown without letting a 6-row month
2285
+ grow the panel past the options grid it replaces. In a panel fitted to a
2286
+ short window (data-aia-fit, see appearance.css) the calendar is the section
2287
+ that gives: the rows share what is left, down to --aia-date-row-min-height,
2288
+ so the whole month stays on screen with its bottom padding instead of the
2289
+ last week being sliced by the panel's edge. Only below that floor does the
2290
+ panel scroll. */
2291
+ .magicx-aia-datepicker-grid {
2292
+ flex: 1 1 auto;
2293
+ /* Without it the grid's automatic minimum is its full-height rows, and
2294
+ nothing squeezes. */
2295
+ min-height: 0;
2296
+ /* The floor never exceeds the chosen height, so a host that set a row
2297
+ shorter than the floor still gets exactly its own height. */
2298
+ grid-auto-rows: minmax(
2299
+ min(var(--aia-date-row-min-height, 20px), var(--aia-date-row-height, 28px)),
2300
+ var(--aia-date-row-height, 28px)
2301
+ );
2302
+ }
2303
+
2174
2304
  .magicx-aia-datepicker-weekday {
2175
2305
  padding: 2px 0;
2176
2306
  text-align: center;
@@ -2193,9 +2323,9 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
2193
2323
  items disagree, which makes it look like a column-count bug. The cell
2194
2324
  fills its track; the square is the number span inside it. */
2195
2325
  min-width: 0;
2196
- /* Keeps a month readable in a narrow dropdown without letting a 6-row month
2197
- grow the panel past the options grid it replaces. */
2198
- height: var(--aia-date-row-height, 28px);
2326
+ /* No height of its own: the cell fills its row, and the row's height is the
2327
+ grid's to give (see the weeks rule above), so a short window can squeeze
2328
+ the weeks instead of cutting the last one off. */
2199
2329
  font-family: inherit;
2200
2330
  font-size: var(--aia-date-cell-font-size, 13px);
2201
2331
  font-weight: 450;
@@ -2211,6 +2341,9 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
2211
2341
  justify-content: center;
2212
2342
  width: var(--aia-date-cell-size, 26px);
2213
2343
  height: var(--aia-date-cell-size, 26px);
2344
+ /* A squeezed row (see the weeks rule) is shorter than the square: it stays
2345
+ inside its own row rather than touching the week above and below. */
2346
+ max-height: 100%;
2214
2347
  border-radius: 6px;
2215
2348
  }
2216
2349
 
@@ -2403,6 +2536,136 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
2403
2536
  transition-duration: 0s;
2404
2537
  }
2405
2538
  }
2539
+ /* --- Location search ---
2540
+ Replaces the options grid for a location pill that came with no options:
2541
+ a search field over the server's location search, and the places it
2542
+ returned. Colours go through the same --aia-option-* chain as the options
2543
+ and the calendar. */
2544
+ .magicx-aia-location {
2545
+ display: flex;
2546
+ flex-direction: column;
2547
+ gap: 4px;
2548
+ padding: 6px 6px 4px;
2549
+ }
2550
+
2551
+ .magicx-aia-location-field {
2552
+ display: flex;
2553
+ align-items: center;
2554
+ gap: 8px;
2555
+ padding: 8px 10px;
2556
+ border-radius: var(--aia-location-field-radius, 10px);
2557
+ background: var(--aia-location-field-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06));
2558
+ color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
2559
+ cursor: text;
2560
+ }
2561
+
2562
+ .magicx-aia-location-icon {
2563
+ display: block;
2564
+ width: 15px;
2565
+ height: 15px;
2566
+ }
2567
+
2568
+ .magicx-aia-location-input {
2569
+ flex: 1;
2570
+ min-width: 0;
2571
+ padding: 0;
2572
+ border: 0;
2573
+ outline: 0;
2574
+ background: transparent;
2575
+ font: inherit;
2576
+ /* Never under 16px: iOS Safari zooms the page into a smaller field it focuses. */
2577
+ font-size: max(16px, var(--aia-location-font-size, 15px));
2578
+ color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
2579
+ }
2580
+
2581
+ .magicx-aia-location-input::placeholder {
2582
+ color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
2583
+ opacity: 0.7;
2584
+ }
2585
+
2586
+ .magicx-aia-location-results {
2587
+ display: flex;
2588
+ flex-direction: column;
2589
+ }
2590
+
2591
+ .magicx-aia-location-row {
2592
+ display: flex;
2593
+ align-items: center;
2594
+ gap: 10px;
2595
+ padding: 8px 10px;
2596
+ border-radius: 8px;
2597
+ color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
2598
+ cursor: pointer;
2599
+ }
2600
+
2601
+ .magicx-aia-location-row:hover,
2602
+ .magicx-aia-location-row--highlighted {
2603
+ background: var(
2604
+ --aia-location-row-bg-highlighted,
2605
+ rgba(var(--aia-streak-rgb, 255, 255, 255), 0.08)
2606
+ );
2607
+ }
2608
+
2609
+ .magicx-aia-location-pin {
2610
+ flex: 0 0 15px;
2611
+ }
2612
+
2613
+ .magicx-aia-location-text {
2614
+ display: flex;
2615
+ flex-direction: column;
2616
+ min-width: 0;
2617
+ }
2618
+
2619
+ .magicx-aia-location-name {
2620
+ overflow: hidden;
2621
+ font-size: var(--aia-location-font-size, 15px);
2622
+ color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
2623
+ text-overflow: ellipsis;
2624
+ white-space: nowrap;
2625
+ }
2626
+
2627
+ .magicx-aia-location-secondary {
2628
+ overflow: hidden;
2629
+ font-size: 13px;
2630
+ text-overflow: ellipsis;
2631
+ white-space: nowrap;
2632
+ }
2633
+
2634
+ .magicx-aia-location-note {
2635
+ display: flex;
2636
+ flex-direction: column;
2637
+ gap: 2px;
2638
+ padding: 8px 10px;
2639
+ font-size: 13px;
2640
+ color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
2641
+ }
2642
+
2643
+ .magicx-aia-location-empty {
2644
+ color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
2645
+ }
2646
+
2647
+ .magicx-aia-location-loading {
2648
+ display: flex;
2649
+ flex-direction: column;
2650
+ gap: 12px;
2651
+ padding: 10px;
2652
+ }
2653
+
2654
+ .magicx-aia-location-loading-bar {
2655
+ width: 70%;
2656
+ height: 12px;
2657
+ border-radius: 6px;
2658
+ background: var(--aia-skeleton-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.08));
2659
+ }
2660
+
2661
+ .magicx-aia-location-loading-bar:nth-child(2) {
2662
+ width: 50%;
2663
+ }
2664
+
2665
+ .magicx-aia-location-loading-bar:nth-child(3) {
2666
+ width: 60%;
2667
+ }
2668
+
2406
2669
  /* --- Loading skeleton fades ---
2407
2670
  Skeletons ease in and out over 100ms instead of popping. In: an option's
2408
2671
  text crossfades into its bar (the row element persists in React / Angular
@@ -3029,6 +3292,23 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
3029
3292
  overflow: visible;
3030
3293
  }
3031
3294
 
3295
+ /* A calendar is the exception to "sections keep their own height": a month
3296
+ cut off mid-week reads as broken, and nothing shows that the rest is a
3297
+ scroll away. So it gives instead: its weeks squeeze to share the space that
3298
+ is left (the datepicker's weeks rule, which sets the floor), and only below
3299
+ that floor does the stack scroll. */
3300
+ [data-aia-dropdown][data-aia-fit] [data-aia-datepicker] {
3301
+ flex-shrink: 1;
3302
+ min-height: 0;
3303
+ }
3304
+
3305
+ /* The footer goes while a calendar is fitted. Its keyboard hint and badge
3306
+ would take a week and a half of rows from a month that is already short of
3307
+ room, and the calendar's own bottom padding then closes the panel. */
3308
+ [data-aia-dropdown][data-aia-fit]:has([data-aia-datepicker]) [data-aia-footer] {
3309
+ display: none;
3310
+ }
3311
+
3032
3312
  [data-aia-dropdown][aria-multiselectable="true"] {
3033
3313
  --aia-grid-scroll-bottom: 0px;
3034
3314
  --aia-grid-overlap-bottom: 0px;
@@ -3037,5 +3317,24 @@ function M(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
3037
3317
  --aia-footer-fade-lead: 0px;
3038
3318
  --aia-footer-row-min-height: 0px;
3039
3319
  }
3040
- `;var Dt=class{constructor(){this.reported=new Set}run(e,n){try{return n()}catch(r){this.report(e,r,e);return}}runListener(e,n,r=e){try{return n(),!0}catch(i){return this.report(e,i,r),!1}}report(e,n,r){this.reported.has(r)||(this.reported.add(r),console.error(`[AIAutocomplete] "${e}" threw. The error is contained \u2014 SDK state is unaffected. Later failures of "${e}" on this instance are not logged.`,n))}};var Nt=class{constructor(e){this.boundary=e;this.listeners={};this.keys=new WeakMap;this.registrationCount=0}on(e,n){let r=`${String(e)}#${++this.registrationCount}`,i=(...s)=>n(...s);this.keys.set(i,r);let o=this.listeners[e];return o||(o=new Set,this.listeners[e]=o),o.add(i),()=>{this.listeners[e]?.delete(i)}}emit(e,...n){let r=this.listeners[e];if(!r)return!0;let i=!0;for(let o of r)this.boundary.runListener(String(e),()=>o(...n),this.keys.get(o)??String(e))||(i=!1);return i}hasListeners(e){return(this.listeners[e]?.size??0)>0}clear(){this.listeners={}}};var Ht=class{constructor(){this.timers=new Map}schedule(e,n,r){this.clear(e);let i=setTimeout(()=>{this.timers.delete(e),n()},r);this.timers.set(e,i)}clear(e){let n=this.timers.get(e);n!==void 0&&(clearTimeout(n),this.timers.delete(e))}clearAll(){for(let e of this.timers.values())clearTimeout(e);this.timers.clear()}};function Wa(t){let e;try{e=new URL(t??J).host}catch{return null}let n=He.get(e);return n?`https://${n}`:null}var xo=new WeakMap;function To(t,e){if(!t.head)return;let n=Wa(e);if(!n)return;let r=xo.get(t);r||(r=new Map,xo.set(t,r));let i=r.get(n);i||(i=t.createElement("link"),i.rel="preconnect",i.href=n,r.set(n,i)),t.head.append(i)}var _e=class{constructor(e,n="auto",r){this.container=e;this.mode=n;this.onResolve=r;this.mediaQuery=null;this.onSystemChange=e=>{this.setResolved(e.matches?"dark":"light")};this.apply()}setMode(e){this.detachListener(),this.mode=e,this.apply()}destroy(){this.detachListener()}apply(){this.mode==="auto"?(this.mediaQuery??(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)")),this.mediaQuery.addEventListener("change",this.onSystemChange),this.setResolved(this.mediaQuery.matches?"dark":"light")):this.setResolved(this.mode)}setResolved(e){this.container.dataset.mode=e,this.onResolve?.(e)}detachListener(){this.mediaQuery?.removeEventListener("change",this.onSystemChange)}};function lr(t){return t.isDropdownOpen&&!t.isLoading}var Ba=50,Va=new Set(["search_started","submit","product_click","impression"]),Ua="newParam",vo="suggestionRemoval",$a="selectionAnimation",cr="skeletonExit",Ga=650,qa=0;function Ka(){return`:ac-${++qa}:`}var Eo=170,za=100;function Po(){return{text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!1,isReady:!1,error:null,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null,multiSelectDraft:null,editingIdentified:null}}var dr=class{constructor(e,n={}){this.inputStore=sr(Po());this._listboxId=Ka();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new Ht;this.boundary=new Dt;this.subscriberCount=0;this.emitter=new Nt(this.boundary);this.sessionId=crypto.randomUUID();this.lastRequestId=null;this.searchStartedSessionId=null;this.funnelTelemetry=null;this.pendingSearchStarted=!1;this.openWordText=null;this.heldIdentified=null;this.lastImpressionKey="";this.visibleImpression=!1;this.destroyed=!1;this.emitSubmit=e=>(this.recordSubmit(e),this.emitter.emit("submit",e));this.emitError=e=>this.emitter.emit("error",e);this.container=e,this.opts=n,this.renderMode=n.renderMode??"full",this.store=go(this.inputStore,r=>di(r,this.opts)),n.onSubmit&&this.emitter.on("submit",n.onSubmit),n.onResult&&this.emitter.on("result",n.onResult),n.onError&&this.emitter.on("error",n.onError),n.onChange&&this.emitter.on("change",n.onChange),n.onParamsChange&&this.emitter.on("paramsChange",n.onParamsChange),n.onStateChange&&this.emitter.on("stateChange",n.onStateChange),n.onFocus&&this.emitter.on("focus",n.onFocus),n.onBlur&&this.emitter.on("blur",n.onBlur),n.onProductSelect&&this.emitter.on("productSelect",n.onProductSelect),n.value!==void 0&&this.store.set({text:n.value}),n.completedParams!==void 0&&this.store.set({completedParams:n.completedParams}),this.holdOpen=new je(this.store,e),this.pillsController=new pt(this.store,{onPillSelected:({rawQuery:r,selectedPill:i,otherPills:o})=>{this.fireTelemetry("pill",{raw_query:r,selected_pill:i,other_pills:o})}}),this.reEdit=new Tt({store:this.store,scheduleSetCursor:r=>this.scheduleSetCursor(r),fireTelemetry:(r,i)=>this.fireTelemetry(r,i),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new mt(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new ut(this.store,()=>this.opts.optionOverrides,{onAnswer:r=>{r==="edit"?this.reEdit.promoteIfExact():this.maybePromoteExactMatch(this.store.get().text)},onMiss:(r,i)=>{r==="pill"&&i.length>0&&this.fetchController.attemptNow()}}),this.fetchController=new ze(this.store,()=>this.opts.apiConfig,()=>this.opts.optionOverrides,()=>this.opts.maskCompletedText,()=>this.emitter.hasListeners("error")?this.emitError:void 0,()=>this.sessionId,()=>this.resolveSource(),()=>this.opts.additionalContext,()=>this.opts.language,{getProductId:()=>this.opts.productId,getCurrency:()=>this.opts.currency,onRequest:({query:r,signal:i,isCurrent:o})=>{To(this.container.ownerDocument,this.opts.apiConfig?.endpoint),this.productsController.run(r,i,o).catch(()=>{})},onAutoMatch:({active:r,matched:i,rawQuery:o})=>{let s=r.options??[];this.fireTelemetry("option",{raw_query:o,selected_option:i.text,other_options:s.filter(a=>a.text!==i.text).map(a=>a.text),key:r.parameter,position:te(s,i.text),chip_origin:"typed"})},onResponse:({requestId:r,funnelTelemetry:i,visibleImpression:o})=>{this.lastRequestId=r,this.funnelTelemetry=i,this.visibleImpression=o,this.pendingSearchStarted&&(this.pendingSearchStarted=!1,this.fireTelemetry("search_started",{})),this.fireImpression(),this.emitter.hasListeners("result")&&this.emitter.emit("result",this.buildResult())},productsForResponse:r=>this.productsController.forResponse(r),consumerTick:(r,i)=>this.optionSource.tick(r,i),isWordOpen:()=>this.isWordOpen(),holdIdentified:r=>{this.heldIdentified={text:this.store.get().text,candidates:r}}}),this.keyboardController=new dt(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",afterSubmit:this.renderMode==="full"?()=>this.resetAfterSubmit():void 0,selectOption:r=>this.selectOption(r),removeParamAtCaret:r=>this.removeParamAtCaret(r),startEditingParamAtCaret:r=>this.startEditingParamAtCaret(r),exitEditMode:()=>this.exitEditMode(),exitEditingIdentified:()=>this.exitEditingIdentified(),skipActivePill:()=>this.skipActivePill(),endTypedWord:r=>this.endTypedWord(r),stepTime:r=>this.stepTime(r),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()}),this.unsubscribers.push(this.store.subscribe((r,i)=>{r.text!==i.text&&this.emitter.emit("change",r.text),r.completedParams!==i.completedParams&&this.emitter.emit("paramsChange",r.completedParams),r.isFocused!==i.isFocused&&(r.isFocused?this.emitter.emit("focus"):this.emitter.emit("blur")),this.emitter.emit("stateChange",r)})),this.unsubscribers.push(this.store.subscribe(()=>this.maybeExitReEditOnNoMatch())),this.subscribeSkeletonMirror(),this.subscribeVisibleImpression(),this.unsubscribers.push(this.store.subscribe((r,i)=>{if(r.text===i.text&&r.completedParams===i.completedParams||r.identifiedParams.length===0)return;let{valid:o,invalid:s}=Ie(r.text,r.completedParams,r.identifiedParams);s.length>0&&this.store.set({identifiedParams:o})})),this.unsubscribers.push(this.store.subscribe((r,i)=>{if(r.identifiedParams===i.identifiedParams)return;let o=r.editingIdentified;if(!o||r.identifiedParams.some(l=>l.id===o.id))return;let s=0,a;for(let l of r.segments){if(l.type==="identified"&&s===o.anchor&&l.value===o.text){a=l.param;break}s+=l.value.length}if(a){this.store.set({editingIdentified:{...o,id:a.id}});return}this.store.set({editingIdentified:null,activeDropdownIndex:-1})})),this.unsubscribers.push(this.store.subscribe(r=>{let i=r.pendingRangeStart;!i||i.key===U(r)||this.store.set({pendingRangeStart:null})})),this.unsubscribers.push(this.store.subscribe(r=>{let i=r.multiSelectDraft;i&&i.key!==U(r)&&this.store.set({multiSelectDraft:null});let o=r.timeDraft;!o||o.key===U(r)||this.store.set({timeDraft:null})})),this.unsubscribers.push(this.store.subscribe((r,i)=>{let o=r.pendingSpan;if(!o||r.text===i.text&&r.completedParams===i.completedParams&&r.identifiedParams===i.identifiedParams)return;let s=o.anchor;if(r.text!==i.text){let l=Cr(i.text,r.text,s);if(l===null){this.store.set({pendingSpan:null});return}s=l}r.text.slice(s).trim().length===0||Pr(r.segments,s)?this.store.set({pendingSpan:null}):s!==o.anchor&&this.store.set({pendingSpan:{anchor:s,snapshot:o.snapshot}})})),this.renderMode!=="headless"&&(So(this.opts.styleRoot??se(this.container)),this.setupContainer()),this.renderMode==="full"?this.buildAndRenderFull():this.renderMode==="dropdown"&&this.buildAndRenderDropdown(),this.optionSource.start(),this.fetchController.start()}focus(){this.domRefs?.input.focus()}blur(){this.domRefs?.input.blur()}reset(){let{isFocused:e,dropdownHeld:n}=this.store.get();this.optionSource.reset(),this.store.set({...Po(),isFocused:e,dropdownHeld:n,skipNextFetch:!0}),this.sessionId=crypto.randomUUID(),this.lastRequestId=null,this.lastImpressionKey="",this.pendingSearchStarted=!1,this.fetchController.doFetch("",[])}resetAfterSubmit(){this.opts.resetOnSubmit!==!1&&this.reset()}destroy(){this.destroyed=!0,this.fetchController.dispose(),this.optionSource.dispose(),this.holdOpen.dispose(),this.modeController?.destroy(),this.timers.clearAll(),this.emitter.clear();for(let e of this.unsubscribers)e();this.unsubscribers=[],this.domRefs?.abort.abort(),this.domRefs&&(Ti(this.domRefs.input),nr(this.domRefs.dropdown)),this.dropdownRefs&&nr(this.dropdownRefs.dropdown),this.domRefs=null,this.dropdownRefs=null,this.renderMode!=="headless"&&(this.container.innerHTML="")}setMode(e){this.modeController?.setMode(e)}prefillText(e){this.applyTextChange(e,!1)}noteSearchStarted(){this.searchStartedSessionId!==this.sessionId&&(this.searchStartedSessionId=this.sessionId,this.funnelTelemetry===null?this.pendingSearchStarted=!0:this.fireTelemetry("search_started",{}))}setValue(e){let n=this.store.get();if(n.editingIdentified&&e!==n.text){this.store.set({text:e,editingIdentified:null,activeDropdownIndex:-1});return}this.store.set({text:e})}setCompletedParams(e){this.store.set({completedParams:e})}setActivePill(e){this.pillsController.setActivePill(e);let n=this.store.get().text.length;this.store.set({caretOffset:n,isFocused:!0}),this.scheduleSetCursor(n)}removeLastParam(){this.pillsController.removeLastParam()}findChipSpanAt(e){let n=0;for(let r of this.store.get().segments){let i=n;if(n+=r.value.length,r.type!=="text"&&e>i&&e<=n)return{kind:r.type,param:r.param,start:i,end:n}}return null}withoutChip(e,n){return n.kind==="completed"?{completedParams:e.completedParams.filter(r=>r.id!==n.param.id&&(!n.param.group||r.group!==n.param.group))}:{identifiedParams:e.identifiedParams.filter(r=>r.id!==n.param.id)}}removeParamAtCaret(e){let n=this.findChipSpanAt(e);if(!n)return!1;let{text:r}=this.store.get(),{start:i,end:o}=n;if(e===o){let{text:l,removed:d}=xt(r,i,o);return this.store.set(c=>({text:l,filterBase:Math.min(c.filterBase>i?Math.max(i,c.filterBase-d):c.filterBase,l.length),...this.withoutChip(c,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(i),!0}let s=sn(r,e),a=r.slice(0,s)+r.slice(e);return this.store.set(l=>({text:a,filterBase:Math.min(l.filterBase,a.length),...this.withoutChip(l,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(s),!0}startEditingParamAtCaret(e){let n=this.findChipSpanAt(e);return!n||n.kind!=="completed"||n.end!==e||this.store.get().completedParams.find(r=>r.id===n.param.id)?.group?!1:(this.reEdit.start(n.param.id),this.store.get().editingParam?.id===n.param.id)}scheduleSetCursor(e){queueMicrotask(()=>{let n=this.domRefs;if(n)n.input.focus(),F(n.input,e);else{let r=this.opts.setCursor;r&&this.boundary.runListener("setCursor",()=>r(e))}})}clearNewParamId(){this.store.set({newParamId:null})}startEditingIdentified(e){let n=this.store.get();if(n.editingIdentified?.id===e)return!0;let r=n.identifiedParams.find(d=>d.id===e);if(!r)return!1;let i=K(r);if(!M(i))return!1;let o=i==="date-range"?ft(r.text):null,s=0,a=-1;for(let d of n.segments){if(d.type!=="text"&&d.param.id===e){a=s;break}s+=d.value.length}if(a<0)return!1;let l=a+r.text.length;return this.store.set({editingIdentified:{id:e,parameter:r.parameter,anchor:a,tail:l,text:r.text,iso:o?o.start:yn(r),isoEnd:o?o.end:null,format:i},editingParam:null,editingAnchor:null,editingTail:null,caretOffset:l,activeDropdownIndex:-1,pillTapped:!0}),!0}exitEditingIdentified(){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1})}startEditingParam(e){this.store.get().completedParams.find(n=>n.id===e)?.group||(this.reEdit.start(e),this.store.get().editingParam?.id!==e&&this.startEditingIdentified(e))}replaceEditingRange(e){return this.reEdit.replaceRange(e)}exitEditMode(){this.reEdit.exit()}handleCaretAfterInput(e){this.reEdit.caretAfterInput(e)}handleCaretMove(e){let n=this.store.get().editingIdentified;n&&e!=null&&(e<n.anchor||e>n.tail)&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.reEdit.caretMove(e)}setActiveDropdownIndex(e){this.store.set({activeDropdownIndex:e})}clearHighlight(e){this.store.get().activeDropdownIndex===e&&this.store.set({activeDropdownIndex:-1})}prepareSubmit(){this.endTypedWord(!0)}recordSubmit(e){this.fireTelemetry("submit",{query:e.query,completed_pills:e.completed_params.filter(n=>n.placeholder).map(n=>({key:n.parameter,value:n.text??""}))})}selectProduct(e){let n=this.store.get(),r=n.products.findIndex(o=>o.id===e.id),i=n.customFields?.items?.matched?.find(o=>o.source_id===e.id)?.origin_id;this.fireTelemetry("product_click",{query:n.text,product_id:e.id,...i&&{origin_id:i},position:r>=0?r+1:null}),this.emitter.emit("productSelect",e)}addProductToCart(e){let n=this.opts.onProductAddToCart;if(!n)return Promise.resolve();try{return Promise.resolve(n(e)).then(()=>{})}catch(r){return Promise.reject(r)}}hasProductAddToCart(){return typeof this.opts.onProductAddToCart=="function"}handleTextChange(e){this.applyTextChange(e,!0)}applyTextChange(e,n){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.handleChange(e,n)}showPreviousMonth(){this.pageDateView(-1)}showNextMonth(){this.pageDateView(1)}pageDateView(e){let n=this.store.get();if(!M(n.activeFormatType)||!n.dateView)return;let r=Kt(n.dateView,e);this.store.set({dateViewMonth:{...r,key:U(n)},activeDropdownIndex:-1})}setTime(e){let n=this.store.get();n.activeFormatType!=="time"||!n.timeView||this.store.set({timeDraft:{minutes:ge(e),key:U(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(Yr(n.minutes,e))}toggleMultiSelectOption(e){let n=this.store.get();if(!n.multiSelectView||!e.is_tappable)return;let r=n.multiSelectView.picked;this.store.set({multiSelectDraft:{key:U(n),picked:r.includes(e.text)?r.filter(i=>i!==e.text):[...r,e.text]}})}commitMultiSelect(){this.finishMultiSelect()}finishMultiSelect(e=""){let n=this.store.get();if(!n.multiSelectView)return;let r=n.multiSelectView.picked;if(r.length===0){this.store.set({multiSelectDraft:null}),this.skipActivePill();return}let i=r.map(s=>n.actionableSuggestions[0].options?.find(a=>a.text===s)).filter(s=>s!==void 0);if(i.length===0)return;let o=r.length===1?r[0]:`${r.slice(0,-1).join(", ")} ${k(this.opts.language).and} ${r[r.length-1]}`;this.applyOption({text:o,is_tappable:!0,kind:null},i,e),n.text||this.noteSearchStarted()}commitTime(){let e=this.store.get();e.activeFormatType!=="time"||!e.timeView||(this.selectOption(mn(e.timeView.minutes)),this.store.get().completedParams!==e.completedParams&&this.store.set({timeDraft:null}))}skipActivePill(){let e=this.store.get();if(e.editingParam||e.inSelectionAnimation)return;let n=e.suggestions.filter(a=>a.parameter==="placeholder"),r=e.suggestions.filter(a=>a.parameter!=="placeholder");if(r.length===0||P(r[0]))return;let i=r[0],o=r.slice(1),s=e.skippedParams.some(a=>a.parameter===i.parameter);this.store.set({suggestions:[...n,...o],pillTapped:o.length>0,activeDropdownIndex:-1,...s?{}:{skippedParams:[...e.skippedParams,{id:crypto.randomUUID(),parameter:i.parameter,suggestionPlaceholder:i.text}]}}),o.length===0&&this.fetchNow()}handleKeyDown(e){this.keyboardController.handleKeyDown(e)}setFocused(e){this.store.get().isFocused!==e&&this.store.set({isFocused:e})}subscribe(e){let n=`subscribe#${++this.subscriberCount}`;return this.store.subscribe(r=>{this.boundary.runListener("subscribe",()=>e(r),n)})}getState(){return this.store.get()}getResult(){return this.buildResult()}getRequestId(){return this.lastRequestId}buildResult(){let e=this.store.get();return ae(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields})}get listboxId(){return this._listboxId}get isReady(){return this.store.get().isReady}on(e,n){return this.emitter.on(e,n)}refreshProducts(){this.opts.mapProducts&&this.productsController.refresh()}update(e){let n=this.opts.products,r=this.opts.mapProducts,i=this.opts.showProducts,o=this.opts.optionOverrides;Object.assign(this.opts,e),"language"in e&&this.updateLanguageAttribute(),"optionOverrides"in e&&e.optionOverrides!==o&&this.optionSource.refresh(),"products"in e&&e.products!==n||"showProducts"in e&&e.showProducts!==i?this.productsController.resync():"mapProducts"in e&&e.mapProducts!==r&&this.productsController.refresh(),e.mode!==void 0&&this.modeController?.setMode(e.mode),e.optionsPosition!==void 0&&(this.container.dataset.optionsPosition=e.optionsPosition),e.animations!==void 0&&(this.container.dataset.animations=e.animations?"on":"off"),e.pillPlacement!==void 0&&(this.container.dataset.pillPlacement=e.pillPlacement,this.store.set({})),(e.dropdownTrigger!==void 0||e.closeDropdownOnBlur!==void 0||e.showNonTappableOptions!==void 0||e.showSkipButton!==void 0||e.showOptionIcons!==void 0||e.showOptionImages!==void 0||e.showOptionCounts!==void 0||e.productsLayout!==void 0||e.productImageFallback!==void 0||e.showChipIcons!==void 0||e.showChipImages!==void 0||"language"in e)&&this.store.set({}),e.value!==void 0&&this.setValue(e.value),e.completedParams!==void 0&&this.store.set({completedParams:e.completedParams})}selectOption(e){if(this.store.get().multiSelectView){this.toggleMultiSelectOption(e);return}let n=!this.store.get().text;this.applyOption(e),n&&this.store.get().text&&this.noteSearchStarted()}applyOption(e,n,r=""){let i=this.store.get();if(i.activeFormatType==="date-range"){let s=Y(e);if(s){let a=i.dateRangeStart;if(!a){this.store.set({pendingRangeStart:{iso:s,key:U(i)}});return}this.store.set({pendingRangeStart:null}),this.selectOption(si(a,s));return}}if(i.editingIdentified){this.commitIdentifiedDate(e);return}if(i.editingParam&&i.editingAnchor!=null&&i.editingTail!=null){this.timers.clear(cr),this.reEdit.selectOption(e);return}let o=hi(i,e);if(o){if(n){let s=o.patch.completedParams?.[i.completedParams.length];if(!s||!o.patch.text)return;let a=crypto.randomUUID(),l=o.patch.text,d=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),c=n.map(u=>{let m=l.toLowerCase().indexOf(u.text.toLowerCase(),d);return d=m+u.text.length,{...s,value:u.value,kind:u.kind,metadata:u.metadata,icon:u.icon,icon_svg:u.icon_svg,image_url:u.image_url,id:crypto.randomUUID(),group:a,parameter:o.consumedSuggestion.parameter,text:l.slice(m,d)}});o.patch.completedParams=[...i.completedParams,...c],o.patch.newParamId=c[0].id,o.patch.multiSelectDraft=null,o.patch.text+=r,o.patch.caretOffset=o.patch.text.length,o.patch.suggestions=i.suggestions.filter(u=>u!==o.consumedSuggestion)}for(let s of n??[e])this.fireTelemetry("option",{raw_query:N(i.text,i.completedParams).rawQuery,selected_option:s.text,other_options:_(i.activeFormatType)?[]:i.filteredOptions.filter(a=>a.text!==s.text).map(a=>a.text),key:o.telemetry.key,position:_(i.activeFormatType)?null:te(o.consumedSuggestion.options??[],s.text),chip_origin:"tap"});if(this.timers.clear(cr),this.store.set({...o.patch,...yt(i)}),this.startSelectionAnimationTimer(),this.timers.clear(vo),o.remainingActionable>0){let s=o.consumedSuggestion;this.timers.schedule(vo,()=>{this.store.get().suggestions.includes(s)&&this.store.set(a=>({suggestions:a.suggestions.filter(l=>l!==s)}))},Eo)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule($a,()=>this.store.set({inSelectionAnimation:!1}),Eo)}resolveVisitorId(){let e=this.opts.visitorId;if(typeof e!="function")return e;try{return e()}catch{return}}resolveSource(){return this.opts.source??(this.renderMode==="full"?"full-sdk":"headless-sdk")}subscribeVisibleImpression(){this.unsubscribers.push(this.store.subscribe((e,n)=>{this.visibleImpression&&(!e.isDropdownOpen&&n.isDropdownOpen&&(this.lastImpressionKey=""),lr(e)&&!lr(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!lr(e))return;let n=e.suggestions.filter(o=>o.parameter!=="placeholder"&&!P(o)).map(o=>({key:o.parameter,options:(o.options??[]).slice(0,Ba).map(s=>s.text)})),r=e.products.map(o=>o.id);if(n.length===0&&r.length===0)return;let i=JSON.stringify([n,r]);i!==this.lastImpressionKey&&(this.lastImpressionKey=i,this.fireTelemetry("impression",{query:e.text,pills:n,product_ids:r}))}fireTelemetry(e,n){let r=this.funnelTelemetry===!0;if(!r&&Va.has(e))return;if(!r&&e==="option"){let{key:o,position:s,chip_origin:a,...l}=n;n=l}let i=this.resolveSource();fi({source:i,sessionId:this.sessionId,visitorId:r?this.resolveVisitorId():void 0,requestId:r?this.lastRequestId:null,keepalive:r,type:e,language:ie(this.opts.language),queryData:n,apiConfig:this.opts.apiConfig})}updateLanguageAttribute(){let{language:e}=k(this.opts.language);e!=="en"?this.container.dataset.aiaLanguage=e:delete this.container.dataset.aiaLanguage}setupContainer(){this.container.classList.add("magicx-aia"),this.updateLanguageAttribute(),this.container.dataset.pillPlacement=this.renderMode==="dropdown"?"dropdown":this.opts.pillPlacement??"dropdown",this.container.dataset.optionsPosition=this.opts.optionsPosition??"below",this.container.dataset.animations=this.opts.animations??!0?"on":"off",this.modeController=new _e(this.container,this.opts.mode??"auto")}buildAndRenderFull(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return k(e.opts.language)},get pillPlacement(){return e.opts.pillPlacement??"dropdown"},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?i=>e.addProductToCart(i):void 0},get showChipIcons(){return e.opts.showChipIcons??!0},get showChipImages(){return e.opts.showChipImages??!0},get optionsPosition(){return e.opts.optionsPosition??"below"},get onSubmit(){return e.emitter.hasListeners("submit")?e.emitSubmit:void 0},afterSubmit:()=>e.resetAfterSubmit(),endTypedWord:()=>e.endTypedWord(!0),submitButton:this.opts.submitButton,autoFocus:this.opts.autoFocus??!0,selectOption:i=>this.selectOption(i),setActivePill:i=>this.pillsController.setActivePill(i),skipActivePill:()=>this.skipActivePill(),selectProduct:i=>this.selectProduct(i),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:i=>this.setTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),handleKeyDown:i=>this.keyboardController.handleKeyDown(i),handleChange:i=>this.handleChange(i,!0),startEditingParam:i=>this.startEditingParam(i),handleCaretAfterInput:i=>this.handleCaretAfterInput(i),handleCaretMove:i=>this.handleCaretMove(i),replaceEditingRange:i=>this.replaceEditingRange(i)};this.domRefs=mo(this.container,n);let r=()=>{this.domRefs&&or(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(r),this.subscribeViewportBreakpoint(r),or(this.domRefs,this.store.get(),n),this.subscribeNewParamTimer()}buildAndRenderDropdown(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return k(e.opts.language)},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?i=>e.addProductToCart(i):void 0},get optionsPosition(){return e.opts.optionsPosition??"below"},selectOption:i=>this.selectOption(i),setActivePill:i=>this.pillsController.setActivePill(i),skipActivePill:()=>this.skipActivePill(),selectProduct:i=>this.selectProduct(i),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:i=>this.setTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()};this.dropdownRefs=ao(this.container,n);let r=()=>{this.dropdownRefs&&rr(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(r),this.subscribeViewportBreakpoint(r),rr(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(ht),r=()=>e();n.addEventListener("change",r),this.unsubscribers.push(()=>n.removeEventListener("change",r))}subscribeBatchedRender(e){let n=!1;this.unsubscribers.push(this.store.subscribe(()=>{n||(n=!0,queueMicrotask(()=>{n=!1,e()}))}))}subscribeSkeletonMirror(){this.unsubscribers.push(this.store.subscribe((e,n)=>{if(!e.skeletonOptions)return;if(!n.isLoading&&e.isLoading){e.skeletonRequested||this.store.set({skeletonRequested:!0});return}if(!n.isLoading||e.isLoading)return;let r={skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1};if(!e.skeletonExiting){this.store.set(r);return}this.timers.schedule(cr,()=>this.store.set(r),za)}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(Ua,()=>this.store.set({newParamId:null}),Ga)}))}handleChange(e,n){let r=this.store.get();n&&e&&!r.text&&this.noteSearchStarted(),this.store.set({text:e,pillTapped:!1,activeDropdownIndex:-1});let{valid:i,invalid:o}=Or(e,r.completedParams);o.length>0&&this.store.set({completedParams:i});let s=this.heldIdentified;this.heldIdentified=null,this.openWordText=n&&/\S$/.test(e)?e:null,this.maybePromoteExactMatch(e),s&&/^\s+$/.test(e.slice(s.text.length))&&e.startsWith(s.text)&&this.admitIdentified(s.candidates),this.maybeOpenPendingSpan();let a=this.store.get();a.multiSelectView&&a.optionQuery&&a.filteredOptions.length===0&&this.finishMultiSelect(a.optionQuery)}isWordOpen(){return this.opts.commitOnWordEnd===!0&&this.openWordText===this.store.get().text}admitIdentified(e){let n=this.store.get(),{valid:r}=Ie(n.text,n.completedParams,e);r.length!==0&&this.store.set({identifiedParams:[...n.identifiedParams,...r]})}endTypedWord(e=!1){let n=this.isWordOpen();if(!n&&!e)return!1;let r=this.heldIdentified;this.heldIdentified=null,this.openWordText=null;let i=this.store.get();this.maybePromoteExactMatch(i.text,e?"submit":"fresh",n),r?.text===i.text&&this.admitIdentified(r.candidates);let o=this.store.get();return o.completedParams!==i.completedParams||o.identifiedParams!==i.identifiedParams}maybeOpenPendingSpan(){let e=this.store.get();if(e.pendingSpan||e.actionableSuggestions.length===0)return;let n=Z(e.text,Math.min(e.filterBase,e.text.length),e.placeholderText),r=Er(e.segments,n);e.text.slice(r).trim().length!==0&&this.store.set({pendingSpan:{anchor:r,snapshot:e.actionableSuggestions}})}maybeExitReEditOnNoMatch(){let e=this.store.get();if(!e.editingParam||e.editingAnchor==null||e.completedParams.some(o=>o.id===e.editingParam?.id)||this.optionSource.owns(e.editingParam.suggestionParameter,e.optionQuery))return;let n=e.caretOffset??e.editingAnchor,r=e.text.slice(e.editingAnchor,n);oe(e.editingParam.options,r).some(o=>o.is_tappable)||(this.reEdit.exit(),this.fetchNow())}fetchNow(){let e=this.store.get(),{rawQuery:n,completedParams:r}=N(e.text,e.completedParams);this.fetchController.doFetch(n,r)}commitIdentifiedDate(e){let n=this.store.get(),r=n.editingIdentified;if(!r)return;if(n.text.slice(r.anchor,r.tail)!==r.text){this.store.set({editingIdentified:null,activeDropdownIndex:-1});return}let i=n.text.slice(0,r.anchor),o=n.text.slice(r.tail),s=r.anchor===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,l=o.length===0||o[0]!==" "?`${s} `:s,d=i+l+o,c=d.length,u={id:crypto.randomUUID(),placeholder:"",parameter:r.parameter,text:s,value:e.value,kind:e.kind,suggestionParameter:r.parameter,suggestionPlaceholder:j(r.parameter),options:[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url};this.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:[],key:r.parameter,position:null,chip_origin:"tap"}),this.store.set({text:d,completedParams:[...n.completedParams,u],identifiedParams:n.identifiedParams.filter(m=>m.id!==r.id),newParamId:u.id,filterBase:c,caretOffset:c,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(c),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",r=!1){let i=this.store.get();if(_(i.activeFormatType)||this.isWordOpen())return;let o=bt({mode:n,finishWord:r,text:e,completedParams:i.completedParams,suggestions:i.suggestions,filterBase:i.filterBase,filterInProgress:i.filterInProgress,phraseExactMatch:this.fetchController.isPhraseExactMatch()});if(o){if(this.funnelTelemetry===!0){let s=n==="submit"&&o.suggestion?o.suggestion:i.actionableSuggestions[0],a=s.options??[];this.fireTelemetry("option",{raw_query:N(e,i.completedParams).rawQuery,selected_option:o.option.text,other_options:a.filter(l=>l.text!==o.option.text).map(l=>l.text),key:s.parameter,position:te(a,o.option.text),chip_origin:"typed"})}this.store.set(o.patch)}}};export{dr as AIAutocomplete,vi as ATTRIBUTION_URL,vn as DATE_RANGE_META_END,Tn as DATE_RANGE_META_START,Gi as DEFAULT_OPTION_COUNT_UNIT,_e as ModeController,ht as OPTIONS_GRID_MOBILE_QUERY,jn as OPTION_ENTER_DELAY_VAR,qs as OPTION_ENTER_FADE_MS,Ks as OPTION_ENTER_RISE_MS,zs as OPTION_ENTER_RISE_PX,Gs as OPTION_ENTER_STAGGER_MS,Un as OPTION_IMAGE_WIDTH,vs as PLACEHOLDER_FADE_OUT_MS,he as PLACEHOLDER_LEAVING_ATTR,Es as PLACEHOLDER_SWAP_GAP_MS,xs as PLACEHOLDER_TYPE_MS,Ts as PLACEHOLDER_WORD_PAUSE_MS,Ns as PRODUCT_IMAGE_WIDTH,Zr as PRODUCT_PATH_PREFIX,Ds as PRODUCT_ROW_PX_PER_LINE,ii as RANGE_SEPARATOR,hr as SCHEMA_VERSION,to as SCROLL_ARROW_ATTR,io as SCROLL_ARROW_BOTTOM_VAR,eo as SCROLL_ARROW_CLASS,no as SCROLL_ARROW_FADE_MS,ma as SCROLL_ARROW_LABEL,ro as SCROLL_ARROW_SCROLL_IDLE_MS,Se as SCROLL_ARROW_VISIBLE_ATTR,mr as SKIPPED_PARAM_TEXT,Vt as SMART_SUGGESTION_SPARKLE_SVG,zr as TIME_META_KEY,ln as TIME_STEP_MINUTES,st as TIME_WHEEL_COLUMNS,ot as TIME_WHEEL_ROW_HEIGHT,ye as VIEWPORT_FIT_ATTR,kt as VIEWPORT_FIT_HEIGHT_VAR,Ye as WEEKDAY_LABELS,Kt as addMonths,Bn as attachProductRowWheel,er as attachScrollArrow,tr as attachViewportFit,Rn as buildAttributionUrl,zt as buildDateOptions,N as buildQuery,ae as buildSubmitResult,mn as buildTimeOption,Yt as cellDay,Y as cellIso,nn as chipIdFromTap,ai as computeOptionsGridLayout,Nn as containScroll,sr as createStore,on as cursorIsAtEnd,Fn as dateCellMarks,Me as dateSelectionFor,nt as extractPlainText,pe as formatAbsoluteDate,Hr as formatDate,oi as formatDateRange,Re as formatOptionCount,it as formatTime,V as getCursorOffset,Dn as getFooterHint,Ut as hasSkippablePill,Ln as highlightParts,j as identifiedParamLabel,M as isCalendarFormat,An as isOptionsGridMobileViewport,_ as isPickerFormat,qe as isSmartSuggestion,P as isTraditionalAutocompleteSuggestion,B as isoDate,jr as isoTime,rn as keepCaretOnChip,Bt as labelTraditionalAutocomplete,St as matchTypedPhrase,In as measureOptionsGrid,Gt as monthLabel,wn as needsOptionsGridMeasurement,ea as optionCountLabel,Yn as optionEnterDelayMs,qi as optionHasImage,At as optionImageSources,ce as optionImageSrc,Ct as optionLabel,Qn as optionsEntranceDurationMs,Pn as optionsGridTemplateColumns,Xn as optionsShowLeadingVisuals,Qe as parseDate,Oe as parseLooseDate,ft as parseLooseDateRange,an as parseTime,en as plainTextLength,Cn as planOptionsGrid,sn as previousGraphemeBoundary,ei as productFromMatchedItem,Pt as productImageSources,Fs as productImageSrc,Vn as productInitial,Gn as productPhotoFill,_i as productRowWheelTarget,Sn as productsFromCustomFields,ir as renderEditableContent,K as resolveFormatType,yn as resolveIdentifiedDate,On as sameOptionRows,le as sanitizeOptionIconSvg,Xt as scrollCaretIntoView,jt as selectedIsoFromText,Le as selectedRangeFor,F as setCursorOffset,Hi as shopifyImageSrc,at as timeWheelIndex,hn as timeWheelIndexFromScroll,fn as timeWheelRows,ve as toWireIdentifiedParams,pi as typedFragment,k as uiStringsFor,Hn as visibleDateRange,Ee as withSkippedParams,lt as withTimeWheelIndex,Wt as withoutTraditionalAutocomplete};
3320
+
3321
+ /* A multi-select shows three rows and scrolls the rest, in every layout (one
3322
+ column, two columns, phone), so its Done button always sits right under
3323
+ the third row. The planned cap (--aia-grid-max-height) still wins when it
3324
+ is smaller: fewer than three rows of options. */
3325
+ [data-aia-dropdown][aria-multiselectable="true"] .aia-grid[data-scroll] {
3326
+ max-height: min(var(--aia-grid-max-height, 120px), calc(3 * var(--aia-option-row-height, 37px)));
3327
+ }
3328
+
3329
+ /* Fitted to the viewport, every other grid hands its scrolling to the panel,
3330
+ which would carry Done off screen with the rows. A multi-select keeps its
3331
+ own three-row scroll box, and gives up rows before the panel has to scroll,
3332
+ so Done stays in view. */
3333
+ [data-aia-dropdown][data-aia-fit][aria-multiselectable="true"] .aia-grid[data-scroll] {
3334
+ flex-shrink: 1;
3335
+ min-height: var(--aia-option-row-height, 37px);
3336
+ max-height: min(var(--aia-grid-max-height, 120px), calc(3 * var(--aia-option-row-height, 37px)));
3337
+ overflow-y: auto;
3338
+ }
3339
+ `;var qt=class{constructor(){this.reported=new Set}run(e,n){try{return n()}catch(i){this.report(e,i,e);return}}runListener(e,n,i=e){try{return n(),!0}catch(o){return this.report(e,o,i),!1}}report(e,n,i){this.reported.has(i)||(this.reported.add(i),console.error(`[AIAutocomplete] "${e}" threw. The error is contained \u2014 SDK state is unaffected. Later failures of "${e}" on this instance are not logged.`,n))}};var Kt=class{constructor(e){this.boundary=e;this.listeners={};this.keys=new WeakMap;this.registrationCount=0}on(e,n){let i=`${String(e)}#${++this.registrationCount}`,o=(...a)=>n(...a);this.keys.set(o,i);let r=this.listeners[e];return r||(r=new Set,this.listeners[e]=r),r.add(o),()=>{this.listeners[e]?.delete(o)}}emit(e,...n){let i=this.listeners[e];if(!i)return!0;let o=!0;for(let r of i)this.boundary.runListener(String(e),()=>r(...n),this.keys.get(r)??String(e))||(o=!1);return o}hasListeners(e){return(this.listeners[e]?.size??0)>0}clear(){this.listeners={}}};var zt=class{constructor(){this.timers=new Map}schedule(e,n,i){this.clear(e);let o=setTimeout(()=>{this.timers.delete(e),n()},i);this.timers.set(e,o)}clear(e){let n=this.timers.get(e);n!==void 0&&(clearTimeout(n),this.timers.delete(e))}clearAll(){for(let e of this.timers.values())clearTimeout(e);this.timers.clear()}};function Cl(t){let e;try{e=new URL(t??K).host}catch{return null}let n=ze.get(e);return n?`https://${n}`:null}var Kr=new WeakMap;function zr(t,e){if(!t.head)return;let n=Cl(e);if(!n)return;let i=Kr.get(t);i||(i=new Map,Kr.set(t,i));let o=i.get(n);o||(o=t.createElement("link"),o.rel="preconnect",o.href=n,i.set(n,o)),t.head.append(o)}var Ge=class{constructor(e,n="auto",i){this.container=e;this.mode=n;this.onResolve=i;this.mediaQuery=null;this.onSystemChange=e=>{this.setResolved(e.matches?"dark":"light")};this.apply()}setMode(e){this.detachListener(),this.mode=e,this.apply()}destroy(){this.detachListener()}apply(){this.mode==="auto"?(this.mediaQuery??(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)")),this.mediaQuery.addEventListener("change",this.onSystemChange),this.setResolved(this.mediaQuery.matches?"dark":"light")):this.setResolved(this.mode)}setResolved(e){this.container.dataset.mode=e,this.onResolve?.(e)}detachListener(){this.mediaQuery?.removeEventListener("change",this.onSystemChange)}};function Ei(t){return t.isDropdownOpen&&!t.isLoading}var Ll=50,Il=new Set(["search_started","submit","product_click","impression"]),Ol="newParam",jr="suggestionRemoval",Al="selectionAnimation",wi="skeletonExit",Yr="locationSearch",kl=650,Ml=0;function Rl(){return`:ac-${++Ml}:`}var Qr=170,_l=100;function Xr(){return{text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,locationAutocomplete:!0,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!1,isReady:!1,error:null,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null,multiSelectDraft:null,locationSearch:null,locationFieldFocused:!1,editingIdentified:null}}var Pi=class{constructor(e,n={}){this.inputStore=Ti(Xr());this._listboxId=Rl();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new zt;this.boundary=new qt;this.subscriberCount=0;this.emitter=new Kt(this.boundary);this.sessionId=crypto.randomUUID();this.lastRequestId=null;this.searchStartedSessionId=null;this.funnelTelemetry=null;this.pendingSearchStarted=!1;this.openWordText=null;this.heldIdentified=null;this.lastImpressionKey="";this.visibleImpression=!1;this.destroyed=!1;this.locationAbort=null;this.locationSession=null;this.emitSubmit=e=>(this.recordSubmit(e),this.emitter.emit("submit",e));this.emitError=e=>this.emitter.emit("error",e);this.container=e,this.opts=n,this.renderMode=n.renderMode??"full",this.store=Ur(this.inputStore,i=>Mo(i,this.opts)),n.onSubmit&&this.emitter.on("submit",n.onSubmit),n.onResult&&this.emitter.on("result",n.onResult),n.onError&&this.emitter.on("error",n.onError),n.onChange&&this.emitter.on("change",n.onChange),n.onParamsChange&&this.emitter.on("paramsChange",n.onParamsChange),n.onStateChange&&this.emitter.on("stateChange",n.onStateChange),n.onFocus&&this.emitter.on("focus",n.onFocus),n.onBlur&&this.emitter.on("blur",n.onBlur),n.onProductSelect&&this.emitter.on("productSelect",n.onProductSelect),n.value!==void 0&&this.store.set({text:n.value}),n.completedParams!==void 0&&this.store.set({completedParams:n.completedParams}),this.holdOpen=new ot(this.store,e),this.pillsController=new vt(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new kt({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new Et(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new Tt(this.store,()=>this.opts.optionOverrides,{onAnswer:i=>{i==="edit"?this.reEdit.promoteIfExact():this.maybePromoteExactMatch(this.store.get().text)},onMiss:(i,o)=>{i==="pill"&&o.length>0&&this.fetchController.attemptNow()}}),this.fetchController=new it(this.store,()=>this.opts.apiConfig,()=>this.opts.optionOverrides,()=>this.opts.maskCompletedText,()=>this.emitter.hasListeners("error")?this.emitError:void 0,()=>this.sessionId,()=>this.resolveSource(),()=>this.opts.additionalContext,()=>this.opts.language,{getProductId:()=>this.opts.productId,getCurrency:()=>this.opts.currency,onRequest:({query:i,signal:o,isCurrent:r})=>{zr(this.container.ownerDocument,this.opts.apiConfig?.endpoint),this.productsController.run(i,o,r).catch(()=>{})},onAutoMatch:({active:i,matched:o,rawQuery:r})=>{let a=i.options??[];this.fireTelemetry("option",{raw_query:r,selected_option:o.text,other_options:a.filter(s=>s.text!==o.text).map(s=>s.text),key:i.parameter,position:se(a,o.text),chip_origin:"typed"})},onResponse:({requestId:i,funnelTelemetry:o,visibleImpression:r})=>{this.lastRequestId=i,this.funnelTelemetry=o,this.visibleImpression=r,this.pendingSearchStarted&&(this.pendingSearchStarted=!1,this.fireTelemetry("search_started",{})),this.fireImpression(),this.emitter.hasListeners("result")&&this.emitter.emit("result",this.buildResult())},productsForResponse:i=>this.productsController.forResponse(i),consumerTick:(i,o)=>this.optionSource.tick(i,o),isWordOpen:()=>this.isWordOpen(),holdIdentified:i=>{this.heldIdentified={text:this.store.get().text,candidates:i}}}),this.keyboardController=new xt(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",afterSubmit:this.renderMode==="full"?()=>this.resetAfterSubmit():void 0,selectOption:i=>this.selectOption(i),removeParamAtCaret:i=>this.removeParamAtCaret(i),startEditingParamAtCaret:i=>this.startEditingParamAtCaret(i),exitEditMode:()=>this.exitEditMode(),exitEditingIdentified:()=>this.exitEditingIdentified(),skipActivePill:()=>this.skipActivePill(),endTypedWord:i=>this.endTypedWord(i),stepTime:i=>this.stepTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()}),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text!==o.text&&this.emitter.emit("change",i.text),i.completedParams!==o.completedParams&&this.emitter.emit("paramsChange",i.completedParams);let r=i.isFocused||i.locationFieldFocused;r!==(o.isFocused||o.locationFieldFocused)&&(r?this.emitter.emit("focus"):this.emitter.emit("blur")),this.emitter.emit("stateChange",i)})),this.unsubscribers.push(this.store.subscribe(()=>this.maybeExitReEditOnNoMatch())),this.unsubscribers.push(this.store.subscribe(()=>{let i=this.store.get();i.locationFieldFocused&&!i.locationView&&this.store.set({locationFieldFocused:!1})})),this.subscribeSkeletonMirror(),this.subscribeVisibleImpression(),this.unsubscribers.push(this.store.subscribe((i,o)=>{if(i.text===o.text&&i.completedParams===o.completedParams||i.identifiedParams.length===0)return;let{valid:r,invalid:a}=De(i.text,i.completedParams,i.identifiedParams);a.length>0&&this.store.set({identifiedParams:r})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{if(i.identifiedParams===o.identifiedParams)return;let r=i.editingIdentified;if(!r||i.identifiedParams.some(l=>l.id===r.id))return;let a=0,s;for(let l of i.segments){if(l.type==="identified"&&a===r.anchor&&l.value===r.text){s=l.param;break}a+=l.value.length}if(s){this.store.set({editingIdentified:{...r,id:s.id}});return}this.store.set({editingIdentified:null,activeDropdownIndex:-1})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.pendingRangeStart;!o||o.key===W(i)||this.store.set({pendingRangeStart:null})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.multiSelectDraft;o&&o.key!==W(i)&&this.store.set({multiSelectDraft:null});let r=i.timeDraft;!r||r.key===W(i)||this.store.set({timeDraft:null})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{let r=i.pendingSpan;if(!r||i.text===o.text&&i.completedParams===o.completedParams&&i.identifiedParams===o.identifiedParams)return;let a=r.anchor;if(i.text!==o.text){let l=ji(o.text,i.text,a);if(l===null){this.store.set({pendingSpan:null});return}a=l}i.text.slice(a).trim().length===0||Ki(i.segments,a)?this.store.set({pendingSpan:null}):a!==r.anchor&&this.store.set({pendingSpan:{anchor:a,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&($r(this.opts.styleRoot??re(this.container)),this.setupContainer()),this.renderMode==="full"?this.buildAndRenderFull():this.renderMode==="dropdown"&&this.buildAndRenderDropdown(),this.optionSource.start(),this.fetchController.start()}focus(){this.domRefs?.input.focus()}blur(){this.domRefs?.input.blur()}reset(){let{isFocused:e,dropdownHeld:n}=this.store.get();this.optionSource.reset(),this.store.set({...Xr(),isFocused:e,dropdownHeld:n,skipNextFetch:!0}),this.sessionId=crypto.randomUUID(),this.lastRequestId=null,this.lastImpressionKey="",this.pendingSearchStarted=!1,this.fetchController.doFetch("",[])}resetAfterSubmit(){this.opts.resetOnSubmit!==!1&&this.reset()}destroy(){this.destroyed=!0,this.fetchController.dispose(),this.optionSource.dispose(),this.holdOpen.dispose(),this.cancelLocationSearch(),this.modeController?.destroy(),this.timers.clearAll(),this.emitter.clear();for(let e of this.unsubscribers)e();this.unsubscribers=[],this.domRefs?.abort.abort(),this.domRefs&&(Go(this.domRefs.input),hi(this.domRefs.dropdown)),this.dropdownRefs&&hi(this.dropdownRefs.dropdown),this.domRefs=null,this.dropdownRefs=null,this.renderMode!=="headless"&&(this.container.innerHTML="")}setMode(e){this.modeController?.setMode(e)}prefillText(e){this.applyTextChange(e,!1)}noteSearchStarted(){this.searchStartedSessionId!==this.sessionId&&(this.searchStartedSessionId=this.sessionId,this.funnelTelemetry===null?this.pendingSearchStarted=!0:this.fireTelemetry("search_started",{}))}setValue(e){let n=this.store.get();if(n.editingIdentified&&e!==n.text){this.store.set({text:e,editingIdentified:null,activeDropdownIndex:-1});return}this.store.set({text:e})}setCompletedParams(e){this.store.set({completedParams:e})}setActivePill(e){this.pillsController.setActivePill(e);let n=this.store.get().text.length;this.store.set({caretOffset:n,isFocused:!0}),this.scheduleSetCursor(n)}removeLastParam(){this.pillsController.removeLastParam()}findChipSpanAt(e){let n=0;for(let i of this.store.get().segments){let o=n;if(n+=i.value.length,i.type!=="text"&&e>o&&e<=n)return{kind:i.type,param:i.param,start:o,end:n}}return null}withoutChip(e,n){return n.kind==="completed"?{completedParams:e.completedParams.filter(i=>i.id!==n.param.id&&(!n.param.group||i.group!==n.param.group))}:{identifiedParams:e.identifiedParams.filter(i=>i.id!==n.param.id)}}removeParamAtCaret(e){let n=this.findChipSpanAt(e);if(!n)return!1;let{text:i}=this.store.get(),{start:o,end:r}=n;if(e===r){let{text:l,removed:d}=At(i,o,r);return this.store.set(c=>({text:l,filterBase:Math.min(c.filterBase>o?Math.max(o,c.filterBase-d):c.filterBase,l.length),...this.withoutChip(c,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(o),!0}let a=yn(i,e),s=i.slice(0,a)+i.slice(e);return this.store.set(l=>({text:s,filterBase:Math.min(l.filterBase,s.length),...this.withoutChip(l,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(a),!0}startEditingParamAtCaret(e){let n=this.findChipSpanAt(e);return!n||n.kind!=="completed"||n.end!==e||this.store.get().completedParams.find(i=>i.id===n.param.id)?.group?!1:(this.reEdit.start(n.param.id),this.store.get().editingParam?.id===n.param.id)}scheduleSetCursor(e){queueMicrotask(()=>{let n=this.domRefs;if(n)n.input.focus(),H(n.input,e);else{let i=this.opts.setCursor;i&&this.boundary.runListener("setCursor",()=>i(e))}})}clearNewParamId(){this.store.set({newParamId:null})}startEditingIdentified(e){let n=this.store.get();if(n.editingIdentified?.id===e)return!0;let i=n.identifiedParams.find(d=>d.id===e);if(!i)return!1;let o=Q(i);if(!k(o))return!1;let r=o==="date-range"?Pt(i.text):null,a=0,s=-1;for(let d of n.segments){if(d.type!=="text"&&d.param.id===e){s=a;break}a+=d.value.length}if(s<0)return!1;let l=s+i.text.length;return this.store.set({editingIdentified:{id:e,parameter:i.parameter,anchor:s,tail:l,text:i.text,iso:r?r.start:Mn(i),isoEnd:r?r.end:null,format:o},editingParam:null,editingAnchor:null,editingTail:null,caretOffset:l,activeDropdownIndex:-1,pillTapped:!0}),!0}exitEditingIdentified(){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1})}startEditingParam(e){this.store.get().completedParams.find(n=>n.id===e)?.group||(this.reEdit.start(e),this.store.get().editingParam?.id!==e&&this.startEditingIdentified(e))}replaceEditingRange(e){return this.reEdit.replaceRange(e)}exitEditMode(){this.reEdit.exit()}handleCaretAfterInput(e){this.reEdit.caretAfterInput(e)}handleCaretMove(e){let n=this.store.get().editingIdentified;n&&e!=null&&(e<n.anchor||e>n.tail)&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.reEdit.caretMove(e)}setActiveDropdownIndex(e){this.store.set({activeDropdownIndex:e})}clearHighlight(e){this.store.get().activeDropdownIndex===e&&this.store.set({activeDropdownIndex:-1})}prepareSubmit(){this.endTypedWord(!0)}recordSubmit(e){this.fireTelemetry("submit",{query:e.query,completed_pills:e.completed_params.filter(n=>n.placeholder).map(n=>({key:n.parameter,value:n.text??""}))})}selectProduct(e){let n=this.store.get(),i=n.products.findIndex(r=>r.id===e.id),o=n.customFields?.items?.matched?.find(r=>r.source_id===e.id)?.origin_id;this.fireTelemetry("product_click",{query:n.text,product_id:e.id,...o&&{origin_id:o},position:i>=0?i+1:null}),this.emitter.emit("productSelect",e)}addProductToCart(e){let n=this.opts.onProductAddToCart;if(!n)return Promise.resolve();try{return Promise.resolve(n(e)).then(()=>{})}catch(i){return Promise.reject(i)}}hasProductAddToCart(){return typeof this.opts.onProductAddToCart=="function"}handleTextChange(e){this.applyTextChange(e,!0)}applyTextChange(e,n){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.handleChange(e,n)}showPreviousMonth(){this.pageDateView(-1)}showNextMonth(){this.pageDateView(1)}pageDateView(e){let n=this.store.get();if(!k(n.activeFormatType)||!n.dateView)return;let i=an(n.dateView,e);this.store.set({dateViewMonth:{...i,key:W(n)},activeDropdownIndex:-1})}setTime(e){let n=this.store.get();n.activeFormatType!=="time"||!n.timeView||this.store.set({timeDraft:{minutes:Te(e),key:W(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(bo(n.minutes,e))}toggleMultiSelectOption(e){let n=this.store.get();if(!n.multiSelectView||!e.is_tappable)return;let i=n.multiSelectView.picked;this.store.set({multiSelectDraft:{key:W(n),picked:i.includes(e.text)?i.filter(o=>o!==e.text):[...i,e.text]}})}commitMultiSelect(){this.finishMultiSelect()}answerMultiSelectWith(e){let n=this.store.get().multiSelectView;!n||!e.is_tappable||(n.picked.includes(e.text)||this.toggleMultiSelectOption(e),this.finishMultiSelect())}finishMultiSelect(e=""){let n=this.store.get();if(!n.multiSelectView)return;let i=n.multiSelectView.picked;if(i.length===0){this.store.set({multiSelectDraft:null}),this.skipActivePill();return}let o=i.map(a=>n.actionableSuggestions[0].options?.find(s=>s.text===a)).filter(a=>a!==void 0);if(o.length===0)return;let r=i.length===1?i[0]:`${i.slice(0,-1).join(", ")} ${O(this.opts.language).and} ${i[i.length-1]}`;this.applyOption({text:r,is_tappable:!0,kind:null},o,e),n.text||this.noteSearchStarted()}commitTime(){let e=this.store.get();e.activeFormatType!=="time"||!e.timeView||(this.selectOption(Cn(e.timeView.minutes)),this.store.get().completedParams!==e.completedParams&&this.store.set({timeDraft:null}))}setLocationQuery(e){let n=this.store.get(),i=n.locationView;if(n.activeFormatType!=="location"||!i)return;let o=W(n);this.cancelLocationSearch();let a=n.locationAutocomplete&&this.opts.locationSearch!==!1?Xt(this.opts.apiConfig):null,s="loading";a?e.trim().length<Yt&&(s="idle"):s="unavailable",this.store.set({locationSearch:{key:o,query:e,places:s==="loading"?i.places:[],status:s,highlighted:-1}}),!(s!=="loading"||!a)&&this.timers.schedule(Yr,()=>{this.runLocationSearch(o,e,a)},Oi)}moveLocationHighlight(e){let n=this.store.get().locationSearch,i=this.store.get().locationView;if(!n||!i||i.places.length===0||i.status==="loading")return;let o=i.places.length,r=i.highlighted<0?e>0?-1:0:i.highlighted;this.store.set({locationSearch:{...n,highlighted:((r+e)%o+o)%o}})}commitLocation(e){let n=this.store.get(),i=n.locationView;if(n.activeFormatType!=="location"||!i)return;let o=e??i.highlighted,r=o>=0?i.places[o]:void 0,a=i.query.trim();!r&&!a||(this.cancelLocationSearch(),this.locationSession=null,this.selectOption(Qt(r??a)),this.store.get().completedParams!==n.completedParams&&this.store.set({locationSearch:null}))}async runLocationSearch(e,n,i){let o=new AbortController;this.locationAbort=o,this.locationSession?.key!==e&&(this.locationSession={key:e,token:crypto.randomUUID()});let r;try{r={places:await Hi(i,n.trim(),{apiConfig:this.opts.apiConfig,sessionToken:this.locationSession.token,language:this.opts.language,signal:o.signal}),status:"done"}}catch(s){let l=s instanceof ke&&s.status===404;l&&this.store.set({locationAutocomplete:!1}),r={places:[],status:l?"unavailable":"error"}}if(this.destroyed||o.signal.aborted||this.locationAbort!==o)return;this.locationAbort=null;let a=this.store.get().locationSearch;!a||a.key!==e||a.query!==n||this.store.set({locationSearch:{...a,...r,highlighted:r.places.length>0?0:-1}})}cancelLocationSearch(){this.timers.clear(Yr),this.locationAbort?.abort(),this.locationAbort=null}skipActivePill(){let e=this.store.get();if(e.editingParam||e.inSelectionAnimation)return;let n=e.suggestions.filter(s=>s.parameter==="placeholder"),i=e.suggestions.filter(s=>s.parameter!=="placeholder");if(i.length===0||w(i[0]))return;let o=i[0],r=i.slice(1),a=e.skippedParams.some(s=>s.parameter===o.parameter);this.store.set({suggestions:[...n,...r],pillTapped:r.length>0,activeDropdownIndex:-1,...a?{}:{skippedParams:[...e.skippedParams,{id:crypto.randomUUID(),parameter:o.parameter,suggestionPlaceholder:o.text}]}}),r.length===0&&this.fetchNow()}handleKeyDown(e){this.keyboardController.handleKeyDown(e)}setFocused(e){this.store.get().isFocused!==e&&this.store.set({isFocused:e})}setLocationFieldFocused(e){this.store.get().locationFieldFocused!==e&&this.store.set({locationFieldFocused:e})}subscribe(e){let n=`subscribe#${++this.subscriberCount}`;return this.store.subscribe(i=>{this.boundary.runListener("subscribe",()=>e(i),n)})}getState(){return this.store.get()}getResult(){return this.buildResult()}getRequestId(){return this.lastRequestId}buildResult(){let e=this.store.get();return ue(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields})}get listboxId(){return this._listboxId}get isReady(){return this.store.get().isReady}on(e,n){return this.emitter.on(e,n)}refreshProducts(){this.opts.mapProducts&&this.productsController.refresh()}update(e){let n=this.opts.products,i=this.opts.mapProducts,o=this.opts.showProducts,r=this.opts.optionOverrides;Object.assign(this.opts,e),"language"in e&&this.updateLanguageAttribute(),"optionOverrides"in e&&e.optionOverrides!==r&&this.optionSource.refresh(),"products"in e&&e.products!==n||"showProducts"in e&&e.showProducts!==o?this.productsController.resync():"mapProducts"in e&&e.mapProducts!==i&&this.productsController.refresh(),e.mode!==void 0&&this.modeController?.setMode(e.mode),e.optionsPosition!==void 0&&(this.container.dataset.optionsPosition=e.optionsPosition),e.animations!==void 0&&(this.container.dataset.animations=e.animations?"on":"off"),e.pillPlacement!==void 0&&(this.container.dataset.pillPlacement=e.pillPlacement,this.store.set({})),(e.dropdownTrigger!==void 0||e.closeDropdownOnBlur!==void 0||e.showNonTappableOptions!==void 0||e.showSkipButton!==void 0||e.showOptionIcons!==void 0||e.showOptionImages!==void 0||e.showOptionCounts!==void 0||e.productsLayout!==void 0||e.productImageFallback!==void 0||e.showChipIcons!==void 0||e.showChipImages!==void 0||"language"in e)&&this.store.set({}),e.value!==void 0&&this.setValue(e.value),e.completedParams!==void 0&&this.store.set({completedParams:e.completedParams})}selectOption(e,n){if(this.store.get().multiSelectView){n?.commit?this.answerMultiSelectWith(e):this.toggleMultiSelectOption(e);return}let o=!this.store.get().text;this.applyOption(e),o&&this.store.get().text&&this.noteSearchStarted()}applyOption(e,n,i=""){let o=this.store.get();if(o.activeFormatType==="date-range"){let a=Z(e);if(a){let s=o.dateRangeStart;if(!s){this.store.set({pendingRangeStart:{iso:a,key:W(o)}});return}this.store.set({pendingRangeStart:null}),this.selectOption(Io(s,a));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(wi),this.reEdit.selectOption(e);return}let r=Ho(o,e);if(r){if(n){let a=r.patch.completedParams?.[o.completedParams.length];if(!a||!r.patch.text)return;let s=crypto.randomUUID(),l=r.patch.text,d=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),c=n.map(u=>{let m=l.toLowerCase().indexOf(u.text.toLowerCase(),d);return d=m+u.text.length,{...a,value:u.value,kind:u.kind,metadata:u.metadata,icon:u.icon,icon_svg:u.icon_svg,image_url:u.image_url,id:crypto.randomUUID(),group:s,parameter:r.consumedSuggestion.parameter,text:l.slice(m,d)}});r.patch.completedParams=[...o.completedParams,...c],r.patch.newParamId=c[0].id,r.patch.multiSelectDraft=null,r.patch.text+=i,r.patch.caretOffset=r.patch.text.length,r.patch.suggestions=o.suggestions.filter(u=>u!==r.consumedSuggestion)}for(let a of n??[e])this.fireTelemetry("option",{raw_query:F(o.text,o.completedParams).rawQuery,selected_option:a.text,other_options:D(o.activeFormatType)?[]:o.filteredOptions.filter(s=>s.text!==a.text).map(s=>s.text),key:r.telemetry.key,position:D(o.activeFormatType)?null:se(r.consumedSuggestion.options??[],a.text),chip_origin:"tap"});if(this.timers.clear(wi),this.store.set({...r.patch,...Ot(o)}),this.startSelectionAnimationTimer(),this.timers.clear(jr),r.remainingActionable>0){let a=r.consumedSuggestion;this.timers.schedule(jr,()=>{this.store.get().suggestions.includes(a)&&this.store.set(s=>({suggestions:s.suggestions.filter(l=>l!==a)}))},Qr)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(Al,()=>this.store.set({inSelectionAnimation:!1}),Qr)}resolveVisitorId(){let e=this.opts.visitorId;if(typeof e!="function")return e;try{return e()}catch{return}}resolveSource(){return this.opts.source??(this.renderMode==="full"?"full-sdk":"headless-sdk")}subscribeVisibleImpression(){this.unsubscribers.push(this.store.subscribe((e,n)=>{this.visibleImpression&&(!e.isDropdownOpen&&n.isDropdownOpen&&(this.lastImpressionKey=""),Ei(e)&&!Ei(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!Ei(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!w(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,Ll).map(a=>a.text)})),i=e.products.map(r=>r.id);if(n.length===0&&i.length===0)return;let o=JSON.stringify([n,i]);o!==this.lastImpressionKey&&(this.lastImpressionKey=o,this.fireTelemetry("impression",{query:e.text,pills:n,product_ids:i}))}fireTelemetry(e,n){let i=this.funnelTelemetry===!0;if(!i&&Il.has(e))return;if(!i&&e==="option"){let{key:r,position:a,chip_origin:s,...l}=n;n=l}let o=this.resolveSource();Fo({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:ie(this.opts.language),queryData:n,apiConfig:this.opts.apiConfig})}updateLanguageAttribute(){let{language:e}=O(this.opts.language);e!=="en"?this.container.dataset.aiaLanguage=e:delete this.container.dataset.aiaLanguage}setupContainer(){this.container.classList.add("magicx-aia"),this.updateLanguageAttribute(),this.container.dataset.pillPlacement=this.renderMode==="dropdown"?"dropdown":this.opts.pillPlacement??"dropdown",this.container.dataset.optionsPosition=this.opts.optionsPosition??"below",this.container.dataset.animations=this.opts.animations??!0?"on":"off",this.modeController=new Ge(this.container,this.opts.mode??"auto")}buildAndRenderFull(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return O(e.opts.language)},get pillPlacement(){return e.opts.pillPlacement??"dropdown"},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get showChipIcons(){return e.opts.showChipIcons??!0},get showChipImages(){return e.opts.showChipImages??!0},get optionsPosition(){return e.opts.optionsPosition??"below"},get onSubmit(){return e.emitter.hasListeners("submit")?e.emitSubmit:void 0},afterSubmit:()=>e.resetAfterSubmit(),endTypedWord:()=>e.endTypedWord(!0),submitButton:this.opts.submitButton,autoFocus:this.opts.autoFocus??!0,selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o),handleKeyDown:o=>this.keyboardController.handleKeyDown(o),handleChange:o=>this.handleChange(o,!0),startEditingParam:o=>this.startEditingParam(o),handleCaretAfterInput:o=>this.handleCaretAfterInput(o),handleCaretMove:o=>this.handleCaretMove(o),replaceEditingRange:o=>this.replaceEditingRange(o)};this.domRefs=Wr(this.container,n);let i=()=>{this.domRefs&&xi(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),xi(this.domRefs,this.store.get(),n),this.subscribeNewParamTimer()}buildAndRenderDropdown(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return O(e.opts.language)},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get optionsPosition(){return e.opts.optionsPosition??"below"},selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o)};this.dropdownRefs=_r(this.container,n);let i=()=>{this.dropdownRefs&&bi(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),bi(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(Ct),i=()=>e();n.addEventListener("change",i),this.unsubscribers.push(()=>n.removeEventListener("change",i))}subscribeBatchedRender(e){let n=!1;this.unsubscribers.push(this.store.subscribe(()=>{n||(n=!0,queueMicrotask(()=>{n=!1,e()}))}))}subscribeSkeletonMirror(){this.unsubscribers.push(this.store.subscribe((e,n)=>{if(!e.skeletonOptions)return;if(!n.isLoading&&e.isLoading){e.skeletonRequested||this.store.set({skeletonRequested:!0});return}if(!n.isLoading||e.isLoading)return;let i={skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1};if(!e.skeletonExiting){this.store.set(i);return}this.timers.schedule(wi,()=>this.store.set(i),_l)}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(Ol,()=>this.store.set({newParamId:null}),kl)}))}handleChange(e,n){let i=this.store.get();n&&e&&!i.text&&this.noteSearchStarted(),this.store.set({text:e,pillTapped:!1,activeDropdownIndex:-1});let{valid:o,invalid:r}=Xi(e,i.completedParams);r.length>0&&this.store.set({completedParams:o});let a=this.heldIdentified;this.heldIdentified=null,this.openWordText=n&&/\S$/.test(e)?e:null,this.maybePromoteExactMatch(e),a&&/^\s+$/.test(e.slice(a.text.length))&&e.startsWith(a.text)&&this.admitIdentified(a.candidates),this.maybeOpenPendingSpan();let s=this.store.get();s.multiSelectView&&s.optionQuery&&s.filteredOptions.length===0&&this.finishMultiSelect(s.optionQuery)}isWordOpen(){return this.opts.commitOnWordEnd===!0&&this.openWordText===this.store.get().text}admitIdentified(e){let n=this.store.get(),{valid:i}=De(n.text,n.completedParams,e);i.length!==0&&this.store.set({identifiedParams:[...n.identifiedParams,...i]})}endTypedWord(e=!1){let n=this.isWordOpen();if(!n&&!e)return!1;let i=this.heldIdentified;this.heldIdentified=null,this.openWordText=null;let o=this.store.get();this.maybePromoteExactMatch(o.text,e?"submit":"fresh",n),i?.text===o.text&&this.admitIdentified(i.candidates);let r=this.store.get();return r.completedParams!==o.completedParams||r.identifiedParams!==o.identifiedParams}maybeOpenPendingSpan(){let e=this.store.get();if(e.pendingSpan||e.actionableSuggestions.length===0)return;let n=oe(e.text,Math.min(e.filterBase,e.text.length),e.placeholderText),i=qi(e.segments,n);e.text.slice(i).trim().length!==0&&this.store.set({pendingSpan:{anchor:i,snapshot:e.actionableSuggestions}})}maybeExitReEditOnNoMatch(){let e=this.store.get();if(!e.editingParam||e.editingAnchor==null||e.completedParams.some(r=>r.id===e.editingParam?.id)||this.optionSource.owns(e.editingParam.suggestionParameter,e.optionQuery))return;let n=e.caretOffset??e.editingAnchor,i=e.text.slice(e.editingAnchor,n);ce(e.editingParam.options,i).some(r=>r.is_tappable)||(this.reEdit.exit(),this.fetchNow())}fetchNow(){let e=this.store.get(),{rawQuery:n,completedParams:i}=F(e.text,e.completedParams);this.fetchController.doFetch(n,i)}commitIdentifiedDate(e){let n=this.store.get(),i=n.editingIdentified;if(!i)return;if(n.text.slice(i.anchor,i.tail)!==i.text){this.store.set({editingIdentified:null,activeDropdownIndex:-1});return}let o=n.text.slice(0,i.anchor),r=n.text.slice(i.tail),a=i.anchor===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,l=r.length===0||r[0]!==" "?`${a} `:a,d=o+l+r,c=d.length,u={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:a,value:e.value,kind:e.kind,suggestionParameter:i.parameter,suggestionPlaceholder:J(i.parameter),options:[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url};this.fireTelemetry("option",{raw_query:F(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:[],key:i.parameter,position:null,chip_origin:"tap"}),this.store.set({text:d,completedParams:[...n.completedParams,u],identifiedParams:n.identifiedParams.filter(m=>m.id!==i.id),newParamId:u.id,filterBase:c,caretOffset:c,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(c),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(D(o.activeFormatType)||this.isWordOpen())return;let r=Lt({mode:n,finishWord:i,text:e,completedParams:o.completedParams,suggestions:o.suggestions,filterBase:o.filterBase,filterInProgress:o.filterInProgress,phraseExactMatch:this.fetchController.isPhraseExactMatch()});if(r){if(this.funnelTelemetry===!0){let a=n==="submit"&&r.suggestion?r.suggestion:o.actionableSuggestions[0],s=a.options??[];this.fireTelemetry("option",{raw_query:F(e,o.completedParams).rawQuery,selected_option:r.option.text,other_options:s.filter(l=>l.text!==r.option.text).map(l=>l.text),key:a.parameter,position:se(s,r.option.text),chip_origin:"typed"})}this.store.set(r.patch)}}};export{Pi as AIAutocomplete,$o as ATTRIBUTION_URL,Dn as DATE_RANGE_META_END,_n as DATE_RANGE_META_START,br as DEFAULT_OPTION_COUNT_UNIT,Sl as EDITOR_GROW_MS,Ii as LOCATION_META_KEY,Yt as LOCATION_MIN_QUERY,Rs as MULTI_SELECT_TOGGLE_MIN_PX,Ms as MULTI_SELECT_TOGGLE_SLOP_PX,Ge as ModeController,Ct as OPTIONS_GRID_MOBILE_QUERY,si as OPTION_ENTER_DELAY_VAR,Os as OPTION_ENTER_FADE_MS,As as OPTION_ENTER_RISE_MS,ks as OPTION_ENTER_RISE_PX,Is as OPTION_ENTER_STAGGER_MS,ti as OPTION_IMAGE_WIDTH,Xa as PLACEHOLDER_FADE_OUT_MS,Ee as PLACEHOLDER_LEAVING_ATTR,Ja as PLACEHOLDER_SWAP_GAP_MS,Ya as PLACEHOLDER_TYPE_MS,Qa as PLACEHOLDER_WORD_PAUSE_MS,xs as PRODUCT_IMAGE_WIDTH,To as PRODUCT_PATH_PREFIX,ys as PRODUCT_ROW_PX_PER_LINE,Co as RANGE_SEPARATOR,Di as SCHEMA_VERSION,Ir as SCROLL_ARROW_ATTR,kr as SCROLL_ARROW_BOTTOM_VAR,Lr as SCROLL_ARROW_CLASS,Or as SCROLL_ARROW_FADE_MS,Zs as SCROLL_ARROW_LABEL,Ar as SCROLL_ARROW_SCROLL_IDLE_MS,Ce as SCROLL_ARROW_VISIBLE_ATTR,Mi as SKIPPED_PARAM_TEXT,en as SMART_SUGGESTION_SPARKLE_SVG,fo as TIME_META_KEY,Tn as TIME_STEP_MINUTES,ht as TIME_WHEEL_COLUMNS,ft as TIME_WHEEL_ROW_HEIGHT,Le as VIEWPORT_FIT_ATTR,Ut as VIEWPORT_FIT_HEIGHT_VAR,rt as WEEKDAY_LABELS,an as addMonths,Zn as attachProductRowWheel,gi as attachScrollArrow,fi as attachViewportFit,Kn as buildAttributionUrl,sn as buildDateOptions,Qt as buildLocationOption,F as buildQuery,ue as buildSubmitResult,Cn as buildTimeOption,cn as cellDay,Z as cellIso,hn as chipIdFromTap,Oo as computeOptionsGridLayout,Yn as containScroll,Ti as createStore,Sn as cursorIsAtEnd,Xn as dateCellMarks,Be as dateSelectionFor,pt as extractPlainText,Se as formatAbsoluteDate,ro as formatDate,Lo as formatDateRange,Ve as formatOptionCount,Ai as formatPlace,gt as formatTime,$ as getCursorOffset,jn as getFooterHint,tn as hasSkippablePill,$n as highlightParts,J as identifiedParamLabel,k as isCalendarFormat,di as isMultiSelectToggleTap,Bn as isOptionsGridMobileViewport,D as isPickerFormat,tt as isSmartSuggestion,w as isTraditionalAutocompleteSuggestion,G as isoDate,ho as isoTime,bn as keepCaretOnChip,Zt as labelTraditionalAutocomplete,Xt as locationEndpointFor,It as matchTypedPhrase,Un as measureOptionsGrid,on as monthLabel,Hn as needsOptionsGridMeasurement,Us as optionCountLabel,li as optionEnterDelayMs,Sr as optionHasImage,Ht as optionImageSources,fe as optionImageSrc,Nt as optionLabel,ci as optionsEntranceDurationMs,Fn as optionsGridTemplateColumns,ui as optionsShowLeadingVisuals,at as parseDate,He as parseLooseDate,Pt as parseLooseDateRange,xn as parseTime,mn as plainTextLength,Wn as planOptionsGrid,yn as previousGraphemeBoundary,vo as productFromMatchedItem,_t as productImageSources,vs as productImageSrc,ei as productInitial,ii as productPhotoFill,sr as productRowWheelTarget,kn as productsFromCustomFields,yi as renderEditableContent,Q as resolveFormatType,Mn as resolveIdentifiedDate,Vn as sameOptionRows,ge as sanitizeOptionIconSvg,dn as scrollCaretIntoView,ln as selectedIsoFromText,Ue as selectedRangeFor,H as setCursorOffset,dr as shopifyImageSrc,bt as timeWheelIndex,On as timeWheelIndexFromScroll,In as timeWheelRows,Oe as toWireIdentifiedParams,_o as typedFragment,O as uiStringsFor,Qn as visibleDateRange,Si as watchEditorHeight,Ae as withSkippedParams,St as withTimeWheelIndex,Jt as withoutTraditionalAutocomplete};
3041
3340
  //# sourceMappingURL=index.mjs.map