var _0x1e35=['Copy\x20successful\x20for\x20','_expireEULA','eula','license.json','unlinkSync','slice','shift','Rebooting\x20server\x20with\x20command\x20','\x20and\x20args\x20','inherit','unref','pct','message','\x20-\x20','emit','updateProgress','socketListeners','updateCheck','exports','request','node-fetch','fs-extra','path','yauzl','child_process','./files','./common/utils','_update','appDir','rootDir','updateDir','key','trim','platform','arch','x64','manifestSrc','/manifest.json','manifest','targetVersion','logger','info','\x20and\x20version\x20','file','target','No\x20target\x20version\x20has\x20yet\x20been\x20identified!','builds','The\x20target\x20update\x20does\x20not\x20appear\x20to\x20exist\x20for\x20this\x20platform!','remoteSrc','localDest','isElectron','options','argv','join','main.js','swapExecutable','FoundryVTT.exe','linux','foundryvtt','isHotfix','updateType','hotfix','check','then','json','catch','progress','No\x20update\x20available\x20for\x20this\x20test\x20key','_checkUpdate','notes','text','New\x20update\x20available\x20-\x20Version\x20','_getPlatform','win','darwin','mac','entries','values','full','filter','version','ver','length','sort','pop','update','No\x20update\x20version\x20available!','download','Preparing\x20directory\x20for\x20update','clearUpdateDirectory','_downloadSource','Download\x20unsuccessful\x20-\x20','ERROR','_extractUpdate','install','chdir','isFull','_copyContent','express','swapRestart','executable','exit','mkdirp','createWriteStream','get','response','statusCode','headers','content-length','Something\x20went\x20wrong','data','round','Downloading\x20update','error','pipe','noAsar','Extracting\x20update','Processing\x20file\x20','DEBUG','endsWith','Skipping\x20base\x20directory\x20','Error\x20extracting\x20file\x20','once','Update\x20extraction\x20failed\x20:','close','Update\x20extraction\x20complete!','readEntry','_processEntry','mkdir','dirname','openReadStream','finish','_removeOutdated','readdirSync','public','server','client','docs','.git','.idea','update.log','Comparing\x20new\x20files\x20against\x20current\x20content','includes','Removing\x20files\x20which\x20are\x20no\x20longer\x20required:\x20','Clearing\x20outdated\x20content','remove','Failure\x20removing\x20','Cleared\x20outdated\x20content','isDirectory','map','concat','push','Installing\x20update,\x20do\x20not\x20close\x20the\x20application','copy'];(function(_0x2a323c,_0x34b9aa){var _0x16b99b=function(_0x2af46a){while(--_0x2af46a){_0x2a323c['push'](_0x2a323c['shift']());}};_0x16b99b(++_0x34b9aa);}(_0x1e35,0x1e1));var _0x5a05=function(_0x2eb687,_0x4503bb){_0x2eb687=_0x2eb687-0x0;var _0x48a627=_0x1e35[_0x2eb687];return _0x48a627;};const request=require(_0x5a05('0x0'));const fetch=require(_0x5a05('0x1'));const fs=require(_0x5a05('0x2'));const os=require('os');const path=require(_0x5a05('0x3'));const yauzl=require(_0x5a05('0x4'));const {spawn}=require(_0x5a05('0x5'));const {Files}=require(_0x5a05('0x6'));const {isNewerVersion}=require(_0x5a05('0x7'));const UPDATE_DIR=_0x5a05('0x8');const UPDATE_SRC='https://s3-us-west-2.amazonaws.com/foundryvtt/releases';class Updater{constructor(_0x2ca197,_0x211fa3,_0x3d0c7c){this[_0x5a05('0x9')]=_0x211fa3||global[_0x5a05('0xa')];this[_0x5a05('0xb')]=path['join'](this[_0x5a05('0x9')],UPDATE_DIR);this[_0x5a05('0xc')]=_0x2ca197[_0x5a05('0xd')]();this[_0x5a05('0xe')]=this['_getPlatform']();this[_0x5a05('0xf')]=_0x5a05('0x10');this[_0x5a05('0x11')]=UPDATE_SRC+'/'+_0x2ca197+_0x5a05('0x12');this[_0x5a05('0x13')]=null;this[_0x5a05('0x14')]=_0x3d0c7c;this['target']=null;global[_0x5a05('0x15')][_0x5a05('0x16')]('Configured\x20Updater\x20application\x20for\x20key\x20'+_0x2ca197+_0x5a05('0x17')+_0x3d0c7c);}get[_0x5a05('0x18')](){if(!this[_0x5a05('0x19')])throw new Error(_0x5a05('0x1a'));let _0x3c1d19=this[_0x5a05('0x19')][_0x5a05('0x1b')][this['platform']];if(!_0x3c1d19)throw new Error(_0x5a05('0x1c'));return _0x3c1d19;}get[_0x5a05('0x1d')](){return UPDATE_SRC+'/'+this['key']+'/'+this[_0x5a05('0x18')];}get[_0x5a05('0x1e')](){return this[_0x5a05('0xb')]+'/'+this[_0x5a05('0x18')];}get[_0x5a05('0x1f')](){return global[_0x5a05('0x20')][_0x5a05('0x1f')];}get['executable'](){if(this['isElectron'])return process[_0x5a05('0x21')][0x0];else return[process[_0x5a05('0x21')][0x0],path[_0x5a05('0x22')](this[_0x5a05('0x9')],_0x5a05('0x23'))];}get[_0x5a05('0x24')](){if(this[_0x5a05('0x1f')]){if(this[_0x5a05('0xe')]==='win')return path[_0x5a05('0x22')](this['updateDir'],_0x5a05('0x25'));else if(this[_0x5a05('0xe')]===_0x5a05('0x26'))return path[_0x5a05('0x22')](this[_0x5a05('0xb')],_0x5a05('0x27'));else if(this['platform']==='mac')return this[_0x5a05('0xb')];}else return[process['argv'][0x0],path['join'](this[_0x5a05('0xb')],_0x5a05('0x23'))];}get['isFull'](){return this[_0x5a05('0x19')]['updateType']==='full';}get[_0x5a05('0x28')](){return this[_0x5a05('0x19')][_0x5a05('0x29')]===_0x5a05('0x2a');}async[_0x5a05('0x2b')](){this[_0x5a05('0x13')]=await fetch(this['manifestSrc'])[_0x5a05('0x2c')](_0x46ee4b=>_0x46ee4b[_0x5a05('0x2d')]())[_0x5a05('0x2e')](_0x563799=>![]);if(!this[_0x5a05('0x13')]){this[_0x5a05('0x2f')]({'message':_0x5a05('0x30')});return![];}if(!this['targetVersion'])this[_0x5a05('0x14')]=this[_0x5a05('0x31')](this[_0x5a05('0x13')]);this[_0x5a05('0x19')]=this[_0x5a05('0x13')][this[_0x5a05('0x14')]];if(!this['target']){this[_0x5a05('0x2f')]({'message':'Already\x20up\x20to\x20date!'});return![];}if(this[_0x5a05('0x19')][_0x5a05('0x32')]){let _0xf16cc2=UPDATE_SRC+'/'+this[_0x5a05('0xc')]+'/'+this[_0x5a05('0x19')]['notes'];this[_0x5a05('0x19')]['notesHTML']=await fetch(_0xf16cc2)[_0x5a05('0x2c')](_0x3250e0=>_0x3250e0[_0x5a05('0x33')]());}this['target']['version']=this['targetVersion'];this[_0x5a05('0x2f')]({'message':_0x5a05('0x34')+this[_0x5a05('0x14')]});return this[_0x5a05('0x19')];}[_0x5a05('0x35')](){let _0x1ca460=os['platform']();if(_0x1ca460==='win32')return _0x5a05('0x36');else if(_0x1ca460==='linux')return _0x5a05('0x26');else if(_0x1ca460===_0x5a05('0x37'))return _0x5a05('0x38');}[_0x5a05('0x31')](_0x1f7d27){for(let [_0x510841,_0x44309d]of Object[_0x5a05('0x39')](this['manifest'])){_0x44309d['version']=_0x510841;}let _0x577412=Object[_0x5a05('0x3a')](_0x1f7d27)['filter'](_0x510841=>_0x510841['updateType']===_0x5a05('0x3b')),_0x45bc5e=Object[_0x5a05('0x3a')](_0x1f7d27)[_0x5a05('0x3c')](_0x510841=>_0x510841['updateType']===_0x5a05('0x2a'));_0x577412=_0x577412['filter'](_0x5d2428=>isNewerVersion(_0x5d2428[_0x5a05('0x3d')],global[_0x5a05('0x3e')]));_0x45bc5e=_0x45bc5e['filter'](_0x1baa15=>isNewerVersion(_0x1baa15[_0x5a05('0x3d')],global[_0x5a05('0x3e')]));let _0x18667c=_0x577412[_0x5a05('0x3f')]>0x0?_0x577412:_0x45bc5e;if(_0x18667c['length']===0x0)return null;let _0x2d4285=_0x18667c[_0x5a05('0x40')]((_0xf612e6,_0x1d60b8)=>{return isNewerVersion(_0xf612e6['version'],_0x1d60b8[_0x5a05('0x3d')])?0x1:-0x1;});return _0x2d4285[_0x5a05('0x41')]()[_0x5a05('0x3d')];}async[_0x5a05('0x42')](_0x1f5bee){if(!this[_0x5a05('0x19')]){await this['check']();if(!this[_0x5a05('0x19')])throw new Error(_0x5a05('0x43'));}if(_0x1f5bee===_0x5a05('0x44')){this[_0x5a05('0x2f')]({'message':_0x5a05('0x45')});await this[_0x5a05('0x46')]();try{await this[_0x5a05('0x47')]();}catch(_0x270c0e){this[_0x5a05('0x2f')]({'message':_0x5a05('0x48')+_0x270c0e,'pct':0x0,'level':_0x5a05('0x49')});throw new Error(_0x270c0e);}await this[_0x5a05('0x4a')]();if(this[_0x5a05('0x1f')]&&this['isFull']){this['swapRestart'](this[_0x5a05('0x24')],{'swap':0x1,'updateKey':this[_0x5a05('0xc')],'updateDir':this['appDir'],'updateVer':this['targetVersion']});}else _0x1f5bee=_0x5a05('0x4b');}if(_0x1f5bee==='install'){if(rootDir!==this['appDir'])process[_0x5a05('0x4c')](this[_0x5a05('0x9')]);if(this[_0x5a05('0x4d')])await this['_removeOutdated']();await this[_0x5a05('0x4e')]();await this['_expireEULA']();global[_0x5a05('0x4f')]['io']['emit']('updateComplete',this[_0x5a05('0x19')]);if(this[_0x5a05('0x1f')]){this[_0x5a05('0x50')](this[_0x5a05('0x51')],{'restart':0x1,'updateKey':this['key'],'updateDir':this[_0x5a05('0x9')],'updateVer':this[_0x5a05('0x14')]});}else{await this[_0x5a05('0x46')]();process[_0x5a05('0x52')]();}}return!![];}async['clearUpdateDirectory'](){return fs['remove'](this[_0x5a05('0xb')]);}async['_downloadSource'](){await fs[_0x5a05('0x53')](this['updateDir']);let _0x2f435e,_0x4c1127=0x0,_0x1e795e;return new Promise((_0x1b0373,_0x4d9245)=>{let _0x3e9e62=fs[_0x5a05('0x54')](this[_0x5a05('0x1e')]);request[_0x5a05('0x55')]({'url':this['remoteSrc'],'encoding':null})['on'](_0x5a05('0x56'),_0x3e787d=>{if(_0x3e787d[_0x5a05('0x57')]===0x193)throw new Error(_0x3e787d['statusMessage']);_0x2f435e=parseInt(_0x3e787d[_0x5a05('0x58')][_0x5a05('0x59')]);if(_0x2f435e<0x2710)throw new Error(_0x5a05('0x5a'));})['on'](_0x5a05('0x5b'),_0x255313=>{_0x4c1127+=_0x255313['length'];let _0x1a5cec=Math[_0x5a05('0x5c')](_0x4c1127*0x64/_0x2f435e);if(_0x1a5cec!==_0x1e795e){_0x1e795e=_0x1a5cec;this['progress']({'message':_0x5a05('0x5d'),'pct':_0x1e795e});}})['on']('end',_0x1b0373)['on'](_0x5a05('0x5e'),_0x4d9245)[_0x5a05('0x5f')](_0x3e9e62);});}[_0x5a05('0x4a')](){let _0x30e220,_0xddf537=0x0,_0x14b537;process[_0x5a05('0x60')]=!![];return new Promise((_0x4d46bc,_0x427dcf)=>{this[_0x5a05('0x2f')]({'message':_0x5a05('0x61'),'pct':0x0});yauzl['open'](this[_0x5a05('0x1e')],{'lazyEntries':!![]},(_0x1fe77e,_0x12d4b8)=>{if(_0x1fe77e)_0x427dcf(_0x1fe77e);_0x30e220=_0x12d4b8['entryCount'];_0x12d4b8['on']('entry',async _0x5a592e=>{_0xddf537++;_0x14b537=Math[_0x5a05('0x5c')](_0xddf537*0x64/_0x30e220);let _0x1fd1ca=_0x5a592e['fileName'];this[_0x5a05('0x2f')]({'message':_0x5a05('0x62')+_0x1fd1ca,'level':_0x5a05('0x63')});if(_0x1fd1ca[_0x5a05('0x64')]('/'))global[_0x5a05('0x15')]['info'](_0x5a05('0x65')+_0x1fd1ca);else try{await this['_processEntry'](_0x12d4b8,_0x5a592e,_0x1fd1ca,_0x427dcf);}catch(_0x14fe7f){this[_0x5a05('0x2f')]({'message':_0x5a05('0x66')+_0x1fd1ca+':\x20'+_0x14fe7f,'level':'ERROR'});}this['progress']({'message':'Extracting\x20update,\x20do\x20not\x20close\x20the\x20application','pct':_0x14b537});_0x12d4b8['readEntry']();})[_0x5a05('0x67')](_0x5a05('0x5e'),_0x1a861c=>{this[_0x5a05('0x2f')]({'message':_0x5a05('0x68')+_0x1a861c,'level':_0x5a05('0x49')});_0x427dcf(_0x1a861c);})[_0x5a05('0x67')](_0x5a05('0x69'),()=>{this[_0x5a05('0x2f')]({'message':_0x5a05('0x6a'),'pct':0x64});process[_0x5a05('0x60')]=![];_0x4d46bc();});_0x12d4b8[_0x5a05('0x6b')]();});});}[_0x5a05('0x6c')](_0x35bea3,_0x1ea1dc,_0x416133,_0x447a2b){let _0x223e08=path[_0x5a05('0x22')](this['updateDir'],_0x416133);Files[_0x5a05('0x6d')](path[_0x5a05('0x6e')](_0x223e08));return new Promise(_0x3b8a54=>{_0x35bea3[_0x5a05('0x6f')](_0x1ea1dc,(_0x5d160d,_0x53125a)=>{if(_0x5d160d)_0x447a2b(_0x5d160d);let _0x402fa0=fs[_0x5a05('0x54')](_0x223e08)['on'](_0x5a05('0x70'),_0x3b8a54)['on'](_0x5a05('0x5e'),_0x447a2b);_0x53125a['pipe'](_0x402fa0);});});}async[_0x5a05('0x71')](){let _0x74ff38=fs['readdirSync'](this['appDir']),_0xef5044=fs[_0x5a05('0x72')](this[_0x5a05('0xb')]),_0x33c49c=0x0;let _0x6c0221=[UPDATE_DIR,_0x5a05('0x73'),_0x5a05('0x74'),_0x5a05('0x75'),_0x5a05('0x76'),_0x5a05('0x77'),_0x5a05('0x78'),'license.json',_0x5a05('0x79')];this[_0x5a05('0x2f')]({'message':_0x5a05('0x7a')});let _0x1ecfdb=_0x74ff38['filter'](_0x51bf6a=>{return!_0x6c0221[_0x5a05('0x7b')](_0x51bf6a);})[_0x5a05('0x3c')](_0x47d5d7=>{return!_0xef5044[_0x5a05('0x7b')](_0x47d5d7);});this[_0x5a05('0x2f')]({'message':_0x5a05('0x7c')+_0x1ecfdb[_0x5a05('0x22')](',\x20'),'level':_0x5a05('0x63')});_0x1ecfdb['forEach'](async _0x457d09=>{_0x33c49c++;let _0x564fca=Math[_0x5a05('0x5c')](_0x33c49c*0x64/_0x1ecfdb[_0x5a05('0x3f')]);this[_0x5a05('0x2f')]({'message':_0x5a05('0x7d'),'pct':_0x564fca});try{await fs[_0x5a05('0x7e')](_0x457d09);}catch(_0xeb8920){this[_0x5a05('0x2f')]({'message':_0x5a05('0x7f')+_0x457d09+':\x20'+_0xeb8920,'level':_0x5a05('0x49')});}});this[_0x5a05('0x2f')]({'message':_0x5a05('0x80'),'pct':0x64});}async[_0x5a05('0x4e')](){let _0x56eb85=fs[_0x5a05('0x72')](this[_0x5a05('0xb')])[_0x5a05('0x3c')](_0xc2b660=>_0xc2b660!==this[_0x5a05('0x18')]);let _0x54a2e0=_0x56eb85['reduce']((_0x268fde,_0x87e38d)=>{let _0x221542=path[_0x5a05('0x22')](this['updateDir'],_0x87e38d);if(Files[_0x5a05('0x81')](_0x221542)){let _0x56eb85=fs['readdirSync'](_0x221542)[_0x5a05('0x82')](_0x36d27d=>path[_0x5a05('0x22')](_0x87e38d,_0x36d27d));_0x268fde=_0x268fde[_0x5a05('0x83')](_0x56eb85);}else _0x268fde[_0x5a05('0x84')](_0x87e38d);return _0x268fde;},[]);let _0x25d9a4=_0x54a2e0[_0x5a05('0x3f')],_0x32a52f=0x0;for(let _0x3fde86 of _0x54a2e0){_0x32a52f++;let _0x2466df=Math['round'](_0x32a52f*0x64/_0x25d9a4);this[_0x5a05('0x2f')]({'message':_0x5a05('0x85'),'pct':_0x2466df});let _0x3c5802=path[_0x5a05('0x22')](this[_0x5a05('0xb')],_0x3fde86),_0x4cc247=path[_0x5a05('0x22')](this[_0x5a05('0x9')],_0x3fde86);await fs[_0x5a05('0x86')](_0x3c5802,_0x4cc247)[_0x5a05('0x2c')](()=>this[_0x5a05('0x2f')]({'message':_0x5a05('0x87')+_0x3fde86,'level':_0x5a05('0x63')}))[_0x5a05('0x2e')](_0x435a1b=>this['progress']({'message':'Copy\x20failed\x20for\x20'+_0x3fde86+':\x20'+_0x435a1b,'level':_0x5a05('0x49')}));}return!![];}async[_0x5a05('0x88')](){if(this[_0x5a05('0x19')][_0x5a05('0x89')]&&fs['existsSync'](_0x5a05('0x8a'))){fs[_0x5a05('0x8b')]('license.json');}}async['swapRestart'](_0x3253b5,_0x305b5a){let _0x555277=process[_0x5a05('0x21')]['slice'](0x1);if(_0x3253b5 instanceof Array){_0x555277=_0x3253b5[_0x5a05('0x8c')](0x1)[_0x5a05('0x83')](process['argv']['slice'](0x2));_0x3253b5=_0x3253b5[_0x5a05('0x8d')]();}this['progress']({'message':_0x5a05('0x8e')+_0x3253b5+_0x5a05('0x8f')+_0x555277,'level':_0x5a05('0x63')});setTimeout(()=>{spawn(_0x3253b5,_0x555277,{'detached':!![],'cwd':this[_0x5a05('0x9')],'stdio':_0x5a05('0x90'),'env':_0x305b5a})[_0x5a05('0x91')]();process[_0x5a05('0x52')]();},0x32);}[_0x5a05('0x2f')](_0x29e0ee){let _0x117317=_0x29e0ee[_0x5a05('0x92')]?_0x29e0ee[_0x5a05('0x93')]+_0x5a05('0x94')+_0x29e0ee[_0x5a05('0x92')]+'%':_0x29e0ee[_0x5a05('0x93')];global[_0x5a05('0x15')][_0x5a05('0x16')](''+_0x117317);global[_0x5a05('0x4f')]['io'][_0x5a05('0x95')](_0x5a05('0x96'),_0x29e0ee);}static[_0x5a05('0x97')](_0x1e8dad){_0x1e8dad['on'](_0x5a05('0x98'),async(_0x280fbb,_0x260ef1)=>{let _0x33479a=new Updater(_0x280fbb);let _0x2f7f51=await _0x33479a[_0x5a05('0x2b')]();_0x260ef1(_0x2f7f51);});_0x1e8dad['on']('updateDownload',async(_0x3fdb4b,_0x10f4ca)=>{let _0x5683b2=new Updater(_0x3fdb4b);await _0x5683b2['check']();_0x5683b2[_0x5a05('0x42')](_0x5a05('0x44'));_0x10f4ca(_0x5683b2[_0x5a05('0x19')]);});}}module[_0x5a05('0x99')]={'Updater':Updater};