1(function(){if(window.__wbSearchRedirectBound)return;window.__wbSearchRedirectBound=!0;var SEARCH_URL=(document.querySelector("#header-component")||{}).getAttribute&&document.querySelector("#header-component").getAttribute("data-search-url")||"/search",brandVendorMap={};try{var arr=window.__wbBrandProfiles||[];arr.forEach(function(it){!it||!it.brand||(brandVendorMap[String(it.brand).toLowerCase().trim()]=String(it.vendor||"").trim())})}catch(e){}function getVendorForBrand(brand){var b=String(brand||"").toLowerCase().trim();return b?(brandVendorMap[b]||"").trim():""}function getBrandFromHeader(){var header=document.querySelector("#header-component");if(!header)return"";var brand=(header.getAttribute("data-wb-brand")||"").toLowerCase().trim();return!brand||brand==="default"?"":brand}function getVendorFromHeader(){var header=document.querySelector("#header-component");return header?(header.getAttribute("data-wb-search-vendor")||"").trim():""}function getBrandFromUrl(){try{return(new URL(location.href).searchParams.get("brand")||"").toLowerCase().trim()}catch(e){return""}}function splitVendors(v){return String(v||"").replace(/\|/g,",").split(",").map(function(s){return s.trim()}).filter(Boolean)}function buildVendorQuery(vendorRaw){var vendors=splitVendors(vendorRaw);return vendors.length?vendors.length===1?'vendor:"'+vendors[0].replace(/"/g,'\\"')+'"':"("+vendors.map(function(v){return'vendor:"'+v.replace(/"/g,'\\"')+'"'}).join(" OR ")+")":""}function buildSearchUrl(q,brand,vendorRaw){var query=(q||"").trim();if(vendorRaw&&!/vendor\s*:/i.test(query)){var vq=buildVendorQuery(vendorRaw);vq&&(query=vq+" "+query)}query=query.replace(/\s+/g," ").trim();var url=new URL(SEARCH_URL,window.location.origin);return url.searchParams.set("q",query),url.searchParams.set("options[prefix]","last"),url.searchParams.set("type","product"),brand&&url.searchParams.set("brand",brand),url.toString()}function findSearchInputFromEvent(e){for(var path=e.composedPath&&e.composedPath()||[],i=0;i<path.length;i++){var el=path[i];if(!(!el||!el.tagName)&&el.tagName.toLowerCase()==="input"){var type=(el.getAttribute("type")||"").toLowerCase(),name=(el.getAttribute("name")||"").toLowerCase();if(name==="q"||type==="search")return el}}return document.querySelector('input[name="q"], input[type="search"]')}function stripVendorForDisplay(val,vendorRaw){if(!val)return val;var out=String(val);if(vendorRaw){var vendors=splitVendors(vendorRaw);vendors.forEach(function(v){var vn=String(v).replace(/\u3000/g," ").replace(/\s+/g," ").trim(),vEsc=vn.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"[\\s\\u3000]+"),re1=new RegExp('\\s*vendor\\s*:\\s*"'+vEsc+'"\\s*',"ig"),re2=new RegExp("\\s*vendor\\s*:\\s*""+vEsc+""\\s*","ig");out=out.replace(re1," ").replace(re2," ")})}else out=out.replace(/\s*vendor\s*:\s*(?:"[^"]*"|"[^&]*")\s*/gi," ");return out=out.replace(/[()]/g," "),out=out.replace(/\bOR\b/gi," "),out=out.replace(/\s+/g," ").trim(),out}function getEffectiveBrand(){return getBrandFromUrl()||getBrandFromHeader()}function getEffectiveVendorRaw(brand){return getVendorForBrand(brand)||getVendorFromHeader()}function stripVendorForDisplayEverywhere(){var brand=getEffectiveBrand(),vendor=getEffectiveVendorRaw(brand);document.querySelectorAll('input[name="q"], input[type="search"]').forEach(function(input){var before=input.value||"",after=stripVendorForDisplay(before,vendor);before!==after&&(input.value=after)})}function redirectToSearch(e){var brand=getEffectiveBrand();if(brand){var input=findSearchInputFromEvent(e);if(input){var q=(input.value||"").trim();if(q){e.preventDefault(),e.stopPropagation();var vendor=getEffectiveVendorRaw(brand);window.location.href=buildSearchUrl(q,brand,vendor)}}}}function fixSearchBrandIfMissing(){try{var u=new URL(location.href);if(u.pathname!==SEARCH_URL||u.searchParams.get("brand"))return;var brand=getBrandFromUrl()||getBrandFromHeader();if(!brand)return;u.searchParams.set("brand",brand),location.replace(u.toString())}catch(e){}}function ensureBrandParamEverywhere(){var brand=getEffectiveBrand();brand&&(document.querySelectorAll('a[href^="/search"], a[href*="/search?"]').forEach(function(a){try{var href=a.getAttribute("href");if(!href)return;var u=new URL(href,window.location.origin);if(u.pathname!==SEARCH_URL)return;u.searchParams.get("brand")||(u.searchParams.set("brand",brand),a.setAttribute("href",u.pathname+"?"+u.searchParams.toString()))}catch(e){}}),document.querySelectorAll('form[action^="/search"], form[action*="/search"]').forEach(function(form){var qInput=form.querySelector('input[name="q"], input[type="search"]');if(qInput){var input=form.querySelector('input[name="brand"]');input||(input=document.createElement("input"),input.type="hidden",input.name="brand",form.appendChild(input)),input.value=brand}}))}fixSearchBrandIfMissing(),document.addEventListener("submit",redirectToSearch,!0),document.addEventListener("click",function(e){var a=e.target&&e.target.closest?e.target.closest("a[href]"):null;if(a){var href=a.getAttribute("href")||"";if(href.indexOf("/search")!==-1)try{var u=new URL(href,window.location.origin);if(u.pathname===SEARCH_URL&&!u.searchParams.get("brand")){var brand=getEffectiveBrand();brand&&(u.searchParams.set("brand",brand),a.setAttribute("href",u.pathname+"?"+u.searchParams.toString()))}}catch(err){}}for(var path=e.composedPath&&e.composedPath()||[],i=0;i<path.length;i++){var el=path[i];if(!(!el||!el.tagName)){var tag=el.tagName.toLowerCase();if(tag==="button"||tag==="input"){var type=(el.getAttribute("type")||"").toLowerCase();if(type==="submit"){redirectToSearch(e);return}}}}},!0),document.addEventListener("keydown",function(e){if(e.key==="Enter"){var t=e.target;if(!(!t||!t.tagName)&&t.tagName.toLowerCase()==="input"){var type=(t.getAttribute("type")||"").toLowerCase(),name=(t.getAttribute("name")||"").toLowerCase();(name==="q"||type==="search")&&redirectToSearch(e)}}},!0);var scheduled=!1,lastBrand="";function getBrandFast(){var m=location.search.match(/[?&]brand=([^&]+)/i),b=m?decodeURIComponent(m[1]||""):"";return b=(b||"").toLowerCase().trim(),b&&b!=="default"?b:getBrandFromHeader()}function scheduleSync(reason){scheduled||(scheduled=!0,requestAnimationFrame(function(){scheduled=!1;var brand=getBrandFast(),brandChanged=brand&&brand!==lastBrand;brandChanged&&(lastBrand=brand,ensureBrandParamEverywhere()),(reason==="input"||location.pathname===SEARCH_URL)&&stripVendorForDisplayEverywhere()}
1))}var root=document.querySelector("#header-group")||document.querySelector("#header-component")||document.body;new MutationObserver(function(mutations){for(var i=0;i<mutations.length;i++){var m=mutations[i];if(!(!m.addedNodes||!m.addedNodes.length))for(var j=0;j<m.addedNodes.length;j++){var n=m.addedNodes[j];if(!(!n||n.nodeType!==1)&&(n.matches&&n.matches('input[name="q"], input[type="search"]')||n.querySelector&&n.querySelector('input[name="q"], input[type="search"]'))){scheduleSync("input");return}}}scheduleSync("mut")}).observe(root,{childList:!0,subtree:!0}),scheduleSync("init"),document.addEventListener("DOMContentLoaded",function(){scheduleSync("init")})})(); 2//# sourceMappingURL=/cdn/shop/t/26/assets/header-brand-search.js.map?v=53037301700443147441775444117
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.