/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
"use strict";function getApplicationPath(){return process.env.VSCODE_DEV?appRoot:"darwin"===process.platform?path.dirname(path.dirname(path.dirname(appRoot))):path.dirname(path.dirname(appRoot))}function getPortableDataPath(){if(process.env.VSCODE_PORTABLE)return process.env.VSCODE_PORTABLE;if("win32"===process.platform||"linux"===process.platform)return path.join(getApplicationPath(),"data");{const e=product.portable||`${product.applicationName}-portable-data`;return path.join(path.dirname(getApplicationPath()),e)}}function getUserDataPath(){return isPortable?path.join(portableDataPath,"user-data"):path.resolve(args["user-data-dir"]||paths.getDefaultUserDataPath(process.platform))}function stripComments(e){return e.replace(/("(?:[^\\\"]*(?:\\.)?)*")|('(?:[^\\\']*(?:\\.)?)*')|(\/\*(?:\r?\n|.)*?\*\/)|(\/{2,}.*?(?:(?:\r?\n)|$))/g,function(e,a,r,t,n){if(t)return"";if(n){let e=n.length;return e>2&&"\n"===n[e-1]?"\r"===n[e-2]?"\r\n":"\n":""}return e})}function mkdirp(e){return mkdir(e).then(null,a=>{
if(a&&"ENOENT"===a.code){const a=path.dirname(e);if(a!==e)return mkdirp(a).then(()=>mkdir(e))}throw a})}function rimraf(e){return lstat(e).then(a=>a.isDirectory()&&!a.isSymbolicLink()?readdir(e).then(a=>Promise.all(a.map(a=>rimraf(path.join(e,a))))).then(()=>rmdir(e)):unlink(e),e=>{if("ENOENT"!==e.code)throw e})}function resolveJSFlags(...e){return args["js-flags"]&&e.push(args["js-flags"]),args["max-memory"]&&!/max_old_space_size=(\d+)/g.exec(args["js-flags"])&&e.push(`--max_old_space_size=${args["max-memory"]}`),e.length>0?e.join(" "):null}function getUserDefinedLocale(){let e=args.locale;if(e)return Promise.resolve(e.toLowerCase());let a=path.join(userDataPath,"User","locale.json");return exists(a).then(e=>e?readFile(a).then(e=>{e=stripComments(e);try{let a=JSON.parse(e).locale;return a&&"string"==typeof a?a.toLowerCase():void 0}catch(e){return}}):void 0)}function getLanguagePackConfigurations(){let e=path.join(userDataPath,"languagepacks.json");try{return require(e)}catch(e){}}
function resolveLanguagePackLocale(e,a){try{for(;a;){if(e[a])return a;{let e=a.lastIndexOf("-");if(!(e>0))return;a=a.substring(0,e)}}}catch(e){console.error("Resolving language pack configuration failed.",e)}}function getNLSConfiguration(e){if("pseudo"===e)return Promise.resolve({locale:e,availableLanguages:{},pseudo:!0});if(process.env.VSCODE_DEV)return Promise.resolve({locale:e,availableLanguages:{}});if(e&&("en"===e||"en-us"===e))return Promise.resolve({locale:e,availableLanguages:{}});let a=e;perf.mark("nlsGeneration:start");let r=function(e){return perf.mark("nlsGeneration:end"),Promise.resolve({locale:e,availableLanguages:{}})};try{let t=product.commit;if(!t)return r(a);let n=getLanguagePackConfigurations();if(!n)return r(a);if(!(e=resolveLanguagePackLocale(n,e)))return r(a);let o,s=n[e];return s&&"string"==typeof s.hash&&s.translations&&"string"==typeof(o=s.translations.vscode)?exists(o).then(n=>{if(!n)return r(a)
;let i=s.hash+"."+e,l=path.join(userDataPath,"clp",i),p=path.join(l,t),c=path.join(l,"tcf.json"),u=path.join(l,"corrupted.info"),f={locale:a,availableLanguages:{"*":e},_languagePackId:i,_translationsConfigFile:c,_cacheRoot:l,_resolvedLanguagePackCoreLocation:p,_corruptedFile:u};return exists(u).then(a=>{let t;return(t=a?rimraf(l):Promise.resolve(void 0)).then(()=>exists(p).then(a=>a?(touch(p).catch(()=>{}),perf.mark("nlsGeneration:end"),f):mkdirp(p).then(()=>Promise.all([readFile(path.join(__dirname,"nls.metadata.json")),readFile(o)])).then(e=>{let a=JSON.parse(e[0]),r=JSON.parse(e[1]).contents,t=Object.keys(a.bundles),n=[];for(let e of t){let t=a.bundles[e],o=Object.create(null);for(let e of t){let t,n=a.keys[e],s=a.messages[e],i=r[e];if(i){t=[];for(let e=0;e<n.length;e++){let a=n[e],r=i["string"==typeof a?a:a.key];void 0===r&&(r=s[e]),t.push(r)}}else t=s;o[e]=t}n.push(writeFile(path.join(p,e.replace(/\//g,"!")+".nls.json"),JSON.stringify(o)))}return n.push(writeFile(c,JSON.stringify(s.translations))),
Promise.all(n)}).then(()=>(perf.mark("nlsGeneration:end"),f)).catch(a=>(console.error("Generating translation files failed.",a),r(e)))))})}):r(a)}catch(a){return console.error("Generating translation files failed.",a),r(e)}}const perf=require("./vs/base/common/performance");perf.mark("main:started"),Error.stackTraceLimit=100;const fs=require("fs"),path=require("path"),product=require("../product.json"),appRoot=path.dirname(__dirname),portableDataPath=getPortableDataPath(),isPortable=fs.existsSync(portableDataPath),portableTempPath=path.join(portableDataPath,"tmp"),isTempPortable=isPortable&&fs.existsSync(portableTempPath);isPortable?process.env.VSCODE_PORTABLE=portableDataPath:delete process.env.VSCODE_PORTABLE,isTempPortable&&(process.env["win32"===process.platform?"TEMP":"TMPDIR"]=portableTempPath),function(){const e=require("path"),a=require("module"),r=e.join(__dirname,"../node_modules"),t=r+".asar",n=a._resolveLookupPaths;a._resolveLookupPaths=function(e,a,o){const s=n(e,a,o),i=o?s:s[1]
;for(let e=0,a=i.length;e<a;e++)if(i[e]===r){i.splice(e,0,t);break}return s}}();const app=require("electron").app;app.commandLine.appendSwitch("disable-mojo-local-storage"),app.commandLine.appendSwitch("disable-features","ColorCorrectRendering");const minimist=require("minimist"),paths=require("./paths"),args=minimist(process.argv,{string:["user-data-dir","locale","js-flags","max-memory"]}),userDataPath=getUserDataPath();app.setPath("userData",userDataPath);const mkdir=e=>new Promise((a,r)=>fs.mkdir(e,t=>t&&"EEXIST"!==t.code?r(t):a(e))),exists=e=>new Promise(a=>fs.exists(e,a)),readFile=e=>new Promise((a,r)=>fs.readFile(e,"utf8",(e,t)=>e?r(e):a(t))),writeFile=(e,a)=>new Promise((r,t)=>fs.writeFile(e,a,"utf8",e=>e?t(e):r())),touch=e=>new Promise((a,r)=>{const t=new Date;fs.utimes(e,t,t,e=>e?r(e):a())
}),lstat=e=>new Promise((a,r)=>fs.lstat(e,(e,t)=>e?r(e):a(t))),readdir=e=>new Promise((a,r)=>fs.readdir(e,(e,t)=>e?r(e):a(t))),rmdir=e=>new Promise((a,r)=>fs.rmdir(e,e=>e?r(e):a(void 0))),unlink=e=>new Promise((a,r)=>fs.unlink(e,e=>e?r(e):a(void 0))),nodeCachedDataDir=new class{constructor(){this.value=this._compute()}jsFlags(){return this.value?"--nolazy":void 0}ensureExists(){return mkdirp(this.value).then(()=>this.value,()=>{})}_compute(){if(process.argv.indexOf("--no-cached-data")>0)return;if(process.env.VSCODE_DEV)return;let e=product.commit;if(e)return path.join(userDataPath,"CachedData",e)}};try{"win32"===process.platform?(process.env.VSCODE_CWD=process.cwd(),process.chdir(path.dirname(app.getPath("exe")))):process.env.VSCODE_CWD&&process.chdir(process.env.VSCODE_CWD)}catch(e){console.error(e)}global.macOpenFiles=[],app.on("open-file",function(e,a){global.macOpenFiles.push(a)});let openUrls=[],onOpenUrl=function(e,a){e.preventDefault(),openUrls.push(a)};app.on("will-finish-launching",function(){
app.on("open-url",onOpenUrl)}),global.getOpenUrls=function(){return app.removeListener("open-url",onOpenUrl),openUrls};let nlsConfiguration=void 0,userDefinedLocale=getUserDefinedLocale();userDefinedLocale.then(e=>{e&&!nlsConfiguration&&(nlsConfiguration=getNLSConfiguration(e))});let jsFlags=resolveJSFlags(nodeCachedDataDir.jsFlags());jsFlags&&app.commandLine.appendSwitch("--js-flags",jsFlags),app.once("ready",function(){perf.mark("main:appReady"),Promise.all([nodeCachedDataDir.ensureExists(),userDefinedLocale]).then(([e,a])=>{a&&!nlsConfiguration&&(nlsConfiguration=getNLSConfiguration(a)),nlsConfiguration||(nlsConfiguration=Promise.resolve(void 0)),nlsConfiguration.then(a=>{let r=a=>{a._languagePackSupport=!0,process.env.VSCODE_NLS_CONFIG=JSON.stringify(a),e&&(process.env["VSCODE_NODE_CACHED_DATA_DIR_"+process.pid]=e),require("./bootstrap-amd").bootstrap("vs/code/electron-main/main")};if(a)r(a);else{let e=app.getLocale();e?getNLSConfiguration(e=e.toLowerCase()).then(a=>{a||(a={locale:e,availableLanguages:{}
}),r(a)}):r({locale:"en",availableLanguages:{}})}})},console.error)});
//# sourceMappingURL=https://ticino.blob.core.windows.net/sourcemaps/5944e81f3c46a3938a82c701f96d7a59b074cfdc/core/main.js.map
