"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[941],{96463:function(e,t){Object.prototype.toString,Object.prototype.hasOwnProperty},90941:function(e,t,r){r.r(t),r.d(t,{default:function(){return search}});var a=r(33067),o=r(43412),n=r.n(o),getBaseDomain=e=>{if(e[0]===e[1])return".".concat(new URL(n().storeUrl).hostname);for(var t=e.map(e=>{try{var t=new URL(e).hostname,r=n().api.subDomainPrefix||[],a=new RegExp("^(".concat(["www",...r].join("|"),")\\."));return t.replace(a,"")}catch(e){return""}}).map(e=>e.split(".").reverse()),r=Math.min(...t.map(e=>e.length)),a=[],_loop=function(e){if(1!==new Set(t.map(t=>t[e])).size)return"break";a.push(t[0][e])},o=0;o<r&&"break"!==_loop(o);o++);if(a.length<2){var s="No common domain found for URLs: ".concat(e.join(", "));return console.warn("".concat(s,". Please check the Production URLs in the discovery.config file.")),""}return"."+a.reverse().join(".")};function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){(0,a.Z)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}r(96463),r(57861).lW;var randomUUID=()=>"function"==typeof crypto.randomUUID?crypto.randomUUID().replaceAll("-",""):(1e6*Math.random()).toFixed(0),createOrRefreshCookie=(e,t)=>{var r=n().secureSubdomain?getBaseDomain([n().storeUrl,n().secureSubdomain]):".".concat(new URL(n().storeUrl).hostname);return()=>{var a=function(e){for(var t of decodeURIComponent(document.cookie).split(";")){var[r,a]=t.trim().split("=");if(r===e)return a}}(e);return void 0===a&&(a=randomUUID()),document.cookie="".concat(e,"=").concat(a,"; max-age=").concat(t,"; domain=").concat(r,"; path=/;"),a}},s={anonymous:createOrRefreshCookie("vtex-search-anonymous",31536e3),session:createOrRefreshCookie("vtex-search-session",1800)},sendEvent=e=>fetch("https://sp.vtex.com/event-api/v1/".concat(n().api.storeId,"/event"),{method:"POST",body:JSON.stringify(_objectSpread(_objectSpread({},e),{},{userAgent:navigator.userAgent,anonymous:s.anonymous(),session:s.session()})),headers:{"content-type":"application/json"}}),isFullTextSearch=e=>"string"==typeof e.searchParams.get("q")&&/^\/s(\/)?$/g.test(e.pathname);setInterval(()=>sendEvent({type:"session.ping"}),6e4);var search=e=>{switch(e.name){case"search_select_item":var t,r,a=new URL(e.params.url);if(!isFullTextSearch(a))return;for(var o of null!==(n=e.params.items)&&void 0!==n?n:[]){var n,s,c,i=null!==(s=o.item_id)&&void 0!==s?s:o.item_variant,p=o.index;i&&p&&sendEvent({type:"search.click",productId:i,position:p,url:a.href,text:null!==(c=a.searchParams.get("q"))&&void 0!==c?c:"<empty>"})}break;case"intelligent_search_query":sendEvent({type:"search.query",url:e.params.url,text:e.params.term,misspelled:e.params.isTermMisspelled,match:e.params.totalCount,operator:e.params.logicalOperator,locale:e.params.locale});break;case"intelligent_search_autocomplete_query":sendEvent({type:"search.autocomplete.query",url:e.params.url,text:e.params.term,misspelled:e.params.isTermMisspelled,match:e.params.totalCount,operator:e.params.logicalOperator,locale:e.params.locale});break;case"intelligent_search_autocomplete_click":sendEvent(_objectSpread(_objectSpread({text:e.params.term,url:null!==(t=e.params.url)&&void 0!==t?t:"",productId:null!==(r=e.params.productId)&&void 0!==r?r:""},e.params.position&&{position:e.params.position}),{},{type:"search.autocomplete.click"}))}}}}]);