(this.webpackJSONPwpmdb=this.webpackJSONPwpmdb||[]).push([[7],{583:function(e,t,r){"use strict";r.r(t),r.d(t,"setImportTableData",function(){return m}),r.d(t,"importFile",function(){return _}),r.d(t,"uploadFileActions",function(){return d});var n=r(4),a=r.n(n),c=r(9),u=r(3),i=r(197),s=r(5),p=r(13),o=r(29),b=r(6),f=r(11),l=r(254),m=function(e){return function(t,r){return t(Object(s.a)(l.a,e))}},_=function e(t){return function(){var r=Object(c.a)(a.a.mark(function r(n,c){var l,_,O,d,j,h,v,w,k,g,x;return a.a.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return l=Object(u.h)("import_gzipped",c()),_=Object(i.selectFromImportData)("file_size",c()),(O={chunk:t.chunk,current_query:t.current_query,import_file:t.import_filename}).import_info=JSON.stringify({import_gzipped:l}),r.prev=4,r.next=7,Object(b.b)("/import-file",O);case 7:d=r.sent,r.next=14;break;case 10:return r.prev=10,r.t0=r.catch(4),n(Object(o.v)({error_type:f.a,error_message:r.t0.message})),r.abrupt("return",!1);case 14:if(j=d.data,h=j.table_sizes,v=j.table_rows,w=j.tables,n(m({table_sizes:h,table_rows:v,tables:w})),k=Math.ceil(_/j.num_chunks),g=k/1e3,n(Object(o.A)(g)),!(j.chunk>=j.num_chunks)){r.next=26;break}return n(Object(o.q)()),n(Object(s.a)(p.u,"import")),r.abrupt("return",n(Object(o.s)("MIGRATE",[],"find_replace")));case 26:return x=[{import_filename:t.import_filename,item_name:t.item_name,chunk:j.chunk,current_query:j.current_query}],r.next=29,n(Object(o.s)("IMPORT_FILE",[{fn:e,args:x}]));case 29:return r.abrupt("return",r.sent);case 30:case"end":return r.stop()}},r,null,[[4,10]])}));return function(e,t){return r.apply(this,arguments)}}()},O=function(e){return function(){var t=Object(c.a)(a.a.mark(function t(r,n){var c,u,i,l;return a.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r(Object(s.a)(p.i,"import")),r(Object(s.a)(f.d)),t.prev=2,t.next=5,Object(b.b)("/prepare-upload",{});case 5:c=t.sent,t.next=12;break;case 8:return t.prev=8,t.t0=t.catch(2),r(Object(o.v)({error_type:f.a,error_message:t.t0.message})),t.abrupt("return",!1);case 12:return u=e.name,i=window.wpmdb_strings.importing_file_to_db.replace(/%s\s?/,u),r(Object(s.a)(f.w,i)),".gz"===u.slice(-3)&&(u=e.name.slice(0,-3)),l=[{import_filename:c.data.import_file,item_name:u,chunk:0,current_query:""}],t.next=19,r(Object(o.s)(o.a,[{fn:_,args:l}]));case 19:return t.abrupt("return",t.sent);case 20:case"end":return t.stop()}},t,null,[[2,8]])}));return function(e,r){return t.apply(this,arguments)}}()},d=function e(t){return function(){var r=Object(c.a)(a.a.mark(function r(n,l){var m,_,d,j,h;return a.a.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:m=Object(u.f)("remote_site",l()),t="undefined"===typeof t?0:t,_=Object(i.selectFromImportData)("file",l()),d=t+1024e3+1,j=new FileReader,0===t&&(n(Object(s.a)(p.i,"upload")),n(Object(o.w)(Math.ceil(Object(i.selectFromImportData)("file_size",l())/1e3)))),j.onloadend=function(){var r=Object(c.a)(a.a.mark(function r(c){var u,i;return a.a.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(c.target.readyState===FileReader.DONE){r.next=2;break}return r.abrupt("return");case 2:return u={action:"wpmdb_upload_file",file_data:c.target.result,file:_.name,file_type:_.type,stage:"import",import_info:m},r.prev=3,r.next=6,Object(b.b)("/upload-file",u);case 6:r.next=12;break;case 8:return r.prev=8,r.t0=r.catch(3),n(Object(o.v)({error_type:f.a,error_message:r.t0.message})),r.abrupt("return",!1);case 12:if(!(d<_.size)){r.next=19;break}return n(Object(o.A)(Math.ceil(1024))),r.next=16,n(Object(o.s)(o.c,[{fn:e,args:[d]}]));case 16:return r.abrupt("return",r.sent);case 19:return i=_.size-t,n(Object(o.A)(Math.ceil(i/1e3))),n(Object(s.a)(p.u,"upload")),r.next=24,n(Object(o.s)(o.d,[{fn:O,args:[_]}]));case 24:return r.abrupt("return",r.sent);case 25:case"end":return r.stop()}},r,null,[[3,8]])}));return function(e){return r.apply(this,arguments)}}(),h=_.slice(t,d),j.readAsDataURL(h);case 9:case"end":return r.stop()}},r)}));return function(e,t){return r.apply(this,arguments)}}()}}}]);