/**
 * [zipacker]{@link https://github.com/emn178/zipacker}
 *
 * @version 0.3.0
 * @author Chen, Yi-Cyuan [emn178@gmail.com]
 * @copyright Chen, Yi-Cyuan 2016-2022
 * @license MIT
 */
!function(){function o(o){this.options=o||{},this.options.zipFile=this.options.zipFile||"download.zip",this.tasks={},this.fs=new zip.fs.FS,["onError","onZipping","onZippedBlob"].forEach(function(o){this[o]=this[o].bind(this)}.bind(this))}o.prototype.addBlob=function(o,t){this.fs.root.addBlob(t,o)},o.prototype.addData64URI=function(o,t){this.fs.root.addData64URI(t,o)},o.prototype.addText=function(o,t){this.fs.root.addText(t,o)},o.prototype.isDir=function(o){return""===o||"/"==o.charAt(o.length-1)},o.prototype.add=function(o,i){if(o.constructor==Blob)return this.addBlob(o,i);var s,n=this.tasks,p=!1;if(i=i||"",Array.isArray(o))this.isDir(i)||(i+="/");else{if("object"==typeof o){for(var t in o)this.add(t,o[t]);return}p=!this.isDir(i),o=[o]}o.forEach(function(o){var t;s=p?i:(t=o.split("/"),s=(s=t[t.length-1]).split("?")[0],i+s),n[o]||(n[o]=[]),n[o].push(s)})},o.prototype.doTasks=function(){var t,i=this.fs;for(t in this.tasks)this.tasks[t].forEach(function(o){i.root.addHttpContent(o,t)})},o.prototype.onError=function(o){this.options.onError&&this.options.onError.call(this,o)},o.prototype.onZipping=function(o,t){this.options.onProgress&&this.options.onProgress.call(this,o,t,"zip"),this.options.onZipping&&this.options.onZipping.call(this,o,t)},o.prototype.onZippedBlob=function(o){this.options.onZipped&&this.options.onZipped.call(this),saveAs(o,this.options.zipFile),this.options.onDone&&this.options.onDone.call(this)},o.prototype.zipInMemory=function(){this.doTasks(),this.fs.exportBlob({onprogress:this.onZipping,password:this.options.password,zipCrypto:!!this.options.password}).then(this.onZippedBlob,this.onError)},o.prototype.download=function(){this.zipInMemory()},window.Zipacker=o}();