(window.webpackJsonpvtex_search_result_3_143_4=window.webpackJsonpvtex_search_result_3_143_4||[]).push([[18],{122:function(e,t){var r="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global,o=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var r=void 0!==e&&e||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{},o="URLSearchParams"in r,n="Symbol"in r&&"iterator"in Symbol,s="FileReader"in r&&"Blob"in r&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in r,a="ArrayBuffer"in r;if(a)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(e){return e&&u.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function f(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function y(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function b(e){var t=new FileReader,r=y(t);return t.readAsArrayBuffer(e),r}function m(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function w(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:o&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():a&&s&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=m(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(e)||d(e))?this._bodyArrayBuffer=m(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):o&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=p(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(s)return this.blob().then(b);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,r,o,n,s=p(this);if(s)return s;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=y(t),o=/charset=([A-Za-z0-9_-]+)/.exec(e.type),n=o?o[1]:"utf-8",t.readAsText(e,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),o=0;o-1?n:o),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in r)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function _(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(o),decodeURIComponent(n))}})),t}function E(e,t){if(!(this instanceof E))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},w.call(g.prototype),w.call(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},E.error=function(){var e=new E(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var T=[301,302,303,307,308];E.redirect=function(e,t){if(-1===T.indexOf(t))throw new RangeError("Invalid status code");return new E(null,{status:t,headers:{location:e}})},t.DOMException=r.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function A(e,o){return new Promise((function(n,i){var u=new g(e,o);if(u.signal&&u.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var d=new XMLHttpRequest;function f(){d.abort()}if(d.onload=function(){var e,t,r={statusText:d.statusText,headers:(e=d.getAllResponseHeaders()||"",t=new h,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();try{t.append(o,n)}catch(e){console.warn("Response "+e.message)}}})),t)};0===u.url.indexOf("file://")&&(d.status<200||d.status>599)?r.status=200:r.status=d.status,r.url="responseURL"in d?d.responseURL:r.headers.get("X-Request-URL");var o="response"in d?d.response:d.responseText;setTimeout((function(){n(new E(o,r))}),0)},d.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},d.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request timed out"))}),0)},d.onabort=function(){setTimeout((function(){i(new t.DOMException("Aborted","AbortError"))}),0)},d.open(u.method,function(e){try{return""===e&&r.location.href?r.location.href:e}catch(t){return e}}(u.url),!0),"include"===u.credentials?d.withCredentials=!0:"omit"===u.credentials&&(d.withCredentials=!1),"responseType"in d&&(s?d.responseType="blob":a&&(d.responseType="arraybuffer")),o&&"object"==typeof o.headers&&!(o.headers instanceof h||r.Headers&&o.headers instanceof r.Headers)){var p=[];Object.getOwnPropertyNames(o.headers).forEach((function(e){p.push(c(e)),d.setRequestHeader(e,l(o.headers[e]))})),u.headers.forEach((function(e,t){-1===p.indexOf(t)&&d.setRequestHeader(t,e)}))}else u.headers.forEach((function(e,t){d.setRequestHeader(t,e)}));u.signal&&(u.signal.addEventListener("abort",f),d.onreadystatechange=function(){4===d.readyState&&u.signal.removeEventListener("abort",f)}),d.send(void 0===u._bodyInit?null:u._bodyInit)}))}A.polyfill=!0,r.fetch||(r.fetch=A,r.Headers=h,r.Request=g,r.Response=E),t.Headers=h,t.Request=g,t.Response=E,t.fetch=A}({})}(o),o.fetch.ponyfill=!0,delete o.fetch.polyfill;var n=r.fetch?r:o;(t=n.fetch).default=n.fetch,t.fetch=n.fetch,t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response,e.exports=t},127:function(e,t,r){"use strict";r.d(t,"a",(function(){return _}));var o=r(0),n=r(122),s=r.n(n),i=(()=>{const e=async(e,t,r,o)=>{const n=new URL(t,e).toString(),i=o?{"content-type":"application/json"}:void 0;return s()(n,{body:o?JSON.stringify(o):void 0,method:r,headers:{accept:"application/json",...i}}).then(e=>{if(!e.ok)throw console.error({description:"HTTP error",response:e}),new Error("HTTP error! status: "+e.status);return e.json()})};return{get:async(t,r)=>e(t,r,"GET"),post:async(t,r,o)=>e(t,r,"POST",o),put:async(t,r,o)=>e(t,r,"PUT",o),delete:async(t,r)=>e(t,r,"DELETE")}})(),a=async(e,t)=>i.post("https://newtail-media.newtail.com.br/v1/rma/",e,t).then(e=>{if(e.validations&&e.validations.length>0)throw console.error(JSON.stringify({description:"Ads validation error",response:e},null,2)),new Error("Ads validation error");return e}),u=e=>Object.entries(e).filter(([,e])=>e instanceof Array).map(([e,t])=>[e,t.filter(e=>"product_sku"in e)]).filter(([e,t])=>t.length>0),d=e=>{var t;return{skuId:e.product_sku,sellerId:null!=(t=e.seller_id)?t:"1",productId:e.product_metadata.productId}},c=(e,t,r)=>({product:e,advertisement:{eventUrls:{click:t.click_url,impression:t.impression_url,view:t.view_url},eventParameters:btoa(t.impression_url),sponsoredBySellerId:r.sellerId}}),l=({selectedFacets:e,attributeSynonyms:t,attributePrefix:r})=>{if(!e||!e.length)return;const o=null==t?void 0:t.map(e=>e.toLowerCase()),n=null==r?void 0:r.toLowerCase(),s=e.filter(e=>{const t=e.key.toLowerCase();return(null==o?void 0:o.includes(t))||n&&t.startsWith(n)});return s.length>0?s:void 0},f=e=>{var t;return null==(t=l({selectedFacets:e,attributeSynonyms:["categoria","c"],attributePrefix:"category"}))?void 0:t.map(e=>e.value).join(" > ")},h=e=>{var t;return null==(t=l({selectedFacets:e,attributeSynonyms:["brand","b"]}))?void 0:t.map(e=>e.value)[0]},p=e=>{var t;return null==(t=l({selectedFacets:e,attributeSynonyms:["productClusterIds","productClusterNames"]}))?void 0:t.map(e=>"product_cluster/"+e.value)},y=e=>{const{category:t,brand:r,tags:o}=(n=e.search.selectedFacets,{category:f(n),brand:h(n),tags:p(n)});var n;return{brand_name:r,category_name:t,tags:o,context:(({term:e,category:t,brand:r,skuId:o})=>e?"search":t?"category":r?"brand_page":o?"product_page":"home")({term:e.search.term,category:t,brand:r,skuId:e.search.skuId}),placements:e.placements,channel:e.identity.channel,term:e.search.term,session_id:e.identity.sessionId,user_id:e.identity.userId,product_sku:e.search.skuId}},b=async(e,t,r)=>{const o=y(e),n=u(await a(e.identity.publisherId,o));return{sponsoredProducts:((e,t,r)=>{const o={},n=[];for(const[s,i]of t)for(const t of i){const i=d(t),a=e.find(e=>r(e,i));a?(null!=o[s]||(o[s]=[]),o[s].push(c(a,t,i))):n.push(t)}return{byPlacement:o,failed:n}})(await t((e=>e.flatMap(([e,t])=>t).map(e=>d(e)))(n),e.identity),n,r),banners:void 0,sponsoredBrands:void 0}},m="undefined"!=typeof globalThis&&globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},w=Symbol.for("vtex.ads.react.context"),v=m[w],g=null!=v?v:function(){const e=Object(o.createContext)(void 0);return m[w]=e,e}();function _({placement:e,type:t,amount:r,term:n,selectedFacets:s,skuId:i,enabled:a=!0}){var u,d,c;const l=Object(o.useContext)(g),f=s?s.map(e=>`${e.key}:${e.value}`).join(", "):"none",[h,p]=Object(o.useState)({ads:[],failed:[],isLoading:Boolean(l)&&a,error:void 0}),[y,m]=Object(o.useState)(0),w=Object(o.useRef)(!1),v=Object(o.useRef)(l);v.current=l;return Object(o.useEffect)(()=>{if(!a)return void p({ads:[],failed:[],isLoading:!1,error:void 0});if(!l){const e=setTimeout(()=>{if(!w.current&&!v.current){w.current=!0;!function(e,t){"dev"!==t&&"unknown"!==t||console.warn(e)}("[vtex-ads-react] useAds was called without an AdsProvider. Returning a no-op result. Wrap your tree with .",function(){try{if("undefined"!=typeof window){const e=window.__RUNTIME__;return e&&"boolean"==typeof e.production?!1===e.production?"dev":"prod":"unknown"}return"unknown"}catch(e){return"unknown"}}())}},0);return p({ads:[],failed:[],isLoading:!1,error:void 0}),()=>clearTimeout(e)}p(e=>({...e,isLoading:!0}));const o={identity:l.identity,search:{selectedFacets:s,term:n,skuId:i},placements:{[e]:{quantity:r,types:[t]}}};b(o,l.hydrationStrategy.fetcher,l.hydrationStrategy.matcher).then(t=>{p({ads:t.sponsoredProducts.byPlacement[e],failed:t.sponsoredProducts.failed||[],isLoading:!1,error:void 0})}).catch(e=>{p({ads:[],failed:[],isLoading:!1,error:e})})},[e,t,r,n,f,i,a,null==(u=null==l?void 0:l.identity)?void 0:u.accountName,null==(d=null==l?void 0:l.identity)?void 0:d.publisherId,null==(c=null==l?void 0:l.hydrationStrategy)?void 0:c.key,y]),{ads:h.ads,failed:h.failed,isLoading:h.isLoading,error:h.error,refresh:()=>{m(e=>(e+1)%100)}}}}}]);