const channel=new BroadcastChannel("DOBARE-IFRAME");let contentLoadedFlag=!1,lastStylesheetHref=null;const loadStylesheet=e=>{if(e===lastStylesheetHref)return;lastStylesheetHref=e,document.querySelectorAll('link[href$="./styles/mobile-style.css"], link[href$="./styles/desktop-style.css"]').forEach(e=>e.parentNode.removeChild(e));let t=document.createElement("link");t.rel="stylesheet",t.href=e,t.media="print",t.addEventListener("load",function(){t.media="all",contentLoadedFlag||(loadContent(),contentLoadedFlag=!0);const e=new Event("styleSheetLoaded");document.dispatchEvent(e)}),t.addEventListener("error",function(){contentLoadedFlag||(loadContent(),contentLoadedFlag=!0)}),document.head.appendChild(t)},loadContent=()=>{const e=document.getElementById("dobare-lead-magnet-wrraper"),t=document.getElementById("dobare-lead-magnet-template").content.cloneNode(!0);e.appendChild(t),e.classList.remove("dobare-loader");const n=e.clientHeight;channel.postMessage({key:"SET_DOBARE_IFRAME_HEIGHT",height:n});const l=new Event("contentLoaded");document.dispatchEvent(l)};channel.onmessage=function(e){if("SEND_WIDTH_TO_DOBARE_IFRAME"===e.data.key){const t=e.data.width>=780?"./styles/desktop-style.css":"./styles/mobile-style.css";loadStylesheet(t)}};