!function(e){"use strict";!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();class t{constructor(e){var o;this.dialogElement=e,t.isAlreadyRegistered(e)||("BODY"!==this.dialogElement.parentElement.tagName&&document.body.appendChild(this.dialogElement),this.updateFocusableElements(),this.mutationObserver=new MutationObserver((()=>{this.updateFocusableElements()})),this.mutationObserver.observe(e,{subtree:!0,childList:!0,attributes:!0}),e.addEventListener("click",(e=>{void 0!==e.composedPath().find((e=>{var t;return e&&(null===(t=e.classList)||void 0===t?void 0:t.contains("dialog-close"))}))&&this.close()})),e.addEventListener("keydown",(e=>{var t;if("Esc"!==e.key&&"Escape"!==e.key||this.close(),"Tab"===e.key){e.preventDefault(),this.focusableElements&&0!==this.focusableElements.length||this.updateFocusableElements();const o=this.focusableElements,n=null!==(t=o.findIndex((e=>e===document.activeElement)))&&void 0!==t?t:0;e.shiftKey?0===n?o[o.length-1].focus():o[n-1].focus():n===o.length-1?o[0].focus():o[n+1].focus()}})),""!==(null===(o=this.dialogElement.id)||void 0===o?void 0:o.trim())&&document.querySelectorAll(`button[aria-controls="${this.dialogElement.id}"], a[aria-controls="${this.dialogElement.id}"]`).forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),this.open()}))})),this.handleDatePickers(),this.dialogElement.dataset.registeredDialog="true")}updateFocusableElements(){this.focusableElements=Array.from(this.dialogElement.querySelectorAll('a:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), input[type="button"]:not([disabled]), select:not([disabled])')).filter((e=>null!==e.offsetParent&&(e.childNodes.length>0||"A"!==e.tagName)))}handleDatePickers(){e(this.dialogElement).on("ab.datepicker.opened",(e=>{const t=e.target,o=this.dialogElement.querySelector(`#${t.getAttribute("aria-controls")}`);this.dialogElement.appendChild(t);const n=o.getBoundingClientRect(),i=this.dialogElement.getBoundingClientRect();if(t.style.left=n.left-i.left+"px",t.classList.contains("above")){const e=n.top-i.top-t.clientHeight,o=Math.max(-i.top,e);t.style.top=`${o}px`}else{const e=window.innerHeight-i.top-t.clientHeight,o=n.bottom-i.top,a=Math.min(e,o);t.style.top=`${a}px`}}))}open(){this.dialogElement.hasAttribute("open")||this.dialogElement.showModal()}close(){this.dialogElement.close()}delete(){this.mutationObserver.disconnect(),this.dialogElement.remove()}static isAlreadyRegistered(e){var t;return"true"===(null===(t=null==e?void 0:e.dataset)||void 0===t?void 0:t.registeredDialog)}static registerAllDialogsInDOM(){document.querySelectorAll("dialog").forEach((e=>{t.isAlreadyRegistered(e)||new t(e)}))}static updateDialogTriggers(){document.querySelectorAll("button[aria-controls], a[aria-controls]").forEach((e=>{const t=e.getAttribute("aria-controls"),o=document.querySelector(`dialog#${t}`);o&&e.addEventListener("click",(()=>{o.showModal()}))}))}static blankDialog(e){var t,o
;const n=`\n      <dialog${e.dialogId?` id="${e.dialogId}"`:""}${e.dialogClasses?` class="${e.dialogClasses}"`:""}>\n        <div class="dialog-content">\n          <div class="dialog-header">\n            <h2 class="dialog-title">${null!==(t=null==e?void 0:e.title)&&void 0!==t?t:""}</h2>\n            ${(null==e?void 0:e.hideCloseButtonInHeader)?"":'\n    <div class="dialog-header-buttons">\n        <button type="button" class="dialog-close" title="Close"><i class="far fa-times fa-2x" aria-hidden="true"></i></button>\n    </div>'}\n          </div>\n          <div class="dialog-body">\n            ${null!==(o=null==e?void 0:e.content)&&void 0!==o?o:""}\n          </div>\n          <div class="dialog-footer">\n            ${(null==e?void 0:e.hideCloseButtonInFooter)?"":'<button type="button" class="btn btn-default dialog-close">Cancel</button>'}\n          </div>\n        </div>\n      </dialog>\n    `;return(new DOMParser).parseFromString(n,"text/html").querySelector("dialog")}}const o=()=>document.getElementById("email-owner-link"),n=()=>document.getElementById("email-page-owner"),i=new DOMParser;function a(){const e=n();e.classList.contains("hidden")?(e.classList.remove("hidden"),e.scrollIntoView(!0)):e.classList.add("hidden")}function s(e){e.querySelector("#message-submit").addEventListener("click",(t=>{t.preventDefault(),async function(){const e=o().getAttribute("href"),t=fetch(e,{method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(new FormData(n().querySelector("form")))});n().innerHTML='<i class="fas fa-spinner-third fa-spin" aria-hidden="true"></i> Sending...';const a=await t;return a.ok?a.text().then((e=>i.parseFromString(e,"text/html"))).catch((e=>Promise.reject(`Could not parse response after submitting email page contact form: ${e}`))):Promise.reject("Could not submit email page contact form")}().then((t=>{var o;if("Success"===(null===(o=t.body.querySelector("h1"))||void 0===o?void 0:o.innerText))e.innerHTML='<i class="fas fa-check" aria-hidden="true"></i> Sent';else{e.innerHTML="",e.appendChild(t.body.querySelector("div"));const o=e.querySelector("#emailPageOwnerAntiSpam");o&&window.grecaptcha.render(o,o.dataset.sitekey),s(e)}}))})),e.querySelector("#message-cancel").addEventListener("click",(e=>{e.preventDefault(),a()}))}async function l(e){const t=await async function(){const e=o().getAttribute("href"),t=await fetch(e);return t.ok?t.text().then((e=>i.parseFromString(e,"text/html"))).catch((e=>Promise.reject(`Could not parse page contact email form: ${e}`))):Promise.reject("Could not get page contact email form")}();e.appendChild(t.body.querySelector("div"));const n=document.createElement("script");n.async=!0,n.src="https://www.google.com/recaptcha/api.js",document.querySelector("head").appendChild(n),s(e)}const c={x:'\n    <svg class="fa-x" viewBox="0 0 1200 1227" aria-hidden="true">\n    <path id="p" d="M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z" fill="currentColor"/>\n    </svg>\n    '.trim(),"x-square":'\n    <svg class="fa-x-square" viewBox="0 0 512 512" aria-hidden="true">\n    <path id="p" fill="currentColor" d="M 64,0 A 64,64 0 0 0 0,64 v 384 a 64,64 0 0 0 64,64 h 384 a 64,64 0 0 0 64,-64 V 64 A 64,64 0 0 0 448,0 Z m 9.427734,77.443359 H 180.96875 L 274.20703,213.13867 390.94531,77.443359 h 31.85938 L 288.35938,233.72461 h -0.008 L 434.57422,446.52539 H 327.03516 L 228.56836,303.22461 105.28906,446.52539 H 73.427734 L 214.42383,282.64062 Z m 43.341796,23.984371 113.66602,162.58789 14.28515,20.43165 v 0.008 l 97.30274,139.17578 h 48.93554 L 271.7207,253.07422 257.43555,232.64062 165.70508,101.42773 Z"></path>\n    </svg>\n    '.trim()
},r=["fa-stack-1x","fa-stack-2x","fa-inverse","fa-fw","fa-2x","fa-3x","fa-4x","fa-5x","fa-flip-vertical","fa-flip-horizontal","fa-rotate-90","fa-rotate-180","fa-rotate-270","fa"],d={keepOriginal:!1};function u(e,t,o,n){o.querySelectorAll(t).forEach((t=>{if(n.keepOriginal&&t.dataset.xCloned)return;const o=function(e){const t=document.createElement("div");return t.innerHTML=c[e],t.querySelector("svg")}(e).cloneNode(!0);r.forEach((e=>{t.classList.contains(e)&&o.classList.add(e)})),n.keepOriginal?(t.dataset.xCloned="true",t.classList.add("hidden"),t.insertAdjacentElement("afterend",o)):t.replaceWith(o)}))}let f=null;function h(e){e.querySelectorAll(".checkbox").forEach((e=>{e.querySelector('input[type="checkbox"]').checked?e.classList.add("selected"):e.classList.remove("selected")}))}function m(e){if("true"!==e.dataset.initialised){e.querySelectorAll('input[type="checkbox"]').forEach((t=>{const o=t.closest(".checkbox"),n=o.classList.contains("disabled")?"fas fa-fw fa-check fa-lg":"far fa-fw fa-check-square fa-2x";t.insertAdjacentHTML("afterend",`<i class="${n}" aria-hidden="true"></i><i class="fal fa-fw fa-square fa-2x" aria-hidden="true"></i>`),t.addEventListener("change",(()=>{h(e)})),t.addEventListener("focus",(()=>{o.classList.add("focused")})),t.addEventListener("blur",(()=>{o.classList.remove("focused")}))})),h(e),function(e){null===f&&(f={functional:e.querySelector("input#cookie-modal-functional-cookies").checked,advertising:e.querySelector("input#cookie-modal-advertising-cookies").checked,performance:e.querySelector("input#cookie-modal-performance-cookies").checked})}(e),e.dataset.initialised="true"}}function p(){let e=document.querySelector("#cookie-modal");if(e){const t=e.querySelector("form");!function(e){e.querySelector("input#cookie-modal-functional-cookies").checked=f.functional,e.querySelector("input#cookie-modal-advertising-cookies").checked=f.advertising,e.querySelector("input#cookie-modal-performance-cookies").checked=f.performance}(t),m(t),h(t),e.showModal()}else{const o=encodeURIComponent(window.location.pathname+window.location.search);fetch(`/sitebuilder2/user/cookiepreference/modal.htm?returnTo=${o}`).then((o=>{o.text().then((o=>{document.querySelector(".cookie-preference-modal-container").innerHTML=o,e=document.querySelector("#cookie-modal"),new t(e);const n=e.querySelector("form");m(n),e.querySelector(".cookie-preference-submit").addEventListener("click",(()=>{n.submit()})),e.showModal()}))}))}}window.SiteBuilderDialog=t,window.addEventListener("DOMContentLoaded",(()=>{t.registerAllDialogsInDOM(),function(){const e=n();let t=!1;const i=o();null==i||i.addEventListener("click",(async o=>{o.preventDefault(),t||(await l(e),t=!0),a()}))}(),function(e,t){const o=Object.assign({},d,t);u("x","i.fa-twitter,em.fa-twitter",e,o),u("x-square","i.fa-twitter-square,em.fa-twitter-square",e,o)}(document.body),function(){document.querySelectorAll(".cookie-banner-modal-button, #cookie-preference-link").forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),p()}))}));const e=document.querySelector("#cookiePreferenceForm");if(e){const t=e.querySelector(".btn-accept-all");null==t||t.addEventListener("mouseover",(()=>{!function(e){e.querySelectorAll(".checkbox:not(.disabled)").forEach((e=>{e.classList.add("ghostTick")}))}(e)})),null==t||t.addEventListener("mouseout",(()=>{!function(e){e.querySelectorAll(".checkbox:not(.disabled)").forEach((e=>{e.classList.remove("ghostTick")}))}(e)})),m(e)}}()}))}(jQuery);//# sourceMappingURL=sitebuilder.js.map
