-
Notifications
You must be signed in to change notification settings - Fork 32
/
index.js
1 lines (1 loc) · 200 KB
/
index.js
1
(()=>{"use strict";var __webpack_modules__={2859:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeAccount=t.setSerial=t.updateAccountAction=t.addAccountAction=void 0;const o=i(8396),r=i(9303),a=i(5937),s=i(272),l=i(609),d=i(5862);t.addAccountAction=()=>n(void 0,void 0,void 0,(function*(){l.logger.info("Creating account...");const e=(0,s.requireAndParseEnv)("IDENTIFY",s.identity);if(yield r.Config.findOne({where:{identify:e}}))throw new Error("account already exists");const t={};for(const{name:e,required:i}of Object.values(o.ENVS))t[e]=i?(0,s.requireAndParseEnv)(e,s.identity):(0,s.askAndParseEnv)(e,s.identity,null);for(const e in t)null!==t[e]&&l.logger.info(`${e}=${t[e]}`);yield(0,a.addAccount)(t),l.logger.info("Account created")})),t.updateAccountAction=()=>n(void 0,void 0,void 0,(function*(){l.logger.info("Updating account...");const e=(0,s.requireAndParseEnv)("IDENTIFY",s.identity),t=yield r.Config.findOne({where:{identify:e}});if(!t)throw new Error("account not exists");const i={};for(const{name:e}of Object.values(o.ENVS))"IDENTIFY"!==e&&void 0!==process.env[e]&&(i[e]=(0,s.askAndParseEnv)(e,s.identity,null));for(const e in i)l.logger.info(`${e}=${i[e]}`);yield t.update(i),l.logger.info("Account updated");const n=yield r.Config.findOne({where:{identify:e}});n&&(yield(0,d.startAccountPm2)(n))})),t.setSerial=()=>n(void 0,void 0,void 0,(function*(){l.logger.info("Setting serial...");const e=(0,s.requireAndParseEnv)("IDENTIFY",s.identity),t=(0,s.requireAndParseEnv)("SERIAL",s.identity);(yield(0,a.setConfig)(e,"SERIAL",t))?l.logger.info("Serial set"):l.logger.info("Account not found")})),t.removeAccount=()=>n(void 0,void 0,void 0,(function*(){const e=(0,s.requireAndParseEnv)("IDENTIFY",s.identity);yield(0,d.deleteAccountPm2)(e),l.logger.info(`Removing account ${e}...`),yield(0,a.removeAllDataAccount)(e),l.logger.info("Account removed")}))},5911:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.makeLoginMessage=t.makeGameMessage=t.hashLoginMessage=t.hashGameMessage=void 0;const n=i(5699),o=i(8396),r=i(272);function a(e,t,i){const n=(0,r.currentTimeSinceAD)(),a=`${e}|${i}|${t}|${n}|${o.SALT_KEY}`;return[(0,r.hashMD5)(a),n]}function s(e){const t=(0,r.currentTimeSinceAD)(),i=`${e}|LOGIN|${t}|${o.SALT_KEY}`;return[(0,r.hashMD5)(i),t]}t.hashGameMessage=a,t.hashLoginMessage=s,t.makeGameMessage=function(e,t,i,o=new n.SFSObject){const r=new n.SFSObject,[s,l]=a(e,t,i);return r.put("data",o,n.SFSDataType.SFS_OBJECT),r.put("id",i,n.SFSDataType.INT),r.put("hash",s,n.SFSDataType.UTF_STRING),r.put("timestamp",l,n.SFSDataType.LONG),new n.ExtensionRequest(t,r)},t.makeLoginMessage=function(e,t,i,r,a,l,d){const c=new n.SFSObject,u=new n.SFSObject,[h,m]=s(e);return c.put("pln",t,n.SFSDataType.UTF_STRING),c.put("token",i,n.SFSDataType.UTF_STRING),c.put("data_type",r,n.SFSDataType.UTF_STRING),c.put("device_type","WEB",n.SFSDataType.UTF_STRING),c.put("version_code",a,n.SFSDataType.INT),c.put("lt",d,n.SFSDataType.INT),c.put("slogan","senspark",n.SFSDataType.UTF_STRING),c.put("signature",l,n.SFSDataType.UTF_STRING),u.put("lc",o.LC,n.SFSDataType.UTF_STRING),u.put("data",c,n.SFSDataType.SFS_OBJECT),u.put("hash",h,n.SFSDataType.UTF_STRING),u.put("timestamp",m,n.SFSDataType.LONG),new n.LoginRequest(e,"",u)}},3365:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Client=void 0;const r=o(i(6452)),a=i(5699),s=o(i(807)),l=o(i(8519)),d=i(341),c=i(8396),u=i(5937),h=i(3622),m=i(272),g=i(609),p=i(4245),y=i(7224),v=i(1877);t.Client=class{constructor(e,t=0,i=!1,n){this.modeAmazon=!1,this.moreParams=n,this.modeAmazon=i;const o=new s.default;this.apiBaseHeaders={origin:"https://app.bombcrypto.io",referer:"https://app.bombcrypto.io","sec-ch-ua":' " Not A;Brand";v="99", "Chromium";v="98", "Google Chrome";v="98"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-site","content-type":"application/json","user-agent":o.toString()},this.web3=new l.default(c.WEB3_RPC),this.sfs={},this.timeout=t,this.loginParams=e,this.contractBhero=new this.web3.eth.Contract(c.ABI_BHERO,this.web3.utils.toChecksumAddress(c.CONTRACT_BHERO))}get walletId(){return this.loginParams.wallet}get isConnected(){return this.sfs.isConnected}get isLoggedIn(){return"mySelf"in this.sfs&&null!==this.sfs.mySelf}on({event:e,handler:t}){const i=this.handlers[e];return this.pushHandler(i,t)}connect(e=0){return n(this,void 0,void 0,(function*(){if(!this.isConnected)return yield(0,y.makeUniquePromise)(this.controller.connect,(()=>this.sfs.connect()),e||this.timeout)}))}disconnect(e=0){return n(this,void 0,void 0,(function*(){if(this.isConnected)return yield(0,y.makeUniquePromise)(this.controller.disconnect,(()=>this.sfs.disconnect()),e||this.timeout)}))}removeAllPromises(){return n(this,void 0,void 0,(function*(){Object.values(this.controller).map((e=>{var t;null===(t=e.current)||void 0===t||t.reject(new Error("Canceled"))}))}))}createServer(e){return n(this,void 0,void 0,(function*(){this.sfs=new a.SmartFox({host:`server-${e}.bombcrypto.io`,port:c.PORT,zone:c.ZONE,debug:(0,m.askAndParseEnv)("DEBUG",m.parseBoolean,!1),useSSL:!0}),this.sfs.setClientDetails("Unity WebGL",""),this.wipe(),this.connectEvents()}))}getJwtToken(){return n(this,void 0,void 0,(function*(){try{const{type:e}=this.loginParams;let t;if("wallet"==e){const{privateKey:e,wallet:i}=this.loginParams,n=yield r.default.get(`https://api.bombcrypto.io/gateway/auth/dapp/token?address=${i}`,{headers:this.apiBaseHeaders}).json(),o=(0,v.makeLoginSignature)(e,n.message);t=yield r.default.post("https://api.bombcrypto.io/gateway/auth/dapp/verify-signature",{json:{address:i,signature:o},headers:this.apiBaseHeaders}).json(),this.loginParams.signature=o}else{const{password:e,username:i}=this.loginParams;t=yield r.default.post("https://api.bombcrypto.io/gateway/auth/tr/login",{json:{username:i,password:e},headers:this.apiBaseHeaders}).json()}g.logger.info(`New token: ${t.message.token}`);const i=yield r.default.get("https://api.bombcrypto.io/gateway/auth/tr/verify-token",{headers:Object.assign(Object.assign({},this.apiBaseHeaders),{authorization:`Bearer ${t.message.token}`})}).json();if(!i.message.address)throw yield d.bot.telegram.sendMessageChat("Wallet not found"),(0,h.makeException)("LoginFailed","Wallet not found");if(yield(0,u.setConfigCurrent)("username",i.message.address),g.logger.info(`Wallet: ${i.message.address}`),g.logger.info(`User Id: ${i.message.id}`),i.message.isDeleted)throw yield d.bot.telegram.sendMessageChat("Account deleted"),(0,h.makeException)("LoginFailed","Account deleted");this.loginParams.wallet=i.message.address,this.loginParams.token=t.message.token}catch(e){if("Response code 401 (Unauthorized)"==e.message)throw yield d.bot.telegram.sendMessageChat("username or password invalid"),(0,h.makeException)("LoginFailed","username or password invalid");throw(0,h.makeException)("LoginFailed",e.message)}}))}connectServer(){return n(this,void 0,void 0,(function*(){const e=yield this.getServerByPing();g.logger.info(`Best server found '${e.server}' ping: ${e.ping}ms`),yield this.createServer(e.server)}))}login(e=0){return n(this,void 0,void 0,(function*(){return this.isLoggedIn?this.walletId:(yield this.getJwtToken(),yield this.connect(),g.logger.info(`Network: ${this.loginParams.rede}`),yield(0,y.makeUniquePromise)(this.controller.login,(()=>this.sfs.send((0,v.makeLoginRequest)(this.loginParams))),e||this.timeout))}))}approveClaim(e,t=0){return n(this,void 0,void 0,(function*(){return this.ensureLoggedIn(),yield(0,y.makeUniquePromise)(this.controller.approveClaim,(()=>this.sfs.send((0,v.makeApproveClaim)(this.walletId,this.nextId(),e))),t||this.timeout)}))}activeBomber(e,t,i=0){return n(this,void 0,void 0,(function*(){return this.ensureLoggedIn(),yield(0,y.makeUniquePromise)(this.controller.activeBomber,(()=>this.sfs.send((0,v.makeActiveBomber)(this.walletId,this.nextId(),e,t))),i||this.timeout)}))}confirmClaimRewardSuccess(e,t=0){return n(this,void 0,void 0,(function*(){return this.ensureLoggedIn(),yield(0,y.makeUniquePromise)(this.controller.confirmClaimRewardSuccess,(()=>this.sfs.send((0,v.makeApproveConfirmClaimRewardSuccess)(this.walletId,this.nextId(),e))),t||this.timeout)}))}getPing(e){return n(this,void 0,void 0,(function*(){const t=process.hrtime();return yield r.default.get(`https://api.bombcrypto.io/ping/${e}`,{headers:this.apiBaseHeaders,http2:!0}),yield r.default.get(`https://api.bombcrypto.io/ping/${e}`,{headers:this.apiBaseHeaders,http2:!0}),{server:e,ping:(0,m.getDurationInMilliseconds)(t)}}))}getServerByPing(){return n(this,void 0,void 0,(function*(){return{server:"sea",ping:0}}))}logout(e=0){return n(this,void 0,void 0,(function*(){if(this.isLoggedIn)return yield(0,y.makeUniquePromise)(this.controller.logout,(()=>this.sfs.send(new a.LogoutRequest)),e||this.timeout)}))}getHeroUpgradePower(e=0){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.getHeroUpgradePower,(()=>{const e=(0,v.makeGetHeroUpgradePowerRequest)(this.walletId,this.nextId());this.sfs.send(e)}),e||this.timeout)}getBlockMap(e=0){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.getBlockMap,(()=>{const e=(0,v.makeGetBlockMapRequest)(this.walletId,this.nextId());this.sfs.send(e)}),e||this.timeout)}syncHouse(e=0){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.syncHouse,(()=>{const e=(0,v.makeSyncHouseRequest)(this.walletId,this.nextId());this.sfs.send(e)}),e||this.timeout)}activeHouse(e,t=0){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.activeHouse,(()=>{const t=(0,v.makeActiveHouseRequest)(e,this.walletId,this.nextId());this.sfs.send(t)}),t||this.timeout)}getActiveHeroes(e=0){return g.logger.info("Update list heroes..."),this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.getActiveHeroes,(()=>{const e=(0,v.makeGetActiveBomberRequest)(this.walletId,this.nextId());this.sfs.send(e)}),e||this.timeout)}syncBomberman(e=0){return g.logger.info("Update list heroes..."),this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.syncBomberman,(()=>{const e=(0,v.makeSyncBombermanRequest)(this.walletId,this.nextId());this.sfs.send(e)}),e||this.timeout)}startExplode(e,t=0){return this.ensureLoggedIn(),(0,y.makeSerializedPromise)(this.controller.startExplode,(()=>{const t=(0,v.makeStartExplodeRequest)(this.walletId,this.nextId(),e);this.sfs.send(t)}),t||this.timeout)}startExplodeV2(e,t=0){return this.ensureLoggedIn(),(0,y.makeSerializedPromise)(this.controller.startExplodeV2,(()=>{const t=(0,v.makeStartExplodeV2Request)(this.walletId,this.nextId(),e);this.sfs.send(t)}),t||this.timeout)}startStoryExplode(e,t=0){return this.ensureLoggedIn(),(0,y.makeSerializedPromise)(this.controller.startStoryExplode,(()=>{const t=(0,v.makeStartExplodeExplodeRequest)(this.walletId,this.nextId(),e);this.sfs.send(t)}),t||this.timeout)}enemyTakeDamage(e,t=0){return this.ensureLoggedIn(),(0,y.makeSerializedPromise)(this.controller.enemyTakeDamage,(()=>{const t=(0,v.makeEnemyTakeDamageRequest)(this.walletId,this.nextId(),e);this.sfs.send(t)}),t||this.timeout)}startPVE(e=0,t){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.startPVE,(()=>{const e=(0,v.makeStartPVERequest)(this.walletId,this.nextId(),t);this.sfs.send(e)}),e||this.timeout)}stopPVE(e=0){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.stopPVE,(()=>{const e=(0,v.makeStopPVERequest)(this.walletId,this.nextId());this.sfs.send(e)}),e||this.timeout)}ping(){this.ensureLoggedIn(),g.logger.info("Send ping to server");const e=(0,v.makePingPongRequest)(this.walletId,this.nextId());this.sfs.send(e)}sendTransactionWeb3({contract:e,dataTransaction:t,gasLimit:i}){return n(this,void 0,void 0,(function*(){const o=new Promise(((o,r)=>n(this,void 0,void 0,(function*(){var n;try{if(!("privateKey"in this.loginParams)||!(null===(n=this.loginParams)||void 0===n?void 0:n.privateKey))return!1;const a=this.web3.eth.accounts.privateKeyToAccount(this.loginParams.privateKey),s=yield this.web3.eth.getTransactionCount(a.address),l=yield(0,m.getGasPolygon)(),d={nonce:parseInt(this.web3.utils.toHex(s)),to:e.options.address,gasPrice:this.web3.utils.toHex(this.web3.utils.toWei(l.toString(),"gwei")),data:t.encodeABI()};i&&(d.gasLimit=this.web3.utils.toHex(i));const c=yield a.signTransaction(d);c.rawTransaction&&this.web3.eth.sendSignedTransaction(c.rawTransaction,((e,t)=>{if(g.logger.info("transaction hash: "+t),e)return r(e);const i=setInterval((()=>{this.web3.eth.getTransactionReceipt(t,((e,n)=>{try{if(e)return r(e);if(n)return n.status?(clearInterval(i),void o(n)):r("error transaction")}catch(e){return clearInterval(i),r(`${e.message}\n\nHash: ${t}`)}}))}),1e3)}))}catch(e){r(e)}}))));return(0,m.retryWeb3)(o)}))}poolBomb(){return n(this,void 0,void 0,(function*(){const e=new this.web3.eth.Contract([{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],this.web3.utils.toChecksumAddress(c.CONTRACT_BOMB)),t=yield e.methods.balanceOf(c.ADDRESS_BOMB).call();return this.web3.utils.fromWei(t,"ether")}))}web3Balance(e,t="ether"){return n(this,void 0,void 0,(function*(){const i=new this.web3.eth.Contract([{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],this.web3.utils.toChecksumAddress(e)),n=yield i.methods.balanceOf(this.loginParams.wallet).call();return this.web3.utils.fromWei(n,t)}))}web3GetRock(){return n(this,void 0,void 0,(function*(){if("user"==this.loginParams.type)return null;const e=new this.web3.eth.Contract(c.ABI_RESET_SHIELD_HERO,this.web3.utils.toChecksumAddress(c.CONTRACT_RESET_SHIELD));return yield e.methods.getTotalRockByUser(this.loginParams.wallet).call()}))}web3ResetShield({id:e,rockRepairShield:t}){return n(this,void 0,void 0,(function*(){const i=new this.web3.eth.Contract(c.ABI_RESET_SHIELD_HERO,this.web3.utils.toChecksumAddress(c.CONTRACT_RESET_SHIELD)),n=yield i.methods.resetShieldHeroS(this.web3.utils.toBN(e),this.web3.utils.toBN(t)).estimateGas({from:this.loginParams.wallet}),o=yield i.methods.resetShieldHeroS(this.web3.utils.toBN(e),this.web3.utils.toBN(t));return this.sendTransactionWeb3({contract:i,dataTransaction:o,gasLimit:n})}))}web3CreateRock(e){return n(this,void 0,void 0,(function*(){const t=new this.web3.eth.Contract(c.ABI_RESET_SHIELD_HERO,this.web3.utils.toChecksumAddress(c.CONTRACT_RESET_SHIELD)),i=yield t.methods.createRock(e.map((e=>this.web3.utils.toBN(e)))).estimateGas({from:this.loginParams.wallet}),n=yield t.methods.createRock(e.map((e=>this.web3.utils.toBN(e))));return this.sendTransactionWeb3({contract:t,gasLimit:i,dataTransaction:n})}))}web3CheckAllowance(e){return n(this,void 0,void 0,(function*(){const t=new this.web3.eth.Contract(c.ABI_BCOIN_TOKEN,this.web3.utils.toChecksumAddress(c.CONTRACT_BOMB)),i=yield(()=>n(this,void 0,void 0,(function*(){return yield t.methods.allowance(this.loginParams.wallet,c.CONTRACT_BHERO).call()})))(),o=this.web3.utils.toBN(e),r=this.web3.utils.toBN(i);if(o.lte(r))return;const a=this.web3.utils.toBN(10);yield(e=>n(this,void 0,void 0,(function*(){const i=this.web3.utils.toWei(e,"wei"),n=yield t.methods.increaseAllowance(c.CONTRACT_BHERO,i).estimateGas({from:this.loginParams.wallet}),o=yield t.methods.increaseAllowance(c.CONTRACT_BHERO,i);return yield this.sendTransactionWeb3({contract:t,gasLimit:2*n,dataTransaction:o})})))(o.mul(a).toString())}))}web3Mint(e){return n(this,void 0,void 0,(function*(){const t=this.web3.utils.toBN(e),i=this.web3.utils.toBN("10000000000000000000");yield this.web3CheckAllowance(i.mul(t).toString());const n=new this.web3.eth.Contract(c.ABI_RESET_SHIELD_HERO,this.web3.utils.toChecksumAddress(c.CONTRACT_RESET_SHIELD)),o=yield n.methods.mint(this.web3.utils.toBN(e),this.web3.utils.toBN(0)).estimateGas({from:this.loginParams.wallet}),r=yield n.methods.mint(this.web3.utils.toBN(e),this.web3.utils.toBN(0));return this.sendTransactionWeb3({contract:n,gasLimit:2*o,dataTransaction:r})}))}webGetProcessableTokens(){return n(this,void 0,void 0,(function*(){const e=new this.web3.eth.Contract(c.ABI_BHERO,this.web3.utils.toChecksumAddress(c.CONTRACT_BHERO));return(yield e.methods.getProcessableTokens(this.loginParams.wallet).call()).toString()}))}web3GetPendingTokensV2(){return n(this,void 0,void 0,(function*(){const e=new this.web3.eth.Contract(c.ABI_BHERO,this.web3.utils.toChecksumAddress(c.CONTRACT_BHERO)),t=yield e.methods.getPendingTokensV2(this.loginParams.wallet).call();return{pendingHeroes:parseInt(t[0]),pendingHeroesFusion:parseInt(t[1])}}))}web3ListenToFusionEvents(e,t){return n(this,void 0,void 0,(function*(){const i=this.loginParams.wallet;return new Promise(((n,o)=>{try{const o={fusionFailAmount:0,fusionSuccessAmount:0,fusionSuccessHeroIds:[]},r=()=>{o.fusionFailAmount+o.fusionSuccessAmount===e&&(t.events.FusionSuccess().off("data",s),t.events.FusionFailed().off("data",a),n(o))},a=(e,t)=>{if(e)return void console.error(e);const{returnValues:i}=t,n=parseInt(i.countFusionFailed);o.fusionFailAmount=n,r()},s=(e,t)=>{if(e)return void console.error(e);const{returnValues:i}=t,n=parseInt(i.countFusionSuccess),a=i.idHeroFusionSuccess.map((e=>parseInt(e))).filter((e=>0!==e));o.fusionSuccessAmount=n,o.fusionSuccessHeroIds=a,r()};e>0&&(t.once("FusionSuccess",{filter:{walletAddress:i}},s),t.once("FusionFailed",{filter:{walletAddress:i}},a)),r()}catch(e){o(e)}}))}))}web3MintProcessToken(){return n(this,void 0,void 0,(function*(){const e=parseInt(yield this.webGetProcessableTokens());for(;(yield this.web3GetPendingTokensV2()).pendingHeroes!==e;)yield(0,m.sleep)(2e3);const t=new this.web3.eth.Contract(c.ABI_BHEROS,this.web3.utils.toChecksumAddress(c.CONTRACT_BHERO)),i=yield t.methods.processTokenRequests().estimateGas({from:this.loginParams.wallet}),n=yield t.methods.processTokenRequests();return yield this.sendTransactionWeb3({contract:t,gasLimit:2*i,dataTransaction:n})}))}checkTransaction(e){return n(this,void 0,void 0,(function*(){return new Promise((t=>{this.web3.eth.getTransactionReceipt(e,((e,i)=>t(!!i)))}))}))}web3ApproveClaim({amount:e,details:t,nonce:i,signature:o,tokenType:r}){return n(this,void 0,void 0,(function*(){const n=new this.web3.eth.Contract(c.ABI_APPROVE_CLAIM,this.web3.utils.toChecksumAddress(c.CONTRACT_APPROVE_CLAIM)),a=yield n.methods.claimTokens(this.web3.utils.toBN(r),this.web3.utils.toWei(e.toString(),"ether"),this.web3.utils.toBN(i),t,o).estimateGas({from:this.loginParams.wallet}),s=n.methods.claimTokens(this.web3.utils.toBN(r),this.web3.utils.toWei(e.toString(),"ether"),this.web3.utils.toBN(i),t,o);return this.sendTransactionWeb3({contract:n,dataTransaction:s,gasLimit:a})}))}goSleep(e,t=0){return this.ensureLoggedIn(),(0,y.makeSerializedPromise)(this.controller.goSleep,(()=>{const t=(0,v.makeGoSleepRequest)(this.walletId,this.nextId(),e);this.sfs.send(t)}),t||this.timeout)}goHome(e,t=0){return this.ensureLoggedIn(),(0,y.makeSerializedPromise)(this.controller.goHome,(()=>{const t=(0,v.makeGoHomeRequest)(this.walletId,this.nextId(),e);this.sfs.send(t)}),t||this.timeout)}goWork(e,t=0){return this.ensureLoggedIn(),(0,y.makeSerializedPromise)(this.controller.goWork,(()=>{const t=(0,v.makeGoWorkRequest)(this.walletId,this.nextId(),e);this.sfs.send(t)}),t||this.timeout)}getReward(e=0){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.getReward,(()=>{const e=(0,v.makeGetRewardRequest)(this.walletId,this.nextId());this.sfs.send(e)}),e||this.timeout)}coinDetail(e=0){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.coinDetail,(()=>{const e=(0,v.makeCoinDetailRequest)(this.walletId,this.nextId());this.sfs.send(e)}),e||this.timeout)}getStoryDetails(e=0){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.getStoryDetails,(()=>{const e=(0,v.makeGetStoryLevelDetail)(this.walletId,this.nextId());this.sfs.send(e)}),e||this.timeout)}getStoryMap(e,t,i=0){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.getStoryMap,(()=>{const i=(0,v.makeGetStoryMap)(this.walletId,this.nextId(),e,t);this.sfs.send(i)}),i||this.timeout)}enterDoor(e=0){return this.ensureLoggedIn(),(0,y.makeUniquePromise)(this.controller.enterDoor,(()=>{const e=(0,v.makeEnterDoorRequest)(this.walletId,this.nextId());this.sfs.send(e)}),e||this.timeout)}wipe(){this.isConnected&&this.sfs.disconnect(),this.handlers={connection:[],connectionFailed:[],connectionLost:[],login:[],approveClaim:[],activeBomber:[],confirmClaimRewardSuccess:[],loginError:[],logout:[],getHeroUpgradePower:[],getBlockMap:[],syncHouse:[],activeHouse:[],getActiveBomber:[],syncBomberman:[],startPVE:[],ping:[],stopPVE:[],startExplode:[],startExplodeV2:[],startStoryExplode:[],enemyTakeDamage:[],goSleep:[],goHome:[],goWork:[],getReward:[],coinDetail:[],getStoryDetails:[],getStoryMap:[],enterDoor:[],messageError:[]},this.controller={connect:{current:void 0},disconnect:{current:void 0},login:{current:void 0},approveClaim:{current:void 0},activeBomber:{current:void 0},confirmClaimRewardSuccess:{current:void 0},logout:{current:void 0},getHeroUpgradePower:{current:void 0},getBlockMap:{current:void 0},syncHouse:{current:void 0},activeHouse:{current:void 0},getActiveHeroes:{current:void 0},syncBomberman:{current:void 0},startPVE:{current:void 0},stopPVE:{current:void 0},ping:{current:void 0},startExplode:{current:void 0,executors:[]},startExplodeV2:{current:void 0,executors:[]},startStoryExplode:{current:void 0,executors:[]},enemyTakeDamage:{current:void 0,executors:[]},goWork:{current:void 0,executors:[]},goSleep:{current:void 0,executors:[]},goHome:{current:void 0,executors:[]},getReward:{current:void 0},coinDetail:{current:void 0},getStoryDetails:{current:void 0},getStoryMap:{current:void 0},enterDoor:{current:void 0}},this.messageId=0}ensureLoggedIn(){if(!this.isLoggedIn)throw(0,h.makeException)("WrongUsage","Log in first")}nextId(){return this.messageId++}pushHandler(e,t){return e.push(t),()=>e.splice(e.indexOf(t),1)}callHandler(e,...t){e.forEach((e=>e(...t)))}handleConnection(e){return n(this,void 0,void 0,(function*(){if(e.success)yield(0,u.setConfig)(d.bot.getIdentify(),"lastServer",null),this.callHandler(this.handlers.connection),(0,y.resolveUniquePromise)(this.controller.connect,void 0);else{if(this.moreParams.tryServers){let e=(yield(0,u.getConfig)(d.bot.getIdentify(),"lastServer"))||{try:0,server:this.moreParams.server};if(e.try>=5){const t=c.SERVERS.filter((t=>t!=e.server)),i=t[Math.floor(Math.random()*t.length)];e={try:0,server:i}}e.try++,yield(0,u.setConfig)(d.bot.getIdentify(),"lastServer",e)}this.callHandler(this.handlers.connectionFailed),(0,y.rejectUniquePromise)(this.controller.connect,(0,h.makeException)("ConnectionFailed","Connection failed"))}}))}handleLogin(){this.callHandler(this.handlers.login)}handleLoginError({errorCode:e}){(0,y.rejectUniquePromise)(this.controller.login,(0,h.makeException)("LoginFailed",`Error code ${e}`)),this.callHandler(this.handlers.loginError,e)}handleUserLogin(){(0,y.resolveUniquePromise)(this.controller.login,void 0)}handleLogout(){(0,y.resolveUniquePromise)(this.controller.logout,void 0),this.callHandler(this.handlers.logout)}handleGetHeroUpgradePower(){(0,y.resolveUniquePromise)(this.controller.getHeroUpgradePower,void 0),this.callHandler(this.handlers.getHeroUpgradePower)}handleConnectionLost(){(0,y.resolveUniquePromise)(this.controller.disconnect,void 0),this.callHandler(this.handlers.connectionLost)}handleGetBlockMap(e){const t=e.getUtfString(this.modeAmazon?"datas_pve_v2":"datas_pve"),i=JSON.parse(t);(0,y.resolveUniquePromise)(this.controller.getBlockMap,i),this.callHandler(this.handlers.getBlockMap,i)}handleSyncBomberman(e){const t=e.getSFSArray("bombers"),i=e.getSFSArray("new_bombers"),n=Array(i.size()).fill(null).map(((e,t)=>i.getLong(t))),o=Array(t.size()).fill(null).map(((e,i)=>{const n=t.getSFSObject(i),o=n.getSFSArray("shields"),r=Array(o.size()),a=n.getSFSObject("data");return{shields:r.fill(null).map(((e,t)=>{const i=o.getSFSObject(t);return{current:i.getInt("current"),total:i.getInt("total"),ability:i.getInt("ability")}})),stage:n.getInt("stage"),id:n.getLong("id"),gen_id:n.getUtfString("gen_id"),energy:n.getInt("energy"),active:n.getInt("active"),heroType:a.getInt("hero_type"),skills:a.getIntArray("abilities"),restore_hp:n.getInt("restore_hp")}}));(0,y.resolveUniquePromise)(this.controller.syncBomberman,{newBombers:n,bombers:o}),this.callHandler(this.handlers.syncBomberman,{newBombers:n,bombers:o})}handleGetActiveHeroes(e){const t=e.getSFSArray("bombers"),i=Array(t.size()).fill(null).map(((e,i)=>{const n=t.getSFSObject(i),o=n.getSFSArray("shields");return{shields:Array(o.size()).fill(null).map(((e,t)=>{const i=o.getSFSObject(t);return{current:i.getInt("current"),total:i.getInt("total"),ability:i.getInt("ability")}})),stage:n.getInt("stage"),id:n.getLong("id"),gen_id:n.getUtfString("gen_id"),energy:n.getInt("energy"),heroType:n.getInt("hero_type")}}));(0,y.resolveUniquePromise)(this.controller.getActiveHeroes,i),this.callHandler(this.handlers.getActiveBomber,i)}handleStartExplode(e){const t=e.getLong("id"),i=e.getSFSArray("blocks"),n=Array(i.size()).fill(null).map(((e,t)=>{const n=i.getSFSObject(t),o=n.getSFSArray("rewards"),r=Array(o.size()).fill(null).map(((e,t)=>{const i=o.getSFSObject(t);return{type:i.getUtfString("type"),value:i.getFloat("value")}}));return{hp:n.getInt("hp"),i:n.getInt("i"),j:n.getInt("j"),rewards:r}})),o={id:t,energy:e.getInt("energy"),blocks:n};(0,y.resolveSerializedPromise)(this.controller.startExplode,o),this.callHandler(this.handlers.startExplode,o)}handleStartStoryExplode(e){const t=e.getSFSArray("blocks"),i=Array(t.size()).fill(null).map(((e,i)=>{const n=t.getSFSObject(i);return{i:n.getInt("i"),j:n.getInt("j")}})),n=e.getSFSArray("enemies"),o=Array(n.size()).fill(null).map(((e,t)=>{const i=n.getSFSObject(t);return{damage:i.getInt("damage"),maxHp:i.getFloat("maxHp"),skin:i.getInt("skin"),hp:i.getFloat("hp"),id:i.getInt("id"),follow:i.getBool("follow"),bombSkin:i.getInt("bombSkin"),speed:i.getFloat("speed"),throughBrick:i.getBool("throughBrick")}})),r={bombId:e.getLong("bombId"),blocks:i,enemies:o};(0,y.resolveSerializedPromise)(this.controller.startStoryExplode,r),this.callHandler(this.handlers.startStoryExplode,r)}handleEnemyTakeDamage(e){const t={damage:e.getInt("damage"),code:e.getInt("code"),hp:e.getFloat("hp"),id:e.getInt("id")};(0,y.resolveSerializedPromise)(this.controller.enemyTakeDamage,t),this.callHandler(this.handlers.enemyTakeDamage,t)}handleStartExplodeV2(e){const t=e.getLong("id"),i=e.getSFSArray("blocks"),n=Array(i.size()).fill(null).map(((e,t)=>{const n=i.getSFSObject(t),o=n.getSFSArray("rewards");let r=[];return o&&(r=Array(o.size()).fill(null).map(((e,t)=>{const i=o.getSFSObject(t);return{type:i.getUtfString("type"),value:i.getFloat("value")}}))),{hp:n.getInt("hp"),i:n.getInt("i"),j:n.getInt("j"),rewards:r}})),o={id:t,energy:e.getInt("energy"),blocks:n};(0,y.resolveSerializedPromise)(this.controller.startExplodeV2,o),this.callHandler(this.handlers.startExplodeV2,o)}handleStartPVE(){(0,y.resolveUniquePromise)(this.controller.startPVE,void 0),this.callHandler(this.handlers.startPVE)}handleStopPVE(){(0,y.resolveUniquePromise)(this.controller.stopPVE,void 0),this.callHandler(this.handlers.stopPVE)}handleGoSleep(e){const t={id:e.getLong("id"),energy:e.getInt("energy")};(0,y.resolveSerializedPromise)(this.controller.goSleep,t),this.callHandler(this.handlers.goSleep,t)}handleGoHome(e){const t={id:e.getLong("id"),energy:e.getInt("energy")};(0,y.resolveSerializedPromise)(this.controller.goHome,t),this.callHandler(this.handlers.goHome,t)}handleGoWork(e){const t={id:e.getLong("id"),energy:e.getInt("energy")};(0,y.resolveSerializedPromise)(this.controller.goWork,t),this.callHandler(this.handlers.goWork,t)}handleGetReward(e){const t=e.getSFSArray("rewards"),i=Array(t.size()).fill(null).map(((e,i)=>{const n=t.getSFSObject(i);return{remainTime:n.getInt("remain_time"),type:(0,p.parseRewardType)(n.getUtfString("type")),value:n.getFloat("value"),claimPending:n.getDouble("claimPending"),network:n.getUtfString("data_type")}}));(0,y.resolveUniquePromise)(this.controller.getReward,i),this.callHandler(this.handlers.getReward,i)}handleCoinDetail(e){const t={mined:e.getFloat("mined"),invested:e.getFloat("invested"),rewards:e.getFloat("rewards")};(0,y.resolveUniquePromise)(this.controller.coinDetail,t),this.callHandler(this.handlers.coinDetail,t)}handleGetStoryDetails(e){const t=e.getSFSArray("level_rewards"),i=Array(t.size()).fill(null).map(((e,i)=>{const n=t.getSFSObject(i);return{rare:n.getInt("rare"),replay:n.getFloat("replay"),first_win:n.getFloat("first_win")}})),n=e.getSFSArray("played_bombers"),o={level_rewards:i,played_bombers:Array(n.size()).fill(null).map(((e,t)=>{const i=n.getSFSObject(t);return{remaining_time:i.getLong("remaining_time"),id:i.getLong("id")}})),is_new:e.getBool("is_new"),max_level:e.getInt("max_level"),current_level:e.getInt("current_level"),hero_id:e.getLong("hero_id")};(0,y.resolveUniquePromise)(this.controller.getStoryDetails,o),this.callHandler(this.handlers.getStoryDetails,o)}handleGetStoryMap(e){const t=JSON.parse(e.getUtfString("positions")),i=e.getSFSArray("enemies"),n=Array(i.size()).fill(null).map(((e,t)=>{const n=i.getSFSObject(t);return{damage:n.getInt("damage"),maxHp:n.getFloat("maxHp"),skin:n.getInt("skin"),hp:n.getFloat("hp"),id:n.getInt("id"),follow:n.getBool("follow"),bombSkin:n.getInt("bombSkin"),speed:n.getFloat("speed"),throughBrick:n.getBool("throughBrick")}})),o=e.getSFSObject("hero"),r={maxHp:o.getInt("maxHp"),level:o.getInt("level"),stamina:o.getInt("stamina"),playercolor:o.getInt("playercolor"),active:o.getInt("active"),bombSkin:o.getInt("bombSkin"),speed:o.getInt("speed"),bombDamage:o.getInt("bombDamage"),genId:o.getUtfString("genId"),abilities:o.getIntArray("abilities"),bombRange:o.getInt("bombRange"),stage:o.getInt("stage"),playerType:o.getInt("playerType"),rare:o.getInt("rare"),heroType:o.getInt("hero_type"),bombNum:o.getInt("bombNum"),id:o.getLong("id")},a={positions:t,enemies:n,col:e.getInt("col"),door_x:e.getInt("door_x"),level:e.getInt("level"),row:e.getInt("row"),door_y:e.getInt("door_y"),ec:e.getInt("ec"),hero:r};(0,y.resolveUniquePromise)(this.controller.getStoryMap,a),this.callHandler(this.handlers.getStoryMap)}handleSyncHouse(e){const t=e.getSFSArray("houses"),i=Array(t.size()).fill(null).map(((e,i)=>{const n=t.getSFSObject(i);return{house_gen_id:n.getUtfString("house_gen_id"),active:n.getInt("active")}}));(0,y.resolveUniquePromise)(this.controller.syncHouse,i),this.callHandler(this.handlers.syncHouse,i)}handleApproveClaim(e){const t={amount:e.getDouble("amount"),signature:e.getUtfString("signature"),tokenType:e.getInt("tokenType"),nonce:e.getInt("nonce"),details:e.getUtfStringArray("details")};(0,y.resolveUniquePromise)(this.controller.approveClaim,t),this.callHandler(this.handlers.approveClaim,t)}handleConfirmClaimRewardSuccess(e){const t={received:e.getDouble("received")};(0,y.resolveUniquePromise)(this.controller.confirmClaimRewardSuccess,t),this.callHandler(this.handlers.confirmClaimRewardSuccess,t)}handleActiveHouse(){(0,y.resolveUniquePromise)(this.controller.activeHouse,void 0),this.callHandler(this.handlers.activeHouse)}handleActiveBomber(){(0,y.resolveUniquePromise)(this.controller.activeBomber,void 0),this.callHandler(this.handlers.activeBomber)}handleEnterDoor(e){const t={rewards:e.getFloat("rewards")};(0,y.resolveUniquePromise)(this.controller.enterDoor,t),this.callHandler(this.handlers.enterDoor)}handleMessageError(e,t){this.callHandler(this.handlers.messageError,e,t);const i=(0,h.makeException)("MessageError",`Failed with code ${t}`);switch(e){case"GET_BLOCK_MAP":return(0,y.rejectUniquePromise)(this.controller.getBlockMap,i);case"SYNC_HOUSE":return(0,y.rejectUniquePromise)(this.controller.syncHouse,i);case"ACTIVE_HOUSE":return(0,y.rejectUniquePromise)(this.controller.activeHouse,i);case"GET_ACTIVE_BOMBER":return(0,y.rejectUniquePromise)(this.controller.getActiveHeroes,i);case"ACTIVE_BOMBER":return(0,y.rejectUniquePromise)(this.controller.activeBomber,i);case"APPROVE_CLAIM":return(0,y.rejectUniquePromise)(this.controller.approveClaim,i);case"SYNC_BOMBERMAN":return(0,y.rejectUniquePromise)(this.controller.syncBomberman,i);case"START_EXPLODE":(0,y.resolveUniquePromise)(this.controller.startExplode,void 0);break;case"START_EXPLODE_V2":(0,y.resolveSerializedPromise)(this.controller.startExplodeV2,void 0),this.callHandler(this.handlers.startExplodeV2,void 0);break;case"START_STORY_EXPLODE":(0,y.resolveUniquePromise)(this.controller.startStoryExplode,void 0);break;case"ENEMY_TAKE_DAMAGE":(0,y.resolveUniquePromise)(this.controller.enemyTakeDamage,void 0);break;case"USER_LOGIN":return(0,y.rejectUniquePromise)(this.controller.login,i);case"START_PVE":return(0,y.rejectUniquePromise)(this.controller.startPVE,i);case"STOP_PVE":return(0,y.rejectUniquePromise)(this.controller.stopPVE,i);case"GO_SLEEP":return(0,y.rejectSerializedPromise)(this.controller.goSleep,i);case"GO_HOME":(0,y.resolveUniquePromise)(this.controller.goHome,void 0);break;case"GO_WORK":return(0,y.rejectSerializedPromise)(this.controller.goWork,i);case"GET_REWARD":return(0,y.rejectUniquePromise)(this.controller.getReward,i);case"COIN_DETAIL":return(0,y.rejectUniquePromise)(this.controller.coinDetail,i);case"GET_HERO_UPGRADE_POWER":return(0,y.rejectUniquePromise)(this.controller.getHeroUpgradePower,i);case"GET_STORY_LEVEL_DETAIL":return(0,y.rejectUniquePromise)(this.controller.getStoryDetails,i);case"GET_STORY_MAP":return(0,y.rejectUniquePromise)(this.controller.getStoryMap,i);case"ENTER_DOOR":return(0,y.rejectUniquePromise)(this.controller.enterDoor,i)}}connectEvents(){this.sfs.addEventListener(a.SFSEvent.EXTENSION_RESPONSE,this.handleExtentionResponse,this),this.sfs.addEventListener(a.SFSEvent.LOGIN,this.handleLogin,this),this.sfs.addEventListener(a.SFSEvent.LOGIN_ERROR,this.handleLoginError,this),this.sfs.addEventListener(a.SFSEvent.LOGOUT,this.handleLogout,this),this.sfs.addEventListener(a.SFSEvent.CONNECTION,this.handleConnection,this),this.sfs.addEventListener(a.SFSEvent.CONNECTION_LOST,this.handleConnectionLost,this),(0,m.askAndParseEnv)("DEBUG",m.parseBoolean,!1)&&(this.sfs.logger.level=a.LogLevel.DEBUG,this.sfs.logger.enableConsoleOutput=!0,this.sfs.logger.enableEventDispatching=!0,this.sfs.logger.addEventListener(a.LoggerEvent.INFO,g.logger.info,g.logger),this.sfs.logger.addEventListener(a.LoggerEvent.ERROR,g.logger.error,g.logger),this.sfs.logger.addEventListener(a.LoggerEvent.WARNING,g.logger.warning,g.logger),this.sfs.logger.addEventListener(a.LoggerEvent.DEBUG,g.logger.debug,g.logger))}handleExtentionResponse(e){const t=e.params,i=t.getInt("ec");if(t.containsKey("ec"),t.containsKey("ec")&&0!==i)return this.handleMessageError(e.cmd,i);switch(e.cmd){case"GET_BLOCK_MAP":return this.handleGetBlockMap(e.params);case"SYNC_HOUSE":return this.handleSyncHouse(e.params);case"ACTIVE_HOUSE":return this.handleActiveHouse();case"ACTIVE_BOMBER":return this.handleActiveBomber();case"GET_ACTIVE_BOMBER":return this.handleGetActiveHeroes(e.params);case"APPROVE_CLAIM":return this.handleApproveClaim(e.params);case"CONFIRM_CLAIM_REWARD_SUCCESS":return this.handleConfirmClaimRewardSuccess(e.params);case"SYNC_BOMBERMAN":return this.handleSyncBomberman(e.params);case"START_EXPLODE":return this.handleStartExplode(e.params);case"START_EXPLODE_V2":return this.handleStartExplodeV2(e.params);case"START_STORY_EXPLODE":return this.handleStartStoryExplode(e.params);case"ENEMY_TAKE_DAMAGE":return this.handleEnemyTakeDamage(e.params);case"START_PVE":return this.handleStartPVE();case"STOP_PVE":return this.handleStopPVE();case"GO_SLEEP":return this.handleGoSleep(e.params);case"GO_WORK":return this.handleGoWork(e.params);case"GO_HOME":return this.handleGoHome(e.params);case"USER_LOGIN":return this.handleUserLogin();case"GET_REWARD":return this.handleGetReward(e.params);case"COIN_DETAIL":return this.handleCoinDetail(e.params);case"GET_HERO_UPGRADE_POWER":return this.handleGetHeroUpgradePower();case"GET_STORY_LEVEL_DETAIL":return this.handleGetStoryDetails(e.params);case"GET_STORY_MAP":return this.handleGetStoryMap(e.params);case"ENTER_DOOR":return this.handleEnterDoor(e.params)}console.warn("Unmapped command: ",e)}}},8799:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Database=void 0;const r=i(496),a=i(4464),s=i(9303),l=i(8832),d=i(8433),c=i(6625),u=i(6197),h=i(8172),m=i(8957),g=i(609),p=o(i(2897)),y=o(i(6274)),v=o(i(8988)),f=o(i(1786));class E{constructor(e){this.identify=e}static getDb(){return this.db||(this.db=new a.Sequelize({dialect:"sqlite",storage:"./database.sqlite",logging:!1,models:[s.Config,l.HeroShield,d.HeroZeroShield,c.LastResetShield,u.MapEntity,h.Report,m.Rewards],transactionType:r.Transaction.TYPES.IMMEDIATE})),this.db}static runMigrations(){return n(this,void 0,void 0,(function*(){g.logger.info("Checking if there are migrations to run on the database");const e=yield E.getDb(),t=[p.default,y.default,v.default,f.default];yield e.getQueryInterface().sequelize.query("CREATE TABLE IF NOT EXISTS `SequelizeMeta` (`name` VARCHAR(255))");const i=(yield e.query("SELECT * FROM `SequelizeMeta`",{type:r.QueryTypes.SELECT})).map((e=>e.name)),n=t.filter((e=>!i.includes(e.name)));n.length&&g.logger.info("Running migrations");for(const t of n)yield t.up(e.getQueryInterface(),a.Sequelize),yield e.query("INSERT INTO `SequelizeMeta` VALUES(:name)",{type:r.QueryTypes.INSERT,replacements:{name:t.name}})}))}static sync(){return n(this,void 0,void 0,(function*(){}))}}t.Database=E},766:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=t.ENCRYPTION=void 0;const o=n(i(5666));t.ENCRYPTION="aes-256-cbc",t.encrypt=e=>o.default.AES.encrypt(e,t.ENCRYPTION).toString(),t.decrypt=e=>o.default.AES.decrypt(e,t.ENCRYPTION).toString(o.default.enc.Utf8)},2934:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),o(i(3365),t)},2665:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Notification=void 0;const o=i(341),r=i(8832),a=i(8433),s=i(5937),l=i(6686),d=i(8646);t.Notification=class{constructor(e){this.db=e}setHeroShield(e,t){return(0,l.updateOrCreateHeroShield)(o.bot.getIdentify(),e,t)}setMaterial(e){return(0,s.setConfig)(o.bot.getIdentify(),"materialAlert",e)}setHeroZeroShield(e,t){return(0,d.updateOrCreateHeroZeroShield)(o.bot.getIdentify(),e,t)}hasHeroShield(e){return n(this,void 0,void 0,(function*(){return yield r.HeroShield.findOne({where:{hero:e,identify:o.bot.getIdentify()}})}))}hasMaterial(){return n(this,void 0,void 0,(function*(){return yield(0,s.getConfig)(o.bot.getIdentify(),"materialAlert")}))}hasHeroZeroShield(e){return n(this,void 0,void 0,(function*(){const t=yield a.HeroZeroShield.findOne({where:{identify:o.bot.getIdentify(),hero:e}});return Boolean(t)}))}checkHeroShield(e,t){return n(this,void 0,void 0,(function*(){const i=yield r.HeroShield.findOne({where:{hero:e,identify:o.bot.getIdentify()}});i&&t>i.shield&&(yield i.destroy());const n=yield a.HeroZeroShield.findOne({where:{hero:e,identify:o.bot.getIdentify()}});null!==n&&t>0&&(yield n.destroy())}))}}},7224:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rejectUniquePromise=t.resolveUniquePromise=t.makeUniquePromise=t.rejectSerializedPromise=t.resolveSerializedPromise=t.makeSerializedPromise=t.ControlledPromise=void 0;const n=i(3622);class o{constructor(e,t=0){this.finished=!1,this.orig=new Promise(((i,n)=>{this.resolveFn=i,this.rejectFn=n,e&&this.init(e,t)}))}get promise(){return this.orig}get settled(){return this.finished}init(e,t=0){try{if(e(),t<=0)return;const i="Promise timed out",o=(0,n.makeException)("PromiseTimeout",i);this.timeoutId=setTimeout(this.rejectFn.bind(this,o),t)}catch(e){this.clearTimeout(),this.rejectFn(e)}}resolve(e){this.resolveFn(e),this.clearTimeout(),this.finished=!0}reject(e){this.rejectFn(e),this.clearTimeout(),this.finished=!0}clearTimeout(){this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=void 0}}function r(e){if(e.current&&!e.current.settled)return;e.current=void 0;const t=e.executors.shift();t&&(e.current=t.promise,t.promise.init(t.starter,t.timeout))}t.ControlledPromise=o,t.makeSerializedPromise=function(e,t,i=0){const n=new o;return e.executors.push({starter:t,promise:n,timeout:i}),n.promise.finally((()=>r(e))),r(e),n.promise},t.resolveSerializedPromise=function(e,t){var i;null===(i=e.current)||void 0===i||i.resolve(t)},t.rejectSerializedPromise=function(e,t){var i;null===(i=e.current)||void 0===i||i.reject(t)},t.makeUniquePromise=function(e,t,i=0){return e.current&&!e.current.settled||(e.current=new o(t,i),e.current.promise.finally((()=>{e.current=void 0}))),e.current.promise},t.resolveUniquePromise=function(e,t){var i;null===(i=e.current)||void 0===i||i.resolve(t)},t.rejectUniquePromise=function(e,t){var i;null===(i=e.current)||void 0===i||i.reject(t)}},1877:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.makeEnterDoorRequest=t.makeEnemyTakeDamageRequest=t.makeStartExplodeExplodeRequest=t.makeGetStoryMap=t.makeGetStoryLevelDetail=t.makeStartExplodeV2Request=t.makeStartExplodeRequest=t.makeGoWorkRequest=t.makeGoHomeRequest=t.makeActiveHouseRequest=t.makeGoSleepRequest=t.makeGetActiveBomberRequest=t.makeCoinDetailRequest=t.makeGetRewardRequest=t.makeSyncHouseRequest=t.makeApproveConfirmClaimRewardSuccess=t.makeActiveBomber=t.makeApproveClaim=t.makeStopPVERequest=t.makeStartPVERequest=t.makeSyncBombermanRequest=t.makeLoginRequest=t.makeLoginSignature=t.makeGetHeroUpgradePowerRequest=t.makeGetBlockMapRequest=t.makePingPongRequest=void 0;const o=i(5699),r=n(i(8519)),a=i(272),s=i(5911);t.makePingPongRequest=function(e,t){return(0,s.makeGameMessage)(e,"PING_PONG",t)},t.makeGetBlockMapRequest=function(e,t){return(0,s.makeGameMessage)(e,"GET_BLOCK_MAP",t)},t.makeGetHeroUpgradePowerRequest=function(e,t){return(0,s.makeGameMessage)(e,"GET_HERO_UPGRADE_POWER",t)},t.makeLoginSignature=function(e,t){return(new r.default).eth.accounts.sign(t,e).signature},t.makeLoginRequest=function(e){return e.type,(0,s.makeLoginMessage)(e.wallet,e.wallet,e.token,e.rede,e.version,"",1)},t.makeSyncBombermanRequest=function(e,t){return(0,s.makeGameMessage)(e,"SYNC_BOMBERMAN",t)},t.makeStartPVERequest=function(e,t,i){const n=new o.SFSObject;return n.putUtfString("slogan","gold_miner"),n.putInt("mode",i?3:1),(0,s.makeGameMessage)(e,"START_PVE",t,n)},t.makeStopPVERequest=function(e,t){const i=new o.SFSObject;return i.putUtfString("slogan","stick_war"),(0,s.makeGameMessage)(e,"STOP_PVE",t,i)},t.makeApproveClaim=function(e,t,i){const n=new o.SFSObject;return n.putInt("block_reward_type",i),(0,s.makeGameMessage)(e,"APPROVE_CLAIM",t,n)},t.makeActiveBomber=function(e,t,i,n){const r=new o.SFSObject;return r.putLong("id",i.id),r.putInt("active",n),r.putInt("account_type",0),r.putInt("hero_type",i.heroType),(0,s.makeGameMessage)(e,"ACTIVE_BOMBER",t,r)},t.makeApproveConfirmClaimRewardSuccess=function(e,t,i){const n=new o.SFSObject;return n.putInt("block_reward_type",i),(0,s.makeGameMessage)(e,"CONFIRM_CLAIM_REWARD_SUCCESS",t,n)},t.makeSyncHouseRequest=function(e,t){return(0,s.makeGameMessage)(e,"SYNC_HOUSE",t)},t.makeGetRewardRequest=function(e,t){return(0,s.makeGameMessage)(e,"GET_REWARD",t)},t.makeCoinDetailRequest=function(e,t){return(0,s.makeGameMessage)(e,"COIN_DETAIL",t)},t.makeGetActiveBomberRequest=function(e,t){return(0,s.makeGameMessage)(e,"GET_ACTIVE_BOMBER",t)},t.makeGoSleepRequest=function(e,t,{id:i,heroType:n}){const r=new o.SFSObject;return r.putLong("id",i),r.putInt("account_type",0),r.putInt("hero_type",n),(0,s.makeGameMessage)(e,"GO_SLEEP",t,r)},t.makeActiveHouseRequest=function(e,t,i){const n=new o.SFSObject;return n.putInt("house_id",e),(0,s.makeGameMessage)(t,"ACTIVE_HOUSE",i,n)},t.makeGoHomeRequest=function(e,t,{id:i,heroType:n}){const r=new o.SFSObject;return r.putLong("id",i),r.putInt("account_type",0),r.putInt("hero_type",n),(0,s.makeGameMessage)(e,"GO_HOME",t,r)},t.makeGoWorkRequest=function(e,t,{id:i,heroType:n}){const r=new o.SFSObject;return r.putLong("id",i),r.putInt("account_type",0),r.putInt("hero_type",n),(0,s.makeGameMessage)(e,"GO_WORK",t,r)},t.makeStartExplodeRequest=function(e,t,i){const n=new o.SFSObject,r=new o.SFSArray;return n.putLong("id",i.heroId),n.putInt("num",i.bombId),n.putInt("i",i.i),n.putInt("j",i.j),i.blocks.forEach((e=>{const t=new o.SFSObject;t.putInt("i",e.i),t.putInt("j",e.j),r.addSFSObject(t)})),n.putSFSArray("blocks",r),(0,s.makeGameMessage)(e,"START_EXPLODE",t,n)},t.makeStartExplodeV2Request=function(e,t,i){const n=new o.SFSObject,r=new o.SFSArray;return n.putLong("id",i.heroId),n.putInt("num",i.bombId),n.putInt("i",i.i),n.putInt("j",i.j),n.putInt("account_type",0),n.putInt("hero_type",i.hero_type),i.blocks.forEach((e=>{const t=new o.SFSObject;t.putInt("i",e.i),t.putInt("j",e.j),r.addSFSObject(t)})),n.putSFSArray("blocks",r),(0,s.makeGameMessage)(e,"START_EXPLODE_V2",t,n)},t.makeGetStoryLevelDetail=function(e,t){return(0,s.makeGameMessage)(e,"GET_STORY_LEVEL_DETAIL",t)},t.makeGetStoryMap=function(e,t,i,n){const r=new o.SFSObject;return r.putInt("level",n),r.putLong("hero_id",i),r.putInt("ticket_type",0),r.putUtfString("slogan","bomb_squad"),(0,s.makeGameMessage)(e,"GET_STORY_MAP",t,r)},t.makeStartExplodeExplodeRequest=function(e,t,i){const n=new o.SFSObject,r=new o.SFSArray,l=(0,a.currentTimeSinceAD)();return n.putInt("id",i.heroId),n.putBool("is_hero",i.isHero),n.putLong("bombId",l),n.putInt("i",i.i),n.putInt("j",i.j),n.putInt("account_type",0),i.blocks.forEach((e=>{const t=new o.SFSObject;t.putInt("i",e.i),t.putInt("j",e.j),r.addSFSObject(t)})),n.putSFSArray("blocks",r),(0,s.makeGameMessage)(e,"START_STORY_EXPLODE",t,n)},t.makeEnemyTakeDamageRequest=function(e,t,i){let[,n]=(0,s.hashGameMessage)(e,"ENEMY_TAKE_DAMAGE",t);"string"==typeof n&&(n=parseInt(n));const r=new o.SFSObject;return r.putLong("timestamp",n),r.putLong("hero_id",i.heroId),r.putInt("enemy_id",i.enemyId),(0,s.makeGameMessage)(e,"ENEMY_TAKE_DAMAGE",t,r)},t.makeEnterDoorRequest=function(e,t){const i=new o.SFSObject;return i.putUtfString("slogan","card_game"),(0,s.makeGameMessage)(e,"ENTER_DOOR",t,i)}},8941:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Telegram=void 0;const o=i(4146),r=i(832),a=i(8396),s=i(6197),l=i(8172),d=i(5937),c=i(8727),u=i(272),h=i(609),m=i(2863),g=i(5862),p=i(9581),y=i(7970),v=i(4375),f=i(6778),E=i(6615),_=i(7632),b=i(4391),S=i(4070),R=i(6464),T=i(9300),w=i(9822);t.Telegram=class{constructor(e){this.subItem="┃ ┣",this.subLastItem=" ┣",this.subItemLast="┃ ┗",this.subLastItemLast=" ┗",this.item="┣",this.lastItem="┗",this.bot=e}init(){var e,t,i,o,a,s,l,c,u,m,g,A,I,C,H,M,k,O,N,L,P,x,W,D,B,$,G,F,q,j;return n(this,void 0,void 0,(function*(){try{if(!this.bot.params.telegramKey)return;h.logger.info("Starting telegraf..."),this.telegraf=new r.Telegraf(this.bot.params.telegramKey);const U=new r.Scenes.Stage([w.sceneResetShield,E.sceneDeactivateHero,p.sceneActivateHero,S.scenePutHeroWork,f.sceneCreateMaterial,v.sceneConfig,v.sceneConfigServer,v.sceneConfigPercentage,y.sceneAddAccount,R.sceneRemoveAccount,v.sceneConfigHouseHeroes,v.sceneConfigNumHeroes,v.sceneConfigTelegramChatId,v.sceneConfigResetShieldAuto,v.sceneConfigMaxGasRepairShield,v.sceneConfigAlertShield,v.sceneConfigAlertMaterial,T.sceneRemoveDatabase,b.sceneMInt]);this.telegraf.use((0,r.session)()),this.telegraf.use(U.middleware()),null===(e=this.telegraf)||void 0===e||e.command("stats",(e=>this.checkChatId(e,(()=>this.telegramStats(e)),"/stats"))),null===(t=this.telegraf)||void 0===t||t.command("rewards_all",(e=>this.checkChatId(e,(()=>this.telegramRewardsAll(e)),"/rewards_all"))),null===(i=this.telegraf)||void 0===i||i.command("rewards",(e=>this.checkChatId(e,(()=>this.telegramRewards(e)),"/rewards"))),null===(o=this.telegraf)||void 0===o||o.command("exit",(e=>this.checkChatId(e,(()=>this.telegramExit(e)),"/exit"))),null===(a=this.telegraf)||void 0===a||a.command("start",(e=>this.checkChatId(e,(()=>this.telegramStart(e)),"/start"))),null===(s=this.telegraf)||void 0===s||s.command("start_calc_farm",(e=>this.checkChatId(e,(()=>this.telegramStartCalcFarm(e)),"/start_calc_farm"))),null===(l=this.telegraf)||void 0===l||l.command("stop_calc_farm",(e=>this.checkChatId(e,(()=>this.telegramStopCalcFarm(e)),"/stop_calc_farm"))),null===(c=this.telegraf)||void 0===c||c.command("current_calc_farm",(e=>this.checkChatId(e,(()=>this.telegramStopCalcFarm(e,!1)),"/current_calc_farm"))),null===(u=this.telegraf)||void 0===u||u.command("shield",(e=>this.checkChatId(e,(()=>this.telegramStatsShield(e)),"/shield"))),null===(m=this.telegraf)||void 0===m||m.command("test_msg",(e=>this.checkChatId(e,(()=>this.telegramTestMsg(e)),"/test_msg"))),null===(g=this.telegraf)||void 0===g||g.command("config",(e=>this.checkChatId(e,(()=>this.telegramConfig(e)),"/config"))),null===(A=this.telegraf)||void 0===A||A.command("withdraw",(e=>this.checkChatId(e,(()=>this.telegramWithdraw(e)),"/withdraw"))),null===(I=this.telegraf)||void 0===I||I.command("gas_polygon",(e=>this.checkChatId(e,(()=>this.telegramAverageGasPolygon(e)),"/gas_polygon"))),null===(C=this.telegraf)||void 0===C||C.command("wallet",(e=>this.checkChatId(e,(()=>this.telegramWallet(e)),"/wallet"))),null===(H=this.telegraf)||void 0===H||H.command("serial",(e=>this.checkChatId(e,(()=>this.telegramSerial(e)),"/serial"))),null===(M=this.telegraf)||void 0===M||M.command("pool",(e=>this.checkChatId(e,(()=>this.telegramPool(e)),"/pool"))),null===(k=this.telegraf)||void 0===k||k.command("reset_shield",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_RESET_SHIELD)),"/reset_shield"))),null===(O=this.telegraf)||void 0===O||O.command("deactivate_hero",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_DEACTIVATE_HERO)),"/deactivate_hero"))),null===(N=this.telegraf)||void 0===N||N.command("activate_hero",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_ACTIVATE_HERO)),"/activate_hero"))),null===(L=this.telegraf)||void 0===L||L.command("put_hero_work",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_PUT_HERO_WORK)),"/put_hero_work"))),null===(P=this.telegraf)||void 0===P||P.command("create_material",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_CREATE_MATERIAL)),"/create_material"))),null===(x=this.telegraf)||void 0===x||x.command("list_heroes",(e=>this.checkChatId(e,(()=>this.telegramListHeroes(e)),"/list_heroes"))),null===(W=this.telegraf)||void 0===W||W.command("put_all_heroes_work",(e=>this.checkChatId(e,(()=>this.telegramPutAllHeroes(e)),"/list_heroes"))),null===(D=this.telegraf)||void 0===D||D.command("remove_database",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_REMOVE_DATABASE)),"/remove_database"))),null===(B=this.telegraf)||void 0===B||B.command("change_config",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_CHANGE_CONFIG)),"/change_config"))),null===($=this.telegraf)||void 0===$||$.command("add_account",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_ADD_ACCOUNT)),"/add_account"))),null===(G=this.telegraf)||void 0===G||G.command("remove_account",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_REMOVE_ACCOUNT)),"/remove_account"))),null===(F=this.telegraf)||void 0===F||F.command("remove_database",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_REMOVE_DATABASE)),"/remove_database"))),null===(q=this.telegraf)||void 0===q||q.command("mint",(e=>this.checkChatId(e,(()=>e.scene.enter(_.SCENE_MINT)),"/mint")));const z=[{command:"exit",description:"exit"},{command:"start",description:"start"},{command:"rewards",description:"rewards"},{command:"rewards_all",description:"rewards_all"},{command:"shield",description:"shield"},{command:"stats",description:"stats"},{command:"start_calc_farm",description:"start_calc_farm"},{command:"config",description:"config"},{command:"stop_calc_farm",description:"stop_calc_farm"},{command:"current_calc_farm",description:"current_calc_farm"},{command:"test_msg",description:"test_msg"},{command:"gas_polygon",description:"gas_polygon"},{command:"withdraw",description:"withdraw"},{command:"wallet",description:"wallet"},{command:"reset_shield",description:"reset_shield"},{command:"deactivate_hero",description:"deactivate_hero"},{command:"activate_hero",description:"activate_hero"},{command:"list_heroes",description:"list_heroes"},{command:"put_hero_work",description:"put_hero_work"},{command:"pool",description:"pool"},{command:"create_material",description:"create_material"},{command:"change_config",description:"change_config"},{command:"add_account",description:"add_account"},{command:"remove_account",description:"remove_account"},{command:"remove_database",description:"remove_database"},{command:"serial",description:"serial"},{command:"put_all_heroes_work",description:"put_all_heroes_work"},{command:"mint",description:"mint"}],V=yield(0,d.getConfig)(this.bot.getIdentify(),"telegramCommands");if(Date.now()>V+18e5){yield(0,d.setConfig)(this.bot.getIdentify(),"telegramCommands",Date.now());const e=z.filter((e=>!this.bot.params.ignoreCommands.includes(e.command)));yield this.telegraf.telegram.setMyCommands(e,{language_code:"en"}),yield this.telegraf.telegram.setMyCommands(e,{language_code:"pt"})}this.telegraf.catch((e=>{console.error(e),process.exit(1)})),this.telegraf.launch({dropPendingUpdates:!0});const Y=setInterval((()=>n(this,void 0,void 0,(function*(){var e;try{null===(e=this.telegraf)||void 0===e||e.stop(),setTimeout((()=>{var e;null===(e=this.telegraf)||void 0===e||e.launch()}),1e4)}catch(e){setTimeout((()=>{var e;null===(e=this.telegraf)||void 0===e||e.launch()}),1e4)}}))),18e4);process.once("SIGINT",(()=>{var e;null===(e=this.telegraf)||void 0===e||e.stop("SIGINT"),clearInterval(Y)})),process.once("SIGTERM",(()=>{var e;null===(e=this.telegraf)||void 0===e||e.stop("SIGTERM"),clearInterval(Y)})),this.bot.params.telegramChatId.length&&(this.owner=yield null===(j=this.telegraf)||void 0===j?void 0:j.telegram.getChat(this.bot.params.telegramChatId[0]))}catch(e){console.log(e)}}))}checkChatId(e,t,i){var o,r,a;return n(this,void 0,void 0,(function*(){const{ignoreCommands:n}=this.bot.params;if(!n.includes(i)){if(!(Date.now()/1e3-((null===(o=e.message)||void 0===o?void 0:o.date)||0)>=30)){if(this.bot.params.telegramChatId.length){const t=(0,u.getChatId)(e);if(this.bot.params.telegramChatIdCheck&&!this.bot.params.telegramChatId.includes(t.toString()))return yield e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nYou do not have permission. your Telegram Chat Id is different from what was informed in the settings`),void(yield this.sendMessageChat(`one person tried to run this command: ${i}\n\n${JSON.stringify(null===(a=e.update)||void 0===a?void 0:a.message.from,null,4)}`))}return t(e)}h.logger.info(`Ignoring message ${null===(r=e.message)||void 0===r?void 0:r.message_id}`)}}))}addAccount(e,t){return n(this,void 0,void 0,(function*(){const e=(e,i)=>e in t&&1==t[e]?{[i]:1}:{};let i="";i="wallet"==t.login?`${t.wallet}:${t.privateKey}`:`${t.username}:${t.password}`,h.logger.info(`Creating account ${t.identify}`);const n=Object.assign(Object.assign(Object.assign({LOGIN:`${t.login}:${i}`,TELEGRAM_KEY:t.telegramKey,SERIAL:t.serial,NETWORK:t.network,MIN_HERO_ENERGY_PERCENTAGE:t.percentageWork,HOUSE_HEROES:t.houseHeroes,ALERT_SHIELD:t.alertShield,NUM_HERO_WORK:t.numHeroWork,SERVER:t.server,REPORT_REWARDS:t.reportRewards||"0",TELEGRAM_CHAT_ID:t.telegramChatId,MAX_GAS_REPAIR_SHIELD:t.maxGasRepairShield||"0",ALERT_MATERIAL:t.alertMaterial||"0",IGNORE_COMMANDS:((null==t?void 0:t.ignoreCommands)||[]).join(":"),IDENTIFY:t.identify},e("resetShieldAuto","RESET_SHIELD_AUTO")),e("ignoreNumHeroWork","IGNORE_NUM_HERO_WORK")),e("telegramChatIdCheck","TELEGRAM_CHAT_ID_CHECK")),o=yield(0,d.addAccount)(n);if(!o)throw new Error("account already exists");yield(0,g.startAccountPm2)(o)}))}telegramConfig(e){return n(this,void 0,void 0,(function*(){const{rede:t,alertShield:i,houseHeroes:n,minHeroEnergyPercentage:o,numHeroWork:r,server:a,telegramChatId:s,telegramKey:l,resetShieldAuto:d,ignoreNumHeroWork:c,alertMaterial:u,version:h,maxGasRepairShield:m,reportRewards:g,telegramChatIdCheck:p}=this.bot.params,{type:y}=this.bot.loginParams,v=e=>e?"Yes":"No",f=`Account: ${this.bot.getIdentify()}\n\n<b>Network</b>: ${t}\n<b>Alert shield</b>: ${i}\n<b>Heroes select at home</b>: ${n.split(":").join(", ")}\n<b>Percentage of hero life to work</b>: ${o}%\n<b>Qty of heroes to work</b>: ${r}\n<b>Server</b>: ${a}\n<b>Telegram chat ID</b>: ${s.join(", ")}\n<b>Telegram KEY</b>: ${l}\n<b>Check telegram chat id</b>: ${v(p)}\n<b>Alert material</b>: ${u}\n<b>Max gas reset shield</b>: ${m||"No"}\n<b>Report rewards</b>: ${g?g+" min":"No"}\n<b>Auto reset shield</b>: ${v(d)}\n<b>Ignore qty hero work</b>: ${v(c)}\n<b>Type login</b>: ${y}\n<b>Bomb version</b>: ${h}`;e.replyWithHTML(f)}))}telegramStats(e){return n(this,void 0,void 0,(function*(){if(!this.bot.shouldRun)return void(yield e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nAccount not working`));const t=yield this.getStatsAccount();yield e.replyWithHTML(t)}))}getColor({rarityIndex:e}){return["⚪","🟢","🔵","🟣","🟡","🔴"][e]}telegramListHeroes(e){return n(this,void 0,void 0,(function*(){const t=(e,t,i)=>{var n;const o=t==i-1,r=(null===(n=e.shields)||void 0===n?void 0:n.length)?`${e.shields[0].current}/${e.shields[0].total}`:"empty shield";return`${o?this.lastItem:this.item} ${this.getColor(e)} ${e.raritySimbol} [${e.id}] Shield: ${r}`},i=(0,u.sortByRarityDesc)(this.bot.squad.activeHeroes),n=(0,u.sortByRarityDesc)(this.bot.squad.inactiveHeroes),o=i.map(((e,n)=>t(e,n,i.length))).join("\n"),r=n.map(((e,i)=>t(e,i,n.length))).join("\n");return this.sendMessage(e,`Total heroes: ${i.length+n.length}\n\nActive heroes (${i.length}):\n${o}\n\nDeactivated heroes (${n.length}):\n${r}`)}))}telegramPutAllHeroes(e){return n(this,void 0,void 0,(function*(){const t=this.bot.squad.notWorking,i=(e,t,i)=>`${t==i-1?this.lastItem:this.item} ${this.getColor(e)} ${e.raritySimbol} [${e.id}]`;t.map((e=>this.bot.toWork(e)));const n=t.map(((e,n)=>i(e,n,t.length))).join("\n");return this.sendMessage(e,`Heroes put to work: ${t.length}\n${n}`)}))}sendMessage(e,t){return n(this,void 0,void 0,(function*(){for(const i of(0,u.str_split)(t,4e3)){if(!i)return;yield e.replyWithHTML(i)}}))}getStatsAccount(){return n(this,void 0,void 0,(function*(){const e=(e,t,i)=>{var n;const o=t==i-1,r=this.bot.houseHeroes.includes(e.id.toString()),a=(null===(n=e.shields)||void 0===n?void 0:n.length)?`${e.shields[0].current}/${e.shields[0].total}`:"empty shield",s=o?this.lastItem:this.item;return r?`${s} ${this.getColor(e)} <b>${e.raritySimbol} [${e.id}] ${e.energy}/${e.maxEnergy} | ${a}</b>`:`${s} ${this.getColor(e)} ${e.raritySimbol} [${e.id}] ${e.energy}/${e.maxEnergy} | ${a}`},t=(0,u.sortByEnergyAsc)(this.bot.workingSelection).map(((t,i)=>e(t,i,this.bot.workingSelection.length))).join("\n"),i=(0,u.sortByEnergyAsc)(this.bot.sleepingSelection).map(((t,i)=>e(t,i,this.bot.sleepingSelection.length))).join("\n"),n=(0,u.sortByEnergyAsc)(this.bot.homeSelection).map(((t,i)=>e(t,i,this.bot.homeSelection.length))).join("\n");let o="\n";"Adventure"===this.bot.playing&&(o=`Total enemies adventure: ${this.bot.adventureEnemies.filter((e=>e.hp>0)).length}/${this.bot.adventureEnemies.length}\n\n`);const r=this.bot.houseHeroes.join(", "),a=this.bot.map.formatMsgBlock().join("\n");return`Account: ${this.bot.getIdentify()}\n\nPlaying mode: ${this.bot.getStatusPlaying()}\n\n`+o+`Network: ${this.bot.client.loginParams.rede}\nTreasure/Amazon:\n`+`${this.bot.map.toString()}\n`+`Heroes selected for home(${this.bot.houseHeroes.length}): ${r}\n\n`+`📦 Remaining chest: \n${a}\n\n`+`👷♂️ Working heroes (${this.bot.workingSelection.length}): \n${t}\n\n`+`🛌 Resting heroes (${this.bot.sleepingSelection.length}): \n${i}\n\n`+`🏘 Resting heroes at home (${this.bot.homeSelection.length}): \n${n}`}))}getTotalHeroZeroShield(e){return Object.keys(e).filter((e=>-1!==e.indexOf("heroZeroShield"))).length}telegramRewardsAll(e){return n(this,void 0,void 0,(function*(){const{rewardsAllPermission:t}=this.bot.params,i=yield(0,c.getAllRewards)(),n=`\n<b>Rewards</b>\n\nBcoin | Bomberman | heroes with zero shield | time last update UTC 0\n\n${i.filter((e=>e.rewards)).filter((({account:e})=>0==t.length||t.length&&t.includes(e.identify))).map((({account:e,rewards:t},n)=>{var o,r;const a=new Date(t[0].date),s=e.identify,l=this.getTotalHeroZeroShield(e),d=null===(o=t.find((t=>t.network==e.NETWORK&&"BCoin"==t.type)))||void 0===o?void 0:o.value.toFixed(2),c=(null===(r=t.find((t=>t.network==e.NETWORK&&"Bomberman"==t.type)))||void 0===r?void 0:r.value)||"0",u=`${a.getHours()}:${a.getMinutes().toString().padStart(2,"0")}`,h=i.length-1==n,m=h?this.lastItem:this.item,g=h?this.subLastItem:this.subItem;return`${m} <b>${s}</b>\n${g} Bomb: ${d}\n${g} Bomberman: ${c}\n${g} Zero Shield: ${l}\n${h?this.subLastItemLast:this.subItemLast} Date: ${u}`})).join("\n")}`;this.sendMessage(e,n)}))}telegramRewards(e){return n(this,void 0,void 0,(function*(){try{const t=yield this.getRewardAccount();yield e.replyWithHTML(t)}catch(t){yield e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nNot connected, please wait`)}}))}sendRewardReport(e){return n(this,void 0,void 0,(function*(){try{const t=yield this.getRewardAccount();yield this.sendMessageChat(t),yield(0,d.setConfig)(this.bot.getIdentify(),"lastReport",e)}catch(e){yield this.sendMessageChat(`Account: ${this.bot.getIdentify()}\n\nNot connected, please wait`)}}))}getRewardAccount(){return n(this,void 0,void 0,(function*(){if(this.bot.client.isConnected){const e=yield this.bot.client.getReward(),{ignoreRewardCurrency:t}=this.bot.params;let i="Account: "+this.bot.getIdentify()+"\n\nRewards:\n"+e.filter((e=>e.network==this.bot.params.rede||"TR"==e.network)).filter((e=>!t.includes(e.type))).sort(((e,t)=>e.network>t.network?-1:1)).map((e=>`${e.network}-${e.type}: ${(0,m.isFloat)(e.value)?e.value.toFixed(2):e.value}`)).join("\n");return"wallet"==this.bot.loginParams.type&&(i+=`\nMaterial: ${yield this.bot.client.web3GetRock()}`),i}throw new Error("Not connected, please wait")}))}telegramExit(e){var t;return n(this,void 0,void 0,(function*(){if(!this.bot.isResettingShield)throw yield e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nExiting in 10 seconds...`),yield this.bot.sleepAllHeroes(),this.bot.shouldRun=!1,yield null===(t=this.telegraf)||void 0===t?void 0:t.stop("SIGINT"),yield(0,u.sleep)(1e4),yield(0,d.setConfig)(this.bot.getIdentify(),"start",0),new Error("exit");yield e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nIt is not possible to finalize at the moment, there is a web3 transaction being executed at the moment`)}))}telegramStart(e){var t;return n(this,void 0,void 0,(function*(){if(1===(yield(0,d.getConfig)(this.bot.getIdentify(),"start")))return yield e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nYour account is already working, nothing will be done`);throw yield(0,d.setConfig)(this.bot.getIdentify(),"start",1),yield e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nstarting...`),yield null===(t=this.telegraf)||void 0===t?void 0:t.stop("SIGINT"),yield(0,u.sleep)(5e3),new Error("exit")}))}telegramStatsShield(e){return n(this,void 0,void 0,(function*(){if(!this.bot.shouldRun)return void(yield e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nAccount not working`));const t=yield this.bot.client.web3GetRock(),i=this.bot.squad.activeHeroes,n=(e,t)=>{var n;const o=(null===(n=e.shields)||void 0===n?void 0:n.length)?`${e.shields[0].current}/${e.shields[0].total}`:"empty shield";return`${t==i.length-1?this.lastItem:this.item} ${this.getColor(e)} ${e.raritySimbol} [${e.id}]: ${o}`};let o="Account not connected, wait the bot will try to connect again";if(i&&i.length){const e=i.sort(((e,t)=>{var i,n;return(e.shields?null===(i=e.shields[0])||void 0===i?void 0:i.current:0)-(t.shields?null===(n=t.shields[0])||void 0===n?void 0:n.current:0)})).map(n).join("\n");o=`Account: ${this.bot.getIdentify()}\n\n🛡Shield heroes (${i.length}): \n${e}`,null!==t&&(o+=`\n\nMaterial:${t}`)}e.replyWithHTML(o)}))}getTotalMap(e){return n(this,void 0,void 0,(function*(){return(yield s.MapEntity.findAll({where:{identify:this.bot.getIdentify()}})).filter((t=>t.date>=e)).length}))}telegramStopCalcFarm(e,t=!0){return n(this,void 0,void 0,(function*(){if(!this.bot.shouldRun||!this.bot.client.isLoggedIn)return void(yield e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nAccount not working`));const i=yield this.bot.currentCalcFarm();if(!i)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nFarm calculation was not previously started`);const n=i.start.date,r=i.current.date,a=i.start.bcoin,d=i.current.bcoin,c=d-a,h=yield this.getTotalMap(n),m=(0,o.differenceInMinutes)(r,n),g=m/60;if(0==m)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nwait at least 1 minute`);t&&(yield l.Report.destroy({where:{identify:this.bot.getIdentify()}}),yield s.MapEntity.destroy({where:{identify:this.bot.getIdentify()}}));let p=h/m,y=c/m,v=`Total minutes: ${m.toFixed(2)}\nAverage per minute: ${y.toFixed(2)}\nAverage per day: ${(1440*y).toFixed(2)}\nAverage map per minute: ${p.toFixed(2)}`;g>1&&(y=c/g,p=h/g,v=`Total hours: ${g.toFixed(2)}\nAverage per hour: ${y.toFixed(2)}\nAverage per day: ${(24*y).toFixed(2)}\nAverage map per hour: ${p.toFixed(2)}`);const f=`Account: ${this.bot.getIdentify()}\n\nDate start: ${(0,u.formatDate)(new Date(n))}\nDate end: ${(0,u.formatDate)(new Date(r))}\n\nBcoin start: ${a.toFixed(2)}\nBcoin end: ${d.toFixed(2)}\n\nTotal bcoin: ${c.toFixed(2)}\nTotal maps: ${h}\n\n`+v;e.replyWithHTML(f)}))}telegramCheckVersion(){return n(this,void 0,void 0,(function*(){return!0}))}telegramAverageGasPolygon(e){return n(this,void 0,void 0,(function*(){const t=yield this.bot.getAverageWeb3Transaction(),i=`Account: ${this.bot.getIdentify()}\n\nThe values below are an average of how much it would cost right now\n\nClaim: ${t.claim.toFixed(4)}\nReset Shield: ${t.resetShield.toFixed(4)}\nMint 1 hero: ${t.mint1.toFixed(4)}\nMint 5 heroes: ${t.mint5.toFixed(4)}\nMint 10 heroes: ${t.mint10.toFixed(4)}\nMint 15 heroes: ${t.mint15.toFixed(4)}`;e.replyWithHTML(i)}))}telegramWallet(e){return n(this,void 0,void 0,(function*(){if("user"==this.bot.loginParams.type)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nFunctionality only allowed when logging in with the wallet`);const t=yield this.bot.getWalletBalance(),i=`Account: ${this.bot.getIdentify()}\n\nMATIC: ${parseFloat(t.matic).toFixed(2)}\nUSDT: ${parseFloat(t.usdt).toFixed(2)}\nBOMB: ${parseFloat(t.bomb).toFixed(2)}\n`;e.replyWithHTML(i)}))}telegramSerial(e){return n(this,void 0,void 0,(function*(){const t=yield this.bot.getSerial(),i=`Account: ${this.bot.getIdentify()}\n\nSerial: ${t.serial}\nDate: ${(0,u.formatDate)(new Date(t.date))}`;e.replyWithHTML(i)}))}telegramPool(e){return n(this,void 0,void 0,(function*(){const t=yield this.bot.client.poolBomb(),i=`Account : ${this.bot.getIdentify()}\n\nPool Bomb: ${parseFloat(t).toFixed(2)}`;e.replyWithHTML(i)}))}telegramDeactivateHero(e,t){return n(this,void 0,void 0,(function*(){this.bot.isFarming=!1,yield e.replyWithHTML(`Deactivating hero ${t.id}`),this.bot.isHeroFarming&&(h.logger.info("Waiting for the heroes to finish farming"),yield e.replyWithHTML("Waiting for the heroes to finish farming")),yield this.bot.awaitHeroFarm(),yield this.bot.client.activeBomber(t,0),yield this.bot.client.syncBomberman(),yield e.replyWithHTML(`Deactivated hero ${t.id}`),this.bot.setIsFarmTrue()}))}telegramActivateHero(e,t){return n(this,void 0,void 0,(function*(){this.bot.isFarming=!1,yield e.replyWithHTML(`Activating hero ${t.id}`),this.bot.isHeroFarming&&(h.logger.info("Waiting for the heroes to finish farming"),yield e.replyWithHTML("Waiting for the heroes to finish farming")),yield this.bot.awaitHeroFarm(),yield this.bot.client.activeBomber(t,1),yield this.bot.client.syncBomberman(),yield e.replyWithHTML(`Activated hero ${t.id}`),this.bot.setIsFarmTrue()}))}telegramResetShield(e,t){return n(this,void 0,void 0,(function*(){try{const{maxGasRepairShield:i}=this.bot.params,n=this.bot.squad.activeHeroes.find((e=>e.id==t));if(!n)return;if(!this.bot.client.isConnected)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nAccount not connected, please wait`);if(this.bot.isResettingShield)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nThere is already another hero resetting the shield at the moment`);if("user"==this.bot.loginParams.type)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nFunctionality only allowed when logging in with the wallet`);if("POLYGON"!=this.bot.loginParams.rede)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nFunctionality only allowed for POLYGON`);if(!(yield this.bot.web3Ready()))return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nyou currently have an ongoing transaction in your wallet`);const o=yield this.bot.client.web3GetRock(),r=yield this.bot.getAverageWeb3Transaction();if(n.rockRepairShield>o)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nNot enough material, needed ${n.rockRepairShield}, you have ${o}`);if(i>0&&r.resetShield>i)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nYou configured to spend a maximum of ${i} on the transaction, at the moment ${r.resetShield} is being charged`);yield this.bot.resetShield(n),this.bot.setIsFarmTrue()}catch(t){e.replyWithHTML(t.message)}}))}telegramWithdraw(e){return n(this,void 0,void 0,(function*(){try{if("user"==this.bot.loginParams.type)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nFunctionality only allowed when logging in with the wallet`);if("POLYGON"!=this.bot.loginParams.rede)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nFunctionality only allowed for POLYGON`);if(!(yield this.bot.web3Ready()))return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nyou currently have an ongoing transaction in your wallet`);const t=yield this.bot.client.poolBomb(),i=(yield this.bot.getReward()).find((e=>e.network==this.bot.loginParams.rede&&"BCoin"==e.type));if(!i)return;const n=i.value+i.claimPending;if(parseFloat(t)<n)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nBomb reward pool is empty: ${parseFloat(t).toFixed(4)}`);if(n<40)return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nMinimum amount of 40 bcoin`);e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nStarting withdraw ${n}`),yield this.telegramStopCalcFarm(e,!0);const o=yield this.bot.client.approveClaim(a.BLOCK_REWARD_TYPE_BCOIN_POLYGON);if((yield this.bot.client.web3ApproveClaim(o)).status){yield(0,u.sleep)(5e3);const{received:t}=yield this.bot.client.confirmClaimRewardSuccess(a.BLOCK_REWARD_TYPE_BCOIN_POLYGON);e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nYou withdraw ${t} Bcoin`),yield this.telegramStartCalcFarm(e)}else e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nfailed`);e.replyWithAnimation("https://lh6.ggpht.com/_Iaq7cCYNnH4/TY-ZmL3uLII/AAAAAAAAAFY/cbB7U-W7F_M/s740/Kog1K.gif")}catch(t){return e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nError: ${t.message}`)}}))}telegramTestMsg(e){return n(this,void 0,void 0,(function*(){yield e.replyWithHTML('if you receive message below "ARROMBADO", it means that your TELEGRAM_CHAT_ID is working, TELEGRAM_CHAT_ID: '+this.bot.params.telegramChatId),this.sendMessageChat("ARROMBADO")}))}telegramStartCalcFarm(e){return n(this,void 0,void 0,(function*(){if(!this.bot.shouldRun||!this.bot.client.isLoggedIn)return void(yield e.replyWithHTML(`Account: ${this.bot.getIdentify()}\n\nAccount not working`));const t=yield this.bot.startCalcFarm(),i=`Account: ${this.bot.getIdentify()}\n\nThis command is for you to see a farm calculation from this moment on\n\nDate: ${(0,u.formatDate)(new Date(t.date))}\nBcoin: ${t.bcoin.toFixed(2)}\n\nto terminate and see the final result, type /stop_calc_farm`;e.replyWithHTML(i)}))}sendMessageChat(e){return n(this,void 0,void 0,(function*(){const{telegramChatId:t}=this.bot.params;t.length&&(yield Promise.all(t.map((t=>{var i;return null===(i=this.telegraf)||void 0===i?void 0:i.telegram.sendMessage(t,`Account: ${this.bot.getIdentify()}\n\n${e}`)}))))}))}createButtonsHero(e,t){return e.map((e=>{const i=`${t.includes(e.id.toString())?"✅":""} ${this.getColor(e)} ${e.raritySimbol} [${e.id}]`;return r.Markup.button.callback(i,e.id.toString())}))}formatHero(e){return`${this.getColor(e)} ${e.rarity} [${e.id}]\n${this.item} 💣 bombs: ${e.capacity}\n${this.item} 💪 power: ${e.damage}\n${this.item} 🏹 range: ${e.range}\n${this.item} ⚡️ stamina: ${e.stamina}\n${this.lastItem} 👟 speed: ${e.speed}`}}},7074:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TreasureMapBot=void 0;const r=i(2934),a=i(8396),s=i(272),l=i(609),d=o(i(6452)),c=i(8799),u=i(766),h=i(2665),m=i(8941),g=i(9303),p=i(8433),y=i(6625),v=i(6197),f=i(8172),E=i(5937),_=i(8957),b=i(2483),S=i(2863),R=i(5862);t.TreasureMapBot=class{constructor(e,t){this.heroBombs={},this.forceExit=!0,this.adventureBlocks=[],this.adventureEnemies=[],this.houseHeroes=[],this.adventureHeroes=[],this.playing=null,this.isResettingShield=!1,this.isActivateHero=!1,this.lastTransactionWeb3="";const{forceExit:i=!0,minHeroEnergyPercentage:n=90,tryServers:o=!1,modeAmazon:s=!1,houseHeroes:l="",adventureHeroes:d="",modeAdventure:u=!1,saveRewardsCsv:g=!1,resetShieldAuto:p=!1,telegramChatIdCheck:y=!1,ignoreNumHeroWork:v=!1,ignoreShieldHeroHouse:f=!1,reportRewards:E=0,serial:_,ignoreCommands:S=[],workHeroWithShield:R=0,rede:T="BSC",version:w=a.VERSION_CODE,alertShield:A=0,alertMaterial:I=0,maxGasRepairShield:C=0,numHeroWork:H=15,server:M="sea",telegramChatId:k=[],rewardsAllPermission:O=[],telegramKey:N="",identify:L="",ignoreRewardCurrency:P=[]}=t;if(this.params={forceExit:i,minHeroEnergyPercentage:n,modeAmazon:!0,tryServers:o,houseHeroes:l,serial:_,adventureHeroes:d,modeAdventure:u,saveRewardsCsv:g,rede:T,version:w,alertShield:A,numHeroWork:H,server:M,ignoreCommands:S,workHeroWithShield:R,telegramChatId:k,telegramKey:N,telegramChatIdCheck:y,ignoreShieldHeroHouse:f,resetShieldAuto:p,rewardsAllPermission:O,maxGasRepairShield:C,ignoreNumHeroWork:v,alertMaterial:I,reportRewards:E,identify:L,ignoreRewardCurrency:P},!this.params.serial)throw new Error("Serial is required");this.loginParams=e,e.rede=T,e.version=w,this.db=new c.Database(this.getIdentify()),this.playing=null,this.client=new r.Client(e,12e4,s,this.params),this.map=new b.TreasureMap({blocks:[]}),this.squad=new b.Squad({heroes:[]}),this.houses=[],this.forceExit=i||!0,this.houseHeroes=l?l.split(":"):[],this.adventureHeroes=d?d.split(":"):[],this.minHeroEnergyPercentage=n,this.explosionByHero=new Map,this.heroBombs={},this.locationByHeroWorking=new Map,this.notificationShieldHero=new Map,this.selection=[],this.history=[],this.index=0,this.shouldRun=!1,this.isCreatingMaterial=!1,this.isFarming=!1,this.isMinting=!1,this.isHeroFarming=!1,this.lastAdventure=0,this.alertShield=A,this.notification=new h.Notification(this.db),this.telegram=new m.Telegram(this)}stop(){var e,t;return n(this,void 0,void 0,(function*(){l.logger.info("Send sleeping heros..."),this.shouldRun=!1,yield(0,s.sleep)(5e3);for(const e of this.workingSelection)yield this.client.goSleep(e);null===(t=null===(e=this.telegram)||void 0===e?void 0:e.telegraf)||void 0===t||t.stop()}))}getCurrentCalcFarm(){var e;return n(this,void 0,void 0,(function*(){const t=yield this.getReward();return{date:(new Date).getTime(),bcoin:(null===(e=t.find((e=>e.network==this.params.rede&&"BCoin"==e.type)))||void 0===e?void 0:e.value)||0}}))}startCalcFarm(){return n(this,void 0,void 0,(function*(){const e=yield this.getCurrentCalcFarm();return yield f.Report.create({identify:this.getIdentify(),bcoin:e.bcoin,date:e.date}),e}))}currentCalcFarm(){return n(this,void 0,void 0,(function*(){const e=yield f.Report.findOne({where:{identify:this.getIdentify()}});return e?{current:yield this.getCurrentCalcFarm(),start:e}:null}))}getStatusPlaying(){return"sleep"===this.playing?"sleep for 10 seconds":null===this.playing?"starting":this.playing}getStatsAccount(){return n(this,void 0,void 0,(function*(){const e=e=>{var t;const i=this.houseHeroes.includes(e.id.toString()),n=(null===(t=e.shields)||void 0===t?void 0:t.length)?`${e.shields[0].current}/${e.shields[0].total}`:"empty shield";return i?`<b>${e.rarity} [${e.id}]: ${e.energy}/${e.maxEnergy} | ${n}</b>`:`${e.rarity} [${e.id}]: ${e.energy}/${e.maxEnergy} | ${n}`},t=this.workingSelection.map(e).join("\n"),i=this.sleepingSelection.map(e).join("\n"),n=this.homeSelection.map(e).join("\n");let o="\n";"Adventure"===this.playing&&(o=`Total enemies adventure: ${this.adventureEnemies.filter((e=>e.hp>0)).length}/${this.adventureEnemies.length}\n\n`);const r=this.houseHeroes.join(", ");return`Account: ${this.getIdentify()}\n\nPlaying mode: ${this.getStatusPlaying()}\n\n`+o+`Network: ${this.client.loginParams.rede}\nTreasure/Amazon:\n`+`${this.map.toString()}\n`+`Heroes selected for home(${this.houseHeroes.length}): ${r}\n`+`Remaining chest (Amazon): \n${this.map.formatMsgBlock().join("\n")}\n\nINFO: LIFE HERO | SHIELD HERO\n`+`Working heroes (${this.workingSelection.length}): \n${t}\n\n`+`Resting heroes (${this.sleepingSelection.length}): \n${i}\n\n`+`Resting heroes at home (${this.homeSelection.length}): \n${n}`}))}getRewardAccount(){return n(this,void 0,void 0,(function*(){if(this.client.isConnected){const e=yield this.client.getReward();return"Account: "+this.getIdentify()+"\n\nRewards:\n"+e.filter((e=>e.network==this.params.rede||"TR"==e.network)).sort(((e,t)=>e.network>t.network?-1:1)).map((e=>`${e.network}-${e.type}: ${(0,S.isFloat)(e.value)?e.value.toFixed(2):e.value}`)).join("\n")}throw new Error("Not connected, please wait")}))}get workingSelection(){return this.selection.filter((e=>"Work"===e.state&&e.energy>0))}get notWorkingSelection(){return this.squad.notWorking}get sleepingSelection(){return this.squad.sleeping}get homeSelection(){return this.squad.home}get home(){return this.houses.filter((e=>e.active))[0]}get homeSlots(){var e;return(null===(e=this.home)||void 0===e?void 0:e.slots)||0}nextId(){return this.index++}nextHero(){return this.workingSelection[this.nextId()%this.workingSelection.length]}logIn(){return n(this,void 0,void 0,(function*(){this.client.isLoggedIn||(l.logger.info("Logging in..."),yield this.client.connectServer(),this.reset(),yield this.client.login(),l.logger.info("Logged in successfully"),yield(0,E.setConfig)(this.getIdentify(),"wallet",this.client.loginParams.wallet))}))}saveRewards(){return n(this,void 0,void 0,(function*(){if(!this.params.saveRewardsCsv)return;l.logger.info("Save rewards in csv...");let e="nameuser";"username"in this.client.loginParams?e=this.client.loginParams.username:"wallet"in this.client.loginParams&&(e=this.client.loginParams.wallet);const t=`./csv/${e}.csv`,i=yield this.client.getReward(),n=yield(0,s.getFromCsv)(t),o=[],r={};i.map((e=>{const t=e.type;r[t]=e.value.toString(),o.push({id:t,title:t})})),n.push(r),yield(0,s.writeCsv)(t,n,o)}))}getAverageWeb3Transaction(){return n(this,void 0,void 0,(function*(){const e=yield(0,s.getGasPolygon)();return{claim:107115*e*1e-9,resetShield:61983*e*1e-9,mint1:376802*e*1e-9+219016*e*1e-9,mint5:578116*e*1e-9+181996*e*1e-9,mint10:1111150*e*1e-9+181996*e*1e-9,mint15:1584771*e*1e-9+181996*e*1e-9}}))}getWalletBalance(){return n(this,void 0,void 0,(function*(){const[e,t,i]=yield Promise.all([this.client.web3Balance(a.CONTRACT_BOMB),this.client.web3Balance(a.CONTRACT_MATIC),this.client.web3Balance(a.CONTRACT_USDT,"mwei")]);return{bomb:e,matic:t,usdt:i}}))}refreshHeroAtHome(){return n(this,void 0,void 0,(function*(){const{ignoreShieldHeroHouse:e,modeAmazon:t}=this.params,i=this.squad.notWorking.filter((i=>!t||e||t&&i.shields&&i.shields.length&&this.getSumShield(i))).sort(((e,t)=>+this.houseHeroes.includes(t.id.toString())-+this.houseHeroes.includes(e.id.toString())||t.rarityIndex-e.rarityIndex)).slice(0,this.homeSlots);l.logger.info(`Will send heroes home (${this.homeSlots} slots)`);for(const e of i){if("Home"===e.state)continue;const t=this.squad.byState("Home");if(this.houseHeroes.includes(e.id.toString())||t.length<this.homeSlots)if(t.length<this.homeSlots)l.logger.info(`Sending hero ${e.id} home`),yield this.client.goHome(e);else{const i=t.find((e=>!this.houseHeroes.includes(e.id.toString())));i&&(l.logger.info(`Removing hero ${i.id} from home`),yield this.client.goSleep(i),l.logger.info(`Sending hero ${e.id} home`),yield this.client.goHome(e))}}}))}getSumShield(e){var t;return(null===(t=e.shields)||void 0===t?void 0:t.map((e=>e.current)).reduce(((e,t)=>e+t),0))||0}alertShieldHero(e){return n(this,void 0,void 0,(function*(){(yield this.notification.hasHeroShield(e.id))||(this.telegram.sendMessageChat(`Hero ${e.id} needs shield repair`),this.notification.setHeroShield(e.id,this.getSumShield(e))),l.logger.info(`Hero ${e.id} needs shield repair`)}))}alertMaterial(e){return n(this,void 0,void 0,(function*(){(yield this.notification.hasMaterial())||(this.telegram.sendMessageChat("You need more material"),this.notification.setMaterial(e))}))}alertShielZerodHero(e){return n(this,void 0,void 0,(function*(){(yield this.notification.hasHeroZeroShield(e.id))||(this.telegram.sendMessageChat(`Hero ${e.id} has 0 shield`),this.notification.setHeroZeroShield(e.id,0))}))}toWork(e){return n(this,void 0,void 0,(function*(){l.logger.info(`Sending hero ${e.id} to work`),yield this.client.goWork(e),this.selection.push(e)}))}refreshHeroSelection(){return n(this,void 0,void 0,(function*(){l.logger.info("Refreshing heroes"),yield this.client.syncBomberman();const{ignoreNumHeroWork:e,numHeroWork:t,workHeroWithShield:i}=this.params;this.selection=this.squad.byState("Work");const n=this.squad.notWorking.sort(((e,t)=>{const i=e.energy/e.maxEnergy*100;return t.energy/t.maxEnergy*100-i||t.rarityIndex-e.rarityIndex}));for(const o of n){yield(0,s.sleep)(500);const n=o.energy/o.maxEnergy*100;!o.shields||0===o.shields.length||this.getSumShield(o)<=0||(i>0&&this.getSumShield(o)<=i&&o.energy>=50?this.toWork(o):n<this.minHeroEnergyPercentage||(this.workingSelection.length<=t-1||e&&n>=100)&&this.toWork(o))}l.logger.info(`Sent ${this.selection.length} heroes to work`),yield this.refreshHeroAtHome()}))}getReward(){return n(this,void 0,void 0,(function*(){const e=yield this.client.getReward();return yield _.Rewards.destroy({where:{identify:this.getIdentify()}}),e.map((e=>n(this,void 0,void 0,(function*(){return yield _.Rewards.create({identify:this.getIdentify(),date:(new Date).getTime(),remainTime:e.remainTime,type:e.type,value:e.value,claimPending:e.claimPending,network:e.network})})))),e}))}refreshMap(){return n(this,void 0,void 0,(function*(){l.logger.info("Refreshing map..."),this.map.totalLife<=0&&(this.resetState(),l.logger.info(JSON.stringify(yield this.getReward()))),yield this.client.getBlockMap(),l.logger.info(`Current map state: ${this.map.toString()}`)}))}nextLocation(e){const t=this.locationByHeroWorking.get(e.id),i=this.map.getHeroDamageForMap(e).find((({tile:e})=>e.i==(null==t?void 0:t.tile.i)&&e.j==(null==t?void 0:t.tile.j)));if(t&&i&&i.damage>0)return t;const n=this.map.getHeroDamageForMap(e).filter((({damage:e})=>e>0));let o;return o=n.length<=5?n[0]:n.filter((({tile:e})=>!this.history.find((t=>t.i===e.i&&t.j===e.j))))[0],o||(o=n[0]),this.locationByHeroWorking.set(e.id,o),o}tete(e,t){var i;const n=this.explosionByHero.get(e.id);if(!n)return!0;const o=Math.abs(t.i-n.tile.i)+Math.abs(t.j-n.tile.j),r=Date.now()-n.timestamp,a=(null===(i=this.heroBombs[e.id])||void 0===i?void 0:i.ids.length)||0;return r>=(0,s.timedelta)(o,e)&&a<e.capacity}removeBombHero(e,t){e.id in this.heroBombs||(this.heroBombs[e.id]={ids:[],lastId:0});const i=this.heroBombs[e.id];this.heroBombs[e.id].ids=i.ids.filter((e=>e!==t))}addBombHero(e){e.id in this.heroBombs||(this.heroBombs[e.id]={ids:[],lastId:0});const t=this.heroBombs[e.id];return t.lastId++,t.lastId>e.capacity&&(t.lastId=1),t.ids.push(t.lastId),t}placeBomb(e,t){return n(this,void 0,void 0,(function*(){const i=this.addBombHero(e);if(this.locationByHeroWorking.delete(e.id),this.explosionByHero.set(e.id,{timestamp:Date.now(),tile:t}),this.nextLocation(e),!i)return!1;const n=i.lastId;this.history.push(t),l.logger.info(`${e.rarity} ${e.id} ${e.energy}/${e.maxEnergy} will place bomb on (${t.i}, ${t.j})`);const o=yield this.client.startExplodeV2({heroId:e.id,bombId:n,hero_type:e.heroType,blocks:[],i:t.i,j:t.j});if(this.removeBombHero(e,n),!o)return!1;const{energy:r}=o;for(;this.history.length>5;)this.history.shift();r<=0&&(l.logger.info(`Sending hero ${e.id} to sleep`),yield this.client.goSleep(e),yield this.refreshHeroSelection(),yield this.refreshHeroAtHome())}))}placeBombsHero(e){return n(this,void 0,void 0,(function*(){const t=this.nextLocation(e);t&&this.tete(e,t.tile)&&(yield this.placeBomb(e,t.tile))}))}placeBombs(){return n(this,void 0,void 0,(function*(){const e={},t=[];for(;this.map.totalLife>0&&this.workingSelection.length>0&&this.shouldRun&&this.isFarming;){this.isHeroFarming=!0;for(const i of this.workingSelection){yield(0,s.sleep)(70),e[i.id]=i;const n=this.placeBombsHero(i).catch((e=>{throw e}));t.push(n)}}yield Promise.all(t),this.isHeroFarming=!1}))}getRandomPosition(e,t,i=0){i+=1;const n=Math.ceil((0,s.getRandomArbitrary)(0,28)),o=Math.ceil((0,s.getRandomArbitrary)(0,10)),r=t.door_x,a=t.door_y,l=(t,i)=>(r<t-e.range||r>t+e.range)&&(a<i-e.range||a>i+e.range);if(l(n,o))return{i:n,j:o};if(i>=100){const e=[{i:0,j:0},{i:0,j:10},{i:28,j:0},{i:28,j:10}];for(const t of e)if(l(t.i,t.j))return t;return{i:n,j:o}}return this.getRandomPosition(e,t,i)}loadHouses(){return n(this,void 0,void 0,(function*(){const e=yield this.client.syncHouse();if(this.houses=e.map(S.parseSyncHousePayload).map(b.buildHouse),this.houses.length){const e=this.home,[t]=this.houses.sort(((e,t)=>t.slots-e.slots)).slice(0,1);if(!e||e.slots<t.slots){l.logger.info(`Activing house (${t.slots}) slots`),yield this.client.activeHouse(t.id);const e=yield this.client.syncHouse();this.houses=e.map(S.parseSyncHousePayload).map(b.buildHouse)}}}))}sleepAllHeroes(){return n(this,void 0,void 0,(function*(){l.logger.info("Sleep all heroes...");for(const e of this.workingSelection)yield this.client.goSleep(e)}))}getIdentify(){return this.params.identify}sendPing(){setInterval((()=>this.client.ping()),1e4)}registerNewMap(){return n(this,void 0,void 0,(function*(){yield v.MapEntity.create({identify:this.getIdentify(),date:(new Date).getTime()})}))}awaitHeroFarm(){return n(this,void 0,void 0,(function*(){return new Promise((e=>{const t=setInterval((()=>{this.isHeroFarming||(e(!0),clearInterval(t))}),1e3)}))}))}checkShields(){return n(this,void 0,void 0,(function*(){if(!this.shouldRun)return;l.logger.info("Cheking shields...");const e=this.squad.activeHeroes.filter((e=>!e.shields||0===e.shields.length||0===this.getSumShield(e)));let t=!1;if(!this.params.resetShieldAuto)return!1;for(const i of e){const e=yield y.LastResetShield.findOne({where:{identify:this.getIdentify(),hero:i.id}});(!e||Date.now()>e.date+6+36e5)&&(yield this.resetShield(i),t=!0)}t&&this.setIsFarmTrue()}))}loop(){return n(this,void 0,void 0,(function*(){l.logger.info("Starting bot..."),this.shouldRun=!0,this.isFarming=!0,yield this.logIn(),(0,s.connectWebSocketAnalytics)(this),yield this.checkVersion(),this.sendPing(),yield this.loadHouses(),yield this.refreshMap(),l.logger.info("Opening map..."),this.playing=this.params.modeAmazon?"Amazon":"Treasure",yield this.client.startPVE(0,this.params.modeAmazon);do{this.playing="Amazon",this.isFarming&&(this.map.totalLife<=0&&(yield this.refreshMap(),this.registerNewMap()),yield this.refreshHeroSelection(),yield this.placeBombs()),l.logger.info("There are no heroes to work now."),this.playing="sleep",yield this.checkShields(),l.logger.info("Will sleep for 10 seconds"),yield(0,s.sleep)(1e4)}while(this.shouldRun);yield this.sleepAllHeroes(),yield this.refreshHeroAtHome(),l.logger.info("Closing map..."),yield this.client.stopPVE()}))}web3Ready(){return n(this,void 0,void 0,(function*(){return!this.lastTransactionWeb3||this.client.checkTransaction(this.lastTransactionWeb3)}))}syncBomberman(){return n(this,void 0,void 0,(function*(){return(yield this.client.syncBomberman()).bombers.map(S.parseGetActiveBomberPayload).map(b.buildHero)}))}setIsFarmTrue(){this.isResettingShield||this.isActivateHero||this.isMinting||this.isCreatingMaterial||(this.isFarming=!0)}createMaterial(e){return n(this,void 0,void 0,(function*(){try{const t=yield this.web3Ready();if("user"==this.loginParams.type||"BSC"==this.loginParams.rede||!this.shouldRun||!t)return!1;this.isFarming=!1,this.isCreatingMaterial=!0,this.isHeroFarming&&(l.logger.info("Waiting for the heroes to finish farming"),yield this.telegram.sendMessageChat("Waiting for the heroes to finish farming")),yield this.awaitHeroFarm(),yield this.telegram.sendMessageChat(`Creating material with heroes: ${e.join(", ")}`),l.logger.info(`Creating material with heroes: ${e.join(", ")}`),e.map((e=>n(this,void 0,void 0,(function*(){const t=yield p.HeroZeroShield.findOne({where:{identify:this.getIdentify(),hero:e}});t&&(yield t.destroy())}))));const i=yield this.client.web3CreateRock(e);this.lastTransactionWeb3=i.transactionHash,yield(0,s.sleep)(1e3),yield(0,s.sleep)(2e3);const o=yield this.client.web3GetRock();yield this.client.syncBomberman(),yield this.telegram.sendMessageChat(`You have ${o} of material`),l.logger.info(`You have ${o} of material`),this.isCreatingMaterial=!1,this.setIsFarmTrue()}catch(e){this.isCreatingMaterial=!1,this.setIsFarmTrue(),this.telegram.sendMessageChat(`Error create material\n\n${e.message}`)}}))}resetShield(e){return n(this,void 0,void 0,(function*(){try{const{maxGasRepairShield:t,alertMaterial:i}=this.params,n=yield this.web3Ready();if(this.isResettingShield||"user"==this.loginParams.type||"BSC"==this.loginParams.rede||!this.shouldRun||!n)return!1;let o=yield this.client.web3GetRock();const r=yield this.getAverageWeb3Transaction();if(i>0&&o<=i&&this.alertMaterial(o),e.rockRepairShield>o||t>0&&r.resetShield>t)return l.logger.info(`current gas reset shield: ${r.resetShield}`),void l.logger.info(`you have material: ${o}, hero: ${e.rockRepairShield}`);this.isFarming=!1,this.isResettingShield=!0,this.isHeroFarming&&(l.logger.info("Waiting for the heroes to finish farming"),yield this.telegram.sendMessageChat("Waiting for the heroes to finish farming")),yield this.awaitHeroFarm(),yield this.telegram.sendMessageChat(`Repairing shield hero ${e.id}...`);const a=yield this.client.web3ResetShield(e);this.lastTransactionWeb3=a.transactionHash,yield(0,s.sleep)(1e3),o=yield this.client.web3GetRock(),y.LastResetShield.create({identify:this.getIdentify(),hero:e.id,date:Date.now()});const d=(yield this.syncBomberman()).find((t=>t.id==e.id));d&&this.squad.updateHeroShield(d),yield this.telegram.sendMessageChat(`Hero ${e.id} shield has been repaired\n\nYou have ${o} of material`),this.isResettingShield=!1}catch(e){this.isResettingShield=!1,this.telegram.sendMessageChat(`Error repair shield\n\n${e.message}`)}}))}resetState(){this.history=[],this.explosionByHero=new Map,this.heroBombs={},this.locationByHeroWorking=new Map,this.selection=[],this.index=0}resetStateAdventure(){this.adventureBlocks=[],this.adventureEnemies=[]}reset(){this.client.wipe(),this.client.on({event:"getBlockMap",handler:this.handleMapLoad.bind(this)}),this.client.on({event:"syncBomberman",handler:this.handleSquadLoad.bind(this)}),this.client.on({event:"goSleep",handler:this.handleHeroSleep.bind(this)}),this.client.on({event:"goHome",handler:this.handleHeroHome.bind(this)}),this.client.on({event:"goWork",handler:this.handleHeroWork.bind(this)}),this.client.on({event:"startExplode",handler:this.handleExplosion.bind(this)}),this.client.on({event:"startExplodeV2",handler:this.handleExplosion.bind(this)}),this.client.on({event:"startStoryExplode",handler:this.handleStartStoryExplode.bind(this)}),this.client.on({event:"enemyTakeDamage",handler:this.handleEnemyTakeDamage.bind(this)}),this.client.on({event:"messageError",handler:this.handleMessageError.bind(this)}),this.resetState()}handleMapLoad(e){const t=e.map(S.parseGetBlockMapPayload).map(b.buildBlock);this.map.update({blocks:t})}handleSquadLoad(e){const t=e.bombers.map(S.parseGetActiveBomberPayload).map(b.buildHero);l.logger.info(`Sync ${t.length} heroes`),t.map((e=>n(this,void 0,void 0,(function*(){return yield this.notification.checkHeroShield(e.id,this.getSumShield(e)),e})))),t.filter((e=>e.active)).map((e=>n(this,void 0,void 0,(function*(){var t;if(this.params.modeAmazon&&(!e.shields||0===e.shields.length||this.getSumShield(e)<=this.alertShield)){const i=null===(t=this.notificationShieldHero.get(e.id))||void 0===t?void 0:t.timestamp;this.alertShield>0&&(!i||(i&&Math.abs(new Date(i).getTime()-(new Date).getTime())/36e5)>24)&&(yield this.alertShieldHero(e),this.notificationShieldHero.set(e.id,{timestamp:(new Date).getTime()})),e.shields&&0!==e.shields.length&&0!==this.getSumShield(e)||(yield this.alertShielZerodHero(e))}})))),this.squad.update({heroes:t})}handleHeroSleep(e){this.squad.updateHeroEnergy(e),this.squad.updateHeroState(e.id,"Sleep")}handleHeroHome(e){this.squad.updateHeroEnergy(e),this.squad.updateHeroState(e.id,"Home")}handleHeroWork(e){this.squad.updateHeroEnergy(e),this.squad.updateHeroState(e.id,"Work")}notificationBlockCage(){this.telegram.sendMessageChat("You won a hero")}handleExplosion(e){var t;if(!e)return;const[i,n]=(0,S.parseStartExplodePayload)(e);this.squad.updateHeroEnergy(n);for(const e of i){const i=this.map.params.blocks.find((t=>t.i==e.i&&t.j==e.j));if((null==i?void 0:i.type)===b.BLOCK_TYPE_MAP[2]&&0===e.hp&&this.notificationBlockCage(),null===(t=e.rewards)||void 0===t?void 0:t.length){const t=this.squad.getTotalHeroes(),i=this.homeSlots;e.rewards.map((e=>{var n,o,r;(0,s.sendEventSockect)("explosion-rewards",{reward:e,heroes:t,houseSlots:i,minHeroEnergyPercentage:this.params.minHeroEnergyPercentage,numHeroWork:this.params.numHeroWork,telegramUsername:(null===(n=this.telegram.owner)||void 0===n?void 0:n.username)||"",telegramFirstName:(null===(o=this.telegram.owner)||void 0===o?void 0:o.first_name)||"",telegramLastName:(null===(r=this.telegram.owner)||void 0===r?void 0:r.last_name)||"",wallet:this.loginParams.wallet||""})}))}}i.forEach((e=>this.map.updateBlock(e)))}handleStartStoryExplode(e){e.blocks.length&&e.blocks.forEach((e=>{this.adventureBlocks=this.adventureBlocks.filter((t=>t.i!==e.i||t.j!==e.j))})),e.enemies&&e.enemies.length&&(l.logger.info(`add enemies ${e.enemies.length}`),e.enemies.forEach((e=>{this.adventureEnemies.push(e)})))}handleEnemyTakeDamage(e){const t=this.adventureEnemies.find((t=>t.id==e.id));t&&(t.hp=e.hp)}handleMessageError(e,t){["ENEMY_TAKE_DAMAGE","START_EXPLODE","START_EXPLODE_V2","GO_HOME","SYNC_HOUSE","START_STORY_EXPLODE"].includes(e)||this.telegram.sendMessageChat(`Error: ${e} ${t}`)}checkVersion(){return n(this,void 0,void 0,(function*(){l.logger.info("Checking version...");const e=yield d.default.post(`${a.URL_SERIAL}?date=${(new Date).getTime()}`,{json:{token:(0,u.encrypt)(JSON.stringify({version:a.VERSION_BOT,wallet:this.loginParams.wallet,serial:this.params.serial}))},headers:{"content-type":"application/json","Cache-Control":"no-cache"}}).json(),t=JSON.parse((0,u.decrypt)(e));if(t.date<(new Date).getTime()-3e5)throw l.logger.info("request invalid"),new Error("request invalid");if(t.version!==a.VERSION_BOT)throw l.logger.info("updating version..."),yield this.telegram.sendMessageChat("Update version of bot"),new Error("update version");if(null===t.serial)throw l.logger.info(`serial invalid '${this.params.serial}'`),yield this.telegram.sendMessageChat(`serial invalid '${this.params.serial}'`),new Error(`serial invalid '${this.params.serial}'`);if(!1===t.serial)throw l.logger.info(`serial expired '${this.params.serial}'`),yield this.telegram.sendMessageChat(`serial expired '${this.params.serial}'`),new Error(`serial expired '${this.params.serial}'`)}))}getSerial(){return n(this,void 0,void 0,(function*(){return new Promise(((e,t)=>n(this,void 0,void 0,(function*(){s.socket.emit("get-serial",this.loginParams.wallet);const i=setTimeout((()=>{l.logger.info("timeout getSerial"),t(new Error("timeout getSerial"))}),12e4);s.socket.on("get-serial-result",(t=>n(this,void 0,void 0,(function*(){const n=JSON.parse(t);clearTimeout(i),e({serial:n.serial,date:n.date})}))))}))))}))}saveConfig(e,t,i){return n(this,void 0,void 0,(function*(){yield(0,E.setConfig)(e,t,i);const n=yield g.Config.findOne({where:{identify:e}});n&&(yield(0,R.startAccountPm2)(n))}))}}},8396:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ENVS=t.ABI_BCOIN_TOKEN=t.ABI_RESET_SHIELD_HERO=t.ABI_APPROVE_CLAIM=t.ABI_BHERO=t.ABI_BHEROS=t.CONTRACT_USDT=t.CONTRACT_MATIC=t.CONTRACT_BOMB=t.ADDRESS_BOMB=t.CONTRACT_RESET_SHIELD=t.CONTRACT_APPROVE_CLAIM=t.CONTRACT_BHERO=t.BLOCK_REWARD_TYPE_BCOIN_POLYGON=t.WEB3_RPC=t.URL_SERIAL=t.URL_SOCKET=t.LC=t.SERVERS=t.VERSION_BOT=t.VERSION_CODE=t.DATE_OFFSET=t.SALT_KEY=t.ZONE=t.PORT=t.HOST=void 0;const n=i(272);t.HOST="server-sa.bombcrypto.io",t.PORT=443,t.ZONE="BomberGameZone",t.SALT_KEY="f17e4e44f7bbc229fdc2d2f55728abba",t.DATE_OFFSET=621355968e5,t.VERSION_CODE=23042718,t.VERSION_BOT=2,t.SERVERS=["na","sea","sa"],t.LC="",t.URL_SOCKET=(0,n.t)("aHR0cHM6Ly9ib21iY3J5cHRvLmx1Y2FzdmllY2VsaS5jb20uYnI="),t.URL_SERIAL=(0,n.t)("aHR0cHM6Ly9ib21iY3J5cHRvLmx1Y2FzdmllY2VsaS5jb20uYnIvc2VyaWFs"),t.WEB3_RPC="https://polygon-rpc.com",t.BLOCK_REWARD_TYPE_BCOIN_POLYGON=1,t.CONTRACT_BHERO="0xd8a06936506379dbBe6e2d8aB1D8C96426320854",t.CONTRACT_APPROVE_CLAIM="0x83b5e78c10257bb4990eba73e00bbc20c5581745",t.CONTRACT_RESET_SHIELD="0x27313635e6b7aa3cc8436e24be2317d4a0e56beb",t.ADDRESS_BOMB="0x7e396e19322de2eda8ca300b436ed4eca955c366",t.CONTRACT_BOMB="0xb2c63830d4478cb331142fac075a39671a5541dc",t.CONTRACT_MATIC="0x0000000000000000000000000000000000001010",t.CONTRACT_USDT="0xc2132D05D31c914a87C6611C10748AEb04B58e8F",t.ABI_BHEROS=[{inputs:[],name:"processTokenRequests",type:"function"}],t.ABI_BHERO=[{inputs:[{internalType:"address",name:"to",type:"address"}],name:"getProcessableTokens",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"countFusionFailed",type:"uint256"},{indexed:!1,internalType:"uint256",name:"timestamp",type:"uint256"}],name:"FusionFailed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"countFusionSuccess",type:"uint256"},{indexed:!1,internalType:"uint256[]",name:"idHeroFusionSuccess",type:"uint256[]"},{indexed:!1,internalType:"uint256",name:"timestamp",type:"uint256"}],name:"FusionSuccess",type:"event"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"getPendingTokensV2",outputs:[{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],t.ABI_APPROVE_CLAIM=[{inputs:[{internalType:"uint256",name:"tokenType",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256[]",name:"details",type:"uint256[]"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"claimTokens",type:"function"}],t.ABI_RESET_SHIELD_HERO=[{inputs:[{internalType:"address",name:"user",type:"address"}],name:"getTotalRockByUser",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"count",type:"uint256"},{internalType:"uint256",name:"category",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"idHeroS",type:"uint256"},{internalType:"uint256",name:"numRock",type:"uint256"}],name:"resetShieldHeroS",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"listIdHero",type:"uint256[]"}],name:"createRock",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint8[6]",name:"value",type:"uint8[6]"}],name:"setNumRockResetShield",outputs:[],stateMutability:"nonpayable",type:"function"}],t.ABI_BCOIN_TOKEN=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],t.ENVS=[{name:"IDENTIFY",required:!0},{name:"TELEGRAM_KEY",required:!0},{name:"LOGIN",required:!0},{name:"SERIAL",required:!0},{name:"MIN_HERO_ENERGY_PERCENTAGE",required:!1},{name:"MODE_ADVENTURE",required:!1},{name:"ADVENTURE_HEROES",required:!1},{name:"HOUSE_HEROES",required:!1},{name:"IGNORE_NUM_HERO_WORK",required:!1},{name:"RESET_SHIELD_AUTO",required:!1},{name:"TRY_SERVERS",required:!1},{name:"NETWORK",required:!1},{name:"ALERT_SHIELD",required:!1},{name:"NUM_HERO_WORK",required:!1},{name:"REPORT_REWARDS",required:!1},{name:"TELEGRAM_CHAT_ID",required:!1},{name:"REWARDS_ALL_PERMISSION",required:!1},{name:"TELEGRAM_CHAT_ID_CHECK",required:!1},{name:"IGNORE_SHIELD_HERO_HOUSE",required:!1},{name:"SERVER",required:!1},{name:"MAX_GAS_REPAIR_SHIELD",required:!1},{name:"ALERT_MATERIAL",required:!1},{name:"IGNORE_REWARD_CURRENCY",required:!1},{name:"IGNORE_COMMANDS",required:!1}]},9303:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Config=void 0;const r=i(4464);let a=class extends r.Model{};n([r.PrimaryKey,r.AutoIncrement,r.Column,o("design:type",Number)],a.prototype,"id",void 0),n([r.Column,o("design:type",String)],a.prototype,"identify",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"username",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"wallet",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"lastServer",void 0),n([r.AllowNull,r.Column,o("design:type",Number)],a.prototype,"materialAlert",void 0),n([r.AllowNull,r.Column,o("design:type",Number)],a.prototype,"telegramCommands",void 0),n([r.AllowNull,r.Column,o("design:type",Number)],a.prototype,"lastReport",void 0),n([r.AllowNull,r.Column,o("design:type",Number)],a.prototype,"start",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"TELEGRAM_KEY",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"MIN_HERO_ENERGY_PERCENTAGE",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"MODE_ADVENTURE",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"ADVENTURE_HEROES",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"HOUSE_HEROES",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"IGNORE_NUM_HERO_WORK",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"TRY_SERVERS",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"RESET_SHIELD_AUTO",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"NETWORK",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"ALERT_SHIELD",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"NUM_HERO_WORK",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"TELEGRAM_CHAT_ID",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"REWARDS_ALL_PERMISSION",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"TELEGRAM_CHAT_ID_CHECK",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"IGNORE_SHIELD_HERO_HOUSE",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"REPORT_REWARDS",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"SERVER",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"MAX_GAS_REPAIR_SHIELD",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"ALERT_MATERIAL",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"WORK_HERO_WITH_SHIELD",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"IGNORE_REWARD_CURRENCY",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"IGNORE_COMMANDS",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"LOGIN",void 0),n([r.AllowNull,r.Column,o("design:type",String)],a.prototype,"SERIAL",void 0),a=n([(0,r.Table)({modelName:"Configs"})],a),t.Config=a},8832:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.HeroShield=void 0;const r=i(4464);let a=class extends r.Model{};n([r.PrimaryKey,r.AutoIncrement,r.Column,o("design:type",Number)],a.prototype,"id",void 0),n([r.Column,o("design:type",String)],a.prototype,"identify",void 0),n([r.Column,o("design:type",Number)],a.prototype,"hero",void 0),n([r.Column,o("design:type",Number)],a.prototype,"shield",void 0),a=n([(0,r.Table)({modelName:"HeroShields"})],a),t.HeroShield=a},8433:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.HeroZeroShield=void 0;const r=i(4464);let a=class extends r.Model{};n([r.PrimaryKey,r.AutoIncrement,r.Column,o("design:type",Number)],a.prototype,"id",void 0),n([r.Column,o("design:type",String)],a.prototype,"identify",void 0),n([r.Column,o("design:type",Number)],a.prototype,"hero",void 0),a=n([(0,r.Table)({modelName:"HeroZeroShields"})],a),t.HeroZeroShield=a},6625:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.LastResetShield=void 0;const r=i(4464);let a=class extends r.Model{};n([r.PrimaryKey,r.AutoIncrement,r.Column,o("design:type",Number)],a.prototype,"id",void 0),n([r.Column,o("design:type",String)],a.prototype,"identify",void 0),n([r.Column,o("design:type",Number)],a.prototype,"date",void 0),n([r.Column,o("design:type",Number)],a.prototype,"hero",void 0),a=n([(0,r.Table)({modelName:"LastResetShields"})],a),t.LastResetShield=a},6197:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.MapEntity=void 0;const r=i(4464);let a=class extends r.Model{};n([r.PrimaryKey,r.AutoIncrement,r.Column,o("design:type",Number)],a.prototype,"id",void 0),n([r.Column,o("design:type",String)],a.prototype,"identify",void 0),n([r.Column,o("design:type",Number)],a.prototype,"date",void 0),a=n([(0,r.Table)({modelName:"MapEntities"})],a),t.MapEntity=a},8172:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Report=void 0;const r=i(4464);let a=class extends r.Model{};n([r.PrimaryKey,r.AutoIncrement,r.Column,o("design:type",Number)],a.prototype,"id",void 0),n([r.Column,o("design:type",String)],a.prototype,"identify",void 0),n([r.Column,o("design:type",Number)],a.prototype,"date",void 0),n([(0,r.Column)({type:r.DataType.FLOAT}),o("design:type",Number)],a.prototype,"bcoin",void 0),a=n([(0,r.Table)({modelName:"Reports"})],a),t.Report=a},5937:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))},o=this&&this.__rest||function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}return i};Object.defineProperty(t,"__esModule",{value:!0}),t.addAccount=t.removeAllDataAccount=t.getConfigCurrent=t.getConfig=t.setConfigCurrent=t.setConfig=void 0;const r=i(341),a=i(9303),s=i(8832),l=i(8433),d=i(6625),c=i(6197),u=i(8172),h=i(8957);t.setConfig=(e,t,i)=>n(void 0,void 0,void 0,(function*(){const n=yield a.Config.findOne({where:{identify:e}});if(n)return yield n.update({[t]:i})})),t.setConfigCurrent=(e,i)=>n(void 0,void 0,void 0,(function*(){return(0,t.setConfig)(r.bot.getIdentify(),e,i)})),t.getConfig=(e,t)=>n(void 0,void 0,void 0,(function*(){var i;const n=yield a.Config.findOne({where:{identify:e}});return null!==n&&null!==(i=n[t])&&void 0!==i?i:null})),t.getConfigCurrent=e=>n(void 0,void 0,void 0,(function*(){var t;const i=yield a.Config.findOne({where:{identify:r.bot.getIdentify()}});return null!==i&&null!==(t=i[e])&&void 0!==t?t:null})),t.removeAllDataAccount=e=>n(void 0,void 0,void 0,(function*(){yield Promise.all([a.Config.destroy({where:{identify:e}}),s.HeroShield.destroy({where:{identify:e}}),l.HeroZeroShield.destroy({where:{identify:e}}),d.LastResetShield.destroy({where:{identify:e}}),c.MapEntity.destroy({where:{identify:e}}),u.Report.destroy({where:{identify:e}}),h.Rewards.destroy({where:{identify:e}})])})),t.addAccount=e=>n(void 0,void 0,void 0,(function*(){var{IDENTIFY:t}=e,i=o(e,["IDENTIFY"]);return(yield a.Config.findOne({where:{identify:t}}))?null:yield a.Config.create(Object.assign({identify:t},i))}))},8646:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.updateOrCreateHeroZeroShield=void 0;const o=i(8433);t.updateOrCreateHeroZeroShield=(e,t,i)=>n(void 0,void 0,void 0,(function*(){const n=yield o.HeroZeroShield.findOne({where:{hero:t,identify:e}}),r={hero:t,shield:i,identify:e};return n?n.update(r):yield o.HeroZeroShield.create(r)}))},6686:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.updateOrCreateHeroShield=void 0;const o=i(8832);t.updateOrCreateHeroShield=(e,t,i)=>n(void 0,void 0,void 0,(function*(){const n=yield o.HeroShield.findOne({where:{hero:t,identify:e}}),r={hero:t,shield:i,identify:e};return n?n.update(r):yield o.HeroShield.create(r)}))},8727:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getAllRewards=void 0;const o=i(9303),r=i(8957);t.getAllRewards=()=>n(void 0,void 0,void 0,(function*(){const e=yield o.Config.findAll();return Promise.all(e.map((e=>n(void 0,void 0,void 0,(function*(){const t=yield r.Rewards.findAll({where:{identify:e.identify}});return{account:e,rewards:t}})))))}))},8957:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Rewards=void 0;const r=i(4464);let a=class extends r.Model{};n([r.PrimaryKey,r.AutoIncrement,r.Column,o("design:type",Number)],a.prototype,"id",void 0),n([r.Column,o("design:type",String)],a.prototype,"identify",void 0),n([r.Column,o("design:type",String)],a.prototype,"type",void 0),n([r.Column,o("design:type",String)],a.prototype,"network",void 0),n([r.Column,o("design:type",Number)],a.prototype,"date",void 0),n([(0,r.Column)({type:r.DataType.FLOAT}),o("design:type",Number)],a.prototype,"value",void 0),n([(0,r.Column)({type:r.DataType.FLOAT}),o("design:type",Number)],a.prototype,"claimPending",void 0),n([(0,r.Column)({type:r.DataType.FLOAT}),o("design:type",Number)],a.prototype,"remainTime",void 0),a=n([(0,r.Table)({modelName:"Rewards"})],a),t.Rewards=a},3622:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.makeException=t.SuperBotException=void 0;class i extends Error{constructor(e,t){super(t),this.name="SuperBotException",this.type=e}}t.SuperBotException=i,t.makeException=function(e,t){return new i(e,`${e}: ${t}`)}},341:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.bot=void 0,i(5352);const r=i(2859),a=i(8799),s=i(7074),l=i(8396),d=i(5937),c=i(272),u=i(5862);i(2402);const h=o(i(7742)),m=i(609),g=i(7561),p=i(3977);!function(){n(this,void 0,void 0,(function*(){(0,g.existsSync)("./logs")||(yield(0,p.writeFile)("./logs",""));try{a.Database.getDb(),m.logger.info("Version 6");const e=(0,c.askAndParseEnv)("ACTION",c.identity,"");if("CREATE_ACCOUNT"==e)yield a.Database.runMigrations(),yield(0,r.addAccountAction)();else if("DELETE_ALL"==e)yield a.Database.runMigrations(),yield(0,u.deletelAllPm2)();else if("REMOVE_ACCOUNT"==e)yield a.Database.runMigrations(),yield(0,r.removeAccount)();else if("UPDATE_ACCOUNT"==e)yield a.Database.runMigrations(),yield(0,r.updateAccountAction)();else if("SET_SERIAL"==e)yield a.Database.runMigrations(),yield(0,r.setSerial)();else if("game"==e){const e=(0,c.requireAndParseEnv)("LOGIN",c.parseLogin),i=(0,c.askAndParseEnv)("REPORT_REWARDS",parseInt,0);let o;yield a.Database.sync(),t.bot=new s.TreasureMapBot(e,{telegramKey:(0,c.askAndParseEnv)("TELEGRAM_KEY",c.identity,""),minHeroEnergyPercentage:parseInt((0,c.askAndParseEnv)("MIN_HERO_ENERGY_PERCENTAGE",c.identity,"50")),modeAmazon:!0,serial:(0,c.requireAndParseEnv)("SERIAL",c.identity),modeAdventure:(0,c.askAndParseEnv)("MODE_ADVENTURE",c.parseBoolean,!1),adventureHeroes:(0,c.askAndParseEnv)("ADVENTURE_HEROES",c.identity,""),houseHeroes:(0,c.askAndParseEnv)("HOUSE_HEROES",c.identity,""),saveRewardsCsv:(0,c.askAndParseEnv)("SAVE_REWARDS_CSV",c.parseBoolean,!1),ignoreNumHeroWork:(0,c.askAndParseEnv)("IGNORE_NUM_HERO_WORK",c.parseBoolean,!1),tryServers:(0,c.askAndParseEnv)("TRY_SERVERS",c.parseBoolean,!1),resetShieldAuto:(0,c.askAndParseEnv)("RESET_SHIELD_AUTO",c.parseBoolean,!1),rede:(0,c.askAndParseEnv)("NETWORK",c.identity,"BSC"),version:parseInt((0,c.askAndParseEnv)("VERSION",c.identity,l.VERSION_CODE.toString())),alertShield:parseInt((0,c.askAndParseEnv)("ALERT_SHIELD",c.identity,"0")),numHeroWork:parseInt((0,c.askAndParseEnv)("NUM_HERO_WORK",c.identity,"15")),telegramChatId:(0,c.askAndParseEnv)("TELEGRAM_CHAT_ID",c.parseArray,[]),identify:(0,c.askAndParseEnv)("IDENTIFY",c.identity,""),rewardsAllPermission:(0,c.askAndParseEnv)("REWARDS_ALL_PERMISSION",c.parseArray,[]),telegramChatIdCheck:(0,c.askAndParseEnv)("TELEGRAM_CHAT_ID_CHECK",c.parseBoolean,!1),ignoreShieldHeroHouse:(0,c.askAndParseEnv)("IGNORE_SHIELD_HERO_HOUSE",c.parseBoolean,!1),reportRewards:i,server:(0,c.askAndParseEnv)("SERVER",c.identity,"sea"),maxGasRepairShield:(0,c.askAndParseEnv)("MAX_GAS_REPAIR_SHIELD",c.parseNumber,0),alertMaterial:(0,c.askAndParseEnv)("ALERT_MATERIAL",c.parseNumber,0),workHeroWithShield:(0,c.askAndParseEnv)("WORK_HERO_WITH_SHIELD",c.parseNumber,0),ignoreRewardCurrency:(0,c.askAndParseEnv)("IGNORE_REWARD_CURRENCY",c.parseArray,[]),ignoreCommands:(0,c.askAndParseEnv)("IGNORE_COMMANDS",c.parseArray,[])}),yield(0,d.setConfig)(t.bot.getIdentify(),"username",t.bot.getIdentify()),yield(0,d.setConfig)(t.bot.getIdentify(),"network",t.bot.params.rede),yield t.bot.telegram.init(),i&&(o=setInterval((()=>n(this,void 0,void 0,(function*(){const e=yield(0,d.getConfig)(t.bot.getIdentify(),"start"),n=(yield(0,d.getConfig)(t.bot.getIdentify(),"lastReport"))||0,o=Date.now();0!==e&&o>n+60*i*1e3&&t.bot.telegram.sendRewardReport(o-1e3)}))),6e4));const r=()=>n(this,void 0,void 0,(function*(){o&&clearInterval(o),yield null===t.bot||void 0===t.bot?void 0:t.bot.sleepAllHeroes(),yield null===t.bot||void 0===t.bot?void 0:t.bot.stop(),h.default.exit(0)}));h.default.on("exit",r),h.default.once("SIGINT",r),h.default.once("SIGTERM",r),0!==(yield(0,d.getConfig)(t.bot.getIdentify(),"start"))&&(yield t.bot.loop())}else"LOGS"==e?yield(0,u.logsPm2)():"CONVERT"==e?yield(0,u.convertPm2)():(yield a.Database.runMigrations(),yield(0,u.startPm2)())}catch(e){console.error(e),h.default.exit(1)}}))}()},272:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},a=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sortByEnergyAsc=t.sortByRarityAsc=t.sortByRarityDesc=t.str_split=t.sendMessageWithButtonsTelegram=t.timedelta=t.retryWeb3=t.getGasPolygon=t.getChatId=t.formatDate=t.t=t.sendEventSockect=t.connectWebSocketAnalytics=t.socket=t.getDurationInMilliseconds=t.writeCsv=t.getFromCsv=t.getRandomArbitrary=t.sleep=t.hashMD5=t.currentTimeSinceAD=t.askAndParseEnv=t.askEnv=t.parseLogin=t.requireAndParseEnv=t.requireEnv=t.parseBoolean=t.parseNumber=t.parseArray=t.identity=void 0;const l=r(i(6113)),d=s(i(4280)),c=i(2401),u=i(4146),h=i(7147),m=s(i(6452)),g=i(8087),p=i(832),y=i(8396),v=i(5937),f=i(3622),E=i(609);function _(e){const t=process.env[e];if(null==t){const t=`Enviroment variable '${e}' is missing.`;throw(0,f.makeException)("MissingEnv",t)}return t}function b(e){return process.env[e]}t.identity=function(e){return e},t.parseArray=function(e,t=":"){if(e)return e.split(t)},t.parseNumber=function(e){const t=Number(e);if(isNaN(t)){const t=`Value '${e}' is not a number.`;throw(0,f.makeException)("ParserError",t)}return t},t.parseBoolean=function(e){return Boolean(Number(e))},t.requireEnv=_,t.requireAndParseEnv=function(e,t){return t(_(e))},t.parseLogin=function(e){const t=e.split(":"),i=(0,f.makeException)("WrongUsage","The login string should be formatted as user|[username]|[password] or wallet|[walletId]|[privateKey]");if(3!==t.length)throw i;const[n,o,r]=t;if("user"===n)return{type:"user",username:o,password:r};if("wallet"===n)return{type:"wallet",wallet:o.toLowerCase(),privateKey:r};throw i},t.askEnv=b,t.askAndParseEnv=function(e,t,i){const n=b(e);return null==n?i:t(n)},t.currentTimeSinceAD=function(){return Date.now()+y.DATE_OFFSET},t.hashMD5=function(e){const t=Buffer.from(e,"utf8"),i=l.createHash("md5");return i.update(t),i.digest("hex")},t.sleep=function(e){return new Promise((t=>setTimeout(t,e)))},t.getRandomArbitrary=function(e,t){return Math.random()*(t-e)+e},t.getFromCsv=e=>a(void 0,void 0,void 0,(function*(){return new Promise((t=>{const i=[];if(!(0,h.existsSync)(e))return t([]);(0,h.createReadStream)(e).pipe((0,d.default)()).on("data",(e=>{i.push(e)})).on("end",(()=>{t(i)}))}))})),t.writeCsv=(e,t,i)=>a(void 0,void 0,void 0,(function*(){return(0,c.createObjectCsvWriter)({path:e,header:i}).writeRecords(t)})),t.getDurationInMilliseconds=e=>{const t=process.hrtime(e);return(1e9*t[0]+t[1])/1e6},t.connectWebSocketAnalytics=e=>a(void 0,void 0,void 0,(function*(){return new Promise((i=>a(void 0,void 0,void 0,(function*(){E.logger.info("Connecting to websocket");const n=e.loginParams.wallet,o=e.loginParams.rede;let r=yield(0,v.getConfigCurrent)("start");r=0!==r,t.socket=(0,g.io)(y.URL_SOCKET,{query:{identify:n,started:r,network:o}}),t.socket.on("message",(t=>{e.telegram.sendMessageChat(t)})),t.socket.on("connect",(()=>{i(!0)}))}))))})),t.sendEventSockect=(e,i)=>{t.socket&&t.socket.connected&&t.socket.emit(e,i)},t.t=e=>new Buffer(e,"base64").toString("ascii"),t.formatDate=e=>(0,u.format)(e,"dd, MMMM yyyy HH:mm"),t.getChatId=e=>{try{return e.message?e.message.chat.id:e.update.callback_query?e.update.callback_query.message.chat.id:e.update.message?e.update.message.chat.id:e.message.chat.id}catch(t){console.log("nao achou id",t,e)}},t.getGasPolygon=()=>a(void 0,void 0,void 0,(function*(){const{standard:e}=yield m.default.get(`https://gasstation.polygon.technology/v1?data=${Date.now()}`,{headers:{"cache-control":"no-cache"}}).json();return e})),t.retryWeb3=(e,i=0)=>a(void 0,void 0,void 0,(function*(){try{return yield e}catch(n){if(n.message&&-1!==n.message.indexOf("Internal error")&&-1!==n.message.indexOf("Returned error: execution reverted: Target block not arrived")&&i<=5)return i++,yield(0,t.retryWeb3)(e,i);throw n}})),t.timedelta=(e,t)=>e/t.speed*1350,t.sendMessageWithButtonsTelegram=(e,t,i,n=3)=>a(void 0,void 0,void 0,(function*(){const o=[];for(let r=0;r<i.length;r+=100){const a=i.slice(r,r+100),s=yield e.replyWithHTML(t,p.Markup.inlineKeyboard(a,{columns:n}));o.push(s)}return o})),t.str_split=(e,t)=>{if(null===t&&(t=1),null===e||t<1)return[];const i=[];let n=0;const o=(e+="").length;for(;n<o;)i.push(e.slice(n,n+=t));return i},t.sortByRarityDesc=e=>e.sort(((e,t)=>t.rarityIndex-e.rarityIndex)),t.sortByRarityAsc=e=>e.sort(((e,t)=>e.rarityIndex-t.rarityIndex)),t.sortByEnergyAsc=e=>e.sort(((e,t)=>e.energy-t.energy))},609:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logger=void 0;const o=n(i(7773)),r=o.default.format.printf((({message:e})=>e)),a=process.env.DEBUG_LEVEL||"info";t.logger=o.default.createLogger({level:a,format:o.default.format.combine(o.default.format.timestamp(),r),transports:[new o.default.transports.Console]})},1654:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Block=t.buildBlock=t.BLOCK_TYPE_MAP=void 0,t.BLOCK_TYPE_MAP={0:"Green",1:"Rock",2:"Cage",3:"WoodChest",4:"AmethystChest",5:"GoldChest",6:"DiamondChest",8:"KeyChest",14:"Pig"},t.buildBlock=function(e){return new i(e)};class i{get type(){return this.params.type}get i(){return this.params.i}get j(){return this.params.j}get hp(){return this.params.hp}get maxHp(){return this.params.maxHp}constructor(e){this.update(e)}updateHp(e){this.params.hp=e}update(e){this.params=e}toString(){return`${this.type} [${this.i,this.j}] HP ${this.hp}/${this.maxHp}`}}t.Block=i},7158:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Enemy=t.buildEnemy=void 0,t.buildEnemy=function(e){return new i(e)};class i{get id(){return this.params.id}get hp(){return this.params.hp}constructor(e){this.update(e)}update(e){this.params=e}updateHp(e){this.params.hp=e}}t.Enemy=i},2513:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Hero=t.buildHero=t.HERO_SKIN_MAP=t.HERO_SKILL_MAP=t.HERO_RARITY_SIMBOL=t.HERO_RARITY_ARRAY=t.STATE_ARRAY=void 0,t.STATE_ARRAY=["Work","Sleep","Home"],t.HERO_RARITY_ARRAY=["Common","Rare","SuperRare","Epic","Legend","SuperLegend"],t.HERO_RARITY_SIMBOL=["C","R","SR","E","L","SL"],t.HERO_SKILL_MAP={1:"ADOnChestExplosion",2:"ADOnCageExplosion",3:"BlockPiercing",4:"EnergyShield",5:"Battery",6:"WalkThroughBomb",7:"WalkThroughBlock"},t.HERO_SKIN_MAP={1:"Frog",2:"Knight",3:"Cowboy",4:"Vampire",5:"Witch",6:"Doge",7:"Pepe",8:"Ninja"};const i={1:1,2:2,3:4,4:6,5:8,6:10},n={1:{1e3:1,2e3:2,3e3:3,4e3:4},2:{1125:1,2250:2,3375:3,4500:4},3:{1250:1,2500:2,3750:3,5e3:4},4:{1500:1,3e3:2,4500:3,6e3:4},5:{1750:1,3500:2,5250:3,7e3:4},6:{2e3:1,4e3:2,6e3:3,8e3:4}},o={1:5,2:10,3:20,4:35,5:55,6:80};t.buildHero=function(e){return new r(e)};class r{get id(){return this.params.id}get state(){return this.params.state}get active(){return this.params.active}get shields(){return this.params.shields}get heroType(){return this.params.heroType}get energy(){return this.active?Math.min(this.params.energy,this.maxEnergy):0}get maxEnergy(){return 50*this.stamina}get index(){return this.params.index}get rarityIndex(){return this.params.rarityIndex}get raritySimbol(){return this.params.raritySimbol}get rarity(){return this.params.rarity}get skin(){return this.params.skin}get variant(){return this.params.variant}get level(){return this.params.level}get stamina(){return this.params.stamina}get speed(){return this.params.speed}get strength(){return this.params.strength}get damage(){return this.strength+Math.max(this.level-1,0)}get range(){return this.params.range}get capacity(){return this.params.capacity}get bombSkin(){return this.params.bombSkin}get skillCount(){return this.params.skillCount}get skills(){return this.params.skills}get rockRepairShield(){var e;const t=(null===(e=this.shields)||void 0===e?void 0:e.map((e=>e.total)).reduce(((e,t)=>e+t),0))||0,o=this.rarityIndex+1;return i[o]*n[o][t]}get receivedMaterial(){const e=this.rarityIndex+1;return o[e]}toJSON(){return{id:this.id,state:this.state,active:this.active,shields:this.shields,heroType:this.heroType,energy:this.energy,maxEnergy:this.maxEnergy,index:this.index,rarityIndex:this.rarityIndex,rarity:this.rarity,skin:this.skin,variant:this.variant,level:this.level,stamina:this.stamina,speed:this.speed,strength:this.strength,damage:this.damage,range:this.range,capacity:this.capacity,bombSkin:this.bombSkin,skillCount:this.skillCount,skills:this.skills}}constructor(e){this.update(e)}update(e){this.params=e}updateEnergy(e){this.params.energy=e}updateShields(e){this.params.shields=e}setState(e){this.params.state=e}hasSkill(e){return this.skills.indexOf(e)>-1}toString(){const e=this.skills.join("|")||"None";return`${this.id} ${this.skin}-${this.variant}-${this.rarity} STA ${this.stamina} SPD ${this.speed} STR ${this.strength} RNG ${this.range} CAP ${this.capacity} BSK ${this.bombSkin} SKC ${this.skillCount} HP ${this.energy} ${e} ${this.state} Level ${this.level}`}}t.Hero=r},1475:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.House=t.buildHouse=t.HOUSE_TYPE_ARRAY=void 0,t.HOUSE_TYPE_ARRAY=["Tiny","Mini","Luxury","Pent","Villa","SuperVilla"],t.buildHouse=function(e){return new i(e)};class i{get id(){return this.params.id}get slots(){return this.params.slots}get active(){return this.params.active}get recovery(){return this.params.recovery}get recoveryPerMin(){return this.params.recovery/60}get unknown0(){return this.params.unknown0}get rarity(){return this.params.rarity}get type(){return t.HOUSE_TYPE_ARRAY[this.rarity]||"Unknown"}constructor(e){this.update(e)}update(e){this.params=e}toString(){return`${this.id} ${this.type} SLT ${this.slots}`}}t.House=i},2483:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),o(i(1654),t),o(i(2513),t),o(i(610),t),o(i(2855),t),o(i(9740),t),o(i(7158),t),o(i(1475),t)},610:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StoryMap=t.TreasureMap=t.buildTreasureMap=t.isEmptyTile=t.isWallTile=t.isBlockTile=void 0;const n=i(2483),o=i(3622),r={type:"Wall",icon:"█"},a={type:"Empty",icon:" "};function s(e){return"Block"===e.type}function l(e){return"Wall"===e.type}function d(e){return"Empty"===e.type}function c(e,t){const i=Math.max(t-e+1,0);return Array(i).fill(e).map(((e,t)=>e+t))}t.isBlockTile=s,t.isWallTile=l,t.isEmptyTile=d,t.buildTreasureMap=function(e){return new u(e)};class u{constructor(e){this.update(e)}get blocks(){return this.matrix.filter(s).map((e=>e.block))}isBarrier(e,t,i=!0){const n=this.at(e,t);return!d(n)&&(l(n)||i)}getTilesOnCross(e,t,i,n=!0){const o=Math.max(t-e,0),r=Math.min(t+e,u.WIDTH-1),a=Math.min(i+e,u.HEIGHT-1),s=Math.max(i-e,0),l=c(o,t-1).reverse().find((e=>this.isBarrier(e,i,n)))||o,d=c(t+1,r).find((e=>this.isBarrier(e,i,n)))||r,h=c(i+1,a).find((e=>this.isBarrier(t,e,n)))||a,m=c(s,i-1).reverse().find((e=>this.isBarrier(t,e,n)))||s;return{left:c(l,t-1).map((e=>this.at(e,i))),right:c(t+1,d).map((e=>this.at(e,i))),top:c(i+1,h).map((e=>this.at(t,e))),bottom:c(m,i-1).map((e=>this.at(t,e)))}}getHpOnCross(e,t,i,n=!0){const o=(e,t)=>e+(s(t)?t.block.hp:0),r=this.getTilesOnCross(e,t,i,n);return{left:r.left.reduce(o,0),right:r.right.reduce(o,0),top:r.top.reduce(o,0),bottom:r.bottom.reduce(o,0)}}getHeroDamageOnCross(e,t,i){if(!d(this.at(t,i)))throw(0,o.makeException)("InvalidMapIndices",`Tile at [${t}, ${i}] is not empty`);const n=this.getHpOnCross(e.range,t,i,!e.hasSkill("BlockPiercing"));return{left:Math.min(n.left,e.damage),right:Math.min(n.right,e.damage),top:Math.min(n.top,e.damage),bottom:Math.min(n.bottom,e.damage)}}getHeroDamageForTile(e,t,i){const n=this.getHeroDamageOnCross(e,t,i);return n.left+n.right+n.top+n.bottom}getHeroDamageForMap(e){return this.matrix.filter(d).map((t=>({damage:this.getHeroDamageForTile(e,t.i,t.j),tile:t}))).sort(((e,t)=>t.damage-e.damage))}toCoords(e){return[e%u.WIDTH,Math.floor(e/u.WIDTH)]}toIndex(e,t){return t*u.WIDTH+e}updateMatrix(){this.matrix=Array(u.WIDTH*u.HEIGHT).fill(null).map(((e,t)=>{const[i,n]=this.toCoords(t);return this.isWall(i,n)?Object.assign({i,j:n},r):Object.assign({i,j:n},a)})),this.params.blocks.forEach((e=>this.matrix[this.toIndex(e.i,e.j)]={type:"Block",block:e,i:e.i,j:e.j}))}at(e,t){const i=this.toIndex(e,t);if(i<0||i>=this.matrix.length)throw(0,o.makeException)("InvalidMapIndices",`Indices [${e}, ${t}] are out of bounds`);return this.matrix[i]}update(e){this.params=e,this.updateMatrix()}updateBlock(e){const t=this.at(e.i,e.j);if("Block"!==t.type){const t=`Tile at [${e.i}, ${e.j}] is not a block`;throw(0,o.makeException)("InvalidMapIndices",t)}t.block.updateHp(e.hp);const i=this.toIndex(e.i,e.j);e.hp<=0&&(this.matrix[i]=Object.assign({i:e.i,j:e.j},a))}get totalLife(){return this.blocks.reduce(((e,t)=>e+t.hp),0)}get totalMaxLife(){return this.params.blocks.reduce(((e,t)=>e+t.maxHp),0)}isWall(e,t){return e%2==1&&t%2==1}drawMap(){return[" "+"▄".repeat(2*u.WIDTH+2),...Array(u.HEIGHT).fill(null).map(((e,t)=>t.toString().padStart(2,"0")+"█"+Array(u.WIDTH).fill(null).map(((e,i)=>{const n=this.at(i,t);return s(n)?"Rock"===n.block.type?"▒":n.block.type[0]:d(n)?" ":"█"})).map((e=>e.repeat(2))).join("")+"█")).reverse()," "+"▀".repeat(2*u.WIDTH+2)," "+Array(u.WIDTH).fill(0).map(((e,t)=>t.toString().padStart(2,"0"))).join("")].join("\n")}toString(){return`Map: ${this.totalLife}/${this.totalMaxLife}`}formatMsgBlock(){const e=this.params.blocks.filter((e=>e.hp>0)).reduce((function(e,t){return e[t.type]=e[t.type]||[],e[t.type].push(t),e}),Object.create(null));return Object.keys(e).map(((t,i)=>`${i==Object.keys(e).length-1?"┗":"┣"} ${t}: ${e[t].length}`))}}t.TreasureMap=u,u.WIDTH=35,u.HEIGHT=17,t.StoryMap=class{constructor(e){this.update(e)}update(e){this.params=e,this.enemies=this.params.enemies.map(n.buildEnemy)}aliveEnemies(){return this.enemies.filter((e=>e.hp>0))}enemyById(e){return this.enemies.find((t=>t.id===e))}}},2855:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Squad=void 0;const n=i(2483),o=i(3622);t.Squad=class{constructor(e){this.update(e)}get heroes(){return this.params.heroes}get activeHeroes(){return this.heroes.filter((e=>e.active))}get inactiveHeroes(){return this.heroes.filter((e=>!e.active))}get rarest(){return this.activeHeroes.sort(((e,t)=>t.rarityIndex-e.rarityIndex))[0]}get notWorking(){return this.activeHeroes.filter((e=>"Work"!==e.state||0===e.energy))}get sleeping(){return this.activeHeroes.filter((e=>"Sleep"===e.state||"Work"===e.state&&0===e.energy))}get home(){return this.activeHeroes.filter((e=>"Home"===e.state))}getTotalHeroes(){const e={};return n.HERO_RARITY_ARRAY.map((t=>{e[t]=0})),this.params.heroes.reduce(((e,t)=>(e[t.rarity]=(e[t.rarity]||0)+1,e)),e)}update(e){this.params=e,this.heroById=new Map(this.heroes.map((e=>[e.id,e])))}updateHeroEnergy(e){this.byId(e.id).updateEnergy(e.energy)}updateHeroShield(e){this.byId(e.id).updateShields(e.shields)}updateHeroState(e,t){this.byId(e).setState(t)}byState(e){return this.activeHeroes.filter((t=>t.state===e))}byId(e){const t=this.heroById.get(e);if(!t){const t=`Hero with id '${e}' not present`;throw(0,o.makeException)("InvalidHeroId",t)}return t}}},9740:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StoryDetails=t.buildStoryDetails=void 0,t.buildStoryDetails=function(e){return new i(e)};class i{get maxLevel(){return this.params.maxLevel}get playedHeroes(){return this.params.playedHeroes}bestToPlay(e){return e.activeHeroes.filter((e=>!this.playedHeroes.some((t=>t.id===e.id)))).sort(((e,t)=>t.rarityIndex-e.rarityIndex))[0]}constructor(e){this.update(e)}update(e){this.params=e}}t.StoryDetails=i},889:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseGetBlockMapPayload=void 0;const n=i(2483);t.parseGetBlockMapPayload=function(e){return Object.assign(Object.assign({},e),{type:(t=e.type,function(e){return e in n.BLOCK_TYPE_MAP}(t)?n.BLOCK_TYPE_MAP[t]:"Unknown")});var t}},8993:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseRevBin=t.toRevBin=void 0,t.toRevBin=function(e){return BigInt(e).toString(2).split("").reverse().join("")},t.parseRevBin=function(e,t,i){return parseInt(e.slice(t,i).split("").reverse().join(""),2)}},9694:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},7812:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseStartExplodePayload=void 0,t.parseStartExplodePayload=function(e){return[e.blocks,{id:e.id,energy:e.energy}]}},7001:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseGetActiveBomberPayload=t.parseHeroStats=t.parseHeroRaritySimbol=t.parseHeroRarity=void 0;const n=i(2863),o=i(3622),r=i(2483);function a(e){return r.HERO_RARITY_ARRAY[e]||"Unknown"}function s(e){return r.HERO_RARITY_SIMBOL[e]||"Unknown"}function l(e){return function(e){return e in r.HERO_SKILL_MAP}(e)?r.HERO_SKILL_MAP[e]:"Unknown"}function d(e){const t=(0,n.toRevBin)(e);if(t.length<95)throw(0,o.makeException)("InvalidGenId",`gen_id '${e}' is invalid.`);return{index:(0,n.parseRevBin)(t,30,40),rarity:a((0,n.parseRevBin)(t,40,45)),raritySimbol:s((0,n.parseRevBin)(t,40,45)),rarityIndex:(0,n.parseRevBin)(t,40,45),level:(0,n.parseRevBin)(t,45,50),variant:(0,n.parseRevBin)(t,50,55),skin:(i=(0,n.parseRevBin)(t,55,60),function(e){return e in r.HERO_SKIN_MAP}(i)?r.HERO_SKIN_MAP[i]:"Unknown"),stamina:(0,n.parseRevBin)(t,60,65),speed:(0,n.parseRevBin)(t,65,70),bombSkin:(0,n.parseRevBin)(t,70,75),skillCount:(0,n.parseRevBin)(t,75,80),strength:(0,n.parseRevBin)(t,80,85),range:(0,n.parseRevBin)(t,85,90),capacity:(0,n.parseRevBin)(t,90,95)};var i}t.parseHeroRarity=a,t.parseHeroRaritySimbol=s,t.parseHeroStats=d,t.parseGetActiveBomberPayload=function(e){return Object.assign({id:e.id,state:(t=e.stage,r.STATE_ARRAY[t]||"Unknown"),energy:e.energy+e.restore_hp,shields:null==e?void 0:e.shields,heroType:e.heroType,active:Boolean(e.active),skills:e.skills.map(l)},d(e.gen_id));var t}},6908:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseSyncHousePayload=void 0;const n=i(2863),o=i(3622);t.parseSyncHousePayload=function(e){return Object.assign({active:Boolean(e.active)},function(e){const t=(0,n.toRevBin)(e);if(t.length<60)throw(0,o.makeException)("InvalidGenId",`gen_id '${e}' is invalid.`);return{id:(0,n.parseRevBin)(t,0,30),unknown0:(0,n.parseRevBin)(t,30,40),rarity:(0,n.parseRevBin)(t,40,45),recovery:(0,n.parseRevBin)(t,45,60),slots:(0,n.parseRevBin)(t,60,65),blockNumber:(0,n.parseRevBin)(t,65,t.length)}}(e.house_gen_id))}},2863:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),o(i(8993),t),o(i(889),t),o(i(7812),t),o(i(7001),t),o(i(6908),t),o(i(4245),t),o(i(9694),t),o(i(9199),t)},4245:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFloat=t.parseRewardType=void 0;const i={BOMBERMAN:"Bomberman",BCOIN:"BCoin",BCOIN_DEPOSITED:"BCoin Deposited",SENSPARK:"Senspark",MSPc:"MSPc",BOSS_TICKET:"BOSS TICKET",PVP_TICKET:"PVP TICKET",COIN:"COIN",NFT_PVP:"NFT PVP",LUS:"Lus",WOFM:"WOFM",LUS_NFT:"Lus NFT",KEY:"Key"};t.parseRewardType=function(e){return function(e){return e in i}(e)?i[e]:"Unknown"},t.isFloat=e=>void 0!==e.toString().split(".")[1]},9199:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseStoryDetailsPayload=void 0;const n=i(2863);function o(e){return{id:e.id,remainingTime:e.remaining_time}}function r(e){return{firstWin:e.first_win,rarity:(0,n.parseHeroRarity)(e.rare),rarityIndex:e.rare,replay:e.replay}}t.parseStoryDetailsPayload=function(e){return{currentLevel:e.current_level,heroId:e.hero_id,isNew:e.is_new,maxLevel:e.max_level,playedHeroes:e.played_bombers.map(o),rewards:e.level_rewards.map(r)}}},5862:function(__unused_webpack_module,exports,__webpack_require__){var __awaiter=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.convertPm2=exports.logsPm2=exports.startPm2=exports.deleteAccountPm2=exports.deletelAllPm2=exports.startAccountPm2=exports.pm2List=exports.pm2delete=exports.pm2Start=exports.pm2Connect=void 0;const pm2_1=__importDefault(__webpack_require__(5171)),tail_1=__webpack_require__(6511),constants_1=__webpack_require__(8396),config_1=__webpack_require__(9303),logger_1=__webpack_require__(609),safe_1=__importDefault(__webpack_require__(3211)),lib_1=__webpack_require__(272),fs_1=__webpack_require__(7147),pm2Connect=()=>new Promise(((e,t)=>pm2_1.default.connect((i=>{i&&t(i),e()}))));exports.pm2Connect=pm2Connect;const pm2Start=e=>new Promise(((t,i)=>pm2_1.default.start(e,(e=>{e&&(console.log(e),i(e)),t()}))));exports.pm2Start=pm2Start;const pm2delete=e=>new Promise(((t,i)=>pm2_1.default.delete(e,(e=>{e&&i(e),t()}))));exports.pm2delete=pm2delete;const pm2List=()=>new Promise(((e,t)=>pm2_1.default.list(((i,n)=>{i&&t(i),e(n)}))));exports.pm2List=pm2List;const getProcessPm2=e=>{const t={};for(const{name:i}of Object.values(constants_1.ENVS)){let n=i;if("IDENTIFY"==i&&(n="identify"),n in e){const o=e[n];null!==o&&(t[i]=o)}}return{name:e.identify,instances:1,exec_mode:"fork",script:"yarn start:bot",log_type:"json",log:"./logs",log_date_format:"DD/MM/YYYY HH:mm:ss",env:Object.assign({DEBUG_LEVEL:"info",ACTION:"game"},t)}},startAccountPm2=e=>__awaiter(void 0,void 0,void 0,(function*(){logger_1.logger.info(`Starting account ${e.identify}`);const t=getProcessPm2(e);yield(0,exports.pm2Start)(t)}));exports.startAccountPm2=startAccountPm2;const deletelAllPm2=()=>__awaiter(void 0,void 0,void 0,(function*(){yield(0,exports.pm2Connect)(),logger_1.logger.info("Deleting all account pm2");const e=yield(0,exports.pm2List)();if(e.length)for(const t of e)t.name&&(logger_1.logger.info(`Deleting account pm2 ${t.name}`),yield(0,exports.pm2delete)(t.name));pm2_1.default.disconnect()}));exports.deletelAllPm2=deletelAllPm2;const deleteAccountPm2=(e,t=!0)=>__awaiter(void 0,void 0,void 0,(function*(){t&&(yield(0,exports.pm2Connect)()),(yield(0,exports.pm2List)()).find((t=>t.name==e))?(logger_1.logger.info(`Deleting account pm2 ${e}`),yield(0,exports.pm2delete)(e),t&&pm2_1.default.disconnect()):t&&pm2_1.default.disconnect()}));exports.deleteAccountPm2=deleteAccountPm2;const startPm2=(e=!0)=>__awaiter(void 0,void 0,void 0,(function*(){yield(0,exports.pm2Connect)(),e&&(logger_1.logger.info("Deleting all account pm2"),(yield(0,exports.pm2List)()).length&&(yield(0,exports.pm2delete)("all")));const t=yield config_1.Config.findAll();for(const e of t)yield(0,exports.startAccountPm2)(e);logger_1.logger.info("Accounts started..."),pm2_1.default.disconnect()}));exports.startPm2=startPm2;const logsPm2=()=>__awaiter(void 0,void 0,void 0,(function*(){return new Promise((()=>{const e=(0,lib_1.askAndParseEnv)("IDENTIFY",lib_1.identity,void 0),t=(0,lib_1.askAndParseEnv)("TYPE",lib_1.identity,void 0);new tail_1.Tail("./logs",{nLines:10}).on("line",(function(i){const n=JSON.parse(i);if(e&&e!=n.app_name)return;const o="out"==n.type?"info":"error";if(t&&t!=n.type)return;const r=`[${n.app_name}]`,a=n.timestamp,s=n.message.replace(/\n$/,"");"error"==o?console.log(safe_1.default.red(`${r} ${a} ${s}`)):console.log(`${safe_1.default.blue(`${r} ${a}`)} ${safe_1.default.green(s)}`)}))}))}));exports.logsPm2=logsPm2;const convertPm2=()=>__awaiter(void 0,void 0,void 0,(function*(){try{const fileContent=(0,fs_1.readFileSync)("ecosystem.config.js",{encoding:"utf8"}),json=eval(fileContent);for(const e of json.apps){const t={};Object.keys(e.env).forEach((i=>{"DEBUG_LEVEL"!==i&&(t[i.toUpperCase()]=e.env[i])})),"IDENTIFY"in t||(t.IDENTIFY=e.name);const i=Object.entries(t).map((([e,t])=>`${safe_1.default.green(e)}="${t}"`)).join(" ");console.log(`ACTION=CREATE_ACCOUNT ${i} yarn start\n`)}}catch(e){return void logger_1.logger.error(e)}}));exports.convertPm2=convertPm2},9581:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sceneActivateHero=void 0;const o=i(832),r=i(341),a=i(272),s=i(7632);t.sceneActivateHero=new o.Scenes.WizardScene(s.SCENE_ACTIVATE_HERO,(e=>n(void 0,void 0,void 0,(function*(){return((e,t)=>{var i,n;return e.message&&(e.message.text=""),(null===(n=null===(i=null==e?void 0:e.update)||void 0===i?void 0:i.callback_query)||void 0===n?void 0:n.data.length)&&(e.update.callback_query.data=""),e.wizard.next(),e.wizard.steps[e.wizard.cursor](e)})(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{if(!r.bot.shouldRun)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not working`),e.scene.leave();const t=(e=>{var t,i,n,o,r,a;return(null===(i=null===(t=null==e?void 0:e.update)||void 0===t?void 0:t.callback_query)||void 0===i?void 0:i.data.length)?null===(o=null===(n=null==e?void 0:e.update)||void 0===n?void 0:n.callback_query)||void 0===o?void 0:o.data:(null===(r=e.message)||void 0===r?void 0:r.text)?null===(a=e.message)||void 0===a?void 0:a.text:""})(e);if(t){const i=t,n=r.bot.squad.heroes.find((e=>e.id==i));return n?(r.bot.telegram.telegramActivateHero(e,n),e.scene.leave()):(e.replyWithHTML(`Hero not found: ${i}`),e.scene.leave())}if(15==r.bot.squad.activeHeroes.map((e=>e.id)).length)return e.replyWithHTML("You already have 15 active heroes"),e.scene.leave();const i=r.bot.squad.inactiveHeroes.sort(((e,t)=>t.rarityIndex-e.rarityIndex));if(!i.length)return e.replyWithHTML("There is no disabled hero"),e.scene.leave();const n=i.map(((e,t)=>{var n;const o=t==i.length-1,a=(null===(n=e.shields)||void 0===n?void 0:n.length)?`${e.shields[0].current}/${e.shields[0].total}`:"empty shield";return`${o?r.bot.telegram.lastItem:r.bot.telegram.item} ${r.bot.telegram.getColor(e)} ${e.raritySimbol} [${e.id}]: shield: ${a}`})).join("\n");yield e.replyWithHTML(`Heroes (${i.length}): \n${n}`),yield(0,a.sendMessageWithButtonsTelegram)(e,"Select a hero",r.bot.telegram.createButtonsHero(i,[]),2)}catch(t){e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))))},7970:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sceneAddAccount=void 0;const o=i(832),r=i(341),a=i(272),s=i(7632),l=(e,t)=>{var i,n;return e.message&&(e.message.text=""),(null===(n=null===(i=null==e?void 0:e.update)||void 0===i?void 0:i.callback_query)||void 0===n?void 0:n.data.length)&&(e.update.callback_query.data=""),t?e.wizard.cursor=t:e.wizard.next(),e.wizard.steps[e.wizard.cursor](e)},d=e=>{var t,i,n,o,r,a;return(null===(i=null===(t=null==e?void 0:e.update)||void 0===t?void 0:t.callback_query)||void 0===i?void 0:i.data.length)?null===(o=null===(n=null==e?void 0:e.update)||void 0===n?void 0:n.callback_query)||void 0===o?void 0:o.data:(null===(r=e.message)||void 0===r?void 0:r.text)?null===(a=e.message)||void 0===a?void 0:a.text:""},c=(e,t)=>[...e.map((e=>{const i=`${t.includes(e)?"✅":""} ${e}`;return o.Markup.button.callback(i,e)})),o.Markup.button.callback("next","next")];t.sceneAddAccount=new o.Scenes.WizardScene(s.SCENE_ADD_ACCOUNT,(e=>n(void 0,void 0,void 0,(function*(){return l(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{if(!r.bot.shouldRun)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not working`),e.scene.leave();const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):["wallet","user"].includes(t)?(e.wizard.state.login=t,void("user"==t?yield l(e):yield l(e,4))):(e.replyWithHTML("Command not found, exiting command..."),e.scene.leave());yield e.replyWithHTML("to cancel the registration action, type moment /meu_cu_arrombado"),yield(0,a.sendMessageWithButtonsTelegram)(e,"Would you like to login to bomb via wallet or username",[o.Markup.button.callback("wallet","wallet"),o.Markup.button.callback("user","user")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.username=t,void(yield l(e)));yield e.replyWithHTML("Enter bomb username")}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.password=t,void(yield l(e,6)));yield e.replyWithHTML("Enter bomb password")}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.wallet=t,void(yield l(e)));yield e.replyWithHTML("Enter wallet ID")}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.privateKey=t,void(yield l(e)));yield e.replyWithHTML("Enter wallet private key"),yield e.replyWithAnimation("https://metamask.zendesk.com/hc/article_attachments/9025953096603/How_to_export_an_account_s_private_key.gif")}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){yield l(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t.length)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):"1"===t?l(e):l(e,10);yield(0,a.sendMessageWithButtonsTelegram)(e,"Does the account have a house?",[o.Markup.button.callback("No","0"),o.Markup.button.callback("Yes","1")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t.length)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):"1"===t?l(e):l(e,10);yield(0,a.sendMessageWithButtonsTelegram)(e,"Would you like to inform the heroes who will have preference to use the house?",[o.Markup.button.callback("No","0"),o.Markup.button.callback("Yes","1")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t.length)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.houseHeroes=t,l(e));yield e.replyWithHTML('inform the ids of the heroes separated by ":", \n\n example: \n\n 22324987:22824990:232824987')}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);return t?"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.network=t,l(e)):yield(0,a.sendMessageWithButtonsTelegram)(e,"Which network do you want to play?",[o.Markup.button.callback("BSC","BSC"),o.Markup.button.callback("POLYGON","POLYGON")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);return t?"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.telegramKey=t,l(e)):yield e.replyWithHTML("Enter the TELEGRAM_KEY")}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){var t;try{const i=d(e);return i?"/meu_cu_arrombado"==i?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.telegramChatId=i,l(e)):(yield e.replyWithHTML("Enter the TELEGRAM_CHAT_ID"),yield e.replyWithHTML(`Your TELEGRAM_CHAT_ID: ${null===(t=e.update)||void 0===t?void 0:t.message.chat.id}`))}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.percentageWork=parseInt(t),l(e));yield(0,a.sendMessageWithButtonsTelegram)(e,"How many % of life will the hero work with?",[o.Markup.button.callback("2","2"),o.Markup.button.callback("5","5"),o.Markup.button.callback("10","10"),o.Markup.button.callback("15","15"),o.Markup.button.callback("20","20"),o.Markup.button.callback("30","30"),o.Markup.button.callback("50","50"),o.Markup.button.callback("70","70"),o.Markup.button.callback("90","90")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.alertShield=parseInt(t),l(e));yield(0,a.sendMessageWithButtonsTelegram)(e,"How much shield does the hero have, for you to be notified?",[o.Markup.button.callback("10","10"),o.Markup.button.callback("30","30"),o.Markup.button.callback("50","50"),o.Markup.button.callback("70","70"),o.Markup.button.callback("100","100"),o.Markup.button.callback("130","130"),o.Markup.button.callback("150","150"),o.Markup.button.callback("200","200")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.numHeroWork=parseInt(t),l(e));yield(0,a.sendMessageWithButtonsTelegram)(e,"How many heroes can work at the same time?",[o.Markup.button.callback("1","1"),o.Markup.button.callback("2","2"),o.Markup.button.callback("3","3"),o.Markup.button.callback("4","4"),o.Markup.button.callback("5","5"),o.Markup.button.callback("6","6"),o.Markup.button.callback("7","7"),o.Markup.button.callback("8","8"),o.Markup.button.callback("9","9"),o.Markup.button.callback("10","10"),o.Markup.button.callback("11","11"),o.Markup.button.callback("12","12"),o.Markup.button.callback("13","13"),o.Markup.button.callback("14","14"),o.Markup.button.callback("15","15")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.server=t,l(e));yield(0,a.sendMessageWithButtonsTelegram)(e,"What server",[o.Markup.button.callback("sea","sea"),o.Markup.button.callback("na","na"),o.Markup.button.callback("sa","sa")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.identify=t,l(e));yield e.replyWithHTML("Enter an identifying name for this account")}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t.length)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):"1"===t?l(e):l(e,20);yield(0,a.sendMessageWithButtonsTelegram)(e,"Would you like to receive reports automatically? /rewards",[o.Markup.button.callback("No","0"),o.Markup.button.callback("Yes","1")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.reportRewards=t,l(e));yield e.replyWithHTML("Type in minutes, how often it should be sent, example: 120 = 2 hours")}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{if("user"===e.wizard.state.login||"BSC"==e.wizard.state.network)return l(e);const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.resetShieldAuto="1"==t,l(e));yield(0,a.sendMessageWithButtonsTelegram)(e,"Would you like to enable automatic shield reset",[o.Markup.button.callback("No","0"),o.Markup.button.callback("Yes","1")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{if("user"===e.wizard.state.login||"BSC"==e.wizard.state.network)return l(e);const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):"1"==t?l(e):l(e,23);yield(0,a.sendMessageWithButtonsTelegram)(e,"Do you want to inform the maximum value in matic to repair the shield?",[o.Markup.button.callback("No","0"),o.Markup.button.callback("Yes","1")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{if("user"===e.wizard.state.login||"BSC"==e.wizard.state.network)return l(e);const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.maxGasRepairShield=parseFloat(t),l(e));yield e.replyWithHTML("Enter the maximum value in matic, example <b>0.004</b>")}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{if("user"===e.wizard.state.login||"BSC"==e.wizard.state.network)return l(e);const t=d(e);if(t)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.alertMaterial=parseInt(t),l(e));yield e.replyWithHTML("Inform how much material you want to receive notification with")}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t.length)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.ignoreNumHeroWork="1"==t,l(e));yield(0,a.sendMessageWithButtonsTelegram)(e,"You want when the hero reaches 100% energy, he is forced to work?",[o.Markup.button.callback("No","0"),o.Markup.button.callback("Yes","1")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t.length)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):(e.wizard.state.telegramChatIdCheck="1"==t,l(e));yield(0,a.sendMessageWithButtonsTelegram)(e,`Do you want only the owner of the telegram chat id "${e.wizard.state.telegramChatId}" to be able to trigger commands on that account?`,[o.Markup.button.callback("No","0"),o.Markup.button.callback("Yes","1")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t.length)return"/meu_cu_arrombado"==t?(yield e.replyWithHTML("Hmmm..."),e.scene.leave()):"1"===t?l(e):l(e,28);yield(0,a.sendMessageWithButtonsTelegram)(e,"Do you want this account not to run any commands?",[o.Markup.button.callback("No","0"),o.Markup.button.callback("Yes","1")])}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){var t;try{const i=["/rewards","/shield","/rewards_all","/withdraw","/deactivate_hero","/add_account","/remove_account","/activate_hero"],n=d(e);if(n.length){if("/meu_cu_arrombado"==n)return yield e.replyWithHTML("Hmmm..."),e.scene.leave();if("next"==n)return l(e);const a=e.wizard.state.buttons;let s=e.wizard.state.ignoreCommands;s.includes(n)?s=s.filter((e=>e!=n)):s.push(n),e.wizard.state.ignoreCommands=s;const d=o.Markup.inlineKeyboard([...c(i,s)],{columns:1});return void(yield null===(t=r.bot.telegram.telegraf)||void 0===t?void 0:t.telegram.editMessageReplyMarkup(a.chat.id,a.message_id,"Select the command",{inline_keyboard:d.reply_markup.inline_keyboard}))}e.wizard.state.ignoreCommands=[],e.wizard.state.buttons=yield e.replyWithHTML("Select the command",o.Markup.inlineKeyboard(i.map((e=>o.Markup.button.callback(e,e))),{columns:1}))}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=d(e);if(t.length)return e.wizard.state.serial=t,l(e);yield e.replyWithHTML("Inform the serial of the account you want to add")}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))),(e=>n(void 0,void 0,void 0,(function*(){try{e.replyWithHTML("Creating account..."),yield r.bot.telegram.addAccount(e,e.wizard.state),e.replyWithHTML("Account created"),yield e.scene.leave()}catch(t){yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}}))))},4375:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sceneConfig=t.sceneConfigHouseHeroes=t.sceneConfigNumHeroes=t.sceneConfigPercentage=t.sceneConfigServer=t.sceneConfigResetShieldAuto=t.sceneConfigAlertMaterial=t.sceneConfigTelegramChatId=t.sceneConfigAlertShield=t.sceneConfigMaxGasRepairShield=void 0;const o=i(832),r=i(341),a=i(5937),s=i(272),l=i(7632),d=(e,t)=>{var i,n;return e.message&&(e.message.text=""),(null===(n=null===(i=null==e?void 0:e.update)||void 0===i?void 0:i.callback_query)||void 0===n?void 0:n.data.length)&&(e.update.callback_query.data=""),t?e.wizard.cursor=t:e.wizard.next(),e.wizard.steps[e.wizard.cursor](e)},c=e=>{var t,i,n,o,r,a;return(null===(i=null===(t=null==e?void 0:e.update)||void 0===t?void 0:t.callback_query)||void 0===i?void 0:i.data.length)?null===(o=null===(n=null==e?void 0:e.update)||void 0===n?void 0:n.callback_query)||void 0===o?void 0:o.data:(null===(r=e.message)||void 0===r?void 0:r.text)?null===(a=e.message)||void 0===a?void 0:a.text:""};t.sceneConfigMaxGasRepairShield=new o.Scenes.WizardScene(l.SCENE_CHANGE_CONFIG_MAX_GAS_REPAIR_SHIELD,(e=>n(void 0,void 0,void 0,(function*(){return d(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=c(e).replace(",",".");if(t)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nConfiguration changed, server will restarted`),yield r.bot.saveConfig(r.bot.getIdentify(),"MAX_GAS_REPAIR_SHIELD",t),e.scene.leave();yield e.replyWithHTML("Enter the maximum value in matic, example <b>0.004</b>")}catch(t){if("exit"==t.message)throw t;e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}})))),t.sceneConfigAlertShield=new o.Scenes.WizardScene(l.SCENE_CHANGE_CONFIG_ALERT_SHIELD,(e=>n(void 0,void 0,void 0,(function*(){return d(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=parseInt(c(e));if(t)return t<0||t>200?(yield e.replyWithHTML(`Value not allowed: ${t}`),e.scene.leave()):(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nConfiguration changed, server will restarted`),yield r.bot.saveConfig(r.bot.getIdentify(),"ALERT_SHIELD",t.toString()),e.scene.leave());yield(0,s.sendMessageWithButtonsTelegram)(e,"How much shield does the hero have, for you to be notified?",[o.Markup.button.callback("10","10"),o.Markup.button.callback("30","30"),o.Markup.button.callback("50","50"),o.Markup.button.callback("70","70"),o.Markup.button.callback("100","100"),o.Markup.button.callback("130","130"),o.Markup.button.callback("150","150"),o.Markup.button.callback("200","200")])}catch(t){if("exit"==t.message)throw t;e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}})))),t.sceneConfigTelegramChatId=new o.Scenes.WizardScene(l.SCENE_CHANGE_CONFIG_TELEGRAM_CHAT_ID,(e=>n(void 0,void 0,void 0,(function*(){return d(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=c(e);if(t)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nConfiguration changed, server will restarted`),yield r.bot.saveConfig(r.bot.getIdentify(),"TELEGRAM_CHAT_ID",t),e.scene.leave();yield e.replyWithHTML("Enter the TELEGRAM_CHAT_ID")}catch(t){if("exit"==t.message)throw t;e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}})))),t.sceneConfigAlertMaterial=new o.Scenes.WizardScene(l.SCENE_CHANGE_CONFIG_ALERT_MATERIAL,(e=>n(void 0,void 0,void 0,(function*(){return d(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=c(e);if(t)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nConfiguration changed, server will restarted`),yield r.bot.saveConfig(r.bot.getIdentify(),"ALERT_MATERIAL",t),e.scene.leave();yield e.replyWithHTML("Inform how much material you want to receive notification with")}catch(t){if("exit"==t.message)throw t;e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}})))),t.sceneConfigResetShieldAuto=new o.Scenes.WizardScene(l.SCENE_CHANGE_CONFIG_RESET_SHIELD_AUTO,(e=>n(void 0,void 0,void 0,(function*(){return d(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=c(e);if(t.length)return"0"!==t&&"1"!==t?(yield e.replyWithHTML(`Value not allowed: ${t}`),e.scene.leave()):(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nConfiguration changed, server will restarted`),yield r.bot.saveConfig(r.bot.getIdentify(),"RESET_SHIELD_AUTO","0"===t?null:"1"),e.scene.leave());if("user"==r.bot.loginParams.type)return yield e.replyWithHTML("Functionality only allowed when logging in with the wallet"),e.scene.leave();if("POLYGON"!=r.bot.loginParams.rede)return yield e.replyWithHTML("Functionality only allowed for POLYGON"),e.scene.leave();yield(0,s.sendMessageWithButtonsTelegram)(e,"Reset auto shield",[o.Markup.button.callback("Enable","1"),o.Markup.button.callback("Disable","0")])}catch(t){if("exit"==t.message)throw t;e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}})))),t.sceneConfigServer=new o.Scenes.WizardScene(l.SCENE_CHANGE_CONFIG_SERVER,(e=>n(void 0,void 0,void 0,(function*(){return d(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=c(e);if(t)return["na","sea","sa"].includes(t)?(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nConfiguration changed, server will restarted`),yield(0,a.setConfig)(r.bot.getIdentify(),"lastServer",null),yield r.bot.saveConfig(r.bot.getIdentify(),"SERVER",t),e.scene.leave()):(yield e.replyWithHTML("Server not found: "+t),e.scene.leave());yield(0,s.sendMessageWithButtonsTelegram)(e,"Select a server",[o.Markup.button.callback("na","na"),o.Markup.button.callback("sea","sea"),o.Markup.button.callback("sa","sa")])}catch(t){if("exit"==t.message)throw t;e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))));const u=[2,5,8,10,15,20,30,40,50,60,70,80,90,100];t.sceneConfigPercentage=new o.Scenes.WizardScene(l.SCENE_CHANGE_CONFIG_PERCENTAGE,(e=>n(void 0,void 0,void 0,(function*(){return d(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=parseInt(c(e));if(t)return u.includes(t)?(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nConfiguration changed, server will restarted`),yield r.bot.saveConfig(r.bot.getIdentify(),"MIN_HERO_ENERGY_PERCENTAGE",t.toString()),e.scene.leave()):(yield e.replyWithHTML("Percentage not found: "+t),e.scene.leave());yield(0,s.sendMessageWithButtonsTelegram)(e,"Select a percentage",u.map((e=>o.Markup.button.callback(`${e}%`,e.toString()))))}catch(t){if("exit"==t.message)throw t;e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))));const h=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];t.sceneConfigNumHeroes=new o.Scenes.WizardScene(l.SCENE_CHANGE_CONFIG_NUM_HEROES,(e=>n(void 0,void 0,void 0,(function*(){return d(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=parseInt(c(e));if(t)return h.includes(t)?(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nConfiguration changed, server will restarted`),yield r.bot.saveConfig(r.bot.getIdentify(),"NUM_HERO_WORK",t.toString()),e.scene.leave()):(yield e.replyWithHTML("Qty not found: "+t),e.scene.leave());yield(0,s.sendMessageWithButtonsTelegram)(e,"Select a qty",h.map((e=>o.Markup.button.callback(`${e}`,e.toString()))))}catch(t){if("exit"==t.message)throw t;e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}})))),t.sceneConfigHouseHeroes=new o.Scenes.WizardScene(l.SCENE_CHANGE_CONFIG_HOUSE_HEROES,(e=>n(void 0,void 0,void 0,(function*(){return d(e)}))),(e=>n(void 0,void 0,void 0,(function*(){var t;try{const i=c(e),n=(0,s.sortByRarityDesc)(r.bot.squad.activeHeroes);if(i){let a=e.wizard.state.heroesSelected;if("submit"==i)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nConfiguration changed, server will restarted`),yield r.bot.saveConfig(r.bot.getIdentify(),"HOUSE_HEROES",a.join(":")),e.scene.leave();if("cancel"==i)return yield e.replyWithHTML("Canceled"),e.scene.leave();const s=r.bot.squad.activeHeroes.find((e=>e.id==i));if(!s||!a)return e.replyWithHTML(`Hero not found: ${s}`),yield e.replyWithHTML("Canceled"),e.scene.leave();a.includes(i)?a=a.filter((e=>e!=i)):a.push(i),e.wizard.state.heroesSelected=a;const l=e.wizard.state.button,d=o.Markup.inlineKeyboard([...r.bot.telegram.createButtonsHero(n,a),o.Markup.button.callback("cancel","cancel"),o.Markup.button.callback("submit","submit")],{columns:2});return void(yield null===(t=r.bot.telegram.telegraf)||void 0===t?void 0:t.telegram.editMessageReplyMarkup(l.chat.id,l.message_id,l.text,{inline_keyboard:d.reply_markup.inline_keyboard}))}e.wizard.state.heroesSelected=r.bot.params.houseHeroes.split(":"),e.wizard.state.button=yield e.replyWithHTML("Select the heroes",o.Markup.inlineKeyboard([...r.bot.telegram.createButtonsHero(n,e.wizard.state.heroesSelected),o.Markup.button.callback("cancel","cancel"),o.Markup.button.callback("submit","submit")],{columns:2}))}catch(t){console.log(t),yield e.replyWithHTML("ERROR: \n"+t.message),e.scene.leave()}})))),t.sceneConfig=new o.Scenes.WizardScene(l.SCENE_CHANGE_CONFIG,(e=>n(void 0,void 0,void 0,(function*(){return d(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{if(!r.bot.shouldRun)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not working`),e.scene.leave();const t=c(e);if(t){const i={SERVER:l.SCENE_CHANGE_CONFIG_SERVER,MIN_HERO_ENERGY_PERCENTAGE:l.SCENE_CHANGE_CONFIG_PERCENTAGE,NUM_HERO_WORK:l.SCENE_CHANGE_CONFIG_NUM_HEROES,HOUSE_HEROES:l.SCENE_CHANGE_CONFIG_HOUSE_HEROES,TELEGRAM_CHAT_ID:l.SCENE_CHANGE_CONFIG_TELEGRAM_CHAT_ID,RESET_SHIELD_AUTO:l.SCENE_CHANGE_CONFIG_RESET_SHIELD_AUTO,MAX_GAS_REPAIR_SHIELD:l.SCENE_CHANGE_CONFIG_MAX_GAS_REPAIR_SHIELD,ALERT_MATERIAL:l.SCENE_CHANGE_CONFIG_ALERT_MATERIAL};return t in i?yield e.scene.enter(i[t]):(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nCommand not found: ${t}\n\nCanceled`),e.scene.leave())}yield(0,s.sendMessageWithButtonsTelegram)(e,"Select a config",[o.Markup.button.callback("SERVER","SERVER"),o.Markup.button.callback("MIN_HERO_ENERGY_PERCENTAGE","MIN_HERO_ENERGY_PERCENTAGE"),o.Markup.button.callback("NUM_HERO_WORK","NUM_HERO_WORK"),o.Markup.button.callback("HOUSE_HEROES","HOUSE_HEROES"),o.Markup.button.callback("TELEGRAM_CHAT_ID","TELEGRAM_CHAT_ID"),o.Markup.button.callback("RESET_SHIELD_AUTO","RESET_SHIELD_AUTO"),o.Markup.button.callback("MAX_GAS_REPAIR_SHIELD","MAX_GAS_REPAIR_SHIELD"),o.Markup.button.callback("ALERT_SHIELD","ALERT_SHIELD"),o.Markup.button.callback("ALERT_MATERIAL","ALERT_MATERIAL")],1)}catch(t){e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))))},6778:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sceneCreateMaterial=void 0;const o=i(832),r=i(341),a=i(272),s=i(7632),l=(e,t)=>{var i,n;return e.message&&(e.message.text=""),(null===(n=null===(i=null==e?void 0:e.update)||void 0===i?void 0:i.callback_query)||void 0===n?void 0:n.data.length)&&(e.update.callback_query.data=""),t?e.wizard.cursor=t:e.wizard.next(),e.wizard.steps[e.wizard.cursor](e)},d=(e,t)=>e.map((e=>{const i=`${t.includes(e.id.toString())?"✅":""} ${r.bot.telegram.getColor(e)} ${e.raritySimbol} [${e.id}]`;return o.Markup.button.callback(i,e.id.toString())}));t.sceneCreateMaterial=new o.Scenes.WizardScene(s.SCENE_CREATE_MATERIAL,(e=>n(void 0,void 0,void 0,(function*(){return r.bot.client.isConnected?r.bot.isCreatingMaterial?(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAt the moment there is already a transaction to create material`),e.scene.leave()):"user"==r.bot.loginParams.type?(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nFunctionality only allowed when logging in with the wallet`),e.scene.leave()):"POLYGON"!=r.bot.loginParams.rede?(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nFunctionality only allowed for POLYGON`),e.scene.leave()):void l(e):(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not connected, please wait`),e.scene.leave())}))),(e=>n(void 0,void 0,void 0,(function*(){var t,i,n;try{if(!r.bot.shouldRun)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not working`),e.scene.leave();const s=(e=>{var t,i,n,o,r,a;return(null===(i=null===(t=null==e?void 0:e.update)||void 0===t?void 0:t.callback_query)||void 0===i?void 0:i.data.length)?null===(o=null===(n=null==e?void 0:e.update)||void 0===n?void 0:n.callback_query)||void 0===o?void 0:o.data:(null===(r=e.message)||void 0===r?void 0:r.text)?null===(a=e.message)||void 0===a?void 0:a.text:""})(e);if(s){const a=s,c=e.wizard.state.heroes;if("submit"==a)return l(e);if("cancel"==a)return yield e.replyWithHTML("Canceled"),e.scene.leave();let u;if("all"!=a){const t=r.bot.squad.inactiveHeroes.find((e=>e.id==a));if(u=e.wizard.state.heroesSelected,!t||!u)return e.replyWithHTML(`Hero not found: ${t}`),yield e.replyWithHTML("Canceled"),e.scene.leave();u.includes(a)?u=u.filter((e=>e!=a)):u.push(a)}else u=c.map((e=>e.id.toString()));e.wizard.state.heroesSelected=u;const h=e.wizard.state.button,m=e.wizard.state.material,g=`Qty material: ${n=c,u.reduce(((e,t)=>{const i=n.find((e=>e.id.toString()==t));if(i)return e+i.receivedMaterial}),0)}`,p=o.Markup.inlineKeyboard([...d(c,u),o.Markup.button.callback("select all","all"),o.Markup.button.callback("cancel","cancel"),o.Markup.button.callback("submit","submit")],{columns:2});null===(t=r.bot.telegram.telegraf)||void 0===t||t.telegram.editMessageText(m.chat.id,m.message_id,g,g),yield null===(i=r.bot.telegram.telegraf)||void 0===i?void 0:i.telegram.editMessageReplyMarkup(h.chat.id,h.message_id,g,{inline_keyboard:p.reply_markup.inline_keyboard})}if(!e.wizard.state.button){const t=(0,a.sortByRarityAsc)(r.bot.squad.inactiveHeroes.filter((e=>"Legend"!=e.rarity&&"SuperLegend"!=e.rarity)).slice(0,90));e.wizard.state.heroes=t,e.wizard.state.heroesSelected=[],e.wizard.state.button=yield e.replyWithHTML("Select the heroes",o.Markup.inlineKeyboard([...d(t,[]),o.Markup.button.callback("select all","all"),o.Markup.button.callback("cancel","cancel"),o.Markup.button.callback("submit","submit")],{columns:2})),e.wizard.state.material=yield e.replyWithHTML("Qty material:")}}catch(t){e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))),(e=>n(void 0,void 0,void 0,(function*(){const t=e.wizard.state.heroesSelected;return 0==t.length?(yield e.replyWithHTML("No hero selected"),e.scene.leave()):(yield r.bot.createMaterial(t),e.scene.leave())}))))},6615:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sceneDeactivateHero=void 0;const o=i(832),r=i(341),a=i(272),s=i(7632);t.sceneDeactivateHero=new o.Scenes.WizardScene(s.SCENE_DEACTIVATE_HERO,(e=>n(void 0,void 0,void 0,(function*(){return((e,t)=>{var i,n;return e.message&&(e.message.text=""),(null===(n=null===(i=null==e?void 0:e.update)||void 0===i?void 0:i.callback_query)||void 0===n?void 0:n.data.length)&&(e.update.callback_query.data=""),e.wizard.next(),e.wizard.steps[e.wizard.cursor](e)})(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{if(!r.bot.shouldRun)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not working`),e.scene.leave();const t=(e=>{var t,i,n,o,r,a;return(null===(i=null===(t=null==e?void 0:e.update)||void 0===t?void 0:t.callback_query)||void 0===i?void 0:i.data.length)?null===(o=null===(n=null==e?void 0:e.update)||void 0===n?void 0:n.callback_query)||void 0===o?void 0:o.data:(null===(r=e.message)||void 0===r?void 0:r.text)?null===(a=e.message)||void 0===a?void 0:a.text:""})(e);if(t){const i=t,n=r.bot.squad.activeHeroes.find((e=>e.id==i));return n?(r.bot.telegram.telegramDeactivateHero(e,n),e.scene.leave()):(e.replyWithHTML(`Hero not found: ${n}`),e.scene.leave())}const i=r.bot.squad.activeHeroes.sort(((e,t)=>t.rarityIndex-e.rarityIndex)),n=i.map(((e,t)=>{var n;const o=t==i.length-1,a=(null===(n=e.shields)||void 0===n?void 0:n.length)?`${e.shields[0].current}/${e.shields[0].total}`:"empty shield";return`${o?r.bot.telegram.lastItem:r.bot.telegram.item} ${r.bot.telegram.getColor(e)} ${e.raritySimbol} [${e.id}]: shield: ${a}`})).join("\n");yield e.replyWithHTML(`Heroes (${i.length}): \n${n}`),yield(0,a.sendMessageWithButtonsTelegram)(e,"Select a hero",r.bot.telegram.createButtonsHero(i,[]),2)}catch(t){e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))))},7632:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SCENE_REMOVE_ACCOUNT=t.SCENE_ADD_ACCOUNT=t.SCENE_CHANGE_CONFIG_TELEGRAM_CHAT_ID=t.SCENE_CHANGE_CONFIG_RESET_SHIELD_AUTO=t.SCENE_CHANGE_CONFIG_MAX_GAS_REPAIR_SHIELD=t.SCENE_CHANGE_CONFIG_ALERT_MATERIAL=t.SCENE_CHANGE_CONFIG_ALERT_SHIELD=t.SCENE_MINT=t.SCENE_CHANGE_CONFIG_HOUSE_HEROES=t.SCENE_CHANGE_CONFIG_NUM_HEROES=t.SCENE_CHANGE_CONFIG_PERCENTAGE=t.SCENE_CHANGE_CONFIG_SERVER=t.SCENE_CHANGE_CONFIG=t.SCENE_REMOVE_DATABASE=t.SCENE_CREATE_MATERIAL=t.SCENE_PUT_HERO_WORK=t.SCENE_ACTIVATE_HERO=t.SCENE_DEACTIVATE_HERO=t.SCENE_RESET_SHIELD=void 0,t.SCENE_RESET_SHIELD="reset-shield",t.SCENE_DEACTIVATE_HERO="deactivate-hero",t.SCENE_ACTIVATE_HERO="activate-hero",t.SCENE_PUT_HERO_WORK="put-hero-work",t.SCENE_CREATE_MATERIAL="create-material",t.SCENE_REMOVE_DATABASE="remove-database",t.SCENE_CHANGE_CONFIG="change-config",t.SCENE_CHANGE_CONFIG_SERVER="change-config-server",t.SCENE_CHANGE_CONFIG_PERCENTAGE="change-config-percentage",t.SCENE_CHANGE_CONFIG_NUM_HEROES="change-config-num-heroes",t.SCENE_CHANGE_CONFIG_HOUSE_HEROES="change-config-house-heroes",t.SCENE_MINT="mint",t.SCENE_CHANGE_CONFIG_ALERT_SHIELD="change-config-alert-shield",t.SCENE_CHANGE_CONFIG_ALERT_MATERIAL="change-config-ALERT_MATERIAL",t.SCENE_CHANGE_CONFIG_MAX_GAS_REPAIR_SHIELD="change-config-MAX_GAS_REPAIR_SHIELD",t.SCENE_CHANGE_CONFIG_RESET_SHIELD_AUTO="change-config-reset-shield-auto",t.SCENE_CHANGE_CONFIG_TELEGRAM_CHAT_ID="change-config-telegram-chat-id",t.SCENE_ADD_ACCOUNT="add-account",t.SCENE_REMOVE_ACCOUNT="remove-account"},4391:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sceneMInt=void 0;const o=i(832),r=i(341),a=i(272),s=i(609),l=i(2483),d=i(2863),c=i(7632),u=(e,t)=>{var i,n;return e.message&&(e.message.text=""),(null===(n=null===(i=null==e?void 0:e.update)||void 0===i?void 0:i.callback_query)||void 0===n?void 0:n.data.length)&&(e.update.callback_query.data=""),t?e.wizard.cursor=t:e.wizard.next(),e.wizard.steps[e.wizard.cursor](e)};t.sceneMInt=new o.Scenes.WizardScene(c.SCENE_MINT,(e=>n(void 0,void 0,void 0,(function*(){return r.bot.client.isConnected?r.bot.isMinting?(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAt the moment there is already a transaction`),e.scene.leave()):(yield r.bot.web3Ready())?"user"==r.bot.loginParams.type?(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nFunctionality only allowed when logging in with the wallet`),e.scene.leave()):"POLYGON"!=r.bot.loginParams.rede?(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nFunctionality only allowed for POLYGON`),e.scene.leave()):void u(e):(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAt the moment there is already a transaction`),e.scene.leave()):(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not connected, please wait`),e.scene.leave())}))),(e=>n(void 0,void 0,void 0,(function*(){try{if(!r.bot.shouldRun)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not working`),e.scene.leave();const t=(e=>{var t,i,n,o,r,a;return(null===(i=null===(t=null==e?void 0:e.update)||void 0===t?void 0:t.callback_query)||void 0===i?void 0:i.data.length)?null===(o=null===(n=null==e?void 0:e.update)||void 0===n?void 0:n.callback_query)||void 0===o?void 0:o.data:(null===(r=e.message)||void 0===r?void 0:r.text)?null===(a=e.message)||void 0===a?void 0:a.text:""})(e);if(t){const i=["1","5","10","15"];return i.includes(t)?(e.wizard.state.qty=t,u(e)):(e.replyWithHTML(`Not found qty: ${i}`),e.scene.leave())}yield(0,a.sendMessageWithButtonsTelegram)(e,"Select qty heroes",[o.Markup.button.callback("1","1"),o.Markup.button.callback("5","5"),o.Markup.button.callback("10","10"),o.Markup.button.callback("15","15")])}catch(t){e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=e.wizard.state.qty,{bomb:i}=yield r.bot.getWalletBalance(),n=10*t;if(parseFloat(i)<n)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nyou don't have ${n} bombs for this transaction, you have ${i}`),e.scene.leave();if(r.bot.isFarming=!1,!(yield r.bot.web3Ready()))return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAt the moment there is already a transaction`),e.scene.leave();if(r.bot.isMinting=!0,r.bot.isHeroFarming&&(s.logger.info("Waiting for the heroes to finish farming"),yield r.bot.telegram.sendMessageChat("Waiting for the heroes to finish farming")),yield r.bot.awaitHeroFarm(),!r.bot.shouldRun)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not working`),e.scene.leave();yield e.scene.leave(),yield r.bot.telegram.sendMessageChat("starting mint..."),yield r.bot.client.web3Mint(t),s.logger.info("Waiting..."),yield r.bot.telegram.sendMessageChat("Waiting..."),yield r.bot.client.web3MintProcessToken();const o=yield r.bot.client.syncBomberman(),a=o.bombers.map(d.parseGetActiveBomberPayload).map(l.buildHero).filter((e=>o.newBombers.includes(e.id)));r.bot.isMinting=!1,yield r.bot.telegram.sendMessageChat("New Heroes: \n\n"+a.map((e=>r.bot.telegram.formatHero(e))).join("\n\n")),r.bot.setIsFarmTrue()}catch(e){console.log(e),r.bot.isMinting=!1,r.bot.setIsFarmTrue(),r.bot.telegram.sendMessageChat("ERROR: \n"+e.message)}}))))},4070:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.scenePutHeroWork=void 0;const o=i(832),r=i(341),a=i(272),s=i(7632);t.scenePutHeroWork=new o.Scenes.WizardScene(s.SCENE_PUT_HERO_WORK,(e=>n(void 0,void 0,void 0,(function*(){return((e,t)=>{var i,n;return e.message&&(e.message.text=""),(null===(n=null===(i=null==e?void 0:e.update)||void 0===i?void 0:i.callback_query)||void 0===n?void 0:n.data.length)&&(e.update.callback_query.data=""),e.wizard.next(),e.wizard.steps[e.wizard.cursor](e)})(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{if(!r.bot.shouldRun)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not working`),e.scene.leave();const t=(e=>{var t,i,n,o,r,a;return(null===(i=null===(t=null==e?void 0:e.update)||void 0===t?void 0:t.callback_query)||void 0===i?void 0:i.data.length)?null===(o=null===(n=null==e?void 0:e.update)||void 0===n?void 0:n.callback_query)||void 0===o?void 0:o.data:(null===(r=e.message)||void 0===r?void 0:r.text)?null===(a=e.message)||void 0===a?void 0:a.text:""})(e);if(t){const i=t,n=r.bot.squad.activeHeroes.find((e=>e.id==i));return n?n.energy<=0?(e.replyWithHTML("Hero without power"),e.scene.leave()):r.bot.getSumShield(n)<=0?(e.replyWithHTML("Hero without shield"),e.scene.leave()):(yield e.replyWithHTML(`Sending hero ${n.id} to work`),yield r.bot.toWork(n),yield r.bot.telegram.telegramStats(e),e.scene.leave()):(e.replyWithHTML(`Hero not found: ${i}`),e.scene.leave())}const i=r.bot.squad.activeHeroes.filter((e=>"Work"!=e.state)).sort(((e,t)=>t.rarityIndex-e.rarityIndex));if(!i.length)return e.replyWithHTML("No heroes found"),e.scene.leave();const n=i.map(((e,t)=>{var n;const o=t==i.length-1,a=(null===(n=e.shields)||void 0===n?void 0:n.length)?`${e.shields[0].current}/${e.shields[0].total}`:"empty shield";return`${o?r.bot.telegram.lastItem:r.bot.telegram.item} ${r.bot.telegram.getColor(e)} ${e.raritySimbol} [${e.id}]: shield: ${a}`})).join("\n");yield e.replyWithHTML(`Heroes (${i.length}): \n${n}`),yield(0,a.sendMessageWithButtonsTelegram)(e,"Select a hero",r.bot.telegram.createButtonsHero(i,[]),2)}catch(t){e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))))},6464:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sceneRemoveAccount=void 0;const o=i(832),r=i(341),a=i(5937),s=i(272),l=i(7632),d=i(9303),c=i(5862);t.sceneRemoveAccount=new o.Scenes.WizardScene(l.SCENE_REMOVE_ACCOUNT,(e=>n(void 0,void 0,void 0,(function*(){return((e,t)=>{var i,n;return e.message&&(e.message.text=""),(null===(n=null===(i=null==e?void 0:e.update)||void 0===i?void 0:i.callback_query)||void 0===n?void 0:n.data.length)&&(e.update.callback_query.data=""),e.wizard.next(),e.wizard.steps[e.wizard.cursor](e)})(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{if(!r.bot.shouldRun)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not working`),e.scene.leave();const t=yield d.Config.findAll(),i=(e=>{var t,i,n,o,r,a;return(null===(i=null===(t=null==e?void 0:e.update)||void 0===t?void 0:t.callback_query)||void 0===i?void 0:i.data.length)?null===(o=null===(n=null==e?void 0:e.update)||void 0===n?void 0:n.callback_query)||void 0===o?void 0:o.data:(null===(r=e.message)||void 0===r?void 0:r.text)?null===(a=e.message)||void 0===a?void 0:a.text:""})(e);if(i)return t.find((e=>e.identify==i))?(yield e.replyWithHTML("Removing account..."),yield e.scene.leave(),yield(0,c.pm2delete)(i),void(yield(0,a.removeAllDataAccount)(i))):(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not found: ${i}`),e.scene.leave());yield(0,s.sendMessageWithButtonsTelegram)(e,"Select a account",t.map((e=>o.Markup.button.callback(e.identify,e.identify))))}catch(t){e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))))},9300:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sceneRemoveDatabase=void 0;const o=i(832),r=i(341),a=i(9303),s=i(5937),l=i(272),d=i(7632);t.sceneRemoveDatabase=new o.Scenes.WizardScene(d.SCENE_REMOVE_DATABASE,(e=>n(void 0,void 0,void 0,(function*(){return((e,t)=>{var i,n;return e.message&&(e.message.text=""),(null===(n=null===(i=null==e?void 0:e.update)||void 0===i?void 0:i.callback_query)||void 0===n?void 0:n.data.length)&&(e.update.callback_query.data=""),e.wizard.next(),e.wizard.steps[e.wizard.cursor](e)})(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{if(!r.bot.shouldRun)return yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not working`),e.scene.leave();const t=yield a.Config.findAll(),i=(e=>{var t,i,n,o,r,a;return(null===(i=null===(t=null==e?void 0:e.update)||void 0===t?void 0:t.callback_query)||void 0===i?void 0:i.data.length)?null===(o=null===(n=null==e?void 0:e.update)||void 0===n?void 0:n.callback_query)||void 0===o?void 0:o.data:(null===(r=e.message)||void 0===r?void 0:r.text)?null===(a=e.message)||void 0===a?void 0:a.text:""})(e);if(i)return t.find((e=>e.identify!=i))?(yield e.replyWithHTML("Removing account from database..."),yield(0,s.removeAllDataAccount)(i),void(yield e.scene.leave())):(yield e.replyWithHTML(`Account: ${r.bot.getIdentify()}\n\nAccount not found: ${i}`),e.scene.leave());yield(0,l.sendMessageWithButtonsTelegram)(e,"Select a account",t.map((e=>o.Markup.button.callback(e.identify,e.identify))))}catch(t){e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))))},9822:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sceneResetShield=void 0;const o=i(832),r=i(341),a=i(272),s=i(7632);t.sceneResetShield=new o.Scenes.WizardScene(s.SCENE_RESET_SHIELD,(e=>n(void 0,void 0,void 0,(function*(){return((e,t)=>{var i,n;return e.message&&(e.message.text=""),(null===(n=null===(i=null==e?void 0:e.update)||void 0===i?void 0:i.callback_query)||void 0===n?void 0:n.data.length)&&(e.update.callback_query.data=""),e.wizard.next(),e.wizard.steps[e.wizard.cursor](e)})(e)}))),(e=>n(void 0,void 0,void 0,(function*(){try{const t=(e=>{var t,i,n,o,r,a;return(null===(i=null===(t=null==e?void 0:e.update)||void 0===t?void 0:t.callback_query)||void 0===i?void 0:i.data.length)?null===(o=null===(n=null==e?void 0:e.update)||void 0===n?void 0:n.callback_query)||void 0===o?void 0:o.data:(null===(r=e.message)||void 0===r?void 0:r.text)?null===(a=e.message)||void 0===a?void 0:a.text:""})(e);if(t){const i=t;return r.bot.squad.activeHeroes.find((e=>e.id==i))?(r.bot.telegram.telegramResetShield(e,i),e.scene.leave()):(e.replyWithHTML(`Hero not found: ${i}`),e.scene.leave())}yield(0,a.sendMessageWithButtonsTelegram)(e,"Select a hero",r.bot.telegram.createButtonsHero(r.bot.telegram.bot.squad.activeHeroes,[]),2)}catch(t){e.scene.leave(),e.replyWithHTML("ERROR: \n"+t.message)}}))))},2402:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),global.WebSocket=i(5352)},2897:(e,t,i)=>{const{DataTypes:n}=i(496);e.exports={name:"20230211124400-migration-skeleton.js",async up(e){await e.sequelize.query("CREATE TABLE IF NOT EXISTS `Configs` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `identify` VARCHAR(255), `username` VARCHAR(255), `lastServer` VARCHAR(255), `materialAlert` INTEGER, `telegramCommands` INTEGER, `lastReport` INTEGER, `start` INTEGER, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL)"),await e.sequelize.query("CREATE TABLE IF NOT EXISTS `HeroShields` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `identify` VARCHAR(255), `hero` INTEGER, `shield` INTEGER, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL)"),await e.sequelize.query("CREATE TABLE IF NOT EXISTS `HeroZeroShields` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `identify` VARCHAR(255), `hero` INTEGER, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL)"),await e.sequelize.query("CREATE TABLE IF NOT EXISTS `LastResetShields` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `identify` VARCHAR(255), `date` INTEGER, `hero` INTEGER, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL)"),await e.sequelize.query("CREATE TABLE IF NOT EXISTS `MapEntities` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `identify` VARCHAR(255), `date` INTEGER, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL)"),await e.sequelize.query("CREATE TABLE IF NOT EXISTS `Reports` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `identify` VARCHAR(255), `date` INTEGER, `bcoin` FLOAT, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL)"),await e.sequelize.query("CREATE TABLE IF NOT EXISTS `Rewards` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `identify` VARCHAR(255), `type` VARCHAR(255), `network` VARCHAR(255), `date` INTEGER, `value` FLOAT, `claimPending` FLOAT, `remainTime` FLOAT, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL)"),e.addColumn("Configs","network",{type:n.STRING,allowNull:!0})},async down(e){e.removeColumn("Configs","network")}}},6274:(e,t,i)=>{const{DataTypes:n}=i(496);e.exports={name:"20230211124402-migration-skeleto1.js",async up(e){(await e.describeTable("Configs")).teste||e.addColumn("Configs","teste",{type:n.STRING,allowNull:!0})},async down(e){e.removeColumn("Configs","teste")}}},8988:(e,t,i)=>{const{DataTypes:n}=i(496);e.exports={name:"20230211124403-migration-config.js",async up(e){const t=await e.describeTable("Configs");t.network&&await e.removeColumn("Configs","network",{type:n.STRING,allowNull:!0}),t.TELEGRAM_KEY||await e.addColumn("Configs","TELEGRAM_KEY",{type:n.STRING,allowNull:!0}),t.MIN_HERO_ENERGY_PERCENTAGE||await e.addColumn("Configs","MIN_HERO_ENERGY_PERCENTAGE",{type:n.STRING,allowNull:!0}),t.MODE_ADVENTURE||await e.addColumn("Configs","MODE_ADVENTURE",{type:n.STRING,allowNull:!0}),t.wallet||await e.addColumn("Configs","wallet",{type:n.STRING,allowNull:!0}),t.ADVENTURE_HEROES||await e.addColumn("Configs","ADVENTURE_HEROES",{type:n.STRING,allowNull:!0}),t.HOUSE_HEROES||await e.addColumn("Configs","HOUSE_HEROES",{type:n.STRING,allowNull:!0}),t.IGNORE_NUM_HERO_WORK||await e.addColumn("Configs","IGNORE_NUM_HERO_WORK",{type:n.STRING,allowNull:!0}),t.TRY_SERVERS||await e.addColumn("Configs","TRY_SERVERS",{type:n.STRING,allowNull:!0}),t.RESET_SHIELD_AUTO||await e.addColumn("Configs","RESET_SHIELD_AUTO",{type:n.STRING,allowNull:!0}),t.NETWORK||await e.addColumn("Configs","NETWORK",{type:n.STRING,allowNull:!0}),t.ALERT_SHIELD||await e.addColumn("Configs","ALERT_SHIELD",{type:n.STRING,allowNull:!0}),t.NUM_HERO_WORK||await e.addColumn("Configs","NUM_HERO_WORK",{type:n.STRING,allowNull:!0}),t.TELEGRAM_CHAT_ID||await e.addColumn("Configs","TELEGRAM_CHAT_ID",{type:n.STRING,allowNull:!0}),t.REWARDS_ALL_PERMISSION||await e.addColumn("Configs","REWARDS_ALL_PERMISSION",{type:n.STRING,allowNull:!0}),t.TELEGRAM_CHAT_ID_CHECK||await e.addColumn("Configs","TELEGRAM_CHAT_ID_CHECK",{type:n.STRING,allowNull:!0}),t.IGNORE_SHIELD_HERO_HOUSE||await e.addColumn("Configs","IGNORE_SHIELD_HERO_HOUSE",{type:n.STRING,allowNull:!0}),t.REPORT_REWARDS||await e.addColumn("Configs","REPORT_REWARDS",{type:n.STRING,allowNull:!0}),t.SERVER||await e.addColumn("Configs","SERVER",{type:n.STRING,allowNull:!0}),t.MAX_GAS_REPAIR_SHIELD||await e.addColumn("Configs","MAX_GAS_REPAIR_SHIELD",{type:n.STRING,allowNull:!0}),t.ALERT_MATERIAL||await e.addColumn("Configs","ALERT_MATERIAL",{type:n.STRING,allowNull:!0}),t.WORK_HERO_WITH_SHIELD||await e.addColumn("Configs","WORK_HERO_WITH_SHIELD",{type:n.STRING,allowNull:!0}),t.IGNORE_REWARD_CURRENCY||await e.addColumn("Configs","IGNORE_REWARD_CURRENCY",{type:n.STRING,allowNull:!0}),t.IGNORE_COMMANDS||await e.addColumn("Configs","IGNORE_COMMANDS",{type:n.STRING,allowNull:!0}),t.LOGIN||await e.addColumn("Configs","LOGIN",{type:n.STRING,allowNull:!0})},async down(){}}},1786:(e,t,i)=>{const{DataTypes:n}=i(496);e.exports={name:"20230211124404-migration-serial.js",async up(e){(await e.describeTable("Configs")).SERIAL||await e.addColumn("Configs","SERIAL",{type:n.STRING,allowNull:!0})},async down(){}}},3211:e=>{e.exports=require("colors/safe")},5666:e=>{e.exports=require("crypto-js")},4280:e=>{e.exports=require("csv-parser")},2401:e=>{e.exports=require("csv-writer")},4146:e=>{e.exports=require("date-fns")},6452:e=>{e.exports=require("got")},5171:e=>{e.exports=require("pm2")},496:e=>{e.exports=require("sequelize")},4464:e=>{e.exports=require("sequelize-typescript")},5699:e=>{e.exports=require("sfs2x-api")},8087:e=>{e.exports=require("socket.io-client")},6511:e=>{e.exports=require("tail")},832:e=>{e.exports=require("telegraf")},807:e=>{e.exports=require("user-agents")},8519:e=>{e.exports=require("web3")},7773:e=>{e.exports=require("winston")},5352:e=>{e.exports=require("ws")},6113:e=>{e.exports=require("crypto")},7147:e=>{e.exports=require("fs")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},7742:e=>{e.exports=require("node:process")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.exports}var __webpack_exports__=__webpack_require__(341)})();