mk-sdk-git 1.1.3 → 1.1.5
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 +5 -0
- package/src/platforms/index.js +30 -7
- package/src/platforms/shopify.js +10 -3
- package/src/tryon/bridge.js +24 -2
package/dist/mk-sdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var qe=Object.defineProperty;var A=(t,e)=>{for(var r in e)qe(t,r,{get:e[r],enumerable:!0})};var at={collectorUrl:"https://api-collector.mk3dlabs.com",appUrl:"https://mkfashion.mk3dlabs.com/visualizer",apiUrl:"https://mkfashion-new-api.mk3dlabs.com"},$e={},N=null;function st(){if(N)return N;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,o=e("data-mk-product")||window.__MK&&window.__MK.product||"mk-fashion",n=e("data-mk-collector")||window.__MK&&window.__MK.collectorUrl||$e.collectorUrl||at.collectorUrl;return N={projectId:r,product:o,collectorUrl:n,appUrl:window.__MK&&window.__MK.appUrl||at.appUrl,apiUrl:window.__MK&&window.__MK.apiUrl||at.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),autoTrack:e("data-mk-no-autotrack")===null,batchIntervalMs:2e3,batchMaxSize:20,engagementIntervalMs:15e3},N}function f(){return N||st()}function m(...t){let e=f();e&&e.debug&&typeof console!="undefined"&&console.log("[mk-sdk]",...t)}var Mt="_mk_vid",Ft="_mk_sid",O=null,U=null;function $(){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 Dt(){if(O)return O;try{let t=localStorage.getItem(Mt);return t||(t="v_"+$(),localStorage.setItem(Mt,t)),O=t,t}catch(t){return O="v_"+$(),O}}function zt(){if(U)return U;try{let t=sessionStorage.getItem(Ft);return t||(t="s_"+$(),sessionStorage.setItem(Ft,t)),U=t,t}catch(t){return U="s_"+$(),U}}var qt=[/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],$t={imageUrl:1,image:1,thumbnail:1,photo:1,imageBase64:1,src:1},lt=2e3;function Kt(t){for(let e=0;e<qt.length;e++)if(qt[e].test(t))return!0;return!1}function Ht(t){if(!t||typeof t!="object"||Array.isArray(t))return typeof t=="string"&&t.length>lt?t.slice(0,200)+"...[truncated "+t.length+"B]":t;let e={};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||Kt(r))continue;let o=t[r];if($t[r]){e[r+"Present"]=!!o;continue}if(typeof o=="string"&&o.length>lt){e[r]=o.slice(0,200)+"...[truncated "+o.length+"B]";continue}if(o&&typeof o=="object"&&!Array.isArray(o)){e[r]=Ke(o);continue}e[r]=o}return e}function Ke(t){let e={};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||Kt(r))continue;let o=t[r];if($t[r]){e[r+"Present"]=!!o;continue}if(typeof o=="string"&&o.length>lt){e[r]=o.slice(0,200)+"...[truncated]";continue}e[r]=o}return e}var K=[],ut=null,L=null,He=["off","pdp_tryon","pdp","all"],dt,pt=null,H="unknown",I=[];function Vt(t){if(dt===void 0)return"hold";switch(dt){case"off":return"drop";case"all":return"collect";case"pdp":return t==="pdp"?"collect":"drop";case"pdp_tryon":return t!=="pdp"?"drop":H==="available"?"collect":H==="unavailable"?"drop":"hold";default:return"collect"}}function ft(t){if(!I.length)return;let e=[];for(let r of I){let o=Vt(r._pt);o==="collect"?Xt(r.name,r.params,r.ts):o==="hold"&&!t&&e.push(r)}I=e}function mt(t){dt=He.indexOf(t)>=0?t:"all",ft(!1)}function Gt(t){H=t==="available"?"available":"unavailable",ft(!1)}function Wt(t){ft(!0),L=t,pt=t&&t.pageType||null,H="unknown"}function l(t,e,r){if(!f().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 n=l._pre;l._pre=[];for(let i of n)Jt(i.name,i.params,i.ts)}Jt(t,e,r)}function Jt(t,e,r){let o=Vt(pt);if(o==="collect"){Xt(t,e,r);return}if(o==="drop"){m("descartado (escopo)",t);return}I.push({name:t,params:e,ts:r||Date.now(),_pt:pt}),I.length>300&&I.shift()}function Xt(t,e,r){let o=f(),n=Ht(e||{}),i="page_"+Je(t);if(K.push({name:i,ts:r||Date.now(),params:n}),m("queued",t,n),o.observe)try{window.postMessage({__mkpixel:!0,event:{name:i,params:n},site:L?{pageType:L.pageType,platform:L.platform,url:L.url}:null},"*")}catch(c){}if(K.length>=o.batchMaxSize){M();return}ut||(ut=setTimeout(()=>{ut=null,M()},o.batchIntervalMs))}function Je(t){if(typeof t!="string"||!t)return"unknown";let e=t.replace(/^on/,"");return e=e.replace(/[A-Z]/g,(r,o)=>(o>0?"_":"")+r.toLowerCase()),e.indexOf("page_")===0&&(e=e.slice(5)),e}function M(t){if(K.length===0)return;let e=f();if(!e.projectId||!e.collectorUrl)return;let r=K.splice(0,50),o=JSON.stringify({product:e.product||void 0,visitorId:Dt(),sessionId:zt(),events:r,site:L||void 0}),n=e.collectorUrl+"/v1/track";if(t&&navigator.sendBeacon)try{let i=new Blob([o],{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:o}).catch(()=>{})}function Yt(){try{window.addEventListener("pagehide",()=>M(!0)),window.addEventListener("beforeunload",()=>M(!0)),document.addEventListener("visibilitychange",()=>{document.hidden&&M(!0)})}catch(t){}}function _(t){let e=[];try{let r=document.querySelectorAll('script[type="application/ld+json"]');for(let o of r){let n;try{n=JSON.parse(o.textContent)}catch(c){continue}let i=[];Array.isArray(n)?i.push(...n):n["@graph"]?i.push(...n["@graph"]):i.push(n);for(let c of i){if(!c||!c["@type"])continue;let a=Array.isArray(c["@type"])?c["@type"]:[c["@type"]];(!t||t.some(u=>a.includes(u)))&&e.push(c)}}}catch(r){}return e}var ht={};A(ht,{addToCart:()=>Xe,detect:()=>Ge,id:()=>Ve,resolveSku:()=>We});var Ve="shopify";function Ge(){return!!(window.Shopify||window.ShopifyAnalytics)}function We(){let t=window;return t.ShopifyAnalytics&&t.ShopifyAnalytics.meta&&t.ShopifyAnalytics.meta.product?{value:String(t.ShopifyAnalytics.meta.product.id),source:"shopify"}:null}var J=t=>String(t==null?"":t).trim().toLowerCase();async function Xe({size:t,sku:e,quantity:r}){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 i=(await fetch("/products/"+o+".js").then(s=>s.json())).variants||[],c=s=>[s.option1,s.option2,s.option3,s.title].some(x=>J(x)===J(t)),a=null;if(t&&(a=i.find(s=>c(s)&&s.available)||i.find(c)),!a&&e&&(a=i.find(s=>J(s.sku)===J(e))),a||(a=i.find(s=>s.available)||i[0]),!a)throw new Error("shopify: variante n\xE3o encontrada");let u=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:a.id,quantity:r||1}]})});if(!u.ok)throw new Error("shopify: /cart/add.js HTTP "+u.status);return{platform:"shopify",variantId:a.id,size:a.title,sku:a.sku||null}}var gt={};A(gt,{addToCart:()=>to,detect:()=>Ze,id:()=>Ye,resolveSku:()=>Qe});var Ye="hybris";function Ze(){return!!(window.ACC&&window.ACC.config)}function Qe(){let t=(location.pathname||"").match(/\/p\/([^/?#]+)/);return t&&t[1]?{value:decodeURIComponent(t[1]),source:"hybris/url"}:null}var Zt=t=>String(t==null?"":t).trim().toLowerCase();async function to({size:t,quantity:e}){let r=[...document.querySelectorAll('.js-product-select-size, a[data-code], [class*="select-size"]')].filter(h=>h.getAttribute&&h.getAttribute("data-code")),o=t?r.find(h=>Zt(h.textContent)===Zt(t)):null;o||(o=r.find(h=>h.offsetParent!==null)||r[0]);let n=o&&o.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"]'),c=i&&i.querySelector('[name="CSRFToken"]'),a=c&&c.value,u=i&&i.getAttribute("action")||"/cart/add";if(!a)throw new Error("hybris: CSRFToken n\xE3o encontrado");let s=new URLSearchParams;s.set("productCodePost",n),s.set("qty",String(e||1)),s.set("CSRFToken",a);let x=await fetch(u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:s.toString()});if(!x.ok)throw new Error("hybris: "+u+" HTTP "+x.status);return{platform:"hybris",productCode:n,size:o.textContent.trim()}}var yt={};A(yt,{addToCart:()=>no,detect:()=>oo,id:()=>eo,resolveSku:()=>ro});var eo="vtex";function oo(){return!!(window.vtex||window.vtexjs||window.vtxctx||window.skuJson_0)}function ro(){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 V=t=>String(t==null?"":t).trim().toLowerCase();async function no({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 o=i=>V(i.skuname)===V(t)||i.dimensions&&Object.values(i.dimensions).some(c=>V(c)===V(t)),n=t?r.find(i=>o(i)&&i.available)||r.find(o):null;if(n||(n=r.find(i=>i.available)||r[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 wt={};A(wt,{addToCart:()=>lo,detect:()=>ao,id:()=>io,resolveSku:()=>so,skipRedirect:()=>co});var io="nuvemshop",co=!0;function ao(){return!!(window.LS&&(window.LS.cart||window.LS.addToCart))}function so(){try{let t=window.LS,e=t&&t.variants||[],r=document.querySelector('[name="variant_id"]'),o=r&&r.value?e.find(n=>String(n.id)===String(r.value)):null;if(o||(o=e.find(n=>n.available!==!1&&n.sku)||e.find(n=>n.sku)||e[0]),o&&o.sku)return{value:String(o.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 G=t=>String(t==null?"":t).trim().toLowerCase();async function lo({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(a=>G(a.textContent).includes(G(t))||G(a.value)===G(t));c&&(i.value=c.value,i.dispatchEvent(new Event("change",{bubbles:!0})))});let o=r.querySelector('[name="quantity"]');return o&&e&&(o.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}}var xt={};A(xt,{addToCart:()=>ho,detect:()=>fo,id:()=>uo,resolveSku:()=>mo,skipRedirect:()=>po});var uo="wake",po=!0;function fo(){return!!(window.StorefrontClient||typeof window.addOrCreateCheckout=="function"||typeof window.addToCartClick=="function")}function mo(){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 Qt=t=>String(t==null?"":t).trim().toLowerCase();async function ho({size:t,quantity:e}){if(t){let i=[...document.querySelectorAll("input[attribute-value]")].find(c=>Qt(c.getAttribute("attribute-value"))===Qt(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"]'),o=r&&r.value;if(!o)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(o),quantity:e||1,customization:[]}]))throw new Error("wake: addOrCreateCheckout retornou false");return{platform:"wake",productVariantId:o,size:t||null}}var kt={};A(kt,{addToCart:()=>W,detect:()=>yo,id:()=>go,resolveSku:()=>bt});var go="generic";function yo(){return!0}function bt(){let t=_(["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 wo=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora/i,xo=/continuar|como comprar|lista|desejos|favorito/i;async function W(){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&&wo.test(r)&&!xo.test(r))try{return e.click(),{platform:"native-click",clicked:r}}catch(o){}}return{platform:"none",error:"bot\xE3o de carrinho nativo n\xE3o encontrado"}}var oe=[ht,gt,yt,wt,xt],bo=[["woocommerce",()=>!!(window.wc_add_to_cart_params||window.woocommerce_params)],["lojaintegrada",()=>!!window.LojaIntegrada]],X;function re(){return X||(X=oe.find(t=>{try{return t.detect()}catch(e){return!1}})||kt,X)}function ne(){let t=oe.find(e=>{try{return e.detect()}catch(r){return!1}});if(t)return t.id;for(let[e,r]of bo)try{if(r())return e}catch(o){}return null}function F(){let t=re();if(t.id!=="generic"&&t.resolveSku)try{let e=t.resolveSku();if(e)return e}catch(e){}return bt()}async function ie(t){t=t||{};let e={size:t.size||t.selectedSize||null,sku:t.sku||t.identifier||t.selectedIdentifier||null,quantity:t.quantity||1},r=re();try{let o=r.addToCart?await r.addToCart(e):await W(e);return m("cart: adicionado",o),te(),ee(r),o}catch(o){m('cart: adapter "'+r.id+'" falhou \u2014 fallback clique nativo',o&&o.message);let n=await W(e);return te(),ee(r),n}}function te(){["cart:refresh","cart:updated","cart:build","ajaxProduct:added","product:added-to-cart"].forEach(t=>{try{document.dispatchEvent(new CustomEvent(t))}catch(e){}})}function ee(t){if(!f().cartRedirect||t&&t.skipRedirect)return;let r=t&&t.cartUrl||"/cart";setTimeout(()=>{try{window.location.href=r}catch(o){}},250)}var ko=/\/(thank[_-]?you|orders?\/|pedido[_-]?(confirmado|realizado|finalizado|sucesso)|sucesso|order[_-]?confirmation|compra[_-]?(finalizada|concluida)|orderplaced)/i,Co=/\/checkout/i,_o=/\/(cart|carrinho|sacola|bag)(\/|$|\?|#)/i,vo=/\/(products?|produtos?|p)\//i,So=/\/(collections?|categoria|categorias|c|departamento)\//i,To=/\/(search|busca|s)(\/|\?)/i;function ce(){try{if(window.__mkPageType)return window.__mkPageType}catch(e){}try{let e=_();for(let r of e){let o=Array.isArray(r["@type"])?r["@type"]:[r["@type"]];if(o.includes("Order")||o.includes("Invoice"))return"purchase";if(o.includes("Product"))return"pdp";if(o.includes("SearchResultsPage"))return"search";if(o.includes("CollectionPage")||o.includes("ItemList"))return"category"}}catch(e){}let t=(location.pathname||"").toLowerCase();return t==="/"||t===""||t==="/home"||t==="/index.html"?"home":ko.test(t)?"purchase":Co.test(t)?"checkout":_o.test(t)?"cart":vo.test(t)?"pdp":So.test(t)?"category":To.test(t)?"search":"other"}function ae(t){let e=null;try{let r=new URLSearchParams(location.search),o=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],n={};for(let i of o){let c=r.get(i);c&&(n[i.replace("utm_","")]=c)}Object.keys(n).length&&(e=n)}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:Eo()}}function Eo(){return ne()}var Ct={},Ao=null,D=0,se=!1;function le(t){se||(se=!0,ue(t),Lo(),Io(),Po(),Ro(),jo(t))}function ue(t){Ct={};let e=ce(),r=ae(e);if(Wt(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(o){}}function Lo(){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 o=Date.now();if(o-e<100)return;e=o;let n=r.target;for(let a=0;a<5&&n&&n!==document.body&&!(t[n.tagName]||n.getAttribute&&n.getAttribute("role")==="button");a++)n=n.parentElement;if(!n||!t[n.tagName]&&!(n.getAttribute&&n.getAttribute("role")==="button"))return;let i={tag:n.tagName},c=n.tagName==="INPUT"||n.tagName==="TEXTAREA"?n.value:n.textContent;i.text=(c||"").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(o){}},{capture:!0,passive:!0})}function Io(){let t=[25,50,75,100],e=null,r=()=>{try{let o=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((o+window.innerHeight)/n*100));for(let c of t)i>=c&&!Ct[c]&&(Ct[c]=!0,l("scroll_depth",{depth:c}))}catch(o){}};r(),window.addEventListener("scroll",()=>{e||(e=setTimeout(()=>{e=null,r()},250))},{passive:!0})}function Po(){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",o=(e.className||"").toLowerCase(),n=(e.action||"").toLowerCase();e.querySelector('input[type="search"], input[name="q"], input[name="s"]')?r="search":/newsletter|subscribe|mailchimp/.test(o+n)?r="newsletter":/contact|contato/.test(o+n)&&(r="contact"),l("form_submit",{form_id:e.id||"",form_type:r})}catch(e){}},{capture:!0})}function Ro(){let t=f();D=Date.now(),Ao=setInterval(()=>{if(document.hidden)return;let e=Date.now(),r=Math.round((e-D)/1e3);D=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()-D)/1e3);e>0&&e<600&&l("engagement",{url:location.pathname,dwellSec:e})}D=Date.now()})}function jo(t){let e=location.href,r=()=>{location.href!==e&&(e=location.href,ue(t))};try{let o=history.pushState,n=history.replaceState;history.pushState=function(){o.apply(this,arguments),setTimeout(r,0)},history.replaceState=function(){n.apply(this,arguments),setTimeout(r,0)},window.addEventListener("popstate",r)}catch(o){}}var de=["off","pdp_tryon","pdp","all"],Bo="all",No=30*60*1e3,P=null;function Y(){if(P)return P;let t=f();return!t.projectId||!t.apiUrl?(P=Promise.resolve(null),P):(P=fetch(t.apiUrl+"/projects/"+t.projectId).then(e=>e.ok?e.json():null).then(e=>e&&e.project||e||null).catch(()=>null),P)}function pe(t){let e=t&&t.analytic&&t.analytic.scope;return de.indexOf(e)>=0?e:Bo}var fe=t=>"mk_scope_"+t;function me(t){try{let e=localStorage.getItem(fe(t));if(!e)return null;let r=JSON.parse(e);return!r||typeof r.exp!="number"||r.exp<Date.now()?null:de.indexOf(r.scope)>=0?r.scope:null}catch(e){return null}}function he(t,e){try{localStorage.setItem(fe(t),JSON.stringify({scope:e,exp:Date.now()+No}))}catch(r){}}function _t(){let t=F(),e=_(["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 r=n=>{let i=document.querySelector('meta[property="og:'+n+'"], meta[property="product:'+n+'"]');return i?i.getAttribute("content"):null},o=n=>{let i=document.querySelector('[itemprop="'+n+'"]');return i?i.getAttribute("content")||(i.textContent||"").trim():null};if(t||r("type")==="product"||r("price:amount")||o("name")){let n=o("price")||r("price:amount");return{sku:t?t.value:null,skuSource:t?t.source:null,name:o("name")||r("title")||document.title||null,price:n&&parseFloat(String(n).replace(",","."))||null,currency:o("priceCurrency")||r("price:currency")||null,brand:o("brand")||null,category:null}}return null}function ge(){let t=_(["Order","Invoice"]);if(t.length>0){let o=t[0],n=o.totalPaymentDue?parseFloat(o.totalPaymentDue.price):parseFloat(o.price||o.total);return{orderId:o.orderNumber||o.confirmationNumber||o.identifier||null,revenue:Number.isFinite(n)?n:null,currency:o.totalPaymentDue&&o.totalPaymentDue.priceCurrency||o.priceCurrency||null,source:"jsonld"}}try{if(Array.isArray(window.dataLayer))for(let o=window.dataLayer.length-1;o>=0;o--){let n=window.dataLayer[o];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(o){}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 r=Oo();return r||null}function Oo(){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 o=Mo(r.textContent);if(o)return{orderId:Uo(),revenue:o,source:"dom"}}}return null}catch(t){return null}}function Uo(){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 Mo(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 o=parseFloat(r);return Number.isFinite(o)&&o>0?o:null}function ye(){let t=_(["ItemList","CollectionPage"]);if(t.length===0)return null;let e=t[0],r=e.itemListElement||e.mainEntity&&e.mainEntity.itemListElement||[],o=[];for(let n of r.slice(0,50)){let i=n.item||n;i&&(i.sku||i.productID||i.name)&&o.push(i.sku||i.productID||i.name)}return o.length>0?{count:o.length,skus:o.slice(0,20)}:null}var we=!1,Z=[/\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],Fo=[/^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 z(t,e){for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}function xe(t){switch(t){case"pdp":{let e=_t();l("view_item",e||{sku:null});break}case"category":case"search":{let e=ye();l("view_item_list",e||{count:0});break}case"cart":l("view_cart",{});break;case"checkout":l("begin_checkout",{});break;case"purchase":Do();break}}function Do(){let t=ge();if(t&&t.orderId){let e="_mk_purch_"+t.orderId;try{if(sessionStorage.getItem(e)){m("purchase j\xE1 contado",t.orderId);return}sessionStorage.setItem(e,"1")}catch(r){}}else if(we)return;we=!0,l("purchase",t||{revenue:null,_note:"no_order_data_extracted"}),m("purchase emitido",t)}function be(){if(!document.body)return;let t=0;document.body.addEventListener("click",e=>{try{let r=Date.now();if(r-t<150)return;let o=e.target;for(let a=0;a<5&&o&&o!==document.body&&!(o.tagName==="BUTTON"||o.tagName==="A"||o.getAttribute&&o.getAttribute("role")==="button");a++)o=o.parentElement;if(!o)return;let n=o.tagName!=="A",i=(o.textContent||"").replace(/\s+/g," ").trim();if(!i||i.length>80)return;let c=!1;if((z([Z[0]],i)||n&&z([Z[1]],i)||n&&z([Z[2]],i)||z(Z.slice(3),i))&&(c=!0),c){t=r;let a=_t();l("add_to_cart",{via:"click",buttonText:i,sku:a?a.sku:null,price:a?a.price:null});return}n&&z(Fo,i)&&(t=r,l("begin_checkout",{via:"click",buttonText:i}))}catch(r){}},{capture:!0,passive:!0})}var k=null,v=null,tt=!1,R=null,ke={},vt=null,Q=0,w={onReady:null,onClose:null,onAddToCart:null,onProductLoaded:null,onError:null,onInteraction:null,onGenerationComplete:null},zo={gregory:"698c7e791d3129430f15dddd"};function _e(t){return t?zo[String(t).toLowerCase()]||t:null}async function j(t,e){let r=f(),o=_e(t);e=String(e||"").trim();let n=r.apiUrl+"/availability/"+o+"?sku="+encodeURIComponent(e),i=await fetch(n);if(!i.ok)throw new Error("availability HTTP "+i.status);return i.json()}async function ve(t,e){e||(e=t,t="698c7e791d3129430f15dddd");try{return(await j(t,e)).available===!0}catch(r){return!1}}async function et(t){if(t=t||{},tt)return;let e=_e(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 o=e+":"+r;if(ke[o]!==!0){try{if(!(await j(e,r)).available){alert("Produto nao disponivel para prova virtual.");return}}catch(n){alert("Produto nao encontrado ou indisponivel.");return}ke[o]=!0}R={projectId:e,identifier:r,width:t.width||430,height:t.height||800},Te(),qo(R),tt=!0,Q=Date.now(),l("modal_opened",{projectId:e,identifier:r})}function Tt(){tt&&($o(),tt=!1,T("onClose"),l("modal_closed",{projectId:R&&R.projectId,identifier:R&&R.identifier}))}function qo(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:99999;";let e=document.createElement("div"),r=typeof t.width=="number"?t.width+"px":t.width,o=typeof t.height=="number"?t.height+"px":t.height;e.style.cssText="position:relative;width:"+r+";height:"+o+";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),k.appendChild(e),document.body.appendChild(k),m("try-on modal aberto",v.src)}function $o(){k&&k.parentNode&&k.parentNode.removeChild(k),k=null,v=null}var Ce=!1;function Se(){Te()}function Te(){Ce||(Ce=!0,window.addEventListener("message",t=>{let e=t.data;if(!e||e.source!=="mkfashion-app")return;let r=e.action,o=e.data||{};switch(r){case"close_request":Tt();break;case"ready":T("onReady",o);break;case"product_loaded":T("onProductLoaded",o),l("product_loaded",St(o));break;case"interaction":{T("onInteraction",o),o&&o.method&&(vt=o.method),l(Ko(o),St(o));break}case"add_to_cart":l("add_to_cart",Object.assign({via:"tryon"},St(o))),typeof w.onAddToCart=="function"?T("onAddToCart",o):ie(o).catch(()=>{});break;case"generation_start":Q=Date.now();break;case"generation_complete":T("onGenerationComplete",o),l("generation_complete",{method:o.method||vt||"unknown",durationMs:Q?Date.now()-Q:null,success:o.success!==!1,imageUrlPresent:!!o.imageUrl});break;case"generation_error":T("onError",o),l("generation_error",{method:vt||"unknown",error:o&&o.error});break}}))}function Ko(t){return t&&t.action,"interaction"}function St(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 T(t,e){if(typeof w[t]=="function")try{w[t](e)}catch(r){console.error("[mk-sdk]",r)}}function Ee(t){w.onReady=t}function Ae(t){w.onClose=t}function Le(t){w.onAddToCart=t}function Ie(t){w.onProductLoaded=t}function Pe(t){w.onError=t}function Re(t){w.onInteraction=t}function je(t){w.onGenerationComplete=t}var Jo=767,Vo=1024,Go=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora|^comprar$|finalizar compra|eu quero/i,Wo=/continuar|como comprar|lista|desejos|favorito|looks|cupom/i;function Et(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 Xo(t){if(!t)return!1;try{let e=document.querySelector(t);return!!e&&Et(e)}catch(e){return!1}}function Yo(t){return(t.tagName==="INPUT"?t.value||"":t.textContent||"").replace(/\s+/g," ").trim()}function Zo(t){if(!t||typeof t!="object"||t.selector)return t;let e=!1;if(["mobile","tablet","desktop"].forEach(o=>{let n=t[o];n&&n.mkAnchor===1&&n.anchor&&typeof n.anchor=="object"&&(e=!0)}),!e)return t;let r={};return["mobile","tablet","desktop"].forEach(o=>{let n=t[o];if(n){if(n.selector){r[o]=n;return}if(n.mkAnchor===1&&n.anchor&&typeof n.anchor=="object"){let i=n.anchor[o]||n.anchor.desktop||n.anchor.mobile||n.anchor.tablet;i&&i.selector&&(r[o]=i)}}}),["bpMobile","bpTablet","breakpoint"].forEach(o=>{t[o]!=null&&(r[o]=t[o])}),r}function At(t){if(!t||typeof t!="object")return null;if(t=Zo(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])=>Xo(u.selector));if(r.length===1)return r[0][1];let o=window.innerWidth||1024,n=Number(t.bpMobile)||Number(t.breakpoint)||Jo,i=Number(t.bpTablet)||Vo,c=u=>(e.find(s=>s[0]===u)||[])[1],a=o<=n?["mobile","tablet","desktop"]:o<=i?["tablet","desktop","mobile"]:["desktop","tablet","mobile"];for(let u of a){let s=c(u);if(s)return s}return e[0][1]}function Be(){let t=f(),e=At(t&&t.anchor);if(e&&e.selector)try{let o=document.querySelector(e.selector);if(o&&Et(o))return{el:o,position:e.position||"afterend",mode:e.mode||"flow",style:e.style||"",align:e.align||"top-left",selector:e.selector}}catch(o){}let r=document.querySelectorAll('button, [role="button"], a.btn, a.button, input[type="submit"], input[type="button"]');for(let o of r){let n=Yo(o);if(!(!n||n.length>40)&&!Wo.test(n)&&Go.test(n)&&Et(o))return{el:o,position:"afterend",mode:"flow",style:"",selector:null}}return null}var y="'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Lt={none:"0",sm:"4px",md:"8px",pill:"9999px"},It={none:"0",sm:"4px",md:"8px",lg:"16px"},Qo='<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>',tr='<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 o in e.attrs)r.setAttribute(o,e.attrs[o]);if(e.on)for(let o in e.on)r.addEventListener(o,e.on[o]);if(e.children)for(let o of e.children)o&&r.appendChild(o);return r}function ot(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:Qo})}function Ne(t){return p("span",{style:`width:12px;height:12px;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:tr})}function rt(t){return t.borderWidth>0&&t.borderColor?`${t.borderWidth}px solid ${t.borderColor}`:"none"}function nt(){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 er(t){return t.subtext?p("span",{style:`display:flex;align-items:center;justify-content:center;padding:4px;background:${t.badgeBgColor};font-family:${y};font-weight:700;font-size:16px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,text:t.subtext}):null}function Oe(t,e){nt();let r=p("span",{style:"display:inline-flex;align-items:center;gap:4px;",children:[ot(t.textColor),p("span",{text:t.text,style:`font-family:${y};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:${rt(t)};border-radius:${t.borderRadiusPx};font-family:${y};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[r,er(t)],on:{mouseenter:o=>{o.currentTarget.style.opacity="0.85"},mouseleave:o=>{o.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(o){}}}})}function rr(t){return t.subtext?p("span",{style:`display:flex;align-items:center;gap:4px;padding:4px;background:${t.badgeBgColor};font-family:${y};font-weight:600;font-size:10px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,children:[Ne(t.badgeTextColor),p("span",{text:t.subtext})]}):null}function nr(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:${rt(t)};border-radius:${t.borderRadiusPx};filter:drop-shadow(0 0 6px rgba(0,0,0,0.08));font-family:${y};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[ot(t.textColor),p("span",{text:t.text,style:`font-family:${y};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 Ue(t,e){nt();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:${y};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:${y};font-weight:400;font-size:12px;max-width:177px;line-height:1.2;color:${t.cardTextColor};`})]}),o=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:${y};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:[rr(t),nr(t,e)]}),i=p("div",{style:"display:flex;gap:16px;align-items:stretch;width:100%;flex:1;box-sizing:border-box;",children:[o,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:${y};`,children:[i]})}var cr={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 Pt(t,e){let r=(e?t&&t.mobile:t&&t.desktop)||t&&t.desktop||t&&t.mobile||{},o={...cr,...r};return o.style==="gregory-card"&&e&&(o.style="gregory-black"),o.borderRadiusPx=Lt[o.borderRadius]!=null?Lt[o.borderRadius]:"0",o.cardBorderRadiusPx=It[o.cardBorderRadius]!=null?It[o.cardBorderRadius]:"0",o.fontSize=Number(o.fontSize)||14,o.borderWidth=Number(o.borderWidth)||0,o}var Rt={"gregory-black":Oe,"gregory-card":Ue},tn=Object.keys(Rt);function Me(t,e){return(Rt[t.style]||Rt["gregory-black"])(t,e)}var Ot="mk-tryon-button-host",ar=/^(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 sr(t){return!t||typeof t!="string"?"":t.split(";").map(e=>e.trim()).filter(Boolean).filter(e=>ar.test(e.split(":")[0].trim().toLowerCase())).join(";")}var it=null,jt=!1,Bt={},Fe=!1,Nt=null;function De(){return Nt||(Nt=Y().then(t=>t&&t.template&&t.template.tryOnButton||null).catch(()=>null)),Nt}function lr(){if(Fe)return;Fe=!0;let t=null;try{window.addEventListener("resize",()=>{clearTimeout(t),t=setTimeout(()=>{it&&B("pdp")},200)})}catch(e){}}function Ut(){let t=document.getElementById(Ot);if(t){if(typeof t.__mkCleanup=="function")try{t.__mkCleanup()}catch(e){}t.parentNode&&t.parentNode.removeChild(t)}it=null}var ur={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 dr(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 pr(t,e,r){let n=!ur[t.tagName]?t:t.parentElement||document.body;try{getComputedStyle(n).position==="static"&&(n.style.position="relative")}catch(s){}if(n===t){e.style.cssText="position:absolute;z-index:2147483000;"+dr(r),t.appendChild(e);return}e.style.cssText="position:absolute;z-index:2147483000;",n.appendChild(e);let i=()=>{try{let s=t.getBoundingClientRect(),x=n.getBoundingClientRect(),h=e.offsetWidth,d=e.offsetHeight,C=s.top-x.top+n.scrollTop,E=s.left-x.left+n.scrollLeft,g=r||"top-left",q=C,S=E;g.indexOf("bottom")===0?q=C+s.height-d:(g.indexOf("middle")===0||g==="center")&&(q=C+(s.height-d)/2),g.indexOf("right")>=0?S=E+s.width-h:g.indexOf("center")>=0&&(S=E+(s.width-h)/2),e.style.top=q+"px",e.style.left=S+"px"}catch(s){}};i();let c=()=>i();window.addEventListener("resize",c);let a=setTimeout(i,600),u=setTimeout(i,1500);e.__mkCleanup=()=>{window.removeEventListener("resize",c),clearTimeout(a),clearTimeout(u)}}function fr(t,e,r){try{return t.insertAdjacentElement(r||"afterend",e),!0}catch(o){try{return t.parentNode.insertBefore(e,t.nextSibling),!0}catch(n){return!1}}}async function B(t){let e=f();if(t!=="pdp"){Ut();return}if(!e.projectId)return;if(!e._anchorFromPicker){let u=await De();u&&u.anchor&&(e.anchor=u.anchor)}if(jt)return;let r=F(),o=r&&r.value,n=!!e.forceButton,i=At(e.anchor),c=[o||"demo",i?[i.selector,i.position,i.mode,i.align,i.style].join("~"):"heuristic"].join("|"),a=document.getElementById(Ot);if(!(a&&it===c)){if(a&&Ut(),!o&&!n){m("auto-mount: SKU n\xE3o resolvido na PDP");return}jt=!0;try{let u=n;n||(Bt[o]||(Bt[o]=j(e.projectId,o).then(b=>!!(b&&b.available)).catch(()=>!1)),u=await Bt[o]);try{Gt(u?"available":"unavailable")}catch(b){}if(!u){m("auto-mount: produto sem try-on",o);return}let s=await De(),x=window.matchMedia("(max-width: 767px)").matches,h=Pt(s,x),d=Be(),C=d&&d.mode||"flow",E=Me(h,()=>{let b=F(),ct=b&&b.value||o||"";l("button_clicked",{sku:ct,style:h.style,mode:C}),et({projectId:e.projectId,identifier:ct})}),g=document.createElement("div");g.id=Ot,g.attachShadow({mode:"closed"}).appendChild(E);let S=!1;if(d&&d.el&&d.el.parentNode&&(C==="overlay"?(pr(d.el,g,d.align),S=!0):(g.style.cssText="display:contents;",S=fr(d.el,g,d.position))),S||(g.style.cssText="position:fixed;left:16px;bottom:16px;z-index:2147483000;",document.body.appendChild(g)),d&&d.style){let b=sr(d.style);if(b)try{E.style.cssText+=";"+b}catch(ct){}}it=c,lr(),m("auto-mount: bot\xE3o injetado",{style:h.style,sku:o,anchorFound:!!d,position:d&&d.position,mode:C,forced:n}),l("button_rendered",{style:h.style,sku:o||null,skuSource:r&&r.source,anchorFound:!!d,position:d?d.position:null,mode:C,forced:n})}finally{jt=!1}}}function ze(){try{let t=f(),e={anchor:t.anchor,forceButton:t.forceButton};window.addEventListener("message",r=>{if(r.source!==window)return;let o=r.data;!o||!o.__mkCmd||(o.__mkCmd==="remount"||o.__mkCmd==="applyRecipe"?(t.anchor=o.anchor||null,t._anchorFromPicker=!0,t.forceButton=!0,B("pdp")):o.__mkCmd==="cancelPreview"&&(t.anchor=e.anchor,t._anchorFromPicker=!1,t.forceButton=e.forceButton,Ut(),B("pdp")))})}catch(t){}}(function(){"use strict";try{let r=function(){try{Yt(),ze(),Se(),e.autoTrack!==!1&&(le((n,i)=>{xe(n,i),B(n)}),be()),m("mk-sdk iniciado",{projectId:e.projectId,collectorUrl:e.collectorUrl})}catch(n){e.debug&&console.error("[mk-sdk] init erro",n)}},e=st();if(e.projectId){let n=me(e.projectId);n&&mt(n),Y().then(i=>{let c=pe(i);mt(c),he(e.projectId,c),m("escopo de coleta",c)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r):r();let o={open:et,close:Tt,isAvailable:ve,getAvailability:j,onReady:Ee,onClose:Ae,onAddToCart:Le,onProductLoaded:Ie,onError:Pe,onInteraction:Re,onGenerationComplete:je,_version:"0.1.0",_isMkSdk:!0};typeof window!="undefined"&&(window.mk=o)}catch(e){typeof console!="undefined"&&console.error("[mk-sdk] boot fatal",e)}})();})();
|
|
1
|
+
(()=>{var $e=Object.defineProperty;var E=(t,e)=>{for(var r in e)$e(t,r,{get:e[r],enumerable:!0})};var lt={collectorUrl:"https://api-collector.mk3dlabs.com",appUrl:"https://mkfashion.mk3dlabs.com/visualizer",apiUrl:"https://mkfashion-new-api.mk3dlabs.com"},Ke={},N=null;function st(){if(N)return N;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,o=e("data-mk-product")||window.__MK&&window.__MK.product||"mk-fashion",n=e("data-mk-collector")||window.__MK&&window.__MK.collectorUrl||Ke.collectorUrl||lt.collectorUrl;return N={projectId:r,product:o,collectorUrl:n,appUrl:window.__MK&&window.__MK.appUrl||lt.appUrl,apiUrl:window.__MK&&window.__MK.apiUrl||lt.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},N}function f(){return N||st()}function h(...t){let e=f();e&&e.debug&&typeof console!="undefined"&&console.log("[mk-sdk]",...t)}var Ut="_mk_vid",Dt="_mk_sid",M=null,U=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 Ft(){if(M)return M;try{let t=localStorage.getItem(Ut);return t||(t="v_"+H(),localStorage.setItem(Ut,t)),M=t,t}catch(t){return M="v_"+H(),M}}function zt(){if(U)return U;try{let t=sessionStorage.getItem(Dt);return t||(t="s_"+H(),sessionStorage.setItem(Dt,t)),U=t,t}catch(t){return U="s_"+H(),U}}var qt=[/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],$t={imageUrl:1,image:1,thumbnail:1,photo:1,imageBase64:1,src:1},ut=2e3;function Kt(t){for(let e=0;e<qt.length;e++)if(qt[e].test(t))return!0;return!1}function Ht(t){if(!t||typeof t!="object"||Array.isArray(t))return typeof t=="string"&&t.length>ut?t.slice(0,200)+"...[truncated "+t.length+"B]":t;let e={};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||Kt(r))continue;let o=t[r];if($t[r]){e[r+"Present"]=!!o;continue}if(typeof o=="string"&&o.length>ut){e[r]=o.slice(0,200)+"...[truncated "+o.length+"B]";continue}if(o&&typeof o=="object"&&!Array.isArray(o)){e[r]=He(o);continue}e[r]=o}return e}function He(t){let e={};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||Kt(r))continue;let o=t[r];if($t[r]){e[r+"Present"]=!!o;continue}if(typeof o=="string"&&o.length>ut){e[r]=o.slice(0,200)+"...[truncated]";continue}e[r]=o}return e}var J=[],dt=null,L=null,Je=["off","pdp_tryon","pdp","all"],pt,ft=null,V="unknown",I=[];function Vt(t){if(pt===void 0)return"hold";switch(pt){case"off":return"drop";case"all":return"collect";case"pdp":return t==="pdp"?"collect":"drop";case"pdp_tryon":return t!=="pdp"?"drop":V==="available"?"collect":V==="unavailable"?"drop":"hold";default:return"collect"}}function mt(t){if(!I.length)return;let e=[];for(let r of I){let o=Vt(r._pt);o==="collect"?Xt(r.name,r.params,r.ts):o==="hold"&&!t&&e.push(r)}I=e}function ht(t){pt=Je.indexOf(t)>=0?t:"all",mt(!1)}function Gt(t){V=t==="available"?"available":"unavailable",mt(!1)}function Wt(t){mt(!0),L=t,ft=t&&t.pageType||null,V="unknown"}function l(t,e,r){if(!f().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 n=l._pre;l._pre=[];for(let i of n)Jt(i.name,i.params,i.ts)}Jt(t,e,r)}function Jt(t,e,r){let o=Vt(ft);if(o==="collect"){Xt(t,e,r);return}if(o==="drop"){h("descartado (escopo)",t);return}I.push({name:t,params:e,ts:r||Date.now(),_pt:ft}),I.length>300&&I.shift()}function Xt(t,e,r){let o=f(),n=Ht(e||{}),i="page_"+Ve(t);if(J.push({name:i,ts:r||Date.now(),params:n}),h("queued",t,n),o.observe)try{window.postMessage({__mkpixel:!0,event:{name:i,params:n},site:L?{pageType:L.pageType,platform:L.platform,url:L.url}:null},"*")}catch(c){}if(J.length>=o.batchMaxSize){D();return}dt||(dt=setTimeout(()=>{dt=null,D()},o.batchIntervalMs))}function Ve(t){if(typeof t!="string"||!t)return"unknown";let e=t.replace(/^on/,"");return e=e.replace(/[A-Z]/g,(r,o)=>(o>0?"_":"")+r.toLowerCase()),e.indexOf("page_")===0&&(e=e.slice(5)),e}function D(t){if(J.length===0)return;let e=f();if(!e.projectId||!e.collectorUrl)return;let r=J.splice(0,50),o=JSON.stringify({product:e.product||void 0,visitorId:Ft(),sessionId:zt(),events:r,site:L||void 0}),n=e.collectorUrl+"/v1/track";if(t&&navigator.sendBeacon)try{let i=new Blob([o],{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:o}).catch(()=>{})}function Yt(){try{window.addEventListener("pagehide",()=>D(!0)),window.addEventListener("beforeunload",()=>D(!0)),document.addEventListener("visibilitychange",()=>{document.hidden&&D(!0)})}catch(t){}}function C(t){let e=[];try{let r=document.querySelectorAll('script[type="application/ld+json"]');for(let o of r){let n;try{n=JSON.parse(o.textContent)}catch(c){continue}let i=[];Array.isArray(n)?i.push(...n):n["@graph"]?i.push(...n["@graph"]):i.push(n);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 Zt=["off","pdp_tryon","pdp","all"],Ge="all",We=30*60*1e3,P=null;function R(){if(P)return P;let t=f();return!t.projectId||!t.apiUrl?(P=Promise.resolve(null),P):(P=fetch(t.apiUrl+"/projects/"+t.projectId).then(e=>e.ok?e.json():null).then(e=>e&&e.project||e||null).catch(()=>null),P)}function Qt(t){let e=t&&t.analytic&&t.analytic.scope;return Zt.indexOf(e)>=0?e:Ge}var te=t=>"mk_scope_"+t;function ee(t){try{let e=localStorage.getItem(te(t));if(!e)return null;let r=JSON.parse(e);return!r||typeof r.exp!="number"||r.exp<Date.now()?null:Zt.indexOf(r.scope)>=0?r.scope:null}catch(e){return null}}function oe(t,e){try{localStorage.setItem(te(t),JSON.stringify({scope:e,exp:Date.now()+We}))}catch(r){}}var gt={};E(gt,{addToCart:()=>Qe,detect:()=>Ye,id:()=>Xe,resolveSku:()=>Ze});var Xe="shopify";function Ye(){return!!(window.Shopify||window.ShopifyAnalytics)}function Ze(){let t=window;return t.ShopifyAnalytics&&t.ShopifyAnalytics.meta&&t.ShopifyAnalytics.meta.product?{value:String(t.ShopifyAnalytics.meta.product.id),source:"shopify"}:null}var G=t=>String(t==null?"":t).trim().toLowerCase();async function Qe({size:t,color:e,sku:r,quantity:o}){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 c=(await fetch("/products/"+n+".js").then(a=>a.json())).variants||[],s=a=>[a.option1,a.option2,a.option3].concat(String(a.title||"").split("/")).map(G).filter(Boolean),u=(a,x)=>s(a).indexOf(G(x))>=0,d=a=>(!t||u(a,t))&&(!e||u(a,e)),m=null;if((t||e)&&(m=c.find(a=>d(a)&&a.available)||c.find(d)),!m&&r&&(m=c.find(a=>G(a.sku)===G(r))),m||(m=c.find(a=>a.available)||c[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:o||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 yt={};E(yt,{addToCart:()=>ro,detect:()=>eo,id:()=>to,resolveSku:()=>oo});var to="hybris";function eo(){return!!(window.ACC&&window.ACC.config)}function oo(){let t=(location.pathname||"").match(/\/p\/([^/?#]+)/);return t&&t[1]?{value:decodeURIComponent(t[1]),source:"hybris/url"}:null}var re=t=>String(t==null?"":t).trim().toLowerCase();async function ro({size:t,quantity:e}){let r=[...document.querySelectorAll('.js-product-select-size, a[data-code], [class*="select-size"]')].filter(g=>g.getAttribute&&g.getAttribute("data-code")),o=t?r.find(g=>re(g.textContent)===re(t)):null;o||(o=r.find(g=>g.offsetParent!==null)||r[0]);let n=o&&o.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"]'),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",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:o.textContent.trim()}}var wt={};E(wt,{addToCart:()=>ao,detect:()=>io,id:()=>no,resolveSku:()=>co});var no="vtex";function io(){return!!(window.vtex||window.vtexjs||window.vtxctx||window.skuJson_0)}function co(){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 W=t=>String(t==null?"":t).trim().toLowerCase();async function ao({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 o=i=>W(i.skuname)===W(t)||i.dimensions&&Object.values(i.dimensions).some(c=>W(c)===W(t)),n=t?r.find(i=>o(i)&&i.available)||r.find(o):null;if(n||(n=r.find(i=>i.available)||r[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 xt={};E(xt,{addToCart:()=>fo,detect:()=>uo,id:()=>lo,resolveSku:()=>po,skipRedirect:()=>so});var lo="nuvemshop",so=!0;function uo(){return!!(window.LS&&(window.LS.cart||window.LS.addToCart))}function po(){try{let t=window.LS,e=t&&t.variants||[],r=document.querySelector('[name="variant_id"]'),o=r&&r.value?e.find(n=>String(n.id)===String(r.value)):null;if(o||(o=e.find(n=>n.available!==!1&&n.sku)||e.find(n=>n.sku)||e[0]),o&&o.sku)return{value:String(o.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 X=t=>String(t==null?"":t).trim().toLowerCase();async function fo({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=>X(s.textContent).includes(X(t))||X(s.value)===X(t));c&&(i.value=c.value,i.dispatchEvent(new Event("change",{bubbles:!0})))});let o=r.querySelector('[name="quantity"]');return o&&e&&(o.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}}var bt={};E(bt,{addToCart:()=>wo,detect:()=>go,id:()=>mo,resolveSku:()=>yo,skipRedirect:()=>ho});var mo="wake",ho=!0;function go(){return!!(window.StorefrontClient||typeof window.addOrCreateCheckout=="function"||typeof window.addToCartClick=="function")}function yo(){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 ne=t=>String(t==null?"":t).trim().toLowerCase();async function wo({size:t,quantity:e}){if(t){let i=[...document.querySelectorAll("input[attribute-value]")].find(c=>ne(c.getAttribute("attribute-value"))===ne(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"]'),o=r&&r.value;if(!o)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(o),quantity:e||1,customization:[]}]))throw new Error("wake: addOrCreateCheckout retornou false");return{platform:"wake",productVariantId:o,size:t||null}}var _t={};E(_t,{addToCart:()=>Y,detect:()=>bo,id:()=>xo,resolveSku:()=>kt});var xo="generic";function bo(){return!0}function kt(){let t=C(["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 ko=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora/i,_o=/continuar|como comprar|lista|desejos|favorito/i;async function Y(){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&&ko.test(r)&&!_o.test(r))try{return e.click(),{platform:"native-click",clicked:r}}catch(o){}}return{platform:"none",error:"bot\xE3o de carrinho nativo n\xE3o encontrado"}}var ae=[gt,yt,wt,xt,bt],Co=[["woocommerce",()=>!!(window.wc_add_to_cart_params||window.woocommerce_params)],["lojaintegrada",()=>!!window.LojaIntegrada]],Z;function le(){return Z||(Z=ae.find(t=>{try{return t.detect()}catch(e){return!1}})||_t,Z)}function se(){let t=ae.find(e=>{try{return e.detect()}catch(r){return!1}});if(t)return t.id;for(let[e,r]of Co)try{if(r())return e}catch(o){}return null}function F(){let t=le();if(t.id!=="generic"&&t.resolveSku)try{let e=t.resolveSku();if(e)return e}catch(e){}return kt()}async function ue(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=le();try{let o=r.addToCart?await r.addToCart(e):await Y(e);return h("cart: adicionado",o),ie(),await ce(r),o}catch(o){h('cart: adapter "'+r.id+'" falhou \u2014 fallback clique nativo',o&&o.message);let n=await Y(e);return ie(),await ce(r),n}}function ie(){["cart:refresh","cart:updated","cart:build","ajaxProduct:added","product:added-to-cart"].forEach(t=>{try{document.dispatchEvent(new CustomEvent(t))}catch(e){}})}async function ce(t){let e=f(),r=null;try{r=await R()}catch(s){}let o=r&&r.template&&r.template.cart||r&&r.cart||{},n=o.afterAdd||o.behavior||e.cartBehavior||(e.cartRedirect?"redirect":"none"),i=o.openSelector||e.cartOpenSelector||t&&t.cartToggleSelector||null;if(n==="none")return;if(n==="drawer"&&i){setTimeout(()=>{try{let s=document.querySelector(i);s&&s.click()}catch(s){}},300);return}if(t&&t.skipRedirect)return;let c=t&&t.cartUrl||"/cart";setTimeout(()=>{try{window.location.href=c}catch(s){}},250)}var vo=/\/(thank[_-]?you|orders?\/|pedido[_-]?(confirmado|realizado|finalizado|sucesso)|sucesso|order[_-]?confirmation|compra[_-]?(finalizada|concluida)|orderplaced)/i,So=/\/checkout/i,To=/\/(cart|carrinho|sacola|bag)(\/|$|\?|#)/i,Ao=/\/(products?|produtos?|p)\//i,Eo=/\/(collections?|categoria|categorias|c|departamento)\//i,Lo=/\/(search|busca|s)(\/|\?)/i;function de(){try{if(window.__mkPageType)return window.__mkPageType}catch(e){}try{let e=C();for(let r of e){let o=Array.isArray(r["@type"])?r["@type"]:[r["@type"]];if(o.includes("Order")||o.includes("Invoice"))return"purchase";if(o.includes("Product"))return"pdp";if(o.includes("SearchResultsPage"))return"search";if(o.includes("CollectionPage")||o.includes("ItemList"))return"category"}}catch(e){}let t=(location.pathname||"").toLowerCase();return t==="/"||t===""||t==="/home"||t==="/index.html"?"home":vo.test(t)?"purchase":So.test(t)?"checkout":To.test(t)?"cart":Ao.test(t)?"pdp":Eo.test(t)?"category":Lo.test(t)?"search":"other"}function pe(t){let e=null;try{let r=new URLSearchParams(location.search),o=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],n={};for(let i of o){let c=r.get(i);c&&(n[i.replace("utm_","")]=c)}Object.keys(n).length&&(e=n)}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:Io()}}function Io(){return se()}var Ct={},Po=null,z=0,fe=!1;function me(t){fe||(fe=!0,he(t),Ro(),jo(),Bo(),Oo(),No(t))}function he(t){Ct={};let e=de(),r=pe(e);if(Wt(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(o){}}function Ro(){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 o=Date.now();if(o-e<100)return;e=o;let n=r.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},c=n.tagName==="INPUT"||n.tagName==="TEXTAREA"?n.value:n.textContent;i.text=(c||"").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(o){}},{capture:!0,passive:!0})}function jo(){let t=[25,50,75,100],e=null,r=()=>{try{let o=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((o+window.innerHeight)/n*100));for(let c of t)i>=c&&!Ct[c]&&(Ct[c]=!0,l("scroll_depth",{depth:c}))}catch(o){}};r(),window.addEventListener("scroll",()=>{e||(e=setTimeout(()=>{e=null,r()},250))},{passive:!0})}function Bo(){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",o=(e.className||"").toLowerCase(),n=(e.action||"").toLowerCase();e.querySelector('input[type="search"], input[name="q"], input[name="s"]')?r="search":/newsletter|subscribe|mailchimp/.test(o+n)?r="newsletter":/contact|contato/.test(o+n)&&(r="contact"),l("form_submit",{form_id:e.id||"",form_type:r})}catch(e){}},{capture:!0})}function Oo(){let t=f();z=Date.now(),Po=setInterval(()=>{if(document.hidden)return;let e=Date.now(),r=Math.round((e-z)/1e3);z=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()-z)/1e3);e>0&&e<600&&l("engagement",{url:location.pathname,dwellSec:e})}z=Date.now()})}function No(t){let e=location.href,r=()=>{location.href!==e&&(e=location.href,he(t))};try{let o=history.pushState,n=history.replaceState;history.pushState=function(){o.apply(this,arguments),setTimeout(r,0)},history.replaceState=function(){n.apply(this,arguments),setTimeout(r,0)},window.addEventListener("popstate",r)}catch(o){}}function vt(){let t=F(),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 r=n=>{let i=document.querySelector('meta[property="og:'+n+'"], meta[property="product:'+n+'"]');return i?i.getAttribute("content"):null},o=n=>{let i=document.querySelector('[itemprop="'+n+'"]');return i?i.getAttribute("content")||(i.textContent||"").trim():null};if(t||r("type")==="product"||r("price:amount")||o("name")){let n=o("price")||r("price:amount");return{sku:t?t.value:null,skuSource:t?t.source:null,name:o("name")||r("title")||document.title||null,price:n&&parseFloat(String(n).replace(",","."))||null,currency:o("priceCurrency")||r("price:currency")||null,brand:o("brand")||null,category:null}}return null}function ge(){let t=C(["Order","Invoice"]);if(t.length>0){let o=t[0],n=o.totalPaymentDue?parseFloat(o.totalPaymentDue.price):parseFloat(o.price||o.total);return{orderId:o.orderNumber||o.confirmationNumber||o.identifier||null,revenue:Number.isFinite(n)?n:null,currency:o.totalPaymentDue&&o.totalPaymentDue.priceCurrency||o.priceCurrency||null,source:"jsonld"}}try{if(Array.isArray(window.dataLayer))for(let o=window.dataLayer.length-1;o>=0;o--){let n=window.dataLayer[o];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(o){}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 r=Mo();return r||null}function Mo(){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 o=Do(r.textContent);if(o)return{orderId:Uo(),revenue:o,source:"dom"}}}return null}catch(t){return null}}function Uo(){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 Do(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 o=parseFloat(r);return Number.isFinite(o)&&o>0?o:null}function ye(){let t=C(["ItemList","CollectionPage"]);if(t.length===0)return null;let e=t[0],r=e.itemListElement||e.mainEntity&&e.mainEntity.itemListElement||[],o=[];for(let n of r.slice(0,50)){let i=n.item||n;i&&(i.sku||i.productID||i.name)&&o.push(i.sku||i.productID||i.name)}return o.length>0?{count:o.length,skus:o.slice(0,20)}:null}var we=!1,Q=[/\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],Fo=[/^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 q(t,e){for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}function xe(t){switch(t){case"pdp":{let e=vt();l("view_item",e||{sku:null});break}case"category":case"search":{let e=ye();l("view_item_list",e||{count:0});break}case"cart":l("view_cart",{});break;case"checkout":l("begin_checkout",{});break;case"purchase":zo();break}}function zo(){let t=ge();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(r){}}else if(we)return;we=!0,l("purchase",t||{revenue:null,_note:"no_order_data_extracted"}),h("purchase emitido",t)}function be(){if(!document.body)return;let t=0;document.body.addEventListener("click",e=>{try{let r=Date.now();if(r-t<150)return;let o=e.target;for(let s=0;s<5&&o&&o!==document.body&&!(o.tagName==="BUTTON"||o.tagName==="A"||o.getAttribute&&o.getAttribute("role")==="button");s++)o=o.parentElement;if(!o)return;let n=o.tagName!=="A",i=(o.textContent||"").replace(/\s+/g," ").trim();if(!i||i.length>80)return;let c=!1;if((q([Q[0]],i)||n&&q([Q[1]],i)||n&&q([Q[2]],i)||q(Q.slice(3),i))&&(c=!0),c){t=r;let s=vt();l("add_to_cart",{via:"click",buttonText:i,sku:s?s.sku:null,price:s?s.price:null});return}n&&q(Fo,i)&&(t=r,l("begin_checkout",{via:"click",buttonText:i}))}catch(r){}},{capture:!0,passive:!0})}var _=null,v=null,et=!1,j=null,ke={},St=null,tt=0,b={onReady:null,onClose:null,onAddToCart:null,onProductLoaded:null,onError:null,onInteraction:null,onGenerationComplete:null},qo={gregory:"698c7e791d3129430f15dddd"};function Ce(t){return t?qo[String(t).toLowerCase()]||t:null}async function B(t,e){let r=f(),o=Ce(t);e=String(e||"").trim();let n=r.apiUrl+"/availability/"+o+"?sku="+encodeURIComponent(e),i=await fetch(n);if(!i.ok)throw new Error("availability HTTP "+i.status);return i.json()}async function ve(t,e){e||(e=t,t="698c7e791d3129430f15dddd");try{return(await B(t,e)).available===!0}catch(r){return!1}}async function ot(t){if(t=t||{},et)return;let e=Ce(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 o=e+":"+r;if(ke[o]!==!0){try{if(!(await B(e,r)).available){alert("Produto nao disponivel para prova virtual.");return}}catch(n){alert("Produto nao encontrado ou indisponivel.");return}ke[o]=!0}j={projectId:e,identifier:r,width:t.width||430,height:t.height||800},Ae(),$o(j),et=!0,tt=Date.now(),l("modal_opened",{projectId:e,identifier:r})}function $(){et&&(Ko(),et=!1,T("onClose"),l("modal_closed",{projectId:j&&j.projectId,identifier:j&&j.identifier}))}function Se(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 $o(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;",Se(!0);let e=document.createElement("div"),r=typeof t.width=="number"?t.width+"px":t.width,o=typeof t.height=="number"?t.height+"px":t.height;e.style.cssText="position:relative;width:"+r+";height:"+o+";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 Ko(){_&&_.parentNode&&_.parentNode.removeChild(_),_=null,v=null,Se(!1)}var _e=!1;function Te(){Ae()}function Ae(){_e||(_e=!0,window.addEventListener("message",t=>{let e=t.data;if(!e||e.source!=="mkfashion-app")return;let r=e.action,o=e.data||{};switch(r){case"close_request":$();break;case"ready":T("onReady",o);break;case"product_loaded":T("onProductLoaded",o),l("product_loaded",Tt(o));break;case"interaction":{T("onInteraction",o),o&&o.method&&(St=o.method),l(Ho(o),Tt(o));break}case"add_to_cart":l("add_to_cart",Object.assign({via:"tryon"},Tt(o))),typeof b.onAddToCart=="function"?T("onAddToCart",o):ue(o).then(()=>$()).catch(()=>{$()});break;case"generation_start":tt=Date.now();break;case"generation_complete":T("onGenerationComplete",o),l("generation_complete",{method:o.method||St||"unknown",durationMs:tt?Date.now()-tt:null,success:o.success!==!1,imageUrlPresent:!!o.imageUrl});break;case"generation_error":T("onError",o),l("generation_error",{method:St||"unknown",error:o&&o.error});break}}))}function Ho(t){return t&&t.action,"interaction"}function Tt(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 T(t,e){if(typeof b[t]=="function")try{b[t](e)}catch(r){console.error("[mk-sdk]",r)}}function Ee(t){b.onReady=t}function Le(t){b.onClose=t}function Ie(t){b.onAddToCart=t}function Pe(t){b.onProductLoaded=t}function Re(t){b.onError=t}function je(t){b.onInteraction=t}function Be(t){b.onGenerationComplete=t}var Vo=767,Go=1024,Wo=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora|^comprar$|finalizar compra|eu quero/i,Xo=/continuar|como comprar|lista|desejos|favorito|looks|cupom/i;function At(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 Yo(t){if(!t)return!1;try{let e=document.querySelector(t);return!!e&&At(e)}catch(e){return!1}}function Zo(t){return(t.tagName==="INPUT"?t.value||"":t.textContent||"").replace(/\s+/g," ").trim()}function Qo(t){if(!t||typeof t!="object"||t.selector)return t;let e=!1;if(["mobile","tablet","desktop"].forEach(o=>{let n=t[o];n&&n.mkAnchor===1&&n.anchor&&typeof n.anchor=="object"&&(e=!0)}),!e)return t;let r={};return["mobile","tablet","desktop"].forEach(o=>{let n=t[o];if(n){if(n.selector){r[o]=n;return}if(n.mkAnchor===1&&n.anchor&&typeof n.anchor=="object"){let i=n.anchor[o]||n.anchor.desktop||n.anchor.mobile||n.anchor.tablet;i&&i.selector&&(r[o]=i)}}}),["bpMobile","bpTablet","breakpoint"].forEach(o=>{t[o]!=null&&(r[o]=t[o])}),r}function Et(t){if(!t||typeof t!="object")return null;if(t=Qo(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])=>Yo(u.selector));if(r.length===1)return r[0][1];let o=window.innerWidth||1024,n=Number(t.bpMobile)||Number(t.breakpoint)||Vo,i=Number(t.bpTablet)||Go,c=u=>(e.find(d=>d[0]===u)||[])[1],s=o<=n?["mobile","tablet","desktop"]:o<=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 Oe(){let t=f(),e=Et(t&&t.anchor);if(e&&e.selector)try{let o=document.querySelector(e.selector);if(o&&At(o))return{el:o,position:e.position||"afterend",mode:e.mode||"flow",style:e.style||"",align:e.align||"top-left",selector:e.selector}}catch(o){}let r=document.querySelectorAll('button, [role="button"], a.btn, a.button, input[type="submit"], input[type="button"]');for(let o of r){let n=Zo(o);if(!(!n||n.length>40)&&!Xo.test(n)&&Wo.test(n)&&At(o))return{el:o,position:"afterend",mode:"flow",style:"",selector:null}}return null}var w="'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Lt={none:"0",sm:"4px",md:"8px",pill:"9999px"},It={none:"0",sm:"4px",md:"8px",lg:"16px"},tr='<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>',er='<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 o in e.attrs)r.setAttribute(o,e.attrs[o]);if(e.on)for(let o in e.on)r.addEventListener(o,e.on[o]);if(e.children)for(let o of e.children)o&&r.appendChild(o);return r}function rt(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:tr})}function Ne(t){return p("span",{style:`width:12px;height:12px;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:er})}function nt(t){return t.borderWidth>0&&t.borderColor?`${t.borderWidth}px solid ${t.borderColor}`:"none"}function it(){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 or(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 Me(t,e){it();let r=p("span",{style:"display:inline-flex;align-items:center;gap:4px;",children:[rt(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:${nt(t)};border-radius:${t.borderRadiusPx};font-family:${w};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[r,or(t)],on:{mouseenter:o=>{o.currentTarget.style.opacity="0.85"},mouseleave:o=>{o.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(o){}}}})}function nr(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:[Ne(t.badgeTextColor),p("span",{text:t.subtext})]}):null}function ir(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:${nt(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:[rt(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:r=>{r.currentTarget.style.opacity="0.85"},mouseleave:r=>{r.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(r){}}}})}function Ue(t,e){it();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:${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};`})]}),o=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:${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:[nr(t),ir(t,e)]}),i=p("div",{style:"display:flex;gap:16px;align-items:stretch;width:100%;flex:1;box-sizing:border-box;",children:[o,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 ar={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 Pt(t,e){let r=(e?t&&t.mobile:t&&t.desktop)||t&&t.desktop||t&&t.mobile||{},o={...ar,...r};return o.style==="gregory-card"&&e&&(o.style="gregory-black"),o.borderRadiusPx=Lt[o.borderRadius]!=null?Lt[o.borderRadius]:"0",o.cardBorderRadiusPx=It[o.cardBorderRadius]!=null?It[o.cardBorderRadius]:"0",o.fontSize=Number(o.fontSize)||14,o.borderWidth=Number(o.borderWidth)||0,o}var Rt={"gregory-black":Me,"gregory-card":Ue},on=Object.keys(Rt);function De(t,e){return(Rt[t.style]||Rt["gregory-black"])(t,e)}var Nt="mk-tryon-button-host",lr=/^(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 sr(t){return!t||typeof t!="string"?"":t.split(";").map(e=>e.trim()).filter(Boolean).filter(e=>lr.test(e.split(":")[0].trim().toLowerCase())).join(";")}var ct=null,jt=!1,Bt={},Fe=!1,Ot=null;function ze(){return Ot||(Ot=R().then(t=>t&&t.template&&t.template.tryOnButton||null).catch(()=>null)),Ot}function ur(){if(Fe)return;Fe=!0;let t=null;try{window.addEventListener("resize",()=>{clearTimeout(t),t=setTimeout(()=>{ct&&O("pdp")},200)})}catch(e){}}function Mt(){let t=document.getElementById(Nt);if(t){if(typeof t.__mkCleanup=="function")try{t.__mkCleanup()}catch(e){}t.parentNode&&t.parentNode.removeChild(t)}ct=null}var dr={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 pr(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 fr(t,e,r){let n=!dr[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;"+pr(r),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,a=e.offsetHeight,x=d.top-m.top+n.scrollTop,A=d.left-m.left+n.scrollLeft,y=r||"top-left",K=x,S=A;y.indexOf("bottom")===0?K=x+d.height-a:(y.indexOf("middle")===0||y==="center")&&(K=x+(d.height-a)/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 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 mr(t,e,r){try{return t.insertAdjacentElement(r||"afterend",e),!0}catch(o){try{return t.parentNode.insertBefore(e,t.nextSibling),!0}catch(n){return!1}}}async function O(t){let e=f();if(t!=="pdp"){Mt();return}if(!e.projectId)return;if(!e._anchorFromPicker){let u=await ze();u&&u.anchor&&(e.anchor=u.anchor)}if(jt)return;let r=F(),o=r&&r.value,n=!!e.forceButton,i=Et(e.anchor),c=[o||"demo",i?[i.selector,i.position,i.mode,i.align,i.style].join("~"):"heuristic"].join("|"),s=document.getElementById(Nt);if(!(s&&ct===c)){if(s&&Mt(),!o&&!n){h("auto-mount: SKU n\xE3o resolvido na PDP");return}jt=!0;try{let u=n;n||(Bt[o]||(Bt[o]=B(e.projectId,o).then(k=>!!(k&&k.available)).catch(()=>!1)),u=await Bt[o]);try{Gt(u?"available":"unavailable")}catch(k){}if(!u){h("auto-mount: produto sem try-on",o);return}let d=await ze(),m=window.matchMedia("(max-width: 767px)").matches,g=Pt(d,m),a=Oe(),x=a&&a.mode||"flow",A=De(g,()=>{let k=F(),at=k&&k.value||o||"";l("button_clicked",{sku:at,style:g.style,mode:x}),ot({projectId:e.projectId,identifier:at})}),y=document.createElement("div");y.id=Nt,y.attachShadow({mode:"closed"}).appendChild(A);let S=!1;if(a&&a.el&&a.el.parentNode&&(x==="overlay"?(fr(a.el,y,a.align),S=!0):(y.style.cssText="display:contents;",S=mr(a.el,y,a.position))),S||(y.style.cssText="position:fixed;left:16px;bottom:16px;z-index:2147483000;",document.body.appendChild(y)),a&&a.style){let k=sr(a.style);if(k)try{A.style.cssText+=";"+k}catch(at){}}ct=c,ur(),h("auto-mount: bot\xE3o injetado",{style:g.style,sku:o,anchorFound:!!a,position:a&&a.position,mode:x,forced:n}),l("button_rendered",{style:g.style,sku:o||null,skuSource:r&&r.source,anchorFound:!!a,position:a?a.position:null,mode:x,forced:n})}finally{jt=!1}}}function qe(){try{let t=f(),e={anchor:t.anchor,forceButton:t.forceButton};window.addEventListener("message",r=>{if(r.source!==window)return;let o=r.data;!o||!o.__mkCmd||(o.__mkCmd==="remount"||o.__mkCmd==="applyRecipe"?(t.anchor=o.anchor||null,t._anchorFromPicker=!0,t.forceButton=!0,O("pdp")):o.__mkCmd==="cancelPreview"&&(t.anchor=e.anchor,t._anchorFromPicker=!1,t.forceButton=e.forceButton,Mt(),O("pdp")))})}catch(t){}}(function(){"use strict";try{let r=function(){try{Yt(),qe(),Te(),e.autoTrack!==!1&&(me((n,i)=>{xe(n,i),O(n)}),be()),h("mk-sdk iniciado",{projectId:e.projectId,collectorUrl:e.collectorUrl})}catch(n){e.debug&&console.error("[mk-sdk] init erro",n)}},e=st();if(e.projectId){let n=ee(e.projectId);n&&ht(n),R().then(i=>{let c=Qt(i);ht(c),oe(e.projectId,c),h("escopo de coleta",c)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r):r();let o={open:ot,close:$,isAvailable:ve,getAvailability:B,onReady:Ee,onClose:Le,onAddToCart:Ie,onProductLoaded:Pe,onError:Re,onInteraction:je,onGenerationComplete:Be,_version:"0.1.0",_isMkSdk:!0};typeof window!="undefined"&&(window.mk=o)}catch(e){typeof console!="undefined"&&console.error("[mk-sdk] boot fatal",e)}})();})();
|
package/package.json
CHANGED
package/src/core/config.js
CHANGED
|
@@ -64,6 +64,11 @@ export function resolveConfig() {
|
|
|
64
64
|
anchor: (window.__MK && window.__MK.anchor) || null,
|
|
65
65
|
// cartRedirect: após adicionar ao carrinho pelo provador, leva o usuário ao /cart (default: sim).
|
|
66
66
|
cartRedirect: !(window.__MK && window.__MK.cartRedirect === false),
|
|
67
|
+
// cartBehavior: o que fazer após adicionar — 'redirect' (vai pro /cart), 'drawer'
|
|
68
|
+
// (abre a sacola lateral do tema) ou 'none'. Server-driven via receita; este é
|
|
69
|
+
// só o fallback inline. cartOpenSelector = o que clicar pra abrir o drawer.
|
|
70
|
+
cartBehavior: (window.__MK && window.__MK.cartBehavior) || null,
|
|
71
|
+
cartOpenSelector: (window.__MK && window.__MK.cartOpenSelector) || null,
|
|
67
72
|
autoTrack: attr('data-mk-no-autotrack') === null, // autotrack ligado por padrão
|
|
68
73
|
batchIntervalMs: 2000,
|
|
69
74
|
batchMaxSize: 20,
|
package/src/platforms/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// O nº de arquivos cresce com plataformas (poucas), não com lojas (ilimitadas).
|
|
6
6
|
|
|
7
7
|
import { getConfig, log } from '../core/config.js';
|
|
8
|
+
import { fetchProjectRecipe } from '../core/projectRecipe.js';
|
|
8
9
|
import * as shopify from './shopify.js';
|
|
9
10
|
import * as hybris from './hybris.js';
|
|
10
11
|
import * as vtex from './vtex.js';
|
|
@@ -49,7 +50,8 @@ export function resolveSku() {
|
|
|
49
50
|
export async function addToCart(payload) {
|
|
50
51
|
payload = payload || {};
|
|
51
52
|
const norm = {
|
|
52
|
-
size: payload.size || payload.selectedSize || null,
|
|
53
|
+
size: payload.size || payload.selectedSize || payload.tamanho || null,
|
|
54
|
+
color: payload.color || payload.selectedColor || payload.colour || payload.cor || null,
|
|
53
55
|
sku: payload.sku || payload.identifier || payload.selectedIdentifier || null,
|
|
54
56
|
quantity: payload.quantity || 1
|
|
55
57
|
};
|
|
@@ -58,13 +60,13 @@ export async function addToCart(payload) {
|
|
|
58
60
|
const result = plat.addToCart ? await plat.addToCart(norm) : await generic.addToCart(norm);
|
|
59
61
|
log('cart: adicionado', result);
|
|
60
62
|
notifyTheme();
|
|
61
|
-
|
|
63
|
+
await applyAfterAdd(plat);
|
|
62
64
|
return result;
|
|
63
65
|
} catch (e) {
|
|
64
66
|
log('cart: adapter "' + plat.id + '" falhou — fallback clique nativo', e && e.message);
|
|
65
67
|
const r = await generic.addToCart(norm);
|
|
66
68
|
notifyTheme();
|
|
67
|
-
|
|
69
|
+
await applyAfterAdd(plat);
|
|
68
70
|
return r;
|
|
69
71
|
}
|
|
70
72
|
}
|
|
@@ -75,11 +77,32 @@ function notifyTheme() {
|
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
|
|
80
|
+
// O que fazer após adicionar ao carrinho. Server-driven: a receita da dashboard
|
|
81
|
+
// (project.template.cart) manda; cai no __MK inline e, por fim, no cartRedirect
|
|
82
|
+
// legado. Comportamentos:
|
|
83
|
+
// • 'drawer' → abre a sacola lateral do tema (clica cartOpenSelector), sem sair da página
|
|
84
|
+
// • 'redirect' → leva o usuário ao /cart (default histórico)
|
|
85
|
+
// • 'none' → só adiciona, não faz nada
|
|
86
|
+
async function applyAfterAdd(plat) {
|
|
81
87
|
const cfg = getConfig();
|
|
82
|
-
|
|
88
|
+
let recipe = null;
|
|
89
|
+
try { recipe = await fetchProjectRecipe(); } catch (_) {}
|
|
90
|
+
const rc = (recipe && recipe.template && recipe.template.cart) || (recipe && recipe.cart) || {};
|
|
91
|
+
|
|
92
|
+
const behavior = rc.afterAdd || rc.behavior || cfg.cartBehavior || (cfg.cartRedirect ? 'redirect' : 'none');
|
|
93
|
+
const openSelector = rc.openSelector || cfg.cartOpenSelector || (plat && plat.cartToggleSelector) || null;
|
|
94
|
+
|
|
95
|
+
if (behavior === 'none') return;
|
|
96
|
+
|
|
97
|
+
if (behavior === 'drawer' && openSelector) {
|
|
98
|
+
// o tema re-renderiza a sacola com o item ao abrir; pequeno delay garante o /cart atualizado
|
|
99
|
+
setTimeout(() => {
|
|
100
|
+
try { const el = document.querySelector(openSelector); if (el) el.click(); } catch (_) {}
|
|
101
|
+
}, 300);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// redirect (default) — também é o fallback de 'drawer' sem seletor configurado
|
|
83
106
|
if (plat && plat.skipRedirect) return;
|
|
84
107
|
const url = (plat && plat.cartUrl) || '/cart';
|
|
85
108
|
setTimeout(() => { try { window.location.href = url; } catch (_) {} }, 250);
|
package/src/platforms/shopify.js
CHANGED
|
@@ -13,15 +13,22 @@ export function resolveSku() {
|
|
|
13
13
|
|
|
14
14
|
const norm = (s) => String(s == null ? '' : s).trim().toLowerCase();
|
|
15
15
|
|
|
16
|
-
export async function addToCart({ size, sku, quantity }) {
|
|
16
|
+
export async function addToCart({ size, color, sku, quantity }) {
|
|
17
17
|
const handle = (location.pathname.split('/products/')[1] || '').split(/[?#]/)[0];
|
|
18
18
|
if (!handle) throw new Error('shopify: sem handle de produto na URL (não é PDP?)');
|
|
19
19
|
const prod = await fetch('/products/' + handle + '.js').then((r) => r.json());
|
|
20
20
|
const vars = prod.variants || [];
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
// valores de opção da variante: option1/2/3 + pedaços do title ("Cor / Tam").
|
|
23
|
+
const valsOf = (x) => [x.option1, x.option2, x.option3]
|
|
24
|
+
.concat(String(x.title || '').split('/'))
|
|
25
|
+
.map(norm).filter(Boolean);
|
|
26
|
+
const has = (x, val) => valsOf(x).indexOf(norm(val)) >= 0;
|
|
27
|
+
// casa por COR e TAMANHO quando informados (ignora o que não veio).
|
|
28
|
+
const matches = (x) => (!size || has(x, size)) && (!color || has(x, color));
|
|
22
29
|
|
|
23
30
|
let v = null;
|
|
24
|
-
if (size) v = vars.find((x) =>
|
|
31
|
+
if (size || color) v = vars.find((x) => matches(x) && x.available) || vars.find(matches);
|
|
25
32
|
if (!v && sku) v = vars.find((x) => norm(x.sku) === norm(sku));
|
|
26
33
|
if (!v) v = vars.find((x) => x.available) || vars[0];
|
|
27
34
|
if (!v) throw new Error('shopify: variante não encontrada');
|
package/src/tryon/bridge.js
CHANGED
|
@@ -83,9 +83,28 @@ export function close() {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// ─── Modal DOM ────────────────────────────────────────────────────────────
|
|
86
|
+
// Esconde/mostra o botão de try-on enquanto o modal está aberto. O host usa
|
|
87
|
+
// z-index altíssimo (overlay) e apareceria POR CIMA do modal; esconder garante
|
|
88
|
+
// que ele suma independente de z-index/stacking context da loja.
|
|
89
|
+
function toggleTryonButton(hide) {
|
|
90
|
+
try {
|
|
91
|
+
const h = document.getElementById('mk-tryon-button-host');
|
|
92
|
+
if (!h) return;
|
|
93
|
+
if (hide) {
|
|
94
|
+
if (h.dataset.mkPrevDisplay === undefined) h.dataset.mkPrevDisplay = h.style.display;
|
|
95
|
+
h.style.display = 'none';
|
|
96
|
+
} else {
|
|
97
|
+
h.style.display = h.dataset.mkPrevDisplay || '';
|
|
98
|
+
delete h.dataset.mkPrevDisplay;
|
|
99
|
+
}
|
|
100
|
+
} catch (_) {}
|
|
101
|
+
}
|
|
102
|
+
|
|
86
103
|
function openModal(cfg) {
|
|
87
104
|
modal = document.createElement('div');
|
|
88
|
-
modal
|
|
105
|
+
// z-index máximo: o modal fica acima de tudo, inclusive do host do botão (~2.1bi).
|
|
106
|
+
modal.style.cssText = 'position:fixed;inset:0;background:rgba(0,0,0,.8);display:flex;align-items:center;justify-content:center;z-index:2147483647;';
|
|
107
|
+
toggleTryonButton(true);
|
|
89
108
|
|
|
90
109
|
const container = document.createElement('div');
|
|
91
110
|
const w = typeof cfg.width === 'number' ? cfg.width + 'px' : cfg.width;
|
|
@@ -110,6 +129,7 @@ function hideModal() {
|
|
|
110
129
|
if (modal && modal.parentNode) modal.parentNode.removeChild(modal);
|
|
111
130
|
modal = null;
|
|
112
131
|
iframe = null;
|
|
132
|
+
toggleTryonButton(false); // volta a mostrar o botão
|
|
113
133
|
}
|
|
114
134
|
|
|
115
135
|
// ─── postMessage listener — capta eventos do iframe MK ────────────────────
|
|
@@ -150,7 +170,9 @@ function setupMessageListener() {
|
|
|
150
170
|
if (typeof callbacks.onAddToCart === 'function') {
|
|
151
171
|
fire('onAddToCart', payload); // cliente cuida (compat SDK v2)
|
|
152
172
|
} else {
|
|
153
|
-
|
|
173
|
+
// mk-sdk adiciona sozinho (zero-touch) e fecha o provador — aí o
|
|
174
|
+
// pós-add (redirect/drawer) acontece sem o modal por cima da sacola.
|
|
175
|
+
cartAdd(payload).then(() => close()).catch(() => { close(); });
|
|
154
176
|
}
|
|
155
177
|
break;
|
|
156
178
|
case 'generation_start':
|