diff --git a/Linux_x64/app.asar b/Linux_x64/app.asar index 87ab8ee..e0ce7ce 100644 Binary files a/Linux_x64/app.asar and b/Linux_x64/app.asar differ diff --git a/Linux_x64/dec_app/atom.js b/Linux_x64/dec_app/atom.js index ce52e60..d67ee95 100644 --- a/Linux_x64/dec_app/atom.js +++ b/Linux_x64/dec_app/atom.js @@ -1,2 +1,2 @@ module.exports= function(k){}; -(()=>{var n={883:(t,n,a)=>{var s=a(134),c=s.app,e=s.ipcMain,d=s.BrowserWindow,u="win32"==process.platform,p="linux"==process.platform,r=a(156),i=a(344);n.bindJumplist=()=>{var t;u&&(t=[{type:"custom",name:"Recent Locations",items:c.setting.getRecentFolders().slice(0,5).map(function(e){return{type:"task",title:e.name,description:e.path,program:process.execPath,args:JSON.stringify(e.path),iconPath:"explorer.exe",iconIndex:0}})},{type:"recent"},{type:"tasks",items:[{type:"task",program:process.execPath,arguments:"--new",iconPath:process.execPath,iconIndex:0,title:"New"}]}],c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t),i.loadDict().then(e=>{t[0].name=e["Recent Locations"]||"Recent Locations",t[2].items[0].title=e.New||"New",c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t)}))},e.handle("shell.saveItem",(e,{path:n,data:o})=>new Promise(t=>{a(833).writeFile(n,o,function(e){t()})})),e.handle("shell.openItem",(e,t)=>s.shell.openPath(a(541).normalize(t))),e.handle("shell.trashItem",async(e,t)=>{try{return await s.shell.trashItem(t),!0}catch(e){return!1}}),e.handle("shell.openExternal",(e,t)=>{if("about:blank"!=t)return s.shell.openExternal(t)}),e.handle("shell.showItemInFolder",(e,t)=>(u&&(t=t.replace(/\//g,"\\")),s.shell.showItemInFolder(t))),e.handle("shell.showDownload",(e,t)=>{e=d.fromWebContents(e.sender);const n=a(554)["download"];n(e,t,{saveAs:!0})}),e.handle("dialog.showMessageBox",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showMessageBox(p?null:e,t)}),e.handle("dialog.showSaveDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showSaveDialog(p?null:e,t)}),e.handle("dialog.showOpenDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showOpenDialog(p?null:e,t)}),e.handle("dialog.showOpenDialogAlone",(e,t)=>s.dialog.showOpenDialog(t));const h=t=>new Promise(e=>{setTimeout(()=>{e("sleep")},t)}),m=async(e,t)=>{var n=new d({skipTaskbar:!0,title:"Print PDF Preview",show:!1,webPreferences:{webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!1,nodeIntegration:!1,safeDialogs:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,zoomFactor:+(c.setting.get("zoomFactor")||"1"),backgroundThrottling:!1}});try{var o,i,r=t?(console.log("load file ["+t+"] for PDF export"),n.loadFile(t)):(o=a(541).join(c.setting.tempPath||c.getPath("temp"),+new Date+"tmp.html"),i=a(728),console.log("write output to temp file ["+o+"] for PDF export"),await i.outputFile(o,e),n.loadFile(o))}catch(e){return console.error(e),n&&n.destroy(),null}return Promise.race([h(2e4),r]).then(e=>"sleep"===e?(l(n.id),console.warn("Timeout for loading print view"),null):n.id).catch(e=>(console.error(e),n&&n.destroy(),null))},l=(e.handle("export.genPrintView",(e,t,n)=>(n&&l(n),m(null,t))),e=>{e=d.fromId(e);e&&(e.isDestroyed()||e.destroy())});e.handle("export.destroyPrintView",(e,t)=>{l(t)}),e.handle("export.getPageColor",async(e,t)=>{try{var n=await m(null,t);if(console.log("generate print preview window with id "+n),!n)return null;printWin=d.fromId(n),await h(200);var o=await printWin.webContents.executeJavaScript("window.getComputedStyle(document.body).backgroundColor")}catch(e){console.error(e)}finally{printWin&&printWin.destroy()}return o}),e.handle("export.print",(e,n,o)=>{var i=d.fromId(n);o=o||{},i.webContents.print(o,(e,t)=>{if(!e&&!/cancel/.exec(t||"")){if("no valid printers available"===t)return void i.webContents.executeJavaScript("window.print()").then(()=>{o.skipCleanUp||l(n)});s.dialog.showMessageBox({type:"error",message:r.getPanelString("Error"),detail:t,buttons:["OK"]})}o.skipCleanUp||l(n)})}),e.handle("export.printToPDF",async(e,t,n)=>{let o=null,i=null,r=null,a="";try{var l=await m(null,t);if(console.log("generate print window with id "+l),!l)return[i,r];o=d.fromId(l),await h(200),i=await o.webContents.printToPDF(n),console.log("get PDF data");var s=`(${function(){var e=document.querySelector("#write");return e?{color:(e=window.getComputedStyle(e)).color,fontFamily:e.fontFamily,bgColor:e.backgroundColor}:null}.toString()})()`;r=(r=await o.webContents.executeJavaScript(s))&&JSON.stringify(r),console.log("get background color")}catch(e){a=e.message||"",console.error(e)}finally{o&&o.destroy()}return[i,r,a]});var f,o,g=u?8e3:960,w=1;function b(){console.log("updateTheme");var e=c.setting.curTheme(),t=(c.execInAll("window.ClientCommand && File.setTheme('"+e+"');"),e.replace(/\.css$/,"").replace(/(^|-|_)(\w)/g,function(e,t,n,o){return(t?" ":"")+n.toUpperCase()})),e=s.Menu.getApplicationMenu().getItem("Themes");e&&e.submenu.items.map(function(e){e.checked=e.label==t})}e.handle("export.prepareImageCapture",async(e,t,n)=>{var o,i=s.screen.getPrimaryDisplay();try{w=i.scaleFactor||1;var r=i.workArea;if(g=Math.min(g,r.height-20),f=n.imageWidth,await(o=new d({skipTaskbar:!0,show:!1,webPreferences:{devTools:!1,webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!0,nodeIntegration:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,safeDialogs:!0},webgl:!1,useContentSize:!0,x:r.x,y:r.y,width:n.imageWidth,height:g,frame:!1,enableLargerThanScreen:!!u,offscreen:!0,alwaysOnTop:!0,minimizable:!1,closable:!0})).loadURL("file:///"+t),o.isDestroyed())return null;if(await h(2e3),o.isDestroyed())return null;var a=+await o.webContents.executeJavaScript("window.innerHeight");if(o.isDestroyed())return null;var l=+await o.webContents.executeJavaScript("document.body.parentElement.scrollTop = document.body.clientHeight;\nMath.max(document.body.clientHeight, document.body.parentElement.scrollHeight)");return o.isDestroyed()?null:Number.isNaN(l)||Number.isNaN(a)?void 0:(p&&(g=a),{winId:o.id,totalHeight:l,pageHeight:g,imageWidth:n.imageWidth,scale:3===n.quality?w:1})}catch(e){return console.error(e),null==o||o.isDestroyed()||o.destroy(),null}}),e.handle("export.captureImage",async(e,t,n,o)=>{t=d.fromId(t);if(!t||t.isDestroyed())return null;try{o&&(t.setSize(o.imageWidth,o.pageHeight),t.setContentSize(o.imageWidth,o.pageHeight));var i=+await t.webContents.executeJavaScript("document.body.parentElement.scrollTop = {d}; document.body.parentElement.scrollHeight;".replace("{d}",n));if(await h(1e3),t.isDestroyed()||Number.isNaN(i))return null;var r=await t.webContents.capturePage();if(!r||r.isEmpty())return null;var a=null;return 1new Promise((t,e)=>{try{var n=s.net.request({url:o,redirect:"follow"});n.on("response",function(e){try{if(200!=e.statusCode)return t(null);if(!e.data)return t(null);t({type:(e.headers["content-type"]||[""])[0],data:e.data})}catch(e){t(null)}}),n.end()}catch(e){t(null)}})),e.handle("clipboard.write",(e,t,n)=>{n&&s.clipboard.clear(),s.clipboard.write(JSON.parse(t))}),e.handle("pandoc.import",(e,n)=>{var o={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"'":"\\'","\\":"\\\\"},e=d.fromWebContents(e.sender),t=n?Promise.resolve(e):c.openFile(null,{syncAndPrepOnly:!0}).then(n=>new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e(n.activeWindow)}):e(n.activeWindow)})),e=s.dialog.showOpenDialog(n?e:null,{title:i.getMenuDict.Import,properties:["openFile"],filters:[{name:r.getPanelString("All Supported Formats"),extensions:["docx","rtf","latex","tex","ltx","rst","rest","org","wiki","dokuwiki","mediawiki","textile","opml","epub"]},{name:"MS Word",extensions:["docx"]},{name:"RTF",extensions:["rtf"]},{name:"TeX/LaTeX",extensions:["latex","tex","ltx"]},{name:"reStructuredText",extensions:["rst","rest"]},{name:"org-mode",extensions:["org"]},{name:"Wiki",extensions:["wiki","dokuwiki","mediawiki"]},{name:"Epub",extensions:["epub"]},{name:"Textile",extensions:["textile"]},{name:"OPML",extensions:["opml"]}]}).then(({filePaths:e})=>(e||[null])[0]);return Promise.all([t,e]).then(async([e,t])=>{t?(await h(100),e.show(),e.webContents.executeJavaScript('window.getSelection().removeAllRanges();ClientCommand.doImport("'+t.replace(/["'\\\b\t\n\f\r]/g,function(e){return o[e]}).replace(/\u200b/g,"")+'")')):n||e.destroy()})}),e.handle("pandoc.version",()=>o),e.handle("pandoc.setVersion",(e,t)=>{o=t}),s.nativeTheme.on("updated",function(){null!==c.setting.useDarkThemeBefore()&&c.setting.useDarkThemeBefore()!==c.setting.useDarkTheme()&&b()}),e.handle("theme.apply",()=>{b()}),e.handle("theme.setThemeSource",(e,t)=>{"system"!==(t=t||"system")&&c.setting.get("useSeparateDarkTheme")||(s.nativeTheme.themeSource=t)}),e.on("ondragstart",function(t,n,o){setTimeout(function(){var e=s.nativeImage;t.sender.startDrag({file:n,icon:o?e.createFromPath(a(541).normalize(o)):e.createEmpty()}),console.log("ondragstart "+n+" "+o)},100)}),e.handle("getPath",(e,t)=>c.getPath(t))},156:(e,t,n)=>{var o=n(134).app,i=n(728),r=n(541).join(__dirname,"../"),a=["Operation Failed","Save As","All Supported Formats","Error","Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2","Updater","Checking Updates…","Downloading Updates…","You're up to date!","Check Update Failed","Download failed","Install Updates ?","Quit and Install","Cancel","Download","Downloading…","Extracting binary…","This dev version of Typora is expired, please download and install a newer version.","This device has been deactivated","Typora is now deactivated","UNREGISTERED"],l={},s=!1;e.exports={initDict:function(){if(s)return Promise.resolve();var e=n(541).join(r,o.setting.getLocaleFolder("Panel"));return i.readJSON(e,"utf8").then(function(t){s=!0,a.map(function(e){l[e]=t[e]||e})}).catch(function(){})},getPanelString:function(e){return l[e]||e}}},351:(r,l,c)=>{function d(e,t){this.activeWindow=t||null,this.windows=new Set(t),this.path=e||null,this.snap=null,this.lastSync,this.content,this.backupState=null}var e=c(134),u=e.app,a=e.BrowserWindow,s=(e.powerMonitor,c(728)),e=c(232),h=(c(266),process.platform,process.platform,"linux"==process.platform),g=c(468),m=c(587),t=c(134).ipcMain,o=(t.on("doc.syncChange",function(e,t){var n=a.fromWebContents(e.sender),o=u.documentController.getDocumentFromWindowId(n.id);n==o.activeWindow&&1=n}catch(e){console.warn(e)}return!1}},d.prototype.getWindowToFocus=function(){var e=this.activeWindow||this.windows.keys().next().value;if(e){if(!e.isDestroyed())return e;this.activeWindow=null,this.windows.delete(e)}return null},d.prototype.syncFullContent=function(t){var e,n=!1;if(this.windows.forEach(function(e){this.activeWindow!=e&&!n&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&(n=!0)}),n)return e=this.windows,this.activeWindow.webContents.executeJavaScript("File.sync(false, true);1;").then(function(){e.forEach(function(e){this.activeWindow!=e&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&e.webContents.executeJavaScript("File.editor.applyFullContent("+!!t+")")})}),null},d.prototype.popBackupState=async function(){var e=this.backupState;return this.backupState=void 0,Promise,e},function(e){return c(541).basename(e)}),f=e.isCaseInsensitive();function p(e){return f?e&&e.toLowerCase():e}function n(){this.documents=new Set,this.path2doc=new Map,this.win2doc=new Map,this.name2docs=new Map,this.frozenDocs=[],this.watchSystemPause()}n.prototype.watchSystemPause=function(){u.whenReady().then(()=>{})},n.prototype.setContentForWindow=function(e,t){var n=this.getDocumentFromWindowId(t);(n.activeWindow||{}).id==t&&n.setContent(e)},n.prototype.solveDuplicateName_=function(e){var t=e.path,t=p(o(t)),n=this.name2docs.get(t)||new Set;this.name2docs.set(t,n),0{e=a.fromWebContents(e.sender),t=t?u.getDocumentController().getDocument(t):u.documentController.getDocumentFromWindowId(e.id);t&&t.activeWindow==e&&t&&t.switchToUntitled(n)}),t.handle("document.setLastSync",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).setLastSync(t)}),t.handle("document.syncFullContent",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).syncFullContent(t)}),t.handle("document.getContent",e=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).getContent()}),t.handle("document.currentPath",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).path});const b=async e=>{var t=e.getSnap(null),n=e.path,o=!1,i=null;return(t||{}).nodeMap?o=await e.shouldReadFromDisk():i=await e.popBackupState(),i&&i.hasUnsaved?console.log("load from recover content length: "+i.content.length):i=null,JSON.stringify({snap:t,filePath:n,backups:i,shouldReadFromDisk:o,windowCounts:e.windows.size})};t.handle("document.loadData",async e=>{console.log("handle document.loadData");new Date;e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),e=await b(e);return new Date,e}),t.handle("document.switchDocument",async(e,t)=>{e=a.fromWebContents(e.sender),e=await u.getDocumentController().switchDocument(e.id,t);return b(e)}),t.handle("document.rename",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).rename(t),!0}),t.handle("document.setContent",(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=e.content==t;return e.setContent(t),n}),t.handle("document.addSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return t?e.addSnap(JSON.parse(t)):e.addSnap(null),!0}),t.handle("document.addSnapAndLastSync",(e,t)=>{try{var n,o,i=a.fromWebContents(e.sender),r=u.documentController.getDocumentFromWindowId(i.id);t?({snap:n,lastSync:o}=JSON.parse(t),r.addSnap(n),r.setLastSync(o)):r.addSnap(null)}catch(e){console.error(e)}return!0}),t.handle("document.shouldSaveSnap",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).shouldSaveSnap()}),t.handle("document.getSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return JSON.stringify(e.getSnap(t))}),t.handle("document.getSnapWithValidation",async(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=await e.isSnapValid();return JSON.stringify({snap:e.getSnap(t),shouldReadFromDisk:0==n})}),t.handle("document.enterOversize",e=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);e&&e.enterOversize()}),t.handle("document.newWindow",e=>{3==u.setting.get("restoreWhenLaunch")?u.openFile(null,{mountFolder:u.setting.get("pinFolder"),silent:"pinFolder"}):u.openFile()}),t.handle("document.checkIfMoveOnSave",(e,t)=>{var e=a.fromWebContents(e.sender),n=u.documentController.getDocument(t);return!n&&((n=u.documentController.getDocumentFromWindowId(e.id)).rename(t),!0)}),t.handle("document.hasDuplicateName",(e,t)=>u.documentController.hasDuplicateName(t)),t.handle("document.noOtherWindow",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).windows.size<=1});var i=new n;r.exports=i},824:(e,t,s)=>{var c=s(728),d=s(541),u={title:"Download",text:"Downloading…",indeterminate:!1,initialValue:0,maxValue:1,closeOnComplete:!1,abortOnError:!1,style:{text:{padding:"3px 0"}},browserWindow:{modal:!1,closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}};function p(e){if(e<1024)return e+" B";var t=e/Math.pow(1024,1),e=e/Math.pow(1024,2);return e<1?(t+"").replace(/(\..)(.+)$/,"$1")+"KB":(e+"").replace(/(\..)(.+)$/,"$1")+"MB"}function n(e,t,n){this.onAbort=null,this.onSuccess=null,this.onError=null,this.downloadURL=e,this.dist=t,this.displayOption=n||{},this.progressBar=null,this.downloadItem=null}n.prototype.cancel=function(){if(this.downloadItem){try{this.downloadItem.cancel()}catch(e){}this.downloadItem=null}this.setCompleted(),this.onAbort&&this.onAbort()},n.prototype.setCompleted=function(){this.downloadItem=null,this.progressBar&&(this.progressBar.setCompleted(),this.progressBar.close(),this.progressBar=null)},n.prototype.download=function(){var e=s(477),t=s(554),n=this,o=this.downloadURL,i=this.dist,r=this.displayOption,a=new e(Object.assign({},u,r)),l=((this.progressBar=a).on("aborted",function(){n.cancel()}),d.dirname(i));Promise.all([new Promise(function(e){a.on("ready",e)}),c.ensureDir(l)]).then(function(){console.record("[downloader] downloading "+o,"DEBUG"),t.download(a._window,o,{showBadge:r.showBadge||!1,directory:l,filename:d.basename(i),onProgress:function(e){a&&(a.value=e.percent*(r.processOnComplete||1),a.detail=p(e.transferredBytes)+" / "+p(e.totalBytes))},onStarted:function(e){console.log("start downloading "+e.getURL()),n.downloadItem=e},onCancel:function(){console.log("canceled downloading "+downloadItem.getURL()),n.cancel()}}).then(function(e){n.onSuccess(e,a)}).catch(function(e){console.log("error downloading "+(n.downloadItem&&n.downloadItem.getURL())),n.onError(e)})})},e.exports=n},405:(e,t,n)=>{var n=n(134),o=n.app,n=n.ipcMain,i=global.t_workingDir,r=o.getVersion(),a=(/-([a-z]+)/.exec(r)||[])[1],l=r;function s(e,t){var n,o,i;for(e=(e||"").replace(/-[a-z]+/,""),t=(t||"").replace(/-[a-z]+/,""),e=e.split("."),t=t.split("."),o=Math.min(e.length,t.length),n=0;n({PRODUCTION_MODE:global.PRODUCTION_MODE,DEBUG_MODE:global.DEBUG_MODE,version:o.getVersion(),devVersion:global.devVersion})),global.compareVersion=s,global.t_workingDir=i,global.PRODUCTION_MODE=!0,global.DEBUG_MODE=!1},932:(e,t,n)=>{function o(){this.clearUndo()}function i(e){r.dialog.showErrorBox(l.getPanelString("Operation Failed"),e.message)}var r=n(134),a=r.app,l=n(156),s=n(728),n=r.ipcMain,c=(o.prototype.hasUndo=function(e){return!(!this.hasUndo_||!e)&&(0==(this.undoTo_||"").indexOf(e)||0==(this.undoFrom_||"").indexOf(e))},o.prototype.undoLabel=function(){return this.undoLabel_},o.prototype.clearUndo=function(){this.undoFrom_="",this.undoTo_="",this.undoLabel_="",this.hasUndo_=!1},o.prototype.registerUndo=function(e,t,n){this.undoFrom_=e,this.undoTo_=t,this.undoLabel_=n,this.hasUndo_=!0},o.prototype.getFocusPath=function(){return this.hasUndo_&&this.undoTo_},o.prototype.performUndo=function(){var t;function n(){r.dialog.showMessageBox({type:"warning",message:l.getPanelString("Operation Failed"),defaultId:0,cancelId:1,buttons:[l.getPanelString("Save As"),l.getPanelString("Cancel")]}).then(({response:e})=>{0==e?r.dialog.showSaveDialog({defaultPath:t.undoTo_,properties:["showOverwriteConfirmation"]}).then(({filePath:e})=>{e&&e!=t.undoFrom_&&s.rename(t.undoFrom_,e,function(e){e&&i(e)}),t.clearUndo()}):t.clearUndo()})}this.hasUndo_&&(this.hasUndo_=!1,(t=this).undoTo_?s.existsSync(this.undoTo_)?n():(a.sendEvent("willRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),s.copyFile(this.undoFrom_,this.undoTo_,function(e){s.unlink(t.undoFrom_,function(){}),e?(n(),a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoFrom_})):(a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),t.clearUndo())})):s.remove(this.undoFrom_,function(e){e?i(e):(t.clearUndo(),a.sendEvent("updateQuickOpenCache",{toDel:this.undoFrom_}))}))},new o);n.handle("filesOp.registerUndo",(e,t,n,o)=>{c.registerUndo(t,n,o)}),n.handle("filesOp.clearUndo",e=>{c.clearUndo()}),n.handle("filesOp.performUndo",e=>{c.performUndo()}),n.handle("filesOp.getFocusPath",e=>c.getFocusPath()),n.handle("filesOp.undoLabel",(e,t)=>c.hasUndo(t)?c.undoLabel():null),t.default=c},445:(o,u,i)=>{i(405);var p,h=i(156),g=i(134),m=g.shell,l=g.app,e=g.ipcMain,f=g.BrowserWindow,w="win32"==process.platform,b="darwin"==process.platform,y="linux"==process.platform,v=i(587),k=i(359).default,s=i(468),C=!1;const F=function(e){try{return require(e)}catch(e){if(C)return;C=!0;var t=e.message;setTimeout(()=>{C=!1,(dialog=i(134).dialog).showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:"A required module cannot be loaded by Typora",message:t.split("\n")[0]+"\n\nPlease check if that file exists or reinstall Typora to fix."}).then(({})=>{process.exit(1)})},1500)}};var S,r=null,x="",c="",a="",D="";const T={SUCCESS:0,OUT_OF_LIMIT:1,INVALIDATE:-1,WRONG_USER:-2},P=JSON.parse(Buffer.from("WyItLS0tLUJFR0lOIFBVQkxJQyBLRVktLS0tLSIsIk1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBN25Wb0dDSHFJTUp5cWdBTEVVcmMiLCI1SkpoYXAwK0h0SnF6UEUwNHB6NHkrbnJPbVk3LzEyZjNIdlp5eW9Sc3hLZFhUWmJPMHdFSEZJaDBjUnFzdWFKIiwiUHlhT09QYkEwQnNhbG9mSUFZM21SaFFRM3ZTZitybjNnK3cwUyt1ZFdtS1Y5RG5tSmxwV3FpekZhalU0VC9FNCIsIjVaZ01OY1h0M0UxaXBzMzJyZGJUUjBObmVuOVBWSVR2cmJKM2w2Q0kyQkZCSW1aUVoyUDhOK0xzcWZKc3F5VlYiLCJ3RGt0M21IQVZ4VjdGWmJmWVdHKzhGRFN1S1FIYUNtdmdBdENoeDlod2wzSjZSZWtrcURWYTZHSVYxM0QyM0xTIiwicWRrMEpiNTIxd0ZKaS9WNlFBSzZTTEJpYnk1Z1lONnpRUTVSUXBqWHRSNTNNd3pUZGlBekdFdUtkT3RyWTJNZSIsIkR3SURBUUFCIiwiLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tIiwiIiwiIl0=","base64").toString("utf8")).join("\n"),I=864e5;var W="https://store.typora.io";const E=e=>{if(!e)return e;var t;try{t=Buffer.from(e,"base64");const n=i(289).publicDecrypt(P,t);return JSON.parse(n.toString("utf8"))}catch(e){return null}},O=function(){var e=Array.from(arguments);const t=i(289).createHash("sha256");return e.forEach(e=>{t.update(e)}),t.digest("base64")},_=()=>{const e=d().get("SLicense");if(!e)return null;var[t,n,o]=e.split("#"),t=E(t);return t&&t.fingerprint==a?(Object.assign(t,{failCounts:n,lastRetry:new Date(o)}),t):null},M=async e=>{console.log("writeInstallDate fromBTime="+e);var t=new Date;if(e)try{var n=await i(728).stat(l.getPath("userData")+"/profile.data"),t=new Date(n.birthtime);n.birthtime}catch(e){}e=(p=t).toLocaleDateString("en-US");return d().put("IDate",e),p};var L=null;const d=function(){var n;return L=null==L?w?function(){const o=F("native-reg"),i="Software\\Typora";return{get:function(e){var t=o.openKey(o.HKCU,i,o.Access.READ);if(null==t)return"";e=o.getValue(t,null,e);return o.closeKey(t),e},put:function(e,t){var n=o.createKey(o.HKCU,i,o.Access.WRITE);o.setValueSZ(n,e,t),o.closeKey(n)}}}():(n=l.setting.prepDatabase(a),{put:function(e,t){console.log("ls put "+e),n.getState()[e]=t,n.write()},get:function(e){return n.getState()[e]}}):L};const U=async()=>{if(!a){if(w){const t=F("native-reg");var e=t.openKey(t.HKEY.LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Cryptography",t.Access.WOW64_64KEY|t.Access.READ);a=t.getValue(e,null,"MachineGuid"),t.closeKey(e)}else a=await i(560).machineId({original:!0});a||s.captureMessage("[L] Failed to get fingerPrint"),a=O(a,"typora").substr(0,10).replace(/[/=+-]/g,"a"),b&&(a+="darwin")}return a};var R=!1;const A=()=>{var e=s.getContext().tags;e.hasLicense=r,s.mergeContext(e)},N=()=>process.platform.replace(/\d+/,""),B=async(t,n,o)=>{oe(),console.log(`request ${W}/`+t);const e=new AbortController;var i,r=setTimeout(()=>e.abort(),3e4);try{i=await k(W+"/"+t,{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}}),clearTimeout(r)}catch(e){var a=e;if(console.warn(e.stack),clearTimeout(r),o&&"zh-Hans"==l.setting.getUserLocale()&&!l.setting.get("useMirrorInCN")){r=(await g.dialog.showMessageBox(null,{message:"链接服务器失败,使用尝试访问国内域名进行激活?",buttons:["确认","取消"]}))["response"];if(console.log("click "+r),r)throw a;return l.setting.put("useMirrorInCN",!0),B(t,n,!1)}if(l.setting.get("useMirrorInCN"))try{console.log("request to typora.com.cn"),i=await post("https://typora.com.cn/store/"+t,n)}catch(e){throw a}}if(i){if(200==i.status)return-1{const o=(new Date).toLocaleDateString("en-US");var{deviceId:t,lastRetry:i}=t||{};if(n||!(new Date-ir.abort(),4e4);const a=await(await k(W+"/api/client/renew",{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}})).json();clearTimeout(e),a.success||(console.warn("[renewL]: unfill due to renew fail"),$(a.msg)),d().put("SLicense",[a.msg,0,o].join("#"))}catch(e){e.stack,s.captureException(e,{level:"warning"}),console.warn("Failed to Renew L");var[t,n]=(i=d().get("SLicense")).split("#"),i=[t,n=+n+1,o].join("#");d().put("SLicense",i)}}},J=e=>{var t=new Date(d().get("IDate"));return isNaN(t.getTime())?e?null:new Date:e?t:(e=1675942262795,isNaN(e)?e=new Date("2021-10-01"):(e=new Date(e),isNaN(e.getTime())&&(e=new Date("2021-10-01"))),t{if(t=t||15,432e5{var e=(p=J(!global.devVersion))?V(!1):100;(15{R=!0;var t=_(),{license:n,email:o,type:i}=t||{};n&&o?(j(o,n,i),z(t,e)):$()},K=(e,t)=>g.dialog.showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:e,message:t}),Q=function(){l.expired=!0,K(h.getPanelString("Error"),h.getPanelString("This dev version of Typora is expired, please download and install a newer version.")).then(()=>{m.openExternal("https://typora.io/#download"),setTimeout(()=>{process.exit(1)},1e3)})},Z=function(){var e;re()&&!l.setting.inFirstShow&&(e=y||global.devVersion,y&&Math.random()<.8||(!S||new Date-S>36e5*(e?4:2)||!e&&V(!0,16)<=0)&&Y())};var G=!1,t=null;const Y=async function(e){if(S=new Date,null==t)return(t=v.showPanelWindow({width:525,height:420,path:`page-dist/license.html?dayRemains=${V(!0)}&index=${e?1:0}&hasActivated=${r||!1}&email=${x}&license=${c}&lang=${l.setting.getUserLocale()}&needLicense=${ie()&&!global.devVersion}&type=${D}&os=`+(w?"win":b?"mac":"linux"),frame:!1,alwaysOnTop:!C})).on("closed",function(){t=null}),void setTimeout(()=>{t&&!t.isDestroyed()&&t.setAlwaysOnTop(!1)},5e3);t.focus()};var n=null;async function X(){var o=(o=process.env.USER)||i(842).userInfo().username;switch(process.platform){case"win32":return process.env.COMPUTERNAME+" | "+o+" | Windows";case"darwin":return new Promise(n=>{i(620).exec("scutil --get ComputerName",{timeout:5e3},(e,t)=>{n(!e&&t?t.toString().trim()+" | "+o+" | darwin":i(842).hostname()+" | "+o+" | darwin")})});default:return i(842).hostname()+" | "+o+" | Linux"}}async function ee(e){try{var{fingerprint:t,email:n,license:o,type:i}=E(e)||{};return n&&o&&t?t!=await U()?(console.log("[L] validate server return fail"),$(),!1):(j(n,o,i),d().put("SLicense",e+"#0#"+(new Date).toLocaleDateString("en-US")),r=!0):(console.log("[L] validate server return empty"),$(),!1)}catch(e){throw console.error(e.stack),new Error("WriteActivationInfoFail")}}const te=e=>{const r="L23456789ABCDEFGHJKMNPQRSTUVWXYZ";if(!/^([A-Z0-9]{6}-){3}[A-Z0-9]{6}$/.exec(e))return!1;var e=e.replace(/-/g,""),t=e.substr(22);return!e.replace(/[L23456789ABCDEFGHJKMNPQRSTUVWXYZ]/g,"")&&t==(e=>{for(var t="",n=0;n<2;n++){for(var o=0,i=0;i<16;i+=2)o+=r.indexOf(e[n+i]);o%=r.length,t+=r[o]}return t})(e)},ne=(e.handle("license.machineCode",async()=>{console.log("handle license.machineCode");try{return await Buffer.from(JSON.stringify({v:N()+"|"+l.getVersion(),i:await U(),l:await X()}),"utf8").toString("base64")}catch(e){console.error(e.stack)}}),async t=>{r&&x&&c||console.error("doDeactivation on unregistered device");var e=(_()||{})["deviceId"];try{await B("api/client/deactivate",{license:c,l:e,sig:O(x,await U(),c)},!1)}catch(e){if(s.captureException(e,{level:"warning"}),console.log(e.stack),!t&&"off"==D)return!1}return $(),!0}),oe=(e.handle("addLicense",async(e,{email:t,license:n,force:o})=>{try{return await async function(e,t,n){if(e=(e||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),t=(t||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),!/^[^\s@'"/\\=?]+@[^\s@'"/\\]+\.[^\s@'"/\\]+$/.test(e))return[!1,"Please input a valid email address"];if(!te(t))return[!1,"Please input a valid license code"];t={v:N()+"|"+l.getVersion(),license:t,email:e,l:await X(),f:await U(),u:l.setting.generateUUID(),type:global.devVersion?"dev":"",force:n};JSON.stringify(t);try{var o=await B("api/client/activate",t,!0);if(JSON.stringify(o),console.log("[License] response code is "+o.code),o.code==T.SUCCESS)return await ee(o.msg)?[!0,""]:[!1,"Please input a valid license code"];if(o.code==T.OUT_OF_LIMIT)return n?await ee(o.msg)?[!0,"Your license has exceeded the max devices numbers.\nThe oldest device was unregistered automatically."]:[!1,"Please input a valid license code"]:["confirm",'Your license has exceeded the max devices numbers.\nIf you click "Continue Activation", this device will be activated and the oldest device will be unregistered automatically.'];if(o.code==T.INVALIDATE)return[!1,"Please input a valid license code"];if(o.code==T.WRONG_USER)return[!1,"This license code has been used with a different email address."]}catch(e){return"WriteActivationInfoFail"==e.message?(ne(!0).then(()=>{},()=>{}),[!1,"Failed to write your license to local machine"]):e.response&&e.response.code?(console.warn("[L] error from server "+e.response.code),[!1,"Unknown Error. Please contact hi@typora.io"]):(s.captureException(e,{level:"warning"}),console.error(e.stack),[!1,"Failed to access the license server. Please check your network or try again later."])}}(t,n,o)}catch(e){console.error(e.stack)}}),e.handle("offlineActivation",async(e,t)=>{try{return n=t,await(await ee(n)?[!0,"",x,c]:[!1,"Please input a valid license code"])}catch(e){console.error(e.stack)}var n}),e.handle("license.show",(e,t)=>{Y(t||!1)}),e.handle("license.show.debug",()=>{t&&t.webContents.openDevTools()}),e.handle("removeLicense",async e=>{try{return await ne()}catch(e){console.error(e.stack)}return!1}),()=>{W=l.setting.get("useMirrorInCN")?shostc||"".substring(1):global.shost||"".substring(1)});const ie=()=>!r&&!y,re=e=>R&&!r;var ae;ae=(new Date).getTime();const le="txxxx-xxxx-xxxxy".replace(/[x]/g,function(e){var t=(ae+16*Math.random())%16|0;return ae=Math.floor(ae/16),t.toString(16)}),se=()=>{f.getAllWindows().forEach(e=>{e.webContents.executeJavaScript(`try{document.querySelector(".${le}").remove();}catch(e){};File.option && (File.option.hasLicense = true);File.megaMenu && File.megaMenu.forceReload();0;`)})},ce=async e=>{await h.initDict();const t=`.typora-sourceview-on .${le}{left: 170px;}.${le} {position: fixed;bottom: 2px;z-index: 9999;left: 70px;font-size: 12px;line-height: 24px;background: rgb(120 120 120 / 30%);padding: 0 12px;color: var(--text-color);border-radius: 4px;cursor: pointer;}.pin-outline .${le}{left:calc(var(--sidebar-width) + 70px);}`,n=`if(window.File.option){File.option.hasLicense = false;File.megaMenu && File.megaMenu.forceReload();if(!document.querySelector(".${le}")) {const pos = Math.round(Math.random() * document.body.children.length);const dom = document.createElement("DIV");dom.innerText = "${h.getPanelString("UNREGISTERED")} ×";dom.classList.add("${le}");dom.style = "position: fixed !important;bottom: 2px !important; display: block !important; opacity: 1 !important; height: auto !important; width: auto !important; z-index: 9999 !important;";dom.setAttribute("role", "button");dom.addEventListener("click", () => {dom.remove();reqnode("electron").ipcRenderer.invoke("license.show");});document.body.insertBefore(dom, document.body.children[pos]);}};1;`;function o(e){e.webContents.insertCSS(t.replace(/(\{|\}|;)\n/g,"$1")),e.webContents.executeJavaScript(n.replace(/(\{|\}|;)\n/g,"$1"))}e?o(e):f.getAllWindows().forEach(o)};w&&(e=i(541).join(t_workingDir,"../winmm.dll"),i(833).stat(e,function(e,t){!e&&t&&setTimeout(function(){G=!0},138e4)})),u.startL=async(e,t)=>{console.log("start LM in devVersion="+(global.devVersion||!1));try{oe(),await U(),!e&&t||y||(global.devVersion||!t||-1240*I)&&Q(),n=+n,console.log("verInitTime is "+n),!isNaN(n)&&o-n>200*I&&Q()),(async e=>{console.log("[watch L]"),q(e),await H(),console.log("[watch L] hasL: "+r),Z(),A()})(e)}catch(e){s.captureException(e)}var n,o,i;v.on("dom-ready",e=>{e=e,R&&re()&&ce(e)}),v.on("make-window",e=>{Z()})},u.showLicensePanel=Y,u.showWelcomePanel=async function(){if(S=new Date,null==n)return(n=v.showPanelWindow({width:760,height:460,path:"page-dist/welcome.html?lang="+l.setting.getUserLocale(),frame:!1,alwaysOnTop:!C})).on("closed",function(){n=null}),void setTimeout(()=>{n&&!n.isDestroyed()&&n.setAlwaysOnTop(!1)},4e3);n.focus()},u.shouldShowWelcomePanel=ie,u.getHasLicense=()=>r,u.cannotContinueUse=function(){return!1===r&&!y&&!global.devVersion&&(G||V(!0,20)<=0)}},557:(o,i,F)=>{var c,d,W=global.PRODUCTION_MODE,S=F(134),x=S.app,u=F(266),r=F(338),a=S.Menu,l=S.MenuItem,p=S.BrowserWindow,s=S.shell,D="win32"==process.platform,h="darwin"==process.platform,g="linux"==process.platform,T=F(728),P=F(541).join(__dirname,"../"),m=F(344),f=F(824),w=F(156),E=F(445),b=require(W?"package.json":"../package.json"),I=F(468),y=1e4;function v(t){var o,i,r=0,n=x.getPath("userData")+"/typora.log",a="",l=console.error;function s(e,t){try{if(y{this.logStream=e})}function k(){var n=(new Date).getTime();return uuid="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),("x"==e?t:3&t|8).toString(16)})}function _(t){var e=1675942262795,n=!1,o=0;isNaN(e)||(o=30<(e=(new Date-e)/864e5/5)?(n=!0,.001):Math.max(0,(30-e)/30),isNaN(o)&&(o=.01)),I.config("https://41af752e6d61480d85276af874a7f69b@sentry.typora.io/2",{logger:"node",release:b.releaseId,autoBreadcrumbs:{http:!1,console:!1},sampleRate:o,shouldSendCallback:function(e){return(!e||"debug"!=e.level)&&(!n&&!t.hasUpdates&&t.db&&t.get("send_usage_info")+""!="false")}}).install(B),C=k(),I.mergeContext({tags:{instance:C,arch:process.platform,appVersion:x.getVersion()}}),I.disableConsoleAlerts(),setTimeout(function(){console.log("[Raven] instanceKey = "+C)},0),I.setDataCallback(function(e){try{return e?(e.request&&(e.request.url="http://typora/"),e.mechanism&&delete e.mechanism,e.exception&&(t=e)&&(t.message&&(t.message=L(t.message)),(t.exception||[]).forEach(function(e){e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&e.stacktrace.frames.forEach(function(e){e.filename&&(e.filename=U(e.filename))})}),n=t.stacktrace||[],(t=(t.exception||{}).values||[]).forEach&&t.forEach(function(e,t){e&&(e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&(n=n.concat(e.stacktrace.frames)))}),n.length&&n.forEach(function(e){var t;-1<(t=e.filename.lastIndexOf("atom.asar"))&&(e.filename="http://typora-app/atom/"+e.filename.substring(t+9).replace(/\\/g,"/"))})),e):void 0}catch(e){console.error(e.stack)}var t,n;return{}})}e.prototype.closeLogging=function(){console.log("closeLogging");try{c=!0,d&&(process.stdout.write=process.stderr.write=d),this.logStream&&this.logStream.end()}catch(e){console.error(e)}},e.prototype.put=function(e,t){this.db.getState()[e]=t,this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=setTimeout(this.save.bind(this),500)},e.prototype.get=function(e,t){try{return"recentDocument"==e?this.getRecentDocuments():"recentFolder"==e?this.getRecentFolders():("framelessWindow"!=e||!g)&&(void 0===(n=this.db.getState())[e]?t:n[e]);var n}catch(e){return console.error(e),t}},e.prototype.save=function(){this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=null;try{this.db.write()}catch(e){console.error(e.stack)}},e.prototype.syncAll=function(){this.saveTimer&&clearTimeout(this.saveTimer);try{this.db.write(),this.history.write()}catch(e){console.error(e.stack)}},e.prototype.getAllThemes=function(){return this.allThemes},e.prototype.getRecentFolders=function(){var e=this.history.getState(),t=e.recentFolder;return t||(e.recentFolder=t=[]),t||[]},e.prototype.addRecentFolder=function(e){console.log("addRecentFolder"),e=F(541).normalize(e);var t=F(541).basename(e),n=this.getRecentFolders();if(t.length){this.removeRecentFolder(e,!0),n.unshift({name:t,path:e,date:new Date}),8new Promise(e=>{T.rm(l.join(v,t),{force:!0,recursive:!0,maxRetries:1},e)})))}await 0}if(0==o&&T.existsSync(a))g();else{console.log("overwriteThemeFolder"),T.ensureDirSync(f);var w=[];if(-1<["github.css","newsprint.css","night.css","pixyll.css","white.css"].indexOf(e)){try{T.renameSync(l.join(a,e),l.join(f,e)),w.push(e)}catch(e){}T.copySync(l.join(m,e),l.join(a,e),{overwrite:!0})}h.list(m,function(e,t){Promise.all(t.map(function(e){var r=l.basename(e);return new Promise(function(e,t){if(-1{}),C.rm(s.join(c,i+".aff"),{force:!0},()=>{}),C.rm(s.join(c,i+"-LICENSE"),{force:!0},()=>{}),console.log(`remove ${c}/${i}.dic`)}}else this.put("strict_mode",!0),this.put("copy_markdown_by_default",!0)}this.initDictionary_(),this.addAnalyticsEvent("launch"),t&&0!=o?this.addAnalyticsEvent(0{var t=x.setting.get("export.general")||{},n={},o=(["pdf","html","html-plain","image"].forEach(e=>{n[e]=Object.assign({type:e},t,x.setting.get("export."+e)||{})}),{});return x.setting.loadCustomExports().forEach(e=>{o[e.key]=Object.assign({},t,e,x.setting.get("export."+e.key)||{})}),JSON.stringify([n,o])}),n.handle("export.recordLastExport",(e,t)=>{A||(x.updateMenu({"File→Export→Export with Previous":{enabled:!0}}),x.updateMenu({"File→Export→Export and Overwrite with Previous":{enabled:!0}})),A=t,x.setting.lastExport=t,x.execInAll("File.option._lastExport = "+JSON.stringify(t))}),n.handle("setting.getDownloadingDicts",e=>JSON.stringify(x.setting.downloadingDicts||[])),n.handle("setting.getUserDictionaryPath",e=>x.setting.getUserDictionaryPath()),n.handle("setting.getUserDict",e=>JSON.stringify(x.setting.userDict)),n.handle("setting.downloadDict",(e,t)=>{e=p.fromWebContents(e.sender);x.setting.downloadDict(t,e.id)}),n.handle("setting.getThemes",e=>({all:x.setting.getAllThemes()||[],current:x.setting.curTheme()})),n.handle("setting.setCurTheme",(e,t,n)=>{x.setting.setCurTheme(t,n)}),n.handle("setting.resetAdvancedSettings",(e,t)=>{function n(){}var o=F(728),i=x.getPath("userData")+"/conf/conf.user.json";o.copy(P+"/conf.default.json",x.getPath("userData")+"/conf/conf.default.json",{overwrite:!0},t?function(){S.shell.showItemInFolder(i)}:n),o.copy(P+"/conf.default.json",i,{overwrite:!0},n)}),n.handle("logger.error",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Error] "+t)}),n.handle("logger.warn",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Warn] "+t)}),n.handle("setting.clearRecentDocuments",e=>{x.setting.clearRecentDocuments()}),n.handle("setting.removeRecentFolder",(e,t)=>{x.setting.removeRecentFolder(t)}),n.handle("setting.removeRecentDocument",(e,t)=>{x.setting.removeRecentDocument(t)}),n.handle("setting.addRecentFolder",(e,t)=>{x.setting.addRecentFolder(t)}),n.handle("setting.getRecentFiles",e=>JSON.stringify({files:x.setting.getRecentDocuments()||[],folders:x.setting.getRecentFolders()||[]})),n.handle("setting.put",(e,t,n)=>{x.setting.put(t,n)}),n.handle("setting.get",(e,t)=>x.setting.get(t)),n.handle("setting.fetchAnalytics",e=>{var t=JSON.stringify(x.setting.analyticsEvents);return x.setting.analyticsEvents=[],t}),null),B=(n.handle("setting.getUnsavedDraftsPath",e=>x.setting.getUnsavedDraftPath()),e.prototype.getUnsavedDraftPath=function(){return N?Promise.resolve(N):(N=F(541).resolve(x.getPath("userData"),"draftsRecover"),F(728).ensureDir(N).then(()=>N))},function(e,t,n){t&&console.info(t.stack||t.message),e=e||{},console.error(e.stack||e.message),!x.isReady()||"ENOTFOUND"!=(t=e.errno||e.code)&&"ETIMEDOUT"!=t&&"ECONNRESET"!=t&&0!=(e.message||"").indexOf("net::ERR")&&(dialog=F(134).dialog,stack=null!=(ref=e.stack)?ref:e.name+": "+e.message,message="Uncaught Exception:\n"+stack,dialog.showMessageBox(null,{type:"error",buttons:["OK","Learn Data Recovery"],defaultId:0,cancelId:0,title:"A JavaScript error occurred in the main process",message:message}).then(({response:e})=>{1==e?(e=x.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",s.openExternal(`https://support.${e}/Version-Control/`)):process.exit(1)}))});function z(t,n){p.getAllWindows().forEach(function(e){e.isDestroyed()||e.webContents.isDestroyed()||e.webContents.isLoading()||e.webContents.send(t,n)})}function J(e,t){t=e.indexOf(t);-1{},()=>{}),console.error(e),I.captureException(e)}}catch(e){console.error(e),I.captureException(e)}try{o.userDictionaryPath?(e=await T.readFile(this.userDictionaryPath+"/user-dict.json","utf8"),o.userDict=JSON.parse(e)):console.error("no userDictionaryPath found")}catch(e){console.warn("user-dict.json not found")}function r(){o.userDictionaryPath&&F(833).writeFile(o.userDictionaryPath+"/user-dict.json",JSON.stringify(o.userDict),function(){}),x.sendEvent("user-dict-update",o.userDict)}n=S.ipcMain;n.on("user-dict-add",function(e,t){var{lang:t,word:n}=t;o.userDict[t]=o.userDict[t]||[],-1==o.userDict[t].indexOf(n)&&o.userDict[t].push(n),r()}),n.on("user-dict-remove",function(e,t){o.userDict[t.lang]=(o.userDict[t.lang]||[]).filter(function(e){return e!=t.word}),r()})},e.prototype.buildOption=async function(){var t={},e=(t.supportTextBundle=this.supportTextBundle,t.enableInlineMath=this.get("enable_inline_math")||!1,t.enableHighlight=this.get("enable_highlight")||!1,t.enableSubscript=this.get("enable_subscript")||!1,t.enableSuperscript=this.get("enable_superscript")||!1,t.enableDiagram=0!=this.get("enable_diagram"),t.copyMarkdownByDefault=this.get("copy_markdown_by_default")||!1,t.showLineNumbersForFence=this.get("show_line_numbers_for_fence")||!1,t.noPairingMatch=this.get("no_pairing_match")||!1,t.autoPairExtendSymbol=this.get("match_pari_markdown")||!1,t.expandSimpleBlock=this.get("auto_expand_block")||!1,t.headingStyle=this.get("heading_style")||0,t.ulStyle=this.get("ul_style")||0,t.olStyle=this.get("ol_style")||0,t.scrollWithCursor=!this.get("no_mid_caret"),t.autoNumberingForMath=this.get("auto_numbering_for_math"),t.allowPhysicsConflict=this.get("allowPhysicsConflict"),t.noDisplayLinesInMath=this.get("noDisplayLinesInMath"),t.useRelativePathForImg=this.get("use_relative_path_for_img")||!1,t.relativePathWithDot=this.get("relativePathWithDot")||!1,t.allowImageUpload=this.get("allow_image_upload")||!1,t.defaultImageStorage=this.get("image_save_location")||null,"custom"==t.defaultImageStorage&&(t.defaultImageStorage=this.get("custom_image_save_location")),t.applyImageMoveForWeb=this.get("apply_image_move_for_web")||!1,t.applyImageMoveForLocal=!this.get("no_image_move_for_local"),t.preferCRLF=this.get("line_ending_crlf")||!1,t.sidebarTab=this.get("sidebar_tab")||"",t.useTreeStyle=this.get("useTreeStyle")||!1,t.strictMarkdown=this.get("strict_mode")||!1,t.noLineWrapping=this.get("no_line_wrapping")||!1,t.prettyIndent=this.get("prettyIndent")||!1,t.convertSmartOnRender=this.get("SmartyPantsOnRendering"),t.smartDash=this.get("smartDash"),t.smartQuote=this.get("smartQuote"),t.twoHyphensToEm=this.get("twoHyphensToEm")||!1,t.remapUnicodePunctuation=this.get("remapPunctuation"),t.indentSize=this.get("indentSize")||2,t.codeIndentSize=this.get("codeIndentSize")||4,t.enableAutoSave=this.get("enableAutoSave")||!1,t.saveFileOnSwitch=this.get("save_file_on_switch")||!1,t.presetSpellCheck=this.get("preset_spell_check")||"auto",t.autoCorrectMisspell=!1,this.config||{});t.monocolorEmoji=e.monocolorEmoji,t.userQuotesArray=this.get("userQuotesArray"),t.passiveEvents=!0,t.canCollapseOutlinePanel=this.get("can_collapse_outline_panel"),t.preLinebreakOnExport=this.get("preLinebreakOnExport"),t.preLinebreakOnExport=1==t.preLinebreakOnExport||"true"==t.preLinebreakOnExport,t.indentFirstLine=this.get("indentFirstLine"),t.hideBrAndLineBreak=this.get("hideBrAndLineBreak"),t.isFocusMode=this.get("isFocusMode"),t.isTypeWriterMode=this.get("isTypeWriterMode"),t.ignoreLineBreak=this.get("ignoreLineBreak")||!1,t.sendAnonymousUsage=this.get("send_usage_info"),t.useMirrorInCN=this.get("useMirrorInCN"),void 0!==t.sendAnonymousUsage&&null!==t.sendAnonymousUsage||(t.sendAnonymousUsage=!0),t.uuid=this.get("uuid"),t.appVersion=x.getVersion(),t.instance=C,t.devVersion=global.devVersion,t.hasLicense=E.getHasLicense(),t.userLocale=this.getUserLocale(),t.appLocale=x.getLocale(),t.sidebarWidth=this.get("sidebar-width"),t.caseSensitive=this.get("caseSensitive"),t.wholeWord=this.get("wholeWord"),t.useRegexp=this.get("useRegexp"),t.fileSearchCaseSensitive=this.get("fileSearchCaseSensitive"),t.fileSearchWholeWord=this.get("fileSearchWholeWord"),t.fileSearchUseRegexp=this.get("fileSearchUseRegexp"),t.wordCountDelimiter=this.get("wordCountDelimiter")||0;try{t.userPath=x.getPath("home")||""}catch(e){t.userPath=(D?process.env.USERPROFILE:"")||""}if(t.mainPath=global.addonPath||"",t.userDataPath=x.getPath("userData")||"",!this.tempPath){var n=x.getPath("temp");0{t.keys[e]=(m.getKeyAccelerator(e)||"").toLowerCase()}),t.mathFormatOnCopy=this.get("mathFormatOnCopy")||"svg",t.imageUploader=this.get("image_uploader"),t.customImageUploader=this.get("custom_image_uploader"),t.picgoAppPath=this.get("picgo_app_path"),t.noWarnigUploadDisabled=this.get("noWarnigUploadDisabled")||!1,t.noWarnigForMoveFile=this.get("noWarnigForMoveFile")||!1,t.noWarnigForMoveFileToList=this.get("noWarnigForMoveFileToList")||!1,t.noWarnigForDeleteFile=this.get("noWarnigForDeleteFile")||!1,t.noWarnigForTypeWriterMode=this.get("noWarnigForTypeWriterMode")||!1,t.noHintForOpenLink=this.get("noHintForOpenLink")||!1,t.noHintForUnibody=this.get("noHintForUnibody")||!1,t.noWarnigForFocusMode=this.get("noWarnigForFocusMode")||!1,t.noWarningForExportOverwrite=this.get("noWarningForExportOverwrite")||!1,t.noWarningForUpdateImageReference=this.get("noWarningForUpdateImageReference")||!1,t.hasUpdates=this.hasUpdates||!1,t.pandocPath=this.get("pandocPath")||"",t.buildTime=1675942262795,t.debug=this.get("debug"),t._lastExport=A,t.lineWiseCopyCut=this.get("lineWiseCopyCut")||!1,t},e.prototype.extraOption=async function(){var t=await this.buildOption();return t.restoreWhenLaunch=this.get("restoreWhenLaunch")||0,t.pinFolder=this.get("pinFolder"),t.enable_inline_math=t.enableInlineMath,t.enable_highlight=t.enableHighlight,t.enable_subscript=t.enableSubscript,t.enable_superscript=t.enableSuperscript,t.enableDiagram=0!=this.get("enable_diagram"),t.enable_diagram=t.enableDiagram,t.copy_markdown_by_default=!!this.get("copy_markdown_by_default"),t.show_line_numbers_for_fence=!!this.get("show_line_numbers_for_fence"),t.no_pairing_match=!!this.get("no_pairing_match"),t.match_pari_markdown=!!this.get("match_pari_markdown"),t.auto_expand_block=!!this.get("auto_expand_block"),t.heading_style=this.get("heading_style")||0,t.ul_style=this.get("ul_style")||0,t.ol_style=this.get("ol_style")||0,t.no_mid_caret=this.get("no_mid_caret"),t.auto_numbering_for_math=this.get("auto_numbering_for_math"),t.use_relative_path_for_img=this.get("use_relative_path_for_img"),t.relativePathWithDot=this.get("relativePathWithDot"),t.allow_image_upload=this.get("allow_image_upload"),t.image_save_location=this.get("image_save_location"),t.custom_image_save_location=this.get("custom_image_save_location"),t.apply_image_move_for_web=this.get("apply_image_move_for_web"),t.no_image_move_for_local=this.get("no_image_move_for_local"),t.line_ending_crlf=this.get("line_ending_crlf"),t.strict_mode=this.get("strict_mode"),t.no_line_wrapping=this.get("no_line_wrapping"),t.prettyIndent=this.get("prettyIndent"),t.SmartyPantsOnRendering=this.get("SmartyPantsOnRendering"),t.remapPunctuation=this.get("remapPunctuation"),t.save_file_on_switch=this.get("save_file_on_switch")||!1,t.preset_spell_check=this.get("preset_spell_check")||"auto",t.can_collapse_outline_panel=this.get("can_collapse_outline_panel"),t.send_usage_info=!1!==this.get("send_usage_info"),t.currentThemeFolder=x.getPath("userData")+(D?"\\":"/")+"themes",t.enableAutoUpdate=!1!==this.get("enableAutoUpdate"),t.autoUpdateToDev=this.get("autoUpdateToDev"),t.userLanguage=this.get("userLanguage"),t.image_uploader=this.get("image_uploader"),t.custom_image_uploader=this.get("custom_image_uploader"),t.picgo_app_path=this.get("picgo_app_path"),t.allThemes=this.allThemes,t.useSeparateDarkTheme=this.get("useSeparateDarkTheme")||!1,t.theme=this.get("theme")||"github.css",t.darkTheme=this.get("darkTheme")||"night.css",t.customExport=this.get("customExport"),["general","pdf","html","html-plain","image"].forEach(e=>{t["export."+e]=this.get("export."+e)}),(t.customExport||R).forEach(e=>{t["export."+e.key]=this.get("export."+e.key)}),t},n.handle("setting.getExtraOption",async e=>JSON.stringify(await x.setting.extraOption())),n.handle("setting.doDownloadPicgo",e=>{x.setting.doDownloadPicgo()}),n.handle("setting.getKeyBinding",e=>x.setting.config.keyBinding||{}),e.prototype.doDownloadPicgo=function(){w.initDict().then(function(){var e="https://github.com/typora/PicGo-cli/releases/download/latest/%@.zip".replace("%@",D?"x64"==process.arch?"win64":"win32":"linux");console.log(e);let n=F(541).normalize(x.getPath("userData")+"/picgo"),o=F(541).normalize(n+"/_picgo.zip");var i=new f(e,o,{title:w.getPanelString("Download"),text:w.getPanelString("Downloading…"),processOnComplete:.9});i.onSuccess=(e,t)=>{F(834)(o,{dir:n},function(e){t.value=1,t.text=w.getPanelString("Finished"),t.detail="",setTimeout(()=>{i.setCompleted()},2e3),T.unlink(o,()=>{})}),t.detail=w.getPanelString("Unzipping…")},i.onError=e=>{S.dialog.showErrorBox(w.getPanelString("Download"),e.message)},i.download()})};var V=null;e.prototype.useDarkTheme=function(){return V=S.nativeTheme.shouldUseDarkColors&&this.get("useSeparateDarkTheme")},e.prototype.useDarkThemeBefore=function(){return V},e.prototype.curTheme=function(){return this.useDarkTheme()?this.get("darkTheme")||"night.css":this.get("theme")||"github.css"},e.prototype.setCurTheme=function(e,t){return a.getApplicationMenu().getItem("Themes").submenu.items.map(function(e){e.checked=e.label==t}),this.useDarkTheme()?this.put("darkTheme",e):this.put("theme",e)},o.exports=e},587:(o,e,t)=>{var u,p=t(134),h=p.app,n=p.ipcMain,g=p.BrowserWindow,m=(t(445),t(468)),f=(process.platform,"linux"==process.platform),w=t(541).join(__dirname,"../");n.handle("window.setTitle",(e,t,n)=>{e=g.fromWebContents(e.sender);t=t||("Typora"===(t=e.getTitle())?"Untitled"+(n?"• - Typora":" - Typora"):t.replace(/•? - Typora$/,n?"• - Typora":" - Typora")),e.setTitle(t)}),n.handle("window.focus",e=>{e=g.fromWebContents(e.sender);return e.focus(),e.webContents.focus(),!0}),n.handle("window.setInSourceMode",(e,t)=>{g.fromWebContents(e.sender).inSourceMode=!!t}),n.handle("window.minimize",e=>{g.fromWebContents(e.sender).minimize()}),n.handle("window.close",e=>{g.fromWebContents(e.sender).close()}),n.handle("window.restore",e=>{e=g.fromWebContents(e.sender);e.unmaximize(),e.setFullScreen(!1)}),n.handle("window.maximize",e=>{g.fromWebContents(e.sender).maximize()}),n.handle("window.fullscreen",e=>{e=g.fromWebContents(e.sender);return e.setFullScreen(!0),e.isFullScreen()}),n.handle("window.setMenuBarVisibility",(e,t)=>{g.fromWebContents(e.sender).setMenuBarVisibility(t)}),n.handle("window.pin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!0)}),n.handle("window.unpin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!1)}),n.handle("window.updateMenuForIsAlwaysOnTop",e=>{e={"View→Always on Top":{state:g.fromWebContents(e.sender).isAlwaysOnTop()}};h.updateMenu(e)}),n.handle("window.toggleDevTools",e=>{e=g.fromWebContents(e.sender);e.webContents.isDevToolsOpened()?e.webContents.closeDevTools():e.webContents.openDevTools()}),n.handle("window.inspectElement",(e,t,n)=>{g.fromWebContents(e.sender).inspectElement(t,n)}),n.handle("window.checkAsFocus",e=>{e=g.fromWebContents(e.sender);e&&e.isFocused&&(h.currentFocusWindowId=e.id)}),n.handle("controller.switchFolder",(e,t)=>{e=g.fromWebContents(e.sender);h.switchFolder(t,e)}),n.handle("webContents.copy",e=>{g.fromWebContents(e.sender).webContents.copy()}),n.handle("webContents.cut",e=>{g.fromWebContents(e.sender).webContents.cut()}),n.handle("webContents.paste",e=>{g.fromWebContents(e.sender).webContents.paste()}),n.handle("webContents.selectAll",e=>{g.fromWebContents(e.sender).webContents.selectAll()}),n.handle("webContents.undo",(e,t)=>{g.fromWebContents(e.sender).webContents.undo()}),n.handle("webContents.redo",(e,t)=>{g.fromWebContents(e.sender).webContents.redo()}),n.handle("webContents.clearCache",(e,t)=>{var n=g.fromWebContents(e.sender);return new Promise(e=>{n.webContents.session.clearCache(e)})}),n.handle("webContents.action",(e,t)=>{g.fromWebContents(e.sender).webContents[t]()}),e.makeWindow=async(d,e)=>{var t=h.getDocumentController();e=e||{};var n,o,i=g.getFocusedWindow(),r=h.setting.config||{},a=t.lastClosedBounds,l=(i=i&&!t.getDocumentFromWindowId(i.id)?null:i)&&i.getBounds(),s=0,l=(a||(l?(s=i.isMaximized()||i.isFullScreen()?0:30,a={fullscreen:i.isFullScreen(),maximized:i.isMaximized()},s&&(a.x=l.x+s,a.y=l.y+s,a.width=l.width,a.height=l.height)):a=u?(s=u.fullscreen||u.maximize?0:30,{x:u.x+s,y:u.y-s,width:u.width,height:u.height,fullscreen:u.fullscreen,maximized:u.maximized}):{}),!a.fullscreen&&a.maximized),e={x:a.x,y:a.y,width:a.width||800,height:a.height||700,minWidth:400,minHeight:400,frame:!h.setting.get("framelessWindow"),disableAutoHideCursor:!1,backgroundColor:h.setting.get("backgroundColor"),webPreferences:{webSecurity:!1,allowRunningInsecureContent:!1,plugins:!1,nodeIntegration:!0,enableRemoteModule:!1,webviewTag:!0,nodeIntegrationInWorker:!0,devTools:!0,images:!0,directWrite:r.directWrite,defaultFontFamily:r.defaultFontFamily,allowDisplayingInsecureContent:!1,backgroundThrottling:!1,spellcheck:!1,contextIsolation:!1,additionalArguments:["--tyopt="+JSON.stringify({isMaximized:l,isFullScreen:a.fullscreen,...await h.setting.buildOption(),...e})]},autoHideMenuBar:a.fullscreen||r.autoHideMenuBar,show:d,fullscreen:a.fullscreen,alwaysOnTop:i&&i.isAlwaysOnTop(),fullscreenable:!0},c=(f&&(e.icon=w+"/assets/icon/icon_256x256.png"),r=e,i=0s.y+s.height&&(r.y=s.y+s.height-r.height),r.xs.x+s.width&&(r.x=i?s.x:s.x+s.width-r.width)),u=e,l&&(e.show=!1),new g(e));return t.lastClosedBounds=null,l&&(c.maximize(),d&&c.show()),a.fullscreen&&(c.autoHideMenuBar=!0,c.setMenuBarVisibility(!1)),c.loadURL(entry||"".substring(1)),n=c,o=p.shell,n.webContents.on("will-navigate",function(e,t){e.preventDefault(),o.openExternal(t)}),n.webContents.setWindowOpenHandler(e=>(/^https?:/.exec(e.url)&&o.openExternal(e.url),{action:"deny"})),n.webContents.on("crashed",function(e,t){console.error("render process is killed? "+t),m.captureMessage("render process crashed, killed="+t),h.setting.addAnalyticsEvent("crashed")}),n.webContents.on("unresponsive",function(){m.captureMessage("unresponsive",{extra:{winId:n.id}}),h.setting.addAnalyticsEvent("unresponsive")}),n.webContents.setMaxListeners(15),n.webContents.on("dom-ready",function(){n.isMaximized()&&n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");'),b("dom-ready",n)}),n.on("maximize",()=>{n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");')}),n.on("enter-full-screen",function(){n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");document.body.classList.add("typora-fullscreen");if(document.body.classList.contains("native-window")) {$("#ty-top-placeholder").show();};1;')}),n.on("unmaximize",function(){n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");')}),n.on("session-end",function(){console.log("[win] session-end"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),n.on("leave-full-screen",function(){n.autoHideMenuBar=!!h.setting.config.autoHideMenuBar,n.setMenuBarVisibility(!h.setting.config.autoHideMenuBar),n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");document.body.classList.remove("typora-fullscreen");$("#ty-top-placeholder").hide();1;'),u&&(u.fullscreen=!1)}),n.on("focus",function(){n.webContents.incrementCapturerCount();var e=t.getDocumentFromWindowId(n.id);e&&(e.setActiveWindow(n),h.focusedWindow=n)}),n.on("blur",()=>{console.log("[win] blur"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),b("make-window"),c};const i=t(93);var r=new i;const b=function(e,t){r.emit(e,t)};e.on=function(e,t){r.on(e,t)},e.showPanelWindow=function({path:e,...t}){var n=new g({modal:!0,show:!1,center:!0,resizable:!1,webPreferences:{devTools:!global.releaseMode,defaultFontSize:14,nodeIntegration:!0,contextIsolation:!1,enableRemoteModule:!1},...t});return n.loadURL("file://"+w+"/"+e),n.once("ready-to-show",function(){n.show()}),n.removeMenu(),f&&(n.icon=w+"/assets/icon/icon_256x256.png"),n.webContents.setWindowOpenHandler(e=>(p.shell.openExternal(e.url),{action:"deny"})),n}},90:(e,o,s)=>{e=s.nmd(e);var t,i=s(541),n=s(640),r=(t=i.join(__dirname,"../"),i.join(t,"node_modules.asar")),a=(n.globalPaths.push(r),n.prototype.require);n.prototype.require=function(e){return-1==this.paths.indexOf(__dirname)&&(this.paths.push(__dirname),this.paths.push(r)),/(\.node$)|(\/build\/Release)/.exec(e)&&"."==e[0]&&(e=i.resolve(i.dirname(this.id),e).replace(/\bnode_modules\.asar\b/,"node_modules")),a.call(this,e)};for(let e=0;e{c.exit()},1e3),s(405);var n=s(134),c=n.app,l=n.protocol,m=n.powerMonitor,d=n.BrowserWindow,u=s(728),f="win32"==process.platform,w=(process.platform,process.platform,s(557),s(344)),b=s(883),e=s(932),y=s(445),p=s(351),n=n.ipcMain;s(468);if(!c.requestSingleInstanceLock())return console.record("secondary instance would exit"),void c.quit();console.record("launch with argv ["+process.argv.join(", ")+"]"),c.on("second-instance",function(e,t,n){console.record("got argv ["+t.join(", ")+"] from secondary instance"),t=Array.from(t),d.getAllWindows().length&&((n=F(t,n))?c.openFileOrFolder(n,{forceCreateWindow:!n}):T(t||[]))});var v=1,k=2,C=3;function F(e,t){null==t&&(t=process.cwd());for(var n,o=e.length-1;0<=o;o--)if("-"!=e[o][0]&&!/\.asar$/.exec(e[o]||"")){n=e[o];break}if((n=0!=o&&n!=t?n:void 0)&&/^file:\/\//i.exec(n)){n=n.replace(/^file:\/\//i,"");try{n=decodeURI(n)}catch(e){}}return n?s(541).resolve(t,n):void 0}function S(e){if(!e)return e;var t=e.length;return 50((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFile(t||null,n).then(n=>{if(n)return new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e({winId:n.activeWindow.id})}):e({winId:n.activeWindow.id})})}))),n.handle("app.openFileOrFolder",(e,t,n)=>((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFileOrFolder(t||null,n))),n.handle("app.openOrSwitch",async(e,t,n)=>{var o,e=d.fromWebContents(e.sender),i=c.documentController.getDocument(t),r=c.documentController.getDocumentFromWindowId(e.id);if(i)return(o=i.activeWindow||i.windows.keys().next().value)&&o.focus(),!1;if(n)return c.openFileOrFolder(t,{curWindow:!0}),!1;if(await O(t))c.switchFolder(t,e);else if(!i)return r.rename(t),!0;return!1}),n.handle("app.openFolder",(e,t,n)=>{c.openFolder(t||null,n?d.fromWebContents(e.sender):void 0)}),n.handle("app.onCloseWin",(e,t)=>{e=d.fromWebContents(e.sender);c.onCloseWin(e.id,t)}),n.handle("app.sendEvent",(e,t,n)=>{c.sendEvent(t,n)}),n.handle("executeJavaScript",(e,t,n)=>{d.fromId(t).webContents.executeJavaScript(n)}),c.reopenFolder=function(){var t=new Set,n=!1;return g.forEach(function(e){e.mountFolder&&!t.has(e.mountFolder)&&(t.add(e.mountFolder),c.openFile(null,{forceCreateWindow:!0,mountFolder:e.mountFolder}),n=!0)}),n},c.reopenClosed=function(o){var i=!1;return g.length&&g.forEach(function(e,t){var n=c.getDocumentController().getDocument(e.path);n?n.activeWindow&&n.activeWindow.show():(c.openFile(e.path,{forceCreateWindow:!!t,mountFolder:e.mountFolder,silent:o,backupState:e,fromReopen:!0}),i=!0)}),i},function(e){var t,n=c.setting.get("restoreWhenLaunch")||0,o=!0,i=e||process.argv||[];-1{/^--/.exec(e)&&("--on-dev"==e?process.traceDeprecation=!0:-1===["--new","--reopen-file"].indexOf(e)&&c.commandLine.appendSwitch.apply(null,[e]))}),scheme||"".substring(3));c.on("ready",async function(){var e,t;await c.setting.initSetting(),c.expired||(p.lastClosedBounds=c.setting.get("lastClosedBounds"),console.record("------------------start------------------"),console.log("typora version: "+c.getVersion()),console.log(""+s.c[s.s].filename),M(P),c.setAppUserModelId("abnerworks.Typora"),(e=F(process.argv))&&"--on-dev"!==process.argv[process.argv.length-1]?c.openFileOrFolder(e):c.recoverFromBackup(),w.loadDict().then(()=>{w.bindMainMenu()}),f&&(t=s(558),c.updater=t,setTimeout(function(){t.initUpdater().then(function(){!1!==c.setting.get("enableAutoUpdate")&&c.updater.checkForUpdates(!1)})},3e3)),b.bindJumplist(),setTimeout(function(){try{E()}catch(e){console.warn(e.stack)}},3e4),m.on("suspend",()=>{console.record("[Power] suspend"),c.execInAll('window.onPowerChange && window.onPowerChange("suspend")')}),m.on("resume",()=>{console.record("[Power] resume"),c.execInAll('window.onPowerChange && window.onPowerChange("resume")')}),m.on("lock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("lock-screen")')}),m.on("unlock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("unlock-screen")')}))});var I,W={},E=async function(){var r,a,l,s,n=await c.setting.getUnsavedDraftPath(),e=await u.readdir(n);e.length<200||(console.record("cleanUpExpiredDrafts"),400{var o=[],i=async function(){Math.min(l+50,a.length);if(l+1>=a.length)n(o);else{for(;l++;){if(!a[l])return void n(o);try{var e=r+"/"+a[l],t=await u.stat(e);864e6{try{return{name:e,time:W[e]||(await u.stat(n+"/"+e)).mtime.getTime()}}catch(e){}return{name:e,time:0}})),W=null,e.sort(function(e,t){return t.time-e.time}).forEach(function(e,t){150{D=!1}),c.on("quit",function(){console.log("-----------------quit------------------"),c.setting.closeLogging()}),c.on("will-quit",function(){console.log("------------------will-quit------------------"),h&&clearTimeout(h),I&&clearTimeout(I),f&&c.updater&&c.updater.installIfNeeded(),c.setting.syncAll();try{u.rmSync(c.getPath("userData")+"/runtime-storage",{recursive:!0,force:!0})}catch(e){console.error(e)}try{var e=c.getPath("userData")+"/typora.log",t=c.getPath("userData")+"/typora-old.log",n=u.statSync(e);n&&5e5p.getDocumentFromWindowId(n.id)):l()}).then(function(e){return e})}return l()},c.sendEvent=function(t,n){d.getAllWindows().forEach(function(e){e.webContents.send(t,n)}),c.onMessage(t,n)},c.execInAll=function(t){d.getAllWindows().forEach(function(e){e.webContents.executeJavaScript(t)})},c.onMessage=function(e,t){"didRename"==e?c.setting.renameRecentDocuments(t.oldPath,t.newPath):"updateQuickOpenCache"==e&&t.toDel&&c.setting.renameRecentDocuments(t.toDel,null)},c.refreshMenu=function(){w.refreshMenu()},{});n.handle("app.download",(e,t,n,o)=>{var i,r,a=s(541),l=d.fromWebContents(e.sender),e=s(554),o=o||(e=>{var t=s(426),n=s(541),t=t.parse(e),e=n.basename(t.pathname);try{var o=decodeURIComponent(e);if(o!=e)return n.basename(o)}catch(e){}return e})(t),a=a.join(n,o);return u.existsSync(a)&&(i=a,r=s(541),a=i.replace(/(\.[^.\/\\]+?$)/,"")+"-"+ +new Date+r.extname(i)),_[l.id+t]||(_[l.id+t]=e.download(l,t,{showBadge:!1,directory:n,filename:o})),setTimeout(()=>{delete _[l.id+t]},10),Promise.race([_[l.id+t].then(e=>({path:e.getSavePath(),state:e.getState(),type:e.getMimeType()}),()=>({path:t,state:"error"})),new Promise(e=>{setTimeout(()=>{e({path:t,state:"timeout"})},3e4)})])});var M=function(e){l.registerFileProtocol(e,function(e,t){e.url?t({path:c.getRealPath(e.url)}):t({error:-324})}),l.registerBufferProtocol("typora-bg",function(e,t){var n=c.setting.get("backgroundColor");t(n?{mimeType:"text/css",data:Buffer.from(`body {background:${n};`)}:{mimeType:"text/css",data:Buffer.from("")})})};c.getRealPath=function(e){try{e=decodeURI(e)}catch(e){}e=e.substr(13);return/^userData/.exec(e)&&(e=e.replace(/^userData/,c.getPath("userData").replace(/\\/g,"\\\\"))),/current-theme\.css$/.exec(e)&&(e=e.replace(/current-theme\.css$/,c.setting.curTheme())),/^typemark/i.exec(e)&&(e=e.replace(/^typemark/,t)),e=(e=/preview\.html/.exec(e)?e.replace(/\.html[?#].*$/,".html"):e).replace(/[?#][^\\\/]*$/,"")},c.filesOp=e,P&&l.registerSchemesAsPrivileged([{scheme:P,privileges:{standard:!0,secure:!0,supportFetchAPI:!0,bypassCSP:!0,corsEnabled:!0,stream:!0}}])},344:(t,n,h)=>{function r(e,t){return function(){k(e,t)}}var i,a=h(134),l=a.app,g=a.dialog,s=a.Menu,c=a.MenuItem,m=a.BrowserWindow,e=a.ipcMain,f=h(728),d="win32"==process.platform,w="darwin"==process.platform,b="linux"==process.platform,y=h(445),u=h(541).join(__dirname,"../"),v=(e.on("execForAll",function(e,t){v(t)}),e.on("forceRefreshMenu",function(e,t){l.forceRefreshMenu()}),e.on("syncToPreference",function(e,t){a.webContents.getAllWebContents().forEach(function(e){e.send("syncToPreference",t)})}),n.loadDict=()=>{var o,e;return i?Promise.resolve(i):(o=l.setting.getUserLocale(),e=h(541).join(u,l.setting.getLocaleFolder("Menu")),new Promise(n=>{f.readFile(e,"utf8",(e,t)=>{i=t?JSON.parse(t):{},n(i),e&&console.warn("cannot load dict as ["+o+"] "+e.stack)})}))},function(e){var t=e=e.toString();/^\s*function\s*\(/.exec(e)&&(t="window.File && ("+e+")();"),l.execInAll(t),console.log(t)}),k=function(e,t){var n=m.getFocusedWindow();n&&(t?n.webContents.executeJavaScript("window.File && !File.blockUI && ("+e.toString()+")();0;"):n.webContents.executeJavaScript("!File.blockUI && window.ClientCommand['"+e+"']();0;"),n.webContents.executeJavaScript("window.Reporter && window.Reporter.fullValidate();File.editor && File.editor.contextMenu && File.editor.contextMenu.hide();0;"))};function C(e){var t=/&[a-z]/i.exec(e),n=/(\.\.\.)|(…)/.exec(e),o=(e=e.replace(/(\.\.\.)|(…)|&/g,""),(i||{})[e]||e);return t?function(e,t){e=S[e];if(!e)return t;{var n,o;(d||b)&&(-1==(n=t.indexOf(e))?n=t.indexOf(e.toLowerCase()):-1<(o=t.indexOf(e.toLowerCase()))&&(n=Math.min(n,o)),-1{setTimeout(o,0)}))),e}function x(e,t){return p(e={label:e,accelerator:t}),e.accelerator}function D(e){function n(e,t){e=e.label;f.existsSync(e)?l.openFileOrFolder(e,{curWindow:t}):(g.showMessageBox({title:C("Open Failed"),message:C("File or folder does not exist."),buttons:["Close"],cancelId:0,defaultId:0}),l.setting.removeRecentDocument(e))}try{var o=e.getItem("File").submenu.getItem("Open Recent").submenu,t=l.setting.getRecentDocuments(),i=l.setting.getRecentFolders();t.sort(function(e,t){return t.date-e.date}),i.sort(function(e,t){return t.date-e.date}),o.clear(),o.append(new c({label:C("Reopen Closed File"),accelerator:"CmdOrCtrl+Shift+T",click:function(){l.reopenClosed()}})),o.append(new c({type:"separator"})),t.length&&(t.forEach(function(e,t){10{e.type&&(hasCustom=!0,o.push({label:e.name,click:t(e)}))}),o.push({type:"separator"}),o.push({label:"Export with Previous",accelerator:"Shift+Ctrl+E",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast();")},enabled:!!l.setting.lastExport}),o.push({label:"Export and Overwrite with Previous",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast(true)")},enabled:!!l.setting.lastExport}),o.push({type:"separator"}),o.push({label:"Export Setting…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('export-setting-group');")},enabled:!0}),e&&(o.forEach(p),n=P("File→Export").submenu,o[o.length-1].enabled=(I("Export and Overwrite with Previous",n)||{}).enabled,n.clear(),o.forEach(e=>{n.append(new c(e))}),w&&s.setApplicationMenu(s.getApplicationMenu())),o}function P(e){if(!e)return null;var t,n=(W=W||{})[e];return n||(e.split("→").forEach(function(e){if(n=I(e,n),!(W[t=t?t+"→"+e:e]=n))return null}),W=null,n)}function I(e,t){var n,o=t?t.submenu:s.getApplicationMenu();return o?(n=o.getItem(e),t||n||"File"!=e?n:o.getItem("Typora")||o.getItem("Electron")):null}var W,o=null;l.forceRefreshMenu=function(){b&&(o&&clearTimeout(o),o=setTimeout(function(){s.setApplicationMenu(s.getApplicationMenu()),o=null},100))};l.updateMenu=function(e){W={};for(var t in e){var n,o,i=P(t),r=e[t];i&&(n=null,void 0!==r.accelerator&&(r.accelerator,o=x(i.label,r.accelerator),i=n=o!=i.accelerator?new c(p({label:i.label,type:i.type,enabled:i.enabled,checked:i.enabled,click:i.click,accelerator:o})):n),"Paragraph→Table"!=t?(void 0!==r.state&&(i.checked=r.state),void 0!==r.enabled&&(i.enabled=r.enabled,"Paragraph"!=t&&"Format"!=t&&"Format→Image→Zoom Image"!=t||i.submenu.items.forEach(function(e){e.enabled=r.enabled})),void 0!==r.hidden&&(i.visible=!r.hidden),!n||-1<(t=(o=P(t.replace(/→[^→]+$/,"")).submenu.items).findIndex(e=>e.label==n.label))&&(o.splice(t,1,n),console.log("newItem.accelerator "+n.accelerator))):(function(e,n){n.enabled||n.state?(e.enabled=!0,e.submenu.items.forEach(function(e,t){e.enabled=0==t?!n.state:n.state})):e.enabled=!1}(i,r),0))}W=null,l.forceRefreshMenu()},e.on("menu.updateMenu",function(e,t){l.updateMenu(JSON.parse(t))}),e.handle("menu.updateCustomZoom",e=>{l.updateMenu({"View→Actual Size":{state:!l.setting.get("customZoom")}})}),e.handle("menu.refreshThemeMenu",function(e){l.setting.refreshThemeMenu()}),e.handle("menu.reloadExportMenu",function(e){T(!0)}),e.handle("menu.popup",function(e,t){s.getApplicationMenu().popup(t)}),n.bindMainMenu=function(){function e(e,t){e=(/\((.+)\)/.exec(e.label)||[])[1]||e.label;e==C("Auto")&&(e=""),k("function(){File.reloadWithEncoding('"+e+"')}",!0)}var t=l.setting.get("SmartyPantsOnRendering")||!1,n=l.setting.get("smartQuote")||!1,o=l.setting.get("smartDash")||!1,t=[p({label:"&File",submenu:[{label:"New",accelerator:"CmdOrCtrl+N",click:r("newFile")},{label:"New Window",accelerator:"CmdOrCtrl+Shift+N",click:r("newWindow")},{type:"separator"},{label:"Open…",accelerator:"CmdOrCtrl+O",click:r("open")},{label:"Open Folder…",click:r("openFolder")},{type:"separator"},{label:"Open Quickly…",accelerator:"CmdOrCtrl+P",click:r("quickOpen")},{label:"Open Recent",submenu:[]},{label:"Reopen with Encoding",submenu:[{label:"Auto",click:e},{type:"separator"},{label:"UTF-8",click:e},{label:"UTF-16 LE",click:e},{label:"UTF-16 BE",click:e},{type:"separator"},{label:"Western (windows-1252)",click:e},{label:"Cyrillic (windows-1251)",click:e},{label:"Cyrillic (ISO-8859-2)",click:e},{label:"Cyrillic (IBM866)",click:e},{label:"Cyrillic (IBM855)",click:e},{label:"Cyrillic (KOI8-R)",click:e},{label:"Cyrillic (MacCyrillic)",click:e},{label:"Central European (windows-1250)",click:e},{label:"Central European (ISO-8859-2)",click:e},{label:"Geek (windows-1253)",click:e},{label:"Geek (ISO-8859-7)",click:e},{label:"Hebrew (windows-1255)",click:e},{label:"Hebrew (ISO-8859-8)",click:e},{label:"Chinese Simplified (GB2312)",click:e},{label:"Chinese Simplified (GB18030)",click:e},{label:"Chinese Traditional (Big5)",click:e},{label:"Japanese (SHIFT_JIS)",click:e},{label:"Japanese (EUC-JP)",click:e},{label:"Korean (EUC-KR)",click:e},{label:"Thai (TIS-620)",click:e}]},{type:"separator"},{label:"Save",accelerator:"CmdOrCtrl+S",click:r("save")},{label:"Save As…",accelerator:"CmdOrCtrl+Shift+S",click:r("saveAs")},{label:"Move To…",click:r("moveTo")},{label:"Save All…",click:r("saveAll")},{type:"separator"},d?{label:"Properties…",click:function(e,t){t&&t.webContents.executeJavaScript("File.winShell().openProperties(File.bundle.filePath);")}}:null,{label:"Open File Location…",click:r("openFileLocation")},{label:"Reveal in Sidebar",click:r(function(){window.File.editor.library.revealInSidebar()},!0)},{label:"Delete…",click:function(e,t){t&&t.webContents.executeJavaScript("File.trashSelf();")}},{type:"separator"},{label:"Import…",click:r("import")},{label:"Export",submenu:T()},{label:"Print…",accelerator:"Shift+Alt+P",click:r("print")},{type:"separator"},{label:"Preferences…",accelerator:"CmdOrCtrl+,",click:r("togglePreferencePanel")},{type:"separator"},{label:"Close",accelerator:"CmdOrCtrl+W",click:r("close")}]}),p({label:"&Edit",id:"edit",submenu:[{label:"Undo",id:"undo",accelerator:"CmdOrCtrl+Z",click:r("undo")},{label:"Redo",id:"redo",accelerator:"CmdOrCtrl+Y",click:r("redo")},{type:"separator"},{label:"Cut",accelerator:"CmdOrCtrl+X",role:"cut"},{label:"Copy",accelerator:"CmdOrCtrl+C",role:"copy"},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Paste",accelerator:"CmdOrCtrl+V",role:"paste"},{type:"separator"},{label:"Copy as Plain Text",click:r("copyAsPlainText")},{label:"Copy as Markdown",accelerator:"CmdOrCtrl+Shift+C",click:r("copyAsMarkdown")},{label:"Copy as HTML Code",click:r("copyAsHTMLSource")},{label:"Copy without Theme Styling",click:r("copyAsSemanticHTML")},{type:"separator"},{label:"Paste as Plain Text",accelerator:"CmdOrCtrl+Shift+v",click:r("pasteAsPlain")},{type:"separator"},{label:"Selection",submenu:[{label:"Select All",accelerator:"CmdOrCtrl+A",click:r("selectAll")},{label:"Select Paragraph / Block",accelerator:"CmdOrCtrl+Alt+P",click:r(function(){File.editor.selection.selectBlock()},!0)},{label:"Select Line / Sentence",accelerator:"CmdOrCtrl+L",click:r(function(){File.editor.selection.selectLine()},!0)},{label:"Select Styled Scope",accelerator:"CmdOrCtrl+E",click:r(function(){File.editor.selection.selectPhrase()},!0)},{label:"Select Word",accelerator:"CmdOrCtrl+D",click:r(function(){File.editor.selection.selectWord()},!0)},{type:"separator"},{label:"Jump to Top",accelerator:"Ctrl+Home",click:r(function(){File.editor.selection.jumpTop()},!0)},{label:"Jump to Selection",accelerator:"CmdOrCtrl+j",click:r(function(){File.editor.selection.jumpSelection()},!0)},{label:"Jump to Bottom",accelerator:"Ctrl+End",click:r(function(){File.editor.selection.jumpBottom()},!0)},{label:"Extend Selection to Top",accelerator:"Ctrl+Shift+Home",visible:!1,click:r(function(){File.editor.selection.jumpTop(!0)},!0)},{label:"Extend Selection to Bottom",accelerator:"Ctrl+Shift+End",visible:!1,click:r(function(){File.editor.selection.jumpBottom(!0)},!0)},{label:"Extend Selection to Line Start",accelerator:"Shift+Home",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!1)},!0)},{label:"Extend Selection to Line End",accelerator:"Shift+End",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!0)},!0)}]},{type:"separator"},{label:"Delete",click:r(function(){File.delete()},!0)},{label:"Delete Range",submenu:[{label:"Delete Paragraph / Block",accelerator:"Shift+CmdOrCtrl+Alt+P",click:r("deleteBlock")},{label:"Delete Line / Sentence",accelerator:"Shift+CmdOrCtrl+Alt+L",click:r("deleteLine")},{label:"Delete Styled Scope",accelerator:"Shift+CmdOrCtrl+Alt+E",click:r("deleteScope")},{label:"Delete Word",accelerator:"Shift+Ctrl+D",click:r("deleteWord")}]},{type:"separator"},{label:"Math Tools",submenu:[{label:"Refresh All Math Expressions",click:r(function(){File.editor.mathBlock.forceRefresh()},!0)}]},{type:"separator"},{label:"Smart Punctuation",submenu:[{label:"Convert on Input",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+!e+")"))},checked:!t},{label:"Convert on Rendering",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+e+")"))},checked:t},{type:"separator"},{label:"Smart Quotes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartQuote("+e+")"))},checked:n},{label:"Smart Dashes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartDash("+e+")"))},checked:o},{type:"separator"},{label:"Remap Unicode Punctuation on Parse",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setRemapPunctuation("+e+")"))},checked:l.setting.get("remapPunctuation")||!t&&(n||o),enabled:!(!t&&(n||o))},{type:"separator"},{label:"More Options…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('smart-punctuation-group');")}}]},{label:"Line Endings",submenu:[{label:"Windows Line Endings (CRLF)",type:"checkbox",click:r(function(){File.setLineEnding(!0,!0)},!0)},{label:"Unix Line Endings (LF)",type:"checkbox",click:r(function(){File.setLineEnding(!1,!0)},!0)},{type:"separator"},{label:"Insert Final New Line On Save",type:"checkbox",click:function(e,t){t&&t.webContents.executeJavaScript("File.setFinalNewline("+e.checked+")")}}]},{label:"Whitespace and Line Breaks",submenu:[{label:"Indent first line of paragraphs",type:"checkbox",click:r(function(){File.setIndentFirstLine(!File.option.indentFirstLine,!0,!0)},!0)},{type:"separator"},{label:"Visible
",type:"checkbox",checked:!0,click:r(function(){File.setHideBrAndLineBreak(!File.option.hideBrAndLineBreak,!0,!0)},!0)},{label:"Preserve single line break",type:"checkbox",checked:!0,click:r(function(){File.setIgnoreLineBreak(!File.option.ignoreLineBreak,!0,!0)},!0)},{type:"separator"},{label:"Learn More…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/Line-Break/`)}}]},{label:"Spell Check…",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.spellChecker && File.editor.spellChecker.show();")}},{type:"separator"},{label:"Find and Replace",submenu:[{label:"Find…",accelerator:"CmdOrCtrl+f",click:r(function(){File.megaMenu.isPreferencePanelShown()?File.megaMenu.searchOnPreferencePanel():File.editor.searchPanel.showPanel()},!0)},{label:"Find Next",accelerator:"F3",click:r(function(){File.editor.searchPanel.highlightNext()},!0)},{label:"Find Previous",accelerator:"Shift+F3",click:r(function(){File.editor.searchPanel.highlightNext(!0)},!0)},{type:"separator"},{label:"Replace",accelerator:"Ctrl+h",click:r(function(){File.editor.searchPanel.showPanel(!0)},!0)}]}]}),p({label:"&Paragraph",submenu:[{label:"Heading 1",type:"checkbox",accelerator:"Ctrl+1",click:r(function(){File.editor.stylize.changeBlock("header1",void 0,!0)},!0)},{label:"Heading 2",type:"checkbox",accelerator:"Ctrl+2",click:r(function(){File.editor.stylize.changeBlock("header2",void 0,!0)},!0)},{label:"Heading 3",type:"checkbox",accelerator:"Ctrl+3",click:r(function(){File.editor.stylize.changeBlock("header3",void 0,!0)},!0)},{label:"Heading 4",type:"checkbox",accelerator:"Ctrl+4",click:r(function(){File.editor.stylize.changeBlock("header4",void 0,!0)},!0)},{label:"Heading 5",type:"checkbox",accelerator:"Ctrl+5",click:r(function(){File.editor.stylize.changeBlock("header5",void 0,!0)},!0)},{label:"Heading 6",type:"checkbox",accelerator:"Ctrl+6",click:r(function(){File.editor.stylize.changeBlock("header6",void 0,!0)},!0)},{type:"separator"},{label:"Paragraph",type:"checkbox",accelerator:"Ctrl+0",click:r(function(){File.editor.stylize.changeBlock("paragraph")},!0)},{type:"separator"},{label:"Increase Heading Level",accelerator:"Ctrl+=",click:r(function(){File.editor.stylize.increaseHeaderLevel()},!0)},{label:"Decrease Heading Level",accelerator:"Ctrl+-",click:r(function(){File.editor.stylize.decreaseHeaderLevel()},!0)},{type:"separator"},{label:"Table",submenu:[{label:"Insert Table",accelerator:"Ctrl+T",click:r(function(){File.editor.tableEdit.insertTable()},!0)},{type:"separator"},{label:"Add Row Above",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!0)},!0)},{label:"Add Row Below",accelerator:"Ctrl+Return",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!1)},!0)},{type:"separator"},{label:"Add Column Before",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{label:"Add Column After",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{type:"separator"},{label:"Move Row Up",enabled:!1,accelerator:"Alt+Up",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!0)},!0)},{label:"Move Row Down",enabled:!1,accelerator:"Alt+Down",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!1)},!0)},{label:"Move Column Left",enabled:!1,accelerator:"Alt+Left",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!0)},!0)},{label:"Move Column Right",enabled:!1,accelerator:"Alt+Right",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!1)},!0)},{type:"separator"},{label:"Delete Row",enabled:!1,accelerator:"Shift+Ctrl+Backspace",click:r(function(){File.editor.tableEdit.deleteRow()},!0)},{label:"Delete Column",enabled:!1,click:r(function(){File.editor.tableEdit.deleteCol()},!0)},{type:"separator"},{label:"Copy Table",enabled:!1,click:r(function(){File.editor.tableEdit.copyTable()},!0)},{label:"Prettify Source Code",enabled:!1,click:r(function(){File.editor.tableEdit.reformatTable()},!0)},{type:"separator"},{label:"Delete Table",enabled:!1,click:r(function(){File.editor.tableEdit.deleteTable()},!0)}]},{label:"Code Fences",type:"checkbox",accelerator:"Ctrl+Shift+K",click:r(function(){File.editor.stylize.toggleFences()},!0)},{label:"Math Block",type:"checkbox",accelerator:"Ctrl+Shift+M",click:r(function(){File.editor.stylize.toggleMathBlock()},!0)},{type:"separator"},{label:"Quote",type:"checkbox",accelerator:"Ctrl+Shift+Q",click:r(function(){File.editor.stylize.toggleIndent("blockquote")},!0)},{type:"separator"},{label:"Ordered List",type:"checkbox",accelerator:"Ctrl+Shift+[",click:r(function(){File.editor.stylize.toggleIndent("ol")},!0)},{label:"Unordered List",type:"checkbox",accelerator:"Ctrl+Shift+]",click:r(function(){File.editor.stylize.toggleIndent("ul")},!0)},{label:"Task List",type:"checkbox",accelerator:"Ctrl+Shift+X",click:r(function(){File.editor.stylize.toggleIndent("tasklist")},!0)},{label:"Task Status",submenu:[{label:"Toggle Task Status",click:r(function(){File.editor.stylize.toggleTaskStatus()},!0)},{type:"separator"},{label:"Mark as Complete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!0)},!0)},{label:"Mark as Incomplete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!1)},!0)}]},{label:"List Indentation",submenu:[{label:"Indent",accelerator:"CmdOrCtrl+]",click:r(function(){File.editor.UserOp.moreIndent(File.editor)},!0)},{label:"Outdent",accelerator:"CmdOrCtrl+[",click:r(function(){File.editor.UserOp.lessIndent(File.editor)},!0)}]},{type:"separator"},{label:"Insert Paragraph Before",click:r(function(){File.editor.UserOp.insertParagraph(!0)},!0)},{label:"Insert Paragraph After",click:r(function(){File.editor.UserOp.insertParagraph(!1)},!0)},{type:"separator"},{label:"Link Reference",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_link")},!0)},{label:"Footnotes",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_footnote")},!0)},{type:"separator"},{label:"Horizontal Line",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("hr")},!0)},{label:"Table of Contents",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("toc")},!0)},{label:"YAML Front Matter",type:"checkbox",click:r(function(){File.editor.stylize.insertMetaBlock()},!0)}]}),p({label:"F&ormat",submenu:[{label:"Strong",type:"checkbox",accelerator:"CmdOrCtrl+B",click:r(function(){File.editor.stylize.toggleStyle("strong")},!0)},{label:"Emphasis",type:"checkbox",accelerator:"CmdOrCtrl+I",click:r(function(){File.editor.stylize.toggleStyle("em")},!0)},{label:"Underline",type:"checkbox",accelerator:"CmdOrCtrl+U",click:r(function(){File.editor.stylize.toggleStyle("underline")},!0)},{label:"Code",type:"checkbox",accelerator:"CmdOrCtrl+Shift+`",click:r(function(){File.editor.stylize.toggleStyle("code")},!0)},{type:"separator"},{label:"Inline Math",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("inline_math")},!0)},{label:"Strike",type:"checkbox",accelerator:"Alt+Shift+5",click:r(function(){File.editor.stylize.toggleStyle("del")},!0)},{label:"Highlight",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("highlight")},!0)},{label:"Superscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("superscript")},!0)},{label:"Subscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("subscript")},!0)},{label:"Comment",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("comment")},!0)},{type:"separator"},{label:"Hyperlink",type:"checkbox",accelerator:"Ctrl+K",click:r(function(){File.editor.stylize.toggleStyle("link")},!0)},{label:"Hyperlink Actions",submenu:[{label:"Open Link",click:r(function(){File.editor.openCurrentLink()},!0)},{label:"Copy Link Address",click:r(function(){File.editor.copyCurrentLink()},!0)}]},{label:"Image",submenu:[{label:"Insert Image",accelerator:"CmdOrCtrl+Shift+I",click:r(function(){File.editor.stylize.toggleStyle("image")},!0)},{label:"Insert Local Images…",click:r(function(){File.editor.imgEdit.insertLocalImage()},!0)},{type:"separator"},{label:"Open Image Location…",click:r(function(){File.editor.imgEdit.revealInFinder()},!0)},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Zoom Image",submenu:[{label:"25%",click:r(function(){File.editor.imgEdit.zoomAction(null,"25%")},!0)},{label:"33%",click:r(function(){File.editor.imgEdit.zoomAction(null,"33%")},!0)},{label:"50%",click:r(function(){File.editor.imgEdit.zoomAction(null,"50%")},!0)},{label:"67%",click:r(function(){File.editor.imgEdit.zoomAction(null,"67%")},!0)},{label:"80%",click:r(function(){File.editor.imgEdit.zoomAction(null,"80%")},!0)},{type:"separator"},{label:"100%",click:r(function(){File.editor.imgEdit.zoomAction(null,"100%")},!0)},{type:"separator"},{label:"150%",click:r(function(){File.editor.imgEdit.zoomAction(null,"150%")},!0)},{label:"200%",click:r(function(){File.editor.imgEdit.zoomAction(null,"200%")},!0)}]},{label:"Switch Image Syntax",submenu:[{label:"Markdown Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!1)},!0)},{label:"HTML Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!0)},!0)}]},{type:"separator"},{label:"Delete Image File",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.deleteImageAction(true)")}},{type:"separator"},{label:"Copy Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction()},!0)},{label:"Rename or Move Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction(!0)},!0)},{label:"Upload Image",click:r(function(){File.editor.imgEdit.uploadAction()},!0)},{type:"separator"},{label:"Copy All Images to…",click:r(function(){File.editor.imgEdit.copyAllImages()},!0)},{label:"Move All Images to…",click:r(function(){File.editor.imgEdit.moveAllImages()},!0)},{label:"Upload All Local Images",click:r(function(){File.editor.imgEdit.uploadAllImages()},!0)},{type:"separator"},{label:"Reload All Images",click:r(function(){File.editor.imgEdit.reloadAllByNode()},!0)},{type:"separator"},{label:"When Insert Local Image",submenu:[{label:"Copy Image File to Folder…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleCopyToFolder()},!0)},{label:"Upload Image",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUploadForFile()},!0)}]},{label:"Use Image Root Path…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUseImageRootPath()},!0)},{type:"separator"},{label:"Global Image Settings…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('image-setting-group');")}}]},{type:"separator"},{label:"Clear Format",type:"checkbox",accelerator:"CmdOrCtrl+\\",click:r(function(){File.editor.stylize.clearStyle()},!0)}]}),p({label:"&View",submenu:[{label:"Toggle Sidebar",accelerator:"CmdOrCtrl+Shift+L",click:r(function(){File.editor.library.toggleSidebar()},!0)},{label:"Outline",type:"checkbox",accelerator:"CmdOrCtrl+Shift+1",click:r("toggleOutline")},{label:"Articles",type:"checkbox",accelerator:"CmdOrCtrl+Shift+2",click:r("toggleFileList")},{label:"File Tree",type:"checkbox",accelerator:"CmdOrCtrl+Shift+3",click:r("toggleFileTree")},{label:"Search",type:"checkbox",accelerator:"CmdOrCtrl+Shift+F",click:r("globalSearch")},{type:"separator"},{label:"Source Code Mode",type:"checkbox",accelerator:"CmdOrCtrl+/",click:r(function(){File.toggleSourceMode()},!0)},{type:"separator"},{label:"Focus Mode",type:"checkbox",accelerator:"F8",click:r(function(){File.editor.toggleFocusMode()},!0),enabled:!1},{label:"Typewriter Mode",type:"checkbox",accelerator:"F9",click:r(function(){File.editor.toggleTypeWriterMode()},!0),enabled:!1},{type:"separator"},{label:"Show Status Bar",type:"checkbox",click:r("toggleStatusBar")},{type:"separator"},{label:"Toggle Fullscreen",accelerator:"F11",click:function(e,t){t&&(t.isFullScreen()?t.setFullScreen(!1):t.setFullScreen(!0))}},{label:"Always on Top",type:"checkbox",click:function(e,t){t&&(k(function(){document.body.classList.toggle("always-on-top")},!0),t.setAlwaysOnTop(!t.isAlwaysOnTop()),e.checked=t.isAlwaysOnTop())}},{type:"separator"},{label:"Actual Size",type:"checkbox",accelerator:d?"Ctrl+Shift+9":"Ctrl+Shift+0",click:function(e,t){v(function(){ClientCommand.resetZoom()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom In",accelerator:"Ctrl+Shift+=",click:function(e,t){v(function(){ClientCommand.zoomIn()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom Out",accelerator:"Ctrl+Shift+-",click:function(e,t){v(function(){ClientCommand.zoomOut()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{type:"separator"},{label:"Switch Between Opened Documents",accelerator:"Ctrl+Tab",click:function(e,t){var n;!t||-1!=(t=(n=m.getAllWindows()).indexOf(t))&&n[t=++t>=n.length?0:t].focus()}},{type:"separator"},{label:"Toggle DevTools",accelerator:"Shift+F12",click:function(e,t){var n;t&&(n=setTimeout(t.webContents.openDevTools,2e3),t.webContents.executeJavaScript("ClientCommand.toggleDevTools()").then(function(){clearTimeout(n)},function(){clearTimeout(n),t.webContents.openDevTools()}))}}]}),p({label:"&Themes",submenu:[]}),p({label:"&Help",submenu:[{label:"What's New…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/What's-New/`)}},{type:"separator"},{label:"Quick Start",click:function(e,t){l.openFile(u+"/Docs/Quick Start.md")}},{label:"Markdown Reference",click:function(e,t){l.openFile(u+"/Docs/Markdown Reference.md")}},{label:"Install and Use Pandoc",click:function(e,t){l.openFile(u+"/Docs/Install and Use Pandoc.md")}},{label:"Custom Themes",click:function(e,t){l.openFile(u+"/Docs/Custom Themes.md")}},{label:"Use Images in Typora",click:function(e,t){l.openFile(u+"/Docs/Use Images in Typora.md")}},{label:"Data Recovery and Version Control",click:function(e,t){l.openFile(u+"/Docs/Auto Save, Version Control and Recovery.md")}},{label:"More Topics…",click:function(e,t){var n=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal("https://support."+n)}},{type:"separator"},{label:"Credits",click:function(e,t){l.openFile(u+"/Docs/Credits.md")}},{label:"Change Log",click:function(e,t){l.openFile(u+"/Docs/Change Log.md")}},{label:"Privacy Policy",click:function(e,t){l.openFile(u+"/Docs/Privacy Policy.md")}},{label:"Website",click:function(){var e=l.setting.get("useMirrorInCN")?"https://typoraio.cn":"https://typora.io";a.shell.openExternal(e)}},{label:"Feedback",click:function(e,t){a.shell.openExternal("mailto:hi@typora.io")}},{type:"separator"},{label:"Check Updates…",click:function(){d&&l.updater.checkForUpdates(!0)},visible:d},{label:"My License…",click:function(){y.showLicensePanel()}},global.PRODUCTION_MODE?null:{label:"Welcome…",click:function(){y.showWelcomePanel()}},{label:"About",click:r(function(){File.megaMenu.closePreferencePanel(),document.body.classList.contains("native-window")?($(".modal:not(.block-modal)").modal("hide"),$("#about-dialog").modal("show"),$("*:focus").blur()):(File.megaMenu.show(),$("#m-about").trigger("click"))},!0)}]})];d||t[0].submenu.splice(t[0].submenu.indexOf(null),1),l.isEmojiPanelSupported()&&(t[1].submenu.push({type:"separator"}),t[1].submenu.push(p({label:"Emoji and Symbols",accelerator:d?"Super+.":"",click:function(){l.showEmojiPanel()}})));const i=t[t.length-1].submenu;for(;-1{"use strict";var a=c(93).EventEmitter,n=c(134),t=n.ipcMain,d=n.app,r=c(728),l="linux"==process.platform,s=c(541).join(__dirname,"../"),g=c(445),u=c(156),m=c(359).default,f=c(477),w=c(824),b=c(587),p=new a,o=["Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2"],h="64";"ia32"==process.arch&&(h="32"),"arm64"==process.arch&&(h="arm"),p.initUpdater=function(){return u.initDict().then(function(){return o.forEach(function(e,t){o[t]=u.getPanelString(e)}),Promise.resolve()})},p.showDetailWindow=function(e,t,n){p.progressBar&&(p.progressBar.close(),p.progressBar=null),p.win&&(p.win.destroy(),p.win=null);e=b.showPanelWindow({title:u.getPanelString("Updater"),width:640,height:600,path:"updater/updater.html?curVersion=$1&newVersion=$2&labels=$3&enableAutoUpdate=$4&releaseNoteLink=$5&hideAutoUpdates=$6".replace("$1",e).replace("$2",t).replace("$3",encodeURIComponent(JSON.stringify(o))).replace("$4",JSON.stringify(!1!==d.setting.get("enableAutoUpdate"))).replace("$5",encodeURIComponent(n)).replace("$6",global.devVersion&&!g.getHasLicense())});(p.win=e).on("closed",function(){p.win=null})},p.showUI=function(){p.win||p.progressBar||(p.progressBar=new f({title:u.getPanelString("Updater"),text:u.getPanelString("Checking Updates…"),indeterminate:!0,style:{text:{padding:"3px 0"}},browserWindow:{closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}}))};p.checkForUpdates=async function(t){var e,n,o,i=d.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",i=global.devVersion||d.setting.get("autoUpdateToDev")?`https://${i}/releases/dev_windows_${h}.json`:`https://${i}/releases/windows_${h}.json`;if(i){if(p.emit("checking-for-update"),t)p.showUI();else if((e=d.setting.get("cancelUpdate"))&&new Date-new Date(e)<432e5)return;try{var r=await m(i);if(204==r.status)return void p.emit("update-not-available");if(200!=r.status)return p.emit("update-not-available"),console.error("invalid status code: "+r.statusCode+" from "+i),"Failed to check updates, invalid status code: "+r.status;var a=await r.json(),l=(n=a,o=c(842).release().replace(/\.[^.]+$/,""),a=(o=(n.alternatives||{})[o])?Object.assign(n,o):n,p.data=a,d.getVersion());if(!a.version||!l)return;if(!(0{e||(console.log(t),p.installPathOnQuit=t,d.quit())})},p.installIfNeeded=function(){p.installPathOnQuit&&p.install(p.installPathOnQuit)},p.install=function(e){c(620).spawn(e,["/SILENT"],{detached:!0,stdio:["ignore","ignore","ignore"]}).unref()},t.handle("updater.checkForUpdates",(e,t)=>{p.checkForUpdates(t)}),t.handle("updater.cancelUpdate",e=>{p.cancelUpdate()}),t.handle("updater.skipUpdate",e=>{p.skipUpdate()}),t.handle("updater.downloadUpdate",e=>{p.downloadUpdate()}),e.exports=p},620:e=>{"use strict";e.exports=require("child_process")},289:e=>{"use strict";e.exports=require("crypto")},134:e=>{"use strict";e.exports=require("electron")},554:e=>{"use strict";e.exports=require("electron-dl")},359:e=>{"use strict";e.exports=require("electron-fetch")},477:e=>{"use strict";e.exports=require("electron-progressbar")},93:e=>{"use strict";e.exports=require("events")},834:e=>{"use strict";e.exports=require("extract-zip")},833:e=>{"use strict";e.exports=require("fs")},728:e=>{"use strict";e.exports=require("fs-extra")},232:e=>{"use strict";e.exports=require("fs-plus")},338:e=>{"use strict";e.exports=require("hjson")},783:e=>{"use strict";e.exports=require("lowdb")},207:e=>{"use strict";e.exports=require("lowdb/adapters/FileSync")},640:e=>{"use strict";e.exports=require("module")},560:e=>{"use strict";e.exports=require("node-machine-id")},842:e=>{"use strict";e.exports=require("os")},541:e=>{"use strict";e.exports=require("path")},208:e=>{"use strict";e.exports=require("process")},468:e=>{"use strict";e.exports=require("raven")},426:e=>{"use strict";e.exports=require("url")},266:e=>{"use strict";e.exports=require("util")}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;t=o[e]={id:e,loaded:!1,exports:{}};return n[e](t,t.exports,i),t.loaded=!0,t.exports}i.c=o,i.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);i(i.s=90)})(); \ No newline at end of file +(()=>{var n={883:(t,n,a)=>{var s=a(134),c=s.app,e=s.ipcMain,d=s.BrowserWindow,u="win32"==process.platform,p="linux"==process.platform,r=a(156),i=a(344);n.bindJumplist=()=>{var t;u&&(t=[{type:"custom",name:"Recent Locations",items:c.setting.getRecentFolders().slice(0,5).map(function(e){return{type:"task",title:e.name,description:e.path,program:process.execPath,args:JSON.stringify(e.path),iconPath:"explorer.exe",iconIndex:0}})},{type:"recent"},{type:"tasks",items:[{type:"task",program:process.execPath,arguments:"--new",iconPath:process.execPath,iconIndex:0,title:"New"}]}],c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t),i.loadDict().then(e=>{t[0].name=e["Recent Locations"]||"Recent Locations",t[2].items[0].title=e.New||"New",c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t)}))},e.handle("shell.saveItem",(e,{path:n,data:o})=>new Promise(t=>{a(833).writeFile(n,o,function(e){t()})})),e.handle("shell.openItem",(e,t)=>s.shell.openPath(a(541).normalize(t))),e.handle("shell.trashItem",async(e,t)=>{try{return await s.shell.trashItem(t),!0}catch(e){return!1}}),e.handle("shell.openExternal",(e,t)=>{if("about:blank"!=t)return s.shell.openExternal(t)}),e.handle("shell.showItemInFolder",(e,t)=>(u&&(t=t.replace(/\//g,"\\")),s.shell.showItemInFolder(t))),e.handle("shell.showDownload",(e,t)=>{e=d.fromWebContents(e.sender);const n=a(554)["download"];n(e,t,{saveAs:!0})}),e.handle("dialog.showMessageBox",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showMessageBox(p?null:e,t)}),e.handle("dialog.showSaveDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showSaveDialog(p?null:e,t)}),e.handle("dialog.showOpenDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showOpenDialog(p?null:e,t)}),e.handle("dialog.showOpenDialogAlone",(e,t)=>s.dialog.showOpenDialog(t));const h=t=>new Promise(e=>{setTimeout(()=>{e("sleep")},t)}),m=async(e,t)=>{var n=new d({skipTaskbar:!0,title:"Print PDF Preview",show:!1,webPreferences:{webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!1,nodeIntegration:!1,safeDialogs:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,zoomFactor:+(c.setting.get("zoomFactor")||"1"),backgroundThrottling:!1}});try{var o,i,r=t?(console.log("load file ["+t+"] for PDF export"),n.loadFile(t)):(o=a(541).join(c.setting.tempPath||c.getPath("temp"),+new Date+"tmp.html"),i=a(728),console.log("write output to temp file ["+o+"] for PDF export"),await i.outputFile(o,e),n.loadFile(o))}catch(e){return console.error(e),n&&n.destroy(),null}return Promise.race([h(2e4),r]).then(e=>"sleep"===e?(l(n.id),console.warn("Timeout for loading print view"),null):n.id).catch(e=>(console.error(e),n&&n.destroy(),null))},l=(e.handle("export.genPrintView",(e,t,n)=>(n&&l(n),m(null,t))),e=>{e=d.fromId(e);e&&(e.isDestroyed()||e.destroy())});e.handle("export.destroyPrintView",(e,t)=>{l(t)}),e.handle("export.getPageColor",async(e,t)=>{try{var n=await m(null,t);if(console.log("generate print preview window with id "+n),!n)return null;printWin=d.fromId(n),await h(200);var o=await printWin.webContents.executeJavaScript("window.getComputedStyle(document.body).backgroundColor")}catch(e){console.error(e)}finally{printWin&&printWin.destroy()}return o}),e.handle("export.print",(e,n,o)=>{var i=d.fromId(n);o=o||{},i.webContents.print(o,(e,t)=>{if(!e&&!/cancel/.exec(t||"")){if("no valid printers available"===t)return void i.webContents.executeJavaScript("window.print()").then(()=>{o.skipCleanUp||l(n)});s.dialog.showMessageBox({type:"error",message:r.getPanelString("Error"),detail:t,buttons:["OK"]})}o.skipCleanUp||l(n)})}),e.handle("export.printToPDF",async(e,t,n)=>{let o=null,i=null,r=null,a="";try{var l=await m(null,t);if(console.log("generate print window with id "+l),!l)return[i,r];o=d.fromId(l),await h(200),i=await o.webContents.printToPDF(n),console.log("get PDF data");var s=`(${function(){var e=document.querySelector("#write");return e?{color:(e=window.getComputedStyle(e)).color,fontFamily:e.fontFamily,bgColor:e.backgroundColor}:null}.toString()})()`;r=(r=await o.webContents.executeJavaScript(s))&&JSON.stringify(r),console.log("get background color")}catch(e){a=e.message||"",console.error(e)}finally{o&&o.destroy()}return[i,r,a]});var f,o,g=u?8e3:960,w=1;function b(){console.log("updateTheme");var e=c.setting.curTheme(),t=(c.execInAll("window.ClientCommand && File.setTheme('"+e+"');"),e.replace(/\.css$/,"").replace(/(^|-|_)(\w)/g,function(e,t,n,o){return(t?" ":"")+n.toUpperCase()})),e=s.Menu.getApplicationMenu().getItem("Themes");e&&e.submenu.items.map(function(e){e.checked=e.label==t})}e.handle("export.prepareImageCapture",async(e,t,n)=>{var o,i=s.screen.getPrimaryDisplay();try{w=i.scaleFactor||1;var r=i.workArea;if(g=Math.min(g,r.height-20),f=n.imageWidth,await(o=new d({skipTaskbar:!0,show:!1,webPreferences:{devTools:!1,webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!0,nodeIntegration:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,safeDialogs:!0},webgl:!1,useContentSize:!0,x:r.x,y:r.y,width:n.imageWidth,height:g,frame:!1,enableLargerThanScreen:!!u,offscreen:!0,alwaysOnTop:!0,minimizable:!1,closable:!0})).loadURL("file:///"+t),o.isDestroyed())return null;if(await h(2e3),o.isDestroyed())return null;var a=+await o.webContents.executeJavaScript("window.innerHeight");if(o.isDestroyed())return null;var l=+await o.webContents.executeJavaScript("document.body.parentElement.scrollTop = document.body.clientHeight;\nMath.max(document.body.clientHeight, document.body.parentElement.scrollHeight)");return o.isDestroyed()?null:Number.isNaN(l)||Number.isNaN(a)?void 0:(p&&(g=a),{winId:o.id,totalHeight:l,pageHeight:g,imageWidth:n.imageWidth,scale:3===n.quality?w:1})}catch(e){return console.error(e),null==o||o.isDestroyed()||o.destroy(),null}}),e.handle("export.captureImage",async(e,t,n,o)=>{t=d.fromId(t);if(!t||t.isDestroyed())return null;try{o&&(t.setSize(o.imageWidth,o.pageHeight),t.setContentSize(o.imageWidth,o.pageHeight));var i=+await t.webContents.executeJavaScript("document.body.parentElement.scrollTop = {d}; document.body.parentElement.scrollHeight;".replace("{d}",n));if(await h(1e3),t.isDestroyed()||Number.isNaN(i))return null;var r=await t.webContents.capturePage();if(!r||r.isEmpty())return null;var a=null;return 1new Promise((t,e)=>{try{var n=s.net.request({url:o,redirect:"follow"});n.on("response",function(e){try{if(200!=e.statusCode)return t(null);if(!e.data)return t(null);t({type:(e.headers["content-type"]||[""])[0],data:e.data})}catch(e){t(null)}}),n.end()}catch(e){t(null)}})),e.handle("clipboard.write",(e,t,n)=>{n&&s.clipboard.clear(),s.clipboard.write(JSON.parse(t))}),e.handle("pandoc.import",(e,n)=>{var o={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"'":"\\'","\\":"\\\\"},e=d.fromWebContents(e.sender),t=n?Promise.resolve(e):c.openFile(null,{syncAndPrepOnly:!0}).then(n=>new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e(n.activeWindow)}):e(n.activeWindow)})),e=s.dialog.showOpenDialog(n?e:null,{title:i.getMenuDict.Import,properties:["openFile"],filters:[{name:r.getPanelString("All Supported Formats"),extensions:["docx","rtf","latex","tex","ltx","rst","rest","org","wiki","dokuwiki","mediawiki","textile","opml","epub"]},{name:"MS Word",extensions:["docx"]},{name:"RTF",extensions:["rtf"]},{name:"TeX/LaTeX",extensions:["latex","tex","ltx"]},{name:"reStructuredText",extensions:["rst","rest"]},{name:"org-mode",extensions:["org"]},{name:"Wiki",extensions:["wiki","dokuwiki","mediawiki"]},{name:"Epub",extensions:["epub"]},{name:"Textile",extensions:["textile"]},{name:"OPML",extensions:["opml"]}]}).then(({filePaths:e})=>(e||[null])[0]);return Promise.all([t,e]).then(async([e,t])=>{t?(await h(100),e.show(),e.webContents.executeJavaScript('window.getSelection().removeAllRanges();ClientCommand.doImport("'+t.replace(/["'\\\b\t\n\f\r]/g,function(e){return o[e]}).replace(/\u200b/g,"")+'")')):n||e.destroy()})}),e.handle("pandoc.version",()=>o),e.handle("pandoc.setVersion",(e,t)=>{o=t}),s.nativeTheme.on("updated",function(){null!==c.setting.useDarkThemeBefore()&&c.setting.useDarkThemeBefore()!==c.setting.useDarkTheme()&&b()}),e.handle("theme.apply",()=>{b()}),e.handle("theme.setThemeSource",(e,t)=>{"system"!==(t=t||"system")&&c.setting.get("useSeparateDarkTheme")||(s.nativeTheme.themeSource=t)}),e.on("ondragstart",function(t,n,o){setTimeout(function(){var e=s.nativeImage;t.sender.startDrag({file:n,icon:o?e.createFromPath(a(541).normalize(o)):e.createEmpty()}),console.log("ondragstart "+n+" "+o)},100)}),e.handle("getPath",(e,t)=>c.getPath(t))},156:(e,t,n)=>{var o=n(134).app,i=n(728),r=n(541).join(__dirname,"../"),a=["Operation Failed","Save As","All Supported Formats","Error","Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2","Updater","Checking Updates…","Downloading Updates…","You're up to date!","Check Update Failed","Download failed","Install Updates ?","Quit and Install","Cancel","Download","Downloading…","Extracting binary…","This dev version of Typora is expired, please download and install a newer version.","This device has been deactivated","Typora is now deactivated","UNREGISTERED"],l={},s=!1;e.exports={initDict:function(){if(s)return Promise.resolve();var e=n(541).join(r,o.setting.getLocaleFolder("Panel"));return i.readJSON(e,"utf8").then(function(t){s=!0,a.map(function(e){l[e]=t[e]||e})}).catch(function(){})},getPanelString:function(e){return l[e]||e}}},351:(r,l,c)=>{function d(e,t){this.activeWindow=t||null,this.windows=new Set(t),this.path=e||null,this.snap=null,this.lastSync,this.content,this.backupState=null}var e=c(134),u=e.app,a=e.BrowserWindow,s=(e.powerMonitor,c(728)),e=c(232),h=(c(266),process.platform,process.platform,"linux"==process.platform),g=c(468),m=c(587),t=c(134).ipcMain,o=(t.on("doc.syncChange",function(e,t){var n=a.fromWebContents(e.sender),o=u.documentController.getDocumentFromWindowId(n.id);n==o.activeWindow&&1=n}catch(e){console.warn(e)}return!1}},d.prototype.getWindowToFocus=function(){var e=this.activeWindow||this.windows.keys().next().value;if(e){if(!e.isDestroyed())return e;this.activeWindow=null,this.windows.delete(e)}return null},d.prototype.syncFullContent=function(t){var e,n=!1;if(this.windows.forEach(function(e){this.activeWindow!=e&&!n&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&(n=!0)}),n)return e=this.windows,this.activeWindow.webContents.executeJavaScript("File.sync(false, true);1;").then(function(){e.forEach(function(e){this.activeWindow!=e&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&e.webContents.executeJavaScript("File.editor.applyFullContent("+!!t+")")})}),null},d.prototype.popBackupState=async function(){var e=this.backupState;return this.backupState=void 0,Promise,e},function(e){return c(541).basename(e)}),f=e.isCaseInsensitive();function p(e){return f?e&&e.toLowerCase():e}function n(){this.documents=new Set,this.path2doc=new Map,this.win2doc=new Map,this.name2docs=new Map,this.frozenDocs=[],this.watchSystemPause()}n.prototype.watchSystemPause=function(){u.whenReady().then(()=>{})},n.prototype.setContentForWindow=function(e,t){var n=this.getDocumentFromWindowId(t);(n.activeWindow||{}).id==t&&n.setContent(e)},n.prototype.solveDuplicateName_=function(e){var t=e.path,t=p(o(t)),n=this.name2docs.get(t)||new Set;this.name2docs.set(t,n),0{e=a.fromWebContents(e.sender),t=t?u.getDocumentController().getDocument(t):u.documentController.getDocumentFromWindowId(e.id);t&&t.activeWindow==e&&t&&t.switchToUntitled(n)}),t.handle("document.setLastSync",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).setLastSync(t)}),t.handle("document.syncFullContent",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).syncFullContent(t)}),t.handle("document.getContent",e=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).getContent()}),t.handle("document.currentPath",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).path});const b=async e=>{var t=e.getSnap(null),n=e.path,o=!1,i=null;return(t||{}).nodeMap?o=await e.shouldReadFromDisk():i=await e.popBackupState(),i&&i.hasUnsaved?console.log("load from recover content length: "+i.content.length):i=null,JSON.stringify({snap:t,filePath:n,backups:i,shouldReadFromDisk:o,windowCounts:e.windows.size})};t.handle("document.loadData",async e=>{console.log("handle document.loadData");new Date;e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),e=await b(e);return new Date,e}),t.handle("document.switchDocument",async(e,t)=>{e=a.fromWebContents(e.sender),e=await u.getDocumentController().switchDocument(e.id,t);return b(e)}),t.handle("document.rename",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).rename(t),!0}),t.handle("document.setContent",(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=e.content==t;return e.setContent(t),n}),t.handle("document.addSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return t?e.addSnap(JSON.parse(t)):e.addSnap(null),!0}),t.handle("document.addSnapAndLastSync",(e,t)=>{try{var n,o,i=a.fromWebContents(e.sender),r=u.documentController.getDocumentFromWindowId(i.id);t?({snap:n,lastSync:o}=JSON.parse(t),r.addSnap(n),r.setLastSync(o)):r.addSnap(null)}catch(e){console.error(e)}return!0}),t.handle("document.shouldSaveSnap",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).shouldSaveSnap()}),t.handle("document.getSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return JSON.stringify(e.getSnap(t))}),t.handle("document.getSnapWithValidation",async(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=await e.isSnapValid();return JSON.stringify({snap:e.getSnap(t),shouldReadFromDisk:0==n})}),t.handle("document.enterOversize",e=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);e&&e.enterOversize()}),t.handle("document.newWindow",e=>{3==u.setting.get("restoreWhenLaunch")?u.openFile(null,{mountFolder:u.setting.get("pinFolder"),silent:"pinFolder"}):u.openFile()}),t.handle("document.checkIfMoveOnSave",(e,t)=>{var e=a.fromWebContents(e.sender),n=u.documentController.getDocument(t);return!n&&((n=u.documentController.getDocumentFromWindowId(e.id)).rename(t),!0)}),t.handle("document.hasDuplicateName",(e,t)=>u.documentController.hasDuplicateName(t)),t.handle("document.noOtherWindow",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).windows.size<=1});var i=new n;r.exports=i},824:(e,t,s)=>{var c=s(728),d=s(541),u={title:"Download",text:"Downloading…",indeterminate:!1,initialValue:0,maxValue:1,closeOnComplete:!1,abortOnError:!1,style:{text:{padding:"3px 0"}},browserWindow:{modal:!1,closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}};function p(e){if(e<1024)return e+" B";var t=e/Math.pow(1024,1),e=e/Math.pow(1024,2);return e<1?(t+"").replace(/(\..)(.+)$/,"$1")+"KB":(e+"").replace(/(\..)(.+)$/,"$1")+"MB"}function n(e,t,n){this.onAbort=null,this.onSuccess=null,this.onError=null,this.downloadURL=e,this.dist=t,this.displayOption=n||{},this.progressBar=null,this.downloadItem=null}n.prototype.cancel=function(){if(this.downloadItem){try{this.downloadItem.cancel()}catch(e){}this.downloadItem=null}this.setCompleted(),this.onAbort&&this.onAbort()},n.prototype.setCompleted=function(){this.downloadItem=null,this.progressBar&&(this.progressBar.setCompleted(),this.progressBar.close(),this.progressBar=null)},n.prototype.download=function(){var e=s(477),t=s(554),n=this,o=this.downloadURL,i=this.dist,r=this.displayOption,a=new e(Object.assign({},u,r)),l=((this.progressBar=a).on("aborted",function(){n.cancel()}),d.dirname(i));Promise.all([new Promise(function(e){a.on("ready",e)}),c.ensureDir(l)]).then(function(){console.record("[downloader] downloading "+o,"DEBUG"),t.download(a._window,o,{showBadge:r.showBadge||!1,directory:l,filename:d.basename(i),onProgress:function(e){a&&(a.value=e.percent*(r.processOnComplete||1),a.detail=p(e.transferredBytes)+" / "+p(e.totalBytes))},onStarted:function(e){console.log("start downloading "+e.getURL()),n.downloadItem=e},onCancel:function(){console.log("canceled downloading "+downloadItem.getURL()),n.cancel()}}).then(function(e){n.onSuccess(e,a)}).catch(function(e){console.log("error downloading "+(n.downloadItem&&n.downloadItem.getURL())),n.onError(e)})})},e.exports=n},405:(e,t,n)=>{var n=n(134),o=n.app,n=n.ipcMain,i=global.t_workingDir,r=o.getVersion(),a=(/-([a-z]+)/.exec(r)||[])[1],l=r;function s(e,t){var n,o,i;for(e=(e||"").replace(/-[a-z]+/,""),t=(t||"").replace(/-[a-z]+/,""),e=e.split("."),t=t.split("."),o=Math.min(e.length,t.length),n=0;n({PRODUCTION_MODE:global.PRODUCTION_MODE,DEBUG_MODE:global.DEBUG_MODE,version:o.getVersion(),devVersion:global.devVersion})),global.compareVersion=s,global.t_workingDir=i,global.PRODUCTION_MODE=!0,global.DEBUG_MODE=!1},932:(e,t,n)=>{function o(){this.clearUndo()}function i(e){r.dialog.showErrorBox(l.getPanelString("Operation Failed"),e.message)}var r=n(134),a=r.app,l=n(156),s=n(728),n=r.ipcMain,c=(o.prototype.hasUndo=function(e){return!(!this.hasUndo_||!e)&&(0==(this.undoTo_||"").indexOf(e)||0==(this.undoFrom_||"").indexOf(e))},o.prototype.undoLabel=function(){return this.undoLabel_},o.prototype.clearUndo=function(){this.undoFrom_="",this.undoTo_="",this.undoLabel_="",this.hasUndo_=!1},o.prototype.registerUndo=function(e,t,n){this.undoFrom_=e,this.undoTo_=t,this.undoLabel_=n,this.hasUndo_=!0},o.prototype.getFocusPath=function(){return this.hasUndo_&&this.undoTo_},o.prototype.performUndo=function(){var t;function n(){r.dialog.showMessageBox({type:"warning",message:l.getPanelString("Operation Failed"),defaultId:0,cancelId:1,buttons:[l.getPanelString("Save As"),l.getPanelString("Cancel")]}).then(({response:e})=>{0==e?r.dialog.showSaveDialog({defaultPath:t.undoTo_,properties:["showOverwriteConfirmation"]}).then(({filePath:e})=>{e&&e!=t.undoFrom_&&s.rename(t.undoFrom_,e,function(e){e&&i(e)}),t.clearUndo()}):t.clearUndo()})}this.hasUndo_&&(this.hasUndo_=!1,(t=this).undoTo_?s.existsSync(this.undoTo_)?n():(a.sendEvent("willRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),s.copyFile(this.undoFrom_,this.undoTo_,function(e){s.unlink(t.undoFrom_,function(){}),e?(n(),a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoFrom_})):(a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),t.clearUndo())})):s.remove(this.undoFrom_,function(e){e?i(e):(t.clearUndo(),a.sendEvent("updateQuickOpenCache",{toDel:this.undoFrom_}))}))},new o);n.handle("filesOp.registerUndo",(e,t,n,o)=>{c.registerUndo(t,n,o)}),n.handle("filesOp.clearUndo",e=>{c.clearUndo()}),n.handle("filesOp.performUndo",e=>{c.performUndo()}),n.handle("filesOp.getFocusPath",e=>c.getFocusPath()),n.handle("filesOp.undoLabel",(e,t)=>c.hasUndo(t)?c.undoLabel():null),t.default=c},445:(o,u,i)=>{i(405);var p,h=i(156),g=i(134),m=g.shell,l=g.app,e=g.ipcMain,f=g.BrowserWindow,w="win32"==process.platform,b="darwin"==process.platform,y="linux"==process.platform,v=i(587),k=i(359).default,s=i(468),C=!1;const F=function(e){try{return require(e)}catch(e){if(C)return;C=!0;var t=e.message;setTimeout(()=>{C=!1,(dialog=i(134).dialog).showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:"A required module cannot be loaded by Typora",message:t.split("\n")[0]+"\n\nPlease check if that file exists or reinstall Typora to fix."}).then(({})=>{process.exit(1)})},1500)}};var S,r=null,x="",c="",a="",D="";const T={SUCCESS:0,OUT_OF_LIMIT:1,INVALIDATE:-1,WRONG_USER:-2},P=JSON.parse(Buffer.from("WyItLS0tLUJFR0lOIFBVQkxJQyBLRVktLS0tLSIsIk1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBN25Wb0dDSHFJTUp5cWdBTEVVcmMiLCI1SkpoYXAwK0h0SnF6UEUwNHB6NHkrbnJPbVk3LzEyZjNIdlp5eW9Sc3hLZFhUWmJPMHdFSEZJaDBjUnFzdWFKIiwiUHlhT09QYkEwQnNhbG9mSUFZM21SaFFRM3ZTZitybjNnK3cwUyt1ZFdtS1Y5RG5tSmxwV3FpekZhalU0VC9FNCIsIjVaZ01OY1h0M0UxaXBzMzJyZGJUUjBObmVuOVBWSVR2cmJKM2w2Q0kyQkZCSW1aUVoyUDhOK0xzcWZKc3F5VlYiLCJ3RGt0M21IQVZ4VjdGWmJmWVdHKzhGRFN1S1FIYUNtdmdBdENoeDlod2wzSjZSZWtrcURWYTZHSVYxM0QyM0xTIiwicWRrMEpiNTIxd0ZKaS9WNlFBSzZTTEJpYnk1Z1lONnpRUTVSUXBqWHRSNTNNd3pUZGlBekdFdUtkT3RyWTJNZSIsIkR3SURBUUFCIiwiLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tIiwiIiwiIl0=","base64").toString("utf8")).join("\n"),I=864e5;var W="https://store.typora.io";const E=e=>{if(!e)return e;var t;try{t=Buffer.from(e,"base64");const n=i(289).publicDecrypt(P,t);return JSON.parse(n.toString("utf8"))}catch(e){return null}},O=function(){var e=Array.from(arguments);const t=i(289).createHash("sha256");return e.forEach(e=>{t.update(e)}),t.digest("base64")},_=()=>{const e=d().get("SLicense");if(!e)return null;var[t,n,o]=e.split("#"),t=E(t);return t&&t.fingerprint==a?(Object.assign(t,{failCounts:n,lastRetry:new Date(o)}),t):null},M=async e=>{console.log("writeInstallDate fromBTime="+e);var t=new Date;if(e)try{var n=await i(728).stat(l.getPath("userData")+"/profile.data"),t=new Date(n.birthtime);n.birthtime}catch(e){}e=(p=t).toLocaleDateString("en-US");return d().put("IDate",e),p};var L=null;const d=function(){var n;return L=null==L?w?function(){const o=F("native-reg"),i="Software\\Typora";return{get:function(e){var t=o.openKey(o.HKCU,i,o.Access.READ);if(null==t)return"";e=o.getValue(t,null,e);return o.closeKey(t),e},put:function(e,t){var n=o.createKey(o.HKCU,i,o.Access.WRITE);o.setValueSZ(n,e,t),o.closeKey(n)}}}():(n=l.setting.prepDatabase(a),{put:function(e,t){console.log("ls put "+e),n.getState()[e]=t,n.write()},get:function(e){return n.getState()[e]}}):L};const U=async()=>{if(!a){if(w){const t=F("native-reg");var e=t.openKey(t.HKEY.LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Cryptography",t.Access.WOW64_64KEY|t.Access.READ);a=t.getValue(e,null,"MachineGuid"),t.closeKey(e)}else a=await i(560).machineId({original:!0});a||s.captureMessage("[L] Failed to get fingerPrint"),a=O(a,"typora").substr(0,10).replace(/[/=+-]/g,"a"),b&&(a+="darwin")}return a};var R=!1;const A=()=>{var e=s.getContext().tags;e.hasLicense=r,s.mergeContext(e)},N=()=>process.platform.replace(/\d+/,""),B=async(t,n,o)=>{oe(),console.log(`request ${W}/`+t);const e=new AbortController;var i,r=setTimeout(()=>e.abort(),3e4);try{i=await k(W+"/"+t,{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}}),clearTimeout(r)}catch(e){var a=e;if(console.warn(e.stack),clearTimeout(r),o&&"zh-Hans"==l.setting.getUserLocale()&&!l.setting.get("useMirrorInCN")){r=(await g.dialog.showMessageBox(null,{message:"链接服务器失败,使用尝试访问国内域名进行激活?",buttons:["确认","取消"]}))["response"];if(console.log("click "+r),r)throw a;return l.setting.put("useMirrorInCN",!0),B(t,n,!1)}if(l.setting.get("useMirrorInCN"))try{console.log("request to typora.com.cn"),i=await post("https://typora.com.cn/store/"+t,n)}catch(e){throw a}}if(i){if(200==i.status)return-1{const o=(new Date).toLocaleDateString("en-US");var{deviceId:t,lastRetry:i}=t||{};if(n||!(new Date-ir.abort(),4e4);const a=await(await k(W+"/api/client/renew",{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}})).json();clearTimeout(e),a.success||(console.warn("[renewL]: unfill due to renew fail"),$(a.msg)),d().put("SLicense",[a.msg,0,o].join("#"))}catch(e){e.stack,s.captureException(e,{level:"warning"}),console.warn("Failed to Renew L");var[t,n]=(i=d().get("SLicense")).split("#"),i=[t,n=+n+1,o].join("#");d().put("SLicense",i)}}},J=e=>{var t=new Date(d().get("IDate"));return isNaN(t.getTime())?e?null:new Date:e?t:(e=1676346227284,isNaN(e)?e=new Date("2021-10-01"):(e=new Date(e),isNaN(e.getTime())&&(e=new Date("2021-10-01"))),t{if(t=t||15,432e5{var e=(p=J(!global.devVersion))?V(!1):100;(15{R=!0;var t=_(),{license:n,email:o,type:i}=t||{};n&&o?(j(o,n,i),z(t,e)):$()},K=(e,t)=>g.dialog.showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:e,message:t}),Q=function(){l.expired=!0,K(h.getPanelString("Error"),h.getPanelString("This dev version of Typora is expired, please download and install a newer version.")).then(()=>{m.openExternal("https://typora.io/#download"),setTimeout(()=>{process.exit(1)},1e3)})},Z=function(){var e;re()&&!l.setting.inFirstShow&&(e=y||global.devVersion,y&&Math.random()<.8||(!S||new Date-S>36e5*(e?4:2)||!e&&V(!0,16)<=0)&&Y())};var G=!1,t=null;const Y=async function(e){if(S=new Date,null==t)return(t=v.showPanelWindow({width:525,height:420,path:`page-dist/license.html?dayRemains=${V(!0)}&index=${e?1:0}&hasActivated=${r||!1}&email=${x}&license=${c}&lang=${l.setting.getUserLocale()}&needLicense=${ie()&&!global.devVersion}&type=${D}&os=`+(w?"win":b?"mac":"linux"),frame:!1,alwaysOnTop:!C})).on("closed",function(){t=null}),void setTimeout(()=>{t&&!t.isDestroyed()&&t.setAlwaysOnTop(!1)},5e3);t.focus()};var n=null;async function X(){var o=(o=process.env.USER)||i(842).userInfo().username;switch(process.platform){case"win32":return process.env.COMPUTERNAME+" | "+o+" | Windows";case"darwin":return new Promise(n=>{i(620).exec("scutil --get ComputerName",{timeout:5e3},(e,t)=>{n(!e&&t?t.toString().trim()+" | "+o+" | darwin":i(842).hostname()+" | "+o+" | darwin")})});default:return i(842).hostname()+" | "+o+" | Linux"}}async function ee(e){try{var{fingerprint:t,email:n,license:o,type:i}=E(e)||{};return n&&o&&t?t!=await U()?(console.log("[L] validate server return fail"),$(),!1):(j(n,o,i),d().put("SLicense",e+"#0#"+(new Date).toLocaleDateString("en-US")),r=!0):(console.log("[L] validate server return empty"),$(),!1)}catch(e){throw console.error(e.stack),new Error("WriteActivationInfoFail")}}const te=e=>{const r="L23456789ABCDEFGHJKMNPQRSTUVWXYZ";if(!/^([A-Z0-9]{6}-){3}[A-Z0-9]{6}$/.exec(e))return!1;var e=e.replace(/-/g,""),t=e.substr(22);return!e.replace(/[L23456789ABCDEFGHJKMNPQRSTUVWXYZ]/g,"")&&t==(e=>{for(var t="",n=0;n<2;n++){for(var o=0,i=0;i<16;i+=2)o+=r.indexOf(e[n+i]);o%=r.length,t+=r[o]}return t})(e)},ne=(e.handle("license.machineCode",async()=>{console.log("handle license.machineCode");try{return await Buffer.from(JSON.stringify({v:N()+"|"+l.getVersion(),i:await U(),l:await X()}),"utf8").toString("base64")}catch(e){console.error(e.stack)}}),async t=>{r&&x&&c||console.error("doDeactivation on unregistered device");var e=(_()||{})["deviceId"];try{await B("api/client/deactivate",{license:c,l:e,sig:O(x,await U(),c)},!1)}catch(e){if(s.captureException(e,{level:"warning"}),console.log(e.stack),!t&&"off"==D)return!1}return $(),!0}),oe=(e.handle("addLicense",async(e,{email:t,license:n,force:o})=>{try{return await async function(e,t,n){if(e=(e||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),t=(t||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),!/^[^\s@'"/\\=?]+@[^\s@'"/\\]+\.[^\s@'"/\\]+$/.test(e))return[!1,"Please input a valid email address"];if(!te(t))return[!1,"Please input a valid license code"];t={v:N()+"|"+l.getVersion(),license:t,email:e,l:await X(),f:await U(),u:l.setting.generateUUID(),type:global.devVersion?"dev":"",force:n};JSON.stringify(t);try{var o=await B("api/client/activate",t,!0);if(JSON.stringify(o),console.log("[License] response code is "+o.code),o.code==T.SUCCESS)return await ee(o.msg)?[!0,""]:[!1,"Please input a valid license code"];if(o.code==T.OUT_OF_LIMIT)return n?await ee(o.msg)?[!0,"Your license has exceeded the max devices numbers.\nThe oldest device was unregistered automatically."]:[!1,"Please input a valid license code"]:["confirm",'Your license has exceeded the max devices numbers.\nIf you click "Continue Activation", this device will be activated and the oldest device will be unregistered automatically.'];if(o.code==T.INVALIDATE)return[!1,"Please input a valid license code"];if(o.code==T.WRONG_USER)return[!1,"This license code has been used with a different email address."]}catch(e){return"WriteActivationInfoFail"==e.message?(ne(!0).then(()=>{},()=>{}),[!1,"Failed to write your license to local machine"]):e.response&&e.response.code?(console.warn("[L] error from server "+e.response.code),[!1,"Unknown Error. Please contact hi@typora.io"]):(s.captureException(e,{level:"warning"}),console.error(e.stack),[!1,"Failed to access the license server. Please check your network or try again later."])}}(t,n,o)}catch(e){console.error(e.stack)}}),e.handle("offlineActivation",async(e,t)=>{try{return n=t,await(await ee(n)?[!0,"",x,c]:[!1,"Please input a valid license code"])}catch(e){console.error(e.stack)}var n}),e.handle("license.show",(e,t)=>{Y(t||!1)}),e.handle("license.show.debug",()=>{t&&t.webContents.openDevTools()}),e.handle("removeLicense",async e=>{try{return await ne()}catch(e){console.error(e.stack)}return!1}),()=>{W=l.setting.get("useMirrorInCN")?shostc||"".substring(1):global.shost||"".substring(1)});const ie=()=>!r&&!y,re=e=>R&&!r;var ae;ae=(new Date).getTime();const le="txxxx-xxxx-xxxxy".replace(/[x]/g,function(e){var t=(ae+16*Math.random())%16|0;return ae=Math.floor(ae/16),t.toString(16)}),se=()=>{f.getAllWindows().forEach(e=>{e.webContents.executeJavaScript(`try{document.querySelector(".${le}").remove();}catch(e){};File.option && (File.option.hasLicense = true);File.megaMenu && File.megaMenu.forceReload();0;`)})},ce=async e=>{await h.initDict();const t=`.typora-sourceview-on .${le}{left: 170px;}.${le} {position: fixed;bottom: 2px;z-index: 9999;left: 70px;font-size: 12px;line-height: 24px;background: rgb(120 120 120 / 30%);padding: 0 12px;color: var(--text-color);border-radius: 4px;cursor: pointer;}.pin-outline .${le}{left:calc(var(--sidebar-width) + 70px);}`,n=`if(window.File.option){File.option.hasLicense = false;File.megaMenu && File.megaMenu.forceReload();if(!document.querySelector(".${le}")) {const pos = Math.round(Math.random() * document.body.children.length);const dom = document.createElement("DIV");dom.innerText = "${h.getPanelString("UNREGISTERED")} ×";dom.classList.add("${le}");dom.style = "position: fixed !important;bottom: 2px !important; display: block !important; opacity: 1 !important; height: auto !important; width: auto !important; z-index: 9999 !important;";dom.setAttribute("role", "button");dom.addEventListener("click", () => {dom.remove();reqnode("electron").ipcRenderer.invoke("license.show");});document.body.insertBefore(dom, document.body.children[pos]);}};1;`;function o(e){e.webContents.insertCSS(t.replace(/(\{|\}|;)\n/g,"$1")),e.webContents.executeJavaScript(n.replace(/(\{|\}|;)\n/g,"$1"))}e?o(e):f.getAllWindows().forEach(o)};w&&(e=i(541).join(t_workingDir,"../winmm.dll"),i(833).stat(e,function(e,t){!e&&t&&setTimeout(function(){G=!0},138e4)})),u.startL=async(e,t)=>{console.log("start LM in devVersion="+(global.devVersion||!1));try{oe(),await U(),!e&&t||y||(global.devVersion||!t||-1240*I)&&Q(),n=+n,console.log("verInitTime is "+n),!isNaN(n)&&o-n>200*I&&Q()),(async e=>{console.log("[watch L]"),q(e),await H(),console.log("[watch L] hasL: "+r),Z(),A()})(e)}catch(e){s.captureException(e)}var n,o,i;v.on("dom-ready",e=>{e=e,R&&re()&&ce(e)}),v.on("make-window",e=>{Z()})},u.showLicensePanel=Y,u.showWelcomePanel=async function(){if(S=new Date,null==n)return(n=v.showPanelWindow({width:760,height:460,path:"page-dist/welcome.html?lang="+l.setting.getUserLocale(),frame:!1,alwaysOnTop:!C})).on("closed",function(){n=null}),void setTimeout(()=>{n&&!n.isDestroyed()&&n.setAlwaysOnTop(!1)},4e3);n.focus()},u.shouldShowWelcomePanel=ie,u.getHasLicense=()=>r,u.cannotContinueUse=function(){return!1===r&&!y&&!global.devVersion&&(G||V(!0,20)<=0)}},557:(o,i,F)=>{var c,d,W=global.PRODUCTION_MODE,S=F(134),x=S.app,u=F(266),r=F(338),a=S.Menu,l=S.MenuItem,p=S.BrowserWindow,s=S.shell,D="win32"==process.platform,h="darwin"==process.platform,g="linux"==process.platform,T=F(728),P=F(541).join(__dirname,"../"),m=F(344),f=F(824),w=F(156),E=F(445),b=require(W?"package.json":"../package.json"),I=F(468),y=1e4;function v(t){var o,i,r=0,n=x.getPath("userData")+"/typora.log",a="",l=console.error;function s(e,t){try{if(y{this.logStream=e})}function k(){var n=(new Date).getTime();return uuid="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),("x"==e?t:3&t|8).toString(16)})}function _(t){var e=1676346227284,n=!1,o=0;isNaN(e)||(o=30<(e=(new Date-e)/864e5/5)?(n=!0,.001):Math.max(0,(30-e)/30),isNaN(o)&&(o=.01)),I.config("https://41af752e6d61480d85276af874a7f69b@sentry.typora.io/2",{logger:"node",release:b.releaseId,autoBreadcrumbs:{http:!1,console:!1},sampleRate:o,shouldSendCallback:function(e){return(!e||"debug"!=e.level)&&(!n&&!t.hasUpdates&&t.db&&t.get("send_usage_info")+""!="false")}}).install(B),C=k(),I.mergeContext({tags:{instance:C,arch:process.platform,appVersion:x.getVersion()}}),I.disableConsoleAlerts(),setTimeout(function(){console.log("[Raven] instanceKey = "+C)},0),I.setDataCallback(function(e){try{return e?(e.request&&(e.request.url="http://typora/"),e.mechanism&&delete e.mechanism,e.exception&&(t=e)&&(t.message&&(t.message=L(t.message)),(t.exception||[]).forEach(function(e){e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&e.stacktrace.frames.forEach(function(e){e.filename&&(e.filename=U(e.filename))})}),n=t.stacktrace||[],(t=(t.exception||{}).values||[]).forEach&&t.forEach(function(e,t){e&&(e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&(n=n.concat(e.stacktrace.frames)))}),n.length&&n.forEach(function(e){var t;-1<(t=e.filename.lastIndexOf("atom.asar"))&&(e.filename="http://typora-app/atom/"+e.filename.substring(t+9).replace(/\\/g,"/"))})),e):void 0}catch(e){console.error(e.stack)}var t,n;return{}})}e.prototype.closeLogging=function(){console.log("closeLogging");try{c=!0,d&&(process.stdout.write=process.stderr.write=d),this.logStream&&this.logStream.end()}catch(e){console.error(e)}},e.prototype.put=function(e,t){this.db.getState()[e]=t,this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=setTimeout(this.save.bind(this),500)},e.prototype.get=function(e,t){try{return"recentDocument"==e?this.getRecentDocuments():"recentFolder"==e?this.getRecentFolders():("framelessWindow"!=e||!g)&&(void 0===(n=this.db.getState())[e]?t:n[e]);var n}catch(e){return console.error(e),t}},e.prototype.save=function(){this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=null;try{this.db.write()}catch(e){console.error(e.stack)}},e.prototype.syncAll=function(){this.saveTimer&&clearTimeout(this.saveTimer);try{this.db.write(),this.history.write()}catch(e){console.error(e.stack)}},e.prototype.getAllThemes=function(){return this.allThemes},e.prototype.getRecentFolders=function(){var e=this.history.getState(),t=e.recentFolder;return t||(e.recentFolder=t=[]),t||[]},e.prototype.addRecentFolder=function(e){console.log("addRecentFolder"),e=F(541).normalize(e);var t=F(541).basename(e),n=this.getRecentFolders();if(t.length){this.removeRecentFolder(e,!0),n.unshift({name:t,path:e,date:new Date}),8new Promise(e=>{T.rm(l.join(v,t),{force:!0,recursive:!0,maxRetries:1},e)})))}await 0}if(0==o&&T.existsSync(a))g();else{console.log("overwriteThemeFolder"),T.ensureDirSync(f);var w=[];if(-1<["github.css","newsprint.css","night.css","pixyll.css","white.css"].indexOf(e)){try{T.renameSync(l.join(a,e),l.join(f,e)),w.push(e)}catch(e){}T.copySync(l.join(m,e),l.join(a,e),{overwrite:!0})}h.list(m,function(e,t){Promise.all(t.map(function(e){var r=l.basename(e);return new Promise(function(e,t){if(-1{}),C.rm(s.join(c,i+".aff"),{force:!0},()=>{}),C.rm(s.join(c,i+"-LICENSE"),{force:!0},()=>{}),console.log(`remove ${c}/${i}.dic`)}}else this.put("strict_mode",!0),this.put("copy_markdown_by_default",!0)}this.initDictionary_(),this.addAnalyticsEvent("launch"),t&&0!=o?this.addAnalyticsEvent(0{var t=x.setting.get("export.general")||{},n={},o=(["pdf","html","html-plain","image"].forEach(e=>{n[e]=Object.assign({type:e},t,x.setting.get("export."+e)||{})}),{});return x.setting.loadCustomExports().forEach(e=>{o[e.key]=Object.assign({},t,e,x.setting.get("export."+e.key)||{})}),JSON.stringify([n,o])}),n.handle("export.recordLastExport",(e,t)=>{A||(x.updateMenu({"File→Export→Export with Previous":{enabled:!0}}),x.updateMenu({"File→Export→Export and Overwrite with Previous":{enabled:!0}})),A=t,x.setting.lastExport=t,x.execInAll("File.option._lastExport = "+JSON.stringify(t))}),n.handle("setting.getDownloadingDicts",e=>JSON.stringify(x.setting.downloadingDicts||[])),n.handle("setting.getUserDictionaryPath",e=>x.setting.getUserDictionaryPath()),n.handle("setting.getUserDict",e=>JSON.stringify(x.setting.userDict)),n.handle("setting.downloadDict",(e,t)=>{e=p.fromWebContents(e.sender);x.setting.downloadDict(t,e.id)}),n.handle("setting.getThemes",e=>({all:x.setting.getAllThemes()||[],current:x.setting.curTheme()})),n.handle("setting.setCurTheme",(e,t,n)=>{x.setting.setCurTheme(t,n)}),n.handle("setting.resetAdvancedSettings",(e,t)=>{function n(){}var o=F(728),i=x.getPath("userData")+"/conf/conf.user.json";o.copy(P+"/conf.default.json",x.getPath("userData")+"/conf/conf.default.json",{overwrite:!0},t?function(){S.shell.showItemInFolder(i)}:n),o.copy(P+"/conf.default.json",i,{overwrite:!0},n)}),n.handle("logger.error",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Error] "+t)}),n.handle("logger.warn",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Warn] "+t)}),n.handle("setting.clearRecentDocuments",e=>{x.setting.clearRecentDocuments()}),n.handle("setting.removeRecentFolder",(e,t)=>{x.setting.removeRecentFolder(t)}),n.handle("setting.removeRecentDocument",(e,t)=>{x.setting.removeRecentDocument(t)}),n.handle("setting.addRecentFolder",(e,t)=>{x.setting.addRecentFolder(t)}),n.handle("setting.getRecentFiles",e=>JSON.stringify({files:x.setting.getRecentDocuments()||[],folders:x.setting.getRecentFolders()||[]})),n.handle("setting.put",(e,t,n)=>{x.setting.put(t,n)}),n.handle("setting.get",(e,t)=>x.setting.get(t)),n.handle("setting.fetchAnalytics",e=>{var t=JSON.stringify(x.setting.analyticsEvents);return x.setting.analyticsEvents=[],t}),null),B=(n.handle("setting.getUnsavedDraftsPath",e=>x.setting.getUnsavedDraftPath()),e.prototype.getUnsavedDraftPath=function(){return N?Promise.resolve(N):(N=F(541).resolve(x.getPath("userData"),"draftsRecover"),F(728).ensureDir(N).then(()=>N))},function(e,t,n){t&&console.info(t.stack||t.message),e=e||{},console.error(e.stack||e.message),!x.isReady()||"ENOTFOUND"!=(t=e.errno||e.code)&&"ETIMEDOUT"!=t&&"ECONNRESET"!=t&&0!=(e.message||"").indexOf("net::ERR")&&(dialog=F(134).dialog,stack=null!=(ref=e.stack)?ref:e.name+": "+e.message,message="Uncaught Exception:\n"+stack,dialog.showMessageBox(null,{type:"error",buttons:["OK","Learn Data Recovery"],defaultId:0,cancelId:0,title:"A JavaScript error occurred in the main process",message:message}).then(({response:e})=>{1==e?(e=x.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",s.openExternal(`https://support.${e}/Version-Control/`)):process.exit(1)}))});function z(t,n){p.getAllWindows().forEach(function(e){e.isDestroyed()||e.webContents.isDestroyed()||e.webContents.isLoading()||e.webContents.send(t,n)})}function J(e,t){t=e.indexOf(t);-1{},()=>{}),console.error(e),I.captureException(e)}}catch(e){console.error(e),I.captureException(e)}try{o.userDictionaryPath?(e=await T.readFile(this.userDictionaryPath+"/user-dict.json","utf8"),o.userDict=JSON.parse(e)):console.error("no userDictionaryPath found")}catch(e){console.warn("user-dict.json not found")}function r(){o.userDictionaryPath&&F(833).writeFile(o.userDictionaryPath+"/user-dict.json",JSON.stringify(o.userDict),function(){}),x.sendEvent("user-dict-update",o.userDict)}n=S.ipcMain;n.on("user-dict-add",function(e,t){var{lang:t,word:n}=t;o.userDict[t]=o.userDict[t]||[],-1==o.userDict[t].indexOf(n)&&o.userDict[t].push(n),r()}),n.on("user-dict-remove",function(e,t){o.userDict[t.lang]=(o.userDict[t.lang]||[]).filter(function(e){return e!=t.word}),r()})},e.prototype.buildOption=async function(){var t={},e=(t.supportTextBundle=this.supportTextBundle,t.enableInlineMath=this.get("enable_inline_math")||!1,t.enableHighlight=this.get("enable_highlight")||!1,t.enableSubscript=this.get("enable_subscript")||!1,t.enableSuperscript=this.get("enable_superscript")||!1,t.enableDiagram=0!=this.get("enable_diagram"),t.copyMarkdownByDefault=this.get("copy_markdown_by_default")||!1,t.showLineNumbersForFence=this.get("show_line_numbers_for_fence")||!1,t.noPairingMatch=this.get("no_pairing_match")||!1,t.autoPairExtendSymbol=this.get("match_pari_markdown")||!1,t.expandSimpleBlock=this.get("auto_expand_block")||!1,t.headingStyle=this.get("heading_style")||0,t.ulStyle=this.get("ul_style")||0,t.olStyle=this.get("ol_style")||0,t.scrollWithCursor=!this.get("no_mid_caret"),t.autoNumberingForMath=this.get("auto_numbering_for_math"),t.allowPhysicsConflict=this.get("allowPhysicsConflict"),t.noDisplayLinesInMath=this.get("noDisplayLinesInMath"),t.useRelativePathForImg=this.get("use_relative_path_for_img")||!1,t.relativePathWithDot=this.get("relativePathWithDot")||!1,t.allowImageUpload=this.get("allow_image_upload")||!1,t.defaultImageStorage=this.get("image_save_location")||null,"custom"==t.defaultImageStorage&&(t.defaultImageStorage=this.get("custom_image_save_location")),t.applyImageMoveForWeb=this.get("apply_image_move_for_web")||!1,t.applyImageMoveForLocal=!this.get("no_image_move_for_local"),t.preferCRLF=this.get("line_ending_crlf")||!1,t.sidebarTab=this.get("sidebar_tab")||"",t.useTreeStyle=this.get("useTreeStyle")||!1,t.strictMarkdown=this.get("strict_mode")||!1,t.noLineWrapping=this.get("no_line_wrapping")||!1,t.prettyIndent=this.get("prettyIndent")||!1,t.convertSmartOnRender=this.get("SmartyPantsOnRendering"),t.smartDash=this.get("smartDash"),t.smartQuote=this.get("smartQuote"),t.twoHyphensToEm=this.get("twoHyphensToEm")||!1,t.remapUnicodePunctuation=this.get("remapPunctuation"),t.indentSize=this.get("indentSize")||2,t.codeIndentSize=this.get("codeIndentSize")||4,t.enableAutoSave=this.get("enableAutoSave")||!1,t.saveFileOnSwitch=this.get("save_file_on_switch")||!1,t.presetSpellCheck=this.get("preset_spell_check")||"auto",t.autoCorrectMisspell=!1,this.config||{});t.monocolorEmoji=e.monocolorEmoji,t.userQuotesArray=this.get("userQuotesArray"),t.passiveEvents=!0,t.canCollapseOutlinePanel=this.get("can_collapse_outline_panel"),t.preLinebreakOnExport=this.get("preLinebreakOnExport"),t.preLinebreakOnExport=1==t.preLinebreakOnExport||"true"==t.preLinebreakOnExport,t.indentFirstLine=this.get("indentFirstLine"),t.hideBrAndLineBreak=this.get("hideBrAndLineBreak"),t.isFocusMode=this.get("isFocusMode"),t.isTypeWriterMode=this.get("isTypeWriterMode"),t.ignoreLineBreak=this.get("ignoreLineBreak")||!1,t.sendAnonymousUsage=this.get("send_usage_info"),t.useMirrorInCN=this.get("useMirrorInCN"),void 0!==t.sendAnonymousUsage&&null!==t.sendAnonymousUsage||(t.sendAnonymousUsage=!0),t.uuid=this.get("uuid"),t.appVersion=x.getVersion(),t.instance=C,t.devVersion=global.devVersion,t.hasLicense=E.getHasLicense(),t.userLocale=this.getUserLocale(),t.appLocale=x.getLocale(),t.sidebarWidth=this.get("sidebar-width"),t.caseSensitive=this.get("caseSensitive"),t.wholeWord=this.get("wholeWord"),t.useRegexp=this.get("useRegexp"),t.fileSearchCaseSensitive=this.get("fileSearchCaseSensitive"),t.fileSearchWholeWord=this.get("fileSearchWholeWord"),t.fileSearchUseRegexp=this.get("fileSearchUseRegexp"),t.wordCountDelimiter=this.get("wordCountDelimiter")||0;try{t.userPath=x.getPath("home")||""}catch(e){t.userPath=(D?process.env.USERPROFILE:"")||""}if(t.mainPath=global.addonPath||"",t.userDataPath=x.getPath("userData")||"",!this.tempPath){var n=x.getPath("temp");0{t.keys[e]=(m.getKeyAccelerator(e)||"").toLowerCase()}),t.mathFormatOnCopy=this.get("mathFormatOnCopy")||"svg",t.imageUploader=this.get("image_uploader"),t.customImageUploader=this.get("custom_image_uploader"),t.picgoAppPath=this.get("picgo_app_path"),t.noWarnigUploadDisabled=this.get("noWarnigUploadDisabled")||!1,t.noWarnigForMoveFile=this.get("noWarnigForMoveFile")||!1,t.noWarnigForMoveFileToList=this.get("noWarnigForMoveFileToList")||!1,t.noWarnigForDeleteFile=this.get("noWarnigForDeleteFile")||!1,t.noWarnigForTypeWriterMode=this.get("noWarnigForTypeWriterMode")||!1,t.noHintForOpenLink=this.get("noHintForOpenLink")||!1,t.noHintForUnibody=this.get("noHintForUnibody")||!1,t.noWarnigForFocusMode=this.get("noWarnigForFocusMode")||!1,t.noWarningForExportOverwrite=this.get("noWarningForExportOverwrite")||!1,t.noWarningForUpdateImageReference=this.get("noWarningForUpdateImageReference")||!1,t.hasUpdates=this.hasUpdates||!1,t.pandocPath=this.get("pandocPath")||"",t.buildTime=1676346227284,t.debug=this.get("debug"),t._lastExport=A,t.lineWiseCopyCut=this.get("lineWiseCopyCut")||!1,t},e.prototype.extraOption=async function(){var t=await this.buildOption();return t.restoreWhenLaunch=this.get("restoreWhenLaunch")||0,t.pinFolder=this.get("pinFolder"),t.enable_inline_math=t.enableInlineMath,t.enable_highlight=t.enableHighlight,t.enable_subscript=t.enableSubscript,t.enable_superscript=t.enableSuperscript,t.enableDiagram=0!=this.get("enable_diagram"),t.enable_diagram=t.enableDiagram,t.copy_markdown_by_default=!!this.get("copy_markdown_by_default"),t.show_line_numbers_for_fence=!!this.get("show_line_numbers_for_fence"),t.no_pairing_match=!!this.get("no_pairing_match"),t.match_pari_markdown=!!this.get("match_pari_markdown"),t.auto_expand_block=!!this.get("auto_expand_block"),t.heading_style=this.get("heading_style")||0,t.ul_style=this.get("ul_style")||0,t.ol_style=this.get("ol_style")||0,t.no_mid_caret=this.get("no_mid_caret"),t.auto_numbering_for_math=this.get("auto_numbering_for_math"),t.use_relative_path_for_img=this.get("use_relative_path_for_img"),t.relativePathWithDot=this.get("relativePathWithDot"),t.allow_image_upload=this.get("allow_image_upload"),t.image_save_location=this.get("image_save_location"),t.custom_image_save_location=this.get("custom_image_save_location"),t.apply_image_move_for_web=this.get("apply_image_move_for_web"),t.no_image_move_for_local=this.get("no_image_move_for_local"),t.line_ending_crlf=this.get("line_ending_crlf"),t.strict_mode=this.get("strict_mode"),t.no_line_wrapping=this.get("no_line_wrapping"),t.prettyIndent=this.get("prettyIndent"),t.SmartyPantsOnRendering=this.get("SmartyPantsOnRendering"),t.remapPunctuation=this.get("remapPunctuation"),t.save_file_on_switch=this.get("save_file_on_switch")||!1,t.preset_spell_check=this.get("preset_spell_check")||"auto",t.can_collapse_outline_panel=this.get("can_collapse_outline_panel"),t.send_usage_info=!1!==this.get("send_usage_info"),t.currentThemeFolder=x.getPath("userData")+(D?"\\":"/")+"themes",t.enableAutoUpdate=!1!==this.get("enableAutoUpdate"),t.autoUpdateToDev=this.get("autoUpdateToDev"),t.userLanguage=this.get("userLanguage"),t.image_uploader=this.get("image_uploader"),t.custom_image_uploader=this.get("custom_image_uploader"),t.picgo_app_path=this.get("picgo_app_path"),t.allThemes=this.allThemes,t.useSeparateDarkTheme=this.get("useSeparateDarkTheme")||!1,t.theme=this.get("theme")||"github.css",t.darkTheme=this.get("darkTheme")||"night.css",t.customExport=this.get("customExport"),["general","pdf","html","html-plain","image"].forEach(e=>{t["export."+e]=this.get("export."+e)}),(t.customExport||R).forEach(e=>{t["export."+e.key]=this.get("export."+e.key)}),t},n.handle("setting.getExtraOption",async e=>JSON.stringify(await x.setting.extraOption())),n.handle("setting.doDownloadPicgo",e=>{x.setting.doDownloadPicgo()}),n.handle("setting.getKeyBinding",e=>x.setting.config.keyBinding||{}),e.prototype.doDownloadPicgo=function(){w.initDict().then(function(){var e="https://github.com/typora/PicGo-cli/releases/download/latest/%@.zip".replace("%@",D?"x64"==process.arch?"win64":"win32":"linux");console.log(e);let n=F(541).normalize(x.getPath("userData")+"/picgo"),o=F(541).normalize(n+"/_picgo.zip");var i=new f(e,o,{title:w.getPanelString("Download"),text:w.getPanelString("Downloading…"),processOnComplete:.9});i.onSuccess=(e,t)=>{F(834)(o,{dir:n},function(e){t.value=1,t.text=w.getPanelString("Finished"),t.detail="",setTimeout(()=>{i.setCompleted()},2e3),T.unlink(o,()=>{})}),t.detail=w.getPanelString("Unzipping…")},i.onError=e=>{S.dialog.showErrorBox(w.getPanelString("Download"),e.message)},i.download()})};var V=null;e.prototype.useDarkTheme=function(){return V=S.nativeTheme.shouldUseDarkColors&&this.get("useSeparateDarkTheme")},e.prototype.useDarkThemeBefore=function(){return V},e.prototype.curTheme=function(){return this.useDarkTheme()?this.get("darkTheme")||"night.css":this.get("theme")||"github.css"},e.prototype.setCurTheme=function(e,t){return a.getApplicationMenu().getItem("Themes").submenu.items.map(function(e){e.checked=e.label==t}),this.useDarkTheme()?this.put("darkTheme",e):this.put("theme",e)},o.exports=e},587:(o,e,t)=>{var u,p=t(134),h=p.app,n=p.ipcMain,g=p.BrowserWindow,m=(t(445),t(468)),f=(process.platform,"linux"==process.platform),w=t(541).join(__dirname,"../");n.handle("window.setTitle",(e,t,n)=>{e=g.fromWebContents(e.sender);t=t||("Typora"===(t=e.getTitle())?"Untitled"+(n?"• - Typora":" - Typora"):t.replace(/•? - Typora$/,n?"• - Typora":" - Typora")),e.setTitle(t)}),n.handle("window.focus",e=>{e=g.fromWebContents(e.sender);return e.focus(),e.webContents.focus(),!0}),n.handle("window.setInSourceMode",(e,t)=>{g.fromWebContents(e.sender).inSourceMode=!!t}),n.handle("window.minimize",e=>{g.fromWebContents(e.sender).minimize()}),n.handle("window.close",e=>{g.fromWebContents(e.sender).close()}),n.handle("window.restore",e=>{e=g.fromWebContents(e.sender);e.unmaximize(),e.setFullScreen(!1)}),n.handle("window.maximize",e=>{g.fromWebContents(e.sender).maximize()}),n.handle("window.fullscreen",e=>{e=g.fromWebContents(e.sender);return e.setFullScreen(!0),e.isFullScreen()}),n.handle("window.setMenuBarVisibility",(e,t)=>{g.fromWebContents(e.sender).setMenuBarVisibility(t)}),n.handle("window.pin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!0)}),n.handle("window.unpin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!1)}),n.handle("window.updateMenuForIsAlwaysOnTop",e=>{e={"View→Always on Top":{state:g.fromWebContents(e.sender).isAlwaysOnTop()}};h.updateMenu(e)}),n.handle("window.toggleDevTools",e=>{e=g.fromWebContents(e.sender);e.webContents.isDevToolsOpened()?e.webContents.closeDevTools():e.webContents.openDevTools()}),n.handle("window.inspectElement",(e,t,n)=>{g.fromWebContents(e.sender).inspectElement(t,n)}),n.handle("window.checkAsFocus",e=>{e=g.fromWebContents(e.sender);e&&e.isFocused&&(h.currentFocusWindowId=e.id)}),n.handle("controller.switchFolder",(e,t)=>{e=g.fromWebContents(e.sender);h.switchFolder(t,e)}),n.handle("webContents.copy",e=>{g.fromWebContents(e.sender).webContents.copy()}),n.handle("webContents.cut",e=>{g.fromWebContents(e.sender).webContents.cut()}),n.handle("webContents.paste",e=>{g.fromWebContents(e.sender).webContents.paste()}),n.handle("webContents.selectAll",e=>{g.fromWebContents(e.sender).webContents.selectAll()}),n.handle("webContents.undo",(e,t)=>{g.fromWebContents(e.sender).webContents.undo()}),n.handle("webContents.redo",(e,t)=>{g.fromWebContents(e.sender).webContents.redo()}),n.handle("webContents.clearCache",(e,t)=>{var n=g.fromWebContents(e.sender);return new Promise(e=>{n.webContents.session.clearCache(e)})}),n.handle("webContents.action",(e,t)=>{g.fromWebContents(e.sender).webContents[t]()}),e.makeWindow=async(d,e)=>{var t=h.getDocumentController();e=e||{};var n,o,i=g.getFocusedWindow(),r=h.setting.config||{},a=t.lastClosedBounds,l=(i=i&&!t.getDocumentFromWindowId(i.id)?null:i)&&i.getBounds(),s=0,l=(a||(l?(s=i.isMaximized()||i.isFullScreen()?0:30,a={fullscreen:i.isFullScreen(),maximized:i.isMaximized()},s&&(a.x=l.x+s,a.y=l.y+s,a.width=l.width,a.height=l.height)):a=u?(s=u.fullscreen||u.maximize?0:30,{x:u.x+s,y:u.y-s,width:u.width,height:u.height,fullscreen:u.fullscreen,maximized:u.maximized}):{}),!a.fullscreen&&a.maximized),e={x:a.x,y:a.y,width:a.width||800,height:a.height||700,minWidth:400,minHeight:400,frame:!h.setting.get("framelessWindow"),disableAutoHideCursor:!1,backgroundColor:h.setting.get("backgroundColor"),webPreferences:{webSecurity:!1,allowRunningInsecureContent:!1,plugins:!1,nodeIntegration:!0,enableRemoteModule:!1,webviewTag:!0,nodeIntegrationInWorker:!0,devTools:!0,images:!0,directWrite:r.directWrite,defaultFontFamily:r.defaultFontFamily,allowDisplayingInsecureContent:!1,backgroundThrottling:!1,spellcheck:!1,contextIsolation:!1,additionalArguments:["--tyopt="+JSON.stringify({isMaximized:l,isFullScreen:a.fullscreen,...await h.setting.buildOption(),...e})]},autoHideMenuBar:a.fullscreen||r.autoHideMenuBar,show:d,fullscreen:a.fullscreen,alwaysOnTop:i&&i.isAlwaysOnTop(),fullscreenable:!0},c=(f&&(e.icon=w+"/assets/icon/icon_256x256.png"),r=e,i=0s.y+s.height&&(r.y=s.y+s.height-r.height),r.xs.x+s.width&&(r.x=i?s.x:s.x+s.width-r.width)),u=e,l&&(e.show=!1),new g(e));return t.lastClosedBounds=null,l&&(c.maximize(),d&&c.show()),a.fullscreen&&(c.autoHideMenuBar=!0,c.setMenuBarVisibility(!1)),c.loadURL(entry||"".substring(1)),n=c,o=p.shell,n.webContents.on("will-navigate",function(e,t){e.preventDefault(),o.openExternal(t)}),n.webContents.setWindowOpenHandler(e=>(/^https?:/.exec(e.url)&&o.openExternal(e.url),{action:"deny"})),n.webContents.on("crashed",function(e,t){console.error("render process is killed? "+t),m.captureMessage("render process crashed, killed="+t),h.setting.addAnalyticsEvent("crashed")}),n.webContents.on("unresponsive",function(){m.captureMessage("unresponsive",{extra:{winId:n.id}}),h.setting.addAnalyticsEvent("unresponsive")}),n.webContents.setMaxListeners(15),n.webContents.on("dom-ready",function(){n.isMaximized()&&n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");'),b("dom-ready",n)}),n.on("maximize",()=>{n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");')}),n.on("enter-full-screen",function(){n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");document.body.classList.add("typora-fullscreen");if(document.body.classList.contains("native-window")) {$("#ty-top-placeholder").show();};1;')}),n.on("unmaximize",function(){n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");')}),n.on("session-end",function(){console.log("[win] session-end"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),n.on("leave-full-screen",function(){n.autoHideMenuBar=!!h.setting.config.autoHideMenuBar,n.setMenuBarVisibility(!h.setting.config.autoHideMenuBar),n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");document.body.classList.remove("typora-fullscreen");$("#ty-top-placeholder").hide();1;'),u&&(u.fullscreen=!1)}),n.on("focus",function(){n.webContents.incrementCapturerCount();var e=t.getDocumentFromWindowId(n.id);e&&(e.setActiveWindow(n),h.focusedWindow=n)}),n.on("blur",()=>{console.log("[win] blur"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),b("make-window"),c};const i=t(93);var r=new i;const b=function(e,t){r.emit(e,t)};e.on=function(e,t){r.on(e,t)},e.showPanelWindow=function({path:e,...t}){var n=new g({modal:!0,show:!1,center:!0,resizable:!1,webPreferences:{devTools:!global.releaseMode,defaultFontSize:14,nodeIntegration:!0,contextIsolation:!1,enableRemoteModule:!1},...t});return n.loadURL("file://"+w+"/"+e),n.once("ready-to-show",function(){n.show()}),n.removeMenu(),f&&(n.icon=w+"/assets/icon/icon_256x256.png"),n.webContents.setWindowOpenHandler(e=>(p.shell.openExternal(e.url),{action:"deny"})),n}},90:(e,o,s)=>{e=s.nmd(e);var t,i=s(541),n=s(640),r=(t=i.join(__dirname,"../"),i.join(t,"node_modules.asar")),a=(n.globalPaths.push(r),n.prototype.require);n.prototype.require=function(e){return-1==this.paths.indexOf(__dirname)&&(this.paths.push(__dirname),this.paths.push(r)),/(\.node$)|(\/build\/Release)/.exec(e)&&"."==e[0]&&(e=i.resolve(i.dirname(this.id),e).replace(/\bnode_modules\.asar\b/,"node_modules")),a.call(this,e)};for(let e=0;e{c.exit()},1e3),s(405);var n=s(134),c=n.app,l=n.protocol,m=n.powerMonitor,d=n.BrowserWindow,u=s(728),f="win32"==process.platform,w=(process.platform,process.platform,s(557),s(344)),b=s(883),e=s(932),y=s(445),p=s(351),n=n.ipcMain;s(468);if(!c.requestSingleInstanceLock())return console.record("secondary instance would exit"),void c.quit();console.record("launch with argv ["+process.argv.join(", ")+"]"),c.on("second-instance",function(e,t,n){console.record("got argv ["+t.join(", ")+"] from secondary instance"),t=Array.from(t),d.getAllWindows().length&&((n=F(t,n))?c.openFileOrFolder(n,{forceCreateWindow:!n}):T(t||[]))});var v=1,k=2,C=3;function F(e,t){null==t&&(t=process.cwd());for(var n,o=e.length-1;0<=o;o--)if("-"!=e[o][0]&&!/\.asar$/.exec(e[o]||"")){n=e[o];break}if((n=0!=o&&n!=t?n:void 0)&&/^file:\/\//i.exec(n)){n=n.replace(/^file:\/\//i,"");try{n=decodeURI(n)}catch(e){}}return n?s(541).resolve(t,n):void 0}function S(e){if(!e)return e;var t=e.length;return 50((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFile(t||null,n).then(n=>{if(n)return new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e({winId:n.activeWindow.id})}):e({winId:n.activeWindow.id})})}))),n.handle("app.openFileOrFolder",(e,t,n)=>((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFileOrFolder(t||null,n))),n.handle("app.openOrSwitch",async(e,t,n)=>{var o,e=d.fromWebContents(e.sender),i=c.documentController.getDocument(t),r=c.documentController.getDocumentFromWindowId(e.id);if(i)return(o=i.activeWindow||i.windows.keys().next().value)&&o.focus(),!1;if(n)return c.openFileOrFolder(t,{curWindow:!0}),!1;if(await O(t))c.switchFolder(t,e);else if(!i)return r.rename(t),!0;return!1}),n.handle("app.openFolder",(e,t,n)=>{c.openFolder(t||null,n?d.fromWebContents(e.sender):void 0)}),n.handle("app.onCloseWin",(e,t)=>{e=d.fromWebContents(e.sender);c.onCloseWin(e.id,t)}),n.handle("app.sendEvent",(e,t,n)=>{c.sendEvent(t,n)}),n.handle("executeJavaScript",(e,t,n)=>{d.fromId(t).webContents.executeJavaScript(n)}),c.reopenFolder=function(){var t=new Set,n=!1;return g.forEach(function(e){e.mountFolder&&!t.has(e.mountFolder)&&(t.add(e.mountFolder),c.openFile(null,{forceCreateWindow:!0,mountFolder:e.mountFolder}),n=!0)}),n},c.reopenClosed=function(o){var i=!1;return g.length&&g.forEach(function(e,t){var n=c.getDocumentController().getDocument(e.path);n?n.activeWindow&&n.activeWindow.show():(c.openFile(e.path,{forceCreateWindow:!!t,mountFolder:e.mountFolder,silent:o,backupState:e,fromReopen:!0}),i=!0)}),i},function(e){var t,n=c.setting.get("restoreWhenLaunch")||0,o=!0,i=e||process.argv||[];-1{/^--/.exec(e)&&("--on-dev"==e?process.traceDeprecation=!0:-1===["--new","--reopen-file"].indexOf(e)&&c.commandLine.appendSwitch.apply(null,[e]))}),scheme||"".substring(3));c.on("ready",async function(){var e,t;await c.setting.initSetting(),c.expired||(p.lastClosedBounds=c.setting.get("lastClosedBounds"),console.record("------------------start------------------"),console.log("typora version: "+c.getVersion()),console.log(""+s.c[s.s].filename),M(P),c.setAppUserModelId("abnerworks.Typora"),(e=F(process.argv))&&"--on-dev"!==process.argv[process.argv.length-1]?c.openFileOrFolder(e):c.recoverFromBackup(),w.loadDict().then(()=>{w.bindMainMenu()}),f&&(t=s(558),c.updater=t,setTimeout(function(){t.initUpdater().then(function(){!1!==c.setting.get("enableAutoUpdate")&&c.updater.checkForUpdates(!1)})},3e3)),b.bindJumplist(),setTimeout(function(){try{E()}catch(e){console.warn(e.stack)}},3e4),m.on("suspend",()=>{console.record("[Power] suspend"),c.execInAll('window.onPowerChange && window.onPowerChange("suspend")')}),m.on("resume",()=>{console.record("[Power] resume"),c.execInAll('window.onPowerChange && window.onPowerChange("resume")')}),m.on("lock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("lock-screen")')}),m.on("unlock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("unlock-screen")')}))});var I,W={},E=async function(){var r,a,l,s,n=await c.setting.getUnsavedDraftPath(),e=await u.readdir(n);e.length<200||(console.record("cleanUpExpiredDrafts"),400{var o=[],i=async function(){Math.min(l+50,a.length);if(l+1>=a.length)n(o);else{for(;l++;){if(!a[l])return void n(o);try{var e=r+"/"+a[l],t=await u.stat(e);864e6{try{return{name:e,time:W[e]||(await u.stat(n+"/"+e)).mtime.getTime()}}catch(e){}return{name:e,time:0}})),W=null,e.sort(function(e,t){return t.time-e.time}).forEach(function(e,t){150{D=!1}),c.on("quit",function(){console.log("-----------------quit------------------"),c.setting.closeLogging()}),c.on("will-quit",function(){console.log("------------------will-quit------------------"),h&&clearTimeout(h),I&&clearTimeout(I),f&&c.updater&&c.updater.installIfNeeded(),c.setting.syncAll();try{u.rmSync(c.getPath("userData")+"/runtime-storage",{recursive:!0,force:!0})}catch(e){console.error(e)}try{var e=c.getPath("userData")+"/typora.log",t=c.getPath("userData")+"/typora-old.log",n=u.statSync(e);n&&5e5p.getDocumentFromWindowId(n.id)):l()}).then(function(e){return e})}return l()},c.sendEvent=function(t,n){d.getAllWindows().forEach(function(e){e.webContents.send(t,n)}),c.onMessage(t,n)},c.execInAll=function(t){d.getAllWindows().forEach(function(e){e.webContents.executeJavaScript(t)})},c.onMessage=function(e,t){"didRename"==e?c.setting.renameRecentDocuments(t.oldPath,t.newPath):"updateQuickOpenCache"==e&&t.toDel&&c.setting.renameRecentDocuments(t.toDel,null)},c.refreshMenu=function(){w.refreshMenu()},{});n.handle("app.download",(e,t,n,o)=>{var i,r,a=s(541),l=d.fromWebContents(e.sender),e=s(554),o=o||(e=>{var t=s(426),n=s(541),t=t.parse(e),e=n.basename(t.pathname);try{var o=decodeURIComponent(e);if(o!=e)return n.basename(o)}catch(e){}return e})(t),a=a.join(n,o);return u.existsSync(a)&&(i=a,r=s(541),a=i.replace(/(\.[^.\/\\]+?$)/,"")+"-"+ +new Date+r.extname(i)),_[l.id+t]||(_[l.id+t]=e.download(l,t,{showBadge:!1,directory:n,filename:o})),setTimeout(()=>{delete _[l.id+t]},10),Promise.race([_[l.id+t].then(e=>({path:e.getSavePath(),state:e.getState(),type:e.getMimeType()}),()=>({path:t,state:"error"})),new Promise(e=>{setTimeout(()=>{e({path:t,state:"timeout"})},3e4)})])});var M=function(e){l.registerFileProtocol(e,function(e,t){e.url?t({path:c.getRealPath(e.url)}):t({error:-324})}),l.registerBufferProtocol("typora-bg",function(e,t){var n=c.setting.get("backgroundColor");t(n?{mimeType:"text/css",data:Buffer.from(`body {background:${n};`)}:{mimeType:"text/css",data:Buffer.from("")})})};c.getRealPath=function(e){try{e=decodeURI(e)}catch(e){}e=e.substr(13);return/^userData/.exec(e)&&(e=e.replace(/^userData/,c.getPath("userData").replace(/\\/g,"\\\\"))),/current-theme\.css$/.exec(e)&&(e=e.replace(/current-theme\.css$/,c.setting.curTheme())),/^typemark/i.exec(e)&&(e=e.replace(/^typemark/,t)),e=(e=/preview\.html/.exec(e)?e.replace(/\.html[?#].*$/,".html"):e).replace(/[?#][^\\\/]*$/,"")},c.filesOp=e,P&&l.registerSchemesAsPrivileged([{scheme:P,privileges:{standard:!0,secure:!0,supportFetchAPI:!0,bypassCSP:!0,corsEnabled:!0,stream:!0}}])},344:(t,n,h)=>{function r(e,t){return function(){k(e,t)}}var i,a=h(134),l=a.app,g=a.dialog,s=a.Menu,c=a.MenuItem,m=a.BrowserWindow,e=a.ipcMain,f=h(728),d="win32"==process.platform,w="darwin"==process.platform,b="linux"==process.platform,y=h(445),u=h(541).join(__dirname,"../"),v=(e.on("execForAll",function(e,t){v(t)}),e.on("forceRefreshMenu",function(e,t){l.forceRefreshMenu()}),e.on("syncToPreference",function(e,t){a.webContents.getAllWebContents().forEach(function(e){e.send("syncToPreference",t)})}),n.loadDict=()=>{var o,e;return i?Promise.resolve(i):(o=l.setting.getUserLocale(),e=h(541).join(u,l.setting.getLocaleFolder("Menu")),new Promise(n=>{f.readFile(e,"utf8",(e,t)=>{i=t?JSON.parse(t):{},n(i),e&&console.warn("cannot load dict as ["+o+"] "+e.stack)})}))},function(e){var t=e=e.toString();/^\s*function\s*\(/.exec(e)&&(t="window.File && ("+e+")();"),l.execInAll(t),console.log(t)}),k=function(e,t){var n=m.getFocusedWindow();n&&(t?n.webContents.executeJavaScript("window.File && !File.blockUI && ("+e.toString()+")();0;"):n.webContents.executeJavaScript("!File.blockUI && window.ClientCommand['"+e+"']();0;"),n.webContents.executeJavaScript("window.Reporter && window.Reporter.fullValidate();File.editor && File.editor.contextMenu && File.editor.contextMenu.hide();0;"))};function C(e){var t=/&[a-z]/i.exec(e),n=/(\.\.\.)|(…)/.exec(e),o=(e=e.replace(/(\.\.\.)|(…)|&/g,""),(i||{})[e]||e);return t?function(e,t){e=S[e];if(!e)return t;{var n,o;(d||b)&&(-1==(n=t.indexOf(e))?n=t.indexOf(e.toLowerCase()):-1<(o=t.indexOf(e.toLowerCase()))&&(n=Math.min(n,o)),-1{setTimeout(o,0)}))),e}function x(e,t){return p(e={label:e,accelerator:t}),e.accelerator}function D(e){function n(e,t){e=e.label;f.existsSync(e)?l.openFileOrFolder(e,{curWindow:t}):(g.showMessageBox({title:C("Open Failed"),message:C("File or folder does not exist."),buttons:["Close"],cancelId:0,defaultId:0}),l.setting.removeRecentDocument(e))}try{var o=e.getItem("File").submenu.getItem("Open Recent").submenu,t=l.setting.getRecentDocuments(),i=l.setting.getRecentFolders();t.sort(function(e,t){return t.date-e.date}),i.sort(function(e,t){return t.date-e.date}),o.clear(),o.append(new c({label:C("Reopen Closed File"),accelerator:"CmdOrCtrl+Shift+T",click:function(){l.reopenClosed()}})),o.append(new c({type:"separator"})),t.length&&(t.forEach(function(e,t){10{e.type&&(hasCustom=!0,o.push({label:e.name,click:t(e)}))}),o.push({type:"separator"}),o.push({label:"Export with Previous",accelerator:"Shift+Ctrl+E",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast();")},enabled:!!l.setting.lastExport}),o.push({label:"Export and Overwrite with Previous",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast(true)")},enabled:!!l.setting.lastExport}),o.push({type:"separator"}),o.push({label:"Export Setting…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('export-setting-group');")},enabled:!0}),e&&(o.forEach(p),n=P("File→Export").submenu,o[o.length-1].enabled=(I("Export and Overwrite with Previous",n)||{}).enabled,n.clear(),o.forEach(e=>{n.append(new c(e))}),w&&s.setApplicationMenu(s.getApplicationMenu())),o}function P(e){if(!e)return null;var t,n=(W=W||{})[e];return n||(e.split("→").forEach(function(e){if(n=I(e,n),!(W[t=t?t+"→"+e:e]=n))return null}),W=null,n)}function I(e,t){var n,o=t?t.submenu:s.getApplicationMenu();return o?(n=o.getItem(e),t||n||"File"!=e?n:o.getItem("Typora")||o.getItem("Electron")):null}var W,o=null;l.forceRefreshMenu=function(){b&&(o&&clearTimeout(o),o=setTimeout(function(){s.setApplicationMenu(s.getApplicationMenu()),o=null},100))};l.updateMenu=function(e){W={};for(var t in e){var n,o,i=P(t),r=e[t];i&&(n=null,void 0!==r.accelerator&&(r.accelerator,o=x(i.label,r.accelerator),i=n=o!=i.accelerator?new c(p({label:i.label,type:i.type,enabled:i.enabled,checked:i.enabled,click:i.click,accelerator:o})):n),"Paragraph→Table"!=t?(void 0!==r.state&&(i.checked=r.state),void 0!==r.enabled&&(i.enabled=r.enabled,"Paragraph"!=t&&"Format"!=t&&"Format→Image→Zoom Image"!=t||i.submenu.items.forEach(function(e){e.enabled=r.enabled})),void 0!==r.hidden&&(i.visible=!r.hidden),!n||-1<(t=(o=P(t.replace(/→[^→]+$/,"")).submenu.items).findIndex(e=>e.label==n.label))&&(o.splice(t,1,n),console.log("newItem.accelerator "+n.accelerator))):(function(e,n){n.enabled||n.state?(e.enabled=!0,e.submenu.items.forEach(function(e,t){e.enabled=0==t?!n.state:n.state})):e.enabled=!1}(i,r),0))}W=null,l.forceRefreshMenu()},e.on("menu.updateMenu",function(e,t){l.updateMenu(JSON.parse(t))}),e.handle("menu.updateCustomZoom",e=>{l.updateMenu({"View→Actual Size":{state:!l.setting.get("customZoom")}})}),e.handle("menu.refreshThemeMenu",function(e){l.setting.refreshThemeMenu()}),e.handle("menu.reloadExportMenu",function(e){T(!0)}),e.handle("menu.popup",function(e,t){s.getApplicationMenu().popup(t)}),n.bindMainMenu=function(){function e(e,t){e=(/\((.+)\)/.exec(e.label)||[])[1]||e.label;e==C("Auto")&&(e=""),k("function(){File.reloadWithEncoding('"+e+"')}",!0)}var t=l.setting.get("SmartyPantsOnRendering")||!1,n=l.setting.get("smartQuote")||!1,o=l.setting.get("smartDash")||!1,t=[p({label:"&File",submenu:[{label:"New",accelerator:"CmdOrCtrl+N",click:r("newFile")},{label:"New Window",accelerator:"CmdOrCtrl+Shift+N",click:r("newWindow")},{type:"separator"},{label:"Open…",accelerator:"CmdOrCtrl+O",click:r("open")},{label:"Open Folder…",click:r("openFolder")},{type:"separator"},{label:"Open Quickly…",accelerator:"CmdOrCtrl+P",click:r("quickOpen")},{label:"Open Recent",submenu:[]},{label:"Reopen with Encoding",submenu:[{label:"Auto",click:e},{type:"separator"},{label:"UTF-8",click:e},{label:"UTF-16 LE",click:e},{label:"UTF-16 BE",click:e},{type:"separator"},{label:"Western (windows-1252)",click:e},{label:"Cyrillic (windows-1251)",click:e},{label:"Cyrillic (ISO-8859-2)",click:e},{label:"Cyrillic (IBM866)",click:e},{label:"Cyrillic (IBM855)",click:e},{label:"Cyrillic (KOI8-R)",click:e},{label:"Cyrillic (MacCyrillic)",click:e},{label:"Central European (windows-1250)",click:e},{label:"Central European (ISO-8859-2)",click:e},{label:"Geek (windows-1253)",click:e},{label:"Geek (ISO-8859-7)",click:e},{label:"Hebrew (windows-1255)",click:e},{label:"Hebrew (ISO-8859-8)",click:e},{label:"Chinese Simplified (GB2312)",click:e},{label:"Chinese Simplified (GB18030)",click:e},{label:"Chinese Traditional (Big5)",click:e},{label:"Japanese (SHIFT_JIS)",click:e},{label:"Japanese (EUC-JP)",click:e},{label:"Korean (EUC-KR)",click:e},{label:"Thai (TIS-620)",click:e}]},{type:"separator"},{label:"Save",accelerator:"CmdOrCtrl+S",click:r("save")},{label:"Save As…",accelerator:"CmdOrCtrl+Shift+S",click:r("saveAs")},{label:"Move To…",click:r("moveTo")},{label:"Save All…",click:r("saveAll")},{type:"separator"},d?{label:"Properties…",click:function(e,t){t&&t.webContents.executeJavaScript("File.winShell().openProperties(File.bundle.filePath);")}}:null,{label:"Open File Location…",click:r("openFileLocation")},{label:"Reveal in Sidebar",click:r(function(){window.File.editor.library.revealInSidebar()},!0)},{label:"Delete…",click:function(e,t){t&&t.webContents.executeJavaScript("File.trashSelf();")}},{type:"separator"},{label:"Import…",click:r("import")},{label:"Export",submenu:T()},{label:"Print…",accelerator:"Shift+Alt+P",click:r("print")},{type:"separator"},{label:"Preferences…",accelerator:"CmdOrCtrl+,",click:r("togglePreferencePanel")},{type:"separator"},{label:"Close",accelerator:"CmdOrCtrl+W",click:r("close")}]}),p({label:"&Edit",id:"edit",submenu:[{label:"Undo",id:"undo",accelerator:"CmdOrCtrl+Z",click:r("undo")},{label:"Redo",id:"redo",accelerator:"CmdOrCtrl+Y",click:r("redo")},{type:"separator"},{label:"Cut",accelerator:"CmdOrCtrl+X",role:"cut"},{label:"Copy",accelerator:"CmdOrCtrl+C",role:"copy"},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Paste",accelerator:"CmdOrCtrl+V",role:"paste"},{type:"separator"},{label:"Copy as Plain Text",click:r("copyAsPlainText")},{label:"Copy as Markdown",accelerator:"CmdOrCtrl+Shift+C",click:r("copyAsMarkdown")},{label:"Copy as HTML Code",click:r("copyAsHTMLSource")},{label:"Copy without Theme Styling",click:r("copyAsSemanticHTML")},{type:"separator"},{label:"Paste as Plain Text",accelerator:"CmdOrCtrl+Shift+v",click:r("pasteAsPlain")},{type:"separator"},{label:"Selection",submenu:[{label:"Select All",accelerator:"CmdOrCtrl+A",click:r("selectAll")},{label:"Select Paragraph / Block",accelerator:"CmdOrCtrl+Alt+P",click:r(function(){File.editor.selection.selectBlock()},!0)},{label:"Select Line / Sentence",accelerator:"CmdOrCtrl+L",click:r(function(){File.editor.selection.selectLine()},!0)},{label:"Select Styled Scope",accelerator:"CmdOrCtrl+E",click:r(function(){File.editor.selection.selectPhrase()},!0)},{label:"Select Word",accelerator:"CmdOrCtrl+D",click:r(function(){File.editor.selection.selectWord()},!0)},{type:"separator"},{label:"Jump to Top",accelerator:"Ctrl+Home",click:r(function(){File.editor.selection.jumpTop()},!0)},{label:"Jump to Selection",accelerator:"CmdOrCtrl+j",click:r(function(){File.editor.selection.jumpSelection()},!0)},{label:"Jump to Bottom",accelerator:"Ctrl+End",click:r(function(){File.editor.selection.jumpBottom()},!0)},{label:"Extend Selection to Top",accelerator:"Ctrl+Shift+Home",visible:!1,click:r(function(){File.editor.selection.jumpTop(!0)},!0)},{label:"Extend Selection to Bottom",accelerator:"Ctrl+Shift+End",visible:!1,click:r(function(){File.editor.selection.jumpBottom(!0)},!0)},{label:"Extend Selection to Line Start",accelerator:"Shift+Home",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!1)},!0)},{label:"Extend Selection to Line End",accelerator:"Shift+End",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!0)},!0)}]},{type:"separator"},{label:"Delete",click:r(function(){File.delete()},!0)},{label:"Delete Range",submenu:[{label:"Delete Paragraph / Block",accelerator:"Shift+CmdOrCtrl+Alt+P",click:r("deleteBlock")},{label:"Delete Line / Sentence",accelerator:"Shift+CmdOrCtrl+Alt+L",click:r("deleteLine")},{label:"Delete Styled Scope",accelerator:"Shift+CmdOrCtrl+Alt+E",click:r("deleteScope")},{label:"Delete Word",accelerator:"Shift+Ctrl+D",click:r("deleteWord")}]},{type:"separator"},{label:"Math Tools",submenu:[{label:"Refresh All Math Expressions",click:r(function(){File.editor.mathBlock.forceRefresh()},!0)}]},{type:"separator"},{label:"Smart Punctuation",submenu:[{label:"Convert on Input",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+!e+")"))},checked:!t},{label:"Convert on Rendering",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+e+")"))},checked:t},{type:"separator"},{label:"Smart Quotes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartQuote("+e+")"))},checked:n},{label:"Smart Dashes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartDash("+e+")"))},checked:o},{type:"separator"},{label:"Remap Unicode Punctuation on Parse",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setRemapPunctuation("+e+")"))},checked:l.setting.get("remapPunctuation")||!t&&(n||o),enabled:!(!t&&(n||o))},{type:"separator"},{label:"More Options…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('smart-punctuation-group');")}}]},{label:"Line Endings",submenu:[{label:"Windows Line Endings (CRLF)",type:"checkbox",click:r(function(){File.setLineEnding(!0,!0)},!0)},{label:"Unix Line Endings (LF)",type:"checkbox",click:r(function(){File.setLineEnding(!1,!0)},!0)},{type:"separator"},{label:"Insert Final New Line On Save",type:"checkbox",click:function(e,t){t&&t.webContents.executeJavaScript("File.setFinalNewline("+e.checked+")")}}]},{label:"Whitespace and Line Breaks",submenu:[{label:"Indent first line of paragraphs",type:"checkbox",click:r(function(){File.setIndentFirstLine(!File.option.indentFirstLine,!0,!0)},!0)},{type:"separator"},{label:"Visible
",type:"checkbox",checked:!0,click:r(function(){File.setHideBrAndLineBreak(!File.option.hideBrAndLineBreak,!0,!0)},!0)},{label:"Preserve single line break",type:"checkbox",checked:!0,click:r(function(){File.setIgnoreLineBreak(!File.option.ignoreLineBreak,!0,!0)},!0)},{type:"separator"},{label:"Learn More…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/Line-Break/`)}}]},{label:"Spell Check…",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.spellChecker && File.editor.spellChecker.show();")}},{type:"separator"},{label:"Find and Replace",submenu:[{label:"Find…",accelerator:"CmdOrCtrl+f",click:r(function(){File.megaMenu.isPreferencePanelShown()?File.megaMenu.searchOnPreferencePanel():File.editor.searchPanel.showPanel()},!0)},{label:"Find Next",accelerator:"F3",click:r(function(){File.editor.searchPanel.highlightNext()},!0)},{label:"Find Previous",accelerator:"Shift+F3",click:r(function(){File.editor.searchPanel.highlightNext(!0)},!0)},{type:"separator"},{label:"Replace",accelerator:"Ctrl+h",click:r(function(){File.editor.searchPanel.showPanel(!0)},!0)}]}]}),p({label:"&Paragraph",submenu:[{label:"Heading 1",type:"checkbox",accelerator:"Ctrl+1",click:r(function(){File.editor.stylize.changeBlock("header1",void 0,!0)},!0)},{label:"Heading 2",type:"checkbox",accelerator:"Ctrl+2",click:r(function(){File.editor.stylize.changeBlock("header2",void 0,!0)},!0)},{label:"Heading 3",type:"checkbox",accelerator:"Ctrl+3",click:r(function(){File.editor.stylize.changeBlock("header3",void 0,!0)},!0)},{label:"Heading 4",type:"checkbox",accelerator:"Ctrl+4",click:r(function(){File.editor.stylize.changeBlock("header4",void 0,!0)},!0)},{label:"Heading 5",type:"checkbox",accelerator:"Ctrl+5",click:r(function(){File.editor.stylize.changeBlock("header5",void 0,!0)},!0)},{label:"Heading 6",type:"checkbox",accelerator:"Ctrl+6",click:r(function(){File.editor.stylize.changeBlock("header6",void 0,!0)},!0)},{type:"separator"},{label:"Paragraph",type:"checkbox",accelerator:"Ctrl+0",click:r(function(){File.editor.stylize.changeBlock("paragraph")},!0)},{type:"separator"},{label:"Increase Heading Level",accelerator:"Ctrl+=",click:r(function(){File.editor.stylize.increaseHeaderLevel()},!0)},{label:"Decrease Heading Level",accelerator:"Ctrl+-",click:r(function(){File.editor.stylize.decreaseHeaderLevel()},!0)},{type:"separator"},{label:"Table",submenu:[{label:"Insert Table",accelerator:"Ctrl+T",click:r(function(){File.editor.tableEdit.insertTable()},!0)},{type:"separator"},{label:"Add Row Above",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!0)},!0)},{label:"Add Row Below",accelerator:"Ctrl+Return",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!1)},!0)},{type:"separator"},{label:"Add Column Before",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{label:"Add Column After",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{type:"separator"},{label:"Move Row Up",enabled:!1,accelerator:"Alt+Up",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!0)},!0)},{label:"Move Row Down",enabled:!1,accelerator:"Alt+Down",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!1)},!0)},{label:"Move Column Left",enabled:!1,accelerator:"Alt+Left",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!0)},!0)},{label:"Move Column Right",enabled:!1,accelerator:"Alt+Right",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!1)},!0)},{type:"separator"},{label:"Delete Row",enabled:!1,accelerator:"Shift+Ctrl+Backspace",click:r(function(){File.editor.tableEdit.deleteRow()},!0)},{label:"Delete Column",enabled:!1,click:r(function(){File.editor.tableEdit.deleteCol()},!0)},{type:"separator"},{label:"Copy Table",enabled:!1,click:r(function(){File.editor.tableEdit.copyTable()},!0)},{label:"Prettify Source Code",enabled:!1,click:r(function(){File.editor.tableEdit.reformatTable()},!0)},{type:"separator"},{label:"Delete Table",enabled:!1,click:r(function(){File.editor.tableEdit.deleteTable()},!0)}]},{label:"Code Fences",type:"checkbox",accelerator:"Ctrl+Shift+K",click:r(function(){File.editor.stylize.toggleFences()},!0)},{label:"Math Block",type:"checkbox",accelerator:"Ctrl+Shift+M",click:r(function(){File.editor.stylize.toggleMathBlock()},!0)},{type:"separator"},{label:"Quote",type:"checkbox",accelerator:"Ctrl+Shift+Q",click:r(function(){File.editor.stylize.toggleIndent("blockquote")},!0)},{type:"separator"},{label:"Ordered List",type:"checkbox",accelerator:"Ctrl+Shift+[",click:r(function(){File.editor.stylize.toggleIndent("ol")},!0)},{label:"Unordered List",type:"checkbox",accelerator:"Ctrl+Shift+]",click:r(function(){File.editor.stylize.toggleIndent("ul")},!0)},{label:"Task List",type:"checkbox",accelerator:"Ctrl+Shift+X",click:r(function(){File.editor.stylize.toggleIndent("tasklist")},!0)},{label:"Task Status",submenu:[{label:"Toggle Task Status",click:r(function(){File.editor.stylize.toggleTaskStatus()},!0)},{type:"separator"},{label:"Mark as Complete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!0)},!0)},{label:"Mark as Incomplete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!1)},!0)}]},{label:"List Indentation",submenu:[{label:"Indent",accelerator:"CmdOrCtrl+]",click:r(function(){File.editor.UserOp.moreIndent(File.editor)},!0)},{label:"Outdent",accelerator:"CmdOrCtrl+[",click:r(function(){File.editor.UserOp.lessIndent(File.editor)},!0)}]},{type:"separator"},{label:"Insert Paragraph Before",click:r(function(){File.editor.UserOp.insertParagraph(!0)},!0)},{label:"Insert Paragraph After",click:r(function(){File.editor.UserOp.insertParagraph(!1)},!0)},{type:"separator"},{label:"Link Reference",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_link")},!0)},{label:"Footnotes",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_footnote")},!0)},{type:"separator"},{label:"Horizontal Line",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("hr")},!0)},{label:"Table of Contents",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("toc")},!0)},{label:"YAML Front Matter",type:"checkbox",click:r(function(){File.editor.stylize.insertMetaBlock()},!0)}]}),p({label:"F&ormat",submenu:[{label:"Strong",type:"checkbox",accelerator:"CmdOrCtrl+B",click:r(function(){File.editor.stylize.toggleStyle("strong")},!0)},{label:"Emphasis",type:"checkbox",accelerator:"CmdOrCtrl+I",click:r(function(){File.editor.stylize.toggleStyle("em")},!0)},{label:"Underline",type:"checkbox",accelerator:"CmdOrCtrl+U",click:r(function(){File.editor.stylize.toggleStyle("underline")},!0)},{label:"Code",type:"checkbox",accelerator:"CmdOrCtrl+Shift+`",click:r(function(){File.editor.stylize.toggleStyle("code")},!0)},{type:"separator"},{label:"Inline Math",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("inline_math")},!0)},{label:"Strike",type:"checkbox",accelerator:"Alt+Shift+5",click:r(function(){File.editor.stylize.toggleStyle("del")},!0)},{label:"Highlight",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("highlight")},!0)},{label:"Superscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("superscript")},!0)},{label:"Subscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("subscript")},!0)},{label:"Comment",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("comment")},!0)},{type:"separator"},{label:"Hyperlink",type:"checkbox",accelerator:"Ctrl+K",click:r(function(){File.editor.stylize.toggleStyle("link")},!0)},{label:"Hyperlink Actions",submenu:[{label:"Open Link",click:r(function(){File.editor.openCurrentLink()},!0)},{label:"Copy Link Address",click:r(function(){File.editor.copyCurrentLink()},!0)}]},{label:"Image",submenu:[{label:"Insert Image",accelerator:"CmdOrCtrl+Shift+I",click:r(function(){File.editor.stylize.toggleStyle("image")},!0)},{label:"Insert Local Images…",click:r(function(){File.editor.imgEdit.insertLocalImage()},!0)},{type:"separator"},{label:"Open Image Location…",click:r(function(){File.editor.imgEdit.revealInFinder()},!0)},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Zoom Image",submenu:[{label:"25%",click:r(function(){File.editor.imgEdit.zoomAction(null,"25%")},!0)},{label:"33%",click:r(function(){File.editor.imgEdit.zoomAction(null,"33%")},!0)},{label:"50%",click:r(function(){File.editor.imgEdit.zoomAction(null,"50%")},!0)},{label:"67%",click:r(function(){File.editor.imgEdit.zoomAction(null,"67%")},!0)},{label:"80%",click:r(function(){File.editor.imgEdit.zoomAction(null,"80%")},!0)},{type:"separator"},{label:"100%",click:r(function(){File.editor.imgEdit.zoomAction(null,"100%")},!0)},{type:"separator"},{label:"150%",click:r(function(){File.editor.imgEdit.zoomAction(null,"150%")},!0)},{label:"200%",click:r(function(){File.editor.imgEdit.zoomAction(null,"200%")},!0)}]},{label:"Switch Image Syntax",submenu:[{label:"Markdown Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!1)},!0)},{label:"HTML Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!0)},!0)}]},{type:"separator"},{label:"Delete Image File",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.deleteImageAction(true)")}},{type:"separator"},{label:"Copy Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction()},!0)},{label:"Rename or Move Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction(!0)},!0)},{label:"Upload Image",click:r(function(){File.editor.imgEdit.uploadAction()},!0)},{type:"separator"},{label:"Copy All Images to…",click:r(function(){File.editor.imgEdit.copyAllImages()},!0)},{label:"Move All Images to…",click:r(function(){File.editor.imgEdit.moveAllImages()},!0)},{label:"Upload All Local Images",click:r(function(){File.editor.imgEdit.uploadAllImages()},!0)},{type:"separator"},{label:"Reload All Images",click:r(function(){File.editor.imgEdit.reloadAllByNode()},!0)},{type:"separator"},{label:"When Insert Local Image",submenu:[{label:"Copy Image File to Folder…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleCopyToFolder()},!0)},{label:"Upload Image",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUploadForFile()},!0)}]},{label:"Use Image Root Path…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUseImageRootPath()},!0)},{type:"separator"},{label:"Global Image Settings…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('image-setting-group');")}}]},{type:"separator"},{label:"Clear Format",type:"checkbox",accelerator:"CmdOrCtrl+\\",click:r(function(){File.editor.stylize.clearStyle()},!0)}]}),p({label:"&View",submenu:[{label:"Toggle Sidebar",accelerator:"CmdOrCtrl+Shift+L",click:r(function(){File.editor.library.toggleSidebar()},!0)},{label:"Outline",type:"checkbox",accelerator:"CmdOrCtrl+Shift+1",click:r("toggleOutline")},{label:"Articles",type:"checkbox",accelerator:"CmdOrCtrl+Shift+2",click:r("toggleFileList")},{label:"File Tree",type:"checkbox",accelerator:"CmdOrCtrl+Shift+3",click:r("toggleFileTree")},{label:"Search",type:"checkbox",accelerator:"CmdOrCtrl+Shift+F",click:r("globalSearch")},{type:"separator"},{label:"Source Code Mode",type:"checkbox",accelerator:"CmdOrCtrl+/",click:r(function(){File.toggleSourceMode()},!0)},{type:"separator"},{label:"Focus Mode",type:"checkbox",accelerator:"F8",click:r(function(){File.editor.toggleFocusMode()},!0),enabled:!1},{label:"Typewriter Mode",type:"checkbox",accelerator:"F9",click:r(function(){File.editor.toggleTypeWriterMode()},!0),enabled:!1},{type:"separator"},{label:"Show Status Bar",type:"checkbox",click:r("toggleStatusBar")},{type:"separator"},{label:"Toggle Fullscreen",accelerator:"F11",click:function(e,t){t&&(t.isFullScreen()?t.setFullScreen(!1):t.setFullScreen(!0))}},{label:"Always on Top",type:"checkbox",click:function(e,t){t&&(k(function(){document.body.classList.toggle("always-on-top")},!0),t.setAlwaysOnTop(!t.isAlwaysOnTop()),e.checked=t.isAlwaysOnTop())}},{type:"separator"},{label:"Actual Size",type:"checkbox",accelerator:d?"Ctrl+Shift+9":"Ctrl+Shift+0",click:function(e,t){v(function(){ClientCommand.resetZoom()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom In",accelerator:"Ctrl+Shift+=",click:function(e,t){v(function(){ClientCommand.zoomIn()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom Out",accelerator:"Ctrl+Shift+-",click:function(e,t){v(function(){ClientCommand.zoomOut()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{type:"separator"},{label:"Switch Between Opened Documents",accelerator:"Ctrl+Tab",click:function(e,t){var n;!t||-1!=(t=(n=m.getAllWindows()).indexOf(t))&&n[t=++t>=n.length?0:t].focus()}},{type:"separator"},{label:"Toggle DevTools",accelerator:"Shift+F12",click:function(e,t){var n;t&&(n=setTimeout(t.webContents.openDevTools,2e3),t.webContents.executeJavaScript("ClientCommand.toggleDevTools()").then(function(){clearTimeout(n)},function(){clearTimeout(n),t.webContents.openDevTools()}))}}]}),p({label:"&Themes",submenu:[]}),p({label:"&Help",submenu:[{label:"What's New…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/What's-New/`)}},{type:"separator"},{label:"Quick Start",click:function(e,t){l.openFile(u+"/Docs/Quick Start.md")}},{label:"Markdown Reference",click:function(e,t){l.openFile(u+"/Docs/Markdown Reference.md")}},{label:"Install and Use Pandoc",click:function(e,t){l.openFile(u+"/Docs/Install and Use Pandoc.md")}},{label:"Custom Themes",click:function(e,t){l.openFile(u+"/Docs/Custom Themes.md")}},{label:"Use Images in Typora",click:function(e,t){l.openFile(u+"/Docs/Use Images in Typora.md")}},{label:"Data Recovery and Version Control",click:function(e,t){l.openFile(u+"/Docs/Auto Save, Version Control and Recovery.md")}},{label:"More Topics…",click:function(e,t){var n=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal("https://support."+n)}},{type:"separator"},{label:"Credits",click:function(e,t){l.openFile(u+"/Docs/Credits.md")}},{label:"Change Log",click:function(e,t){l.openFile(u+"/Docs/Change Log.md")}},{label:"Privacy Policy",click:function(e,t){l.openFile(u+"/Docs/Privacy Policy.md")}},{label:"Website",click:function(){var e=l.setting.get("useMirrorInCN")?"https://typoraio.cn":"https://typora.io";a.shell.openExternal(e)}},{label:"Feedback",click:function(e,t){a.shell.openExternal("mailto:hi@typora.io")}},{type:"separator"},{label:"Check Updates…",click:function(){d&&l.updater.checkForUpdates(!0)},visible:d},{label:"My License…",click:function(){y.showLicensePanel()}},global.PRODUCTION_MODE?null:{label:"Welcome…",click:function(){y.showWelcomePanel()}},{label:"About",click:r(function(){File.megaMenu.closePreferencePanel(),document.body.classList.contains("native-window")?($(".modal:not(.block-modal)").modal("hide"),$("#about-dialog").modal("show"),$("*:focus").blur()):(File.megaMenu.show(),$("#m-about").trigger("click"))},!0)}]})];d||t[0].submenu.splice(t[0].submenu.indexOf(null),1),l.isEmojiPanelSupported()&&(t[1].submenu.push({type:"separator"}),t[1].submenu.push(p({label:"Emoji and Symbols",accelerator:d?"Super+.":"",click:function(){l.showEmojiPanel()}})));const i=t[t.length-1].submenu;for(;-1{"use strict";var a=c(93).EventEmitter,n=c(134),t=n.ipcMain,d=n.app,r=c(728),l="linux"==process.platform,s=c(541).join(__dirname,"../"),g=c(445),u=c(156),m=c(359).default,f=c(477),w=c(824),b=c(587),p=new a,o=["Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2"],h="64";"ia32"==process.arch&&(h="32"),"arm64"==process.arch&&(h="arm"),p.initUpdater=function(){return u.initDict().then(function(){return o.forEach(function(e,t){o[t]=u.getPanelString(e)}),Promise.resolve()})},p.showDetailWindow=function(e,t,n){p.progressBar&&(p.progressBar.close(),p.progressBar=null),p.win&&(p.win.destroy(),p.win=null);e=b.showPanelWindow({title:u.getPanelString("Updater"),width:640,height:600,path:"updater/updater.html?curVersion=$1&newVersion=$2&labels=$3&enableAutoUpdate=$4&releaseNoteLink=$5&hideAutoUpdates=$6".replace("$1",e).replace("$2",t).replace("$3",encodeURIComponent(JSON.stringify(o))).replace("$4",JSON.stringify(!1!==d.setting.get("enableAutoUpdate"))).replace("$5",encodeURIComponent(n)).replace("$6",global.devVersion&&!g.getHasLicense())});(p.win=e).on("closed",function(){p.win=null})},p.showUI=function(){p.win||p.progressBar||(p.progressBar=new f({title:u.getPanelString("Updater"),text:u.getPanelString("Checking Updates…"),indeterminate:!0,style:{text:{padding:"3px 0"}},browserWindow:{closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}}))};p.checkForUpdates=async function(t){var e,n,o,i=d.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",i=global.devVersion||d.setting.get("autoUpdateToDev")?`https://${i}/releases/dev_windows_${h}.json`:`https://${i}/releases/windows_${h}.json`;if(i){if(p.emit("checking-for-update"),t)p.showUI();else if((e=d.setting.get("cancelUpdate"))&&new Date-new Date(e)<432e5)return;try{var r=await m(i);if(204==r.status)return void p.emit("update-not-available");if(200!=r.status)return p.emit("update-not-available"),console.error("invalid status code: "+r.statusCode+" from "+i),"Failed to check updates, invalid status code: "+r.status;var a=await r.json(),l=(n=a,o=c(842).release().replace(/\.[^.]+$/,""),a=(o=(n.alternatives||{})[o])?Object.assign(n,o):n,p.data=a,d.getVersion());if(!a.version||!l)return;if(!(0{e||(console.log(t),p.installPathOnQuit=t,d.quit())})},p.installIfNeeded=function(){p.installPathOnQuit&&p.install(p.installPathOnQuit)},p.install=function(e){c(620).spawn(e,["/SILENT"],{detached:!0,stdio:["ignore","ignore","ignore"]}).unref()},t.handle("updater.checkForUpdates",(e,t)=>{p.checkForUpdates(t)}),t.handle("updater.cancelUpdate",e=>{p.cancelUpdate()}),t.handle("updater.skipUpdate",e=>{p.skipUpdate()}),t.handle("updater.downloadUpdate",e=>{p.downloadUpdate()}),e.exports=p},620:e=>{"use strict";e.exports=require("child_process")},289:e=>{"use strict";e.exports=require("crypto")},134:e=>{"use strict";e.exports=require("electron")},554:e=>{"use strict";e.exports=require("electron-dl")},359:e=>{"use strict";e.exports=require("electron-fetch")},477:e=>{"use strict";e.exports=require("electron-progressbar")},93:e=>{"use strict";e.exports=require("events")},834:e=>{"use strict";e.exports=require("extract-zip")},833:e=>{"use strict";e.exports=require("fs")},728:e=>{"use strict";e.exports=require("fs-extra")},232:e=>{"use strict";e.exports=require("fs-plus")},338:e=>{"use strict";e.exports=require("hjson")},783:e=>{"use strict";e.exports=require("lowdb")},207:e=>{"use strict";e.exports=require("lowdb/adapters/FileSync")},640:e=>{"use strict";e.exports=require("module")},560:e=>{"use strict";e.exports=require("node-machine-id")},842:e=>{"use strict";e.exports=require("os")},541:e=>{"use strict";e.exports=require("path")},208:e=>{"use strict";e.exports=require("process")},468:e=>{"use strict";e.exports=require("raven")},426:e=>{"use strict";e.exports=require("url")},266:e=>{"use strict";e.exports=require("util")}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;t=o[e]={id:e,loaded:!1,exports:{}};return n[e](t,t.exports,i),t.loaded=!0,t.exports}i.c=o,i.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);i(i.s=90)})(); \ No newline at end of file diff --git a/Linux_x64/dec_app/head.json b/Linux_x64/dec_app/head.json index 09314c7..a929317 100644 --- a/Linux_x64/dec_app/head.json +++ b/Linux_x64/dec_app/head.json @@ -1 +1 @@ -{"files": {"atom.js": {"size": 172972, "offset": "0", "integrity": {"algorithm": "SHA256", "hash": "0e755100a549f5214f8c7df1c122178e38260c4fb7323700b19bc6d1ce3cb3de", "blockSize": 4194304, "blocks": ["0e755100a549f5214f8c7df1c122178e38260c4fb7323700b19bc6d1ce3cb3de"]}}, "main.node": {"size": 505368, "unpacked": true, "integrity": {"algorithm": "SHA256", "hash": "a07239c59161287afc47c03079d1f7a68e416c0fd91738f82f43031f83803c0b", "blockSize": 4194304, "blocks": ["a07239c59161287afc47c03079d1f7a68e416c0fd91738f82f43031f83803c0b"]}}, "package.json": {"size": 245, "offset": "172972", "integrity": {"algorithm": "SHA256", "hash": "dc658429b9fc0b6c81a33ddf7b48eb5b4c8ec11a6257761c61826d67d72e633c", "blockSize": 4194304, "blocks": ["dc658429b9fc0b6c81a33ddf7b48eb5b4c8ec11a6257761c61826d67d72e633c"]}}}} \ No newline at end of file +{"files": {"atom.js": {"size": 172972, "offset": "0", "integrity": {"algorithm": "SHA256", "hash": "8472c8c4b7f95bbec1622ea73e16dee806e822a98771731146742cf5266f0f66", "blockSize": 4194304, "blocks": ["8472c8c4b7f95bbec1622ea73e16dee806e822a98771731146742cf5266f0f66"]}}, "main.node": {"size": 505368, "unpacked": true, "integrity": {"algorithm": "SHA256", "hash": "a07239c59161287afc47c03079d1f7a68e416c0fd91738f82f43031f83803c0b", "blockSize": 4194304, "blocks": ["a07239c59161287afc47c03079d1f7a68e416c0fd91738f82f43031f83803c0b"]}}, "package.json": {"size": 245, "offset": "172972", "integrity": {"algorithm": "SHA256", "hash": "2303353d94a1f5338cb1d0ead2a99624f2fe4c9013523286f8915fb3202476f6", "blockSize": 4194304, "blocks": ["2303353d94a1f5338cb1d0ead2a99624f2fe4c9013523286f8915fb3202476f6"]}}}} \ No newline at end of file diff --git a/Linux_x64/dec_app/package.json b/Linux_x64/dec_app/package.json index 028e3b5..510b3dc 100644 --- a/Linux_x64/dec_app/package.json +++ b/Linux_x64/dec_app/package.json @@ -1,11 +1,11 @@ { "name": "Typora", - "version": "1.5.6", + "version": "1.5.8", "main": "main.node", "family": "abnerworks", "private": true, "author": "typora.io", "homepage": "https://typora.io", "concat": "hi@typora.io", - "releaseId": "2c58e870" + "releaseId": "182719c8" } \ No newline at end of file diff --git a/README-CN.md b/README-CN.md index 327fc29..fae1dea 100644 --- a/README-CN.md +++ b/README-CN.md @@ -2,7 +2,7 @@ | 大版本 | 推荐下载版本 | | ---------- | ------------------------------------------------------------ | -| v1.5.x | [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.5.6/total?label=%E4%B8%8B%E8%BD%BD%40v1.5.6&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.5.6) [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.5.5/total?label=%E4%B8%8B%E8%BD%BD%40v1.5.5&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.5.5) | +| v1.5.x | [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.5.8/total?label=%E4%B8%8B%E8%BD%BD%40v1.5.8&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.5.8) [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.5.5/total?label=%E4%B8%8B%E8%BD%BD%40v1.5.5&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.5.5) | | v1.5.x-dev | [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.5.3-dev/total?label=%E4%B8%8B%E8%BD%BD%40v1.5.3-dev&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.5.3-dev) | | v1.4.x | [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.4.8/total?label=%E4%B8%8B%E8%BD%BD%40v1.4.8&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.4.8) [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.4.4/total?label=%E4%B8%8B%E8%BD%BD%40v1.4.4&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.4.4) | | v1.4.x-dev | [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.4.1-dev/total?label=%E4%B8%8B%E8%BD%BD%40v1.4.1-dev&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.4.1-dev) | @@ -16,7 +16,7 @@ # TxxxxxGreen -基于 txxxxxCracker 仓库,并独自研发生成的用于绿化 Txxxxx v1.1 (最新支持 v1.5.6/v1.5.3-dev) 版本及以上的一些文件。View the **English** version of Readme, please click [here](./README.md). +基于 txxxxxCracker 仓库,并独自研发生成的用于绿化 Txxxxx v1.1 (最新支持 v1.5.8/v1.5.3-dev) 版本及以上的一些文件。View the **English** version of Readme, please click [here](./README.md). @@ -97,6 +97,7 @@ | Typora 版本 | Windows 64位 | Windows 32位 | Windows Arm | Linux 64位 | Linux Arm | MacOS | | :------------: | :---------: | :---------: | :--------------: | :-------: | :--------------: | :---: | +| v1.5.8 | √ | √ | × | √ | × | × | | v1.5.6 | √ | √ | × | √ | × | × | | v1.5.5 | √ | √ | × | √ | × | × | | v1.5.4-dev | --- | --- | --- | --- | --- | × | @@ -138,6 +139,7 @@ | Timeline | Actions | | --------- |-------------------------------------------------------------------------| +| 2023.2.15 | 增加了对 Windows 32/64 位,Linux 64 位系统 1.5.8 版本的支持 | | 2023.2.12 | 增加了对 Windows 32/64 位,Linux 64 位系统 1.5.6 版本的支持 | | 2023.2.4 | 增加了对 Windows 32/64 位,Linux 64 位系统 1.5.5 版本的支持 | | 2023.2.4 | 增加了对 Windows 64 位,Linux 64 位系统 1.5.3-dev 版本的支持 | diff --git a/README.md b/README.md index 93c5abc..662bce8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ | Upgrade | Recommend Release Version | | ------------ | ------------------------------------------------------------ | -| v1.5.x | [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.5.6/total?label=Download%40v1.5.6&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.5.6) [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.5.5/total?label=Download%40v1.5.5&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.5.5) | +| v1.5.x | [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.5.8/total?label=Download%40v1.5.8&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.5.8) [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.5.5/total?label=Download%40v1.5.5&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.5.5) | | v1.5.x-dev | [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.5.3-dev/total?label=Download%40v1.5.3-dev&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.5.3-dev) | | v1.4.x | [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.4.8/total?label=Download%40v1.4.8&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.4.8) [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.4.4/total?label=Download%40v1.4.4&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.4.4) | | v1.4.x-dev | [![GitHub release (by tag)](https://img.shields.io/github/downloads/Delppine1024/TGreen/v1.4.1-dev/total?label=Download%40v1.4.1-dev&style=flat)](https://github.com/Delppine1024/TGreen/releases/tag/v1.4.1-dev) | @@ -16,7 +16,7 @@ # TxxxxxGreen -Some crack files work well on Txxxxx v1.1 (The latest support v1.5.6/v1.5.3-dev), Based on txxxxxCracker. 查看 **中文** 文档请戳 [这里](./README-CN.md). +Some crack files work well on Txxxxx v1.1 (The latest support v1.5.8/v1.5.3-dev), Based on txxxxxCracker. 查看 **中文** 文档请戳 [这里](./README-CN.md). @@ -90,6 +90,7 @@ ANY PROBLEMS ARISING FROM THIS WILL BE BORNE BY THE USER. | Typora Version | Windows X64 | Windows X86 | Windows Arm | Linux X64 | Linux Arm | MacOS | | :------------: | :---------: | :---------: | :--------------: | :-------: | :--------------: | :---: | +| v1.5.8 | √ | √ | × | √ | × | × | | v1.5.6 | √ | √ | × | √ | × | × | | v1.5.5 | √ | √ | × | √ | × | × | | v1.5.4-dev | --- | --- | --- | --- | --- | × | @@ -131,6 +132,7 @@ ANY PROBLEMS ARISING FROM THIS WILL BE BORNE BY THE USER. | Timeline | Actions | | ---------- | ------------------------------------------------------------ | +| 2023.2.15 | Add support for v1.5.8 on Windows x86/x64, Linux x64 | | 2023.2.12 | Add support for v1.5.6 on Windows x86/x64, Linux x64 | | 2023.2.4 | Add support for v1.5.5 on Windows x86/x64, Linux x64 | | 2023.2.4 | Add support for v1.5.3-dev on Windows x64, Linux x64 | diff --git a/Windows_x64/app.asar b/Windows_x64/app.asar index ecca300..8c437c4 100644 Binary files a/Windows_x64/app.asar and b/Windows_x64/app.asar differ diff --git a/Windows_x64/dec_app/atom.js b/Windows_x64/dec_app/atom.js index f79a010..0ce6adc 100644 --- a/Windows_x64/dec_app/atom.js +++ b/Windows_x64/dec_app/atom.js @@ -1,2 +1,2 @@ module.exports= function(k){}; -(()=>{var n={883:(t,n,a)=>{var s=a(134),c=s.app,e=s.ipcMain,d=s.BrowserWindow,u="win32"==process.platform,p="linux"==process.platform,r=a(156),i=a(344);n.bindJumplist=()=>{var t;u&&(t=[{type:"custom",name:"Recent Locations",items:c.setting.getRecentFolders().slice(0,5).map(function(e){return{type:"task",title:e.name,description:e.path,program:process.execPath,args:JSON.stringify(e.path),iconPath:"explorer.exe",iconIndex:0}})},{type:"recent"},{type:"tasks",items:[{type:"task",program:process.execPath,arguments:"--new",iconPath:process.execPath,iconIndex:0,title:"New"}]}],c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t),i.loadDict().then(e=>{t[0].name=e["Recent Locations"]||"Recent Locations",t[2].items[0].title=e.New||"New",c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t)}))},e.handle("shell.saveItem",(e,{path:n,data:o})=>new Promise(t=>{a(833).writeFile(n,o,function(e){t()})})),e.handle("shell.openItem",(e,t)=>s.shell.openPath(a(541).normalize(t))),e.handle("shell.trashItem",async(e,t)=>{try{return await s.shell.trashItem(t),!0}catch(e){return!1}}),e.handle("shell.openExternal",(e,t)=>{if("about:blank"!=t)return s.shell.openExternal(t)}),e.handle("shell.showItemInFolder",(e,t)=>(u&&(t=t.replace(/\//g,"\\")),s.shell.showItemInFolder(t))),e.handle("shell.showDownload",(e,t)=>{e=d.fromWebContents(e.sender);const n=a(554)["download"];n(e,t,{saveAs:!0})}),e.handle("dialog.showMessageBox",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showMessageBox(p?null:e,t)}),e.handle("dialog.showSaveDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showSaveDialog(p?null:e,t)}),e.handle("dialog.showOpenDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showOpenDialog(p?null:e,t)}),e.handle("dialog.showOpenDialogAlone",(e,t)=>s.dialog.showOpenDialog(t));const h=t=>new Promise(e=>{setTimeout(()=>{e("sleep")},t)}),m=async(e,t)=>{var n=new d({skipTaskbar:!0,title:"Print PDF Preview",show:!1,webPreferences:{webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!1,nodeIntegration:!1,safeDialogs:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,zoomFactor:+(c.setting.get("zoomFactor")||"1"),backgroundThrottling:!1}});try{var o,i,r=t?(console.log("load file ["+t+"] for PDF export"),n.loadFile(t)):(o=a(541).join(c.setting.tempPath||c.getPath("temp"),+new Date+"tmp.html"),i=a(728),console.log("write output to temp file ["+o+"] for PDF export"),await i.outputFile(o,e),n.loadFile(o))}catch(e){return console.error(e),n&&n.destroy(),null}return Promise.race([h(2e4),r]).then(e=>"sleep"===e?(l(n.id),console.warn("Timeout for loading print view"),null):n.id).catch(e=>(console.error(e),n&&n.destroy(),null))},l=(e.handle("export.genPrintView",(e,t,n)=>(n&&l(n),m(null,t))),e=>{e=d.fromId(e);e&&(e.isDestroyed()||e.destroy())});e.handle("export.destroyPrintView",(e,t)=>{l(t)}),e.handle("export.getPageColor",async(e,t)=>{try{var n=await m(null,t);if(console.log("generate print preview window with id "+n),!n)return null;printWin=d.fromId(n),await h(200);var o=await printWin.webContents.executeJavaScript("window.getComputedStyle(document.body).backgroundColor")}catch(e){console.error(e)}finally{printWin&&printWin.destroy()}return o}),e.handle("export.print",(e,n,o)=>{var i=d.fromId(n);o=o||{},i.webContents.print(o,(e,t)=>{if(!e&&!/cancel/.exec(t||"")){if("no valid printers available"===t)return void i.webContents.executeJavaScript("window.print()").then(()=>{o.skipCleanUp||l(n)});s.dialog.showMessageBox({type:"error",message:r.getPanelString("Error"),detail:t,buttons:["OK"]})}o.skipCleanUp||l(n)})}),e.handle("export.printToPDF",async(e,t,n)=>{let o=null,i=null,r=null,a="";try{var l=await m(null,t);if(console.log("generate print window with id "+l),!l)return[i,r];o=d.fromId(l),await h(200),i=await o.webContents.printToPDF(n),console.log("get PDF data");var s=`(${function(){var e=document.querySelector("#write");return e?{color:(e=window.getComputedStyle(e)).color,fontFamily:e.fontFamily,bgColor:e.backgroundColor}:null}.toString()})()`;r=(r=await o.webContents.executeJavaScript(s))&&JSON.stringify(r),console.log("get background color")}catch(e){a=e.message||"",console.error(e)}finally{o&&o.destroy()}return[i,r,a]});var f,o,g=u?8e3:960,w=1;function b(){console.log("updateTheme");var e=c.setting.curTheme(),t=(c.execInAll("window.ClientCommand && File.setTheme('"+e+"');"),e.replace(/\.css$/,"").replace(/(^|-|_)(\w)/g,function(e,t,n,o){return(t?" ":"")+n.toUpperCase()})),e=s.Menu.getApplicationMenu().getItem("Themes");e&&e.submenu.items.map(function(e){e.checked=e.label==t})}e.handle("export.prepareImageCapture",async(e,t,n)=>{var o,i=s.screen.getPrimaryDisplay();try{w=i.scaleFactor||1;var r=i.workArea;if(g=Math.min(g,r.height-20),f=n.imageWidth,await(o=new d({skipTaskbar:!0,show:!1,webPreferences:{devTools:!1,webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!0,nodeIntegration:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,safeDialogs:!0},webgl:!1,useContentSize:!0,x:r.x,y:r.y,width:n.imageWidth,height:g,frame:!1,enableLargerThanScreen:!!u,offscreen:!0,alwaysOnTop:!0,minimizable:!1,closable:!0})).loadURL("file:///"+t),o.isDestroyed())return null;if(await h(2e3),o.isDestroyed())return null;var a=+await o.webContents.executeJavaScript("window.innerHeight");if(o.isDestroyed())return null;var l=+await o.webContents.executeJavaScript("document.body.parentElement.scrollTop = document.body.clientHeight;\nMath.max(document.body.clientHeight, document.body.parentElement.scrollHeight)");return o.isDestroyed()?null:Number.isNaN(l)||Number.isNaN(a)?void 0:(p&&(g=a),{winId:o.id,totalHeight:l,pageHeight:g,imageWidth:n.imageWidth,scale:3===n.quality?w:1})}catch(e){return console.error(e),null==o||o.isDestroyed()||o.destroy(),null}}),e.handle("export.captureImage",async(e,t,n,o)=>{t=d.fromId(t);if(!t||t.isDestroyed())return null;try{o&&(t.setSize(o.imageWidth,o.pageHeight),t.setContentSize(o.imageWidth,o.pageHeight));var i=+await t.webContents.executeJavaScript("document.body.parentElement.scrollTop = {d}; document.body.parentElement.scrollHeight;".replace("{d}",n));if(await h(1e3),t.isDestroyed()||Number.isNaN(i))return null;var r=await t.webContents.capturePage();if(!r||r.isEmpty())return null;var a=null;return 1new Promise((t,e)=>{try{var n=s.net.request({url:o,redirect:"follow"});n.on("response",function(e){try{if(200!=e.statusCode)return t(null);if(!e.data)return t(null);t({type:(e.headers["content-type"]||[""])[0],data:e.data})}catch(e){t(null)}}),n.end()}catch(e){t(null)}})),e.handle("clipboard.write",(e,t,n)=>{n&&s.clipboard.clear(),s.clipboard.write(JSON.parse(t))}),e.handle("pandoc.import",(e,n)=>{var o={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"'":"\\'","\\":"\\\\"},e=d.fromWebContents(e.sender),t=n?Promise.resolve(e):c.openFile(null,{syncAndPrepOnly:!0}).then(n=>new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e(n.activeWindow)}):e(n.activeWindow)})),e=s.dialog.showOpenDialog(n?e:null,{title:i.getMenuDict.Import,properties:["openFile"],filters:[{name:r.getPanelString("All Supported Formats"),extensions:["docx","rtf","latex","tex","ltx","rst","rest","org","wiki","dokuwiki","mediawiki","textile","opml","epub"]},{name:"MS Word",extensions:["docx"]},{name:"RTF",extensions:["rtf"]},{name:"TeX/LaTeX",extensions:["latex","tex","ltx"]},{name:"reStructuredText",extensions:["rst","rest"]},{name:"org-mode",extensions:["org"]},{name:"Wiki",extensions:["wiki","dokuwiki","mediawiki"]},{name:"Epub",extensions:["epub"]},{name:"Textile",extensions:["textile"]},{name:"OPML",extensions:["opml"]}]}).then(({filePaths:e})=>(e||[null])[0]);return Promise.all([t,e]).then(async([e,t])=>{t?(await h(100),e.show(),e.webContents.executeJavaScript('window.getSelection().removeAllRanges();ClientCommand.doImport("'+t.replace(/["'\\\b\t\n\f\r]/g,function(e){return o[e]}).replace(/\u200b/g,"")+'")')):n||e.destroy()})}),e.handle("pandoc.version",()=>o),e.handle("pandoc.setVersion",(e,t)=>{o=t}),s.nativeTheme.on("updated",function(){null!==c.setting.useDarkThemeBefore()&&c.setting.useDarkThemeBefore()!==c.setting.useDarkTheme()&&b()}),e.handle("theme.apply",()=>{b()}),e.handle("theme.setThemeSource",(e,t)=>{"system"!==(t=t||"system")&&c.setting.get("useSeparateDarkTheme")||(s.nativeTheme.themeSource=t)}),e.on("ondragstart",function(t,n,o){setTimeout(function(){var e=s.nativeImage;t.sender.startDrag({file:n,icon:o?e.createFromPath(a(541).normalize(o)):e.createEmpty()}),console.log("ondragstart "+n+" "+o)},100)}),e.handle("getPath",(e,t)=>c.getPath(t))},156:(e,t,n)=>{var o=n(134).app,i=n(728),r=n(541).join(__dirname,"../"),a=["Operation Failed","Save As","All Supported Formats","Error","Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2","Updater","Checking Updates…","Downloading Updates…","You're up to date!","Check Update Failed","Download failed","Install Updates ?","Quit and Install","Cancel","Download","Downloading…","Extracting binary…","This dev version of Typora is expired, please download and install a newer version.","This device has been deactivated","Typora is now deactivated","UNREGISTERED"],l={},s=!1;e.exports={initDict:function(){if(s)return Promise.resolve();var e=n(541).join(r,o.setting.getLocaleFolder("Panel"));return i.readJSON(e,"utf8").then(function(t){s=!0,a.map(function(e){l[e]=t[e]||e})}).catch(function(){})},getPanelString:function(e){return l[e]||e}}},351:(r,l,c)=>{function d(e,t){this.activeWindow=t||null,this.windows=new Set(t),this.path=e||null,this.snap=null,this.lastSync,this.content,this.backupState=null}var e=c(134),u=e.app,a=e.BrowserWindow,s=(e.powerMonitor,c(728)),e=c(232),h=(c(266),process.platform,process.platform,"linux"==process.platform),g=c(468),m=c(587),t=c(134).ipcMain,o=(t.on("doc.syncChange",function(e,t){var n=a.fromWebContents(e.sender),o=u.documentController.getDocumentFromWindowId(n.id);n==o.activeWindow&&1=n}catch(e){console.warn(e)}return!1}},d.prototype.getWindowToFocus=function(){var e=this.activeWindow||this.windows.keys().next().value;if(e){if(!e.isDestroyed())return e;this.activeWindow=null,this.windows.delete(e)}return null},d.prototype.syncFullContent=function(t){var e,n=!1;if(this.windows.forEach(function(e){this.activeWindow!=e&&!n&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&(n=!0)}),n)return e=this.windows,this.activeWindow.webContents.executeJavaScript("File.sync(false, true);1;").then(function(){e.forEach(function(e){this.activeWindow!=e&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&e.webContents.executeJavaScript("File.editor.applyFullContent("+!!t+")")})}),null},d.prototype.popBackupState=async function(){var e=this.backupState;return this.backupState=void 0,Promise,e},function(e){return c(541).basename(e)}),f=e.isCaseInsensitive();function p(e){return f?e&&e.toLowerCase():e}function n(){this.documents=new Set,this.path2doc=new Map,this.win2doc=new Map,this.name2docs=new Map,this.frozenDocs=[],this.watchSystemPause()}n.prototype.watchSystemPause=function(){u.whenReady().then(()=>{})},n.prototype.setContentForWindow=function(e,t){var n=this.getDocumentFromWindowId(t);(n.activeWindow||{}).id==t&&n.setContent(e)},n.prototype.solveDuplicateName_=function(e){var t=e.path,t=p(o(t)),n=this.name2docs.get(t)||new Set;this.name2docs.set(t,n),0{e=a.fromWebContents(e.sender),t=t?u.getDocumentController().getDocument(t):u.documentController.getDocumentFromWindowId(e.id);t&&t.activeWindow==e&&t&&t.switchToUntitled(n)}),t.handle("document.setLastSync",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).setLastSync(t)}),t.handle("document.syncFullContent",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).syncFullContent(t)}),t.handle("document.getContent",e=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).getContent()}),t.handle("document.currentPath",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).path});const b=async e=>{var t=e.getSnap(null),n=e.path,o=!1,i=null;return(t||{}).nodeMap?o=await e.shouldReadFromDisk():i=await e.popBackupState(),i&&i.hasUnsaved?console.log("load from recover content length: "+i.content.length):i=null,JSON.stringify({snap:t,filePath:n,backups:i,shouldReadFromDisk:o,windowCounts:e.windows.size})};t.handle("document.loadData",async e=>{console.log("handle document.loadData");new Date;e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),e=await b(e);return new Date,e}),t.handle("document.switchDocument",async(e,t)=>{e=a.fromWebContents(e.sender),e=await u.getDocumentController().switchDocument(e.id,t);return b(e)}),t.handle("document.rename",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).rename(t),!0}),t.handle("document.setContent",(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=e.content==t;return e.setContent(t),n}),t.handle("document.addSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return t?e.addSnap(JSON.parse(t)):e.addSnap(null),!0}),t.handle("document.addSnapAndLastSync",(e,t)=>{try{var n,o,i=a.fromWebContents(e.sender),r=u.documentController.getDocumentFromWindowId(i.id);t?({snap:n,lastSync:o}=JSON.parse(t),r.addSnap(n),r.setLastSync(o)):r.addSnap(null)}catch(e){console.error(e)}return!0}),t.handle("document.shouldSaveSnap",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).shouldSaveSnap()}),t.handle("document.getSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return JSON.stringify(e.getSnap(t))}),t.handle("document.getSnapWithValidation",async(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=await e.isSnapValid();return JSON.stringify({snap:e.getSnap(t),shouldReadFromDisk:0==n})}),t.handle("document.enterOversize",e=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);e&&e.enterOversize()}),t.handle("document.newWindow",e=>{3==u.setting.get("restoreWhenLaunch")?u.openFile(null,{mountFolder:u.setting.get("pinFolder"),silent:"pinFolder"}):u.openFile()}),t.handle("document.checkIfMoveOnSave",(e,t)=>{var e=a.fromWebContents(e.sender),n=u.documentController.getDocument(t);return!n&&((n=u.documentController.getDocumentFromWindowId(e.id)).rename(t),!0)}),t.handle("document.hasDuplicateName",(e,t)=>u.documentController.hasDuplicateName(t)),t.handle("document.noOtherWindow",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).windows.size<=1});var i=new n;r.exports=i},824:(e,t,s)=>{var c=s(728),d=s(541),u={title:"Download",text:"Downloading…",indeterminate:!1,initialValue:0,maxValue:1,closeOnComplete:!1,abortOnError:!1,style:{text:{padding:"3px 0"}},browserWindow:{modal:!1,closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}};function p(e){if(e<1024)return e+" B";var t=e/Math.pow(1024,1),e=e/Math.pow(1024,2);return e<1?(t+"").replace(/(\..)(.+)$/,"$1")+"KB":(e+"").replace(/(\..)(.+)$/,"$1")+"MB"}function n(e,t,n){this.onAbort=null,this.onSuccess=null,this.onError=null,this.downloadURL=e,this.dist=t,this.displayOption=n||{},this.progressBar=null,this.downloadItem=null}n.prototype.cancel=function(){if(this.downloadItem){try{this.downloadItem.cancel()}catch(e){}this.downloadItem=null}this.setCompleted(),this.onAbort&&this.onAbort()},n.prototype.setCompleted=function(){this.downloadItem=null,this.progressBar&&(this.progressBar.setCompleted(),this.progressBar.close(),this.progressBar=null)},n.prototype.download=function(){var e=s(477),t=s(554),n=this,o=this.downloadURL,i=this.dist,r=this.displayOption,a=new e(Object.assign({},u,r)),l=((this.progressBar=a).on("aborted",function(){n.cancel()}),d.dirname(i));Promise.all([new Promise(function(e){a.on("ready",e)}),c.ensureDir(l)]).then(function(){console.record("[downloader] downloading "+o,"DEBUG"),t.download(a._window,o,{showBadge:r.showBadge||!1,directory:l,filename:d.basename(i),onProgress:function(e){a&&(a.value=e.percent*(r.processOnComplete||1),a.detail=p(e.transferredBytes)+" / "+p(e.totalBytes))},onStarted:function(e){console.log("start downloading "+e.getURL()),n.downloadItem=e},onCancel:function(){console.log("canceled downloading "+downloadItem.getURL()),n.cancel()}}).then(function(e){n.onSuccess(e,a)}).catch(function(e){console.log("error downloading "+(n.downloadItem&&n.downloadItem.getURL())),n.onError(e)})})},e.exports=n},405:(e,t,n)=>{var n=n(134),o=n.app,n=n.ipcMain,i=global.t_workingDir,r=o.getVersion(),a=(/-([a-z]+)/.exec(r)||[])[1],l=r;function s(e,t){var n,o,i;for(e=(e||"").replace(/-[a-z]+/,""),t=(t||"").replace(/-[a-z]+/,""),e=e.split("."),t=t.split("."),o=Math.min(e.length,t.length),n=0;n({PRODUCTION_MODE:global.PRODUCTION_MODE,DEBUG_MODE:global.DEBUG_MODE,version:o.getVersion(),devVersion:global.devVersion})),global.compareVersion=s,global.t_workingDir=i,global.PRODUCTION_MODE=!0,global.DEBUG_MODE=!1},932:(e,t,n)=>{function o(){this.clearUndo()}function i(e){r.dialog.showErrorBox(l.getPanelString("Operation Failed"),e.message)}var r=n(134),a=r.app,l=n(156),s=n(728),n=r.ipcMain,c=(o.prototype.hasUndo=function(e){return!(!this.hasUndo_||!e)&&(0==(this.undoTo_||"").indexOf(e)||0==(this.undoFrom_||"").indexOf(e))},o.prototype.undoLabel=function(){return this.undoLabel_},o.prototype.clearUndo=function(){this.undoFrom_="",this.undoTo_="",this.undoLabel_="",this.hasUndo_=!1},o.prototype.registerUndo=function(e,t,n){this.undoFrom_=e,this.undoTo_=t,this.undoLabel_=n,this.hasUndo_=!0},o.prototype.getFocusPath=function(){return this.hasUndo_&&this.undoTo_},o.prototype.performUndo=function(){var t;function n(){r.dialog.showMessageBox({type:"warning",message:l.getPanelString("Operation Failed"),defaultId:0,cancelId:1,buttons:[l.getPanelString("Save As"),l.getPanelString("Cancel")]}).then(({response:e})=>{0==e?r.dialog.showSaveDialog({defaultPath:t.undoTo_,properties:["showOverwriteConfirmation"]}).then(({filePath:e})=>{e&&e!=t.undoFrom_&&s.rename(t.undoFrom_,e,function(e){e&&i(e)}),t.clearUndo()}):t.clearUndo()})}this.hasUndo_&&(this.hasUndo_=!1,(t=this).undoTo_?s.existsSync(this.undoTo_)?n():(a.sendEvent("willRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),s.copyFile(this.undoFrom_,this.undoTo_,function(e){s.unlink(t.undoFrom_,function(){}),e?(n(),a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoFrom_})):(a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),t.clearUndo())})):s.remove(this.undoFrom_,function(e){e?i(e):(t.clearUndo(),a.sendEvent("updateQuickOpenCache",{toDel:this.undoFrom_}))}))},new o);n.handle("filesOp.registerUndo",(e,t,n,o)=>{c.registerUndo(t,n,o)}),n.handle("filesOp.clearUndo",e=>{c.clearUndo()}),n.handle("filesOp.performUndo",e=>{c.performUndo()}),n.handle("filesOp.getFocusPath",e=>c.getFocusPath()),n.handle("filesOp.undoLabel",(e,t)=>c.hasUndo(t)?c.undoLabel():null),t.default=c},445:(o,u,i)=>{i(405);var p,h=i(156),g=i(134),m=g.shell,l=g.app,e=g.ipcMain,f=g.BrowserWindow,w="win32"==process.platform,b="darwin"==process.platform,y="linux"==process.platform,v=i(587),k=i(359).default,s=i(468),C=!1;const F=function(e){try{return require(e)}catch(e){if(C)return;C=!0;var t=e.message;setTimeout(()=>{C=!1,(dialog=i(134).dialog).showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:"A required module cannot be loaded by Typora",message:t.split("\n")[0]+"\n\nPlease check if that file exists or reinstall Typora to fix."}).then(({})=>{process.exit(1)})},1500)}};var S,r=null,x="",c="",a="",D="";const T={SUCCESS:0,OUT_OF_LIMIT:1,INVALIDATE:-1,WRONG_USER:-2},P=JSON.parse(Buffer.from("WyItLS0tLUJFR0lOIFBVQkxJQyBLRVktLS0tLSIsIk1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBN25Wb0dDSHFJTUp5cWdBTEVVcmMiLCI1SkpoYXAwK0h0SnF6UEUwNHB6NHkrbnJPbVk3LzEyZjNIdlp5eW9Sc3hLZFhUWmJPMHdFSEZJaDBjUnFzdWFKIiwiUHlhT09QYkEwQnNhbG9mSUFZM21SaFFRM3ZTZitybjNnK3cwUyt1ZFdtS1Y5RG5tSmxwV3FpekZhalU0VC9FNCIsIjVaZ01OY1h0M0UxaXBzMzJyZGJUUjBObmVuOVBWSVR2cmJKM2w2Q0kyQkZCSW1aUVoyUDhOK0xzcWZKc3F5VlYiLCJ3RGt0M21IQVZ4VjdGWmJmWVdHKzhGRFN1S1FIYUNtdmdBdENoeDlod2wzSjZSZWtrcURWYTZHSVYxM0QyM0xTIiwicWRrMEpiNTIxd0ZKaS9WNlFBSzZTTEJpYnk1Z1lONnpRUTVSUXBqWHRSNTNNd3pUZGlBekdFdUtkT3RyWTJNZSIsIkR3SURBUUFCIiwiLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tIiwiIiwiIl0=","base64").toString("utf8")).join("\n"),I=864e5;var W="https://store.typora.io";const E=e=>{if(!e)return e;var t;try{t=Buffer.from(e,"base64");const n=i(289).publicDecrypt(P,t);return JSON.parse(n.toString("utf8"))}catch(e){return null}},O=function(){var e=Array.from(arguments);const t=i(289).createHash("sha256");return e.forEach(e=>{t.update(e)}),t.digest("base64")},_=()=>{const e=d().get("SLicense");if(!e)return null;var[t,n,o]=e.split("#"),t=E(t);return t&&t.fingerprint==a?(Object.assign(t,{failCounts:n,lastRetry:new Date(o)}),t):null},M=async e=>{console.log("writeInstallDate fromBTime="+e);var t=new Date;if(e)try{var n=await i(728).stat(l.getPath("userData")+"/profile.data"),t=new Date(n.birthtime);n.birthtime}catch(e){}e=(p=t).toLocaleDateString("en-US");return d().put("IDate",e),p};var L=null;const d=function(){var n;return L=null==L?w?function(){const o=F("native-reg"),i="Software\\Typora";return{get:function(e){var t=o.openKey(o.HKCU,i,o.Access.READ);if(null==t)return"";e=o.getValue(t,null,e);return o.closeKey(t),e},put:function(e,t){var n=o.createKey(o.HKCU,i,o.Access.WRITE);o.setValueSZ(n,e,t),o.closeKey(n)}}}():(n=l.setting.prepDatabase(a),{put:function(e,t){console.log("ls put "+e),n.getState()[e]=t,n.write()},get:function(e){return n.getState()[e]}}):L};const U=async()=>{if(!a){if(w){const t=F("native-reg");var e=t.openKey(t.HKEY.LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Cryptography",t.Access.WOW64_64KEY|t.Access.READ);a=t.getValue(e,null,"MachineGuid"),t.closeKey(e)}else a=await i(560).machineId({original:!0});a||s.captureMessage("[L] Failed to get fingerPrint"),a=O(a,"typora").substr(0,10).replace(/[/=+-]/g,"a"),b&&(a+="darwin")}return a};var R=!1;const A=()=>{var e=s.getContext().tags;e.hasLicense=r,s.mergeContext(e)},N=()=>process.platform.replace(/\d+/,""),B=async(t,n,o)=>{oe(),console.log(`request ${W}/`+t);const e=new AbortController;var i,r=setTimeout(()=>e.abort(),3e4);try{i=await k(W+"/"+t,{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}}),clearTimeout(r)}catch(e){var a=e;if(console.warn(e.stack),clearTimeout(r),o&&"zh-Hans"==l.setting.getUserLocale()&&!l.setting.get("useMirrorInCN")){r=(await g.dialog.showMessageBox(null,{message:"链接服务器失败,使用尝试访问国内域名进行激活?",buttons:["确认","取消"]}))["response"];if(console.log("click "+r),r)throw a;return l.setting.put("useMirrorInCN",!0),B(t,n,!1)}if(l.setting.get("useMirrorInCN"))try{console.log("request to typora.com.cn"),i=await post("https://typora.com.cn/store/"+t,n)}catch(e){throw a}}if(i){if(200==i.status)return-1{const o=(new Date).toLocaleDateString("en-US");var{deviceId:t,lastRetry:i}=t||{};if(n||!(new Date-ir.abort(),4e4);const a=await(await k(W+"/api/client/renew",{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}})).json();clearTimeout(e),a.success||(console.warn("[renewL]: unfill due to renew fail"),$(a.msg)),d().put("SLicense",[a.msg,0,o].join("#"))}catch(e){e.stack,s.captureException(e,{level:"warning"}),console.warn("Failed to Renew L");var[t,n]=(i=d().get("SLicense")).split("#"),i=[t,n=+n+1,o].join("#");d().put("SLicense",i)}}},J=e=>{var t=new Date(d().get("IDate"));return isNaN(t.getTime())?e?null:new Date:e?t:(e=1675928631787,isNaN(e)?e=new Date("2021-10-01"):(e=new Date(e),isNaN(e.getTime())&&(e=new Date("2021-10-01"))),t{if(t=t||15,432e5{var e=(p=J(!global.devVersion))?V(!1):100;(15{R=!0;var t=_(),{license:n,email:o,type:i}=t||{};n&&o?(j(o,n,i),z(t,e)):$()},K=(e,t)=>g.dialog.showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:e,message:t}),Q=function(){l.expired=!0,K(h.getPanelString("Error"),h.getPanelString("This dev version of Typora is expired, please download and install a newer version.")).then(()=>{m.openExternal("https://typora.io/#download"),setTimeout(()=>{process.exit(1)},1e3)})},Z=function(){var e;re()&&!l.setting.inFirstShow&&(e=y||global.devVersion,y&&Math.random()<.8||(!S||new Date-S>36e5*(e?4:2)||!e&&V(!0,16)<=0)&&Y())};var G=!1,t=null;const Y=async function(e){if(S=new Date,null==t)return(t=v.showPanelWindow({width:525,height:420,path:`page-dist/license.html?dayRemains=${V(!0)}&index=${e?1:0}&hasActivated=${r||!1}&email=${x}&license=${c}&lang=${l.setting.getUserLocale()}&needLicense=${ie()&&!global.devVersion}&type=${D}&os=`+(w?"win":b?"mac":"linux"),frame:!1,alwaysOnTop:!C})).on("closed",function(){t=null}),void setTimeout(()=>{t&&!t.isDestroyed()&&t.setAlwaysOnTop(!1)},5e3);t.focus()};var n=null;async function X(){var o=(o=process.env.USER)||i(842).userInfo().username;switch(process.platform){case"win32":return process.env.COMPUTERNAME+" | "+o+" | Windows";case"darwin":return new Promise(n=>{i(620).exec("scutil --get ComputerName",{timeout:5e3},(e,t)=>{n(!e&&t?t.toString().trim()+" | "+o+" | darwin":i(842).hostname()+" | "+o+" | darwin")})});default:return i(842).hostname()+" | "+o+" | Linux"}}async function ee(e){try{var{fingerprint:t,email:n,license:o,type:i}=E(e)||{};return n&&o&&t?t!=await U()?(console.log("[L] validate server return fail"),$(),!1):(j(n,o,i),d().put("SLicense",e+"#0#"+(new Date).toLocaleDateString("en-US")),r=!0):(console.log("[L] validate server return empty"),$(),!1)}catch(e){throw console.error(e.stack),new Error("WriteActivationInfoFail")}}const te=e=>{const r="L23456789ABCDEFGHJKMNPQRSTUVWXYZ";if(!/^([A-Z0-9]{6}-){3}[A-Z0-9]{6}$/.exec(e))return!1;var e=e.replace(/-/g,""),t=e.substr(22);return!e.replace(/[L23456789ABCDEFGHJKMNPQRSTUVWXYZ]/g,"")&&t==(e=>{for(var t="",n=0;n<2;n++){for(var o=0,i=0;i<16;i+=2)o+=r.indexOf(e[n+i]);o%=r.length,t+=r[o]}return t})(e)},ne=(e.handle("license.machineCode",async()=>{console.log("handle license.machineCode");try{return await Buffer.from(JSON.stringify({v:N()+"|"+l.getVersion(),i:await U(),l:await X()}),"utf8").toString("base64")}catch(e){console.error(e.stack)}}),async t=>{r&&x&&c||console.error("doDeactivation on unregistered device");var e=(_()||{})["deviceId"];try{await B("api/client/deactivate",{license:c,l:e,sig:O(x,await U(),c)},!1)}catch(e){if(s.captureException(e,{level:"warning"}),console.log(e.stack),!t&&"off"==D)return!1}return $(),!0}),oe=(e.handle("addLicense",async(e,{email:t,license:n,force:o})=>{try{return await async function(e,t,n){if(e=(e||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),t=(t||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),!/^[^\s@'"/\\=?]+@[^\s@'"/\\]+\.[^\s@'"/\\]+$/.test(e))return[!1,"Please input a valid email address"];if(!te(t))return[!1,"Please input a valid license code"];t={v:N()+"|"+l.getVersion(),license:t,email:e,l:await X(),f:await U(),u:l.setting.generateUUID(),type:global.devVersion?"dev":"",force:n};JSON.stringify(t);try{var o=await B("api/client/activate",t,!0);if(JSON.stringify(o),console.log("[License] response code is "+o.code),o.code==T.SUCCESS)return await ee(o.msg)?[!0,""]:[!1,"Please input a valid license code"];if(o.code==T.OUT_OF_LIMIT)return n?await ee(o.msg)?[!0,"Your license has exceeded the max devices numbers.\nThe oldest device was unregistered automatically."]:[!1,"Please input a valid license code"]:["confirm",'Your license has exceeded the max devices numbers.\nIf you click "Continue Activation", this device will be activated and the oldest device will be unregistered automatically.'];if(o.code==T.INVALIDATE)return[!1,"Please input a valid license code"];if(o.code==T.WRONG_USER)return[!1,"This license code has been used with a different email address."]}catch(e){return"WriteActivationInfoFail"==e.message?(ne(!0).then(()=>{},()=>{}),[!1,"Failed to write your license to local machine"]):e.response&&e.response.code?(console.warn("[L] error from server "+e.response.code),[!1,"Unknown Error. Please contact hi@typora.io"]):(s.captureException(e,{level:"warning"}),console.error(e.stack),[!1,"Failed to access the license server. Please check your network or try again later."])}}(t,n,o)}catch(e){console.error(e.stack)}}),e.handle("offlineActivation",async(e,t)=>{try{return n=t,await(await ee(n)?[!0,"",x,c]:[!1,"Please input a valid license code"])}catch(e){console.error(e.stack)}var n}),e.handle("license.show",(e,t)=>{Y(t||!1)}),e.handle("license.show.debug",()=>{t&&t.webContents.openDevTools()}),e.handle("removeLicense",async e=>{try{return await ne()}catch(e){console.error(e.stack)}return!1}),()=>{W=l.setting.get("useMirrorInCN")?shostc||"".substring(1):global.shost||"".substring(1)});const ie=()=>!r&&!y,re=e=>R&&!r;var ae;ae=(new Date).getTime();const le="txxxx-xxxx-xxxxy".replace(/[x]/g,function(e){var t=(ae+16*Math.random())%16|0;return ae=Math.floor(ae/16),t.toString(16)}),se=()=>{f.getAllWindows().forEach(e=>{e.webContents.executeJavaScript(`try{document.querySelector(".${le}").remove();}catch(e){};File.option && (File.option.hasLicense = true);File.megaMenu && File.megaMenu.forceReload();0;`)})},ce=async e=>{await h.initDict();const t=`.typora-sourceview-on .${le}{left: 170px;}.${le} {position: fixed;bottom: 2px;z-index: 9999;left: 70px;font-size: 12px;line-height: 24px;background: rgb(120 120 120 / 30%);padding: 0 12px;color: var(--text-color);border-radius: 4px;cursor: pointer;}.pin-outline .${le}{left:calc(var(--sidebar-width) + 70px);}`,n=`if(window.File.option){File.option.hasLicense = false;File.megaMenu && File.megaMenu.forceReload(); };1;`;function o(e){e.webContents.insertCSS(t.replace(/(\{|\}|;)\n/g,"$1")),e.webContents.executeJavaScript(n.replace(/(\{|\}|;)\n/g,"$1"))}e?o(e):f.getAllWindows().forEach(o)};w&&(e=i(541).join(t_workingDir,"../winmm.dll"),i(833).stat(e,function(e,t){!e&&t&&setTimeout(function(){G=!0},138e4)})),u.startL=async(e,t)=>{console.log("start LM in devVersion="+(global.devVersion||!1));try{oe(),await U(),!e&&t||y||(global.devVersion||!t||-1240*I)&&Q(),n=+n,console.log("verInitTime is "+n),!isNaN(n)&&o-n>200*I&&Q()),(async e=>{console.log("[watch L]"),q(e),r=true,await H(),console.log("[watch L] hasL: "+r),Z(),A()})(e)}catch(e){s.captureException(e)}var n,o,i;v.on("dom-ready",e=>{e=e,R&&re()&&ce(e)}),v.on("make-window",e=>{Z()})},u.showLicensePanel=Y,u.showWelcomePanel=async function(){if(S=new Date,null==n)return(n=v.showPanelWindow({width:760,height:460,path:"page-dist/welcome.html?lang="+l.setting.getUserLocale(),frame:!1,alwaysOnTop:!C})).on("closed",function(){n=null}),void setTimeout(()=>{n&&!n.isDestroyed()&&n.setAlwaysOnTop(!1)},4e3);n.focus()},u.shouldShowWelcomePanel=ie,u.getHasLicense=()=>r,u.cannotContinueUse=function(){return!1===r&&!y&&!global.devVersion&&(G||V(!0,20)<=0)}},557:(o,i,F)=>{var c,d,W=global.PRODUCTION_MODE,S=F(134),x=S.app,u=F(266),r=F(338),a=S.Menu,l=S.MenuItem,p=S.BrowserWindow,s=S.shell,D="win32"==process.platform,h="darwin"==process.platform,g="linux"==process.platform,T=F(728),P=F(541).join(__dirname,"../"),m=F(344),f=F(824),w=F(156),E=F(445),b=require(W?"package.json":"../package.json"),I=F(468),y=1e4;function v(t){var o,i,r=0,n=x.getPath("userData")+"/typora.log",a="",l=console.error;function s(e,t){try{if(y{this.logStream=e})}function k(){var n=(new Date).getTime();return uuid="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),("x"==e?t:3&t|8).toString(16)})}function _(t){var e=1675928631787,n=!1,o=0;isNaN(e)||(o=30<(e=(new Date-e)/864e5/5)?(n=!0,.001):Math.max(0,(30-e)/30),isNaN(o)&&(o=.01)),I.config("https://41af752e6d61480d85276af874a7f69b@sentry.typora.io/2",{logger:"node",release:b.releaseId,autoBreadcrumbs:{http:!1,console:!1},sampleRate:o,shouldSendCallback:function(e){return(!e||"debug"!=e.level)&&(!n&&!t.hasUpdates&&t.db&&t.get("send_usage_info")+""!="false")}}).install(B),C=k(),I.mergeContext({tags:{instance:C,arch:process.platform,appVersion:x.getVersion()}}),I.disableConsoleAlerts(),setTimeout(function(){console.log("[Raven] instanceKey = "+C)},0),I.setDataCallback(function(e){try{return e?(e.request&&(e.request.url="http://typora/"),e.mechanism&&delete e.mechanism,e.exception&&(t=e)&&(t.message&&(t.message=L(t.message)),(t.exception||[]).forEach(function(e){e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&e.stacktrace.frames.forEach(function(e){e.filename&&(e.filename=U(e.filename))})}),n=t.stacktrace||[],(t=(t.exception||{}).values||[]).forEach&&t.forEach(function(e,t){e&&(e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&(n=n.concat(e.stacktrace.frames)))}),n.length&&n.forEach(function(e){var t;-1<(t=e.filename.lastIndexOf("atom.asar"))&&(e.filename="http://typora-app/atom/"+e.filename.substring(t+9).replace(/\\/g,"/"))})),e):void 0}catch(e){console.error(e.stack)}var t,n;return{}})}e.prototype.closeLogging=function(){console.log("closeLogging");try{c=!0,d&&(process.stdout.write=process.stderr.write=d),this.logStream&&this.logStream.end()}catch(e){console.error(e)}},e.prototype.put=function(e,t){this.db.getState()[e]=t,this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=setTimeout(this.save.bind(this),500)},e.prototype.get=function(e,t){try{return"recentDocument"==e?this.getRecentDocuments():"recentFolder"==e?this.getRecentFolders():("framelessWindow"!=e||!g)&&(void 0===(n=this.db.getState())[e]?t:n[e]);var n}catch(e){return console.error(e),t}},e.prototype.save=function(){this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=null;try{this.db.write()}catch(e){console.error(e.stack)}},e.prototype.syncAll=function(){this.saveTimer&&clearTimeout(this.saveTimer);try{this.db.write(),this.history.write()}catch(e){console.error(e.stack)}},e.prototype.getAllThemes=function(){return this.allThemes},e.prototype.getRecentFolders=function(){var e=this.history.getState(),t=e.recentFolder;return t||(e.recentFolder=t=[]),t||[]},e.prototype.addRecentFolder=function(e){console.log("addRecentFolder"),e=F(541).normalize(e);var t=F(541).basename(e),n=this.getRecentFolders();if(t.length){this.removeRecentFolder(e,!0),n.unshift({name:t,path:e,date:new Date}),8new Promise(e=>{T.rm(l.join(v,t),{force:!0,recursive:!0,maxRetries:1},e)})))}await 0}if(0==o&&T.existsSync(a))g();else{console.log("overwriteThemeFolder"),T.ensureDirSync(f);var w=[];if(-1<["github.css","newsprint.css","night.css","pixyll.css","white.css"].indexOf(e)){try{T.renameSync(l.join(a,e),l.join(f,e)),w.push(e)}catch(e){}T.copySync(l.join(m,e),l.join(a,e),{overwrite:!0})}h.list(m,function(e,t){Promise.all(t.map(function(e){var r=l.basename(e);return new Promise(function(e,t){if(-1{}),C.rm(s.join(c,i+".aff"),{force:!0},()=>{}),C.rm(s.join(c,i+"-LICENSE"),{force:!0},()=>{}),console.log(`remove ${c}/${i}.dic`)}}else this.put("strict_mode",!0),this.put("copy_markdown_by_default",!0)}this.initDictionary_(),this.addAnalyticsEvent("launch"),t&&0!=o?this.addAnalyticsEvent(0{var t=x.setting.get("export.general")||{},n={},o=(["pdf","html","html-plain","image"].forEach(e=>{n[e]=Object.assign({type:e},t,x.setting.get("export."+e)||{})}),{});return x.setting.loadCustomExports().forEach(e=>{o[e.key]=Object.assign({},t,e,x.setting.get("export."+e.key)||{})}),JSON.stringify([n,o])}),n.handle("export.recordLastExport",(e,t)=>{A||(x.updateMenu({"File→Export→Export with Previous":{enabled:!0}}),x.updateMenu({"File→Export→Export and Overwrite with Previous":{enabled:!0}})),A=t,x.setting.lastExport=t,x.execInAll("File.option._lastExport = "+JSON.stringify(t))}),n.handle("setting.getDownloadingDicts",e=>JSON.stringify(x.setting.downloadingDicts||[])),n.handle("setting.getUserDictionaryPath",e=>x.setting.getUserDictionaryPath()),n.handle("setting.getUserDict",e=>JSON.stringify(x.setting.userDict)),n.handle("setting.downloadDict",(e,t)=>{e=p.fromWebContents(e.sender);x.setting.downloadDict(t,e.id)}),n.handle("setting.getThemes",e=>({all:x.setting.getAllThemes()||[],current:x.setting.curTheme()})),n.handle("setting.setCurTheme",(e,t,n)=>{x.setting.setCurTheme(t,n)}),n.handle("setting.resetAdvancedSettings",(e,t)=>{function n(){}var o=F(728),i=x.getPath("userData")+"/conf/conf.user.json";o.copy(P+"/conf.default.json",x.getPath("userData")+"/conf/conf.default.json",{overwrite:!0},t?function(){S.shell.showItemInFolder(i)}:n),o.copy(P+"/conf.default.json",i,{overwrite:!0},n)}),n.handle("logger.error",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Error] "+t)}),n.handle("logger.warn",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Warn] "+t)}),n.handle("setting.clearRecentDocuments",e=>{x.setting.clearRecentDocuments()}),n.handle("setting.removeRecentFolder",(e,t)=>{x.setting.removeRecentFolder(t)}),n.handle("setting.removeRecentDocument",(e,t)=>{x.setting.removeRecentDocument(t)}),n.handle("setting.addRecentFolder",(e,t)=>{x.setting.addRecentFolder(t)}),n.handle("setting.getRecentFiles",e=>JSON.stringify({files:x.setting.getRecentDocuments()||[],folders:x.setting.getRecentFolders()||[]})),n.handle("setting.put",(e,t,n)=>{x.setting.put(t,n)}),n.handle("setting.get",(e,t)=>x.setting.get(t)),n.handle("setting.fetchAnalytics",e=>{var t=JSON.stringify(x.setting.analyticsEvents);return x.setting.analyticsEvents=[],t}),null),B=(n.handle("setting.getUnsavedDraftsPath",e=>x.setting.getUnsavedDraftPath()),e.prototype.getUnsavedDraftPath=function(){return N?Promise.resolve(N):(N=F(541).resolve(x.getPath("userData"),"draftsRecover"),F(728).ensureDir(N).then(()=>N))},function(e,t,n){t&&console.info(t.stack||t.message),e=e||{},console.error(e.stack||e.message),!x.isReady()||"ENOTFOUND"!=(t=e.errno||e.code)&&"ETIMEDOUT"!=t&&"ECONNRESET"!=t&&0!=(e.message||"").indexOf("net::ERR")&&(dialog=F(134).dialog,stack=null!=(ref=e.stack)?ref:e.name+": "+e.message,message="Uncaught Exception:\n"+stack,dialog.showMessageBox(null,{type:"error",buttons:["OK","Learn Data Recovery"],defaultId:0,cancelId:0,title:"A JavaScript error occurred in the main process",message:message}).then(({response:e})=>{1==e?(e=x.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",s.openExternal(`https://support.${e}/Version-Control/`)):process.exit(1)}))});function z(t,n){p.getAllWindows().forEach(function(e){e.isDestroyed()||e.webContents.isDestroyed()||e.webContents.isLoading()||e.webContents.send(t,n)})}function J(e,t){t=e.indexOf(t);-1{},()=>{}),console.error(e),I.captureException(e)}}catch(e){console.error(e),I.captureException(e)}try{o.userDictionaryPath?(e=await T.readFile(this.userDictionaryPath+"/user-dict.json","utf8"),o.userDict=JSON.parse(e)):console.error("no userDictionaryPath found")}catch(e){console.warn("user-dict.json not found")}function r(){o.userDictionaryPath&&F(833).writeFile(o.userDictionaryPath+"/user-dict.json",JSON.stringify(o.userDict),function(){}),x.sendEvent("user-dict-update",o.userDict)}n=S.ipcMain;n.on("user-dict-add",function(e,t){var{lang:t,word:n}=t;o.userDict[t]=o.userDict[t]||[],-1==o.userDict[t].indexOf(n)&&o.userDict[t].push(n),r()}),n.on("user-dict-remove",function(e,t){o.userDict[t.lang]=(o.userDict[t.lang]||[]).filter(function(e){return e!=t.word}),r()})},e.prototype.buildOption=async function(){var t={},e=(t.supportTextBundle=this.supportTextBundle,t.enableInlineMath=this.get("enable_inline_math")||!1,t.enableHighlight=this.get("enable_highlight")||!1,t.enableSubscript=this.get("enable_subscript")||!1,t.enableSuperscript=this.get("enable_superscript")||!1,t.enableDiagram=0!=this.get("enable_diagram"),t.copyMarkdownByDefault=this.get("copy_markdown_by_default")||!1,t.showLineNumbersForFence=this.get("show_line_numbers_for_fence")||!1,t.noPairingMatch=this.get("no_pairing_match")||!1,t.autoPairExtendSymbol=this.get("match_pari_markdown")||!1,t.expandSimpleBlock=this.get("auto_expand_block")||!1,t.headingStyle=this.get("heading_style")||0,t.ulStyle=this.get("ul_style")||0,t.olStyle=this.get("ol_style")||0,t.scrollWithCursor=!this.get("no_mid_caret"),t.autoNumberingForMath=this.get("auto_numbering_for_math"),t.allowPhysicsConflict=this.get("allowPhysicsConflict"),t.noDisplayLinesInMath=this.get("noDisplayLinesInMath"),t.useRelativePathForImg=this.get("use_relative_path_for_img")||!1,t.relativePathWithDot=this.get("relativePathWithDot")||!1,t.allowImageUpload=this.get("allow_image_upload")||!1,t.defaultImageStorage=this.get("image_save_location")||null,"custom"==t.defaultImageStorage&&(t.defaultImageStorage=this.get("custom_image_save_location")),t.applyImageMoveForWeb=this.get("apply_image_move_for_web")||!1,t.applyImageMoveForLocal=!this.get("no_image_move_for_local"),t.preferCRLF=this.get("line_ending_crlf")||!1,t.sidebarTab=this.get("sidebar_tab")||"",t.useTreeStyle=this.get("useTreeStyle")||!1,t.strictMarkdown=this.get("strict_mode")||!1,t.noLineWrapping=this.get("no_line_wrapping")||!1,t.prettyIndent=this.get("prettyIndent")||!1,t.convertSmartOnRender=this.get("SmartyPantsOnRendering"),t.smartDash=this.get("smartDash"),t.smartQuote=this.get("smartQuote"),t.twoHyphensToEm=this.get("twoHyphensToEm")||!1,t.remapUnicodePunctuation=this.get("remapPunctuation"),t.indentSize=this.get("indentSize")||2,t.codeIndentSize=this.get("codeIndentSize")||4,t.enableAutoSave=this.get("enableAutoSave")||!1,t.saveFileOnSwitch=this.get("save_file_on_switch")||!1,t.presetSpellCheck=this.get("preset_spell_check")||"auto",t.autoCorrectMisspell=!1,this.config||{});t.monocolorEmoji=e.monocolorEmoji,t.userQuotesArray=this.get("userQuotesArray"),t.passiveEvents=!0,t.canCollapseOutlinePanel=this.get("can_collapse_outline_panel"),t.preLinebreakOnExport=this.get("preLinebreakOnExport"),t.preLinebreakOnExport=1==t.preLinebreakOnExport||"true"==t.preLinebreakOnExport,t.indentFirstLine=this.get("indentFirstLine"),t.hideBrAndLineBreak=this.get("hideBrAndLineBreak"),t.isFocusMode=this.get("isFocusMode"),t.isTypeWriterMode=this.get("isTypeWriterMode"),t.ignoreLineBreak=this.get("ignoreLineBreak")||!1,t.sendAnonymousUsage=this.get("send_usage_info"),t.useMirrorInCN=this.get("useMirrorInCN"),void 0!==t.sendAnonymousUsage&&null!==t.sendAnonymousUsage||(t.sendAnonymousUsage=!0),t.uuid=this.get("uuid"),t.appVersion=x.getVersion(),t.instance=C,t.devVersion=global.devVersion,t.hasLicense=E.getHasLicense(),t.userLocale=this.getUserLocale(),t.appLocale=x.getLocale(),t.sidebarWidth=this.get("sidebar-width"),t.caseSensitive=this.get("caseSensitive"),t.wholeWord=this.get("wholeWord"),t.useRegexp=this.get("useRegexp"),t.fileSearchCaseSensitive=this.get("fileSearchCaseSensitive"),t.fileSearchWholeWord=this.get("fileSearchWholeWord"),t.fileSearchUseRegexp=this.get("fileSearchUseRegexp"),t.wordCountDelimiter=this.get("wordCountDelimiter")||0;try{t.userPath=x.getPath("home")||""}catch(e){t.userPath=(D?process.env.USERPROFILE:"")||""}if(t.mainPath=global.addonPath||"",t.userDataPath=x.getPath("userData")||"",!this.tempPath){var n=x.getPath("temp");0{t.keys[e]=(m.getKeyAccelerator(e)||"").toLowerCase()}),t.mathFormatOnCopy=this.get("mathFormatOnCopy")||"svg",t.imageUploader=this.get("image_uploader"),t.customImageUploader=this.get("custom_image_uploader"),t.picgoAppPath=this.get("picgo_app_path"),t.noWarnigUploadDisabled=this.get("noWarnigUploadDisabled")||!1,t.noWarnigForMoveFile=this.get("noWarnigForMoveFile")||!1,t.noWarnigForMoveFileToList=this.get("noWarnigForMoveFileToList")||!1,t.noWarnigForDeleteFile=this.get("noWarnigForDeleteFile")||!1,t.noWarnigForTypeWriterMode=this.get("noWarnigForTypeWriterMode")||!1,t.noHintForOpenLink=this.get("noHintForOpenLink")||!1,t.noHintForUnibody=this.get("noHintForUnibody")||!1,t.noWarnigForFocusMode=this.get("noWarnigForFocusMode")||!1,t.noWarningForExportOverwrite=this.get("noWarningForExportOverwrite")||!1,t.noWarningForUpdateImageReference=this.get("noWarningForUpdateImageReference")||!1,t.hasUpdates=this.hasUpdates||!1,t.pandocPath=this.get("pandocPath")||"",t.buildTime=1675928631787,t.debug=this.get("debug"),t._lastExport=A,t.lineWiseCopyCut=this.get("lineWiseCopyCut")||!1,t},e.prototype.extraOption=async function(){var t=await this.buildOption();return t.restoreWhenLaunch=this.get("restoreWhenLaunch")||0,t.pinFolder=this.get("pinFolder"),t.enable_inline_math=t.enableInlineMath,t.enable_highlight=t.enableHighlight,t.enable_subscript=t.enableSubscript,t.enable_superscript=t.enableSuperscript,t.enableDiagram=0!=this.get("enable_diagram"),t.enable_diagram=t.enableDiagram,t.copy_markdown_by_default=!!this.get("copy_markdown_by_default"),t.show_line_numbers_for_fence=!!this.get("show_line_numbers_for_fence"),t.no_pairing_match=!!this.get("no_pairing_match"),t.match_pari_markdown=!!this.get("match_pari_markdown"),t.auto_expand_block=!!this.get("auto_expand_block"),t.heading_style=this.get("heading_style")||0,t.ul_style=this.get("ul_style")||0,t.ol_style=this.get("ol_style")||0,t.no_mid_caret=this.get("no_mid_caret"),t.auto_numbering_for_math=this.get("auto_numbering_for_math"),t.use_relative_path_for_img=this.get("use_relative_path_for_img"),t.relativePathWithDot=this.get("relativePathWithDot"),t.allow_image_upload=this.get("allow_image_upload"),t.image_save_location=this.get("image_save_location"),t.custom_image_save_location=this.get("custom_image_save_location"),t.apply_image_move_for_web=this.get("apply_image_move_for_web"),t.no_image_move_for_local=this.get("no_image_move_for_local"),t.line_ending_crlf=this.get("line_ending_crlf"),t.strict_mode=this.get("strict_mode"),t.no_line_wrapping=this.get("no_line_wrapping"),t.prettyIndent=this.get("prettyIndent"),t.SmartyPantsOnRendering=this.get("SmartyPantsOnRendering"),t.remapPunctuation=this.get("remapPunctuation"),t.save_file_on_switch=this.get("save_file_on_switch")||!1,t.preset_spell_check=this.get("preset_spell_check")||"auto",t.can_collapse_outline_panel=this.get("can_collapse_outline_panel"),t.send_usage_info=!1!==this.get("send_usage_info"),t.currentThemeFolder=x.getPath("userData")+(D?"\\":"/")+"themes",t.enableAutoUpdate=!1!==this.get("enableAutoUpdate"),t.autoUpdateToDev=this.get("autoUpdateToDev"),t.userLanguage=this.get("userLanguage"),t.image_uploader=this.get("image_uploader"),t.custom_image_uploader=this.get("custom_image_uploader"),t.picgo_app_path=this.get("picgo_app_path"),t.allThemes=this.allThemes,t.useSeparateDarkTheme=this.get("useSeparateDarkTheme")||!1,t.theme=this.get("theme")||"github.css",t.darkTheme=this.get("darkTheme")||"night.css",t.customExport=this.get("customExport"),["general","pdf","html","html-plain","image"].forEach(e=>{t["export."+e]=this.get("export."+e)}),(t.customExport||R).forEach(e=>{t["export."+e.key]=this.get("export."+e.key)}),t},n.handle("setting.getExtraOption",async e=>JSON.stringify(await x.setting.extraOption())),n.handle("setting.doDownloadPicgo",e=>{x.setting.doDownloadPicgo()}),n.handle("setting.getKeyBinding",e=>x.setting.config.keyBinding||{}),e.prototype.doDownloadPicgo=function(){w.initDict().then(function(){var e="https://github.com/typora/PicGo-cli/releases/download/latest/%@.zip".replace("%@",D?"x64"==process.arch?"win64":"win32":"linux");console.log(e);let n=F(541).normalize(x.getPath("userData")+"/picgo"),o=F(541).normalize(n+"/_picgo.zip");var i=new f(e,o,{title:w.getPanelString("Download"),text:w.getPanelString("Downloading…"),processOnComplete:.9});i.onSuccess=(e,t)=>{F(834)(o,{dir:n},function(e){t.value=1,t.text=w.getPanelString("Finished"),t.detail="",setTimeout(()=>{i.setCompleted()},2e3),T.unlink(o,()=>{})}),t.detail=w.getPanelString("Unzipping…")},i.onError=e=>{S.dialog.showErrorBox(w.getPanelString("Download"),e.message)},i.download()})};var V=null;e.prototype.useDarkTheme=function(){return V=S.nativeTheme.shouldUseDarkColors&&this.get("useSeparateDarkTheme")},e.prototype.useDarkThemeBefore=function(){return V},e.prototype.curTheme=function(){return this.useDarkTheme()?this.get("darkTheme")||"night.css":this.get("theme")||"github.css"},e.prototype.setCurTheme=function(e,t){return a.getApplicationMenu().getItem("Themes").submenu.items.map(function(e){e.checked=e.label==t}),this.useDarkTheme()?this.put("darkTheme",e):this.put("theme",e)},o.exports=e},587:(o,e,t)=>{var u,p=t(134),h=p.app,n=p.ipcMain,g=p.BrowserWindow,m=(t(445),t(468)),f=(process.platform,"linux"==process.platform),w=t(541).join(__dirname,"../");n.handle("window.setTitle",(e,t,n)=>{e=g.fromWebContents(e.sender);t=t||("Typora"===(t=e.getTitle())?"Untitled"+(n?"• - Typora":" - Typora"):t.replace(/•? - Typora$/,n?"• - Typora":" - Typora")),e.setTitle(t)}),n.handle("window.focus",e=>{e=g.fromWebContents(e.sender);return e.focus(),e.webContents.focus(),!0}),n.handle("window.setInSourceMode",(e,t)=>{g.fromWebContents(e.sender).inSourceMode=!!t}),n.handle("window.minimize",e=>{g.fromWebContents(e.sender).minimize()}),n.handle("window.close",e=>{g.fromWebContents(e.sender).close()}),n.handle("window.restore",e=>{e=g.fromWebContents(e.sender);e.unmaximize(),e.setFullScreen(!1)}),n.handle("window.maximize",e=>{g.fromWebContents(e.sender).maximize()}),n.handle("window.fullscreen",e=>{e=g.fromWebContents(e.sender);return e.setFullScreen(!0),e.isFullScreen()}),n.handle("window.setMenuBarVisibility",(e,t)=>{g.fromWebContents(e.sender).setMenuBarVisibility(t)}),n.handle("window.pin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!0)}),n.handle("window.unpin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!1)}),n.handle("window.updateMenuForIsAlwaysOnTop",e=>{e={"View→Always on Top":{state:g.fromWebContents(e.sender).isAlwaysOnTop()}};h.updateMenu(e)}),n.handle("window.toggleDevTools",e=>{e=g.fromWebContents(e.sender);e.webContents.isDevToolsOpened()?e.webContents.closeDevTools():e.webContents.openDevTools()}),n.handle("window.inspectElement",(e,t,n)=>{g.fromWebContents(e.sender).inspectElement(t,n)}),n.handle("window.checkAsFocus",e=>{e=g.fromWebContents(e.sender);e&&e.isFocused&&(h.currentFocusWindowId=e.id)}),n.handle("controller.switchFolder",(e,t)=>{e=g.fromWebContents(e.sender);h.switchFolder(t,e)}),n.handle("webContents.copy",e=>{g.fromWebContents(e.sender).webContents.copy()}),n.handle("webContents.cut",e=>{g.fromWebContents(e.sender).webContents.cut()}),n.handle("webContents.paste",e=>{g.fromWebContents(e.sender).webContents.paste()}),n.handle("webContents.selectAll",e=>{g.fromWebContents(e.sender).webContents.selectAll()}),n.handle("webContents.undo",(e,t)=>{g.fromWebContents(e.sender).webContents.undo()}),n.handle("webContents.redo",(e,t)=>{g.fromWebContents(e.sender).webContents.redo()}),n.handle("webContents.clearCache",(e,t)=>{var n=g.fromWebContents(e.sender);return new Promise(e=>{n.webContents.session.clearCache(e)})}),n.handle("webContents.action",(e,t)=>{g.fromWebContents(e.sender).webContents[t]()}),e.makeWindow=async(d,e)=>{var t=h.getDocumentController();e=e||{};var n,o,i=g.getFocusedWindow(),r=h.setting.config||{},a=t.lastClosedBounds,l=(i=i&&!t.getDocumentFromWindowId(i.id)?null:i)&&i.getBounds(),s=0,l=(a||(l?(s=i.isMaximized()||i.isFullScreen()?0:30,a={fullscreen:i.isFullScreen(),maximized:i.isMaximized()},s&&(a.x=l.x+s,a.y=l.y+s,a.width=l.width,a.height=l.height)):a=u?(s=u.fullscreen||u.maximize?0:30,{x:u.x+s,y:u.y-s,width:u.width,height:u.height,fullscreen:u.fullscreen,maximized:u.maximized}):{}),!a.fullscreen&&a.maximized),e={x:a.x,y:a.y,width:a.width||800,height:a.height||700,minWidth:400,minHeight:400,frame:!h.setting.get("framelessWindow"),disableAutoHideCursor:!1,backgroundColor:h.setting.get("backgroundColor"),webPreferences:{webSecurity:!1,allowRunningInsecureContent:!1,plugins:!1,nodeIntegration:!0,enableRemoteModule:!1,webviewTag:!0,nodeIntegrationInWorker:!0,devTools:!0,images:!0,directWrite:r.directWrite,defaultFontFamily:r.defaultFontFamily,allowDisplayingInsecureContent:!1,backgroundThrottling:!1,spellcheck:!1,contextIsolation:!1,additionalArguments:["--tyopt="+JSON.stringify({isMaximized:l,isFullScreen:a.fullscreen,...await h.setting.buildOption(),...e})]},autoHideMenuBar:a.fullscreen||r.autoHideMenuBar,show:d,fullscreen:a.fullscreen,alwaysOnTop:i&&i.isAlwaysOnTop(),fullscreenable:!0},c=(f&&(e.icon=w+"/assets/icon/icon_256x256.png"),r=e,i=0s.y+s.height&&(r.y=s.y+s.height-r.height),r.xs.x+s.width&&(r.x=i?s.x:s.x+s.width-r.width)),u=e,l&&(e.show=!1),new g(e));return t.lastClosedBounds=null,l&&(c.maximize(),d&&c.show()),a.fullscreen&&(c.autoHideMenuBar=!0,c.setMenuBarVisibility(!1)),c.loadURL(entry||"".substring(1)),n=c,o=p.shell,n.webContents.on("will-navigate",function(e,t){e.preventDefault(),o.openExternal(t)}),n.webContents.setWindowOpenHandler(e=>(/^https?:/.exec(e.url)&&o.openExternal(e.url),{action:"deny"})),n.webContents.on("crashed",function(e,t){console.error("render process is killed? "+t),m.captureMessage("render process crashed, killed="+t),h.setting.addAnalyticsEvent("crashed")}),n.webContents.on("unresponsive",function(){m.captureMessage("unresponsive",{extra:{winId:n.id}}),h.setting.addAnalyticsEvent("unresponsive")}),n.webContents.setMaxListeners(15),n.webContents.on("dom-ready",function(){n.isMaximized()&&n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");'),b("dom-ready",n)}),n.on("maximize",()=>{n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");')}),n.on("enter-full-screen",function(){n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");document.body.classList.add("typora-fullscreen");if(document.body.classList.contains("native-window")) {$("#ty-top-placeholder").show();};1;')}),n.on("unmaximize",function(){n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");')}),n.on("session-end",function(){console.log("[win] session-end"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),n.on("leave-full-screen",function(){n.autoHideMenuBar=!!h.setting.config.autoHideMenuBar,n.setMenuBarVisibility(!h.setting.config.autoHideMenuBar),n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");document.body.classList.remove("typora-fullscreen");$("#ty-top-placeholder").hide();1;'),u&&(u.fullscreen=!1)}),n.on("focus",function(){n.webContents.incrementCapturerCount();var e=t.getDocumentFromWindowId(n.id);e&&(e.setActiveWindow(n),h.focusedWindow=n)}),n.on("blur",()=>{console.log("[win] blur"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),b("make-window"),c};const i=t(93);var r=new i;const b=function(e,t){r.emit(e,t)};e.on=function(e,t){r.on(e,t)},e.showPanelWindow=function({path:e,...t}){var n=new g({modal:!0,show:!1,center:!0,resizable:!1,webPreferences:{devTools:!global.releaseMode,defaultFontSize:14,nodeIntegration:!0,contextIsolation:!1,enableRemoteModule:!1},...t});return n.loadURL("file://"+w+"/"+e),n.once("ready-to-show",function(){n.show()}),n.removeMenu(),f&&(n.icon=w+"/assets/icon/icon_256x256.png"),n.webContents.setWindowOpenHandler(e=>(p.shell.openExternal(e.url),{action:"deny"})),n}},90:(e,o,s)=>{e=s.nmd(e);var t,i=s(541),n=s(640),r=(t=i.join(__dirname,"../"),i.join(t,"node_modules.asar")),a=(n.globalPaths.push(r),n.prototype.require);n.prototype.require=function(e){return-1==this.paths.indexOf(__dirname)&&(this.paths.push(__dirname),this.paths.push(r)),/(\.node$)|(\/build\/Release)/.exec(e)&&"."==e[0]&&(e=i.resolve(i.dirname(this.id),e).replace(/\bnode_modules\.asar\b/,"node_modules")),a.call(this,e)};for(let e=0;e{c.exit()},1e3),s(405);var n=s(134),c=n.app,l=n.protocol,m=n.powerMonitor,d=n.BrowserWindow,u=s(728),f="win32"==process.platform,w=(process.platform,process.platform,s(557),s(344)),b=s(883),e=s(932),y=s(445),p=s(351),n=n.ipcMain;s(468);if(!c.requestSingleInstanceLock())return console.record("secondary instance would exit"),void c.quit();console.record("launch with argv ["+process.argv.join(", ")+"]"),c.on("second-instance",function(e,t,n){console.record("got argv ["+t.join(", ")+"] from secondary instance"),t=Array.from(t),d.getAllWindows().length&&((n=F(t,n))?c.openFileOrFolder(n,{forceCreateWindow:!n}):T(t||[]))});var v=1,k=2,C=3;function F(e,t){null==t&&(t=process.cwd());for(var n,o=e.length-1;0<=o;o--)if("-"!=e[o][0]&&!/\.asar$/.exec(e[o]||"")){n=e[o];break}if((n=0!=o&&n!=t?n:void 0)&&/^file:\/\//i.exec(n)){n=n.replace(/^file:\/\//i,"");try{n=decodeURI(n)}catch(e){}}return n?s(541).resolve(t,n):void 0}function S(e){if(!e)return e;var t=e.length;return 50((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFile(t||null,n).then(n=>{if(n)return new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e({winId:n.activeWindow.id})}):e({winId:n.activeWindow.id})})}))),n.handle("app.openFileOrFolder",(e,t,n)=>((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFileOrFolder(t||null,n))),n.handle("app.openOrSwitch",async(e,t,n)=>{var o,e=d.fromWebContents(e.sender),i=c.documentController.getDocument(t),r=c.documentController.getDocumentFromWindowId(e.id);if(i)return(o=i.activeWindow||i.windows.keys().next().value)&&o.focus(),!1;if(n)return c.openFileOrFolder(t,{curWindow:!0}),!1;if(await O(t))c.switchFolder(t,e);else if(!i)return r.rename(t),!0;return!1}),n.handle("app.openFolder",(e,t,n)=>{c.openFolder(t||null,n?d.fromWebContents(e.sender):void 0)}),n.handle("app.onCloseWin",(e,t)=>{e=d.fromWebContents(e.sender);c.onCloseWin(e.id,t)}),n.handle("app.sendEvent",(e,t,n)=>{c.sendEvent(t,n)}),n.handle("executeJavaScript",(e,t,n)=>{d.fromId(t).webContents.executeJavaScript(n)}),c.reopenFolder=function(){var t=new Set,n=!1;return g.forEach(function(e){e.mountFolder&&!t.has(e.mountFolder)&&(t.add(e.mountFolder),c.openFile(null,{forceCreateWindow:!0,mountFolder:e.mountFolder}),n=!0)}),n},c.reopenClosed=function(o){var i=!1;return g.length&&g.forEach(function(e,t){var n=c.getDocumentController().getDocument(e.path);n?n.activeWindow&&n.activeWindow.show():(c.openFile(e.path,{forceCreateWindow:!!t,mountFolder:e.mountFolder,silent:o,backupState:e,fromReopen:!0}),i=!0)}),i},function(e){var t,n=c.setting.get("restoreWhenLaunch")||0,o=!0,i=e||process.argv||[];-1{/^--/.exec(e)&&("--on-dev"==e?process.traceDeprecation=!0:-1===["--new","--reopen-file"].indexOf(e)&&c.commandLine.appendSwitch.apply(null,[e]))}),scheme||"".substring(3));c.on("ready",async function(){var e,t;await c.setting.initSetting(),c.expired||(p.lastClosedBounds=c.setting.get("lastClosedBounds"),console.record("------------------start------------------"),console.log("typora version: "+c.getVersion()),console.log(""+s.c[s.s].filename),M(P),c.setAppUserModelId("abnerworks.Typora"),(e=F(process.argv))&&"--on-dev"!==process.argv[process.argv.length-1]?c.openFileOrFolder(e):c.recoverFromBackup(),w.loadDict().then(()=>{w.bindMainMenu()}),f&&(t=s(558),c.updater=t,setTimeout(function(){t.initUpdater().then(function(){!1!==c.setting.get("enableAutoUpdate")&&c.updater.checkForUpdates(!1)})},3e3)),b.bindJumplist(),setTimeout(function(){try{E()}catch(e){console.warn(e.stack)}},3e4),m.on("suspend",()=>{console.record("[Power] suspend"),c.execInAll('window.onPowerChange && window.onPowerChange("suspend")')}),m.on("resume",()=>{console.record("[Power] resume"),c.execInAll('window.onPowerChange && window.onPowerChange("resume")')}),m.on("lock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("lock-screen")')}),m.on("unlock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("unlock-screen")')}))});var I,W={},E=async function(){var r,a,l,s,n=await c.setting.getUnsavedDraftPath(),e=await u.readdir(n);e.length<200||(console.record("cleanUpExpiredDrafts"),400{var o=[],i=async function(){Math.min(l+50,a.length);if(l+1>=a.length)n(o);else{for(;l++;){if(!a[l])return void n(o);try{var e=r+"/"+a[l],t=await u.stat(e);864e6{try{return{name:e,time:W[e]||(await u.stat(n+"/"+e)).mtime.getTime()}}catch(e){}return{name:e,time:0}})),W=null,e.sort(function(e,t){return t.time-e.time}).forEach(function(e,t){150{D=!1}),c.on("quit",function(){console.log("-----------------quit------------------"),c.setting.closeLogging()}),c.on("will-quit",function(){console.log("------------------will-quit------------------"),h&&clearTimeout(h),I&&clearTimeout(I),f&&c.updater&&c.updater.installIfNeeded(),c.setting.syncAll();try{u.rmSync(c.getPath("userData")+"/runtime-storage",{recursive:!0,force:!0})}catch(e){console.error(e)}try{var e=c.getPath("userData")+"/typora.log",t=c.getPath("userData")+"/typora-old.log",n=u.statSync(e);n&&5e5p.getDocumentFromWindowId(n.id)):l()}).then(function(e){return e})}return l()},c.sendEvent=function(t,n){d.getAllWindows().forEach(function(e){e.webContents.send(t,n)}),c.onMessage(t,n)},c.execInAll=function(t){d.getAllWindows().forEach(function(e){e.webContents.executeJavaScript(t)})},c.onMessage=function(e,t){"didRename"==e?c.setting.renameRecentDocuments(t.oldPath,t.newPath):"updateQuickOpenCache"==e&&t.toDel&&c.setting.renameRecentDocuments(t.toDel,null)},c.refreshMenu=function(){w.refreshMenu()},{});n.handle("app.download",(e,t,n,o)=>{var i,r,a=s(541),l=d.fromWebContents(e.sender),e=s(554),o=o||(e=>{var t=s(426),n=s(541),t=t.parse(e),e=n.basename(t.pathname);try{var o=decodeURIComponent(e);if(o!=e)return n.basename(o)}catch(e){}return e})(t),a=a.join(n,o);return u.existsSync(a)&&(i=a,r=s(541),a=i.replace(/(\.[^.\/\\]+?$)/,"")+"-"+ +new Date+r.extname(i)),_[l.id+t]||(_[l.id+t]=e.download(l,t,{showBadge:!1,directory:n,filename:o})),setTimeout(()=>{delete _[l.id+t]},10),Promise.race([_[l.id+t].then(e=>({path:e.getSavePath(),state:e.getState(),type:e.getMimeType()}),()=>({path:t,state:"error"})),new Promise(e=>{setTimeout(()=>{e({path:t,state:"timeout"})},3e4)})])});var M=function(e){l.registerFileProtocol(e,function(e,t){e.url?t({path:c.getRealPath(e.url)}):t({error:-324})}),l.registerBufferProtocol("typora-bg",function(e,t){var n=c.setting.get("backgroundColor");t(n?{mimeType:"text/css",data:Buffer.from(`body {background:${n};`)}:{mimeType:"text/css",data:Buffer.from("")})})};c.getRealPath=function(e){try{e=decodeURI(e)}catch(e){}e=e.substr(13);return/^userData/.exec(e)&&(e=e.replace(/^userData/,c.getPath("userData").replace(/\\/g,"\\\\"))),/current-theme\.css$/.exec(e)&&(e=e.replace(/current-theme\.css$/,c.setting.curTheme())),/^typemark/i.exec(e)&&(e=e.replace(/^typemark/,t)),e=(e=/preview\.html/.exec(e)?e.replace(/\.html[?#].*$/,".html"):e).replace(/[?#][^\\\/]*$/,"")},c.filesOp=e,P&&l.registerSchemesAsPrivileged([{scheme:P,privileges:{standard:!0,secure:!0,supportFetchAPI:!0,bypassCSP:!0,corsEnabled:!0,stream:!0}}])},344:(t,n,h)=>{function r(e,t){return function(){k(e,t)}}var i,a=h(134),l=a.app,g=a.dialog,s=a.Menu,c=a.MenuItem,m=a.BrowserWindow,e=a.ipcMain,f=h(728),d="win32"==process.platform,w="darwin"==process.platform,b="linux"==process.platform,y=h(445),u=h(541).join(__dirname,"../"),v=(e.on("execForAll",function(e,t){v(t)}),e.on("forceRefreshMenu",function(e,t){l.forceRefreshMenu()}),e.on("syncToPreference",function(e,t){a.webContents.getAllWebContents().forEach(function(e){e.send("syncToPreference",t)})}),n.loadDict=()=>{var o,e;return i?Promise.resolve(i):(o=l.setting.getUserLocale(),e=h(541).join(u,l.setting.getLocaleFolder("Menu")),new Promise(n=>{f.readFile(e,"utf8",(e,t)=>{i=t?JSON.parse(t):{},n(i),e&&console.warn("cannot load dict as ["+o+"] "+e.stack)})}))},function(e){var t=e=e.toString();/^\s*function\s*\(/.exec(e)&&(t="window.File && ("+e+")();"),l.execInAll(t),console.log(t)}),k=function(e,t){var n=m.getFocusedWindow();n&&(t?n.webContents.executeJavaScript("window.File && !File.blockUI && ("+e.toString()+")();0;"):n.webContents.executeJavaScript("!File.blockUI && window.ClientCommand['"+e+"']();0;"),n.webContents.executeJavaScript("window.Reporter && window.Reporter.fullValidate();File.editor && File.editor.contextMenu && File.editor.contextMenu.hide();0;"))};function C(e){var t=/&[a-z]/i.exec(e),n=/(\.\.\.)|(…)/.exec(e),o=(e=e.replace(/(\.\.\.)|(…)|&/g,""),(i||{})[e]||e);return t?function(e,t){e=S[e];if(!e)return t;{var n,o;(d||b)&&(-1==(n=t.indexOf(e))?n=t.indexOf(e.toLowerCase()):-1<(o=t.indexOf(e.toLowerCase()))&&(n=Math.min(n,o)),-1{setTimeout(o,0)}))),e}function x(e,t){return p(e={label:e,accelerator:t}),e.accelerator}function D(e){function n(e,t){e=e.label;f.existsSync(e)?l.openFileOrFolder(e,{curWindow:t}):(g.showMessageBox({title:C("Open Failed"),message:C("File or folder does not exist."),buttons:["Close"],cancelId:0,defaultId:0}),l.setting.removeRecentDocument(e))}try{var o=e.getItem("File").submenu.getItem("Open Recent").submenu,t=l.setting.getRecentDocuments(),i=l.setting.getRecentFolders();t.sort(function(e,t){return t.date-e.date}),i.sort(function(e,t){return t.date-e.date}),o.clear(),o.append(new c({label:C("Reopen Closed File"),accelerator:"CmdOrCtrl+Shift+T",click:function(){l.reopenClosed()}})),o.append(new c({type:"separator"})),t.length&&(t.forEach(function(e,t){10{e.type&&(hasCustom=!0,o.push({label:e.name,click:t(e)}))}),o.push({type:"separator"}),o.push({label:"Export with Previous",accelerator:"Shift+Ctrl+E",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast();")},enabled:!!l.setting.lastExport}),o.push({label:"Export and Overwrite with Previous",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast(true)")},enabled:!!l.setting.lastExport}),o.push({type:"separator"}),o.push({label:"Export Setting…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('export-setting-group');")},enabled:!0}),e&&(o.forEach(p),n=P("File→Export").submenu,o[o.length-1].enabled=(I("Export and Overwrite with Previous",n)||{}).enabled,n.clear(),o.forEach(e=>{n.append(new c(e))}),w&&s.setApplicationMenu(s.getApplicationMenu())),o}function P(e){if(!e)return null;var t,n=(W=W||{})[e];return n||(e.split("→").forEach(function(e){if(n=I(e,n),!(W[t=t?t+"→"+e:e]=n))return null}),W=null,n)}function I(e,t){var n,o=t?t.submenu:s.getApplicationMenu();return o?(n=o.getItem(e),t||n||"File"!=e?n:o.getItem("Typora")||o.getItem("Electron")):null}var W,o=null;l.forceRefreshMenu=function(){b&&(o&&clearTimeout(o),o=setTimeout(function(){s.setApplicationMenu(s.getApplicationMenu()),o=null},100))};l.updateMenu=function(e){W={};for(var t in e){var n,o,i=P(t),r=e[t];i&&(n=null,void 0!==r.accelerator&&(r.accelerator,o=x(i.label,r.accelerator),i=n=o!=i.accelerator?new c(p({label:i.label,type:i.type,enabled:i.enabled,checked:i.enabled,click:i.click,accelerator:o})):n),"Paragraph→Table"!=t?(void 0!==r.state&&(i.checked=r.state),void 0!==r.enabled&&(i.enabled=r.enabled,"Paragraph"!=t&&"Format"!=t&&"Format→Image→Zoom Image"!=t||i.submenu.items.forEach(function(e){e.enabled=r.enabled})),void 0!==r.hidden&&(i.visible=!r.hidden),!n||-1<(t=(o=P(t.replace(/→[^→]+$/,"")).submenu.items).findIndex(e=>e.label==n.label))&&(o.splice(t,1,n),console.log("newItem.accelerator "+n.accelerator))):(function(e,n){n.enabled||n.state?(e.enabled=!0,e.submenu.items.forEach(function(e,t){e.enabled=0==t?!n.state:n.state})):e.enabled=!1}(i,r),0))}W=null,l.forceRefreshMenu()},e.on("menu.updateMenu",function(e,t){l.updateMenu(JSON.parse(t))}),e.handle("menu.updateCustomZoom",e=>{l.updateMenu({"View→Actual Size":{state:!l.setting.get("customZoom")}})}),e.handle("menu.refreshThemeMenu",function(e){l.setting.refreshThemeMenu()}),e.handle("menu.reloadExportMenu",function(e){T(!0)}),e.handle("menu.popup",function(e,t){s.getApplicationMenu().popup(t)}),n.bindMainMenu=function(){function e(e,t){e=(/\((.+)\)/.exec(e.label)||[])[1]||e.label;e==C("Auto")&&(e=""),k("function(){File.reloadWithEncoding('"+e+"')}",!0)}var t=l.setting.get("SmartyPantsOnRendering")||!1,n=l.setting.get("smartQuote")||!1,o=l.setting.get("smartDash")||!1,t=[p({label:"&File",submenu:[{label:"New",accelerator:"CmdOrCtrl+N",click:r("newFile")},{label:"New Window",accelerator:"CmdOrCtrl+Shift+N",click:r("newWindow")},{type:"separator"},{label:"Open…",accelerator:"CmdOrCtrl+O",click:r("open")},{label:"Open Folder…",click:r("openFolder")},{type:"separator"},{label:"Open Quickly…",accelerator:"CmdOrCtrl+P",click:r("quickOpen")},{label:"Open Recent",submenu:[]},{label:"Reopen with Encoding",submenu:[{label:"Auto",click:e},{type:"separator"},{label:"UTF-8",click:e},{label:"UTF-16 LE",click:e},{label:"UTF-16 BE",click:e},{type:"separator"},{label:"Western (windows-1252)",click:e},{label:"Cyrillic (windows-1251)",click:e},{label:"Cyrillic (ISO-8859-2)",click:e},{label:"Cyrillic (IBM866)",click:e},{label:"Cyrillic (IBM855)",click:e},{label:"Cyrillic (KOI8-R)",click:e},{label:"Cyrillic (MacCyrillic)",click:e},{label:"Central European (windows-1250)",click:e},{label:"Central European (ISO-8859-2)",click:e},{label:"Geek (windows-1253)",click:e},{label:"Geek (ISO-8859-7)",click:e},{label:"Hebrew (windows-1255)",click:e},{label:"Hebrew (ISO-8859-8)",click:e},{label:"Chinese Simplified (GB2312)",click:e},{label:"Chinese Simplified (GB18030)",click:e},{label:"Chinese Traditional (Big5)",click:e},{label:"Japanese (SHIFT_JIS)",click:e},{label:"Japanese (EUC-JP)",click:e},{label:"Korean (EUC-KR)",click:e},{label:"Thai (TIS-620)",click:e}]},{type:"separator"},{label:"Save",accelerator:"CmdOrCtrl+S",click:r("save")},{label:"Save As…",accelerator:"CmdOrCtrl+Shift+S",click:r("saveAs")},{label:"Move To…",click:r("moveTo")},{label:"Save All…",click:r("saveAll")},{type:"separator"},d?{label:"Properties…",click:function(e,t){t&&t.webContents.executeJavaScript("File.winShell().openProperties(File.bundle.filePath);")}}:null,{label:"Open File Location…",click:r("openFileLocation")},{label:"Reveal in Sidebar",click:r(function(){window.File.editor.library.revealInSidebar()},!0)},{label:"Delete…",click:function(e,t){t&&t.webContents.executeJavaScript("File.trashSelf();")}},{type:"separator"},{label:"Import…",click:r("import")},{label:"Export",submenu:T()},{label:"Print…",accelerator:"Shift+Alt+P",click:r("print")},{type:"separator"},{label:"Preferences…",accelerator:"CmdOrCtrl+,",click:r("togglePreferencePanel")},{type:"separator"},{label:"Close",accelerator:"CmdOrCtrl+W",click:r("close")}]}),p({label:"&Edit",id:"edit",submenu:[{label:"Undo",id:"undo",accelerator:"CmdOrCtrl+Z",click:r("undo")},{label:"Redo",id:"redo",accelerator:"CmdOrCtrl+Y",click:r("redo")},{type:"separator"},{label:"Cut",accelerator:"CmdOrCtrl+X",role:"cut"},{label:"Copy",accelerator:"CmdOrCtrl+C",role:"copy"},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Paste",accelerator:"CmdOrCtrl+V",role:"paste"},{type:"separator"},{label:"Copy as Plain Text",click:r("copyAsPlainText")},{label:"Copy as Markdown",accelerator:"CmdOrCtrl+Shift+C",click:r("copyAsMarkdown")},{label:"Copy as HTML Code",click:r("copyAsHTMLSource")},{label:"Copy without Theme Styling",click:r("copyAsSemanticHTML")},{type:"separator"},{label:"Paste as Plain Text",accelerator:"CmdOrCtrl+Shift+v",click:r("pasteAsPlain")},{type:"separator"},{label:"Selection",submenu:[{label:"Select All",accelerator:"CmdOrCtrl+A",click:r("selectAll")},{label:"Select Paragraph / Block",accelerator:"CmdOrCtrl+Alt+P",click:r(function(){File.editor.selection.selectBlock()},!0)},{label:"Select Line / Sentence",accelerator:"CmdOrCtrl+L",click:r(function(){File.editor.selection.selectLine()},!0)},{label:"Select Styled Scope",accelerator:"CmdOrCtrl+E",click:r(function(){File.editor.selection.selectPhrase()},!0)},{label:"Select Word",accelerator:"CmdOrCtrl+D",click:r(function(){File.editor.selection.selectWord()},!0)},{type:"separator"},{label:"Jump to Top",accelerator:"Ctrl+Home",click:r(function(){File.editor.selection.jumpTop()},!0)},{label:"Jump to Selection",accelerator:"CmdOrCtrl+j",click:r(function(){File.editor.selection.jumpSelection()},!0)},{label:"Jump to Bottom",accelerator:"Ctrl+End",click:r(function(){File.editor.selection.jumpBottom()},!0)},{label:"Extend Selection to Top",accelerator:"Ctrl+Shift+Home",visible:!1,click:r(function(){File.editor.selection.jumpTop(!0)},!0)},{label:"Extend Selection to Bottom",accelerator:"Ctrl+Shift+End",visible:!1,click:r(function(){File.editor.selection.jumpBottom(!0)},!0)},{label:"Extend Selection to Line Start",accelerator:"Shift+Home",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!1)},!0)},{label:"Extend Selection to Line End",accelerator:"Shift+End",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!0)},!0)}]},{type:"separator"},{label:"Delete",click:r(function(){File.delete()},!0)},{label:"Delete Range",submenu:[{label:"Delete Paragraph / Block",accelerator:"Shift+CmdOrCtrl+Alt+P",click:r("deleteBlock")},{label:"Delete Line / Sentence",accelerator:"Shift+CmdOrCtrl+Alt+L",click:r("deleteLine")},{label:"Delete Styled Scope",accelerator:"Shift+CmdOrCtrl+Alt+E",click:r("deleteScope")},{label:"Delete Word",accelerator:"Shift+Ctrl+D",click:r("deleteWord")}]},{type:"separator"},{label:"Math Tools",submenu:[{label:"Refresh All Math Expressions",click:r(function(){File.editor.mathBlock.forceRefresh()},!0)}]},{type:"separator"},{label:"Smart Punctuation",submenu:[{label:"Convert on Input",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+!e+")"))},checked:!t},{label:"Convert on Rendering",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+e+")"))},checked:t},{type:"separator"},{label:"Smart Quotes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartQuote("+e+")"))},checked:n},{label:"Smart Dashes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartDash("+e+")"))},checked:o},{type:"separator"},{label:"Remap Unicode Punctuation on Parse",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setRemapPunctuation("+e+")"))},checked:l.setting.get("remapPunctuation")||!t&&(n||o),enabled:!(!t&&(n||o))},{type:"separator"},{label:"More Options…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('smart-punctuation-group');")}}]},{label:"Line Endings",submenu:[{label:"Windows Line Endings (CRLF)",type:"checkbox",click:r(function(){File.setLineEnding(!0,!0)},!0)},{label:"Unix Line Endings (LF)",type:"checkbox",click:r(function(){File.setLineEnding(!1,!0)},!0)},{type:"separator"},{label:"Insert Final New Line On Save",type:"checkbox",click:function(e,t){t&&t.webContents.executeJavaScript("File.setFinalNewline("+e.checked+")")}}]},{label:"Whitespace and Line Breaks",submenu:[{label:"Indent first line of paragraphs",type:"checkbox",click:r(function(){File.setIndentFirstLine(!File.option.indentFirstLine,!0,!0)},!0)},{type:"separator"},{label:"Visible
",type:"checkbox",checked:!0,click:r(function(){File.setHideBrAndLineBreak(!File.option.hideBrAndLineBreak,!0,!0)},!0)},{label:"Preserve single line break",type:"checkbox",checked:!0,click:r(function(){File.setIgnoreLineBreak(!File.option.ignoreLineBreak,!0,!0)},!0)},{type:"separator"},{label:"Learn More…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/Line-Break/`)}}]},{label:"Spell Check…",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.spellChecker && File.editor.spellChecker.show();")}},{type:"separator"},{label:"Find and Replace",submenu:[{label:"Find…",accelerator:"CmdOrCtrl+f",click:r(function(){File.megaMenu.isPreferencePanelShown()?File.megaMenu.searchOnPreferencePanel():File.editor.searchPanel.showPanel()},!0)},{label:"Find Next",accelerator:"F3",click:r(function(){File.editor.searchPanel.highlightNext()},!0)},{label:"Find Previous",accelerator:"Shift+F3",click:r(function(){File.editor.searchPanel.highlightNext(!0)},!0)},{type:"separator"},{label:"Replace",accelerator:"Ctrl+h",click:r(function(){File.editor.searchPanel.showPanel(!0)},!0)}]}]}),p({label:"&Paragraph",submenu:[{label:"Heading 1",type:"checkbox",accelerator:"Ctrl+1",click:r(function(){File.editor.stylize.changeBlock("header1",void 0,!0)},!0)},{label:"Heading 2",type:"checkbox",accelerator:"Ctrl+2",click:r(function(){File.editor.stylize.changeBlock("header2",void 0,!0)},!0)},{label:"Heading 3",type:"checkbox",accelerator:"Ctrl+3",click:r(function(){File.editor.stylize.changeBlock("header3",void 0,!0)},!0)},{label:"Heading 4",type:"checkbox",accelerator:"Ctrl+4",click:r(function(){File.editor.stylize.changeBlock("header4",void 0,!0)},!0)},{label:"Heading 5",type:"checkbox",accelerator:"Ctrl+5",click:r(function(){File.editor.stylize.changeBlock("header5",void 0,!0)},!0)},{label:"Heading 6",type:"checkbox",accelerator:"Ctrl+6",click:r(function(){File.editor.stylize.changeBlock("header6",void 0,!0)},!0)},{type:"separator"},{label:"Paragraph",type:"checkbox",accelerator:"Ctrl+0",click:r(function(){File.editor.stylize.changeBlock("paragraph")},!0)},{type:"separator"},{label:"Increase Heading Level",accelerator:"Ctrl+=",click:r(function(){File.editor.stylize.increaseHeaderLevel()},!0)},{label:"Decrease Heading Level",accelerator:"Ctrl+-",click:r(function(){File.editor.stylize.decreaseHeaderLevel()},!0)},{type:"separator"},{label:"Table",submenu:[{label:"Insert Table",accelerator:"Ctrl+T",click:r(function(){File.editor.tableEdit.insertTable()},!0)},{type:"separator"},{label:"Add Row Above",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!0)},!0)},{label:"Add Row Below",accelerator:"Ctrl+Return",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!1)},!0)},{type:"separator"},{label:"Add Column Before",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{label:"Add Column After",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{type:"separator"},{label:"Move Row Up",enabled:!1,accelerator:"Alt+Up",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!0)},!0)},{label:"Move Row Down",enabled:!1,accelerator:"Alt+Down",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!1)},!0)},{label:"Move Column Left",enabled:!1,accelerator:"Alt+Left",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!0)},!0)},{label:"Move Column Right",enabled:!1,accelerator:"Alt+Right",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!1)},!0)},{type:"separator"},{label:"Delete Row",enabled:!1,accelerator:"Shift+Ctrl+Backspace",click:r(function(){File.editor.tableEdit.deleteRow()},!0)},{label:"Delete Column",enabled:!1,click:r(function(){File.editor.tableEdit.deleteCol()},!0)},{type:"separator"},{label:"Copy Table",enabled:!1,click:r(function(){File.editor.tableEdit.copyTable()},!0)},{label:"Prettify Source Code",enabled:!1,click:r(function(){File.editor.tableEdit.reformatTable()},!0)},{type:"separator"},{label:"Delete Table",enabled:!1,click:r(function(){File.editor.tableEdit.deleteTable()},!0)}]},{label:"Code Fences",type:"checkbox",accelerator:"Ctrl+Shift+K",click:r(function(){File.editor.stylize.toggleFences()},!0)},{label:"Math Block",type:"checkbox",accelerator:"Ctrl+Shift+M",click:r(function(){File.editor.stylize.toggleMathBlock()},!0)},{type:"separator"},{label:"Quote",type:"checkbox",accelerator:"Ctrl+Shift+Q",click:r(function(){File.editor.stylize.toggleIndent("blockquote")},!0)},{type:"separator"},{label:"Ordered List",type:"checkbox",accelerator:"Ctrl+Shift+[",click:r(function(){File.editor.stylize.toggleIndent("ol")},!0)},{label:"Unordered List",type:"checkbox",accelerator:"Ctrl+Shift+]",click:r(function(){File.editor.stylize.toggleIndent("ul")},!0)},{label:"Task List",type:"checkbox",accelerator:"Ctrl+Shift+X",click:r(function(){File.editor.stylize.toggleIndent("tasklist")},!0)},{label:"Task Status",submenu:[{label:"Toggle Task Status",click:r(function(){File.editor.stylize.toggleTaskStatus()},!0)},{type:"separator"},{label:"Mark as Complete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!0)},!0)},{label:"Mark as Incomplete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!1)},!0)}]},{label:"List Indentation",submenu:[{label:"Indent",accelerator:"CmdOrCtrl+]",click:r(function(){File.editor.UserOp.moreIndent(File.editor)},!0)},{label:"Outdent",accelerator:"CmdOrCtrl+[",click:r(function(){File.editor.UserOp.lessIndent(File.editor)},!0)}]},{type:"separator"},{label:"Insert Paragraph Before",click:r(function(){File.editor.UserOp.insertParagraph(!0)},!0)},{label:"Insert Paragraph After",click:r(function(){File.editor.UserOp.insertParagraph(!1)},!0)},{type:"separator"},{label:"Link Reference",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_link")},!0)},{label:"Footnotes",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_footnote")},!0)},{type:"separator"},{label:"Horizontal Line",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("hr")},!0)},{label:"Table of Contents",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("toc")},!0)},{label:"YAML Front Matter",type:"checkbox",click:r(function(){File.editor.stylize.insertMetaBlock()},!0)}]}),p({label:"F&ormat",submenu:[{label:"Strong",type:"checkbox",accelerator:"CmdOrCtrl+B",click:r(function(){File.editor.stylize.toggleStyle("strong")},!0)},{label:"Emphasis",type:"checkbox",accelerator:"CmdOrCtrl+I",click:r(function(){File.editor.stylize.toggleStyle("em")},!0)},{label:"Underline",type:"checkbox",accelerator:"CmdOrCtrl+U",click:r(function(){File.editor.stylize.toggleStyle("underline")},!0)},{label:"Code",type:"checkbox",accelerator:"CmdOrCtrl+Shift+`",click:r(function(){File.editor.stylize.toggleStyle("code")},!0)},{type:"separator"},{label:"Inline Math",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("inline_math")},!0)},{label:"Strike",type:"checkbox",accelerator:"Alt+Shift+5",click:r(function(){File.editor.stylize.toggleStyle("del")},!0)},{label:"Highlight",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("highlight")},!0)},{label:"Superscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("superscript")},!0)},{label:"Subscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("subscript")},!0)},{label:"Comment",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("comment")},!0)},{type:"separator"},{label:"Hyperlink",type:"checkbox",accelerator:"Ctrl+K",click:r(function(){File.editor.stylize.toggleStyle("link")},!0)},{label:"Hyperlink Actions",submenu:[{label:"Open Link",click:r(function(){File.editor.openCurrentLink()},!0)},{label:"Copy Link Address",click:r(function(){File.editor.copyCurrentLink()},!0)}]},{label:"Image",submenu:[{label:"Insert Image",accelerator:"CmdOrCtrl+Shift+I",click:r(function(){File.editor.stylize.toggleStyle("image")},!0)},{label:"Insert Local Images…",click:r(function(){File.editor.imgEdit.insertLocalImage()},!0)},{type:"separator"},{label:"Open Image Location…",click:r(function(){File.editor.imgEdit.revealInFinder()},!0)},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Zoom Image",submenu:[{label:"25%",click:r(function(){File.editor.imgEdit.zoomAction(null,"25%")},!0)},{label:"33%",click:r(function(){File.editor.imgEdit.zoomAction(null,"33%")},!0)},{label:"50%",click:r(function(){File.editor.imgEdit.zoomAction(null,"50%")},!0)},{label:"67%",click:r(function(){File.editor.imgEdit.zoomAction(null,"67%")},!0)},{label:"80%",click:r(function(){File.editor.imgEdit.zoomAction(null,"80%")},!0)},{type:"separator"},{label:"100%",click:r(function(){File.editor.imgEdit.zoomAction(null,"100%")},!0)},{type:"separator"},{label:"150%",click:r(function(){File.editor.imgEdit.zoomAction(null,"150%")},!0)},{label:"200%",click:r(function(){File.editor.imgEdit.zoomAction(null,"200%")},!0)}]},{label:"Switch Image Syntax",submenu:[{label:"Markdown Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!1)},!0)},{label:"HTML Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!0)},!0)}]},{type:"separator"},{label:"Delete Image File",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.deleteImageAction(true)")}},{type:"separator"},{label:"Copy Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction()},!0)},{label:"Rename or Move Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction(!0)},!0)},{label:"Upload Image",click:r(function(){File.editor.imgEdit.uploadAction()},!0)},{type:"separator"},{label:"Copy All Images to…",click:r(function(){File.editor.imgEdit.copyAllImages()},!0)},{label:"Move All Images to…",click:r(function(){File.editor.imgEdit.moveAllImages()},!0)},{label:"Upload All Local Images",click:r(function(){File.editor.imgEdit.uploadAllImages()},!0)},{type:"separator"},{label:"Reload All Images",click:r(function(){File.editor.imgEdit.reloadAllByNode()},!0)},{type:"separator"},{label:"When Insert Local Image",submenu:[{label:"Copy Image File to Folder…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleCopyToFolder()},!0)},{label:"Upload Image",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUploadForFile()},!0)}]},{label:"Use Image Root Path…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUseImageRootPath()},!0)},{type:"separator"},{label:"Global Image Settings…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('image-setting-group');")}}]},{type:"separator"},{label:"Clear Format",type:"checkbox",accelerator:"CmdOrCtrl+\\",click:r(function(){File.editor.stylize.clearStyle()},!0)}]}),p({label:"&View",submenu:[{label:"Toggle Sidebar",accelerator:"CmdOrCtrl+Shift+L",click:r(function(){File.editor.library.toggleSidebar()},!0)},{label:"Outline",type:"checkbox",accelerator:"CmdOrCtrl+Shift+1",click:r("toggleOutline")},{label:"Articles",type:"checkbox",accelerator:"CmdOrCtrl+Shift+2",click:r("toggleFileList")},{label:"File Tree",type:"checkbox",accelerator:"CmdOrCtrl+Shift+3",click:r("toggleFileTree")},{label:"Search",type:"checkbox",accelerator:"CmdOrCtrl+Shift+F",click:r("globalSearch")},{type:"separator"},{label:"Source Code Mode",type:"checkbox",accelerator:"CmdOrCtrl+/",click:r(function(){File.toggleSourceMode()},!0)},{type:"separator"},{label:"Focus Mode",type:"checkbox",accelerator:"F8",click:r(function(){File.editor.toggleFocusMode()},!0),enabled:!1},{label:"Typewriter Mode",type:"checkbox",accelerator:"F9",click:r(function(){File.editor.toggleTypeWriterMode()},!0),enabled:!1},{type:"separator"},{label:"Show Status Bar",type:"checkbox",click:r("toggleStatusBar")},{type:"separator"},{label:"Toggle Fullscreen",accelerator:"F11",click:function(e,t){t&&(t.isFullScreen()?t.setFullScreen(!1):t.setFullScreen(!0))}},{label:"Always on Top",type:"checkbox",click:function(e,t){t&&(k(function(){document.body.classList.toggle("always-on-top")},!0),t.setAlwaysOnTop(!t.isAlwaysOnTop()),e.checked=t.isAlwaysOnTop())}},{type:"separator"},{label:"Actual Size",type:"checkbox",accelerator:d?"Ctrl+Shift+9":"Ctrl+Shift+0",click:function(e,t){v(function(){ClientCommand.resetZoom()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom In",accelerator:"Ctrl+Shift+=",click:function(e,t){v(function(){ClientCommand.zoomIn()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom Out",accelerator:"Ctrl+Shift+-",click:function(e,t){v(function(){ClientCommand.zoomOut()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{type:"separator"},{label:"Switch Between Opened Documents",accelerator:"Ctrl+Tab",click:function(e,t){var n;!t||-1!=(t=(n=m.getAllWindows()).indexOf(t))&&n[t=++t>=n.length?0:t].focus()}},{type:"separator"},{label:"Toggle DevTools",accelerator:"Shift+F12",click:function(e,t){var n;t&&(n=setTimeout(t.webContents.openDevTools,2e3),t.webContents.executeJavaScript("ClientCommand.toggleDevTools()").then(function(){clearTimeout(n)},function(){clearTimeout(n),t.webContents.openDevTools()}))}}]}),p({label:"&Themes",submenu:[]}),p({label:"&Help",submenu:[{label:"What's New…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/What's-New/`)}},{type:"separator"},{label:"Quick Start",click:function(e,t){l.openFile(u+"/Docs/Quick Start.md")}},{label:"Markdown Reference",click:function(e,t){l.openFile(u+"/Docs/Markdown Reference.md")}},{label:"Install and Use Pandoc",click:function(e,t){l.openFile(u+"/Docs/Install and Use Pandoc.md")}},{label:"Custom Themes",click:function(e,t){l.openFile(u+"/Docs/Custom Themes.md")}},{label:"Use Images in Typora",click:function(e,t){l.openFile(u+"/Docs/Use Images in Typora.md")}},{label:"Data Recovery and Version Control",click:function(e,t){l.openFile(u+"/Docs/Auto Save, Version Control and Recovery.md")}},{label:"More Topics…",click:function(e,t){var n=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal("https://support."+n)}},{type:"separator"},{label:"Credits",click:function(e,t){l.openFile(u+"/Docs/Credits.md")}},{label:"Change Log",click:function(e,t){l.openFile(u+"/Docs/Change Log.md")}},{label:"Privacy Policy",click:function(e,t){l.openFile(u+"/Docs/Privacy Policy.md")}},{label:"Website",click:function(){var e=l.setting.get("useMirrorInCN")?"https://typoraio.cn":"https://typora.io";a.shell.openExternal(e)}},{label:"Feedback",click:function(e,t){a.shell.openExternal("mailto:hi@typora.io")}},{type:"separator"},{label:"Check Updates…",click:function(){d&&l.updater.checkForUpdates(!0)},visible:d},{label:"My License…",click:function(){y.showLicensePanel()}},global.PRODUCTION_MODE?null:{label:"Welcome…",click:function(){y.showWelcomePanel()}},{label:"About",click:r(function(){File.megaMenu.closePreferencePanel(),document.body.classList.contains("native-window")?($(".modal:not(.block-modal)").modal("hide"),$("#about-dialog").modal("show"),$("*:focus").blur()):(File.megaMenu.show(),$("#m-about").trigger("click"))},!0)}]})];d||t[0].submenu.splice(t[0].submenu.indexOf(null),1),l.isEmojiPanelSupported()&&(t[1].submenu.push({type:"separator"}),t[1].submenu.push(p({label:"Emoji and Symbols",accelerator:d?"Super+.":"",click:function(){l.showEmojiPanel()}})));const i=t[t.length-1].submenu;for(;-1{"use strict";var a=c(93).EventEmitter,n=c(134),t=n.ipcMain,d=n.app,r=c(728),l="linux"==process.platform,s=c(541).join(__dirname,"../"),g=c(445),u=c(156),m=c(359).default,f=c(477),w=c(824),b=c(587),p=new a,o=["Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2"],h="64";"ia32"==process.arch&&(h="32"),"arm64"==process.arch&&(h="arm"),p.initUpdater=function(){return u.initDict().then(function(){return o.forEach(function(e,t){o[t]=u.getPanelString(e)}),Promise.resolve()})},p.showDetailWindow=function(e,t,n){p.progressBar&&(p.progressBar.close(),p.progressBar=null),p.win&&(p.win.destroy(),p.win=null);e=b.showPanelWindow({title:u.getPanelString("Updater"),width:640,height:600,path:"updater/updater.html?curVersion=$1&newVersion=$2&labels=$3&enableAutoUpdate=$4&releaseNoteLink=$5&hideAutoUpdates=$6".replace("$1",e).replace("$2",t).replace("$3",encodeURIComponent(JSON.stringify(o))).replace("$4",JSON.stringify(!1!==d.setting.get("enableAutoUpdate"))).replace("$5",encodeURIComponent(n)).replace("$6",global.devVersion&&!g.getHasLicense())});(p.win=e).on("closed",function(){p.win=null})},p.showUI=function(){p.win||p.progressBar||(p.progressBar=new f({title:u.getPanelString("Updater"),text:u.getPanelString("Checking Updates…"),indeterminate:!0,style:{text:{padding:"3px 0"}},browserWindow:{closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}}))};p.checkForUpdates=async function(t){var e,n,o,i=d.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",i=global.devVersion||d.setting.get("autoUpdateToDev")?`https://${i}/releases/dev_windows_${h}.json`:`https://${i}/releases/windows_${h}.json`;if(i){if(p.emit("checking-for-update"),t)p.showUI();else if((e=d.setting.get("cancelUpdate"))&&new Date-new Date(e)<432e5)return;try{var r=await m(i);if(204==r.status)return void p.emit("update-not-available");if(200!=r.status)return p.emit("update-not-available"),console.error("invalid status code: "+r.statusCode+" from "+i),"Failed to check updates, invalid status code: "+r.status;var a=await r.json(),l=(n=a,o=c(842).release().replace(/\.[^.]+$/,""),a=(o=(n.alternatives||{})[o])?Object.assign(n,o):n,p.data=a,d.getVersion());if(!a.version||!l)return;if(!(0{e||(console.log(t),p.installPathOnQuit=t,d.quit())})},p.installIfNeeded=function(){p.installPathOnQuit&&p.install(p.installPathOnQuit)},p.install=function(e){c(620).spawn(e,["/SILENT"],{detached:!0,stdio:["ignore","ignore","ignore"]}).unref()},t.handle("updater.checkForUpdates",(e,t)=>{p.checkForUpdates(t)}),t.handle("updater.cancelUpdate",e=>{p.cancelUpdate()}),t.handle("updater.skipUpdate",e=>{p.skipUpdate()}),t.handle("updater.downloadUpdate",e=>{p.downloadUpdate()}),e.exports=p},620:e=>{"use strict";e.exports=require("child_process")},289:e=>{"use strict";e.exports=require("crypto")},134:e=>{"use strict";e.exports=require("electron")},554:e=>{"use strict";e.exports=require("electron-dl")},359:e=>{"use strict";e.exports=require("electron-fetch")},477:e=>{"use strict";e.exports=require("electron-progressbar")},93:e=>{"use strict";e.exports=require("events")},834:e=>{"use strict";e.exports=require("extract-zip")},833:e=>{"use strict";e.exports=require("fs")},728:e=>{"use strict";e.exports=require("fs-extra")},232:e=>{"use strict";e.exports=require("fs-plus")},338:e=>{"use strict";e.exports=require("hjson")},783:e=>{"use strict";e.exports=require("lowdb")},207:e=>{"use strict";e.exports=require("lowdb/adapters/FileSync")},640:e=>{"use strict";e.exports=require("module")},560:e=>{"use strict";e.exports=require("node-machine-id")},842:e=>{"use strict";e.exports=require("os")},541:e=>{"use strict";e.exports=require("path")},208:e=>{"use strict";e.exports=require("process")},468:e=>{"use strict";e.exports=require("raven")},426:e=>{"use strict";e.exports=require("url")},266:e=>{"use strict";e.exports=require("util")}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;t=o[e]={id:e,loaded:!1,exports:{}};return n[e](t,t.exports,i),t.loaded=!0,t.exports}i.c=o,i.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);i(i.s=90)})(); \ No newline at end of file +(()=>{var n={883:(t,n,a)=>{var s=a(134),c=s.app,e=s.ipcMain,d=s.BrowserWindow,u="win32"==process.platform,p="linux"==process.platform,r=a(156),i=a(344);n.bindJumplist=()=>{var t;u&&(t=[{type:"custom",name:"Recent Locations",items:c.setting.getRecentFolders().slice(0,5).map(function(e){return{type:"task",title:e.name,description:e.path,program:process.execPath,args:JSON.stringify(e.path),iconPath:"explorer.exe",iconIndex:0}})},{type:"recent"},{type:"tasks",items:[{type:"task",program:process.execPath,arguments:"--new",iconPath:process.execPath,iconIndex:0,title:"New"}]}],c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t),i.loadDict().then(e=>{t[0].name=e["Recent Locations"]||"Recent Locations",t[2].items[0].title=e.New||"New",c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t)}))},e.handle("shell.saveItem",(e,{path:n,data:o})=>new Promise(t=>{a(833).writeFile(n,o,function(e){t()})})),e.handle("shell.openItem",(e,t)=>s.shell.openPath(a(541).normalize(t))),e.handle("shell.trashItem",async(e,t)=>{try{return await s.shell.trashItem(t),!0}catch(e){return!1}}),e.handle("shell.openExternal",(e,t)=>{if("about:blank"!=t)return s.shell.openExternal(t)}),e.handle("shell.showItemInFolder",(e,t)=>(u&&(t=t.replace(/\//g,"\\")),s.shell.showItemInFolder(t))),e.handle("shell.showDownload",(e,t)=>{e=d.fromWebContents(e.sender);const n=a(554)["download"];n(e,t,{saveAs:!0})}),e.handle("dialog.showMessageBox",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showMessageBox(p?null:e,t)}),e.handle("dialog.showSaveDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showSaveDialog(p?null:e,t)}),e.handle("dialog.showOpenDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showOpenDialog(p?null:e,t)}),e.handle("dialog.showOpenDialogAlone",(e,t)=>s.dialog.showOpenDialog(t));const h=t=>new Promise(e=>{setTimeout(()=>{e("sleep")},t)}),m=async(e,t)=>{var n=new d({skipTaskbar:!0,title:"Print PDF Preview",show:!1,webPreferences:{webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!1,nodeIntegration:!1,safeDialogs:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,zoomFactor:+(c.setting.get("zoomFactor")||"1"),backgroundThrottling:!1}});try{var o,i,r=t?(console.log("load file ["+t+"] for PDF export"),n.loadFile(t)):(o=a(541).join(c.setting.tempPath||c.getPath("temp"),+new Date+"tmp.html"),i=a(728),console.log("write output to temp file ["+o+"] for PDF export"),await i.outputFile(o,e),n.loadFile(o))}catch(e){return console.error(e),n&&n.destroy(),null}return Promise.race([h(2e4),r]).then(e=>"sleep"===e?(l(n.id),console.warn("Timeout for loading print view"),null):n.id).catch(e=>(console.error(e),n&&n.destroy(),null))},l=(e.handle("export.genPrintView",(e,t,n)=>(n&&l(n),m(null,t))),e=>{e=d.fromId(e);e&&(e.isDestroyed()||e.destroy())});e.handle("export.destroyPrintView",(e,t)=>{l(t)}),e.handle("export.getPageColor",async(e,t)=>{try{var n=await m(null,t);if(console.log("generate print preview window with id "+n),!n)return null;printWin=d.fromId(n),await h(200);var o=await printWin.webContents.executeJavaScript("window.getComputedStyle(document.body).backgroundColor")}catch(e){console.error(e)}finally{printWin&&printWin.destroy()}return o}),e.handle("export.print",(e,n,o)=>{var i=d.fromId(n);o=o||{},i.webContents.print(o,(e,t)=>{if(!e&&!/cancel/.exec(t||"")){if("no valid printers available"===t)return void i.webContents.executeJavaScript("window.print()").then(()=>{o.skipCleanUp||l(n)});s.dialog.showMessageBox({type:"error",message:r.getPanelString("Error"),detail:t,buttons:["OK"]})}o.skipCleanUp||l(n)})}),e.handle("export.printToPDF",async(e,t,n)=>{let o=null,i=null,r=null,a="";try{var l=await m(null,t);if(console.log("generate print window with id "+l),!l)return[i,r];o=d.fromId(l),await h(200),i=await o.webContents.printToPDF(n),console.log("get PDF data");var s=`(${function(){var e=document.querySelector("#write");return e?{color:(e=window.getComputedStyle(e)).color,fontFamily:e.fontFamily,bgColor:e.backgroundColor}:null}.toString()})()`;r=(r=await o.webContents.executeJavaScript(s))&&JSON.stringify(r),console.log("get background color")}catch(e){a=e.message||"",console.error(e)}finally{o&&o.destroy()}return[i,r,a]});var f,o,g=u?8e3:960,w=1;function b(){console.log("updateTheme");var e=c.setting.curTheme(),t=(c.execInAll("window.ClientCommand && File.setTheme('"+e+"');"),e.replace(/\.css$/,"").replace(/(^|-|_)(\w)/g,function(e,t,n,o){return(t?" ":"")+n.toUpperCase()})),e=s.Menu.getApplicationMenu().getItem("Themes");e&&e.submenu.items.map(function(e){e.checked=e.label==t})}e.handle("export.prepareImageCapture",async(e,t,n)=>{var o,i=s.screen.getPrimaryDisplay();try{w=i.scaleFactor||1;var r=i.workArea;if(g=Math.min(g,r.height-20),f=n.imageWidth,await(o=new d({skipTaskbar:!0,show:!1,webPreferences:{devTools:!1,webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!0,nodeIntegration:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,safeDialogs:!0},webgl:!1,useContentSize:!0,x:r.x,y:r.y,width:n.imageWidth,height:g,frame:!1,enableLargerThanScreen:!!u,offscreen:!0,alwaysOnTop:!0,minimizable:!1,closable:!0})).loadURL("file:///"+t),o.isDestroyed())return null;if(await h(2e3),o.isDestroyed())return null;var a=+await o.webContents.executeJavaScript("window.innerHeight");if(o.isDestroyed())return null;var l=+await o.webContents.executeJavaScript("document.body.parentElement.scrollTop = document.body.clientHeight;\nMath.max(document.body.clientHeight, document.body.parentElement.scrollHeight)");return o.isDestroyed()?null:Number.isNaN(l)||Number.isNaN(a)?void 0:(p&&(g=a),{winId:o.id,totalHeight:l,pageHeight:g,imageWidth:n.imageWidth,scale:3===n.quality?w:1})}catch(e){return console.error(e),null==o||o.isDestroyed()||o.destroy(),null}}),e.handle("export.captureImage",async(e,t,n,o)=>{t=d.fromId(t);if(!t||t.isDestroyed())return null;try{o&&(t.setSize(o.imageWidth,o.pageHeight),t.setContentSize(o.imageWidth,o.pageHeight));var i=+await t.webContents.executeJavaScript("document.body.parentElement.scrollTop = {d}; document.body.parentElement.scrollHeight;".replace("{d}",n));if(await h(1e3),t.isDestroyed()||Number.isNaN(i))return null;var r=await t.webContents.capturePage();if(!r||r.isEmpty())return null;var a=null;return 1new Promise((t,e)=>{try{var n=s.net.request({url:o,redirect:"follow"});n.on("response",function(e){try{if(200!=e.statusCode)return t(null);if(!e.data)return t(null);t({type:(e.headers["content-type"]||[""])[0],data:e.data})}catch(e){t(null)}}),n.end()}catch(e){t(null)}})),e.handle("clipboard.write",(e,t,n)=>{n&&s.clipboard.clear(),s.clipboard.write(JSON.parse(t))}),e.handle("pandoc.import",(e,n)=>{var o={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"'":"\\'","\\":"\\\\"},e=d.fromWebContents(e.sender),t=n?Promise.resolve(e):c.openFile(null,{syncAndPrepOnly:!0}).then(n=>new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e(n.activeWindow)}):e(n.activeWindow)})),e=s.dialog.showOpenDialog(n?e:null,{title:i.getMenuDict.Import,properties:["openFile"],filters:[{name:r.getPanelString("All Supported Formats"),extensions:["docx","rtf","latex","tex","ltx","rst","rest","org","wiki","dokuwiki","mediawiki","textile","opml","epub"]},{name:"MS Word",extensions:["docx"]},{name:"RTF",extensions:["rtf"]},{name:"TeX/LaTeX",extensions:["latex","tex","ltx"]},{name:"reStructuredText",extensions:["rst","rest"]},{name:"org-mode",extensions:["org"]},{name:"Wiki",extensions:["wiki","dokuwiki","mediawiki"]},{name:"Epub",extensions:["epub"]},{name:"Textile",extensions:["textile"]},{name:"OPML",extensions:["opml"]}]}).then(({filePaths:e})=>(e||[null])[0]);return Promise.all([t,e]).then(async([e,t])=>{t?(await h(100),e.show(),e.webContents.executeJavaScript('window.getSelection().removeAllRanges();ClientCommand.doImport("'+t.replace(/["'\\\b\t\n\f\r]/g,function(e){return o[e]}).replace(/\u200b/g,"")+'")')):n||e.destroy()})}),e.handle("pandoc.version",()=>o),e.handle("pandoc.setVersion",(e,t)=>{o=t}),s.nativeTheme.on("updated",function(){null!==c.setting.useDarkThemeBefore()&&c.setting.useDarkThemeBefore()!==c.setting.useDarkTheme()&&b()}),e.handle("theme.apply",()=>{b()}),e.handle("theme.setThemeSource",(e,t)=>{"system"!==(t=t||"system")&&c.setting.get("useSeparateDarkTheme")||(s.nativeTheme.themeSource=t)}),e.on("ondragstart",function(t,n,o){setTimeout(function(){var e=s.nativeImage;t.sender.startDrag({file:n,icon:o?e.createFromPath(a(541).normalize(o)):e.createEmpty()}),console.log("ondragstart "+n+" "+o)},100)}),e.handle("getPath",(e,t)=>c.getPath(t))},156:(e,t,n)=>{var o=n(134).app,i=n(728),r=n(541).join(__dirname,"../"),a=["Operation Failed","Save As","All Supported Formats","Error","Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2","Updater","Checking Updates…","Downloading Updates…","You're up to date!","Check Update Failed","Download failed","Install Updates ?","Quit and Install","Cancel","Download","Downloading…","Extracting binary…","This dev version of Typora is expired, please download and install a newer version.","This device has been deactivated","Typora is now deactivated","UNREGISTERED"],l={},s=!1;e.exports={initDict:function(){if(s)return Promise.resolve();var e=n(541).join(r,o.setting.getLocaleFolder("Panel"));return i.readJSON(e,"utf8").then(function(t){s=!0,a.map(function(e){l[e]=t[e]||e})}).catch(function(){})},getPanelString:function(e){return l[e]||e}}},351:(r,l,c)=>{function d(e,t){this.activeWindow=t||null,this.windows=new Set(t),this.path=e||null,this.snap=null,this.lastSync,this.content,this.backupState=null}var e=c(134),u=e.app,a=e.BrowserWindow,s=(e.powerMonitor,c(728)),e=c(232),h=(c(266),process.platform,process.platform,"linux"==process.platform),g=c(468),m=c(587),t=c(134).ipcMain,o=(t.on("doc.syncChange",function(e,t){var n=a.fromWebContents(e.sender),o=u.documentController.getDocumentFromWindowId(n.id);n==o.activeWindow&&1=n}catch(e){console.warn(e)}return!1}},d.prototype.getWindowToFocus=function(){var e=this.activeWindow||this.windows.keys().next().value;if(e){if(!e.isDestroyed())return e;this.activeWindow=null,this.windows.delete(e)}return null},d.prototype.syncFullContent=function(t){var e,n=!1;if(this.windows.forEach(function(e){this.activeWindow!=e&&!n&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&(n=!0)}),n)return e=this.windows,this.activeWindow.webContents.executeJavaScript("File.sync(false, true);1;").then(function(){e.forEach(function(e){this.activeWindow!=e&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&e.webContents.executeJavaScript("File.editor.applyFullContent("+!!t+")")})}),null},d.prototype.popBackupState=async function(){var e=this.backupState;return this.backupState=void 0,Promise,e},function(e){return c(541).basename(e)}),f=e.isCaseInsensitive();function p(e){return f?e&&e.toLowerCase():e}function n(){this.documents=new Set,this.path2doc=new Map,this.win2doc=new Map,this.name2docs=new Map,this.frozenDocs=[],this.watchSystemPause()}n.prototype.watchSystemPause=function(){u.whenReady().then(()=>{})},n.prototype.setContentForWindow=function(e,t){var n=this.getDocumentFromWindowId(t);(n.activeWindow||{}).id==t&&n.setContent(e)},n.prototype.solveDuplicateName_=function(e){var t=e.path,t=p(o(t)),n=this.name2docs.get(t)||new Set;this.name2docs.set(t,n),0{e=a.fromWebContents(e.sender),t=t?u.getDocumentController().getDocument(t):u.documentController.getDocumentFromWindowId(e.id);t&&t.activeWindow==e&&t&&t.switchToUntitled(n)}),t.handle("document.setLastSync",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).setLastSync(t)}),t.handle("document.syncFullContent",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).syncFullContent(t)}),t.handle("document.getContent",e=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).getContent()}),t.handle("document.currentPath",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).path});const b=async e=>{var t=e.getSnap(null),n=e.path,o=!1,i=null;return(t||{}).nodeMap?o=await e.shouldReadFromDisk():i=await e.popBackupState(),i&&i.hasUnsaved?console.log("load from recover content length: "+i.content.length):i=null,JSON.stringify({snap:t,filePath:n,backups:i,shouldReadFromDisk:o,windowCounts:e.windows.size})};t.handle("document.loadData",async e=>{console.log("handle document.loadData");new Date;e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),e=await b(e);return new Date,e}),t.handle("document.switchDocument",async(e,t)=>{e=a.fromWebContents(e.sender),e=await u.getDocumentController().switchDocument(e.id,t);return b(e)}),t.handle("document.rename",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).rename(t),!0}),t.handle("document.setContent",(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=e.content==t;return e.setContent(t),n}),t.handle("document.addSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return t?e.addSnap(JSON.parse(t)):e.addSnap(null),!0}),t.handle("document.addSnapAndLastSync",(e,t)=>{try{var n,o,i=a.fromWebContents(e.sender),r=u.documentController.getDocumentFromWindowId(i.id);t?({snap:n,lastSync:o}=JSON.parse(t),r.addSnap(n),r.setLastSync(o)):r.addSnap(null)}catch(e){console.error(e)}return!0}),t.handle("document.shouldSaveSnap",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).shouldSaveSnap()}),t.handle("document.getSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return JSON.stringify(e.getSnap(t))}),t.handle("document.getSnapWithValidation",async(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=await e.isSnapValid();return JSON.stringify({snap:e.getSnap(t),shouldReadFromDisk:0==n})}),t.handle("document.enterOversize",e=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);e&&e.enterOversize()}),t.handle("document.newWindow",e=>{3==u.setting.get("restoreWhenLaunch")?u.openFile(null,{mountFolder:u.setting.get("pinFolder"),silent:"pinFolder"}):u.openFile()}),t.handle("document.checkIfMoveOnSave",(e,t)=>{var e=a.fromWebContents(e.sender),n=u.documentController.getDocument(t);return!n&&((n=u.documentController.getDocumentFromWindowId(e.id)).rename(t),!0)}),t.handle("document.hasDuplicateName",(e,t)=>u.documentController.hasDuplicateName(t)),t.handle("document.noOtherWindow",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).windows.size<=1});var i=new n;r.exports=i},824:(e,t,s)=>{var c=s(728),d=s(541),u={title:"Download",text:"Downloading…",indeterminate:!1,initialValue:0,maxValue:1,closeOnComplete:!1,abortOnError:!1,style:{text:{padding:"3px 0"}},browserWindow:{modal:!1,closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}};function p(e){if(e<1024)return e+" B";var t=e/Math.pow(1024,1),e=e/Math.pow(1024,2);return e<1?(t+"").replace(/(\..)(.+)$/,"$1")+"KB":(e+"").replace(/(\..)(.+)$/,"$1")+"MB"}function n(e,t,n){this.onAbort=null,this.onSuccess=null,this.onError=null,this.downloadURL=e,this.dist=t,this.displayOption=n||{},this.progressBar=null,this.downloadItem=null}n.prototype.cancel=function(){if(this.downloadItem){try{this.downloadItem.cancel()}catch(e){}this.downloadItem=null}this.setCompleted(),this.onAbort&&this.onAbort()},n.prototype.setCompleted=function(){this.downloadItem=null,this.progressBar&&(this.progressBar.setCompleted(),this.progressBar.close(),this.progressBar=null)},n.prototype.download=function(){var e=s(477),t=s(554),n=this,o=this.downloadURL,i=this.dist,r=this.displayOption,a=new e(Object.assign({},u,r)),l=((this.progressBar=a).on("aborted",function(){n.cancel()}),d.dirname(i));Promise.all([new Promise(function(e){a.on("ready",e)}),c.ensureDir(l)]).then(function(){console.record("[downloader] downloading "+o,"DEBUG"),t.download(a._window,o,{showBadge:r.showBadge||!1,directory:l,filename:d.basename(i),onProgress:function(e){a&&(a.value=e.percent*(r.processOnComplete||1),a.detail=p(e.transferredBytes)+" / "+p(e.totalBytes))},onStarted:function(e){console.log("start downloading "+e.getURL()),n.downloadItem=e},onCancel:function(){console.log("canceled downloading "+downloadItem.getURL()),n.cancel()}}).then(function(e){n.onSuccess(e,a)}).catch(function(e){console.log("error downloading "+(n.downloadItem&&n.downloadItem.getURL())),n.onError(e)})})},e.exports=n},405:(e,t,n)=>{var n=n(134),o=n.app,n=n.ipcMain,i=global.t_workingDir,r=o.getVersion(),a=(/-([a-z]+)/.exec(r)||[])[1],l=r;function s(e,t){var n,o,i;for(e=(e||"").replace(/-[a-z]+/,""),t=(t||"").replace(/-[a-z]+/,""),e=e.split("."),t=t.split("."),o=Math.min(e.length,t.length),n=0;n({PRODUCTION_MODE:global.PRODUCTION_MODE,DEBUG_MODE:global.DEBUG_MODE,version:o.getVersion(),devVersion:global.devVersion})),global.compareVersion=s,global.t_workingDir=i,global.PRODUCTION_MODE=!0,global.DEBUG_MODE=!1},932:(e,t,n)=>{function o(){this.clearUndo()}function i(e){r.dialog.showErrorBox(l.getPanelString("Operation Failed"),e.message)}var r=n(134),a=r.app,l=n(156),s=n(728),n=r.ipcMain,c=(o.prototype.hasUndo=function(e){return!(!this.hasUndo_||!e)&&(0==(this.undoTo_||"").indexOf(e)||0==(this.undoFrom_||"").indexOf(e))},o.prototype.undoLabel=function(){return this.undoLabel_},o.prototype.clearUndo=function(){this.undoFrom_="",this.undoTo_="",this.undoLabel_="",this.hasUndo_=!1},o.prototype.registerUndo=function(e,t,n){this.undoFrom_=e,this.undoTo_=t,this.undoLabel_=n,this.hasUndo_=!0},o.prototype.getFocusPath=function(){return this.hasUndo_&&this.undoTo_},o.prototype.performUndo=function(){var t;function n(){r.dialog.showMessageBox({type:"warning",message:l.getPanelString("Operation Failed"),defaultId:0,cancelId:1,buttons:[l.getPanelString("Save As"),l.getPanelString("Cancel")]}).then(({response:e})=>{0==e?r.dialog.showSaveDialog({defaultPath:t.undoTo_,properties:["showOverwriteConfirmation"]}).then(({filePath:e})=>{e&&e!=t.undoFrom_&&s.rename(t.undoFrom_,e,function(e){e&&i(e)}),t.clearUndo()}):t.clearUndo()})}this.hasUndo_&&(this.hasUndo_=!1,(t=this).undoTo_?s.existsSync(this.undoTo_)?n():(a.sendEvent("willRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),s.copyFile(this.undoFrom_,this.undoTo_,function(e){s.unlink(t.undoFrom_,function(){}),e?(n(),a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoFrom_})):(a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),t.clearUndo())})):s.remove(this.undoFrom_,function(e){e?i(e):(t.clearUndo(),a.sendEvent("updateQuickOpenCache",{toDel:this.undoFrom_}))}))},new o);n.handle("filesOp.registerUndo",(e,t,n,o)=>{c.registerUndo(t,n,o)}),n.handle("filesOp.clearUndo",e=>{c.clearUndo()}),n.handle("filesOp.performUndo",e=>{c.performUndo()}),n.handle("filesOp.getFocusPath",e=>c.getFocusPath()),n.handle("filesOp.undoLabel",(e,t)=>c.hasUndo(t)?c.undoLabel():null),t.default=c},445:(o,u,i)=>{i(405);var p,h=i(156),g=i(134),m=g.shell,l=g.app,e=g.ipcMain,f=g.BrowserWindow,w="win32"==process.platform,b="darwin"==process.platform,y="linux"==process.platform,v=i(587),k=i(359).default,s=i(468),C=!1;const F=function(e){try{return require(e)}catch(e){if(C)return;C=!0;var t=e.message;setTimeout(()=>{C=!1,(dialog=i(134).dialog).showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:"A required module cannot be loaded by Typora",message:t.split("\n")[0]+"\n\nPlease check if that file exists or reinstall Typora to fix."}).then(({})=>{process.exit(1)})},1500)}};var S,r=null,x="",c="",a="",D="";const T={SUCCESS:0,OUT_OF_LIMIT:1,INVALIDATE:-1,WRONG_USER:-2},P=JSON.parse(Buffer.from("WyItLS0tLUJFR0lOIFBVQkxJQyBLRVktLS0tLSIsIk1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBN25Wb0dDSHFJTUp5cWdBTEVVcmMiLCI1SkpoYXAwK0h0SnF6UEUwNHB6NHkrbnJPbVk3LzEyZjNIdlp5eW9Sc3hLZFhUWmJPMHdFSEZJaDBjUnFzdWFKIiwiUHlhT09QYkEwQnNhbG9mSUFZM21SaFFRM3ZTZitybjNnK3cwUyt1ZFdtS1Y5RG5tSmxwV3FpekZhalU0VC9FNCIsIjVaZ01OY1h0M0UxaXBzMzJyZGJUUjBObmVuOVBWSVR2cmJKM2w2Q0kyQkZCSW1aUVoyUDhOK0xzcWZKc3F5VlYiLCJ3RGt0M21IQVZ4VjdGWmJmWVdHKzhGRFN1S1FIYUNtdmdBdENoeDlod2wzSjZSZWtrcURWYTZHSVYxM0QyM0xTIiwicWRrMEpiNTIxd0ZKaS9WNlFBSzZTTEJpYnk1Z1lONnpRUTVSUXBqWHRSNTNNd3pUZGlBekdFdUtkT3RyWTJNZSIsIkR3SURBUUFCIiwiLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tIiwiIiwiIl0=","base64").toString("utf8")).join("\n"),I=864e5;var W="https://store.typora.io";const E=e=>{if(!e)return e;var t;try{t=Buffer.from(e,"base64");const n=i(289).publicDecrypt(P,t);return JSON.parse(n.toString("utf8"))}catch(e){return null}},O=function(){var e=Array.from(arguments);const t=i(289).createHash("sha256");return e.forEach(e=>{t.update(e)}),t.digest("base64")},_=()=>{const e=d().get("SLicense");if(!e)return null;var[t,n,o]=e.split("#"),t=E(t);return t&&t.fingerprint==a?(Object.assign(t,{failCounts:n,lastRetry:new Date(o)}),t):null},M=async e=>{console.log("writeInstallDate fromBTime="+e);var t=new Date;if(e)try{var n=await i(728).stat(l.getPath("userData")+"/profile.data"),t=new Date(n.birthtime);n.birthtime}catch(e){}e=(p=t).toLocaleDateString("en-US");return d().put("IDate",e),p};var L=null;const d=function(){var n;return L=null==L?w?function(){const o=F("native-reg"),i="Software\\Typora";return{get:function(e){var t=o.openKey(o.HKCU,i,o.Access.READ);if(null==t)return"";e=o.getValue(t,null,e);return o.closeKey(t),e},put:function(e,t){var n=o.createKey(o.HKCU,i,o.Access.WRITE);o.setValueSZ(n,e,t),o.closeKey(n)}}}():(n=l.setting.prepDatabase(a),{put:function(e,t){console.log("ls put "+e),n.getState()[e]=t,n.write()},get:function(e){return n.getState()[e]}}):L};const U=async()=>{if(!a){if(w){const t=F("native-reg");var e=t.openKey(t.HKEY.LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Cryptography",t.Access.WOW64_64KEY|t.Access.READ);a=t.getValue(e,null,"MachineGuid"),t.closeKey(e)}else a=await i(560).machineId({original:!0});a||s.captureMessage("[L] Failed to get fingerPrint"),a=O(a,"typora").substr(0,10).replace(/[/=+-]/g,"a"),b&&(a+="darwin")}return a};var R=!1;const A=()=>{var e=s.getContext().tags;e.hasLicense=r,s.mergeContext(e)},N=()=>process.platform.replace(/\d+/,""),B=async(t,n,o)=>{oe(),console.log(`request ${W}/`+t);const e=new AbortController;var i,r=setTimeout(()=>e.abort(),3e4);try{i=await k(W+"/"+t,{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}}),clearTimeout(r)}catch(e){var a=e;if(console.warn(e.stack),clearTimeout(r),o&&"zh-Hans"==l.setting.getUserLocale()&&!l.setting.get("useMirrorInCN")){r=(await g.dialog.showMessageBox(null,{message:"链接服务器失败,使用尝试访问国内域名进行激活?",buttons:["确认","取消"]}))["response"];if(console.log("click "+r),r)throw a;return l.setting.put("useMirrorInCN",!0),B(t,n,!1)}if(l.setting.get("useMirrorInCN"))try{console.log("request to typora.com.cn"),i=await post("https://typora.com.cn/store/"+t,n)}catch(e){throw a}}if(i){if(200==i.status)return-1{const o=(new Date).toLocaleDateString("en-US");var{deviceId:t,lastRetry:i}=t||{};if(n||!(new Date-ir.abort(),4e4);const a=await(await k(W+"/api/client/renew",{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}})).json();clearTimeout(e),a.success||(console.warn("[renewL]: unfill due to renew fail"),$(a.msg)),d().put("SLicense",[a.msg,0,o].join("#"))}catch(e){e.stack,s.captureException(e,{level:"warning"}),console.warn("Failed to Renew L");var[t,n]=(i=d().get("SLicense")).split("#"),i=[t,n=+n+1,o].join("#");d().put("SLicense",i)}}},J=e=>{var t=new Date(d().get("IDate"));return isNaN(t.getTime())?e?null:new Date:e?t:(e=1676345080018,isNaN(e)?e=new Date("2021-10-01"):(e=new Date(e),isNaN(e.getTime())&&(e=new Date("2021-10-01"))),t{if(t=t||15,432e5{var e=(p=J(!global.devVersion))?V(!1):100;(15{R=!0;var t=_(),{license:n,email:o,type:i}=t||{};n&&o?(j(o,n,i),z(t,e)):$()},K=(e,t)=>g.dialog.showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:e,message:t}),Q=function(){l.expired=!0,K(h.getPanelString("Error"),h.getPanelString("This dev version of Typora is expired, please download and install a newer version.")).then(()=>{m.openExternal("https://typora.io/#download"),setTimeout(()=>{process.exit(1)},1e3)})},Z=function(){var e;re()&&!l.setting.inFirstShow&&(e=y||global.devVersion,y&&Math.random()<.8||(!S||new Date-S>36e5*(e?4:2)||!e&&V(!0,16)<=0)&&Y())};var G=!1,t=null;const Y=async function(e){if(S=new Date,null==t)return(t=v.showPanelWindow({width:525,height:420,path:`page-dist/license.html?dayRemains=${V(!0)}&index=${e?1:0}&hasActivated=${r||!1}&email=${x}&license=${c}&lang=${l.setting.getUserLocale()}&needLicense=${ie()&&!global.devVersion}&type=${D}&os=`+(w?"win":b?"mac":"linux"),frame:!1,alwaysOnTop:!C})).on("closed",function(){t=null}),void setTimeout(()=>{t&&!t.isDestroyed()&&t.setAlwaysOnTop(!1)},5e3);t.focus()};var n=null;async function X(){var o=(o=process.env.USER)||i(842).userInfo().username;switch(process.platform){case"win32":return process.env.COMPUTERNAME+" | "+o+" | Windows";case"darwin":return new Promise(n=>{i(620).exec("scutil --get ComputerName",{timeout:5e3},(e,t)=>{n(!e&&t?t.toString().trim()+" | "+o+" | darwin":i(842).hostname()+" | "+o+" | darwin")})});default:return i(842).hostname()+" | "+o+" | Linux"}}async function ee(e){try{var{fingerprint:t,email:n,license:o,type:i}=E(e)||{};return n&&o&&t?t!=await U()?(console.log("[L] validate server return fail"),$(),!1):(j(n,o,i),d().put("SLicense",e+"#0#"+(new Date).toLocaleDateString("en-US")),r=!0):(console.log("[L] validate server return empty"),$(),!1)}catch(e){throw console.error(e.stack),new Error("WriteActivationInfoFail")}}const te=e=>{const r="L23456789ABCDEFGHJKMNPQRSTUVWXYZ";if(!/^([A-Z0-9]{6}-){3}[A-Z0-9]{6}$/.exec(e))return!1;var e=e.replace(/-/g,""),t=e.substr(22);return!e.replace(/[L23456789ABCDEFGHJKMNPQRSTUVWXYZ]/g,"")&&t==(e=>{for(var t="",n=0;n<2;n++){for(var o=0,i=0;i<16;i+=2)o+=r.indexOf(e[n+i]);o%=r.length,t+=r[o]}return t})(e)},ne=(e.handle("license.machineCode",async()=>{console.log("handle license.machineCode");try{return await Buffer.from(JSON.stringify({v:N()+"|"+l.getVersion(),i:await U(),l:await X()}),"utf8").toString("base64")}catch(e){console.error(e.stack)}}),async t=>{r&&x&&c||console.error("doDeactivation on unregistered device");var e=(_()||{})["deviceId"];try{await B("api/client/deactivate",{license:c,l:e,sig:O(x,await U(),c)},!1)}catch(e){if(s.captureException(e,{level:"warning"}),console.log(e.stack),!t&&"off"==D)return!1}return $(),!0}),oe=(e.handle("addLicense",async(e,{email:t,license:n,force:o})=>{try{return await async function(e,t,n){if(e=(e||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),t=(t||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),!/^[^\s@'"/\\=?]+@[^\s@'"/\\]+\.[^\s@'"/\\]+$/.test(e))return[!1,"Please input a valid email address"];if(!te(t))return[!1,"Please input a valid license code"];t={v:N()+"|"+l.getVersion(),license:t,email:e,l:await X(),f:await U(),u:l.setting.generateUUID(),type:global.devVersion?"dev":"",force:n};JSON.stringify(t);try{var o=await B("api/client/activate",t,!0);if(JSON.stringify(o),console.log("[License] response code is "+o.code),o.code==T.SUCCESS)return await ee(o.msg)?[!0,""]:[!1,"Please input a valid license code"];if(o.code==T.OUT_OF_LIMIT)return n?await ee(o.msg)?[!0,"Your license has exceeded the max devices numbers.\nThe oldest device was unregistered automatically."]:[!1,"Please input a valid license code"]:["confirm",'Your license has exceeded the max devices numbers.\nIf you click "Continue Activation", this device will be activated and the oldest device will be unregistered automatically.'];if(o.code==T.INVALIDATE)return[!1,"Please input a valid license code"];if(o.code==T.WRONG_USER)return[!1,"This license code has been used with a different email address."]}catch(e){return"WriteActivationInfoFail"==e.message?(ne(!0).then(()=>{},()=>{}),[!1,"Failed to write your license to local machine"]):e.response&&e.response.code?(console.warn("[L] error from server "+e.response.code),[!1,"Unknown Error. Please contact hi@typora.io"]):(s.captureException(e,{level:"warning"}),console.error(e.stack),[!1,"Failed to access the license server. Please check your network or try again later."])}}(t,n,o)}catch(e){console.error(e.stack)}}),e.handle("offlineActivation",async(e,t)=>{try{return n=t,await(await ee(n)?[!0,"",x,c]:[!1,"Please input a valid license code"])}catch(e){console.error(e.stack)}var n}),e.handle("license.show",(e,t)=>{Y(t||!1)}),e.handle("license.show.debug",()=>{t&&t.webContents.openDevTools()}),e.handle("removeLicense",async e=>{try{return await ne()}catch(e){console.error(e.stack)}return!1}),()=>{W=l.setting.get("useMirrorInCN")?shostc||"".substring(1):global.shost||"".substring(1)});const ie=()=>!r&&!y,re=e=>R&&!r;var ae;ae=(new Date).getTime();const le="txxxx-xxxx-xxxxy".replace(/[x]/g,function(e){var t=(ae+16*Math.random())%16|0;return ae=Math.floor(ae/16),t.toString(16)}),se=()=>{f.getAllWindows().forEach(e=>{e.webContents.executeJavaScript(`try{document.querySelector(".${le}").remove();}catch(e){};File.option && (File.option.hasLicense = true);File.megaMenu && File.megaMenu.forceReload();0;`)})},ce=async e=>{await h.initDict();const t=`.typora-sourceview-on .${le}{left: 170px;}.${le} {position: fixed;bottom: 2px;z-index: 9999;left: 70px;font-size: 12px;line-height: 24px;background: rgb(120 120 120 / 30%);padding: 0 12px;color: var(--text-color);border-radius: 4px;cursor: pointer;}.pin-outline .${le}{left:calc(var(--sidebar-width) + 70px);}`,n=`if(window.File.option){File.option.hasLicense = false;File.megaMenu && File.megaMenu.forceReload(); };1;`;function o(e){e.webContents.insertCSS(t.replace(/(\{|\}|;)\n/g,"$1")),e.webContents.executeJavaScript(n.replace(/(\{|\}|;)\n/g,"$1"))}e?o(e):f.getAllWindows().forEach(o)};w&&(e=i(541).join(t_workingDir,"../winmm.dll"),i(833).stat(e,function(e,t){!e&&t&&setTimeout(function(){G=!0},138e4)})),u.startL=async(e,t)=>{console.log("start LM in devVersion="+(global.devVersion||!1));try{oe(),await U(),!e&&t||y||(global.devVersion||!t||-1240*I)&&Q(),n=+n,console.log("verInitTime is "+n),!isNaN(n)&&o-n>200*I&&Q()),(async e=>{console.log("[watch L]"),q(e),r=true,await H(),console.log("[watch L] hasL: "+r),Z(),A()})(e)}catch(e){s.captureException(e)}var n,o,i;v.on("dom-ready",e=>{e=e,R&&re()&&ce(e)}),v.on("make-window",e=>{Z()})},u.showLicensePanel=Y,u.showWelcomePanel=async function(){if(S=new Date,null==n)return(n=v.showPanelWindow({width:760,height:460,path:"page-dist/welcome.html?lang="+l.setting.getUserLocale(),frame:!1,alwaysOnTop:!C})).on("closed",function(){n=null}),void setTimeout(()=>{n&&!n.isDestroyed()&&n.setAlwaysOnTop(!1)},4e3);n.focus()},u.shouldShowWelcomePanel=ie,u.getHasLicense=()=>r,u.cannotContinueUse=function(){return!1===r&&!y&&!global.devVersion&&(G||V(!0,20)<=0)}},557:(o,i,F)=>{var c,d,W=global.PRODUCTION_MODE,S=F(134),x=S.app,u=F(266),r=F(338),a=S.Menu,l=S.MenuItem,p=S.BrowserWindow,s=S.shell,D="win32"==process.platform,h="darwin"==process.platform,g="linux"==process.platform,T=F(728),P=F(541).join(__dirname,"../"),m=F(344),f=F(824),w=F(156),E=F(445),b=require(W?"package.json":"../package.json"),I=F(468),y=1e4;function v(t){var o,i,r=0,n=x.getPath("userData")+"/typora.log",a="",l=console.error;function s(e,t){try{if(y{this.logStream=e})}function k(){var n=(new Date).getTime();return uuid="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),("x"==e?t:3&t|8).toString(16)})}function _(t){var e=1676345080018,n=!1,o=0;isNaN(e)||(o=30<(e=(new Date-e)/864e5/5)?(n=!0,.001):Math.max(0,(30-e)/30),isNaN(o)&&(o=.01)),I.config("https://41af752e6d61480d85276af874a7f69b@sentry.typora.io/2",{logger:"node",release:b.releaseId,autoBreadcrumbs:{http:!1,console:!1},sampleRate:o,shouldSendCallback:function(e){return(!e||"debug"!=e.level)&&(!n&&!t.hasUpdates&&t.db&&t.get("send_usage_info")+""!="false")}}).install(B),C=k(),I.mergeContext({tags:{instance:C,arch:process.platform,appVersion:x.getVersion()}}),I.disableConsoleAlerts(),setTimeout(function(){console.log("[Raven] instanceKey = "+C)},0),I.setDataCallback(function(e){try{return e?(e.request&&(e.request.url="http://typora/"),e.mechanism&&delete e.mechanism,e.exception&&(t=e)&&(t.message&&(t.message=L(t.message)),(t.exception||[]).forEach(function(e){e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&e.stacktrace.frames.forEach(function(e){e.filename&&(e.filename=U(e.filename))})}),n=t.stacktrace||[],(t=(t.exception||{}).values||[]).forEach&&t.forEach(function(e,t){e&&(e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&(n=n.concat(e.stacktrace.frames)))}),n.length&&n.forEach(function(e){var t;-1<(t=e.filename.lastIndexOf("atom.asar"))&&(e.filename="http://typora-app/atom/"+e.filename.substring(t+9).replace(/\\/g,"/"))})),e):void 0}catch(e){console.error(e.stack)}var t,n;return{}})}e.prototype.closeLogging=function(){console.log("closeLogging");try{c=!0,d&&(process.stdout.write=process.stderr.write=d),this.logStream&&this.logStream.end()}catch(e){console.error(e)}},e.prototype.put=function(e,t){this.db.getState()[e]=t,this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=setTimeout(this.save.bind(this),500)},e.prototype.get=function(e,t){try{return"recentDocument"==e?this.getRecentDocuments():"recentFolder"==e?this.getRecentFolders():("framelessWindow"!=e||!g)&&(void 0===(n=this.db.getState())[e]?t:n[e]);var n}catch(e){return console.error(e),t}},e.prototype.save=function(){this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=null;try{this.db.write()}catch(e){console.error(e.stack)}},e.prototype.syncAll=function(){this.saveTimer&&clearTimeout(this.saveTimer);try{this.db.write(),this.history.write()}catch(e){console.error(e.stack)}},e.prototype.getAllThemes=function(){return this.allThemes},e.prototype.getRecentFolders=function(){var e=this.history.getState(),t=e.recentFolder;return t||(e.recentFolder=t=[]),t||[]},e.prototype.addRecentFolder=function(e){console.log("addRecentFolder"),e=F(541).normalize(e);var t=F(541).basename(e),n=this.getRecentFolders();if(t.length){this.removeRecentFolder(e,!0),n.unshift({name:t,path:e,date:new Date}),8new Promise(e=>{T.rm(l.join(v,t),{force:!0,recursive:!0,maxRetries:1},e)})))}await 0}if(0==o&&T.existsSync(a))g();else{console.log("overwriteThemeFolder"),T.ensureDirSync(f);var w=[];if(-1<["github.css","newsprint.css","night.css","pixyll.css","white.css"].indexOf(e)){try{T.renameSync(l.join(a,e),l.join(f,e)),w.push(e)}catch(e){}T.copySync(l.join(m,e),l.join(a,e),{overwrite:!0})}h.list(m,function(e,t){Promise.all(t.map(function(e){var r=l.basename(e);return new Promise(function(e,t){if(-1{}),C.rm(s.join(c,i+".aff"),{force:!0},()=>{}),C.rm(s.join(c,i+"-LICENSE"),{force:!0},()=>{}),console.log(`remove ${c}/${i}.dic`)}}else this.put("strict_mode",!0),this.put("copy_markdown_by_default",!0)}this.initDictionary_(),this.addAnalyticsEvent("launch"),t&&0!=o?this.addAnalyticsEvent(0{var t=x.setting.get("export.general")||{},n={},o=(["pdf","html","html-plain","image"].forEach(e=>{n[e]=Object.assign({type:e},t,x.setting.get("export."+e)||{})}),{});return x.setting.loadCustomExports().forEach(e=>{o[e.key]=Object.assign({},t,e,x.setting.get("export."+e.key)||{})}),JSON.stringify([n,o])}),n.handle("export.recordLastExport",(e,t)=>{A||(x.updateMenu({"File→Export→Export with Previous":{enabled:!0}}),x.updateMenu({"File→Export→Export and Overwrite with Previous":{enabled:!0}})),A=t,x.setting.lastExport=t,x.execInAll("File.option._lastExport = "+JSON.stringify(t))}),n.handle("setting.getDownloadingDicts",e=>JSON.stringify(x.setting.downloadingDicts||[])),n.handle("setting.getUserDictionaryPath",e=>x.setting.getUserDictionaryPath()),n.handle("setting.getUserDict",e=>JSON.stringify(x.setting.userDict)),n.handle("setting.downloadDict",(e,t)=>{e=p.fromWebContents(e.sender);x.setting.downloadDict(t,e.id)}),n.handle("setting.getThemes",e=>({all:x.setting.getAllThemes()||[],current:x.setting.curTheme()})),n.handle("setting.setCurTheme",(e,t,n)=>{x.setting.setCurTheme(t,n)}),n.handle("setting.resetAdvancedSettings",(e,t)=>{function n(){}var o=F(728),i=x.getPath("userData")+"/conf/conf.user.json";o.copy(P+"/conf.default.json",x.getPath("userData")+"/conf/conf.default.json",{overwrite:!0},t?function(){S.shell.showItemInFolder(i)}:n),o.copy(P+"/conf.default.json",i,{overwrite:!0},n)}),n.handle("logger.error",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Error] "+t)}),n.handle("logger.warn",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Warn] "+t)}),n.handle("setting.clearRecentDocuments",e=>{x.setting.clearRecentDocuments()}),n.handle("setting.removeRecentFolder",(e,t)=>{x.setting.removeRecentFolder(t)}),n.handle("setting.removeRecentDocument",(e,t)=>{x.setting.removeRecentDocument(t)}),n.handle("setting.addRecentFolder",(e,t)=>{x.setting.addRecentFolder(t)}),n.handle("setting.getRecentFiles",e=>JSON.stringify({files:x.setting.getRecentDocuments()||[],folders:x.setting.getRecentFolders()||[]})),n.handle("setting.put",(e,t,n)=>{x.setting.put(t,n)}),n.handle("setting.get",(e,t)=>x.setting.get(t)),n.handle("setting.fetchAnalytics",e=>{var t=JSON.stringify(x.setting.analyticsEvents);return x.setting.analyticsEvents=[],t}),null),B=(n.handle("setting.getUnsavedDraftsPath",e=>x.setting.getUnsavedDraftPath()),e.prototype.getUnsavedDraftPath=function(){return N?Promise.resolve(N):(N=F(541).resolve(x.getPath("userData"),"draftsRecover"),F(728).ensureDir(N).then(()=>N))},function(e,t,n){t&&console.info(t.stack||t.message),e=e||{},console.error(e.stack||e.message),!x.isReady()||"ENOTFOUND"!=(t=e.errno||e.code)&&"ETIMEDOUT"!=t&&"ECONNRESET"!=t&&0!=(e.message||"").indexOf("net::ERR")&&(dialog=F(134).dialog,stack=null!=(ref=e.stack)?ref:e.name+": "+e.message,message="Uncaught Exception:\n"+stack,dialog.showMessageBox(null,{type:"error",buttons:["OK","Learn Data Recovery"],defaultId:0,cancelId:0,title:"A JavaScript error occurred in the main process",message:message}).then(({response:e})=>{1==e?(e=x.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",s.openExternal(`https://support.${e}/Version-Control/`)):process.exit(1)}))});function z(t,n){p.getAllWindows().forEach(function(e){e.isDestroyed()||e.webContents.isDestroyed()||e.webContents.isLoading()||e.webContents.send(t,n)})}function J(e,t){t=e.indexOf(t);-1{},()=>{}),console.error(e),I.captureException(e)}}catch(e){console.error(e),I.captureException(e)}try{o.userDictionaryPath?(e=await T.readFile(this.userDictionaryPath+"/user-dict.json","utf8"),o.userDict=JSON.parse(e)):console.error("no userDictionaryPath found")}catch(e){console.warn("user-dict.json not found")}function r(){o.userDictionaryPath&&F(833).writeFile(o.userDictionaryPath+"/user-dict.json",JSON.stringify(o.userDict),function(){}),x.sendEvent("user-dict-update",o.userDict)}n=S.ipcMain;n.on("user-dict-add",function(e,t){var{lang:t,word:n}=t;o.userDict[t]=o.userDict[t]||[],-1==o.userDict[t].indexOf(n)&&o.userDict[t].push(n),r()}),n.on("user-dict-remove",function(e,t){o.userDict[t.lang]=(o.userDict[t.lang]||[]).filter(function(e){return e!=t.word}),r()})},e.prototype.buildOption=async function(){var t={},e=(t.supportTextBundle=this.supportTextBundle,t.enableInlineMath=this.get("enable_inline_math")||!1,t.enableHighlight=this.get("enable_highlight")||!1,t.enableSubscript=this.get("enable_subscript")||!1,t.enableSuperscript=this.get("enable_superscript")||!1,t.enableDiagram=0!=this.get("enable_diagram"),t.copyMarkdownByDefault=this.get("copy_markdown_by_default")||!1,t.showLineNumbersForFence=this.get("show_line_numbers_for_fence")||!1,t.noPairingMatch=this.get("no_pairing_match")||!1,t.autoPairExtendSymbol=this.get("match_pari_markdown")||!1,t.expandSimpleBlock=this.get("auto_expand_block")||!1,t.headingStyle=this.get("heading_style")||0,t.ulStyle=this.get("ul_style")||0,t.olStyle=this.get("ol_style")||0,t.scrollWithCursor=!this.get("no_mid_caret"),t.autoNumberingForMath=this.get("auto_numbering_for_math"),t.allowPhysicsConflict=this.get("allowPhysicsConflict"),t.noDisplayLinesInMath=this.get("noDisplayLinesInMath"),t.useRelativePathForImg=this.get("use_relative_path_for_img")||!1,t.relativePathWithDot=this.get("relativePathWithDot")||!1,t.allowImageUpload=this.get("allow_image_upload")||!1,t.defaultImageStorage=this.get("image_save_location")||null,"custom"==t.defaultImageStorage&&(t.defaultImageStorage=this.get("custom_image_save_location")),t.applyImageMoveForWeb=this.get("apply_image_move_for_web")||!1,t.applyImageMoveForLocal=!this.get("no_image_move_for_local"),t.preferCRLF=this.get("line_ending_crlf")||!1,t.sidebarTab=this.get("sidebar_tab")||"",t.useTreeStyle=this.get("useTreeStyle")||!1,t.strictMarkdown=this.get("strict_mode")||!1,t.noLineWrapping=this.get("no_line_wrapping")||!1,t.prettyIndent=this.get("prettyIndent")||!1,t.convertSmartOnRender=this.get("SmartyPantsOnRendering"),t.smartDash=this.get("smartDash"),t.smartQuote=this.get("smartQuote"),t.twoHyphensToEm=this.get("twoHyphensToEm")||!1,t.remapUnicodePunctuation=this.get("remapPunctuation"),t.indentSize=this.get("indentSize")||2,t.codeIndentSize=this.get("codeIndentSize")||4,t.enableAutoSave=this.get("enableAutoSave")||!1,t.saveFileOnSwitch=this.get("save_file_on_switch")||!1,t.presetSpellCheck=this.get("preset_spell_check")||"auto",t.autoCorrectMisspell=!1,this.config||{});t.monocolorEmoji=e.monocolorEmoji,t.userQuotesArray=this.get("userQuotesArray"),t.passiveEvents=!0,t.canCollapseOutlinePanel=this.get("can_collapse_outline_panel"),t.preLinebreakOnExport=this.get("preLinebreakOnExport"),t.preLinebreakOnExport=1==t.preLinebreakOnExport||"true"==t.preLinebreakOnExport,t.indentFirstLine=this.get("indentFirstLine"),t.hideBrAndLineBreak=this.get("hideBrAndLineBreak"),t.isFocusMode=this.get("isFocusMode"),t.isTypeWriterMode=this.get("isTypeWriterMode"),t.ignoreLineBreak=this.get("ignoreLineBreak")||!1,t.sendAnonymousUsage=this.get("send_usage_info"),t.useMirrorInCN=this.get("useMirrorInCN"),void 0!==t.sendAnonymousUsage&&null!==t.sendAnonymousUsage||(t.sendAnonymousUsage=!0),t.uuid=this.get("uuid"),t.appVersion=x.getVersion(),t.instance=C,t.devVersion=global.devVersion,t.hasLicense=E.getHasLicense(),t.userLocale=this.getUserLocale(),t.appLocale=x.getLocale(),t.sidebarWidth=this.get("sidebar-width"),t.caseSensitive=this.get("caseSensitive"),t.wholeWord=this.get("wholeWord"),t.useRegexp=this.get("useRegexp"),t.fileSearchCaseSensitive=this.get("fileSearchCaseSensitive"),t.fileSearchWholeWord=this.get("fileSearchWholeWord"),t.fileSearchUseRegexp=this.get("fileSearchUseRegexp"),t.wordCountDelimiter=this.get("wordCountDelimiter")||0;try{t.userPath=x.getPath("home")||""}catch(e){t.userPath=(D?process.env.USERPROFILE:"")||""}if(t.mainPath=global.addonPath||"",t.userDataPath=x.getPath("userData")||"",!this.tempPath){var n=x.getPath("temp");0{t.keys[e]=(m.getKeyAccelerator(e)||"").toLowerCase()}),t.mathFormatOnCopy=this.get("mathFormatOnCopy")||"svg",t.imageUploader=this.get("image_uploader"),t.customImageUploader=this.get("custom_image_uploader"),t.picgoAppPath=this.get("picgo_app_path"),t.noWarnigUploadDisabled=this.get("noWarnigUploadDisabled")||!1,t.noWarnigForMoveFile=this.get("noWarnigForMoveFile")||!1,t.noWarnigForMoveFileToList=this.get("noWarnigForMoveFileToList")||!1,t.noWarnigForDeleteFile=this.get("noWarnigForDeleteFile")||!1,t.noWarnigForTypeWriterMode=this.get("noWarnigForTypeWriterMode")||!1,t.noHintForOpenLink=this.get("noHintForOpenLink")||!1,t.noHintForUnibody=this.get("noHintForUnibody")||!1,t.noWarnigForFocusMode=this.get("noWarnigForFocusMode")||!1,t.noWarningForExportOverwrite=this.get("noWarningForExportOverwrite")||!1,t.noWarningForUpdateImageReference=this.get("noWarningForUpdateImageReference")||!1,t.hasUpdates=this.hasUpdates||!1,t.pandocPath=this.get("pandocPath")||"",t.buildTime=1676345080018,t.debug=this.get("debug"),t._lastExport=A,t.lineWiseCopyCut=this.get("lineWiseCopyCut")||!1,t},e.prototype.extraOption=async function(){var t=await this.buildOption();return t.restoreWhenLaunch=this.get("restoreWhenLaunch")||0,t.pinFolder=this.get("pinFolder"),t.enable_inline_math=t.enableInlineMath,t.enable_highlight=t.enableHighlight,t.enable_subscript=t.enableSubscript,t.enable_superscript=t.enableSuperscript,t.enableDiagram=0!=this.get("enable_diagram"),t.enable_diagram=t.enableDiagram,t.copy_markdown_by_default=!!this.get("copy_markdown_by_default"),t.show_line_numbers_for_fence=!!this.get("show_line_numbers_for_fence"),t.no_pairing_match=!!this.get("no_pairing_match"),t.match_pari_markdown=!!this.get("match_pari_markdown"),t.auto_expand_block=!!this.get("auto_expand_block"),t.heading_style=this.get("heading_style")||0,t.ul_style=this.get("ul_style")||0,t.ol_style=this.get("ol_style")||0,t.no_mid_caret=this.get("no_mid_caret"),t.auto_numbering_for_math=this.get("auto_numbering_for_math"),t.use_relative_path_for_img=this.get("use_relative_path_for_img"),t.relativePathWithDot=this.get("relativePathWithDot"),t.allow_image_upload=this.get("allow_image_upload"),t.image_save_location=this.get("image_save_location"),t.custom_image_save_location=this.get("custom_image_save_location"),t.apply_image_move_for_web=this.get("apply_image_move_for_web"),t.no_image_move_for_local=this.get("no_image_move_for_local"),t.line_ending_crlf=this.get("line_ending_crlf"),t.strict_mode=this.get("strict_mode"),t.no_line_wrapping=this.get("no_line_wrapping"),t.prettyIndent=this.get("prettyIndent"),t.SmartyPantsOnRendering=this.get("SmartyPantsOnRendering"),t.remapPunctuation=this.get("remapPunctuation"),t.save_file_on_switch=this.get("save_file_on_switch")||!1,t.preset_spell_check=this.get("preset_spell_check")||"auto",t.can_collapse_outline_panel=this.get("can_collapse_outline_panel"),t.send_usage_info=!1!==this.get("send_usage_info"),t.currentThemeFolder=x.getPath("userData")+(D?"\\":"/")+"themes",t.enableAutoUpdate=!1!==this.get("enableAutoUpdate"),t.autoUpdateToDev=this.get("autoUpdateToDev"),t.userLanguage=this.get("userLanguage"),t.image_uploader=this.get("image_uploader"),t.custom_image_uploader=this.get("custom_image_uploader"),t.picgo_app_path=this.get("picgo_app_path"),t.allThemes=this.allThemes,t.useSeparateDarkTheme=this.get("useSeparateDarkTheme")||!1,t.theme=this.get("theme")||"github.css",t.darkTheme=this.get("darkTheme")||"night.css",t.customExport=this.get("customExport"),["general","pdf","html","html-plain","image"].forEach(e=>{t["export."+e]=this.get("export."+e)}),(t.customExport||R).forEach(e=>{t["export."+e.key]=this.get("export."+e.key)}),t},n.handle("setting.getExtraOption",async e=>JSON.stringify(await x.setting.extraOption())),n.handle("setting.doDownloadPicgo",e=>{x.setting.doDownloadPicgo()}),n.handle("setting.getKeyBinding",e=>x.setting.config.keyBinding||{}),e.prototype.doDownloadPicgo=function(){w.initDict().then(function(){var e="https://github.com/typora/PicGo-cli/releases/download/latest/%@.zip".replace("%@",D?"x64"==process.arch?"win64":"win32":"linux");console.log(e);let n=F(541).normalize(x.getPath("userData")+"/picgo"),o=F(541).normalize(n+"/_picgo.zip");var i=new f(e,o,{title:w.getPanelString("Download"),text:w.getPanelString("Downloading…"),processOnComplete:.9});i.onSuccess=(e,t)=>{F(834)(o,{dir:n},function(e){t.value=1,t.text=w.getPanelString("Finished"),t.detail="",setTimeout(()=>{i.setCompleted()},2e3),T.unlink(o,()=>{})}),t.detail=w.getPanelString("Unzipping…")},i.onError=e=>{S.dialog.showErrorBox(w.getPanelString("Download"),e.message)},i.download()})};var V=null;e.prototype.useDarkTheme=function(){return V=S.nativeTheme.shouldUseDarkColors&&this.get("useSeparateDarkTheme")},e.prototype.useDarkThemeBefore=function(){return V},e.prototype.curTheme=function(){return this.useDarkTheme()?this.get("darkTheme")||"night.css":this.get("theme")||"github.css"},e.prototype.setCurTheme=function(e,t){return a.getApplicationMenu().getItem("Themes").submenu.items.map(function(e){e.checked=e.label==t}),this.useDarkTheme()?this.put("darkTheme",e):this.put("theme",e)},o.exports=e},587:(o,e,t)=>{var u,p=t(134),h=p.app,n=p.ipcMain,g=p.BrowserWindow,m=(t(445),t(468)),f=(process.platform,"linux"==process.platform),w=t(541).join(__dirname,"../");n.handle("window.setTitle",(e,t,n)=>{e=g.fromWebContents(e.sender);t=t||("Typora"===(t=e.getTitle())?"Untitled"+(n?"• - Typora":" - Typora"):t.replace(/•? - Typora$/,n?"• - Typora":" - Typora")),e.setTitle(t)}),n.handle("window.focus",e=>{e=g.fromWebContents(e.sender);return e.focus(),e.webContents.focus(),!0}),n.handle("window.setInSourceMode",(e,t)=>{g.fromWebContents(e.sender).inSourceMode=!!t}),n.handle("window.minimize",e=>{g.fromWebContents(e.sender).minimize()}),n.handle("window.close",e=>{g.fromWebContents(e.sender).close()}),n.handle("window.restore",e=>{e=g.fromWebContents(e.sender);e.unmaximize(),e.setFullScreen(!1)}),n.handle("window.maximize",e=>{g.fromWebContents(e.sender).maximize()}),n.handle("window.fullscreen",e=>{e=g.fromWebContents(e.sender);return e.setFullScreen(!0),e.isFullScreen()}),n.handle("window.setMenuBarVisibility",(e,t)=>{g.fromWebContents(e.sender).setMenuBarVisibility(t)}),n.handle("window.pin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!0)}),n.handle("window.unpin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!1)}),n.handle("window.updateMenuForIsAlwaysOnTop",e=>{e={"View→Always on Top":{state:g.fromWebContents(e.sender).isAlwaysOnTop()}};h.updateMenu(e)}),n.handle("window.toggleDevTools",e=>{e=g.fromWebContents(e.sender);e.webContents.isDevToolsOpened()?e.webContents.closeDevTools():e.webContents.openDevTools()}),n.handle("window.inspectElement",(e,t,n)=>{g.fromWebContents(e.sender).inspectElement(t,n)}),n.handle("window.checkAsFocus",e=>{e=g.fromWebContents(e.sender);e&&e.isFocused&&(h.currentFocusWindowId=e.id)}),n.handle("controller.switchFolder",(e,t)=>{e=g.fromWebContents(e.sender);h.switchFolder(t,e)}),n.handle("webContents.copy",e=>{g.fromWebContents(e.sender).webContents.copy()}),n.handle("webContents.cut",e=>{g.fromWebContents(e.sender).webContents.cut()}),n.handle("webContents.paste",e=>{g.fromWebContents(e.sender).webContents.paste()}),n.handle("webContents.selectAll",e=>{g.fromWebContents(e.sender).webContents.selectAll()}),n.handle("webContents.undo",(e,t)=>{g.fromWebContents(e.sender).webContents.undo()}),n.handle("webContents.redo",(e,t)=>{g.fromWebContents(e.sender).webContents.redo()}),n.handle("webContents.clearCache",(e,t)=>{var n=g.fromWebContents(e.sender);return new Promise(e=>{n.webContents.session.clearCache(e)})}),n.handle("webContents.action",(e,t)=>{g.fromWebContents(e.sender).webContents[t]()}),e.makeWindow=async(d,e)=>{var t=h.getDocumentController();e=e||{};var n,o,i=g.getFocusedWindow(),r=h.setting.config||{},a=t.lastClosedBounds,l=(i=i&&!t.getDocumentFromWindowId(i.id)?null:i)&&i.getBounds(),s=0,l=(a||(l?(s=i.isMaximized()||i.isFullScreen()?0:30,a={fullscreen:i.isFullScreen(),maximized:i.isMaximized()},s&&(a.x=l.x+s,a.y=l.y+s,a.width=l.width,a.height=l.height)):a=u?(s=u.fullscreen||u.maximize?0:30,{x:u.x+s,y:u.y-s,width:u.width,height:u.height,fullscreen:u.fullscreen,maximized:u.maximized}):{}),!a.fullscreen&&a.maximized),e={x:a.x,y:a.y,width:a.width||800,height:a.height||700,minWidth:400,minHeight:400,frame:!h.setting.get("framelessWindow"),disableAutoHideCursor:!1,backgroundColor:h.setting.get("backgroundColor"),webPreferences:{webSecurity:!1,allowRunningInsecureContent:!1,plugins:!1,nodeIntegration:!0,enableRemoteModule:!1,webviewTag:!0,nodeIntegrationInWorker:!0,devTools:!0,images:!0,directWrite:r.directWrite,defaultFontFamily:r.defaultFontFamily,allowDisplayingInsecureContent:!1,backgroundThrottling:!1,spellcheck:!1,contextIsolation:!1,additionalArguments:["--tyopt="+JSON.stringify({isMaximized:l,isFullScreen:a.fullscreen,...await h.setting.buildOption(),...e})]},autoHideMenuBar:a.fullscreen||r.autoHideMenuBar,show:d,fullscreen:a.fullscreen,alwaysOnTop:i&&i.isAlwaysOnTop(),fullscreenable:!0},c=(f&&(e.icon=w+"/assets/icon/icon_256x256.png"),r=e,i=0s.y+s.height&&(r.y=s.y+s.height-r.height),r.xs.x+s.width&&(r.x=i?s.x:s.x+s.width-r.width)),u=e,l&&(e.show=!1),new g(e));return t.lastClosedBounds=null,l&&(c.maximize(),d&&c.show()),a.fullscreen&&(c.autoHideMenuBar=!0,c.setMenuBarVisibility(!1)),c.loadURL(entry||"".substring(1)),n=c,o=p.shell,n.webContents.on("will-navigate",function(e,t){e.preventDefault(),o.openExternal(t)}),n.webContents.setWindowOpenHandler(e=>(/^https?:/.exec(e.url)&&o.openExternal(e.url),{action:"deny"})),n.webContents.on("crashed",function(e,t){console.error("render process is killed? "+t),m.captureMessage("render process crashed, killed="+t),h.setting.addAnalyticsEvent("crashed")}),n.webContents.on("unresponsive",function(){m.captureMessage("unresponsive",{extra:{winId:n.id}}),h.setting.addAnalyticsEvent("unresponsive")}),n.webContents.setMaxListeners(15),n.webContents.on("dom-ready",function(){n.isMaximized()&&n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");'),b("dom-ready",n)}),n.on("maximize",()=>{n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");')}),n.on("enter-full-screen",function(){n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");document.body.classList.add("typora-fullscreen");if(document.body.classList.contains("native-window")) {$("#ty-top-placeholder").show();};1;')}),n.on("unmaximize",function(){n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");')}),n.on("session-end",function(){console.log("[win] session-end"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),n.on("leave-full-screen",function(){n.autoHideMenuBar=!!h.setting.config.autoHideMenuBar,n.setMenuBarVisibility(!h.setting.config.autoHideMenuBar),n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");document.body.classList.remove("typora-fullscreen");$("#ty-top-placeholder").hide();1;'),u&&(u.fullscreen=!1)}),n.on("focus",function(){n.webContents.incrementCapturerCount();var e=t.getDocumentFromWindowId(n.id);e&&(e.setActiveWindow(n),h.focusedWindow=n)}),n.on("blur",()=>{console.log("[win] blur"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),b("make-window"),c};const i=t(93);var r=new i;const b=function(e,t){r.emit(e,t)};e.on=function(e,t){r.on(e,t)},e.showPanelWindow=function({path:e,...t}){var n=new g({modal:!0,show:!1,center:!0,resizable:!1,webPreferences:{devTools:!global.releaseMode,defaultFontSize:14,nodeIntegration:!0,contextIsolation:!1,enableRemoteModule:!1},...t});return n.loadURL("file://"+w+"/"+e),n.once("ready-to-show",function(){n.show()}),n.removeMenu(),f&&(n.icon=w+"/assets/icon/icon_256x256.png"),n.webContents.setWindowOpenHandler(e=>(p.shell.openExternal(e.url),{action:"deny"})),n}},90:(e,o,s)=>{e=s.nmd(e);var t,i=s(541),n=s(640),r=(t=i.join(__dirname,"../"),i.join(t,"node_modules.asar")),a=(n.globalPaths.push(r),n.prototype.require);n.prototype.require=function(e){return-1==this.paths.indexOf(__dirname)&&(this.paths.push(__dirname),this.paths.push(r)),/(\.node$)|(\/build\/Release)/.exec(e)&&"."==e[0]&&(e=i.resolve(i.dirname(this.id),e).replace(/\bnode_modules\.asar\b/,"node_modules")),a.call(this,e)};for(let e=0;e{c.exit()},1e3),s(405);var n=s(134),c=n.app,l=n.protocol,m=n.powerMonitor,d=n.BrowserWindow,u=s(728),f="win32"==process.platform,w=(process.platform,process.platform,s(557),s(344)),b=s(883),e=s(932),y=s(445),p=s(351),n=n.ipcMain;s(468);if(!c.requestSingleInstanceLock())return console.record("secondary instance would exit"),void c.quit();console.record("launch with argv ["+process.argv.join(", ")+"]"),c.on("second-instance",function(e,t,n){console.record("got argv ["+t.join(", ")+"] from secondary instance"),t=Array.from(t),d.getAllWindows().length&&((n=F(t,n))?c.openFileOrFolder(n,{forceCreateWindow:!n}):T(t||[]))});var v=1,k=2,C=3;function F(e,t){null==t&&(t=process.cwd());for(var n,o=e.length-1;0<=o;o--)if("-"!=e[o][0]&&!/\.asar$/.exec(e[o]||"")){n=e[o];break}if((n=0!=o&&n!=t?n:void 0)&&/^file:\/\//i.exec(n)){n=n.replace(/^file:\/\//i,"");try{n=decodeURI(n)}catch(e){}}return n?s(541).resolve(t,n):void 0}function S(e){if(!e)return e;var t=e.length;return 50((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFile(t||null,n).then(n=>{if(n)return new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e({winId:n.activeWindow.id})}):e({winId:n.activeWindow.id})})}))),n.handle("app.openFileOrFolder",(e,t,n)=>((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFileOrFolder(t||null,n))),n.handle("app.openOrSwitch",async(e,t,n)=>{var o,e=d.fromWebContents(e.sender),i=c.documentController.getDocument(t),r=c.documentController.getDocumentFromWindowId(e.id);if(i)return(o=i.activeWindow||i.windows.keys().next().value)&&o.focus(),!1;if(n)return c.openFileOrFolder(t,{curWindow:!0}),!1;if(await O(t))c.switchFolder(t,e);else if(!i)return r.rename(t),!0;return!1}),n.handle("app.openFolder",(e,t,n)=>{c.openFolder(t||null,n?d.fromWebContents(e.sender):void 0)}),n.handle("app.onCloseWin",(e,t)=>{e=d.fromWebContents(e.sender);c.onCloseWin(e.id,t)}),n.handle("app.sendEvent",(e,t,n)=>{c.sendEvent(t,n)}),n.handle("executeJavaScript",(e,t,n)=>{d.fromId(t).webContents.executeJavaScript(n)}),c.reopenFolder=function(){var t=new Set,n=!1;return g.forEach(function(e){e.mountFolder&&!t.has(e.mountFolder)&&(t.add(e.mountFolder),c.openFile(null,{forceCreateWindow:!0,mountFolder:e.mountFolder}),n=!0)}),n},c.reopenClosed=function(o){var i=!1;return g.length&&g.forEach(function(e,t){var n=c.getDocumentController().getDocument(e.path);n?n.activeWindow&&n.activeWindow.show():(c.openFile(e.path,{forceCreateWindow:!!t,mountFolder:e.mountFolder,silent:o,backupState:e,fromReopen:!0}),i=!0)}),i},function(e){var t,n=c.setting.get("restoreWhenLaunch")||0,o=!0,i=e||process.argv||[];-1{/^--/.exec(e)&&("--on-dev"==e?process.traceDeprecation=!0:-1===["--new","--reopen-file"].indexOf(e)&&c.commandLine.appendSwitch.apply(null,[e]))}),scheme||"".substring(3));c.on("ready",async function(){var e,t;await c.setting.initSetting(),c.expired||(p.lastClosedBounds=c.setting.get("lastClosedBounds"),console.record("------------------start------------------"),console.log("typora version: "+c.getVersion()),console.log(""+s.c[s.s].filename),M(P),c.setAppUserModelId("abnerworks.Typora"),(e=F(process.argv))&&"--on-dev"!==process.argv[process.argv.length-1]?c.openFileOrFolder(e):c.recoverFromBackup(),w.loadDict().then(()=>{w.bindMainMenu()}),f&&(t=s(558),c.updater=t,setTimeout(function(){t.initUpdater().then(function(){!1!==c.setting.get("enableAutoUpdate")&&c.updater.checkForUpdates(!1)})},3e3)),b.bindJumplist(),setTimeout(function(){try{E()}catch(e){console.warn(e.stack)}},3e4),m.on("suspend",()=>{console.record("[Power] suspend"),c.execInAll('window.onPowerChange && window.onPowerChange("suspend")')}),m.on("resume",()=>{console.record("[Power] resume"),c.execInAll('window.onPowerChange && window.onPowerChange("resume")')}),m.on("lock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("lock-screen")')}),m.on("unlock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("unlock-screen")')}))});var I,W={},E=async function(){var r,a,l,s,n=await c.setting.getUnsavedDraftPath(),e=await u.readdir(n);e.length<200||(console.record("cleanUpExpiredDrafts"),400{var o=[],i=async function(){Math.min(l+50,a.length);if(l+1>=a.length)n(o);else{for(;l++;){if(!a[l])return void n(o);try{var e=r+"/"+a[l],t=await u.stat(e);864e6{try{return{name:e,time:W[e]||(await u.stat(n+"/"+e)).mtime.getTime()}}catch(e){}return{name:e,time:0}})),W=null,e.sort(function(e,t){return t.time-e.time}).forEach(function(e,t){150{D=!1}),c.on("quit",function(){console.log("-----------------quit------------------"),c.setting.closeLogging()}),c.on("will-quit",function(){console.log("------------------will-quit------------------"),h&&clearTimeout(h),I&&clearTimeout(I),f&&c.updater&&c.updater.installIfNeeded(),c.setting.syncAll();try{u.rmSync(c.getPath("userData")+"/runtime-storage",{recursive:!0,force:!0})}catch(e){console.error(e)}try{var e=c.getPath("userData")+"/typora.log",t=c.getPath("userData")+"/typora-old.log",n=u.statSync(e);n&&5e5p.getDocumentFromWindowId(n.id)):l()}).then(function(e){return e})}return l()},c.sendEvent=function(t,n){d.getAllWindows().forEach(function(e){e.webContents.send(t,n)}),c.onMessage(t,n)},c.execInAll=function(t){d.getAllWindows().forEach(function(e){e.webContents.executeJavaScript(t)})},c.onMessage=function(e,t){"didRename"==e?c.setting.renameRecentDocuments(t.oldPath,t.newPath):"updateQuickOpenCache"==e&&t.toDel&&c.setting.renameRecentDocuments(t.toDel,null)},c.refreshMenu=function(){w.refreshMenu()},{});n.handle("app.download",(e,t,n,o)=>{var i,r,a=s(541),l=d.fromWebContents(e.sender),e=s(554),o=o||(e=>{var t=s(426),n=s(541),t=t.parse(e),e=n.basename(t.pathname);try{var o=decodeURIComponent(e);if(o!=e)return n.basename(o)}catch(e){}return e})(t),a=a.join(n,o);return u.existsSync(a)&&(i=a,r=s(541),a=i.replace(/(\.[^.\/\\]+?$)/,"")+"-"+ +new Date+r.extname(i)),_[l.id+t]||(_[l.id+t]=e.download(l,t,{showBadge:!1,directory:n,filename:o})),setTimeout(()=>{delete _[l.id+t]},10),Promise.race([_[l.id+t].then(e=>({path:e.getSavePath(),state:e.getState(),type:e.getMimeType()}),()=>({path:t,state:"error"})),new Promise(e=>{setTimeout(()=>{e({path:t,state:"timeout"})},3e4)})])});var M=function(e){l.registerFileProtocol(e,function(e,t){e.url?t({path:c.getRealPath(e.url)}):t({error:-324})}),l.registerBufferProtocol("typora-bg",function(e,t){var n=c.setting.get("backgroundColor");t(n?{mimeType:"text/css",data:Buffer.from(`body {background:${n};`)}:{mimeType:"text/css",data:Buffer.from("")})})};c.getRealPath=function(e){try{e=decodeURI(e)}catch(e){}e=e.substr(13);return/^userData/.exec(e)&&(e=e.replace(/^userData/,c.getPath("userData").replace(/\\/g,"\\\\"))),/current-theme\.css$/.exec(e)&&(e=e.replace(/current-theme\.css$/,c.setting.curTheme())),/^typemark/i.exec(e)&&(e=e.replace(/^typemark/,t)),e=(e=/preview\.html/.exec(e)?e.replace(/\.html[?#].*$/,".html"):e).replace(/[?#][^\\\/]*$/,"")},c.filesOp=e,P&&l.registerSchemesAsPrivileged([{scheme:P,privileges:{standard:!0,secure:!0,supportFetchAPI:!0,bypassCSP:!0,corsEnabled:!0,stream:!0}}])},344:(t,n,h)=>{function r(e,t){return function(){k(e,t)}}var i,a=h(134),l=a.app,g=a.dialog,s=a.Menu,c=a.MenuItem,m=a.BrowserWindow,e=a.ipcMain,f=h(728),d="win32"==process.platform,w="darwin"==process.platform,b="linux"==process.platform,y=h(445),u=h(541).join(__dirname,"../"),v=(e.on("execForAll",function(e,t){v(t)}),e.on("forceRefreshMenu",function(e,t){l.forceRefreshMenu()}),e.on("syncToPreference",function(e,t){a.webContents.getAllWebContents().forEach(function(e){e.send("syncToPreference",t)})}),n.loadDict=()=>{var o,e;return i?Promise.resolve(i):(o=l.setting.getUserLocale(),e=h(541).join(u,l.setting.getLocaleFolder("Menu")),new Promise(n=>{f.readFile(e,"utf8",(e,t)=>{i=t?JSON.parse(t):{},n(i),e&&console.warn("cannot load dict as ["+o+"] "+e.stack)})}))},function(e){var t=e=e.toString();/^\s*function\s*\(/.exec(e)&&(t="window.File && ("+e+")();"),l.execInAll(t),console.log(t)}),k=function(e,t){var n=m.getFocusedWindow();n&&(t?n.webContents.executeJavaScript("window.File && !File.blockUI && ("+e.toString()+")();0;"):n.webContents.executeJavaScript("!File.blockUI && window.ClientCommand['"+e+"']();0;"),n.webContents.executeJavaScript("window.Reporter && window.Reporter.fullValidate();File.editor && File.editor.contextMenu && File.editor.contextMenu.hide();0;"))};function C(e){var t=/&[a-z]/i.exec(e),n=/(\.\.\.)|(…)/.exec(e),o=(e=e.replace(/(\.\.\.)|(…)|&/g,""),(i||{})[e]||e);return t?function(e,t){e=S[e];if(!e)return t;{var n,o;(d||b)&&(-1==(n=t.indexOf(e))?n=t.indexOf(e.toLowerCase()):-1<(o=t.indexOf(e.toLowerCase()))&&(n=Math.min(n,o)),-1{setTimeout(o,0)}))),e}function x(e,t){return p(e={label:e,accelerator:t}),e.accelerator}function D(e){function n(e,t){e=e.label;f.existsSync(e)?l.openFileOrFolder(e,{curWindow:t}):(g.showMessageBox({title:C("Open Failed"),message:C("File or folder does not exist."),buttons:["Close"],cancelId:0,defaultId:0}),l.setting.removeRecentDocument(e))}try{var o=e.getItem("File").submenu.getItem("Open Recent").submenu,t=l.setting.getRecentDocuments(),i=l.setting.getRecentFolders();t.sort(function(e,t){return t.date-e.date}),i.sort(function(e,t){return t.date-e.date}),o.clear(),o.append(new c({label:C("Reopen Closed File"),accelerator:"CmdOrCtrl+Shift+T",click:function(){l.reopenClosed()}})),o.append(new c({type:"separator"})),t.length&&(t.forEach(function(e,t){10{e.type&&(hasCustom=!0,o.push({label:e.name,click:t(e)}))}),o.push({type:"separator"}),o.push({label:"Export with Previous",accelerator:"Shift+Ctrl+E",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast();")},enabled:!!l.setting.lastExport}),o.push({label:"Export and Overwrite with Previous",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast(true)")},enabled:!!l.setting.lastExport}),o.push({type:"separator"}),o.push({label:"Export Setting…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('export-setting-group');")},enabled:!0}),e&&(o.forEach(p),n=P("File→Export").submenu,o[o.length-1].enabled=(I("Export and Overwrite with Previous",n)||{}).enabled,n.clear(),o.forEach(e=>{n.append(new c(e))}),w&&s.setApplicationMenu(s.getApplicationMenu())),o}function P(e){if(!e)return null;var t,n=(W=W||{})[e];return n||(e.split("→").forEach(function(e){if(n=I(e,n),!(W[t=t?t+"→"+e:e]=n))return null}),W=null,n)}function I(e,t){var n,o=t?t.submenu:s.getApplicationMenu();return o?(n=o.getItem(e),t||n||"File"!=e?n:o.getItem("Typora")||o.getItem("Electron")):null}var W,o=null;l.forceRefreshMenu=function(){b&&(o&&clearTimeout(o),o=setTimeout(function(){s.setApplicationMenu(s.getApplicationMenu()),o=null},100))};l.updateMenu=function(e){W={};for(var t in e){var n,o,i=P(t),r=e[t];i&&(n=null,void 0!==r.accelerator&&(r.accelerator,o=x(i.label,r.accelerator),i=n=o!=i.accelerator?new c(p({label:i.label,type:i.type,enabled:i.enabled,checked:i.enabled,click:i.click,accelerator:o})):n),"Paragraph→Table"!=t?(void 0!==r.state&&(i.checked=r.state),void 0!==r.enabled&&(i.enabled=r.enabled,"Paragraph"!=t&&"Format"!=t&&"Format→Image→Zoom Image"!=t||i.submenu.items.forEach(function(e){e.enabled=r.enabled})),void 0!==r.hidden&&(i.visible=!r.hidden),!n||-1<(t=(o=P(t.replace(/→[^→]+$/,"")).submenu.items).findIndex(e=>e.label==n.label))&&(o.splice(t,1,n),console.log("newItem.accelerator "+n.accelerator))):(function(e,n){n.enabled||n.state?(e.enabled=!0,e.submenu.items.forEach(function(e,t){e.enabled=0==t?!n.state:n.state})):e.enabled=!1}(i,r),0))}W=null,l.forceRefreshMenu()},e.on("menu.updateMenu",function(e,t){l.updateMenu(JSON.parse(t))}),e.handle("menu.updateCustomZoom",e=>{l.updateMenu({"View→Actual Size":{state:!l.setting.get("customZoom")}})}),e.handle("menu.refreshThemeMenu",function(e){l.setting.refreshThemeMenu()}),e.handle("menu.reloadExportMenu",function(e){T(!0)}),e.handle("menu.popup",function(e,t){s.getApplicationMenu().popup(t)}),n.bindMainMenu=function(){function e(e,t){e=(/\((.+)\)/.exec(e.label)||[])[1]||e.label;e==C("Auto")&&(e=""),k("function(){File.reloadWithEncoding('"+e+"')}",!0)}var t=l.setting.get("SmartyPantsOnRendering")||!1,n=l.setting.get("smartQuote")||!1,o=l.setting.get("smartDash")||!1,t=[p({label:"&File",submenu:[{label:"New",accelerator:"CmdOrCtrl+N",click:r("newFile")},{label:"New Window",accelerator:"CmdOrCtrl+Shift+N",click:r("newWindow")},{type:"separator"},{label:"Open…",accelerator:"CmdOrCtrl+O",click:r("open")},{label:"Open Folder…",click:r("openFolder")},{type:"separator"},{label:"Open Quickly…",accelerator:"CmdOrCtrl+P",click:r("quickOpen")},{label:"Open Recent",submenu:[]},{label:"Reopen with Encoding",submenu:[{label:"Auto",click:e},{type:"separator"},{label:"UTF-8",click:e},{label:"UTF-16 LE",click:e},{label:"UTF-16 BE",click:e},{type:"separator"},{label:"Western (windows-1252)",click:e},{label:"Cyrillic (windows-1251)",click:e},{label:"Cyrillic (ISO-8859-2)",click:e},{label:"Cyrillic (IBM866)",click:e},{label:"Cyrillic (IBM855)",click:e},{label:"Cyrillic (KOI8-R)",click:e},{label:"Cyrillic (MacCyrillic)",click:e},{label:"Central European (windows-1250)",click:e},{label:"Central European (ISO-8859-2)",click:e},{label:"Geek (windows-1253)",click:e},{label:"Geek (ISO-8859-7)",click:e},{label:"Hebrew (windows-1255)",click:e},{label:"Hebrew (ISO-8859-8)",click:e},{label:"Chinese Simplified (GB2312)",click:e},{label:"Chinese Simplified (GB18030)",click:e},{label:"Chinese Traditional (Big5)",click:e},{label:"Japanese (SHIFT_JIS)",click:e},{label:"Japanese (EUC-JP)",click:e},{label:"Korean (EUC-KR)",click:e},{label:"Thai (TIS-620)",click:e}]},{type:"separator"},{label:"Save",accelerator:"CmdOrCtrl+S",click:r("save")},{label:"Save As…",accelerator:"CmdOrCtrl+Shift+S",click:r("saveAs")},{label:"Move To…",click:r("moveTo")},{label:"Save All…",click:r("saveAll")},{type:"separator"},d?{label:"Properties…",click:function(e,t){t&&t.webContents.executeJavaScript("File.winShell().openProperties(File.bundle.filePath);")}}:null,{label:"Open File Location…",click:r("openFileLocation")},{label:"Reveal in Sidebar",click:r(function(){window.File.editor.library.revealInSidebar()},!0)},{label:"Delete…",click:function(e,t){t&&t.webContents.executeJavaScript("File.trashSelf();")}},{type:"separator"},{label:"Import…",click:r("import")},{label:"Export",submenu:T()},{label:"Print…",accelerator:"Shift+Alt+P",click:r("print")},{type:"separator"},{label:"Preferences…",accelerator:"CmdOrCtrl+,",click:r("togglePreferencePanel")},{type:"separator"},{label:"Close",accelerator:"CmdOrCtrl+W",click:r("close")}]}),p({label:"&Edit",id:"edit",submenu:[{label:"Undo",id:"undo",accelerator:"CmdOrCtrl+Z",click:r("undo")},{label:"Redo",id:"redo",accelerator:"CmdOrCtrl+Y",click:r("redo")},{type:"separator"},{label:"Cut",accelerator:"CmdOrCtrl+X",role:"cut"},{label:"Copy",accelerator:"CmdOrCtrl+C",role:"copy"},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Paste",accelerator:"CmdOrCtrl+V",role:"paste"},{type:"separator"},{label:"Copy as Plain Text",click:r("copyAsPlainText")},{label:"Copy as Markdown",accelerator:"CmdOrCtrl+Shift+C",click:r("copyAsMarkdown")},{label:"Copy as HTML Code",click:r("copyAsHTMLSource")},{label:"Copy without Theme Styling",click:r("copyAsSemanticHTML")},{type:"separator"},{label:"Paste as Plain Text",accelerator:"CmdOrCtrl+Shift+v",click:r("pasteAsPlain")},{type:"separator"},{label:"Selection",submenu:[{label:"Select All",accelerator:"CmdOrCtrl+A",click:r("selectAll")},{label:"Select Paragraph / Block",accelerator:"CmdOrCtrl+Alt+P",click:r(function(){File.editor.selection.selectBlock()},!0)},{label:"Select Line / Sentence",accelerator:"CmdOrCtrl+L",click:r(function(){File.editor.selection.selectLine()},!0)},{label:"Select Styled Scope",accelerator:"CmdOrCtrl+E",click:r(function(){File.editor.selection.selectPhrase()},!0)},{label:"Select Word",accelerator:"CmdOrCtrl+D",click:r(function(){File.editor.selection.selectWord()},!0)},{type:"separator"},{label:"Jump to Top",accelerator:"Ctrl+Home",click:r(function(){File.editor.selection.jumpTop()},!0)},{label:"Jump to Selection",accelerator:"CmdOrCtrl+j",click:r(function(){File.editor.selection.jumpSelection()},!0)},{label:"Jump to Bottom",accelerator:"Ctrl+End",click:r(function(){File.editor.selection.jumpBottom()},!0)},{label:"Extend Selection to Top",accelerator:"Ctrl+Shift+Home",visible:!1,click:r(function(){File.editor.selection.jumpTop(!0)},!0)},{label:"Extend Selection to Bottom",accelerator:"Ctrl+Shift+End",visible:!1,click:r(function(){File.editor.selection.jumpBottom(!0)},!0)},{label:"Extend Selection to Line Start",accelerator:"Shift+Home",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!1)},!0)},{label:"Extend Selection to Line End",accelerator:"Shift+End",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!0)},!0)}]},{type:"separator"},{label:"Delete",click:r(function(){File.delete()},!0)},{label:"Delete Range",submenu:[{label:"Delete Paragraph / Block",accelerator:"Shift+CmdOrCtrl+Alt+P",click:r("deleteBlock")},{label:"Delete Line / Sentence",accelerator:"Shift+CmdOrCtrl+Alt+L",click:r("deleteLine")},{label:"Delete Styled Scope",accelerator:"Shift+CmdOrCtrl+Alt+E",click:r("deleteScope")},{label:"Delete Word",accelerator:"Shift+Ctrl+D",click:r("deleteWord")}]},{type:"separator"},{label:"Math Tools",submenu:[{label:"Refresh All Math Expressions",click:r(function(){File.editor.mathBlock.forceRefresh()},!0)}]},{type:"separator"},{label:"Smart Punctuation",submenu:[{label:"Convert on Input",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+!e+")"))},checked:!t},{label:"Convert on Rendering",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+e+")"))},checked:t},{type:"separator"},{label:"Smart Quotes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartQuote("+e+")"))},checked:n},{label:"Smart Dashes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartDash("+e+")"))},checked:o},{type:"separator"},{label:"Remap Unicode Punctuation on Parse",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setRemapPunctuation("+e+")"))},checked:l.setting.get("remapPunctuation")||!t&&(n||o),enabled:!(!t&&(n||o))},{type:"separator"},{label:"More Options…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('smart-punctuation-group');")}}]},{label:"Line Endings",submenu:[{label:"Windows Line Endings (CRLF)",type:"checkbox",click:r(function(){File.setLineEnding(!0,!0)},!0)},{label:"Unix Line Endings (LF)",type:"checkbox",click:r(function(){File.setLineEnding(!1,!0)},!0)},{type:"separator"},{label:"Insert Final New Line On Save",type:"checkbox",click:function(e,t){t&&t.webContents.executeJavaScript("File.setFinalNewline("+e.checked+")")}}]},{label:"Whitespace and Line Breaks",submenu:[{label:"Indent first line of paragraphs",type:"checkbox",click:r(function(){File.setIndentFirstLine(!File.option.indentFirstLine,!0,!0)},!0)},{type:"separator"},{label:"Visible
",type:"checkbox",checked:!0,click:r(function(){File.setHideBrAndLineBreak(!File.option.hideBrAndLineBreak,!0,!0)},!0)},{label:"Preserve single line break",type:"checkbox",checked:!0,click:r(function(){File.setIgnoreLineBreak(!File.option.ignoreLineBreak,!0,!0)},!0)},{type:"separator"},{label:"Learn More…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/Line-Break/`)}}]},{label:"Spell Check…",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.spellChecker && File.editor.spellChecker.show();")}},{type:"separator"},{label:"Find and Replace",submenu:[{label:"Find…",accelerator:"CmdOrCtrl+f",click:r(function(){File.megaMenu.isPreferencePanelShown()?File.megaMenu.searchOnPreferencePanel():File.editor.searchPanel.showPanel()},!0)},{label:"Find Next",accelerator:"F3",click:r(function(){File.editor.searchPanel.highlightNext()},!0)},{label:"Find Previous",accelerator:"Shift+F3",click:r(function(){File.editor.searchPanel.highlightNext(!0)},!0)},{type:"separator"},{label:"Replace",accelerator:"Ctrl+h",click:r(function(){File.editor.searchPanel.showPanel(!0)},!0)}]}]}),p({label:"&Paragraph",submenu:[{label:"Heading 1",type:"checkbox",accelerator:"Ctrl+1",click:r(function(){File.editor.stylize.changeBlock("header1",void 0,!0)},!0)},{label:"Heading 2",type:"checkbox",accelerator:"Ctrl+2",click:r(function(){File.editor.stylize.changeBlock("header2",void 0,!0)},!0)},{label:"Heading 3",type:"checkbox",accelerator:"Ctrl+3",click:r(function(){File.editor.stylize.changeBlock("header3",void 0,!0)},!0)},{label:"Heading 4",type:"checkbox",accelerator:"Ctrl+4",click:r(function(){File.editor.stylize.changeBlock("header4",void 0,!0)},!0)},{label:"Heading 5",type:"checkbox",accelerator:"Ctrl+5",click:r(function(){File.editor.stylize.changeBlock("header5",void 0,!0)},!0)},{label:"Heading 6",type:"checkbox",accelerator:"Ctrl+6",click:r(function(){File.editor.stylize.changeBlock("header6",void 0,!0)},!0)},{type:"separator"},{label:"Paragraph",type:"checkbox",accelerator:"Ctrl+0",click:r(function(){File.editor.stylize.changeBlock("paragraph")},!0)},{type:"separator"},{label:"Increase Heading Level",accelerator:"Ctrl+=",click:r(function(){File.editor.stylize.increaseHeaderLevel()},!0)},{label:"Decrease Heading Level",accelerator:"Ctrl+-",click:r(function(){File.editor.stylize.decreaseHeaderLevel()},!0)},{type:"separator"},{label:"Table",submenu:[{label:"Insert Table",accelerator:"Ctrl+T",click:r(function(){File.editor.tableEdit.insertTable()},!0)},{type:"separator"},{label:"Add Row Above",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!0)},!0)},{label:"Add Row Below",accelerator:"Ctrl+Return",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!1)},!0)},{type:"separator"},{label:"Add Column Before",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{label:"Add Column After",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{type:"separator"},{label:"Move Row Up",enabled:!1,accelerator:"Alt+Up",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!0)},!0)},{label:"Move Row Down",enabled:!1,accelerator:"Alt+Down",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!1)},!0)},{label:"Move Column Left",enabled:!1,accelerator:"Alt+Left",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!0)},!0)},{label:"Move Column Right",enabled:!1,accelerator:"Alt+Right",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!1)},!0)},{type:"separator"},{label:"Delete Row",enabled:!1,accelerator:"Shift+Ctrl+Backspace",click:r(function(){File.editor.tableEdit.deleteRow()},!0)},{label:"Delete Column",enabled:!1,click:r(function(){File.editor.tableEdit.deleteCol()},!0)},{type:"separator"},{label:"Copy Table",enabled:!1,click:r(function(){File.editor.tableEdit.copyTable()},!0)},{label:"Prettify Source Code",enabled:!1,click:r(function(){File.editor.tableEdit.reformatTable()},!0)},{type:"separator"},{label:"Delete Table",enabled:!1,click:r(function(){File.editor.tableEdit.deleteTable()},!0)}]},{label:"Code Fences",type:"checkbox",accelerator:"Ctrl+Shift+K",click:r(function(){File.editor.stylize.toggleFences()},!0)},{label:"Math Block",type:"checkbox",accelerator:"Ctrl+Shift+M",click:r(function(){File.editor.stylize.toggleMathBlock()},!0)},{type:"separator"},{label:"Quote",type:"checkbox",accelerator:"Ctrl+Shift+Q",click:r(function(){File.editor.stylize.toggleIndent("blockquote")},!0)},{type:"separator"},{label:"Ordered List",type:"checkbox",accelerator:"Ctrl+Shift+[",click:r(function(){File.editor.stylize.toggleIndent("ol")},!0)},{label:"Unordered List",type:"checkbox",accelerator:"Ctrl+Shift+]",click:r(function(){File.editor.stylize.toggleIndent("ul")},!0)},{label:"Task List",type:"checkbox",accelerator:"Ctrl+Shift+X",click:r(function(){File.editor.stylize.toggleIndent("tasklist")},!0)},{label:"Task Status",submenu:[{label:"Toggle Task Status",click:r(function(){File.editor.stylize.toggleTaskStatus()},!0)},{type:"separator"},{label:"Mark as Complete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!0)},!0)},{label:"Mark as Incomplete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!1)},!0)}]},{label:"List Indentation",submenu:[{label:"Indent",accelerator:"CmdOrCtrl+]",click:r(function(){File.editor.UserOp.moreIndent(File.editor)},!0)},{label:"Outdent",accelerator:"CmdOrCtrl+[",click:r(function(){File.editor.UserOp.lessIndent(File.editor)},!0)}]},{type:"separator"},{label:"Insert Paragraph Before",click:r(function(){File.editor.UserOp.insertParagraph(!0)},!0)},{label:"Insert Paragraph After",click:r(function(){File.editor.UserOp.insertParagraph(!1)},!0)},{type:"separator"},{label:"Link Reference",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_link")},!0)},{label:"Footnotes",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_footnote")},!0)},{type:"separator"},{label:"Horizontal Line",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("hr")},!0)},{label:"Table of Contents",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("toc")},!0)},{label:"YAML Front Matter",type:"checkbox",click:r(function(){File.editor.stylize.insertMetaBlock()},!0)}]}),p({label:"F&ormat",submenu:[{label:"Strong",type:"checkbox",accelerator:"CmdOrCtrl+B",click:r(function(){File.editor.stylize.toggleStyle("strong")},!0)},{label:"Emphasis",type:"checkbox",accelerator:"CmdOrCtrl+I",click:r(function(){File.editor.stylize.toggleStyle("em")},!0)},{label:"Underline",type:"checkbox",accelerator:"CmdOrCtrl+U",click:r(function(){File.editor.stylize.toggleStyle("underline")},!0)},{label:"Code",type:"checkbox",accelerator:"CmdOrCtrl+Shift+`",click:r(function(){File.editor.stylize.toggleStyle("code")},!0)},{type:"separator"},{label:"Inline Math",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("inline_math")},!0)},{label:"Strike",type:"checkbox",accelerator:"Alt+Shift+5",click:r(function(){File.editor.stylize.toggleStyle("del")},!0)},{label:"Highlight",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("highlight")},!0)},{label:"Superscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("superscript")},!0)},{label:"Subscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("subscript")},!0)},{label:"Comment",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("comment")},!0)},{type:"separator"},{label:"Hyperlink",type:"checkbox",accelerator:"Ctrl+K",click:r(function(){File.editor.stylize.toggleStyle("link")},!0)},{label:"Hyperlink Actions",submenu:[{label:"Open Link",click:r(function(){File.editor.openCurrentLink()},!0)},{label:"Copy Link Address",click:r(function(){File.editor.copyCurrentLink()},!0)}]},{label:"Image",submenu:[{label:"Insert Image",accelerator:"CmdOrCtrl+Shift+I",click:r(function(){File.editor.stylize.toggleStyle("image")},!0)},{label:"Insert Local Images…",click:r(function(){File.editor.imgEdit.insertLocalImage()},!0)},{type:"separator"},{label:"Open Image Location…",click:r(function(){File.editor.imgEdit.revealInFinder()},!0)},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Zoom Image",submenu:[{label:"25%",click:r(function(){File.editor.imgEdit.zoomAction(null,"25%")},!0)},{label:"33%",click:r(function(){File.editor.imgEdit.zoomAction(null,"33%")},!0)},{label:"50%",click:r(function(){File.editor.imgEdit.zoomAction(null,"50%")},!0)},{label:"67%",click:r(function(){File.editor.imgEdit.zoomAction(null,"67%")},!0)},{label:"80%",click:r(function(){File.editor.imgEdit.zoomAction(null,"80%")},!0)},{type:"separator"},{label:"100%",click:r(function(){File.editor.imgEdit.zoomAction(null,"100%")},!0)},{type:"separator"},{label:"150%",click:r(function(){File.editor.imgEdit.zoomAction(null,"150%")},!0)},{label:"200%",click:r(function(){File.editor.imgEdit.zoomAction(null,"200%")},!0)}]},{label:"Switch Image Syntax",submenu:[{label:"Markdown Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!1)},!0)},{label:"HTML Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!0)},!0)}]},{type:"separator"},{label:"Delete Image File",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.deleteImageAction(true)")}},{type:"separator"},{label:"Copy Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction()},!0)},{label:"Rename or Move Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction(!0)},!0)},{label:"Upload Image",click:r(function(){File.editor.imgEdit.uploadAction()},!0)},{type:"separator"},{label:"Copy All Images to…",click:r(function(){File.editor.imgEdit.copyAllImages()},!0)},{label:"Move All Images to…",click:r(function(){File.editor.imgEdit.moveAllImages()},!0)},{label:"Upload All Local Images",click:r(function(){File.editor.imgEdit.uploadAllImages()},!0)},{type:"separator"},{label:"Reload All Images",click:r(function(){File.editor.imgEdit.reloadAllByNode()},!0)},{type:"separator"},{label:"When Insert Local Image",submenu:[{label:"Copy Image File to Folder…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleCopyToFolder()},!0)},{label:"Upload Image",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUploadForFile()},!0)}]},{label:"Use Image Root Path…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUseImageRootPath()},!0)},{type:"separator"},{label:"Global Image Settings…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('image-setting-group');")}}]},{type:"separator"},{label:"Clear Format",type:"checkbox",accelerator:"CmdOrCtrl+\\",click:r(function(){File.editor.stylize.clearStyle()},!0)}]}),p({label:"&View",submenu:[{label:"Toggle Sidebar",accelerator:"CmdOrCtrl+Shift+L",click:r(function(){File.editor.library.toggleSidebar()},!0)},{label:"Outline",type:"checkbox",accelerator:"CmdOrCtrl+Shift+1",click:r("toggleOutline")},{label:"Articles",type:"checkbox",accelerator:"CmdOrCtrl+Shift+2",click:r("toggleFileList")},{label:"File Tree",type:"checkbox",accelerator:"CmdOrCtrl+Shift+3",click:r("toggleFileTree")},{label:"Search",type:"checkbox",accelerator:"CmdOrCtrl+Shift+F",click:r("globalSearch")},{type:"separator"},{label:"Source Code Mode",type:"checkbox",accelerator:"CmdOrCtrl+/",click:r(function(){File.toggleSourceMode()},!0)},{type:"separator"},{label:"Focus Mode",type:"checkbox",accelerator:"F8",click:r(function(){File.editor.toggleFocusMode()},!0),enabled:!1},{label:"Typewriter Mode",type:"checkbox",accelerator:"F9",click:r(function(){File.editor.toggleTypeWriterMode()},!0),enabled:!1},{type:"separator"},{label:"Show Status Bar",type:"checkbox",click:r("toggleStatusBar")},{type:"separator"},{label:"Toggle Fullscreen",accelerator:"F11",click:function(e,t){t&&(t.isFullScreen()?t.setFullScreen(!1):t.setFullScreen(!0))}},{label:"Always on Top",type:"checkbox",click:function(e,t){t&&(k(function(){document.body.classList.toggle("always-on-top")},!0),t.setAlwaysOnTop(!t.isAlwaysOnTop()),e.checked=t.isAlwaysOnTop())}},{type:"separator"},{label:"Actual Size",type:"checkbox",accelerator:d?"Ctrl+Shift+9":"Ctrl+Shift+0",click:function(e,t){v(function(){ClientCommand.resetZoom()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom In",accelerator:"Ctrl+Shift+=",click:function(e,t){v(function(){ClientCommand.zoomIn()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom Out",accelerator:"Ctrl+Shift+-",click:function(e,t){v(function(){ClientCommand.zoomOut()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{type:"separator"},{label:"Switch Between Opened Documents",accelerator:"Ctrl+Tab",click:function(e,t){var n;!t||-1!=(t=(n=m.getAllWindows()).indexOf(t))&&n[t=++t>=n.length?0:t].focus()}},{type:"separator"},{label:"Toggle DevTools",accelerator:"Shift+F12",click:function(e,t){var n;t&&(n=setTimeout(t.webContents.openDevTools,2e3),t.webContents.executeJavaScript("ClientCommand.toggleDevTools()").then(function(){clearTimeout(n)},function(){clearTimeout(n),t.webContents.openDevTools()}))}}]}),p({label:"&Themes",submenu:[]}),p({label:"&Help",submenu:[{label:"What's New…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/What's-New/`)}},{type:"separator"},{label:"Quick Start",click:function(e,t){l.openFile(u+"/Docs/Quick Start.md")}},{label:"Markdown Reference",click:function(e,t){l.openFile(u+"/Docs/Markdown Reference.md")}},{label:"Install and Use Pandoc",click:function(e,t){l.openFile(u+"/Docs/Install and Use Pandoc.md")}},{label:"Custom Themes",click:function(e,t){l.openFile(u+"/Docs/Custom Themes.md")}},{label:"Use Images in Typora",click:function(e,t){l.openFile(u+"/Docs/Use Images in Typora.md")}},{label:"Data Recovery and Version Control",click:function(e,t){l.openFile(u+"/Docs/Auto Save, Version Control and Recovery.md")}},{label:"More Topics…",click:function(e,t){var n=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal("https://support."+n)}},{type:"separator"},{label:"Credits",click:function(e,t){l.openFile(u+"/Docs/Credits.md")}},{label:"Change Log",click:function(e,t){l.openFile(u+"/Docs/Change Log.md")}},{label:"Privacy Policy",click:function(e,t){l.openFile(u+"/Docs/Privacy Policy.md")}},{label:"Website",click:function(){var e=l.setting.get("useMirrorInCN")?"https://typoraio.cn":"https://typora.io";a.shell.openExternal(e)}},{label:"Feedback",click:function(e,t){a.shell.openExternal("mailto:hi@typora.io")}},{type:"separator"},{label:"Check Updates…",click:function(){d&&l.updater.checkForUpdates(!0)},visible:d},{label:"My License…",click:function(){y.showLicensePanel()}},global.PRODUCTION_MODE?null:{label:"Welcome…",click:function(){y.showWelcomePanel()}},{label:"About",click:r(function(){File.megaMenu.closePreferencePanel(),document.body.classList.contains("native-window")?($(".modal:not(.block-modal)").modal("hide"),$("#about-dialog").modal("show"),$("*:focus").blur()):(File.megaMenu.show(),$("#m-about").trigger("click"))},!0)}]})];d||t[0].submenu.splice(t[0].submenu.indexOf(null),1),l.isEmojiPanelSupported()&&(t[1].submenu.push({type:"separator"}),t[1].submenu.push(p({label:"Emoji and Symbols",accelerator:d?"Super+.":"",click:function(){l.showEmojiPanel()}})));const i=t[t.length-1].submenu;for(;-1{"use strict";var a=c(93).EventEmitter,n=c(134),t=n.ipcMain,d=n.app,r=c(728),l="linux"==process.platform,s=c(541).join(__dirname,"../"),g=c(445),u=c(156),m=c(359).default,f=c(477),w=c(824),b=c(587),p=new a,o=["Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2"],h="64";"ia32"==process.arch&&(h="32"),"arm64"==process.arch&&(h="arm"),p.initUpdater=function(){return u.initDict().then(function(){return o.forEach(function(e,t){o[t]=u.getPanelString(e)}),Promise.resolve()})},p.showDetailWindow=function(e,t,n){p.progressBar&&(p.progressBar.close(),p.progressBar=null),p.win&&(p.win.destroy(),p.win=null);e=b.showPanelWindow({title:u.getPanelString("Updater"),width:640,height:600,path:"updater/updater.html?curVersion=$1&newVersion=$2&labels=$3&enableAutoUpdate=$4&releaseNoteLink=$5&hideAutoUpdates=$6".replace("$1",e).replace("$2",t).replace("$3",encodeURIComponent(JSON.stringify(o))).replace("$4",JSON.stringify(!1!==d.setting.get("enableAutoUpdate"))).replace("$5",encodeURIComponent(n)).replace("$6",global.devVersion&&!g.getHasLicense())});(p.win=e).on("closed",function(){p.win=null})},p.showUI=function(){p.win||p.progressBar||(p.progressBar=new f({title:u.getPanelString("Updater"),text:u.getPanelString("Checking Updates…"),indeterminate:!0,style:{text:{padding:"3px 0"}},browserWindow:{closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}}))};p.checkForUpdates=async function(t){var e,n,o,i=d.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",i=global.devVersion||d.setting.get("autoUpdateToDev")?`https://${i}/releases/dev_windows_${h}.json`:`https://${i}/releases/windows_${h}.json`;if(i){if(p.emit("checking-for-update"),t)p.showUI();else if((e=d.setting.get("cancelUpdate"))&&new Date-new Date(e)<432e5)return;try{var r=await m(i);if(204==r.status)return void p.emit("update-not-available");if(200!=r.status)return p.emit("update-not-available"),console.error("invalid status code: "+r.statusCode+" from "+i),"Failed to check updates, invalid status code: "+r.status;var a=await r.json(),l=(n=a,o=c(842).release().replace(/\.[^.]+$/,""),a=(o=(n.alternatives||{})[o])?Object.assign(n,o):n,p.data=a,d.getVersion());if(!a.version||!l)return;if(!(0{e||(console.log(t),p.installPathOnQuit=t,d.quit())})},p.installIfNeeded=function(){p.installPathOnQuit&&p.install(p.installPathOnQuit)},p.install=function(e){c(620).spawn(e,["/SILENT"],{detached:!0,stdio:["ignore","ignore","ignore"]}).unref()},t.handle("updater.checkForUpdates",(e,t)=>{p.checkForUpdates(t)}),t.handle("updater.cancelUpdate",e=>{p.cancelUpdate()}),t.handle("updater.skipUpdate",e=>{p.skipUpdate()}),t.handle("updater.downloadUpdate",e=>{p.downloadUpdate()}),e.exports=p},620:e=>{"use strict";e.exports=require("child_process")},289:e=>{"use strict";e.exports=require("crypto")},134:e=>{"use strict";e.exports=require("electron")},554:e=>{"use strict";e.exports=require("electron-dl")},359:e=>{"use strict";e.exports=require("electron-fetch")},477:e=>{"use strict";e.exports=require("electron-progressbar")},93:e=>{"use strict";e.exports=require("events")},834:e=>{"use strict";e.exports=require("extract-zip")},833:e=>{"use strict";e.exports=require("fs")},728:e=>{"use strict";e.exports=require("fs-extra")},232:e=>{"use strict";e.exports=require("fs-plus")},338:e=>{"use strict";e.exports=require("hjson")},783:e=>{"use strict";e.exports=require("lowdb")},207:e=>{"use strict";e.exports=require("lowdb/adapters/FileSync")},640:e=>{"use strict";e.exports=require("module")},560:e=>{"use strict";e.exports=require("node-machine-id")},842:e=>{"use strict";e.exports=require("os")},541:e=>{"use strict";e.exports=require("path")},208:e=>{"use strict";e.exports=require("process")},468:e=>{"use strict";e.exports=require("raven")},426:e=>{"use strict";e.exports=require("url")},266:e=>{"use strict";e.exports=require("util")}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;t=o[e]={id:e,loaded:!1,exports:{}};return n[e](t,t.exports,i),t.loaded=!0,t.exports}i.c=o,i.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);i(i.s=90)})(); \ No newline at end of file diff --git a/Windows_x64/dec_app/head.json b/Windows_x64/dec_app/head.json index 583bc51..f07f94e 100644 --- a/Windows_x64/dec_app/head.json +++ b/Windows_x64/dec_app/head.json @@ -1 +1 @@ -{"files": {"atom.js": {"size": 172972, "offset": "0", "integrity": {"algorithm": "SHA256", "hash": "58a1c250d93bf2c2fb28a802dc08740b16b1387fe5ca999afbf2876700985d06", "blockSize": 4194304, "blocks": ["58a1c250d93bf2c2fb28a802dc08740b16b1387fe5ca999afbf2876700985d06"]}}, "main.node": {"size": 1092096, "unpacked": true, "integrity": {"algorithm": "SHA256", "hash": "799c8ff13cc08e2e52cc32d635fbffeb7a7407b66c1a7b3da575f75db1eb8603", "blockSize": 4194304, "blocks": ["799c8ff13cc08e2e52cc32d635fbffeb7a7407b66c1a7b3da575f75db1eb8603"]}}, "package.json": {"size": 245, "offset": "172972", "integrity": {"algorithm": "SHA256", "hash": "dc658429b9fc0b6c81a33ddf7b48eb5b4c8ec11a6257761c61826d67d72e633c", "blockSize": 4194304, "blocks": ["dc658429b9fc0b6c81a33ddf7b48eb5b4c8ec11a6257761c61826d67d72e633c"]}}}} \ No newline at end of file +{"files": {"atom.js": {"size": 172972, "offset": "0", "integrity": {"algorithm": "SHA256", "hash": "6f1de0c9ffe8cefda552b616aff78e5b73b3726eed1060992154fd8e27c387d5", "blockSize": 4194304, "blocks": ["6f1de0c9ffe8cefda552b616aff78e5b73b3726eed1060992154fd8e27c387d5"]}}, "main.node": {"size": 1092096, "unpacked": true, "integrity": {"algorithm": "SHA256", "hash": "799c8ff13cc08e2e52cc32d635fbffeb7a7407b66c1a7b3da575f75db1eb8603", "blockSize": 4194304, "blocks": ["799c8ff13cc08e2e52cc32d635fbffeb7a7407b66c1a7b3da575f75db1eb8603"]}}, "package.json": {"size": 245, "offset": "172972", "integrity": {"algorithm": "SHA256", "hash": "2303353d94a1f5338cb1d0ead2a99624f2fe4c9013523286f8915fb3202476f6", "blockSize": 4194304, "blocks": ["2303353d94a1f5338cb1d0ead2a99624f2fe4c9013523286f8915fb3202476f6"]}}}} \ No newline at end of file diff --git a/Windows_x64/dec_app/main.node b/Windows_x64/dec_app/main.node index b7cec0d..02ee1b7 100644 Binary files a/Windows_x64/dec_app/main.node and b/Windows_x64/dec_app/main.node differ diff --git a/Windows_x64/dec_app/package.json b/Windows_x64/dec_app/package.json index 028e3b5..510b3dc 100644 --- a/Windows_x64/dec_app/package.json +++ b/Windows_x64/dec_app/package.json @@ -1,11 +1,11 @@ { "name": "Typora", - "version": "1.5.6", + "version": "1.5.8", "main": "main.node", "family": "abnerworks", "private": true, "author": "typora.io", "homepage": "https://typora.io", "concat": "hi@typora.io", - "releaseId": "2c58e870" + "releaseId": "182719c8" } \ No newline at end of file diff --git a/Windows_x86/app.asar b/Windows_x86/app.asar index b7d4e0c..b064371 100644 Binary files a/Windows_x86/app.asar and b/Windows_x86/app.asar differ diff --git a/Windows_x86/dec_app/atom.js b/Windows_x86/dec_app/atom.js index f79a010..0ce6adc 100644 --- a/Windows_x86/dec_app/atom.js +++ b/Windows_x86/dec_app/atom.js @@ -1,2 +1,2 @@ module.exports= function(k){}; -(()=>{var n={883:(t,n,a)=>{var s=a(134),c=s.app,e=s.ipcMain,d=s.BrowserWindow,u="win32"==process.platform,p="linux"==process.platform,r=a(156),i=a(344);n.bindJumplist=()=>{var t;u&&(t=[{type:"custom",name:"Recent Locations",items:c.setting.getRecentFolders().slice(0,5).map(function(e){return{type:"task",title:e.name,description:e.path,program:process.execPath,args:JSON.stringify(e.path),iconPath:"explorer.exe",iconIndex:0}})},{type:"recent"},{type:"tasks",items:[{type:"task",program:process.execPath,arguments:"--new",iconPath:process.execPath,iconIndex:0,title:"New"}]}],c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t),i.loadDict().then(e=>{t[0].name=e["Recent Locations"]||"Recent Locations",t[2].items[0].title=e.New||"New",c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t)}))},e.handle("shell.saveItem",(e,{path:n,data:o})=>new Promise(t=>{a(833).writeFile(n,o,function(e){t()})})),e.handle("shell.openItem",(e,t)=>s.shell.openPath(a(541).normalize(t))),e.handle("shell.trashItem",async(e,t)=>{try{return await s.shell.trashItem(t),!0}catch(e){return!1}}),e.handle("shell.openExternal",(e,t)=>{if("about:blank"!=t)return s.shell.openExternal(t)}),e.handle("shell.showItemInFolder",(e,t)=>(u&&(t=t.replace(/\//g,"\\")),s.shell.showItemInFolder(t))),e.handle("shell.showDownload",(e,t)=>{e=d.fromWebContents(e.sender);const n=a(554)["download"];n(e,t,{saveAs:!0})}),e.handle("dialog.showMessageBox",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showMessageBox(p?null:e,t)}),e.handle("dialog.showSaveDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showSaveDialog(p?null:e,t)}),e.handle("dialog.showOpenDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showOpenDialog(p?null:e,t)}),e.handle("dialog.showOpenDialogAlone",(e,t)=>s.dialog.showOpenDialog(t));const h=t=>new Promise(e=>{setTimeout(()=>{e("sleep")},t)}),m=async(e,t)=>{var n=new d({skipTaskbar:!0,title:"Print PDF Preview",show:!1,webPreferences:{webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!1,nodeIntegration:!1,safeDialogs:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,zoomFactor:+(c.setting.get("zoomFactor")||"1"),backgroundThrottling:!1}});try{var o,i,r=t?(console.log("load file ["+t+"] for PDF export"),n.loadFile(t)):(o=a(541).join(c.setting.tempPath||c.getPath("temp"),+new Date+"tmp.html"),i=a(728),console.log("write output to temp file ["+o+"] for PDF export"),await i.outputFile(o,e),n.loadFile(o))}catch(e){return console.error(e),n&&n.destroy(),null}return Promise.race([h(2e4),r]).then(e=>"sleep"===e?(l(n.id),console.warn("Timeout for loading print view"),null):n.id).catch(e=>(console.error(e),n&&n.destroy(),null))},l=(e.handle("export.genPrintView",(e,t,n)=>(n&&l(n),m(null,t))),e=>{e=d.fromId(e);e&&(e.isDestroyed()||e.destroy())});e.handle("export.destroyPrintView",(e,t)=>{l(t)}),e.handle("export.getPageColor",async(e,t)=>{try{var n=await m(null,t);if(console.log("generate print preview window with id "+n),!n)return null;printWin=d.fromId(n),await h(200);var o=await printWin.webContents.executeJavaScript("window.getComputedStyle(document.body).backgroundColor")}catch(e){console.error(e)}finally{printWin&&printWin.destroy()}return o}),e.handle("export.print",(e,n,o)=>{var i=d.fromId(n);o=o||{},i.webContents.print(o,(e,t)=>{if(!e&&!/cancel/.exec(t||"")){if("no valid printers available"===t)return void i.webContents.executeJavaScript("window.print()").then(()=>{o.skipCleanUp||l(n)});s.dialog.showMessageBox({type:"error",message:r.getPanelString("Error"),detail:t,buttons:["OK"]})}o.skipCleanUp||l(n)})}),e.handle("export.printToPDF",async(e,t,n)=>{let o=null,i=null,r=null,a="";try{var l=await m(null,t);if(console.log("generate print window with id "+l),!l)return[i,r];o=d.fromId(l),await h(200),i=await o.webContents.printToPDF(n),console.log("get PDF data");var s=`(${function(){var e=document.querySelector("#write");return e?{color:(e=window.getComputedStyle(e)).color,fontFamily:e.fontFamily,bgColor:e.backgroundColor}:null}.toString()})()`;r=(r=await o.webContents.executeJavaScript(s))&&JSON.stringify(r),console.log("get background color")}catch(e){a=e.message||"",console.error(e)}finally{o&&o.destroy()}return[i,r,a]});var f,o,g=u?8e3:960,w=1;function b(){console.log("updateTheme");var e=c.setting.curTheme(),t=(c.execInAll("window.ClientCommand && File.setTheme('"+e+"');"),e.replace(/\.css$/,"").replace(/(^|-|_)(\w)/g,function(e,t,n,o){return(t?" ":"")+n.toUpperCase()})),e=s.Menu.getApplicationMenu().getItem("Themes");e&&e.submenu.items.map(function(e){e.checked=e.label==t})}e.handle("export.prepareImageCapture",async(e,t,n)=>{var o,i=s.screen.getPrimaryDisplay();try{w=i.scaleFactor||1;var r=i.workArea;if(g=Math.min(g,r.height-20),f=n.imageWidth,await(o=new d({skipTaskbar:!0,show:!1,webPreferences:{devTools:!1,webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!0,nodeIntegration:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,safeDialogs:!0},webgl:!1,useContentSize:!0,x:r.x,y:r.y,width:n.imageWidth,height:g,frame:!1,enableLargerThanScreen:!!u,offscreen:!0,alwaysOnTop:!0,minimizable:!1,closable:!0})).loadURL("file:///"+t),o.isDestroyed())return null;if(await h(2e3),o.isDestroyed())return null;var a=+await o.webContents.executeJavaScript("window.innerHeight");if(o.isDestroyed())return null;var l=+await o.webContents.executeJavaScript("document.body.parentElement.scrollTop = document.body.clientHeight;\nMath.max(document.body.clientHeight, document.body.parentElement.scrollHeight)");return o.isDestroyed()?null:Number.isNaN(l)||Number.isNaN(a)?void 0:(p&&(g=a),{winId:o.id,totalHeight:l,pageHeight:g,imageWidth:n.imageWidth,scale:3===n.quality?w:1})}catch(e){return console.error(e),null==o||o.isDestroyed()||o.destroy(),null}}),e.handle("export.captureImage",async(e,t,n,o)=>{t=d.fromId(t);if(!t||t.isDestroyed())return null;try{o&&(t.setSize(o.imageWidth,o.pageHeight),t.setContentSize(o.imageWidth,o.pageHeight));var i=+await t.webContents.executeJavaScript("document.body.parentElement.scrollTop = {d}; document.body.parentElement.scrollHeight;".replace("{d}",n));if(await h(1e3),t.isDestroyed()||Number.isNaN(i))return null;var r=await t.webContents.capturePage();if(!r||r.isEmpty())return null;var a=null;return 1new Promise((t,e)=>{try{var n=s.net.request({url:o,redirect:"follow"});n.on("response",function(e){try{if(200!=e.statusCode)return t(null);if(!e.data)return t(null);t({type:(e.headers["content-type"]||[""])[0],data:e.data})}catch(e){t(null)}}),n.end()}catch(e){t(null)}})),e.handle("clipboard.write",(e,t,n)=>{n&&s.clipboard.clear(),s.clipboard.write(JSON.parse(t))}),e.handle("pandoc.import",(e,n)=>{var o={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"'":"\\'","\\":"\\\\"},e=d.fromWebContents(e.sender),t=n?Promise.resolve(e):c.openFile(null,{syncAndPrepOnly:!0}).then(n=>new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e(n.activeWindow)}):e(n.activeWindow)})),e=s.dialog.showOpenDialog(n?e:null,{title:i.getMenuDict.Import,properties:["openFile"],filters:[{name:r.getPanelString("All Supported Formats"),extensions:["docx","rtf","latex","tex","ltx","rst","rest","org","wiki","dokuwiki","mediawiki","textile","opml","epub"]},{name:"MS Word",extensions:["docx"]},{name:"RTF",extensions:["rtf"]},{name:"TeX/LaTeX",extensions:["latex","tex","ltx"]},{name:"reStructuredText",extensions:["rst","rest"]},{name:"org-mode",extensions:["org"]},{name:"Wiki",extensions:["wiki","dokuwiki","mediawiki"]},{name:"Epub",extensions:["epub"]},{name:"Textile",extensions:["textile"]},{name:"OPML",extensions:["opml"]}]}).then(({filePaths:e})=>(e||[null])[0]);return Promise.all([t,e]).then(async([e,t])=>{t?(await h(100),e.show(),e.webContents.executeJavaScript('window.getSelection().removeAllRanges();ClientCommand.doImport("'+t.replace(/["'\\\b\t\n\f\r]/g,function(e){return o[e]}).replace(/\u200b/g,"")+'")')):n||e.destroy()})}),e.handle("pandoc.version",()=>o),e.handle("pandoc.setVersion",(e,t)=>{o=t}),s.nativeTheme.on("updated",function(){null!==c.setting.useDarkThemeBefore()&&c.setting.useDarkThemeBefore()!==c.setting.useDarkTheme()&&b()}),e.handle("theme.apply",()=>{b()}),e.handle("theme.setThemeSource",(e,t)=>{"system"!==(t=t||"system")&&c.setting.get("useSeparateDarkTheme")||(s.nativeTheme.themeSource=t)}),e.on("ondragstart",function(t,n,o){setTimeout(function(){var e=s.nativeImage;t.sender.startDrag({file:n,icon:o?e.createFromPath(a(541).normalize(o)):e.createEmpty()}),console.log("ondragstart "+n+" "+o)},100)}),e.handle("getPath",(e,t)=>c.getPath(t))},156:(e,t,n)=>{var o=n(134).app,i=n(728),r=n(541).join(__dirname,"../"),a=["Operation Failed","Save As","All Supported Formats","Error","Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2","Updater","Checking Updates…","Downloading Updates…","You're up to date!","Check Update Failed","Download failed","Install Updates ?","Quit and Install","Cancel","Download","Downloading…","Extracting binary…","This dev version of Typora is expired, please download and install a newer version.","This device has been deactivated","Typora is now deactivated","UNREGISTERED"],l={},s=!1;e.exports={initDict:function(){if(s)return Promise.resolve();var e=n(541).join(r,o.setting.getLocaleFolder("Panel"));return i.readJSON(e,"utf8").then(function(t){s=!0,a.map(function(e){l[e]=t[e]||e})}).catch(function(){})},getPanelString:function(e){return l[e]||e}}},351:(r,l,c)=>{function d(e,t){this.activeWindow=t||null,this.windows=new Set(t),this.path=e||null,this.snap=null,this.lastSync,this.content,this.backupState=null}var e=c(134),u=e.app,a=e.BrowserWindow,s=(e.powerMonitor,c(728)),e=c(232),h=(c(266),process.platform,process.platform,"linux"==process.platform),g=c(468),m=c(587),t=c(134).ipcMain,o=(t.on("doc.syncChange",function(e,t){var n=a.fromWebContents(e.sender),o=u.documentController.getDocumentFromWindowId(n.id);n==o.activeWindow&&1=n}catch(e){console.warn(e)}return!1}},d.prototype.getWindowToFocus=function(){var e=this.activeWindow||this.windows.keys().next().value;if(e){if(!e.isDestroyed())return e;this.activeWindow=null,this.windows.delete(e)}return null},d.prototype.syncFullContent=function(t){var e,n=!1;if(this.windows.forEach(function(e){this.activeWindow!=e&&!n&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&(n=!0)}),n)return e=this.windows,this.activeWindow.webContents.executeJavaScript("File.sync(false, true);1;").then(function(){e.forEach(function(e){this.activeWindow!=e&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&e.webContents.executeJavaScript("File.editor.applyFullContent("+!!t+")")})}),null},d.prototype.popBackupState=async function(){var e=this.backupState;return this.backupState=void 0,Promise,e},function(e){return c(541).basename(e)}),f=e.isCaseInsensitive();function p(e){return f?e&&e.toLowerCase():e}function n(){this.documents=new Set,this.path2doc=new Map,this.win2doc=new Map,this.name2docs=new Map,this.frozenDocs=[],this.watchSystemPause()}n.prototype.watchSystemPause=function(){u.whenReady().then(()=>{})},n.prototype.setContentForWindow=function(e,t){var n=this.getDocumentFromWindowId(t);(n.activeWindow||{}).id==t&&n.setContent(e)},n.prototype.solveDuplicateName_=function(e){var t=e.path,t=p(o(t)),n=this.name2docs.get(t)||new Set;this.name2docs.set(t,n),0{e=a.fromWebContents(e.sender),t=t?u.getDocumentController().getDocument(t):u.documentController.getDocumentFromWindowId(e.id);t&&t.activeWindow==e&&t&&t.switchToUntitled(n)}),t.handle("document.setLastSync",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).setLastSync(t)}),t.handle("document.syncFullContent",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).syncFullContent(t)}),t.handle("document.getContent",e=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).getContent()}),t.handle("document.currentPath",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).path});const b=async e=>{var t=e.getSnap(null),n=e.path,o=!1,i=null;return(t||{}).nodeMap?o=await e.shouldReadFromDisk():i=await e.popBackupState(),i&&i.hasUnsaved?console.log("load from recover content length: "+i.content.length):i=null,JSON.stringify({snap:t,filePath:n,backups:i,shouldReadFromDisk:o,windowCounts:e.windows.size})};t.handle("document.loadData",async e=>{console.log("handle document.loadData");new Date;e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),e=await b(e);return new Date,e}),t.handle("document.switchDocument",async(e,t)=>{e=a.fromWebContents(e.sender),e=await u.getDocumentController().switchDocument(e.id,t);return b(e)}),t.handle("document.rename",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).rename(t),!0}),t.handle("document.setContent",(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=e.content==t;return e.setContent(t),n}),t.handle("document.addSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return t?e.addSnap(JSON.parse(t)):e.addSnap(null),!0}),t.handle("document.addSnapAndLastSync",(e,t)=>{try{var n,o,i=a.fromWebContents(e.sender),r=u.documentController.getDocumentFromWindowId(i.id);t?({snap:n,lastSync:o}=JSON.parse(t),r.addSnap(n),r.setLastSync(o)):r.addSnap(null)}catch(e){console.error(e)}return!0}),t.handle("document.shouldSaveSnap",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).shouldSaveSnap()}),t.handle("document.getSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return JSON.stringify(e.getSnap(t))}),t.handle("document.getSnapWithValidation",async(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=await e.isSnapValid();return JSON.stringify({snap:e.getSnap(t),shouldReadFromDisk:0==n})}),t.handle("document.enterOversize",e=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);e&&e.enterOversize()}),t.handle("document.newWindow",e=>{3==u.setting.get("restoreWhenLaunch")?u.openFile(null,{mountFolder:u.setting.get("pinFolder"),silent:"pinFolder"}):u.openFile()}),t.handle("document.checkIfMoveOnSave",(e,t)=>{var e=a.fromWebContents(e.sender),n=u.documentController.getDocument(t);return!n&&((n=u.documentController.getDocumentFromWindowId(e.id)).rename(t),!0)}),t.handle("document.hasDuplicateName",(e,t)=>u.documentController.hasDuplicateName(t)),t.handle("document.noOtherWindow",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).windows.size<=1});var i=new n;r.exports=i},824:(e,t,s)=>{var c=s(728),d=s(541),u={title:"Download",text:"Downloading…",indeterminate:!1,initialValue:0,maxValue:1,closeOnComplete:!1,abortOnError:!1,style:{text:{padding:"3px 0"}},browserWindow:{modal:!1,closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}};function p(e){if(e<1024)return e+" B";var t=e/Math.pow(1024,1),e=e/Math.pow(1024,2);return e<1?(t+"").replace(/(\..)(.+)$/,"$1")+"KB":(e+"").replace(/(\..)(.+)$/,"$1")+"MB"}function n(e,t,n){this.onAbort=null,this.onSuccess=null,this.onError=null,this.downloadURL=e,this.dist=t,this.displayOption=n||{},this.progressBar=null,this.downloadItem=null}n.prototype.cancel=function(){if(this.downloadItem){try{this.downloadItem.cancel()}catch(e){}this.downloadItem=null}this.setCompleted(),this.onAbort&&this.onAbort()},n.prototype.setCompleted=function(){this.downloadItem=null,this.progressBar&&(this.progressBar.setCompleted(),this.progressBar.close(),this.progressBar=null)},n.prototype.download=function(){var e=s(477),t=s(554),n=this,o=this.downloadURL,i=this.dist,r=this.displayOption,a=new e(Object.assign({},u,r)),l=((this.progressBar=a).on("aborted",function(){n.cancel()}),d.dirname(i));Promise.all([new Promise(function(e){a.on("ready",e)}),c.ensureDir(l)]).then(function(){console.record("[downloader] downloading "+o,"DEBUG"),t.download(a._window,o,{showBadge:r.showBadge||!1,directory:l,filename:d.basename(i),onProgress:function(e){a&&(a.value=e.percent*(r.processOnComplete||1),a.detail=p(e.transferredBytes)+" / "+p(e.totalBytes))},onStarted:function(e){console.log("start downloading "+e.getURL()),n.downloadItem=e},onCancel:function(){console.log("canceled downloading "+downloadItem.getURL()),n.cancel()}}).then(function(e){n.onSuccess(e,a)}).catch(function(e){console.log("error downloading "+(n.downloadItem&&n.downloadItem.getURL())),n.onError(e)})})},e.exports=n},405:(e,t,n)=>{var n=n(134),o=n.app,n=n.ipcMain,i=global.t_workingDir,r=o.getVersion(),a=(/-([a-z]+)/.exec(r)||[])[1],l=r;function s(e,t){var n,o,i;for(e=(e||"").replace(/-[a-z]+/,""),t=(t||"").replace(/-[a-z]+/,""),e=e.split("."),t=t.split("."),o=Math.min(e.length,t.length),n=0;n({PRODUCTION_MODE:global.PRODUCTION_MODE,DEBUG_MODE:global.DEBUG_MODE,version:o.getVersion(),devVersion:global.devVersion})),global.compareVersion=s,global.t_workingDir=i,global.PRODUCTION_MODE=!0,global.DEBUG_MODE=!1},932:(e,t,n)=>{function o(){this.clearUndo()}function i(e){r.dialog.showErrorBox(l.getPanelString("Operation Failed"),e.message)}var r=n(134),a=r.app,l=n(156),s=n(728),n=r.ipcMain,c=(o.prototype.hasUndo=function(e){return!(!this.hasUndo_||!e)&&(0==(this.undoTo_||"").indexOf(e)||0==(this.undoFrom_||"").indexOf(e))},o.prototype.undoLabel=function(){return this.undoLabel_},o.prototype.clearUndo=function(){this.undoFrom_="",this.undoTo_="",this.undoLabel_="",this.hasUndo_=!1},o.prototype.registerUndo=function(e,t,n){this.undoFrom_=e,this.undoTo_=t,this.undoLabel_=n,this.hasUndo_=!0},o.prototype.getFocusPath=function(){return this.hasUndo_&&this.undoTo_},o.prototype.performUndo=function(){var t;function n(){r.dialog.showMessageBox({type:"warning",message:l.getPanelString("Operation Failed"),defaultId:0,cancelId:1,buttons:[l.getPanelString("Save As"),l.getPanelString("Cancel")]}).then(({response:e})=>{0==e?r.dialog.showSaveDialog({defaultPath:t.undoTo_,properties:["showOverwriteConfirmation"]}).then(({filePath:e})=>{e&&e!=t.undoFrom_&&s.rename(t.undoFrom_,e,function(e){e&&i(e)}),t.clearUndo()}):t.clearUndo()})}this.hasUndo_&&(this.hasUndo_=!1,(t=this).undoTo_?s.existsSync(this.undoTo_)?n():(a.sendEvent("willRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),s.copyFile(this.undoFrom_,this.undoTo_,function(e){s.unlink(t.undoFrom_,function(){}),e?(n(),a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoFrom_})):(a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),t.clearUndo())})):s.remove(this.undoFrom_,function(e){e?i(e):(t.clearUndo(),a.sendEvent("updateQuickOpenCache",{toDel:this.undoFrom_}))}))},new o);n.handle("filesOp.registerUndo",(e,t,n,o)=>{c.registerUndo(t,n,o)}),n.handle("filesOp.clearUndo",e=>{c.clearUndo()}),n.handle("filesOp.performUndo",e=>{c.performUndo()}),n.handle("filesOp.getFocusPath",e=>c.getFocusPath()),n.handle("filesOp.undoLabel",(e,t)=>c.hasUndo(t)?c.undoLabel():null),t.default=c},445:(o,u,i)=>{i(405);var p,h=i(156),g=i(134),m=g.shell,l=g.app,e=g.ipcMain,f=g.BrowserWindow,w="win32"==process.platform,b="darwin"==process.platform,y="linux"==process.platform,v=i(587),k=i(359).default,s=i(468),C=!1;const F=function(e){try{return require(e)}catch(e){if(C)return;C=!0;var t=e.message;setTimeout(()=>{C=!1,(dialog=i(134).dialog).showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:"A required module cannot be loaded by Typora",message:t.split("\n")[0]+"\n\nPlease check if that file exists or reinstall Typora to fix."}).then(({})=>{process.exit(1)})},1500)}};var S,r=null,x="",c="",a="",D="";const T={SUCCESS:0,OUT_OF_LIMIT:1,INVALIDATE:-1,WRONG_USER:-2},P=JSON.parse(Buffer.from("WyItLS0tLUJFR0lOIFBVQkxJQyBLRVktLS0tLSIsIk1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBN25Wb0dDSHFJTUp5cWdBTEVVcmMiLCI1SkpoYXAwK0h0SnF6UEUwNHB6NHkrbnJPbVk3LzEyZjNIdlp5eW9Sc3hLZFhUWmJPMHdFSEZJaDBjUnFzdWFKIiwiUHlhT09QYkEwQnNhbG9mSUFZM21SaFFRM3ZTZitybjNnK3cwUyt1ZFdtS1Y5RG5tSmxwV3FpekZhalU0VC9FNCIsIjVaZ01OY1h0M0UxaXBzMzJyZGJUUjBObmVuOVBWSVR2cmJKM2w2Q0kyQkZCSW1aUVoyUDhOK0xzcWZKc3F5VlYiLCJ3RGt0M21IQVZ4VjdGWmJmWVdHKzhGRFN1S1FIYUNtdmdBdENoeDlod2wzSjZSZWtrcURWYTZHSVYxM0QyM0xTIiwicWRrMEpiNTIxd0ZKaS9WNlFBSzZTTEJpYnk1Z1lONnpRUTVSUXBqWHRSNTNNd3pUZGlBekdFdUtkT3RyWTJNZSIsIkR3SURBUUFCIiwiLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tIiwiIiwiIl0=","base64").toString("utf8")).join("\n"),I=864e5;var W="https://store.typora.io";const E=e=>{if(!e)return e;var t;try{t=Buffer.from(e,"base64");const n=i(289).publicDecrypt(P,t);return JSON.parse(n.toString("utf8"))}catch(e){return null}},O=function(){var e=Array.from(arguments);const t=i(289).createHash("sha256");return e.forEach(e=>{t.update(e)}),t.digest("base64")},_=()=>{const e=d().get("SLicense");if(!e)return null;var[t,n,o]=e.split("#"),t=E(t);return t&&t.fingerprint==a?(Object.assign(t,{failCounts:n,lastRetry:new Date(o)}),t):null},M=async e=>{console.log("writeInstallDate fromBTime="+e);var t=new Date;if(e)try{var n=await i(728).stat(l.getPath("userData")+"/profile.data"),t=new Date(n.birthtime);n.birthtime}catch(e){}e=(p=t).toLocaleDateString("en-US");return d().put("IDate",e),p};var L=null;const d=function(){var n;return L=null==L?w?function(){const o=F("native-reg"),i="Software\\Typora";return{get:function(e){var t=o.openKey(o.HKCU,i,o.Access.READ);if(null==t)return"";e=o.getValue(t,null,e);return o.closeKey(t),e},put:function(e,t){var n=o.createKey(o.HKCU,i,o.Access.WRITE);o.setValueSZ(n,e,t),o.closeKey(n)}}}():(n=l.setting.prepDatabase(a),{put:function(e,t){console.log("ls put "+e),n.getState()[e]=t,n.write()},get:function(e){return n.getState()[e]}}):L};const U=async()=>{if(!a){if(w){const t=F("native-reg");var e=t.openKey(t.HKEY.LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Cryptography",t.Access.WOW64_64KEY|t.Access.READ);a=t.getValue(e,null,"MachineGuid"),t.closeKey(e)}else a=await i(560).machineId({original:!0});a||s.captureMessage("[L] Failed to get fingerPrint"),a=O(a,"typora").substr(0,10).replace(/[/=+-]/g,"a"),b&&(a+="darwin")}return a};var R=!1;const A=()=>{var e=s.getContext().tags;e.hasLicense=r,s.mergeContext(e)},N=()=>process.platform.replace(/\d+/,""),B=async(t,n,o)=>{oe(),console.log(`request ${W}/`+t);const e=new AbortController;var i,r=setTimeout(()=>e.abort(),3e4);try{i=await k(W+"/"+t,{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}}),clearTimeout(r)}catch(e){var a=e;if(console.warn(e.stack),clearTimeout(r),o&&"zh-Hans"==l.setting.getUserLocale()&&!l.setting.get("useMirrorInCN")){r=(await g.dialog.showMessageBox(null,{message:"链接服务器失败,使用尝试访问国内域名进行激活?",buttons:["确认","取消"]}))["response"];if(console.log("click "+r),r)throw a;return l.setting.put("useMirrorInCN",!0),B(t,n,!1)}if(l.setting.get("useMirrorInCN"))try{console.log("request to typora.com.cn"),i=await post("https://typora.com.cn/store/"+t,n)}catch(e){throw a}}if(i){if(200==i.status)return-1{const o=(new Date).toLocaleDateString("en-US");var{deviceId:t,lastRetry:i}=t||{};if(n||!(new Date-ir.abort(),4e4);const a=await(await k(W+"/api/client/renew",{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}})).json();clearTimeout(e),a.success||(console.warn("[renewL]: unfill due to renew fail"),$(a.msg)),d().put("SLicense",[a.msg,0,o].join("#"))}catch(e){e.stack,s.captureException(e,{level:"warning"}),console.warn("Failed to Renew L");var[t,n]=(i=d().get("SLicense")).split("#"),i=[t,n=+n+1,o].join("#");d().put("SLicense",i)}}},J=e=>{var t=new Date(d().get("IDate"));return isNaN(t.getTime())?e?null:new Date:e?t:(e=1675928631787,isNaN(e)?e=new Date("2021-10-01"):(e=new Date(e),isNaN(e.getTime())&&(e=new Date("2021-10-01"))),t{if(t=t||15,432e5{var e=(p=J(!global.devVersion))?V(!1):100;(15{R=!0;var t=_(),{license:n,email:o,type:i}=t||{};n&&o?(j(o,n,i),z(t,e)):$()},K=(e,t)=>g.dialog.showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:e,message:t}),Q=function(){l.expired=!0,K(h.getPanelString("Error"),h.getPanelString("This dev version of Typora is expired, please download and install a newer version.")).then(()=>{m.openExternal("https://typora.io/#download"),setTimeout(()=>{process.exit(1)},1e3)})},Z=function(){var e;re()&&!l.setting.inFirstShow&&(e=y||global.devVersion,y&&Math.random()<.8||(!S||new Date-S>36e5*(e?4:2)||!e&&V(!0,16)<=0)&&Y())};var G=!1,t=null;const Y=async function(e){if(S=new Date,null==t)return(t=v.showPanelWindow({width:525,height:420,path:`page-dist/license.html?dayRemains=${V(!0)}&index=${e?1:0}&hasActivated=${r||!1}&email=${x}&license=${c}&lang=${l.setting.getUserLocale()}&needLicense=${ie()&&!global.devVersion}&type=${D}&os=`+(w?"win":b?"mac":"linux"),frame:!1,alwaysOnTop:!C})).on("closed",function(){t=null}),void setTimeout(()=>{t&&!t.isDestroyed()&&t.setAlwaysOnTop(!1)},5e3);t.focus()};var n=null;async function X(){var o=(o=process.env.USER)||i(842).userInfo().username;switch(process.platform){case"win32":return process.env.COMPUTERNAME+" | "+o+" | Windows";case"darwin":return new Promise(n=>{i(620).exec("scutil --get ComputerName",{timeout:5e3},(e,t)=>{n(!e&&t?t.toString().trim()+" | "+o+" | darwin":i(842).hostname()+" | "+o+" | darwin")})});default:return i(842).hostname()+" | "+o+" | Linux"}}async function ee(e){try{var{fingerprint:t,email:n,license:o,type:i}=E(e)||{};return n&&o&&t?t!=await U()?(console.log("[L] validate server return fail"),$(),!1):(j(n,o,i),d().put("SLicense",e+"#0#"+(new Date).toLocaleDateString("en-US")),r=!0):(console.log("[L] validate server return empty"),$(),!1)}catch(e){throw console.error(e.stack),new Error("WriteActivationInfoFail")}}const te=e=>{const r="L23456789ABCDEFGHJKMNPQRSTUVWXYZ";if(!/^([A-Z0-9]{6}-){3}[A-Z0-9]{6}$/.exec(e))return!1;var e=e.replace(/-/g,""),t=e.substr(22);return!e.replace(/[L23456789ABCDEFGHJKMNPQRSTUVWXYZ]/g,"")&&t==(e=>{for(var t="",n=0;n<2;n++){for(var o=0,i=0;i<16;i+=2)o+=r.indexOf(e[n+i]);o%=r.length,t+=r[o]}return t})(e)},ne=(e.handle("license.machineCode",async()=>{console.log("handle license.machineCode");try{return await Buffer.from(JSON.stringify({v:N()+"|"+l.getVersion(),i:await U(),l:await X()}),"utf8").toString("base64")}catch(e){console.error(e.stack)}}),async t=>{r&&x&&c||console.error("doDeactivation on unregistered device");var e=(_()||{})["deviceId"];try{await B("api/client/deactivate",{license:c,l:e,sig:O(x,await U(),c)},!1)}catch(e){if(s.captureException(e,{level:"warning"}),console.log(e.stack),!t&&"off"==D)return!1}return $(),!0}),oe=(e.handle("addLicense",async(e,{email:t,license:n,force:o})=>{try{return await async function(e,t,n){if(e=(e||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),t=(t||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),!/^[^\s@'"/\\=?]+@[^\s@'"/\\]+\.[^\s@'"/\\]+$/.test(e))return[!1,"Please input a valid email address"];if(!te(t))return[!1,"Please input a valid license code"];t={v:N()+"|"+l.getVersion(),license:t,email:e,l:await X(),f:await U(),u:l.setting.generateUUID(),type:global.devVersion?"dev":"",force:n};JSON.stringify(t);try{var o=await B("api/client/activate",t,!0);if(JSON.stringify(o),console.log("[License] response code is "+o.code),o.code==T.SUCCESS)return await ee(o.msg)?[!0,""]:[!1,"Please input a valid license code"];if(o.code==T.OUT_OF_LIMIT)return n?await ee(o.msg)?[!0,"Your license has exceeded the max devices numbers.\nThe oldest device was unregistered automatically."]:[!1,"Please input a valid license code"]:["confirm",'Your license has exceeded the max devices numbers.\nIf you click "Continue Activation", this device will be activated and the oldest device will be unregistered automatically.'];if(o.code==T.INVALIDATE)return[!1,"Please input a valid license code"];if(o.code==T.WRONG_USER)return[!1,"This license code has been used with a different email address."]}catch(e){return"WriteActivationInfoFail"==e.message?(ne(!0).then(()=>{},()=>{}),[!1,"Failed to write your license to local machine"]):e.response&&e.response.code?(console.warn("[L] error from server "+e.response.code),[!1,"Unknown Error. Please contact hi@typora.io"]):(s.captureException(e,{level:"warning"}),console.error(e.stack),[!1,"Failed to access the license server. Please check your network or try again later."])}}(t,n,o)}catch(e){console.error(e.stack)}}),e.handle("offlineActivation",async(e,t)=>{try{return n=t,await(await ee(n)?[!0,"",x,c]:[!1,"Please input a valid license code"])}catch(e){console.error(e.stack)}var n}),e.handle("license.show",(e,t)=>{Y(t||!1)}),e.handle("license.show.debug",()=>{t&&t.webContents.openDevTools()}),e.handle("removeLicense",async e=>{try{return await ne()}catch(e){console.error(e.stack)}return!1}),()=>{W=l.setting.get("useMirrorInCN")?shostc||"".substring(1):global.shost||"".substring(1)});const ie=()=>!r&&!y,re=e=>R&&!r;var ae;ae=(new Date).getTime();const le="txxxx-xxxx-xxxxy".replace(/[x]/g,function(e){var t=(ae+16*Math.random())%16|0;return ae=Math.floor(ae/16),t.toString(16)}),se=()=>{f.getAllWindows().forEach(e=>{e.webContents.executeJavaScript(`try{document.querySelector(".${le}").remove();}catch(e){};File.option && (File.option.hasLicense = true);File.megaMenu && File.megaMenu.forceReload();0;`)})},ce=async e=>{await h.initDict();const t=`.typora-sourceview-on .${le}{left: 170px;}.${le} {position: fixed;bottom: 2px;z-index: 9999;left: 70px;font-size: 12px;line-height: 24px;background: rgb(120 120 120 / 30%);padding: 0 12px;color: var(--text-color);border-radius: 4px;cursor: pointer;}.pin-outline .${le}{left:calc(var(--sidebar-width) + 70px);}`,n=`if(window.File.option){File.option.hasLicense = false;File.megaMenu && File.megaMenu.forceReload(); };1;`;function o(e){e.webContents.insertCSS(t.replace(/(\{|\}|;)\n/g,"$1")),e.webContents.executeJavaScript(n.replace(/(\{|\}|;)\n/g,"$1"))}e?o(e):f.getAllWindows().forEach(o)};w&&(e=i(541).join(t_workingDir,"../winmm.dll"),i(833).stat(e,function(e,t){!e&&t&&setTimeout(function(){G=!0},138e4)})),u.startL=async(e,t)=>{console.log("start LM in devVersion="+(global.devVersion||!1));try{oe(),await U(),!e&&t||y||(global.devVersion||!t||-1240*I)&&Q(),n=+n,console.log("verInitTime is "+n),!isNaN(n)&&o-n>200*I&&Q()),(async e=>{console.log("[watch L]"),q(e),r=true,await H(),console.log("[watch L] hasL: "+r),Z(),A()})(e)}catch(e){s.captureException(e)}var n,o,i;v.on("dom-ready",e=>{e=e,R&&re()&&ce(e)}),v.on("make-window",e=>{Z()})},u.showLicensePanel=Y,u.showWelcomePanel=async function(){if(S=new Date,null==n)return(n=v.showPanelWindow({width:760,height:460,path:"page-dist/welcome.html?lang="+l.setting.getUserLocale(),frame:!1,alwaysOnTop:!C})).on("closed",function(){n=null}),void setTimeout(()=>{n&&!n.isDestroyed()&&n.setAlwaysOnTop(!1)},4e3);n.focus()},u.shouldShowWelcomePanel=ie,u.getHasLicense=()=>r,u.cannotContinueUse=function(){return!1===r&&!y&&!global.devVersion&&(G||V(!0,20)<=0)}},557:(o,i,F)=>{var c,d,W=global.PRODUCTION_MODE,S=F(134),x=S.app,u=F(266),r=F(338),a=S.Menu,l=S.MenuItem,p=S.BrowserWindow,s=S.shell,D="win32"==process.platform,h="darwin"==process.platform,g="linux"==process.platform,T=F(728),P=F(541).join(__dirname,"../"),m=F(344),f=F(824),w=F(156),E=F(445),b=require(W?"package.json":"../package.json"),I=F(468),y=1e4;function v(t){var o,i,r=0,n=x.getPath("userData")+"/typora.log",a="",l=console.error;function s(e,t){try{if(y{this.logStream=e})}function k(){var n=(new Date).getTime();return uuid="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),("x"==e?t:3&t|8).toString(16)})}function _(t){var e=1675928631787,n=!1,o=0;isNaN(e)||(o=30<(e=(new Date-e)/864e5/5)?(n=!0,.001):Math.max(0,(30-e)/30),isNaN(o)&&(o=.01)),I.config("https://41af752e6d61480d85276af874a7f69b@sentry.typora.io/2",{logger:"node",release:b.releaseId,autoBreadcrumbs:{http:!1,console:!1},sampleRate:o,shouldSendCallback:function(e){return(!e||"debug"!=e.level)&&(!n&&!t.hasUpdates&&t.db&&t.get("send_usage_info")+""!="false")}}).install(B),C=k(),I.mergeContext({tags:{instance:C,arch:process.platform,appVersion:x.getVersion()}}),I.disableConsoleAlerts(),setTimeout(function(){console.log("[Raven] instanceKey = "+C)},0),I.setDataCallback(function(e){try{return e?(e.request&&(e.request.url="http://typora/"),e.mechanism&&delete e.mechanism,e.exception&&(t=e)&&(t.message&&(t.message=L(t.message)),(t.exception||[]).forEach(function(e){e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&e.stacktrace.frames.forEach(function(e){e.filename&&(e.filename=U(e.filename))})}),n=t.stacktrace||[],(t=(t.exception||{}).values||[]).forEach&&t.forEach(function(e,t){e&&(e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&(n=n.concat(e.stacktrace.frames)))}),n.length&&n.forEach(function(e){var t;-1<(t=e.filename.lastIndexOf("atom.asar"))&&(e.filename="http://typora-app/atom/"+e.filename.substring(t+9).replace(/\\/g,"/"))})),e):void 0}catch(e){console.error(e.stack)}var t,n;return{}})}e.prototype.closeLogging=function(){console.log("closeLogging");try{c=!0,d&&(process.stdout.write=process.stderr.write=d),this.logStream&&this.logStream.end()}catch(e){console.error(e)}},e.prototype.put=function(e,t){this.db.getState()[e]=t,this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=setTimeout(this.save.bind(this),500)},e.prototype.get=function(e,t){try{return"recentDocument"==e?this.getRecentDocuments():"recentFolder"==e?this.getRecentFolders():("framelessWindow"!=e||!g)&&(void 0===(n=this.db.getState())[e]?t:n[e]);var n}catch(e){return console.error(e),t}},e.prototype.save=function(){this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=null;try{this.db.write()}catch(e){console.error(e.stack)}},e.prototype.syncAll=function(){this.saveTimer&&clearTimeout(this.saveTimer);try{this.db.write(),this.history.write()}catch(e){console.error(e.stack)}},e.prototype.getAllThemes=function(){return this.allThemes},e.prototype.getRecentFolders=function(){var e=this.history.getState(),t=e.recentFolder;return t||(e.recentFolder=t=[]),t||[]},e.prototype.addRecentFolder=function(e){console.log("addRecentFolder"),e=F(541).normalize(e);var t=F(541).basename(e),n=this.getRecentFolders();if(t.length){this.removeRecentFolder(e,!0),n.unshift({name:t,path:e,date:new Date}),8new Promise(e=>{T.rm(l.join(v,t),{force:!0,recursive:!0,maxRetries:1},e)})))}await 0}if(0==o&&T.existsSync(a))g();else{console.log("overwriteThemeFolder"),T.ensureDirSync(f);var w=[];if(-1<["github.css","newsprint.css","night.css","pixyll.css","white.css"].indexOf(e)){try{T.renameSync(l.join(a,e),l.join(f,e)),w.push(e)}catch(e){}T.copySync(l.join(m,e),l.join(a,e),{overwrite:!0})}h.list(m,function(e,t){Promise.all(t.map(function(e){var r=l.basename(e);return new Promise(function(e,t){if(-1{}),C.rm(s.join(c,i+".aff"),{force:!0},()=>{}),C.rm(s.join(c,i+"-LICENSE"),{force:!0},()=>{}),console.log(`remove ${c}/${i}.dic`)}}else this.put("strict_mode",!0),this.put("copy_markdown_by_default",!0)}this.initDictionary_(),this.addAnalyticsEvent("launch"),t&&0!=o?this.addAnalyticsEvent(0{var t=x.setting.get("export.general")||{},n={},o=(["pdf","html","html-plain","image"].forEach(e=>{n[e]=Object.assign({type:e},t,x.setting.get("export."+e)||{})}),{});return x.setting.loadCustomExports().forEach(e=>{o[e.key]=Object.assign({},t,e,x.setting.get("export."+e.key)||{})}),JSON.stringify([n,o])}),n.handle("export.recordLastExport",(e,t)=>{A||(x.updateMenu({"File→Export→Export with Previous":{enabled:!0}}),x.updateMenu({"File→Export→Export and Overwrite with Previous":{enabled:!0}})),A=t,x.setting.lastExport=t,x.execInAll("File.option._lastExport = "+JSON.stringify(t))}),n.handle("setting.getDownloadingDicts",e=>JSON.stringify(x.setting.downloadingDicts||[])),n.handle("setting.getUserDictionaryPath",e=>x.setting.getUserDictionaryPath()),n.handle("setting.getUserDict",e=>JSON.stringify(x.setting.userDict)),n.handle("setting.downloadDict",(e,t)=>{e=p.fromWebContents(e.sender);x.setting.downloadDict(t,e.id)}),n.handle("setting.getThemes",e=>({all:x.setting.getAllThemes()||[],current:x.setting.curTheme()})),n.handle("setting.setCurTheme",(e,t,n)=>{x.setting.setCurTheme(t,n)}),n.handle("setting.resetAdvancedSettings",(e,t)=>{function n(){}var o=F(728),i=x.getPath("userData")+"/conf/conf.user.json";o.copy(P+"/conf.default.json",x.getPath("userData")+"/conf/conf.default.json",{overwrite:!0},t?function(){S.shell.showItemInFolder(i)}:n),o.copy(P+"/conf.default.json",i,{overwrite:!0},n)}),n.handle("logger.error",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Error] "+t)}),n.handle("logger.warn",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Warn] "+t)}),n.handle("setting.clearRecentDocuments",e=>{x.setting.clearRecentDocuments()}),n.handle("setting.removeRecentFolder",(e,t)=>{x.setting.removeRecentFolder(t)}),n.handle("setting.removeRecentDocument",(e,t)=>{x.setting.removeRecentDocument(t)}),n.handle("setting.addRecentFolder",(e,t)=>{x.setting.addRecentFolder(t)}),n.handle("setting.getRecentFiles",e=>JSON.stringify({files:x.setting.getRecentDocuments()||[],folders:x.setting.getRecentFolders()||[]})),n.handle("setting.put",(e,t,n)=>{x.setting.put(t,n)}),n.handle("setting.get",(e,t)=>x.setting.get(t)),n.handle("setting.fetchAnalytics",e=>{var t=JSON.stringify(x.setting.analyticsEvents);return x.setting.analyticsEvents=[],t}),null),B=(n.handle("setting.getUnsavedDraftsPath",e=>x.setting.getUnsavedDraftPath()),e.prototype.getUnsavedDraftPath=function(){return N?Promise.resolve(N):(N=F(541).resolve(x.getPath("userData"),"draftsRecover"),F(728).ensureDir(N).then(()=>N))},function(e,t,n){t&&console.info(t.stack||t.message),e=e||{},console.error(e.stack||e.message),!x.isReady()||"ENOTFOUND"!=(t=e.errno||e.code)&&"ETIMEDOUT"!=t&&"ECONNRESET"!=t&&0!=(e.message||"").indexOf("net::ERR")&&(dialog=F(134).dialog,stack=null!=(ref=e.stack)?ref:e.name+": "+e.message,message="Uncaught Exception:\n"+stack,dialog.showMessageBox(null,{type:"error",buttons:["OK","Learn Data Recovery"],defaultId:0,cancelId:0,title:"A JavaScript error occurred in the main process",message:message}).then(({response:e})=>{1==e?(e=x.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",s.openExternal(`https://support.${e}/Version-Control/`)):process.exit(1)}))});function z(t,n){p.getAllWindows().forEach(function(e){e.isDestroyed()||e.webContents.isDestroyed()||e.webContents.isLoading()||e.webContents.send(t,n)})}function J(e,t){t=e.indexOf(t);-1{},()=>{}),console.error(e),I.captureException(e)}}catch(e){console.error(e),I.captureException(e)}try{o.userDictionaryPath?(e=await T.readFile(this.userDictionaryPath+"/user-dict.json","utf8"),o.userDict=JSON.parse(e)):console.error("no userDictionaryPath found")}catch(e){console.warn("user-dict.json not found")}function r(){o.userDictionaryPath&&F(833).writeFile(o.userDictionaryPath+"/user-dict.json",JSON.stringify(o.userDict),function(){}),x.sendEvent("user-dict-update",o.userDict)}n=S.ipcMain;n.on("user-dict-add",function(e,t){var{lang:t,word:n}=t;o.userDict[t]=o.userDict[t]||[],-1==o.userDict[t].indexOf(n)&&o.userDict[t].push(n),r()}),n.on("user-dict-remove",function(e,t){o.userDict[t.lang]=(o.userDict[t.lang]||[]).filter(function(e){return e!=t.word}),r()})},e.prototype.buildOption=async function(){var t={},e=(t.supportTextBundle=this.supportTextBundle,t.enableInlineMath=this.get("enable_inline_math")||!1,t.enableHighlight=this.get("enable_highlight")||!1,t.enableSubscript=this.get("enable_subscript")||!1,t.enableSuperscript=this.get("enable_superscript")||!1,t.enableDiagram=0!=this.get("enable_diagram"),t.copyMarkdownByDefault=this.get("copy_markdown_by_default")||!1,t.showLineNumbersForFence=this.get("show_line_numbers_for_fence")||!1,t.noPairingMatch=this.get("no_pairing_match")||!1,t.autoPairExtendSymbol=this.get("match_pari_markdown")||!1,t.expandSimpleBlock=this.get("auto_expand_block")||!1,t.headingStyle=this.get("heading_style")||0,t.ulStyle=this.get("ul_style")||0,t.olStyle=this.get("ol_style")||0,t.scrollWithCursor=!this.get("no_mid_caret"),t.autoNumberingForMath=this.get("auto_numbering_for_math"),t.allowPhysicsConflict=this.get("allowPhysicsConflict"),t.noDisplayLinesInMath=this.get("noDisplayLinesInMath"),t.useRelativePathForImg=this.get("use_relative_path_for_img")||!1,t.relativePathWithDot=this.get("relativePathWithDot")||!1,t.allowImageUpload=this.get("allow_image_upload")||!1,t.defaultImageStorage=this.get("image_save_location")||null,"custom"==t.defaultImageStorage&&(t.defaultImageStorage=this.get("custom_image_save_location")),t.applyImageMoveForWeb=this.get("apply_image_move_for_web")||!1,t.applyImageMoveForLocal=!this.get("no_image_move_for_local"),t.preferCRLF=this.get("line_ending_crlf")||!1,t.sidebarTab=this.get("sidebar_tab")||"",t.useTreeStyle=this.get("useTreeStyle")||!1,t.strictMarkdown=this.get("strict_mode")||!1,t.noLineWrapping=this.get("no_line_wrapping")||!1,t.prettyIndent=this.get("prettyIndent")||!1,t.convertSmartOnRender=this.get("SmartyPantsOnRendering"),t.smartDash=this.get("smartDash"),t.smartQuote=this.get("smartQuote"),t.twoHyphensToEm=this.get("twoHyphensToEm")||!1,t.remapUnicodePunctuation=this.get("remapPunctuation"),t.indentSize=this.get("indentSize")||2,t.codeIndentSize=this.get("codeIndentSize")||4,t.enableAutoSave=this.get("enableAutoSave")||!1,t.saveFileOnSwitch=this.get("save_file_on_switch")||!1,t.presetSpellCheck=this.get("preset_spell_check")||"auto",t.autoCorrectMisspell=!1,this.config||{});t.monocolorEmoji=e.monocolorEmoji,t.userQuotesArray=this.get("userQuotesArray"),t.passiveEvents=!0,t.canCollapseOutlinePanel=this.get("can_collapse_outline_panel"),t.preLinebreakOnExport=this.get("preLinebreakOnExport"),t.preLinebreakOnExport=1==t.preLinebreakOnExport||"true"==t.preLinebreakOnExport,t.indentFirstLine=this.get("indentFirstLine"),t.hideBrAndLineBreak=this.get("hideBrAndLineBreak"),t.isFocusMode=this.get("isFocusMode"),t.isTypeWriterMode=this.get("isTypeWriterMode"),t.ignoreLineBreak=this.get("ignoreLineBreak")||!1,t.sendAnonymousUsage=this.get("send_usage_info"),t.useMirrorInCN=this.get("useMirrorInCN"),void 0!==t.sendAnonymousUsage&&null!==t.sendAnonymousUsage||(t.sendAnonymousUsage=!0),t.uuid=this.get("uuid"),t.appVersion=x.getVersion(),t.instance=C,t.devVersion=global.devVersion,t.hasLicense=E.getHasLicense(),t.userLocale=this.getUserLocale(),t.appLocale=x.getLocale(),t.sidebarWidth=this.get("sidebar-width"),t.caseSensitive=this.get("caseSensitive"),t.wholeWord=this.get("wholeWord"),t.useRegexp=this.get("useRegexp"),t.fileSearchCaseSensitive=this.get("fileSearchCaseSensitive"),t.fileSearchWholeWord=this.get("fileSearchWholeWord"),t.fileSearchUseRegexp=this.get("fileSearchUseRegexp"),t.wordCountDelimiter=this.get("wordCountDelimiter")||0;try{t.userPath=x.getPath("home")||""}catch(e){t.userPath=(D?process.env.USERPROFILE:"")||""}if(t.mainPath=global.addonPath||"",t.userDataPath=x.getPath("userData")||"",!this.tempPath){var n=x.getPath("temp");0{t.keys[e]=(m.getKeyAccelerator(e)||"").toLowerCase()}),t.mathFormatOnCopy=this.get("mathFormatOnCopy")||"svg",t.imageUploader=this.get("image_uploader"),t.customImageUploader=this.get("custom_image_uploader"),t.picgoAppPath=this.get("picgo_app_path"),t.noWarnigUploadDisabled=this.get("noWarnigUploadDisabled")||!1,t.noWarnigForMoveFile=this.get("noWarnigForMoveFile")||!1,t.noWarnigForMoveFileToList=this.get("noWarnigForMoveFileToList")||!1,t.noWarnigForDeleteFile=this.get("noWarnigForDeleteFile")||!1,t.noWarnigForTypeWriterMode=this.get("noWarnigForTypeWriterMode")||!1,t.noHintForOpenLink=this.get("noHintForOpenLink")||!1,t.noHintForUnibody=this.get("noHintForUnibody")||!1,t.noWarnigForFocusMode=this.get("noWarnigForFocusMode")||!1,t.noWarningForExportOverwrite=this.get("noWarningForExportOverwrite")||!1,t.noWarningForUpdateImageReference=this.get("noWarningForUpdateImageReference")||!1,t.hasUpdates=this.hasUpdates||!1,t.pandocPath=this.get("pandocPath")||"",t.buildTime=1675928631787,t.debug=this.get("debug"),t._lastExport=A,t.lineWiseCopyCut=this.get("lineWiseCopyCut")||!1,t},e.prototype.extraOption=async function(){var t=await this.buildOption();return t.restoreWhenLaunch=this.get("restoreWhenLaunch")||0,t.pinFolder=this.get("pinFolder"),t.enable_inline_math=t.enableInlineMath,t.enable_highlight=t.enableHighlight,t.enable_subscript=t.enableSubscript,t.enable_superscript=t.enableSuperscript,t.enableDiagram=0!=this.get("enable_diagram"),t.enable_diagram=t.enableDiagram,t.copy_markdown_by_default=!!this.get("copy_markdown_by_default"),t.show_line_numbers_for_fence=!!this.get("show_line_numbers_for_fence"),t.no_pairing_match=!!this.get("no_pairing_match"),t.match_pari_markdown=!!this.get("match_pari_markdown"),t.auto_expand_block=!!this.get("auto_expand_block"),t.heading_style=this.get("heading_style")||0,t.ul_style=this.get("ul_style")||0,t.ol_style=this.get("ol_style")||0,t.no_mid_caret=this.get("no_mid_caret"),t.auto_numbering_for_math=this.get("auto_numbering_for_math"),t.use_relative_path_for_img=this.get("use_relative_path_for_img"),t.relativePathWithDot=this.get("relativePathWithDot"),t.allow_image_upload=this.get("allow_image_upload"),t.image_save_location=this.get("image_save_location"),t.custom_image_save_location=this.get("custom_image_save_location"),t.apply_image_move_for_web=this.get("apply_image_move_for_web"),t.no_image_move_for_local=this.get("no_image_move_for_local"),t.line_ending_crlf=this.get("line_ending_crlf"),t.strict_mode=this.get("strict_mode"),t.no_line_wrapping=this.get("no_line_wrapping"),t.prettyIndent=this.get("prettyIndent"),t.SmartyPantsOnRendering=this.get("SmartyPantsOnRendering"),t.remapPunctuation=this.get("remapPunctuation"),t.save_file_on_switch=this.get("save_file_on_switch")||!1,t.preset_spell_check=this.get("preset_spell_check")||"auto",t.can_collapse_outline_panel=this.get("can_collapse_outline_panel"),t.send_usage_info=!1!==this.get("send_usage_info"),t.currentThemeFolder=x.getPath("userData")+(D?"\\":"/")+"themes",t.enableAutoUpdate=!1!==this.get("enableAutoUpdate"),t.autoUpdateToDev=this.get("autoUpdateToDev"),t.userLanguage=this.get("userLanguage"),t.image_uploader=this.get("image_uploader"),t.custom_image_uploader=this.get("custom_image_uploader"),t.picgo_app_path=this.get("picgo_app_path"),t.allThemes=this.allThemes,t.useSeparateDarkTheme=this.get("useSeparateDarkTheme")||!1,t.theme=this.get("theme")||"github.css",t.darkTheme=this.get("darkTheme")||"night.css",t.customExport=this.get("customExport"),["general","pdf","html","html-plain","image"].forEach(e=>{t["export."+e]=this.get("export."+e)}),(t.customExport||R).forEach(e=>{t["export."+e.key]=this.get("export."+e.key)}),t},n.handle("setting.getExtraOption",async e=>JSON.stringify(await x.setting.extraOption())),n.handle("setting.doDownloadPicgo",e=>{x.setting.doDownloadPicgo()}),n.handle("setting.getKeyBinding",e=>x.setting.config.keyBinding||{}),e.prototype.doDownloadPicgo=function(){w.initDict().then(function(){var e="https://github.com/typora/PicGo-cli/releases/download/latest/%@.zip".replace("%@",D?"x64"==process.arch?"win64":"win32":"linux");console.log(e);let n=F(541).normalize(x.getPath("userData")+"/picgo"),o=F(541).normalize(n+"/_picgo.zip");var i=new f(e,o,{title:w.getPanelString("Download"),text:w.getPanelString("Downloading…"),processOnComplete:.9});i.onSuccess=(e,t)=>{F(834)(o,{dir:n},function(e){t.value=1,t.text=w.getPanelString("Finished"),t.detail="",setTimeout(()=>{i.setCompleted()},2e3),T.unlink(o,()=>{})}),t.detail=w.getPanelString("Unzipping…")},i.onError=e=>{S.dialog.showErrorBox(w.getPanelString("Download"),e.message)},i.download()})};var V=null;e.prototype.useDarkTheme=function(){return V=S.nativeTheme.shouldUseDarkColors&&this.get("useSeparateDarkTheme")},e.prototype.useDarkThemeBefore=function(){return V},e.prototype.curTheme=function(){return this.useDarkTheme()?this.get("darkTheme")||"night.css":this.get("theme")||"github.css"},e.prototype.setCurTheme=function(e,t){return a.getApplicationMenu().getItem("Themes").submenu.items.map(function(e){e.checked=e.label==t}),this.useDarkTheme()?this.put("darkTheme",e):this.put("theme",e)},o.exports=e},587:(o,e,t)=>{var u,p=t(134),h=p.app,n=p.ipcMain,g=p.BrowserWindow,m=(t(445),t(468)),f=(process.platform,"linux"==process.platform),w=t(541).join(__dirname,"../");n.handle("window.setTitle",(e,t,n)=>{e=g.fromWebContents(e.sender);t=t||("Typora"===(t=e.getTitle())?"Untitled"+(n?"• - Typora":" - Typora"):t.replace(/•? - Typora$/,n?"• - Typora":" - Typora")),e.setTitle(t)}),n.handle("window.focus",e=>{e=g.fromWebContents(e.sender);return e.focus(),e.webContents.focus(),!0}),n.handle("window.setInSourceMode",(e,t)=>{g.fromWebContents(e.sender).inSourceMode=!!t}),n.handle("window.minimize",e=>{g.fromWebContents(e.sender).minimize()}),n.handle("window.close",e=>{g.fromWebContents(e.sender).close()}),n.handle("window.restore",e=>{e=g.fromWebContents(e.sender);e.unmaximize(),e.setFullScreen(!1)}),n.handle("window.maximize",e=>{g.fromWebContents(e.sender).maximize()}),n.handle("window.fullscreen",e=>{e=g.fromWebContents(e.sender);return e.setFullScreen(!0),e.isFullScreen()}),n.handle("window.setMenuBarVisibility",(e,t)=>{g.fromWebContents(e.sender).setMenuBarVisibility(t)}),n.handle("window.pin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!0)}),n.handle("window.unpin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!1)}),n.handle("window.updateMenuForIsAlwaysOnTop",e=>{e={"View→Always on Top":{state:g.fromWebContents(e.sender).isAlwaysOnTop()}};h.updateMenu(e)}),n.handle("window.toggleDevTools",e=>{e=g.fromWebContents(e.sender);e.webContents.isDevToolsOpened()?e.webContents.closeDevTools():e.webContents.openDevTools()}),n.handle("window.inspectElement",(e,t,n)=>{g.fromWebContents(e.sender).inspectElement(t,n)}),n.handle("window.checkAsFocus",e=>{e=g.fromWebContents(e.sender);e&&e.isFocused&&(h.currentFocusWindowId=e.id)}),n.handle("controller.switchFolder",(e,t)=>{e=g.fromWebContents(e.sender);h.switchFolder(t,e)}),n.handle("webContents.copy",e=>{g.fromWebContents(e.sender).webContents.copy()}),n.handle("webContents.cut",e=>{g.fromWebContents(e.sender).webContents.cut()}),n.handle("webContents.paste",e=>{g.fromWebContents(e.sender).webContents.paste()}),n.handle("webContents.selectAll",e=>{g.fromWebContents(e.sender).webContents.selectAll()}),n.handle("webContents.undo",(e,t)=>{g.fromWebContents(e.sender).webContents.undo()}),n.handle("webContents.redo",(e,t)=>{g.fromWebContents(e.sender).webContents.redo()}),n.handle("webContents.clearCache",(e,t)=>{var n=g.fromWebContents(e.sender);return new Promise(e=>{n.webContents.session.clearCache(e)})}),n.handle("webContents.action",(e,t)=>{g.fromWebContents(e.sender).webContents[t]()}),e.makeWindow=async(d,e)=>{var t=h.getDocumentController();e=e||{};var n,o,i=g.getFocusedWindow(),r=h.setting.config||{},a=t.lastClosedBounds,l=(i=i&&!t.getDocumentFromWindowId(i.id)?null:i)&&i.getBounds(),s=0,l=(a||(l?(s=i.isMaximized()||i.isFullScreen()?0:30,a={fullscreen:i.isFullScreen(),maximized:i.isMaximized()},s&&(a.x=l.x+s,a.y=l.y+s,a.width=l.width,a.height=l.height)):a=u?(s=u.fullscreen||u.maximize?0:30,{x:u.x+s,y:u.y-s,width:u.width,height:u.height,fullscreen:u.fullscreen,maximized:u.maximized}):{}),!a.fullscreen&&a.maximized),e={x:a.x,y:a.y,width:a.width||800,height:a.height||700,minWidth:400,minHeight:400,frame:!h.setting.get("framelessWindow"),disableAutoHideCursor:!1,backgroundColor:h.setting.get("backgroundColor"),webPreferences:{webSecurity:!1,allowRunningInsecureContent:!1,plugins:!1,nodeIntegration:!0,enableRemoteModule:!1,webviewTag:!0,nodeIntegrationInWorker:!0,devTools:!0,images:!0,directWrite:r.directWrite,defaultFontFamily:r.defaultFontFamily,allowDisplayingInsecureContent:!1,backgroundThrottling:!1,spellcheck:!1,contextIsolation:!1,additionalArguments:["--tyopt="+JSON.stringify({isMaximized:l,isFullScreen:a.fullscreen,...await h.setting.buildOption(),...e})]},autoHideMenuBar:a.fullscreen||r.autoHideMenuBar,show:d,fullscreen:a.fullscreen,alwaysOnTop:i&&i.isAlwaysOnTop(),fullscreenable:!0},c=(f&&(e.icon=w+"/assets/icon/icon_256x256.png"),r=e,i=0s.y+s.height&&(r.y=s.y+s.height-r.height),r.xs.x+s.width&&(r.x=i?s.x:s.x+s.width-r.width)),u=e,l&&(e.show=!1),new g(e));return t.lastClosedBounds=null,l&&(c.maximize(),d&&c.show()),a.fullscreen&&(c.autoHideMenuBar=!0,c.setMenuBarVisibility(!1)),c.loadURL(entry||"".substring(1)),n=c,o=p.shell,n.webContents.on("will-navigate",function(e,t){e.preventDefault(),o.openExternal(t)}),n.webContents.setWindowOpenHandler(e=>(/^https?:/.exec(e.url)&&o.openExternal(e.url),{action:"deny"})),n.webContents.on("crashed",function(e,t){console.error("render process is killed? "+t),m.captureMessage("render process crashed, killed="+t),h.setting.addAnalyticsEvent("crashed")}),n.webContents.on("unresponsive",function(){m.captureMessage("unresponsive",{extra:{winId:n.id}}),h.setting.addAnalyticsEvent("unresponsive")}),n.webContents.setMaxListeners(15),n.webContents.on("dom-ready",function(){n.isMaximized()&&n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");'),b("dom-ready",n)}),n.on("maximize",()=>{n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");')}),n.on("enter-full-screen",function(){n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");document.body.classList.add("typora-fullscreen");if(document.body.classList.contains("native-window")) {$("#ty-top-placeholder").show();};1;')}),n.on("unmaximize",function(){n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");')}),n.on("session-end",function(){console.log("[win] session-end"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),n.on("leave-full-screen",function(){n.autoHideMenuBar=!!h.setting.config.autoHideMenuBar,n.setMenuBarVisibility(!h.setting.config.autoHideMenuBar),n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");document.body.classList.remove("typora-fullscreen");$("#ty-top-placeholder").hide();1;'),u&&(u.fullscreen=!1)}),n.on("focus",function(){n.webContents.incrementCapturerCount();var e=t.getDocumentFromWindowId(n.id);e&&(e.setActiveWindow(n),h.focusedWindow=n)}),n.on("blur",()=>{console.log("[win] blur"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),b("make-window"),c};const i=t(93);var r=new i;const b=function(e,t){r.emit(e,t)};e.on=function(e,t){r.on(e,t)},e.showPanelWindow=function({path:e,...t}){var n=new g({modal:!0,show:!1,center:!0,resizable:!1,webPreferences:{devTools:!global.releaseMode,defaultFontSize:14,nodeIntegration:!0,contextIsolation:!1,enableRemoteModule:!1},...t});return n.loadURL("file://"+w+"/"+e),n.once("ready-to-show",function(){n.show()}),n.removeMenu(),f&&(n.icon=w+"/assets/icon/icon_256x256.png"),n.webContents.setWindowOpenHandler(e=>(p.shell.openExternal(e.url),{action:"deny"})),n}},90:(e,o,s)=>{e=s.nmd(e);var t,i=s(541),n=s(640),r=(t=i.join(__dirname,"../"),i.join(t,"node_modules.asar")),a=(n.globalPaths.push(r),n.prototype.require);n.prototype.require=function(e){return-1==this.paths.indexOf(__dirname)&&(this.paths.push(__dirname),this.paths.push(r)),/(\.node$)|(\/build\/Release)/.exec(e)&&"."==e[0]&&(e=i.resolve(i.dirname(this.id),e).replace(/\bnode_modules\.asar\b/,"node_modules")),a.call(this,e)};for(let e=0;e{c.exit()},1e3),s(405);var n=s(134),c=n.app,l=n.protocol,m=n.powerMonitor,d=n.BrowserWindow,u=s(728),f="win32"==process.platform,w=(process.platform,process.platform,s(557),s(344)),b=s(883),e=s(932),y=s(445),p=s(351),n=n.ipcMain;s(468);if(!c.requestSingleInstanceLock())return console.record("secondary instance would exit"),void c.quit();console.record("launch with argv ["+process.argv.join(", ")+"]"),c.on("second-instance",function(e,t,n){console.record("got argv ["+t.join(", ")+"] from secondary instance"),t=Array.from(t),d.getAllWindows().length&&((n=F(t,n))?c.openFileOrFolder(n,{forceCreateWindow:!n}):T(t||[]))});var v=1,k=2,C=3;function F(e,t){null==t&&(t=process.cwd());for(var n,o=e.length-1;0<=o;o--)if("-"!=e[o][0]&&!/\.asar$/.exec(e[o]||"")){n=e[o];break}if((n=0!=o&&n!=t?n:void 0)&&/^file:\/\//i.exec(n)){n=n.replace(/^file:\/\//i,"");try{n=decodeURI(n)}catch(e){}}return n?s(541).resolve(t,n):void 0}function S(e){if(!e)return e;var t=e.length;return 50((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFile(t||null,n).then(n=>{if(n)return new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e({winId:n.activeWindow.id})}):e({winId:n.activeWindow.id})})}))),n.handle("app.openFileOrFolder",(e,t,n)=>((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFileOrFolder(t||null,n))),n.handle("app.openOrSwitch",async(e,t,n)=>{var o,e=d.fromWebContents(e.sender),i=c.documentController.getDocument(t),r=c.documentController.getDocumentFromWindowId(e.id);if(i)return(o=i.activeWindow||i.windows.keys().next().value)&&o.focus(),!1;if(n)return c.openFileOrFolder(t,{curWindow:!0}),!1;if(await O(t))c.switchFolder(t,e);else if(!i)return r.rename(t),!0;return!1}),n.handle("app.openFolder",(e,t,n)=>{c.openFolder(t||null,n?d.fromWebContents(e.sender):void 0)}),n.handle("app.onCloseWin",(e,t)=>{e=d.fromWebContents(e.sender);c.onCloseWin(e.id,t)}),n.handle("app.sendEvent",(e,t,n)=>{c.sendEvent(t,n)}),n.handle("executeJavaScript",(e,t,n)=>{d.fromId(t).webContents.executeJavaScript(n)}),c.reopenFolder=function(){var t=new Set,n=!1;return g.forEach(function(e){e.mountFolder&&!t.has(e.mountFolder)&&(t.add(e.mountFolder),c.openFile(null,{forceCreateWindow:!0,mountFolder:e.mountFolder}),n=!0)}),n},c.reopenClosed=function(o){var i=!1;return g.length&&g.forEach(function(e,t){var n=c.getDocumentController().getDocument(e.path);n?n.activeWindow&&n.activeWindow.show():(c.openFile(e.path,{forceCreateWindow:!!t,mountFolder:e.mountFolder,silent:o,backupState:e,fromReopen:!0}),i=!0)}),i},function(e){var t,n=c.setting.get("restoreWhenLaunch")||0,o=!0,i=e||process.argv||[];-1{/^--/.exec(e)&&("--on-dev"==e?process.traceDeprecation=!0:-1===["--new","--reopen-file"].indexOf(e)&&c.commandLine.appendSwitch.apply(null,[e]))}),scheme||"".substring(3));c.on("ready",async function(){var e,t;await c.setting.initSetting(),c.expired||(p.lastClosedBounds=c.setting.get("lastClosedBounds"),console.record("------------------start------------------"),console.log("typora version: "+c.getVersion()),console.log(""+s.c[s.s].filename),M(P),c.setAppUserModelId("abnerworks.Typora"),(e=F(process.argv))&&"--on-dev"!==process.argv[process.argv.length-1]?c.openFileOrFolder(e):c.recoverFromBackup(),w.loadDict().then(()=>{w.bindMainMenu()}),f&&(t=s(558),c.updater=t,setTimeout(function(){t.initUpdater().then(function(){!1!==c.setting.get("enableAutoUpdate")&&c.updater.checkForUpdates(!1)})},3e3)),b.bindJumplist(),setTimeout(function(){try{E()}catch(e){console.warn(e.stack)}},3e4),m.on("suspend",()=>{console.record("[Power] suspend"),c.execInAll('window.onPowerChange && window.onPowerChange("suspend")')}),m.on("resume",()=>{console.record("[Power] resume"),c.execInAll('window.onPowerChange && window.onPowerChange("resume")')}),m.on("lock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("lock-screen")')}),m.on("unlock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("unlock-screen")')}))});var I,W={},E=async function(){var r,a,l,s,n=await c.setting.getUnsavedDraftPath(),e=await u.readdir(n);e.length<200||(console.record("cleanUpExpiredDrafts"),400{var o=[],i=async function(){Math.min(l+50,a.length);if(l+1>=a.length)n(o);else{for(;l++;){if(!a[l])return void n(o);try{var e=r+"/"+a[l],t=await u.stat(e);864e6{try{return{name:e,time:W[e]||(await u.stat(n+"/"+e)).mtime.getTime()}}catch(e){}return{name:e,time:0}})),W=null,e.sort(function(e,t){return t.time-e.time}).forEach(function(e,t){150{D=!1}),c.on("quit",function(){console.log("-----------------quit------------------"),c.setting.closeLogging()}),c.on("will-quit",function(){console.log("------------------will-quit------------------"),h&&clearTimeout(h),I&&clearTimeout(I),f&&c.updater&&c.updater.installIfNeeded(),c.setting.syncAll();try{u.rmSync(c.getPath("userData")+"/runtime-storage",{recursive:!0,force:!0})}catch(e){console.error(e)}try{var e=c.getPath("userData")+"/typora.log",t=c.getPath("userData")+"/typora-old.log",n=u.statSync(e);n&&5e5p.getDocumentFromWindowId(n.id)):l()}).then(function(e){return e})}return l()},c.sendEvent=function(t,n){d.getAllWindows().forEach(function(e){e.webContents.send(t,n)}),c.onMessage(t,n)},c.execInAll=function(t){d.getAllWindows().forEach(function(e){e.webContents.executeJavaScript(t)})},c.onMessage=function(e,t){"didRename"==e?c.setting.renameRecentDocuments(t.oldPath,t.newPath):"updateQuickOpenCache"==e&&t.toDel&&c.setting.renameRecentDocuments(t.toDel,null)},c.refreshMenu=function(){w.refreshMenu()},{});n.handle("app.download",(e,t,n,o)=>{var i,r,a=s(541),l=d.fromWebContents(e.sender),e=s(554),o=o||(e=>{var t=s(426),n=s(541),t=t.parse(e),e=n.basename(t.pathname);try{var o=decodeURIComponent(e);if(o!=e)return n.basename(o)}catch(e){}return e})(t),a=a.join(n,o);return u.existsSync(a)&&(i=a,r=s(541),a=i.replace(/(\.[^.\/\\]+?$)/,"")+"-"+ +new Date+r.extname(i)),_[l.id+t]||(_[l.id+t]=e.download(l,t,{showBadge:!1,directory:n,filename:o})),setTimeout(()=>{delete _[l.id+t]},10),Promise.race([_[l.id+t].then(e=>({path:e.getSavePath(),state:e.getState(),type:e.getMimeType()}),()=>({path:t,state:"error"})),new Promise(e=>{setTimeout(()=>{e({path:t,state:"timeout"})},3e4)})])});var M=function(e){l.registerFileProtocol(e,function(e,t){e.url?t({path:c.getRealPath(e.url)}):t({error:-324})}),l.registerBufferProtocol("typora-bg",function(e,t){var n=c.setting.get("backgroundColor");t(n?{mimeType:"text/css",data:Buffer.from(`body {background:${n};`)}:{mimeType:"text/css",data:Buffer.from("")})})};c.getRealPath=function(e){try{e=decodeURI(e)}catch(e){}e=e.substr(13);return/^userData/.exec(e)&&(e=e.replace(/^userData/,c.getPath("userData").replace(/\\/g,"\\\\"))),/current-theme\.css$/.exec(e)&&(e=e.replace(/current-theme\.css$/,c.setting.curTheme())),/^typemark/i.exec(e)&&(e=e.replace(/^typemark/,t)),e=(e=/preview\.html/.exec(e)?e.replace(/\.html[?#].*$/,".html"):e).replace(/[?#][^\\\/]*$/,"")},c.filesOp=e,P&&l.registerSchemesAsPrivileged([{scheme:P,privileges:{standard:!0,secure:!0,supportFetchAPI:!0,bypassCSP:!0,corsEnabled:!0,stream:!0}}])},344:(t,n,h)=>{function r(e,t){return function(){k(e,t)}}var i,a=h(134),l=a.app,g=a.dialog,s=a.Menu,c=a.MenuItem,m=a.BrowserWindow,e=a.ipcMain,f=h(728),d="win32"==process.platform,w="darwin"==process.platform,b="linux"==process.platform,y=h(445),u=h(541).join(__dirname,"../"),v=(e.on("execForAll",function(e,t){v(t)}),e.on("forceRefreshMenu",function(e,t){l.forceRefreshMenu()}),e.on("syncToPreference",function(e,t){a.webContents.getAllWebContents().forEach(function(e){e.send("syncToPreference",t)})}),n.loadDict=()=>{var o,e;return i?Promise.resolve(i):(o=l.setting.getUserLocale(),e=h(541).join(u,l.setting.getLocaleFolder("Menu")),new Promise(n=>{f.readFile(e,"utf8",(e,t)=>{i=t?JSON.parse(t):{},n(i),e&&console.warn("cannot load dict as ["+o+"] "+e.stack)})}))},function(e){var t=e=e.toString();/^\s*function\s*\(/.exec(e)&&(t="window.File && ("+e+")();"),l.execInAll(t),console.log(t)}),k=function(e,t){var n=m.getFocusedWindow();n&&(t?n.webContents.executeJavaScript("window.File && !File.blockUI && ("+e.toString()+")();0;"):n.webContents.executeJavaScript("!File.blockUI && window.ClientCommand['"+e+"']();0;"),n.webContents.executeJavaScript("window.Reporter && window.Reporter.fullValidate();File.editor && File.editor.contextMenu && File.editor.contextMenu.hide();0;"))};function C(e){var t=/&[a-z]/i.exec(e),n=/(\.\.\.)|(…)/.exec(e),o=(e=e.replace(/(\.\.\.)|(…)|&/g,""),(i||{})[e]||e);return t?function(e,t){e=S[e];if(!e)return t;{var n,o;(d||b)&&(-1==(n=t.indexOf(e))?n=t.indexOf(e.toLowerCase()):-1<(o=t.indexOf(e.toLowerCase()))&&(n=Math.min(n,o)),-1{setTimeout(o,0)}))),e}function x(e,t){return p(e={label:e,accelerator:t}),e.accelerator}function D(e){function n(e,t){e=e.label;f.existsSync(e)?l.openFileOrFolder(e,{curWindow:t}):(g.showMessageBox({title:C("Open Failed"),message:C("File or folder does not exist."),buttons:["Close"],cancelId:0,defaultId:0}),l.setting.removeRecentDocument(e))}try{var o=e.getItem("File").submenu.getItem("Open Recent").submenu,t=l.setting.getRecentDocuments(),i=l.setting.getRecentFolders();t.sort(function(e,t){return t.date-e.date}),i.sort(function(e,t){return t.date-e.date}),o.clear(),o.append(new c({label:C("Reopen Closed File"),accelerator:"CmdOrCtrl+Shift+T",click:function(){l.reopenClosed()}})),o.append(new c({type:"separator"})),t.length&&(t.forEach(function(e,t){10{e.type&&(hasCustom=!0,o.push({label:e.name,click:t(e)}))}),o.push({type:"separator"}),o.push({label:"Export with Previous",accelerator:"Shift+Ctrl+E",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast();")},enabled:!!l.setting.lastExport}),o.push({label:"Export and Overwrite with Previous",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast(true)")},enabled:!!l.setting.lastExport}),o.push({type:"separator"}),o.push({label:"Export Setting…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('export-setting-group');")},enabled:!0}),e&&(o.forEach(p),n=P("File→Export").submenu,o[o.length-1].enabled=(I("Export and Overwrite with Previous",n)||{}).enabled,n.clear(),o.forEach(e=>{n.append(new c(e))}),w&&s.setApplicationMenu(s.getApplicationMenu())),o}function P(e){if(!e)return null;var t,n=(W=W||{})[e];return n||(e.split("→").forEach(function(e){if(n=I(e,n),!(W[t=t?t+"→"+e:e]=n))return null}),W=null,n)}function I(e,t){var n,o=t?t.submenu:s.getApplicationMenu();return o?(n=o.getItem(e),t||n||"File"!=e?n:o.getItem("Typora")||o.getItem("Electron")):null}var W,o=null;l.forceRefreshMenu=function(){b&&(o&&clearTimeout(o),o=setTimeout(function(){s.setApplicationMenu(s.getApplicationMenu()),o=null},100))};l.updateMenu=function(e){W={};for(var t in e){var n,o,i=P(t),r=e[t];i&&(n=null,void 0!==r.accelerator&&(r.accelerator,o=x(i.label,r.accelerator),i=n=o!=i.accelerator?new c(p({label:i.label,type:i.type,enabled:i.enabled,checked:i.enabled,click:i.click,accelerator:o})):n),"Paragraph→Table"!=t?(void 0!==r.state&&(i.checked=r.state),void 0!==r.enabled&&(i.enabled=r.enabled,"Paragraph"!=t&&"Format"!=t&&"Format→Image→Zoom Image"!=t||i.submenu.items.forEach(function(e){e.enabled=r.enabled})),void 0!==r.hidden&&(i.visible=!r.hidden),!n||-1<(t=(o=P(t.replace(/→[^→]+$/,"")).submenu.items).findIndex(e=>e.label==n.label))&&(o.splice(t,1,n),console.log("newItem.accelerator "+n.accelerator))):(function(e,n){n.enabled||n.state?(e.enabled=!0,e.submenu.items.forEach(function(e,t){e.enabled=0==t?!n.state:n.state})):e.enabled=!1}(i,r),0))}W=null,l.forceRefreshMenu()},e.on("menu.updateMenu",function(e,t){l.updateMenu(JSON.parse(t))}),e.handle("menu.updateCustomZoom",e=>{l.updateMenu({"View→Actual Size":{state:!l.setting.get("customZoom")}})}),e.handle("menu.refreshThemeMenu",function(e){l.setting.refreshThemeMenu()}),e.handle("menu.reloadExportMenu",function(e){T(!0)}),e.handle("menu.popup",function(e,t){s.getApplicationMenu().popup(t)}),n.bindMainMenu=function(){function e(e,t){e=(/\((.+)\)/.exec(e.label)||[])[1]||e.label;e==C("Auto")&&(e=""),k("function(){File.reloadWithEncoding('"+e+"')}",!0)}var t=l.setting.get("SmartyPantsOnRendering")||!1,n=l.setting.get("smartQuote")||!1,o=l.setting.get("smartDash")||!1,t=[p({label:"&File",submenu:[{label:"New",accelerator:"CmdOrCtrl+N",click:r("newFile")},{label:"New Window",accelerator:"CmdOrCtrl+Shift+N",click:r("newWindow")},{type:"separator"},{label:"Open…",accelerator:"CmdOrCtrl+O",click:r("open")},{label:"Open Folder…",click:r("openFolder")},{type:"separator"},{label:"Open Quickly…",accelerator:"CmdOrCtrl+P",click:r("quickOpen")},{label:"Open Recent",submenu:[]},{label:"Reopen with Encoding",submenu:[{label:"Auto",click:e},{type:"separator"},{label:"UTF-8",click:e},{label:"UTF-16 LE",click:e},{label:"UTF-16 BE",click:e},{type:"separator"},{label:"Western (windows-1252)",click:e},{label:"Cyrillic (windows-1251)",click:e},{label:"Cyrillic (ISO-8859-2)",click:e},{label:"Cyrillic (IBM866)",click:e},{label:"Cyrillic (IBM855)",click:e},{label:"Cyrillic (KOI8-R)",click:e},{label:"Cyrillic (MacCyrillic)",click:e},{label:"Central European (windows-1250)",click:e},{label:"Central European (ISO-8859-2)",click:e},{label:"Geek (windows-1253)",click:e},{label:"Geek (ISO-8859-7)",click:e},{label:"Hebrew (windows-1255)",click:e},{label:"Hebrew (ISO-8859-8)",click:e},{label:"Chinese Simplified (GB2312)",click:e},{label:"Chinese Simplified (GB18030)",click:e},{label:"Chinese Traditional (Big5)",click:e},{label:"Japanese (SHIFT_JIS)",click:e},{label:"Japanese (EUC-JP)",click:e},{label:"Korean (EUC-KR)",click:e},{label:"Thai (TIS-620)",click:e}]},{type:"separator"},{label:"Save",accelerator:"CmdOrCtrl+S",click:r("save")},{label:"Save As…",accelerator:"CmdOrCtrl+Shift+S",click:r("saveAs")},{label:"Move To…",click:r("moveTo")},{label:"Save All…",click:r("saveAll")},{type:"separator"},d?{label:"Properties…",click:function(e,t){t&&t.webContents.executeJavaScript("File.winShell().openProperties(File.bundle.filePath);")}}:null,{label:"Open File Location…",click:r("openFileLocation")},{label:"Reveal in Sidebar",click:r(function(){window.File.editor.library.revealInSidebar()},!0)},{label:"Delete…",click:function(e,t){t&&t.webContents.executeJavaScript("File.trashSelf();")}},{type:"separator"},{label:"Import…",click:r("import")},{label:"Export",submenu:T()},{label:"Print…",accelerator:"Shift+Alt+P",click:r("print")},{type:"separator"},{label:"Preferences…",accelerator:"CmdOrCtrl+,",click:r("togglePreferencePanel")},{type:"separator"},{label:"Close",accelerator:"CmdOrCtrl+W",click:r("close")}]}),p({label:"&Edit",id:"edit",submenu:[{label:"Undo",id:"undo",accelerator:"CmdOrCtrl+Z",click:r("undo")},{label:"Redo",id:"redo",accelerator:"CmdOrCtrl+Y",click:r("redo")},{type:"separator"},{label:"Cut",accelerator:"CmdOrCtrl+X",role:"cut"},{label:"Copy",accelerator:"CmdOrCtrl+C",role:"copy"},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Paste",accelerator:"CmdOrCtrl+V",role:"paste"},{type:"separator"},{label:"Copy as Plain Text",click:r("copyAsPlainText")},{label:"Copy as Markdown",accelerator:"CmdOrCtrl+Shift+C",click:r("copyAsMarkdown")},{label:"Copy as HTML Code",click:r("copyAsHTMLSource")},{label:"Copy without Theme Styling",click:r("copyAsSemanticHTML")},{type:"separator"},{label:"Paste as Plain Text",accelerator:"CmdOrCtrl+Shift+v",click:r("pasteAsPlain")},{type:"separator"},{label:"Selection",submenu:[{label:"Select All",accelerator:"CmdOrCtrl+A",click:r("selectAll")},{label:"Select Paragraph / Block",accelerator:"CmdOrCtrl+Alt+P",click:r(function(){File.editor.selection.selectBlock()},!0)},{label:"Select Line / Sentence",accelerator:"CmdOrCtrl+L",click:r(function(){File.editor.selection.selectLine()},!0)},{label:"Select Styled Scope",accelerator:"CmdOrCtrl+E",click:r(function(){File.editor.selection.selectPhrase()},!0)},{label:"Select Word",accelerator:"CmdOrCtrl+D",click:r(function(){File.editor.selection.selectWord()},!0)},{type:"separator"},{label:"Jump to Top",accelerator:"Ctrl+Home",click:r(function(){File.editor.selection.jumpTop()},!0)},{label:"Jump to Selection",accelerator:"CmdOrCtrl+j",click:r(function(){File.editor.selection.jumpSelection()},!0)},{label:"Jump to Bottom",accelerator:"Ctrl+End",click:r(function(){File.editor.selection.jumpBottom()},!0)},{label:"Extend Selection to Top",accelerator:"Ctrl+Shift+Home",visible:!1,click:r(function(){File.editor.selection.jumpTop(!0)},!0)},{label:"Extend Selection to Bottom",accelerator:"Ctrl+Shift+End",visible:!1,click:r(function(){File.editor.selection.jumpBottom(!0)},!0)},{label:"Extend Selection to Line Start",accelerator:"Shift+Home",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!1)},!0)},{label:"Extend Selection to Line End",accelerator:"Shift+End",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!0)},!0)}]},{type:"separator"},{label:"Delete",click:r(function(){File.delete()},!0)},{label:"Delete Range",submenu:[{label:"Delete Paragraph / Block",accelerator:"Shift+CmdOrCtrl+Alt+P",click:r("deleteBlock")},{label:"Delete Line / Sentence",accelerator:"Shift+CmdOrCtrl+Alt+L",click:r("deleteLine")},{label:"Delete Styled Scope",accelerator:"Shift+CmdOrCtrl+Alt+E",click:r("deleteScope")},{label:"Delete Word",accelerator:"Shift+Ctrl+D",click:r("deleteWord")}]},{type:"separator"},{label:"Math Tools",submenu:[{label:"Refresh All Math Expressions",click:r(function(){File.editor.mathBlock.forceRefresh()},!0)}]},{type:"separator"},{label:"Smart Punctuation",submenu:[{label:"Convert on Input",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+!e+")"))},checked:!t},{label:"Convert on Rendering",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+e+")"))},checked:t},{type:"separator"},{label:"Smart Quotes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartQuote("+e+")"))},checked:n},{label:"Smart Dashes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartDash("+e+")"))},checked:o},{type:"separator"},{label:"Remap Unicode Punctuation on Parse",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setRemapPunctuation("+e+")"))},checked:l.setting.get("remapPunctuation")||!t&&(n||o),enabled:!(!t&&(n||o))},{type:"separator"},{label:"More Options…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('smart-punctuation-group');")}}]},{label:"Line Endings",submenu:[{label:"Windows Line Endings (CRLF)",type:"checkbox",click:r(function(){File.setLineEnding(!0,!0)},!0)},{label:"Unix Line Endings (LF)",type:"checkbox",click:r(function(){File.setLineEnding(!1,!0)},!0)},{type:"separator"},{label:"Insert Final New Line On Save",type:"checkbox",click:function(e,t){t&&t.webContents.executeJavaScript("File.setFinalNewline("+e.checked+")")}}]},{label:"Whitespace and Line Breaks",submenu:[{label:"Indent first line of paragraphs",type:"checkbox",click:r(function(){File.setIndentFirstLine(!File.option.indentFirstLine,!0,!0)},!0)},{type:"separator"},{label:"Visible
",type:"checkbox",checked:!0,click:r(function(){File.setHideBrAndLineBreak(!File.option.hideBrAndLineBreak,!0,!0)},!0)},{label:"Preserve single line break",type:"checkbox",checked:!0,click:r(function(){File.setIgnoreLineBreak(!File.option.ignoreLineBreak,!0,!0)},!0)},{type:"separator"},{label:"Learn More…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/Line-Break/`)}}]},{label:"Spell Check…",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.spellChecker && File.editor.spellChecker.show();")}},{type:"separator"},{label:"Find and Replace",submenu:[{label:"Find…",accelerator:"CmdOrCtrl+f",click:r(function(){File.megaMenu.isPreferencePanelShown()?File.megaMenu.searchOnPreferencePanel():File.editor.searchPanel.showPanel()},!0)},{label:"Find Next",accelerator:"F3",click:r(function(){File.editor.searchPanel.highlightNext()},!0)},{label:"Find Previous",accelerator:"Shift+F3",click:r(function(){File.editor.searchPanel.highlightNext(!0)},!0)},{type:"separator"},{label:"Replace",accelerator:"Ctrl+h",click:r(function(){File.editor.searchPanel.showPanel(!0)},!0)}]}]}),p({label:"&Paragraph",submenu:[{label:"Heading 1",type:"checkbox",accelerator:"Ctrl+1",click:r(function(){File.editor.stylize.changeBlock("header1",void 0,!0)},!0)},{label:"Heading 2",type:"checkbox",accelerator:"Ctrl+2",click:r(function(){File.editor.stylize.changeBlock("header2",void 0,!0)},!0)},{label:"Heading 3",type:"checkbox",accelerator:"Ctrl+3",click:r(function(){File.editor.stylize.changeBlock("header3",void 0,!0)},!0)},{label:"Heading 4",type:"checkbox",accelerator:"Ctrl+4",click:r(function(){File.editor.stylize.changeBlock("header4",void 0,!0)},!0)},{label:"Heading 5",type:"checkbox",accelerator:"Ctrl+5",click:r(function(){File.editor.stylize.changeBlock("header5",void 0,!0)},!0)},{label:"Heading 6",type:"checkbox",accelerator:"Ctrl+6",click:r(function(){File.editor.stylize.changeBlock("header6",void 0,!0)},!0)},{type:"separator"},{label:"Paragraph",type:"checkbox",accelerator:"Ctrl+0",click:r(function(){File.editor.stylize.changeBlock("paragraph")},!0)},{type:"separator"},{label:"Increase Heading Level",accelerator:"Ctrl+=",click:r(function(){File.editor.stylize.increaseHeaderLevel()},!0)},{label:"Decrease Heading Level",accelerator:"Ctrl+-",click:r(function(){File.editor.stylize.decreaseHeaderLevel()},!0)},{type:"separator"},{label:"Table",submenu:[{label:"Insert Table",accelerator:"Ctrl+T",click:r(function(){File.editor.tableEdit.insertTable()},!0)},{type:"separator"},{label:"Add Row Above",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!0)},!0)},{label:"Add Row Below",accelerator:"Ctrl+Return",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!1)},!0)},{type:"separator"},{label:"Add Column Before",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{label:"Add Column After",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{type:"separator"},{label:"Move Row Up",enabled:!1,accelerator:"Alt+Up",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!0)},!0)},{label:"Move Row Down",enabled:!1,accelerator:"Alt+Down",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!1)},!0)},{label:"Move Column Left",enabled:!1,accelerator:"Alt+Left",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!0)},!0)},{label:"Move Column Right",enabled:!1,accelerator:"Alt+Right",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!1)},!0)},{type:"separator"},{label:"Delete Row",enabled:!1,accelerator:"Shift+Ctrl+Backspace",click:r(function(){File.editor.tableEdit.deleteRow()},!0)},{label:"Delete Column",enabled:!1,click:r(function(){File.editor.tableEdit.deleteCol()},!0)},{type:"separator"},{label:"Copy Table",enabled:!1,click:r(function(){File.editor.tableEdit.copyTable()},!0)},{label:"Prettify Source Code",enabled:!1,click:r(function(){File.editor.tableEdit.reformatTable()},!0)},{type:"separator"},{label:"Delete Table",enabled:!1,click:r(function(){File.editor.tableEdit.deleteTable()},!0)}]},{label:"Code Fences",type:"checkbox",accelerator:"Ctrl+Shift+K",click:r(function(){File.editor.stylize.toggleFences()},!0)},{label:"Math Block",type:"checkbox",accelerator:"Ctrl+Shift+M",click:r(function(){File.editor.stylize.toggleMathBlock()},!0)},{type:"separator"},{label:"Quote",type:"checkbox",accelerator:"Ctrl+Shift+Q",click:r(function(){File.editor.stylize.toggleIndent("blockquote")},!0)},{type:"separator"},{label:"Ordered List",type:"checkbox",accelerator:"Ctrl+Shift+[",click:r(function(){File.editor.stylize.toggleIndent("ol")},!0)},{label:"Unordered List",type:"checkbox",accelerator:"Ctrl+Shift+]",click:r(function(){File.editor.stylize.toggleIndent("ul")},!0)},{label:"Task List",type:"checkbox",accelerator:"Ctrl+Shift+X",click:r(function(){File.editor.stylize.toggleIndent("tasklist")},!0)},{label:"Task Status",submenu:[{label:"Toggle Task Status",click:r(function(){File.editor.stylize.toggleTaskStatus()},!0)},{type:"separator"},{label:"Mark as Complete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!0)},!0)},{label:"Mark as Incomplete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!1)},!0)}]},{label:"List Indentation",submenu:[{label:"Indent",accelerator:"CmdOrCtrl+]",click:r(function(){File.editor.UserOp.moreIndent(File.editor)},!0)},{label:"Outdent",accelerator:"CmdOrCtrl+[",click:r(function(){File.editor.UserOp.lessIndent(File.editor)},!0)}]},{type:"separator"},{label:"Insert Paragraph Before",click:r(function(){File.editor.UserOp.insertParagraph(!0)},!0)},{label:"Insert Paragraph After",click:r(function(){File.editor.UserOp.insertParagraph(!1)},!0)},{type:"separator"},{label:"Link Reference",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_link")},!0)},{label:"Footnotes",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_footnote")},!0)},{type:"separator"},{label:"Horizontal Line",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("hr")},!0)},{label:"Table of Contents",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("toc")},!0)},{label:"YAML Front Matter",type:"checkbox",click:r(function(){File.editor.stylize.insertMetaBlock()},!0)}]}),p({label:"F&ormat",submenu:[{label:"Strong",type:"checkbox",accelerator:"CmdOrCtrl+B",click:r(function(){File.editor.stylize.toggleStyle("strong")},!0)},{label:"Emphasis",type:"checkbox",accelerator:"CmdOrCtrl+I",click:r(function(){File.editor.stylize.toggleStyle("em")},!0)},{label:"Underline",type:"checkbox",accelerator:"CmdOrCtrl+U",click:r(function(){File.editor.stylize.toggleStyle("underline")},!0)},{label:"Code",type:"checkbox",accelerator:"CmdOrCtrl+Shift+`",click:r(function(){File.editor.stylize.toggleStyle("code")},!0)},{type:"separator"},{label:"Inline Math",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("inline_math")},!0)},{label:"Strike",type:"checkbox",accelerator:"Alt+Shift+5",click:r(function(){File.editor.stylize.toggleStyle("del")},!0)},{label:"Highlight",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("highlight")},!0)},{label:"Superscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("superscript")},!0)},{label:"Subscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("subscript")},!0)},{label:"Comment",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("comment")},!0)},{type:"separator"},{label:"Hyperlink",type:"checkbox",accelerator:"Ctrl+K",click:r(function(){File.editor.stylize.toggleStyle("link")},!0)},{label:"Hyperlink Actions",submenu:[{label:"Open Link",click:r(function(){File.editor.openCurrentLink()},!0)},{label:"Copy Link Address",click:r(function(){File.editor.copyCurrentLink()},!0)}]},{label:"Image",submenu:[{label:"Insert Image",accelerator:"CmdOrCtrl+Shift+I",click:r(function(){File.editor.stylize.toggleStyle("image")},!0)},{label:"Insert Local Images…",click:r(function(){File.editor.imgEdit.insertLocalImage()},!0)},{type:"separator"},{label:"Open Image Location…",click:r(function(){File.editor.imgEdit.revealInFinder()},!0)},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Zoom Image",submenu:[{label:"25%",click:r(function(){File.editor.imgEdit.zoomAction(null,"25%")},!0)},{label:"33%",click:r(function(){File.editor.imgEdit.zoomAction(null,"33%")},!0)},{label:"50%",click:r(function(){File.editor.imgEdit.zoomAction(null,"50%")},!0)},{label:"67%",click:r(function(){File.editor.imgEdit.zoomAction(null,"67%")},!0)},{label:"80%",click:r(function(){File.editor.imgEdit.zoomAction(null,"80%")},!0)},{type:"separator"},{label:"100%",click:r(function(){File.editor.imgEdit.zoomAction(null,"100%")},!0)},{type:"separator"},{label:"150%",click:r(function(){File.editor.imgEdit.zoomAction(null,"150%")},!0)},{label:"200%",click:r(function(){File.editor.imgEdit.zoomAction(null,"200%")},!0)}]},{label:"Switch Image Syntax",submenu:[{label:"Markdown Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!1)},!0)},{label:"HTML Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!0)},!0)}]},{type:"separator"},{label:"Delete Image File",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.deleteImageAction(true)")}},{type:"separator"},{label:"Copy Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction()},!0)},{label:"Rename or Move Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction(!0)},!0)},{label:"Upload Image",click:r(function(){File.editor.imgEdit.uploadAction()},!0)},{type:"separator"},{label:"Copy All Images to…",click:r(function(){File.editor.imgEdit.copyAllImages()},!0)},{label:"Move All Images to…",click:r(function(){File.editor.imgEdit.moveAllImages()},!0)},{label:"Upload All Local Images",click:r(function(){File.editor.imgEdit.uploadAllImages()},!0)},{type:"separator"},{label:"Reload All Images",click:r(function(){File.editor.imgEdit.reloadAllByNode()},!0)},{type:"separator"},{label:"When Insert Local Image",submenu:[{label:"Copy Image File to Folder…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleCopyToFolder()},!0)},{label:"Upload Image",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUploadForFile()},!0)}]},{label:"Use Image Root Path…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUseImageRootPath()},!0)},{type:"separator"},{label:"Global Image Settings…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('image-setting-group');")}}]},{type:"separator"},{label:"Clear Format",type:"checkbox",accelerator:"CmdOrCtrl+\\",click:r(function(){File.editor.stylize.clearStyle()},!0)}]}),p({label:"&View",submenu:[{label:"Toggle Sidebar",accelerator:"CmdOrCtrl+Shift+L",click:r(function(){File.editor.library.toggleSidebar()},!0)},{label:"Outline",type:"checkbox",accelerator:"CmdOrCtrl+Shift+1",click:r("toggleOutline")},{label:"Articles",type:"checkbox",accelerator:"CmdOrCtrl+Shift+2",click:r("toggleFileList")},{label:"File Tree",type:"checkbox",accelerator:"CmdOrCtrl+Shift+3",click:r("toggleFileTree")},{label:"Search",type:"checkbox",accelerator:"CmdOrCtrl+Shift+F",click:r("globalSearch")},{type:"separator"},{label:"Source Code Mode",type:"checkbox",accelerator:"CmdOrCtrl+/",click:r(function(){File.toggleSourceMode()},!0)},{type:"separator"},{label:"Focus Mode",type:"checkbox",accelerator:"F8",click:r(function(){File.editor.toggleFocusMode()},!0),enabled:!1},{label:"Typewriter Mode",type:"checkbox",accelerator:"F9",click:r(function(){File.editor.toggleTypeWriterMode()},!0),enabled:!1},{type:"separator"},{label:"Show Status Bar",type:"checkbox",click:r("toggleStatusBar")},{type:"separator"},{label:"Toggle Fullscreen",accelerator:"F11",click:function(e,t){t&&(t.isFullScreen()?t.setFullScreen(!1):t.setFullScreen(!0))}},{label:"Always on Top",type:"checkbox",click:function(e,t){t&&(k(function(){document.body.classList.toggle("always-on-top")},!0),t.setAlwaysOnTop(!t.isAlwaysOnTop()),e.checked=t.isAlwaysOnTop())}},{type:"separator"},{label:"Actual Size",type:"checkbox",accelerator:d?"Ctrl+Shift+9":"Ctrl+Shift+0",click:function(e,t){v(function(){ClientCommand.resetZoom()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom In",accelerator:"Ctrl+Shift+=",click:function(e,t){v(function(){ClientCommand.zoomIn()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom Out",accelerator:"Ctrl+Shift+-",click:function(e,t){v(function(){ClientCommand.zoomOut()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{type:"separator"},{label:"Switch Between Opened Documents",accelerator:"Ctrl+Tab",click:function(e,t){var n;!t||-1!=(t=(n=m.getAllWindows()).indexOf(t))&&n[t=++t>=n.length?0:t].focus()}},{type:"separator"},{label:"Toggle DevTools",accelerator:"Shift+F12",click:function(e,t){var n;t&&(n=setTimeout(t.webContents.openDevTools,2e3),t.webContents.executeJavaScript("ClientCommand.toggleDevTools()").then(function(){clearTimeout(n)},function(){clearTimeout(n),t.webContents.openDevTools()}))}}]}),p({label:"&Themes",submenu:[]}),p({label:"&Help",submenu:[{label:"What's New…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/What's-New/`)}},{type:"separator"},{label:"Quick Start",click:function(e,t){l.openFile(u+"/Docs/Quick Start.md")}},{label:"Markdown Reference",click:function(e,t){l.openFile(u+"/Docs/Markdown Reference.md")}},{label:"Install and Use Pandoc",click:function(e,t){l.openFile(u+"/Docs/Install and Use Pandoc.md")}},{label:"Custom Themes",click:function(e,t){l.openFile(u+"/Docs/Custom Themes.md")}},{label:"Use Images in Typora",click:function(e,t){l.openFile(u+"/Docs/Use Images in Typora.md")}},{label:"Data Recovery and Version Control",click:function(e,t){l.openFile(u+"/Docs/Auto Save, Version Control and Recovery.md")}},{label:"More Topics…",click:function(e,t){var n=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal("https://support."+n)}},{type:"separator"},{label:"Credits",click:function(e,t){l.openFile(u+"/Docs/Credits.md")}},{label:"Change Log",click:function(e,t){l.openFile(u+"/Docs/Change Log.md")}},{label:"Privacy Policy",click:function(e,t){l.openFile(u+"/Docs/Privacy Policy.md")}},{label:"Website",click:function(){var e=l.setting.get("useMirrorInCN")?"https://typoraio.cn":"https://typora.io";a.shell.openExternal(e)}},{label:"Feedback",click:function(e,t){a.shell.openExternal("mailto:hi@typora.io")}},{type:"separator"},{label:"Check Updates…",click:function(){d&&l.updater.checkForUpdates(!0)},visible:d},{label:"My License…",click:function(){y.showLicensePanel()}},global.PRODUCTION_MODE?null:{label:"Welcome…",click:function(){y.showWelcomePanel()}},{label:"About",click:r(function(){File.megaMenu.closePreferencePanel(),document.body.classList.contains("native-window")?($(".modal:not(.block-modal)").modal("hide"),$("#about-dialog").modal("show"),$("*:focus").blur()):(File.megaMenu.show(),$("#m-about").trigger("click"))},!0)}]})];d||t[0].submenu.splice(t[0].submenu.indexOf(null),1),l.isEmojiPanelSupported()&&(t[1].submenu.push({type:"separator"}),t[1].submenu.push(p({label:"Emoji and Symbols",accelerator:d?"Super+.":"",click:function(){l.showEmojiPanel()}})));const i=t[t.length-1].submenu;for(;-1{"use strict";var a=c(93).EventEmitter,n=c(134),t=n.ipcMain,d=n.app,r=c(728),l="linux"==process.platform,s=c(541).join(__dirname,"../"),g=c(445),u=c(156),m=c(359).default,f=c(477),w=c(824),b=c(587),p=new a,o=["Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2"],h="64";"ia32"==process.arch&&(h="32"),"arm64"==process.arch&&(h="arm"),p.initUpdater=function(){return u.initDict().then(function(){return o.forEach(function(e,t){o[t]=u.getPanelString(e)}),Promise.resolve()})},p.showDetailWindow=function(e,t,n){p.progressBar&&(p.progressBar.close(),p.progressBar=null),p.win&&(p.win.destroy(),p.win=null);e=b.showPanelWindow({title:u.getPanelString("Updater"),width:640,height:600,path:"updater/updater.html?curVersion=$1&newVersion=$2&labels=$3&enableAutoUpdate=$4&releaseNoteLink=$5&hideAutoUpdates=$6".replace("$1",e).replace("$2",t).replace("$3",encodeURIComponent(JSON.stringify(o))).replace("$4",JSON.stringify(!1!==d.setting.get("enableAutoUpdate"))).replace("$5",encodeURIComponent(n)).replace("$6",global.devVersion&&!g.getHasLicense())});(p.win=e).on("closed",function(){p.win=null})},p.showUI=function(){p.win||p.progressBar||(p.progressBar=new f({title:u.getPanelString("Updater"),text:u.getPanelString("Checking Updates…"),indeterminate:!0,style:{text:{padding:"3px 0"}},browserWindow:{closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}}))};p.checkForUpdates=async function(t){var e,n,o,i=d.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",i=global.devVersion||d.setting.get("autoUpdateToDev")?`https://${i}/releases/dev_windows_${h}.json`:`https://${i}/releases/windows_${h}.json`;if(i){if(p.emit("checking-for-update"),t)p.showUI();else if((e=d.setting.get("cancelUpdate"))&&new Date-new Date(e)<432e5)return;try{var r=await m(i);if(204==r.status)return void p.emit("update-not-available");if(200!=r.status)return p.emit("update-not-available"),console.error("invalid status code: "+r.statusCode+" from "+i),"Failed to check updates, invalid status code: "+r.status;var a=await r.json(),l=(n=a,o=c(842).release().replace(/\.[^.]+$/,""),a=(o=(n.alternatives||{})[o])?Object.assign(n,o):n,p.data=a,d.getVersion());if(!a.version||!l)return;if(!(0{e||(console.log(t),p.installPathOnQuit=t,d.quit())})},p.installIfNeeded=function(){p.installPathOnQuit&&p.install(p.installPathOnQuit)},p.install=function(e){c(620).spawn(e,["/SILENT"],{detached:!0,stdio:["ignore","ignore","ignore"]}).unref()},t.handle("updater.checkForUpdates",(e,t)=>{p.checkForUpdates(t)}),t.handle("updater.cancelUpdate",e=>{p.cancelUpdate()}),t.handle("updater.skipUpdate",e=>{p.skipUpdate()}),t.handle("updater.downloadUpdate",e=>{p.downloadUpdate()}),e.exports=p},620:e=>{"use strict";e.exports=require("child_process")},289:e=>{"use strict";e.exports=require("crypto")},134:e=>{"use strict";e.exports=require("electron")},554:e=>{"use strict";e.exports=require("electron-dl")},359:e=>{"use strict";e.exports=require("electron-fetch")},477:e=>{"use strict";e.exports=require("electron-progressbar")},93:e=>{"use strict";e.exports=require("events")},834:e=>{"use strict";e.exports=require("extract-zip")},833:e=>{"use strict";e.exports=require("fs")},728:e=>{"use strict";e.exports=require("fs-extra")},232:e=>{"use strict";e.exports=require("fs-plus")},338:e=>{"use strict";e.exports=require("hjson")},783:e=>{"use strict";e.exports=require("lowdb")},207:e=>{"use strict";e.exports=require("lowdb/adapters/FileSync")},640:e=>{"use strict";e.exports=require("module")},560:e=>{"use strict";e.exports=require("node-machine-id")},842:e=>{"use strict";e.exports=require("os")},541:e=>{"use strict";e.exports=require("path")},208:e=>{"use strict";e.exports=require("process")},468:e=>{"use strict";e.exports=require("raven")},426:e=>{"use strict";e.exports=require("url")},266:e=>{"use strict";e.exports=require("util")}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;t=o[e]={id:e,loaded:!1,exports:{}};return n[e](t,t.exports,i),t.loaded=!0,t.exports}i.c=o,i.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);i(i.s=90)})(); \ No newline at end of file +(()=>{var n={883:(t,n,a)=>{var s=a(134),c=s.app,e=s.ipcMain,d=s.BrowserWindow,u="win32"==process.platform,p="linux"==process.platform,r=a(156),i=a(344);n.bindJumplist=()=>{var t;u&&(t=[{type:"custom",name:"Recent Locations",items:c.setting.getRecentFolders().slice(0,5).map(function(e){return{type:"task",title:e.name,description:e.path,program:process.execPath,args:JSON.stringify(e.path),iconPath:"explorer.exe",iconIndex:0}})},{type:"recent"},{type:"tasks",items:[{type:"task",program:process.execPath,arguments:"--new",iconPath:process.execPath,iconIndex:0,title:"New"}]}],c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t),i.loadDict().then(e=>{t[0].name=e["Recent Locations"]||"Recent Locations",t[2].items[0].title=e.New||"New",c.setAppUserModelId("abnerworks.Typora"),c.setJumpList(t)}))},e.handle("shell.saveItem",(e,{path:n,data:o})=>new Promise(t=>{a(833).writeFile(n,o,function(e){t()})})),e.handle("shell.openItem",(e,t)=>s.shell.openPath(a(541).normalize(t))),e.handle("shell.trashItem",async(e,t)=>{try{return await s.shell.trashItem(t),!0}catch(e){return!1}}),e.handle("shell.openExternal",(e,t)=>{if("about:blank"!=t)return s.shell.openExternal(t)}),e.handle("shell.showItemInFolder",(e,t)=>(u&&(t=t.replace(/\//g,"\\")),s.shell.showItemInFolder(t))),e.handle("shell.showDownload",(e,t)=>{e=d.fromWebContents(e.sender);const n=a(554)["download"];n(e,t,{saveAs:!0})}),e.handle("dialog.showMessageBox",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showMessageBox(p?null:e,t)}),e.handle("dialog.showSaveDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showSaveDialog(p?null:e,t)}),e.handle("dialog.showOpenDialog",(e,t)=>{e=d.fromWebContents(e.sender);return s.dialog.showOpenDialog(p?null:e,t)}),e.handle("dialog.showOpenDialogAlone",(e,t)=>s.dialog.showOpenDialog(t));const h=t=>new Promise(e=>{setTimeout(()=>{e("sleep")},t)}),m=async(e,t)=>{var n=new d({skipTaskbar:!0,title:"Print PDF Preview",show:!1,webPreferences:{webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!1,nodeIntegration:!1,safeDialogs:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,zoomFactor:+(c.setting.get("zoomFactor")||"1"),backgroundThrottling:!1}});try{var o,i,r=t?(console.log("load file ["+t+"] for PDF export"),n.loadFile(t)):(o=a(541).join(c.setting.tempPath||c.getPath("temp"),+new Date+"tmp.html"),i=a(728),console.log("write output to temp file ["+o+"] for PDF export"),await i.outputFile(o,e),n.loadFile(o))}catch(e){return console.error(e),n&&n.destroy(),null}return Promise.race([h(2e4),r]).then(e=>"sleep"===e?(l(n.id),console.warn("Timeout for loading print view"),null):n.id).catch(e=>(console.error(e),n&&n.destroy(),null))},l=(e.handle("export.genPrintView",(e,t,n)=>(n&&l(n),m(null,t))),e=>{e=d.fromId(e);e&&(e.isDestroyed()||e.destroy())});e.handle("export.destroyPrintView",(e,t)=>{l(t)}),e.handle("export.getPageColor",async(e,t)=>{try{var n=await m(null,t);if(console.log("generate print preview window with id "+n),!n)return null;printWin=d.fromId(n),await h(200);var o=await printWin.webContents.executeJavaScript("window.getComputedStyle(document.body).backgroundColor")}catch(e){console.error(e)}finally{printWin&&printWin.destroy()}return o}),e.handle("export.print",(e,n,o)=>{var i=d.fromId(n);o=o||{},i.webContents.print(o,(e,t)=>{if(!e&&!/cancel/.exec(t||"")){if("no valid printers available"===t)return void i.webContents.executeJavaScript("window.print()").then(()=>{o.skipCleanUp||l(n)});s.dialog.showMessageBox({type:"error",message:r.getPanelString("Error"),detail:t,buttons:["OK"]})}o.skipCleanUp||l(n)})}),e.handle("export.printToPDF",async(e,t,n)=>{let o=null,i=null,r=null,a="";try{var l=await m(null,t);if(console.log("generate print window with id "+l),!l)return[i,r];o=d.fromId(l),await h(200),i=await o.webContents.printToPDF(n),console.log("get PDF data");var s=`(${function(){var e=document.querySelector("#write");return e?{color:(e=window.getComputedStyle(e)).color,fontFamily:e.fontFamily,bgColor:e.backgroundColor}:null}.toString()})()`;r=(r=await o.webContents.executeJavaScript(s))&&JSON.stringify(r),console.log("get background color")}catch(e){a=e.message||"",console.error(e)}finally{o&&o.destroy()}return[i,r,a]});var f,o,g=u?8e3:960,w=1;function b(){console.log("updateTheme");var e=c.setting.curTheme(),t=(c.execInAll("window.ClientCommand && File.setTheme('"+e+"');"),e.replace(/\.css$/,"").replace(/(^|-|_)(\w)/g,function(e,t,n,o){return(t?" ":"")+n.toUpperCase()})),e=s.Menu.getApplicationMenu().getItem("Themes");e&&e.submenu.items.map(function(e){e.checked=e.label==t})}e.handle("export.prepareImageCapture",async(e,t,n)=>{var o,i=s.screen.getPrimaryDisplay();try{w=i.scaleFactor||1;var r=i.workArea;if(g=Math.min(g,r.height-20),f=n.imageWidth,await(o=new d({skipTaskbar:!0,show:!1,webPreferences:{devTools:!1,webSecurity:!1,allowDisplayingInsecureContent:!0,allowRunningInsecureContent:!0,nodeIntegration:!1,directWrite:c.setting.config.directWrite,defaultFontFamily:c.setting.config.defaultFontFamily,safeDialogs:!0},webgl:!1,useContentSize:!0,x:r.x,y:r.y,width:n.imageWidth,height:g,frame:!1,enableLargerThanScreen:!!u,offscreen:!0,alwaysOnTop:!0,minimizable:!1,closable:!0})).loadURL("file:///"+t),o.isDestroyed())return null;if(await h(2e3),o.isDestroyed())return null;var a=+await o.webContents.executeJavaScript("window.innerHeight");if(o.isDestroyed())return null;var l=+await o.webContents.executeJavaScript("document.body.parentElement.scrollTop = document.body.clientHeight;\nMath.max(document.body.clientHeight, document.body.parentElement.scrollHeight)");return o.isDestroyed()?null:Number.isNaN(l)||Number.isNaN(a)?void 0:(p&&(g=a),{winId:o.id,totalHeight:l,pageHeight:g,imageWidth:n.imageWidth,scale:3===n.quality?w:1})}catch(e){return console.error(e),null==o||o.isDestroyed()||o.destroy(),null}}),e.handle("export.captureImage",async(e,t,n,o)=>{t=d.fromId(t);if(!t||t.isDestroyed())return null;try{o&&(t.setSize(o.imageWidth,o.pageHeight),t.setContentSize(o.imageWidth,o.pageHeight));var i=+await t.webContents.executeJavaScript("document.body.parentElement.scrollTop = {d}; document.body.parentElement.scrollHeight;".replace("{d}",n));if(await h(1e3),t.isDestroyed()||Number.isNaN(i))return null;var r=await t.webContents.capturePage();if(!r||r.isEmpty())return null;var a=null;return 1new Promise((t,e)=>{try{var n=s.net.request({url:o,redirect:"follow"});n.on("response",function(e){try{if(200!=e.statusCode)return t(null);if(!e.data)return t(null);t({type:(e.headers["content-type"]||[""])[0],data:e.data})}catch(e){t(null)}}),n.end()}catch(e){t(null)}})),e.handle("clipboard.write",(e,t,n)=>{n&&s.clipboard.clear(),s.clipboard.write(JSON.parse(t))}),e.handle("pandoc.import",(e,n)=>{var o={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"'":"\\'","\\":"\\\\"},e=d.fromWebContents(e.sender),t=n?Promise.resolve(e):c.openFile(null,{syncAndPrepOnly:!0}).then(n=>new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e(n.activeWindow)}):e(n.activeWindow)})),e=s.dialog.showOpenDialog(n?e:null,{title:i.getMenuDict.Import,properties:["openFile"],filters:[{name:r.getPanelString("All Supported Formats"),extensions:["docx","rtf","latex","tex","ltx","rst","rest","org","wiki","dokuwiki","mediawiki","textile","opml","epub"]},{name:"MS Word",extensions:["docx"]},{name:"RTF",extensions:["rtf"]},{name:"TeX/LaTeX",extensions:["latex","tex","ltx"]},{name:"reStructuredText",extensions:["rst","rest"]},{name:"org-mode",extensions:["org"]},{name:"Wiki",extensions:["wiki","dokuwiki","mediawiki"]},{name:"Epub",extensions:["epub"]},{name:"Textile",extensions:["textile"]},{name:"OPML",extensions:["opml"]}]}).then(({filePaths:e})=>(e||[null])[0]);return Promise.all([t,e]).then(async([e,t])=>{t?(await h(100),e.show(),e.webContents.executeJavaScript('window.getSelection().removeAllRanges();ClientCommand.doImport("'+t.replace(/["'\\\b\t\n\f\r]/g,function(e){return o[e]}).replace(/\u200b/g,"")+'")')):n||e.destroy()})}),e.handle("pandoc.version",()=>o),e.handle("pandoc.setVersion",(e,t)=>{o=t}),s.nativeTheme.on("updated",function(){null!==c.setting.useDarkThemeBefore()&&c.setting.useDarkThemeBefore()!==c.setting.useDarkTheme()&&b()}),e.handle("theme.apply",()=>{b()}),e.handle("theme.setThemeSource",(e,t)=>{"system"!==(t=t||"system")&&c.setting.get("useSeparateDarkTheme")||(s.nativeTheme.themeSource=t)}),e.on("ondragstart",function(t,n,o){setTimeout(function(){var e=s.nativeImage;t.sender.startDrag({file:n,icon:o?e.createFromPath(a(541).normalize(o)):e.createEmpty()}),console.log("ondragstart "+n+" "+o)},100)}),e.handle("getPath",(e,t)=>c.getPath(t))},156:(e,t,n)=>{var o=n(134).app,i=n(728),r=n(541).join(__dirname,"../"),a=["Operation Failed","Save As","All Supported Formats","Error","Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2","Updater","Checking Updates…","Downloading Updates…","You're up to date!","Check Update Failed","Download failed","Install Updates ?","Quit and Install","Cancel","Download","Downloading…","Extracting binary…","This dev version of Typora is expired, please download and install a newer version.","This device has been deactivated","Typora is now deactivated","UNREGISTERED"],l={},s=!1;e.exports={initDict:function(){if(s)return Promise.resolve();var e=n(541).join(r,o.setting.getLocaleFolder("Panel"));return i.readJSON(e,"utf8").then(function(t){s=!0,a.map(function(e){l[e]=t[e]||e})}).catch(function(){})},getPanelString:function(e){return l[e]||e}}},351:(r,l,c)=>{function d(e,t){this.activeWindow=t||null,this.windows=new Set(t),this.path=e||null,this.snap=null,this.lastSync,this.content,this.backupState=null}var e=c(134),u=e.app,a=e.BrowserWindow,s=(e.powerMonitor,c(728)),e=c(232),h=(c(266),process.platform,process.platform,"linux"==process.platform),g=c(468),m=c(587),t=c(134).ipcMain,o=(t.on("doc.syncChange",function(e,t){var n=a.fromWebContents(e.sender),o=u.documentController.getDocumentFromWindowId(n.id);n==o.activeWindow&&1=n}catch(e){console.warn(e)}return!1}},d.prototype.getWindowToFocus=function(){var e=this.activeWindow||this.windows.keys().next().value;if(e){if(!e.isDestroyed())return e;this.activeWindow=null,this.windows.delete(e)}return null},d.prototype.syncFullContent=function(t){var e,n=!1;if(this.windows.forEach(function(e){this.activeWindow!=e&&!n&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&(n=!0)}),n)return e=this.windows,this.activeWindow.webContents.executeJavaScript("File.sync(false, true);1;").then(function(){e.forEach(function(e){this.activeWindow!=e&&(e.inSourceMode&&!t||!e.inSourceMode&&t)&&e.webContents.executeJavaScript("File.editor.applyFullContent("+!!t+")")})}),null},d.prototype.popBackupState=async function(){var e=this.backupState;return this.backupState=void 0,Promise,e},function(e){return c(541).basename(e)}),f=e.isCaseInsensitive();function p(e){return f?e&&e.toLowerCase():e}function n(){this.documents=new Set,this.path2doc=new Map,this.win2doc=new Map,this.name2docs=new Map,this.frozenDocs=[],this.watchSystemPause()}n.prototype.watchSystemPause=function(){u.whenReady().then(()=>{})},n.prototype.setContentForWindow=function(e,t){var n=this.getDocumentFromWindowId(t);(n.activeWindow||{}).id==t&&n.setContent(e)},n.prototype.solveDuplicateName_=function(e){var t=e.path,t=p(o(t)),n=this.name2docs.get(t)||new Set;this.name2docs.set(t,n),0{e=a.fromWebContents(e.sender),t=t?u.getDocumentController().getDocument(t):u.documentController.getDocumentFromWindowId(e.id);t&&t.activeWindow==e&&t&&t.switchToUntitled(n)}),t.handle("document.setLastSync",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).setLastSync(t)}),t.handle("document.syncFullContent",(e,t)=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).syncFullContent(t)}),t.handle("document.getContent",e=>{e=a.fromWebContents(e.sender);u.documentController.getDocumentFromWindowId(e.id).getContent()}),t.handle("document.currentPath",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).path});const b=async e=>{var t=e.getSnap(null),n=e.path,o=!1,i=null;return(t||{}).nodeMap?o=await e.shouldReadFromDisk():i=await e.popBackupState(),i&&i.hasUnsaved?console.log("load from recover content length: "+i.content.length):i=null,JSON.stringify({snap:t,filePath:n,backups:i,shouldReadFromDisk:o,windowCounts:e.windows.size})};t.handle("document.loadData",async e=>{console.log("handle document.loadData");new Date;e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),e=await b(e);return new Date,e}),t.handle("document.switchDocument",async(e,t)=>{e=a.fromWebContents(e.sender),e=await u.getDocumentController().switchDocument(e.id,t);return b(e)}),t.handle("document.rename",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).rename(t),!0}),t.handle("document.setContent",(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=e.content==t;return e.setContent(t),n}),t.handle("document.addSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return t?e.addSnap(JSON.parse(t)):e.addSnap(null),!0}),t.handle("document.addSnapAndLastSync",(e,t)=>{try{var n,o,i=a.fromWebContents(e.sender),r=u.documentController.getDocumentFromWindowId(i.id);t?({snap:n,lastSync:o}=JSON.parse(t),r.addSnap(n),r.setLastSync(o)):r.addSnap(null)}catch(e){console.error(e)}return!0}),t.handle("document.shouldSaveSnap",e=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).shouldSaveSnap()}),t.handle("document.getSnap",(e,t)=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);return JSON.stringify(e.getSnap(t))}),t.handle("document.getSnapWithValidation",async(e,t)=>{var e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id),n=await e.isSnapValid();return JSON.stringify({snap:e.getSnap(t),shouldReadFromDisk:0==n})}),t.handle("document.enterOversize",e=>{e=a.fromWebContents(e.sender),e=u.documentController.getDocumentFromWindowId(e.id);e&&e.enterOversize()}),t.handle("document.newWindow",e=>{3==u.setting.get("restoreWhenLaunch")?u.openFile(null,{mountFolder:u.setting.get("pinFolder"),silent:"pinFolder"}):u.openFile()}),t.handle("document.checkIfMoveOnSave",(e,t)=>{var e=a.fromWebContents(e.sender),n=u.documentController.getDocument(t);return!n&&((n=u.documentController.getDocumentFromWindowId(e.id)).rename(t),!0)}),t.handle("document.hasDuplicateName",(e,t)=>u.documentController.hasDuplicateName(t)),t.handle("document.noOtherWindow",(e,t)=>{e=a.fromWebContents(e.sender);return u.documentController.getDocumentFromWindowId(e.id).windows.size<=1});var i=new n;r.exports=i},824:(e,t,s)=>{var c=s(728),d=s(541),u={title:"Download",text:"Downloading…",indeterminate:!1,initialValue:0,maxValue:1,closeOnComplete:!1,abortOnError:!1,style:{text:{padding:"3px 0"}},browserWindow:{modal:!1,closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}};function p(e){if(e<1024)return e+" B";var t=e/Math.pow(1024,1),e=e/Math.pow(1024,2);return e<1?(t+"").replace(/(\..)(.+)$/,"$1")+"KB":(e+"").replace(/(\..)(.+)$/,"$1")+"MB"}function n(e,t,n){this.onAbort=null,this.onSuccess=null,this.onError=null,this.downloadURL=e,this.dist=t,this.displayOption=n||{},this.progressBar=null,this.downloadItem=null}n.prototype.cancel=function(){if(this.downloadItem){try{this.downloadItem.cancel()}catch(e){}this.downloadItem=null}this.setCompleted(),this.onAbort&&this.onAbort()},n.prototype.setCompleted=function(){this.downloadItem=null,this.progressBar&&(this.progressBar.setCompleted(),this.progressBar.close(),this.progressBar=null)},n.prototype.download=function(){var e=s(477),t=s(554),n=this,o=this.downloadURL,i=this.dist,r=this.displayOption,a=new e(Object.assign({},u,r)),l=((this.progressBar=a).on("aborted",function(){n.cancel()}),d.dirname(i));Promise.all([new Promise(function(e){a.on("ready",e)}),c.ensureDir(l)]).then(function(){console.record("[downloader] downloading "+o,"DEBUG"),t.download(a._window,o,{showBadge:r.showBadge||!1,directory:l,filename:d.basename(i),onProgress:function(e){a&&(a.value=e.percent*(r.processOnComplete||1),a.detail=p(e.transferredBytes)+" / "+p(e.totalBytes))},onStarted:function(e){console.log("start downloading "+e.getURL()),n.downloadItem=e},onCancel:function(){console.log("canceled downloading "+downloadItem.getURL()),n.cancel()}}).then(function(e){n.onSuccess(e,a)}).catch(function(e){console.log("error downloading "+(n.downloadItem&&n.downloadItem.getURL())),n.onError(e)})})},e.exports=n},405:(e,t,n)=>{var n=n(134),o=n.app,n=n.ipcMain,i=global.t_workingDir,r=o.getVersion(),a=(/-([a-z]+)/.exec(r)||[])[1],l=r;function s(e,t){var n,o,i;for(e=(e||"").replace(/-[a-z]+/,""),t=(t||"").replace(/-[a-z]+/,""),e=e.split("."),t=t.split("."),o=Math.min(e.length,t.length),n=0;n({PRODUCTION_MODE:global.PRODUCTION_MODE,DEBUG_MODE:global.DEBUG_MODE,version:o.getVersion(),devVersion:global.devVersion})),global.compareVersion=s,global.t_workingDir=i,global.PRODUCTION_MODE=!0,global.DEBUG_MODE=!1},932:(e,t,n)=>{function o(){this.clearUndo()}function i(e){r.dialog.showErrorBox(l.getPanelString("Operation Failed"),e.message)}var r=n(134),a=r.app,l=n(156),s=n(728),n=r.ipcMain,c=(o.prototype.hasUndo=function(e){return!(!this.hasUndo_||!e)&&(0==(this.undoTo_||"").indexOf(e)||0==(this.undoFrom_||"").indexOf(e))},o.prototype.undoLabel=function(){return this.undoLabel_},o.prototype.clearUndo=function(){this.undoFrom_="",this.undoTo_="",this.undoLabel_="",this.hasUndo_=!1},o.prototype.registerUndo=function(e,t,n){this.undoFrom_=e,this.undoTo_=t,this.undoLabel_=n,this.hasUndo_=!0},o.prototype.getFocusPath=function(){return this.hasUndo_&&this.undoTo_},o.prototype.performUndo=function(){var t;function n(){r.dialog.showMessageBox({type:"warning",message:l.getPanelString("Operation Failed"),defaultId:0,cancelId:1,buttons:[l.getPanelString("Save As"),l.getPanelString("Cancel")]}).then(({response:e})=>{0==e?r.dialog.showSaveDialog({defaultPath:t.undoTo_,properties:["showOverwriteConfirmation"]}).then(({filePath:e})=>{e&&e!=t.undoFrom_&&s.rename(t.undoFrom_,e,function(e){e&&i(e)}),t.clearUndo()}):t.clearUndo()})}this.hasUndo_&&(this.hasUndo_=!1,(t=this).undoTo_?s.existsSync(this.undoTo_)?n():(a.sendEvent("willRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),s.copyFile(this.undoFrom_,this.undoTo_,function(e){s.unlink(t.undoFrom_,function(){}),e?(n(),a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoFrom_})):(a.sendEvent("didRename",{oldPath:t.undoFrom_,newPath:t.undoTo_}),t.clearUndo())})):s.remove(this.undoFrom_,function(e){e?i(e):(t.clearUndo(),a.sendEvent("updateQuickOpenCache",{toDel:this.undoFrom_}))}))},new o);n.handle("filesOp.registerUndo",(e,t,n,o)=>{c.registerUndo(t,n,o)}),n.handle("filesOp.clearUndo",e=>{c.clearUndo()}),n.handle("filesOp.performUndo",e=>{c.performUndo()}),n.handle("filesOp.getFocusPath",e=>c.getFocusPath()),n.handle("filesOp.undoLabel",(e,t)=>c.hasUndo(t)?c.undoLabel():null),t.default=c},445:(o,u,i)=>{i(405);var p,h=i(156),g=i(134),m=g.shell,l=g.app,e=g.ipcMain,f=g.BrowserWindow,w="win32"==process.platform,b="darwin"==process.platform,y="linux"==process.platform,v=i(587),k=i(359).default,s=i(468),C=!1;const F=function(e){try{return require(e)}catch(e){if(C)return;C=!0;var t=e.message;setTimeout(()=>{C=!1,(dialog=i(134).dialog).showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:"A required module cannot be loaded by Typora",message:t.split("\n")[0]+"\n\nPlease check if that file exists or reinstall Typora to fix."}).then(({})=>{process.exit(1)})},1500)}};var S,r=null,x="",c="",a="",D="";const T={SUCCESS:0,OUT_OF_LIMIT:1,INVALIDATE:-1,WRONG_USER:-2},P=JSON.parse(Buffer.from("WyItLS0tLUJFR0lOIFBVQkxJQyBLRVktLS0tLSIsIk1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBN25Wb0dDSHFJTUp5cWdBTEVVcmMiLCI1SkpoYXAwK0h0SnF6UEUwNHB6NHkrbnJPbVk3LzEyZjNIdlp5eW9Sc3hLZFhUWmJPMHdFSEZJaDBjUnFzdWFKIiwiUHlhT09QYkEwQnNhbG9mSUFZM21SaFFRM3ZTZitybjNnK3cwUyt1ZFdtS1Y5RG5tSmxwV3FpekZhalU0VC9FNCIsIjVaZ01OY1h0M0UxaXBzMzJyZGJUUjBObmVuOVBWSVR2cmJKM2w2Q0kyQkZCSW1aUVoyUDhOK0xzcWZKc3F5VlYiLCJ3RGt0M21IQVZ4VjdGWmJmWVdHKzhGRFN1S1FIYUNtdmdBdENoeDlod2wzSjZSZWtrcURWYTZHSVYxM0QyM0xTIiwicWRrMEpiNTIxd0ZKaS9WNlFBSzZTTEJpYnk1Z1lONnpRUTVSUXBqWHRSNTNNd3pUZGlBekdFdUtkT3RyWTJNZSIsIkR3SURBUUFCIiwiLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tIiwiIiwiIl0=","base64").toString("utf8")).join("\n"),I=864e5;var W="https://store.typora.io";const E=e=>{if(!e)return e;var t;try{t=Buffer.from(e,"base64");const n=i(289).publicDecrypt(P,t);return JSON.parse(n.toString("utf8"))}catch(e){return null}},O=function(){var e=Array.from(arguments);const t=i(289).createHash("sha256");return e.forEach(e=>{t.update(e)}),t.digest("base64")},_=()=>{const e=d().get("SLicense");if(!e)return null;var[t,n,o]=e.split("#"),t=E(t);return t&&t.fingerprint==a?(Object.assign(t,{failCounts:n,lastRetry:new Date(o)}),t):null},M=async e=>{console.log("writeInstallDate fromBTime="+e);var t=new Date;if(e)try{var n=await i(728).stat(l.getPath("userData")+"/profile.data"),t=new Date(n.birthtime);n.birthtime}catch(e){}e=(p=t).toLocaleDateString("en-US");return d().put("IDate",e),p};var L=null;const d=function(){var n;return L=null==L?w?function(){const o=F("native-reg"),i="Software\\Typora";return{get:function(e){var t=o.openKey(o.HKCU,i,o.Access.READ);if(null==t)return"";e=o.getValue(t,null,e);return o.closeKey(t),e},put:function(e,t){var n=o.createKey(o.HKCU,i,o.Access.WRITE);o.setValueSZ(n,e,t),o.closeKey(n)}}}():(n=l.setting.prepDatabase(a),{put:function(e,t){console.log("ls put "+e),n.getState()[e]=t,n.write()},get:function(e){return n.getState()[e]}}):L};const U=async()=>{if(!a){if(w){const t=F("native-reg");var e=t.openKey(t.HKEY.LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Cryptography",t.Access.WOW64_64KEY|t.Access.READ);a=t.getValue(e,null,"MachineGuid"),t.closeKey(e)}else a=await i(560).machineId({original:!0});a||s.captureMessage("[L] Failed to get fingerPrint"),a=O(a,"typora").substr(0,10).replace(/[/=+-]/g,"a"),b&&(a+="darwin")}return a};var R=!1;const A=()=>{var e=s.getContext().tags;e.hasLicense=r,s.mergeContext(e)},N=()=>process.platform.replace(/\d+/,""),B=async(t,n,o)=>{oe(),console.log(`request ${W}/`+t);const e=new AbortController;var i,r=setTimeout(()=>e.abort(),3e4);try{i=await k(W+"/"+t,{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}}),clearTimeout(r)}catch(e){var a=e;if(console.warn(e.stack),clearTimeout(r),o&&"zh-Hans"==l.setting.getUserLocale()&&!l.setting.get("useMirrorInCN")){r=(await g.dialog.showMessageBox(null,{message:"链接服务器失败,使用尝试访问国内域名进行激活?",buttons:["确认","取消"]}))["response"];if(console.log("click "+r),r)throw a;return l.setting.put("useMirrorInCN",!0),B(t,n,!1)}if(l.setting.get("useMirrorInCN"))try{console.log("request to typora.com.cn"),i=await post("https://typora.com.cn/store/"+t,n)}catch(e){throw a}}if(i){if(200==i.status)return-1{const o=(new Date).toLocaleDateString("en-US");var{deviceId:t,lastRetry:i}=t||{};if(n||!(new Date-ir.abort(),4e4);const a=await(await k(W+"/api/client/renew",{method:"POST",cache:"no-cache",body:JSON.stringify(n),headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}})).json();clearTimeout(e),a.success||(console.warn("[renewL]: unfill due to renew fail"),$(a.msg)),d().put("SLicense",[a.msg,0,o].join("#"))}catch(e){e.stack,s.captureException(e,{level:"warning"}),console.warn("Failed to Renew L");var[t,n]=(i=d().get("SLicense")).split("#"),i=[t,n=+n+1,o].join("#");d().put("SLicense",i)}}},J=e=>{var t=new Date(d().get("IDate"));return isNaN(t.getTime())?e?null:new Date:e?t:(e=1676345080018,isNaN(e)?e=new Date("2021-10-01"):(e=new Date(e),isNaN(e.getTime())&&(e=new Date("2021-10-01"))),t{if(t=t||15,432e5{var e=(p=J(!global.devVersion))?V(!1):100;(15{R=!0;var t=_(),{license:n,email:o,type:i}=t||{};n&&o?(j(o,n,i),z(t,e)):$()},K=(e,t)=>g.dialog.showMessageBox(null,{type:"error",buttons:["OK"],defaultId:0,cancelId:0,title:e,message:t}),Q=function(){l.expired=!0,K(h.getPanelString("Error"),h.getPanelString("This dev version of Typora is expired, please download and install a newer version.")).then(()=>{m.openExternal("https://typora.io/#download"),setTimeout(()=>{process.exit(1)},1e3)})},Z=function(){var e;re()&&!l.setting.inFirstShow&&(e=y||global.devVersion,y&&Math.random()<.8||(!S||new Date-S>36e5*(e?4:2)||!e&&V(!0,16)<=0)&&Y())};var G=!1,t=null;const Y=async function(e){if(S=new Date,null==t)return(t=v.showPanelWindow({width:525,height:420,path:`page-dist/license.html?dayRemains=${V(!0)}&index=${e?1:0}&hasActivated=${r||!1}&email=${x}&license=${c}&lang=${l.setting.getUserLocale()}&needLicense=${ie()&&!global.devVersion}&type=${D}&os=`+(w?"win":b?"mac":"linux"),frame:!1,alwaysOnTop:!C})).on("closed",function(){t=null}),void setTimeout(()=>{t&&!t.isDestroyed()&&t.setAlwaysOnTop(!1)},5e3);t.focus()};var n=null;async function X(){var o=(o=process.env.USER)||i(842).userInfo().username;switch(process.platform){case"win32":return process.env.COMPUTERNAME+" | "+o+" | Windows";case"darwin":return new Promise(n=>{i(620).exec("scutil --get ComputerName",{timeout:5e3},(e,t)=>{n(!e&&t?t.toString().trim()+" | "+o+" | darwin":i(842).hostname()+" | "+o+" | darwin")})});default:return i(842).hostname()+" | "+o+" | Linux"}}async function ee(e){try{var{fingerprint:t,email:n,license:o,type:i}=E(e)||{};return n&&o&&t?t!=await U()?(console.log("[L] validate server return fail"),$(),!1):(j(n,o,i),d().put("SLicense",e+"#0#"+(new Date).toLocaleDateString("en-US")),r=!0):(console.log("[L] validate server return empty"),$(),!1)}catch(e){throw console.error(e.stack),new Error("WriteActivationInfoFail")}}const te=e=>{const r="L23456789ABCDEFGHJKMNPQRSTUVWXYZ";if(!/^([A-Z0-9]{6}-){3}[A-Z0-9]{6}$/.exec(e))return!1;var e=e.replace(/-/g,""),t=e.substr(22);return!e.replace(/[L23456789ABCDEFGHJKMNPQRSTUVWXYZ]/g,"")&&t==(e=>{for(var t="",n=0;n<2;n++){for(var o=0,i=0;i<16;i+=2)o+=r.indexOf(e[n+i]);o%=r.length,t+=r[o]}return t})(e)},ne=(e.handle("license.machineCode",async()=>{console.log("handle license.machineCode");try{return await Buffer.from(JSON.stringify({v:N()+"|"+l.getVersion(),i:await U(),l:await X()}),"utf8").toString("base64")}catch(e){console.error(e.stack)}}),async t=>{r&&x&&c||console.error("doDeactivation on unregistered device");var e=(_()||{})["deviceId"];try{await B("api/client/deactivate",{license:c,l:e,sig:O(x,await U(),c)},!1)}catch(e){if(s.captureException(e,{level:"warning"}),console.log(e.stack),!t&&"off"==D)return!1}return $(),!0}),oe=(e.handle("addLicense",async(e,{email:t,license:n,force:o})=>{try{return await async function(e,t,n){if(e=(e||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),t=(t||"").replace(/^[\s\u200b ]/g,"").replace(/[\s\u200b ]$/g,""),!/^[^\s@'"/\\=?]+@[^\s@'"/\\]+\.[^\s@'"/\\]+$/.test(e))return[!1,"Please input a valid email address"];if(!te(t))return[!1,"Please input a valid license code"];t={v:N()+"|"+l.getVersion(),license:t,email:e,l:await X(),f:await U(),u:l.setting.generateUUID(),type:global.devVersion?"dev":"",force:n};JSON.stringify(t);try{var o=await B("api/client/activate",t,!0);if(JSON.stringify(o),console.log("[License] response code is "+o.code),o.code==T.SUCCESS)return await ee(o.msg)?[!0,""]:[!1,"Please input a valid license code"];if(o.code==T.OUT_OF_LIMIT)return n?await ee(o.msg)?[!0,"Your license has exceeded the max devices numbers.\nThe oldest device was unregistered automatically."]:[!1,"Please input a valid license code"]:["confirm",'Your license has exceeded the max devices numbers.\nIf you click "Continue Activation", this device will be activated and the oldest device will be unregistered automatically.'];if(o.code==T.INVALIDATE)return[!1,"Please input a valid license code"];if(o.code==T.WRONG_USER)return[!1,"This license code has been used with a different email address."]}catch(e){return"WriteActivationInfoFail"==e.message?(ne(!0).then(()=>{},()=>{}),[!1,"Failed to write your license to local machine"]):e.response&&e.response.code?(console.warn("[L] error from server "+e.response.code),[!1,"Unknown Error. Please contact hi@typora.io"]):(s.captureException(e,{level:"warning"}),console.error(e.stack),[!1,"Failed to access the license server. Please check your network or try again later."])}}(t,n,o)}catch(e){console.error(e.stack)}}),e.handle("offlineActivation",async(e,t)=>{try{return n=t,await(await ee(n)?[!0,"",x,c]:[!1,"Please input a valid license code"])}catch(e){console.error(e.stack)}var n}),e.handle("license.show",(e,t)=>{Y(t||!1)}),e.handle("license.show.debug",()=>{t&&t.webContents.openDevTools()}),e.handle("removeLicense",async e=>{try{return await ne()}catch(e){console.error(e.stack)}return!1}),()=>{W=l.setting.get("useMirrorInCN")?shostc||"".substring(1):global.shost||"".substring(1)});const ie=()=>!r&&!y,re=e=>R&&!r;var ae;ae=(new Date).getTime();const le="txxxx-xxxx-xxxxy".replace(/[x]/g,function(e){var t=(ae+16*Math.random())%16|0;return ae=Math.floor(ae/16),t.toString(16)}),se=()=>{f.getAllWindows().forEach(e=>{e.webContents.executeJavaScript(`try{document.querySelector(".${le}").remove();}catch(e){};File.option && (File.option.hasLicense = true);File.megaMenu && File.megaMenu.forceReload();0;`)})},ce=async e=>{await h.initDict();const t=`.typora-sourceview-on .${le}{left: 170px;}.${le} {position: fixed;bottom: 2px;z-index: 9999;left: 70px;font-size: 12px;line-height: 24px;background: rgb(120 120 120 / 30%);padding: 0 12px;color: var(--text-color);border-radius: 4px;cursor: pointer;}.pin-outline .${le}{left:calc(var(--sidebar-width) + 70px);}`,n=`if(window.File.option){File.option.hasLicense = false;File.megaMenu && File.megaMenu.forceReload(); };1;`;function o(e){e.webContents.insertCSS(t.replace(/(\{|\}|;)\n/g,"$1")),e.webContents.executeJavaScript(n.replace(/(\{|\}|;)\n/g,"$1"))}e?o(e):f.getAllWindows().forEach(o)};w&&(e=i(541).join(t_workingDir,"../winmm.dll"),i(833).stat(e,function(e,t){!e&&t&&setTimeout(function(){G=!0},138e4)})),u.startL=async(e,t)=>{console.log("start LM in devVersion="+(global.devVersion||!1));try{oe(),await U(),!e&&t||y||(global.devVersion||!t||-1240*I)&&Q(),n=+n,console.log("verInitTime is "+n),!isNaN(n)&&o-n>200*I&&Q()),(async e=>{console.log("[watch L]"),q(e),r=true,await H(),console.log("[watch L] hasL: "+r),Z(),A()})(e)}catch(e){s.captureException(e)}var n,o,i;v.on("dom-ready",e=>{e=e,R&&re()&&ce(e)}),v.on("make-window",e=>{Z()})},u.showLicensePanel=Y,u.showWelcomePanel=async function(){if(S=new Date,null==n)return(n=v.showPanelWindow({width:760,height:460,path:"page-dist/welcome.html?lang="+l.setting.getUserLocale(),frame:!1,alwaysOnTop:!C})).on("closed",function(){n=null}),void setTimeout(()=>{n&&!n.isDestroyed()&&n.setAlwaysOnTop(!1)},4e3);n.focus()},u.shouldShowWelcomePanel=ie,u.getHasLicense=()=>r,u.cannotContinueUse=function(){return!1===r&&!y&&!global.devVersion&&(G||V(!0,20)<=0)}},557:(o,i,F)=>{var c,d,W=global.PRODUCTION_MODE,S=F(134),x=S.app,u=F(266),r=F(338),a=S.Menu,l=S.MenuItem,p=S.BrowserWindow,s=S.shell,D="win32"==process.platform,h="darwin"==process.platform,g="linux"==process.platform,T=F(728),P=F(541).join(__dirname,"../"),m=F(344),f=F(824),w=F(156),E=F(445),b=require(W?"package.json":"../package.json"),I=F(468),y=1e4;function v(t){var o,i,r=0,n=x.getPath("userData")+"/typora.log",a="",l=console.error;function s(e,t){try{if(y{this.logStream=e})}function k(){var n=(new Date).getTime();return uuid="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),("x"==e?t:3&t|8).toString(16)})}function _(t){var e=1676345080018,n=!1,o=0;isNaN(e)||(o=30<(e=(new Date-e)/864e5/5)?(n=!0,.001):Math.max(0,(30-e)/30),isNaN(o)&&(o=.01)),I.config("https://41af752e6d61480d85276af874a7f69b@sentry.typora.io/2",{logger:"node",release:b.releaseId,autoBreadcrumbs:{http:!1,console:!1},sampleRate:o,shouldSendCallback:function(e){return(!e||"debug"!=e.level)&&(!n&&!t.hasUpdates&&t.db&&t.get("send_usage_info")+""!="false")}}).install(B),C=k(),I.mergeContext({tags:{instance:C,arch:process.platform,appVersion:x.getVersion()}}),I.disableConsoleAlerts(),setTimeout(function(){console.log("[Raven] instanceKey = "+C)},0),I.setDataCallback(function(e){try{return e?(e.request&&(e.request.url="http://typora/"),e.mechanism&&delete e.mechanism,e.exception&&(t=e)&&(t.message&&(t.message=L(t.message)),(t.exception||[]).forEach(function(e){e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&e.stacktrace.frames.forEach(function(e){e.filename&&(e.filename=U(e.filename))})}),n=t.stacktrace||[],(t=(t.exception||{}).values||[]).forEach&&t.forEach(function(e,t){e&&(e.value&&(e.value=L(e.value)),e.stacktrace&&e.stacktrace.frames&&(n=n.concat(e.stacktrace.frames)))}),n.length&&n.forEach(function(e){var t;-1<(t=e.filename.lastIndexOf("atom.asar"))&&(e.filename="http://typora-app/atom/"+e.filename.substring(t+9).replace(/\\/g,"/"))})),e):void 0}catch(e){console.error(e.stack)}var t,n;return{}})}e.prototype.closeLogging=function(){console.log("closeLogging");try{c=!0,d&&(process.stdout.write=process.stderr.write=d),this.logStream&&this.logStream.end()}catch(e){console.error(e)}},e.prototype.put=function(e,t){this.db.getState()[e]=t,this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=setTimeout(this.save.bind(this),500)},e.prototype.get=function(e,t){try{return"recentDocument"==e?this.getRecentDocuments():"recentFolder"==e?this.getRecentFolders():("framelessWindow"!=e||!g)&&(void 0===(n=this.db.getState())[e]?t:n[e]);var n}catch(e){return console.error(e),t}},e.prototype.save=function(){this.saveTimer&&clearTimeout(this.saveTimer),this.saveTimer=null;try{this.db.write()}catch(e){console.error(e.stack)}},e.prototype.syncAll=function(){this.saveTimer&&clearTimeout(this.saveTimer);try{this.db.write(),this.history.write()}catch(e){console.error(e.stack)}},e.prototype.getAllThemes=function(){return this.allThemes},e.prototype.getRecentFolders=function(){var e=this.history.getState(),t=e.recentFolder;return t||(e.recentFolder=t=[]),t||[]},e.prototype.addRecentFolder=function(e){console.log("addRecentFolder"),e=F(541).normalize(e);var t=F(541).basename(e),n=this.getRecentFolders();if(t.length){this.removeRecentFolder(e,!0),n.unshift({name:t,path:e,date:new Date}),8new Promise(e=>{T.rm(l.join(v,t),{force:!0,recursive:!0,maxRetries:1},e)})))}await 0}if(0==o&&T.existsSync(a))g();else{console.log("overwriteThemeFolder"),T.ensureDirSync(f);var w=[];if(-1<["github.css","newsprint.css","night.css","pixyll.css","white.css"].indexOf(e)){try{T.renameSync(l.join(a,e),l.join(f,e)),w.push(e)}catch(e){}T.copySync(l.join(m,e),l.join(a,e),{overwrite:!0})}h.list(m,function(e,t){Promise.all(t.map(function(e){var r=l.basename(e);return new Promise(function(e,t){if(-1{}),C.rm(s.join(c,i+".aff"),{force:!0},()=>{}),C.rm(s.join(c,i+"-LICENSE"),{force:!0},()=>{}),console.log(`remove ${c}/${i}.dic`)}}else this.put("strict_mode",!0),this.put("copy_markdown_by_default",!0)}this.initDictionary_(),this.addAnalyticsEvent("launch"),t&&0!=o?this.addAnalyticsEvent(0{var t=x.setting.get("export.general")||{},n={},o=(["pdf","html","html-plain","image"].forEach(e=>{n[e]=Object.assign({type:e},t,x.setting.get("export."+e)||{})}),{});return x.setting.loadCustomExports().forEach(e=>{o[e.key]=Object.assign({},t,e,x.setting.get("export."+e.key)||{})}),JSON.stringify([n,o])}),n.handle("export.recordLastExport",(e,t)=>{A||(x.updateMenu({"File→Export→Export with Previous":{enabled:!0}}),x.updateMenu({"File→Export→Export and Overwrite with Previous":{enabled:!0}})),A=t,x.setting.lastExport=t,x.execInAll("File.option._lastExport = "+JSON.stringify(t))}),n.handle("setting.getDownloadingDicts",e=>JSON.stringify(x.setting.downloadingDicts||[])),n.handle("setting.getUserDictionaryPath",e=>x.setting.getUserDictionaryPath()),n.handle("setting.getUserDict",e=>JSON.stringify(x.setting.userDict)),n.handle("setting.downloadDict",(e,t)=>{e=p.fromWebContents(e.sender);x.setting.downloadDict(t,e.id)}),n.handle("setting.getThemes",e=>({all:x.setting.getAllThemes()||[],current:x.setting.curTheme()})),n.handle("setting.setCurTheme",(e,t,n)=>{x.setting.setCurTheme(t,n)}),n.handle("setting.resetAdvancedSettings",(e,t)=>{function n(){}var o=F(728),i=x.getPath("userData")+"/conf/conf.user.json";o.copy(P+"/conf.default.json",x.getPath("userData")+"/conf/conf.default.json",{overwrite:!0},t?function(){S.shell.showItemInFolder(i)}:n),o.copy(P+"/conf.default.json",i,{overwrite:!0},n)}),n.handle("logger.error",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Error] "+t)}),n.handle("logger.warn",function(e,t){console.log("[RenderProcess "+e.sender.id+"][Warn] "+t)}),n.handle("setting.clearRecentDocuments",e=>{x.setting.clearRecentDocuments()}),n.handle("setting.removeRecentFolder",(e,t)=>{x.setting.removeRecentFolder(t)}),n.handle("setting.removeRecentDocument",(e,t)=>{x.setting.removeRecentDocument(t)}),n.handle("setting.addRecentFolder",(e,t)=>{x.setting.addRecentFolder(t)}),n.handle("setting.getRecentFiles",e=>JSON.stringify({files:x.setting.getRecentDocuments()||[],folders:x.setting.getRecentFolders()||[]})),n.handle("setting.put",(e,t,n)=>{x.setting.put(t,n)}),n.handle("setting.get",(e,t)=>x.setting.get(t)),n.handle("setting.fetchAnalytics",e=>{var t=JSON.stringify(x.setting.analyticsEvents);return x.setting.analyticsEvents=[],t}),null),B=(n.handle("setting.getUnsavedDraftsPath",e=>x.setting.getUnsavedDraftPath()),e.prototype.getUnsavedDraftPath=function(){return N?Promise.resolve(N):(N=F(541).resolve(x.getPath("userData"),"draftsRecover"),F(728).ensureDir(N).then(()=>N))},function(e,t,n){t&&console.info(t.stack||t.message),e=e||{},console.error(e.stack||e.message),!x.isReady()||"ENOTFOUND"!=(t=e.errno||e.code)&&"ETIMEDOUT"!=t&&"ECONNRESET"!=t&&0!=(e.message||"").indexOf("net::ERR")&&(dialog=F(134).dialog,stack=null!=(ref=e.stack)?ref:e.name+": "+e.message,message="Uncaught Exception:\n"+stack,dialog.showMessageBox(null,{type:"error",buttons:["OK","Learn Data Recovery"],defaultId:0,cancelId:0,title:"A JavaScript error occurred in the main process",message:message}).then(({response:e})=>{1==e?(e=x.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",s.openExternal(`https://support.${e}/Version-Control/`)):process.exit(1)}))});function z(t,n){p.getAllWindows().forEach(function(e){e.isDestroyed()||e.webContents.isDestroyed()||e.webContents.isLoading()||e.webContents.send(t,n)})}function J(e,t){t=e.indexOf(t);-1{},()=>{}),console.error(e),I.captureException(e)}}catch(e){console.error(e),I.captureException(e)}try{o.userDictionaryPath?(e=await T.readFile(this.userDictionaryPath+"/user-dict.json","utf8"),o.userDict=JSON.parse(e)):console.error("no userDictionaryPath found")}catch(e){console.warn("user-dict.json not found")}function r(){o.userDictionaryPath&&F(833).writeFile(o.userDictionaryPath+"/user-dict.json",JSON.stringify(o.userDict),function(){}),x.sendEvent("user-dict-update",o.userDict)}n=S.ipcMain;n.on("user-dict-add",function(e,t){var{lang:t,word:n}=t;o.userDict[t]=o.userDict[t]||[],-1==o.userDict[t].indexOf(n)&&o.userDict[t].push(n),r()}),n.on("user-dict-remove",function(e,t){o.userDict[t.lang]=(o.userDict[t.lang]||[]).filter(function(e){return e!=t.word}),r()})},e.prototype.buildOption=async function(){var t={},e=(t.supportTextBundle=this.supportTextBundle,t.enableInlineMath=this.get("enable_inline_math")||!1,t.enableHighlight=this.get("enable_highlight")||!1,t.enableSubscript=this.get("enable_subscript")||!1,t.enableSuperscript=this.get("enable_superscript")||!1,t.enableDiagram=0!=this.get("enable_diagram"),t.copyMarkdownByDefault=this.get("copy_markdown_by_default")||!1,t.showLineNumbersForFence=this.get("show_line_numbers_for_fence")||!1,t.noPairingMatch=this.get("no_pairing_match")||!1,t.autoPairExtendSymbol=this.get("match_pari_markdown")||!1,t.expandSimpleBlock=this.get("auto_expand_block")||!1,t.headingStyle=this.get("heading_style")||0,t.ulStyle=this.get("ul_style")||0,t.olStyle=this.get("ol_style")||0,t.scrollWithCursor=!this.get("no_mid_caret"),t.autoNumberingForMath=this.get("auto_numbering_for_math"),t.allowPhysicsConflict=this.get("allowPhysicsConflict"),t.noDisplayLinesInMath=this.get("noDisplayLinesInMath"),t.useRelativePathForImg=this.get("use_relative_path_for_img")||!1,t.relativePathWithDot=this.get("relativePathWithDot")||!1,t.allowImageUpload=this.get("allow_image_upload")||!1,t.defaultImageStorage=this.get("image_save_location")||null,"custom"==t.defaultImageStorage&&(t.defaultImageStorage=this.get("custom_image_save_location")),t.applyImageMoveForWeb=this.get("apply_image_move_for_web")||!1,t.applyImageMoveForLocal=!this.get("no_image_move_for_local"),t.preferCRLF=this.get("line_ending_crlf")||!1,t.sidebarTab=this.get("sidebar_tab")||"",t.useTreeStyle=this.get("useTreeStyle")||!1,t.strictMarkdown=this.get("strict_mode")||!1,t.noLineWrapping=this.get("no_line_wrapping")||!1,t.prettyIndent=this.get("prettyIndent")||!1,t.convertSmartOnRender=this.get("SmartyPantsOnRendering"),t.smartDash=this.get("smartDash"),t.smartQuote=this.get("smartQuote"),t.twoHyphensToEm=this.get("twoHyphensToEm")||!1,t.remapUnicodePunctuation=this.get("remapPunctuation"),t.indentSize=this.get("indentSize")||2,t.codeIndentSize=this.get("codeIndentSize")||4,t.enableAutoSave=this.get("enableAutoSave")||!1,t.saveFileOnSwitch=this.get("save_file_on_switch")||!1,t.presetSpellCheck=this.get("preset_spell_check")||"auto",t.autoCorrectMisspell=!1,this.config||{});t.monocolorEmoji=e.monocolorEmoji,t.userQuotesArray=this.get("userQuotesArray"),t.passiveEvents=!0,t.canCollapseOutlinePanel=this.get("can_collapse_outline_panel"),t.preLinebreakOnExport=this.get("preLinebreakOnExport"),t.preLinebreakOnExport=1==t.preLinebreakOnExport||"true"==t.preLinebreakOnExport,t.indentFirstLine=this.get("indentFirstLine"),t.hideBrAndLineBreak=this.get("hideBrAndLineBreak"),t.isFocusMode=this.get("isFocusMode"),t.isTypeWriterMode=this.get("isTypeWriterMode"),t.ignoreLineBreak=this.get("ignoreLineBreak")||!1,t.sendAnonymousUsage=this.get("send_usage_info"),t.useMirrorInCN=this.get("useMirrorInCN"),void 0!==t.sendAnonymousUsage&&null!==t.sendAnonymousUsage||(t.sendAnonymousUsage=!0),t.uuid=this.get("uuid"),t.appVersion=x.getVersion(),t.instance=C,t.devVersion=global.devVersion,t.hasLicense=E.getHasLicense(),t.userLocale=this.getUserLocale(),t.appLocale=x.getLocale(),t.sidebarWidth=this.get("sidebar-width"),t.caseSensitive=this.get("caseSensitive"),t.wholeWord=this.get("wholeWord"),t.useRegexp=this.get("useRegexp"),t.fileSearchCaseSensitive=this.get("fileSearchCaseSensitive"),t.fileSearchWholeWord=this.get("fileSearchWholeWord"),t.fileSearchUseRegexp=this.get("fileSearchUseRegexp"),t.wordCountDelimiter=this.get("wordCountDelimiter")||0;try{t.userPath=x.getPath("home")||""}catch(e){t.userPath=(D?process.env.USERPROFILE:"")||""}if(t.mainPath=global.addonPath||"",t.userDataPath=x.getPath("userData")||"",!this.tempPath){var n=x.getPath("temp");0{t.keys[e]=(m.getKeyAccelerator(e)||"").toLowerCase()}),t.mathFormatOnCopy=this.get("mathFormatOnCopy")||"svg",t.imageUploader=this.get("image_uploader"),t.customImageUploader=this.get("custom_image_uploader"),t.picgoAppPath=this.get("picgo_app_path"),t.noWarnigUploadDisabled=this.get("noWarnigUploadDisabled")||!1,t.noWarnigForMoveFile=this.get("noWarnigForMoveFile")||!1,t.noWarnigForMoveFileToList=this.get("noWarnigForMoveFileToList")||!1,t.noWarnigForDeleteFile=this.get("noWarnigForDeleteFile")||!1,t.noWarnigForTypeWriterMode=this.get("noWarnigForTypeWriterMode")||!1,t.noHintForOpenLink=this.get("noHintForOpenLink")||!1,t.noHintForUnibody=this.get("noHintForUnibody")||!1,t.noWarnigForFocusMode=this.get("noWarnigForFocusMode")||!1,t.noWarningForExportOverwrite=this.get("noWarningForExportOverwrite")||!1,t.noWarningForUpdateImageReference=this.get("noWarningForUpdateImageReference")||!1,t.hasUpdates=this.hasUpdates||!1,t.pandocPath=this.get("pandocPath")||"",t.buildTime=1676345080018,t.debug=this.get("debug"),t._lastExport=A,t.lineWiseCopyCut=this.get("lineWiseCopyCut")||!1,t},e.prototype.extraOption=async function(){var t=await this.buildOption();return t.restoreWhenLaunch=this.get("restoreWhenLaunch")||0,t.pinFolder=this.get("pinFolder"),t.enable_inline_math=t.enableInlineMath,t.enable_highlight=t.enableHighlight,t.enable_subscript=t.enableSubscript,t.enable_superscript=t.enableSuperscript,t.enableDiagram=0!=this.get("enable_diagram"),t.enable_diagram=t.enableDiagram,t.copy_markdown_by_default=!!this.get("copy_markdown_by_default"),t.show_line_numbers_for_fence=!!this.get("show_line_numbers_for_fence"),t.no_pairing_match=!!this.get("no_pairing_match"),t.match_pari_markdown=!!this.get("match_pari_markdown"),t.auto_expand_block=!!this.get("auto_expand_block"),t.heading_style=this.get("heading_style")||0,t.ul_style=this.get("ul_style")||0,t.ol_style=this.get("ol_style")||0,t.no_mid_caret=this.get("no_mid_caret"),t.auto_numbering_for_math=this.get("auto_numbering_for_math"),t.use_relative_path_for_img=this.get("use_relative_path_for_img"),t.relativePathWithDot=this.get("relativePathWithDot"),t.allow_image_upload=this.get("allow_image_upload"),t.image_save_location=this.get("image_save_location"),t.custom_image_save_location=this.get("custom_image_save_location"),t.apply_image_move_for_web=this.get("apply_image_move_for_web"),t.no_image_move_for_local=this.get("no_image_move_for_local"),t.line_ending_crlf=this.get("line_ending_crlf"),t.strict_mode=this.get("strict_mode"),t.no_line_wrapping=this.get("no_line_wrapping"),t.prettyIndent=this.get("prettyIndent"),t.SmartyPantsOnRendering=this.get("SmartyPantsOnRendering"),t.remapPunctuation=this.get("remapPunctuation"),t.save_file_on_switch=this.get("save_file_on_switch")||!1,t.preset_spell_check=this.get("preset_spell_check")||"auto",t.can_collapse_outline_panel=this.get("can_collapse_outline_panel"),t.send_usage_info=!1!==this.get("send_usage_info"),t.currentThemeFolder=x.getPath("userData")+(D?"\\":"/")+"themes",t.enableAutoUpdate=!1!==this.get("enableAutoUpdate"),t.autoUpdateToDev=this.get("autoUpdateToDev"),t.userLanguage=this.get("userLanguage"),t.image_uploader=this.get("image_uploader"),t.custom_image_uploader=this.get("custom_image_uploader"),t.picgo_app_path=this.get("picgo_app_path"),t.allThemes=this.allThemes,t.useSeparateDarkTheme=this.get("useSeparateDarkTheme")||!1,t.theme=this.get("theme")||"github.css",t.darkTheme=this.get("darkTheme")||"night.css",t.customExport=this.get("customExport"),["general","pdf","html","html-plain","image"].forEach(e=>{t["export."+e]=this.get("export."+e)}),(t.customExport||R).forEach(e=>{t["export."+e.key]=this.get("export."+e.key)}),t},n.handle("setting.getExtraOption",async e=>JSON.stringify(await x.setting.extraOption())),n.handle("setting.doDownloadPicgo",e=>{x.setting.doDownloadPicgo()}),n.handle("setting.getKeyBinding",e=>x.setting.config.keyBinding||{}),e.prototype.doDownloadPicgo=function(){w.initDict().then(function(){var e="https://github.com/typora/PicGo-cli/releases/download/latest/%@.zip".replace("%@",D?"x64"==process.arch?"win64":"win32":"linux");console.log(e);let n=F(541).normalize(x.getPath("userData")+"/picgo"),o=F(541).normalize(n+"/_picgo.zip");var i=new f(e,o,{title:w.getPanelString("Download"),text:w.getPanelString("Downloading…"),processOnComplete:.9});i.onSuccess=(e,t)=>{F(834)(o,{dir:n},function(e){t.value=1,t.text=w.getPanelString("Finished"),t.detail="",setTimeout(()=>{i.setCompleted()},2e3),T.unlink(o,()=>{})}),t.detail=w.getPanelString("Unzipping…")},i.onError=e=>{S.dialog.showErrorBox(w.getPanelString("Download"),e.message)},i.download()})};var V=null;e.prototype.useDarkTheme=function(){return V=S.nativeTheme.shouldUseDarkColors&&this.get("useSeparateDarkTheme")},e.prototype.useDarkThemeBefore=function(){return V},e.prototype.curTheme=function(){return this.useDarkTheme()?this.get("darkTheme")||"night.css":this.get("theme")||"github.css"},e.prototype.setCurTheme=function(e,t){return a.getApplicationMenu().getItem("Themes").submenu.items.map(function(e){e.checked=e.label==t}),this.useDarkTheme()?this.put("darkTheme",e):this.put("theme",e)},o.exports=e},587:(o,e,t)=>{var u,p=t(134),h=p.app,n=p.ipcMain,g=p.BrowserWindow,m=(t(445),t(468)),f=(process.platform,"linux"==process.platform),w=t(541).join(__dirname,"../");n.handle("window.setTitle",(e,t,n)=>{e=g.fromWebContents(e.sender);t=t||("Typora"===(t=e.getTitle())?"Untitled"+(n?"• - Typora":" - Typora"):t.replace(/•? - Typora$/,n?"• - Typora":" - Typora")),e.setTitle(t)}),n.handle("window.focus",e=>{e=g.fromWebContents(e.sender);return e.focus(),e.webContents.focus(),!0}),n.handle("window.setInSourceMode",(e,t)=>{g.fromWebContents(e.sender).inSourceMode=!!t}),n.handle("window.minimize",e=>{g.fromWebContents(e.sender).minimize()}),n.handle("window.close",e=>{g.fromWebContents(e.sender).close()}),n.handle("window.restore",e=>{e=g.fromWebContents(e.sender);e.unmaximize(),e.setFullScreen(!1)}),n.handle("window.maximize",e=>{g.fromWebContents(e.sender).maximize()}),n.handle("window.fullscreen",e=>{e=g.fromWebContents(e.sender);return e.setFullScreen(!0),e.isFullScreen()}),n.handle("window.setMenuBarVisibility",(e,t)=>{g.fromWebContents(e.sender).setMenuBarVisibility(t)}),n.handle("window.pin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!0)}),n.handle("window.unpin",e=>{g.fromWebContents(e.sender).setAlwaysOnTop(!1)}),n.handle("window.updateMenuForIsAlwaysOnTop",e=>{e={"View→Always on Top":{state:g.fromWebContents(e.sender).isAlwaysOnTop()}};h.updateMenu(e)}),n.handle("window.toggleDevTools",e=>{e=g.fromWebContents(e.sender);e.webContents.isDevToolsOpened()?e.webContents.closeDevTools():e.webContents.openDevTools()}),n.handle("window.inspectElement",(e,t,n)=>{g.fromWebContents(e.sender).inspectElement(t,n)}),n.handle("window.checkAsFocus",e=>{e=g.fromWebContents(e.sender);e&&e.isFocused&&(h.currentFocusWindowId=e.id)}),n.handle("controller.switchFolder",(e,t)=>{e=g.fromWebContents(e.sender);h.switchFolder(t,e)}),n.handle("webContents.copy",e=>{g.fromWebContents(e.sender).webContents.copy()}),n.handle("webContents.cut",e=>{g.fromWebContents(e.sender).webContents.cut()}),n.handle("webContents.paste",e=>{g.fromWebContents(e.sender).webContents.paste()}),n.handle("webContents.selectAll",e=>{g.fromWebContents(e.sender).webContents.selectAll()}),n.handle("webContents.undo",(e,t)=>{g.fromWebContents(e.sender).webContents.undo()}),n.handle("webContents.redo",(e,t)=>{g.fromWebContents(e.sender).webContents.redo()}),n.handle("webContents.clearCache",(e,t)=>{var n=g.fromWebContents(e.sender);return new Promise(e=>{n.webContents.session.clearCache(e)})}),n.handle("webContents.action",(e,t)=>{g.fromWebContents(e.sender).webContents[t]()}),e.makeWindow=async(d,e)=>{var t=h.getDocumentController();e=e||{};var n,o,i=g.getFocusedWindow(),r=h.setting.config||{},a=t.lastClosedBounds,l=(i=i&&!t.getDocumentFromWindowId(i.id)?null:i)&&i.getBounds(),s=0,l=(a||(l?(s=i.isMaximized()||i.isFullScreen()?0:30,a={fullscreen:i.isFullScreen(),maximized:i.isMaximized()},s&&(a.x=l.x+s,a.y=l.y+s,a.width=l.width,a.height=l.height)):a=u?(s=u.fullscreen||u.maximize?0:30,{x:u.x+s,y:u.y-s,width:u.width,height:u.height,fullscreen:u.fullscreen,maximized:u.maximized}):{}),!a.fullscreen&&a.maximized),e={x:a.x,y:a.y,width:a.width||800,height:a.height||700,minWidth:400,minHeight:400,frame:!h.setting.get("framelessWindow"),disableAutoHideCursor:!1,backgroundColor:h.setting.get("backgroundColor"),webPreferences:{webSecurity:!1,allowRunningInsecureContent:!1,plugins:!1,nodeIntegration:!0,enableRemoteModule:!1,webviewTag:!0,nodeIntegrationInWorker:!0,devTools:!0,images:!0,directWrite:r.directWrite,defaultFontFamily:r.defaultFontFamily,allowDisplayingInsecureContent:!1,backgroundThrottling:!1,spellcheck:!1,contextIsolation:!1,additionalArguments:["--tyopt="+JSON.stringify({isMaximized:l,isFullScreen:a.fullscreen,...await h.setting.buildOption(),...e})]},autoHideMenuBar:a.fullscreen||r.autoHideMenuBar,show:d,fullscreen:a.fullscreen,alwaysOnTop:i&&i.isAlwaysOnTop(),fullscreenable:!0},c=(f&&(e.icon=w+"/assets/icon/icon_256x256.png"),r=e,i=0s.y+s.height&&(r.y=s.y+s.height-r.height),r.xs.x+s.width&&(r.x=i?s.x:s.x+s.width-r.width)),u=e,l&&(e.show=!1),new g(e));return t.lastClosedBounds=null,l&&(c.maximize(),d&&c.show()),a.fullscreen&&(c.autoHideMenuBar=!0,c.setMenuBarVisibility(!1)),c.loadURL(entry||"".substring(1)),n=c,o=p.shell,n.webContents.on("will-navigate",function(e,t){e.preventDefault(),o.openExternal(t)}),n.webContents.setWindowOpenHandler(e=>(/^https?:/.exec(e.url)&&o.openExternal(e.url),{action:"deny"})),n.webContents.on("crashed",function(e,t){console.error("render process is killed? "+t),m.captureMessage("render process crashed, killed="+t),h.setting.addAnalyticsEvent("crashed")}),n.webContents.on("unresponsive",function(){m.captureMessage("unresponsive",{extra:{winId:n.id}}),h.setting.addAnalyticsEvent("unresponsive")}),n.webContents.setMaxListeners(15),n.webContents.on("dom-ready",function(){n.isMaximized()&&n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");'),b("dom-ready",n)}),n.on("maximize",()=>{n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");')}),n.on("enter-full-screen",function(){n.webContents.executeJavaScript('document.body.classList.add("typora-maxmized");document.body.classList.add("typora-fullscreen");if(document.body.classList.contains("native-window")) {$("#ty-top-placeholder").show();};1;')}),n.on("unmaximize",function(){n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");')}),n.on("session-end",function(){console.log("[win] session-end"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),n.on("leave-full-screen",function(){n.autoHideMenuBar=!!h.setting.config.autoHideMenuBar,n.setMenuBarVisibility(!h.setting.config.autoHideMenuBar),n.webContents.executeJavaScript('document.body.classList.remove("typora-maxmized");document.body.classList.remove("typora-fullscreen");$("#ty-top-placeholder").hide();1;'),u&&(u.fullscreen=!1)}),n.on("focus",function(){n.webContents.incrementCapturerCount();var e=t.getDocumentFromWindowId(n.id);e&&(e.setActiveWindow(n),h.focusedWindow=n)}),n.on("blur",()=>{console.log("[win] blur"),n.webContents.executeJavaScript("if(File.backupWindow){File.backupWindow(true);File.saveAndBackup()};1;")}),b("make-window"),c};const i=t(93);var r=new i;const b=function(e,t){r.emit(e,t)};e.on=function(e,t){r.on(e,t)},e.showPanelWindow=function({path:e,...t}){var n=new g({modal:!0,show:!1,center:!0,resizable:!1,webPreferences:{devTools:!global.releaseMode,defaultFontSize:14,nodeIntegration:!0,contextIsolation:!1,enableRemoteModule:!1},...t});return n.loadURL("file://"+w+"/"+e),n.once("ready-to-show",function(){n.show()}),n.removeMenu(),f&&(n.icon=w+"/assets/icon/icon_256x256.png"),n.webContents.setWindowOpenHandler(e=>(p.shell.openExternal(e.url),{action:"deny"})),n}},90:(e,o,s)=>{e=s.nmd(e);var t,i=s(541),n=s(640),r=(t=i.join(__dirname,"../"),i.join(t,"node_modules.asar")),a=(n.globalPaths.push(r),n.prototype.require);n.prototype.require=function(e){return-1==this.paths.indexOf(__dirname)&&(this.paths.push(__dirname),this.paths.push(r)),/(\.node$)|(\/build\/Release)/.exec(e)&&"."==e[0]&&(e=i.resolve(i.dirname(this.id),e).replace(/\bnode_modules\.asar\b/,"node_modules")),a.call(this,e)};for(let e=0;e{c.exit()},1e3),s(405);var n=s(134),c=n.app,l=n.protocol,m=n.powerMonitor,d=n.BrowserWindow,u=s(728),f="win32"==process.platform,w=(process.platform,process.platform,s(557),s(344)),b=s(883),e=s(932),y=s(445),p=s(351),n=n.ipcMain;s(468);if(!c.requestSingleInstanceLock())return console.record("secondary instance would exit"),void c.quit();console.record("launch with argv ["+process.argv.join(", ")+"]"),c.on("second-instance",function(e,t,n){console.record("got argv ["+t.join(", ")+"] from secondary instance"),t=Array.from(t),d.getAllWindows().length&&((n=F(t,n))?c.openFileOrFolder(n,{forceCreateWindow:!n}):T(t||[]))});var v=1,k=2,C=3;function F(e,t){null==t&&(t=process.cwd());for(var n,o=e.length-1;0<=o;o--)if("-"!=e[o][0]&&!/\.asar$/.exec(e[o]||"")){n=e[o];break}if((n=0!=o&&n!=t?n:void 0)&&/^file:\/\//i.exec(n)){n=n.replace(/^file:\/\//i,"");try{n=decodeURI(n)}catch(e){}}return n?s(541).resolve(t,n):void 0}function S(e){if(!e)return e;var t=e.length;return 50((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFile(t||null,n).then(n=>{if(n)return new Promise(e=>{let t=n.activeWindow.webContents;t.isLoading()?t.once("did-finish-load",function(){e({winId:n.activeWindow.id})}):e({winId:n.activeWindow.id})})}))),n.handle("app.openFileOrFolder",(e,t,n)=>((n=n||{}).curWindow&&(n.curWindow=d.fromWebContents(e.sender)),c.openFileOrFolder(t||null,n))),n.handle("app.openOrSwitch",async(e,t,n)=>{var o,e=d.fromWebContents(e.sender),i=c.documentController.getDocument(t),r=c.documentController.getDocumentFromWindowId(e.id);if(i)return(o=i.activeWindow||i.windows.keys().next().value)&&o.focus(),!1;if(n)return c.openFileOrFolder(t,{curWindow:!0}),!1;if(await O(t))c.switchFolder(t,e);else if(!i)return r.rename(t),!0;return!1}),n.handle("app.openFolder",(e,t,n)=>{c.openFolder(t||null,n?d.fromWebContents(e.sender):void 0)}),n.handle("app.onCloseWin",(e,t)=>{e=d.fromWebContents(e.sender);c.onCloseWin(e.id,t)}),n.handle("app.sendEvent",(e,t,n)=>{c.sendEvent(t,n)}),n.handle("executeJavaScript",(e,t,n)=>{d.fromId(t).webContents.executeJavaScript(n)}),c.reopenFolder=function(){var t=new Set,n=!1;return g.forEach(function(e){e.mountFolder&&!t.has(e.mountFolder)&&(t.add(e.mountFolder),c.openFile(null,{forceCreateWindow:!0,mountFolder:e.mountFolder}),n=!0)}),n},c.reopenClosed=function(o){var i=!1;return g.length&&g.forEach(function(e,t){var n=c.getDocumentController().getDocument(e.path);n?n.activeWindow&&n.activeWindow.show():(c.openFile(e.path,{forceCreateWindow:!!t,mountFolder:e.mountFolder,silent:o,backupState:e,fromReopen:!0}),i=!0)}),i},function(e){var t,n=c.setting.get("restoreWhenLaunch")||0,o=!0,i=e||process.argv||[];-1{/^--/.exec(e)&&("--on-dev"==e?process.traceDeprecation=!0:-1===["--new","--reopen-file"].indexOf(e)&&c.commandLine.appendSwitch.apply(null,[e]))}),scheme||"".substring(3));c.on("ready",async function(){var e,t;await c.setting.initSetting(),c.expired||(p.lastClosedBounds=c.setting.get("lastClosedBounds"),console.record("------------------start------------------"),console.log("typora version: "+c.getVersion()),console.log(""+s.c[s.s].filename),M(P),c.setAppUserModelId("abnerworks.Typora"),(e=F(process.argv))&&"--on-dev"!==process.argv[process.argv.length-1]?c.openFileOrFolder(e):c.recoverFromBackup(),w.loadDict().then(()=>{w.bindMainMenu()}),f&&(t=s(558),c.updater=t,setTimeout(function(){t.initUpdater().then(function(){!1!==c.setting.get("enableAutoUpdate")&&c.updater.checkForUpdates(!1)})},3e3)),b.bindJumplist(),setTimeout(function(){try{E()}catch(e){console.warn(e.stack)}},3e4),m.on("suspend",()=>{console.record("[Power] suspend"),c.execInAll('window.onPowerChange && window.onPowerChange("suspend")')}),m.on("resume",()=>{console.record("[Power] resume"),c.execInAll('window.onPowerChange && window.onPowerChange("resume")')}),m.on("lock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("lock-screen")')}),m.on("unlock-screen",()=>{console.record("[Power] lock-screen"),c.execInAll('window.onPowerChange && window.onPowerChange("unlock-screen")')}))});var I,W={},E=async function(){var r,a,l,s,n=await c.setting.getUnsavedDraftPath(),e=await u.readdir(n);e.length<200||(console.record("cleanUpExpiredDrafts"),400{var o=[],i=async function(){Math.min(l+50,a.length);if(l+1>=a.length)n(o);else{for(;l++;){if(!a[l])return void n(o);try{var e=r+"/"+a[l],t=await u.stat(e);864e6{try{return{name:e,time:W[e]||(await u.stat(n+"/"+e)).mtime.getTime()}}catch(e){}return{name:e,time:0}})),W=null,e.sort(function(e,t){return t.time-e.time}).forEach(function(e,t){150{D=!1}),c.on("quit",function(){console.log("-----------------quit------------------"),c.setting.closeLogging()}),c.on("will-quit",function(){console.log("------------------will-quit------------------"),h&&clearTimeout(h),I&&clearTimeout(I),f&&c.updater&&c.updater.installIfNeeded(),c.setting.syncAll();try{u.rmSync(c.getPath("userData")+"/runtime-storage",{recursive:!0,force:!0})}catch(e){console.error(e)}try{var e=c.getPath("userData")+"/typora.log",t=c.getPath("userData")+"/typora-old.log",n=u.statSync(e);n&&5e5p.getDocumentFromWindowId(n.id)):l()}).then(function(e){return e})}return l()},c.sendEvent=function(t,n){d.getAllWindows().forEach(function(e){e.webContents.send(t,n)}),c.onMessage(t,n)},c.execInAll=function(t){d.getAllWindows().forEach(function(e){e.webContents.executeJavaScript(t)})},c.onMessage=function(e,t){"didRename"==e?c.setting.renameRecentDocuments(t.oldPath,t.newPath):"updateQuickOpenCache"==e&&t.toDel&&c.setting.renameRecentDocuments(t.toDel,null)},c.refreshMenu=function(){w.refreshMenu()},{});n.handle("app.download",(e,t,n,o)=>{var i,r,a=s(541),l=d.fromWebContents(e.sender),e=s(554),o=o||(e=>{var t=s(426),n=s(541),t=t.parse(e),e=n.basename(t.pathname);try{var o=decodeURIComponent(e);if(o!=e)return n.basename(o)}catch(e){}return e})(t),a=a.join(n,o);return u.existsSync(a)&&(i=a,r=s(541),a=i.replace(/(\.[^.\/\\]+?$)/,"")+"-"+ +new Date+r.extname(i)),_[l.id+t]||(_[l.id+t]=e.download(l,t,{showBadge:!1,directory:n,filename:o})),setTimeout(()=>{delete _[l.id+t]},10),Promise.race([_[l.id+t].then(e=>({path:e.getSavePath(),state:e.getState(),type:e.getMimeType()}),()=>({path:t,state:"error"})),new Promise(e=>{setTimeout(()=>{e({path:t,state:"timeout"})},3e4)})])});var M=function(e){l.registerFileProtocol(e,function(e,t){e.url?t({path:c.getRealPath(e.url)}):t({error:-324})}),l.registerBufferProtocol("typora-bg",function(e,t){var n=c.setting.get("backgroundColor");t(n?{mimeType:"text/css",data:Buffer.from(`body {background:${n};`)}:{mimeType:"text/css",data:Buffer.from("")})})};c.getRealPath=function(e){try{e=decodeURI(e)}catch(e){}e=e.substr(13);return/^userData/.exec(e)&&(e=e.replace(/^userData/,c.getPath("userData").replace(/\\/g,"\\\\"))),/current-theme\.css$/.exec(e)&&(e=e.replace(/current-theme\.css$/,c.setting.curTheme())),/^typemark/i.exec(e)&&(e=e.replace(/^typemark/,t)),e=(e=/preview\.html/.exec(e)?e.replace(/\.html[?#].*$/,".html"):e).replace(/[?#][^\\\/]*$/,"")},c.filesOp=e,P&&l.registerSchemesAsPrivileged([{scheme:P,privileges:{standard:!0,secure:!0,supportFetchAPI:!0,bypassCSP:!0,corsEnabled:!0,stream:!0}}])},344:(t,n,h)=>{function r(e,t){return function(){k(e,t)}}var i,a=h(134),l=a.app,g=a.dialog,s=a.Menu,c=a.MenuItem,m=a.BrowserWindow,e=a.ipcMain,f=h(728),d="win32"==process.platform,w="darwin"==process.platform,b="linux"==process.platform,y=h(445),u=h(541).join(__dirname,"../"),v=(e.on("execForAll",function(e,t){v(t)}),e.on("forceRefreshMenu",function(e,t){l.forceRefreshMenu()}),e.on("syncToPreference",function(e,t){a.webContents.getAllWebContents().forEach(function(e){e.send("syncToPreference",t)})}),n.loadDict=()=>{var o,e;return i?Promise.resolve(i):(o=l.setting.getUserLocale(),e=h(541).join(u,l.setting.getLocaleFolder("Menu")),new Promise(n=>{f.readFile(e,"utf8",(e,t)=>{i=t?JSON.parse(t):{},n(i),e&&console.warn("cannot load dict as ["+o+"] "+e.stack)})}))},function(e){var t=e=e.toString();/^\s*function\s*\(/.exec(e)&&(t="window.File && ("+e+")();"),l.execInAll(t),console.log(t)}),k=function(e,t){var n=m.getFocusedWindow();n&&(t?n.webContents.executeJavaScript("window.File && !File.blockUI && ("+e.toString()+")();0;"):n.webContents.executeJavaScript("!File.blockUI && window.ClientCommand['"+e+"']();0;"),n.webContents.executeJavaScript("window.Reporter && window.Reporter.fullValidate();File.editor && File.editor.contextMenu && File.editor.contextMenu.hide();0;"))};function C(e){var t=/&[a-z]/i.exec(e),n=/(\.\.\.)|(…)/.exec(e),o=(e=e.replace(/(\.\.\.)|(…)|&/g,""),(i||{})[e]||e);return t?function(e,t){e=S[e];if(!e)return t;{var n,o;(d||b)&&(-1==(n=t.indexOf(e))?n=t.indexOf(e.toLowerCase()):-1<(o=t.indexOf(e.toLowerCase()))&&(n=Math.min(n,o)),-1{setTimeout(o,0)}))),e}function x(e,t){return p(e={label:e,accelerator:t}),e.accelerator}function D(e){function n(e,t){e=e.label;f.existsSync(e)?l.openFileOrFolder(e,{curWindow:t}):(g.showMessageBox({title:C("Open Failed"),message:C("File or folder does not exist."),buttons:["Close"],cancelId:0,defaultId:0}),l.setting.removeRecentDocument(e))}try{var o=e.getItem("File").submenu.getItem("Open Recent").submenu,t=l.setting.getRecentDocuments(),i=l.setting.getRecentFolders();t.sort(function(e,t){return t.date-e.date}),i.sort(function(e,t){return t.date-e.date}),o.clear(),o.append(new c({label:C("Reopen Closed File"),accelerator:"CmdOrCtrl+Shift+T",click:function(){l.reopenClosed()}})),o.append(new c({type:"separator"})),t.length&&(t.forEach(function(e,t){10{e.type&&(hasCustom=!0,o.push({label:e.name,click:t(e)}))}),o.push({type:"separator"}),o.push({label:"Export with Previous",accelerator:"Shift+Ctrl+E",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast();")},enabled:!!l.setting.lastExport}),o.push({label:"Export and Overwrite with Previous",click:function(e,t){t&&t.webContents.executeJavaScript("ClientCommand && ClientCommand.exportLast(true)")},enabled:!!l.setting.lastExport}),o.push({type:"separator"}),o.push({label:"Export Setting…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('export-setting-group');")},enabled:!0}),e&&(o.forEach(p),n=P("File→Export").submenu,o[o.length-1].enabled=(I("Export and Overwrite with Previous",n)||{}).enabled,n.clear(),o.forEach(e=>{n.append(new c(e))}),w&&s.setApplicationMenu(s.getApplicationMenu())),o}function P(e){if(!e)return null;var t,n=(W=W||{})[e];return n||(e.split("→").forEach(function(e){if(n=I(e,n),!(W[t=t?t+"→"+e:e]=n))return null}),W=null,n)}function I(e,t){var n,o=t?t.submenu:s.getApplicationMenu();return o?(n=o.getItem(e),t||n||"File"!=e?n:o.getItem("Typora")||o.getItem("Electron")):null}var W,o=null;l.forceRefreshMenu=function(){b&&(o&&clearTimeout(o),o=setTimeout(function(){s.setApplicationMenu(s.getApplicationMenu()),o=null},100))};l.updateMenu=function(e){W={};for(var t in e){var n,o,i=P(t),r=e[t];i&&(n=null,void 0!==r.accelerator&&(r.accelerator,o=x(i.label,r.accelerator),i=n=o!=i.accelerator?new c(p({label:i.label,type:i.type,enabled:i.enabled,checked:i.enabled,click:i.click,accelerator:o})):n),"Paragraph→Table"!=t?(void 0!==r.state&&(i.checked=r.state),void 0!==r.enabled&&(i.enabled=r.enabled,"Paragraph"!=t&&"Format"!=t&&"Format→Image→Zoom Image"!=t||i.submenu.items.forEach(function(e){e.enabled=r.enabled})),void 0!==r.hidden&&(i.visible=!r.hidden),!n||-1<(t=(o=P(t.replace(/→[^→]+$/,"")).submenu.items).findIndex(e=>e.label==n.label))&&(o.splice(t,1,n),console.log("newItem.accelerator "+n.accelerator))):(function(e,n){n.enabled||n.state?(e.enabled=!0,e.submenu.items.forEach(function(e,t){e.enabled=0==t?!n.state:n.state})):e.enabled=!1}(i,r),0))}W=null,l.forceRefreshMenu()},e.on("menu.updateMenu",function(e,t){l.updateMenu(JSON.parse(t))}),e.handle("menu.updateCustomZoom",e=>{l.updateMenu({"View→Actual Size":{state:!l.setting.get("customZoom")}})}),e.handle("menu.refreshThemeMenu",function(e){l.setting.refreshThemeMenu()}),e.handle("menu.reloadExportMenu",function(e){T(!0)}),e.handle("menu.popup",function(e,t){s.getApplicationMenu().popup(t)}),n.bindMainMenu=function(){function e(e,t){e=(/\((.+)\)/.exec(e.label)||[])[1]||e.label;e==C("Auto")&&(e=""),k("function(){File.reloadWithEncoding('"+e+"')}",!0)}var t=l.setting.get("SmartyPantsOnRendering")||!1,n=l.setting.get("smartQuote")||!1,o=l.setting.get("smartDash")||!1,t=[p({label:"&File",submenu:[{label:"New",accelerator:"CmdOrCtrl+N",click:r("newFile")},{label:"New Window",accelerator:"CmdOrCtrl+Shift+N",click:r("newWindow")},{type:"separator"},{label:"Open…",accelerator:"CmdOrCtrl+O",click:r("open")},{label:"Open Folder…",click:r("openFolder")},{type:"separator"},{label:"Open Quickly…",accelerator:"CmdOrCtrl+P",click:r("quickOpen")},{label:"Open Recent",submenu:[]},{label:"Reopen with Encoding",submenu:[{label:"Auto",click:e},{type:"separator"},{label:"UTF-8",click:e},{label:"UTF-16 LE",click:e},{label:"UTF-16 BE",click:e},{type:"separator"},{label:"Western (windows-1252)",click:e},{label:"Cyrillic (windows-1251)",click:e},{label:"Cyrillic (ISO-8859-2)",click:e},{label:"Cyrillic (IBM866)",click:e},{label:"Cyrillic (IBM855)",click:e},{label:"Cyrillic (KOI8-R)",click:e},{label:"Cyrillic (MacCyrillic)",click:e},{label:"Central European (windows-1250)",click:e},{label:"Central European (ISO-8859-2)",click:e},{label:"Geek (windows-1253)",click:e},{label:"Geek (ISO-8859-7)",click:e},{label:"Hebrew (windows-1255)",click:e},{label:"Hebrew (ISO-8859-8)",click:e},{label:"Chinese Simplified (GB2312)",click:e},{label:"Chinese Simplified (GB18030)",click:e},{label:"Chinese Traditional (Big5)",click:e},{label:"Japanese (SHIFT_JIS)",click:e},{label:"Japanese (EUC-JP)",click:e},{label:"Korean (EUC-KR)",click:e},{label:"Thai (TIS-620)",click:e}]},{type:"separator"},{label:"Save",accelerator:"CmdOrCtrl+S",click:r("save")},{label:"Save As…",accelerator:"CmdOrCtrl+Shift+S",click:r("saveAs")},{label:"Move To…",click:r("moveTo")},{label:"Save All…",click:r("saveAll")},{type:"separator"},d?{label:"Properties…",click:function(e,t){t&&t.webContents.executeJavaScript("File.winShell().openProperties(File.bundle.filePath);")}}:null,{label:"Open File Location…",click:r("openFileLocation")},{label:"Reveal in Sidebar",click:r(function(){window.File.editor.library.revealInSidebar()},!0)},{label:"Delete…",click:function(e,t){t&&t.webContents.executeJavaScript("File.trashSelf();")}},{type:"separator"},{label:"Import…",click:r("import")},{label:"Export",submenu:T()},{label:"Print…",accelerator:"Shift+Alt+P",click:r("print")},{type:"separator"},{label:"Preferences…",accelerator:"CmdOrCtrl+,",click:r("togglePreferencePanel")},{type:"separator"},{label:"Close",accelerator:"CmdOrCtrl+W",click:r("close")}]}),p({label:"&Edit",id:"edit",submenu:[{label:"Undo",id:"undo",accelerator:"CmdOrCtrl+Z",click:r("undo")},{label:"Redo",id:"redo",accelerator:"CmdOrCtrl+Y",click:r("redo")},{type:"separator"},{label:"Cut",accelerator:"CmdOrCtrl+X",role:"cut"},{label:"Copy",accelerator:"CmdOrCtrl+C",role:"copy"},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Paste",accelerator:"CmdOrCtrl+V",role:"paste"},{type:"separator"},{label:"Copy as Plain Text",click:r("copyAsPlainText")},{label:"Copy as Markdown",accelerator:"CmdOrCtrl+Shift+C",click:r("copyAsMarkdown")},{label:"Copy as HTML Code",click:r("copyAsHTMLSource")},{label:"Copy without Theme Styling",click:r("copyAsSemanticHTML")},{type:"separator"},{label:"Paste as Plain Text",accelerator:"CmdOrCtrl+Shift+v",click:r("pasteAsPlain")},{type:"separator"},{label:"Selection",submenu:[{label:"Select All",accelerator:"CmdOrCtrl+A",click:r("selectAll")},{label:"Select Paragraph / Block",accelerator:"CmdOrCtrl+Alt+P",click:r(function(){File.editor.selection.selectBlock()},!0)},{label:"Select Line / Sentence",accelerator:"CmdOrCtrl+L",click:r(function(){File.editor.selection.selectLine()},!0)},{label:"Select Styled Scope",accelerator:"CmdOrCtrl+E",click:r(function(){File.editor.selection.selectPhrase()},!0)},{label:"Select Word",accelerator:"CmdOrCtrl+D",click:r(function(){File.editor.selection.selectWord()},!0)},{type:"separator"},{label:"Jump to Top",accelerator:"Ctrl+Home",click:r(function(){File.editor.selection.jumpTop()},!0)},{label:"Jump to Selection",accelerator:"CmdOrCtrl+j",click:r(function(){File.editor.selection.jumpSelection()},!0)},{label:"Jump to Bottom",accelerator:"Ctrl+End",click:r(function(){File.editor.selection.jumpBottom()},!0)},{label:"Extend Selection to Top",accelerator:"Ctrl+Shift+Home",visible:!1,click:r(function(){File.editor.selection.jumpTop(!0)},!0)},{label:"Extend Selection to Bottom",accelerator:"Ctrl+Shift+End",visible:!1,click:r(function(){File.editor.selection.jumpBottom(!0)},!0)},{label:"Extend Selection to Line Start",accelerator:"Shift+Home",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!1)},!0)},{label:"Extend Selection to Line End",accelerator:"Shift+End",visible:!1,click:r(function(){File.editor.selection.extendToLineEdge(!0)},!0)}]},{type:"separator"},{label:"Delete",click:r(function(){File.delete()},!0)},{label:"Delete Range",submenu:[{label:"Delete Paragraph / Block",accelerator:"Shift+CmdOrCtrl+Alt+P",click:r("deleteBlock")},{label:"Delete Line / Sentence",accelerator:"Shift+CmdOrCtrl+Alt+L",click:r("deleteLine")},{label:"Delete Styled Scope",accelerator:"Shift+CmdOrCtrl+Alt+E",click:r("deleteScope")},{label:"Delete Word",accelerator:"Shift+Ctrl+D",click:r("deleteWord")}]},{type:"separator"},{label:"Math Tools",submenu:[{label:"Refresh All Math Expressions",click:r(function(){File.editor.mathBlock.forceRefresh()},!0)}]},{type:"separator"},{label:"Smart Punctuation",submenu:[{label:"Convert on Input",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+!e+")"))},checked:!t},{label:"Convert on Rendering",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartyPantsTiming("+e+")"))},checked:t},{type:"separator"},{label:"Smart Quotes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartQuote("+e+")"))},checked:n},{label:"Smart Dashes",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setSmartDash("+e+")"))},checked:o},{type:"separator"},{label:"Remap Unicode Punctuation on Parse",type:"checkbox",click:function(e,t){t&&(e=e.checked,t.webContents.executeJavaScript("File.megaMenu.setRemapPunctuation("+e+")"))},checked:l.setting.get("remapPunctuation")||!t&&(n||o),enabled:!(!t&&(n||o))},{type:"separator"},{label:"More Options…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('smart-punctuation-group');")}}]},{label:"Line Endings",submenu:[{label:"Windows Line Endings (CRLF)",type:"checkbox",click:r(function(){File.setLineEnding(!0,!0)},!0)},{label:"Unix Line Endings (LF)",type:"checkbox",click:r(function(){File.setLineEnding(!1,!0)},!0)},{type:"separator"},{label:"Insert Final New Line On Save",type:"checkbox",click:function(e,t){t&&t.webContents.executeJavaScript("File.setFinalNewline("+e.checked+")")}}]},{label:"Whitespace and Line Breaks",submenu:[{label:"Indent first line of paragraphs",type:"checkbox",click:r(function(){File.setIndentFirstLine(!File.option.indentFirstLine,!0,!0)},!0)},{type:"separator"},{label:"Visible
",type:"checkbox",checked:!0,click:r(function(){File.setHideBrAndLineBreak(!File.option.hideBrAndLineBreak,!0,!0)},!0)},{label:"Preserve single line break",type:"checkbox",checked:!0,click:r(function(){File.setIgnoreLineBreak(!File.option.ignoreLineBreak,!0,!0)},!0)},{type:"separator"},{label:"Learn More…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/Line-Break/`)}}]},{label:"Spell Check…",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.spellChecker && File.editor.spellChecker.show();")}},{type:"separator"},{label:"Find and Replace",submenu:[{label:"Find…",accelerator:"CmdOrCtrl+f",click:r(function(){File.megaMenu.isPreferencePanelShown()?File.megaMenu.searchOnPreferencePanel():File.editor.searchPanel.showPanel()},!0)},{label:"Find Next",accelerator:"F3",click:r(function(){File.editor.searchPanel.highlightNext()},!0)},{label:"Find Previous",accelerator:"Shift+F3",click:r(function(){File.editor.searchPanel.highlightNext(!0)},!0)},{type:"separator"},{label:"Replace",accelerator:"Ctrl+h",click:r(function(){File.editor.searchPanel.showPanel(!0)},!0)}]}]}),p({label:"&Paragraph",submenu:[{label:"Heading 1",type:"checkbox",accelerator:"Ctrl+1",click:r(function(){File.editor.stylize.changeBlock("header1",void 0,!0)},!0)},{label:"Heading 2",type:"checkbox",accelerator:"Ctrl+2",click:r(function(){File.editor.stylize.changeBlock("header2",void 0,!0)},!0)},{label:"Heading 3",type:"checkbox",accelerator:"Ctrl+3",click:r(function(){File.editor.stylize.changeBlock("header3",void 0,!0)},!0)},{label:"Heading 4",type:"checkbox",accelerator:"Ctrl+4",click:r(function(){File.editor.stylize.changeBlock("header4",void 0,!0)},!0)},{label:"Heading 5",type:"checkbox",accelerator:"Ctrl+5",click:r(function(){File.editor.stylize.changeBlock("header5",void 0,!0)},!0)},{label:"Heading 6",type:"checkbox",accelerator:"Ctrl+6",click:r(function(){File.editor.stylize.changeBlock("header6",void 0,!0)},!0)},{type:"separator"},{label:"Paragraph",type:"checkbox",accelerator:"Ctrl+0",click:r(function(){File.editor.stylize.changeBlock("paragraph")},!0)},{type:"separator"},{label:"Increase Heading Level",accelerator:"Ctrl+=",click:r(function(){File.editor.stylize.increaseHeaderLevel()},!0)},{label:"Decrease Heading Level",accelerator:"Ctrl+-",click:r(function(){File.editor.stylize.decreaseHeaderLevel()},!0)},{type:"separator"},{label:"Table",submenu:[{label:"Insert Table",accelerator:"Ctrl+T",click:r(function(){File.editor.tableEdit.insertTable()},!0)},{type:"separator"},{label:"Add Row Above",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!0)},!0)},{label:"Add Row Below",accelerator:"Ctrl+Return",enabled:!1,click:r(function(){File.editor.tableEdit.addRow(!1)},!0)},{type:"separator"},{label:"Add Column Before",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{label:"Add Column After",enabled:!1,click:r(function(){File.editor.tableEdit.addCol(!1)},!0)},{type:"separator"},{label:"Move Row Up",enabled:!1,accelerator:"Alt+Up",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!0)},!0)},{label:"Move Row Down",enabled:!1,accelerator:"Alt+Down",click:r(function(){File.editor.tableEdit.moveRowUpOrDown(!1)},!0)},{label:"Move Column Left",enabled:!1,accelerator:"Alt+Left",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!0)},!0)},{label:"Move Column Right",enabled:!1,accelerator:"Alt+Right",click:r(function(){File.editor.tableEdit.moveColLeftOrRight(!1)},!0)},{type:"separator"},{label:"Delete Row",enabled:!1,accelerator:"Shift+Ctrl+Backspace",click:r(function(){File.editor.tableEdit.deleteRow()},!0)},{label:"Delete Column",enabled:!1,click:r(function(){File.editor.tableEdit.deleteCol()},!0)},{type:"separator"},{label:"Copy Table",enabled:!1,click:r(function(){File.editor.tableEdit.copyTable()},!0)},{label:"Prettify Source Code",enabled:!1,click:r(function(){File.editor.tableEdit.reformatTable()},!0)},{type:"separator"},{label:"Delete Table",enabled:!1,click:r(function(){File.editor.tableEdit.deleteTable()},!0)}]},{label:"Code Fences",type:"checkbox",accelerator:"Ctrl+Shift+K",click:r(function(){File.editor.stylize.toggleFences()},!0)},{label:"Math Block",type:"checkbox",accelerator:"Ctrl+Shift+M",click:r(function(){File.editor.stylize.toggleMathBlock()},!0)},{type:"separator"},{label:"Quote",type:"checkbox",accelerator:"Ctrl+Shift+Q",click:r(function(){File.editor.stylize.toggleIndent("blockquote")},!0)},{type:"separator"},{label:"Ordered List",type:"checkbox",accelerator:"Ctrl+Shift+[",click:r(function(){File.editor.stylize.toggleIndent("ol")},!0)},{label:"Unordered List",type:"checkbox",accelerator:"Ctrl+Shift+]",click:r(function(){File.editor.stylize.toggleIndent("ul")},!0)},{label:"Task List",type:"checkbox",accelerator:"Ctrl+Shift+X",click:r(function(){File.editor.stylize.toggleIndent("tasklist")},!0)},{label:"Task Status",submenu:[{label:"Toggle Task Status",click:r(function(){File.editor.stylize.toggleTaskStatus()},!0)},{type:"separator"},{label:"Mark as Complete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!0)},!0)},{label:"Mark as Incomplete",type:"checkbox",click:r(function(){File.editor.stylize.toggleTaskStatus(!1)},!0)}]},{label:"List Indentation",submenu:[{label:"Indent",accelerator:"CmdOrCtrl+]",click:r(function(){File.editor.UserOp.moreIndent(File.editor)},!0)},{label:"Outdent",accelerator:"CmdOrCtrl+[",click:r(function(){File.editor.UserOp.lessIndent(File.editor)},!0)}]},{type:"separator"},{label:"Insert Paragraph Before",click:r(function(){File.editor.UserOp.insertParagraph(!0)},!0)},{label:"Insert Paragraph After",click:r(function(){File.editor.UserOp.insertParagraph(!1)},!0)},{type:"separator"},{label:"Link Reference",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_link")},!0)},{label:"Footnotes",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("def_footnote")},!0)},{type:"separator"},{label:"Horizontal Line",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("hr")},!0)},{label:"Table of Contents",type:"checkbox",click:r(function(){File.editor.stylize.insertBlock("toc")},!0)},{label:"YAML Front Matter",type:"checkbox",click:r(function(){File.editor.stylize.insertMetaBlock()},!0)}]}),p({label:"F&ormat",submenu:[{label:"Strong",type:"checkbox",accelerator:"CmdOrCtrl+B",click:r(function(){File.editor.stylize.toggleStyle("strong")},!0)},{label:"Emphasis",type:"checkbox",accelerator:"CmdOrCtrl+I",click:r(function(){File.editor.stylize.toggleStyle("em")},!0)},{label:"Underline",type:"checkbox",accelerator:"CmdOrCtrl+U",click:r(function(){File.editor.stylize.toggleStyle("underline")},!0)},{label:"Code",type:"checkbox",accelerator:"CmdOrCtrl+Shift+`",click:r(function(){File.editor.stylize.toggleStyle("code")},!0)},{type:"separator"},{label:"Inline Math",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("inline_math")},!0)},{label:"Strike",type:"checkbox",accelerator:"Alt+Shift+5",click:r(function(){File.editor.stylize.toggleStyle("del")},!0)},{label:"Highlight",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("highlight")},!0)},{label:"Superscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("superscript")},!0)},{label:"Subscript",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("subscript")},!0)},{label:"Comment",type:"checkbox",click:r(function(){File.editor.stylize.toggleStyle("comment")},!0)},{type:"separator"},{label:"Hyperlink",type:"checkbox",accelerator:"Ctrl+K",click:r(function(){File.editor.stylize.toggleStyle("link")},!0)},{label:"Hyperlink Actions",submenu:[{label:"Open Link",click:r(function(){File.editor.openCurrentLink()},!0)},{label:"Copy Link Address",click:r(function(){File.editor.copyCurrentLink()},!0)}]},{label:"Image",submenu:[{label:"Insert Image",accelerator:"CmdOrCtrl+Shift+I",click:r(function(){File.editor.stylize.toggleStyle("image")},!0)},{label:"Insert Local Images…",click:r(function(){File.editor.imgEdit.insertLocalImage()},!0)},{type:"separator"},{label:"Open Image Location…",click:r(function(){File.editor.imgEdit.revealInFinder()},!0)},{label:"Copy Image Content",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.copyImage()")}},{label:"Zoom Image",submenu:[{label:"25%",click:r(function(){File.editor.imgEdit.zoomAction(null,"25%")},!0)},{label:"33%",click:r(function(){File.editor.imgEdit.zoomAction(null,"33%")},!0)},{label:"50%",click:r(function(){File.editor.imgEdit.zoomAction(null,"50%")},!0)},{label:"67%",click:r(function(){File.editor.imgEdit.zoomAction(null,"67%")},!0)},{label:"80%",click:r(function(){File.editor.imgEdit.zoomAction(null,"80%")},!0)},{type:"separator"},{label:"100%",click:r(function(){File.editor.imgEdit.zoomAction(null,"100%")},!0)},{type:"separator"},{label:"150%",click:r(function(){File.editor.imgEdit.zoomAction(null,"150%")},!0)},{label:"200%",click:r(function(){File.editor.imgEdit.zoomAction(null,"200%")},!0)}]},{label:"Switch Image Syntax",submenu:[{label:"Markdown Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!1)},!0)},{label:"HTML Style",click:r(function(){File.editor.imgEdit.switchPattern(null,!0)},!0)}]},{type:"separator"},{label:"Delete Image File",click:function(e,t){t&&t.webContents.executeJavaScript("File.editor.imgEdit.deleteImageAction(true)")}},{type:"separator"},{label:"Copy Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction()},!0)},{label:"Rename or Move Image to…",click:r(function(){File.editor.imgEdit.copyToSelectedFolderAction(!0)},!0)},{label:"Upload Image",click:r(function(){File.editor.imgEdit.uploadAction()},!0)},{type:"separator"},{label:"Copy All Images to…",click:r(function(){File.editor.imgEdit.copyAllImages()},!0)},{label:"Move All Images to…",click:r(function(){File.editor.imgEdit.moveAllImages()},!0)},{label:"Upload All Local Images",click:r(function(){File.editor.imgEdit.uploadAllImages()},!0)},{type:"separator"},{label:"Reload All Images",click:r(function(){File.editor.imgEdit.reloadAllByNode()},!0)},{type:"separator"},{label:"When Insert Local Image",submenu:[{label:"Copy Image File to Folder…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleCopyToFolder()},!0)},{label:"Upload Image",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUploadForFile()},!0)}]},{label:"Use Image Root Path…",type:"checkbox",click:r(function(){File.editor.imgEdit.toggleUseImageRootPath()},!0)},{type:"separator"},{label:"Global Image Settings…",click:function(e,t){t&&t.webContents.executeJavaScript("File.megaMenu.highlight('image-setting-group');")}}]},{type:"separator"},{label:"Clear Format",type:"checkbox",accelerator:"CmdOrCtrl+\\",click:r(function(){File.editor.stylize.clearStyle()},!0)}]}),p({label:"&View",submenu:[{label:"Toggle Sidebar",accelerator:"CmdOrCtrl+Shift+L",click:r(function(){File.editor.library.toggleSidebar()},!0)},{label:"Outline",type:"checkbox",accelerator:"CmdOrCtrl+Shift+1",click:r("toggleOutline")},{label:"Articles",type:"checkbox",accelerator:"CmdOrCtrl+Shift+2",click:r("toggleFileList")},{label:"File Tree",type:"checkbox",accelerator:"CmdOrCtrl+Shift+3",click:r("toggleFileTree")},{label:"Search",type:"checkbox",accelerator:"CmdOrCtrl+Shift+F",click:r("globalSearch")},{type:"separator"},{label:"Source Code Mode",type:"checkbox",accelerator:"CmdOrCtrl+/",click:r(function(){File.toggleSourceMode()},!0)},{type:"separator"},{label:"Focus Mode",type:"checkbox",accelerator:"F8",click:r(function(){File.editor.toggleFocusMode()},!0),enabled:!1},{label:"Typewriter Mode",type:"checkbox",accelerator:"F9",click:r(function(){File.editor.toggleTypeWriterMode()},!0),enabled:!1},{type:"separator"},{label:"Show Status Bar",type:"checkbox",click:r("toggleStatusBar")},{type:"separator"},{label:"Toggle Fullscreen",accelerator:"F11",click:function(e,t){t&&(t.isFullScreen()?t.setFullScreen(!1):t.setFullScreen(!0))}},{label:"Always on Top",type:"checkbox",click:function(e,t){t&&(k(function(){document.body.classList.toggle("always-on-top")},!0),t.setAlwaysOnTop(!t.isAlwaysOnTop()),e.checked=t.isAlwaysOnTop())}},{type:"separator"},{label:"Actual Size",type:"checkbox",accelerator:d?"Ctrl+Shift+9":"Ctrl+Shift+0",click:function(e,t){v(function(){ClientCommand.resetZoom()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom In",accelerator:"Ctrl+Shift+=",click:function(e,t){v(function(){ClientCommand.zoomIn()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{label:"Zoom Out",accelerator:"Ctrl+Shift+-",click:function(e,t){v(function(){ClientCommand.zoomOut()}),k(function(){ClientCommand.refreshViewMenu()},!0)}},{type:"separator"},{label:"Switch Between Opened Documents",accelerator:"Ctrl+Tab",click:function(e,t){var n;!t||-1!=(t=(n=m.getAllWindows()).indexOf(t))&&n[t=++t>=n.length?0:t].focus()}},{type:"separator"},{label:"Toggle DevTools",accelerator:"Shift+F12",click:function(e,t){var n;t&&(n=setTimeout(t.webContents.openDevTools,2e3),t.webContents.executeJavaScript("ClientCommand.toggleDevTools()").then(function(){clearTimeout(n)},function(){clearTimeout(n),t.webContents.openDevTools()}))}}]}),p({label:"&Themes",submenu:[]}),p({label:"&Help",submenu:[{label:"What's New…",click:function(){var e=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal(`https://support.${e}/What's-New/`)}},{type:"separator"},{label:"Quick Start",click:function(e,t){l.openFile(u+"/Docs/Quick Start.md")}},{label:"Markdown Reference",click:function(e,t){l.openFile(u+"/Docs/Markdown Reference.md")}},{label:"Install and Use Pandoc",click:function(e,t){l.openFile(u+"/Docs/Install and Use Pandoc.md")}},{label:"Custom Themes",click:function(e,t){l.openFile(u+"/Docs/Custom Themes.md")}},{label:"Use Images in Typora",click:function(e,t){l.openFile(u+"/Docs/Use Images in Typora.md")}},{label:"Data Recovery and Version Control",click:function(e,t){l.openFile(u+"/Docs/Auto Save, Version Control and Recovery.md")}},{label:"More Topics…",click:function(e,t){var n=l.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io";a.shell.openExternal("https://support."+n)}},{type:"separator"},{label:"Credits",click:function(e,t){l.openFile(u+"/Docs/Credits.md")}},{label:"Change Log",click:function(e,t){l.openFile(u+"/Docs/Change Log.md")}},{label:"Privacy Policy",click:function(e,t){l.openFile(u+"/Docs/Privacy Policy.md")}},{label:"Website",click:function(){var e=l.setting.get("useMirrorInCN")?"https://typoraio.cn":"https://typora.io";a.shell.openExternal(e)}},{label:"Feedback",click:function(e,t){a.shell.openExternal("mailto:hi@typora.io")}},{type:"separator"},{label:"Check Updates…",click:function(){d&&l.updater.checkForUpdates(!0)},visible:d},{label:"My License…",click:function(){y.showLicensePanel()}},global.PRODUCTION_MODE?null:{label:"Welcome…",click:function(){y.showWelcomePanel()}},{label:"About",click:r(function(){File.megaMenu.closePreferencePanel(),document.body.classList.contains("native-window")?($(".modal:not(.block-modal)").modal("hide"),$("#about-dialog").modal("show"),$("*:focus").blur()):(File.megaMenu.show(),$("#m-about").trigger("click"))},!0)}]})];d||t[0].submenu.splice(t[0].submenu.indexOf(null),1),l.isEmojiPanelSupported()&&(t[1].submenu.push({type:"separator"}),t[1].submenu.push(p({label:"Emoji and Symbols",accelerator:d?"Super+.":"",click:function(){l.showEmojiPanel()}})));const i=t[t.length-1].submenu;for(;-1{"use strict";var a=c(93).EventEmitter,n=c(134),t=n.ipcMain,d=n.app,r=c(728),l="linux"==process.platform,s=c(541).join(__dirname,"../"),g=c(445),u=c(156),m=c(359).default,f=c(477),w=c(824),b=c(587),p=new a,o=["Check updates automatically","Skip This Version","Remind Me Later","Download Update","New version available.","Latest version is $1, your version is $2"],h="64";"ia32"==process.arch&&(h="32"),"arm64"==process.arch&&(h="arm"),p.initUpdater=function(){return u.initDict().then(function(){return o.forEach(function(e,t){o[t]=u.getPanelString(e)}),Promise.resolve()})},p.showDetailWindow=function(e,t,n){p.progressBar&&(p.progressBar.close(),p.progressBar=null),p.win&&(p.win.destroy(),p.win=null);e=b.showPanelWindow({title:u.getPanelString("Updater"),width:640,height:600,path:"updater/updater.html?curVersion=$1&newVersion=$2&labels=$3&enableAutoUpdate=$4&releaseNoteLink=$5&hideAutoUpdates=$6".replace("$1",e).replace("$2",t).replace("$3",encodeURIComponent(JSON.stringify(o))).replace("$4",JSON.stringify(!1!==d.setting.get("enableAutoUpdate"))).replace("$5",encodeURIComponent(n)).replace("$6",global.devVersion&&!g.getHasLicense())});(p.win=e).on("closed",function(){p.win=null})},p.showUI=function(){p.win||p.progressBar||(p.progressBar=new f({title:u.getPanelString("Updater"),text:u.getPanelString("Checking Updates…"),indeterminate:!0,style:{text:{padding:"3px 0"}},browserWindow:{closable:!0,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}}))};p.checkForUpdates=async function(t){var e,n,o,i=d.setting.get("useMirrorInCN")?"typoraio.cn":"typora.io",i=global.devVersion||d.setting.get("autoUpdateToDev")?`https://${i}/releases/dev_windows_${h}.json`:`https://${i}/releases/windows_${h}.json`;if(i){if(p.emit("checking-for-update"),t)p.showUI();else if((e=d.setting.get("cancelUpdate"))&&new Date-new Date(e)<432e5)return;try{var r=await m(i);if(204==r.status)return void p.emit("update-not-available");if(200!=r.status)return p.emit("update-not-available"),console.error("invalid status code: "+r.statusCode+" from "+i),"Failed to check updates, invalid status code: "+r.status;var a=await r.json(),l=(n=a,o=c(842).release().replace(/\.[^.]+$/,""),a=(o=(n.alternatives||{})[o])?Object.assign(n,o):n,p.data=a,d.getVersion());if(!a.version||!l)return;if(!(0{e||(console.log(t),p.installPathOnQuit=t,d.quit())})},p.installIfNeeded=function(){p.installPathOnQuit&&p.install(p.installPathOnQuit)},p.install=function(e){c(620).spawn(e,["/SILENT"],{detached:!0,stdio:["ignore","ignore","ignore"]}).unref()},t.handle("updater.checkForUpdates",(e,t)=>{p.checkForUpdates(t)}),t.handle("updater.cancelUpdate",e=>{p.cancelUpdate()}),t.handle("updater.skipUpdate",e=>{p.skipUpdate()}),t.handle("updater.downloadUpdate",e=>{p.downloadUpdate()}),e.exports=p},620:e=>{"use strict";e.exports=require("child_process")},289:e=>{"use strict";e.exports=require("crypto")},134:e=>{"use strict";e.exports=require("electron")},554:e=>{"use strict";e.exports=require("electron-dl")},359:e=>{"use strict";e.exports=require("electron-fetch")},477:e=>{"use strict";e.exports=require("electron-progressbar")},93:e=>{"use strict";e.exports=require("events")},834:e=>{"use strict";e.exports=require("extract-zip")},833:e=>{"use strict";e.exports=require("fs")},728:e=>{"use strict";e.exports=require("fs-extra")},232:e=>{"use strict";e.exports=require("fs-plus")},338:e=>{"use strict";e.exports=require("hjson")},783:e=>{"use strict";e.exports=require("lowdb")},207:e=>{"use strict";e.exports=require("lowdb/adapters/FileSync")},640:e=>{"use strict";e.exports=require("module")},560:e=>{"use strict";e.exports=require("node-machine-id")},842:e=>{"use strict";e.exports=require("os")},541:e=>{"use strict";e.exports=require("path")},208:e=>{"use strict";e.exports=require("process")},468:e=>{"use strict";e.exports=require("raven")},426:e=>{"use strict";e.exports=require("url")},266:e=>{"use strict";e.exports=require("util")}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;t=o[e]={id:e,loaded:!1,exports:{}};return n[e](t,t.exports,i),t.loaded=!0,t.exports}i.c=o,i.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);i(i.s=90)})(); \ No newline at end of file diff --git a/Windows_x86/dec_app/head.json b/Windows_x86/dec_app/head.json index ba0f1dd..d70f94c 100644 --- a/Windows_x86/dec_app/head.json +++ b/Windows_x86/dec_app/head.json @@ -1 +1 @@ -{"files": {"atom.js": {"size": 172972, "offset": "0", "integrity": {"algorithm": "SHA256", "hash": "4f2fa813c9bc685a97306c5ee6da4fe04cf62e1d56bc3d140ad52688ae8074ba", "blockSize": 4194304, "blocks": ["4f2fa813c9bc685a97306c5ee6da4fe04cf62e1d56bc3d140ad52688ae8074ba"]}}, "main.node": {"size": 870912, "unpacked": true, "integrity": {"algorithm": "SHA256", "hash": "d5f67b57a057463f54e4c135416809ab33fec6b0b9cc1206a810b5cdf4d88d72", "blockSize": 4194304, "blocks": ["d5f67b57a057463f54e4c135416809ab33fec6b0b9cc1206a810b5cdf4d88d72"]}}, "package.json": {"size": 246, "offset": "172972", "integrity": {"algorithm": "SHA256", "hash": "5710672463a9f3043780c1577b071b4608aa9b09ad1ed48ee416d0894ef0203e", "blockSize": 4194304, "blocks": ["5710672463a9f3043780c1577b071b4608aa9b09ad1ed48ee416d0894ef0203e"]}}}} \ No newline at end of file +{"files": {"atom.js": {"size": 172972, "offset": "0", "integrity": {"algorithm": "SHA256", "hash": "7277089751858348c05732ba2b7258abdeba3af31d11724c5fe57011c60d4982", "blockSize": 4194304, "blocks": ["7277089751858348c05732ba2b7258abdeba3af31d11724c5fe57011c60d4982"]}}, "main.node": {"size": 870912, "unpacked": true, "integrity": {"algorithm": "SHA256", "hash": "d5f67b57a057463f54e4c135416809ab33fec6b0b9cc1206a810b5cdf4d88d72", "blockSize": 4194304, "blocks": ["d5f67b57a057463f54e4c135416809ab33fec6b0b9cc1206a810b5cdf4d88d72"]}}, "package.json": {"size": 246, "offset": "172972", "integrity": {"algorithm": "SHA256", "hash": "15c30ad24ec26159c2b70d21751f0ede715fbe20457b48bb26ba75986651f1c3", "blockSize": 4194304, "blocks": ["15c30ad24ec26159c2b70d21751f0ede715fbe20457b48bb26ba75986651f1c3"]}}}} \ No newline at end of file diff --git a/Windows_x86/dec_app/main.node b/Windows_x86/dec_app/main.node index 5ba973b..c00ae6d 100644 Binary files a/Windows_x86/dec_app/main.node and b/Windows_x86/dec_app/main.node differ diff --git a/Windows_x86/dec_app/package.json b/Windows_x86/dec_app/package.json index c35b188..fdaa9c3 100644 --- a/Windows_x86/dec_app/package.json +++ b/Windows_x86/dec_app/package.json @@ -1,11 +1,11 @@ { "name": "Typora", - "version": "1.5.6", + "version": "1.5.8", "main": "main.node", "family": "abnerworks", "private": true, "author": "typora.io", "homepage": "https://typora.io", "concat": "hi@typora.io", - "releaseId": "2c58e8705" + "releaseId": "182719c82" } \ No newline at end of file