{"version":3,"file":"TrackginBanner.DXuyePwB.mjs","names":["React.useState","React.useRef","__esmMin","init_ssg_sandbox_shims","_e","de","init_jsx_runtime","c","init_npm_react_18_3_1","ce","window","RenderTarget","init_framer_B6PCHH0A","addPropertyControls","ControlType","GA4Banner","props","hasBeenViewed","setHasBeenViewed","bannerRef","sendEvent","eventName","observer","entry","init_TrackginBanner"],"sources":["https:/framerusercontent.com/modules/oMlBsXovgSBHIyu77ZKb/SuXtbnM6m9bAiwogpuxd/TrackginBanner.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{ControlType,addPropertyControls,RenderTarget}from\"framer\";export default function GA4Banner(props){const{children,promotion_id,promotion_name,location}=props;const[hasBeenViewed,setHasBeenViewed]=React.useState(false);const bannerRef=React.useRef(null);const sendEvent=eventName=>{if(typeof window!==\"undefined\"){window.dataLayer=window.dataLayer||[];window.dataLayer.push({event:eventName,promotion_id,promotion_name,location});console.log(`📡 [GA4] ${eventName}:`,{promotion_id,promotion_name,location});}};// Lógica para detectar se o banner apareceu na tela (Intersection Observer)\nReact.useEffect(()=>{// Não dispara no Canvas do Framer, apenas no Preview ou Site Publicado\nif(RenderTarget.current()===RenderTarget.canvas)return;if(hasBeenViewed)return;// Garante que dispare apenas 1 vez\nconst observer=new IntersectionObserver(([entry])=>{if(entry.isIntersecting){sendEvent(\"view_promotion\");setHasBeenViewed(true);observer.disconnect()// Para de observar após o disparo\n;}},{threshold:.5}// 50% do banner precisa estar visível para contar\n);if(bannerRef.current){observer.observe(bannerRef.current);}return()=>observer.disconnect();},[sendEvent,hasBeenViewed]);return /*#__PURE__*/_jsx(\"div\",{ref:bannerRef,onClick:()=>sendEvent(\"select_promotion\"),style:{display:\"block\",cursor:\"pointer\"},children:children});}addPropertyControls(GA4Banner,{children:{type:ControlType.ComponentInstance,title:\"Banner Element\"},promotion_id:{type:ControlType.String,title:\"Promo ID\",defaultValue:\"promo_01\"},promotion_name:{type:ControlType.String,title:\"Promo Name\",defaultValue:\"Campanha Ver\\xe3o\"},location:{type:ControlType.String,title:\"Location\",defaultValue:\"home_hero\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GA4Banner\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TrackginBanner.map"],"mappings":"A,8MAAwI,SAAwBe,EAAU,EAAM,CAAC,GAAK,CAAC,WAAS,eAAa,iBAAe,YAAUC,EAAW,CAACC,EAAcC,GAAkBlB,EAAe,EAAK,EAAQmB,EAAUlB,EAAa,IAAI,EAAQmB,EAAU,GAAW,CAAWV,IAAS,SAAa,EAAO,UAAUA,EAAO,WAAW,CAAC,EAAEA,EAAO,UAAU,KAAK,CAAC,MAAMW,EAAU,eAAa,iBAAe,UAAQ,CAAC,EAAE,QAAQ,IAAI,YAAYA,EAAU,GAAG,CAAC,eAAa,iBAAe,UAAQ,CAAC,EAAG,EAK/c,OAJ1HZ,MAAoB,CACmC,GAApDE,EAAa,QAAQ,IAAIA,EAAa,QAAiBM,EAAc,OACxE,IAAMK,EAAS,IAAI,sBAAsB,CAACC,KAAS,CAAIA,EAAM,iBAAgBH,EAAU,gBAAgB,EAAEF,EAAiB,EAAI,EAAEI,EAAS,WAAW,EAClJ,EAAE,CAAC,UAAU,EAAE,CACjB,EAA6D,OAAxDH,EAAU,SAASG,EAAS,QAAQH,EAAU,OAAO,MAAaG,EAAS,WAAW,CAAE,EAAE,CAACF,EAAUH,CAAa,CAAC,EAAsB,gBAAK,MAAM,CAAC,IAAIE,EAAU,YAAYC,EAAU,kBAAkB,EAAE,MAAM,CAAC,QAAQ,QAAQ,OAAO,SAAS,EAAW,UAAQ,CAAC,CAAE,C,8CAACP,EAAoBE,EAAU,CAAC,SAAS,CAAC,KAAKD,EAAY,kBAAkB,MAAM,gBAAgB,EAAE,aAAa,CAAC,KAAKA,EAAY,OAAO,MAAM,WAAW,aAAa,UAAU,EAAE,eAAe,CAAC,KAAKA,EAAY,OAAO,MAAM,aAAa,aAAa,gBAAmB,EAAE,SAAS,CAAC,KAAKA,EAAY,OAAO,MAAM,WAAW,aAAa,WAAW,CAAC,CAAC,C"}