{"version":3,"file":"pmw-lazy__premium_only.js","mappings":"2DAOAA,SAASC,iBAAiB,gCAAkCC,SAASC,IACpE,IAAIC,EAAeJ,SAASK,cAAc,QAC1CD,EAAYE,KAAOH,EAAOI,IAC1BH,EAAYI,IAAO,UACnBJ,EAAYK,GAAO,SACnBT,SAASU,KAAKC,YAAYP,EAAY,IAevC,SAASQ,IAERZ,SAASC,iBAAiB,gCAAkCC,SAASC,IAEpEA,EAAOU,SACP,IAAIC,EAAkBd,SAASK,cAAc,UAC7CS,EAAgBP,IAAMJ,EAAOI,IAC7BP,SAASe,KAAKJ,YAAYG,EAAgB,GAE5C,CApByB,CACxB,UACA,YACA,YACA,YACA,aACA,WACA,SAgBgBZ,SAASc,IACzBhB,SAASiB,iBAAiBD,GAAO,SAASE,IAKzCN,IAGAZ,SAASmB,oBAAoBH,EAAOE,EAMrC,GAAE,IAIHlB,SAASiB,iBAAiB,oBAAoB,KAEjB,oBAAjBG,eASwB,SAAlCA,cAAcC,MAAMC,WACiB,aAAlCF,cAAcC,MAAMC,WAEvBV,IACD,G","sources":["webpack://Pixel-Manager-for-WooCommerce/./src/js-src/public/pmw-lazy__premium_only.js"],"sourcesContent":["/**\n * Copyright 2023 SweetCode. All rights reserved.\n *\n * Process lazy loaded PMW scripts\n */\n\n// Preload the scripts\ndocument.querySelectorAll(\"script[type=\\\"text/pmw-lazy\\\"]\").forEach((script) => {\n\tlet preloadLink = document.createElement(\"link\")\n\tpreloadLink.href = script.src\n\tpreloadLink.rel = \"preload\"\n\tpreloadLink.as = \"script\"\n\tdocument.head.appendChild(preloadLink)\n})\n\n// All user interaction events to listen to\nconst eventsToListenTo = [\n\t\"keydown\",\n\t\"mousedown\",\n\t\"mousemove\",\n\t\"touchmove\",\n\t\"touchstart\",\n\t\"touchend\",\n\t\"wheel\",\n]\n\n// Load scripts after interaction\nfunction activateLazyLoadedScripts() {\n\n\tdocument.querySelectorAll(\"script[type=\\\"text/pmw-lazy\\\"]\").forEach((script) => {\n\n\t\tscript.remove()\n\t\tlet preloadedScript = document.createElement(\"script\")\n\t\tpreloadedScript.src = script.src\n\t\tdocument.body.appendChild(preloadedScript)\n\t})\n}\n\n// Add event listeners to any interaction events\neventsToListenTo.forEach((event) => {\n\tdocument.addEventListener(event, function handler() {\n\n\t\t// console log timestamp\n\t\t// console.log(\"timestamp: \" + Date.now())\n\n\t\tactivateLazyLoadedScripts()\n\n\t\t// detach event listener\n\t\tdocument.removeEventListener(event, handler)\n\n\t\t// detach all event listeners\n\t\t// eventsToListenTo.forEach(function (event) {\n\t\t// \tdocument.removeEventListener(event, handler)\n\t\t// })\n\t})\n})\n\n// Always fully load scripts on cart and checkout pages\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n\n\tif (typeof wpmDataLayer === \"undefined\") {\n\n\t\t// At this point the wpmDataLayer should be defined\n\t\t// It might not be the case if a third-party plugin blocks it, such as a consent management platform or a JavaScript optimizer.\n\t\t// console.error(\"Pixel Manager error: The wpmDataLayer is undefined. Whitelist the wpmDataLayer from any consent management platforms and JavaScript optimizers.\")\n\t\treturn\n\t}\n\n\tif (\n\t\twpmDataLayer?.shop?.page_type === \"cart\"\n\t\t|| wpmDataLayer?.shop?.page_type === \"checkout\"\n\t) {\n\t\tactivateLazyLoadedScripts()\n\t}\n})\n"],"names":["document","querySelectorAll","forEach","script","preloadLink","createElement","href","src","rel","as","head","appendChild","activateLazyLoadedScripts","remove","preloadedScript","body","event","addEventListener","handler","removeEventListener","wpmDataLayer","shop","page_type"],"sourceRoot":""}