document.addEventListener("DOMContentLoaded",(function(){"use strict";function e(){if(0===document.querySelectorAll('input[name="explore-explainer-type"]').length)return;const e=document.querySelector('input[name="explore-explainer-type"]:checked'),t=e&&"fullscreen"===e.value;["explore-top","explore-left"].forEach((function(e){const r=document.querySelector('input[name="'+e+'"]');if(!r)return;t?(r.removeAttribute("required"),r.classList.remove("orbem-studio-error")):r.setAttribute("required","");let o=r.closest("p");for(;o&&"H3"!==o.tagName;)o=o.previousElementSibling;if(o){const e=o.querySelector("sup");e&&(e.style.display=t?"none":"")}}))}e(),document.addEventListener("change",(function(t){t.target&&"explore-explainer-type"===t.target.name&&e()}));const t=document.querySelectorAll("#publish, .editor-post-publish-button, .editor-post-update-button");if(0<t.length){function i(e){if(e.disabled||null===e.offsetParent)return!1;const t=e.tagName.toLowerCase(),r=e.value;return"select"===t?!r||"none"===r:!("input"!==t&&"textarea"!==t||r&&0!==r&&""!==r&&"0"!==r)}function l(e){const t=document.querySelectorAll("[required]");let r=null,o=!1;return t&&(t.forEach((e=>{e.classList.remove("orbem-studio-error")})),t.forEach((e=>{const t=e;i(t)&&(t.classList.add("orbem-studio-error"),r||(r=t),o=!0)}))),!o||(e.preventDefault(),e.stopPropagation(),alert("There is one or more required fields that need attending to."),r&&(r.scrollIntoView({behavior:"smooth",block:"center"}),r.focus()),!1)}for(let u=0;u<t.length;u++)t[u].addEventListener("click",l)}if(!window.wp||!wp.data||!wp.data.dispatch)return;const r="orbem-required-fields";let o=!1;const n=e=>{if(e.disabled||null===e.offsetParent)return!1;const t=e.tagName.toLowerCase(),r=e.value;return"select"===t?!r||"none"===r:!("input"!==t&&"textarea"!==t||r&&0!==r&&""!==r&&"0"!==r)},s=()=>{const e=document.querySelectorAll("[required]");let t=!1;e.forEach((e=>{e.classList.remove("orbem-studio-error"),n(e)&&(e.classList.add("orbem-studio-error"),t=!0)}));const s=wp.data.dispatch("core/editor");t&&!o?(s.lockPostSaving(r),o=!0):!t&&o&&(s.unlockPostSaving(r),o=!1)};s(),wp.data.subscribe((()=>{setTimeout(s,0)})),document.addEventListener("click",(e=>{if(!e.target.closest(".editor-post-publish-button, .editor-post-update-button"))return;const t=document.querySelectorAll("[required]");let r=null,o=!1;t.forEach((e=>{e.classList.remove("orbem-studio-error"),n(e)&&(e.classList.add("orbem-studio-error"),r||(r=e),o=!0)})),o&&(e.preventDefault(),e.stopPropagation(),alert("There is one or more required fields that need attending to."),r&&(r.scrollIntoView({behavior:"smooth",block:"center"}),r.focus()))}))}));