mk-sdk-git 1.1.10 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mk-sdk.js +1 -1
- package/package.json +1 -1
- package/src/core/config.js +8 -2
- package/src/ecommerce/extractors.js +43 -8
- package/src/ecommerce/funnel.js +38 -4
- package/src/platforms/hybris.js +36 -1
- package/src/platforms/index.js +26 -0
- package/src/platforms/nuvemshop.js +13 -0
- package/src/platforms/shopify.js +9 -0
- package/src/platforms/vtex.js +14 -0
- package/src/platforms/wake.js +17 -0
package/dist/mk-sdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var We=Object.defineProperty;var E=(t,e)=>{for(var o in e)We(t,o,{get:e[o],enumerable:!0})};var dt={collectorUrl:"https://api-collector.mk3dlabs.com",appUrl:"https://mkfashion.mk3dlabs.com/visualizer",apiUrl:"https://mkfashion-new-api.mk3dlabs.com"},Xe={},M=null;function pt(){if(M)return M;let t=null;try{t=document.currentScript||document.querySelector("script[data-mk-project]")||document.querySelector('script[src*="mk-sdk"]')||document.querySelector('script[src*="mk-pixel"]')}catch(i){}let e=i=>{try{return t&&t.getAttribute(i)}catch(a){return null}},o=e("data-mk-project")||e("data-mk-client")||window.__MK&&(window.__MK.projectId||window.__MK.clientSlug)||null,r=e("data-mk-product")||window.__MK&&window.__MK.product||"mk-fashion",n=e("data-mk-collector")||window.__MK&&window.__MK.collectorUrl||Xe.collectorUrl||dt.collectorUrl;return M={projectId:o,product:r,collectorUrl:n,appUrl:window.__MK&&window.__MK.appUrl||dt.appUrl,apiUrl:window.__MK&&window.__MK.apiUrl||dt.apiUrl,debug:!!(e("data-mk-debug")!==null||window.__MK&&window.__MK.debug||/[?&]mkdebug\b/.test(location.search)),observe:!!(window.__MK&&window.__MK.observe),forceButton:!!(window.__MK&&window.__MK.forceButton),anchor:window.__MK&&window.__MK.anchor||null,cartRedirect:!(window.__MK&&window.__MK.cartRedirect===!1),cartBehavior:window.__MK&&window.__MK.cartBehavior||null,cartOpenSelector:window.__MK&&window.__MK.cartOpenSelector||null,autoTrack:e("data-mk-no-autotrack")===null,batchIntervalMs:2e3,batchMaxSize:20,engagementIntervalMs:15e3},M}function f(){return M||pt()}function h(...t){let e=f();e&&e.debug&&typeof console!="undefined"&&console.log("[mk-sdk]",...t)}var qt="_mk_vid",zt="_mk_sid",U=null,D=null;function H(){return typeof crypto!="undefined"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function $t(){if(U)return U;try{let t=localStorage.getItem(qt);return t||(t="v_"+H(),localStorage.setItem(qt,t)),U=t,t}catch(t){return U="v_"+H(),U}}function Kt(){if(D)return D;try{let t=sessionStorage.getItem(zt);return t||(t="s_"+H(),sessionStorage.setItem(zt,t)),D=t,t}catch(t){return D="s_"+H(),D}}var Ht=[/email/i,/e-?mail/i,/cpf/i,/cnpj/i,/phone/i,/telefone/i,/celular/i,/address/i,/endereco/i,/cep/i,/zip/i,/card/i,/cartao/i,/cvv/i,/password/i,/senha/i,/token/i,/\bnome\b/i,/fullname/i,/firstname/i,/lastname/i,/sobrenome/i,/birth/i,/nascimento/i,/rg\b/i],Jt={imageUrl:1,image:1,thumbnail:1,photo:1,imageBase64:1,src:1},ft=2e3;function Vt(t){for(let e=0;e<Ht.length;e++)if(Ht[e].test(t))return!0;return!1}function Gt(t){if(!t||typeof t!="object"||Array.isArray(t))return typeof t=="string"&&t.length>ft?t.slice(0,200)+"...[truncated "+t.length+"B]":t;let e={};for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||Vt(o))continue;let r=t[o];if(Jt[o]){e[o+"Present"]=!!r;continue}if(typeof r=="string"&&r.length>ft){e[o]=r.slice(0,200)+"...[truncated "+r.length+"B]";continue}if(r&&typeof r=="object"&&!Array.isArray(r)){e[o]=Ye(r);continue}e[o]=r}return e}function Ye(t){let e={};for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||Vt(o))continue;let r=t[o];if(Jt[o]){e[o+"Present"]=!!r;continue}if(typeof r=="string"&&r.length>ft){e[o]=r.slice(0,200)+"...[truncated]";continue}e[o]=r}return e}var J=[],mt=null,I=null,Ze=["off","pdp_tryon","pdp","all","tryon_engaged"],ht,gt=null,V="unknown",P=[],L=null;function Xt(){let t=f();return"mk_engaged_"+(t&&t.projectId||"")}function Yt(){if(L!==null)return L;try{L=localStorage.getItem(Xt())==="1"}catch(t){L=!1}return L}function Zt(){if(!Yt()){L=!0;try{localStorage.setItem(Xt(),"1")}catch(t){}G(!1)}}function Qt(t){if(ht===void 0)return"hold";switch(ht){case"off":return"drop";case"all":return"collect";case"pdp":return t==="pdp"?"collect":"drop";case"tryon_engaged":if(Yt())return"collect";case"pdp_tryon":return t!=="pdp"?"drop":V==="available"?"collect":V==="unavailable"?"drop":"hold";default:return"collect"}}function G(t){if(!P.length)return;let e=[];for(let o of P){let r=Qt(o._pt);r==="collect"?re(o.name,o.params,o.ts):r==="hold"&&!t&&e.push(o)}P=e}function yt(t){ht=Ze.indexOf(t)>=0?t:"all",G(!1)}function te(t){V=t==="available"?"available":"unavailable",G(!1)}function ee(t){G(!0),I=t,gt=t&&t.pageType||null,V="unknown"}function l(t,e,o){if(!f().projectId){(l._pre=l._pre||[]).push({name:t,params:e,ts:o||Date.now()}),l._pre.length>50&&l._pre.shift();return}if(l._pre&&l._pre.length){let n=l._pre;l._pre=[];for(let i of n)Wt(i.name,i.params,i.ts)}Wt(t,e,o)}function Wt(t,e,o){let r=Qt(gt);if(r==="collect"){re(t,e,o);return}if(r==="drop"){h("descartado (escopo)",t);return}P.push({name:t,params:e,ts:o||Date.now(),_pt:gt}),P.length>300&&P.shift()}function re(t,e,o){let r=f(),n=Gt(e||{}),i="page_"+Qe(t);if(J.push({name:i,ts:o||Date.now(),params:n}),h("queued",t,n),r.observe)try{window.postMessage({__mkpixel:!0,event:{name:i,params:n},site:I?{pageType:I.pageType,platform:I.platform,url:I.url}:null},"*")}catch(a){}if(J.length>=r.batchMaxSize){F();return}mt||(mt=setTimeout(()=>{mt=null,F()},r.batchIntervalMs))}function Qe(t){if(typeof t!="string"||!t)return"unknown";let e=t.replace(/^on/,"");return e=e.replace(/[A-Z]/g,(o,r)=>(r>0?"_":"")+o.toLowerCase()),e.indexOf("page_")===0&&(e=e.slice(5)),e}function F(t){if(J.length===0)return;let e=f();if(!e.projectId||!e.collectorUrl)return;let o=J.splice(0,50),r=JSON.stringify({product:e.product||void 0,visitorId:$t(),sessionId:Kt(),events:o,site:I||void 0}),n=e.collectorUrl+"/v1/track";if(t&&navigator.sendBeacon)try{let i=new Blob([r],{type:"application/json"});navigator.sendBeacon(n+"?projectId="+encodeURIComponent(e.projectId),i);return}catch(i){}fetch(n,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","X-MK-Project-Id":e.projectId},body:r}).catch(()=>{})}function oe(){try{window.addEventListener("pagehide",()=>F(!0)),window.addEventListener("beforeunload",()=>F(!0)),document.addEventListener("visibilitychange",()=>{document.hidden&&F(!0)})}catch(t){}}function C(t){let e=[];try{let o=document.querySelectorAll('script[type="application/ld+json"]');for(let r of o){let n;try{n=JSON.parse(r.textContent)}catch(a){continue}let i=[];Array.isArray(n)?i.push(...n):n["@graph"]?i.push(...n["@graph"]):i.push(n);for(let a of i){if(!a||!a["@type"])continue;let s=Array.isArray(a["@type"])?a["@type"]:[a["@type"]];(!t||t.some(u=>s.includes(u)))&&e.push(a)}}}catch(o){}return e}var ne=["off","pdp_tryon","pdp","all","tryon_engaged"],tr="all",er=30*60*1e3,R=null;function j(){if(R)return R;let t=f();return!t.projectId||!t.apiUrl?(R=Promise.resolve(null),R):(R=fetch(t.apiUrl+"/projects/"+t.projectId).then(e=>e.ok?e.json():null).then(e=>e&&e.project||e||null).catch(()=>null),R)}function ie(t){let e=t&&t.analytic&&t.analytic.scope;return ne.indexOf(e)>=0?e:tr}var ae=t=>"mk_scope_"+t;function ce(t){try{let e=localStorage.getItem(ae(t));if(!e)return null;let o=JSON.parse(e);return!o||typeof o.exp!="number"||o.exp<Date.now()?null:ne.indexOf(o.scope)>=0?o.scope:null}catch(e){return null}}function le(t,e){try{localStorage.setItem(ae(t),JSON.stringify({scope:e,exp:Date.now()+er}))}catch(o){}}var wt={};E(wt,{addToCart:()=>ir,detect:()=>or,id:()=>rr,openCartDrawer:()=>lr,resolveSku:()=>nr});var rr="shopify";function or(){return!!(window.Shopify||window.ShopifyAnalytics)}function nr(){let t=window;return t.ShopifyAnalytics&&t.ShopifyAnalytics.meta&&t.ShopifyAnalytics.meta.product?{value:String(t.ShopifyAnalytics.meta.product.id),source:"shopify"}:null}var W=t=>String(t==null?"":t).trim().toLowerCase();async function ir({size:t,color:e,sku:o,quantity:r}){let n=(location.pathname.split("/products/")[1]||"").split(/[?#]/)[0];if(!n)throw new Error("shopify: sem handle de produto na URL (n\xE3o \xE9 PDP?)");let a=(await fetch("/products/"+n+".js").then(c=>c.json())).variants||[],s=c=>[c.option1,c.option2,c.option3].concat(String(c.title||"").split("/")).map(W).filter(Boolean),u=(c,x)=>s(c).indexOf(W(x))>=0,d=c=>(!t||u(c,t))&&(!e||u(c,e)),m=null;if((t||e)&&(m=a.find(c=>d(c)&&c.available)||a.find(d)),!m&&o&&(m=a.find(c=>W(c.sku)===W(o))),m||(m=a.find(c=>c.available)||a[0]),!m)throw new Error("shopify: variante n\xE3o encontrada");let g=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:m.id,quantity:r||1}]})});if(!g.ok)throw new Error("shopify: /cart/add.js HTTP "+g.status);return{platform:"shopify",variantId:m.id,size:m.title,sku:m.sku||null}}var ar=["[data-cart-drawer-toggle]",'[data-action="open-cart-drawer"]','[data-action="open-cart"]',".js-cart-drawer-open",".js-drawer-open-cart",".cart-drawer-toggle",".js-cart-toggle",'[aria-controls="CartDrawer"]','[aria-controls="cart-drawer"]',"#cart-icon-bubble","#lk-cart-icon",".header__cart",".site-header__cart",".cart-link",".header-cart",'a[href="/cart"]','a[href$="/cart"]'];function cr(t){try{let e=t.getBoundingClientRect();return e.width>0&&e.height>0&&getComputedStyle(t).visibility!=="hidden"}catch(e){return!1}}function lr(){let t=null;for(let e of ar)try{if(t=[...document.querySelectorAll(e)].find(cr),t)break}catch(o){}return t?(setTimeout(()=>{try{t.click()}catch(e){}},300),!0):!1}var xt={};E(xt,{addToCart:()=>pr,detect:()=>ur,id:()=>sr,resolveSku:()=>dr});var sr="hybris";function ur(){return!!(window.ACC&&window.ACC.config)}function dr(){let t=(location.pathname||"").match(/\/p\/([^/?#]+)/);return t&&t[1]?{value:decodeURIComponent(t[1]),source:"hybris/url"}:null}var se=t=>String(t==null?"":t).trim().toLowerCase();async function pr({size:t,quantity:e}){let o=[...document.querySelectorAll('.js-product-select-size, a[data-code], [class*="select-size"]')].filter(g=>g.getAttribute&&g.getAttribute("data-code")),r=t?o.find(g=>se(g.textContent)===se(t)):null;r||(r=o.find(g=>g.offsetParent!==null)||o[0]);let n=r&&r.getAttribute("data-code");if(!n)throw new Error("hybris: variante (data-code) n\xE3o encontrada");let i=document.getElementById("product--add-to-cart-form")||document.querySelector('form[action*="/cart/add"]'),a=i&&i.querySelector('[name="CSRFToken"]'),s=a&&a.value,u=i&&i.getAttribute("action")||"/cart/add";if(!s)throw new Error("hybris: CSRFToken n\xE3o encontrado");let d=new URLSearchParams;d.set("productCodePost",n),d.set("qty",String(e||1)),d.set("CSRFToken",s);let m=await fetch(u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:d.toString()});if(!m.ok)throw new Error("hybris: "+u+" HTTP "+m.status);return{platform:"hybris",productCode:n,size:r.textContent.trim()}}var bt={};E(bt,{addToCart:()=>gr,detect:()=>mr,id:()=>fr,resolveSku:()=>hr});var fr="vtex";function mr(){return!!(window.vtex||window.vtexjs||window.vtxctx||window.skuJson_0)}function hr(){let t=window;return t.vtxctx&&t.vtxctx.skus&&t.vtxctx.skus[0]?{value:String(t.vtxctx.skus[0]),source:"vtex/vtxctx"}:t.skuJson_0&&t.skuJson_0.skus&&t.skuJson_0.skus[0]?{value:String(t.skuJson_0.skus[0].sku),source:"vtex/skuJson"}:null}var X=t=>String(t==null?"":t).trim().toLowerCase();async function gr({size:t,quantity:e}){let o=window.skuJson_0&&window.skuJson_0.skus||[];if(!o.length)throw new Error("vtex: skuJson_0 indispon\xEDvel");let r=i=>X(i.skuname)===X(t)||i.dimensions&&Object.values(i.dimensions).some(a=>X(a)===X(t)),n=t?o.find(i=>r(i)&&i.available)||o.find(r):null;if(n||(n=o.find(i=>i.available)||o[0]),!n)throw new Error("vtex: variante n\xE3o encontrada");if(window.vtexjs&&window.vtexjs.checkout&&window.vtexjs.checkout.addToCart)return await window.vtexjs.checkout.addToCart([{id:parseInt(n.sku,10),quantity:e||1,seller:"1"}]),{platform:"vtex",skuId:n.sku,size:n.skuname||t};throw new Error("vtex: vtexjs.checkout indispon\xEDvel")}var kt={};E(kt,{addToCart:()=>kr,detect:()=>xr,id:()=>yr,resolveSku:()=>br,skipRedirect:()=>wr});var yr="nuvemshop",wr=!0;function xr(){return!!(window.LS&&(window.LS.cart||window.LS.addToCart))}function br(){try{let t=window.LS,e=t&&t.variants||[],o=document.querySelector('[name="variant_id"]'),r=o&&o.value?e.find(n=>String(n.id)===String(o.value)):null;if(r||(r=e.find(n=>n.available!==!1&&n.sku)||e.find(n=>n.sku)||e[0]),r&&r.sku)return{value:String(r.sku),source:"nuvemshop/variant"};if(t&&t.product&&t.product.sku)return{value:String(t.product.sku),source:"nuvemshop/product"}}catch(t){}return null}var Y=t=>String(t==null?"":t).trim().toLowerCase();async function kr({size:t,quantity:e}){let o=document.getElementById("product_form")||document.querySelector('.js-product-form, form[action*="/comprar"]');if(!o)throw new Error("nuvemshop: #product_form n\xE3o encontrado");t&&o.querySelectorAll('select[name^="variation"]').forEach(i=>{let a=[...i.options].find(s=>Y(s.textContent).includes(Y(t))||Y(s.value)===Y(t));a&&(i.value=a.value,i.dispatchEvent(new Event("change",{bubbles:!0})))});let r=o.querySelector('[name="quantity"]');return r&&e&&(r.value=String(e)),await new Promise(i=>setTimeout(i,400)),typeof o.requestSubmit=="function"?o.requestSubmit():o.submit(),{platform:"nuvemshop",variantId:(o.querySelector('[name="variant_id"]')||{}).value||null}}var _t={};E(_t,{addToCart:()=>Tr,detect:()=>vr,id:()=>_r,resolveSku:()=>Sr,skipRedirect:()=>Cr});var _r="wake",Cr=!0;function vr(){return!!(window.StorefrontClient||typeof window.addOrCreateCheckout=="function"||typeof window.addToCartClick=="function")}function Sr(){try{let t=document.querySelector('input[name="product-id"], [data-product-id]'),e=t?t.value||t.getAttribute("data-product-id"):null;if(e)return{value:String(e).trim(),source:"wake/product-id"};let o=(location.pathname||"").match(/-(\d+)\/?(?:[?#]|$)/);if(o)return{value:o[1],source:"wake/url"}}catch(t){}return null}var ue=t=>String(t==null?"":t).trim().toLowerCase();async function Tr({size:t,quantity:e}){if(t){let i=[...document.querySelectorAll("input[attribute-value]")].find(a=>ue(a.getAttribute("attribute-value"))===ue(t));if(i){try{i.checked=!0}catch(a){}try{typeof window.selectAttribute=="function"?window.selectAttribute(i):i.click()}catch(a){}await new Promise(a=>setTimeout(a,600))}}let o=document.querySelector('[name="product-variant-id"]'),r=o&&o.value;if(!r)throw new Error("wake: product-variant-id n\xE3o encontrado");if(typeof window.addOrCreateCheckout!="function")throw new Error("wake: addOrCreateCheckout indispon\xEDvel");if(!await window.addOrCreateCheckout([{productVariantId:Number(r),quantity:e||1,customization:[]}]))throw new Error("wake: addOrCreateCheckout retornou false");return{platform:"wake",productVariantId:r,size:t||null}}var vt={};E(vt,{addToCart:()=>Z,detect:()=>Er,id:()=>Ar,resolveSku:()=>Ct});var Ar="generic";function Er(){return!0}function Ct(){let t=C(["Product"]);if(t[0]){let e=t[0],o=e.sku||e.mpn||e.gtin13||e.productID;if(o)return{value:String(o),source:"jsonld"}}try{let e=document.querySelector('[itemprop="sku"]');if(e){let o=e.getAttribute("content")||(e.textContent||"").trim();if(o)return{value:String(o),source:"microdata"}}}catch(e){}try{let e=window.konfidencyData;if(e&&e.product&&e.product.variants&&e.product.variants[0])return{value:String(e.product.variants[0]),source:"konfidency"}}catch(e){}return null}var Lr=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora/i,Ir=/continuar|como comprar|lista|desejos|favorito/i;async function Z(){let t=document.querySelectorAll("button,[role=button],input[type=submit]");for(let e of t){let o=(e.textContent||e.value||"").replace(/\s+/g," ").trim();if(o&&o.length<40&&Lr.test(o)&&!Ir.test(o))try{return e.click(),{platform:"native-click",clicked:o}}catch(r){}}return{platform:"none",error:"bot\xE3o de carrinho nativo n\xE3o encontrado"}}var pe=[wt,xt,bt,kt,_t],Pr=[["woocommerce",()=>!!(window.wc_add_to_cart_params||window.woocommerce_params)],["lojaintegrada",()=>!!window.LojaIntegrada]],Q;function tt(){return Q||(Q=pe.find(t=>{try{return t.detect()}catch(e){return!1}})||vt,Q)}function fe(){let t=pe.find(e=>{try{return e.detect()}catch(o){return!1}});if(t)return t.id;for(let[e,o]of Pr)try{if(o())return e}catch(r){}return null}function q(){let t=tt();if(t.id!=="generic"&&t.resolveSku)try{let e=t.resolveSku();if(e)return e}catch(e){}return Ct()}async function me(t){t=t||{};let e={size:t.size||t.selectedSize||t.tamanho||null,color:t.color||t.selectedColor||t.colour||t.cor||null,sku:t.sku||t.identifier||t.selectedIdentifier||null,quantity:t.quantity||1},o=tt();try{let r=o.addToCart?await o.addToCart(e):await Z(e);return h("cart: adicionado",r),de(),r}catch(r){h('cart: adapter "'+o.id+'" falhou \u2014 fallback clique nativo',r&&r.message);let n=await Z(e);return de(),n}}function de(){["cart:refresh","cart:updated","cart:build","ajaxProduct:added","product:added-to-cart"].forEach(t=>{try{document.dispatchEvent(new CustomEvent(t))}catch(e){}})}async function he(){let t=tt(),e=f(),o=null;try{o=await j()}catch(i){}let r=o&&o.template&&o.template.cart||o&&o.cart||{},n=r.afterAdd||r.behavior||e.cartBehavior;if(n||(n=e.cartRedirect===!1?"none":"auto"),n==="none")return!1;if(n==="auto"||n==="drawer"){let i=r.openSelector||e.cartOpenSelector;if(i){let a=document.querySelector(i);if(a)return setTimeout(()=>{try{a.click()}catch(s){}},300),!1}else if(t&&t.openCartDrawer){let a=!1;try{a=t.openCartDrawer()}catch(s){}if(a)return!1}}return!0}function ge(){let t=tt();if(t&&t.skipRedirect)return;let e=t&&t.cartUrl||"/cart";setTimeout(()=>{try{window.location.href=e}catch(o){}},250)}var Rr=/\/(thank[_-]?you|orders?\/|pedido[_-]?(confirmado|realizado|finalizado|sucesso)|sucesso|order[_-]?confirmation|compra[_-]?(finalizada|concluida)|orderplaced)/i,jr=/\/checkout/i,Br=/\/(cart|carrinho|sacola|bag)(\/|$|\?|#)/i,Or=/\/(products?|produtos?|p)\//i,Nr=/\/(collections?|categoria|categorias|c|departamento)\//i,Mr=/\/(search|busca|s)(\/|\?)/i;function ye(){try{if(window.__mkPageType)return window.__mkPageType}catch(e){}try{let e=C();for(let o of e){let r=Array.isArray(o["@type"])?o["@type"]:[o["@type"]];if(r.includes("Order")||r.includes("Invoice"))return"purchase";if(r.includes("Product"))return"pdp";if(r.includes("SearchResultsPage"))return"search";if(r.includes("CollectionPage")||r.includes("ItemList"))return"category"}}catch(e){}let t=(location.pathname||"").toLowerCase();return t==="/"||t===""||t==="/home"||t==="/index.html"?"home":Rr.test(t)?"purchase":jr.test(t)?"checkout":Br.test(t)?"cart":Or.test(t)?"pdp":Nr.test(t)?"category":Mr.test(t)?"search":"other"}function we(t){let e=null;try{let o=new URLSearchParams(location.search),r=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],n={};for(let i of r){let a=o.get(i);a&&(n[i.replace("utm_","")]=a)}Object.keys(n).length&&(e=n)}catch(o){}return{url:location.href,pathname:location.pathname,referrer:document.referrer||null,title:document.title||null,pageType:t,utm:e,userAgent:navigator.userAgent,language:navigator.language,viewport:window.innerWidth+"x"+window.innerHeight,platform:Ur()}}function Ur(){return fe()}var St={},Dr=null,z=0,xe=!1;function be(t){xe||(xe=!0,ke(t),Fr(),qr(),zr(),$r(),Kr(t))}function ke(t){St={};let e=ye(),o=we(e);if(ee(o),l("view",{url:location.href,pathname:location.pathname,referrer:document.referrer||null,title:document.title||null,pageType:e}),typeof t=="function")try{t(e,o)}catch(r){}}function Fr(){if(!document.body)return;let t={A:1,BUTTON:1,INPUT:1,SELECT:1,TEXTAREA:1},e=0;document.body.addEventListener("click",o=>{try{let r=Date.now();if(r-e<100)return;e=r;let n=o.target;for(let s=0;s<5&&n&&n!==document.body&&!(t[n.tagName]||n.getAttribute&&n.getAttribute("role")==="button");s++)n=n.parentElement;if(!n||!t[n.tagName]&&!(n.getAttribute&&n.getAttribute("role")==="button"))return;let i={tag:n.tagName},a=n.tagName==="INPUT"||n.tagName==="TEXTAREA"?n.value:n.textContent;i.text=(a||"").replace(/\s+/g," ").trim().substring(0,100),n.href&&(i.href=String(n.href).substring(0,500)),n.id&&(i.id=n.id),n.className&&typeof n.className=="string"&&(i.classes=n.className.trim().substring(0,200)),l("click",i)}catch(r){}},{capture:!0,passive:!0})}function qr(){let t=[25,50,75,100],e=null,o=()=>{try{let r=window.scrollY||document.documentElement.scrollTop||0,n=Math.max(document.body&&document.body.scrollHeight||0,document.documentElement&&document.documentElement.scrollHeight||0);if(n<=0)return;let i=Math.min(100,Math.floor((r+window.innerHeight)/n*100));for(let a of t)i>=a&&!St[a]&&(St[a]=!0,l("scroll_depth",{depth:a}))}catch(r){}};o(),window.addEventListener("scroll",()=>{e||(e=setTimeout(()=>{e=null,o()},250))},{passive:!0})}function zr(){document.body&&document.body.addEventListener("submit",t=>{try{let e=t.target;if(!e||e.tagName!=="FORM"||e.querySelector('input[type="password"], input[name*="card"], input[name*="cpf"]'))return;let o="other",r=(e.className||"").toLowerCase(),n=(e.action||"").toLowerCase();e.querySelector('input[type="search"], input[name="q"], input[name="s"]')?o="search":/newsletter|subscribe|mailchimp/.test(r+n)?o="newsletter":/contact|contato/.test(r+n)&&(o="contact"),l("form_submit",{form_id:e.id||"",form_type:o})}catch(e){}},{capture:!0})}function $r(){let t=f();z=Date.now(),Dr=setInterval(()=>{if(document.hidden)return;let e=Date.now(),o=Math.round((e-z)/1e3);z=e,o>0&&o<60&&l("engagement",{url:location.pathname,dwellSec:o})},t.engagementIntervalMs),document.addEventListener("visibilitychange",()=>{if(document.hidden){let e=Math.round((Date.now()-z)/1e3);e>0&&e<600&&l("engagement",{url:location.pathname,dwellSec:e})}z=Date.now()})}function Kr(t){let e=location.href,o=()=>{location.href!==e&&(e=location.href,ke(t))};try{let r=history.pushState,n=history.replaceState;history.pushState=function(){r.apply(this,arguments),setTimeout(o,0)},history.replaceState=function(){n.apply(this,arguments),setTimeout(o,0)},window.addEventListener("popstate",o)}catch(r){}}function Tt(){let t=q(),e=C(["Product"]);if(e.length>0){let n=e[0],i=Array.isArray(n.offers)?n.offers[0]:n.offers;return{sku:t?t.value:n.sku||n.mpn||n.gtin13||n.productID||null,skuSource:t?t.source:null,name:typeof n.name=="string"?n.name:null,price:i&&parseFloat(i.price||i.lowPrice)||null,currency:i?i.priceCurrency:null,brand:n.brand?typeof n.brand=="string"?n.brand:n.brand.name:null,category:n.category||null}}let o=n=>{let i=document.querySelector('meta[property="og:'+n+'"], meta[property="product:'+n+'"]');return i?i.getAttribute("content"):null},r=n=>{let i=document.querySelector('[itemprop="'+n+'"]');return i?i.getAttribute("content")||(i.textContent||"").trim():null};if(t||o("type")==="product"||o("price:amount")||r("name")){let n=r("price")||o("price:amount");return{sku:t?t.value:null,skuSource:t?t.source:null,name:r("name")||o("title")||document.title||null,price:n&&parseFloat(String(n).replace(",","."))||null,currency:r("priceCurrency")||o("price:currency")||null,brand:r("brand")||null,category:null}}return null}function _e(){let t=C(["Order","Invoice"]);if(t.length>0){let r=t[0],n=r.totalPaymentDue?parseFloat(r.totalPaymentDue.price):parseFloat(r.price||r.total);return{orderId:r.orderNumber||r.confirmationNumber||r.identifier||null,revenue:Number.isFinite(n)?n:null,currency:r.totalPaymentDue&&r.totalPaymentDue.priceCurrency||r.priceCurrency||null,source:"jsonld"}}try{if(Array.isArray(window.dataLayer))for(let r=window.dataLayer.length-1;r>=0;r--){let n=window.dataLayer[r];if(n&&n.event==="purchase"&&n.ecommerce){let i=n.ecommerce;return{orderId:i.transaction_id||i.transactionId||null,revenue:parseFloat(i.value||i.revenue)||null,currency:i.currency||i.currencyCode||null,itemCount:(i.items||i.products||[]).length||null,source:"datalayer"}}}}catch(r){}let e=document.querySelector('meta[property="order:total"], meta[name="order-total"]');if(e&&e.content)return{orderId:null,revenue:parseFloat(e.content)||null,source:"meta"};let o=Hr();return o||null}function Hr(){try{let t=[".order-total","#order-total",".total-price",".order__total","[data-order-total]",".summary-total",".grand-total"];for(let e of t){let o=document.querySelector(e);if(o){let r=Vr(o.textContent);if(r)return{orderId:Jr(),revenue:r,source:"dom"}}}return null}catch(t){return null}}function Jr(){try{let e=(document.body.innerText||"").match(/(?:pedido|order|n[º°o]\.?)\s*#?\s*([A-Z0-9-]{4,})/i);return e?e[1]:null}catch(t){return null}}function Vr(t){if(!t)return null;let e=String(t).replace(/[^\d.,]/g,"");if(!e)return null;let o;e.indexOf(",")>e.indexOf(".")?o=e.replace(/\./g,"").replace(",","."):o=e.replace(/,/g,"");let r=parseFloat(o);return Number.isFinite(r)&&r>0?r:null}function Ce(){let t=C(["ItemList","CollectionPage"]);if(t.length===0)return null;let e=t[0],o=e.itemListElement||e.mainEntity&&e.mainEntity.itemListElement||[],r=[];for(let n of o.slice(0,50)){let i=n.item||n;i&&(i.sku||i.productID||i.name)&&r.push(i.sku||i.productID||i.name)}return r.length>0?{count:r.length,skus:r.slice(0,20)}:null}var ve=!1,et=[/\b(adicionar|adic\.?|colocar|incluir|jogar)\b.{0,30}\b(carrinho|sacola|sacolinha|bag)\b/i,/\bcomprar\b(?!\s+(em|por|sem))/i,/\bcomprar\s*$/i,/^add\s+to\s+(cart|bag)\b/i,/^buy\s+(now|it|this)\b/i,/^(sacolinha|carrinho|sacola)$/i],Gr=[/^finalizar(\s+(compra|pedido|pagamento))?\b/i,/^(fechar|confirmar)\s+(compra|pedido|pagamento)\b/i,/^pagar(\s+(agora|pedido))?\b/i,/^(complete|place)\s+(purchase|order)\b/i,/^checkout$/i];function $(t,e){for(let o=0;o<t.length;o++)if(t[o].test(e))return!0;return!1}function Se(t){switch(t){case"pdp":{let e=Tt();l("view_item",e||{sku:null});break}case"category":case"search":{let e=Ce();l("view_item_list",e||{count:0});break}case"cart":l("view_cart",{});break;case"checkout":l("begin_checkout",{});break;case"purchase":Wr();break}}function Wr(){let t=_e();if(t&&t.orderId){let e="_mk_purch_"+t.orderId;try{if(sessionStorage.getItem(e)){h("purchase j\xE1 contado",t.orderId);return}sessionStorage.setItem(e,"1")}catch(o){}}else if(ve)return;ve=!0,l("purchase",t||{revenue:null,_note:"no_order_data_extracted"}),h("purchase emitido",t)}function Te(){if(!document.body)return;let t=0;document.body.addEventListener("click",e=>{try{let o=Date.now();if(o-t<150)return;let r=e.target;for(let s=0;s<5&&r&&r!==document.body&&!(r.tagName==="BUTTON"||r.tagName==="A"||r.getAttribute&&r.getAttribute("role")==="button");s++)r=r.parentElement;if(!r)return;let n=r.tagName!=="A",i=(r.textContent||"").replace(/\s+/g," ").trim();if(!i||i.length>80)return;let a=!1;if(($([et[0]],i)||n&&$([et[1]],i)||n&&$([et[2]],i)||$(et.slice(3),i))&&(a=!0),a){t=o;let s=Tt();l("add_to_cart",{via:"click",buttonText:i,sku:s?s.sku:null,price:s?s.price:null});return}n&&$(Gr,i)&&(t=o,l("begin_checkout",{via:"click",buttonText:i}))}catch(o){}},{capture:!0,passive:!0})}var _=null,v=null,ot=!1,nt=!1,B=null,Ae={},At=null,rt=0,b={onReady:null,onClose:null,onAddToCart:null,onProductLoaded:null,onError:null,onInteraction:null,onGenerationComplete:null},Xr={gregory:"698c7e791d3129430f15dddd"};function Le(t){return t?Xr[String(t).toLowerCase()]||t:null}async function O(t,e){let o=f(),r=Le(t);e=String(e||"").trim();let n=o.apiUrl+"/availability/"+r+"?sku="+encodeURIComponent(e),i=await fetch(n);if(!i.ok)throw new Error("availability HTTP "+i.status);return i.json()}async function Ie(t,e){e||(e=t,t="698c7e791d3129430f15dddd");try{return(await O(t,e)).available===!0}catch(o){return!1}}async function it(t){if(t=t||{},ot)return;let e=Le(t.projectId||t.projectid||t.store),o=String(t.identifier||t.sku||"").trim();if(!e||!o){console.error("[mk-sdk] open: projectId e identifier obrigatorios");return}let r=e+":"+o;if(Ae[r]!==!0){try{if(!(await O(e,o)).available){alert("Produto nao disponivel para prova virtual.");return}}catch(n){alert("Produto nao encontrado ou indisponivel.");return}Ae[r]=!0}B={projectId:e,identifier:o,width:t.width||430,height:t.height||800},nt=!1,je(),Yr(B),ot=!0,rt=Date.now(),l("modal_opened",{projectId:e,identifier:o})}function Lt(){if(!ot)return;let t=nt;if(nt=!1,Zr(),ot=!1,T("onClose"),l("modal_closed",{projectId:B&&B.projectId,identifier:B&&B.identifier}),t)try{ge()}catch(e){}}function Pe(t){try{let e=document.getElementById("mk-tryon-button-host");if(!e)return;t?(e.dataset.mkPrevDisplay===void 0&&(e.dataset.mkPrevDisplay=e.style.display),e.style.display="none"):(e.style.display=e.dataset.mkPrevDisplay||"",delete e.dataset.mkPrevDisplay)}catch(e){}}function Yr(t){_=document.createElement("div"),_.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,.8);display:flex;align-items:center;justify-content:center;z-index:2147483647;",Pe(!0);let e=document.createElement("div"),o=typeof t.width=="number"?t.width+"px":t.width,r=typeof t.height=="number"?t.height+"px":t.height;e.style.cssText="position:relative;width:"+o+";height:"+r+";max-width:100vw;max-height:100dvh;border-radius:12px;overflow:hidden;background:#fff;",v=document.createElement("iframe");let n=encodeURIComponent(t.identifier).replace(/\./g,"%2E");v.src=f().appUrl+"/"+t.projectId+"/"+n,v.style.cssText="width:100%;height:100%;border:none;",v.setAttribute("allow","camera *; microphone *"),v.setAttribute("allowfullscreen","true"),e.appendChild(v),_.appendChild(e),document.body.appendChild(_),h("try-on modal aberto",v.src)}function Zr(){_&&_.parentNode&&_.parentNode.removeChild(_),_=null,v=null,Pe(!1)}var Ee=!1;function Re(){je()}function je(){Ee||(Ee=!0,window.addEventListener("message",t=>{let e=t.data;if(!e||e.source!=="mkfashion-app")return;let o=e.action,r=e.data||{};switch(o){case"close_request":Lt();break;case"ready":T("onReady",r);break;case"product_loaded":T("onProductLoaded",r),l("product_loaded",Et(r));break;case"interaction":{T("onInteraction",r),r&&r.method&&(At=r.method),l(Qr(r),Et(r));break}case"add_to_cart":l("add_to_cart",Object.assign({via:"tryon"},Et(r))),typeof b.onAddToCart=="function"?T("onAddToCart",r):me(r).then(()=>he()).then(n=>{nt=!!n}).catch(()=>{});break;case"generation_start":rt=Date.now();break;case"generation_complete":T("onGenerationComplete",r),l("generation_complete",{method:r.method||At||"unknown",durationMs:rt?Date.now()-rt:null,success:r.success!==!1,imageUrlPresent:!!r.imageUrl});break;case"generation_error":T("onError",r),l("generation_error",{method:At||"unknown",error:r&&r.error});break}}))}function Qr(t){return t&&t.action,"interaction"}function Et(t){if(!t||typeof t!="object")return t;let e={};for(let o in t){if(o==="imageUrl"||o==="image"||o==="product"){o==="product"&&t[o]?(e.productSku=t[o].sku||null,e.productName=t[o].name||null):e[o+"Present"]=!!t[o];continue}e[o]=t[o]}return e}function T(t,e){if(typeof b[t]=="function")try{b[t](e)}catch(o){console.error("[mk-sdk]",o)}}function Be(t){b.onReady=t}function Oe(t){b.onClose=t}function Ne(t){b.onAddToCart=t}function Me(t){b.onProductLoaded=t}function Ue(t){b.onError=t}function De(t){b.onInteraction=t}function Fe(t){b.onGenerationComplete=t}var eo=767,ro=1024,oo=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora|^comprar$|finalizar compra|eu quero/i,no=/continuar|como comprar|lista|desejos|favorito|looks|cupom/i;function It(t){try{let e=t.getBoundingClientRect();if(e.width<=0||e.height<=0)return!1;let o=getComputedStyle(t);return o.display!=="none"&&o.visibility!=="hidden"&&o.opacity!=="0"}catch(e){return!1}}function io(t){if(!t)return!1;try{let e=document.querySelector(t);return!!e&&It(e)}catch(e){return!1}}function ao(t){return(t.tagName==="INPUT"?t.value||"":t.textContent||"").replace(/\s+/g," ").trim()}function co(t){if(!t||typeof t!="object"||t.selector)return t;let e=!1;if(["mobile","tablet","desktop"].forEach(r=>{let n=t[r];n&&n.mkAnchor===1&&n.anchor&&typeof n.anchor=="object"&&(e=!0)}),!e)return t;let o={};return["mobile","tablet","desktop"].forEach(r=>{let n=t[r];if(n){if(n.selector){o[r]=n;return}if(n.mkAnchor===1&&n.anchor&&typeof n.anchor=="object"){let i=n.anchor[r]||n.anchor.desktop||n.anchor.mobile||n.anchor.tablet;i&&i.selector&&(o[r]=i)}}}),["bpMobile","bpTablet","breakpoint"].forEach(r=>{t[r]!=null&&(o[r]=t[r])}),o}function Pt(t){if(!t||typeof t!="object")return null;if(t=co(t),t.selector)return t;let e=[["mobile",t.mobile],["tablet",t.tablet],["desktop",t.desktop]].filter(u=>u[1]&&u[1].selector);if(e.length===0)return null;if(e.length===1)return e[0][1];let o=e.filter(([,u])=>io(u.selector));if(o.length===1)return o[0][1];let r=window.innerWidth||1024,n=Number(t.bpMobile)||Number(t.breakpoint)||eo,i=Number(t.bpTablet)||ro,a=u=>(e.find(d=>d[0]===u)||[])[1],s=r<=n?["mobile","tablet","desktop"]:r<=i?["tablet","desktop","mobile"]:["desktop","tablet","mobile"];for(let u of s){let d=a(u);if(d)return d}return e[0][1]}function qe(){let t=f(),e=Pt(t&&t.anchor);if(e&&e.selector)try{let r=document.querySelector(e.selector);if(r&&It(r))return{el:r,position:e.position||"afterend",mode:e.mode||"flow",style:e.style||"",align:e.align||"top-left",selector:e.selector}}catch(r){}let o=document.querySelectorAll('button, [role="button"], a.btn, a.button, input[type="submit"], input[type="button"]');for(let r of o){let n=ao(r);if(!(!n||n.length>40)&&!no.test(n)&&oo.test(n)&&It(r))return{el:r,position:"afterend",mode:"flow",style:"",selector:null}}return null}var w="'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Rt={none:"0",sm:"4px",md:"8px",pill:"9999px"},jt={none:"0",sm:"4px",md:"8px",lg:"16px"},lo='<svg viewBox="0 0 17.5263 20.6862" fill="none" xmlns="http://www.w3.org/2000/svg" style="display:block;width:100%;height:100%"><g><path d="M8.49995 12.1862C10.1568 12.1862 11.5 10.8431 11.5 9.18622C11.5 7.52936 10.1568 6.18622 8.49995 6.18622C6.8431 6.18622 5.49995 7.52936 5.49995 9.18622C5.49995 10.8431 6.8431 12.1862 8.49995 12.1862Z" stroke="currentColor" shape-rendering="crispEdges"/><path d="M0.5 9.11152C0.5 6.56953 0.5 5.29894 1.1099 4.38664C1.375 3.9902 1.71424 3.65088 2.10821 3.38809C2.6945 2.9958 3.42899 2.85564 4.55351 2.80588C5.09013 2.80588 5.55183 2.39949 5.65687 1.87284C5.73715 1.48708 5.94572 1.14138 6.24735 0.894155C6.54898 0.646934 6.92516 0.51336 7.31231 0.516006H9.9734C10.7779 0.516006 11.4709 1.08412 11.6288 1.87284C11.7339 2.39949 12.1956 2.80588 12.7322 2.80588C13.8559 2.85564 12.9129 4.67413 13.5 5.06559C13.8949 5.32932 15.1484 3.80355 15.5 4.02647C16.1099 4.93876 16.7857 6.56953 16.7857 9.11152C16.7857 11.6535 16.7857 12.9233 16.1758 13.8364C15.9107 14.2328 15.5715 14.5722 15.1775 14.835C14.2647 15.4445 12.9936 15.4445 10.4522 15.4445H6.83351C4.29213 15.4445 3.02103 15.4445 2.10821 14.835C1.71446 14.5718 1.3755 14.2322 1.11071 13.8356C0.933802 13.5672 0.803519 13.2698 0.725557 12.9564" stroke="currentColor" stroke-linecap="round"/><path d="M12.676 0.607931C12.9446 -0.178095 14.0307 -0.2019 14.3491 0.536515L14.3761 0.60838L14.7385 1.66839C14.8216 1.91149 14.9559 2.13395 15.1322 2.32076C15.3086 2.50757 15.5229 2.65439 15.7608 2.75131L15.8583 2.78769L16.9183 3.14971C17.7044 3.41831 17.7282 4.50437 16.9902 4.82283L16.9183 4.84978L15.8583 5.21225C15.6151 5.29526 15.3926 5.42947 15.2057 5.60582C15.0188 5.78218 14.8719 5.99657 14.7749 6.23453L14.7385 6.33155L14.3765 7.39201C14.1079 8.17803 13.0219 8.20184 12.7039 7.46387L12.676 7.39201L12.314 6.332C12.231 6.08881 12.0968 5.86627 11.9204 5.67938C11.744 5.49249 11.5297 5.3456 11.2917 5.24863L11.1947 5.21225L10.1347 4.85022C9.34817 4.58163 9.32437 3.49557 10.0628 3.17756L10.1347 3.14971L11.1947 2.78769C11.4378 2.70462 11.6602 2.57039 11.847 2.39404C12.0339 2.21769 12.1807 2.00333 12.2776 1.76541L12.314 1.66839L12.676 0.607931Z" fill="currentColor"/></g></svg>',so='<svg viewBox="0 0 11.6122 12.7248" fill="none" xmlns="http://www.w3.org/2000/svg" style="display:block;width:12px;height:12px"><path d="M4.09055 2.01133C4.43939 0.9905 5.84989 0.959583 6.26347 1.91858L6.29847 2.01192L6.76922 3.38858C6.8771 3.7043 7.05144 3.99321 7.28047 4.23583C7.5095 4.47845 7.7879 4.66912 8.09689 4.795L8.22347 4.84225L9.60014 5.31242C10.621 5.66125 10.6519 7.07175 9.69347 7.48533L9.60014 7.52033L8.22347 7.99108C7.90764 8.09889 7.61862 8.2732 7.3759 8.50223C7.13318 8.73127 6.94241 9.0097 6.81647 9.31875L6.76922 9.44475L6.29905 10.822C5.95022 11.8428 4.53972 11.8737 4.12672 10.9153L4.09055 10.822L3.62039 9.44533C3.51258 9.12951 3.33827 8.84048 3.10924 8.59776C2.8802 8.35504 2.60177 8.16427 2.29272 8.03833L2.16672 7.99108L0.790054 7.52092C-0.231363 7.17208 -0.26228 5.76158 0.69672 5.34858L0.790054 5.31242L2.16672 4.84225C2.48244 4.73437 2.77135 4.56003 3.01397 4.331C3.25658 4.10197 3.44726 3.82357 3.57314 3.51458L3.62039 3.38858L4.09055 2.01133ZM9.86147 0C9.9706 0 10.0775 0.0306123 10.1701 0.0883584C10.2627 0.146104 10.3373 0.228668 10.3853 0.326667L10.4133 0.394917L10.6175 0.993417L11.2166 1.19758C11.3259 1.23474 11.4218 1.30353 11.492 1.39523C11.5623 1.48693 11.6037 1.59741 11.611 1.71268C11.6184 1.82795 11.5914 1.94281 11.5334 2.04271C11.4755 2.14261 11.3891 2.22305 11.2854 2.27383L11.2166 2.30183L10.6181 2.506L10.4139 3.10508C10.3767 3.21442 10.3078 3.31024 10.2161 3.38041C10.1244 3.45058 10.0139 3.49194 9.89859 3.49925C9.78333 3.50656 9.66849 3.47949 9.56863 3.42147C9.46876 3.36345 9.38837 3.27709 9.33764 3.17333L9.30964 3.10508L9.10547 2.50658L8.50639 2.30242C8.39702 2.26526 8.30115 2.19647 8.23092 2.10477C8.16069 2.01307 8.11926 1.90259 8.11189 1.78732C8.10452 1.67205 8.13153 1.55719 8.18951 1.45729C8.24749 1.35739 8.33381 1.27695 8.43755 1.22617L8.50639 1.19817L9.10489 0.994L9.30905 0.394917C9.34839 0.279665 9.42281 0.179613 9.52187 0.108791C9.62094 0.0379686 9.73969 -0.0000730808 9.86147 0Z" fill="currentColor"/></svg>';function p(t,e={}){let o=document.createElement(t);if(e.style&&(o.style.cssText=e.style),e.text!=null&&(o.textContent=e.text),e.html!=null&&(o.innerHTML=e.html),e.attrs)for(let r in e.attrs)o.setAttribute(r,e.attrs[r]);if(e.on)for(let r in e.on)o.addEventListener(r,e.on[r]);if(e.children)for(let r of e.children)r&&o.appendChild(r);return o}function at(t){return p("span",{style:`width:24px;height:24px;padding:2px;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:lo})}function ze(t){return p("span",{style:`width:12px;height:12px;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:so})}function ct(t){return t.borderWidth>0&&t.borderColor?`${t.borderWidth}px solid ${t.borderColor}`:"none"}function lt(){if(!document.getElementById("mk-jakarta-font"))try{document.head.appendChild(p("link",{attrs:{id:"mk-jakarta-font",rel:"stylesheet",href:"https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap"}}))}catch(t){}}function uo(t){return t.subtext?p("span",{style:`display:flex;align-items:center;justify-content:center;padding:4px;background:${t.badgeBgColor};font-family:${w};font-weight:700;font-size:16px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,text:t.subtext}):null}function $e(t,e){lt();let o=p("span",{style:"display:inline-flex;align-items:center;gap:4px;",children:[at(t.textColor),p("span",{text:t.text,style:`font-family:${w};font-weight:700;font-size:${t.fontSize}px;text-transform:uppercase;letter-spacing:2px;color:${t.textColor};white-space:nowrap;text-align:center;line-height:1;`})]});return p("button",{attrs:{type:"button"},style:`display:flex;align-items:center;justify-content:center;gap:8px;padding:8px;width:100%;max-width:238px;box-sizing:border-box;background:${t.bgColor};border:${ct(t)};border-radius:${t.borderRadiusPx};font-family:${w};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[o,uo(t)],on:{mouseenter:r=>{r.currentTarget.style.opacity="0.85"},mouseleave:r=>{r.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(r){}}}})}function fo(t){return t.subtext?p("span",{style:`display:flex;align-items:center;gap:4px;padding:4px;background:${t.badgeBgColor};font-family:${w};font-weight:600;font-size:10px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,children:[ze(t.badgeTextColor),p("span",{text:t.subtext})]}):null}function mo(t,e){return p("button",{attrs:{type:"button"},style:`display:flex;align-items:center;justify-content:center;gap:8px;padding:8px 12px 8px 8px;width:100%;margin-top:auto;box-sizing:border-box;background:${t.bgColor};border:${ct(t)};border-radius:${t.borderRadiusPx};filter:drop-shadow(0 0 6px rgba(0,0,0,0.08));font-family:${w};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[at(t.textColor),p("span",{text:t.text,style:`font-family:${w};font-weight:700;font-size:${t.fontSize}px;color:${t.textColor};white-space:nowrap;line-height:1;`})],on:{mouseenter:o=>{o.currentTarget.style.opacity="0.85"},mouseleave:o=>{o.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(o){}}}})}function Ke(t,e){lt();let o=p("div",{style:"display:flex;flex-direction:column;gap:4px;",children:[t.cardTitle&&p("p",{text:t.cardTitle,style:`margin:0;font-family:${w};font-weight:700;font-size:16px;letter-spacing:1px;text-transform:uppercase;color:${t.cardTitleColor};line-height:1.2;`}),t.cardDescription&&p("p",{html:t.cardDescription,style:`margin:0;font-family:${w};font-weight:400;font-size:12px;max-width:177px;line-height:1.2;color:${t.cardTextColor};`})]}),r=p("div",{style:"display:flex;flex-direction:column;justify-content:space-between;gap:16px;flex:1 1 0;min-width:0;",children:[o,t.cardFooter&&p("p",{text:t.cardFooter,style:`margin:0;font-family:${w};font-weight:400;font-size:10px;color:${t.cardTextColor};line-height:1.2;`})]}),n=p("div",{style:"display:flex;flex-direction:column;align-items:flex-end;flex:1 1 0;min-width:0;",children:[fo(t),mo(t,e)]}),i=p("div",{style:"display:flex;gap:16px;align-items:stretch;width:100%;flex:1;box-sizing:border-box;",children:[r,n]});return p("div",{style:`display:flex;flex-direction:column;align-items:flex-start;padding:12px;width:100%;max-width:402px;min-height:140px;box-sizing:border-box;background:${t.cardBgColor};border-radius:${t.cardBorderRadiusPx};font-family:${w};`,children:[i]})}var go={style:"gregory-black",text:"Provar Virtualmente",fontSize:14,subtext:"",bgColor:"#1E1E1E",textColor:"#FFFFFF",badgeBgColor:"#C51A1B",badgeTextColor:"#FFFFFF",borderRadius:"md",borderColor:"#1E1E1E",borderWidth:0,cardTitle:"",cardDescription:"",cardFooter:"",cardBgColor:"#F6F6F6",cardTitleColor:"#1E1E1E",cardTextColor:"#717171",cardBorderRadius:"md"};function Bt(t,e){let o=(e?t&&t.mobile:t&&t.desktop)||t&&t.desktop||t&&t.mobile||{},r={...go,...o};return r.style==="gregory-card"&&e&&(r.style="gregory-black"),r.borderRadiusPx=Rt[r.borderRadius]!=null?Rt[r.borderRadius]:"0",r.cardBorderRadiusPx=jt[r.cardBorderRadius]!=null?jt[r.cardBorderRadius]:"0",r.fontSize=Number(r.fontSize)||14,r.borderWidth=Number(r.borderWidth)||0,r}var Ot={"gregory-black":$e,"gregory-card":Ke},pn=Object.keys(Ot);function He(t,e){return(Ot[t.style]||Ot["gregory-black"])(t,e)}var Dt="mk-tryon-button-host",yo=/^(transform|transform-origin|margin|margin-(top|right|bottom|left)|position|inset|top|right|bottom|left|z-index|width|min-width|max-width|height|min-height|max-height)$/i;function wo(t){return!t||typeof t!="string"?"":t.split(";").map(e=>e.trim()).filter(Boolean).filter(e=>yo.test(e.split(":")[0].trim().toLowerCase())).join(";")}var st=null,Nt=!1,Mt={},Je=!1,Ut=null;function Ve(){return Ut||(Ut=j().then(t=>t&&t.template&&t.template.tryOnButton||null).catch(()=>null)),Ut}function xo(){if(Je)return;Je=!0;let t=null;try{window.addEventListener("resize",()=>{clearTimeout(t),t=setTimeout(()=>{st&&N("pdp")},200)})}catch(e){}}function Ft(){let t=document.getElementById(Dt);if(t){if(typeof t.__mkCleanup=="function")try{t.__mkCleanup()}catch(e){}t.parentNode&&t.parentNode.removeChild(t)}st=null}var bo={IMG:1,INPUT:1,VIDEO:1,CANVAS:1,EMBED:1,OBJECT:1,IFRAME:1,BR:1,HR:1,SELECT:1,TEXTAREA:1,SVG:1};function ko(t){switch(t){case"top-center":return"top:0;left:50%;transform:translateX(-50%);";case"top-right":return"top:0;right:0;";case"middle-left":return"top:50%;left:0;transform:translateY(-50%);";case"center":return"top:50%;left:50%;transform:translate(-50%,-50%);";case"middle-right":return"top:50%;right:0;transform:translateY(-50%);";case"bottom-left":return"bottom:0;left:0;";case"bottom-center":return"bottom:0;left:50%;transform:translateX(-50%);";case"bottom-right":return"bottom:0;right:0;";case"top-left":default:return"top:0;left:0;"}}function _o(t,e,o){let n=!bo[t.tagName]?t:t.parentElement||document.body;try{getComputedStyle(n).position==="static"&&(n.style.position="relative")}catch(d){}if(n===t){e.style.cssText="position:absolute;z-index:2147483000;"+ko(o),t.appendChild(e);return}e.style.cssText="position:absolute;z-index:2147483000;",n.appendChild(e);let i=()=>{try{let d=t.getBoundingClientRect(),m=n.getBoundingClientRect(),g=e.offsetWidth,c=e.offsetHeight,x=d.top-m.top+n.scrollTop,A=d.left-m.left+n.scrollLeft,y=o||"top-left",K=x,S=A;y.indexOf("bottom")===0?K=x+d.height-c:(y.indexOf("middle")===0||y==="center")&&(K=x+(d.height-c)/2),y.indexOf("right")>=0?S=A+d.width-g:y.indexOf("center")>=0&&(S=A+(d.width-g)/2),e.style.top=K+"px",e.style.left=S+"px"}catch(d){}};i();let a=()=>i();window.addEventListener("resize",a);let s=setTimeout(i,600),u=setTimeout(i,1500);e.__mkCleanup=()=>{window.removeEventListener("resize",a),clearTimeout(s),clearTimeout(u)}}function Co(t,e,o){try{return t.insertAdjacentElement(o||"afterend",e),!0}catch(r){try{return t.parentNode.insertBefore(e,t.nextSibling),!0}catch(n){return!1}}}async function N(t){let e=f();if(t!=="pdp"){Ft();return}if(!e.projectId)return;if(!e._anchorFromPicker){let u=await Ve();u&&u.anchor&&(e.anchor=u.anchor)}if(Nt)return;let o=q(),r=o&&o.value,n=!!e.forceButton,i=Pt(e.anchor),a=[r||"demo",i?[i.selector,i.position,i.mode,i.align,i.style].join("~"):"heuristic"].join("|"),s=document.getElementById(Dt);if(!(s&&st===a)){if(s&&Ft(),!r&&!n){h("auto-mount: SKU n\xE3o resolvido na PDP");return}Nt=!0;try{let u=n;n||(Mt[r]||(Mt[r]=O(e.projectId,r).then(k=>!!(k&&k.available)).catch(()=>!1)),u=await Mt[r]);try{te(u?"available":"unavailable")}catch(k){}if(!u){h("auto-mount: produto sem try-on",r);return}let d=await Ve(),m=window.matchMedia("(max-width: 767px)").matches,g=Bt(d,m),c=qe(),x=c&&c.mode||"flow",A=He(g,()=>{let k=q(),ut=k&&k.value||r||"";Zt(),l("button_clicked",{sku:ut,style:g.style,mode:x}),it({projectId:e.projectId,identifier:ut})}),y=document.createElement("div");y.id=Dt,y.attachShadow({mode:"closed"}).appendChild(A);let S=!1;if(c&&c.el&&c.el.parentNode&&(x==="overlay"?(_o(c.el,y,c.align),S=!0):(y.style.cssText="display:contents;",S=Co(c.el,y,c.position))),S||(y.style.cssText="position:fixed;left:16px;bottom:16px;z-index:2147483000;",document.body.appendChild(y)),c&&c.style){let k=wo(c.style);if(k)try{A.style.cssText+=";"+k}catch(ut){}}st=a,xo(),h("auto-mount: bot\xE3o injetado",{style:g.style,sku:r,anchorFound:!!c,position:c&&c.position,mode:x,forced:n}),l("button_rendered",{style:g.style,sku:r||null,skuSource:o&&o.source,anchorFound:!!c,position:c?c.position:null,mode:x,forced:n})}finally{Nt=!1}}}function Ge(){try{let t=f(),e={anchor:t.anchor,forceButton:t.forceButton};window.addEventListener("message",o=>{if(o.source!==window)return;let r=o.data;!r||!r.__mkCmd||(r.__mkCmd==="remount"||r.__mkCmd==="applyRecipe"?(t.anchor=r.anchor||null,t._anchorFromPicker=!0,t.forceButton=!0,N("pdp")):r.__mkCmd==="cancelPreview"&&(t.anchor=e.anchor,t._anchorFromPicker=!1,t.forceButton=e.forceButton,Ft(),N("pdp")))})}catch(t){}}(function(){"use strict";try{let o=function(){try{oe(),Ge(),Re(),e.autoTrack!==!1&&(be((n,i)=>{Se(n,i),N(n)}),Te()),h("mk-sdk iniciado",{projectId:e.projectId,collectorUrl:e.collectorUrl})}catch(n){e.debug&&console.error("[mk-sdk] init erro",n)}},e=pt();if(e.projectId){let n=ce(e.projectId);n&&yt(n),j().then(i=>{let a=ie(i);yt(a),le(e.projectId,a),h("escopo de coleta",a)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o):o();let r={open:it,close:Lt,isAvailable:Ie,getAvailability:O,onReady:Be,onClose:Oe,onAddToCart:Ne,onProductLoaded:Me,onError:Ue,onInteraction:De,onGenerationComplete:Fe,_version:"0.1.0",_isMkSdk:!0};typeof window!="undefined"&&(window.mk=r)}catch(e){typeof console!="undefined"&&console.error("[mk-sdk] boot fatal",e)}})();})();
|
|
1
|
+
(()=>{var er=Object.defineProperty;var I=(t,e)=>{for(var r in e)er(t,r,{get:e[r],enumerable:!0})};var ft={collectorUrl:"https://api-collector.mk3dlabs.com",appUrl:"https://mkfashion.mk3dlabs.com/visualizer",apiUrl:"https://mkfashion-new-api.mk3dlabs.com"},rr={},F=null;function pt(){if(F)return F;let t=null;try{t=document.currentScript||document.querySelector("script[data-mk-project]")||document.querySelector('script[src*="mk-sdk"]')||document.querySelector('script[src*="mk-pixel"]')}catch(i){}let e=i=>{try{return t&&t.getAttribute(i)}catch(c){return null}},r=e("data-mk-project")||e("data-mk-client")||window.__MK&&(window.__MK.projectId||window.__MK.clientSlug)||null,n=e("data-mk-product")||window.__MK&&window.__MK.product||"mk-fashion",o=e("data-mk-collector")||window.__MK&&window.__MK.collectorUrl||rr.collectorUrl||ft.collectorUrl;return F={projectId:r,product:n,collectorUrl:o,appUrl:window.__MK&&window.__MK.appUrl||ft.appUrl,apiUrl:window.__MK&&window.__MK.apiUrl||ft.apiUrl,debug:!!(e("data-mk-debug")!==null||window.__MK&&window.__MK.debug||/[?&]mkdebug\b/.test(location.search)),observe:!!(window.__MK&&window.__MK.observe),forceButton:!!(window.__MK&&window.__MK.forceButton),anchor:window.__MK&&window.__MK.anchor||null,cartRedirect:!(window.__MK&&window.__MK.cartRedirect===!1),cartBehavior:window.__MK&&window.__MK.cartBehavior||null,cartOpenSelector:window.__MK&&window.__MK.cartOpenSelector||null,autoTrack:e("data-mk-no-autotrack")===null,batchIntervalMs:window.__MK&&window.__MK.batchIntervalMs||8e3,batchMaxSize:window.__MK&&window.__MK.batchMaxSize||20,engagementIntervalMs:15e3},F}function m(){return F||pt()}function y(...t){let e=m();e&&e.debug&&typeof console!="undefined"&&console.log("[mk-sdk]",...t)}var $t="_mk_vid",Kt="_mk_sid",D=null,q=null;function J(){return typeof crypto!="undefined"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Ht(){if(D)return D;try{let t=localStorage.getItem($t);return t||(t="v_"+J(),localStorage.setItem($t,t)),D=t,t}catch(t){return D="v_"+J(),D}}function Vt(){if(q)return q;try{let t=sessionStorage.getItem(Kt);return t||(t="s_"+J(),sessionStorage.setItem(Kt,t)),q=t,t}catch(t){return q="s_"+J(),q}}var Jt=[/email/i,/e-?mail/i,/cpf/i,/cnpj/i,/phone/i,/telefone/i,/celular/i,/address/i,/endereco/i,/cep/i,/zip/i,/card/i,/cartao/i,/cvv/i,/password/i,/senha/i,/token/i,/\bnome\b/i,/fullname/i,/firstname/i,/lastname/i,/sobrenome/i,/birth/i,/nascimento/i,/rg\b/i],Gt={imageUrl:1,image:1,thumbnail:1,photo:1,imageBase64:1,src:1},mt=2e3;function Wt(t){for(let e=0;e<Jt.length;e++)if(Jt[e].test(t))return!0;return!1}function Yt(t){if(!t||typeof t!="object"||Array.isArray(t))return typeof t=="string"&&t.length>mt?t.slice(0,200)+"...[truncated "+t.length+"B]":t;let e={};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||Wt(r))continue;let n=t[r];if(Gt[r]){e[r+"Present"]=!!n;continue}if(typeof n=="string"&&n.length>mt){e[r]=n.slice(0,200)+"...[truncated "+n.length+"B]";continue}if(n&&typeof n=="object"&&!Array.isArray(n)){e[r]=nr(n);continue}e[r]=n}return e}function nr(t){let e={};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||Wt(r))continue;let n=t[r];if(Gt[r]){e[r+"Present"]=!!n;continue}if(typeof n=="string"&&n.length>mt){e[r]=n.slice(0,200)+"...[truncated]";continue}e[r]=n}return e}var G=[],ht=null,R=null,or=["off","pdp_tryon","pdp","all","tryon_engaged"],yt,gt=null,W="unknown",j=[],P=null;function Zt(){let t=m();return"mk_engaged_"+(t&&t.projectId||"")}function Qt(){if(P!==null)return P;try{P=localStorage.getItem(Zt())==="1"}catch(t){P=!1}return P}function te(){if(!Qt()){P=!0;try{localStorage.setItem(Zt(),"1")}catch(t){}Y(!1)}}function ee(t){if(yt===void 0)return"hold";switch(yt){case"off":return"drop";case"all":return"collect";case"pdp":return t==="pdp"?"collect":"drop";case"tryon_engaged":if(Qt())return"collect";case"pdp_tryon":return t!=="pdp"?"drop":W==="available"?"collect":W==="unavailable"?"drop":"hold";default:return"collect"}}function Y(t){if(!j.length)return;let e=[];for(let r of j){let n=ee(r._pt);n==="collect"?oe(r.name,r.params,r.ts):n==="hold"&&!t&&e.push(r)}j=e}function wt(t){yt=or.indexOf(t)>=0?t:"all",Y(!1)}function re(t){W=t==="available"?"available":"unavailable",Y(!1)}function ne(t){Y(!0),R=t,gt=t&&t.pageType||null,W="unknown"}function l(t,e,r){if(!m().projectId){(l._pre=l._pre||[]).push({name:t,params:e,ts:r||Date.now()}),l._pre.length>50&&l._pre.shift();return}if(l._pre&&l._pre.length){let o=l._pre;l._pre=[];for(let i of o)Xt(i.name,i.params,i.ts)}Xt(t,e,r)}function Xt(t,e,r){let n=ee(gt);if(n==="collect"){oe(t,e,r);return}if(n==="drop"){y("descartado (escopo)",t);return}j.push({name:t,params:e,ts:r||Date.now(),_pt:gt}),j.length>300&&j.shift()}function oe(t,e,r){let n=m(),o=Yt(e||{}),i="page_"+ir(t);if(G.push({name:i,ts:r||Date.now(),params:o}),y("queued",t,o),n.observe)try{window.postMessage({__mkpixel:!0,event:{name:i,params:o},site:R?{pageType:R.pageType,platform:R.platform,url:R.url}:null},"*")}catch(c){}if(G.length>=n.batchMaxSize){A();return}ht||(ht=setTimeout(()=>{ht=null,A()},n.batchIntervalMs))}function ir(t){if(typeof t!="string"||!t)return"unknown";let e=t.replace(/^on/,"");return e=e.replace(/[A-Z]/g,(r,n)=>(n>0?"_":"")+r.toLowerCase()),e.indexOf("page_")===0&&(e=e.slice(5)),e}function A(t){if(G.length===0)return;let e=m();if(!e.projectId||!e.collectorUrl)return;let r=G.splice(0,50),n=JSON.stringify({product:e.product||void 0,visitorId:Ht(),sessionId:Vt(),events:r,site:R||void 0}),o=e.collectorUrl+"/v1/track";if(t&&navigator.sendBeacon)try{let i=new Blob([n],{type:"application/json"});navigator.sendBeacon(o+"?projectId="+encodeURIComponent(e.projectId),i);return}catch(i){}fetch(o,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","X-MK-Project-Id":e.projectId},body:n}).catch(()=>{})}function ie(){try{window.addEventListener("pagehide",()=>A(!0)),window.addEventListener("beforeunload",()=>A(!0)),document.addEventListener("visibilitychange",()=>{document.hidden&&A(!0)})}catch(t){}}function v(t){let e=[];try{let r=document.querySelectorAll('script[type="application/ld+json"]');for(let n of r){let o;try{o=JSON.parse(n.textContent)}catch(c){continue}let i=[];Array.isArray(o)?i.push(...o):o["@graph"]?i.push(...o["@graph"]):i.push(o);for(let c of i){if(!c||!c["@type"])continue;let s=Array.isArray(c["@type"])?c["@type"]:[c["@type"]];(!t||t.some(u=>s.includes(u)))&&e.push(c)}}}catch(r){}return e}var ce=["off","pdp_tryon","pdp","all","tryon_engaged"],cr="all",ar=30*60*1e3,B=null;function N(){if(B)return B;let t=m();return!t.projectId||!t.apiUrl?(B=Promise.resolve(null),B):(B=fetch(t.apiUrl+"/projects/"+t.projectId).then(e=>e.ok?e.json():null).then(e=>e&&e.project||e||null).catch(()=>null),B)}function ae(t){let e=t&&t.analytic&&t.analytic.scope;return ce.indexOf(e)>=0?e:cr}var le=t=>"mk_scope_"+t;function se(t){try{let e=localStorage.getItem(le(t));if(!e)return null;let r=JSON.parse(e);return!r||typeof r.exp!="number"||r.exp<Date.now()?null:ce.indexOf(r.scope)>=0?r.scope:null}catch(e){return null}}function ue(t,e){try{localStorage.setItem(le(t),JSON.stringify({scope:e,exp:Date.now()+ar}))}catch(r){}}var xt={};I(xt,{addToCart:()=>dr,detect:()=>sr,getCartSummary:()=>fr,id:()=>lr,openCartDrawer:()=>hr,resolveSku:()=>ur});var lr="shopify";function sr(){return!!(window.Shopify||window.ShopifyAnalytics)}function ur(){let t=window;return t.ShopifyAnalytics&&t.ShopifyAnalytics.meta&&t.ShopifyAnalytics.meta.product?{value:String(t.ShopifyAnalytics.meta.product.id),source:"shopify"}:null}var X=t=>String(t==null?"":t).trim().toLowerCase();async function dr({size:t,color:e,sku:r,quantity:n}){let o=(location.pathname.split("/products/")[1]||"").split(/[?#]/)[0];if(!o)throw new Error("shopify: sem handle de produto na URL (n\xE3o \xE9 PDP?)");let c=(await fetch("/products/"+o+".js").then(a=>a.json())).variants||[],s=a=>[a.option1,a.option2,a.option3].concat(String(a.title||"").split("/")).map(X).filter(Boolean),u=(a,f)=>s(a).indexOf(X(f))>=0,d=a=>(!t||u(a,t))&&(!e||u(a,e)),h=null;if((t||e)&&(h=c.find(a=>d(a)&&a.available)||c.find(d)),!h&&r&&(h=c.find(a=>X(a.sku)===X(r))),h||(h=c.find(a=>a.available)||c[0]),!h)throw new Error("shopify: variante n\xE3o encontrada");let w=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:h.id,quantity:n||1}]})});if(!w.ok)throw new Error("shopify: /cart/add.js HTTP "+w.status);return{platform:"shopify",variantId:h.id,size:h.title,sku:h.sku||null}}async function fr(){try{let t=await fetch("/cart.js",{headers:{Accept:"application/json"}}).then(e=>e.json());return{value:(Number(t.total_price)||0)/100,itemCount:Number(t.item_count)||0,currency:t.currency||null}}catch(t){return null}}var pr=["[data-cart-drawer-toggle]",'[data-action="open-cart-drawer"]','[data-action="open-cart"]',".js-cart-drawer-open",".js-drawer-open-cart",".cart-drawer-toggle",".js-cart-toggle",'[aria-controls="CartDrawer"]','[aria-controls="cart-drawer"]',"#cart-icon-bubble","#lk-cart-icon",".header__cart",".site-header__cart",".cart-link",".header-cart",'a[href="/cart"]','a[href$="/cart"]'];function mr(t){try{let e=t.getBoundingClientRect();return e.width>0&&e.height>0&&getComputedStyle(t).visibility!=="hidden"}catch(e){return!1}}function hr(){let t=null;for(let e of pr)try{if(t=[...document.querySelectorAll(e)].find(mr),t)break}catch(r){}return t?(setTimeout(()=>{try{t.click()}catch(e){}},300),!0):!1}var bt={};I(bt,{addToCart:()=>xr,detect:()=>gr,getCartSummary:()=>br,id:()=>yr,resolveSku:()=>wr});var yr="hybris";function gr(){return!!(window.ACC&&window.ACC.config)}function wr(){let t=(location.pathname||"").match(/\/p\/([^/?#]+)/);return t&&t[1]?{value:decodeURIComponent(t[1]),source:"hybris/url"}:null}var de=t=>String(t==null?"":t).trim().toLowerCase();async function xr({size:t,quantity:e}){let r=[...document.querySelectorAll('.js-product-select-size, a[data-code], [class*="select-size"]')].filter(f=>f.getAttribute&&f.getAttribute("data-code")),n=t?r.find(f=>de(f.textContent)===de(t)):null;n||(n=r.find(f=>f.offsetParent!==null)||r[0]);let o=n&&n.getAttribute("data-code");if(!o)throw new Error("hybris: variante (data-code) n\xE3o encontrada");let i=document.getElementById("product--add-to-cart-form")||document.querySelector('form[action*="/cart/add"]'),c=i&&i.querySelector('[name="CSRFToken"]'),s=c&&c.value,u=i&&i.getAttribute("action")||"/cart/add";if(!s)throw new Error("hybris: CSRFToken n\xE3o encontrado");let d=new URLSearchParams;d.set("productCodePost",o),d.set("qty",String(e||1)),d.set("CSRFToken",s);let h=await fetch(u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:d.toString()});if(!h.ok)throw new Error("hybris: "+u+" HTTP "+h.status);let w=null,a=null;try{let f=await h.clone().json(),g=f&&f.cartData;g&&(w=fe(g.total!=null?g.total:g.totalPrice),a=g.totalUnitCount!=null?Number(g.totalUnitCount):Array.isArray(g.products)?g.products.length:null)}catch(f){}return{platform:"hybris",productCode:o,size:n.textContent.trim(),cartValue:w,itemCount:a,currency:"BRL"}}function fe(t){if(t==null||t==="")return null;if(typeof t=="number")return Number.isFinite(t)?t:null;let e=String(t).replace(/[^\d.,]/g,"");if(!e)return null;let r=e.indexOf(",")>e.indexOf(".")?parseFloat(e.replace(/\./g,"").replace(",",".")):parseFloat(e.replace(/,/g,""));return Number.isFinite(r)?r:null}function br(){try{let t=[".js-cart-total",".cart-total",".total-price",".grand-total",'[class*="cart"][class*="total" i]'];for(let e of t){let r=document.querySelector(e),n=r&&fe(r.textContent);if(n)return{value:n,itemCount:null,currency:"BRL"}}}catch(t){}return null}var _t={};I(_t,{addToCart:()=>vr,detect:()=>Cr,getCartSummary:()=>Sr,id:()=>_r,resolveSku:()=>kr});var _r="vtex";function Cr(){return!!(window.vtex||window.vtexjs||window.vtxctx||window.skuJson_0)}function kr(){let t=window;return t.vtxctx&&t.vtxctx.skus&&t.vtxctx.skus[0]?{value:String(t.vtxctx.skus[0]),source:"vtex/vtxctx"}:t.skuJson_0&&t.skuJson_0.skus&&t.skuJson_0.skus[0]?{value:String(t.skuJson_0.skus[0].sku),source:"vtex/skuJson"}:null}var Z=t=>String(t==null?"":t).trim().toLowerCase();async function vr({size:t,quantity:e}){let r=window.skuJson_0&&window.skuJson_0.skus||[];if(!r.length)throw new Error("vtex: skuJson_0 indispon\xEDvel");let n=i=>Z(i.skuname)===Z(t)||i.dimensions&&Object.values(i.dimensions).some(c=>Z(c)===Z(t)),o=t?r.find(i=>n(i)&&i.available)||r.find(n):null;if(o||(o=r.find(i=>i.available)||r[0]),!o)throw new Error("vtex: variante n\xE3o encontrada");if(window.vtexjs&&window.vtexjs.checkout&&window.vtexjs.checkout.addToCart)return await window.vtexjs.checkout.addToCart([{id:parseInt(o.sku,10),quantity:e||1,seller:"1"}]),{platform:"vtex",skuId:o.sku,size:o.skuname||t};throw new Error("vtex: vtexjs.checkout indispon\xEDvel")}function Sr(){try{let t=window.vtexjs&&window.vtexjs.checkout&&window.vtexjs.checkout.orderForm;if(t&&typeof t.value=="number"){let e=t.storePreferencesData&&t.storePreferencesData.currencyCode||"BRL",r=(t.items||[]).reduce((n,o)=>n+(Number(o.quantity)||1),0);return{value:t.value/100,itemCount:r,currency:e}}}catch(t){}return null}var Ct={};I(Ct,{addToCart:()=>Ir,detect:()=>Er,getCartSummary:()=>Pr,id:()=>Tr,resolveSku:()=>Lr,skipRedirect:()=>Ar});var Tr="nuvemshop",Ar=!0;function Er(){return!!(window.LS&&(window.LS.cart||window.LS.addToCart))}function Lr(){try{let t=window.LS,e=t&&t.variants||[],r=document.querySelector('[name="variant_id"]'),n=r&&r.value?e.find(o=>String(o.id)===String(r.value)):null;if(n||(n=e.find(o=>o.available!==!1&&o.sku)||e.find(o=>o.sku)||e[0]),n&&n.sku)return{value:String(n.sku),source:"nuvemshop/variant"};if(t&&t.product&&t.product.sku)return{value:String(t.product.sku),source:"nuvemshop/product"}}catch(t){}return null}var Q=t=>String(t==null?"":t).trim().toLowerCase();async function Ir({size:t,quantity:e}){let r=document.getElementById("product_form")||document.querySelector('.js-product-form, form[action*="/comprar"]');if(!r)throw new Error("nuvemshop: #product_form n\xE3o encontrado");t&&r.querySelectorAll('select[name^="variation"]').forEach(i=>{let c=[...i.options].find(s=>Q(s.textContent).includes(Q(t))||Q(s.value)===Q(t));c&&(i.value=c.value,i.dispatchEvent(new Event("change",{bubbles:!0})))});let n=r.querySelector('[name="quantity"]');return n&&e&&(n.value=String(e)),await new Promise(i=>setTimeout(i,400)),typeof r.requestSubmit=="function"?r.requestSubmit():r.submit(),{platform:"nuvemshop",variantId:(r.querySelector('[name="variant_id"]')||{}).value||null}}function Pr(){try{let t=window.LS,e=t&&t.cart;if(!e)return null;let r=t.currency&&t.currency.code||"BRL",n=Array.isArray(e.items)?e.items.reduce((i,c)=>i+(Number(c.quantity)||1),0):Number(e.items)||0,o=e.subtotal!=null?Number(e.subtotal):null;return{value:o!=null?o/100:null,itemCount:n,currency:r}}catch(t){return null}}var kt={};I(kt,{addToCart:()=>Or,detect:()=>Br,getCartSummary:()=>Mr,id:()=>Rr,resolveSku:()=>Nr,skipRedirect:()=>jr});var Rr="wake",jr=!0;function Br(){return!!(window.StorefrontClient||typeof window.addOrCreateCheckout=="function"||typeof window.addToCartClick=="function")}function Nr(){try{let t=document.querySelector('input[name="product-id"], [data-product-id]'),e=t?t.value||t.getAttribute("data-product-id"):null;if(e)return{value:String(e).trim(),source:"wake/product-id"};let r=(location.pathname||"").match(/-(\d+)\/?(?:[?#]|$)/);if(r)return{value:r[1],source:"wake/url"}}catch(t){}return null}var pe=t=>String(t==null?"":t).trim().toLowerCase();async function Or({size:t,quantity:e}){if(t){let i=[...document.querySelectorAll("input[attribute-value]")].find(c=>pe(c.getAttribute("attribute-value"))===pe(t));if(i){try{i.checked=!0}catch(c){}try{typeof window.selectAttribute=="function"?window.selectAttribute(i):i.click()}catch(c){}await new Promise(c=>setTimeout(c,600))}}let r=document.querySelector('[name="product-variant-id"]'),n=r&&r.value;if(!n)throw new Error("wake: product-variant-id n\xE3o encontrado");if(typeof window.addOrCreateCheckout!="function")throw new Error("wake: addOrCreateCheckout indispon\xEDvel");if(!await window.addOrCreateCheckout([{productVariantId:Number(n),quantity:e||1,customization:[]}]))throw new Error("wake: addOrCreateCheckout retornou false");return{platform:"wake",productVariantId:n,size:t||null}}function Mr(){try{let t=document.querySelectorAll('[class*="total" i],[class*="minicart" i],[class*="cart" i]');for(let e of t){let r=e.textContent||"";if(/total/i.test(r)){let n=r.match(/R\$\s*([\d.]+,\d{2})/);if(n){let o=parseFloat(n[1].replace(/\./g,"").replace(",","."));if(Number.isFinite(o)&&o>0)return{value:o,itemCount:null,currency:"BRL"}}}}}catch(t){}return null}var St={};I(St,{addToCart:()=>tt,detect:()=>Fr,id:()=>Ur,resolveSku:()=>vt});var Ur="generic";function Fr(){return!0}function vt(){let t=v(["Product"]);if(t[0]){let e=t[0],r=e.sku||e.mpn||e.gtin13||e.productID;if(r)return{value:String(r),source:"jsonld"}}try{let e=document.querySelector('[itemprop="sku"]');if(e){let r=e.getAttribute("content")||(e.textContent||"").trim();if(r)return{value:String(r),source:"microdata"}}}catch(e){}try{let e=window.konfidencyData;if(e&&e.product&&e.product.variants&&e.product.variants[0])return{value:String(e.product.variants[0]),source:"konfidency"}}catch(e){}return null}var Dr=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora/i,qr=/continuar|como comprar|lista|desejos|favorito/i;async function tt(){let t=document.querySelectorAll("button,[role=button],input[type=submit]");for(let e of t){let r=(e.textContent||e.value||"").replace(/\s+/g," ").trim();if(r&&r.length<40&&Dr.test(r)&&!qr.test(r))try{return e.click(),{platform:"native-click",clicked:r}}catch(n){}}return{platform:"none",error:"bot\xE3o de carrinho nativo n\xE3o encontrado"}}var ye=[xt,bt,_t,Ct,kt],zr=[["woocommerce",()=>!!(window.wc_add_to_cart_params||window.woocommerce_params)],["lojaintegrada",()=>!!window.LojaIntegrada]],et;function z(){return et||(et=ye.find(t=>{try{return t.detect()}catch(e){return!1}})||St,et)}function ge(){let t=ye.find(e=>{try{return e.detect()}catch(r){return!1}});if(t)return t.id;for(let[e,r]of zr)try{if(r())return e}catch(n){}return null}function $(){let t=z();if(t.id!=="generic"&&t.resolveSku)try{let e=t.resolveSku();if(e)return e}catch(e){}return vt()}async function we(t){t=t||{};let e={size:t.size||t.selectedSize||t.tamanho||null,color:t.color||t.selectedColor||t.colour||t.cor||null,sku:t.sku||t.identifier||t.selectedIdentifier||null,quantity:t.quantity||1},r=z();try{let n=r.addToCart?await r.addToCart(e):await tt(e);return y("cart: adicionado",n),he(),me(r,n,e.sku),n}catch(n){y('cart: adapter "'+r.id+'" falhou \u2014 fallback clique nativo',n&&n.message);let o=await tt(e);return he(),me(r,o,e.sku),o}}async function me(t,e,r){try{let n=null;e&&e.cartValue!=null?n={value:e.cartValue,itemCount:e.itemCount!=null?e.itemCount:null,currency:e.currency||null}:t&&t.getCartSummary&&(n=await t.getCartSummary()),n&&n.value!=null&&l("cart_value",{via:"tryon",value:n.value,itemCount:n.itemCount!=null?n.itemCount:null,currency:n.currency||null,sku:r||null})}catch(n){}}async function xe(){let t=z();if(t&&t.getCartSummary)try{return await t.getCartSummary()}catch(e){}return null}function he(){["cart:refresh","cart:updated","cart:build","ajaxProduct:added","product:added-to-cart"].forEach(t=>{try{document.dispatchEvent(new CustomEvent(t))}catch(e){}})}async function be(){let t=z(),e=m(),r=null;try{r=await N()}catch(i){}let n=r&&r.template&&r.template.cart||r&&r.cart||{},o=n.afterAdd||n.behavior||e.cartBehavior;if(o||(o=e.cartRedirect===!1?"none":"auto"),o==="none")return!1;if(o==="auto"||o==="drawer"){let i=n.openSelector||e.cartOpenSelector;if(i){let c=document.querySelector(i);if(c)return setTimeout(()=>{try{c.click()}catch(s){}},300),!1}else if(t&&t.openCartDrawer){let c=!1;try{c=t.openCartDrawer()}catch(s){}if(c)return!1}}return!0}function _e(){let t=z();if(t&&t.skipRedirect)return;let e=t&&t.cartUrl||"/cart";setTimeout(()=>{try{window.location.href=e}catch(r){}},250)}var $r=/\/(thank[_-]?you|orders?\/|pedido[_-]?(confirmado|realizado|finalizado|sucesso)|sucesso|order[_-]?confirmation|compra[_-]?(finalizada|concluida)|orderplaced)/i,Kr=/\/checkout/i,Hr=/\/(cart|carrinho|sacola|bag)(\/|$|\?|#)/i,Vr=/\/(products?|produtos?|p)\//i,Jr=/\/(collections?|categoria|categorias|c|departamento)\//i,Gr=/\/(search|busca|s)(\/|\?)/i;function Ce(){try{if(window.__mkPageType)return window.__mkPageType}catch(e){}try{let e=v();for(let r of e){let n=Array.isArray(r["@type"])?r["@type"]:[r["@type"]];if(n.includes("Order")||n.includes("Invoice"))return"purchase";if(n.includes("Product"))return"pdp";if(n.includes("SearchResultsPage"))return"search";if(n.includes("CollectionPage")||n.includes("ItemList"))return"category"}}catch(e){}let t=(location.pathname||"").toLowerCase();return t==="/"||t===""||t==="/home"||t==="/index.html"?"home":$r.test(t)?"purchase":Kr.test(t)?"checkout":Hr.test(t)?"cart":Vr.test(t)?"pdp":Jr.test(t)?"category":Gr.test(t)?"search":"other"}function ke(t){let e=null;try{let r=new URLSearchParams(location.search),n=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],o={};for(let i of n){let c=r.get(i);c&&(o[i.replace("utm_","")]=c)}Object.keys(o).length&&(e=o)}catch(r){}return{url:location.href,pathname:location.pathname,referrer:document.referrer||null,title:document.title||null,pageType:t,utm:e,userAgent:navigator.userAgent,language:navigator.language,viewport:window.innerWidth+"x"+window.innerHeight,platform:Wr()}}function Wr(){return ge()}var Tt={},Yr=null,K=0,ve=!1;function Se(t){ve||(ve=!0,Te(t),Xr(),Zr(),Qr(),tn(),en(t))}function Te(t){Tt={};let e=Ce(),r=ke(e);if(ne(r),l("view",{url:location.href,pathname:location.pathname,referrer:document.referrer||null,title:document.title||null,pageType:e}),typeof t=="function")try{t(e,r)}catch(n){}}function Xr(){if(!document.body)return;let t={A:1,BUTTON:1,INPUT:1,SELECT:1,TEXTAREA:1},e=0;document.body.addEventListener("click",r=>{try{let n=Date.now();if(n-e<100)return;e=n;let o=r.target;for(let s=0;s<5&&o&&o!==document.body&&!(t[o.tagName]||o.getAttribute&&o.getAttribute("role")==="button");s++)o=o.parentElement;if(!o||!t[o.tagName]&&!(o.getAttribute&&o.getAttribute("role")==="button"))return;let i={tag:o.tagName},c=o.tagName==="INPUT"||o.tagName==="TEXTAREA"?o.value:o.textContent;i.text=(c||"").replace(/\s+/g," ").trim().substring(0,100),o.href&&(i.href=String(o.href).substring(0,500)),o.id&&(i.id=o.id),o.className&&typeof o.className=="string"&&(i.classes=o.className.trim().substring(0,200)),l("click",i)}catch(n){}},{capture:!0,passive:!0})}function Zr(){let t=[25,50,75,100],e=null,r=()=>{try{let n=window.scrollY||document.documentElement.scrollTop||0,o=Math.max(document.body&&document.body.scrollHeight||0,document.documentElement&&document.documentElement.scrollHeight||0);if(o<=0)return;let i=Math.min(100,Math.floor((n+window.innerHeight)/o*100));for(let c of t)i>=c&&!Tt[c]&&(Tt[c]=!0,l("scroll_depth",{depth:c}))}catch(n){}};r(),window.addEventListener("scroll",()=>{e||(e=setTimeout(()=>{e=null,r()},250))},{passive:!0})}function Qr(){document.body&&document.body.addEventListener("submit",t=>{try{let e=t.target;if(!e||e.tagName!=="FORM"||e.querySelector('input[type="password"], input[name*="card"], input[name*="cpf"]'))return;let r="other",n=(e.className||"").toLowerCase(),o=(e.action||"").toLowerCase();e.querySelector('input[type="search"], input[name="q"], input[name="s"]')?r="search":/newsletter|subscribe|mailchimp/.test(n+o)?r="newsletter":/contact|contato/.test(n+o)&&(r="contact"),l("form_submit",{form_id:e.id||"",form_type:r})}catch(e){}},{capture:!0})}function tn(){let t=m();K=Date.now(),Yr=setInterval(()=>{if(document.hidden)return;let e=Date.now(),r=Math.round((e-K)/1e3);K=e,r>0&&r<60&&l("engagement",{url:location.pathname,dwellSec:r})},t.engagementIntervalMs),document.addEventListener("visibilitychange",()=>{if(document.hidden){let e=Math.round((Date.now()-K)/1e3);e>0&&e<600&&l("engagement",{url:location.pathname,dwellSec:e})}K=Date.now()})}function en(t){let e=location.href,r=()=>{location.href!==e&&(e=location.href,Te(t))};try{let n=history.pushState,o=history.replaceState;history.pushState=function(){n.apply(this,arguments),setTimeout(r,0)},history.replaceState=function(){o.apply(this,arguments),setTimeout(r,0)},window.addEventListener("popstate",r)}catch(n){}}function At(){let t=$(),e=v(["Product"]);if(e.length>0){let o=e[0],i=Array.isArray(o.offers)?o.offers[0]:o.offers;return{sku:t?t.value:o.sku||o.mpn||o.gtin13||o.productID||null,skuSource:t?t.source:null,name:typeof o.name=="string"?o.name:null,price:i&&parseFloat(i.price||i.lowPrice)||null,currency:i?i.priceCurrency:null,brand:o.brand?typeof o.brand=="string"?o.brand:o.brand.name:null,category:o.category||null}}let r=o=>{let i=document.querySelector('meta[property="og:'+o+'"], meta[property="product:'+o+'"]');return i?i.getAttribute("content"):null},n=o=>{let i=document.querySelector('[itemprop="'+o+'"]');return i?i.getAttribute("content")||(i.textContent||"").trim():null};if(t||r("type")==="product"||r("price:amount")||n("name")){let o=n("price")||r("price:amount");return{sku:t?t.value:null,skuSource:t?t.source:null,name:n("name")||r("title")||document.title||null,price:o&&parseFloat(String(o).replace(",","."))||null,currency:n("priceCurrency")||r("price:currency")||null,brand:n("brand")||null,category:null}}return null}function E(){try{let t=location.pathname+location.search,e=t.match(/order[_-]?confirmation\/([\w-]+)/i)||t.match(/[?&]order[_-]?id=([\w-]+)/i)||t.match(/\/orders?\/([\w-]{4,})/i)||t.match(/pedido[_-]?(?:confirmado|realizado|finalizado)?\/([\w-]+)/i);return e?e[1]:null}catch(t){return null}}function Et(){let t=v(["Order","Invoice"]);if(t.length>0){let o=t[0],i=o.totalPaymentDue?parseFloat(o.totalPaymentDue.price):parseFloat(o.price||o.total);return{orderId:o.orderNumber||o.confirmationNumber||o.identifier||E(),revenue:Number.isFinite(i)?i:null,currency:o.totalPaymentDue&&o.totalPaymentDue.priceCurrency||o.priceCurrency||null,source:"jsonld"}}try{let o=window.Shopify&&window.Shopify.checkout;if(o&&o.total_price!=null){let i=parseFloat(o.total_price);return{orderId:(o.order_id!=null?String(o.order_id):null)||o.token||E(),revenue:Number.isFinite(i)?i:null,currency:o.currency||null,itemCount:Array.isArray(o.line_items)?o.line_items.length:null,source:"shopify"}}}catch(o){}try{if(Array.isArray(window.dataLayer))for(let o=window.dataLayer.length-1;o>=0;o--){let i=window.dataLayer[o],c=i&&i.ecommerce;if(c&&(i.event==="purchase"||c.purchase)){let s=c.purchase&&c.purchase.actionField,u=parseFloat(s&&(s.revenue||s.value)||c.value||c.revenue);return{orderId:s&&s.id||c.transaction_id||c.transactionId||E(),revenue:Number.isFinite(u)?u:null,currency:c.currency||c.currencyCode||null,itemCount:(c.purchase&&c.purchase.products||c.items||c.products||[]).length||null,source:"datalayer"}}}}catch(o){}let e=document.querySelector('meta[property="order:total"], meta[name="order-total"]');if(e&&e.content)return{orderId:E(),revenue:parseFloat(e.content)||null,source:"meta"};let r=rn();if(r)return r;let n=E();return n?{orderId:n,revenue:null,source:"url"}:null}function rn(){try{let t=[".order-total","#order-total",".total-price",".order__total","[data-order-total]",".summary-total",".grand-total"];for(let e of t){let r=document.querySelector(e);if(r){let n=on(r.textContent);if(n)return{orderId:nn(),revenue:n,source:"dom"}}}return null}catch(t){return null}}function nn(){try{let e=(document.body.innerText||"").match(/(?:pedido|order|n[º°o]\.?)\s*#?\s*([A-Z0-9-]{4,})/i);return e?e[1]:null}catch(t){return null}}function on(t){if(!t)return null;let e=String(t).replace(/[^\d.,]/g,"");if(!e)return null;let r;e.indexOf(",")>e.indexOf(".")?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");let n=parseFloat(r);return Number.isFinite(n)&&n>0?n:null}function Ae(){let t=v(["ItemList","CollectionPage"]);if(t.length===0)return null;let e=t[0],r=e.itemListElement||e.mainEntity&&e.mainEntity.itemListElement||[],n=[];for(let o of r.slice(0,50)){let i=o.item||o;i&&(i.sku||i.productID||i.name)&&n.push(i.sku||i.productID||i.name)}return n.length>0?{count:n.length,skus:n.slice(0,20)}:null}var Ee=!1,rt=[/\b(adicionar|adic\.?|colocar|incluir|jogar)\b.{0,30}\b(carrinho|sacola|sacolinha|bag)\b/i,/\bcomprar\b(?!\s+(em|por|sem))/i,/\bcomprar\s*$/i,/^add\s+to\s+(cart|bag)\b/i,/^buy\s+(now|it|this)\b/i,/^(sacolinha|carrinho|sacola)$/i],cn=[/^finalizar(\s+(compra|pedido|pagamento))?\b/i,/^(fechar|confirmar)\s+(compra|pedido|pagamento)\b/i,/^pagar(\s+(agora|pedido))?\b/i,/^(complete|place)\s+(purchase|order)\b/i,/^checkout$/i];function H(t,e){for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}function Pe(t){switch(t){case"pdp":{let e=At();l("view_item",e||{sku:null});break}case"category":case"search":{let e=Ae();l("view_item_list",e||{count:0});break}case"cart":xe().then(e=>l("view_cart",e&&e.value!=null?{value:e.value,itemCount:e.itemCount,currency:e.currency}:{})).catch(()=>l("view_cart",{}));break;case"checkout":l("begin_checkout",{});break;case"purchase":an();break}}var Le=500,Ie=16;function an(){let t=!1,e=0,r=(o,i)=>{t||(t=!0,ln(o,i))};try{window.addEventListener("pagehide",()=>r(Et(),!0),{once:!0})}catch(o){}let n=()=>{if(t)return;let o=Et();if(o&&o.revenue!=null)return r(o);if(e++>=Ie)return y("purchase: receita n\xE3o apareceu em "+Le*Ie+"ms \u2014 emitindo sem valor"),r(o);setTimeout(n,Le)};n()}function ln(t,e){if(t&&!t.orderId&&(t.orderId=E()),t&&t.orderId){let r="_mk_purch_"+t.orderId;try{if(sessionStorage.getItem(r)){y("purchase j\xE1 contado",t.orderId);return}sessionStorage.setItem(r,"1")}catch(n){}}else if(Ee)return;if(Ee=!0,l("purchase",t||{revenue:null,_note:"no_order_data_extracted"}),y("purchase emitido",t),e)try{A(!0)}catch(r){}}function Re(){if(!document.body)return;let t=0;document.body.addEventListener("click",e=>{try{let r=Date.now();if(r-t<150)return;let n=e.target;for(let s=0;s<5&&n&&n!==document.body&&!(n.tagName==="BUTTON"||n.tagName==="A"||n.getAttribute&&n.getAttribute("role")==="button");s++)n=n.parentElement;if(!n)return;let o=n.tagName!=="A",i=(n.textContent||"").replace(/\s+/g," ").trim();if(!i||i.length>80)return;let c=!1;if((H([rt[0]],i)||o&&H([rt[1]],i)||o&&H([rt[2]],i)||H(rt.slice(3),i))&&(c=!0),c){t=r;let s=At();l("add_to_cart",{via:"click",buttonText:i,sku:s?s.sku:null,price:s?s.price:null});return}o&&H(cn,i)&&(t=r,l("begin_checkout",{via:"click",buttonText:i}))}catch(r){}},{capture:!0,passive:!0})}var k=null,S=null,ot=!1,it=!1,O=null,je={},Lt=null,nt=0,_={onReady:null,onClose:null,onAddToCart:null,onProductLoaded:null,onError:null,onInteraction:null,onGenerationComplete:null},sn={gregory:"698c7e791d3129430f15dddd"};function Ne(t){return t?sn[String(t).toLowerCase()]||t:null}async function M(t,e){let r=m(),n=Ne(t);e=String(e||"").trim();let o=r.apiUrl+"/availability/"+n+"?sku="+encodeURIComponent(e),i=await fetch(o);if(!i.ok)throw new Error("availability HTTP "+i.status);return i.json()}async function Oe(t,e){e||(e=t,t="698c7e791d3129430f15dddd");try{return(await M(t,e)).available===!0}catch(r){return!1}}async function ct(t){if(t=t||{},ot)return;let e=Ne(t.projectId||t.projectid||t.store),r=String(t.identifier||t.sku||"").trim();if(!e||!r){console.error("[mk-sdk] open: projectId e identifier obrigatorios");return}let n=e+":"+r;if(je[n]!==!0){try{if(!(await M(e,r)).available){alert("Produto nao disponivel para prova virtual.");return}}catch(o){alert("Produto nao encontrado ou indisponivel.");return}je[n]=!0}O={projectId:e,identifier:r,width:t.width||430,height:t.height||800},it=!1,Fe(),un(O),ot=!0,nt=Date.now(),l("modal_opened",{projectId:e,identifier:r})}function Pt(){if(!ot)return;let t=it;if(it=!1,dn(),ot=!1,L("onClose"),l("modal_closed",{projectId:O&&O.projectId,identifier:O&&O.identifier}),t)try{_e()}catch(e){}}function Me(t){try{let e=document.getElementById("mk-tryon-button-host");if(!e)return;t?(e.dataset.mkPrevDisplay===void 0&&(e.dataset.mkPrevDisplay=e.style.display),e.style.display="none"):(e.style.display=e.dataset.mkPrevDisplay||"",delete e.dataset.mkPrevDisplay)}catch(e){}}function un(t){k=document.createElement("div"),k.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,.8);display:flex;align-items:center;justify-content:center;z-index:2147483647;",Me(!0);let e=document.createElement("div"),r=typeof t.width=="number"?t.width+"px":t.width,n=typeof t.height=="number"?t.height+"px":t.height;e.style.cssText="position:relative;width:"+r+";height:"+n+";max-width:100vw;max-height:100dvh;border-radius:12px;overflow:hidden;background:#fff;",S=document.createElement("iframe");let o=encodeURIComponent(t.identifier).replace(/\./g,"%2E");S.src=m().appUrl+"/"+t.projectId+"/"+o,S.style.cssText="width:100%;height:100%;border:none;",S.setAttribute("allow","camera *; microphone *"),S.setAttribute("allowfullscreen","true"),e.appendChild(S),k.appendChild(e),document.body.appendChild(k),y("try-on modal aberto",S.src)}function dn(){k&&k.parentNode&&k.parentNode.removeChild(k),k=null,S=null,Me(!1)}var Be=!1;function Ue(){Fe()}function Fe(){Be||(Be=!0,window.addEventListener("message",t=>{let e=t.data;if(!e||e.source!=="mkfashion-app")return;let r=e.action,n=e.data||{};switch(r){case"close_request":Pt();break;case"ready":L("onReady",n);break;case"product_loaded":L("onProductLoaded",n),l("product_loaded",It(n));break;case"interaction":{L("onInteraction",n),n&&n.method&&(Lt=n.method),l(fn(n),It(n));break}case"add_to_cart":l("add_to_cart",Object.assign({via:"tryon"},It(n))),typeof _.onAddToCart=="function"?L("onAddToCart",n):we(n).then(()=>be()).then(o=>{it=!!o}).catch(()=>{});break;case"generation_start":nt=Date.now();break;case"generation_complete":L("onGenerationComplete",n),l("generation_complete",{method:n.method||Lt||"unknown",durationMs:nt?Date.now()-nt:null,success:n.success!==!1,imageUrlPresent:!!n.imageUrl});break;case"generation_error":L("onError",n),l("generation_error",{method:Lt||"unknown",error:n&&n.error});break}}))}function fn(t){return t&&t.action,"interaction"}function It(t){if(!t||typeof t!="object")return t;let e={};for(let r in t){if(r==="imageUrl"||r==="image"||r==="product"){r==="product"&&t[r]?(e.productSku=t[r].sku||null,e.productName=t[r].name||null):e[r+"Present"]=!!t[r];continue}e[r]=t[r]}return e}function L(t,e){if(typeof _[t]=="function")try{_[t](e)}catch(r){console.error("[mk-sdk]",r)}}function De(t){_.onReady=t}function qe(t){_.onClose=t}function ze(t){_.onAddToCart=t}function $e(t){_.onProductLoaded=t}function Ke(t){_.onError=t}function He(t){_.onInteraction=t}function Ve(t){_.onGenerationComplete=t}var mn=767,hn=1024,yn=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora|^comprar$|finalizar compra|eu quero/i,gn=/continuar|como comprar|lista|desejos|favorito|looks|cupom/i;function Rt(t){try{let e=t.getBoundingClientRect();if(e.width<=0||e.height<=0)return!1;let r=getComputedStyle(t);return r.display!=="none"&&r.visibility!=="hidden"&&r.opacity!=="0"}catch(e){return!1}}function wn(t){if(!t)return!1;try{let e=document.querySelector(t);return!!e&&Rt(e)}catch(e){return!1}}function xn(t){return(t.tagName==="INPUT"?t.value||"":t.textContent||"").replace(/\s+/g," ").trim()}function bn(t){if(!t||typeof t!="object"||t.selector)return t;let e=!1;if(["mobile","tablet","desktop"].forEach(n=>{let o=t[n];o&&o.mkAnchor===1&&o.anchor&&typeof o.anchor=="object"&&(e=!0)}),!e)return t;let r={};return["mobile","tablet","desktop"].forEach(n=>{let o=t[n];if(o){if(o.selector){r[n]=o;return}if(o.mkAnchor===1&&o.anchor&&typeof o.anchor=="object"){let i=o.anchor[n]||o.anchor.desktop||o.anchor.mobile||o.anchor.tablet;i&&i.selector&&(r[n]=i)}}}),["bpMobile","bpTablet","breakpoint"].forEach(n=>{t[n]!=null&&(r[n]=t[n])}),r}function jt(t){if(!t||typeof t!="object")return null;if(t=bn(t),t.selector)return t;let e=[["mobile",t.mobile],["tablet",t.tablet],["desktop",t.desktop]].filter(u=>u[1]&&u[1].selector);if(e.length===0)return null;if(e.length===1)return e[0][1];let r=e.filter(([,u])=>wn(u.selector));if(r.length===1)return r[0][1];let n=window.innerWidth||1024,o=Number(t.bpMobile)||Number(t.breakpoint)||mn,i=Number(t.bpTablet)||hn,c=u=>(e.find(d=>d[0]===u)||[])[1],s=n<=o?["mobile","tablet","desktop"]:n<=i?["tablet","desktop","mobile"]:["desktop","tablet","mobile"];for(let u of s){let d=c(u);if(d)return d}return e[0][1]}function Je(){let t=m(),e=jt(t&&t.anchor);if(e&&e.selector)try{let n=document.querySelector(e.selector);if(n&&Rt(n))return{el:n,position:e.position||"afterend",mode:e.mode||"flow",style:e.style||"",align:e.align||"top-left",selector:e.selector}}catch(n){}let r=document.querySelectorAll('button, [role="button"], a.btn, a.button, input[type="submit"], input[type="button"]');for(let n of r){let o=xn(n);if(!(!o||o.length>40)&&!gn.test(o)&&yn.test(o)&&Rt(n))return{el:n,position:"afterend",mode:"flow",style:"",selector:null}}return null}var b="'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Bt={none:"0",sm:"4px",md:"8px",pill:"9999px"},Nt={none:"0",sm:"4px",md:"8px",lg:"16px"},_n='<svg viewBox="0 0 17.5263 20.6862" fill="none" xmlns="http://www.w3.org/2000/svg" style="display:block;width:100%;height:100%"><g><path d="M8.49995 12.1862C10.1568 12.1862 11.5 10.8431 11.5 9.18622C11.5 7.52936 10.1568 6.18622 8.49995 6.18622C6.8431 6.18622 5.49995 7.52936 5.49995 9.18622C5.49995 10.8431 6.8431 12.1862 8.49995 12.1862Z" stroke="currentColor" shape-rendering="crispEdges"/><path d="M0.5 9.11152C0.5 6.56953 0.5 5.29894 1.1099 4.38664C1.375 3.9902 1.71424 3.65088 2.10821 3.38809C2.6945 2.9958 3.42899 2.85564 4.55351 2.80588C5.09013 2.80588 5.55183 2.39949 5.65687 1.87284C5.73715 1.48708 5.94572 1.14138 6.24735 0.894155C6.54898 0.646934 6.92516 0.51336 7.31231 0.516006H9.9734C10.7779 0.516006 11.4709 1.08412 11.6288 1.87284C11.7339 2.39949 12.1956 2.80588 12.7322 2.80588C13.8559 2.85564 12.9129 4.67413 13.5 5.06559C13.8949 5.32932 15.1484 3.80355 15.5 4.02647C16.1099 4.93876 16.7857 6.56953 16.7857 9.11152C16.7857 11.6535 16.7857 12.9233 16.1758 13.8364C15.9107 14.2328 15.5715 14.5722 15.1775 14.835C14.2647 15.4445 12.9936 15.4445 10.4522 15.4445H6.83351C4.29213 15.4445 3.02103 15.4445 2.10821 14.835C1.71446 14.5718 1.3755 14.2322 1.11071 13.8356C0.933802 13.5672 0.803519 13.2698 0.725557 12.9564" stroke="currentColor" stroke-linecap="round"/><path d="M12.676 0.607931C12.9446 -0.178095 14.0307 -0.2019 14.3491 0.536515L14.3761 0.60838L14.7385 1.66839C14.8216 1.91149 14.9559 2.13395 15.1322 2.32076C15.3086 2.50757 15.5229 2.65439 15.7608 2.75131L15.8583 2.78769L16.9183 3.14971C17.7044 3.41831 17.7282 4.50437 16.9902 4.82283L16.9183 4.84978L15.8583 5.21225C15.6151 5.29526 15.3926 5.42947 15.2057 5.60582C15.0188 5.78218 14.8719 5.99657 14.7749 6.23453L14.7385 6.33155L14.3765 7.39201C14.1079 8.17803 13.0219 8.20184 12.7039 7.46387L12.676 7.39201L12.314 6.332C12.231 6.08881 12.0968 5.86627 11.9204 5.67938C11.744 5.49249 11.5297 5.3456 11.2917 5.24863L11.1947 5.21225L10.1347 4.85022C9.34817 4.58163 9.32437 3.49557 10.0628 3.17756L10.1347 3.14971L11.1947 2.78769C11.4378 2.70462 11.6602 2.57039 11.847 2.39404C12.0339 2.21769 12.1807 2.00333 12.2776 1.76541L12.314 1.66839L12.676 0.607931Z" fill="currentColor"/></g></svg>',Cn='<svg viewBox="0 0 11.6122 12.7248" fill="none" xmlns="http://www.w3.org/2000/svg" style="display:block;width:12px;height:12px"><path d="M4.09055 2.01133C4.43939 0.9905 5.84989 0.959583 6.26347 1.91858L6.29847 2.01192L6.76922 3.38858C6.8771 3.7043 7.05144 3.99321 7.28047 4.23583C7.5095 4.47845 7.7879 4.66912 8.09689 4.795L8.22347 4.84225L9.60014 5.31242C10.621 5.66125 10.6519 7.07175 9.69347 7.48533L9.60014 7.52033L8.22347 7.99108C7.90764 8.09889 7.61862 8.2732 7.3759 8.50223C7.13318 8.73127 6.94241 9.0097 6.81647 9.31875L6.76922 9.44475L6.29905 10.822C5.95022 11.8428 4.53972 11.8737 4.12672 10.9153L4.09055 10.822L3.62039 9.44533C3.51258 9.12951 3.33827 8.84048 3.10924 8.59776C2.8802 8.35504 2.60177 8.16427 2.29272 8.03833L2.16672 7.99108L0.790054 7.52092C-0.231363 7.17208 -0.26228 5.76158 0.69672 5.34858L0.790054 5.31242L2.16672 4.84225C2.48244 4.73437 2.77135 4.56003 3.01397 4.331C3.25658 4.10197 3.44726 3.82357 3.57314 3.51458L3.62039 3.38858L4.09055 2.01133ZM9.86147 0C9.9706 0 10.0775 0.0306123 10.1701 0.0883584C10.2627 0.146104 10.3373 0.228668 10.3853 0.326667L10.4133 0.394917L10.6175 0.993417L11.2166 1.19758C11.3259 1.23474 11.4218 1.30353 11.492 1.39523C11.5623 1.48693 11.6037 1.59741 11.611 1.71268C11.6184 1.82795 11.5914 1.94281 11.5334 2.04271C11.4755 2.14261 11.3891 2.22305 11.2854 2.27383L11.2166 2.30183L10.6181 2.506L10.4139 3.10508C10.3767 3.21442 10.3078 3.31024 10.2161 3.38041C10.1244 3.45058 10.0139 3.49194 9.89859 3.49925C9.78333 3.50656 9.66849 3.47949 9.56863 3.42147C9.46876 3.36345 9.38837 3.27709 9.33764 3.17333L9.30964 3.10508L9.10547 2.50658L8.50639 2.30242C8.39702 2.26526 8.30115 2.19647 8.23092 2.10477C8.16069 2.01307 8.11926 1.90259 8.11189 1.78732C8.10452 1.67205 8.13153 1.55719 8.18951 1.45729C8.24749 1.35739 8.33381 1.27695 8.43755 1.22617L8.50639 1.19817L9.10489 0.994L9.30905 0.394917C9.34839 0.279665 9.42281 0.179613 9.52187 0.108791C9.62094 0.0379686 9.73969 -0.0000730808 9.86147 0Z" fill="currentColor"/></svg>';function p(t,e={}){let r=document.createElement(t);if(e.style&&(r.style.cssText=e.style),e.text!=null&&(r.textContent=e.text),e.html!=null&&(r.innerHTML=e.html),e.attrs)for(let n in e.attrs)r.setAttribute(n,e.attrs[n]);if(e.on)for(let n in e.on)r.addEventListener(n,e.on[n]);if(e.children)for(let n of e.children)n&&r.appendChild(n);return r}function at(t){return p("span",{style:`width:24px;height:24px;padding:2px;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:_n})}function Ge(t){return p("span",{style:`width:12px;height:12px;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:Cn})}function lt(t){return t.borderWidth>0&&t.borderColor?`${t.borderWidth}px solid ${t.borderColor}`:"none"}function st(){if(!document.getElementById("mk-jakarta-font"))try{document.head.appendChild(p("link",{attrs:{id:"mk-jakarta-font",rel:"stylesheet",href:"https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap"}}))}catch(t){}}function kn(t){return t.subtext?p("span",{style:`display:flex;align-items:center;justify-content:center;padding:4px;background:${t.badgeBgColor};font-family:${b};font-weight:700;font-size:16px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,text:t.subtext}):null}function We(t,e){st();let r=p("span",{style:"display:inline-flex;align-items:center;gap:4px;",children:[at(t.textColor),p("span",{text:t.text,style:`font-family:${b};font-weight:700;font-size:${t.fontSize}px;text-transform:uppercase;letter-spacing:2px;color:${t.textColor};white-space:nowrap;text-align:center;line-height:1;`})]});return p("button",{attrs:{type:"button"},style:`display:flex;align-items:center;justify-content:center;gap:8px;padding:8px;width:100%;max-width:238px;box-sizing:border-box;background:${t.bgColor};border:${lt(t)};border-radius:${t.borderRadiusPx};font-family:${b};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[r,kn(t)],on:{mouseenter:n=>{n.currentTarget.style.opacity="0.85"},mouseleave:n=>{n.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(n){}}}})}function Sn(t){return t.subtext?p("span",{style:`display:flex;align-items:center;gap:4px;padding:4px;background:${t.badgeBgColor};font-family:${b};font-weight:600;font-size:10px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,children:[Ge(t.badgeTextColor),p("span",{text:t.subtext})]}):null}function Tn(t,e){return p("button",{attrs:{type:"button"},style:`display:flex;align-items:center;justify-content:center;gap:8px;padding:8px 12px 8px 8px;width:100%;margin-top:auto;box-sizing:border-box;background:${t.bgColor};border:${lt(t)};border-radius:${t.borderRadiusPx};filter:drop-shadow(0 0 6px rgba(0,0,0,0.08));font-family:${b};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[at(t.textColor),p("span",{text:t.text,style:`font-family:${b};font-weight:700;font-size:${t.fontSize}px;color:${t.textColor};white-space:nowrap;line-height:1;`})],on:{mouseenter:r=>{r.currentTarget.style.opacity="0.85"},mouseleave:r=>{r.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(r){}}}})}function Ye(t,e){st();let r=p("div",{style:"display:flex;flex-direction:column;gap:4px;",children:[t.cardTitle&&p("p",{text:t.cardTitle,style:`margin:0;font-family:${b};font-weight:700;font-size:16px;letter-spacing:1px;text-transform:uppercase;color:${t.cardTitleColor};line-height:1.2;`}),t.cardDescription&&p("p",{html:t.cardDescription,style:`margin:0;font-family:${b};font-weight:400;font-size:12px;max-width:177px;line-height:1.2;color:${t.cardTextColor};`})]}),n=p("div",{style:"display:flex;flex-direction:column;justify-content:space-between;gap:16px;flex:1 1 0;min-width:0;",children:[r,t.cardFooter&&p("p",{text:t.cardFooter,style:`margin:0;font-family:${b};font-weight:400;font-size:10px;color:${t.cardTextColor};line-height:1.2;`})]}),o=p("div",{style:"display:flex;flex-direction:column;align-items:flex-end;flex:1 1 0;min-width:0;",children:[Sn(t),Tn(t,e)]}),i=p("div",{style:"display:flex;gap:16px;align-items:stretch;width:100%;flex:1;box-sizing:border-box;",children:[n,o]});return p("div",{style:`display:flex;flex-direction:column;align-items:flex-start;padding:12px;width:100%;max-width:402px;min-height:140px;box-sizing:border-box;background:${t.cardBgColor};border-radius:${t.cardBorderRadiusPx};font-family:${b};`,children:[i]})}var En={style:"gregory-black",text:"Provar Virtualmente",fontSize:14,subtext:"",bgColor:"#1E1E1E",textColor:"#FFFFFF",badgeBgColor:"#C51A1B",badgeTextColor:"#FFFFFF",borderRadius:"md",borderColor:"#1E1E1E",borderWidth:0,cardTitle:"",cardDescription:"",cardFooter:"",cardBgColor:"#F6F6F6",cardTitleColor:"#1E1E1E",cardTextColor:"#717171",cardBorderRadius:"md"};function Ot(t,e){let r=(e?t&&t.mobile:t&&t.desktop)||t&&t.desktop||t&&t.mobile||{},n={...En,...r};return n.style==="gregory-card"&&e&&(n.style="gregory-black"),n.borderRadiusPx=Bt[n.borderRadius]!=null?Bt[n.borderRadius]:"0",n.cardBorderRadiusPx=Nt[n.cardBorderRadius]!=null?Nt[n.cardBorderRadius]:"0",n.fontSize=Number(n.fontSize)||14,n.borderWidth=Number(n.borderWidth)||0,n}var Mt={"gregory-black":We,"gregory-card":Ye},To=Object.keys(Mt);function Xe(t,e){return(Mt[t.style]||Mt["gregory-black"])(t,e)}var qt="mk-tryon-button-host",Ln=/^(transform|transform-origin|margin|margin-(top|right|bottom|left)|position|inset|top|right|bottom|left|z-index|width|min-width|max-width|height|min-height|max-height)$/i;function In(t){return!t||typeof t!="string"?"":t.split(";").map(e=>e.trim()).filter(Boolean).filter(e=>Ln.test(e.split(":")[0].trim().toLowerCase())).join(";")}var ut=null,Ut=!1,Ft={},Ze=!1,Dt=null;function Qe(){return Dt||(Dt=N().then(t=>t&&t.template&&t.template.tryOnButton||null).catch(()=>null)),Dt}function Pn(){if(Ze)return;Ze=!0;let t=null;try{window.addEventListener("resize",()=>{clearTimeout(t),t=setTimeout(()=>{ut&&U("pdp")},200)})}catch(e){}}function zt(){let t=document.getElementById(qt);if(t){if(typeof t.__mkCleanup=="function")try{t.__mkCleanup()}catch(e){}t.parentNode&&t.parentNode.removeChild(t)}ut=null}var Rn={IMG:1,INPUT:1,VIDEO:1,CANVAS:1,EMBED:1,OBJECT:1,IFRAME:1,BR:1,HR:1,SELECT:1,TEXTAREA:1,SVG:1};function jn(t){switch(t){case"top-center":return"top:0;left:50%;transform:translateX(-50%);";case"top-right":return"top:0;right:0;";case"middle-left":return"top:50%;left:0;transform:translateY(-50%);";case"center":return"top:50%;left:50%;transform:translate(-50%,-50%);";case"middle-right":return"top:50%;right:0;transform:translateY(-50%);";case"bottom-left":return"bottom:0;left:0;";case"bottom-center":return"bottom:0;left:50%;transform:translateX(-50%);";case"bottom-right":return"bottom:0;right:0;";case"top-left":default:return"top:0;left:0;"}}function Bn(t,e,r){let o=!Rn[t.tagName]?t:t.parentElement||document.body;try{getComputedStyle(o).position==="static"&&(o.style.position="relative")}catch(d){}if(o===t){e.style.cssText="position:absolute;z-index:2147483000;"+jn(r),t.appendChild(e);return}e.style.cssText="position:absolute;z-index:2147483000;",o.appendChild(e);let i=()=>{try{let d=t.getBoundingClientRect(),h=o.getBoundingClientRect(),w=e.offsetWidth,a=e.offsetHeight,f=d.top-h.top+o.scrollTop,g=d.left-h.left+o.scrollLeft,x=r||"top-left",V=f,T=g;x.indexOf("bottom")===0?V=f+d.height-a:(x.indexOf("middle")===0||x==="center")&&(V=f+(d.height-a)/2),x.indexOf("right")>=0?T=g+d.width-w:x.indexOf("center")>=0&&(T=g+(d.width-w)/2),e.style.top=V+"px",e.style.left=T+"px"}catch(d){}};i();let c=()=>i();window.addEventListener("resize",c);let s=setTimeout(i,600),u=setTimeout(i,1500);e.__mkCleanup=()=>{window.removeEventListener("resize",c),clearTimeout(s),clearTimeout(u)}}function Nn(t,e,r){try{return t.insertAdjacentElement(r||"afterend",e),!0}catch(n){try{return t.parentNode.insertBefore(e,t.nextSibling),!0}catch(o){return!1}}}async function U(t){let e=m();if(t!=="pdp"){zt();return}if(!e.projectId)return;if(!e._anchorFromPicker){let u=await Qe();u&&u.anchor&&(e.anchor=u.anchor)}if(Ut)return;let r=$(),n=r&&r.value,o=!!e.forceButton,i=jt(e.anchor),c=[n||"demo",i?[i.selector,i.position,i.mode,i.align,i.style].join("~"):"heuristic"].join("|"),s=document.getElementById(qt);if(!(s&&ut===c)){if(s&&zt(),!n&&!o){y("auto-mount: SKU n\xE3o resolvido na PDP");return}Ut=!0;try{let u=o;o||(Ft[n]||(Ft[n]=M(e.projectId,n).then(C=>!!(C&&C.available)).catch(()=>!1)),u=await Ft[n]);try{re(u?"available":"unavailable")}catch(C){}if(!u){y("auto-mount: produto sem try-on",n);return}let d=await Qe(),h=window.matchMedia("(max-width: 767px)").matches,w=Ot(d,h),a=Je(),f=a&&a.mode||"flow",g=Xe(w,()=>{let C=$(),dt=C&&C.value||n||"";te(),l("button_clicked",{sku:dt,style:w.style,mode:f}),ct({projectId:e.projectId,identifier:dt})}),x=document.createElement("div");x.id=qt,x.attachShadow({mode:"closed"}).appendChild(g);let T=!1;if(a&&a.el&&a.el.parentNode&&(f==="overlay"?(Bn(a.el,x,a.align),T=!0):(x.style.cssText="display:contents;",T=Nn(a.el,x,a.position))),T||(x.style.cssText="position:fixed;left:16px;bottom:16px;z-index:2147483000;",document.body.appendChild(x)),a&&a.style){let C=In(a.style);if(C)try{g.style.cssText+=";"+C}catch(dt){}}ut=c,Pn(),y("auto-mount: bot\xE3o injetado",{style:w.style,sku:n,anchorFound:!!a,position:a&&a.position,mode:f,forced:o}),l("button_rendered",{style:w.style,sku:n||null,skuSource:r&&r.source,anchorFound:!!a,position:a?a.position:null,mode:f,forced:o})}finally{Ut=!1}}}function tr(){try{let t=m(),e={anchor:t.anchor,forceButton:t.forceButton};window.addEventListener("message",r=>{if(r.source!==window)return;let n=r.data;!n||!n.__mkCmd||(n.__mkCmd==="remount"||n.__mkCmd==="applyRecipe"?(t.anchor=n.anchor||null,t._anchorFromPicker=!0,t.forceButton=!0,U("pdp")):n.__mkCmd==="cancelPreview"&&(t.anchor=e.anchor,t._anchorFromPicker=!1,t.forceButton=e.forceButton,zt(),U("pdp")))})}catch(t){}}(function(){"use strict";try{let r=function(){try{ie(),tr(),Ue(),e.autoTrack!==!1&&(Se((o,i)=>{Pe(o,i),U(o)}),Re()),y("mk-sdk iniciado",{projectId:e.projectId,collectorUrl:e.collectorUrl})}catch(o){e.debug&&console.error("[mk-sdk] init erro",o)}},e=pt();if(e.projectId){let o=se(e.projectId);o&&wt(o),N().then(i=>{let c=ae(i);wt(c),ue(e.projectId,c),y("escopo de coleta",c)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r):r();let n={open:ct,close:Pt,isAvailable:Oe,getAvailability:M,onReady:De,onClose:qe,onAddToCart:ze,onProductLoaded:$e,onError:Ke,onInteraction:He,onGenerationComplete:Ve,_version:"0.1.0",_isMkSdk:!0};typeof window!="undefined"&&(window.mk=n)}catch(e){typeof console!="undefined"&&console.error("[mk-sdk] boot fatal",e)}})();})();
|
package/package.json
CHANGED
package/src/core/config.js
CHANGED
|
@@ -70,8 +70,14 @@ export function resolveConfig() {
|
|
|
70
70
|
cartBehavior: (window.__MK && window.__MK.cartBehavior) || null,
|
|
71
71
|
cartOpenSelector: (window.__MK && window.__MK.cartOpenSelector) || null,
|
|
72
72
|
autoTrack: attr('data-mk-no-autotrack') === null, // autotrack ligado por padrão
|
|
73
|
-
batchIntervalMs:
|
|
74
|
-
|
|
73
|
+
// batchIntervalMs: janela do timer de flush. O batch fecha em batchMaxSize
|
|
74
|
+
// eventos OU batchIntervalMs (o que vier primeiro). Na navegação real o timer
|
|
75
|
+
// dispara antes de encher (poucos eventos por janela), então este valor é o
|
|
76
|
+
// que define o tamanho efetivo do batch — e, com isso, o nº de requests/PUTs
|
|
77
|
+
// no collector. 8s junta mais eventos por POST sem impacto real de freshness
|
|
78
|
+
// (o aggregator só roda de hora em hora). Overridável via window.__MK.
|
|
79
|
+
batchIntervalMs: (window.__MK && window.__MK.batchIntervalMs) || 8000,
|
|
80
|
+
batchMaxSize: (window.__MK && window.__MK.batchMaxSize) || 20,
|
|
75
81
|
engagementIntervalMs: 15000
|
|
76
82
|
};
|
|
77
83
|
return _config;
|
|
@@ -54,9 +54,23 @@ export function extractProduct() {
|
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/** orderId pela URL da confirmação (ex.: /checkout/orderConfirmation/{id}, ?order_id=). */
|
|
58
|
+
export function orderIdFromUrl() {
|
|
59
|
+
try {
|
|
60
|
+
const s = location.pathname + location.search;
|
|
61
|
+
const m = s.match(/order[_-]?confirmation\/([\w-]+)/i) ||
|
|
62
|
+
s.match(/[?&]order[_-]?id=([\w-]+)/i) ||
|
|
63
|
+
s.match(/\/orders?\/([\w-]{4,})/i) ||
|
|
64
|
+
s.match(/pedido[_-]?(?:confirmado|realizado|finalizado)?\/([\w-]+)/i);
|
|
65
|
+
return m ? m[1] : null;
|
|
66
|
+
} catch (_) { return null; }
|
|
67
|
+
}
|
|
68
|
+
|
|
57
69
|
/**
|
|
58
70
|
* Extrai dados de pedido/compra (página de confirmação).
|
|
59
|
-
* Cascata: JSON-LD Order > dataLayer
|
|
71
|
+
* Cascata: JSON-LD Order > Shopify.checkout > dataLayer GA4/UA > meta > DOM.
|
|
72
|
+
* A receita costuma chegar DEPOIS do load (dataLayer.push async) — quem chama
|
|
73
|
+
* deve fazer retry (ver funnel.emitPurchase).
|
|
60
74
|
*/
|
|
61
75
|
export function extractOrder() {
|
|
62
76
|
const orders = readJsonLd(['Order', 'Invoice']);
|
|
@@ -64,23 +78,41 @@ export function extractOrder() {
|
|
|
64
78
|
const o = orders[0];
|
|
65
79
|
const total = o.totalPaymentDue ? parseFloat(o.totalPaymentDue.price) : parseFloat(o.price || o.total);
|
|
66
80
|
return {
|
|
67
|
-
orderId: o.orderNumber || o.confirmationNumber || o.identifier ||
|
|
81
|
+
orderId: o.orderNumber || o.confirmationNumber || o.identifier || orderIdFromUrl(),
|
|
68
82
|
revenue: Number.isFinite(total) ? total : null,
|
|
69
83
|
currency: (o.totalPaymentDue && o.totalPaymentDue.priceCurrency) || o.priceCurrency || null,
|
|
70
84
|
source: 'jsonld'
|
|
71
85
|
};
|
|
72
86
|
}
|
|
87
|
+
// Shopify thank-you page expõe o pedido em window.Shopify.checkout
|
|
88
|
+
try {
|
|
89
|
+
const sc = window.Shopify && window.Shopify.checkout;
|
|
90
|
+
if (sc && sc.total_price != null) {
|
|
91
|
+
const rev = parseFloat(sc.total_price);
|
|
92
|
+
return {
|
|
93
|
+
orderId: (sc.order_id != null ? String(sc.order_id) : null) || sc.token || orderIdFromUrl(),
|
|
94
|
+
revenue: Number.isFinite(rev) ? rev : null,
|
|
95
|
+
currency: sc.currency || null,
|
|
96
|
+
itemCount: Array.isArray(sc.line_items) ? sc.line_items.length : null,
|
|
97
|
+
source: 'shopify'
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
} catch (_) {}
|
|
73
101
|
try {
|
|
74
102
|
if (Array.isArray(window.dataLayer)) {
|
|
75
103
|
for (let i = window.dataLayer.length - 1; i >= 0; i--) {
|
|
76
104
|
const item = window.dataLayer[i];
|
|
77
|
-
|
|
78
|
-
|
|
105
|
+
// GA4: {event:'purchase', ecommerce:{value,...}} | UA: {ecommerce:{purchase:{actionField:{revenue}}}}
|
|
106
|
+
const ec = item && item.ecommerce;
|
|
107
|
+
if (!ec) continue;
|
|
108
|
+
if (item.event === 'purchase' || ec.purchase) {
|
|
109
|
+
const ua = ec.purchase && ec.purchase.actionField;
|
|
110
|
+
const rev = parseFloat((ua && (ua.revenue || ua.value)) || ec.value || ec.revenue);
|
|
79
111
|
return {
|
|
80
|
-
orderId: ec.transaction_id || ec.transactionId ||
|
|
81
|
-
revenue:
|
|
112
|
+
orderId: (ua && ua.id) || ec.transaction_id || ec.transactionId || orderIdFromUrl(),
|
|
113
|
+
revenue: Number.isFinite(rev) ? rev : null,
|
|
82
114
|
currency: ec.currency || ec.currencyCode || null,
|
|
83
|
-
itemCount: (ec.items || ec.products || []).length || null,
|
|
115
|
+
itemCount: ((ec.purchase && ec.purchase.products) || ec.items || ec.products || []).length || null,
|
|
84
116
|
source: 'datalayer'
|
|
85
117
|
};
|
|
86
118
|
}
|
|
@@ -89,10 +121,13 @@ export function extractOrder() {
|
|
|
89
121
|
} catch (_) {}
|
|
90
122
|
const metaTotal = document.querySelector('meta[property="order:total"], meta[name="order-total"]');
|
|
91
123
|
if (metaTotal && metaTotal.content) {
|
|
92
|
-
return { orderId:
|
|
124
|
+
return { orderId: orderIdFromUrl(), revenue: parseFloat(metaTotal.content) || null, source: 'meta' };
|
|
93
125
|
}
|
|
94
126
|
const dom = scrapeOrderFromDom();
|
|
95
127
|
if (dom) return dom;
|
|
128
|
+
// sem valor em lugar nenhum (ainda): pelo menos o orderId da URL pro dedup
|
|
129
|
+
const uid = orderIdFromUrl();
|
|
130
|
+
if (uid) return { orderId: uid, revenue: null, source: 'url' };
|
|
96
131
|
return null;
|
|
97
132
|
}
|
|
98
133
|
|
package/src/ecommerce/funnel.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// funnel.js — emite eventos do funil de e-commerce reagindo ao pageType
|
|
2
2
|
// detectado, + heurística de add_to_cart por clique. Sinais nativos, sem GA.
|
|
3
3
|
|
|
4
|
-
import { track } from '../core/transport.js';
|
|
4
|
+
import { track, flush } from '../core/transport.js';
|
|
5
5
|
import { log } from '../core/config.js';
|
|
6
|
-
import { extractProduct, extractOrder, extractItemList } from './extractors.js';
|
|
6
|
+
import { extractProduct, extractOrder, extractItemList, orderIdFromUrl } from './extractors.js';
|
|
7
|
+
import { getCartSummary } from '../platforms/index.js';
|
|
7
8
|
|
|
8
9
|
let purchaseEmittedThisLoad = false;
|
|
9
10
|
|
|
@@ -47,7 +48,10 @@ export function onPageView(pageType) {
|
|
|
47
48
|
break;
|
|
48
49
|
}
|
|
49
50
|
case 'cart':
|
|
50
|
-
|
|
51
|
+
// enriquece com o total do carrinho (valor) quando a plataforma expõe
|
|
52
|
+
getCartSummary()
|
|
53
|
+
.then((s) => track('view_cart', (s && s.value != null) ? { value: s.value, itemCount: s.itemCount, currency: s.currency } : {}))
|
|
54
|
+
.catch(() => track('view_cart', {}));
|
|
51
55
|
break;
|
|
52
56
|
case 'checkout':
|
|
53
57
|
track('begin_checkout', {});
|
|
@@ -60,9 +64,38 @@ export function onPageView(pageType) {
|
|
|
60
64
|
|
|
61
65
|
/**
|
|
62
66
|
* Emite purchase com dedup. Conversão é contada mesmo sem revenue.
|
|
67
|
+
* A receita (GA4 dataLayer.push, Shopify.checkout) costuma aparecer DEPOIS do
|
|
68
|
+
* load — faz retry por até ~8s até o valor existir; no timeout emite o que
|
|
69
|
+
* tiver (conversão sem valor). Se o usuário sair no meio, emite e flusha já.
|
|
63
70
|
*/
|
|
71
|
+
const PURCHASE_RETRY_MS = 500;
|
|
72
|
+
const PURCHASE_RETRY_MAX = 16; // 16 × 500ms = 8s
|
|
73
|
+
|
|
64
74
|
function emitPurchase() {
|
|
65
|
-
|
|
75
|
+
let done = false;
|
|
76
|
+
let attempts = 0;
|
|
77
|
+
const finish = (order, immediate) => {
|
|
78
|
+
if (done) return;
|
|
79
|
+
done = true;
|
|
80
|
+
finishPurchase(order, immediate);
|
|
81
|
+
};
|
|
82
|
+
// usuário saindo antes da receita aparecer → emite o que tiver e flusha agora
|
|
83
|
+
try { window.addEventListener('pagehide', () => finish(extractOrder(), true), { once: true }); } catch (_) {}
|
|
84
|
+
const tick = () => {
|
|
85
|
+
if (done) return;
|
|
86
|
+
const order = extractOrder();
|
|
87
|
+
if (order && order.revenue != null) return finish(order);
|
|
88
|
+
if (attempts++ >= PURCHASE_RETRY_MAX) {
|
|
89
|
+
log('purchase: receita não apareceu em ' + (PURCHASE_RETRY_MS * PURCHASE_RETRY_MAX) + 'ms — emitindo sem valor');
|
|
90
|
+
return finish(order);
|
|
91
|
+
}
|
|
92
|
+
setTimeout(tick, PURCHASE_RETRY_MS);
|
|
93
|
+
};
|
|
94
|
+
tick();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function finishPurchase(order, immediate) {
|
|
98
|
+
if (order && !order.orderId) order.orderId = orderIdFromUrl();
|
|
66
99
|
|
|
67
100
|
// Dedup: por orderId (cross-reload) ou por load (sem orderId)
|
|
68
101
|
if (order && order.orderId) {
|
|
@@ -78,6 +111,7 @@ function emitPurchase() {
|
|
|
78
111
|
|
|
79
112
|
track('purchase', order || { revenue: null, _note: 'no_order_data_extracted' });
|
|
80
113
|
log('purchase emitido', order);
|
|
114
|
+
if (immediate) { try { flush(true); } catch (_) {} }
|
|
81
115
|
}
|
|
82
116
|
|
|
83
117
|
/**
|
package/src/platforms/hybris.js
CHANGED
|
@@ -40,7 +40,42 @@ export async function addToCart({ size, quantity }) {
|
|
|
40
40
|
body: body.toString()
|
|
41
41
|
});
|
|
42
42
|
if (!resp.ok) throw new Error('hybris: ' + action + ' HTTP ' + resp.status);
|
|
43
|
-
|
|
43
|
+
// a resposta do Hybris traz cartData.total (visto na Marisa). Lê o valor do carrinho.
|
|
44
|
+
let cartValue = null, itemCount = null;
|
|
45
|
+
try {
|
|
46
|
+
const data = await resp.clone().json();
|
|
47
|
+
const cd = data && data.cartData;
|
|
48
|
+
if (cd) {
|
|
49
|
+
cartValue = toMoney(cd.total != null ? cd.total : cd.totalPrice);
|
|
50
|
+
itemCount = cd.totalUnitCount != null ? Number(cd.totalUnitCount)
|
|
51
|
+
: (Array.isArray(cd.products) ? cd.products.length : null);
|
|
52
|
+
}
|
|
53
|
+
} catch (_) {}
|
|
54
|
+
return { platform: 'hybris', productCode: code, size: el.textContent.trim(), cartValue, itemCount, currency: 'BRL' };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Converte "R$ 1.234,56" | "1234.56" | 1234.56 → número (reais). null se vazio.
|
|
58
|
+
function toMoney(v) {
|
|
59
|
+
if (v == null || v === '') return null;
|
|
60
|
+
if (typeof v === 'number') return Number.isFinite(v) ? v : null;
|
|
61
|
+
const c = String(v).replace(/[^\d.,]/g, '');
|
|
62
|
+
if (!c) return null;
|
|
63
|
+
const n = (c.indexOf(',') > c.indexOf('.')) ? parseFloat(c.replace(/\./g, '').replace(',', '.')) : parseFloat(c.replace(/,/g, ''));
|
|
64
|
+
return Number.isFinite(n) ? n : null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Total do carrinho pro view_cart: raspa o total da página de carrinho (best-effort).
|
|
68
|
+
// ⚠️ NÃO validado ao vivo (anti-bot da Marisa bloqueia carrinho em automação).
|
|
69
|
+
export function getCartSummary() {
|
|
70
|
+
try {
|
|
71
|
+
const sels = ['.js-cart-total', '.cart-total', '.total-price', '.grand-total', '[class*="cart"][class*="total" i]'];
|
|
72
|
+
for (const s of sels) {
|
|
73
|
+
const el = document.querySelector(s);
|
|
74
|
+
const v = el && toMoney(el.textContent);
|
|
75
|
+
if (v) return { value: v, itemCount: null, currency: 'BRL' };
|
|
76
|
+
}
|
|
77
|
+
} catch (_) {}
|
|
78
|
+
return null;
|
|
44
79
|
}
|
|
45
80
|
// Sem openCartDrawer: a Marisa (Hybris) não tem sacola lateral no tema. Sem drawer,
|
|
46
81
|
// o fluxo cai no redirect pro /cart ao fechar o provador (preservando o NPS).
|
package/src/platforms/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { getConfig, log } from '../core/config.js';
|
|
8
8
|
import { fetchProjectRecipe } from '../core/projectRecipe.js';
|
|
9
|
+
import { track } from '../core/transport.js';
|
|
9
10
|
import * as shopify from './shopify.js';
|
|
10
11
|
import * as hybris from './hybris.js';
|
|
11
12
|
import * as vtex from './vtex.js';
|
|
@@ -60,15 +61,40 @@ export async function addToCart(payload) {
|
|
|
60
61
|
const result = plat.addToCart ? await plat.addToCart(norm) : await generic.addToCart(norm);
|
|
61
62
|
log('cart: adicionado', result);
|
|
62
63
|
notifyTheme();
|
|
64
|
+
emitCartValue(plat, result, norm.sku);
|
|
63
65
|
return result;
|
|
64
66
|
} catch (e) {
|
|
65
67
|
log('cart: adapter "' + plat.id + '" falhou — fallback clique nativo', e && e.message);
|
|
66
68
|
const r = await generic.addToCart(norm);
|
|
67
69
|
notifyTheme();
|
|
70
|
+
emitCartValue(plat, r, norm.sku);
|
|
68
71
|
return r;
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
|
|
75
|
+
// Emite cart_value (valor do carrinho) após o add. Prefere o valor que o adapter
|
|
76
|
+
// já leu (ex.: Hybris, da resposta do /cart/add); senão lê via getCartSummary.
|
|
77
|
+
async function emitCartValue(plat, result, sku) {
|
|
78
|
+
try {
|
|
79
|
+
let s = null;
|
|
80
|
+
if (result && result.cartValue != null) {
|
|
81
|
+
s = { value: result.cartValue, itemCount: result.itemCount != null ? result.itemCount : null, currency: result.currency || null };
|
|
82
|
+
} else if (plat && plat.getCartSummary) {
|
|
83
|
+
s = await plat.getCartSummary();
|
|
84
|
+
}
|
|
85
|
+
if (s && s.value != null) {
|
|
86
|
+
track('cart_value', { via: 'tryon', value: s.value, itemCount: s.itemCount != null ? s.itemCount : null, currency: s.currency || null, sku: sku || null });
|
|
87
|
+
}
|
|
88
|
+
} catch (_) {}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Total do carrinho da plataforma ativa (value em reais, itemCount, currency) | null. */
|
|
92
|
+
export async function getCartSummary() {
|
|
93
|
+
const plat = currentPlatform();
|
|
94
|
+
if (plat && plat.getCartSummary) { try { return await plat.getCartSummary(); } catch (_) {} }
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
|
|
72
98
|
function notifyTheme() {
|
|
73
99
|
['cart:refresh', 'cart:updated', 'cart:build', 'ajaxProduct:added', 'product:added-to-cart'].forEach((n) => {
|
|
74
100
|
try { document.dispatchEvent(new CustomEvent(n)); } catch (_) {}
|
|
@@ -46,3 +46,16 @@ export async function addToCart({ size, quantity }) {
|
|
|
46
46
|
const vId = (form.querySelector('[name="variant_id"]') || {}).value || null;
|
|
47
47
|
return { platform: 'nuvemshop', variantId: vId };
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
// Total do carrinho via window.LS.cart. subtotal segue a convenção _raw da
|
|
51
|
+
// Nuvemshop (CENTAVOS) → /100. ⚠️ unidade a confirmar em carrinho real.
|
|
52
|
+
export function getCartSummary() {
|
|
53
|
+
try {
|
|
54
|
+
const LS = window.LS; const c = LS && LS.cart;
|
|
55
|
+
if (!c) return null;
|
|
56
|
+
const cur = (LS.currency && LS.currency.code) || 'BRL';
|
|
57
|
+
const items = Array.isArray(c.items) ? c.items.reduce((n, i) => n + (Number(i.quantity) || 1), 0) : (Number(c.items) || 0);
|
|
58
|
+
const sub = c.subtotal != null ? Number(c.subtotal) : null;
|
|
59
|
+
return { value: sub != null ? sub / 100 : null, itemCount: items, currency: cur };
|
|
60
|
+
} catch (_) { return null; }
|
|
61
|
+
}
|
package/src/platforms/shopify.js
CHANGED
|
@@ -41,6 +41,15 @@ export async function addToCart({ size, color, sku, quantity }) {
|
|
|
41
41
|
return { platform: 'shopify', variantId: v.id, size: v.title, sku: v.sku || null };
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// Total autoritativo do carrinho via /cart.js (total_price em CENTAVOS → /100).
|
|
45
|
+
// Validado ao vivo (LK): total_price 239999 = R$ 2.399,99.
|
|
46
|
+
export async function getCartSummary() {
|
|
47
|
+
try {
|
|
48
|
+
const c = await fetch('/cart.js', { headers: { Accept: 'application/json' } }).then((r) => r.json());
|
|
49
|
+
return { value: (Number(c.total_price) || 0) / 100, itemCount: Number(c.item_count) || 0, currency: c.currency || null };
|
|
50
|
+
} catch (_) { return null; }
|
|
51
|
+
}
|
|
52
|
+
|
|
44
53
|
// Seletores comuns de gatilho da sacola lateral em temas Shopify (mais específico
|
|
45
54
|
// → mais genérico). O último (`a[href="/cart"]`) degrada graciosamente: em tema
|
|
46
55
|
// com drawer abre a sacola, sem drawer só navega pro /cart (= o redirect de antes).
|
package/src/platforms/vtex.js
CHANGED
|
@@ -32,3 +32,17 @@ export async function addToCart({ size, quantity }) {
|
|
|
32
32
|
}
|
|
33
33
|
throw new Error('vtex: vtexjs.checkout indisponível'); // → fallback clique nativo
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
// Total do carrinho via vtexjs.checkout.orderForm.value (CENTAVOS → /100).
|
|
37
|
+
// ⚠️ API conhecida, NÃO validado ao vivo (sem loja VTEX de teste).
|
|
38
|
+
export function getCartSummary() {
|
|
39
|
+
try {
|
|
40
|
+
const of = window.vtexjs && window.vtexjs.checkout && window.vtexjs.checkout.orderForm;
|
|
41
|
+
if (of && typeof of.value === 'number') {
|
|
42
|
+
const cur = (of.storePreferencesData && of.storePreferencesData.currencyCode) || 'BRL';
|
|
43
|
+
const items = (of.items || []).reduce((n, i) => n + (Number(i.quantity) || 1), 0);
|
|
44
|
+
return { value: of.value / 100, itemCount: items, currency: cur };
|
|
45
|
+
}
|
|
46
|
+
} catch (_) {}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
package/src/platforms/wake.js
CHANGED
|
@@ -50,3 +50,20 @@ export async function addToCart({ size, quantity }) {
|
|
|
50
50
|
if (!ok) throw new Error('wake: addOrCreateCheckout retornou false');
|
|
51
51
|
return { platform: 'wake', productVariantId: variantId, size: size || null };
|
|
52
52
|
}
|
|
53
|
+
|
|
54
|
+
// Total do carrinho — Wake não expõe um objeto global pronto; raspa o "TOTAL" do
|
|
55
|
+
// mini-cart (DOM). ⚠️ best-effort, NÃO validado ao vivo. Ideal futuro: query
|
|
56
|
+
// GraphQL no StorefrontClient (checkout.total) com o checkoutId.
|
|
57
|
+
export function getCartSummary() {
|
|
58
|
+
try {
|
|
59
|
+
const els = document.querySelectorAll('[class*="total" i],[class*="minicart" i],[class*="cart" i]');
|
|
60
|
+
for (const el of els) {
|
|
61
|
+
const t = (el.textContent || '');
|
|
62
|
+
if (/total/i.test(t)) {
|
|
63
|
+
const m = t.match(/R\$\s*([\d.]+,\d{2})/);
|
|
64
|
+
if (m) { const n = parseFloat(m[1].replace(/\./g, '').replace(',', '.')); if (Number.isFinite(n) && n > 0) return { value: n, itemCount: null, currency: 'BRL' }; }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
} catch (_) {}
|
|
68
|
+
return null;
|
|
69
|
+
}
|