/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@aladas-org/cryptocalc@0.5.11/www/js/_main/electron_main.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";const MAIN_WINDOW_WIDTH=1040,MAIN_WINDOW_HEIGHT=651,{app:app,Menu:Menu,BrowserWindow:BrowserWindow,ipcMain:ipcMain,shell:shell,remote:remote,dialog:dialog}=require("electron");require("v8-compile-cache");const os=require("os"),{exec:exec}=require("child_process"),WINDOWS="win32",LINUX="linux",FREE_BSD="freebsd",OPEN_BSD="openbsd",fs=require("fs"),path=require("path"),{v4:uuidv4}=require("uuid"),checkInternetConnected=require("check-internet-connected"),PasswordGenerator=require("generate-password"),{_CYAN_:_CYAN_,_RED_:_RED_,_PURPLE_:_PURPLE_,_YELLOW_:_YELLOW_,_END_:_END_}=require("../util/color/color_console_codes.js"),{pretty_func_header_log:pretty_func_header_log,pretty_log:pretty_log}=require("../util/log/log_utils.js"),{Skribi:Skribi}=require("../util/log/skribi.js"),{APP_VERSION:APP_VERSION,PROGRAM:PROGRAM,ELECTRON_LAUNCHER:ELECTRON_LAUNCHER,EXE_LAUNCHER:EXE_LAUNCHER,OUTPUT_DIR_PATH:OUTPUT_DIR_PATH,INVALID_OUTPUT_DIR_PATH:INVALID_OUTPUT_DIR_PATH,SELECT_DIRECTORY_PATH_MODE:SELECT_DIRECTORY_PATH_MODE,SELECT_FILE_PATH_MODE:SELECT_FILE_PATH_MODE,WITS_PATH:WITS_PATH,PATH:PATH,ARGS:ARGS,BLOCKCHAIN:BLOCKCHAIN,BIP32_PASSPHRASE:BIP32_PASSPHRASE,BIP32_PROTOCOL:BIP32_PROTOCOL,ACCOUNT:ACCOUNT,ADDRESS_INDEX:ADDRESS_INDEX}=require("../const_keywords.js"),{CRYPTO_NET:CRYPTO_NET}=require("../crypto/const_wallet.js"),{CMD_OPEN_WALLET:CMD_OPEN_WALLET,VIEW_TOGGLE_DEVTOOLS:VIEW_TOGGLE_DEVTOOLS,TOOLS_OPTIONS:TOOLS_OPTIONS,TOOLS_DATABASE_MANAGEMENT:TOOLS_DATABASE_MANAGEMENT,TOOLS_BIP38_ENCRYPTER_DECRYTER:TOOLS_BIP38_ENCRYPTER_DECRYTER,TOOLS_SECRET_PHRASE_TRANSLATOR:TOOLS_SECRET_PHRASE_TRANSLATOR,ToMain_RQ_QUIT_APP:ToMain_RQ_QUIT_APP,ToMain_RQ_LOG_2_MAIN:ToMain_RQ_LOG_2_MAIN,ToMain_RQ_LOG_2_MAIN_SYNC:ToMain_RQ_LOG_2_MAIN_SYNC,ToMain_RQ_GET_APP_PATH:ToMain_RQ_GET_APP_PATH,ToMain_RQ_EXEC_CMD:ToMain_RQ_EXEC_CMD,ToMain_RQ_SET_WINDOW_TITLE:ToMain_RQ_SET_WINDOW_TITLE,ToMain_RQ_TOGGLE_DEBUG_PANEL:ToMain_RQ_TOGGLE_DEBUG_PANEL,ToMain_RQ_SELECT_FILE_OR_DIRECTORY_PATH_DIALOG:ToMain_RQ_SELECT_FILE_OR_DIRECTORY_PATH_DIALOG,ToMain_RQ_IMPORT_OUTPUT_FILES_IN_DATABASE:ToMain_RQ_IMPORT_OUTPUT_FILES_IN_DATABASE,ToMain_RQ_NEW_WALLET_INFO:ToMain_RQ_NEW_WALLET_INFO,ToMain_RQ_OPEN_WALLET_INFO:ToMain_RQ_OPEN_WALLET_INFO,ToMain_RQ_SAVE_WALLET_INFO:ToMain_RQ_SAVE_WALLET_INFO,ToMain_RQ_OPEN_URL:ToMain_RQ_OPEN_URL,ToMain_RQ_SHOW_OUTPUT_FOLDER_IN_EXPLORER:ToMain_RQ_SHOW_OUTPUT_FOLDER_IN_EXPLORER,ToMain_RQ_LOAD_IMG_FROM_FILE:ToMain_RQ_LOAD_IMG_FROM_FILE,ToMain_RQ_DRAW_RND_CRYPTO_LOGO:ToMain_RQ_DRAW_RND_CRYPTO_LOGO,ToMain_RQ_MNEMONICS_TO_ENTROPY_INFO:ToMain_RQ_MNEMONICS_TO_ENTROPY_INFO,ToMain_RQ_MNEMONICS_TO_HD_WALLET_INFO:ToMain_RQ_MNEMONICS_TO_HD_WALLET_INFO,ToMain_RQ_GET_SIMPLE_WALLET:ToMain_RQ_GET_SIMPLE_WALLET,ToMain_RQ_ENTROPY_TO_MNEMONICS:ToMain_RQ_ENTROPY_TO_MNEMONICS,ToMain_RQ_ENTROPY_TO_CHECKSUM:ToMain_RQ_ENTROPY_TO_CHECKSUM,ToMain_RQ_ENTROPY_SRC_TO_ENTROPY:ToMain_RQ_ENTROPY_SRC_TO_ENTROPY,ToMain_RQ_MNEMONICS_AS_4LETTER:ToMain_RQ_MNEMONICS_AS_4LETTER,ToMain_RQ_MNEMONICS_AS_TWO_PARTS:ToMain_RQ_MNEMONICS_AS_TWO_PARTS,ToMain_RQ_GET_UUID:ToMain_RQ_GET_UUID,ToMain_RQ_GET_L10N_KEYPAIRS:ToMain_RQ_GET_L10N_KEYPAIRS,ToMain_RQ_GET_L10N_MSG:ToMain_RQ_GET_L10N_MSG,ToMain_RQ_SET_MENU_ITEM_STATE:ToMain_RQ_SET_MENU_ITEM_STATE,ToMain_RQ_CHECK_MNEMONICS:ToMain_RQ_CHECK_MNEMONICS,ToMain_RQ_WORD_INDEXES_TO_MNEMONICS:ToMain_RQ_WORD_INDEXES_TO_MNEMONICS,ToMain_RQ_MNEMONICS_TO_WORD_INDEXES:ToMain_RQ_MNEMONICS_TO_WORD_INDEXES,ToMain_RQ_GUESS_MNEMONICS_LANG:ToMain_RQ_GUESS_MNEMONICS_LANG,ToMain_RQ_SAVE_OPTIONS:ToMain_RQ_SAVE_OPTIONS,ToMain_RQ_RESET_OPTIONS:ToMain_RQ_RESET_OPTIONS,ToMain_RQ_UPDATE_OPTIONS:ToMain_RQ_UPDATE_OPTIONS,ToMain_RQ_GET_FORTUNE_COOKIE:ToMain_RQ_GET_FORTUNE_COOKIE,ToMain_RQ_GENERATE_PASSWORD:ToMain_RQ_GENERATE_PASSWORD,ToMain_RQ_GET_HD_WALLET:ToMain_RQ_GET_HD_WALLET,ToMain_RQ_BIP38_ENCRYPT:ToMain_RQ_BIP38_ENCRYPT,ToMain_RQ_BIP38_DECRYPT:ToMain_RQ_BIP38_DECRYPT,ToMain_RQ_GET_PASSWORD_STRENGTH:ToMain_RQ_GET_PASSWORD_STRENGTH,FromMain_DID_FINISH_LOAD:FromMain_DID_FINISH_LOAD,FromMain_EXEC_CMD:FromMain_EXEC_CMD,FromMain_FILE_NEW:FromMain_FILE_NEW,FromMain_FILE_OPEN:FromMain_FILE_OPEN,FromMain_FILE_SAVE:FromMain_FILE_SAVE,FromMain_HELP_ABOUT:FromMain_HELP_ABOUT,FromMain_TOOLS_OPTIONS_DIALOG:FromMain_TOOLS_OPTIONS_DIALOG,FromMain_TOOLS_DB_MANAGEMENT_DIALOG:FromMain_TOOLS_DB_MANAGEMENT_DIALOG,FromMain_TOOLS_BIP38_ENCRYPT_DECRYPT_DIALOG:FromMain_TOOLS_BIP38_ENCRYPT_DECRYPT_DIALOG,FromMain_TOOLS_SECRET_PHRASE_TRANSLATOR_DIALOG:FromMain_TOOLS_SECRET_PHRASE_TRANSLATOR_DIALOG,FromMain_UPDATE_OPTIONS:FromMain_UPDATE_OPTIONS,FromMain_SEND_IMG_URL:FromMain_SEND_IMG_URL,FromMain_SET_FORTUNE_COOKIE:FromMain_SET_FORTUNE_COOKIE,FromMain_SET_VARIABLE:FromMain_SET_VARIABLE,FromMain_INTERNET_CONNECTED:FromMain_INTERNET_CONNECTED}=require("../const_events.js"),{ENTROPY_SOURCE_IMG_ID:ENTROPY_SOURCE_IMG_ID}=require("../view/const_gui.js"),{DEFAULT_OPTIONS:DEFAULT_OPTIONS}=require("../crypto/const_default_options.js"),{getShortenedString:getShortenedString}=require("../util/values/string_utils.js"),{FileUtils:FileUtils}=require("../util/system/file_utils.js"),{Bip39Utils:Bip39Utils}=require("../crypto/bip39_utils.js"),{Bip38Utils:Bip38Utils}=require("../crypto/bip38_utils.js"),{PasswordStrengthEvaluator:PasswordStrengthEvaluator}=require("../crypto/password_strength_evaluator.js"),{getRandomInt:getRandomInt}=require("../crypto/hex_utils.js"),{getFortuneCookie:getFortuneCookie}=require("../util/fortune/fortune.js"),{L10nUtils:L10nUtils}=require("../L10n/L10n_utils.js"),{Bip32Utils:Bip32Utils}=require("../crypto/HDWallet/bip32_utils.js"),{HDWallet:HDWallet}=require("../crypto/HDWallet/hd_wallet.js"),{SimpleWallet:SimpleWallet}=require("../crypto/SimpleWallet/simple_wallet.js"),{MainModel:MainModel}=require("../model/main_model.js"),{SqLiteUtils:SqLiteUtils}=require("./db/sqlite_utils.js"),DEFAULT_APP_CONFIG={ToFile:!0},gotTheLock=app.requestSingleInstanceLock(),error_handler=e=>{if(e)return Skribi.log("error: "+e);Skribi.log("saving file... "+filename)};class ElectronMain{static#e=Symbol();static#n=new ElectronMain(this.#e);static#i=0;static GetInstance(){if(null==ElectronMain.#n){if(this.#n=new ElectronMain(this.#e),this.#i>0)throw new TypeError("'ElectronMain' constructor called more than once");this.#i++}return ElectronMain.#n}constructor(e){if(e!==ElectronMain.#e)throw new TypeError("'ElectronMain' constructor is private");this.cryptowallet_version="x.x.x",this.app_config=DEFAULT_APP_CONFIG,this.cmd_line={},this.cmd_line[PROGRAM]=ELECTRON_LAUNCHER,this.cmd_line[PATH]=".",this.cmd_line[ARGS]="",this.DidFinishLoad_FiredCount=0,this.Show_DebugPanel=!1,this.MainWindow=void 0,this.Options={},this.SupportedBlockchains={},this.FirstImageAsEntropySource=!0,this.output_path=""}createBrowserWindow(e){new BrowserWindow({height:900,width:1200}).loadURL(e)}getMainWindow(){return this.MainWindow}isLaunchedFromExe(){return this.cmd_line[PROGRAM]==EXE_LAUNCHER}getCmdLineArgs(){let e=process.argv.length;return e>0&&(this.cmd_line[PROGRAM]=path.basename(process.argv[0])),e>1&&(this.cmd_line[PATH]=process.argv[1]),e>2&&(this.cmd_line[ARGS]=process.argv[2]),"nb_args: "+e+PROGRAM+": "+this.cmd_line[PROGRAM]+PATH+": "+this.cmd_line[PATH]+ARGS+": "+this.cmd_line[ARGS]}getMenuTemplate(){return[{label:L10nUtils.GetLocalizedMsg("File"),submenu:[{label:L10nUtils.GetLocalizedMsg("New"),async click(){await ElectronMain.GetInstance().doFileNew()}},{label:L10nUtils.GetLocalizedMsg("Open"),async click(){await ElectronMain.GetInstance().doFileOpen()}},{label:L10nUtils.GetLocalizedMsg("Save"),click(){ElectronMain.GetInstance().doFileSave()},id:"file_save_menu_item_id"},{label:L10nUtils.GetLocalizedMsg("SaveAs"),click(){ElectronMain.GetInstance().doFileSaveAs()},id:"file_save_as_menu_item_id"},{label:L10nUtils.GetLocalizedMsg("Quit"),click(){app.quit()}}]},{label:L10nUtils.GetLocalizedMsg("View"),submenu:[{label:L10nUtils.GetLocalizedMsg("ToggleDebug"),type:"checkbox",click(){pretty_func_header_log("[Electron]",VIEW_TOGGLE_DEVTOOLS),ElectronMain.GetInstance().toggleDebugPanel()}}]},{label:L10nUtils.GetLocalizedMsg("Tools"),submenu:[{label:"Options...",click(){pretty_func_header_log("[Electron]",TOOLS_OPTIONS),ElectronMain.GetInstance().getMainWindow().webContents.send("fromMain",[FromMain_TOOLS_OPTIONS_DIALOG,ElectronMain.GetInstance().Options])}},{label:L10nUtils.GetLocalizedMsg("DatabaseManagementTool"),click(){pretty_func_header_log("[Electron]",TOOLS_DATABASE_MANAGEMENT),ElectronMain.GetInstance().getMainWindow().webContents.send("fromMain",[FromMain_TOOLS_DB_MANAGEMENT_DIALOG,SqLiteUtils.This.appFolderPath])}},{label:L10nUtils.GetLocalizedMsg("SecretPhraseTranslatorTool"),click(){pretty_func_header_log("[Electron]",TOOLS_SECRET_PHRASE_TRANSLATOR),ElectronMain.GetInstance().getMainWindow().webContents.send("fromMain",[FromMain_TOOLS_SECRET_PHRASE_TRANSLATOR_DIALOG,ElectronMain.GetInstance().Options])}},{label:L10nUtils.GetLocalizedMsg("Bip38EncryptDecryptTool"),click(){pretty_func_header_log("[Electron]",TOOLS_BIP38_ENCRYPTER_DECRYTER),ElectronMain.GetInstance().getMainWindow().webContents.send("fromMain",[FromMain_TOOLS_BIP38_ENCRYPT_DECRYPT_DIALOG,ElectronMain.GetInstance().Options])}}]},{label:L10nUtils.GetLocalizedMsg("Help"),submenu:[{label:"Setup guide and User's Manual",click(){ElectronMain.GetInstance().createBrowserWindow(app.getAppPath()+"/_doc/README.html")}},{label:"Cryptocalc Test protocols",click(){ElectronMain.GetInstance().createBrowserWindow(app.getAppPath()+"/tests/_doc/index.html")}},{label:L10nUtils.GetLocalizedMsg("Resources"),submenu:[{label:"Ian Coleman BIP39",click(){ElectronMain.GetInstance().createBrowserWindow("https://iancoleman.io/bip39/")}},{label:"Guarda",click(){ElectronMain.GetInstance().createBrowserWindow("https://guarda.com/")}}]},{label:L10nUtils.GetLocalizedMsg("About"),click(){ElectronMain.GetInstance().getMainWindow().webContents.send("fromMain",[FromMain_HELP_ABOUT])}}]}]}createWindow(){pretty_func_header_log("ElectronMain.createWindow"),process.env.ELECTRON_DISABLE_SECURITY_WARNINGS="true",this.MainWindow=new BrowserWindow({width:1040,height:651,icon:path.join(__dirname,"../../icons/Cryptocalc_Icon.png"),webPreferences:{contextIsolation:!0,preload:path.join(__dirname,"./preload.js")}}),console.log("ElectronMain.createWindow()  this.MainWindow: "+typeof this.MainWindow),MainModel.This.setMainWindow(this.MainWindow);const e=Menu.buildFromTemplate(this.getMenuTemplate());Menu.setApplicationMenu(e),this.MainWindow.webContents.on("did-finish-load",(async()=>{Skribi.Initialize(this.app_config),this.app_config=this.readAppConfig(),this.getCmdLineArgs(),Skribi.log(">> "+_CYAN_+"eMain.evtH('"+_YELLOW_+"'did-finish-load'"+_CYAN_+")> this.cmd_line[PROGRAM]: "+_END_+this.cmd_line[PROGRAM]),this.cryptowallet_version=MainModel.This.getAppVersion(),this.updateWindowTitle(),this.MainWindow.webContents.send("fromMain",[FromMain_DID_FINISH_LOAD]),this.MainWindow.webContents.send("fromMain",[FromMain_SET_VARIABLE,APP_VERSION,this.cryptowallet_version]),this.MainWindow.webContents.setWindowOpenHandler((e=>(shell.openExternal(e.url),{action:"deny"}))),this.setCallbacks(),this.Options=await this.loadOptions();let e=this.cmd_line[PATH];e.endsWith(".wits")&&(Skribi.log(">> "+_CYAN_+"eMain.evtH('"+_RED_+"'did-finish-load'"+_CYAN_+")> SET_VARIABLE("+WITS_PATH+") in Renderer"+_END_+e),await this.MainWindow.webContents.send("fromMain",[FromMain_SET_VARIABLE,WITS_PATH,e])),await this.doFileNew()}));let n=path.join(__dirname,"../../../www/index.html");this.MainWindow.loadFile(n)}async openWits(e){if(null==e)throw new Error("**ERROR** in Cryptowallet: '.wits' path is undefined");if(Skribi.log(">> "+_CYAN_+"eMain.evtH('"+_YELLOW_+"'openWits'"+_CYAN_+")> *TEST* Trying to Open '.wits': "+_END_+e),e.endsWith(".wits")){const n=fs.readFileSync(e,{encoding:"utf8",flag:"r"});let i=JSON.parse(n);this.Options=await this.loadOptions(),await this.MainWindow.webContents.send("fromMain",[FromMain_EXEC_CMD,CMD_OPEN_WALLET,i])}}updateWindowTitle(e,n){let i="Cryptowallet "+this.cryptowallet_version;null!=n&&""!=n&&(i+=" - "+n),null!=e&&""!=e&&(i+=": "+e),this.MainWindow.setTitle(i)}async doFileNew(){Skribi.log(">> "+_CYAN_+"ElectronMain.doFileNew"+_END_),this.Options=await this.loadOptions(),await this.MainWindow.webContents.send("fromMain",[FromMain_FILE_NEW,this.Options])}doFileSave(){Skribi.log(">> "+_CYAN_+"ElectronMain.doFileSave"+_END_),this.MainWindow.webContents.send("fromMain",[FromMain_FILE_SAVE])}doFileSaveAs(){Skribi.log(">> "+_CYAN_+"ElectronMain.doFileSaveAs"+_END_),this.MainWindow.webContents.send("fromMain",[FromMain_FILE_SAVE])}async doFileOpen(e){if(Skribi.log(">> "+_CYAN_+"ElectronMain.doFileOpen"+_END_),null==e){let n=app.getAppPath()+"\\_output";if(e=await this.selectFileWithDialogBox(n,"Wallet Informations","wits"),pretty_log("in_file_path",e),""==e)return}const n=fs.readFileSync(e,{encoding:"utf8",flag:"r"});let i=JSON.parse(n);await this.MainWindow.webContents.send("fromMain",[FromMain_FILE_OPEN,i])}async selectFileWithDialogBox(e,n,i){pretty_func_header_log("ElectronMain.selectFileWithDialogBox");let _="",t=await dialog.showOpenDialog(this.MainWindow,{defaultPath:e,filters:[{name:n,extensions:[i]}],properties:["openFile"]});return t.filePaths.length>0&&(_=t.filePaths[0]),_}async selectFileOrDirectoryPathWithDialogBox(e,n,i,_){pretty_func_header_log("ElectronMain.selectFileOrDirectoryPathWithDialogBox"),null==i&&(i=SELECT_DIRECTORY_PATH_MODE),null==_&&(_=""),pretty_log(">> -=-=-=-=-=-=  selectFileOrDirectoryPathWithDialogBox   path_type: '"+_+"'");let t,o,a="";if(i==SELECT_DIRECTORY_PATH_MODE?t=await dialog.showOpenDialog(this.MainWindow,{title:n,defaultPath:e,properties:["openDirectory"],buttonLabel:"Select"}):i==SELECT_FILE_PATH_MODE&&(t=await dialog.showSaveDialog(this.MainWindow,{title:n,defaultPath:e,filters:[{name:"Fichier SQLite",extensions:["db"]}],buttonLabel:"Select",showsTagField:!1}),!t.canceled&&t.filePath&&(console.log("Selected file path:",t.filePath),o=t.filePath)),pretty_log(">> ---------------- selected_file_path: '"+o+"'"),pretty_log(">> ---------------- result.filePaths: '"+t.filePaths+"'"),pretty_log(">> ---------------- result.filePath: '"+t.filePath+"'"),pretty_log(">> ---------------- selected_file_path: '"+o+"'"),null==t.filePaths){if(console.log(">> ********* result.filePaths == undefined\n   selected_file_path: "+o),a=o,!fs.existsSync(a))try{fs.writeFileSync(a,""),console.log("✓ Fichier créé avec succès")}catch(e){console.error("✗ Erreur:",e.message)}}else pretty_log(">> ---------------- result.filePaths.length: '"+t.filePaths.length+"'"),t.filePaths.length>0&&(pretty_log("filePaths: "+JSON.stringify(t.filePaths)),a=t.filePaths[0]);if(_==OUTPUT_DIR_PATH){const e=e=>{const n=/^(\d{4})_(\d{2})_(\d{2})_(\d{2})h-(\d{2})m-(\d{2})s-(\d+)_([A-Z]{3,4})_([A-Z]{2})$/;try{const i=e.match(n);if(!i)return!1;parseInt(i[1],10);const _=parseInt(i[2],10),t=parseInt(i[3],10),o=parseInt(i[4],10),a=parseInt(i[5],10),r=parseInt(i[6],10);parseInt(i[7],10);if(_<1||_>12)return!1;if(t<1||t>31)return!1;if(o<0||o>23)return!1;if(a<0||a>59)return!1;if(r<0||r>59)return!1;i[8],i[9]}catch(e){return console.log("** Parsing Error ** in ElectronMain.selectFileOrDirectoryPathWithDialogBox.validate_output_path"),!1}return!0};let n=!1;const i=fs.readdirSync(a,{withFileTypes:!0});for(let _=0;_<i.length;_++){let t=i[_];console.log("> -------- current_sub_dir.path["+_+"]: "+t.path);let o=t.name;console.log("> -------- subdir_name["+_+"]: "+o);let r=e(o);if(console.log("> -------- valid_as_ouput_dir_path["+_+"]: "+r),r){let e=t.path+"\\"+o+"\\wallet_info.wits";if(console.log("> wits_file_path["+_+"]: "+e),fs.existsSync(e))return n=!0,a}}if(!n)return INVALID_OUTPUT_DIR_PATH}return a}showFolderInExplorer(){pretty_func_header_log("ElectronMain.showFolderInExplorer");let e=os.platform(),n="/",i=this.output_path;"win32"==e?n="\\":e==LINUX&&(n="/"),i=this.output_path.replaceAll("\\","\0").replaceAll("/","\0");let _=i.split("\0");_.pop();i=_.join(n);"win32"==e?shell.openPath(i):e==LINUX&&(i=i.replaceAll("\\","/"),(e=>{exec(`xdg-open "${e}"`,(e=>{e&&console.error(`Error opening folder: ${e}`)}))})(i))}getNewFortuneCookie(){pretty_func_header_log("ElectronMain.getNewFortuneCookie");let e=getFortuneCookie();Skribi.log("   fortune_cookie: "+getShortenedString(e)),this.MainWindow.webContents.send("fromMain",[FromMain_SET_FORTUNE_COOKIE,e])}toggleDebugPanel(){pretty_func_header_log("ElectronMain.toggleDebugPanel"),this.Show_DebugPanel=!this.Show_DebugPanel,this.Show_DebugPanel?this.MainWindow.webContents.openDevTools():this.MainWindow.webContents.closeDevTools()}readAppConfig(){pretty_func_header_log("ElectronMain.readAppConfig");let e=DEFAULT_APP_CONFIG,n=app.getAppPath()+"/www/config"+"/app_config.json";if(fs.existsSync(n)){const i=fs.readFileSync(n);""!=i&&"[]"!=i&&"{}"!=i&&(e=JSON.parse(i))}return e}readOptionsFile(){pretty_func_header_log("ElectronMain.readOptionsFile");let e=DEFAULT_OPTIONS,n=app.getAppPath()+"/www/config"+"/options.json";if(fs.existsSync(n)){const i=fs.readFileSync(n);""!=i&&"[]"!=i&&"{}"!=i&&(e=JSON.parse(i))}return e}async loadOptions(){return pretty_func_header_log("ElectronMain.loadOptions"),this.Options=this.readOptionsFile(),await this.MainWindow.webContents.send("fromMain",[FromMain_UPDATE_OPTIONS,this.Options]),this.Options}async setDefaultOptions(){pretty_func_header_log("ElectronMain.setDefaultOptions"),this.Options=DEFAULT_OPTIONS,await this.saveOptions(this.Options)}async updateOptions(e){pretty_func_header_log("ElectronMain.updateOptions"),this.Options=e,Skribi.log("   this.Options: "+JSON.stringify(this.Options))}async saveOptions(e){pretty_func_header_log("ElectronMain.saveOptions"),this.Options=e;let n=app.getAppPath()+"/www/config"+"/options.json";fs.writeFileSync(n,JSON.stringify(this.Options)),Skribi.log(" B this.Options: "+JSON.stringify(this.Options)),await this.MainWindow.webContents.send("fromMain",[FromMain_UPDATE_OPTIONS,e])}async resetOptions(){pretty_func_header_log("ElectronMain.resetOptions");let e=app.getAppPath()+"/www/config"+"/defaults/options.json",n=fs.readFileSync(e).toString();Skribi.log("   default_options_str: "+n),this.Options=JSON.parse(n),await this.saveOptions(this.Options)}setCallbacks(){Skribi.log(">> "+_CYAN_+"ElectronMain.setCallbacks"+_END_),ipcMain.handle(ToMain_RQ_QUIT_APP,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_QUIT_APP),app.quit()})),ipcMain.handle(ToMain_RQ_EXEC_CMD,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_EXEC_CMD);const{cmd_name:i,cmd_args:_}=n;Skribi.log("eMain.evtH('ExecCmd')> cmd_name: "+i),Skribi.log("eMain.evtH('ExecCmd')> cmd_args: "+_),i==CMD_OPEN_WALLET&&await ElectronMain.GetInstance().openWits(_)})),ipcMain.on(ToMain_RQ_LOG_2_MAIN,((e,n)=>{Skribi.log(n)})),ipcMain.handle(ToMain_RQ_LOG_2_MAIN_SYNC,(async(e,n)=>{Skribi.log(n)})),ipcMain.handle(ToMain_RQ_GET_APP_PATH,(async(e,n)=>(pretty_func_header_log("[Electron]",ToMain_RQ_GET_APP_PATH),app.getAppPath()))),ipcMain.on(ToMain_RQ_SET_WINDOW_TITLE,((e,n)=>{const{coin:i,wallet_mode:_}=n;ElectronMain.GetInstance().updateWindowTitle(i,_)})),ipcMain.on(ToMain_RQ_TOGGLE_DEBUG_PANEL,((e,n)=>{ElectronMain.GetInstance().toggleDebugPanel()})),ipcMain.on(ToMain_RQ_SHOW_OUTPUT_FOLDER_IN_EXPLORER,((e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_SHOW_OUTPUT_FOLDER_IN_EXPLORER),this.showFolderInExplorer()})),ipcMain.on(ToMain_RQ_OPEN_URL,((e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_OPEN_URL),Skribi.log("eMain.evtH('OpnURL')> "+n),this.MainWindow.location=n})),Skribi.log(">> register ToMain_RQ_SELECT_FILE_OR_DIRECTORY_PATH_DIALOG: '"+ToMain_RQ_SELECT_FILE_OR_DIRECTORY_PATH_DIALOG+"'"),ipcMain.handle(ToMain_RQ_SELECT_FILE_OR_DIRECTORY_PATH_DIALOG,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_SELECT_FILE_OR_DIRECTORY_PATH_DIALOG),Skribi.log("eMain.evtH('selectFileOrDirPath')>");let{default_path:i,title:_,select_mode:t,path_type:o}=n;return await ElectronMain.GetInstance().selectFileOrDirectoryPathWithDialogBox(i,_,t,o)})),Skribi.log(">> register ToMain_RQ_IMPORT_OUTPUT_FILES_IN_DATABASE: '"+ToMain_RQ_IMPORT_OUTPUT_FILES_IN_DATABASE+"'"),ipcMain.handle(ToMain_RQ_IMPORT_OUTPUT_FILES_IN_DATABASE,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_IMPORT_OUTPUT_FILES_IN_DATABASE),Skribi.log("eMain.evtH(importOutpuFilesInDB')>");let{output_dirs_path:i,db_path:_}=n;await SqLiteUtils.This.importWallets(i,_)})),ipcMain.handle(ToMain_RQ_NEW_WALLET_INFO,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_NEW_WALLET_INFO),Skribi.log("eMain.evtH('NewWinf')>"),await ElectronMain.GetInstance().doFileNew()})),ipcMain.handle(ToMain_RQ_OPEN_WALLET_INFO,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_OPEN_WALLET_INFO),await ElectronMain.GetInstance().doFileOpen()})),ipcMain.handle(ToMain_RQ_SAVE_WALLET_INFO,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_SAVE_WALLET_INFO),Skribi.log("eMain.evtH('SaveWinf')>"),this.output_path=await MainModel.This.saveWalletInfo(n)})),ipcMain.handle(ToMain_RQ_RESET_OPTIONS,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_RESET_OPTIONS),Skribi.log("eMain.evtH('RstOpt')>"),ElectronMain.GetInstance().resetOptions()})),ipcMain.handle(ToMain_RQ_UPDATE_OPTIONS,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_UPDATE_OPTIONS),null==n&&(Skribi.log(">> "+_RED_+ToMain_RQ_QUIT_APP+_END_),app.quit()),this.Options=n,Skribi.log("eMain.evtH('UpOpt')> this.Options: "+JSON.stringify(this.Options)),await this.MainWindow.webContents.send("fromMain",[FromMain_UPDATE_OPTIONS,this.Options])})),ipcMain.handle(ToMain_RQ_SAVE_OPTIONS,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_SAVE_OPTIONS);let i=n;pretty_log("eMain.evtH('SaveOpt')> options_data: "+JSON.stringify(i)),ElectronMain.GetInstance().saveOptions(i),pretty_log("eMain.evtH('SaveOpt')> this.Options: "+JSON.stringify(this.Options)),await this.MainWindow.webContents.send("fromMain",[FromMain_UPDATE_OPTIONS,i])}));const e=e=>{let n=fs.readFileSync(e,{encoding:"base64"}),i=e.split("."),_="png",t=i.length;return t>1&&(_=i[t-1].toLowerCase(),"jpg"==_?_="jpeg":"svg"==_&&(_="svg+xml")),this.MainWindow.webContents.send("fromMain",[FromMain_SEND_IMG_URL,ENTROPY_SOURCE_IMG_ID,n,_]),n};ipcMain.handle(ToMain_RQ_LOAD_IMG_FROM_FILE,(async(n,i)=>(pretty_func_header_log("[Electron]",ToMain_RQ_LOAD_IMG_FROM_FILE),e(i)))),ipcMain.handle(ToMain_RQ_DRAW_RND_CRYPTO_LOGO,((n,i)=>{pretty_func_header_log("[Electron]",ToMain_RQ_DRAW_RND_CRYPTO_LOGO);let _=app.getAppPath()+"/www/img/CryptoCurrency",t=FileUtils.GetFilesInFolder(_),o=_+"/",a="Zilver_64px.svg";if(!this.FirstImageAsEntropySource){a=t[getRandomInt(t.length)]}return this.FirstImageAsEntropySource=!1,o+=a,e(o)})),ipcMain.handle(ToMain_RQ_GENERATE_PASSWORD,(async(e,n)=>(pretty_func_header_log("[Electron]",ToMain_RQ_GENERATE_PASSWORD),PasswordGenerator.generate({length:24,numbers:!0,symbols:!0,uppercase:!0,lowercase:!0,excludeSimilarCharacters:!0,strict:!0})))),ipcMain.handle(ToMain_RQ_BIP38_ENCRYPT,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_BIP38_ENCRYPT);const{private_key:i,passphrase:_}=n;return await Bip38Utils.This.encrypt(i,_,this.getMainWindow())})),ipcMain.handle(ToMain_RQ_BIP38_DECRYPT,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_BIP38_DECRYPT);const{bip38_encrypted_pk:i,passphrase:_}=n;return await Bip38Utils.This.decrypt(i,_,this.getMainWindow())})),ipcMain.handle(ToMain_RQ_GET_PASSWORD_STRENGTH,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_GET_PASSWORD_STRENGTH);const i=n;return PasswordStrengthEvaluator.This.getPasswordStrengthInfo(i)})),ipcMain.handle(ToMain_RQ_GET_HD_WALLET,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_GET_HD_WALLET+"======================");const{entropy_hex:i,salt_uuid:_,blockchain:t,crypto_net:o,bip32_passphrase:a,account:r,address_index:l,bip32_protocol:s}=n;pretty_log("bip32_protocol",s);let E={[BLOCKCHAIN]:t,[CRYPTO_NET]:o,[BIP32_PASSPHRASE]:a,[BIP32_PROTOCOL]:s,[ACCOUNT]:r,[ADDRESS_INDEX]:l};return await HDWallet.GetWallet(i,_,E)})),ipcMain.handle(ToMain_RQ_GET_SIMPLE_WALLET,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_GET_SIMPLE_WALLET);const{private_key:i,salt_uuid:_,blockchain:t,crypto_net:o}=n;if(null==i||""==i)throw new Error("ElectronMain ToMain_RQ_GET_SIMPLE_WALLET handler: 'private_key' NOT DEFINED");return await SimpleWallet.GetWallet(i,_,t,o)})),ipcMain.handle(ToMain_RQ_MNEMONICS_TO_HD_WALLET_INFO,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_MNEMONICS_TO_HD_WALLET_INFO+"=)=)=)=)=)=)=)=)=)=)");const{mnemonics:i,options:_}=n;return await Bip32Utils.MnemonicsToHDWalletInfo(i,_)})),ipcMain.handle(ToMain_RQ_MNEMONICS_TO_ENTROPY_INFO,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_MNEMONICS_TO_ENTROPY_INFO);const{mnemonics:i,lang:_}=n;return Bip39Utils.MnemonicsToEntropyInfo(i,_)})),ipcMain.handle(ToMain_RQ_ENTROPY_TO_MNEMONICS,(async(e,n)=>{const{entropy:i,lang:_}=n;return Bip39Utils.EntropyToMnemonics(i,_)})),ipcMain.handle(ToMain_RQ_ENTROPY_TO_CHECKSUM,(async(e,n)=>{const{entropy:i,options:_}=n;return Bip39Utils.EntropyToChecksum(i,_)})),ipcMain.handle(ToMain_RQ_ENTROPY_SRC_TO_ENTROPY,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_ENTROPY_SRC_TO_ENTROPY);const{salted_entropy_src_str:i,options:_}=n;return Bip39Utils.EntropySourceToEntropy(i,_)})),ipcMain.handle(ToMain_RQ_MNEMONICS_AS_4LETTER,(async(e,n)=>Bip39Utils.MnemonicsAs4letter(n))),ipcMain.handle(ToMain_RQ_MNEMONICS_AS_TWO_PARTS,(async(e,n)=>Bip39Utils.MnemonicsAsTwoParts(n))),ipcMain.handle(ToMain_RQ_GET_FORTUNE_COOKIE,(async(e,n)=>(pretty_func_header_log("[Electron]",ToMain_RQ_GET_FORTUNE_COOKIE),this.getNewFortuneCookie()))),ipcMain.handle(ToMain_RQ_WORD_INDEXES_TO_MNEMONICS,(async(e,n)=>{Skribi.log(">> "+_CYAN_+"[Electron] "+_YELLOW_+ToMain_RQ_WORD_INDEXES_TO_MNEMONICS+_END_);const{word_indexes:i,lang:_}=n;return Bip39Utils.WordIndexesToMnemonics(i,_)})),ipcMain.handle(ToMain_RQ_MNEMONICS_TO_WORD_INDEXES,(async(e,n)=>{const{mnemonics:i,options:_}=n;return Bip39Utils.GetWordIndexes(i,_)})),ipcMain.handle(ToMain_RQ_GUESS_MNEMONICS_LANG,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_GUESS_MNEMONICS_LANG);const{mnemonics:i}=n;return Bip39Utils.GuessMnemonicsLang(i)})),ipcMain.handle(ToMain_RQ_CHECK_MNEMONICS,(async(e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_CHECK_MNEMONICS);const{mnemonics:i,options:_}=n;return Bip39Utils.CheckMnemonics(i,_)})),ipcMain.handle(ToMain_RQ_GET_UUID,(async(e,n)=>uuidv4())),ipcMain.handle(ToMain_RQ_GET_L10N_KEYPAIRS,((e,n)=>L10nUtils.GetKeyPairs())),ipcMain.handle(ToMain_RQ_GET_L10N_MSG,((e,n)=>L10nUtils.GetLocalizedMsg(n))),ipcMain.on(ToMain_RQ_SET_MENU_ITEM_STATE,((e,n)=>{pretty_func_header_log("[Electron]",ToMain_RQ_SET_MENU_ITEM_STATE);const{menu_item_id:i,enabled:_}=n;Menu.getApplicationMenu().getMenuItemById(i).enabled=_}))}}gotTheLock?(app.on("second-instance",((e,n,i)=>{let _=ElectronMain.GetInstance().getMainWindow();null!=_&&(_&&_.restore(),_.focus())})),app.whenReady().then((async()=>{if(process.platform.startsWith("win")&&process.argv.length>=2){process.argv[1]}ElectronMain.GetInstance().createWindow();let e=!0;const n=async()=>{e=!0,await checkInternetConnected().catch((n=>{e=!1})),ElectronMain.GetInstance().getMainWindow().webContents.send("fromMain",[FromMain_INTERNET_CONNECTED,e]),setTimeout(n,1250)};await n()}))):app.quit();
//# sourceMappingURL=/sm/aba537df9ff5e3d5698bbb16474f030e2a418c9c59155c2b301371b6066fd548.map