1var module_185031264794=function(){const DEFAULT_MODULE_CONFIG=Object.freeze({autosuggest_results_message:"Results for â[[search_term]]â",sr_autosuggest_results_message:"There are currently [[number_of_results]] auto-suggested results for [[search_term]].",sr_search_field_aria_label:"This is a search field with an auto-suggest feature attached.",sr_search_button_aria_label:"Search"});let srAnnounceTimeout;const moduleConfig=(moduleName=>{const configJSONScript=document.querySelector(`[data-${moduleName}-config]`);return configJSONScript?JSON.parse(configJSONScript.textContent):DEFAULT_MODULE_CONFIG})("search_input"),KEYS=Object.freeze({TAB:"Tab",ESC:"Esc",ESCAPE:"Escape",UP:"Up",ARROW_UP:"ArrowUp",DOWN:"Down",ARROW_DOWN:"ArrowDown"}),debounce=(func,wait)=>{let timer;return(...args)=>{clearTimeout(timer),timer=setTimeout((()=>{func.apply(this,args)}),wait)}},emptySearchSuggestions=(suggestionsResponse,searchInputElements)=>{const{searchForm:searchForm,searchSuggestions:searchSuggestions,searchInput:searchInput,srMessageContainer:srMessageContainer}=searchInputElements,{searchTerm:searchTerm}=suggestionsResponse,noSearchResultsMessage=searchTerm?moduleConfig.autosuggest_no_results_message.replace("[[search_term]]",searchTerm):moduleConfig.sr_empty_search_field_message,emptyResultsItem=`<li role="option"\n tabindex="-1"\n aria-posinset="1"\n aria-setsize="0"\n class="results-for ${searchTerm?"":"show-for-sr"}">${noSearchResultsMessage}</li>`;searchSuggestions.innerHTML=emptyResultsItem,srMessageContainer.innerHTML=noSearchResultsMessage,searchInput.focus(),searchForm.classList.remove("hs-search-field--open")},trapFocus=searchInputElements=>{const{searchInput:searchInput,searchSuggestions:searchSuggestions,searchInputContainer:searchInputContainer}=searchInputElements,tabbable=[];tabbable.push(searchInput);searchSuggestions.querySelectorAll("a").forEach((suggestion=>tabbable.push(suggestion)));const firstTabbable=tabbable[0],lastTabbable=tabbable[tabbable.length-1];searchInputContainer.removeEventListener("keydown",window.captureKeyDown),window.captureKeyDown=e=>{switch(e.key){case KEYS.TAB:(e=>{e.target!==lastTabbable||e.shiftKey?e.target===firstTabbable&&e.shiftKey&&(e.preventDefault(),lastTabbable.focus()):(e.preventDefault(),firstTabbable.focus())})(e);break;case KEYS.ESC:case KEYS.ESCAPE:emptySearchSuggestions({},searchInputElements);break;case KEYS.UP:case KEYS.ARROW_UP:(e=>{e.preventDefault(),e.target===firstTabbable?lastTabbable.focus():tabbable.forEach((el=>{el===e.target&&tabbable[tabbable.indexOf(el)-1].focus()}))})(e);break;case KEYS.DOWN:case KEYS.ARROW_DOWN:(e=>{e.preventDefault(),e.target===lastTabbable?firstTabbable.focus():tabbable.forEach((el=>{el===e.target&&tabbable[tabbable.indexOf(el)+1].focus()}))})(e)}},searchInputContainer.addEventListener("keydown",window.captureKeyDown)},renderSearchSuggestions=(suggestionsResponse,searchInputElements)=>{const{searchSuggestions:searchSuggestions,srMessageContainer:srMessageContainer,searchInputContainer:searchInputContainer}=searchInputElements,{results:results,searchTerm:searchTerm}=suggestionsResponse,searchResultsMessage=moduleConfig.autosuggest_results_message.replace("[[search_term]]",searchTerm),items=[`<li role="option"\n tabindex="-1"\n aria-posinset="1"\n aria-setsize="${results.length}"\n class="results-for">${searchResultsMessage}</li>`,...results.map(((result,index)=>`<li role="option"\n aria-posinset="${index+2}"\n tabindex="${index+1}"><a href="${result.url}">${result.title}</a></li>`))];emptySearchSuggestions({},searchInputElements),searchSuggestions.innerHTML=items.join(""),searchInputContainer.classList.add("hs-search-field--open"),srAnnounceTimeout=setTimeout((()=>{((suggestionsResponse,srMessageContainer)=>{const{results:results,searchTerm:searchTerm}=suggestionsResponse;srMessageContainer&&(srMessageContainer.innerHTML=`${moduleConfig.sr_autosuggest_results_message.replace("[[number_of_results]]",results.length).replace("[[search_term]]",searchTerm)}`)})(suggestionsResponse,srMessageContainer)}),1500)},getSearchContentTypesQueryParamsArray=searchForm=>{const data=new FormData(searchForm);let formTypeParams=[],otherParams=[];for(const[key,value]of data.entries()){const param=`${encodeURIComponent(key)}=${encodeURIComponent(value)}`;("type"===key?formTypeParams:otherParams).push(param)}return formTypeParams=function(formParams){const validContentTypesElement=document.getElementById("hs-search-input__valid-content-types");if(!validContentTypesElement)return formParams;try{const validContentTypes=new Set(JSON.parse(validContentTypesElement.textContent)),newParams=new URLSearchParams(window.location.search).getAll("type").filter((type=>validContentTypes.has(type))).map((type=>`type=${encodeURIComponent(type)}`));return newParams.length>0?newParams:formParams}catch(e){return console.warn("Error parsing valid content types:",e),formParams}}(formTypeParams),[...formTypeParams,...otherParams]},initializeSearchInput=searchInputContainer=>{let searchTerm="";if(searchInputContainer.classList.contains("hs-search-field--initialized"))return;searchInputContainer.classList.add("hs-search-field--initialized");const searchForm=searchInputContainer.querySelector("form"),searchInput=searchForm.querySelector(".hs-search-field__input"),searchSuggestions=searchInputContainer.querySelector(".hs-search-field__suggestions"),srMessageContainer=searchInputContainer.querySelector(".hs-search-sr-message-container"),searchInputElements={searchInputContainer:searchInputContainer,searchForm:searchForm,searchSuggestions:searchSuggestions,srMessageContainer:srMessageContainer,searchInput:searchInput},isSearchTermPresent=debounce((()=>{searchTerm=searchInput.value,searchTerm.length>2?(searchInputElements=>{const{searchForm:searchForm}=searchInputElements,parsedParamsArray=getSearchContentTypesQueryParamsArray(searchForm);parsedParamsArray.push("limit=3"),parsedParamsArray.push("autocomplete=true"),parsedParamsArray.push("analytics=true");const searchUrl=`/_hcms/v3/site-search/search?${new URLSearchParams(parsedParamsArray.join("&")).toString()}`,request=new XMLHttpRequest;request.open("GET",searchUrl,!0),request.onload=function(){if(request.status>=200&&request.status<400){const resultData=JSON.parse(request.responseText);srAnnounceTimeout&&clearTimeout(srAnnounceTimeout),resultData.results.length>0?(renderSearchSuggestions(resultData,searchInputElements),trapFocus(searchInputElements)):emptySearchSuggestions(resultData,searchInputElements)}else console.error("Server reached, error retrieving results.")},request.onerror=function(){console.error("Could not reach the server.")},request.send()})(searchInputElements):0===searchTerm.length&&emptySearchSuggestions({},searchInputElements)}),250);searchInput.addEventListener("input",(()=>{searchTerm!==searchInput.value&&isSearchTermPresent()}
1)),searchForm.addEventListener("submit",(function(e){e.preventDefault();const form=e.target;let redirectUrl=form.getAttribute("action");redirectUrl+=redirectUrl.includes("?")?"&":"?";const currentParams=getSearchContentTypesQueryParamsArray(form).join("&");currentParams&&(redirectUrl+=currentParams),window.location.href=redirectUrl}))};document.addEventListener("DOMContentLoaded",(()=>{const searchInputContainers=document.querySelectorAll(".hs-search-field");searchInputContainers.length>0&&searchInputContainers.forEach((searchInputContainer=>{initializeSearchInput(searchInputContainer)}))}))}(); 2//# sourceURL=https://1830569.fs1.hubspotusercontent-na1.net/hubfs/1830569/hub_generated/module_assets/1/185031264794/1740989997413/module_search_input.js
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.