function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.apply(null,arguments)}var t=!1;try{t=typeof localStorage<`u`}catch{}var n=typeof process<`u`,r=t&&typeof localStorage.getItem==`function`&&localStorage.getItem(`DEBUG`)||n&&{}.DEBUG?console.log:function(e){return``};function i(t,n,r,i,a){i===void 0&&(i={});var o=e({},s(r),i),c=d(t,n,o,r,a),l=c.languageServiceHost,f=c.updateFile,p=c.deleteFile,m=r.createLanguageService(l),h=m.getCompilerOptionsDiagnostics();if(h.length){var g=u(t,i,r);throw Error(r.formatDiagnostics(h,g.compilerHost))}return{name:`vfs`,sys:t,languageService:m,getSourceFile:function(e){return m.getProgram()?.getSourceFile(e)},createFile:function(e,t){f(r.createSourceFile(e,t,o.target,!1))},updateFile:function(e,t,n){var i=m.getProgram().getSourceFile(e);if(!i)throw Error(`Did not find a source file for `+e);var a=i.text,o=n??r.createTextSpan(0,a.length),s=a.slice(0,o.start)+t+a.slice(o.start+o.length);f(r.updateSourceFile(i,s,{span:o,newLength:t.length}))},deleteFile:function(e){var t=m.getProgram().getSourceFile(e);t&&p(t)}}}function a(e){throw Error(`Method '`+e+`' is not implemented.`)}function o(e,t){return function(){var n=[...arguments],i=t.apply(void 0,n),a=typeof i==`string`?i.slice(0,80)+`...`:i;return r.apply(void 0,[`> `+e].concat(n)),r(`< `+a),i}}var s=function(t){return e({},t.getDefaultCompilerOptions(),{jsx:t.JsxEmit.React,strict:!0,esModuleInterop:!0,module:t.ModuleKind.ESNext,suppressOutputPathCheck:!0,skipLibCheck:!0,skipDefaultLibCheck:!0},t.versionMajorMinor&&Number(t.versionMajorMinor.split(`.`)[0])>=6?{ignoreDeprecations:`6.0`}:{moduleResolution:t.ModuleResolutionKind.NodeJs})},c=function(e){return e.replace(`/`,`/lib.`).toLowerCase()};function l(e){return{args:[],createDirectory:function(){return a(`createDirectory`)},directoryExists:o(`directoryExists`,function(t){return Array.from(e.keys()).some(function(e){return e.startsWith(t)})}),exit:function(){return a(`exit`)},fileExists:o(`fileExists`,function(t){return e.has(t)||e.has(c(t))}),getCurrentDirectory:function(){return`/`},getDirectories:function(){return[]},getExecutingFilePath:function(){return a(`getExecutingFilePath`)},readDirectory:o(`readDirectory`,function(t){return t===`/`?Array.from(e.keys()):[]}),readFile:o(`readFile`,function(t){return e.get(t)??e.get(c(t))}),resolvePath:function(e){return e},newLine:`
`,useCaseSensitiveFileNames:!0,write:function(){return a(`write`)},writeFile:function(t,n){e.set(t,n)},deleteFile:function(t){e.delete(t)}}}function u(t,n,r){var i=new Map,a=function(e){return i.set(e.fileName,e),e};return{compilerHost:e({},t,{getCanonicalFileName:function(e){return e},getDefaultLibFileName:function(){return`/`+r.getDefaultLibFileName(n)},getNewLine:function(){return t.newLine},getSourceFile:function(e,o){return i.get(e)||a(r.createSourceFile(e,t.readFile(e),o??n.target??s(r).target,!1))},useCaseSensitiveFileNames:function(){return t.useCaseSensitiveFileNames}}),updateFile:function(e){var n=i.has(e.fileName);return t.writeFile(e.fileName,e.text),i.set(e.fileName,e),n},deleteFile:function(e){var n=i.has(e.fileName);return i.delete(e.fileName),t.deleteFile(e.fileName),n}}}function d(t,n,r,i,a){var o=[].concat(n),s=u(t,r,i),c=s.compilerHost,l=s.updateFile,d=s.deleteFile,f=new Map,p=0;return{languageServiceHost:e({},c,{getProjectVersion:function(){return p.toString()},getCompilationSettings:function(){return r},getCustomTransformers:function(){return a},getScriptFileNames:function(){return o.slice()},getScriptSnapshot:function(e){var n=t.readFile(e);if(n&&typeof n==`string`)return i.ScriptSnapshot.fromString(n)},getScriptVersion:function(e){return f.get(e)||`0`},writeFile:t.writeFile}),updateFile:function(e){p++,f.set(e.fileName,p.toString()),o.includes(e.fileName)||o.push(e.fileName),l(e)},deleteFile:function(e){p++,f.set(e.fileName,p.toString());var t=o.indexOf(e.fileName);t!==-1&&o.splice(t,1),d(e)}}}export{l as createSystem,i as createVirtualTypeScriptEnvironment};