@magicx-eng/ai-autocomplete-vanilla 0.58.0 → 0.58.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Qn=Object.defineProperty;var Sa=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var xa=Object.prototype.hasOwnProperty;var Ta=(t,e)=>{for(var n in e)Qn(t,n,{get:e[n],enumerable:!0})},va=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ya(e))!xa.call(t,o)&&o!==n&&Qn(t,o,{get:()=>e[o],enumerable:!(i=Sa(e,o))||i.enumerable});return t};var Ea=t=>va(Qn({},"__esModule",{value:!0}),t);var Vl={};Ta(Vl,{AIAutocomplete:()=>jn,ATTRIBUTION_URL:()=>Ci,DATE_RANGE_META_END:()=>rn,DATE_RANGE_META_START:()=>on,DEFAULT_OPTION_COUNT_UNIT:()=>Di,EDITOR_GROW_MS:()=>Xr,LOCATION_META_KEY:()=>Xn,LOCATION_MIN_QUERY:()=>mt,MULTI_SELECT_TOGGLE_MIN_PX:()=>Dr,MULTI_SELECT_TOGGLE_SLOP_PX:()=>_r,ModeController:()=>_e,OPTIONS_GRID_MOBILE_QUERY:()=>et,OPTION_ENTER_DELAY_VAR:()=>On,OPTION_ENTER_FADE_MS:()=>kr,OPTION_ENTER_RISE_MS:()=>Mr,OPTION_ENTER_RISE_PX:()=>Rr,OPTION_ENTER_STAGGER_MS:()=>Ar,OPTION_IMAGE_WIDTH:()=>Cn,PLACEHOLDER_FADE_OUT_MS:()=>Zo,PLACEHOLDER_LEAVING_ATTR:()=>fe,PLACEHOLDER_SWAP_GAP_MS:()=>er,PLACEHOLDER_TYPE_MS:()=>Xo,PLACEHOLDER_WORD_PAUSE_MS:()=>Jo,PRODUCT_IMAGE_WIDTH:()=>wr,PRODUCT_PATH_PREFIX:()=>hi,PRODUCT_ROW_PX_PER_LINE:()=>Tr,RANGE_SEPARATOR:()=>yi,SCHEMA_VERSION:()=>ei,SCROLL_ARROW_ATTR:()=>Ui,SCROLL_ARROW_BOTTOM_VAR:()=>Gi,SCROLL_ARROW_CLASS:()=>Wi,SCROLL_ARROW_FADE_MS:()=>Bi,SCROLL_ARROW_LABEL:()=>zr,SCROLL_ARROW_SCROLL_IDLE_MS:()=>Vi,SCROLL_ARROW_VISIBLE_ATTR:()=>Se,SKIPPED_PARAM_TEXT:()=>Zn,SMART_SUGGESTION_SPARKLE_SVG:()=>vt,TIME_META_KEY:()=>li,TIME_STEP_MINUTES:()=>qt,TIME_WHEEL_COLUMNS:()=>Ye,TIME_WHEEL_ROW_HEIGHT:()=>je,VIEWPORT_FIT_ATTR:()=>ye,VIEWPORT_FIT_HEIGHT_VAR:()=>rt,WEEKDAY_LABELS:()=>Ve,addMonths:()=>It,attachProductRowWheel:()=>wn,attachScrollArrow:()=>Nn,attachViewportFit:()=>Fn,buildAttributionUrl:()=>Sn,buildDateOptions:()=>Ot,buildLocationOption:()=>gt,buildQuery:()=>N,buildSubmitResult:()=>se,buildTimeOption:()=>Kt,cellDay:()=>kt,cellIso:()=>Q,chipIdFromTap:()=>Wt,computeOptionsGridLayout:()=>vi,containScroll:()=>xn,createStore:()=>$n,cursorIsAtEnd:()=>Bt,dateCellMarks:()=>vn,dateSelectionFor:()=>ke,extractPlainText:()=>Ke,formatAbsoluteDate:()=>ge,formatDate:()=>ni,formatDateRange:()=>xi,formatOptionCount:()=>Re,formatPlace:()=>Jn,formatTime:()=>ze,getCursorOffset:()=>V,getFooterHint:()=>yn,hasSkippablePill:()=>Et,highlightParts:()=>mn,identifiedParamLabel:()=>j,isCalendarFormat:()=>A,isMultiSelectToggleTap:()=>Mn,isOptionsGridMobileViewport:()=>dn,isPickerFormat:()=>_,isSmartSuggestion:()=>Ue,isTraditionalAutocompleteSuggestion:()=>E,isoDate:()=>B,isoTime:()=>mi,keepCaretOnChip:()=>Ut,labelTraditionalAutocomplete:()=>Tt,locationEndpointFor:()=>ft,matchTypedPhrase:()=>tt,measureOptionsGrid:()=>cn,monthLabel:()=>Lt,needsOptionsGridMeasurement:()=>sn,optionCountLabel:()=>Hr,optionEnterDelayMs:()=>An,optionHasImage:()=>Ni,optionImageSources:()=>ot,optionImageSrc:()=>ue,optionLabel:()=>it,optionsEntranceDurationMs:()=>kn,optionsGridTemplateColumns:()=>an,optionsShowLeadingVisuals:()=>_n,parseDate:()=>Ge,parseLooseDate:()=>Ie,parseLooseDateRange:()=>Ze,parseTime:()=>$t,plainTextLength:()=>Ht,planOptionsGrid:()=>ln,previousGraphemeBoundary:()=>Vt,productFromMatchedItem:()=>bi,productImageSources:()=>nt,productImageSrc:()=>Pr,productInitial:()=>Pn,productPhotoFill:()=>Ln,productRowWheelTarget:()=>Oi,productsFromCustomFields:()=>Zt,renderEditableContent:()=>Gn,resolveFormatType:()=>K,resolveIdentifiedDate:()=>nn,sameOptionRows:()=>un,sanitizeOptionIconSvg:()=>de,scrollCaretIntoView:()=>Dt,selectedIsoFromText:()=>At,selectedRangeFor:()=>Oe,setCursorOffset:()=>F,shopifyImageSrc:()=>Ai,timeWheelIndex:()=>Qe,timeWheelIndexFromScroll:()=>jt,timeWheelRows:()=>zt,toWireIdentifiedParams:()=>Te,typedFragment:()=>wi,uiStringsFor:()=>O,visibleDateRange:()=>Tn,watchEditorHeight:()=>Vn,withSkippedParams:()=>ve,withTimeWheelIndex:()=>Xe,withoutTraditionalAutocomplete:()=>xt});module.exports=Ea(Vl);function A(t){return t==="date"||t==="date-range"}function _(t){return t!=="options"}function K(t){return t?.type?.kind==="date"?"date":t?.type?.kind==="date_range"?"date-range":t?.type?.kind==="time"?"time":t?.type?.kind==="location"&&!t.options?.length?"location":"options"}var lt=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 wa="https://api.ai-autocomplete.com",z=`${wa}/api/suggest`,ct=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),Xi=new WeakMap;function De(t){return t?.type==="accessToken"}function Pa(t){if(!(!t||De(t)))return t}function dt(t){let e=Xi.get(t.getAccessToken);return e||(e=new lt(t),Xi.set(t.getAccessToken,e)),e}function ut(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function pt(t){let e=Pa(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var Xn="aiaPlace",mt=2,Ji=250;function Jn(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function gt(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:Jn(t),is_tappable:!0,kind:null,metadata:{[Xn]:{id:t.id}}}}function ft(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??z,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 Zi(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 Te(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var Zn="skipped";function ve(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:Zn,kind:null}));return i.length>0?[...t,...i]:t}var Ca="0.58.0",ei="1.0",eo=!1;function La(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function ie(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function Ia(t,e,n,i,o,r,a,s,l,d,c,u,m){let h=e.find(f=>f.parameter==="contact"&&f.metadata?.contact_account_count)?.metadata?.contact_account_count,g=typeof h=="number"?h:void 0;return{data:{raw_query:t,accepts_traditional_autocomplete:!0,client_option_parameters:m??[],completed_params:ve(e.map(f=>La(f,n)),l??[]),...a&&a.length>0&&{identified_params:Te(a)},...s&&s.length>0&&{recently_suggested:s},...g!=null&&{contact_account_count:g},...d!==void 0&&{additional_context:d}},meta:{request_id:o,request_at:new Date().toISOString(),language:ie(c),...u?.code&&Number.isFinite(u.rate)&&u.rate>0&&{currency:u.code,currency_rate:u.rate,...u.country!==void 0&&{country:u.country}},client_version:Ca,session_id:i,source:r,schema_version:ei}}}async function to(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function no(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=Ia(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??z,s=await io(a,JSON.stringify(r),i,n.signal);if(!s.ok)throw new Error(`API error: ${s.status} ${s.statusText}`);return s.json()}async function io(t,e,n,i){let o=ut(n);if(De(n)){let a=dt(n),s=await a.getToken(),l=await to(t,o,s,e,i);if(l.status===401){let d=await a.getToken(!0);l=await to(t,o,d,e,i)}return l}let r=pt(n);return!r&&!eo&&(eo=!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 Ne=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function oo(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:ie(n.language)}),o=await io(t,i,n.apiConfig,n.signal);if(!o.ok)throw new Ne(o.status);return Zi(await o.json())}var ht=/[\p{L}\p{N}]/u,Oa=/['\u2019-]/;function ro(t,e,n){let i=t[e];if(i===void 0)return!1;if(ht.test(i))return!0;let o=t[e+n];return Oa.test(i)&&o!==void 0&&ht.test(o)}function Aa(t,e,n){let i=e+n.length;return!(ht.test(n[0])&&ro(t,e-1,-1)||ht.test(n[n.length-1])&&ro(t,i,1))}function Z(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(Aa(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=h=>Z(n,s.text,h,g=>!r.some(f=>g<f.end&&g+s.text.length>f.start)),m=u(a);if(m===-1&&(m=u(0)),m!==-1){n=n.slice(0,m)+c+n.slice(m+s.text.length);let h=c.length-s.text.length;for(let g of r)g.start>=m+s.text.length&&(g.start+=h,g.end+=h);r.push({start:m,end:m+c.length}),a=m>=a?m+c.length:a+h}o.push({...s,placeholder:c})}return{rawQuery:n,completedParams:o}}function oe(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function St(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function Fe(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 ao(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 so(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function ka(t,e){let n=so(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function pe(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?so(i).trimStart():"";if(o)return t.filter(a=>!a.is_tappable||ka(a.text,o));let r=i.toLowerCase();return t.filter(a=>!a.is_tappable||a.text.toLowerCase().includes(r))}function bt(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 He(t,e,n,i,o){let r=Fe(e,n,i),a=bt(t,r);if(a||!o||!r.trim())return a;if(r===e.slice(n))return null;let s=e.lastIndexOf(" ",n-1)+1;return bt(t,e.slice(s))}function lo(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 co(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function Ma(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function j(t){let e=Ma(t);return e.length>0?e.join(" "):t}function Y(t,e){return t.parameter||e}function We(t){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:j(t)}}function yt(t,e){let n=Y(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?We(n):{parameter:n,suggestionParameter:t.suggestionParameter,suggestionValueType:t.suggestionValueType,suggestionPlaceholder:t.suggestionPlaceholder}}function E(t){return t?.type?.kind==="traditional_autocomplete"}function uo(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function Ue(t){return E(t)||t?.smart_suggestion===!0}function xt(t){return t.some(E)?t.filter(e=>!E(e)):t}function Tt(t,e){return t.some(n=>E(n)&&!n.text)?t.map(n=>E(n)&&!n.text?{...n,text:e}:n):t}var vt='<svg viewBox="0 0 20 20" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false"><path class="aia-sparkle-large" d="M8 5C8.5 9.5 10.5 11.5 15 12C10.5 12.5 8.5 14.5 8 19C7.5 14.5 5.5 12.5 1 12C5.5 11.5 7.5 9.5 8 5Z"/><path class="aia-sparkle-small" d="M16 1C16.2 3 17 3.8 19 4C17 4.2 16.2 5 16 7C15.8 5 15 4.2 13 4C15 3.8 15.8 3 16 1Z"/></svg>';function Et(t){return t.some(e=>!E(e))}function po(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 mo(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 go(t,e){let n=[],i=new Set;for(let o of[...t,...e])o.parameter==="placeholder"||E(o)||i.has(o.parameter)||(i.add(o.parameter),n.push({parameter:o.parameter,text:o.text}));return n}function fo(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 wt(t,e){let n=[],i=[],o=0;for(let r of e){let a=Z(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 me(t,e){let{located:n}=wt(t,e);return n.length>0?n[n.length-1].end:0}function ho(t,e,n){let i=[],o=[],r=0;for(let a of n){let s=Z(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 bo(t,e,n=[]){let i=wt(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=ho(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 So(t,e){let{located:n,missing:i}=wt(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 Be(t,e,n){let i=wt(t,e).located,{located:o,missing:r}=ho(t,i,n);return{valid:o.map(a=>a.param),invalid:r}}function yo(t,e,n){let i=e?.endpoint??z,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${Ra(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,a)=>{let s=ct.get(a);return s?`https://${s}`:r})}function Ra(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 xo(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 _a(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var Da=100,Na=300,Fa=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;try{this.callbacks.onRequest?.({query:this.store.get().text,signal:i.signal,isCurrent:()=>o===this.fetchVersion})}catch{}try{this.store.set({isLoading:!0,error:null});let a=this.store.get(),s=a.pendingSpan?go(a.pendingSpan.snapshot,a.actionableSuggestions):void 0,l=crypto.randomUUID(),d=e===""&&n.length===0&&a.skippedParams.length===0&&a.identifiedParams.length===0?this.startingStateUrl():void 0,c=d?await xo(fetch(d,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let u=c??await no(e,n,{sessionId:this.getSessionId(),requestId:l,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:i.signal,apiConfig:this.getApiConfig(),identifiedParams:a.identifiedParams,recentlySuggested:s,skippedParams:a.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})});if(o!==this.fetchVersion)return;this.phraseExactMatch=u.meta?.phrase_exact_match===!0;let m=(u.data.suggestions??[]).find(E),h=m?[]:u.data.input??[],g=h.filter(v=>v.source==="identified").map(v=>({id:crypto.randomUUID(),parameter:v.parameter,text:v.text,...v.type?{type:v.type}:{}})),f=this.callbacks.isWordOpen?.()??!1,S=this.store.get().text.toLowerCase(),y=v=>f&&S.endsWith(v.text.toLowerCase()),p=g.filter(v=>!y(v));f&&this.callbacks.holdIdentified?.(g.filter(y));let b=m?[m]:co(u.data.suggestions??[],this.getOptionOverrides()),T=h,x=T[T.length-1],L=this.store.get().text,P,w;if(x?.state==="in_progress"){w=!0;let v=L.toLowerCase().lastIndexOf(x.text.toLowerCase());P=v!==-1?v:r}else w=!1,P=r;let k=b.filter(v=>v.parameter!=="placeholder")[0],G=null;if(k&&!E(k)&&!f&&k.type?.kind!=="multi_select"&&!_(K(k))){let v=He(k.options,L,P,w,this.phraseExactMatch);v&&(G={id:crypto.randomUUID(),placeholder:"",parameter:Y(v,k.parameter),text:v.text,value:v.value,kind:v.kind,suggestionParameter:k.parameter,suggestionValueType:k.type,suggestionPlaceholder:k.text,options:k.options??[],metadata:v.metadata,icon:v.icon,icon_svg:v.icon_svg,image_url:v.image_url},b=b.filter(J=>J!==k),this.callbacks.onAutoMatch?.({active:k,matched:v,rawQuery:e}))}let te=u.data.custom_fields??null,D=this.callbacks.productsForResponse?.(te);this.store.set(v=>{let J=G?[...v.completedParams,G]:v.completedParams,R=Be(v.text,J,p).valid,ne=new Set(a.skippedParams.map($=>$.id)),at=new Set(v.skippedParams.filter($=>!ne.has($.id)).map($=>$.parameter));return{suggestions:at.size>0?b.filter($=>$.parameter==="placeholder"||!at.has($.parameter)):b,isLoading:!1,isReady:u.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:P,filterInProgress:w,identifiedParams:R,customFields:te,traditionalAutocomplete:u.meta?.traditional_autocomplete===!0,...D!==void 0?{products:D}:{},...G?{completedParams:J}:{}}}),this.callbacks.onResponse?.({requestId:l,funnelTelemetry:u.meta?.funnel_telemetry===!0,visibleImpression:u.meta?.visible_impression===!0})}catch(a){let s=_a(a);o===this.fetchVersion&&(this.store.set({error:s,isLoading:!1}),this.getOnError()?.(s))}finally{if(o===this.fetchVersion&&this.store.get().isLoading)try{this.store.set({isLoading:!1})}catch{}}}startingStateUrl(){let e=this.callbacks.getProductId?.();return e?yo(e,this.getApiConfig(),ie(this.getLanguage())):void 0}attemptNow(){if(this.clearTimers(),this.store.get().skipNextFetch){this.store.set({skipNextFetch:!1});return}this.attemptFetch(1,!0)}scheduleFetch(){if(this.clearTimers(),this.store.get().skipNextFetch){this.store.set({skipNextFetch:!1});return}this.debounceTimer=setTimeout(()=>{this.attemptFetch(Fa)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},Da),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),Na)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;let a=o.suggestions.filter(L=>L.parameter==="placeholder").map(L=>L.text).join(" "),s=oe(o.text,o.filterBase,a),l=Fe(o.text,s,o.filterInProgress),d=o.suggestions.filter(L=>L.parameter!=="placeholder"),c=E(d[0])?void 0:d[0],u=_(o.activeFormatType),m=c&&!u?pe(c.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&m.length>0)return!1;let h=m.filter(L=>L.is_tappable),g=c&&!u&&!this.callbacks.isWordOpen?.()?He(c.options,o.text,s,o.filterInProgress,this.phraseExactMatch)!==null:!1,f=l.trim().length>0,S=i&&o.products.length>0;if(h.length>0&&!g&&f&&!S||St(o.text,o.completedParams.length,a))return!1;let{rawQuery:y,completedParams:p}=N(o.text,o.completedParams),b=y.length<o.lastRawQuery.length,T=Math.abs(y.length-o.lastRawQuery.length),x=n&&y!==o.lastRawQuery;return b||T>=e||x?(this.doFetch(y,p),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var Ha="(hover: none) and (pointer: coarse)";var Wa="[data-aia-dropdown], [data-aia-input-wrapper]",Ua=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),Ct=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(Ua)),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(Ha):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(Wa))return!0;return!1}};var Ee=["January","February","March","April","May","June","July","August","September","October","November","December"],Ve=["S","M","T","W","T","F","S"],Eo=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],wo="aiaDate",Po="aiaDay",To=t=>String(t).padStart(2,"0");function B(t){return`${t.getFullYear()}-${To(t.getMonth()+1)}-${To(t.getDate())}`}function ti(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Ba(t){let e=ti(t).getTime()-ti(new Date).getTime();return Math.round(e/864e5)}function ni(t){let e=Ba(t);return e>=0&&e<7?Eo[t.getDay()]:ge(t)}function ge(t){return t.getFullYear()===new Date().getFullYear()?`${Ee[t.getMonth()]} ${t.getDate()}`:`${Ee[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function Ge(t){if(!t)return null;let e=Eo.findIndex(s=>s.toLowerCase()===t.trim().toLowerCase());if(e>=0){let s=ti(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=Ee.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 Lt(t){return`${Ee[t.month]} ${t.year}`}function ii(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function Co(t){return{year:t.getFullYear(),month:t.getMonth()}}function It(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function vo(){return{text:"",is_tappable:!1,kind:null}}function Ot(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(vo());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:ni(r),is_tappable:!0,kind:null,metadata:{[wo]:B(r),[Po]:o}})}for(;i.length%Ve.length!==0;)i.push(vo());return i}function At(t){let e=Ge(t);return e?B(e):null}function Q(t){let e=t?.metadata?.[wo];return typeof e=="string"?e:null}function kt(t){let e=t?.metadata?.[Po];return typeof e=="number"?e:null}function Va(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function re(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&Va(e)?e:t.ownerDocument??t}function Mt(t){return re(t).activeElement??null}function M(t){return t.ownerDocument??t}function Ga(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Lo(t){let e=re(t);return!Ga(e)||typeof e.getSelection=="function"?null:e}function Io(t){let e=Lo(t);if(!e)return null;let n=M(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function Oo(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 $e(t){let n=re(t).getSelection?.();return n||(M(t).getSelection?.()??null)}function ae(t){let e=$e(t);if(!e||e.rangeCount===0)return null;let n=Io(t);if(n){let i=Oo(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 we(t){let e=$e(t);if(!e||e.rangeCount===0)return null;let n=Io(t);if(!n)return e.getRangeAt(0);let i=Oo(e,n);if(!i)return null;let o=M(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function qe(t,e,n){let i=$e(t);if(!i)return null;if(Lo(t))return i.collapse(e,n),i;let o=M(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function Rt(t,e){let n=t?re(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var _t=2,$a="magicx-aia";function Ao(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function qa(t){let e=M(t),n=e.defaultView;if(!n?.getComputedStyle)return null;let i=t;for(;i&&i!==e.body&&i!==e.documentElement;){let o=i.scrollWidth>i.clientWidth,r=i.scrollHeight>i.clientHeight;if(o||r){let a=n.getComputedStyle(i);if(o&&Ao(a.overflowX)||r&&Ao(a.overflowY))return i}if(i.classList.contains($a))return null;i=i.parentElement}return null}function Dt(t){let e=we(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=qa(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+_t:i.left<r&&(n.scrollLeft-=r-i.left+_t)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,a=r+n.clientHeight;i.bottom>a?n.scrollTop+=i.bottom-a+_t:i.top<r&&(n.scrollTop-=r-i.top+_t)}}var Mo='[contenteditable="false"]',ri="strong[data-param-id]",Pe;function Ka(){if(Pe!==void 0)return Pe;let t=globalThis.Intl.Segmenter;if(!t)return Pe=null,null;try{Pe=new t(void 0,{granularity:"grapheme"})}catch{Pe=null}return Pe??null}function Nt(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(Mo))return!0;n=n.parentNode}return!1}function Ft(t){return M(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return Nt(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Ke(t){let e=Ft(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function Ht(t){let e=Ft(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function V(t){let e=ae(t);if(!e)return null;let n=e.node,i=e.offset;if(!t.contains(n))return null;if(n.nodeType===Node.ELEMENT_NODE){let o=n;if(Nt(o,t)&&o!==t)return null;let r=0;for(let a=0;a<i&&a<o.childNodes.length;a++)r+=ai(o.childNodes[a],t);return r+oi(o,t)}return n.nodeType!==Node.TEXT_NODE||Nt(n,t)?null:oi(n,t)+i}function ai(t,e){if(t.nodeType===Node.TEXT_NODE)return Nt(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(Mo))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=ai(o,e);return i}function oi(t,e){let n=Ft(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=M(t),i=Math.max(0,Math.min(e,Ht(t))),o=Ft(t),r=0,a=null,s=0,l=o.nextNode(),d=null;for(;l;){let u=l.data.length;if(i<r+u){a=l,s=i-r;break}if(i===r+u){let m=o.nextNode();m?(a=m,s=0):(a=l,s=u);break}r+=u,d=l,l=o.nextNode()}let c=n.createRange();if(a){let u=a.parentElement?.closest('strong[data-seg="completed"]');u&&u!==t&&t.contains(u)?s===0?c.setStartBefore(u):s===a.data.length?c.setStartAfter(u):c.setStart(a,s):c.setStart(a,s)}else d?c.setStart(d,d.data.length):c.setStart(t,0);c.collapse(!0),qe(t,c.startContainer,c.startOffset)&&(za(t,c,i),Dt(t))}function ko(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(ri)??null;return i&&e.contains(i)?i:null}function za(t,e,n){let i=ko(ae(t)?.node??null,t);if(i&&i!==ko(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function Ro(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=V(t);return i!==null&&n===`${i}:${e}`}function si(t){return re(t).activeElement===t}function Wt(t,e){if(!e||e.nodeType===void 0)return null;let n=e,o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(ri);if(!o||!t.contains(o))return null;let r=ae(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function Ut(t,e){let n=null;for(let a of t.querySelectorAll(ri))if(a.dataset.paramId===e){n=a;break}if(!n)return;let i=oi(n,t),o=i+ai(n,t),r=V(t);r!=null&&r>=i&&r<=o||F(t,i)}function Bt(t){let e=V(t);return e==null?!1:e>=Ht(t)}function Vt(t,e){if(e<=0)return 0;let n=Ka();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 li="aiaTime",qt=5;var ci=[12,1,2,3,4,5,6,7,8,9,10,11],di=Array.from({length:60/5},(t,e)=>e*5),ui=["AM","PM"];function Le(t){return(Math.round(t)%1440+1440)%1440}function pi(t){let e=Le(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function Gt(t){let e=t.hour%12+(t.period==="PM"?12:0);return Le(e*60+t.minute)}function ze(t){let{hour:e,minute:n,period:i}=pi(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function mi(t){let e=Le(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function Ce(t){return Le(Math.round(t/5)*5)}function _o(t,e){return Le(t+e)}var ja=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,Ya=/^(\d{1,2}):(\d{2})$/;function $t(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=ja.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:Gt({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=Ya.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 Do(t){let e=$t(t.editingText);if(e!=null)return Ce(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>$t(o.text)).filter(o=>o!=null);if(n.length>0)return Ce(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return Le((i.getHours()+1)*60)}function Kt(t){return{text:ze(t),is_tappable:!0,kind:null,metadata:{[li]:mi(t)}}}var je=30,Ye=["hour","minute","period"],gi={hour:ci.map(t=>({label:String(t)})),minute:di.map(t=>({label:String(t).padStart(2,"0")})),period:ui.map(t=>({label:t}))};function zt(t){return gi[t]}function Qe(t,e){let n=pi(Ce(e));return t==="hour"?ci.indexOf(n.hour):t==="minute"?di.indexOf(n.minute):ui.indexOf(n.period)}function Xe(t,e,n){let i=gi[t],o=Math.min(Math.max(n,0),i.length-1),r=pi(Ce(e));return Gt(t==="hour"?{...r,hour:ci[o]}:t==="minute"?{...r,minute:di[o]}:{...r,period:ui[o]})}function jt(t,e){let n=gi[t].length-1;return Math.min(Math.max(Math.round(e/je),0),n)}function se(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=N(t,e);return{query:t.trim(),raw_query:o,completed_params:ve(r,n),identified_params:Te(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function Yt(t,e){return t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement?t.selectionStart!=null&&t.selectionStart===t.value.length:t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?Bt(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function fi(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?V(t):null}var Qt=class{constructor(e,n){this.store=e;this.ctx=n}handleKeyDown(e){if(e.isComposing||e.keyCode===229)return;let n=this.store.get(),{listboxId:i,getOnSubmit:o}=this.ctx,r=e.target instanceof Node?e.target:null,a=this.getEffectiveColumns(r),s=o(),l=this.getTappableIndices(a);if((e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)&&(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight"))return;let d=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let c=n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&c?.is_tappable){e.preventDefault(),this.ctx.selectOption(c);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&c?.is_tappable&&this.ctx.selectOption(c),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let c=Yt(e.target,n),u=!!n.editingParam;if(!c&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(d)break;e.preventDefault();let g=A(n.activeFormatType)?this.dateEntryIndex(n,!1):l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:g});break}if(l.length===0)return;this.store.set({activeDropdownIndex:g});break}if(e.preventDefault(),l.length===0)return;if(A(n.activeFormatType)){this.stepDateWeek(n,7);break}if(n.filteredOptions.length>0){let g=Math.floor((n.filteredOptions.length-1)/a);if(Math.floor(n.activeDropdownIndex/a)===g){this.store.set({activeDropdownIndex:-1});break}}let m=l.indexOf(n.activeDropdownIndex),h=m<l.length-1?m+1:0;this.store.set({activeDropdownIndex:l[h]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!d)break;let m=Yt(e.target,n),h=!!n.editingParam;if(!m&&!h)break;e.preventDefault();let g=A(n.activeFormatType)?this.dateEntryIndex(n,!0):this.firstTappableInBottomRow(a)??l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:g});break}if(l.length===0)return;this.store.set({activeDropdownIndex:g});break}if(l.length===0)break;if(e.preventDefault(),A(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(),A(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%a<a-1){let m=n.activeDropdownIndex+1;m<n.filteredOptions.length&&n.filteredOptions[m]?.is_tappable&&this.store.set({activeDropdownIndex:m})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,m=n.editingTail;this.ctx.exitEditMode?.(),F(u,m);break}Yt(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),A(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=fi(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=fi(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let c=fi(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(se(c.text,c.completedParams,c.skippedParams,{identifiedParams:c.identifiedParams,isReady:c.isReady,customFields:c.customFields}))&&this.ctx.afterSubmit?.()}break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let c=n.filteredOptions.map((h,g)=>h.is_tappable?g:-1).filter(h=>h!==-1);if(c.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let h=e.shiftKey?c[c.length-1]:c[0];this.store.set({pillTapped:!0,activeDropdownIndex:h});break}e.preventDefault();let u=c.indexOf(n.activeDropdownIndex),m;if(u<0)m=e.shiftKey?c.length-1:0;else{let h=e.shiftKey?-1:1;m=(u+h+c.length)%c.length}this.store.set({activeDropdownIndex:c[m]});break}case"Escape":{if(n.dateRangeStart){this.store.set({pendingRangeStart:null});break}if(n.editingIdentified){this.ctx.exitEditingIdentified?.(),this.store.set({activeDropdownIndex:-1});break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingTail;this.ctx.exitEditMode?.(),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!Yt(e.target,n)&&!n.editingParam?!1:(e.preventDefault(),this.ctx.stepTime?.(e.key==="ArrowDown"?5:-5),!0);case"Enter":return i.touched?(e.preventDefault(),this.ctx.commitTime?.(),!0):!1;case"Escape":return i.touched?(this.store.set({timeDraft:null}),!0):!1;default:return!1}}firstTappableInBottomRow(e){let n=this.store.get();if(n.filteredOptions.length===0)return null;let o=Math.floor((n.filteredOptions.length-1)/e)*e;for(let r=o;r<n.filteredOptions.length;r++)if(n.filteredOptions[r]?.is_tappable)return r;return null}dateEntryIndex(e,n){let i=B(new Date),o=e.filteredOptions.findIndex(a=>Q(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=Rt(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=Rt(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=Rt(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var Xt=class{constructor(e,n,i={}){this.store=e;this.getOverrides=n;this.callbacks=i;this.unsubscribe=null;this.current=null;this.version=0;this.lastMiss=null;this.hasLoggedError=!1}start(){this.unsubscribe=this.store.subscribe(e=>this.sync(e)),this.sync(this.store.get())}dispose(){this.unsubscribe?.(),this.unsubscribe=null,this.cancel(),this.current=null}reset(){this.cancel(),this.current=null,this.lastMiss=null}refresh(){this.reset(),this.sync(this.store.get())}hasOverride(e){return!!this.getOverrides()?.[e]}owns(e,n){return this.hasOverride(e)&&!this.missCovers(e,n)}tick(e,n){let i=this.resolveTarget(e);if(!i||this.missCovers(i.parameter,i.query))return"no";let o=this.current;if(o&&o.key===i.key){if(o.query===i.query)return"owns";let r=Math.abs(i.query.length-o.query.length),a=i.query.length<o.query.length;if(n>1&&!a&&r<n)return"owns"}return this.ask(i),"asked"}sync(e){let n=this.resolveTarget(e);if(!n){this.current&&(this.cancel(),this.current=null),e.optionSearch&&this.store.set({optionSearch:null});return}this.current&&this.current.key===n.key||this.ask(n)}resolveTarget(e){if(_(e.activeFormatType)||e.editingIdentified)return null;let n=e.editingParam;if(n&&e.editingAnchor!=null)return this.hasOverride(n.suggestionParameter)?{mode:"edit",key:n.id,parameter:n.suggestionParameter,suggestion:{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options},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||Qa(a))return;this.logOnce(a),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=this.resolveTarget(this.store.get());if(!o||o.key!==e.key)return;n.length===0?this.lastMiss={parameter:e.parameter,query:e.query}:this.lastMiss?.parameter===e.parameter&&(this.lastMiss=null);let r={parameter:e.parameter,query:e.query,status:"done"};if(e.mode==="edit")this.store.set(a=>({editingParam:a.editingParam&&a.editingParam.id===e.key?{...a.editingParam,options:n}:a.editingParam,optionSearch:r}));else{let a={...e.suggestion,options:n};this.current&&this.current.key===e.key&&(this.current.key=a),this.store.set(s=>({suggestions:s.suggestions.map(l=>l===e.suggestion?a:l),optionSearch:r}))}n.length===0?this.callbacks.onMiss?.(e.mode,e.query):this.callbacks.onAnswer?.(e.mode,e.query)}setSearch(e,n){let i=this.store.get().optionSearch;i&&i.parameter===e.parameter&&i.query===e.query&&i.status===n||this.store.set({optionSearch:{parameter:e.parameter,query:e.query,status:n}})}cancel(){this.current?.abort?.abort(),this.version++}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] an optionOverrides entry threw or rejected \u2014 treated as no options. Later failures on this instance are not logged.",e))}};function Qa(t){return t instanceof Error&&t.name==="AbortError"}var Jt=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(E(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 hi="/products/",No="https://relative.invalid";function Xa(t){if(!t)return;let e;try{e=new URL(t,`${No}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===No?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function bi(t,e){let n=Xa(t.item_url)??Za(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:Fo(t.price,t.currency,e)},...Ja(t)&&{compareAtPrice:Fo(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function Ja(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 Fo(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 Za(t){if(!t.handle)return;let e=`${hi}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function Zt(t,e){return(t?.items.matched??[]).map(n=>bi(n,e))}var en=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=Zt(e,ie(this.getLanguage())),i=this.getMapper();if(!i)return n;try{let o=i(n,e?.items.matched??[]);if(Array.isArray(o))return o}catch(o){this.hasLoggedMapperError||(this.hasLoggedMapperError=!0,console.warn("[AIAutocomplete] mapProducts failed. The original cards are shown.",o))}return n}async run(e,n,i){if(!this.isEnabled())return;let o=this.getConfig();if(!o)return;if(e.trim().length===0){this.clear(i);return}let r=()=>n.aborted||!i()||!this.owns(o);try{let a=await o.fetch(e,n);if(r())return;let s=o.transform(a),l=Array.isArray(s)?s:[],d=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(d)}catch(a){if(n.aborted||es(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 es(t){return t instanceof Error&&t.name==="AbortError"}function ts(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function Ho(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:Ee.findIndex(n=>n.toLowerCase().startsWith(e))}function ns(t,e,n){let i=new Date(n.getFullYear(),t,e);if(i.getMonth()!==t||i.getDate()!==e)return null;let o=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(i>=o)return i;let r=new Date(n.getFullYear()+1,t,e);return r.getMonth()===t&&r.getDate()===e?r:null}function Wo(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function Ie(t,e={}){if(!t)return null;let n=e.today??new Date,i=ts(t.trim().toLowerCase()).replace(/\s+/g," "),o=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(i);if(o){let l=Wo(Number(o[1]),Number(o[2])-1,Number(o[3]));return l?B(l):null}let r=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(i);if(r){let l=Ho(r[1]);if(l>=0)return tn(l,Number(r[2]),r[3],n)}let a=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(i);if(a){let l=Ho(a[2]);if(l>=0)return tn(l,Number(a[1]),a[3],n)}let s=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(i);if(s){let l=Number(s[1]),d=Number(s[2]);return l>12&&d<=12?tn(d-1,l,s[3],n):d>12&&l<=12?tn(l-1,d,s[3],n):null}return null}function tn(t,e,n,i){if(n){if(n.length!==4)return null;let r=Wo(Number(n),t,e);return r?B(r):null}let o=ns(t,e,i);return o?B(o):null}function nn(t,e={}){let n=t.isoDate;return typeof n=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(n)?n:Ie(t.text,e)}var yi=" - ",on="aiaDateRangeStart",rn="aiaDateRangeEnd";function Je(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var Si=/^\d{4}-\d{2}-\d{2}$/;function Uo(t){if(!Si.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 is=/\s+(?:to|through|thru|until|til|till)\s+/g,os=/[-–—]/g;function rs(t){let e=[];for(let n of[is,os]){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 Ze(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of rs(t.trim())){let a=Ie(o.trim(),e);if(!a)continue;let s=Ie(r.trim(),e);!s||s<a||(n.add(`${a}|${s}`),i={start:a,end:s})}return n.size===1?i:null}function xi(t){let e=Uo(t.start),n=Uo(t.end);return!e||!n?"":t.start===t.end?ge(e):`${ge(e)}${yi}${ge(n)}`}function Bo(t,e){let n=Je(t,e);return{text:xi(n),is_tappable:!0,kind:null,metadata:{[on]:n.start,[rn]:n.end}}}function Oe(t,e={}){let n=t?.metadata?.[on],i=t?.metadata?.[rn];return typeof n=="string"&&typeof i=="string"&&Si.test(n)&&Si.test(i)?Je(n,i):Ze(t?.text,e)}var et="(max-width: 768px)";var as="var(--aia-option-row-height, 37px)",ss="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function vi(t,e){return e?Ti(1,Math.min(t,5)):Ti(1,Math.min(t,4))}function Ti(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${as} + ${ss})`}}function sn(t,e){return!e&&t>=5}function ln(t,e,n,i){if(!(!e&&t>=5&&ls(n,i))){let a=vi(t,e);return{...a,template:an(a.cols),scrollHintIndices:!e&&t>a.rows?[a.rows-1]:[]}}let r=6;return{...Ti(2,3),template:an(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function ls(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 cn(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 an(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function dn(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(et).matches}function un(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}function Vo(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 Go(t){if(!t)return ii();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function cs(t){let e=Ge(t);return e?Co(e):ii()}function $o(t,e){let n=bo(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(I=>I.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(I=>I.parameter==="placeholder").map(I=>I.text).join(" "),a=oe(t.text,Math.min(t.filterBase,t.text.length),r),l=a===0&&St(t.text,t.completedParams.length,r)?"":Fe(t.text,a,t.filterInProgress),d=o?.options??[],c=t.editingParam!=null&&t.editingAnchor!=null,u=!c&&!t.editingIdentified&&o?.type?.kind==="multi_select",m,h,g,f;if(c&&t.editingParam&&t.editingAnchor!=null){let I=t.editingParam.id,H=t.completedParams.some(ba=>ba.id===I),xe=t.caretOffset??t.editingAnchor,st=H?"":t.text.slice(t.editingAnchor,xe);h=st.trim(),g=t.editingParam.options,f=t.editingParam.suggestionParameter,m=pe(t.editingParam.options,st)}else h=l.trim(),g=d,f=o?.parameter,m=E(o)?d.map(I=>({...I,matchedText:t.text.slice(me(t.text,t.completedParams)),parameterLabel:uo(I.parameter)})):pe(d,l,t.traditionalAutocomplete);let S=t.optionSearch,y=S!=null&&f!=null&&S.parameter===f;y&&S.status==="done"&&S.query===h&&(m=g);let p=y&&S.status==="loading",b=e.showNonTappableOptions===!1;b&&(m=m.filter(I=>I.is_tappable));let T=c?h:t.text.slice(me(t.text,t.completedParams));u||(m=lo(m,T));let x=t.editingIdentified,L=c?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,P=x?x.format:K(L),w=c?t.editingParam?.suggestionParameter:o?.parameter,C=P==="location"&&w&&e.optionOverrides?.[w]?"options":P,k=c&&C==="date-range"?Oe(t.editingParam):null,G=null,te=null;if(A(C)){let I=W({...t,actionableSuggestions:i}),H=t.dateViewMonth;G=H&&H.key===I?{year:H.year,month:H.month}:x?Go(x.iso):k?Go(k.start):cs(t.editingParam?.text),m=Ot(G);let xe=t.pendingRangeStart;C==="date-range"&&xe&&xe.key===I&&(te=xe.iso)}let D=null;if(C==="time"){let I=W({...t,actionableSuggestions:i}),H=t.timeDraft;D=H&&H.key===I?{minutes:H.minutes,touched:!0}:{minutes:Do({editingText:c?t.editingParam?.text:null,options:c?t.editingParam?.options:o?.options}),touched:!1},m=[]}let v=null;if(C==="location"){let I=W({...t,actionableSuggestions:i}),H=t.locationSearch;if(H&&H.key===I){let{key:xe,...st}=H;v=st}else v={query:c?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};m=[]}let J=I=>b?I.is_tappable:!0,R;if(c){let I=t.editingParam?.options??[];R=t.editingParam!=null&&I.filter(J).length===0}else R=o!=null&&d.filter(J).length===0;D&&(R=!0),v&&(R=!0);let ne=Vo({inEditMode:c||x!=null,filteredOptionsLength:m.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||p,pillTapped:t.pillTapped,activePillHasNoOptions:R,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),at=ne&&t.activeDropdownIndex>=0&&!!m[t.activeDropdownIndex]?.is_tappable,Yn=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,$=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||p||Yn,Qi=$&&t.skeletonOptions!==null,fa=Qi&&t.skeletonOptions?t.skeletonOptions:m,ha=Qi?t.skeletonSuggestion:null;return{segments:n,actionableSuggestions:i,filteredOptions:m,dropdownLoading:$,dropdownOptions:fa,dropdownSuggestion:ha,skeletonExiting:Yn,activeFormatType:C,dateView:G,dateRangeStart:te,timeView:D,multiSelectView:u?{picked:t.multiSelectDraft?.key===W({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,locationView:v,placeholderText:r,optionQuery:h,isSearchingOptions:p,isDropdownOpen:ne,isActivePillSelected:at}}function pn(t){return t.mode!=="edit"?us(t):ps(t)}function ds(t,e,n){let i=t.find(E);if(!i?.options)return null;let o=e.slice(me(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 qo(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,a=n.find(c=>c.parameter!=="placeholder"&&!E(c));if(!a?.options||a.type?.kind==="multi_select")return null;let s=n.filter(c=>c.parameter==="placeholder").map(c=>c.text).join(" "),l=oe(e,i,s),d=He(a.options,e,l,o,r===!0);return d?{suggestion:a,option:d,matchText:d.text}:null}function us(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?qo(t):null)??ds(i,e,n):qo(t);if(!o)return null;let{suggestion:r,option:a,matchText:s}=o,l=s.toLowerCase(),d=e.toLowerCase().lastIndexOf(l),c=d>=0?d:Math.max(0,e.length-a.text.length),u=c+s.length,m=e.slice(c,u),g=u<e.length&&e[u]===" "?u+1:u,f={id:crypto.randomUUID(),placeholder:"",parameter:Y(a,r.parameter),text:m,value:a.value,kind:a.kind,suggestionParameter:r.parameter,suggestionValueType:r.type,suggestionPlaceholder:r.text,...t.mode==="submit"&&E(r)?We(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,f],suggestions:i.filter(S=>S!==r),filterBase:g,newParamId:f.id,caretOffset:g,activeDropdownIndex:-1},caretPos:g,option:a,suggestion:r}}function ps(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(b=>b.id===i.id))return null;let a=e.slice(o,r),s=bt(i.options,a);if(!s)return null;let l=s.text.toLowerCase(),d=a.toLowerCase().lastIndexOf(l),c=o+Math.max(0,d),u=c+s.text.length,m=e.slice(c,u),h=u<e.length&&e[u]===" "?u+1:u,g=e.length,f={id:crypto.randomUUID(),placeholder:"",...yt(i,s),text:m,value:s.value,kind:s.kind,options:i.options,metadata:s.metadata,icon:s.icon,icon_svg:s.icon_svg,image_url:s.image_url},S=n.length,y=0;for(let b=0;b<n.length;b++){let T=Z(e,n[b].text,y);if(T!==-1){if(T>=h){S=b;break}y=T+n[b].text.length}}let p=[...n];return p.splice(S,0,f),{patch:{text:e,completedParams:p,newParamId:f.id,filterBase:g,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:g,activeDropdownIndex:-1},caretPos:g,option:s}}function wi(t){return t.slice(t.search(/\S*$/))}function Ko(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function zo(t,e){let n="",i=0;for(let o of t){if(n+=Ko(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 Ei(t){return[...t].map(Ko).join("")}function tt(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(Ei),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:Ei(o[0])}));for(let o=n.length;o>=1;o--){let r=n.slice(n.length-o),a=r[o-1];for(let s=0;s+o<=i.length;s++){if(!r.slice(0,-1).every((u,m)=>i[s+m].folded===u))continue;let d=i[s+o-1],c=zo(d.text,a);if(c>0)return{typedWords:o,start:i[s].index,end:d.index+c}}}return null}function mn(t,e){let n=e?tt(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?wi(e):"",o=Ei(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:zo(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 ms=6e4;function gs(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function fs(t){return(t??z).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function hs(t){return De(t)?`Bearer ${await dt(t).getToken()}`:pt(t)}async function jo(t){try{let e=fs(t.apiConfig?.endpoint),n=ut(t.apiConfig),i=await hs(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&&gs(o)<=ms&&{keepalive:!0}})}catch{}}function le(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var Pi=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function bs(t,e,n){let i=Pi(t??"");if(i.length===0)return"";let r=Pi(e).slice(-i.length),a=Pi(n).slice(0,i.length);return r.join(" ")===i.join(" ")||a.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function Yo(t,e){let n=t.actionableSuggestions[0];if(!n)return null;let i=E(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(me(t.text,t.completedParams),s.length);if(i){let P=[...s.slice(c).matchAll(/\S+/g)],w=tt(e.text,s.slice(c)),C=P[P.length-(w?.typedWords??1)];s=s.slice(0,C?c+(C.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word===!0){let P=[...s.slice(c).matchAll(/\S+/g)],w=P[P.length-1];s=s.slice(0,w?c+(w.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word!==!1){let P=ao(s.slice(c),e.text);P>0&&(s=s.slice(0,s.length-P))}let u=s.length>0&&s[s.length-1]!==" ",m=t.activeFormatType??K(n),g=_(m)||n.type?.kind==="multi_select"?bs(n.lead_in,s,e.text):"",f=`${s}${u?" ":""}${g?`${g} `:""}${e.text} `,y=(l||d||i&&s.length===0)&&f.length>0?f[0].toUpperCase()+f.slice(1):f,p=y.toLowerCase().lastIndexOf(e.text.toLowerCase()),b=p>=0?y.slice(p,p+e.text.length):e.text,T=i?We(r):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text},x={id:crypto.randomUUID(),placeholder:"",...T,text:b,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},L=t.actionableSuggestions.length-1;return{patch:{text:y,filterBase:y.length,completedParams:[...t.completedParams,x],newParamId:x.id,caretOffset:y.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(P=>P.text!==e.text).map(P=>P.text),key:i?r:n.parameter,position:le(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:L}}function gn(t){let e=_(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 fn(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 hn=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=Z(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===""?fn(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=yt(i,e);this.deps.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(p=>p.text!==e.text).map(p=>p.text),key:a.suggestionParameter,position:le(i.options,e.text),chip_origin:"tap"});let s=n.text.slice(0,o),l=n.text.slice(r),d=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,u=l.length===0||l[0]!==" "?`${d} `:d,m=s+u+l,h=m.length,g={id:crypto.randomUUID(),placeholder:"",...a,text:d,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},f=n.completedParams.findIndex(p=>p.id===i.id),S=n.completedParams.filter(p=>p.id!==i.id),y=f>=0?Math.min(f,S.length):S.length;S.splice(y,0,g),this.deps.store.set({text:m,completedParams:S,newParamId:g.id,filterBase:h,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:h,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...gn(n)}),this.deps.startSelectionAnimationTimer(),this.deps.scheduleSetCursor(h),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=pn({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 Xo=33,Jo=70,Zo=120,er=50,fe="data-aia-placeholder-leaving",Ae=new WeakMap;function bn(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function Ss(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function tr(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||(tr(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 Qo(t,e){tr(t,e,0),e.timer=setTimeout(()=>nr(t,e),33)}function ir(t,e){let n=Ae.get(t);if(e===""){n&&(bn(n),Ae.delete(t)),t.removeAttribute(fe),delete t.dataset.placeholder;return}if(n?.target===e)return;if(Ss(t)){n&&bn(n),t.removeAttribute(fe),Ae.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&&bn(n),Ae.set(t,i),o){t.setAttribute(fe,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(fe),t.isConnected&&Qo(t,i)},170);return}t.removeAttribute(fe),Qo(t,i)}function or(t){let e=Ae.get(t);e&&(bn(e),Ae.delete(t))}var Ci="https://ai-autocomplete.com";function Sn(t=Ci){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 rr={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Best match",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",timeLabel:"Time",locationSearch:"Search a city or address",locationNoResults:"No places found",locationUseTyped:"Press Enter to use what you typed"},ys={language:"es",and:"y",proceed:"para continuar",select:"para seleccionar",skipHint:"para omitir",skip:"omitir",skipLabel:"Omitir",products:"Mejor coincidencia",soldOut:"Agotado",addToCart:"A\xF1adir al carrito",submit:"Buscar",scrollArrow:"Despl\xE1zate para ver m\xE1s opciones",keepTyping:"Sigue escribiendo",done:"Listo",timeLabel:"Hora",locationSearch:"Busca una ciudad o direcci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},Li={en:rr,es:ys,fr:{language:"fr",and:"et",proceed:"pour continuer",select:"pour s\xE9lectionner",skipHint:"pour passer",skip:"passer",skipLabel:"Passer",products:"Meilleure correspondance",soldOut:"\xC9puis\xE9",addToCart:"Ajouter au panier",submit:"Rechercher",scrollArrow:"Faites d\xE9filer pour voir plus d\u2019options",keepTyping:"Continuez \xE0 taper",done:"Termin\xE9",timeLabel:"Heure",locationSearch:"Rechercher une ville ou une adresse",locationNoResults:"Aucun lieu trouv\xE9",locationUseTyped:"Appuyez sur Entr\xE9e pour utiliser votre saisie"},"pt-BR":{language:"pt-BR",and:"e",proceed:"para continuar",select:"para selecionar",skipHint:"para pular",skip:"pular",skipLabel:"Pular",products:"Melhor correspond\xEAncia",soldOut:"Esgotado",addToCart:"Adicionar ao carrinho",submit:"Buscar",scrollArrow:"Role para ver mais op\xE7\xF5es",keepTyping:"Continue digitando",done:"Conclu\xEDdo",timeLabel:"Hor\xE1rio",locationSearch:"Pesquise uma cidade ou endere\xE7o",locationNoResults:"Nenhum lugar encontrado",locationUseTyped:"Pressione Enter para usar o que voc\xEA digitou"},it:{language:"it",and:"e",proceed:"per continuare",select:"per selezionare",skipHint:"per saltare",skip:"salta",skipLabel:"Salta",products:"Migliore corrispondenza",soldOut:"Esaurito",addToCart:"Aggiungi al carrello",submit:"Cerca",scrollArrow:"Scorri per vedere altre opzioni",keepTyping:"Continua a scrivere",done:"Fatto",timeLabel:"Ora",locationSearch:"Cerca una citt\xE0 o un indirizzo",locationNoResults:"Nessun luogo trovato",locationUseTyped:"Premi Invio per usare ci\xF2 che hai scritto"},tr:{language:"tr",and:"ve",proceed:"devam etmek i\xE7in",select:"se\xE7mek i\xE7in",skipHint:"atlamak i\xE7in",skip:"atla",skipLabel:"Atla",products:"En iyi e\u015Fle\u015Fme",soldOut:"T\xFCkendi",addToCart:"Sepete ekle",submit:"Ara",scrollArrow:"Daha fazla se\xE7enek i\xE7in kayd\u0131r",keepTyping:"Yazmaya devam et",done:"Tamam",timeLabel:"Saat",locationSearch:"\u015Eehir veya adres aray\u0131n",locationNoResults:"Yer bulunamad\u0131",locationUseTyped:"Yazd\u0131\u011F\u0131n\u0131z\u0131 kullanmak i\xE7in Enter'a bas\u0131n"},id:{language:"id",and:"dan",proceed:"untuk melanjutkan",select:"untuk memilih",skipHint:"untuk melewati",skip:"lewati",skipLabel:"Lewati",products:"Paling cocok",soldOut:"Habis",addToCart:"Tambah ke keranjang",submit:"Cari",scrollArrow:"Gulir untuk melihat opsi lainnya",keepTyping:"Teruskan mengetik",done:"Selesai",timeLabel:"Waktu",locationSearch:"Cari kota atau alamat",locationNoResults:"Tempat tidak ditemukan",locationUseTyped:"Tekan Enter untuk memakai yang Anda ketik"},pl:{language:"pl",and:"i",proceed:"aby kontynuowa\u0107",select:"aby wybra\u0107",skipHint:"aby pomin\u0105\u0107",skip:"pomi\u0144",skipLabel:"Pomi\u0144",products:"Najlepsze dopasowanie",soldOut:"Wyprzedane",addToCart:"Dodaj do koszyka",submit:"Szukaj",scrollArrow:"Przewi\u0144, aby zobaczy\u0107 wi\u0119cej opcji",keepTyping:"Pisz dalej",done:"Gotowe",timeLabel:"Godzina",locationSearch:"Szukaj miasta lub adresu",locationNoResults:"Nie znaleziono miejsc",locationUseTyped:"Naci\u015Bnij Enter, aby u\u017Cy\u0107 wpisanego tekstu"},de:{language:"de",and:"und",proceed:"zum Fortfahren",select:"zum Ausw\xE4hlen",skipHint:"zum \xDCberspringen",skip:"\xFCberspringen",skipLabel:"\xDCberspringen",products:"Beste Treffer",soldOut:"Ausverkauft",addToCart:"In den Warenkorb",submit:"Suchen",scrollArrow:"Scrolle f\xFCr weitere Optionen",keepTyping:"Weitertippen",done:"Fertig",timeLabel:"Uhrzeit",locationSearch:"Stadt oder Adresse suchen",locationNoResults:"Keine Orte gefunden",locationUseTyped:"Dr\xFCcke Enter, um deine Eingabe zu verwenden"},nl:{language:"nl",and:"en",proceed:"om door te gaan",select:"om te selecteren",skipHint:"om over te slaan",skip:"overslaan",skipLabel:"Overslaan",products:"Beste match",soldOut:"Uitverkocht",addToCart:"In winkelwagen",submit:"Zoeken",scrollArrow:"Scrol voor meer opties",keepTyping:"Blijf typen",done:"Klaar",timeLabel:"Tijd",locationSearch:"Zoek een stad of adres",locationNoResults:"Geen plaatsen gevonden",locationUseTyped:"Druk op Enter om je invoer te gebruiken"},sv:{language:"sv",and:"och",proceed:"f\xF6r att forts\xE4tta",select:"f\xF6r att v\xE4lja",skipHint:"f\xF6r att hoppa \xF6ver",skip:"hoppa \xF6ver",skipLabel:"Hoppa \xF6ver",products:"B\xE4sta matchning",soldOut:"Sluts\xE5ld",addToCart:"L\xE4gg i varukorgen",submit:"S\xF6k",scrollArrow:"Skrolla f\xF6r fler alternativ",keepTyping:"Forts\xE4tt skriva",done:"Klar",timeLabel:"Tid",locationSearch:"S\xF6k efter en stad eller adress",locationNoResults:"Inga platser hittades",locationUseTyped:"Tryck p\xE5 Enter f\xF6r att anv\xE4nda det du skrev"},nb:{language:"nb",and:"og",proceed:"for \xE5 fortsette",select:"for \xE5 velge",skipHint:"for \xE5 hoppe over",skip:"hopp over",skipLabel:"Hopp over",products:"Beste treff",soldOut:"Utsolgt",addToCart:"Legg i handlekurven",submit:"S\xF8k",scrollArrow:"Rull ned for \xE5 se flere alternativer",keepTyping:"Fortsett \xE5 skrive",done:"Ferdig",timeLabel:"Tid",locationSearch:"S\xF8k etter en by eller adresse",locationNoResults:"Fant ingen steder",locationUseTyped:"Trykk Enter for \xE5 bruke det du skrev"},da:{language:"da",and:"og",proceed:"for at forts\xE6tte",select:"for at v\xE6lge",skipHint:"for at springe over",skip:"spring over",skipLabel:"Spring over",products:"Bedste match",soldOut:"Udsolgt",addToCart:"L\xE6g i kurv",submit:"S\xF8g",scrollArrow:"Rul for flere muligheder",keepTyping:"Forts\xE6t med at skrive",done:"F\xE6rdig",timeLabel:"Tidspunkt",locationSearch:"S\xF8g efter en by eller adresse",locationNoResults:"Ingen steder fundet",locationUseTyped:"Tryk p\xE5 Enter for at bruge det, du skrev"},fi:{language:"fi",and:"ja",proceed:"jatkaaksesi",select:"valitaksesi",skipHint:"ohittaaksesi",skip:"ohita",skipLabel:"Ohita",products:"Paras vastaavuus",soldOut:"Loppuunmyyty",addToCart:"Lis\xE4\xE4 ostoskoriin",submit:"Hae",scrollArrow:"Vierit\xE4 n\xE4hd\xE4ksesi lis\xE4\xE4 vaihtoehtoja",keepTyping:"Jatka kirjoittamista",done:"Valmis",timeLabel:"Aika",locationSearch:"Hae kaupunkia tai osoitetta",locationNoResults:"Paikkoja ei l\xF6ytynyt",locationUseTyped:"Paina Enteri\xE4 k\xE4ytt\xE4\xE4ksesi kirjoittamaasi"},ja:{language:"ja",and:"\u3068",proceed:"\u3067\u6B21\u3078",select:"\u3067\u9078\u629E",skipHint:"\u3067\u30B9\u30AD\u30C3\u30D7",skip:"\u30B9\u30AD\u30C3\u30D7",skipLabel:"\u30B9\u30AD\u30C3\u30D7",products:"\u30D9\u30B9\u30C8\u30DE\u30C3\u30C1",soldOut:"\u58F2\u308A\u5207\u308C",addToCart:"\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",submit:"\u691C\u7D22",scrollArrow:"\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u3066\u4ED6\u306E\u5019\u88DC\u3092\u898B\u308B",keepTyping:"\u5165\u529B\u3092\u7D9A\u3051\u308B",done:"\u5B8C\u4E86",timeLabel:"\u6642\u523B",locationSearch:"\u90FD\u5E02\u540D\u3084\u4F4F\u6240\u3067\u691C\u7D22",locationNoResults:"\u5834\u6240\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",locationUseTyped:"\u5165\u529B\u3057\u305F\u5185\u5BB9\u3092\u4F7F\u3046\u306B\u306F Enter \u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044"},ko:{language:"ko",and:"\uBC0F",proceed:"\uACC4\uC18D",select:"\uC120\uD0DD",skipHint:"\uAC74\uB108\uB6F0\uAE30",skip:"\uAC74\uB108\uB6F0\uAE30",skipLabel:"\uAC74\uB108\uB6F0\uAE30",products:"\uCD5C\uC801 \uC77C\uCE58",soldOut:"\uD488\uC808",addToCart:"\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uB2F4\uAE30",submit:"\uAC80\uC0C9",scrollArrow:"\uB354 \uB9CE\uC740 \uC635\uC158\uC744 \uBCF4\uB824\uBA74 \uC2A4\uD06C\uB864\uD558\uC138\uC694",keepTyping:"\uACC4\uC18D \uC785\uB825\uD558\uC138\uC694",done:"\uC644\uB8CC",timeLabel:"\uC2DC\uAC04",locationSearch:"\uB3C4\uC2DC \uB610\uB294 \uC8FC\uC18C \uAC80\uC0C9",locationNoResults:"\uC7A5\uC18C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",locationUseTyped:"\uC785\uB825\uD55C \uB0B4\uC6A9\uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 Enter\uB97C \uB204\uB974\uC138\uC694"},"zh-CN":{language:"zh-CN",and:"\u548C",proceed:"\u7EE7\u7EED",select:"\u9009\u62E9",skipHint:"\u8DF3\u8FC7",skip:"\u8DF3\u8FC7",skipLabel:"\u8DF3\u8FC7",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u7F44",addToCart:"\u52A0\u5165\u8D2D\u7269\u8F66",submit:"\u641C\u7D22",scrollArrow:"\u5411\u4E0B\u6EDA\u52A8\u67E5\u770B\u66F4\u591A\u9009\u9879",keepTyping:"\u7EE7\u7EED\u8F93\u5165",done:"\u5B8C\u6210",timeLabel:"\u65F6\u95F4",locationSearch:"\u641C\u7D22\u57CE\u5E02\u6216\u5730\u5740",locationNoResults:"\u672A\u627E\u5230\u5730\u70B9",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F93\u5165\u7684\u5185\u5BB9"},"zh-TW":{language:"zh-TW",and:"\u548C",proceed:"\u7E7C\u7E8C",select:"\u9078\u64C7",skipHint:"\u7565\u904E",skip:"\u7565\u904E",skipLabel:"\u7565\u904E",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u5B8C",addToCart:"\u52A0\u5165\u8CFC\u7269\u8ECA",submit:"\u641C\u5C0B",scrollArrow:"\u5411\u4E0B\u6372\u52D5\u67E5\u770B\u66F4\u591A\u9078\u9805",keepTyping:"\u7E7C\u7E8C\u8F38\u5165",done:"\u5B8C\u6210",timeLabel:"\u6642\u9593",locationSearch:"\u641C\u5C0B\u57CE\u5E02\u6216\u5730\u5740",locationNoResults:"\u627E\u4E0D\u5230\u5730\u9EDE",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F38\u5165\u7684\u5167\u5BB9"}},xs={pt:"pt-BR",no:"nb",nn:"nb"};function O(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return Li[o?"zh-TW":"zh-CN"]}let i=xs[e]??e;return Object.prototype.hasOwnProperty.call(Li,i)?Li[i]:rr}function yn(t,e,n=O()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function xn(t){let e=a=>{a.ctrlKey||ar(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&&!ar(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 ar(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&Ts(o,i)||n!==0&&vs(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var sr=/^(auto|scroll|overlay)$/;function Ts(t,e){return t.scrollHeight<=t.clientHeight||!sr.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function vs(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!sr.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 lr=new WeakMap,cr=new WeakSet;function U(t,e,n){if(lr.set(t,n),cr.has(t))return;cr.add(t);let i=()=>lr.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 ce(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function q(t){t.offsetWidth}var Es={selectedIso:null,selectedRange:null,rangeStart:null};function ke(t){if(!A(t.activeFormatType))return Es;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?Je(i,o):null,rangeStart:t.dateRangeStart}}let n=Oe(t.editingParam);return{selectedIso:n?null:At(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart}}function Tn(t){return t.pendingStart?Je(t.pendingStart,t.highlightedIso??t.pendingStart):t.selected}function vn(t,e){if(t==null)return{selected:!1,inRange:!1};let{selectedIso:n,range:i}=e,o=t===n||i!=null&&(t===i.start||t===i.end),r=i!=null&&t>i.start&&t<i.end;return{selected:o,inRange:r}}var dr="data-aia-key";function X(t,e,n){let i=new Map;for(let a of Array.from(t.children)){let s=a.getAttribute(dr);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(dr,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 ur(t,e){if(!e.interactive)return null;let n=e.options[ce(t)];return n?.is_tappable?n:null}var ws={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=ur(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")&&ur(t,e)&&e.callbacks.onHighlight(ce(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,ce(t))}};function mr(t,e,n,i,o,r,a,s=!0){let l=t.querySelector(".magicx-aia-datepicker");if(!o||e.length===0){l?.remove();return}if(!l){l=Ls(),t.appendChild(l),q(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}U(l,ws,{options:e,callbacks:a,interactive:s});let d=l.querySelector(".magicx-aia-datepicker-month");d&&(d.textContent=Lt(o));let c=l.querySelector(".magicx-aia-datepicker-grid");c&&Ps(c,e,n,i,r)}function Ps(t,e,n,i,o){let r=B(new Date),a=Tn({pendingStart:o.rangeStart,highlightedIso:Q(e[n]),selected:o.selectedRange});X(t,e,{keyOf:(s,l)=>Q(s)??`pad-${l}`,create:s=>Cs(s),update:(s,l,d)=>{let c=Q(l),u=vn(c,{selectedIso:o.selectedIso,range:a}),m=d===n&&l.is_tappable;s.id=`${i}-option-${d}`,s.dataset.aiaIndex=String(d),s.setAttribute("aria-selected",String(m)),s.classList.toggle("magicx-aia-date-cell--past",c!=null&&c<r),s.classList.toggle("magicx-aia-date-cell--highlighted",m),s.classList.toggle("magicx-aia-date-cell--today",c!=null&&c===r),s.classList.toggle("magicx-aia-date-cell--selected",u.selected),s.classList.toggle("magicx-aia-date-cell--in-range",u.inRange)}})}function Cs(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=kt(t);if(n==null)return e.className="magicx-aia-date-cell magicx-aia-date-cell--blank",e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e;e.className="magicx-aia-date-cell magicx-aia-date-cell--day",e.tabIndex=0,e.setAttribute("aria-label",t.text);let i=document.createElement("span");return i.className="magicx-aia-date-cell-number",i.textContent=String(n),e.appendChild(i),e}function Ls(){let t=document.createElement("div");t.className="magicx-aia-datepicker",t.setAttribute("data-aia-datepicker","");let e=document.createElement("div");e.className="magicx-aia-datepicker-header";let n=document.createElement("span");n.className="magicx-aia-datepicker-month",n.setAttribute("data-aia-date-month",""),n.setAttribute("aria-live","polite"),e.append(pr("prev","Previous month","\u2039"),n,pr("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of Ve){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 pr(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 Is='<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>',gr="data-aia-location-body";function Os(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=Is;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 As(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 fr(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(gr)!==r){for(let s of Array.from(t.children))s.hasAttribute("data-aia-location-row")||s.remove();let a=As(r,n);a&&t.appendChild(a),t.setAttribute(gr,r)}X(t,o,{keyOf:(a,s)=>`${s}:${a.id}`,create:a=>Os(a),update:(a,s,l)=>{let d=l===e.highlighted;a.classList.toggle("magicx-aia-location-row--highlighted",d),a.setAttribute("aria-selected",String(d)),a.setAttribute("data-aia-index",String(l)),a.id=i(l)}})}var ee=new WeakMap,ks=0,he=new WeakMap,Ms='<svg class="magicx-aia-location-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>',be=t=>Mt(t.input)===t.input;function hr(t,e){let n=Mt(t);if(n instanceof HTMLElement&&n!==e.input&&n!==M(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=we(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Rs(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=$e(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=M(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var _s={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&Me(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function Me(t,e=!1){let n=he.get(t),i=ee.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&be(n)&&(n.returning=!0,Rs(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function Ds(t){let e=he.get(t),n=ee.get(t);if(!(!e||!n||be(e))){if(hr(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!be(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function Ns(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++ks}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=Ms;let i=document.createElement("input");i.type="text",i.className="magicx-aia-location-input",i.setAttribute("data-aia-location-input",""),i.setAttribute("autocomplete","off"),i.setAttribute("autocapitalize","words"),i.setAttribute("enterkeyhint","done"),i.spellcheck=!1,i.placeholder=e.locationSearch,i.setAttribute("aria-label",e.locationSearch),n.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-location-results",o.setAttribute("data-aia-location-results",""),o.setAttribute("aria-live","polite"),t.append(n,o);let r={input:i,field:n,results:o,returnTo:null,returnRange:null,returning:!1,declined:!1,widgetFocused:!1};return t.addEventListener("mousedown",a=>{!(a.target instanceof Node)||!n.contains(a.target)||(a.stopPropagation(),hr(t,r),ee.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>ee.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",()=>ee.get(t)?.callbacks.onLocationFocusChange(!0)),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,ee.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",a=>{let s=ee.get(t);if(!(!s||a.isComposing))switch(a.key){case"ArrowDown":case"ArrowUp":a.preventDefault(),s.callbacks.onLocationMove(a.key==="ArrowDown"?1:-1);return;case"Enter":if(a.preventDefault(),!s.interactive)return;Me(t,!0),s.callbacks.onLocationCommit();return;case"Escape":a.preventDefault(),a.stopPropagation(),r.declined=!0,Me(t);return;case"Backspace":if(i.value!=="")return;a.preventDefault(),r.declined=!0,Me(t);return}}),he.set(t,r),r}function br(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=he.get(e);n&&(be(n)&&Me(e),n.declined=!1,n.input.tabIndex=-1)}}function Sr(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=he.get(r);l&&be(l)&&Me(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let a=he.get(r)??Ns(r,n);a.input.tabIndex=0,ee.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),U(a.results,_s,ee.get(r)),a.input.value!==e.query&&!be(a)&&(a.input.value=e.query);let s=l=>`${r?.id}-row-${l}`;if(fr(a.results,e,n,s),e.highlighted>=0&&e.highlighted<e.places.length?a.input.setAttribute("aria-activedescendant",s(e.highlighted)):a.input.removeAttribute("aria-activedescendant"),a.widgetFocused=o.inputFocused??!1,o.inputFocused){if(!a.declined&&o.interactive!==!1&&!be(a)){let l=r;queueMicrotask(()=>{l.isConnected&&!he.get(l)?.declined&&Ds(l)})}}else{let l=a;setTimeout(()=>{if(l.widgetFocused)return;let d=l.returnTo;d&&Mt(d)===d||(l.declined=!1)},0)}}var Fs={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},yr=[125,69];function xr(t,e){return e?1:t===0?.7:t===1?.4:.2}function En(t,e,n,i,o=!1,r=!1,a=!1){let s=t.querySelector(".magicx-aia-pill-list");if(s||(s=document.createElement("span"),s.className="magicx-aia-pill-list",t.appendChild(s)),U(s,Fs,{onSelectPill:i,loading:r}),r&&e.length===0){s.setAttribute("data-aia-pill-list-loading",""),s.innerHTML="";for(let l=0;l<yr.length;l++){let d=yr[l],c=document.createElement("span");c.setAttribute("data-aia-pill-skeleton",""),c.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,c.style.width=`${d}px`,c.style.opacity=String(xr(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();X(s,e,{keyOf:l=>`${l.type?.kind??""}|${Ue(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"),Ue(l)){d.setAttribute("data-aia-smart-suggestion",E(l)?"header":"");let c=document.createElement("span");c.className="magicx-aia-smart-suggestion-text",c.textContent=l.text;let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-sparkle",u.innerHTML=vt,d.append(c,u)}else d.textContent=l.text;return d.disabled=!0,d},update:(l,d,c)=>{let u=l,m=a&&c===n&&!r,h=["magicx-aia-pill"];o&&h.push("magicx-aia-pill--rounded"),r&&h.push("magicx-aia-pill--skeleton"),u.className=h.join(" "),u.style.width="",u.style.opacity=String(xr(c,m)),u.dataset.aiaPillIndex=String(c),r?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),q(s);for(let l of s.querySelectorAll("[data-aia-pill]"))l.disabled=r}function Ii(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var Tr=32;function Oi(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 wn(t){let e=n=>{let i=Oi(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var vr=Intl.Segmenter,Er=vr?new vr(void 0,{granularity:"grapheme"}):null;function Pn(t){let e=t.trim().normalize("NFC").toUpperCase();if(Er)for(let n of Er.segment(e))return n.segment;return Array.from(e)[0]??"?"}var Cn=120,wr=360;function Hs(t){let e=t.pathname;return t.hostname==="cdn.shopify.com"&&e.startsWith("/s/files/")||e.startsWith("/cdn/shop/")?/\.png$/i.test(e)?{format:"pjpg"}:/\.webp$/i.test(e)?{format:null}:null:null}function Ai(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=Hs(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 ki(t,e){let n=Ai(t,e);return n===t?[t]:[n,t]}function Ln(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 nt(t){let e=t?.trim();return e?ki(e,360):[]}function Pr(t){return nt(t)[0]}var In=new WeakMap,Ri=new WeakMap,Lr=new WeakMap;function Ir(t,e,n,i,o,r="row",a="image",s=O(),l){let d=t.querySelector(".magicx-aia-products");if(e.length===0){d?.remove();return}if(!d){d=document.createElement("section"),d.className="magicx-aia-products",d.setAttribute("data-aia-products",""),d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${n}-products-label`);let m=document.createElement("div");m.className="magicx-aia-products-label",m.id=`${n}-products-label`,m.setAttribute("data-aia-products-label",""),m.textContent=s.products;let h=document.createElement("div");h.className="magicx-aia-products-row",h.setAttribute("data-aia-products-row",""),wn(h),d.append(m,h),t.appendChild(d)}d.setAttribute("data-aia-products-layout",r);let c=d.querySelector(".magicx-aia-products-label");c&&c.textContent!==s.products&&(c.textContent=s.products);let u=d.querySelector(".magicx-aia-products-row");if(u){X(u,e,{keyOf:m=>Vs(m,!!l),create:m=>Gs(m,i,o,a,s,l),update:(m,h,g)=>{In.set(m,h),Ws(m,h.price,h.compareAtPrice),m.id=`${n}-product-${g}`,m.dataset.aiaIndex=String(g),Lr.get(m)?.(a);let f=m.querySelector(".magicx-aia-product-badge");f&&f.textContent!==s.soldOut&&(f.textContent=s.soldOut);let S=m.querySelector(".magicx-aia-product-cart");S&&S.setAttribute("aria-label",Or(h,s))}}),q(u);for(let m of u.querySelectorAll("[data-aia-product]")){let h=Ri.get(m);h&&(Ri.delete(m),h())}}}function _i(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)i.tabIndex=e?0:-1}function Ws(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 Cr(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 Or(t,e){return`${e.addToCart}: ${t.title}`}var Mi="http://www.w3.org/2000/svg";function Us(){let t=document.createElementNS(Mi,"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(Mi,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(Mi,"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 Bs(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",Or(e,o)),r.tabIndex=0,r.appendChild(Us());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(In.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 Vs(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 Gs(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=nt(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=Pn(t.title))};if(Lr.set(a,f=>{f!==i&&(i=f,c||u())}),d){let f=document.createElement("img"),S=0;f.onload=()=>{s.setAttribute("data-aia-image-loaded",""),Cr(a,Ln(f.naturalWidth,f.naturalHeight))},f.onerror=()=>{let y=l[++S];if(y){f.src=y;return}c=!1,Cr(a,null),u()},f.className="magicx-aia-product-image",f.src=d,f.alt="",f.loading="lazy",f.decoding="async",s.appendChild(f)}else u();a.appendChild(s);let m=document.createElement("span");if(m.className="magicx-aia-product-body",t.vendor){let f=document.createElement("span");f.className="magicx-aia-product-vendor",f.textContent=t.vendor,m.appendChild(f)}let h=document.createElement("span");if(h.className="magicx-aia-product-title",h.textContent=t.title,m.appendChild(h),t.available===!1){a.setAttribute("data-aia-product-sold-out","");let f=document.createElement("span");f.className="magicx-aia-product-badge",f.textContent=o.soldOut,m.appendChild(f)}a.appendChild(m);let g=r&&t.available!==!1?Bs(a,t,r,n,o):null;return g&&(a.setAttribute("data-aia-product-has-cart",""),a.appendChild(g.el)),Ri.set(a,()=>{g?.arm(),t.url&&(a.href=t.url),a.addEventListener("click",f=>{f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||f.button!==0||(f.preventDefault(),e(In.get(a)??t))})}),a.addEventListener("keydown",f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),e(In.get(a)??t))}),a.addEventListener("focus",()=>n(!0)),a.addEventListener("blur",f=>{f.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),a}var Ar=40,kr=340,Mr=340,Rr=7,On="--aia-option-enter-delay";function An(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 kn(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 _r=10,Dr=44;function Mn(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 Nr="http://www.w3.org/2000/svg",$s=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function qs(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 Ks=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],zs=/^[a-zA-Z0-9#.,%\s()-]+$/;function js(t){let e=[];for(let n of Ks){let i=t.getAttribute(n);i===null||!zs.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function Fr(t){for(let e of Array.from(t.attributes))qs(e.name,e.value)&&t.removeAttribute(e.name);js(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!$s.has(n.localName)||n.namespaceURI!==Nr?n.remove():Fr(n)}else e.remove()}function de(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!==Nr||e.getElementsByTagName("parsererror").length>0?null:(Fr(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function it(t){return t.text}function ue(t){return ot(t)[0]??null}function ot(t){let e=Ys(t);return e?ki(e,120):[]}function Ys(t){if(!t)return null;let e=t.trim();if(e==="")return null;let n;try{n=new URL(e,typeof document>"u"?void 0:document.baseURI)}catch{return null}return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}function Re(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var Di={one:"item",other:"items"};function Hr(t,e=Di){let n=Re(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function Ni(t){return ue(t.image_url)!==null}var Rn=new Map;function Qs(t){let e=t.icon_svg;if(!e)return!1;let n=Rn.get(e);return n===void 0&&(n=de(e)!==null,Rn.size>=256&&Rn.clear(),Rn.set(e,n)),n}function _n(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&Ni(i)||e&&Qs(i))}var Wr=new WeakMap;function Xs(t,e,n){let i=e.length,o=dn(),r=Wr.get(t),a=n&&r&&un(r.options,e)?r.plan:null,s=!a&&!n&&sn(i,o)?cn(t):null,l=a??ln(i,o,s?.rowWidths??null,s?.gridWidth??null);return n||Wr.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 Ur(t,e){if(e.loading||!e.interactive)return null;let n=e.options[ce(t)];return n?.is_tappable?n:null}var Js={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=Ur(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!Mn(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)=>{Ur(t,e)&&e.onHighlight(ce(t))},onLeave:(t,e)=>e.onHighlight(-1,ce(t))};function Br(t,e,n,i,o,r,a,s="",l="below",d=!0,c=!0,u=!0,m=!0,h){let g=t.querySelector(".aia-grid");if(e.length===0){g?.remove();return}g||(g=document.createElement("div"),g.className="aia-grid magicx-aia-grid",g.setAttribute("data-scroll",""),g.style.setProperty("--aia-grid-min","250px"),g.style.setProperty("--aia-grid-max","1fr"),g.style.setProperty("--aia-grid-gap","0"),t.appendChild(g)),U(g,Js,{options:e,onSelect:i,onHighlight:o,loading:a,interactive:m});let f=g.dataset.aiaGroup!==s;g.dataset.aiaGroup=s;let S=_n(e,d,c);Zs(g,e,n,r,a,{showIcons:d&&S,showImages:c&&S,showCounts:u,picked:h});let y=Xs(g,e,a);el(g,e.length,y,a,l),f&&(g.scrollTop=0)}function Zs(t,e,n,i,o,r){let a=o?"1":"0",s=t.dataset.aiaGroup??"",{showIcons:l,showImages:d,showCounts:c}=r,u=l?g=>g.icon??g.icon_svg??"":()=>"",m=d?g=>ue(g.image_url)??"":()=>"",h=c?g=>Re(g.item_count)??"":()=>"";X(t,e,{keyOf:g=>`${g.text}\0${g.parameterLabel??""}\0${u(g)}\0${m(g)}\0${h(g)}\0${a}\0${s}`,create:(g,f)=>{let S=tl(g,o,r);return o||(S.dataset.aiaEntering=""),S},update:(g,f,S)=>{if(Fi.get(g)!==(f.matchedText??"")){let b=g.querySelector(".magicx-aia-option-text");b&&Vr(b,f),Fi.set(g,f.matchedText??"")}let y=S===n&&!o;g.id=`${i}-option-${S}`,g.dataset.aiaIndex=String(S),g.setAttribute("aria-selected",String(r.picked?r.picked.includes(f.text):y));let p=g.querySelector(".magicx-aia-checkbox");r.picked&&f.is_tappable?(p||(p=document.createElement("span"),p.className="magicx-aia-checkbox",p.setAttribute("aria-hidden","true"),g.querySelector(".magicx-aia-option-content")?.prepend(p)),p.dataset.checked=String(r.picked.includes(f.text)),p.textContent=r.picked.includes(f.text)?"\u2713":""):p?.remove(),g.classList.toggle("magicx-aia-option--highlighted",y),g.classList.toggle("magicx-aia-option--live-match",!!f.liveMatch&&!o)}})}function el(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(On,`${An(a,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var Fi=new WeakMap;function Vr(t,e){if(t.replaceChildren(),e.matchedText)for(let n of mn(it(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(it(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 tl(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?ot(t.image_url):[],d=l[0];if(d){let h=document.createElement("span");h.className="magicx-aia-option-image",h.setAttribute("aria-hidden","true");let g=document.createElement("img");g.setAttribute("alt",""),g.setAttribute("loading","lazy"),g.setAttribute("decoding","async"),g.setAttribute("referrerpolicy","no-referrer"),g.setAttribute("draggable","false");let f=0;g.onload=()=>h.setAttribute("data-aia-image-loaded",""),g.onerror=()=>{let S=l[++f];S?g.src=S:g.hidden=!0},g.src=d,h.appendChild(g),s.appendChild(h),r.dataset.aiaImage=""}let c=!d&&n&&t.icon_svg?de(t.icon_svg):null;if(c){let h=document.createElement("span");h.className="magicx-aia-option-icon",h.setAttribute("aria-hidden","true"),h.innerHTML=c,s.appendChild(h),t.icon&&(r.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",Vr(u,t),Fi.set(r,t.matchedText??""),s.appendChild(u),t.tag){let h=document.createElement("span");h.className="magicx-aia-option-tag",h.textContent=t.tag,s.appendChild(h)}let m=o?Re(t.item_count):null;if(m!==null){let h=document.createElement("span");h.className="magicx-aia-option-count",h.textContent=m,s.appendChild(h),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(s),r}var nl=120,il={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(Xe(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},$r=new WeakMap,Gr=new WeakMap;function qr(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=al(),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};$r.set(r,a),U(r,il,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=ze(e.minutes));for(let d of Ye){let c=r.querySelector(`[data-aia-time-column="${d}"]`);c&&ol(c,d,e.minutes)}}function ol(t,e,n){let i=Qe(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=Dn(t);if(o.settle)return;let r=i*je;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function Dn(t){let e=Gr.get(t);return e||(e={syncedTop:null,settle:null},Gr.set(t,e)),e}function rl(t,e,n){let i=Dn(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(()=>Kr(t,e,n),nl)}function Kr(t,e,n){let i=Dn(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=$r.get(t);if(!o||!o.interactive)return;let r=jt(n,e.scrollTop);r!==Qe(n,o.view.minutes)&&o.callbacks.onTimeChange(Xe(n,o.view.minutes,r))}function al(){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 Ye){if(r==="minute"){let a=document.createElement("span");a.className="magicx-aia-time-wheel-separator",a.textContent=":",n.appendChild(a)}n.appendChild(sl(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 sl(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),zt(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",()=>rl(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{Dn(n).settle&&Kr(t,n,e)}),n}var Wi="magicx-aia-scroll-arrow",Ui="data-aia-scroll-arrow",Se="data-aia-visible",Bi=1e3,Vi=160,Gi="--aia-scroll-arrow-bottom",zr="Scroll down for more options",ll="[data-aia-products-label]",cl=4,dl=8,ul=240;function pl(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,a=t.ownerDocument?.visibilityState==="hidden";if(!r||a||Hi(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)/ul),u=1-(1-c)*(1-c);t.scrollTop=o+e*u,c<1?r.call(n,d):i()};r.call(n,d)}function ml(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 jr(t=document,e=O()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=Wi,n.setAttribute(Ui,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(ml(t)),n}function gl(t){let e=t.style.gridTemplateColumns.trim();return e?Math.max(1,e.split(/\s+/).length):1}function Hi(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Nn({dropdown:t,grid:e,button:n}){let i=e.ownerDocument?.defaultView??(typeof window<"u"?window:null),o=!1;n.disabled=!0;let r=null,a=null,s=null,l=null,d=p=>{if(p){if(n.hasAttribute(Se))return;if(n.setAttribute(Se,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),Hi(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(Se)&&(n.disabled=!1)},Bi)}else n.removeAttribute(Se),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},c=p=>{let b=0,T=p;for(;T&&T!==t;)b+=T.offsetTop,T=T.offsetParent instanceof HTMLElement?T.offsetParent:null;return b},u=()=>{let p=t.querySelector(ll),b;if(p){let T=c(p)+p.offsetHeight/2;b=t.clientHeight-T-n.offsetHeight/2}else{let T=c(e),x=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;b=t.clientHeight-(T+e.offsetHeight)+(x>0?0:dl)}n.style.setProperty(Gi,`${Math.max(0,Math.round(b))}px`)},m=()=>{if(o||a!==null||s!==null)return;let p=e.querySelector("[data-aia-option][data-aia-loading]")!==null,b=e.scrollHeight-e.clientHeight-e.scrollTop;d(!p&&b>cl)},h=()=>{if(o)return;u();let p=e.getAttribute("data-aia-group")??"";if(p!==r){r=p,d(!1),a!==null&&clearTimeout(a);let b=e.querySelectorAll("[data-aia-option]").length,T=Hi(e)?0:kn(b,gl(e));a=setTimeout(()=>{a=null,m()},T);return}m()},g=()=>{o||a!==null||(d(!1),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,m()},Vi))};e.addEventListener("scroll",g,{passive:!0});let f=p=>p.preventDefault(),S=()=>{let p=i?(Number.parseFloat(i.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0):0,b=Math.max(1,e.clientHeight-p);pl(e,b,i,g)};n.addEventListener("mousedown",f),n.addEventListener("click",S);let y=null;return i&&typeof i.ResizeObserver=="function"&&(y=new i.ResizeObserver(()=>{u(),m()}),y.observe(e)),h(),{update:h,destroy(){o||(o=!0,a!==null&&clearTimeout(a),a=null,s!==null&&clearTimeout(s),s=null,l!==null&&clearTimeout(l),l=null,n.disabled=!0,e.removeEventListener("scroll",g),n.removeEventListener("mousedown",f),n.removeEventListener("click",S),y?.disconnect(),n.removeAttribute(Se),n.setAttribute("aria-hidden","true"))}}}var ye="data-aia-fit",rt="--aia-dropdown-fit-height";function Fn({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,a=null,s=null,l=()=>{t.removeAttribute(ye),t.style.removeProperty(rt)},d=h=>{let f=`${r}|${(h??t).scrollHeight}|${t.offsetWidth}`;if(s?.key===f)return s.height;let S=h?.scrollTop??0;t.removeAttribute(ye);let y=t.offsetHeight;return t.setAttribute(ye,""),h&&S&&(h.scrollTop=S),s={key:f,height:y},y},c=()=>{if(i)return;if(!e()){o=!1;return}o||(o=!0,l());let h=t.hasAttribute(ye),g=t.querySelector(".aia-grid")?.getAttribute("data-aia-group")??null,f=g!==r;r=g;let S=hl(t,n);if(S===null)return;let y=fl(t);if(h){if(d(y)<=S){l();return}}else if(t.offsetHeight<=S)return;let p=`${Math.max(160,Math.floor(S))}px`;t.style.getPropertyValue(rt)!==p&&t.style.setProperty(rt,p),h?f&&y&&(y.scrollTop=0):t.setAttribute(ye,"")},u=()=>{i||a!==null||!n||(a=n.requestAnimationFrame(()=>{a=null,c()}))},m=n?.visualViewport??null;return m?.addEventListener("resize",u),m?.addEventListener("scroll",u),n?.addEventListener("resize",u),n?.addEventListener("scroll",u,{capture:!0,passive:!0}),c(),{update:c,destroy(){i||(i=!0,a!==null&&n?.cancelAnimationFrame(a),m?.removeEventListener("resize",u),m?.removeEventListener("scroll",u),n?.removeEventListener("resize",u),n?.removeEventListener("scroll",u,{capture:!0}))}}}function fl(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function hl(t,e){if(!e)return null;let n=e.visualViewport,i=n?n.offsetTop:0,o=n?n.height:e.innerHeight;if(!o)return null;let r=t.offsetParent,a=r?r.getBoundingClientRect().top:0,s=r?a+t.offsetTop:t.getBoundingClientRect().top;return t.closest("[data-options-position]")?.getAttribute("data-options-position")==="above"?(r?s+t.offsetHeight:t.getBoundingClientRect().bottom)-i-8:i+o-s-8}var bl=[159,119,164];function Un(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()),xn(e),e}var Hn=new WeakMap;function Sl(t,e,n){let i=Hn.get(t);if(i||(i={button:jr(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),Hn.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=Nn({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var Wn=new WeakMap;function Yr(t){let e=Wn.get(t);if(e){e.update();return}Wn.set(t,Fn({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function $i(t){Wn.get(t)?.destroy(),Wn.delete(t);let e=Hn.get(t);e&&(e.controller?.destroy(),Hn.delete(t))}function Bn(t,e){let n=e.strings??O(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:a,showPills:s,isActivePillSelected:l,onSelect:d,onHighlight:c,onPillClick:u,onSkip:m}=e,h=Tt(e.pills,n.keepTyping),g=Et(h),f=s&&h.length>0,S=i.length>0,y=e.products.length>0,p=e.formatType==="time"&&e.timeView!=null,b=e.formatType==="location"&&e.locationView!=null,T=r&&(S||f||a||y||p||b);if(T?t.classList.add("magicx-aia-dropdown--visible"):t.classList.remove("magicx-aia-dropdown--visible"),a?t.setAttribute("data-aia-loading",""):t.removeAttribute("data-aia-loading"),!T){_i(t,!1),br(t),Yr(t);return}y?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let x=t.querySelector(".aia-stack");x||(x=document.createElement("div"),x.className="aia-stack",x.style.setProperty("--aia-stack-space","8px"),t.appendChild(x));let L=e.showSkipButton&&g&&!e.isInputEmpty,P=f||a&&s||L,w=x.querySelector(".magicx-aia-pill-bar");if(P){w||(w=document.createElement("div"),w.className="magicx-aia-pill-bar aia-cluster",w.setAttribute("data-nowrap",""),w.setAttribute("data-aia-pillbar",""),x.insertBefore(w,x.firstChild));let R=w.querySelector(".magicx-aia-pill-scroll");R||(R=document.createElement("span"),R.className="magicx-aia-pill-scroll",R.setAttribute("data-aia-pill-scroll",""),w.insertBefore(R,w.firstChild)),En(R,s?h:[],0,u,!0,a&&s,l),Tl(w,L,a||e.skipDisabled,h[0],m,n)}else w&&w.remove();let C=e.suggestions[0],k=C?`${C.parameter} ${C.text}`:"",G=A(e.formatType),te=G&&!a;Br(x,G?[]:i,o,d,c,e.listboxId,a,k,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)),Pl(x,!!e.multiSelectView&&!a,e.skipDisabled,e.onMultiSelectCommit,n.done),Sl(t,x.querySelector(".aia-grid"),n),mr(x,te?i:[],o,e.listboxId,te?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart},{onSelect:d,onHighlight:c,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),qr(x,e.formatType==="time"&&!a?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),Sr(x,e.formatType==="location"&&!a?e.locationView:null,n,{onLocationQuery:e.onLocationQuery,onLocationMove:e.onLocationMove,onLocationCommit:e.onLocationCommit,onLocationFocusChange:e.onLocationFocusChange},{interactive:!e.skipDisabled,inputFocused:e.isFocused??!1});let D=x.querySelector(".magicx-aia-skeleton-bars");if(a&&(!S||_(e.formatType))){if(!D){D=document.createElement("div"),D.className="magicx-aia-skeleton-bars",D.setAttribute("data-aia-skeleton-bars","");for(let R of bl){let ne=document.createElement("span");ne.className="magicx-aia-skeleton-bar",ne.style.width=`${R}px`,D.appendChild(ne)}x.appendChild(D)}}else D&&D.remove();Ir(x,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart),_i(t,!0);let v=x.querySelector(".magicx-aia-footer")??El(n),J=o>=0&&!!i[o]?.is_tappable;vl(v,yn(J,e.isInputEmpty,n)),v.isConnected||x.appendChild(v),yl(x,[".magicx-aia-pill-bar",".aia-grid","[data-aia-multi-actions]",".magicx-aia-datepicker",".magicx-aia-time-wheel","[data-aia-location]",".magicx-aia-skeleton-bars",".magicx-aia-products",".magicx-aia-footer"]),Yr(t)}function yl(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 xl={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function Tl(t,e,n,i,o,r){U(t,xl,{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 vl(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 El(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=Sn(),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 wl={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function Pl(t,e,n,i,o){let r=t.querySelector("[data-aia-multi-actions]");if(!e){r?.remove();return}if(!r){r=document.createElement("div"),r.dataset.aiaMultiActions="";let s=document.createElement("button");s.type="button",s.tabIndex=-1,s.className="magicx-aia-multi-done",s.disabled=!0,r.appendChild(s),t.appendChild(r),q(s)}U(r,wl,{commit:i,disabled:n});let a=r.querySelector("button");a&&(a.textContent=o,a.disabled=n)}function Qr(t,e){let n=Un(e.listboxId);return t.appendChild(n),{dropdown:n}}function qi(t,e,n){let i=ke(e);Bn(t.dropdown,{strings:n.strings,suggestions:e.editingIdentified?[{parameter:e.editingIdentified.parameter,text:j(e.editingIdentified.parameter),required:!0,options:e.filteredOptions}]:e.dropdownSuggestion??e.actionableSuggestions[0]?[{...e.dropdownSuggestion??e.actionableSuggestions[0],options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:e.actionableSuggestions,showPills:!0,showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:i.selectedIso,selectedDateRange:i.selectedRange,dateRangeStart:i.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,locationView:e.locationView,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:n.selectOption,onHighlight:(o,r)=>{r!==void 0&&n.store.get().activeDropdownIndex!==r||n.store.set({activeDropdownIndex:o})},onPillClick:n.setActivePill,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,onProductSelect:n.selectProduct,onProductFocusChange:o=>n.store.set({isFocused:o})})}var Xr=340;function Vn(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let c=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let u=t.getBoundingClientRect().height;if(u!==0){if(c===0||Math.abs(u-c)<.5){t.style.height=`${u}px`;return}t.style.height=`${c}px`,t.getBoundingClientRect(),t.style.height=`${u}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(c=>{for(let m of c)if(m.target!==t){n();return}let u=t.getBoundingClientRect().width;Math.abs(u-i)<.5||(i=u,n())}):null,r=()=>{for(let c of Array.from(t.children))o?.observe(c)},a=0,s=()=>{r(),n(),e.clearTimeout(a),a=e.setTimeout(n,340)},l=new e.MutationObserver(s);l.observe(t,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["data-placeholder","data-aia-empty"]}),o?.observe(t),r(),t.addEventListener("load",s,!0);let d=!1;return t.ownerDocument.fonts?.ready.then(()=>{d||n()}),n(),()=>{d=!0,t.removeEventListener("load",s,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(a),t.style.height=""}}var Cl=6,Ll=.3;function Jr(t){return t<=0?"0px":`${(-Math.min(Ll,2*Cl/t)).toFixed(3)}px`}var Zr=new Map;function Il(t,e,n){let i=Zr.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`;Zr.set(e,s),t.style.setProperty("--aia-chip-image-fit",s)},o.src=e}function Gn(t){let{input:e,segments:n,newParamId:i,editingParamId:o,placeholderText:r,isFocused:a}=t,s=t.showChipIcons??!0,l=t.showChipImages??!0,d=n.length===0;e.dataset.aiaEmpty=d?"true":"false",ir(e,d?r:"");let c=n.map(p=>p.type==="completed"?`${p.type}:${p.value}${s?p.param.icon??p.param.icon_svg??"":""}${l?ue(p.param.image_url)??"":""}`:`${p.type}:${p.value}`).join("\0"),u=e.dataset.segKey??"",m=e.dataset.newParamId??"",h=e.dataset.editingParamId??"";if(c===u&&(i??"")===m&&(o??"")===h)return;if(c===u){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let p of e.querySelectorAll("strong[data-param-id]")){let b=p.dataset.paramId,T=p.dataset.seg==="completed"&&b===i;p.classList.toggle("magicx-aia-shimmer-revealed",T),p.classList.toggle("magicx-aia-shimmer-sweep",T),p.classList.toggle("magicx-aia-segment--editing",b===o)}return}let g=a&&si(e)?V(e):null;e.dataset.segKey=c,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let f=M(e),S=f.createDocumentFragment(),y=0;for(let p of n)if(y+=p.value.length,p.type==="completed"){let b=f.createElement("strong");b.dataset.seg="completed",b.dataset.paramId=p.param.id;let T=p.param.id===i,x=p.param.id===o,L=["magicx-aia-segment","magicx-aia-segment--completed"];T&&L.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),x&&L.push("magicx-aia-segment--editing"),b.className=L.join(" "),b.style.letterSpacing=Jr(p.value.length);let P=l?ue(p.param.image_url):null;if(P){let C=f.createElement("span");C.className="magicx-aia-segment-image",C.setAttribute("contenteditable","false"),C.setAttribute("aria-hidden","true"),C.style.setProperty("--aia-chip-image",`url("${P}")`),Il(C,P,f),b.appendChild(C),b.dataset.aiaImage=""}let w=!P&&s&&p.param.icon_svg?de(p.param.icon_svg):null;if(w){let C=f.createElement("span");C.className="magicx-aia-segment-icon",C.setAttribute("contenteditable","false"),C.setAttribute("aria-hidden","true"),C.innerHTML=w,b.appendChild(C),p.param.icon&&(b.dataset.aiaIcon=p.param.icon)}b.appendChild(f.createTextNode(p.value)),S.appendChild(b)}else if(p.type==="identified"){let b=f.createElement("strong");b.dataset.seg="identified",b.dataset.paramId=p.param.id;let T=["magicx-aia-segment","magicx-aia-segment--completed"];p.param.id===o&&T.push("magicx-aia-segment--editing"),b.className=T.join(" "),b.style.letterSpacing=Jr(p.value.length),b.textContent=p.value,S.appendChild(b)}else S.appendChild(f.createTextNode(p.value));e.replaceChildren(S),e.dataset.aiaTextLength=String(y),g!=null?F(e,Math.max(0,Math.min(g,y))):a&&si(e)&&F(e,y)}var Ol='<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 ea(t=O()){let e=document.createElement("button");return e.type="button",e.className="magicx-aia-submit",e.setAttribute("aria-label",t.submit),e.setAttribute("data-aia-submit",""),e.innerHTML=Ol.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function Al(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function ta(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 na(t,e){let{listboxId:n}=e,i=Un(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",Al()?"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=ea(e.strings),o.appendChild(l),d=l):e.submitButton!==null&&(d=e.submitButton,d.hasAttribute("data-aia-submit")||d.setAttribute("data-aia-submit",""),d.setAttribute("data-aia-submit-slot",""),o.appendChild(d));let c=new AbortController,{signal:u}=c,m=!1,h=0,g=()=>{let p=Ke(a),T=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;e.handleChange(T)},f=()=>{let p=ae(a)?.node??null;if(!p||!a.contains(p))return null;let x=(p.nodeType===Node.ELEMENT_NODE?p:p.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return x&&Ro(a,x)?null:x};if(o.addEventListener("click",p=>{p.target?.closest("[data-aia-pill]")||a.getRootNode().activeElement?.closest("[data-aia-location]")||a.focus()},{signal:u}),a.addEventListener("input",()=>{m||(h=performance.now(),g(),e.handleCaretAfterInput(V(a)))},{signal:u}),M(a).addEventListener("selectionchange",()=>{let p=ae(a);if(!p||!a.contains(p.node))return;let b=p.collapsed?f():null,T=e.store.get(),x=T.editingParam?.id??T.editingIdentified?.id??null;if(b&&b!==x){e.startEditingParam(b);return}performance.now()-h<50||e.handleCaretMove(V(a))},{signal:u}),a.addEventListener("click",p=>{let b=Wt(a,p.target);b&&(e.startEditingParam(b),Ut(a,b))},{signal:u}),a.addEventListener("compositionstart",()=>{m=!0,a.setAttribute("data-aia-composing","true")},{signal:u}),a.addEventListener("compositionend",()=>{m=!1,a.removeAttribute("data-aia-composing"),g()},{signal:u}),a.addEventListener("beforeinput",p=>{let b=p,T=b.inputType;if(T==="insertParagraph"||T==="insertLineBreak"||T==="insertFromDrop"){p.preventDefault();return}if(T.startsWith("insert")||T.startsWith("delete")){let x=T.startsWith("delete")?"":b.data??"";e.replaceEditingRange(x)&&p.preventDefault()}},{signal:u}),a.addEventListener("paste",p=>{p.preventDefault();let b=(p.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let T=M(a),x=we(a);if(!x||!a.contains(x.startContainer))return;x.deleteContents();let L=T.createTextNode(b);x.insertNode(L),x.setStartAfter(L),qe(a,x.startContainer,x.startOffset),g()},{signal:u}),a.addEventListener("keydown",p=>e.handleKeyDown(p),{signal:u}),a.addEventListener("focus",()=>e.store.set({isFocused:!0}),{signal:u}),a.addEventListener("blur",()=>e.store.set({isFocused:!1}),{signal:u}),d&&d.addEventListener("click",p=>{let b=e.store.get();if(!(!!b.text||b.completedParams.length>0)||!e.onSubmit)return;p.stopPropagation(),e.endTypedWord?.();let x=e.store.get();e.onSubmit(se(x.text,x.completedParams,x.skippedParams,{identifiedParams:x.identifiedParams,isReady:x.isReady,customFields:x.customFields}))&&e.afterSubmit?.()},{signal:u}),e.autoFocus!==!1){a.focus();let p=ae(a);(!p||!a.contains(p.node))&&qe(a,a,0)}if(typeof ResizeObserver<"u"){let p=new ResizeObserver(()=>ta(a,s));p.observe(a),c.signal.addEventListener("abort",()=>p.disconnect(),{once:!0})}let y=Vn(r);return c.signal.addEventListener("abort",y,{once:!0}),{input:a,inlinePillContainer:s,dropdown:i,submitButton:l,abort:c}}function Ki(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:a}=t,{pillPlacement:s,setActivePill:l,selectOption:d,store:c}=n;i.setAttribute("aria-expanded",String(e.isDropdownOpen));let u=e.activeDropdownIndex>=0?`${n.listboxId}-option-${e.activeDropdownIndex}`:"";if(u?i.setAttribute("aria-activedescendant",u):i.removeAttribute("aria-activedescendant"),a){let y=n.strings??O();a.getAttribute("aria-label")!==y.submit&&a.setAttribute("aria-label",y.submit);let p=a.querySelector("svg");p&&p.getAttribute("aria-label")!==y.submit&&p.setAttribute("aria-label",y.submit);let b=!!e.text||e.completedParams.length>0;a.disabled=!b,a.toggleAttribute("data-aia-ready",b&&e.isReady)}let m=i.dataset.newParamId??"",h=e.newParamId!==null&&e.newParamId!==m;if(Gn({input:i,segments:e.segments,newParamId:e.newParamId,editingParamId:e.editingParam?.id??null,placeholderText:e.placeholderText,isFocused:e.isFocused,showChipIcons:n.showChipIcons??!0,showChipImages:n.showChipImages??!0}),s==="inline"){let y=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,p=xt(e.actionableSuggestions);y||p.length>0?En(o,p,0,l,!1,y,e.isActivePillSelected):Ii(o)}else Ii(o);ta(i,o),h?(i.focus(),F(i,e.caretOffset??e.text.length)):e.isFocused&&Ke(i)!==e.text&&F(i,e.text.length);let g=e.editingParam?{parameter:e.editingParam.suggestionParameter,text:e.editingParam.suggestionPlaceholder,required:!0,options:e.editingParam.options}:e.editingIdentified?{parameter:e.editingIdentified.parameter,text:j(e.editingIdentified.parameter),required:!0,options:[]}:null,f=e.dropdownSuggestion??g??e.actionableSuggestions[0],S=ke(e);Bn(r,{strings:n.strings,suggestions:f?[{...f,options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:g?[g]:e.actionableSuggestions,showPills:s==="dropdown",showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:S.selectedIso,selectedDateRange:S.selectedRange,dateRangeStart:S.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,locationView:e.locationView,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:d,onHighlight:(y,p)=>{p!==void 0&&c.get().activeDropdownIndex!==p||c.set({activeDropdownIndex:y})},onPillClick:l,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,onProductSelect:n.selectProduct,onProductFocusChange:y=>c.set({isFocused:y})})}function $n(t){let e=t,n=new Set,i=[],o=!1;return{get:()=>e,set:r=>{let a=typeof r=="function"?r(e):r,s=e;if(e={...e,...a},i.push([e,s]),!o){o=!0;try{let l=0;for(let d=i.shift();d;d=i.shift()){if(++l>1e4)throw i.length=0,new Error("createStore: notifications did not settle after 10000 deliveries \u2014 a listener is likely calling set() on every notification");let[c,u]=d;for(let m of n)m(c,u)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function ia(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 zi=new WeakSet,oa=new WeakMap;function aa(t){return t.nodeType===Node.DOCUMENT_NODE}function kl(t){return aa(t)?t:t.ownerDocument}function Ml(t){let e=oa.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(la),oa.set(t,i),i)}catch{return null}}function ra(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=la,e.appendChild(n)}function sa(t){if(typeof document>"u")return;let e=t??document;if(zi.has(e))return;let n=kl(e);if(aa(e)){let r=e.head??e.documentElement;if(!r)return;ra(n,r),zi.add(e);return}let i=Ml(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):ra(n,e),zi.add(e)}var la=`.aia-stack {
|
|
1
|
+
"use strict";var Jn=Object.defineProperty;var Sa=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var xa=Object.prototype.hasOwnProperty;var Ta=(t,e)=>{for(var n in e)Jn(t,n,{get:e[n],enumerable:!0})},va=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ya(e))!xa.call(t,o)&&o!==n&&Jn(t,o,{get:()=>e[o],enumerable:!(i=Sa(e,o))||i.enumerable});return t};var Ea=t=>va(Jn({},"__esModule",{value:!0}),t);var Vl={};Ta(Vl,{AIAutocomplete:()=>Xn,ATTRIBUTION_URL:()=>Li,DATE_RANGE_META_END:()=>ln,DATE_RANGE_META_START:()=>sn,DEFAULT_OPTION_COUNT_UNIT:()=>Fi,EDITOR_GROW_MS:()=>Zr,LOCATION_META_KEY:()=>Zn,LOCATION_MIN_QUERY:()=>ht,MULTI_SELECT_TOGGLE_MIN_PX:()=>Fr,MULTI_SELECT_TOGGLE_SLOP_PX:()=>Nr,ModeController:()=>De,OPTIONS_GRID_MOBILE_QUERY:()=>nt,OPTION_ENTER_DELAY_VAR:()=>Mn,OPTION_ENTER_FADE_MS:()=>Rr,OPTION_ENTER_RISE_MS:()=>_r,OPTION_ENTER_RISE_PX:()=>Dr,OPTION_ENTER_STAGGER_MS:()=>Mr,OPTION_IMAGE_WIDTH:()=>An,PLACEHOLDER_FADE_OUT_MS:()=>tr,PLACEHOLDER_LEAVING_ATTR:()=>ge,PLACEHOLDER_SWAP_GAP_MS:()=>nr,PLACEHOLDER_TYPE_MS:()=>Zo,PLACEHOLDER_WORD_PAUSE_MS:()=>er,PRODUCT_IMAGE_WIDTH:()=>Cr,PRODUCT_PATH_PREFIX:()=>Si,PRODUCT_ROW_PX_PER_LINE:()=>Er,RANGE_SEPARATOR:()=>Ti,SCHEMA_VERSION:()=>ni,SCROLL_ARROW_ATTR:()=>Vi,SCROLL_ARROW_BOTTOM_VAR:()=>qi,SCROLL_ARROW_CLASS:()=>Bi,SCROLL_ARROW_FADE_MS:()=>Gi,SCROLL_ARROW_LABEL:()=>Yr,SCROLL_ARROW_SCROLL_IDLE_MS:()=>$i,SCROLL_ARROW_VISIBLE_ATTR:()=>be,SKIPPED_PARAM_TEXT:()=>ti,SMART_SUGGESTION_SPARKLE_SVG:()=>Pt,TIME_META_KEY:()=>di,TIME_STEP_MINUTES:()=>jt,TIME_WHEEL_COLUMNS:()=>Xe,TIME_WHEEL_ROW_HEIGHT:()=>Qe,VIEWPORT_FIT_ATTR:()=>Se,VIEWPORT_FIT_HEIGHT_VAR:()=>st,WEEKDAY_LABELS:()=>$e,addMonths:()=>kt,attachProductRowWheel:()=>In,attachScrollArrow:()=>Wn,attachViewportFit:()=>Un,buildAttributionUrl:()=>Tn,buildDateOptions:()=>Mt,buildLocationOption:()=>bt,buildQuery:()=>D,buildSubmitResult:()=>re,buildTimeOption:()=>Yt,cellDay:()=>_t,cellIso:()=>Q,chipIdFromTap:()=>Vt,computeOptionsGridLayout:()=>wi,containScroll:()=>En,createStore:()=>zn,cursorIsAtEnd:()=>$t,dateCellMarks:()=>Pn,dateSelectionFor:()=>Me,extractPlainText:()=>je,formatAbsoluteDate:()=>me,formatDate:()=>oi,formatDateRange:()=>vi,formatOptionCount:()=>_e,formatPlace:()=>ei,formatTime:()=>Ye,getCursorOffset:()=>V,getFooterHint:()=>vn,hasSkippablePill:()=>Ct,highlightParts:()=>hn,identifiedParamLabel:()=>j,isCalendarFormat:()=>k,isMultiSelectToggleTap:()=>Dn,isOptionsGridMobileViewport:()=>mn,isPickerFormat:()=>_,isSmartSuggestion:()=>Ve,isTraditionalAutocompleteSuggestion:()=>w,isoDate:()=>B,isoTime:()=>fi,keepCaretOnChip:()=>Gt,labelTraditionalAutocomplete:()=>wt,locationEndpointFor:()=>St,matchTypedPhrase:()=>it,measureOptionsGrid:()=>pn,monthLabel:()=>Ot,needsOptionsGridMeasurement:()=>dn,optionCountLabel:()=>Ur,optionEnterDelayMs:()=>Rn,optionHasImage:()=>Hi,optionImageSources:()=>at,optionImageSrc:()=>ce,optionLabel:()=>rt,optionsEntranceDurationMs:()=>_n,optionsGridTemplateColumns:()=>cn,optionsShowLeadingVisuals:()=>Fn,parseDate:()=>qe,parseLooseDate:()=>Ae,parseLooseDateRange:()=>tt,parseTime:()=>zt,plainTextLength:()=>Bt,planOptionsGrid:()=>un,previousGraphemeBoundary:()=>qt,productFromMatchedItem:()=>yi,productImageSources:()=>ot,productImageSrc:()=>Ir,productInitial:()=>Ln,productPhotoFill:()=>On,productRowWheelTarget:()=>ki,productsFromCustomFields:()=>nn,renderEditableContent:()=>Kn,resolveFormatType:()=>K,resolveIdentifiedDate:()=>an,sameOptionRows:()=>gn,sanitizeOptionIconSvg:()=>le,scrollCaretIntoView:()=>Ht,selectedIsoFromText:()=>Rt,selectedRangeFor:()=>Oe,setCursorOffset:()=>N,shopifyImageSrc:()=>Mi,timeWheelIndex:()=>Je,timeWheelIndexFromScroll:()=>Xt,timeWheelRows:()=>Qt,toWireIdentifiedParams:()=>ve,typedFragment:()=>Ci,uiStringsFor:()=>O,visibleDateRange:()=>wn,watchEditorHeight:()=>qn,withSkippedParams:()=>Ee,withTimeWheelIndex:()=>Ze,withoutTraditionalAutocomplete:()=>Et});module.exports=Ea(Vl);function k(t){return t==="date"||t==="date-range"}function _(t){return t!=="options"}function K(t){return t?.type?.kind==="date"?"date":t?.type?.kind==="date_range"?"date-range":t?.type?.kind==="time"?"time":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 wa="https://api.ai-autocomplete.com",z=`${wa}/api/suggest`,pt=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),Zi=new WeakMap;function Fe(t){return t?.type==="accessToken"}function Pa(t){if(!(!t||Fe(t)))return t}function mt(t){let e=Zi.get(t.getAccessToken);return e||(e=new ut(t),Zi.set(t.getAccessToken,e)),e}function gt(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function ft(t){let e=Pa(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var Zn="aiaPlace",ht=2,eo=250;function ei(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function bt(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:ei(t),is_tappable:!0,kind:null,metadata:{[Zn]:{id:t.id}}}}function St(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??z,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 to(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 ve(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var ti="skipped";function Ee(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:ti,kind:null}));return i.length>0?[...t,...i]:t}var Ca="0.58.1",ni="1.0",no=!1;function Ia(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function te(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function La(t,e,n,i,o,r,a,s,l,d,c,u,p){let h=e.find(f=>f.parameter==="contact"&&f.metadata?.contact_account_count)?.metadata?.contact_account_count,g=typeof h=="number"?h:void 0;return{data:{raw_query:t,accepts_traditional_autocomplete:!0,client_option_parameters:p??[],completed_params:Ee(e.map(f=>Ia(f,n)),l??[]),...a&&a.length>0&&{identified_params:ve(a)},...s&&s.length>0&&{recently_suggested:s},...g!=null&&{contact_account_count:g},...d!==void 0&&{additional_context:d}},meta:{request_id:o,request_at:new Date().toISOString(),language:te(c),...u?.code&&Number.isFinite(u.rate)&&u.rate>0&&{currency:u.code,currency_rate:u.rate,...u.country!==void 0&&{country:u.country}},client_version:Ca,session_id:i,source:r,schema_version:ni}}}async function io(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function oo(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=La(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??z,s=await ro(a,JSON.stringify(r),i,n.signal);if(!s.ok)throw new Error(`API error: ${s.status} ${s.statusText}`);return s.json()}async function ro(t,e,n,i){let o=gt(n);if(Fe(n)){let a=mt(n),s=await a.getToken(),l=await io(t,o,s,e,i);if(l.status===401){let d=await a.getToken(!0);l=await io(t,o,d,e,i)}return l}let r=ft(n);return!r&&!no&&(no=!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 He=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function ao(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:te(n.language)}),o=await ro(t,i,n.apiConfig,n.signal);if(!o.ok)throw new He(o.status);return to(await o.json())}var yt=/[\p{L}\p{N}]/u,Aa=/['\u2019-]/;function so(t,e,n){let i=t[e];if(i===void 0)return!1;if(yt.test(i))return!0;let o=t[e+n];return Aa.test(i)&&o!==void 0&&yt.test(o)}function Oa(t,e,n){let i=e+n.length;return!(yt.test(n[0])&&so(t,e-1,-1)||yt.test(n[n.length-1])&&so(t,i,1))}function Z(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(Oa(t,r,e))return r;o===-1&&(o=r)}r=t.indexOf(e,r+1)}return o}function D(t,e){let n=t,i={},o=[],r=[],a=0;for(let s of e){let l=(i[s.parameter]??0)+1;i[s.parameter]=l;let c=`{{${s.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,u=h=>Z(n,s.text,h,g=>!r.some(f=>g<f.end&&g+s.text.length>f.start)),p=u(a);if(p===-1&&(p=u(0)),p!==-1){n=n.slice(0,p)+c+n.slice(p+s.text.length);let h=c.length-s.text.length;for(let g of r)g.start>=p+s.text.length&&(g.start+=h,g.end+=h);r.push({start:p,end:p+c.length}),a=p>=a?p+c.length:a+h}o.push({...s,placeholder:c})}return{rawQuery:n,completedParams:o}}function ne(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function Tt(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function We(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 lo(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 co(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function ka(t,e){let n=co(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function ue(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?co(i).trimStart():"";if(o)return t.filter(a=>!a.is_tappable||ka(a.text,o));let r=i.toLowerCase();return t.filter(a=>!a.is_tappable||a.text.toLowerCase().includes(r))}function xt(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 Ue(t,e,n,i,o){let r=We(e,n,i),a=xt(t,r);if(a||!o||!r.trim())return a;if(r===e.slice(n))return null;let s=e.lastIndexOf(" ",n-1)+1;return xt(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 po(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function Ma(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function j(t){let e=Ma(t);return e.length>0?e.join(" "):t}function Y(t,e){return t.parameter||e}function Be(t){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:j(t)}}function vt(t,e){let n=Y(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?Be(n):{parameter:n,suggestionParameter:t.suggestionParameter,suggestionValueType:t.suggestionValueType,suggestionPlaceholder:t.suggestionPlaceholder}}function w(t){return t?.type?.kind==="traditional_autocomplete"}function mo(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function Ve(t){return w(t)||t?.smart_suggestion===!0}function Et(t){return t.some(w)?t.filter(e=>!w(e)):t}function wt(t,e){return t.some(n=>w(n)&&!n.text)?t.map(n=>w(n)&&!n.text?{...n,text:e}:n):t}var Pt='<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 Ct(t){return t.some(e=>!w(e))}function go(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 fo(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 ho(t,e){let n=[],i=new Map;for(let o of[...t,...e]){if(o.parameter==="placeholder"||w(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 bo(t,e,n){if(t===e)return n;let i=Math.min(t.length,e.length),o=0;for(;o<i&&t[o]===e[o];)o++;if(o>=n)return n;let r=0;for(;r<i-o&&t[t.length-1-r]===e[e.length-1-r];)r++;return t.length-r<=n?n+(e.length-t.length):null}function It(t,e){let n=[],i=[],o=0;for(let r of e){let a=Z(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 pe(t,e){let{located:n}=It(t,e);return n.length>0?n[n.length-1].end:0}function So(t,e,n){let i=[],o=[],r=0;for(let a of n){let s=Z(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 yo(t,e,n=[]){let i=It(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=So(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 xo(t,e){let{located:n,missing:i}=It(t,e),o=new Set(i.map(a=>a.group).filter(Boolean)),r=n.map(a=>a.param).filter(a=>!o.has(a.group));return{valid:r,invalid:e.filter(a=>!r.includes(a))}}function Ge(t,e,n){let i=It(t,e).located,{located:o,missing:r}=So(t,i,n);return{valid:o.map(a=>a.param),invalid:r}}function To(t,e,n){let i=e?.endpoint??z,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${Ra(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,a)=>{let s=pt.get(a);return s?`https://${s}`:r})}function Ra(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 vo(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 _a(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var Da=100,Na=300,Fa=2,Lt=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?ho(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 vo(fetch(c,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let p=u??await oo(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=p.meta?.phrase_exact_match===!0;let h=(p.data.suggestions??[]).find(w),g=h?[]:p.data.input??[],f=v=>({id:crypto.randomUUID(),parameter:v.parameter,text:v.text,...v.type?{type:v.type}:{}}),S=g.filter(v=>v.source==="identified");this.callbacks.waitIdentified?.(S.filter(v=>v.state==="need_confirmation").map(f),a);let y=S.filter(v=>v.state!=="need_confirmation").map(f),m=this.callbacks.isWordOpen?.()??!1,b=this.store.get().text.toLowerCase(),T=v=>m&&b.endsWith(v.text.toLowerCase()),x=y.filter(v=>!T(v));m&&this.callbacks.holdIdentified?.(y.filter(T));let P=h?[h]:po(p.data.suggestions??[],this.getOptionOverrides()),I=g,C=I[I.length-1],E=this.store.get().text,J,G;if(C?.state==="in_progress"){G=!0;let v=E.toLowerCase().lastIndexOf(C.text.toLowerCase());J=v!==-1?v:r}else G=!1,J=r;let L=P.filter(v=>v.parameter!=="placeholder")[0],H=null;if(L&&!w(L)&&!m&&L.type?.kind!=="multi_select"&&!_(K(L))){let v=Ue(L.options,E,J,G,this.phraseExactMatch);v&&(H={id:crypto.randomUUID(),placeholder:"",parameter:Y(v,L.parameter),text:v.text,value:v.value,kind:v.kind,suggestionParameter:L.parameter,suggestionValueType:L.type,suggestionPlaceholder:L.text,options:L.options??[],metadata:v.metadata,icon:v.icon,icon_svg:v.icon_svg,image_url:v.image_url},P=P.filter(xe=>xe!==L),this.callbacks.onAutoMatch?.({active:L,matched:v,rawQuery:e}))}let de=p.data.custom_fields??null,M=this.callbacks.productsForResponse?.(de);this.store.set(v=>{let xe=H?[...v.completedParams,H]:v.completedParams,lt=Ge(v.text,xe,x).valid,ct=new Set(s.skippedParams.map(q=>q.id)),Ne=new Set(v.skippedParams.filter(q=>!ct.has(q.id)).map(q=>q.parameter));return{suggestions:Ne.size>0?P.filter(q=>q.parameter==="placeholder"||!Ne.has(q.parameter)):P,isLoading:!1,isReady:p.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:J,filterInProgress:G,identifiedParams:lt,customFields:de,traditionalAutocomplete:p.meta?.traditional_autocomplete===!0,...M!==void 0?{products:M}:{},...H?{completedParams:xe}:{}}}),this.callbacks.onResponse?.({requestId:d,funnelTelemetry:p.meta?.funnel_telemetry===!0,visibleImpression:p.meta?.visible_impression===!0})}catch(s){let l=_a(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?To(e,this.getApiConfig(),te(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(Fa)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},Da),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),Na)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;let a=o.suggestions.filter(P=>P.parameter==="placeholder").map(P=>P.text).join(" "),s=ne(o.text,o.filterBase,a),l=We(o.text,s,o.filterInProgress),d=o.suggestions.filter(P=>P.parameter!=="placeholder"),c=w(d[0])?void 0:d[0],u=_(o.activeFormatType),p=c&&!u?ue(c.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&p.length>0)return!1;let h=p.filter(P=>P.is_tappable),g=c&&!u&&!this.callbacks.isWordOpen?.()?Ue(c.options,o.text,s,o.filterInProgress,this.phraseExactMatch)!==null:!1,f=l.trim().length>0,S=i&&o.products.length>0;if(h.length>0&&!g&&f&&!S||Tt(o.text,o.completedParams.length,a))return!1;let{rawQuery:y,completedParams:m}=D(o.text,o.completedParams),b=y.length<o.lastRawQuery.length,T=Math.abs(y.length-o.lastRawQuery.length),x=n&&y!==o.lastRawQuery;return b||T>=e||x?(this.doFetch(y,m),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var Ha="(hover: none) and (pointer: coarse)";var Wa="[data-aia-dropdown], [data-aia-input-wrapper]",Ua=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),At=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(Ua)),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(Ha):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(Wa))return!0;return!1}};var we=["January","February","March","April","May","June","July","August","September","October","November","December"],$e=["S","M","T","W","T","F","S"],Po=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Co="aiaDate",Io="aiaDay",Eo=t=>String(t).padStart(2,"0");function B(t){return`${t.getFullYear()}-${Eo(t.getMonth()+1)}-${Eo(t.getDate())}`}function ii(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Ba(t){let e=ii(t).getTime()-ii(new Date).getTime();return Math.round(e/864e5)}function oi(t){let e=Ba(t);return e>=0&&e<7?Po[t.getDay()]:me(t)}function me(t){return t.getFullYear()===new Date().getFullYear()?`${we[t.getMonth()]} ${t.getDate()}`:`${we[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function qe(t){if(!t)return null;let e=Po.findIndex(s=>s.toLowerCase()===t.trim().toLowerCase());if(e>=0){let s=ii(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 Ot(t){return`${we[t.month]} ${t.year}`}function ri(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function Lo(t){return{year:t.getFullYear(),month:t.getMonth()}}function kt(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function wo(){return{text:"",is_tappable:!1,kind:null}}function Mt(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(wo());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:oi(r),is_tappable:!0,kind:null,metadata:{[Co]:B(r),[Io]:o}})}for(;i.length%$e.length!==0;)i.push(wo());return i}function Rt(t){let e=qe(t);return e?B(e):null}function Q(t){let e=t?.metadata?.[Co];return typeof e=="string"?e:null}function _t(t){let e=t?.metadata?.[Io];return typeof e=="number"?e:null}function Va(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function ie(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&Va(e)?e:t.ownerDocument??t}function Dt(t){return ie(t).activeElement??null}function R(t){return t.ownerDocument??t}function Ga(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Ao(t){let e=ie(t);return!Ga(e)||typeof e.getSelection=="function"?null:e}function Oo(t){let e=Ao(t);if(!e)return null;let n=R(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function ko(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 Ke(t){let n=ie(t).getSelection?.();return n||(R(t).getSelection?.()??null)}function oe(t){let e=Ke(t);if(!e||e.rangeCount===0)return null;let n=Oo(t);if(n){let i=ko(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 Pe(t){let e=Ke(t);if(!e||e.rangeCount===0)return null;let n=Oo(t);if(!n)return e.getRangeAt(0);let i=ko(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=Ke(t);if(!i)return null;if(Ao(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 Nt(t,e){let n=t?ie(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var Ft=2,$a="magicx-aia";function Mo(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function qa(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&&Mo(a.overflowX)||r&&Mo(a.overflowY))return i}if(i.classList.contains($a))return null;i=i.parentElement}return null}function Ht(t){let e=Pe(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=qa(t);if(!n||typeof e.getBoundingClientRect!="function")return;let i=e.getBoundingClientRect();if(i.height===0)return;let o=n.getBoundingClientRect();if(n.scrollWidth>n.clientWidth){let r=o.left+n.clientLeft,a=r+n.clientWidth;i.right>a?n.scrollLeft+=i.right-a+Ft:i.left<r&&(n.scrollLeft-=r-i.left+Ft)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,a=r+n.clientHeight;i.bottom>a?n.scrollTop+=i.bottom-a+Ft:i.top<r&&(n.scrollTop-=r-i.top+Ft)}}var _o='[contenteditable="false"]',si="strong[data-param-id]",Ce;function Ka(){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 Wt(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(_o))return!0;n=n.parentNode}return!1}function Ut(t){return R(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return Wt(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function je(t){let e=Ut(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function Bt(t){let e=Ut(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function V(t){let e=oe(t);if(!e)return null;let n=e.node,i=e.offset;if(!t.contains(n))return null;if(n.nodeType===Node.ELEMENT_NODE){let o=n;if(Wt(o,t)&&o!==t)return null;let r=0;for(let a=0;a<i&&a<o.childNodes.length;a++)r+=li(o.childNodes[a],t);return r+ai(o,t)}return n.nodeType!==Node.TEXT_NODE||Wt(n,t)?null:ai(n,t)+i}function li(t,e){if(t.nodeType===Node.TEXT_NODE)return Wt(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(_o))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=li(o,e);return i}function ai(t,e){let n=Ut(e),i=0,o=n.nextNode();for(;o;){if(o===t||t.nodeType===Node.ELEMENT_NODE&&t.contains(o))return i;i+=o.data.length,o=n.nextNode()}return i}function N(t,e){let n=R(t),i=Math.max(0,Math.min(e,Bt(t))),o=Ut(t),r=0,a=null,s=0,l=o.nextNode(),d=null;for(;l;){let u=l.data.length;if(i<r+u){a=l,s=i-r;break}if(i===r+u){let p=o.nextNode();p?(a=p,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)&&(za(t,c,i),Ht(t))}function Ro(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(si)??null;return i&&e.contains(i)?i:null}function za(t,e,n){let i=Ro(oe(t)?.node??null,t);if(i&&i!==Ro(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function Do(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=V(t);return i!==null&&n===`${i}:${e}`}function ci(t){return ie(t).activeElement===t}function Vt(t,e){if(!e||e.nodeType===void 0)return null;let n=e,o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(si);if(!o||!t.contains(o))return null;let r=oe(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function Gt(t,e){let n=null;for(let a of t.querySelectorAll(si))if(a.dataset.paramId===e){n=a;break}if(!n)return;let i=ai(n,t),o=i+li(n,t),r=V(t);r!=null&&r>=i&&r<=o||N(t,i)}function $t(t){let e=V(t);return e==null?!1:e>=Bt(t)}function qt(t,e){if(e<=0)return 0;let n=Ka();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 di="aiaTime",jt=5;var ui=[12,1,2,3,4,5,6,7,8,9,10,11],pi=Array.from({length:60/5},(t,e)=>e*5),mi=["AM","PM"];function Le(t){return(Math.round(t)%1440+1440)%1440}function gi(t){let e=Le(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function Kt(t){let e=t.hour%12+(t.period==="PM"?12:0);return Le(e*60+t.minute)}function Ye(t){let{hour:e,minute:n,period:i}=gi(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function fi(t){let e=Le(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function Ie(t){return Le(Math.round(t/5)*5)}function No(t,e){return Le(t+e)}var ja=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,Ya=/^(\d{1,2}):(\d{2})$/;function zt(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=ja.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:Kt({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=Ya.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 Fo(t){let e=zt(t.editingText);if(e!=null)return Ie(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>zt(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 Le((i.getHours()+1)*60)}function Yt(t){return{text:Ye(t),is_tappable:!0,kind:null,metadata:{[di]:fi(t)}}}var Qe=30,Xe=["hour","minute","period"],hi={hour:ui.map(t=>({label:String(t)})),minute:pi.map(t=>({label:String(t).padStart(2,"0")})),period:mi.map(t=>({label:t}))};function Qt(t){return hi[t]}function Je(t,e){let n=gi(Ie(e));return t==="hour"?ui.indexOf(n.hour):t==="minute"?pi.indexOf(n.minute):mi.indexOf(n.period)}function Ze(t,e,n){let i=hi[t],o=Math.min(Math.max(n,0),i.length-1),r=gi(Ie(e));return Kt(t==="hour"?{...r,hour:ui[o]}:t==="minute"?{...r,minute:pi[o]}:{...r,period:mi[o]})}function Xt(t,e){let n=hi[t].length-1;return Math.min(Math.max(Math.round(e/Qe),0),n)}function re(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=D(t,e);return{query:t.trim(),raw_query:o,completed_params:Ee(r,n),identified_params:ve(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function Jt(t,e){return t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement?t.selectionStart!=null&&t.selectionStart===t.value.length:t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?$t(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function bi(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?V(t):null}var Zt=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=Jt(e.target,n),u=!!n.editingParam;if(!c&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(d)break;e.preventDefault();let g=k(n.activeFormatType)?this.dateEntryIndex(n,!1):l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:g});break}if(l.length===0)return;this.store.set({activeDropdownIndex:g});break}if(e.preventDefault(),l.length===0)return;if(k(n.activeFormatType)){this.stepDateWeek(n,7);break}if(n.filteredOptions.length>0){let g=Math.floor((n.filteredOptions.length-1)/a);if(Math.floor(n.activeDropdownIndex/a)===g){this.store.set({activeDropdownIndex:-1});break}}let p=l.indexOf(n.activeDropdownIndex),h=p<l.length-1?p+1:0;this.store.set({activeDropdownIndex:l[h]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!d)break;let p=Jt(e.target,n),h=!!n.editingParam;if(!p&&!h)break;e.preventDefault();let g=k(n.activeFormatType)?this.dateEntryIndex(n,!0):this.firstTappableInBottomRow(a)??l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:g});break}if(l.length===0)return;this.store.set({activeDropdownIndex:g});break}if(l.length===0)break;if(e.preventDefault(),k(n.activeFormatType)){this.stepDateWeek(n,-7);break}if(n.activeDropdownIndex<a){this.store.set({activeDropdownIndex:-1});break}let c=l.indexOf(n.activeDropdownIndex),u=c>0?c-1:l.length-1;this.store.set({activeDropdownIndex:l[u]});break}case"ArrowRight":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%a<a-1){let p=n.activeDropdownIndex+1;p<n.filteredOptions.length&&n.filteredOptions[p]?.is_tappable&&this.store.set({activeDropdownIndex:p})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,p=n.editingTail;this.ctx.exitEditMode?.(),N(u,p);break}Jt(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=bi(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?.(),N(c,u);break}if(this.ctx.startEditingParamAtCaret){let c=bi(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let c=bi(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(re(c.text,c.completedParams,c.skippedParams,{identifiedParams:c.identifiedParams,isReady:c.isReady,customFields:c.customFields}))&&this.ctx.afterSubmit?.()}break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let c=n.filteredOptions.map((h,g)=>h.is_tappable?g:-1).filter(h=>h!==-1);if(c.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let h=e.shiftKey?c[c.length-1]:c[0];this.store.set({pillTapped:!0,activeDropdownIndex:h});break}e.preventDefault();let u=c.indexOf(n.activeDropdownIndex),p;if(u<0)p=e.shiftKey?c.length-1:0;else{let h=e.shiftKey?-1:1;p=(u+h+c.length)%c.length}this.store.set({activeDropdownIndex:c[p]});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?.(),N(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!Jt(e.target,n)&&!n.editingParam?!1:(e.preventDefault(),this.ctx.stepTime?.(e.key==="ArrowDown"?5:-5),!0);case"Enter":return i.touched?(e.preventDefault(),this.ctx.commitTime?.(),!0):!1;case"Escape":return i.touched?(this.store.set({timeDraft:null}),!0):!1;default:return!1}}firstTappableInBottomRow(e){let n=this.store.get();if(n.filteredOptions.length===0)return null;let o=Math.floor((n.filteredOptions.length-1)/e)*e;for(let r=o;r<n.filteredOptions.length;r++)if(n.filteredOptions[r]?.is_tappable)return r;return null}dateEntryIndex(e,n){let i=B(new Date),o=e.filteredOptions.findIndex(a=>Q(a)===i);if(o>=0)return o;let r=e.filteredOptions.map((a,s)=>a.is_tappable?s:-1).filter(a=>a!==-1);return(n?r[r.length-1]:r[0])??0}stepDateDay(e,n){for(let i=e.activeDropdownIndex+n;i>=0&&i<e.filteredOptions.length;i+=n)if(e.filteredOptions[i]?.is_tappable){this.store.set({activeDropdownIndex:i});return}}stepDateWeek(e,n){let i=e.activeDropdownIndex+n;this.store.set({activeDropdownIndex:e.filteredOptions[i]?.is_tappable?i:-1})}getTappableIndices(e){let i=this.store.get().filteredOptions.map((r,a)=>r.is_tappable?a:-1).filter(r=>r!==-1),o=Array.from({length:e},()=>[]);for(let r of i)o[r%e].push(r);return o.flat()}getEffectiveColumns(e){let n=Nt(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=Nt(e,`${this.ctx.listboxId}-option-0`)?.parentElement??null;for(;o;){let r=getComputedStyle(o).gridTemplateColumns;if(r&&r!=="none"){let a=r.split(" ").filter(Boolean).length;if(a>0)return a}if(o===n)break;o=o.parentElement}return this.ctx.columns}clickOrSelect(e,n,i,o){let r=Nt(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var en=class{constructor(e,n,i={}){this.store=e;this.getOverrides=n;this.callbacks=i;this.unsubscribe=null;this.current=null;this.version=0;this.lastMiss=null;this.hasLoggedError=!1}start(){this.unsubscribe=this.store.subscribe(e=>this.sync(e)),this.sync(this.store.get())}dispose(){this.unsubscribe?.(),this.unsubscribe=null,this.cancel(),this.current=null}reset(){this.cancel(),this.current=null,this.lastMiss=null}refresh(){this.reset(),this.sync(this.store.get())}hasOverride(e){return!!this.getOverrides()?.[e]}owns(e,n){return this.hasOverride(e)&&!this.missCovers(e,n)}tick(e,n){let i=this.resolveTarget(e);if(!i||this.missCovers(i.parameter,i.query))return"no";let o=this.current;if(o&&o.key===i.key){if(o.query===i.query)return"owns";let r=Math.abs(i.query.length-o.query.length),a=i.query.length<o.query.length;if(n>1&&!a&&r<n)return"owns"}return this.ask(i),"asked"}sync(e){let n=this.resolveTarget(e);if(!n){this.current&&(this.cancel(),this.current=null),e.optionSearch&&this.store.set({optionSearch:null});return}this.current&&this.current.key===n.key||this.ask(n)}resolveTarget(e){if(_(e.activeFormatType)||e.editingIdentified)return null;let n=e.editingParam;if(n&&e.editingAnchor!=null)return this.hasOverride(n.suggestionParameter)?{mode:"edit",key:n.id,parameter:n.suggestionParameter,suggestion:{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options},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||Qa(a))return;this.logOnce(a),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=this.resolveTarget(this.store.get());if(!o||o.key!==e.key)return;n.length===0?this.lastMiss={parameter:e.parameter,query:e.query}:this.lastMiss?.parameter===e.parameter&&(this.lastMiss=null);let r={parameter:e.parameter,query:e.query,status:"done"};if(e.mode==="edit")this.store.set(a=>({editingParam:a.editingParam&&a.editingParam.id===e.key?{...a.editingParam,options:n}:a.editingParam,optionSearch:r}));else{let a={...e.suggestion,options:n};this.current&&this.current.key===e.key&&(this.current.key=a),this.store.set(s=>({suggestions:s.suggestions.map(l=>l===e.suggestion?a:l),optionSearch:r}))}n.length===0?this.callbacks.onMiss?.(e.mode,e.query):this.callbacks.onAnswer?.(e.mode,e.query)}setSearch(e,n){let i=this.store.get().optionSearch;i&&i.parameter===e.parameter&&i.query===e.query&&i.status===n||this.store.set({optionSearch:{parameter:e.parameter,query:e.query,status:n}})}cancel(){this.current?.abort?.abort(),this.version++}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] an optionOverrides entry threw or rejected \u2014 treated as no options. Later failures on this instance are not logged.",e))}};function Qa(t){return t instanceof Error&&t.name==="AbortError"}var tn=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(d=>d.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(w(o))return;let r=i.filter((d,c)=>c!==e),a=n.suggestions.filter(d=>d.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:d}=D(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 Si="/products/",Ho="https://relative.invalid";function Xa(t){if(!t)return;let e;try{e=new URL(t,`${Ho}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===Ho?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function yi(t,e){let n=Xa(t.item_url)??Za(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:Wo(t.price,t.currency,e)},...Ja(t)&&{compareAtPrice:Wo(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function Ja(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 Wo(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 Za(t){if(!t.handle)return;let e=`${Si}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function nn(t,e){return(t?.items.matched??[]).map(n=>yi(n,e))}var on=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=nn(e,te(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||es(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 es(t){return t instanceof Error&&t.name==="AbortError"}function ts(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function Uo(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:we.findIndex(n=>n.toLowerCase().startsWith(e))}function ns(t,e,n){let i=new Date(n.getFullYear(),t,e);if(i.getMonth()!==t||i.getDate()!==e)return null;let o=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(i>=o)return i;let r=new Date(n.getFullYear()+1,t,e);return r.getMonth()===t&&r.getDate()===e?r:null}function Bo(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function Ae(t,e={}){if(!t)return null;let n=e.today??new Date,i=ts(t.trim().toLowerCase()).replace(/\s+/g," "),o=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(i);if(o){let l=Bo(Number(o[1]),Number(o[2])-1,Number(o[3]));return l?B(l):null}let r=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(i);if(r){let l=Uo(r[1]);if(l>=0)return rn(l,Number(r[2]),r[3],n)}let a=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(i);if(a){let l=Uo(a[2]);if(l>=0)return rn(l,Number(a[1]),a[3],n)}let s=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(i);if(s){let l=Number(s[1]),d=Number(s[2]);return l>12&&d<=12?rn(d-1,l,s[3],n):d>12&&l<=12?rn(l-1,d,s[3],n):null}return null}function rn(t,e,n,i){if(n){if(n.length!==4)return null;let r=Bo(Number(n),t,e);return r?B(r):null}let o=ns(t,e,i);return o?B(o):null}function an(t,e={}){let n=t.isoDate;return typeof n=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(n)?n:Ae(t.text,e)}var Ti=" - ",sn="aiaDateRangeStart",ln="aiaDateRangeEnd";function et(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var xi=/^\d{4}-\d{2}-\d{2}$/;function Vo(t){if(!xi.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 is=/\s+(?:to|through|thru|until|til|till)\s+/g,os=/[-–—]/g;function rs(t){let e=[];for(let n of[is,os]){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 tt(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of rs(t.trim())){let a=Ae(o.trim(),e);if(!a)continue;let s=Ae(r.trim(),e);!s||s<a||(n.add(`${a}|${s}`),i={start:a,end:s})}return n.size===1?i:null}function vi(t){let e=Vo(t.start),n=Vo(t.end);return!e||!n?"":t.start===t.end?me(e):`${me(e)}${Ti}${me(n)}`}function Go(t,e){let n=et(t,e);return{text:vi(n),is_tappable:!0,kind:null,metadata:{[sn]:n.start,[ln]:n.end}}}function Oe(t,e={}){let n=t?.metadata?.[sn],i=t?.metadata?.[ln];return typeof n=="string"&&typeof i=="string"&&xi.test(n)&&xi.test(i)?et(n,i):tt(t?.text,e)}var nt="(max-width: 768px)";var as="var(--aia-option-row-height, 37px)",ss="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function wi(t,e){return e?Ei(1,Math.min(t,5)):Ei(1,Math.min(t,4))}function Ei(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${as} + ${ss})`}}function dn(t,e){return!e&&t>=5}function un(t,e,n,i){if(!(!e&&t>=5&&ls(n,i))){let a=wi(t,e);return{...a,template:cn(a.cols),scrollHintIndices:!e&&t>a.rows?[a.rows-1]:[]}}let r=6;return{...Ei(2,3),template:cn(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function ls(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 pn(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 cn(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function mn(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(nt).matches}function gn(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}function $o(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 qo(t){if(!t)return ri();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function cs(t){let e=qe(t);return e?Lo(e):ri()}function Ko(t,e){let n=yo(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(A=>A.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(A=>A.parameter==="placeholder").map(A=>A.text).join(" "),a=ne(t.text,Math.min(t.filterBase,t.text.length),r),l=a===0&&Tt(t.text,t.completedParams.length,r)?"":We(t.text,a,t.filterInProgress),d=o?.options??[],c=t.editingParam!=null&&t.editingAnchor!=null,u=!c&&!t.editingIdentified&&o?.type?.kind==="multi_select",p,h,g,f;if(c&&t.editingParam&&t.editingAnchor!=null){let A=t.editingParam.id,F=t.completedParams.some(ba=>ba.id===A),Te=t.caretOffset??t.editingAnchor,dt=F?"":t.text.slice(t.editingAnchor,Te);h=dt.trim(),g=t.editingParam.options,f=t.editingParam.suggestionParameter,p=ue(t.editingParam.options,dt)}else h=l.trim(),g=d,f=o?.parameter,p=w(o)?d.map(A=>({...A,matchedText:t.text.slice(pe(t.text,t.completedParams)),parameterLabel:mo(A.parameter)})):ue(d,l,t.traditionalAutocomplete);let S=t.optionSearch,y=S!=null&&f!=null&&S.parameter===f;y&&S.status==="done"&&S.query===h&&(p=g);let m=y&&S.status==="loading",b=e.showNonTappableOptions===!1;b&&(p=p.filter(A=>A.is_tappable));let T=c?h:t.text.slice(pe(t.text,t.completedParams));u||(p=uo(p,T));let x=t.editingIdentified,P=c?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,I=x?x.format:K(P),C=c?t.editingParam?.suggestionParameter:o?.parameter,E=I==="location"&&C&&e.optionOverrides?.[C]?"options":I,J=c&&E==="date-range"?Oe(t.editingParam):null,G=null,ye=null;if(k(E)){let A=W({...t,actionableSuggestions:i}),F=t.dateViewMonth;G=F&&F.key===A?{year:F.year,month:F.month}:x?qo(x.iso):J?qo(J.start):cs(t.editingParam?.text),p=Mt(G);let Te=t.pendingRangeStart;E==="date-range"&&Te&&Te.key===A&&(ye=Te.iso)}let L=null;if(E==="time"){let A=W({...t,actionableSuggestions:i}),F=t.timeDraft;L=F&&F.key===A?{minutes:F.minutes,touched:!0}:{minutes:Fo({editingText:c?t.editingParam?.text:null,options:c?t.editingParam?.options:o?.options}),touched:!1},p=[]}let H=null;if(E==="location"){let A=W({...t,actionableSuggestions:i}),F=t.locationSearch;if(F&&F.key===A){let{key:Te,...dt}=F;H=dt}else H={query:c?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};p=[]}let de=A=>b?A.is_tappable:!0,M;if(c){let A=t.editingParam?.options??[];M=t.editingParam!=null&&A.filter(de).length===0}else M=o!=null&&d.filter(de).length===0;L&&(M=!0),H&&(M=!0);let v=$o({inEditMode:c||x!=null,filteredOptionsLength:p.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||m,pillTapped:t.pillTapped,activePillHasNoOptions:M,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),xe=v&&t.activeDropdownIndex>=0&&!!p[t.activeDropdownIndex]?.is_tappable,lt=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,ct=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||m||lt,Ne=ct&&t.skeletonOptions!==null,Ji=Ne&&t.skeletonOptions?t.skeletonOptions:p,q=Ne?t.skeletonSuggestion:null;return{segments:n,actionableSuggestions:i,filteredOptions:p,dropdownLoading:ct,dropdownOptions:Ji,dropdownSuggestion:q,skeletonExiting:lt,activeFormatType:E,dateView:G,dateRangeStart:ye,timeView:L,multiSelectView:u?{picked:t.multiSelectDraft?.key===W({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,locationView:H,placeholderText:r,optionQuery:h,isSearchingOptions:m,isDropdownOpen:v,isActivePillSelected:xe}}function fn(t){return t.mode!=="edit"?us(t):ps(t)}function ds(t,e,n){let i=t.find(w);if(!i?.options)return null;let o=e.slice(pe(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 zo(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,a=n.find(c=>c.parameter!=="placeholder"&&!w(c));if(!a?.options||a.type?.kind==="multi_select")return null;let s=n.filter(c=>c.parameter==="placeholder").map(c=>c.text).join(" "),l=ne(e,i,s),d=Ue(a.options,e,l,o,r===!0);return d?{suggestion:a,option:d,matchText:d.text}:null}function us(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?zo(t):null)??ds(i,e,n):zo(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,p=e.slice(c,u),g=u<e.length&&e[u]===" "?u+1:u,f={id:crypto.randomUUID(),placeholder:"",parameter:Y(a,r.parameter),text:p,value:a.value,kind:a.kind,suggestionParameter:r.parameter,suggestionValueType:r.type,suggestionPlaceholder:r.text,...t.mode==="submit"&&w(r)?Be(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,f],suggestions:i.filter(S=>S!==r),filterBase:g,newParamId:f.id,caretOffset:g,activeDropdownIndex:-1},caretPos:g,option:a,suggestion:r}}function ps(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(b=>b.id===i.id))return null;let a=e.slice(o,r),s=xt(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,p=e.slice(c,u),h=u<e.length&&e[u]===" "?u+1:u,g=e.length,f={id:crypto.randomUUID(),placeholder:"",...vt(i,s),text:p,value:s.value,kind:s.kind,options:i.options,metadata:s.metadata,icon:s.icon,icon_svg:s.icon_svg,image_url:s.image_url},S=n.length,y=0;for(let b=0;b<n.length;b++){let T=Z(e,n[b].text,y);if(T!==-1){if(T>=h){S=b;break}y=T+n[b].text.length}}let m=[...n];return m.splice(S,0,f),{patch:{text:e,completedParams:m,newParamId:f.id,filterBase:g,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:g,activeDropdownIndex:-1},caretPos:g,option:s}}function Ci(t){return t.slice(t.search(/\S*$/))}function jo(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function Yo(t,e){let n="",i=0;for(let o of t){if(n+=jo(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 Pi(t){return[...t].map(jo).join("")}function it(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(Pi),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:Pi(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,p)=>i[s+p].folded===u))continue;let d=i[s+o-1],c=Yo(d.text,a);if(c>0)return{typedWords:o,start:i[s].index,end:d.index+c}}}return null}function hn(t,e){let n=e?it(t,e):null;if(n&&n.typedWords>1)return[{text:t.slice(0,n.start),bold:!1},{text:t.slice(n.start,n.end),bold:!0},{text:t.slice(n.end),bold:!1}].filter(a=>a.text!=="");let i=e?Ci(e):"",o=Pi(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:Yo(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 ms=6e4;function gs(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function fs(t){return(t??z).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function hs(t){return Fe(t)?`Bearer ${await mt(t).getToken()}`:ft(t)}async function Qo(t){try{let e=fs(t.apiConfig?.endpoint),n=gt(t.apiConfig),i=await hs(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&&gs(o)<=ms&&{keepalive:!0}})}catch{}}function ae(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var Ii=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function bs(t,e,n){let i=Ii(t??"");if(i.length===0)return"";let r=Ii(e).slice(-i.length),a=Ii(n).slice(0,i.length);return r.join(" ")===i.join(" ")||a.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function Xo(t,e){let n=t.actionableSuggestions[0];if(!n)return null;let i=w(n),o=e.parameter;if(i&&!o)return null;let r=i&&o?o: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(pe(t.text,t.completedParams),s.length);if(i){let I=[...s.slice(c).matchAll(/\S+/g)],C=it(e.text,s.slice(c)),E=I[I.length-(C?.typedWords??1)];s=s.slice(0,E?c+(E.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word===!0){let I=[...s.slice(c).matchAll(/\S+/g)],C=I[I.length-1];s=s.slice(0,C?c+(C.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word!==!1){let I=lo(s.slice(c),e.text);I>0&&(s=s.slice(0,s.length-I))}let u=s.length>0&&s[s.length-1]!==" ",p=t.activeFormatType??K(n),g=_(p)||n.type?.kind==="multi_select"?bs(n.lead_in,s,e.text):"",f=`${s}${u?" ":""}${g?`${g} `:""}${e.text} `,y=(l||d||i&&s.length===0)&&f.length>0?f[0].toUpperCase()+f.slice(1):f,m=y.toLowerCase().lastIndexOf(e.text.toLowerCase()),b=m>=0?y.slice(m,m+e.text.length):e.text,T=i?Be(r):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text},x={id:crypto.randomUUID(),placeholder:"",...T,text:b,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},P=t.actionableSuggestions.length-1;return{patch:{text:y,filterBase:y.length,completedParams:[...t.completedParams,x],newParamId:x.id,caretOffset:y.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(I=>I.text!==e.text).map(I=>I.text),key:i?r:n.parameter,position:ae(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:P}}function bn(t){let e=_(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 Sn(t,e,n){let i=t.slice(0,e),o=t.slice(n),r=(i===""||i.endsWith(" "))&&o.startsWith(" ");return r&&(o=o.slice(1)),{text:i+o,removed:n-e+(r?1:0)}}var yn=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=Z(n.text,a.text,o);if(s!==-1){if(a.id===e){r=s;break}o=s+a.text.length}}r<0||this.deps.store.set({editingParam:i,editingAnchor:r,editingTail:r+i.text.length,caretOffset:r+i.text.length,activeDropdownIndex:-1,editingIdentified:null})}exit(){this.deps.store.get().editingParam&&this.deps.store.set({editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1})}replaceRange(e){let n=this.deps.store.get(),i=n.editingParam,o=n.editingAnchor,r=n.editingTail;if(!i||o==null||r==null||!n.completedParams.some(l=>l.id===i.id))return!1;let{text:a}=e===""?Sn(n.text,o,r):{text:n.text.slice(0,o)+e+n.text.slice(r)},s=o+e.length;return this.deps.store.set(l=>({text:a,completedParams:l.completedParams.filter(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=vt(i,e);this.deps.fireTelemetry("option",{raw_query:D(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(m=>m.text!==e.text).map(m=>m.text),key:a.suggestionParameter,position:ae(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,p=s+u+l,h=p.length,g={id:crypto.randomUUID(),placeholder:"",...a,text:d,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},f=n.completedParams.findIndex(m=>m.id===i.id),S=n.completedParams.filter(m=>m.id!==i.id),y=f>=0?Math.min(f,S.length):S.length;S.splice(y,0,g),this.deps.store.set({text:p,completedParams:S,newParamId:g.id,filterBase:h,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:h,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...bn(n)}),this.deps.startSelectionAnimationTimer(),this.deps.scheduleSetCursor(h),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=fn({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 Zo=33,er=70,tr=120,nr=50,ge="data-aia-placeholder-leaving",ke=new WeakMap;function xn(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function Ss(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function ir(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function or(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(ir(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(()=>or(t,e),33+i)}function Jo(t,e){ir(t,e,0),e.timer=setTimeout(()=>or(t,e),33)}function rr(t,e){let n=ke.get(t);if(e===""){n&&(xn(n),ke.delete(t)),t.removeAttribute(ge),delete t.dataset.placeholder;return}if(n?.target===e)return;if(Ss(t)){n&&xn(n),t.removeAttribute(ge),ke.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&&xn(n),ke.set(t,i),o){t.setAttribute(ge,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(ge),t.isConnected&&Jo(t,i)},170);return}t.removeAttribute(ge),Jo(t,i)}function ar(t){let e=ke.get(t);e&&(xn(e),ke.delete(t))}var Li="https://ai-autocomplete.com";function Tn(t=Li){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 sr={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Best match",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",timeLabel:"Time",locationSearch:"Search a city or address",locationNoResults:"No places found",locationUseTyped:"Press Enter to use what you typed"},ys={language:"es",and:"y",proceed:"para continuar",select:"para seleccionar",skipHint:"para omitir",skip:"omitir",skipLabel:"Omitir",products:"Mejor coincidencia",soldOut:"Agotado",addToCart:"A\xF1adir al carrito",submit:"Buscar",scrollArrow:"Despl\xE1zate para ver m\xE1s opciones",keepTyping:"Sigue escribiendo",done:"Listo",timeLabel:"Hora",locationSearch:"Busca una ciudad o direcci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},Ai={en:sr,es:ys,fr:{language:"fr",and:"et",proceed:"pour continuer",select:"pour s\xE9lectionner",skipHint:"pour passer",skip:"passer",skipLabel:"Passer",products:"Meilleure correspondance",soldOut:"\xC9puis\xE9",addToCart:"Ajouter au panier",submit:"Rechercher",scrollArrow:"Faites d\xE9filer pour voir plus d\u2019options",keepTyping:"Continuez \xE0 taper",done:"Termin\xE9",timeLabel:"Heure",locationSearch:"Rechercher une ville ou une adresse",locationNoResults:"Aucun lieu trouv\xE9",locationUseTyped:"Appuyez sur Entr\xE9e pour utiliser votre saisie"},"pt-BR":{language:"pt-BR",and:"e",proceed:"para continuar",select:"para selecionar",skipHint:"para pular",skip:"pular",skipLabel:"Pular",products:"Melhor correspond\xEAncia",soldOut:"Esgotado",addToCart:"Adicionar ao carrinho",submit:"Buscar",scrollArrow:"Role para ver mais op\xE7\xF5es",keepTyping:"Continue digitando",done:"Conclu\xEDdo",timeLabel:"Hor\xE1rio",locationSearch:"Pesquise uma cidade ou endere\xE7o",locationNoResults:"Nenhum lugar encontrado",locationUseTyped:"Pressione Enter para usar o que voc\xEA digitou"},it:{language:"it",and:"e",proceed:"per continuare",select:"per selezionare",skipHint:"per saltare",skip:"salta",skipLabel:"Salta",products:"Migliore corrispondenza",soldOut:"Esaurito",addToCart:"Aggiungi al carrello",submit:"Cerca",scrollArrow:"Scorri per vedere altre opzioni",keepTyping:"Continua a scrivere",done:"Fatto",timeLabel:"Ora",locationSearch:"Cerca una citt\xE0 o un indirizzo",locationNoResults:"Nessun luogo trovato",locationUseTyped:"Premi Invio per usare ci\xF2 che hai scritto"},tr:{language:"tr",and:"ve",proceed:"devam etmek i\xE7in",select:"se\xE7mek i\xE7in",skipHint:"atlamak i\xE7in",skip:"atla",skipLabel:"Atla",products:"En iyi e\u015Fle\u015Fme",soldOut:"T\xFCkendi",addToCart:"Sepete ekle",submit:"Ara",scrollArrow:"Daha fazla se\xE7enek i\xE7in kayd\u0131r",keepTyping:"Yazmaya devam et",done:"Tamam",timeLabel:"Saat",locationSearch:"\u015Eehir veya adres aray\u0131n",locationNoResults:"Yer bulunamad\u0131",locationUseTyped:"Yazd\u0131\u011F\u0131n\u0131z\u0131 kullanmak i\xE7in Enter'a bas\u0131n"},id:{language:"id",and:"dan",proceed:"untuk melanjutkan",select:"untuk memilih",skipHint:"untuk melewati",skip:"lewati",skipLabel:"Lewati",products:"Paling cocok",soldOut:"Habis",addToCart:"Tambah ke keranjang",submit:"Cari",scrollArrow:"Gulir untuk melihat opsi lainnya",keepTyping:"Teruskan mengetik",done:"Selesai",timeLabel:"Waktu",locationSearch:"Cari kota atau alamat",locationNoResults:"Tempat tidak ditemukan",locationUseTyped:"Tekan Enter untuk memakai yang Anda ketik"},pl:{language:"pl",and:"i",proceed:"aby kontynuowa\u0107",select:"aby wybra\u0107",skipHint:"aby pomin\u0105\u0107",skip:"pomi\u0144",skipLabel:"Pomi\u0144",products:"Najlepsze dopasowanie",soldOut:"Wyprzedane",addToCart:"Dodaj do koszyka",submit:"Szukaj",scrollArrow:"Przewi\u0144, aby zobaczy\u0107 wi\u0119cej opcji",keepTyping:"Pisz dalej",done:"Gotowe",timeLabel:"Godzina",locationSearch:"Szukaj miasta lub adresu",locationNoResults:"Nie znaleziono miejsc",locationUseTyped:"Naci\u015Bnij Enter, aby u\u017Cy\u0107 wpisanego tekstu"},de:{language:"de",and:"und",proceed:"zum Fortfahren",select:"zum Ausw\xE4hlen",skipHint:"zum \xDCberspringen",skip:"\xFCberspringen",skipLabel:"\xDCberspringen",products:"Beste Treffer",soldOut:"Ausverkauft",addToCart:"In den Warenkorb",submit:"Suchen",scrollArrow:"Scrolle f\xFCr weitere Optionen",keepTyping:"Weitertippen",done:"Fertig",timeLabel:"Uhrzeit",locationSearch:"Stadt oder Adresse suchen",locationNoResults:"Keine Orte gefunden",locationUseTyped:"Dr\xFCcke Enter, um deine Eingabe zu verwenden"},nl:{language:"nl",and:"en",proceed:"om door te gaan",select:"om te selecteren",skipHint:"om over te slaan",skip:"overslaan",skipLabel:"Overslaan",products:"Beste match",soldOut:"Uitverkocht",addToCart:"In winkelwagen",submit:"Zoeken",scrollArrow:"Scrol voor meer opties",keepTyping:"Blijf typen",done:"Klaar",timeLabel:"Tijd",locationSearch:"Zoek een stad of adres",locationNoResults:"Geen plaatsen gevonden",locationUseTyped:"Druk op Enter om je invoer te gebruiken"},sv:{language:"sv",and:"och",proceed:"f\xF6r att forts\xE4tta",select:"f\xF6r att v\xE4lja",skipHint:"f\xF6r att hoppa \xF6ver",skip:"hoppa \xF6ver",skipLabel:"Hoppa \xF6ver",products:"B\xE4sta matchning",soldOut:"Sluts\xE5ld",addToCart:"L\xE4gg i varukorgen",submit:"S\xF6k",scrollArrow:"Skrolla f\xF6r fler alternativ",keepTyping:"Forts\xE4tt skriva",done:"Klar",timeLabel:"Tid",locationSearch:"S\xF6k efter en stad eller adress",locationNoResults:"Inga platser hittades",locationUseTyped:"Tryck p\xE5 Enter f\xF6r att anv\xE4nda det du skrev"},nb:{language:"nb",and:"og",proceed:"for \xE5 fortsette",select:"for \xE5 velge",skipHint:"for \xE5 hoppe over",skip:"hopp over",skipLabel:"Hopp over",products:"Beste treff",soldOut:"Utsolgt",addToCart:"Legg i handlekurven",submit:"S\xF8k",scrollArrow:"Rull ned for \xE5 se flere alternativer",keepTyping:"Fortsett \xE5 skrive",done:"Ferdig",timeLabel:"Tid",locationSearch:"S\xF8k etter en by eller adresse",locationNoResults:"Fant ingen steder",locationUseTyped:"Trykk Enter for \xE5 bruke det du skrev"},da:{language:"da",and:"og",proceed:"for at forts\xE6tte",select:"for at v\xE6lge",skipHint:"for at springe over",skip:"spring over",skipLabel:"Spring over",products:"Bedste match",soldOut:"Udsolgt",addToCart:"L\xE6g i kurv",submit:"S\xF8g",scrollArrow:"Rul for flere muligheder",keepTyping:"Forts\xE6t med at skrive",done:"F\xE6rdig",timeLabel:"Tidspunkt",locationSearch:"S\xF8g efter en by eller adresse",locationNoResults:"Ingen steder fundet",locationUseTyped:"Tryk p\xE5 Enter for at bruge det, du skrev"},fi:{language:"fi",and:"ja",proceed:"jatkaaksesi",select:"valitaksesi",skipHint:"ohittaaksesi",skip:"ohita",skipLabel:"Ohita",products:"Paras vastaavuus",soldOut:"Loppuunmyyty",addToCart:"Lis\xE4\xE4 ostoskoriin",submit:"Hae",scrollArrow:"Vierit\xE4 n\xE4hd\xE4ksesi lis\xE4\xE4 vaihtoehtoja",keepTyping:"Jatka kirjoittamista",done:"Valmis",timeLabel:"Aika",locationSearch:"Hae kaupunkia tai osoitetta",locationNoResults:"Paikkoja ei l\xF6ytynyt",locationUseTyped:"Paina Enteri\xE4 k\xE4ytt\xE4\xE4ksesi kirjoittamaasi"},ja:{language:"ja",and:"\u3068",proceed:"\u3067\u6B21\u3078",select:"\u3067\u9078\u629E",skipHint:"\u3067\u30B9\u30AD\u30C3\u30D7",skip:"\u30B9\u30AD\u30C3\u30D7",skipLabel:"\u30B9\u30AD\u30C3\u30D7",products:"\u30D9\u30B9\u30C8\u30DE\u30C3\u30C1",soldOut:"\u58F2\u308A\u5207\u308C",addToCart:"\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",submit:"\u691C\u7D22",scrollArrow:"\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u3066\u4ED6\u306E\u5019\u88DC\u3092\u898B\u308B",keepTyping:"\u5165\u529B\u3092\u7D9A\u3051\u308B",done:"\u5B8C\u4E86",timeLabel:"\u6642\u523B",locationSearch:"\u90FD\u5E02\u540D\u3084\u4F4F\u6240\u3067\u691C\u7D22",locationNoResults:"\u5834\u6240\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",locationUseTyped:"\u5165\u529B\u3057\u305F\u5185\u5BB9\u3092\u4F7F\u3046\u306B\u306F Enter \u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044"},ko:{language:"ko",and:"\uBC0F",proceed:"\uACC4\uC18D",select:"\uC120\uD0DD",skipHint:"\uAC74\uB108\uB6F0\uAE30",skip:"\uAC74\uB108\uB6F0\uAE30",skipLabel:"\uAC74\uB108\uB6F0\uAE30",products:"\uCD5C\uC801 \uC77C\uCE58",soldOut:"\uD488\uC808",addToCart:"\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uB2F4\uAE30",submit:"\uAC80\uC0C9",scrollArrow:"\uB354 \uB9CE\uC740 \uC635\uC158\uC744 \uBCF4\uB824\uBA74 \uC2A4\uD06C\uB864\uD558\uC138\uC694",keepTyping:"\uACC4\uC18D \uC785\uB825\uD558\uC138\uC694",done:"\uC644\uB8CC",timeLabel:"\uC2DC\uAC04",locationSearch:"\uB3C4\uC2DC \uB610\uB294 \uC8FC\uC18C \uAC80\uC0C9",locationNoResults:"\uC7A5\uC18C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",locationUseTyped:"\uC785\uB825\uD55C \uB0B4\uC6A9\uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 Enter\uB97C \uB204\uB974\uC138\uC694"},"zh-CN":{language:"zh-CN",and:"\u548C",proceed:"\u7EE7\u7EED",select:"\u9009\u62E9",skipHint:"\u8DF3\u8FC7",skip:"\u8DF3\u8FC7",skipLabel:"\u8DF3\u8FC7",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u7F44",addToCart:"\u52A0\u5165\u8D2D\u7269\u8F66",submit:"\u641C\u7D22",scrollArrow:"\u5411\u4E0B\u6EDA\u52A8\u67E5\u770B\u66F4\u591A\u9009\u9879",keepTyping:"\u7EE7\u7EED\u8F93\u5165",done:"\u5B8C\u6210",timeLabel:"\u65F6\u95F4",locationSearch:"\u641C\u7D22\u57CE\u5E02\u6216\u5730\u5740",locationNoResults:"\u672A\u627E\u5230\u5730\u70B9",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F93\u5165\u7684\u5185\u5BB9"},"zh-TW":{language:"zh-TW",and:"\u548C",proceed:"\u7E7C\u7E8C",select:"\u9078\u64C7",skipHint:"\u7565\u904E",skip:"\u7565\u904E",skipLabel:"\u7565\u904E",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u5B8C",addToCart:"\u52A0\u5165\u8CFC\u7269\u8ECA",submit:"\u641C\u5C0B",scrollArrow:"\u5411\u4E0B\u6372\u52D5\u67E5\u770B\u66F4\u591A\u9078\u9805",keepTyping:"\u7E7C\u7E8C\u8F38\u5165",done:"\u5B8C\u6210",timeLabel:"\u6642\u9593",locationSearch:"\u641C\u5C0B\u57CE\u5E02\u6216\u5730\u5740",locationNoResults:"\u627E\u4E0D\u5230\u5730\u9EDE",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F38\u5165\u7684\u5167\u5BB9"}},xs={pt:"pt-BR",no:"nb",nn:"nb"};function O(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return Ai[o?"zh-TW":"zh-CN"]}let i=xs[e]??e;return Object.prototype.hasOwnProperty.call(Ai,i)?Ai[i]:sr}function vn(t,e,n=O()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function En(t){let e=a=>{a.ctrlKey||lr(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&&!lr(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 lr(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&Ts(o,i)||n!==0&&vs(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var cr=/^(auto|scroll|overlay)$/;function Ts(t,e){return t.scrollHeight<=t.clientHeight||!cr.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function vs(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!cr.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 dr=new WeakMap,ur=new WeakSet;function U(t,e,n){if(dr.set(t,n),ur.has(t))return;ur.add(t);let i=()=>dr.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 se(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function $(t){t.offsetWidth}var Es={selectedIso:null,selectedRange:null,rangeStart:null};function Me(t){if(!k(t.activeFormatType))return Es;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}}let n=Oe(t.editingParam);return{selectedIso:n?null:Rt(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart}}function wn(t){return t.pendingStart?et(t.pendingStart,t.highlightedIso??t.pendingStart):t.selected}function Pn(t,e){if(t==null)return{selected:!1,inRange:!1};let{selectedIso:n,range:i}=e,o=t===n||i!=null&&(t===i.start||t===i.end),r=i!=null&&t>i.start&&t<i.end;return{selected:o,inRange:r}}var pr="data-aia-key";function X(t,e,n){let i=new Map;for(let a of Array.from(t.children)){let s=a.getAttribute(pr);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(pr,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 mr(t,e){if(!e.interactive)return null;let n=e.options[se(t)];return n?.is_tappable?n:null}var ws={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=mr(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")&&mr(t,e)&&e.callbacks.onHighlight(se(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,se(t))}};function fr(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=Is(),t.appendChild(l),$(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}U(l,ws,{options:e,callbacks:a,interactive:s});let d=l.querySelector(".magicx-aia-datepicker-month");d&&(d.textContent=Ot(o));let c=l.querySelector(".magicx-aia-datepicker-grid");c&&Ps(c,e,n,i,r)}function Ps(t,e,n,i,o){let r=B(new Date),a=wn({pendingStart:o.rangeStart,highlightedIso:Q(e[n]),selected:o.selectedRange});X(t,e,{keyOf:(s,l)=>Q(s)??`pad-${l}`,create:s=>Cs(s),update:(s,l,d)=>{let c=Q(l),u=Pn(c,{selectedIso:o.selectedIso,range:a}),p=d===n&&l.is_tappable;s.id=`${i}-option-${d}`,s.dataset.aiaIndex=String(d),s.setAttribute("aria-selected",String(p)),s.classList.toggle("magicx-aia-date-cell--past",c!=null&&c<r),s.classList.toggle("magicx-aia-date-cell--highlighted",p),s.classList.toggle("magicx-aia-date-cell--today",c!=null&&c===r),s.classList.toggle("magicx-aia-date-cell--selected",u.selected),s.classList.toggle("magicx-aia-date-cell--in-range",u.inRange)}})}function Cs(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=_t(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 Is(){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(gr("prev","Previous month","\u2039"),n,gr("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of $e){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 gr(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 Ls='<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>',hr="data-aia-location-body";function As(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=Ls;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 Os(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 br(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(hr)!==r){for(let s of Array.from(t.children))s.hasAttribute("data-aia-location-row")||s.remove();let a=Os(r,n);a&&t.appendChild(a),t.setAttribute(hr,r)}X(t,o,{keyOf:(a,s)=>`${s}:${a.id}`,create:a=>As(a),update:(a,s,l)=>{let d=l===e.highlighted;a.classList.toggle("magicx-aia-location-row--highlighted",d),a.setAttribute("aria-selected",String(d)),a.setAttribute("data-aia-index",String(l)),a.id=i(l)}})}var ee=new WeakMap,ks=0,fe=new WeakMap,Ms='<svg class="magicx-aia-location-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>',he=t=>Dt(t.input)===t.input;function Sr(t,e){let n=Dt(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=Pe(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Rs(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=Ke(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 _s={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&Re(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function Re(t,e=!1){let n=fe.get(t),i=ee.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&he(n)&&(n.returning=!0,Rs(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function Ds(t){let e=fe.get(t),n=ee.get(t);if(!(!e||!n||he(e))){if(Sr(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!he(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function Ns(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++ks}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=Ms;let i=document.createElement("input");i.type="text",i.className="magicx-aia-location-input",i.setAttribute("data-aia-location-input",""),i.setAttribute("autocomplete","off"),i.setAttribute("autocapitalize","words"),i.setAttribute("enterkeyhint","done"),i.spellcheck=!1,i.placeholder=e.locationSearch,i.setAttribute("aria-label",e.locationSearch),n.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-location-results",o.setAttribute("data-aia-location-results",""),o.setAttribute("aria-live","polite"),t.append(n,o);let r={input:i,field:n,results:o,returnTo:null,returnRange:null,returning:!1,declined:!1,widgetFocused:!1};return t.addEventListener("mousedown",a=>{!(a.target instanceof Node)||!n.contains(a.target)||(a.stopPropagation(),Sr(t,r),ee.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>ee.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",()=>ee.get(t)?.callbacks.onLocationFocusChange(!0)),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,ee.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",a=>{let s=ee.get(t);if(!(!s||a.isComposing))switch(a.key){case"ArrowDown":case"ArrowUp":a.preventDefault(),s.callbacks.onLocationMove(a.key==="ArrowDown"?1:-1);return;case"Enter":if(a.preventDefault(),!s.interactive)return;Re(t,!0),s.callbacks.onLocationCommit();return;case"Escape":a.preventDefault(),a.stopPropagation(),r.declined=!0,Re(t);return;case"Backspace":if(i.value!=="")return;a.preventDefault(),r.declined=!0,Re(t);return}}),fe.set(t,r),r}function yr(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=fe.get(e);n&&(he(n)&&Re(e),n.declined=!1,n.input.tabIndex=-1)}}function xr(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=fe.get(r);l&&he(l)&&Re(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let a=fe.get(r)??Ns(r,n);a.input.tabIndex=0,ee.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),U(a.results,_s,ee.get(r)),a.input.value!==e.query&&!he(a)&&(a.input.value=e.query);let s=l=>`${r?.id}-row-${l}`;if(br(a.results,e,n,s),e.highlighted>=0&&e.highlighted<e.places.length?a.input.setAttribute("aria-activedescendant",s(e.highlighted)):a.input.removeAttribute("aria-activedescendant"),a.widgetFocused=o.inputFocused??!1,o.inputFocused){if(!a.declined&&o.interactive!==!1&&!he(a)){let l=r;queueMicrotask(()=>{l.isConnected&&!fe.get(l)?.declined&&Ds(l)})}}else{let l=a;setTimeout(()=>{if(l.widgetFocused)return;let d=l.returnTo;d&&Dt(d)===d||(l.declined=!1)},0)}}var Fs={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},Tr=[125,69];function vr(t,e){return e?1:t===0?.7:t===1?.4:.2}function Cn(t,e,n,i,o=!1,r=!1,a=!1){let s=t.querySelector(".magicx-aia-pill-list");if(s||(s=document.createElement("span"),s.className="magicx-aia-pill-list",t.appendChild(s)),U(s,Fs,{onSelectPill:i,loading:r}),r&&e.length===0){s.setAttribute("data-aia-pill-list-loading",""),s.innerHTML="";for(let l=0;l<Tr.length;l++){let d=Tr[l],c=document.createElement("span");c.setAttribute("data-aia-pill-skeleton",""),c.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,c.style.width=`${d}px`,c.style.opacity=String(vr(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();X(s,e,{keyOf:l=>`${l.type?.kind??""}|${Ve(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"),Ve(l)){d.setAttribute("data-aia-smart-suggestion",w(l)?"header":"");let c=document.createElement("span");c.className="magicx-aia-smart-suggestion-text",c.textContent=l.text;let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-sparkle",u.innerHTML=Pt,d.append(c,u)}else d.textContent=l.text;return d.disabled=!0,d},update:(l,d,c)=>{let u=l,p=a&&c===n&&!r,h=["magicx-aia-pill"];o&&h.push("magicx-aia-pill--rounded"),r&&h.push("magicx-aia-pill--skeleton"),u.className=h.join(" "),u.style.width="",u.style.opacity=String(vr(c,p)),u.dataset.aiaPillIndex=String(c),r?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),$(s);for(let l of s.querySelectorAll("[data-aia-pill]"))l.disabled=r}function Oi(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var Er=32;function ki(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 In(t){let e=n=>{let i=ki(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var wr=Intl.Segmenter,Pr=wr?new wr(void 0,{granularity:"grapheme"}):null;function Ln(t){let e=t.trim().normalize("NFC").toUpperCase();if(Pr)for(let n of Pr.segment(e))return n.segment;return Array.from(e)[0]??"?"}var An=120,Cr=360;function Hs(t){let e=t.pathname;return t.hostname==="cdn.shopify.com"&&e.startsWith("/s/files/")||e.startsWith("/cdn/shop/")?/\.png$/i.test(e)?{format:"pjpg"}:/\.webp$/i.test(e)?{format:null}:null:null}function Mi(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=Hs(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 Ri(t,e){let n=Mi(t,e);return n===t?[t]:[n,t]}function On(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 ot(t){let e=t?.trim();return e?Ri(e,360):[]}function Ir(t){return ot(t)[0]}var kn=new WeakMap,Di=new WeakMap,Ar=new WeakMap;function Or(t,e,n,i,o,r="row",a="image",s=O(),l){let d=t.querySelector(".magicx-aia-products");if(e.length===0){d?.remove();return}if(!d){d=document.createElement("section"),d.className="magicx-aia-products",d.setAttribute("data-aia-products",""),d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${n}-products-label`);let p=document.createElement("div");p.className="magicx-aia-products-label",p.id=`${n}-products-label`,p.setAttribute("data-aia-products-label",""),p.textContent=s.products;let h=document.createElement("div");h.className="magicx-aia-products-row",h.setAttribute("data-aia-products-row",""),In(h),d.append(p,h),t.appendChild(d)}d.setAttribute("data-aia-products-layout",r);let c=d.querySelector(".magicx-aia-products-label");c&&c.textContent!==s.products&&(c.textContent=s.products);let u=d.querySelector(".magicx-aia-products-row");if(u){X(u,e,{keyOf:p=>Vs(p,!!l),create:p=>Gs(p,i,o,a,s,l),update:(p,h,g)=>{kn.set(p,h),Ws(p,h.price,h.compareAtPrice),p.id=`${n}-product-${g}`,p.dataset.aiaIndex=String(g),Ar.get(p)?.(a);let f=p.querySelector(".magicx-aia-product-badge");f&&f.textContent!==s.soldOut&&(f.textContent=s.soldOut);let S=p.querySelector(".magicx-aia-product-cart");S&&S.setAttribute("aria-label",kr(h,s))}}),$(u);for(let p of u.querySelectorAll("[data-aia-product]")){let h=Di.get(p);h&&(Di.delete(p),h())}}}function Ni(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)i.tabIndex=e?0:-1}function Ws(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 Lr(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 kr(t,e){return`${e.addToCart}: ${t.title}`}var _i="http://www.w3.org/2000/svg";function Us(){let t=document.createElementNS(_i,"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(_i,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(_i,"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 Bs(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",kr(e,o)),r.tabIndex=0,r.appendChild(Us());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(kn.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 Vs(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 Gs(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=ot(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=Ln(t.title))};if(Ar.set(a,f=>{f!==i&&(i=f,c||u())}),d){let f=document.createElement("img"),S=0;f.onload=()=>{s.setAttribute("data-aia-image-loaded",""),Lr(a,On(f.naturalWidth,f.naturalHeight))},f.onerror=()=>{let y=l[++S];if(y){f.src=y;return}c=!1,Lr(a,null),u()},f.className="magicx-aia-product-image",f.src=d,f.alt="",f.loading="lazy",f.decoding="async",s.appendChild(f)}else u();a.appendChild(s);let p=document.createElement("span");if(p.className="magicx-aia-product-body",t.vendor){let f=document.createElement("span");f.className="magicx-aia-product-vendor",f.textContent=t.vendor,p.appendChild(f)}let h=document.createElement("span");if(h.className="magicx-aia-product-title",h.textContent=t.title,p.appendChild(h),t.available===!1){a.setAttribute("data-aia-product-sold-out","");let f=document.createElement("span");f.className="magicx-aia-product-badge",f.textContent=o.soldOut,p.appendChild(f)}a.appendChild(p);let g=r&&t.available!==!1?Bs(a,t,r,n,o):null;return g&&(a.setAttribute("data-aia-product-has-cart",""),a.appendChild(g.el)),Di.set(a,()=>{g?.arm(),t.url&&(a.href=t.url),a.addEventListener("click",f=>{f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||f.button!==0||(f.preventDefault(),e(kn.get(a)??t))})}),a.addEventListener("keydown",f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),e(kn.get(a)??t))}),a.addEventListener("focus",()=>n(!0)),a.addEventListener("blur",f=>{f.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),a}var Mr=40,Rr=340,_r=340,Dr=7,Mn="--aia-option-enter-delay";function Rn(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 _n(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 Nr=10,Fr=44;function Dn(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 Hr="http://www.w3.org/2000/svg",$s=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function qs(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 Ks=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],zs=/^[a-zA-Z0-9#.,%\s()-]+$/;function js(t){let e=[];for(let n of Ks){let i=t.getAttribute(n);i===null||!zs.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function Wr(t){for(let e of Array.from(t.attributes))qs(e.name,e.value)&&t.removeAttribute(e.name);js(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!$s.has(n.localName)||n.namespaceURI!==Hr?n.remove():Wr(n)}else e.remove()}function le(t){if(typeof DOMParser>"u"||typeof XMLSerializer>"u")return null;let e=new DOMParser().parseFromString(t,"image/svg+xml"),n=e.documentElement;return!n||n.localName!=="svg"||n.namespaceURI!==Hr||e.getElementsByTagName("parsererror").length>0?null:(Wr(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function rt(t){return t.text}function ce(t){return at(t)[0]??null}function at(t){let e=Ys(t);return e?Ri(e,120):[]}function Ys(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 _e(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var Fi={one:"item",other:"items"};function Ur(t,e=Fi){let n=_e(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function Hi(t){return ce(t.image_url)!==null}var Nn=new Map;function Qs(t){let e=t.icon_svg;if(!e)return!1;let n=Nn.get(e);return n===void 0&&(n=le(e)!==null,Nn.size>=256&&Nn.clear(),Nn.set(e,n)),n}function Fn(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&Hi(i)||e&&Qs(i))}var Br=new WeakMap;function Xs(t,e,n){let i=e.length,o=mn(),r=Br.get(t),a=n&&r&&gn(r.options,e)?r.plan:null,s=!a&&!n&&dn(i,o)?pn(t):null,l=a??un(i,o,s?.rowWidths??null,s?.gridWidth??null);return n||Br.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 Vr(t,e){if(e.loading||!e.interactive)return null;let n=e.options[se(t)];return n?.is_tappable?n:null}var Js={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=Vr(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!Dn(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)=>{Vr(t,e)&&e.onHighlight(se(t))},onLeave:(t,e)=>e.onHighlight(-1,se(t))};function Gr(t,e,n,i,o,r,a,s="",l="below",d=!0,c=!0,u=!0,p=!0,h){let g=t.querySelector(".aia-grid");if(e.length===0){g?.remove();return}g||(g=document.createElement("div"),g.className="aia-grid magicx-aia-grid",g.setAttribute("data-scroll",""),g.style.setProperty("--aia-grid-min","250px"),g.style.setProperty("--aia-grid-max","1fr"),g.style.setProperty("--aia-grid-gap","0"),t.appendChild(g)),U(g,Js,{options:e,onSelect:i,onHighlight:o,loading:a,interactive:p});let f=g.dataset.aiaGroup!==s;g.dataset.aiaGroup=s;let S=Fn(e,d,c);Zs(g,e,n,r,a,{showIcons:d&&S,showImages:c&&S,showCounts:u,picked:h});let y=Xs(g,e,a);el(g,e.length,y,a,l),f&&(g.scrollTop=0)}function Zs(t,e,n,i,o,r){let a=o?"1":"0",s=t.dataset.aiaGroup??"",{showIcons:l,showImages:d,showCounts:c}=r,u=l?g=>g.icon??g.icon_svg??"":()=>"",p=d?g=>ce(g.image_url)??"":()=>"",h=c?g=>_e(g.item_count)??"":()=>"";X(t,e,{keyOf:g=>`${g.text}\0${g.parameterLabel??""}\0${u(g)}\0${p(g)}\0${h(g)}\0${a}\0${s}`,create:(g,f)=>{let S=tl(g,o,r);return o||(S.dataset.aiaEntering=""),S},update:(g,f,S)=>{if(Wi.get(g)!==(f.matchedText??"")){let b=g.querySelector(".magicx-aia-option-text");b&&$r(b,f),Wi.set(g,f.matchedText??"")}let y=S===n&&!o;g.id=`${i}-option-${S}`,g.dataset.aiaIndex=String(S),g.setAttribute("aria-selected",String(r.picked?r.picked.includes(f.text):y));let m=g.querySelector(".magicx-aia-checkbox");r.picked&&f.is_tappable?(m||(m=document.createElement("span"),m.className="magicx-aia-checkbox",m.setAttribute("aria-hidden","true"),g.querySelector(".magicx-aia-option-content")?.prepend(m)),m.dataset.checked=String(r.picked.includes(f.text)),m.textContent=r.picked.includes(f.text)?"\u2713":""):m?.remove(),g.classList.toggle("magicx-aia-option--highlighted",y),g.classList.toggle("magicx-aia-option--live-match",!!f.liveMatch&&!o)}})}function el(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(Mn,`${Rn(a,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var Wi=new WeakMap;function $r(t,e){if(t.replaceChildren(),e.matchedText)for(let n of hn(rt(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(rt(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 tl(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?at(t.image_url):[],d=l[0];if(d){let h=document.createElement("span");h.className="magicx-aia-option-image",h.setAttribute("aria-hidden","true");let g=document.createElement("img");g.setAttribute("alt",""),g.setAttribute("loading","lazy"),g.setAttribute("decoding","async"),g.setAttribute("referrerpolicy","no-referrer"),g.setAttribute("draggable","false");let f=0;g.onload=()=>h.setAttribute("data-aia-image-loaded",""),g.onerror=()=>{let S=l[++f];S?g.src=S:g.hidden=!0},g.src=d,h.appendChild(g),s.appendChild(h),r.dataset.aiaImage=""}let c=!d&&n&&t.icon_svg?le(t.icon_svg):null;if(c){let h=document.createElement("span");h.className="magicx-aia-option-icon",h.setAttribute("aria-hidden","true"),h.innerHTML=c,s.appendChild(h),t.icon&&(r.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",$r(u,t),Wi.set(r,t.matchedText??""),s.appendChild(u),t.tag){let h=document.createElement("span");h.className="magicx-aia-option-tag",h.textContent=t.tag,s.appendChild(h)}let p=o?_e(t.item_count):null;if(p!==null){let h=document.createElement("span");h.className="magicx-aia-option-count",h.textContent=p,s.appendChild(h),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(s),r}var nl=120,il={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(Ze(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},Kr=new WeakMap,qr=new WeakMap;function zr(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=al(),t.appendChild(r),$(r);let d=r.querySelector("[data-aia-time-done]");d&&(d.disabled=!1)}let a={view:e,callbacks:i,interactive:o};Kr.set(r,a),U(r,il,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=Ye(e.minutes));for(let d of Xe){let c=r.querySelector(`[data-aia-time-column="${d}"]`);c&&ol(c,d,e.minutes)}}function ol(t,e,n){let i=Je(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=Hn(t);if(o.settle)return;let r=i*Qe;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function Hn(t){let e=qr.get(t);return e||(e={syncedTop:null,settle:null},qr.set(t,e)),e}function rl(t,e,n){let i=Hn(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(()=>jr(t,e,n),nl)}function jr(t,e,n){let i=Hn(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=Kr.get(t);if(!o||!o.interactive)return;let r=Xt(n,e.scrollTop);r!==Je(n,o.view.minutes)&&o.callbacks.onTimeChange(Ze(n,o.view.minutes,r))}function al(){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 Xe){if(r==="minute"){let a=document.createElement("span");a.className="magicx-aia-time-wheel-separator",a.textContent=":",n.appendChild(a)}n.appendChild(sl(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 sl(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),Qt(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",()=>rl(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{Hn(n).settle&&jr(t,n,e)}),n}var Bi="magicx-aia-scroll-arrow",Vi="data-aia-scroll-arrow",be="data-aia-visible",Gi=1e3,$i=160,qi="--aia-scroll-arrow-bottom",Yr="Scroll down for more options",ll="[data-aia-products-label]",cl=4,dl=8,ul=240;function pl(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,a=t.ownerDocument?.visibilityState==="hidden";if(!r||a||Ui(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)/ul),u=1-(1-c)*(1-c);t.scrollTop=o+e*u,c<1?r.call(n,d):i()};r.call(n,d)}function ml(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 Qr(t=document,e=O()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=Bi,n.setAttribute(Vi,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(ml(t)),n}function gl(t){let e=t.style.gridTemplateColumns.trim();return e?Math.max(1,e.split(/\s+/).length):1}function Ui(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Wn({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=m=>{if(m){if(n.hasAttribute(be))return;if(n.setAttribute(be,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),Ui(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(be)&&(n.disabled=!1)},Gi)}else n.removeAttribute(be),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},c=m=>{let b=0,T=m;for(;T&&T!==t;)b+=T.offsetTop,T=T.offsetParent instanceof HTMLElement?T.offsetParent:null;return b},u=()=>{let m=t.querySelector(ll),b;if(m){let T=c(m)+m.offsetHeight/2;b=t.clientHeight-T-n.offsetHeight/2}else{let T=c(e),x=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;b=t.clientHeight-(T+e.offsetHeight)+(x>0?0:dl)}n.style.setProperty(qi,`${Math.max(0,Math.round(b))}px`)},p=()=>{if(o||a!==null||s!==null)return;let m=e.querySelector("[data-aia-option][data-aia-loading]")!==null,b=e.scrollHeight-e.clientHeight-e.scrollTop;d(!m&&b>cl)},h=()=>{if(o)return;u();let m=e.getAttribute("data-aia-group")??"";if(m!==r){r=m,d(!1),a!==null&&clearTimeout(a);let b=e.querySelectorAll("[data-aia-option]").length,T=Ui(e)?0:_n(b,gl(e));a=setTimeout(()=>{a=null,p()},T);return}p()},g=()=>{o||a!==null||(d(!1),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,p()},$i))};e.addEventListener("scroll",g,{passive:!0});let f=m=>m.preventDefault(),S=()=>{let m=i?(Number.parseFloat(i.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0):0,b=Math.max(1,e.clientHeight-m);pl(e,b,i,g)};n.addEventListener("mousedown",f),n.addEventListener("click",S);let y=null;return i&&typeof i.ResizeObserver=="function"&&(y=new i.ResizeObserver(()=>{u(),p()}),y.observe(e)),h(),{update:h,destroy(){o||(o=!0,a!==null&&clearTimeout(a),a=null,s!==null&&clearTimeout(s),s=null,l!==null&&clearTimeout(l),l=null,n.disabled=!0,e.removeEventListener("scroll",g),n.removeEventListener("mousedown",f),n.removeEventListener("click",S),y?.disconnect(),n.removeAttribute(be),n.setAttribute("aria-hidden","true"))}}}var Se="data-aia-fit",st="--aia-dropdown-fit-height";function Un({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,a=null,s=null,l=()=>{t.removeAttribute(Se),t.style.removeProperty(st)},d=h=>{let f=`${r}|${(h??t).scrollHeight}|${t.offsetWidth}`;if(s?.key===f)return s.height;let S=h?.scrollTop??0;t.removeAttribute(Se);let y=t.offsetHeight;return t.setAttribute(Se,""),h&&S&&(h.scrollTop=S),s={key:f,height:y},y},c=()=>{if(i)return;if(!e()){o=!1;return}o||(o=!0,l());let h=t.hasAttribute(Se),g=t.querySelector(".aia-grid")?.getAttribute("data-aia-group")??null,f=g!==r;r=g;let S=hl(t,n);if(S===null)return;let y=fl(t);if(h){if(d(y)<=S){l();return}}else if(t.offsetHeight<=S)return;let m=`${Math.max(160,Math.floor(S))}px`;t.style.getPropertyValue(st)!==m&&t.style.setProperty(st,m),h?f&&y&&(y.scrollTop=0):t.setAttribute(Se,"")},u=()=>{i||a!==null||!n||(a=n.requestAnimationFrame(()=>{a=null,c()}))},p=n?.visualViewport??null;return p?.addEventListener("resize",u),p?.addEventListener("scroll",u),n?.addEventListener("resize",u),n?.addEventListener("scroll",u,{capture:!0,passive:!0}),c(),{update:c,destroy(){i||(i=!0,a!==null&&n?.cancelAnimationFrame(a),p?.removeEventListener("resize",u),p?.removeEventListener("scroll",u),n?.removeEventListener("resize",u),n?.removeEventListener("scroll",u,{capture:!0}))}}}function fl(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function hl(t,e){if(!e)return null;let n=e.visualViewport,i=n?n.offsetTop:0,o=n?n.height:e.innerHeight;if(!o)return null;let r=t.offsetParent,a=r?r.getBoundingClientRect().top:0,s=r?a+t.offsetTop:t.getBoundingClientRect().top;return t.closest("[data-options-position]")?.getAttribute("data-options-position")==="above"?(r?s+t.offsetHeight:t.getBoundingClientRect().bottom)-i-8:i+o-s-8}var bl=[159,119,164];function Gn(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()),En(e),e}var Bn=new WeakMap;function Sl(t,e,n){let i=Bn.get(t);if(i||(i={button:Qr(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),Bn.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=Wn({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var Vn=new WeakMap;function Xr(t){let e=Vn.get(t);if(e){e.update();return}Vn.set(t,Un({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function Ki(t){Vn.get(t)?.destroy(),Vn.delete(t);let e=Bn.get(t);e&&(e.controller?.destroy(),Bn.delete(t))}function $n(t,e){let n=e.strings??O(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:a,showPills:s,isActivePillSelected:l,onSelect:d,onHighlight:c,onPillClick:u,onSkip:p}=e,h=wt(e.pills,n.keepTyping),g=Ct(h),f=s&&h.length>0,S=i.length>0,y=e.products.length>0,m=e.formatType==="time"&&e.timeView!=null,b=e.formatType==="location"&&e.locationView!=null,T=r&&(S||f||a||y||m||b);if(T?t.classList.add("magicx-aia-dropdown--visible"):t.classList.remove("magicx-aia-dropdown--visible"),a?t.setAttribute("data-aia-loading",""):t.removeAttribute("data-aia-loading"),!T){Ni(t,!1),yr(t),Xr(t);return}y?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let x=t.querySelector(".aia-stack");x||(x=document.createElement("div"),x.className="aia-stack",x.style.setProperty("--aia-stack-space","8px"),t.appendChild(x));let P=e.showSkipButton&&g&&!e.isInputEmpty,I=f||a&&s||P,C=x.querySelector(".magicx-aia-pill-bar");if(I){C||(C=document.createElement("div"),C.className="magicx-aia-pill-bar aia-cluster",C.setAttribute("data-nowrap",""),C.setAttribute("data-aia-pillbar",""),x.insertBefore(C,x.firstChild));let M=C.querySelector(".magicx-aia-pill-scroll");M||(M=document.createElement("span"),M.className="magicx-aia-pill-scroll",M.setAttribute("data-aia-pill-scroll",""),C.insertBefore(M,C.firstChild)),Cn(M,s?h:[],0,u,!0,a&&s,l),Tl(C,P,a||e.skipDisabled,h[0],p,n)}else C&&C.remove();let E=e.suggestions[0],J=E?`${E.parameter} ${E.text}`:"",G=k(e.formatType),ye=G&&!a;Gr(x,G?[]:i,o,d,c,e.listboxId,a,J,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)),Pl(x,!!e.multiSelectView&&!a,e.skipDisabled,e.onMultiSelectCommit,n.done),Sl(t,x.querySelector(".aia-grid"),n),fr(x,ye?i:[],o,e.listboxId,ye?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart},{onSelect:d,onHighlight:c,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),zr(x,e.formatType==="time"&&!a?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),xr(x,e.formatType==="location"&&!a?e.locationView:null,n,{onLocationQuery:e.onLocationQuery,onLocationMove:e.onLocationMove,onLocationCommit:e.onLocationCommit,onLocationFocusChange:e.onLocationFocusChange},{interactive:!e.skipDisabled,inputFocused:e.isFocused??!1});let L=x.querySelector(".magicx-aia-skeleton-bars");if(a&&(!S||_(e.formatType))){if(!L){L=document.createElement("div"),L.className="magicx-aia-skeleton-bars",L.setAttribute("data-aia-skeleton-bars","");for(let M of bl){let v=document.createElement("span");v.className="magicx-aia-skeleton-bar",v.style.width=`${M}px`,L.appendChild(v)}x.appendChild(L)}}else L&&L.remove();Or(x,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart),Ni(t,!0);let H=x.querySelector(".magicx-aia-footer")??El(n),de=o>=0&&!!i[o]?.is_tappable;vl(H,vn(de,e.isInputEmpty,n)),H.isConnected||x.appendChild(H),yl(x,[".magicx-aia-pill-bar",".aia-grid","[data-aia-multi-actions]",".magicx-aia-datepicker",".magicx-aia-time-wheel","[data-aia-location]",".magicx-aia-skeleton-bars",".magicx-aia-products",".magicx-aia-footer"]),Xr(t)}function yl(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 xl={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function Tl(t,e,n,i,o,r){U(t,xl,{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),$(a)),a.textContent!==r.skip&&(a.textContent=r.skip),a.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),a.disabled=n}function vl(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 El(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=Tn(),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 wl={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function Pl(t,e,n,i,o){let r=t.querySelector("[data-aia-multi-actions]");if(!e){r?.remove();return}if(!r){r=document.createElement("div"),r.dataset.aiaMultiActions="";let s=document.createElement("button");s.type="button",s.tabIndex=-1,s.className="magicx-aia-multi-done",s.disabled=!0,r.appendChild(s),t.appendChild(r),$(s)}U(r,wl,{commit:i,disabled:n});let a=r.querySelector("button");a&&(a.textContent=o,a.disabled=n)}function Jr(t,e){let n=Gn(e.listboxId);return t.appendChild(n),{dropdown:n}}function zi(t,e,n){let i=Me(e);$n(t.dropdown,{strings:n.strings,suggestions:e.editingIdentified?[{parameter:e.editingIdentified.parameter,text:j(e.editingIdentified.parameter),required:!0,options:e.filteredOptions}]:e.dropdownSuggestion??e.actionableSuggestions[0]?[{...e.dropdownSuggestion??e.actionableSuggestions[0],options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:e.actionableSuggestions,showPills:!0,showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:i.selectedIso,selectedDateRange:i.selectedRange,dateRangeStart:i.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,locationView:e.locationView,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:n.selectOption,onHighlight:(o,r)=>{r!==void 0&&n.store.get().activeDropdownIndex!==r||n.store.set({activeDropdownIndex:o})},onPillClick:n.setActivePill,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,onProductSelect:n.selectProduct,onProductFocusChange:o=>n.store.set({isFocused:o})})}var Zr=340;function qn(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 p of c)if(p.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 Cl=6,Il=.3;function ea(t){return t<=0?"0px":`${(-Math.min(Il,2*Cl/t)).toFixed(3)}px`}var ta=new Map;function Ll(t,e,n){let i=ta.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`;ta.set(e,s),t.style.setProperty("--aia-chip-image-fit",s)},o.src=e}function Kn(t){let{input:e,segments:n,newParamId:i,editingParamId:o,placeholderText:r,isFocused:a}=t,s=t.showChipIcons??!0,l=t.showChipImages??!0,d=n.length===0;e.dataset.aiaEmpty=d?"true":"false",rr(e,d?r:"");let c=n.map(m=>m.type==="completed"?`${m.type}:${m.value}${s?m.param.icon??m.param.icon_svg??"":""}${l?ce(m.param.image_url)??"":""}`:`${m.type}:${m.value}`).join("\0"),u=e.dataset.segKey??"",p=e.dataset.newParamId??"",h=e.dataset.editingParamId??"";if(c===u&&(i??"")===p&&(o??"")===h)return;if(c===u){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let m of e.querySelectorAll("strong[data-param-id]")){let b=m.dataset.paramId,T=m.dataset.seg==="completed"&&b===i;m.classList.toggle("magicx-aia-shimmer-revealed",T),m.classList.toggle("magicx-aia-shimmer-sweep",T),m.classList.toggle("magicx-aia-segment--editing",b===o)}return}let g=a&&ci(e)?V(e):null;e.dataset.segKey=c,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let f=R(e),S=f.createDocumentFragment(),y=0;for(let m of n)if(y+=m.value.length,m.type==="completed"){let b=f.createElement("strong");b.dataset.seg="completed",b.dataset.paramId=m.param.id;let T=m.param.id===i,x=m.param.id===o,P=["magicx-aia-segment","magicx-aia-segment--completed"];T&&P.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),x&&P.push("magicx-aia-segment--editing"),b.className=P.join(" "),b.style.letterSpacing=ea(m.value.length);let I=l?ce(m.param.image_url):null;if(I){let E=f.createElement("span");E.className="magicx-aia-segment-image",E.setAttribute("contenteditable","false"),E.setAttribute("aria-hidden","true"),E.style.setProperty("--aia-chip-image",`url("${I}")`),Ll(E,I,f),b.appendChild(E),b.dataset.aiaImage=""}let C=!I&&s&&m.param.icon_svg?le(m.param.icon_svg):null;if(C){let E=f.createElement("span");E.className="magicx-aia-segment-icon",E.setAttribute("contenteditable","false"),E.setAttribute("aria-hidden","true"),E.innerHTML=C,b.appendChild(E),m.param.icon&&(b.dataset.aiaIcon=m.param.icon)}b.appendChild(f.createTextNode(m.value)),S.appendChild(b)}else if(m.type==="identified"){let b=f.createElement("strong");b.dataset.seg="identified",b.dataset.paramId=m.param.id;let T=["magicx-aia-segment","magicx-aia-segment--completed"];m.param.id===o&&T.push("magicx-aia-segment--editing"),b.className=T.join(" "),b.style.letterSpacing=ea(m.value.length),b.textContent=m.value,S.appendChild(b)}else S.appendChild(f.createTextNode(m.value));e.replaceChildren(S),e.dataset.aiaTextLength=String(y),g!=null?N(e,Math.max(0,Math.min(g,y))):a&&ci(e)&&N(e,y)}var Al='<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 na(t=O()){let e=document.createElement("button");return e.type="button",e.className="magicx-aia-submit",e.setAttribute("aria-label",t.submit),e.setAttribute("data-aia-submit",""),e.innerHTML=Al.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function Ol(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function ia(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 oa(t,e){let{listboxId:n}=e,i=Gn(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",Ol()?"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=na(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,p=!1,h=0,g=()=>{let m=je(a),T=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;e.handleChange(T)},f=()=>{let m=oe(a)?.node??null;if(!m||!a.contains(m))return null;let x=(m.nodeType===Node.ELEMENT_NODE?m:m.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return x&&Do(a,x)?null:x};if(o.addEventListener("click",m=>{m.target?.closest("[data-aia-pill]")||a.getRootNode().activeElement?.closest("[data-aia-location]")||a.focus()},{signal:u}),a.addEventListener("input",()=>{p||(h=performance.now(),g(),e.handleCaretAfterInput(V(a)))},{signal:u}),R(a).addEventListener("selectionchange",()=>{let m=oe(a);if(!m||!a.contains(m.node))return;let b=m.collapsed?f():null,T=e.store.get(),x=T.editingParam?.id??T.editingIdentified?.id??null;if(b&&b!==x){e.startEditingParam(b);return}performance.now()-h<50||e.handleCaretMove(V(a))},{signal:u}),a.addEventListener("click",m=>{let b=Vt(a,m.target);b&&(e.startEditingParam(b),Gt(a,b))},{signal:u}),a.addEventListener("compositionstart",()=>{p=!0,a.setAttribute("data-aia-composing","true")},{signal:u}),a.addEventListener("compositionend",()=>{p=!1,a.removeAttribute("data-aia-composing"),g()},{signal:u}),a.addEventListener("beforeinput",m=>{let b=m,T=b.inputType;if(T==="insertParagraph"||T==="insertLineBreak"||T==="insertFromDrop"){m.preventDefault();return}if(T.startsWith("insert")||T.startsWith("delete")){let x=T.startsWith("delete")?"":b.data??"";e.replaceEditingRange(x)&&m.preventDefault()}},{signal:u}),a.addEventListener("paste",m=>{m.preventDefault();let b=(m.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let T=R(a),x=Pe(a);if(!x||!a.contains(x.startContainer))return;x.deleteContents();let P=T.createTextNode(b);x.insertNode(P),x.setStartAfter(P),ze(a,x.startContainer,x.startOffset),g()},{signal:u}),a.addEventListener("keydown",m=>e.handleKeyDown(m),{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",m=>{let b=e.store.get();if(!(!!b.text||b.completedParams.length>0)||!e.onSubmit)return;m.stopPropagation(),e.endTypedWord?.();let x=e.store.get();e.onSubmit(re(x.text,x.completedParams,x.skippedParams,{identifiedParams:x.identifiedParams,isReady:x.isReady,customFields:x.customFields}))&&e.afterSubmit?.()},{signal:u}),e.autoFocus!==!1){a.focus();let m=oe(a);(!m||!a.contains(m.node))&&ze(a,a,0)}if(typeof ResizeObserver<"u"){let m=new ResizeObserver(()=>ia(a,s));m.observe(a),c.signal.addEventListener("abort",()=>m.disconnect(),{once:!0})}let y=qn(r);return c.signal.addEventListener("abort",y,{once:!0}),{input:a,inlinePillContainer:s,dropdown:i,submitButton:l,abort:c}}function ji(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:a}=t,{pillPlacement:s,setActivePill:l,selectOption:d,store:c}=n;i.setAttribute("aria-expanded",String(e.isDropdownOpen));let u=e.activeDropdownIndex>=0?`${n.listboxId}-option-${e.activeDropdownIndex}`:"";if(u?i.setAttribute("aria-activedescendant",u):i.removeAttribute("aria-activedescendant"),a){let y=n.strings??O();a.getAttribute("aria-label")!==y.submit&&a.setAttribute("aria-label",y.submit);let m=a.querySelector("svg");m&&m.getAttribute("aria-label")!==y.submit&&m.setAttribute("aria-label",y.submit);let b=!!e.text||e.completedParams.length>0;a.disabled=!b,a.toggleAttribute("data-aia-ready",b&&e.isReady)}let p=i.dataset.newParamId??"",h=e.newParamId!==null&&e.newParamId!==p;if(Kn({input:i,segments:e.segments,newParamId:e.newParamId,editingParamId:e.editingParam?.id??null,placeholderText:e.placeholderText,isFocused:e.isFocused,showChipIcons:n.showChipIcons??!0,showChipImages:n.showChipImages??!0}),s==="inline"){let y=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,m=Et(e.actionableSuggestions);y||m.length>0?Cn(o,m,0,l,!1,y,e.isActivePillSelected):Oi(o)}else Oi(o);ia(i,o),h?(i.focus(),N(i,e.caretOffset??e.text.length)):e.isFocused&&je(i)!==e.text&&N(i,e.text.length);let g=e.editingParam?{parameter:e.editingParam.suggestionParameter,text:e.editingParam.suggestionPlaceholder,required:!0,options:e.editingParam.options}:e.editingIdentified?{parameter:e.editingIdentified.parameter,text:j(e.editingIdentified.parameter),required:!0,options:[]}:null,f=e.dropdownSuggestion??g??e.actionableSuggestions[0],S=Me(e);$n(r,{strings:n.strings,suggestions:f?[{...f,options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:g?[g]:e.actionableSuggestions,showPills:s==="dropdown",showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:S.selectedIso,selectedDateRange:S.selectedRange,dateRangeStart:S.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,locationView:e.locationView,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:d,onHighlight:(y,m)=>{m!==void 0&&c.get().activeDropdownIndex!==m||c.set({activeDropdownIndex:y})},onPillClick:l,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,onProductSelect:n.selectProduct,onProductFocusChange:y=>c.set({isFocused:y})})}function zn(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 p of n)p(c,u)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function ra(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 Yi=new WeakSet,aa=new WeakMap;function la(t){return t.nodeType===Node.DOCUMENT_NODE}function kl(t){return la(t)?t:t.ownerDocument}function Ml(t){let e=aa.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(da),aa.set(t,i),i)}catch{return null}}function sa(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=da,e.appendChild(n)}function ca(t){if(typeof document>"u")return;let e=t??document;if(Yi.has(e))return;let n=kl(e);if(la(e)){let r=e.head??e.documentElement;if(!r)return;sa(n,r),Yi.add(e);return}let i=Ml(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):sa(n,e),Yi.add(e)}var da=`.aia-stack {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -3336,5 +3336,5 @@
|
|
|
3336
3336
|
max-height: min(var(--aia-grid-max-height, 120px), calc(3 * var(--aia-option-row-height, 37px)));
|
|
3337
3337
|
overflow-y: auto;
|
|
3338
3338
|
}
|
|
3339
|
-
`;var qn=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 Kn=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 zn=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 Rl(t){let e;try{e=new URL(t??z).host}catch{return null}let n=ct.get(e);return n?`https://${n}`:null}var ca=new WeakMap;function da(t,e){if(!t.head)return;let n=Rl(e);if(!n)return;let i=ca.get(t);i||(i=new Map,ca.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 _e=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 ji(t){return t.isDropdownOpen&&!t.isLoading}var _l=50,Dl=new Set(["search_started","submit","product_click","impression"]),Nl="newParam",ua="suggestionRemoval",Fl="selectionAnimation",Yi="skeletonExit",pa="locationSearch",Hl=650,Wl=0;function Ul(){return`:ac-${++Wl}:`}var ma=170,Bl=100;function ga(){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 jn=class{constructor(e,n={}){this.inputStore=$n(ga());this._listboxId=Ul();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new zn;this.boundary=new qn;this.subscriberCount=0;this.emitter=new Kn(this.boundary);this.sessionId=crypto.randomUUID();this.lastRequestId=null;this.searchStartedSessionId=null;this.funnelTelemetry=null;this.pendingSearchStarted=!1;this.openWordText=null;this.heldIdentified=null;this.lastImpressionKey="";this.visibleImpression=!1;this.destroyed=!1;this.locationAbort=null;this.locationSession=null;this.emitSubmit=e=>(this.recordSubmit(e),this.emitter.emit("submit",e));this.emitError=e=>this.emitter.emit("error",e);this.container=e,this.opts=n,this.renderMode=n.renderMode??"full",this.store=ia(this.inputStore,i=>$o(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 Ct(this.store,e),this.pillsController=new Jt(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new hn({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new en(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new Xt(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,onRequest:({query:i,signal:o,isCurrent:r})=>{da(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:le(a,o.text),chip_origin:"typed"})},onResponse:({requestId:i,funnelTelemetry:o,visibleImpression:r})=>{this.lastRequestId=i,this.funnelTelemetry=o,this.visibleImpression=r,this.pendingSearchStarted&&(this.pendingSearchStarted=!1,this.fireTelemetry("search_started",{})),this.fireImpression(),this.emitter.hasListeners("result")&&this.emitter.emit("result",this.buildResult())},productsForResponse:i=>this.productsController.forResponse(i),consumerTick:(i,o)=>this.optionSource.tick(i,o),isWordOpen:()=>this.isWordOpen(),holdIdentified:i=>{this.heldIdentified={text:this.store.get().text,candidates:i}}}),this.keyboardController=new Qt(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",afterSubmit:this.renderMode==="full"?()=>this.resetAfterSubmit():void 0,selectOption:i=>this.selectOption(i),removeParamAtCaret:i=>this.removeParamAtCaret(i),startEditingParamAtCaret:i=>this.startEditingParamAtCaret(i),exitEditMode:()=>this.exitEditMode(),exitEditingIdentified:()=>this.exitEditingIdentified(),skipActivePill:()=>this.skipActivePill(),endTypedWord:i=>this.endTypedWord(i),stepTime:i=>this.stepTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()}),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text!==o.text&&this.emitter.emit("change",i.text),i.completedParams!==o.completedParams&&this.emitter.emit("paramsChange",i.completedParams);let r=i.isFocused||i.locationFieldFocused;r!==(o.isFocused||o.locationFieldFocused)&&(r?this.emitter.emit("focus"):this.emitter.emit("blur")),this.emitter.emit("stateChange",i)})),this.unsubscribers.push(this.store.subscribe(()=>this.maybeExitReEditOnNoMatch())),this.unsubscribers.push(this.store.subscribe(()=>{let i=this.store.get();i.locationFieldFocused&&!i.locationView&&this.store.set({locationFieldFocused:!1})})),this.subscribeSkeletonMirror(),this.subscribeVisibleImpression(),this.unsubscribers.push(this.store.subscribe((i,o)=>{if(i.text===o.text&&i.completedParams===o.completedParams||i.identifiedParams.length===0)return;let{valid:r,invalid:a}=Be(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=fo(o.text,i.text,a);if(l===null){this.store.set({pendingSpan:null});return}a=l}i.text.slice(a).trim().length===0||mo(i.segments,a)?this.store.set({pendingSpan:null}):a!==r.anchor&&this.store.set({pendingSpan:{anchor:a,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(sa(this.opts.styleRoot??re(this.container)),this.setupContainer()),this.renderMode==="full"?this.buildAndRenderFull():this.renderMode==="dropdown"&&this.buildAndRenderDropdown(),this.optionSource.start(),this.fetchController.start()}focus(){this.domRefs?.input.focus()}blur(){this.domRefs?.input.blur()}reset(){let{isFocused:e,dropdownHeld:n}=this.store.get();this.optionSource.reset(),this.store.set({...ga(),isFocused:e,dropdownHeld:n,skipNextFetch:!0}),this.sessionId=crypto.randomUUID(),this.lastRequestId=null,this.lastImpressionKey="",this.pendingSearchStarted=!1,this.fetchController.doFetch("",[])}resetAfterSubmit(){this.opts.resetOnSubmit!==!1&&this.reset()}destroy(){this.destroyed=!0,this.fetchController.dispose(),this.optionSource.dispose(),this.holdOpen.dispose(),this.cancelLocationSearch(),this.modeController?.destroy(),this.timers.clearAll(),this.emitter.clear();for(let e of this.unsubscribers)e();this.unsubscribers=[],this.domRefs?.abort.abort(),this.domRefs&&(or(this.domRefs.input),$i(this.domRefs.dropdown)),this.dropdownRefs&&$i(this.dropdownRefs.dropdown),this.domRefs=null,this.dropdownRefs=null,this.renderMode!=="headless"&&(this.container.innerHTML="")}setMode(e){this.modeController?.setMode(e)}prefillText(e){this.applyTextChange(e,!1)}noteSearchStarted(){this.searchStartedSessionId!==this.sessionId&&(this.searchStartedSessionId=this.sessionId,this.funnelTelemetry===null?this.pendingSearchStarted=!0:this.fireTelemetry("search_started",{}))}setValue(e){let n=this.store.get();if(n.editingIdentified&&e!==n.text){this.store.set({text:e,editingIdentified:null,activeDropdownIndex:-1});return}this.store.set({text:e})}setCompletedParams(e){this.store.set({completedParams:e})}setActivePill(e){this.pillsController.setActivePill(e);let n=this.store.get().text.length;this.store.set({caretOffset:n,isFocused:!0}),this.scheduleSetCursor(n)}removeLastParam(){this.pillsController.removeLastParam()}findChipSpanAt(e){let n=0;for(let i of this.store.get().segments){let o=n;if(n+=i.value.length,i.type!=="text"&&e>o&&e<=n)return{kind:i.type,param:i.param,start:o,end:n}}return null}withoutChip(e,n){return n.kind==="completed"?{completedParams:e.completedParams.filter(i=>i.id!==n.param.id&&(!n.param.group||i.group!==n.param.group))}:{identifiedParams:e.identifiedParams.filter(i=>i.id!==n.param.id)}}removeParamAtCaret(e){let n=this.findChipSpanAt(e);if(!n)return!1;let{text:i}=this.store.get(),{start:o,end:r}=n;if(e===r){let{text:l,removed:d}=fn(i,o,r);return this.store.set(c=>({text:l,filterBase:Math.min(c.filterBase>o?Math.max(o,c.filterBase-d):c.filterBase,l.length),...this.withoutChip(c,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(o),!0}let a=Vt(i,e),s=i.slice(0,a)+i.slice(e);return this.store.set(l=>({text:s,filterBase:Math.min(l.filterBase,s.length),...this.withoutChip(l,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(a),!0}startEditingParamAtCaret(e){let n=this.findChipSpanAt(e);return!n||n.kind!=="completed"||n.end!==e||this.store.get().completedParams.find(i=>i.id===n.param.id)?.group?!1:(this.reEdit.start(n.param.id),this.store.get().editingParam?.id===n.param.id)}scheduleSetCursor(e){queueMicrotask(()=>{let n=this.domRefs;if(n)n.input.focus(),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=K(i);if(!A(o))return!1;let r=o==="date-range"?Ze(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:nn(i),isoEnd:r?r.end:null,format:o},editingParam:null,editingAnchor:null,editingTail:null,caretOffset:l,activeDropdownIndex:-1,pillTapped:!0}),!0}exitEditingIdentified(){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1})}startEditingParam(e){this.store.get().completedParams.find(n=>n.id===e)?.group||(this.reEdit.start(e),this.store.get().editingParam?.id!==e&&this.startEditingIdentified(e))}replaceEditingRange(e){return this.reEdit.replaceRange(e)}exitEditMode(){this.reEdit.exit()}handleCaretAfterInput(e){this.reEdit.caretAfterInput(e)}handleCaretMove(e){let n=this.store.get().editingIdentified;n&&e!=null&&(e<n.anchor||e>n.tail)&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.reEdit.caretMove(e)}setActiveDropdownIndex(e){this.store.set({activeDropdownIndex:e})}clearHighlight(e){this.store.get().activeDropdownIndex===e&&this.store.set({activeDropdownIndex:-1})}prepareSubmit(){this.endTypedWord(!0)}recordSubmit(e){this.fireTelemetry("submit",{query:e.query,completed_pills:e.completed_params.filter(n=>n.placeholder).map(n=>({key:n.parameter,value:n.text??""}))})}selectProduct(e){let n=this.store.get(),i=n.products.findIndex(r=>r.id===e.id),o=n.customFields?.items?.matched?.find(r=>r.source_id===e.id)?.origin_id;this.fireTelemetry("product_click",{query:n.text,product_id:e.id,...o&&{origin_id:o},position:i>=0?i+1:null}),this.emitter.emit("productSelect",e)}addProductToCart(e){let n=this.opts.onProductAddToCart;if(!n)return Promise.resolve();try{return Promise.resolve(n(e)).then(()=>{})}catch(i){return Promise.reject(i)}}hasProductAddToCart(){return typeof this.opts.onProductAddToCart=="function"}handleTextChange(e){this.applyTextChange(e,!0)}applyTextChange(e,n){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.handleChange(e,n)}showPreviousMonth(){this.pageDateView(-1)}showNextMonth(){this.pageDateView(1)}pageDateView(e){let n=this.store.get();if(!A(n.activeFormatType)||!n.dateView)return;let i=It(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:Ce(e),key:W(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(_o(n.minutes,e))}toggleMultiSelectOption(e){let n=this.store.get();if(!n.multiSelectView||!e.is_tappable)return;let i=n.multiSelectView.picked;this.store.set({multiSelectDraft:{key:W(n),picked:i.includes(e.text)?i.filter(o=>o!==e.text):[...i,e.text]}})}commitMultiSelect(){this.finishMultiSelect()}answerMultiSelectWith(e){let n=this.store.get().multiSelectView;!n||!e.is_tappable||(n.picked.includes(e.text)||this.toggleMultiSelectOption(e),this.finishMultiSelect())}finishMultiSelect(e=""){let n=this.store.get();if(!n.multiSelectView)return;let i=n.multiSelectView.picked;if(i.length===0){this.store.set({multiSelectDraft:null}),this.skipActivePill();return}let o=i.map(a=>n.actionableSuggestions[0].options?.find(s=>s.text===a)).filter(a=>a!==void 0);if(o.length===0)return;let r=i.length===1?i[0]:`${i.slice(0,-1).join(", ")} ${O(this.opts.language).and} ${i[i.length-1]}`;this.applyOption({text:r,is_tappable:!0,kind:null},o,e),n.text||this.noteSearchStarted()}commitTime(){let e=this.store.get();e.activeFormatType!=="time"||!e.timeView||(this.selectOption(Kt(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?ft(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(pa,()=>{this.runLocationSearch(o,e,a)},Ji)}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(gt(r??a)),this.store.get().completedParams!==n.completedParams&&this.store.set({locationSearch:null}))}async runLocationSearch(e,n,i){let o=new AbortController;this.locationAbort=o,this.locationSession?.key!==e&&(this.locationSession={key:e,token:crypto.randomUUID()});let r;try{r={places:await oo(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 Ne&&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(pa),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||E(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 se(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields})}get listboxId(){return this._listboxId}get isReady(){return this.store.get().isReady}on(e,n){return this.emitter.on(e,n)}refreshProducts(){this.opts.mapProducts&&this.productsController.refresh()}update(e){let n=this.opts.products,i=this.opts.mapProducts,o=this.opts.showProducts,r=this.opts.optionOverrides;Object.assign(this.opts,e),"language"in e&&this.updateLanguageAttribute(),"optionOverrides"in e&&e.optionOverrides!==r&&this.optionSource.refresh(),"products"in e&&e.products!==n||"showProducts"in e&&e.showProducts!==o?this.productsController.resync():"mapProducts"in e&&e.mapProducts!==i&&this.productsController.refresh(),e.mode!==void 0&&this.modeController?.setMode(e.mode),e.optionsPosition!==void 0&&(this.container.dataset.optionsPosition=e.optionsPosition),e.animations!==void 0&&(this.container.dataset.animations=e.animations?"on":"off"),e.pillPlacement!==void 0&&(this.container.dataset.pillPlacement=e.pillPlacement,this.store.set({})),(e.dropdownTrigger!==void 0||e.closeDropdownOnBlur!==void 0||e.showNonTappableOptions!==void 0||e.showSkipButton!==void 0||e.showOptionIcons!==void 0||e.showOptionImages!==void 0||e.showOptionCounts!==void 0||e.productsLayout!==void 0||e.productImageFallback!==void 0||e.showChipIcons!==void 0||e.showChipImages!==void 0||"language"in e)&&this.store.set({}),e.value!==void 0&&this.setValue(e.value),e.completedParams!==void 0&&this.store.set({completedParams:e.completedParams})}selectOption(e,n){if(this.store.get().multiSelectView){n?.commit?this.answerMultiSelectWith(e):this.toggleMultiSelectOption(e);return}let o=!this.store.get().text;this.applyOption(e),o&&this.store.get().text&&this.noteSearchStarted()}applyOption(e,n,i=""){let o=this.store.get();if(o.activeFormatType==="date-range"){let a=Q(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(Bo(s,a));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(Yi),this.reEdit.selectOption(e);return}let r=Yo(o,e);if(r){if(n){let a=r.patch.completedParams?.[o.completedParams.length];if(!a||!r.patch.text)return;let s=crypto.randomUUID(),l=r.patch.text,d=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),c=n.map(u=>{let m=l.toLowerCase().indexOf(u.text.toLowerCase(),d);return d=m+u.text.length,{...a,value:u.value,kind:u.kind,metadata:u.metadata,icon:u.icon,icon_svg:u.icon_svg,image_url:u.image_url,id:crypto.randomUUID(),group:s,parameter:r.consumedSuggestion.parameter,text:l.slice(m,d)}});r.patch.completedParams=[...o.completedParams,...c],r.patch.newParamId=c[0].id,r.patch.multiSelectDraft=null,r.patch.text+=i,r.patch.caretOffset=r.patch.text.length,r.patch.suggestions=o.suggestions.filter(u=>u!==r.consumedSuggestion)}for(let a of n??[e])this.fireTelemetry("option",{raw_query:N(o.text,o.completedParams).rawQuery,selected_option:a.text,other_options:_(o.activeFormatType)?[]:o.filteredOptions.filter(s=>s.text!==a.text).map(s=>s.text),key:r.telemetry.key,position:_(o.activeFormatType)?null:le(r.consumedSuggestion.options??[],a.text),chip_origin:"tap"});if(this.timers.clear(Yi),this.store.set({...r.patch,...gn(o)}),this.startSelectionAnimationTimer(),this.timers.clear(ua),r.remainingActionable>0){let a=r.consumedSuggestion;this.timers.schedule(ua,()=>{this.store.get().suggestions.includes(a)&&this.store.set(s=>({suggestions:s.suggestions.filter(l=>l!==a)}))},ma)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(Fl,()=>this.store.set({inSelectionAnimation:!1}),ma)}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=""),ji(e)&&!ji(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!ji(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!E(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,_l).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&&Dl.has(e))return;if(!i&&e==="option"){let{key:r,position:a,chip_origin:s,...l}=n;n=l}let o=this.resolveSource();jo({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:ie(this.opts.language),queryData:n,apiConfig:this.opts.apiConfig})}updateLanguageAttribute(){let{language:e}=O(this.opts.language);e!=="en"?this.container.dataset.aiaLanguage=e:delete this.container.dataset.aiaLanguage}setupContainer(){this.container.classList.add("magicx-aia"),this.updateLanguageAttribute(),this.container.dataset.pillPlacement=this.renderMode==="dropdown"?"dropdown":this.opts.pillPlacement??"dropdown",this.container.dataset.optionsPosition=this.opts.optionsPosition??"below",this.container.dataset.animations=this.opts.animations??!0?"on":"off",this.modeController=new _e(this.container,this.opts.mode??"auto")}buildAndRenderFull(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return O(e.opts.language)},get pillPlacement(){return e.opts.pillPlacement??"dropdown"},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get showChipIcons(){return e.opts.showChipIcons??!0},get showChipImages(){return e.opts.showChipImages??!0},get optionsPosition(){return e.opts.optionsPosition??"below"},get onSubmit(){return e.emitter.hasListeners("submit")?e.emitSubmit:void 0},afterSubmit:()=>e.resetAfterSubmit(),endTypedWord:()=>e.endTypedWord(!0),submitButton:this.opts.submitButton,autoFocus:this.opts.autoFocus??!0,selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o),handleKeyDown:o=>this.keyboardController.handleKeyDown(o),handleChange:o=>this.handleChange(o,!0),startEditingParam:o=>this.startEditingParam(o),handleCaretAfterInput:o=>this.handleCaretAfterInput(o),handleCaretMove:o=>this.handleCaretMove(o),replaceEditingRange:o=>this.replaceEditingRange(o)};this.domRefs=na(this.container,n);let i=()=>{this.domRefs&&Ki(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),Ki(this.domRefs,this.store.get(),n),this.subscribeNewParamTimer()}buildAndRenderDropdown(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return O(e.opts.language)},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get optionsPosition(){return e.opts.optionsPosition??"below"},selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o)};this.dropdownRefs=Qr(this.container,n);let i=()=>{this.dropdownRefs&&qi(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),qi(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(et),i=()=>e();n.addEventListener("change",i),this.unsubscribers.push(()=>n.removeEventListener("change",i))}subscribeBatchedRender(e){let n=!1;this.unsubscribers.push(this.store.subscribe(()=>{n||(n=!0,queueMicrotask(()=>{n=!1,e()}))}))}subscribeSkeletonMirror(){this.unsubscribers.push(this.store.subscribe((e,n)=>{if(!e.skeletonOptions)return;if(!n.isLoading&&e.isLoading){e.skeletonRequested||this.store.set({skeletonRequested:!0});return}if(!n.isLoading||e.isLoading)return;let i={skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1};if(!e.skeletonExiting){this.store.set(i);return}this.timers.schedule(Yi,()=>this.store.set(i),Bl)}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(Nl,()=>this.store.set({newParamId:null}),Hl)}))}handleChange(e,n){let i=this.store.get();n&&e&&!i.text&&this.noteSearchStarted(),this.store.set({text:e,pillTapped:!1,activeDropdownIndex:-1});let{valid:o,invalid:r}=So(e,i.completedParams);r.length>0&&this.store.set({completedParams:o});let a=this.heldIdentified;this.heldIdentified=null,this.openWordText=n&&/\S$/.test(e)?e:null,this.maybePromoteExactMatch(e),a&&/^\s+$/.test(e.slice(a.text.length))&&e.startsWith(a.text)&&this.admitIdentified(a.candidates),this.maybeOpenPendingSpan();let s=this.store.get();s.multiSelectView&&s.optionQuery&&s.filteredOptions.length===0&&this.finishMultiSelect(s.optionQuery)}isWordOpen(){return this.opts.commitOnWordEnd===!0&&this.openWordText===this.store.get().text}admitIdentified(e){let n=this.store.get(),{valid:i}=Be(n.text,n.completedParams,e);i.length!==0&&this.store.set({identifiedParams:[...n.identifiedParams,...i]})}endTypedWord(e=!1){let n=this.isWordOpen();if(!n&&!e)return!1;let i=this.heldIdentified;this.heldIdentified=null,this.openWordText=null;let o=this.store.get();this.maybePromoteExactMatch(o.text,e?"submit":"fresh",n),i?.text===o.text&&this.admitIdentified(i.candidates);let r=this.store.get();return r.completedParams!==o.completedParams||r.identifiedParams!==o.identifiedParams}maybeOpenPendingSpan(){let e=this.store.get();if(e.pendingSpan||e.actionableSuggestions.length===0)return;let n=oe(e.text,Math.min(e.filterBase,e.text.length),e.placeholderText),i=po(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);pe(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:j(i.parameter),options:[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url};this.fireTelemetry("option",{raw_query: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(m=>m.id!==i.id),newParamId:u.id,filterBase:c,caretOffset:c,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(c),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(_(o.activeFormatType)||this.isWordOpen())return;let r=pn({mode:n,finishWord:i,text:e,completedParams:o.completedParams,suggestions:o.suggestions,filterBase:o.filterBase,filterInProgress:o.filterInProgress,phraseExactMatch:this.fetchController.isPhraseExactMatch()});if(r){if(this.funnelTelemetry===!0){let a=n==="submit"&&r.suggestion?r.suggestion:o.actionableSuggestions[0],s=a.options??[];this.fireTelemetry("option",{raw_query: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:le(s,r.option.text),chip_origin:"typed"})}this.store.set(r.patch)}}};0&&(module.exports={AIAutocomplete,ATTRIBUTION_URL,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,EDITOR_GROW_MS,LOCATION_META_KEY,LOCATION_MIN_QUERY,MULTI_SELECT_TOGGLE_MIN_PX,MULTI_SELECT_TOGGLE_SLOP_PX,ModeController,OPTIONS_GRID_MOBILE_QUERY,OPTION_ENTER_DELAY_VAR,OPTION_ENTER_FADE_MS,OPTION_ENTER_RISE_MS,OPTION_ENTER_RISE_PX,OPTION_ENTER_STAGGER_MS,OPTION_IMAGE_WIDTH,PLACEHOLDER_FADE_OUT_MS,PLACEHOLDER_LEAVING_ATTR,PLACEHOLDER_SWAP_GAP_MS,PLACEHOLDER_TYPE_MS,PLACEHOLDER_WORD_PAUSE_MS,PRODUCT_IMAGE_WIDTH,PRODUCT_PATH_PREFIX,PRODUCT_ROW_PX_PER_LINE,RANGE_SEPARATOR,SCHEMA_VERSION,SCROLL_ARROW_ATTR,SCROLL_ARROW_BOTTOM_VAR,SCROLL_ARROW_CLASS,SCROLL_ARROW_FADE_MS,SCROLL_ARROW_LABEL,SCROLL_ARROW_SCROLL_IDLE_MS,SCROLL_ARROW_VISIBLE_ATTR,SKIPPED_PARAM_TEXT,SMART_SUGGESTION_SPARKLE_SVG,TIME_META_KEY,TIME_STEP_MINUTES,TIME_WHEEL_COLUMNS,TIME_WHEEL_ROW_HEIGHT,VIEWPORT_FIT_ATTR,VIEWPORT_FIT_HEIGHT_VAR,WEEKDAY_LABELS,addMonths,attachProductRowWheel,attachScrollArrow,attachViewportFit,buildAttributionUrl,buildDateOptions,buildLocationOption,buildQuery,buildSubmitResult,buildTimeOption,cellDay,cellIso,chipIdFromTap,computeOptionsGridLayout,containScroll,createStore,cursorIsAtEnd,dateCellMarks,dateSelectionFor,extractPlainText,formatAbsoluteDate,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,getCursorOffset,getFooterHint,hasSkippablePill,highlightParts,identifiedParamLabel,isCalendarFormat,isMultiSelectToggleTap,isOptionsGridMobileViewport,isPickerFormat,isSmartSuggestion,isTraditionalAutocompleteSuggestion,isoDate,isoTime,keepCaretOnChip,labelTraditionalAutocomplete,locationEndpointFor,matchTypedPhrase,measureOptionsGrid,monthLabel,needsOptionsGridMeasurement,optionCountLabel,optionEnterDelayMs,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsEntranceDurationMs,optionsGridTemplateColumns,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,parseTime,plainTextLength,planOptionsGrid,previousGraphemeBoundary,productFromMatchedItem,productImageSources,productImageSrc,productInitial,productPhotoFill,productRowWheelTarget,productsFromCustomFields,renderEditableContent,resolveFormatType,resolveIdentifiedDate,sameOptionRows,sanitizeOptionIconSvg,scrollCaretIntoView,selectedIsoFromText,selectedRangeFor,setCursorOffset,shopifyImageSrc,timeWheelIndex,timeWheelIndexFromScroll,timeWheelRows,toWireIdentifiedParams,typedFragment,uiStringsFor,visibleDateRange,watchEditorHeight,withSkippedParams,withTimeWheelIndex,withoutTraditionalAutocomplete});
|
|
3339
|
+
`;var jn=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 Qn=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 Rl(t){let e;try{e=new URL(t??z).host}catch{return null}let n=pt.get(e);return n?`https://${n}`:null}var ua=new WeakMap;function pa(t,e){if(!t.head)return;let n=Rl(e);if(!n)return;let i=ua.get(t);i||(i=new Map,ua.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 De=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 Qi(t){return t.isDropdownOpen&&!t.isLoading}var _l=50,Dl=new Set(["search_started","submit","product_click","impression"]),Nl="newParam",ma="suggestionRemoval",Fl="selectionAnimation",Xi="skeletonExit",ga="locationSearch",Hl=650,Wl=0;function Ul(){return`:ac-${++Wl}:`}var fa=170,Bl=100;function ha(){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 Xn=class{constructor(e,n={}){this.inputStore=zn(ha());this._listboxId=Ul();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new Qn;this.boundary=new jn;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.heldIdentified=null;this.waitingIdentified=null;this.lastImpressionKey="";this.visibleImpression=!1;this.destroyed=!1;this.locationAbort=null;this.locationSession=null;this.emitSubmit=e=>(this.recordSubmit(e),this.emitter.emit("submit",e));this.emitError=e=>this.emitter.emit("error",e);this.container=e,this.opts=n,this.renderMode=n.renderMode??"full",this.store=ra(this.inputStore,i=>Ko(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 At(this.store,e),this.pillsController=new tn(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new yn({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new on(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new en(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 Lt(this.store,()=>this.opts.apiConfig,()=>this.opts.optionOverrides,()=>this.opts.maskCompletedText,()=>this.emitter.hasListeners("error")?this.emitError:void 0,()=>this.sessionId,()=>this.resolveSource(),()=>this.opts.additionalContext,()=>this.opts.language,{getProductId:()=>this.opts.productId,getCurrency:()=>this.opts.currency,onRequest:({query:i,signal:o,isCurrent:r})=>{pa(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:ae(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 Zt(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",afterSubmit:this.renderMode==="full"?()=>this.resetAfterSubmit():void 0,selectOption:i=>this.selectOption(i),removeParamAtCaret:i=>this.removeParamAtCaret(i),startEditingParamAtCaret:i=>this.startEditingParamAtCaret(i),exitEditMode:()=>this.exitEditMode(),exitEditingIdentified:()=>this.exitEditingIdentified(),skipActivePill:()=>this.skipActivePill(),endTypedWord:i=>this.endTypedWord(i),stepTime:i=>this.stepTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()}),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text!==o.text&&this.emitter.emit("change",i.text),i.completedParams!==o.completedParams&&this.emitter.emit("paramsChange",i.completedParams);let r=i.isFocused||i.locationFieldFocused;r!==(o.isFocused||o.locationFieldFocused)&&(r?this.emitter.emit("focus"):this.emitter.emit("blur")),this.emitter.emit("stateChange",i)})),this.unsubscribers.push(this.store.subscribe(()=>this.maybeExitReEditOnNoMatch())),this.unsubscribers.push(this.store.subscribe(()=>{let i=this.store.get();i.locationFieldFocused&&!i.locationView&&this.store.set({locationFieldFocused:!1})})),this.subscribeSkeletonMirror(),this.subscribeVisibleImpression(),this.unsubscribers.push(this.store.subscribe((i,o)=>{if(i.text===o.text&&i.completedParams===o.completedParams||i.identifiedParams.length===0)return;let{valid:r,invalid:a}=Ge(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=bo(o.text,i.text,a);if(l===null){this.store.set({pendingSpan:null});return}a=l}i.text.slice(a).trim().length===0||fo(i.segments,a)?this.store.set({pendingSpan:null}):a!==r.anchor&&this.store.set({pendingSpan:{anchor:a,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(ca(this.opts.styleRoot??ie(this.container)),this.setupContainer()),this.renderMode==="full"?this.buildAndRenderFull():this.renderMode==="dropdown"&&this.buildAndRenderDropdown(),this.optionSource.start(),this.fetchController.start()}focus(){this.domRefs?.input.focus()}blur(){this.domRefs?.input.blur()}reset(){let{isFocused:e,dropdownHeld:n}=this.store.get();this.optionSource.reset(),this.store.set({...ha(),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&&(ar(this.domRefs.input),Ki(this.domRefs.dropdown)),this.dropdownRefs&&Ki(this.dropdownRefs.dropdown),this.domRefs=null,this.dropdownRefs=null,this.renderMode!=="headless"&&(this.container.innerHTML="")}setMode(e){this.modeController?.setMode(e)}prefillText(e){this.applyTextChange(e,!1)}noteSearchStarted(){this.searchStartedSessionId!==this.sessionId&&(this.searchStartedSessionId=this.sessionId,this.funnelTelemetry===null?this.pendingSearchStarted=!0:this.fireTelemetry("search_started",{}))}setValue(e){let n=this.store.get();if(n.editingIdentified&&e!==n.text){this.store.set({text:e,editingIdentified:null,activeDropdownIndex:-1});return}this.store.set({text:e})}setCompletedParams(e){this.store.set({completedParams:e})}setActivePill(e){this.pillsController.setActivePill(e);let n=this.store.get().text.length;this.store.set({caretOffset:n,isFocused:!0}),this.scheduleSetCursor(n)}removeLastParam(){this.pillsController.removeLastParam()}findChipSpanAt(e){let n=0;for(let i of this.store.get().segments){let o=n;if(n+=i.value.length,i.type!=="text"&&e>o&&e<=n)return{kind:i.type,param:i.param,start:o,end:n}}return null}withoutChip(e,n){return n.kind==="completed"?{completedParams:e.completedParams.filter(i=>i.id!==n.param.id&&(!n.param.group||i.group!==n.param.group))}:{identifiedParams:e.identifiedParams.filter(i=>i.id!==n.param.id)}}removeParamAtCaret(e){let n=this.findChipSpanAt(e);if(!n)return!1;let{text:i}=this.store.get(),{start:o,end:r}=n;if(e===r){let{text:l,removed:d}=Sn(i,o,r);return this.store.set(c=>({text:l,filterBase:Math.min(c.filterBase>o?Math.max(o,c.filterBase-d):c.filterBase,l.length),...this.withoutChip(c,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(o),!0}let a=qt(i,e),s=i.slice(0,a)+i.slice(e);return this.store.set(l=>({text:s,filterBase:Math.min(l.filterBase,s.length),...this.withoutChip(l,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(a),!0}startEditingParamAtCaret(e){let n=this.findChipSpanAt(e);return!n||n.kind!=="completed"||n.end!==e||this.store.get().completedParams.find(i=>i.id===n.param.id)?.group?!1:(this.reEdit.start(n.param.id),this.store.get().editingParam?.id===n.param.id)}scheduleSetCursor(e){queueMicrotask(()=>{let n=this.domRefs;if(n)n.input.focus(),N(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=K(i);if(!k(o))return!1;let r=o==="date-range"?tt(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:an(i),isoEnd:r?r.end:null,format:o},editingParam:null,editingAnchor:null,editingTail:null,caretOffset:l,activeDropdownIndex:-1,pillTapped:!0}),!0}exitEditingIdentified(){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1})}startEditingParam(e){this.store.get().completedParams.find(n=>n.id===e)?.group||(this.reEdit.start(e),this.store.get().editingParam?.id!==e&&this.startEditingIdentified(e))}replaceEditingRange(e){return this.reEdit.replaceRange(e)}exitEditMode(){this.reEdit.exit()}handleCaretAfterInput(e){this.reEdit.caretAfterInput(e)}handleCaretMove(e){let n=this.store.get().editingIdentified;n&&e!=null&&(e<n.anchor||e>n.tail)&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.reEdit.caretMove(e)}setActiveDropdownIndex(e){this.store.set({activeDropdownIndex:e})}clearHighlight(e){this.store.get().activeDropdownIndex===e&&this.store.set({activeDropdownIndex:-1})}prepareSubmit(){this.endTypedWord(!0)}recordSubmit(e){this.fireTelemetry("submit",{query:e.query,completed_pills:e.completed_params.filter(n=>n.placeholder).map(n=>({key:n.parameter,value:n.text??""}))})}selectProduct(e){let n=this.store.get(),i=n.products.findIndex(r=>r.id===e.id),o=n.customFields?.items?.matched?.find(r=>r.source_id===e.id)?.origin_id;this.fireTelemetry("product_click",{query:n.text,product_id:e.id,...o&&{origin_id:o},position:i>=0?i+1:null}),this.emitter.emit("productSelect",e)}addProductToCart(e){let n=this.opts.onProductAddToCart;if(!n)return Promise.resolve();try{return Promise.resolve(n(e)).then(()=>{})}catch(i){return Promise.reject(i)}}hasProductAddToCart(){return typeof this.opts.onProductAddToCart=="function"}handleTextChange(e){this.applyTextChange(e,!0)}applyTextChange(e,n){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.handleChange(e,n)}showPreviousMonth(){this.pageDateView(-1)}showNextMonth(){this.pageDateView(1)}pageDateView(e){let n=this.store.get();if(!k(n.activeFormatType)||!n.dateView)return;let i=kt(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:Ie(e),key:W(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(No(n.minutes,e))}toggleMultiSelectOption(e){let n=this.store.get();if(!n.multiSelectView||!e.is_tappable)return;let i=n.multiSelectView.picked;this.store.set({multiSelectDraft:{key:W(n),picked:i.includes(e.text)?i.filter(o=>o!==e.text):[...i,e.text]}})}commitMultiSelect(){this.finishMultiSelect()}answerMultiSelectWith(e){let n=this.store.get().multiSelectView;!n||!e.is_tappable||(n.picked.includes(e.text)||this.toggleMultiSelectOption(e),this.finishMultiSelect())}finishMultiSelect(e=""){let n=this.store.get();if(!n.multiSelectView)return;let i=n.multiSelectView.picked;if(i.length===0){this.store.set({multiSelectDraft:null}),this.skipActivePill();return}let o=i.map(a=>n.actionableSuggestions[0].options?.find(s=>s.text===a)).filter(a=>a!==void 0);if(o.length===0)return;let r=i.length===1?i[0]:`${i.slice(0,-1).join(", ")} ${O(this.opts.language).and} ${i[i.length-1]}`;this.applyOption({text:r,is_tappable:!0,kind:null},o,e),n.text||this.noteSearchStarted()}commitTime(){let e=this.store.get();e.activeFormatType!=="time"||!e.timeView||(this.selectOption(Yt(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?St(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(ga,()=>{this.runLocationSearch(o,e,a)},eo)}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(bt(r??a)),this.store.get().completedParams!==n.completedParams&&this.store.set({locationSearch:null}))}async runLocationSearch(e,n,i){let o=new AbortController;this.locationAbort=o,this.locationSession?.key!==e&&(this.locationSession={key:e,token:crypto.randomUUID()});let r;try{r={places:await ao(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 He&&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(ga),this.locationAbort?.abort(),this.locationAbort=null}skipActivePill(){let e=this.store.get();if(e.editingParam||e.inSelectionAnimation)return;let n=e.suggestions.filter(s=>s.parameter==="placeholder"),i=e.suggestions.filter(s=>s.parameter!=="placeholder");if(i.length===0||w(i[0]))return;let o=i[0],r=i.slice(1),a=e.skippedParams.some(s=>s.parameter===o.parameter);this.store.set({suggestions:[...n,...r],pillTapped:r.length>0,activeDropdownIndex:-1,...a?{}:{skippedParams:[...e.skippedParams,{id:crypto.randomUUID(),parameter:o.parameter,suggestionPlaceholder:o.text}]}}),r.length===0&&this.fetchNow()}handleKeyDown(e){this.keyboardController.handleKeyDown(e)}setFocused(e){this.store.get().isFocused!==e&&this.store.set({isFocused:e})}setLocationFieldFocused(e){this.store.get().locationFieldFocused!==e&&this.store.set({locationFieldFocused:e})}subscribe(e){let n=`subscribe#${++this.subscriberCount}`;return this.store.subscribe(i=>{this.boundary.runListener("subscribe",()=>e(i),n)})}getState(){return this.store.get()}getResult(){return this.buildResult()}getRequestId(){return this.lastRequestId}buildResult(){let e=this.store.get();return re(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields})}get listboxId(){return this._listboxId}get isReady(){return this.store.get().isReady}on(e,n){return this.emitter.on(e,n)}refreshProducts(){this.opts.mapProducts&&this.productsController.refresh()}update(e){let n=this.opts.products,i=this.opts.mapProducts,o=this.opts.showProducts,r=this.opts.optionOverrides;Object.assign(this.opts,e),"language"in e&&this.updateLanguageAttribute(),"optionOverrides"in e&&e.optionOverrides!==r&&this.optionSource.refresh(),"products"in e&&e.products!==n||"showProducts"in e&&e.showProducts!==o?this.productsController.resync():"mapProducts"in e&&e.mapProducts!==i&&this.productsController.refresh(),e.mode!==void 0&&this.modeController?.setMode(e.mode),e.optionsPosition!==void 0&&(this.container.dataset.optionsPosition=e.optionsPosition),e.animations!==void 0&&(this.container.dataset.animations=e.animations?"on":"off"),e.pillPlacement!==void 0&&(this.container.dataset.pillPlacement=e.pillPlacement,this.store.set({})),(e.dropdownTrigger!==void 0||e.closeDropdownOnBlur!==void 0||e.showNonTappableOptions!==void 0||e.showSkipButton!==void 0||e.showOptionIcons!==void 0||e.showOptionImages!==void 0||e.showOptionCounts!==void 0||e.productsLayout!==void 0||e.productImageFallback!==void 0||e.showChipIcons!==void 0||e.showChipImages!==void 0||"language"in e)&&this.store.set({}),e.value!==void 0&&this.setValue(e.value),e.completedParams!==void 0&&this.store.set({completedParams:e.completedParams})}selectOption(e,n){if(this.store.get().multiSelectView){n?.commit?this.answerMultiSelectWith(e):this.toggleMultiSelectOption(e);return}let o=!this.store.get().text;this.applyOption(e),o&&this.store.get().text&&this.noteSearchStarted()}applyOption(e,n,i=""){let o=this.store.get();if(o.activeFormatType==="date-range"){let a=Q(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(Go(s,a));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(Xi),this.reEdit.selectOption(e);return}let r=Xo(o,e);if(r){if(n){let a=r.patch.completedParams?.[o.completedParams.length];if(!a||!r.patch.text)return;let s=crypto.randomUUID(),l=r.patch.text,d=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),c=n.map(u=>{let p=l.toLowerCase().indexOf(u.text.toLowerCase(),d);return d=p+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(p,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:D(o.text,o.completedParams).rawQuery,selected_option:a.text,other_options:_(o.activeFormatType)?[]:o.filteredOptions.filter(s=>s.text!==a.text).map(s=>s.text),key:r.telemetry.key,position:_(o.activeFormatType)?null:ae(r.consumedSuggestion.options??[],a.text),chip_origin:"tap"});if(this.timers.clear(Xi),this.store.set({...r.patch,...bn(o)}),this.startSelectionAnimationTimer(),this.timers.clear(ma),r.remainingActionable>0){let a=r.consumedSuggestion;this.timers.schedule(ma,()=>{this.store.get().suggestions.includes(a)&&this.store.set(s=>({suggestions:s.suggestions.filter(l=>l!==a)}))},fa)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(Fl,()=>this.store.set({inSelectionAnimation:!1}),fa)}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=""),Qi(e)&&!Qi(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!Qi(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!w(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,_l).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&&Dl.has(e))return;if(!i&&e==="option"){let{key:r,position:a,chip_origin:s,...l}=n;n=l}let o=this.resolveSource();Qo({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:te(this.opts.language),queryData:n,apiConfig:this.opts.apiConfig})}updateLanguageAttribute(){let{language:e}=O(this.opts.language);e!=="en"?this.container.dataset.aiaLanguage=e:delete this.container.dataset.aiaLanguage}setupContainer(){this.container.classList.add("magicx-aia"),this.updateLanguageAttribute(),this.container.dataset.pillPlacement=this.renderMode==="dropdown"?"dropdown":this.opts.pillPlacement??"dropdown",this.container.dataset.optionsPosition=this.opts.optionsPosition??"below",this.container.dataset.animations=this.opts.animations??!0?"on":"off",this.modeController=new De(this.container,this.opts.mode??"auto")}buildAndRenderFull(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return O(e.opts.language)},get pillPlacement(){return e.opts.pillPlacement??"dropdown"},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get showChipIcons(){return e.opts.showChipIcons??!0},get showChipImages(){return e.opts.showChipImages??!0},get optionsPosition(){return e.opts.optionsPosition??"below"},get onSubmit(){return e.emitter.hasListeners("submit")?e.emitSubmit:void 0},afterSubmit:()=>e.resetAfterSubmit(),endTypedWord:()=>e.endTypedWord(!0),submitButton:this.opts.submitButton,autoFocus:this.opts.autoFocus??!0,selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o),handleKeyDown:o=>this.keyboardController.handleKeyDown(o),handleChange:o=>this.handleChange(o,!0),startEditingParam:o=>this.startEditingParam(o),handleCaretAfterInput:o=>this.handleCaretAfterInput(o),handleCaretMove:o=>this.handleCaretMove(o),replaceEditingRange:o=>this.replaceEditingRange(o)};this.domRefs=oa(this.container,n);let i=()=>{this.domRefs&&ji(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),ji(this.domRefs,this.store.get(),n),this.subscribeNewParamTimer()}buildAndRenderDropdown(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return O(e.opts.language)},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get optionsPosition(){return e.opts.optionsPosition??"below"},selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o)};this.dropdownRefs=Jr(this.container,n);let i=()=>{this.dropdownRefs&&zi(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),zi(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(nt),i=()=>e();n.addEventListener("change",i),this.unsubscribers.push(()=>n.removeEventListener("change",i))}subscribeBatchedRender(e){let n=!1;this.unsubscribers.push(this.store.subscribe(()=>{n||(n=!0,queueMicrotask(()=>{n=!1,e()}))}))}subscribeSkeletonMirror(){this.unsubscribers.push(this.store.subscribe((e,n)=>{if(!e.skeletonOptions)return;if(!n.isLoading&&e.isLoading){e.skeletonRequested||this.store.set({skeletonRequested:!0});return}if(!n.isLoading||e.isLoading)return;let i={skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1};if(!e.skeletonExiting){this.store.set(i);return}this.timers.schedule(Xi,()=>this.store.set(i),Bl)}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(Nl,()=>this.store.set({newParamId:null}),Hl)}))}handleChange(e,n){let i=this.store.get();n&&e&&!i.text&&this.noteSearchStarted(),this.store.set({text:e,pillTapped:!1,activeDropdownIndex:-1});let{valid:o,invalid:r}=xo(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)}isWordOpen(){return this.opts.commitOnWordEnd===!0&&this.openWordText===this.store.get().text}admitIdentified(e){let n=this.store.get(),{valid:i}=Ge(n.text,n.completedParams,e);i.length!==0&&this.store.set({identifiedParams:[...n.identifiedParams,...i]})}endTypedWord(e=!1){let n=this.isWordOpen();if(!n&&!e)return!1;let i=this.heldIdentified;this.heldIdentified=null,this.openWordText=null;let o=this.store.get();this.maybePromoteExactMatch(o.text,e?"submit":"fresh",n),i?.text===o.text&&this.admitIdentified(i.candidates);let r=this.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=ne(e.text,Math.min(e.filterBase,e.text.length),e.placeholderText),i=go(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);ue(e.editingParam.options,i).some(r=>r.is_tappable)||(this.reEdit.exit(),this.fetchNow())}fetchNow(){let e=this.store.get(),{rawQuery:n,completedParams:i}=D(e.text,e.completedParams);this.fetchController.doFetch(n,i)}commitIdentifiedDate(e){let n=this.store.get(),i=n.editingIdentified;if(!i)return;if(n.text.slice(i.anchor,i.tail)!==i.text){this.store.set({editingIdentified:null,activeDropdownIndex:-1});return}let o=n.text.slice(0,i.anchor),r=n.text.slice(i.tail),a=i.anchor===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,l=r.length===0||r[0]!==" "?`${a} `:a,d=o+l+r,c=d.length,u={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:a,value:e.value,kind:e.kind,suggestionParameter:i.parameter,suggestionPlaceholder:j(i.parameter),options:[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url};this.fireTelemetry("option",{raw_query:D(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(p=>p.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(_(o.activeFormatType)||this.isWordOpen())return;let r=fn({mode:n,finishWord:i,text:e,completedParams:o.completedParams,suggestions:o.suggestions,filterBase:o.filterBase,filterInProgress:o.filterInProgress,phraseExactMatch:this.fetchController.isPhraseExactMatch()});if(r){if(this.funnelTelemetry===!0){let a=n==="submit"&&r.suggestion?r.suggestion:o.actionableSuggestions[0],s=a.options??[];this.fireTelemetry("option",{raw_query:D(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:ae(s,r.option.text),chip_origin:"typed"})}this.store.set(r.patch)}}};0&&(module.exports={AIAutocomplete,ATTRIBUTION_URL,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,EDITOR_GROW_MS,LOCATION_META_KEY,LOCATION_MIN_QUERY,MULTI_SELECT_TOGGLE_MIN_PX,MULTI_SELECT_TOGGLE_SLOP_PX,ModeController,OPTIONS_GRID_MOBILE_QUERY,OPTION_ENTER_DELAY_VAR,OPTION_ENTER_FADE_MS,OPTION_ENTER_RISE_MS,OPTION_ENTER_RISE_PX,OPTION_ENTER_STAGGER_MS,OPTION_IMAGE_WIDTH,PLACEHOLDER_FADE_OUT_MS,PLACEHOLDER_LEAVING_ATTR,PLACEHOLDER_SWAP_GAP_MS,PLACEHOLDER_TYPE_MS,PLACEHOLDER_WORD_PAUSE_MS,PRODUCT_IMAGE_WIDTH,PRODUCT_PATH_PREFIX,PRODUCT_ROW_PX_PER_LINE,RANGE_SEPARATOR,SCHEMA_VERSION,SCROLL_ARROW_ATTR,SCROLL_ARROW_BOTTOM_VAR,SCROLL_ARROW_CLASS,SCROLL_ARROW_FADE_MS,SCROLL_ARROW_LABEL,SCROLL_ARROW_SCROLL_IDLE_MS,SCROLL_ARROW_VISIBLE_ATTR,SKIPPED_PARAM_TEXT,SMART_SUGGESTION_SPARKLE_SVG,TIME_META_KEY,TIME_STEP_MINUTES,TIME_WHEEL_COLUMNS,TIME_WHEEL_ROW_HEIGHT,VIEWPORT_FIT_ATTR,VIEWPORT_FIT_HEIGHT_VAR,WEEKDAY_LABELS,addMonths,attachProductRowWheel,attachScrollArrow,attachViewportFit,buildAttributionUrl,buildDateOptions,buildLocationOption,buildQuery,buildSubmitResult,buildTimeOption,cellDay,cellIso,chipIdFromTap,computeOptionsGridLayout,containScroll,createStore,cursorIsAtEnd,dateCellMarks,dateSelectionFor,extractPlainText,formatAbsoluteDate,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,getCursorOffset,getFooterHint,hasSkippablePill,highlightParts,identifiedParamLabel,isCalendarFormat,isMultiSelectToggleTap,isOptionsGridMobileViewport,isPickerFormat,isSmartSuggestion,isTraditionalAutocompleteSuggestion,isoDate,isoTime,keepCaretOnChip,labelTraditionalAutocomplete,locationEndpointFor,matchTypedPhrase,measureOptionsGrid,monthLabel,needsOptionsGridMeasurement,optionCountLabel,optionEnterDelayMs,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsEntranceDurationMs,optionsGridTemplateColumns,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,parseTime,plainTextLength,planOptionsGrid,previousGraphemeBoundary,productFromMatchedItem,productImageSources,productImageSrc,productInitial,productPhotoFill,productRowWheelTarget,productsFromCustomFields,renderEditableContent,resolveFormatType,resolveIdentifiedDate,sameOptionRows,sanitizeOptionIconSvg,scrollCaretIntoView,selectedIsoFromText,selectedRangeFor,setCursorOffset,shopifyImageSrc,timeWheelIndex,timeWheelIndexFromScroll,timeWheelRows,toWireIdentifiedParams,typedFragment,uiStringsFor,visibleDateRange,watchEditorHeight,withSkippedParams,withTimeWheelIndex,withoutTraditionalAutocomplete});
|
|
3340
3340
|
//# sourceMappingURL=index.js.map
|