{"version":3,"file":"CookiesBanner.CuvzAS-5.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/SoMZlNYjHxKnvxJeTd3O/3XS9cPsCxyhxiO8vrYsj/CookiesBanner.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const domainsToDecorate=[\"smile2impress.com\",\"drsmile.es\",\"dr-smile.it\",\"drsmile.fr\"],queryParams=[\"utm_term\",\"utm_campaign\",\"utm_source\",\"utm_medium\",\"utm_content\",\"hsa_acc\",\"hsa_cam\",\"hsa_grp\",\"hsa_ad\",\"hsa_src\",\"hsa_tgt\",\"hsa_kw\",\"hsa_mt\",\"hsa_net\",\"hsa_ver\",\"gclid\",\"ttclid\",\"fbclid\"];export default function CookiesBanner({id,locale,hideCookiesPolicyBanner,hasQueryInit}){// We can't really do anything without a formId\nif(!id){return /*#__PURE__*/_jsx(\"div\",{children:\"Cookies banner will be here!\"});}// We use the Framer node id for a stable id\nconst elementId=`container_${id}`;const[cookiesBanner,setCookiesBanner]=useState();useEffect(()=>{const script=document.createElement(\"script\");const scriptUrl=\"https://mf.smile2impress.com/cookies-banner-widget/index.js\";script.src=scriptUrl;script.async=true;const handleScriptLoad=()=>{// The remote script has loaded successfully\nconsole.log(`Script loaded: ${scriptUrl}`);setCookiesBanner(new window.CookiesBannerWidget);};const handleScriptError=()=>{// There was an error loading the script\nconsole.error(`Error loading script: ${scriptUrl}`);};script.addEventListener(\"load\",handleScriptLoad);script.addEventListener(\"error\",handleScriptError);// Append the script to the document body\ndocument.body.appendChild(script);// Clean up event listeners when the component unmounts\nreturn()=>{script.removeEventListener(\"load\",handleScriptLoad);script.removeEventListener(\"error\",handleScriptError);};},[id]);useEffect(()=>{if(!hasQueryInit){return;}// We get all the links on the page\nconst links=document.querySelectorAll(\"a\");// We check and add parameters only if they are missing\nfor(let linkIndex=0;linkIndex<links.length;linkIndex++){for(let domainIndex=0;domainIndex<domainsToDecorate.length;domainIndex++){if(links[linkIndex].href.indexOf(domainsToDecorate[domainIndex])>-1&&links[linkIndex].href.indexOf(\"#\")===-1){if(!hasRequiredQueryParams(links[linkIndex].href)){// We check if the necessary parameters already exist\nlinks[linkIndex].href=decorateUrl(links[linkIndex].href);}}}}// Function for adding query parameters to URL\nfunction decorateUrl(urlToDecorate){urlToDecorate=urlToDecorate.indexOf(\"?\")===-1?urlToDecorate+\"?\":urlToDecorate+\"&\";let collectedQueryParams=[];for(let queryIndex=0;queryIndex<queryParams.length;queryIndex++){if(getQueryParam(queryParams[queryIndex])){collectedQueryParams.push(queryParams[queryIndex]+\"=\"+getQueryParam(queryParams[queryIndex]));}}return urlToDecorate+collectedQueryParams.join(\"&\");}// Checking for the presence of mandatory query parameters in the link\nfunction hasRequiredQueryParams(url){for(let queryIndex=0;queryIndex<queryParams.length;queryIndex++){if(url.indexOf(queryParams[queryIndex]+\"=\")>-1){return true// If at least one parameter already exists, return true\n;}}return false// If there are no parameters, return false\n;}// Getting the value of a query parameter from the current URL\nfunction getQueryParam(name){if(name=new RegExp(\"[?&]\"+encodeURIComponent(name)+\"=([^&]*)\").exec(window.location.search)){return decodeURIComponent(name[1]);}}},[id,hasQueryInit]);useEffect(()=>{if(cookiesBanner){cookiesBanner.mount({id,elementId,locale,hideCookiesPolicyBanner});}},[cookiesBanner,locale,hideCookiesPolicyBanner]);return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"},id:elementId});}addPropertyControls(CookiesBanner,{locale:{type:ControlType.Enum,title:\"Locale\",options:[\"es-ES\",\"it-IT\",\"pt-PT\",\"fr-FR\",\"de-DE\",\"uk-UA\",\"en-GB\",\"en-US\"],optionTitles:[\"Spain\",\"Italy\",\"Portugal\",\"France\",\"Germany\",\"Ukraine\",\"UK\",\"USA\"],defaultValue:\"es-ES\"},hideCookiesPolicyBanner:{type:ControlType.Boolean,title:\"Hide cookies policy banner\",enabledTitle:\"True\",disabledTitle:\"False\",defaultValue:false},hasQueryInit:{type:ControlType.Boolean,title:\"Has query init\",enabledTitle:\"True\",disabledTitle:\"False\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CookiesBanner\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CookiesBanner.map"],"mappings":"+LAAsa,SAAwB,EAAc,CAAC,KAAG,SAAO,0BAAwB,gBAAc,CAC7f,GAAG,CAAC,EAAI,OAAoB,EAAK,MAAM,CAAC,SAAS,+BAA+B,CAAC,CACjF,IAAM,EAAU,aAAa,IAAU,CAAC,EAAc,GAAkBA,GAAU,CAYyP,OAZxP,MAAc,CAAC,IAAM,EAAO,SAAS,cAAc,SAAS,CAAO,EAAU,8DAA8D,EAAO,IAAI,EAAU,EAAO,MAAM,GAAK,IAAM,MAAqB,CAChS,QAAQ,IAAI,kBAAkB,IAAY,CAAC,EAAiB,IAAI,EAAO,oBAAoB,EAAS,MAAsB,CAC1H,QAAQ,MAAM,yBAAyB,IAAY,EAEnD,OAFsD,EAAO,iBAAiB,OAAO,EAAiB,CAAC,EAAO,iBAAiB,QAAQ,EAAkB,CACzJ,SAAS,KAAK,YAAY,EAAO,KACvB,CAAC,EAAO,oBAAoB,OAAO,EAAiB,CAAC,EAAO,oBAAoB,QAAQ,EAAkB,GAAK,CAAC,EAAG,CAAC,CAAC,MAAc,CAAC,GAAG,CAAC,EAAc,OAChK,IAAM,EAAM,SAAS,iBAAiB,IAAI,CAC1C,IAAI,IAAI,EAAU,EAAE,EAAU,EAAM,OAAO,IAAa,IAAI,IAAI,EAAY,EAAE,EAAY,EAAkB,OAAO,IAAkB,EAAM,GAAW,KAAK,QAAQ,EAAkB,GAAa,CAAC,IAAI,EAAM,GAAW,KAAK,QAAQ,IAAI,GAAG,KAAQ,EAAuB,EAAM,GAAW,KAAK,GACjS,EAAM,GAAW,KAAK,EAAY,EAAM,GA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