function Fs(t){"use strict";var e=this;this.ext2Type={},this.mountPath=t.app.mountPath||baseMountPath,this.mediaTypes=(t.options||{}).mediaTypes||defaultMediaTypes,this.types=this.mediaTypes.registered=Object.keys(this.mediaTypes).reduce(function(t,s){return"registered"!==s&&"playable"!==s?t.concat(e.mediaTypes[s]):t},[]),this.mediaTypes.playable=this.mediaTypes.video.concat(this.mediaTypes.audio,this.mediaTypes.image,this.mediaTypes.playlist,this.mediaTypes.diskImage),Object.keys(this.mediaTypes).forEach(function(t){e.mediaTypes[t].forEach(function(s){e.ext2Type[s]=t})}),Object.defineProperty(this,"onMount",{set:function(t){stbEvent.addListener("message",function(e){e.broadcast&&("storage.mount"===e.message?t(!0):"storage.unmount"===e.message&&t(!1))})}})}var baseMountPath="/ram/mnt",defaultMediaTypes={video:["mpg","mpeg","mov","mp4","avi","mkv","3gp","ts","vob","wmv","mts","m2t","m2v","divx","m2ts","m2p","tp","flv","mod","tod","asf","tts","m4v","trp","wtv"],audio:["mp3","wav","ac3","ogg","oga","aiff","wv","tta","wma","aac","dts","flac","ape","m4a"],image:["jpg","jpeg","png","bmp","tif","tiff","raw","gif","cr2","nef","orf","iiq","ico","psd","webp","tif","tiff"],text:["txt","srt","sub","ass"],playlist:["cue","m3u","m3u8"],diskImage:["iso"],record:["tspinf"]},activeRegisterTypes,tools;tools={parseError:function(t){return"Error in magcore-plugin-fs plugin!\nAction: "+t.cause+"\nLine: "+t.line+"\nMessage: "+t.message+"\nStack:\n"+t.stack},asyncCall:function(t){var e=[].slice.call(arguments,1);setTimeout(function(){try{t.apply(null,e)}catch(t){throw t}},0)}},Fs.prototype.getReadOnlyState=function(){return"true"===core.environment.mount_media_ro},Fs.prototype.readDir=function(path,callback){var data;this.types!==activeRegisterTypes&&(gSTB.SetListFilesExt("."+this.types.join(" .")),activeRegisterTypes=this.types);try{eval(gSTB.ListDir(path,!0)),data={dirs:dirs.reduce(function(t,e){return t.concat(""===e?[]:{name:e.slice(0,-1),type:9})},[]),files:files.reduce(function(t,e){return e.name?t.concat(e):t},[])},tools.asyncCall(callback,null,data)}catch(t){t.cause="[readDir] invalid data from gSTB.listDir",tools.asyncCall(callback,tools.parseError(t))}},Fs.prototype.readFile=function(t,e){"use strict";tools.asyncCall(e,null,gSTB.RDir('GetFile "'+t+'"'))},Fs.prototype.setTypes=function(t){"use strict";this.types=this.mediaTypes.registered=t},Fs.prototype.getMountPoints=function(){"use strict";var t={},e=JSON.parse(gSTB.GetStorageInfo("{}"));return Array.isArray(e.result)&&""===e.errMsg&&e.result.length>0?(e.result.forEach(function(e){e.mediaType="000022272228"===e.sn?3:e.mediaType,e.label=e.label.trim(),t[e.sn]?t[e.sn]++:t[e.sn]=1}),e.result.forEach(function(e){e.label||(e.label=e.vendor+" "+e.model.replace(/\//,""),t[e.sn]>1&&(e.label+=" #"+e.partitionNum))}),e.result.sort(),e.result):[]},Fs.prototype.getHDDInfo=function(){"use strict";try{return JSON.parse(gSTB.RDir("get_hdd_info")||"[]")}catch(t){return[]}},Fs.prototype.removeDir=function(t,e){"use strict";var s='RemoveDirFull "'+("/"===t.charAt(t.length-1)?t.substr(0,t.length-1):t)+'"';tools.asyncCall(e,null,"Ok"===gSTB.RDir(s))},Fs.prototype.removeFile=function(t,e){"use strict";tools.asyncCall(e,null,"Ok"===gSTB.RDir('RemoveFile "'+t+'"'))},Fs.prototype.createDir=function(t,e){"use strict";var s=this;gSTB.ExecAction('make_dir "'+t+'"'),tools.asyncCall(function(){s.isFolderExist(t,function(t,s){t?e(t):e(null,s)})})},Fs.prototype.isFileUTF8Encoded=function(t){"use strict";return gSTB.IsFileUTF8Encoded(t)},Fs.prototype.isFileExist=function(t,e){"use strict";tools.asyncCall(e,null,gSTB.IsFileExist(t))},Fs.prototype.isFolderExist=function(t,e){"use strict";tools.asyncCall(e,null,gSTB.IsFolderExist(t))},Fs.prototype.mount=function(t,e){"use strict";var s,i,a,r;t&&t.address&&(t.address="/"===t.address.charAt(t.address.length-1)?t.address.substr(0,t.address.length-1):t.address,s=t.login||"guest",i=t.pass||"",a='mount cifs "'+t.address+'" "'+(t.mountPath||this.mountPath)+'" username='+s+",password="+i+",iocharset=utf8",r=gSTB.RDir(a).trim()),tools.asyncCall(e,null,"Ok"===r)},Fs.prototype.umount=function(t){"use strict";(t.mounted||t.force)&&gSTB.ExecAction("umount_dir "+t.path)},module.exports={onAppInit:function(t,e){e(null,new Fs(t))}};