@magicx-eng/ai-autocomplete-vanilla 0.80.1 → 0.80.3

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 ao=Object.defineProperty;var Ml=Object.getOwnPropertyDescriptor;var kl=Object.getOwnPropertyNames;var Rl=Object.prototype.hasOwnProperty;var _l=(t,e)=>{for(var n in e)ao(t,n,{get:e[n],enumerable:!0})},Dl=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of kl(e))!Rl.call(t,o)&&o!==n&&ao(t,o,{get:()=>e[o],enumerable:!(i=Ml(e,o))||i.enumerable});return t};var Hl=t=>Dl(ao({},"__esModule",{value:!0}),t);var fm={};_l(fm,{AIAutocomplete:()=>so,ATTRIBUTION_URL:()=>Ko,DATE_RANGE_META_END:()=>Xn,DATE_RANGE_META_START:()=>Yn,DEFAULT_OPTION_COUNT_UNIT:()=>hr,EDITOR_GROW_MS:()=>Za,HANDOFF_NOT_HANDLED:()=>io,HINT_ATTR:()=>Yi,HINT_EL_ATTR:()=>Lr,HINT_HOLD_MS:()=>Pr,LAST_SEARCH_KEY:()=>Rr,LOCATION_META_KEY:()=>ln,LOCATION_MIN_QUERY:()=>Tt,MULTI_DONE_FIT_VAR:()=>hi,MULTI_SELECT_TOGGLE_MIN_PX:()=>Da,MULTI_SELECT_TOGGLE_SLOP_PX:()=>_a,ModeController:()=>gt,OPTIONS_GRID_MOBILE_QUERY:()=>Wt,OPTION_ENTER_DELAY_VAR:()=>yi,OPTION_ENTER_FADE_MS:()=>ea,OPTION_ENTER_RISE_MS:()=>ta,OPTION_ENTER_RISE_PX:()=>na,OPTION_ENTER_STAGGER_MS:()=>Zs,OPTION_IMAGE_WIDTH:()=>Mi,PANEL_ENTER_DELAY_MS:()=>or,PANEL_ENTER_MS:()=>ir,PANEL_GHOST_CLASS:()=>ie,PANEL_GLIDE_MS:()=>tr,PANEL_LEAVE_MS:()=>nr,PLACEHOLDER_FADE_OUT_MS:()=>Us,PLACEHOLDER_LEAVING_ATTR:()=>De,PLACEHOLDER_SWAP_GAP_MS:()=>$s,PLACEHOLDER_TYPE_MS:()=>Vs,PLACEHOLDER_WORD_PAUSE_MS:()=>Bs,PRODUCT_IMAGE_WIDTH:()=>Aa,PRODUCT_PATH_PREFIX:()=>ko,PRODUCT_ROW_PX_PER_LINE:()=>Pa,RANGE_SEPARATOR:()=>No,SCHEMA_VERSION:()=>po,SCROLL_ARROW_ATTR:()=>$t,SCROLL_ARROW_BOTTOM_VAR:()=>Xo,SCROLL_ARROW_CLASS:()=>Qo,SCROLL_ARROW_FADE_MS:()=>jo,SCROLL_ARROW_LABEL:()=>oa,SCROLL_ARROW_SCROLL_IDLE_MS:()=>Yo,SCROLL_ARROW_VISIBLE_ATTR:()=>Ne,SKIPPED_PARAM_TEXT:()=>lo,SMART_SUGGESTION_SPARKLE_SVG:()=>gn,TIME_META_KEY:()=>Eo,TIME_STEP_MINUTES:()=>Fn,TIME_WHEEL_COLUMNS:()=>kt,TIME_WHEEL_ROW_HEIGHT:()=>Mt,VIEWPORT_FIT_ATTR:()=>me,VIEWPORT_FIT_HEIGHT_VAR:()=>Kt,WEEKDAY_LABELS:()=>At,addMonths:()=>Rn,attachChipRemove:()=>qi,attachProductRowWheel:()=>Ii,attachScrollArrow:()=>wi,attachViewportFit:()=>Di,buildAttributionUrl:()=>pi,buildDateOptions:()=>_n,buildLocationOption:()=>cn,buildQuery:()=>D,buildSubmitResult:()=>jt,buildTimeOption:()=>Wn,cancelStartingHint:()=>Xi,cellDay:()=>Dn,cellIso:()=>K,chipIdFromTap:()=>Pn,computeOptionsGridLayout:()=>Wo,containScroll:()=>gi,createStore:()=>eo,cursorIsAtEnd:()=>Cn,dateCellMarks:()=>ui,dateFloorFor:()=>mi,dateSelectionFor:()=>rt,destroyPanelMorph:()=>Ci,dropdownPillsFor:()=>mt,editingSuggestion:()=>qe,extractPlainText:()=>Me,findMultiSelectDone:()=>Js,fitMultiSelectDone:()=>bi,focusEditorFromTap:()=>In,focusesInputOnSelect:()=>je,formatAbsoluteDate:()=>ke,formatDate:()=>xo,formatDateRange:()=>Fo,formatOptionCount:()=>dt,formatPlace:()=>uo,formatTime:()=>Ot,getCursorOffset:()=>q,getFooterHint:()=>fi,hasSkippablePill:()=>hn,highlightParts:()=>ri,identifiedParamLabel:()=>te,inPanelGhost:()=>He,isCalendarFormat:()=>_,isDimmedDay:()=>di,isMultiSelectToggleTap:()=>_i,isOptionsGridMobileViewport:()=>nt,isPickerFormat:()=>N,isSmartSuggestion:()=>Ce,isTouchPrimary:()=>ce,isTraditionalAutocompleteSuggestion:()=>C,isoDate:()=>V,isoTime:()=>Io,keepCaretOnChip:()=>Ln,labelTraditionalAutocomplete:()=>fn,locationEndpointFor:()=>un,matchTypedPhrase:()=>Bt,measureOptionsGrid:()=>tt,monthLabel:()=>kn,needsOptionsGridMeasurement:()=>Zn,notePanelMorphHeight:()=>Li,optionCountLabel:()=>Ua,optionEnterDelayMs:()=>Si,optionHasImage:()=>br,optionImageSources:()=>ut,optionImageSrc:()=>we,optionLabel:()=>Qt,optionsEntranceDurationMs:()=>Ti,optionsGridTemplateColumns:()=>Jn,optionsShowLeadingVisuals:()=>Wi,panelMorphGlide:()=>ue,panelMorphKey:()=>Ei,panelMorphTargetHeight:()=>Pi,parseDate:()=>It,parseLooseDate:()=>Re,parseLooseDateRange:()=>Ft,parseTime:()=>Nn,plainTextLength:()=>Qe,planOptionsGrid:()=>ei,pointerMayHighlight:()=>zt,previousGraphemeBoundary:()=>An,productFromMatchedItem:()=>Ro,productImageSources:()=>qt,productImageSrc:()=>Ia,productInitial:()=>Oi,productPhotoFill:()=>ki,productRowWheelTarget:()=>ur,productsFromCustomFields:()=>Kn,queryLive:()=>B,releasePanelHug:()=>lt,renderEditableContent:()=>Zi,resolveFormatType:()=>Y,resolveIdentifiedDate:()=>jn,sameOptionRows:()=>ni,sanitizeOptionIconSvg:()=>se,scrollCaretIntoView:()=>xn,selectedIsoFromText:()=>Je,selectedRangeFor:()=>_e,setCursorOffset:()=>W,settlePanelMorph:()=>Gt,settlePickFocus:()=>Ye,shopifyImageSrc:()=>dr,startingHintOptions:()=>Ji,syncHighlightScroll:()=>Ni,syncPanelHug:()=>pa,timeWheelIndex:()=>Rt,timeWheelIndexFromScroll:()=>Bn,timeWheelRows:()=>Vn,toWireIdentifiedParams:()=>$e,typedFragment:()=>$o,uiStringsFor:()=>k,visibleDateRange:()=>ci,watchEditorHeight:()=>Ki,withSkippedParams:()=>be,withTimeWheelIndex:()=>_t,withoutTraditionalAutocomplete:()=>pn});module.exports=Hl(fm);function _(t){return t==="date"||t==="date-range"}function N(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 en=/[\p{L}\p{N}]/u,Nl=/['\u2019-]/;function Dr(t,e,n){let i=t[e];if(i===void 0)return!1;if(en.test(i))return!0;let o=t[e+n];return Nl.test(i)&&o!==void 0&&en.test(o)}function Fl(t,e,n){let i=e+n.length;return!(en.test(n[0])&&Dr(t,e-1,-1)||en.test(n[n.length-1])&&Dr(t,i,1))}function ae(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(Fl(t,r,e))return r;o===-1&&(o=r)}r=t.indexOf(e,r+1)}return o}function D(t,e){let n=t,i={},o=[],r=[],s=0;for(let a of e){let l=(i[a.parameter]??0)+1;i[a.parameter]=l;let u=`{{${a.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,d=p=>ae(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)+u+n.slice(f+a.text.length);let p=u.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+u.length}),s=f>=s?f+u.length:s+p}o.push({...a,placeholder:u})}return{rawQuery:n,completedParams:o}}var lo="skipped";function be(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:lo,kind:null}));return i.length>0?[...t,...i]:t}function tn(t,e,n){return JSON.stringify([t,be(e,n).map(i=>[i.placeholder,i.parameter,i.value??i.text??""])])}function Ue(t){let{rawQuery:e,completedParams:n}=D(t.text,t.completedParams);return tn(e,n,t.skippedParams)}var nn=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 Wl="https://api.ai-autocomplete.com",ee=`${Wl}/api/suggest`,on=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),Hr=new WeakMap;function St(t){return t?.type==="accessToken"}function Vl(t){if(!(!t||St(t)))return t}function rn(t){let e=Hr.get(t.getAccessToken);return e||(e=new nn(t),Hr.set(t.getAccessToken,e)),e}function sn(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function an(t){let e=Vl(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var ln="aiaPlace",Tt=2,Wr=250,Nr=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(" ")),Fr=new Set("city beach springs falls island park heights valley bay".split(" ")),Bl=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 Vr(t){let e=Ul(t);for(;e.length>0&&Bl.has(e[0].toLowerCase().replace(/[.,]+$/,""));)e.shift();return e.join(" ")}function Ul(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&&Nr.has(r(o))&&Fr.has(r(n))?[o,i,n]:i&&(Nr.has(r(i))||Fr.has(r(n)))?[i,n]:[n]}function uo(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function co(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function mo(t,e){let n=co(e);if(!n)return!1;if(co(t.name)===n)return!0;for(let[,i]of t.name.matchAll(/\(([^()]*)\)/g))if(co(i)===n)return!0;return!1}function Br(t,e){let n=e.metadata?.[ln];if(typeof n?.name!="string")return 0;let i={id:"",name:n.name},o=[...t.matchAll(/\S+/g)];for(let r of o){let s=r.index??0,a=t.slice(s).trim().replace(/[.,]+$/,"");if(mo(i,a))return t.length-s}return 0}function cn(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:uo(t),is_tappable:!0,kind:null,metadata:{[ln]:{id:t.id,name:t.name}}}}function un(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??ee,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 Ur(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 $e(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var $l="0.80.1",po="1.0",$r=!1;function Gl(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function le(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function ql(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function Kl(t,e,n,i,o,r,s,a,l,c,u,d,f,p,m,g){let b=e.find(P=>P.parameter==="contact"&&P.metadata?.contact_account_count)?.metadata?.contact_account_count,T=typeof b=="number"?b:void 0,y=ql();return{data:{raw_query:t,...!g&&{accepts_traditional_autocomplete:!0},...p&&{traditional_autocomplete_only:!0},client_option_parameters:f??[],completed_params:be(e.map(P=>Gl(P,n)),l??[]),...s&&s.length>0&&{identified_params:$e(s)},...a&&a.length>0&&{recently_suggested:a},...T!=null&&{contact_account_count:T},...c!==void 0&&{additional_context:c}},meta:{request_id:o,request_at:new Date().toISOString(),language:le(u),...y&&{timezone:y},...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:$l,session_id:i,...m&&{search_id:m},source:r,schema_version:po}}}async function Gr(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function fo(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=Kl(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,n.searchId,n.fullAnswer),s=i?.endpoint??ee,a=await qr(s,JSON.stringify(r),i,n.signal);if(!a.ok)throw new Error(`API error: ${a.status} ${a.statusText}`);return a.json()}async function qr(t,e,n,i){let o=sn(n);if(St(n)){let s=rn(n),a=await s.getToken(),l=await Gr(t,o,a,e,i);if(l.status===401){let c=await s.getToken(!0);l=await Gr(t,o,c,e,i)}return l}let r=an(n);return!r&&!$r&&($r=!0,console.warn("[Intent-1] 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 vt=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:le(n.language)}),o=await qr(t,i,n.apiConfig,n.signal);if(!o.ok)throw new vt(o.status);return Ur(await o.json())}function ye(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function Ge(t,e){return e===!1?"":t}function xt(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function wt(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 zr(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 Qr(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function zl(t,e){let n=Qr(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function Se(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?Qr(i).trimStart():"";if(o)return t.filter(s=>!s.is_tappable||zl(s.text,o));let r=i.toLowerCase();return t.filter(s=>!s.is_tappable||s.text.toLowerCase().includes(r))}function dn(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 Et(t,e,n,i,o){let r=wt(e,n,i),s=dn(t,r);if(s||!o||!r.trim())return s;if(r===e.slice(n))return null;let a=e.lastIndexOf(" ",n-1)+1;return dn(t,e.slice(a))}function jr(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 Xr(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function Jr(t,e){let{icon:n,icon_svg:i}=e;return!i||t.every(Yr)?t:t.map(o=>Yr(o)?o:{...o,icon:n,icon_svg:i})}function Yr(t){return!!(t.icon_svg||t.image_url)}function Ql(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function te(t){let e=Ql(t);return e.length>0?e.join(" "):t}function ne(t,e){return t.parameter||e}function Pt(t,e,n){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:n?.trim()||te(t),...e?{suggestionHeader:e}:{}}}function qe(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 mn(t,e){let n=ne(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?Pt(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 jl(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function go(t){return t.parameter_label?.trim()||jl(t.parameter)}function Ce(t){return C(t)||t?.smart_suggestion===!0}function pn(t){return t.some(C)?t.filter(e=>!C(e)):t}function fn(t,e){return t.some(n=>C(n)&&!n.text)?t.map(n=>C(n)&&!n.text?{...n,text:e}:n):t}var gn='<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 hn(t){return t.some(e=>!C(e))}function Zr(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 es(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 ts(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 ns(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 bn(t,e){let n=[],i=[],o=0;for(let r of e){let s=ae(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 Ae(t,e){let{located:n}=bn(t,e);return n.length>0?n[n.length-1].end:0}function is(t,e,n){let i=[],o=[],r=0;for(let s of n){let a=ae(t,s.text,r,l=>!e.some(c=>l<c.end&&l+s.text.length>c.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 yn(t,e,n=[]){let i=bn(t,e).located,o=[];for(let u of i){let d=o[o.length-1];u.param.group&&d?.param.group===u.param.group?(d.end=u.end,d.params?.push(u.param)):o.push({...u,...u.param.group?{params:[u.param]}:{}})}let r=is(t,o,n).located,s=[...o.map(u=>({start:u.start,end:u.end,segment:{type:"completed",value:t.slice(u.start,u.end),param:u.param,...u.params?{params:u.params}:{}}})),...r.map(u=>({start:u.start,end:u.end,segment:{type:"identified",value:u.param.text,param:u.param}}))].sort((u,d)=>u.start-d.start),a=[],l=0;for(let u of s)u.start>l&&a.push({type:"text",value:t.slice(l,u.start)}),a.push(u.segment),l=u.end;let c=t.slice(l);return c&&a.push({type:"text",value:c}),a}function os(t,e){let{located:n,missing:i}=bn(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 Lt(t,e,n){let i=bn(t,e).located,{located:o,missing:r}=is(t,i,n);return{valid:o.map(s=>s.param),invalid:r}}function rs(t,e,n){let i=e?.endpoint??ee,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${Yl(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,s)=>{let a=on.get(s);return a?`https://${a}`:r})}function Yl(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 ss(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 Xl(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var as=100,Jl=300,Zl=2;function ec(t,e){return e===0&&t.trim()===""}var Sn=class{constructor(e,n,i,o,r,s,a,l,c,u={}){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=c;this.callbacks=u;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;this.inFlight=null;this.answered=null;this.committing=!1}start(){this.startingStateOff()||this.doFetch("",[]);let e=this.store.get().text,n=this.store.get().completedParams;this.unsubscribe=this.store.subscribe(i=>{if(i.text!==e||i.completedParams!==n){if(e=i.text,n=i.completedParams,this.asksNothing(i.text,i.completedParams.length)){this.standDown();return}this.scheduleFetch()}})}startingStateOff(){return this.callbacks.getStartingState?.()===!1}asksNothing(e,n){return this.startingStateOff()&&ec(e,n)}standDown(){this.abortController?.abort(),this.abortController=null,this.clearTimers(),this.clearPreview(),this.forceNextFetch=!1,this.fetchVersion++,this.inFlight=null,this.forgetAnswer();let e=this.store.get();e.suggestions.length===0&&e.products.length===0&&e.customFields===null&&!e.traditionalAutocomplete&&!e.isLoading&&!e.isReady&&e.error===null&&e.lastRawQuery===""&&e.filterBase===0&&!e.filterInProgress&&e.activeDropdownIndex===-1&&!e.skipNextFetch||this.store.set({suggestions:[],products:[],customFields:null,traditionalAutocomplete:!1,isLoading:!1,isReady:!1,error:null,lastRawQuery:"",filterBase:0,filterInProgress:!1,activeDropdownIndex:-1,skipNextFetch:!1})}isPhraseExactMatch(){return this.phraseExactMatch}answersState(e){return this.answered!==null&&this.answered.customFields===e.customFields&&this.answered.key===this.requestKey(Ue(e))}forgetAnswer(){this.answered=null}requestKey(e){let n;try{n=JSON.stringify([le(this.getLanguage()),this.callbacks.getCurrency?.()??null,this.getAdditionalContext()??null])}catch{n=""}return`${e}\0${n}`}isCommitting(){return this.committing}answerCurrent(){let e=this.store.get(),{rawQuery:n,completedParams:i}=D(e.text,e.completedParams);if(this.asksNothing(n,i.length))return this.standDown(),Promise.resolve("unasked");let o=this.requestKey(tn(n,i,e.skippedParams));return this.inFlight?.key===o?this.inFlight.settled:(this.clearTimers(),e.skipNextFetch&&this.store.set({skipNextFetch:!1}),this.doFetch(n,i,{fullAnswer:!0}),this.inFlight?.settled??Promise.resolve("superseded"))}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)},as)}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}=D(e,r.completedParams);try{let l=await fo(s,a,{...this.requestOptions(r,n.signal,crypto.randomUUID()),traditionalAutocompleteOnly:!0});if(i!==this.previewVersion||o!==this.fetchVersion)return;let c=(l.data.suggestions??[]).find(C);if(!c)return;let u=l.meta?.traditional_autocomplete===!0;this.shownPreview={answer:c,traditionalAutocomplete:u},this.store.set({suggestions:[c],traditionalAutocomplete:u,activeDropdownIndex:-1})}catch{}}requestOptions(e,n,i){let o=e.pendingSpan?ts(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()??{}),searchId:this.callbacks.getSearchId?.()}}async doFetch(e,n,{fullAnswer:i=!1}={}){if(this.asksNothing(e,n.length)){this.standDown();return}this.abortController?.abort(),this.previewAbort?.abort(),this.previewAbort=null,this.previewPending=!1,this.shownPreview=null,this.forceNextFetch=!1;let o=new AbortController;this.abortController=o;let r=++this.fetchVersion,s="superseded",a=()=>{},l={key:this.requestKey(tn(e,n,this.store.get().skippedParams)),settled:new Promise(d=>{a=d})};this.inFlight=l;let c=this.store.get().text.length,u=this.store.get().text;try{this.callbacks.onRequest?.({query:this.store.get().text,signal:o.signal,isCurrent:()=>r===this.fetchVersion})}catch{}try{this.store.set({isLoading:!0,error:null});let d=this.store.get(),f=crypto.randomUUID(),p=e===""&&n.length===0&&d.skippedParams.length===0&&d.identifiedParams.length===0,m=p?this.startingStateUrl():void 0,g=m?await ss(fetch(m,{signal:o.signal})):null;if(r!==this.fetchVersion)return;let b=g??await fo(e,n,{...this.requestOptions(d,o.signal,f),fullAnswer:i});if(r!==this.fetchVersion)return;this.phraseExactMatch=b.meta?.phrase_exact_match===!0;let T=(b.data.suggestions??[]).find(C),y=T?[]:b.data.input??[],P=w=>({id:crypto.randomUUID(),parameter:w.parameter,text:w.text,...w.type?{type:w.type}:{},...w.iso_date?{isoDate:w.iso_date}:{},...w.iso_date_end?{isoDateEnd:w.iso_date_end}:{}}),x=y.filter(w=>w.source==="identified");this.callbacks.waitIdentified?.(x.filter(w=>w.state==="need_confirmation").map(P),u);let h=x.filter(w=>w.state!=="need_confirmation").map(P),v=this.callbacks.isWordOpen?.()??!1,E=this.store.get().text.toLowerCase(),S=w=>v&&E.endsWith(w.text.toLowerCase()),L=h.filter(w=>!S(w));v&&this.callbacks.holdIdentified?.(h.filter(S));let O=T?[T]:Xr(b.data.suggestions??[],this.getOptionOverrides());this.startingStateOff()&&(O=O.filter(w=>w.parameter!=="placeholder"));let I=y,Q=I[I.length-1],R=this.store.get().text,j,J;if(Q?.state==="in_progress"){J=!0;let w=R.toLowerCase().lastIndexOf(Q.text.toLowerCase());j=w!==-1?w:c}else J=!1,j=c;let A=O.filter(w=>w.parameter!=="placeholder")[0],fe=null;if(A&&!C(A)&&!v&&A.type?.kind!=="multi_select"&&!N(Y(A))){let w=Et(A.options,R,j,J,this.phraseExactMatch);w&&(fe={id:crypto.randomUUID(),placeholder:"",parameter:ne(w,A.parameter),text:w.text,value:w.value,kind:w.kind,suggestionParameter:A.parameter,suggestionValueType:A.type,suggestionPlaceholder:A.text,suggestionIcon:A.icon,suggestionIconSvg:A.icon_svg,options:A.options??[],metadata:w.metadata,icon:w.icon,icon_svg:w.icon_svg,image_url:w.image_url},O=O.filter(Le=>Le!==A),this.callbacks.onAutoMatch?.({active:A,matched:w,rawQuery:e}))}let Ee=b.data.custom_fields??null,Pe=this.callbacks.productsForResponse?.(Ee);this.answered=T?null:{key:l.key,customFields:Ee};let Yt=w=>{let Le=fe?[...w.completedParams,fe]:w.completedParams;fe&&this.answered&&w.text===u&&(this.answered={...this.answered,key:this.requestKey(Ue({text:w.text,completedParams:Le,skippedParams:w.skippedParams}))});let Ve=new Set,_r=Lt(w.text,Le,L).valid.map(H=>{let bt=w.identifiedParams.find(Be=>!Ve.has(Be.id)&&Be.parameter===H.parameter&&Be.text===H.text);return bt?(Ve.add(bt.id),{...H,id:bt.id}):H}),Xt=new Set(d.skippedParams.map(H=>H.id)),Jt=new Set(w.skippedParams.filter(H=>!Xt.has(H.id)).map(H=>H.parameter)),ht=Jt.size>0?O.filter(H=>H.parameter==="placeholder"||!Jt.has(H.parameter)):O,Zt=this.callbacks.getAllOption?.()===!0&&!p,ge=w.composing?this.shownPreview:null;return{suggestions:ge?[ge.answer]:Zt?ht.map(H=>H.parameter==="placeholder"?H:{...H,leadsWithAll:!0}):ht,isLoading:!1,isReady:b.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:j,filterInProgress:J,identifiedParams:_r,customFields:Ee,traditionalAutocomplete:ge?ge.traditionalAutocomplete:b.meta?.traditional_autocomplete===!0,...Pe!==void 0?{products:Pe}:{},...fe?{completedParams:Le}:{}}};this.committing=!0;try{this.store.set(Yt)}finally{this.committing=!1}s="committed",this.callbacks.onResponse?.({requestId:f,funnelTelemetry:b.meta?.funnel_telemetry===!0,visibleImpression:b.meta?.visible_impression===!0,sdkVisitorId:b.meta?.sdk_visitor_id===!0,searchIds:b.meta?.search_ids===!0})}catch(d){let f=Xl(d);s!=="committed"&&r===this.fetchVersion&&(s="failed"),r===this.fetchVersion&&(this.store.set({error:f,isLoading:!1}),this.getOnError()?.(f))}finally{if(r===this.fetchVersion&&this.store.get().isLoading)try{this.store.set({isLoading:!1})}catch{}this.inFlight===l&&(this.inFlight=null),a(s)}}startingStateUrl(){let e=this.callbacks.getProductId?.();return e?rs(e,this.getApiConfig(),le(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(Zl)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},as),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),Jl)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;if(this.forceNextFetch){let{rawQuery:v,completedParams:E}=D(o.text,o.completedParams);return this.doFetch(v,E),!0}let s=Ge(o.suggestions.filter(v=>v.parameter==="placeholder").map(v=>v.text).join(" "),this.callbacks.getPrependPlaceholder?.()),a=ye(o.text,o.filterBase,s),l=wt(o.text,a,o.filterInProgress),c=o.suggestions.filter(v=>v.parameter!=="placeholder"),u=C(c[0])?void 0:c[0],d=N(o.activeFormatType),f=u&&!d?Se(u.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&f.length>0)return!1;let p=f.filter(v=>v.is_tappable),m=u&&!d&&!this.callbacks.isWordOpen?.()?Et(u.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||xt(o.text,o.completedParams.length,s))return!1;let{rawQuery:T,completedParams:y}=D(o.text,o.completedParams),P=T.length<o.lastRawQuery.length,x=Math.abs(T.length-o.lastRawQuery.length),h=n&&T!==o.lastRawQuery;return P||x>=e||h?(this.doFetch(T,y),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};function tc(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function Te(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&tc(e)?e:t.ownerDocument??t}function Ke(t){return Te(t).activeElement??null}function F(t){return t.ownerDocument??t}function nc(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function ls(t){let e=Te(t);return!nc(e)||typeof e.getSelection=="function"?null:e}function cs(t){let e=ls(t);if(!e)return null;let n=F(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function us(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 Ie(t){let n=Te(t).getSelection?.();return n||(F(t).getSelection?.()??null)}function X(t){let e=Ie(t);if(!e||e.rangeCount===0)return null;let n=cs(t);if(n){let i=us(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 Oe(t){let e=Ie(t);if(!e||e.rangeCount===0)return null;let n=cs(t);if(!n)return e.getRangeAt(0);let i=us(e,n);if(!i)return null;let o=F(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function Ct(t,e,n){let i=Ie(t);if(!i)return null;if(ls(t))return i.collapse(e,n),i;let o=F(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function Tn(t,e){let n=t?Te(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var vn=2,ic="magicx-aia";function ds(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function oc(t){let e=F(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&&ds(s.overflowX)||r&&ds(s.overflowY))return i}if(i.classList.contains(ic))return null;i=i.parentElement}return null}function xn(t){let e=Oe(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=oc(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+vn:i.left<r&&(n.scrollLeft-=r-i.left+vn)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,s=r+n.clientHeight;i.bottom>s?n.scrollTop+=i.bottom-s+vn:i.top<r&&(n.scrollTop-=r-i.top+vn)}}var ps='[contenteditable="false"]',bo="strong[data-param-id]",ze;function rc(){if(ze!==void 0)return ze;let t=globalThis.Intl.Segmenter;if(!t)return ze=null,null;try{ze=new t(void 0,{granularity:"grapheme"})}catch{ze=null}return ze??null}function wn(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(ps))return!0;n=n.parentNode}return!1}function En(t){return F(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return wn(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Me(t){let e=En(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function Qe(t){let e=En(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function q(t){let e=X(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(wn(o,t)&&o!==t)return null;let r=0;for(let s=0;s<i&&s<o.childNodes.length;s++)r+=yo(o.childNodes[s],t);return r+ho(o,t)}return n.nodeType!==Node.TEXT_NODE||wn(n,t)?null:ho(n,t)+i}function yo(t,e){if(t.nodeType===Node.TEXT_NODE)return wn(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(ps))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=yo(o,e);return i}function ho(t,e){let n=En(e),i=0,o=n.nextNode();for(;o;){if(o===t||t.nodeType===Node.ELEMENT_NODE&&t.contains(o))return i;i+=o.data.length,o=n.nextNode()}return i}function W(t,e){let n=F(t),i=Math.max(0,Math.min(e,Qe(t))),o=En(t),r=0,s=null,a=0,l=o.nextNode(),c=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,c=l,l=o.nextNode()}let u=n.createRange();if(s){let d=s.parentElement?.closest('strong[data-seg="completed"]');d&&d!==t&&t.contains(d)?a===0?u.setStartBefore(d):a===s.data.length?u.setStartAfter(d):u.setStart(s,a):u.setStart(s,a)}else c?u.setStart(c,c.data.length):u.setStart(t,0);u.collapse(!0),Ct(t,u.startContainer,u.startOffset)&&(sc(t,u,i),xn(t))}function ms(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(bo)??null;return i&&e.contains(i)?i:null}function sc(t,e,n){let i=ms(X(t)?.node??null,t);if(i&&i!==ms(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function fs(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=q(t);return i!==null&&n===`${i}:${e}`}function gs(t){return Te(t).activeElement===t}function Pn(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(bo);if(!o||!t.contains(o))return null;let r=X(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function Ln(t,e){let n=null;for(let s of t.querySelectorAll(bo))if(s.dataset.paramId===e){n=s;break}if(!n)return;let i=ho(n,t),o=i+yo(n,t),r=q(t);r!=null&&r>=i&&r<=o||W(t,i)}function Cn(t){let e=q(t);return e==null?!1:e>=Qe(t)}function An(t,e){if(e<=0)return 0;let n=rc();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 ac="(hover: none) and (pointer: coarse)";function ce(){try{if(typeof window>"u")return!1;let t=window.matchMedia;return typeof t!="function"?!1:(So?.source!==t&&(So={source:t,list:window.matchMedia(ac)}),So.list.matches===!0)}catch{return!1}}function lc(t){let e=Ke(t);return e===t||!!e?.closest("[data-aia-location]")}function To(t){let e=X(t);e&&t.contains(e.node)&&Ie(t)?.removeAllRanges()}var So=null;function je(t){return t==="always"?!0:t==="never"?!1:!ce()}function Ye(t,e,n){if(!n&&!lc(t)){To(t);return}t.focus(),W(t,e)}function In(t){let e=X(t),n=e!==null&&t.contains(e.node);t.focus(),!n&&ce()&&W(t,Qe(t))}var hs=150,cc="[data-aia-dropdown], [data-aia-input-wrapper]",uc=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),On=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.picking=0;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(uc)),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})},hs))};this.unsubscribe=e.subscribe(()=>this.sync())}dispose(){this.unsubscribe(),this.listen(!1),this.cancelRelease(),this.recheckTimer!==null&&clearTimeout(this.recheckTimer),this.recheckTimer=null}through(e){this.picking++;try{return e()}finally{this.picking--,this.picking===0&&this.sync()}}holdThroughBlur(){let e=this.store.get();!ce()||!e.isDropdownOpen||e.dropdownHeld||(this.declined=!1,this.store.set({dropdownHeld:!0}))}sync(){let e=this.store.get(),n=ce();e.isFocused||(this.declined=!1),e.isDropdownOpen?e.isFocused&&!e.dropdownHeld&&!this.declined&&n&&this.store.set({dropdownHeld:!0}):e.dropdownHeld&&this.picking===0&&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())},hs)}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(cc))return!0;return!1}};var Xe=["January","February","March","April","May","June","July","August","September","October","November","December"],At=["S","M","T","W","T","F","S"],Ss=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Mn="aiaDate",Ts="aiaDay",bs=t=>String(t).padStart(2,"0");function V(t){return`${t.getFullYear()}-${bs(t.getMonth()+1)}-${bs(t.getDate())}`}function vo(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function dc(t){let e=vo(t).getTime()-vo(new Date).getTime();return Math.round(e/864e5)}function xo(t){let e=dc(t);return e>=0&&e<7?Ss[t.getDay()]:ke(t)}function ke(t){return t.getFullYear()===new Date().getFullYear()?`${Xe[t.getMonth()]} ${t.getDate()}`:`${Xe[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function It(t){if(!t)return null;let e=Ss.findIndex(a=>a.toLowerCase()===t.trim().toLowerCase());if(e>=0){let a=vo(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=Xe.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 kn(t){return`${Xe[t.month]} ${t.year}`}function wo(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function vs(t){return{year:t.getFullYear(),month:t.getMonth()}}function Rn(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function ys(){return{text:"",is_tappable:!1,kind:null}}function _n(t){let e=new Date(t.year,t.month,1).getDay(),n=new Date(t.year,t.month+1,0).getDate(),i=[];for(let o=0;o<e;o++)i.push(ys());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:xo(r),is_tappable:!0,kind:null,metadata:{[Mn]:V(r),[Ts]:o}})}for(;i.length%At.length!==0;)i.push(ys());return i}function Je(t){let e=It(t);return e?V(e):null}function K(t){let e=t?.metadata?.[Mn];return typeof e=="string"?e:null}function Dn(t){let e=t?.metadata?.[Ts];return typeof e=="number"?e:null}var Eo="aiaTime",Fn=5;var Po=[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 et(t){return(Math.round(t)%1440+1440)%1440}function Ao(t){let e=et(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function Hn(t){let e=t.hour%12+(t.period==="PM"?12:0);return et(e*60+t.minute)}function Ot(t){let{hour:e,minute:n,period:i}=Ao(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function Io(t){let e=et(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function Ze(t){return et(Math.round(t/5)*5)}function xs(t,e){return et(t+e)}var mc=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,pc=/^(\d{1,2}):(\d{2})$/;function Nn(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=mc.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:Hn({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=pc.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 ws(t){let e=Nn(t.editingText);if(e!=null)return Ze(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>Nn(o.text)).filter(o=>o!=null);if(n.length>0)return Ze(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return et((i.getHours()+1)*60)}function Wn(t){return{text:Ot(t),is_tappable:!0,kind:null,metadata:{[Eo]:Io(t)}}}var Mt=30,kt=["hour","minute","period"],Oo={hour:Po.map(t=>({label:String(t)})),minute:Lo.map(t=>({label:String(t).padStart(2,"0")})),period:Co.map(t=>({label:t}))};function Vn(t){return Oo[t]}function Rt(t,e){let n=Ao(Ze(e));return t==="hour"?Po.indexOf(n.hour):t==="minute"?Lo.indexOf(n.minute):Co.indexOf(n.period)}function _t(t,e,n){let i=Oo[t],o=Math.min(Math.max(n,0),i.length-1),r=Ao(Ze(e));return Hn(t==="hour"?{...r,hour:Po[o]}:t==="minute"?{...r,minute:Lo[o]}:{...r,period:Co[o]})}function Bn(t,e){let n=Oo[t].length-1;return Math.min(Math.max(Math.round(e/Mt),0),n)}function Un(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")?Cn(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function Mo(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?q(t):null}var $n=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 c=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let u=n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&u?.is_tappable){e.preventDefault(),this.ctx.selectOption(u);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&u?.is_tappable&&this.ctx.selectOption(u),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let u=Un(e.target,n),d=!!n.editingParam;if(!u&&!d&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(c)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(!c)break;let f=Un(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 u=l.indexOf(n.activeDropdownIndex),d=u>0?u-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?.(),W(d,f);break}Un(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 u=n.activeDropdownIndex-1;u>=0&&n.filteredOptions[u]?.is_tappable&&this.store.set({activeDropdownIndex:u});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let u=Mo(e.target);u!=null&&this.ctx.startEditingParamAtCaret(u)}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingAnchor!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,d=n.editingAnchor;this.ctx.exitEditMode?.(),W(u,d);break}if(this.ctx.startEditingParamAtCaret){let u=Mo(e.target);u!=null&&this.ctx.startEditingParamAtCaret(u)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let u=Mo(e.target);if(u==null)break;this.ctx.removeParamAtCaret(u)&&e.preventDefault();break}case"Enter":{e.preventDefault(),n.activeDropdownIndex>=0&&n.filteredOptions[n.activeDropdownIndex]?.is_tappable?this.clickOrSelect(n.activeDropdownIndex,n.filteredOptions,i,r):a&&this.ctx.submit();break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let u=n.filteredOptions.map((p,m)=>p.is_tappable?m:-1).filter(p=>p!==-1);if(u.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let p=e.shiftKey?u[u.length-1]:u[0];this.store.set({pillTapped:!0,activeDropdownIndex:p});break}e.preventDefault();let d=u.indexOf(n.activeDropdownIndex);if(!e.shiftKey&&!_(n.activeFormatType)&&!n.multiSelectView){let p=d>=0?u[d]:u.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?u.length-1:0;else{let p=e.shiftKey?-1:1;f=(d+p+u.length)%u.length}this.store.set({activeDropdownIndex:u[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 u=e.target.closest("[data-aia-input]")??e.target,d=n.editingTail;this.ctx.exitEditMode?.(),W(u,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!Un(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=V(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=Tn(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=Tn(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=Tn(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var Gn=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(N(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||fc(s))return;this.logOnce(s),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=Jr(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(c=>c===e.suggestion?a:c),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("[Intent-1] an optionOverrides entry threw or rejected \u2014 treated as no options. Later failures on this instance are not logged.",e))}};function fc(t){return t instanceof Error&&t.name==="AbortError"}var qn=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(c=>c.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(C(o))return;let r=i.filter((c,u)=>u!==e),s=n.suggestions.filter(c=>c.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:c}=D(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:c,selectedPill:o.text,otherPills:r.map(u=>u.text)})}let a=[...s,o,...r],l=this.store.peek({suggestions:a}).filteredOptions.findIndex(c=>c.is_tappable&&!c.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 ko="/products/",Es="https://relative.invalid";function gc(t){if(!t)return;let e;try{e=new URL(t,`${Es}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===Es?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function Ro(t,e){let n=gc(t.item_url)??bc(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:Ps(t.price,t.currency,e)},...hc(t)&&{compareAtPrice:Ps(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function hc(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 Ps(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 bc(t){if(!t.handle)return;let e=`${ko}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function Kn(t,e){return(t?.items.matched??[]).map(n=>Ro(n,e))}var zn=class{constructor(e,n,i=()=>!0,o=()=>{},r=()=>{}){this.store=e;this.getConfig=n;this.isEnabled=i;this.getLanguage=o;this.getMapper=r;this.hasLoggedError=!1;this.hasLoggedMapperError=!1}forResponse(e){if(!this.isEnabled())return[];if(this.getConfig())return;let n=Kn(e,le(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("[Intent-1] 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:[],c=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(c)}catch(s){if(n.aborted||yc(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("[Intent-1] products.fetch/transform failed \u2014 the product strip is hidden. Later failures on this instance are not logged.",e))}};function yc(t){return t instanceof Error&&t.name==="AbortError"}function Sc(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function Ls(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:Xe.findIndex(n=>n.toLowerCase().startsWith(e))}function Tc(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 vc=/^(?:(?:on|from) )?(?:the )?(\d{1,2})(?:st|nd|rd|th)$/;function _o(t){let e=vc.exec(t.trim().toLowerCase().replace(/\s+/g," "));if(!e)return null;let n=Number(e[1]);return n>=1&&n<=31?n:null}function xc(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 Cs(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function Re(t,e={}){if(!t)return null;let n=e.today??new Date,i=_o(t);if(i!==null){let c=xc(i,n);return c?V(c):null}let o=Sc(t.trim().toLowerCase()).replace(/\s+/g," "),r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o);if(r){let c=Cs(Number(r[1]),Number(r[2])-1,Number(r[3]));return c?V(c):null}let s=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(o);if(s){let c=Ls(s[1]);if(c>=0)return Qn(c,Number(s[2]),s[3],n)}let a=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(o);if(a){let c=Ls(a[2]);if(c>=0)return Qn(c,Number(a[1]),a[3],n)}let l=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(o);if(l){let c=Number(l[1]),u=Number(l[2]);return c>12&&u<=12?Qn(u-1,c,l[3],n):u>12&&c<=12?Qn(c-1,u,l[3],n):null}return null}function Qn(t,e,n,i){if(n){if(n.length!==4)return null;let r=Cs(Number(n),t,e);return r?V(r):null}let o=Tc(t,e,i);return o?V(o):null}var wc=/^\d{4}-\d{2}-\d{2}$/;function Dt(t){return typeof t=="string"&&wc.test(t)?t:null}function jn(t,e={}){return Dt(t.isoDate)??Re(t.text,e)}function Ht(t){let e=Dt(t.isoDate);return e?{start:e,end:Dt(t.isoDateEnd)}:null}var No=" - ",Yn="aiaDateRangeStart",Xn="aiaDateRangeEnd";function Nt(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var Do=/^\d{4}-\d{2}-\d{2}$/;function Ho(t){if(!Do.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 Ec=/\s+(?:to|through|thru|until|til|till)\s+/g,Pc=/[-–—]/g;function Lc(t){let e=[];for(let n of[Ec,Pc]){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 Ft(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of Lc(t.trim())){let s=Re(o.trim(),e);if(!s)continue;let a=_o(r)!==null?Re(r.trim(),{...e,today:Ho(s)??e.today}):Re(r.trim(),e);!a||a<s||(n.add(`${s}|${a}`),i={start:s,end:a})}return n.size===1?i:null}function Fo(t){let e=Ho(t.start),n=Ho(t.end);return!e||!n?"":t.start===t.end?ke(e):`${ke(e)}${No}${ke(n)}`}function As(t,e){let n=Nt(t,e);return{text:Fo(n),is_tappable:!0,kind:null,metadata:{[Yn]:n.start,[Xn]:n.end}}}function _e(t,e={}){let n=t?.metadata?.[Yn],i=t?.metadata?.[Xn];return typeof n=="string"&&typeof i=="string"&&Do.test(n)&&Do.test(i)?Nt(n,i):Ft(t?.text,e)}var Wt="(max-width: 768px)";var Cc="var(--aia-option-row-height, 37px)",Ac="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)",Ic="max(0, var(--aia-option-peek, 0))";function Wo(t,e){let n=e?5:4;return Is(1,Math.min(t,n),t>n)}function Is(t,e,n){let i=n?`(${e} + ${Ic})`:`${e}`;return{cols:t,rows:e,maxHeight:`calc(${i} * ${Cc} + ${Ac})`}}function Zn(t,e){return!e&&t>=5}function ei(t,e,n,i){if(!(!e&&t>=5&&Oc(n,i))){let s=Wo(t,e);return{...s,template:Jn(s.cols),scrollHintIndices:!e&&t>s.rows?[s.rows-1]:[]}}let r=6;return{...Is(2,3,t>r),template:Jn(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function Oc(t,e){return!t||t.length===0||e==null||e<=0||t.some(i=>i<=0)?!1:Math.ceil(Math.max(...t))*2<=e}function tt(t){if(typeof document>"u")return null;let e=Array.from(t.querySelectorAll("[data-aia-option]"));if(e.length===0)return null;let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:-9999px;top:0;";for(let 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)+Mc(t);return{rowWidths:i,gridWidth:r}}function Mc(t){let e=t.closest("[data-aia-dropdown]"),n=Number.parseFloat(e?.getAttribute(ti)??"");if(!e||!Number.isFinite(n)||e.style.getPropertyValue(Vt)!=="")return 0;let i=e.getBoundingClientRect().width;return i>0?n-i:0}var ti="data-aia-glide-width",Vt="--aia-glide-content-width";function Jn(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function nt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Wt).matches}function ni(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}var Os={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"},kc={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"},Vo={en:Os,es:kc,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"}},Rc={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 Vo[o?"zh-TW":"zh-CN"]}let i=Rc[e]??e;return Object.prototype.hasOwnProperty.call(Vo,i)?Vo[i]:Os}function Ms(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,c=t.caretOffset==null||t.caretOffset>=l;return(s||t.isLoading)&&a&&c}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 ii(t){if(!t)return wo();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function _c(t){let e=It(t);return e?vs(e):wo()}function Dc(t,e){if(!t)return null;for(let n of e){if(n.parameter!==t||n.type?.kind!=="date_range")continue;let i=Ht(n);if(i&&i.end==null)return i.start}return null}function Hc(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(Dt(i.metadata?.[Mn])??Je(i.text)),o==="date_range"){let r=_e(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=Ht(i);n(r?.start),n(r?.end)}return[...e].sort()}function Bo(t,e){return t.editingParam!=null&&t.editingAnchor!=null?e:t.text.slice(Ae(t.text,t.completedParams))}var Nc=/price/i;function Fc(t){return!t||Ce(t)||N(Y(t))||t.type?.kind==="multi_select"||Nc.test(t.parameter)?!1:(t.options??[]).filter(e=>e.is_tappable).length>=2}function it(t,e,n){if(e>0)return!1;let i=t.trim();return i===""||i.toLowerCase()===n.trim().toLowerCase()||xt(i,0,n)}var Wc=4;function Vc(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,Wc);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 Bc(t,e){let{composing:n}=t,i=n?.over===t.text?n.text:t.text,o=i.slice(Ae(i,t.completedParams));return e?.completes_word!==!0?o:o.match(/\S+(?=\s*$)/)?.[0]??""}function ks(t,e){let n=yn(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(M=>M.parameter!=="placeholder"),o=i[0],r=e.startingState===!1,s=r?"":t.suggestions.filter(M=>M.parameter==="placeholder").map(M=>M.text).join(" "),a=Ge(s,e.prependPlaceholder),l=ye(t.text,Math.min(t.filterBase,t.text.length),a),u=l===0&&xt(t.text,t.completedParams.length,a)?"":wt(t.text,l,t.filterInProgress),d=o?.options??[],f=t.editingParam!=null&&t.editingAnchor!=null,p=!f&&!t.editingIdentified&&o?.type?.kind==="multi_select",m,g,b,T;if(f&&t.editingParam&&t.editingAnchor!=null){let M=t.editingParam.id,G=t.completedParams.some(he=>he.id===M),yt=t.caretOffset??t.editingAnchor,Z=G?"":t.text.slice(t.editingAnchor,yt);g=Z.trim(),b=t.editingParam.options,T=t.editingParam.suggestionParameter,m=t.editingParam.suggestionValueType?.kind==="traditional_autocomplete"?Se(t.editingParam.options,Z).map(he=>({...he,matchedText:g,parameterLabel:go(he)})):Se(t.editingParam.options,Z)}else g=u.trim(),b=d,T=o?.parameter,m=C(o)?d.map(M=>({...M,matchedText:Bc(t,o),parameterLabel:go(M)})):Se(d,u,t.traditionalAutocomplete);let y=t.optionSearch,P=y!=null&&T!=null&&y.parameter===T;P&&y.status==="done"&&y.query===g&&(m=b);let x=P&&y.status==="loading",h=e.showNonTappableOptions===!1;h&&(m=m.filter(M=>M.is_tappable));let v=it(t.text,t.completedParams.length,a);e.allOption===!0&&o?.leadsWithAll===!0&&!v&&!f&&!t.editingIdentified&&u.trim()===""&&Fc(o)&&(m=Vc(m,k(e.language).allOption));let E=Bo(t,g),S=f?t.editingParam?.suggestionValueType?.kind==="traditional_autocomplete":C(o);!p&&!S&&(m=jr(m,E));let L=t.editingIdentified,O=f?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,I=L?L.format:Y(O),Q=f?t.editingParam?.suggestionParameter:o?.parameter,R=I==="location"&&Q&&e.optionOverrides?.[Q]?"options":I,j=f&&R==="date-range"?_e(t.editingParam):null,J=!f&&!L&&R==="date"?Dc(o?.parameter,t.identifiedParams):null,pe=null,A=null,fe=_(R)?Hc(t):[];if(_(R)){let M=V(new Date),G=fe.find(Ol=>Ol>=M)??null,yt=U({...t,actionableSuggestions:i}),Z=t.dateViewMonth;pe=Z&&Z.key===yt?{year:Z.year,month:Z.month}:L?ii(L.iso):j?ii(j.start):J?ii(J):G&&!f?ii(G):_c(t.editingParam?.text),m=_n(pe);let he=t.pendingRangeStart;R==="date-range"&&he&&he.key===yt&&(A=he.iso)}let Ee=null;if(R==="time"){let M=U({...t,actionableSuggestions:i}),G=t.timeDraft;Ee=G&&G.key===M?{minutes:G.minutes,touched:!0}:{minutes:ws({editingText:f?t.editingParam?.text:null,options:f?t.editingParam?.options:o?.options}),touched:!1},m=[]}let Pe=null;if(R==="location"){let M=U({...t,actionableSuggestions:i}),G=t.locationSearch;if(G&&G.key===M){let{key:yt,...Z}=G;Pe=Z}else Pe={query:f?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};m=[]}let Yt=M=>h?M.is_tappable:!0,w;if(f){let M=t.editingParam?.options??[];w=t.editingParam!=null&&M.filter(Yt).length===0}else w=o!=null&&d.filter(Yt).length===0;Ee&&(w=!0),Pe&&(w=!0);let Le=t.composing?.over===t.text?t.composing.text:t.text,Ve=r&&it(Le,t.completedParams.length,a),Xt=Ms({inEditMode:f||L!=null,filteredOptionsLength:m.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||x,pillTapped:t.pillTapped,activePillHasNoOptions:w,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur})&&!Ve,Jt=Xt&&t.activeDropdownIndex>=0&&!!m[t.activeDropdownIndex]?.is_tappable,ht=!Ve&&t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,Zt=!Ve&&(t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||x||ht),ge=Zt&&t.skeletonOptions!==null,H=ge&&t.skeletonOptions?t.skeletonOptions:m,bt=ge?t.skeletonSuggestion:null,Be=p?{picked:t.multiSelectDraft?.key===U({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,Il=Be??(ge&&t.skeletonSuggestion?.type?.kind==="multi_select"?{picked:t.skeletonPicked??[]}:null);return{segments:n,actionableSuggestions:i,filteredOptions:m,dropdownLoading:Zt,dropdownOptions:H,dropdownSuggestion:bt,skeletonExiting:ht,activeFormatType:R,dateView:pe,dateRangeStart:A,dateFloor:J,dateReferences:fe,timeView:Ee,multiSelectView:Be,dropdownMultiSelect:Il,locationView:Pe,placeholderText:s,leadInText:a,optionQuery:g,isSearchingOptions:x,isDropdownOpen:Xt,isActivePillSelected:Jt}}function oi(t){return t.mode!=="edit"?$c(t):Gc(t)}function Uc(t,e,n){let i=t.find(C);if(!i?.options)return null;let o=e.slice(Ae(e,n)).trim().toLowerCase();if(!o)return null;let r=i.completes_word===!0?o.split(/\s+/).pop()??"":o,s=i.options.filter(c=>c.is_tappable&&c.text.trim().toLowerCase()===r);if(new Set(s.map(c=>ne(c,i.parameter))).size!==1)return null;let l=s[0];return{suggestion:i,option:l,matchText:l.text.trim()}}function Rs(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,s=n.find(u=>u.parameter!=="placeholder"&&!C(u));if(!s?.options||s.type?.kind==="multi_select")return null;let a=n.filter(u=>u.parameter==="placeholder").map(u=>u.text).join(" "),l=ye(e,i,Ge(a,t.prependPlaceholder)),c=Et(s.options,e,l,o,r===!0);return c?{suggestion:s,option:c,matchText:c.text}:null}function $c(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?Rs(t):null)??Uc(i,e,n):Rs(t);if(!o)return null;let{suggestion:r,option:s,matchText:a}=o,l=a.toLowerCase(),c=e.toLowerCase().lastIndexOf(l),u=c>=0?c:Math.max(0,e.length-s.text.length),d=u+a.length,f=e.slice(u,d),m=d<e.length&&e[d]===" "?d+1:d,g={id:crypto.randomUUID(),placeholder:"",parameter:ne(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)?Pt(ne(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 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 s=e.slice(o,r),a=dn(i.options,s);if(!a)return null;let l=a.text.toLowerCase(),c=s.toLowerCase().lastIndexOf(l),u=o+Math.max(0,c),d=u+a.text.length,f=e.slice(u,d),p=d<e.length&&e[d]===" "?d+1:d,m=e.length,g={id:crypto.randomUUID(),placeholder:"",...mn(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 x=ae(e,n[P].text,T);if(x!==-1){if(x>=p){b=P;break}T=x+n[P].text.length}}let y=[...n];return y.splice(b,0,g),{patch:{text:e,completedParams:y,newParamId:g.id,filterBase:m,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:m,activeDropdownIndex:-1},caretPos:m,option:a}}function $o(t){return t.slice(t.search(/\S*$/))}function Ds(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function Go(t,e){let n="",i=0;for(let o of t){let r=i;if(n+=Ds(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 Hs(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 Uo(t){return[...t].map(Ds).join("")}function Bt(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(Uo),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:Uo(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 c=i[a+o-1],u=Go(c.text,s);if(u)return{typedWords:o,start:i[a].index,end:c.index+u.length,partialStart:c.index+u.partialStart}}}return null}function _s(t,e,n,i){return[{text:t.slice(0,e),bold:!1},...Hs(t,e,n,i),{text:t.slice(n),bold:!1}].filter(o=>o.text!=="")}function qc(t,e){let n=0;for(let i of t){if(!/^\p{M}/u.test(i)){let o=Go(t.slice(n),e);if(o)return{start:n,end:n+o.length,partialStart:n+o.partialStart}}n+=i.length}return null}var Kc=/\p{Script=Hangul}/u;function ri(t,e){let n=e?Bt(t,e):null;if(n&&n.typedWords>1)return _s(t,n.start,n.end,n.partialStart);let i=e?$o(e):"",o=Uo(i);if(!o)return[{text:t,bold:!1}];let r=[],s=!1;for(let l of t.split(/(\s+)/)){if(l==="")continue;let c=/^\s/.test(l)?null:Go(l,o);if(c){s=!0;let{length:d,partialStart:f}=c;r.push(...Hs(l,0,d,f))}let u=c?l.slice(c.length):l;u&&r.push({text:u,bold:!1})}if(s||!Kc.test(i))return r;let a=qc(t,o);return a?_s(t,a.start,a.end,a.partialStart):r}var zc=6e4;function Qc(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function jc(t){return(t??ee).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function Yc(t){return St(t)?`Bearer ${await rn(t).getToken()}`:an(t)}async function Ns(t){try{let e=jc(t.apiConfig?.endpoint),n=sn(t.apiConfig),i=await Yc(t.apiConfig);i&&(n.Authorization=i);let o=JSON.stringify({source:t.source,session_id:t.sessionId,...t.visitorId&&{visitor_id:t.visitorId},...t.searchId&&{search_id:t.searchId},...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&&Qc(o)<=zc&&{keepalive:!0}})}catch{}}function ve(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var qo=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function Xc(t,e,n){let i=qo(t??"");if(i.length===0)return"";let r=qo(e).slice(-i.length),s=qo(n).slice(0,i.length);return r.join(" ")===i.join(" ")||s.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function Fs(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:ne(e,n.parameter),s=i?t.text.length:t.filterBase,a=t.text.slice(0,s),l=a.length===0&&t.text.length===0,c=a.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||c)&&t.placeholderText&&(a=`${t.placeholderText} `);let u=Math.min(Ae(t.text,t.completedParams),a.length),d=!1;if(i&&n.completes_word!==!0){let S=[...a.slice(u).matchAll(/\S+/g)],L=Bt(e.text,a.slice(u)),O=S[S.length-(L?.typedWords??1)];a=a.slice(0,O?u+(O.index??0):Math.max(a.lastIndexOf(" ")+1,u))}else if(n.completes_word===!0){let S=[...a.slice(u).matchAll(/\S+/g)],L=S[S.length-1];a=a.slice(0,L?u+(L.index??0):Math.max(a.lastIndexOf(" ")+1,u))}else if(n.completes_word!==!1){let S=a.slice(u),L=Math.max(zr(S,e.text),Br(S,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&&!N(t.activeFormatType)&&N(Y({type:n.type})),g=p||m?"":Xc(n.lead_in,a,e.text),b=`${a}${f?" ":""}${g?`${g} `:""}${e.text} `,y=(l||c||i&&a.length===0)&&b.length>0?b[0].toUpperCase()+b.slice(1):b,P=y.toLowerCase().lastIndexOf(e.text.toLowerCase()),x=P>=0?y.slice(P,P+e.text.length):e.text,h=i?Pt(r,n.text,e.parameter_label):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text,suggestionIcon:n.icon,suggestionIconSvg:n.icon_svg},v={id:crypto.randomUUID(),placeholder:"",...h,text:x,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},E=t.actionableSuggestions.length-1;return{patch:{text:y,filterBase:y.length,completedParams:[...t.completedParams,v],newParamId:v.id,caretOffset:y.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(S=>S.text!==e.text).map(S=>S.text),key:i?r:n.parameter,position:ve(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:E}}function Ut(t,e){let n=N(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,i=t.editingParam,o=i?qe(i):t.actionableSuggestions[0]??null;return{skeletonOptions:n,skeletonSuggestion:n?o:null,skeletonPicked:n?e??null:null,skeletonRequested:!1}}function si(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 ai=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=ae(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===""?si(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(c=>c.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=mn(i,e);this.deps.fireTelemetry("option",{raw_query:D(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(y=>y.text!==e.text).map(y=>y.text),key:s.suggestionParameter,position:ve(i.options,e.text),chip_origin:"tap"});let a=n.text.slice(0,o),l=n.text.slice(r),c=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,d=l.length===0||l[0]!==" "?`${c} `:c,f=a+d+l,p=f.length,m={id:crypto.randomUUID(),placeholder:"",...s,text:c,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},g=n.completedParams.findIndex(y=>y.id===i.id),b=n.completedParams.filter(y=>y.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,...Ut(n)}),this.deps.startSelectionAnimationTimer(),this.deps.schedulePickCursor(p),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=oi({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 Vs=33,Bs=70,Us=120,$s=50,De="data-aia-placeholder-leaving",ot=new WeakMap;function li(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function Jc(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Gs(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function qs(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Gs(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(()=>qs(t,e),33+i)}function Ws(t,e){Gs(t,e,0),e.timer=setTimeout(()=>qs(t,e),33)}function Ks(t,e){let n=ot.get(t);if(e===""){n&&(li(n),ot.delete(t)),t.removeAttribute(De),delete t.dataset.placeholder;return}if(n?.target===e)return;if(Jc(t)){n&&li(n),t.removeAttribute(De),ot.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&&li(n),ot.set(t,i),o){t.setAttribute(De,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(De),t.isConnected&&Ws(t,i)},170);return}t.removeAttribute(De),Ws(t,i)}function zs(t){let e=ot.get(t);e&&(li(e),ot.delete(t))}var Zc={selectedIso:null,selectedRange:null,rangeStart:null};function rt(t){if(!_(t.activeFormatType))return Zc;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?Nt(i,o):null,rangeStart:t.dateRangeStart,references:t.dateReferences??[]}}let n=_e(t.editingParam);return{selectedIso:n?null:Je(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart??t.dateFloor??null,floor:t.dateFloor??null,references:t.dateReferences??[]}}function ci(t){let e=t.floor!=null&&t.highlightedIso!=null&&t.highlightedIso<t.floor?null:t.highlightedIso;return t.pendingStart?Nt(t.pendingStart,e??t.pendingStart):t.selected}function ui(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 di(t,e,n){return t==null?!1:t<e||n!=null&&t<n}function mi(t,e){return t==="date"?e??null:null}var Ko="https://magicx.ai/intent-1";function pi(t=Ko){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 fi(t,e,n=k()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function gi(t){let e=s=>{s.ctrlKey||Qs(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,c=i-a.clientY;n=a.clientX,i=a.clientY,s.cancelable&&!Qs(s.target,t,l,c)&&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 Qs(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&eu(o,i)||n!==0&&tu(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var js=/^(auto|scroll|overlay)$/;function eu(t,e){return t.scrollHeight<=t.clientHeight||!js.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function tu(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!js.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 st(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 Ys=new WeakMap,Xs=new WeakSet;function $(t,e,n){if(Ys.set(t,n),Xs.has(t))return;Xs.add(t);let i=()=>Ys.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 xe(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function z(t){t.offsetWidth}var ie="magicx-aia-panel-ghost";function He(t){return t.closest(`.${ie}`)!==null}function B(t,e){for(let n of t.querySelectorAll(e))if(!He(n))return n;return null}var hi="--aia-multi-done-fit";function Js(t){return B(t,"[data-aia-multi-done]")}function bi(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(He(s))continue;let a=n.defaultView?.getComputedStyle(s),l=Number.parseFloat(i?a?.paddingRight??"0":a?.paddingLeft??"0")||0,c=n.createTreeWalker(s,NodeFilter.SHOW_TEXT),u=n.createRange();for(let d=c.nextNode();d;d=c.nextNode()){if(!d.textContent?.trim())continue;u.selectNodeContents(d);let f=u.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(hi,`${Math.ceil(r)}px`):e.style.removeProperty(hi)}var Zs=40,ea=340,ta=340,na=7,yi="--aia-option-enter-delay";function Si(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 Ti(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 vi(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function xi(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,s=t.ownerDocument?.visibilityState==="hidden";if(!r||s||vi(t))return t.scrollTop=o+e,i(),()=>{};let a=!1,l=n.performance?.now?.()??Date.now(),c=()=>n.performance?.now?.()??Date.now(),u=()=>{if(a)return;let d=Math.min(1,(c()-l)/240),f=1-(1-d)*(1-d);t.scrollTop=o+e*f,d<1?r.call(n,u):i()};return r.call(n,u),()=>{a=!0}}var Qo="magicx-aia-scroll-arrow",$t="data-aia-scroll-arrow",Ne="data-aia-visible",jo=1e3,Yo=160,Xo="--aia-scroll-arrow-bottom",oa="Scroll down for more options",zo="data-aia-scrollable",nu="--aia-scroll-track-top",iu="--aia-scroll-track-height",ou="--aia-scroll-track-right",ru="--aia-scroll-thumb-top",su="--aia-scroll-thumb-height",au=12,lu=.5,cu="[data-aia-products-label]",uu="--aia-option-peek",du=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;function mu(t){let e=t?.trim()??"";if(!du.test(e))return 0;let n=Number(e);return Number.isFinite(n)&&n>0?n:0}function pu(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 ia=4,fu=8;function gu(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 ra(t=document,e=k()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=Qo,n.setAttribute($t,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(gu(t)),n}function hu(t){return Math.max(1,Jo(t.style.gridTemplateColumns))}function wi({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,c=v=>{if(v){if(n.hasAttribute(Ne))return;if(n.setAttribute(Ne,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),vi(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(Ne)&&(n.disabled=!1)},jo)}else n.removeAttribute(Ne),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},u=v=>{let E=0,S=v;for(;S&&S!==t;)E+=S.offsetTop,S=S.offsetParent instanceof HTMLElement?S.offsetParent:null;return E},d=()=>{let v=B(t,cu),E;if(v){let S=u(v)+v.offsetHeight/2;E=t.clientHeight-S-n.offsetHeight/2}else{let S=u(e),L=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;E=t.clientHeight-(S+e.offsetHeight)+(L>0?0:fu)}n.style.setProperty(Xo,`${Math.max(0,Math.round(E))}px`)},f=v=>{let E=0,S=v;for(;S&&S!==t;)E+=S.offsetLeft,S=S.offsetParent instanceof HTMLElement?S.offsetParent:null;return E},p=null,m=(v,E)=>{let S=Math.min(1,Math.max(0,e.scrollTop/v));n.style.setProperty(ru,`${Math.round(E*S)}px`)},g=()=>{let v=e.scrollHeight-e.clientHeight,E=e.querySelector("[data-aia-option][data-aia-loading]")!==null;if(v<=ia||E){p=null,n.removeAttribute(zo);return}let S=e.clientHeight,L=Math.round(S*lu),O=u(e)+(S-L)/2,I=t.clientWidth-(f(e)+e.offsetWidth),Q=Math.min(L,Math.max(au,Math.round(L*S/e.scrollHeight)));p={overflow:v,travel:L-Q},n.style.setProperty(nu,`${Math.round(O)}px`),n.style.setProperty(iu,`${L}px`),n.style.setProperty(ou,`${Math.max(0,Math.round(I))}px`),n.style.setProperty(su,`${Q}px`),m(v,p.travel),n.setAttribute(zo,"")},b=()=>{if(o||s!==null||a!==null)return;let v=e.querySelector("[data-aia-option][data-aia-loading]")!==null,E=e.scrollHeight-e.clientHeight-e.scrollTop;c(!v&&E>ia)},T=()=>{if(o)return;d(),g();let v=e.getAttribute("data-aia-group")??"";if(v!==r){r=v,c(!1),s!==null&&clearTimeout(s);let E=e.querySelectorAll("[data-aia-option]").length,S=vi(e)?0:Ti(E,hu(e));s=setTimeout(()=>{s=null,b()},S);return}b()},y=()=>{o||(p&&m(p.overflow,p.travel),s===null&&(c(!1),a!==null&&clearTimeout(a),a=setTimeout(()=>{a=null,b()},Yo)))};e.addEventListener("scroll",y,{passive:!0});let P=v=>v.preventDefault(),x=()=>{let v=i?i.getComputedStyle(e):null,E=v?(Number.parseFloat(v.paddingTop)||0)+(Number.parseFloat(v.paddingBottom)||0):0,S=mu(v?.getPropertyValue(uu)),L=S>0?pu(e):0,O=Math.max(1,e.clientHeight-E-S*L);xi(e,O,i,y)};n.addEventListener("mousedown",P),n.addEventListener("click",x);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",y),n.removeEventListener("mousedown",P),n.removeEventListener("click",x),h?.disconnect(),n.removeAttribute(Ne),n.removeAttribute(zo),n.setAttribute("aria-hidden","true"))}}}var sa="cubic-bezier(0.25, 0.1, 0.25, 1)",bu="cubic-bezier(0.32, 0.72, 0, 1)",tr=360,nr=280,ir=320,or=40,aa="blur(2px)",yu=160,Su=.05,Tu=/pressed/i;function la(){return typeof performance<"u"?performance.now():Date.now()}function vu(t){for(let e of t.querySelectorAll("[data-aia-loading]"))if(!e.closest(`.${ie}`))return!0;return!1}function xu(t){return t===null?1:1-Math.min(1,Math.max(0,(la()-t)/yu))**1.7}function rr(t){return t.hasAttribute($t)}function er(t){let e=0;for(let n of Array.from(t.children))n.classList.contains(ie)||rr(n)||(e+=n.offsetHeight||0);return e}var oe=new WeakMap;function wu(t){return(Number.parseFloat(t.borderLeftWidth)||0)+(Number.parseFloat(t.borderRightWidth)||0)}function Eu(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 Zo=new WeakMap;function Pu(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 Lu(t,e){let n=0,i="";for(let o of Array.from(t.children))o.classList.contains(ie)||(n+=1+o.getElementsByTagName("*").length,i+=`${o.textContent??""}\0`);return`${e??""}${n}${i}`}function Cu(t){let e=t.ownerDocument.createElement("div");e.className=ie,e.setAttribute("aria-hidden","true"),e.inert=!0;for(let n of Array.from(t.children))n.classList.contains(ie)||rr(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))Tu.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 Au(t,e,n,i,o){for(let s of Array.from(t.children))s.classList.contains(ie)&&s.remove();let r=Array.from(t.children).filter(s=>!rr(s));i>Su&&Ou(t,e,n,i,o);for(let s of r)Iu(s),s.animate([{opacity:0,filter:aa},{opacity:1,filter:"blur(0px)"}],{duration:ir,delay:or,easing:sa,fill:"backwards"})}function Iu(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 Ou(t,e,n,i,o){let r=(t.ownerDocument.defaultView??window).getComputedStyle(t);e.style.cssText=["position:absolute","left:0",o>0?`width:${o-wu(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:aa}],{duration:nr*i,easing:sa,fill:"forwards"}).finished.then(()=>e.remove(),()=>e.remove())}function Ei(t){let e=t[0]?.text;return e==null||e===""?null:e}function Gt(t,e,n){let i=n.visible,o=Pu(t,n.enabled??!0),r=oe.get(t);if(!i||!o){o||r?.glide?.cancel(),oe.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=Lu(t,e),a=vu(t)?r?.loadingSince??la():null;if(r&&r.height>0&&r.glide&&r.signature===s){r.loadingSince=a;return}let l=ue(t),c=t.getBoundingClientRect(),u=c.height;r?.glide?.cancel();let d=t.getBoundingClientRect(),f=d.height,p=d.width||0,m=null,g=r?l?u:r.height:0,b=r?l?c.width||0:r.width:0;r&&g>0&&(e!==r.key&&r.snapshot&&Au(t,r.snapshot,n.anchorBottom??!1,xu(r.loadingSince),b),m=ca(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:Cu(t)),oe.set(t,{height:f,width:p,key:e,signature:s,snapshot:T,glide:m,loadingSince:a,contentHeight:m?er(t):0})}function ca(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:tr,easing:bu});i&&(t.setAttribute(ti,String(n.width)),n.width>e.width?t.style.setProperty(Vt,`${n.width-Eu(t)}px`):t.style.removeProperty(Vt),Zo.set(t,r));let s=()=>{Zo.get(t)===r&&(Zo.delete(t),t.removeAttribute(ti),t.style.removeProperty(Vt))};return r.finished.then(()=>{s();let a=oe.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 ue(t){let e=oe.get(t)?.glide??null;return e&&(e.playState==="running"||e.pending)?e:null}function Pi(t){if(!ue(t))return null;let e=oe.get(t)?.height??0;return e>0?e:null}function Li(t,e){let n=oe.get(t);n&&n.height>0&&!ue(t)&&e>0&&(n.height=e)}function ua(t,{widthChanged:e}){let n=oe.get(t);if(!n||n.height<=0)return;let i=ue(t);if(!i||!e&&(t.hasAttribute("data-aia-fit")||Math.abs(er(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=ca(t,{height:o.height,width:o.width||0},{height:r.height,width:n.width}),n.contentHeight=n.glide?er(t):0}function Ci(t){oe.get(t)?.glide?.cancel(),oe.delete(t)}var sr="data-aia-hug",at="--aia-panel-fit-width",ar="data-aia-full-width",Mu=36;function lt(t){t.removeAttribute(sr)}function lr(t,e,{eligible:n,loading:i}){let o=t.style.getPropertyValue(at);ku(t,e,n,i),ua(t,{widthChanged:t.style.getPropertyValue(at)!==o})}function ku(t,e,n,i){if(!n){t.style.removeProperty(at),lt(t);return}if(i){t.style.getPropertyValue(at)&&t.setAttribute(sr,"");return}let o=Ru(t,e);if(o==null){t.style.removeProperty(at);return}t.style.setProperty(at,`${o}px`),t.setAttribute(sr,"")}var da=new WeakMap;function Ru(t,e){if(nt())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=da.get(t);if(r?.key===o)return r.width;let s=_u(t,e,n);return da.set(t,{key:o,width:s}),s}function _u(t,e,n){let i=tt(n);if(!i||i.rowWidths.some(a=>a<=0))return null;let o=Math.ceil(Math.max(...i.rowWidths)),r=Math.max(1,Jo(n.style.gridTemplateColumns)),s=ma(n,t,r-1)+r*(o+Mu);return Math.ceil(Math.max(s,Du(e,t)))}function Du(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:ma(n,e,i>0&&o>0?1:0)+i+o}function Jo(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 ma(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 Hu="[data-aia-products], [data-aia-datepicker], [data-aia-date-grid], [data-aia-time-wheel], [data-aia-location], [data-aia-see-all]";function pa(t){let e=!t.hasAttribute("data-aia-has-products")&&!t.hasAttribute(ar)&&B(t,".aia-grid [data-aia-option]")!==null&&B(t,Hu)===null,n=B(t,".aia-grid [data-aia-option][data-aia-loading]")!==null;e||lt(t),lr(t,t,{eligible:e,loading:n})}var fa="data-aia-key";function re(t,e,n){let i=new Map;for(let s of Array.from(t.children)){let a=s.getAttribute(fa);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 c=i.get(l);c||(c=n.create(a,s),c.setAttribute(fa,l)),n.update?.(c,a,s),t.children[s]!==c&&t.insertBefore(c,t.children[s]??null),r.push(c)}for(let[s,a]of i)o.has(s)||a.remove();return r}function ga(t,e){if(!e.interactive)return null;let n=e.options[xe(t)];return n?.is_tappable?n:null}var Nu={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=ga(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")&&ga(t,e)&&e.callbacks.onHighlight(xe(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,xe(t))}};function ba(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=Vu(),t.appendChild(l),z(l);for(let d of l.querySelectorAll(".magicx-aia-datepicker-nav"))d.disabled=!1}$(l,Nu,{options:e,callbacks:s,interactive:a});let c=l.querySelector(".magicx-aia-datepicker-month");c&&(c.textContent=kn(o));let u=l.querySelector(".magicx-aia-datepicker-grid");u&&Fu(u,e,n,i,r)}function Fu(t,e,n,i,o){let r=V(new Date),s=ci({pendingStart:o.rangeStart,highlightedIso:K(e[n]),selected:o.selectedRange,floor:o.floor});re(t,e,{keyOf:(a,l)=>K(a)??`pad-${l}`,create:a=>Wu(a),update:(a,l,c)=>{let u=K(l),d=ui(u,{selectedIso:o.selectedIso,range:s,references:o.references}),f=c===n&&l.is_tappable;a.id=`${i}-option-${c}`,a.dataset.aiaIndex=String(c),a.setAttribute("aria-selected",String(f)),a.classList.toggle("magicx-aia-date-cell--past",di(u,r,o.floor)),a.classList.toggle("magicx-aia-date-cell--highlighted",f),a.classList.toggle("magicx-aia-date-cell--today",u!=null&&u===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 Wu(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=Dn(t);if(n==null)return e.className="magicx-aia-date-cell magicx-aia-date-cell--blank",e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e;e.className="magicx-aia-date-cell magicx-aia-date-cell--day",e.tabIndex=0,e.setAttribute("aria-label",t.text);let i=document.createElement("span");return i.className="magicx-aia-date-cell-number",i.textContent=String(n),e.appendChild(i),e}function Vu(){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(ha("prev","Previous month","\u2039"),n,ha("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of At){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 ha(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 Bu='<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>',ya="data-aia-location-body";function Uu(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=Bu;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 $u(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 Sa(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(ya)!==r){for(let a of Array.from(t.children))a.hasAttribute("data-aia-location-row")||a.remove();let s=$u(r,n);s&&t.appendChild(s),t.setAttribute(ya,r)}re(t,o,{keyOf:(s,a)=>`${a}:${s.id}`,create:s=>Uu(s),update:(s,a,l)=>{let c=l===e.highlighted;s.classList.toggle("magicx-aia-location-row--highlighted",c),s.setAttribute("aria-selected",String(c)),s.setAttribute("data-aia-index",String(l)),s.id=i(l)}})}var de=new WeakMap,Gu=0,Fe=new WeakMap,qu='<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>',We=t=>Ke(t.input)===t.input;function Ta(t,e){let n=Ke(t);if(n instanceof HTMLElement&&n!==e.input&&n!==F(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=Oe(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Ku(t,e,n){if(!(!(n instanceof HTMLElement)||n===e.returnTo||t.contains(n))&&n!==F(t).body&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=Oe(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function zu(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=Ie(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=F(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var Qu={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&ct(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function ct(t,e=!1){let n=Fe.get(t),i=de.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&We(n)&&(n.returning=!0,zu(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function ju(t){let e=Fe.get(t),n=de.get(t);if(!(!e||!n||We(e))){if(Ta(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!We(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function Yu(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++Gu}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=qu;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(),Ta(t,r),de.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>de.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",s=>{Ku(t,r,s.relatedTarget),de.get(t)?.callbacks.onLocationFocusChange(!0)}),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,de.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",s=>{let a=de.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;ct(t,!0),a.callbacks.onLocationCommit();return;case"Escape":s.preventDefault(),s.stopPropagation(),r.declined=!0,ct(t);return;case"Backspace":if(i.value!=="")return;s.preventDefault(),r.declined=!0,ct(t);return}}),Fe.set(t,r),r}function va(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=Fe.get(e);n&&(We(n)&&ct(e),n.declined=!1,n.input.tabIndex=-1)}}function xa(t,e,n,i,o={}){let r=Array.from(t.children).find(l=>l.hasAttribute("data-aia-location"))??null;if(!e){if(r){let l=Fe.get(r);l&&We(l)&&ct(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let s=Fe.get(r)??Yu(r,n);s.input.tabIndex=0,de.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),$(s.results,Qu,de.get(r)),s.input.value!==e.query&&!We(s)&&(s.input.value=e.query);let a=l=>`${r?.id}-row-${l}`;if(Sa(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&&!We(s)){let l=r;queueMicrotask(()=>{l.isConnected&&!Fe.get(l)?.declined&&ju(l)})}}else{let l=s;setTimeout(()=>{if(l.widgetFocused)return;let c=l.returnTo;c&&Ke(c)===c||(l.declined=!1)},0)}}var Xu={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},wa=[125,69];function Ea(t,e){return e?1:t===0?.7:t===1?.4:.2}function Ai(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,Xu,{onSelectPill:i,loading:r}),r&&e.length===0){a.setAttribute("data-aia-pill-list-loading",""),a.innerHTML="";for(let l=0;l<wa.length;l++){let c=wa[l],u=document.createElement("span");u.setAttribute("data-aia-pill-skeleton",""),u.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,u.style.width=`${c}px`,u.style.setProperty("--aia-pill-opacity",String(Ea(l,!1))),a.appendChild(u)}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();re(a,e,{keyOf:l=>`${l.type?.kind??""}|${Ce(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let c=document.createElement("button");if(c.type="button",c.tabIndex=-1,c.setAttribute("data-aia-pill",""),c.setAttribute("contenteditable","false"),Ce(l)){c.setAttribute("data-aia-smart-suggestion",C(l)?"header":"");let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-text",u.textContent=l.text;let d=document.createElement("span");d.className="magicx-aia-smart-suggestion-sparkle",d.innerHTML=gn,c.append(u,d)}else c.textContent=l.text;return c.disabled=!0,c},update:(l,c,u)=>{let d=l,f=s&&u===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(Ea(u,f))),d.dataset.aiaPillIndex=String(u),d.toggleAttribute("data-aia-pill-active",u===n),r?d.setAttribute("data-aia-loading",""):d.removeAttribute("data-aia-loading")}}),z(a);for(let l of a.querySelectorAll("[data-aia-pill]"))l.disabled=r}function cr(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var Pa=32;function ur(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 Ii(t){let e=n=>{let i=ur(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var La=Intl.Segmenter,Ca=La?new La(void 0,{granularity:"grapheme"}):null;function Oi(t){let e=t.trim().normalize("NFC").toUpperCase();if(Ca)for(let n of Ca.segment(e))return n.segment;return Array.from(e)[0]??"?"}var Mi=120,Aa=360;function Ju(t){let e=t.pathname;return t.hostname==="cdn.shopify.com"&&e.startsWith("/s/files/")||e.startsWith("/cdn/shop/")?/\.png$/i.test(e)?{format:"pjpg"}:/\.webp$/i.test(e)?{format:null}:null:null}function dr(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=Ju(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 mr(t,e){let n=dr(t,e);return n===t?[t]:[n,t]}function ki(t,e){if(!(t>0)||!(e>0))return null;let n=t/e,i=o=>Math.round(o*1e3)/1e3;return{x:i(Math.min(n,1)),y:i(Math.min(1/n,1))}}function qt(t){let e=t?.trim();return e?mr(e,360):[]}function Ia(t){return qt(t)[0]}var Ri=new WeakMap,fr=new WeakMap,Ma=new WeakMap;function ka(t,e,n,i,o,r="row",s="image",a=k(),l,c=!0,u=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",""),Ii(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){re(p,e,{keyOf:m=>id(m,!!l),create:m=>od(m,i,o,s,a,l),update:(m,g,b)=>{Ri.set(m,g),Zu(m,c?g.vendor:void 0),ed(m,g.price,g.compareAtPrice),m.id=`${n}-product-${b}`,m.dataset.aiaIndex=String(b),Ma.get(m)?.(s),st(m,"data-aia-product-state",g.id===u);let T=m.querySelector(".magicx-aia-product-badge");T&&T.textContent!==a.soldOut&&(T.textContent=a.soldOut);let y=m.querySelector(".magicx-aia-product-cart");y&&y.setAttribute("aria-label",Ra(g,a))}}),z(p);for(let m of p.querySelectorAll("[data-aia-product]")){let g=fr.get(m);g&&(fr.delete(m),g())}}}function gr(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)He(i)||(i.tabIndex=e?0:-1)}function Zu(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 Oa(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 Ra(t,e){return`${e.addToCart}: ${t.title}`}var pr="http://www.w3.org/2000/svg";function td(){let t=document.createElementNS(pr,"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(pr,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(pr,"circle");i.setAttribute("class","magicx-aia-product-cart-glyph"),i.setAttribute("cx",n),i.setAttribute("cy","20"),i.setAttribute("r","1.3"),t.appendChild(i)}return t}function nd(t,e,n,i,o){let r=document.createElement("span");r.className="magicx-aia-product-cart",r.setAttribute("data-aia-product-cart",""),r.setAttribute("role","button"),r.setAttribute("aria-label",Ra(e,o)),r.tabIndex=0,r.appendChild(td());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(Ri.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 id(t,e){return[e?"cart":"",t.id,t.title,t.url,t.imageUrl,t.vendor,t.available===!1?"sold-out":""].map(n=>n??"").join("\0")}function od(t,e,n,i,o,r){let 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=qt(t.imageUrl),c=l[0],u=!!c,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=Oi(t.title))};if(Ma.set(s,g=>{g!==i&&(i=g,u||d())}),c){let g=document.createElement("img"),b=0;g.onload=()=>{a.setAttribute("data-aia-image-loaded",""),Oa(s,ki(g.naturalWidth,g.naturalHeight))},g.onerror=()=>{let T=l[++b];if(T){g.src=T;return}u=!1,Oa(s,null),d()},g.className="magicx-aia-product-image",g.src=c,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?nd(s,t,r,n,o):null;return m&&(s.setAttribute("data-aia-product-has-cart",""),s.appendChild(m.el)),fr.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(Ri.get(s)??t))})}),s.addEventListener("keydown",g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),e(Ri.get(s)??t))}),s.addEventListener("focus",()=>n(!0)),s.addEventListener("blur",g=>{g.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),s}var _a=10,Da=44;function _i(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 me="data-aia-fit",Kt="--aia-dropdown-fit-height",Ha=8,rd=160;function Di({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,s=null,a=null,l=null,c=!1,u=()=>{t.removeAttribute(me),t.style.removeProperty(Kt)},d=()=>{if(ue(t)){c=!0;return}c=!1,Li(t,t.getBoundingClientRect().height)},f=y=>`${r}|${(y??t).scrollHeight}|${t.offsetWidth}`,p=y=>a?.key===f(y)?a.height:null,m=y=>{let P=f(y);if(a?.key===P)return a.height;let x=y?.scrollTop??0;t.removeAttribute(me);let h=t.offsetHeight;return t.setAttribute(me,""),y&&x&&(y.scrollTop=x),a={key:P,height:h},h},g=()=>{if(i)return;if(!e()){o=!1;return}let y=ue(t),P=y?Pi(t):null;y&&l!==y&&(l=y,y.finished.then(b,b)),!y&&c&&d(),o||(o=!0,u());let x=t.hasAttribute(me),h=B(t,".aia-grid")?.getAttribute("data-aia-group")??null,v=h!==r;r=h;let E=ad(t,n);if(E===null)return;let S=sd(t);if(x){let I=y?p(S):m(S);if(I!==null&&I<=E){u(),d();return}}else if((P??t.offsetHeight)<=E)return;let L=`${Math.max(rd,Math.floor(E))}px`,O=t.style.getPropertyValue(Kt)!==L;O&&t.style.setProperty(Kt,L),x?v&&S&&(S.scrollTop=0):t.setAttribute(me,""),(O||!x)&&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 sd(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function ad(t,e){if(!e)return null;let n=e.visualViewport,i=n?n.offsetTop:0,o=n?n.height:e.innerHeight;if(!o)return null;let r=t.offsetParent,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-Ha:i+o-a-Ha}var Hi=.5;function ld(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-Hi||e.height>i+Hi?s=Math.floor(e.top-t.coverTop):r>o+i+Hi&&(s=Math.ceil(r-t.coverTop-i)),Math.min(n,Math.max(0,s))}var Na=new WeakMap;function Fa(t){let e=Na.get(t);if(e)return e;let n={shown:-1,byPointer:-1,held:!1,x:null,y:null,cancel:null};Na.set(t,n);let i=o=>Wa(n,o);for(let o of["mouseover","mouseout","mousemove"])t.addEventListener(o,i,{capture:!0,passive:!0});return n}function Wa(t,e){e.screenX===t.x&&e.screenY===t.y||(t.held=!1,t.x=e.screenX,t.y=e.screenY)}function zt(t,e,n){if(!t)return!0;let i=Fa(t);return Wa(i,n),i.held?!1:(i.byPointer=e,!0)}function cd(t){if(t.scrollHeight-t.clientHeight>1)return t;let e=t.closest(".aia-stack");return e?.parentElement?.hasAttribute(me)&&e.scrollHeight-e.clientHeight>1?e:null}function ud(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 Ni(t,e){let n=Fa(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=cd(t),s=r?ud(r,o):null;if(!r||!s)return;let a=ld(s.box,s.row);Math.abs(a-r.scrollTop)<Hi||(n.held=!0,n.cancel=xi(r,a-r.scrollTop,r.ownerDocument.defaultView,()=>{n.cancel=null}))}var Va="http://www.w3.org/2000/svg",dd=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function md(t,e){let n=t.toLowerCase();return n.startsWith("on")||n.includes("href")||n==="style"||n==="xml:base"||n==="id"||n==="name"||/^\s*javascript:/i.test(e)||/url\s*\(\s*['"]?\s*[^#'"\s)]/i.test(e)}var pd=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],fd=/^[a-zA-Z0-9#.,%\s()-]+$/;function gd(t){let e=[];for(let n of pd){let i=t.getAttribute(n);i===null||!fd.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function Ba(t){for(let e of Array.from(t.attributes))md(e.name,e.value)&&t.removeAttribute(e.name);gd(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!dd.has(n.localName)||n.namespaceURI!==Va?n.remove():Ba(n)}else e.remove()}function se(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!==Va||e.getElementsByTagName("parsererror").length>0?null:(Ba(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function Qt(t){return t.text}function we(t){return ut(t)[0]??null}function ut(t){let e=hd(t);return e?mr(e,120):[]}function hd(t){if(!t)return null;let e=t.trim();if(e==="")return null;let n;try{n=new URL(e,typeof document>"u"?void 0:document.baseURI)}catch{return null}return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}function dt(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var hr={one:"item",other:"items"};function Ua(t,e=hr){let n=dt(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function br(t){return we(t.image_url)!==null}var Fi=new Map;function bd(t){let e=t.icon_svg;if(!e)return!1;let n=Fi.get(e);return n===void 0&&(n=se(e)!==null,Fi.size>=256&&Fi.clear(),Fi.set(e,n)),n}function Wi(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&br(i)||e&&bd(i))}var $a=new WeakMap;function yd(t,e,n){let i=e.length,o=nt(),r=$a.get(t),s=n&&r&&ni(r.options,e)?r.plan:null,a=!s&&!n&&Zn(i,o)?tt(t):null,l=s??ei(i,o,a?.rowWidths??null,a?.gridWidth??null);return n||$a.set(t,{options:e,plan:l}),t.style.gridTemplateColumns=l.template,t.style.setProperty("--aia-grid-max-height",l.maxHeight),t.querySelectorAll("[data-aia-option]").forEach((c,u)=>{c.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(u))}),l.cols}function Ga(t,e){if(e.loading||!e.interactive)return null;let n=e.options[xe(t)];return n?.is_tappable?n:null}var Sd={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=Ga(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!_i(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(!Ga(t,e))return;let i=xe(t);zt(t.closest(".aia-grid"),i,n)&&e.onHighlight(i)},onLeave:(t,e,n)=>{zt(t.closest(".aia-grid"),-1,n)&&e.onHighlight(-1,xe(t))}};function qa(t,e,n,i,o,r,s,a="",l="below",c=!0,u=!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,Sd,{options:e,onSelect:i,onHighlight:o,loading:s,interactive:f});let g=m.dataset.aiaGroup!==a;m.dataset.aiaGroup=a;let b=Wi(e,c,u);Td(m,e,n,r,s,{showIcons:c&&b,showImages:u&&b,showCounts:d,picked:p});let T=yd(m,e,s);vd(m,e.length,T,s,l),g&&(m.scrollTop=0),Ni(m,s?-1:n)}function Td(t,e,n,i,o,r){let s=o?"1":"0",a=t.dataset.aiaGroup??"",{showIcons:l,showImages:c,showCounts:u}=r,d=l?m=>m.icon??m.icon_svg??"":()=>"",f=c?m=>`${we(m.image_url)??""}${(m.imageCollage??[]).join("")}`:()=>"",p=u?m=>dt(m.item_count)??"":()=>"";re(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=xd(m,o,r);return o||(b.dataset.aiaEntering=""),b},update:(m,g,b)=>{if(yr.get(m)!==(g.matchedText??"")){let P=m.querySelector(".magicx-aia-option-text");P&&Ka(P,g),yr.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 y=m.querySelector(".magicx-aia-checkbox");r.picked&&g.is_tappable?(y||(y=document.createElement("span"),y.className="magicx-aia-checkbox",y.setAttribute("aria-hidden","true"),m.querySelector(".magicx-aia-option-content")?.prepend(y)),y.dataset.checked=String(r.picked.includes(g.text)),y.textContent=r.picked.includes(g.text)?"\u2713":""):y?.remove(),m.classList.toggle("magicx-aia-option--highlighted",T),m.classList.toggle("magicx-aia-option--live-match",!!g.liveMatch&&!o)}})}function vd(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(yi,`${Si(s,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var yr=new WeakMap;function Ka(t,e){if(t.replaceChildren(),e.matchedText)for(let n of ri(Qt(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(Qt(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 xd(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?ut(t.image_url):[],c=l[0];if(c){let p=document.createElement("span");p.className="magicx-aia-option-image",p.setAttribute("aria-hidden","true");let m=(t.imageCollage??[]).map(g=>ut(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 y=g[++T];y?b.src=y:b.hidden=!0},b.src=g[0],p.appendChild(b)}a.appendChild(p),r.dataset.aiaImage=""}let u=!c&&n&&t.icon_svg?se(t.icon_svg):null;if(u){let p=document.createElement("span");p.className="magicx-aia-option-icon",p.setAttribute("aria-hidden","true"),p.innerHTML=u,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),yr.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?dt(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 wd=120,Ed={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(_t(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},Qa=new WeakMap,za=new WeakMap;function ja(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=Cd(),t.appendChild(r),z(r);let c=r.querySelector("[data-aia-time-done]");c&&(c.disabled=!1)}let s={view:e,callbacks:i,interactive:o};Qa.set(r,s),$(r,Ed,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=Ot(e.minutes));for(let c of kt){let u=r.querySelector(`[data-aia-time-column="${c}"]`);u&&Pd(u,c,e.minutes)}}function Pd(t,e,n){let i=Rt(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=Vi(t);if(o.settle)return;let r=i*Mt;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function Vi(t){let e=za.get(t);return e||(e={syncedTop:null,settle:null},za.set(t,e)),e}function Ld(t,e,n){let i=Vi(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(()=>Ya(t,e,n),wd)}function Ya(t,e,n){let i=Vi(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=Qa.get(t);if(!o||!o.interactive)return;let r=Bn(n,e.scrollTop);r!==Rt(n,o.view.minutes)&&o.callbacks.onTimeChange(_t(n,o.view.minutes,r))}function Cd(){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 kt){if(r==="minute"){let s=document.createElement("span");s.className="magicx-aia-time-wheel-separator",s.textContent=":",n.appendChild(s)}n.appendChild(Ad(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 Ad(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),Vn(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",()=>Ld(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{Vi(n).settle&&Ya(t,n,e)}),n}var Id=[159,119,164];function $i(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()),gi(e),e}var Bi=new WeakMap;function Od(t,e,n){let i=Bi.get(t);if(i||(i={button:ra(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),Bi.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=wi({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var Ui=new WeakMap;function Xa(t){let e=Ui.get(t);if(e){e.update();return}Ui.set(t,Di({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function Sr(t){Ui.get(t)?.destroy(),Ui.delete(t),Ci(t);let e=Bi.get(t);e&&(e.controller?.destroy(),Bi.delete(t))}function Gi(t,e){let n=e.strings??k(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:s,showPills:a,isActivePillSelected:l,onSelect:c,onHighlight:u,onPillClick:d,onSkip:f}=e,p=fn(e.pills,n.keepTyping),m=hn(p),g=a&&p.length>0,b=i.length>0,T=e.products.length>0,y=e.formatType==="time"&&e.timeView!=null,P=e.formatType==="location"&&e.locationView!=null,x=r&&(b||g||s||T||y||P);if(x?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"),!x){gr(t,!1),va(t),Xa(t),Gt(t,null,{visible:!1});return}T?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute(ar,e.fullWidth===!0),lt(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 v=e.showSkipButton&&m&&!e.isInputEmpty,E=g||s&&a||v,S=h.querySelector(".magicx-aia-pill-bar");if(E){S||(S=document.createElement("div"),S.className="magicx-aia-pill-bar aia-cluster",S.setAttribute("data-nowrap",""),S.setAttribute("data-aia-pillbar",""),h.insertBefore(S,h.firstChild));let pe=g||s&&a,A=S.querySelector(".magicx-aia-pill-scroll");pe?(A||(A=document.createElement("span"),A.className="magicx-aia-pill-scroll",A.setAttribute("data-aia-pill-scroll",""),S.insertBefore(A,S.firstChild)),Ai(A,p,0,d,!0,s,l)):A&&A.remove(),Rd(S,v,s||e.skipDisabled,p[0],f,n)}else S&&S.remove();let L=e.suggestions[0],O=L?`${L.parameter} ${L.text}`:"",I=_(e.formatType),Q=I&&!s;qa(h,I?[]:i,o,c,u,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)),Wd(h,!!e.multiSelectView,e.skipDisabled||s,e.onMultiSelectCommit,n.done),Od(t,h.querySelector(".aia-grid"),n),ba(h,Q?i:[],o,e.listboxId,Q?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart,floor:mi(e.formatType,e.dateRangeStart),references:e.dateReferences??[]},{onSelect:c,onHighlight:u,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),ja(h,e.formatType==="time"&&!s?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),xa(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 R=h.querySelector(".magicx-aia-skeleton-bars");if(s&&(!b||N(e.formatType))){if(!R){R=document.createElement("div"),R.className="magicx-aia-skeleton-bars",R.setAttribute("data-aia-skeleton-bars","");for(let pe of Id){let A=document.createElement("span");A.className="magicx-aia-skeleton-bar",A.style.width=`${pe}px`,R.appendChild(A)}h.appendChild(R)}}else R&&R.remove();ka(h,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart,e.showProductVendor??!0,e.busyProductId??null),gr(t,!s),Nd(h,e.onSeeAllResults,n.seeAllResults,e.seeAllBusy===!0);let j=h.querySelector(".magicx-aia-footer")??Dd(n),J=o>=0&&!!i[o]?.is_tappable;_d(j,fi(J,e.isInputEmpty,n)),j.isConnected||h.appendChild(j),Md(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"]),bi(h,h.querySelector(".magicx-aia-multi-done")),lr(t,h,{eligible:b&&!T&&!I&&!y&&!P&&!e.onSeeAllResults&&!e.fullWidth,loading:s}),Xa(t),Gt(t,Ei(a?p:[]),{visible:!0,anchorBottom:e.optionsPosition==="above"})}function Md(t,e){let n=e.map(i=>t.querySelector(`:scope > ${i}`)).filter(i=>i!==null);for(let i=0;i<n.length;i++)t.children[i]!==n[i]&&t.insertBefore(n[i],t.children[i]??null)}var kd={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function Rd(t,e,n,i,o,r){$(t,kd,{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),z(s)),s.textContent!==r.skip&&(s.textContent=r.skip),s.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),s.disabled=n}function _d(t,{key:e,hint:n}){let i=t.querySelector(".magicx-aia-footer-key"),o=t.querySelector(".magicx-aia-footer-hint");!i||!o||(i.textContent!==e&&(i.textContent=e),o.textContent!==n&&(o.textContent=n))}function Dd(t){let e=document.createElement("footer");e.className="magicx-aia-footer",e.setAttribute("data-aia-footer","");let n=document.createElement("div");n.className="aia-cluster magicx-aia-footer-row",n.setAttribute("data-align","center"),n.setAttribute("data-justify","between"),n.setAttribute("data-nowrap","");let i=document.createElement("div");i.className="aia-cluster magicx-aia-footer-hint-group",i.setAttribute("data-align","center"),i.style.setProperty("--aia-cluster-gap","5px");let o=document.createElement("kbd");o.className="magicx-aia-footer-key",o.textContent="tab";let r=document.createElement("span");r.className="magicx-aia-footer-hint",r.textContent=t.select,i.append(o,r);let s=document.createElement("a");s.className="aia-cluster magicx-aia-footer-brand-link",s.setAttribute("data-align","center"),s.href=pi(),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="Powered by Intent-1";let l=document.createElement("span");return l.className="magicx-aia-footer-badge",l.append(a),s.append(l),n.append(i,s),e.append(n),e}var Hd={itemSelector:".magicx-aia-see-all",onClick:(t,e,n)=>{e.submit&&(n.stopPropagation(),e.submit())}};function Nd(t,e,n,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),z(s)}$(o,Hd,{submit:e});let r=o.querySelector("button");r&&(r.textContent!==n&&(r.textContent=n),r.disabled=!1,st(r,"data-aia-see-all-state",i))}var Fd={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function Wd(t,e,n,i,o){let r=t.querySelector("[data-aia-multi-actions]");if(!e){r?.remove();return}if(!r){r=document.createElement("div"),r.dataset.aiaMultiActions="";let 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),z(a)}$(r,Fd,{commit:i,disabled:n});let s=r.querySelector("button");s&&(s.textContent=o,s.disabled=n)}function mt(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 Ja(t,e){let n=$i(e.listboxId);return t.appendChild(n),{dropdown:n}}function Tr(t,e,n){let i=rt(e);Gi(t.dropdown,{strings:n.strings,suggestions:e.editingIdentified?[{parameter:e.editingIdentified.parameter,text:te(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:mt(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 Vd="[data-aia-chip-remove]";function vr(t,e){let n=e;if(!n||n.nodeType===void 0)return null;let o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(Vd)??null;return o&&t.contains(o)?o:null}function qi(t,e){let n=null,i=c=>{n=null;let u=c;if(u.button)return;let d=vr(t,c.target);if(!d)return;c.preventDefault(),c.stopPropagation();let f=d.dataset.aiaChipRemove,p=u.pointerType==="touch"||u.pointerType==="pen";n={id:f,x:u.clientX,y:u.clientY,pending:p},!p&&f&&e(f)},o=c=>{if(!n?.pending)return;n.pending=!1;let u=c;if(Math.hypot(u.clientX-n.x,u.clientY-n.y)>10)return;let f=t.getRootNode().elementFromPoint?.(u.clientX,u.clientY)??c.target,p=vr(t,f)?.dataset.aiaChipRemove;p&&p===n.id&&e(p)},r=()=>{n&&(n.pending=!1)},s=c=>{!n&&!vr(t,c.target)||(c.cancelable&&c.preventDefault(),c.type==="click"&&(c.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 Za=340;function Ki(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let u=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let d=t.getBoundingClientRect().height;if(d!==0){if(u===0||Math.abs(d-u)<.5){t.style.height=`${d}px`;return}t.style.height=`${u}px`,t.getBoundingClientRect(),t.style.height=`${d}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(u=>{for(let f of u)if(f.target!==t){n();return}let d=t.getBoundingClientRect().width;Math.abs(d-i)<.5||(i=d,n())}):null,r=()=>{for(let u of Array.from(t.children))o?.observe(u)},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 c=!1;return t.ownerDocument.fonts?.ready.then(()=>{c||n()}),n(),()=>{c=!0,t.removeEventListener("load",a,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(s),t.style.height=""}}var Pr=2600,Bd=3,Yi="data-aia-hint",Er="magicx-aia-hint",Lr="data-aia-hint-el",Ud={position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--aia-hint-color, #999)",userSelect:"none"},$d=280,Gd=320,qd=380,xr="cubic-bezier(0.25, 0.1, 0.25, 1)",el=new Set(["a","an","the","some","my"]),ji=new WeakMap;function Kd(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function tl(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&&el.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,[c,...u]=n.split(/\s+/);u.length&&c&&el.has(c.toLowerCase())&&(l=c,n=u.join(" "));let d=l??s;d&&o.push({key:`w:${d.toLowerCase()}`,text:d,icon:null});let f=t.icon_svg?se(t.icon_svg):null;return o.push({key:`c:${f??""}:${n}`,text:n,icon:f}),o}function zd(t,e){let n=t.createElement("span");if(n.className=`${Er}__word`,n.dataset.key=e.key,n.style.display="inline-block",e.icon){let i=t.createElement("span");i.className=`${Er}__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 wr(t,e,n){return typeof t.animate=="function"?t.animate(e,n):null}function zi(t,e){let n=t.ownerDocument?.defaultView;if(!n)return;let i=n.getComputedStyle(t),o=u=>Number.parseFloat(u)||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,c=Math.max(a,l);e.style.left=`${r}px`,e.style.top=`${s}px`,c>0&&(e.style.maxWidth=`${c}px`),e.style.font=i.font,e.style.lineHeight=i.lineHeight,e.style.letterSpacing=i.letterSpacing,e.style.fontWeight="var(--aia-hint-font-weight, 300)"}function nl(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=wr(m,[{opacity:1,filter:"blur(0)"},{opacity:0,filter:"blur(2px)"}],{duration:$d,easing:xr,fill:"forwards"});g?g.onfinish=()=>m.remove():m.remove()}let c=Array.from(o.children).filter(p=>p.dataset.leaving!==void 0),u=[];if(e.forEach((p,m)=>{m>0&&u.push(r.createTextNode(" ")),u.push(s.get(p.key)??zd(r,p))}),o.replaceChildren(...u,...c),!n)return;let d=new Map;for(let p of u)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))wr(m,[{opacity:0,filter:"blur(2px)"},{opacity:1,filter:"blur(0)"}],{duration:Gd,delay:i?80*f++:180+60*f++,easing:xr,fill:"backwards"});else{let b=(a.get(p.key)??m.offsetLeft)-m.offsetLeft;Math.abs(b)>.5&&wr(m,[{transform:`translateX(${b}px)`},{transform:"none"}],{duration:qd,easing:xr})}}}function Qi(t){let e=ji.get(t);e&&(e.timer!==null&&clearInterval(e.timer),e.resize?.disconnect(),e.el.remove(),ji.delete(t),t.removeAttribute(Yi),t.removeAttribute("aria-placeholder"))}function il(t,e,n,i){let o=i.filter(m=>m.text.trim()!=="").slice(0,Bd),r=t.parentElement;if(!e||o.length<2||!r){Qi(t);return}let s=`${n}\0${o.map(m=>`${m.text}${m.icon_svg??""}`).join("\0")}`,a=ji.get(t);if(a&&a.key===s&&a.el.isConnected){zi(t,a.el);return}Qi(t);let l=t.ownerDocument,c=l.createElement("span");c.className=Er,c.setAttribute(Lr,""),c.setAttribute("aria-hidden","true"),Object.assign(c.style,Ud),r.insertBefore(c,t),t.setAttribute(Yi,""),n.trim()&&t.setAttribute("aria-placeholder",n.trim()),zi(t,c);let u=l.defaultView,d=u?.ResizeObserver?new u.ResizeObserver(()=>{c.isConnected&&zi(t,c)}):null;d?.observe(r);let f=Kd(t),p={key:s,lead:n,options:o,index:0,el:c,timer:null,resize:d};ji.set(t,p),nl(p,tl(o[0],n),!f,!0),!f&&(p.timer=setInterval(()=>{if(!t.isConnected||!c.isConnected){Qi(t);return}t.ownerDocument?.hidden||(p.index=(p.index+1)%p.options.length,zi(t,c),nl(p,tl(p.options[p.index],p.lead),!0,!1))},Pr))}function Xi(t){Qi(t)}function Ji(t){return(t.find(n=>n.type?.kind!=="traditional_autocomplete")?.options??[]).filter(n=>n.is_tappable!==!1).map(n=>({text:n.text,icon_svg:n.icon_svg}))}var Qd=6,jd=.3;function ol(t){return t<=0?"0px":`${(-Math.min(jd,2*Qd/t)).toFixed(3)}px`}var rl=new Map;function Yd(t,e,n){let i=rl.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`;rl.set(e,a),t.style.setProperty("--aia-chip-image-fit",a)},o.src=e}function Zi(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,c=n.length===0;e.dataset.aiaEmpty=c?"true":"false",Ks(e,c?r:""),il(e,c,r,t.hintOptions??[]);let u=n.map(x=>x.type==="completed"?`${x.type}:${x.value}${s?x.param.icon??x.param.icon_svg??"":""}${a?we(x.param.image_url)??"":""}${l?"x":""}`:x.type==="identified"?`${x.type}:${x.value}${x.param.id}${l?"x":""}`:`${x.type}:${x.value}`).join("\0"),d=e.dataset.segKey??"",f=e.dataset.newParamId??"",p=e.dataset.editingParamId??"";if(u===d&&(i??"")===f&&(o??"")===p)return;if(u===d){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let x of e.querySelectorAll("strong[data-param-id]")){let h=x.dataset.paramId,v=x.dataset.seg==="completed"&&h===i;x.classList.toggle("magicx-aia-shimmer-revealed",v),x.classList.toggle("magicx-aia-shimmer-sweep",v),x.classList.toggle("magicx-aia-segment--editing",h===o)}return}let m=e.getAttribute("data-aia-composing")==="true"?Xd(e,n):null;if(m==="unsafe")return;let g=gs(e),b=g&&!m?q(e):null;e.dataset.segKey=u,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let T=F(e),y=T.createDocumentFragment(),P=0;for(let x of n)if(P+=x.value.length,x.type==="completed"){let h=T.createElement("strong");h.dataset.seg="completed",h.dataset.paramId=x.param.id;let v=x.param.id===i,E=x.param.id===o,S=["magicx-aia-segment","magicx-aia-segment--completed"];v&&S.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),E&&S.push("magicx-aia-segment--editing"),h.className=S.join(" "),h.style.letterSpacing=ol(x.value.length);let L=a?we(x.param.image_url):null;if(L){let I=T.createElement("span");I.className="magicx-aia-segment-image",I.setAttribute("contenteditable","false"),I.setAttribute("aria-hidden","true"),I.style.setProperty("--aia-chip-image",`url("${L}")`),Yd(I,L,T),h.appendChild(I),h.dataset.aiaImage=""}let O=!L&&s&&x.param.icon_svg?se(x.param.icon_svg):null;if(O){let I=T.createElement("span");I.className="magicx-aia-segment-icon",I.setAttribute("contenteditable","false"),I.setAttribute("aria-hidden","true"),I.innerHTML=O,h.appendChild(I),x.param.icon&&(h.dataset.aiaIcon=x.param.icon)}h.appendChild(T.createTextNode(x.value)),l&&h.appendChild(sl(T,x.param.id)),y.appendChild(h)}else if(x.type==="identified"){let h=T.createElement("strong");h.dataset.seg="identified",h.dataset.paramId=x.param.id;let v=["magicx-aia-segment","magicx-aia-segment--completed"];x.param.id===o&&v.push("magicx-aia-segment--editing"),h.className=v.join(" "),h.style.letterSpacing=ol(x.value.length),h.textContent=x.value,l&&h.appendChild(sl(T,x.param.id)),y.appendChild(h)}else y.appendChild(T.createTextNode(x.value));if(m){m.node.deleteData(0,m.node.data.length-m.syllable.length);for(let x of Array.from(e.childNodes))x!==m.node&&x.remove();e.insertBefore(y,m.node),e.dataset.aiaTextLength=String(P+m.syllable.length);return}e.replaceChildren(y),e.dataset.aiaTextLength=String(P),b!=null?W(e,Math.max(0,Math.min(b,P))):g&&W(e,P)}function Xd(t,e){let n=e.map(s=>s.value).join(""),i=Me(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 sl(t,e){let n=t.createElement("span");return n.className="magicx-aia-segment-remove",n.setAttribute("contenteditable","false"),n.setAttribute("aria-hidden","true"),n.dataset.aiaChipRemove=e,n.innerHTML='<svg viewBox="0 0 10 10" aria-hidden="true"><path d="M2.5 2.5l5 5M7.5 2.5l-5 5"/></svg>',n}var Jd='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" role="img" aria-label="Submit"><path d="M9 14V4M9 4L4 9M9 4L14 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function al(t=k()){let e=document.createElement("button");return e.type="button",e.className="magicx-aia-submit",e.setAttribute("aria-label",t.submit),e.setAttribute("data-aia-submit",""),e.innerHTML=Jd.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function ll(t){let e=t.store.get();return(!!e.text||e.completedParams.length>0)&&!!t.onSubmit}function Zd(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function cl(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 ul(t,e){let{listboxId:n}=e,i=$i(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",Zd()?"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,c=null;e.submitButton===void 0?(l=al(e.strings),o.appendChild(l),c=l):e.submitButton!==null&&(c=e.submitButton,c.hasAttribute("data-aia-submit")||c.setAttribute("data-aia-submit",""),c.setAttribute("data-aia-submit-slot",""),o.appendChild(c));let u=new AbortController,{signal:d}=u,f=!1,p=0,m=()=>{let h=Me(s);return h.length>0&&h[0]!==h[0].toUpperCase()?h[0].toUpperCase()+h.slice(1):h},g=()=>e.handleChange(m()),b=()=>{let h=X(s)?.node??null;if(!h||!s.contains(h))return null;let S=(h.nodeType===Node.ELEMENT_NODE?h:h.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return S&&fs(s,S)?null:S};o.addEventListener("click",h=>{h.target?.closest("[data-aia-pill]")||s.getRootNode().activeElement?.closest("[data-aia-location]")||In(s)},{signal:d});let T=null,y=()=>{let h=e.showChipRemove??!1;h!==(T!==null)&&(T?.(),T=h?qi(s,v=>e.removeParam(v)):null)};if(y(),d.addEventListener("abort",()=>{T?.(),T=null}),s.addEventListener("input",()=>{if(f){e.handleCompositionText(m());return}p=performance.now(),g(),e.handleCaretAfterInput(q(s))},{signal:d}),F(s).addEventListener("selectionchange",()=>{let h=X(s);if(!h||!s.contains(h.node))return;let v=h.collapsed?b():null,E=e.store.get(),S=E.editingParam?.id??E.editingIdentified?.id??null;if(v&&v!==S){e.startEditingParam(v);return}performance.now()-p<50||e.handleCaretMove(q(s))},{signal:d}),s.addEventListener("click",h=>{let v=Pn(s,h.target);v&&(e.startEditingParam(v),Ln(s,v))},{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 v=h,E=v.inputType;if(E==="insertParagraph"||E==="insertLineBreak"||E==="insertFromDrop"){h.preventDefault();return}if(E.startsWith("insert")||E.startsWith("delete")){let S=E.startsWith("delete")?"":v.data??"";e.replaceEditingRange(S)&&h.preventDefault()}},{signal:d}),s.addEventListener("paste",h=>{h.preventDefault();let v=(h.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!v)return;let E=F(s),S=Oe(s);if(!S||!s.contains(S.startContainer))return;S.deleteContents();let L=E.createTextNode(v);S.insertNode(L),S.setStartAfter(L),Ct(s,S.startContainer,S.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}),c&&c.addEventListener("click",h=>{ll(e)&&(h.stopPropagation(),e.submit?.())},{signal:d}),e.autoFocus!==!1){s.focus();let h=X(s);(!h||!s.contains(h.node))&&Ct(s,s,0)}if(typeof ResizeObserver<"u"){let h=new ResizeObserver(()=>cl(s,a));h.observe(s),u.signal.addEventListener("abort",()=>h.disconnect(),{once:!0})}let x=Ki(r);return u.signal.addEventListener("abort",x,{once:!0}),{input:s,inlinePillContainer:a,dropdown:i,submitButton:l,submitTarget:c,abort:u,syncChipRemove:y}}function Cr(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:s}=t,{pillPlacement:a,setActivePill:l,selectOption:c,store:u}=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??k();s.getAttribute("aria-label")!==T.submit&&s.setAttribute("aria-label",T.submit);let y=s.querySelector("svg");y&&y.getAttribute("aria-label")!==T.submit&&y.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&&st(t.submitTarget,"data-aia-submit-state",e.isSubmitting);let f=i.dataset.newParamId??"",p=e.newParamId!==null&&e.newParamId!==f;if(Zi({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"?[]:Ji(e.actionableSuggestions),showChipRemove:n.showChipRemove??!1}),a==="inline"){let T=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,y=pn(e.actionableSuggestions);T||y.length>0?Ai(o,y,0,l,!1,T,e.isActivePillSelected):cr(o)}else cr(o);cl(i,o),p?Ye(i,e.caretOffset??e.text.length,je(n.focusInputOnSelect)):e.isFocused&&Me(i)!==e.text&&!i.hasAttribute("data-aia-composing")&&W(i,e.text.length);let m=e.editingParam?qe(e.editingParam):e.editingIdentified?{parameter:e.editingIdentified.parameter,text:te(e.editingIdentified.parameter),required:!0,options:[]}:null,g=e.dropdownSuggestion??m??e.actionableSuggestions[0],b=rt(e);Gi(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:mt(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:c,onHighlight:(T,y)=>{y!==void 0&&u.get().activeDropdownIndex!==y||u.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=>u.set({isFocused:T}),seeAllBusy:e.isSubmitting,busyProductId:e.selectingProductId,onSeeAllResults:n.seeAllResults&&e.text.trim().length>0&&ll(n)?()=>n.submit?.():void 0,fullWidth:n.seeAllResults===!0})}function eo(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 c=i.shift();c;c=i.shift()){if(++l>1e4)throw i.length=0,new Error("createStore: notifications did not settle after 10000 deliveries \u2014 a listener is likely calling set() on every notification");let[u,d]=c;for(let f of n)f(u,d)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function dl(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)},c={...s,...o(s)};r(c,l)})}}var Ar=new WeakSet,ml=new WeakMap;function fl(t){return t.nodeType===Node.DOCUMENT_NODE}function em(t){return fl(t)?t:t.ownerDocument}function tm(t){let e=ml.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(hl),ml.set(t,i),i)}catch{return null}}function pl(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=hl,e.appendChild(n)}function gl(t){if(typeof document>"u")return;let e=t??document;if(Ar.has(e))return;let n=em(e);if(fl(e)){let r=e.head??e.documentElement;if(!r)return;pl(n,r),Ar.add(e);return}let i=tm(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):pl(n,e),Ar.add(e)}var hl=`.aia-stack {
1
+ "use strict";var lo=Object.defineProperty;var Wl=Object.getOwnPropertyDescriptor;var Vl=Object.getOwnPropertyNames;var Bl=Object.prototype.hasOwnProperty;var Ul=(t,e)=>{for(var n in e)lo(t,n,{get:e[n],enumerable:!0})},$l=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vl(e))!Bl.call(t,o)&&o!==n&&lo(t,o,{get:()=>e[o],enumerable:!(i=Wl(e,o))||i.enumerable});return t};var ql=t=>$l(lo({},"__esModule",{value:!0}),t);var xm={};Ul(xm,{AIAutocomplete:()=>ao,ATTRIBUTION_URL:()=>jo,DATE_RANGE_META_END:()=>Xn,DATE_RANGE_META_START:()=>Yn,DEFAULT_OPTION_COUNT_UNIT:()=>Tr,EDITOR_GROW_MS:()=>al,HANDOFF_NOT_HANDLED:()=>oo,HINT_ATTR:()=>Xi,HINT_EL_ATTR:()=>Or,HINT_HOLD_MS:()=>Ir,LAST_SEARCH_KEY:()=>Nr,LOCATION_META_KEY:()=>ln,LOCATION_MIN_QUERY:()=>Tt,MULTI_DONE_FIT_VAR:()=>gi,MULTI_SELECT_TOGGLE_MIN_PX:()=>Ua,MULTI_SELECT_TOGGLE_SLOP_PX:()=>Ba,ModeController:()=>gt,OPTIONS_GRID_MOBILE_QUERY:()=>Wt,OPTION_ENTER_DELAY_VAR:()=>bi,OPTION_ENTER_FADE_MS:()=>oa,OPTION_ENTER_RISE_MS:()=>ra,OPTION_ENTER_RISE_PX:()=>sa,OPTION_ENTER_STAGGER_MS:()=>ia,OPTION_IMAGE_WIDTH:()=>ki,PANEL_ENTER_DELAY_MS:()=>lr,PANEL_ENTER_MS:()=>ar,PANEL_GHOST_CLASS:()=>Q,PANEL_GLIDE_MS:()=>rr,PANEL_LEAVE_MS:()=>sr,PLACEHOLDER_FADE_OUT_MS:()=>Ks,PLACEHOLDER_LEAVING_ATTR:()=>De,PLACEHOLDER_SWAP_GAP_MS:()=>zs,PLACEHOLDER_TYPE_MS:()=>qs,PLACEHOLDER_WORD_PAUSE_MS:()=>Gs,PRODUCT_IMAGE_WIDTH:()=>Da,PRODUCT_PATH_PREFIX:()=>Ro,PRODUCT_ROW_PX_PER_LINE:()=>ka,RANGE_SEPARATOR:()=>Fo,SCHEMA_VERSION:()=>fo,SCROLL_ARROW_ATTR:()=>Ut,SCROLL_ARROW_BOTTOM_VAR:()=>er,SCROLL_ARROW_CLASS:()=>Xo,SCROLL_ARROW_FADE_MS:()=>Jo,SCROLL_ARROW_LABEL:()=>la,SCROLL_ARROW_SCROLL_IDLE_MS:()=>Zo,SCROLL_ARROW_VISIBLE_ATTR:()=>Ne,SKIPPED_PARAM_TEXT:()=>co,SMART_SUGGESTION_SPARKLE_SVG:()=>gn,TIME_META_KEY:()=>Po,TIME_STEP_MINUTES:()=>Fn,TIME_WHEEL_COLUMNS:()=>kt,TIME_WHEEL_ROW_HEIGHT:()=>Mt,VIEWPORT_FIT_ATTR:()=>me,VIEWPORT_FIT_HEIGHT_VAR:()=>Gt,WEEKDAY_LABELS:()=>At,addMonths:()=>Rn,attachChipRemove:()=>Ki,attachProductRowWheel:()=>Oi,attachScrollArrow:()=>xi,attachViewportFit:()=>Hi,buildAttributionUrl:()=>mi,buildDateOptions:()=>_n,buildLocationOption:()=>cn,buildQuery:()=>D,buildSubmitResult:()=>jt,buildTimeOption:()=>Wn,cancelStartingHint:()=>Ji,cellDay:()=>Dn,cellIso:()=>K,chipIdFromTap:()=>Pn,clearPanelMorphPressLook:()=>wi,computeOptionsGridLayout:()=>Vo,containScroll:()=>fi,createStore:()=>to,cursorIsAtEnd:()=>Cn,dateCellMarks:()=>ci,dateFloorFor:()=>di,dateSelectionFor:()=>rt,destroyPanelMorph:()=>Ai,dropdownPillsFor:()=>mt,editingSuggestion:()=>Ge,extractPlainText:()=>Me,findMultiSelectDone:()=>na,fitMultiSelectDone:()=>hi,focusEditorFromTap:()=>In,focusesInputOnSelect:()=>je,formatAbsoluteDate:()=>ke,formatDate:()=>Eo,formatDateRange:()=>Wo,formatOptionCount:()=>dt,formatPlace:()=>mo,formatTime:()=>Ot,getCursorOffset:()=>G,getFooterHint:()=>pi,hasSkippablePill:()=>hn,highlightParts:()=>oi,identifiedParamLabel:()=>ie,inPanelGhost:()=>He,isCalendarFormat:()=>_,isDimmedDay:()=>ui,isMultiSelectToggleTap:()=>Di,isOptionsGridMobileViewport:()=>nt,isPickerFormat:()=>N,isSmartSuggestion:()=>Ce,isTouchPrimary:()=>ce,isTraditionalAutocompleteSuggestion:()=>C,isoDate:()=>V,isoTime:()=>Oo,keepCaretOnChip:()=>Ln,labelTraditionalAutocomplete:()=>fn,locationEndpointFor:()=>un,matchTypedPhrase:()=>Vt,measureOptionsGrid:()=>tt,monthLabel:()=>kn,needsOptionsGridMeasurement:()=>Zn,notePanelMorphHeight:()=>Ci,optionCountLabel:()=>ja,optionEnterDelayMs:()=>yi,optionHasImage:()=>vr,optionImageSources:()=>ut,optionImageSrc:()=>Ee,optionLabel:()=>zt,optionsEntranceDurationMs:()=>Si,optionsGridTemplateColumns:()=>Jn,optionsShowLeadingVisuals:()=>Vi,panelMorphGlide:()=>ue,panelMorphKey:()=>Pi,panelMorphTargetHeight:()=>Li,parseDate:()=>It,parseLooseDate:()=>Re,parseLooseDateRange:()=>Ft,parseTime:()=>Nn,plainTextLength:()=>Qe,planOptionsGrid:()=>ei,pointerMayHighlight:()=>Kt,previousGraphemeBoundary:()=>An,productFromMatchedItem:()=>_o,productImageSources:()=>qt,productImageSrc:()=>Ha,productInitial:()=>Mi,productPhotoFill:()=>Ri,productRowWheelTarget:()=>fr,productsFromCustomFields:()=>Kn,queryLive:()=>B,releasePanelHug:()=>lt,renderEditableContent:()=>eo,resolveFormatType:()=>X,resolveIdentifiedDate:()=>jn,sameOptionRows:()=>ti,sanitizeOptionIconSvg:()=>se,scrollCaretIntoView:()=>xn,selectedIsoFromText:()=>Je,selectedRangeFor:()=>_e,setCursorOffset:()=>W,settlePanelMorph:()=>$t,settlePickFocus:()=>Ye,shopifyImageSrc:()=>gr,startingHintOptions:()=>Zi,syncHighlightScroll:()=>Fi,syncPanelHug:()=>Ta,timeWheelIndex:()=>Rt,timeWheelIndexFromScroll:()=>Bn,timeWheelRows:()=>Vn,toWireIdentifiedParams:()=>$e,typedFragment:()=>Ko,uiStringsFor:()=>k,visibleDateRange:()=>li,watchEditorHeight:()=>zi,withSkippedParams:()=>be,withTimeWheelIndex:()=>_t,withoutTraditionalAutocomplete:()=>pn});module.exports=ql(xm);function _(t){return t==="date"||t==="date-range"}function N(t){return t!=="options"}function X(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 en=/[\p{L}\p{N}]/u,Gl=/['\u2019-]/;function Wr(t,e,n){let i=t[e];if(i===void 0)return!1;if(en.test(i))return!0;let o=t[e+n];return Gl.test(i)&&o!==void 0&&en.test(o)}function Kl(t,e,n){let i=e+n.length;return!(en.test(n[0])&&Wr(t,e-1,-1)||en.test(n[n.length-1])&&Wr(t,i,1))}function ae(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 D(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 u=`{{${a.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,d=p=>ae(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)+u+n.slice(f+a.text.length);let p=u.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+u.length}),s=f>=s?f+u.length:s+p}o.push({...a,placeholder:u})}return{rawQuery:n,completedParams:o}}var co="skipped";function be(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:co,kind:null}));return i.length>0?[...t,...i]:t}function tn(t,e,n){return JSON.stringify([t,be(e,n).map(i=>[i.placeholder,i.parameter,i.value??i.text??""])])}function Ue(t){let{rawQuery:e,completedParams:n}=D(t.text,t.completedParams);return tn(e,n,t.skippedParams)}var nn=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 zl="https://api.ai-autocomplete.com",ne=`${zl}/api/suggest`,on=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),Vr=new WeakMap;function St(t){return t?.type==="accessToken"}function Ql(t){if(!(!t||St(t)))return t}function rn(t){let e=Vr.get(t.getAccessToken);return e||(e=new nn(t),Vr.set(t.getAccessToken,e)),e}function sn(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function an(t){let e=Ql(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var ln="aiaPlace",Tt=2,$r=250,Br=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(" ")),Ur=new Set("city beach springs falls island park heights valley bay".split(" ")),jl=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 qr(t){let e=Yl(t);for(;e.length>0&&jl.has(e[0].toLowerCase().replace(/[.,]+$/,""));)e.shift();return e.join(" ")}function Yl(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&&Br.has(r(o))&&Ur.has(r(n))?[o,i,n]:i&&(Br.has(r(i))||Ur.has(r(n)))?[i,n]:[n]}function mo(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function uo(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function po(t,e){let n=uo(e);if(!n)return!1;if(uo(t.name)===n)return!0;for(let[,i]of t.name.matchAll(/\(([^()]*)\)/g))if(uo(i)===n)return!0;return!1}function Gr(t,e){let n=e.metadata?.[ln];if(typeof n?.name!="string")return 0;let i={id:"",name:n.name},o=[...t.matchAll(/\S+/g)];for(let r of o){let s=r.index??0,a=t.slice(s).trim().replace(/[.,]+$/,"");if(po(i,a))return t.length-s}return 0}function cn(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:mo(t),is_tappable:!0,kind:null,metadata:{[ln]:{id:t.id,name:t.name}}}}function un(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??ne,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 Kr(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 $e(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var Xl="0.80.3",fo="1.0",zr=!1;function Jl(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function le(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function Zl(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function ec(t,e,n,i,o,r,s,a,l,c,u,d,f,p,m,g){let b=e.find(P=>P.parameter==="contact"&&P.metadata?.contact_account_count)?.metadata?.contact_account_count,T=typeof b=="number"?b:void 0,y=Zl();return{data:{raw_query:t,...!g&&{accepts_traditional_autocomplete:!0},...p&&{traditional_autocomplete_only:!0},client_option_parameters:f??[],completed_params:be(e.map(P=>Jl(P,n)),l??[]),...s&&s.length>0&&{identified_params:$e(s)},...a&&a.length>0&&{recently_suggested:a},...T!=null&&{contact_account_count:T},...c!==void 0&&{additional_context:c}},meta:{request_id:o,request_at:new Date().toISOString(),language:le(u),...y&&{timezone:y},...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:Xl,session_id:i,...m&&{search_id:m},source:r,schema_version:fo}}}async function Qr(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function go(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=ec(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,n.searchId,n.fullAnswer),s=i?.endpoint??ne,a=await jr(s,JSON.stringify(r),i,n.signal);if(!a.ok)throw new Error(`API error: ${a.status} ${a.statusText}`);return a.json()}async function jr(t,e,n,i){let o=sn(n);if(St(n)){let s=rn(n),a=await s.getToken(),l=await Qr(t,o,a,e,i);if(l.status===401){let c=await s.getToken(!0);l=await Qr(t,o,c,e,i)}return l}let r=an(n);return!r&&!zr&&(zr=!0,console.warn("[Intent-1] 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 vt=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function Yr(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:le(n.language)}),o=await jr(t,i,n.apiConfig,n.signal);if(!o.ok)throw new vt(o.status);return Kr(await o.json())}function ye(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function qe(t,e){return e===!1?"":t}function xt(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function Et(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 Xr(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 Jr(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function tc(t,e){let n=Jr(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function Se(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?Jr(i).trimStart():"";if(o)return t.filter(s=>!s.is_tappable||tc(s.text,o));let r=i.toLowerCase();return t.filter(s=>!s.is_tappable||s.text.toLowerCase().includes(r))}function dn(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 wt(t,e,n,i,o){let r=Et(e,n,i),s=dn(t,r);if(s||!o||!r.trim())return s;if(r===e.slice(n))return null;let a=e.lastIndexOf(" ",n-1)+1;return dn(t,e.slice(a))}function Zr(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 ts(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function ns(t,e){let{icon:n,icon_svg:i}=e;return!i||t.every(es)?t:t.map(o=>es(o)?o:{...o,icon:n,icon_svg:i})}function es(t){return!!(t.icon_svg||t.image_url)}function nc(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function ie(t){let e=nc(t);return e.length>0?e.join(" "):t}function oe(t,e){return t.parameter||e}function Pt(t,e,n){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:n?.trim()||ie(t),...e?{suggestionHeader:e}:{}}}function Ge(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 mn(t,e){let n=oe(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?Pt(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 ic(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function ho(t){return t.parameter_label?.trim()||ic(t.parameter)}function Ce(t){return C(t)||t?.smart_suggestion===!0}function pn(t){return t.some(C)?t.filter(e=>!C(e)):t}function fn(t,e){return t.some(n=>C(n)&&!n.text)?t.map(n=>C(n)&&!n.text?{...n,text:e}:n):t}var gn='<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 hn(t){return t.some(e=>!C(e))}function is(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 os(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 rs(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 ss(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 bn(t,e){let n=[],i=[],o=0;for(let r of e){let s=ae(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 Ae(t,e){let{located:n}=bn(t,e);return n.length>0?n[n.length-1].end:0}function as(t,e,n){let i=[],o=[],r=0;for(let s of n){let a=ae(t,s.text,r,l=>!e.some(c=>l<c.end&&l+s.text.length>c.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 yn(t,e,n=[]){let i=bn(t,e).located,o=[];for(let u of i){let d=o[o.length-1];u.param.group&&d?.param.group===u.param.group?(d.end=u.end,d.params?.push(u.param)):o.push({...u,...u.param.group?{params:[u.param]}:{}})}let r=as(t,o,n).located,s=[...o.map(u=>({start:u.start,end:u.end,segment:{type:"completed",value:t.slice(u.start,u.end),param:u.param,...u.params?{params:u.params}:{}}})),...r.map(u=>({start:u.start,end:u.end,segment:{type:"identified",value:u.param.text,param:u.param}}))].sort((u,d)=>u.start-d.start),a=[],l=0;for(let u of s)u.start>l&&a.push({type:"text",value:t.slice(l,u.start)}),a.push(u.segment),l=u.end;let c=t.slice(l);return c&&a.push({type:"text",value:c}),a}function ls(t,e){let{located:n,missing:i}=bn(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 Lt(t,e,n){let i=bn(t,e).located,{located:o,missing:r}=as(t,i,n);return{valid:o.map(s=>s.param),invalid:r}}function cs(t,e,n){let i=e?.endpoint??ne,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${oc(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,s)=>{let a=on.get(s);return a?`https://${a}`:r})}function oc(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 us(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 rc(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var ds=100,sc=300,ac=2;function lc(t,e){return e===0&&t.trim()===""}var Sn=class{constructor(e,n,i,o,r,s,a,l,c,u={}){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=c;this.callbacks=u;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;this.inFlight=null;this.answered=null;this.committing=!1}start(){this.startingStateOff()||this.doFetch("",[]);let e=this.store.get().text,n=this.store.get().completedParams;this.unsubscribe=this.store.subscribe(i=>{if(i.text!==e||i.completedParams!==n){if(e=i.text,n=i.completedParams,this.asksNothing(i.text,i.completedParams.length)){this.standDown();return}this.scheduleFetch()}})}startingStateOff(){return this.callbacks.getStartingState?.()===!1}asksNothing(e,n){return this.startingStateOff()&&lc(e,n)}standDown(){this.abortController?.abort(),this.abortController=null,this.clearTimers(),this.clearPreview(),this.forceNextFetch=!1,this.fetchVersion++,this.inFlight=null,this.forgetAnswer();let e=this.store.get();e.suggestions.length===0&&e.products.length===0&&e.customFields===null&&!e.traditionalAutocomplete&&!e.isLoading&&!e.isReady&&e.error===null&&e.lastRawQuery===""&&e.filterBase===0&&!e.filterInProgress&&e.activeDropdownIndex===-1&&!e.skipNextFetch||this.store.set({suggestions:[],products:[],customFields:null,traditionalAutocomplete:!1,isLoading:!1,isReady:!1,error:null,lastRawQuery:"",filterBase:0,filterInProgress:!1,activeDropdownIndex:-1,skipNextFetch:!1})}isPhraseExactMatch(){return this.phraseExactMatch}answersState(e){return this.answered!==null&&this.answered.customFields===e.customFields&&this.answered.key===this.requestKey(Ue(e))}forgetAnswer(){this.answered=null}requestKey(e){let n;try{n=JSON.stringify([le(this.getLanguage()),this.callbacks.getCurrency?.()??null,this.getAdditionalContext()??null])}catch{n=""}return`${e}\0${n}`}isCommitting(){return this.committing}answerCurrent(){let e=this.store.get(),{rawQuery:n,completedParams:i}=D(e.text,e.completedParams);if(this.asksNothing(n,i.length))return this.standDown(),Promise.resolve("unasked");let o=this.requestKey(tn(n,i,e.skippedParams));return this.inFlight?.key===o?this.inFlight.settled:(this.clearTimers(),e.skipNextFetch&&this.store.set({skipNextFetch:!1}),this.doFetch(n,i,{fullAnswer:!0}),this.inFlight?.settled??Promise.resolve("superseded"))}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)},ds)}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}=D(e,r.completedParams);try{let l=await go(s,a,{...this.requestOptions(r,n.signal,crypto.randomUUID()),traditionalAutocompleteOnly:!0});if(i!==this.previewVersion||o!==this.fetchVersion)return;let c=(l.data.suggestions??[]).find(C);if(!c)return;let u=l.meta?.traditional_autocomplete===!0;this.shownPreview={answer:c,traditionalAutocomplete:u},this.store.set({suggestions:[c],traditionalAutocomplete:u,activeDropdownIndex:-1})}catch{}}requestOptions(e,n,i){let o=e.pendingSpan?rs(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()??{}),searchId:this.callbacks.getSearchId?.()}}async doFetch(e,n,{fullAnswer:i=!1}={}){if(this.asksNothing(e,n.length)){this.standDown();return}this.abortController?.abort(),this.previewAbort?.abort(),this.previewAbort=null,this.previewPending=!1,this.shownPreview=null,this.forceNextFetch=!1;let o=new AbortController;this.abortController=o;let r=++this.fetchVersion,s="superseded",a=()=>{},l={key:this.requestKey(tn(e,n,this.store.get().skippedParams)),settled:new Promise(d=>{a=d})};this.inFlight=l;let c=this.store.get().text.length,u=this.store.get().text;try{this.callbacks.onRequest?.({query:this.store.get().text,signal:o.signal,isCurrent:()=>r===this.fetchVersion})}catch{}try{this.store.set({isLoading:!0,error:null});let d=this.store.get(),f=crypto.randomUUID(),p=e===""&&n.length===0&&d.skippedParams.length===0&&d.identifiedParams.length===0,m=p?this.startingStateUrl():void 0,g=m?await us(fetch(m,{signal:o.signal})):null;if(r!==this.fetchVersion)return;let b=g??await go(e,n,{...this.requestOptions(d,o.signal,f),fullAnswer:i});if(r!==this.fetchVersion)return;this.phraseExactMatch=b.meta?.phrase_exact_match===!0;let T=(b.data.suggestions??[]).find(C),y=T?[]:b.data.input??[],P=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}:{}}),x=y.filter(E=>E.source==="identified");this.callbacks.waitIdentified?.(x.filter(E=>E.state==="need_confirmation").map(P),u);let h=x.filter(E=>E.state!=="need_confirmation").map(P),v=this.callbacks.isWordOpen?.()??!1,w=this.store.get().text.toLowerCase(),S=E=>v&&w.endsWith(E.text.toLowerCase()),L=h.filter(E=>!S(E));v&&this.callbacks.holdIdentified?.(h.filter(S));let O=T?[T]:ts(b.data.suggestions??[],this.getOptionOverrides());this.startingStateOff()&&(O=O.filter(E=>E.parameter!=="placeholder"));let I=y,j=I[I.length-1],R=this.store.get().text,Y,ee;if(j?.state==="in_progress"){ee=!0;let E=R.toLowerCase().lastIndexOf(j.text.toLowerCase());Y=E!==-1?E:c}else ee=!1,Y=c;let A=O.filter(E=>E.parameter!=="placeholder")[0],fe=null;if(A&&!C(A)&&!v&&A.type?.kind!=="multi_select"&&!N(X(A))){let E=wt(A.options,R,Y,ee,this.phraseExactMatch);E&&(fe={id:crypto.randomUUID(),placeholder:"",parameter:oe(E,A.parameter),text:E.text,value:E.value,kind:E.kind,suggestionParameter:A.parameter,suggestionValueType:A.type,suggestionPlaceholder:A.text,suggestionIcon:A.icon,suggestionIconSvg:A.icon_svg,options:A.options??[],metadata:E.metadata,icon:E.icon,icon_svg:E.icon_svg,image_url:E.image_url},O=O.filter(Le=>Le!==A),this.callbacks.onAutoMatch?.({active:A,matched:E,rawQuery:e}))}let we=b.data.custom_fields??null,Pe=this.callbacks.productsForResponse?.(we);this.answered=T?null:{key:l.key,customFields:we};let Yt=E=>{let Le=fe?[...E.completedParams,fe]:E.completedParams;fe&&this.answered&&E.text===u&&(this.answered={...this.answered,key:this.requestKey(Ue({text:E.text,completedParams:Le,skippedParams:E.skippedParams}))});let Ve=new Set,Fr=Lt(E.text,Le,L).valid.map(H=>{let bt=E.identifiedParams.find(Be=>!Ve.has(Be.id)&&Be.parameter===H.parameter&&Be.text===H.text);return bt?(Ve.add(bt.id),{...H,id:bt.id}):H}),Xt=new Set(d.skippedParams.map(H=>H.id)),Jt=new Set(E.skippedParams.filter(H=>!Xt.has(H.id)).map(H=>H.parameter)),ht=Jt.size>0?O.filter(H=>H.parameter==="placeholder"||!Jt.has(H.parameter)):O,Zt=this.callbacks.getAllOption?.()===!0&&!p,ge=E.composing?this.shownPreview:null;return{suggestions:ge?[ge.answer]:Zt?ht.map(H=>H.parameter==="placeholder"?H:{...H,leadsWithAll:!0}):ht,isLoading:!1,isReady:b.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:Y,filterInProgress:ee,identifiedParams:Fr,customFields:we,traditionalAutocomplete:ge?ge.traditionalAutocomplete:b.meta?.traditional_autocomplete===!0,...Pe!==void 0?{products:Pe}:{},...fe?{completedParams:Le}:{}}};this.committing=!0;try{this.store.set(Yt)}finally{this.committing=!1}s="committed",this.callbacks.onResponse?.({requestId:f,funnelTelemetry:b.meta?.funnel_telemetry===!0,visibleImpression:b.meta?.visible_impression===!0,sdkVisitorId:b.meta?.sdk_visitor_id===!0,searchIds:b.meta?.search_ids===!0})}catch(d){let f=rc(d);s!=="committed"&&r===this.fetchVersion&&(s="failed"),r===this.fetchVersion&&(this.store.set({error:f,isLoading:!1}),this.getOnError()?.(f))}finally{if(r===this.fetchVersion&&this.store.get().isLoading)try{this.store.set({isLoading:!1})}catch{}this.inFlight===l&&(this.inFlight=null),a(s)}}startingStateUrl(){let e=this.callbacks.getProductId?.();return e?cs(e,this.getApiConfig(),le(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(ac)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},ds),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),sc)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;if(this.forceNextFetch){let{rawQuery:v,completedParams:w}=D(o.text,o.completedParams);return this.doFetch(v,w),!0}let s=qe(o.suggestions.filter(v=>v.parameter==="placeholder").map(v=>v.text).join(" "),this.callbacks.getPrependPlaceholder?.()),a=ye(o.text,o.filterBase,s),l=Et(o.text,a,o.filterInProgress),c=o.suggestions.filter(v=>v.parameter!=="placeholder"),u=C(c[0])?void 0:c[0],d=N(o.activeFormatType),f=u&&!d?Se(u.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&f.length>0)return!1;let p=f.filter(v=>v.is_tappable),m=u&&!d&&!this.callbacks.isWordOpen?.()?wt(u.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||xt(o.text,o.completedParams.length,s))return!1;let{rawQuery:T,completedParams:y}=D(o.text,o.completedParams),P=T.length<o.lastRawQuery.length,x=Math.abs(T.length-o.lastRawQuery.length),h=n&&T!==o.lastRawQuery;return P||x>=e||h?(this.doFetch(T,y),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};function cc(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function Te(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&cc(e)?e:t.ownerDocument??t}function Ke(t){return Te(t).activeElement??null}function F(t){return t.ownerDocument??t}function uc(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function ms(t){let e=Te(t);return!uc(e)||typeof e.getSelection=="function"?null:e}function ps(t){let e=ms(t);if(!e)return null;let n=F(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function fs(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 Ie(t){let n=Te(t).getSelection?.();return n||(F(t).getSelection?.()??null)}function J(t){let e=Ie(t);if(!e||e.rangeCount===0)return null;let n=ps(t);if(n){let i=fs(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 Oe(t){let e=Ie(t);if(!e||e.rangeCount===0)return null;let n=ps(t);if(!n)return e.getRangeAt(0);let i=fs(e,n);if(!i)return null;let o=F(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function Ct(t,e,n){let i=Ie(t);if(!i)return null;if(ms(t))return i.collapse(e,n),i;let o=F(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function Tn(t,e){let n=t?Te(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var vn=2,dc="magicx-aia";function gs(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function mc(t){let e=F(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&&gs(s.overflowX)||r&&gs(s.overflowY))return i}if(i.classList.contains(dc))return null;i=i.parentElement}return null}function xn(t){let e=Oe(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=mc(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+vn:i.left<r&&(n.scrollLeft-=r-i.left+vn)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,s=r+n.clientHeight;i.bottom>s?n.scrollTop+=i.bottom-s+vn:i.top<r&&(n.scrollTop-=r-i.top+vn)}}var bs='[contenteditable="false"]',yo="strong[data-param-id]",ze;function pc(){if(ze!==void 0)return ze;let t=globalThis.Intl.Segmenter;if(!t)return ze=null,null;try{ze=new t(void 0,{granularity:"grapheme"})}catch{ze=null}return ze??null}function En(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(bs))return!0;n=n.parentNode}return!1}function wn(t){return F(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return En(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Me(t){let e=wn(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function Qe(t){let e=wn(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function G(t){let e=J(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(En(o,t)&&o!==t)return null;let r=0;for(let s=0;s<i&&s<o.childNodes.length;s++)r+=So(o.childNodes[s],t);return r+bo(o,t)}return n.nodeType!==Node.TEXT_NODE||En(n,t)?null:bo(n,t)+i}function So(t,e){if(t.nodeType===Node.TEXT_NODE)return En(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(bs))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=So(o,e);return i}function bo(t,e){let n=wn(e),i=0,o=n.nextNode();for(;o;){if(o===t||t.nodeType===Node.ELEMENT_NODE&&t.contains(o))return i;i+=o.data.length,o=n.nextNode()}return i}function W(t,e){let n=F(t),i=Math.max(0,Math.min(e,Qe(t))),o=wn(t),r=0,s=null,a=0,l=o.nextNode(),c=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,c=l,l=o.nextNode()}let u=n.createRange();if(s){let d=s.parentElement?.closest('strong[data-seg="completed"]');d&&d!==t&&t.contains(d)?a===0?u.setStartBefore(d):a===s.data.length?u.setStartAfter(d):u.setStart(s,a):u.setStart(s,a)}else c?u.setStart(c,c.data.length):u.setStart(t,0);u.collapse(!0),Ct(t,u.startContainer,u.startOffset)&&(fc(t,u,i),xn(t))}function hs(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(yo)??null;return i&&e.contains(i)?i:null}function fc(t,e,n){let i=hs(J(t)?.node??null,t);if(i&&i!==hs(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function ys(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=G(t);return i!==null&&n===`${i}:${e}`}function Ss(t){return Te(t).activeElement===t}function Pn(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(yo);if(!o||!t.contains(o))return null;let r=J(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function Ln(t,e){let n=null;for(let s of t.querySelectorAll(yo))if(s.dataset.paramId===e){n=s;break}if(!n)return;let i=bo(n,t),o=i+So(n,t),r=G(t);r!=null&&r>=i&&r<=o||W(t,i)}function Cn(t){let e=G(t);return e==null?!1:e>=Qe(t)}function An(t,e){if(e<=0)return 0;let n=pc();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 gc="(hover: none) and (pointer: coarse)";function ce(){try{if(typeof window>"u")return!1;let t=window.matchMedia;return typeof t!="function"?!1:(To?.source!==t&&(To={source:t,list:window.matchMedia(gc)}),To.list.matches===!0)}catch{return!1}}function hc(t){let e=Ke(t);return e===t||!!e?.closest("[data-aia-location]")}function vo(t){let e=J(t);e&&t.contains(e.node)&&Ie(t)?.removeAllRanges()}var To=null;function je(t){return t==="always"?!0:t==="never"?!1:!ce()}function Ye(t,e,n){if(!n&&!hc(t)){vo(t);return}t.focus(),W(t,e)}function In(t){let e=J(t),n=e!==null&&t.contains(e.node);t.focus(),!n&&ce()&&W(t,Qe(t))}var Ts=150,bc="[data-aia-dropdown], [data-aia-input-wrapper]",yc=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),On=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.picking=0;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(yc)),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})},Ts))};this.unsubscribe=e.subscribe(()=>this.sync())}dispose(){this.unsubscribe(),this.listen(!1),this.cancelRelease(),this.recheckTimer!==null&&clearTimeout(this.recheckTimer),this.recheckTimer=null}through(e){this.picking++;try{return e()}finally{this.picking--,this.picking===0&&this.sync()}}holdThroughBlur(){let e=this.store.get();!ce()||!e.isDropdownOpen||e.dropdownHeld||(this.declined=!1,this.store.set({dropdownHeld:!0}))}sync(){let e=this.store.get(),n=ce();e.isFocused||(this.declined=!1),e.isDropdownOpen?e.isFocused&&!e.dropdownHeld&&!this.declined&&n&&this.store.set({dropdownHeld:!0}):e.dropdownHeld&&this.picking===0&&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())},Ts)}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(bc))return!0;return!1}};var Xe=["January","February","March","April","May","June","July","August","September","October","November","December"],At=["S","M","T","W","T","F","S"],Es=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Mn="aiaDate",ws="aiaDay",vs=t=>String(t).padStart(2,"0");function V(t){return`${t.getFullYear()}-${vs(t.getMonth()+1)}-${vs(t.getDate())}`}function xo(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Sc(t){let e=xo(t).getTime()-xo(new Date).getTime();return Math.round(e/864e5)}function Eo(t){let e=Sc(t);return e>=0&&e<7?Es[t.getDay()]:ke(t)}function ke(t){return t.getFullYear()===new Date().getFullYear()?`${Xe[t.getMonth()]} ${t.getDate()}`:`${Xe[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function It(t){if(!t)return null;let e=Es.findIndex(a=>a.toLowerCase()===t.trim().toLowerCase());if(e>=0){let a=xo(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=Xe.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 kn(t){return`${Xe[t.month]} ${t.year}`}function wo(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function Ps(t){return{year:t.getFullYear(),month:t.getMonth()}}function Rn(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function xs(){return{text:"",is_tappable:!1,kind:null}}function _n(t){let e=new Date(t.year,t.month,1).getDay(),n=new Date(t.year,t.month+1,0).getDate(),i=[];for(let o=0;o<e;o++)i.push(xs());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:Eo(r),is_tappable:!0,kind:null,metadata:{[Mn]:V(r),[ws]:o}})}for(;i.length%At.length!==0;)i.push(xs());return i}function Je(t){let e=It(t);return e?V(e):null}function K(t){let e=t?.metadata?.[Mn];return typeof e=="string"?e:null}function Dn(t){let e=t?.metadata?.[ws];return typeof e=="number"?e:null}var Po="aiaTime",Fn=5;var Lo=[12,1,2,3,4,5,6,7,8,9,10,11],Co=Array.from({length:60/5},(t,e)=>e*5),Ao=["AM","PM"];function et(t){return(Math.round(t)%1440+1440)%1440}function Io(t){let e=et(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function Hn(t){let e=t.hour%12+(t.period==="PM"?12:0);return et(e*60+t.minute)}function Ot(t){let{hour:e,minute:n,period:i}=Io(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function Oo(t){let e=et(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function Ze(t){return et(Math.round(t/5)*5)}function Ls(t,e){return et(t+e)}var Tc=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,vc=/^(\d{1,2}):(\d{2})$/;function Nn(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=Tc.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:Hn({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=vc.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=Nn(t.editingText);if(e!=null)return Ze(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>Nn(o.text)).filter(o=>o!=null);if(n.length>0)return Ze(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return et((i.getHours()+1)*60)}function Wn(t){return{text:Ot(t),is_tappable:!0,kind:null,metadata:{[Po]:Oo(t)}}}var Mt=30,kt=["hour","minute","period"],Mo={hour:Lo.map(t=>({label:String(t)})),minute:Co.map(t=>({label:String(t).padStart(2,"0")})),period:Ao.map(t=>({label:t}))};function Vn(t){return Mo[t]}function Rt(t,e){let n=Io(Ze(e));return t==="hour"?Lo.indexOf(n.hour):t==="minute"?Co.indexOf(n.minute):Ao.indexOf(n.period)}function _t(t,e,n){let i=Mo[t],o=Math.min(Math.max(n,0),i.length-1),r=Io(Ze(e));return Hn(t==="hour"?{...r,hour:Lo[o]}:t==="minute"?{...r,minute:Co[o]}:{...r,period:Ao[o]})}function Bn(t,e){let n=Mo[t].length-1;return Math.min(Math.max(Math.round(e/Mt),0),n)}function Un(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")?Cn(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function ko(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?G(t):null}var $n=class{constructor(e,n){this.store=e;this.ctx=n}handleKeyDown(e){let n=this.store.get();this.handleKey(e),n.highlightByPointer&&this.store.get().activeDropdownIndex!==n.activeDropdownIndex&&this.store.set({highlightByPointer:!1})}handleKey(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 c=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let u=n.highlightByPointer?void 0:n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&u?.is_tappable){e.preventDefault(),this.ctx.selectOption(u);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&u?.is_tappable&&this.ctx.selectOption(u),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let u=Un(e.target,n),d=!!n.editingParam;if(!u&&!d&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(c)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(!c)break;let f=Un(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 u=l.indexOf(n.activeDropdownIndex),d=u>0?u-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?.(),W(d,f);break}Un(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 u=n.activeDropdownIndex-1;u>=0&&n.filteredOptions[u]?.is_tappable&&this.store.set({activeDropdownIndex:u});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let u=ko(e.target);u!=null&&this.ctx.startEditingParamAtCaret(u)}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingAnchor!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,d=n.editingAnchor;this.ctx.exitEditMode?.(),W(u,d);break}if(this.ctx.startEditingParamAtCaret){let u=ko(e.target);u!=null&&this.ctx.startEditingParamAtCaret(u)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let u=ko(e.target);if(u==null)break;this.ctx.removeParamAtCaret(u)&&e.preventDefault();break}case"Enter":{e.preventDefault(),n.activeDropdownIndex>=0&&n.filteredOptions[n.activeDropdownIndex]?.is_tappable?this.clickOrSelect(n.activeDropdownIndex,n.filteredOptions,i,r):a&&this.ctx.submit();break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let u=n.filteredOptions.map((p,m)=>p.is_tappable?m:-1).filter(p=>p!==-1);if(u.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let p=e.shiftKey?u[u.length-1]:u[0];this.store.set({pillTapped:!0,activeDropdownIndex:p});break}e.preventDefault();let d=u.indexOf(n.activeDropdownIndex);if(!e.shiftKey&&!_(n.activeFormatType)&&!n.multiSelectView){let p=d>=0?u[d]:u.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?u.length-1:0;else{let p=e.shiftKey?-1:1;f=(d+p+u.length)%u.length}this.store.set({activeDropdownIndex:u[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 u=e.target.closest("[data-aia-input]")??e.target,d=n.editingTail;this.ctx.exitEditMode?.(),W(u,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!Un(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=V(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=Tn(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=Tn(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=Tn(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var qn=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(N(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||xc(s))return;this.logOnce(s),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=ns(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(c=>c===e.suggestion?a:c),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("[Intent-1] an optionOverrides entry threw or rejected \u2014 treated as no options. Later failures on this instance are not logged.",e))}};function xc(t){return t instanceof Error&&t.name==="AbortError"}var Gn=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(c=>c.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(C(o))return;let r=i.filter((c,u)=>u!==e),s=n.suggestions.filter(c=>c.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:c}=D(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:c,selectedPill:o.text,otherPills:r.map(u=>u.text)})}let a=[...s,o,...r],l=this.store.peek({suggestions:a}).filteredOptions.findIndex(c=>c.is_tappable&&!c.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 Ro="/products/",As="https://relative.invalid";function Ec(t){if(!t)return;let e;try{e=new URL(t,`${As}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===As?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function _o(t,e){let n=Ec(t.item_url)??Pc(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:Is(t.price,t.currency,e)},...wc(t)&&{compareAtPrice:Is(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function wc(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 Is(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 Pc(t){if(!t.handle)return;let e=`${Ro}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function Kn(t,e){return(t?.items.matched??[]).map(n=>_o(n,e))}var zn=class{constructor(e,n,i=()=>!0,o=()=>{},r=()=>{}){this.store=e;this.getConfig=n;this.isEnabled=i;this.getLanguage=o;this.getMapper=r;this.hasLoggedError=!1;this.hasLoggedMapperError=!1}forResponse(e){if(!this.isEnabled())return[];if(this.getConfig())return;let n=Kn(e,le(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("[Intent-1] 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:[],c=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(c)}catch(s){if(n.aborted||Lc(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("[Intent-1] products.fetch/transform failed \u2014 the product strip is hidden. Later failures on this instance are not logged.",e))}};function Lc(t){return t instanceof Error&&t.name==="AbortError"}function Cc(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function Os(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:Xe.findIndex(n=>n.toLowerCase().startsWith(e))}function Ac(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 Ic=/^(?:(?:on|from) )?(?:the )?(\d{1,2})(?:st|nd|rd|th)$/;function Do(t){let e=Ic.exec(t.trim().toLowerCase().replace(/\s+/g," "));if(!e)return null;let n=Number(e[1]);return n>=1&&n<=31?n:null}function Oc(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 Ms(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function Re(t,e={}){if(!t)return null;let n=e.today??new Date,i=Do(t);if(i!==null){let c=Oc(i,n);return c?V(c):null}let o=Cc(t.trim().toLowerCase()).replace(/\s+/g," "),r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o);if(r){let c=Ms(Number(r[1]),Number(r[2])-1,Number(r[3]));return c?V(c):null}let s=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(o);if(s){let c=Os(s[1]);if(c>=0)return Qn(c,Number(s[2]),s[3],n)}let a=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(o);if(a){let c=Os(a[2]);if(c>=0)return Qn(c,Number(a[1]),a[3],n)}let l=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(o);if(l){let c=Number(l[1]),u=Number(l[2]);return c>12&&u<=12?Qn(u-1,c,l[3],n):u>12&&c<=12?Qn(c-1,u,l[3],n):null}return null}function Qn(t,e,n,i){if(n){if(n.length!==4)return null;let r=Ms(Number(n),t,e);return r?V(r):null}let o=Ac(t,e,i);return o?V(o):null}var Mc=/^\d{4}-\d{2}-\d{2}$/;function Dt(t){return typeof t=="string"&&Mc.test(t)?t:null}function jn(t,e={}){return Dt(t.isoDate)??Re(t.text,e)}function Ht(t){let e=Dt(t.isoDate);return e?{start:e,end:Dt(t.isoDateEnd)}:null}var Fo=" - ",Yn="aiaDateRangeStart",Xn="aiaDateRangeEnd";function Nt(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var Ho=/^\d{4}-\d{2}-\d{2}$/;function No(t){if(!Ho.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 kc=/\s+(?:to|through|thru|until|til|till)\s+/g,Rc=/[-–—]/g;function _c(t){let e=[];for(let n of[kc,Rc]){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 Ft(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of _c(t.trim())){let s=Re(o.trim(),e);if(!s)continue;let a=Do(r)!==null?Re(r.trim(),{...e,today:No(s)??e.today}):Re(r.trim(),e);!a||a<s||(n.add(`${s}|${a}`),i={start:s,end:a})}return n.size===1?i:null}function Wo(t){let e=No(t.start),n=No(t.end);return!e||!n?"":t.start===t.end?ke(e):`${ke(e)}${Fo}${ke(n)}`}function ks(t,e){let n=Nt(t,e);return{text:Wo(n),is_tappable:!0,kind:null,metadata:{[Yn]:n.start,[Xn]:n.end}}}function _e(t,e={}){let n=t?.metadata?.[Yn],i=t?.metadata?.[Xn];return typeof n=="string"&&typeof i=="string"&&Ho.test(n)&&Ho.test(i)?Nt(n,i):Ft(t?.text,e)}var Wt="(max-width: 768px)";var Dc="var(--aia-option-row-height, 37px)",Hc="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)",Nc="max(0, var(--aia-option-peek, 0))";function Vo(t,e){let n=e?5:4;return Rs(1,Math.min(t,n),t>n)}function Rs(t,e,n){let i=n?`(${e} + ${Nc})`:`${e}`;return{cols:t,rows:e,maxHeight:`calc(${i} * ${Dc} + ${Hc})`}}function Zn(t,e){return!e&&t>=5}function ei(t,e,n,i){if(!(!e&&t>=5&&Fc(n,i))){let s=Vo(t,e);return{...s,template:Jn(s.cols),scrollHintIndices:!e&&t>s.rows?[s.rows-1]:[]}}let r=6;return{...Rs(2,3,t>r),template:Jn(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 tt(t){if(typeof document>"u")return null;let e=Array.from(t.querySelectorAll("[data-aia-option]"));if(e.length===0)return null;let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:-9999px;top:0;";for(let 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);return{rowWidths:i,gridWidth:r}}var Bo="data-aia-glide-width",Uo="--aia-glide-content-width";function Jn(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function nt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Wt).matches}function ti(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}var _s={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"},Wc={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"},$o={en:_s,es:Wc,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"}},Vc={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 $o[o?"zh-TW":"zh-CN"]}let i=Vc[e]??e;return Object.prototype.hasOwnProperty.call($o,i)?$o[i]:_s}function Ds(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,c=t.caretOffset==null||t.caretOffset>=l;return(s||t.isLoading)&&a&&c}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 ni(t){if(!t)return wo();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function Bc(t){let e=It(t);return e?Ps(e):wo()}function Uc(t,e){if(!t)return null;for(let n of e){if(n.parameter!==t||n.type?.kind!=="date_range")continue;let i=Ht(n);if(i&&i.end==null)return i.start}return null}function $c(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(Dt(i.metadata?.[Mn])??Je(i.text)),o==="date_range"){let r=_e(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=Ht(i);n(r?.start),n(r?.end)}return[...e].sort()}function qo(t,e){return t.editingParam!=null&&t.editingAnchor!=null?e:t.text.slice(Ae(t.text,t.completedParams))}var qc=/price/i;function Gc(t){return!t||Ce(t)||N(X(t))||t.type?.kind==="multi_select"||qc.test(t.parameter)?!1:(t.options??[]).filter(e=>e.is_tappable).length>=2}function it(t,e,n){if(e>0)return!1;let i=t.trim();return i===""||i.toLowerCase()===n.trim().toLowerCase()||xt(i,0,n)}var Kc=4;function zc(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,Kc);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 Qc(t,e){let{composing:n}=t,i=n?.over===t.text?n.text:t.text,o=i.slice(Ae(i,t.completedParams));return e?.completes_word!==!0?o:o.match(/\S+(?=\s*$)/)?.[0]??""}function Hs(t,e){let n=yn(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(M=>M.parameter!=="placeholder"),o=i[0],r=e.startingState===!1,s=r?"":t.suggestions.filter(M=>M.parameter==="placeholder").map(M=>M.text).join(" "),a=qe(s,e.prependPlaceholder),l=ye(t.text,Math.min(t.filterBase,t.text.length),a),u=l===0&&xt(t.text,t.completedParams.length,a)?"":Et(t.text,l,t.filterInProgress),d=o?.options??[],f=t.editingParam!=null&&t.editingAnchor!=null,p=!f&&!t.editingIdentified&&o?.type?.kind==="multi_select",m,g,b,T;if(f&&t.editingParam&&t.editingAnchor!=null){let M=t.editingParam.id,q=t.completedParams.some(he=>he.id===M),yt=t.caretOffset??t.editingAnchor,te=q?"":t.text.slice(t.editingAnchor,yt);g=te.trim(),b=t.editingParam.options,T=t.editingParam.suggestionParameter,m=t.editingParam.suggestionValueType?.kind==="traditional_autocomplete"?Se(t.editingParam.options,te).map(he=>({...he,matchedText:g,parameterLabel:ho(he)})):Se(t.editingParam.options,te)}else g=u.trim(),b=d,T=o?.parameter,m=C(o)?d.map(M=>({...M,matchedText:Qc(t,o),parameterLabel:ho(M)})):Se(d,u,t.traditionalAutocomplete);let y=t.optionSearch,P=y!=null&&T!=null&&y.parameter===T;P&&y.status==="done"&&y.query===g&&(m=b);let x=P&&y.status==="loading",h=e.showNonTappableOptions===!1;h&&(m=m.filter(M=>M.is_tappable));let v=it(t.text,t.completedParams.length,a);e.allOption===!0&&o?.leadsWithAll===!0&&!v&&!f&&!t.editingIdentified&&u.trim()===""&&Gc(o)&&(m=zc(m,k(e.language).allOption));let w=qo(t,g),S=f?t.editingParam?.suggestionValueType?.kind==="traditional_autocomplete":C(o);!p&&!S&&(m=Zr(m,w));let L=t.editingIdentified,O=f?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,I=L?L.format:X(O),j=f?t.editingParam?.suggestionParameter:o?.parameter,R=I==="location"&&j&&e.optionOverrides?.[j]?"options":I,Y=f&&R==="date-range"?_e(t.editingParam):null,ee=!f&&!L&&R==="date"?Uc(o?.parameter,t.identifiedParams):null,pe=null,A=null,fe=_(R)?$c(t):[];if(_(R)){let M=V(new Date),q=fe.find(Fl=>Fl>=M)??null,yt=U({...t,actionableSuggestions:i}),te=t.dateViewMonth;pe=te&&te.key===yt?{year:te.year,month:te.month}:L?ni(L.iso):Y?ni(Y.start):ee?ni(ee):q&&!f?ni(q):Bc(t.editingParam?.text),m=_n(pe);let he=t.pendingRangeStart;R==="date-range"&&he&&he.key===yt&&(A=he.iso)}let we=null;if(R==="time"){let M=U({...t,actionableSuggestions:i}),q=t.timeDraft;we=q&&q.key===M?{minutes:q.minutes,touched:!0}:{minutes:Cs({editingText:f?t.editingParam?.text:null,options:f?t.editingParam?.options:o?.options}),touched:!1},m=[]}let Pe=null;if(R==="location"){let M=U({...t,actionableSuggestions:i}),q=t.locationSearch;if(q&&q.key===M){let{key:yt,...te}=q;Pe=te}else Pe={query:f?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};m=[]}let Yt=M=>h?M.is_tappable:!0,E;if(f){let M=t.editingParam?.options??[];E=t.editingParam!=null&&M.filter(Yt).length===0}else E=o!=null&&d.filter(Yt).length===0;we&&(E=!0),Pe&&(E=!0);let Le=t.composing?.over===t.text?t.composing.text:t.text,Ve=r&&it(Le,t.completedParams.length,a),Xt=Ds({inEditMode:f||L!=null,filteredOptionsLength:m.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||x,pillTapped:t.pillTapped,activePillHasNoOptions:E,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur})&&!Ve,Jt=Xt&&t.activeDropdownIndex>=0&&!!m[t.activeDropdownIndex]?.is_tappable,ht=!Ve&&t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,Zt=!Ve&&(t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||x||ht),ge=Zt&&t.skeletonOptions!==null,H=ge&&t.skeletonOptions?t.skeletonOptions:m,bt=ge?t.skeletonSuggestion:null,Be=p?{picked:t.multiSelectDraft?.key===U({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,Nl=Be??(ge&&t.skeletonSuggestion?.type?.kind==="multi_select"?{picked:t.skeletonPicked??[]}:null);return{segments:n,actionableSuggestions:i,filteredOptions:m,dropdownLoading:Zt,dropdownOptions:H,dropdownSuggestion:bt,skeletonExiting:ht,activeFormatType:R,dateView:pe,dateRangeStart:A,dateFloor:ee,dateReferences:fe,timeView:we,multiSelectView:Be,dropdownMultiSelect:Nl,locationView:Pe,placeholderText:s,leadInText:a,optionQuery:g,isSearchingOptions:x,isDropdownOpen:Xt,isActivePillSelected:Jt}}function ii(t){return t.mode!=="edit"?Yc(t):Xc(t)}function jc(t,e,n){let i=t.find(C);if(!i?.options)return null;let o=e.slice(Ae(e,n)).trim().toLowerCase();if(!o)return null;let r=i.completes_word===!0?o.split(/\s+/).pop()??"":o,s=i.options.filter(c=>c.is_tappable&&c.text.trim().toLowerCase()===r);if(new Set(s.map(c=>oe(c,i.parameter))).size!==1)return null;let l=s[0];return{suggestion:i,option:l,matchText:l.text.trim()}}function Ns(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,s=n.find(u=>u.parameter!=="placeholder"&&!C(u));if(!s?.options||s.type?.kind==="multi_select")return null;let a=n.filter(u=>u.parameter==="placeholder").map(u=>u.text).join(" "),l=ye(e,i,qe(a,t.prependPlaceholder)),c=wt(s.options,e,l,o,r===!0);return c?{suggestion:s,option:c,matchText:c.text}:null}function Yc(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?Ns(t):null)??jc(i,e,n):Ns(t);if(!o)return null;let{suggestion:r,option:s,matchText:a}=o,l=a.toLowerCase(),c=e.toLowerCase().lastIndexOf(l),u=c>=0?c:Math.max(0,e.length-s.text.length),d=u+a.length,f=e.slice(u,d),m=d<e.length&&e[d]===" "?d+1:d,g={id:crypto.randomUUID(),placeholder:"",parameter:oe(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)?Pt(oe(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 Xc(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=dn(i.options,s);if(!a)return null;let l=a.text.toLowerCase(),c=s.toLowerCase().lastIndexOf(l),u=o+Math.max(0,c),d=u+a.text.length,f=e.slice(u,d),p=d<e.length&&e[d]===" "?d+1:d,m=e.length,g={id:crypto.randomUUID(),placeholder:"",...mn(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 x=ae(e,n[P].text,T);if(x!==-1){if(x>=p){b=P;break}T=x+n[P].text.length}}let y=[...n];return y.splice(b,0,g),{patch:{text:e,completedParams:y,newParamId:g.id,filterBase:m,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:m,activeDropdownIndex:-1},caretPos:m,option:a}}function Ko(t){return t.slice(t.search(/\S*$/))}function Ws(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function zo(t,e){let n="",i=0;for(let o of t){let r=i;if(n+=Ws(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 Go(t){return[...t].map(Ws).join("")}function Vt(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(Go),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:Go(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 c=i[a+o-1],u=zo(c.text,s);if(u)return{typedWords:o,start:i[a].index,end:c.index+u.length,partialStart:c.index+u.partialStart}}}return null}function Fs(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 Jc(t,e){let n=0;for(let i of t){if(!/^\p{M}/u.test(i)){let o=zo(t.slice(n),e);if(o)return{start:n,end:n+o.length,partialStart:n+o.partialStart}}n+=i.length}return null}var Zc=/\p{Script=Hangul}/u;function oi(t,e){let n=e?Vt(t,e):null;if(n&&n.typedWords>1)return Fs(t,n.start,n.end,n.partialStart);let i=e?Ko(e):"",o=Go(i);if(!o)return[{text:t,bold:!1}];let r=[],s=!1;for(let l of t.split(/(\s+)/)){if(l==="")continue;let c=/^\s/.test(l)?null:zo(l,o);if(c){s=!0;let{length:d,partialStart:f}=c;r.push(...Vs(l,0,d,f))}let u=c?l.slice(c.length):l;u&&r.push({text:u,bold:!1})}if(s||!Zc.test(i))return r;let a=Jc(t,o);return a?Fs(t,a.start,a.end,a.partialStart):r}var eu=6e4;function tu(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function nu(t){return(t??ne).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function iu(t){return St(t)?`Bearer ${await rn(t).getToken()}`:an(t)}async function Bs(t){try{let e=nu(t.apiConfig?.endpoint),n=sn(t.apiConfig),i=await iu(t.apiConfig);i&&(n.Authorization=i);let o=JSON.stringify({source:t.source,session_id:t.sessionId,...t.visitorId&&{visitor_id:t.visitorId},...t.searchId&&{search_id:t.searchId},...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&&tu(o)<=eu&&{keepalive:!0}})}catch{}}function ve(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var Qo=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function ou(t,e,n){let i=Qo(t??"");if(i.length===0)return"";let r=Qo(e).slice(-i.length),s=Qo(n).slice(0,i.length);return r.join(" ")===i.join(" ")||s.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function Us(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:oe(e,n.parameter),s=i?t.text.length:t.filterBase,a=t.text.slice(0,s),l=a.length===0&&t.text.length===0,c=a.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||c)&&t.placeholderText&&(a=`${t.placeholderText} `);let u=Math.min(Ae(t.text,t.completedParams),a.length),d=!1;if(i&&n.completes_word!==!0){let S=[...a.slice(u).matchAll(/\S+/g)],L=Vt(e.text,a.slice(u)),O=S[S.length-(L?.typedWords??1)];a=a.slice(0,O?u+(O.index??0):Math.max(a.lastIndexOf(" ")+1,u))}else if(n.completes_word===!0){let S=[...a.slice(u).matchAll(/\S+/g)],L=S[S.length-1];a=a.slice(0,L?u+(L.index??0):Math.max(a.lastIndexOf(" ")+1,u))}else if(n.completes_word!==!1){let S=a.slice(u),L=Math.max(Xr(S,e.text),Gr(S,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&&!N(t.activeFormatType)&&N(X({type:n.type})),g=p||m?"":ou(n.lead_in,a,e.text),b=`${a}${f?" ":""}${g?`${g} `:""}${e.text} `,y=(l||c||i&&a.length===0)&&b.length>0?b[0].toUpperCase()+b.slice(1):b,P=y.toLowerCase().lastIndexOf(e.text.toLowerCase()),x=P>=0?y.slice(P,P+e.text.length):e.text,h=i?Pt(r,n.text,e.parameter_label):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text,suggestionIcon:n.icon,suggestionIconSvg:n.icon_svg},v={id:crypto.randomUUID(),placeholder:"",...h,text:x,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},w=t.actionableSuggestions.length-1;return{patch:{text:y,filterBase:y.length,completedParams:[...t.completedParams,v],newParamId:v.id,caretOffset:y.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(S=>S.text!==e.text).map(S=>S.text),key:i?r:n.parameter,position:ve(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:w}}function Bt(t,e){let n=N(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,i=t.editingParam,o=i?Ge(i):t.actionableSuggestions[0]??null;return{skeletonOptions:n,skeletonSuggestion:n?o:null,skeletonPicked:n?e??null:null,skeletonRequested:!1}}function ri(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 si=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=ae(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===""?ri(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(c=>c.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=mn(i,e);this.deps.fireTelemetry("option",{raw_query:D(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(y=>y.text!==e.text).map(y=>y.text),key:s.suggestionParameter,position:ve(i.options,e.text),chip_origin:"tap"});let a=n.text.slice(0,o),l=n.text.slice(r),c=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,d=l.length===0||l[0]!==" "?`${c} `:c,f=a+d+l,p=f.length,m={id:crypto.randomUUID(),placeholder:"",...s,text:c,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},g=n.completedParams.findIndex(y=>y.id===i.id),b=n.completedParams.filter(y=>y.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,...Bt(n)}),this.deps.startSelectionAnimationTimer(),this.deps.schedulePickCursor(p),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=ii({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 qs=33,Gs=70,Ks=120,zs=50,De="data-aia-placeholder-leaving",ot=new WeakMap;function ai(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function ru(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Qs(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function js(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Qs(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(()=>js(t,e),33+i)}function $s(t,e){Qs(t,e,0),e.timer=setTimeout(()=>js(t,e),33)}function Ys(t,e){let n=ot.get(t);if(e===""){n&&(ai(n),ot.delete(t)),t.removeAttribute(De),delete t.dataset.placeholder;return}if(n?.target===e)return;if(ru(t)){n&&ai(n),t.removeAttribute(De),ot.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&&ai(n),ot.set(t,i),o){t.setAttribute(De,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(De),t.isConnected&&$s(t,i)},170);return}t.removeAttribute(De),$s(t,i)}function Xs(t){let e=ot.get(t);e&&(ai(e),ot.delete(t))}var su={selectedIso:null,selectedRange:null,rangeStart:null};function rt(t){if(!_(t.activeFormatType))return su;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?Nt(i,o):null,rangeStart:t.dateRangeStart,references:t.dateReferences??[]}}let n=_e(t.editingParam);return{selectedIso:n?null:Je(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart??t.dateFloor??null,floor:t.dateFloor??null,references:t.dateReferences??[]}}function li(t){let e=t.floor!=null&&t.highlightedIso!=null&&t.highlightedIso<t.floor?null:t.highlightedIso;return t.pendingStart?Nt(t.pendingStart,e??t.pendingStart):t.selected}function ci(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 ui(t,e,n){return t==null?!1:t<e||n!=null&&t<n}function di(t,e){return t==="date"?e??null:null}var jo="https://magicx.ai/intent-1";function mi(t=jo){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 pi(t,e,n=k()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function fi(t){let e=s=>{s.ctrlKey||Js(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,c=i-a.clientY;n=a.clientX,i=a.clientY,s.cancelable&&!Js(s.target,t,l,c)&&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 Js(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&au(o,i)||n!==0&&lu(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var Zs=/^(auto|scroll|overlay)$/;function au(t,e){return t.scrollHeight<=t.clientHeight||!Zs.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function lu(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!Zs.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 st(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 ea=new WeakMap,ta=new WeakSet;function $(t,e,n){if(ea.set(t,n),ta.has(t))return;ta.add(t);let i=()=>ea.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 xe(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function z(t){t.offsetWidth}var Q="magicx-aia-panel-ghost";function He(t){return t.closest(`.${Q}`)!==null}function B(t,e){for(let n of t.querySelectorAll(e))if(!He(n))return n;return null}var gi="--aia-multi-done-fit";function na(t){return B(t,"[data-aia-multi-done]")}function hi(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(He(s))continue;let a=n.defaultView?.getComputedStyle(s),l=Number.parseFloat(i?a?.paddingRight??"0":a?.paddingLeft??"0")||0,c=n.createTreeWalker(s,NodeFilter.SHOW_TEXT),u=n.createRange();for(let d=c.nextNode();d;d=c.nextNode()){if(!d.textContent?.trim())continue;u.selectNodeContents(d);let f=u.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(gi,`${Math.ceil(r)}px`):e.style.removeProperty(gi)}var ia=40,oa=340,ra=340,sa=7,bi="--aia-option-enter-delay";function yi(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 Si(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 Ti(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function vi(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,s=t.ownerDocument?.visibilityState==="hidden";if(!r||s||Ti(t))return t.scrollTop=o+e,i(),()=>{};let a=!1,l=n.performance?.now?.()??Date.now(),c=()=>n.performance?.now?.()??Date.now(),u=()=>{if(a)return;let d=Math.min(1,(c()-l)/240),f=1-(1-d)*(1-d);t.scrollTop=o+e*f,d<1?r.call(n,u):i()};return r.call(n,u),()=>{a=!0}}var Xo="magicx-aia-scroll-arrow",Ut="data-aia-scroll-arrow",Ne="data-aia-visible",Jo=1e3,Zo=160,er="--aia-scroll-arrow-bottom",la="Scroll down for more options",Yo="data-aia-scrollable",cu="--aia-scroll-track-top",uu="--aia-scroll-track-height",du="--aia-scroll-track-right",mu="--aia-scroll-thumb-top",pu="--aia-scroll-thumb-height",fu=12,gu=.5,hu="[data-aia-products-label]",bu="--aia-option-peek",yu=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;function Su(t){let e=t?.trim()??"";if(!yu.test(e))return 0;let n=Number(e);return Number.isFinite(n)&&n>0?n:0}function Tu(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 aa=4,vu=8;function xu(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 ca(t=document,e=k()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=Xo,n.setAttribute(Ut,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(xu(t)),n}function Eu(t){return Math.max(1,tr(t.style.gridTemplateColumns))}function xi({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,c=v=>{if(v){if(n.hasAttribute(Ne))return;if(n.setAttribute(Ne,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),Ti(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(Ne)&&(n.disabled=!1)},Jo)}else n.removeAttribute(Ne),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},u=v=>{let w=0,S=v;for(;S&&S!==t;)w+=S.offsetTop,S=S.offsetParent instanceof HTMLElement?S.offsetParent:null;return w},d=()=>{let v=B(t,hu),w;if(v){let S=u(v)+v.offsetHeight/2;w=t.clientHeight-S-n.offsetHeight/2}else{let S=u(e),L=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;w=t.clientHeight-(S+e.offsetHeight)+(L>0?0:vu)}n.style.setProperty(er,`${Math.max(0,Math.round(w))}px`)},f=v=>{let w=0,S=v;for(;S&&S!==t;)w+=S.offsetLeft,S=S.offsetParent instanceof HTMLElement?S.offsetParent:null;return w},p=null,m=(v,w)=>{let S=Math.min(1,Math.max(0,e.scrollTop/v));n.style.setProperty(mu,`${Math.round(w*S)}px`)},g=()=>{let v=e.scrollHeight-e.clientHeight,w=e.querySelector("[data-aia-option][data-aia-loading]")!==null;if(v<=aa||w){p=null,n.removeAttribute(Yo);return}let S=e.clientHeight,L=Math.round(S*gu),O=u(e)+(S-L)/2,I=t.clientWidth-(f(e)+e.offsetWidth),j=Math.min(L,Math.max(fu,Math.round(L*S/e.scrollHeight)));p={overflow:v,travel:L-j},n.style.setProperty(cu,`${Math.round(O)}px`),n.style.setProperty(uu,`${L}px`),n.style.setProperty(du,`${Math.max(0,Math.round(I))}px`),n.style.setProperty(pu,`${j}px`),m(v,p.travel),n.setAttribute(Yo,"")},b=()=>{if(o||s!==null||a!==null)return;let v=e.querySelector("[data-aia-option][data-aia-loading]")!==null,w=e.scrollHeight-e.clientHeight-e.scrollTop;c(!v&&w>aa)},T=()=>{if(o)return;d(),g();let v=e.getAttribute("data-aia-group")??"";if(v!==r){r=v,c(!1),s!==null&&clearTimeout(s);let w=e.querySelectorAll("[data-aia-option]").length,S=Ti(e)?0:Si(w,Eu(e));s=setTimeout(()=>{s=null,b()},S);return}b()},y=()=>{o||(p&&m(p.overflow,p.travel),s===null&&(c(!1),a!==null&&clearTimeout(a),a=setTimeout(()=>{a=null,b()},Zo)))};e.addEventListener("scroll",y,{passive:!0});let P=v=>v.preventDefault(),x=()=>{let v=i?i.getComputedStyle(e):null,w=v?(Number.parseFloat(v.paddingTop)||0)+(Number.parseFloat(v.paddingBottom)||0):0,S=Su(v?.getPropertyValue(bu)),L=S>0?Tu(e):0,O=Math.max(1,e.clientHeight-w-S*L);vi(e,O,i,y)};n.addEventListener("mousedown",P),n.addEventListener("click",x);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",y),n.removeEventListener("mousedown",P),n.removeEventListener("click",x),h?.disconnect(),n.removeAttribute(Ne),n.removeAttribute(Yo),n.setAttribute("aria-hidden","true"))}}}var ma="cubic-bezier(0.25, 0.1, 0.25, 1)",wu="cubic-bezier(0.32, 0.72, 0, 1)",rr=360,sr=280,ar=320,lr=40,pa="blur(2px)",Pu=160,Lu=.05,fa=/pressed/i;function ga(){return typeof performance<"u"?performance.now():Date.now()}function Cu(t){for(let e of t.querySelectorAll("[data-aia-loading]"))if(!e.closest(`.${Q}`))return!0;return!1}function Au(t){return t===null?1:1-Math.min(1,Math.max(0,(ga()-t)/Pu))**1.7}function cr(t){return t.hasAttribute(Ut)}function ir(t){let e=0;for(let n of Array.from(t.children))n.classList.contains(Q)||cr(n)||(e+=n.offsetHeight||0);return e}var Z=new WeakMap;function Iu(t){return(Number.parseFloat(t.borderLeftWidth)||0)+(Number.parseFloat(t.borderRightWidth)||0)}function Ou(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 nr=new WeakMap;function Mu(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 ku(t,e){let n=0,i="";for(let o of Array.from(t.children))o.classList.contains(Q)||(n+=1+o.getElementsByTagName("*").length,i+=`${o.textContent??""}\0`);return`${e??""}${n}${i}`}function or(t){return Array.from(t.classList).some(e=>fa.test(e))}function ua(t){return Array.from(t.querySelectorAll("*")).some(e=>or(e)&&!e.closest(`.${Q}`))}function Ru(t,e){let n=Array.from(t.querySelectorAll("*")).filter(r=>or(r)&&!r.closest(`.${Q}`));if(n.length===0)return;let i=Array.from(e.querySelectorAll("*")).filter(or),o=t.ownerDocument.defaultView;i.forEach((r,s)=>{let a=n[s];if(a&&o){let l=o.getComputedStyle(a);r.style.backgroundColor=l.backgroundColor,r.style.color=l.color,r.style.fontWeight=l.fontWeight,r.setAttribute(Ei,"")}for(let l of Array.from(r.parentElement?.children??[]))l!==r&&l instanceof HTMLElement&&(l.style.opacity="0.35",l.setAttribute(Ei,""))})}var Ei="data-aia-press-baked";function wi(t){let e=t?Z.get(t)?.snapshot:null;if(e)for(let n of Array.from(e.querySelectorAll(`[${Ei}]`)))n.style.opacity="",n.style.backgroundColor="",n.style.color="",n.style.fontWeight="",n.removeAttribute(Ei)}function da(t){let e=t.ownerDocument.createElement("div");e.className=Q,e.setAttribute("aria-hidden","true"),e.inert=!0;for(let n of Array.from(t.children))n.classList.contains(Q)||cr(n)||e.appendChild(n.cloneNode(!0));Ru(t,e);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))fa.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 _u(t,e,n,i,o){for(let s of Array.from(t.children))s.classList.contains(Q)&&s.remove();let r=Array.from(t.children).filter(s=>!cr(s));i>Lu&&Hu(t,e,n,i,o);for(let s of r)Du(s),s.animate([{opacity:0,filter:pa},{opacity:1,filter:"blur(0px)"}],{duration:ar,delay:lr,easing:ma,fill:"backwards"})}function Du(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 Hu(t,e,n,i,o){let r=(t.ownerDocument.defaultView??window).getComputedStyle(t);e.style.cssText=["position:absolute","left:0",o>0?`width:${o-Iu(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:pa}],{duration:sr*i,easing:ma,fill:"forwards"}).finished.then(()=>e.remove(),()=>e.remove())}function Pi(t){let e=t[0]?.text;return e==null||e===""?null:e}function $t(t,e,n){let i=n.visible,o=Mu(t,n.enabled??!0),r=Z.get(t);if(!i||!o){o||r?.glide?.cancel(),Z.set(t,{height:0,width:0,key:i?e:null,signature:"",snapshot:null,glide:o?r?.glide??null:null,loadingSince:null,contentHeight:0});return}let s=ku(t,e),a=Cu(t)?r?.loadingSince??ga():null;if(r&&r.height>0&&r.glide&&r.signature===s){r.loadingSince=a,r.snapshot&&ua(t)&&(r.snapshot=da(t));return}let l=ue(t),c=t.getBoundingClientRect(),u=c.height;r?.glide?.cancel();let d=t.getBoundingClientRect(),f=d.height,p=d.width||0,m=null,g=r?l?u:r.height:0,b=r?l?c.width||0:r.width:0;r&&g>0&&(e!==r.key&&r.snapshot&&_u(t,r.snapshot,n.anchorBottom??!1,Au(r.loadingSince),b),m=ha(t,{height:g,width:b},{height:f,width:p}));let T=null;e!==null&&(T=r&&r.signature===s&&r.snapshot&&!r.snapshot.isConnected&&!ua(t)?r.snapshot:da(t)),Z.set(t,{height:f,width:p,key:e,signature:s,snapshot:T,glide:m,loadingSince:a,contentHeight:m?ir(t):0})}function ha(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:rr,easing:wu});i&&(t.setAttribute(Bo,String(n.width)),t.style.setProperty(Uo,`${n.width-Ou(t)}px`),nr.set(t,r));let s=()=>{nr.get(t)===r&&(nr.delete(t),t.removeAttribute(Bo),t.style.removeProperty(Uo))};return r.finished.then(()=>{s();let a=Z.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 ue(t){let e=Z.get(t)?.glide??null;return e&&(e.playState==="running"||e.pending)?e:null}function Li(t){if(!ue(t))return null;let e=Z.get(t)?.height??0;return e>0?e:null}function Ci(t,e){let n=Z.get(t);n&&n.height>0&&!ue(t)&&e>0&&(n.height=e)}function ba(t,{widthChanged:e}){let n=Z.get(t);if(!n||n.height<=0)return;let i=ue(t);if(!i||!e&&(t.hasAttribute("data-aia-fit")||Math.abs(ir(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=ha(t,{height:o.height,width:o.width||0},{height:r.height,width:n.width}),n.contentHeight=n.glide?ir(t):0}function Ai(t){Z.get(t)?.glide?.cancel(),Z.delete(t)}var ur="data-aia-hug",at="--aia-panel-fit-width",dr="data-aia-full-width",Nu=36;function lt(t){t.removeAttribute(ur)}function mr(t,e,{eligible:n,loading:i}){let o=t.style.getPropertyValue(at);Fu(t,e,n,i),ba(t,{widthChanged:t.style.getPropertyValue(at)!==o})}function Fu(t,e,n,i){if(!n){t.style.removeProperty(at),lt(t);return}if(i){t.style.getPropertyValue(at)&&t.setAttribute(ur,"");return}let o=Wu(t,e);if(o==null){t.style.removeProperty(at);return}t.style.setProperty(at,`${o}px`),t.setAttribute(ur,"")}var ya=new WeakMap;function Wu(t,e){if(nt())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=ya.get(t);if(r?.key===o)return r.width;let s=Vu(t,e,n);return ya.set(t,{key:o,width:s}),s}function Vu(t,e,n){let i=tt(n);if(!i||i.rowWidths.some(a=>a<=0))return null;let o=Math.ceil(Math.max(...i.rowWidths)),r=Math.max(1,tr(n.style.gridTemplateColumns)),s=Sa(n,t,r-1)+r*(o+Nu);return Math.ceil(Math.max(s,Bu(e,t)))}function Bu(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:Sa(n,e,i>0&&o>0?1:0)+i+o}function tr(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 Sa(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 Uu="[data-aia-products], [data-aia-datepicker], [data-aia-date-grid], [data-aia-time-wheel], [data-aia-location], [data-aia-see-all]";function Ta(t){let e=!t.hasAttribute("data-aia-has-products")&&!t.hasAttribute(dr)&&B(t,".aia-grid [data-aia-option]")!==null&&B(t,Uu)===null,n=B(t,".aia-grid [data-aia-option][data-aia-loading]")!==null;e||lt(t),mr(t,t,{eligible:e,loading:n})}var va="data-aia-key";function re(t,e,n){let i=new Map;for(let s of Array.from(t.children)){let a=s.getAttribute(va);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 c=i.get(l);c||(c=n.create(a,s),c.setAttribute(va,l)),n.update?.(c,a,s),t.children[s]!==c&&t.insertBefore(c,t.children[s]??null),r.push(c)}for(let[s,a]of i)o.has(s)||a.remove();return r}function xa(t,e){if(!e.interactive)return null;let n=e.options[xe(t)];return n?.is_tappable?n:null}var $u={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=xa(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")&&xa(t,e)&&e.callbacks.onHighlight(xe(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,xe(t))}};function wa(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=Ku(),t.appendChild(l),z(l);for(let d of l.querySelectorAll(".magicx-aia-datepicker-nav"))d.disabled=!1}$(l,$u,{options:e,callbacks:s,interactive:a});let c=l.querySelector(".magicx-aia-datepicker-month");c&&(c.textContent=kn(o));let u=l.querySelector(".magicx-aia-datepicker-grid");u&&qu(u,e,n,i,r)}function qu(t,e,n,i,o){let r=V(new Date),s=li({pendingStart:o.rangeStart,highlightedIso:K(e[n]),selected:o.selectedRange,floor:o.floor});re(t,e,{keyOf:(a,l)=>K(a)??`pad-${l}`,create:a=>Gu(a),update:(a,l,c)=>{let u=K(l),d=ci(u,{selectedIso:o.selectedIso,range:s,references:o.references}),f=c===n&&l.is_tappable;a.id=`${i}-option-${c}`,a.dataset.aiaIndex=String(c),a.setAttribute("aria-selected",String(f)),a.classList.toggle("magicx-aia-date-cell--past",ui(u,r,o.floor)),a.classList.toggle("magicx-aia-date-cell--highlighted",f),a.classList.toggle("magicx-aia-date-cell--today",u!=null&&u===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 Gu(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=Dn(t);if(n==null)return e.className="magicx-aia-date-cell magicx-aia-date-cell--blank",e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e;e.className="magicx-aia-date-cell magicx-aia-date-cell--day",e.tabIndex=0,e.setAttribute("aria-label",t.text);let i=document.createElement("span");return i.className="magicx-aia-date-cell-number",i.textContent=String(n),e.appendChild(i),e}function Ku(){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(Ea("prev","Previous month","\u2039"),n,Ea("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of At){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 Ea(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 zu='<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>',Pa="data-aia-location-body";function Qu(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=zu;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 ju(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 La(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(Pa)!==r){for(let a of Array.from(t.children))a.hasAttribute("data-aia-location-row")||a.remove();let s=ju(r,n);s&&t.appendChild(s),t.setAttribute(Pa,r)}re(t,o,{keyOf:(s,a)=>`${a}:${s.id}`,create:s=>Qu(s),update:(s,a,l)=>{let c=l===e.highlighted;s.classList.toggle("magicx-aia-location-row--highlighted",c),s.setAttribute("aria-selected",String(c)),s.setAttribute("data-aia-index",String(l)),s.id=i(l)}})}var de=new WeakMap,Yu=0,Fe=new WeakMap,Xu='<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>',We=t=>Ke(t.input)===t.input;function Ca(t,e){let n=Ke(t);if(n instanceof HTMLElement&&n!==e.input&&n!==F(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=Oe(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Ju(t,e,n){if(!(!(n instanceof HTMLElement)||n===e.returnTo||t.contains(n))&&n!==F(t).body&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=Oe(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Zu(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=Ie(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=F(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var ed={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&ct(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function ct(t,e=!1){let n=Fe.get(t),i=de.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&We(n)&&(n.returning=!0,Zu(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function td(t){let e=Fe.get(t),n=de.get(t);if(!(!e||!n||We(e))){if(Ca(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!We(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function nd(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++Yu}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=Xu;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(),Ca(t,r),de.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>de.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",s=>{Ju(t,r,s.relatedTarget),de.get(t)?.callbacks.onLocationFocusChange(!0)}),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,de.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",s=>{let a=de.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;ct(t,!0),a.callbacks.onLocationCommit();return;case"Escape":s.preventDefault(),s.stopPropagation(),r.declined=!0,ct(t);return;case"Backspace":if(i.value!=="")return;s.preventDefault(),r.declined=!0,ct(t);return}}),Fe.set(t,r),r}function Aa(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=Fe.get(e);n&&(We(n)&&ct(e),n.declined=!1,n.input.tabIndex=-1)}}function Ia(t,e,n,i,o={}){let r=Array.from(t.children).find(l=>l.hasAttribute("data-aia-location"))??null;if(!e){if(r){let l=Fe.get(r);l&&We(l)&&ct(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let s=Fe.get(r)??nd(r,n);s.input.tabIndex=0,de.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),$(s.results,ed,de.get(r)),s.input.value!==e.query&&!We(s)&&(s.input.value=e.query);let a=l=>`${r?.id}-row-${l}`;if(La(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&&!We(s)){let l=r;queueMicrotask(()=>{l.isConnected&&!Fe.get(l)?.declined&&td(l)})}}else{let l=s;setTimeout(()=>{if(l.widgetFocused)return;let c=l.returnTo;c&&Ke(c)===c||(l.declined=!1)},0)}}var id={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},Oa=[125,69];function Ma(t,e){return e?1:t===0?.7:t===1?.4:.2}function Ii(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,id,{onSelectPill:i,loading:r}),r&&e.length===0){a.setAttribute("data-aia-pill-list-loading",""),a.innerHTML="";for(let l=0;l<Oa.length;l++){let c=Oa[l],u=document.createElement("span");u.setAttribute("data-aia-pill-skeleton",""),u.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,u.style.width=`${c}px`,u.style.setProperty("--aia-pill-opacity",String(Ma(l,!1))),a.appendChild(u)}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();re(a,e,{keyOf:l=>`${l.type?.kind??""}|${Ce(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let c=document.createElement("button");if(c.type="button",c.tabIndex=-1,c.setAttribute("data-aia-pill",""),c.setAttribute("contenteditable","false"),Ce(l)){c.setAttribute("data-aia-smart-suggestion",C(l)?"header":"");let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-text",u.textContent=l.text;let d=document.createElement("span");d.className="magicx-aia-smart-suggestion-sparkle",d.innerHTML=gn,c.append(u,d)}else c.textContent=l.text;return c.disabled=!0,c},update:(l,c,u)=>{let d=l,f=s&&u===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(Ma(u,f))),d.dataset.aiaPillIndex=String(u),d.toggleAttribute("data-aia-pill-active",u===n),r?d.setAttribute("data-aia-loading",""):d.removeAttribute("data-aia-loading")}}),z(a);for(let l of a.querySelectorAll("[data-aia-pill]"))l.disabled=r}function pr(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var ka=32;function fr(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 Oi(t){let e=n=>{let i=fr(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var Ra=Intl.Segmenter,_a=Ra?new Ra(void 0,{granularity:"grapheme"}):null;function Mi(t){let e=t.trim().normalize("NFC").toUpperCase();if(_a)for(let n of _a.segment(e))return n.segment;return Array.from(e)[0]??"?"}var ki=120,Da=360;function od(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 gr(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=od(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 hr(t,e){let n=gr(t,e);return n===t?[t]:[n,t]}function Ri(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 qt(t){let e=t?.trim();return e?hr(e,360):[]}function Ha(t){return qt(t)[0]}var _i=new WeakMap,yr=new WeakMap,Fa=new WeakMap;function Wa(t,e,n,i,o,r="row",s="image",a=k(),l,c=!0,u=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",""),Oi(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){re(p,e,{keyOf:m=>cd(m,!!l),create:m=>ud(m,i,o,s,a,l),update:(m,g,b)=>{_i.set(m,g),rd(m,c?g.vendor:void 0),sd(m,g.price,g.compareAtPrice),m.id=`${n}-product-${b}`,m.dataset.aiaIndex=String(b),Fa.get(m)?.(s),st(m,"data-aia-product-state",g.id===u);let T=m.querySelector(".magicx-aia-product-badge");T&&T.textContent!==a.soldOut&&(T.textContent=a.soldOut);let y=m.querySelector(".magicx-aia-product-cart");y&&y.setAttribute("aria-label",Va(g,a))}}),z(p);for(let m of p.querySelectorAll("[data-aia-product]")){let g=yr.get(m);g&&(yr.delete(m),g())}}}function Sr(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)He(i)||(i.tabIndex=e?0:-1)}function rd(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 sd(t,e,n){let i=t.querySelector(".magicx-aia-product-price");if(!e){i?.remove();return}i||(i=document.createElement("span"),i.className="magicx-aia-product-price",i.append(document.createTextNode("")),t.querySelector(".magicx-aia-product-title")?.after(i));let o=i.firstChild;o.data!==e&&(o.data=e);let r=i.querySelector(".magicx-aia-product-compare-at");if(!n){r?.remove();return}r||(r=document.createElement("s"),r.className="magicx-aia-product-compare-at",i.append(r)),r.textContent!==n&&(r.textContent=n)}function Na(t,e){e?(t.style.setProperty("--aia-product-photo-fill-x",String(e.x)),t.style.setProperty("--aia-product-photo-fill-y",String(e.y))):(t.style.removeProperty("--aia-product-photo-fill-x"),t.style.removeProperty("--aia-product-photo-fill-y"))}function Va(t,e){return`${e.addToCart}: ${t.title}`}var br="http://www.w3.org/2000/svg";function ad(){let t=document.createElementNS(br,"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(br,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(br,"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 ld(t,e,n,i,o){let r=document.createElement("span");r.className="magicx-aia-product-cart",r.setAttribute("data-aia-product-cart",""),r.setAttribute("role","button"),r.setAttribute("aria-label",Va(e,o)),r.tabIndex=0,r.appendChild(ad());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(_i.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 cd(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 ud(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=qt(t.imageUrl),c=l[0],u=!!c,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=Mi(t.title))};if(Fa.set(s,g=>{g!==i&&(i=g,u||d())}),c){let g=document.createElement("img"),b=0;g.onload=()=>{a.setAttribute("data-aia-image-loaded",""),Na(s,Ri(g.naturalWidth,g.naturalHeight))},g.onerror=()=>{let T=l[++b];if(T){g.src=T;return}u=!1,Na(s,null),d()},g.className="magicx-aia-product-image",g.src=c,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?ld(s,t,r,n,o):null;return m&&(s.setAttribute("data-aia-product-has-cart",""),s.appendChild(m.el)),yr.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(_i.get(s)??t))})}),s.addEventListener("keydown",g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),e(_i.get(s)??t))}),s.addEventListener("focus",()=>n(!0)),s.addEventListener("blur",g=>{g.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),s}var Ba=10,Ua=44;function Di(t,e,n){if(!e||n.detail===0)return!0;let i=t.getBoundingClientRect(),o=e.getBoundingClientRect();if(t.ownerDocument.defaultView?.getComputedStyle(t).direction==="rtl"){let 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 me="data-aia-fit",Gt="--aia-dropdown-fit-height",$a=8,dd=160;function Hi({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,s=null,a=null,l=null,c=!1,u=()=>{t.removeAttribute(me),t.style.removeProperty(Gt)},d=()=>{if(ue(t)){c=!0;return}c=!1,Ci(t,t.getBoundingClientRect().height)},f=y=>`${r}|${(y??t).scrollHeight}|${t.offsetWidth}`,p=y=>a?.key===f(y)?a.height:null,m=y=>{let P=f(y);if(a?.key===P)return a.height;let x=y?.scrollTop??0;t.removeAttribute(me);let h=t.offsetHeight;return t.setAttribute(me,""),y&&x&&(y.scrollTop=x),a={key:P,height:h},h},g=()=>{if(i)return;if(!e()){o=!1;return}let y=ue(t),P=y?Li(t):null;y&&l!==y&&(l=y,y.finished.then(b,b)),!y&&c&&d(),o||(o=!0,u());let x=t.hasAttribute(me),h=B(t,".aia-grid")?.getAttribute("data-aia-group")??null,v=h!==r;r=h;let w=pd(t,n);if(w===null)return;let S=md(t);if(x){let I=y?p(S):m(S);if(I!==null&&I<=w){u(),d();return}}else if((P??t.offsetHeight)<=w)return;let L=`${Math.max(dd,Math.floor(w))}px`,O=t.style.getPropertyValue(Gt)!==L;O&&t.style.setProperty(Gt,L),x?v&&S&&(S.scrollTop=0):t.setAttribute(me,""),(O||!x)&&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 md(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function pd(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-$a:i+o-a-$a}var Ni=.5;function fd(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-Ni||e.height>i+Ni?s=Math.floor(e.top-t.coverTop):r>o+i+Ni&&(s=Math.ceil(r-t.coverTop-i)),Math.min(n,Math.max(0,s))}var qa=new WeakMap;function Ga(t){let e=qa.get(t);if(e)return e;let n={shown:-1,byPointer:-1,held:!1,x:null,y:null,cancel:null};qa.set(t,n);let i=o=>Ka(n,o);for(let o of["mouseover","mouseout","mousemove"])t.addEventListener(o,i,{capture:!0,passive:!0});return n}function Ka(t,e){e.screenX===t.x&&e.screenY===t.y||(t.held=!1,t.x=e.screenX,t.y=e.screenY)}function Kt(t,e,n){if(!t)return!0;let i=Ga(t);return Ka(i,n),i.held?!1:(i.byPointer=e,!0)}function gd(t){if(t.scrollHeight-t.clientHeight>1)return t;let e=t.closest(".aia-stack");return e?.parentElement?.hasAttribute(me)&&e.scrollHeight-e.clientHeight>1?e:null}function hd(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 Fi(t,e){let n=Ga(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=gd(t),s=r?hd(r,o):null;if(!r||!s)return;let a=fd(s.box,s.row);Math.abs(a-r.scrollTop)<Ni||(n.held=!0,n.cancel=vi(r,a-r.scrollTop,r.ownerDocument.defaultView,()=>{n.cancel=null}))}var za="http://www.w3.org/2000/svg",bd=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function yd(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 Sd=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],Td=/^[a-zA-Z0-9#.,%\s()-]+$/;function vd(t){let e=[];for(let n of Sd){let i=t.getAttribute(n);i===null||!Td.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function Qa(t){for(let e of Array.from(t.attributes))yd(e.name,e.value)&&t.removeAttribute(e.name);vd(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!bd.has(n.localName)||n.namespaceURI!==za?n.remove():Qa(n)}else e.remove()}function se(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!==za||e.getElementsByTagName("parsererror").length>0?null:(Qa(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function zt(t){return t.text}function Ee(t){return ut(t)[0]??null}function ut(t){let e=xd(t);return e?hr(e,120):[]}function xd(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 dt(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var Tr={one:"item",other:"items"};function ja(t,e=Tr){let n=dt(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function vr(t){return Ee(t.image_url)!==null}var Wi=new Map;function Ed(t){let e=t.icon_svg;if(!e)return!1;let n=Wi.get(e);return n===void 0&&(n=se(e)!==null,Wi.size>=256&&Wi.clear(),Wi.set(e,n)),n}function Vi(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&vr(i)||e&&Ed(i))}var Ya=new WeakMap;function wd(t,e,n){let i=e.length,o=nt(),r=Ya.get(t),s=n&&r&&ti(r.options,e)?r.plan:null,a=!s&&!n&&Zn(i,o)?tt(t):null,l=s??ei(i,o,a?.rowWidths??null,a?.gridWidth??null);return n||Ya.set(t,{options:e,plan:l}),t.style.gridTemplateColumns=l.template,t.style.setProperty("--aia-grid-max-height",l.maxHeight),t.querySelectorAll("[data-aia-option]").forEach((c,u)=>{c.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(u))}),l.cols}function Xa(t,e){if(e.loading||!e.interactive)return null;let n=e.options[xe(t)];return n?.is_tappable?n:null}var Pd=2e3,Qt=new WeakMap;function Ld(t,e){t.classList.add("magicx-aia-option--pressed");let n=t.closest(".aia-grid");if(!n)return;let i=`${Date.now()}:${e}`;n.dataset.aiaPress=e,n.dataset.aiaPressToken=i,clearTimeout(Qt.get(n)),Qt.set(n,setTimeout(()=>{Qt.delete(n),n.dataset.aiaPressToken===i&&Ja(n,!0)},Pd))}function Ja(t,e=!1){clearTimeout(Qt.get(t)),Qt.delete(t),delete t.dataset.aiaPress,delete t.dataset.aiaPressToken;for(let n of t.querySelectorAll(".magicx-aia-option--pressed"))n.classList.remove("magicx-aia-option--pressed");e&&wi(t.closest("[data-aia-dropdown]"))}var Cd={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=Xa(t,e);if(!i)return;let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!Di(t,o,n);if((!o||r)&&Ld(t,i.text),o){let s=r||t.getAttribute("aria-selected")!=="true";t.setAttribute("aria-selected",String(s)),o.dataset.checked=String(s)}r?e.onSelect(i,{commit:!0}):e.onSelect(i)},onEnter:(t,e,n)=>{if(!Xa(t,e))return;let i=xe(t);Kt(t.closest(".aia-grid"),i,n)&&e.onHighlight(i)},onLeave:(t,e,n)=>{Kt(t.closest(".aia-grid"),-1,n)&&e.onHighlight(-1,xe(t))}};function Za(t,e,n,i,o,r,s,a="",l="below",c=!0,u=!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,Cd,{options:e,onSelect:i,onHighlight:o,loading:s,interactive:f});let g=m.dataset.aiaGroup!==a;m.dataset.aiaGroup=a,g&&Ja(m);let b=Vi(e,c,u);Ad(m,e,n,r,s,{showIcons:c&&b,showImages:u&&b,showCounts:d,picked:p});let T=wd(m,e,s);Id(m,e.length,T,s,l),g&&(m.scrollTop=0),Fi(m,s?-1:n)}function Ad(t,e,n,i,o,r){let s=o?"1":"0",a=t.dataset.aiaGroup??"",{showIcons:l,showImages:c,showCounts:u}=r,d=l?m=>m.icon??m.icon_svg??"":()=>"",f=c?m=>`${Ee(m.image_url)??""}${(m.imageCollage??[]).join("")}`:()=>"",p=u?m=>dt(m.item_count)??"":()=>"";re(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=Od(m,o,r);return t.dataset.aiaPress===m.text&&b.classList.add("magicx-aia-option--pressed"),o||(b.dataset.aiaEntering=""),b},update:(m,g,b)=>{if(xr.get(m)!==(g.matchedText??"")){let P=m.querySelector(".magicx-aia-option-text");P&&el(P,g),xr.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 y=m.querySelector(".magicx-aia-checkbox");r.picked&&g.is_tappable?(y||(y=document.createElement("span"),y.className="magicx-aia-checkbox",y.setAttribute("aria-hidden","true"),m.querySelector(".magicx-aia-option-content")?.prepend(y)),y.dataset.checked=String(r.picked.includes(g.text))):y?.remove(),m.classList.toggle("magicx-aia-option--highlighted",T),m.classList.toggle("magicx-aia-option--live-match",!!g.liveMatch&&!o)}})}function Id(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(bi,`${yi(s,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var xr=new WeakMap;function el(t,e){if(t.replaceChildren(),e.matchedText)for(let n of oi(zt(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(zt(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 Od(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?ut(t.image_url):[],c=l[0];if(c){let p=document.createElement("span");p.className="magicx-aia-option-image",p.setAttribute("aria-hidden","true");let m=(t.imageCollage??[]).map(g=>ut(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 y=g[++T];y?b.src=y:b.hidden=!0},b.src=g[0],p.appendChild(b)}a.appendChild(p),r.dataset.aiaImage=""}let u=!c&&n&&t.icon_svg?se(t.icon_svg):null;if(u){let p=document.createElement("span");p.className="magicx-aia-option-icon",p.setAttribute("aria-hidden","true"),p.innerHTML=u,a.appendChild(p),t.icon&&(r.dataset.aiaIcon=t.icon)}let d=document.createElement("span");if(d.className="magicx-aia-option-text",el(d,t),xr.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?dt(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 Md=120,kd={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(_t(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},nl=new WeakMap,tl=new WeakMap;function il(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),z(r);let c=r.querySelector("[data-aia-time-done]");c&&(c.disabled=!1)}let s={view:e,callbacks:i,interactive:o};nl.set(r,s),$(r,kd,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=Ot(e.minutes));for(let c of kt){let u=r.querySelector(`[data-aia-time-column="${c}"]`);u&&Rd(u,c,e.minutes)}}function Rd(t,e,n){let i=Rt(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=Bi(t);if(o.settle)return;let r=i*Mt;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function Bi(t){let e=tl.get(t);return e||(e={syncedTop:null,settle:null},tl.set(t,e)),e}function _d(t,e,n){let i=Bi(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(()=>ol(t,e,n),Md)}function ol(t,e,n){let i=Bi(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=nl.get(t);if(!o||!o.interactive)return;let r=Bn(n,e.scrollTop);r!==Rt(n,o.view.minutes)&&o.callbacks.onTimeChange(_t(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 kt){if(r==="minute"){let s=document.createElement("span");s.className="magicx-aia-time-wheel-separator",s.textContent=":",n.appendChild(s)}n.appendChild(Hd(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 Hd(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),Vn(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",()=>{Bi(n).settle&&ol(t,n,e)}),n}var Nd=[159,119,164];function qi(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()),fi(e),e}var Ui=new WeakMap;function Fd(t,e,n){let i=Ui.get(t);if(i||(i={button:ca(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),Ui.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=xi({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var $i=new WeakMap;function rl(t){let e=$i.get(t);if(e){e.update();return}$i.set(t,Hi({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function Er(t){$i.get(t)?.destroy(),$i.delete(t),Ai(t);let e=Ui.get(t);e&&(e.controller?.destroy(),Ui.delete(t))}function Gi(t,e){let n=e.strings??k(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:s,showPills:a,isActivePillSelected:l,onSelect:c,onHighlight:u,onPillClick:d,onSkip:f}=e,p=fn(e.pills,n.keepTyping),m=hn(p),g=a&&p.length>0,b=i.length>0,T=e.products.length>0,y=e.formatType==="time"&&e.timeView!=null,P=e.formatType==="location"&&e.locationView!=null,x=r&&(b||g||s||T||y||P);if(x?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"),!x){Sr(t,!1),Aa(t),rl(t),$t(t,null,{visible:!1});return}T?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute(dr,e.fullWidth===!0),lt(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 v=e.showSkipButton&&m&&!e.isInputEmpty,w=g||s&&a||v,S=h.querySelector(".magicx-aia-pill-bar");if(w){S||(S=document.createElement("div"),S.className="magicx-aia-pill-bar aia-cluster",S.setAttribute("data-nowrap",""),S.setAttribute("data-aia-pillbar",""),h.insertBefore(S,h.firstChild));let pe=g||s&&a,A=S.querySelector(".magicx-aia-pill-scroll");pe?(A||(A=document.createElement("span"),A.className="magicx-aia-pill-scroll",A.setAttribute("data-aia-pill-scroll",""),S.insertBefore(A,S.firstChild)),Ii(A,p,0,d,!0,s,l)):A&&A.remove(),Bd(S,v,s||e.skipDisabled,p[0],f,n)}else S&&S.remove();let L=e.suggestions[0],O=L?`${L.parameter} ${L.text}`:"",I=_(e.formatType),j=I&&!s;Za(h,I?[]:i,o,c,u,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)),zd(h,!!e.multiSelectView,e.skipDisabled||s,e.onMultiSelectCommit,n.done),Fd(t,h.querySelector(".aia-grid"),n),wa(h,j?i:[],o,e.listboxId,j?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart,floor:di(e.formatType,e.dateRangeStart),references:e.dateReferences??[]},{onSelect:c,onHighlight:u,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),il(h,e.formatType==="time"&&!s?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),Ia(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 R=h.querySelector(".magicx-aia-skeleton-bars");if(s&&(!b||N(e.formatType))){if(!R){R=document.createElement("div"),R.className="magicx-aia-skeleton-bars",R.setAttribute("data-aia-skeleton-bars","");for(let pe of Nd){let A=document.createElement("span");A.className="magicx-aia-skeleton-bar",A.style.width=`${pe}px`,R.appendChild(A)}h.appendChild(R)}}else R&&R.remove();Wa(h,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart,e.showProductVendor??!0,e.busyProductId??null),Sr(t,!s),Gd(h,e.onSeeAllResults,n.seeAllResults,e.seeAllBusy===!0);let Y=h.querySelector(".magicx-aia-footer")??$d(n),ee=o>=0&&!!i[o]?.is_tappable;Ud(Y,pi(ee,e.isInputEmpty,n)),Y.isConnected||h.appendChild(Y),Wd(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"]),hi(h,h.querySelector(".magicx-aia-multi-done")),mr(t,h,{eligible:b&&!T&&!I&&!y&&!P&&!e.onSeeAllResults&&!e.fullWidth,loading:s}),rl(t),$t(t,Pi(a?p:[]),{visible:!0,anchorBottom:e.optionsPosition==="above"})}function Wd(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 Vd={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function Bd(t,e,n,i,o,r){$(t,Vd,{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),z(s)),s.textContent!==r.skip&&(s.textContent=r.skip),s.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),s.disabled=n}function Ud(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 $d(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=mi(),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="Powered by Intent-1";let l=document.createElement("span");return l.className="magicx-aia-footer-badge",l.append(a),s.append(l),n.append(i,s),e.append(n),e}var qd={itemSelector:".magicx-aia-see-all",onClick:(t,e,n)=>{e.submit&&(n.stopPropagation(),e.submit())}};function Gd(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),z(s)}$(o,qd,{submit:e});let r=o.querySelector("button");r&&(r.textContent!==n&&(r.textContent=n),r.disabled=!1,st(r,"data-aia-see-all-state",i))}var Kd={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function zd(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),z(a)}$(r,Kd,{commit:i,disabled:n});let s=r.querySelector("button");s&&(s.textContent=o,s.disabled=n)}function mt(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 sl(t,e){let n=qi(e.listboxId);return t.appendChild(n),{dropdown:n}}function wr(t,e,n){let i=rt(e);Gi(t.dropdown,{strings:n.strings,suggestions:e.editingIdentified?[{parameter:e.editingIdentified.parameter,text:ie(e.editingIdentified.parameter),required:!0,options:e.filteredOptions}]:e.dropdownSuggestion??e.actionableSuggestions[0]?[{...e.dropdownSuggestion??e.actionableSuggestions[0],options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:mt(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,highlightByPointer:o>=0})},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 Qd="[data-aia-chip-remove]";function Pr(t,e){let n=e;if(!n||n.nodeType===void 0)return null;let o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(Qd)??null;return o&&t.contains(o)?o:null}function Ki(t,e){let n=null,i=c=>{n=null;let u=c;if(u.button)return;let d=Pr(t,c.target);if(!d)return;c.preventDefault(),c.stopPropagation();let f=d.dataset.aiaChipRemove,p=u.pointerType==="touch"||u.pointerType==="pen";n={id:f,x:u.clientX,y:u.clientY,pending:p},!p&&f&&e(f)},o=c=>{if(!n?.pending)return;n.pending=!1;let u=c;if(Math.hypot(u.clientX-n.x,u.clientY-n.y)>10)return;let f=t.getRootNode().elementFromPoint?.(u.clientX,u.clientY)??c.target,p=Pr(t,f)?.dataset.aiaChipRemove;p&&p===n.id&&e(p)},r=()=>{n&&(n.pending=!1)},s=c=>{!n&&!Pr(t,c.target)||(c.cancelable&&c.preventDefault(),c.type==="click"&&(c.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 al=340;function zi(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let u=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let d=t.getBoundingClientRect().height;if(d!==0){if(u===0||Math.abs(d-u)<.5){t.style.height=`${d}px`;return}t.style.height=`${u}px`,t.getBoundingClientRect(),t.style.height=`${d}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(u=>{for(let f of u)if(f.target!==t){n();return}let d=t.getBoundingClientRect().width;Math.abs(d-i)<.5||(i=d,n())}):null,r=()=>{for(let u of Array.from(t.children))o?.observe(u)},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 c=!1;return t.ownerDocument.fonts?.ready.then(()=>{c||n()}),n(),()=>{c=!0,t.removeEventListener("load",a,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(s),t.style.height=""}}var Ir=2600,jd=3,Xi="data-aia-hint",Ar="magicx-aia-hint",Or="data-aia-hint-el",Yd={position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--aia-hint-color, #999)",userSelect:"none"},Xd=280,Jd=320,Zd=380,Lr="cubic-bezier(0.25, 0.1, 0.25, 1)",ll=new Set(["a","an","the","some","my"]),Yi=new WeakMap;function em(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function cl(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&&ll.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,[c,...u]=n.split(/\s+/);u.length&&c&&ll.has(c.toLowerCase())&&(l=c,n=u.join(" "));let d=l??s;d&&o.push({key:`w:${d.toLowerCase()}`,text:d,icon:null});let f=t.icon_svg?se(t.icon_svg):null;return o.push({key:`c:${f??""}:${n}`,text:n,icon:f}),o}function tm(t,e){let n=t.createElement("span");if(n.className=`${Ar}__word`,n.dataset.key=e.key,n.style.display="inline-block",e.icon){let i=t.createElement("span");i.className=`${Ar}__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 Cr(t,e,n){return typeof t.animate=="function"?t.animate(e,n):null}function Qi(t,e){let n=t.ownerDocument?.defaultView;if(!n)return;let i=n.getComputedStyle(t),o=u=>Number.parseFloat(u)||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,c=Math.max(a,l);e.style.left=`${r}px`,e.style.top=`${s}px`,c>0&&(e.style.maxWidth=`${c}px`),e.style.font=i.font,e.style.lineHeight=i.lineHeight,e.style.letterSpacing=i.letterSpacing,e.style.fontWeight="var(--aia-hint-font-weight, 300)"}function ul(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=Cr(m,[{opacity:1,filter:"blur(0)"},{opacity:0,filter:"blur(2px)"}],{duration:Xd,easing:Lr,fill:"forwards"});g?g.onfinish=()=>m.remove():m.remove()}let c=Array.from(o.children).filter(p=>p.dataset.leaving!==void 0),u=[];if(e.forEach((p,m)=>{m>0&&u.push(r.createTextNode(" ")),u.push(s.get(p.key)??tm(r,p))}),o.replaceChildren(...u,...c),!n)return;let d=new Map;for(let p of u)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))Cr(m,[{opacity:0,filter:"blur(2px)"},{opacity:1,filter:"blur(0)"}],{duration:Jd,delay:i?80*f++:180+60*f++,easing:Lr,fill:"backwards"});else{let b=(a.get(p.key)??m.offsetLeft)-m.offsetLeft;Math.abs(b)>.5&&Cr(m,[{transform:`translateX(${b}px)`},{transform:"none"}],{duration:Zd,easing:Lr})}}}function ji(t){let e=Yi.get(t);e&&(e.timer!==null&&clearInterval(e.timer),e.resize?.disconnect(),e.el.remove(),Yi.delete(t),t.removeAttribute(Xi),t.removeAttribute("aria-placeholder"))}function dl(t,e,n,i){let o=i.filter(m=>m.text.trim()!=="").slice(0,jd),r=t.parentElement;if(!e||o.length<2||!r){ji(t);return}let s=`${n}\0${o.map(m=>`${m.text}${m.icon_svg??""}`).join("\0")}`,a=Yi.get(t);if(a&&a.key===s&&a.el.isConnected){Qi(t,a.el);return}ji(t);let l=t.ownerDocument,c=l.createElement("span");c.className=Ar,c.setAttribute(Or,""),c.setAttribute("aria-hidden","true"),Object.assign(c.style,Yd),r.insertBefore(c,t),t.setAttribute(Xi,""),n.trim()&&t.setAttribute("aria-placeholder",n.trim()),Qi(t,c);let u=l.defaultView,d=u?.ResizeObserver?new u.ResizeObserver(()=>{c.isConnected&&Qi(t,c)}):null;d?.observe(r);let f=em(t),p={key:s,lead:n,options:o,index:0,el:c,timer:null,resize:d};Yi.set(t,p),ul(p,cl(o[0],n),!f,!0),!f&&(p.timer=setInterval(()=>{if(!t.isConnected||!c.isConnected){ji(t);return}t.ownerDocument?.hidden||(p.index=(p.index+1)%p.options.length,Qi(t,c),ul(p,cl(p.options[p.index],p.lead),!0,!1))},Ir))}function Ji(t){ji(t)}function Zi(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 nm=6,im=.3;function ml(t){return t<=0?"0px":`${(-Math.min(im,2*nm/t)).toFixed(3)}px`}var pl=new Map;function om(t,e,n){let i=pl.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`;pl.set(e,a),t.style.setProperty("--aia-chip-image-fit",a)},o.src=e}function eo(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,c=n.length===0;e.dataset.aiaEmpty=c?"true":"false",Ys(e,c?r:""),dl(e,c,r,t.hintOptions??[]);let u=n.map(x=>x.type==="completed"?`${x.type}:${x.value}${s?x.param.icon??x.param.icon_svg??"":""}${a?Ee(x.param.image_url)??"":""}${l?"x":""}`:x.type==="identified"?`${x.type}:${x.value}${x.param.id}${l?"x":""}`:`${x.type}:${x.value}`).join("\0"),d=e.dataset.segKey??"",f=e.dataset.newParamId??"",p=e.dataset.editingParamId??"";if(u===d&&(i??"")===f&&(o??"")===p)return;if(u===d){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let x of e.querySelectorAll("strong[data-param-id]")){let h=x.dataset.paramId,v=x.dataset.seg==="completed"&&h===i;x.classList.toggle("magicx-aia-shimmer-revealed",v),x.classList.toggle("magicx-aia-shimmer-sweep",v),x.classList.toggle("magicx-aia-segment--editing",h===o)}return}let m=e.getAttribute("data-aia-composing")==="true"?rm(e,n):null;if(m==="unsafe")return;let g=Ss(e),b=g&&!m?G(e):null;e.dataset.segKey=u,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let T=F(e),y=T.createDocumentFragment(),P=0;for(let x of n)if(P+=x.value.length,x.type==="completed"){let h=T.createElement("strong");h.dataset.seg="completed",h.dataset.paramId=x.param.id;let v=x.param.id===i,w=x.param.id===o,S=["magicx-aia-segment","magicx-aia-segment--completed"];v&&S.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),w&&S.push("magicx-aia-segment--editing"),h.className=S.join(" "),h.style.letterSpacing=ml(x.value.length);let L=a?Ee(x.param.image_url):null;if(L){let I=T.createElement("span");I.className="magicx-aia-segment-image",I.setAttribute("contenteditable","false"),I.setAttribute("aria-hidden","true"),I.style.setProperty("--aia-chip-image",`url("${L}")`),om(I,L,T),h.appendChild(I),h.dataset.aiaImage=""}let O=!L&&s&&x.param.icon_svg?se(x.param.icon_svg):null;if(O){let I=T.createElement("span");I.className="magicx-aia-segment-icon",I.setAttribute("contenteditable","false"),I.setAttribute("aria-hidden","true"),I.innerHTML=O,h.appendChild(I),x.param.icon&&(h.dataset.aiaIcon=x.param.icon)}h.appendChild(T.createTextNode(x.value)),l&&h.appendChild(fl(T,x.param.id)),y.appendChild(h)}else if(x.type==="identified"){let h=T.createElement("strong");h.dataset.seg="identified",h.dataset.paramId=x.param.id;let v=["magicx-aia-segment","magicx-aia-segment--completed"];x.param.id===o&&v.push("magicx-aia-segment--editing"),h.className=v.join(" "),h.style.letterSpacing=ml(x.value.length),h.textContent=x.value,l&&h.appendChild(fl(T,x.param.id)),y.appendChild(h)}else y.appendChild(T.createTextNode(x.value));if(m){m.node.deleteData(0,m.node.data.length-m.syllable.length);for(let x of Array.from(e.childNodes))x!==m.node&&x.remove();e.insertBefore(y,m.node),e.dataset.aiaTextLength=String(P+m.syllable.length);return}e.replaceChildren(y),e.dataset.aiaTextLength=String(P),b!=null?W(e,Math.max(0,Math.min(b,P))):g&&W(e,P)}function rm(t,e){let n=e.map(s=>s.value).join(""),i=Me(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 fl(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 sm='<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 gl(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=sm.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function hl(t){let e=t.store.get();return(!!e.text||e.completedParams.length>0)&&!!t.onSubmit}function am(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function bl(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 yl(t,e){let{listboxId:n}=e,i=qi(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",am()?"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,c=null;e.submitButton===void 0?(l=gl(e.strings),o.appendChild(l),c=l):e.submitButton!==null&&(c=e.submitButton,c.hasAttribute("data-aia-submit")||c.setAttribute("data-aia-submit",""),c.setAttribute("data-aia-submit-slot",""),o.appendChild(c));let u=new AbortController,{signal:d}=u,f=!1,p=0,m=()=>{let h=Me(s);return h.length>0&&h[0]!==h[0].toUpperCase()?h[0].toUpperCase()+h.slice(1):h},g=()=>e.handleChange(m()),b=()=>{let h=J(s)?.node??null;if(!h||!s.contains(h))return null;let S=(h.nodeType===Node.ELEMENT_NODE?h:h.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return S&&ys(s,S)?null:S};o.addEventListener("click",h=>{h.target?.closest("[data-aia-pill]")||s.getRootNode().activeElement?.closest("[data-aia-location]")||In(s)},{signal:d});let T=null,y=()=>{let h=e.showChipRemove??!1;h!==(T!==null)&&(T?.(),T=h?Ki(s,v=>e.removeParam(v)):null)};if(y(),d.addEventListener("abort",()=>{T?.(),T=null}),s.addEventListener("input",()=>{if(f){e.handleCompositionText(m());return}p=performance.now(),g(),e.handleCaretAfterInput(G(s))},{signal:d}),F(s).addEventListener("selectionchange",()=>{let h=J(s);if(!h||!s.contains(h.node))return;let v=h.collapsed?b():null,w=e.store.get(),S=w.editingParam?.id??w.editingIdentified?.id??null;if(v&&v!==S){e.startEditingParam(v);return}performance.now()-p<50||e.handleCaretMove(G(s))},{signal:d}),s.addEventListener("click",h=>{let v=Pn(s,h.target);v&&(e.startEditingParam(v),Ln(s,v))},{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 v=h,w=v.inputType;if(w==="insertParagraph"||w==="insertLineBreak"||w==="insertFromDrop"){h.preventDefault();return}if(w.startsWith("insert")||w.startsWith("delete")){let S=w.startsWith("delete")?"":v.data??"";e.replaceEditingRange(S)&&h.preventDefault()}},{signal:d}),s.addEventListener("paste",h=>{h.preventDefault();let v=(h.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!v)return;let w=F(s),S=Oe(s);if(!S||!s.contains(S.startContainer))return;S.deleteContents();let L=w.createTextNode(v);S.insertNode(L),S.setStartAfter(L),Ct(s,S.startContainer,S.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}),c&&c.addEventListener("click",h=>{hl(e)&&(h.stopPropagation(),e.submit?.())},{signal:d}),e.autoFocus!==!1){s.focus();let h=J(s);(!h||!s.contains(h.node))&&Ct(s,s,0)}if(typeof ResizeObserver<"u"){let h=new ResizeObserver(()=>bl(s,a));h.observe(s),u.signal.addEventListener("abort",()=>h.disconnect(),{once:!0})}let x=zi(r);return u.signal.addEventListener("abort",x,{once:!0}),{input:s,inlinePillContainer:a,dropdown:i,submitButton:l,submitTarget:c,abort:u,syncChipRemove:y}}function Mr(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:s}=t,{pillPlacement:a,setActivePill:l,selectOption:c,store:u}=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??k();s.getAttribute("aria-label")!==T.submit&&s.setAttribute("aria-label",T.submit);let y=s.querySelector("svg");y&&y.getAttribute("aria-label")!==T.submit&&y.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&&st(t.submitTarget,"data-aia-submit-state",e.isSubmitting);let f=i.dataset.newParamId??"",p=e.newParamId!==null&&e.newParamId!==f;if(eo({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"?[]:Zi(e.actionableSuggestions),showChipRemove:n.showChipRemove??!1}),a==="inline"){let T=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,y=pn(e.actionableSuggestions);T||y.length>0?Ii(o,y,0,l,!1,T,e.isActivePillSelected):pr(o)}else pr(o);bl(i,o),p?Ye(i,e.caretOffset??e.text.length,je(n.focusInputOnSelect)):e.isFocused&&Me(i)!==e.text&&!i.hasAttribute("data-aia-composing")&&W(i,e.text.length);let m=e.editingParam?Ge(e.editingParam):e.editingIdentified?{parameter:e.editingIdentified.parameter,text:ie(e.editingIdentified.parameter),required:!0,options:[]}:null,g=e.dropdownSuggestion??m??e.actionableSuggestions[0],b=rt(e);Gi(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:mt(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:c,onHighlight:(T,y)=>{y!==void 0&&u.get().activeDropdownIndex!==y||u.set({activeDropdownIndex:T,highlightByPointer:T>=0})},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=>u.set({isFocused:T}),seeAllBusy:e.isSubmitting,busyProductId:e.selectingProductId,onSeeAllResults:n.seeAllResults&&e.text.trim().length>0&&hl(n)?()=>n.submit?.():void 0,fullWidth:n.seeAllResults===!0})}function to(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 c=i.shift();c;c=i.shift()){if(++l>1e4)throw i.length=0,new Error("createStore: notifications did not settle after 10000 deliveries \u2014 a listener is likely calling set() on every notification");let[u,d]=c;for(let f of n)f(u,d)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function Sl(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)},c={...s,...o(s)};r(c,l)})}}var kr=new WeakSet,Tl=new WeakMap;function xl(t){return t.nodeType===Node.DOCUMENT_NODE}function lm(t){return xl(t)?t:t.ownerDocument}function cm(t){let e=Tl.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(wl),Tl.set(t,i),i)}catch{return null}}function vl(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=wl,e.appendChild(n)}function El(t){if(typeof document>"u")return;let e=t??document;if(kr.has(e))return;let n=lm(e);if(xl(e)){let r=e.head??e.documentElement;if(!r)return;vl(n,r),kr.add(e);return}let i=cm(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):vl(n,e),kr.add(e)}var wl=`.aia-stack {
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: var(--aia-stack-space, 0.5rem);
@@ -2257,32 +2257,23 @@
2257
2257
  filter: opacity(0.42);
2258
2258
  }
2259
2259
 
2260
- /* Press feedback: the picked option's text compresses down while every other
2261
- option steps back in opacity \u2014 no fill, no glow, the hierarchy carries it. */
2260
+ /* Press feedback: the picked option fills with the option background (the
2261
+ row's own background transition) while every other option steps back in
2262
+ opacity. No scale: a row that shrinks and springs back reads as a jolt,
2263
+ and the next question then arrives on top of it. The press stays on until
2264
+ the options leave, so the picked row never flashes back to normal first. */
2262
2265
  .magicx-aia-option--pressed {
2263
2266
  color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
2264
- animation: magicx-aia-pressCompress 170ms ease forwards;
2267
+ background: var(--aia-option-bg, transparent);
2268
+ font-weight: 500;
2265
2269
  }
2266
2270
 
2267
2271
  [role="listbox"]:has(.magicx-aia-option--pressed)
2268
2272
  .magicx-aia-option:not(.magicx-aia-option--pressed) {
2269
2273
  opacity: 0.35;
2270
- transition: opacity 60ms ease;
2271
- }
2272
-
2273
- @keyframes magicx-aia-pressCompress {
2274
- 0% {
2275
- transform: scale(1);
2276
- }
2277
- 25% {
2278
- transform: scale(0.93);
2279
- }
2280
- 60% {
2281
- transform: scale(0.93);
2282
- }
2283
- 100% {
2284
- transform: scale(1);
2285
- }
2274
+ transition:
2275
+ background-color 180ms ease,
2276
+ opacity 120ms ease;
2286
2277
  }
2287
2278
 
2288
2279
  /* Scroll hint \u2014 the last visible row of a scrollable web grid fades toward its
@@ -2896,8 +2887,8 @@
2896
2887
  display: inline-flex;
2897
2888
  align-items: center;
2898
2889
  justify-content: center;
2899
- /* The mark is text centred in the box. An indent inherited from the row
2900
- (an icon row hangs its text with one) would slide it out of the box. */
2890
+ /* An indent inherited from the row (an icon row hangs its text with one)
2891
+ would slide the mark out of the box. */
2901
2892
  text-indent: 0;
2902
2893
  flex: 0 0 18px;
2903
2894
  width: 18px;
@@ -2906,14 +2897,61 @@
2906
2897
  border-radius: 6px;
2907
2898
  background: var(--aia-surface);
2908
2899
  color: transparent;
2909
- font-size: 11px;
2910
2900
  line-height: 1;
2901
+ /* A tick animates the box alone: the row stays put (no press, no dimming),
2902
+ since a multi-select tap keeps the list open for the next tick. */
2903
+ transition:
2904
+ background-color 140ms ease,
2905
+ border-color 140ms ease,
2906
+ color 140ms ease;
2907
+ }
2908
+
2909
+ /* The tick is drawn, not typed: a rounded stroke with a short left leg and a
2910
+ long right one, shaped like Apple's SF Symbols "checkmark". The text "\u2713"
2911
+ it replaces changes with the font and reads thin and cheap. It is painted
2912
+ in the box's text colour, so it fades in with the fill. */
2913
+ .magicx-aia-checkbox::after {
2914
+ content: "";
2915
+ width: 14px;
2916
+ height: 14px;
2917
+ background: currentColor;
2918
+ -webkit-mask:
2919
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5.2 12.6l4.6 4.6 9-10.6' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
2920
+ center / contain no-repeat;
2921
+ mask:
2922
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5.2 12.6l4.6 4.6 9-10.6' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
2923
+ center / contain no-repeat;
2924
+ }
2925
+
2926
+ /* Forced colours replace backgrounds with Canvas, which would hide a tick
2927
+ painted as a background; draw it in the forced text colour instead. */
2928
+ @media (forced-colors: active) {
2929
+ .magicx-aia-checkbox[data-checked="true"]::after {
2930
+ forced-color-adjust: none;
2931
+ background: CanvasText;
2932
+ }
2911
2933
  }
2912
2934
 
2913
2935
  .magicx-aia-checkbox[data-checked="true"] {
2914
2936
  background: var(--aia-confirm-bg, #262626);
2915
2937
  border-color: var(--aia-confirm-bg, #262626);
2916
2938
  color: var(--aia-confirm-color, #ffffff);
2939
+ animation: magicx-aia-checkPop 160ms ease-out;
2940
+ }
2941
+
2942
+ @keyframes magicx-aia-checkPop {
2943
+ 0% {
2944
+ transform: scale(0.82);
2945
+ }
2946
+ 100% {
2947
+ transform: scale(1);
2948
+ }
2949
+ }
2950
+
2951
+ @media (prefers-reduced-motion: reduce) {
2952
+ .magicx-aia-checkbox[data-checked="true"] {
2953
+ animation: none;
2954
+ }
2917
2955
  }
2918
2956
 
2919
2957
  .magicx-aia-option:has(.magicx-aia-checkbox[data-checked="true"]) {
@@ -3188,7 +3226,6 @@
3188
3226
  width: 18px;
3189
3227
  height: 18px;
3190
3228
  border-radius: 6px;
3191
- font-size: 11px;
3192
3229
  }
3193
3230
  /* Reduced motion still wins over the classic transitions above. */
3194
3231
  @media (prefers-reduced-motion: reduce) {
@@ -3900,13 +3937,15 @@
3900
3937
  );
3901
3938
  }
3902
3939
  }
3903
- /* While the panel glides wider (panelMorph.ts), its new content is laid out at
3904
- the width it lands at and the panel, which clips, reveals it as it opens:
3905
- squeezed into the narrow width it starts from, two columns would wrap. The
3906
- leaving copy keeps its own width. */
3940
+ /* While the panel glides to a new width (panelMorph.ts), its new content is
3941
+ laid out at the width it lands at, so it never rewraps under the glide:
3942
+ wider, the panel, which clips, reveals it as it opens; narrower, it starts
3943
+ at its final width instead of squeezing frame by frame. The leaving copy
3944
+ keeps its own width. */
3907
3945
  [data-aia-dropdown][data-aia-glide-width]
3908
3946
  > :not(.magicx-aia-panel-ghost):not([data-aia-scroll-arrow]) {
3909
3947
  min-width: var(--aia-glide-content-width, auto);
3948
+ max-width: var(--aia-glide-content-width, none);
3910
3949
  }
3911
3950
  /* The All row's tile shows the first options' pictures together: two side by
3912
3951
  side, three as a tall half and two quarters, four in a 2x2 grid. Each is
@@ -4043,5 +4082,5 @@
4043
4082
  padding-inline: 8px;
4044
4083
  font-size: var(--aia-skip-font-size, 13.5px);
4045
4084
  }
4046
- `;var to=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(`[Intent-1] "${e}" threw. The error is contained \u2014 SDK state is unaffected. Later failures of "${e}" on this instance are not logged.`,n))}};var no=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 nm(t){return t!=null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}var io=Symbol("aia.handoff.not-handled"),im=new Set(["Shift","Control","Alt","Meta"]),pt=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=>{im.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.expires!==!1&&this.opts.timers.schedule(this.opts.name,()=>this.end(),8e3),this.listen();let o=n.filter(nm),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 ft(t){return`${t.text}\0${t.completedParams.map(e=>e.id).join("\0")}`}function oo(t){return`${ft(t)}${t.products.map(e=>e.id).join("\0")}`}var ro=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 om(t){let e;try{e=new URL(t??ee).host}catch{return null}let n=on.get(e);return n?`https://${n}`:null}var bl=new WeakMap;function yl(t,e){if(!t.head)return;let n=om(e);if(!n)return;let i=bl.get(t);i||(i=new Map,bl.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 gt=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 jt(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=D(t,e);return{query:t.trim(),raw_query:o,completed_params:be(r,n),identified_params:$e(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{},...i.customFields&&i.customFieldsStale?{custom_fields_stale:!0}:{}}}var Or="aia_vid";var rm=/^[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 Ir(t){return t.cookie.match(new RegExp(`(?:^|; )${Or}=([^;]*)`))?.[1]}function Tl(t){try{let e=Ir(t),n=e&&rm.test(e)?e:crypto.randomUUID(),i=t.location?.protocol==="https:"?"; Secure":"";return t.cookie=`${Or}=${n}; Path=/; Max-Age=31536000; SameSite=Lax${i}`,Ir(t)===n?n:void 0}catch{return}}function vl(t){try{if(Ir(t)===void 0)return;t.cookie=`${Or}=; Path=/; Max-Age=0`}catch{}}function Mr(t){return t.isDropdownOpen&&!t.isLoading}var sm=50,am=new Set(["search_started","submit","product_click","impression"]),Rr="aia:last-search",lm="newParam",xl="suggestionRemoval",wl="selectionAnimation",kr="skeletonExit",El="locationSearch",Pl="submitAnswer",cm=2500,um=4,dm=650,mm=0;function pm(){return`:ac-${++mm}:`}var Ll=170,Cl=160;function Al(){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 so=class{constructor(e,n={}){this.inputStore=eo(Al());this._listboxId=pm();this.typing=0;this.picking=0;this.lastInput=null;this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new ro;this.boundary=new to;this.subscriberCount=0;this.emitter=new no(this.boundary);this.sessionId=crypto.randomUUID();this.searchId=crypto.randomUUID();this.searchHandedOff=!1;this.searchIds=!1;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=ft(this.store.get()),{completed:i,returned:o}=this.emitter.collect("submit",e);return this.showsProgress()&&i&&!this.resetsAfterSubmit()&&!this.submitHold.active&&ft(this.store.get())===n&&(this.submitHold.start(n,o),this.store.set({isSubmitting:!0})),i};this.submitHold=new pt({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.answerWait=null;this.settlingSubmit=!1;this.answerHold=new pt({timers:this.timers,name:"answer-hold",controls:"[data-aia-submit], [data-aia-see-all]",document:()=>this.container.ownerDocument,ownsKey:e=>this.ownKeys.has(e),expires:!1,onEnd:()=>this.answerWait?.end(null)});this.productHold=new pt({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.onDocumentInput=e=>{this.lastInput=e};this.container=e,this.opts=n,this.renderMode=n.renderMode??"full",this.store=dl(this.inputStore,i=>ks(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 On(this.store,e),this.watchDocumentInput(!0),this.pillsController=new qn(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new ai({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),schedulePickCursor:i=>this.schedulePickCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new zn(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new Gn(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,getSearchId:()=>this.searchIds?this.searchId:void 0,getPrependPlaceholder:()=>this.opts.prependPlaceholder,getAllOption:()=>this.opts.allOption===!0,getStartingState:()=>this.opts.startingState,onRequest:({query:i,signal:o,isCurrent:r})=>{yl(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:ve(s,o.text),chip_origin:"typed"})},onResponse:({requestId:i,funnelTelemetry:o,visibleImpression:r,sdkVisitorId:s,searchIds:a})=>{this.lastRequestId=i,this.funnelTelemetry=o,this.visibleImpression=r,this.sdkVisitorId=s,this.searchIds=a,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 $n(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",submit:()=>this.runSubmit(),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)&&it(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&&it(i.text,i.completedParams.length,i.leadInText)&&(it(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}=Lt(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=ns(o.text,i.text,s);if(l===null){this.store.set({pendingSpan:null});return}s=l}i.text.slice(s).trim().length===0||es(i.segments,s)?this.store.set({pendingSpan:null}):s!==r.anchor&&this.store.set({pendingSpan:{anchor:s,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(gl(this.opts.styleRoot??Te(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.answerWait?.end(null),this.fetchController.forgetAnswer(),this.store.set({...Al(),isFocused:e,dropdownHeld:n,skipNextFetch:!0}),this.sessionId=crypto.randomUUID(),this.searchId=crypto.randomUUID(),this.searchHandedOff=!1,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.answerWait?.end(null),this.fetchController.dispose(),this.optionSource.dispose(),this.submitHold.dispose(),this.productHold.dispose(),this.holdOpen.dispose(),this.watchDocumentInput(!1),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&&(zs(this.domRefs.input),Xi(this.domRefs.input),Sr(this.domRefs.dropdown)),this.dropdownRefs&&Sr(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(),i=n.text.length;if(!this.focusesInputOnSelect()&&n.isDropdownOpen&&!n.isFocused&&!n.locationFieldFocused){this.store.set({caretOffset:i});return}this.store.set({caretOffset:i,isFocused:!0}),this.scheduleSetCursor(i)}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=An(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}=si(this.store.get().text,e.start,e.end);this.store.set(o=>({text:n,filterBase:Math.min(o.filterBase>e.start?Math.max(e.start,o.filterBase-i):o.filterBase,n.length),...this.withoutChip(o,e),pillTapped:!1,activeDropdownIndex:-1}))}removeParam(e){let n=this.store.get(),i=n.completedParams.find(l=>l.id===e),o=i?"completed":n.identifiedParams.some(l=>l.id===e)?"identified":null;if(!o)return!1;let r=()=>{let l=0;for(let c of this.store.get().segments)if(l+=c.value.length,c.type===o&&(c.param.id===e||c.type==="completed"&&i?.group&&c.param.group===i.group))return l;return null};if(r()===null)return!1;this.store.get().editingParam&&this.exitEditMode(),this.store.get().editingIdentified&&this.exitEditingIdentified();let 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(),W(n.input,e);else{let i=this.opts.setCursor;i&&this.boundary.runListener("setCursor",()=>i(e))}})}focusesInputOnSelect(){return je(this.opts.focusInputOnSelect)}schedulePickCursor(e){queueMicrotask(()=>{let n=this.focusesInputOnSelect(),i=this.domRefs;if(i){Ye(i.input,e,n);return}let o=this.store.get();if(!n&&!o.isFocused&&!o.locationFieldFocused)return;let r=this.opts.setCursor;r&&this.boundary.runListener("setCursor",()=>r(e))})}pick(e){return this.holdOpen.through(()=>{this.picking++;try{return e()}finally{this.picking--,this.picking===0&&this.releaseKeyboardAfterPick()}})}typed(e){this.typing++;try{e()}finally{this.typing--}}keyboardInputInFlight(){let e=this.lastInput;return!e||e.eventPhase===0?!1:e.type==="keydown"||e.detail===0}watchDocumentInput(e){let n=this.container.ownerDocument;for(let i of["click","keydown"])e?n.addEventListener(i,this.onDocumentInput,!0):n.removeEventListener(i,this.onDocumentInput,!0);e||(this.lastInput=null)}releaseKeyboardAfterPick(){if(this.typing>0||this.keyboardInputInFlight()||this.focusesInputOnSelect()||!ce())return;let e=this.store.get();if(!e.isFocused&&!e.locationFieldFocused)return;let n=this.container.ownerDocument.activeElement;for(;n?.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;n instanceof HTMLElement&&n.matches("input, textarea, [contenteditable]:not([contenteditable='false'])")&&(this.holdOpen.holdThroughBlur(),n.blur(),To(n))}clearNewParamId(){this.store.set({newParamId:null})}startEditingIdentified(e){let n=this.store.get();if(n.editingIdentified?.id===e)return!0;let i=n.identifiedParams.find(c=>c.id===e);if(!i)return!1;let o=Y(i);if(!_(o))return!1;let r=o==="date-range"?Ht(i)??Ft(i.text):null,s=0,a=-1;for(let c of n.segments){if(c.type!=="text"&&c.param.id===e){a=s;break}s+=c.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:jn(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.settleSubmit()}awaitSubmitResult(){return this.destroyed||this.answerWait||this.submitHold.active?Promise.resolve(null):new Promise(e=>this.withSubmitAnswer(e))}recordSubmit(e){this.searchHandedOff=!0,this.fireTelemetry("submit",{query:e.query,completed_pills:e.completed_params.filter(n=>n.placeholder).map(n=>({key:n.parameter,value:n.text??""}))})}getSearchId(){return this.searchIds?this.searchId:void 0}getVisitorId(){return this.funnelTelemetry===!0?this.resolveVisitorId():void 0}refreshAnalyticsConsent(){this.opts.visitorId===void 0&&this.resolveOwnVisitorId()}endSubmitProgress(){this.answerWait?.end(null),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(ft(this.store.get()),[e]),this.store.set({isSubmitting:!0}))}selectProduct(e){this.answerWait?.end(null);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.searchHandedOff=!0,!this.emitter.hasListeners("productSelect"))return;let r=oo(n),{completed:s,returned:a}=this.emitter.collect("productSelect",e);this.showsProgress()&&s&&a.some(l=>l!==io)&&oo(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){n&&this.continueSearch(),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=Rn(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:Ze(e),key:U(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(xs(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.pick(()=>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(", ")} ${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(Wn(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?un(this.opts.apiConfig):null,a="loading";s?e.trim().length<Tt&&(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(El,()=>{this.runLocationSearch(o,e,s)},Wr)}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(cn(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&&mo(o,r)}typedLocationQuery(e){let n=this.typedLocationPhrase(e);return this.isReEditing(e)?n.trim():Vr(n)}isReEditing(e){return e.editingParam!=null&&e.editingAnchor!=null}typedLocationPhrase(e){if(this.isReEditing(e))return Bo(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 yn(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 vt&&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(El),this.locationAbort?.abort(),this.locationAbort=null}skipActivePill(){this.pick(()=>this.skipActive())}skipActive(){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;this.continueSearch();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.typed(()=>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 jt(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields,customFieldsStale:!this.fetchController.answersState(e)})}buildResultWithoutAnswer(){let e=this.store.get();return jt(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady})}settleSubmit(){this.settlingSubmit=!0;try{this.endTypedWord(!0)}finally{this.settlingSubmit=!1}}runSubmit(){if(!this.emitter.hasListeners("submit")||this.answerWait||this.submitHold.active||this.store.get().isSubmitting)return;let e=n=>{this.emitSubmit(n)&&this.renderMode==="full"&&this.resetAfterSubmit()};if(this.opts.awaitAnswerOnSubmit!==!0){this.settleSubmit(),e(this.buildResult());return}this.withSubmitAnswer(n=>{n&&e(n)})}withSubmitAnswer(e){this.settleSubmit();let n=this.store.get();if(this.fetchController.answersState(n)){e(this.buildResult());return}if(this.fetchController.asksNothing(n.text,n.completedParams.length)){e(this.buildResultWithoutAnswer());return}let i=!1,o={key:Ue(n),end:r=>{if(!i){if(i=!0,this.answerWait=null,this.timers.clear(Pl),this.answerHold.dispose(),this.destroyed){e(null);return}e(r),!this.submitHold.active&&this.store.get().isSubmitting&&this.store.set({isSubmitting:!1})}}};this.answerWait=o,this.timers.schedule(Pl,()=>o.end(this.buildResultWithoutAnswer()),this.opts.submitAnswerTimeoutMs??cm),this.answerHold.start("",[]),this.showsProgress()&&this.store.set({isSubmitting:!0}),this.pursueSubmitAnswer(()=>i,o.end)}async pursueSubmitAnswer(e,n){try{for(let i=0;i<um;i+=1){let o=await this.fetchController.answerCurrent();if(e())return;if(o==="failed"||o==="unasked")break;if(this.settleSubmit(),this.fetchController.answersState(this.store.get())){n(this.buildResult());return}}}catch{}n(this.buildResultWithoutAnswer())}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,s=this.opts.startingState!==!1;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({});let a=this.opts.startingState!==!1;if(a!==s){this.store.set(c=>a?{}:{suggestions:c.suggestions.filter(u=>u.parameter!=="placeholder")});let l=this.store.get();l.completedParams.length===0&&l.text.trim()===""&&this.fetchController.doFetch("",[])}e.value!==void 0&&this.setValue(e.value),e.completedParams!==void 0&&this.store.set({completedParams:e.completedParams})}selectOption(e,n){n?.fromKeyboard?this.typed(()=>this.pick(()=>this.select(e,n))):this.pick(()=>this.select(e,n))}select(e,n){if(this.continueSearch(),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(As(a,s));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(kr),this.reEdit.selectOption(e);return}let r=Fs({...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,c=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),u=n.map(d=>{let f=l.toLowerCase().indexOf(d.text.toLowerCase(),c);return c=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,c)}});r.patch.completedParams=[...o.completedParams,...u],r.patch.newParamId=u[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:D(o.text,o.completedParams).rawQuery,selected_option:s.text,other_options:N(o.activeFormatType)?[]:o.filteredOptions.filter(a=>a.text!==s.text&&!a.selectsAll).map(a=>a.text),key:r.telemetry.key,position:N(o.activeFormatType)?null:ve(r.consumedSuggestion.options??[],s.text),chip_origin:"tap"});if(this.timers.clear(kr),n?(this.timers.clear(wl),this.store.set({...r.patch,...Ut(o,n.map(s=>s.text)),inSelectionAnimation:!1})):(this.store.set({...r.patch,...Ut(o)}),this.startSelectionAnimationTimer()),this.timers.clear(xl),r.remainingActionable>0){let s=r.consumedSuggestion;this.timers.schedule(xl,()=>{this.store.get().suggestions.includes(s)&&this.store.set(a=>({suggestions:a.suggestions.filter(l=>l!==s)}))},Ll)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(wl,()=>this.store.set({inSelectionAnimation:!1}),Ll)}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&&vl(n),e===!0&&this.sdkVisitorId?Tl(n):void 0}continueSearch(){this.searchHandedOff&&(this.searchHandedOff=!1,this.searchId=crypto.randomUUID())}rememberSearch(){try{this.container.ownerDocument.defaultView?.sessionStorage.setItem(Rr,JSON.stringify({id:this.searchId,at:Date.now()}))}catch{}}resolveSource(){return this.opts.source??(this.renderMode==="full"?"full-sdk":"headless-sdk")}subscribeHandoffHolds(){this.unsubscribers.push(this.store.subscribe(e=>{this.syncAnswerWait(e),this.submitHold.active&&this.submitHold.sync(ft(e)),this.productHold.active&&this.productHold.sync(oo(e))}))}syncAnswerWait(e){let n=this.answerWait;if(!n)return;let i=Ue(e);if(i!==n.key){if(this.settlingSubmit||this.fetchController.isCommitting()){n.key=i;return}n.end(null)}}subscribeVisibleImpression(){this.unsubscribers.push(this.store.subscribe((e,n)=>{this.visibleImpression&&(!e.isDropdownOpen&&n.isDropdownOpen&&(this.lastImpressionKey=""),Mr(e)&&!Mr(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!Mr(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!C(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,sm).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&&am.has(e))return;if(!i&&e==="option"){let{key:s,position:a,chip_origin:l,...c}=n;n=c}let o=this.resolveSource(),r=i&&this.searchIds?this.searchId:void 0;r&&(e==="submit"||e==="product_click")&&this.rememberSearch(),Ns({source:o,sessionId:this.sessionId,searchId:r,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:le(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 gt(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 focusInputOnSelect(){return e.opts.focusInputOnSelect},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},submit:()=>e.runSubmit(),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=ul(this.container,n);let i=()=>{this.domRefs&&Cr(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),Cr(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=Ja(this.container,n);let i=()=>{this.dropdownRefs&&Tr(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),Tr(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(Wt),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=Cl-(Date.now()-e);this.timers.schedule(kr,()=>this.store.set(r),Math.min(Cl,Math.max(0,s)))}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(lm,()=>this.store.set({newParamId:null}),dm)}))}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.typed(()=>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}=os(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<Tt){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}=Lt(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=ye(e.text,Math.min(e.filterBase,e.text.length),e.leadInText),i=Zr(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);Se(e.editingParam.options,i).some(r=>r.is_tappable)||(this.reEdit.exit(),this.fetchNow())}fetchNow(){let e=this.store.get(),{rawQuery:n,completedParams:i}=D(e.text,e.completedParams);this.fetchController.doFetch(n,i)}commitIdentifiedDate(e){let n=this.store.get(),i=n.editingIdentified;if(!i)return;if(n.text.slice(i.anchor,i.tail)!==i.text){this.store.set({editingIdentified:null,activeDropdownIndex:-1});return}let o=n.text.slice(0,i.anchor),r=n.text.slice(i.tail),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,c=o+l+r,u=c.length,d={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:s,value:e.value,kind:e.kind,suggestionParameter:i.parameter,suggestionPlaceholder:te(i.parameter),options:[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url};this.fireTelemetry("option",{raw_query:D(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:[],key:i.parameter,position:null,chip_origin:"tap"}),this.store.set({text:c,completedParams:[...n.completedParams,d],identifiedParams:n.identifiedParams.filter(f=>f.id!==i.id),newParamId:d.id,filterBase:u,caretOffset:u,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.schedulePickCursor(u),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(N(o.activeFormatType)||this.isWordOpen())return;let r=oi({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:D(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:ve(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,LAST_SEARCH_KEY,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,focusEditorFromTap,focusesInputOnSelect,formatAbsoluteDate,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,getCursorOffset,getFooterHint,hasSkippablePill,highlightParts,identifiedParamLabel,inPanelGhost,isCalendarFormat,isDimmedDay,isMultiSelectToggleTap,isOptionsGridMobileViewport,isPickerFormat,isSmartSuggestion,isTouchPrimary,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,settlePickFocus,shopifyImageSrc,startingHintOptions,syncHighlightScroll,syncPanelHug,timeWheelIndex,timeWheelIndexFromScroll,timeWheelRows,toWireIdentifiedParams,typedFragment,uiStringsFor,visibleDateRange,watchEditorHeight,withSkippedParams,withTimeWheelIndex,withoutTraditionalAutocomplete});
4085
+ `;var no=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(`[Intent-1] "${e}" threw. The error is contained \u2014 SDK state is unaffected. Later failures of "${e}" on this instance are not logged.`,n))}};var io=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 um(t){return t!=null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}var oo=Symbol("aia.handoff.not-handled"),dm=new Set(["Shift","Control","Alt","Meta"]),pt=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=>{dm.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.expires!==!1&&this.opts.timers.schedule(this.opts.name,()=>this.end(),8e3),this.listen();let o=n.filter(um),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 ft(t){return`${t.text}\0${t.completedParams.map(e=>e.id).join("\0")}`}function ro(t){return`${ft(t)}${t.products.map(e=>e.id).join("\0")}`}var so=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 mm(t){let e;try{e=new URL(t??ne).host}catch{return null}let n=on.get(e);return n?`https://${n}`:null}var Pl=new WeakMap;function Ll(t,e){if(!t.head)return;let n=mm(e);if(!n)return;let i=Pl.get(t);i||(i=new Map,Pl.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 gt=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 jt(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=D(t,e);return{query:t.trim(),raw_query:o,completed_params:be(r,n),identified_params:$e(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{},...i.customFields&&i.customFieldsStale?{custom_fields_stale:!0}:{}}}var _r="aia_vid";var pm=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Cl(t){let e=t;if(typeof t=="function")try{e=t()}catch{return}return typeof e=="boolean"?e:void 0}function Rr(t){return t.cookie.match(new RegExp(`(?:^|; )${_r}=([^;]*)`))?.[1]}function Al(t){try{let e=Rr(t),n=e&&pm.test(e)?e:crypto.randomUUID(),i=t.location?.protocol==="https:"?"; Secure":"";return t.cookie=`${_r}=${n}; Path=/; Max-Age=31536000; SameSite=Lax${i}`,Rr(t)===n?n:void 0}catch{return}}function Il(t){try{if(Rr(t)===void 0)return;t.cookie=`${_r}=; Path=/; Max-Age=0`}catch{}}function Dr(t){return t.isDropdownOpen&&!t.isLoading}var fm=50,gm=new Set(["search_started","submit","product_click","impression"]),Nr="aia:last-search",hm="newParam",Ol="suggestionRemoval",Ml="selectionAnimation",Hr="skeletonExit",kl="locationSearch",Rl="submitAnswer",bm=2500,ym=4,Sm=650,Tm=0;function vm(){return`:ac-${++Tm}:`}var _l=170,Dl=160;function Hl(){return{text:"",composing:null,completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,locationAutocomplete:!0,customFields:null,optionSearch:null,activeDropdownIndex:-1,highlightByPointer:!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 ao=class{constructor(e,n={}){this.inputStore=to(Hl());this._listboxId=vm();this.typing=0;this.picking=0;this.lastInput=null;this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new so;this.boundary=new no;this.subscriberCount=0;this.emitter=new io(this.boundary);this.sessionId=crypto.randomUUID();this.searchId=crypto.randomUUID();this.searchHandedOff=!1;this.searchIds=!1;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=ft(this.store.get()),{completed:i,returned:o}=this.emitter.collect("submit",e);return this.showsProgress()&&i&&!this.resetsAfterSubmit()&&!this.submitHold.active&&ft(this.store.get())===n&&(this.submitHold.start(n,o),this.store.set({isSubmitting:!0})),i};this.submitHold=new pt({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.answerWait=null;this.settlingSubmit=!1;this.answerHold=new pt({timers:this.timers,name:"answer-hold",controls:"[data-aia-submit], [data-aia-see-all]",document:()=>this.container.ownerDocument,ownsKey:e=>this.ownKeys.has(e),expires:!1,onEnd:()=>this.answerWait?.end(null)});this.productHold=new pt({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.onDocumentInput=e=>{this.lastInput=e};this.container=e,this.opts=n,this.renderMode=n.renderMode??"full",this.store=Sl(this.inputStore,i=>Hs(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 On(this.store,e),this.watchDocumentInput(!0),this.pillsController=new Gn(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new si({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),schedulePickCursor:i=>this.schedulePickCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new zn(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new qn(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,getSearchId:()=>this.searchIds?this.searchId:void 0,getPrependPlaceholder:()=>this.opts.prependPlaceholder,getAllOption:()=>this.opts.allOption===!0,getStartingState:()=>this.opts.startingState,onRequest:({query:i,signal:o,isCurrent:r})=>{Ll(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:ve(s,o.text),chip_origin:"typed"})},onResponse:({requestId:i,funnelTelemetry:o,visibleImpression:r,sdkVisitorId:s,searchIds:a})=>{this.lastRequestId=i,this.funnelTelemetry=o,this.visibleImpression=r,this.sdkVisitorId=s,this.searchIds=a,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 $n(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",submit:()=>this.runSubmit(),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)&&it(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&&it(i.text,i.completedParams.length,i.leadInText)&&(it(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}=Lt(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=ss(o.text,i.text,s);if(l===null){this.store.set({pendingSpan:null});return}s=l}i.text.slice(s).trim().length===0||os(i.segments,s)?this.store.set({pendingSpan:null}):s!==r.anchor&&this.store.set({pendingSpan:{anchor:s,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(El(this.opts.styleRoot??Te(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.answerWait?.end(null),this.fetchController.forgetAnswer(),this.store.set({...Hl(),isFocused:e,dropdownHeld:n,skipNextFetch:!0}),this.sessionId=crypto.randomUUID(),this.searchId=crypto.randomUUID(),this.searchHandedOff=!1,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.answerWait?.end(null),this.fetchController.dispose(),this.optionSource.dispose(),this.submitHold.dispose(),this.productHold.dispose(),this.holdOpen.dispose(),this.watchDocumentInput(!1),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&&(Xs(this.domRefs.input),Ji(this.domRefs.input),Er(this.domRefs.dropdown)),this.dropdownRefs&&Er(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(),i=n.text.length;if(!this.focusesInputOnSelect()&&n.isDropdownOpen&&!n.isFocused&&!n.locationFieldFocused){this.store.set({caretOffset:i});return}this.store.set({caretOffset:i,isFocused:!0}),this.scheduleSetCursor(i)}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=An(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}=ri(this.store.get().text,e.start,e.end);this.store.set(o=>({text:n,filterBase:Math.min(o.filterBase>e.start?Math.max(e.start,o.filterBase-i):o.filterBase,n.length),...this.withoutChip(o,e),pillTapped:!1,activeDropdownIndex:-1}))}removeParam(e){let n=this.store.get(),i=n.completedParams.find(l=>l.id===e),o=i?"completed":n.identifiedParams.some(l=>l.id===e)?"identified":null;if(!o)return!1;let r=()=>{let l=0;for(let c of this.store.get().segments)if(l+=c.value.length,c.type===o&&(c.param.id===e||c.type==="completed"&&i?.group&&c.param.group===i.group))return l;return null};if(r()===null)return!1;this.store.get().editingParam&&this.exitEditMode(),this.store.get().editingIdentified&&this.exitEditingIdentified();let 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(),W(n.input,e);else{let i=this.opts.setCursor;i&&this.boundary.runListener("setCursor",()=>i(e))}})}focusesInputOnSelect(){return je(this.opts.focusInputOnSelect)}schedulePickCursor(e){queueMicrotask(()=>{let n=this.focusesInputOnSelect(),i=this.domRefs;if(i){Ye(i.input,e,n);return}let o=this.store.get();if(!n&&!o.isFocused&&!o.locationFieldFocused)return;let r=this.opts.setCursor;r&&this.boundary.runListener("setCursor",()=>r(e))})}pick(e){return this.holdOpen.through(()=>{this.picking++;try{return e()}finally{this.picking--,this.picking===0&&this.releaseKeyboardAfterPick()}})}typed(e){this.typing++;try{e()}finally{this.typing--}}keyboardInputInFlight(){let e=this.lastInput;return!e||e.eventPhase===0?!1:e.type==="keydown"||e.detail===0}watchDocumentInput(e){let n=this.container.ownerDocument;for(let i of["click","keydown"])e?n.addEventListener(i,this.onDocumentInput,!0):n.removeEventListener(i,this.onDocumentInput,!0);e||(this.lastInput=null)}releaseKeyboardAfterPick(){if(this.typing>0||this.keyboardInputInFlight()||this.focusesInputOnSelect()||!ce())return;let e=this.store.get();if(!e.isFocused&&!e.locationFieldFocused)return;let n=this.container.ownerDocument.activeElement;for(;n?.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;n instanceof HTMLElement&&n.matches("input, textarea, [contenteditable]:not([contenteditable='false'])")&&(this.holdOpen.holdThroughBlur(),n.blur(),vo(n))}clearNewParamId(){this.store.set({newParamId:null})}startEditingIdentified(e){let n=this.store.get();if(n.editingIdentified?.id===e)return!0;let i=n.identifiedParams.find(c=>c.id===e);if(!i)return!1;let o=X(i);if(!_(o))return!1;let r=o==="date-range"?Ht(i)??Ft(i.text):null,s=0,a=-1;for(let c of n.segments){if(c.type!=="text"&&c.param.id===e){a=s;break}s+=c.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:jn(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,highlightByPointer:e>=0})}clearHighlight(e){this.store.get().activeDropdownIndex===e&&this.store.set({activeDropdownIndex:-1,highlightByPointer:!1})}prepareSubmit(){this.settleSubmit()}awaitSubmitResult(){return this.destroyed||this.answerWait||this.submitHold.active?Promise.resolve(null):new Promise(e=>this.withSubmitAnswer(e))}recordSubmit(e){this.searchHandedOff=!0,this.fireTelemetry("submit",{query:e.query,completed_pills:e.completed_params.filter(n=>n.placeholder).map(n=>({key:n.parameter,value:n.text??""}))})}getSearchId(){return this.searchIds?this.searchId:void 0}getVisitorId(){return this.funnelTelemetry===!0?this.resolveVisitorId():void 0}refreshAnalyticsConsent(){this.opts.visitorId===void 0&&this.resolveOwnVisitorId()}endSubmitProgress(){this.answerWait?.end(null),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(ft(this.store.get()),[e]),this.store.set({isSubmitting:!0}))}selectProduct(e){this.answerWait?.end(null);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.searchHandedOff=!0,!this.emitter.hasListeners("productSelect"))return;let r=ro(n),{completed:s,returned:a}=this.emitter.collect("productSelect",e);this.showsProgress()&&s&&a.some(l=>l!==oo)&&ro(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){n&&this.continueSearch(),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=Rn(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:Ze(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.pick(()=>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(", ")} ${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(Wn(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?un(this.opts.apiConfig):null,a="loading";s?e.trim().length<Tt&&(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(kl,()=>{this.runLocationSearch(o,e,s)},$r)}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(cn(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&&po(o,r)}typedLocationQuery(e){let n=this.typedLocationPhrase(e);return this.isReEditing(e)?n.trim():qr(n)}isReEditing(e){return e.editingParam!=null&&e.editingAnchor!=null}typedLocationPhrase(e){if(this.isReEditing(e))return qo(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 yn(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 Yr(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 vt&&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(kl),this.locationAbort?.abort(),this.locationAbort=null}skipActivePill(){this.pick(()=>this.skipActive())}skipActive(){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;this.continueSearch();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.typed(()=>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 jt(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields,customFieldsStale:!this.fetchController.answersState(e)})}buildResultWithoutAnswer(){let e=this.store.get();return jt(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady})}settleSubmit(){this.settlingSubmit=!0;try{this.endTypedWord(!0)}finally{this.settlingSubmit=!1}}runSubmit(){if(!this.emitter.hasListeners("submit")||this.answerWait||this.submitHold.active||this.store.get().isSubmitting)return;let e=n=>{this.emitSubmit(n)&&this.renderMode==="full"&&this.resetAfterSubmit()};if(this.opts.awaitAnswerOnSubmit!==!0){this.settleSubmit(),e(this.buildResult());return}this.withSubmitAnswer(n=>{n&&e(n)})}withSubmitAnswer(e){this.settleSubmit();let n=this.store.get();if(this.fetchController.answersState(n)){e(this.buildResult());return}if(this.fetchController.asksNothing(n.text,n.completedParams.length)){e(this.buildResultWithoutAnswer());return}let i=!1,o={key:Ue(n),end:r=>{if(!i){if(i=!0,this.answerWait=null,this.timers.clear(Rl),this.answerHold.dispose(),this.destroyed){e(null);return}e(r),!this.submitHold.active&&this.store.get().isSubmitting&&this.store.set({isSubmitting:!1})}}};this.answerWait=o,this.timers.schedule(Rl,()=>o.end(this.buildResultWithoutAnswer()),this.opts.submitAnswerTimeoutMs??bm),this.answerHold.start("",[]),this.showsProgress()&&this.store.set({isSubmitting:!0}),this.pursueSubmitAnswer(()=>i,o.end)}async pursueSubmitAnswer(e,n){try{for(let i=0;i<ym;i+=1){let o=await this.fetchController.answerCurrent();if(e())return;if(o==="failed"||o==="unasked")break;if(this.settleSubmit(),this.fetchController.answersState(this.store.get())){n(this.buildResult());return}}}catch{}n(this.buildResultWithoutAnswer())}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,s=this.opts.startingState!==!1;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({});let a=this.opts.startingState!==!1;if(a!==s){this.store.set(c=>a?{}:{suggestions:c.suggestions.filter(u=>u.parameter!=="placeholder")});let l=this.store.get();l.completedParams.length===0&&l.text.trim()===""&&this.fetchController.doFetch("",[])}e.value!==void 0&&this.setValue(e.value),e.completedParams!==void 0&&this.store.set({completedParams:e.completedParams})}selectOption(e,n){n?.fromKeyboard?this.typed(()=>this.pick(()=>this.select(e,n))):this.pick(()=>this.select(e,n))}select(e,n){if(this.continueSearch(),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(ks(a,s));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(Hr),this.reEdit.selectOption(e);return}let r=Us({...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,c=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),u=n.map(d=>{let f=l.toLowerCase().indexOf(d.text.toLowerCase(),c);return c=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,c)}});r.patch.completedParams=[...o.completedParams,...u],r.patch.newParamId=u[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:D(o.text,o.completedParams).rawQuery,selected_option:s.text,other_options:N(o.activeFormatType)?[]:o.filteredOptions.filter(a=>a.text!==s.text&&!a.selectsAll).map(a=>a.text),key:r.telemetry.key,position:N(o.activeFormatType)?null:ve(r.consumedSuggestion.options??[],s.text),chip_origin:"tap"});if(this.timers.clear(Hr),n?(this.timers.clear(Ml),this.store.set({...r.patch,...Bt(o,n.map(s=>s.text)),inSelectionAnimation:!1})):(this.store.set({...r.patch,...Bt(o)}),this.startSelectionAnimationTimer()),this.timers.clear(Ol),r.remainingActionable>0){let s=r.consumedSuggestion;this.timers.schedule(Ol,()=>{this.store.get().suggestions.includes(s)&&this.store.set(a=>({suggestions:a.suggestions.filter(l=>l!==s)}))},_l)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(Ml,()=>this.store.set({inSelectionAnimation:!1}),_l)}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=Cl(this.opts.analyticsConsent),n=this.container.ownerDocument;return e===!1&&Il(n),e===!0&&this.sdkVisitorId?Al(n):void 0}continueSearch(){this.searchHandedOff&&(this.searchHandedOff=!1,this.searchId=crypto.randomUUID())}rememberSearch(){try{this.container.ownerDocument.defaultView?.sessionStorage.setItem(Nr,JSON.stringify({id:this.searchId,at:Date.now()}))}catch{}}resolveSource(){return this.opts.source??(this.renderMode==="full"?"full-sdk":"headless-sdk")}subscribeHandoffHolds(){this.unsubscribers.push(this.store.subscribe(e=>{this.syncAnswerWait(e),this.submitHold.active&&this.submitHold.sync(ft(e)),this.productHold.active&&this.productHold.sync(ro(e))}))}syncAnswerWait(e){let n=this.answerWait;if(!n)return;let i=Ue(e);if(i!==n.key){if(this.settlingSubmit||this.fetchController.isCommitting()){n.key=i;return}n.end(null)}}subscribeVisibleImpression(){this.unsubscribers.push(this.store.subscribe((e,n)=>{this.visibleImpression&&(!e.isDropdownOpen&&n.isDropdownOpen&&(this.lastImpressionKey=""),Dr(e)&&!Dr(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!Dr(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!C(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,fm).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&&gm.has(e))return;if(!i&&e==="option"){let{key:s,position:a,chip_origin:l,...c}=n;n=c}let o=this.resolveSource(),r=i&&this.searchIds?this.searchId:void 0;r&&(e==="submit"||e==="product_click")&&this.rememberSearch(),Bs({source:o,sessionId:this.sessionId,searchId:r,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:le(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 gt(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 focusInputOnSelect(){return e.opts.focusInputOnSelect},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},submit:()=>e.runSubmit(),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=yl(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=sl(this.container,n);let i=()=>{this.dropdownRefs&&wr(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),wr(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(Wt),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=Dl-(Date.now()-e);this.timers.schedule(Hr,()=>this.store.set(r),Math.min(Dl,Math.max(0,s)))}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(hm,()=>this.store.set({newParamId:null}),Sm)}))}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.typed(()=>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}=ls(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<Tt){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}=Lt(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=ye(e.text,Math.min(e.filterBase,e.text.length),e.leadInText),i=is(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);Se(e.editingParam.options,i).some(r=>r.is_tappable)||(this.reEdit.exit(),this.fetchNow())}fetchNow(){let e=this.store.get(),{rawQuery:n,completedParams:i}=D(e.text,e.completedParams);this.fetchController.doFetch(n,i)}commitIdentifiedDate(e){let n=this.store.get(),i=n.editingIdentified;if(!i)return;if(n.text.slice(i.anchor,i.tail)!==i.text){this.store.set({editingIdentified:null,activeDropdownIndex:-1});return}let o=n.text.slice(0,i.anchor),r=n.text.slice(i.tail),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,c=o+l+r,u=c.length,d={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:s,value:e.value,kind:e.kind,suggestionParameter:i.parameter,suggestionPlaceholder:ie(i.parameter),options:[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url};this.fireTelemetry("option",{raw_query:D(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:[],key:i.parameter,position:null,chip_origin:"tap"}),this.store.set({text:c,completedParams:[...n.completedParams,d],identifiedParams:n.identifiedParams.filter(f=>f.id!==i.id),newParamId:d.id,filterBase:u,caretOffset:u,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.schedulePickCursor(u),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(N(o.activeFormatType)||this.isWordOpen())return;let r=ii({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:D(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:ve(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,LAST_SEARCH_KEY,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,clearPanelMorphPressLook,computeOptionsGridLayout,containScroll,createStore,cursorIsAtEnd,dateCellMarks,dateFloorFor,dateSelectionFor,destroyPanelMorph,dropdownPillsFor,editingSuggestion,extractPlainText,findMultiSelectDone,fitMultiSelectDone,focusEditorFromTap,focusesInputOnSelect,formatAbsoluteDate,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,getCursorOffset,getFooterHint,hasSkippablePill,highlightParts,identifiedParamLabel,inPanelGhost,isCalendarFormat,isDimmedDay,isMultiSelectToggleTap,isOptionsGridMobileViewport,isPickerFormat,isSmartSuggestion,isTouchPrimary,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,settlePickFocus,shopifyImageSrc,startingHintOptions,syncHighlightScroll,syncPanelHug,timeWheelIndex,timeWheelIndexFromScroll,timeWheelRows,toWireIdentifiedParams,typedFragment,uiStringsFor,visibleDateRange,watchEditorHeight,withSkippedParams,withTimeWheelIndex,withoutTraditionalAutocomplete});
4047
4086
  //# sourceMappingURL=index.js.map