{"version":3,"file":"TrackingEvent.cql0d4HG.mjs","names":["React"],"sources":["https:/framerusercontent.com/modules/Mw3aZ3xVHFqwfCO7exyy/ksOa4w67j1KYVPclzm7k/TrackingEvent.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import React from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";// Create a shared store for managing state\nconst useStore=createStore({intialVariant:null});// Higher-order component to observe variant changes\nexport function TrackingEvent(Component){return props=>{const[store,setStore]=useStore();const targetNode=React.useRef(null);React.useEffect(()=>{// Callback function for MutationObserver\nconst callback=mutationsList=>{for(const mutation of mutationsList){if(mutation.type===\"attributes\"&&mutation.attributeName===\"data-framer-name\"){const newVariant=mutation.target.getAttribute(\"data-framer-name\");// Update the store with the new variant\nif(store.intialVariant!==newVariant){setStore({intialVariant:newVariant});// Trigger GTM event when the variant is \"Success\"\nif(newVariant===\"Success\"){console.log(\"Success variant detected! Triggering GTM event...\");if(typeof window!==\"undefined\"){window.dataLayer=window.dataLayer||[];window.dataLayer.push({event:\"order-form-submit\",timestamp:new Date().toISOString()});console.log(\"GTM Event: order-form-submit triggered.\");}window.scrollTo({top:0,behavior:\"smooth\"});}}}}};// Create a MutationObserver instance\nconst observer=new MutationObserver(callback);// Observer configuration: listen for attribute changes\nconst config={attributes:true,attributeFilter:[\"data-framer-name\"]};// Start observing the target node\nif(targetNode.current){setStore({initialVariant:targetNode.current.getAttribute(\"data-framer-name\")});observer.observe(targetNode.current,config);}// Cleanup the observer on component unmount\nreturn()=>{observer.disconnect();};},[]);// React.useEffect(() => {\n//     // Log the initial variant whenever it changes\n//     console.log(Current Variant in Store: ${store.intialVariant})\n// }, [store.intialVariant])\nreturn /*#__PURE__*/_jsx(Component,{ref:targetNode,...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"TrackingEvent\":{\"type\":\"reactHoc\",\"name\":\"TrackingEvent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TrackingEvent.map"],"mappings":"wLAEA,SAAgB,EAAc,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAM,GAAU,EAAS,EAAQ,EAAWA,EAAM,OAAO,IAAI,EAW3H,OAX6H,EAAM,cAAc,CAIjJ,IAAM,EAAS,IAAI,iBAHJ,GAAe,CAAC,IAAI,IAAM,KAAY,EAAe,GAAG,EAAS,OAAO,cAAc,EAAS,gBAAgB,mBAAmB,CAAC,IAAM,EAAW,EAAS,OAAO,aAAa,kBAAkB,EAC/M,EAAM,gBAAgB,IAAY,EAAS,CAAC,cAAc,CAAU,CAAC,EACrE,IAAa,YAAW,QAAQ,IAAI,mDAAmD,EAAY,IAAS,SAAa,EAAO,UAAU,EAAO,WAAW,CAAC,EAAE,EAAO,UAAU,KAAK,CAAC,MAAM,oBAAoB,UAAU,IAAI,KAAK,CAAA,CAAE,YAAY,CAAC,CAAC,EAAE,QAAQ,IAAI,yCAAyC,GAAG,EAAO,SAAS,CAAC,IAAI,EAAE,SAAS,QAAQ,CAAC,GAAI,CAAE,CACnT,EAG5C,OADG,EAAW,UAAS,EAAS,CAAC,eAAe,EAAW,QAAQ,aAAa,kBAAkB,CAAC,CAAC,EAAE,EAAS,QAAQ,EAAW,QAAQ,CAD5H,WAAW,GAAK,gBAAgB,CAAC,kBAAkB,CACyE,CAAM,OACtI,CAAC,EAAS,WAAW,CAAE,CAAE,EAAE,CAAC,CAAC,EAInB,EAAK,EAAU,CAAC,IAAI,EAAW,GAAG,CAAK,CAAC,CAAE,CAAE,uBAbtB,IAAyB,IAAqE,EAClI,EAAS,EAAY,CAAC,cAAc,IAAI,CAAC"}