@magicx-eng/ai-autocomplete-vanilla 0.74.2 → 0.74.4

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 R(t){return t==="date"||t==="date-range"}function _(t){return t!=="options"}function Y(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 Tt=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 Rs="https://api.ai-autocomplete.com",X=`${Rs}/api/suggest`,xt=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),Do=new WeakMap;function Ke(t){return t?.type==="accessToken"}function _s(t){if(!(!t||Ke(t)))return t}function vt(t){let e=Do.get(t.getAccessToken);return e||(e=new Tt(t),Do.set(t.getAccessToken,e)),e}function Et(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function wt(t){let e=_s(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var Mn="aiaPlace",Pt=2,Fo=250,Ho=new Set("new san los las santa saint st fort port north south east west lake mount el la rio de palm long grand cape salt hong".split(" ")),No=new Set("city beach springs falls island park heights valley bay".split(" ")),Ds=new Set("a an the in at to off on of from for by near into onto around via toward towards up out and or with within".split(" "));function Wo(t){let e=Hs(t);for(;e.length>0&&Ds.has(e[0].toLowerCase().replace(/[.,]+$/,""));)e.shift();return e.join(" ")}function Hs(t){let e=t.trim().split(/\s+/).filter(Boolean);if(e.length===0)return[];let n=e[e.length-1].replace(/[.,]+$/,"");if(!n)return[];let i=e.length>1?e[e.length-2]:void 0,o=e.length>2?e[e.length-3]:void 0,r=a=>a.toLowerCase().replace(/[.,]+$/,"");return i&&o&&Ho.has(r(o))&&No.has(r(n))?[o,i,n]:i&&(Ho.has(r(i))||No.has(r(n)))?[i,n]:[n]}function Vo(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function On(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function kn(t,e){let n=On(e);if(!n)return!1;if(On(t.name)===n)return!0;for(let[,i]of t.name.matchAll(/\(([^()]*)\)/g))if(On(i)===n)return!0;return!1}function Bo(t,e){let n=e.metadata?.[Mn];if(typeof n?.name!="string")return 0;let i={id:"",name:n.name},o=[...t.matchAll(/\S+/g)];for(let r of o){let a=r.index??0,s=t.slice(a).trim().replace(/[.,]+$/,"");if(kn(i,s))return t.length-a}return 0}function Rn(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:Vo(t),is_tappable:!0,kind:null,metadata:{[Mn]:{id:t.id,name:t.name}}}}function _n(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??X,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 Uo(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 ze(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var $o="skipped";function je(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:$o,kind:null}));return i.length>0?[...t,...i]:t}var Ns="0.74.2",Ko="1.0",Go=!1;function Fs(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function de(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function Ws(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function Vs(t,e,n,i,o,r,a,s,l,c,d,u,g,m){let p=e.find(x=>x.parameter==="contact"&&x.metadata?.contact_account_count)?.metadata?.contact_account_count,f=typeof p=="number"?p:void 0,h=Ws();return{data:{raw_query:t,accepts_traditional_autocomplete:!0,...m&&{traditional_autocomplete_only:!0},client_option_parameters:g??[],completed_params:je(e.map(x=>Fs(x,n)),l??[]),...a&&a.length>0&&{identified_params:ze(a)},...s&&s.length>0&&{recently_suggested:s},...f!=null&&{contact_account_count:f},...c!==void 0&&{additional_context:c}},meta:{request_id:o,request_at:new Date().toISOString(),language:de(d),...h&&{timezone:h},...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:Ns,session_id:i,source:r,schema_version:Ko}}}async function qo(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function Dn(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=Vs(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,n.traditionalAutocompleteOnly),a=i?.endpoint??X,s=await zo(a,JSON.stringify(r),i,n.signal);if(!s.ok)throw new Error(`API error: ${s.status} ${s.statusText}`);return s.json()}async function zo(t,e,n,i){let o=Et(n);if(Ke(n)){let a=vt(n),s=await a.getToken(),l=await qo(t,o,s,e,i);if(l.status===401){let c=await a.getToken(!0);l=await qo(t,o,c,e,i)}return l}let r=wt(n);return!r&&!Go&&(Go=!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 Qe=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function jo(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:de(n.language)}),o=await zo(t,i,n.apiConfig,n.signal);if(!o.ok)throw new Qe(o.status);return Uo(await o.json())}var Lt=/[\p{L}\p{N}]/u,Bs=/['\u2019-]/;function Qo(t,e,n){let i=t[e];if(i===void 0)return!1;if(Lt.test(i))return!0;let o=t[e+n];return Bs.test(i)&&o!==void 0&&Lt.test(o)}function Us(t,e,n){let i=e+n.length;return!(Lt.test(n[0])&&Qo(t,e-1,-1)||Lt.test(n[n.length-1])&&Qo(t,i,1))}function ne(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(Us(t,r,e))return r;o===-1&&(o=r)}r=t.indexOf(e,r+1)}return o}function N(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 d=`{{${s.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,u=m=>ne(n,s.text,m,p=>!r.some(f=>p<f.end&&p+s.text.length>f.start)),g=u(a);if(g===-1&&(g=u(0)),g!==-1){n=n.slice(0,g)+d+n.slice(g+s.text.length);let m=d.length-s.text.length;for(let p of r)p.start>=g+s.text.length&&(p.start+=m,p.end+=m);r.push({start:g,end:g+d.length}),a=g>=a?g+d.length:a+m}o.push({...s,placeholder:d})}return{rawQuery:n,completedParams:o}}function ue(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function Ce(t,e){return e===!1?"":t}function Ye(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function Xe(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 Yo(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 Xo(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function $s(t,e){let n=Xo(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function me(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?Xo(i).trimStart():"";if(o)return t.filter(a=>!a.is_tappable||$s(a.text,o));let r=i.toLowerCase();return t.filter(a=>!a.is_tappable||a.text.toLowerCase().includes(r))}function Ct(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 Je(t,e,n,i,o){let r=Xe(e,n,i),a=Ct(t,r);if(a||!o||!r.trim())return a;if(r===e.slice(n))return null;let s=e.lastIndexOf(" ",n-1)+1;return Ct(t,e.slice(s))}function Jo(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.selectsAll&&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 er(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function tr(t,e){let{icon:n,icon_svg:i}=e;return!i||t.every(Zo)?t:t.map(o=>Zo(o)?o:{...o,icon:n,icon_svg:i})}function Zo(t){return!!(t.icon_svg||t.image_url)}function Gs(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function ie(t){let e=Gs(t);return e.length>0?e.join(" "):t}function J(t,e){return t.parameter||e}function Ze(t,e){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:ie(t),...e?{suggestionHeader:e}:{}}}function et(t){return t.suggestionValueType?.kind==="traditional_autocomplete"?{parameter:t.suggestionParameter,text:t.suggestionHeader??"",required:!0,type:t.suggestionValueType,options:t.options}:{parameter:t.suggestionParameter,text:t.suggestionPlaceholder,required:!0,options:t.options}}function At(t,e){let n=J(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?Ze(n,t.suggestionHeader):{parameter:n,suggestionParameter:t.suggestionParameter,suggestionValueType:t.suggestionValueType,suggestionPlaceholder:t.suggestionPlaceholder,suggestionIcon:t.suggestionIcon,suggestionIconSvg:t.suggestionIconSvg}}function A(t){return t?.type?.kind==="traditional_autocomplete"}function Hn(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function Ae(t){return A(t)||t?.smart_suggestion===!0}function Nn(t){return t.some(A)?t.filter(e=>!A(e)):t}function Fn(t,e){return t.some(n=>A(n)&&!n.text)?t.map(n=>A(n)&&!n.text?{...n,text:e}:n):t}var Wn='<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 Vn(t){return t.some(e=>!A(e))}function nr(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 ir(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 or(t,e){let n=[],i=new Map;for(let o of[...t,...e]){if(o.parameter==="placeholder"||A(o))continue;let r=i.get(o.parameter);r||(r={parameter:o.parameter,text:o.text},i.set(o.parameter,r),n.push(r));for(let a of o.options??[])!a.is_tappable||r.options?.includes(a.text)||(r.options??(r.options=[]),r.options.push(a.text))}return n}function rr(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 It(t,e){let n=[],i=[],o=0;for(let r of e){let a=ne(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 xe(t,e){let{located:n}=It(t,e);return n.length>0?n[n.length-1].end:0}function ar(t,e,n){let i=[],o=[],r=0;for(let a of n){let s=ne(t,a.text,r,l=>!e.some(c=>l<c.end&&l+a.text.length>c.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 Ot(t,e,n=[]){let i=It(t,e).located,o=[];for(let d of i){let u=o[o.length-1];d.param.group&&u?.param.group===d.param.group?(u.end=d.end,u.params?.push(d.param)):o.push({...d,...d.param.group?{params:[d.param]}:{}})}let r=ar(t,o,n).located,a=[...o.map(d=>({start:d.start,end:d.end,segment:{type:"completed",value:t.slice(d.start,d.end),param:d.param,...d.params?{params:d.params}:{}}})),...r.map(d=>({start:d.start,end:d.end,segment:{type:"identified",value:d.param.text,param:d.param}}))].sort((d,u)=>d.start-u.start),s=[],l=0;for(let d of a)d.start>l&&s.push({type:"text",value:t.slice(l,d.start)}),s.push(d.segment),l=d.end;let c=t.slice(l);return c&&s.push({type:"text",value:c}),s}function sr(t,e){let{located:n,missing:i}=It(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 tt(t,e,n){let i=It(t,e).located,{located:o,missing:r}=ar(t,i,n);return{valid:o.map(a=>a.param),invalid:r}}function lr(t,e,n){let i=e?.endpoint??X,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${qs(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,a)=>{let s=xt.get(a);return s?`https://${s}`:r})}function qs(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 cr(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 Ks(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var dr=100,zs=300,js=2,Mt=class{constructor(e,n,i,o,r,a,s,l,c,d={}){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=c;this.callbacks=d;this.fetchVersion=0;this.abortController=null;this.debounceTimer=null;this.slowDebounceTimer=null;this.unsubscribe=null;this.phraseExactMatch=!1;this.previewTimer=null;this.previewAbort=null;this.previewVersion=0;this.previewPending=!1;this.forceNextFetch=!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.clearPreview(),this.unsubscribe?.()}previewComposition(e){this.previewTimer&&clearTimeout(this.previewTimer),this.previewPending=!0,this.previewTimer=setTimeout(()=>{this.previewTimer=null,this.doPreview(e)},dr)}endPreview(){this.previewPending&&(this.clearPreview(),this.forceNextFetch=!0,this.scheduleFetch())}clearPreview(){this.previewTimer&&clearTimeout(this.previewTimer),this.previewTimer=null,this.previewAbort?.abort(),this.previewAbort=null,this.previewPending=!1}async doPreview(e){this.previewAbort?.abort();let n=new AbortController;this.previewAbort=n;let i=++this.previewVersion;this.previewPending=!0;let o=this.fetchVersion,r=this.store.get(),{rawQuery:a,completedParams:s}=N(e,r.completedParams);try{let l=await Dn(a,s,{...this.requestOptions(r,n.signal,crypto.randomUUID()),traditionalAutocompleteOnly:!0});if(i!==this.previewVersion||o!==this.fetchVersion)return;let c=(l.data.suggestions??[]).find(A);if(!c)return;this.store.set({suggestions:[c],traditionalAutocomplete:l.meta?.traditional_autocomplete===!0,activeDropdownIndex:-1})}catch{}}requestOptions(e,n,i){let o=e.pendingSpan?or(e.pendingSpan.snapshot,e.actionableSuggestions):void 0;return{sessionId:this.getSessionId(),requestId:i,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:n,apiConfig:this.getApiConfig(),identifiedParams:e.identifiedParams,recentlySuggested:o,skippedParams:e.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})}}async doFetch(e,n){this.abortController?.abort(),this.previewAbort?.abort(),this.previewAbort=null,this.previewPending=!1,this.forceNextFetch=!1;let i=new AbortController;this.abortController=i;let o=++this.fetchVersion,r=this.store.get().text.length,a=this.store.get().text;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 s=this.store.get(),l=crypto.randomUUID(),c=e===""&&n.length===0&&s.skippedParams.length===0&&s.identifiedParams.length===0,d=c?this.startingStateUrl():void 0,u=d?await cr(fetch(d,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let g=u??await Dn(e,n,this.requestOptions(s,i.signal,l));if(o!==this.fetchVersion)return;this.phraseExactMatch=g.meta?.phrase_exact_match===!0;let m=(g.data.suggestions??[]).find(A),p=m?[]:g.data.input??[],f=E=>({id:crypto.randomUUID(),parameter:E.parameter,text:E.text,...E.type?{type:E.type}:{},...E.iso_date?{isoDate:E.iso_date}:{},...E.iso_date_end?{isoDateEnd:E.iso_date_end}:{}}),h=p.filter(E=>E.source==="identified");this.callbacks.waitIdentified?.(h.filter(E=>E.state==="need_confirmation").map(f),a);let x=h.filter(E=>E.state!=="need_confirmation").map(f),y=this.callbacks.isWordOpen?.()??!1,T=this.store.get().text.toLowerCase(),P=E=>y&&T.endsWith(E.text.toLowerCase()),b=x.filter(E=>!P(E));y&&this.callbacks.holdIdentified?.(x.filter(P));let v=m?[m]:er(g.data.suggestions??[],this.getOptionOverrides()),w=p,S=w[w.length-1],L=this.store.get().text,C,H;if(S?.state==="in_progress"){H=!0;let E=L.toLowerCase().lastIndexOf(S.text.toLowerCase());C=E!==-1?E:r}else H=!1,C=r;let I=v.filter(E=>E.parameter!=="placeholder")[0],G=null;if(I&&!A(I)&&!y&&I.type?.kind!=="multi_select"&&!_(Y(I))){let E=Je(I.options,L,C,H,this.phraseExactMatch);E&&(G={id:crypto.randomUUID(),placeholder:"",parameter:J(E,I.parameter),text:E.text,value:E.value,kind:E.kind,suggestionParameter:I.parameter,suggestionValueType:I.type,suggestionPlaceholder:I.text,suggestionIcon:I.icon,suggestionIconSvg:I.icon_svg,options:I.options??[],metadata:E.metadata,icon:E.icon,icon_svg:E.icon_svg,image_url:E.image_url},v=v.filter(le=>le!==I),this.callbacks.onAutoMatch?.({active:I,matched:E,rawQuery:e}))}let se=g.data.custom_fields??null,te=this.callbacks.productsForResponse?.(se);this.store.set(E=>{let le=G?[...E.completedParams,G]:E.completedParams,Se=new Set,St=tt(E.text,le,b).valid.map(M=>{let Te=E.identifiedParams.find(Ge=>!Se.has(Ge.id)&&Ge.parameter===M.parameter&&Ge.text===M.text);return Te?(Se.add(Te.id),{...M,id:Te.id}):M}),ye=new Set(s.skippedParams.map(M=>M.id)),$e=new Set(E.skippedParams.filter(M=>!ye.has(M.id)).map(M=>M.parameter)),yt=$e.size>0?v.filter(M=>M.parameter==="placeholder"||!$e.has(M.parameter)):v;return{suggestions:this.callbacks.getAllOption?.()===!0&&!c?yt.map(M=>M.parameter==="placeholder"?M:{...M,leadsWithAll:!0}):yt,isLoading:!1,isReady:g.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:C,filterInProgress:H,identifiedParams:St,customFields:se,traditionalAutocomplete:g.meta?.traditional_autocomplete===!0,...te!==void 0?{products:te}:{},...G?{completedParams:le}:{}}}),this.callbacks.onResponse?.({requestId:l,funnelTelemetry:g.meta?.funnel_telemetry===!0,visibleImpression:g.meta?.visible_impression===!0})}catch(s){let l=Ks(s);o===this.fetchVersion&&(this.store.set({error:l,isLoading:!1}),this.getOnError()?.(l))}finally{if(o===this.fetchVersion&&this.store.get().isLoading)try{this.store.set({isLoading:!1})}catch{}}}startingStateUrl(){let e=this.callbacks.getProductId?.();return e?lr(e,this.getApiConfig(),de(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(js)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},dr),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),zs)}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;if(this.forceNextFetch){let{rawQuery:v,completedParams:w}=N(o.text,o.completedParams);return this.doFetch(v,w),!0}let a=Ce(o.suggestions.filter(v=>v.parameter==="placeholder").map(v=>v.text).join(" "),this.callbacks.getPrependPlaceholder?.()),s=ue(o.text,o.filterBase,a),l=Xe(o.text,s,o.filterInProgress),c=o.suggestions.filter(v=>v.parameter!=="placeholder"),d=A(c[0])?void 0:c[0],u=_(o.activeFormatType),g=d&&!u?me(d.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&g.length>0)return!1;let m=g.filter(v=>v.is_tappable),p=d&&!u&&!this.callbacks.isWordOpen?.()?Je(d.options,o.text,s,o.filterInProgress,this.phraseExactMatch)!==null:!1,f=l.trim().length>0,h=i&&o.products.length>0;if(m.length>0&&!p&&f&&!h||Ye(o.text,o.completedParams.length,a))return!1;let{rawQuery:x,completedParams:y}=N(o.text,o.completedParams),T=x.length<o.lastRawQuery.length,P=Math.abs(x.length-o.lastRawQuery.length),b=n&&x!==o.lastRawQuery;return T||P>=e||b?(this.doFetch(x,y),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var Qs="(hover: none) and (pointer: coarse)";var Ys="[data-aia-dropdown], [data-aia-input-wrapper]",Xs=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),kt=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(Xs)),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(Qs):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(Ys))return!0;return!1}};var Ie=["January","February","March","April","May","June","July","August","September","October","November","December"],Rt=["S","M","T","W","T","F","S"],pr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],_t="aiaDate",gr="aiaDay",ur=t=>String(t).padStart(2,"0");function W(t){return`${t.getFullYear()}-${ur(t.getMonth()+1)}-${ur(t.getDate())}`}function Bn(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Js(t){let e=Bn(t).getTime()-Bn(new Date).getTime();return Math.round(e/864e5)}function fr(t){let e=Js(t);return e>=0&&e<7?pr[t.getDay()]:Oe(t)}function Oe(t){return t.getFullYear()===new Date().getFullYear()?`${Ie[t.getMonth()]} ${t.getDate()}`:`${Ie[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function Dt(t){if(!t)return null;let e=pr.findIndex(s=>s.toLowerCase()===t.trim().toLowerCase());if(e>=0){let s=Bn(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=Ie.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 Un(t){return`${Ie[t.month]} ${t.year}`}function $n(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function hr(t){return{year:t.getFullYear(),month:t.getMonth()}}function Gn(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function mr(){return{text:"",is_tappable:!1,kind:null}}function qn(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(mr());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:fr(r),is_tappable:!0,kind:null,metadata:{[_t]:W(r),[gr]:o}})}for(;i.length%Rt.length!==0;)i.push(mr());return i}function nt(t){let e=Dt(t);return e?W(e):null}function z(t){let e=t?.metadata?.[_t];return typeof e=="string"?e:null}function Kn(t){let e=t?.metadata?.[gr];return typeof e=="number"?e:null}function Zs(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function pe(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&Zs(e)?e:t.ownerDocument??t}function Ht(t){return pe(t).activeElement??null}function D(t){return t.ownerDocument??t}function el(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function br(t){let e=pe(t);return!el(e)||typeof e.getSelection=="function"?null:e}function Sr(t){let e=br(t);if(!e)return null;let n=D(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function yr(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 it(t){let n=pe(t).getSelection?.();return n||(D(t).getSelection?.()??null)}function ge(t){let e=it(t);if(!e||e.rangeCount===0)return null;let n=Sr(t);if(n){let i=yr(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 ve(t){let e=it(t);if(!e||e.rangeCount===0)return null;let n=Sr(t);if(!n)return e.getRangeAt(0);let i=yr(e,n);if(!i)return null;let o=D(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function ot(t,e,n){let i=it(t);if(!i)return null;if(br(t))return i.collapse(e,n),i;let o=D(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function Nt(t,e){let n=t?pe(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var Ft=2,tl="magicx-aia";function Tr(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function nl(t){let e=D(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&&Tr(a.overflowX)||r&&Tr(a.overflowY))return i}if(i.classList.contains(tl))return null;i=i.parentElement}return null}function zn(t){let e=ve(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=nl(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+Ft:i.left<r&&(n.scrollLeft-=r-i.left+Ft)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,a=r+n.clientHeight;i.bottom>a?n.scrollTop+=i.bottom-a+Ft:i.top<r&&(n.scrollTop-=r-i.top+Ft)}}var vr='[contenteditable="false"]',Qn="strong[data-param-id]",Me;function il(){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 Wt(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(vr))return!0;n=n.parentNode}return!1}function Vt(t){return D(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return Wt(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Bt(t){let e=Vt(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function Yn(t){let e=Vt(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function j(t){let e=ge(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(Wt(o,t)&&o!==t)return null;let r=0;for(let a=0;a<i&&a<o.childNodes.length;a++)r+=Xn(o.childNodes[a],t);return r+jn(o,t)}return n.nodeType!==Node.TEXT_NODE||Wt(n,t)?null:jn(n,t)+i}function Xn(t,e){if(t.nodeType===Node.TEXT_NODE)return Wt(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(vr))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=Xn(o,e);return i}function jn(t,e){let n=Vt(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 V(t,e){let n=D(t),i=Math.max(0,Math.min(e,Yn(t))),o=Vt(t),r=0,a=null,s=0,l=o.nextNode(),c=null;for(;l;){let u=l.data.length;if(i<r+u){a=l,s=i-r;break}if(i===r+u){let g=o.nextNode();g?(a=g,s=0):(a=l,s=u);break}r+=u,c=l,l=o.nextNode()}let d=n.createRange();if(a){let u=a.parentElement?.closest('strong[data-seg="completed"]');u&&u!==t&&t.contains(u)?s===0?d.setStartBefore(u):s===a.data.length?d.setStartAfter(u):d.setStart(a,s):d.setStart(a,s)}else c?d.setStart(c,c.data.length):d.setStart(t,0);d.collapse(!0),ot(t,d.startContainer,d.startOffset)&&(ol(t,d,i),zn(t))}function xr(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(Qn)??null;return i&&e.contains(i)?i:null}function ol(t,e,n){let i=xr(ge(t)?.node??null,t);if(i&&i!==xr(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function Er(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=j(t);return i!==null&&n===`${i}:${e}`}function wr(t){return pe(t).activeElement===t}function Jn(t,e){if(!e||e.nodeType===void 0)return null;let n=e,i=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;if(i?.closest("[data-aia-chip-remove]"))return null;let o=i?.closest(Qn);if(!o||!t.contains(o))return null;let r=ge(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function Zn(t,e){let n=null;for(let a of t.querySelectorAll(Qn))if(a.dataset.paramId===e){n=a;break}if(!n)return;let i=jn(n,t),o=i+Xn(n,t),r=j(t);r!=null&&r>=i&&r<=o||V(t,i)}function ei(t){let e=j(t);return e==null?!1:e>=Yn(t)}function ti(t,e){if(e<=0)return 0;let n=il();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 Pr="aiaTime",ii=5;var oi=[12,1,2,3,4,5,6,7,8,9,10,11],ri=Array.from({length:60/5},(t,e)=>e*5),ai=["AM","PM"];function Re(t){return(Math.round(t)%1440+1440)%1440}function si(t){let e=Re(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function Ut(t){let e=t.hour%12+(t.period==="PM"?12:0);return Re(e*60+t.minute)}function $t(t){let{hour:e,minute:n,period:i}=si(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function Lr(t){let e=Re(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function ke(t){return Re(Math.round(t/5)*5)}function Cr(t,e){return Re(t+e)}var rl=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,al=/^(\d{1,2}):(\d{2})$/;function ni(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=rl.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:Ut({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=al.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 Ar(t){let e=ni(t.editingText);if(e!=null)return ke(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>ni(o.text)).filter(o=>o!=null);if(n.length>0)return ke(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return Re((i.getHours()+1)*60)}function li(t){return{text:$t(t),is_tappable:!0,kind:null,metadata:{[Pr]:Lr(t)}}}var Gt=30,qt=["hour","minute","period"],ci={hour:oi.map(t=>({label:String(t)})),minute:ri.map(t=>({label:String(t).padStart(2,"0")})),period:ai.map(t=>({label:t}))};function di(t){return ci[t]}function Kt(t,e){let n=si(ke(e));return t==="hour"?oi.indexOf(n.hour):t==="minute"?ri.indexOf(n.minute):ai.indexOf(n.period)}function zt(t,e,n){let i=ci[t],o=Math.min(Math.max(n,0),i.length-1),r=si(ke(e));return Ut(t==="hour"?{...r,hour:oi[o]}:t==="minute"?{...r,minute:ri[o]}:{...r,period:ai[o]})}function ui(t,e){let n=ci[t].length-1;return Math.min(Math.max(Math.round(e/Gt),0),n)}function Ee(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=N(t,e);return{query:t.trim(),raw_query:o,completed_params:je(r,n),identified_params:ze(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function jt(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")?ei(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function mi(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?j(t):null}var Qt=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 c=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let d=n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&d?.is_tappable){e.preventDefault(),this.ctx.selectOption(d);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&d?.is_tappable&&this.ctx.selectOption(d),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let d=jt(e.target,n),u=!!n.editingParam;if(!d&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(c)break;e.preventDefault();let p=R(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(R(n.activeFormatType)){this.stepDateWeek(n,7);break}if(n.filteredOptions.length>0){let p=Math.floor((n.filteredOptions.length-1)/a);if(Math.floor(n.activeDropdownIndex/a)===p){this.store.set({activeDropdownIndex:-1});break}}let g=l.indexOf(n.activeDropdownIndex),m=g<l.length-1?g+1:0;this.store.set({activeDropdownIndex:l[m]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!c)break;let g=jt(e.target,n),m=!!n.editingParam;if(!g&&!m)break;e.preventDefault();let p=R(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:p});break}if(l.length===0)return;this.store.set({activeDropdownIndex:p});break}if(l.length===0)break;if(e.preventDefault(),R(n.activeFormatType)){this.stepDateWeek(n,-7);break}if(n.activeDropdownIndex<a){this.store.set({activeDropdownIndex:-1});break}let d=l.indexOf(n.activeDropdownIndex),u=d>0?d-1:l.length-1;this.store.set({activeDropdownIndex:l[u]});break}case"ArrowRight":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),R(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%a<a-1){let g=n.activeDropdownIndex+1;g<n.filteredOptions.length&&n.filteredOptions[g]?.is_tappable&&this.store.set({activeDropdownIndex:g})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,g=n.editingTail;this.ctx.exitEditMode?.(),V(u,g);break}jt(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),R(n.activeFormatType)){this.stepDateDay(n,-1);break}if(n.activeDropdownIndex%a>0){let d=n.activeDropdownIndex-1;d>=0&&n.filteredOptions[d]?.is_tappable&&this.store.set({activeDropdownIndex:d});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let d=mi(e.target);d!=null&&this.ctx.startEditingParamAtCaret(d)}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingAnchor!=null){e.preventDefault();let d=e.target.closest("[data-aia-input]")??e.target,u=n.editingAnchor;this.ctx.exitEditMode?.(),V(d,u);break}if(this.ctx.startEditingParamAtCaret){let d=mi(e.target);d!=null&&this.ctx.startEditingParamAtCaret(d)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let d=mi(e.target);if(d==null)break;this.ctx.removeParamAtCaret(d)&&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 d=this.store.get();s(Ee(d.text,d.completedParams,d.skippedParams,{identifiedParams:d.identifiedParams,isReady:d.isReady,customFields:d.customFields}))&&this.ctx.afterSubmit?.()}break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let d=n.filteredOptions.map((m,p)=>m.is_tappable?p:-1).filter(m=>m!==-1);if(d.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let m=e.shiftKey?d[d.length-1]:d[0];this.store.set({pillTapped:!0,activeDropdownIndex:m});break}e.preventDefault();let u=d.indexOf(n.activeDropdownIndex);if(!e.shiftKey&&!R(n.activeFormatType)&&!n.multiSelectView){let m=u>=0?d[u]:d.find(p=>!n.filteredOptions[p]?.selectsAll);if(m===void 0)break;this.clickOrSelect(m,n.filteredOptions,i,r);break}let g;if(u<0)g=e.shiftKey?d.length-1:0;else{let m=e.shiftKey?-1:1;g=(u+m+d.length)%d.length}this.store.set({activeDropdownIndex:d[g]});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 d=e.target.closest("[data-aia-input]")??e.target,u=n.editingTail;this.ctx.exitEditMode?.(),V(d,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!jt(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){if(e.dateFloor){let a=e.filteredOptions.findIndex(s=>z(s)===e.dateFloor);if(a>=0)return a}let i=W(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=Nt(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=Nt(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=Nt(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var Yt=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(_(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,icon:n.suggestionIcon,icon_svg:n.suggestionIconSvg},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||sl(a))return;this.logOnce(a),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=tr(n,e.suggestion),r=this.resolveTarget(this.store.get());if(!r||r.key!==e.key)return;o.length===0?this.lastMiss={parameter:e.parameter,query:e.query}:this.lastMiss?.parameter===e.parameter&&(this.lastMiss=null);let a={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:o}:s.editingParam,optionSearch:a}));else{let s={...e.suggestion,options:o};this.current&&this.current.key===e.key&&(this.current.key=s),this.store.set(l=>({suggestions:l.suggestions.map(c=>c===e.suggestion?s:c),optionSearch:a}))}o.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 sl(t){return t instanceof Error&&t.name==="AbortError"}var Xt=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(c=>c.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(A(o))return;let r=i.filter((c,d)=>d!==e),a=n.suggestions.filter(c=>c.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:c}=N(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:c,selectedPill:o.text,otherPills:r.map(d=>d.text)})}let s=[...a,o,...r],l=this.store.peek({suggestions:s}).filteredOptions.findIndex(c=>c.is_tappable&&!c.selectsAll);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 Mr="/products/",Ir="https://relative.invalid";function ll(t){if(!t)return;let e;try{e=new URL(t,`${Ir}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===Ir?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function kr(t,e){let n=ll(t.item_url)??dl(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:Or(t.price,t.currency,e)},...cl(t)&&{compareAtPrice:Or(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function cl(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 Or(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 dl(t){if(!t.handle)return;let e=`${Mr}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function pi(t,e){return(t?.items.matched??[]).map(n=>kr(n,e))}var Jt=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=pi(e,de(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:[],c=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(c)}catch(a){if(n.aborted||ul(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 ul(t){return t instanceof Error&&t.name==="AbortError"}function ml(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function Rr(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:Ie.findIndex(n=>n.toLowerCase().startsWith(e))}function pl(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}var gl=/^(?:(?:on|from) )?(?:the )?(\d{1,2})(?:st|nd|rd|th)$/;function gi(t){let e=gl.exec(t.trim().toLowerCase().replace(/\s+/g," "));if(!e)return null;let n=Number(e[1]);return n>=1&&n<=31?n:null}function fl(t,e){if(!Number.isFinite(e.getTime()))return null;let n=new Date(e.getFullYear(),e.getMonth(),e.getDate());for(let i=0;i<12;i++){let o=new Date(e.getFullYear(),e.getMonth()+i,t);if(o.getDate()===t&&o>=n)return o}return null}function _r(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function _e(t,e={}){if(!t)return null;let n=e.today??new Date,i=gi(t);if(i!==null){let c=fl(i,n);return c?W(c):null}let o=ml(t.trim().toLowerCase()).replace(/\s+/g," "),r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o);if(r){let c=_r(Number(r[1]),Number(r[2])-1,Number(r[3]));return c?W(c):null}let a=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(o);if(a){let c=Rr(a[1]);if(c>=0)return Zt(c,Number(a[2]),a[3],n)}let s=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(o);if(s){let c=Rr(s[2]);if(c>=0)return Zt(c,Number(s[1]),s[3],n)}let l=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(o);if(l){let c=Number(l[1]),d=Number(l[2]);return c>12&&d<=12?Zt(d-1,c,l[3],n):d>12&&c<=12?Zt(c-1,d,l[3],n):null}return null}function Zt(t,e,n,i){if(n){if(n.length!==4)return null;let r=_r(Number(n),t,e);return r?W(r):null}let o=pl(t,e,i);return o?W(o):null}var hl=/^\d{4}-\d{2}-\d{2}$/;function rt(t){return typeof t=="string"&&hl.test(t)?t:null}function fi(t,e={}){return rt(t.isoDate)??_e(t.text,e)}function at(t){let e=rt(t.isoDate);return e?{start:e,end:rt(t.isoDateEnd)}:null}var Dr=" - ",Si="aiaDateRangeStart",yi="aiaDateRangeEnd";function st(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var hi=/^\d{4}-\d{2}-\d{2}$/;function bi(t){if(!hi.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 bl=/\s+(?:to|through|thru|until|til|till)\s+/g,Sl=/[-–—]/g;function yl(t){let e=[];for(let n of[bl,Sl]){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 en(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of yl(t.trim())){let a=_e(o.trim(),e);if(!a)continue;let s=gi(r)!==null?_e(r.trim(),{...e,today:bi(a)??e.today}):_e(r.trim(),e);!s||s<a||(n.add(`${a}|${s}`),i={start:a,end:s})}return n.size===1?i:null}function Hr(t){let e=bi(t.start),n=bi(t.end);return!e||!n?"":t.start===t.end?Oe(e):`${Oe(e)}${Dr}${Oe(n)}`}function Nr(t,e){let n=st(t,e);return{text:Hr(n),is_tappable:!0,kind:null,metadata:{[Si]:n.start,[yi]:n.end}}}function De(t,e={}){let n=t?.metadata?.[Si],i=t?.metadata?.[yi];return typeof n=="string"&&typeof i=="string"&&hi.test(n)&&hi.test(i)?st(n,i):en(t?.text,e)}var tn="(max-width: 768px)";var Tl="var(--aia-option-row-height, 37px)",xl="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function Fr(t,e){return e?Ti(1,Math.min(t,5)):Ti(1,Math.min(t,4))}function Ti(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${Tl} + ${xl})`}}function vi(t,e){return!e&&t>=5}function Ei(t,e,n,i){if(!(!e&&t>=5&&vl(n,i))){let a=Fr(t,e);return{...a,template:xi(a.cols),scrollHintIndices:!e&&t>a.rows?[a.rows-1]:[]}}let r=6;return{...Ti(2,3),template:xi(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function vl(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 lt(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)+El(t);return{rowWidths:i,gridWidth:r}}function El(t){let e=t.closest("[data-aia-dropdown]"),n=Number.parseFloat(e?.getAttribute(nn)??"");if(!e||!Number.isFinite(n)||e.style.getPropertyValue(ct)!=="")return 0;let i=e.getBoundingClientRect().width;return i>0?n-i:0}var nn="data-aia-glide-width",ct="--aia-glide-content-width";function xi(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function dt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(tn).matches}function wi(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}var Wr={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Items",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",seeAllResults:"See all results",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",allOption:"All",timeLabel:"Time",locationSearch:"Say a location",locationNoResults:"No places found",locationUseTyped:"Press Enter to use what you typed"},wl={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",seeAllResults:"Ver todos los resultados",scrollArrow:"Despl\xE1zate para ver m\xE1s opciones",keepTyping:"Sigue escribiendo",done:"Listo",allOption:"Todo",timeLabel:"Hora",locationSearch:"Di una ubicaci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},Pi={en:Wr,es:wl,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",seeAllResults:"Voir tous les r\xE9sultats",scrollArrow:"Faites d\xE9filer pour voir plus d\u2019options",keepTyping:"Continuez \xE0 taper",done:"Termin\xE9",allOption:"Tout",timeLabel:"Heure",locationSearch:"Dites un lieu",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",seeAllResults:"Ver todos os resultados",scrollArrow:"Role para ver mais op\xE7\xF5es",keepTyping:"Continue digitando",done:"Conclu\xEDdo",allOption:"Tudo",timeLabel:"Hor\xE1rio",locationSearch:"Diga um local",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",seeAllResults:"Vedi tutti i risultati",scrollArrow:"Scorri per vedere altre opzioni",keepTyping:"Continua a scrivere",done:"Fatto",allOption:"Tutto",timeLabel:"Ora",locationSearch:"Di' un luogo",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",seeAllResults:"T\xFCm sonu\xE7lar\u0131 g\xF6r",scrollArrow:"Daha fazla se\xE7enek i\xE7in kayd\u0131r",keepTyping:"Yazmaya devam et",done:"Tamam",allOption:"T\xFCm\xFC",timeLabel:"Saat",locationSearch:"Bir konum s\xF6yleyin",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",seeAllResults:"Lihat semua hasil",scrollArrow:"Gulir untuk melihat opsi lainnya",keepTyping:"Teruskan mengetik",done:"Selesai",allOption:"Semua",timeLabel:"Waktu",locationSearch:"Sebutkan lokasi",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",seeAllResults:"Zobacz wszystkie wyniki",scrollArrow:"Przewi\u0144, aby zobaczy\u0107 wi\u0119cej opcji",keepTyping:"Pisz dalej",done:"Gotowe",allOption:"Wszystko",timeLabel:"Godzina",locationSearch:"Podaj lokalizacj\u0119",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",seeAllResults:"Alle Ergebnisse anzeigen",scrollArrow:"Scrolle f\xFCr weitere Optionen",keepTyping:"Weitertippen",done:"Fertig",allOption:"Alle",timeLabel:"Uhrzeit",locationSearch:"Nenne einen Ort",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",seeAllResults:"Alle resultaten bekijken",scrollArrow:"Scrol voor meer opties",keepTyping:"Blijf typen",done:"Klaar",allOption:"Alles",timeLabel:"Tijd",locationSearch:"Noem een locatie",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",seeAllResults:"Visa alla resultat",scrollArrow:"Skrolla f\xF6r fler alternativ",keepTyping:"Forts\xE4tt skriva",done:"Klar",allOption:"Alla",timeLabel:"Tid",locationSearch:"S\xE4g en plats",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",seeAllResults:"Se alle resultater",scrollArrow:"Rull ned for \xE5 se flere alternativer",keepTyping:"Fortsett \xE5 skrive",done:"Ferdig",allOption:"Alle",timeLabel:"Tid",locationSearch:"Si et sted",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",seeAllResults:"Se alle resultater",scrollArrow:"Rul for flere muligheder",keepTyping:"Forts\xE6t med at skrive",done:"F\xE6rdig",allOption:"Alle",timeLabel:"Tidspunkt",locationSearch:"Sig et sted",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",seeAllResults:"N\xE4yt\xE4 kaikki tulokset",scrollArrow:"Vierit\xE4 n\xE4hd\xE4ksesi lis\xE4\xE4 vaihtoehtoja",keepTyping:"Jatka kirjoittamista",done:"Valmis",allOption:"Kaikki",timeLabel:"Aika",locationSearch:"Sano sijainti",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",seeAllResults:"\u3059\u3079\u3066\u306E\u7D50\u679C\u3092\u898B\u308B",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",allOption:"\u3059\u3079\u3066",timeLabel:"\u6642\u523B",locationSearch:"\u5834\u6240\u3092\u8A00\u3063\u3066\u304F\u3060\u3055\u3044",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:"\uCD94\uCC9C \uC0C1\uD488",soldOut:"\uD488\uC808",addToCart:"\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uB2F4\uAE30",submit:"\uAC80\uC0C9",seeAllResults:"\uBAA8\uB4E0 \uACB0\uACFC \uBCF4\uAE30",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",allOption:"\uC804\uCCB4",timeLabel:"\uC2DC\uAC04",locationSearch:"\uC704\uCE58\uB97C \uB9D0\uD558\uC138\uC694",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",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7ED3\u679C",scrollArrow:"\u5411\u4E0B\u6EDA\u52A8\u67E5\u770B\u66F4\u591A\u9009\u9879",keepTyping:"\u7EE7\u7EED\u8F93\u5165",done:"\u5B8C\u6210",allOption:"\u5168\u90E8",timeLabel:"\u65F6\u95F4",locationSearch:"\u8BF4\u51FA\u5730\u70B9",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",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7D50\u679C",scrollArrow:"\u5411\u4E0B\u6372\u52D5\u67E5\u770B\u66F4\u591A\u9078\u9805",keepTyping:"\u7E7C\u7E8C\u8F38\u5165",done:"\u5B8C\u6210",allOption:"\u5168\u90E8",timeLabel:"\u6642\u9593",locationSearch:"\u8AAA\u51FA\u5730\u9EDE",locationNoResults:"\u627E\u4E0D\u5230\u5730\u9EDE",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F38\u5165\u7684\u5167\u5BB9"}},Pl={pt:"pt-BR",no:"nb",nn:"nb"};function k(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return Pi[o?"zh-TW":"zh-CN"]}let i=Pl[e]??e;return Object.prototype.hasOwnProperty.call(Pi,i)?Pi[i]:Wr}function Vr(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,c=t.caretOffset==null||t.caretOffset>=l;return(a||t.isLoading)&&s&&c}return n==="manual"?(a||t.isLoading)&&t.pillTapped:!1}function B(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 on(t){if(!t)return $n();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function Ll(t){let e=Dt(t);return e?hr(e):$n()}function Cl(t,e){if(!t)return null;for(let n of e){if(n.parameter!==t||n.type?.kind!=="date_range")continue;let i=at(n);if(i&&i.end==null)return i.start}return null}function Al(t){let e=new Set,n=i=>{i&&e.add(i)};for(let i of t.completedParams??[]){if(i.id===t.editingParam?.id)continue;let o=i.suggestionValueType?.kind;if(o==="date"&&n(rt(i.metadata?.[_t])??nt(i.text)),o==="date_range"){let r=De(i);n(r?.start),n(r?.end)}}for(let i of t.identifiedParams??[]){if(i.id===t.editingIdentified?.id)continue;let o=i.type?.kind;if(o!=="date"&&o!=="date_range")continue;let r=at(i);n(r?.start),n(r?.end)}return[...e].sort()}function Li(t,e){return t.editingParam!=null&&t.editingAnchor!=null?e:t.text.slice(xe(t.text,t.completedParams))}var Il=/price/i;function Ol(t){return!t||Ae(t)||_(Y(t))||t.type?.kind==="multi_select"||Il.test(t.parameter)?!1:(t.options??[]).filter(e=>e.is_tappable).length>=2}function ut(t,e,n){if(e>0)return!1;let i=t.trim();return i===""||i.toLowerCase()===n.trim().toLowerCase()||Ye(i,0,n)}var Ml=4;function kl(t,e){let n={text:e,kind:null,is_tappable:!0,selectsAll:!0},i=[...new Set(t.filter(r=>r.is_tappable&&r.image_url).map(r=>r.image_url))].slice(0,Ml);if(i.length>0)return n.image_url=i[0],i.length>1&&(n.imageCollage=i),[n,...t];let o;for(let r of t)r.is_tappable&&(o=r);return o?.icon&&(n.icon=o.icon),o?.icon_svg&&(n.icon_svg=o.icon_svg),[n,...t]}function Rl(t,e){let{composing:n}=t,i=n?.over===t.text?n.text:t.text,o=i.slice(xe(i,t.completedParams));return e?.completes_word!==!0?o:o.match(/\S+(?=\s*$)/)?.[0]??""}function Br(t,e){let n=Ot(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(O=>O.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(O=>O.parameter==="placeholder").map(O=>O.text).join(" "),a=Ce(r,e.prependPlaceholder),s=ue(t.text,Math.min(t.filterBase,t.text.length),a),c=s===0&&Ye(t.text,t.completedParams.length,a)?"":Xe(t.text,s,t.filterInProgress),d=o?.options??[],u=t.editingParam!=null&&t.editingAnchor!=null,g=!u&&!t.editingIdentified&&o?.type?.kind==="multi_select",m,p,f,h;if(u&&t.editingParam&&t.editingAnchor!=null){let O=t.editingParam.id,q=t.completedParams.some(ce=>ce.id===O),qe=t.caretOffset??t.editingAnchor,Q=q?"":t.text.slice(t.editingAnchor,qe);p=Q.trim(),f=t.editingParam.options,h=t.editingParam.suggestionParameter,m=t.editingParam.suggestionValueType?.kind==="traditional_autocomplete"?me(t.editingParam.options,Q).map(ce=>({...ce,matchedText:p,parameterLabel:Hn(ce.parameter)})):me(t.editingParam.options,Q)}else p=c.trim(),f=d,h=o?.parameter,m=A(o)?d.map(O=>({...O,matchedText:Rl(t,o),parameterLabel:Hn(O.parameter)})):me(d,c,t.traditionalAutocomplete);let x=t.optionSearch,y=x!=null&&h!=null&&x.parameter===h;y&&x.status==="done"&&x.query===p&&(m=f);let T=y&&x.status==="loading",P=e.showNonTappableOptions===!1;P&&(m=m.filter(O=>O.is_tappable));let b=ut(t.text,t.completedParams.length,a);e.allOption===!0&&o?.leadsWithAll===!0&&!b&&!u&&!t.editingIdentified&&c.trim()===""&&Ol(o)&&(m=kl(m,k(e.language).allOption));let v=Li(t,p),w=u?t.editingParam?.suggestionValueType?.kind==="traditional_autocomplete":A(o);!g&&!w&&(m=Jo(m,v));let S=t.editingIdentified,L=u?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,C=S?S.format:Y(L),H=u?t.editingParam?.suggestionParameter:o?.parameter,F=C==="location"&&H&&e.optionOverrides?.[H]?"options":C,I=u&&F==="date-range"?De(t.editingParam):null,G=!u&&!S&&F==="date"?Cl(o?.parameter,t.identifiedParams):null,se=null,te=null,E=R(F)?Al(t):[];if(R(F)){let O=W(new Date),q=E.find(ks=>ks>=O)??null,qe=B({...t,actionableSuggestions:i}),Q=t.dateViewMonth;se=Q&&Q.key===qe?{year:Q.year,month:Q.month}:S?on(S.iso):I?on(I.start):G?on(G):q&&!u?on(q):Ll(t.editingParam?.text),m=qn(se);let ce=t.pendingRangeStart;F==="date-range"&&ce&&ce.key===qe&&(te=ce.iso)}let le=null;if(F==="time"){let O=B({...t,actionableSuggestions:i}),q=t.timeDraft;le=q&&q.key===O?{minutes:q.minutes,touched:!0}:{minutes:Ar({editingText:u?t.editingParam?.text:null,options:u?t.editingParam?.options:o?.options}),touched:!1},m=[]}let Se=null;if(F==="location"){let O=B({...t,actionableSuggestions:i}),q=t.locationSearch;if(q&&q.key===O){let{key:qe,...Q}=q;Se=Q}else Se={query:u?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};m=[]}let St=O=>P?O.is_tappable:!0,ye;if(u){let O=t.editingParam?.options??[];ye=t.editingParam!=null&&O.filter(St).length===0}else ye=o!=null&&d.filter(St).length===0;le&&(ye=!0),Se&&(ye=!0);let $e=Vr({inEditMode:u||S!=null,filteredOptionsLength:m.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||T,pillTapped:t.pillTapped,activePillHasNoOptions:ye,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),yt=$e&&t.activeDropdownIndex>=0&&!!m[t.activeDropdownIndex]?.is_tappable,In=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,M=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||T||In,Te=M&&t.skeletonOptions!==null,Ge=Te&&t.skeletonOptions?t.skeletonOptions:m,Os=Te?t.skeletonSuggestion:null,_o=g?{picked:t.multiSelectDraft?.key===B({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,Ms=_o??(Te&&t.skeletonSuggestion?.type?.kind==="multi_select"?{picked:t.skeletonPicked??[]}:null);return{segments:n,actionableSuggestions:i,filteredOptions:m,dropdownLoading:M,dropdownOptions:Ge,dropdownSuggestion:Os,skeletonExiting:In,activeFormatType:F,dateView:se,dateRangeStart:te,dateFloor:G,dateReferences:E,timeView:le,multiSelectView:_o,dropdownMultiSelect:Ms,locationView:Se,placeholderText:r,leadInText:a,optionQuery:p,isSearchingOptions:T,isDropdownOpen:$e,isActivePillSelected:yt}}function rn(t){return t.mode!=="edit"?Dl(t):Hl(t)}function _l(t,e,n){let i=t.find(A);if(!i?.options)return null;let o=e.slice(xe(e,n)).trim().toLowerCase();if(!o)return null;let r=i.completes_word===!0?o.split(/\s+/).pop()??"":o,a=i.options.filter(c=>c.is_tappable&&c.text.trim().toLowerCase()===r);if(new Set(a.map(c=>J(c,i.parameter))).size!==1)return null;let l=a[0];return{suggestion:i,option:l,matchText:l.text.trim()}}function Ur(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,a=n.find(d=>d.parameter!=="placeholder"&&!A(d));if(!a?.options||a.type?.kind==="multi_select")return null;let s=n.filter(d=>d.parameter==="placeholder").map(d=>d.text).join(" "),l=ue(e,i,Ce(s,t.prependPlaceholder)),c=Je(a.options,e,l,o,r===!0);return c?{suggestion:a,option:c,matchText:c.text}:null}function Dl(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?Ur(t):null)??_l(i,e,n):Ur(t);if(!o)return null;let{suggestion:r,option:a,matchText:s}=o,l=s.toLowerCase(),c=e.toLowerCase().lastIndexOf(l),d=c>=0?c:Math.max(0,e.length-a.text.length),u=d+s.length,g=e.slice(d,u),p=u<e.length&&e[u]===" "?u+1:u,f={id:crypto.randomUUID(),placeholder:"",parameter:J(a,r.parameter),text:g,value:a.value,kind:a.kind,suggestionParameter:r.parameter,suggestionValueType:r.type,suggestionPlaceholder:r.text,suggestionIcon:r.icon,suggestionIconSvg:r.icon_svg,...t.mode==="submit"&&A(r)?Ze(J(a,r.parameter),r.text):{},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(h=>h!==r),filterBase:p,newParamId:f.id,caretOffset:p,activeDropdownIndex:-1},caretPos:p,option:a,suggestion:r}}function Hl(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(T=>T.id===i.id))return null;let a=e.slice(o,r),s=Ct(i.options,a);if(!s)return null;let l=s.text.toLowerCase(),c=a.toLowerCase().lastIndexOf(l),d=o+Math.max(0,c),u=d+s.text.length,g=e.slice(d,u),m=u<e.length&&e[u]===" "?u+1:u,p=e.length,f={id:crypto.randomUUID(),placeholder:"",...At(i,s),text:g,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},h=n.length,x=0;for(let T=0;T<n.length;T++){let P=ne(e,n[T].text,x);if(P!==-1){if(P>=m){h=T;break}x=P+n[T].text.length}}let y=[...n];return y.splice(h,0,f),{patch:{text:e,completedParams:y,newParamId:f.id,filterBase:p,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:p,activeDropdownIndex:-1},caretPos:p,option:s}}function Gr(t){return t.slice(t.search(/\S*$/))}function qr(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function Kr(t,e){let n="",i=0;for(let o of t){let r=i;if(n+=qr(o),i+=o.length,n.length>=e.length){if(!n.startsWith(e))return null;let a=i+(t.slice(i).match(/^\p{M}*/u)?.[0].length??0),s=n.length>e.length;return{length:a,partialStart:s?r:a}}if(!e.startsWith(n))return null}return null}function $r(t,e,n,i){let o=[];return e<i&&o.push({text:t.slice(e,i),bold:!0}),i<n&&o.push({text:t.slice(i,n),bold:!0,partial:!0}),o}function Ci(t){return[...t].map(qr).join("")}function an(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(Ci),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:Ci(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,g)=>i[s+g].folded===u))continue;let c=i[s+o-1],d=Kr(c.text,a);if(d)return{typedWords:o,start:i[s].index,end:c.index+d.length,partialStart:c.index+d.partialStart}}}return null}function Ai(t,e){let n=e?an(t,e):null;if(n&&n.typedWords>1)return[{text:t.slice(0,n.start),bold:!1},...$r(t,n.start,n.end,n.partialStart),{text:t.slice(n.end),bold:!1}].filter(a=>a.text!=="");let i=e?Gr(e):"",o=Ci(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)?null:Kr(a,o);if(s){let{length:c,partialStart:d}=s;r.push(...$r(a,0,c,d))}let l=s?a.slice(s.length):a;l&&r.push({text:l,bold:!1})}return r}var Nl=6e4;function Fl(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function Wl(t){return(t??X).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function Vl(t){return Ke(t)?`Bearer ${await vt(t).getToken()}`:wt(t)}async function zr(t){try{let e=Wl(t.apiConfig?.endpoint),n=Et(t.apiConfig),i=await Vl(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&&Fl(o)<=Nl&&{keepalive:!0}})}catch{}}function fe(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var Ii=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function Bl(t,e,n){let i=Ii(t??"");if(i.length===0)return"";let r=Ii(e).slice(-i.length),a=Ii(n).slice(0,i.length);return r.join(" ")===i.join(" ")||a.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function jr(t,e){let n=t.actionableSuggestions[0];if(!n)return null;let i=A(n),o=e.parameter;if(i&&!o)return null;let r=i&&o?o:J(e,n.parameter),a=i?t.text.length:t.filterBase,s=t.text.slice(0,a),l=s.length===0&&t.text.length===0,c=s.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||c)&&t.placeholderText&&(s=`${t.placeholderText} `);let d=Math.min(xe(t.text,t.completedParams),s.length),u=!1;if(i&&n.completes_word!==!0){let S=[...s.slice(d).matchAll(/\S+/g)],L=an(e.text,s.slice(d)),C=S[S.length-(L?.typedWords??1)];s=s.slice(0,C?d+(C.index??0):Math.max(s.lastIndexOf(" ")+1,d))}else if(n.completes_word===!0){let S=[...s.slice(d).matchAll(/\S+/g)],L=S[S.length-1];s=s.slice(0,L?d+(L.index??0):Math.max(s.lastIndexOf(" ")+1,d))}else if(n.completes_word!==!1){let S=s.slice(d),L=Math.max(Yo(S,e.text),Bo(S,e));L>0&&(s=s.slice(0,s.length-L)),u=L>0}let g=s.length>0&&s[s.length-1]!==" ",m=i||n.completes_word===!0||u,p=t.activeFormatType!==void 0&&!_(t.activeFormatType)&&_(Y({type:n.type})),f=m||p?"":Bl(n.lead_in,s,e.text),h=`${s}${g?" ":""}${f?`${f} `:""}${e.text} `,y=(l||c||i&&s.length===0)&&h.length>0?h[0].toUpperCase()+h.slice(1):h,T=y.toLowerCase().lastIndexOf(e.text.toLowerCase()),P=T>=0?y.slice(T,T+e.text.length):e.text,b=i?Ze(r,n.text):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text,suggestionIcon:n.icon,suggestionIconSvg:n.icon_svg},v={id:crypto.randomUUID(),placeholder:"",...b,text:P,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:y,filterBase:y.length,completedParams:[...t.completedParams,v],newParamId:v.id,caretOffset:y.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(S=>S.text!==e.text).map(S=>S.text),key:i?r:n.parameter,position:fe(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:w}}function mt(t,e){let n=_(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,i=t.editingParam,o=i?et(i):t.actionableSuggestions[0]??null;return{skeletonOptions:n,skeletonSuggestion:n?o:null,skeletonPicked:n?e??null:null,skeletonRequested:!1}}function sn(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 ln=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=ne(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===""?sn(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(c=>c.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=At(i,e);this.deps.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(y=>y.text!==e.text).map(y=>y.text),key:a.suggestionParameter,position:fe(i.options,e.text),chip_origin:"tap"});let s=n.text.slice(0,o),l=n.text.slice(r),c=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,u=l.length===0||l[0]!==" "?`${c} `:c,g=s+u+l,m=g.length,p={id:crypto.randomUUID(),placeholder:"",...a,text:c,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(y=>y.id===i.id),h=n.completedParams.filter(y=>y.id!==i.id),x=f>=0?Math.min(f,h.length):h.length;h.splice(x,0,p),this.deps.store.set({text:g,completedParams:h,newParamId:p.id,filterBase:m,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:m,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...mt(n)}),this.deps.startSelectionAnimationTimer(),this.deps.scheduleSetCursor(m),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=rn({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 Ul=33,$l=70,Gl=120,ql=50,He="data-aia-placeholder-leaving",Ne=new WeakMap;function cn(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function Kl(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Yr(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function Xr(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Yr(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(()=>Xr(t,e),33+i)}function Qr(t,e){Yr(t,e,0),e.timer=setTimeout(()=>Xr(t,e),33)}function Jr(t,e){let n=Ne.get(t);if(e===""){n&&(cn(n),Ne.delete(t)),t.removeAttribute(He),delete t.dataset.placeholder;return}if(n?.target===e)return;if(Kl(t)){n&&cn(n),t.removeAttribute(He),Ne.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&&cn(n),Ne.set(t,i),o){t.setAttribute(He,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(He),t.isConnected&&Qr(t,i)},170);return}t.removeAttribute(He),Qr(t,i)}function Zr(t){let e=Ne.get(t);e&&(cn(e),Ne.delete(t))}var zl={selectedIso:null,selectedRange:null,rangeStart:null};function pt(t){if(!R(t.activeFormatType))return zl;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?st(i,o):null,rangeStart:t.dateRangeStart,references:t.dateReferences??[]}}let n=De(t.editingParam);return{selectedIso:n?null:nt(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart??t.dateFloor??null,floor:t.dateFloor??null,references:t.dateReferences??[]}}function Oi(t){let e=t.floor!=null&&t.highlightedIso!=null&&t.highlightedIso<t.floor?null:t.highlightedIso;return t.pendingStart?st(t.pendingStart,e??t.pendingStart):t.selected}function Mi(t,e){if(t==null)return{selected:!1,inRange:!1,reference:!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,a=!o&&!r&&(e.references?.includes(t)??!1);return{selected:o,inRange:r,reference:a}}function ki(t,e,n){return t==null?!1:t<e||n!=null&&t<n}function Ri(t,e){return t==="date"?e??null:null}var ea="https://ai-autocomplete.com";function _i(t=ea){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}}function Di(t,e,n=k()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function Hi(t){let e=a=>{a.ctrlKey||ta(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,c=i-s.clientY;n=s.clientX,i=s.clientY,a.cancelable&&!ta(a.target,t,l,c)&&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 ta(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&jl(o,i)||n!==0&&Ql(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var na=/^(auto|scroll|overlay)$/;function jl(t,e){return t.scrollHeight<=t.clientHeight||!na.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function Ql(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!na.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 ia=new WeakMap,oa=new WeakSet;function U(t,e,n){if(ia.set(t,n),oa.has(t))return;oa.add(t);let i=()=>ia.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 he(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function K(t){t.offsetWidth}var oe="magicx-aia-panel-ghost";function Fe(t){return t.closest(`.${oe}`)!==null}function $(t,e){for(let n of t.querySelectorAll(e))if(!Fe(n))return n;return null}var Ni="--aia-multi-done-fit";function Yl(t){return $(t,"[data-aia-multi-done]")}function Fi(t,e){if(!e?.isConnected)return;let n=e.ownerDocument,i=n.defaultView?.getComputedStyle(e).direction==="rtl";if(typeof n.createRange().getBoundingClientRect!="function")return;let o=e.getBoundingClientRect(),r=0;for(let a of t.querySelectorAll("[data-aia-option]")){if(Fe(a))continue;let s=n.defaultView?.getComputedStyle(a),l=Number.parseFloat(i?s?.paddingRight??"0":s?.paddingLeft??"0")||0,c=n.createTreeWalker(a,NodeFilter.SHOW_TEXT),d=n.createRange();for(let u=c.nextNode();u;u=c.nextNode()){if(!u.textContent?.trim())continue;d.selectNodeContents(u);let g=d.getBoundingClientRect();if(g.width===0)continue;let m=i?o.right-g.left:g.right-o.left;r=Math.max(r,m+l)}}r>0?e.style.setProperty(Ni,`${Math.ceil(r)}px`):e.style.removeProperty(Ni)}var Xl=40,Jl=340,Zl=340,ec=7,Wi="--aia-option-enter-delay";function Vi(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 Bi(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 aa="magicx-aia-scroll-arrow",dn="data-aia-scroll-arrow",We="data-aia-visible",sa=1e3,la=160,ca="--aia-scroll-arrow-bottom",tc="Scroll down for more options",Ui="data-aia-scrollable",nc="--aia-scroll-track-top",ic="--aia-scroll-track-height",oc="--aia-scroll-track-right",rc="--aia-scroll-thumb-top",ac="--aia-scroll-thumb-height",sc=12,lc=.5,cc="[data-aia-products-label]",ra=4,dc=8,uc=240;function mc(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,a=t.ownerDocument?.visibilityState==="hidden";if(!r||a||$i(t)){t.scrollTop=o+e,i();return}let s=n.performance?.now?.()??Date.now(),l=()=>n.performance?.now?.()??Date.now(),c=()=>{let d=Math.min(1,(l()-s)/uc),u=1-(1-d)*(1-d);t.scrollTop=o+e*u,d<1?r.call(n,c):i()};r.call(n,c)}function pc(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 da(t=document,e=k()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=aa,n.setAttribute(dn,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(pc(t)),n}function gc(t){return Math.max(1,qi(t.style.gridTemplateColumns))}function $i(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,c=v=>{if(v){if(n.hasAttribute(We))return;if(n.setAttribute(We,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),$i(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(We)&&(n.disabled=!1)},sa)}else n.removeAttribute(We),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},d=v=>{let w=0,S=v;for(;S&&S!==t;)w+=S.offsetTop,S=S.offsetParent instanceof HTMLElement?S.offsetParent:null;return w},u=()=>{let v=$(t,cc),w;if(v){let S=d(v)+v.offsetHeight/2;w=t.clientHeight-S-n.offsetHeight/2}else{let S=d(e),L=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;w=t.clientHeight-(S+e.offsetHeight)+(L>0?0:dc)}n.style.setProperty(ca,`${Math.max(0,Math.round(w))}px`)},g=v=>{let w=0,S=v;for(;S&&S!==t;)w+=S.offsetLeft,S=S.offsetParent instanceof HTMLElement?S.offsetParent:null;return w},m=null,p=(v,w)=>{let S=Math.min(1,Math.max(0,e.scrollTop/v));n.style.setProperty(rc,`${Math.round(w*S)}px`)},f=()=>{let v=e.scrollHeight-e.clientHeight,w=e.querySelector("[data-aia-option][data-aia-loading]")!==null;if(v<=ra||w){m=null,n.removeAttribute(Ui);return}let S=e.clientHeight,L=Math.round(S*lc),C=d(e)+(S-L)/2,H=t.clientWidth-(g(e)+e.offsetWidth),F=Math.min(L,Math.max(sc,Math.round(L*S/e.scrollHeight)));m={overflow:v,travel:L-F},n.style.setProperty(nc,`${Math.round(C)}px`),n.style.setProperty(ic,`${L}px`),n.style.setProperty(oc,`${Math.max(0,Math.round(H))}px`),n.style.setProperty(ac,`${F}px`),p(v,m.travel),n.setAttribute(Ui,"")},h=()=>{if(o||a!==null||s!==null)return;let v=e.querySelector("[data-aia-option][data-aia-loading]")!==null,w=e.scrollHeight-e.clientHeight-e.scrollTop;c(!v&&w>ra)},x=()=>{if(o)return;u(),f();let v=e.getAttribute("data-aia-group")??"";if(v!==r){r=v,c(!1),a!==null&&clearTimeout(a);let w=e.querySelectorAll("[data-aia-option]").length,S=$i(e)?0:Bi(w,gc(e));a=setTimeout(()=>{a=null,h()},S);return}h()},y=()=>{o||(m&&p(m.overflow,m.travel),a===null&&(c(!1),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,h()},la)))};e.addEventListener("scroll",y,{passive:!0});let T=v=>v.preventDefault(),P=()=>{let v=i?(Number.parseFloat(i.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0):0,w=Math.max(1,e.clientHeight-v);mc(e,w,i,y)};n.addEventListener("mousedown",T),n.addEventListener("click",P);let b=null;return i&&typeof i.ResizeObserver=="function"&&(b=new i.ResizeObserver(()=>{u(),f(),h()}),b.observe(e)),x(),{update:x,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",y),n.removeEventListener("mousedown",T),n.removeEventListener("click",P),b?.disconnect(),n.removeAttribute(We),n.removeAttribute(Ui),n.setAttribute("aria-hidden","true"))}}}var ua="cubic-bezier(0.25, 0.1, 0.25, 1)",fc="cubic-bezier(0.32, 0.72, 0, 1)",ma=360,pa=280,ga=320,fa=40,ha="blur(2px)",hc=160,bc=.05,Sc=/pressed/i;function ba(){return typeof performance<"u"?performance.now():Date.now()}function yc(t){for(let e of t.querySelectorAll("[data-aia-loading]"))if(!e.closest(`.${oe}`))return!0;return!1}function Tc(t){return t===null?1:1-Math.min(1,Math.max(0,(ba()-t)/hc))**1.7}function ji(t){return t.hasAttribute(dn)}function zi(t){let e=0;for(let n of Array.from(t.children))n.classList.contains(oe)||ji(n)||(e+=n.offsetHeight||0);return e}var Z=new WeakMap;function xc(t){return(Number.parseFloat(t.borderLeftWidth)||0)+(Number.parseFloat(t.borderRightWidth)||0)}function vc(t){let e=(t.ownerDocument.defaultView??window).getComputedStyle(t);return(Number.parseFloat(e.paddingLeft)||0)+(Number.parseFloat(e.paddingRight)||0)+(Number.parseFloat(e.borderLeftWidth)||0)+(Number.parseFloat(e.borderRightWidth)||0)}var Ki=new WeakMap;function Ec(t,e){return!e||typeof t.animate!="function"||t.closest('[data-animations="off"]')||t.closest('[data-aia-options-style="classic"]')?!1:!(t.ownerDocument.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)")??null)?.matches}function wc(t,e){let n=0,i="";for(let o of Array.from(t.children))o.classList.contains(oe)||(n+=1+o.getElementsByTagName("*").length,i+=`${o.textContent??""}\0`);return`${e??""}${n}${i}`}function Pc(t){let e=t.ownerDocument.createElement("div");e.className=oe,e.setAttribute("aria-hidden","true"),e.inert=!0;for(let n of Array.from(t.children))n.classList.contains(oe)||ji(n)||e.appendChild(n.cloneNode(!0));for(let n of[e,...Array.from(e.querySelectorAll("*"))]){n.removeAttribute("id"),n.removeAttribute("role"),n.removeAttribute("tabindex");for(let i of Array.from(n.classList))Sc.test(i)&&n.classList.remove(i);n.tagName==="A"&&n.removeAttribute("href"),n.tagName==="BUTTON"&&(n.disabled=!0);for(let i of Array.from(n.attributes))i.name.startsWith("aria-")&&i.name!=="aria-hidden"&&n.removeAttribute(i.name)}return e}function Lc(t,e,n,i,o){for(let a of Array.from(t.children))a.classList.contains(oe)&&a.remove();let r=Array.from(t.children).filter(a=>!ji(a));i>bc&&Cc(t,e,n,i,o);for(let a of r)a.animate([{opacity:0,filter:ha},{opacity:1,filter:"blur(0px)"}],{duration:ga,delay:fa,easing:ua,fill:"backwards"})}function Cc(t,e,n,i,o){let r=(t.ownerDocument.defaultView??window).getComputedStyle(t);e.style.cssText=["position:absolute","left:0",o>0?`width:${o-xc(r)}px`:"right:0",n?"bottom:0":"top:0",`padding:${r.padding}`,"pointer-events:none","box-sizing:border-box"].join(";"),t.appendChild(e),e.animate([{opacity:i,filter:"blur(0px)"},{opacity:0,filter:ha}],{duration:pa*i,easing:ua,fill:"forwards"}).finished.then(()=>e.remove(),()=>e.remove())}function Qi(t){let e=t[0]?.text;return e==null||e===""?null:e}function un(t,e,n){let i=n.visible,o=Ec(t,n.enabled??!0),r=Z.get(t);if(!i||!o){o||r?.glide?.cancel(),Z.set(t,{height:0,width:0,key:i?e:null,signature:"",snapshot:null,glide:o?r?.glide??null:null,loadingSince:null,contentHeight:0});return}let a=wc(t,e),s=yc(t)?r?.loadingSince??ba():null;if(r&&r.height>0&&r.glide&&r.signature===a){r.loadingSince=s;return}let l=be(t),c=t.getBoundingClientRect(),d=c.height;r?.glide?.cancel();let u=t.getBoundingClientRect(),g=u.height,m=u.width||0,p=null,f=r?l?d:r.height:0,h=r?l?c.width||0:r.width:0;r&&f>0&&(e!==r.key&&r.snapshot&&Lc(t,r.snapshot,n.anchorBottom??!1,Tc(r.loadingSince),h),p=Sa(t,{height:f,width:h},{height:g,width:m}));let x=null;e!==null&&(x=r&&r.signature===a&&r.snapshot&&!r.snapshot.isConnected?r.snapshot:Pc(t)),Z.set(t,{height:g,width:m,key:e,signature:a,snapshot:x,glide:p,loadingSince:s,contentHeight:p?zi(t):0})}function Sa(t,e,n){let i=e.width>0&&n.width>0&&Math.abs(e.width-n.width)>1;if(Math.abs(e.height-n.height)<=1&&!i)return null;let o=i?[{height:`${e.height}px`,width:`${e.width}px`},{height:`${n.height}px`,width:`${n.width}px`}]:[{height:`${e.height}px`},{height:`${n.height}px`}],r=t.animate(o,{duration:ma,easing:fc});i&&(t.setAttribute(nn,String(n.width)),n.width>e.width?t.style.setProperty(ct,`${n.width-vc(t)}px`):t.style.removeProperty(ct),Ki.set(t,r));let a=()=>{Ki.get(t)===r&&(Ki.delete(t),t.removeAttribute(nn),t.style.removeProperty(ct))};return r.finished.then(()=>{a();let s=Z.get(t);if(s?.glide!==r||(s.glide=null,s.height<=0))return;let l=t.getBoundingClientRect();l.height>0&&(s.height=l.height),l.width>0&&(s.width=l.width)},a),r}function be(t){let e=Z.get(t)?.glide??null;return e&&(e.playState==="running"||e.pending)?e:null}function Yi(t){if(!be(t))return null;let e=Z.get(t)?.height??0;return e>0?e:null}function Xi(t,e){let n=Z.get(t);n&&n.height>0&&!be(t)&&e>0&&(n.height=e)}function ya(t,{widthChanged:e}){let n=Z.get(t);if(!n||n.height<=0)return;let i=be(t);if(!i||!e&&(t.hasAttribute("data-aia-fit")||Math.abs(zi(t)-n.contentHeight)<=1))return;let o=t.getBoundingClientRect();i.cancel();let r=t.getBoundingClientRect();n.width=r.width||0,n.height=r.height,n.glide=Sa(t,{height:o.height,width:o.width||0},{height:r.height,width:n.width}),n.contentHeight=n.glide?zi(t):0}function Ji(t){Z.get(t)?.glide?.cancel(),Z.delete(t)}var Zi="data-aia-hug",Ve="--aia-panel-fit-width",eo="data-aia-full-width",Ac=36;function gt(t){t.removeAttribute(Zi)}function to(t,e,{eligible:n,loading:i}){let o=t.style.getPropertyValue(Ve);Ic(t,e,n,i),ya(t,{widthChanged:t.style.getPropertyValue(Ve)!==o})}function Ic(t,e,n,i){if(!n){t.style.removeProperty(Ve),gt(t);return}if(i){t.style.getPropertyValue(Ve)&&t.setAttribute(Zi,"");return}let o=Oc(t,e);if(o==null){t.style.removeProperty(Ve);return}t.style.setProperty(Ve,`${o}px`),t.setAttribute(Zi,"")}var Ta=new WeakMap;function Oc(t,e){if(dt())return null;let n=$(e,".aia-grid");if(!n||t.offsetWidth===0)return null;let i=$(e,"[data-aia-pillbar]"),o=[n.style.gridTemplateColumns,i?.textContent??"",...Array.from(n.querySelectorAll("[data-aia-option]"),s=>s.textContent)].join("\0"),r=Ta.get(t);if(r?.key===o)return r.width;let a=Mc(t,e,n);return Ta.set(t,{key:o,width:a}),a}function Mc(t,e,n){let i=lt(n);if(!i||i.rowWidths.some(s=>s<=0))return null;let o=Math.ceil(Math.max(...i.rowWidths)),r=Math.max(1,qi(n.style.gridTemplateColumns)),a=xa(n,t,r-1)+r*(o+Ac);return Math.ceil(Math.max(a,kc(e,t)))}function kc(t,e){let n=$(t,"[data-aia-pillbar]");if(!n)return 0;let i=n.querySelector("[data-aia-pill-scroll]")?.scrollWidth??0,o=n.querySelector("[data-aia-skip]")?.offsetWidth??0;return i+o===0?0:xa(n,e,i>0&&o>0?1:0)+i+o}function qi(t){let e=0,n=0,i=!1;for(let o of t)o==="("?e++:o===")"&&e--,e===0&&/\s/.test(o)?i=!1:i||(i=!0,n++);return n}function xa(t,e,n){let i=0;for(let o=t;o;o=o.parentElement){let r=getComputedStyle(o);if(i+=(Number.parseFloat(r.paddingLeft)||0)+(Number.parseFloat(r.paddingRight)||0)+(Number.parseFloat(r.borderLeftWidth)||0)+(Number.parseFloat(r.borderRightWidth)||0),o===t&&(i+=n*(Number.parseFloat(r.columnGap)||0)),o===e)break}return i}var Rc="[data-aia-products], [data-aia-datepicker], [data-aia-date-grid], [data-aia-time-wheel], [data-aia-location], [data-aia-see-all]";function _c(t){let e=!t.hasAttribute("data-aia-has-products")&&!t.hasAttribute(eo)&&$(t,".aia-grid [data-aia-option]")!==null&&$(t,Rc)===null,n=$(t,".aia-grid [data-aia-option][data-aia-loading]")!==null;e||gt(t),to(t,t,{eligible:e,loading:n})}var va="data-aia-key";function ee(t,e,n){let i=new Map;for(let a of Array.from(t.children)){let s=a.getAttribute(va);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 c=i.get(l);c||(c=n.create(s,a),c.setAttribute(va,l)),n.update?.(c,s,a),t.children[a]!==c&&t.insertBefore(c,t.children[a]??null),r.push(c)}for(let[a,s]of i)o.has(a)||s.remove();return r}function Ea(t,e){if(!e.interactive)return null;let n=e.options[he(t)];return n?.is_tappable?n:null}var Dc={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=Ea(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")&&Ea(t,e)&&e.callbacks.onHighlight(he(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,he(t))}};function Pa(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=Fc(),t.appendChild(l),K(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}U(l,Dc,{options:e,callbacks:a,interactive:s});let c=l.querySelector(".magicx-aia-datepicker-month");c&&(c.textContent=Un(o));let d=l.querySelector(".magicx-aia-datepicker-grid");d&&Hc(d,e,n,i,r)}function Hc(t,e,n,i,o){let r=W(new Date),a=Oi({pendingStart:o.rangeStart,highlightedIso:z(e[n]),selected:o.selectedRange,floor:o.floor});ee(t,e,{keyOf:(s,l)=>z(s)??`pad-${l}`,create:s=>Nc(s),update:(s,l,c)=>{let d=z(l),u=Mi(d,{selectedIso:o.selectedIso,range:a,references:o.references}),g=c===n&&l.is_tappable;s.id=`${i}-option-${c}`,s.dataset.aiaIndex=String(c),s.setAttribute("aria-selected",String(g)),s.classList.toggle("magicx-aia-date-cell--past",ki(d,r,o.floor)),s.classList.toggle("magicx-aia-date-cell--highlighted",g),s.classList.toggle("magicx-aia-date-cell--today",d!=null&&d===r),s.classList.toggle("magicx-aia-date-cell--selected",u.selected),s.classList.toggle("magicx-aia-date-cell--in-range",u.inRange),s.classList.toggle("magicx-aia-date-cell--reference",u.reference)}})}function Nc(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=Kn(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 Fc(){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(wa("prev","Previous month","\u2039"),n,wa("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 wa(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 Wc='<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>',La="data-aia-location-body";function Vc(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=Wc;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 Bc(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 Ca(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(La)!==r){for(let s of Array.from(t.children))s.hasAttribute("data-aia-location-row")||s.remove();let a=Bc(r,n);a&&t.appendChild(a),t.setAttribute(La,r)}ee(t,o,{keyOf:(a,s)=>`${s}:${a.id}`,create:a=>Vc(a),update:(a,s,l)=>{let c=l===e.highlighted;a.classList.toggle("magicx-aia-location-row--highlighted",c),a.setAttribute("aria-selected",String(c)),a.setAttribute("data-aia-index",String(l)),a.id=i(l)}})}var re=new WeakMap,Uc=0,we=new WeakMap,$c='<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>',Pe=t=>Ht(t.input)===t.input;function Aa(t,e){let n=Ht(t);if(n instanceof HTMLElement&&n!==e.input&&n!==D(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=ve(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Gc(t,e,n){if(!(!(n instanceof HTMLElement)||n===e.returnTo||t.contains(n))&&n!==D(t).body&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=ve(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function qc(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=it(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=D(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var Kc={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&Be(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function Be(t,e=!1){let n=we.get(t),i=re.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&Pe(n)&&(n.returning=!0,qc(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function zc(t){let e=we.get(t),n=re.get(t);if(!(!e||!n||Pe(e))){if(Aa(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!Pe(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function jc(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++Uc}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=$c;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,wasReediting:!1};return t.addEventListener("mousedown",a=>{!(a.target instanceof Node)||!n.contains(a.target)||(a.stopPropagation(),Aa(t,r),re.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>re.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",a=>{Gc(t,r,a.relatedTarget),re.get(t)?.callbacks.onLocationFocusChange(!0)}),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,re.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",a=>{let s=re.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;Be(t,!0),s.callbacks.onLocationCommit();return;case"Escape":a.preventDefault(),a.stopPropagation(),r.declined=!0,Be(t);return;case"Backspace":if(i.value!=="")return;a.preventDefault(),r.declined=!0,Be(t);return}}),we.set(t,r),r}function Ia(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=we.get(e);n&&(Pe(n)&&Be(e),n.declined=!1,n.input.tabIndex=-1)}}function Oa(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=we.get(r);l&&Pe(l)&&Be(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let a=we.get(r)??jc(r,n);a.input.tabIndex=0,re.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),U(a.results,Kc,re.get(r)),a.input.value!==e.query&&!Pe(a)&&(a.input.value=e.query);let s=l=>`${r?.id}-row-${l}`;if(Ca(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"),o.inputFocused){let l=o.reediting??!1;l&&!a.wasReediting&&(a.declined=!1),a.wasReediting=l}if(a.widgetFocused=o.inputFocused??!1,o.inputFocused){if(o.reediting&&!a.declined&&o.interactive!==!1&&!Pe(a)){let l=r;queueMicrotask(()=>{l.isConnected&&!we.get(l)?.declined&&zc(l)})}}else{let l=a;setTimeout(()=>{if(l.widgetFocused)return;let c=l.returnTo;c&&Ht(c)===c||(l.declined=!1)},0)}}var Qc={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},Ma=[125,69];function ka(t,e){return e?1:t===0?.7:t===1?.4:.2}function mn(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,Qc,{onSelectPill:i,loading:r}),r&&e.length===0){s.setAttribute("data-aia-pill-list-loading",""),s.innerHTML="";for(let l=0;l<Ma.length;l++){let c=Ma[l],d=document.createElement("span");d.setAttribute("data-aia-pill-skeleton",""),d.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,d.style.width=`${c}px`,d.style.setProperty("--aia-pill-opacity",String(ka(l,!1))),s.appendChild(d)}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();ee(s,e,{keyOf:l=>`${l.type?.kind??""}|${Ae(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let c=document.createElement("button");if(c.type="button",c.tabIndex=-1,c.setAttribute("data-aia-pill",""),c.setAttribute("contenteditable","false"),Ae(l)){c.setAttribute("data-aia-smart-suggestion",A(l)?"header":"");let d=document.createElement("span");d.className="magicx-aia-smart-suggestion-text",d.textContent=l.text;let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-sparkle",u.innerHTML=Wn,c.append(d,u)}else c.textContent=l.text;return c.disabled=!0,c},update:(l,c,d)=>{let u=l,g=a&&d===n&&!r,m=["magicx-aia-pill"];o&&m.push("magicx-aia-pill--rounded"),r&&m.push("magicx-aia-pill--skeleton"),u.className=m.join(" "),u.style.width="",u.style.setProperty("--aia-pill-opacity",String(ka(d,g))),u.dataset.aiaPillIndex=String(d),u.toggleAttribute("data-aia-pill-active",d===n),r?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),K(s);for(let l of s.querySelectorAll("[data-aia-pill]"))l.disabled=r}function no(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var Yc=32;function Ra(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 io(t){let e=n=>{let i=Ra(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var _a=Intl.Segmenter,Da=_a?new _a(void 0,{granularity:"grapheme"}):null;function oo(t){let e=t.trim().normalize("NFC").toUpperCase();if(Da)for(let n of Da.segment(e))return n.segment;return Array.from(e)[0]??"?"}var ro=120,Xc=360;function Jc(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 Ha(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=Jc(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 ao(t,e){let n=Ha(t,e);return n===t?[t]:[n,t]}function so(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 pn(t){let e=t?.trim();return e?ao(e,360):[]}function Zc(t){return pn(t)[0]}var gn=new WeakMap,co=new WeakMap,Fa=new WeakMap;function Wa(t,e,n,i,o,r="row",a="image",s=k(),l){let c=t.querySelector(".magicx-aia-products");if(e.length===0){c?.remove();return}if(!c){c=document.createElement("section"),c.className="magicx-aia-products",c.setAttribute("data-aia-products",""),c.setAttribute("role","group"),c.setAttribute("aria-labelledby",`${n}-products-label`);let g=document.createElement("div");g.className="magicx-aia-products-label",g.id=`${n}-products-label`,g.setAttribute("data-aia-products-label",""),g.textContent=s.products;let m=document.createElement("div");m.className="magicx-aia-products-row",m.setAttribute("data-aia-products-row",""),io(m),c.append(g,m),t.appendChild(c)}c.setAttribute("data-aia-products-layout",r);let d=c.querySelector(".magicx-aia-products-label");d&&d.textContent!==s.products&&(d.textContent=s.products);let u=c.querySelector(".magicx-aia-products-row");if(u){ee(u,e,{keyOf:g=>id(g,!!l),create:g=>od(g,i,o,a,s,l),update:(g,m,p)=>{gn.set(g,m),ed(g,m.price,m.compareAtPrice),g.id=`${n}-product-${p}`,g.dataset.aiaIndex=String(p),Fa.get(g)?.(a);let f=g.querySelector(".magicx-aia-product-badge");f&&f.textContent!==s.soldOut&&(f.textContent=s.soldOut);let h=g.querySelector(".magicx-aia-product-cart");h&&h.setAttribute("aria-label",Va(m,s))}}),K(u);for(let g of u.querySelectorAll("[data-aia-product]")){let m=co.get(g);m&&(co.delete(g),m())}}}function uo(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)Fe(i)||(i.tabIndex=e?0:-1)}function ed(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 Na(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 Va(t,e){return`${e.addToCart}: ${t.title}`}var lo="http://www.w3.org/2000/svg";function td(){let t=document.createElementNS(lo,"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(lo,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(lo,"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 nd(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",Va(e,o)),r.tabIndex=0,r.appendChild(td());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(gn.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 id(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 od(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=pn(t.imageUrl),c=l[0],d=!!c,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=oo(t.title))};if(Fa.set(a,f=>{f!==i&&(i=f,d||u())}),c){let f=document.createElement("img"),h=0;f.onload=()=>{s.setAttribute("data-aia-image-loaded",""),Na(a,so(f.naturalWidth,f.naturalHeight))},f.onerror=()=>{let x=l[++h];if(x){f.src=x;return}d=!1,Na(a,null),u()},f.className="magicx-aia-product-image",f.src=c,f.alt="",f.loading="lazy",f.decoding="async",s.appendChild(f)}else u();a.appendChild(s);let g=document.createElement("span");if(g.className="magicx-aia-product-body",t.vendor){let f=document.createElement("span");f.className="magicx-aia-product-vendor",f.textContent=t.vendor,g.appendChild(f)}let m=document.createElement("span");if(m.className="magicx-aia-product-title",m.textContent=t.title,g.appendChild(m),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,g.appendChild(f)}a.appendChild(g);let p=r&&t.available!==!1?nd(a,t,r,n,o):null;return p&&(a.setAttribute("data-aia-product-has-cart",""),a.appendChild(p.el)),co.set(a,()=>{p?.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(gn.get(a)??t))})}),a.addEventListener("keydown",f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),e(gn.get(a)??t))}),a.addEventListener("focus",()=>n(!0)),a.addEventListener("blur",f=>{f.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),a}var rd=10,ad=44;function mo(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 Ba="http://www.w3.org/2000/svg",sd=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function ld(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 cd=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],dd=/^[a-zA-Z0-9#.,%\s()-]+$/;function ud(t){let e=[];for(let n of cd){let i=t.getAttribute(n);i===null||!dd.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function Ua(t){for(let e of Array.from(t.attributes))ld(e.name,e.value)&&t.removeAttribute(e.name);ud(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!sd.has(n.localName)||n.namespaceURI!==Ba?n.remove():Ua(n)}else e.remove()}function ae(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!==Ba||e.getElementsByTagName("parsererror").length>0?null:(Ua(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function fn(t){return t.text}function Le(t){return ft(t)[0]??null}function ft(t){let e=md(t);return e?ao(e,120):[]}function md(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 ht(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var $a={one:"item",other:"items"};function pd(t,e=$a){let n=ht(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function Ga(t){return Le(t.image_url)!==null}var hn=new Map;function gd(t){let e=t.icon_svg;if(!e)return!1;let n=hn.get(e);return n===void 0&&(n=ae(e)!==null,hn.size>=256&&hn.clear(),hn.set(e,n)),n}function po(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&Ga(i)||e&&gd(i))}var qa=new WeakMap;function fd(t,e,n){let i=e.length,o=dt(),r=qa.get(t),a=n&&r&&wi(r.options,e)?r.plan:null,s=!a&&!n&&vi(i,o)?lt(t):null,l=a??Ei(i,o,s?.rowWidths??null,s?.gridWidth??null);return n||qa.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((c,d)=>{c.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(d))}),l.cols}function Ka(t,e){if(e.loading||!e.interactive)return null;let n=e.options[he(t)];return n?.is_tappable?n:null}var hd={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=Ka(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!mo(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)=>{Ka(t,e)&&e.onHighlight(he(t))},onLeave:(t,e)=>e.onHighlight(-1,he(t))};function za(t,e,n,i,o,r,a,s="",l="below",c=!0,d=!0,u=!0,g=!0,m){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)),U(p,hd,{options:e,onSelect:i,onHighlight:o,loading:a,interactive:g});let f=p.dataset.aiaGroup!==s;p.dataset.aiaGroup=s;let h=po(e,c,d);bd(p,e,n,r,a,{showIcons:c&&h,showImages:d&&h,showCounts:u,picked:m});let x=fd(p,e,a);Sd(p,e.length,x,a,l),f&&(p.scrollTop=0)}function bd(t,e,n,i,o,r){let a=o?"1":"0",s=t.dataset.aiaGroup??"",{showIcons:l,showImages:c,showCounts:d}=r,u=l?p=>p.icon??p.icon_svg??"":()=>"",g=c?p=>`${Le(p.image_url)??""}${(p.imageCollage??[]).join("")}`:()=>"",m=d?p=>ht(p.item_count)??"":()=>"";ee(t,e,{keyOf:p=>`${p.text}\0${p.parameter??""}\0${p.parameterLabel??""}\0${u(p)}\0${g(p)}\0${m(p)}\0${a}\0${s}`,create:(p,f)=>{let h=yd(p,o,r);return o||(h.dataset.aiaEntering=""),h},update:(p,f,h)=>{if(go.get(p)!==(f.matchedText??"")){let T=p.querySelector(".magicx-aia-option-text");T&&ja(T,f),go.set(p,f.matchedText??"")}let x=h===n&&!o;p.id=`${i}-option-${h}`,p.dataset.aiaIndex=String(h),p.setAttribute("aria-selected",String(r.picked?r.picked.includes(f.text):x));let y=p.querySelector(".magicx-aia-checkbox");r.picked&&f.is_tappable?(y||(y=document.createElement("span"),y.className="magicx-aia-checkbox",y.setAttribute("aria-hidden","true"),p.querySelector(".magicx-aia-option-content")?.prepend(y)),y.dataset.checked=String(r.picked.includes(f.text)),y.textContent=r.picked.includes(f.text)?"\u2713":""):y?.remove(),p.classList.toggle("magicx-aia-option--highlighted",x),p.classList.toggle("magicx-aia-option--live-match",!!f.liveMatch&&!o)}})}function Sd(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(Wi,`${Vi(a,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var go=new WeakMap;function ja(t,e){if(t.replaceChildren(),e.matchedText)for(let n of Ai(fn(e),e.matchedText))if(n.bold){let i=document.createElement("strong");i.className="magicx-aia-option-match",n.partial&&i.setAttribute("data-aia-match-partial",""),i.textContent=n.text,t.appendChild(i)}else t.appendChild(document.createTextNode(n.text));else t.appendChild(document.createTextNode(fn(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 yd(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?ft(t.image_url):[],c=l[0];if(c){let m=document.createElement("span");m.className="magicx-aia-option-image",m.setAttribute("aria-hidden","true");let p=(t.imageCollage??[]).map(f=>ft(f)).filter(f=>f.length>0);p.length>1&&m.setAttribute("data-aia-collage",String(p.length));for(let f of p.length>1?p:[l]){let h=document.createElement("img");h.setAttribute("alt",""),h.setAttribute("loading","lazy"),h.setAttribute("decoding","async"),h.setAttribute("referrerpolicy","no-referrer"),h.setAttribute("draggable","false");let x=0;h.onload=()=>m.setAttribute("data-aia-image-loaded",""),h.onerror=()=>{let y=f[++x];y?h.src=y:h.hidden=!0},h.src=f[0],m.appendChild(h)}s.appendChild(m),r.dataset.aiaImage=""}let d=!c&&n&&t.icon_svg?ae(t.icon_svg):null;if(d){let m=document.createElement("span");m.className="magicx-aia-option-icon",m.setAttribute("aria-hidden","true"),m.innerHTML=d,s.appendChild(m),t.icon&&(r.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",ja(u,t),go.set(r,t.matchedText??""),s.appendChild(u),t.tag){let m=document.createElement("span");m.className="magicx-aia-option-tag",m.textContent=t.tag,s.appendChild(m)}let g=o?ht(t.item_count):null;if(g!==null){let m=document.createElement("span");m.className="magicx-aia-option-count",m.textContent=g,s.appendChild(m),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(s),r}var Td=120,xd={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(zt(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},Ya=new WeakMap,Qa=new WeakMap;function Xa(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=wd(),t.appendChild(r),K(r);let c=r.querySelector("[data-aia-time-done]");c&&(c.disabled=!1)}let a={view:e,callbacks:i,interactive:o};Ya.set(r,a),U(r,xd,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=$t(e.minutes));for(let c of qt){let d=r.querySelector(`[data-aia-time-column="${c}"]`);d&&vd(d,c,e.minutes)}}function vd(t,e,n){let i=Kt(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=bn(t);if(o.settle)return;let r=i*Gt;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function bn(t){let e=Qa.get(t);return e||(e={syncedTop:null,settle:null},Qa.set(t,e)),e}function Ed(t,e,n){let i=bn(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(()=>Ja(t,e,n),Td)}function Ja(t,e,n){let i=bn(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=Ya.get(t);if(!o||!o.interactive)return;let r=ui(n,e.scrollTop);r!==Kt(n,o.view.minutes)&&o.callbacks.onTimeChange(zt(n,o.view.minutes,r))}function wd(){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 qt){if(r==="minute"){let a=document.createElement("span");a.className="magicx-aia-time-wheel-separator",a.textContent=":",n.appendChild(a)}n.appendChild(Pd(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 Pd(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),di(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",()=>Ed(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{bn(n).settle&&Ja(t,n,e)}),n}var Ue="data-aia-fit",Sn="--aia-dropdown-fit-height",Za=8,Ld=160;function fo({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,a=null,s=null,l=null,c=!1,d=()=>{t.removeAttribute(Ue),t.style.removeProperty(Sn)},u=()=>{if(be(t)){c=!0;return}c=!1,Xi(t,t.getBoundingClientRect().height)},g=y=>`${r}|${(y??t).scrollHeight}|${t.offsetWidth}`,m=y=>s?.key===g(y)?s.height:null,p=y=>{let T=g(y);if(s?.key===T)return s.height;let P=y?.scrollTop??0;t.removeAttribute(Ue);let b=t.offsetHeight;return t.setAttribute(Ue,""),y&&P&&(y.scrollTop=P),s={key:T,height:b},b},f=()=>{if(i)return;if(!e()){o=!1;return}let y=be(t),T=y?Yi(t):null;y&&l!==y&&(l=y,y.finished.then(h,h)),!y&&c&&u(),o||(o=!0,d());let P=t.hasAttribute(Ue),b=$(t,".aia-grid")?.getAttribute("data-aia-group")??null,v=b!==r;r=b;let w=Ad(t,n);if(w===null)return;let S=Cd(t);if(P){let H=y?m(S):p(S);if(H!==null&&H<=w){d(),u();return}}else if((T??t.offsetHeight)<=w)return;let L=`${Math.max(Ld,Math.floor(w))}px`,C=t.style.getPropertyValue(Sn)!==L;C&&t.style.setProperty(Sn,L),P?v&&S&&(S.scrollTop=0):t.setAttribute(Ue,""),(C||!P)&&u()},h=()=>{i||a!==null||!n||(a=n.requestAnimationFrame(()=>{a=null,f()}))},x=n?.visualViewport??null;return x?.addEventListener("resize",h),x?.addEventListener("scroll",h),n?.addEventListener("resize",h),n?.addEventListener("scroll",h,{capture:!0,passive:!0}),f(),{update:f,destroy(){i||(i=!0,a!==null&&n?.cancelAnimationFrame(a),x?.removeEventListener("resize",h),x?.removeEventListener("scroll",h),n?.removeEventListener("resize",h),n?.removeEventListener("scroll",h,{capture:!0}))}}}function Cd(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function Ad(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-Za:i+o-s-Za}var Id=[159,119,164];function xn(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()),Hi(e),e}var yn=new WeakMap;function Od(t,e,n){let i=yn.get(t);if(i||(i={button:da(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),yn.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 Tn=new WeakMap;function es(t){let e=Tn.get(t);if(e){e.update();return}Tn.set(t,fo({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function ho(t){Tn.get(t)?.destroy(),Tn.delete(t),Ji(t);let e=yn.get(t);e&&(e.controller?.destroy(),yn.delete(t))}function vn(t,e){let n=e.strings??k(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:a,showPills:s,isActivePillSelected:l,onSelect:c,onHighlight:d,onPillClick:u,onSkip:g}=e,m=Fn(e.pills,n.keepTyping),p=Vn(m),f=s&&m.length>0,h=i.length>0,x=e.products.length>0,y=e.formatType==="time"&&e.timeView!=null,T=e.formatType==="location"&&e.locationView!=null,P=r&&(h||f||a||x||y||T);if(P?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"),!P){uo(t,!1),Ia(t),es(t),un(t,null,{visible:!1});return}x?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute(eo,e.fullWidth===!0),gt(t),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let b=t.querySelector(".aia-stack");b||(b=document.createElement("div"),b.className="aia-stack",b.style.setProperty("--aia-stack-space","8px"),t.appendChild(b));let v=e.showSkipButton&&p&&!e.isInputEmpty,w=f||a&&s||v,S=b.querySelector(".magicx-aia-pill-bar");if(w){S||(S=document.createElement("div"),S.className="magicx-aia-pill-bar aia-cluster",S.setAttribute("data-nowrap",""),S.setAttribute("data-aia-pillbar",""),b.insertBefore(S,b.firstChild));let te=f||a&&s,E=S.querySelector(".magicx-aia-pill-scroll");te?(E||(E=document.createElement("span"),E.className="magicx-aia-pill-scroll",E.setAttribute("data-aia-pill-scroll",""),S.insertBefore(E,S.firstChild)),mn(E,m,0,u,!0,a,l)):E&&E.remove(),Rd(S,v,a||e.skipDisabled,m[0],g,n)}else S&&S.remove();let L=e.suggestions[0],C=L?`${L.parameter} ${L.text}`:"",H=R(e.formatType),F=H&&!a;za(b,H?[]:i,o,c,d,e.listboxId,a,C,e.optionsPosition??"below",e.showOptionIcons??!0,e.showOptionImages??!0,e.showOptionCounts??!0,!e.skipDisabled,e.multiSelectView?.picked),t.setAttribute("aria-multiselectable",String(!!e.multiSelectView)),Wd(b,!!e.multiSelectView,e.skipDisabled||a,e.onMultiSelectCommit,n.done),Od(t,b.querySelector(".aia-grid"),n),Pa(b,F?i:[],o,e.listboxId,F?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart,floor:Ri(e.formatType,e.dateRangeStart),references:e.dateReferences??[]},{onSelect:c,onHighlight:d,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),Xa(b,e.formatType==="time"&&!a?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),Oa(b,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,reediting:e.isReediting??!1});let I=b.querySelector(".magicx-aia-skeleton-bars");if(a&&(!h||_(e.formatType))){if(!I){I=document.createElement("div"),I.className="magicx-aia-skeleton-bars",I.setAttribute("data-aia-skeleton-bars","");for(let te of Id){let E=document.createElement("span");E.className="magicx-aia-skeleton-bar",E.style.width=`${te}px`,I.appendChild(E)}b.appendChild(I)}}else I&&I.remove();Wa(b,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart),uo(t,!a),Nd(b,e.onSeeAllResults,n.seeAllResults);let G=b.querySelector(".magicx-aia-footer")??Dd(n),se=o>=0&&!!i[o]?.is_tappable;_d(G,Di(se,e.isInputEmpty,n)),G.isConnected||b.appendChild(G),Md(b,[".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","[data-aia-see-all]",".magicx-aia-footer"]),Fi(b,b.querySelector(".magicx-aia-multi-done")),to(t,b,{eligible:h&&!x&&!H&&!y&&!T&&!e.onSeeAllResults&&!e.fullWidth,loading:a}),es(t),un(t,Qi(s?m:[]),{visible:!0,anchorBottom:e.optionsPosition==="above"})}function Md(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 kd={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function Rd(t,e,n,i,o,r){U(t,kd,{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),K(a)),a.textContent!==r.skip&&(a.textContent=r.skip),a.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),a.disabled=n}function _d(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 Dd(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=_i(),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 Hd={itemSelector:".magicx-aia-see-all",onClick:(t,e,n)=>{e.submit&&(n.stopPropagation(),e.submit())}};function Nd(t,e,n){let i=t.querySelector(":scope > [data-aia-see-all]");if(!e){i?.remove();return}if(!i){i=document.createElement("div"),i.className="magicx-aia-see-all-row",i.dataset.aiaSeeAll="";let r=document.createElement("button");r.type="button",r.tabIndex=-1,r.className="magicx-aia-see-all",r.disabled=!0,i.appendChild(r),t.appendChild(i),K(r)}U(i,Hd,{submit:e});let o=i.querySelector("button");o&&(o.textContent!==n&&(o.textContent=n),o.disabled=!1)}var Fd={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function Wd(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.setAttribute("data-aia-multi-done",""),s.disabled=!0,r.appendChild(s),t.appendChild(r),K(s)}U(r,Fd,{commit:i,disabled:n});let a=r.querySelector("button");a&&(a.textContent=o,a.disabled=n)}function ts(t,e){let n=xn(e.listboxId);return t.appendChild(n),{dropdown:n}}function bo(t,e,n){let i=pt(e);vn(t.dropdown,{strings:n.strings,suggestions:e.editingIdentified?[{parameter:e.editingIdentified.parameter,text:ie(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,dateReferences:i.references,timeView:e.timeView,multiSelectView:e.dropdownMultiSelect,locationView:e.locationView,isReediting:e.editingParam!=null,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 Vd="[data-aia-chip-remove]";function So(t,e){let n=e;if(!n||n.nodeType===void 0)return null;let o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(Vd)??null;return o&&t.contains(o)?o:null}function yo(t,e){let n=null,i=c=>{n=null;let d=c;if(d.button)return;let u=So(t,c.target);if(!u)return;c.preventDefault(),c.stopPropagation();let g=u.dataset.aiaChipRemove,m=d.pointerType==="touch"||d.pointerType==="pen";n={id:g,x:d.clientX,y:d.clientY,pending:m},!m&&g&&e(g)},o=c=>{if(!n?.pending)return;n.pending=!1;let d=c;if(Math.hypot(d.clientX-n.x,d.clientY-n.y)>10)return;let g=t.getRootNode().elementFromPoint?.(d.clientX,d.clientY)??c.target,m=So(t,g)?.dataset.aiaChipRemove;m&&m===n.id&&e(m)},r=()=>{n&&(n.pending=!1)},a=c=>{!n&&!So(t,c.target)||(c.cancelable&&c.preventDefault(),c.type==="click"&&(c.stopImmediatePropagation(),n=null))},s={capture:!0},l={capture:!0,passive:!1};return t.addEventListener("pointerdown",i,s),t.addEventListener("pointerup",o,s),t.addEventListener("pointercancel",r,s),t.addEventListener("touchstart",a,l),t.addEventListener("mousedown",a,s),t.addEventListener("click",a,s),()=>{t.removeEventListener("pointerdown",i,s),t.removeEventListener("pointerup",o,s),t.removeEventListener("pointercancel",r,s),t.removeEventListener("touchstart",a,l),t.removeEventListener("mousedown",a,s),t.removeEventListener("click",a,s)}}var Bd=340;function To(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let d=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let u=t.getBoundingClientRect().height;if(u!==0){if(d===0||Math.abs(u-d)<.5){t.style.height=`${u}px`;return}t.style.height=`${d}px`,t.getBoundingClientRect(),t.style.height=`${u}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(d=>{for(let g of d)if(g.target!==t){n();return}let u=t.getBoundingClientRect().width;Math.abs(u-i)<.5||(i=u,n())}):null,r=()=>{for(let d of Array.from(t.children))o?.observe(d)},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 c=!1;return t.ownerDocument.fonts?.ready.then(()=>{c||n()}),n(),()=>{c=!0,t.removeEventListener("load",s,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(a),t.style.height=""}}var rs=2600,Ud=3,wo="data-aia-hint",Eo="magicx-aia-hint",as="data-aia-hint-el",$d={position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--aia-hint-color, #999)",userSelect:"none"},Gd=280,qd=320,Kd=380,xo="cubic-bezier(0.25, 0.1, 0.25, 1)",ns=new Set(["a","an","the","some","my"]),Pn=new WeakMap;function zd(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function is(t,e){let n=t.text.trim(),i=e.trim(),o=[];i&&n.toLowerCase().startsWith(`${i.toLowerCase()} `)&&(n=n.slice(i.length+1).trim());let r=i?i.split(/\s+/):[],a=null;r.length>1&&ns.has(r[r.length-1].toLowerCase())&&(a=r.pop()??null);let s=r.join(" ");s&&o.push({key:`w:${s.toLowerCase()}`,text:s,icon:null});let l=null,[c,...d]=n.split(/\s+/);d.length&&c&&ns.has(c.toLowerCase())&&(l=c,n=d.join(" "));let u=l??a;u&&o.push({key:`w:${u.toLowerCase()}`,text:u,icon:null});let g=t.icon_svg?ae(t.icon_svg):null;return o.push({key:`c:${g??""}:${n}`,text:n,icon:g}),o}function jd(t,e){let n=t.createElement("span");if(n.className=`${Eo}__word`,n.dataset.key=e.key,n.style.display="inline-block",e.icon){let i=t.createElement("span");i.className=`${Eo}__icon`,Object.assign(i.style,{display:"inline-flex",width:"1em",height:"1em",marginRight:"0.25em",verticalAlign:"-0.125em",opacity:"var(--aia-hint-icon-opacity, 0.7)"}),i.innerHTML=e.icon;let o=i.querySelector("svg");o&&(o.style.width="100%",o.style.height="100%"),n.appendChild(i)}return n.appendChild(t.createTextNode(e.text)),n}function vo(t,e,n){return typeof t.animate=="function"?t.animate(e,n):null}function En(t,e){let n=t.ownerDocument?.defaultView;if(!n)return;let i=n.getComputedStyle(t),o=d=>Number.parseFloat(d)||0,r=t.offsetLeft+o(i.borderLeftWidth)+o(i.paddingLeft),a=t.offsetTop+o(i.borderTopWidth)+o(i.paddingTop),s=t.clientWidth-o(i.paddingLeft)-o(i.paddingRight),l=t.offsetParent instanceof HTMLElement?t.offsetParent.clientWidth-r:0,c=Math.max(s,l);e.style.left=`${r}px`,e.style.top=`${a}px`,c>0&&(e.style.maxWidth=`${c}px`),e.style.font=i.font,e.style.lineHeight=i.lineHeight,e.style.letterSpacing=i.letterSpacing,e.style.fontWeight="var(--aia-hint-font-weight, 300)"}function os(t,e,n,i){let{el:o}=t,r=o.ownerDocument,a=new Map;for(let m of Array.from(o.children))m.dataset.leaving===void 0&&m.dataset.key&&a.set(m.dataset.key,m);let s=new Map;for(let[m,p]of a)s.set(m,p.offsetLeft);let l=new Set(e.map(m=>m.key));for(let[m,p]of a){if(l.has(m))continue;if(!n){p.remove();continue}p.dataset.leaving="",p.style.position="absolute",p.style.left=`${s.get(m)??0}px`,p.style.top=`${p.offsetTop}px`;let f=vo(p,[{opacity:1,filter:"blur(0)"},{opacity:0,filter:"blur(2px)"}],{duration:Gd,easing:xo,fill:"forwards"});f?f.onfinish=()=>p.remove():p.remove()}let c=Array.from(o.children).filter(m=>m.dataset.leaving!==void 0),d=[];if(e.forEach((m,p)=>{p>0&&d.push(r.createTextNode(" ")),d.push(a.get(m.key)??jd(r,m))}),o.replaceChildren(...d,...c),!n)return;let u=new Map;for(let m of d)m instanceof HTMLElement&&m.dataset.key&&u.set(m.dataset.key,m);let g=0;for(let m of e){let p=u.get(m.key);if(p)if(!a.has(m.key))vo(p,[{opacity:0,filter:"blur(2px)"},{opacity:1,filter:"blur(0)"}],{duration:qd,delay:i?80*g++:180+60*g++,easing:xo,fill:"backwards"});else{let h=(s.get(m.key)??p.offsetLeft)-p.offsetLeft;Math.abs(h)>.5&&vo(p,[{transform:`translateX(${h}px)`},{transform:"none"}],{duration:Kd,easing:xo})}}}function wn(t){let e=Pn.get(t);e&&(e.timer!==null&&clearInterval(e.timer),e.resize?.disconnect(),e.el.remove(),Pn.delete(t),t.removeAttribute(wo),t.removeAttribute("aria-placeholder"))}function ss(t,e,n,i){let o=i.filter(p=>p.text.trim()!=="").slice(0,Ud),r=t.parentElement;if(!e||o.length<2||!r){wn(t);return}let a=`${n}\0${o.map(p=>`${p.text}${p.icon_svg??""}`).join("\0")}`,s=Pn.get(t);if(s&&s.key===a&&s.el.isConnected){En(t,s.el);return}wn(t);let l=t.ownerDocument,c=l.createElement("span");c.className=Eo,c.setAttribute(as,""),c.setAttribute("aria-hidden","true"),Object.assign(c.style,$d),r.insertBefore(c,t),t.setAttribute(wo,""),n.trim()&&t.setAttribute("aria-placeholder",n.trim()),En(t,c);let d=l.defaultView,u=d?.ResizeObserver?new d.ResizeObserver(()=>{c.isConnected&&En(t,c)}):null;u?.observe(r);let g=zd(t),m={key:a,lead:n,options:o,index:0,el:c,timer:null,resize:u};Pn.set(t,m),os(m,is(o[0],n),!g,!0),!g&&(m.timer=setInterval(()=>{if(!t.isConnected||!c.isConnected){wn(t);return}t.ownerDocument?.hidden||(m.index=(m.index+1)%m.options.length,En(t,c),os(m,is(m.options[m.index],m.lead),!0,!1))},rs))}function Po(t){wn(t)}function Lo(t){return(t.find(n=>n.type?.kind!=="traditional_autocomplete")?.options??[]).filter(n=>n.is_tappable!==!1).map(n=>({text:n.text,icon_svg:n.icon_svg}))}var Qd=6,Yd=.3;function ls(t){return t<=0?"0px":`${(-Math.min(Yd,2*Qd/t)).toFixed(3)}px`}var cs=new Map;function Xd(t,e,n){let i=cs.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`;cs.set(e,s),t.style.setProperty("--aia-chip-image-fit",s)},o.src=e}function Co(t){let{input:e,segments:n,newParamId:i,editingParamId:o,placeholderText:r}=t,a=t.showChipIcons??!0,s=t.showChipImages??!0,l=t.showChipRemove??!1,c=n.length===0;e.dataset.aiaEmpty=c?"true":"false",Jr(e,c?r:""),ss(e,c,r,t.hintOptions??[]);let d=n.map(T=>T.type==="completed"?`${T.type}:${T.value}${a?T.param.icon??T.param.icon_svg??"":""}${s?Le(T.param.image_url)??"":""}${l?"x":""}`:T.type==="identified"?`${T.type}:${T.value}${T.param.id}${l?"x":""}`:`${T.type}:${T.value}`).join("\0"),u=e.dataset.segKey??"",g=e.dataset.newParamId??"",m=e.dataset.editingParamId??"";if(d===u&&(i??"")===g&&(o??"")===m)return;if(d===u){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let T of e.querySelectorAll("strong[data-param-id]")){let P=T.dataset.paramId,b=T.dataset.seg==="completed"&&P===i;T.classList.toggle("magicx-aia-shimmer-revealed",b),T.classList.toggle("magicx-aia-shimmer-sweep",b),T.classList.toggle("magicx-aia-segment--editing",P===o)}return}let p=wr(e),f=p?j(e):null;e.dataset.segKey=d,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let h=D(e),x=h.createDocumentFragment(),y=0;for(let T of n)if(y+=T.value.length,T.type==="completed"){let P=h.createElement("strong");P.dataset.seg="completed",P.dataset.paramId=T.param.id;let b=T.param.id===i,v=T.param.id===o,w=["magicx-aia-segment","magicx-aia-segment--completed"];b&&w.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),v&&w.push("magicx-aia-segment--editing"),P.className=w.join(" "),P.style.letterSpacing=ls(T.value.length);let S=s?Le(T.param.image_url):null;if(S){let C=h.createElement("span");C.className="magicx-aia-segment-image",C.setAttribute("contenteditable","false"),C.setAttribute("aria-hidden","true"),C.style.setProperty("--aia-chip-image",`url("${S}")`),Xd(C,S,h),P.appendChild(C),P.dataset.aiaImage=""}let L=!S&&a&&T.param.icon_svg?ae(T.param.icon_svg):null;if(L){let C=h.createElement("span");C.className="magicx-aia-segment-icon",C.setAttribute("contenteditable","false"),C.setAttribute("aria-hidden","true"),C.innerHTML=L,P.appendChild(C),T.param.icon&&(P.dataset.aiaIcon=T.param.icon)}P.appendChild(h.createTextNode(T.value)),l&&P.appendChild(ds(h,T.param.id)),x.appendChild(P)}else if(T.type==="identified"){let P=h.createElement("strong");P.dataset.seg="identified",P.dataset.paramId=T.param.id;let b=["magicx-aia-segment","magicx-aia-segment--completed"];T.param.id===o&&b.push("magicx-aia-segment--editing"),P.className=b.join(" "),P.style.letterSpacing=ls(T.value.length),P.textContent=T.value,l&&P.appendChild(ds(h,T.param.id)),x.appendChild(P)}else x.appendChild(h.createTextNode(T.value));e.replaceChildren(x),e.dataset.aiaTextLength=String(y),f!=null?V(e,Math.max(0,Math.min(f,y))):p&&V(e,y)}function ds(t,e){let n=t.createElement("span");return n.className="magicx-aia-segment-remove",n.setAttribute("contenteditable","false"),n.setAttribute("aria-hidden","true"),n.dataset.aiaChipRemove=e,n.innerHTML='<svg viewBox="0 0 10 10" aria-hidden="true"><path d="M2.5 2.5l5 5M7.5 2.5l-5 5"/></svg>',n}var Jd='<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 us(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=Jd.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function ms(t){let e=t.store.get();return(!!e.text||e.completedParams.length>0)&&!!t.onSubmit}function ps(t){if(!t.onSubmit)return;t.endTypedWord?.();let e=t.store.get();t.onSubmit(Ee(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields}))&&t.afterSubmit?.()}function Zd(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function gs(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 fs(t,e){let{listboxId:n}=e,i=xn(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",Zd()?"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,c=null;e.submitButton===void 0?(l=us(e.strings),o.appendChild(l),c=l):e.submitButton!==null&&(c=e.submitButton,c.hasAttribute("data-aia-submit")||c.setAttribute("data-aia-submit",""),c.setAttribute("data-aia-submit-slot",""),o.appendChild(c));let d=new AbortController,{signal:u}=d,g=!1,m=0,p=()=>{let b=Bt(a);return b.length>0&&b[0]!==b[0].toUpperCase()?b[0].toUpperCase()+b.slice(1):b},f=()=>e.handleChange(p()),h=()=>{let b=ge(a)?.node??null;if(!b||!a.contains(b))return null;let S=(b.nodeType===Node.ELEMENT_NODE?b:b.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return S&&Er(a,S)?null:S};o.addEventListener("click",b=>{b.target?.closest("[data-aia-pill]")||a.getRootNode().activeElement?.closest("[data-aia-location]")||a.focus()},{signal:u});let x=null,y=()=>{let b=e.showChipRemove??!1;b!==(x!==null)&&(x?.(),x=b?yo(a,v=>e.removeParam(v)):null)};if(y(),u.addEventListener("abort",()=>{x?.(),x=null}),a.addEventListener("input",()=>{if(g){e.handleCompositionText(p());return}m=performance.now(),f(),e.handleCaretAfterInput(j(a))},{signal:u}),D(a).addEventListener("selectionchange",()=>{let b=ge(a);if(!b||!a.contains(b.node))return;let v=b.collapsed?h():null,w=e.store.get(),S=w.editingParam?.id??w.editingIdentified?.id??null;if(v&&v!==S){e.startEditingParam(v);return}performance.now()-m<50||e.handleCaretMove(j(a))},{signal:u}),a.addEventListener("click",b=>{let v=Jn(a,b.target);v&&(e.startEditingParam(v),Zn(a,v))},{signal:u}),a.addEventListener("compositionstart",()=>{g=!0,a.setAttribute("data-aia-composing","true")},{signal:u}),a.addEventListener("compositionend",()=>{g=!1,a.removeAttribute("data-aia-composing"),f()},{signal:u}),a.addEventListener("beforeinput",b=>{let v=b,w=v.inputType;if(w==="insertParagraph"||w==="insertLineBreak"||w==="insertFromDrop"){b.preventDefault();return}if(w.startsWith("insert")||w.startsWith("delete")){let S=w.startsWith("delete")?"":v.data??"";e.replaceEditingRange(S)&&b.preventDefault()}},{signal:u}),a.addEventListener("paste",b=>{b.preventDefault();let v=(b.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!v)return;let w=D(a),S=ve(a);if(!S||!a.contains(S.startContainer))return;S.deleteContents();let L=w.createTextNode(v);S.insertNode(L),S.setStartAfter(L),ot(a,S.startContainer,S.startOffset),f()},{signal:u}),a.addEventListener("keydown",b=>e.handleKeyDown(b),{signal:u}),a.addEventListener("focus",()=>e.store.set({isFocused:!0}),{signal:u}),a.addEventListener("blur",()=>e.store.set({isFocused:!1}),{signal:u}),c&&c.addEventListener("click",b=>{ms(e)&&(b.stopPropagation(),ps(e))},{signal:u}),e.autoFocus!==!1){a.focus();let b=ge(a);(!b||!a.contains(b.node))&&ot(a,a,0)}if(typeof ResizeObserver<"u"){let b=new ResizeObserver(()=>gs(a,s));b.observe(a),d.signal.addEventListener("abort",()=>b.disconnect(),{once:!0})}let P=To(r);return d.signal.addEventListener("abort",P,{once:!0}),{input:a,inlinePillContainer:s,dropdown:i,submitButton:l,abort:d,syncChipRemove:y}}function Ao(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:a}=t,{pillPlacement:s,setActivePill:l,selectOption:c,store:d}=n;t.syncChipRemove(),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 x=n.strings??k();a.getAttribute("aria-label")!==x.submit&&a.setAttribute("aria-label",x.submit);let y=a.querySelector("svg");y&&y.getAttribute("aria-label")!==x.submit&&y.setAttribute("aria-label",x.submit);let T=!!e.text||e.completedParams.length>0;a.disabled=!T,a.toggleAttribute("data-aia-ready",T&&e.isReady)}let g=i.dataset.newParamId??"",m=e.newParamId!==null&&e.newParamId!==g;if(Co({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,hintOptions:s==="inline"?[]:Lo(e.actionableSuggestions),showChipRemove:n.showChipRemove??!1}),s==="inline"){let x=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,y=Nn(e.actionableSuggestions);x||y.length>0?mn(o,y,0,l,!1,x,e.isActivePillSelected):no(o)}else no(o);gs(i,o),m?(i.focus(),V(i,e.caretOffset??e.text.length)):e.isFocused&&Bt(i)!==e.text&&!i.hasAttribute("data-aia-composing")&&V(i,e.text.length);let p=e.editingParam?et(e.editingParam):e.editingIdentified?{parameter:e.editingIdentified.parameter,text:ie(e.editingIdentified.parameter),required:!0,options:[]}:null,f=e.dropdownSuggestion??p??e.actionableSuggestions[0],h=pt(e);vn(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:p?[p]: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:h.selectedIso,selectedDateRange:h.selectedRange,dateRangeStart:h.rangeStart,dateReferences:h.references,timeView:e.timeView,multiSelectView:e.dropdownMultiSelect,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:c,onHighlight:(x,y)=>{y!==void 0&&d.get().activeDropdownIndex!==y||d.set({activeDropdownIndex:x})},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:x=>d.set({isFocused:x}),onSeeAllResults:n.seeAllResults&&e.text.trim().length>0&&ms(n)?()=>ps(n):void 0,fullWidth:n.seeAllResults===!0})}function Io(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 c=i.shift();c;c=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[d,u]=c;for(let g of n)g(d,u)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function hs(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)},c={...a,...o(a)};r(c,l)})}}var Oo=new WeakSet,bs=new WeakMap;function ys(t){return t.nodeType===Node.DOCUMENT_NODE}function eu(t){return ys(t)?t:t.ownerDocument}function tu(t){let e=bs.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(xs),bs.set(t,i),i)}catch{return null}}function Ss(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=xs,e.appendChild(n)}function Ts(t){if(typeof document>"u")return;let e=t??document;if(Oo.has(e))return;let n=eu(e);if(ys(e)){let r=e.head??e.documentElement;if(!r)return;Ss(n,r),Oo.add(e);return}let i=tu(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):Ss(n,e),Oo.add(e)}var xs=`.aia-stack {
1
+ function R(t){return t==="date"||t==="date-range"}function _(t){return t!=="options"}function Y(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 Tt=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 _s="https://api.ai-autocomplete.com",X=`${_s}/api/suggest`,xt=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),Ho=new WeakMap;function Ke(t){return t?.type==="accessToken"}function Ds(t){if(!(!t||Ke(t)))return t}function vt(t){let e=Ho.get(t.getAccessToken);return e||(e=new Tt(t),Ho.set(t.getAccessToken,e)),e}function Et(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function wt(t){let e=Ds(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var Mn="aiaPlace",Pt=2,Wo=250,No=new Set("new san los las santa saint st fort port north south east west lake mount el la rio de palm long grand cape salt hong".split(" ")),Fo=new Set("city beach springs falls island park heights valley bay".split(" ")),Hs=new Set("a an the in at to off on of from for by near into onto around via toward towards up out and or with within".split(" "));function Vo(t){let e=Ns(t);for(;e.length>0&&Hs.has(e[0].toLowerCase().replace(/[.,]+$/,""));)e.shift();return e.join(" ")}function Ns(t){let e=t.trim().split(/\s+/).filter(Boolean);if(e.length===0)return[];let n=e[e.length-1].replace(/[.,]+$/,"");if(!n)return[];let i=e.length>1?e[e.length-2]:void 0,o=e.length>2?e[e.length-3]:void 0,r=a=>a.toLowerCase().replace(/[.,]+$/,"");return i&&o&&No.has(r(o))&&Fo.has(r(n))?[o,i,n]:i&&(No.has(r(i))||Fo.has(r(n)))?[i,n]:[n]}function Bo(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function On(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function kn(t,e){let n=On(e);if(!n)return!1;if(On(t.name)===n)return!0;for(let[,i]of t.name.matchAll(/\(([^()]*)\)/g))if(On(i)===n)return!0;return!1}function Uo(t,e){let n=e.metadata?.[Mn];if(typeof n?.name!="string")return 0;let i={id:"",name:n.name},o=[...t.matchAll(/\S+/g)];for(let r of o){let a=r.index??0,s=t.slice(a).trim().replace(/[.,]+$/,"");if(kn(i,s))return t.length-a}return 0}function Rn(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:Bo(t),is_tappable:!0,kind:null,metadata:{[Mn]:{id:t.id,name:t.name}}}}function _n(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??X,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 $o(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 ze(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var Go="skipped";function je(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:Go,kind:null}));return i.length>0?[...t,...i]:t}var Fs="0.74.4",zo="1.0",qo=!1;function Ws(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function de(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function Vs(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function Bs(t,e,n,i,o,r,a,s,l,c,d,u,g,m){let p=e.find(x=>x.parameter==="contact"&&x.metadata?.contact_account_count)?.metadata?.contact_account_count,f=typeof p=="number"?p:void 0,h=Vs();return{data:{raw_query:t,accepts_traditional_autocomplete:!0,...m&&{traditional_autocomplete_only:!0},client_option_parameters:g??[],completed_params:je(e.map(x=>Ws(x,n)),l??[]),...a&&a.length>0&&{identified_params:ze(a)},...s&&s.length>0&&{recently_suggested:s},...f!=null&&{contact_account_count:f},...c!==void 0&&{additional_context:c}},meta:{request_id:o,request_at:new Date().toISOString(),language:de(d),...h&&{timezone:h},...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:Fs,session_id:i,source:r,schema_version:zo}}}async function Ko(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function Dn(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=Bs(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,n.traditionalAutocompleteOnly),a=i?.endpoint??X,s=await jo(a,JSON.stringify(r),i,n.signal);if(!s.ok)throw new Error(`API error: ${s.status} ${s.statusText}`);return s.json()}async function jo(t,e,n,i){let o=Et(n);if(Ke(n)){let a=vt(n),s=await a.getToken(),l=await Ko(t,o,s,e,i);if(l.status===401){let c=await a.getToken(!0);l=await Ko(t,o,c,e,i)}return l}let r=wt(n);return!r&&!qo&&(qo=!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 Qe=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function Qo(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:de(n.language)}),o=await jo(t,i,n.apiConfig,n.signal);if(!o.ok)throw new Qe(o.status);return $o(await o.json())}var Lt=/[\p{L}\p{N}]/u,Us=/['\u2019-]/;function Yo(t,e,n){let i=t[e];if(i===void 0)return!1;if(Lt.test(i))return!0;let o=t[e+n];return Us.test(i)&&o!==void 0&&Lt.test(o)}function $s(t,e,n){let i=e+n.length;return!(Lt.test(n[0])&&Yo(t,e-1,-1)||Lt.test(n[n.length-1])&&Yo(t,i,1))}function ne(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($s(t,r,e))return r;o===-1&&(o=r)}r=t.indexOf(e,r+1)}return o}function N(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 d=`{{${s.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,u=m=>ne(n,s.text,m,p=>!r.some(f=>p<f.end&&p+s.text.length>f.start)),g=u(a);if(g===-1&&(g=u(0)),g!==-1){n=n.slice(0,g)+d+n.slice(g+s.text.length);let m=d.length-s.text.length;for(let p of r)p.start>=g+s.text.length&&(p.start+=m,p.end+=m);r.push({start:g,end:g+d.length}),a=g>=a?g+d.length:a+m}o.push({...s,placeholder:d})}return{rawQuery:n,completedParams:o}}function ue(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function Ce(t,e){return e===!1?"":t}function Ye(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function Xe(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 Xo(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 Jo(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function Gs(t,e){let n=Jo(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function me(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?Jo(i).trimStart():"";if(o)return t.filter(a=>!a.is_tappable||Gs(a.text,o));let r=i.toLowerCase();return t.filter(a=>!a.is_tappable||a.text.toLowerCase().includes(r))}function Ct(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 Je(t,e,n,i,o){let r=Xe(e,n,i),a=Ct(t,r);if(a||!o||!r.trim())return a;if(r===e.slice(n))return null;let s=e.lastIndexOf(" ",n-1)+1;return Ct(t,e.slice(s))}function Zo(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.selectsAll&&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 tr(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function nr(t,e){let{icon:n,icon_svg:i}=e;return!i||t.every(er)?t:t.map(o=>er(o)?o:{...o,icon:n,icon_svg:i})}function er(t){return!!(t.icon_svg||t.image_url)}function qs(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function ie(t){let e=qs(t);return e.length>0?e.join(" "):t}function J(t,e){return t.parameter||e}function Ze(t,e,n){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:n?.trim()||ie(t),...e?{suggestionHeader:e}:{}}}function et(t){return t.suggestionValueType?.kind==="traditional_autocomplete"?{parameter:t.suggestionParameter,text:t.suggestionHeader??"",required:!0,type:t.suggestionValueType,options:t.options}:{parameter:t.suggestionParameter,text:t.suggestionPlaceholder,required:!0,options:t.options}}function At(t,e){let n=J(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?Ze(n,t.suggestionHeader,e.parameter_label):{parameter:n,suggestionParameter:t.suggestionParameter,suggestionValueType:t.suggestionValueType,suggestionPlaceholder:t.suggestionPlaceholder,suggestionIcon:t.suggestionIcon,suggestionIconSvg:t.suggestionIconSvg}}function A(t){return t?.type?.kind==="traditional_autocomplete"}function Ks(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function Hn(t){return t.parameter_label?.trim()||Ks(t.parameter)}function Ae(t){return A(t)||t?.smart_suggestion===!0}function Nn(t){return t.some(A)?t.filter(e=>!A(e)):t}function Fn(t,e){return t.some(n=>A(n)&&!n.text)?t.map(n=>A(n)&&!n.text?{...n,text:e}:n):t}var Wn='<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 Vn(t){return t.some(e=>!A(e))}function ir(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 or(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 rr(t,e){let n=[],i=new Map;for(let o of[...t,...e]){if(o.parameter==="placeholder"||A(o))continue;let r=i.get(o.parameter);r||(r={parameter:o.parameter,text:o.text},i.set(o.parameter,r),n.push(r));for(let a of o.options??[])!a.is_tappable||r.options?.includes(a.text)||(r.options??(r.options=[]),r.options.push(a.text))}return n}function ar(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 It(t,e){let n=[],i=[],o=0;for(let r of e){let a=ne(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 xe(t,e){let{located:n}=It(t,e);return n.length>0?n[n.length-1].end:0}function sr(t,e,n){let i=[],o=[],r=0;for(let a of n){let s=ne(t,a.text,r,l=>!e.some(c=>l<c.end&&l+a.text.length>c.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 Ot(t,e,n=[]){let i=It(t,e).located,o=[];for(let d of i){let u=o[o.length-1];d.param.group&&u?.param.group===d.param.group?(u.end=d.end,u.params?.push(d.param)):o.push({...d,...d.param.group?{params:[d.param]}:{}})}let r=sr(t,o,n).located,a=[...o.map(d=>({start:d.start,end:d.end,segment:{type:"completed",value:t.slice(d.start,d.end),param:d.param,...d.params?{params:d.params}:{}}})),...r.map(d=>({start:d.start,end:d.end,segment:{type:"identified",value:d.param.text,param:d.param}}))].sort((d,u)=>d.start-u.start),s=[],l=0;for(let d of a)d.start>l&&s.push({type:"text",value:t.slice(l,d.start)}),s.push(d.segment),l=d.end;let c=t.slice(l);return c&&s.push({type:"text",value:c}),s}function lr(t,e){let{located:n,missing:i}=It(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 tt(t,e,n){let i=It(t,e).located,{located:o,missing:r}=sr(t,i,n);return{valid:o.map(a=>a.param),invalid:r}}function cr(t,e,n){let i=e?.endpoint??X,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${zs(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,a)=>{let s=xt.get(a);return s?`https://${s}`:r})}function zs(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 dr(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 js(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var ur=100,Qs=300,Ys=2,Mt=class{constructor(e,n,i,o,r,a,s,l,c,d={}){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=c;this.callbacks=d;this.fetchVersion=0;this.abortController=null;this.debounceTimer=null;this.slowDebounceTimer=null;this.unsubscribe=null;this.phraseExactMatch=!1;this.previewTimer=null;this.previewAbort=null;this.previewVersion=0;this.previewPending=!1;this.forceNextFetch=!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.clearPreview(),this.unsubscribe?.()}previewComposition(e){this.previewTimer&&clearTimeout(this.previewTimer),this.previewPending=!0,this.previewTimer=setTimeout(()=>{this.previewTimer=null,this.doPreview(e)},ur)}endPreview(){this.previewPending&&(this.clearPreview(),this.forceNextFetch=!0,this.scheduleFetch())}clearPreview(){this.previewTimer&&clearTimeout(this.previewTimer),this.previewTimer=null,this.previewAbort?.abort(),this.previewAbort=null,this.previewPending=!1}async doPreview(e){this.previewAbort?.abort();let n=new AbortController;this.previewAbort=n;let i=++this.previewVersion;this.previewPending=!0;let o=this.fetchVersion,r=this.store.get(),{rawQuery:a,completedParams:s}=N(e,r.completedParams);try{let l=await Dn(a,s,{...this.requestOptions(r,n.signal,crypto.randomUUID()),traditionalAutocompleteOnly:!0});if(i!==this.previewVersion||o!==this.fetchVersion)return;let c=(l.data.suggestions??[]).find(A);if(!c)return;this.store.set({suggestions:[c],traditionalAutocomplete:l.meta?.traditional_autocomplete===!0,activeDropdownIndex:-1})}catch{}}requestOptions(e,n,i){let o=e.pendingSpan?rr(e.pendingSpan.snapshot,e.actionableSuggestions):void 0;return{sessionId:this.getSessionId(),requestId:i,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:n,apiConfig:this.getApiConfig(),identifiedParams:e.identifiedParams,recentlySuggested:o,skippedParams:e.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})}}async doFetch(e,n){this.abortController?.abort(),this.previewAbort?.abort(),this.previewAbort=null,this.previewPending=!1,this.forceNextFetch=!1;let i=new AbortController;this.abortController=i;let o=++this.fetchVersion,r=this.store.get().text.length,a=this.store.get().text;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 s=this.store.get(),l=crypto.randomUUID(),c=e===""&&n.length===0&&s.skippedParams.length===0&&s.identifiedParams.length===0,d=c?this.startingStateUrl():void 0,u=d?await dr(fetch(d,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let g=u??await Dn(e,n,this.requestOptions(s,i.signal,l));if(o!==this.fetchVersion)return;this.phraseExactMatch=g.meta?.phrase_exact_match===!0;let m=(g.data.suggestions??[]).find(A),p=m?[]:g.data.input??[],f=E=>({id:crypto.randomUUID(),parameter:E.parameter,text:E.text,...E.type?{type:E.type}:{},...E.iso_date?{isoDate:E.iso_date}:{},...E.iso_date_end?{isoDateEnd:E.iso_date_end}:{}}),h=p.filter(E=>E.source==="identified");this.callbacks.waitIdentified?.(h.filter(E=>E.state==="need_confirmation").map(f),a);let x=h.filter(E=>E.state!=="need_confirmation").map(f),y=this.callbacks.isWordOpen?.()??!1,T=this.store.get().text.toLowerCase(),P=E=>y&&T.endsWith(E.text.toLowerCase()),b=x.filter(E=>!P(E));y&&this.callbacks.holdIdentified?.(x.filter(P));let v=m?[m]:tr(g.data.suggestions??[],this.getOptionOverrides()),w=p,S=w[w.length-1],L=this.store.get().text,C,H;if(S?.state==="in_progress"){H=!0;let E=L.toLowerCase().lastIndexOf(S.text.toLowerCase());C=E!==-1?E:r}else H=!1,C=r;let I=v.filter(E=>E.parameter!=="placeholder")[0],G=null;if(I&&!A(I)&&!y&&I.type?.kind!=="multi_select"&&!_(Y(I))){let E=Je(I.options,L,C,H,this.phraseExactMatch);E&&(G={id:crypto.randomUUID(),placeholder:"",parameter:J(E,I.parameter),text:E.text,value:E.value,kind:E.kind,suggestionParameter:I.parameter,suggestionValueType:I.type,suggestionPlaceholder:I.text,suggestionIcon:I.icon,suggestionIconSvg:I.icon_svg,options:I.options??[],metadata:E.metadata,icon:E.icon,icon_svg:E.icon_svg,image_url:E.image_url},v=v.filter(le=>le!==I),this.callbacks.onAutoMatch?.({active:I,matched:E,rawQuery:e}))}let se=g.data.custom_fields??null,te=this.callbacks.productsForResponse?.(se);this.store.set(E=>{let le=G?[...E.completedParams,G]:E.completedParams,Se=new Set,St=tt(E.text,le,b).valid.map(M=>{let Te=E.identifiedParams.find(Ge=>!Se.has(Ge.id)&&Ge.parameter===M.parameter&&Ge.text===M.text);return Te?(Se.add(Te.id),{...M,id:Te.id}):M}),ye=new Set(s.skippedParams.map(M=>M.id)),$e=new Set(E.skippedParams.filter(M=>!ye.has(M.id)).map(M=>M.parameter)),yt=$e.size>0?v.filter(M=>M.parameter==="placeholder"||!$e.has(M.parameter)):v;return{suggestions:this.callbacks.getAllOption?.()===!0&&!c?yt.map(M=>M.parameter==="placeholder"?M:{...M,leadsWithAll:!0}):yt,isLoading:!1,isReady:g.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:C,filterInProgress:H,identifiedParams:St,customFields:se,traditionalAutocomplete:g.meta?.traditional_autocomplete===!0,...te!==void 0?{products:te}:{},...G?{completedParams:le}:{}}}),this.callbacks.onResponse?.({requestId:l,funnelTelemetry:g.meta?.funnel_telemetry===!0,visibleImpression:g.meta?.visible_impression===!0})}catch(s){let l=js(s);o===this.fetchVersion&&(this.store.set({error:l,isLoading:!1}),this.getOnError()?.(l))}finally{if(o===this.fetchVersion&&this.store.get().isLoading)try{this.store.set({isLoading:!1})}catch{}}}startingStateUrl(){let e=this.callbacks.getProductId?.();return e?cr(e,this.getApiConfig(),de(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(Ys)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},ur),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),Qs)}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;if(this.forceNextFetch){let{rawQuery:v,completedParams:w}=N(o.text,o.completedParams);return this.doFetch(v,w),!0}let a=Ce(o.suggestions.filter(v=>v.parameter==="placeholder").map(v=>v.text).join(" "),this.callbacks.getPrependPlaceholder?.()),s=ue(o.text,o.filterBase,a),l=Xe(o.text,s,o.filterInProgress),c=o.suggestions.filter(v=>v.parameter!=="placeholder"),d=A(c[0])?void 0:c[0],u=_(o.activeFormatType),g=d&&!u?me(d.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&g.length>0)return!1;let m=g.filter(v=>v.is_tappable),p=d&&!u&&!this.callbacks.isWordOpen?.()?Je(d.options,o.text,s,o.filterInProgress,this.phraseExactMatch)!==null:!1,f=l.trim().length>0,h=i&&o.products.length>0;if(m.length>0&&!p&&f&&!h||Ye(o.text,o.completedParams.length,a))return!1;let{rawQuery:x,completedParams:y}=N(o.text,o.completedParams),T=x.length<o.lastRawQuery.length,P=Math.abs(x.length-o.lastRawQuery.length),b=n&&x!==o.lastRawQuery;return T||P>=e||b?(this.doFetch(x,y),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var Xs="(hover: none) and (pointer: coarse)";var Js="[data-aia-dropdown], [data-aia-input-wrapper]",Zs=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),kt=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(Zs)),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(Xs):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(Js))return!0;return!1}};var Ie=["January","February","March","April","May","June","July","August","September","October","November","December"],Rt=["S","M","T","W","T","F","S"],gr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],_t="aiaDate",fr="aiaDay",mr=t=>String(t).padStart(2,"0");function W(t){return`${t.getFullYear()}-${mr(t.getMonth()+1)}-${mr(t.getDate())}`}function Bn(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function el(t){let e=Bn(t).getTime()-Bn(new Date).getTime();return Math.round(e/864e5)}function hr(t){let e=el(t);return e>=0&&e<7?gr[t.getDay()]:Oe(t)}function Oe(t){return t.getFullYear()===new Date().getFullYear()?`${Ie[t.getMonth()]} ${t.getDate()}`:`${Ie[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function Dt(t){if(!t)return null;let e=gr.findIndex(s=>s.toLowerCase()===t.trim().toLowerCase());if(e>=0){let s=Bn(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=Ie.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 Un(t){return`${Ie[t.month]} ${t.year}`}function $n(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function br(t){return{year:t.getFullYear(),month:t.getMonth()}}function Gn(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function pr(){return{text:"",is_tappable:!1,kind:null}}function qn(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(pr());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:hr(r),is_tappable:!0,kind:null,metadata:{[_t]:W(r),[fr]:o}})}for(;i.length%Rt.length!==0;)i.push(pr());return i}function nt(t){let e=Dt(t);return e?W(e):null}function z(t){let e=t?.metadata?.[_t];return typeof e=="string"?e:null}function Kn(t){let e=t?.metadata?.[fr];return typeof e=="number"?e:null}function tl(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function pe(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&tl(e)?e:t.ownerDocument??t}function Ht(t){return pe(t).activeElement??null}function D(t){return t.ownerDocument??t}function nl(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Sr(t){let e=pe(t);return!nl(e)||typeof e.getSelection=="function"?null:e}function yr(t){let e=Sr(t);if(!e)return null;let n=D(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function Tr(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 it(t){let n=pe(t).getSelection?.();return n||(D(t).getSelection?.()??null)}function ge(t){let e=it(t);if(!e||e.rangeCount===0)return null;let n=yr(t);if(n){let i=Tr(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 ve(t){let e=it(t);if(!e||e.rangeCount===0)return null;let n=yr(t);if(!n)return e.getRangeAt(0);let i=Tr(e,n);if(!i)return null;let o=D(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function ot(t,e,n){let i=it(t);if(!i)return null;if(Sr(t))return i.collapse(e,n),i;let o=D(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function Nt(t,e){let n=t?pe(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var Ft=2,il="magicx-aia";function xr(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function ol(t){let e=D(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&&xr(a.overflowX)||r&&xr(a.overflowY))return i}if(i.classList.contains(il))return null;i=i.parentElement}return null}function zn(t){let e=ve(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=ol(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+Ft:i.left<r&&(n.scrollLeft-=r-i.left+Ft)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,a=r+n.clientHeight;i.bottom>a?n.scrollTop+=i.bottom-a+Ft:i.top<r&&(n.scrollTop-=r-i.top+Ft)}}var Er='[contenteditable="false"]',Qn="strong[data-param-id]",Me;function rl(){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 Wt(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(Er))return!0;n=n.parentNode}return!1}function Vt(t){return D(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return Wt(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Bt(t){let e=Vt(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function Yn(t){let e=Vt(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function j(t){let e=ge(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(Wt(o,t)&&o!==t)return null;let r=0;for(let a=0;a<i&&a<o.childNodes.length;a++)r+=Xn(o.childNodes[a],t);return r+jn(o,t)}return n.nodeType!==Node.TEXT_NODE||Wt(n,t)?null:jn(n,t)+i}function Xn(t,e){if(t.nodeType===Node.TEXT_NODE)return Wt(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(Er))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=Xn(o,e);return i}function jn(t,e){let n=Vt(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 V(t,e){let n=D(t),i=Math.max(0,Math.min(e,Yn(t))),o=Vt(t),r=0,a=null,s=0,l=o.nextNode(),c=null;for(;l;){let u=l.data.length;if(i<r+u){a=l,s=i-r;break}if(i===r+u){let g=o.nextNode();g?(a=g,s=0):(a=l,s=u);break}r+=u,c=l,l=o.nextNode()}let d=n.createRange();if(a){let u=a.parentElement?.closest('strong[data-seg="completed"]');u&&u!==t&&t.contains(u)?s===0?d.setStartBefore(u):s===a.data.length?d.setStartAfter(u):d.setStart(a,s):d.setStart(a,s)}else c?d.setStart(c,c.data.length):d.setStart(t,0);d.collapse(!0),ot(t,d.startContainer,d.startOffset)&&(al(t,d,i),zn(t))}function vr(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(Qn)??null;return i&&e.contains(i)?i:null}function al(t,e,n){let i=vr(ge(t)?.node??null,t);if(i&&i!==vr(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function wr(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=j(t);return i!==null&&n===`${i}:${e}`}function Pr(t){return pe(t).activeElement===t}function Jn(t,e){if(!e||e.nodeType===void 0)return null;let n=e,i=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;if(i?.closest("[data-aia-chip-remove]"))return null;let o=i?.closest(Qn);if(!o||!t.contains(o))return null;let r=ge(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function Zn(t,e){let n=null;for(let a of t.querySelectorAll(Qn))if(a.dataset.paramId===e){n=a;break}if(!n)return;let i=jn(n,t),o=i+Xn(n,t),r=j(t);r!=null&&r>=i&&r<=o||V(t,i)}function ei(t){let e=j(t);return e==null?!1:e>=Yn(t)}function ti(t,e){if(e<=0)return 0;let n=rl();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 Lr="aiaTime",ii=5;var oi=[12,1,2,3,4,5,6,7,8,9,10,11],ri=Array.from({length:60/5},(t,e)=>e*5),ai=["AM","PM"];function Re(t){return(Math.round(t)%1440+1440)%1440}function si(t){let e=Re(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function Ut(t){let e=t.hour%12+(t.period==="PM"?12:0);return Re(e*60+t.minute)}function $t(t){let{hour:e,minute:n,period:i}=si(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function Cr(t){let e=Re(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function ke(t){return Re(Math.round(t/5)*5)}function Ar(t,e){return Re(t+e)}var sl=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,ll=/^(\d{1,2}):(\d{2})$/;function ni(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=sl.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:Ut({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=ll.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 Ir(t){let e=ni(t.editingText);if(e!=null)return ke(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>ni(o.text)).filter(o=>o!=null);if(n.length>0)return ke(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return Re((i.getHours()+1)*60)}function li(t){return{text:$t(t),is_tappable:!0,kind:null,metadata:{[Lr]:Cr(t)}}}var Gt=30,qt=["hour","minute","period"],ci={hour:oi.map(t=>({label:String(t)})),minute:ri.map(t=>({label:String(t).padStart(2,"0")})),period:ai.map(t=>({label:t}))};function di(t){return ci[t]}function Kt(t,e){let n=si(ke(e));return t==="hour"?oi.indexOf(n.hour):t==="minute"?ri.indexOf(n.minute):ai.indexOf(n.period)}function zt(t,e,n){let i=ci[t],o=Math.min(Math.max(n,0),i.length-1),r=si(ke(e));return Ut(t==="hour"?{...r,hour:oi[o]}:t==="minute"?{...r,minute:ri[o]}:{...r,period:ai[o]})}function ui(t,e){let n=ci[t].length-1;return Math.min(Math.max(Math.round(e/Gt),0),n)}function Ee(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=N(t,e);return{query:t.trim(),raw_query:o,completed_params:je(r,n),identified_params:ze(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function jt(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")?ei(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function mi(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?j(t):null}var Qt=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 c=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let d=n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&d?.is_tappable){e.preventDefault(),this.ctx.selectOption(d);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&d?.is_tappable&&this.ctx.selectOption(d),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let d=jt(e.target,n),u=!!n.editingParam;if(!d&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(c)break;e.preventDefault();let p=R(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(R(n.activeFormatType)){this.stepDateWeek(n,7);break}if(n.filteredOptions.length>0){let p=Math.floor((n.filteredOptions.length-1)/a);if(Math.floor(n.activeDropdownIndex/a)===p){this.store.set({activeDropdownIndex:-1});break}}let g=l.indexOf(n.activeDropdownIndex),m=g<l.length-1?g+1:0;this.store.set({activeDropdownIndex:l[m]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!c)break;let g=jt(e.target,n),m=!!n.editingParam;if(!g&&!m)break;e.preventDefault();let p=R(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:p});break}if(l.length===0)return;this.store.set({activeDropdownIndex:p});break}if(l.length===0)break;if(e.preventDefault(),R(n.activeFormatType)){this.stepDateWeek(n,-7);break}if(n.activeDropdownIndex<a){this.store.set({activeDropdownIndex:-1});break}let d=l.indexOf(n.activeDropdownIndex),u=d>0?d-1:l.length-1;this.store.set({activeDropdownIndex:l[u]});break}case"ArrowRight":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),R(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%a<a-1){let g=n.activeDropdownIndex+1;g<n.filteredOptions.length&&n.filteredOptions[g]?.is_tappable&&this.store.set({activeDropdownIndex:g})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,g=n.editingTail;this.ctx.exitEditMode?.(),V(u,g);break}jt(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),R(n.activeFormatType)){this.stepDateDay(n,-1);break}if(n.activeDropdownIndex%a>0){let d=n.activeDropdownIndex-1;d>=0&&n.filteredOptions[d]?.is_tappable&&this.store.set({activeDropdownIndex:d});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let d=mi(e.target);d!=null&&this.ctx.startEditingParamAtCaret(d)}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingAnchor!=null){e.preventDefault();let d=e.target.closest("[data-aia-input]")??e.target,u=n.editingAnchor;this.ctx.exitEditMode?.(),V(d,u);break}if(this.ctx.startEditingParamAtCaret){let d=mi(e.target);d!=null&&this.ctx.startEditingParamAtCaret(d)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let d=mi(e.target);if(d==null)break;this.ctx.removeParamAtCaret(d)&&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 d=this.store.get();s(Ee(d.text,d.completedParams,d.skippedParams,{identifiedParams:d.identifiedParams,isReady:d.isReady,customFields:d.customFields}))&&this.ctx.afterSubmit?.()}break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let d=n.filteredOptions.map((m,p)=>m.is_tappable?p:-1).filter(m=>m!==-1);if(d.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let m=e.shiftKey?d[d.length-1]:d[0];this.store.set({pillTapped:!0,activeDropdownIndex:m});break}e.preventDefault();let u=d.indexOf(n.activeDropdownIndex);if(!e.shiftKey&&!R(n.activeFormatType)&&!n.multiSelectView){let m=u>=0?d[u]:d.find(p=>!n.filteredOptions[p]?.selectsAll);if(m===void 0)break;this.clickOrSelect(m,n.filteredOptions,i,r);break}let g;if(u<0)g=e.shiftKey?d.length-1:0;else{let m=e.shiftKey?-1:1;g=(u+m+d.length)%d.length}this.store.set({activeDropdownIndex:d[g]});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 d=e.target.closest("[data-aia-input]")??e.target,u=n.editingTail;this.ctx.exitEditMode?.(),V(d,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!jt(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){if(e.dateFloor){let a=e.filteredOptions.findIndex(s=>z(s)===e.dateFloor);if(a>=0)return a}let i=W(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=Nt(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=Nt(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=Nt(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var Yt=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(_(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,icon:n.suggestionIcon,icon_svg:n.suggestionIconSvg},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||cl(a))return;this.logOnce(a),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=nr(n,e.suggestion),r=this.resolveTarget(this.store.get());if(!r||r.key!==e.key)return;o.length===0?this.lastMiss={parameter:e.parameter,query:e.query}:this.lastMiss?.parameter===e.parameter&&(this.lastMiss=null);let a={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:o}:s.editingParam,optionSearch:a}));else{let s={...e.suggestion,options:o};this.current&&this.current.key===e.key&&(this.current.key=s),this.store.set(l=>({suggestions:l.suggestions.map(c=>c===e.suggestion?s:c),optionSearch:a}))}o.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 cl(t){return t instanceof Error&&t.name==="AbortError"}var Xt=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(c=>c.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(A(o))return;let r=i.filter((c,d)=>d!==e),a=n.suggestions.filter(c=>c.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:c}=N(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:c,selectedPill:o.text,otherPills:r.map(d=>d.text)})}let s=[...a,o,...r],l=this.store.peek({suggestions:s}).filteredOptions.findIndex(c=>c.is_tappable&&!c.selectsAll);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 kr="/products/",Or="https://relative.invalid";function dl(t){if(!t)return;let e;try{e=new URL(t,`${Or}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===Or?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function Rr(t,e){let n=dl(t.item_url)??ml(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:Mr(t.price,t.currency,e)},...ul(t)&&{compareAtPrice:Mr(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function ul(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 Mr(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 ml(t){if(!t.handle)return;let e=`${kr}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function pi(t,e){return(t?.items.matched??[]).map(n=>Rr(n,e))}var Jt=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=pi(e,de(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:[],c=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(c)}catch(a){if(n.aborted||pl(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 pl(t){return t instanceof Error&&t.name==="AbortError"}function gl(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function _r(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:Ie.findIndex(n=>n.toLowerCase().startsWith(e))}function fl(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}var hl=/^(?:(?:on|from) )?(?:the )?(\d{1,2})(?:st|nd|rd|th)$/;function gi(t){let e=hl.exec(t.trim().toLowerCase().replace(/\s+/g," "));if(!e)return null;let n=Number(e[1]);return n>=1&&n<=31?n:null}function bl(t,e){if(!Number.isFinite(e.getTime()))return null;let n=new Date(e.getFullYear(),e.getMonth(),e.getDate());for(let i=0;i<12;i++){let o=new Date(e.getFullYear(),e.getMonth()+i,t);if(o.getDate()===t&&o>=n)return o}return null}function Dr(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function _e(t,e={}){if(!t)return null;let n=e.today??new Date,i=gi(t);if(i!==null){let c=bl(i,n);return c?W(c):null}let o=gl(t.trim().toLowerCase()).replace(/\s+/g," "),r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o);if(r){let c=Dr(Number(r[1]),Number(r[2])-1,Number(r[3]));return c?W(c):null}let a=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(o);if(a){let c=_r(a[1]);if(c>=0)return Zt(c,Number(a[2]),a[3],n)}let s=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(o);if(s){let c=_r(s[2]);if(c>=0)return Zt(c,Number(s[1]),s[3],n)}let l=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(o);if(l){let c=Number(l[1]),d=Number(l[2]);return c>12&&d<=12?Zt(d-1,c,l[3],n):d>12&&c<=12?Zt(c-1,d,l[3],n):null}return null}function Zt(t,e,n,i){if(n){if(n.length!==4)return null;let r=Dr(Number(n),t,e);return r?W(r):null}let o=fl(t,e,i);return o?W(o):null}var Sl=/^\d{4}-\d{2}-\d{2}$/;function rt(t){return typeof t=="string"&&Sl.test(t)?t:null}function fi(t,e={}){return rt(t.isoDate)??_e(t.text,e)}function at(t){let e=rt(t.isoDate);return e?{start:e,end:rt(t.isoDateEnd)}:null}var Hr=" - ",Si="aiaDateRangeStart",yi="aiaDateRangeEnd";function st(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var hi=/^\d{4}-\d{2}-\d{2}$/;function bi(t){if(!hi.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 yl=/\s+(?:to|through|thru|until|til|till)\s+/g,Tl=/[-–—]/g;function xl(t){let e=[];for(let n of[yl,Tl]){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 en(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of xl(t.trim())){let a=_e(o.trim(),e);if(!a)continue;let s=gi(r)!==null?_e(r.trim(),{...e,today:bi(a)??e.today}):_e(r.trim(),e);!s||s<a||(n.add(`${a}|${s}`),i={start:a,end:s})}return n.size===1?i:null}function Nr(t){let e=bi(t.start),n=bi(t.end);return!e||!n?"":t.start===t.end?Oe(e):`${Oe(e)}${Hr}${Oe(n)}`}function Fr(t,e){let n=st(t,e);return{text:Nr(n),is_tappable:!0,kind:null,metadata:{[Si]:n.start,[yi]:n.end}}}function De(t,e={}){let n=t?.metadata?.[Si],i=t?.metadata?.[yi];return typeof n=="string"&&typeof i=="string"&&hi.test(n)&&hi.test(i)?st(n,i):en(t?.text,e)}var tn="(max-width: 768px)";var vl="var(--aia-option-row-height, 37px)",El="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function Wr(t,e){return e?Ti(1,Math.min(t,5)):Ti(1,Math.min(t,4))}function Ti(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${vl} + ${El})`}}function vi(t,e){return!e&&t>=5}function Ei(t,e,n,i){if(!(!e&&t>=5&&wl(n,i))){let a=Wr(t,e);return{...a,template:xi(a.cols),scrollHintIndices:!e&&t>a.rows?[a.rows-1]:[]}}let r=6;return{...Ti(2,3),template:xi(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function wl(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 lt(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)+Pl(t);return{rowWidths:i,gridWidth:r}}function Pl(t){let e=t.closest("[data-aia-dropdown]"),n=Number.parseFloat(e?.getAttribute(nn)??"");if(!e||!Number.isFinite(n)||e.style.getPropertyValue(ct)!=="")return 0;let i=e.getBoundingClientRect().width;return i>0?n-i:0}var nn="data-aia-glide-width",ct="--aia-glide-content-width";function xi(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function dt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(tn).matches}function wi(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}var Vr={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Items",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",seeAllResults:"See all results",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",allOption:"All",timeLabel:"Time",locationSearch:"Say a location",locationNoResults:"No places found",locationUseTyped:"Press Enter to use what you typed"},Ll={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",seeAllResults:"Ver todos los resultados",scrollArrow:"Despl\xE1zate para ver m\xE1s opciones",keepTyping:"Sigue escribiendo",done:"Listo",allOption:"Todo",timeLabel:"Hora",locationSearch:"Di una ubicaci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},Pi={en:Vr,es:Ll,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",seeAllResults:"Voir tous les r\xE9sultats",scrollArrow:"Faites d\xE9filer pour voir plus d\u2019options",keepTyping:"Continuez \xE0 taper",done:"Termin\xE9",allOption:"Tout",timeLabel:"Heure",locationSearch:"Dites un lieu",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",seeAllResults:"Ver todos os resultados",scrollArrow:"Role para ver mais op\xE7\xF5es",keepTyping:"Continue digitando",done:"Conclu\xEDdo",allOption:"Tudo",timeLabel:"Hor\xE1rio",locationSearch:"Diga um local",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",seeAllResults:"Vedi tutti i risultati",scrollArrow:"Scorri per vedere altre opzioni",keepTyping:"Continua a scrivere",done:"Fatto",allOption:"Tutto",timeLabel:"Ora",locationSearch:"Di' un luogo",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",seeAllResults:"T\xFCm sonu\xE7lar\u0131 g\xF6r",scrollArrow:"Daha fazla se\xE7enek i\xE7in kayd\u0131r",keepTyping:"Yazmaya devam et",done:"Tamam",allOption:"T\xFCm\xFC",timeLabel:"Saat",locationSearch:"Bir konum s\xF6yleyin",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",seeAllResults:"Lihat semua hasil",scrollArrow:"Gulir untuk melihat opsi lainnya",keepTyping:"Teruskan mengetik",done:"Selesai",allOption:"Semua",timeLabel:"Waktu",locationSearch:"Sebutkan lokasi",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",seeAllResults:"Zobacz wszystkie wyniki",scrollArrow:"Przewi\u0144, aby zobaczy\u0107 wi\u0119cej opcji",keepTyping:"Pisz dalej",done:"Gotowe",allOption:"Wszystko",timeLabel:"Godzina",locationSearch:"Podaj lokalizacj\u0119",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",seeAllResults:"Alle Ergebnisse anzeigen",scrollArrow:"Scrolle f\xFCr weitere Optionen",keepTyping:"Weitertippen",done:"Fertig",allOption:"Alle",timeLabel:"Uhrzeit",locationSearch:"Nenne einen Ort",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",seeAllResults:"Alle resultaten bekijken",scrollArrow:"Scrol voor meer opties",keepTyping:"Blijf typen",done:"Klaar",allOption:"Alles",timeLabel:"Tijd",locationSearch:"Noem een locatie",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",seeAllResults:"Visa alla resultat",scrollArrow:"Skrolla f\xF6r fler alternativ",keepTyping:"Forts\xE4tt skriva",done:"Klar",allOption:"Alla",timeLabel:"Tid",locationSearch:"S\xE4g en plats",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",seeAllResults:"Se alle resultater",scrollArrow:"Rull ned for \xE5 se flere alternativer",keepTyping:"Fortsett \xE5 skrive",done:"Ferdig",allOption:"Alle",timeLabel:"Tid",locationSearch:"Si et sted",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",seeAllResults:"Se alle resultater",scrollArrow:"Rul for flere muligheder",keepTyping:"Forts\xE6t med at skrive",done:"F\xE6rdig",allOption:"Alle",timeLabel:"Tidspunkt",locationSearch:"Sig et sted",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",seeAllResults:"N\xE4yt\xE4 kaikki tulokset",scrollArrow:"Vierit\xE4 n\xE4hd\xE4ksesi lis\xE4\xE4 vaihtoehtoja",keepTyping:"Jatka kirjoittamista",done:"Valmis",allOption:"Kaikki",timeLabel:"Aika",locationSearch:"Sano sijainti",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",seeAllResults:"\u3059\u3079\u3066\u306E\u7D50\u679C\u3092\u898B\u308B",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",allOption:"\u3059\u3079\u3066",timeLabel:"\u6642\u523B",locationSearch:"\u5834\u6240\u3092\u8A00\u3063\u3066\u304F\u3060\u3055\u3044",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:"\uCD94\uCC9C \uC0C1\uD488",soldOut:"\uD488\uC808",addToCart:"\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uB2F4\uAE30",submit:"\uAC80\uC0C9",seeAllResults:"\uBAA8\uB4E0 \uACB0\uACFC \uBCF4\uAE30",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",allOption:"\uC804\uCCB4",timeLabel:"\uC2DC\uAC04",locationSearch:"\uC704\uCE58\uB97C \uB9D0\uD558\uC138\uC694",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",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7ED3\u679C",scrollArrow:"\u5411\u4E0B\u6EDA\u52A8\u67E5\u770B\u66F4\u591A\u9009\u9879",keepTyping:"\u7EE7\u7EED\u8F93\u5165",done:"\u5B8C\u6210",allOption:"\u5168\u90E8",timeLabel:"\u65F6\u95F4",locationSearch:"\u8BF4\u51FA\u5730\u70B9",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",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7D50\u679C",scrollArrow:"\u5411\u4E0B\u6372\u52D5\u67E5\u770B\u66F4\u591A\u9078\u9805",keepTyping:"\u7E7C\u7E8C\u8F38\u5165",done:"\u5B8C\u6210",allOption:"\u5168\u90E8",timeLabel:"\u6642\u9593",locationSearch:"\u8AAA\u51FA\u5730\u9EDE",locationNoResults:"\u627E\u4E0D\u5230\u5730\u9EDE",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F38\u5165\u7684\u5167\u5BB9"}},Cl={pt:"pt-BR",no:"nb",nn:"nb"};function k(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return Pi[o?"zh-TW":"zh-CN"]}let i=Cl[e]??e;return Object.prototype.hasOwnProperty.call(Pi,i)?Pi[i]:Vr}function Br(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,c=t.caretOffset==null||t.caretOffset>=l;return(a||t.isLoading)&&s&&c}return n==="manual"?(a||t.isLoading)&&t.pillTapped:!1}function B(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 on(t){if(!t)return $n();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function Al(t){let e=Dt(t);return e?br(e):$n()}function Il(t,e){if(!t)return null;for(let n of e){if(n.parameter!==t||n.type?.kind!=="date_range")continue;let i=at(n);if(i&&i.end==null)return i.start}return null}function Ol(t){let e=new Set,n=i=>{i&&e.add(i)};for(let i of t.completedParams??[]){if(i.id===t.editingParam?.id)continue;let o=i.suggestionValueType?.kind;if(o==="date"&&n(rt(i.metadata?.[_t])??nt(i.text)),o==="date_range"){let r=De(i);n(r?.start),n(r?.end)}}for(let i of t.identifiedParams??[]){if(i.id===t.editingIdentified?.id)continue;let o=i.type?.kind;if(o!=="date"&&o!=="date_range")continue;let r=at(i);n(r?.start),n(r?.end)}return[...e].sort()}function Li(t,e){return t.editingParam!=null&&t.editingAnchor!=null?e:t.text.slice(xe(t.text,t.completedParams))}var Ml=/price/i;function kl(t){return!t||Ae(t)||_(Y(t))||t.type?.kind==="multi_select"||Ml.test(t.parameter)?!1:(t.options??[]).filter(e=>e.is_tappable).length>=2}function ut(t,e,n){if(e>0)return!1;let i=t.trim();return i===""||i.toLowerCase()===n.trim().toLowerCase()||Ye(i,0,n)}var Rl=4;function _l(t,e){let n={text:e,kind:null,is_tappable:!0,selectsAll:!0},i=[...new Set(t.filter(r=>r.is_tappable&&r.image_url).map(r=>r.image_url))].slice(0,Rl);if(i.length>0)return n.image_url=i[0],i.length>1&&(n.imageCollage=i),[n,...t];let o;for(let r of t)r.is_tappable&&(o=r);return o?.icon&&(n.icon=o.icon),o?.icon_svg&&(n.icon_svg=o.icon_svg),[n,...t]}function Dl(t,e){let{composing:n}=t,i=n?.over===t.text?n.text:t.text,o=i.slice(xe(i,t.completedParams));return e?.completes_word!==!0?o:o.match(/\S+(?=\s*$)/)?.[0]??""}function Ur(t,e){let n=Ot(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(O=>O.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(O=>O.parameter==="placeholder").map(O=>O.text).join(" "),a=Ce(r,e.prependPlaceholder),s=ue(t.text,Math.min(t.filterBase,t.text.length),a),c=s===0&&Ye(t.text,t.completedParams.length,a)?"":Xe(t.text,s,t.filterInProgress),d=o?.options??[],u=t.editingParam!=null&&t.editingAnchor!=null,g=!u&&!t.editingIdentified&&o?.type?.kind==="multi_select",m,p,f,h;if(u&&t.editingParam&&t.editingAnchor!=null){let O=t.editingParam.id,q=t.completedParams.some(ce=>ce.id===O),qe=t.caretOffset??t.editingAnchor,Q=q?"":t.text.slice(t.editingAnchor,qe);p=Q.trim(),f=t.editingParam.options,h=t.editingParam.suggestionParameter,m=t.editingParam.suggestionValueType?.kind==="traditional_autocomplete"?me(t.editingParam.options,Q).map(ce=>({...ce,matchedText:p,parameterLabel:Hn(ce)})):me(t.editingParam.options,Q)}else p=c.trim(),f=d,h=o?.parameter,m=A(o)?d.map(O=>({...O,matchedText:Dl(t,o),parameterLabel:Hn(O)})):me(d,c,t.traditionalAutocomplete);let x=t.optionSearch,y=x!=null&&h!=null&&x.parameter===h;y&&x.status==="done"&&x.query===p&&(m=f);let T=y&&x.status==="loading",P=e.showNonTappableOptions===!1;P&&(m=m.filter(O=>O.is_tappable));let b=ut(t.text,t.completedParams.length,a);e.allOption===!0&&o?.leadsWithAll===!0&&!b&&!u&&!t.editingIdentified&&c.trim()===""&&kl(o)&&(m=_l(m,k(e.language).allOption));let v=Li(t,p),w=u?t.editingParam?.suggestionValueType?.kind==="traditional_autocomplete":A(o);!g&&!w&&(m=Zo(m,v));let S=t.editingIdentified,L=u?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,C=S?S.format:Y(L),H=u?t.editingParam?.suggestionParameter:o?.parameter,F=C==="location"&&H&&e.optionOverrides?.[H]?"options":C,I=u&&F==="date-range"?De(t.editingParam):null,G=!u&&!S&&F==="date"?Il(o?.parameter,t.identifiedParams):null,se=null,te=null,E=R(F)?Ol(t):[];if(R(F)){let O=W(new Date),q=E.find(Rs=>Rs>=O)??null,qe=B({...t,actionableSuggestions:i}),Q=t.dateViewMonth;se=Q&&Q.key===qe?{year:Q.year,month:Q.month}:S?on(S.iso):I?on(I.start):G?on(G):q&&!u?on(q):Al(t.editingParam?.text),m=qn(se);let ce=t.pendingRangeStart;F==="date-range"&&ce&&ce.key===qe&&(te=ce.iso)}let le=null;if(F==="time"){let O=B({...t,actionableSuggestions:i}),q=t.timeDraft;le=q&&q.key===O?{minutes:q.minutes,touched:!0}:{minutes:Ir({editingText:u?t.editingParam?.text:null,options:u?t.editingParam?.options:o?.options}),touched:!1},m=[]}let Se=null;if(F==="location"){let O=B({...t,actionableSuggestions:i}),q=t.locationSearch;if(q&&q.key===O){let{key:qe,...Q}=q;Se=Q}else Se={query:u?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};m=[]}let St=O=>P?O.is_tappable:!0,ye;if(u){let O=t.editingParam?.options??[];ye=t.editingParam!=null&&O.filter(St).length===0}else ye=o!=null&&d.filter(St).length===0;le&&(ye=!0),Se&&(ye=!0);let $e=Br({inEditMode:u||S!=null,filteredOptionsLength:m.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||T,pillTapped:t.pillTapped,activePillHasNoOptions:ye,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),yt=$e&&t.activeDropdownIndex>=0&&!!m[t.activeDropdownIndex]?.is_tappable,In=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,M=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||T||In,Te=M&&t.skeletonOptions!==null,Ge=Te&&t.skeletonOptions?t.skeletonOptions:m,Ms=Te?t.skeletonSuggestion:null,Do=g?{picked:t.multiSelectDraft?.key===B({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,ks=Do??(Te&&t.skeletonSuggestion?.type?.kind==="multi_select"?{picked:t.skeletonPicked??[]}:null);return{segments:n,actionableSuggestions:i,filteredOptions:m,dropdownLoading:M,dropdownOptions:Ge,dropdownSuggestion:Ms,skeletonExiting:In,activeFormatType:F,dateView:se,dateRangeStart:te,dateFloor:G,dateReferences:E,timeView:le,multiSelectView:Do,dropdownMultiSelect:ks,locationView:Se,placeholderText:r,leadInText:a,optionQuery:p,isSearchingOptions:T,isDropdownOpen:$e,isActivePillSelected:yt}}function rn(t){return t.mode!=="edit"?Nl(t):Fl(t)}function Hl(t,e,n){let i=t.find(A);if(!i?.options)return null;let o=e.slice(xe(e,n)).trim().toLowerCase();if(!o)return null;let r=i.completes_word===!0?o.split(/\s+/).pop()??"":o,a=i.options.filter(c=>c.is_tappable&&c.text.trim().toLowerCase()===r);if(new Set(a.map(c=>J(c,i.parameter))).size!==1)return null;let l=a[0];return{suggestion:i,option:l,matchText:l.text.trim()}}function $r(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,a=n.find(d=>d.parameter!=="placeholder"&&!A(d));if(!a?.options||a.type?.kind==="multi_select")return null;let s=n.filter(d=>d.parameter==="placeholder").map(d=>d.text).join(" "),l=ue(e,i,Ce(s,t.prependPlaceholder)),c=Je(a.options,e,l,o,r===!0);return c?{suggestion:a,option:c,matchText:c.text}:null}function Nl(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?$r(t):null)??Hl(i,e,n):$r(t);if(!o)return null;let{suggestion:r,option:a,matchText:s}=o,l=s.toLowerCase(),c=e.toLowerCase().lastIndexOf(l),d=c>=0?c:Math.max(0,e.length-a.text.length),u=d+s.length,g=e.slice(d,u),p=u<e.length&&e[u]===" "?u+1:u,f={id:crypto.randomUUID(),placeholder:"",parameter:J(a,r.parameter),text:g,value:a.value,kind:a.kind,suggestionParameter:r.parameter,suggestionValueType:r.type,suggestionPlaceholder:r.text,suggestionIcon:r.icon,suggestionIconSvg:r.icon_svg,...t.mode==="submit"&&A(r)?Ze(J(a,r.parameter),r.text,a.parameter_label):{},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(h=>h!==r),filterBase:p,newParamId:f.id,caretOffset:p,activeDropdownIndex:-1},caretPos:p,option:a,suggestion:r}}function Fl(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(T=>T.id===i.id))return null;let a=e.slice(o,r),s=Ct(i.options,a);if(!s)return null;let l=s.text.toLowerCase(),c=a.toLowerCase().lastIndexOf(l),d=o+Math.max(0,c),u=d+s.text.length,g=e.slice(d,u),m=u<e.length&&e[u]===" "?u+1:u,p=e.length,f={id:crypto.randomUUID(),placeholder:"",...At(i,s),text:g,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},h=n.length,x=0;for(let T=0;T<n.length;T++){let P=ne(e,n[T].text,x);if(P!==-1){if(P>=m){h=T;break}x=P+n[T].text.length}}let y=[...n];return y.splice(h,0,f),{patch:{text:e,completedParams:y,newParamId:f.id,filterBase:p,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:p,activeDropdownIndex:-1},caretPos:p,option:s}}function qr(t){return t.slice(t.search(/\S*$/))}function Kr(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function Ai(t,e){let n="",i=0;for(let o of t){let r=i;if(n+=Kr(o),i+=o.length,n.length>=e.length){if(!n.startsWith(e))return null;let a=i+(t.slice(i).match(/^\p{M}*/u)?.[0].length??0),s=n.length>e.length;return{length:a,partialStart:s?r:a}}if(!e.startsWith(n))return null}return null}function zr(t,e,n,i){let o=[];return e<i&&o.push({text:t.slice(e,i),bold:!0}),i<n&&o.push({text:t.slice(i,n),bold:!0,partial:!0}),o}function Ci(t){return[...t].map(Kr).join("")}function an(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(Ci),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:Ci(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,g)=>i[s+g].folded===u))continue;let c=i[s+o-1],d=Ai(c.text,a);if(d)return{typedWords:o,start:i[s].index,end:c.index+d.length,partialStart:c.index+d.partialStart}}}return null}function Gr(t,e,n,i){return[{text:t.slice(0,e),bold:!1},...zr(t,e,n,i),{text:t.slice(n),bold:!1}].filter(o=>o.text!=="")}function Wl(t,e){let n=0;for(let i of t){if(!/^\p{M}/u.test(i)){let o=Ai(t.slice(n),e);if(o)return{start:n,end:n+o.length,partialStart:n+o.partialStart}}n+=i.length}return null}var Vl=/\p{Script=Hangul}/u;function Ii(t,e){let n=e?an(t,e):null;if(n&&n.typedWords>1)return Gr(t,n.start,n.end,n.partialStart);let i=e?qr(e):"",o=Ci(i);if(!o)return[{text:t,bold:!1}];let r=[],a=!1;for(let l of t.split(/(\s+)/)){if(l==="")continue;let c=/^\s/.test(l)?null:Ai(l,o);if(c){a=!0;let{length:u,partialStart:g}=c;r.push(...zr(l,0,u,g))}let d=c?l.slice(c.length):l;d&&r.push({text:d,bold:!1})}if(a||!Vl.test(i))return r;let s=Wl(t,o);return s?Gr(t,s.start,s.end,s.partialStart):r}var Bl=6e4;function Ul(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function $l(t){return(t??X).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function Gl(t){return Ke(t)?`Bearer ${await vt(t).getToken()}`:wt(t)}async function jr(t){try{let e=$l(t.apiConfig?.endpoint),n=Et(t.apiConfig),i=await Gl(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&&Ul(o)<=Bl&&{keepalive:!0}})}catch{}}function fe(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var Oi=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function ql(t,e,n){let i=Oi(t??"");if(i.length===0)return"";let r=Oi(e).slice(-i.length),a=Oi(n).slice(0,i.length);return r.join(" ")===i.join(" ")||a.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function Qr(t,e){let n=t.actionableSuggestions[0];if(!n)return null;let i=A(n),o=e.parameter;if(i&&!o)return null;let r=i&&o?o:J(e,n.parameter),a=i?t.text.length:t.filterBase,s=t.text.slice(0,a),l=s.length===0&&t.text.length===0,c=s.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||c)&&t.placeholderText&&(s=`${t.placeholderText} `);let d=Math.min(xe(t.text,t.completedParams),s.length),u=!1;if(i&&n.completes_word!==!0){let S=[...s.slice(d).matchAll(/\S+/g)],L=an(e.text,s.slice(d)),C=S[S.length-(L?.typedWords??1)];s=s.slice(0,C?d+(C.index??0):Math.max(s.lastIndexOf(" ")+1,d))}else if(n.completes_word===!0){let S=[...s.slice(d).matchAll(/\S+/g)],L=S[S.length-1];s=s.slice(0,L?d+(L.index??0):Math.max(s.lastIndexOf(" ")+1,d))}else if(n.completes_word!==!1){let S=s.slice(d),L=Math.max(Xo(S,e.text),Uo(S,e));L>0&&(s=s.slice(0,s.length-L)),u=L>0}let g=s.length>0&&s[s.length-1]!==" ",m=i||n.completes_word===!0||u,p=t.activeFormatType!==void 0&&!_(t.activeFormatType)&&_(Y({type:n.type})),f=m||p?"":ql(n.lead_in,s,e.text),h=`${s}${g?" ":""}${f?`${f} `:""}${e.text} `,y=(l||c||i&&s.length===0)&&h.length>0?h[0].toUpperCase()+h.slice(1):h,T=y.toLowerCase().lastIndexOf(e.text.toLowerCase()),P=T>=0?y.slice(T,T+e.text.length):e.text,b=i?Ze(r,n.text,e.parameter_label):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text,suggestionIcon:n.icon,suggestionIconSvg:n.icon_svg},v={id:crypto.randomUUID(),placeholder:"",...b,text:P,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:y,filterBase:y.length,completedParams:[...t.completedParams,v],newParamId:v.id,caretOffset:y.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(S=>S.text!==e.text).map(S=>S.text),key:i?r:n.parameter,position:fe(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:w}}function mt(t,e){let n=_(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,i=t.editingParam,o=i?et(i):t.actionableSuggestions[0]??null;return{skeletonOptions:n,skeletonSuggestion:n?o:null,skeletonPicked:n?e??null:null,skeletonRequested:!1}}function sn(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 ln=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=ne(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===""?sn(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(c=>c.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=At(i,e);this.deps.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(y=>y.text!==e.text).map(y=>y.text),key:a.suggestionParameter,position:fe(i.options,e.text),chip_origin:"tap"});let s=n.text.slice(0,o),l=n.text.slice(r),c=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,u=l.length===0||l[0]!==" "?`${c} `:c,g=s+u+l,m=g.length,p={id:crypto.randomUUID(),placeholder:"",...a,text:c,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(y=>y.id===i.id),h=n.completedParams.filter(y=>y.id!==i.id),x=f>=0?Math.min(f,h.length):h.length;h.splice(x,0,p),this.deps.store.set({text:g,completedParams:h,newParamId:p.id,filterBase:m,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:m,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...mt(n)}),this.deps.startSelectionAnimationTimer(),this.deps.scheduleSetCursor(m),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=rn({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 Kl=33,zl=70,jl=120,Ql=50,He="data-aia-placeholder-leaving",Ne=new WeakMap;function cn(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function Yl(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Xr(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function Jr(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Xr(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(()=>Jr(t,e),33+i)}function Yr(t,e){Xr(t,e,0),e.timer=setTimeout(()=>Jr(t,e),33)}function Zr(t,e){let n=Ne.get(t);if(e===""){n&&(cn(n),Ne.delete(t)),t.removeAttribute(He),delete t.dataset.placeholder;return}if(n?.target===e)return;if(Yl(t)){n&&cn(n),t.removeAttribute(He),Ne.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&&cn(n),Ne.set(t,i),o){t.setAttribute(He,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(He),t.isConnected&&Yr(t,i)},170);return}t.removeAttribute(He),Yr(t,i)}function ea(t){let e=Ne.get(t);e&&(cn(e),Ne.delete(t))}var Xl={selectedIso:null,selectedRange:null,rangeStart:null};function pt(t){if(!R(t.activeFormatType))return Xl;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?st(i,o):null,rangeStart:t.dateRangeStart,references:t.dateReferences??[]}}let n=De(t.editingParam);return{selectedIso:n?null:nt(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart??t.dateFloor??null,floor:t.dateFloor??null,references:t.dateReferences??[]}}function Mi(t){let e=t.floor!=null&&t.highlightedIso!=null&&t.highlightedIso<t.floor?null:t.highlightedIso;return t.pendingStart?st(t.pendingStart,e??t.pendingStart):t.selected}function ki(t,e){if(t==null)return{selected:!1,inRange:!1,reference:!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,a=!o&&!r&&(e.references?.includes(t)??!1);return{selected:o,inRange:r,reference:a}}function Ri(t,e,n){return t==null?!1:t<e||n!=null&&t<n}function _i(t,e){return t==="date"?e??null:null}var ta="https://ai-autocomplete.com";function Di(t=ta){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}}function Hi(t,e,n=k()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function Ni(t){let e=a=>{a.ctrlKey||na(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,c=i-s.clientY;n=s.clientX,i=s.clientY,a.cancelable&&!na(a.target,t,l,c)&&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 na(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&Jl(o,i)||n!==0&&Zl(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var ia=/^(auto|scroll|overlay)$/;function Jl(t,e){return t.scrollHeight<=t.clientHeight||!ia.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function Zl(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!ia.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 oa=new WeakMap,ra=new WeakSet;function U(t,e,n){if(oa.set(t,n),ra.has(t))return;ra.add(t);let i=()=>oa.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 he(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function K(t){t.offsetWidth}var oe="magicx-aia-panel-ghost";function Fe(t){return t.closest(`.${oe}`)!==null}function $(t,e){for(let n of t.querySelectorAll(e))if(!Fe(n))return n;return null}var Fi="--aia-multi-done-fit";function ec(t){return $(t,"[data-aia-multi-done]")}function Wi(t,e){if(!e?.isConnected)return;let n=e.ownerDocument,i=n.defaultView?.getComputedStyle(e).direction==="rtl";if(typeof n.createRange().getBoundingClientRect!="function")return;let o=e.getBoundingClientRect(),r=0;for(let a of t.querySelectorAll("[data-aia-option]")){if(Fe(a))continue;let s=n.defaultView?.getComputedStyle(a),l=Number.parseFloat(i?s?.paddingRight??"0":s?.paddingLeft??"0")||0,c=n.createTreeWalker(a,NodeFilter.SHOW_TEXT),d=n.createRange();for(let u=c.nextNode();u;u=c.nextNode()){if(!u.textContent?.trim())continue;d.selectNodeContents(u);let g=d.getBoundingClientRect();if(g.width===0)continue;let m=i?o.right-g.left:g.right-o.left;r=Math.max(r,m+l)}}r>0?e.style.setProperty(Fi,`${Math.ceil(r)}px`):e.style.removeProperty(Fi)}var tc=40,nc=340,ic=340,oc=7,Vi="--aia-option-enter-delay";function Bi(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 Ui(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 sa="magicx-aia-scroll-arrow",dn="data-aia-scroll-arrow",We="data-aia-visible",la=1e3,ca=160,da="--aia-scroll-arrow-bottom",rc="Scroll down for more options",$i="data-aia-scrollable",ac="--aia-scroll-track-top",sc="--aia-scroll-track-height",lc="--aia-scroll-track-right",cc="--aia-scroll-thumb-top",dc="--aia-scroll-thumb-height",uc=12,mc=.5,pc="[data-aia-products-label]",aa=4,gc=8,fc=240;function hc(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,a=t.ownerDocument?.visibilityState==="hidden";if(!r||a||Gi(t)){t.scrollTop=o+e,i();return}let s=n.performance?.now?.()??Date.now(),l=()=>n.performance?.now?.()??Date.now(),c=()=>{let d=Math.min(1,(l()-s)/fc),u=1-(1-d)*(1-d);t.scrollTop=o+e*u,d<1?r.call(n,c):i()};r.call(n,c)}function bc(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 ua(t=document,e=k()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=sa,n.setAttribute(dn,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(bc(t)),n}function Sc(t){return Math.max(1,Ki(t.style.gridTemplateColumns))}function Gi(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function qi({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,c=v=>{if(v){if(n.hasAttribute(We))return;if(n.setAttribute(We,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),Gi(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(We)&&(n.disabled=!1)},la)}else n.removeAttribute(We),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},d=v=>{let w=0,S=v;for(;S&&S!==t;)w+=S.offsetTop,S=S.offsetParent instanceof HTMLElement?S.offsetParent:null;return w},u=()=>{let v=$(t,pc),w;if(v){let S=d(v)+v.offsetHeight/2;w=t.clientHeight-S-n.offsetHeight/2}else{let S=d(e),L=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;w=t.clientHeight-(S+e.offsetHeight)+(L>0?0:gc)}n.style.setProperty(da,`${Math.max(0,Math.round(w))}px`)},g=v=>{let w=0,S=v;for(;S&&S!==t;)w+=S.offsetLeft,S=S.offsetParent instanceof HTMLElement?S.offsetParent:null;return w},m=null,p=(v,w)=>{let S=Math.min(1,Math.max(0,e.scrollTop/v));n.style.setProperty(cc,`${Math.round(w*S)}px`)},f=()=>{let v=e.scrollHeight-e.clientHeight,w=e.querySelector("[data-aia-option][data-aia-loading]")!==null;if(v<=aa||w){m=null,n.removeAttribute($i);return}let S=e.clientHeight,L=Math.round(S*mc),C=d(e)+(S-L)/2,H=t.clientWidth-(g(e)+e.offsetWidth),F=Math.min(L,Math.max(uc,Math.round(L*S/e.scrollHeight)));m={overflow:v,travel:L-F},n.style.setProperty(ac,`${Math.round(C)}px`),n.style.setProperty(sc,`${L}px`),n.style.setProperty(lc,`${Math.max(0,Math.round(H))}px`),n.style.setProperty(dc,`${F}px`),p(v,m.travel),n.setAttribute($i,"")},h=()=>{if(o||a!==null||s!==null)return;let v=e.querySelector("[data-aia-option][data-aia-loading]")!==null,w=e.scrollHeight-e.clientHeight-e.scrollTop;c(!v&&w>aa)},x=()=>{if(o)return;u(),f();let v=e.getAttribute("data-aia-group")??"";if(v!==r){r=v,c(!1),a!==null&&clearTimeout(a);let w=e.querySelectorAll("[data-aia-option]").length,S=Gi(e)?0:Ui(w,Sc(e));a=setTimeout(()=>{a=null,h()},S);return}h()},y=()=>{o||(m&&p(m.overflow,m.travel),a===null&&(c(!1),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,h()},ca)))};e.addEventListener("scroll",y,{passive:!0});let T=v=>v.preventDefault(),P=()=>{let v=i?(Number.parseFloat(i.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0):0,w=Math.max(1,e.clientHeight-v);hc(e,w,i,y)};n.addEventListener("mousedown",T),n.addEventListener("click",P);let b=null;return i&&typeof i.ResizeObserver=="function"&&(b=new i.ResizeObserver(()=>{u(),f(),h()}),b.observe(e)),x(),{update:x,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",y),n.removeEventListener("mousedown",T),n.removeEventListener("click",P),b?.disconnect(),n.removeAttribute(We),n.removeAttribute($i),n.setAttribute("aria-hidden","true"))}}}var ma="cubic-bezier(0.25, 0.1, 0.25, 1)",yc="cubic-bezier(0.32, 0.72, 0, 1)",pa=360,ga=280,fa=320,ha=40,ba="blur(2px)",Tc=160,xc=.05,vc=/pressed/i;function Sa(){return typeof performance<"u"?performance.now():Date.now()}function Ec(t){for(let e of t.querySelectorAll("[data-aia-loading]"))if(!e.closest(`.${oe}`))return!0;return!1}function wc(t){return t===null?1:1-Math.min(1,Math.max(0,(Sa()-t)/Tc))**1.7}function Qi(t){return t.hasAttribute(dn)}function ji(t){let e=0;for(let n of Array.from(t.children))n.classList.contains(oe)||Qi(n)||(e+=n.offsetHeight||0);return e}var Z=new WeakMap;function Pc(t){return(Number.parseFloat(t.borderLeftWidth)||0)+(Number.parseFloat(t.borderRightWidth)||0)}function Lc(t){let e=(t.ownerDocument.defaultView??window).getComputedStyle(t);return(Number.parseFloat(e.paddingLeft)||0)+(Number.parseFloat(e.paddingRight)||0)+(Number.parseFloat(e.borderLeftWidth)||0)+(Number.parseFloat(e.borderRightWidth)||0)}var zi=new WeakMap;function Cc(t,e){return!e||typeof t.animate!="function"||t.closest('[data-animations="off"]')||t.closest('[data-aia-options-style="classic"]')?!1:!(t.ownerDocument.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)")??null)?.matches}function Ac(t,e){let n=0,i="";for(let o of Array.from(t.children))o.classList.contains(oe)||(n+=1+o.getElementsByTagName("*").length,i+=`${o.textContent??""}\0`);return`${e??""}${n}${i}`}function Ic(t){let e=t.ownerDocument.createElement("div");e.className=oe,e.setAttribute("aria-hidden","true"),e.inert=!0;for(let n of Array.from(t.children))n.classList.contains(oe)||Qi(n)||e.appendChild(n.cloneNode(!0));for(let n of[e,...Array.from(e.querySelectorAll("*"))]){n.removeAttribute("id"),n.removeAttribute("role"),n.removeAttribute("tabindex");for(let i of Array.from(n.classList))vc.test(i)&&n.classList.remove(i);n.tagName==="A"&&n.removeAttribute("href"),n.tagName==="BUTTON"&&(n.disabled=!0);for(let i of Array.from(n.attributes))i.name.startsWith("aria-")&&i.name!=="aria-hidden"&&n.removeAttribute(i.name)}return e}function Oc(t,e,n,i,o){for(let a of Array.from(t.children))a.classList.contains(oe)&&a.remove();let r=Array.from(t.children).filter(a=>!Qi(a));i>xc&&Mc(t,e,n,i,o);for(let a of r)a.animate([{opacity:0,filter:ba},{opacity:1,filter:"blur(0px)"}],{duration:fa,delay:ha,easing:ma,fill:"backwards"})}function Mc(t,e,n,i,o){let r=(t.ownerDocument.defaultView??window).getComputedStyle(t);e.style.cssText=["position:absolute","left:0",o>0?`width:${o-Pc(r)}px`:"right:0",n?"bottom:0":"top:0",`padding:${r.padding}`,"pointer-events:none","box-sizing:border-box"].join(";"),t.appendChild(e),e.animate([{opacity:i,filter:"blur(0px)"},{opacity:0,filter:ba}],{duration:ga*i,easing:ma,fill:"forwards"}).finished.then(()=>e.remove(),()=>e.remove())}function Yi(t){let e=t[0]?.text;return e==null||e===""?null:e}function un(t,e,n){let i=n.visible,o=Cc(t,n.enabled??!0),r=Z.get(t);if(!i||!o){o||r?.glide?.cancel(),Z.set(t,{height:0,width:0,key:i?e:null,signature:"",snapshot:null,glide:o?r?.glide??null:null,loadingSince:null,contentHeight:0});return}let a=Ac(t,e),s=Ec(t)?r?.loadingSince??Sa():null;if(r&&r.height>0&&r.glide&&r.signature===a){r.loadingSince=s;return}let l=be(t),c=t.getBoundingClientRect(),d=c.height;r?.glide?.cancel();let u=t.getBoundingClientRect(),g=u.height,m=u.width||0,p=null,f=r?l?d:r.height:0,h=r?l?c.width||0:r.width:0;r&&f>0&&(e!==r.key&&r.snapshot&&Oc(t,r.snapshot,n.anchorBottom??!1,wc(r.loadingSince),h),p=ya(t,{height:f,width:h},{height:g,width:m}));let x=null;e!==null&&(x=r&&r.signature===a&&r.snapshot&&!r.snapshot.isConnected?r.snapshot:Ic(t)),Z.set(t,{height:g,width:m,key:e,signature:a,snapshot:x,glide:p,loadingSince:s,contentHeight:p?ji(t):0})}function ya(t,e,n){let i=e.width>0&&n.width>0&&Math.abs(e.width-n.width)>1;if(Math.abs(e.height-n.height)<=1&&!i)return null;let o=i?[{height:`${e.height}px`,width:`${e.width}px`},{height:`${n.height}px`,width:`${n.width}px`}]:[{height:`${e.height}px`},{height:`${n.height}px`}],r=t.animate(o,{duration:pa,easing:yc});i&&(t.setAttribute(nn,String(n.width)),n.width>e.width?t.style.setProperty(ct,`${n.width-Lc(t)}px`):t.style.removeProperty(ct),zi.set(t,r));let a=()=>{zi.get(t)===r&&(zi.delete(t),t.removeAttribute(nn),t.style.removeProperty(ct))};return r.finished.then(()=>{a();let s=Z.get(t);if(s?.glide!==r||(s.glide=null,s.height<=0))return;let l=t.getBoundingClientRect();l.height>0&&(s.height=l.height),l.width>0&&(s.width=l.width)},a),r}function be(t){let e=Z.get(t)?.glide??null;return e&&(e.playState==="running"||e.pending)?e:null}function Xi(t){if(!be(t))return null;let e=Z.get(t)?.height??0;return e>0?e:null}function Ji(t,e){let n=Z.get(t);n&&n.height>0&&!be(t)&&e>0&&(n.height=e)}function Ta(t,{widthChanged:e}){let n=Z.get(t);if(!n||n.height<=0)return;let i=be(t);if(!i||!e&&(t.hasAttribute("data-aia-fit")||Math.abs(ji(t)-n.contentHeight)<=1))return;let o=t.getBoundingClientRect();i.cancel();let r=t.getBoundingClientRect();n.width=r.width||0,n.height=r.height,n.glide=ya(t,{height:o.height,width:o.width||0},{height:r.height,width:n.width}),n.contentHeight=n.glide?ji(t):0}function Zi(t){Z.get(t)?.glide?.cancel(),Z.delete(t)}var eo="data-aia-hug",Ve="--aia-panel-fit-width",to="data-aia-full-width",kc=36;function gt(t){t.removeAttribute(eo)}function no(t,e,{eligible:n,loading:i}){let o=t.style.getPropertyValue(Ve);Rc(t,e,n,i),Ta(t,{widthChanged:t.style.getPropertyValue(Ve)!==o})}function Rc(t,e,n,i){if(!n){t.style.removeProperty(Ve),gt(t);return}if(i){t.style.getPropertyValue(Ve)&&t.setAttribute(eo,"");return}let o=_c(t,e);if(o==null){t.style.removeProperty(Ve);return}t.style.setProperty(Ve,`${o}px`),t.setAttribute(eo,"")}var xa=new WeakMap;function _c(t,e){if(dt())return null;let n=$(e,".aia-grid");if(!n||t.offsetWidth===0)return null;let i=$(e,"[data-aia-pillbar]"),o=[n.style.gridTemplateColumns,i?.textContent??"",...Array.from(n.querySelectorAll("[data-aia-option]"),s=>s.textContent)].join("\0"),r=xa.get(t);if(r?.key===o)return r.width;let a=Dc(t,e,n);return xa.set(t,{key:o,width:a}),a}function Dc(t,e,n){let i=lt(n);if(!i||i.rowWidths.some(s=>s<=0))return null;let o=Math.ceil(Math.max(...i.rowWidths)),r=Math.max(1,Ki(n.style.gridTemplateColumns)),a=va(n,t,r-1)+r*(o+kc);return Math.ceil(Math.max(a,Hc(e,t)))}function Hc(t,e){let n=$(t,"[data-aia-pillbar]");if(!n)return 0;let i=n.querySelector("[data-aia-pill-scroll]")?.scrollWidth??0,o=n.querySelector("[data-aia-skip]")?.offsetWidth??0;return i+o===0?0:va(n,e,i>0&&o>0?1:0)+i+o}function Ki(t){let e=0,n=0,i=!1;for(let o of t)o==="("?e++:o===")"&&e--,e===0&&/\s/.test(o)?i=!1:i||(i=!0,n++);return n}function va(t,e,n){let i=0;for(let o=t;o;o=o.parentElement){let r=getComputedStyle(o);if(i+=(Number.parseFloat(r.paddingLeft)||0)+(Number.parseFloat(r.paddingRight)||0)+(Number.parseFloat(r.borderLeftWidth)||0)+(Number.parseFloat(r.borderRightWidth)||0),o===t&&(i+=n*(Number.parseFloat(r.columnGap)||0)),o===e)break}return i}var Nc="[data-aia-products], [data-aia-datepicker], [data-aia-date-grid], [data-aia-time-wheel], [data-aia-location], [data-aia-see-all]";function Fc(t){let e=!t.hasAttribute("data-aia-has-products")&&!t.hasAttribute(to)&&$(t,".aia-grid [data-aia-option]")!==null&&$(t,Nc)===null,n=$(t,".aia-grid [data-aia-option][data-aia-loading]")!==null;e||gt(t),no(t,t,{eligible:e,loading:n})}var Ea="data-aia-key";function ee(t,e,n){let i=new Map;for(let a of Array.from(t.children)){let s=a.getAttribute(Ea);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 c=i.get(l);c||(c=n.create(s,a),c.setAttribute(Ea,l)),n.update?.(c,s,a),t.children[a]!==c&&t.insertBefore(c,t.children[a]??null),r.push(c)}for(let[a,s]of i)o.has(a)||s.remove();return r}function wa(t,e){if(!e.interactive)return null;let n=e.options[he(t)];return n?.is_tappable?n:null}var Wc={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=wa(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")&&wa(t,e)&&e.callbacks.onHighlight(he(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,he(t))}};function La(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=Uc(),t.appendChild(l),K(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}U(l,Wc,{options:e,callbacks:a,interactive:s});let c=l.querySelector(".magicx-aia-datepicker-month");c&&(c.textContent=Un(o));let d=l.querySelector(".magicx-aia-datepicker-grid");d&&Vc(d,e,n,i,r)}function Vc(t,e,n,i,o){let r=W(new Date),a=Mi({pendingStart:o.rangeStart,highlightedIso:z(e[n]),selected:o.selectedRange,floor:o.floor});ee(t,e,{keyOf:(s,l)=>z(s)??`pad-${l}`,create:s=>Bc(s),update:(s,l,c)=>{let d=z(l),u=ki(d,{selectedIso:o.selectedIso,range:a,references:o.references}),g=c===n&&l.is_tappable;s.id=`${i}-option-${c}`,s.dataset.aiaIndex=String(c),s.setAttribute("aria-selected",String(g)),s.classList.toggle("magicx-aia-date-cell--past",Ri(d,r,o.floor)),s.classList.toggle("magicx-aia-date-cell--highlighted",g),s.classList.toggle("magicx-aia-date-cell--today",d!=null&&d===r),s.classList.toggle("magicx-aia-date-cell--selected",u.selected),s.classList.toggle("magicx-aia-date-cell--in-range",u.inRange),s.classList.toggle("magicx-aia-date-cell--reference",u.reference)}})}function Bc(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=Kn(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 Uc(){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(Pa("prev","Previous month","\u2039"),n,Pa("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 Pa(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 $c='<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>',Ca="data-aia-location-body";function Gc(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=$c;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 qc(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 Aa(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(Ca)!==r){for(let s of Array.from(t.children))s.hasAttribute("data-aia-location-row")||s.remove();let a=qc(r,n);a&&t.appendChild(a),t.setAttribute(Ca,r)}ee(t,o,{keyOf:(a,s)=>`${s}:${a.id}`,create:a=>Gc(a),update:(a,s,l)=>{let c=l===e.highlighted;a.classList.toggle("magicx-aia-location-row--highlighted",c),a.setAttribute("aria-selected",String(c)),a.setAttribute("data-aia-index",String(l)),a.id=i(l)}})}var re=new WeakMap,Kc=0,we=new WeakMap,zc='<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>',Pe=t=>Ht(t.input)===t.input;function Ia(t,e){let n=Ht(t);if(n instanceof HTMLElement&&n!==e.input&&n!==D(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=ve(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function jc(t,e,n){if(!(!(n instanceof HTMLElement)||n===e.returnTo||t.contains(n))&&n!==D(t).body&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=ve(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Qc(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=it(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=D(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var Yc={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&Be(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function Be(t,e=!1){let n=we.get(t),i=re.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&Pe(n)&&(n.returning=!0,Qc(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function Xc(t){let e=we.get(t),n=re.get(t);if(!(!e||!n||Pe(e))){if(Ia(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!Pe(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function Jc(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++Kc}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=zc;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,wasReediting:!1};return t.addEventListener("mousedown",a=>{!(a.target instanceof Node)||!n.contains(a.target)||(a.stopPropagation(),Ia(t,r),re.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>re.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",a=>{jc(t,r,a.relatedTarget),re.get(t)?.callbacks.onLocationFocusChange(!0)}),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,re.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",a=>{let s=re.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;Be(t,!0),s.callbacks.onLocationCommit();return;case"Escape":a.preventDefault(),a.stopPropagation(),r.declined=!0,Be(t);return;case"Backspace":if(i.value!=="")return;a.preventDefault(),r.declined=!0,Be(t);return}}),we.set(t,r),r}function Oa(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=we.get(e);n&&(Pe(n)&&Be(e),n.declined=!1,n.input.tabIndex=-1)}}function Ma(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=we.get(r);l&&Pe(l)&&Be(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let a=we.get(r)??Jc(r,n);a.input.tabIndex=0,re.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),U(a.results,Yc,re.get(r)),a.input.value!==e.query&&!Pe(a)&&(a.input.value=e.query);let s=l=>`${r?.id}-row-${l}`;if(Aa(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"),o.inputFocused){let l=o.reediting??!1;l&&!a.wasReediting&&(a.declined=!1),a.wasReediting=l}if(a.widgetFocused=o.inputFocused??!1,o.inputFocused){if(o.reediting&&!a.declined&&o.interactive!==!1&&!Pe(a)){let l=r;queueMicrotask(()=>{l.isConnected&&!we.get(l)?.declined&&Xc(l)})}}else{let l=a;setTimeout(()=>{if(l.widgetFocused)return;let c=l.returnTo;c&&Ht(c)===c||(l.declined=!1)},0)}}var Zc={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},ka=[125,69];function Ra(t,e){return e?1:t===0?.7:t===1?.4:.2}function mn(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,Zc,{onSelectPill:i,loading:r}),r&&e.length===0){s.setAttribute("data-aia-pill-list-loading",""),s.innerHTML="";for(let l=0;l<ka.length;l++){let c=ka[l],d=document.createElement("span");d.setAttribute("data-aia-pill-skeleton",""),d.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,d.style.width=`${c}px`,d.style.setProperty("--aia-pill-opacity",String(Ra(l,!1))),s.appendChild(d)}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();ee(s,e,{keyOf:l=>`${l.type?.kind??""}|${Ae(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let c=document.createElement("button");if(c.type="button",c.tabIndex=-1,c.setAttribute("data-aia-pill",""),c.setAttribute("contenteditable","false"),Ae(l)){c.setAttribute("data-aia-smart-suggestion",A(l)?"header":"");let d=document.createElement("span");d.className="magicx-aia-smart-suggestion-text",d.textContent=l.text;let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-sparkle",u.innerHTML=Wn,c.append(d,u)}else c.textContent=l.text;return c.disabled=!0,c},update:(l,c,d)=>{let u=l,g=a&&d===n&&!r,m=["magicx-aia-pill"];o&&m.push("magicx-aia-pill--rounded"),r&&m.push("magicx-aia-pill--skeleton"),u.className=m.join(" "),u.style.width="",u.style.setProperty("--aia-pill-opacity",String(Ra(d,g))),u.dataset.aiaPillIndex=String(d),u.toggleAttribute("data-aia-pill-active",d===n),r?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),K(s);for(let l of s.querySelectorAll("[data-aia-pill]"))l.disabled=r}function io(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var ed=32;function _a(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 oo(t){let e=n=>{let i=_a(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var Da=Intl.Segmenter,Ha=Da?new Da(void 0,{granularity:"grapheme"}):null;function ro(t){let e=t.trim().normalize("NFC").toUpperCase();if(Ha)for(let n of Ha.segment(e))return n.segment;return Array.from(e)[0]??"?"}var ao=120,td=360;function nd(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 Na(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=nd(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 so(t,e){let n=Na(t,e);return n===t?[t]:[n,t]}function lo(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 pn(t){let e=t?.trim();return e?so(e,360):[]}function id(t){return pn(t)[0]}var gn=new WeakMap,uo=new WeakMap,Wa=new WeakMap;function Va(t,e,n,i,o,r="row",a="image",s=k(),l){let c=t.querySelector(".magicx-aia-products");if(e.length===0){c?.remove();return}if(!c){c=document.createElement("section"),c.className="magicx-aia-products",c.setAttribute("data-aia-products",""),c.setAttribute("role","group"),c.setAttribute("aria-labelledby",`${n}-products-label`);let g=document.createElement("div");g.className="magicx-aia-products-label",g.id=`${n}-products-label`,g.setAttribute("data-aia-products-label",""),g.textContent=s.products;let m=document.createElement("div");m.className="magicx-aia-products-row",m.setAttribute("data-aia-products-row",""),oo(m),c.append(g,m),t.appendChild(c)}c.setAttribute("data-aia-products-layout",r);let d=c.querySelector(".magicx-aia-products-label");d&&d.textContent!==s.products&&(d.textContent=s.products);let u=c.querySelector(".magicx-aia-products-row");if(u){ee(u,e,{keyOf:g=>sd(g,!!l),create:g=>ld(g,i,o,a,s,l),update:(g,m,p)=>{gn.set(g,m),od(g,m.price,m.compareAtPrice),g.id=`${n}-product-${p}`,g.dataset.aiaIndex=String(p),Wa.get(g)?.(a);let f=g.querySelector(".magicx-aia-product-badge");f&&f.textContent!==s.soldOut&&(f.textContent=s.soldOut);let h=g.querySelector(".magicx-aia-product-cart");h&&h.setAttribute("aria-label",Ba(m,s))}}),K(u);for(let g of u.querySelectorAll("[data-aia-product]")){let m=uo.get(g);m&&(uo.delete(g),m())}}}function mo(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)Fe(i)||(i.tabIndex=e?0:-1)}function od(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 Fa(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 Ba(t,e){return`${e.addToCart}: ${t.title}`}var co="http://www.w3.org/2000/svg";function rd(){let t=document.createElementNS(co,"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(co,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(co,"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 ad(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",Ba(e,o)),r.tabIndex=0,r.appendChild(rd());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(gn.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 sd(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 ld(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=pn(t.imageUrl),c=l[0],d=!!c,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=ro(t.title))};if(Wa.set(a,f=>{f!==i&&(i=f,d||u())}),c){let f=document.createElement("img"),h=0;f.onload=()=>{s.setAttribute("data-aia-image-loaded",""),Fa(a,lo(f.naturalWidth,f.naturalHeight))},f.onerror=()=>{let x=l[++h];if(x){f.src=x;return}d=!1,Fa(a,null),u()},f.className="magicx-aia-product-image",f.src=c,f.alt="",f.loading="lazy",f.decoding="async",s.appendChild(f)}else u();a.appendChild(s);let g=document.createElement("span");if(g.className="magicx-aia-product-body",t.vendor){let f=document.createElement("span");f.className="magicx-aia-product-vendor",f.textContent=t.vendor,g.appendChild(f)}let m=document.createElement("span");if(m.className="magicx-aia-product-title",m.textContent=t.title,g.appendChild(m),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,g.appendChild(f)}a.appendChild(g);let p=r&&t.available!==!1?ad(a,t,r,n,o):null;return p&&(a.setAttribute("data-aia-product-has-cart",""),a.appendChild(p.el)),uo.set(a,()=>{p?.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(gn.get(a)??t))})}),a.addEventListener("keydown",f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),e(gn.get(a)??t))}),a.addEventListener("focus",()=>n(!0)),a.addEventListener("blur",f=>{f.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),a}var cd=10,dd=44;function po(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 Ua="http://www.w3.org/2000/svg",ud=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function md(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 pd=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],gd=/^[a-zA-Z0-9#.,%\s()-]+$/;function fd(t){let e=[];for(let n of pd){let i=t.getAttribute(n);i===null||!gd.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function $a(t){for(let e of Array.from(t.attributes))md(e.name,e.value)&&t.removeAttribute(e.name);fd(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!ud.has(n.localName)||n.namespaceURI!==Ua?n.remove():$a(n)}else e.remove()}function ae(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!==Ua||e.getElementsByTagName("parsererror").length>0?null:($a(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function fn(t){return t.text}function Le(t){return ft(t)[0]??null}function ft(t){let e=hd(t);return e?so(e,120):[]}function hd(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 ht(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var Ga={one:"item",other:"items"};function bd(t,e=Ga){let n=ht(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function qa(t){return Le(t.image_url)!==null}var hn=new Map;function Sd(t){let e=t.icon_svg;if(!e)return!1;let n=hn.get(e);return n===void 0&&(n=ae(e)!==null,hn.size>=256&&hn.clear(),hn.set(e,n)),n}function go(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&qa(i)||e&&Sd(i))}var Ka=new WeakMap;function yd(t,e,n){let i=e.length,o=dt(),r=Ka.get(t),a=n&&r&&wi(r.options,e)?r.plan:null,s=!a&&!n&&vi(i,o)?lt(t):null,l=a??Ei(i,o,s?.rowWidths??null,s?.gridWidth??null);return n||Ka.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((c,d)=>{c.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(d))}),l.cols}function za(t,e){if(e.loading||!e.interactive)return null;let n=e.options[he(t)];return n?.is_tappable?n:null}var Td={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=za(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!po(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)=>{za(t,e)&&e.onHighlight(he(t))},onLeave:(t,e)=>e.onHighlight(-1,he(t))};function ja(t,e,n,i,o,r,a,s="",l="below",c=!0,d=!0,u=!0,g=!0,m){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)),U(p,Td,{options:e,onSelect:i,onHighlight:o,loading:a,interactive:g});let f=p.dataset.aiaGroup!==s;p.dataset.aiaGroup=s;let h=go(e,c,d);xd(p,e,n,r,a,{showIcons:c&&h,showImages:d&&h,showCounts:u,picked:m});let x=yd(p,e,a);vd(p,e.length,x,a,l),f&&(p.scrollTop=0)}function xd(t,e,n,i,o,r){let a=o?"1":"0",s=t.dataset.aiaGroup??"",{showIcons:l,showImages:c,showCounts:d}=r,u=l?p=>p.icon??p.icon_svg??"":()=>"",g=c?p=>`${Le(p.image_url)??""}${(p.imageCollage??[]).join("")}`:()=>"",m=d?p=>ht(p.item_count)??"":()=>"";ee(t,e,{keyOf:p=>`${p.text}\0${p.parameter??""}\0${p.parameterLabel??""}\0${u(p)}\0${g(p)}\0${m(p)}\0${a}\0${s}`,create:(p,f)=>{let h=Ed(p,o,r);return o||(h.dataset.aiaEntering=""),h},update:(p,f,h)=>{if(fo.get(p)!==(f.matchedText??"")){let T=p.querySelector(".magicx-aia-option-text");T&&Qa(T,f),fo.set(p,f.matchedText??"")}let x=h===n&&!o;p.id=`${i}-option-${h}`,p.dataset.aiaIndex=String(h),p.setAttribute("aria-selected",String(r.picked?r.picked.includes(f.text):x));let y=p.querySelector(".magicx-aia-checkbox");r.picked&&f.is_tappable?(y||(y=document.createElement("span"),y.className="magicx-aia-checkbox",y.setAttribute("aria-hidden","true"),p.querySelector(".magicx-aia-option-content")?.prepend(y)),y.dataset.checked=String(r.picked.includes(f.text)),y.textContent=r.picked.includes(f.text)?"\u2713":""):y?.remove(),p.classList.toggle("magicx-aia-option--highlighted",x),p.classList.toggle("magicx-aia-option--live-match",!!f.liveMatch&&!o)}})}function vd(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(Vi,`${Bi(a,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var fo=new WeakMap;function Qa(t,e){if(t.replaceChildren(),e.matchedText)for(let n of Ii(fn(e),e.matchedText))if(n.bold){let i=document.createElement("strong");i.className="magicx-aia-option-match",n.partial&&i.setAttribute("data-aia-match-partial",""),i.textContent=n.text,t.appendChild(i)}else t.appendChild(document.createTextNode(n.text));else t.appendChild(document.createTextNode(fn(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 Ed(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?ft(t.image_url):[],c=l[0];if(c){let m=document.createElement("span");m.className="magicx-aia-option-image",m.setAttribute("aria-hidden","true");let p=(t.imageCollage??[]).map(f=>ft(f)).filter(f=>f.length>0);p.length>1&&m.setAttribute("data-aia-collage",String(p.length));for(let f of p.length>1?p:[l]){let h=document.createElement("img");h.setAttribute("alt",""),h.setAttribute("loading","lazy"),h.setAttribute("decoding","async"),h.setAttribute("referrerpolicy","no-referrer"),h.setAttribute("draggable","false");let x=0;h.onload=()=>m.setAttribute("data-aia-image-loaded",""),h.onerror=()=>{let y=f[++x];y?h.src=y:h.hidden=!0},h.src=f[0],m.appendChild(h)}s.appendChild(m),r.dataset.aiaImage=""}let d=!c&&n&&t.icon_svg?ae(t.icon_svg):null;if(d){let m=document.createElement("span");m.className="magicx-aia-option-icon",m.setAttribute("aria-hidden","true"),m.innerHTML=d,s.appendChild(m),t.icon&&(r.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",Qa(u,t),fo.set(r,t.matchedText??""),s.appendChild(u),t.tag){let m=document.createElement("span");m.className="magicx-aia-option-tag",m.textContent=t.tag,s.appendChild(m)}let g=o?ht(t.item_count):null;if(g!==null){let m=document.createElement("span");m.className="magicx-aia-option-count",m.textContent=g,s.appendChild(m),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(s),r}var wd=120,Pd={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(zt(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},Xa=new WeakMap,Ya=new WeakMap;function Ja(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=Ad(),t.appendChild(r),K(r);let c=r.querySelector("[data-aia-time-done]");c&&(c.disabled=!1)}let a={view:e,callbacks:i,interactive:o};Xa.set(r,a),U(r,Pd,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=$t(e.minutes));for(let c of qt){let d=r.querySelector(`[data-aia-time-column="${c}"]`);d&&Ld(d,c,e.minutes)}}function Ld(t,e,n){let i=Kt(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=bn(t);if(o.settle)return;let r=i*Gt;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function bn(t){let e=Ya.get(t);return e||(e={syncedTop:null,settle:null},Ya.set(t,e)),e}function Cd(t,e,n){let i=bn(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(()=>Za(t,e,n),wd)}function Za(t,e,n){let i=bn(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=Xa.get(t);if(!o||!o.interactive)return;let r=ui(n,e.scrollTop);r!==Kt(n,o.view.minutes)&&o.callbacks.onTimeChange(zt(n,o.view.minutes,r))}function Ad(){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 qt){if(r==="minute"){let a=document.createElement("span");a.className="magicx-aia-time-wheel-separator",a.textContent=":",n.appendChild(a)}n.appendChild(Id(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 Id(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),di(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",()=>Cd(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{bn(n).settle&&Za(t,n,e)}),n}var Ue="data-aia-fit",Sn="--aia-dropdown-fit-height",es=8,Od=160;function ho({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,a=null,s=null,l=null,c=!1,d=()=>{t.removeAttribute(Ue),t.style.removeProperty(Sn)},u=()=>{if(be(t)){c=!0;return}c=!1,Ji(t,t.getBoundingClientRect().height)},g=y=>`${r}|${(y??t).scrollHeight}|${t.offsetWidth}`,m=y=>s?.key===g(y)?s.height:null,p=y=>{let T=g(y);if(s?.key===T)return s.height;let P=y?.scrollTop??0;t.removeAttribute(Ue);let b=t.offsetHeight;return t.setAttribute(Ue,""),y&&P&&(y.scrollTop=P),s={key:T,height:b},b},f=()=>{if(i)return;if(!e()){o=!1;return}let y=be(t),T=y?Xi(t):null;y&&l!==y&&(l=y,y.finished.then(h,h)),!y&&c&&u(),o||(o=!0,d());let P=t.hasAttribute(Ue),b=$(t,".aia-grid")?.getAttribute("data-aia-group")??null,v=b!==r;r=b;let w=kd(t,n);if(w===null)return;let S=Md(t);if(P){let H=y?m(S):p(S);if(H!==null&&H<=w){d(),u();return}}else if((T??t.offsetHeight)<=w)return;let L=`${Math.max(Od,Math.floor(w))}px`,C=t.style.getPropertyValue(Sn)!==L;C&&t.style.setProperty(Sn,L),P?v&&S&&(S.scrollTop=0):t.setAttribute(Ue,""),(C||!P)&&u()},h=()=>{i||a!==null||!n||(a=n.requestAnimationFrame(()=>{a=null,f()}))},x=n?.visualViewport??null;return x?.addEventListener("resize",h),x?.addEventListener("scroll",h),n?.addEventListener("resize",h),n?.addEventListener("scroll",h,{capture:!0,passive:!0}),f(),{update:f,destroy(){i||(i=!0,a!==null&&n?.cancelAnimationFrame(a),x?.removeEventListener("resize",h),x?.removeEventListener("scroll",h),n?.removeEventListener("resize",h),n?.removeEventListener("scroll",h,{capture:!0}))}}}function Md(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function kd(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-es:i+o-s-es}var Rd=[159,119,164];function xn(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()),Ni(e),e}var yn=new WeakMap;function _d(t,e,n){let i=yn.get(t);if(i||(i={button:ua(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),yn.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=qi({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var Tn=new WeakMap;function ts(t){let e=Tn.get(t);if(e){e.update();return}Tn.set(t,ho({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function bo(t){Tn.get(t)?.destroy(),Tn.delete(t),Zi(t);let e=yn.get(t);e&&(e.controller?.destroy(),yn.delete(t))}function vn(t,e){let n=e.strings??k(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:a,showPills:s,isActivePillSelected:l,onSelect:c,onHighlight:d,onPillClick:u,onSkip:g}=e,m=Fn(e.pills,n.keepTyping),p=Vn(m),f=s&&m.length>0,h=i.length>0,x=e.products.length>0,y=e.formatType==="time"&&e.timeView!=null,T=e.formatType==="location"&&e.locationView!=null,P=r&&(h||f||a||x||y||T);if(P?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"),!P){mo(t,!1),Oa(t),ts(t),un(t,null,{visible:!1});return}x?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute(to,e.fullWidth===!0),gt(t),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let b=t.querySelector(".aia-stack");b||(b=document.createElement("div"),b.className="aia-stack",b.style.setProperty("--aia-stack-space","8px"),t.appendChild(b));let v=e.showSkipButton&&p&&!e.isInputEmpty,w=f||a&&s||v,S=b.querySelector(".magicx-aia-pill-bar");if(w){S||(S=document.createElement("div"),S.className="magicx-aia-pill-bar aia-cluster",S.setAttribute("data-nowrap",""),S.setAttribute("data-aia-pillbar",""),b.insertBefore(S,b.firstChild));let te=f||a&&s,E=S.querySelector(".magicx-aia-pill-scroll");te?(E||(E=document.createElement("span"),E.className="magicx-aia-pill-scroll",E.setAttribute("data-aia-pill-scroll",""),S.insertBefore(E,S.firstChild)),mn(E,m,0,u,!0,a,l)):E&&E.remove(),Nd(S,v,a||e.skipDisabled,m[0],g,n)}else S&&S.remove();let L=e.suggestions[0],C=L?`${L.parameter} ${L.text}`:"",H=R(e.formatType),F=H&&!a;ja(b,H?[]:i,o,c,d,e.listboxId,a,C,e.optionsPosition??"below",e.showOptionIcons??!0,e.showOptionImages??!0,e.showOptionCounts??!0,!e.skipDisabled,e.multiSelectView?.picked),t.setAttribute("aria-multiselectable",String(!!e.multiSelectView)),$d(b,!!e.multiSelectView,e.skipDisabled||a,e.onMultiSelectCommit,n.done),_d(t,b.querySelector(".aia-grid"),n),La(b,F?i:[],o,e.listboxId,F?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart,floor:_i(e.formatType,e.dateRangeStart),references:e.dateReferences??[]},{onSelect:c,onHighlight:d,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),Ja(b,e.formatType==="time"&&!a?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),Ma(b,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,reediting:e.isReediting??!1});let I=b.querySelector(".magicx-aia-skeleton-bars");if(a&&(!h||_(e.formatType))){if(!I){I=document.createElement("div"),I.className="magicx-aia-skeleton-bars",I.setAttribute("data-aia-skeleton-bars","");for(let te of Rd){let E=document.createElement("span");E.className="magicx-aia-skeleton-bar",E.style.width=`${te}px`,I.appendChild(E)}b.appendChild(I)}}else I&&I.remove();Va(b,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart),mo(t,!a),Bd(b,e.onSeeAllResults,n.seeAllResults);let G=b.querySelector(".magicx-aia-footer")??Wd(n),se=o>=0&&!!i[o]?.is_tappable;Fd(G,Hi(se,e.isInputEmpty,n)),G.isConnected||b.appendChild(G),Dd(b,[".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","[data-aia-see-all]",".magicx-aia-footer"]),Wi(b,b.querySelector(".magicx-aia-multi-done")),no(t,b,{eligible:h&&!x&&!H&&!y&&!T&&!e.onSeeAllResults&&!e.fullWidth,loading:a}),ts(t),un(t,Yi(s?m:[]),{visible:!0,anchorBottom:e.optionsPosition==="above"})}function Dd(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 Hd={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function Nd(t,e,n,i,o,r){U(t,Hd,{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),K(a)),a.textContent!==r.skip&&(a.textContent=r.skip),a.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),a.disabled=n}function Fd(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 Wd(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=Di(),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 Vd={itemSelector:".magicx-aia-see-all",onClick:(t,e,n)=>{e.submit&&(n.stopPropagation(),e.submit())}};function Bd(t,e,n){let i=t.querySelector(":scope > [data-aia-see-all]");if(!e){i?.remove();return}if(!i){i=document.createElement("div"),i.className="magicx-aia-see-all-row",i.dataset.aiaSeeAll="";let r=document.createElement("button");r.type="button",r.tabIndex=-1,r.className="magicx-aia-see-all",r.disabled=!0,i.appendChild(r),t.appendChild(i),K(r)}U(i,Vd,{submit:e});let o=i.querySelector("button");o&&(o.textContent!==n&&(o.textContent=n),o.disabled=!1)}var Ud={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function $d(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.setAttribute("data-aia-multi-done",""),s.disabled=!0,r.appendChild(s),t.appendChild(r),K(s)}U(r,Ud,{commit:i,disabled:n});let a=r.querySelector("button");a&&(a.textContent=o,a.disabled=n)}function ns(t,e){let n=xn(e.listboxId);return t.appendChild(n),{dropdown:n}}function So(t,e,n){let i=pt(e);vn(t.dropdown,{strings:n.strings,suggestions:e.editingIdentified?[{parameter:e.editingIdentified.parameter,text:ie(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,dateReferences:i.references,timeView:e.timeView,multiSelectView:e.dropdownMultiSelect,locationView:e.locationView,isReediting:e.editingParam!=null,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 Gd="[data-aia-chip-remove]";function yo(t,e){let n=e;if(!n||n.nodeType===void 0)return null;let o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(Gd)??null;return o&&t.contains(o)?o:null}function To(t,e){let n=null,i=c=>{n=null;let d=c;if(d.button)return;let u=yo(t,c.target);if(!u)return;c.preventDefault(),c.stopPropagation();let g=u.dataset.aiaChipRemove,m=d.pointerType==="touch"||d.pointerType==="pen";n={id:g,x:d.clientX,y:d.clientY,pending:m},!m&&g&&e(g)},o=c=>{if(!n?.pending)return;n.pending=!1;let d=c;if(Math.hypot(d.clientX-n.x,d.clientY-n.y)>10)return;let g=t.getRootNode().elementFromPoint?.(d.clientX,d.clientY)??c.target,m=yo(t,g)?.dataset.aiaChipRemove;m&&m===n.id&&e(m)},r=()=>{n&&(n.pending=!1)},a=c=>{!n&&!yo(t,c.target)||(c.cancelable&&c.preventDefault(),c.type==="click"&&(c.stopImmediatePropagation(),n=null))},s={capture:!0},l={capture:!0,passive:!1};return t.addEventListener("pointerdown",i,s),t.addEventListener("pointerup",o,s),t.addEventListener("pointercancel",r,s),t.addEventListener("touchstart",a,l),t.addEventListener("mousedown",a,s),t.addEventListener("click",a,s),()=>{t.removeEventListener("pointerdown",i,s),t.removeEventListener("pointerup",o,s),t.removeEventListener("pointercancel",r,s),t.removeEventListener("touchstart",a,l),t.removeEventListener("mousedown",a,s),t.removeEventListener("click",a,s)}}var qd=340;function xo(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let d=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let u=t.getBoundingClientRect().height;if(u!==0){if(d===0||Math.abs(u-d)<.5){t.style.height=`${u}px`;return}t.style.height=`${d}px`,t.getBoundingClientRect(),t.style.height=`${u}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(d=>{for(let g of d)if(g.target!==t){n();return}let u=t.getBoundingClientRect().width;Math.abs(u-i)<.5||(i=u,n())}):null,r=()=>{for(let d of Array.from(t.children))o?.observe(d)},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 c=!1;return t.ownerDocument.fonts?.ready.then(()=>{c||n()}),n(),()=>{c=!0,t.removeEventListener("load",s,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(a),t.style.height=""}}var as=2600,Kd=3,Po="data-aia-hint",wo="magicx-aia-hint",ss="data-aia-hint-el",zd={position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--aia-hint-color, #999)",userSelect:"none"},jd=280,Qd=320,Yd=380,vo="cubic-bezier(0.25, 0.1, 0.25, 1)",is=new Set(["a","an","the","some","my"]),Pn=new WeakMap;function Xd(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function os(t,e){let n=t.text.trim(),i=e.trim(),o=[];i&&n.toLowerCase().startsWith(`${i.toLowerCase()} `)&&(n=n.slice(i.length+1).trim());let r=i?i.split(/\s+/):[],a=null;r.length>1&&is.has(r[r.length-1].toLowerCase())&&(a=r.pop()??null);let s=r.join(" ");s&&o.push({key:`w:${s.toLowerCase()}`,text:s,icon:null});let l=null,[c,...d]=n.split(/\s+/);d.length&&c&&is.has(c.toLowerCase())&&(l=c,n=d.join(" "));let u=l??a;u&&o.push({key:`w:${u.toLowerCase()}`,text:u,icon:null});let g=t.icon_svg?ae(t.icon_svg):null;return o.push({key:`c:${g??""}:${n}`,text:n,icon:g}),o}function Jd(t,e){let n=t.createElement("span");if(n.className=`${wo}__word`,n.dataset.key=e.key,n.style.display="inline-block",e.icon){let i=t.createElement("span");i.className=`${wo}__icon`,Object.assign(i.style,{display:"inline-flex",width:"1em",height:"1em",marginRight:"0.25em",verticalAlign:"-0.125em",opacity:"var(--aia-hint-icon-opacity, 0.7)"}),i.innerHTML=e.icon;let o=i.querySelector("svg");o&&(o.style.width="100%",o.style.height="100%"),n.appendChild(i)}return n.appendChild(t.createTextNode(e.text)),n}function Eo(t,e,n){return typeof t.animate=="function"?t.animate(e,n):null}function En(t,e){let n=t.ownerDocument?.defaultView;if(!n)return;let i=n.getComputedStyle(t),o=d=>Number.parseFloat(d)||0,r=t.offsetLeft+o(i.borderLeftWidth)+o(i.paddingLeft),a=t.offsetTop+o(i.borderTopWidth)+o(i.paddingTop),s=t.clientWidth-o(i.paddingLeft)-o(i.paddingRight),l=t.offsetParent instanceof HTMLElement?t.offsetParent.clientWidth-r:0,c=Math.max(s,l);e.style.left=`${r}px`,e.style.top=`${a}px`,c>0&&(e.style.maxWidth=`${c}px`),e.style.font=i.font,e.style.lineHeight=i.lineHeight,e.style.letterSpacing=i.letterSpacing,e.style.fontWeight="var(--aia-hint-font-weight, 300)"}function rs(t,e,n,i){let{el:o}=t,r=o.ownerDocument,a=new Map;for(let m of Array.from(o.children))m.dataset.leaving===void 0&&m.dataset.key&&a.set(m.dataset.key,m);let s=new Map;for(let[m,p]of a)s.set(m,p.offsetLeft);let l=new Set(e.map(m=>m.key));for(let[m,p]of a){if(l.has(m))continue;if(!n){p.remove();continue}p.dataset.leaving="",p.style.position="absolute",p.style.left=`${s.get(m)??0}px`,p.style.top=`${p.offsetTop}px`;let f=Eo(p,[{opacity:1,filter:"blur(0)"},{opacity:0,filter:"blur(2px)"}],{duration:jd,easing:vo,fill:"forwards"});f?f.onfinish=()=>p.remove():p.remove()}let c=Array.from(o.children).filter(m=>m.dataset.leaving!==void 0),d=[];if(e.forEach((m,p)=>{p>0&&d.push(r.createTextNode(" ")),d.push(a.get(m.key)??Jd(r,m))}),o.replaceChildren(...d,...c),!n)return;let u=new Map;for(let m of d)m instanceof HTMLElement&&m.dataset.key&&u.set(m.dataset.key,m);let g=0;for(let m of e){let p=u.get(m.key);if(p)if(!a.has(m.key))Eo(p,[{opacity:0,filter:"blur(2px)"},{opacity:1,filter:"blur(0)"}],{duration:Qd,delay:i?80*g++:180+60*g++,easing:vo,fill:"backwards"});else{let h=(s.get(m.key)??p.offsetLeft)-p.offsetLeft;Math.abs(h)>.5&&Eo(p,[{transform:`translateX(${h}px)`},{transform:"none"}],{duration:Yd,easing:vo})}}}function wn(t){let e=Pn.get(t);e&&(e.timer!==null&&clearInterval(e.timer),e.resize?.disconnect(),e.el.remove(),Pn.delete(t),t.removeAttribute(Po),t.removeAttribute("aria-placeholder"))}function ls(t,e,n,i){let o=i.filter(p=>p.text.trim()!=="").slice(0,Kd),r=t.parentElement;if(!e||o.length<2||!r){wn(t);return}let a=`${n}\0${o.map(p=>`${p.text}${p.icon_svg??""}`).join("\0")}`,s=Pn.get(t);if(s&&s.key===a&&s.el.isConnected){En(t,s.el);return}wn(t);let l=t.ownerDocument,c=l.createElement("span");c.className=wo,c.setAttribute(ss,""),c.setAttribute("aria-hidden","true"),Object.assign(c.style,zd),r.insertBefore(c,t),t.setAttribute(Po,""),n.trim()&&t.setAttribute("aria-placeholder",n.trim()),En(t,c);let d=l.defaultView,u=d?.ResizeObserver?new d.ResizeObserver(()=>{c.isConnected&&En(t,c)}):null;u?.observe(r);let g=Xd(t),m={key:a,lead:n,options:o,index:0,el:c,timer:null,resize:u};Pn.set(t,m),rs(m,os(o[0],n),!g,!0),!g&&(m.timer=setInterval(()=>{if(!t.isConnected||!c.isConnected){wn(t);return}t.ownerDocument?.hidden||(m.index=(m.index+1)%m.options.length,En(t,c),rs(m,os(m.options[m.index],m.lead),!0,!1))},as))}function Lo(t){wn(t)}function Co(t){return(t.find(n=>n.type?.kind!=="traditional_autocomplete")?.options??[]).filter(n=>n.is_tappable!==!1).map(n=>({text:n.text,icon_svg:n.icon_svg}))}var Zd=6,eu=.3;function cs(t){return t<=0?"0px":`${(-Math.min(eu,2*Zd/t)).toFixed(3)}px`}var ds=new Map;function tu(t,e,n){let i=ds.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`;ds.set(e,s),t.style.setProperty("--aia-chip-image-fit",s)},o.src=e}function Ao(t){let{input:e,segments:n,newParamId:i,editingParamId:o,placeholderText:r}=t,a=t.showChipIcons??!0,s=t.showChipImages??!0,l=t.showChipRemove??!1,c=n.length===0;e.dataset.aiaEmpty=c?"true":"false",Zr(e,c?r:""),ls(e,c,r,t.hintOptions??[]);let d=n.map(T=>T.type==="completed"?`${T.type}:${T.value}${a?T.param.icon??T.param.icon_svg??"":""}${s?Le(T.param.image_url)??"":""}${l?"x":""}`:T.type==="identified"?`${T.type}:${T.value}${T.param.id}${l?"x":""}`:`${T.type}:${T.value}`).join("\0"),u=e.dataset.segKey??"",g=e.dataset.newParamId??"",m=e.dataset.editingParamId??"";if(d===u&&(i??"")===g&&(o??"")===m)return;if(d===u){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let T of e.querySelectorAll("strong[data-param-id]")){let P=T.dataset.paramId,b=T.dataset.seg==="completed"&&P===i;T.classList.toggle("magicx-aia-shimmer-revealed",b),T.classList.toggle("magicx-aia-shimmer-sweep",b),T.classList.toggle("magicx-aia-segment--editing",P===o)}return}let p=Pr(e),f=p?j(e):null;e.dataset.segKey=d,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let h=D(e),x=h.createDocumentFragment(),y=0;for(let T of n)if(y+=T.value.length,T.type==="completed"){let P=h.createElement("strong");P.dataset.seg="completed",P.dataset.paramId=T.param.id;let b=T.param.id===i,v=T.param.id===o,w=["magicx-aia-segment","magicx-aia-segment--completed"];b&&w.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),v&&w.push("magicx-aia-segment--editing"),P.className=w.join(" "),P.style.letterSpacing=cs(T.value.length);let S=s?Le(T.param.image_url):null;if(S){let C=h.createElement("span");C.className="magicx-aia-segment-image",C.setAttribute("contenteditable","false"),C.setAttribute("aria-hidden","true"),C.style.setProperty("--aia-chip-image",`url("${S}")`),tu(C,S,h),P.appendChild(C),P.dataset.aiaImage=""}let L=!S&&a&&T.param.icon_svg?ae(T.param.icon_svg):null;if(L){let C=h.createElement("span");C.className="magicx-aia-segment-icon",C.setAttribute("contenteditable","false"),C.setAttribute("aria-hidden","true"),C.innerHTML=L,P.appendChild(C),T.param.icon&&(P.dataset.aiaIcon=T.param.icon)}P.appendChild(h.createTextNode(T.value)),l&&P.appendChild(us(h,T.param.id)),x.appendChild(P)}else if(T.type==="identified"){let P=h.createElement("strong");P.dataset.seg="identified",P.dataset.paramId=T.param.id;let b=["magicx-aia-segment","magicx-aia-segment--completed"];T.param.id===o&&b.push("magicx-aia-segment--editing"),P.className=b.join(" "),P.style.letterSpacing=cs(T.value.length),P.textContent=T.value,l&&P.appendChild(us(h,T.param.id)),x.appendChild(P)}else x.appendChild(h.createTextNode(T.value));e.replaceChildren(x),e.dataset.aiaTextLength=String(y),f!=null?V(e,Math.max(0,Math.min(f,y))):p&&V(e,y)}function us(t,e){let n=t.createElement("span");return n.className="magicx-aia-segment-remove",n.setAttribute("contenteditable","false"),n.setAttribute("aria-hidden","true"),n.dataset.aiaChipRemove=e,n.innerHTML='<svg viewBox="0 0 10 10" aria-hidden="true"><path d="M2.5 2.5l5 5M7.5 2.5l-5 5"/></svg>',n}var nu='<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 ms(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=nu.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function ps(t){let e=t.store.get();return(!!e.text||e.completedParams.length>0)&&!!t.onSubmit}function gs(t){if(!t.onSubmit)return;t.endTypedWord?.();let e=t.store.get();t.onSubmit(Ee(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields}))&&t.afterSubmit?.()}function iu(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function fs(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 hs(t,e){let{listboxId:n}=e,i=xn(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",iu()?"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,c=null;e.submitButton===void 0?(l=ms(e.strings),o.appendChild(l),c=l):e.submitButton!==null&&(c=e.submitButton,c.hasAttribute("data-aia-submit")||c.setAttribute("data-aia-submit",""),c.setAttribute("data-aia-submit-slot",""),o.appendChild(c));let d=new AbortController,{signal:u}=d,g=!1,m=0,p=()=>{let b=Bt(a);return b.length>0&&b[0]!==b[0].toUpperCase()?b[0].toUpperCase()+b.slice(1):b},f=()=>e.handleChange(p()),h=()=>{let b=ge(a)?.node??null;if(!b||!a.contains(b))return null;let S=(b.nodeType===Node.ELEMENT_NODE?b:b.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return S&&wr(a,S)?null:S};o.addEventListener("click",b=>{b.target?.closest("[data-aia-pill]")||a.getRootNode().activeElement?.closest("[data-aia-location]")||a.focus()},{signal:u});let x=null,y=()=>{let b=e.showChipRemove??!1;b!==(x!==null)&&(x?.(),x=b?To(a,v=>e.removeParam(v)):null)};if(y(),u.addEventListener("abort",()=>{x?.(),x=null}),a.addEventListener("input",()=>{if(g){e.handleCompositionText(p());return}m=performance.now(),f(),e.handleCaretAfterInput(j(a))},{signal:u}),D(a).addEventListener("selectionchange",()=>{let b=ge(a);if(!b||!a.contains(b.node))return;let v=b.collapsed?h():null,w=e.store.get(),S=w.editingParam?.id??w.editingIdentified?.id??null;if(v&&v!==S){e.startEditingParam(v);return}performance.now()-m<50||e.handleCaretMove(j(a))},{signal:u}),a.addEventListener("click",b=>{let v=Jn(a,b.target);v&&(e.startEditingParam(v),Zn(a,v))},{signal:u}),a.addEventListener("compositionstart",()=>{g=!0,a.setAttribute("data-aia-composing","true")},{signal:u}),a.addEventListener("compositionend",()=>{g=!1,a.removeAttribute("data-aia-composing"),f()},{signal:u}),a.addEventListener("beforeinput",b=>{let v=b,w=v.inputType;if(w==="insertParagraph"||w==="insertLineBreak"||w==="insertFromDrop"){b.preventDefault();return}if(w.startsWith("insert")||w.startsWith("delete")){let S=w.startsWith("delete")?"":v.data??"";e.replaceEditingRange(S)&&b.preventDefault()}},{signal:u}),a.addEventListener("paste",b=>{b.preventDefault();let v=(b.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!v)return;let w=D(a),S=ve(a);if(!S||!a.contains(S.startContainer))return;S.deleteContents();let L=w.createTextNode(v);S.insertNode(L),S.setStartAfter(L),ot(a,S.startContainer,S.startOffset),f()},{signal:u}),a.addEventListener("keydown",b=>e.handleKeyDown(b),{signal:u}),a.addEventListener("focus",()=>e.store.set({isFocused:!0}),{signal:u}),a.addEventListener("blur",()=>e.store.set({isFocused:!1}),{signal:u}),c&&c.addEventListener("click",b=>{ps(e)&&(b.stopPropagation(),gs(e))},{signal:u}),e.autoFocus!==!1){a.focus();let b=ge(a);(!b||!a.contains(b.node))&&ot(a,a,0)}if(typeof ResizeObserver<"u"){let b=new ResizeObserver(()=>fs(a,s));b.observe(a),d.signal.addEventListener("abort",()=>b.disconnect(),{once:!0})}let P=xo(r);return d.signal.addEventListener("abort",P,{once:!0}),{input:a,inlinePillContainer:s,dropdown:i,submitButton:l,abort:d,syncChipRemove:y}}function Io(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:a}=t,{pillPlacement:s,setActivePill:l,selectOption:c,store:d}=n;t.syncChipRemove(),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 x=n.strings??k();a.getAttribute("aria-label")!==x.submit&&a.setAttribute("aria-label",x.submit);let y=a.querySelector("svg");y&&y.getAttribute("aria-label")!==x.submit&&y.setAttribute("aria-label",x.submit);let T=!!e.text||e.completedParams.length>0;a.disabled=!T,a.toggleAttribute("data-aia-ready",T&&e.isReady)}let g=i.dataset.newParamId??"",m=e.newParamId!==null&&e.newParamId!==g;if(Ao({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,hintOptions:s==="inline"?[]:Co(e.actionableSuggestions),showChipRemove:n.showChipRemove??!1}),s==="inline"){let x=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,y=Nn(e.actionableSuggestions);x||y.length>0?mn(o,y,0,l,!1,x,e.isActivePillSelected):io(o)}else io(o);fs(i,o),m?(i.focus(),V(i,e.caretOffset??e.text.length)):e.isFocused&&Bt(i)!==e.text&&!i.hasAttribute("data-aia-composing")&&V(i,e.text.length);let p=e.editingParam?et(e.editingParam):e.editingIdentified?{parameter:e.editingIdentified.parameter,text:ie(e.editingIdentified.parameter),required:!0,options:[]}:null,f=e.dropdownSuggestion??p??e.actionableSuggestions[0],h=pt(e);vn(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:p?[p]: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:h.selectedIso,selectedDateRange:h.selectedRange,dateRangeStart:h.rangeStart,dateReferences:h.references,timeView:e.timeView,multiSelectView:e.dropdownMultiSelect,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:c,onHighlight:(x,y)=>{y!==void 0&&d.get().activeDropdownIndex!==y||d.set({activeDropdownIndex:x})},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:x=>d.set({isFocused:x}),onSeeAllResults:n.seeAllResults&&e.text.trim().length>0&&ps(n)?()=>gs(n):void 0,fullWidth:n.seeAllResults===!0})}function Oo(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 c=i.shift();c;c=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[d,u]=c;for(let g of n)g(d,u)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function bs(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)},c={...a,...o(a)};r(c,l)})}}var Mo=new WeakSet,Ss=new WeakMap;function Ts(t){return t.nodeType===Node.DOCUMENT_NODE}function ou(t){return Ts(t)?t:t.ownerDocument}function ru(t){let e=Ss.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(vs),Ss.set(t,i),i)}catch{return null}}function ys(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=vs,e.appendChild(n)}function xs(t){if(typeof document>"u")return;let e=t??document;if(Mo.has(e))return;let n=ou(e);if(Ts(e)){let r=e.head??e.documentElement;if(!r)return;ys(n,r),Mo.add(e);return}let i=ru(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):ys(n,e),Mo.add(e)}var vs=`.aia-stack {
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: var(--aia-stack-space, 0.5rem);
@@ -3902,5 +3902,5 @@ function R(t){return t==="date"||t==="date-range"}function _(t){return t!=="opti
3902
3902
  padding-inline: 8px;
3903
3903
  font-size: var(--aia-skip-font-size, 13.5px);
3904
3904
  }
3905
- `;var Ln=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 Cn=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 An=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 nu(t){let e;try{e=new URL(t??X).host}catch{return null}let n=xt.get(e);return n?`https://${n}`:null}var vs=new WeakMap;function Es(t,e){if(!t.head)return;let n=nu(e);if(!n)return;let i=vs.get(t);i||(i=new Map,vs.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 bt=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 Mo(t){return t.isDropdownOpen&&!t.isLoading}var iu=50,ou=new Set(["search_started","submit","product_click","impression"]),ru="newParam",ws="suggestionRemoval",Ps="selectionAnimation",ko="skeletonExit",Ls="locationSearch",au=650,su=0;function lu(){return`:ac-${++su}:`}var Cs=170,As=160;function Is(){return{text:"",composing:null,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,skeletonPicked:null,skeletonRequested:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null,multiSelectDraft:null,locationSearch:null,locationFieldFocused:!1,editingIdentified:null}}var Ro=class{constructor(e,n={}){this.inputStore=Io(Is());this._listboxId=lu();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new An;this.boundary=new Ln;this.subscriberCount=0;this.emitter=new Cn(this.boundary);this.sessionId=crypto.randomUUID();this.lastRequestId=null;this.searchStartedSessionId=null;this.funnelTelemetry=null;this.pendingSearchStarted=!1;this.openWordText=null;this.locationMirrorText=null;this.locationMirrored=null;this.heldIdentified=null;this.waitingIdentified=null;this.lastImpressionKey="";this.visibleImpression=!1;this.destroyed=!1;this.locationAbort=null;this.locationSession=null;this.spacePickCaret=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=hs(this.inputStore,i=>Br(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 kt(this.store,e),this.pillsController=new Xt(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new ln({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new Jt(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new Yt(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 Mt(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,getPrependPlaceholder:()=>this.opts.prependPlaceholder,getAllOption:()=>this.opts.allOption===!0,onRequest:({query:i,signal:o,isCurrent:r})=>{Es(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:fe(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}},waitIdentified:(i,o)=>{this.waitingIdentified=i.length>0&&this.store.get().text===o?{text:o,candidates:i}:null}}),this.keyboardController=new Qt(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.unsubscribers.push(this.store.subscribe((i,o)=>{i.text===o.text&&i.completedParams===o.completedParams||i.suggestions.some(r=>r.leadsWithAll)&&ut(i.text,i.completedParams.length,i.leadInText)&&this.store.set({suggestions:i.suggestions.map(r=>r.leadsWithAll?{...r,leadsWithAll:!1}:r)})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.skippedParams.length!==0&&ut(i.text,i.completedParams.length,i.leadInText)&&(ut(o.text,o.completedParams.length,o.leadInText)||this.store.set({skippedParams:[]}))})),this.subscribeSkeletonMirror(),this.subscribeLocationMirror(),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}=tt(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===B(i)||this.store.set({pendingRangeStart:null})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.multiSelectDraft;o&&o.key!==B(i)&&this.store.set({multiSelectDraft:null});let r=i.timeDraft;!r||r.key===B(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=rr(o.text,i.text,a);if(l===null){this.store.set({pendingSpan:null});return}a=l}i.text.slice(a).trim().length===0||ir(i.segments,a)?this.store.set({pendingSpan:null}):a!==r.anchor&&this.store.set({pendingSpan:{anchor:a,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(Ts(this.opts.styleRoot??pe(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.locationMirrored=null,this.store.set({...Is(),isFocused:e,dropdownHeld:n,skipNextFetch:!0}),this.sessionId=crypto.randomUUID(),this.lastRequestId=null,this.lastImpressionKey="",this.pendingSearchStarted=!1,this.waitingIdentified=null,this.heldIdentified=null,this.openWordText=null,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&&(Zr(this.domRefs.input),Po(this.domRefs.input),ho(this.domRefs.dropdown)),this.dropdownRefs&&ho(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{start:i,end:o}=n;if(e===o)return this.removeWholeChip(n),this.scheduleSetCursor(i),!0;let{text:r}=this.store.get(),a=ti(r,e),s=r.slice(0,a)+r.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}removeWholeChip(e){let{text:n,removed:i}=sn(this.store.get().text,e.start,e.end);this.store.set(o=>({text:n,filterBase:Math.min(o.filterBase>e.start?Math.max(e.start,o.filterBase-i):o.filterBase,n.length),...this.withoutChip(o,e),pillTapped:!1,activeDropdownIndex:-1}))}removeParam(e){let n=this.store.get(),i=n.completedParams.find(l=>l.id===e),o=i?"completed":n.identifiedParams.some(l=>l.id===e)?"identified":null;if(!o)return!1;let r=()=>{let l=0;for(let c of this.store.get().segments)if(l+=c.value.length,c.type===o&&(c.param.id===e||c.type==="completed"&&i?.group&&c.param.group===i.group))return l;return null};if(r()===null)return!1;this.store.get().editingParam&&this.exitEditMode(),this.store.get().editingIdentified&&this.exitEditingIdentified();let a=r(),s=a===null?null:this.findChipSpanAt(a);return!s||s.kind!==o?!1:(this.removeWholeChip(s),this.store.get().isFocused&&this.scheduleSetCursor(s.start),!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(),V(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(c=>c.id===e);if(!i)return!1;let o=Y(i);if(!R(o))return!1;let r=o==="date-range"?at(i)??en(i.text):null,a=0,s=-1;for(let c of n.segments){if(c.type!=="text"&&c.param.id===e){s=a;break}a+=c.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:fi(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){let n=this.spacePickCaret;if(n!=null){this.spacePickCaret=null,this.reEdit.caretAfterInput(n),this.scheduleSetCursor(n);return}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)}handleCompositionText(e){let n=this.store.get();if(!(n.editingParam||n.editingIdentified)){if(e===n.text){n.composing&&this.store.set({composing:null});return}this.store.set({composing:{text:e,over:n.text}}),this.fetchController.previewComposition(e)}}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(!R(n.activeFormatType)||!n.dateView)return;let i=Gn(n.dateView,e);this.store.set({dateViewMonth:{...i,key:B(n)},activeDropdownIndex:-1})}setTime(e){let n=this.store.get();n.activeFormatType!=="time"||!n.timeView||this.store.set({timeDraft:{minutes:ke(e),key:B(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(Cr(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:B(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(", ")} ${k(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(li(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=B(n);this.cancelLocationSearch();let a=n.locationAutocomplete&&this.opts.locationSearch!==!1?_n(this.opts.apiConfig):null,s="loading";a?e.trim().length<Pt&&(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(Ls,()=>{this.runLocationSearch(o,e,a)},Fo)}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(Rn(r??a)),this.store.get().completedParams!==n.completedParams&&this.store.set({locationSearch:null}))}spacePicksTopPlace(e,n){if(n!==`${e.text} `)return!1;let i=e.locationView;if(e.activeFormatType!=="location"||!i||!e.isDropdownOpen||e.locationFieldFocused)return!1;let o=i.places[0],r=this.typedLocationQuery(e);return i.status==="done"&&!!o&&r===i.query&&kn(o,r)}typedLocationQuery(e){let n=this.typedLocationPhrase(e);return this.isReEditing(e)?n.trim():Wo(n)}isReEditing(e){return e.editingParam!=null&&e.editingAnchor!=null}typedLocationPhrase(e){if(this.isReEditing(e))return Li(e,e.optionQuery);let n=e.actionableSuggestions[0]?.parameter,i=0,o=0;for(let r of this.segmentsWithPending(e))i+=r.value.length,(r.type==="completed"||r.type==="identified"&&r.param.parameter!==n)&&(o=i);return e.text.slice(o)}segmentsWithPending(e){let n=[this.heldIdentified,this.waitingIdentified].flatMap(o=>o&&e.text.startsWith(o.text)&&e.text.slice(o.text.length).trim()===""?o.candidates:[]);if(n.length===0)return e.segments;let i=new Set(e.identifiedParams.map(o=>o.id));return Ot(e.text,e.completedParams,[...e.identifiedParams,...n.filter(o=>!i.has(o.id))])}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 jo(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 Qe&&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(Ls),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||A(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 Ee(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.optionsStyle!==void 0&&(this.container.dataset.aiaOptionsStyle=e.optionsStyle),e.pillPlacement!==void 0&&(this.container.dataset.pillPlacement=e.pillPlacement,this.store.set({})),(e.dropdownTrigger!==void 0||e.closeDropdownOnBlur!==void 0||e.prependPlaceholder!==void 0||e.showNonTappableOptions!==void 0||e.allOption!==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.seeAllResults!==void 0||e.showChipIcons!==void 0||e.showChipImages!==void 0||e.showChipRemove!==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(e.selectsAll){this.skipActivePill();return}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.dateFloor){let a=z(e);if(a&&a<o.dateFloor)return}if(o.activeFormatType==="date-range"){let a=z(e);if(a){let s=o.dateRangeStart;if(!s){this.store.set({pendingRangeStart:{iso:a,key:B(o)}});return}this.store.set({pendingRangeStart:null}),this.selectOption(Nr(s,a));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(ko),this.reEdit.selectOption(e);return}let r=jr({...o,placeholderText:o.leadInText},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,c=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),d=n.map(u=>{let g=l.toLowerCase().indexOf(u.text.toLowerCase(),c);return c=g+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(g,c)}});r.patch.completedParams=[...o.completedParams,...d],r.patch.newParamId=d[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:N(o.text,o.completedParams).rawQuery,selected_option:a.text,other_options:_(o.activeFormatType)?[]:o.filteredOptions.filter(s=>s.text!==a.text&&!s.selectsAll).map(s=>s.text),key:r.telemetry.key,position:_(o.activeFormatType)?null:fe(r.consumedSuggestion.options??[],a.text),chip_origin:"tap"});if(this.timers.clear(ko),n?(this.timers.clear(Ps),this.store.set({...r.patch,...mt(o,n.map(a=>a.text)),inSelectionAnimation:!1})):(this.store.set({...r.patch,...mt(o)}),this.startSelectionAnimationTimer()),this.timers.clear(ws),r.remainingActionable>0){let a=r.consumedSuggestion;this.timers.schedule(ws,()=>{this.store.get().suggestions.includes(a)&&this.store.set(s=>({suggestions:s.suggestions.filter(l=>l!==a)}))},Cs)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(Ps,()=>this.store.set({inSelectionAnimation:!1}),Cs)}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=""),Mo(e)&&!Mo(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!Mo(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!A(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,iu).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&&ou.has(e))return;if(!i&&e==="option"){let{key:r,position:a,chip_origin:s,...l}=n;n=l}let o=this.resolveSource();zr({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:de(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.container.dataset.aiaOptionsStyle=this.opts.optionsStyle??"floating",this.modeController=new bt(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()?o=>e.addProductToCart(o):void 0},get showChipIcons(){return e.opts.showChipIcons??!0},get showChipImages(){return e.opts.showChipImages??!0},get showChipRemove(){return e.opts.showChipRemove??!1},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,get seeAllResults(){return e.opts.seeAllResults===!0},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),handleCompositionText:o=>this.handleCompositionText(o),startEditingParam:o=>this.startEditingParam(o),removeParam:o=>this.removeParam(o),handleCaretAfterInput:o=>this.handleCaretAfterInput(o),handleCaretMove:o=>this.handleCaretMove(o),replaceEditingRange:o=>this.replaceEditingRange(o)};this.domRefs=fs(this.container,n);let i=()=>{this.domRefs&&Ao(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),Ao(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()?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=ts(this.container,n);let i=()=>{this.dropdownRefs&&bo(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),bo(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(tn),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()}))}))}subscribeLocationMirror(){this.unsubscribers.push(this.store.subscribe(e=>{if(e.activeFormatType!=="location"){this.locationMirrorText=null;return}!e.isDropdownOpen||e.text===this.locationMirrorText||(this.locationMirrorText=e.text,this.mirrorTypedIntoLocationSearch())}))}subscribeSkeletonMirror(){let e=Date.now();this.unsubscribers.push(this.store.subscribe((n,i)=>{let o=s=>s.dropdownLoading&&s.skeletonOptions!==null;if(!o(i)&&o(n)&&(e=Date.now()),!n.skeletonOptions)return;if(!i.isLoading&&n.isLoading){n.skeletonRequested||this.store.set({skeletonRequested:!0});return}if(!i.isLoading||n.isLoading)return;let r={skeletonOptions:null,skeletonSuggestion:null,skeletonPicked:null,skeletonRequested:!1};if(!n.skeletonExiting){this.store.set(r);return}let a=As-(Date.now()-e);this.timers.schedule(ko,()=>this.store.set(r),Math.min(As,Math.max(0,a)))}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(ru,()=>this.store.set({newParamId:null}),au)}))}handleChange(e,n){this.store.get().composing&&this.store.set({composing:null}),this.fetchController.endPreview();let i=this.store.get();if(n&&this.spacePicksTopPlace(i,e)){this.commitLocation(0);let l=this.store.get();l.completedParams!==i.completedParams&&(this.spacePickCaret=l.caretOffset??l.text.length);return}this.spacePickCaret=null,n&&e&&!i.text&&this.noteSearchStarted(),this.store.set({text:e,pillTapped:!1,activeDropdownIndex:-1});let{valid:o,invalid:r}=sr(e,i.completedParams);r.length>0&&this.store.set({completedParams:o});let a=this.heldIdentified;this.heldIdentified=null,this.waitingIdentified?.text!==e&&(this.waitingIdentified=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)}mirrorTypedIntoLocationSearch(){let e=this.store.get(),n=e.locationView;if(e.activeFormatType!=="location"||!n||!e.isDropdownOpen||e.locationFieldFocused)return;let i=B(e),o=this.typedLocationQuery(e);if(o.length<Pt){let r=this.locationMirrored;(this.typedLocationPhrase(e).trim()===""||o===""&&(r?.text.length??0)>e.text.length)&&r?.key===i&&r.query===n.query&&(this.locationMirrored=null,this.setLocationQuery(""));return}o!==n.query&&(this.setLocationQuery(o),this.locationMirrored={key:i,query:o,text:e.text})}isWordOpen(){return this.opts.commitOnWordEnd===!0&&this.openWordText===this.store.get().text}admitIdentified(e){let n=this.store.get(),{valid:i}=tt(n.text,n.completedParams,e);i.length!==0&&(this.store.set({identifiedParams:[...n.identifiedParams,...i]}),this.mirrorTypedIntoLocationSearch())}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.waitingIdentified;e&&r?.text===o.text&&(this.waitingIdentified=null,this.admitIdentified(r.candidates));let a=this.store.get();return a.completedParams!==o.completedParams||a.identifiedParams!==o.identifiedParams}maybeOpenPendingSpan(){let e=this.store.get();if(e.pendingSpan||e.actionableSuggestions.length===0)return;let n=ue(e.text,Math.min(e.filterBase,e.text.length),e.leadInText),i=nr(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);me(e.editingParam.options,i).some(r=>r.is_tappable)||(this.reEdit.exit(),this.fetchNow())}fetchNow(){let e=this.store.get(),{rawQuery:n,completedParams:i}=N(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,c=o+l+r,d=c.length,u={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:a,value:e.value,kind:e.kind,suggestionParameter:i.parameter,suggestionPlaceholder:ie(i.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:i.parameter,position:null,chip_origin:"tap"}),this.store.set({text:c,completedParams:[...n.completedParams,u],identifiedParams:n.identifiedParams.filter(g=>g.id!==i.id),newParamId:u.id,filterBase:d,caretOffset:d,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(d),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(_(o.activeFormatType)||this.isWordOpen())return;let r=rn({mode:n,finishWord:i,text:e,completedParams:o.completedParams,suggestions:o.suggestions,filterBase:o.filterBase,filterInProgress:o.filterInProgress,phraseExactMatch:this.fetchController.isPhraseExactMatch(),prependPlaceholder:this.opts.prependPlaceholder});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:N(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:fe(s,r.option.text),chip_origin:"typed"})}this.store.set(r.patch)}}};export{Ro as AIAutocomplete,ea as ATTRIBUTION_URL,yi as DATE_RANGE_META_END,Si as DATE_RANGE_META_START,$a as DEFAULT_OPTION_COUNT_UNIT,Bd as EDITOR_GROW_MS,wo as HINT_ATTR,as as HINT_EL_ATTR,rs as HINT_HOLD_MS,Mn as LOCATION_META_KEY,Pt as LOCATION_MIN_QUERY,Ni as MULTI_DONE_FIT_VAR,ad as MULTI_SELECT_TOGGLE_MIN_PX,rd as MULTI_SELECT_TOGGLE_SLOP_PX,bt as ModeController,tn as OPTIONS_GRID_MOBILE_QUERY,Wi as OPTION_ENTER_DELAY_VAR,Jl as OPTION_ENTER_FADE_MS,Zl as OPTION_ENTER_RISE_MS,ec as OPTION_ENTER_RISE_PX,Xl as OPTION_ENTER_STAGGER_MS,ro as OPTION_IMAGE_WIDTH,fa as PANEL_ENTER_DELAY_MS,ga as PANEL_ENTER_MS,oe as PANEL_GHOST_CLASS,ma as PANEL_GLIDE_MS,pa as PANEL_LEAVE_MS,Gl as PLACEHOLDER_FADE_OUT_MS,He as PLACEHOLDER_LEAVING_ATTR,ql as PLACEHOLDER_SWAP_GAP_MS,Ul as PLACEHOLDER_TYPE_MS,$l as PLACEHOLDER_WORD_PAUSE_MS,Xc as PRODUCT_IMAGE_WIDTH,Mr as PRODUCT_PATH_PREFIX,Yc as PRODUCT_ROW_PX_PER_LINE,Dr as RANGE_SEPARATOR,Ko as SCHEMA_VERSION,dn as SCROLL_ARROW_ATTR,ca as SCROLL_ARROW_BOTTOM_VAR,aa as SCROLL_ARROW_CLASS,sa as SCROLL_ARROW_FADE_MS,tc as SCROLL_ARROW_LABEL,la as SCROLL_ARROW_SCROLL_IDLE_MS,We as SCROLL_ARROW_VISIBLE_ATTR,$o as SKIPPED_PARAM_TEXT,Wn as SMART_SUGGESTION_SPARKLE_SVG,Pr as TIME_META_KEY,ii as TIME_STEP_MINUTES,qt as TIME_WHEEL_COLUMNS,Gt as TIME_WHEEL_ROW_HEIGHT,Ue as VIEWPORT_FIT_ATTR,Sn as VIEWPORT_FIT_HEIGHT_VAR,Rt as WEEKDAY_LABELS,Gn as addMonths,yo as attachChipRemove,io as attachProductRowWheel,Gi as attachScrollArrow,fo as attachViewportFit,_i as buildAttributionUrl,qn as buildDateOptions,Rn as buildLocationOption,N as buildQuery,Ee as buildSubmitResult,li as buildTimeOption,Po as cancelStartingHint,Kn as cellDay,z as cellIso,Jn as chipIdFromTap,Fr as computeOptionsGridLayout,Hi as containScroll,Io as createStore,ei as cursorIsAtEnd,Mi as dateCellMarks,Ri as dateFloorFor,pt as dateSelectionFor,Ji as destroyPanelMorph,et as editingSuggestion,Bt as extractPlainText,Yl as findMultiSelectDone,Fi as fitMultiSelectDone,Oe as formatAbsoluteDate,fr as formatDate,Hr as formatDateRange,ht as formatOptionCount,Vo as formatPlace,$t as formatTime,j as getCursorOffset,Di as getFooterHint,Vn as hasSkippablePill,Ai as highlightParts,ie as identifiedParamLabel,Fe as inPanelGhost,R as isCalendarFormat,ki as isDimmedDay,mo as isMultiSelectToggleTap,dt as isOptionsGridMobileViewport,_ as isPickerFormat,Ae as isSmartSuggestion,A as isTraditionalAutocompleteSuggestion,W as isoDate,Lr as isoTime,Zn as keepCaretOnChip,Fn as labelTraditionalAutocomplete,_n as locationEndpointFor,an as matchTypedPhrase,lt as measureOptionsGrid,Un as monthLabel,vi as needsOptionsGridMeasurement,Xi as notePanelMorphHeight,pd as optionCountLabel,Vi as optionEnterDelayMs,Ga as optionHasImage,ft as optionImageSources,Le as optionImageSrc,fn as optionLabel,Bi as optionsEntranceDurationMs,xi as optionsGridTemplateColumns,po as optionsShowLeadingVisuals,be as panelMorphGlide,Qi as panelMorphKey,Yi as panelMorphTargetHeight,Dt as parseDate,_e as parseLooseDate,en as parseLooseDateRange,ni as parseTime,Yn as plainTextLength,Ei as planOptionsGrid,ti as previousGraphemeBoundary,kr as productFromMatchedItem,pn as productImageSources,Zc as productImageSrc,oo as productInitial,so as productPhotoFill,Ra as productRowWheelTarget,pi as productsFromCustomFields,$ as queryLive,gt as releasePanelHug,Co as renderEditableContent,Y as resolveFormatType,fi as resolveIdentifiedDate,wi as sameOptionRows,ae as sanitizeOptionIconSvg,zn as scrollCaretIntoView,nt as selectedIsoFromText,De as selectedRangeFor,V as setCursorOffset,un as settlePanelMorph,Ha as shopifyImageSrc,Lo as startingHintOptions,_c as syncPanelHug,Kt as timeWheelIndex,ui as timeWheelIndexFromScroll,di as timeWheelRows,ze as toWireIdentifiedParams,Gr as typedFragment,k as uiStringsFor,Oi as visibleDateRange,To as watchEditorHeight,je as withSkippedParams,zt as withTimeWheelIndex,Nn as withoutTraditionalAutocomplete};
3905
+ `;var Ln=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 Cn=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 An=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 au(t){let e;try{e=new URL(t??X).host}catch{return null}let n=xt.get(e);return n?`https://${n}`:null}var Es=new WeakMap;function ws(t,e){if(!t.head)return;let n=au(e);if(!n)return;let i=Es.get(t);i||(i=new Map,Es.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 bt=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 ko(t){return t.isDropdownOpen&&!t.isLoading}var su=50,lu=new Set(["search_started","submit","product_click","impression"]),cu="newParam",Ps="suggestionRemoval",Ls="selectionAnimation",Ro="skeletonExit",Cs="locationSearch",du=650,uu=0;function mu(){return`:ac-${++uu}:`}var As=170,Is=160;function Os(){return{text:"",composing:null,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,skeletonPicked:null,skeletonRequested:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null,multiSelectDraft:null,locationSearch:null,locationFieldFocused:!1,editingIdentified:null}}var _o=class{constructor(e,n={}){this.inputStore=Oo(Os());this._listboxId=mu();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new An;this.boundary=new Ln;this.subscriberCount=0;this.emitter=new Cn(this.boundary);this.sessionId=crypto.randomUUID();this.lastRequestId=null;this.searchStartedSessionId=null;this.funnelTelemetry=null;this.pendingSearchStarted=!1;this.openWordText=null;this.locationMirrorText=null;this.locationMirrored=null;this.heldIdentified=null;this.waitingIdentified=null;this.lastImpressionKey="";this.visibleImpression=!1;this.destroyed=!1;this.locationAbort=null;this.locationSession=null;this.spacePickCaret=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=bs(this.inputStore,i=>Ur(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 kt(this.store,e),this.pillsController=new Xt(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new ln({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new Jt(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new Yt(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 Mt(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,getPrependPlaceholder:()=>this.opts.prependPlaceholder,getAllOption:()=>this.opts.allOption===!0,onRequest:({query:i,signal:o,isCurrent:r})=>{ws(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:fe(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}},waitIdentified:(i,o)=>{this.waitingIdentified=i.length>0&&this.store.get().text===o?{text:o,candidates:i}:null}}),this.keyboardController=new Qt(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.unsubscribers.push(this.store.subscribe((i,o)=>{i.text===o.text&&i.completedParams===o.completedParams||i.suggestions.some(r=>r.leadsWithAll)&&ut(i.text,i.completedParams.length,i.leadInText)&&this.store.set({suggestions:i.suggestions.map(r=>r.leadsWithAll?{...r,leadsWithAll:!1}:r)})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.skippedParams.length!==0&&ut(i.text,i.completedParams.length,i.leadInText)&&(ut(o.text,o.completedParams.length,o.leadInText)||this.store.set({skippedParams:[]}))})),this.subscribeSkeletonMirror(),this.subscribeLocationMirror(),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}=tt(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===B(i)||this.store.set({pendingRangeStart:null})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.multiSelectDraft;o&&o.key!==B(i)&&this.store.set({multiSelectDraft:null});let r=i.timeDraft;!r||r.key===B(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=ar(o.text,i.text,a);if(l===null){this.store.set({pendingSpan:null});return}a=l}i.text.slice(a).trim().length===0||or(i.segments,a)?this.store.set({pendingSpan:null}):a!==r.anchor&&this.store.set({pendingSpan:{anchor:a,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(xs(this.opts.styleRoot??pe(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.locationMirrored=null,this.store.set({...Os(),isFocused:e,dropdownHeld:n,skipNextFetch:!0}),this.sessionId=crypto.randomUUID(),this.lastRequestId=null,this.lastImpressionKey="",this.pendingSearchStarted=!1,this.waitingIdentified=null,this.heldIdentified=null,this.openWordText=null,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&&(ea(this.domRefs.input),Lo(this.domRefs.input),bo(this.domRefs.dropdown)),this.dropdownRefs&&bo(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{start:i,end:o}=n;if(e===o)return this.removeWholeChip(n),this.scheduleSetCursor(i),!0;let{text:r}=this.store.get(),a=ti(r,e),s=r.slice(0,a)+r.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}removeWholeChip(e){let{text:n,removed:i}=sn(this.store.get().text,e.start,e.end);this.store.set(o=>({text:n,filterBase:Math.min(o.filterBase>e.start?Math.max(e.start,o.filterBase-i):o.filterBase,n.length),...this.withoutChip(o,e),pillTapped:!1,activeDropdownIndex:-1}))}removeParam(e){let n=this.store.get(),i=n.completedParams.find(l=>l.id===e),o=i?"completed":n.identifiedParams.some(l=>l.id===e)?"identified":null;if(!o)return!1;let r=()=>{let l=0;for(let c of this.store.get().segments)if(l+=c.value.length,c.type===o&&(c.param.id===e||c.type==="completed"&&i?.group&&c.param.group===i.group))return l;return null};if(r()===null)return!1;this.store.get().editingParam&&this.exitEditMode(),this.store.get().editingIdentified&&this.exitEditingIdentified();let a=r(),s=a===null?null:this.findChipSpanAt(a);return!s||s.kind!==o?!1:(this.removeWholeChip(s),this.store.get().isFocused&&this.scheduleSetCursor(s.start),!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(),V(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(c=>c.id===e);if(!i)return!1;let o=Y(i);if(!R(o))return!1;let r=o==="date-range"?at(i)??en(i.text):null,a=0,s=-1;for(let c of n.segments){if(c.type!=="text"&&c.param.id===e){s=a;break}a+=c.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:fi(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){let n=this.spacePickCaret;if(n!=null){this.spacePickCaret=null,this.reEdit.caretAfterInput(n),this.scheduleSetCursor(n);return}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)}handleCompositionText(e){let n=this.store.get();if(!(n.editingParam||n.editingIdentified)){if(e===n.text){n.composing&&this.store.set({composing:null});return}this.store.set({composing:{text:e,over:n.text}}),this.fetchController.previewComposition(e)}}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(!R(n.activeFormatType)||!n.dateView)return;let i=Gn(n.dateView,e);this.store.set({dateViewMonth:{...i,key:B(n)},activeDropdownIndex:-1})}setTime(e){let n=this.store.get();n.activeFormatType!=="time"||!n.timeView||this.store.set({timeDraft:{minutes:ke(e),key:B(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(Ar(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:B(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(", ")} ${k(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(li(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=B(n);this.cancelLocationSearch();let a=n.locationAutocomplete&&this.opts.locationSearch!==!1?_n(this.opts.apiConfig):null,s="loading";a?e.trim().length<Pt&&(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(Cs,()=>{this.runLocationSearch(o,e,a)},Wo)}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(Rn(r??a)),this.store.get().completedParams!==n.completedParams&&this.store.set({locationSearch:null}))}spacePicksTopPlace(e,n){if(n!==`${e.text} `)return!1;let i=e.locationView;if(e.activeFormatType!=="location"||!i||!e.isDropdownOpen||e.locationFieldFocused)return!1;let o=i.places[0],r=this.typedLocationQuery(e);return i.status==="done"&&!!o&&r===i.query&&kn(o,r)}typedLocationQuery(e){let n=this.typedLocationPhrase(e);return this.isReEditing(e)?n.trim():Vo(n)}isReEditing(e){return e.editingParam!=null&&e.editingAnchor!=null}typedLocationPhrase(e){if(this.isReEditing(e))return Li(e,e.optionQuery);let n=e.actionableSuggestions[0]?.parameter,i=0,o=0;for(let r of this.segmentsWithPending(e))i+=r.value.length,(r.type==="completed"||r.type==="identified"&&r.param.parameter!==n)&&(o=i);return e.text.slice(o)}segmentsWithPending(e){let n=[this.heldIdentified,this.waitingIdentified].flatMap(o=>o&&e.text.startsWith(o.text)&&e.text.slice(o.text.length).trim()===""?o.candidates:[]);if(n.length===0)return e.segments;let i=new Set(e.identifiedParams.map(o=>o.id));return Ot(e.text,e.completedParams,[...e.identifiedParams,...n.filter(o=>!i.has(o.id))])}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 Qo(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 Qe&&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(Cs),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||A(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 Ee(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.optionsStyle!==void 0&&(this.container.dataset.aiaOptionsStyle=e.optionsStyle),e.pillPlacement!==void 0&&(this.container.dataset.pillPlacement=e.pillPlacement,this.store.set({})),(e.dropdownTrigger!==void 0||e.closeDropdownOnBlur!==void 0||e.prependPlaceholder!==void 0||e.showNonTappableOptions!==void 0||e.allOption!==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.seeAllResults!==void 0||e.showChipIcons!==void 0||e.showChipImages!==void 0||e.showChipRemove!==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(e.selectsAll){this.skipActivePill();return}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.dateFloor){let a=z(e);if(a&&a<o.dateFloor)return}if(o.activeFormatType==="date-range"){let a=z(e);if(a){let s=o.dateRangeStart;if(!s){this.store.set({pendingRangeStart:{iso:a,key:B(o)}});return}this.store.set({pendingRangeStart:null}),this.selectOption(Fr(s,a));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(Ro),this.reEdit.selectOption(e);return}let r=Qr({...o,placeholderText:o.leadInText},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,c=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),d=n.map(u=>{let g=l.toLowerCase().indexOf(u.text.toLowerCase(),c);return c=g+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(g,c)}});r.patch.completedParams=[...o.completedParams,...d],r.patch.newParamId=d[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:N(o.text,o.completedParams).rawQuery,selected_option:a.text,other_options:_(o.activeFormatType)?[]:o.filteredOptions.filter(s=>s.text!==a.text&&!s.selectsAll).map(s=>s.text),key:r.telemetry.key,position:_(o.activeFormatType)?null:fe(r.consumedSuggestion.options??[],a.text),chip_origin:"tap"});if(this.timers.clear(Ro),n?(this.timers.clear(Ls),this.store.set({...r.patch,...mt(o,n.map(a=>a.text)),inSelectionAnimation:!1})):(this.store.set({...r.patch,...mt(o)}),this.startSelectionAnimationTimer()),this.timers.clear(Ps),r.remainingActionable>0){let a=r.consumedSuggestion;this.timers.schedule(Ps,()=>{this.store.get().suggestions.includes(a)&&this.store.set(s=>({suggestions:s.suggestions.filter(l=>l!==a)}))},As)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(Ls,()=>this.store.set({inSelectionAnimation:!1}),As)}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=""),ko(e)&&!ko(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!ko(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!A(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,su).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&&lu.has(e))return;if(!i&&e==="option"){let{key:r,position:a,chip_origin:s,...l}=n;n=l}let o=this.resolveSource();jr({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:de(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.container.dataset.aiaOptionsStyle=this.opts.optionsStyle??"floating",this.modeController=new bt(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()?o=>e.addProductToCart(o):void 0},get showChipIcons(){return e.opts.showChipIcons??!0},get showChipImages(){return e.opts.showChipImages??!0},get showChipRemove(){return e.opts.showChipRemove??!1},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,get seeAllResults(){return e.opts.seeAllResults===!0},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),handleCompositionText:o=>this.handleCompositionText(o),startEditingParam:o=>this.startEditingParam(o),removeParam:o=>this.removeParam(o),handleCaretAfterInput:o=>this.handleCaretAfterInput(o),handleCaretMove:o=>this.handleCaretMove(o),replaceEditingRange:o=>this.replaceEditingRange(o)};this.domRefs=hs(this.container,n);let i=()=>{this.domRefs&&Io(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),Io(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()?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=ns(this.container,n);let i=()=>{this.dropdownRefs&&So(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),So(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(tn),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()}))}))}subscribeLocationMirror(){this.unsubscribers.push(this.store.subscribe(e=>{if(e.activeFormatType!=="location"){this.locationMirrorText=null;return}!e.isDropdownOpen||e.text===this.locationMirrorText||(this.locationMirrorText=e.text,this.mirrorTypedIntoLocationSearch())}))}subscribeSkeletonMirror(){let e=Date.now();this.unsubscribers.push(this.store.subscribe((n,i)=>{let o=s=>s.dropdownLoading&&s.skeletonOptions!==null;if(!o(i)&&o(n)&&(e=Date.now()),!n.skeletonOptions)return;if(!i.isLoading&&n.isLoading){n.skeletonRequested||this.store.set({skeletonRequested:!0});return}if(!i.isLoading||n.isLoading)return;let r={skeletonOptions:null,skeletonSuggestion:null,skeletonPicked:null,skeletonRequested:!1};if(!n.skeletonExiting){this.store.set(r);return}let a=Is-(Date.now()-e);this.timers.schedule(Ro,()=>this.store.set(r),Math.min(Is,Math.max(0,a)))}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(cu,()=>this.store.set({newParamId:null}),du)}))}handleChange(e,n){this.store.get().composing&&this.store.set({composing:null}),this.fetchController.endPreview();let i=this.store.get();if(n&&this.spacePicksTopPlace(i,e)){this.commitLocation(0);let l=this.store.get();l.completedParams!==i.completedParams&&(this.spacePickCaret=l.caretOffset??l.text.length);return}this.spacePickCaret=null,n&&e&&!i.text&&this.noteSearchStarted(),this.store.set({text:e,pillTapped:!1,activeDropdownIndex:-1});let{valid:o,invalid:r}=lr(e,i.completedParams);r.length>0&&this.store.set({completedParams:o});let a=this.heldIdentified;this.heldIdentified=null,this.waitingIdentified?.text!==e&&(this.waitingIdentified=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)}mirrorTypedIntoLocationSearch(){let e=this.store.get(),n=e.locationView;if(e.activeFormatType!=="location"||!n||!e.isDropdownOpen||e.locationFieldFocused)return;let i=B(e),o=this.typedLocationQuery(e);if(o.length<Pt){let r=this.locationMirrored;(this.typedLocationPhrase(e).trim()===""||o===""&&(r?.text.length??0)>e.text.length)&&r?.key===i&&r.query===n.query&&(this.locationMirrored=null,this.setLocationQuery(""));return}o!==n.query&&(this.setLocationQuery(o),this.locationMirrored={key:i,query:o,text:e.text})}isWordOpen(){return this.opts.commitOnWordEnd===!0&&this.openWordText===this.store.get().text}admitIdentified(e){let n=this.store.get(),{valid:i}=tt(n.text,n.completedParams,e);i.length!==0&&(this.store.set({identifiedParams:[...n.identifiedParams,...i]}),this.mirrorTypedIntoLocationSearch())}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.waitingIdentified;e&&r?.text===o.text&&(this.waitingIdentified=null,this.admitIdentified(r.candidates));let a=this.store.get();return a.completedParams!==o.completedParams||a.identifiedParams!==o.identifiedParams}maybeOpenPendingSpan(){let e=this.store.get();if(e.pendingSpan||e.actionableSuggestions.length===0)return;let n=ue(e.text,Math.min(e.filterBase,e.text.length),e.leadInText),i=ir(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);me(e.editingParam.options,i).some(r=>r.is_tappable)||(this.reEdit.exit(),this.fetchNow())}fetchNow(){let e=this.store.get(),{rawQuery:n,completedParams:i}=N(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,c=o+l+r,d=c.length,u={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:a,value:e.value,kind:e.kind,suggestionParameter:i.parameter,suggestionPlaceholder:ie(i.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:i.parameter,position:null,chip_origin:"tap"}),this.store.set({text:c,completedParams:[...n.completedParams,u],identifiedParams:n.identifiedParams.filter(g=>g.id!==i.id),newParamId:u.id,filterBase:d,caretOffset:d,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(d),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(_(o.activeFormatType)||this.isWordOpen())return;let r=rn({mode:n,finishWord:i,text:e,completedParams:o.completedParams,suggestions:o.suggestions,filterBase:o.filterBase,filterInProgress:o.filterInProgress,phraseExactMatch:this.fetchController.isPhraseExactMatch(),prependPlaceholder:this.opts.prependPlaceholder});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:N(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:fe(s,r.option.text),chip_origin:"typed"})}this.store.set(r.patch)}}};export{_o as AIAutocomplete,ta as ATTRIBUTION_URL,yi as DATE_RANGE_META_END,Si as DATE_RANGE_META_START,Ga as DEFAULT_OPTION_COUNT_UNIT,qd as EDITOR_GROW_MS,Po as HINT_ATTR,ss as HINT_EL_ATTR,as as HINT_HOLD_MS,Mn as LOCATION_META_KEY,Pt as LOCATION_MIN_QUERY,Fi as MULTI_DONE_FIT_VAR,dd as MULTI_SELECT_TOGGLE_MIN_PX,cd as MULTI_SELECT_TOGGLE_SLOP_PX,bt as ModeController,tn as OPTIONS_GRID_MOBILE_QUERY,Vi as OPTION_ENTER_DELAY_VAR,nc as OPTION_ENTER_FADE_MS,ic as OPTION_ENTER_RISE_MS,oc as OPTION_ENTER_RISE_PX,tc as OPTION_ENTER_STAGGER_MS,ao as OPTION_IMAGE_WIDTH,ha as PANEL_ENTER_DELAY_MS,fa as PANEL_ENTER_MS,oe as PANEL_GHOST_CLASS,pa as PANEL_GLIDE_MS,ga as PANEL_LEAVE_MS,jl as PLACEHOLDER_FADE_OUT_MS,He as PLACEHOLDER_LEAVING_ATTR,Ql as PLACEHOLDER_SWAP_GAP_MS,Kl as PLACEHOLDER_TYPE_MS,zl as PLACEHOLDER_WORD_PAUSE_MS,td as PRODUCT_IMAGE_WIDTH,kr as PRODUCT_PATH_PREFIX,ed as PRODUCT_ROW_PX_PER_LINE,Hr as RANGE_SEPARATOR,zo as SCHEMA_VERSION,dn as SCROLL_ARROW_ATTR,da as SCROLL_ARROW_BOTTOM_VAR,sa as SCROLL_ARROW_CLASS,la as SCROLL_ARROW_FADE_MS,rc as SCROLL_ARROW_LABEL,ca as SCROLL_ARROW_SCROLL_IDLE_MS,We as SCROLL_ARROW_VISIBLE_ATTR,Go as SKIPPED_PARAM_TEXT,Wn as SMART_SUGGESTION_SPARKLE_SVG,Lr as TIME_META_KEY,ii as TIME_STEP_MINUTES,qt as TIME_WHEEL_COLUMNS,Gt as TIME_WHEEL_ROW_HEIGHT,Ue as VIEWPORT_FIT_ATTR,Sn as VIEWPORT_FIT_HEIGHT_VAR,Rt as WEEKDAY_LABELS,Gn as addMonths,To as attachChipRemove,oo as attachProductRowWheel,qi as attachScrollArrow,ho as attachViewportFit,Di as buildAttributionUrl,qn as buildDateOptions,Rn as buildLocationOption,N as buildQuery,Ee as buildSubmitResult,li as buildTimeOption,Lo as cancelStartingHint,Kn as cellDay,z as cellIso,Jn as chipIdFromTap,Wr as computeOptionsGridLayout,Ni as containScroll,Oo as createStore,ei as cursorIsAtEnd,ki as dateCellMarks,_i as dateFloorFor,pt as dateSelectionFor,Zi as destroyPanelMorph,et as editingSuggestion,Bt as extractPlainText,ec as findMultiSelectDone,Wi as fitMultiSelectDone,Oe as formatAbsoluteDate,hr as formatDate,Nr as formatDateRange,ht as formatOptionCount,Bo as formatPlace,$t as formatTime,j as getCursorOffset,Hi as getFooterHint,Vn as hasSkippablePill,Ii as highlightParts,ie as identifiedParamLabel,Fe as inPanelGhost,R as isCalendarFormat,Ri as isDimmedDay,po as isMultiSelectToggleTap,dt as isOptionsGridMobileViewport,_ as isPickerFormat,Ae as isSmartSuggestion,A as isTraditionalAutocompleteSuggestion,W as isoDate,Cr as isoTime,Zn as keepCaretOnChip,Fn as labelTraditionalAutocomplete,_n as locationEndpointFor,an as matchTypedPhrase,lt as measureOptionsGrid,Un as monthLabel,vi as needsOptionsGridMeasurement,Ji as notePanelMorphHeight,bd as optionCountLabel,Bi as optionEnterDelayMs,qa as optionHasImage,ft as optionImageSources,Le as optionImageSrc,fn as optionLabel,Ui as optionsEntranceDurationMs,xi as optionsGridTemplateColumns,go as optionsShowLeadingVisuals,be as panelMorphGlide,Yi as panelMorphKey,Xi as panelMorphTargetHeight,Dt as parseDate,_e as parseLooseDate,en as parseLooseDateRange,ni as parseTime,Yn as plainTextLength,Ei as planOptionsGrid,ti as previousGraphemeBoundary,Rr as productFromMatchedItem,pn as productImageSources,id as productImageSrc,ro as productInitial,lo as productPhotoFill,_a as productRowWheelTarget,pi as productsFromCustomFields,$ as queryLive,gt as releasePanelHug,Ao as renderEditableContent,Y as resolveFormatType,fi as resolveIdentifiedDate,wi as sameOptionRows,ae as sanitizeOptionIconSvg,zn as scrollCaretIntoView,nt as selectedIsoFromText,De as selectedRangeFor,V as setCursorOffset,un as settlePanelMorph,Na as shopifyImageSrc,Co as startingHintOptions,Fc as syncPanelHug,Kt as timeWheelIndex,ui as timeWheelIndexFromScroll,di as timeWheelRows,ze as toWireIdentifiedParams,qr as typedFragment,k as uiStringsFor,Mi as visibleDateRange,xo as watchEditorHeight,je as withSkippedParams,zt as withTimeWheelIndex,Nn as withoutTraditionalAutocomplete};
3906
3906
  //# sourceMappingURL=index.mjs.map