(()=>{"use strict";var e={141:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.spin_button=t.flash=t.get_json=t.send_json=void 0,t.send_json=function(e,t,n){let s=new XMLHttpRequest;s.onload=()=>{200==s.status?n(JSON.parse(s.responseText)):console.error(`Failed POST to '${e}' with status ${s.status}.`)},s.onerror=()=>{console.error(`Failed to POST to '${e}'.`)},s.open("POST",e,!0),s.setRequestHeader("Content-Type","application/json;charset=UTF-8"),s.send(JSON.stringify(t))},t.get_json=function(e,t){let n=new XMLHttpRequest;n.onload=()=>{200==n.status?t(JSON.parse(n.responseText)):console.error(`Failed to load json '${e}' with status ${n.status}`)},n.onerror=()=>{console.error(`Failed to load json '${e}'`)},n.open("GET",e,!0),n.send()},t.flash=function(e,t){let n=document.getElementById("flashes"),s=document.createElement("div");n.appendChild(s),s.innerHTML=`<div class="alert alert-${t} alert-dismissible fade show mt-3" role="alert">\n            ${e}\n            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>\n         </div>`},t.spin_button=function(e){e.disabled=!0,e.innerText="";let t=document.createElement("div");e.appendChild(t),t.innerHTML='<div>\n            <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>\n            Loading...\n        </div>'}}},t={};function n(s){var o=t[s];if(void 0!==o)return o.exports;var l=t[s]={exports:{}};return e[s](l,l.exports,n),l.exports}(()=>{const e=n(141);function t(e,t){e.getElementsByClassName("scene-check-box")[0].checked=t;let n=e.getElementsByClassName("section-check-box");for(let e of n)e.checked=t}function s(e){let n=e.getElementsByClassName("section-check-box"),s=n[0].checked;for(let e=1;e<n.length;++e)if(n[e].checked!=s)return;t(e,s)}function o(){let e=document.getElementsByClassName("section-check-box"),t=document.getElementById("confirm-button");for(let n of e)if(n.checked)return void(t.disabled=!1);t.disabled=!0}document.body.onload=()=>{!function(){let e=document.getElementsByClassName("scene-select");for(let n of e){let e=n.getElementsByClassName("scene-check-box")[0];e.addEventListener("click",(()=>{t(n,e.checked),o()}));let l=n.getElementsByClassName("section-select");for(let e of l)e.getElementsByClassName("section-check-box")[0].addEventListener("click",(()=>{s(n),o()}))}}(),function(){let t=document.getElementById("confirm-button"),n=t.dataset.target,s=t.dataset.project_name,o=t.dataset.success_url;t.addEventListener("click",(()=>{let l=function(){let t=function(){let t=document.getElementsByClassName("scene-priority"),n=[],s=Array(t.length).fill(!1);for(let o=0;o<t.length;++o){let l=parseInt(t[o].value);if(s[l])return(0,e.flash)(`The priority ${l} can't be used twice.`,"danger"),[];s[l]=!0,n.push(l)}return n}();if(!t.length)return[];let n=document.getElementsByClassName("scene-select"),s=[];for(let e=0;e<n.length;++e)s.push([]);for(let e=0;e<n.length;++e){let o=n[e].getElementsByClassName("section-check-box");for(let n of o)n.checked&&s[t[e]].push({scene_id:e,section_id:parseInt(n.dataset.section_id)})}let o=[];for(let e=0;e<n.length;++e)for(let t of s[e])o.push(t);let l=-1,r="Used scene order: ";for(let e of o)e.scene_id!=l&&(r+=`${e.scene_id} `,l=e.scene_id);return console.log(r),o}();if(window.scrollTo(0,0),l.length){(0,e.flash)("The project is being populated, this might take a few minutes. Open the terminal for more info.","info"),(0,e.spin_button)(t);let r={name:s,sections:l};(0,e.send_json)(n,r,(t=>{t.success?window.location.href=o:(0,e.flash)(`The editor unexpectedly failed to populate the project '${s}'. For more information see the console log. Please consider opening an Issue on GitHub if this problem persists.`,"danger")}))}}))}(),o()}})()})();