(()=>{"use strict";var e={};// The module cache
var r={};// The require function
function t(o){// Check if module is in cache
var n=r[o];if(n!==undefined){return n.exports}// Create a new module (and put it into the cache)
var a=r[o]={exports:{}};// Execute the module function
e[o](a,a.exports,t);// Return the exports of the module
return a.exports}// webpack/runtime/rspack_version
(()=>{t.rv=()=>"1.6.5"})();// webpack/runtime/rspack_unique_id
(()=>{t.ruid="bundler=rspack@1.6.5"})();// CONCATENATED MODULE: ./node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_async_to_generator.js
function o(e,r,t,o,n,a,i){try{var u=e[a](i);var s=u.value}catch(e){t(e);return}if(u.done)r(s);else Promise.resolve(s).then(o,n)}function n(e){return function(){var r=this,t=arguments;return new Promise(function(n,a){var i=e.apply(r,t);function u(e){o(i,n,a,u,s,"next",e)}function s(e){o(i,n,a,u,s,"throw",e)}u(undefined)})}};// CONCATENATED MODULE: ./assets/src/js/admin-dashboard/tutor-setup.js
// Tutor onboarding
document.addEventListener("DOMContentLoaded",()=>{var e;var{__}=wp.i18n;var r=document.querySelector("#tutor-onboard-wrapper");if(!r){return}var t=e=>{r.querySelectorAll(".tutor-onboard-screen").forEach(e=>{e.classList.remove("is-active");e.classList.remove("is-fading-out")});var t=r.querySelector('.tutor-onboard-screen[data-screen="'.concat(e,'"]'));if(t){t.classList.add("is-active")}};var o=()=>{var e=r.querySelector(".tutor-onboard-screen-loading");if(!(e===null||e===void 0?void 0:e.classList.contains("is-active"))){return Promise.resolve()}e.classList.add("is-fading-out");return new Promise(e=>{setTimeout(e,300)})};var a=e=>new Promise(r=>{setTimeout(r,e)});var i=()=>{r.querySelectorAll(".tutor-onboard-choice-wrapper").forEach(e=>{e.querySelectorAll(".tutor-onboard-choice-card").forEach(e=>{e.classList.remove("is-selected")});e.querySelectorAll(".tutor-onboard-choice-input:checked").forEach(e=>{var r=e.closest(".tutor-onboard-choice-card");if(r){r.classList.add("is-selected")}})})};var u=r.querySelector(".tutor-onboard-loading-text");var s=(u===null||u===void 0?void 0:u.dataset.text)||(u===null||u===void 0?void 0:(e=u.textContent)===null||e===void 0?void 0:e.trim())||"";var c=null;var d=false;var l=false;var v=e=>{if(!l){return undefined}var r="F5"===e.key||(e.metaKey||e.ctrlKey)&&"r"===e.key.toLowerCase();if(!r){return undefined}e.preventDefault();e.stopPropagation();return false};var f=e=>{if(e){document.addEventListener("keydown",v,true);return}document.removeEventListener("keydown",v,true)};var m=()=>{d=false;if(c){clearTimeout(c);c=null}if(u){u.textContent=s}};var _=()=>{if(!u||!s){return}var e=0;d=true;var r=()=>{if(!u||!d){return}u.textContent="".concat(s).concat(".".repeat(e));e=(e+1)%4;c=setTimeout(r,350)};r()};var p=()=>{if(!u||!s){return Promise.resolve()}m();var e=0;u.textContent="";return new Promise(r=>{var t=()=>{if(!u){r();return}if(e<s.length){e+=1;u.textContent=s.slice(0,e);c=setTimeout(t,35);return}c=null;_();r()};t()})};r.addEventListener("click",e=>{var r=e.target.closest(".tutor-onboard-next-screen");if(!r){return}var{target:o}=r.dataset;if(o){t(o)}});r.addEventListener("change",e=>{if(e.target.matches(".tutor-onboard-choice-input")){i()}});i();// Onboarding setup form submit
var b=r.querySelector(".tutor-onboard-setup-form");if(!b){return}b.addEventListener("submit",e=>n(function*(){e.preventDefault();if(l){return}var r=new FormData(b);r.append(_tutorobject.nonce_key,_tutorobject._tutor_nonce);var n=b.querySelector(".tutor-onboard-submit-btn");var i=(n===null||n===void 0?void 0:n.dataset.screen)||__("Loading...","tutor");l=true;f(true);if(n){n.disabled=true}t(i);var u=p();try{if(r.get("tutor_onboard_load_sample_course")){var s=yield y();if(!s){tutor_toast(__("Sample course import failed.","tutor"),"","error")}}var c=yield fetch(_tutorobject.ajaxurl,{method:"POST",body:r});if(!c.ok){throw new Error(__("Onboarding setup request failed.","tutor"))}}catch(e){yield u;tutor_toast((e===null||e===void 0?void 0:e.message)||__("Something went wrong!","tutor"),"","error");yield a(1e3)}finally{l=false;if(n){n.disabled=false}yield u;yield o();f(false);location.href=_tutorOnboardObject.tutor_welcome_page}})());var y=()=>n(function*(){// import sample courses
    var e=new FormData;e.append("action","tutor_import_sample_courses");e.append(_tutorobject.nonce_key,_tutorobject._tutor_nonce);var r=yield fetch(_tutorobject.ajaxurl,{method:"POST",body:e,credentials:"same-origin"});if(r.ok){return true}else{return false}})()})})();