UNPKG

jitar

Version:

Distributed runtime for JavaScript and TypeScript to chop monolithic applications into micros.

2 lines 149 kB
#!/usr/bin/env node import fs from"fs-extra";import{glob}from"glob";import mime from"mime-types";import path from"path";import dotenv from"dotenv";import{B as BadRequest,N as NotFound,F as Forbidden,a as NamedParameter,A as ArrayParameter,O as ObjectParameter,b as NotImplemented,P as PaymentRequired,T as Teapot,U as Unauthorized,S as ServerError,V as Version,c as Segment$1,R as Response,d as AccessLevels,e as Request}from"./Response-D49TlRAU.js";import crypto from"crypto";import express from"express";class MissingArgument extends Error{constructor(name){super(`Missing argument '${name}'`)}}class ArgumentProcessor{#command;#args;constructor(args){this.#command=args[2],this.#args=this.#parseArguments(args)}getCommand(){return this.#command}getRequiredArgument(name){const value=this.#args.get(name);if(void 0===value)throw new MissingArgument(name);return value}getOptionalArgument(name,defaultValue){return this.#args.get(name)??defaultValue}#parseArguments(args){const commandArgs=args.slice(3),map=new Map;return commandArgs.forEach((arg=>{const[key,value]=arg.split("=");map.set(key.trim(),value?.trim())})),map}}class ShowHelp{async execute(args){console.log("\nUsage: jitar <command> [options]\n\nCommands:\n build Builds the application (creates segment bundles)\n start Starts a server with the configured service\n about Shows information about Jitar\n version Shows the installed version of Jitar\n help Shows help (this message)\n\nOptions:\n --config Path to the configuration file (default: jitar.json)\n --service Path to the service configuration file (required for 'start' command)\n --env-file Path to the environment file (default: none)\n --log-level Optional for 'start' and 'build' commands (default: info, other options: debug, warn, error, fatal)\n --http-body-limit Optional for 'start' command (default: 204,800 bytes)\nMore information can be found at https://docs.jitar.dev\n")}}class ShowAbout{async execute(args){console.log("\nJitar is a JavaScript Distributed Runtime created and maintained by Masking Technology.\n\nMore information can be found at:\n- https://jitar.dev\n- https://masking.tech\n")}}class ShowVersion{async execute(args){console.log("v0.8.0")}}const LogLevels_DEBUG=0,LogLevels_INFO=1,LogLevels_WARN=2,LogLevels_ERROR=3,LogLevels_FATAL=4;class Logger{#logLevel;#writer;constructor(logLevel=LogLevels_INFO,writer=console){this.#logLevel=logLevel,this.#writer=writer}debug(...message){if(this.#logLevel>LogLevels_DEBUG)return;const messageString=this.#createMessage("DEBUG",message);this.#writer.debug(messageString)}info(...message){if(this.#logLevel>LogLevels_INFO)return;const messageString=this.#createMessage("INFO",message);this.#writer.info(messageString)}warn(...message){if(this.#logLevel>LogLevels_WARN)return;const messageString=this.#createMessage("WARN",message);this.#writer.warn(messageString)}error(...message){if(this.#logLevel>LogLevels_ERROR)return;const messageString=this.#createMessage("ERROR",message);this.#writer.error(messageString)}fatal(...message){const messageString=this.#createMessage("FATAL",message);this.#writer.error(messageString)}#createMessage(logLevel,messages){return`[${logLevel}][${(new Date).toISOString()}] ${messages.map((value=>this.#interpretValue(value))).join(" ")}`}#interpretValue(value,level=0){let result;switch(typeof value){case"string":result=value;break;case"object":result=this.#interpretObject(value,level+1);break;case"undefined":result="undefined";break;case"function":result="function";break;default:result=String(value)}return`${this.#indent(level)}${result}`}#interpretObject(object,level){if(null===object)return"null";if(Array.isArray(object)){return`[\n${object.map((value=>this.#interpretValue(value,level))).join(",\n")}\n${this.#indent(level-1)}]`}return object instanceof Error?object.stack??object.message:JSON.stringify(object)}#indent(level){return" ".repeat(level)}}class InvalidLogLevel extends Error{constructor(logLevel){super(`Invalid log level: ${logLevel}`)}}class LogLevelParser{parse(logLevel){switch(logLevel.toUpperCase()){case"DEBUG":return LogLevels_DEBUG;case"INFO":return LogLevels_INFO;case"WARN":return LogLevels_WARN;case"ERROR":return LogLevels_ERROR;case"FATAL":return LogLevels_FATAL;default:throw new InvalidLogLevel(logLevel)}}}const Files$1_MODULE_PATTERN="**/*.js",Files$1_RESOURCE_PATTERN="**/*.json",Files$1_SEGMENT_PATTERN="**/*.json";class InvalidPath extends Error{#location;constructor(location){super(`Invalid location: ${location}`),this.#location=location}get location(){return this.#location}}class FileNotFound extends Error{#filename;constructor(filename){super(`The file '${filename}' could not be found`),this.#filename=filename}get filename(){return this.#filename}}class File{#location;#type;#content;constructor(location,type,content){this.#location=location,this.#type=type,this.#content=content}get location(){return this.#location}get type(){return this.#type}get content(){return this.#content}get size(){return this.#content.length}}class FileManager{#location;#rootLocation;#fileSystem;constructor(location,fileSystem){this.#location=location,this.#fileSystem=fileSystem,this.#rootLocation=fileSystem.resolve(location)}getAbsoluteLocation(filename){const location=filename.startsWith("/")?filename:this.#fileSystem.join(this.#location,filename),absolutePath=this.#fileSystem.resolve(location);return this.#validateLocation(absolutePath,filename),absolutePath}getRelativeLocation(filename){return this.#fileSystem.relative(this.#location,filename)}async getType(filename){const location=this.getAbsoluteLocation(filename);return await this.#fileSystem.mimeType(location)??"application/octet-stream"}async getContent(filename){const location=this.getAbsoluteLocation(filename);if(!1===await this.#fileSystem.exists(location))throw new FileNotFound(filename);return this.#fileSystem.read(location)}async exists(filename){const location=this.getAbsoluteLocation(filename);return this.#fileSystem.exists(location)}isDirectory(filename){const location=this.getAbsoluteLocation(filename);return this.#fileSystem.isDirectory(location)}async read(filename){const absoluteFilename=this.getAbsoluteLocation(filename),type=await this.getType(absoluteFilename),content=await this.getContent(absoluteFilename);return new File(filename,type,content)}async write(filename,content){const location=this.getAbsoluteLocation(filename);return this.#fileSystem.write(location,content)}async copy(source,destination){const sourceLocation=this.getAbsoluteLocation(source),destinationLocation=this.getAbsoluteLocation(destination);return this.#fileSystem.copy(sourceLocation,destinationLocation)}async delete(filename){const location=this.getAbsoluteLocation(filename);return this.#fileSystem.delete(location)}async filter(pattern){const location=this.getAbsoluteLocation("./");return this.#fileSystem.filter(location,pattern)}#validateLocation(location,filename){if(!1===location.startsWith(this.#rootLocation))throw new InvalidPath(filename)}}class LocalFileSystem{copy(source,destination){return fs.copy(source,destination,{overwrite:!0})}delete(location){return fs.remove(location)}exists(location){return fs.exists(location)}isDirectory(location){try{return fs.statSync(location).isDirectory()}catch{return!1}}filter(location,pattern){return glob(`${location}/${pattern}`)}join(...paths){return path.join(...paths)}read(location){return fs.readFile(location)}resolve(location){return path.resolve(location)}relative(from,to){return path.relative(from,to)}async mimeType(location){const mimeType=mime.lookup(location);if(!1!==mimeType)return mimeType}async write(location,content){const directory=path.dirname(location);return fs.mkdirSync(directory,{recursive:!0}),fs.writeFile(location,content)}}class LocalFileManager extends FileManager{constructor(location){super(location,new LocalFileSystem)}}let ModuleNotLoaded$1=class extends Error{#url;#reason;constructor(url,reason){super(`Module '${url}' could not be loaded${void 0!==reason?` | ${reason}`:""}`),this.#url=url,this.#reason=reason}get url(){return this.#url}get reason(){return this.#reason}};class ImportManager{#moduleLocator;constructor(moduleLocator){this.#moduleLocator=moduleLocator}async import(filename){const location=this.#moduleLocator.locate(filename);try{return await import(location)}catch(error){const message=error instanceof Error?error.message:String(error);throw new ModuleNotLoaded$1(location,message)}}}class LocalModuleLocator{#fileManager;constructor(fileManager){this.#fileManager=fileManager}locate(filename){return filename.startsWith("/")?this.#fileManager.getAbsoluteLocation(`.${filename}`):this.#fileManager.getAbsoluteLocation(filename)}}class LocalImportManager extends ImportManager{constructor(fileManager){super(new LocalModuleLocator(fileManager))}}class SourcingManager{#fileManager;#importManager;constructor(fileManager,importManager){this.#fileManager=fileManager,this.#importManager=importManager}async filter(...patterns){return(await Promise.all(patterns.map((pattern=>this.#fileManager.filter(pattern))))).flat().map((file=>this.#fileManager.getRelativeLocation(file)))}exists(filename){return this.#fileManager.exists(filename)}read(filename){return this.#fileManager.read(filename)}import(filename){return this.#importManager.import(filename)}}class LocalSourcingManager extends SourcingManager{constructor(location){const fileManager=new LocalFileManager(location);super(fileManager,new LocalImportManager(fileManager))}}let Application$1=class{#repository;#resources;#segmentation;constructor(repository,resources,segmentation){this.#repository=repository,this.#resources=resources,this.#segmentation=segmentation}get resources(){return this.#resources}get repository(){return this.#repository}get segmentation(){return this.#segmentation}};class ResourcesList{#resources;constructor(resources){this.#resources=resources}isResourceModule(moduleFilename){return this.#resources.includes(moduleFilename)}}const Defaults$1_ACCESS_LEVEL="private",Defaults$1_VERSION_NUMBER="0.0.0",Files_INDEX="index.js",Files_JSON=".json",Keywords$1_DEFAULT="default",Patterns_IMPORT=/import\s(?:["'\s]*([\w*{}\n, ]+)from\s*)?["'\s]*([@\w/._-]+)["'\s].*/g,Patterns_EXPORT=/export\s(?:["'\s]*([\w*{}\n, ]+)from\s*)?["'\s]*([@\w/._-]+)["'\s].*/g,Values_ASTERISK="*";let IdGenerator$1=class{#id=0;next(){return"$"+ ++this.#id}};const EXTENSION_PATTERN=/\.js$/,APPLICATION_MODULE_INDICATORS=[".","/","http:","https:"];class FileHelper{translatePath(filename){const parts=filename.split("/"),translated=[];for(const part of parts){switch(part.trim()){case"":case".":continue;case"..":translated.pop();continue}translated.push(part)}return translated.join("/")}makePathRelative(absoluteFilename,relativeToPath){if(""===relativeToPath)return`./${absoluteFilename}`;const absoluteFilenameParts=absoluteFilename.split("/"),relativeToParts=relativeToPath.split("/");for(;absoluteFilenameParts[0]===relativeToParts[0];)absoluteFilenameParts.shift(),relativeToParts.shift();const relativePath=relativeToParts.map((()=>"..")).join("/");return`${relativeToParts.length>0?relativePath:"."}/${absoluteFilenameParts.join("/")}`}makePathAbsolute(relativeFilename,relativeToPath){const fullPath=""!==relativeToPath?`${relativeToPath}/${relativeFilename}`:relativeFilename;return this.translatePath(fullPath)}extractPath(filename){return filename.split("/").slice(0,-1).join("/")}stripPath(path){return path.substring(1,path.length-1)}extractFilename(filename){return filename.split("/").pop()}assureExtension(filename){return filename.endsWith(".js")?filename:`${filename}.js`}addSubExtension(filename,subExtension){return filename.replace(EXTENSION_PATTERN,`.${subExtension}.js`)}isApplicationModule(from){return APPLICATION_MODULE_INDICATORS.some((indicator=>from.startsWith(indicator)))}}let FileNotLoaded$2=class extends Error{constructor(filename,message){super(`Failed to load resource file '${filename}' because of: ${message}`)}};class ResourceReader{#resourcesFileManager;#sourceFileManager;#fileHelper=new FileHelper;constructor(resourcesFileManager,sourceFileManager){this.#resourcesFileManager=resourcesFileManager,this.#sourceFileManager=sourceFileManager}async readAll(filenames){const resources=await Promise.all(filenames.map((filename=>this.#loadResourceDefinition(filename))));return new ResourcesList(resources.flat())}async#loadResourceDefinition(filename){try{const content=await this.#resourcesFileManager.getContent(filename);return JSON.parse(content.toString()).map((resource=>this.#makeResourceFilename(resource)))}catch(error){const message=error instanceof Error?error.message:String(error);throw new FileNotLoaded$2(filename,message)}}#makeResourceFilename(filename){const fullFilename=this.#sourceFileManager.isDirectory(filename)?`${filename}/${Files_INDEX}`:this.#fileHelper.assureExtension(filename);return fullFilename.startsWith("./")?fullFilename.substring(2):fullFilename.startsWith("/")?fullFilename.substring(1):fullFilename}}let Module$1=class{#filename;#code;#model;constructor(filename,code,model){this.#code=code,this.#filename=filename,this.#model=model}get filename(){return this.#filename}get code(){return this.#code}get model(){return this.#model}};class Repository{#modules;constructor(modules){this.#modules=modules}get modules(){return this.#modules}get(filename){return this.#modules.find((module=>module.filename===filename))}}class ESAlias{#name;#as;constructor(name,as){this.#name=name,this.#as=as}get name(){return this.#name}get as(){return this.#as}toString(){return`${this.#name} as ${this.#as}`}}class ESValue{#definition;constructor(definition){this.#definition=definition}get definition(){return this.#definition}toString(){return this.#definition}}class ESArray extends ESValue{}class ESMember{#name;#isStatic;#isPrivate;constructor(name,isStatic=!1,isPrivate=!1){this.#name=name,this.#isStatic=isStatic,this.#isPrivate=isPrivate}get name(){return this.#name}get isStatic(){return this.#isStatic}get isPrivate(){return this.#isPrivate}get isPublic(){return!1===this.#isPrivate}}class ESClass extends ESMember{#parentName;#scope;constructor(name,parentName,scope){super(name),this.#parentName=parentName,this.#scope=scope}get parentName(){return this.#parentName}get scope(){return this.#scope}get members(){return this.#scope.members}get declarations(){return this.#scope.declarations}get functions(){return this.#scope.functions}get getters(){return this.#scope.getters}get setters(){return this.#scope.setters}get generators(){return this.#scope.generators}get readable(){const members=new Map;return this.getters.forEach((getter=>{members.set(getter.name,getter)})),this.declarations.forEach((declaration=>{declaration.isPublic&&members.set(declaration.name,declaration)})),[...members.values()]}get writable(){const members=new Map;return this.setters.forEach((setter=>{members.set(setter.name,setter)})),this.declarations.forEach((declaration=>{declaration.isPublic&&members.set(declaration.name,declaration)})),[...members.values()]}get callable(){return this.functions.filter((funktion=>funktion.isPublic))}getMember(name){return this.#scope.getMember(name)}getDeclaration(name){return this.#scope.getDeclaration(name)}getFunction(name){return this.#scope.getFunction(name)}getGetter(name){return this.#scope.getGetter(name)}getSetter(name){return this.#scope.getSetter(name)}getGenerator(name){return this.#scope.getGenerator(name)}hasMember(name){return this.#scope.hasMember(name)}hasDeclaration(name){return this.#scope.hasDeclaration(name)}hasFunction(name){return this.#scope.hasFunction(name)}hasGetter(name){return this.#scope.hasGetter(name)}hasSetter(name){return this.#scope.hasSetter(name)}hasGenerator(name){return this.#scope.hasGenerator(name)}canRead(name){const declaration=this.getDeclaration(name);return declaration?.isPublic||this.hasGetter(name)}canWrite(name){const declaration=this.getDeclaration(name);return declaration?.isPublic||this.hasSetter(name)}canCall(name){const funktion=this.getFunction(name);return funktion?.isPublic??!1}toString(){const infix=void 0!==this.#parentName?` extends ${this.#parentName}`:"";return`class ${this.name}${infix} { ${this.#scope.toString()} }`}}class ESDeclaration extends ESMember{#identifier;#value;constructor(identifier,value,isStatic=!1,isPrivate=!1){super(identifier.toString(),isStatic,isPrivate),this.#identifier=identifier,this.#value=value}get identifier(){return this.#identifier}get value(){return this.#value}toString(){return`${this.name}${this.value?" = "+this.value.toString():""}`}}class ESDestructuredValue{#members;constructor(members){this.#members=members}get members(){return this.#members}toString(){return this.#members.map((member=>member.toString())).join(" , ")}}class ESDestructuredArray extends ESDestructuredValue{toString(){return`[ ${super.toString()} ]`}}class ESDestructuredObject extends ESDestructuredValue{toString(){return`{ ${super.toString()} }`}}class ESExport extends ESMember{#members;#from;constructor(members,from){super(""),this.#members=members,this.#from=from}get members(){return this.#members}get from(){return this.#from}hasMember(name){return this.#members.some((member=>member.as===name))}getMember(name){return this.#members.find((member=>member.as===name))}toString(){const postfix=this.#from?` from '${this.#from}'`:"";return`export { ${this.#members.join(", ")} }${postfix}`}}class ESExpression extends ESValue{}class ESField{#name;#value;constructor(name,value){this.#name=name,this.#value=value}get name(){return this.#name}get value(){return this.#value}toString(){return`${this.name}${this.value?" = "+this.value.toString():""}`}}class ESFunction extends ESMember{#parameters;#body;#isAsync;constructor(name,parameters,body,isStatic=!1,isAsync=!1,isPrivate=!1){super(name,isStatic,isPrivate),this.#parameters=parameters,this.#body=body,this.#isAsync=isAsync}get parameters(){return this.#parameters}get body(){return this.#body}get isAsync(){return this.#isAsync}toString(){const parameters=this.parameters.map((parameter=>parameter.toString()));return`${this.isAsync?"async ":""}${this.name}(${parameters.join(", ")}) { ${this.body} }`}}class ESGenerator extends ESFunction{toString(){const parameters=this.parameters.map((parameter=>parameter.toString()));return`${this.isAsync?"async ":""}${this.name}*(${parameters.join(", ")}) { ${this.body} }`}}class ESGetter extends ESFunction{toString(){return`get ${super.toString()}`}}class ESImport extends ESMember{#members;#from;constructor(members,from){super(""),this.#members=members,this.#from=from}get members(){return this.#members}get from(){return this.#from}hasMember(name){return this.#members.some((member=>member.as===name))}getMember(name){return this.#members.find((member=>member.as===name))}toString(){return`import { ${this.#members.map((member=>member.toString())).join(", ")} } from '${this.#from}';`}}class ESModule{#scope;constructor(scope){this.#scope=scope}get scope(){return this.#scope}get members(){return this.#scope.members}get exportedMembers(){return this.#filterExported(this.#scope.members)}get imports(){return this.#scope.imports}get exports(){return this.#scope.exports}get declarations(){return this.#scope.declarations}get exportedDeclarations(){return this.#filterExported(this.#scope.declarations)}get functions(){return this.#scope.functions}get exportedFunctions(){return this.#filterExported(this.#scope.functions)}get generators(){return this.#scope.generators}get exportedGenerators(){return this.#filterExported(this.#scope.generators)}get classes(){return this.#scope.classes}get exportedClasses(){return this.#filterExported(this.#scope.classes)}get exported(){const exported=new Map;for(const exportItem of this.exports)for(const alias of exportItem.members){const member=this.getMember(alias.name);void 0!==member&&exported.set(alias.as,member)}return exported}getMember(name){return this.#scope.getMember(name)}getDeclaration(name){return this.#scope.getDeclaration(name)}getFunction(name){return this.#scope.getFunction(name)}getGenerator(name){return this.#scope.getGenerator(name)}getClass(name){return this.#scope.getClass(name)}hasMember(name){return this.#scope.hasMember(name)}hasDeclaration(name){return this.#scope.hasDeclaration(name)}hasFunction(name){return this.#scope.hasFunction(name)}hasGenerator(name){return this.#scope.hasGenerator(name)}hasClass(name){return this.#scope.hasClass(name)}getImport(name){return this.imports.find((importItem=>importItem.hasMember(name)))}getImported(name){for(const importItem of this.imports)for(const alias of importItem.members)if(alias.as===name)return this.getMember(alias.name)}isExported(member){for(const exportItem of this.exports)for(const alias of exportItem.members)if(alias.name===member.name)return!0;return!1}getExport(name){return this.exports.find((exportItem=>exportItem.hasMember(name)))}getExported(name){for(const exportItem of this.exports)for(const alias of exportItem.members)if(alias.as===name)return this.getMember(alias.name)}#filterExported(members){return members.filter((member=>this.isExported(member)))}}class ESObject extends ESValue{}class ESSetter extends ESFunction{toString(){return`set ${super.toString()}`}}const IMPORT_NAME=ESImport.name,EXPORT_NAME=ESExport.name,DECLARATION_NAME=ESDeclaration.name,FUNCTION_NAME=ESFunction.name,GETTER_NAME=ESGetter.name,SETTER_NAME=ESSetter.name,GENERATOR_NAME=ESGenerator.name,CLASS_NAME=ESClass.name;class ESScope{#members;constructor(members){this.#members=members}get members(){return this.#members}get imports(){return this.#members.filter((member=>member.constructor.name===IMPORT_NAME))}get exports(){return this.#members.filter((member=>member.constructor.name===EXPORT_NAME))}get declarations(){return this.#members.filter((member=>member.constructor.name===DECLARATION_NAME))}get functions(){return this.#members.filter((member=>member.constructor.name===FUNCTION_NAME))}get getters(){return this.#members.filter((member=>member.constructor.name===GETTER_NAME))}get setters(){return this.#members.filter((member=>member.constructor.name===SETTER_NAME))}get generators(){return this.#members.filter((member=>member.constructor.name===GENERATOR_NAME))}get classes(){return this.#members.filter((member=>member.constructor.name===CLASS_NAME))}getMember(name){return this.#members.find((member=>member.name===name))}getDeclaration(name){return this.declarations.find((member=>member.name===name))}getFunction(name){return this.functions.find((member=>member.name===name))}getGetter(name){return this.getters.find((member=>member.name===name))}getSetter(name){return this.setters.find((member=>member.name===name))}getGenerator(name){return this.generators.find((member=>member.name===name))}getClass(name){return this.classes.find((member=>member.name===name))}hasMember(name){return void 0!==this.getMember(name)}hasDeclaration(name){return void 0!==this.getDeclaration(name)}hasFunction(name){return void 0!==this.getFunction(name)}hasGetter(name){return void 0!==this.getGetter(name)}hasSetter(name){return void 0!==this.getSetter(name)}hasGenerator(name){return void 0!==this.getGenerator(name)}hasClass(name){return void 0!==this.getClass(name)}toString(){return this.#members.map((member=>member.toString())).join("\n")}}const Comment={SINGLE:"//",MULTI_START:"/*",MULTI_END:"*/"},Comments=Object.values(Comment);const Punctuation_DOT=".",Punctuation_LEFT_PARENTHESIS="(",Punctuation_RIGHT_PARENTHESIS=")",Punctuation_LEFT_BRACKET="[",Punctuation_RIGHT_BRACKET="]",Punctuation_LEFT_BRACE="{",Punctuation_RIGHT_BRACE="}",Divider={SCOPE:":",SEPARATOR:",",TERMINATOR:";"},Divisions=Object.values(Divider);function isDivider(value){return Divisions.includes(value)}const Empty={UNDEFINED:void 0,NULL:null,STRING:""},Empties=Object.values(Empty);function isEmpty(value){return Empties.includes(value)}const Group={OPEN:Punctuation_LEFT_PARENTHESIS,CLOSE:Punctuation_RIGHT_PARENTHESIS};function isGroup(value){return value===Group.OPEN||value===Group.CLOSE}const Keyword={EXPORT:"export",DEFAULT:"default",CLASS:"class",FUNCTION:"function",CONST:"const",LET:"let",VAR:"var",AS:"as",FROM:"from",IMPORT:"import",GET:"get",SET:"set",EXTENDS:"extends",STATIC:"static",ASYNC:"async",RETURN:"return"},Keywords=Object.values(Keyword);function isKeyword(value){return Keywords.includes(value)}function isNotReserved(value){return value===Keyword.AS||value===Keyword.ASYNC||value===Keyword.FROM||value===Keyword.GET||value===Keyword.SET}const List={OPEN:Punctuation_LEFT_BRACKET,CLOSE:Punctuation_RIGHT_BRACKET};function isList(value){return value===List.OPEN||value===List.CLOSE}const Literals=Object.values({SINGLE:"'",DOUBLE:'"',BACKTICK:"`"});function isLiteral(value){return Literals.includes(value)}const Operator={ADD:"+",ARROW:"=>",ASSIGN:"=",ASSIGN_ADD:"+=",ASSIGN_BITWISE_AND:"&=",ASSIGN_BITWISE_OR:"|=",ASSIGN_DIVIDE:"/=",ASSIGN_LEFT_SHIFT:"<<=",ASSIGN_LOGICAL_AND:"&&=",ASSIGN_LOGICAL_OR:"||=",ASSIGN_MODULO:"%=",ASSIGN_MULTIPLY:"*=",ASSIGN_RIGHT_SHIFT:">>=",ASSIGN_SUBTRACT:"-=",ASSIGN_XOR:"^=",BITWISE_AND:"&",BITWISE_OR:"|",DECREMENT:"--",DIVIDE:"/",EQUAL:"==",EQUAL_STRICT:"===",GREATER:">",GREATER_EQUAL:">=",INCREMENT:"++",LEFT_SHIFT:"<<",LESS:"<",LESS_EQUAL:"<=",LOGICAL_AND:"&&",LOGICAL_OR:"||",MODULO:"%",MULTIPLY:"*",NOT:"!",NOT_EQUAL:"!=",NOT_EQUAL_STRICT:"!==",RIGHT_SHIFT:">>",SUBTRACT:"-",TERNARY:"?",XOR:"^"},Operators=Object.values(Operator);function isOperator(value){return Operators.includes(value)}const Scope={OPEN:Punctuation_LEFT_BRACE,CLOSE:Punctuation_RIGHT_BRACE};function isScope(value){return value===Scope.OPEN||value===Scope.CLOSE}const TokenType={COMMENT:"comment",DIVIDER:"divider",GROUP:"group",IDENTIFIER:"identifier",KEYWORD:"keyword",LIST:"list",LITERAL:"literal",OPERATOR:"operator",REGEX:"regex",SCOPE:"scope",WHITESPACE:"whitespace"},Whitespace={SPACE:" ",TAB:"\t",NEWLINE:"\n",CARRIAGE_RETURN:"\r"},Whitespaces=Object.values(Whitespace);function isWhitespace(value){return Whitespaces.includes(value)}class ItemList{#items;#position;constructor(items){this.#items=items,this.#position=0}get items(){return this.#items}get position(){return this.#position}get size(){return this.#items.length}get eol(){return this.#position>=this.#items.length}get current(){return this.#items[this.#position]}get next(){return this.#items[this.#position+1]}get previous(){return this.#items[this.#position-1]}notAtEnd(){return!1===this.eol}get(index){return this.#items[index]}step(amount=1){return this.#position+=amount,this.current}stepBack(amount=1){return this.#position-=amount,this.current}hasNext(){return this.#position+1<this.#items.length}}class CharList extends ItemList{constructor(code){super(code.split(""))}}class Token{#type;#value;#start;#end;constructor(type,value,start,end){this.#type=type,this.#value=value,this.#start=start,this.#end=end}get type(){return this.#type}get value(){return this.#value}get start(){return this.#start}get end(){return this.#end}isType(type){return this.#type===type}hasValue(value){return this.#value===value}toString(){return`${this.#value}`}}class TokenList extends ItemList{}class Lexer{tokenize(code){const charList=new CharList(code),tokens=[];let last;for(;charList.notAtEnd();){const token=this.#getNextToken(charList,last);if(void 0===token)break;token.isType(TokenType.WHITESPACE)||token.isType(TokenType.COMMENT)?charList.step():(tokens.push(token),this.#isCodeToken(token)&&(last=token),charList.step())}return new TokenList(tokens)}#isCodeToken(token){return!1===[TokenType.WHITESPACE,TokenType.COMMENT].includes(token.type)}#getNextToken(charList,lastToken){const char=charList.current,start=charList.position;if(isWhitespace(char)){const end=charList.position;return new Token(TokenType.WHITESPACE,char,start,end)}if(function(value){return Comments.includes(value)}(char+charList.next)){const value=this.#readComment(charList),end=charList.position;return new Token(TokenType.COMMENT,value,start,end)}if(this.#startsRegex(char,lastToken)){const value=this.#readRegex(charList),end=charList.position;return new Token(TokenType.REGEX,value,start,end)}if(isLiteral(char)){const value=this.#readLiteral(charList),end=charList.position;return new Token(TokenType.LITERAL,value,start,end)}if(isOperator(char)){const value=this.#readOperation(charList),end=charList.position;return new Token(TokenType.OPERATOR,value,start,end)}if(isDivider(char)){const end=charList.position;return new Token(TokenType.DIVIDER,char,start,end)}if(isGroup(char)){const end=charList.position;return new Token(TokenType.GROUP,char,start,end)}if(isScope(char)){const end=charList.position;return new Token(TokenType.SCOPE,char,start,end)}if(isList(char)){const end=charList.position;return new Token(TokenType.LIST,char,start,end)}if(isEmpty(char))return;const value=this.#readIdentifier(charList),type=isKeyword(value)?TokenType.KEYWORD:TokenType.IDENTIFIER,end=charList.position;return new Token(type,value,start,end)}#readComment(charList){const isMulti=charList.current+charList.next===Comment.MULTI_START,terminator=isMulti?Comment.MULTI_END:Whitespace.NEWLINE;let value=isMulti?Comment.MULTI_START:Comment.SINGLE;for(charList.step(2);charList.notAtEnd();){const char=charList.current;if((isMulti?char+charList.next:char)===terminator){charList.step(terminator.length-1);break}value+=char,charList.step()}return isMulti?value+Comment.MULTI_END:value.trim()}#startsRegex(char,lastToken){return char===Operator.DIVIDE&&(void 0===lastToken||([TokenType.OPERATOR,TokenType.DIVIDER,TokenType.KEYWORD].includes(lastToken.type)||[Group.OPEN,List.OPEN].includes(lastToken.value)))}#endsRegex(char){return isWhitespace(char)||char==Punctuation_DOT||!1===this.#isIdentifier(char)}#readRegex(charList){let value=charList.current,closed=!1;for(charList.step();charList.notAtEnd();){const current=charList.current,previous=charList.previous;if(current===Operator.DIVIDE&&"\\"!==previous)closed=!0;else if(!0===closed&&this.#endsRegex(current)){charList.stepBack();break}value+=current,charList.step()}return value}#readLiteral(charList){const identifier=charList.current;let value=identifier,escaped=!1;for(charList.step();charList.notAtEnd();){const char=charList.current;if(!1===escaped){if(char===identifier){value+=char;break}"\\"===char&&(escaped=!0)}else escaped=!1;value+=char,charList.step()}return value}#isIdentifier(char){return!1===(isEmpty(char)||isWhitespace(char)||isOperator(char)||isLiteral(char)||isDivider(char)||isGroup(char)||isScope(char)||isList(char))}#readIdentifier(charList){let value="";for(;charList.notAtEnd();){const char=charList.current;if(!1===this.#isIdentifier(char)){charList.stepBack();break}value+=char,charList.step()}return value}#readOperation(charList){let value=charList.current;for(charList.step();charList.notAtEnd();){const char=charList.current;if(!1===isOperator(char)||!1===isOperator(value+char)){charList.stepBack();break}value+=char,charList.step()}return value}}class ExpectedKeyword extends Error{constructor(value,position){super(`Expected keyword '${value}' at position ${position}`)}}class ExpectedToken extends Error{constructor(value,position){super(`Expected token '${value}' at position ${position}`)}}class UnexpectedKeyword extends Error{constructor(keyword,position){super(`Unexpected keyword '${keyword}' at position ${position}`)}}class UnexpectedParseResult extends Error{constructor(expected){super(`The given code does not contain ${expected}`)}}class UnexpectedToken extends Error{constructor(value,position){super(`Unexpected token '${value}' at position ${position}`)}}class Parser{#lexer;constructor(lexer=new Lexer){this.#lexer=lexer}parse(code){const tokenList=this.#lexer.tokenize(code),scope=this.#parseScope(tokenList);return new ESModule(scope)}parseFirst(code){const tokenList=this.#lexer.tokenize(code);return this.#parseNext(tokenList)}parseValue(code){const model=this.parseFirst(code);if(model instanceof ESValue==!1)throw new UnexpectedParseResult("a value definition");return model}parseImport(code){const model=this.parseFirst(code);if(model instanceof ESImport==!1)throw new UnexpectedParseResult("an import definition");return model}parseExport(code){const model=this.parseFirst(code);if(model instanceof ESExport==!1)throw new UnexpectedParseResult("an export definition");return model}parseDeclaration(code){const model=this.parseFirst(code);if(model instanceof ESDeclaration==!1)throw new UnexpectedParseResult("a declaration definition");return model}parseFunction(code){const tokenList=this.#lexer.tokenize(code),model=this.#parseMember(tokenList);if(model instanceof ESFunction==!1)throw new UnexpectedParseResult("a function definition");return model}parseClass(code){const tokenList=this.#lexer.tokenize(code),model=this.#parseMember(tokenList);if(model instanceof ESClass==!1)throw new UnexpectedParseResult("a class definition");return model}#parseScope(tokenList){const members=[];for(;tokenList.notAtEnd();){const member=this.#parseNext(tokenList);member instanceof ESMember&&members.push(member)}return new ESScope(members)}#parseNext(tokenList,isAsync=!1){const token=tokenList.current;if(token.isType(TokenType.LITERAL))return this.#parseExpression(tokenList);if(token.isType(TokenType.IDENTIFIER)){const next=tokenList.next;return next?.hasValue(Operator.ARROW)?this.#parseArrowFunction(tokenList,isAsync):this.#parseExpression(tokenList)}if(token.isType(TokenType.KEYWORD)){if(isNotReserved(token.value)){const next=tokenList.next,nextIsFunction=void 0!==next&&(next.hasValue(Keyword.FUNCTION)||next.hasValue(Group.OPEN));if(token.hasValue(Keyword.ASYNC)&&nextIsFunction)return tokenList.step(),this.#parseNext(tokenList,!0);if(void 0===next||this.#atEndOfStatement(next))return this.#parseExpression(tokenList)}return token.hasValue(Keyword.RETURN)?this.#parseExpression(tokenList):this.#parseMember(tokenList,isAsync)}if(token.isType(TokenType.REGEX))return this.#parseExpression(tokenList);if(token.hasValue(Group.OPEN)){const next=this.#peekAfterBlock(tokenList,Group.OPEN,Group.CLOSE);return next?.hasValue(Operator.ARROW)?this.#parseArrowFunction(tokenList,isAsync):this.#parseExpression(tokenList)}if(token.hasValue(Scope.OPEN))return this.#parseObject(tokenList);if(token.hasValue(List.OPEN))return this.#parseArray(tokenList);if(token.hasValue(Operator.NOT)||token.hasValue(Operator.SUBTRACT))return this.#parseExpression(tokenList);if(!isDivider(token.value))throw new UnexpectedToken(token.value,token.start);tokenList.step()}#parseMember(tokenList,isAsync=!1){const token=tokenList.current;switch(tokenList.step(),token.value){case Keyword.IMPORT:return this.#parseImport(tokenList);case Keyword.EXPORT:return this.#parseExport(tokenList);case Keyword.CLASS:return this.#parseClass(tokenList);case Keyword.FUNCTION:return this.#parseFunction(tokenList,isAsync);case Keyword.VAR:case Keyword.LET:case Keyword.CONST:return this.#parseDeclaration(tokenList,!1,!0);case Keyword.ASYNC:return this.#parseMember(tokenList,!0);default:throw new UnexpectedKeyword(token.value,token.start)}}#parseImport(tokenList){const members=[];let token=tokenList.current;if(token.isType(TokenType.LITERAL))return new ESImport(members,token.value);if(token.hasValue(Group.OPEN)){token=tokenList.step();const from=token.value;return tokenList.step(2),new ESImport(members,from)}if(!1===token.hasValue(Scope.OPEN)){const name=token.hasValue(Operator.MULTIPLY)?Operator.MULTIPLY:"default";let as=token.value;token=tokenList.step(),token.hasValue(Keyword.AS)&&(token=tokenList.step(),as=token.value,token=tokenList.step()),members.push(new ESAlias(name,as))}if(token.hasValue(Divider.SEPARATOR)&&(token=tokenList.step()),token.hasValue(Scope.OPEN)){const aliases=this.#parseAliasList(tokenList);members.push(...aliases),token=tokenList.current}if(!1===token.hasValue(Keyword.FROM))throw new ExpectedKeyword(Keyword.FROM,token.start);token=tokenList.step();const from=token.value;return tokenList.step(),new ESImport(members,from)}#parseExport(tokenList){switch(tokenList.current.value){case Keyword.DEFAULT:return tokenList.step(),this.#parseSingleExport(tokenList,!0);case Scope.OPEN:return this.#parseMultiExport(tokenList);default:return this.#parseSingleExport(tokenList,!1)}}#parseSingleExport(tokenList,isDefault){let token=tokenList.current,stepSize=0;var value;token.hasValue(Keyword.ASYNC)&&(token=tokenList.step(),stepSize++),((value=token.value)===Keyword.CLASS||value===Keyword.FUNCTION||value===Keyword.CONST||value===Keyword.LET||value===Keyword.VAR)&&(token=tokenList.step(),stepSize++);const name=this.#isIdentifier(token)?token.value:"",as=isDefault?"default":name;let from;token=tokenList.step(),token?.hasValue(Keyword.FROM)&&(token=tokenList.step(),from=token.value),stepSize>0&&(stepSize++,tokenList.stepBack(stepSize));const alias=new ESAlias(name,as);return new ESExport([alias],from)}#parseMultiExport(tokenList){const members=this.#parseAliasList(tokenList);let from,token=tokenList.current;return token?.hasValue(Keyword.FROM)&&(token=tokenList.step(),from=token.value),tokenList.step(),new ESExport(members,from)}#parseAliasList(tokenList){const aliases=[];let token=tokenList.step();for(;tokenList.notAtEnd();){if(token.hasValue(Scope.CLOSE)){tokenList.step();break}if(token.hasValue(Divider.SEPARATOR)){token=tokenList.step();continue}const alias=this.#parseAlias(tokenList);aliases.push(alias),token=tokenList.step()}return aliases}#parseAlias(tokenList){let token=tokenList.current;const name=token.value;let as=name;return tokenList.next.hasValue(Keyword.AS)&&(token=tokenList.step(2),as=token.value),new ESAlias(name,as)}#parseDeclaration(tokenList,isStatic,parseMultiple=!1){let identifier,value,token=tokenList.current,isPrivate=!1;return token.hasValue(List.OPEN)?(identifier=this.#parseDestructuredArray(tokenList),token=tokenList.current):token.hasValue(Scope.OPEN)?(identifier=this.#parseDestructuredObject(tokenList),token=tokenList.current):(isPrivate=token.value.startsWith("#"),identifier=isPrivate?token.value.substring(1):token.value,token=tokenList.step()),token.hasValue(Operator.ASSIGN)&&(tokenList.step(),value=this.#parseNext(tokenList,!1),token=tokenList.current),void 0!==token&&(token.hasValue(Divider.TERMINATOR)?tokenList.step():!0===parseMultiple&&token.hasValue(Divider.SEPARATOR)&&(tokenList.step(),this.#parseDeclaration(tokenList,isStatic,!0))),value instanceof ESGenerator?new ESGenerator(identifier.toString(),value.parameters,value.body,isStatic,value.isAsync,isPrivate):value instanceof ESFunction?new ESFunction(identifier.toString(),value.parameters,value.body,isStatic,value.isAsync,isPrivate):value instanceof ESClass?new ESClass(identifier.toString(),value.parentName,value.scope):new ESDeclaration(identifier,value,isStatic,isPrivate)}#parseFunction(tokenList,isAsync,isStatic=!1,isGetter=!1,isSetter=!1){let token=tokenList.current,name="",isGenerator=!1,isPrivate=!1;token.hasValue(Operator.MULTIPLY)&&(isGenerator=!0,token=tokenList.step()),this.#isIdentifier(token)&&(isPrivate=token.value.startsWith("#"),name=isPrivate?token.value.substring(1):token.value,token=tokenList.step());const parameters=this.#parseParameters(tokenList,Group.CLOSE);if(token=tokenList.current,!1===token.hasValue(Scope.OPEN))throw new ExpectedToken(Scope.OPEN,token.start);const body=this.#parseBlock(tokenList,Scope.OPEN,Scope.CLOSE);return isGenerator?new ESGenerator(name,parameters,body,isStatic,isAsync,isPrivate):isGetter?new ESGetter(name,parameters,body,isStatic,isAsync,isPrivate):isSetter?new ESSetter(name,parameters,body,isStatic,isAsync,isPrivate):new ESFunction(name,parameters,body,isStatic,isAsync,isPrivate)}#parseArrowFunction(tokenList,isAsync){let parameters,token=tokenList.current;if(token.hasValue(Group.OPEN)?(parameters=this.#parseParameters(tokenList,Group.CLOSE),token=tokenList.current):(parameters=[new ESField(token.value,void 0)],token=tokenList.step()),!1===token.hasValue(Operator.ARROW))throw new ExpectedToken(Operator.ARROW,token.start);token=tokenList.step();const body=token.hasValue(Scope.OPEN)?this.#parseBlock(tokenList,Scope.OPEN,Scope.CLOSE):this.#parseExpression(tokenList).definition;return new ESFunction("",parameters,body,!1,isAsync,!1)}#parseParameters(tokenList,closeId){const parameters=[];for(tokenList.step();tokenList.notAtEnd();){const token=tokenList.current;if(token.hasValue(closeId)){tokenList.step();break}if(token.hasValue(Divider.SEPARATOR)){tokenList.step();continue}let parameter;parameter=token.hasValue(Scope.OPEN)?this.#parseDestructuredObject(tokenList):token.hasValue(List.OPEN)?this.#parseDestructuredArray(tokenList):this.#parseField(tokenList),parameters.push(parameter)}return parameters}#parseClass(tokenList){let parent,token=tokenList.current,name="";if(this.#isIdentifier(token)&&(name=token.value,token=tokenList.step()),token.hasValue(Keyword.EXTENDS)&&(token=tokenList.step(),parent=token.value,token=tokenList.step()),!1===token.hasValue(Scope.OPEN))throw new ExpectedToken(Scope.OPEN,token.start);const scope=this.#parseClassScope(tokenList);return new ESClass(name,parent,scope)}#parseClassScope(tokenList){let token=tokenList.step();const members=[];for(;tokenList.notAtEnd();){if(token.hasValue(Scope.CLOSE)){tokenList.step();break}const member=this.#parseClassMember(tokenList);members.push(member),token=tokenList.current}return new ESScope(members)}#parseClassMember(tokenList){let token=tokenList.current,isAsync=!1,isStatic=!1,isGetter=!1,isSetter=!1;for(;tokenList.notAtEnd();){if(token.hasValue(Keyword.STATIC))isStatic=!0;else if(token.hasValue(Keyword.ASYNC))isAsync=!0;else if(token.hasValue(Keyword.GET))isGetter=!0;else{if(!token.hasValue(Keyword.SET)){if(token.hasValue(Operator.MULTIPLY))return this.#parseFunction(tokenList,isAsync,isStatic,!1,!1);break}isSetter=!0}token=tokenList.step()}return tokenList.next.hasValue(Group.OPEN)?this.#parseFunction(tokenList,isAsync,isStatic,isGetter,isSetter):this.#parseDeclaration(tokenList,isStatic)}#parseArray(tokenList){const items=this.#parseBlock(tokenList,List.OPEN,List.CLOSE);return new ESArray(items)}#parseDestructuredArray(tokenList){const fields=this.#parseParameters(tokenList,List.CLOSE);return new ESDestructuredArray(fields)}#parseObject(tokenList){const fields=this.#parseBlock(tokenList,Scope.OPEN,Scope.CLOSE);return new ESObject(fields)}#parseDestructuredObject(tokenList){const fields=this.#parseParameters(tokenList,Scope.CLOSE);return new ESDestructuredObject(fields)}#parseField(tokenList){let token=tokenList.current;const name=token.value;let value;return token=tokenList.step(),token.hasValue(Operator.ASSIGN)&&(tokenList.step(),value=this.#parseNext(tokenList,!1)),new ESField(name,value)}#parseExpression(tokenList){let token=tokenList.current,code="";for(;tokenList.notAtEnd();){if(token.hasValue(List.OPEN)){code+=this.#parseBlock(tokenList,List.OPEN,List.CLOSE)+" ",token=tokenList.current}else if(token.hasValue(Group.OPEN)){code+=this.#parseBlock(tokenList,Group.OPEN,Group.CLOSE)+" ",token=tokenList.current}else if(token.hasValue(Scope.OPEN)){code+=this.#parseBlock(tokenList,Scope.OPEN,Scope.CLOSE)+" ",token=tokenList.current}else code+=token.toString()+" ",token=tokenList.step();if(void 0===token||this.#atEndOfStatement(token))break}return new ESExpression(code.trim())}#parseBlock(tokenList,openId,closeId){let token=tokenList.step(),code=openId+" ";for(;tokenList.notAtEnd();)if(token.hasValue(openId))code+=this.#parseBlock(tokenList,openId,closeId)+" ",token=tokenList.current;else{if(token.hasValue(closeId))return tokenList.step(),code+=closeId,code;code+=token.toString()+" ",token=tokenList.step()}return code}#peekAfterBlock(tokenList,openId,closeId){const start=tokenList.position;this.#parseBlock(tokenList,openId,closeId);const token=tokenList.current,end=tokenList.position;return tokenList.stepBack(end-start),token}#atEndOfStatement(token){return[Divider.TERMINATOR,Divider.SEPARATOR].includes(token.value)||[List.CLOSE,Group.CLOSE,Scope.CLOSE].includes(token.value)||isKeyword(token.value)}#isIdentifier(token){return token.isType(TokenType.IDENTIFIER)||token.isType(TokenType.KEYWORD)&&isNotReserved(token.value)}}class ClassMerger{merge(model,parent){const declarations=this.#mergeDeclarations(model.declarations,parent.declarations),functions=this.#mergeFunctions(model.functions,parent.functions),getters=this.#mergeFunctions(model.getters,parent.getters),setters=this.#mergeFunctions(model.setters,parent.setters),members=[...declarations.values(),...functions.values(),...getters.values(),...setters.values()];return new ESClass(model.name,parent.name,new ESScope(members))}#mergeDeclarations(model,parent){const declarations=new Map;return parent.forEach((declaration=>declarations.set(declaration.name,declaration))),model.forEach((declaration=>declarations.set(declaration.name,declaration))),[...declarations.values()]}#mergeFunctions(model,parent){const functions=new Map;return parent.forEach((funktion=>functions.set(funktion.name,funktion))),model.forEach((funktion=>functions.set(funktion.name,funktion))),[...functions.values()]}}class Reflector{#parser=new Parser;#merger=new ClassMerger;fromModule(module,inherit=!1){const entries=Object.entries(module),members=[];for(const[key,member]of entries){if("function"!=typeof member.toString)continue;const code=member.toString();if(code.startsWith("class"))members.push(this.fromClass(member,inherit));else if(code.startsWith("function"))members.push(this.fromFunction(member));else{const expression=new ESExpression(code);members.push(new ESDeclaration(key,expression))}}return new ESModule(new ESScope(members))}fromClass(clazz,inherit=!1){const model=this.isClass(clazz)?this.#reflectStatic(clazz):this.#reflectDynamic(clazz);if(!1===inherit)return model;const parentClazz=this.getParentClass(clazz);if(""===parentClazz.name)return model;const parentModel=this.fromClass(parentClazz,!0);return this.#merger.merge(model,parentModel)}fromObject(object,inherit=!0){const clazz=this.getClass(object);return this.fromClass(clazz,inherit)}fromFunction(funktion){const code=funktion.toString();return this.#parser.parseFunction(code)}createInstance(clazz,args=[]){return new clazz(...args)}getClass(object){return object.constructor}getParentClass(clazz){return Object.getPrototypeOf(clazz)}isClassObject(object){return this.isClass(object.constructor)}isFunctionObject(object){return this.isFunction(object.constructor)}isClass(clazz){return clazz.toString().startsWith("class")}isFunction(clazz){return clazz.toString().startsWith("function")||clazz.toString().startsWith("async function")}#reflectStatic(clazz){const code=clazz.toString();return this.#parser.parseClass(code)}#reflectDynamic(clazz){const object=this.createInstance(clazz),members=this.#getMembers(clazz,object),scope=new ESScope(members);return new ESClass(clazz.name,void 0,scope)}#getMembers(clazz,object){return[...this.#getDeclarations(object),...this.#getFunctions(clazz)]}#getDeclarations(object){const fieldNames=Object.getOwnPropertyNames(object),values=object,models=[];for(const fieldName of fieldNames){const content=values[fieldName],value=void 0!==content?new ESValue(String(content)):void 0,model=new ESDeclaration(fieldName,value);models.push(model)}return models}#getFunctions(clazz){const functionDescriptions=Object.getOwnPropertyDescriptors(clazz.prototype),models=[];for(const functionName in functionDescriptions){const description=functionDescriptions[functionName],funktion=description.value;if(funktion instanceof Function==!1)continue;const model=this.fromFunction(funktion);void 0!==description.get?models.push(new ESGetter(model.name,model.parameters,model.body,model.isStatic,model.isAsync,model.isPrivate)):void 0!==description.set?models.push(new ESSetter(model.name,model.parameters,model.body,model.isStatic,model.isAsync,model.isPrivate)):models.push(model)}return models}}let FileNotLoaded$1=class extends Error{constructor(filename,message){super(`Failed to load module file '${filename}' because of: ${message}`)}},LocationRewriter$1=class{#sourceFileManager;#parser=new Parser;#fileHelper=new FileHelper;constructor(sourceFileManager){this.#sourceFileManager=sourceFileManager}rewrite(filename,code){const replacedImports=this.#rewriteImports(filename,code);return this.#rewriteExports(filename,replacedImports)}#rewriteImports(filename,code){return code.replaceAll(Patterns_IMPORT,(statement=>this.#replaceImport(filename,statement)))}#rewriteExports(filename,code){return code.replaceAll(Patterns_EXPORT,(statement=>this.#replaceExport(filename,statement)))}#replaceImport(filename,statement){const dependency=this.#parser.parseImport(statement),from=this.#fileHelper.stripPath(dependency.from);if(!1===this.#fileHelper.isApplicationModule(from))return statement;const rewrittenFrom=this.#rewriteFrom(filename,from);return statement.replace(from,rewrittenFrom)}#replaceExport(filename,statement){const dependency=this.#parser.parseExport(statement);if(void 0===dependency.from)return statement;const from=this.#fileHelper.stripPath(dependency.from);if(!1===this.#fileHelper.isApplicationModule(from))return statement;const rewrittenFrom=this.#rewriteFrom(filename,from);return statement.replace(from,rewrittenFrom)}#rewriteFrom(filename,from){const callingModulePath=this.#fileHelper.extractPath(filename),translated=this.#fileHelper.makePathAbsolute(from,callingModulePath);return this.#sourceFileManager.isDirectory(translated)?`${from}/${Files_INDEX}`:this.#fileHelper.assureExtension(from)}},Reader$1=class{#sourceFileManager;#parser;#locationRewriter;constructor(sourceFileManager,parser=new Parser){this.#sourceFileManager=sourceFileManager,this.#parser=parser,this.#locationRewriter=new LocationRewriter$1(sourceFileManager)}async readAll(filenames){const modules=await Promise.all(filenames.map((filename=>this.read(filename))));return new Repository(modules)}async read(filename){const relativeLocation=this.#sourceFileManager.getRelativeLocation(filename),code=await this.#loadCode(filename),rewritt