(()=>{var e={141:()=>{}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var d=t[r]={exports:{}};return e[r](d,d.exports,a),d.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";a.r(r);a(141);document.addEventListener("DOMContentLoaded",(function(){({init:function(){this.form=document.getElementById("ddfw-setup-wizard-form"),this.content=document.querySelector(".ddfw-setup-wizard-content"),this.progressBar=document.querySelector(".ddfw-setup-wizard-progress-bar"),this.stepCounter=document.querySelector(".ddfw-current-step-number"),this.params="undefined"!=typeof ddfw_wizard_params?ddfw_wizard_params:{},this.totalSteps=this.params.steps?this.params.steps.length:0,this.bindEvents()},bindEvents:function(){var e=this;document.addEventListener("click",(function(t){var a=t.target.closest(".ddfw-setup-wizard-next");a&&e.handleNext(t,a);var r=t.target.closest(".ddfw-setup-wizard-prev");r&&e.handlePrev(t,r)})),this.form&&this.form.addEventListener("submit",this.handleSubmit.bind(this))},handleNext:function(e,t){e.preventDefault();var a=t.dataset.next,r=t.closest(".ddfw-setup-wizard-step-content"),n=r?r.dataset.step:null;n&&a&&this.saveStep(n,a)},handlePrev:function(e,t){e.preventDefault();var a=t.dataset.prev;a&&this.showStep(a)},handleSubmit:function(e){e.preventDefault();var t=document.querySelector(".ddfw-setup-wizard-step-content:not(.ddfw-hide)");if(t){var a=t.dataset.step;this.saveStep(a,"finish")}},saveStep:function(e,t){var a=this;this.showLoader();var r=new URLSearchParams;if(r.append("action","ddfw_save_wizard_step"),r.append("nonce",this.params.nonce),r.append("plugin_slug",this.params.plugin_slug),r.append("step_id",e),this.form){var n=0,d=document.querySelector('.ddfw-setup-wizard-step-content[data-step="'.concat(e,'"]')),o=new Set;new FormData(this.form).forEach((function(e,t){r.append("form_data[".concat(n,"][name]"),t),r.append("form_data[".concat(n,"][value]"),e),o.add(t),n++})),d&&d.querySelectorAll('input[type="checkbox"]').forEach((function(e){e.checked||!e.name||o.has(e.name)||(r.append("form_data[".concat(n,"][name]"),e.name),r.append("form_data[".concat(n,"][value]"),""),n++)}))}fetch(this.params.ajax_url,{method:"POST",body:r,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8",Accept:"application/json, text/javascript, */*; q=0.01"}}).then((function(e){return e.json()})).then((function(e){a.hideLoader(),e.success?"finish"===t?window.location.href=a.params.redirect:a.showStep(t):alert(e.data&&e.data.message||"Error saving step.")})).catch((function(e){a.hideLoader(),alert("An error occurred.")}))},showStep:function(e){document.querySelectorAll(".ddfw-setup-wizard-step-content").forEach((function(e){e.classList.add("ddfw-hide")}));var t=document.querySelector('.ddfw-setup-wizard-step-content[data-step="'.concat(e,'"]'));if(t&&t.classList.remove("ddfw-hide"),this.params.steps){var a=this.params.steps.indexOf(e)+1,r=a/this.totalSteps*100;this.progressBar&&(this.progressBar.style.width=r+"%"),this.stepCounter&&(this.stepCounter.textContent=a)}if(window.history.pushState){var n=new URL(window.location.href);n.searchParams.set("step",e),window.history.pushState({},"",n)}var d=document.querySelector(".ddfw-setup-wizard-wrap");if(d){var o=d.getBoundingClientRect().top+window.scrollY-40;window.scrollTo({top:o,behavior:"smooth"})}},showLoader:function(){if(!document.querySelector(".ddfw-wizard-loader-overlay")&&this.content){var e=document.createElement("div");e.className="ddfw-wizard-loader-overlay",e.innerHTML='<div class="ddfw-wizard-loader"></div>',this.content.appendChild(e)}},hideLoader:function(){var e=document.querySelector(".ddfw-wizard-loader-overlay");e&&e.remove()}}).init()}))})();for(var n in r)this[n]=r[n];r.__esModule&&Object.defineProperty(this,"__esModule",{value:!0})})();