window.KNOWN_USER_CHECK=void 0;const downloadState="downloading",thanksState="thanks",errorState="error",emailSentState="email-sent",sendingState="sending",submitState="submit";function activeFormElement(e,t){const n=document.getElementById(`${e}-button-${submitState}`),o=document.getElementById(`${e}-button-${sendingState}`),a=document.getElementById(`${e}-button-${emailSentState}`),i=document.getElementById(`${e}-button-${errorState}`),l=document.getElementById(`${e}-button-${thanksState}`),s=document.getElementById(`${e}-button-${downloadState}`);let d;[n,o,a,i,l,s].forEach((e=>{e.style.display="none",e.id.endsWith(t)&&(d=e)})),s.style.setProperty("display","none","important"),d.style.display="block"}function leedEnableFormButton(e){const t=e.currentTarget.id;document.getElementById(`${t}-button`).disabled=!1}function emailChangeListener(){activeFormElement(this.form.id,submitState)}async function downloadFile(e,t){await fetch(e).then((e=>e.blob())).then((e=>{const n=document.createElement("a");n.href=URL.createObjectURL(e),n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)})).catch((e=>{console.error("Error downloading file:",e)}))}async function leedFormSubmit(e){e.preventDefault();const t=e.srcElement.id,n=document.getElementById(`${t}-button`);n.disabled=!0,activeFormElement(t,sendingState);const o=new FormData(e.srcElement),a=Object.fromEntries(o.entries());Object.assign(a,{knownUser:window.KNOWN_USER_CHECK?.known||!1,formId:t,pid:pid,pt:pt,u:location.href});let i=await fetch("/api/clerk",{method:"POST",body:JSON.stringify(a),headers:{"content-type":"application/json"}});const l=e.srcElement.dataset.successcallback,s=e.srcElement.dataset.failurecallback;if(204===i.status)activeFormElement(t,thanksState);else if(200===i.status){if(i.body){const e=await i.json();e&&e.url&&e.filename?(activeFormElement(t,downloadState),await downloadFile(e.url,e.filename),activeFormElement(t,thanksState)):e&&e.message&&"sent"===e.message?activeFormElement(t,emailSentState):activeFormElement(t,thanksState)}else activeFormElement(t,thanksState);l&&window[l]&&"function"==typeof window[l]&&(console.log("Success callback..."),window[l].apply(null,[t]))}else 422===i.status?(activeFormElement(t,errorState),s&&window[s]&&"function"==typeof window[s]&&(console.log("Turnstile failure..."),window[s].apply(null,[t])),n.disabled=!1):(activeFormElement(t,errorState),s&&window[s]&&"function"==typeof window[s]&&(console.log("Failure callback..."),window[s].apply(null,[t])),n.disabled=!1)}async function leedAutofill(e){if(!window.KNOWN_USER_CHECK)try{const e=await fetch("/api/poirot");window.KNOWN_USER_CHECK=await e.json()}catch(e){window.KNOWN_USER_CHECK={known:!1}}if(window?.KNOWN_USER_CHECK?.known){const n=window?.KNOWN_USER_CHECK,o=document.getElementById(e);if(null!=n.details.source&&"form"!==n.details.source){const e=o.querySelectorAll("div.known-valid-hideable");for(var t=0;t<e.length;t++){const n=e[t],o=n.querySelectorAll("*");Array.from(o).forEach((e=>{e.hasAttribute("required")&&(e.required=!1)})),n.style.display="none"}}const a=Object.keys(n.details).reduce(((e,t)=>(e[t.toLowerCase()]=n.details[t],e)),{}),i=document.getElementById(`${e}-wb`);let l=i.innerHTML;const s=o.elements;for(t=0;t<s.length;t++){const e=s[t],o=e.name;if(o){"form"===n.details.source&&a[o]&&(e.value=a[o]);const t="{{"+o+"}}",i=a[o]?a[o]:"";l=l.replace(t,i)}}""!==l&&(i.innerHTML=l,i.style.display="block")}}function setupLeedForms(){for(var e=document.getElementsByClassName("LeedForm"),t=0;t<e.length;t++){const n=e.item(t);n.onsubmit=leedFormSubmit,n.oninput=leedEnableFormButton;let o=document.getElementById(`${n.id}-email`);o&&o.addEventListener("input",emailChangeListener,!1)}}function setupVideoTrackers(){for(var e=document.getElementsByTagName("iframe"),t=0;t<e.length;t++){const n=e.item(t);n.src.includes("cloudflarestream.com")&&window.VideoTimer(n,window.plausible)}}function setupTagObservers(){const e=["p","ul","ol","blockquote","pre","img","iframe"].map((e=>`body ${e}[data-id]`)).join(", "),t=document.querySelectorAll(e),n=Array.from(t).filter((e=>!e.closest("header")&&!e.closest("footer")));window.ContentObserver(n)}function submitLeadUnsubscribe(){const e=document.getElementById("unsubscribeForm");let t=`?reason=${e.elements.reason.value}`;e.elements.donotcontact.checked&&(t+="&donotcontact=true");var n=window.location.pathname.replace(".unsubscribe",".out")+t;return window.location.href=n,!1}window.addEventListener("load",setupLeedForms),window.addEventListener("load",setupVideoTrackers),window.addEventListener("load",setupTagObservers);const LEED_VIDEO_PLAYERS=new Map;function getLeedVideoPlayer(e){const t=LEED_VIDEO_PLAYERS.get(e);if(t)return t;const n=document.querySelector(`iframe[data-assetid="${e}"]`),o=Stream(n);return LEED_VIDEO_PLAYERS.set(e,o),o}async function leedPopupVideoPlay(e){getLeedVideoPlayer(e).play().catch((e=>console.error("Error playing video:",e)))}function leedPopupVideoPause(e){const t=getLeedVideoPlayer(e);t&&t.pause()}async function fetchStubs(e){const t=`/api/${e}/${pid}`,n=await fetch(t);return 200===n.status?await n.text():null}async function recommendations(e){const t=await fetchStubs("abby");null!=t&&(document.getElementById(e).innerHTML+=t)}async function callToAction(e){const t=await fetchStubs("sway");null!=t&&(document.getElementById(e).innerHTML+=t)}