1(()=>{"use strict";(()=>{const e="com.consumeraffairs.styleguide.search.init",t="com.consumeraffairs.styleguide.search.loaded",s="search_interaction",i={BOX:".js-srch-box",INPUT:".js-srch-inpt",LOADER:".js-srch-ldr",RESULTS:".js-srch-rslts",WRAPPER:".js-srch-wrppr",FORM:".js-srch-frm",INPUT_LOADER:".js-srch-inpt-ldr",SEARCH_ICON:".js-srch-icon, .js-search-icon",SHOW_ALL_LINK:".js-srch-shw-all-lnk"},n={HIDE:"js-srch-hd"},o={BASE:"v2/site_search",SUGGESTIONS:"suggestions/",RENDER:"render/"},r={PAGE_TYPE:"data-page-type",IS_SEARCH_ON_HERO_PAGE:"data-is-search-on-hero-page"},h="homepage",a={PAGE_TYPE:"page_type",QUERY:"q",IS_SEARCH_ON_HERO_PAGE:"is_search_on_hero_page"},d={LAZY_LOAD:"com.consumeraffairs.sitecore.contentReload"};function c(e,t){let s;return function(){for(var i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];window.clearTimeout(s),s=window.setTimeout(()=>{e(...n)},t)}}const _=()=>{const e=new URLSearchParams(window.location.search),t=window.useViewTransitions||"1"===e.get("use_view_transitions"),s=!!document.startViewTransition,i="string"==typeof document.visibilityState?"visible"===document.visibilityState:!document.hidden,n=s?window.matchMedia("(prefers-reduced-motion: reduce)"):{matches:!1};return s&&t&&!n.matches&&i},l=e=>{if(_())try{const t=document.startViewTransition(e);if(t){const e=()=>{};[t.ready,t.updateCallbackDone,t.finished].forEach(t=>{t&&"function"==typeof t.catch&&t.catch(e)})}}catch(t){e()}else e()},u={CAPTURE_EXCEPTION_EVENT:"com.consumeraffairs.styleguide.logger.captureException",CAPTURE_MESSAGE_EVENT:"com.consumeraffairs.styleguide.logger.captureMessage"};class p{constructor(){this._headers=[],this._url="",this._method="GET",this._data={},this._contentType="application/json",this._csrfToken=!1}get headers(){return[...window.APIClient&&window.APIClient.headers?window.APIClient.headers:[],...this._headers]}set headers(e){Array.isArray(e)&&e.every(e=>e.key&&e.value)&&(this._headers=e)}get url(){return this._url}set url(e){this._url=e}get method(){return this._method}set method(e){this._method=e}get data(){return this._data}set data(e){this._data=e}get contentType(){return this._contentType}set contentType(e){this._contentType=e}get csrfToken(){return this._csrfToken}set csrfToken(e){this._csrfToken=e}}const E=function(e){const t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.cookie.match(`(^|;) ?${e}=([^;]*)(;|$)`);return t?t[2]:null};class L{static get CSRF_COOKIE_NAME(){return window.CSRF_COOKIE_NAME||"csrftoken"}static get FORM_CONTENT_TYPE(){return"application/x-www-form-urlencoded"}constructor(e){if(!e)throw new Error("APIClient called without a model!");this.model=e}fetch(){const{contentType:e,data:t,method:s,url:i}=this.model,n={method:s?s.toUpperCase():"GET",headers:this._getHeaders(),credentials:"include"};let o=i;return Object.keys(t).length>0&&("GET"===n.method?o+=`?${new URLSearchParams(t).toString()}`:n.body=JSON.stringify(t)),this._logRequest({contentType:e,data:t,url:o,parameters:n,through:"fetch"}),window.fetch(o,n).then(e=>{if(e.ok){const t=e.json();return t&&"function"==typeof t.catch?t.catch(e=>{if(e instanceof SyntaxError)return{};throw e}):t}return e.text().then(t=>{let s;try{s=t&&t.trim()?JSON.parse(t):{}}catch{s={_raw:t}}const i=new Error("Request error");throw i.status=e.status,i.response=Promise.resolve(s),i})}).then(t=>e===L.FORM_CONTENT_TYPE?t:JSON.stringify(t))}sendBeacon(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>{};const{data:t,url:s}=this.model;if(navigator.sendBeacon){const e=this._setBeaconDataContentType(t);return this._logRequest({data:e,url:s,through:"beacon"}),navigator.sendBeacon(s,e)}return this.fetch().catch(e),!0}_getHeaders(){const{contentType:e}=this.model;return{"Content-Type":e,"X-CSRFToken":E(L.CSRF_COOKIE_NAME)||"",...this._getCustomHeaders()}}_getCustomHeaders(){const{headers:e}=this.model;return e.reduce((e,t)=>({...e,[t.key]:t.value}),{})}_setBeaconDataContentType(e){return new Blob([JSON.stringify(e)],{type:"application/json"})}_logRequest(e){if(!window.caEnableHttpRequestsLogging)return;const t=new CustomEvent(u.CAPTURE_MESSAGE_EVENT,{detail:{message:"[APIClientV2] HTTP request sent",level:"debug",context:e}});window.dispatchEvent(t)}}class m{constructor(){this.isLoading=!1,this.module=this.constructor.name,this._bindMethods()}get isLoading(){return this._isLoading}set isLoading(e){this._isLoading=e}get module(){return this._module}set module(e){this._module=e}_bindMethods(){this.sendRequest=this.sendRequest.bind(this),this.setupAPIClient=this.setupAPIClient.bind(this),this.refreshUserDb=this.refreshUserDb.bind(this),this.setButtonState=this.setButtonState.bind(this)}setupAPIClient(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"POST";this._apiModel=new p,this._api=new L(this._apiModel),this._apiModel.method=e,this._apiModel.csrfToken=!0,this._apiModel.headers=[{key:"X-Requested-With",value:"XMLHttpRequest"}]}setURL(e){this._apiModel&&(this._apiModel.url=e)}setData(e){this._apiModel&&(this._apiModel.data=e)}refreshUserDb(e){window.CAUApiEvent&&e&&window.CAUApiEvent.refreshTargets(e)}
1setButtonState(e,t,s){if(e){if(e.classList[t](s),"add"===t)return void e.setAttribute("disabled","");e.removeAttribute("disabled")}}sendRequest(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>{};return this._api&&this._apiModel&&!this.isLoading?(this.isLoading=!this.overrideLoadingState||this.overrideLoadingState.isLoading,this._api.fetch().then(t=>{const s=this._toJSON(t);e(s)}).catch(e=>{this._onError(e),t(e)}).finally(()=>{this.isLoading=!!this.overrideLoadingState&&this.overrideLoadingState.isLoading,s()})):Promise.resolve()}setOverrideLoadingState(e){this.overrideLoadingState=e}_toJSON(e){let t;try{t=JSON.parse(e)}catch(e){this._onError(e,"JSON Parse error"),t={}}return t}_onError(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Request failed";const s=`[${this.module}]: ${t}.`,i=new CustomEvent(u.CAPTURE_EXCEPTION_EVENT,{detail:{message:s,context:e}});window.dispatchEvent(i)}}const w={CLOSE:"com.consumeraffairs.frontend.header.search.close",INNER_CLOSE:"com.consumeraffairs.frontend.header.search.innerClose",OPEN:"com.consumeraffairs.frontend.header.search.open"};class g extends m{constructor(e){super(),this._inputElement=e,this._inputElement&&this._init()}_init(){this._bindMethods(),this._setElements(),this._canInit()&&(window.useViewTransitions=!0,super.setOverrideLoadingState({isLoading:!1}),this._bindEvents(),super.setupAPIClient("GET"),this._dispatchLoadedEvent(),this._fetchSuggestions())}_setElements(){if(this._hasFinishedFetching=!1,this._suggestions=null,this._box=this._inputElement.closest(i.BOX),this._pageType=h,this._box){this._loader=this._box.querySelector(i.LOADER),this._results=this._box.querySelector(i.RESULTS),this._wrapper=this._box.querySelector(i.WRAPPER),this._form=this._box.querySelector(i.FORM),this._inputLoader=this._box.querySelector(i.INPUT_LOADER);const e=this._inputLoader&&this._inputLoader.previousElementSibling;this._searchIcon=e&&e.matches(i.SEARCH_ICON)?e:null,this._pageType=this._box.getAttribute(r.PAGE_TYPE)||h,this._showAllLink=this._box.querySelector(i.SHOW_ALL_LINK)}}_bindMethods(){super._bindMethods(),this._handleOpenEvent=this._handleOpenEvent.bind(this),this._handleDebouncedSearch=this._handleDebouncedSearch.bind(this),this._fetchSuggestions=this._fetchSuggestions.bind(this)}_bindEvents(){document.addEventListener(w.OPEN,this._handleOpenEvent),this._inputElement.addEventListener("input",c(this._handleDebouncedSearch,550)),this._form.addEventListener("submit",e=>{e.preventDefault()})}_handleOpenEvent(){this._hasFinishedFetching?(this._showWrapper(),this._focusInput()):this._focusInput()}_handleDebouncedSearch(){if(!this._inputElement.value&&this._cache)return this._hideShowAllLink(),void this._hideLoaderAndReplaceContent(this._cache);
1if(this._inputElement.value.length>2){const e=this._composeURL(this._inputElement.value,o.RENDER);this._makeRequest(e,{value:this._inputElement.value})}}_canInit(){return!!(this._inputElement&&this._box&&this._results&&this._wrapper&&this._form)}_dispatchLoadedEvent(){const e=new CustomEvent(t);window.dispatchEvent(e)}_fetchSuggestions(){const e=this._composeURL();this._makeRequest(e,{shouldCache:!0})}_makeRequest(e){let{shouldCache:t=!1,value:s=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e&&(this._showInputLoader(),super.setURL(e),super.sendRequest(e=>{t&&e&&e.content&&(this._cache=e),this._hideLoaderAndReplaceContent(e)},()=>{},()=>{this._onFetchFinally(s)}))}_updateShowAllLink(e){if(this._showAllLink&&e){this._showShowAllLink();const t=new URL(this._showAllLink.href);t.searchParams.set(a.QUERY,e),this._showAllLink.href=t.toString()}}_hideShowAllLink(){this._showAllLink&&this._showAllLink.parentElement.classList.add(n.HIDE)}_showShowAllLink(){this._showAllLink&&this._showAllLink.parentElement.classList.remove(n.HIDE)}_composeURL(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.SUGGESTIONS;const s=`${a.PAGE_TYPE}=${this._pageType}`,i=`${window.MAINSITE_BASE_URL}/api/${o.BASE}/${t}?${s}`,n=e?`${a.QUERY}=${e}`:"";return`${i}${n?`&${n}`:""}`}_hideLoaderAndReplaceContent(e){e&&e.content&&l(()=>{this._hideLoader(),this._replaceContent(e.content)})}_onFetchFinally(e){this._hideLoader(),this._hideInputLoader(),this._showWrapper(),this._updateShowAllLink(e),this._hasFinishedFetching=!0}_hideLoader(){this._loader&&this._loader.classList.add(n.HIDE)}_hideInputLoader(){this._inputLoader&&this._inputLoader.classList.add(n.HIDE),this._searchIcon&&this._searchIcon.classList.remove(n.HIDE)}_showInputLoader(){this._inputLoader&&this._inputLoader.classList.remove(n.HIDE),this._searchIcon&&this._searchIcon.classList.add(n.HIDE)}_focusInput(){this._inputElement&&window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{this._inputElement.focus()})})}_showWrapper(){this._wrapper.classList.remove(n.HIDE)}_replaceContent(e){this._results&&(this._results.innerHTML=e,super.refreshUserDb(this._results),this._refreshLazyLoad())}_refreshLazyLoad(){window.dispatchEvent(new CustomEvent(d.LAZY_LOAD))}}class f extends g{_init(){this._bindMethods(),super._setElements(),this._canInit()&&(window.useViewTransitions=!0,super.setOverrideLoadingState({isLoading:!1}),this._bindEvents(),super.setupAPIClient("GET"))}_bindMethods(){super._bindMethods(),this._handleResultLinkMouseDown=this._handleResultLinkMouseDown.bind(this)}_isSafari(){return/^((?!chrome|android|firefox|opera|opr|edg).)*safari/i.test(navigator.userAgent)}_replaceContent(e){this._results&&(this._isSafariLinkHandlerBound=!1,this._results.innerHTML=e,super.refreshUserDb(this._results),this._refreshLazyLoad(),this._isSafari()&&this._bindResultLinkEvents())}_bindEvents(){const e=c(super._handleDebouncedSearch.bind(this),550);this._inputElement.addEventListener("input",()=>{window.hj&&!this._hasHJEventBeenDispatched&&(window.hj("event",s),this._hasHJEventBeenDispatched=!0),e()}),this._form.addEventListener("submit",e=>{e.preventDefault()}),this._inputElement.addEventListener("focus",()=>{super._fetchSuggestions()},{once:!0})}_hideLoaderAndReplaceContent(e){e&&e.content&&(super._hideLoader(),this._replaceContent(e.content))}_handleResultLinkMouseDown(e){0===e.button&&(e.preventDefault(),this._redirect(e))}_redirect(e){const t=e.target.closest("a");t&&t.href&&window.requestAnimationFrame(()=>{window.location.href=t.href})}_bindResultLinkEvents(){if(this._results&&!this._isSafariLinkHandlerBound){this._results.querySelectorAll("a").forEach(e=>{e.addEventListener("mousedown",this._handleResultLinkMouseDown)}),this._isSafariLinkHandlerBound=!0}}_composeURL(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.SUGGESTIONS;const s=`${a.PAGE_TYPE}=${this._pageType}`,i=`${window.MAINSITE_BASE_URL}/api/${o.BASE}/${t}?${s}`,n=e?`${a.QUERY}=${encodeURIComponent(e)}`:"";return`${i}${n?`&${n}`:""}&${`${a.IS_SEARCH_ON_HERO_PAGE}=true`}`}}const S=()=>
1{document.querySelectorAll(i.INPUT).forEach(e=>{if(!e.search){const t=e.hasAttribute(r.IS_SEARCH_ON_HERO_PAGE);e.search=t?new f(e):new g(e)}})};S(),document.addEventListener(e,()=>S())})()})();
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.