"use strict";(()=>{var V=Object.defineProperty;var F=(r,t,e)=>t in r?V(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var o=(r,t,e)=>F(r,typeof t!="symbol"?t+"":t,e);var w=[".vtexcommercestable.com.br"],K=new Set(["session_start","page_view","view_item","view_item_list","select_item","view_promotion","select_promotion","add_to_cart","view_cart","begin_checkout","add_shipping_info","add_payment_info","form_start","form_submit","purchase"]),U="nmu_",E="purchase",N="default-order-form",W=/^\/checkout\/orderplaced\/?$/i,j="orderform",G="checkout.vtex.com",X="checkout.vtex.com__orderFormId",S="__ofid=",P=(r,t)=>{for(let e of r.split(";")){let n=e.trim(),s=n.indexOf("=");if(s===-1||n.slice(0,s)!==t)continue;let i=n.slice(s+1);if(i==="")return null;try{return decodeURIComponent(i)}catch(a){return i}}return null},q=r=>{var t;try{let e=(t=r.localStorage)==null?void 0:t.getItem(j);if(!e)return null;let n=JSON.parse(e);return h(n)?d(n.id):null}catch(e){return null}},B=r=>{var t,e;try{let n=(e=(t=r.document)==null?void 0:t.cookie)!=null?e:"",s=P(n,G);return d(s!==null?s.startsWith(S)?s.slice(S.length):s:P(n,X))}catch(n){return null}},C=r=>({dataLayer:()=>(Array.isArray(r.dataLayer)||(r.dataLayer=[]),r.dataLayer),orderForm:()=>{var t,e;return(e=(t=r.vtexjs)==null?void 0:t.checkout)==null?void 0:e.orderForm},storedOrderFormId:()=>{var t;return(t=q(r))!=null?t:B(r)}}),h=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),d=r=>typeof r=="string"&&r.trim().length>0?r:null,O=r=>r===null||r===N||r.includes("order-form")?null:r,m=class{constructor(t,e,n){o(this,"vtex",t);o(this,"page",e);o(this,"hash",n);o(this,"sink",null);o(this,"lastEmail",null);o(this,"hashRun",0)}start(t){this.sink=t,this.readOrderForm();let e=this.vtex.dataLayer();for(let n of[...e])this.translate(n,!0);this.interceptPush(e),this.orderPlaced()}interceptPush(t){let e=t.push.bind(t);t.push=(...n)=>{let s=e(...n);try{this.readOrderForm();for(let i of n)this.translate(i,!1)}catch(i){}return s}}translate(t,e){var i,a;if(!h(t))return;let n=d(t.event);if(n===null)return;if(n.startsWith(U)){(i=this.sink)==null||i.track(n,Y(t));return}if(!K.has(n)||e&&n==="page_view")return;let s=J(t);if(n===E){this.purchase(this.purchaseCheckout(t),s);return}(a=this.sink)==null||a.track(n,s)}purchaseCheckout(t){let e=this.orderPlacedGroup();if(e!==null)return e;let n=h(t.ecommerce)?t.ecommerce:{};return d(n.transaction_id)}purchase(t,e){let n=this.sink;if(n!==null){if(t!==null){if(!n.claimPurchase(t))return;n.setKeys({checkoutId:t})}n.track(E,e)}}orderPlaced(){let t=this.orderPlacedGroup();t!==null&&this.purchase(t)}orderPlacedGroup(){try{let t=new URL(this.page.url());return W.test(t.pathname)?d(t.searchParams.get("og")):null}catch(t){return null}}readOrderForm(){var i,a;let t=this.vtex.orderForm(),e=h(t)?t:{},n=(i=O(d(e.orderFormId)))!=null?i:O(this.vtex.storedOrderFormId());(a=this.sink)==null||a.setKeys({cartId:n});let s=h(e.clientProfileData)?e.clientProfileData:{};this.identify(d(s.email))}identify(t){if(t===this.lastEmail)return;this.lastEmail=t;let e=++this.hashRun;t!==null&&this.hash(t).then(n=>{var s;e===this.hashRun&&n!==null&&((s=this.sink)==null||s.setKeys({customerHash:n}))}).catch(()=>{})}},J=r=>{let t=h(r.ecommerce)?r.ecommerce:null;return Array.isArray(t==null?void 0:t.items)?{items:t.items}:void 0},Y=r=>{let t={};for(let[e,n]of Object.entries(r))e==="event"||e.startsWith("gtm.")||(t[e]=n);return t};var A=async r=>{var s;let t=typeof r=="string"?r.trim().toLowerCase():"";if(t.length===0)return null;let e=(s=globalThis.crypto)==null?void 0:s.subtle;if(e===void 0)return null;let n=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("")};var R=r=>Array.from(r,t=>t.toString(16).padStart(2,"0")).join(""),b=(r,t)=>({id(){if(typeof(r==null?void 0:r.randomUUID)=="function")return r.randomUUID();let e=new Uint8Array(16);if(typeof(r==null?void 0:r.getRandomValues)=="function")return r.getRandomValues(e),R(e);for(let n=0;n{if(typeof r!="object"||r===null)return!1;let t=r;return t.v===1&&typeof t.visitorId=="string"&&t.visitorId.length>0&&typeof t.sessionId=="string"&&t.sessionId.length>0&&typeof t.lastActivity=="number"&&Array.isArray(t.purchased)&&t.purchased.every(e=>typeof e=="string")},y=class{constructor(t,e,n,s){o(this,"storage",t);o(this,"cookies",e);o(this,"clock",n);o(this,"random",s);o(this,"state");o(this,"firstVisit");let i=this.read();if(i!==null){this.state=i,this.firstVisit=!1;return}let a=this.readCookie();this.firstVisit=a===null,this.state={v:1,visitorId:a!=null?a:s.id(),sessionId:s.id(),lastActivity:n.now(),purchased:[]}}touch(){this.sync();let t=this.clock.now();return t-this.state.lastActivity>18e5&&(this.state.sessionId=this.random.id()),this.state.lastActivity=t,this.write(),{visitorId:this.state.visitorId,sessionId:this.state.sessionId}}claimPurchase(t){return this.sync(),this.state.purchased.includes(t)?!1:(this.state.purchased=[...this.state.purchased,t].slice(-50),this.write(),!0)}sync(){let t=this.read();t!==null&&t.visitorId===this.state.visitorId&&(this.state=t)}read(){try{let t=this.storage.get(L);if(t===null)return null;let e=JSON.parse(t);return $(e)?e:null}catch(t){return null}}readCookie(){try{let t=this.cookies.get(g);return t&&t.length>0?t:null}catch(t){return null}}write(){try{this.storage.set(L,JSON.stringify(this.state))}catch(t){}try{this.cookies.set(g,this.state.visitorId,3456e4)}catch(t){}}};var z=1e4,Z=(r,t)=>{for(let e of r.cookie.split(";")){let[n,...s]=e.trim().split("=");if(n===t)return decodeURIComponent(s.join("="))}return null},H=r=>({storage:{get:t=>r.localStorage.getItem(t),set:(t,e)=>r.localStorage.setItem(t,e)},cookies:{get:t=>Z(r.document,t),set:(t,e,n)=>{if(t!==g)return;let s=r.location.protocol==="https:"?"; Secure":"",i=`${encodeURIComponent(e)}; max-age=${n}; path=/; SameSite=Lax${s}`;r.document.cookie=`nmb_px_vid=${i}`}},transport:{post:(t,e)=>r.fetch(t,{method:"POST",body:e,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"},...typeof AbortSignal.timeout=="function"?{signal:AbortSignal.timeout(z)}:{}}),beacon:(t,e)=>typeof r.navigator.sendBeacon=="function"&&r.navigator.sendBeacon(t,e)},clock:{now:()=>Date.now(),later:(t,e)=>{r.setTimeout(t,e)}},page:{url:()=>r.location.href,referrer:()=>r.document.referrer,onPageHide:t=>r.addEventListener("pagehide",t)},random:b(r.crypto,Math.random)});var Q=["gclid","fbclid","ttclid"],x={utms:{},clickIds:{},referrer:null},tt="utm_",_=r=>r.toLowerCase().replace(/^www\./,""),et=r=>{try{return new URL(r).hostname}catch(t){return null}},k=class{constructor(t,e){o(this,"suffixes",e);o(this,"hosts");this.hosts=new Set(t.map(_))}isInternal(t,e){let n=_(t);return n===_(e)||this.hosts.has(n)?!0:this.suffixes.some(s=>n.endsWith(s.toLowerCase()))}},T=(r,t,e)=>{let n;try{n=new URL(r)}catch(l){return null}let s={},i={};n.searchParams.forEach((l,u)=>{l.length!==0&&u.startsWith(tt)&&(s[u]=l)});for(let l of Q){let u=n.searchParams.get(l);u&&(i[l]=u)}let a=t?et(t):null,f=a!==null&&!e.isInternal(a,n.hostname);return Object.keys(s).length>0||Object.keys(i).length>0||f?{utms:s,clickIds:i,referrer:f?t:null}:null};var rt=20,nt=2e3,st="page_view",it=["cartId","checkoutId","customerHash"],c=(r,t)=>{try{return t()}catch(e){return r}},v=class{constructor(t,e){o(this,"config",t);o(this,"ports",e);o(this,"site");o(this,"visitor",null);o(this,"keys",{});o(this,"queue",[]);o(this,"timerPending",!1);var n;this.site=new k(t.siteHosts,(n=t.internalHostSuffixes)!=null?n:[])}start(t){c(void 0,()=>{var i;let e=this.store(),{page:n}=this.ports,s={marks:(i=T(n.url(),n.referrer(),this.site))!=null?i:x,firstVisit:e.firstVisit};n.onPageHide(()=>this.flushOnHide()),c(void 0,()=>t==null?void 0:t.start(this)),this.enqueue(this.build(st,void 0,s))})}track(t,e){c(void 0,()=>{this.enqueue(this.build(t,e))})}setKeys(t){c(void 0,()=>{let e={...this.keys};for(let n of it){if(!(n in t))continue;let s=t[n];typeof s=="string"&&s.trim().length>0?e[n]=s:delete e[n]}this.keys=e})}claimPurchase(t){return c(!1,()=>this.store().claimPurchase(t))}store(){if(this.visitor===null){let{storage:t,cookies:e,clock:n,random:s}=this.ports;this.visitor=new y(t,e,n,s)}return this.visitor}build(t,e,n=null){var u,I;let{clock:s,page:i,random:a}=this.ports,f=this.store().touch(),p=(u=n==null?void 0:n.marks)!=null?u:x,l={visitorId:f.visitorId,sessionId:f.sessionId,eventId:a.id(),event:t,eventTime:new Date(s.now()).toISOString(),firstVisit:(I=n==null?void 0:n.firstVisit)!=null?I:!1,page:ot(i.url()),referrer:p.referrer,utms:{...p.utms},clickIds:{...p.clickIds},keys:{...this.keys}};return e!==void 0&&(l.eventData=e),l}enqueue(t){if(this.queue.push(t),this.queue.length>=rt){this.flush();return}this.timerPending||(this.timerPending=!0,this.ports.clock.later(()=>{this.timerPending=!1,this.flush()},nt))}take(){if(this.queue.length===0)return null;let t=this.queue;return this.queue=[],JSON.stringify({events:t})}flush(){let t=this.take();t!==null&&this.post(t)}post(t){c(void 0,()=>{this.ports.transport.post(this.config.endpoint,t).catch(()=>{})})}flushOnHide(){c(void 0,()=>{let t=this.take();if(t===null)return;c(!1,()=>this.ports.transport.beacon(this.config.endpoint,t))||this.post(t)})}},ot=r=>c({hostname:"",path:""},()=>{let t=new URL(r);return{hostname:t.hostname,path:t.pathname}});var M=(r,t)=>{if(typeof r!="object"||r===null)return null;let e=r;if(e.platform!==t||typeof e.endpoint!="string"||!/^https?:\/\//.test(e.endpoint))return null;let s=(Array.isArray(e.siteHosts)?e.siteHosts:[]).filter(i=>typeof i=="string"&&i.length>0);return{endpoint:e.endpoint,platform:t,siteHosts:s}};var at="__nemuBifrostPixel",D="__nemuBifrostPixelStarted",lt=()=>{let r=window;if(r[D]===!0)return;let t=M(r[at],"vtex");if(t===null)return;r[D]=!0;let e=H(window),n=new v({endpoint:t.endpoint,siteHosts:t.siteHosts,internalHostSuffixes:w},e),s=C(window);n.start(new m(s,e.page,A))};try{lt()}catch(r){}})();