/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/unrar-js@0.2.3/unrar.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
var fs=require("fs"),path=require("path"),RarEventMgr=require("./lib/RarEventMgr"),child_process=require("child_process");function _registerEvents(r){RarEventMgr.on(RarEventMgr.TYPES.START,(function(){r.onStart&&r.onStart()})),RarEventMgr.on(RarEventMgr.TYPES.PROGRESS,(function(n){r.onProgress&&r.onProgress(n)})),RarEventMgr.on(RarEventMgr.TYPES.EXTRACT,(function(n){r.onExtract&&r.onExtract(n)})),RarEventMgr.on(RarEventMgr.TYPES.FINISH,(function(n){r.onFinish&&r.onFinish(n)})),RarEventMgr.on(RarEventMgr.TYPES.INFO,(function(n){r.onInfo&&r.onInfo(n)})),RarEventMgr.on(RarEventMgr.TYPES.ERROR,(function(n){r.onError&&r.onError(n)}))}function storeFilesToDiskSync(r,n){return mkdirp.sync(n),r.map((function(r){return storeFileToDiskSync(r,n),path.join(n,r.filename)}))}function storeFileToDiskSync(r){var n,e;path.dirname(r.filename);console.log("File name: ",r.filename," size: ",r.header.unpackedSize),console.log("Saving content of file "),path.dirname(r.filename),n=path.join(__dirname,path.basename(r.filename)),e=new Buffer(r.fileData),fs.writeFileSync(n,e)}module.exports={unrarSync:function(){var r,n,e,o=require("./lib/Unrar"),t=arguments[0];return"string"==typeof arguments[1]?(r=arguments[1],e=arguments[2]||{}):e=arguments[1]||{},_registerEvents(e),n=o(fs.readFileSync(t)),r&&(n=storeFilesToDiskSync(n,r)),n},unrar:function(){var r,n,e,o=arguments[0],t=arguments[1],i=[];if("function"==typeof arguments[2]?(r={},n=arguments[2]):(r=arguments[2]||{},n=arguments[3]),!o||"string"!=typeof o)throw"Unrar::Error, missing file argument.";if(!t||"string"!=typeof t)throw"Unrar::Error, missing output directory argument.";if(!n)throw"Unrar::Error, missing callback argument.";childProcess=child_process.fork(path.join(__dirname,"js/UnrarSubprocess.js"),[o,t]),childProcess.on("message",(n=>{"progress"===n.event?r.onProgress&&r.onProgress(n.data):"finish"===n.event?(i=n.data,childProcess.kill("SIGHUP")):("error"===n.event||"abort"===n.event)&&(e=n.data,childProcess.kill("SIGKILL"))})),childProcess.on("close",(function(){n(e,i)}))}};
//# sourceMappingURL=/sm/667efeb659c0b7d4988b077618a48a2097f4d11f614244303af03c8c1c414668.map