@magicx-eng/ai-autocomplete-vanilla 0.72.1 → 0.72.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- function k(t){return t==="date"||t==="date-range"}function D(t){return t!=="options"}function te(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 st=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 bs="https://api.ai-autocomplete.com",j=`${bs}/api/suggest`,lt=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),vo=new WeakMap;function Ve(t){return t?.type==="accessToken"}function Ss(t){if(!(!t||Ve(t)))return t}function ct(t){let e=vo.get(t.getAccessToken);return e||(e=new st(t),vo.set(t.getAccessToken,e)),e}function dt(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function ut(t){let e=Ss(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var vn="aiaPlace",mt=2,wo=250,Eo=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(" ")),Po=new Set("city beach springs falls island park heights valley bay".split(" ")),ys=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 Lo(t){let e=xs(t);for(;e.length>0&&ys.has(e[0].toLowerCase().replace(/[.,]+$/,""));)e.shift();return e.join(" ")}function xs(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&&Eo.has(r(o))&&Po.has(r(n))?[o,i,n]:i&&(Eo.has(r(i))||Po.has(r(n)))?[i,n]:[n]}function Co(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function Tn(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function En(t,e){let n=Tn(e);if(!n)return!1;if(Tn(t.name)===n)return!0;for(let[,i]of t.name.matchAll(/\(([^()]*)\)/g))if(Tn(i)===n)return!0;return!1}function Ao(t,e){let n=e.metadata?.[vn];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(En(i,s))return t.length-a}return 0}function Pn(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:Co(t),is_tappable:!0,kind:null,metadata:{[vn]:{id:t.id,name:t.name}}}}function wn(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??j,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 Io(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 Ue(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var Oo="skipped";function $e(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:Oo,kind:null}));return i.length>0?[...t,...i]:t}var Ts="0.72.1",Ro="1.0",Mo=!1;function vs(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function se(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function Es(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function Ps(t,e,n,i,o,r,a,s,l,d,c,u,f){let m=e.find(h=>h.parameter==="contact"&&h.metadata?.contact_account_count)?.metadata?.contact_account_count,p=typeof m=="number"?m:void 0,g=Es();return{data:{raw_query:t,accepts_traditional_autocomplete:!0,client_option_parameters:f??[],completed_params:$e(e.map(h=>vs(h,n)),l??[]),...a&&a.length>0&&{identified_params:Ue(a)},...s&&s.length>0&&{recently_suggested:s},...p!=null&&{contact_account_count:p},...d!==void 0&&{additional_context:d}},meta:{request_id:o,request_at:new Date().toISOString(),language:se(c),...g&&{timezone:g},...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:Ts,session_id:i,source:r,schema_version:Ro}}}async function ko(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function _o(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=Ps(t,e,o,n.sessionId,n.requestId??crypto.randomUUID(),n.source,n.identifiedParams,n.recentlySuggested,n.skippedParams,n.additionalContext,n.language,n.currency,n.clientOptionParameters),a=i?.endpoint??j,s=await Do(a,JSON.stringify(r),i,n.signal);if(!s.ok)throw new Error(`API error: ${s.status} ${s.statusText}`);return s.json()}async function Do(t,e,n,i){let o=dt(n);if(Ve(n)){let a=ct(n),s=await a.getToken(),l=await ko(t,o,s,e,i);if(l.status===401){let d=await a.getToken(!0);l=await ko(t,o,d,e,i)}return l}let r=ut(n);return!r&&!Mo&&(Mo=!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 Ge=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function Ho(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:se(n.language)}),o=await Do(t,i,n.apiConfig,n.signal);if(!o.ok)throw new Ge(o.status);return Io(await o.json())}var pt=/[\p{L}\p{N}]/u,ws=/['\u2019-]/;function No(t,e,n){let i=t[e];if(i===void 0)return!1;if(pt.test(i))return!0;let o=t[e+n];return ws.test(i)&&o!==void 0&&pt.test(o)}function Ls(t,e,n){let i=e+n.length;return!(pt.test(n[0])&&No(t,e-1,-1)||pt.test(n[n.length-1])&&No(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(Ls(t,r,e))return r;o===-1&&(o=r)}r=t.indexOf(e,r+1)}return o}function H(t,e){let n=t,i={},o=[],r=[],a=0;for(let s of e){let l=(i[s.parameter]??0)+1;i[s.parameter]=l;let c=`{{${s.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,u=m=>ne(n,s.text,m,p=>!r.some(g=>p<g.end&&p+s.text.length>g.start)),f=u(a);if(f===-1&&(f=u(0)),f!==-1){n=n.slice(0,f)+c+n.slice(f+s.text.length);let m=c.length-s.text.length;for(let p of r)p.start>=f+s.text.length&&(p.start+=m,p.end+=m);r.push({start:f,end:f+c.length}),a=f>=a?f+c.length:a+m}o.push({...s,placeholder:c})}return{rawQuery:n,completedParams:o}}function le(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function Pe(t,e){return e===!1?"":t}function gt(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function qe(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 Fo(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 Wo(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function Cs(t,e){let n=Wo(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function he(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?Wo(i).trimStart():"";if(o)return t.filter(a=>!a.is_tappable||Cs(a.text,o));let r=i.toLowerCase();return t.filter(a=>!a.is_tappable||a.text.toLowerCase().includes(r))}function ft(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 Ke(t,e,n,i,o){let r=qe(e,n,i),a=ft(t,r);if(a||!o||!r.trim())return a;if(r===e.slice(n))return null;let s=e.lastIndexOf(" ",n-1)+1;return ft(t,e.slice(s))}function Bo(t,e){let n=e.replace(/^\s+/,"").toLowerCase();for(let i=0;i<n.length;){let o=n.slice(i);if(o.trim().length>=2){let a=t.findIndex(s=>s.is_tappable&&s.text.toLowerCase().startsWith(o));if(a>=0)return t.map((s,l)=>l===a?{...s,liveMatch:!0}:s)}let r=n.indexOf(" ",i);if(r<0)break;i=r+1}return t}function Uo(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function $o(t,e){let{icon:n,icon_svg:i}=e;return!i||t.every(Vo)?t:t.map(o=>Vo(o)?o:{...o,icon:n,icon_svg:i})}function Vo(t){return!!(t.icon_svg||t.image_url)}function As(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=As(t);return e.length>0?e.join(" "):t}function Y(t,e){return t.parameter||e}function ze(t){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:ie(t)}}function ht(t,e){let n=Y(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?ze(n):{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 Go(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function bt(t){return A(t)||t?.smart_suggestion===!0}function Ln(t){return t.some(A)?t.filter(e=>!A(e)):t}function Cn(t,e){return t.some(n=>A(n)&&!n.text)?t.map(n=>A(n)&&!n.text?{...n,text:e}:n):t}var An='<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 In(t){return t.some(e=>!A(e))}function qo(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 Ko(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 zo(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 jo(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 St(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 be(t,e){let{located:n}=St(t,e);return n.length>0?n[n.length-1].end:0}function Yo(t,e,n){let i=[],o=[],r=0;for(let a of n){let s=ne(t,a.text,r,l=>!e.some(d=>l<d.end&&l+a.text.length>d.start));if(s===-1){o.push(a);continue}i.push({start:s,end:s+a.text.length,param:a}),r=s+a.text.length}return{located:i,missing:o}}function yt(t,e,n=[]){let i=St(t,e).located,o=[];for(let c of i){let u=o[o.length-1];c.param.group&&u?.param.group===c.param.group?(u.end=c.end,u.params?.push(c.param)):o.push({...c,...c.param.group?{params:[c.param]}:{}})}let r=Yo(t,o,n).located,a=[...o.map(c=>({start:c.start,end:c.end,segment:{type:"completed",value:t.slice(c.start,c.end),param:c.param,...c.params?{params:c.params}:{}}})),...r.map(c=>({start:c.start,end:c.end,segment:{type:"identified",value:c.param.text,param:c.param}}))].sort((c,u)=>c.start-u.start),s=[],l=0;for(let c of a)c.start>l&&s.push({type:"text",value:t.slice(l,c.start)}),s.push(c.segment),l=c.end;let d=t.slice(l);return d&&s.push({type:"text",value:d}),s}function Qo(t,e){let{located:n,missing:i}=St(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 je(t,e,n){let i=St(t,e).located,{located:o,missing:r}=Yo(t,i,n);return{valid:o.map(a=>a.param),invalid:r}}function Xo(t,e,n){let i=e?.endpoint??j,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${Is(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,a)=>{let s=lt.get(a);return s?`https://${s}`:r})}function Is(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 Jo(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 Os(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var Ms=100,ks=300,Rs=2,xt=class{constructor(e,n,i,o,r,a,s,l,d,c={}){this.store=e;this.getApiConfig=n;this.getOptionOverrides=i;this.getMaskCompletedText=o;this.getOnError=r;this.getSessionId=a;this.getSource=s;this.getAdditionalContext=l;this.getLanguage=d;this.callbacks=c;this.fetchVersion=0;this.abortController=null;this.debounceTimer=null;this.slowDebounceTimer=null;this.unsubscribe=null;this.phraseExactMatch=!1}start(){this.doFetch("",[]);let e=this.store.get().text,n=this.store.get().completedParams;this.unsubscribe=this.store.subscribe(i=>{(i.text!==e||i.completedParams!==n)&&(e=i.text,n=i.completedParams,this.scheduleFetch())})}isPhraseExactMatch(){return this.phraseExactMatch}dispose(){this.abortController?.abort(),this.clearTimers(),this.unsubscribe?.()}async doFetch(e,n){this.abortController?.abort();let i=new AbortController;this.abortController=i;let o=++this.fetchVersion,r=this.store.get().text.length,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=s.pendingSpan?zo(s.pendingSpan.snapshot,s.actionableSuggestions):void 0,d=crypto.randomUUID(),c=e===""&&n.length===0&&s.skippedParams.length===0&&s.identifiedParams.length===0?this.startingStateUrl():void 0,u=c?await Jo(fetch(c,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let f=u??await _o(e,n,{sessionId:this.getSessionId(),requestId:d,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:i.signal,apiConfig:this.getApiConfig(),identifiedParams:s.identifiedParams,recentlySuggested:l,skippedParams:s.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})});if(o!==this.fetchVersion)return;this.phraseExactMatch=f.meta?.phrase_exact_match===!0;let m=(f.data.suggestions??[]).find(A),p=m?[]:f.data.input??[],g=w=>({id:crypto.randomUUID(),parameter:w.parameter,text:w.text,...w.type?{type:w.type}:{},...w.iso_date?{isoDate:w.iso_date}:{},...w.iso_date_end?{isoDateEnd:w.iso_date_end}:{}}),h=p.filter(w=>w.source==="identified");this.callbacks.waitIdentified?.(h.filter(w=>w.state==="need_confirmation").map(g),a);let E=h.filter(w=>w.state!=="need_confirmation").map(g),S=this.callbacks.isWordOpen?.()??!1,y=this.store.get().text.toLowerCase(),b=w=>S&&y.endsWith(w.text.toLowerCase()),x=E.filter(w=>!b(w));S&&this.callbacks.holdIdentified?.(E.filter(b));let v=m?[m]:Uo(f.data.suggestions??[],this.getOptionOverrides()),P=p,T=P[P.length-1],C=this.store.get().text,L,O;if(T?.state==="in_progress"){O=!0;let w=C.toLowerCase().lastIndexOf(T.text.toLowerCase());L=w!==-1?w:r}else O=!1,L=r;let I=v.filter(w=>w.parameter!=="placeholder")[0],U=null;if(I&&!A(I)&&!S&&I.type?.kind!=="multi_select"&&!D(te(I))){let w=Ke(I.options,C,L,O,this.phraseExactMatch);w&&(U={id:crypto.randomUUID(),placeholder:"",parameter:Y(w,I.parameter),text:w.text,value:w.value,kind:w.kind,suggestionParameter:I.parameter,suggestionValueType:I.type,suggestionPlaceholder:I.text,suggestionIcon:I.icon,suggestionIconSvg:I.icon_svg,options:I.options??[],metadata:w.metadata,icon:w.icon,icon_svg:w.icon_svg,image_url:w.image_url},v=v.filter(Z=>Z!==I),this.callbacks.onAutoMatch?.({active:I,matched:w,rawQuery:e}))}let fe=f.data.custom_fields??null,J=this.callbacks.productsForResponse?.(fe);this.store.set(w=>{let Z=U?[...w.completedParams,U]:w.completedParams,at=je(w.text,Z,x).valid,ge=new Set(s.skippedParams.map(q=>q.id)),Fe=new Set(w.skippedParams.filter(q=>!ge.has(q.id)).map(q=>q.parameter));return{suggestions:Fe.size>0?v.filter(q=>q.parameter==="placeholder"||!Fe.has(q.parameter)):v,isLoading:!1,isReady:f.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:L,filterInProgress:O,identifiedParams:at,customFields:fe,traditionalAutocomplete:f.meta?.traditional_autocomplete===!0,...J!==void 0?{products:J}:{},...U?{completedParams:Z}:{}}}),this.callbacks.onResponse?.({requestId:d,funnelTelemetry:f.meta?.funnel_telemetry===!0,visibleImpression:f.meta?.visible_impression===!0})}catch(s){let l=Os(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?Xo(e,this.getApiConfig(),se(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(Rs)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},Ms),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),ks)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;let a=Pe(o.suggestions.filter(v=>v.parameter==="placeholder").map(v=>v.text).join(" "),this.callbacks.getPrependPlaceholder?.()),s=le(o.text,o.filterBase,a),l=qe(o.text,s,o.filterInProgress),d=o.suggestions.filter(v=>v.parameter!=="placeholder"),c=A(d[0])?void 0:d[0],u=D(o.activeFormatType),f=c&&!u?he(c.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&f.length>0)return!1;let m=f.filter(v=>v.is_tappable),p=c&&!u&&!this.callbacks.isWordOpen?.()?Ke(c.options,o.text,s,o.filterInProgress,this.phraseExactMatch)!==null:!1,g=l.trim().length>0,h=i&&o.products.length>0;if(m.length>0&&!p&&g&&!h||gt(o.text,o.completedParams.length,a))return!1;let{rawQuery:E,completedParams:S}=H(o.text,o.completedParams),y=E.length<o.lastRawQuery.length,b=Math.abs(E.length-o.lastRawQuery.length),x=n&&E!==o.lastRawQuery;return y||b>=e||x?(this.doFetch(E,S),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var _s="(hover: none) and (pointer: coarse)";var Ds="[data-aia-dropdown], [data-aia-input-wrapper]",Hs=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),Tt=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(Hs)),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(_s):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(Ds))return!0;return!1}};var we=["January","February","March","April","May","June","July","August","September","October","November","December"],vt=["S","M","T","W","T","F","S"],tr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Et="aiaDate",nr="aiaDay",Zo=t=>String(t).padStart(2,"0");function N(t){return`${t.getFullYear()}-${Zo(t.getMonth()+1)}-${Zo(t.getDate())}`}function On(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Ns(t){let e=On(t).getTime()-On(new Date).getTime();return Math.round(e/864e5)}function ir(t){let e=Ns(t);return e>=0&&e<7?tr[t.getDay()]:Le(t)}function Le(t){return t.getFullYear()===new Date().getFullYear()?`${we[t.getMonth()]} ${t.getDate()}`:`${we[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function Pt(t){if(!t)return null;let e=tr.findIndex(s=>s.toLowerCase()===t.trim().toLowerCase());if(e>=0){let s=On(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=we.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 Mn(t){return`${we[t.month]} ${t.year}`}function kn(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function or(t){return{year:t.getFullYear(),month:t.getMonth()}}function Rn(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function er(){return{text:"",is_tappable:!1,kind:null}}function _n(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(er());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:ir(r),is_tappable:!0,kind:null,metadata:{[Et]:N(r),[nr]:o}})}for(;i.length%vt.length!==0;)i.push(er());return i}function Ye(t){let e=Pt(t);return e?N(e):null}function K(t){let e=t?.metadata?.[Et];return typeof e=="string"?e:null}function Dn(t){let e=t?.metadata?.[nr];return typeof e=="number"?e:null}function Fs(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function ce(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&Fs(e)?e:t.ownerDocument??t}function wt(t){return ce(t).activeElement??null}function R(t){return t.ownerDocument??t}function Ws(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function rr(t){let e=ce(t);return!Ws(e)||typeof e.getSelection=="function"?null:e}function ar(t){let e=rr(t);if(!e)return null;let n=R(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function sr(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 Qe(t){let n=ce(t).getSelection?.();return n||(R(t).getSelection?.()??null)}function de(t){let e=Qe(t);if(!e||e.rangeCount===0)return null;let n=ar(t);if(n){let i=sr(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 Se(t){let e=Qe(t);if(!e||e.rangeCount===0)return null;let n=ar(t);if(!n)return e.getRangeAt(0);let i=sr(e,n);if(!i)return null;let o=R(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function Xe(t,e,n){let i=Qe(t);if(!i)return null;if(rr(t))return i.collapse(e,n),i;let o=R(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function Lt(t,e){let n=t?ce(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var Ct=2,Bs="magicx-aia";function lr(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function Vs(t){let e=R(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&&lr(a.overflowX)||r&&lr(a.overflowY))return i}if(i.classList.contains(Bs))return null;i=i.parentElement}return null}function Hn(t){let e=Se(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=Vs(t);if(!n||typeof e.getBoundingClientRect!="function")return;let i=e.getBoundingClientRect();if(i.height===0)return;let o=n.getBoundingClientRect();if(n.scrollWidth>n.clientWidth){let r=o.left+n.clientLeft,a=r+n.clientWidth;i.right>a?n.scrollLeft+=i.right-a+Ct:i.left<r&&(n.scrollLeft-=r-i.left+Ct)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,a=r+n.clientHeight;i.bottom>a?n.scrollTop+=i.bottom-a+Ct:i.top<r&&(n.scrollTop-=r-i.top+Ct)}}var dr='[contenteditable="false"]',Fn="strong[data-param-id]",Ce;function Us(){if(Ce!==void 0)return Ce;let t=globalThis.Intl.Segmenter;if(!t)return Ce=null,null;try{Ce=new t(void 0,{granularity:"grapheme"})}catch{Ce=null}return Ce??null}function At(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(dr))return!0;n=n.parentNode}return!1}function It(t){return R(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return At(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Ot(t){let e=It(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function Wn(t){let e=It(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function z(t){let e=de(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(At(o,t)&&o!==t)return null;let r=0;for(let a=0;a<i&&a<o.childNodes.length;a++)r+=Bn(o.childNodes[a],t);return r+Nn(o,t)}return n.nodeType!==Node.TEXT_NODE||At(n,t)?null:Nn(n,t)+i}function Bn(t,e){if(t.nodeType===Node.TEXT_NODE)return At(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(dr))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=Bn(o,e);return i}function Nn(t,e){let n=It(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 F(t,e){let n=R(t),i=Math.max(0,Math.min(e,Wn(t))),o=It(t),r=0,a=null,s=0,l=o.nextNode(),d=null;for(;l;){let u=l.data.length;if(i<r+u){a=l,s=i-r;break}if(i===r+u){let f=o.nextNode();f?(a=f,s=0):(a=l,s=u);break}r+=u,d=l,l=o.nextNode()}let c=n.createRange();if(a){let u=a.parentElement?.closest('strong[data-seg="completed"]');u&&u!==t&&t.contains(u)?s===0?c.setStartBefore(u):s===a.data.length?c.setStartAfter(u):c.setStart(a,s):c.setStart(a,s)}else d?c.setStart(d,d.data.length):c.setStart(t,0);c.collapse(!0),Xe(t,c.startContainer,c.startOffset)&&($s(t,c,i),Hn(t))}function cr(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(Fn)??null;return i&&e.contains(i)?i:null}function $s(t,e,n){let i=cr(de(t)?.node??null,t);if(i&&i!==cr(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function ur(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=z(t);return i!==null&&n===`${i}:${e}`}function mr(t){return ce(t).activeElement===t}function Vn(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(Fn);if(!o||!t.contains(o))return null;let r=de(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function Un(t,e){let n=null;for(let a of t.querySelectorAll(Fn))if(a.dataset.paramId===e){n=a;break}if(!n)return;let i=Nn(n,t),o=i+Bn(n,t),r=z(t);r!=null&&r>=i&&r<=o||F(t,i)}function $n(t){let e=z(t);return e==null?!1:e>=Wn(t)}function Gn(t,e){if(e<=0)return 0;let n=Us();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",Kn=5;var zn=[12,1,2,3,4,5,6,7,8,9,10,11],jn=Array.from({length:60/5},(t,e)=>e*5),Yn=["AM","PM"];function Ie(t){return(Math.round(t)%1440+1440)%1440}function Qn(t){let e=Ie(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function Mt(t){let e=t.hour%12+(t.period==="PM"?12:0);return Ie(e*60+t.minute)}function kt(t){let{hour:e,minute:n,period:i}=Qn(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function fr(t){let e=Ie(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function Ae(t){return Ie(Math.round(t/5)*5)}function gr(t,e){return Ie(t+e)}var Gs=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,qs=/^(\d{1,2}):(\d{2})$/;function qn(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=Gs.exec(e);if(n){let o=Number(n[1]),r=n[2]===void 0?0:Number(n[2]);return o<1||o>12||r>59?null:Mt({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=qs.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 hr(t){let e=qn(t.editingText);if(e!=null)return Ae(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>qn(o.text)).filter(o=>o!=null);if(n.length>0)return Ae(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return Ie((i.getHours()+1)*60)}function Xn(t){return{text:kt(t),is_tappable:!0,kind:null,metadata:{[pr]:fr(t)}}}var Rt=30,_t=["hour","minute","period"],Jn={hour:zn.map(t=>({label:String(t)})),minute:jn.map(t=>({label:String(t).padStart(2,"0")})),period:Yn.map(t=>({label:t}))};function Zn(t){return Jn[t]}function Dt(t,e){let n=Qn(Ae(e));return t==="hour"?zn.indexOf(n.hour):t==="minute"?jn.indexOf(n.minute):Yn.indexOf(n.period)}function Ht(t,e,n){let i=Jn[t],o=Math.min(Math.max(n,0),i.length-1),r=Qn(Ae(e));return Mt(t==="hour"?{...r,hour:zn[o]}:t==="minute"?{...r,minute:jn[o]}:{...r,period:Yn[o]})}function ei(t,e){let n=Jn[t].length-1;return Math.min(Math.max(Math.round(e/Rt),0),n)}function ye(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=H(t,e);return{query:t.trim(),raw_query:o,completed_params:$e(r,n),identified_params:Ue(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function Nt(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")?$n(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function ti(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?z(t):null}var Ft=class{constructor(e,n){this.store=e;this.ctx=n}handleKeyDown(e){if(e.isComposing||e.keyCode===229)return;let n=this.store.get(),{listboxId:i,getOnSubmit:o}=this.ctx,r=e.target instanceof Node?e.target:null,a=this.getEffectiveColumns(r),s=o(),l=this.getTappableIndices(a);if((e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)&&(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight"))return;let d=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let c=n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&c?.is_tappable){e.preventDefault(),this.ctx.selectOption(c);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&c?.is_tappable&&this.ctx.selectOption(c),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let c=Nt(e.target,n),u=!!n.editingParam;if(!c&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(d)break;e.preventDefault();let p=k(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(k(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 f=l.indexOf(n.activeDropdownIndex),m=f<l.length-1?f+1:0;this.store.set({activeDropdownIndex:l[m]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!d)break;let f=Nt(e.target,n),m=!!n.editingParam;if(!f&&!m)break;e.preventDefault();let p=k(n.activeFormatType)?this.dateEntryIndex(n,!0):this.firstTappableInBottomRow(a)??l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:p});break}if(l.length===0)return;this.store.set({activeDropdownIndex:p});break}if(l.length===0)break;if(e.preventDefault(),k(n.activeFormatType)){this.stepDateWeek(n,-7);break}if(n.activeDropdownIndex<a){this.store.set({activeDropdownIndex:-1});break}let c=l.indexOf(n.activeDropdownIndex),u=c>0?c-1:l.length-1;this.store.set({activeDropdownIndex:l[u]});break}case"ArrowRight":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%a<a-1){let f=n.activeDropdownIndex+1;f<n.filteredOptions.length&&n.filteredOptions[f]?.is_tappable&&this.store.set({activeDropdownIndex:f})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,f=n.editingTail;this.ctx.exitEditMode?.(),F(u,f);break}Nt(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,-1);break}if(n.activeDropdownIndex%a>0){let c=n.activeDropdownIndex-1;c>=0&&n.filteredOptions[c]?.is_tappable&&this.store.set({activeDropdownIndex:c});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let c=ti(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingAnchor!=null){e.preventDefault();let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingAnchor;this.ctx.exitEditMode?.(),F(c,u);break}if(this.ctx.startEditingParamAtCaret){let c=ti(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let c=ti(e.target);if(c==null)break;this.ctx.removeParamAtCaret(c)&&e.preventDefault();break}case"Enter":{if(e.preventDefault(),n.activeDropdownIndex>=0&&n.filteredOptions[n.activeDropdownIndex]?.is_tappable)this.clickOrSelect(n.activeDropdownIndex,n.filteredOptions,i,r);else if(s){this.ctx.endTypedWord?.(!0);let c=this.store.get();s(ye(c.text,c.completedParams,c.skippedParams,{identifiedParams:c.identifiedParams,isReady:c.isReady,customFields:c.customFields}))&&this.ctx.afterSubmit?.()}break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let c=n.filteredOptions.map((m,p)=>m.is_tappable?p:-1).filter(m=>m!==-1);if(c.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let m=e.shiftKey?c[c.length-1]:c[0];this.store.set({pillTapped:!0,activeDropdownIndex:m});break}e.preventDefault();let u=c.indexOf(n.activeDropdownIndex);if(!e.shiftKey&&!k(n.activeFormatType)&&!n.multiSelectView){let m=c[Math.max(u,0)];this.clickOrSelect(m,n.filteredOptions,i,r);break}let f;if(u<0)f=e.shiftKey?c.length-1:0;else{let m=e.shiftKey?-1:1;f=(u+m+c.length)%c.length}this.store.set({activeDropdownIndex:c[f]});break}case"Escape":{if(n.dateRangeStart){this.store.set({pendingRangeStart:null});break}if(n.editingIdentified){this.ctx.exitEditingIdentified?.(),this.store.set({activeDropdownIndex:-1});break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingTail;this.ctx.exitEditMode?.(),F(c,u)}this.store.set({activeDropdownIndex:-1});break}}}handleTimeWheelKey(e,n){let i=n.timeView;if(n.activeFormatType!=="time"||!i||!n.isDropdownOpen)return!1;switch(e.key){case"ArrowDown":case"ArrowUp":return!Nt(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=>K(s)===e.dateFloor);if(a>=0)return a}let i=N(new Date),o=e.filteredOptions.findIndex(a=>K(a)===i);if(o>=0)return o;let r=e.filteredOptions.map((a,s)=>a.is_tappable?s:-1).filter(a=>a!==-1);return(n?r[r.length-1]:r[0])??0}stepDateDay(e,n){for(let i=e.activeDropdownIndex+n;i>=0&&i<e.filteredOptions.length;i+=n)if(e.filteredOptions[i]?.is_tappable){this.store.set({activeDropdownIndex:i});return}}stepDateWeek(e,n){let i=e.activeDropdownIndex+n;this.store.set({activeDropdownIndex:e.filteredOptions[i]?.is_tappable?i:-1})}getTappableIndices(e){let i=this.store.get().filteredOptions.map((r,a)=>r.is_tappable?a:-1).filter(r=>r!==-1),o=Array.from({length:e},()=>[]);for(let r of i)o[r%e].push(r);return o.flat()}getEffectiveColumns(e){let n=Lt(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=Lt(e,`${this.ctx.listboxId}-option-0`)?.parentElement??null;for(;o;){let r=getComputedStyle(o).gridTemplateColumns;if(r&&r!=="none"){let a=r.split(" ").filter(Boolean).length;if(a>0)return a}if(o===n)break;o=o.parentElement}return this.ctx.columns}clickOrSelect(e,n,i,o){let r=Lt(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var Wt=class{constructor(e,n,i={}){this.store=e;this.getOverrides=n;this.callbacks=i;this.unsubscribe=null;this.current=null;this.version=0;this.lastMiss=null;this.hasLoggedError=!1}start(){this.unsubscribe=this.store.subscribe(e=>this.sync(e)),this.sync(this.store.get())}dispose(){this.unsubscribe?.(),this.unsubscribe=null,this.cancel(),this.current=null}reset(){this.cancel(),this.current=null,this.lastMiss=null}refresh(){this.reset(),this.sync(this.store.get())}hasOverride(e){return!!this.getOverrides()?.[e]}owns(e,n){return this.hasOverride(e)&&!this.missCovers(e,n)}tick(e,n){let i=this.resolveTarget(e);if(!i||this.missCovers(i.parameter,i.query))return"no";let o=this.current;if(o&&o.key===i.key){if(o.query===i.query)return"owns";let r=Math.abs(i.query.length-o.query.length),a=i.query.length<o.query.length;if(n>1&&!a&&r<n)return"owns"}return this.ask(i),"asked"}sync(e){let n=this.resolveTarget(e);if(!n){this.current&&(this.cancel(),this.current=null),e.optionSearch&&this.store.set({optionSearch:null});return}this.current&&this.current.key===n.key||this.ask(n)}resolveTarget(e){if(D(e.activeFormatType)||e.editingIdentified)return null;let n=e.editingParam;if(n&&e.editingAnchor!=null)return this.hasOverride(n.suggestionParameter)?{mode:"edit",key:n.id,parameter:n.suggestionParameter,suggestion:{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options,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||Ks(a))return;this.logOnce(a),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=$o(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(d=>d===e.suggestion?s:d),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 Ks(t){return t instanceof Error&&t.name==="AbortError"}var Bt=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(d=>d.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(A(o))return;let r=i.filter((d,c)=>c!==e),a=n.suggestions.filter(d=>d.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:d}=H(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:d,selectedPill:o.text,otherPills:r.map(c=>c.text)})}let s=[...a,o,...r],l=this.store.peek({suggestions:s}).filteredOptions.findIndex(d=>d.is_tappable);this.store.set({suggestions:s,pillTapped:!0,activeDropdownIndex:l})}removeLastParam(){this.store.get().completedParams.length!==0&&this.store.set(n=>({completedParams:n.completedParams.slice(0,-1),activeDropdownIndex:-1}))}};var yr="/products/",br="https://relative.invalid";function zs(t){if(!t)return;let e;try{e=new URL(t,`${br}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===br?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function xr(t,e){let n=zs(t.item_url)??Ys(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:Sr(t.price,t.currency,e)},...js(t)&&{compareAtPrice:Sr(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function js(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 Sr(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 Ys(t){if(!t.handle)return;let e=`${yr}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function ni(t,e){return(t?.items.matched??[]).map(n=>xr(n,e))}var Vt=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=ni(e,se(this.getLanguage())),i=this.getMapper();if(!i)return n;try{let o=i(n,e?.items.matched??[]);if(Array.isArray(o))return o}catch(o){this.hasLoggedMapperError||(this.hasLoggedMapperError=!0,console.warn("[AIAutocomplete] mapProducts failed. The original cards are shown.",o))}return n}async run(e,n,i){if(!this.isEnabled())return;let o=this.getConfig();if(!o)return;if(e.trim().length===0){this.clear(i);return}let r=()=>n.aborted||!i()||!this.owns(o);try{let a=await o.fetch(e,n);if(r())return;let s=o.transform(a),l=Array.isArray(s)?s:[],d=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(d)}catch(a){if(n.aborted||Qs(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 Qs(t){return t instanceof Error&&t.name==="AbortError"}function Xs(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function Tr(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:we.findIndex(n=>n.toLowerCase().startsWith(e))}function Js(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 Zs=/^(?:(?:on|from) )?(?:the )?(\d{1,2})(?:st|nd|rd|th)$/;function ii(t){let e=Zs.exec(t.trim().toLowerCase().replace(/\s+/g," "));if(!e)return null;let n=Number(e[1]);return n>=1&&n<=31?n:null}function el(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 vr(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function Oe(t,e={}){if(!t)return null;let n=e.today??new Date,i=ii(t);if(i!==null){let d=el(i,n);return d?N(d):null}let o=Xs(t.trim().toLowerCase()).replace(/\s+/g," "),r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o);if(r){let d=vr(Number(r[1]),Number(r[2])-1,Number(r[3]));return d?N(d):null}let a=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(o);if(a){let d=Tr(a[1]);if(d>=0)return Ut(d,Number(a[2]),a[3],n)}let s=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(o);if(s){let d=Tr(s[2]);if(d>=0)return Ut(d,Number(s[1]),s[3],n)}let l=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(o);if(l){let d=Number(l[1]),c=Number(l[2]);return d>12&&c<=12?Ut(c-1,d,l[3],n):c>12&&d<=12?Ut(d-1,c,l[3],n):null}return null}function Ut(t,e,n,i){if(n){if(n.length!==4)return null;let r=vr(Number(n),t,e);return r?N(r):null}let o=Js(t,e,i);return o?N(o):null}var tl=/^\d{4}-\d{2}-\d{2}$/;function Je(t){return typeof t=="string"&&tl.test(t)?t:null}function oi(t,e={}){return Je(t.isoDate)??Oe(t.text,e)}function Ze(t){let e=Je(t.isoDate);return e?{start:e,end:Je(t.isoDateEnd)}:null}var Er=" - ",si="aiaDateRangeStart",li="aiaDateRangeEnd";function et(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var ri=/^\d{4}-\d{2}-\d{2}$/;function ai(t){if(!ri.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 nl=/\s+(?:to|through|thru|until|til|till)\s+/g,il=/[-–—]/g;function ol(t){let e=[];for(let n of[nl,il]){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 $t(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of ol(t.trim())){let a=Oe(o.trim(),e);if(!a)continue;let s=ii(r)!==null?Oe(r.trim(),{...e,today:ai(a)??e.today}):Oe(r.trim(),e);!s||s<a||(n.add(`${a}|${s}`),i={start:a,end:s})}return n.size===1?i:null}function Pr(t){let e=ai(t.start),n=ai(t.end);return!e||!n?"":t.start===t.end?Le(e):`${Le(e)}${Er}${Le(n)}`}function wr(t,e){let n=et(t,e);return{text:Pr(n),is_tappable:!0,kind:null,metadata:{[si]:n.start,[li]:n.end}}}function Me(t,e={}){let n=t?.metadata?.[si],i=t?.metadata?.[li];return typeof n=="string"&&typeof i=="string"&&ri.test(n)&&ri.test(i)?et(n,i):$t(t?.text,e)}var Gt="(max-width: 768px)";var rl="var(--aia-option-row-height, 25.9px)",al="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function Lr(t,e){return e?ci(1,Math.min(t,5)):ci(1,Math.min(t,4))}function ci(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${rl} + ${al})`}}function ui(t,e){return!e&&t>=5}function mi(t,e,n,i){if(!(!e&&t>=5&&sl(n,i))){let a=Lr(t,e);return{...a,template:di(a.cols),scrollHintIndices:!e&&t>a.rows?[a.rows-1]:[]}}let r=6;return{...ci(2,3),template:di(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function sl(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 tt(t){if(typeof document>"u")return null;let e=Array.from(t.querySelectorAll("[data-aia-option]"));if(e.length===0)return null;let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:-9999px;top:0;";for(let a of e){let s=a.cloneNode(!0);s.removeAttribute("id"),s.removeAttribute("role"),s.removeAttribute("aria-selected"),s.style.whiteSpace="nowrap",s.style.width="max-content",n.appendChild(s)}t.appendChild(n);let i=Array.from(n.children).map(a=>a.offsetWidth);n.remove();let o=getComputedStyle(t),r=t.clientWidth-(Number.parseFloat(o.paddingLeft)||0)-(Number.parseFloat(o.paddingRight)||0)-(Number.parseFloat(o.columnGap)||0);return{rowWidths:i,gridWidth:r}}function di(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function nt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Gt).matches}function pi(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}function Cr(t,e){let n=e.dropdownTrigger??"auto",i=e.closeDropdownOnBlur??!0,a=t.filteredOptionsLength>0||t.activePillHasNoOptions||t.hasProducts;if(t.inEditMode){let s=i?t.isFocused||t.dropdownHeld:!0;return a&&s}if(n==="auto"){let s=i?t.isFocused||t.dropdownHeld:!0,l=t.text.replace(/\s+$/,"").length,d=t.caretOffset==null||t.caretOffset>=l;return(a||t.isLoading)&&s&&d}return n==="manual"?(a||t.isLoading)&&t.pillTapped:!1}function W(t){if(t.editingIdentified){let{parameter:n,anchor:i}=t.editingIdentified;return`identified:${n}@${i}`}return t.editingParam!=null&&t.editingAnchor!=null?`edit:${t.editingParam?.id}`:`pill:${t.actionableSuggestions[0]?.parameter??""}`}function qt(t){if(!t)return kn();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function ll(t){let e=Pt(t);return e?or(e):kn()}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=Ze(n);if(i&&i.end==null)return i.start}return null}function dl(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(Je(i.metadata?.[Et])??Ye(i.text)),o==="date_range"){let r=Me(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=Ze(i);n(r?.start),n(r?.end)}return[...e].sort()}function fi(t,e){return t.editingParam!=null&&t.editingAnchor!=null?e:t.text.slice(be(t.text,t.completedParams))}function Ar(t,e){let n=yt(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(M=>M.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(M=>M.parameter==="placeholder").map(M=>M.text).join(" "),a=Pe(r,e.prependPlaceholder),s=le(t.text,Math.min(t.filterBase,t.text.length),a),d=s===0&&gt(t.text,t.completedParams.length,a)?"":qe(t.text,s,t.filterInProgress),c=o?.options??[],u=t.editingParam!=null&&t.editingAnchor!=null,f=!u&&!t.editingIdentified&&o?.type?.kind==="multi_select",m,p,g,h;if(u&&t.editingParam&&t.editingAnchor!=null){let M=t.editingParam.id,$=t.completedParams.some(Be=>Be.id===M),We=t.caretOffset??t.editingAnchor,ee=$?"":t.text.slice(t.editingAnchor,We);p=ee.trim(),g=t.editingParam.options,h=t.editingParam.suggestionParameter,m=he(t.editingParam.options,ee)}else p=d.trim(),g=c,h=o?.parameter,m=A(o)?c.map(M=>({...M,matchedText:t.text.slice(be(t.text,t.completedParams)),parameterLabel:Go(M.parameter)})):he(c,d,t.traditionalAutocomplete);let E=t.optionSearch,S=E!=null&&h!=null&&E.parameter===h;S&&E.status==="done"&&E.query===p&&(m=g);let y=S&&E.status==="loading",b=e.showNonTappableOptions===!1;b&&(m=m.filter(M=>M.is_tappable));let x=fi(t,p),v=u?t.editingParam?.suggestionValueType?.kind==="traditional_autocomplete":A(o);!f&&!v&&(m=Bo(m,x));let P=t.editingIdentified,T=u?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,C=P?P.format:te(T),L=u?t.editingParam?.suggestionParameter:o?.parameter,O=C==="location"&&L&&e.optionOverrides?.[L]?"options":C,X=u&&O==="date-range"?Me(t.editingParam):null,I=!u&&!P&&O==="date"?cl(o?.parameter,t.identifiedParams):null,U=null,fe=null,J=k(O)?dl(t):[];if(k(O)){let M=N(new Date),$=J.find(hs=>hs>=M)??null,We=W({...t,actionableSuggestions:i}),ee=t.dateViewMonth;U=ee&&ee.key===We?{year:ee.year,month:ee.month}:P?qt(P.iso):X?qt(X.start):I?qt(I):$&&!u?qt($):ll(t.editingParam?.text),m=_n(U);let Be=t.pendingRangeStart;O==="date-range"&&Be&&Be.key===We&&(fe=Be.iso)}let w=null;if(O==="time"){let M=W({...t,actionableSuggestions:i}),$=t.timeDraft;w=$&&$.key===M?{minutes:$.minutes,touched:!0}:{minutes:hr({editingText:u?t.editingParam?.text:null,options:u?t.editingParam?.options:o?.options}),touched:!1},m=[]}let Z=null;if(O==="location"){let M=W({...t,actionableSuggestions:i}),$=t.locationSearch;if($&&$.key===M){let{key:We,...ee}=$;Z=ee}else Z={query:u?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};m=[]}let at=M=>b?M.is_tappable:!0,ge;if(u){let M=t.editingParam?.options??[];ge=t.editingParam!=null&&M.filter(at).length===0}else ge=o!=null&&c.filter(at).length===0;w&&(ge=!0),Z&&(ge=!0);let Fe=Cr({inEditMode:u||P!=null,filteredOptionsLength:m.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||y,pillTapped:t.pillTapped,activePillHasNoOptions:ge,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),yo=Fe&&t.activeDropdownIndex>=0&&!!m[t.activeDropdownIndex]?.is_tappable,q=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,xo=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||y||q,To=xo&&t.skeletonOptions!==null,fs=To&&t.skeletonOptions?t.skeletonOptions:m,gs=To?t.skeletonSuggestion:null;return{segments:n,actionableSuggestions:i,filteredOptions:m,dropdownLoading:xo,dropdownOptions:fs,dropdownSuggestion:gs,skeletonExiting:q,activeFormatType:O,dateView:U,dateRangeStart:fe,dateFloor:I,dateReferences:J,timeView:w,multiSelectView:f?{picked:t.multiSelectDraft?.key===W({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,locationView:Z,placeholderText:r,leadInText:a,optionQuery:p,isSearchingOptions:y,isDropdownOpen:Fe,isActivePillSelected:yo}}function Kt(t){return t.mode!=="edit"?ml(t):pl(t)}function ul(t,e,n){let i=t.find(A);if(!i?.options)return null;let o=e.slice(be(e,n)).trim().toLowerCase();if(!o)return null;let r=i.options.filter(l=>l.is_tappable&&l.text.trim().toLowerCase()===o);if(new Set(r.map(l=>Y(l,i.parameter))).size!==1)return null;let s=r[0];return{suggestion:i,option:s,matchText:s.text.trim()}}function Ir(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,a=n.find(c=>c.parameter!=="placeholder"&&!A(c));if(!a?.options||a.type?.kind==="multi_select")return null;let s=n.filter(c=>c.parameter==="placeholder").map(c=>c.text).join(" "),l=le(e,i,Pe(s,t.prependPlaceholder)),d=Ke(a.options,e,l,o,r===!0);return d?{suggestion:a,option:d,matchText:d.text}:null}function ml(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?Ir(t):null)??ul(i,e,n):Ir(t);if(!o)return null;let{suggestion:r,option:a,matchText:s}=o,l=s.toLowerCase(),d=e.toLowerCase().lastIndexOf(l),c=d>=0?d:Math.max(0,e.length-a.text.length),u=c+s.length,f=e.slice(c,u),p=u<e.length&&e[u]===" "?u+1:u,g={id:crypto.randomUUID(),placeholder:"",parameter:Y(a,r.parameter),text:f,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(Y(a,r.parameter)):{},options:r.options??[],metadata:a.metadata,icon:a.icon,icon_svg:a.icon_svg,image_url:a.image_url};return{patch:{text:e,completedParams:[...n,g],suggestions:i.filter(h=>h!==r),filterBase:p,newParamId:g.id,caretOffset:p,activeDropdownIndex:-1},caretPos:p,option:a,suggestion:r}}function pl(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(y=>y.id===i.id))return null;let a=e.slice(o,r),s=ft(i.options,a);if(!s)return null;let l=s.text.toLowerCase(),d=a.toLowerCase().lastIndexOf(l),c=o+Math.max(0,d),u=c+s.text.length,f=e.slice(c,u),m=u<e.length&&e[u]===" "?u+1:u,p=e.length,g={id:crypto.randomUUID(),placeholder:"",...ht(i,s),text:f,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,E=0;for(let y=0;y<n.length;y++){let b=ne(e,n[y].text,E);if(b!==-1){if(b>=m){h=y;break}E=b+n[y].text.length}}let S=[...n];return S.splice(h,0,g),{patch:{text:e,completedParams:S,newParamId:g.id,filterBase:p,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:p,activeDropdownIndex:-1},caretPos:p,option:s}}function Or(t){return t.slice(t.search(/\S*$/))}function Mr(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function kr(t,e){let n="",i=0;for(let o of t){if(n+=Mr(o),i+=o.length,n.length>=e.length)return n.startsWith(e)?i+(t.slice(i).match(/^\p{M}*/u)?.[0].length??0):0;if(!e.startsWith(n))return 0}return 0}function gi(t){return[...t].map(Mr).join("")}function zt(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(gi),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:gi(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,f)=>i[s+f].folded===u))continue;let d=i[s+o-1],c=kr(d.text,a);if(c>0)return{typedWords:o,start:i[s].index,end:d.index+c}}}return null}function hi(t,e){let n=e?zt(t,e):null;if(n&&n.typedWords>1)return[{text:t.slice(0,n.start),bold:!1},{text:t.slice(n.start,n.end),bold:!0},{text:t.slice(n.end),bold:!1}].filter(a=>a.text!=="");let i=e?Or(e):"",o=gi(i);if(!o)return[{text:t,bold:!1}];let r=[];for(let a of t.split(/(\s+)/)){if(a==="")continue;let s=/^\s/.test(a)?0:kr(a,o);s>0&&r.push({text:a.slice(0,s),bold:!0});let l=s>0?a.slice(s):a;l&&r.push({text:l,bold:!1})}return r}var fl=6e4;function gl(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function hl(t){return(t??j).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function bl(t){return Ve(t)?`Bearer ${await ct(t).getToken()}`:ut(t)}async function Rr(t){try{let e=hl(t.apiConfig?.endpoint),n=dt(t.apiConfig),i=await bl(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&&gl(o)<=fl&&{keepalive:!0}})}catch{}}function ue(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var bi=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function Sl(t,e,n){let i=bi(t??"");if(i.length===0)return"";let r=bi(e).slice(-i.length),a=bi(n).slice(0,i.length);return r.join(" ")===i.join(" ")||a.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function _r(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:Y(e,n.parameter),a=i?t.text.length:t.filterBase,s=t.text.slice(0,a),l=s.length===0&&t.text.length===0,d=s.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||d)&&t.placeholderText&&(s=`${t.placeholderText} `);let c=Math.min(be(t.text,t.completedParams),s.length),u=!1;if(i){let T=[...s.slice(c).matchAll(/\S+/g)],C=zt(e.text,s.slice(c)),L=T[T.length-(C?.typedWords??1)];s=s.slice(0,L?c+(L.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word===!0){let T=[...s.slice(c).matchAll(/\S+/g)],C=T[T.length-1];s=s.slice(0,C?c+(C.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word!==!1){let T=s.slice(c),C=Math.max(Fo(T,e.text),Ao(T,e));C>0&&(s=s.slice(0,s.length-C)),u=C>0}let f=s.length>0&&s[s.length-1]!==" ",m=i||n.completes_word===!0||u,p=t.activeFormatType!==void 0&&!D(t.activeFormatType)&&D(te({type:n.type})),g=m||p?"":Sl(n.lead_in,s,e.text),h=`${s}${f?" ":""}${g?`${g} `:""}${e.text} `,S=(l||d||i&&s.length===0)&&h.length>0?h[0].toUpperCase()+h.slice(1):h,y=S.toLowerCase().lastIndexOf(e.text.toLowerCase()),b=y>=0?S.slice(y,y+e.text.length):e.text,x=i?ze(r):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text,suggestionIcon:n.icon,suggestionIconSvg:n.icon_svg},v={id:crypto.randomUUID(),placeholder:"",...x,text:b,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},P=t.actionableSuggestions.length-1;return{patch:{text:S,filterBase:S.length,completedParams:[...t.completedParams,v],newParamId:v.id,caretOffset:S.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(T=>T.text!==e.text).map(T=>T.text),key:i?r:n.parameter,position:ue(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:P}}function jt(t){let e=D(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,n=t.editingParam,i=n?{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options}:t.actionableSuggestions[0]??null;return{skeletonOptions:e,skeletonSuggestion:e?i:null,skeletonRequested:!1}}function Yt(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 Qt=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===""?Yt(n.text,o,r):{text:n.text.slice(0,o)+e+n.text.slice(r)},s=o+e.length;return this.deps.store.set(l=>({text:a,completedParams:l.completedParams.filter(d=>d.id!==i.id),editingTail:s,caretOffset:s,activeDropdownIndex:-1})),this.deps.scheduleSetCursor(s),this.promoteIfExact(),!0}caretAfterInput(e){let n=this.deps.store.get(),i={caretOffset:e};n.editingParam&&n.editingAnchor!=null&&e!=null&&(e<n.editingAnchor?(i.editingParam=null,i.editingAnchor=null,i.editingTail=null,i.activeDropdownIndex=-1):n.editingTail!=null&&(i.editingTail=Math.max(n.editingTail,e))),this.deps.store.set(i),this.promoteIfExact()}caretMove(e){let n=this.deps.store.get();if(n.editingParam&&n.editingAnchor!=null&&n.editingTail!=null&&e!=null&&(e<n.editingAnchor||e>n.editingTail)){this.deps.store.set({caretOffset:e,editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1});return}this.deps.store.set({caretOffset:e})}selectOption(e){let n=this.deps.store.get(),i=n.editingParam,o=n.editingAnchor,r=n.editingTail;if(!i||o==null||r==null)return;let a=ht(i,e);this.deps.fireTelemetry("option",{raw_query:H(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(S=>S.text!==e.text).map(S=>S.text),key:a.suggestionParameter,position:ue(i.options,e.text),chip_origin:"tap"});let s=n.text.slice(0,o),l=n.text.slice(r),d=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,u=l.length===0||l[0]!==" "?`${d} `:d,f=s+u+l,m=f.length,p={id:crypto.randomUUID(),placeholder:"",...a,text:d,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},g=n.completedParams.findIndex(S=>S.id===i.id),h=n.completedParams.filter(S=>S.id!==i.id),E=g>=0?Math.min(g,h.length):h.length;h.splice(E,0,p),this.deps.store.set({text:f,completedParams:h,newParamId:p.id,filterBase:m,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:m,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...jt(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=Kt({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 yl=33,xl=70,Tl=120,vl=50,ke="data-aia-placeholder-leaving",Re=new WeakMap;function Xt(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function El(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Hr(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function Nr(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Hr(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(()=>Nr(t,e),33+i)}function Dr(t,e){Hr(t,e,0),e.timer=setTimeout(()=>Nr(t,e),33)}function Fr(t,e){let n=Re.get(t);if(e===""){n&&(Xt(n),Re.delete(t)),t.removeAttribute(ke),delete t.dataset.placeholder;return}if(n?.target===e)return;if(El(t)){n&&Xt(n),t.removeAttribute(ke),Re.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&&Xt(n),Re.set(t,i),o){t.setAttribute(ke,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(ke),t.isConnected&&Dr(t,i)},170);return}t.removeAttribute(ke),Dr(t,i)}function Wr(t){let e=Re.get(t);e&&(Xt(e),Re.delete(t))}var Pl={selectedIso:null,selectedRange:null,rangeStart:null};function it(t){if(!k(t.activeFormatType))return Pl;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?et(i,o):null,rangeStart:t.dateRangeStart,references:t.dateReferences??[]}}let n=Me(t.editingParam);return{selectedIso:n?null:Ye(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart??t.dateFloor??null,floor:t.dateFloor??null,references:t.dateReferences??[]}}function Si(t){let e=t.floor!=null&&t.highlightedIso!=null&&t.highlightedIso<t.floor?null:t.highlightedIso;return t.pendingStart?et(t.pendingStart,e??t.pendingStart):t.selected}function yi(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 xi(t,e,n){return t==null?!1:t<e||n!=null&&t<n}function Ti(t,e){return t==="date"?e??null:null}var Br="https://ai-autocomplete.com";function vi(t=Br){try{if(typeof window>"u"||!window.location)return t;let e=window.location.hostname;if(!e)return t;let n=new URL(t);return n.searchParams.set("utm_source",e),n.toString()}catch{return t}}var Vr={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Best match",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",seeAllResults:"See all results",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",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",timeLabel:"Hora",locationSearch:"Di una ubicaci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},Ei={en:Vr,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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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"}},Ll={pt:"pt-BR",no:"nb",nn:"nb"};function _(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return Ei[o?"zh-TW":"zh-CN"]}let i=Ll[e]??e;return Object.prototype.hasOwnProperty.call(Ei,i)?Ei[i]:Vr}function Pi(t,e,n=_()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function wi(t){let e=a=>{a.ctrlKey||Ur(a.target,t,a.deltaX,a.deltaY)||a.preventDefault()},n=0,i=0,o=a=>{let s=a.touches[0];s&&(n=s.clientX,i=s.clientY)},r=a=>{if(a.touches.length!==1)return;let s=a.touches[0],l=n-s.clientX,d=i-s.clientY;n=s.clientX,i=s.clientY,a.cancelable&&!Ur(a.target,t,l,d)&&a.preventDefault()};return t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("touchstart",o,{passive:!0}),t.addEventListener("touchmove",r,{passive:!1}),()=>{t.removeEventListener("wheel",e),t.removeEventListener("touchstart",o),t.removeEventListener("touchmove",r)}}function Ur(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&Cl(o,i)||n!==0&&Al(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var $r=/^(auto|scroll|overlay)$/;function Cl(t,e){return t.scrollHeight<=t.clientHeight||!$r.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function Al(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!$r.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 Gr=new WeakMap,qr=new WeakSet;function B(t,e,n){if(Gr.set(t,n),qr.has(t))return;qr.add(t);let i=()=>Gr.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 me(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function G(t){t.offsetWidth}var pe="magicx-aia-panel-ghost";function _e(t){return t.closest(`.${pe}`)!==null}function V(t,e){for(let n of t.querySelectorAll(e))if(!_e(n))return n;return null}var Li="--aia-multi-done-fit";function Il(t){return V(t,"[data-aia-multi-done]")}function Ci(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(_e(a))continue;let s=n.defaultView?.getComputedStyle(a),l=Number.parseFloat(i?s?.paddingRight??"0":s?.paddingLeft??"0")||0,d=n.createTreeWalker(a,NodeFilter.SHOW_TEXT),c=n.createRange();for(let u=d.nextNode();u;u=d.nextNode()){if(!u.textContent?.trim())continue;c.selectNodeContents(u);let f=c.getBoundingClientRect();if(f.width===0)continue;let m=i?o.right-f.left:f.right-o.left;r=Math.max(r,m+l)}}r>0?e.style.setProperty(Li,`${Math.ceil(r)}px`):e.style.removeProperty(Li)}var Ai="data-aia-hug",Jt="--aia-panel-fit-width",Ol=36;function Zt(t){t.removeAttribute(Ai)}function Ii(t,e,{eligible:n,loading:i}){if(!n){t.style.removeProperty(Jt);return}if(i){t.style.getPropertyValue(Jt)&&t.setAttribute(Ai,"");return}let o=Ml(t,e);if(o==null){t.style.removeProperty(Jt);return}t.style.setProperty(Jt,`${o}px`),t.setAttribute(Ai,"")}var Kr=new WeakMap;function Ml(t,e){if(nt())return null;let n=V(e,".aia-grid");if(!n||t.offsetWidth===0)return null;let i=V(e,"[data-aia-pillbar]"),o=[n.style.gridTemplateColumns,i?.textContent??"",...Array.from(n.querySelectorAll("[data-aia-option]"),s=>s.textContent)].join("\0"),r=Kr.get(t);if(r?.key===o)return r.width;let a=kl(t,e,n);return Kr.set(t,{key:o,width:a}),a}function kl(t,e,n){let i=tt(n);if(!i||i.rowWidths.some(s=>s<=0))return null;let o=Math.ceil(Math.max(...i.rowWidths)),r=Math.max(1,Oi(n.style.gridTemplateColumns)),a=zr(n,t,r-1)+r*(o+Ol);return Math.ceil(Math.max(a,Rl(e,t)))}function Rl(t,e){let n=V(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:zr(n,e,i>0&&o>0?1:0)+i+o}function Oi(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 zr(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 _l="[data-aia-products], [data-aia-datepicker], [data-aia-date-grid], [data-aia-time-wheel], [data-aia-location]";function Dl(t){let e=!t.hasAttribute("data-aia-has-products")&&V(t,".aia-grid [data-aia-option]")!==null&&V(t,_l)===null,n=V(t,".aia-grid [data-aia-option][data-aia-loading]")!==null;e||Zt(t),Ii(t,t,{eligible:e,loading:n})}var Hl=40,Nl=340,Fl=340,Wl=7,Mi="--aia-option-enter-delay";function ki(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 Ri(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 Yr="magicx-aia-scroll-arrow",en="data-aia-scroll-arrow",De="data-aia-visible",Qr=1e3,Xr=160,Jr="--aia-scroll-arrow-bottom",Bl="Scroll down for more options",_i="data-aia-scrollable",Vl="--aia-scroll-track-top",Ul="--aia-scroll-track-height",$l="--aia-scroll-track-right",Gl="--aia-scroll-thumb-top",ql="--aia-scroll-thumb-height",Kl=12,zl=.5,jl="[data-aia-products-label]",jr=4,Yl=8,Ql=240;function Xl(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,a=t.ownerDocument?.visibilityState==="hidden";if(!r||a||Di(t)){t.scrollTop=o+e,i();return}let s=n.performance?.now?.()??Date.now(),l=()=>n.performance?.now?.()??Date.now(),d=()=>{let c=Math.min(1,(l()-s)/Ql),u=1-(1-c)*(1-c);t.scrollTop=o+e*u,c<1?r.call(n,d):i()};r.call(n,d)}function Jl(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 Zr(t=document,e=_()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=Yr,n.setAttribute(en,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(Jl(t)),n}function Zl(t){return Math.max(1,Oi(t.style.gridTemplateColumns))}function Di(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Hi({dropdown:t,grid:e,button:n}){let i=e.ownerDocument?.defaultView??(typeof window<"u"?window:null),o=!1;n.disabled=!0;let r=null,a=null,s=null,l=null,d=v=>{if(v){if(n.hasAttribute(De))return;if(n.setAttribute(De,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),Di(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(De)&&(n.disabled=!1)},Qr)}else n.removeAttribute(De),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},c=v=>{let P=0,T=v;for(;T&&T!==t;)P+=T.offsetTop,T=T.offsetParent instanceof HTMLElement?T.offsetParent:null;return P},u=()=>{let v=V(t,jl),P;if(v){let T=c(v)+v.offsetHeight/2;P=t.clientHeight-T-n.offsetHeight/2}else{let T=c(e),C=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;P=t.clientHeight-(T+e.offsetHeight)+(C>0?0:Yl)}n.style.setProperty(Jr,`${Math.max(0,Math.round(P))}px`)},f=v=>{let P=0,T=v;for(;T&&T!==t;)P+=T.offsetLeft,T=T.offsetParent instanceof HTMLElement?T.offsetParent:null;return P},m=null,p=(v,P)=>{let T=Math.min(1,Math.max(0,e.scrollTop/v));n.style.setProperty(Gl,`${Math.round(P*T)}px`)},g=()=>{let v=e.scrollHeight-e.clientHeight,P=e.querySelector("[data-aia-option][data-aia-loading]")!==null;if(v<=jr||P){m=null,n.removeAttribute(_i);return}let T=e.clientHeight,C=Math.round(T*zl),L=c(e)+(T-C)/2,O=t.clientWidth-(f(e)+e.offsetWidth),X=Math.min(C,Math.max(Kl,Math.round(C*T/e.scrollHeight)));m={overflow:v,travel:C-X},n.style.setProperty(Vl,`${Math.round(L)}px`),n.style.setProperty(Ul,`${C}px`),n.style.setProperty($l,`${Math.max(0,Math.round(O))}px`),n.style.setProperty(ql,`${X}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,P=e.scrollHeight-e.clientHeight-e.scrollTop;d(!v&&P>jr)},E=()=>{if(o)return;u(),g();let v=e.getAttribute("data-aia-group")??"";if(v!==r){r=v,d(!1),a!==null&&clearTimeout(a);let P=e.querySelectorAll("[data-aia-option]").length,T=Di(e)?0:Ri(P,Zl(e));a=setTimeout(()=>{a=null,h()},T);return}h()},S=()=>{o||(m&&p(m.overflow,m.travel),a===null&&(d(!1),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,h()},Xr)))};e.addEventListener("scroll",S,{passive:!0});let y=v=>v.preventDefault(),b=()=>{let v=i?(Number.parseFloat(i.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0):0,P=Math.max(1,e.clientHeight-v);Xl(e,P,i,S)};n.addEventListener("mousedown",y),n.addEventListener("click",b);let x=null;return i&&typeof i.ResizeObserver=="function"&&(x=new i.ResizeObserver(()=>{u(),g(),h()}),x.observe(e)),E(),{update:E,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",S),n.removeEventListener("mousedown",y),n.removeEventListener("click",b),x?.disconnect(),n.removeAttribute(De),n.removeAttribute(_i),n.setAttribute("aria-hidden","true"))}}}var ea="cubic-bezier(0.25, 0.1, 0.25, 1)",ec="cubic-bezier(0.32, 0.72, 0, 1)",ta=360,na=280,ia=320,oa=40,ra="blur(2px)",tc=160,nc=.05,ic=/pressed/i;function aa(){return typeof performance<"u"?performance.now():Date.now()}function oc(t){for(let e of t.querySelectorAll("[data-aia-loading]"))if(!e.closest(`.${pe}`))return!0;return!1}function rc(t){return t===null?1:1-Math.min(1,Math.max(0,(aa()-t)/tc))**1.7}function sa(t){return t.hasAttribute(en)}var oe=new WeakMap;function ac(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 sc(t,e){let n=0,i="";for(let o of Array.from(t.children))o.classList.contains(pe)||(n+=1+o.getElementsByTagName("*").length,i+=`${o.textContent??""}\0`);return`${e??""}${n}${i}`}function lc(t){let e=t.ownerDocument.createElement("div");e.className=pe,e.setAttribute("aria-hidden","true"),e.inert=!0;for(let n of Array.from(t.children))n.classList.contains(pe)||sa(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))ic.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 cc(t,e,n,i){for(let r of Array.from(t.children))r.classList.contains(pe)&&r.remove();let o=Array.from(t.children).filter(r=>!sa(r));i>nc&&dc(t,e,n,i);for(let r of o)r.animate([{opacity:0,filter:ra},{opacity:1,filter:"blur(0px)"}],{duration:ia,delay:oa,easing:ea,fill:"backwards"})}function dc(t,e,n,i){let o=(t.ownerDocument.defaultView??window).getComputedStyle(t);e.style.cssText=["position:absolute","left:0","right:0",n?"bottom:0":"top:0",`padding:${o.padding}`,"pointer-events:none","box-sizing:border-box"].join(";"),t.appendChild(e),e.animate([{opacity:i,filter:"blur(0px)"},{opacity:0,filter:ra}],{duration:na*i,easing:ea,fill:"forwards"}).finished.then(()=>e.remove(),()=>e.remove())}function Ni(t){let e=t[0]?.text;return e==null||e===""?null:e}function tn(t,e,n){let i=n.visible,o=ac(t,n.enabled??!0),r=oe.get(t);if(!i||!o){o||r?.glide?.cancel(),oe.set(t,{height:0,key:i?e:null,signature:"",snapshot:null,glide:o?r?.glide??null:null,loadingSince:null});return}let a=sc(t,e),s=oc(t)?r?.loadingSince??aa():null;if(r&&r.height>0&&r.glide&&r.signature===a){r.loadingSince=s;return}let l=xe(t),d=t.getBoundingClientRect().height;r?.glide?.cancel();let c=t.getBoundingClientRect().height,u=null,f=r?l?d:r.height:0;if(r&&f>0&&(e!==r.key&&r.snapshot&&cc(t,r.snapshot,n.anchorBottom??!1,rc(r.loadingSince)),Math.abs(f-c)>1)){u=t.animate([{height:`${f}px`},{height:`${c}px`}],{duration:ta,easing:ec});let p=u;u.finished.then(()=>{let g=oe.get(t);g?.glide===p&&(g.glide=null)},()=>{})}let m=null;e!==null&&(m=r&&r.signature===a&&r.snapshot&&!r.snapshot.isConnected?r.snapshot:lc(t)),oe.set(t,{height:c,key:e,signature:a,snapshot:m,glide:u,loadingSince:s})}function xe(t){let e=oe.get(t)?.glide??null;return e&&(e.playState==="running"||e.pending)?e:null}function Fi(t){if(!xe(t))return null;let e=oe.get(t)?.height??0;return e>0?e:null}function Wi(t,e){let n=oe.get(t);n&&n.height>0&&!xe(t)&&e>0&&(n.height=e)}function Bi(t){oe.get(t)?.glide?.cancel(),oe.delete(t)}var la="data-aia-key";function Q(t,e,n){let i=new Map;for(let a of Array.from(t.children)){let s=a.getAttribute(la);s!=null&&i.set(s,a)}let o=new Set,r=[];for(let a=0;a<e.length;a++){let s=e[a],l=n.keyOf(s,a);o.add(l);let d=i.get(l);d||(d=n.create(s,a),d.setAttribute(la,l)),n.update?.(d,s,a),t.children[a]!==d&&t.insertBefore(d,t.children[a]??null),r.push(d)}for(let[a,s]of i)o.has(a)||s.remove();return r}function ca(t,e){if(!e.interactive)return null;let n=e.options[me(t)];return n?.is_tappable?n:null}var uc={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=ca(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")&&ca(t,e)&&e.callbacks.onHighlight(me(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,me(t))}};function ua(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),G(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}B(l,uc,{options:e,callbacks:a,interactive:s});let d=l.querySelector(".magicx-aia-datepicker-month");d&&(d.textContent=Mn(o));let c=l.querySelector(".magicx-aia-datepicker-grid");c&&mc(c,e,n,i,r)}function mc(t,e,n,i,o){let r=N(new Date),a=Si({pendingStart:o.rangeStart,highlightedIso:K(e[n]),selected:o.selectedRange,floor:o.floor});Q(t,e,{keyOf:(s,l)=>K(s)??`pad-${l}`,create:s=>pc(s),update:(s,l,d)=>{let c=K(l),u=yi(c,{selectedIso:o.selectedIso,range:a,references:o.references}),f=d===n&&l.is_tappable;s.id=`${i}-option-${d}`,s.dataset.aiaIndex=String(d),s.setAttribute("aria-selected",String(f)),s.classList.toggle("magicx-aia-date-cell--past",xi(c,r,o.floor)),s.classList.toggle("magicx-aia-date-cell--highlighted",f),s.classList.toggle("magicx-aia-date-cell--today",c!=null&&c===r),s.classList.toggle("magicx-aia-date-cell--selected",u.selected),s.classList.toggle("magicx-aia-date-cell--in-range",u.inRange),s.classList.toggle("magicx-aia-date-cell--reference",u.reference)}})}function pc(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=Dn(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(da("prev","Previous month","\u2039"),n,da("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of vt){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 da(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 gc='<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>',ma="data-aia-location-body";function hc(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=gc;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 pa(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(ma)!==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(ma,r)}Q(t,o,{keyOf:(a,s)=>`${s}:${a.id}`,create:a=>hc(a),update:(a,s,l)=>{let d=l===e.highlighted;a.classList.toggle("magicx-aia-location-row--highlighted",d),a.setAttribute("aria-selected",String(d)),a.setAttribute("data-aia-index",String(l)),a.id=i(l)}})}var re=new WeakMap,Sc=0,Te=new WeakMap,yc='<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>',ve=t=>wt(t.input)===t.input;function fa(t,e){let n=wt(t);if(n instanceof HTMLElement&&n!==e.input&&n!==R(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=Se(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function xc(t,e,n){if(!(!(n instanceof HTMLElement)||n===e.returnTo||t.contains(n))&&n!==R(t).body&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=Se(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Tc(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=Qe(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=R(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var vc={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&He(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function He(t,e=!1){let n=Te.get(t),i=re.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&ve(n)&&(n.returning=!0,Tc(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function Ec(t){let e=Te.get(t),n=re.get(t);if(!(!e||!n||ve(e))){if(fa(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!ve(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function Pc(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++Sc}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=yc;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(),fa(t,r),re.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>re.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",a=>{xc(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;He(t,!0),s.callbacks.onLocationCommit();return;case"Escape":a.preventDefault(),a.stopPropagation(),r.declined=!0,He(t);return;case"Backspace":if(i.value!=="")return;a.preventDefault(),r.declined=!0,He(t);return}}),Te.set(t,r),r}function ga(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=Te.get(e);n&&(ve(n)&&He(e),n.declined=!1,n.input.tabIndex=-1)}}function ha(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=Te.get(r);l&&ve(l)&&He(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let a=Te.get(r)??Pc(r,n);a.input.tabIndex=0,re.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),B(a.results,vc,re.get(r)),a.input.value!==e.query&&!ve(a)&&(a.input.value=e.query);let s=l=>`${r?.id}-row-${l}`;if(pa(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&&!ve(a)){let l=r;queueMicrotask(()=>{l.isConnected&&!Te.get(l)?.declined&&Ec(l)})}}else{let l=a;setTimeout(()=>{if(l.widgetFocused)return;let d=l.returnTo;d&&wt(d)===d||(l.declined=!1)},0)}}var wc={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},ba=[125,69];function Sa(t,e){return e?1:t===0?.7:t===1?.4:.2}function nn(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)),B(s,wc,{onSelectPill:i,loading:r}),r&&e.length===0){s.setAttribute("data-aia-pill-list-loading",""),s.innerHTML="";for(let l=0;l<ba.length;l++){let d=ba[l],c=document.createElement("span");c.setAttribute("data-aia-pill-skeleton",""),c.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,c.style.width=`${d}px`,c.style.setProperty("--aia-pill-opacity",String(Sa(l,!1))),s.appendChild(c)}return}r?s.setAttribute("data-aia-pill-list-loading",""):s.removeAttribute("data-aia-pill-list-loading");for(let l of s.querySelectorAll("[data-aia-pill-skeleton]"))l.remove();Q(s,e,{keyOf:l=>`${l.type?.kind??""}|${bt(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let d=document.createElement("button");if(d.type="button",d.tabIndex=-1,d.setAttribute("data-aia-pill",""),d.setAttribute("contenteditable","false"),bt(l)){d.setAttribute("data-aia-smart-suggestion",A(l)?"header":"");let c=document.createElement("span");c.className="magicx-aia-smart-suggestion-text",c.textContent=l.text;let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-sparkle",u.innerHTML=An,d.append(c,u)}else d.textContent=l.text;return d.disabled=!0,d},update:(l,d,c)=>{let u=l,f=a&&c===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(Sa(c,f))),u.dataset.aiaPillIndex=String(c),u.toggleAttribute("data-aia-pill-active",c===n),r?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),G(s);for(let l of s.querySelectorAll("[data-aia-pill]"))l.disabled=r}function Vi(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var Lc=32;function ya(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 Ui(t){let e=n=>{let i=ya(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var xa=Intl.Segmenter,Ta=xa?new xa(void 0,{granularity:"grapheme"}):null;function $i(t){let e=t.trim().normalize("NFC").toUpperCase();if(Ta)for(let n of Ta.segment(e))return n.segment;return Array.from(e)[0]??"?"}var Gi=120,Cc=360;function Ac(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 va(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=Ac(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 qi(t,e){let n=va(t,e);return n===t?[t]:[n,t]}function Ki(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 on(t){let e=t?.trim();return e?qi(e,360):[]}function Ic(t){return on(t)[0]}var rn=new WeakMap,ji=new WeakMap,Pa=new WeakMap;function wa(t,e,n,i,o,r="row",a="image",s=_(),l){let d=t.querySelector(".magicx-aia-products");if(e.length===0){d?.remove();return}if(!d){d=document.createElement("section"),d.className="magicx-aia-products",d.setAttribute("data-aia-products",""),d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${n}-products-label`);let f=document.createElement("div");f.className="magicx-aia-products-label",f.id=`${n}-products-label`,f.setAttribute("data-aia-products-label",""),f.textContent=s.products;let m=document.createElement("div");m.className="magicx-aia-products-row",m.setAttribute("data-aia-products-row",""),Ui(m),d.append(f,m),t.appendChild(d)}d.setAttribute("data-aia-products-layout",r);let c=d.querySelector(".magicx-aia-products-label");c&&c.textContent!==s.products&&(c.textContent=s.products);let u=d.querySelector(".magicx-aia-products-row");if(u){Q(u,e,{keyOf:f=>Rc(f,!!l),create:f=>_c(f,i,o,a,s,l),update:(f,m,p)=>{rn.set(f,m),Oc(f,m.price,m.compareAtPrice),f.id=`${n}-product-${p}`,f.dataset.aiaIndex=String(p),Pa.get(f)?.(a);let g=f.querySelector(".magicx-aia-product-badge");g&&g.textContent!==s.soldOut&&(g.textContent=s.soldOut);let h=f.querySelector(".magicx-aia-product-cart");h&&h.setAttribute("aria-label",La(m,s))}}),G(u);for(let f of u.querySelectorAll("[data-aia-product]")){let m=ji.get(f);m&&(ji.delete(f),m())}}}function Yi(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)_e(i)||(i.tabIndex=e?0:-1)}function Oc(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 Ea(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 La(t,e){return`${e.addToCart}: ${t.title}`}var zi="http://www.w3.org/2000/svg";function Mc(){let t=document.createElementNS(zi,"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(zi,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(zi,"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 kc(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",La(e,o)),r.tabIndex=0,r.appendChild(Mc());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(rn.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 Rc(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 _c(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=on(t.imageUrl),d=l[0],c=!!d,u=()=>{s.replaceChildren(),s.removeAttribute("data-aia-image-loaded"),s.toggleAttribute("data-aia-product-placeholder",i==="image"),s.toggleAttribute("data-aia-product-initial",i==="initial"),i==="initial"&&(s.textContent=$i(t.title))};if(Pa.set(a,g=>{g!==i&&(i=g,c||u())}),d){let g=document.createElement("img"),h=0;g.onload=()=>{s.setAttribute("data-aia-image-loaded",""),Ea(a,Ki(g.naturalWidth,g.naturalHeight))},g.onerror=()=>{let E=l[++h];if(E){g.src=E;return}c=!1,Ea(a,null),u()},g.className="magicx-aia-product-image",g.src=d,g.alt="",g.loading="lazy",g.decoding="async",s.appendChild(g)}else u();a.appendChild(s);let f=document.createElement("span");if(f.className="magicx-aia-product-body",t.vendor){let g=document.createElement("span");g.className="magicx-aia-product-vendor",g.textContent=t.vendor,f.appendChild(g)}let m=document.createElement("span");if(m.className="magicx-aia-product-title",m.textContent=t.title,f.appendChild(m),t.available===!1){a.setAttribute("data-aia-product-sold-out","");let g=document.createElement("span");g.className="magicx-aia-product-badge",g.textContent=o.soldOut,f.appendChild(g)}a.appendChild(f);let p=r&&t.available!==!1?kc(a,t,r,n,o):null;return p&&(a.setAttribute("data-aia-product-has-cart",""),a.appendChild(p.el)),ji.set(a,()=>{p?.arm(),t.url&&(a.href=t.url),a.addEventListener("click",g=>{g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||g.button!==0||(g.preventDefault(),e(rn.get(a)??t))})}),a.addEventListener("keydown",g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),e(rn.get(a)??t))}),a.addEventListener("focus",()=>n(!0)),a.addEventListener("blur",g=>{g.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),a}var Dc=10,Hc=44;function Qi(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 Ca="http://www.w3.org/2000/svg",Nc=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function Fc(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 Wc=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],Bc=/^[a-zA-Z0-9#.,%\s()-]+$/;function Vc(t){let e=[];for(let n of Wc){let i=t.getAttribute(n);i===null||!Bc.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function Aa(t){for(let e of Array.from(t.attributes))Fc(e.name,e.value)&&t.removeAttribute(e.name);Vc(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!Nc.has(n.localName)||n.namespaceURI!==Ca?n.remove():Aa(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!==Ca||e.getElementsByTagName("parsererror").length>0?null:(Aa(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function an(t){return t.text}function Ee(t){return ln(t)[0]??null}function ln(t){let e=Uc(t);return e?qi(e,120):[]}function Uc(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 ot(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var Ia={one:"item",other:"items"};function $c(t,e=Ia){let n=ot(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function Oa(t){return Ee(t.image_url)!==null}var sn=new Map;function Gc(t){let e=t.icon_svg;if(!e)return!1;let n=sn.get(e);return n===void 0&&(n=ae(e)!==null,sn.size>=256&&sn.clear(),sn.set(e,n)),n}function Xi(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&Oa(i)||e&&Gc(i))}var Ma=new WeakMap;function qc(t,e,n){let i=e.length,o=nt(),r=Ma.get(t),a=n&&r&&pi(r.options,e)?r.plan:null,s=!a&&!n&&ui(i,o)?tt(t):null,l=a??mi(i,o,s?.rowWidths??null,s?.gridWidth??null);return n||Ma.set(t,{options:e,plan:l}),t.style.gridTemplateColumns=l.template,t.style.setProperty("--aia-grid-max-height",l.maxHeight),t.querySelectorAll("[data-aia-option]").forEach((d,c)=>{d.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(c))}),l.cols}function ka(t,e){if(e.loading||!e.interactive)return null;let n=e.options[me(t)];return n?.is_tappable?n:null}var Kc={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&&!Qi(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(me(t))},onLeave:(t,e)=>e.onHighlight(-1,me(t))};function Ra(t,e,n,i,o,r,a,s="",l="below",d=!0,c=!0,u=!0,f=!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)),B(p,Kc,{options:e,onSelect:i,onHighlight:o,loading:a,interactive:f});let g=p.dataset.aiaGroup!==s;p.dataset.aiaGroup=s;let h=Xi(e,d,c);zc(p,e,n,r,a,{showIcons:d&&h,showImages:c&&h,showCounts:u,picked:m});let E=qc(p,e,a);jc(p,e.length,E,a,l),g&&(p.scrollTop=0)}function zc(t,e,n,i,o,r){let a=o?"1":"0",s=t.dataset.aiaGroup??"",{showIcons:l,showImages:d,showCounts:c}=r,u=l?p=>p.icon??p.icon_svg??"":()=>"",f=d?p=>Ee(p.image_url)??"":()=>"",m=c?p=>ot(p.item_count)??"":()=>"";Q(t,e,{keyOf:p=>`${p.text}\0${p.parameterLabel??""}\0${u(p)}\0${f(p)}\0${m(p)}\0${a}\0${s}`,create:(p,g)=>{let h=Yc(p,o,r);return o||(h.dataset.aiaEntering=""),h},update:(p,g,h)=>{if(Ji.get(p)!==(g.matchedText??"")){let y=p.querySelector(".magicx-aia-option-text");y&&_a(y,g),Ji.set(p,g.matchedText??"")}let E=h===n&&!o;p.id=`${i}-option-${h}`,p.dataset.aiaIndex=String(h),p.setAttribute("aria-selected",String(r.picked?r.picked.includes(g.text):E));let S=p.querySelector(".magicx-aia-checkbox");r.picked&&g.is_tappable?(S||(S=document.createElement("span"),S.className="magicx-aia-checkbox",S.setAttribute("aria-hidden","true"),p.querySelector(".magicx-aia-option-content")?.prepend(S)),S.dataset.checked=String(r.picked.includes(g.text)),S.textContent=r.picked.includes(g.text)?"\u2713":""):S?.remove(),p.classList.toggle("magicx-aia-option--highlighted",E),p.classList.toggle("magicx-aia-option--live-match",!!g.liveMatch&&!o)}})}function jc(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(Mi,`${ki(a,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var Ji=new WeakMap;function _a(t,e){if(t.replaceChildren(),e.matchedText)for(let n of hi(an(e),e.matchedText))if(n.bold){let i=document.createElement("strong");i.className="magicx-aia-option-match",i.textContent=n.text,t.appendChild(i)}else t.appendChild(document.createTextNode(n.text));else t.appendChild(document.createTextNode(an(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 Yc(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?ln(t.image_url):[],d=l[0];if(d){let m=document.createElement("span");m.className="magicx-aia-option-image",m.setAttribute("aria-hidden","true");let p=document.createElement("img");p.setAttribute("alt",""),p.setAttribute("loading","lazy"),p.setAttribute("decoding","async"),p.setAttribute("referrerpolicy","no-referrer"),p.setAttribute("draggable","false");let g=0;p.onload=()=>m.setAttribute("data-aia-image-loaded",""),p.onerror=()=>{let h=l[++g];h?p.src=h:p.hidden=!0},p.src=d,m.appendChild(p),s.appendChild(m),r.dataset.aiaImage=""}let c=!d&&n&&t.icon_svg?ae(t.icon_svg):null;if(c){let m=document.createElement("span");m.className="magicx-aia-option-icon",m.setAttribute("aria-hidden","true"),m.innerHTML=c,s.appendChild(m),t.icon&&(r.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",_a(u,t),Ji.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 f=o?ot(t.item_count):null;if(f!==null){let m=document.createElement("span");m.className="magicx-aia-option-count",m.textContent=f,s.appendChild(m),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(s),r}var Qc=120,Xc={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(Ht(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},Ha=new WeakMap,Da=new WeakMap;function Na(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=ed(),t.appendChild(r),G(r);let d=r.querySelector("[data-aia-time-done]");d&&(d.disabled=!1)}let a={view:e,callbacks:i,interactive:o};Ha.set(r,a),B(r,Xc,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=kt(e.minutes));for(let d of _t){let c=r.querySelector(`[data-aia-time-column="${d}"]`);c&&Jc(c,d,e.minutes)}}function Jc(t,e,n){let i=Dt(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=cn(t);if(o.settle)return;let r=i*Rt;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function cn(t){let e=Da.get(t);return e||(e={syncedTop:null,settle:null},Da.set(t,e)),e}function Zc(t,e,n){let i=cn(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(()=>Fa(t,e,n),Qc)}function Fa(t,e,n){let i=cn(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=Ha.get(t);if(!o||!o.interactive)return;let r=ei(n,e.scrollTop);r!==Dt(n,o.view.minutes)&&o.callbacks.onTimeChange(Ht(n,o.view.minutes,r))}function ed(){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 _t){if(r==="minute"){let a=document.createElement("span");a.className="magicx-aia-time-wheel-separator",a.textContent=":",n.appendChild(a)}n.appendChild(td(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 td(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),Zn(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",()=>Zc(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{cn(n).settle&&Fa(t,n,e)}),n}var Ne="data-aia-fit",dn="--aia-dropdown-fit-height",Wa=8,nd=160;function Zi({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,a=null,s=null,l=null,d=!1,c=()=>{t.removeAttribute(Ne),t.style.removeProperty(dn)},u=()=>{if(xe(t)){d=!0;return}d=!1,Wi(t,t.getBoundingClientRect().height)},f=S=>`${r}|${(S??t).scrollHeight}|${t.offsetWidth}`,m=S=>s?.key===f(S)?s.height:null,p=S=>{let y=f(S);if(s?.key===y)return s.height;let b=S?.scrollTop??0;t.removeAttribute(Ne);let x=t.offsetHeight;return t.setAttribute(Ne,""),S&&b&&(S.scrollTop=b),s={key:y,height:x},x},g=()=>{if(i)return;if(!e()){o=!1;return}let S=xe(t),y=S?Fi(t):null;S&&l!==S&&(l=S,S.finished.then(h,h)),!S&&d&&u(),o||(o=!0,c());let b=t.hasAttribute(Ne),x=V(t,".aia-grid")?.getAttribute("data-aia-group")??null,v=x!==r;r=x;let P=od(t,n);if(P===null)return;let T=id(t);if(b){let O=S?m(T):p(T);if(O!==null&&O<=P){c(),u();return}}else if((y??t.offsetHeight)<=P)return;let C=`${Math.max(nd,Math.floor(P))}px`,L=t.style.getPropertyValue(dn)!==C;L&&t.style.setProperty(dn,C),b?v&&T&&(T.scrollTop=0):t.setAttribute(Ne,""),(L||!b)&&u()},h=()=>{i||a!==null||!n||(a=n.requestAnimationFrame(()=>{a=null,g()}))},E=n?.visualViewport??null;return E?.addEventListener("resize",h),E?.addEventListener("scroll",h),n?.addEventListener("resize",h),n?.addEventListener("scroll",h,{capture:!0,passive:!0}),g(),{update:g,destroy(){i||(i=!0,a!==null&&n?.cancelAnimationFrame(a),E?.removeEventListener("resize",h),E?.removeEventListener("scroll",h),n?.removeEventListener("resize",h),n?.removeEventListener("scroll",h,{capture:!0}))}}}function id(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function od(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-Wa:i+o-s-Wa}var rd=[159,119,164];function pn(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()),wi(e),e}var un=new WeakMap;function ad(t,e,n){let i=un.get(t);if(i||(i={button:Zr(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),un.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=Hi({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var mn=new WeakMap;function Ba(t){let e=mn.get(t);if(e){e.update();return}mn.set(t,Zi({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function eo(t){mn.get(t)?.destroy(),mn.delete(t),Bi(t);let e=un.get(t);e&&(e.controller?.destroy(),un.delete(t))}function fn(t,e){let n=e.strings??_(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:a,showPills:s,isActivePillSelected:l,onSelect:d,onHighlight:c,onPillClick:u,onSkip:f}=e,m=Cn(e.pills,n.keepTyping),p=In(m),g=s&&m.length>0,h=i.length>0,E=e.products.length>0,S=e.formatType==="time"&&e.timeView!=null,y=e.formatType==="location"&&e.locationView!=null,b=r&&(h||g||a||E||S||y);if(b?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"),!b){Yi(t,!1),ga(t),Ba(t),tn(t,null,{visible:!1});return}E?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),Zt(t),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let x=t.querySelector(".aia-stack");x||(x=document.createElement("div"),x.className="aia-stack",x.style.setProperty("--aia-stack-space","8px"),t.appendChild(x));let v=e.showSkipButton&&p&&!e.isInputEmpty,P=g||a&&s||v,T=x.querySelector(".magicx-aia-pill-bar");if(P){T||(T=document.createElement("div"),T.className="magicx-aia-pill-bar aia-cluster",T.setAttribute("data-nowrap",""),T.setAttribute("data-aia-pillbar",""),x.insertBefore(T,x.firstChild));let J=g||a&&s,w=T.querySelector(".magicx-aia-pill-scroll");J?(w||(w=document.createElement("span"),w.className="magicx-aia-pill-scroll",w.setAttribute("data-aia-pill-scroll",""),T.insertBefore(w,T.firstChild)),nn(w,m,0,u,!0,a,l)):w&&w.remove(),cd(T,v,a||e.skipDisabled,m[0],f,n)}else T&&T.remove();let C=e.suggestions[0],L=C?`${C.parameter} ${C.text}`:"",O=k(e.formatType),X=O&&!a;Ra(x,O?[]:i,o,d,c,e.listboxId,a,L,e.optionsPosition??"below",e.showOptionIcons??!0,e.showOptionImages??!0,e.showOptionCounts??!0,!e.skipDisabled,a?void 0:e.multiSelectView?.picked),t.setAttribute("aria-multiselectable",String(!!e.multiSelectView)),gd(x,!!e.multiSelectView&&!a,e.skipDisabled,e.onMultiSelectCommit,n.done),ad(t,x.querySelector(".aia-grid"),n),ua(x,X?i:[],o,e.listboxId,X?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart,floor:Ti(e.formatType,e.dateRangeStart),references:e.dateReferences??[]},{onSelect:d,onHighlight:c,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),Na(x,e.formatType==="time"&&!a?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),ha(x,e.formatType==="location"&&!a?e.locationView:null,n,{onLocationQuery:e.onLocationQuery,onLocationMove:e.onLocationMove,onLocationCommit:e.onLocationCommit,onLocationFocusChange:e.onLocationFocusChange},{interactive:!e.skipDisabled,inputFocused:e.isFocused??!1,reediting:e.isReediting??!1});let I=x.querySelector(".magicx-aia-skeleton-bars");if(a&&(!h||D(e.formatType))){if(!I){I=document.createElement("div"),I.className="magicx-aia-skeleton-bars",I.setAttribute("data-aia-skeleton-bars","");for(let J of rd){let w=document.createElement("span");w.className="magicx-aia-skeleton-bar",w.style.width=`${J}px`,I.appendChild(w)}x.appendChild(I)}}else I&&I.remove();wa(x,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart),Yi(t,!0),pd(x,e.onSeeAllResults,n.seeAllResults);let U=x.querySelector(".magicx-aia-footer")??ud(n),fe=o>=0&&!!i[o]?.is_tappable;dd(U,Pi(fe,e.isInputEmpty,n)),U.isConnected||x.appendChild(U),sd(x,[".magicx-aia-pill-bar",".aia-grid","[data-aia-multi-actions]",".magicx-aia-datepicker",".magicx-aia-time-wheel","[data-aia-location]",".magicx-aia-skeleton-bars",".magicx-aia-products","[data-aia-see-all]",".magicx-aia-footer"]),Ci(x,x.querySelector(".magicx-aia-multi-done")),Ii(t,x,{eligible:h&&!E&&!O&&!S&&!y,loading:a}),Ba(t),tn(t,Ni(s?m:[]),{visible:!0,anchorBottom:e.optionsPosition==="above"})}function sd(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 ld={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function cd(t,e,n,i,o,r){B(t,ld,{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),G(a)),a.textContent!==r.skip&&(a.textContent=r.skip),a.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),a.disabled=n}function dd(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 ud(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=vi(),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 md={itemSelector:".magicx-aia-see-all",onClick:(t,e,n)=>{e.submit&&(n.stopPropagation(),e.submit())}};function pd(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),G(r)}B(i,md,{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 gd(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),G(s)}B(r,fd,{commit:i,disabled:n});let a=r.querySelector("button");a&&(a.textContent=o,a.disabled=n)}function Va(t,e){let n=pn(e.listboxId);return t.appendChild(n),{dropdown:n}}function to(t,e,n){let i=it(e);fn(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.multiSelectView,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 hd="[data-aia-chip-remove]";function no(t,e){let n=e;if(!n||n.nodeType===void 0)return null;let o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(hd)??null;return o&&t.contains(o)?o:null}function io(t,e){let n=null,i=d=>{n=null;let c=d;if(c.button)return;let u=no(t,d.target);if(!u)return;d.preventDefault(),d.stopPropagation();let f=u.dataset.aiaChipRemove,m=c.pointerType==="touch"||c.pointerType==="pen";n={id:f,x:c.clientX,y:c.clientY,pending:m},!m&&f&&e(f)},o=d=>{if(!n?.pending)return;n.pending=!1;let c=d;if(Math.hypot(c.clientX-n.x,c.clientY-n.y)>10)return;let f=t.getRootNode().elementFromPoint?.(c.clientX,c.clientY)??d.target,m=no(t,f)?.dataset.aiaChipRemove;m&&m===n.id&&e(m)},r=()=>{n&&(n.pending=!1)},a=d=>{!n&&!no(t,d.target)||(d.cancelable&&d.preventDefault(),d.type==="click"&&(d.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 oo(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let c=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let u=t.getBoundingClientRect().height;if(u!==0){if(c===0||Math.abs(u-c)<.5){t.style.height=`${u}px`;return}t.style.height=`${c}px`,t.getBoundingClientRect(),t.style.height=`${u}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(c=>{for(let f of c)if(f.target!==t){n();return}let u=t.getBoundingClientRect().width;Math.abs(u-i)<.5||(i=u,n())}):null,r=()=>{for(let c of Array.from(t.children))o?.observe(c)},a=0,s=()=>{r(),n(),e.clearTimeout(a),a=e.setTimeout(n,340)},l=new e.MutationObserver(s);l.observe(t,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["data-placeholder","data-aia-empty"]}),o?.observe(t),r(),t.addEventListener("load",s,!0);let d=!1;return t.ownerDocument.fonts?.ready.then(()=>{d||n()}),n(),()=>{d=!0,t.removeEventListener("load",s,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(a),t.style.height=""}}var qa=2600,Sd=3,lo="data-aia-hint",so="magicx-aia-hint",Ka="data-aia-hint-el",yd={position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--aia-hint-color, #999)",userSelect:"none"},xd=280,Td=320,vd=380,ro="cubic-bezier(0.25, 0.1, 0.25, 1)",Ua=new Set(["a","an","the","some","my"]),bn=new WeakMap;function Ed(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function $a(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&&Ua.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,[d,...c]=n.split(/\s+/);c.length&&d&&Ua.has(d.toLowerCase())&&(l=d,n=c.join(" "));let u=l??a;u&&o.push({key:`w:${u.toLowerCase()}`,text:u,icon:null});let f=t.icon_svg?ae(t.icon_svg):null;return o.push({key:`c:${f??""}:${n}`,text:n,icon:f}),o}function Pd(t,e){let n=t.createElement("span");if(n.className=`${so}__word`,n.dataset.key=e.key,n.style.display="inline-block",e.icon){let i=t.createElement("span");i.className=`${so}__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 ao(t,e,n){return typeof t.animate=="function"?t.animate(e,n):null}function gn(t,e){let n=t.ownerDocument?.defaultView;if(!n)return;let i=n.getComputedStyle(t),o=c=>Number.parseFloat(c)||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,d=Math.max(s,l);e.style.left=`${r}px`,e.style.top=`${a}px`,d>0&&(e.style.maxWidth=`${d}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 Ga(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 g=ao(p,[{opacity:1,filter:"blur(0)"},{opacity:0,filter:"blur(2px)"}],{duration:xd,easing:ro,fill:"forwards"});g?g.onfinish=()=>p.remove():p.remove()}let d=Array.from(o.children).filter(m=>m.dataset.leaving!==void 0),c=[];if(e.forEach((m,p)=>{p>0&&c.push(r.createTextNode(" ")),c.push(a.get(m.key)??Pd(r,m))}),o.replaceChildren(...c,...d),!n)return;let u=new Map;for(let m of c)m instanceof HTMLElement&&m.dataset.key&&u.set(m.dataset.key,m);let f=0;for(let m of e){let p=u.get(m.key);if(p)if(!a.has(m.key))ao(p,[{opacity:0,filter:"blur(2px)"},{opacity:1,filter:"blur(0)"}],{duration:Td,delay:i?80*f++:180+60*f++,easing:ro,fill:"backwards"});else{let h=(s.get(m.key)??p.offsetLeft)-p.offsetLeft;Math.abs(h)>.5&&ao(p,[{transform:`translateX(${h}px)`},{transform:"none"}],{duration:vd,easing:ro})}}}function hn(t){let e=bn.get(t);e&&(e.timer!==null&&clearInterval(e.timer),e.resize?.disconnect(),e.el.remove(),bn.delete(t),t.removeAttribute(lo),t.removeAttribute("aria-placeholder"))}function za(t,e,n,i){let o=i.filter(p=>p.text.trim()!=="").slice(0,Sd),r=t.parentElement;if(!e||o.length<2||!r){hn(t);return}let a=`${n}\0${o.map(p=>`${p.text}${p.icon_svg??""}`).join("\0")}`,s=bn.get(t);if(s&&s.key===a&&s.el.isConnected){gn(t,s.el);return}hn(t);let l=t.ownerDocument,d=l.createElement("span");d.className=so,d.setAttribute(Ka,""),d.setAttribute("aria-hidden","true"),Object.assign(d.style,yd),r.insertBefore(d,t),t.setAttribute(lo,""),n.trim()&&t.setAttribute("aria-placeholder",n.trim()),gn(t,d);let c=l.defaultView,u=c?.ResizeObserver?new c.ResizeObserver(()=>{d.isConnected&&gn(t,d)}):null;u?.observe(r);let f=Ed(t),m={key:a,lead:n,options:o,index:0,el:d,timer:null,resize:u};bn.set(t,m),Ga(m,$a(o[0],n),!f,!0),!f&&(m.timer=setInterval(()=>{if(!t.isConnected||!d.isConnected){hn(t);return}t.ownerDocument?.hidden||(m.index=(m.index+1)%m.options.length,gn(t,d),Ga(m,$a(m.options[m.index],m.lead),!0,!1))},qa))}function co(t){hn(t)}function uo(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 wd=6,Ld=.3;function ja(t){return t<=0?"0px":`${(-Math.min(Ld,2*wd/t)).toFixed(3)}px`}var Ya=new Map;function Cd(t,e,n){let i=Ya.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`;Ya.set(e,s),t.style.setProperty("--aia-chip-image-fit",s)},o.src=e}function mo(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,d=n.length===0;e.dataset.aiaEmpty=d?"true":"false",Fr(e,d?r:""),za(e,d,r,t.hintOptions??[]);let c=n.map(y=>y.type==="completed"?`${y.type}:${y.value}${a?y.param.icon??y.param.icon_svg??"":""}${s?Ee(y.param.image_url)??"":""}${l?"x":""}`:`${y.type}:${y.value}`).join("\0"),u=e.dataset.segKey??"",f=e.dataset.newParamId??"",m=e.dataset.editingParamId??"";if(c===u&&(i??"")===f&&(o??"")===m)return;if(c===u){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let y of e.querySelectorAll("strong[data-param-id]")){let b=y.dataset.paramId,x=y.dataset.seg==="completed"&&b===i;y.classList.toggle("magicx-aia-shimmer-revealed",x),y.classList.toggle("magicx-aia-shimmer-sweep",x),y.classList.toggle("magicx-aia-segment--editing",b===o)}return}let p=mr(e),g=p?z(e):null;e.dataset.segKey=c,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let h=R(e),E=h.createDocumentFragment(),S=0;for(let y of n)if(S+=y.value.length,y.type==="completed"){let b=h.createElement("strong");b.dataset.seg="completed",b.dataset.paramId=y.param.id;let x=y.param.id===i,v=y.param.id===o,P=["magicx-aia-segment","magicx-aia-segment--completed"];x&&P.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),v&&P.push("magicx-aia-segment--editing"),b.className=P.join(" "),b.style.letterSpacing=ja(y.value.length);let T=s?Ee(y.param.image_url):null;if(T){let L=h.createElement("span");L.className="magicx-aia-segment-image",L.setAttribute("contenteditable","false"),L.setAttribute("aria-hidden","true"),L.style.setProperty("--aia-chip-image",`url("${T}")`),Cd(L,T,h),b.appendChild(L),b.dataset.aiaImage=""}let C=!T&&a&&y.param.icon_svg?ae(y.param.icon_svg):null;if(C){let L=h.createElement("span");L.className="magicx-aia-segment-icon",L.setAttribute("contenteditable","false"),L.setAttribute("aria-hidden","true"),L.innerHTML=C,b.appendChild(L),y.param.icon&&(b.dataset.aiaIcon=y.param.icon)}if(b.appendChild(h.createTextNode(y.value)),l){let L=h.createElement("span");L.className="magicx-aia-segment-remove",L.setAttribute("contenteditable","false"),L.setAttribute("aria-hidden","true"),L.dataset.aiaChipRemove=y.param.id,L.innerHTML='<svg viewBox="0 0 10 10" aria-hidden="true"><path d="M2.5 2.5l5 5M7.5 2.5l-5 5"/></svg>',b.appendChild(L)}E.appendChild(b)}else if(y.type==="identified"){let b=h.createElement("strong");b.dataset.seg="identified",b.dataset.paramId=y.param.id;let x=["magicx-aia-segment","magicx-aia-segment--completed"];y.param.id===o&&x.push("magicx-aia-segment--editing"),b.className=x.join(" "),b.style.letterSpacing=ja(y.value.length),b.textContent=y.value,E.appendChild(b)}else E.appendChild(h.createTextNode(y.value));e.replaceChildren(E),e.dataset.aiaTextLength=String(S),g!=null?F(e,Math.max(0,Math.min(g,S))):p&&F(e,S)}var Ad='<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 Qa(t=_()){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=Ad.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function Xa(t){let e=t.store.get();return(!!e.text||e.completedParams.length>0)&&!!t.onSubmit}function Ja(t){if(!t.onSubmit)return;t.endTypedWord?.();let e=t.store.get();t.onSubmit(ye(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields}))&&t.afterSubmit?.()}function Id(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function Za(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 es(t,e){let{listboxId:n}=e,i=pn(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",Id()?"plaintext-only":"true"),a.setAttribute("role","combobox"),a.setAttribute("aria-autocomplete","list"),a.setAttribute("aria-haspopup","listbox"),a.setAttribute("aria-controls",n),a.setAttribute("aria-expanded","false"),a.setAttribute("spellcheck","true"),a.setAttribute("enterkeyhint","send"),r.appendChild(a);let s=document.createElement("span");s.className="magicx-aia-pill-list-container",s.setAttribute("data-aia-pill-list-container",""),r.appendChild(s);let l=null,d=null;e.submitButton===void 0?(l=Qa(e.strings),o.appendChild(l),d=l):e.submitButton!==null&&(d=e.submitButton,d.hasAttribute("data-aia-submit")||d.setAttribute("data-aia-submit",""),d.setAttribute("data-aia-submit-slot",""),o.appendChild(d));let c=new AbortController,{signal:u}=c,f=!1,m=0,p=()=>{let b=Ot(a),v=b.length>0&&b[0]!==b[0].toUpperCase()?b[0].toUpperCase()+b.slice(1):b;e.handleChange(v)},g=()=>{let b=de(a)?.node??null;if(!b||!a.contains(b))return null;let P=(b.nodeType===Node.ELEMENT_NODE?b:b.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return P&&ur(a,P)?null:P};o.addEventListener("click",b=>{b.target?.closest("[data-aia-pill]")||a.getRootNode().activeElement?.closest("[data-aia-location]")||a.focus()},{signal:u});let h=null,E=()=>{let b=e.showChipRemove??!1;b!==(h!==null)&&(h?.(),h=b?io(a,x=>e.removeParam(x)):null)};if(E(),u.addEventListener("abort",()=>{h?.(),h=null}),a.addEventListener("input",()=>{f||(m=performance.now(),p(),e.handleCaretAfterInput(z(a)))},{signal:u}),R(a).addEventListener("selectionchange",()=>{let b=de(a);if(!b||!a.contains(b.node))return;let x=b.collapsed?g():null,v=e.store.get(),P=v.editingParam?.id??v.editingIdentified?.id??null;if(x&&x!==P){e.startEditingParam(x);return}performance.now()-m<50||e.handleCaretMove(z(a))},{signal:u}),a.addEventListener("click",b=>{let x=Vn(a,b.target);x&&(e.startEditingParam(x),Un(a,x))},{signal:u}),a.addEventListener("compositionstart",()=>{f=!0,a.setAttribute("data-aia-composing","true")},{signal:u}),a.addEventListener("compositionend",()=>{f=!1,a.removeAttribute("data-aia-composing"),p()},{signal:u}),a.addEventListener("beforeinput",b=>{let x=b,v=x.inputType;if(v==="insertParagraph"||v==="insertLineBreak"||v==="insertFromDrop"){b.preventDefault();return}if(v.startsWith("insert")||v.startsWith("delete")){let P=v.startsWith("delete")?"":x.data??"";e.replaceEditingRange(P)&&b.preventDefault()}},{signal:u}),a.addEventListener("paste",b=>{b.preventDefault();let x=(b.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!x)return;let v=R(a),P=Se(a);if(!P||!a.contains(P.startContainer))return;P.deleteContents();let T=v.createTextNode(x);P.insertNode(T),P.setStartAfter(T),Xe(a,P.startContainer,P.startOffset),p()},{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}),d&&d.addEventListener("click",b=>{Xa(e)&&(b.stopPropagation(),Ja(e))},{signal:u}),e.autoFocus!==!1){a.focus();let b=de(a);(!b||!a.contains(b.node))&&Xe(a,a,0)}if(typeof ResizeObserver<"u"){let b=new ResizeObserver(()=>Za(a,s));b.observe(a),c.signal.addEventListener("abort",()=>b.disconnect(),{once:!0})}let y=oo(r);return c.signal.addEventListener("abort",y,{once:!0}),{input:a,inlinePillContainer:s,dropdown:i,submitButton:l,abort:c,syncChipRemove:E}}function po(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:a}=t,{pillPlacement:s,setActivePill:l,selectOption:d,store:c}=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 E=n.strings??_();a.getAttribute("aria-label")!==E.submit&&a.setAttribute("aria-label",E.submit);let S=a.querySelector("svg");S&&S.getAttribute("aria-label")!==E.submit&&S.setAttribute("aria-label",E.submit);let y=!!e.text||e.completedParams.length>0;a.disabled=!y,a.toggleAttribute("data-aia-ready",y&&e.isReady)}let f=i.dataset.newParamId??"",m=e.newParamId!==null&&e.newParamId!==f;if(mo({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"?[]:uo(e.actionableSuggestions),showChipRemove:n.showChipRemove??!1}),s==="inline"){let E=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,S=Ln(e.actionableSuggestions);E||S.length>0?nn(o,S,0,l,!1,E,e.isActivePillSelected):Vi(o)}else Vi(o);Za(i,o),m?(i.focus(),F(i,e.caretOffset??e.text.length)):e.isFocused&&Ot(i)!==e.text&&F(i,e.text.length);let p=e.editingParam?{parameter:e.editingParam.suggestionParameter,text:e.editingParam.suggestionPlaceholder,required:!0,options:e.editingParam.options}:e.editingIdentified?{parameter:e.editingIdentified.parameter,text:ie(e.editingIdentified.parameter),required:!0,options:[]}:null,g=e.dropdownSuggestion??p??e.actionableSuggestions[0],h=it(e);fn(r,{strings:n.strings,suggestions:g?[{...g,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.multiSelectView,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:d,onHighlight:(E,S)=>{S!==void 0&&c.get().activeDropdownIndex!==S||c.set({activeDropdownIndex:E})},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:E=>c.set({isFocused:E}),onSeeAllResults:n.seeAllResults&&e.text.trim().length>0&&Xa(n)?()=>Ja(n):void 0})}function fo(t){let e=t,n=new Set,i=[],o=!1;return{get:()=>e,set:r=>{let a=typeof r=="function"?r(e):r,s=e;if(e={...e,...a},i.push([e,s]),!o){o=!0;try{let l=0;for(let d=i.shift();d;d=i.shift()){if(++l>1e4)throw i.length=0,new Error("createStore: notifications did not settle after 10000 deliveries \u2014 a listener is likely calling set() on every notification");let[c,u]=d;for(let f of n)f(c,u)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function ts(t,e){let n,i,o=r=>(r!==n&&(n=r,i=e(r)),i);return{get:()=>{let r=t.get();return{...r,...o(r)}},set:r=>{typeof r=="function"?t.set(a=>{let s={...a,...o(a)};return r(s)}):t.set(r)},peek:r=>{let a={...t.get(),...r};return{...a,...e(a)}},subscribe:r=>t.subscribe((a,s)=>{let l={...s,...o(s)},d={...a,...o(a)};r(d,l)})}}var go=new WeakSet,ns=new WeakMap;function os(t){return t.nodeType===Node.DOCUMENT_NODE}function Od(t){return os(t)?t:t.ownerDocument}function Md(t){let e=ns.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(as),ns.set(t,i),i)}catch{return null}}function is(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=as,e.appendChild(n)}function rs(t){if(typeof document>"u")return;let e=t??document;if(go.has(e))return;let n=Od(e);if(os(e)){let r=e.head??e.documentElement;if(!r)return;is(n,r),go.add(e);return}let i=Md(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):is(n,e),go.add(e)}var as=`.aia-stack {
1
+ function k(t){return t==="date"||t==="date-range"}function H(t){return t!=="options"}function te(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 ut=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 Ts="https://api.ai-autocomplete.com",j=`${Ts}/api/suggest`,mt=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),Po=new WeakMap;function $e(t){return t?.type==="accessToken"}function vs(t){if(!(!t||$e(t)))return t}function pt(t){let e=Po.get(t.getAccessToken);return e||(e=new ut(t),Po.set(t.getAccessToken,e)),e}function ft(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function gt(t){let e=vs(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var Ln="aiaPlace",ht=2,Co=250,wo=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(" ")),Lo=new Set("city beach springs falls island park heights valley bay".split(" ")),Es=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 Ao(t){let e=Ps(t);for(;e.length>0&&Es.has(e[0].toLowerCase().replace(/[.,]+$/,""));)e.shift();return e.join(" ")}function Ps(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&&wo.has(r(o))&&Lo.has(r(n))?[o,i,n]:i&&(wo.has(r(i))||Lo.has(r(n)))?[i,n]:[n]}function Io(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function wn(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function Cn(t,e){let n=wn(e);if(!n)return!1;if(wn(t.name)===n)return!0;for(let[,i]of t.name.matchAll(/\(([^()]*)\)/g))if(wn(i)===n)return!0;return!1}function Oo(t,e){let n=e.metadata?.[Ln];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(Cn(i,s))return t.length-a}return 0}function An(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:Io(t),is_tappable:!0,kind:null,metadata:{[Ln]:{id:t.id,name:t.name}}}}function In(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??j,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 Mo(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 Ge(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var ko="skipped";function qe(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:ko,kind:null}));return i.length>0?[...t,...i]:t}var ws="0.72.2",Do="1.0",Ro=!1;function Ls(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function se(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function Cs(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function As(t,e,n,i,o,r,a,s,l,d,c,u,f){let m=e.find(h=>h.parameter==="contact"&&h.metadata?.contact_account_count)?.metadata?.contact_account_count,p=typeof m=="number"?m:void 0,g=Cs();return{data:{raw_query:t,accepts_traditional_autocomplete:!0,client_option_parameters:f??[],completed_params:qe(e.map(h=>Ls(h,n)),l??[]),...a&&a.length>0&&{identified_params:Ge(a)},...s&&s.length>0&&{recently_suggested:s},...p!=null&&{contact_account_count:p},...d!==void 0&&{additional_context:d}},meta:{request_id:o,request_at:new Date().toISOString(),language:se(c),...g&&{timezone:g},...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:ws,session_id:i,source:r,schema_version:Do}}}async function _o(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function Ho(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=As(t,e,o,n.sessionId,n.requestId??crypto.randomUUID(),n.source,n.identifiedParams,n.recentlySuggested,n.skippedParams,n.additionalContext,n.language,n.currency,n.clientOptionParameters),a=i?.endpoint??j,s=await No(a,JSON.stringify(r),i,n.signal);if(!s.ok)throw new Error(`API error: ${s.status} ${s.statusText}`);return s.json()}async function No(t,e,n,i){let o=ft(n);if($e(n)){let a=pt(n),s=await a.getToken(),l=await _o(t,o,s,e,i);if(l.status===401){let d=await a.getToken(!0);l=await _o(t,o,d,e,i)}return l}let r=gt(n);return!r&&!Ro&&(Ro=!0,console.warn("[AIAutocomplete] No apiKey in apiConfig. Requests will be sent without an Authorization header.")),r&&(o.Authorization=r),fetch(t,{method:"POST",headers:o,body:e,signal:i})}var Ke=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function Fo(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:se(n.language)}),o=await No(t,i,n.apiConfig,n.signal);if(!o.ok)throw new Ke(o.status);return Mo(await o.json())}var bt=/[\p{L}\p{N}]/u,Is=/['\u2019-]/;function Wo(t,e,n){let i=t[e];if(i===void 0)return!1;if(bt.test(i))return!0;let o=t[e+n];return Is.test(i)&&o!==void 0&&bt.test(o)}function Os(t,e,n){let i=e+n.length;return!(bt.test(n[0])&&Wo(t,e-1,-1)||bt.test(n[n.length-1])&&Wo(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(Os(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 c=`{{${s.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,u=m=>ne(n,s.text,m,p=>!r.some(g=>p<g.end&&p+s.text.length>g.start)),f=u(a);if(f===-1&&(f=u(0)),f!==-1){n=n.slice(0,f)+c+n.slice(f+s.text.length);let m=c.length-s.text.length;for(let p of r)p.start>=f+s.text.length&&(p.start+=m,p.end+=m);r.push({start:f,end:f+c.length}),a=f>=a?f+c.length:a+m}o.push({...s,placeholder:c})}return{rawQuery:n,completedParams:o}}function le(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function we(t,e){return e===!1?"":t}function yt(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function ze(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 Bo(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 Vo(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function Ms(t,e){let n=Vo(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function be(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?Vo(i).trimStart():"";if(o)return t.filter(a=>!a.is_tappable||Ms(a.text,o));let r=i.toLowerCase();return t.filter(a=>!a.is_tappable||a.text.toLowerCase().includes(r))}function St(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=ze(e,n,i),a=St(t,r);if(a||!o||!r.trim())return a;if(r===e.slice(n))return null;let s=e.lastIndexOf(" ",n-1)+1;return St(t,e.slice(s))}function Uo(t,e){let n=e.replace(/^\s+/,"").toLowerCase();for(let i=0;i<n.length;){let o=n.slice(i);if(o.trim().length>=2){let a=t.findIndex(s=>s.is_tappable&&s.text.toLowerCase().startsWith(o));if(a>=0)return t.map((s,l)=>l===a?{...s,liveMatch:!0}:s)}let r=n.indexOf(" ",i);if(r<0)break;i=r+1}return t}function Go(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function qo(t,e){let{icon:n,icon_svg:i}=e;return!i||t.every($o)?t:t.map(o=>$o(o)?o:{...o,icon:n,icon_svg:i})}function $o(t){return!!(t.icon_svg||t.image_url)}function ks(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=ks(t);return e.length>0?e.join(" "):t}function Y(t,e){return t.parameter||e}function Ye(t){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:ie(t)}}function xt(t,e){let n=Y(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?Ye(n):{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 Ko(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function Tt(t){return A(t)||t?.smart_suggestion===!0}function On(t){return t.some(A)?t.filter(e=>!A(e)):t}function Mn(t,e){return t.some(n=>A(n)&&!n.text)?t.map(n=>A(n)&&!n.text?{...n,text:e}:n):t}var kn='<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 Rn(t){return t.some(e=>!A(e))}function zo(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 jo(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 Yo(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 Qo(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 vt(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 Se(t,e){let{located:n}=vt(t,e);return n.length>0?n[n.length-1].end:0}function Xo(t,e,n){let i=[],o=[],r=0;for(let a of n){let s=ne(t,a.text,r,l=>!e.some(d=>l<d.end&&l+a.text.length>d.start));if(s===-1){o.push(a);continue}i.push({start:s,end:s+a.text.length,param:a}),r=s+a.text.length}return{located:i,missing:o}}function Et(t,e,n=[]){let i=vt(t,e).located,o=[];for(let c of i){let u=o[o.length-1];c.param.group&&u?.param.group===c.param.group?(u.end=c.end,u.params?.push(c.param)):o.push({...c,...c.param.group?{params:[c.param]}:{}})}let r=Xo(t,o,n).located,a=[...o.map(c=>({start:c.start,end:c.end,segment:{type:"completed",value:t.slice(c.start,c.end),param:c.param,...c.params?{params:c.params}:{}}})),...r.map(c=>({start:c.start,end:c.end,segment:{type:"identified",value:c.param.text,param:c.param}}))].sort((c,u)=>c.start-u.start),s=[],l=0;for(let c of a)c.start>l&&s.push({type:"text",value:t.slice(l,c.start)}),s.push(c.segment),l=c.end;let d=t.slice(l);return d&&s.push({type:"text",value:d}),s}function Jo(t,e){let{located:n,missing:i}=vt(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 Qe(t,e,n){let i=vt(t,e).located,{located:o,missing:r}=Xo(t,i,n);return{valid:o.map(a=>a.param),invalid:r}}function Zo(t,e,n){let i=e?.endpoint??j,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${Rs(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,a)=>{let s=mt.get(a);return s?`https://${s}`:r})}function Rs(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 er(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 _s(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var Ds=100,Hs=300,Ns=2,Pt=class{constructor(e,n,i,o,r,a,s,l,d,c={}){this.store=e;this.getApiConfig=n;this.getOptionOverrides=i;this.getMaskCompletedText=o;this.getOnError=r;this.getSessionId=a;this.getSource=s;this.getAdditionalContext=l;this.getLanguage=d;this.callbacks=c;this.fetchVersion=0;this.abortController=null;this.debounceTimer=null;this.slowDebounceTimer=null;this.unsubscribe=null;this.phraseExactMatch=!1}start(){this.doFetch("",[]);let e=this.store.get().text,n=this.store.get().completedParams;this.unsubscribe=this.store.subscribe(i=>{(i.text!==e||i.completedParams!==n)&&(e=i.text,n=i.completedParams,this.scheduleFetch())})}isPhraseExactMatch(){return this.phraseExactMatch}dispose(){this.abortController?.abort(),this.clearTimers(),this.unsubscribe?.()}async doFetch(e,n){this.abortController?.abort();let i=new AbortController;this.abortController=i;let o=++this.fetchVersion,r=this.store.get().text.length,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=s.pendingSpan?Yo(s.pendingSpan.snapshot,s.actionableSuggestions):void 0,d=crypto.randomUUID(),c=e===""&&n.length===0&&s.skippedParams.length===0&&s.identifiedParams.length===0?this.startingStateUrl():void 0,u=c?await er(fetch(c,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let f=u??await Ho(e,n,{sessionId:this.getSessionId(),requestId:d,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:i.signal,apiConfig:this.getApiConfig(),identifiedParams:s.identifiedParams,recentlySuggested:l,skippedParams:s.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})});if(o!==this.fetchVersion)return;this.phraseExactMatch=f.meta?.phrase_exact_match===!0;let m=(f.data.suggestions??[]).find(A),p=m?[]:f.data.input??[],g=w=>({id:crypto.randomUUID(),parameter:w.parameter,text:w.text,...w.type?{type:w.type}:{},...w.iso_date?{isoDate:w.iso_date}:{},...w.iso_date_end?{isoDateEnd:w.iso_date_end}:{}}),h=p.filter(w=>w.source==="identified");this.callbacks.waitIdentified?.(h.filter(w=>w.state==="need_confirmation").map(g),a);let E=h.filter(w=>w.state!=="need_confirmation").map(g),y=this.callbacks.isWordOpen?.()??!1,S=this.store.get().text.toLowerCase(),b=w=>y&&S.endsWith(w.text.toLowerCase()),x=E.filter(w=>!b(w));y&&this.callbacks.holdIdentified?.(E.filter(b));let v=m?[m]:Go(f.data.suggestions??[],this.getOptionOverrides()),P=p,T=P[P.length-1],L=this.store.get().text,C,O;if(T?.state==="in_progress"){O=!0;let w=L.toLowerCase().lastIndexOf(T.text.toLowerCase());C=w!==-1?w:r}else O=!1,C=r;let I=v.filter(w=>w.parameter!=="placeholder")[0],$=null;if(I&&!A(I)&&!y&&I.type?.kind!=="multi_select"&&!H(te(I))){let w=je(I.options,L,C,O,this.phraseExactMatch);w&&($={id:crypto.randomUUID(),placeholder:"",parameter:Y(w,I.parameter),text:w.text,value:w.value,kind:w.kind,suggestionParameter:I.parameter,suggestionValueType:I.type,suggestionPlaceholder:I.text,suggestionIcon:I.icon,suggestionIconSvg:I.icon_svg,options:I.options??[],metadata:w.metadata,icon:w.icon,icon_svg:w.icon_svg,image_url:w.image_url},v=v.filter(Z=>Z!==I),this.callbacks.onAutoMatch?.({active:I,matched:w,rawQuery:e}))}let fe=f.data.custom_fields??null,J=this.callbacks.productsForResponse?.(fe);this.store.set(w=>{let Z=$?[...w.completedParams,$]:w.completedParams,We=new Set,ge=Qe(w.text,Z,x).valid.map(D=>{let he=w.identifiedParams.find(Be=>!We.has(Be.id)&&Be.parameter===D.parameter&&Be.text===D.text);return he?(We.add(he.id),{...D,id:he.id}):D}),ct=new Set(s.skippedParams.map(D=>D.id)),dt=new Set(w.skippedParams.filter(D=>!ct.has(D.id)).map(D=>D.parameter));return{suggestions:dt.size>0?v.filter(D=>D.parameter==="placeholder"||!dt.has(D.parameter)):v,isLoading:!1,isReady:f.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:C,filterInProgress:O,identifiedParams:ge,customFields:fe,traditionalAutocomplete:f.meta?.traditional_autocomplete===!0,...J!==void 0?{products:J}:{},...$?{completedParams:Z}:{}}}),this.callbacks.onResponse?.({requestId:d,funnelTelemetry:f.meta?.funnel_telemetry===!0,visibleImpression:f.meta?.visible_impression===!0})}catch(s){let l=_s(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?Zo(e,this.getApiConfig(),se(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(Ns)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},Ds),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),Hs)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;let a=we(o.suggestions.filter(v=>v.parameter==="placeholder").map(v=>v.text).join(" "),this.callbacks.getPrependPlaceholder?.()),s=le(o.text,o.filterBase,a),l=ze(o.text,s,o.filterInProgress),d=o.suggestions.filter(v=>v.parameter!=="placeholder"),c=A(d[0])?void 0:d[0],u=H(o.activeFormatType),f=c&&!u?be(c.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&f.length>0)return!1;let m=f.filter(v=>v.is_tappable),p=c&&!u&&!this.callbacks.isWordOpen?.()?je(c.options,o.text,s,o.filterInProgress,this.phraseExactMatch)!==null:!1,g=l.trim().length>0,h=i&&o.products.length>0;if(m.length>0&&!p&&g&&!h||yt(o.text,o.completedParams.length,a))return!1;let{rawQuery:E,completedParams:y}=N(o.text,o.completedParams),S=E.length<o.lastRawQuery.length,b=Math.abs(E.length-o.lastRawQuery.length),x=n&&E!==o.lastRawQuery;return S||b>=e||x?(this.doFetch(E,y),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var Fs="(hover: none) and (pointer: coarse)";var Ws="[data-aia-dropdown], [data-aia-input-wrapper]",Bs=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),wt=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(Bs)),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(Fs):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(Ws))return!0;return!1}};var Le=["January","February","March","April","May","June","July","August","September","October","November","December"],Lt=["S","M","T","W","T","F","S"],ir=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ct="aiaDate",or="aiaDay",tr=t=>String(t).padStart(2,"0");function F(t){return`${t.getFullYear()}-${tr(t.getMonth()+1)}-${tr(t.getDate())}`}function _n(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Vs(t){let e=_n(t).getTime()-_n(new Date).getTime();return Math.round(e/864e5)}function rr(t){let e=Vs(t);return e>=0&&e<7?ir[t.getDay()]:Ce(t)}function Ce(t){return t.getFullYear()===new Date().getFullYear()?`${Le[t.getMonth()]} ${t.getDate()}`:`${Le[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function At(t){if(!t)return null;let e=ir.findIndex(s=>s.toLowerCase()===t.trim().toLowerCase());if(e>=0){let s=_n(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=Le.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 Dn(t){return`${Le[t.month]} ${t.year}`}function Hn(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function ar(t){return{year:t.getFullYear(),month:t.getMonth()}}function Nn(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function nr(){return{text:"",is_tappable:!1,kind:null}}function Fn(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(nr());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:rr(r),is_tappable:!0,kind:null,metadata:{[Ct]:F(r),[or]:o}})}for(;i.length%Lt.length!==0;)i.push(nr());return i}function Xe(t){let e=At(t);return e?F(e):null}function K(t){let e=t?.metadata?.[Ct];return typeof e=="string"?e:null}function Wn(t){let e=t?.metadata?.[or];return typeof e=="number"?e:null}function Us(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function ce(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&Us(e)?e:t.ownerDocument??t}function It(t){return ce(t).activeElement??null}function R(t){return t.ownerDocument??t}function $s(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function sr(t){let e=ce(t);return!$s(e)||typeof e.getSelection=="function"?null:e}function lr(t){let e=sr(t);if(!e)return null;let n=R(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function cr(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 Je(t){let n=ce(t).getSelection?.();return n||(R(t).getSelection?.()??null)}function de(t){let e=Je(t);if(!e||e.rangeCount===0)return null;let n=lr(t);if(n){let i=cr(e,n);return i?{node:i.startContainer,offset:i.startOffset,collapsed:i.startContainer===i.endContainer&&i.startOffset===i.endOffset}:null}return e.anchorNode?{node:e.anchorNode,offset:e.anchorOffset,collapsed:e.isCollapsed}:null}function ye(t){let e=Je(t);if(!e||e.rangeCount===0)return null;let n=lr(t);if(!n)return e.getRangeAt(0);let i=cr(e,n);if(!i)return null;let o=R(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function Ze(t,e,n){let i=Je(t);if(!i)return null;if(sr(t))return i.collapse(e,n),i;let o=R(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function Ot(t,e){let n=t?ce(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var Mt=2,Gs="magicx-aia";function dr(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function qs(t){let e=R(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&&dr(a.overflowX)||r&&dr(a.overflowY))return i}if(i.classList.contains(Gs))return null;i=i.parentElement}return null}function Bn(t){let e=ye(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=qs(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+Mt:i.left<r&&(n.scrollLeft-=r-i.left+Mt)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,a=r+n.clientHeight;i.bottom>a?n.scrollTop+=i.bottom-a+Mt:i.top<r&&(n.scrollTop-=r-i.top+Mt)}}var mr='[contenteditable="false"]',Un="strong[data-param-id]",Ae;function Ks(){if(Ae!==void 0)return Ae;let t=globalThis.Intl.Segmenter;if(!t)return Ae=null,null;try{Ae=new t(void 0,{granularity:"grapheme"})}catch{Ae=null}return Ae??null}function kt(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(mr))return!0;n=n.parentNode}return!1}function Rt(t){return R(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return kt(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function _t(t){let e=Rt(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function $n(t){let e=Rt(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function z(t){let e=de(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(kt(o,t)&&o!==t)return null;let r=0;for(let a=0;a<i&&a<o.childNodes.length;a++)r+=Gn(o.childNodes[a],t);return r+Vn(o,t)}return n.nodeType!==Node.TEXT_NODE||kt(n,t)?null:Vn(n,t)+i}function Gn(t,e){if(t.nodeType===Node.TEXT_NODE)return kt(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(mr))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=Gn(o,e);return i}function Vn(t,e){let n=Rt(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 W(t,e){let n=R(t),i=Math.max(0,Math.min(e,$n(t))),o=Rt(t),r=0,a=null,s=0,l=o.nextNode(),d=null;for(;l;){let u=l.data.length;if(i<r+u){a=l,s=i-r;break}if(i===r+u){let f=o.nextNode();f?(a=f,s=0):(a=l,s=u);break}r+=u,d=l,l=o.nextNode()}let c=n.createRange();if(a){let u=a.parentElement?.closest('strong[data-seg="completed"]');u&&u!==t&&t.contains(u)?s===0?c.setStartBefore(u):s===a.data.length?c.setStartAfter(u):c.setStart(a,s):c.setStart(a,s)}else d?c.setStart(d,d.data.length):c.setStart(t,0);c.collapse(!0),Ze(t,c.startContainer,c.startOffset)&&(zs(t,c,i),Bn(t))}function ur(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(Un)??null;return i&&e.contains(i)?i:null}function zs(t,e,n){let i=ur(de(t)?.node??null,t);if(i&&i!==ur(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function pr(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=z(t);return i!==null&&n===`${i}:${e}`}function fr(t){return ce(t).activeElement===t}function qn(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(Un);if(!o||!t.contains(o))return null;let r=de(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function Kn(t,e){let n=null;for(let a of t.querySelectorAll(Un))if(a.dataset.paramId===e){n=a;break}if(!n)return;let i=Vn(n,t),o=i+Gn(n,t),r=z(t);r!=null&&r>=i&&r<=o||W(t,i)}function zn(t){let e=z(t);return e==null?!1:e>=$n(t)}function jn(t,e){if(e<=0)return 0;let n=Ks();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 gr="aiaTime",Qn=5;var Xn=[12,1,2,3,4,5,6,7,8,9,10,11],Jn=Array.from({length:60/5},(t,e)=>e*5),Zn=["AM","PM"];function Oe(t){return(Math.round(t)%1440+1440)%1440}function ei(t){let e=Oe(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function Dt(t){let e=t.hour%12+(t.period==="PM"?12:0);return Oe(e*60+t.minute)}function Ht(t){let{hour:e,minute:n,period:i}=ei(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function hr(t){let e=Oe(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function Ie(t){return Oe(Math.round(t/5)*5)}function br(t,e){return Oe(t+e)}var js=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,Ys=/^(\d{1,2}):(\d{2})$/;function Yn(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=js.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:Dt({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=Ys.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 Sr(t){let e=Yn(t.editingText);if(e!=null)return Ie(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>Yn(o.text)).filter(o=>o!=null);if(n.length>0)return Ie(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return Oe((i.getHours()+1)*60)}function ti(t){return{text:Ht(t),is_tappable:!0,kind:null,metadata:{[gr]:hr(t)}}}var Nt=30,Ft=["hour","minute","period"],ni={hour:Xn.map(t=>({label:String(t)})),minute:Jn.map(t=>({label:String(t).padStart(2,"0")})),period:Zn.map(t=>({label:t}))};function ii(t){return ni[t]}function Wt(t,e){let n=ei(Ie(e));return t==="hour"?Xn.indexOf(n.hour):t==="minute"?Jn.indexOf(n.minute):Zn.indexOf(n.period)}function Bt(t,e,n){let i=ni[t],o=Math.min(Math.max(n,0),i.length-1),r=ei(Ie(e));return Dt(t==="hour"?{...r,hour:Xn[o]}:t==="minute"?{...r,minute:Jn[o]}:{...r,period:Zn[o]})}function oi(t,e){let n=ni[t].length-1;return Math.min(Math.max(Math.round(e/Nt),0),n)}function xe(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=N(t,e);return{query:t.trim(),raw_query:o,completed_params:qe(r,n),identified_params:Ge(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function Vt(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")?zn(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function ri(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?z(t):null}var Ut=class{constructor(e,n){this.store=e;this.ctx=n}handleKeyDown(e){if(e.isComposing||e.keyCode===229)return;let n=this.store.get(),{listboxId:i,getOnSubmit:o}=this.ctx,r=e.target instanceof Node?e.target:null,a=this.getEffectiveColumns(r),s=o(),l=this.getTappableIndices(a);if((e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)&&(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight"))return;let d=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let c=n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&c?.is_tappable){e.preventDefault(),this.ctx.selectOption(c);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&c?.is_tappable&&this.ctx.selectOption(c),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let c=Vt(e.target,n),u=!!n.editingParam;if(!c&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(d)break;e.preventDefault();let p=k(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(k(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 f=l.indexOf(n.activeDropdownIndex),m=f<l.length-1?f+1:0;this.store.set({activeDropdownIndex:l[m]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!d)break;let f=Vt(e.target,n),m=!!n.editingParam;if(!f&&!m)break;e.preventDefault();let p=k(n.activeFormatType)?this.dateEntryIndex(n,!0):this.firstTappableInBottomRow(a)??l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:p});break}if(l.length===0)return;this.store.set({activeDropdownIndex:p});break}if(l.length===0)break;if(e.preventDefault(),k(n.activeFormatType)){this.stepDateWeek(n,-7);break}if(n.activeDropdownIndex<a){this.store.set({activeDropdownIndex:-1});break}let c=l.indexOf(n.activeDropdownIndex),u=c>0?c-1:l.length-1;this.store.set({activeDropdownIndex:l[u]});break}case"ArrowRight":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%a<a-1){let f=n.activeDropdownIndex+1;f<n.filteredOptions.length&&n.filteredOptions[f]?.is_tappable&&this.store.set({activeDropdownIndex:f})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,f=n.editingTail;this.ctx.exitEditMode?.(),W(u,f);break}Vt(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,-1);break}if(n.activeDropdownIndex%a>0){let c=n.activeDropdownIndex-1;c>=0&&n.filteredOptions[c]?.is_tappable&&this.store.set({activeDropdownIndex:c});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let c=ri(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingAnchor!=null){e.preventDefault();let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingAnchor;this.ctx.exitEditMode?.(),W(c,u);break}if(this.ctx.startEditingParamAtCaret){let c=ri(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let c=ri(e.target);if(c==null)break;this.ctx.removeParamAtCaret(c)&&e.preventDefault();break}case"Enter":{if(e.preventDefault(),n.activeDropdownIndex>=0&&n.filteredOptions[n.activeDropdownIndex]?.is_tappable)this.clickOrSelect(n.activeDropdownIndex,n.filteredOptions,i,r);else if(s){this.ctx.endTypedWord?.(!0);let c=this.store.get();s(xe(c.text,c.completedParams,c.skippedParams,{identifiedParams:c.identifiedParams,isReady:c.isReady,customFields:c.customFields}))&&this.ctx.afterSubmit?.()}break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let c=n.filteredOptions.map((m,p)=>m.is_tappable?p:-1).filter(m=>m!==-1);if(c.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let m=e.shiftKey?c[c.length-1]:c[0];this.store.set({pillTapped:!0,activeDropdownIndex:m});break}e.preventDefault();let u=c.indexOf(n.activeDropdownIndex);if(!e.shiftKey&&!k(n.activeFormatType)&&!n.multiSelectView){let m=c[Math.max(u,0)];this.clickOrSelect(m,n.filteredOptions,i,r);break}let f;if(u<0)f=e.shiftKey?c.length-1:0;else{let m=e.shiftKey?-1:1;f=(u+m+c.length)%c.length}this.store.set({activeDropdownIndex:c[f]});break}case"Escape":{if(n.dateRangeStart){this.store.set({pendingRangeStart:null});break}if(n.editingIdentified){this.ctx.exitEditingIdentified?.(),this.store.set({activeDropdownIndex:-1});break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingTail;this.ctx.exitEditMode?.(),W(c,u)}this.store.set({activeDropdownIndex:-1});break}}}handleTimeWheelKey(e,n){let i=n.timeView;if(n.activeFormatType!=="time"||!i||!n.isDropdownOpen)return!1;switch(e.key){case"ArrowDown":case"ArrowUp":return!Vt(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=>K(s)===e.dateFloor);if(a>=0)return a}let i=F(new Date),o=e.filteredOptions.findIndex(a=>K(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=Ot(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=Ot(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=Ot(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var $t=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(H(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||Qs(a))return;this.logOnce(a),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=qo(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(d=>d===e.suggestion?s:d),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 Qs(t){return t instanceof Error&&t.name==="AbortError"}var Gt=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(d=>d.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(A(o))return;let r=i.filter((d,c)=>c!==e),a=n.suggestions.filter(d=>d.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:d}=N(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:d,selectedPill:o.text,otherPills:r.map(c=>c.text)})}let s=[...a,o,...r],l=this.store.peek({suggestions:s}).filteredOptions.findIndex(d=>d.is_tappable);this.store.set({suggestions:s,pillTapped:!0,activeDropdownIndex:l})}removeLastParam(){this.store.get().completedParams.length!==0&&this.store.set(n=>({completedParams:n.completedParams.slice(0,-1),activeDropdownIndex:-1}))}};var Tr="/products/",yr="https://relative.invalid";function Xs(t){if(!t)return;let e;try{e=new URL(t,`${yr}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===yr?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function vr(t,e){let n=Xs(t.item_url)??Zs(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:xr(t.price,t.currency,e)},...Js(t)&&{compareAtPrice:xr(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function Js(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 xr(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 Zs(t){if(!t.handle)return;let e=`${Tr}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function ai(t,e){return(t?.items.matched??[]).map(n=>vr(n,e))}var qt=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=ai(e,se(this.getLanguage())),i=this.getMapper();if(!i)return n;try{let o=i(n,e?.items.matched??[]);if(Array.isArray(o))return o}catch(o){this.hasLoggedMapperError||(this.hasLoggedMapperError=!0,console.warn("[AIAutocomplete] mapProducts failed. The original cards are shown.",o))}return n}async run(e,n,i){if(!this.isEnabled())return;let o=this.getConfig();if(!o)return;if(e.trim().length===0){this.clear(i);return}let r=()=>n.aborted||!i()||!this.owns(o);try{let a=await o.fetch(e,n);if(r())return;let s=o.transform(a),l=Array.isArray(s)?s:[],d=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(d)}catch(a){if(n.aborted||el(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 el(t){return t instanceof Error&&t.name==="AbortError"}function tl(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function Er(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:Le.findIndex(n=>n.toLowerCase().startsWith(e))}function nl(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 il=/^(?:(?:on|from) )?(?:the )?(\d{1,2})(?:st|nd|rd|th)$/;function si(t){let e=il.exec(t.trim().toLowerCase().replace(/\s+/g," "));if(!e)return null;let n=Number(e[1]);return n>=1&&n<=31?n:null}function ol(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 Pr(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function Me(t,e={}){if(!t)return null;let n=e.today??new Date,i=si(t);if(i!==null){let d=ol(i,n);return d?F(d):null}let o=tl(t.trim().toLowerCase()).replace(/\s+/g," "),r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o);if(r){let d=Pr(Number(r[1]),Number(r[2])-1,Number(r[3]));return d?F(d):null}let a=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(o);if(a){let d=Er(a[1]);if(d>=0)return Kt(d,Number(a[2]),a[3],n)}let s=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(o);if(s){let d=Er(s[2]);if(d>=0)return Kt(d,Number(s[1]),s[3],n)}let l=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(o);if(l){let d=Number(l[1]),c=Number(l[2]);return d>12&&c<=12?Kt(c-1,d,l[3],n):c>12&&d<=12?Kt(d-1,c,l[3],n):null}return null}function Kt(t,e,n,i){if(n){if(n.length!==4)return null;let r=Pr(Number(n),t,e);return r?F(r):null}let o=nl(t,e,i);return o?F(o):null}var rl=/^\d{4}-\d{2}-\d{2}$/;function et(t){return typeof t=="string"&&rl.test(t)?t:null}function li(t,e={}){return et(t.isoDate)??Me(t.text,e)}function tt(t){let e=et(t.isoDate);return e?{start:e,end:et(t.isoDateEnd)}:null}var wr=" - ",ui="aiaDateRangeStart",mi="aiaDateRangeEnd";function nt(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var ci=/^\d{4}-\d{2}-\d{2}$/;function di(t){if(!ci.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 al=/\s+(?:to|through|thru|until|til|till)\s+/g,sl=/[-–—]/g;function ll(t){let e=[];for(let n of[al,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 zt(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of ll(t.trim())){let a=Me(o.trim(),e);if(!a)continue;let s=si(r)!==null?Me(r.trim(),{...e,today:di(a)??e.today}):Me(r.trim(),e);!s||s<a||(n.add(`${a}|${s}`),i={start:a,end:s})}return n.size===1?i:null}function Lr(t){let e=di(t.start),n=di(t.end);return!e||!n?"":t.start===t.end?Ce(e):`${Ce(e)}${wr}${Ce(n)}`}function Cr(t,e){let n=nt(t,e);return{text:Lr(n),is_tappable:!0,kind:null,metadata:{[ui]:n.start,[mi]:n.end}}}function ke(t,e={}){let n=t?.metadata?.[ui],i=t?.metadata?.[mi];return typeof n=="string"&&typeof i=="string"&&ci.test(n)&&ci.test(i)?nt(n,i):zt(t?.text,e)}var jt="(max-width: 768px)";var cl="var(--aia-option-row-height, 25.9px)",dl="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function Ar(t,e){return e?pi(1,Math.min(t,5)):pi(1,Math.min(t,4))}function pi(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${cl} + ${dl})`}}function gi(t,e){return!e&&t>=5}function hi(t,e,n,i){if(!(!e&&t>=5&&ul(n,i))){let a=Ar(t,e);return{...a,template:fi(a.cols),scrollHintIndices:!e&&t>a.rows?[a.rows-1]:[]}}let r=6;return{...pi(2,3),template:fi(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function ul(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 it(t){if(typeof document>"u")return null;let e=Array.from(t.querySelectorAll("[data-aia-option]"));if(e.length===0)return null;let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:-9999px;top:0;";for(let a of e){let s=a.cloneNode(!0);s.removeAttribute("id"),s.removeAttribute("role"),s.removeAttribute("aria-selected"),s.style.whiteSpace="nowrap",s.style.width="max-content",n.appendChild(s)}t.appendChild(n);let i=Array.from(n.children).map(a=>a.offsetWidth);n.remove();let o=getComputedStyle(t),r=t.clientWidth-(Number.parseFloat(o.paddingLeft)||0)-(Number.parseFloat(o.paddingRight)||0)-(Number.parseFloat(o.columnGap)||0);return{rowWidths:i,gridWidth:r}}function fi(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function ot(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(jt).matches}function bi(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}function Ir(t,e){let n=e.dropdownTrigger??"auto",i=e.closeDropdownOnBlur??!0,a=t.filteredOptionsLength>0||t.activePillHasNoOptions||t.hasProducts;if(t.inEditMode){let s=i?t.isFocused||t.dropdownHeld:!0;return a&&s}if(n==="auto"){let s=i?t.isFocused||t.dropdownHeld:!0,l=t.text.replace(/\s+$/,"").length,d=t.caretOffset==null||t.caretOffset>=l;return(a||t.isLoading)&&s&&d}return n==="manual"?(a||t.isLoading)&&t.pillTapped:!1}function 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 Yt(t){if(!t)return Hn();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function ml(t){let e=At(t);return e?ar(e):Hn()}function pl(t,e){if(!t)return null;for(let n of e){if(n.parameter!==t||n.type?.kind!=="date_range")continue;let i=tt(n);if(i&&i.end==null)return i.start}return null}function fl(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(et(i.metadata?.[Ct])??Xe(i.text)),o==="date_range"){let r=ke(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=tt(i);n(r?.start),n(r?.end)}return[...e].sort()}function Si(t,e){return t.editingParam!=null&&t.editingAnchor!=null?e:t.text.slice(Se(t.text,t.completedParams))}function Or(t,e){let n=Et(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(M=>M.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(M=>M.parameter==="placeholder").map(M=>M.text).join(" "),a=we(r,e.prependPlaceholder),s=le(t.text,Math.min(t.filterBase,t.text.length),a),d=s===0&&yt(t.text,t.completedParams.length,a)?"":ze(t.text,s,t.filterInProgress),c=o?.options??[],u=t.editingParam!=null&&t.editingAnchor!=null,f=!u&&!t.editingIdentified&&o?.type?.kind==="multi_select",m,p,g,h;if(u&&t.editingParam&&t.editingAnchor!=null){let M=t.editingParam.id,G=t.completedParams.some(Ue=>Ue.id===M),Ve=t.caretOffset??t.editingAnchor,ee=G?"":t.text.slice(t.editingAnchor,Ve);p=ee.trim(),g=t.editingParam.options,h=t.editingParam.suggestionParameter,m=be(t.editingParam.options,ee)}else p=d.trim(),g=c,h=o?.parameter,m=A(o)?c.map(M=>({...M,matchedText:t.text.slice(Se(t.text,t.completedParams)),parameterLabel:Ko(M.parameter)})):be(c,d,t.traditionalAutocomplete);let E=t.optionSearch,y=E!=null&&h!=null&&E.parameter===h;y&&E.status==="done"&&E.query===p&&(m=g);let S=y&&E.status==="loading",b=e.showNonTappableOptions===!1;b&&(m=m.filter(M=>M.is_tappable));let x=Si(t,p),v=u?t.editingParam?.suggestionValueType?.kind==="traditional_autocomplete":A(o);!f&&!v&&(m=Uo(m,x));let P=t.editingIdentified,T=u?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,L=P?P.format:te(T),C=u?t.editingParam?.suggestionParameter:o?.parameter,O=L==="location"&&C&&e.optionOverrides?.[C]?"options":L,X=u&&O==="date-range"?ke(t.editingParam):null,I=!u&&!P&&O==="date"?pl(o?.parameter,t.identifiedParams):null,$=null,fe=null,J=k(O)?fl(t):[];if(k(O)){let M=F(new Date),G=J.find(xs=>xs>=M)??null,Ve=B({...t,actionableSuggestions:i}),ee=t.dateViewMonth;$=ee&&ee.key===Ve?{year:ee.year,month:ee.month}:P?Yt(P.iso):X?Yt(X.start):I?Yt(I):G&&!u?Yt(G):ml(t.editingParam?.text),m=Fn($);let Ue=t.pendingRangeStart;O==="date-range"&&Ue&&Ue.key===Ve&&(fe=Ue.iso)}let w=null;if(O==="time"){let M=B({...t,actionableSuggestions:i}),G=t.timeDraft;w=G&&G.key===M?{minutes:G.minutes,touched:!0}:{minutes:Sr({editingText:u?t.editingParam?.text:null,options:u?t.editingParam?.options:o?.options}),touched:!1},m=[]}let Z=null;if(O==="location"){let M=B({...t,actionableSuggestions:i}),G=t.locationSearch;if(G&&G.key===M){let{key:Ve,...ee}=G;Z=ee}else Z={query:u?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};m=[]}let We=M=>b?M.is_tappable:!0,ge;if(u){let M=t.editingParam?.options??[];ge=t.editingParam!=null&&M.filter(We).length===0}else ge=o!=null&&c.filter(We).length===0;w&&(ge=!0),Z&&(ge=!0);let ct=Ir({inEditMode:u||P!=null,filteredOptionsLength:m.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||S,pillTapped:t.pillTapped,activePillHasNoOptions:ge,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),dt=ct&&t.activeDropdownIndex>=0&&!!m[t.activeDropdownIndex]?.is_tappable,Pn=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,D=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||S||Pn,he=D&&t.skeletonOptions!==null,Be=he&&t.skeletonOptions?t.skeletonOptions:m,Ss=he?t.skeletonSuggestion:null,Eo=f?{picked:t.multiSelectDraft?.key===B({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,ys=Eo??(he&&t.skeletonSuggestion?.type?.kind==="multi_select"?{picked:t.skeletonPicked??[]}:null);return{segments:n,actionableSuggestions:i,filteredOptions:m,dropdownLoading:D,dropdownOptions:Be,dropdownSuggestion:Ss,skeletonExiting:Pn,activeFormatType:O,dateView:$,dateRangeStart:fe,dateFloor:I,dateReferences:J,timeView:w,multiSelectView:Eo,dropdownMultiSelect:ys,locationView:Z,placeholderText:r,leadInText:a,optionQuery:p,isSearchingOptions:S,isDropdownOpen:ct,isActivePillSelected:dt}}function Qt(t){return t.mode!=="edit"?hl(t):bl(t)}function gl(t,e,n){let i=t.find(A);if(!i?.options)return null;let o=e.slice(Se(e,n)).trim().toLowerCase();if(!o)return null;let r=i.options.filter(l=>l.is_tappable&&l.text.trim().toLowerCase()===o);if(new Set(r.map(l=>Y(l,i.parameter))).size!==1)return null;let s=r[0];return{suggestion:i,option:s,matchText:s.text.trim()}}function Mr(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,a=n.find(c=>c.parameter!=="placeholder"&&!A(c));if(!a?.options||a.type?.kind==="multi_select")return null;let s=n.filter(c=>c.parameter==="placeholder").map(c=>c.text).join(" "),l=le(e,i,we(s,t.prependPlaceholder)),d=je(a.options,e,l,o,r===!0);return d?{suggestion:a,option:d,matchText:d.text}:null}function hl(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?Mr(t):null)??gl(i,e,n):Mr(t);if(!o)return null;let{suggestion:r,option:a,matchText:s}=o,l=s.toLowerCase(),d=e.toLowerCase().lastIndexOf(l),c=d>=0?d:Math.max(0,e.length-a.text.length),u=c+s.length,f=e.slice(c,u),p=u<e.length&&e[u]===" "?u+1:u,g={id:crypto.randomUUID(),placeholder:"",parameter:Y(a,r.parameter),text:f,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)?Ye(Y(a,r.parameter)):{},options:r.options??[],metadata:a.metadata,icon:a.icon,icon_svg:a.icon_svg,image_url:a.image_url};return{patch:{text:e,completedParams:[...n,g],suggestions:i.filter(h=>h!==r),filterBase:p,newParamId:g.id,caretOffset:p,activeDropdownIndex:-1},caretPos:p,option:a,suggestion:r}}function bl(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(S=>S.id===i.id))return null;let a=e.slice(o,r),s=St(i.options,a);if(!s)return null;let l=s.text.toLowerCase(),d=a.toLowerCase().lastIndexOf(l),c=o+Math.max(0,d),u=c+s.text.length,f=e.slice(c,u),m=u<e.length&&e[u]===" "?u+1:u,p=e.length,g={id:crypto.randomUUID(),placeholder:"",...xt(i,s),text:f,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,E=0;for(let S=0;S<n.length;S++){let b=ne(e,n[S].text,E);if(b!==-1){if(b>=m){h=S;break}E=b+n[S].text.length}}let y=[...n];return y.splice(h,0,g),{patch:{text:e,completedParams:y,newParamId:g.id,filterBase:p,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:p,activeDropdownIndex:-1},caretPos:p,option:s}}function kr(t){return t.slice(t.search(/\S*$/))}function Rr(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function _r(t,e){let n="",i=0;for(let o of t){if(n+=Rr(o),i+=o.length,n.length>=e.length)return n.startsWith(e)?i+(t.slice(i).match(/^\p{M}*/u)?.[0].length??0):0;if(!e.startsWith(n))return 0}return 0}function yi(t){return[...t].map(Rr).join("")}function Xt(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(yi),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:yi(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,f)=>i[s+f].folded===u))continue;let d=i[s+o-1],c=_r(d.text,a);if(c>0)return{typedWords:o,start:i[s].index,end:d.index+c}}}return null}function xi(t,e){let n=e?Xt(t,e):null;if(n&&n.typedWords>1)return[{text:t.slice(0,n.start),bold:!1},{text:t.slice(n.start,n.end),bold:!0},{text:t.slice(n.end),bold:!1}].filter(a=>a.text!=="");let i=e?kr(e):"",o=yi(i);if(!o)return[{text:t,bold:!1}];let r=[];for(let a of t.split(/(\s+)/)){if(a==="")continue;let s=/^\s/.test(a)?0:_r(a,o);s>0&&r.push({text:a.slice(0,s),bold:!0});let l=s>0?a.slice(s):a;l&&r.push({text:l,bold:!1})}return r}var Sl=6e4;function yl(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function xl(t){return(t??j).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function Tl(t){return $e(t)?`Bearer ${await pt(t).getToken()}`:gt(t)}async function Dr(t){try{let e=xl(t.apiConfig?.endpoint),n=ft(t.apiConfig),i=await Tl(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&&yl(o)<=Sl&&{keepalive:!0}})}catch{}}function ue(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var Ti=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function vl(t,e,n){let i=Ti(t??"");if(i.length===0)return"";let r=Ti(e).slice(-i.length),a=Ti(n).slice(0,i.length);return r.join(" ")===i.join(" ")||a.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function Hr(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:Y(e,n.parameter),a=i?t.text.length:t.filterBase,s=t.text.slice(0,a),l=s.length===0&&t.text.length===0,d=s.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||d)&&t.placeholderText&&(s=`${t.placeholderText} `);let c=Math.min(Se(t.text,t.completedParams),s.length),u=!1;if(i){let T=[...s.slice(c).matchAll(/\S+/g)],L=Xt(e.text,s.slice(c)),C=T[T.length-(L?.typedWords??1)];s=s.slice(0,C?c+(C.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word===!0){let T=[...s.slice(c).matchAll(/\S+/g)],L=T[T.length-1];s=s.slice(0,L?c+(L.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word!==!1){let T=s.slice(c),L=Math.max(Bo(T,e.text),Oo(T,e));L>0&&(s=s.slice(0,s.length-L)),u=L>0}let f=s.length>0&&s[s.length-1]!==" ",m=i||n.completes_word===!0||u,p=t.activeFormatType!==void 0&&!H(t.activeFormatType)&&H(te({type:n.type})),g=m||p?"":vl(n.lead_in,s,e.text),h=`${s}${f?" ":""}${g?`${g} `:""}${e.text} `,y=(l||d||i&&s.length===0)&&h.length>0?h[0].toUpperCase()+h.slice(1):h,S=y.toLowerCase().lastIndexOf(e.text.toLowerCase()),b=S>=0?y.slice(S,S+e.text.length):e.text,x=i?Ye(r):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text,suggestionIcon:n.icon,suggestionIconSvg:n.icon_svg},v={id:crypto.randomUUID(),placeholder:"",...x,text:b,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},P=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(T=>T.text!==e.text).map(T=>T.text),key:i?r:n.parameter,position:ue(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:P}}function rt(t,e){let n=H(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,i=t.editingParam,o=i?{parameter:i.suggestionParameter,text:i.suggestionPlaceholder,required:!0,options:i.options}:t.actionableSuggestions[0]??null;return{skeletonOptions:n,skeletonSuggestion:n?o:null,skeletonPicked:n?e??null:null,skeletonRequested:!1}}function Jt(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 Zt=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===""?Jt(n.text,o,r):{text:n.text.slice(0,o)+e+n.text.slice(r)},s=o+e.length;return this.deps.store.set(l=>({text:a,completedParams:l.completedParams.filter(d=>d.id!==i.id),editingTail:s,caretOffset:s,activeDropdownIndex:-1})),this.deps.scheduleSetCursor(s),this.promoteIfExact(),!0}caretAfterInput(e){let n=this.deps.store.get(),i={caretOffset:e};n.editingParam&&n.editingAnchor!=null&&e!=null&&(e<n.editingAnchor?(i.editingParam=null,i.editingAnchor=null,i.editingTail=null,i.activeDropdownIndex=-1):n.editingTail!=null&&(i.editingTail=Math.max(n.editingTail,e))),this.deps.store.set(i),this.promoteIfExact()}caretMove(e){let n=this.deps.store.get();if(n.editingParam&&n.editingAnchor!=null&&n.editingTail!=null&&e!=null&&(e<n.editingAnchor||e>n.editingTail)){this.deps.store.set({caretOffset:e,editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1});return}this.deps.store.set({caretOffset:e})}selectOption(e){let n=this.deps.store.get(),i=n.editingParam,o=n.editingAnchor,r=n.editingTail;if(!i||o==null||r==null)return;let a=xt(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:ue(i.options,e.text),chip_origin:"tap"});let s=n.text.slice(0,o),l=n.text.slice(r),d=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,u=l.length===0||l[0]!==" "?`${d} `:d,f=s+u+l,m=f.length,p={id:crypto.randomUUID(),placeholder:"",...a,text:d,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},g=n.completedParams.findIndex(y=>y.id===i.id),h=n.completedParams.filter(y=>y.id!==i.id),E=g>=0?Math.min(g,h.length):h.length;h.splice(E,0,p),this.deps.store.set({text:f,completedParams:h,newParamId:p.id,filterBase:m,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:m,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...rt(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=Qt({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 El=33,Pl=70,wl=120,Ll=50,Re="data-aia-placeholder-leaving",_e=new WeakMap;function en(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function Cl(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Fr(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function Wr(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Fr(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(()=>Wr(t,e),33+i)}function Nr(t,e){Fr(t,e,0),e.timer=setTimeout(()=>Wr(t,e),33)}function Br(t,e){let n=_e.get(t);if(e===""){n&&(en(n),_e.delete(t)),t.removeAttribute(Re),delete t.dataset.placeholder;return}if(n?.target===e)return;if(Cl(t)){n&&en(n),t.removeAttribute(Re),_e.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&&en(n),_e.set(t,i),o){t.setAttribute(Re,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(Re),t.isConnected&&Nr(t,i)},170);return}t.removeAttribute(Re),Nr(t,i)}function Vr(t){let e=_e.get(t);e&&(en(e),_e.delete(t))}var Al={selectedIso:null,selectedRange:null,rangeStart:null};function at(t){if(!k(t.activeFormatType))return Al;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?nt(i,o):null,rangeStart:t.dateRangeStart,references:t.dateReferences??[]}}let n=ke(t.editingParam);return{selectedIso:n?null:Xe(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart??t.dateFloor??null,floor:t.dateFloor??null,references:t.dateReferences??[]}}function vi(t){let e=t.floor!=null&&t.highlightedIso!=null&&t.highlightedIso<t.floor?null:t.highlightedIso;return t.pendingStart?nt(t.pendingStart,e??t.pendingStart):t.selected}function Ei(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 Pi(t,e,n){return t==null?!1:t<e||n!=null&&t<n}function wi(t,e){return t==="date"?e??null:null}var Ur="https://ai-autocomplete.com";function Li(t=Ur){try{if(typeof window>"u"||!window.location)return t;let e=window.location.hostname;if(!e)return t;let n=new URL(t);return n.searchParams.set("utm_source",e),n.toString()}catch{return t}}var $r={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Best match",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",seeAllResults:"See all results",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",timeLabel:"Time",locationSearch:"Say a location",locationNoResults:"No places found",locationUseTyped:"Press Enter to use what you typed"},Il={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",timeLabel:"Hora",locationSearch:"Di una ubicaci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},Ci={en:$r,es:Il,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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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"}},Ol={pt:"pt-BR",no:"nb",nn:"nb"};function _(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return Ci[o?"zh-TW":"zh-CN"]}let i=Ol[e]??e;return Object.prototype.hasOwnProperty.call(Ci,i)?Ci[i]:$r}function Ai(t,e,n=_()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function Ii(t){let e=a=>{a.ctrlKey||Gr(a.target,t,a.deltaX,a.deltaY)||a.preventDefault()},n=0,i=0,o=a=>{let s=a.touches[0];s&&(n=s.clientX,i=s.clientY)},r=a=>{if(a.touches.length!==1)return;let s=a.touches[0],l=n-s.clientX,d=i-s.clientY;n=s.clientX,i=s.clientY,a.cancelable&&!Gr(a.target,t,l,d)&&a.preventDefault()};return t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("touchstart",o,{passive:!0}),t.addEventListener("touchmove",r,{passive:!1}),()=>{t.removeEventListener("wheel",e),t.removeEventListener("touchstart",o),t.removeEventListener("touchmove",r)}}function Gr(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&Ml(o,i)||n!==0&&kl(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var qr=/^(auto|scroll|overlay)$/;function Ml(t,e){return t.scrollHeight<=t.clientHeight||!qr.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function kl(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!qr.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 Kr=new WeakMap,zr=new WeakSet;function V(t,e,n){if(Kr.set(t,n),zr.has(t))return;zr.add(t);let i=()=>Kr.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 me(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function q(t){t.offsetWidth}var pe="magicx-aia-panel-ghost";function De(t){return t.closest(`.${pe}`)!==null}function U(t,e){for(let n of t.querySelectorAll(e))if(!De(n))return n;return null}var Oi="--aia-multi-done-fit";function Rl(t){return U(t,"[data-aia-multi-done]")}function Mi(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(De(a))continue;let s=n.defaultView?.getComputedStyle(a),l=Number.parseFloat(i?s?.paddingRight??"0":s?.paddingLeft??"0")||0,d=n.createTreeWalker(a,NodeFilter.SHOW_TEXT),c=n.createRange();for(let u=d.nextNode();u;u=d.nextNode()){if(!u.textContent?.trim())continue;c.selectNodeContents(u);let f=c.getBoundingClientRect();if(f.width===0)continue;let m=i?o.right-f.left:f.right-o.left;r=Math.max(r,m+l)}}r>0?e.style.setProperty(Oi,`${Math.ceil(r)}px`):e.style.removeProperty(Oi)}var ki="data-aia-hug",tn="--aia-panel-fit-width",_l=36;function nn(t){t.removeAttribute(ki)}function Ri(t,e,{eligible:n,loading:i}){if(!n){t.style.removeProperty(tn);return}if(i){t.style.getPropertyValue(tn)&&t.setAttribute(ki,"");return}let o=Dl(t,e);if(o==null){t.style.removeProperty(tn);return}t.style.setProperty(tn,`${o}px`),t.setAttribute(ki,"")}var jr=new WeakMap;function Dl(t,e){if(ot())return null;let n=U(e,".aia-grid");if(!n||t.offsetWidth===0)return null;let i=U(e,"[data-aia-pillbar]"),o=[n.style.gridTemplateColumns,i?.textContent??"",...Array.from(n.querySelectorAll("[data-aia-option]"),s=>s.textContent)].join("\0"),r=jr.get(t);if(r?.key===o)return r.width;let a=Hl(t,e,n);return jr.set(t,{key:o,width:a}),a}function Hl(t,e,n){let i=it(n);if(!i||i.rowWidths.some(s=>s<=0))return null;let o=Math.ceil(Math.max(...i.rowWidths)),r=Math.max(1,_i(n.style.gridTemplateColumns)),a=Yr(n,t,r-1)+r*(o+_l);return Math.ceil(Math.max(a,Nl(e,t)))}function Nl(t,e){let n=U(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:Yr(n,e,i>0&&o>0?1:0)+i+o}function _i(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 Yr(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 Fl="[data-aia-products], [data-aia-datepicker], [data-aia-date-grid], [data-aia-time-wheel], [data-aia-location]";function Wl(t){let e=!t.hasAttribute("data-aia-has-products")&&U(t,".aia-grid [data-aia-option]")!==null&&U(t,Fl)===null,n=U(t,".aia-grid [data-aia-option][data-aia-loading]")!==null;e||nn(t),Ri(t,t,{eligible:e,loading:n})}var Bl=40,Vl=340,Ul=340,$l=7,Di="--aia-option-enter-delay";function Hi(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 Ni(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 Xr="magicx-aia-scroll-arrow",on="data-aia-scroll-arrow",He="data-aia-visible",Jr=1e3,Zr=160,ea="--aia-scroll-arrow-bottom",Gl="Scroll down for more options",Fi="data-aia-scrollable",ql="--aia-scroll-track-top",Kl="--aia-scroll-track-height",zl="--aia-scroll-track-right",jl="--aia-scroll-thumb-top",Yl="--aia-scroll-thumb-height",Ql=12,Xl=.5,Jl="[data-aia-products-label]",Qr=4,Zl=8,ec=240;function tc(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,a=t.ownerDocument?.visibilityState==="hidden";if(!r||a||Wi(t)){t.scrollTop=o+e,i();return}let s=n.performance?.now?.()??Date.now(),l=()=>n.performance?.now?.()??Date.now(),d=()=>{let c=Math.min(1,(l()-s)/ec),u=1-(1-c)*(1-c);t.scrollTop=o+e*u,c<1?r.call(n,d):i()};r.call(n,d)}function nc(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 ta(t=document,e=_()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=Xr,n.setAttribute(on,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(nc(t)),n}function ic(t){return Math.max(1,_i(t.style.gridTemplateColumns))}function Wi(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Bi({dropdown:t,grid:e,button:n}){let i=e.ownerDocument?.defaultView??(typeof window<"u"?window:null),o=!1;n.disabled=!0;let r=null,a=null,s=null,l=null,d=v=>{if(v){if(n.hasAttribute(He))return;if(n.setAttribute(He,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),Wi(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(He)&&(n.disabled=!1)},Jr)}else n.removeAttribute(He),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},c=v=>{let P=0,T=v;for(;T&&T!==t;)P+=T.offsetTop,T=T.offsetParent instanceof HTMLElement?T.offsetParent:null;return P},u=()=>{let v=U(t,Jl),P;if(v){let T=c(v)+v.offsetHeight/2;P=t.clientHeight-T-n.offsetHeight/2}else{let T=c(e),L=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;P=t.clientHeight-(T+e.offsetHeight)+(L>0?0:Zl)}n.style.setProperty(ea,`${Math.max(0,Math.round(P))}px`)},f=v=>{let P=0,T=v;for(;T&&T!==t;)P+=T.offsetLeft,T=T.offsetParent instanceof HTMLElement?T.offsetParent:null;return P},m=null,p=(v,P)=>{let T=Math.min(1,Math.max(0,e.scrollTop/v));n.style.setProperty(jl,`${Math.round(P*T)}px`)},g=()=>{let v=e.scrollHeight-e.clientHeight,P=e.querySelector("[data-aia-option][data-aia-loading]")!==null;if(v<=Qr||P){m=null,n.removeAttribute(Fi);return}let T=e.clientHeight,L=Math.round(T*Xl),C=c(e)+(T-L)/2,O=t.clientWidth-(f(e)+e.offsetWidth),X=Math.min(L,Math.max(Ql,Math.round(L*T/e.scrollHeight)));m={overflow:v,travel:L-X},n.style.setProperty(ql,`${Math.round(C)}px`),n.style.setProperty(Kl,`${L}px`),n.style.setProperty(zl,`${Math.max(0,Math.round(O))}px`),n.style.setProperty(Yl,`${X}px`),p(v,m.travel),n.setAttribute(Fi,"")},h=()=>{if(o||a!==null||s!==null)return;let v=e.querySelector("[data-aia-option][data-aia-loading]")!==null,P=e.scrollHeight-e.clientHeight-e.scrollTop;d(!v&&P>Qr)},E=()=>{if(o)return;u(),g();let v=e.getAttribute("data-aia-group")??"";if(v!==r){r=v,d(!1),a!==null&&clearTimeout(a);let P=e.querySelectorAll("[data-aia-option]").length,T=Wi(e)?0:Ni(P,ic(e));a=setTimeout(()=>{a=null,h()},T);return}h()},y=()=>{o||(m&&p(m.overflow,m.travel),a===null&&(d(!1),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,h()},Zr)))};e.addEventListener("scroll",y,{passive:!0});let S=v=>v.preventDefault(),b=()=>{let v=i?(Number.parseFloat(i.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0):0,P=Math.max(1,e.clientHeight-v);tc(e,P,i,y)};n.addEventListener("mousedown",S),n.addEventListener("click",b);let x=null;return i&&typeof i.ResizeObserver=="function"&&(x=new i.ResizeObserver(()=>{u(),g(),h()}),x.observe(e)),E(),{update:E,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",S),n.removeEventListener("click",b),x?.disconnect(),n.removeAttribute(He),n.removeAttribute(Fi),n.setAttribute("aria-hidden","true"))}}}var na="cubic-bezier(0.25, 0.1, 0.25, 1)",oc="cubic-bezier(0.32, 0.72, 0, 1)",ia=360,oa=280,ra=320,aa=40,sa="blur(2px)",rc=160,ac=.05,sc=/pressed/i;function la(){return typeof performance<"u"?performance.now():Date.now()}function lc(t){for(let e of t.querySelectorAll("[data-aia-loading]"))if(!e.closest(`.${pe}`))return!0;return!1}function cc(t){return t===null?1:1-Math.min(1,Math.max(0,(la()-t)/rc))**1.7}function ca(t){return t.hasAttribute(on)}var oe=new WeakMap;function dc(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 uc(t,e){let n=0,i="";for(let o of Array.from(t.children))o.classList.contains(pe)||(n+=1+o.getElementsByTagName("*").length,i+=`${o.textContent??""}\0`);return`${e??""}${n}${i}`}function mc(t){let e=t.ownerDocument.createElement("div");e.className=pe,e.setAttribute("aria-hidden","true"),e.inert=!0;for(let n of Array.from(t.children))n.classList.contains(pe)||ca(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 pc(t,e,n,i){for(let r of Array.from(t.children))r.classList.contains(pe)&&r.remove();let o=Array.from(t.children).filter(r=>!ca(r));i>ac&&fc(t,e,n,i);for(let r of o)r.animate([{opacity:0,filter:sa},{opacity:1,filter:"blur(0px)"}],{duration:ra,delay:aa,easing:na,fill:"backwards"})}function fc(t,e,n,i){let o=(t.ownerDocument.defaultView??window).getComputedStyle(t);e.style.cssText=["position:absolute","left:0","right:0",n?"bottom:0":"top:0",`padding:${o.padding}`,"pointer-events:none","box-sizing:border-box"].join(";"),t.appendChild(e),e.animate([{opacity:i,filter:"blur(0px)"},{opacity:0,filter:sa}],{duration:oa*i,easing:na,fill:"forwards"}).finished.then(()=>e.remove(),()=>e.remove())}function Vi(t){let e=t[0]?.text;return e==null||e===""?null:e}function rn(t,e,n){let i=n.visible,o=dc(t,n.enabled??!0),r=oe.get(t);if(!i||!o){o||r?.glide?.cancel(),oe.set(t,{height:0,key:i?e:null,signature:"",snapshot:null,glide:o?r?.glide??null:null,loadingSince:null});return}let a=uc(t,e),s=lc(t)?r?.loadingSince??la():null;if(r&&r.height>0&&r.glide&&r.signature===a){r.loadingSince=s;return}let l=Te(t),d=t.getBoundingClientRect().height;r?.glide?.cancel();let c=t.getBoundingClientRect().height,u=null,f=r?l?d:r.height:0;if(r&&f>0&&(e!==r.key&&r.snapshot&&pc(t,r.snapshot,n.anchorBottom??!1,cc(r.loadingSince)),Math.abs(f-c)>1)){u=t.animate([{height:`${f}px`},{height:`${c}px`}],{duration:ia,easing:oc});let p=u;u.finished.then(()=>{let g=oe.get(t);g?.glide===p&&(g.glide=null)},()=>{})}let m=null;e!==null&&(m=r&&r.signature===a&&r.snapshot&&!r.snapshot.isConnected?r.snapshot:mc(t)),oe.set(t,{height:c,key:e,signature:a,snapshot:m,glide:u,loadingSince:s})}function Te(t){let e=oe.get(t)?.glide??null;return e&&(e.playState==="running"||e.pending)?e:null}function Ui(t){if(!Te(t))return null;let e=oe.get(t)?.height??0;return e>0?e:null}function $i(t,e){let n=oe.get(t);n&&n.height>0&&!Te(t)&&e>0&&(n.height=e)}function Gi(t){oe.get(t)?.glide?.cancel(),oe.delete(t)}var da="data-aia-key";function Q(t,e,n){let i=new Map;for(let a of Array.from(t.children)){let s=a.getAttribute(da);s!=null&&i.set(s,a)}let o=new Set,r=[];for(let a=0;a<e.length;a++){let s=e[a],l=n.keyOf(s,a);o.add(l);let d=i.get(l);d||(d=n.create(s,a),d.setAttribute(da,l)),n.update?.(d,s,a),t.children[a]!==d&&t.insertBefore(d,t.children[a]??null),r.push(d)}for(let[a,s]of i)o.has(a)||s.remove();return r}function ua(t,e){if(!e.interactive)return null;let n=e.options[me(t)];return n?.is_tappable?n:null}var gc={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=ua(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")&&ua(t,e)&&e.callbacks.onHighlight(me(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,me(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=Sc(),t.appendChild(l),q(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}V(l,gc,{options:e,callbacks:a,interactive:s});let d=l.querySelector(".magicx-aia-datepicker-month");d&&(d.textContent=Dn(o));let c=l.querySelector(".magicx-aia-datepicker-grid");c&&hc(c,e,n,i,r)}function hc(t,e,n,i,o){let r=F(new Date),a=vi({pendingStart:o.rangeStart,highlightedIso:K(e[n]),selected:o.selectedRange,floor:o.floor});Q(t,e,{keyOf:(s,l)=>K(s)??`pad-${l}`,create:s=>bc(s),update:(s,l,d)=>{let c=K(l),u=Ei(c,{selectedIso:o.selectedIso,range:a,references:o.references}),f=d===n&&l.is_tappable;s.id=`${i}-option-${d}`,s.dataset.aiaIndex=String(d),s.setAttribute("aria-selected",String(f)),s.classList.toggle("magicx-aia-date-cell--past",Pi(c,r,o.floor)),s.classList.toggle("magicx-aia-date-cell--highlighted",f),s.classList.toggle("magicx-aia-date-cell--today",c!=null&&c===r),s.classList.toggle("magicx-aia-date-cell--selected",u.selected),s.classList.toggle("magicx-aia-date-cell--in-range",u.inRange),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=Wn(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 Sc(){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(ma("prev","Previous month","\u2039"),n,ma("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of Lt){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 ma(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 yc='<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>',fa="data-aia-location-body";function xc(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=yc;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 Tc(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 ga(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(fa)!==r){for(let s of Array.from(t.children))s.hasAttribute("data-aia-location-row")||s.remove();let a=Tc(r,n);a&&t.appendChild(a),t.setAttribute(fa,r)}Q(t,o,{keyOf:(a,s)=>`${s}:${a.id}`,create:a=>xc(a),update:(a,s,l)=>{let d=l===e.highlighted;a.classList.toggle("magicx-aia-location-row--highlighted",d),a.setAttribute("aria-selected",String(d)),a.setAttribute("data-aia-index",String(l)),a.id=i(l)}})}var re=new WeakMap,vc=0,ve=new WeakMap,Ec='<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>',Ee=t=>It(t.input)===t.input;function ha(t,e){let n=It(t);if(n instanceof HTMLElement&&n!==e.input&&n!==R(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=ye(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Pc(t,e,n){if(!(!(n instanceof HTMLElement)||n===e.returnTo||t.contains(n))&&n!==R(t).body&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=ye(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function wc(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=Je(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=R(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var Lc={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&Ne(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function Ne(t,e=!1){let n=ve.get(t),i=re.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&Ee(n)&&(n.returning=!0,wc(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function Cc(t){let e=ve.get(t),n=re.get(t);if(!(!e||!n||Ee(e))){if(ha(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!Ee(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function Ac(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++vc}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=Ec;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(),ha(t,r),re.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>re.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",a=>{Pc(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;Ne(t,!0),s.callbacks.onLocationCommit();return;case"Escape":a.preventDefault(),a.stopPropagation(),r.declined=!0,Ne(t);return;case"Backspace":if(i.value!=="")return;a.preventDefault(),r.declined=!0,Ne(t);return}}),ve.set(t,r),r}function ba(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=ve.get(e);n&&(Ee(n)&&Ne(e),n.declined=!1,n.input.tabIndex=-1)}}function Sa(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=ve.get(r);l&&Ee(l)&&Ne(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let a=ve.get(r)??Ac(r,n);a.input.tabIndex=0,re.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),V(a.results,Lc,re.get(r)),a.input.value!==e.query&&!Ee(a)&&(a.input.value=e.query);let s=l=>`${r?.id}-row-${l}`;if(ga(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&&!Ee(a)){let l=r;queueMicrotask(()=>{l.isConnected&&!ve.get(l)?.declined&&Cc(l)})}}else{let l=a;setTimeout(()=>{if(l.widgetFocused)return;let d=l.returnTo;d&&It(d)===d||(l.declined=!1)},0)}}var Ic={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},ya=[125,69];function xa(t,e){return e?1:t===0?.7:t===1?.4:.2}function an(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)),V(s,Ic,{onSelectPill:i,loading:r}),r&&e.length===0){s.setAttribute("data-aia-pill-list-loading",""),s.innerHTML="";for(let l=0;l<ya.length;l++){let d=ya[l],c=document.createElement("span");c.setAttribute("data-aia-pill-skeleton",""),c.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,c.style.width=`${d}px`,c.style.setProperty("--aia-pill-opacity",String(xa(l,!1))),s.appendChild(c)}return}r?s.setAttribute("data-aia-pill-list-loading",""):s.removeAttribute("data-aia-pill-list-loading");for(let l of s.querySelectorAll("[data-aia-pill-skeleton]"))l.remove();Q(s,e,{keyOf:l=>`${l.type?.kind??""}|${Tt(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let d=document.createElement("button");if(d.type="button",d.tabIndex=-1,d.setAttribute("data-aia-pill",""),d.setAttribute("contenteditable","false"),Tt(l)){d.setAttribute("data-aia-smart-suggestion",A(l)?"header":"");let c=document.createElement("span");c.className="magicx-aia-smart-suggestion-text",c.textContent=l.text;let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-sparkle",u.innerHTML=kn,d.append(c,u)}else d.textContent=l.text;return d.disabled=!0,d},update:(l,d,c)=>{let u=l,f=a&&c===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(xa(c,f))),u.dataset.aiaPillIndex=String(c),u.toggleAttribute("data-aia-pill-active",c===n),r?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),q(s);for(let l of s.querySelectorAll("[data-aia-pill]"))l.disabled=r}function qi(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var Oc=32;function Ta(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 Ki(t){let e=n=>{let i=Ta(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var va=Intl.Segmenter,Ea=va?new va(void 0,{granularity:"grapheme"}):null;function zi(t){let e=t.trim().normalize("NFC").toUpperCase();if(Ea)for(let n of Ea.segment(e))return n.segment;return Array.from(e)[0]??"?"}var ji=120,Mc=360;function kc(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 Pa(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=kc(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 Yi(t,e){let n=Pa(t,e);return n===t?[t]:[n,t]}function Qi(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 sn(t){let e=t?.trim();return e?Yi(e,360):[]}function Rc(t){return sn(t)[0]}var ln=new WeakMap,Ji=new WeakMap,La=new WeakMap;function Ca(t,e,n,i,o,r="row",a="image",s=_(),l){let d=t.querySelector(".magicx-aia-products");if(e.length===0){d?.remove();return}if(!d){d=document.createElement("section"),d.className="magicx-aia-products",d.setAttribute("data-aia-products",""),d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${n}-products-label`);let f=document.createElement("div");f.className="magicx-aia-products-label",f.id=`${n}-products-label`,f.setAttribute("data-aia-products-label",""),f.textContent=s.products;let m=document.createElement("div");m.className="magicx-aia-products-row",m.setAttribute("data-aia-products-row",""),Ki(m),d.append(f,m),t.appendChild(d)}d.setAttribute("data-aia-products-layout",r);let c=d.querySelector(".magicx-aia-products-label");c&&c.textContent!==s.products&&(c.textContent=s.products);let u=d.querySelector(".magicx-aia-products-row");if(u){Q(u,e,{keyOf:f=>Nc(f,!!l),create:f=>Fc(f,i,o,a,s,l),update:(f,m,p)=>{ln.set(f,m),_c(f,m.price,m.compareAtPrice),f.id=`${n}-product-${p}`,f.dataset.aiaIndex=String(p),La.get(f)?.(a);let g=f.querySelector(".magicx-aia-product-badge");g&&g.textContent!==s.soldOut&&(g.textContent=s.soldOut);let h=f.querySelector(".magicx-aia-product-cart");h&&h.setAttribute("aria-label",Aa(m,s))}}),q(u);for(let f of u.querySelectorAll("[data-aia-product]")){let m=Ji.get(f);m&&(Ji.delete(f),m())}}}function Zi(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)De(i)||(i.tabIndex=e?0:-1)}function _c(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 wa(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 Aa(t,e){return`${e.addToCart}: ${t.title}`}var Xi="http://www.w3.org/2000/svg";function Dc(){let t=document.createElementNS(Xi,"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(Xi,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(Xi,"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 Hc(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",Aa(e,o)),r.tabIndex=0,r.appendChild(Dc());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(ln.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 Nc(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 Fc(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=sn(t.imageUrl),d=l[0],c=!!d,u=()=>{s.replaceChildren(),s.removeAttribute("data-aia-image-loaded"),s.toggleAttribute("data-aia-product-placeholder",i==="image"),s.toggleAttribute("data-aia-product-initial",i==="initial"),i==="initial"&&(s.textContent=zi(t.title))};if(La.set(a,g=>{g!==i&&(i=g,c||u())}),d){let g=document.createElement("img"),h=0;g.onload=()=>{s.setAttribute("data-aia-image-loaded",""),wa(a,Qi(g.naturalWidth,g.naturalHeight))},g.onerror=()=>{let E=l[++h];if(E){g.src=E;return}c=!1,wa(a,null),u()},g.className="magicx-aia-product-image",g.src=d,g.alt="",g.loading="lazy",g.decoding="async",s.appendChild(g)}else u();a.appendChild(s);let f=document.createElement("span");if(f.className="magicx-aia-product-body",t.vendor){let g=document.createElement("span");g.className="magicx-aia-product-vendor",g.textContent=t.vendor,f.appendChild(g)}let m=document.createElement("span");if(m.className="magicx-aia-product-title",m.textContent=t.title,f.appendChild(m),t.available===!1){a.setAttribute("data-aia-product-sold-out","");let g=document.createElement("span");g.className="magicx-aia-product-badge",g.textContent=o.soldOut,f.appendChild(g)}a.appendChild(f);let p=r&&t.available!==!1?Hc(a,t,r,n,o):null;return p&&(a.setAttribute("data-aia-product-has-cart",""),a.appendChild(p.el)),Ji.set(a,()=>{p?.arm(),t.url&&(a.href=t.url),a.addEventListener("click",g=>{g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||g.button!==0||(g.preventDefault(),e(ln.get(a)??t))})}),a.addEventListener("keydown",g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),e(ln.get(a)??t))}),a.addEventListener("focus",()=>n(!0)),a.addEventListener("blur",g=>{g.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),a}var Wc=10,Bc=44;function eo(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 Ia="http://www.w3.org/2000/svg",Vc=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function Uc(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 $c=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],Gc=/^[a-zA-Z0-9#.,%\s()-]+$/;function qc(t){let e=[];for(let n of $c){let i=t.getAttribute(n);i===null||!Gc.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function Oa(t){for(let e of Array.from(t.attributes))Uc(e.name,e.value)&&t.removeAttribute(e.name);qc(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!Vc.has(n.localName)||n.namespaceURI!==Ia?n.remove():Oa(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!==Ia||e.getElementsByTagName("parsererror").length>0?null:(Oa(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function cn(t){return t.text}function Pe(t){return un(t)[0]??null}function un(t){let e=Kc(t);return e?Yi(e,120):[]}function Kc(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 st(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var Ma={one:"item",other:"items"};function zc(t,e=Ma){let n=st(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function ka(t){return Pe(t.image_url)!==null}var dn=new Map;function jc(t){let e=t.icon_svg;if(!e)return!1;let n=dn.get(e);return n===void 0&&(n=ae(e)!==null,dn.size>=256&&dn.clear(),dn.set(e,n)),n}function to(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&ka(i)||e&&jc(i))}var Ra=new WeakMap;function Yc(t,e,n){let i=e.length,o=ot(),r=Ra.get(t),a=n&&r&&bi(r.options,e)?r.plan:null,s=!a&&!n&&gi(i,o)?it(t):null,l=a??hi(i,o,s?.rowWidths??null,s?.gridWidth??null);return n||Ra.set(t,{options:e,plan:l}),t.style.gridTemplateColumns=l.template,t.style.setProperty("--aia-grid-max-height",l.maxHeight),t.querySelectorAll("[data-aia-option]").forEach((d,c)=>{d.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(c))}),l.cols}function _a(t,e){if(e.loading||!e.interactive)return null;let n=e.options[me(t)];return n?.is_tappable?n:null}var Qc={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=_a(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!eo(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)=>{_a(t,e)&&e.onHighlight(me(t))},onLeave:(t,e)=>e.onHighlight(-1,me(t))};function Da(t,e,n,i,o,r,a,s="",l="below",d=!0,c=!0,u=!0,f=!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)),V(p,Qc,{options:e,onSelect:i,onHighlight:o,loading:a,interactive:f});let g=p.dataset.aiaGroup!==s;p.dataset.aiaGroup=s;let h=to(e,d,c);Xc(p,e,n,r,a,{showIcons:d&&h,showImages:c&&h,showCounts:u,picked:m});let E=Yc(p,e,a);Jc(p,e.length,E,a,l),g&&(p.scrollTop=0)}function Xc(t,e,n,i,o,r){let a=o?"1":"0",s=t.dataset.aiaGroup??"",{showIcons:l,showImages:d,showCounts:c}=r,u=l?p=>p.icon??p.icon_svg??"":()=>"",f=d?p=>Pe(p.image_url)??"":()=>"",m=c?p=>st(p.item_count)??"":()=>"";Q(t,e,{keyOf:p=>`${p.text}\0${p.parameterLabel??""}\0${u(p)}\0${f(p)}\0${m(p)}\0${a}\0${s}`,create:(p,g)=>{let h=Zc(p,o,r);return o||(h.dataset.aiaEntering=""),h},update:(p,g,h)=>{if(no.get(p)!==(g.matchedText??"")){let S=p.querySelector(".magicx-aia-option-text");S&&Ha(S,g),no.set(p,g.matchedText??"")}let E=h===n&&!o;p.id=`${i}-option-${h}`,p.dataset.aiaIndex=String(h),p.setAttribute("aria-selected",String(r.picked?r.picked.includes(g.text):E));let y=p.querySelector(".magicx-aia-checkbox");r.picked&&g.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(g.text)),y.textContent=r.picked.includes(g.text)?"\u2713":""):y?.remove(),p.classList.toggle("magicx-aia-option--highlighted",E),p.classList.toggle("magicx-aia-option--live-match",!!g.liveMatch&&!o)}})}function Jc(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(Di,`${Hi(a,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var no=new WeakMap;function Ha(t,e){if(t.replaceChildren(),e.matchedText)for(let n of xi(cn(e),e.matchedText))if(n.bold){let i=document.createElement("strong");i.className="magicx-aia-option-match",i.textContent=n.text,t.appendChild(i)}else t.appendChild(document.createTextNode(n.text));else t.appendChild(document.createTextNode(cn(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 Zc(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?un(t.image_url):[],d=l[0];if(d){let m=document.createElement("span");m.className="magicx-aia-option-image",m.setAttribute("aria-hidden","true");let p=document.createElement("img");p.setAttribute("alt",""),p.setAttribute("loading","lazy"),p.setAttribute("decoding","async"),p.setAttribute("referrerpolicy","no-referrer"),p.setAttribute("draggable","false");let g=0;p.onload=()=>m.setAttribute("data-aia-image-loaded",""),p.onerror=()=>{let h=l[++g];h?p.src=h:p.hidden=!0},p.src=d,m.appendChild(p),s.appendChild(m),r.dataset.aiaImage=""}let c=!d&&n&&t.icon_svg?ae(t.icon_svg):null;if(c){let m=document.createElement("span");m.className="magicx-aia-option-icon",m.setAttribute("aria-hidden","true"),m.innerHTML=c,s.appendChild(m),t.icon&&(r.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",Ha(u,t),no.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 f=o?st(t.item_count):null;if(f!==null){let m=document.createElement("span");m.className="magicx-aia-option-count",m.textContent=f,s.appendChild(m),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(s),r}var ed=120,td={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(Bt(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},Fa=new WeakMap,Na=new WeakMap;function Wa(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=od(),t.appendChild(r),q(r);let d=r.querySelector("[data-aia-time-done]");d&&(d.disabled=!1)}let a={view:e,callbacks:i,interactive:o};Fa.set(r,a),V(r,td,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=Ht(e.minutes));for(let d of Ft){let c=r.querySelector(`[data-aia-time-column="${d}"]`);c&&nd(c,d,e.minutes)}}function nd(t,e,n){let i=Wt(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=mn(t);if(o.settle)return;let r=i*Nt;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function mn(t){let e=Na.get(t);return e||(e={syncedTop:null,settle:null},Na.set(t,e)),e}function id(t,e,n){let i=mn(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(()=>Ba(t,e,n),ed)}function Ba(t,e,n){let i=mn(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=Fa.get(t);if(!o||!o.interactive)return;let r=oi(n,e.scrollTop);r!==Wt(n,o.view.minutes)&&o.callbacks.onTimeChange(Bt(n,o.view.minutes,r))}function od(){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 Ft){if(r==="minute"){let a=document.createElement("span");a.className="magicx-aia-time-wheel-separator",a.textContent=":",n.appendChild(a)}n.appendChild(rd(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 rd(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),ii(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",()=>id(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{mn(n).settle&&Ba(t,n,e)}),n}var Fe="data-aia-fit",pn="--aia-dropdown-fit-height",Va=8,ad=160;function io({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,a=null,s=null,l=null,d=!1,c=()=>{t.removeAttribute(Fe),t.style.removeProperty(pn)},u=()=>{if(Te(t)){d=!0;return}d=!1,$i(t,t.getBoundingClientRect().height)},f=y=>`${r}|${(y??t).scrollHeight}|${t.offsetWidth}`,m=y=>s?.key===f(y)?s.height:null,p=y=>{let S=f(y);if(s?.key===S)return s.height;let b=y?.scrollTop??0;t.removeAttribute(Fe);let x=t.offsetHeight;return t.setAttribute(Fe,""),y&&b&&(y.scrollTop=b),s={key:S,height:x},x},g=()=>{if(i)return;if(!e()){o=!1;return}let y=Te(t),S=y?Ui(t):null;y&&l!==y&&(l=y,y.finished.then(h,h)),!y&&d&&u(),o||(o=!0,c());let b=t.hasAttribute(Fe),x=U(t,".aia-grid")?.getAttribute("data-aia-group")??null,v=x!==r;r=x;let P=ld(t,n);if(P===null)return;let T=sd(t);if(b){let O=y?m(T):p(T);if(O!==null&&O<=P){c(),u();return}}else if((S??t.offsetHeight)<=P)return;let L=`${Math.max(ad,Math.floor(P))}px`,C=t.style.getPropertyValue(pn)!==L;C&&t.style.setProperty(pn,L),b?v&&T&&(T.scrollTop=0):t.setAttribute(Fe,""),(C||!b)&&u()},h=()=>{i||a!==null||!n||(a=n.requestAnimationFrame(()=>{a=null,g()}))},E=n?.visualViewport??null;return E?.addEventListener("resize",h),E?.addEventListener("scroll",h),n?.addEventListener("resize",h),n?.addEventListener("scroll",h,{capture:!0,passive:!0}),g(),{update:g,destroy(){i||(i=!0,a!==null&&n?.cancelAnimationFrame(a),E?.removeEventListener("resize",h),E?.removeEventListener("scroll",h),n?.removeEventListener("resize",h),n?.removeEventListener("scroll",h,{capture:!0}))}}}function sd(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function ld(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-Va:i+o-s-Va}var cd=[159,119,164];function hn(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()),Ii(e),e}var fn=new WeakMap;function dd(t,e,n){let i=fn.get(t);if(i||(i={button:ta(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),fn.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=Bi({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var gn=new WeakMap;function Ua(t){let e=gn.get(t);if(e){e.update();return}gn.set(t,io({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function oo(t){gn.get(t)?.destroy(),gn.delete(t),Gi(t);let e=fn.get(t);e&&(e.controller?.destroy(),fn.delete(t))}function bn(t,e){let n=e.strings??_(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:a,showPills:s,isActivePillSelected:l,onSelect:d,onHighlight:c,onPillClick:u,onSkip:f}=e,m=Mn(e.pills,n.keepTyping),p=Rn(m),g=s&&m.length>0,h=i.length>0,E=e.products.length>0,y=e.formatType==="time"&&e.timeView!=null,S=e.formatType==="location"&&e.locationView!=null,b=r&&(h||g||a||E||y||S);if(b?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"),!b){Zi(t,!1),ba(t),Ua(t),rn(t,null,{visible:!1});return}E?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),nn(t),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let x=t.querySelector(".aia-stack");x||(x=document.createElement("div"),x.className="aia-stack",x.style.setProperty("--aia-stack-space","8px"),t.appendChild(x));let v=e.showSkipButton&&p&&!e.isInputEmpty,P=g||a&&s||v,T=x.querySelector(".magicx-aia-pill-bar");if(P){T||(T=document.createElement("div"),T.className="magicx-aia-pill-bar aia-cluster",T.setAttribute("data-nowrap",""),T.setAttribute("data-aia-pillbar",""),x.insertBefore(T,x.firstChild));let J=g||a&&s,w=T.querySelector(".magicx-aia-pill-scroll");J?(w||(w=document.createElement("span"),w.className="magicx-aia-pill-scroll",w.setAttribute("data-aia-pill-scroll",""),T.insertBefore(w,T.firstChild)),an(w,m,0,u,!0,a,l)):w&&w.remove(),pd(T,v,a||e.skipDisabled,m[0],f,n)}else T&&T.remove();let L=e.suggestions[0],C=L?`${L.parameter} ${L.text}`:"",O=k(e.formatType),X=O&&!a;Da(x,O?[]:i,o,d,c,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)),yd(x,!!e.multiSelectView,e.skipDisabled||a,e.onMultiSelectCommit,n.done),dd(t,x.querySelector(".aia-grid"),n),pa(x,X?i:[],o,e.listboxId,X?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart,floor:wi(e.formatType,e.dateRangeStart),references:e.dateReferences??[]},{onSelect:d,onHighlight:c,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),Wa(x,e.formatType==="time"&&!a?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),Sa(x,e.formatType==="location"&&!a?e.locationView:null,n,{onLocationQuery:e.onLocationQuery,onLocationMove:e.onLocationMove,onLocationCommit:e.onLocationCommit,onLocationFocusChange:e.onLocationFocusChange},{interactive:!e.skipDisabled,inputFocused:e.isFocused??!1,reediting:e.isReediting??!1});let I=x.querySelector(".magicx-aia-skeleton-bars");if(a&&(!h||H(e.formatType))){if(!I){I=document.createElement("div"),I.className="magicx-aia-skeleton-bars",I.setAttribute("data-aia-skeleton-bars","");for(let J of cd){let w=document.createElement("span");w.className="magicx-aia-skeleton-bar",w.style.width=`${J}px`,I.appendChild(w)}x.appendChild(I)}}else I&&I.remove();Ca(x,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart),Zi(t,!a),bd(x,e.onSeeAllResults,n.seeAllResults);let $=x.querySelector(".magicx-aia-footer")??gd(n),fe=o>=0&&!!i[o]?.is_tappable;fd($,Ai(fe,e.isInputEmpty,n)),$.isConnected||x.appendChild($),ud(x,[".magicx-aia-pill-bar",".aia-grid","[data-aia-multi-actions]",".magicx-aia-datepicker",".magicx-aia-time-wheel","[data-aia-location]",".magicx-aia-skeleton-bars",".magicx-aia-products","[data-aia-see-all]",".magicx-aia-footer"]),Mi(x,x.querySelector(".magicx-aia-multi-done")),Ri(t,x,{eligible:h&&!E&&!O&&!y&&!S,loading:a}),Ua(t),rn(t,Vi(s?m:[]),{visible:!0,anchorBottom:e.optionsPosition==="above"})}function ud(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 md={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function pd(t,e,n,i,o,r){V(t,md,{onSkip:o,loading:n});let a=t.querySelector(".magicx-aia-skip");if(!e){a?.remove();return}a||(a=document.createElement("button"),a.type="button",a.tabIndex=-1,a.className="magicx-aia-skip",a.setAttribute("data-aia-skip",""),a.textContent=r.skip,a.disabled=!0,t.appendChild(a),q(a)),a.textContent!==r.skip&&(a.textContent=r.skip),a.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),a.disabled=n}function 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 gd(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=Li(),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 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),q(r)}V(i,hd,{submit:e});let o=i.querySelector("button");o&&(o.textContent!==n&&(o.textContent=n),o.disabled=!1)}var Sd={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function yd(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),q(s)}V(r,Sd,{commit:i,disabled:n});let a=r.querySelector("button");a&&(a.textContent=o,a.disabled=n)}function $a(t,e){let n=hn(e.listboxId);return t.appendChild(n),{dropdown:n}}function ro(t,e,n){let i=at(e);bn(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 xd="[data-aia-chip-remove]";function ao(t,e){let n=e;if(!n||n.nodeType===void 0)return null;let o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(xd)??null;return o&&t.contains(o)?o:null}function so(t,e){let n=null,i=d=>{n=null;let c=d;if(c.button)return;let u=ao(t,d.target);if(!u)return;d.preventDefault(),d.stopPropagation();let f=u.dataset.aiaChipRemove,m=c.pointerType==="touch"||c.pointerType==="pen";n={id:f,x:c.clientX,y:c.clientY,pending:m},!m&&f&&e(f)},o=d=>{if(!n?.pending)return;n.pending=!1;let c=d;if(Math.hypot(c.clientX-n.x,c.clientY-n.y)>10)return;let f=t.getRootNode().elementFromPoint?.(c.clientX,c.clientY)??d.target,m=ao(t,f)?.dataset.aiaChipRemove;m&&m===n.id&&e(m)},r=()=>{n&&(n.pending=!1)},a=d=>{!n&&!ao(t,d.target)||(d.cancelable&&d.preventDefault(),d.type==="click"&&(d.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 Td=340;function lo(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let c=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let u=t.getBoundingClientRect().height;if(u!==0){if(c===0||Math.abs(u-c)<.5){t.style.height=`${u}px`;return}t.style.height=`${c}px`,t.getBoundingClientRect(),t.style.height=`${u}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(c=>{for(let f of c)if(f.target!==t){n();return}let u=t.getBoundingClientRect().width;Math.abs(u-i)<.5||(i=u,n())}):null,r=()=>{for(let c of Array.from(t.children))o?.observe(c)},a=0,s=()=>{r(),n(),e.clearTimeout(a),a=e.setTimeout(n,340)},l=new e.MutationObserver(s);l.observe(t,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["data-placeholder","data-aia-empty"]}),o?.observe(t),r(),t.addEventListener("load",s,!0);let d=!1;return t.ownerDocument.fonts?.ready.then(()=>{d||n()}),n(),()=>{d=!0,t.removeEventListener("load",s,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(a),t.style.height=""}}var za=2600,vd=3,po="data-aia-hint",mo="magicx-aia-hint",ja="data-aia-hint-el",Ed={position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--aia-hint-color, #999)",userSelect:"none"},Pd=280,wd=320,Ld=380,co="cubic-bezier(0.25, 0.1, 0.25, 1)",Ga=new Set(["a","an","the","some","my"]),xn=new WeakMap;function Cd(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function qa(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&&Ga.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,[d,...c]=n.split(/\s+/);c.length&&d&&Ga.has(d.toLowerCase())&&(l=d,n=c.join(" "));let u=l??a;u&&o.push({key:`w:${u.toLowerCase()}`,text:u,icon:null});let f=t.icon_svg?ae(t.icon_svg):null;return o.push({key:`c:${f??""}:${n}`,text:n,icon:f}),o}function Ad(t,e){let n=t.createElement("span");if(n.className=`${mo}__word`,n.dataset.key=e.key,n.style.display="inline-block",e.icon){let i=t.createElement("span");i.className=`${mo}__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 uo(t,e,n){return typeof t.animate=="function"?t.animate(e,n):null}function Sn(t,e){let n=t.ownerDocument?.defaultView;if(!n)return;let i=n.getComputedStyle(t),o=c=>Number.parseFloat(c)||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,d=Math.max(s,l);e.style.left=`${r}px`,e.style.top=`${a}px`,d>0&&(e.style.maxWidth=`${d}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 Ka(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 g=uo(p,[{opacity:1,filter:"blur(0)"},{opacity:0,filter:"blur(2px)"}],{duration:Pd,easing:co,fill:"forwards"});g?g.onfinish=()=>p.remove():p.remove()}let d=Array.from(o.children).filter(m=>m.dataset.leaving!==void 0),c=[];if(e.forEach((m,p)=>{p>0&&c.push(r.createTextNode(" ")),c.push(a.get(m.key)??Ad(r,m))}),o.replaceChildren(...c,...d),!n)return;let u=new Map;for(let m of c)m instanceof HTMLElement&&m.dataset.key&&u.set(m.dataset.key,m);let f=0;for(let m of e){let p=u.get(m.key);if(p)if(!a.has(m.key))uo(p,[{opacity:0,filter:"blur(2px)"},{opacity:1,filter:"blur(0)"}],{duration:wd,delay:i?80*f++:180+60*f++,easing:co,fill:"backwards"});else{let h=(s.get(m.key)??p.offsetLeft)-p.offsetLeft;Math.abs(h)>.5&&uo(p,[{transform:`translateX(${h}px)`},{transform:"none"}],{duration:Ld,easing:co})}}}function yn(t){let e=xn.get(t);e&&(e.timer!==null&&clearInterval(e.timer),e.resize?.disconnect(),e.el.remove(),xn.delete(t),t.removeAttribute(po),t.removeAttribute("aria-placeholder"))}function Ya(t,e,n,i){let o=i.filter(p=>p.text.trim()!=="").slice(0,vd),r=t.parentElement;if(!e||o.length<2||!r){yn(t);return}let a=`${n}\0${o.map(p=>`${p.text}${p.icon_svg??""}`).join("\0")}`,s=xn.get(t);if(s&&s.key===a&&s.el.isConnected){Sn(t,s.el);return}yn(t);let l=t.ownerDocument,d=l.createElement("span");d.className=mo,d.setAttribute(ja,""),d.setAttribute("aria-hidden","true"),Object.assign(d.style,Ed),r.insertBefore(d,t),t.setAttribute(po,""),n.trim()&&t.setAttribute("aria-placeholder",n.trim()),Sn(t,d);let c=l.defaultView,u=c?.ResizeObserver?new c.ResizeObserver(()=>{d.isConnected&&Sn(t,d)}):null;u?.observe(r);let f=Cd(t),m={key:a,lead:n,options:o,index:0,el:d,timer:null,resize:u};xn.set(t,m),Ka(m,qa(o[0],n),!f,!0),!f&&(m.timer=setInterval(()=>{if(!t.isConnected||!d.isConnected){yn(t);return}t.ownerDocument?.hidden||(m.index=(m.index+1)%m.options.length,Sn(t,d),Ka(m,qa(m.options[m.index],m.lead),!0,!1))},za))}function fo(t){yn(t)}function go(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 Id=6,Od=.3;function Qa(t){return t<=0?"0px":`${(-Math.min(Od,2*Id/t)).toFixed(3)}px`}var Xa=new Map;function Md(t,e,n){let i=Xa.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`;Xa.set(e,s),t.style.setProperty("--aia-chip-image-fit",s)},o.src=e}function ho(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,d=n.length===0;e.dataset.aiaEmpty=d?"true":"false",Br(e,d?r:""),Ya(e,d,r,t.hintOptions??[]);let c=n.map(S=>S.type==="completed"?`${S.type}:${S.value}${a?S.param.icon??S.param.icon_svg??"":""}${s?Pe(S.param.image_url)??"":""}${l?"x":""}`:S.type==="identified"?`${S.type}:${S.value}${S.param.id}${l?"x":""}`:`${S.type}:${S.value}`).join("\0"),u=e.dataset.segKey??"",f=e.dataset.newParamId??"",m=e.dataset.editingParamId??"";if(c===u&&(i??"")===f&&(o??"")===m)return;if(c===u){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let S of e.querySelectorAll("strong[data-param-id]")){let b=S.dataset.paramId,x=S.dataset.seg==="completed"&&b===i;S.classList.toggle("magicx-aia-shimmer-revealed",x),S.classList.toggle("magicx-aia-shimmer-sweep",x),S.classList.toggle("magicx-aia-segment--editing",b===o)}return}let p=fr(e),g=p?z(e):null;e.dataset.segKey=c,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let h=R(e),E=h.createDocumentFragment(),y=0;for(let S of n)if(y+=S.value.length,S.type==="completed"){let b=h.createElement("strong");b.dataset.seg="completed",b.dataset.paramId=S.param.id;let x=S.param.id===i,v=S.param.id===o,P=["magicx-aia-segment","magicx-aia-segment--completed"];x&&P.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),v&&P.push("magicx-aia-segment--editing"),b.className=P.join(" "),b.style.letterSpacing=Qa(S.value.length);let T=s?Pe(S.param.image_url):null;if(T){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("${T}")`),Md(C,T,h),b.appendChild(C),b.dataset.aiaImage=""}let L=!T&&a&&S.param.icon_svg?ae(S.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,b.appendChild(C),S.param.icon&&(b.dataset.aiaIcon=S.param.icon)}b.appendChild(h.createTextNode(S.value)),l&&b.appendChild(Ja(h,S.param.id)),E.appendChild(b)}else if(S.type==="identified"){let b=h.createElement("strong");b.dataset.seg="identified",b.dataset.paramId=S.param.id;let x=["magicx-aia-segment","magicx-aia-segment--completed"];S.param.id===o&&x.push("magicx-aia-segment--editing"),b.className=x.join(" "),b.style.letterSpacing=Qa(S.value.length),b.textContent=S.value,l&&b.appendChild(Ja(h,S.param.id)),E.appendChild(b)}else E.appendChild(h.createTextNode(S.value));e.replaceChildren(E),e.dataset.aiaTextLength=String(y),g!=null?W(e,Math.max(0,Math.min(g,y))):p&&W(e,y)}function Ja(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 kd='<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 Za(t=_()){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=kd.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function es(t){let e=t.store.get();return(!!e.text||e.completedParams.length>0)&&!!t.onSubmit}function ts(t){if(!t.onSubmit)return;t.endTypedWord?.();let e=t.store.get();t.onSubmit(xe(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields}))&&t.afterSubmit?.()}function Rd(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function ns(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 is(t,e){let{listboxId:n}=e,i=hn(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",Rd()?"plaintext-only":"true"),a.setAttribute("role","combobox"),a.setAttribute("aria-autocomplete","list"),a.setAttribute("aria-haspopup","listbox"),a.setAttribute("aria-controls",n),a.setAttribute("aria-expanded","false"),a.setAttribute("spellcheck","true"),a.setAttribute("enterkeyhint","send"),r.appendChild(a);let s=document.createElement("span");s.className="magicx-aia-pill-list-container",s.setAttribute("data-aia-pill-list-container",""),r.appendChild(s);let l=null,d=null;e.submitButton===void 0?(l=Za(e.strings),o.appendChild(l),d=l):e.submitButton!==null&&(d=e.submitButton,d.hasAttribute("data-aia-submit")||d.setAttribute("data-aia-submit",""),d.setAttribute("data-aia-submit-slot",""),o.appendChild(d));let c=new AbortController,{signal:u}=c,f=!1,m=0,p=()=>{let b=_t(a),v=b.length>0&&b[0]!==b[0].toUpperCase()?b[0].toUpperCase()+b.slice(1):b;e.handleChange(v)},g=()=>{let b=de(a)?.node??null;if(!b||!a.contains(b))return null;let P=(b.nodeType===Node.ELEMENT_NODE?b:b.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return P&&pr(a,P)?null:P};o.addEventListener("click",b=>{b.target?.closest("[data-aia-pill]")||a.getRootNode().activeElement?.closest("[data-aia-location]")||a.focus()},{signal:u});let h=null,E=()=>{let b=e.showChipRemove??!1;b!==(h!==null)&&(h?.(),h=b?so(a,x=>e.removeParam(x)):null)};if(E(),u.addEventListener("abort",()=>{h?.(),h=null}),a.addEventListener("input",()=>{f||(m=performance.now(),p(),e.handleCaretAfterInput(z(a)))},{signal:u}),R(a).addEventListener("selectionchange",()=>{let b=de(a);if(!b||!a.contains(b.node))return;let x=b.collapsed?g():null,v=e.store.get(),P=v.editingParam?.id??v.editingIdentified?.id??null;if(x&&x!==P){e.startEditingParam(x);return}performance.now()-m<50||e.handleCaretMove(z(a))},{signal:u}),a.addEventListener("click",b=>{let x=qn(a,b.target);x&&(e.startEditingParam(x),Kn(a,x))},{signal:u}),a.addEventListener("compositionstart",()=>{f=!0,a.setAttribute("data-aia-composing","true")},{signal:u}),a.addEventListener("compositionend",()=>{f=!1,a.removeAttribute("data-aia-composing"),p()},{signal:u}),a.addEventListener("beforeinput",b=>{let x=b,v=x.inputType;if(v==="insertParagraph"||v==="insertLineBreak"||v==="insertFromDrop"){b.preventDefault();return}if(v.startsWith("insert")||v.startsWith("delete")){let P=v.startsWith("delete")?"":x.data??"";e.replaceEditingRange(P)&&b.preventDefault()}},{signal:u}),a.addEventListener("paste",b=>{b.preventDefault();let x=(b.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!x)return;let v=R(a),P=ye(a);if(!P||!a.contains(P.startContainer))return;P.deleteContents();let T=v.createTextNode(x);P.insertNode(T),P.setStartAfter(T),Ze(a,P.startContainer,P.startOffset),p()},{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}),d&&d.addEventListener("click",b=>{es(e)&&(b.stopPropagation(),ts(e))},{signal:u}),e.autoFocus!==!1){a.focus();let b=de(a);(!b||!a.contains(b.node))&&Ze(a,a,0)}if(typeof ResizeObserver<"u"){let b=new ResizeObserver(()=>ns(a,s));b.observe(a),c.signal.addEventListener("abort",()=>b.disconnect(),{once:!0})}let S=lo(r);return c.signal.addEventListener("abort",S,{once:!0}),{input:a,inlinePillContainer:s,dropdown:i,submitButton:l,abort:c,syncChipRemove:E}}function bo(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:a}=t,{pillPlacement:s,setActivePill:l,selectOption:d,store:c}=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 E=n.strings??_();a.getAttribute("aria-label")!==E.submit&&a.setAttribute("aria-label",E.submit);let y=a.querySelector("svg");y&&y.getAttribute("aria-label")!==E.submit&&y.setAttribute("aria-label",E.submit);let S=!!e.text||e.completedParams.length>0;a.disabled=!S,a.toggleAttribute("data-aia-ready",S&&e.isReady)}let f=i.dataset.newParamId??"",m=e.newParamId!==null&&e.newParamId!==f;if(ho({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"?[]:go(e.actionableSuggestions),showChipRemove:n.showChipRemove??!1}),s==="inline"){let E=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,y=On(e.actionableSuggestions);E||y.length>0?an(o,y,0,l,!1,E,e.isActivePillSelected):qi(o)}else qi(o);ns(i,o),m?(i.focus(),W(i,e.caretOffset??e.text.length)):e.isFocused&&_t(i)!==e.text&&W(i,e.text.length);let p=e.editingParam?{parameter:e.editingParam.suggestionParameter,text:e.editingParam.suggestionPlaceholder,required:!0,options:e.editingParam.options}:e.editingIdentified?{parameter:e.editingIdentified.parameter,text:ie(e.editingIdentified.parameter),required:!0,options:[]}:null,g=e.dropdownSuggestion??p??e.actionableSuggestions[0],h=at(e);bn(r,{strings:n.strings,suggestions:g?[{...g,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:d,onHighlight:(E,y)=>{y!==void 0&&c.get().activeDropdownIndex!==y||c.set({activeDropdownIndex:E})},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:E=>c.set({isFocused:E}),onSeeAllResults:n.seeAllResults&&e.text.trim().length>0&&es(n)?()=>ts(n):void 0})}function So(t){let e=t,n=new Set,i=[],o=!1;return{get:()=>e,set:r=>{let a=typeof r=="function"?r(e):r,s=e;if(e={...e,...a},i.push([e,s]),!o){o=!0;try{let l=0;for(let d=i.shift();d;d=i.shift()){if(++l>1e4)throw i.length=0,new Error("createStore: notifications did not settle after 10000 deliveries \u2014 a listener is likely calling set() on every notification");let[c,u]=d;for(let f of n)f(c,u)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function os(t,e){let n,i,o=r=>(r!==n&&(n=r,i=e(r)),i);return{get:()=>{let r=t.get();return{...r,...o(r)}},set:r=>{typeof r=="function"?t.set(a=>{let s={...a,...o(a)};return r(s)}):t.set(r)},peek:r=>{let a={...t.get(),...r};return{...a,...e(a)}},subscribe:r=>t.subscribe((a,s)=>{let l={...s,...o(s)},d={...a,...o(a)};r(d,l)})}}var yo=new WeakSet,rs=new WeakMap;function ss(t){return t.nodeType===Node.DOCUMENT_NODE}function _d(t){return ss(t)?t:t.ownerDocument}function Dd(t){let e=rs.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(cs),rs.set(t,i),i)}catch{return null}}function as(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=cs,e.appendChild(n)}function ls(t){if(typeof document>"u")return;let e=t??document;if(yo.has(e))return;let n=_d(e);if(ss(e)){let r=e.head??e.documentElement;if(!r)return;as(n,r),yo.add(e);return}let i=Dd(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):as(n,e),yo.add(e)}var cs=`.aia-stack {
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: var(--aia-stack-space, 0.5rem);
@@ -1236,11 +1236,12 @@ function k(t){return t==="date"||t==="date-range"}function D(t){return t!=="opti
1236
1236
  }
1237
1237
 
1238
1238
  /* --- See all results (opt-in: \`seeAllResults\`) ---
1239
- A full-width pill under the products that submits the query: black in
1240
- light mode, the confirm gray in dark (appearance.css sets both). Inset
1241
- 10px like the products section so its edges line up with the cards. */
1239
+ A button under the products that submits the query: near-black in light
1240
+ mode, the confirm gray in dark (appearance.css sets both). It is the same
1241
+ box as the multi-select Done above it: the panel's full width and the same
1242
+ 12px corners, so the two read as one pair. */
1242
1243
  .magicx-aia-see-all-row {
1243
- padding: 4px 10px 0;
1244
+ padding: 4px 0 0;
1244
1245
  }
1245
1246
 
1246
1247
  .magicx-aia-see-all {
@@ -1249,8 +1250,8 @@ function k(t){return t==="date"||t==="date-range"}function D(t){return t!=="opti
1249
1250
  min-height: var(--aia-see-all-height, 48px);
1250
1251
  padding: 0 16px;
1251
1252
  border: none;
1252
- border-radius: var(--aia-see-all-radius, 999px);
1253
- background: var(--aia-see-all-bg, #111111);
1253
+ border-radius: var(--aia-see-all-radius, 12px);
1254
+ background: var(--aia-see-all-bg, #2b2b2b);
1254
1255
  color: var(--aia-see-all-color, #ffffff);
1255
1256
  font-family: inherit;
1256
1257
  font-size: var(--aia-see-all-font-size, 16px);
@@ -1262,7 +1263,7 @@ function k(t){return t==="date"||t==="date-range"}function D(t){return t!=="opti
1262
1263
  }
1263
1264
 
1264
1265
  .magicx-aia-see-all:hover {
1265
- background: var(--aia-see-all-bg-hover, #333333);
1266
+ background: var(--aia-see-all-bg-hover, #3d3d3d);
1266
1267
  }
1267
1268
 
1268
1269
  /* --- Footer (keyboard hint + AI-Autocomplete branding) ---
@@ -1423,6 +1424,24 @@ function k(t){return t==="date"||t==="date-range"}function D(t){return t!=="opti
1423
1424
  animation: none;
1424
1425
  }
1425
1426
 
1427
+ /* The rest of the panel leaves and returns with the options: the product
1428
+ results, "See all results" and the multi-select Done fade out on the same
1429
+ 160ms while a request loads, and fade back when it lands, so a step change
1430
+ never leaves them standing at full strength over rows that are gone. The
1431
+ leaving ghost is a frozen copy and takes no part. */
1432
+ .magicx-aia-dropdown[data-aia-loading] > .aia-stack > .magicx-aia-products,
1433
+ .magicx-aia-dropdown[data-aia-loading] > .aia-stack > [data-aia-see-all],
1434
+ .magicx-aia-dropdown[data-aia-loading] > .aia-stack > [data-aia-multi-actions] {
1435
+ pointer-events: none;
1436
+ animation: magicx-aia-loading-out 160ms ease-in forwards;
1437
+ }
1438
+
1439
+ .magicx-aia-dropdown:not([data-aia-loading]) > .aia-stack > .magicx-aia-products,
1440
+ .magicx-aia-dropdown:not([data-aia-loading]) > .aia-stack > [data-aia-see-all],
1441
+ .magicx-aia-dropdown:not([data-aia-loading]) > .aia-stack > [data-aia-multi-actions] {
1442
+ animation: magicx-aia-fadeIn 160ms ease-out;
1443
+ }
1444
+
1426
1445
  /* Ends a hair above zero, like magicx-aia-fadeIn starts: a pill kept by key
1427
1446
  is re-enabled in place, and iOS cancels a tap on an element leaving 0. */
1428
1447
  @keyframes magicx-aia-loading-out {
@@ -2805,6 +2824,18 @@ function k(t){return t==="date"||t==="date-range"}function D(t){return t!=="opti
2805
2824
  background: var(--aia-multi-done-bg-hover, var(--aia-done-bg-hover, #d8dde8));
2806
2825
  }
2807
2826
 
2827
+ /* With a "See all results" button in the same panel, that button is the
2828
+ filled one: Done drops its fill so the panel does not end on two solid
2829
+ bars. Its hover keeps the usual Done fill. With no fill behind it the
2830
+ label takes the panel's own strong text colour: the Done colour is chosen
2831
+ against the Done fill (black on the dark theme's gray), so it would vanish
2832
+ on the bare dark panel. A host that restyles Done sets these two tokens
2833
+ for this state; \`--aia-multi-done-bg\` and \`--aia-done-bg\` do not reach it. */
2834
+ .magicx-aia-dropdown:has(> .aia-stack > [data-aia-see-all]) .magicx-aia-multi-done:not(:hover) {
2835
+ background: var(--aia-multi-done-bg-beside-see-all, transparent);
2836
+ color: var(--aia-multi-done-color-beside-see-all, var(--aia-option-color-selected, #2a3150));
2837
+ }
2838
+
2808
2839
  /* The open panel's leaving ghost (panelMorph.ts) is a frozen copy of the
2809
2840
  last step: the rows' own entrance must not replay in it while it fades. */
2810
2841
  .magicx-aia-dropdown .magicx-aia-panel-ghost,
@@ -3288,9 +3319,9 @@ function k(t){return t==="date"||t==="date-range"}function D(t){return t!=="opti
3288
3319
  --aia-done-bg-hover: #d8dde8;
3289
3320
  --aia-done-color: #2a3150;
3290
3321
  /* The opt-in "See all results" button (\`seeAllResults\`, vanilla only): a
3291
- solid black pill under white text. */
3292
- --aia-see-all-bg: #111111;
3293
- --aia-see-all-bg-hover: #333333;
3322
+ solid near-black button under white text. */
3323
+ --aia-see-all-bg: #2b2b2b;
3324
+ --aia-see-all-bg-hover: #3d3d3d;
3294
3325
  --aia-see-all-color: #ffffff;
3295
3326
 
3296
3327
  --aia-footer-hint-color: var(--aia-primitive-neutral-500);
@@ -3832,5 +3863,5 @@ function k(t){return t==="date"||t==="date-range"}function D(t){return t!=="opti
3832
3863
  padding-inline: 8px;
3833
3864
  font-size: var(--aia-skip-font-size, 13.5px);
3834
3865
  }
3835
- `;var Sn=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 yn=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 xn=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 kd(t){let e;try{e=new URL(t??j).host}catch{return null}let n=lt.get(e);return n?`https://${n}`:null}var ss=new WeakMap;function ls(t,e){if(!t.head)return;let n=kd(e);if(!n)return;let i=ss.get(t);i||(i=new Map,ss.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 rt=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 ho(t){return t.isDropdownOpen&&!t.isLoading}var Rd=50,_d=new Set(["search_started","submit","product_click","impression"]),Dd="newParam",cs="suggestionRemoval",Hd="selectionAnimation",bo="skeletonExit",ds="locationSearch",Nd=650,Fd=0;function Wd(){return`:ac-${++Fd}:`}var us=170,ms=160;function ps(){return{text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,locationAutocomplete:!0,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!1,isReady:!1,error:null,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null,multiSelectDraft:null,locationSearch:null,locationFieldFocused:!1,editingIdentified:null}}var So=class{constructor(e,n={}){this.inputStore=fo(ps());this._listboxId=Wd();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new xn;this.boundary=new Sn;this.subscriberCount=0;this.emitter=new yn(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=ts(this.inputStore,i=>Ar(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 Tt(this.store,e),this.pillsController=new Bt(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new Qt({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new Vt(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new Wt(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 xt(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,onRequest:({query:i,signal:o,isCurrent:r})=>{ls(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:ue(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 Ft(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",afterSubmit:this.renderMode==="full"?()=>this.resetAfterSubmit():void 0,selectOption:i=>this.selectOption(i),removeParamAtCaret:i=>this.removeParamAtCaret(i),startEditingParamAtCaret:i=>this.startEditingParamAtCaret(i),exitEditMode:()=>this.exitEditMode(),exitEditingIdentified:()=>this.exitEditingIdentified(),skipActivePill:()=>this.skipActivePill(),endTypedWord:i=>this.endTypedWord(i),stepTime:i=>this.stepTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()}),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text!==o.text&&this.emitter.emit("change",i.text),i.completedParams!==o.completedParams&&this.emitter.emit("paramsChange",i.completedParams);let r=i.isFocused||i.locationFieldFocused;r!==(o.isFocused||o.locationFieldFocused)&&(r?this.emitter.emit("focus"):this.emitter.emit("blur")),this.emitter.emit("stateChange",i)})),this.unsubscribers.push(this.store.subscribe(()=>this.maybeExitReEditOnNoMatch())),this.unsubscribers.push(this.store.subscribe(()=>{let i=this.store.get();i.locationFieldFocused&&!i.locationView&&this.store.set({locationFieldFocused:!1})})),this.subscribeSkeletonMirror(),this.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}=je(i.text,i.completedParams,i.identifiedParams);a.length>0&&this.store.set({identifiedParams:r})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{if(i.identifiedParams===o.identifiedParams)return;let r=i.editingIdentified;if(!r||i.identifiedParams.some(l=>l.id===r.id))return;let a=0,s;for(let l of i.segments){if(l.type==="identified"&&a===r.anchor&&l.value===r.text){s=l.param;break}a+=l.value.length}if(s){this.store.set({editingIdentified:{...r,id:s.id}});return}this.store.set({editingIdentified:null,activeDropdownIndex:-1})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.pendingRangeStart;!o||o.key===W(i)||this.store.set({pendingRangeStart:null})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.multiSelectDraft;o&&o.key!==W(i)&&this.store.set({multiSelectDraft:null});let r=i.timeDraft;!r||r.key===W(i)||this.store.set({timeDraft:null})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{let r=i.pendingSpan;if(!r||i.text===o.text&&i.completedParams===o.completedParams&&i.identifiedParams===o.identifiedParams)return;let a=r.anchor;if(i.text!==o.text){let l=jo(o.text,i.text,a);if(l===null){this.store.set({pendingSpan:null});return}a=l}i.text.slice(a).trim().length===0||Ko(i.segments,a)?this.store.set({pendingSpan:null}):a!==r.anchor&&this.store.set({pendingSpan:{anchor:a,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(rs(this.opts.styleRoot??ce(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({...ps(),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&&(Wr(this.domRefs.input),co(this.domRefs.input),eo(this.domRefs.dropdown)),this.dropdownRefs&&eo(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=Gn(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}=Yt(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().completedParams.find(a=>a.id===e);if(!n)return!1;let i=()=>{let a=0;for(let s of this.store.get().segments)if(a+=s.value.length,s.type==="completed"&&(s.param.id===e||n.group&&s.param.group===n.group))return a;return null};if(i()===null)return!1;this.store.get().editingParam&&this.exitEditMode(),this.store.get().editingIdentified&&this.exitEditingIdentified();let o=i(),r=o===null?null:this.findChipSpanAt(o);return!r||r.kind!=="completed"?!1:(this.removeWholeChip(r),this.store.get().isFocused&&this.scheduleSetCursor(r.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(),F(n.input,e);else{let i=this.opts.setCursor;i&&this.boundary.runListener("setCursor",()=>i(e))}})}clearNewParamId(){this.store.set({newParamId:null})}startEditingIdentified(e){let n=this.store.get();if(n.editingIdentified?.id===e)return!0;let i=n.identifiedParams.find(d=>d.id===e);if(!i)return!1;let o=te(i);if(!k(o))return!1;let r=o==="date-range"?Ze(i)??$t(i.text):null,a=0,s=-1;for(let d of n.segments){if(d.type!=="text"&&d.param.id===e){s=a;break}a+=d.value.length}if(s<0)return!1;let l=s+i.text.length;return this.store.set({editingIdentified:{id:e,parameter:i.parameter,anchor:s,tail:l,text:i.text,iso:r?r.start:oi(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)}applyTextChange(e,n){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.handleChange(e,n)}showPreviousMonth(){this.pageDateView(-1)}showNextMonth(){this.pageDateView(1)}pageDateView(e){let n=this.store.get();if(!k(n.activeFormatType)||!n.dateView)return;let i=Rn(n.dateView,e);this.store.set({dateViewMonth:{...i,key:W(n)},activeDropdownIndex:-1})}setTime(e){let n=this.store.get();n.activeFormatType!=="time"||!n.timeView||this.store.set({timeDraft:{minutes:Ae(e),key:W(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(gr(n.minutes,e))}toggleMultiSelectOption(e){let n=this.store.get();if(!n.multiSelectView||!e.is_tappable)return;let i=n.multiSelectView.picked;this.store.set({multiSelectDraft:{key:W(n),picked:i.includes(e.text)?i.filter(o=>o!==e.text):[...i,e.text]}})}commitMultiSelect(){this.finishMultiSelect()}answerMultiSelectWith(e){let n=this.store.get().multiSelectView;!n||!e.is_tappable||(n.picked.includes(e.text)||this.toggleMultiSelectOption(e),this.finishMultiSelect())}finishMultiSelect(e=""){let n=this.store.get();if(!n.multiSelectView)return;let i=n.multiSelectView.picked;if(i.length===0){this.store.set({multiSelectDraft:null}),this.skipActivePill();return}let o=i.map(a=>n.actionableSuggestions[0].options?.find(s=>s.text===a)).filter(a=>a!==void 0);if(o.length===0)return;let r=i.length===1?i[0]:`${i.slice(0,-1).join(", ")} ${_(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(Xn(e.timeView.minutes)),this.store.get().completedParams!==e.completedParams&&this.store.set({timeDraft:null}))}setLocationQuery(e){let n=this.store.get(),i=n.locationView;if(n.activeFormatType!=="location"||!i)return;let o=W(n);this.cancelLocationSearch();let a=n.locationAutocomplete&&this.opts.locationSearch!==!1?wn(this.opts.apiConfig):null,s="loading";a?e.trim().length<mt&&(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(ds,()=>{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(Pn(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&&En(o,r)}typedLocationQuery(e){let n=this.typedLocationPhrase(e);return this.isReEditing(e)?n.trim():Lo(n)}isReEditing(e){return e.editingParam!=null&&e.editingAnchor!=null}typedLocationPhrase(e){if(this.isReEditing(e))return fi(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 yt(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 Ho(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 Ge&&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(ds),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 ye(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.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(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=K(e);if(a&&a<o.dateFloor)return}if(o.activeFormatType==="date-range"){let a=K(e);if(a){let s=o.dateRangeStart;if(!s){this.store.set({pendingRangeStart:{iso:a,key:W(o)}});return}this.store.set({pendingRangeStart:null}),this.selectOption(wr(s,a));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(bo),this.reEdit.selectOption(e);return}let r=_r({...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,d=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),c=n.map(u=>{let f=l.toLowerCase().indexOf(u.text.toLowerCase(),d);return d=f+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(f,d)}});r.patch.completedParams=[...o.completedParams,...c],r.patch.newParamId=c[0].id,r.patch.multiSelectDraft=null,r.patch.text+=i,r.patch.caretOffset=r.patch.text.length,r.patch.suggestions=o.suggestions.filter(u=>u!==r.consumedSuggestion)}for(let a of n??[e])this.fireTelemetry("option",{raw_query:H(o.text,o.completedParams).rawQuery,selected_option:a.text,other_options:D(o.activeFormatType)?[]:o.filteredOptions.filter(s=>s.text!==a.text).map(s=>s.text),key:r.telemetry.key,position:D(o.activeFormatType)?null:ue(r.consumedSuggestion.options??[],a.text),chip_origin:"tap"});if(this.timers.clear(bo),this.store.set({...r.patch,...jt(o)}),this.startSelectionAnimationTimer(),this.timers.clear(cs),r.remainingActionable>0){let a=r.consumedSuggestion;this.timers.schedule(cs,()=>{this.store.get().suggestions.includes(a)&&this.store.set(s=>({suggestions:s.suggestions.filter(l=>l!==a)}))},us)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(Hd,()=>this.store.set({inSelectionAnimation:!1}),us)}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=""),ho(e)&&!ho(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!ho(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!A(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,Rd).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&&_d.has(e))return;if(!i&&e==="option"){let{key:r,position:a,chip_origin:s,...l}=n;n=l}let o=this.resolveSource();Rr({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:se(this.opts.language),queryData:n,apiConfig:this.opts.apiConfig})}updateLanguageAttribute(){let{language:e}=_(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 rt(this.container,this.opts.mode??"auto")}buildAndRenderFull(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return _(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),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=es(this.container,n);let i=()=>{this.domRefs&&po(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),po(this.domRefs,this.store.get(),n),this.subscribeNewParamTimer()}buildAndRenderDropdown(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return _(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=Va(this.container,n);let i=()=>{this.dropdownRefs&&to(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),to(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(Gt),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,skeletonRequested:!1};if(!n.skeletonExiting){this.store.set(r);return}let a=ms-(Date.now()-e);this.timers.schedule(bo,()=>this.store.set(r),Math.min(ms,Math.max(0,a)))}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(Dd,()=>this.store.set({newParamId:null}),Nd)}))}handleChange(e,n){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}=Qo(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=W(e),o=this.typedLocationQuery(e);if(o.length<mt){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}=je(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=le(e.text,Math.min(e.filterBase,e.text.length),e.leadInText),i=qo(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);he(e.editingParam.options,i).some(r=>r.is_tappable)||(this.reEdit.exit(),this.fetchNow())}fetchNow(){let e=this.store.get(),{rawQuery:n,completedParams:i}=H(e.text,e.completedParams);this.fetchController.doFetch(n,i)}commitIdentifiedDate(e){let n=this.store.get(),i=n.editingIdentified;if(!i)return;if(n.text.slice(i.anchor,i.tail)!==i.text){this.store.set({editingIdentified:null,activeDropdownIndex:-1});return}let o=n.text.slice(0,i.anchor),r=n.text.slice(i.tail),a=i.anchor===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,l=r.length===0||r[0]!==" "?`${a} `:a,d=o+l+r,c=d.length,u={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:a,value:e.value,kind:e.kind,suggestionParameter:i.parameter,suggestionPlaceholder: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:H(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:[],key:i.parameter,position:null,chip_origin:"tap"}),this.store.set({text:d,completedParams:[...n.completedParams,u],identifiedParams:n.identifiedParams.filter(f=>f.id!==i.id),newParamId:u.id,filterBase:c,caretOffset:c,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(c),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(D(o.activeFormatType)||this.isWordOpen())return;let r=Kt({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:H(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:ue(s,r.option.text),chip_origin:"typed"})}this.store.set(r.patch)}}};export{So as AIAutocomplete,Br as ATTRIBUTION_URL,li as DATE_RANGE_META_END,si as DATE_RANGE_META_START,Ia as DEFAULT_OPTION_COUNT_UNIT,bd as EDITOR_GROW_MS,lo as HINT_ATTR,Ka as HINT_EL_ATTR,qa as HINT_HOLD_MS,vn as LOCATION_META_KEY,mt as LOCATION_MIN_QUERY,Li as MULTI_DONE_FIT_VAR,Hc as MULTI_SELECT_TOGGLE_MIN_PX,Dc as MULTI_SELECT_TOGGLE_SLOP_PX,rt as ModeController,Gt as OPTIONS_GRID_MOBILE_QUERY,Mi as OPTION_ENTER_DELAY_VAR,Nl as OPTION_ENTER_FADE_MS,Fl as OPTION_ENTER_RISE_MS,Wl as OPTION_ENTER_RISE_PX,Hl as OPTION_ENTER_STAGGER_MS,Gi as OPTION_IMAGE_WIDTH,oa as PANEL_ENTER_DELAY_MS,ia as PANEL_ENTER_MS,pe as PANEL_GHOST_CLASS,ta as PANEL_GLIDE_MS,na as PANEL_LEAVE_MS,Tl as PLACEHOLDER_FADE_OUT_MS,ke as PLACEHOLDER_LEAVING_ATTR,vl as PLACEHOLDER_SWAP_GAP_MS,yl as PLACEHOLDER_TYPE_MS,xl as PLACEHOLDER_WORD_PAUSE_MS,Cc as PRODUCT_IMAGE_WIDTH,yr as PRODUCT_PATH_PREFIX,Lc as PRODUCT_ROW_PX_PER_LINE,Er as RANGE_SEPARATOR,Ro as SCHEMA_VERSION,en as SCROLL_ARROW_ATTR,Jr as SCROLL_ARROW_BOTTOM_VAR,Yr as SCROLL_ARROW_CLASS,Qr as SCROLL_ARROW_FADE_MS,Bl as SCROLL_ARROW_LABEL,Xr as SCROLL_ARROW_SCROLL_IDLE_MS,De as SCROLL_ARROW_VISIBLE_ATTR,Oo as SKIPPED_PARAM_TEXT,An as SMART_SUGGESTION_SPARKLE_SVG,pr as TIME_META_KEY,Kn as TIME_STEP_MINUTES,_t as TIME_WHEEL_COLUMNS,Rt as TIME_WHEEL_ROW_HEIGHT,Ne as VIEWPORT_FIT_ATTR,dn as VIEWPORT_FIT_HEIGHT_VAR,vt as WEEKDAY_LABELS,Rn as addMonths,io as attachChipRemove,Ui as attachProductRowWheel,Hi as attachScrollArrow,Zi as attachViewportFit,vi as buildAttributionUrl,_n as buildDateOptions,Pn as buildLocationOption,H as buildQuery,ye as buildSubmitResult,Xn as buildTimeOption,co as cancelStartingHint,Dn as cellDay,K as cellIso,Vn as chipIdFromTap,Lr as computeOptionsGridLayout,wi as containScroll,fo as createStore,$n as cursorIsAtEnd,yi as dateCellMarks,Ti as dateFloorFor,it as dateSelectionFor,Bi as destroyPanelMorph,Ot as extractPlainText,Il as findMultiSelectDone,Ci as fitMultiSelectDone,Le as formatAbsoluteDate,ir as formatDate,Pr as formatDateRange,ot as formatOptionCount,Co as formatPlace,kt as formatTime,z as getCursorOffset,Pi as getFooterHint,In as hasSkippablePill,hi as highlightParts,ie as identifiedParamLabel,_e as inPanelGhost,k as isCalendarFormat,xi as isDimmedDay,Qi as isMultiSelectToggleTap,nt as isOptionsGridMobileViewport,D as isPickerFormat,bt as isSmartSuggestion,A as isTraditionalAutocompleteSuggestion,N as isoDate,fr as isoTime,Un as keepCaretOnChip,Cn as labelTraditionalAutocomplete,wn as locationEndpointFor,zt as matchTypedPhrase,tt as measureOptionsGrid,Mn as monthLabel,ui as needsOptionsGridMeasurement,Wi as notePanelMorphHeight,$c as optionCountLabel,ki as optionEnterDelayMs,Oa as optionHasImage,ln as optionImageSources,Ee as optionImageSrc,an as optionLabel,Ri as optionsEntranceDurationMs,di as optionsGridTemplateColumns,Xi as optionsShowLeadingVisuals,xe as panelMorphGlide,Ni as panelMorphKey,Fi as panelMorphTargetHeight,Pt as parseDate,Oe as parseLooseDate,$t as parseLooseDateRange,qn as parseTime,Wn as plainTextLength,mi as planOptionsGrid,Gn as previousGraphemeBoundary,xr as productFromMatchedItem,on as productImageSources,Ic as productImageSrc,$i as productInitial,Ki as productPhotoFill,ya as productRowWheelTarget,ni as productsFromCustomFields,V as queryLive,Zt as releasePanelHug,mo as renderEditableContent,te as resolveFormatType,oi as resolveIdentifiedDate,pi as sameOptionRows,ae as sanitizeOptionIconSvg,Hn as scrollCaretIntoView,Ye as selectedIsoFromText,Me as selectedRangeFor,F as setCursorOffset,tn as settlePanelMorph,va as shopifyImageSrc,uo as startingHintOptions,Dl as syncPanelHug,Dt as timeWheelIndex,ei as timeWheelIndexFromScroll,Zn as timeWheelRows,Ue as toWireIdentifiedParams,Or as typedFragment,_ as uiStringsFor,Si as visibleDateRange,oo as watchEditorHeight,$e as withSkippedParams,Ht as withTimeWheelIndex,Ln as withoutTraditionalAutocomplete};
3866
+ `;var Tn=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 vn=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 En=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 Hd(t){let e;try{e=new URL(t??j).host}catch{return null}let n=mt.get(e);return n?`https://${n}`:null}var ds=new WeakMap;function us(t,e){if(!t.head)return;let n=Hd(e);if(!n)return;let i=ds.get(t);i||(i=new Map,ds.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 lt=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 xo(t){return t.isDropdownOpen&&!t.isLoading}var Nd=50,Fd=new Set(["search_started","submit","product_click","impression"]),Wd="newParam",ms="suggestionRemoval",ps="selectionAnimation",To="skeletonExit",fs="locationSearch",Bd=650,Vd=0;function Ud(){return`:ac-${++Vd}:`}var gs=170,hs=160;function bs(){return{text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,locationAutocomplete:!0,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!1,isReady:!1,error:null,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,skeletonOptions:null,skeletonSuggestion:null,skeletonPicked:null,skeletonRequested:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null,multiSelectDraft:null,locationSearch:null,locationFieldFocused:!1,editingIdentified:null}}var vo=class{constructor(e,n={}){this.inputStore=So(bs());this._listboxId=Ud();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new En;this.boundary=new Tn;this.subscriberCount=0;this.emitter=new vn(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=os(this.inputStore,i=>Or(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 wt(this.store,e),this.pillsController=new Gt(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new Zt({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new qt(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new $t(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 Pt(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,onRequest:({query:i,signal:o,isCurrent:r})=>{us(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:ue(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 Ut(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",afterSubmit:this.renderMode==="full"?()=>this.resetAfterSubmit():void 0,selectOption:i=>this.selectOption(i),removeParamAtCaret:i=>this.removeParamAtCaret(i),startEditingParamAtCaret:i=>this.startEditingParamAtCaret(i),exitEditMode:()=>this.exitEditMode(),exitEditingIdentified:()=>this.exitEditingIdentified(),skipActivePill:()=>this.skipActivePill(),endTypedWord:i=>this.endTypedWord(i),stepTime:i=>this.stepTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()}),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text!==o.text&&this.emitter.emit("change",i.text),i.completedParams!==o.completedParams&&this.emitter.emit("paramsChange",i.completedParams);let r=i.isFocused||i.locationFieldFocused;r!==(o.isFocused||o.locationFieldFocused)&&(r?this.emitter.emit("focus"):this.emitter.emit("blur")),this.emitter.emit("stateChange",i)})),this.unsubscribers.push(this.store.subscribe(()=>this.maybeExitReEditOnNoMatch())),this.unsubscribers.push(this.store.subscribe(()=>{let i=this.store.get();i.locationFieldFocused&&!i.locationView&&this.store.set({locationFieldFocused:!1})})),this.subscribeSkeletonMirror(),this.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}=Qe(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=Qo(o.text,i.text,a);if(l===null){this.store.set({pendingSpan:null});return}a=l}i.text.slice(a).trim().length===0||jo(i.segments,a)?this.store.set({pendingSpan:null}):a!==r.anchor&&this.store.set({pendingSpan:{anchor:a,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(ls(this.opts.styleRoot??ce(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({...bs(),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&&(Vr(this.domRefs.input),fo(this.domRefs.input),oo(this.domRefs.dropdown)),this.dropdownRefs&&oo(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=jn(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}=Jt(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 d of this.store.get().segments)if(l+=d.value.length,d.type===o&&(d.param.id===e||d.type==="completed"&&i?.group&&d.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(),W(n.input,e);else{let i=this.opts.setCursor;i&&this.boundary.runListener("setCursor",()=>i(e))}})}clearNewParamId(){this.store.set({newParamId:null})}startEditingIdentified(e){let n=this.store.get();if(n.editingIdentified?.id===e)return!0;let i=n.identifiedParams.find(d=>d.id===e);if(!i)return!1;let o=te(i);if(!k(o))return!1;let r=o==="date-range"?tt(i)??zt(i.text):null,a=0,s=-1;for(let d of n.segments){if(d.type!=="text"&&d.param.id===e){s=a;break}a+=d.value.length}if(s<0)return!1;let l=s+i.text.length;return this.store.set({editingIdentified:{id:e,parameter:i.parameter,anchor:s,tail:l,text:i.text,iso:r?r.start:li(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)}applyTextChange(e,n){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.handleChange(e,n)}showPreviousMonth(){this.pageDateView(-1)}showNextMonth(){this.pageDateView(1)}pageDateView(e){let n=this.store.get();if(!k(n.activeFormatType)||!n.dateView)return;let i=Nn(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:Ie(e),key:B(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(br(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(", ")} ${_(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(ti(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?In(this.opts.apiConfig):null,s="loading";a?e.trim().length<ht&&(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(fs,()=>{this.runLocationSearch(o,e,a)},Co)}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(An(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&&Cn(o,r)}typedLocationQuery(e){let n=this.typedLocationPhrase(e);return this.isReEditing(e)?n.trim():Ao(n)}isReEditing(e){return e.editingParam!=null&&e.editingAnchor!=null}typedLocationPhrase(e){if(this.isReEditing(e))return Si(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 Et(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 Fo(i,n.trim(),{apiConfig:this.opts.apiConfig,sessionToken:this.locationSession.token,language:this.opts.language,signal:o.signal}),status:"done"}}catch(s){let l=s instanceof Ke&&s.status===404;l&&this.store.set({locationAutocomplete:!1}),r={places:[],status:l?"unavailable":"error"}}if(this.destroyed||o.signal.aborted||this.locationAbort!==o)return;this.locationAbort=null;let a=this.store.get().locationSearch;!a||a.key!==e||a.query!==n||this.store.set({locationSearch:{...a,...r,highlighted:r.places.length>0?0:-1}})}cancelLocationSearch(){this.timers.clear(fs),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 xe(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.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(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=K(e);if(a&&a<o.dateFloor)return}if(o.activeFormatType==="date-range"){let a=K(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(Cr(s,a));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(To),this.reEdit.selectOption(e);return}let r=Hr({...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,d=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),c=n.map(u=>{let f=l.toLowerCase().indexOf(u.text.toLowerCase(),d);return d=f+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(f,d)}});r.patch.completedParams=[...o.completedParams,...c],r.patch.newParamId=c[0].id,r.patch.multiSelectDraft=null,r.patch.text+=i,r.patch.caretOffset=r.patch.text.length,r.patch.suggestions=o.suggestions.filter(u=>u!==r.consumedSuggestion)}for(let a of n??[e])this.fireTelemetry("option",{raw_query:N(o.text,o.completedParams).rawQuery,selected_option:a.text,other_options:H(o.activeFormatType)?[]:o.filteredOptions.filter(s=>s.text!==a.text).map(s=>s.text),key:r.telemetry.key,position:H(o.activeFormatType)?null:ue(r.consumedSuggestion.options??[],a.text),chip_origin:"tap"});if(this.timers.clear(To),n?(this.timers.clear(ps),this.store.set({...r.patch,...rt(o,n.map(a=>a.text)),inSelectionAnimation:!1})):(this.store.set({...r.patch,...rt(o)}),this.startSelectionAnimationTimer()),this.timers.clear(ms),r.remainingActionable>0){let a=r.consumedSuggestion;this.timers.schedule(ms,()=>{this.store.get().suggestions.includes(a)&&this.store.set(s=>({suggestions:s.suggestions.filter(l=>l!==a)}))},gs)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(ps,()=>this.store.set({inSelectionAnimation:!1}),gs)}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=""),xo(e)&&!xo(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!xo(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!A(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,Nd).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&&Fd.has(e))return;if(!i&&e==="option"){let{key:r,position:a,chip_origin:s,...l}=n;n=l}let o=this.resolveSource();Dr({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:se(this.opts.language),queryData:n,apiConfig:this.opts.apiConfig})}updateLanguageAttribute(){let{language:e}=_(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 lt(this.container,this.opts.mode??"auto")}buildAndRenderFull(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return _(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),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=is(this.container,n);let i=()=>{this.domRefs&&bo(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),bo(this.domRefs,this.store.get(),n),this.subscribeNewParamTimer()}buildAndRenderDropdown(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return _(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=$a(this.container,n);let i=()=>{this.dropdownRefs&&ro(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),ro(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(jt),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=hs-(Date.now()-e);this.timers.schedule(To,()=>this.store.set(r),Math.min(hs,Math.max(0,a)))}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(Wd,()=>this.store.set({newParamId:null}),Bd)}))}handleChange(e,n){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}=Jo(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<ht){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}=Qe(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=le(e.text,Math.min(e.filterBase,e.text.length),e.leadInText),i=zo(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);be(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,d=o+l+r,c=d.length,u={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:a,value:e.value,kind:e.kind,suggestionParameter:i.parameter,suggestionPlaceholder: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:d,completedParams:[...n.completedParams,u],identifiedParams:n.identifiedParams.filter(f=>f.id!==i.id),newParamId:u.id,filterBase:c,caretOffset:c,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(c),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(H(o.activeFormatType)||this.isWordOpen())return;let r=Qt({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:ue(s,r.option.text),chip_origin:"typed"})}this.store.set(r.patch)}}};export{vo as AIAutocomplete,Ur as ATTRIBUTION_URL,mi as DATE_RANGE_META_END,ui as DATE_RANGE_META_START,Ma as DEFAULT_OPTION_COUNT_UNIT,Td as EDITOR_GROW_MS,po as HINT_ATTR,ja as HINT_EL_ATTR,za as HINT_HOLD_MS,Ln as LOCATION_META_KEY,ht as LOCATION_MIN_QUERY,Oi as MULTI_DONE_FIT_VAR,Bc as MULTI_SELECT_TOGGLE_MIN_PX,Wc as MULTI_SELECT_TOGGLE_SLOP_PX,lt as ModeController,jt as OPTIONS_GRID_MOBILE_QUERY,Di as OPTION_ENTER_DELAY_VAR,Vl as OPTION_ENTER_FADE_MS,Ul as OPTION_ENTER_RISE_MS,$l as OPTION_ENTER_RISE_PX,Bl as OPTION_ENTER_STAGGER_MS,ji as OPTION_IMAGE_WIDTH,aa as PANEL_ENTER_DELAY_MS,ra as PANEL_ENTER_MS,pe as PANEL_GHOST_CLASS,ia as PANEL_GLIDE_MS,oa as PANEL_LEAVE_MS,wl as PLACEHOLDER_FADE_OUT_MS,Re as PLACEHOLDER_LEAVING_ATTR,Ll as PLACEHOLDER_SWAP_GAP_MS,El as PLACEHOLDER_TYPE_MS,Pl as PLACEHOLDER_WORD_PAUSE_MS,Mc as PRODUCT_IMAGE_WIDTH,Tr as PRODUCT_PATH_PREFIX,Oc as PRODUCT_ROW_PX_PER_LINE,wr as RANGE_SEPARATOR,Do as SCHEMA_VERSION,on as SCROLL_ARROW_ATTR,ea as SCROLL_ARROW_BOTTOM_VAR,Xr as SCROLL_ARROW_CLASS,Jr as SCROLL_ARROW_FADE_MS,Gl as SCROLL_ARROW_LABEL,Zr as SCROLL_ARROW_SCROLL_IDLE_MS,He as SCROLL_ARROW_VISIBLE_ATTR,ko as SKIPPED_PARAM_TEXT,kn as SMART_SUGGESTION_SPARKLE_SVG,gr as TIME_META_KEY,Qn as TIME_STEP_MINUTES,Ft as TIME_WHEEL_COLUMNS,Nt as TIME_WHEEL_ROW_HEIGHT,Fe as VIEWPORT_FIT_ATTR,pn as VIEWPORT_FIT_HEIGHT_VAR,Lt as WEEKDAY_LABELS,Nn as addMonths,so as attachChipRemove,Ki as attachProductRowWheel,Bi as attachScrollArrow,io as attachViewportFit,Li as buildAttributionUrl,Fn as buildDateOptions,An as buildLocationOption,N as buildQuery,xe as buildSubmitResult,ti as buildTimeOption,fo as cancelStartingHint,Wn as cellDay,K as cellIso,qn as chipIdFromTap,Ar as computeOptionsGridLayout,Ii as containScroll,So as createStore,zn as cursorIsAtEnd,Ei as dateCellMarks,wi as dateFloorFor,at as dateSelectionFor,Gi as destroyPanelMorph,_t as extractPlainText,Rl as findMultiSelectDone,Mi as fitMultiSelectDone,Ce as formatAbsoluteDate,rr as formatDate,Lr as formatDateRange,st as formatOptionCount,Io as formatPlace,Ht as formatTime,z as getCursorOffset,Ai as getFooterHint,Rn as hasSkippablePill,xi as highlightParts,ie as identifiedParamLabel,De as inPanelGhost,k as isCalendarFormat,Pi as isDimmedDay,eo as isMultiSelectToggleTap,ot as isOptionsGridMobileViewport,H as isPickerFormat,Tt as isSmartSuggestion,A as isTraditionalAutocompleteSuggestion,F as isoDate,hr as isoTime,Kn as keepCaretOnChip,Mn as labelTraditionalAutocomplete,In as locationEndpointFor,Xt as matchTypedPhrase,it as measureOptionsGrid,Dn as monthLabel,gi as needsOptionsGridMeasurement,$i as notePanelMorphHeight,zc as optionCountLabel,Hi as optionEnterDelayMs,ka as optionHasImage,un as optionImageSources,Pe as optionImageSrc,cn as optionLabel,Ni as optionsEntranceDurationMs,fi as optionsGridTemplateColumns,to as optionsShowLeadingVisuals,Te as panelMorphGlide,Vi as panelMorphKey,Ui as panelMorphTargetHeight,At as parseDate,Me as parseLooseDate,zt as parseLooseDateRange,Yn as parseTime,$n as plainTextLength,hi as planOptionsGrid,jn as previousGraphemeBoundary,vr as productFromMatchedItem,sn as productImageSources,Rc as productImageSrc,zi as productInitial,Qi as productPhotoFill,Ta as productRowWheelTarget,ai as productsFromCustomFields,U as queryLive,nn as releasePanelHug,ho as renderEditableContent,te as resolveFormatType,li as resolveIdentifiedDate,bi as sameOptionRows,ae as sanitizeOptionIconSvg,Bn as scrollCaretIntoView,Xe as selectedIsoFromText,ke as selectedRangeFor,W as setCursorOffset,rn as settlePanelMorph,Pa as shopifyImageSrc,go as startingHintOptions,Wl as syncPanelHug,Wt as timeWheelIndex,oi as timeWheelIndexFromScroll,ii as timeWheelRows,Ge as toWireIdentifiedParams,kr as typedFragment,_ as uiStringsFor,vi as visibleDateRange,lo as watchEditorHeight,qe as withSkippedParams,Bt as withTimeWheelIndex,On as withoutTraditionalAutocomplete};
3836
3867
  //# sourceMappingURL=index.mjs.map