((t,i,a,o)=>{"use strict";const e=()=>t.loadJs(t.url+"js/admin/notification",!!i.TF_Notification);i.tfOn("load",(()=>{const n=a.createElement("a");n.className="page-title-action",n.href="#",n.tfOn("click",(a=>{a.preventDefault(),e();const n=document.createElement("input");n.type="file",n.accept=".zip,.txt",n.tfOn("change",(async a=>{await e(),TF_Notification.show("info",o.start),a.currentTarget.remove();try{const e=a.currentTarget.files[0],n=(a,e)=>{t.fetch({action:"tb_bulk_import",_ajax_nonce:o.nonce,data:a,gs_data:e||""}).then((t=>{if(!t.success)throw Error(o.error);i.location.reload()}))};if("text/plain"===e.type){(new FileReader).tfOn("loadend",(function(t){try{this.readyState===FileReader.DONE&&n(t.target.result)}catch(t){}}),{passive:!0,once:!0}).readAsText(e)}else{if("application/x-zip-compressed"!==e.type&&"application/zip"!==e.type)throw Error(o.invalid);{await(()=>t.loadJs("https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js",!!i.JSZip,!1))();const a=new JSZip,c=await a.loadAsync(e),r=c.files;if(!r)throw Error(o.invalid);if(!r["export_file.txt"])throw Error(o.invalid);{const t=await c.file("export_file.txt").async("text"),i=r["builder_gs_data_export.txt"]?await c.file("builder_gs_data_export.txt").async("text"):null;n(t,i)}}}}catch(a){TF_Notification.showHide("error",a.message)}}),{passive:!0,once:!0}).click()})).textContent=o.label,a.tfClass("page-title-action")[0].after(n)}),{passive:!0,once:!0})})(Themify,window,document,tbBulkImport);