@magicx-eng/ai-autocomplete-vanilla 0.76.3 → 0.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Ki=Object.defineProperty;var rl=Object.getOwnPropertyDescriptor;var al=Object.getOwnPropertyNames;var sl=Object.prototype.hasOwnProperty;var ll=(t,e)=>{for(var n in e)Ki(t,n,{get:e[n],enumerable:!0})},cl=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of al(e))!sl.call(t,o)&&o!==n&&Ki(t,o,{get:()=>e[o],enumerable:!(i=rl(e,o))||i.enumerable});return t};var dl=t=>cl(Ki({},"__esModule",{value:!0}),t);var Mu={};ll(Mu,{AIAutocomplete:()=>qi,ATTRIBUTION_URL:()=>Oo,DATE_RANGE_META_END:()=>Vn,DATE_RANGE_META_START:()=>Wn,DEFAULT_OPTION_COUNT_UNIT:()=>tr,EDITOR_GROW_MS:()=>Os,HANDOFF_NOT_HANDLED:()=>Ui,HINT_ATTR:()=>Di,HINT_EL_ATTR:()=>ur,HINT_HOLD_MS:()=>dr,LOCATION_META_KEY:()=>jt,LOCATION_MIN_QUERY:()=>ct,MULTI_DONE_FIT_VAR:()=>ri,MULTI_SELECT_TOGGLE_MIN_PX:()=>gs,MULTI_SELECT_TOGGLE_SLOP_PX:()=>fs,ModeController:()=>it,OPTIONS_GRID_MOBILE_QUERY:()=>It,OPTION_ENTER_DELAY_VAR:()=>si,OPTION_ENTER_FADE_MS:()=>_a,OPTION_ENTER_RISE_MS:()=>Da,OPTION_ENTER_RISE_PX:()=>Ha,OPTION_ENTER_STAGGER_MS:()=>Ra,OPTION_IMAGE_WIDTH:()=>yi,PANEL_ENTER_DELAY_MS:()=>$o,PANEL_ENTER_MS:()=>Uo,PANEL_GHOST_CLASS:()=>ee,PANEL_GLIDE_MS:()=>Vo,PANEL_LEAVE_MS:()=>Bo,PLACEHOLDER_FADE_OUT_MS:()=>va,PLACEHOLDER_LEAVING_ATTR:()=>Oe,PLACEHOLDER_SWAP_GAP_MS:()=>Ea,PLACEHOLDER_TYPE_MS:()=>Ta,PLACEHOLDER_WORD_PAUSE_MS:()=>xa,PRODUCT_IMAGE_WIDTH:()=>ls,PRODUCT_PATH_PREFIX:()=>go,PRODUCT_ROW_PX_PER_LINE:()=>rs,RANGE_SEPARATOR:()=>To,SCHEMA_VERSION:()=>Xi,SCROLL_ARROW_ATTR:()=>_t,SCROLL_ARROW_BOTTOM_VAR:()=>Ho,SCROLL_ARROW_CLASS:()=>Ro,SCROLL_ARROW_FADE_MS:()=>_o,SCROLL_ARROW_LABEL:()=>Fa,SCROLL_ARROW_SCROLL_IDLE_MS:()=>Do,SCROLL_ARROW_VISIBLE_ATTR:()=>ke,SKIPPED_PARAM_TEXT:()=>Yi,SMART_SUGGESTION_SPARKLE_SVG:()=>nn,TIME_META_KEY:()=>ao,TIME_STEP_MINUTES:()=>Cn,TIME_WHEEL_COLUMNS:()=>vt,TIME_WHEEL_ROW_HEIGHT:()=>xt,VIEWPORT_FIT_ATTR:()=>De,VIEWPORT_FIT_HEIGHT_VAR:()=>Ft,WEEKDAY_LABELS:()=>ht,addMonths:()=>un,attachChipRemove:()=>Oi,attachProductRowWheel:()=>hi,attachScrollArrow:()=>di,attachViewportFit:()=>Pi,buildAttributionUrl:()=>ni,buildDateOptions:()=>mn,buildLocationOption:()=>Qt,buildQuery:()=>N,buildSubmitResult:()=>he,buildTimeOption:()=>An,cancelStartingHint:()=>Hi,cellDay:()=>pn,cellIso:()=>K,chipIdFromTap:()=>xn,computeOptionsGridLayout:()=>Eo,containScroll:()=>oi,createStore:()=>Wi,cursorIsAtEnd:()=>En,dateCellMarks:()=>Zn,dateFloorFor:()=>ti,dateSelectionFor:()=>je,destroyPanelMorph:()=>fi,dropdownPillsFor:()=>tt,editingSuggestion:()=>We,extractPlainText:()=>Ce,findMultiSelectDone:()=>ka,fitMultiSelectDone:()=>ai,formatAbsoluteDate:()=>Pe,formatDate:()=>to,formatDateRange:()=>xo,formatOptionCount:()=>et,formatPlace:()=>ji,formatTime:()=>Tt,getCursorOffset:()=>z,getFooterHint:()=>ii,hasSkippablePill:()=>on,highlightParts:()=>jn,identifiedParamLabel:()=>J,inPanelGhost:()=>Me,isCalendarFormat:()=>_,isDimmedDay:()=>ei,isMultiSelectToggleTap:()=>xi,isOptionsGridMobileViewport:()=>Ke,isPickerFormat:()=>D,isSmartSuggestion:()=>Ee,isTraditionalAutocompleteSuggestion:()=>C,isoDate:()=>W,isoTime:()=>mo,keepCaretOnChip:()=>vn,labelTraditionalAutocomplete:()=>tn,locationEndpointFor:()=>Yt,matchTypedPhrase:()=>kt,measureOptionsGrid:()=>qe,monthLabel:()=>dn,needsOptionsGridMeasurement:()=>Un,notePanelMorphHeight:()=>pi,optionCountLabel:()=>ys,optionEnterDelayMs:()=>li,optionHasImage:()=>nr,optionImageSources:()=>Ze,optionImageSrc:()=>Se,optionLabel:()=>Nt,optionsEntranceDurationMs:()=>ci,optionsGridTemplateColumns:()=>Bn,optionsShowLeadingVisuals:()=>Ei,panelMorphGlide:()=>ae,panelMorphKey:()=>ui,panelMorphTargetHeight:()=>mi,parseDate:()=>bt,parseLooseDate:()=>Ae,parseLooseDateRange:()=>At,parseTime:()=>Ln,plainTextLength:()=>Tn,planOptionsGrid:()=>$n,previousGraphemeBoundary:()=>wn,productFromMatchedItem:()=>ho,productImageSources:()=>Ht,productImageSrc:()=>cs,productInitial:()=>bi,productPhotoFill:()=>Si,productRowWheelTarget:()=>Qo,productsFromCustomFields:()=>Dn,queryLive:()=>B,releasePanelHug:()=>Xe,renderEditableContent:()=>Fi,resolveFormatType:()=>Q,resolveIdentifiedDate:()=>Fn,sameOptionRows:()=>qn,sanitizeOptionIconSvg:()=>ie,scrollCaretIntoView:()=>bn,selectedIsoFromText:()=>Be,selectedRangeFor:()=>Ie,setCursorOffset:()=>V,settlePanelMorph:()=>Dt,shopifyImageSrc:()=>Yo,startingHintOptions:()=>Ni,syncPanelHug:()=>za,timeWheelIndex:()=>Et,timeWheelIndexFromScroll:()=>On,timeWheelRows:()=>In,toWireIdentifiedParams:()=>He,typedFragment:()=>Co,uiStringsFor:()=>k,visibleDateRange:()=>Jn,watchEditorHeight:()=>Mi,withSkippedParams:()=>Ne,withTimeWheelIndex:()=>wt,withoutTraditionalAutocomplete:()=>en});module.exports=dl(Mu);function _(t){return t==="date"||t==="date-range"}function D(t){return t!=="options"}function Q(t){return t?.type?.kind==="date"?"date":t?.type?.kind==="date_range"?"date-range":t?.type?.kind==="time"?"time":t?.type?.kind==="location"&&!t.options?.length?"location":"options"}var $t=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 ul="https://api.ai-autocomplete.com",X=`${ul}/api/suggest`,Gt=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),br=new WeakMap;function lt(t){return t?.type==="accessToken"}function ml(t){if(!(!t||lt(t)))return t}function qt(t){let e=br.get(t.getAccessToken);return e||(e=new $t(t),br.set(t.getAccessToken,e)),e}function Kt(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function zt(t){let e=ml(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var jt="aiaPlace",ct=2,Tr=250,yr=new Set("new san los las santa saint st fort port north south east west lake mount el la rio de palm long grand cape salt hong".split(" ")),Sr=new Set("city beach springs falls island park heights valley bay".split(" ")),pl=new Set("a an the in at to off on of from for by near into onto around via toward towards up out and or with within".split(" "));function xr(t){let e=fl(t);for(;e.length>0&&pl.has(e[0].toLowerCase().replace(/[.,]+$/,""));)e.shift();return e.join(" ")}function fl(t){let e=t.trim().split(/\s+/).filter(Boolean);if(e.length===0)return[];let n=e[e.length-1].replace(/[.,]+$/,"");if(!n)return[];let i=e.length>1?e[e.length-2]:void 0,o=e.length>2?e[e.length-3]:void 0,r=a=>a.toLowerCase().replace(/[.,]+$/,"");return i&&o&&yr.has(r(o))&&Sr.has(r(n))?[o,i,n]:i&&(yr.has(r(i))||Sr.has(r(n)))?[i,n]:[n]}function ji(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function zi(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function Qi(t,e){let n=zi(e);if(!n)return!1;if(zi(t.name)===n)return!0;for(let[,i]of t.name.matchAll(/\(([^()]*)\)/g))if(zi(i)===n)return!0;return!1}function vr(t,e){let n=e.metadata?.[jt];if(typeof n?.name!="string")return 0;let i={id:"",name:n.name},o=[...t.matchAll(/\S+/g)];for(let r of o){let a=r.index??0,s=t.slice(a).trim().replace(/[.,]+$/,"");if(Qi(i,s))return t.length-a}return 0}function Qt(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:ji(t),is_tappable:!0,kind:null,metadata:{[jt]:{id:t.id,name:t.name}}}}function Yt(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??X,n=e.indexOf("?"),i=n<0?e:e.slice(0,n),o=n<0?"":e.slice(n+1);if(!/\/suggest\/?$/.test(i))return null;let r=i.replace(/\/suggest\/?$/,"/locations/autocomplete");return o?`${r}?${o}`:r}function Er(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 He(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var Yi="skipped";function Ne(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:Yi,kind:null}));return i.length>0?[...t,...i]:t}var gl="0.76.3",Xi="1.0",wr=!1;function hl(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function ue(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function bl(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function yl(t,e,n,i,o,r,a,s,l,d,c,u,f,p){let m=e.find(T=>T.parameter==="contact"&&T.metadata?.contact_account_count)?.metadata?.contact_account_count,g=typeof m=="number"?m:void 0,b=bl();return{data:{raw_query:t,accepts_traditional_autocomplete:!0,...p&&{traditional_autocomplete_only:!0},client_option_parameters:f??[],completed_params:Ne(e.map(T=>hl(T,n)),l??[]),...a&&a.length>0&&{identified_params:He(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:ue(c),...b&&{timezone:b},...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:gl,session_id:i,source:r,schema_version:Xi}}}async function Pr(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function Ji(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=yl(t,e,o,n.sessionId,n.requestId??crypto.randomUUID(),n.source,n.identifiedParams,n.recentlySuggested,n.skippedParams,n.additionalContext,n.language,n.currency,n.clientOptionParameters,n.traditionalAutocompleteOnly),a=i?.endpoint??X,s=await Lr(a,JSON.stringify(r),i,n.signal);if(!s.ok)throw new Error(`API error: ${s.status} ${s.statusText}`);return s.json()}async function Lr(t,e,n,i){let o=Kt(n);if(lt(n)){let a=qt(n),s=await a.getToken(),l=await Pr(t,o,s,e,i);if(l.status===401){let d=await a.getToken(!0);l=await Pr(t,o,d,e,i)}return l}let r=zt(n);return!r&&!wr&&(wr=!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 dt=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function Cr(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:ue(n.language)}),o=await Lr(t,i,n.apiConfig,n.signal);if(!o.ok)throw new dt(o.status);return Er(await o.json())}var Xt=/[\p{L}\p{N}]/u,Sl=/['\u2019-]/;function Ar(t,e,n){let i=t[e];if(i===void 0)return!1;if(Xt.test(i))return!0;let o=t[e+n];return Sl.test(i)&&o!==void 0&&Xt.test(o)}function Tl(t,e,n){let i=e+n.length;return!(Xt.test(n[0])&&Ar(t,e-1,-1)||Xt.test(n[n.length-1])&&Ar(t,i,1))}function re(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(Tl(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=p=>re(n,s.text,p,m=>!r.some(g=>m<g.end&&m+s.text.length>g.start)),f=u(a);if(f===-1&&(f=u(0)),f!==-1){n=n.slice(0,f)+c+n.slice(f+s.text.length);let p=c.length-s.text.length;for(let m of r)m.start>=f+s.text.length&&(m.start+=p,m.end+=p);r.push({start:f,end:f+c.length}),a=f>=a?f+c.length:a+p}o.push({...s,placeholder:c})}return{rawQuery:n,completedParams:o}}function me(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function Fe(t,e){return e===!1?"":t}function ut(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function mt(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 Ir(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 Or(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function xl(t,e){let n=Or(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?Or(i).trimStart():"";if(o)return t.filter(a=>!a.is_tappable||xl(a.text,o));let r=i.toLowerCase();return t.filter(a=>!a.is_tappable||a.text.toLowerCase().includes(r))}function Jt(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 pt(t,e,n,i,o){let r=mt(e,n,i),a=Jt(t,r);if(a||!o||!r.trim())return a;if(r===e.slice(n))return null;let s=e.lastIndexOf(" ",n-1)+1;return Jt(t,e.slice(s))}function Mr(t,e){let n=e.replace(/^\s+/,"").toLowerCase();for(let i=0;i<n.length;){let o=n.slice(i);if(o.trim().length>=2){let a=t.findIndex(s=>s.is_tappable&&!s.selectsAll&&s.text.toLowerCase().startsWith(o));if(a>=0)return t.map((s,l)=>l===a?{...s,liveMatch:!0}:s)}let r=n.indexOf(" ",i);if(r<0)break;i=r+1}return t}function Rr(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function _r(t,e){let{icon:n,icon_svg:i}=e;return!i||t.every(kr)?t:t.map(o=>kr(o)?o:{...o,icon:n,icon_svg:i})}function kr(t){return!!(t.icon_svg||t.image_url)}function vl(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=vl(t);return e.length>0?e.join(" "):t}function Z(t,e){return t.parameter||e}function ft(t,e,n){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:n?.trim()||J(t),...e?{suggestionHeader:e}:{}}}function We(t){return t.suggestionValueType?.kind==="traditional_autocomplete"?{parameter:t.suggestionParameter,text:t.suggestionHeader??"",required:!0,type:t.suggestionValueType,options:t.options}:{parameter:t.suggestionParameter,text:t.suggestionPlaceholder,required:!0,options:t.options}}function Zt(t,e){let n=Z(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?ft(n,t.suggestionHeader,e.parameter_label):{parameter:n,suggestionParameter:t.suggestionParameter,suggestionValueType:t.suggestionValueType,suggestionPlaceholder:t.suggestionPlaceholder,suggestionIcon:t.suggestionIcon,suggestionIconSvg:t.suggestionIconSvg}}function C(t){return t?.type?.kind==="traditional_autocomplete"}function El(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function Zi(t){return t.parameter_label?.trim()||El(t.parameter)}function Ee(t){return C(t)||t?.smart_suggestion===!0}function en(t){return t.some(C)?t.filter(e=>!C(e)):t}function tn(t,e){return t.some(n=>C(n)&&!n.text)?t.map(n=>C(n)&&!n.text?{...n,text:e}:n):t}var nn='<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 on(t){return t.some(e=>!C(e))}function Dr(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 Hr(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 Nr(t,e){let n=[],i=new Map;for(let o of[...t,...e]){if(o.parameter==="placeholder"||C(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 Fr(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 rn(t,e){let n=[],i=[],o=0;for(let r of e){let a=re(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 we(t,e){let{located:n}=rn(t,e);return n.length>0?n[n.length-1].end:0}function Wr(t,e,n){let i=[],o=[],r=0;for(let a of n){let s=re(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 an(t,e,n=[]){let i=rn(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=Wr(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 Vr(t,e){let{located:n,missing:i}=rn(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 gt(t,e,n){let i=rn(t,e).located,{located:o,missing:r}=Wr(t,i,n);return{valid:o.map(a=>a.param),invalid:r}}function Br(t,e,n){let i=e?.endpoint??X,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${wl(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,a)=>{let s=Gt.get(a);return s?`https://${s}`:r})}function wl(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 Ur(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 Pl(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var $r=100,Ll=300,Cl=2,sn=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;this.previewTimer=null;this.previewAbort=null;this.previewVersion=0;this.previewPending=!1;this.shownPreview=null;this.forceNextFetch=!1}start(){this.doFetch("",[]);let e=this.store.get().text,n=this.store.get().completedParams;this.unsubscribe=this.store.subscribe(i=>{(i.text!==e||i.completedParams!==n)&&(e=i.text,n=i.completedParams,this.scheduleFetch())})}isPhraseExactMatch(){return this.phraseExactMatch}dispose(){this.abortController?.abort(),this.clearTimers(),this.clearPreview(),this.unsubscribe?.()}previewComposition(e){this.previewTimer&&clearTimeout(this.previewTimer),this.previewPending=!0,this.previewTimer=setTimeout(()=>{this.previewTimer=null,this.doPreview(e)},$r)}endPreview(){this.shownPreview=null,this.previewPending&&(this.clearPreview(),this.forceNextFetch=!0,this.scheduleFetch())}clearPreview(){this.previewTimer&&clearTimeout(this.previewTimer),this.previewTimer=null,this.previewAbort?.abort(),this.previewAbort=null,this.previewPending=!1,this.shownPreview=null}async doPreview(e){this.previewAbort?.abort();let n=new AbortController;this.previewAbort=n;let i=++this.previewVersion;this.previewPending=!0;let o=this.fetchVersion,r=this.store.get(),{rawQuery:a,completedParams:s}=N(e,r.completedParams);try{let l=await Ji(a,s,{...this.requestOptions(r,n.signal,crypto.randomUUID()),traditionalAutocompleteOnly:!0});if(i!==this.previewVersion||o!==this.fetchVersion)return;let d=(l.data.suggestions??[]).find(C);if(!d)return;let c=l.meta?.traditional_autocomplete===!0;this.shownPreview={answer:d,traditionalAutocomplete:c},this.store.set({suggestions:[d],traditionalAutocomplete:c,activeDropdownIndex:-1})}catch{}}requestOptions(e,n,i){let o=e.pendingSpan?Nr(e.pendingSpan.snapshot,e.actionableSuggestions):void 0;return{sessionId:this.getSessionId(),requestId:i,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:n,apiConfig:this.getApiConfig(),identifiedParams:e.identifiedParams,recentlySuggested:o,skippedParams:e.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})}}async doFetch(e,n){this.abortController?.abort(),this.previewAbort?.abort(),this.previewAbort=null,this.previewPending=!1,this.shownPreview=null,this.forceNextFetch=!1;let i=new AbortController;this.abortController=i;let o=++this.fetchVersion,r=this.store.get().text.length,a=this.store.get().text;try{this.callbacks.onRequest?.({query:this.store.get().text,signal:i.signal,isCurrent:()=>o===this.fetchVersion})}catch{}try{this.store.set({isLoading:!0,error:null});let s=this.store.get(),l=crypto.randomUUID(),d=e===""&&n.length===0&&s.skippedParams.length===0&&s.identifiedParams.length===0,c=d?this.startingStateUrl():void 0,u=c?await Ur(fetch(c,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let f=u??await Ji(e,n,this.requestOptions(s,i.signal,l));if(o!==this.fetchVersion)return;this.phraseExactMatch=f.meta?.phrase_exact_match===!0;let p=(f.data.suggestions??[]).find(C),m=p?[]:f.data.input??[],g=E=>({id:crypto.randomUUID(),parameter:E.parameter,text:E.text,...E.type?{type:E.type}:{},...E.iso_date?{isoDate:E.iso_date}:{},...E.iso_date_end?{isoDateEnd:E.iso_date_end}:{}}),b=m.filter(E=>E.source==="identified");this.callbacks.waitIdentified?.(b.filter(E=>E.state==="need_confirmation").map(g),a);let T=b.filter(E=>E.state!=="need_confirmation").map(g),S=this.callbacks.isWordOpen?.()??!1,P=this.store.get().text.toLowerCase(),v=E=>S&&P.endsWith(E.text.toLowerCase()),h=T.filter(E=>!v(E));S&&this.callbacks.holdIdentified?.(T.filter(v));let x=p?[p]:Rr(f.data.suggestions??[],this.getOptionOverrides()),w=m,y=w[w.length-1],L=this.store.get().text,R,A;if(y?.state==="in_progress"){A=!0;let E=L.toLowerCase().lastIndexOf(y.text.toLowerCase());R=E!==-1?E:r}else A=!1,R=r;let I=x.filter(E=>E.parameter!=="placeholder")[0],G=null;if(I&&!C(I)&&!S&&I.type?.kind!=="multi_select"&&!D(Q(I))){let E=pt(I.options,L,R,A,this.phraseExactMatch);E&&(G={id:crypto.randomUUID(),placeholder:"",parameter:Z(E,I.parameter),text:E.text,value:E.value,kind:E.kind,suggestionParameter:I.parameter,suggestionValueType:I.type,suggestionPlaceholder:I.text,suggestionIcon:I.icon,suggestionIconSvg:I.icon_svg,options:I.options??[],metadata:E.metadata,icon:E.icon,icon_svg:E.icon_svg,image_url:E.image_url},x=x.filter(ce=>ce!==I),this.callbacks.onAutoMatch?.({active:I,matched:E,rawQuery:e}))}let le=f.data.custom_fields??null,oe=this.callbacks.productsForResponse?.(le);this.store.set(E=>{let ce=G?[...E.completedParams,G]:E.completedParams,Te=new Set,Vt=gt(E.text,ce,h).valid.map(M=>{let rt=E.identifiedParams.find(at=>!Te.has(at.id)&&at.parameter===M.parameter&&at.text===M.text);return rt?(Te.add(rt.id),{...M,id:rt.id}):M}),xe=new Set(s.skippedParams.map(M=>M.id)),ot=new Set(E.skippedParams.filter(M=>!xe.has(M.id)).map(M=>M.parameter)),Bt=ot.size>0?x.filter(M=>M.parameter==="placeholder"||!ot.has(M.parameter)):x,Ut=this.callbacks.getAllOption?.()===!0&&!d,ve=E.composing?this.shownPreview:null;return{suggestions:ve?[ve.answer]:Ut?Bt.map(M=>M.parameter==="placeholder"?M:{...M,leadsWithAll:!0}):Bt,isLoading:!1,isReady:f.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:R,filterInProgress:A,identifiedParams:Vt,customFields:le,traditionalAutocomplete:ve?ve.traditionalAutocomplete:f.meta?.traditional_autocomplete===!0,...oe!==void 0?{products:oe}:{},...G?{completedParams:ce}:{}}}),this.callbacks.onResponse?.({requestId:l,funnelTelemetry:f.meta?.funnel_telemetry===!0,visibleImpression:f.meta?.visible_impression===!0})}catch(s){let l=Pl(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?Br(e,this.getApiConfig(),ue(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(Cl)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},$r),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),Ll)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;if(this.forceNextFetch){let{rawQuery:x,completedParams:w}=N(o.text,o.completedParams);return this.doFetch(x,w),!0}let a=Fe(o.suggestions.filter(x=>x.parameter==="placeholder").map(x=>x.text).join(" "),this.callbacks.getPrependPlaceholder?.()),s=me(o.text,o.filterBase,a),l=mt(o.text,s,o.filterInProgress),d=o.suggestions.filter(x=>x.parameter!=="placeholder"),c=C(d[0])?void 0:d[0],u=D(o.activeFormatType),f=c&&!u?pe(c.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&f.length>0)return!1;let p=f.filter(x=>x.is_tappable),m=c&&!u&&!this.callbacks.isWordOpen?.()?pt(c.options,o.text,s,o.filterInProgress,this.phraseExactMatch)!==null:!1,g=l.trim().length>0,b=i&&o.products.length>0;if(p.length>0&&!m&&g&&!b||ut(o.text,o.completedParams.length,a))return!1;let{rawQuery:T,completedParams:S}=N(o.text,o.completedParams),P=T.length<o.lastRawQuery.length,v=Math.abs(T.length-o.lastRawQuery.length),h=n&&T!==o.lastRawQuery;return P||v>=e||h?(this.doFetch(T,S),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var Al="(hover: none) and (pointer: coarse)";var Il="[data-aia-dropdown], [data-aia-input-wrapper]",Ol=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),ln=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(Ol)),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(Al):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(Il))return!0;return!1}};var Ve=["January","February","March","April","May","June","July","August","September","October","November","December"],ht=["S","M","T","W","T","F","S"],Kr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],cn="aiaDate",zr="aiaDay",Gr=t=>String(t).padStart(2,"0");function W(t){return`${t.getFullYear()}-${Gr(t.getMonth()+1)}-${Gr(t.getDate())}`}function eo(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Ml(t){let e=eo(t).getTime()-eo(new Date).getTime();return Math.round(e/864e5)}function to(t){let e=Ml(t);return e>=0&&e<7?Kr[t.getDay()]:Pe(t)}function Pe(t){return t.getFullYear()===new Date().getFullYear()?`${Ve[t.getMonth()]} ${t.getDate()}`:`${Ve[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function bt(t){if(!t)return null;let e=Kr.findIndex(s=>s.toLowerCase()===t.trim().toLowerCase());if(e>=0){let s=eo(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=Ve.findIndex(s=>s.toLowerCase()===n[1].toLowerCase());if(i<0)return null;let o=Number(n[2]),r=n[3]?Number(n[3]):new Date().getFullYear(),a=new Date(r,i,o);return a.getMonth()!==i||a.getDate()!==o?null:a}function dn(t){return`${Ve[t.month]} ${t.year}`}function no(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function jr(t){return{year:t.getFullYear(),month:t.getMonth()}}function un(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function qr(){return{text:"",is_tappable:!1,kind:null}}function mn(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(qr());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:to(r),is_tappable:!0,kind:null,metadata:{[cn]:W(r),[zr]:o}})}for(;i.length%ht.length!==0;)i.push(qr());return i}function Be(t){let e=bt(t);return e?W(e):null}function K(t){let e=t?.metadata?.[cn];return typeof e=="string"?e:null}function pn(t){let e=t?.metadata?.[zr];return typeof e=="number"?e:null}function kl(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function fe(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&kl(e)?e:t.ownerDocument??t}function fn(t){return fe(t).activeElement??null}function H(t){return t.ownerDocument??t}function Rl(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Qr(t){let e=fe(t);return!Rl(e)||typeof e.getSelection=="function"?null:e}function Yr(t){let e=Qr(t);if(!e)return null;let n=H(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function Xr(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 yt(t){let n=fe(t).getSelection?.();return n||(H(t).getSelection?.()??null)}function ge(t){let e=yt(t);if(!e||e.rangeCount===0)return null;let n=Yr(t);if(n){let i=Xr(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 Le(t){let e=yt(t);if(!e||e.rangeCount===0)return null;let n=Yr(t);if(!n)return e.getRangeAt(0);let i=Xr(e,n);if(!i)return null;let o=H(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function St(t,e,n){let i=yt(t);if(!i)return null;if(Qr(t))return i.collapse(e,n),i;let o=H(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function gn(t,e){let n=t?fe(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var hn=2,_l="magicx-aia";function Jr(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function Dl(t){let e=H(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&&Jr(a.overflowX)||r&&Jr(a.overflowY))return i}if(i.classList.contains(_l))return null;i=i.parentElement}return null}function bn(t){let e=Le(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=Dl(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+hn:i.left<r&&(n.scrollLeft-=r-i.left+hn)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,a=r+n.clientHeight;i.bottom>a?n.scrollTop+=i.bottom-a+hn:i.top<r&&(n.scrollTop-=r-i.top+hn)}}var ea='[contenteditable="false"]',oo="strong[data-param-id]",Ue;function Hl(){if(Ue!==void 0)return Ue;let t=globalThis.Intl.Segmenter;if(!t)return Ue=null,null;try{Ue=new t(void 0,{granularity:"grapheme"})}catch{Ue=null}return Ue??null}function yn(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(ea))return!0;n=n.parentNode}return!1}function Sn(t){return H(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return yn(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Ce(t){let e=Sn(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function Tn(t){let e=Sn(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function z(t){let e=ge(t);if(!e)return null;let n=e.node,i=e.offset;if(!t.contains(n))return null;if(n.nodeType===Node.ELEMENT_NODE){let o=n;if(yn(o,t)&&o!==t)return null;let r=0;for(let a=0;a<i&&a<o.childNodes.length;a++)r+=ro(o.childNodes[a],t);return r+io(o,t)}return n.nodeType!==Node.TEXT_NODE||yn(n,t)?null:io(n,t)+i}function ro(t,e){if(t.nodeType===Node.TEXT_NODE)return yn(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(ea))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=ro(o,e);return i}function io(t,e){let n=Sn(e),i=0,o=n.nextNode();for(;o;){if(o===t||t.nodeType===Node.ELEMENT_NODE&&t.contains(o))return i;i+=o.data.length,o=n.nextNode()}return i}function V(t,e){let n=H(t),i=Math.max(0,Math.min(e,Tn(t))),o=Sn(t),r=0,a=null,s=0,l=o.nextNode(),d=null;for(;l;){let u=l.data.length;if(i<r+u){a=l,s=i-r;break}if(i===r+u){let f=o.nextNode();f?(a=f,s=0):(a=l,s=u);break}r+=u,d=l,l=o.nextNode()}let c=n.createRange();if(a){let u=a.parentElement?.closest('strong[data-seg="completed"]');u&&u!==t&&t.contains(u)?s===0?c.setStartBefore(u):s===a.data.length?c.setStartAfter(u):c.setStart(a,s):c.setStart(a,s)}else d?c.setStart(d,d.data.length):c.setStart(t,0);c.collapse(!0),St(t,c.startContainer,c.startOffset)&&(Nl(t,c,i),bn(t))}function Zr(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(oo)??null;return i&&e.contains(i)?i:null}function Nl(t,e,n){let i=Zr(ge(t)?.node??null,t);if(i&&i!==Zr(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function ta(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=z(t);return i!==null&&n===`${i}:${e}`}function na(t){return fe(t).activeElement===t}function xn(t,e){if(!e||e.nodeType===void 0)return null;let n=e,i=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;if(i?.closest("[data-aia-chip-remove]"))return null;let o=i?.closest(oo);if(!o||!t.contains(o))return null;let r=ge(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function vn(t,e){let n=null;for(let a of t.querySelectorAll(oo))if(a.dataset.paramId===e){n=a;break}if(!n)return;let i=io(n,t),o=i+ro(n,t),r=z(t);r!=null&&r>=i&&r<=o||V(t,i)}function En(t){let e=z(t);return e==null?!1:e>=Tn(t)}function wn(t,e){if(e<=0)return 0;let n=Hl();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 ao="aiaTime",Cn=5;var so=[12,1,2,3,4,5,6,7,8,9,10,11],lo=Array.from({length:60/5},(t,e)=>e*5),co=["AM","PM"];function Ge(t){return(Math.round(t)%1440+1440)%1440}function uo(t){let e=Ge(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function Pn(t){let e=t.hour%12+(t.period==="PM"?12:0);return Ge(e*60+t.minute)}function Tt(t){let{hour:e,minute:n,period:i}=uo(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function mo(t){let e=Ge(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function $e(t){return Ge(Math.round(t/5)*5)}function ia(t,e){return Ge(t+e)}var Fl=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,Wl=/^(\d{1,2}):(\d{2})$/;function Ln(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=Fl.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:Pn({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=Wl.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 oa(t){let e=Ln(t.editingText);if(e!=null)return $e(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>Ln(o.text)).filter(o=>o!=null);if(n.length>0)return $e(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return Ge((i.getHours()+1)*60)}function An(t){return{text:Tt(t),is_tappable:!0,kind:null,metadata:{[ao]:mo(t)}}}var xt=30,vt=["hour","minute","period"],po={hour:so.map(t=>({label:String(t)})),minute:lo.map(t=>({label:String(t).padStart(2,"0")})),period:co.map(t=>({label:t}))};function In(t){return po[t]}function Et(t,e){let n=uo($e(e));return t==="hour"?so.indexOf(n.hour):t==="minute"?lo.indexOf(n.minute):co.indexOf(n.period)}function wt(t,e,n){let i=po[t],o=Math.min(Math.max(n,0),i.length-1),r=uo($e(e));return Pn(t==="hour"?{...r,hour:so[o]}:t==="minute"?{...r,minute:lo[o]}:{...r,period:co[o]})}function On(t,e){let n=po[t].length-1;return Math.min(Math.max(Math.round(e/xt),0),n)}function he(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=N(t,e);return{query:t.trim(),raw_query:o,completed_params:Ne(r,n),identified_params:He(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function Mn(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")?En(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function fo(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?z(t):null}var kn=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=Mn(e.target,n),u=!!n.editingParam;if(!c&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(d)break;e.preventDefault();let m=_(n.activeFormatType)?this.dateEntryIndex(n,!1):l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:m});break}if(l.length===0)return;this.store.set({activeDropdownIndex:m});break}if(e.preventDefault(),l.length===0)return;if(_(n.activeFormatType)){this.stepDateWeek(n,7);break}if(n.filteredOptions.length>0){let m=Math.floor((n.filteredOptions.length-1)/a);if(Math.floor(n.activeDropdownIndex/a)===m){this.store.set({activeDropdownIndex:-1});break}}let f=l.indexOf(n.activeDropdownIndex),p=f<l.length-1?f+1:0;this.store.set({activeDropdownIndex:l[p]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!d)break;let f=Mn(e.target,n),p=!!n.editingParam;if(!f&&!p)break;e.preventDefault();let m=_(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:m});break}if(l.length===0)return;this.store.set({activeDropdownIndex:m});break}if(l.length===0)break;if(e.preventDefault(),_(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(),_(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%a<a-1){let f=n.activeDropdownIndex+1;f<n.filteredOptions.length&&n.filteredOptions[f]?.is_tappable&&this.store.set({activeDropdownIndex:f})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,f=n.editingTail;this.ctx.exitEditMode?.(),V(u,f);break}Mn(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),_(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=fo(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?.(),V(c,u);break}if(this.ctx.startEditingParamAtCaret){let c=fo(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let c=fo(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){if(n.isSubmitting)break;this.ctx.endTypedWord?.(!0);let c=this.store.get();s(he(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((p,m)=>p.is_tappable?m:-1).filter(p=>p!==-1);if(c.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let p=e.shiftKey?c[c.length-1]:c[0];this.store.set({pillTapped:!0,activeDropdownIndex:p});break}e.preventDefault();let u=c.indexOf(n.activeDropdownIndex);if(!e.shiftKey&&!_(n.activeFormatType)&&!n.multiSelectView){let p=u>=0?c[u]:c.find(m=>!n.filteredOptions[m]?.selectsAll);if(p===void 0)break;this.clickOrSelect(p,n.filteredOptions,i,r);break}let f;if(u<0)f=e.shiftKey?c.length-1:0;else{let p=e.shiftKey?-1:1;f=(u+p+c.length)%c.length}this.store.set({activeDropdownIndex:c[f]});break}case"Escape":{if(n.dateRangeStart){this.store.set({pendingRangeStart:null});break}if(n.editingIdentified){this.ctx.exitEditingIdentified?.(),this.store.set({activeDropdownIndex:-1});break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingTail;this.ctx.exitEditMode?.(),V(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!Mn(e.target,n)&&!n.editingParam?!1:(e.preventDefault(),this.ctx.stepTime?.(e.key==="ArrowDown"?5:-5),!0);case"Enter":return i.touched?(e.preventDefault(),this.ctx.commitTime?.(),!0):!1;case"Escape":return i.touched?(this.store.set({timeDraft:null}),!0):!1;default:return!1}}firstTappableInBottomRow(e){let n=this.store.get();if(n.filteredOptions.length===0)return null;let o=Math.floor((n.filteredOptions.length-1)/e)*e;for(let r=o;r<n.filteredOptions.length;r++)if(n.filteredOptions[r]?.is_tappable)return r;return null}dateEntryIndex(e,n){if(e.dateFloor){let a=e.filteredOptions.findIndex(s=>K(s)===e.dateFloor);if(a>=0)return a}let i=W(new Date),o=e.filteredOptions.findIndex(a=>K(a)===i);if(o>=0)return o;let r=e.filteredOptions.map((a,s)=>a.is_tappable?s:-1).filter(a=>a!==-1);return(n?r[r.length-1]:r[0])??0}stepDateDay(e,n){for(let i=e.activeDropdownIndex+n;i>=0&&i<e.filteredOptions.length;i+=n)if(e.filteredOptions[i]?.is_tappable){this.store.set({activeDropdownIndex:i});return}}stepDateWeek(e,n){let i=e.activeDropdownIndex+n;this.store.set({activeDropdownIndex:e.filteredOptions[i]?.is_tappable?i:-1})}getTappableIndices(e){let i=this.store.get().filteredOptions.map((r,a)=>r.is_tappable?a:-1).filter(r=>r!==-1),o=Array.from({length:e},()=>[]);for(let r of i)o[r%e].push(r);return o.flat()}getEffectiveColumns(e){let n=gn(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=gn(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=gn(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var Rn=class{constructor(e,n,i={}){this.store=e;this.getOverrides=n;this.callbacks=i;this.unsubscribe=null;this.current=null;this.version=0;this.lastMiss=null;this.hasLoggedError=!1}start(){this.unsubscribe=this.store.subscribe(e=>this.sync(e)),this.sync(this.store.get())}dispose(){this.unsubscribe?.(),this.unsubscribe=null,this.cancel(),this.current=null}reset(){this.cancel(),this.current=null,this.lastMiss=null}refresh(){this.reset(),this.sync(this.store.get())}hasOverride(e){return!!this.getOverrides()?.[e]}owns(e,n){return this.hasOverride(e)&&!this.missCovers(e,n)}tick(e,n){let i=this.resolveTarget(e);if(!i||this.missCovers(i.parameter,i.query))return"no";let o=this.current;if(o&&o.key===i.key){if(o.query===i.query)return"owns";let r=Math.abs(i.query.length-o.query.length),a=i.query.length<o.query.length;if(n>1&&!a&&r<n)return"owns"}return this.ask(i),"asked"}sync(e){let n=this.resolveTarget(e);if(!n){this.current&&(this.cancel(),this.current=null),e.optionSearch&&this.store.set({optionSearch:null});return}this.current&&this.current.key===n.key||this.ask(n)}resolveTarget(e){if(D(e.activeFormatType)||e.editingIdentified)return null;let n=e.editingParam;if(n&&e.editingAnchor!=null)return this.hasOverride(n.suggestionParameter)?{mode:"edit",key:n.id,parameter:n.suggestionParameter,suggestion:{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options,icon:n.suggestionIcon,icon_svg:n.suggestionIconSvg},query:e.optionQuery}:null;let i=e.actionableSuggestions[0];return!i||!this.hasOverride(i.parameter)?null:{mode:"pill",key:i,parameter:i.parameter,suggestion:i,query:e.optionQuery}}missCovers(e,n){return this.lastMiss!=null&&this.lastMiss.parameter===e&&this.lastMiss.query===n}ask(e){this.cancel();let n=this.getOverrides()?.[e.parameter],i=++this.version;if(!n||this.missCovers(e.parameter,e.query)){this.current={key:e.key,parameter:e.parameter,query:e.query,abort:null},this.setSearch(e,"done");return}let o=new AbortController;this.current={key:e.key,parameter:e.parameter,query:e.query,abort:o};let r;try{r=n(e.query,o.signal,e.suggestion)}catch(a){this.logOnce(a),this.commit(e,[],i);return}if(Array.isArray(r)){this.commit(e,r,i);return}this.setSearch(e,"loading"),this.await(e,r,o.signal,i)}async await(e,n,i,o){let r;try{let a=await n;if(i.aborted||o!==this.version)return;r=Array.isArray(a)?a:[]}catch(a){if(i.aborted||o!==this.version||Vl(a))return;this.logOnce(a),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=_r(n,e.suggestion),r=this.resolveTarget(this.store.get());if(!r||r.key!==e.key)return;o.length===0?this.lastMiss={parameter:e.parameter,query:e.query}:this.lastMiss?.parameter===e.parameter&&(this.lastMiss=null);let a={parameter:e.parameter,query:e.query,status:"done"};if(e.mode==="edit")this.store.set(s=>({editingParam:s.editingParam&&s.editingParam.id===e.key?{...s.editingParam,options:o}:s.editingParam,optionSearch:a}));else{let s={...e.suggestion,options:o};this.current&&this.current.key===e.key&&(this.current.key=s),this.store.set(l=>({suggestions:l.suggestions.map(d=>d===e.suggestion?s:d),optionSearch:a}))}o.length===0?this.callbacks.onMiss?.(e.mode,e.query):this.callbacks.onAnswer?.(e.mode,e.query)}setSearch(e,n){let i=this.store.get().optionSearch;i&&i.parameter===e.parameter&&i.query===e.query&&i.status===n||this.store.set({optionSearch:{parameter:e.parameter,query:e.query,status:n}})}cancel(){this.current?.abort?.abort(),this.version++}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] an optionOverrides entry threw or rejected \u2014 treated as no options. Later failures on this instance are not logged.",e))}};function Vl(t){return t instanceof Error&&t.name==="AbortError"}var _n=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(C(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&&!d.selectsAll);this.store.set({suggestions:s,pillTapped:!0,activeDropdownIndex:l})}removeLastParam(){this.store.get().completedParams.length!==0&&this.store.set(n=>({completedParams:n.completedParams.slice(0,-1),activeDropdownIndex:-1}))}};var go="/products/",ra="https://relative.invalid";function Bl(t){if(!t)return;let e;try{e=new URL(t,`${ra}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===ra?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function ho(t,e){let n=Bl(t.item_url)??$l(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:aa(t.price,t.currency,e)},...Ul(t)&&{compareAtPrice:aa(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function Ul(t){if(!t.price||!t.compare_at_price)return!1;let e=Number(t.price),n=Number(t.compare_at_price);return Number.isFinite(e)&&Number.isFinite(n)&&n>e}function aa(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 $l(t){if(!t.handle)return;let e=`${go}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function Dn(t,e){return(t?.items.matched??[]).map(n=>ho(n,e))}var Hn=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=Dn(e,ue(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||Gl(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 Gl(t){return t instanceof Error&&t.name==="AbortError"}function ql(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function sa(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:Ve.findIndex(n=>n.toLowerCase().startsWith(e))}function Kl(t,e,n){let i=new Date(n.getFullYear(),t,e);if(i.getMonth()!==t||i.getDate()!==e)return null;let o=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(i>=o)return i;let r=new Date(n.getFullYear()+1,t,e);return r.getMonth()===t&&r.getDate()===e?r:null}var zl=/^(?:(?:on|from) )?(?:the )?(\d{1,2})(?:st|nd|rd|th)$/;function bo(t){let e=zl.exec(t.trim().toLowerCase().replace(/\s+/g," "));if(!e)return null;let n=Number(e[1]);return n>=1&&n<=31?n:null}function jl(t,e){if(!Number.isFinite(e.getTime()))return null;let n=new Date(e.getFullYear(),e.getMonth(),e.getDate());for(let i=0;i<12;i++){let o=new Date(e.getFullYear(),e.getMonth()+i,t);if(o.getDate()===t&&o>=n)return o}return null}function la(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=bo(t);if(i!==null){let d=jl(i,n);return d?W(d):null}let o=ql(t.trim().toLowerCase()).replace(/\s+/g," "),r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o);if(r){let d=la(Number(r[1]),Number(r[2])-1,Number(r[3]));return d?W(d):null}let a=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(o);if(a){let d=sa(a[1]);if(d>=0)return Nn(d,Number(a[2]),a[3],n)}let s=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(o);if(s){let d=sa(s[2]);if(d>=0)return Nn(d,Number(s[1]),s[3],n)}let l=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(o);if(l){let d=Number(l[1]),c=Number(l[2]);return d>12&&c<=12?Nn(c-1,d,l[3],n):c>12&&d<=12?Nn(d-1,c,l[3],n):null}return null}function Nn(t,e,n,i){if(n){if(n.length!==4)return null;let r=la(Number(n),t,e);return r?W(r):null}let o=Kl(t,e,i);return o?W(o):null}var Ql=/^\d{4}-\d{2}-\d{2}$/;function Pt(t){return typeof t=="string"&&Ql.test(t)?t:null}function Fn(t,e={}){return Pt(t.isoDate)??Ae(t.text,e)}function Lt(t){let e=Pt(t.isoDate);return e?{start:e,end:Pt(t.isoDateEnd)}:null}var To=" - ",Wn="aiaDateRangeStart",Vn="aiaDateRangeEnd";function Ct(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var yo=/^\d{4}-\d{2}-\d{2}$/;function So(t){if(!yo.test(t))return null;let[e,n,i]=t.split("-").map(Number),o=new Date(e,n-1,i);return o.getMonth()===n-1&&o.getDate()===i?o:null}var Yl=/\s+(?:to|through|thru|until|til|till)\s+/g,Xl=/[-–—]/g;function Jl(t){let e=[];for(let n of[Yl,Xl]){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 At(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of Jl(t.trim())){let a=Ae(o.trim(),e);if(!a)continue;let s=bo(r)!==null?Ae(r.trim(),{...e,today:So(a)??e.today}):Ae(r.trim(),e);!s||s<a||(n.add(`${a}|${s}`),i={start:a,end:s})}return n.size===1?i:null}function xo(t){let e=So(t.start),n=So(t.end);return!e||!n?"":t.start===t.end?Pe(e):`${Pe(e)}${To}${Pe(n)}`}function ca(t,e){let n=Ct(t,e);return{text:xo(n),is_tappable:!0,kind:null,metadata:{[Wn]:n.start,[Vn]:n.end}}}function Ie(t,e={}){let n=t?.metadata?.[Wn],i=t?.metadata?.[Vn];return typeof n=="string"&&typeof i=="string"&&yo.test(n)&&yo.test(i)?Ct(n,i):At(t?.text,e)}var It="(max-width: 768px)";var Zl="var(--aia-option-row-height, 37px)",ec="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function Eo(t,e){return e?vo(1,Math.min(t,5)):vo(1,Math.min(t,4))}function vo(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${Zl} + ${ec})`}}function Un(t,e){return!e&&t>=5}function $n(t,e,n,i){if(!(!e&&t>=5&&tc(n,i))){let a=Eo(t,e);return{...a,template:Bn(a.cols),scrollHintIndices:!e&&t>a.rows?[a.rows-1]:[]}}let r=6;return{...vo(2,3),template:Bn(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function tc(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 qe(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)+nc(t);return{rowWidths:i,gridWidth:r}}function nc(t){let e=t.closest("[data-aia-dropdown]"),n=Number.parseFloat(e?.getAttribute(Gn)??"");if(!e||!Number.isFinite(n)||e.style.getPropertyValue(Ot)!=="")return 0;let i=e.getBoundingClientRect().width;return i>0?n-i:0}var Gn="data-aia-glide-width",Ot="--aia-glide-content-width";function Bn(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function Ke(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(It).matches}function qn(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}var da={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Items",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",seeAllResults:"See all results",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",allOption:"All",timeLabel:"Time",locationSearch:"Say a location",locationNoResults:"No places found",locationUseTyped:"Press Enter to use what you typed"},ic={language:"es",and:"y",proceed:"para continuar",select:"para seleccionar",skipHint:"para omitir",skip:"omitir",skipLabel:"Omitir",products:"Mejor coincidencia",soldOut:"Agotado",addToCart:"A\xF1adir al carrito",submit:"Buscar",seeAllResults:"Ver todos los resultados",scrollArrow:"Despl\xE1zate para ver m\xE1s opciones",keepTyping:"Sigue escribiendo",done:"Listo",allOption:"Todo",timeLabel:"Hora",locationSearch:"Di una ubicaci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},wo={en:da,es:ic,fr:{language:"fr",and:"et",proceed:"pour continuer",select:"pour s\xE9lectionner",skipHint:"pour passer",skip:"passer",skipLabel:"Passer",products:"Meilleure correspondance",soldOut:"\xC9puis\xE9",addToCart:"Ajouter au panier",submit:"Rechercher",seeAllResults:"Voir tous les r\xE9sultats",scrollArrow:"Faites d\xE9filer pour voir plus d\u2019options",keepTyping:"Continuez \xE0 taper",done:"Termin\xE9",allOption:"Tout",timeLabel:"Heure",locationSearch:"Dites un lieu",locationNoResults:"Aucun lieu trouv\xE9",locationUseTyped:"Appuyez sur Entr\xE9e pour utiliser votre saisie"},"pt-BR":{language:"pt-BR",and:"e",proceed:"para continuar",select:"para selecionar",skipHint:"para pular",skip:"pular",skipLabel:"Pular",products:"Melhor correspond\xEAncia",soldOut:"Esgotado",addToCart:"Adicionar ao carrinho",submit:"Buscar",seeAllResults:"Ver todos os resultados",scrollArrow:"Role para ver mais op\xE7\xF5es",keepTyping:"Continue digitando",done:"Conclu\xEDdo",allOption:"Tudo",timeLabel:"Hor\xE1rio",locationSearch:"Diga um local",locationNoResults:"Nenhum lugar encontrado",locationUseTyped:"Pressione Enter para usar o que voc\xEA digitou"},it:{language:"it",and:"e",proceed:"per continuare",select:"per selezionare",skipHint:"per saltare",skip:"salta",skipLabel:"Salta",products:"Migliore corrispondenza",soldOut:"Esaurito",addToCart:"Aggiungi al carrello",submit:"Cerca",seeAllResults:"Vedi tutti i risultati",scrollArrow:"Scorri per vedere altre opzioni",keepTyping:"Continua a scrivere",done:"Fatto",allOption:"Tutto",timeLabel:"Ora",locationSearch:"Di' un luogo",locationNoResults:"Nessun luogo trovato",locationUseTyped:"Premi Invio per usare ci\xF2 che hai scritto"},tr:{language:"tr",and:"ve",proceed:"devam etmek i\xE7in",select:"se\xE7mek i\xE7in",skipHint:"atlamak i\xE7in",skip:"atla",skipLabel:"Atla",products:"En iyi e\u015Fle\u015Fme",soldOut:"T\xFCkendi",addToCart:"Sepete ekle",submit:"Ara",seeAllResults:"T\xFCm sonu\xE7lar\u0131 g\xF6r",scrollArrow:"Daha fazla se\xE7enek i\xE7in kayd\u0131r",keepTyping:"Yazmaya devam et",done:"Tamam",allOption:"T\xFCm\xFC",timeLabel:"Saat",locationSearch:"Bir konum s\xF6yleyin",locationNoResults:"Yer bulunamad\u0131",locationUseTyped:"Yazd\u0131\u011F\u0131n\u0131z\u0131 kullanmak i\xE7in Enter'a bas\u0131n"},id:{language:"id",and:"dan",proceed:"untuk melanjutkan",select:"untuk memilih",skipHint:"untuk melewati",skip:"lewati",skipLabel:"Lewati",products:"Paling cocok",soldOut:"Habis",addToCart:"Tambah ke keranjang",submit:"Cari",seeAllResults:"Lihat semua hasil",scrollArrow:"Gulir untuk melihat opsi lainnya",keepTyping:"Teruskan mengetik",done:"Selesai",allOption:"Semua",timeLabel:"Waktu",locationSearch:"Sebutkan lokasi",locationNoResults:"Tempat tidak ditemukan",locationUseTyped:"Tekan Enter untuk memakai yang Anda ketik"},pl:{language:"pl",and:"i",proceed:"aby kontynuowa\u0107",select:"aby wybra\u0107",skipHint:"aby pomin\u0105\u0107",skip:"pomi\u0144",skipLabel:"Pomi\u0144",products:"Najlepsze dopasowanie",soldOut:"Wyprzedane",addToCart:"Dodaj do koszyka",submit:"Szukaj",seeAllResults:"Zobacz wszystkie wyniki",scrollArrow:"Przewi\u0144, aby zobaczy\u0107 wi\u0119cej opcji",keepTyping:"Pisz dalej",done:"Gotowe",allOption:"Wszystko",timeLabel:"Godzina",locationSearch:"Podaj lokalizacj\u0119",locationNoResults:"Nie znaleziono miejsc",locationUseTyped:"Naci\u015Bnij Enter, aby u\u017Cy\u0107 wpisanego tekstu"},de:{language:"de",and:"und",proceed:"zum Fortfahren",select:"zum Ausw\xE4hlen",skipHint:"zum \xDCberspringen",skip:"\xFCberspringen",skipLabel:"\xDCberspringen",products:"Beste Treffer",soldOut:"Ausverkauft",addToCart:"In den Warenkorb",submit:"Suchen",seeAllResults:"Alle Ergebnisse anzeigen",scrollArrow:"Scrolle f\xFCr weitere Optionen",keepTyping:"Weitertippen",done:"Fertig",allOption:"Alle",timeLabel:"Uhrzeit",locationSearch:"Nenne einen Ort",locationNoResults:"Keine Orte gefunden",locationUseTyped:"Dr\xFCcke Enter, um deine Eingabe zu verwenden"},nl:{language:"nl",and:"en",proceed:"om door te gaan",select:"om te selecteren",skipHint:"om over te slaan",skip:"overslaan",skipLabel:"Overslaan",products:"Beste match",soldOut:"Uitverkocht",addToCart:"In winkelwagen",submit:"Zoeken",seeAllResults:"Alle resultaten bekijken",scrollArrow:"Scrol voor meer opties",keepTyping:"Blijf typen",done:"Klaar",allOption:"Alles",timeLabel:"Tijd",locationSearch:"Noem een locatie",locationNoResults:"Geen plaatsen gevonden",locationUseTyped:"Druk op Enter om je invoer te gebruiken"},sv:{language:"sv",and:"och",proceed:"f\xF6r att forts\xE4tta",select:"f\xF6r att v\xE4lja",skipHint:"f\xF6r att hoppa \xF6ver",skip:"hoppa \xF6ver",skipLabel:"Hoppa \xF6ver",products:"B\xE4sta matchning",soldOut:"Sluts\xE5ld",addToCart:"L\xE4gg i varukorgen",submit:"S\xF6k",seeAllResults:"Visa alla resultat",scrollArrow:"Skrolla f\xF6r fler alternativ",keepTyping:"Forts\xE4tt skriva",done:"Klar",allOption:"Alla",timeLabel:"Tid",locationSearch:"S\xE4g en plats",locationNoResults:"Inga platser hittades",locationUseTyped:"Tryck p\xE5 Enter f\xF6r att anv\xE4nda det du skrev"},nb:{language:"nb",and:"og",proceed:"for \xE5 fortsette",select:"for \xE5 velge",skipHint:"for \xE5 hoppe over",skip:"hopp over",skipLabel:"Hopp over",products:"Beste treff",soldOut:"Utsolgt",addToCart:"Legg i handlekurven",submit:"S\xF8k",seeAllResults:"Se alle resultater",scrollArrow:"Rull ned for \xE5 se flere alternativer",keepTyping:"Fortsett \xE5 skrive",done:"Ferdig",allOption:"Alle",timeLabel:"Tid",locationSearch:"Si et sted",locationNoResults:"Fant ingen steder",locationUseTyped:"Trykk Enter for \xE5 bruke det du skrev"},da:{language:"da",and:"og",proceed:"for at forts\xE6tte",select:"for at v\xE6lge",skipHint:"for at springe over",skip:"spring over",skipLabel:"Spring over",products:"Bedste match",soldOut:"Udsolgt",addToCart:"L\xE6g i kurv",submit:"S\xF8g",seeAllResults:"Se alle resultater",scrollArrow:"Rul for flere muligheder",keepTyping:"Forts\xE6t med at skrive",done:"F\xE6rdig",allOption:"Alle",timeLabel:"Tidspunkt",locationSearch:"Sig et sted",locationNoResults:"Ingen steder fundet",locationUseTyped:"Tryk p\xE5 Enter for at bruge det, du skrev"},fi:{language:"fi",and:"ja",proceed:"jatkaaksesi",select:"valitaksesi",skipHint:"ohittaaksesi",skip:"ohita",skipLabel:"Ohita",products:"Paras vastaavuus",soldOut:"Loppuunmyyty",addToCart:"Lis\xE4\xE4 ostoskoriin",submit:"Hae",seeAllResults:"N\xE4yt\xE4 kaikki tulokset",scrollArrow:"Vierit\xE4 n\xE4hd\xE4ksesi lis\xE4\xE4 vaihtoehtoja",keepTyping:"Jatka kirjoittamista",done:"Valmis",allOption:"Kaikki",timeLabel:"Aika",locationSearch:"Sano sijainti",locationNoResults:"Paikkoja ei l\xF6ytynyt",locationUseTyped:"Paina Enteri\xE4 k\xE4ytt\xE4\xE4ksesi kirjoittamaasi"},ja:{language:"ja",and:"\u3068",proceed:"\u3067\u6B21\u3078",select:"\u3067\u9078\u629E",skipHint:"\u3067\u30B9\u30AD\u30C3\u30D7",skip:"\u30B9\u30AD\u30C3\u30D7",skipLabel:"\u30B9\u30AD\u30C3\u30D7",products:"\u30D9\u30B9\u30C8\u30DE\u30C3\u30C1",soldOut:"\u58F2\u308A\u5207\u308C",addToCart:"\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",submit:"\u691C\u7D22",seeAllResults:"\u3059\u3079\u3066\u306E\u7D50\u679C\u3092\u898B\u308B",scrollArrow:"\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u3066\u4ED6\u306E\u5019\u88DC\u3092\u898B\u308B",keepTyping:"\u5165\u529B\u3092\u7D9A\u3051\u308B",done:"\u5B8C\u4E86",allOption:"\u3059\u3079\u3066",timeLabel:"\u6642\u523B",locationSearch:"\u5834\u6240\u3092\u8A00\u3063\u3066\u304F\u3060\u3055\u3044",locationNoResults:"\u5834\u6240\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",locationUseTyped:"\u5165\u529B\u3057\u305F\u5185\u5BB9\u3092\u4F7F\u3046\u306B\u306F Enter \u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044"},ko:{language:"ko",and:"\uBC0F",proceed:"\uACC4\uC18D",select:"\uC120\uD0DD",skipHint:"\uAC74\uB108\uB6F0\uAE30",skip:"\uAC74\uB108\uB6F0\uAE30",skipLabel:"\uAC74\uB108\uB6F0\uAE30",products:"\uCD94\uCC9C \uC0C1\uD488",soldOut:"\uD488\uC808",addToCart:"\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uB2F4\uAE30",submit:"\uAC80\uC0C9",seeAllResults:"\uBAA8\uB4E0 \uACB0\uACFC \uBCF4\uAE30",scrollArrow:"\uB354 \uB9CE\uC740 \uC635\uC158\uC744 \uBCF4\uB824\uBA74 \uC2A4\uD06C\uB864\uD558\uC138\uC694",keepTyping:"\uACC4\uC18D \uC785\uB825\uD558\uC138\uC694",done:"\uC644\uB8CC",allOption:"\uC804\uCCB4",timeLabel:"\uC2DC\uAC04",locationSearch:"\uC704\uCE58\uB97C \uB9D0\uD558\uC138\uC694",locationNoResults:"\uC7A5\uC18C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",locationUseTyped:"\uC785\uB825\uD55C \uB0B4\uC6A9\uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 Enter\uB97C \uB204\uB974\uC138\uC694"},"zh-CN":{language:"zh-CN",and:"\u548C",proceed:"\u7EE7\u7EED",select:"\u9009\u62E9",skipHint:"\u8DF3\u8FC7",skip:"\u8DF3\u8FC7",skipLabel:"\u8DF3\u8FC7",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u7F44",addToCart:"\u52A0\u5165\u8D2D\u7269\u8F66",submit:"\u641C\u7D22",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7ED3\u679C",scrollArrow:"\u5411\u4E0B\u6EDA\u52A8\u67E5\u770B\u66F4\u591A\u9009\u9879",keepTyping:"\u7EE7\u7EED\u8F93\u5165",done:"\u5B8C\u6210",allOption:"\u5168\u90E8",timeLabel:"\u65F6\u95F4",locationSearch:"\u8BF4\u51FA\u5730\u70B9",locationNoResults:"\u672A\u627E\u5230\u5730\u70B9",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F93\u5165\u7684\u5185\u5BB9"},"zh-TW":{language:"zh-TW",and:"\u548C",proceed:"\u7E7C\u7E8C",select:"\u9078\u64C7",skipHint:"\u7565\u904E",skip:"\u7565\u904E",skipLabel:"\u7565\u904E",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u5B8C",addToCart:"\u52A0\u5165\u8CFC\u7269\u8ECA",submit:"\u641C\u5C0B",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7D50\u679C",scrollArrow:"\u5411\u4E0B\u6372\u52D5\u67E5\u770B\u66F4\u591A\u9078\u9805",keepTyping:"\u7E7C\u7E8C\u8F38\u5165",done:"\u5B8C\u6210",allOption:"\u5168\u90E8",timeLabel:"\u6642\u9593",locationSearch:"\u8AAA\u51FA\u5730\u9EDE",locationNoResults:"\u627E\u4E0D\u5230\u5730\u9EDE",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F38\u5165\u7684\u5167\u5BB9"}},oc={pt:"pt-BR",no:"nb",nn:"nb"};function k(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return wo[o?"zh-TW":"zh-CN"]}let i=oc[e]??e;return Object.prototype.hasOwnProperty.call(wo,i)?wo[i]:da}function ua(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 U(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 Kn(t){if(!t)return no();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function rc(t){let e=bt(t);return e?jr(e):no()}function ac(t,e){if(!t)return null;for(let n of e){if(n.parameter!==t||n.type?.kind!=="date_range")continue;let i=Lt(n);if(i&&i.end==null)return i.start}return null}function sc(t){let e=new Set,n=i=>{i&&e.add(i)};for(let i of t.completedParams??[]){if(i.id===t.editingParam?.id)continue;let o=i.suggestionValueType?.kind;if(o==="date"&&n(Pt(i.metadata?.[cn])??Be(i.text)),o==="date_range"){let r=Ie(i);n(r?.start),n(r?.end)}}for(let i of t.identifiedParams??[]){if(i.id===t.editingIdentified?.id)continue;let o=i.type?.kind;if(o!=="date"&&o!=="date_range")continue;let r=Lt(i);n(r?.start),n(r?.end)}return[...e].sort()}function Po(t,e){return t.editingParam!=null&&t.editingAnchor!=null?e:t.text.slice(we(t.text,t.completedParams))}var lc=/price/i;function cc(t){return!t||Ee(t)||D(Q(t))||t.type?.kind==="multi_select"||lc.test(t.parameter)?!1:(t.options??[]).filter(e=>e.is_tappable).length>=2}function Mt(t,e,n){if(e>0)return!1;let i=t.trim();return i===""||i.toLowerCase()===n.trim().toLowerCase()||ut(i,0,n)}var dc=4;function uc(t,e){let n={text:e,kind:null,is_tappable:!0,selectsAll:!0},i=[...new Set(t.filter(r=>r.is_tappable&&r.image_url).map(r=>r.image_url))].slice(0,dc);if(i.length>0)return n.image_url=i[0],i.length>1&&(n.imageCollage=i),[n,...t];let o;for(let r of t)r.is_tappable&&(o=r);return o?.icon&&(n.icon=o.icon),o?.icon_svg&&(n.icon_svg=o.icon_svg),[n,...t]}function mc(t,e){let{composing:n}=t,i=n?.over===t.text?n.text:t.text,o=i.slice(we(i,t.completedParams));return e?.completes_word!==!0?o:o.match(/\S+(?=\s*$)/)?.[0]??""}function ma(t,e){let n=an(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(O=>O.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(O=>O.parameter==="placeholder").map(O=>O.text).join(" "),a=Fe(r,e.prependPlaceholder),s=me(t.text,Math.min(t.filterBase,t.text.length),a),d=s===0&&ut(t.text,t.completedParams.length,a)?"":mt(t.text,s,t.filterInProgress),c=o?.options??[],u=t.editingParam!=null&&t.editingAnchor!=null,f=!u&&!t.editingIdentified&&o?.type?.kind==="multi_select",p,m,g,b;if(u&&t.editingParam&&t.editingAnchor!=null){let O=t.editingParam.id,q=t.completedParams.some(de=>de.id===O),st=t.caretOffset??t.editingAnchor,Y=q?"":t.text.slice(t.editingAnchor,st);m=Y.trim(),g=t.editingParam.options,b=t.editingParam.suggestionParameter,p=t.editingParam.suggestionValueType?.kind==="traditional_autocomplete"?pe(t.editingParam.options,Y).map(de=>({...de,matchedText:m,parameterLabel:Zi(de)})):pe(t.editingParam.options,Y)}else m=d.trim(),g=c,b=o?.parameter,p=C(o)?c.map(O=>({...O,matchedText:mc(t,o),parameterLabel:Zi(O)})):pe(c,d,t.traditionalAutocomplete);let T=t.optionSearch,S=T!=null&&b!=null&&T.parameter===b;S&&T.status==="done"&&T.query===m&&(p=g);let P=S&&T.status==="loading",v=e.showNonTappableOptions===!1;v&&(p=p.filter(O=>O.is_tappable));let h=Mt(t.text,t.completedParams.length,a);e.allOption===!0&&o?.leadsWithAll===!0&&!h&&!u&&!t.editingIdentified&&d.trim()===""&&cc(o)&&(p=uc(p,k(e.language).allOption));let x=Po(t,m),w=u?t.editingParam?.suggestionValueType?.kind==="traditional_autocomplete":C(o);!f&&!w&&(p=Mr(p,x));let y=t.editingIdentified,L=u?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,R=y?y.format:Q(L),A=u?t.editingParam?.suggestionParameter:o?.parameter,F=R==="location"&&A&&e.optionOverrides?.[A]?"options":R,I=u&&F==="date-range"?Ie(t.editingParam):null,G=!u&&!y&&F==="date"?ac(o?.parameter,t.identifiedParams):null,le=null,oe=null,E=_(F)?sc(t):[];if(_(F)){let O=W(new Date),q=E.find(ol=>ol>=O)??null,st=U({...t,actionableSuggestions:i}),Y=t.dateViewMonth;le=Y&&Y.key===st?{year:Y.year,month:Y.month}:y?Kn(y.iso):I?Kn(I.start):G?Kn(G):q&&!u?Kn(q):rc(t.editingParam?.text),p=mn(le);let de=t.pendingRangeStart;F==="date-range"&&de&&de.key===st&&(oe=de.iso)}let ce=null;if(F==="time"){let O=U({...t,actionableSuggestions:i}),q=t.timeDraft;ce=q&&q.key===O?{minutes:q.minutes,touched:!0}:{minutes:oa({editingText:u?t.editingParam?.text:null,options:u?t.editingParam?.options:o?.options}),touched:!1},p=[]}let Te=null;if(F==="location"){let O=U({...t,actionableSuggestions:i}),q=t.locationSearch;if(q&&q.key===O){let{key:st,...Y}=q;Te=Y}else Te={query:u?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};p=[]}let Vt=O=>v?O.is_tappable:!0,xe;if(u){let O=t.editingParam?.options??[];xe=t.editingParam!=null&&O.filter(Vt).length===0}else xe=o!=null&&c.filter(Vt).length===0;ce&&(xe=!0),Te&&(xe=!0);let ot=ua({inEditMode:u||y!=null,filteredOptionsLength:p.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||P,pillTapped:t.pillTapped,activePillHasNoOptions:xe,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),Bt=ot&&t.activeDropdownIndex>=0&&!!p[t.activeDropdownIndex]?.is_tappable,Ut=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,ve=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||P||Ut,M=ve&&t.skeletonOptions!==null,rt=M&&t.skeletonOptions?t.skeletonOptions:p,at=M?t.skeletonSuggestion:null,hr=f?{picked:t.multiSelectDraft?.key===U({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,il=hr??(M&&t.skeletonSuggestion?.type?.kind==="multi_select"?{picked:t.skeletonPicked??[]}:null);return{segments:n,actionableSuggestions:i,filteredOptions:p,dropdownLoading:ve,dropdownOptions:rt,dropdownSuggestion:at,skeletonExiting:Ut,activeFormatType:F,dateView:le,dateRangeStart:oe,dateFloor:G,dateReferences:E,timeView:ce,multiSelectView:hr,dropdownMultiSelect:il,locationView:Te,placeholderText:r,leadInText:a,optionQuery:m,isSearchingOptions:P,isDropdownOpen:ot,isActivePillSelected:Bt}}function zn(t){return t.mode!=="edit"?fc(t):gc(t)}function pc(t,e,n){let i=t.find(C);if(!i?.options)return null;let o=e.slice(we(e,n)).trim().toLowerCase();if(!o)return null;let r=i.completes_word===!0?o.split(/\s+/).pop()??"":o,a=i.options.filter(d=>d.is_tappable&&d.text.trim().toLowerCase()===r);if(new Set(a.map(d=>Z(d,i.parameter))).size!==1)return null;let l=a[0];return{suggestion:i,option:l,matchText:l.text.trim()}}function pa(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,a=n.find(c=>c.parameter!=="placeholder"&&!C(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=me(e,i,Fe(s,t.prependPlaceholder)),d=pt(a.options,e,l,o,r===!0);return d?{suggestion:a,option:d,matchText:d.text}:null}function fc(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?pa(t):null)??pc(i,e,n):pa(t);if(!o)return null;let{suggestion:r,option:a,matchText:s}=o,l=s.toLowerCase(),d=e.toLowerCase().lastIndexOf(l),c=d>=0?d:Math.max(0,e.length-a.text.length),u=c+s.length,f=e.slice(c,u),m=u<e.length&&e[u]===" "?u+1:u,g={id:crypto.randomUUID(),placeholder:"",parameter:Z(a,r.parameter),text:f,value:a.value,kind:a.kind,suggestionParameter:r.parameter,suggestionValueType:r.type,suggestionPlaceholder:r.text,suggestionIcon:r.icon,suggestionIconSvg:r.icon_svg,...t.mode==="submit"&&C(r)?ft(Z(a,r.parameter),r.text,a.parameter_label):{},options:r.options??[],metadata:a.metadata,icon:a.icon,icon_svg:a.icon_svg,image_url:a.image_url};return{patch:{text:e,completedParams:[...n,g],suggestions:i.filter(b=>b!==r),filterBase:m,newParamId:g.id,caretOffset:m,activeDropdownIndex:-1},caretPos:m,option:a,suggestion:r}}function gc(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(P=>P.id===i.id))return null;let a=e.slice(o,r),s=Jt(i.options,a);if(!s)return null;let l=s.text.toLowerCase(),d=a.toLowerCase().lastIndexOf(l),c=o+Math.max(0,d),u=c+s.text.length,f=e.slice(c,u),p=u<e.length&&e[u]===" "?u+1:u,m=e.length,g={id:crypto.randomUUID(),placeholder:"",...Zt(i,s),text:f,value:s.value,kind:s.kind,options:i.options,metadata:s.metadata,icon:s.icon,icon_svg:s.icon_svg,image_url:s.image_url},b=n.length,T=0;for(let P=0;P<n.length;P++){let v=re(e,n[P].text,T);if(v!==-1){if(v>=p){b=P;break}T=v+n[P].text.length}}let S=[...n];return S.splice(b,0,g),{patch:{text:e,completedParams:S,newParamId:g.id,filterBase:m,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:m,activeDropdownIndex:-1},caretPos:m,option:s}}function Co(t){return t.slice(t.search(/\S*$/))}function ga(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function Ao(t,e){let n="",i=0;for(let o of t){let r=i;if(n+=ga(o),i+=o.length,n.length>=e.length){if(!n.startsWith(e))return null;let a=i+(t.slice(i).match(/^\p{M}*/u)?.[0].length??0),s=n.length>e.length;return{length:a,partialStart:s?r:a}}if(!e.startsWith(n))return null}return null}function ha(t,e,n,i){let o=[];return e<i&&o.push({text:t.slice(e,i),bold:!0}),i<n&&o.push({text:t.slice(i,n),bold:!0,partial:!0}),o}function Lo(t){return[...t].map(ga).join("")}function kt(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(Lo),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:Lo(o[0])}));for(let o=n.length;o>=1;o--){let r=n.slice(n.length-o),a=r[o-1];for(let s=0;s+o<=i.length;s++){if(!r.slice(0,-1).every((u,f)=>i[s+f].folded===u))continue;let d=i[s+o-1],c=Ao(d.text,a);if(c)return{typedWords:o,start:i[s].index,end:d.index+c.length,partialStart:d.index+c.partialStart}}}return null}function fa(t,e,n,i){return[{text:t.slice(0,e),bold:!1},...ha(t,e,n,i),{text:t.slice(n),bold:!1}].filter(o=>o.text!=="")}function hc(t,e){let n=0;for(let i of t){if(!/^\p{M}/u.test(i)){let o=Ao(t.slice(n),e);if(o)return{start:n,end:n+o.length,partialStart:n+o.partialStart}}n+=i.length}return null}var bc=/\p{Script=Hangul}/u;function jn(t,e){let n=e?kt(t,e):null;if(n&&n.typedWords>1)return fa(t,n.start,n.end,n.partialStart);let i=e?Co(e):"",o=Lo(i);if(!o)return[{text:t,bold:!1}];let r=[],a=!1;for(let l of t.split(/(\s+)/)){if(l==="")continue;let d=/^\s/.test(l)?null:Ao(l,o);if(d){a=!0;let{length:u,partialStart:f}=d;r.push(...ha(l,0,u,f))}let c=d?l.slice(d.length):l;c&&r.push({text:c,bold:!1})}if(a||!bc.test(i))return r;let s=hc(t,o);return s?fa(t,s.start,s.end,s.partialStart):r}var yc=6e4;function Sc(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function Tc(t){return(t??X).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function xc(t){return lt(t)?`Bearer ${await qt(t).getToken()}`:zt(t)}async function ba(t){try{let e=Tc(t.apiConfig?.endpoint),n=Kt(t.apiConfig),i=await xc(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&&Sc(o)<=yc&&{keepalive:!0}})}catch{}}function be(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var Io=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function vc(t,e,n){let i=Io(t??"");if(i.length===0)return"";let r=Io(e).slice(-i.length),a=Io(n).slice(0,i.length);return r.join(" ")===i.join(" ")||a.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function ya(t,e){let n=t.actionableSuggestions[0];if(!n)return null;let i=C(n),o=e.parameter;if(i&&!o)return null;let r=i&&o?o:Z(e,n.parameter),a=i?t.text.length:t.filterBase,s=t.text.slice(0,a),l=s.length===0&&t.text.length===0,d=s.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||d)&&t.placeholderText&&(s=`${t.placeholderText} `);let c=Math.min(we(t.text,t.completedParams),s.length),u=!1;if(i&&n.completes_word!==!0){let y=[...s.slice(c).matchAll(/\S+/g)],L=kt(e.text,s.slice(c)),R=y[y.length-(L?.typedWords??1)];s=s.slice(0,R?c+(R.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word===!0){let y=[...s.slice(c).matchAll(/\S+/g)],L=y[y.length-1];s=s.slice(0,L?c+(L.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word!==!1){let y=s.slice(c),L=Math.max(Ir(y,e.text),vr(y,e));L>0&&(s=s.slice(0,s.length-L)),u=L>0}let f=s.length>0&&s[s.length-1]!==" ",p=i||n.completes_word===!0||u,m=t.activeFormatType!==void 0&&!D(t.activeFormatType)&&D(Q({type:n.type})),g=p||m?"":vc(n.lead_in,s,e.text),b=`${s}${f?" ":""}${g?`${g} `:""}${e.text} `,S=(l||d||i&&s.length===0)&&b.length>0?b[0].toUpperCase()+b.slice(1):b,P=S.toLowerCase().lastIndexOf(e.text.toLowerCase()),v=P>=0?S.slice(P,P+e.text.length):e.text,h=i?ft(r,n.text,e.parameter_label):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text,suggestionIcon:n.icon,suggestionIconSvg:n.icon_svg},x={id:crypto.randomUUID(),placeholder:"",...h,text:v,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},w=t.actionableSuggestions.length-1;return{patch:{text:S,filterBase:S.length,completedParams:[...t.completedParams,x],newParamId:x.id,caretOffset:S.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(y=>y.text!==e.text).map(y=>y.text),key:i?r:n.parameter,position:be(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:w}}function Rt(t,e){let n=D(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,i=t.editingParam,o=i?We(i):t.actionableSuggestions[0]??null;return{skeletonOptions:n,skeletonSuggestion:n?o:null,skeletonPicked:n?e??null:null,skeletonRequested:!1}}function Qn(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=re(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===""?Qn(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=Zt(i,e);this.deps.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(S=>S.text!==e.text).map(S=>S.text),key:a.suggestionParameter,position:be(i.options,e.text),chip_origin:"tap"});let s=n.text.slice(0,o),l=n.text.slice(r),d=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,u=l.length===0||l[0]!==" "?`${d} `:d,f=s+u+l,p=f.length,m={id:crypto.randomUUID(),placeholder:"",...a,text:d,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},g=n.completedParams.findIndex(S=>S.id===i.id),b=n.completedParams.filter(S=>S.id!==i.id),T=g>=0?Math.min(g,b.length):b.length;b.splice(T,0,m),this.deps.store.set({text:f,completedParams:b,newParamId:m.id,filterBase:p,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:p,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...Rt(n)}),this.deps.startSelectionAnimationTimer(),this.deps.scheduleSetCursor(p),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=zn({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 Ta=33,xa=70,va=120,Ea=50,Oe="data-aia-placeholder-leaving",ze=new WeakMap;function Xn(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function Ec(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function wa(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function Pa(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(wa(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(()=>Pa(t,e),33+i)}function Sa(t,e){wa(t,e,0),e.timer=setTimeout(()=>Pa(t,e),33)}function La(t,e){let n=ze.get(t);if(e===""){n&&(Xn(n),ze.delete(t)),t.removeAttribute(Oe),delete t.dataset.placeholder;return}if(n?.target===e)return;if(Ec(t)){n&&Xn(n),t.removeAttribute(Oe),ze.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),ze.set(t,i),o){t.setAttribute(Oe,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(Oe),t.isConnected&&Sa(t,i)},170);return}t.removeAttribute(Oe),Sa(t,i)}function Ca(t){let e=ze.get(t);e&&(Xn(e),ze.delete(t))}var wc={selectedIso:null,selectedRange:null,rangeStart:null};function je(t){if(!_(t.activeFormatType))return wc;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?Ct(i,o):null,rangeStart:t.dateRangeStart,references:t.dateReferences??[]}}let n=Ie(t.editingParam);return{selectedIso:n?null:Be(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart??t.dateFloor??null,floor:t.dateFloor??null,references:t.dateReferences??[]}}function Jn(t){let e=t.floor!=null&&t.highlightedIso!=null&&t.highlightedIso<t.floor?null:t.highlightedIso;return t.pendingStart?Ct(t.pendingStart,e??t.pendingStart):t.selected}function Zn(t,e){if(t==null)return{selected:!1,inRange:!1,reference:!1};let{selectedIso:n,range:i}=e,o=t===n||i!=null&&(t===i.start||t===i.end),r=i!=null&&t>i.start&&t<i.end,a=!o&&!r&&(e.references?.includes(t)??!1);return{selected:o,inRange:r,reference:a}}function ei(t,e,n){return t==null?!1:t<e||n!=null&&t<n}function ti(t,e){return t==="date"?e??null:null}var Oo="https://ai-autocomplete.com";function ni(t=Oo){try{if(typeof window>"u"||!window.location)return t;let e=window.location.hostname;if(!e)return t;let n=new URL(t);return n.searchParams.set("utm_source",e),n.toString()}catch{return t}}function ii(t,e,n=k()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function oi(t){let e=a=>{a.ctrlKey||Aa(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&&!Aa(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 Aa(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&Pc(o,i)||n!==0&&Lc(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var Ia=/^(auto|scroll|overlay)$/;function Pc(t,e){return t.scrollHeight<=t.clientHeight||!Ia.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function Lc(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!Ia.test(n.overflowX))return!1;let i=Math.abs(t.scrollLeft),o=t.scrollWidth-t.clientWidth;return(n.direction==="rtl"?e<0:e>0)?i<o-1:i>0}function Qe(t,e,n){n?(t.getAttribute(e)!=="busy"&&t.setAttribute(e,"busy"),t.getAttribute("aria-busy")!=="true"&&t.setAttribute("aria-busy","true")):t.hasAttribute(e)&&(t.removeAttribute(e),t.removeAttribute("aria-busy"))}var Oa=new WeakMap,Ma=new WeakSet;function $(t,e,n){if(Oa.set(t,n),Ma.has(t))return;Ma.add(t);let i=()=>Oa.get(t),o=r=>{if(!(r instanceof Element))return null;let a=r.closest(e.itemSelector);return a&&t.contains(a)?a:null};e.onClick&&t.addEventListener("click",r=>{let a=o(r.target);a&&e.onClick?.(a,i(),r)}),e.onEnter&&t.addEventListener("mouseenter",r=>{let a=r.target;a instanceof HTMLElement&&a.matches(e.itemSelector)&&e.onEnter?.(a,i())},!0),e.onLeave&&t.addEventListener("mouseleave",r=>{let a=r.target;a instanceof HTMLElement&&a.matches(e.itemSelector)&&e.onLeave?.(a,i())},!0),e.preventMousedown&&t.addEventListener("mousedown",r=>r.preventDefault())}function ye(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function j(t){t.offsetWidth}var ee="magicx-aia-panel-ghost";function Me(t){return t.closest(`.${ee}`)!==null}function B(t,e){for(let n of t.querySelectorAll(e))if(!Me(n))return n;return null}var ri="--aia-multi-done-fit";function ka(t){return B(t,"[data-aia-multi-done]")}function ai(t,e){if(!e?.isConnected)return;let n=e.ownerDocument,i=n.defaultView?.getComputedStyle(e).direction==="rtl";if(typeof n.createRange().getBoundingClientRect!="function")return;let o=e.getBoundingClientRect(),r=0;for(let a of t.querySelectorAll("[data-aia-option]")){if(Me(a))continue;let s=n.defaultView?.getComputedStyle(a),l=Number.parseFloat(i?s?.paddingRight??"0":s?.paddingLeft??"0")||0,d=n.createTreeWalker(a,NodeFilter.SHOW_TEXT),c=n.createRange();for(let u=d.nextNode();u;u=d.nextNode()){if(!u.textContent?.trim())continue;c.selectNodeContents(u);let f=c.getBoundingClientRect();if(f.width===0)continue;let p=i?o.right-f.left:f.right-o.left;r=Math.max(r,p+l)}}r>0?e.style.setProperty(ri,`${Math.ceil(r)}px`):e.style.removeProperty(ri)}var Ra=40,_a=340,Da=340,Ha=7,si="--aia-option-enter-delay";function li(t,e,n,i="below"){let o=Math.max(1,Math.floor(e)),r=Math.floor(Math.max(0,t)/o);if(i!=="above")return r*40;let a=Math.max(1,Math.ceil(Math.max(0,n)/o));return Math.max(0,a-1-r)*40}function ci(t,e){let n=Math.max(1,Math.floor(e));return(Math.max(1,Math.ceil(Math.max(0,t)/n))-1)*40+340}var Ro="magicx-aia-scroll-arrow",_t="data-aia-scroll-arrow",ke="data-aia-visible",_o=1e3,Do=160,Ho="--aia-scroll-arrow-bottom",Fa="Scroll down for more options",Mo="data-aia-scrollable",Cc="--aia-scroll-track-top",Ac="--aia-scroll-track-height",Ic="--aia-scroll-track-right",Oc="--aia-scroll-thumb-top",Mc="--aia-scroll-thumb-height",kc=12,Rc=.5,_c="[data-aia-products-label]",Na=4,Dc=8,Hc=240;function Nc(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,a=t.ownerDocument?.visibilityState==="hidden";if(!r||a||ko(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)/Hc),u=1-(1-c)*(1-c);t.scrollTop=o+e*u,c<1?r.call(n,d):i()};r.call(n,d)}function Fc(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 Wa(t=document,e=k()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=Ro,n.setAttribute(_t,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(Fc(t)),n}function Wc(t){return Math.max(1,No(t.style.gridTemplateColumns))}function ko(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function di({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=x=>{if(x){if(n.hasAttribute(ke))return;if(n.setAttribute(ke,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),ko(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(ke)&&(n.disabled=!1)},_o)}else n.removeAttribute(ke),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},c=x=>{let w=0,y=x;for(;y&&y!==t;)w+=y.offsetTop,y=y.offsetParent instanceof HTMLElement?y.offsetParent:null;return w},u=()=>{let x=B(t,_c),w;if(x){let y=c(x)+x.offsetHeight/2;w=t.clientHeight-y-n.offsetHeight/2}else{let y=c(e),L=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;w=t.clientHeight-(y+e.offsetHeight)+(L>0?0:Dc)}n.style.setProperty(Ho,`${Math.max(0,Math.round(w))}px`)},f=x=>{let w=0,y=x;for(;y&&y!==t;)w+=y.offsetLeft,y=y.offsetParent instanceof HTMLElement?y.offsetParent:null;return w},p=null,m=(x,w)=>{let y=Math.min(1,Math.max(0,e.scrollTop/x));n.style.setProperty(Oc,`${Math.round(w*y)}px`)},g=()=>{let x=e.scrollHeight-e.clientHeight,w=e.querySelector("[data-aia-option][data-aia-loading]")!==null;if(x<=Na||w){p=null,n.removeAttribute(Mo);return}let y=e.clientHeight,L=Math.round(y*Rc),R=c(e)+(y-L)/2,A=t.clientWidth-(f(e)+e.offsetWidth),F=Math.min(L,Math.max(kc,Math.round(L*y/e.scrollHeight)));p={overflow:x,travel:L-F},n.style.setProperty(Cc,`${Math.round(R)}px`),n.style.setProperty(Ac,`${L}px`),n.style.setProperty(Ic,`${Math.max(0,Math.round(A))}px`),n.style.setProperty(Mc,`${F}px`),m(x,p.travel),n.setAttribute(Mo,"")},b=()=>{if(o||a!==null||s!==null)return;let x=e.querySelector("[data-aia-option][data-aia-loading]")!==null,w=e.scrollHeight-e.clientHeight-e.scrollTop;d(!x&&w>Na)},T=()=>{if(o)return;u(),g();let x=e.getAttribute("data-aia-group")??"";if(x!==r){r=x,d(!1),a!==null&&clearTimeout(a);let w=e.querySelectorAll("[data-aia-option]").length,y=ko(e)?0:ci(w,Wc(e));a=setTimeout(()=>{a=null,b()},y);return}b()},S=()=>{o||(p&&m(p.overflow,p.travel),a===null&&(d(!1),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,b()},Do)))};e.addEventListener("scroll",S,{passive:!0});let P=x=>x.preventDefault(),v=()=>{let x=i?(Number.parseFloat(i.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0):0,w=Math.max(1,e.clientHeight-x);Nc(e,w,i,S)};n.addEventListener("mousedown",P),n.addEventListener("click",v);let h=null;return i&&typeof i.ResizeObserver=="function"&&(h=new i.ResizeObserver(()=>{u(),g(),b()}),h.observe(e)),T(),{update:T,destroy(){o||(o=!0,a!==null&&clearTimeout(a),a=null,s!==null&&clearTimeout(s),s=null,l!==null&&clearTimeout(l),l=null,n.disabled=!0,e.removeEventListener("scroll",S),n.removeEventListener("mousedown",P),n.removeEventListener("click",v),h?.disconnect(),n.removeAttribute(ke),n.removeAttribute(Mo),n.setAttribute("aria-hidden","true"))}}}var Va="cubic-bezier(0.25, 0.1, 0.25, 1)",Vc="cubic-bezier(0.32, 0.72, 0, 1)",Vo=360,Bo=280,Uo=320,$o=40,Ba="blur(2px)",Bc=160,Uc=.05,$c=/pressed/i;function Ua(){return typeof performance<"u"?performance.now():Date.now()}function Gc(t){for(let e of t.querySelectorAll("[data-aia-loading]"))if(!e.closest(`.${ee}`))return!0;return!1}function qc(t){return t===null?1:1-Math.min(1,Math.max(0,(Ua()-t)/Bc))**1.7}function Go(t){return t.hasAttribute(_t)}function Wo(t){let e=0;for(let n of Array.from(t.children))n.classList.contains(ee)||Go(n)||(e+=n.offsetHeight||0);return e}var te=new WeakMap;function Kc(t){return(Number.parseFloat(t.borderLeftWidth)||0)+(Number.parseFloat(t.borderRightWidth)||0)}function zc(t){let e=(t.ownerDocument.defaultView??window).getComputedStyle(t);return(Number.parseFloat(e.paddingLeft)||0)+(Number.parseFloat(e.paddingRight)||0)+(Number.parseFloat(e.borderLeftWidth)||0)+(Number.parseFloat(e.borderRightWidth)||0)}var Fo=new WeakMap;function jc(t,e){return!e||typeof t.animate!="function"||t.closest('[data-animations="off"]')||t.closest('[data-aia-options-style="classic"]')?!1:!(t.ownerDocument.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)")??null)?.matches}function Qc(t,e){let n=0,i="";for(let o of Array.from(t.children))o.classList.contains(ee)||(n+=1+o.getElementsByTagName("*").length,i+=`${o.textContent??""}\0`);return`${e??""}${n}${i}`}function Yc(t){let e=t.ownerDocument.createElement("div");e.className=ee,e.setAttribute("aria-hidden","true"),e.inert=!0;for(let n of Array.from(t.children))n.classList.contains(ee)||Go(n)||e.appendChild(n.cloneNode(!0));for(let n of[e,...Array.from(e.querySelectorAll("*"))]){n.removeAttribute("id"),n.removeAttribute("role"),n.removeAttribute("tabindex");for(let i of Array.from(n.classList))$c.test(i)&&n.classList.remove(i);n.tagName==="A"&&n.removeAttribute("href"),n.tagName==="BUTTON"&&(n.disabled=!0);for(let i of Array.from(n.attributes))i.name.startsWith("aria-")&&i.name!=="aria-hidden"&&n.removeAttribute(i.name)}return e}function Xc(t,e,n,i,o){for(let a of Array.from(t.children))a.classList.contains(ee)&&a.remove();let r=Array.from(t.children).filter(a=>!Go(a));i>Uc&&Zc(t,e,n,i,o);for(let a of r)Jc(a),a.animate([{opacity:0,filter:Ba},{opacity:1,filter:"blur(0px)"}],{duration:Uo,delay:$o,easing:Va,fill:"backwards"})}function Jc(t){for(let e of t.querySelectorAll("[data-aia-pill]"))if(!(e.hasAttribute("data-aia-loading")||typeof e.getAnimations!="function"))for(let n of e.getAnimations())n.cancel()}function Zc(t,e,n,i,o){let r=(t.ownerDocument.defaultView??window).getComputedStyle(t);e.style.cssText=["position:absolute","left:0",o>0?`width:${o-Kc(r)}px`:"right:0",n?"bottom:0":"top:0",`padding:${r.padding}`,"pointer-events:none","box-sizing:border-box"].join(";"),t.appendChild(e),e.animate([{opacity:i,filter:"blur(0px)"},{opacity:0,filter:Ba}],{duration:Bo*i,easing:Va,fill:"forwards"}).finished.then(()=>e.remove(),()=>e.remove())}function ui(t){let e=t[0]?.text;return e==null||e===""?null:e}function Dt(t,e,n){let i=n.visible,o=jc(t,n.enabled??!0),r=te.get(t);if(!i||!o){o||r?.glide?.cancel(),te.set(t,{height:0,width:0,key:i?e:null,signature:"",snapshot:null,glide:o?r?.glide??null:null,loadingSince:null,contentHeight:0});return}let a=Qc(t,e),s=Gc(t)?r?.loadingSince??Ua():null;if(r&&r.height>0&&r.glide&&r.signature===a){r.loadingSince=s;return}let l=ae(t),d=t.getBoundingClientRect(),c=d.height;r?.glide?.cancel();let u=t.getBoundingClientRect(),f=u.height,p=u.width||0,m=null,g=r?l?c:r.height:0,b=r?l?d.width||0:r.width:0;r&&g>0&&(e!==r.key&&r.snapshot&&Xc(t,r.snapshot,n.anchorBottom??!1,qc(r.loadingSince),b),m=$a(t,{height:g,width:b},{height:f,width:p}));let T=null;e!==null&&(T=r&&r.signature===a&&r.snapshot&&!r.snapshot.isConnected?r.snapshot:Yc(t)),te.set(t,{height:f,width:p,key:e,signature:a,snapshot:T,glide:m,loadingSince:s,contentHeight:m?Wo(t):0})}function $a(t,e,n){let i=e.width>0&&n.width>0&&Math.abs(e.width-n.width)>1;if(Math.abs(e.height-n.height)<=1&&!i)return null;let o=i?[{height:`${e.height}px`,width:`${e.width}px`},{height:`${n.height}px`,width:`${n.width}px`}]:[{height:`${e.height}px`},{height:`${n.height}px`}],r=t.animate(o,{duration:Vo,easing:Vc});i&&(t.setAttribute(Gn,String(n.width)),n.width>e.width?t.style.setProperty(Ot,`${n.width-zc(t)}px`):t.style.removeProperty(Ot),Fo.set(t,r));let a=()=>{Fo.get(t)===r&&(Fo.delete(t),t.removeAttribute(Gn),t.style.removeProperty(Ot))};return r.finished.then(()=>{a();let s=te.get(t);if(s?.glide!==r||(s.glide=null,s.height<=0))return;let l=t.getBoundingClientRect();l.height>0&&(s.height=l.height),l.width>0&&(s.width=l.width)},a),r}function ae(t){let e=te.get(t)?.glide??null;return e&&(e.playState==="running"||e.pending)?e:null}function mi(t){if(!ae(t))return null;let e=te.get(t)?.height??0;return e>0?e:null}function pi(t,e){let n=te.get(t);n&&n.height>0&&!ae(t)&&e>0&&(n.height=e)}function Ga(t,{widthChanged:e}){let n=te.get(t);if(!n||n.height<=0)return;let i=ae(t);if(!i||!e&&(t.hasAttribute("data-aia-fit")||Math.abs(Wo(t)-n.contentHeight)<=1))return;let o=t.getBoundingClientRect();i.cancel();let r=t.getBoundingClientRect();n.width=r.width||0,n.height=r.height,n.glide=$a(t,{height:o.height,width:o.width||0},{height:r.height,width:n.width}),n.contentHeight=n.glide?Wo(t):0}function fi(t){te.get(t)?.glide?.cancel(),te.delete(t)}var qo="data-aia-hug",Ye="--aia-panel-fit-width",Ko="data-aia-full-width",ed=36;function Xe(t){t.removeAttribute(qo)}function zo(t,e,{eligible:n,loading:i}){let o=t.style.getPropertyValue(Ye);td(t,e,n,i),Ga(t,{widthChanged:t.style.getPropertyValue(Ye)!==o})}function td(t,e,n,i){if(!n){t.style.removeProperty(Ye),Xe(t);return}if(i){t.style.getPropertyValue(Ye)&&t.setAttribute(qo,"");return}let o=nd(t,e);if(o==null){t.style.removeProperty(Ye);return}t.style.setProperty(Ye,`${o}px`),t.setAttribute(qo,"")}var qa=new WeakMap;function nd(t,e){if(Ke())return null;let n=B(e,".aia-grid");if(!n||t.offsetWidth===0)return null;let i=B(e,"[data-aia-pillbar]"),o=[n.style.gridTemplateColumns,i?.textContent??"",...Array.from(n.querySelectorAll("[data-aia-option]"),s=>s.textContent)].join("\0"),r=qa.get(t);if(r?.key===o)return r.width;let a=id(t,e,n);return qa.set(t,{key:o,width:a}),a}function id(t,e,n){let i=qe(n);if(!i||i.rowWidths.some(s=>s<=0))return null;let o=Math.ceil(Math.max(...i.rowWidths)),r=Math.max(1,No(n.style.gridTemplateColumns)),a=Ka(n,t,r-1)+r*(o+ed);return Math.ceil(Math.max(a,od(e,t)))}function od(t,e){let n=B(t,"[data-aia-pillbar]");if(!n)return 0;let i=n.querySelector("[data-aia-pill-scroll]")?.scrollWidth??0,o=n.querySelector("[data-aia-skip]")?.offsetWidth??0;return i+o===0?0:Ka(n,e,i>0&&o>0?1:0)+i+o}function No(t){let e=0,n=0,i=!1;for(let o of t)o==="("?e++:o===")"&&e--,e===0&&/\s/.test(o)?i=!1:i||(i=!0,n++);return n}function Ka(t,e,n){let i=0;for(let o=t;o;o=o.parentElement){let r=getComputedStyle(o);if(i+=(Number.parseFloat(r.paddingLeft)||0)+(Number.parseFloat(r.paddingRight)||0)+(Number.parseFloat(r.borderLeftWidth)||0)+(Number.parseFloat(r.borderRightWidth)||0),o===t&&(i+=n*(Number.parseFloat(r.columnGap)||0)),o===e)break}return i}var rd="[data-aia-products], [data-aia-datepicker], [data-aia-date-grid], [data-aia-time-wheel], [data-aia-location], [data-aia-see-all]";function za(t){let e=!t.hasAttribute("data-aia-has-products")&&!t.hasAttribute(Ko)&&B(t,".aia-grid [data-aia-option]")!==null&&B(t,rd)===null,n=B(t,".aia-grid [data-aia-option][data-aia-loading]")!==null;e||Xe(t),zo(t,t,{eligible:e,loading:n})}var ja="data-aia-key";function ne(t,e,n){let i=new Map;for(let a of Array.from(t.children)){let s=a.getAttribute(ja);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(ja,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 Qa(t,e){if(!e.interactive)return null;let n=e.options[ye(t)];return n?.is_tappable?n:null}var ad={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=Qa(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")&&Qa(t,e)&&e.callbacks.onHighlight(ye(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,ye(t))}};function Xa(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=cd(),t.appendChild(l),j(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}$(l,ad,{options:e,callbacks:a,interactive:s});let d=l.querySelector(".magicx-aia-datepicker-month");d&&(d.textContent=dn(o));let c=l.querySelector(".magicx-aia-datepicker-grid");c&&sd(c,e,n,i,r)}function sd(t,e,n,i,o){let r=W(new Date),a=Jn({pendingStart:o.rangeStart,highlightedIso:K(e[n]),selected:o.selectedRange,floor:o.floor});ne(t,e,{keyOf:(s,l)=>K(s)??`pad-${l}`,create:s=>ld(s),update:(s,l,d)=>{let c=K(l),u=Zn(c,{selectedIso:o.selectedIso,range:a,references:o.references}),f=d===n&&l.is_tappable;s.id=`${i}-option-${d}`,s.dataset.aiaIndex=String(d),s.setAttribute("aria-selected",String(f)),s.classList.toggle("magicx-aia-date-cell--past",ei(c,r,o.floor)),s.classList.toggle("magicx-aia-date-cell--highlighted",f),s.classList.toggle("magicx-aia-date-cell--today",c!=null&&c===r),s.classList.toggle("magicx-aia-date-cell--selected",u.selected),s.classList.toggle("magicx-aia-date-cell--in-range",u.inRange),s.classList.toggle("magicx-aia-date-cell--reference",u.reference)}})}function ld(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=pn(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 cd(){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(Ya("prev","Previous month","\u2039"),n,Ya("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of ht){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 Ya(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 dd='<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>',Ja="data-aia-location-body";function ud(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=dd;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 md(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 Za(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(Ja)!==r){for(let s of Array.from(t.children))s.hasAttribute("data-aia-location-row")||s.remove();let a=md(r,n);a&&t.appendChild(a),t.setAttribute(Ja,r)}ne(t,o,{keyOf:(a,s)=>`${s}:${a.id}`,create:a=>ud(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 se=new WeakMap,pd=0,Re=new WeakMap,fd='<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>',_e=t=>fn(t.input)===t.input;function es(t,e){let n=fn(t);if(n instanceof HTMLElement&&n!==e.input&&n!==H(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=Le(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function gd(t,e,n){if(!(!(n instanceof HTMLElement)||n===e.returnTo||t.contains(n))&&n!==H(t).body&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=Le(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function hd(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=yt(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=H(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var bd={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&Je(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function Je(t,e=!1){let n=Re.get(t),i=se.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&_e(n)&&(n.returning=!0,hd(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function yd(t){let e=Re.get(t),n=se.get(t);if(!(!e||!n||_e(e))){if(es(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!_e(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function Sd(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++pd}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=fd;let i=document.createElement("input");i.type="text",i.className="magicx-aia-location-input",i.setAttribute("data-aia-location-input",""),i.setAttribute("autocomplete","off"),i.setAttribute("autocapitalize","words"),i.setAttribute("enterkeyhint","done"),i.spellcheck=!1,i.placeholder=e.locationSearch,i.setAttribute("aria-label",e.locationSearch),n.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-location-results",o.setAttribute("data-aia-location-results",""),o.setAttribute("aria-live","polite"),t.append(n,o);let r={input:i,field:n,results:o,returnTo:null,returnRange:null,returning:!1,declined:!1,widgetFocused:!1,wasReediting:!1};return t.addEventListener("mousedown",a=>{!(a.target instanceof Node)||!n.contains(a.target)||(a.stopPropagation(),es(t,r),se.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>se.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",a=>{gd(t,r,a.relatedTarget),se.get(t)?.callbacks.onLocationFocusChange(!0)}),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,se.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",a=>{let s=se.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;Je(t,!0),s.callbacks.onLocationCommit();return;case"Escape":a.preventDefault(),a.stopPropagation(),r.declined=!0,Je(t);return;case"Backspace":if(i.value!=="")return;a.preventDefault(),r.declined=!0,Je(t);return}}),Re.set(t,r),r}function ts(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=Re.get(e);n&&(_e(n)&&Je(e),n.declined=!1,n.input.tabIndex=-1)}}function ns(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=Re.get(r);l&&_e(l)&&Je(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let a=Re.get(r)??Sd(r,n);a.input.tabIndex=0,se.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),$(a.results,bd,se.get(r)),a.input.value!==e.query&&!_e(a)&&(a.input.value=e.query);let s=l=>`${r?.id}-row-${l}`;if(Za(a.results,e,n,s),e.highlighted>=0&&e.highlighted<e.places.length?a.input.setAttribute("aria-activedescendant",s(e.highlighted)):a.input.removeAttribute("aria-activedescendant"),o.inputFocused){let l=o.reediting??!1;l&&!a.wasReediting&&(a.declined=!1),a.wasReediting=l}if(a.widgetFocused=o.inputFocused??!1,o.inputFocused){if(o.reediting&&!a.declined&&o.interactive!==!1&&!_e(a)){let l=r;queueMicrotask(()=>{l.isConnected&&!Re.get(l)?.declined&&yd(l)})}}else{let l=a;setTimeout(()=>{if(l.widgetFocused)return;let d=l.returnTo;d&&fn(d)===d||(l.declined=!1)},0)}}var Td={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},is=[125,69];function os(t,e){return e?1:t===0?.7:t===1?.4:.2}function gi(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)),$(s,Td,{onSelectPill:i,loading:r}),r&&e.length===0){s.setAttribute("data-aia-pill-list-loading",""),s.innerHTML="";for(let l=0;l<is.length;l++){let d=is[l],c=document.createElement("span");c.setAttribute("data-aia-pill-skeleton",""),c.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,c.style.width=`${d}px`,c.style.setProperty("--aia-pill-opacity",String(os(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();ne(s,e,{keyOf:l=>`${l.type?.kind??""}|${Ee(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"),Ee(l)){d.setAttribute("data-aia-smart-suggestion",C(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=nn,d.append(c,u)}else d.textContent=l.text;return d.disabled=!0,d},update:(l,d,c)=>{let u=l,f=a&&c===n&&!r,p=["magicx-aia-pill"];o&&p.push("magicx-aia-pill--rounded"),r&&p.push("magicx-aia-pill--skeleton"),u.className=p.join(" "),u.style.width="",u.style.setProperty("--aia-pill-opacity",String(os(c,f))),u.dataset.aiaPillIndex=String(c),u.toggleAttribute("data-aia-pill-active",c===n),r?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),j(s);for(let l of s.querySelectorAll("[data-aia-pill]"))l.disabled=r}function jo(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var rs=32;function Qo(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 hi(t){let e=n=>{let i=Qo(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var as=Intl.Segmenter,ss=as?new as(void 0,{granularity:"grapheme"}):null;function bi(t){let e=t.trim().normalize("NFC").toUpperCase();if(ss)for(let n of ss.segment(e))return n.segment;return Array.from(e)[0]??"?"}var yi=120,ls=360;function xd(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 Yo(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=xd(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 Xo(t,e){let n=Yo(t,e);return n===t?[t]:[n,t]}function Si(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 Ht(t){let e=t?.trim();return e?Xo(e,360):[]}function cs(t){return Ht(t)[0]}var Ti=new WeakMap,Zo=new WeakMap,us=new WeakMap;function ms(t,e,n,i,o,r="row",a="image",s=k(),l,d=!0,c=null){let u=t.querySelector(".magicx-aia-products");if(e.length===0){u?.remove();return}if(!u){u=document.createElement("section"),u.className="magicx-aia-products",u.setAttribute("data-aia-products",""),u.setAttribute("role","group"),u.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 g=document.createElement("div");g.className="magicx-aia-products-row",g.setAttribute("data-aia-products-row",""),hi(g),u.append(m,g),t.appendChild(u)}u.setAttribute("data-aia-products-layout",r);let f=u.querySelector(".magicx-aia-products-label");f&&f.textContent!==s.products&&(f.textContent=s.products);let p=u.querySelector(".magicx-aia-products-row");if(p){ne(p,e,{keyOf:m=>Ld(m,!!l),create:m=>Cd(m,i,o,a,s,l),update:(m,g,b)=>{Ti.set(m,g),vd(m,d?g.vendor:void 0),Ed(m,g.price,g.compareAtPrice),m.id=`${n}-product-${b}`,m.dataset.aiaIndex=String(b),us.get(m)?.(a),Qe(m,"data-aia-product-state",g.id===c);let T=m.querySelector(".magicx-aia-product-badge");T&&T.textContent!==s.soldOut&&(T.textContent=s.soldOut);let S=m.querySelector(".magicx-aia-product-cart");S&&S.setAttribute("aria-label",ps(g,s))}}),j(p);for(let m of p.querySelectorAll("[data-aia-product]")){let g=Zo.get(m);g&&(Zo.delete(m),g())}}}function er(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)Me(i)||(i.tabIndex=e?0:-1)}function vd(t,e){let n=t.querySelector(".magicx-aia-product-vendor");if(!e){n?.remove();return}n||(n=document.createElement("span"),n.className="magicx-aia-product-vendor",t.querySelector(".magicx-aia-product-title")?.before(n)),n.textContent!==e&&(n.textContent=e)}function Ed(t,e,n){let i=t.querySelector(".magicx-aia-product-price");if(!e){i?.remove();return}i||(i=document.createElement("span"),i.className="magicx-aia-product-price",i.append(document.createTextNode("")),t.querySelector(".magicx-aia-product-title")?.after(i));let o=i.firstChild;o.data!==e&&(o.data=e);let r=i.querySelector(".magicx-aia-product-compare-at");if(!n){r?.remove();return}r||(r=document.createElement("s"),r.className="magicx-aia-product-compare-at",i.append(r)),r.textContent!==n&&(r.textContent=n)}function ds(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 ps(t,e){return`${e.addToCart}: ${t.title}`}var Jo="http://www.w3.org/2000/svg";function wd(){let t=document.createElementNS(Jo,"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(Jo,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(Jo,"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 Pd(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",ps(e,o)),r.tabIndex=0,r.appendChild(wd());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(Ti.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 Ld(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 Cd(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("data-aia-product-media",""),s.setAttribute("aria-hidden","true");let l=Ht(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=bi(t.title))};if(us.set(a,g=>{g!==i&&(i=g,c||u())}),d){let g=document.createElement("img"),b=0;g.onload=()=>{s.setAttribute("data-aia-image-loaded",""),ds(a,Si(g.naturalWidth,g.naturalHeight))},g.onerror=()=>{let T=l[++b];if(T){g.src=T;return}c=!1,ds(a,null),u()},g.className="magicx-aia-product-image",g.src=d,g.alt="",g.loading="lazy",g.decoding="async",s.appendChild(g)}else u();a.appendChild(s);let f=document.createElement("span");f.className="magicx-aia-product-body";let p=document.createElement("span");if(p.className="magicx-aia-product-title",p.textContent=t.title,f.appendChild(p),t.available===!1){a.setAttribute("data-aia-product-sold-out","");let g=document.createElement("span");g.className="magicx-aia-product-badge",g.textContent=o.soldOut,f.appendChild(g)}a.appendChild(f);let m=r&&t.available!==!1?Pd(a,t,r,n,o):null;return m&&(a.setAttribute("data-aia-product-has-cart",""),a.appendChild(m.el)),Zo.set(a,()=>{m?.arm(),t.url&&(a.href=t.url),a.addEventListener("click",g=>{g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||g.button!==0||(g.preventDefault(),e(Ti.get(a)??t))})}),a.addEventListener("keydown",g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),e(Ti.get(a)??t))}),a.addEventListener("focus",()=>n(!0)),a.addEventListener("blur",g=>{g.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),a}var fs=10,gs=44;function xi(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 hs="http://www.w3.org/2000/svg",Ad=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function Id(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 Od=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],Md=/^[a-zA-Z0-9#.,%\s()-]+$/;function kd(t){let e=[];for(let n of Od){let i=t.getAttribute(n);i===null||!Md.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function bs(t){for(let e of Array.from(t.attributes))Id(e.name,e.value)&&t.removeAttribute(e.name);kd(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!Ad.has(n.localName)||n.namespaceURI!==hs?n.remove():bs(n)}else e.remove()}function ie(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!==hs||e.getElementsByTagName("parsererror").length>0?null:(bs(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function Nt(t){return t.text}function Se(t){return Ze(t)[0]??null}function Ze(t){let e=Rd(t);return e?Xo(e,120):[]}function Rd(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 et(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var tr={one:"item",other:"items"};function ys(t,e=tr){let n=et(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function nr(t){return Se(t.image_url)!==null}var vi=new Map;function _d(t){let e=t.icon_svg;if(!e)return!1;let n=vi.get(e);return n===void 0&&(n=ie(e)!==null,vi.size>=256&&vi.clear(),vi.set(e,n)),n}function Ei(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&nr(i)||e&&_d(i))}var Ss=new WeakMap;function Dd(t,e,n){let i=e.length,o=Ke(),r=Ss.get(t),a=n&&r&&qn(r.options,e)?r.plan:null,s=!a&&!n&&Un(i,o)?qe(t):null,l=a??$n(i,o,s?.rowWidths??null,s?.gridWidth??null);return n||Ss.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 Ts(t,e){if(e.loading||!e.interactive)return null;let n=e.options[ye(t)];return n?.is_tappable?n:null}var Hd={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=Ts(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!xi(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)=>{Ts(t,e)&&e.onHighlight(ye(t))},onLeave:(t,e)=>e.onHighlight(-1,ye(t))};function xs(t,e,n,i,o,r,a,s="",l="below",d=!0,c=!0,u=!0,f=!0,p){let m=t.querySelector(".aia-grid");if(e.length===0){m?.remove();return}m||(m=document.createElement("div"),m.className="aia-grid magicx-aia-grid",m.setAttribute("data-scroll",""),m.style.setProperty("--aia-grid-min","250px"),m.style.setProperty("--aia-grid-max","1fr"),m.style.setProperty("--aia-grid-gap","0"),t.appendChild(m)),$(m,Hd,{options:e,onSelect:i,onHighlight:o,loading:a,interactive:f});let g=m.dataset.aiaGroup!==s;m.dataset.aiaGroup=s;let b=Ei(e,d,c);Nd(m,e,n,r,a,{showIcons:d&&b,showImages:c&&b,showCounts:u,picked:p});let T=Dd(m,e,a);Fd(m,e.length,T,a,l),g&&(m.scrollTop=0)}function Nd(t,e,n,i,o,r){let a=o?"1":"0",s=t.dataset.aiaGroup??"",{showIcons:l,showImages:d,showCounts:c}=r,u=l?m=>m.icon??m.icon_svg??"":()=>"",f=d?m=>`${Se(m.image_url)??""}${(m.imageCollage??[]).join("")}`:()=>"",p=c?m=>et(m.item_count)??"":()=>"";ne(t,e,{keyOf:m=>`${m.text}\0${m.parameter??""}\0${m.parameterLabel??""}\0${u(m)}\0${f(m)}\0${p(m)}\0${a}\0${s}`,create:(m,g)=>{let b=Wd(m,o,r);return o||(b.dataset.aiaEntering=""),b},update:(m,g,b)=>{if(ir.get(m)!==(g.matchedText??"")){let P=m.querySelector(".magicx-aia-option-text");P&&vs(P,g),ir.set(m,g.matchedText??"")}let T=b===n&&!o;m.id=`${i}-option-${b}`,m.dataset.aiaIndex=String(b),m.setAttribute("aria-selected",String(r.picked?r.picked.includes(g.text):T));let S=m.querySelector(".magicx-aia-checkbox");r.picked&&g.is_tappable?(S||(S=document.createElement("span"),S.className="magicx-aia-checkbox",S.setAttribute("aria-hidden","true"),m.querySelector(".magicx-aia-option-content")?.prepend(S)),S.dataset.checked=String(r.picked.includes(g.text)),S.textContent=r.picked.includes(g.text)?"\u2713":""):S?.remove(),m.classList.toggle("magicx-aia-option--highlighted",T),m.classList.toggle("magicx-aia-option--live-match",!!g.liveMatch&&!o)}})}function Fd(t,e,n,i,o){for(let r of t.querySelectorAll("[data-aia-entering]")){if(!i){let a=Number.parseInt(r.dataset.aiaIndex??"-1",10);a>=0&&r.style.setProperty(si,`${li(a,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var ir=new WeakMap;function vs(t,e){if(t.replaceChildren(),e.matchedText)for(let n of jn(Nt(e),e.matchedText))if(n.bold){let i=document.createElement("strong");i.className="magicx-aia-option-match",n.partial&&i.setAttribute("data-aia-match-partial",""),i.textContent=n.text,t.appendChild(i)}else t.appendChild(document.createTextNode(n.text));else t.appendChild(document.createTextNode(Nt(e)));if(e.parameterLabel){t.appendChild(document.createTextNode(" "));let n=document.createElement("span");n.className="magicx-aia-option-parameter",n.textContent=e.parameterLabel,t.appendChild(n)}}function Wd(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?Ze(t.image_url):[],d=l[0];if(d){let p=document.createElement("span");p.className="magicx-aia-option-image",p.setAttribute("aria-hidden","true");let m=(t.imageCollage??[]).map(g=>Ze(g)).filter(g=>g.length>0);m.length>1&&p.setAttribute("data-aia-collage",String(m.length));for(let g of m.length>1?m:[l]){let b=document.createElement("img");b.setAttribute("alt",""),b.setAttribute("loading","lazy"),b.setAttribute("decoding","async"),b.setAttribute("referrerpolicy","no-referrer"),b.setAttribute("draggable","false");let T=0;b.onload=()=>p.setAttribute("data-aia-image-loaded",""),b.onerror=()=>{let S=g[++T];S?b.src=S:b.hidden=!0},b.src=g[0],p.appendChild(b)}s.appendChild(p),r.dataset.aiaImage=""}let c=!d&&n&&t.icon_svg?ie(t.icon_svg):null;if(c){let p=document.createElement("span");p.className="magicx-aia-option-icon",p.setAttribute("aria-hidden","true"),p.innerHTML=c,s.appendChild(p),t.icon&&(r.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",vs(u,t),ir.set(r,t.matchedText??""),s.appendChild(u),t.tag){let p=document.createElement("span");p.className="magicx-aia-option-tag",p.textContent=t.tag,s.appendChild(p)}let f=o?et(t.item_count):null;if(f!==null){let p=document.createElement("span");p.className="magicx-aia-option-count",p.textContent=f,s.appendChild(p),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(s),r}var Vd=120,Bd={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(wt(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},ws=new WeakMap,Es=new WeakMap;function Ps(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=Gd(),t.appendChild(r),j(r);let d=r.querySelector("[data-aia-time-done]");d&&(d.disabled=!1)}let a={view:e,callbacks:i,interactive:o};ws.set(r,a),$(r,Bd,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=Tt(e.minutes));for(let d of vt){let c=r.querySelector(`[data-aia-time-column="${d}"]`);c&&Ud(c,d,e.minutes)}}function Ud(t,e,n){let i=Et(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=wi(t);if(o.settle)return;let r=i*xt;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function wi(t){let e=Es.get(t);return e||(e={syncedTop:null,settle:null},Es.set(t,e)),e}function $d(t,e,n){let i=wi(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(()=>Ls(t,e,n),Vd)}function Ls(t,e,n){let i=wi(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=ws.get(t);if(!o||!o.interactive)return;let r=On(n,e.scrollTop);r!==Et(n,o.view.minutes)&&o.callbacks.onTimeChange(wt(n,o.view.minutes,r))}function Gd(){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 vt){if(r==="minute"){let a=document.createElement("span");a.className="magicx-aia-time-wheel-separator",a.textContent=":",n.appendChild(a)}n.appendChild(qd(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 qd(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),In(e).forEach((i,o)=>{let r=document.createElement("div");r.className="magicx-aia-time-wheel-row",r.setAttribute("data-aia-time-row",""),r.dataset.aiaTimeColumn=e,r.dataset.aiaIndex=String(o),r.textContent=i.label,n.appendChild(r)}),n.addEventListener("scroll",()=>$d(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{wi(n).settle&&Ls(t,n,e)}),n}var De="data-aia-fit",Ft="--aia-dropdown-fit-height",Cs=8,Kd=160;function Pi({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,a=null,s=null,l=null,d=!1,c=()=>{t.removeAttribute(De),t.style.removeProperty(Ft)},u=()=>{if(ae(t)){d=!0;return}d=!1,pi(t,t.getBoundingClientRect().height)},f=S=>`${r}|${(S??t).scrollHeight}|${t.offsetWidth}`,p=S=>s?.key===f(S)?s.height:null,m=S=>{let P=f(S);if(s?.key===P)return s.height;let v=S?.scrollTop??0;t.removeAttribute(De);let h=t.offsetHeight;return t.setAttribute(De,""),S&&v&&(S.scrollTop=v),s={key:P,height:h},h},g=()=>{if(i)return;if(!e()){o=!1;return}let S=ae(t),P=S?mi(t):null;S&&l!==S&&(l=S,S.finished.then(b,b)),!S&&d&&u(),o||(o=!0,c());let v=t.hasAttribute(De),h=B(t,".aia-grid")?.getAttribute("data-aia-group")??null,x=h!==r;r=h;let w=jd(t,n);if(w===null)return;let y=zd(t);if(v){let A=S?p(y):m(y);if(A!==null&&A<=w){c(),u();return}}else if((P??t.offsetHeight)<=w)return;let L=`${Math.max(Kd,Math.floor(w))}px`,R=t.style.getPropertyValue(Ft)!==L;R&&t.style.setProperty(Ft,L),v?x&&y&&(y.scrollTop=0):t.setAttribute(De,""),(R||!v)&&u()},b=()=>{i||a!==null||!n||(a=n.requestAnimationFrame(()=>{a=null,g()}))},T=n?.visualViewport??null;return T?.addEventListener("resize",b),T?.addEventListener("scroll",b),n?.addEventListener("resize",b),n?.addEventListener("scroll",b,{capture:!0,passive:!0}),g(),{update:g,destroy(){i||(i=!0,a!==null&&n?.cancelAnimationFrame(a),T?.removeEventListener("resize",b),T?.removeEventListener("scroll",b),n?.removeEventListener("resize",b),n?.removeEventListener("scroll",b,{capture:!0}))}}}function zd(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function jd(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-Cs:i+o-s-Cs}var Qd=[159,119,164];function Ai(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()),oi(e),e}var Li=new WeakMap;function Yd(t,e,n){let i=Li.get(t);if(i||(i={button:Wa(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),Li.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=di({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var Ci=new WeakMap;function As(t){let e=Ci.get(t);if(e){e.update();return}Ci.set(t,Pi({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function or(t){Ci.get(t)?.destroy(),Ci.delete(t),fi(t);let e=Li.get(t);e&&(e.controller?.destroy(),Li.delete(t))}function Ii(t,e){let n=e.strings??k(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:a,showPills:s,isActivePillSelected:l,onSelect:d,onHighlight:c,onPillClick:u,onSkip:f}=e,p=tn(e.pills,n.keepTyping),m=on(p),g=s&&p.length>0,b=i.length>0,T=e.products.length>0,S=e.formatType==="time"&&e.timeView!=null,P=e.formatType==="location"&&e.locationView!=null,v=r&&(b||g||a||T||S||P);if(v?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"),!v){er(t,!1),ts(t),As(t),Dt(t,null,{visible:!1});return}T?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute(Ko,e.fullWidth===!0),Xe(t),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let h=t.querySelector(".aia-stack");h||(h=document.createElement("div"),h.className="aia-stack",h.style.setProperty("--aia-stack-space","8px"),t.appendChild(h));let x=e.showSkipButton&&m&&!e.isInputEmpty,w=g||a&&s||x,y=h.querySelector(".magicx-aia-pill-bar");if(w){y||(y=document.createElement("div"),y.className="magicx-aia-pill-bar aia-cluster",y.setAttribute("data-nowrap",""),y.setAttribute("data-aia-pillbar",""),h.insertBefore(y,h.firstChild));let oe=g||a&&s,E=y.querySelector(".magicx-aia-pill-scroll");oe?(E||(E=document.createElement("span"),E.className="magicx-aia-pill-scroll",E.setAttribute("data-aia-pill-scroll",""),y.insertBefore(E,y.firstChild)),gi(E,p,0,u,!0,a,l)):E&&E.remove(),Zd(y,x,a||e.skipDisabled,p[0],f,n)}else y&&y.remove();let L=e.suggestions[0],R=L?`${L.parameter} ${L.text}`:"",A=_(e.formatType),F=A&&!a;xs(h,A?[]:i,o,d,c,e.listboxId,a,R,e.optionsPosition??"below",e.showOptionIcons??!0,e.showOptionImages??!0,e.showOptionCounts??!0,!e.skipDisabled,e.multiSelectView?.picked),t.setAttribute("aria-multiselectable",String(!!e.multiSelectView)),ru(h,!!e.multiSelectView,e.skipDisabled||a,e.onMultiSelectCommit,n.done),Yd(t,h.querySelector(".aia-grid"),n),Xa(h,F?i:[],o,e.listboxId,F?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart,floor:ti(e.formatType,e.dateRangeStart),references:e.dateReferences??[]},{onSelect:d,onHighlight:c,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),Ps(h,e.formatType==="time"&&!a?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),ns(h,e.formatType==="location"&&!a?e.locationView:null,n,{onLocationQuery:e.onLocationQuery,onLocationMove:e.onLocationMove,onLocationCommit:e.onLocationCommit,onLocationFocusChange:e.onLocationFocusChange},{interactive:!e.skipDisabled,inputFocused:e.isFocused??!1,reediting:e.isReediting??!1});let I=h.querySelector(".magicx-aia-skeleton-bars");if(a&&(!b||D(e.formatType))){if(!I){I=document.createElement("div"),I.className="magicx-aia-skeleton-bars",I.setAttribute("data-aia-skeleton-bars","");for(let oe of Qd){let E=document.createElement("span");E.className="magicx-aia-skeleton-bar",E.style.width=`${oe}px`,I.appendChild(E)}h.appendChild(I)}}else I&&I.remove();ms(h,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart,e.showProductVendor??!0,e.busyProductId??null),er(t,!a),iu(h,e.onSeeAllResults,n.seeAllResults,e.seeAllBusy===!0);let G=h.querySelector(".magicx-aia-footer")??tu(n),le=o>=0&&!!i[o]?.is_tappable;eu(G,ii(le,e.isInputEmpty,n)),G.isConnected||h.appendChild(G),Xd(h,[".magicx-aia-pill-bar",".aia-grid","[data-aia-multi-actions]",".magicx-aia-datepicker",".magicx-aia-time-wheel","[data-aia-location]",".magicx-aia-skeleton-bars",".magicx-aia-products","[data-aia-see-all]",".magicx-aia-footer"]),ai(h,h.querySelector(".magicx-aia-multi-done")),zo(t,h,{eligible:b&&!T&&!A&&!S&&!P&&!e.onSeeAllResults&&!e.fullWidth,loading:a}),As(t),Dt(t,ui(s?p:[]),{visible:!0,anchorBottom:e.optionsPosition==="above"})}function Xd(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 Jd={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function Zd(t,e,n,i,o,r){$(t,Jd,{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),j(a)),a.textContent!==r.skip&&(a.textContent=r.skip),a.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),a.disabled=n}function eu(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 tu(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=ni(),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 nu={itemSelector:".magicx-aia-see-all",onClick:(t,e,n)=>{e.submit&&(n.stopPropagation(),e.submit())}};function iu(t,e,n,i){let o=t.querySelector(":scope > [data-aia-see-all]");if(!e){o?.remove();return}if(!o){o=document.createElement("div"),o.className="magicx-aia-see-all-row",o.dataset.aiaSeeAll="";let a=document.createElement("button");a.type="button",a.tabIndex=-1,a.className="magicx-aia-see-all",a.disabled=!0,o.appendChild(a),t.appendChild(o),j(a)}$(o,nu,{submit:e});let r=o.querySelector("button");r&&(r.textContent!==n&&(r.textContent=n),r.disabled=!1,Qe(r,"data-aia-see-all-state",i))}var ou={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function ru(t,e,n,i,o){let r=t.querySelector("[data-aia-multi-actions]");if(!e){r?.remove();return}if(!r){r=document.createElement("div"),r.dataset.aiaMultiActions="";let s=document.createElement("button");s.type="button",s.tabIndex=-1,s.className="magicx-aia-multi-done",s.setAttribute("data-aia-multi-done",""),s.disabled=!0,r.appendChild(s),t.appendChild(r),j(s)}$(r,ou,{commit:i,disabled:n});let a=r.querySelector("button");a&&(a.textContent=o,a.disabled=n)}function tt(t,e,n){if(e)return[e];if(!t)return n;let i=n.filter(o=>o.parameter!==t.parameter||o.text!==t.text);return[t,...i]}function Is(t,e){let n=Ai(e.listboxId);return t.appendChild(n),{dropdown:n}}function rr(t,e,n){let i=je(e);Ii(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:tt(e.dropdownSuggestion,null,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",showProductVendor:n.showProductVendor??!0,onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:i.selectedIso,selectedDateRange:i.selectedRange,dateRangeStart:i.rangeStart,dateReferences:i.references,timeView:e.timeView,multiSelectView:e.dropdownMultiSelect,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:n.selectOption,onHighlight:(o,r)=>{r!==void 0&&n.store.get().activeDropdownIndex!==r||n.store.set({activeDropdownIndex:o})},onPillClick:n.setActivePill,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,busyProductId:e.selectingProductId,onProductSelect:n.selectProduct,onProductFocusChange:o=>n.store.set({isFocused:o})})}var au="[data-aia-chip-remove]";function ar(t,e){let n=e;if(!n||n.nodeType===void 0)return null;let o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(au)??null;return o&&t.contains(o)?o:null}function Oi(t,e){let n=null,i=d=>{n=null;let c=d;if(c.button)return;let u=ar(t,d.target);if(!u)return;d.preventDefault(),d.stopPropagation();let f=u.dataset.aiaChipRemove,p=c.pointerType==="touch"||c.pointerType==="pen";n={id:f,x:c.clientX,y:c.clientY,pending:p},!p&&f&&e(f)},o=d=>{if(!n?.pending)return;n.pending=!1;let c=d;if(Math.hypot(c.clientX-n.x,c.clientY-n.y)>10)return;let f=t.getRootNode().elementFromPoint?.(c.clientX,c.clientY)??d.target,p=ar(t,f)?.dataset.aiaChipRemove;p&&p===n.id&&e(p)},r=()=>{n&&(n.pending=!1)},a=d=>{!n&&!ar(t,d.target)||(d.cancelable&&d.preventDefault(),d.type==="click"&&(d.stopImmediatePropagation(),n=null))},s={capture:!0},l={capture:!0,passive:!1};return t.addEventListener("pointerdown",i,s),t.addEventListener("pointerup",o,s),t.addEventListener("pointercancel",r,s),t.addEventListener("touchstart",a,l),t.addEventListener("mousedown",a,s),t.addEventListener("click",a,s),()=>{t.removeEventListener("pointerdown",i,s),t.removeEventListener("pointerup",o,s),t.removeEventListener("pointercancel",r,s),t.removeEventListener("touchstart",a,l),t.removeEventListener("mousedown",a,s),t.removeEventListener("click",a,s)}}var Os=340;function Mi(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let c=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let u=t.getBoundingClientRect().height;if(u!==0){if(c===0||Math.abs(u-c)<.5){t.style.height=`${u}px`;return}t.style.height=`${c}px`,t.getBoundingClientRect(),t.style.height=`${u}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(c=>{for(let f of c)if(f.target!==t){n();return}let u=t.getBoundingClientRect().width;Math.abs(u-i)<.5||(i=u,n())}):null,r=()=>{for(let c of Array.from(t.children))o?.observe(c)},a=0,s=()=>{r(),n(),e.clearTimeout(a),a=e.setTimeout(n,340)},l=new e.MutationObserver(s);l.observe(t,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["data-placeholder","data-aia-empty"]}),o?.observe(t),r(),t.addEventListener("load",s,!0);let d=!1;return t.ownerDocument.fonts?.ready.then(()=>{d||n()}),n(),()=>{d=!0,t.removeEventListener("load",s,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(a),t.style.height=""}}var dr=2600,su=3,Di="data-aia-hint",cr="magicx-aia-hint",ur="data-aia-hint-el",lu={position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--aia-hint-color, #999)",userSelect:"none"},cu=280,du=320,uu=380,sr="cubic-bezier(0.25, 0.1, 0.25, 1)",Ms=new Set(["a","an","the","some","my"]),_i=new WeakMap;function mu(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function ks(t,e){let n=t.text.trim(),i=e.trim(),o=[];i&&n.toLowerCase().startsWith(`${i.toLowerCase()} `)&&(n=n.slice(i.length+1).trim());let r=i?i.split(/\s+/):[],a=null;r.length>1&&Ms.has(r[r.length-1].toLowerCase())&&(a=r.pop()??null);let s=r.join(" ");s&&o.push({key:`w:${s.toLowerCase()}`,text:s,icon:null});let l=null,[d,...c]=n.split(/\s+/);c.length&&d&&Ms.has(d.toLowerCase())&&(l=d,n=c.join(" "));let u=l??a;u&&o.push({key:`w:${u.toLowerCase()}`,text:u,icon:null});let f=t.icon_svg?ie(t.icon_svg):null;return o.push({key:`c:${f??""}:${n}`,text:n,icon:f}),o}function pu(t,e){let n=t.createElement("span");if(n.className=`${cr}__word`,n.dataset.key=e.key,n.style.display="inline-block",e.icon){let i=t.createElement("span");i.className=`${cr}__icon`,Object.assign(i.style,{display:"inline-flex",width:"1em",height:"1em",marginRight:"0.25em",verticalAlign:"-0.125em",opacity:"var(--aia-hint-icon-opacity, 0.7)"}),i.innerHTML=e.icon;let o=i.querySelector("svg");o&&(o.style.width="100%",o.style.height="100%"),n.appendChild(i)}return n.appendChild(t.createTextNode(e.text)),n}function lr(t,e,n){return typeof t.animate=="function"?t.animate(e,n):null}function ki(t,e){let n=t.ownerDocument?.defaultView;if(!n)return;let i=n.getComputedStyle(t),o=c=>Number.parseFloat(c)||0,r=t.offsetLeft+o(i.borderLeftWidth)+o(i.paddingLeft),a=t.offsetTop+o(i.borderTopWidth)+o(i.paddingTop),s=t.clientWidth-o(i.paddingLeft)-o(i.paddingRight),l=t.offsetParent instanceof HTMLElement?t.offsetParent.clientWidth-r:0,d=Math.max(s,l);e.style.left=`${r}px`,e.style.top=`${a}px`,d>0&&(e.style.maxWidth=`${d}px`),e.style.font=i.font,e.style.lineHeight=i.lineHeight,e.style.letterSpacing=i.letterSpacing,e.style.fontWeight="var(--aia-hint-font-weight, 300)"}function Rs(t,e,n,i){let{el:o}=t,r=o.ownerDocument,a=new Map;for(let p of Array.from(o.children))p.dataset.leaving===void 0&&p.dataset.key&&a.set(p.dataset.key,p);let s=new Map;for(let[p,m]of a)s.set(p,m.offsetLeft);let l=new Set(e.map(p=>p.key));for(let[p,m]of a){if(l.has(p))continue;if(!n){m.remove();continue}m.dataset.leaving="",m.style.position="absolute",m.style.left=`${s.get(p)??0}px`,m.style.top=`${m.offsetTop}px`;let g=lr(m,[{opacity:1,filter:"blur(0)"},{opacity:0,filter:"blur(2px)"}],{duration:cu,easing:sr,fill:"forwards"});g?g.onfinish=()=>m.remove():m.remove()}let d=Array.from(o.children).filter(p=>p.dataset.leaving!==void 0),c=[];if(e.forEach((p,m)=>{m>0&&c.push(r.createTextNode(" ")),c.push(a.get(p.key)??pu(r,p))}),o.replaceChildren(...c,...d),!n)return;let u=new Map;for(let p of c)p instanceof HTMLElement&&p.dataset.key&&u.set(p.dataset.key,p);let f=0;for(let p of e){let m=u.get(p.key);if(m)if(!a.has(p.key))lr(m,[{opacity:0,filter:"blur(2px)"},{opacity:1,filter:"blur(0)"}],{duration:du,delay:i?80*f++:180+60*f++,easing:sr,fill:"backwards"});else{let b=(s.get(p.key)??m.offsetLeft)-m.offsetLeft;Math.abs(b)>.5&&lr(m,[{transform:`translateX(${b}px)`},{transform:"none"}],{duration:uu,easing:sr})}}}function Ri(t){let e=_i.get(t);e&&(e.timer!==null&&clearInterval(e.timer),e.resize?.disconnect(),e.el.remove(),_i.delete(t),t.removeAttribute(Di),t.removeAttribute("aria-placeholder"))}function _s(t,e,n,i){let o=i.filter(m=>m.text.trim()!=="").slice(0,su),r=t.parentElement;if(!e||o.length<2||!r){Ri(t);return}let a=`${n}\0${o.map(m=>`${m.text}${m.icon_svg??""}`).join("\0")}`,s=_i.get(t);if(s&&s.key===a&&s.el.isConnected){ki(t,s.el);return}Ri(t);let l=t.ownerDocument,d=l.createElement("span");d.className=cr,d.setAttribute(ur,""),d.setAttribute("aria-hidden","true"),Object.assign(d.style,lu),r.insertBefore(d,t),t.setAttribute(Di,""),n.trim()&&t.setAttribute("aria-placeholder",n.trim()),ki(t,d);let c=l.defaultView,u=c?.ResizeObserver?new c.ResizeObserver(()=>{d.isConnected&&ki(t,d)}):null;u?.observe(r);let f=mu(t),p={key:a,lead:n,options:o,index:0,el:d,timer:null,resize:u};_i.set(t,p),Rs(p,ks(o[0],n),!f,!0),!f&&(p.timer=setInterval(()=>{if(!t.isConnected||!d.isConnected){Ri(t);return}t.ownerDocument?.hidden||(p.index=(p.index+1)%p.options.length,ki(t,d),Rs(p,ks(p.options[p.index],p.lead),!0,!1))},dr))}function Hi(t){Ri(t)}function Ni(t){return(t.find(n=>n.type?.kind!=="traditional_autocomplete")?.options??[]).filter(n=>n.is_tappable!==!1).map(n=>({text:n.text,icon_svg:n.icon_svg}))}var fu=6,gu=.3;function Ds(t){return t<=0?"0px":`${(-Math.min(gu,2*fu/t)).toFixed(3)}px`}var Hs=new Map;function hu(t,e,n){let i=Hs.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`;Hs.set(e,s),t.style.setProperty("--aia-chip-image-fit",s)},o.src=e}function Fi(t){let{input:e,segments:n,newParamId:i,editingParamId:o,placeholderText:r}=t,a=t.showChipIcons??!0,s=t.showChipImages??!0,l=t.showChipRemove??!1,d=n.length===0;e.dataset.aiaEmpty=d?"true":"false",La(e,d?r:""),_s(e,d,r,t.hintOptions??[]);let c=n.map(v=>v.type==="completed"?`${v.type}:${v.value}${a?v.param.icon??v.param.icon_svg??"":""}${s?Se(v.param.image_url)??"":""}${l?"x":""}`:v.type==="identified"?`${v.type}:${v.value}${v.param.id}${l?"x":""}`:`${v.type}:${v.value}`).join("\0"),u=e.dataset.segKey??"",f=e.dataset.newParamId??"",p=e.dataset.editingParamId??"";if(c===u&&(i??"")===f&&(o??"")===p)return;if(c===u){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let v of e.querySelectorAll("strong[data-param-id]")){let h=v.dataset.paramId,x=v.dataset.seg==="completed"&&h===i;v.classList.toggle("magicx-aia-shimmer-revealed",x),v.classList.toggle("magicx-aia-shimmer-sweep",x),v.classList.toggle("magicx-aia-segment--editing",h===o)}return}let m=e.getAttribute("data-aia-composing")==="true"?bu(e,n):null;if(m==="unsafe")return;let g=na(e),b=g&&!m?z(e):null;e.dataset.segKey=c,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let T=H(e),S=T.createDocumentFragment(),P=0;for(let v of n)if(P+=v.value.length,v.type==="completed"){let h=T.createElement("strong");h.dataset.seg="completed",h.dataset.paramId=v.param.id;let x=v.param.id===i,w=v.param.id===o,y=["magicx-aia-segment","magicx-aia-segment--completed"];x&&y.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),w&&y.push("magicx-aia-segment--editing"),h.className=y.join(" "),h.style.letterSpacing=Ds(v.value.length);let L=s?Se(v.param.image_url):null;if(L){let A=T.createElement("span");A.className="magicx-aia-segment-image",A.setAttribute("contenteditable","false"),A.setAttribute("aria-hidden","true"),A.style.setProperty("--aia-chip-image",`url("${L}")`),hu(A,L,T),h.appendChild(A),h.dataset.aiaImage=""}let R=!L&&a&&v.param.icon_svg?ie(v.param.icon_svg):null;if(R){let A=T.createElement("span");A.className="magicx-aia-segment-icon",A.setAttribute("contenteditable","false"),A.setAttribute("aria-hidden","true"),A.innerHTML=R,h.appendChild(A),v.param.icon&&(h.dataset.aiaIcon=v.param.icon)}h.appendChild(T.createTextNode(v.value)),l&&h.appendChild(Ns(T,v.param.id)),S.appendChild(h)}else if(v.type==="identified"){let h=T.createElement("strong");h.dataset.seg="identified",h.dataset.paramId=v.param.id;let x=["magicx-aia-segment","magicx-aia-segment--completed"];v.param.id===o&&x.push("magicx-aia-segment--editing"),h.className=x.join(" "),h.style.letterSpacing=Ds(v.value.length),h.textContent=v.value,l&&h.appendChild(Ns(T,v.param.id)),S.appendChild(h)}else S.appendChild(T.createTextNode(v.value));if(m){m.node.deleteData(0,m.node.data.length-m.syllable.length);for(let v of Array.from(e.childNodes))v!==m.node&&v.remove();e.insertBefore(S,m.node),e.dataset.aiaTextLength=String(P+m.syllable.length);return}e.replaceChildren(S),e.dataset.aiaTextLength=String(P),b!=null?V(e,Math.max(0,Math.min(b,P))):g&&V(e,P)}function bu(t,e){let n=e.map(a=>a.value).join(""),i=Ce(t);if(i===n)return null;if(!i.startsWith(n))return"unsafe";let o=i.slice(n.length),r=t.lastChild;return r?.nodeType!==Node.TEXT_NODE||!r.data.endsWith(o)?"unsafe":{node:r,syllable:o}}function Ns(t,e){let n=t.createElement("span");return n.className="magicx-aia-segment-remove",n.setAttribute("contenteditable","false"),n.setAttribute("aria-hidden","true"),n.dataset.aiaChipRemove=e,n.innerHTML='<svg viewBox="0 0 10 10" aria-hidden="true"><path d="M2.5 2.5l5 5M7.5 2.5l-5 5"/></svg>',n}var yu='<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 Fs(t=k()){let e=document.createElement("button");return e.type="button",e.className="magicx-aia-submit",e.setAttribute("aria-label",t.submit),e.setAttribute("data-aia-submit",""),e.innerHTML=yu.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function Ws(t){let e=t.store.get();return(!!e.text||e.completedParams.length>0)&&!!t.onSubmit}function Vs(t){if(!t.onSubmit||t.store.get().isSubmitting)return;t.endTypedWord?.();let e=t.store.get();t.onSubmit(he(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields}))&&t.afterSubmit?.()}function Su(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function Bs(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 Us(t,e){let{listboxId:n}=e,i=Ai(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",Su()?"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=Fs(e.strings),o.appendChild(l),d=l):e.submitButton!==null&&(d=e.submitButton,d.hasAttribute("data-aia-submit")||d.setAttribute("data-aia-submit",""),d.setAttribute("data-aia-submit-slot",""),o.appendChild(d));let c=new AbortController,{signal:u}=c,f=!1,p=0,m=()=>{let h=Ce(a);return h.length>0&&h[0]!==h[0].toUpperCase()?h[0].toUpperCase()+h.slice(1):h},g=()=>e.handleChange(m()),b=()=>{let h=ge(a)?.node??null;if(!h||!a.contains(h))return null;let y=(h.nodeType===Node.ELEMENT_NODE?h:h.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return y&&ta(a,y)?null:y};o.addEventListener("click",h=>{h.target?.closest("[data-aia-pill]")||a.getRootNode().activeElement?.closest("[data-aia-location]")||a.focus()},{signal:u});let T=null,S=()=>{let h=e.showChipRemove??!1;h!==(T!==null)&&(T?.(),T=h?Oi(a,x=>e.removeParam(x)):null)};if(S(),u.addEventListener("abort",()=>{T?.(),T=null}),a.addEventListener("input",()=>{if(f){e.handleCompositionText(m());return}p=performance.now(),g(),e.handleCaretAfterInput(z(a))},{signal:u}),H(a).addEventListener("selectionchange",()=>{let h=ge(a);if(!h||!a.contains(h.node))return;let x=h.collapsed?b():null,w=e.store.get(),y=w.editingParam?.id??w.editingIdentified?.id??null;if(x&&x!==y){e.startEditingParam(x);return}performance.now()-p<50||e.handleCaretMove(z(a))},{signal:u}),a.addEventListener("click",h=>{let x=xn(a,h.target);x&&(e.startEditingParam(x),vn(a,x))},{signal:u}),a.addEventListener("compositionstart",()=>{f=!0,a.setAttribute("data-aia-composing","true")},{signal:u}),a.addEventListener("compositionend",()=>{f=!1,a.removeAttribute("data-aia-composing"),g()},{signal:u}),a.addEventListener("beforeinput",h=>{let x=h,w=x.inputType;if(w==="insertParagraph"||w==="insertLineBreak"||w==="insertFromDrop"){h.preventDefault();return}if(w.startsWith("insert")||w.startsWith("delete")){let y=w.startsWith("delete")?"":x.data??"";e.replaceEditingRange(y)&&h.preventDefault()}},{signal:u}),a.addEventListener("paste",h=>{h.preventDefault();let x=(h.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!x)return;let w=H(a),y=Le(a);if(!y||!a.contains(y.startContainer))return;y.deleteContents();let L=w.createTextNode(x);y.insertNode(L),y.setStartAfter(L),St(a,y.startContainer,y.startOffset),g()},{signal:u}),a.addEventListener("keydown",h=>e.handleKeyDown(h),{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",h=>{Ws(e)&&(h.stopPropagation(),Vs(e))},{signal:u}),e.autoFocus!==!1){a.focus();let h=ge(a);(!h||!a.contains(h.node))&&St(a,a,0)}if(typeof ResizeObserver<"u"){let h=new ResizeObserver(()=>Bs(a,s));h.observe(a),c.signal.addEventListener("abort",()=>h.disconnect(),{once:!0})}let v=Mi(r);return c.signal.addEventListener("abort",v,{once:!0}),{input:a,inlinePillContainer:s,dropdown:i,submitButton:l,submitTarget:d,abort:c,syncChipRemove:S}}function mr(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:a}=t,{pillPlacement:s,setActivePill:l,selectOption:d,store:c}=n;t.syncChipRemove(),i.setAttribute("aria-expanded",String(e.isDropdownOpen));let u=e.activeDropdownIndex>=0?`${n.listboxId}-option-${e.activeDropdownIndex}`:"";if(u?i.setAttribute("aria-activedescendant",u):i.removeAttribute("aria-activedescendant"),a){let T=n.strings??k();a.getAttribute("aria-label")!==T.submit&&a.setAttribute("aria-label",T.submit);let S=a.querySelector("svg");S&&S.getAttribute("aria-label")!==T.submit&&S.setAttribute("aria-label",T.submit);let P=!!e.text||e.completedParams.length>0;a.disabled=!P,a.toggleAttribute("data-aia-ready",P&&e.isReady)}t.submitTarget&&Qe(t.submitTarget,"data-aia-submit-state",e.isSubmitting);let f=i.dataset.newParamId??"",p=e.newParamId!==null&&e.newParamId!==f;if(Fi({input:i,segments:e.segments,newParamId:e.newParamId,editingParamId:e.editingParam?.id??null,placeholderText:e.placeholderText,isFocused:e.isFocused,showChipIcons:n.showChipIcons??!0,showChipImages:n.showChipImages??!0,hintOptions:s==="inline"?[]:Ni(e.actionableSuggestions),showChipRemove:n.showChipRemove??!1}),s==="inline"){let T=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,S=en(e.actionableSuggestions);T||S.length>0?gi(o,S,0,l,!1,T,e.isActivePillSelected):jo(o)}else jo(o);Bs(i,o),p?(i.focus(),V(i,e.caretOffset??e.text.length)):e.isFocused&&Ce(i)!==e.text&&!i.hasAttribute("data-aia-composing")&&V(i,e.text.length);let m=e.editingParam?We(e.editingParam):e.editingIdentified?{parameter:e.editingIdentified.parameter,text:J(e.editingIdentified.parameter),required:!0,options:[]}:null,g=e.dropdownSuggestion??m??e.actionableSuggestions[0],b=je(e);Ii(r,{strings:n.strings,suggestions:g?[{...g,options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:tt(e.dropdownSuggestion,m,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",showProductVendor:n.showProductVendor??!0,onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:b.selectedIso,selectedDateRange:b.selectedRange,dateRangeStart:b.rangeStart,dateReferences:b.references,timeView:e.timeView,multiSelectView:e.dropdownMultiSelect,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:d,onHighlight:(T,S)=>{S!==void 0&&c.get().activeDropdownIndex!==S||c.set({activeDropdownIndex:T})},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:T=>c.set({isFocused:T}),seeAllBusy:e.isSubmitting,busyProductId:e.selectingProductId,onSeeAllResults:n.seeAllResults&&e.text.trim().length>0&&Ws(n)?()=>Vs(n):void 0,fullWidth:n.seeAllResults===!0})}function Wi(t){let e=t,n=new Set,i=[],o=!1;return{get:()=>e,set:r=>{let a=typeof r=="function"?r(e):r,s=e;if(e={...e,...a},i.push([e,s]),!o){o=!0;try{let l=0;for(let d=i.shift();d;d=i.shift()){if(++l>1e4)throw i.length=0,new Error("createStore: notifications did not settle after 10000 deliveries \u2014 a listener is likely calling set() on every notification");let[c,u]=d;for(let f of n)f(c,u)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function $s(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 pr=new WeakSet,Gs=new WeakMap;function Ks(t){return t.nodeType===Node.DOCUMENT_NODE}function Tu(t){return Ks(t)?t:t.ownerDocument}function xu(t){let e=Gs.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(js),Gs.set(t,i),i)}catch{return null}}function qs(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=js,e.appendChild(n)}function zs(t){if(typeof document>"u")return;let e=t??document;if(pr.has(e))return;let n=Tu(e);if(Ks(e)){let r=e.head??e.documentElement;if(!r)return;qs(n,r),pr.add(e);return}let i=xu(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):qs(n,e),pr.add(e)}var js=`.aia-stack {
1
+ "use strict";var Xi=Object.defineProperty;var bl=Object.getOwnPropertyDescriptor;var yl=Object.getOwnPropertyNames;var Sl=Object.prototype.hasOwnProperty;var Tl=(t,e)=>{for(var n in e)Xi(t,n,{get:e[n],enumerable:!0})},xl=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of yl(e))!Sl.call(t,o)&&o!==n&&Xi(t,o,{get:()=>e[o],enumerable:!(i=bl(e,o))||i.enumerable});return t};var vl=t=>xl(Xi({},"__esModule",{value:!0}),t);var Qd={};Tl(Qd,{AIAutocomplete:()=>Qi,ATTRIBUTION_URL:()=>_o,DATE_RANGE_META_END:()=>Bn,DATE_RANGE_META_START:()=>Vn,DEFAULT_OPTION_COUNT_UNIT:()=>or,EDITOR_GROW_MS:()=>Wa,HANDOFF_NOT_HANDLED:()=>zi,HINT_ATTR:()=>Vi,HINT_EL_ATTR:()=>fr,HINT_HOLD_MS:()=>pr,LOCATION_META_KEY:()=>Yt,LOCATION_MIN_QUERY:()=>ct,MULTI_DONE_FIT_VAR:()=>si,MULTI_SELECT_TOGGLE_MIN_PX:()=>xa,MULTI_SELECT_TOGGLE_SLOP_PX:()=>Ta,ModeController:()=>it,OPTIONS_GRID_MOBILE_QUERY:()=>It,OPTION_ENTER_DELAY_VAR:()=>li,OPTION_ENTER_FADE_MS:()=>Vs,OPTION_ENTER_RISE_MS:()=>Bs,OPTION_ENTER_RISE_PX:()=>Us,OPTION_ENTER_STAGGER_MS:()=>Ws,OPTION_IMAGE_WIDTH:()=>xi,PANEL_ENTER_DELAY_MS:()=>Ko,PANEL_ENTER_MS:()=>qo,PANEL_GHOST_CLASS:()=>ee,PANEL_GLIDE_MS:()=>$o,PANEL_LEAVE_MS:()=>Go,PLACEHOLDER_FADE_OUT_MS:()=>As,PLACEHOLDER_LEAVING_ATTR:()=>Me,PLACEHOLDER_SWAP_GAP_MS:()=>Is,PLACEHOLDER_TYPE_MS:()=>Ls,PLACEHOLDER_WORD_PAUSE_MS:()=>Cs,PRODUCT_IMAGE_WIDTH:()=>fa,PRODUCT_PATH_PREFIX:()=>To,PRODUCT_ROW_PX_PER_LINE:()=>da,RANGE_SEPARATOR:()=>Po,SCHEMA_VERSION:()=>no,SCROLL_ARROW_ATTR:()=>_t,SCROLL_ARROW_BOTTOM_VAR:()=>Wo,SCROLL_ARROW_CLASS:()=>Ho,SCROLL_ARROW_FADE_MS:()=>No,SCROLL_ARROW_LABEL:()=>Gs,SCROLL_ARROW_SCROLL_IDLE_MS:()=>Fo,SCROLL_ARROW_VISIBLE_ATTR:()=>Re,SKIPPED_PARAM_TEXT:()=>to,SMART_SUGGESTION_SPARKLE_SVG:()=>on,TIME_META_KEY:()=>mo,TIME_STEP_MINUTES:()=>An,TIME_WHEEL_COLUMNS:()=>vt,TIME_WHEEL_ROW_HEIGHT:()=>xt,VIEWPORT_FIT_ATTR:()=>le,VIEWPORT_FIT_HEIGHT_VAR:()=>Nt,WEEKDAY_LABELS:()=>ht,addMonths:()=>mn,attachChipRemove:()=>Di,attachProductRowWheel:()=>Si,attachScrollArrow:()=>pi,attachViewportFit:()=>Pi,buildAttributionUrl:()=>ii,buildDateOptions:()=>pn,buildLocationOption:()=>Qt,buildQuery:()=>N,buildSubmitResult:()=>be,buildTimeOption:()=>In,cancelStartingHint:()=>Bi,cellDay:()=>fn,cellIso:()=>K,chipIdFromTap:()=>vn,computeOptionsGridLayout:()=>Co,containScroll:()=>ri,createStore:()=>Gi,cursorIsAtEnd:()=>wn,dateCellMarks:()=>ei,dateFloorFor:()=>ni,dateSelectionFor:()=>je,destroyPanelMorph:()=>bi,dropdownPillsFor:()=>tt,editingSuggestion:()=>We,extractPlainText:()=>Ae,findMultiSelectDone:()=>Fs,fitMultiSelectDone:()=>ai,formatAbsoluteDate:()=>Le,formatDate:()=>so,formatDateRange:()=>Lo,formatOptionCount:()=>et,formatPlace:()=>Zi,formatTime:()=>Tt,getCursorOffset:()=>z,getFooterHint:()=>oi,hasSkippablePill:()=>rn,highlightParts:()=>Yn,identifiedParamLabel:()=>J,inPanelGhost:()=>ke,isCalendarFormat:()=>_,isDimmedDay:()=>ti,isMultiSelectToggleTap:()=>wi,isOptionsGridMobileViewport:()=>Ke,isPickerFormat:()=>D,isSmartSuggestion:()=>we,isTraditionalAutocompleteSuggestion:()=>C,isoDate:()=>W,isoTime:()=>bo,keepCaretOnChip:()=>En,labelTraditionalAutocomplete:()=>nn,locationEndpointFor:()=>Xt,matchTypedPhrase:()=>kt,measureOptionsGrid:()=>qe,monthLabel:()=>dn,needsOptionsGridMeasurement:()=>$n,notePanelMorphHeight:()=>hi,optionCountLabel:()=>Aa,optionEnterDelayMs:()=>ci,optionHasImage:()=>rr,optionImageSources:()=>Ze,optionImageSrc:()=>Te,optionLabel:()=>Wt,optionsEntranceDurationMs:()=>ui,optionsGridTemplateColumns:()=>Un,optionsShowLeadingVisuals:()=>Ii,panelMorphGlide:()=>se,panelMorphKey:()=>fi,panelMorphTargetHeight:()=>gi,parseDate:()=>bt,parseLooseDate:()=>Ie,parseLooseDateRange:()=>At,parseTime:()=>Cn,plainTextLength:()=>xn,planOptionsGrid:()=>Gn,pointerMayHighlight:()=>Ft,previousGraphemeBoundary:()=>Pn,productFromMatchedItem:()=>xo,productImageSources:()=>Ht,productImageSrc:()=>ga,productInitial:()=>Ti,productPhotoFill:()=>vi,productRowWheelTarget:()=>Jo,productsFromCustomFields:()=>Hn,queryLive:()=>B,releasePanelHug:()=>Xe,renderEditableContent:()=>$i,resolveFormatType:()=>Y,resolveIdentifiedDate:()=>Wn,sameOptionRows:()=>Kn,sanitizeOptionIconSvg:()=>ie,scrollCaretIntoView:()=>yn,selectedIsoFromText:()=>Be,selectedRangeFor:()=>Oe,setCursorOffset:()=>V,settlePanelMorph:()=>Dt,shopifyImageSrc:()=>Zo,startingHintOptions:()=>Ui,syncHighlightScroll:()=>Ci,syncPanelHug:()=>Zs,timeWheelIndex:()=>Et,timeWheelIndexFromScroll:()=>Mn,timeWheelRows:()=>On,toWireIdentifiedParams:()=>He,typedFragment:()=>Mo,uiStringsFor:()=>R,visibleDateRange:()=>Zn,watchEditorHeight:()=>Hi,withSkippedParams:()=>Ne,withTimeWheelIndex:()=>wt,withoutTraditionalAutocomplete:()=>tn});module.exports=vl(Qd);function _(t){return t==="date"||t==="date-range"}function D(t){return t!=="options"}function Y(t){return t?.type?.kind==="date"?"date":t?.type?.kind==="date_range"?"date-range":t?.type?.kind==="time"?"time":t?.type?.kind==="location"&&!t.options?.length?"location":"options"}var Gt=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 El="https://api.ai-autocomplete.com",X=`${El}/api/suggest`,qt=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),vr=new WeakMap;function lt(t){return t?.type==="accessToken"}function wl(t){if(!(!t||lt(t)))return t}function Kt(t){let e=vr.get(t.getAccessToken);return e||(e=new Gt(t),vr.set(t.getAccessToken,e)),e}function zt(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function jt(t){let e=wl(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var Yt="aiaPlace",ct=2,Pr=250,Er=new Set("new san los las santa saint st fort port north south east west lake mount el la rio de palm long grand cape salt hong".split(" ")),wr=new Set("city beach springs falls island park heights valley bay".split(" ")),Pl=new Set("a an the in at to off on of from for by near into onto around via toward towards up out and or with within".split(" "));function Lr(t){let e=Ll(t);for(;e.length>0&&Pl.has(e[0].toLowerCase().replace(/[.,]+$/,""));)e.shift();return e.join(" ")}function Ll(t){let e=t.trim().split(/\s+/).filter(Boolean);if(e.length===0)return[];let n=e[e.length-1].replace(/[.,]+$/,"");if(!n)return[];let i=e.length>1?e[e.length-2]:void 0,o=e.length>2?e[e.length-3]:void 0,r=s=>s.toLowerCase().replace(/[.,]+$/,"");return i&&o&&Er.has(r(o))&&wr.has(r(n))?[o,i,n]:i&&(Er.has(r(i))||wr.has(r(n)))?[i,n]:[n]}function Zi(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function Ji(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function eo(t,e){let n=Ji(e);if(!n)return!1;if(Ji(t.name)===n)return!0;for(let[,i]of t.name.matchAll(/\(([^()]*)\)/g))if(Ji(i)===n)return!0;return!1}function Cr(t,e){let n=e.metadata?.[Yt];if(typeof n?.name!="string")return 0;let i={id:"",name:n.name},o=[...t.matchAll(/\S+/g)];for(let r of o){let s=r.index??0,a=t.slice(s).trim().replace(/[.,]+$/,"");if(eo(i,a))return t.length-s}return 0}function Qt(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:Zi(t),is_tappable:!0,kind:null,metadata:{[Yt]:{id:t.id,name:t.name}}}}function Xt(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??X,n=e.indexOf("?"),i=n<0?e:e.slice(0,n),o=n<0?"":e.slice(n+1);if(!/\/suggest\/?$/.test(i))return null;let r=i.replace(/\/suggest\/?$/,"/locations/autocomplete");return o?`${r}?${o}`:r}function Ar(t){let e=t?.places;if(!Array.isArray(e))return[];let n=[];for(let i of e){let{id:o,name:r,secondary:s}=i??{};typeof o!="string"||!o||typeof r!="string"||!r.trim()||n.push({id:o,name:r.trim(),...typeof s=="string"&&s.trim()?{secondary:s.trim()}:{}})}return n}function He(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var to="skipped";function Ne(t,e){if(t.some(o=>"group"in o)&&(t=t.map(o=>{let{group:r,...s}=o;return s})),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:to,kind:null}));return i.length>0?[...t,...i]:t}var Cl="0.78.0",no="1.0",Ir=!1;function Al(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function me(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function Il(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function Ol(t,e,n,i,o,r,s,a,l,u,c,d,f,p){let m=e.find(T=>T.parameter==="contact"&&T.metadata?.contact_account_count)?.metadata?.contact_account_count,g=typeof m=="number"?m:void 0,b=Il();return{data:{raw_query:t,accepts_traditional_autocomplete:!0,...p&&{traditional_autocomplete_only:!0},client_option_parameters:f??[],completed_params:Ne(e.map(T=>Al(T,n)),l??[]),...s&&s.length>0&&{identified_params:He(s)},...a&&a.length>0&&{recently_suggested:a},...g!=null&&{contact_account_count:g},...u!==void 0&&{additional_context:u}},meta:{request_id:o,request_at:new Date().toISOString(),language:me(c),...b&&{timezone:b},...d?.code&&Number.isFinite(d.rate)&&d.rate>0&&{currency:d.code,currency_rate:d.rate,...d.country!==void 0&&{country:d.country}},client_version:Cl,session_id:i,source:r,schema_version:no}}}async function Or(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function io(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=Ol(t,e,o,n.sessionId,n.requestId??crypto.randomUUID(),n.source,n.identifiedParams,n.recentlySuggested,n.skippedParams,n.additionalContext,n.language,n.currency,n.clientOptionParameters,n.traditionalAutocompleteOnly),s=i?.endpoint??X,a=await Mr(s,JSON.stringify(r),i,n.signal);if(!a.ok)throw new Error(`API error: ${a.status} ${a.statusText}`);return a.json()}async function Mr(t,e,n,i){let o=zt(n);if(lt(n)){let s=Kt(n),a=await s.getToken(),l=await Or(t,o,a,e,i);if(l.status===401){let u=await s.getToken(!0);l=await Or(t,o,u,e,i)}return l}let r=jt(n);return!r&&!Ir&&(Ir=!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 ut=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function kr(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:me(n.language)}),o=await Mr(t,i,n.apiConfig,n.signal);if(!o.ok)throw new ut(o.status);return Ar(await o.json())}var Jt=/[\p{L}\p{N}]/u,Ml=/['\u2019-]/;function Rr(t,e,n){let i=t[e];if(i===void 0)return!1;if(Jt.test(i))return!0;let o=t[e+n];return Ml.test(i)&&o!==void 0&&Jt.test(o)}function kl(t,e,n){let i=e+n.length;return!(Jt.test(n[0])&&Rr(t,e-1,-1)||Jt.test(n[n.length-1])&&Rr(t,i,1))}function re(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(kl(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=[],s=0;for(let a of e){let l=(i[a.parameter]??0)+1;i[a.parameter]=l;let c=`{{${a.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,d=p=>re(n,a.text,p,m=>!r.some(g=>m<g.end&&m+a.text.length>g.start)),f=d(s);if(f===-1&&(f=d(0)),f!==-1){n=n.slice(0,f)+c+n.slice(f+a.text.length);let p=c.length-a.text.length;for(let m of r)m.start>=f+a.text.length&&(m.start+=p,m.end+=p);r.push({start:f,end:f+c.length}),s=f>=s?f+c.length:s+p}o.push({...a,placeholder:c})}return{rawQuery:n,completedParams:o}}function pe(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function Fe(t,e){return e===!1?"":t}function dt(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function mt(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 _r(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 s=i.slice(r).join(" ");if(o.startsWith(s.toLowerCase())){let a=n.length-s.length;return t.length-a}}return 0}function Dr(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function Rl(t,e){let n=Dr(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function fe(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?Dr(i).trimStart():"";if(o)return t.filter(s=>!s.is_tappable||Rl(s.text,o));let r=i.toLowerCase();return t.filter(s=>!s.is_tappable||s.text.toLowerCase().includes(r))}function Zt(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 pt(t,e,n,i,o){let r=mt(e,n,i),s=Zt(t,r);if(s||!o||!r.trim())return s;if(r===e.slice(n))return null;let a=e.lastIndexOf(" ",n-1)+1;return Zt(t,e.slice(a))}function Hr(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 s=t.findIndex(a=>a.is_tappable&&!a.selectsAll&&a.text.toLowerCase().startsWith(o));if(s>=0)return t.map((a,l)=>l===s?{...a,liveMatch:!0}:a)}let r=n.indexOf(" ",i);if(r<0)break;i=r+1}return t}function Fr(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function Wr(t,e){let{icon:n,icon_svg:i}=e;return!i||t.every(Nr)?t:t.map(o=>Nr(o)?o:{...o,icon:n,icon_svg:i})}function Nr(t){return!!(t.icon_svg||t.image_url)}function _l(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=_l(t);return e.length>0?e.join(" "):t}function Z(t,e){return t.parameter||e}function ft(t,e,n){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:n?.trim()||J(t),...e?{suggestionHeader:e}:{}}}function We(t){return t.suggestionValueType?.kind==="traditional_autocomplete"?{parameter:t.suggestionParameter,text:t.suggestionHeader??"",required:!0,type:t.suggestionValueType,options:t.options}:{parameter:t.suggestionParameter,text:t.suggestionPlaceholder,required:!0,options:t.options}}function en(t,e){let n=Z(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?ft(n,t.suggestionHeader,e.parameter_label):{parameter:n,suggestionParameter:t.suggestionParameter,suggestionValueType:t.suggestionValueType,suggestionPlaceholder:t.suggestionPlaceholder,suggestionIcon:t.suggestionIcon,suggestionIconSvg:t.suggestionIconSvg}}function C(t){return t?.type?.kind==="traditional_autocomplete"}function Dl(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function oo(t){return t.parameter_label?.trim()||Dl(t.parameter)}function we(t){return C(t)||t?.smart_suggestion===!0}function tn(t){return t.some(C)?t.filter(e=>!C(e)):t}function nn(t,e){return t.some(n=>C(n)&&!n.text)?t.map(n=>C(n)&&!n.text?{...n,text:e}:n):t}var on='<svg viewBox="0 0 20 20" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false"><path class="aia-sparkle-large" d="M8 5C8.5 9.5 10.5 11.5 15 12C10.5 12.5 8.5 14.5 8 19C7.5 14.5 5.5 12.5 1 12C5.5 11.5 7.5 9.5 8 5Z"/><path class="aia-sparkle-small" d="M16 1C16.2 3 17 3.8 19 4C17 4.2 16.2 5 16 7C15.8 5 15 4.2 13 4C15 3.8 15.8 3 16 1Z"/></svg>';function rn(t){return t.some(e=>!C(e))}function Vr(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 Br(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 Ur(t,e){let n=[],i=new Map;for(let o of[...t,...e]){if(o.parameter==="placeholder"||C(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 s of o.options??[])!s.is_tappable||r.options?.includes(s.text)||(r.options??(r.options=[]),r.options.push(s.text))}return n}function $r(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 sn(t,e){let n=[],i=[],o=0;for(let r of e){let s=re(t,r.text,o);if(s===-1){i.push(r);continue}n.push({start:s,end:s+r.text.length,param:r}),o=s+r.text.length}return{located:n,missing:i}}function Pe(t,e){let{located:n}=sn(t,e);return n.length>0?n[n.length-1].end:0}function Gr(t,e,n){let i=[],o=[],r=0;for(let s of n){let a=re(t,s.text,r,l=>!e.some(u=>l<u.end&&l+s.text.length>u.start));if(a===-1){o.push(s);continue}i.push({start:a,end:a+s.text.length,param:s}),r=a+s.text.length}return{located:i,missing:o}}function an(t,e,n=[]){let i=sn(t,e).located,o=[];for(let c of i){let d=o[o.length-1];c.param.group&&d?.param.group===c.param.group?(d.end=c.end,d.params?.push(c.param)):o.push({...c,...c.param.group?{params:[c.param]}:{}})}let r=Gr(t,o,n).located,s=[...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,d)=>c.start-d.start),a=[],l=0;for(let c of s)c.start>l&&a.push({type:"text",value:t.slice(l,c.start)}),a.push(c.segment),l=c.end;let u=t.slice(l);return u&&a.push({type:"text",value:u}),a}function qr(t,e){let{located:n,missing:i}=sn(t,e),o=new Set(i.map(s=>s.group).filter(Boolean)),r=n.map(s=>s.param).filter(s=>!o.has(s.group));return{valid:r,invalid:e.filter(s=>!r.includes(s))}}function gt(t,e,n){let i=sn(t,e).located,{located:o,missing:r}=Gr(t,i,n);return{valid:o.map(s=>s.param),invalid:r}}function Kr(t,e,n){let i=e?.endpoint??X,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${Hl(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,s)=>{let a=qt.get(s);return a?`https://${a}`:r})}function Hl(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 zr(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 Nl(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var jr=100,Fl=300,Wl=2,ln=class{constructor(e,n,i,o,r,s,a,l,u,c={}){this.store=e;this.getApiConfig=n;this.getOptionOverrides=i;this.getMaskCompletedText=o;this.getOnError=r;this.getSessionId=s;this.getSource=a;this.getAdditionalContext=l;this.getLanguage=u;this.callbacks=c;this.fetchVersion=0;this.abortController=null;this.debounceTimer=null;this.slowDebounceTimer=null;this.unsubscribe=null;this.phraseExactMatch=!1;this.previewTimer=null;this.previewAbort=null;this.previewVersion=0;this.previewPending=!1;this.shownPreview=null;this.forceNextFetch=!1}start(){this.doFetch("",[]);let e=this.store.get().text,n=this.store.get().completedParams;this.unsubscribe=this.store.subscribe(i=>{(i.text!==e||i.completedParams!==n)&&(e=i.text,n=i.completedParams,this.scheduleFetch())})}isPhraseExactMatch(){return this.phraseExactMatch}dispose(){this.abortController?.abort(),this.clearTimers(),this.clearPreview(),this.unsubscribe?.()}previewComposition(e){this.previewTimer&&clearTimeout(this.previewTimer),this.previewPending=!0,this.previewTimer=setTimeout(()=>{this.previewTimer=null,this.doPreview(e)},jr)}endPreview(){this.shownPreview=null,this.previewPending&&(this.clearPreview(),this.forceNextFetch=!0,this.scheduleFetch())}clearPreview(){this.previewTimer&&clearTimeout(this.previewTimer),this.previewTimer=null,this.previewAbort?.abort(),this.previewAbort=null,this.previewPending=!1,this.shownPreview=null}async doPreview(e){this.previewAbort?.abort();let n=new AbortController;this.previewAbort=n;let i=++this.previewVersion;this.previewPending=!0;let o=this.fetchVersion,r=this.store.get(),{rawQuery:s,completedParams:a}=N(e,r.completedParams);try{let l=await io(s,a,{...this.requestOptions(r,n.signal,crypto.randomUUID()),traditionalAutocompleteOnly:!0});if(i!==this.previewVersion||o!==this.fetchVersion)return;let u=(l.data.suggestions??[]).find(C);if(!u)return;let c=l.meta?.traditional_autocomplete===!0;this.shownPreview={answer:u,traditionalAutocomplete:c},this.store.set({suggestions:[u],traditionalAutocomplete:c,activeDropdownIndex:-1})}catch{}}requestOptions(e,n,i){let o=e.pendingSpan?Ur(e.pendingSpan.snapshot,e.actionableSuggestions):void 0;return{sessionId:this.getSessionId(),requestId:i,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:n,apiConfig:this.getApiConfig(),identifiedParams:e.identifiedParams,recentlySuggested:o,skippedParams:e.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})}}async doFetch(e,n){this.abortController?.abort(),this.previewAbort?.abort(),this.previewAbort=null,this.previewPending=!1,this.shownPreview=null,this.forceNextFetch=!1;let i=new AbortController;this.abortController=i;let o=++this.fetchVersion,r=this.store.get().text.length,s=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 a=this.store.get(),l=crypto.randomUUID(),u=e===""&&n.length===0&&a.skippedParams.length===0&&a.identifiedParams.length===0,c=u?this.startingStateUrl():void 0,d=c?await zr(fetch(c,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let f=d??await io(e,n,this.requestOptions(a,i.signal,l));if(o!==this.fetchVersion)return;this.phraseExactMatch=f.meta?.phrase_exact_match===!0;let p=(f.data.suggestions??[]).find(C),m=p?[]:f.data.input??[],g=E=>({id:crypto.randomUUID(),parameter:E.parameter,text:E.text,...E.type?{type:E.type}:{},...E.iso_date?{isoDate:E.iso_date}:{},...E.iso_date_end?{isoDateEnd:E.iso_date_end}:{}}),b=m.filter(E=>E.source==="identified");this.callbacks.waitIdentified?.(b.filter(E=>E.state==="need_confirmation").map(g),s);let T=b.filter(E=>E.state!=="need_confirmation").map(g),S=this.callbacks.isWordOpen?.()??!1,P=this.store.get().text.toLowerCase(),v=E=>S&&P.endsWith(E.text.toLowerCase()),h=T.filter(E=>!v(E));S&&this.callbacks.holdIdentified?.(T.filter(v));let x=p?[p]:Fr(f.data.suggestions??[],this.getOptionOverrides()),w=m,y=w[w.length-1],L=this.store.get().text,O,A;if(y?.state==="in_progress"){A=!0;let E=L.toLowerCase().lastIndexOf(y.text.toLowerCase());O=E!==-1?E:r}else A=!1,O=r;let I=x.filter(E=>E.parameter!=="placeholder")[0],G=null;if(I&&!C(I)&&!S&&I.type?.kind!=="multi_select"&&!D(Y(I))){let E=pt(I.options,L,O,A,this.phraseExactMatch);E&&(G={id:crypto.randomUUID(),placeholder:"",parameter:Z(E,I.parameter),text:E.text,value:E.value,kind:E.kind,suggestionParameter:I.parameter,suggestionValueType:I.type,suggestionPlaceholder:I.text,suggestionIcon:I.icon,suggestionIconSvg:I.icon_svg,options:I.options??[],metadata:E.metadata,icon:E.icon,icon_svg:E.icon_svg,image_url:E.image_url},x=x.filter(ue=>ue!==I),this.callbacks.onAutoMatch?.({active:I,matched:E,rawQuery:e}))}let ce=f.data.custom_fields??null,oe=this.callbacks.productsForResponse?.(ce);this.store.set(E=>{let ue=G?[...E.completedParams,G]:E.completedParams,xe=new Set,Bt=gt(E.text,ue,h).valid.map(k=>{let rt=E.identifiedParams.find(st=>!xe.has(st.id)&&st.parameter===k.parameter&&st.text===k.text);return rt?(xe.add(rt.id),{...k,id:rt.id}):k}),ve=new Set(a.skippedParams.map(k=>k.id)),ot=new Set(E.skippedParams.filter(k=>!ve.has(k.id)).map(k=>k.parameter)),Ut=ot.size>0?x.filter(k=>k.parameter==="placeholder"||!ot.has(k.parameter)):x,$t=this.callbacks.getAllOption?.()===!0&&!u,Ee=E.composing?this.shownPreview:null;return{suggestions:Ee?[Ee.answer]:$t?Ut.map(k=>k.parameter==="placeholder"?k:{...k,leadsWithAll:!0}):Ut,isLoading:!1,isReady:f.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:O,filterInProgress:A,identifiedParams:Bt,customFields:ce,traditionalAutocomplete:Ee?Ee.traditionalAutocomplete:f.meta?.traditional_autocomplete===!0,...oe!==void 0?{products:oe}:{},...G?{completedParams:ue}:{}}}),this.callbacks.onResponse?.({requestId:l,funnelTelemetry:f.meta?.funnel_telemetry===!0,visibleImpression:f.meta?.visible_impression===!0,sdkVisitorId:f.meta?.sdk_visitor_id===!0})}catch(a){let l=Nl(a);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?Kr(e,this.getApiConfig(),me(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(Wl)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},jr),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),Fl)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;if(this.forceNextFetch){let{rawQuery:x,completedParams:w}=N(o.text,o.completedParams);return this.doFetch(x,w),!0}let s=Fe(o.suggestions.filter(x=>x.parameter==="placeholder").map(x=>x.text).join(" "),this.callbacks.getPrependPlaceholder?.()),a=pe(o.text,o.filterBase,s),l=mt(o.text,a,o.filterInProgress),u=o.suggestions.filter(x=>x.parameter!=="placeholder"),c=C(u[0])?void 0:u[0],d=D(o.activeFormatType),f=c&&!d?fe(c.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&f.length>0)return!1;let p=f.filter(x=>x.is_tappable),m=c&&!d&&!this.callbacks.isWordOpen?.()?pt(c.options,o.text,a,o.filterInProgress,this.phraseExactMatch)!==null:!1,g=l.trim().length>0,b=i&&o.products.length>0;if(p.length>0&&!m&&g&&!b||dt(o.text,o.completedParams.length,s))return!1;let{rawQuery:T,completedParams:S}=N(o.text,o.completedParams),P=T.length<o.lastRawQuery.length,v=Math.abs(T.length-o.lastRawQuery.length),h=n&&T!==o.lastRawQuery;return P||v>=e||h?(this.doFetch(T,S),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var Vl="(hover: none) and (pointer: coarse)";var Bl="[data-aia-dropdown], [data-aia-input-wrapper]",Ul=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),cn=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(Ul)),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(Vl):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(Bl))return!0;return!1}};var Ve=["January","February","March","April","May","June","July","August","September","October","November","December"],ht=["S","M","T","W","T","F","S"],Xr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],un="aiaDate",Jr="aiaDay",Yr=t=>String(t).padStart(2,"0");function W(t){return`${t.getFullYear()}-${Yr(t.getMonth()+1)}-${Yr(t.getDate())}`}function ro(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function $l(t){let e=ro(t).getTime()-ro(new Date).getTime();return Math.round(e/864e5)}function so(t){let e=$l(t);return e>=0&&e<7?Xr[t.getDay()]:Le(t)}function Le(t){return t.getFullYear()===new Date().getFullYear()?`${Ve[t.getMonth()]} ${t.getDate()}`:`${Ve[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function bt(t){if(!t)return null;let e=Xr.findIndex(a=>a.toLowerCase()===t.trim().toLowerCase());if(e>=0){let a=ro(new Date),l=(e-a.getDay()+7)%7;return new Date(a.getFullYear(),a.getMonth(),a.getDate()+l)}let n=/^\s*([A-Za-z]+)\s+(\d{1,2})(?:\s+(\d{4}))?\s*$/.exec(t);if(!n)return null;let i=Ve.findIndex(a=>a.toLowerCase()===n[1].toLowerCase());if(i<0)return null;let o=Number(n[2]),r=n[3]?Number(n[3]):new Date().getFullYear(),s=new Date(r,i,o);return s.getMonth()!==i||s.getDate()!==o?null:s}function dn(t){return`${Ve[t.month]} ${t.year}`}function ao(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function Zr(t){return{year:t.getFullYear(),month:t.getMonth()}}function mn(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function Qr(){return{text:"",is_tappable:!1,kind:null}}function pn(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(Qr());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:so(r),is_tappable:!0,kind:null,metadata:{[un]:W(r),[Jr]:o}})}for(;i.length%ht.length!==0;)i.push(Qr());return i}function Be(t){let e=bt(t);return e?W(e):null}function K(t){let e=t?.metadata?.[un];return typeof e=="string"?e:null}function fn(t){let e=t?.metadata?.[Jr];return typeof e=="number"?e:null}function Gl(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function ge(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&Gl(e)?e:t.ownerDocument??t}function gn(t){return ge(t).activeElement??null}function H(t){return t.ownerDocument??t}function ql(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function es(t){let e=ge(t);return!ql(e)||typeof e.getSelection=="function"?null:e}function ts(t){let e=es(t);if(!e)return null;let n=H(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function ns(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 yt(t){let n=ge(t).getSelection?.();return n||(H(t).getSelection?.()??null)}function he(t){let e=yt(t);if(!e||e.rangeCount===0)return null;let n=ts(t);if(n){let i=ns(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 Ce(t){let e=yt(t);if(!e||e.rangeCount===0)return null;let n=ts(t);if(!n)return e.getRangeAt(0);let i=ns(e,n);if(!i)return null;let o=H(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function St(t,e,n){let i=yt(t);if(!i)return null;if(es(t))return i.collapse(e,n),i;let o=H(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function hn(t,e){let n=t?ge(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var bn=2,Kl="magicx-aia";function is(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function zl(t){let e=H(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 s=n.getComputedStyle(i);if(o&&is(s.overflowX)||r&&is(s.overflowY))return i}if(i.classList.contains(Kl))return null;i=i.parentElement}return null}function yn(t){let e=Ce(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=zl(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,s=r+n.clientWidth;i.right>s?n.scrollLeft+=i.right-s+bn:i.left<r&&(n.scrollLeft-=r-i.left+bn)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,s=r+n.clientHeight;i.bottom>s?n.scrollTop+=i.bottom-s+bn:i.top<r&&(n.scrollTop-=r-i.top+bn)}}var rs='[contenteditable="false"]',co="strong[data-param-id]",Ue;function jl(){if(Ue!==void 0)return Ue;let t=globalThis.Intl.Segmenter;if(!t)return Ue=null,null;try{Ue=new t(void 0,{granularity:"grapheme"})}catch{Ue=null}return Ue??null}function Sn(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(rs))return!0;n=n.parentNode}return!1}function Tn(t){return H(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return Sn(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Ae(t){let e=Tn(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function xn(t){let e=Tn(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function z(t){let e=he(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(Sn(o,t)&&o!==t)return null;let r=0;for(let s=0;s<i&&s<o.childNodes.length;s++)r+=uo(o.childNodes[s],t);return r+lo(o,t)}return n.nodeType!==Node.TEXT_NODE||Sn(n,t)?null:lo(n,t)+i}function uo(t,e){if(t.nodeType===Node.TEXT_NODE)return Sn(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(rs))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=uo(o,e);return i}function lo(t,e){let n=Tn(e),i=0,o=n.nextNode();for(;o;){if(o===t||t.nodeType===Node.ELEMENT_NODE&&t.contains(o))return i;i+=o.data.length,o=n.nextNode()}return i}function V(t,e){let n=H(t),i=Math.max(0,Math.min(e,xn(t))),o=Tn(t),r=0,s=null,a=0,l=o.nextNode(),u=null;for(;l;){let d=l.data.length;if(i<r+d){s=l,a=i-r;break}if(i===r+d){let f=o.nextNode();f?(s=f,a=0):(s=l,a=d);break}r+=d,u=l,l=o.nextNode()}let c=n.createRange();if(s){let d=s.parentElement?.closest('strong[data-seg="completed"]');d&&d!==t&&t.contains(d)?a===0?c.setStartBefore(d):a===s.data.length?c.setStartAfter(d):c.setStart(s,a):c.setStart(s,a)}else u?c.setStart(u,u.data.length):c.setStart(t,0);c.collapse(!0),St(t,c.startContainer,c.startOffset)&&(Yl(t,c,i),yn(t))}function os(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(co)??null;return i&&e.contains(i)?i:null}function Yl(t,e,n){let i=os(he(t)?.node??null,t);if(i&&i!==os(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function ss(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=z(t);return i!==null&&n===`${i}:${e}`}function as(t){return ge(t).activeElement===t}function vn(t,e){if(!e||e.nodeType===void 0)return null;let n=e,i=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;if(i?.closest("[data-aia-chip-remove]"))return null;let o=i?.closest(co);if(!o||!t.contains(o))return null;let r=he(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function En(t,e){let n=null;for(let s of t.querySelectorAll(co))if(s.dataset.paramId===e){n=s;break}if(!n)return;let i=lo(n,t),o=i+uo(n,t),r=z(t);r!=null&&r>=i&&r<=o||V(t,i)}function wn(t){let e=z(t);return e==null?!1:e>=xn(t)}function Pn(t,e){if(e<=0)return 0;let n=jl();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 mo="aiaTime",An=5;var po=[12,1,2,3,4,5,6,7,8,9,10,11],fo=Array.from({length:60/5},(t,e)=>e*5),go=["AM","PM"];function Ge(t){return(Math.round(t)%1440+1440)%1440}function ho(t){let e=Ge(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function Ln(t){let e=t.hour%12+(t.period==="PM"?12:0);return Ge(e*60+t.minute)}function Tt(t){let{hour:e,minute:n,period:i}=ho(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function bo(t){let e=Ge(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function $e(t){return Ge(Math.round(t/5)*5)}function ls(t,e){return Ge(t+e)}var Ql=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,Xl=/^(\d{1,2}):(\d{2})$/;function Cn(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=Ql.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:Ln({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=Xl.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 cs(t){let e=Cn(t.editingText);if(e!=null)return $e(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>Cn(o.text)).filter(o=>o!=null);if(n.length>0)return $e(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return Ge((i.getHours()+1)*60)}function In(t){return{text:Tt(t),is_tappable:!0,kind:null,metadata:{[mo]:bo(t)}}}var xt=30,vt=["hour","minute","period"],yo={hour:po.map(t=>({label:String(t)})),minute:fo.map(t=>({label:String(t).padStart(2,"0")})),period:go.map(t=>({label:t}))};function On(t){return yo[t]}function Et(t,e){let n=ho($e(e));return t==="hour"?po.indexOf(n.hour):t==="minute"?fo.indexOf(n.minute):go.indexOf(n.period)}function wt(t,e,n){let i=yo[t],o=Math.min(Math.max(n,0),i.length-1),r=ho($e(e));return Ln(t==="hour"?{...r,hour:po[o]}:t==="minute"?{...r,minute:fo[o]}:{...r,period:go[o]})}function Mn(t,e){let n=yo[t].length-1;return Math.min(Math.max(Math.round(e/xt),0),n)}function be(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=N(t,e);return{query:t.trim(),raw_query:o,completed_params:Ne(r,n),identified_params:He(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function kn(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")?wn(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function So(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?z(t):null}var Rn=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,s=this.getEffectiveColumns(r),a=o(),l=this.getTappableIndices(s);if((e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)&&(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight"))return;let u=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=kn(e.target,n),d=!!n.editingParam;if(!c&&!d&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(u)break;e.preventDefault();let m=_(n.activeFormatType)?this.dateEntryIndex(n,!1):l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:m});break}if(l.length===0)return;this.store.set({activeDropdownIndex:m});break}if(e.preventDefault(),l.length===0)return;if(_(n.activeFormatType)){this.stepDateWeek(n,7);break}if(n.filteredOptions.length>0){let m=Math.floor((n.filteredOptions.length-1)/s);if(Math.floor(n.activeDropdownIndex/s)===m){this.store.set({activeDropdownIndex:-1});break}}let f=l.indexOf(n.activeDropdownIndex),p=f<l.length-1?f+1:0;this.store.set({activeDropdownIndex:l[p]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!u)break;let f=kn(e.target,n),p=!!n.editingParam;if(!f&&!p)break;e.preventDefault();let m=_(n.activeFormatType)?this.dateEntryIndex(n,!0):this.firstTappableInBottomRow(s)??l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:m});break}if(l.length===0)return;this.store.set({activeDropdownIndex:m});break}if(l.length===0)break;if(e.preventDefault(),_(n.activeFormatType)){this.stepDateWeek(n,-7);break}if(n.activeDropdownIndex<s){this.store.set({activeDropdownIndex:-1});break}let c=l.indexOf(n.activeDropdownIndex),d=c>0?c-1:l.length-1;this.store.set({activeDropdownIndex:l[d]});break}case"ArrowRight":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),_(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%s<s-1){let f=n.activeDropdownIndex+1;f<n.filteredOptions.length&&n.filteredOptions[f]?.is_tappable&&this.store.set({activeDropdownIndex:f})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let d=e.target.closest("[data-aia-input]")??e.target,f=n.editingTail;this.ctx.exitEditMode?.(),V(d,f);break}kn(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),_(n.activeFormatType)){this.stepDateDay(n,-1);break}if(n.activeDropdownIndex%s>0){let c=n.activeDropdownIndex-1;c>=0&&n.filteredOptions[c]?.is_tappable&&this.store.set({activeDropdownIndex:c});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let c=So(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,d=n.editingAnchor;this.ctx.exitEditMode?.(),V(c,d);break}if(this.ctx.startEditingParamAtCaret){let c=So(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let c=So(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(a){if(n.isSubmitting)break;this.ctx.endTypedWord?.(!0);let c=this.store.get();a(be(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((p,m)=>p.is_tappable?m:-1).filter(p=>p!==-1);if(c.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let p=e.shiftKey?c[c.length-1]:c[0];this.store.set({pillTapped:!0,activeDropdownIndex:p});break}e.preventDefault();let d=c.indexOf(n.activeDropdownIndex);if(!e.shiftKey&&!_(n.activeFormatType)&&!n.multiSelectView){let p=d>=0?c[d]:c.find(m=>!n.filteredOptions[m]?.selectsAll);if(p===void 0)break;this.clickOrSelect(p,n.filteredOptions,i,r);break}let f;if(d<0)f=e.shiftKey?c.length-1:0;else{let p=e.shiftKey?-1:1;f=(d+p+c.length)%c.length}this.store.set({activeDropdownIndex:c[f]});break}case"Escape":{if(n.dateRangeStart){this.store.set({pendingRangeStart:null});break}if(n.editingIdentified){this.ctx.exitEditingIdentified?.(),this.store.set({activeDropdownIndex:-1});break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){let c=e.target.closest("[data-aia-input]")??e.target,d=n.editingTail;this.ctx.exitEditMode?.(),V(c,d)}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!kn(e.target,n)&&!n.editingParam?!1:(e.preventDefault(),this.ctx.stepTime?.(e.key==="ArrowDown"?5:-5),!0);case"Enter":return i.touched?(e.preventDefault(),this.ctx.commitTime?.(),!0):!1;case"Escape":return i.touched?(this.store.set({timeDraft:null}),!0):!1;default:return!1}}firstTappableInBottomRow(e){let n=this.store.get();if(n.filteredOptions.length===0)return null;let o=Math.floor((n.filteredOptions.length-1)/e)*e;for(let r=o;r<n.filteredOptions.length;r++)if(n.filteredOptions[r]?.is_tappable)return r;return null}dateEntryIndex(e,n){if(e.dateFloor){let s=e.filteredOptions.findIndex(a=>K(a)===e.dateFloor);if(s>=0)return s}let i=W(new Date),o=e.filteredOptions.findIndex(s=>K(s)===i);if(o>=0)return o;let r=e.filteredOptions.map((s,a)=>s.is_tappable?a:-1).filter(s=>s!==-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,s)=>r.is_tappable?s:-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=hn(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=hn(e,`${this.ctx.listboxId}-option-0`)?.parentElement??null;for(;o;){let r=getComputedStyle(o).gridTemplateColumns;if(r&&r!=="none"){let s=r.split(" ").filter(Boolean).length;if(s>0)return s}if(o===n)break;o=o.parentElement}return this.ctx.columns}clickOrSelect(e,n,i,o){let r=hn(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var _n=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),s=i.query.length<o.query.length;if(n>1&&!s&&r<n)return"owns"}return this.ask(i),"asked"}sync(e){let n=this.resolveTarget(e);if(!n){this.current&&(this.cancel(),this.current=null),e.optionSearch&&this.store.set({optionSearch:null});return}this.current&&this.current.key===n.key||this.ask(n)}resolveTarget(e){if(D(e.activeFormatType)||e.editingIdentified)return null;let n=e.editingParam;if(n&&e.editingAnchor!=null)return this.hasOverride(n.suggestionParameter)?{mode:"edit",key:n.id,parameter:n.suggestionParameter,suggestion:{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options,icon:n.suggestionIcon,icon_svg:n.suggestionIconSvg},query:e.optionQuery}:null;let i=e.actionableSuggestions[0];return!i||!this.hasOverride(i.parameter)?null:{mode:"pill",key:i,parameter:i.parameter,suggestion:i,query:e.optionQuery}}missCovers(e,n){return this.lastMiss!=null&&this.lastMiss.parameter===e&&this.lastMiss.query===n}ask(e){this.cancel();let n=this.getOverrides()?.[e.parameter],i=++this.version;if(!n||this.missCovers(e.parameter,e.query)){this.current={key:e.key,parameter:e.parameter,query:e.query,abort:null},this.setSearch(e,"done");return}let o=new AbortController;this.current={key:e.key,parameter:e.parameter,query:e.query,abort:o};let r;try{r=n(e.query,o.signal,e.suggestion)}catch(s){this.logOnce(s),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 s=await n;if(i.aborted||o!==this.version)return;r=Array.isArray(s)?s:[]}catch(s){if(i.aborted||o!==this.version||Jl(s))return;this.logOnce(s),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=Wr(n,e.suggestion),r=this.resolveTarget(this.store.get());if(!r||r.key!==e.key)return;o.length===0?this.lastMiss={parameter:e.parameter,query:e.query}:this.lastMiss?.parameter===e.parameter&&(this.lastMiss=null);let s={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:o}:a.editingParam,optionSearch:s}));else{let a={...e.suggestion,options:o};this.current&&this.current.key===e.key&&(this.current.key=a),this.store.set(l=>({suggestions:l.suggestions.map(u=>u===e.suggestion?a:u),optionSearch:s}))}o.length===0?this.callbacks.onMiss?.(e.mode,e.query):this.callbacks.onAnswer?.(e.mode,e.query)}setSearch(e,n){let i=this.store.get().optionSearch;i&&i.parameter===e.parameter&&i.query===e.query&&i.status===n||this.store.set({optionSearch:{parameter:e.parameter,query:e.query,status:n}})}cancel(){this.current?.abort?.abort(),this.version++}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] an optionOverrides entry threw or rejected \u2014 treated as no options. Later failures on this instance are not logged.",e))}};function Jl(t){return t instanceof Error&&t.name==="AbortError"}var Dn=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(u=>u.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(C(o))return;let r=i.filter((u,c)=>c!==e),s=n.suggestions.filter(u=>u.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:u}=N(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:u,selectedPill:o.text,otherPills:r.map(c=>c.text)})}let a=[...s,o,...r],l=this.store.peek({suggestions:a}).filteredOptions.findIndex(u=>u.is_tappable&&!u.selectsAll);this.store.set({suggestions:a,pillTapped:!0,activeDropdownIndex:l})}removeLastParam(){this.store.get().completedParams.length!==0&&this.store.set(n=>({completedParams:n.completedParams.slice(0,-1),activeDropdownIndex:-1}))}};var To="/products/",us="https://relative.invalid";function Zl(t){if(!t)return;let e;try{e=new URL(t,`${us}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===us?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function xo(t,e){let n=Zl(t.item_url)??tc(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:ds(t.price,t.currency,e)},...ec(t)&&{compareAtPrice:ds(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function ec(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 ds(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 tc(t){if(!t.handle)return;let e=`${To}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function Hn(t,e){return(t?.items.matched??[]).map(n=>xo(n,e))}var Nn=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=Hn(e,me(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 s=await o.fetch(e,n);if(r())return;let a=o.transform(s),l=Array.isArray(a)?a:[],u=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(u)}catch(s){if(n.aborted||nc(s)||(this.logOnce(s),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 nc(t){return t instanceof Error&&t.name==="AbortError"}function ic(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function ms(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:Ve.findIndex(n=>n.toLowerCase().startsWith(e))}function oc(t,e,n){let i=new Date(n.getFullYear(),t,e);if(i.getMonth()!==t||i.getDate()!==e)return null;let o=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(i>=o)return i;let r=new Date(n.getFullYear()+1,t,e);return r.getMonth()===t&&r.getDate()===e?r:null}var rc=/^(?:(?:on|from) )?(?:the )?(\d{1,2})(?:st|nd|rd|th)$/;function vo(t){let e=rc.exec(t.trim().toLowerCase().replace(/\s+/g," "));if(!e)return null;let n=Number(e[1]);return n>=1&&n<=31?n:null}function sc(t,e){if(!Number.isFinite(e.getTime()))return null;let n=new Date(e.getFullYear(),e.getMonth(),e.getDate());for(let i=0;i<12;i++){let o=new Date(e.getFullYear(),e.getMonth()+i,t);if(o.getDate()===t&&o>=n)return o}return null}function ps(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=vo(t);if(i!==null){let u=sc(i,n);return u?W(u):null}let o=ic(t.trim().toLowerCase()).replace(/\s+/g," "),r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o);if(r){let u=ps(Number(r[1]),Number(r[2])-1,Number(r[3]));return u?W(u):null}let s=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(o);if(s){let u=ms(s[1]);if(u>=0)return Fn(u,Number(s[2]),s[3],n)}let a=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(o);if(a){let u=ms(a[2]);if(u>=0)return Fn(u,Number(a[1]),a[3],n)}let l=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(o);if(l){let u=Number(l[1]),c=Number(l[2]);return u>12&&c<=12?Fn(c-1,u,l[3],n):c>12&&u<=12?Fn(u-1,c,l[3],n):null}return null}function Fn(t,e,n,i){if(n){if(n.length!==4)return null;let r=ps(Number(n),t,e);return r?W(r):null}let o=oc(t,e,i);return o?W(o):null}var ac=/^\d{4}-\d{2}-\d{2}$/;function Pt(t){return typeof t=="string"&&ac.test(t)?t:null}function Wn(t,e={}){return Pt(t.isoDate)??Ie(t.text,e)}function Lt(t){let e=Pt(t.isoDate);return e?{start:e,end:Pt(t.isoDateEnd)}:null}var Po=" - ",Vn="aiaDateRangeStart",Bn="aiaDateRangeEnd";function Ct(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var Eo=/^\d{4}-\d{2}-\d{2}$/;function wo(t){if(!Eo.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 lc=/\s+(?:to|through|thru|until|til|till)\s+/g,cc=/[-–—]/g;function uc(t){let e=[];for(let n of[lc,cc]){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 At(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of uc(t.trim())){let s=Ie(o.trim(),e);if(!s)continue;let a=vo(r)!==null?Ie(r.trim(),{...e,today:wo(s)??e.today}):Ie(r.trim(),e);!a||a<s||(n.add(`${s}|${a}`),i={start:s,end:a})}return n.size===1?i:null}function Lo(t){let e=wo(t.start),n=wo(t.end);return!e||!n?"":t.start===t.end?Le(e):`${Le(e)}${Po}${Le(n)}`}function fs(t,e){let n=Ct(t,e);return{text:Lo(n),is_tappable:!0,kind:null,metadata:{[Vn]:n.start,[Bn]:n.end}}}function Oe(t,e={}){let n=t?.metadata?.[Vn],i=t?.metadata?.[Bn];return typeof n=="string"&&typeof i=="string"&&Eo.test(n)&&Eo.test(i)?Ct(n,i):At(t?.text,e)}var It="(max-width: 768px)";var dc="var(--aia-option-row-height, 37px)",mc="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)",pc="max(0, var(--aia-option-peek, 0))";function Co(t,e){let n=e?5:4;return gs(1,Math.min(t,n),t>n)}function gs(t,e,n){let i=n?`(${e} + ${pc})`:`${e}`;return{cols:t,rows:e,maxHeight:`calc(${i} * ${dc} + ${mc})`}}function $n(t,e){return!e&&t>=5}function Gn(t,e,n,i){if(!(!e&&t>=5&&fc(n,i))){let s=Co(t,e);return{...s,template:Un(s.cols),scrollHintIndices:!e&&t>s.rows?[s.rows-1]:[]}}let r=6;return{...gs(2,3,t>r),template:Un(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function fc(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 qe(t){if(typeof document>"u")return null;let e=Array.from(t.querySelectorAll("[data-aia-option]"));if(e.length===0)return null;let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:-9999px;top:0;";for(let s of e){let a=s.cloneNode(!0);a.removeAttribute("id"),a.removeAttribute("role"),a.removeAttribute("aria-selected"),a.style.whiteSpace="nowrap",a.style.width="max-content",n.appendChild(a)}t.appendChild(n);let i=Array.from(n.children).map(s=>s.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)+gc(t);return{rowWidths:i,gridWidth:r}}function gc(t){let e=t.closest("[data-aia-dropdown]"),n=Number.parseFloat(e?.getAttribute(qn)??"");if(!e||!Number.isFinite(n)||e.style.getPropertyValue(Ot)!=="")return 0;let i=e.getBoundingClientRect().width;return i>0?n-i:0}var qn="data-aia-glide-width",Ot="--aia-glide-content-width";function Un(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function Ke(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(It).matches}function Kn(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}var hs={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Items",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",seeAllResults:"See all results",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",allOption:"All",timeLabel:"Time",locationSearch:"Say a location",locationNoResults:"No places found",locationUseTyped:"Press Enter to use what you typed"},hc={language:"es",and:"y",proceed:"para continuar",select:"para seleccionar",skipHint:"para omitir",skip:"omitir",skipLabel:"Omitir",products:"Mejor coincidencia",soldOut:"Agotado",addToCart:"A\xF1adir al carrito",submit:"Buscar",seeAllResults:"Ver todos los resultados",scrollArrow:"Despl\xE1zate para ver m\xE1s opciones",keepTyping:"Sigue escribiendo",done:"Listo",allOption:"Todo",timeLabel:"Hora",locationSearch:"Di una ubicaci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},Ao={en:hs,es:hc,fr:{language:"fr",and:"et",proceed:"pour continuer",select:"pour s\xE9lectionner",skipHint:"pour passer",skip:"passer",skipLabel:"Passer",products:"Meilleure correspondance",soldOut:"\xC9puis\xE9",addToCart:"Ajouter au panier",submit:"Rechercher",seeAllResults:"Voir tous les r\xE9sultats",scrollArrow:"Faites d\xE9filer pour voir plus d\u2019options",keepTyping:"Continuez \xE0 taper",done:"Termin\xE9",allOption:"Tout",timeLabel:"Heure",locationSearch:"Dites un lieu",locationNoResults:"Aucun lieu trouv\xE9",locationUseTyped:"Appuyez sur Entr\xE9e pour utiliser votre saisie"},"pt-BR":{language:"pt-BR",and:"e",proceed:"para continuar",select:"para selecionar",skipHint:"para pular",skip:"pular",skipLabel:"Pular",products:"Melhor correspond\xEAncia",soldOut:"Esgotado",addToCart:"Adicionar ao carrinho",submit:"Buscar",seeAllResults:"Ver todos os resultados",scrollArrow:"Role para ver mais op\xE7\xF5es",keepTyping:"Continue digitando",done:"Conclu\xEDdo",allOption:"Tudo",timeLabel:"Hor\xE1rio",locationSearch:"Diga um local",locationNoResults:"Nenhum lugar encontrado",locationUseTyped:"Pressione Enter para usar o que voc\xEA digitou"},it:{language:"it",and:"e",proceed:"per continuare",select:"per selezionare",skipHint:"per saltare",skip:"salta",skipLabel:"Salta",products:"Migliore corrispondenza",soldOut:"Esaurito",addToCart:"Aggiungi al carrello",submit:"Cerca",seeAllResults:"Vedi tutti i risultati",scrollArrow:"Scorri per vedere altre opzioni",keepTyping:"Continua a scrivere",done:"Fatto",allOption:"Tutto",timeLabel:"Ora",locationSearch:"Di' un luogo",locationNoResults:"Nessun luogo trovato",locationUseTyped:"Premi Invio per usare ci\xF2 che hai scritto"},tr:{language:"tr",and:"ve",proceed:"devam etmek i\xE7in",select:"se\xE7mek i\xE7in",skipHint:"atlamak i\xE7in",skip:"atla",skipLabel:"Atla",products:"En iyi e\u015Fle\u015Fme",soldOut:"T\xFCkendi",addToCart:"Sepete ekle",submit:"Ara",seeAllResults:"T\xFCm sonu\xE7lar\u0131 g\xF6r",scrollArrow:"Daha fazla se\xE7enek i\xE7in kayd\u0131r",keepTyping:"Yazmaya devam et",done:"Tamam",allOption:"T\xFCm\xFC",timeLabel:"Saat",locationSearch:"Bir konum s\xF6yleyin",locationNoResults:"Yer bulunamad\u0131",locationUseTyped:"Yazd\u0131\u011F\u0131n\u0131z\u0131 kullanmak i\xE7in Enter'a bas\u0131n"},id:{language:"id",and:"dan",proceed:"untuk melanjutkan",select:"untuk memilih",skipHint:"untuk melewati",skip:"lewati",skipLabel:"Lewati",products:"Paling cocok",soldOut:"Habis",addToCart:"Tambah ke keranjang",submit:"Cari",seeAllResults:"Lihat semua hasil",scrollArrow:"Gulir untuk melihat opsi lainnya",keepTyping:"Teruskan mengetik",done:"Selesai",allOption:"Semua",timeLabel:"Waktu",locationSearch:"Sebutkan lokasi",locationNoResults:"Tempat tidak ditemukan",locationUseTyped:"Tekan Enter untuk memakai yang Anda ketik"},pl:{language:"pl",and:"i",proceed:"aby kontynuowa\u0107",select:"aby wybra\u0107",skipHint:"aby pomin\u0105\u0107",skip:"pomi\u0144",skipLabel:"Pomi\u0144",products:"Najlepsze dopasowanie",soldOut:"Wyprzedane",addToCart:"Dodaj do koszyka",submit:"Szukaj",seeAllResults:"Zobacz wszystkie wyniki",scrollArrow:"Przewi\u0144, aby zobaczy\u0107 wi\u0119cej opcji",keepTyping:"Pisz dalej",done:"Gotowe",allOption:"Wszystko",timeLabel:"Godzina",locationSearch:"Podaj lokalizacj\u0119",locationNoResults:"Nie znaleziono miejsc",locationUseTyped:"Naci\u015Bnij Enter, aby u\u017Cy\u0107 wpisanego tekstu"},de:{language:"de",and:"und",proceed:"zum Fortfahren",select:"zum Ausw\xE4hlen",skipHint:"zum \xDCberspringen",skip:"\xFCberspringen",skipLabel:"\xDCberspringen",products:"Beste Treffer",soldOut:"Ausverkauft",addToCart:"In den Warenkorb",submit:"Suchen",seeAllResults:"Alle Ergebnisse anzeigen",scrollArrow:"Scrolle f\xFCr weitere Optionen",keepTyping:"Weitertippen",done:"Fertig",allOption:"Alle",timeLabel:"Uhrzeit",locationSearch:"Nenne einen Ort",locationNoResults:"Keine Orte gefunden",locationUseTyped:"Dr\xFCcke Enter, um deine Eingabe zu verwenden"},nl:{language:"nl",and:"en",proceed:"om door te gaan",select:"om te selecteren",skipHint:"om over te slaan",skip:"overslaan",skipLabel:"Overslaan",products:"Beste match",soldOut:"Uitverkocht",addToCart:"In winkelwagen",submit:"Zoeken",seeAllResults:"Alle resultaten bekijken",scrollArrow:"Scrol voor meer opties",keepTyping:"Blijf typen",done:"Klaar",allOption:"Alles",timeLabel:"Tijd",locationSearch:"Noem een locatie",locationNoResults:"Geen plaatsen gevonden",locationUseTyped:"Druk op Enter om je invoer te gebruiken"},sv:{language:"sv",and:"och",proceed:"f\xF6r att forts\xE4tta",select:"f\xF6r att v\xE4lja",skipHint:"f\xF6r att hoppa \xF6ver",skip:"hoppa \xF6ver",skipLabel:"Hoppa \xF6ver",products:"B\xE4sta matchning",soldOut:"Sluts\xE5ld",addToCart:"L\xE4gg i varukorgen",submit:"S\xF6k",seeAllResults:"Visa alla resultat",scrollArrow:"Skrolla f\xF6r fler alternativ",keepTyping:"Forts\xE4tt skriva",done:"Klar",allOption:"Alla",timeLabel:"Tid",locationSearch:"S\xE4g en plats",locationNoResults:"Inga platser hittades",locationUseTyped:"Tryck p\xE5 Enter f\xF6r att anv\xE4nda det du skrev"},nb:{language:"nb",and:"og",proceed:"for \xE5 fortsette",select:"for \xE5 velge",skipHint:"for \xE5 hoppe over",skip:"hopp over",skipLabel:"Hopp over",products:"Beste treff",soldOut:"Utsolgt",addToCart:"Legg i handlekurven",submit:"S\xF8k",seeAllResults:"Se alle resultater",scrollArrow:"Rull ned for \xE5 se flere alternativer",keepTyping:"Fortsett \xE5 skrive",done:"Ferdig",allOption:"Alle",timeLabel:"Tid",locationSearch:"Si et sted",locationNoResults:"Fant ingen steder",locationUseTyped:"Trykk Enter for \xE5 bruke det du skrev"},da:{language:"da",and:"og",proceed:"for at forts\xE6tte",select:"for at v\xE6lge",skipHint:"for at springe over",skip:"spring over",skipLabel:"Spring over",products:"Bedste match",soldOut:"Udsolgt",addToCart:"L\xE6g i kurv",submit:"S\xF8g",seeAllResults:"Se alle resultater",scrollArrow:"Rul for flere muligheder",keepTyping:"Forts\xE6t med at skrive",done:"F\xE6rdig",allOption:"Alle",timeLabel:"Tidspunkt",locationSearch:"Sig et sted",locationNoResults:"Ingen steder fundet",locationUseTyped:"Tryk p\xE5 Enter for at bruge det, du skrev"},fi:{language:"fi",and:"ja",proceed:"jatkaaksesi",select:"valitaksesi",skipHint:"ohittaaksesi",skip:"ohita",skipLabel:"Ohita",products:"Paras vastaavuus",soldOut:"Loppuunmyyty",addToCart:"Lis\xE4\xE4 ostoskoriin",submit:"Hae",seeAllResults:"N\xE4yt\xE4 kaikki tulokset",scrollArrow:"Vierit\xE4 n\xE4hd\xE4ksesi lis\xE4\xE4 vaihtoehtoja",keepTyping:"Jatka kirjoittamista",done:"Valmis",allOption:"Kaikki",timeLabel:"Aika",locationSearch:"Sano sijainti",locationNoResults:"Paikkoja ei l\xF6ytynyt",locationUseTyped:"Paina Enteri\xE4 k\xE4ytt\xE4\xE4ksesi kirjoittamaasi"},ja:{language:"ja",and:"\u3068",proceed:"\u3067\u6B21\u3078",select:"\u3067\u9078\u629E",skipHint:"\u3067\u30B9\u30AD\u30C3\u30D7",skip:"\u30B9\u30AD\u30C3\u30D7",skipLabel:"\u30B9\u30AD\u30C3\u30D7",products:"\u30D9\u30B9\u30C8\u30DE\u30C3\u30C1",soldOut:"\u58F2\u308A\u5207\u308C",addToCart:"\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",submit:"\u691C\u7D22",seeAllResults:"\u3059\u3079\u3066\u306E\u7D50\u679C\u3092\u898B\u308B",scrollArrow:"\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u3066\u4ED6\u306E\u5019\u88DC\u3092\u898B\u308B",keepTyping:"\u5165\u529B\u3092\u7D9A\u3051\u308B",done:"\u5B8C\u4E86",allOption:"\u3059\u3079\u3066",timeLabel:"\u6642\u523B",locationSearch:"\u5834\u6240\u3092\u8A00\u3063\u3066\u304F\u3060\u3055\u3044",locationNoResults:"\u5834\u6240\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",locationUseTyped:"\u5165\u529B\u3057\u305F\u5185\u5BB9\u3092\u4F7F\u3046\u306B\u306F Enter \u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044"},ko:{language:"ko",and:"\uBC0F",proceed:"\uACC4\uC18D",select:"\uC120\uD0DD",skipHint:"\uAC74\uB108\uB6F0\uAE30",skip:"\uAC74\uB108\uB6F0\uAE30",skipLabel:"\uAC74\uB108\uB6F0\uAE30",products:"\uCD94\uCC9C \uC0C1\uD488",soldOut:"\uD488\uC808",addToCart:"\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uB2F4\uAE30",submit:"\uAC80\uC0C9",seeAllResults:"\uBAA8\uB4E0 \uACB0\uACFC \uBCF4\uAE30",scrollArrow:"\uB354 \uB9CE\uC740 \uC635\uC158\uC744 \uBCF4\uB824\uBA74 \uC2A4\uD06C\uB864\uD558\uC138\uC694",keepTyping:"\uACC4\uC18D \uC785\uB825\uD558\uC138\uC694",done:"\uC644\uB8CC",allOption:"\uC804\uCCB4",timeLabel:"\uC2DC\uAC04",locationSearch:"\uC704\uCE58\uB97C \uB9D0\uD558\uC138\uC694",locationNoResults:"\uC7A5\uC18C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",locationUseTyped:"\uC785\uB825\uD55C \uB0B4\uC6A9\uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 Enter\uB97C \uB204\uB974\uC138\uC694"},"zh-CN":{language:"zh-CN",and:"\u548C",proceed:"\u7EE7\u7EED",select:"\u9009\u62E9",skipHint:"\u8DF3\u8FC7",skip:"\u8DF3\u8FC7",skipLabel:"\u8DF3\u8FC7",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u7F44",addToCart:"\u52A0\u5165\u8D2D\u7269\u8F66",submit:"\u641C\u7D22",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7ED3\u679C",scrollArrow:"\u5411\u4E0B\u6EDA\u52A8\u67E5\u770B\u66F4\u591A\u9009\u9879",keepTyping:"\u7EE7\u7EED\u8F93\u5165",done:"\u5B8C\u6210",allOption:"\u5168\u90E8",timeLabel:"\u65F6\u95F4",locationSearch:"\u8BF4\u51FA\u5730\u70B9",locationNoResults:"\u672A\u627E\u5230\u5730\u70B9",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F93\u5165\u7684\u5185\u5BB9"},"zh-TW":{language:"zh-TW",and:"\u548C",proceed:"\u7E7C\u7E8C",select:"\u9078\u64C7",skipHint:"\u7565\u904E",skip:"\u7565\u904E",skipLabel:"\u7565\u904E",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u5B8C",addToCart:"\u52A0\u5165\u8CFC\u7269\u8ECA",submit:"\u641C\u5C0B",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7D50\u679C",scrollArrow:"\u5411\u4E0B\u6372\u52D5\u67E5\u770B\u66F4\u591A\u9078\u9805",keepTyping:"\u7E7C\u7E8C\u8F38\u5165",done:"\u5B8C\u6210",allOption:"\u5168\u90E8",timeLabel:"\u6642\u9593",locationSearch:"\u8AAA\u51FA\u5730\u9EDE",locationNoResults:"\u627E\u4E0D\u5230\u5730\u9EDE",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F38\u5165\u7684\u5167\u5BB9"}},bc={pt:"pt-BR",no:"nb",nn:"nb"};function R(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return Ao[o?"zh-TW":"zh-CN"]}let i=bc[e]??e;return Object.prototype.hasOwnProperty.call(Ao,i)?Ao[i]:hs}function bs(t,e){let n=e.dropdownTrigger??"auto",i=e.closeDropdownOnBlur??!0,s=t.filteredOptionsLength>0||t.activePillHasNoOptions||t.hasProducts;if(t.inEditMode){let a=i?t.isFocused||t.dropdownHeld:!0;return s&&a}if(n==="auto"){let a=i?t.isFocused||t.dropdownHeld:!0,l=t.text.replace(/\s+$/,"").length,u=t.caretOffset==null||t.caretOffset>=l;return(s||t.isLoading)&&a&&u}return n==="manual"?(s||t.isLoading)&&t.pillTapped:!1}function U(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 zn(t){if(!t)return ao();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function yc(t){let e=bt(t);return e?Zr(e):ao()}function Sc(t,e){if(!t)return null;for(let n of e){if(n.parameter!==t||n.type?.kind!=="date_range")continue;let i=Lt(n);if(i&&i.end==null)return i.start}return null}function Tc(t){let e=new Set,n=i=>{i&&e.add(i)};for(let i of t.completedParams??[]){if(i.id===t.editingParam?.id)continue;let o=i.suggestionValueType?.kind;if(o==="date"&&n(Pt(i.metadata?.[un])??Be(i.text)),o==="date_range"){let r=Oe(i);n(r?.start),n(r?.end)}}for(let i of t.identifiedParams??[]){if(i.id===t.editingIdentified?.id)continue;let o=i.type?.kind;if(o!=="date"&&o!=="date_range")continue;let r=Lt(i);n(r?.start),n(r?.end)}return[...e].sort()}function Io(t,e){return t.editingParam!=null&&t.editingAnchor!=null?e:t.text.slice(Pe(t.text,t.completedParams))}var xc=/price/i;function vc(t){return!t||we(t)||D(Y(t))||t.type?.kind==="multi_select"||xc.test(t.parameter)?!1:(t.options??[]).filter(e=>e.is_tappable).length>=2}function Mt(t,e,n){if(e>0)return!1;let i=t.trim();return i===""||i.toLowerCase()===n.trim().toLowerCase()||dt(i,0,n)}var Ec=4;function wc(t,e){let n={text:e,kind:null,is_tappable:!0,selectsAll:!0},i=[...new Set(t.filter(r=>r.is_tappable&&r.image_url).map(r=>r.image_url))].slice(0,Ec);if(i.length>0)return n.image_url=i[0],i.length>1&&(n.imageCollage=i),[n,...t];let o;for(let r of t)r.is_tappable&&(o=r);return o?.icon&&(n.icon=o.icon),o?.icon_svg&&(n.icon_svg=o.icon_svg),[n,...t]}function Pc(t,e){let{composing:n}=t,i=n?.over===t.text?n.text:t.text,o=i.slice(Pe(i,t.completedParams));return e?.completes_word!==!0?o:o.match(/\S+(?=\s*$)/)?.[0]??""}function ys(t,e){let n=an(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(M=>M.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(M=>M.parameter==="placeholder").map(M=>M.text).join(" "),s=Fe(r,e.prependPlaceholder),a=pe(t.text,Math.min(t.filterBase,t.text.length),s),u=a===0&&dt(t.text,t.completedParams.length,s)?"":mt(t.text,a,t.filterInProgress),c=o?.options??[],d=t.editingParam!=null&&t.editingAnchor!=null,f=!d&&!t.editingIdentified&&o?.type?.kind==="multi_select",p,m,g,b;if(d&&t.editingParam&&t.editingAnchor!=null){let M=t.editingParam.id,q=t.completedParams.some(de=>de.id===M),at=t.caretOffset??t.editingAnchor,Q=q?"":t.text.slice(t.editingAnchor,at);m=Q.trim(),g=t.editingParam.options,b=t.editingParam.suggestionParameter,p=t.editingParam.suggestionValueType?.kind==="traditional_autocomplete"?fe(t.editingParam.options,Q).map(de=>({...de,matchedText:m,parameterLabel:oo(de)})):fe(t.editingParam.options,Q)}else m=u.trim(),g=c,b=o?.parameter,p=C(o)?c.map(M=>({...M,matchedText:Pc(t,o),parameterLabel:oo(M)})):fe(c,u,t.traditionalAutocomplete);let T=t.optionSearch,S=T!=null&&b!=null&&T.parameter===b;S&&T.status==="done"&&T.query===m&&(p=g);let P=S&&T.status==="loading",v=e.showNonTappableOptions===!1;v&&(p=p.filter(M=>M.is_tappable));let h=Mt(t.text,t.completedParams.length,s);e.allOption===!0&&o?.leadsWithAll===!0&&!h&&!d&&!t.editingIdentified&&u.trim()===""&&vc(o)&&(p=wc(p,R(e.language).allOption));let x=Io(t,m),w=d?t.editingParam?.suggestionValueType?.kind==="traditional_autocomplete":C(o);!f&&!w&&(p=Hr(p,x));let y=t.editingIdentified,L=d?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,O=y?y.format:Y(L),A=d?t.editingParam?.suggestionParameter:o?.parameter,F=O==="location"&&A&&e.optionOverrides?.[A]?"options":O,I=d&&F==="date-range"?Oe(t.editingParam):null,G=!d&&!y&&F==="date"?Sc(o?.parameter,t.identifiedParams):null,ce=null,oe=null,E=_(F)?Tc(t):[];if(_(F)){let M=W(new Date),q=E.find(hl=>hl>=M)??null,at=U({...t,actionableSuggestions:i}),Q=t.dateViewMonth;ce=Q&&Q.key===at?{year:Q.year,month:Q.month}:y?zn(y.iso):I?zn(I.start):G?zn(G):q&&!d?zn(q):yc(t.editingParam?.text),p=pn(ce);let de=t.pendingRangeStart;F==="date-range"&&de&&de.key===at&&(oe=de.iso)}let ue=null;if(F==="time"){let M=U({...t,actionableSuggestions:i}),q=t.timeDraft;ue=q&&q.key===M?{minutes:q.minutes,touched:!0}:{minutes:cs({editingText:d?t.editingParam?.text:null,options:d?t.editingParam?.options:o?.options}),touched:!1},p=[]}let xe=null;if(F==="location"){let M=U({...t,actionableSuggestions:i}),q=t.locationSearch;if(q&&q.key===M){let{key:at,...Q}=q;xe=Q}else xe={query:d?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};p=[]}let Bt=M=>v?M.is_tappable:!0,ve;if(d){let M=t.editingParam?.options??[];ve=t.editingParam!=null&&M.filter(Bt).length===0}else ve=o!=null&&c.filter(Bt).length===0;ue&&(ve=!0),xe&&(ve=!0);let ot=bs({inEditMode:d||y!=null,filteredOptionsLength:p.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||P,pillTapped:t.pillTapped,activePillHasNoOptions:ve,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),Ut=ot&&t.activeDropdownIndex>=0&&!!p[t.activeDropdownIndex]?.is_tappable,$t=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,Ee=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||P||$t,k=Ee&&t.skeletonOptions!==null,rt=k&&t.skeletonOptions?t.skeletonOptions:p,st=k?t.skeletonSuggestion:null,xr=f?{picked:t.multiSelectDraft?.key===U({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,gl=xr??(k&&t.skeletonSuggestion?.type?.kind==="multi_select"?{picked:t.skeletonPicked??[]}:null);return{segments:n,actionableSuggestions:i,filteredOptions:p,dropdownLoading:Ee,dropdownOptions:rt,dropdownSuggestion:st,skeletonExiting:$t,activeFormatType:F,dateView:ce,dateRangeStart:oe,dateFloor:G,dateReferences:E,timeView:ue,multiSelectView:xr,dropdownMultiSelect:gl,locationView:xe,placeholderText:r,leadInText:s,optionQuery:m,isSearchingOptions:P,isDropdownOpen:ot,isActivePillSelected:Ut}}function jn(t){return t.mode!=="edit"?Cc(t):Ac(t)}function Lc(t,e,n){let i=t.find(C);if(!i?.options)return null;let o=e.slice(Pe(e,n)).trim().toLowerCase();if(!o)return null;let r=i.completes_word===!0?o.split(/\s+/).pop()??"":o,s=i.options.filter(u=>u.is_tappable&&u.text.trim().toLowerCase()===r);if(new Set(s.map(u=>Z(u,i.parameter))).size!==1)return null;let l=s[0];return{suggestion:i,option:l,matchText:l.text.trim()}}function Ss(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,s=n.find(c=>c.parameter!=="placeholder"&&!C(c));if(!s?.options||s.type?.kind==="multi_select")return null;let a=n.filter(c=>c.parameter==="placeholder").map(c=>c.text).join(" "),l=pe(e,i,Fe(a,t.prependPlaceholder)),u=pt(s.options,e,l,o,r===!0);return u?{suggestion:s,option:u,matchText:u.text}:null}function Cc(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?Ss(t):null)??Lc(i,e,n):Ss(t);if(!o)return null;let{suggestion:r,option:s,matchText:a}=o,l=a.toLowerCase(),u=e.toLowerCase().lastIndexOf(l),c=u>=0?u:Math.max(0,e.length-s.text.length),d=c+a.length,f=e.slice(c,d),m=d<e.length&&e[d]===" "?d+1:d,g={id:crypto.randomUUID(),placeholder:"",parameter:Z(s,r.parameter),text:f,value:s.value,kind:s.kind,suggestionParameter:r.parameter,suggestionValueType:r.type,suggestionPlaceholder:r.text,suggestionIcon:r.icon,suggestionIconSvg:r.icon_svg,...t.mode==="submit"&&C(r)?ft(Z(s,r.parameter),r.text,s.parameter_label):{},options:r.options??[],metadata:s.metadata,icon:s.icon,icon_svg:s.icon_svg,image_url:s.image_url};return{patch:{text:e,completedParams:[...n,g],suggestions:i.filter(b=>b!==r),filterBase:m,newParamId:g.id,caretOffset:m,activeDropdownIndex:-1},caretPos:m,option:s,suggestion:r}}function Ac(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(P=>P.id===i.id))return null;let s=e.slice(o,r),a=Zt(i.options,s);if(!a)return null;let l=a.text.toLowerCase(),u=s.toLowerCase().lastIndexOf(l),c=o+Math.max(0,u),d=c+a.text.length,f=e.slice(c,d),p=d<e.length&&e[d]===" "?d+1:d,m=e.length,g={id:crypto.randomUUID(),placeholder:"",...en(i,a),text:f,value:a.value,kind:a.kind,options:i.options,metadata:a.metadata,icon:a.icon,icon_svg:a.icon_svg,image_url:a.image_url},b=n.length,T=0;for(let P=0;P<n.length;P++){let v=re(e,n[P].text,T);if(v!==-1){if(v>=p){b=P;break}T=v+n[P].text.length}}let S=[...n];return S.splice(b,0,g),{patch:{text:e,completedParams:S,newParamId:g.id,filterBase:m,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:m,activeDropdownIndex:-1},caretPos:m,option:a}}function Mo(t){return t.slice(t.search(/\S*$/))}function xs(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function ko(t,e){let n="",i=0;for(let o of t){let r=i;if(n+=xs(o),i+=o.length,n.length>=e.length){if(!n.startsWith(e))return null;let s=i+(t.slice(i).match(/^\p{M}*/u)?.[0].length??0),a=n.length>e.length;return{length:s,partialStart:a?r:s}}if(!e.startsWith(n))return null}return null}function vs(t,e,n,i){let o=[];return e<i&&o.push({text:t.slice(e,i),bold:!0}),i<n&&o.push({text:t.slice(i,n),bold:!0,partial:!0}),o}function Oo(t){return[...t].map(xs).join("")}function kt(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(Oo),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:Oo(o[0])}));for(let o=n.length;o>=1;o--){let r=n.slice(n.length-o),s=r[o-1];for(let a=0;a+o<=i.length;a++){if(!r.slice(0,-1).every((d,f)=>i[a+f].folded===d))continue;let u=i[a+o-1],c=ko(u.text,s);if(c)return{typedWords:o,start:i[a].index,end:u.index+c.length,partialStart:u.index+c.partialStart}}}return null}function Ts(t,e,n,i){return[{text:t.slice(0,e),bold:!1},...vs(t,e,n,i),{text:t.slice(n),bold:!1}].filter(o=>o.text!=="")}function Ic(t,e){let n=0;for(let i of t){if(!/^\p{M}/u.test(i)){let o=ko(t.slice(n),e);if(o)return{start:n,end:n+o.length,partialStart:n+o.partialStart}}n+=i.length}return null}var Oc=/\p{Script=Hangul}/u;function Yn(t,e){let n=e?kt(t,e):null;if(n&&n.typedWords>1)return Ts(t,n.start,n.end,n.partialStart);let i=e?Mo(e):"",o=Oo(i);if(!o)return[{text:t,bold:!1}];let r=[],s=!1;for(let l of t.split(/(\s+)/)){if(l==="")continue;let u=/^\s/.test(l)?null:ko(l,o);if(u){s=!0;let{length:d,partialStart:f}=u;r.push(...vs(l,0,d,f))}let c=u?l.slice(u.length):l;c&&r.push({text:c,bold:!1})}if(s||!Oc.test(i))return r;let a=Ic(t,o);return a?Ts(t,a.start,a.end,a.partialStart):r}var Mc=6e4;function kc(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function Rc(t){return(t??X).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function _c(t){return lt(t)?`Bearer ${await Kt(t).getToken()}`:jt(t)}async function Es(t){try{let e=Rc(t.apiConfig?.endpoint),n=zt(t.apiConfig),i=await _c(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&&kc(o)<=Mc&&{keepalive:!0}})}catch{}}function ye(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var Ro=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function Dc(t,e,n){let i=Ro(t??"");if(i.length===0)return"";let r=Ro(e).slice(-i.length),s=Ro(n).slice(0,i.length);return r.join(" ")===i.join(" ")||s.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function ws(t,e){let n=t.actionableSuggestions[0];if(!n)return null;let i=C(n),o=e.parameter;if(i&&!o)return null;let r=i&&o?o:Z(e,n.parameter),s=i?t.text.length:t.filterBase,a=t.text.slice(0,s),l=a.length===0&&t.text.length===0,u=a.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||u)&&t.placeholderText&&(a=`${t.placeholderText} `);let c=Math.min(Pe(t.text,t.completedParams),a.length),d=!1;if(i&&n.completes_word!==!0){let y=[...a.slice(c).matchAll(/\S+/g)],L=kt(e.text,a.slice(c)),O=y[y.length-(L?.typedWords??1)];a=a.slice(0,O?c+(O.index??0):Math.max(a.lastIndexOf(" ")+1,c))}else if(n.completes_word===!0){let y=[...a.slice(c).matchAll(/\S+/g)],L=y[y.length-1];a=a.slice(0,L?c+(L.index??0):Math.max(a.lastIndexOf(" ")+1,c))}else if(n.completes_word!==!1){let y=a.slice(c),L=Math.max(_r(y,e.text),Cr(y,e));L>0&&(a=a.slice(0,a.length-L)),d=L>0}let f=a.length>0&&a[a.length-1]!==" ",p=i||n.completes_word===!0||d,m=t.activeFormatType!==void 0&&!D(t.activeFormatType)&&D(Y({type:n.type})),g=p||m?"":Dc(n.lead_in,a,e.text),b=`${a}${f?" ":""}${g?`${g} `:""}${e.text} `,S=(l||u||i&&a.length===0)&&b.length>0?b[0].toUpperCase()+b.slice(1):b,P=S.toLowerCase().lastIndexOf(e.text.toLowerCase()),v=P>=0?S.slice(P,P+e.text.length):e.text,h=i?ft(r,n.text,e.parameter_label):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text,suggestionIcon:n.icon,suggestionIconSvg:n.icon_svg},x={id:crypto.randomUUID(),placeholder:"",...h,text:v,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},w=t.actionableSuggestions.length-1;return{patch:{text:S,filterBase:S.length,completedParams:[...t.completedParams,x],newParamId:x.id,caretOffset:S.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(y=>y.text!==e.text).map(y=>y.text),key:i?r:n.parameter,position:ye(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:w}}function Rt(t,e){let n=D(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,i=t.editingParam,o=i?We(i):t.actionableSuggestions[0]??null;return{skeletonOptions:n,skeletonSuggestion:n?o:null,skeletonPicked:n?e??null:null,skeletonRequested:!1}}function Qn(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 Xn=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(s=>s.id===e);if(!i)return;let o=0,r=-1;for(let s of n.completedParams){let a=re(n.text,s.text,o);if(a!==-1){if(s.id===e){r=a;break}o=a+s.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:s}=e===""?Qn(n.text,o,r):{text:n.text.slice(0,o)+e+n.text.slice(r)},a=o+e.length;return this.deps.store.set(l=>({text:s,completedParams:l.completedParams.filter(u=>u.id!==i.id),editingTail:a,caretOffset:a,activeDropdownIndex:-1})),this.deps.scheduleSetCursor(a),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 s=en(i,e);this.deps.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(S=>S.text!==e.text).map(S=>S.text),key:s.suggestionParameter,position:ye(i.options,e.text),chip_origin:"tap"});let a=n.text.slice(0,o),l=n.text.slice(r),u=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,d=l.length===0||l[0]!==" "?`${u} `:u,f=a+d+l,p=f.length,m={id:crypto.randomUUID(),placeholder:"",...s,text:u,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},g=n.completedParams.findIndex(S=>S.id===i.id),b=n.completedParams.filter(S=>S.id!==i.id),T=g>=0?Math.min(g,b.length):b.length;b.splice(T,0,m),this.deps.store.set({text:f,completedParams:b,newParamId:m.id,filterBase:p,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:p,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...Rt(n)}),this.deps.startSelectionAnimationTimer(),this.deps.scheduleSetCursor(p),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=jn({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 Ls=33,Cs=70,As=120,Is=50,Me="data-aia-placeholder-leaving",ze=new WeakMap;function Jn(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function Hc(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Os(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function Ms(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Os(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(()=>Ms(t,e),33+i)}function Ps(t,e){Os(t,e,0),e.timer=setTimeout(()=>Ms(t,e),33)}function ks(t,e){let n=ze.get(t);if(e===""){n&&(Jn(n),ze.delete(t)),t.removeAttribute(Me),delete t.dataset.placeholder;return}if(n?.target===e)return;if(Hc(t)){n&&Jn(n),t.removeAttribute(Me),ze.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&&Jn(n),ze.set(t,i),o){t.setAttribute(Me,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(Me),t.isConnected&&Ps(t,i)},170);return}t.removeAttribute(Me),Ps(t,i)}function Rs(t){let e=ze.get(t);e&&(Jn(e),ze.delete(t))}var Nc={selectedIso:null,selectedRange:null,rangeStart:null};function je(t){if(!_(t.activeFormatType))return Nc;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?Ct(i,o):null,rangeStart:t.dateRangeStart,references:t.dateReferences??[]}}let n=Oe(t.editingParam);return{selectedIso:n?null:Be(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart??t.dateFloor??null,floor:t.dateFloor??null,references:t.dateReferences??[]}}function Zn(t){let e=t.floor!=null&&t.highlightedIso!=null&&t.highlightedIso<t.floor?null:t.highlightedIso;return t.pendingStart?Ct(t.pendingStart,e??t.pendingStart):t.selected}function ei(t,e){if(t==null)return{selected:!1,inRange:!1,reference:!1};let{selectedIso:n,range:i}=e,o=t===n||i!=null&&(t===i.start||t===i.end),r=i!=null&&t>i.start&&t<i.end,s=!o&&!r&&(e.references?.includes(t)??!1);return{selected:o,inRange:r,reference:s}}function ti(t,e,n){return t==null?!1:t<e||n!=null&&t<n}function ni(t,e){return t==="date"?e??null:null}var _o="https://ai-autocomplete.com";function ii(t=_o){try{if(typeof window>"u"||!window.location)return t;let e=window.location.hostname;if(!e)return t;let n=new URL(t);return n.searchParams.set("utm_source",e),n.toString()}catch{return t}}function oi(t,e,n=R()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function ri(t){let e=s=>{s.ctrlKey||_s(s.target,t,s.deltaX,s.deltaY)||s.preventDefault()},n=0,i=0,o=s=>{let a=s.touches[0];a&&(n=a.clientX,i=a.clientY)},r=s=>{if(s.touches.length!==1)return;let a=s.touches[0],l=n-a.clientX,u=i-a.clientY;n=a.clientX,i=a.clientY,s.cancelable&&!_s(s.target,t,l,u)&&s.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 _s(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&Fc(o,i)||n!==0&&Wc(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var Ds=/^(auto|scroll|overlay)$/;function Fc(t,e){return t.scrollHeight<=t.clientHeight||!Ds.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function Wc(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!Ds.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}function Ye(t,e,n){n?(t.getAttribute(e)!=="busy"&&t.setAttribute(e,"busy"),t.getAttribute("aria-busy")!=="true"&&t.setAttribute("aria-busy","true")):t.hasAttribute(e)&&(t.removeAttribute(e),t.removeAttribute("aria-busy"))}var Hs=new WeakMap,Ns=new WeakSet;function $(t,e,n){if(Hs.set(t,n),Ns.has(t))return;Ns.add(t);let i=()=>Hs.get(t),o=r=>{if(!(r instanceof Element))return null;let s=r.closest(e.itemSelector);return s&&t.contains(s)?s:null};e.onClick&&t.addEventListener("click",r=>{let s=o(r.target);s&&e.onClick?.(s,i(),r)}),e.onEnter&&t.addEventListener("mouseenter",r=>{let s=r.target;s instanceof HTMLElement&&s.matches(e.itemSelector)&&e.onEnter?.(s,i(),r)},!0),e.onLeave&&t.addEventListener("mouseleave",r=>{let s=r.target;s instanceof HTMLElement&&s.matches(e.itemSelector)&&e.onLeave?.(s,i(),r)},!0),e.preventMousedown&&t.addEventListener("mousedown",r=>r.preventDefault())}function Se(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function j(t){t.offsetWidth}var ee="magicx-aia-panel-ghost";function ke(t){return t.closest(`.${ee}`)!==null}function B(t,e){for(let n of t.querySelectorAll(e))if(!ke(n))return n;return null}var si="--aia-multi-done-fit";function Fs(t){return B(t,"[data-aia-multi-done]")}function ai(t,e){if(!e?.isConnected)return;let n=e.ownerDocument,i=n.defaultView?.getComputedStyle(e).direction==="rtl";if(typeof n.createRange().getBoundingClientRect!="function")return;let o=e.getBoundingClientRect(),r=0;for(let s of t.querySelectorAll("[data-aia-option]")){if(ke(s))continue;let a=n.defaultView?.getComputedStyle(s),l=Number.parseFloat(i?a?.paddingRight??"0":a?.paddingLeft??"0")||0,u=n.createTreeWalker(s,NodeFilter.SHOW_TEXT),c=n.createRange();for(let d=u.nextNode();d;d=u.nextNode()){if(!d.textContent?.trim())continue;c.selectNodeContents(d);let f=c.getBoundingClientRect();if(f.width===0)continue;let p=i?o.right-f.left:f.right-o.left;r=Math.max(r,p+l)}}r>0?e.style.setProperty(si,`${Math.ceil(r)}px`):e.style.removeProperty(si)}var Ws=40,Vs=340,Bs=340,Us=7,li="--aia-option-enter-delay";function ci(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 s=Math.max(1,Math.ceil(Math.max(0,n)/o));return Math.max(0,s-1-r)*40}function ui(t,e){let n=Math.max(1,Math.floor(e));return(Math.max(1,Math.ceil(Math.max(0,t)/n))-1)*40+340}function di(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function mi(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,s=t.ownerDocument?.visibilityState==="hidden";if(!r||s||di(t))return t.scrollTop=o+e,i(),()=>{};let a=!1,l=n.performance?.now?.()??Date.now(),u=()=>n.performance?.now?.()??Date.now(),c=()=>{if(a)return;let d=Math.min(1,(u()-l)/240),f=1-(1-d)*(1-d);t.scrollTop=o+e*f,d<1?r.call(n,c):i()};return r.call(n,c),()=>{a=!0}}var Ho="magicx-aia-scroll-arrow",_t="data-aia-scroll-arrow",Re="data-aia-visible",No=1e3,Fo=160,Wo="--aia-scroll-arrow-bottom",Gs="Scroll down for more options",Do="data-aia-scrollable",Vc="--aia-scroll-track-top",Bc="--aia-scroll-track-height",Uc="--aia-scroll-track-right",$c="--aia-scroll-thumb-top",Gc="--aia-scroll-thumb-height",qc=12,Kc=.5,zc="[data-aia-products-label]",jc="--aia-option-peek",Yc=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;function Qc(t){let e=t?.trim()??"";if(!Yc.test(e))return 0;let n=Number(e);return Number.isFinite(n)&&n>0?n:0}function Xc(t){let e=t.ownerDocument.createElement("div");e.style.cssText="position:absolute;visibility:hidden;pointer-events:none;padding:0;border:0;height:var(--aia-option-row-height, 37px);",t.appendChild(e);let n=e.offsetHeight;if(e.remove(),Number.isFinite(n)&&n>0)return n;let i=t.querySelector("[data-aia-option]")?.offsetHeight??0;return Number.isFinite(i)&&i>0?i:0}var $s=4,Jc=8;function Zc(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 qs(t=document,e=R()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=Ho,n.setAttribute(_t,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(Zc(t)),n}function eu(t){return Math.max(1,Vo(t.style.gridTemplateColumns))}function pi({dropdown:t,grid:e,button:n}){let i=e.ownerDocument?.defaultView??(typeof window<"u"?window:null),o=!1;n.disabled=!0;let r=null,s=null,a=null,l=null,u=x=>{if(x){if(n.hasAttribute(Re))return;if(n.setAttribute(Re,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),di(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(Re)&&(n.disabled=!1)},No)}else n.removeAttribute(Re),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},c=x=>{let w=0,y=x;for(;y&&y!==t;)w+=y.offsetTop,y=y.offsetParent instanceof HTMLElement?y.offsetParent:null;return w},d=()=>{let x=B(t,zc),w;if(x){let y=c(x)+x.offsetHeight/2;w=t.clientHeight-y-n.offsetHeight/2}else{let y=c(e),L=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;w=t.clientHeight-(y+e.offsetHeight)+(L>0?0:Jc)}n.style.setProperty(Wo,`${Math.max(0,Math.round(w))}px`)},f=x=>{let w=0,y=x;for(;y&&y!==t;)w+=y.offsetLeft,y=y.offsetParent instanceof HTMLElement?y.offsetParent:null;return w},p=null,m=(x,w)=>{let y=Math.min(1,Math.max(0,e.scrollTop/x));n.style.setProperty($c,`${Math.round(w*y)}px`)},g=()=>{let x=e.scrollHeight-e.clientHeight,w=e.querySelector("[data-aia-option][data-aia-loading]")!==null;if(x<=$s||w){p=null,n.removeAttribute(Do);return}let y=e.clientHeight,L=Math.round(y*Kc),O=c(e)+(y-L)/2,A=t.clientWidth-(f(e)+e.offsetWidth),F=Math.min(L,Math.max(qc,Math.round(L*y/e.scrollHeight)));p={overflow:x,travel:L-F},n.style.setProperty(Vc,`${Math.round(O)}px`),n.style.setProperty(Bc,`${L}px`),n.style.setProperty(Uc,`${Math.max(0,Math.round(A))}px`),n.style.setProperty(Gc,`${F}px`),m(x,p.travel),n.setAttribute(Do,"")},b=()=>{if(o||s!==null||a!==null)return;let x=e.querySelector("[data-aia-option][data-aia-loading]")!==null,w=e.scrollHeight-e.clientHeight-e.scrollTop;u(!x&&w>$s)},T=()=>{if(o)return;d(),g();let x=e.getAttribute("data-aia-group")??"";if(x!==r){r=x,u(!1),s!==null&&clearTimeout(s);let w=e.querySelectorAll("[data-aia-option]").length,y=di(e)?0:ui(w,eu(e));s=setTimeout(()=>{s=null,b()},y);return}b()},S=()=>{o||(p&&m(p.overflow,p.travel),s===null&&(u(!1),a!==null&&clearTimeout(a),a=setTimeout(()=>{a=null,b()},Fo)))};e.addEventListener("scroll",S,{passive:!0});let P=x=>x.preventDefault(),v=()=>{let x=i?i.getComputedStyle(e):null,w=x?(Number.parseFloat(x.paddingTop)||0)+(Number.parseFloat(x.paddingBottom)||0):0,y=Qc(x?.getPropertyValue(jc)),L=y>0?Xc(e):0,O=Math.max(1,e.clientHeight-w-y*L);mi(e,O,i,S)};n.addEventListener("mousedown",P),n.addEventListener("click",v);let h=null;return i&&typeof i.ResizeObserver=="function"&&(h=new i.ResizeObserver(()=>{d(),g(),b()}),h.observe(e)),T(),{update:T,destroy(){o||(o=!0,s!==null&&clearTimeout(s),s=null,a!==null&&clearTimeout(a),a=null,l!==null&&clearTimeout(l),l=null,n.disabled=!0,e.removeEventListener("scroll",S),n.removeEventListener("mousedown",P),n.removeEventListener("click",v),h?.disconnect(),n.removeAttribute(Re),n.removeAttribute(Do),n.setAttribute("aria-hidden","true"))}}}var Ks="cubic-bezier(0.25, 0.1, 0.25, 1)",tu="cubic-bezier(0.32, 0.72, 0, 1)",$o=360,Go=280,qo=320,Ko=40,zs="blur(2px)",nu=160,iu=.05,ou=/pressed/i;function js(){return typeof performance<"u"?performance.now():Date.now()}function ru(t){for(let e of t.querySelectorAll("[data-aia-loading]"))if(!e.closest(`.${ee}`))return!0;return!1}function su(t){return t===null?1:1-Math.min(1,Math.max(0,(js()-t)/nu))**1.7}function zo(t){return t.hasAttribute(_t)}function Uo(t){let e=0;for(let n of Array.from(t.children))n.classList.contains(ee)||zo(n)||(e+=n.offsetHeight||0);return e}var te=new WeakMap;function au(t){return(Number.parseFloat(t.borderLeftWidth)||0)+(Number.parseFloat(t.borderRightWidth)||0)}function lu(t){let e=(t.ownerDocument.defaultView??window).getComputedStyle(t);return(Number.parseFloat(e.paddingLeft)||0)+(Number.parseFloat(e.paddingRight)||0)+(Number.parseFloat(e.borderLeftWidth)||0)+(Number.parseFloat(e.borderRightWidth)||0)}var Bo=new WeakMap;function cu(t,e){return!e||typeof t.animate!="function"||t.closest('[data-animations="off"]')||t.closest('[data-aia-options-style="classic"]')?!1:!(t.ownerDocument.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)")??null)?.matches}function uu(t,e){let n=0,i="";for(let o of Array.from(t.children))o.classList.contains(ee)||(n+=1+o.getElementsByTagName("*").length,i+=`${o.textContent??""}\0`);return`${e??""}${n}${i}`}function du(t){let e=t.ownerDocument.createElement("div");e.className=ee,e.setAttribute("aria-hidden","true"),e.inert=!0;for(let n of Array.from(t.children))n.classList.contains(ee)||zo(n)||e.appendChild(n.cloneNode(!0));for(let n of[e,...Array.from(e.querySelectorAll("*"))]){n.removeAttribute("id"),n.removeAttribute("role"),n.removeAttribute("tabindex");for(let i of Array.from(n.classList))ou.test(i)&&n.classList.remove(i);n.tagName==="A"&&n.removeAttribute("href"),n.tagName==="BUTTON"&&(n.disabled=!0);for(let i of Array.from(n.attributes))i.name.startsWith("aria-")&&i.name!=="aria-hidden"&&n.removeAttribute(i.name)}return e}function mu(t,e,n,i,o){for(let s of Array.from(t.children))s.classList.contains(ee)&&s.remove();let r=Array.from(t.children).filter(s=>!zo(s));i>iu&&fu(t,e,n,i,o);for(let s of r)pu(s),s.animate([{opacity:0,filter:zs},{opacity:1,filter:"blur(0px)"}],{duration:qo,delay:Ko,easing:Ks,fill:"backwards"})}function pu(t){for(let e of t.querySelectorAll("[data-aia-pill]"))if(!(e.hasAttribute("data-aia-loading")||typeof e.getAnimations!="function"))for(let n of e.getAnimations())n.cancel()}function fu(t,e,n,i,o){let r=(t.ownerDocument.defaultView??window).getComputedStyle(t);e.style.cssText=["position:absolute","left:0",o>0?`width:${o-au(r)}px`:"right:0",n?"bottom:0":"top:0",`padding:${r.padding}`,"pointer-events:none","box-sizing:border-box"].join(";"),t.appendChild(e),e.animate([{opacity:i,filter:"blur(0px)"},{opacity:0,filter:zs}],{duration:Go*i,easing:Ks,fill:"forwards"}).finished.then(()=>e.remove(),()=>e.remove())}function fi(t){let e=t[0]?.text;return e==null||e===""?null:e}function Dt(t,e,n){let i=n.visible,o=cu(t,n.enabled??!0),r=te.get(t);if(!i||!o){o||r?.glide?.cancel(),te.set(t,{height:0,width:0,key:i?e:null,signature:"",snapshot:null,glide:o?r?.glide??null:null,loadingSince:null,contentHeight:0});return}let s=uu(t,e),a=ru(t)?r?.loadingSince??js():null;if(r&&r.height>0&&r.glide&&r.signature===s){r.loadingSince=a;return}let l=se(t),u=t.getBoundingClientRect(),c=u.height;r?.glide?.cancel();let d=t.getBoundingClientRect(),f=d.height,p=d.width||0,m=null,g=r?l?c:r.height:0,b=r?l?u.width||0:r.width:0;r&&g>0&&(e!==r.key&&r.snapshot&&mu(t,r.snapshot,n.anchorBottom??!1,su(r.loadingSince),b),m=Ys(t,{height:g,width:b},{height:f,width:p}));let T=null;e!==null&&(T=r&&r.signature===s&&r.snapshot&&!r.snapshot.isConnected?r.snapshot:du(t)),te.set(t,{height:f,width:p,key:e,signature:s,snapshot:T,glide:m,loadingSince:a,contentHeight:m?Uo(t):0})}function Ys(t,e,n){let i=e.width>0&&n.width>0&&Math.abs(e.width-n.width)>1;if(Math.abs(e.height-n.height)<=1&&!i)return null;let o=i?[{height:`${e.height}px`,width:`${e.width}px`},{height:`${n.height}px`,width:`${n.width}px`}]:[{height:`${e.height}px`},{height:`${n.height}px`}],r=t.animate(o,{duration:$o,easing:tu});i&&(t.setAttribute(qn,String(n.width)),n.width>e.width?t.style.setProperty(Ot,`${n.width-lu(t)}px`):t.style.removeProperty(Ot),Bo.set(t,r));let s=()=>{Bo.get(t)===r&&(Bo.delete(t),t.removeAttribute(qn),t.style.removeProperty(Ot))};return r.finished.then(()=>{s();let a=te.get(t);if(a?.glide!==r||(a.glide=null,a.height<=0))return;let l=t.getBoundingClientRect();l.height>0&&(a.height=l.height),l.width>0&&(a.width=l.width)},s),r}function se(t){let e=te.get(t)?.glide??null;return e&&(e.playState==="running"||e.pending)?e:null}function gi(t){if(!se(t))return null;let e=te.get(t)?.height??0;return e>0?e:null}function hi(t,e){let n=te.get(t);n&&n.height>0&&!se(t)&&e>0&&(n.height=e)}function Qs(t,{widthChanged:e}){let n=te.get(t);if(!n||n.height<=0)return;let i=se(t);if(!i||!e&&(t.hasAttribute("data-aia-fit")||Math.abs(Uo(t)-n.contentHeight)<=1))return;let o=t.getBoundingClientRect();i.cancel();let r=t.getBoundingClientRect();n.width=r.width||0,n.height=r.height,n.glide=Ys(t,{height:o.height,width:o.width||0},{height:r.height,width:n.width}),n.contentHeight=n.glide?Uo(t):0}function bi(t){te.get(t)?.glide?.cancel(),te.delete(t)}var jo="data-aia-hug",Qe="--aia-panel-fit-width",Yo="data-aia-full-width",gu=36;function Xe(t){t.removeAttribute(jo)}function Qo(t,e,{eligible:n,loading:i}){let o=t.style.getPropertyValue(Qe);hu(t,e,n,i),Qs(t,{widthChanged:t.style.getPropertyValue(Qe)!==o})}function hu(t,e,n,i){if(!n){t.style.removeProperty(Qe),Xe(t);return}if(i){t.style.getPropertyValue(Qe)&&t.setAttribute(jo,"");return}let o=bu(t,e);if(o==null){t.style.removeProperty(Qe);return}t.style.setProperty(Qe,`${o}px`),t.setAttribute(jo,"")}var Xs=new WeakMap;function bu(t,e){if(Ke())return null;let n=B(e,".aia-grid");if(!n||t.offsetWidth===0)return null;let i=B(e,"[data-aia-pillbar]"),o=[n.style.gridTemplateColumns,i?.textContent??"",...Array.from(n.querySelectorAll("[data-aia-option]"),a=>a.textContent)].join("\0"),r=Xs.get(t);if(r?.key===o)return r.width;let s=yu(t,e,n);return Xs.set(t,{key:o,width:s}),s}function yu(t,e,n){let i=qe(n);if(!i||i.rowWidths.some(a=>a<=0))return null;let o=Math.ceil(Math.max(...i.rowWidths)),r=Math.max(1,Vo(n.style.gridTemplateColumns)),s=Js(n,t,r-1)+r*(o+gu);return Math.ceil(Math.max(s,Su(e,t)))}function Su(t,e){let n=B(t,"[data-aia-pillbar]");if(!n)return 0;let i=n.querySelector("[data-aia-pill-scroll]")?.scrollWidth??0,o=n.querySelector("[data-aia-skip]")?.offsetWidth??0;return i+o===0?0:Js(n,e,i>0&&o>0?1:0)+i+o}function Vo(t){let e=0,n=0,i=!1;for(let o of t)o==="("?e++:o===")"&&e--,e===0&&/\s/.test(o)?i=!1:i||(i=!0,n++);return n}function Js(t,e,n){let i=0;for(let o=t;o;o=o.parentElement){let r=getComputedStyle(o);if(i+=(Number.parseFloat(r.paddingLeft)||0)+(Number.parseFloat(r.paddingRight)||0)+(Number.parseFloat(r.borderLeftWidth)||0)+(Number.parseFloat(r.borderRightWidth)||0),o===t&&(i+=n*(Number.parseFloat(r.columnGap)||0)),o===e)break}return i}var Tu="[data-aia-products], [data-aia-datepicker], [data-aia-date-grid], [data-aia-time-wheel], [data-aia-location], [data-aia-see-all]";function Zs(t){let e=!t.hasAttribute("data-aia-has-products")&&!t.hasAttribute(Yo)&&B(t,".aia-grid [data-aia-option]")!==null&&B(t,Tu)===null,n=B(t,".aia-grid [data-aia-option][data-aia-loading]")!==null;e||Xe(t),Qo(t,t,{eligible:e,loading:n})}var ea="data-aia-key";function ne(t,e,n){let i=new Map;for(let s of Array.from(t.children)){let a=s.getAttribute(ea);a!=null&&i.set(a,s)}let o=new Set,r=[];for(let s=0;s<e.length;s++){let a=e[s],l=n.keyOf(a,s);o.add(l);let u=i.get(l);u||(u=n.create(a,s),u.setAttribute(ea,l)),n.update?.(u,a,s),t.children[s]!==u&&t.insertBefore(u,t.children[s]??null),r.push(u)}for(let[s,a]of i)o.has(s)||a.remove();return r}function ta(t,e){if(!e.interactive)return null;let n=e.options[Se(t)];return n?.is_tappable?n:null}var xu={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=ta(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")&&ta(t,e)&&e.callbacks.onHighlight(Se(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,Se(t))}};function ia(t,e,n,i,o,r,s,a=!0){let l=t.querySelector(".magicx-aia-datepicker");if(!o||e.length===0){l?.remove();return}if(!l){l=wu(),t.appendChild(l),j(l);for(let d of l.querySelectorAll(".magicx-aia-datepicker-nav"))d.disabled=!1}$(l,xu,{options:e,callbacks:s,interactive:a});let u=l.querySelector(".magicx-aia-datepicker-month");u&&(u.textContent=dn(o));let c=l.querySelector(".magicx-aia-datepicker-grid");c&&vu(c,e,n,i,r)}function vu(t,e,n,i,o){let r=W(new Date),s=Zn({pendingStart:o.rangeStart,highlightedIso:K(e[n]),selected:o.selectedRange,floor:o.floor});ne(t,e,{keyOf:(a,l)=>K(a)??`pad-${l}`,create:a=>Eu(a),update:(a,l,u)=>{let c=K(l),d=ei(c,{selectedIso:o.selectedIso,range:s,references:o.references}),f=u===n&&l.is_tappable;a.id=`${i}-option-${u}`,a.dataset.aiaIndex=String(u),a.setAttribute("aria-selected",String(f)),a.classList.toggle("magicx-aia-date-cell--past",ti(c,r,o.floor)),a.classList.toggle("magicx-aia-date-cell--highlighted",f),a.classList.toggle("magicx-aia-date-cell--today",c!=null&&c===r),a.classList.toggle("magicx-aia-date-cell--selected",d.selected),a.classList.toggle("magicx-aia-date-cell--in-range",d.inRange),a.classList.toggle("magicx-aia-date-cell--reference",d.reference)}})}function Eu(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=fn(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 wu(){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(na("prev","Previous month","\u2039"),n,na("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of ht){let s=document.createElement("span");s.className="magicx-aia-datepicker-weekday",s.textContent=r,i.appendChild(s)}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 na(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 Pu='<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>',oa="data-aia-location-body";function Lu(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=Pu;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 Cu(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 ra(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(oa)!==r){for(let a of Array.from(t.children))a.hasAttribute("data-aia-location-row")||a.remove();let s=Cu(r,n);s&&t.appendChild(s),t.setAttribute(oa,r)}ne(t,o,{keyOf:(s,a)=>`${a}:${s.id}`,create:s=>Lu(s),update:(s,a,l)=>{let u=l===e.highlighted;s.classList.toggle("magicx-aia-location-row--highlighted",u),s.setAttribute("aria-selected",String(u)),s.setAttribute("data-aia-index",String(l)),s.id=i(l)}})}var ae=new WeakMap,Au=0,_e=new WeakMap,Iu='<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>',De=t=>gn(t.input)===t.input;function sa(t,e){let n=gn(t);if(n instanceof HTMLElement&&n!==e.input&&n!==H(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=Ce(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Ou(t,e,n){if(!(!(n instanceof HTMLElement)||n===e.returnTo||t.contains(n))&&n!==H(t).body&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=Ce(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Mu(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=yt(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=H(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var ku={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&Je(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function Je(t,e=!1){let n=_e.get(t),i=ae.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&De(n)&&(n.returning=!0,Mu(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function Ru(t){let e=_e.get(t),n=ae.get(t);if(!(!e||!n||De(e))){if(sa(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!De(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function _u(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++Au}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=Iu;let i=document.createElement("input");i.type="text",i.className="magicx-aia-location-input",i.setAttribute("data-aia-location-input",""),i.setAttribute("autocomplete","off"),i.setAttribute("autocapitalize","words"),i.setAttribute("enterkeyhint","done"),i.spellcheck=!1,i.placeholder=e.locationSearch,i.setAttribute("aria-label",e.locationSearch),n.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-location-results",o.setAttribute("data-aia-location-results",""),o.setAttribute("aria-live","polite"),t.append(n,o);let r={input:i,field:n,results:o,returnTo:null,returnRange:null,returning:!1,declined:!1,widgetFocused:!1,wasReediting:!1};return t.addEventListener("mousedown",s=>{!(s.target instanceof Node)||!n.contains(s.target)||(s.stopPropagation(),sa(t,r),ae.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>ae.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",s=>{Ou(t,r,s.relatedTarget),ae.get(t)?.callbacks.onLocationFocusChange(!0)}),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,ae.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",s=>{let a=ae.get(t);if(!(!a||s.isComposing))switch(s.key){case"ArrowDown":case"ArrowUp":s.preventDefault(),a.callbacks.onLocationMove(s.key==="ArrowDown"?1:-1);return;case"Enter":if(s.preventDefault(),!a.interactive)return;Je(t,!0),a.callbacks.onLocationCommit();return;case"Escape":s.preventDefault(),s.stopPropagation(),r.declined=!0,Je(t);return;case"Backspace":if(i.value!=="")return;s.preventDefault(),r.declined=!0,Je(t);return}}),_e.set(t,r),r}function aa(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=_e.get(e);n&&(De(n)&&Je(e),n.declined=!1,n.input.tabIndex=-1)}}function la(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=_e.get(r);l&&De(l)&&Je(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let s=_e.get(r)??_u(r,n);s.input.tabIndex=0,ae.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),$(s.results,ku,ae.get(r)),s.input.value!==e.query&&!De(s)&&(s.input.value=e.query);let a=l=>`${r?.id}-row-${l}`;if(ra(s.results,e,n,a),e.highlighted>=0&&e.highlighted<e.places.length?s.input.setAttribute("aria-activedescendant",a(e.highlighted)):s.input.removeAttribute("aria-activedescendant"),o.inputFocused){let l=o.reediting??!1;l&&!s.wasReediting&&(s.declined=!1),s.wasReediting=l}if(s.widgetFocused=o.inputFocused??!1,o.inputFocused){if(o.reediting&&!s.declined&&o.interactive!==!1&&!De(s)){let l=r;queueMicrotask(()=>{l.isConnected&&!_e.get(l)?.declined&&Ru(l)})}}else{let l=s;setTimeout(()=>{if(l.widgetFocused)return;let u=l.returnTo;u&&gn(u)===u||(l.declined=!1)},0)}}var Du={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},ca=[125,69];function ua(t,e){return e?1:t===0?.7:t===1?.4:.2}function yi(t,e,n,i,o=!1,r=!1,s=!1){let a=t.querySelector(".magicx-aia-pill-list");if(a||(a=document.createElement("span"),a.className="magicx-aia-pill-list",t.appendChild(a)),$(a,Du,{onSelectPill:i,loading:r}),r&&e.length===0){a.setAttribute("data-aia-pill-list-loading",""),a.innerHTML="";for(let l=0;l<ca.length;l++){let u=ca[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=`${u}px`,c.style.setProperty("--aia-pill-opacity",String(ua(l,!1))),a.appendChild(c)}return}r?a.setAttribute("data-aia-pill-list-loading",""):a.removeAttribute("data-aia-pill-list-loading");for(let l of a.querySelectorAll("[data-aia-pill-skeleton]"))l.remove();ne(a,e,{keyOf:l=>`${l.type?.kind??""}|${we(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let u=document.createElement("button");if(u.type="button",u.tabIndex=-1,u.setAttribute("data-aia-pill",""),u.setAttribute("contenteditable","false"),we(l)){u.setAttribute("data-aia-smart-suggestion",C(l)?"header":"");let c=document.createElement("span");c.className="magicx-aia-smart-suggestion-text",c.textContent=l.text;let d=document.createElement("span");d.className="magicx-aia-smart-suggestion-sparkle",d.innerHTML=on,u.append(c,d)}else u.textContent=l.text;return u.disabled=!0,u},update:(l,u,c)=>{let d=l,f=s&&c===n&&!r,p=["magicx-aia-pill"];o&&p.push("magicx-aia-pill--rounded"),r&&p.push("magicx-aia-pill--skeleton"),d.className=p.join(" "),d.style.width="",d.style.setProperty("--aia-pill-opacity",String(ua(c,f))),d.dataset.aiaPillIndex=String(c),d.toggleAttribute("data-aia-pill-active",c===n),r?d.setAttribute("data-aia-loading",""):d.removeAttribute("data-aia-loading")}}),j(a);for(let l of a.querySelectorAll("[data-aia-pill]"))l.disabled=r}function Xo(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var da=32;function Jo(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,s=n;return e.deltaMode===1?s*=32:e.deltaMode===2&&(s*=t.clientWidth),Math.max(0,Math.min(o,r+s))}function Si(t){let e=n=>{let i=Jo(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var ma=Intl.Segmenter,pa=ma?new ma(void 0,{granularity:"grapheme"}):null;function Ti(t){let e=t.trim().normalize("NFC").toUpperCase();if(pa)for(let n of pa.segment(e))return n.segment;return Array.from(e)[0]??"?"}var xi=120,fa=360;function Hu(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 Zo(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=Hu(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 er(t,e){let n=Zo(t,e);return n===t?[t]:[n,t]}function vi(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 Ht(t){let e=t?.trim();return e?er(e,360):[]}function ga(t){return Ht(t)[0]}var Ei=new WeakMap,nr=new WeakMap,ba=new WeakMap;function ya(t,e,n,i,o,r="row",s="image",a=R(),l,u=!0,c=null){let d=t.querySelector(".magicx-aia-products");if(e.length===0){d?.remove();return}if(!d){d=document.createElement("section"),d.className="magicx-aia-products",d.setAttribute("data-aia-products",""),d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${n}-products-label`);let m=document.createElement("div");m.className="magicx-aia-products-label",m.id=`${n}-products-label`,m.setAttribute("data-aia-products-label",""),m.textContent=a.products;let g=document.createElement("div");g.className="magicx-aia-products-row",g.setAttribute("data-aia-products-row",""),Si(g),d.append(m,g),t.appendChild(d)}d.setAttribute("data-aia-products-layout",r);let f=d.querySelector(".magicx-aia-products-label");f&&f.textContent!==a.products&&(f.textContent=a.products);let p=d.querySelector(".magicx-aia-products-row");if(p){ne(p,e,{keyOf:m=>Bu(m,!!l),create:m=>Uu(m,i,o,s,a,l),update:(m,g,b)=>{Ei.set(m,g),Nu(m,u?g.vendor:void 0),Fu(m,g.price,g.compareAtPrice),m.id=`${n}-product-${b}`,m.dataset.aiaIndex=String(b),ba.get(m)?.(s),Ye(m,"data-aia-product-state",g.id===c);let T=m.querySelector(".magicx-aia-product-badge");T&&T.textContent!==a.soldOut&&(T.textContent=a.soldOut);let S=m.querySelector(".magicx-aia-product-cart");S&&S.setAttribute("aria-label",Sa(g,a))}}),j(p);for(let m of p.querySelectorAll("[data-aia-product]")){let g=nr.get(m);g&&(nr.delete(m),g())}}}function ir(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)ke(i)||(i.tabIndex=e?0:-1)}function Nu(t,e){let n=t.querySelector(".magicx-aia-product-vendor");if(!e){n?.remove();return}n||(n=document.createElement("span"),n.className="magicx-aia-product-vendor",t.querySelector(".magicx-aia-product-title")?.before(n)),n.textContent!==e&&(n.textContent=e)}function Fu(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 ha(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 Sa(t,e){return`${e.addToCart}: ${t.title}`}var tr="http://www.w3.org/2000/svg";function Wu(){let t=document.createElementNS(tr,"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(tr,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(tr,"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 Vu(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",Sa(e,o)),r.tabIndex=0,r.appendChild(Wu());let s=a=>{a.preventDefault(),a.stopPropagation(),r.getAttribute("data-aia-cart-state")!=="adding"&&(r.setAttribute("data-aia-cart-state","adding"),r.setAttribute("aria-busy","true"),n(Ei.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",a=>{a.key!=="Enter"&&a.key!==" "||s(a)}),r.addEventListener("focus",()=>i(!0)),r.addEventListener("blur",a=>{a.relatedTarget?.closest("[data-aia-dropdown]")||i(!1)}),{el:r,arm:()=>r.addEventListener("click",s)}}function Bu(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 Uu(t,e,n,i,o,r){let s=document.createElement("a");s.className="magicx-aia-product",s.setAttribute("data-aia-product",""),s.setAttribute("role","option"),s.setAttribute("aria-selected","false"),s.tabIndex=0;let a=document.createElement("span");a.className="magicx-aia-product-media",a.setAttribute("data-aia-product-media",""),a.setAttribute("aria-hidden","true");let l=Ht(t.imageUrl),u=l[0],c=!!u,d=()=>{a.replaceChildren(),a.removeAttribute("data-aia-image-loaded"),a.toggleAttribute("data-aia-product-placeholder",i==="image"),a.toggleAttribute("data-aia-product-initial",i==="initial"),i==="initial"&&(a.textContent=Ti(t.title))};if(ba.set(s,g=>{g!==i&&(i=g,c||d())}),u){let g=document.createElement("img"),b=0;g.onload=()=>{a.setAttribute("data-aia-image-loaded",""),ha(s,vi(g.naturalWidth,g.naturalHeight))},g.onerror=()=>{let T=l[++b];if(T){g.src=T;return}c=!1,ha(s,null),d()},g.className="magicx-aia-product-image",g.src=u,g.alt="",g.loading="lazy",g.decoding="async",a.appendChild(g)}else d();s.appendChild(a);let f=document.createElement("span");f.className="magicx-aia-product-body";let p=document.createElement("span");if(p.className="magicx-aia-product-title",p.textContent=t.title,f.appendChild(p),t.available===!1){s.setAttribute("data-aia-product-sold-out","");let g=document.createElement("span");g.className="magicx-aia-product-badge",g.textContent=o.soldOut,f.appendChild(g)}s.appendChild(f);let m=r&&t.available!==!1?Vu(s,t,r,n,o):null;return m&&(s.setAttribute("data-aia-product-has-cart",""),s.appendChild(m.el)),nr.set(s,()=>{m?.arm(),t.url&&(s.href=t.url),s.addEventListener("click",g=>{g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||g.button!==0||(g.preventDefault(),e(Ei.get(s)??t))})}),s.addEventListener("keydown",g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),e(Ei.get(s)??t))}),s.addEventListener("focus",()=>n(!0)),s.addEventListener("blur",g=>{g.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),s}var Ta=10,xa=44;function wi(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 a=Math.min(o.left-10,i.right-44);return n.clientX>=a}let s=Math.max(o.right+10,i.left+44);return n.clientX<=s}var le="data-aia-fit",Nt="--aia-dropdown-fit-height",va=8,$u=160;function Pi({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,s=null,a=null,l=null,u=!1,c=()=>{t.removeAttribute(le),t.style.removeProperty(Nt)},d=()=>{if(se(t)){u=!0;return}u=!1,hi(t,t.getBoundingClientRect().height)},f=S=>`${r}|${(S??t).scrollHeight}|${t.offsetWidth}`,p=S=>a?.key===f(S)?a.height:null,m=S=>{let P=f(S);if(a?.key===P)return a.height;let v=S?.scrollTop??0;t.removeAttribute(le);let h=t.offsetHeight;return t.setAttribute(le,""),S&&v&&(S.scrollTop=v),a={key:P,height:h},h},g=()=>{if(i)return;if(!e()){o=!1;return}let S=se(t),P=S?gi(t):null;S&&l!==S&&(l=S,S.finished.then(b,b)),!S&&u&&d(),o||(o=!0,c());let v=t.hasAttribute(le),h=B(t,".aia-grid")?.getAttribute("data-aia-group")??null,x=h!==r;r=h;let w=qu(t,n);if(w===null)return;let y=Gu(t);if(v){let A=S?p(y):m(y);if(A!==null&&A<=w){c(),d();return}}else if((P??t.offsetHeight)<=w)return;let L=`${Math.max($u,Math.floor(w))}px`,O=t.style.getPropertyValue(Nt)!==L;O&&t.style.setProperty(Nt,L),v?x&&y&&(y.scrollTop=0):t.setAttribute(le,""),(O||!v)&&d()},b=()=>{i||s!==null||!n||(s=n.requestAnimationFrame(()=>{s=null,g()}))},T=n?.visualViewport??null;return T?.addEventListener("resize",b),T?.addEventListener("scroll",b),n?.addEventListener("resize",b),n?.addEventListener("scroll",b,{capture:!0,passive:!0}),g(),{update:g,destroy(){i||(i=!0,s!==null&&n?.cancelAnimationFrame(s),T?.removeEventListener("resize",b),T?.removeEventListener("scroll",b),n?.removeEventListener("resize",b),n?.removeEventListener("scroll",b,{capture:!0}))}}}function Gu(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function qu(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,s=r?r.getBoundingClientRect().top:0,a=r?s+t.offsetTop:t.getBoundingClientRect().top;return t.closest("[data-options-position]")?.getAttribute("data-options-position")==="above"?(r?a+t.offsetHeight:t.getBoundingClientRect().bottom)-i-va:i+o-a-va}var Li=.5;function Ku(t,e){let n=Math.max(0,t.scrollHeight-t.clientHeight),i=t.clientHeight-t.coverTop-t.coverBottom,o=t.scrollTop+t.coverTop,r=e.top+e.height,s=t.scrollTop;return e.top<o-Li||e.height>i+Li?s=Math.floor(e.top-t.coverTop):r>o+i+Li&&(s=Math.ceil(r-t.coverTop-i)),Math.min(n,Math.max(0,s))}var Ea=new WeakMap;function wa(t){let e=Ea.get(t);if(e)return e;let n={shown:-1,byPointer:-1,held:!1,x:null,y:null,cancel:null};Ea.set(t,n);let i=o=>Pa(n,o);for(let o of["mouseover","mouseout","mousemove"])t.addEventListener(o,i,{capture:!0,passive:!0});return n}function Pa(t,e){e.screenX===t.x&&e.screenY===t.y||(t.held=!1,t.x=e.screenX,t.y=e.screenY)}function Ft(t,e,n){if(!t)return!0;let i=wa(t);return Pa(i,n),i.held?!1:(i.byPointer=e,!0)}function zu(t){if(t.scrollHeight-t.clientHeight>1)return t;let e=t.closest(".aia-stack");return e?.parentElement?.hasAttribute(le)&&e.scrollHeight-e.clientHeight>1?e:null}function ju(t,e){let n=t.getBoundingClientRect(),i=e.getBoundingClientRect();if(!(n.height>0)||!(i.height>0))return null;let o=t.offsetHeight>0?n.height/t.offsetHeight:1,r=t.ownerDocument.defaultView?.getComputedStyle(t);return{box:{scrollTop:t.scrollTop,clientHeight:t.clientHeight,scrollHeight:t.scrollHeight,coverTop:Number.parseFloat(r?.paddingTop??"")||0,coverBottom:Number.parseFloat(r?.paddingBottom??"")||0},row:{top:(i.top-n.top)/o-t.clientTop+t.scrollTop,height:i.height/o}}}function Ci(t,e){let n=wa(t);if(e===n.shown)return;let i=e===n.byPointer;if(n.byPointer=-1,e<0||i){n.shown=e;return}let o=t.querySelectorAll("[data-aia-option]")[e];if(!o||!(t.getBoundingClientRect().height>0))return;n.shown=e,n.cancel?.(),n.cancel=null;let r=zu(t),s=r?ju(r,o):null;if(!r||!s)return;let a=Ku(s.box,s.row);Math.abs(a-r.scrollTop)<Li||(n.held=!0,n.cancel=mi(r,a-r.scrollTop,r.ownerDocument.defaultView,()=>{n.cancel=null}))}var La="http://www.w3.org/2000/svg",Yu=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function Qu(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 Xu=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],Ju=/^[a-zA-Z0-9#.,%\s()-]+$/;function Zu(t){let e=[];for(let n of Xu){let i=t.getAttribute(n);i===null||!Ju.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function Ca(t){for(let e of Array.from(t.attributes))Qu(e.name,e.value)&&t.removeAttribute(e.name);Zu(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!Yu.has(n.localName)||n.namespaceURI!==La?n.remove():Ca(n)}else e.remove()}function ie(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!==La||e.getElementsByTagName("parsererror").length>0?null:(Ca(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function Wt(t){return t.text}function Te(t){return Ze(t)[0]??null}function Ze(t){let e=ed(t);return e?er(e,120):[]}function ed(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 et(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var or={one:"item",other:"items"};function Aa(t,e=or){let n=et(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function rr(t){return Te(t.image_url)!==null}var Ai=new Map;function td(t){let e=t.icon_svg;if(!e)return!1;let n=Ai.get(e);return n===void 0&&(n=ie(e)!==null,Ai.size>=256&&Ai.clear(),Ai.set(e,n)),n}function Ii(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&rr(i)||e&&td(i))}var Ia=new WeakMap;function nd(t,e,n){let i=e.length,o=Ke(),r=Ia.get(t),s=n&&r&&Kn(r.options,e)?r.plan:null,a=!s&&!n&&$n(i,o)?qe(t):null,l=s??Gn(i,o,a?.rowWidths??null,a?.gridWidth??null);return n||Ia.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((u,c)=>{u.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(c))}),l.cols}function Oa(t,e){if(e.loading||!e.interactive)return null;let n=e.options[Se(t)];return n?.is_tappable?n:null}var id={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=Oa(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!wi(t,o,n);if(o){let s=r||t.getAttribute("aria-selected")!=="true";t.setAttribute("aria-selected",String(s)),o.dataset.checked=String(s),o.textContent=s?"\u2713":""}r?e.onSelect(i,{commit:!0}):e.onSelect(i),setTimeout(()=>t.classList.remove("magicx-aia-option--pressed"),170)},onEnter:(t,e,n)=>{if(!Oa(t,e))return;let i=Se(t);Ft(t.closest(".aia-grid"),i,n)&&e.onHighlight(i)},onLeave:(t,e,n)=>{Ft(t.closest(".aia-grid"),-1,n)&&e.onHighlight(-1,Se(t))}};function Ma(t,e,n,i,o,r,s,a="",l="below",u=!0,c=!0,d=!0,f=!0,p){let m=t.querySelector(".aia-grid");if(e.length===0){m?.remove();return}m||(m=document.createElement("div"),m.className="aia-grid magicx-aia-grid",m.setAttribute("data-scroll",""),m.style.setProperty("--aia-grid-min","250px"),m.style.setProperty("--aia-grid-max","1fr"),m.style.setProperty("--aia-grid-gap","0"),t.appendChild(m)),$(m,id,{options:e,onSelect:i,onHighlight:o,loading:s,interactive:f});let g=m.dataset.aiaGroup!==a;m.dataset.aiaGroup=a;let b=Ii(e,u,c);od(m,e,n,r,s,{showIcons:u&&b,showImages:c&&b,showCounts:d,picked:p});let T=nd(m,e,s);rd(m,e.length,T,s,l),g&&(m.scrollTop=0),Ci(m,s?-1:n)}function od(t,e,n,i,o,r){let s=o?"1":"0",a=t.dataset.aiaGroup??"",{showIcons:l,showImages:u,showCounts:c}=r,d=l?m=>m.icon??m.icon_svg??"":()=>"",f=u?m=>`${Te(m.image_url)??""}${(m.imageCollage??[]).join("")}`:()=>"",p=c?m=>et(m.item_count)??"":()=>"";ne(t,e,{keyOf:m=>`${m.text}\0${m.parameter??""}\0${m.parameterLabel??""}\0${d(m)}\0${f(m)}\0${p(m)}\0${s}\0${a}`,create:(m,g)=>{let b=sd(m,o,r);return o||(b.dataset.aiaEntering=""),b},update:(m,g,b)=>{if(sr.get(m)!==(g.matchedText??"")){let P=m.querySelector(".magicx-aia-option-text");P&&ka(P,g),sr.set(m,g.matchedText??"")}let T=b===n&&!o;m.id=`${i}-option-${b}`,m.dataset.aiaIndex=String(b),m.setAttribute("aria-selected",String(r.picked?r.picked.includes(g.text):T));let S=m.querySelector(".magicx-aia-checkbox");r.picked&&g.is_tappable?(S||(S=document.createElement("span"),S.className="magicx-aia-checkbox",S.setAttribute("aria-hidden","true"),m.querySelector(".magicx-aia-option-content")?.prepend(S)),S.dataset.checked=String(r.picked.includes(g.text)),S.textContent=r.picked.includes(g.text)?"\u2713":""):S?.remove(),m.classList.toggle("magicx-aia-option--highlighted",T),m.classList.toggle("magicx-aia-option--live-match",!!g.liveMatch&&!o)}})}function rd(t,e,n,i,o){for(let r of t.querySelectorAll("[data-aia-entering]")){if(!i){let s=Number.parseInt(r.dataset.aiaIndex??"-1",10);s>=0&&r.style.setProperty(li,`${ci(s,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var sr=new WeakMap;function ka(t,e){if(t.replaceChildren(),e.matchedText)for(let n of Yn(Wt(e),e.matchedText))if(n.bold){let i=document.createElement("strong");i.className="magicx-aia-option-match",n.partial&&i.setAttribute("data-aia-match-partial",""),i.textContent=n.text,t.appendChild(i)}else t.appendChild(document.createTextNode(n.text));else t.appendChild(document.createTextNode(Wt(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 sd(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 s=["magicx-aia-option"];t.is_tappable?s.push("magicx-aia-option--tappable"):s.push("magicx-aia-option--non-tappable"),r.className=s.join(" ");let a=document.createElement("span");a.className="magicx-aia-option-content";let l=i?Ze(t.image_url):[],u=l[0];if(u){let p=document.createElement("span");p.className="magicx-aia-option-image",p.setAttribute("aria-hidden","true");let m=(t.imageCollage??[]).map(g=>Ze(g)).filter(g=>g.length>0);m.length>1&&p.setAttribute("data-aia-collage",String(m.length));for(let g of m.length>1?m:[l]){let b=document.createElement("img");b.setAttribute("alt",""),b.setAttribute("loading","lazy"),b.setAttribute("decoding","async"),b.setAttribute("referrerpolicy","no-referrer"),b.setAttribute("draggable","false");let T=0;b.onload=()=>p.setAttribute("data-aia-image-loaded",""),b.onerror=()=>{let S=g[++T];S?b.src=S:b.hidden=!0},b.src=g[0],p.appendChild(b)}a.appendChild(p),r.dataset.aiaImage=""}let c=!u&&n&&t.icon_svg?ie(t.icon_svg):null;if(c){let p=document.createElement("span");p.className="magicx-aia-option-icon",p.setAttribute("aria-hidden","true"),p.innerHTML=c,a.appendChild(p),t.icon&&(r.dataset.aiaIcon=t.icon)}let d=document.createElement("span");if(d.className="magicx-aia-option-text",ka(d,t),sr.set(r,t.matchedText??""),a.appendChild(d),t.tag){let p=document.createElement("span");p.className="magicx-aia-option-tag",p.textContent=t.tag,a.appendChild(p)}let f=o?et(t.item_count):null;if(f!==null){let p=document.createElement("span");p.className="magicx-aia-option-count",p.textContent=f,a.appendChild(p),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(a),r}var ad=120,ld={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(wt(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},_a=new WeakMap,Ra=new WeakMap;function Da(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=dd(),t.appendChild(r),j(r);let u=r.querySelector("[data-aia-time-done]");u&&(u.disabled=!1)}let s={view:e,callbacks:i,interactive:o};_a.set(r,s),$(r,ld,s),r.setAttribute("aria-label",n.timeLabel);let a=r.querySelector("[data-aia-time-done]");a&&(a.textContent=n.done);let l=r.querySelector("[data-aia-time-value]");l&&(l.textContent=Tt(e.minutes));for(let u of vt){let c=r.querySelector(`[data-aia-time-column="${u}"]`);c&&cd(c,u,e.minutes)}}function cd(t,e,n){let i=Et(e,n);for(let s of t.querySelectorAll("[data-aia-time-row]")){let a=Number(s.dataset.aiaIndex)===i;s.classList.toggle("magicx-aia-time-wheel-row--selected",a),s.setAttribute("aria-selected",String(a))}let o=Oi(t);if(o.settle)return;let r=i*xt;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function Oi(t){let e=Ra.get(t);return e||(e={syncedTop:null,settle:null},Ra.set(t,e)),e}function ud(t,e,n){let i=Oi(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(()=>Ha(t,e,n),ad)}function Ha(t,e,n){let i=Oi(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=_a.get(t);if(!o||!o.interactive)return;let r=Mn(n,e.scrollTop);r!==Et(n,o.view.minutes)&&o.callbacks.onTimeChange(wt(n,o.view.minutes,r))}function dd(){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 vt){if(r==="minute"){let s=document.createElement("span");s.className="magicx-aia-time-wheel-separator",s.textContent=":",n.appendChild(s)}n.appendChild(md(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 md(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),On(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",()=>ud(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{Oi(n).settle&&Ha(t,n,e)}),n}var pd=[159,119,164];function Ri(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()),ri(e),e}var Mi=new WeakMap;function fd(t,e,n){let i=Mi.get(t);if(i||(i={button:qs(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),Mi.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=pi({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var ki=new WeakMap;function Na(t){let e=ki.get(t);if(e){e.update();return}ki.set(t,Pi({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function ar(t){ki.get(t)?.destroy(),ki.delete(t),bi(t);let e=Mi.get(t);e&&(e.controller?.destroy(),Mi.delete(t))}function _i(t,e){let n=e.strings??R(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:s,showPills:a,isActivePillSelected:l,onSelect:u,onHighlight:c,onPillClick:d,onSkip:f}=e,p=nn(e.pills,n.keepTyping),m=rn(p),g=a&&p.length>0,b=i.length>0,T=e.products.length>0,S=e.formatType==="time"&&e.timeView!=null,P=e.formatType==="location"&&e.locationView!=null,v=r&&(b||g||s||T||S||P);if(v?t.classList.add("magicx-aia-dropdown--visible"):t.classList.remove("magicx-aia-dropdown--visible"),s?t.setAttribute("data-aia-loading",""):t.removeAttribute("data-aia-loading"),!v){ir(t,!1),aa(t),Na(t),Dt(t,null,{visible:!1});return}T?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute(Yo,e.fullWidth===!0),Xe(t),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let h=t.querySelector(".aia-stack");h||(h=document.createElement("div"),h.className="aia-stack",h.style.setProperty("--aia-stack-space","8px"),t.appendChild(h));let x=e.showSkipButton&&m&&!e.isInputEmpty,w=g||s&&a||x,y=h.querySelector(".magicx-aia-pill-bar");if(w){y||(y=document.createElement("div"),y.className="magicx-aia-pill-bar aia-cluster",y.setAttribute("data-nowrap",""),y.setAttribute("data-aia-pillbar",""),h.insertBefore(y,h.firstChild));let oe=g||s&&a,E=y.querySelector(".magicx-aia-pill-scroll");oe?(E||(E=document.createElement("span"),E.className="magicx-aia-pill-scroll",E.setAttribute("data-aia-pill-scroll",""),y.insertBefore(E,y.firstChild)),yi(E,p,0,d,!0,s,l)):E&&E.remove(),bd(y,x,s||e.skipDisabled,p[0],f,n)}else y&&y.remove();let L=e.suggestions[0],O=L?`${L.parameter} ${L.text}`:"",A=_(e.formatType),F=A&&!s;Ma(h,A?[]:i,o,u,c,e.listboxId,s,O,e.optionsPosition??"below",e.showOptionIcons??!0,e.showOptionImages??!0,e.showOptionCounts??!0,!e.skipDisabled,e.multiSelectView?.picked),t.setAttribute("aria-multiselectable",String(!!e.multiSelectView)),Ed(h,!!e.multiSelectView,e.skipDisabled||s,e.onMultiSelectCommit,n.done),fd(t,h.querySelector(".aia-grid"),n),ia(h,F?i:[],o,e.listboxId,F?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart,floor:ni(e.formatType,e.dateRangeStart),references:e.dateReferences??[]},{onSelect:u,onHighlight:c,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),Da(h,e.formatType==="time"&&!s?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),la(h,e.formatType==="location"&&!s?e.locationView:null,n,{onLocationQuery:e.onLocationQuery,onLocationMove:e.onLocationMove,onLocationCommit:e.onLocationCommit,onLocationFocusChange:e.onLocationFocusChange},{interactive:!e.skipDisabled,inputFocused:e.isFocused??!1,reediting:e.isReediting??!1});let I=h.querySelector(".magicx-aia-skeleton-bars");if(s&&(!b||D(e.formatType))){if(!I){I=document.createElement("div"),I.className="magicx-aia-skeleton-bars",I.setAttribute("data-aia-skeleton-bars","");for(let oe of pd){let E=document.createElement("span");E.className="magicx-aia-skeleton-bar",E.style.width=`${oe}px`,I.appendChild(E)}h.appendChild(I)}}else I&&I.remove();ya(h,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart,e.showProductVendor??!0,e.busyProductId??null),ir(t,!s),xd(h,e.onSeeAllResults,n.seeAllResults,e.seeAllBusy===!0);let G=h.querySelector(".magicx-aia-footer")??Sd(n),ce=o>=0&&!!i[o]?.is_tappable;yd(G,oi(ce,e.isInputEmpty,n)),G.isConnected||h.appendChild(G),gd(h,[".magicx-aia-pill-bar",".aia-grid","[data-aia-multi-actions]",".magicx-aia-datepicker",".magicx-aia-time-wheel","[data-aia-location]",".magicx-aia-skeleton-bars",".magicx-aia-products","[data-aia-see-all]",".magicx-aia-footer"]),ai(h,h.querySelector(".magicx-aia-multi-done")),Qo(t,h,{eligible:b&&!T&&!A&&!S&&!P&&!e.onSeeAllResults&&!e.fullWidth,loading:s}),Na(t),Dt(t,fi(a?p:[]),{visible:!0,anchorBottom:e.optionsPosition==="above"})}function gd(t,e){let n=e.map(i=>t.querySelector(`:scope > ${i}`)).filter(i=>i!==null);for(let i=0;i<n.length;i++)t.children[i]!==n[i]&&t.insertBefore(n[i],t.children[i]??null)}var hd={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function bd(t,e,n,i,o,r){$(t,hd,{onSkip:o,loading:n});let s=t.querySelector(".magicx-aia-skip");if(!e){s?.remove();return}s||(s=document.createElement("button"),s.type="button",s.tabIndex=-1,s.className="magicx-aia-skip",s.setAttribute("data-aia-skip",""),s.textContent=r.skip,s.disabled=!0,t.appendChild(s),j(s)),s.textContent!==r.skip&&(s.textContent=r.skip),s.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),s.disabled=n}function yd(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 Sd(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 s=document.createElement("a");s.className="aia-cluster magicx-aia-footer-brand-link",s.setAttribute("data-align","center"),s.href=ii(),s.target="_blank",s.rel="noopener noreferrer",s.style.setProperty("--aia-cluster-gap","2px");let a=document.createElement("span");a.className="magicx-aia-footer-brand",a.textContent="AI";let l=document.createElement("span");return l.className="magicx-aia-footer-badge",l.textContent="Autocomplete",s.append(a,l),n.append(i,s),e.append(n),e}var Td={itemSelector:".magicx-aia-see-all",onClick:(t,e,n)=>{e.submit&&(n.stopPropagation(),e.submit())}};function xd(t,e,n,i){let o=t.querySelector(":scope > [data-aia-see-all]");if(!e){o?.remove();return}if(!o){o=document.createElement("div"),o.className="magicx-aia-see-all-row",o.dataset.aiaSeeAll="";let s=document.createElement("button");s.type="button",s.tabIndex=-1,s.className="magicx-aia-see-all",s.disabled=!0,o.appendChild(s),t.appendChild(o),j(s)}$(o,Td,{submit:e});let r=o.querySelector("button");r&&(r.textContent!==n&&(r.textContent=n),r.disabled=!1,Ye(r,"data-aia-see-all-state",i))}var vd={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function Ed(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 a=document.createElement("button");a.type="button",a.tabIndex=-1,a.className="magicx-aia-multi-done",a.setAttribute("data-aia-multi-done",""),a.disabled=!0,r.appendChild(a),t.appendChild(r),j(a)}$(r,vd,{commit:i,disabled:n});let s=r.querySelector("button");s&&(s.textContent=o,s.disabled=n)}function tt(t,e,n){if(e)return[e];if(!t)return n;let i=n.filter(o=>o.parameter!==t.parameter||o.text!==t.text);return[t,...i]}function Fa(t,e){let n=Ri(e.listboxId);return t.appendChild(n),{dropdown:n}}function lr(t,e,n){let i=je(e);_i(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:tt(e.dropdownSuggestion,null,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",showProductVendor:n.showProductVendor??!0,onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:i.selectedIso,selectedDateRange:i.selectedRange,dateRangeStart:i.rangeStart,dateReferences:i.references,timeView:e.timeView,multiSelectView:e.dropdownMultiSelect,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:n.selectOption,onHighlight:(o,r)=>{r!==void 0&&n.store.get().activeDropdownIndex!==r||n.store.set({activeDropdownIndex:o})},onPillClick:n.setActivePill,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,busyProductId:e.selectingProductId,onProductSelect:n.selectProduct,onProductFocusChange:o=>n.store.set({isFocused:o})})}var wd="[data-aia-chip-remove]";function cr(t,e){let n=e;if(!n||n.nodeType===void 0)return null;let o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(wd)??null;return o&&t.contains(o)?o:null}function Di(t,e){let n=null,i=u=>{n=null;let c=u;if(c.button)return;let d=cr(t,u.target);if(!d)return;u.preventDefault(),u.stopPropagation();let f=d.dataset.aiaChipRemove,p=c.pointerType==="touch"||c.pointerType==="pen";n={id:f,x:c.clientX,y:c.clientY,pending:p},!p&&f&&e(f)},o=u=>{if(!n?.pending)return;n.pending=!1;let c=u;if(Math.hypot(c.clientX-n.x,c.clientY-n.y)>10)return;let f=t.getRootNode().elementFromPoint?.(c.clientX,c.clientY)??u.target,p=cr(t,f)?.dataset.aiaChipRemove;p&&p===n.id&&e(p)},r=()=>{n&&(n.pending=!1)},s=u=>{!n&&!cr(t,u.target)||(u.cancelable&&u.preventDefault(),u.type==="click"&&(u.stopImmediatePropagation(),n=null))},a={capture:!0},l={capture:!0,passive:!1};return t.addEventListener("pointerdown",i,a),t.addEventListener("pointerup",o,a),t.addEventListener("pointercancel",r,a),t.addEventListener("touchstart",s,l),t.addEventListener("mousedown",s,a),t.addEventListener("click",s,a),()=>{t.removeEventListener("pointerdown",i,a),t.removeEventListener("pointerup",o,a),t.removeEventListener("pointercancel",r,a),t.removeEventListener("touchstart",s,l),t.removeEventListener("mousedown",s,a),t.removeEventListener("click",s,a)}}var Wa=340;function Hi(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 d=t.getBoundingClientRect().height;if(d!==0){if(c===0||Math.abs(d-c)<.5){t.style.height=`${d}px`;return}t.style.height=`${c}px`,t.getBoundingClientRect(),t.style.height=`${d}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(c=>{for(let f of c)if(f.target!==t){n();return}let d=t.getBoundingClientRect().width;Math.abs(d-i)<.5||(i=d,n())}):null,r=()=>{for(let c of Array.from(t.children))o?.observe(c)},s=0,a=()=>{r(),n(),e.clearTimeout(s),s=e.setTimeout(n,340)},l=new e.MutationObserver(a);l.observe(t,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["data-placeholder","data-aia-empty"]}),o?.observe(t),r(),t.addEventListener("load",a,!0);let u=!1;return t.ownerDocument.fonts?.ready.then(()=>{u||n()}),n(),()=>{u=!0,t.removeEventListener("load",a,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(s),t.style.height=""}}var pr=2600,Pd=3,Vi="data-aia-hint",mr="magicx-aia-hint",fr="data-aia-hint-el",Ld={position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--aia-hint-color, #999)",userSelect:"none"},Cd=280,Ad=320,Id=380,ur="cubic-bezier(0.25, 0.1, 0.25, 1)",Va=new Set(["a","an","the","some","my"]),Wi=new WeakMap;function Od(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Ba(t,e){let n=t.text.trim(),i=e.trim(),o=[];i&&n.toLowerCase().startsWith(`${i.toLowerCase()} `)&&(n=n.slice(i.length+1).trim());let r=i?i.split(/\s+/):[],s=null;r.length>1&&Va.has(r[r.length-1].toLowerCase())&&(s=r.pop()??null);let a=r.join(" ");a&&o.push({key:`w:${a.toLowerCase()}`,text:a,icon:null});let l=null,[u,...c]=n.split(/\s+/);c.length&&u&&Va.has(u.toLowerCase())&&(l=u,n=c.join(" "));let d=l??s;d&&o.push({key:`w:${d.toLowerCase()}`,text:d,icon:null});let f=t.icon_svg?ie(t.icon_svg):null;return o.push({key:`c:${f??""}:${n}`,text:n,icon:f}),o}function Md(t,e){let n=t.createElement("span");if(n.className=`${mr}__word`,n.dataset.key=e.key,n.style.display="inline-block",e.icon){let i=t.createElement("span");i.className=`${mr}__icon`,Object.assign(i.style,{display:"inline-flex",width:"1em",height:"1em",marginRight:"0.25em",verticalAlign:"-0.125em",opacity:"var(--aia-hint-icon-opacity, 0.7)"}),i.innerHTML=e.icon;let o=i.querySelector("svg");o&&(o.style.width="100%",o.style.height="100%"),n.appendChild(i)}return n.appendChild(t.createTextNode(e.text)),n}function dr(t,e,n){return typeof t.animate=="function"?t.animate(e,n):null}function Ni(t,e){let n=t.ownerDocument?.defaultView;if(!n)return;let i=n.getComputedStyle(t),o=c=>Number.parseFloat(c)||0,r=t.offsetLeft+o(i.borderLeftWidth)+o(i.paddingLeft),s=t.offsetTop+o(i.borderTopWidth)+o(i.paddingTop),a=t.clientWidth-o(i.paddingLeft)-o(i.paddingRight),l=t.offsetParent instanceof HTMLElement?t.offsetParent.clientWidth-r:0,u=Math.max(a,l);e.style.left=`${r}px`,e.style.top=`${s}px`,u>0&&(e.style.maxWidth=`${u}px`),e.style.font=i.font,e.style.lineHeight=i.lineHeight,e.style.letterSpacing=i.letterSpacing,e.style.fontWeight="var(--aia-hint-font-weight, 300)"}function Ua(t,e,n,i){let{el:o}=t,r=o.ownerDocument,s=new Map;for(let p of Array.from(o.children))p.dataset.leaving===void 0&&p.dataset.key&&s.set(p.dataset.key,p);let a=new Map;for(let[p,m]of s)a.set(p,m.offsetLeft);let l=new Set(e.map(p=>p.key));for(let[p,m]of s){if(l.has(p))continue;if(!n){m.remove();continue}m.dataset.leaving="",m.style.position="absolute",m.style.left=`${a.get(p)??0}px`,m.style.top=`${m.offsetTop}px`;let g=dr(m,[{opacity:1,filter:"blur(0)"},{opacity:0,filter:"blur(2px)"}],{duration:Cd,easing:ur,fill:"forwards"});g?g.onfinish=()=>m.remove():m.remove()}let u=Array.from(o.children).filter(p=>p.dataset.leaving!==void 0),c=[];if(e.forEach((p,m)=>{m>0&&c.push(r.createTextNode(" ")),c.push(s.get(p.key)??Md(r,p))}),o.replaceChildren(...c,...u),!n)return;let d=new Map;for(let p of c)p instanceof HTMLElement&&p.dataset.key&&d.set(p.dataset.key,p);let f=0;for(let p of e){let m=d.get(p.key);if(m)if(!s.has(p.key))dr(m,[{opacity:0,filter:"blur(2px)"},{opacity:1,filter:"blur(0)"}],{duration:Ad,delay:i?80*f++:180+60*f++,easing:ur,fill:"backwards"});else{let b=(a.get(p.key)??m.offsetLeft)-m.offsetLeft;Math.abs(b)>.5&&dr(m,[{transform:`translateX(${b}px)`},{transform:"none"}],{duration:Id,easing:ur})}}}function Fi(t){let e=Wi.get(t);e&&(e.timer!==null&&clearInterval(e.timer),e.resize?.disconnect(),e.el.remove(),Wi.delete(t),t.removeAttribute(Vi),t.removeAttribute("aria-placeholder"))}function $a(t,e,n,i){let o=i.filter(m=>m.text.trim()!=="").slice(0,Pd),r=t.parentElement;if(!e||o.length<2||!r){Fi(t);return}let s=`${n}\0${o.map(m=>`${m.text}${m.icon_svg??""}`).join("\0")}`,a=Wi.get(t);if(a&&a.key===s&&a.el.isConnected){Ni(t,a.el);return}Fi(t);let l=t.ownerDocument,u=l.createElement("span");u.className=mr,u.setAttribute(fr,""),u.setAttribute("aria-hidden","true"),Object.assign(u.style,Ld),r.insertBefore(u,t),t.setAttribute(Vi,""),n.trim()&&t.setAttribute("aria-placeholder",n.trim()),Ni(t,u);let c=l.defaultView,d=c?.ResizeObserver?new c.ResizeObserver(()=>{u.isConnected&&Ni(t,u)}):null;d?.observe(r);let f=Od(t),p={key:s,lead:n,options:o,index:0,el:u,timer:null,resize:d};Wi.set(t,p),Ua(p,Ba(o[0],n),!f,!0),!f&&(p.timer=setInterval(()=>{if(!t.isConnected||!u.isConnected){Fi(t);return}t.ownerDocument?.hidden||(p.index=(p.index+1)%p.options.length,Ni(t,u),Ua(p,Ba(p.options[p.index],p.lead),!0,!1))},pr))}function Bi(t){Fi(t)}function Ui(t){return(t.find(n=>n.type?.kind!=="traditional_autocomplete")?.options??[]).filter(n=>n.is_tappable!==!1).map(n=>({text:n.text,icon_svg:n.icon_svg}))}var kd=6,Rd=.3;function Ga(t){return t<=0?"0px":`${(-Math.min(Rd,2*kd/t)).toFixed(3)}px`}var qa=new Map;function _d(t,e,n){let i=qa.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,s=Number.parseFloat(getComputedStyle(t).fontSize);if(!(r>0&&s>0&&o.naturalWidth>0&&o.naturalHeight>0))return;let a=`${(r/s*(o.naturalWidth/o.naturalHeight)).toFixed(3)}em`;qa.set(e,a),t.style.setProperty("--aia-chip-image-fit",a)},o.src=e}function $i(t){let{input:e,segments:n,newParamId:i,editingParamId:o,placeholderText:r}=t,s=t.showChipIcons??!0,a=t.showChipImages??!0,l=t.showChipRemove??!1,u=n.length===0;e.dataset.aiaEmpty=u?"true":"false",ks(e,u?r:""),$a(e,u,r,t.hintOptions??[]);let c=n.map(v=>v.type==="completed"?`${v.type}:${v.value}${s?v.param.icon??v.param.icon_svg??"":""}${a?Te(v.param.image_url)??"":""}${l?"x":""}`:v.type==="identified"?`${v.type}:${v.value}${v.param.id}${l?"x":""}`:`${v.type}:${v.value}`).join("\0"),d=e.dataset.segKey??"",f=e.dataset.newParamId??"",p=e.dataset.editingParamId??"";if(c===d&&(i??"")===f&&(o??"")===p)return;if(c===d){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let v of e.querySelectorAll("strong[data-param-id]")){let h=v.dataset.paramId,x=v.dataset.seg==="completed"&&h===i;v.classList.toggle("magicx-aia-shimmer-revealed",x),v.classList.toggle("magicx-aia-shimmer-sweep",x),v.classList.toggle("magicx-aia-segment--editing",h===o)}return}let m=e.getAttribute("data-aia-composing")==="true"?Dd(e,n):null;if(m==="unsafe")return;let g=as(e),b=g&&!m?z(e):null;e.dataset.segKey=c,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let T=H(e),S=T.createDocumentFragment(),P=0;for(let v of n)if(P+=v.value.length,v.type==="completed"){let h=T.createElement("strong");h.dataset.seg="completed",h.dataset.paramId=v.param.id;let x=v.param.id===i,w=v.param.id===o,y=["magicx-aia-segment","magicx-aia-segment--completed"];x&&y.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),w&&y.push("magicx-aia-segment--editing"),h.className=y.join(" "),h.style.letterSpacing=Ga(v.value.length);let L=a?Te(v.param.image_url):null;if(L){let A=T.createElement("span");A.className="magicx-aia-segment-image",A.setAttribute("contenteditable","false"),A.setAttribute("aria-hidden","true"),A.style.setProperty("--aia-chip-image",`url("${L}")`),_d(A,L,T),h.appendChild(A),h.dataset.aiaImage=""}let O=!L&&s&&v.param.icon_svg?ie(v.param.icon_svg):null;if(O){let A=T.createElement("span");A.className="magicx-aia-segment-icon",A.setAttribute("contenteditable","false"),A.setAttribute("aria-hidden","true"),A.innerHTML=O,h.appendChild(A),v.param.icon&&(h.dataset.aiaIcon=v.param.icon)}h.appendChild(T.createTextNode(v.value)),l&&h.appendChild(Ka(T,v.param.id)),S.appendChild(h)}else if(v.type==="identified"){let h=T.createElement("strong");h.dataset.seg="identified",h.dataset.paramId=v.param.id;let x=["magicx-aia-segment","magicx-aia-segment--completed"];v.param.id===o&&x.push("magicx-aia-segment--editing"),h.className=x.join(" "),h.style.letterSpacing=Ga(v.value.length),h.textContent=v.value,l&&h.appendChild(Ka(T,v.param.id)),S.appendChild(h)}else S.appendChild(T.createTextNode(v.value));if(m){m.node.deleteData(0,m.node.data.length-m.syllable.length);for(let v of Array.from(e.childNodes))v!==m.node&&v.remove();e.insertBefore(S,m.node),e.dataset.aiaTextLength=String(P+m.syllable.length);return}e.replaceChildren(S),e.dataset.aiaTextLength=String(P),b!=null?V(e,Math.max(0,Math.min(b,P))):g&&V(e,P)}function Dd(t,e){let n=e.map(s=>s.value).join(""),i=Ae(t);if(i===n)return null;if(!i.startsWith(n))return"unsafe";let o=i.slice(n.length),r=t.lastChild;return r?.nodeType!==Node.TEXT_NODE||!r.data.endsWith(o)?"unsafe":{node:r,syllable:o}}function Ka(t,e){let n=t.createElement("span");return n.className="magicx-aia-segment-remove",n.setAttribute("contenteditable","false"),n.setAttribute("aria-hidden","true"),n.dataset.aiaChipRemove=e,n.innerHTML='<svg viewBox="0 0 10 10" aria-hidden="true"><path d="M2.5 2.5l5 5M7.5 2.5l-5 5"/></svg>',n}var Hd='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" role="img" aria-label="Submit"><path d="M9 14V4M9 4L4 9M9 4L14 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function za(t=R()){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=Hd.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function ja(t){let e=t.store.get();return(!!e.text||e.completedParams.length>0)&&!!t.onSubmit}function Ya(t){if(!t.onSubmit||t.store.get().isSubmitting)return;t.endTypedWord?.();let e=t.store.get();t.onSubmit(be(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields}))&&t.afterSubmit?.()}function Nd(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function Qa(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 Xa(t,e){let{listboxId:n}=e,i=Ri(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 s=document.createElement("div");s.className="magicx-aia-input",s.setAttribute("data-aia-input",""),s.setAttribute("contenteditable",Nd()?"plaintext-only":"true"),s.setAttribute("role","combobox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-haspopup","listbox"),s.setAttribute("aria-controls",n),s.setAttribute("aria-expanded","false"),s.setAttribute("spellcheck","true"),s.setAttribute("enterkeyhint","send"),r.appendChild(s);let a=document.createElement("span");a.className="magicx-aia-pill-list-container",a.setAttribute("data-aia-pill-list-container",""),r.appendChild(a);let l=null,u=null;e.submitButton===void 0?(l=za(e.strings),o.appendChild(l),u=l):e.submitButton!==null&&(u=e.submitButton,u.hasAttribute("data-aia-submit")||u.setAttribute("data-aia-submit",""),u.setAttribute("data-aia-submit-slot",""),o.appendChild(u));let c=new AbortController,{signal:d}=c,f=!1,p=0,m=()=>{let h=Ae(s);return h.length>0&&h[0]!==h[0].toUpperCase()?h[0].toUpperCase()+h.slice(1):h},g=()=>e.handleChange(m()),b=()=>{let h=he(s)?.node??null;if(!h||!s.contains(h))return null;let y=(h.nodeType===Node.ELEMENT_NODE?h:h.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return y&&ss(s,y)?null:y};o.addEventListener("click",h=>{h.target?.closest("[data-aia-pill]")||s.getRootNode().activeElement?.closest("[data-aia-location]")||s.focus()},{signal:d});let T=null,S=()=>{let h=e.showChipRemove??!1;h!==(T!==null)&&(T?.(),T=h?Di(s,x=>e.removeParam(x)):null)};if(S(),d.addEventListener("abort",()=>{T?.(),T=null}),s.addEventListener("input",()=>{if(f){e.handleCompositionText(m());return}p=performance.now(),g(),e.handleCaretAfterInput(z(s))},{signal:d}),H(s).addEventListener("selectionchange",()=>{let h=he(s);if(!h||!s.contains(h.node))return;let x=h.collapsed?b():null,w=e.store.get(),y=w.editingParam?.id??w.editingIdentified?.id??null;if(x&&x!==y){e.startEditingParam(x);return}performance.now()-p<50||e.handleCaretMove(z(s))},{signal:d}),s.addEventListener("click",h=>{let x=vn(s,h.target);x&&(e.startEditingParam(x),En(s,x))},{signal:d}),s.addEventListener("compositionstart",()=>{f=!0,s.setAttribute("data-aia-composing","true")},{signal:d}),s.addEventListener("compositionend",()=>{f=!1,s.removeAttribute("data-aia-composing"),g()},{signal:d}),s.addEventListener("beforeinput",h=>{let x=h,w=x.inputType;if(w==="insertParagraph"||w==="insertLineBreak"||w==="insertFromDrop"){h.preventDefault();return}if(w.startsWith("insert")||w.startsWith("delete")){let y=w.startsWith("delete")?"":x.data??"";e.replaceEditingRange(y)&&h.preventDefault()}},{signal:d}),s.addEventListener("paste",h=>{h.preventDefault();let x=(h.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!x)return;let w=H(s),y=Ce(s);if(!y||!s.contains(y.startContainer))return;y.deleteContents();let L=w.createTextNode(x);y.insertNode(L),y.setStartAfter(L),St(s,y.startContainer,y.startOffset),g()},{signal:d}),s.addEventListener("keydown",h=>e.handleKeyDown(h),{signal:d}),s.addEventListener("focus",()=>e.store.set({isFocused:!0}),{signal:d}),s.addEventListener("blur",()=>e.store.set({isFocused:!1}),{signal:d}),u&&u.addEventListener("click",h=>{ja(e)&&(h.stopPropagation(),Ya(e))},{signal:d}),e.autoFocus!==!1){s.focus();let h=he(s);(!h||!s.contains(h.node))&&St(s,s,0)}if(typeof ResizeObserver<"u"){let h=new ResizeObserver(()=>Qa(s,a));h.observe(s),c.signal.addEventListener("abort",()=>h.disconnect(),{once:!0})}let v=Hi(r);return c.signal.addEventListener("abort",v,{once:!0}),{input:s,inlinePillContainer:a,dropdown:i,submitButton:l,submitTarget:u,abort:c,syncChipRemove:S}}function gr(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:s}=t,{pillPlacement:a,setActivePill:l,selectOption:u,store:c}=n;t.syncChipRemove(),i.setAttribute("aria-expanded",String(e.isDropdownOpen));let d=e.activeDropdownIndex>=0?`${n.listboxId}-option-${e.activeDropdownIndex}`:"";if(d?i.setAttribute("aria-activedescendant",d):i.removeAttribute("aria-activedescendant"),s){let T=n.strings??R();s.getAttribute("aria-label")!==T.submit&&s.setAttribute("aria-label",T.submit);let S=s.querySelector("svg");S&&S.getAttribute("aria-label")!==T.submit&&S.setAttribute("aria-label",T.submit);let P=!!e.text||e.completedParams.length>0;s.disabled=!P,s.toggleAttribute("data-aia-ready",P&&e.isReady)}t.submitTarget&&Ye(t.submitTarget,"data-aia-submit-state",e.isSubmitting);let f=i.dataset.newParamId??"",p=e.newParamId!==null&&e.newParamId!==f;if($i({input:i,segments:e.segments,newParamId:e.newParamId,editingParamId:e.editingParam?.id??null,placeholderText:e.placeholderText,isFocused:e.isFocused,showChipIcons:n.showChipIcons??!0,showChipImages:n.showChipImages??!0,hintOptions:a==="inline"?[]:Ui(e.actionableSuggestions),showChipRemove:n.showChipRemove??!1}),a==="inline"){let T=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,S=tn(e.actionableSuggestions);T||S.length>0?yi(o,S,0,l,!1,T,e.isActivePillSelected):Xo(o)}else Xo(o);Qa(i,o),p?(i.focus(),V(i,e.caretOffset??e.text.length)):e.isFocused&&Ae(i)!==e.text&&!i.hasAttribute("data-aia-composing")&&V(i,e.text.length);let m=e.editingParam?We(e.editingParam):e.editingIdentified?{parameter:e.editingIdentified.parameter,text:J(e.editingIdentified.parameter),required:!0,options:[]}:null,g=e.dropdownSuggestion??m??e.actionableSuggestions[0],b=je(e);_i(r,{strings:n.strings,suggestions:g?[{...g,options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:tt(e.dropdownSuggestion,m,e.actionableSuggestions),showPills:a==="dropdown",showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",showProductVendor:n.showProductVendor??!0,onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:b.selectedIso,selectedDateRange:b.selectedRange,dateRangeStart:b.rangeStart,dateReferences:b.references,timeView:e.timeView,multiSelectView:e.dropdownMultiSelect,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:u,onHighlight:(T,S)=>{S!==void 0&&c.get().activeDropdownIndex!==S||c.set({activeDropdownIndex:T})},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:T=>c.set({isFocused:T}),seeAllBusy:e.isSubmitting,busyProductId:e.selectingProductId,onSeeAllResults:n.seeAllResults&&e.text.trim().length>0&&ja(n)?()=>Ya(n):void 0,fullWidth:n.seeAllResults===!0})}function Gi(t){let e=t,n=new Set,i=[],o=!1;return{get:()=>e,set:r=>{let s=typeof r=="function"?r(e):r,a=e;if(e={...e,...s},i.push([e,a]),!o){o=!0;try{let l=0;for(let u=i.shift();u;u=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,d]=u;for(let f of n)f(c,d)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function Ja(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(s=>{let a={...s,...o(s)};return r(a)}):t.set(r)},peek:r=>{let s={...t.get(),...r};return{...s,...e(s)}},subscribe:r=>t.subscribe((s,a)=>{let l={...a,...o(a)},u={...s,...o(s)};r(u,l)})}}var hr=new WeakSet,Za=new WeakMap;function tl(t){return t.nodeType===Node.DOCUMENT_NODE}function Fd(t){return tl(t)?t:t.ownerDocument}function Wd(t){let e=Za.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(il),Za.set(t,i),i)}catch{return null}}function el(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=il,e.appendChild(n)}function nl(t){if(typeof document>"u")return;let e=t??document;if(hr.has(e))return;let n=Fd(e);if(tl(e)){let r=e.head??e.documentElement;if(!r)return;el(n,r),hr.add(e);return}let i=Wd(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):el(n,e),hr.add(e)}var il=`.aia-stack {
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: var(--aia-stack-space, 0.5rem);
@@ -3783,9 +3783,18 @@
3783
3783
  /* A multi-select shows three rows and scrolls the rest, in every layout (one
3784
3784
  column, two columns, phone), so its Done button always sits right under
3785
3785
  the third row. The planned cap (--aia-grid-max-height) still wins when it
3786
- is smaller: fewer than three rows of options. */
3786
+ is smaller: three rows of options or fewer. --aia-option-peek (a unitless
3787
+ number of rows, 0 or more, default 0, set by the consumer on the widget or
3788
+ any ancestor) shows that much of the next row when the list scrolls; the
3789
+ planned cap carries it too, but only for a list that scrolls, so a list of
3790
+ three or fewer is never padded out. max() reads a negative as 0. A value
3791
+ with a unit makes the calc invalid and the cap is lost: nothing here can
3792
+ catch that, and the reference says so. */
3787
3793
  [data-aia-dropdown][aria-multiselectable="true"] .aia-grid[data-scroll] {
3788
- max-height: min(var(--aia-grid-max-height, 120px), calc(3 * var(--aia-option-row-height, 37px)));
3794
+ max-height: min(
3795
+ var(--aia-grid-max-height, 120px),
3796
+ calc((3 + max(0, var(--aia-option-peek, 0))) * var(--aia-option-row-height, 37px))
3797
+ );
3789
3798
  }
3790
3799
 
3791
3800
  /* Fitted to the viewport, every other grid hands its scrolling to the panel,
@@ -3795,7 +3804,10 @@
3795
3804
  [data-aia-dropdown][data-aia-fit][aria-multiselectable="true"] .aia-grid[data-scroll] {
3796
3805
  flex-shrink: 1;
3797
3806
  min-height: var(--aia-option-row-height, 37px);
3798
- max-height: min(var(--aia-grid-max-height, 120px), calc(3 * var(--aia-option-row-height, 37px)));
3807
+ max-height: min(
3808
+ var(--aia-grid-max-height, 120px),
3809
+ calc((3 + max(0, var(--aia-option-peek, 0))) * var(--aia-option-row-height, 37px))
3810
+ );
3799
3811
  overflow-y: auto;
3800
3812
  }
3801
3813
 
@@ -4006,13 +4018,19 @@
4006
4018
  :where([data-aia-options-style="classic"])
4007
4019
  [data-aia-dropdown][aria-multiselectable="true"]
4008
4020
  .aia-grid[data-scroll] {
4009
- max-height: min(var(--aia-grid-max-height, 120px), calc(3 * var(--aia-option-row-height, 37px)));
4021
+ max-height: min(
4022
+ var(--aia-grid-max-height, 120px),
4023
+ calc((3 + max(0, var(--aia-option-peek, 0))) * var(--aia-option-row-height, 37px))
4024
+ );
4010
4025
  }
4011
4026
  :where([data-aia-options-style="classic"])
4012
4027
  [data-aia-dropdown][data-aia-fit][aria-multiselectable="true"]
4013
4028
  .aia-grid[data-scroll] {
4014
4029
  min-height: var(--aia-option-row-height, 37px);
4015
- max-height: min(var(--aia-grid-max-height, 120px), calc(3 * var(--aia-option-row-height, 37px)));
4030
+ max-height: min(
4031
+ var(--aia-grid-max-height, 120px),
4032
+ calc((3 + max(0, var(--aia-option-peek, 0))) * var(--aia-option-row-height, 37px))
4033
+ );
4016
4034
  }
4017
4035
  :where([data-aia-options-style="classic"])
4018
4036
  [data-aia-dropdown]
@@ -4024,5 +4042,5 @@
4024
4042
  padding-inline: 8px;
4025
4043
  font-size: var(--aia-skip-font-size, 13.5px);
4026
4044
  }
4027
- `;var Vi=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 Bi=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){return this.collect(e,...n).completed}collect(e,...n){let i=[],o=this.listeners[e];if(!o)return{completed:!0,returned:i};let r=!0;for(let a of o)this.boundary.runListener(String(e),()=>{i.push(a(...n))},this.keys.get(a)??String(e))||(r=!1);return{completed:r,returned:i}}hasListeners(e){return(this.listeners[e]?.size??0)>0}clear(){this.listeners={}}};function vu(t){return t!=null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}var Ui=Symbol("aia.handoff.not-handled"),Eu=new Set(["Shift","Control","Alt","Meta"]),Wt=class{constructor(e){this.opts=e;this.key=null;this.run=0;this.listening=null;this.onPageShow=e=>{e.persisted&&this.end()};this.onPointerDown=e=>{this.onControl(e)||this.end()};this.onKeyDown=e=>{Eu.has(e.key)||this.onControl(e)||this.opts.timers.schedule(`${this.opts.name}:key`,()=>{this.opts.ownsKey(e)||this.end()},0)}}get active(){return this.key!==null}start(e,n){this.stop(),this.key=e;let i=this.run;this.opts.timers.schedule(this.opts.name,()=>this.end(),8e3),this.listen();let o=n.filter(vu),r=o.length,a=()=>{r-=1,r===0&&this.run===i&&this.end()};for(let s of o)Promise.resolve(s).then(a,l=>{throw a(),l})}sync(e){this.key!==null&&this.key!==e&&this.end()}end(){this.key!==null&&(this.stop(),this.opts.onEnd())}dispose(){this.stop()}onControl(e){return e.composedPath().some(n=>typeof n.matches=="function"&&n.matches(this.opts.controls))}listen(){let e=this.opts.document()??(typeof document>"u"?null:document);if(!e)return;let n=e.defaultView;n?.addEventListener("pageshow",this.onPageShow),e.addEventListener("pointerdown",this.onPointerDown,!0),e.addEventListener("keydown",this.onKeyDown,!0),this.listening={doc:e,view:n}}stop(){if(this.key=null,this.run+=1,this.opts.timers.clear(this.opts.name),this.opts.timers.clear(`${this.opts.name}:key`),!this.listening)return;let{doc:e,view:n}=this.listening;n?.removeEventListener("pageshow",this.onPageShow),e.removeEventListener("pointerdown",this.onPointerDown,!0),e.removeEventListener("keydown",this.onKeyDown,!0),this.listening=null}};function nt(t){return`${t.text}\0${t.completedParams.map(e=>e.id).join("\0")}`}function $i(t){return`${nt(t)}${t.products.map(e=>e.id).join("\0")}`}var Gi=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 wu(t){let e;try{e=new URL(t??X).host}catch{return null}let n=Gt.get(e);return n?`https://${n}`:null}var Qs=new WeakMap;function Ys(t,e){if(!t.head)return;let n=wu(e);if(!n)return;let i=Qs.get(t);i||(i=new Map,Qs.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 it=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 fr(t){return t.isDropdownOpen&&!t.isLoading}var Pu=50,Lu=new Set(["search_started","submit","product_click","impression"]),Cu="newParam",Xs="suggestionRemoval",Js="selectionAnimation",gr="skeletonExit",Zs="locationSearch",Au=650,Iu=0;function Ou(){return`:ac-${++Iu}:`}var el=170,tl=160;function nl(){return{text:"",composing:null,completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,locationAutocomplete:!0,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!1,isReady:!1,error:null,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,skeletonOptions:null,skeletonSuggestion:null,skeletonPicked:null,skeletonRequested:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null,multiSelectDraft:null,locationSearch:null,locationFieldFocused:!1,isSubmitting:!1,selectingProductId:null,editingIdentified:null}}var qi=class{constructor(e,n={}){this.inputStore=Wi(nl());this._listboxId=Ou();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new Gi;this.boundary=new Vi;this.subscriberCount=0;this.emitter=new Bi(this.boundary);this.sessionId=crypto.randomUUID();this.lastRequestId=null;this.searchStartedSessionId=null;this.funnelTelemetry=null;this.pendingSearchStarted=!1;this.openWordText=null;this.locationMirrorText=null;this.locationMirrored=null;this.heldIdentified=null;this.waitingIdentified=null;this.lastImpressionKey="";this.visibleImpression=!1;this.destroyed=!1;this.locationAbort=null;this.locationSession=null;this.spacePickCaret=null;this.emitSubmit=e=>{if(this.submitHold.active)return!1;this.recordSubmit(e);let n=nt(this.store.get()),{completed:i,returned:o}=this.emitter.collect("submit",e);return this.showsProgress()&&i&&!this.resetsAfterSubmit()&&!this.submitHold.active&&nt(this.store.get())===n&&(this.submitHold.start(n,o),this.store.set({isSubmitting:!0})),i};this.submitHold=new Wt({timers:this.timers,name:"submit-hold",controls:"[data-aia-submit], [data-aia-see-all]",document:()=>this.container.ownerDocument,ownsKey:e=>this.ownKeys.has(e),onEnd:()=>this.store.set({isSubmitting:!1})});this.productHold=new Wt({timers:this.timers,name:"product-hold",controls:'[data-aia-product][data-aia-product-state="busy"]',document:()=>this.container.ownerDocument,ownsKey:e=>this.ownKeys.has(e),onEnd:()=>this.store.set({selectingProductId:null})});this.ownKeys=new WeakSet;this.emitError=e=>this.emitter.emit("error",e);this.container=e,this.opts=n,this.renderMode=n.renderMode??"full",this.store=$s(this.inputStore,i=>ma(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 ln(this.store,e),this.pillsController=new _n(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 Hn(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new Rn(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 sn(this.store,()=>this.opts.apiConfig,()=>this.opts.optionOverrides,()=>this.opts.maskCompletedText,()=>this.emitter.hasListeners("error")?this.emitError:void 0,()=>this.sessionId,()=>this.resolveSource(),()=>this.opts.additionalContext,()=>this.opts.language,{getProductId:()=>this.opts.productId,getCurrency:()=>this.opts.currency,getPrependPlaceholder:()=>this.opts.prependPlaceholder,getAllOption:()=>this.opts.allOption===!0,onRequest:({query:i,signal:o,isCurrent:r})=>{Ys(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:be(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 kn(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",afterSubmit:this.renderMode==="full"?()=>this.resetAfterSubmit():void 0,selectOption:i=>this.selectOption(i),removeParamAtCaret:i=>this.removeParamAtCaret(i),startEditingParamAtCaret:i=>this.startEditingParamAtCaret(i),exitEditMode:()=>this.exitEditMode(),exitEditingIdentified:()=>this.exitEditingIdentified(),skipActivePill:()=>this.skipActivePill(),endTypedWord:i=>this.endTypedWord(i),stepTime:i=>this.stepTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()}),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text!==o.text&&this.emitter.emit("change",i.text),i.completedParams!==o.completedParams&&this.emitter.emit("paramsChange",i.completedParams);let r=i.isFocused||i.locationFieldFocused;r!==(o.isFocused||o.locationFieldFocused)&&(r?this.emitter.emit("focus"):this.emitter.emit("blur")),this.emitter.emit("stateChange",i)})),this.unsubscribers.push(this.store.subscribe(()=>this.maybeExitReEditOnNoMatch())),this.unsubscribers.push(this.store.subscribe(()=>{let i=this.store.get();i.locationFieldFocused&&!i.locationView&&this.store.set({locationFieldFocused:!1})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text===o.text&&i.completedParams===o.completedParams||i.suggestions.some(r=>r.leadsWithAll)&&Mt(i.text,i.completedParams.length,i.leadInText)&&this.store.set({suggestions:i.suggestions.map(r=>r.leadsWithAll?{...r,leadsWithAll:!1}:r)})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.skippedParams.length!==0&&Mt(i.text,i.completedParams.length,i.leadInText)&&(Mt(o.text,o.completedParams.length,o.leadInText)||this.store.set({skippedParams:[]}))})),this.subscribeSkeletonMirror(),this.subscribeLocationMirror(),this.subscribeVisibleImpression(),this.subscribeHandoffHolds(),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}=gt(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===U(i)||this.store.set({pendingRangeStart:null})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.multiSelectDraft;o&&o.key!==U(i)&&this.store.set({multiSelectDraft:null});let r=i.timeDraft;!r||r.key===U(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=Fr(o.text,i.text,a);if(l===null){this.store.set({pendingSpan:null});return}a=l}i.text.slice(a).trim().length===0||Hr(i.segments,a)?this.store.set({pendingSpan:null}):a!==r.anchor&&this.store.set({pendingSpan:{anchor:a,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(zs(this.opts.styleRoot??fe(this.container)),this.setupContainer()),this.renderMode==="full"?this.buildAndRenderFull():this.renderMode==="dropdown"&&this.buildAndRenderDropdown(),this.optionSource.start(),this.fetchController.start()}focus(){this.domRefs?.input.focus()}blur(){this.domRefs?.input.blur()}reset(){let{isFocused:e,dropdownHeld:n}=this.store.get();this.optionSource.reset(),this.locationMirrored=null,this.submitHold.dispose(),this.productHold.dispose(),this.store.set({...nl(),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.submitHold.dispose(),this.productHold.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&&(Ca(this.domRefs.input),Hi(this.domRefs.input),or(this.domRefs.dropdown)),this.dropdownRefs&&or(this.dropdownRefs.dropdown),this.domRefs=null,this.dropdownRefs=null,this.renderMode!=="headless"&&(this.container.innerHTML="")}setMode(e){this.modeController?.setMode(e)}prefillText(e){this.applyTextChange(e,!1)}noteSearchStarted(){this.searchStartedSessionId!==this.sessionId&&(this.searchStartedSessionId=this.sessionId,this.funnelTelemetry===null?this.pendingSearchStarted=!0:this.fireTelemetry("search_started",{}))}setValue(e){let n=this.store.get();if(n.editingIdentified&&e!==n.text){this.store.set({text:e,editingIdentified:null,activeDropdownIndex:-1});return}this.store.set({text:e})}setCompletedParams(e){this.store.set({completedParams:e})}setActivePill(e){this.pillsController.setActivePill(e);let n=this.store.get().text.length;this.store.set({caretOffset:n,isFocused:!0}),this.scheduleSetCursor(n)}removeLastParam(){this.pillsController.removeLastParam()}findChipSpanAt(e){let n=0;for(let i of this.store.get().segments){let o=n;if(n+=i.value.length,i.type!=="text"&&e>o&&e<=n)return{kind:i.type,param:i.param,start:o,end:n}}return null}withoutChip(e,n){return n.kind==="completed"?{completedParams:e.completedParams.filter(i=>i.id!==n.param.id&&(!n.param.group||i.group!==n.param.group))}:{identifiedParams:e.identifiedParams.filter(i=>i.id!==n.param.id)}}removeParamAtCaret(e){let n=this.findChipSpanAt(e);if(!n)return!1;let{start:i,end:o}=n;if(e===o)return this.removeWholeChip(n),this.scheduleSetCursor(i),!0;let{text:r}=this.store.get(),a=wn(r,e),s=r.slice(0,a)+r.slice(e);return this.store.set(l=>({text:s,filterBase:Math.min(l.filterBase,s.length),...this.withoutChip(l,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(a),!0}removeWholeChip(e){let{text:n,removed:i}=Qn(this.store.get().text,e.start,e.end);this.store.set(o=>({text:n,filterBase:Math.min(o.filterBase>e.start?Math.max(e.start,o.filterBase-i):o.filterBase,n.length),...this.withoutChip(o,e),pillTapped:!1,activeDropdownIndex:-1}))}removeParam(e){let n=this.store.get(),i=n.completedParams.find(l=>l.id===e),o=i?"completed":n.identifiedParams.some(l=>l.id===e)?"identified":null;if(!o)return!1;let r=()=>{let l=0;for(let d of this.store.get().segments)if(l+=d.value.length,d.type===o&&(d.param.id===e||d.type==="completed"&&i?.group&&d.param.group===i.group))return l;return null};if(r()===null)return!1;this.store.get().editingParam&&this.exitEditMode(),this.store.get().editingIdentified&&this.exitEditingIdentified();let a=r(),s=a===null?null:this.findChipSpanAt(a);return!s||s.kind!==o?!1:(this.removeWholeChip(s),this.store.get().isFocused&&this.scheduleSetCursor(s.start),!0)}startEditingParamAtCaret(e){let n=this.findChipSpanAt(e);return!n||n.kind!=="completed"||n.end!==e||this.store.get().completedParams.find(i=>i.id===n.param.id)?.group?!1:(this.reEdit.start(n.param.id),this.store.get().editingParam?.id===n.param.id)}scheduleSetCursor(e){queueMicrotask(()=>{let n=this.domRefs;if(n)n.input.focus(),V(n.input,e);else{let i=this.opts.setCursor;i&&this.boundary.runListener("setCursor",()=>i(e))}})}clearNewParamId(){this.store.set({newParamId:null})}startEditingIdentified(e){let n=this.store.get();if(n.editingIdentified?.id===e)return!0;let i=n.identifiedParams.find(d=>d.id===e);if(!i)return!1;let o=Q(i);if(!_(o))return!1;let r=o==="date-range"?Lt(i)??At(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:Fn(i),isoEnd:r?r.end:null,format:o},editingParam:null,editingAnchor:null,editingTail:null,caretOffset:l,activeDropdownIndex:-1,pillTapped:!0}),!0}exitEditingIdentified(){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1})}startEditingParam(e){this.store.get().completedParams.find(n=>n.id===e)?.group||(this.reEdit.start(e),this.store.get().editingParam?.id!==e&&this.startEditingIdentified(e))}replaceEditingRange(e){return this.reEdit.replaceRange(e)}exitEditMode(){this.reEdit.exit()}handleCaretAfterInput(e){let n=this.spacePickCaret;if(n!=null){this.spacePickCaret=null,this.reEdit.caretAfterInput(n),this.scheduleSetCursor(n);return}this.reEdit.caretAfterInput(e)}handleCaretMove(e){let n=this.store.get().editingIdentified;n&&e!=null&&(e<n.anchor||e>n.tail)&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.reEdit.caretMove(e)}setActiveDropdownIndex(e){this.store.set({activeDropdownIndex:e})}clearHighlight(e){this.store.get().activeDropdownIndex===e&&this.store.set({activeDropdownIndex:-1})}prepareSubmit(){this.endTypedWord(!0)}recordSubmit(e){this.fireTelemetry("submit",{query:e.query,completed_pills:e.completed_params.filter(n=>n.placeholder).map(n=>({key:n.parameter,value:n.text??""}))})}endSubmitProgress(){this.submitHold.end(),this.productHold.end()}resetsAfterSubmit(){return this.renderMode==="full"&&this.opts.resetOnSubmit!==!1}showsProgress(){return this.opts.submitProgress!==!1}holdSubmit(e){this.destroyed||!this.showsProgress()||this.submitHold.active||(this.submitHold.start(nt(this.store.get()),[e]),this.store.set({isSubmitting:!0}))}selectProduct(e){let n=this.store.get();if(this.productHold.active){if(n.selectingProductId===e.id)return;this.productHold.end()}let i=n.products.findIndex(l=>l.id===e.id),o=n.customFields?.items?.matched?.find(l=>l.source_id===e.id)?.origin_id;if(this.fireTelemetry("product_click",{query:n.text,product_id:e.id,...o&&{origin_id:o},position:i>=0?i+1:null}),!this.emitter.hasListeners("productSelect"))return;let r=$i(n),{completed:a,returned:s}=this.emitter.collect("productSelect",e);this.showsProgress()&&a&&s.some(l=>l!==Ui)&&$i(this.store.get())===r&&(this.productHold.start(r,s),this.store.set({selectingProductId:e.id}))}addProductToCart(e){let n=this.opts.onProductAddToCart;if(!n)return Promise.resolve();try{return Promise.resolve(n(e)).then(()=>{})}catch(i){return Promise.reject(i)}}hasProductAddToCart(){return typeof this.opts.onProductAddToCart=="function"}handleTextChange(e){this.applyTextChange(e,!0)}handleCompositionText(e){let n=this.store.get();if(!(n.editingParam||n.editingIdentified)){if(e===n.text){n.composing&&this.store.set({composing:null});return}this.store.set({composing:{text:e,over:n.text}}),this.fetchController.previewComposition(e)}}applyTextChange(e,n){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.handleChange(e,n)}showPreviousMonth(){this.pageDateView(-1)}showNextMonth(){this.pageDateView(1)}pageDateView(e){let n=this.store.get();if(!_(n.activeFormatType)||!n.dateView)return;let i=un(n.dateView,e);this.store.set({dateViewMonth:{...i,key:U(n)},activeDropdownIndex:-1})}setTime(e){let n=this.store.get();n.activeFormatType!=="time"||!n.timeView||this.store.set({timeDraft:{minutes:$e(e),key:U(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(ia(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:U(n),picked:i.includes(e.text)?i.filter(o=>o!==e.text):[...i,e.text]}})}commitMultiSelect(){this.finishMultiSelect()}answerMultiSelectWith(e){let n=this.store.get().multiSelectView;!n||!e.is_tappable||(n.picked.includes(e.text)||this.toggleMultiSelectOption(e),this.finishMultiSelect())}finishMultiSelect(e=""){let n=this.store.get();if(!n.multiSelectView)return;let i=n.multiSelectView.picked;if(i.length===0){this.store.set({multiSelectDraft:null}),this.skipActivePill();return}let o=i.map(a=>n.actionableSuggestions[0].options?.find(s=>s.text===a)).filter(a=>a!==void 0);if(o.length===0)return;let r=i.length===1?i[0]:`${i.slice(0,-1).join(", ")} ${k(this.opts.language).and} ${i[i.length-1]}`;this.applyOption({text:r,is_tappable:!0,kind:null},o,e),n.text||this.noteSearchStarted()}commitTime(){let e=this.store.get();e.activeFormatType!=="time"||!e.timeView||(this.selectOption(An(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=U(n);this.cancelLocationSearch();let a=n.locationAutocomplete&&this.opts.locationSearch!==!1?Yt(this.opts.apiConfig):null,s="loading";a?e.trim().length<ct&&(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(Zs,()=>{this.runLocationSearch(o,e,a)},Tr)}moveLocationHighlight(e){let n=this.store.get().locationSearch,i=this.store.get().locationView;if(!n||!i||i.places.length===0||i.status==="loading")return;let o=i.places.length,r=i.highlighted<0?e>0?-1:0:i.highlighted;this.store.set({locationSearch:{...n,highlighted:((r+e)%o+o)%o}})}commitLocation(e){let n=this.store.get(),i=n.locationView;if(n.activeFormatType!=="location"||!i)return;let o=e??i.highlighted,r=o>=0?i.places[o]:void 0,a=i.query.trim();!r&&!a||(this.cancelLocationSearch(),this.locationSession=null,this.selectOption(Qt(r??a)),this.store.get().completedParams!==n.completedParams&&this.store.set({locationSearch:null}))}spacePicksTopPlace(e,n){if(n!==`${e.text} `)return!1;let i=e.locationView;if(e.activeFormatType!=="location"||!i||!e.isDropdownOpen||e.locationFieldFocused)return!1;let o=i.places[0],r=this.typedLocationQuery(e);return i.status==="done"&&!!o&&r===i.query&&Qi(o,r)}typedLocationQuery(e){let n=this.typedLocationPhrase(e);return this.isReEditing(e)?n.trim():xr(n)}isReEditing(e){return e.editingParam!=null&&e.editingAnchor!=null}typedLocationPhrase(e){if(this.isReEditing(e))return Po(e,e.optionQuery);let n=e.actionableSuggestions[0]?.parameter,i=0,o=0;for(let r of this.segmentsWithPending(e))i+=r.value.length,(r.type==="completed"||r.type==="identified"&&r.param.parameter!==n)&&(o=i);return e.text.slice(o)}segmentsWithPending(e){let n=[this.heldIdentified,this.waitingIdentified].flatMap(o=>o&&e.text.startsWith(o.text)&&e.text.slice(o.text.length).trim()===""?o.candidates:[]);if(n.length===0)return e.segments;let i=new Set(e.identifiedParams.map(o=>o.id));return an(e.text,e.completedParams,[...e.identifiedParams,...n.filter(o=>!i.has(o.id))])}async runLocationSearch(e,n,i){let o=new AbortController;this.locationAbort=o,this.locationSession?.key!==e&&(this.locationSession={key:e,token:crypto.randomUUID()});let r;try{r={places:await Cr(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 dt&&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(Zs),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||C(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.ownKeys.add(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 he(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(),e.submitProgress===!1&&(this.submitHold.end(),this.productHold.end()),"products"in e&&e.products!==n||"showProducts"in e&&e.showProducts!==o?this.productsController.resync():"mapProducts"in e&&e.mapProducts!==i&&this.productsController.refresh(),e.mode!==void 0&&this.modeController?.setMode(e.mode),e.optionsPosition!==void 0&&(this.container.dataset.optionsPosition=e.optionsPosition),e.animations!==void 0&&(this.container.dataset.animations=e.animations?"on":"off"),e.optionsStyle!==void 0&&(this.container.dataset.aiaOptionsStyle=e.optionsStyle),e.pillPlacement!==void 0&&(this.container.dataset.pillPlacement=e.pillPlacement,this.store.set({})),(e.dropdownTrigger!==void 0||e.closeDropdownOnBlur!==void 0||e.prependPlaceholder!==void 0||e.showNonTappableOptions!==void 0||e.allOption!==void 0||e.showSkipButton!==void 0||e.showOptionIcons!==void 0||e.showOptionImages!==void 0||e.showOptionCounts!==void 0||e.productsLayout!==void 0||e.productImageFallback!==void 0||e.showProductVendor!==void 0||e.seeAllResults!==void 0||e.showChipIcons!==void 0||e.showChipImages!==void 0||e.showChipRemove!==void 0||"language"in e)&&this.store.set({}),e.value!==void 0&&this.setValue(e.value),e.completedParams!==void 0&&this.store.set({completedParams:e.completedParams})}selectOption(e,n){if(e.selectsAll){this.skipActivePill();return}if(this.store.get().multiSelectView){n?.commit?this.answerMultiSelectWith(e):this.toggleMultiSelectOption(e);return}let o=!this.store.get().text;this.applyOption(e),o&&this.store.get().text&&this.noteSearchStarted()}applyOption(e,n,i=""){let o=this.store.get();if(o.dateFloor){let a=K(e);if(a&&a<o.dateFloor)return}if(o.activeFormatType==="date-range"){let a=K(e);if(a){let s=o.dateRangeStart;if(!s){this.store.set({pendingRangeStart:{iso:a,key:U(o)}});return}this.store.set({pendingRangeStart:null}),this.selectOption(ca(s,a));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(gr),this.reEdit.selectOption(e);return}let r=ya({...o,placeholderText:o.leadInText},e);if(r){if(n){let a=r.patch.completedParams?.[o.completedParams.length];if(!a||!r.patch.text)return;let s=crypto.randomUUID(),l=r.patch.text,d=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),c=n.map(u=>{let f=l.toLowerCase().indexOf(u.text.toLowerCase(),d);return d=f+u.text.length,{...a,value:u.value,kind:u.kind,metadata:u.metadata,icon:u.icon,icon_svg:u.icon_svg,image_url:u.image_url,id:crypto.randomUUID(),group:s,parameter:r.consumedSuggestion.parameter,text:l.slice(f,d)}});r.patch.completedParams=[...o.completedParams,...c],r.patch.newParamId=c[0].id,r.patch.multiSelectDraft=null,r.patch.text+=i,r.patch.caretOffset=r.patch.text.length,r.patch.suggestions=o.suggestions.filter(u=>u!==r.consumedSuggestion)}for(let a of n??[e])this.fireTelemetry("option",{raw_query:N(o.text,o.completedParams).rawQuery,selected_option:a.text,other_options:D(o.activeFormatType)?[]:o.filteredOptions.filter(s=>s.text!==a.text&&!s.selectsAll).map(s=>s.text),key:r.telemetry.key,position:D(o.activeFormatType)?null:be(r.consumedSuggestion.options??[],a.text),chip_origin:"tap"});if(this.timers.clear(gr),n?(this.timers.clear(Js),this.store.set({...r.patch,...Rt(o,n.map(a=>a.text)),inSelectionAnimation:!1})):(this.store.set({...r.patch,...Rt(o)}),this.startSelectionAnimationTimer()),this.timers.clear(Xs),r.remainingActionable>0){let a=r.consumedSuggestion;this.timers.schedule(Xs,()=>{this.store.get().suggestions.includes(a)&&this.store.set(s=>({suggestions:s.suggestions.filter(l=>l!==a)}))},el)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(Js,()=>this.store.set({inSelectionAnimation:!1}),el)}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")}subscribeHandoffHolds(){this.unsubscribers.push(this.store.subscribe(e=>{this.submitHold.active&&this.submitHold.sync(nt(e)),this.productHold.active&&this.productHold.sync($i(e))}))}subscribeVisibleImpression(){this.unsubscribers.push(this.store.subscribe((e,n)=>{this.visibleImpression&&(!e.isDropdownOpen&&n.isDropdownOpen&&(this.lastImpressionKey=""),fr(e)&&!fr(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!fr(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!C(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,Pu).map(a=>a.text)})),i=e.products.map(r=>r.id);if(n.length===0&&i.length===0)return;let o=JSON.stringify([n,i]);o!==this.lastImpressionKey&&(this.lastImpressionKey=o,this.fireTelemetry("impression",{query:e.text,pills:n,product_ids:i}))}fireTelemetry(e,n){let i=this.funnelTelemetry===!0;if(!i&&Lu.has(e))return;if(!i&&e==="option"){let{key:r,position:a,chip_origin:s,...l}=n;n=l}let o=this.resolveSource();ba({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:ue(this.opts.language),queryData:n,apiConfig:this.opts.apiConfig})}updateLanguageAttribute(){let{language:e}=k(this.opts.language);e!=="en"?this.container.dataset.aiaLanguage=e:delete this.container.dataset.aiaLanguage}setupContainer(){this.container.classList.add("magicx-aia"),this.updateLanguageAttribute(),this.container.dataset.pillPlacement=this.renderMode==="dropdown"?"dropdown":this.opts.pillPlacement??"dropdown",this.container.dataset.optionsPosition=this.opts.optionsPosition??"below",this.container.dataset.animations=this.opts.animations??!0?"on":"off",this.container.dataset.aiaOptionsStyle=this.opts.optionsStyle??"floating",this.modeController=new it(this.container,this.opts.mode??"auto")}buildAndRenderFull(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return k(e.opts.language)},get pillPlacement(){return e.opts.pillPlacement??"dropdown"},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get showProductVendor(){return e.opts.showProductVendor??!0},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get showChipIcons(){return e.opts.showChipIcons??!0},get showChipImages(){return e.opts.showChipImages??!0},get showChipRemove(){return e.opts.showChipRemove??!1},get optionsPosition(){return e.opts.optionsPosition??"below"},get onSubmit(){return e.emitter.hasListeners("submit")?e.emitSubmit:void 0},afterSubmit:()=>e.resetAfterSubmit(),endTypedWord:()=>e.endTypedWord(!0),submitButton:this.opts.submitButton,get seeAllResults(){return e.opts.seeAllResults===!0},autoFocus:this.opts.autoFocus??!0,selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o),handleKeyDown:o=>this.handleKeyDown(o),handleChange:o=>this.handleChange(o,!0),handleCompositionText:o=>this.handleCompositionText(o),startEditingParam:o=>this.startEditingParam(o),removeParam:o=>this.removeParam(o),handleCaretAfterInput:o=>this.handleCaretAfterInput(o),handleCaretMove:o=>this.handleCaretMove(o),replaceEditingRange:o=>this.replaceEditingRange(o)};this.domRefs=Us(this.container,n);let i=()=>{this.domRefs&&mr(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),mr(this.domRefs,this.store.get(),n),this.subscribeNewParamTimer()}buildAndRenderDropdown(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return k(e.opts.language)},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get showProductVendor(){return e.opts.showProductVendor??!0},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=Is(this.container,n);let i=()=>{this.dropdownRefs&&rr(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),rr(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(It),i=()=>e();n.addEventListener("change",i),this.unsubscribers.push(()=>n.removeEventListener("change",i))}subscribeBatchedRender(e){let n=!1;this.unsubscribers.push(this.store.subscribe(()=>{n||(n=!0,queueMicrotask(()=>{n=!1,e()}))}))}subscribeLocationMirror(){this.unsubscribers.push(this.store.subscribe(e=>{if(e.activeFormatType!=="location"){this.locationMirrorText=null;return}!e.isDropdownOpen||e.text===this.locationMirrorText||(this.locationMirrorText=e.text,this.mirrorTypedIntoLocationSearch())}))}subscribeSkeletonMirror(){let e=Date.now();this.unsubscribers.push(this.store.subscribe((n,i)=>{let o=s=>s.dropdownLoading&&s.skeletonOptions!==null;if(!o(i)&&o(n)&&(e=Date.now()),!n.skeletonOptions)return;if(!i.isLoading&&n.isLoading){n.skeletonRequested||this.store.set({skeletonRequested:!0});return}if(!i.isLoading||n.isLoading)return;let r={skeletonOptions:null,skeletonSuggestion:null,skeletonPicked:null,skeletonRequested:!1};if(!n.skeletonExiting){this.store.set(r);return}let a=tl-(Date.now()-e);this.timers.schedule(gr,()=>this.store.set(r),Math.min(tl,Math.max(0,a)))}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(Cu,()=>this.store.set({newParamId:null}),Au)}))}handleChange(e,n){this.store.get().composing&&this.store.set({composing:null}),this.fetchController.endPreview();let i=this.store.get();if(n&&this.spacePicksTopPlace(i,e)){this.commitLocation(0);let l=this.store.get();l.completedParams!==i.completedParams&&(this.spacePickCaret=l.caretOffset??l.text.length);return}this.spacePickCaret=null,n&&e&&!i.text&&this.noteSearchStarted(),this.store.set({text:e,pillTapped:!1,activeDropdownIndex:-1});let{valid:o,invalid:r}=Vr(e,i.completedParams);r.length>0&&this.store.set({completedParams:o});let a=this.heldIdentified;this.heldIdentified=null,this.waitingIdentified?.text!==e&&(this.waitingIdentified=null),this.openWordText=n&&/\S$/.test(e)?e:null,this.maybePromoteExactMatch(e),a&&/^\s+$/.test(e.slice(a.text.length))&&e.startsWith(a.text)&&this.admitIdentified(a.candidates),this.maybeOpenPendingSpan();let s=this.store.get();s.multiSelectView&&s.optionQuery&&s.filteredOptions.length===0&&this.finishMultiSelect(s.optionQuery)}mirrorTypedIntoLocationSearch(){let e=this.store.get(),n=e.locationView;if(e.activeFormatType!=="location"||!n||!e.isDropdownOpen||e.locationFieldFocused)return;let i=U(e),o=this.typedLocationQuery(e);if(o.length<ct){let r=this.locationMirrored;(this.typedLocationPhrase(e).trim()===""||o===""&&(r?.text.length??0)>e.text.length)&&r?.key===i&&r.query===n.query&&(this.locationMirrored=null,this.setLocationQuery(""));return}o!==n.query&&(this.setLocationQuery(o),this.locationMirrored={key:i,query:o,text:e.text})}isWordOpen(){return this.opts.commitOnWordEnd===!0&&this.openWordText===this.store.get().text}admitIdentified(e){let n=this.store.get(),{valid:i}=gt(n.text,n.completedParams,e);i.length!==0&&(this.store.set({identifiedParams:[...n.identifiedParams,...i]}),this.mirrorTypedIntoLocationSearch())}endTypedWord(e=!1){let n=this.isWordOpen();if(!n&&!e)return!1;let i=this.heldIdentified;this.heldIdentified=null,this.openWordText=null;let o=this.store.get();this.maybePromoteExactMatch(o.text,e?"submit":"fresh",n),i?.text===o.text&&this.admitIdentified(i.candidates);let r=this.waitingIdentified;e&&r?.text===o.text&&(this.waitingIdentified=null,this.admitIdentified(r.candidates));let a=this.store.get();return a.completedParams!==o.completedParams||a.identifiedParams!==o.identifiedParams}maybeOpenPendingSpan(){let e=this.store.get();if(e.pendingSpan||e.actionableSuggestions.length===0)return;let n=me(e.text,Math.min(e.filterBase,e.text.length),e.leadInText),i=Dr(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(f=>f.id!==i.id),newParamId:u.id,filterBase:c,caretOffset:c,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(c),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(D(o.activeFormatType)||this.isWordOpen())return;let r=zn({mode:n,finishWord:i,text:e,completedParams:o.completedParams,suggestions:o.suggestions,filterBase:o.filterBase,filterInProgress:o.filterInProgress,phraseExactMatch:this.fetchController.isPhraseExactMatch(),prependPlaceholder:this.opts.prependPlaceholder});if(r){if(this.funnelTelemetry===!0){let a=n==="submit"&&r.suggestion?r.suggestion:o.actionableSuggestions[0],s=a.options??[];this.fireTelemetry("option",{raw_query:N(e,o.completedParams).rawQuery,selected_option:r.option.text,other_options:s.filter(l=>l.text!==r.option.text).map(l=>l.text),key:a.parameter,position:be(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,HANDOFF_NOT_HANDLED,HINT_ATTR,HINT_EL_ATTR,HINT_HOLD_MS,LOCATION_META_KEY,LOCATION_MIN_QUERY,MULTI_DONE_FIT_VAR,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,PANEL_ENTER_DELAY_MS,PANEL_ENTER_MS,PANEL_GHOST_CLASS,PANEL_GLIDE_MS,PANEL_LEAVE_MS,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,attachChipRemove,attachProductRowWheel,attachScrollArrow,attachViewportFit,buildAttributionUrl,buildDateOptions,buildLocationOption,buildQuery,buildSubmitResult,buildTimeOption,cancelStartingHint,cellDay,cellIso,chipIdFromTap,computeOptionsGridLayout,containScroll,createStore,cursorIsAtEnd,dateCellMarks,dateFloorFor,dateSelectionFor,destroyPanelMorph,dropdownPillsFor,editingSuggestion,extractPlainText,findMultiSelectDone,fitMultiSelectDone,formatAbsoluteDate,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,getCursorOffset,getFooterHint,hasSkippablePill,highlightParts,identifiedParamLabel,inPanelGhost,isCalendarFormat,isDimmedDay,isMultiSelectToggleTap,isOptionsGridMobileViewport,isPickerFormat,isSmartSuggestion,isTraditionalAutocompleteSuggestion,isoDate,isoTime,keepCaretOnChip,labelTraditionalAutocomplete,locationEndpointFor,matchTypedPhrase,measureOptionsGrid,monthLabel,needsOptionsGridMeasurement,notePanelMorphHeight,optionCountLabel,optionEnterDelayMs,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsEntranceDurationMs,optionsGridTemplateColumns,optionsShowLeadingVisuals,panelMorphGlide,panelMorphKey,panelMorphTargetHeight,parseDate,parseLooseDate,parseLooseDateRange,parseTime,plainTextLength,planOptionsGrid,previousGraphemeBoundary,productFromMatchedItem,productImageSources,productImageSrc,productInitial,productPhotoFill,productRowWheelTarget,productsFromCustomFields,queryLive,releasePanelHug,renderEditableContent,resolveFormatType,resolveIdentifiedDate,sameOptionRows,sanitizeOptionIconSvg,scrollCaretIntoView,selectedIsoFromText,selectedRangeFor,setCursorOffset,settlePanelMorph,shopifyImageSrc,startingHintOptions,syncPanelHug,timeWheelIndex,timeWheelIndexFromScroll,timeWheelRows,toWireIdentifiedParams,typedFragment,uiStringsFor,visibleDateRange,watchEditorHeight,withSkippedParams,withTimeWheelIndex,withoutTraditionalAutocomplete});
4045
+ `;var qi=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 Ki=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=(...s)=>n(...s);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){return this.collect(e,...n).completed}collect(e,...n){let i=[],o=this.listeners[e];if(!o)return{completed:!0,returned:i};let r=!0;for(let s of o)this.boundary.runListener(String(e),()=>{i.push(s(...n))},this.keys.get(s)??String(e))||(r=!1);return{completed:r,returned:i}}hasListeners(e){return(this.listeners[e]?.size??0)>0}clear(){this.listeners={}}};function Vd(t){return t!=null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}var zi=Symbol("aia.handoff.not-handled"),Bd=new Set(["Shift","Control","Alt","Meta"]),Vt=class{constructor(e){this.opts=e;this.key=null;this.run=0;this.listening=null;this.onPageShow=e=>{e.persisted&&this.end()};this.onPointerDown=e=>{this.onControl(e)||this.end()};this.onKeyDown=e=>{Bd.has(e.key)||this.onControl(e)||this.opts.timers.schedule(`${this.opts.name}:key`,()=>{this.opts.ownsKey(e)||this.end()},0)}}get active(){return this.key!==null}start(e,n){this.stop(),this.key=e;let i=this.run;this.opts.timers.schedule(this.opts.name,()=>this.end(),8e3),this.listen();let o=n.filter(Vd),r=o.length,s=()=>{r-=1,r===0&&this.run===i&&this.end()};for(let a of o)Promise.resolve(a).then(s,l=>{throw s(),l})}sync(e){this.key!==null&&this.key!==e&&this.end()}end(){this.key!==null&&(this.stop(),this.opts.onEnd())}dispose(){this.stop()}onControl(e){return e.composedPath().some(n=>typeof n.matches=="function"&&n.matches(this.opts.controls))}listen(){let e=this.opts.document()??(typeof document>"u"?null:document);if(!e)return;let n=e.defaultView;n?.addEventListener("pageshow",this.onPageShow),e.addEventListener("pointerdown",this.onPointerDown,!0),e.addEventListener("keydown",this.onKeyDown,!0),this.listening={doc:e,view:n}}stop(){if(this.key=null,this.run+=1,this.opts.timers.clear(this.opts.name),this.opts.timers.clear(`${this.opts.name}:key`),!this.listening)return;let{doc:e,view:n}=this.listening;n?.removeEventListener("pageshow",this.onPageShow),e.removeEventListener("pointerdown",this.onPointerDown,!0),e.removeEventListener("keydown",this.onKeyDown,!0),this.listening=null}};function nt(t){return`${t.text}\0${t.completedParams.map(e=>e.id).join("\0")}`}function ji(t){return`${nt(t)}${t.products.map(e=>e.id).join("\0")}`}var Yi=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 Ud(t){let e;try{e=new URL(t??X).host}catch{return null}let n=qt.get(e);return n?`https://${n}`:null}var ol=new WeakMap;function rl(t,e){if(!t.head)return;let n=Ud(e);if(!n)return;let i=ol.get(t);i||(i=new Map,ol.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 it=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)}};var yr="aia_vid";var $d=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function sl(t){let e=t;if(typeof t=="function")try{e=t()}catch{return}return typeof e=="boolean"?e:void 0}function br(t){return t.cookie.match(new RegExp(`(?:^|; )${yr}=([^;]*)`))?.[1]}function al(t){try{let e=br(t),n=e&&$d.test(e)?e:crypto.randomUUID(),i=t.location?.protocol==="https:"?"; Secure":"";return t.cookie=`${yr}=${n}; Path=/; Max-Age=31536000; SameSite=Lax${i}`,br(t)===n?n:void 0}catch{return}}function ll(t){try{if(br(t)===void 0)return;t.cookie=`${yr}=; Path=/; Max-Age=0`}catch{}}function Sr(t){return t.isDropdownOpen&&!t.isLoading}var Gd=50,qd=new Set(["search_started","submit","product_click","impression"]),Kd="newParam",cl="suggestionRemoval",ul="selectionAnimation",Tr="skeletonExit",dl="locationSearch",zd=650,jd=0;function Yd(){return`:ac-${++jd}:`}var ml=170,pl=160;function fl(){return{text:"",composing:null,completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,locationAutocomplete:!0,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!1,isReady:!1,error:null,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,skeletonOptions:null,skeletonSuggestion:null,skeletonPicked:null,skeletonRequested:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null,multiSelectDraft:null,locationSearch:null,locationFieldFocused:!1,isSubmitting:!1,selectingProductId:null,editingIdentified:null}}var Qi=class{constructor(e,n={}){this.inputStore=Gi(fl());this._listboxId=Yd();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new Yi;this.boundary=new qi;this.subscriberCount=0;this.emitter=new Ki(this.boundary);this.sessionId=crypto.randomUUID();this.lastRequestId=null;this.searchStartedSessionId=null;this.funnelTelemetry=null;this.pendingSearchStarted=!1;this.openWordText=null;this.locationMirrorText=null;this.locationMirrored=null;this.heldIdentified=null;this.waitingIdentified=null;this.lastImpressionKey="";this.visibleImpression=!1;this.sdkVisitorId=!1;this.destroyed=!1;this.locationAbort=null;this.locationSession=null;this.spacePickCaret=null;this.emitSubmit=e=>{if(this.submitHold.active)return!1;this.recordSubmit(e);let n=nt(this.store.get()),{completed:i,returned:o}=this.emitter.collect("submit",e);return this.showsProgress()&&i&&!this.resetsAfterSubmit()&&!this.submitHold.active&&nt(this.store.get())===n&&(this.submitHold.start(n,o),this.store.set({isSubmitting:!0})),i};this.submitHold=new Vt({timers:this.timers,name:"submit-hold",controls:"[data-aia-submit], [data-aia-see-all]",document:()=>this.container.ownerDocument,ownsKey:e=>this.ownKeys.has(e),onEnd:()=>this.store.set({isSubmitting:!1})});this.productHold=new Vt({timers:this.timers,name:"product-hold",controls:'[data-aia-product][data-aia-product-state="busy"]',document:()=>this.container.ownerDocument,ownsKey:e=>this.ownKeys.has(e),onEnd:()=>this.store.set({selectingProductId:null})});this.ownKeys=new WeakSet;this.emitError=e=>this.emitter.emit("error",e);this.container=e,this.opts=n,this.renderMode=n.renderMode??"full",this.store=Ja(this.inputStore,i=>ys(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 cn(this.store,e),this.pillsController=new Dn(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new Xn({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new Nn(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new _n(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 ln(this.store,()=>this.opts.apiConfig,()=>this.opts.optionOverrides,()=>this.opts.maskCompletedText,()=>this.emitter.hasListeners("error")?this.emitError:void 0,()=>this.sessionId,()=>this.resolveSource(),()=>this.opts.additionalContext,()=>this.opts.language,{getProductId:()=>this.opts.productId,getCurrency:()=>this.opts.currency,getPrependPlaceholder:()=>this.opts.prependPlaceholder,getAllOption:()=>this.opts.allOption===!0,onRequest:({query:i,signal:o,isCurrent:r})=>{rl(this.container.ownerDocument,this.opts.apiConfig?.endpoint),this.productsController.run(i,o,r).catch(()=>{})},onAutoMatch:({active:i,matched:o,rawQuery:r})=>{let s=i.options??[];this.fireTelemetry("option",{raw_query:r,selected_option:o.text,other_options:s.filter(a=>a.text!==o.text).map(a=>a.text),key:i.parameter,position:ye(s,o.text),chip_origin:"typed"})},onResponse:({requestId:i,funnelTelemetry:o,visibleImpression:r,sdkVisitorId:s})=>{this.lastRequestId=i,this.funnelTelemetry=o,this.visibleImpression=r,this.sdkVisitorId=s,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 Rn(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",afterSubmit:this.renderMode==="full"?()=>this.resetAfterSubmit():void 0,selectOption:i=>this.selectOption(i),removeParamAtCaret:i=>this.removeParamAtCaret(i),startEditingParamAtCaret:i=>this.startEditingParamAtCaret(i),exitEditMode:()=>this.exitEditMode(),exitEditingIdentified:()=>this.exitEditingIdentified(),skipActivePill:()=>this.skipActivePill(),endTypedWord:i=>this.endTypedWord(i),stepTime:i=>this.stepTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()}),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text!==o.text&&this.emitter.emit("change",i.text),i.completedParams!==o.completedParams&&this.emitter.emit("paramsChange",i.completedParams);let r=i.isFocused||i.locationFieldFocused;r!==(o.isFocused||o.locationFieldFocused)&&(r?this.emitter.emit("focus"):this.emitter.emit("blur")),this.emitter.emit("stateChange",i)})),this.unsubscribers.push(this.store.subscribe(()=>this.maybeExitReEditOnNoMatch())),this.unsubscribers.push(this.store.subscribe(()=>{let i=this.store.get();i.locationFieldFocused&&!i.locationView&&this.store.set({locationFieldFocused:!1})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text===o.text&&i.completedParams===o.completedParams||i.suggestions.some(r=>r.leadsWithAll)&&Mt(i.text,i.completedParams.length,i.leadInText)&&this.store.set({suggestions:i.suggestions.map(r=>r.leadsWithAll?{...r,leadsWithAll:!1}:r)})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.skippedParams.length!==0&&Mt(i.text,i.completedParams.length,i.leadInText)&&(Mt(o.text,o.completedParams.length,o.leadInText)||this.store.set({skippedParams:[]}))})),this.subscribeSkeletonMirror(),this.subscribeLocationMirror(),this.subscribeVisibleImpression(),this.subscribeHandoffHolds(),this.refreshAnalyticsConsent(),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:s}=gt(i.text,i.completedParams,i.identifiedParams);s.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 s=0,a;for(let l of i.segments){if(l.type==="identified"&&s===r.anchor&&l.value===r.text){a=l.param;break}s+=l.value.length}if(a){this.store.set({editingIdentified:{...r,id:a.id}});return}this.store.set({editingIdentified:null,activeDropdownIndex:-1})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.pendingRangeStart;!o||o.key===U(i)||this.store.set({pendingRangeStart:null})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.multiSelectDraft;o&&o.key!==U(i)&&this.store.set({multiSelectDraft:null});let r=i.timeDraft;!r||r.key===U(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 s=r.anchor;if(i.text!==o.text){let l=$r(o.text,i.text,s);if(l===null){this.store.set({pendingSpan:null});return}s=l}i.text.slice(s).trim().length===0||Br(i.segments,s)?this.store.set({pendingSpan:null}):s!==r.anchor&&this.store.set({pendingSpan:{anchor:s,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(nl(this.opts.styleRoot??ge(this.container)),this.setupContainer()),this.renderMode==="full"?this.buildAndRenderFull():this.renderMode==="dropdown"&&this.buildAndRenderDropdown(),this.optionSource.start(),this.fetchController.start()}focus(){this.domRefs?.input.focus()}blur(){this.domRefs?.input.blur()}reset(){let{isFocused:e,dropdownHeld:n}=this.store.get();this.optionSource.reset(),this.locationMirrored=null,this.submitHold.dispose(),this.productHold.dispose(),this.store.set({...fl(),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.submitHold.dispose(),this.productHold.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&&(Rs(this.domRefs.input),Bi(this.domRefs.input),ar(this.domRefs.dropdown)),this.dropdownRefs&&ar(this.dropdownRefs.dropdown),this.domRefs=null,this.dropdownRefs=null,this.renderMode!=="headless"&&(this.container.innerHTML="")}setMode(e){this.modeController?.setMode(e)}prefillText(e){this.applyTextChange(e,!1)}noteSearchStarted(){this.searchStartedSessionId!==this.sessionId&&(this.searchStartedSessionId=this.sessionId,this.funnelTelemetry===null?this.pendingSearchStarted=!0:this.fireTelemetry("search_started",{}))}setValue(e){let n=this.store.get();if(n.editingIdentified&&e!==n.text){this.store.set({text:e,editingIdentified:null,activeDropdownIndex:-1});return}this.store.set({text:e})}setCompletedParams(e){this.store.set({completedParams:e})}setActivePill(e){this.pillsController.setActivePill(e);let n=this.store.get().text.length;this.store.set({caretOffset:n,isFocused:!0}),this.scheduleSetCursor(n)}removeLastParam(){this.pillsController.removeLastParam()}findChipSpanAt(e){let n=0;for(let i of this.store.get().segments){let o=n;if(n+=i.value.length,i.type!=="text"&&e>o&&e<=n)return{kind:i.type,param:i.param,start:o,end:n}}return null}withoutChip(e,n){return n.kind==="completed"?{completedParams:e.completedParams.filter(i=>i.id!==n.param.id&&(!n.param.group||i.group!==n.param.group))}:{identifiedParams:e.identifiedParams.filter(i=>i.id!==n.param.id)}}removeParamAtCaret(e){let n=this.findChipSpanAt(e);if(!n)return!1;let{start:i,end:o}=n;if(e===o)return this.removeWholeChip(n),this.scheduleSetCursor(i),!0;let{text:r}=this.store.get(),s=Pn(r,e),a=r.slice(0,s)+r.slice(e);return this.store.set(l=>({text:a,filterBase:Math.min(l.filterBase,a.length),...this.withoutChip(l,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(s),!0}removeWholeChip(e){let{text:n,removed:i}=Qn(this.store.get().text,e.start,e.end);this.store.set(o=>({text:n,filterBase:Math.min(o.filterBase>e.start?Math.max(e.start,o.filterBase-i):o.filterBase,n.length),...this.withoutChip(o,e),pillTapped:!1,activeDropdownIndex:-1}))}removeParam(e){let n=this.store.get(),i=n.completedParams.find(l=>l.id===e),o=i?"completed":n.identifiedParams.some(l=>l.id===e)?"identified":null;if(!o)return!1;let r=()=>{let l=0;for(let u of this.store.get().segments)if(l+=u.value.length,u.type===o&&(u.param.id===e||u.type==="completed"&&i?.group&&u.param.group===i.group))return l;return null};if(r()===null)return!1;this.store.get().editingParam&&this.exitEditMode(),this.store.get().editingIdentified&&this.exitEditingIdentified();let s=r(),a=s===null?null:this.findChipSpanAt(s);return!a||a.kind!==o?!1:(this.removeWholeChip(a),this.store.get().isFocused&&this.scheduleSetCursor(a.start),!0)}startEditingParamAtCaret(e){let n=this.findChipSpanAt(e);return!n||n.kind!=="completed"||n.end!==e||this.store.get().completedParams.find(i=>i.id===n.param.id)?.group?!1:(this.reEdit.start(n.param.id),this.store.get().editingParam?.id===n.param.id)}scheduleSetCursor(e){queueMicrotask(()=>{let n=this.domRefs;if(n)n.input.focus(),V(n.input,e);else{let i=this.opts.setCursor;i&&this.boundary.runListener("setCursor",()=>i(e))}})}clearNewParamId(){this.store.set({newParamId:null})}startEditingIdentified(e){let n=this.store.get();if(n.editingIdentified?.id===e)return!0;let i=n.identifiedParams.find(u=>u.id===e);if(!i)return!1;let o=Y(i);if(!_(o))return!1;let r=o==="date-range"?Lt(i)??At(i.text):null,s=0,a=-1;for(let u of n.segments){if(u.type!=="text"&&u.param.id===e){a=s;break}s+=u.value.length}if(a<0)return!1;let l=a+i.text.length;return this.store.set({editingIdentified:{id:e,parameter:i.parameter,anchor:a,tail:l,text:i.text,iso:r?r.start:Wn(i),isoEnd:r?r.end:null,format:o},editingParam:null,editingAnchor:null,editingTail:null,caretOffset:l,activeDropdownIndex:-1,pillTapped:!0}),!0}exitEditingIdentified(){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1})}startEditingParam(e){this.store.get().completedParams.find(n=>n.id===e)?.group||(this.reEdit.start(e),this.store.get().editingParam?.id!==e&&this.startEditingIdentified(e))}replaceEditingRange(e){return this.reEdit.replaceRange(e)}exitEditMode(){this.reEdit.exit()}handleCaretAfterInput(e){let n=this.spacePickCaret;if(n!=null){this.spacePickCaret=null,this.reEdit.caretAfterInput(n),this.scheduleSetCursor(n);return}this.reEdit.caretAfterInput(e)}handleCaretMove(e){let n=this.store.get().editingIdentified;n&&e!=null&&(e<n.anchor||e>n.tail)&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.reEdit.caretMove(e)}setActiveDropdownIndex(e){this.store.set({activeDropdownIndex:e})}clearHighlight(e){this.store.get().activeDropdownIndex===e&&this.store.set({activeDropdownIndex:-1})}prepareSubmit(){this.endTypedWord(!0)}recordSubmit(e){this.fireTelemetry("submit",{query:e.query,completed_pills:e.completed_params.filter(n=>n.placeholder).map(n=>({key:n.parameter,value:n.text??""}))})}getVisitorId(){return this.funnelTelemetry===!0?this.resolveVisitorId():void 0}refreshAnalyticsConsent(){this.opts.visitorId===void 0&&this.resolveOwnVisitorId()}endSubmitProgress(){this.submitHold.end(),this.productHold.end()}resetsAfterSubmit(){return this.renderMode==="full"&&this.opts.resetOnSubmit!==!1}showsProgress(){return this.opts.submitProgress!==!1}holdSubmit(e){this.destroyed||!this.showsProgress()||this.submitHold.active||(this.submitHold.start(nt(this.store.get()),[e]),this.store.set({isSubmitting:!0}))}selectProduct(e){let n=this.store.get();if(this.productHold.active){if(n.selectingProductId===e.id)return;this.productHold.end()}let i=n.products.findIndex(l=>l.id===e.id),o=n.customFields?.items?.matched?.find(l=>l.source_id===e.id)?.origin_id;if(this.fireTelemetry("product_click",{query:n.text,product_id:e.id,...o&&{origin_id:o},position:i>=0?i+1:null}),!this.emitter.hasListeners("productSelect"))return;let r=ji(n),{completed:s,returned:a}=this.emitter.collect("productSelect",e);this.showsProgress()&&s&&a.some(l=>l!==zi)&&ji(this.store.get())===r&&(this.productHold.start(r,a),this.store.set({selectingProductId:e.id}))}addProductToCart(e){let n=this.opts.onProductAddToCart;if(!n)return Promise.resolve();try{return Promise.resolve(n(e)).then(()=>{})}catch(i){return Promise.reject(i)}}hasProductAddToCart(){return typeof this.opts.onProductAddToCart=="function"}handleTextChange(e){this.applyTextChange(e,!0)}handleCompositionText(e){let n=this.store.get();if(!(n.editingParam||n.editingIdentified)){if(e===n.text){n.composing&&this.store.set({composing:null});return}this.store.set({composing:{text:e,over:n.text}}),this.fetchController.previewComposition(e)}}applyTextChange(e,n){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.handleChange(e,n)}showPreviousMonth(){this.pageDateView(-1)}showNextMonth(){this.pageDateView(1)}pageDateView(e){let n=this.store.get();if(!_(n.activeFormatType)||!n.dateView)return;let i=mn(n.dateView,e);this.store.set({dateViewMonth:{...i,key:U(n)},activeDropdownIndex:-1})}setTime(e){let n=this.store.get();n.activeFormatType!=="time"||!n.timeView||this.store.set({timeDraft:{minutes:$e(e),key:U(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(ls(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:U(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(s=>n.actionableSuggestions[0].options?.find(a=>a.text===s)).filter(s=>s!==void 0);if(o.length===0)return;let r=i.length===1?i[0]:`${i.slice(0,-1).join(", ")} ${R(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(In(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=U(n);this.cancelLocationSearch();let s=n.locationAutocomplete&&this.opts.locationSearch!==!1?Xt(this.opts.apiConfig):null,a="loading";s?e.trim().length<ct&&(a="idle"):a="unavailable",this.store.set({locationSearch:{key:o,query:e,places:a==="loading"?i.places:[],status:a,highlighted:-1}}),!(a!=="loading"||!s)&&this.timers.schedule(dl,()=>{this.runLocationSearch(o,e,s)},Pr)}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,s=i.query.trim();!r&&!s||(this.cancelLocationSearch(),this.locationSession=null,this.selectOption(Qt(r??s)),this.store.get().completedParams!==n.completedParams&&this.store.set({locationSearch:null}))}spacePicksTopPlace(e,n){if(n!==`${e.text} `)return!1;let i=e.locationView;if(e.activeFormatType!=="location"||!i||!e.isDropdownOpen||e.locationFieldFocused)return!1;let o=i.places[0],r=this.typedLocationQuery(e);return i.status==="done"&&!!o&&r===i.query&&eo(o,r)}typedLocationQuery(e){let n=this.typedLocationPhrase(e);return this.isReEditing(e)?n.trim():Lr(n)}isReEditing(e){return e.editingParam!=null&&e.editingAnchor!=null}typedLocationPhrase(e){if(this.isReEditing(e))return Io(e,e.optionQuery);let n=e.actionableSuggestions[0]?.parameter,i=0,o=0;for(let r of this.segmentsWithPending(e))i+=r.value.length,(r.type==="completed"||r.type==="identified"&&r.param.parameter!==n)&&(o=i);return e.text.slice(o)}segmentsWithPending(e){let n=[this.heldIdentified,this.waitingIdentified].flatMap(o=>o&&e.text.startsWith(o.text)&&e.text.slice(o.text.length).trim()===""?o.candidates:[]);if(n.length===0)return e.segments;let i=new Set(e.identifiedParams.map(o=>o.id));return an(e.text,e.completedParams,[...e.identifiedParams,...n.filter(o=>!i.has(o.id))])}async runLocationSearch(e,n,i){let o=new AbortController;this.locationAbort=o,this.locationSession?.key!==e&&(this.locationSession={key:e,token:crypto.randomUUID()});let r;try{r={places:await kr(i,n.trim(),{apiConfig:this.opts.apiConfig,sessionToken:this.locationSession.token,language:this.opts.language,signal:o.signal}),status:"done"}}catch(a){let l=a instanceof ut&&a.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 s=this.store.get().locationSearch;!s||s.key!==e||s.query!==n||this.store.set({locationSearch:{...s,...r,highlighted:r.places.length>0?0:-1}})}cancelLocationSearch(){this.timers.clear(dl),this.locationAbort?.abort(),this.locationAbort=null}skipActivePill(){let e=this.store.get();if(e.editingParam||e.inSelectionAnimation)return;let n=e.suggestions.filter(a=>a.parameter==="placeholder"),i=e.suggestions.filter(a=>a.parameter!=="placeholder");if(i.length===0||C(i[0]))return;let o=i[0],r=i.slice(1),s=e.skippedParams.some(a=>a.parameter===o.parameter);this.store.set({suggestions:[...n,...r],pillTapped:r.length>0,activeDropdownIndex:-1,...s?{}:{skippedParams:[...e.skippedParams,{id:crypto.randomUUID(),parameter:o.parameter,suggestionPlaceholder:o.text}]}}),r.length===0&&this.fetchNow()}handleKeyDown(e){this.ownKeys.add(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 be(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(),"analyticsConsent"in e&&this.refreshAnalyticsConsent(),"optionOverrides"in e&&e.optionOverrides!==r&&this.optionSource.refresh(),e.submitProgress===!1&&(this.submitHold.end(),this.productHold.end()),"products"in e&&e.products!==n||"showProducts"in e&&e.showProducts!==o?this.productsController.resync():"mapProducts"in e&&e.mapProducts!==i&&this.productsController.refresh(),e.mode!==void 0&&this.modeController?.setMode(e.mode),e.optionsPosition!==void 0&&(this.container.dataset.optionsPosition=e.optionsPosition),e.animations!==void 0&&(this.container.dataset.animations=e.animations?"on":"off"),e.optionsStyle!==void 0&&(this.container.dataset.aiaOptionsStyle=e.optionsStyle),e.pillPlacement!==void 0&&(this.container.dataset.pillPlacement=e.pillPlacement,this.store.set({})),(e.dropdownTrigger!==void 0||e.closeDropdownOnBlur!==void 0||e.prependPlaceholder!==void 0||e.showNonTappableOptions!==void 0||e.allOption!==void 0||e.showSkipButton!==void 0||e.showOptionIcons!==void 0||e.showOptionImages!==void 0||e.showOptionCounts!==void 0||e.productsLayout!==void 0||e.productImageFallback!==void 0||e.showProductVendor!==void 0||e.seeAllResults!==void 0||e.showChipIcons!==void 0||e.showChipImages!==void 0||e.showChipRemove!==void 0||"language"in e)&&this.store.set({}),e.value!==void 0&&this.setValue(e.value),e.completedParams!==void 0&&this.store.set({completedParams:e.completedParams})}selectOption(e,n){if(e.selectsAll){this.skipActivePill();return}if(this.store.get().multiSelectView){n?.commit?this.answerMultiSelectWith(e):this.toggleMultiSelectOption(e);return}let o=!this.store.get().text;this.applyOption(e),o&&this.store.get().text&&this.noteSearchStarted()}applyOption(e,n,i=""){let o=this.store.get();if(o.dateFloor){let s=K(e);if(s&&s<o.dateFloor)return}if(o.activeFormatType==="date-range"){let s=K(e);if(s){let a=o.dateRangeStart;if(!a){this.store.set({pendingRangeStart:{iso:s,key:U(o)}});return}this.store.set({pendingRangeStart:null}),this.selectOption(fs(a,s));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(Tr),this.reEdit.selectOption(e);return}let r=ws({...o,placeholderText:o.leadInText},e);if(r){if(n){let s=r.patch.completedParams?.[o.completedParams.length];if(!s||!r.patch.text)return;let a=crypto.randomUUID(),l=r.patch.text,u=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),c=n.map(d=>{let f=l.toLowerCase().indexOf(d.text.toLowerCase(),u);return u=f+d.text.length,{...s,value:d.value,kind:d.kind,metadata:d.metadata,icon:d.icon,icon_svg:d.icon_svg,image_url:d.image_url,id:crypto.randomUUID(),group:a,parameter:r.consumedSuggestion.parameter,text:l.slice(f,u)}});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(d=>d!==r.consumedSuggestion)}for(let s of n??[e])this.fireTelemetry("option",{raw_query:N(o.text,o.completedParams).rawQuery,selected_option:s.text,other_options:D(o.activeFormatType)?[]:o.filteredOptions.filter(a=>a.text!==s.text&&!a.selectsAll).map(a=>a.text),key:r.telemetry.key,position:D(o.activeFormatType)?null:ye(r.consumedSuggestion.options??[],s.text),chip_origin:"tap"});if(this.timers.clear(Tr),n?(this.timers.clear(ul),this.store.set({...r.patch,...Rt(o,n.map(s=>s.text)),inSelectionAnimation:!1})):(this.store.set({...r.patch,...Rt(o)}),this.startSelectionAnimationTimer()),this.timers.clear(cl),r.remainingActionable>0){let s=r.consumedSuggestion;this.timers.schedule(cl,()=>{this.store.get().suggestions.includes(s)&&this.store.set(a=>({suggestions:a.suggestions.filter(l=>l!==s)}))},ml)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(ul,()=>this.store.set({inSelectionAnimation:!1}),ml)}resolveVisitorId(){let e=this.opts.visitorId;if(e===void 0)return this.resolveOwnVisitorId();if(typeof e!="function")return e;try{return e()}catch{return}}resolveOwnVisitorId(){let e=sl(this.opts.analyticsConsent),n=this.container.ownerDocument;return e===!1&&ll(n),e===!0&&this.sdkVisitorId?al(n):void 0}resolveSource(){return this.opts.source??(this.renderMode==="full"?"full-sdk":"headless-sdk")}subscribeHandoffHolds(){this.unsubscribers.push(this.store.subscribe(e=>{this.submitHold.active&&this.submitHold.sync(nt(e)),this.productHold.active&&this.productHold.sync(ji(e))}))}subscribeVisibleImpression(){this.unsubscribers.push(this.store.subscribe((e,n)=>{this.visibleImpression&&(!e.isDropdownOpen&&n.isDropdownOpen&&(this.lastImpressionKey=""),Sr(e)&&!Sr(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!Sr(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!C(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,Gd).map(s=>s.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&&qd.has(e))return;if(!i&&e==="option"){let{key:r,position:s,chip_origin:a,...l}=n;n=l}let o=this.resolveSource();Es({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:me(this.opts.language),queryData:n,apiConfig:this.opts.apiConfig})}updateLanguageAttribute(){let{language:e}=R(this.opts.language);e!=="en"?this.container.dataset.aiaLanguage=e:delete this.container.dataset.aiaLanguage}setupContainer(){this.container.classList.add("magicx-aia"),this.updateLanguageAttribute(),this.container.dataset.pillPlacement=this.renderMode==="dropdown"?"dropdown":this.opts.pillPlacement??"dropdown",this.container.dataset.optionsPosition=this.opts.optionsPosition??"below",this.container.dataset.animations=this.opts.animations??!0?"on":"off",this.container.dataset.aiaOptionsStyle=this.opts.optionsStyle??"floating",this.modeController=new it(this.container,this.opts.mode??"auto")}buildAndRenderFull(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return R(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 showProductVendor(){return e.opts.showProductVendor??!0},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get showChipIcons(){return e.opts.showChipIcons??!0},get showChipImages(){return e.opts.showChipImages??!0},get showChipRemove(){return e.opts.showChipRemove??!1},get optionsPosition(){return e.opts.optionsPosition??"below"},get onSubmit(){return e.emitter.hasListeners("submit")?e.emitSubmit:void 0},afterSubmit:()=>e.resetAfterSubmit(),endTypedWord:()=>e.endTypedWord(!0),submitButton:this.opts.submitButton,get seeAllResults(){return e.opts.seeAllResults===!0},autoFocus:this.opts.autoFocus??!0,selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o),handleKeyDown:o=>this.handleKeyDown(o),handleChange:o=>this.handleChange(o,!0),handleCompositionText:o=>this.handleCompositionText(o),startEditingParam:o=>this.startEditingParam(o),removeParam:o=>this.removeParam(o),handleCaretAfterInput:o=>this.handleCaretAfterInput(o),handleCaretMove:o=>this.handleCaretMove(o),replaceEditingRange:o=>this.replaceEditingRange(o)};this.domRefs=Xa(this.container,n);let i=()=>{this.domRefs&&gr(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),gr(this.domRefs,this.store.get(),n),this.subscribeNewParamTimer()}buildAndRenderDropdown(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return R(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 showProductVendor(){return e.opts.showProductVendor??!0},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=Fa(this.container,n);let i=()=>{this.dropdownRefs&&lr(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),lr(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(It),i=()=>e();n.addEventListener("change",i),this.unsubscribers.push(()=>n.removeEventListener("change",i))}subscribeBatchedRender(e){let n=!1;this.unsubscribers.push(this.store.subscribe(()=>{n||(n=!0,queueMicrotask(()=>{n=!1,e()}))}))}subscribeLocationMirror(){this.unsubscribers.push(this.store.subscribe(e=>{if(e.activeFormatType!=="location"){this.locationMirrorText=null;return}!e.isDropdownOpen||e.text===this.locationMirrorText||(this.locationMirrorText=e.text,this.mirrorTypedIntoLocationSearch())}))}subscribeSkeletonMirror(){let e=Date.now();this.unsubscribers.push(this.store.subscribe((n,i)=>{let o=a=>a.dropdownLoading&&a.skeletonOptions!==null;if(!o(i)&&o(n)&&(e=Date.now()),!n.skeletonOptions)return;if(!i.isLoading&&n.isLoading){n.skeletonRequested||this.store.set({skeletonRequested:!0});return}if(!i.isLoading||n.isLoading)return;let r={skeletonOptions:null,skeletonSuggestion:null,skeletonPicked:null,skeletonRequested:!1};if(!n.skeletonExiting){this.store.set(r);return}let s=pl-(Date.now()-e);this.timers.schedule(Tr,()=>this.store.set(r),Math.min(pl,Math.max(0,s)))}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(Kd,()=>this.store.set({newParamId:null}),zd)}))}handleChange(e,n){this.store.get().composing&&this.store.set({composing:null}),this.fetchController.endPreview();let i=this.store.get();if(n&&this.spacePicksTopPlace(i,e)){this.commitLocation(0);let l=this.store.get();l.completedParams!==i.completedParams&&(this.spacePickCaret=l.caretOffset??l.text.length);return}this.spacePickCaret=null,n&&e&&!i.text&&this.noteSearchStarted(),this.store.set({text:e,pillTapped:!1,activeDropdownIndex:-1});let{valid:o,invalid:r}=qr(e,i.completedParams);r.length>0&&this.store.set({completedParams:o});let s=this.heldIdentified;this.heldIdentified=null,this.waitingIdentified?.text!==e&&(this.waitingIdentified=null),this.openWordText=n&&/\S$/.test(e)?e:null,this.maybePromoteExactMatch(e),s&&/^\s+$/.test(e.slice(s.text.length))&&e.startsWith(s.text)&&this.admitIdentified(s.candidates),this.maybeOpenPendingSpan();let a=this.store.get();a.multiSelectView&&a.optionQuery&&a.filteredOptions.length===0&&this.finishMultiSelect(a.optionQuery)}mirrorTypedIntoLocationSearch(){let e=this.store.get(),n=e.locationView;if(e.activeFormatType!=="location"||!n||!e.isDropdownOpen||e.locationFieldFocused)return;let i=U(e),o=this.typedLocationQuery(e);if(o.length<ct){let r=this.locationMirrored;(this.typedLocationPhrase(e).trim()===""||o===""&&(r?.text.length??0)>e.text.length)&&r?.key===i&&r.query===n.query&&(this.locationMirrored=null,this.setLocationQuery(""));return}o!==n.query&&(this.setLocationQuery(o),this.locationMirrored={key:i,query:o,text:e.text})}isWordOpen(){return this.opts.commitOnWordEnd===!0&&this.openWordText===this.store.get().text}admitIdentified(e){let n=this.store.get(),{valid:i}=gt(n.text,n.completedParams,e);i.length!==0&&(this.store.set({identifiedParams:[...n.identifiedParams,...i]}),this.mirrorTypedIntoLocationSearch())}endTypedWord(e=!1){let n=this.isWordOpen();if(!n&&!e)return!1;let i=this.heldIdentified;this.heldIdentified=null,this.openWordText=null;let o=this.store.get();this.maybePromoteExactMatch(o.text,e?"submit":"fresh",n),i?.text===o.text&&this.admitIdentified(i.candidates);let r=this.waitingIdentified;e&&r?.text===o.text&&(this.waitingIdentified=null,this.admitIdentified(r.candidates));let s=this.store.get();return s.completedParams!==o.completedParams||s.identifiedParams!==o.identifiedParams}maybeOpenPendingSpan(){let e=this.store.get();if(e.pendingSpan||e.actionableSuggestions.length===0)return;let n=pe(e.text,Math.min(e.filterBase,e.text.length),e.leadInText),i=Vr(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);fe(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),s=i.anchor===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,l=r.length===0||r[0]!==" "?`${s} `:s,u=o+l+r,c=u.length,d={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:s,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:u,completedParams:[...n.completedParams,d],identifiedParams:n.identifiedParams.filter(f=>f.id!==i.id),newParamId:d.id,filterBase:c,caretOffset:c,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(c),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(D(o.activeFormatType)||this.isWordOpen())return;let r=jn({mode:n,finishWord:i,text:e,completedParams:o.completedParams,suggestions:o.suggestions,filterBase:o.filterBase,filterInProgress:o.filterInProgress,phraseExactMatch:this.fetchController.isPhraseExactMatch(),prependPlaceholder:this.opts.prependPlaceholder});if(r){if(this.funnelTelemetry===!0){let s=n==="submit"&&r.suggestion?r.suggestion:o.actionableSuggestions[0],a=s.options??[];this.fireTelemetry("option",{raw_query:N(e,o.completedParams).rawQuery,selected_option:r.option.text,other_options:a.filter(l=>l.text!==r.option.text).map(l=>l.text),key:s.parameter,position:ye(a,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,HANDOFF_NOT_HANDLED,HINT_ATTR,HINT_EL_ATTR,HINT_HOLD_MS,LOCATION_META_KEY,LOCATION_MIN_QUERY,MULTI_DONE_FIT_VAR,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,PANEL_ENTER_DELAY_MS,PANEL_ENTER_MS,PANEL_GHOST_CLASS,PANEL_GLIDE_MS,PANEL_LEAVE_MS,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,attachChipRemove,attachProductRowWheel,attachScrollArrow,attachViewportFit,buildAttributionUrl,buildDateOptions,buildLocationOption,buildQuery,buildSubmitResult,buildTimeOption,cancelStartingHint,cellDay,cellIso,chipIdFromTap,computeOptionsGridLayout,containScroll,createStore,cursorIsAtEnd,dateCellMarks,dateFloorFor,dateSelectionFor,destroyPanelMorph,dropdownPillsFor,editingSuggestion,extractPlainText,findMultiSelectDone,fitMultiSelectDone,formatAbsoluteDate,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,getCursorOffset,getFooterHint,hasSkippablePill,highlightParts,identifiedParamLabel,inPanelGhost,isCalendarFormat,isDimmedDay,isMultiSelectToggleTap,isOptionsGridMobileViewport,isPickerFormat,isSmartSuggestion,isTraditionalAutocompleteSuggestion,isoDate,isoTime,keepCaretOnChip,labelTraditionalAutocomplete,locationEndpointFor,matchTypedPhrase,measureOptionsGrid,monthLabel,needsOptionsGridMeasurement,notePanelMorphHeight,optionCountLabel,optionEnterDelayMs,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsEntranceDurationMs,optionsGridTemplateColumns,optionsShowLeadingVisuals,panelMorphGlide,panelMorphKey,panelMorphTargetHeight,parseDate,parseLooseDate,parseLooseDateRange,parseTime,plainTextLength,planOptionsGrid,pointerMayHighlight,previousGraphemeBoundary,productFromMatchedItem,productImageSources,productImageSrc,productInitial,productPhotoFill,productRowWheelTarget,productsFromCustomFields,queryLive,releasePanelHug,renderEditableContent,resolveFormatType,resolveIdentifiedDate,sameOptionRows,sanitizeOptionIconSvg,scrollCaretIntoView,selectedIsoFromText,selectedRangeFor,setCursorOffset,settlePanelMorph,shopifyImageSrc,startingHintOptions,syncHighlightScroll,syncPanelHug,timeWheelIndex,timeWheelIndexFromScroll,timeWheelRows,toWireIdentifiedParams,typedFragment,uiStringsFor,visibleDateRange,watchEditorHeight,withSkippedParams,withTimeWheelIndex,withoutTraditionalAutocomplete});
4028
4046
  //# sourceMappingURL=index.js.map