(()=>{"use strict";const c=(t,e)=>{var n=wp.i18n["__"],{data:t={}}=t||{},{message:t=e||n("Something Went Wrong!","tutor")}=t;return t};jQuery(document).ready(function(r){wp.i18n.__;r(document).on("click",".btn-csv-download",function(t){t.preventDefault();var e=r(this);r.ajax({url:ajaxurl,type:"POST",data:{quiz_id:r(this).data("id"),action:"quiz_export_data"},beforeSend:function(){e.addClass("is-loading")},success:function(t){var e,n,a;t.success?(e="",t.data.output_quiz_data.forEach(function(t){t=t.join(",");e+=t+"\r\n"}),n=new Blob([e],{type:"text/csv"}),n=window.webkitURL.createObjectURL(n),(a=document.createElement("a")).setAttribute("href",n),a.setAttribute("download","tutor-quiz-"+t.data.title+".csv"),document.body.appendChild(a),a.click()):tutor_toast("Error!",c(t),"error")},complete:function(){e.removeClass("is-loading")}})}),r(document).on("change",'#tutor-course-content-builder-root input[name="csv_file"]',function(t){var e,n,a=r(this).prop("files"),o=r(this),i=r(this).parent().find("button");a[0]?0<a[0].size?(e=tutor_get_nonce_data(!0),(n=new FormData).append("action","quiz_import_data"),n.append("csv_file",a[0]),n.append("topic_id",r(this).parent().find("input[name='csv_file']").data("topic")),n.append(e.key,e.value),r.ajax({url:ajaxurl,type:"POST",data:n,cache:!1,contentType:!1,processData:!1,beforeSend:function(){i.addClass("is-loading")},success:function(t){t.success?(o.val(""),o.closest(".tutor-topics-wrap").find(".tutor-lessons").append(t.data.html)):tutor_toast("Error",c(t),"error")},complete:function(){i.removeClass("is-loading")}})):alert("File is Empty."):alert("No File Selected."),r(this).val("")}),r(document).on("click",".tutor-import-quiz-button button",function(t){t.preventDefault(),r(this).parent().find(".tutor-csv-file").click()})})})();