document.addEventListener("DOMContentLoaded",(function(){"use strict";const e=document.querySelector('.tutorial-step[data-step="3"]'),t=document.querySelector('.tutorial-step[data-step="0"]');if(t&&!0===t.classList.contains("engage")){const e=t.querySelector("#generate-starter-game"),n=t.querySelector("#start-manual-setup");n&&n.addEventListener("click",(function(){a("manual")})),e&&e.addEventListener("click",(function(){a("generate")}))}const n=document.querySelector("#generate-game-page");if(n&&n.addEventListener("click",(function(){a("page")})),e&&!0===e.classList.contains("engage")){const e=document.querySelector(".form-table tbody tr"),t=document.querySelector(".form-table tbody tr:nth-of-type(2)"),n=document.querySelector(".form-table tbody tr:nth-of-type(3)"),a=document.querySelector('.tutorial-step[data-step="4"]'),s=document.querySelector('.tutorial-step[data-step="5"]'),r=document.querySelector('.tutorial-step[data-step="6"]');if(e){e.classList.add("engage");const c=e.querySelector("select");if(c){const n=c.value;console.log(n),""===n?c.addEventListener("change",(()=>{o(e,a,t)})):o(e,a,t)}t&&t.addEventListener("change",(()=>{t.classList.remove("engage"),n.classList.add("engage"),n.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),s&&(a.classList.remove("engage"),s.classList.add("engage"))})),n&&n.addEventListener("change",(()=>{n.classList.remove("engage"),scrollTo(0,8e4),r&&(s.classList.remove("engage"),r.classList.add("engage"))}))}}function a(e){const n=`${OrbemOrder.siteRESTURL}/choose-setup-type/`,a={type:e};if("generate"===e){const e=document.querySelector(".game-generating"),t=document.querySelector(".game-generating-load"),n=document.querySelector(".generate-title"),a=document.querySelector(".choose-setup-type-buttons");e&&(e.classList.add("engage"),t.classList.add("engage"),n.style.display="none",a.style.display="none")}fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":OrbemOrder.orbemNonce},body:JSON.stringify(a)}).then((n=>{if(!n.ok)throw new Error("Network response was not ok "+n.statusText);if("manual"===e&&t.classList.remove("engage"),"generate"===e){const e=document.querySelector(".game-generating-load"),t=document.querySelector(".game-generating-finished");t&&e&&(e.classList.remove("engage"),t.classList.add("engage"),setTimeout((()=>{window.location.reload()}),2e3))}if("page"===e)return n.json()})).then((e=>{window.location.href=e.data}))}function o(t,n,a){t.classList.remove("engage"),a.classList.add("engage"),a.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),n&&(e.classList.remove("engage"),n.classList.add("engage"))}}));