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