jitar 0.10.7 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigurationManager-D8N-pXTY.js +1 -0
- package/dist/cli.js +1 -1
- package/dist/client.js +1 -1
- package/dist/lib.d.ts +76 -1
- package/dist/lib.js +1 -1
- package/dist/templates/backend/jitar.json +1 -1
- package/dist/templates/backend/{_package.json → package.json} +4 -3
- package/dist/templates/backend/src/tsconfig.json +8 -0
- package/dist/templates/{react/tsconfig.base.json → backend/tsconfig.json} +4 -11
- package/dist/templates/react/jitar.json +1 -1
- package/dist/templates/react/package.json +28 -0
- package/dist/templates/react/services/standalone.json +1 -0
- package/dist/templates/react/src/{webui → app/components}/App.tsx +3 -3
- package/dist/templates/react/{index.html → src/app/index.html} +1 -1
- package/dist/templates/react/src/app/public/vite.svg +1 -0
- package/dist/templates/react/src/app/tsconfig.json +9 -0
- package/dist/templates/react/src/app/vite.config.ts +25 -0
- package/dist/templates/react/src/tsconfig.json +8 -0
- package/dist/templates/react/tsconfig.json +15 -0
- package/dist/templates/vue/jitar.json +1 -1
- package/dist/templates/vue/package.json +27 -0
- package/dist/templates/vue/services/standalone.json +1 -0
- package/dist/templates/vue/src/{webui → app/components}/App.vue +3 -3
- package/dist/templates/vue/{index.html → src/app/index.html} +1 -1
- package/dist/templates/vue/src/app/public/vite.svg +1 -0
- package/dist/templates/vue/src/app/tsconfig.json +7 -0
- package/dist/templates/vue/src/app/vite.config.ts +25 -0
- package/dist/templates/vue/src/domain/sayHello.js +3 -0
- package/dist/templates/vue/src/tsconfig.json +8 -0
- package/dist/templates/vue/tsconfig.json +15 -0
- package/package.json +4 -4
- package/dist/Response-DEjrdAZ9.js +0 -1
- package/dist/templates/backend/_gitignore +0 -25
- package/dist/templates/backend/_tsconfig.json +0 -20
- package/dist/templates/react/_gitignore +0 -25
- package/dist/templates/react/_package.json +0 -28
- package/dist/templates/react/_tsconfig.json +0 -6
- package/dist/templates/react/_vite.config.ts +0 -14
- package/dist/templates/react/public/vite.svg +0 -1
- package/dist/templates/react/src/vite-env.d.ts +0 -1
- package/dist/templates/react/tsconfig.build.json +0 -11
- package/dist/templates/vue/_gitignore +0 -25
- package/dist/templates/vue/_package.json +0 -26
- package/dist/templates/vue/_tsconfig.json +0 -19
- package/dist/templates/vue/_vite.config.ts +0 -14
- package/dist/templates/vue/public/vite.svg +0 -1
- package/dist/templates/vue/src/vite-env.d.ts +0 -1
- package/dist/templates/vue/tsconfig.build.json +0 -10
- /package/dist/templates/react/src/{webui → app}/assets/jitar.svg +0 -0
- /package/dist/templates/react/src/{webui → app}/assets/react.svg +0 -0
- /package/dist/templates/react/src/{webui → app/components}/App.css +0 -0
- /package/dist/templates/react/src/{webui → app/components}/index.css +0 -0
- /package/dist/templates/react/src/{webui → app/components}/main.tsx +0 -0
- /package/dist/templates/vue/src/{webui → app}/assets/jitar.svg +0 -0
- /package/dist/templates/vue/src/{webui → app}/assets/vue.svg +0 -0
- /package/dist/templates/vue/src/{webui → app/components}/main.ts +0 -0
- /package/dist/templates/vue/src/{webui → app/components}/style.css +0 -0
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class e extends Error{constructor(e="Invalid request"){super(e)}}class t extends Error{constructor(e="Forbidden"){super(e)}}class s extends Error{constructor(e="Not found"){super(e)}}class r extends Error{constructor(e="Not implemented"){super(e)}}class n extends Error{constructor(e="Payment required"){super(e)}}class a extends Error{constructor(e="Server error"){super(e)}}class i extends Error{constructor(e="I'm a teapot"){super(e)}}class o extends Error{constructor(e="Unauthorized"){super(e)}}const c="private",u="protected",l="public",h="normal",d="dry",p=200,m=400,g=401,f=402,w=403,y=404,v=418,S=500,E=501;class b extends e{#e;constructor(e){super(`Invalid version number '${e}'`),this.#e=e}get number(){return this.#e}}class x extends s{#t;constructor(e){super(`Procedure '${e}' not found`),this.#t=e}get fqn(){return this.#t}}class O extends t{constructor(e,t){super(`Procedure '${e}' (v${t}) is not accessible`)}}class A{#s;#r=new Map;#n=new Map;constructor(e){this.#s=e}get id(){return this.#s}addClass(e){return this.#r.set(e.fqn,e),this}hasClass(e){return void 0!==this.getClass(e)}getClass(e){return this.#r.get(e)}getClassByImplementation(e){return this.getClasses().find(t=>t.implementation===e)}getClasses(){return[...this.#r.values()]}addProcedure(e){return this.#n.set(e.fqn,e),this}hasProcedure(e){return this.#n.has(e)}getProcedure(e){return this.#n.get(e)}getExposedProcedures(){return[...this.#n.values()].filter(e=>e.public||e.protected)}}class C{#t;#a;constructor(e,t){this.#t=e,this.#a=t}get fqn(){return this.#t}get implementation(){return this.#a}}class I{static get DEFAULT(){return new I(0,0,0)}#i;#o;#c;constructor(e=0,t=0,s=0){this.#i=e,this.#o=t,this.#c=s}get major(){return this.#i}get minor(){return this.#o}get patch(){return this.#c}equals(e){return this.#i===e.major&&this.#o===e.minor&&this.#c===e.patch}greater(e){return this.#i!==e.major?this.#i>e.major:this.#o!==e.minor?this.#o>e.minor:this.#c!==e.patch&&this.#c>e.patch}less(e){return this.#i!==e.major?this.#i<e.major:this.#o!==e.minor?this.#o<e.minor:this.#c!==e.patch&&this.#c<e.patch}toString(){return`${this.#i}.${this.#o}.${this.#c}`}}class N{#t;#u=new Map;#l;constructor(e){this.#t=e}get fqn(){return this.#t}get public(){return[...this.#u.values()].some(e=>e.public)}get protected(){return[...this.#u.values()].some(e=>e.protected)}addImplementation(e){return this.#u.set(e.version,e),this.#h(e)&&(this.#l=e),this}#h(e){return void 0===this.#l||e.version.greater(this.#l.version)}getImplementation(e){const t=this.#d(e);return this.#u.get(t)}#d(e){let t=I.DEFAULT;for(const s of this.#u.keys()){if(s.equals(e))return s;s.greater(e)||t.less(s)&&(t=s)}return t}}class M{#p;#m;#g;#f;constructor(e,t,s,r){this.#p=e,this.#m=t,this.#g=s,this.#f=r}get version(){return this.#p}get public(){return this.#m===l}get protected(){return this.#m===u}get private(){return this.#m===c}get parameters(){return this.#g}get executable(){return this.#f}}class T{#w;#y;constructor(e,t=!1){this.#w=e,this.#y=t}get name(){return this.#w}get isOptional(){return this.#y}}class R extends T{}class z extends T{#v;constructor(e,t,s){super(t??"(anonymous)",s),this.#v=e}get variables(){return this.#v}}class P extends z{}class L extends z{}class k{#t;#p;#S;#E=new Map;#b;constructor(e,t,s,r,n){this.#t=e,this.#p=t,this.#S=s,this.#E=r,this.#b=n}get fqn(){return this.#t}get version(){return this.#p}get args(){return this.#S}get headers(){return this.#E}get mode(){return this.#b}clearArguments(){this.#S.clear()}setArgument(e,t){this.#S.set(e,t)}getArgument(e){return this.#S.get(e)}hasArgument(e){return this.#S.has(e)}removeArgument(e){this.#S.delete(e)}clearHeaders(){this.#E.clear()}setHeader(e,t){this.#E.set(e.toLowerCase(),t)}getHeader(e){return this.#E.get(e.toLowerCase())}hasHeader(e){return this.#E.has(e.toLowerCase())}removeHeader(e){this.#E.delete(e.toLowerCase())}}class D{#x;#O;#E;constructor(e,t=void 0,s=new Map){this.#x=e,this.#O=t,this.#E=s}get status(){return this.#x}get result(){return this.#O}set result(e){this.#O=e}get headers(){return this.#E}clearHeaders(){this.#E.clear()}setHeader(e,t){this.#E.set(e.toLowerCase(),t)}getHeader(e){return this.#E.get(e.toLowerCase())}hasHeader(e){return this.#E.has(e.toLowerCase())}removeHeader(e){this.#E.delete(e.toLowerCase())}}class F extends e{#A;constructor(e){super(`Unknown parameter ${e}`),this.#A=e}get parameterName(){return this.#A}}class V extends e{#A;constructor(e){super(`Missing value for parameter '${e}'`),this.#A=e}get parameterName(){return this.#A}}class j extends e{#A;constructor(e){super(`Invalid value for parameter '${e}'`),this.#A=e}get parameterName(){return this.#A}}class ${extract(e,t){const s=this.#C(e,t),r=[];for(const t of e){const e=this.#I(t,s);r.push(e)}if(s.size>0){const e=s.keys().next().value;throw new F(e)}return r}#C(e,t){const s=new Map;for(const[r,n]of t){if(this.#N(r)){const t=this.#M(r);!0===this.#T(e,t)&&s.set(t,n);continue}s.set(r,n)}return s}#N(e){return e.startsWith("*")}#M(e){return e.substring(1)}#T(e,t){return void 0!==e.find(e=>e.name===t)}#I(e,t,s){return e instanceof R?this.#R(e,t,s):this.#z(e,t)}#R(e,t,s){const r=t.get(e.name);if(this.#P(e,r,s))throw new V(e.name);if(this.#L(e,r,s))throw new j(e.name);return t.delete(e.name),r}#z(e,t){return e instanceof P?this.#k(e,t):this.#D(e,t)}#k(e,t){const s=this.#F(e,t);return void 0!==s?Object.values(s):void 0}#D(e,t){return this.#F(e,t)}#F(e,t){const s=e instanceof P,r={},n=[];let a=!1,i=0;for(const o of e.variables){const c=s?i++:o.name,u=this.#I(o,t,e);void 0!==u?a=!0:!1===o.isOptional&&n.push(o.name),r[c]=u}if(!0===a&&n.length>0)throw new V(n[0]);return a?r:void 0}#P(e,t,s){return void 0===t&&(!0!==e.isOptional&&!0!==s?.isOptional)}#L(e,t,s){return!1!==e.name.startsWith("...")&&(void 0===s&&t instanceof Array==!1||s instanceof P&&t instanceof Array==!1||s instanceof L&&t instanceof Object==!1)}}class H{toStatus(a){return a instanceof e?m:a instanceof t?w:a instanceof s?y:a instanceof r?E:a instanceof n?f:a instanceof i?v:a instanceof o?g:S}fromStatus(c,u){switch(c){case m:return new e(u);case w:return new t(u);case y:return new s(u);case E:return new r(u);case f:return new n(u);case v:return new i(u);case g:return new o(u);default:return new a(u)}}}const U=/^\d+(?:\.\d+){0,2}$/;class G{parse(e){if(0===e.trim().length)return I.DEFAULT;if(!1===U.test(e))throw new b(e);const t=e.split(".");switch(t.length){case 1:return new I(Number.parseInt(t[0]));case 2:return new I(Number.parseInt(t[0]),Number.parseInt(t[1]));default:return new I(Number.parseInt(t[0]),Number.parseInt(t[1]),Number.parseInt(t[2]))}}}class q extends s{#t;#p;constructor(e,t){super(`No implementation found for procedure '${e}' with version '${t}'`),this.#t=e,this.#p=t}get fqn(){return this.#t}get version(){return this.#p}}class B extends a{constructor(){super("Invalid segment")}}class W{#V=new Map;addSegment(e){this.#V.set(e.id,e)}clearSegments(){this.#V.clear()}getClassNames(){const e=new Set;for(const t of this.#V.values()){t.getClasses().forEach(t=>e.add(t.fqn))}return[...e.values()]}hasClass(e){return this.getClassNames().includes(e)}getClass(e){for(const t of this.#V.values())if(t.hasClass(e))return t.getClass(e)}getClassByImplementation(e){for(const t of this.#V.values()){const s=t.getClassByImplementation(e);if(void 0!==s)return s}}getProcedureNames(){const e=new Set;for(const t of this.#V.values()){t.getExposedProcedures().forEach(t=>e.add(t.fqn))}return[...e.values()]}hasProcedure(e){return this.getProcedureNames().includes(e)}getProcedure(e){for(const t of this.#V.values())if(t.hasProcedure(e))return t.getProcedure(e)}}class _{#j;#$;#H=new $;#U=new H;#G=new W;constructor(e,t=[]){this.#j=e,this.#$=t}async start(){return this.#q()}async stop(){return this.#B()}async loadSegment(e){const t=await this.#j.import(e);this.addSegment(t.default)}async addSegment(e){if(e instanceof A==!1)throw new B;this.#G.addSegment(e)}getClassNames(){return this.#G.getClassNames()}hasClass(e){return this.#G.hasClass(e)}getClass(e){return this.#G.getClass(e)}getClassByImplementation(e){return this.#G.getClassByImplementation(e)}getProcedureNames(){return this.#G.getProcedureNames()}hasProcedure(e){return this.#G.hasProcedure(e)}getProcedure(e){return this.#G.getProcedure(e)}async run(e){const t=this.#W(e.fqn,e.version),s=this.#H.extract(t.parameters,e.args);return e.mode===d?new D(p,void 0):this.#_(e,t,s)}async#q(){await Promise.all(this.#$.map(e=>this.loadSegment(e)))}#B(){this.#G.clearSegments()}#W(e,t){const s=this.#G.getProcedure(e);if(void 0===s)throw new x(e);const r=s.getImplementation(t);if(void 0===r)throw new q(s.fqn,t.toString());return r}async#_(e,t,s){try{const r=await t.executable.call(e,...s);return new D(p,r)}catch(e){const t=this.#U.toStatus(e);return new D(t,e)}}}class K extends a{constructor(){super("Request cancelled")}}class Y{#K;#Y;#X=[];#J=!1;#Q=0;constructor(e,t=20){this.#K=e,this.#Y=t}start(){this.#J=!0,this.#Z()}stop(){this.#J=!1,this.#ee()}run(e){return new Promise((t,s)=>{this.#X.push({request:e,resolve:t,reject:s}),this.#Z()})}#Z(){if(this.#te())return;const e=this.#X.length,t=this.#Y-this.#Q,s=Math.min(e,t);this.#se(s)}#te(){return this.#re()||this.#ne()||this.#ae()}#re(){return!1===this.#J}#ne(){return 0===this.#X.length}#ae(){return this.#Q>=this.#Y}#se(e){const t=this.#X.splice(0,e);this.#Q+=e,t.forEach(e=>this.#ie(e))}async#ie(e){try{const t=await this.#K.run(e.request);e.resolve(t)}catch(t){e.reject(t)}finally{this.#Q--,this.#Z()}}#ee(){for(;this.#X.length>0;){const e=this.#X.shift();void 0!==e&&this.#oe(e)}}#oe(e){e.reject(new K)}}const X="starting",J="available",Q="unavailable",Z="stopping",ee="stopped";class te{#ce=ee;get state(){return this.#ce}set state(e){this.#ce=e}async start(e){if(!this.isStarted())try{this.setStarting(),await e()}catch(e){throw this.setStopped(),e}}async stop(e){this.isStopped()||(this.setStopping(),await e(),this.setStopped())}isStarted(){return this.#ue(ee)}isStopped(){return this.#le(ee)}isAvailable(){return this.#le(J)}setStarting(){this.#ce=X}setAvailable(){this.#ce=J}setUnavailable(){this.#ce=Q}setAvailability(e){return this.#ce=e?J:Q,this.#ce}setStopping(){this.#ce=Z}setStopped(){this.#ce=ee}#le(...e){return e.includes(this.#ce)}#ue(...e){return!1===this.#le(...e)}}class se{#he;#de;#pe=new te;constructor(e){this.#he=e.url,this.#de=e.remote}get url(){return this.#he}get state(){return this.#pe.state}get trustKey(){}async start(){return this.#pe.start(async()=>{await this.#de.connect(),await this.updateState()})}async stop(){return this.#pe.stop(async()=>{await this.#de.disconnect()})}isHealthy(){return this.#de.isHealthy()}getHealth(){return this.#de.getHealth()}async updateState(){const e=await this.isHealthy();return this.#pe.setAvailability(e)}getProcedureNames(){throw new r}hasProcedure(e){throw new r}addWorker(e){return this.#de.addWorker(e.url,e.getProcedureNames(),e.trustKey)}reportWorker(e,t){return this.#de.reportWorker(e,t)}removeWorker(e){return this.#de.removeWorker(e)}run(e){return this.#de.run(e)}}class re extends Error{#me;constructor(e){super(`Invalid location: ${e}`),this.#me=e}get location(){return this.#me}}class ne extends Error{#ge;constructor(e){super(`The file '${e}' could not be found`),this.#ge=e}get filename(){return this.#ge}}class ae{#me;#fe;#we;constructor(e,t,s){this.#me=e,this.#fe=t,this.#we=s}get location(){return this.#me}get type(){return this.#fe}get content(){return this.#we}get size(){return this.#we.length}}class ie{#me;#ye;#ve;constructor(e,t){const s=t.resolve(e);this.#me=t.normalize(e),this.#ye=t.normalize(s),this.#ve=t}getAbsoluteLocation(e){const t=this.#ve.isAbsolute(e)?e:this.#ve.join(this.#me,e),s=this.#ve.resolve(t),r=this.#ve.normalize(s);return this.#Se(r,e),r}getRelativeLocation(e){const t=this.#ve.relative(this.#me,e);return this.#ve.normalize(t)}normalizeLocation(e){return this.#ve.normalize(e)}async getType(e){const t=this.getAbsoluteLocation(e);return await this.#ve.mimeType(t)??"application/octet-stream"}async getContent(e){const t=this.getAbsoluteLocation(e);if(!1===await this.#ve.exists(t))throw new ne(e);return this.#ve.read(t)}async exists(e){const t=this.getAbsoluteLocation(e);return this.#ve.exists(t)}isDirectory(e){const t=this.getAbsoluteLocation(e);return this.#ve.isDirectory(t)}async read(e){const t=this.getAbsoluteLocation(e),s=await this.getType(t),r=await this.getContent(t);return new ae(e,s,r)}async write(e,t){const s=this.getAbsoluteLocation(e);return this.#ve.write(s,t)}async copy(e,t){const s=this.getAbsoluteLocation(e),r=this.getAbsoluteLocation(t);return this.#ve.copy(s,r)}async delete(e){const t=this.getAbsoluteLocation(e);return this.#ve.delete(t)}async filter(e){const t=this.getAbsoluteLocation("./"),s=this.#ve.normalize(e);return(await this.#ve.filter(t,s)).map(e=>this.#ve.normalize(e))}#Se(e,t){if(!1===e.startsWith(this.#ye))throw new re(t)}}class oe extends Error{constructor(){super("Remote files are not supported")}}class ce{copy(e,t){throw new oe}delete(e){throw new oe}exists(e){throw new oe}async filter(e,t){return[]}isAbsolute(e){return e.startsWith("/")}isDirectory(e){throw new oe}join(...e){throw new oe}read(e){throw new oe}resolve(e){return e}relative(e,t){throw new oe}normalize(e){return e}mimeType(e){throw new oe}write(e,t){throw new oe}}class ue extends ie{constructor(e){super(e,new ce)}}class le extends Error{#he;#Ee;constructor(e,t){super(`Module '${e}' could not be loaded${void 0!==t?` | ${t}`:""}`),this.#he=e,this.#Ee=t}get url(){return this.#he}get reason(){return this.#Ee}}class he{#be;constructor(e){this.#be=e}async import(e){const t=this.#be.locate(e);try{return await import(t)}catch(e){const s=e instanceof Error?e.message:String(e);throw new le(t,s)}}}class de{constructor(e){}locate(e){throw new le(e,"Remote module loading is not allowed")}}class pe extends he{constructor(e){super(new de(e))}}class me{#xe;#Oe;constructor(e,t){this.#xe=e,this.#Oe=t}async filter(...e){return(await Promise.all(e.map(e=>this.#xe.filter(e)))).flat().map(e=>this.#xe.getRelativeLocation(e))}exists(e){return this.#xe.exists(e)}read(e){return this.#xe.read(e)}import(e){return this.#Oe.import(e)}}class ge extends me{constructor(e){super(new ue(e),new pe(e))}}class fe extends Error{constructor(e){super(`The class '${e}' could not be found`)}}class we extends Error{constructor(e){super(`The class '${e}' is invalid`)}}class ye extends Error{constructor(e){super(`No deserializer found for value of type '${e}'`)}}class ve extends Error{constructor(e){super(`No serializer found for value of type '${e}'`)}}class Se{#Ae=[];addSerializer(e){e.parent=this,this.#Ae.unshift(e)}async serialize(e){const t=this.#Ae.find(t=>t.canSerialize(e));if(void 0===t)throw new ve(typeof e);return t.serialize(e)}async deserialize(e){const t=this.#Ae.find(t=>t.canDeserialize(e));if(void 0===t)throw new ye(typeof e);return t.deserialize(e)}}class Ee extends Error{constructor(){super("Parent serializer not set")}}class be{#Ce;set parent(e){this.#Ce=e}serializeOther(e){if(void 0===this.#Ce)throw new Ee;return this.#Ce.serialize(e)}deserializeOther(e){if(void 0===this.#Ce)throw new Ee;return this.#Ce.deserialize(e)}}class xe extends be{canSerialize(e){return e instanceof Array}canDeserialize(e){return e instanceof Array}async serialize(e){const t=[];for(const s of e)t.push(await this.serializeOther(s));return t}async deserialize(e){return Promise.all(e.map(async e=>this.deserializeOther(e)))}}class Oe extends Error{constructor(e){super(`Invalid BigInt string '${e}'`)}}class Ae extends be{canSerialize(e){return"bigint"==typeof e}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"BigInt"===t.name&&"string"==typeof t.value}async serialize(e){return{serialized:!0,name:"BigInt",value:e.toString()}}async deserialize(e){try{return BigInt(e.value)}catch{throw new Oe(e.value)}}}class Ce extends Error{constructor(e){super(`Invalid Buffer string '${e}'`)}}class Ie extends be{canSerialize(e){return e instanceof Buffer}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Buffer"===t.name&&"string"==typeof t.base64}async serialize(e){return{serialized:!0,name:"Buffer",base64:e.toString("base64")}}async deserialize(e){try{return Buffer.from(e.base64,"base64")}catch{throw new Ce(e.base64)}}}class Ne{#w;#Ie;constructor(e,t){this.#w=e,this.#Ie=t}get name(){return this.#w}get as(){return this.#Ie}toString(){return`${this.#w} as ${this.#Ie}`}}class Me{#Ne;constructor(e){this.#Ne=e}get definition(){return this.#Ne}toString(){return this.#Ne}}class Te extends Me{}class Re{#w;#Me;#Te;constructor(e,t=!1,s=!1){this.#w=e,this.#Me=t,this.#Te=s}get name(){return this.#w}get isStatic(){return this.#Me}get isPrivate(){return this.#Te}get isPublic(){return!1===this.#Te}}class ze extends Re{#Re;#ze;constructor(e,t,s){super(e),this.#Re=t,this.#ze=s}get parentName(){return this.#Re}get scope(){return this.#ze}get members(){return this.#ze.members}get declarations(){return this.#ze.declarations}get functions(){return this.#ze.functions}get getters(){return this.#ze.getters}get setters(){return this.#ze.setters}get generators(){return this.#ze.generators}get readable(){const e=new Map;return this.getters.forEach(t=>{e.set(t.name,t)}),this.declarations.forEach(t=>{t.isPublic&&e.set(t.name,t)}),[...e.values()]}get writable(){const e=new Map;return this.setters.forEach(t=>{e.set(t.name,t)}),this.declarations.forEach(t=>{t.isPublic&&e.set(t.name,t)}),[...e.values()]}get callable(){return this.functions.filter(e=>e.isPublic)}getMember(e){return this.#ze.getMember(e)}getDeclaration(e){return this.#ze.getDeclaration(e)}getFunction(e){return this.#ze.getFunction(e)}getGetter(e){return this.#ze.getGetter(e)}getSetter(e){return this.#ze.getSetter(e)}getGenerator(e){return this.#ze.getGenerator(e)}hasMember(e){return this.#ze.hasMember(e)}hasDeclaration(e){return this.#ze.hasDeclaration(e)}hasFunction(e){return this.#ze.hasFunction(e)}hasGetter(e){return this.#ze.hasGetter(e)}hasSetter(e){return this.#ze.hasSetter(e)}hasGenerator(e){return this.#ze.hasGenerator(e)}canRead(e){const t=this.getDeclaration(e);return t?.isPublic||this.hasGetter(e)}canWrite(e){const t=this.getDeclaration(e);return t?.isPublic||this.hasSetter(e)}canCall(e){const t=this.getFunction(e);return t?.isPublic??!1}toString(){const e=void 0!==this.#Re?` extends ${this.#Re}`:"";return`class ${this.name}${e} { ${this.#ze.toString()} }`}}class Pe extends Re{#Pe;#Le;constructor(e,t,s=!1,r=!1){super(e.toString(),s,r),this.#Pe=e,this.#Le=t}get identifier(){return this.#Pe}get value(){return this.#Le}toString(){return`${this.name}${this.value?" = "+this.value.toString():""}`}}class Le{#ke;constructor(e){this.#ke=e}get members(){return this.#ke}toString(){return this.#ke.map(e=>e.toString()).join(" , ")}}class ke extends Le{toString(){return`[ ${super.toString()} ]`}}class De extends Le{toString(){return`{ ${super.toString()} }`}}class Fe extends Re{#ke;#De;constructor(e,t){super(""),this.#ke=e,this.#De=t}get members(){return this.#ke}get from(){return this.#De}hasMember(e){return this.#ke.some(t=>t.as===e)}getMember(e){return this.#ke.find(t=>t.as===e)}toString(){const e=this.#De?` from '${this.#De}'`:"";return`export { ${this.#ke.join(", ")} }${e}`}}class Ve extends Me{}class je{#w;#Le;constructor(e,t){this.#w=e,this.#Le=t}get name(){return this.#w}get value(){return this.#Le}toString(){return`${this.name}${this.value?" = "+this.value.toString():""}`}}class $e extends Re{#g;#Fe;#Ve;constructor(e,t,s,r=!1,n=!1,a=!1){super(e,r,a),this.#g=t,this.#Fe=s,this.#Ve=n}get parameters(){return this.#g}get body(){return this.#Fe}get isAsync(){return this.#Ve}toString(){const e=this.parameters.map(e=>e.toString());return`${this.isAsync?"async ":""}${this.name}(${e.join(", ")}) { ${this.body} }`}}class He extends $e{toString(){const e=this.parameters.map(e=>e.toString());return`${this.isAsync?"async ":""}${this.name}*(${e.join(", ")}) { ${this.body} }`}}class Ue extends $e{toString(){return`get ${super.toString()}`}}class Ge extends Re{#ke;#De;constructor(e,t){super(""),this.#ke=e,this.#De=t}get members(){return this.#ke}get from(){return this.#De}hasMember(e){return this.#ke.some(t=>t.as===e)}getMember(e){return this.#ke.find(t=>t.as===e)}toString(){return`import { ${this.#ke.map(e=>e.toString()).join(", ")} } from '${this.#De}';`}}class qe{#ze;constructor(e){this.#ze=e}get scope(){return this.#ze}get members(){return this.#ze.members}get exportedMembers(){return this.#je(this.#ze.members)}get imports(){return this.#ze.imports}get exports(){return this.#ze.exports}get declarations(){return this.#ze.declarations}get exportedDeclarations(){return this.#je(this.#ze.declarations)}get functions(){return this.#ze.functions}get exportedFunctions(){return this.#je(this.#ze.functions)}get generators(){return this.#ze.generators}get exportedGenerators(){return this.#je(this.#ze.generators)}get classes(){return this.#ze.classes}get exportedClasses(){return this.#je(this.#ze.classes)}get exported(){const e=new Map;for(const t of this.exports)for(const s of t.members){const t=this.getMember(s.name);void 0!==t&&e.set(s.as,t)}return e}getMember(e){return this.#ze.getMember(e)}getDeclaration(e){return this.#ze.getDeclaration(e)}getFunction(e){return this.#ze.getFunction(e)}getGenerator(e){return this.#ze.getGenerator(e)}getClass(e){return this.#ze.getClass(e)}hasMember(e){return this.#ze.hasMember(e)}hasDeclaration(e){return this.#ze.hasDeclaration(e)}hasFunction(e){return this.#ze.hasFunction(e)}hasGenerator(e){return this.#ze.hasGenerator(e)}hasClass(e){return this.#ze.hasClass(e)}getImport(e){return this.imports.find(t=>t.hasMember(e))}getImported(e){for(const t of this.imports)for(const s of t.members)if(s.as===e)return this.getMember(s.name)}isExported(e){for(const t of this.exports)for(const s of t.members)if(s.name===e.name)return!0;return!1}getExport(e){return this.exports.find(t=>t.hasMember(e))}getExported(e){for(const t of this.exports)for(const s of t.members)if(s.as===e)return this.getMember(s.name)}#je(e){return e.filter(e=>this.isExported(e))}}class Be extends Me{}class We extends $e{toString(){return`set ${super.toString()}`}}const _e=Ge.name,Ke=Fe.name,Ye=Pe.name,Xe=$e.name,Je=Ue.name,Qe=We.name,Ze=He.name,et=ze.name;class tt{#ke;constructor(e){this.#ke=e}get members(){return this.#ke}get imports(){return this.#ke.filter(e=>e.constructor.name===_e)}get exports(){return this.#ke.filter(e=>e.constructor.name===Ke)}get declarations(){return this.#ke.filter(e=>e.constructor.name===Ye)}get functions(){return this.#ke.filter(e=>e.constructor.name===Xe)}get getters(){return this.#ke.filter(e=>e.constructor.name===Je)}get setters(){return this.#ke.filter(e=>e.constructor.name===Qe)}get generators(){return this.#ke.filter(e=>e.constructor.name===Ze)}get classes(){return this.#ke.filter(e=>e.constructor.name===et)}getMember(e){return this.#ke.find(t=>t.name===e)}getDeclaration(e){return this.declarations.find(t=>t.name===e)}getFunction(e){return this.functions.find(t=>t.name===e)}getGetter(e){return this.getters.find(t=>t.name===e)}getSetter(e){return this.setters.find(t=>t.name===e)}getGenerator(e){return this.generators.find(t=>t.name===e)}getClass(e){return this.classes.find(t=>t.name===e)}hasMember(e){return void 0!==this.getMember(e)}hasDeclaration(e){return void 0!==this.getDeclaration(e)}hasFunction(e){return void 0!==this.getFunction(e)}hasGetter(e){return void 0!==this.getGetter(e)}hasSetter(e){return void 0!==this.getSetter(e)}hasGenerator(e){return void 0!==this.getGenerator(e)}hasClass(e){return void 0!==this.getClass(e)}toString(){return this.#ke.map(e=>e.toString()).join("\n")}}const st={SINGLE:"//",MULTI_START:"/*",MULTI_END:"*/"},rt=Object.values(st);const nt=".",at="(",it=")",ot="[",ct="]",ut="{",lt="}",ht={SCOPE:":",SEPARATOR:",",TERMINATOR:";"},dt=Object.values(ht);function pt(e){return dt.includes(e)}const mt={UNDEFINED:void 0,NULL:null,STRING:""},gt=Object.values(mt);function ft(e){return gt.includes(e)}const wt={OPEN:at,CLOSE:it};function yt(e){return e===wt.OPEN||e===wt.CLOSE}const vt={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"},St=Object.values(vt);function Et(e){return St.includes(e)}function bt(e){return e===vt.AS||e===vt.ASYNC||e===vt.FROM||e===vt.GET||e===vt.SET}const xt={OPEN:ot,CLOSE:ct};function Ot(e){return e===xt.OPEN||e===xt.CLOSE}const At=Object.values({SINGLE:"'",DOUBLE:'"',BACKTICK:"`"});function Ct(e){return At.includes(e)}const It={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:"^"},Nt=Object.values(It);function Mt(e){return Nt.includes(e)}const Tt={OPEN:ut,CLOSE:lt};function Rt(e){return e===Tt.OPEN||e===Tt.CLOSE}const zt={COMMENT:"comment",DIVIDER:"divider",GROUP:"group",IDENTIFIER:"identifier",KEYWORD:"keyword",LIST:"list",LITERAL:"literal",OPERATOR:"operator",REGEX:"regex",SCOPE:"scope",WHITESPACE:"whitespace"},Pt={SPACE:" ",TAB:"\t",NEWLINE:"\n",CARRIAGE_RETURN:"\r"},Lt=Object.values(Pt);function kt(e){return Lt.includes(e)}class Dt{#$e;#He;constructor(e){this.#$e=e,this.#He=0}get items(){return this.#$e}get position(){return this.#He}get size(){return this.#$e.length}get eol(){return this.#He>=this.#$e.length}get current(){return this.#$e[this.#He]}get next(){return this.#$e[this.#He+1]}get previous(){return this.#$e[this.#He-1]}notAtEnd(){return!1===this.eol}get(e){return this.#$e[e]}step(e=1){return this.#He+=e,this.current}stepBack(e=1){return this.#He-=e,this.current}hasNext(){return this.#He+1<this.#$e.length}}class Ft extends Dt{constructor(e){super(e.split(""))}}class Vt{#fe;#Le;#Ue;#Ge;constructor(e,t,s,r){this.#fe=e,this.#Le=t,this.#Ue=s,this.#Ge=r}get type(){return this.#fe}get value(){return this.#Le}get start(){return this.#Ue}get end(){return this.#Ge}isType(e){return this.#fe===e}hasValue(e){return this.#Le===e}toString(){return`${this.#Le}`}}class jt extends Dt{}class $t{tokenize(e){const t=new Ft(e),s=[];let r;for(;t.notAtEnd();){const e=this.#qe(t,r);if(void 0===e)break;e.isType(zt.WHITESPACE)||e.isType(zt.COMMENT)?t.step():(s.push(e),this.#Be(e)&&(r=e),t.step())}return new jt(s)}#Be(e){return!1===[zt.WHITESPACE,zt.COMMENT].includes(e.type)}#qe(e,t){const s=e.current,r=e.position;if(kt(s)){const t=e.position;return new Vt(zt.WHITESPACE,s,r,t)}if(function(e){return rt.includes(e)}(s+e.next)){const t=this.#We(e),s=e.position;return new Vt(zt.COMMENT,t,r,s)}if(this.#_e(s,t)){const t=this.#Ke(e),s=e.position;return new Vt(zt.REGEX,t,r,s)}if(Ct(s)){const t=this.#Ye(e),s=e.position;return new Vt(zt.LITERAL,t,r,s)}if(Mt(s)){const t=this.#Xe(e),s=e.position;return new Vt(zt.OPERATOR,t,r,s)}if(pt(s)){const t=e.position;return new Vt(zt.DIVIDER,s,r,t)}if(yt(s)){const t=e.position;return new Vt(zt.GROUP,s,r,t)}if(Rt(s)){const t=e.position;return new Vt(zt.SCOPE,s,r,t)}if(Ot(s)){const t=e.position;return new Vt(zt.LIST,s,r,t)}if(ft(s))return;const n=this.#Je(e),a=Et(n)?zt.KEYWORD:zt.IDENTIFIER,i=e.position;return new Vt(a,n,r,i)}#We(e){const t=e.current+e.next===st.MULTI_START,s=t?st.MULTI_END:Pt.NEWLINE;let r=t?st.MULTI_START:st.SINGLE;for(e.step(2);e.notAtEnd();){const n=e.current;if((t?n+e.next:n)===s){e.step(s.length-1);break}r+=n,e.step()}return t?r+st.MULTI_END:r.trim()}#_e(e,t){return e===It.DIVIDE&&(void 0===t||([zt.OPERATOR,zt.DIVIDER,zt.KEYWORD].includes(t.type)||[wt.OPEN,xt.OPEN].includes(t.value)))}#Qe(e){return kt(e)||e==nt||!1===this.#Ze(e)}#Ke(e){let t=e.current,s=!1;for(e.step();e.notAtEnd();){const r=e.current,n=e.previous;if(r===It.DIVIDE&&"\\"!==n)s=!0;else if(!0===s&&this.#Qe(r)){e.stepBack();break}t+=r,e.step()}return t}#Ye(e){const t=e.current;let s=t,r=!1;for(e.step();e.notAtEnd();){const n=e.current;if(!1===r){if(n===t){s+=n;break}"\\"===n&&(r=!0)}else r=!1;s+=n,e.step()}return s}#Ze(e){return!1===(ft(e)||kt(e)||Mt(e)||Ct(e)||pt(e)||yt(e)||Rt(e)||Ot(e))}#Je(e){let t="";for(;e.notAtEnd();){const s=e.current;if(!1===this.#Ze(s)){e.stepBack();break}t+=s,e.step()}return t}#Xe(e){let t=e.current;for(e.step();e.notAtEnd();){const s=e.current;if(!1===Mt(s)||!1===Mt(t+s)){e.stepBack();break}t+=s,e.step()}return t}}class Ht extends Error{constructor(e,t){super(`Expected keyword '${e}' at position ${t}`)}}class Ut extends Error{constructor(e,t){super(`Expected token '${e}' at position ${t}`)}}class Gt extends Error{constructor(e,t){super(`Unexpected keyword '${e}' at position ${t}`)}}class qt extends Error{constructor(e){super(`The given code does not contain ${e}`)}}class Bt extends Error{constructor(e,t){super(`Unexpected token '${e}' at position ${t}`)}}const Wt="default",_t=" ";class Kt{#et;constructor(e=new $t){this.#et=e}parse(e){const t=this.#et.tokenize(e),s=this.#tt(t);return new qe(s)}parseFirst(e){const t=this.#et.tokenize(e);return this.#st(t)}parseValue(e){const t=this.parseFirst(e);if(t instanceof Me==!1)throw new qt("a value definition");return t}parseImport(e){const t=this.parseFirst(e);if(t instanceof Ge==!1)throw new qt("an import definition");return t}parseExport(e){const t=this.parseFirst(e);if(t instanceof Fe==!1)throw new qt("an export definition");return t}parseDeclaration(e){const t=this.parseFirst(e);if(t instanceof Pe==!1)throw new qt("a declaration definition");return t}parseFunction(e){const t=this.#et.tokenize(e),s=this.#rt(t);if(s instanceof $e==!1)throw new qt("a function definition");return s}parseClass(e){const t=this.#et.tokenize(e),s=this.#rt(t);if(s instanceof ze==!1)throw new qt("a class definition");return s}#tt(e){const t=[];for(;e.notAtEnd();){const s=this.#st(e);s instanceof Re&&t.push(s)}return new tt(t)}#st(e,t=!1){const s=e.current;if(s.isType(zt.LITERAL))return this.#nt(e);if(s.isType(zt.IDENTIFIER)){const s=e.next;return s?.hasValue(It.ARROW)?this.#at(e,t):this.#nt(e)}if(s.isType(zt.KEYWORD)){if(bt(s.value)){const t=e.next,r=void 0!==t&&(t.hasValue(vt.FUNCTION)||t.hasValue(wt.OPEN));if(s.hasValue(vt.ASYNC)&&r)return e.step(),this.#st(e,!0);if(void 0===t||this.#it(t))return this.#nt(e)}return s.hasValue(vt.RETURN)?this.#nt(e):this.#rt(e,t)}if(s.isType(zt.REGEX))return this.#nt(e);if(s.hasValue(wt.OPEN)){const s=this.#ot(e,wt.OPEN,wt.CLOSE);return s?.hasValue(It.ARROW)?this.#at(e,t):this.#nt(e)}if(s.hasValue(Tt.OPEN))return this.#ct(e);if(s.hasValue(xt.OPEN))return this.#ut(e);if(s.hasValue(It.NOT)||s.hasValue(It.SUBTRACT))return this.#nt(e);if(!pt(s.value))throw new Bt(s.value,s.start);e.step()}#rt(e,t=!1){const s=e.current;switch(e.step(),s.value){case vt.IMPORT:return this.#lt(e);case vt.EXPORT:return this.#ht(e);case vt.CLASS:return this.#dt(e);case vt.FUNCTION:return this.#pt(e,t);case vt.VAR:case vt.LET:case vt.CONST:return this.#mt(e,!1,!0);case vt.ASYNC:return this.#rt(e,!0);default:throw new Gt(s.value,s.start)}}#lt(e){const t=[];let s=e.current;if(s.isType(zt.LITERAL))return new Ge(t,s.value);if(s.hasValue(wt.OPEN)){s=e.step();const r=s.value;return e.step(2),new Ge(t,r)}if(!1===s.hasValue(Tt.OPEN)){const r=s.hasValue(It.MULTIPLY)?It.MULTIPLY:Wt;let n=s.value;s=e.step(),s.hasValue(vt.AS)&&(s=e.step(),n=s.value,s=e.step()),t.push(new Ne(r,n))}if(s.hasValue(ht.SEPARATOR)&&(s=e.step()),s.hasValue(Tt.OPEN)){const r=this.#gt(e);t.push(...r),s=e.current}if(!1===s.hasValue(vt.FROM))throw new Ht(vt.FROM,s.start);s=e.step();const r=s.value;return e.step(),new Ge(t,r)}#ht(e){switch(e.current.value){case vt.DEFAULT:return e.step(),this.#ft(e,!0);case Tt.OPEN:return this.#wt(e);default:return this.#ft(e,!1)}}#ft(e,t){let s=e.current,r=0;var n;s.hasValue(vt.ASYNC)&&(s=e.step(),r++),((n=s.value)===vt.CLASS||n===vt.FUNCTION||n===vt.CONST||n===vt.LET||n===vt.VAR)&&(s=e.step(),r++);const a=this.#Ze(s)?s.value:"",i=t?Wt:a;let o;s=e.step(),s?.hasValue(vt.FROM)&&(s=e.step(),o=s.value),r>0&&(r++,e.stepBack(r));const c=new Ne(a,i);return new Fe([c],o)}#wt(e){const t=this.#gt(e);let s,r=e.current;return r?.hasValue(vt.FROM)&&(r=e.step(),s=r.value),e.step(),new Fe(t,s)}#gt(e){const t=[];let s=e.step();for(;e.notAtEnd();){if(s.hasValue(Tt.CLOSE)){e.step();break}if(s.hasValue(ht.SEPARATOR)){s=e.step();continue}const r=this.#yt(e);t.push(r),s=e.step()}return t}#yt(e){let t=e.current;const s=t.value;let r=s;return e.next.hasValue(vt.AS)&&(t=e.step(2),r=t.value),new Ne(s,r)}#mt(e,t,s=!1){let r,n,a=e.current,i=!1;return a.hasValue(xt.OPEN)?(r=this.#vt(e),a=e.current):a.hasValue(Tt.OPEN)?(r=this.#St(e),a=e.current):(i=a.value.startsWith("#"),r=i?a.value.substring(1):a.value,a=e.step()),a.hasValue(It.ASSIGN)&&(e.step(),n=this.#st(e,!1),a=e.current),void 0!==a&&(a.hasValue(ht.TERMINATOR)?e.step():!0===s&&a.hasValue(ht.SEPARATOR)&&(e.step(),this.#mt(e,t,!0))),n instanceof He?new He(r.toString(),n.parameters,n.body,t,n.isAsync,i):n instanceof $e?new $e(r.toString(),n.parameters,n.body,t,n.isAsync,i):n instanceof ze?new ze(r.toString(),n.parentName,n.scope):new Pe(r,n,t,i)}#pt(e,t,s=!1,r=!1,n=!1){let a=e.current,i="",o=!1,c=!1;a.hasValue(It.MULTIPLY)&&(o=!0,a=e.step()),this.#Ze(a)&&(c=a.value.startsWith("#"),i=c?a.value.substring(1):a.value,e.step());const u=this.#Et(e,wt.CLOSE);if(a=e.current,!1===a.hasValue(Tt.OPEN))throw new Ut(Tt.OPEN,a.start);const l=this.#bt(e,Tt.OPEN,Tt.CLOSE);return o?new He(i,u,l,s,t,c):r?new Ue(i,u,l,s,t,c):n?new We(i,u,l,s,t,c):new $e(i,u,l,s,t,c)}#at(e,t){let s,r=e.current;if(r.hasValue(wt.OPEN)?(s=this.#Et(e,wt.CLOSE),r=e.current):(s=[new je(r.value,void 0)],r=e.step()),!1===r.hasValue(It.ARROW))throw new Ut(It.ARROW,r.start);r=e.step();const n=r.hasValue(Tt.OPEN)?this.#bt(e,Tt.OPEN,Tt.CLOSE):this.#nt(e).definition;return new $e("",s,n,!1,t,!1)}#Et(e,t){const s=[];for(e.step();e.notAtEnd();){const r=e.current;if(r.hasValue(t)){e.step();break}if(r.hasValue(ht.SEPARATOR)){e.step();continue}let n;n=r.hasValue(Tt.OPEN)?this.#St(e):r.hasValue(xt.OPEN)?this.#vt(e):this.#xt(e),s.push(n)}return s}#dt(e){let t,s=e.current,r="";if(this.#Ze(s)&&(r=s.value,s=e.step()),s.hasValue(vt.EXTENDS)&&(s=e.step(),t=s.value,s=e.step()),!1===s.hasValue(Tt.OPEN))throw new Ut(Tt.OPEN,s.start);const n=this.#Ot(e);return new ze(r,t,n)}#Ot(e){let t=e.step();const s=[];for(;e.notAtEnd();){if(t.hasValue(Tt.CLOSE)){e.step();break}const r=this.#At(e);s.push(r),t=e.current}return new tt(s)}#At(e){let t=e.current,s=!1,r=!1,n=!1,a=!1;for(;e.notAtEnd();){if(t.hasValue(vt.STATIC))r=!0;else if(t.hasValue(vt.ASYNC))s=!0;else if(t.hasValue(vt.GET))n=!0;else{if(!t.hasValue(vt.SET)){if(t.hasValue(It.MULTIPLY))return this.#pt(e,s,r,!1,!1);break}a=!0}t=e.step()}return e.next.hasValue(wt.OPEN)?this.#pt(e,s,r,n,a):this.#mt(e,r)}#ut(e){const t=this.#bt(e,xt.OPEN,xt.CLOSE);return new Te(t)}#vt(e){const t=this.#Et(e,xt.CLOSE);return new ke(t)}#ct(e){const t=this.#bt(e,Tt.OPEN,Tt.CLOSE);return new Be(t)}#St(e){const t=this.#Et(e,Tt.CLOSE);return new De(t)}#xt(e){let t=e.current;const s=t.value;let r;return t=e.step(),t.hasValue(It.ASSIGN)&&(e.step(),r=this.#st(e,!1)),new je(s,r)}#nt(e){let t=e.current,s="";for(;e.notAtEnd();){if(t.hasValue(xt.OPEN)){s+=this.#bt(e,xt.OPEN,xt.CLOSE)+_t,t=e.current}else if(t.hasValue(wt.OPEN)){s+=this.#bt(e,wt.OPEN,wt.CLOSE)+_t,t=e.current}else if(t.hasValue(Tt.OPEN)){s+=this.#bt(e,Tt.OPEN,Tt.CLOSE)+_t,t=e.current}else s+=t.toString()+_t,t=e.step();if(void 0===t||this.#it(t))break}return new Ve(s.trim())}#bt(e,t,s){let r=e.step(),n=t+_t;for(;e.notAtEnd();)if(r.hasValue(t))n+=this.#bt(e,t,s)+_t,r=e.current;else{if(r.hasValue(s))return e.step(),n+=s,n;n+=r.toString()+_t,r=e.step()}return n}#ot(e,t,s){const r=e.position;this.#bt(e,t,s);const n=e.current,a=e.position;return e.stepBack(a-r),n}#it(e){return[ht.TERMINATOR,ht.SEPARATOR].includes(e.value)||[xt.CLOSE,wt.CLOSE,Tt.CLOSE].includes(e.value)||Et(e.value)}#Ze(e){return e.isType(zt.IDENTIFIER)||e.isType(zt.KEYWORD)&&bt(e.value)}}class Yt{merge(e,t){const s=this.#Ct(e.declarations,t.declarations),r=this.#It(e.functions,t.functions),n=this.#It(e.getters,t.getters),a=this.#It(e.setters,t.setters),i=[...s.values(),...r.values(),...n.values(),...a.values()];return new ze(e.name,t.name,new tt(i))}#Ct(e,t){const s=new Map;return t.forEach(e=>s.set(e.name,e)),e.forEach(e=>s.set(e.name,e)),[...s.values()]}#It(e,t){const s=new Map;return t.forEach(e=>s.set(e.name,e)),e.forEach(e=>s.set(e.name,e)),[...s.values()]}}class Xt{#Nt=new Kt;#Mt=new Yt;fromModule(e,t=!1){const s=Object.entries(e),r=[];for(const[e,n]of s){if("function"!=typeof n.toString)continue;const s=n.toString();if(s.startsWith("class"))r.push(this.fromClass(n,t));else if(s.startsWith("function"))r.push(this.fromFunction(n));else{const t=new Ve(s);r.push(new Pe(e,t))}}return new qe(new tt(r))}fromClass(e,t=!1){const s=this.isClass(e)?this.#Tt(e):this.#Rt(e);if(!1===t)return s;const r=this.getParentClass(e);if(""===r.name)return s;const n=this.fromClass(r,!0);return this.#Mt.merge(s,n)}fromObject(e,t=!0){const s=this.getClass(e);return this.fromClass(s,t)}fromFunction(e){const t=e.toString();return this.#Nt.parseFunction(t)}createInstance(e,t=[]){return new e(...t)}getClass(e){return e.constructor}getParentClass(e){return Object.getPrototypeOf(e)}isClassObject(e){return this.isClass(e.constructor)}isFunctionObject(e){return this.isFunction(e.constructor)}isClass(e){return e.toString().startsWith("class")}isFunction(e){return e.toString().startsWith("function")||e.toString().startsWith("async function")}#Tt(e){const t=e.toString();return this.#Nt.parseClass(t)}#Rt(e){const t=this.createInstance(e),s=this.#zt(e,t),r=new tt(s);return new ze(e.name,void 0,r)}#zt(e,t){return[...this.#Pt(t),...this.#Lt(e)]}#Pt(e){const t=Object.getOwnPropertyNames(e),s=e,r=[];for(const e of t){const t=s[e],n=void 0!==t?new Me(String(t)):void 0,a=new Pe(e,n);r.push(a)}return r}#Lt(e){const t=Object.getOwnPropertyDescriptors(e.prototype),s=[];for(const e in t){const r=t[e],n=r.value;if(n instanceof Function==!1)continue;const a=this.fromFunction(n);void 0!==r.get?s.push(new Ue(a.name,a.parameters,a.body,a.isStatic,a.isAsync,a.isPrivate)):void 0!==r.set?s.push(new We(a.name,a.parameters,a.body,a.isStatic,a.isAsync,a.isPrivate)):s.push(a)}return s}}const Jt=new Xt;class Qt extends be{#kt;constructor(e){super(),this.#kt=e}canSerialize(e){return e instanceof Object&&Jt.isClassObject(e)}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"class"===t.name&&"string"==typeof t.key&&t.args instanceof Object&&t.args.constructor===Object&&t.fields instanceof Object&&t.fields.constructor===Object}async serialize(e){const t=Jt.getClass(e),s=Jt.fromClass(t,!0),r=this.#Dt(s),n=this.#kt.resolveKey(t);if(void 0===n)throw new fe(t.name);return{serialized:!0,key:n,name:"class",args:await this.#Ft(s,r,e),fields:await this.#Vt(s,r,e)}}#Dt(e){const t=e.getFunction("constructor");return(t?.parameters??[]).map(e=>e.name)}async#Ft(e,t,s){const r={};for(const[n,a]of t.entries()){const t=e.canRead(a)?await this.serializeOther(s[a]):void 0;r[n.toString()]=t}return r}async#Vt(e,t,s){const r={};for(const n of e.writable){const a=n.name;t.includes(a)||!1===e.canRead(a)||(r[a]=await this.serializeOther(s[a]))}return r}async deserialize(e){const t=await this.#jt(e);if(void 0===t)throw new fe(e.key);if(t instanceof Function==!1)throw new we(e.key);const s=await this.#$t(t,e.args),r=Jt.createInstance(t,s);for(const t in e.fields){const s=e.fields[t];r[t]=await this.deserializeOther(s)}return r}async#$t(e,t){const s=Jt.fromClass(e,!0).getFunction("constructor"),r=(s?.parameters??[]).map((e,s)=>{const r=s.toString(),n=t[r];return this.deserializeOther(n)});return Promise.all(r)}async#jt(e){return globalThis[e.key]??this.#kt.resolveClass(e.key)}}class Zt extends Error{constructor(e){super(`Invalid date string '${e}'`)}}class es extends be{canSerialize(e){return e instanceof Date}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Date"===t.name&&"string"==typeof t.value}async serialize(e){return{serialized:!0,name:"Date",value:e.toISOString()}}async deserialize(e){const t=new Date(e.value);if("Invalid Date"===t.toString())throw new Zt(e.value);return t}}class ts extends be{canSerialize(e){if(e instanceof Object==!1)return!1;const t=e;return t.constructor===Error||t.constructor===EvalError||t.constructor===RangeError||t.constructor===ReferenceError||t.constructor===SyntaxError||t.constructor===TypeError||t.constructor===URIError||t.constructor===AggregateError}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Error"===t.name&&t.type in globalThis}async serialize(e){return{serialized:!0,name:"Error",type:e.constructor.name,stack:e.stack,message:e.message,cause:e.cause}}async deserialize(e){const t=new(0,globalThis[e.type])(e.message,{cause:e.cause});return t.stack=e.stack,t}}class ss extends be{canSerialize(e){return e instanceof Map}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Map"===t.name&&t.entries instanceof Object&&t.entries.keys instanceof Array&&t.entries.values instanceof Array}async serialize(e){const t=[],s=[];for(const[r,n]of e)t.push(await this.serializeOther(r)),s.push(await this.serializeOther(n));return{serialized:!0,name:"Map",entries:{keys:t,values:s}}}async deserialize(e){const t=e.entries.keys,s=e.entries.values,r=new Map;for(let e=0;e<t.length;e++){const n=await this.deserializeOther(t[e]),a=await this.deserializeOther(s[e]);r.set(n,a)}return r}}class rs extends be{canSerialize(e){return e instanceof Object&&e.constructor===Object}canDeserialize(e){return e instanceof Object&&e.constructor===Object}async serialize(e){const t={};for(const s in e){const r=e[s];t[s]=await this.serializeOther(r)}return t}async deserialize(e){const t={};for(const s in e){const r=e[s];t[s]=await this.deserializeOther(r)}return t}}class ns extends be{canSerialize(e){return e instanceof Object==!1}canDeserialize(e){return e instanceof Object==!1}async serialize(e){return e}async deserialize(e){return e}}class as extends Error{constructor(e,t){super(`Invalid regular expression '${e}' with flags '${t}'`)}}class is extends be{canSerialize(e){return e instanceof RegExp}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"RegExp"===t.name&&"string"==typeof t.source&&"string"==typeof t.flags}async serialize(e){return{serialized:!0,name:"RegExp",source:e.source,flags:e.flags}}async deserialize(e){try{return new RegExp(e.source,e.flags)}catch{throw new as(e.source,e.flags)}}}class os extends be{canSerialize(e){return e instanceof Set}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Set"===t.name&&t.values instanceof Array}async serialize(e){const t=[];for(const s of e.values())t.push(await this.serializeOther(s));return{serialized:!0,name:"Set",values:t}}async deserialize(e){const t=await Promise.all(e.values.map(async e=>this.deserializeOther(e)));return new Set([...t])}}const cs=new Xt;class us extends be{canSerialize(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof BigInt64Array||e instanceof BigUint64Array}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"TypedArray"===t.name&&t.type in globalThis&&t.bytes instanceof Array}async serialize(e){const t=e.constructor.name,s=new DataView(e.buffer),r=[];for(let e=0;e<s.byteLength;e++)r.push(s.getUint8(e));return{serialized:!0,name:"TypedArray",type:t,bytes:r}}async deserialize(e){const t=e.type,s=e.bytes,r=new ArrayBuffer(s.length),n=new DataView(r);for(let e=0;e<s.length;e++)n.setUint8(e,s[e]);const a=globalThis[t];return cs.createInstance(a,[r])}}class ls extends Error{constructor(e){super(`Invalid url string '${e}'`)}}class hs extends be{canSerialize(e){return e instanceof URL}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Url"===t.name&&"string"==typeof t.value}async serialize(e){return{serialized:!0,name:"Url",value:e.toString()}}async deserialize(e){try{return new URL(e.value)}catch{throw new ls(e.value)}}}class ds{static build(e){const t=new Se;return t.addSerializer(new ns),t.addSerializer(new rs),void 0!==e&&t.addSerializer(new Qt(e)),t.addSerializer(new ts),t.addSerializer(new is),t.addSerializer(new Ae),t.addSerializer(new hs),t.addSerializer(new es),t.addSerializer(new os),t.addSerializer(new ss),t.addSerializer(new xe),t.addSerializer(new us),"undefined"!=typeof Buffer&&t.addSerializer(new Ie),t}}class ps{#Ht;constructor(e){this.#Ht=e}resolveKey(e){const t=this.#Ht.getClassByImplementation(e);return t?.fqn}resolveClass(e){const t=this.#Ht.getClass(e);return t?.implementation}}class ms extends o{constructor(){super("Request not trusted")}}const gs="X-Jitar-Trust-Key",fs="X-Jitar-Data-Encoding",ws="serialized";class ys{#s;#he;#Ut;#Gt;#qt;#Ht;#Bt;#Wt;#_t;#pe=new te;constructor(e){this.#he=e.url,this.#Ut=e.trustKey,this.#Gt=e.gateway,this.#qt=!0===e.registerAtGateway,this.#Ht=e.executionManager,this.#Bt=e.healthManager;const t=e.scheduleManager;this.#Wt=t.create(()=>this.#Kt(),e.reportInterval);const s=new ps(this.#Ht);this.#_t=ds.build(s)}get id(){return this.#s}set id(e){this.#s=e}get state(){return this.#pe.state}get url(){return this.#he}get trustKey(){return this.#Ut}async start(){return this.#pe.start(async()=>{await Promise.all([this.#Ht.start(),this.#Bt.start()]),void 0!==this.#Gt&&(await this.#Gt.start(),this.#qt&&(this.#s=await this.#Gt.addWorker(this),this.#Wt.start())),await this.updateState()})}async stop(){return this.#pe.stop(async()=>{void 0!==this.#Gt&&(void 0!==this.#s&&(this.#Wt.stop(),await this.#Gt.removeWorker(this.#s)),await this.#Gt.stop()),await Promise.all([this.#Bt.stop(),this.#Ht.stop()])})}getProcedureNames(){return this.#Ht.getProcedureNames()}hasProcedure(e){return this.#Ht.hasProcedure(e)}isHealthy(){return this.#Bt.isHealthy()}getHealth(){return this.#Bt.getHealth()}isAvailable(){return this.#pe.isAvailable()}async updateState(){const e=await this.isHealthy();return this.#pe.setAvailability(e)}async reportState(e){if(void 0!==this.#Gt&&void 0!==this.#s)return this.#Gt.reportWorker(this.#s,e)}async run(e){return this.#Yt(e)?this.#Xt(e):this.#Jt(e)}#Yt(e){return void 0===this.#Gt||this.#Ht.hasProcedure(e.fqn)}async#Xt(e){const t=this.#Ht.getProcedure(e.fqn),s=t?.getImplementation(e.version);if(this.#Qt(s))throw new x(e.fqn);if(this.#Zt(e,s))throw new ms;const r=e.getHeader(fs);r===ws&&(e=await this.#es(e)),e.removeHeader(fs);const n=await this.#Ht.run(e);return r===ws?this.#ts(n):n}#Qt(e){return void 0===e||e.private}#Zt(e,t){if(t.public)return!1;const s=e.getHeader(gs);return this.#Ut!==s}async#Jt(e){(e=await this.#ss(e)).setHeader(fs,ws),void 0!==this.#Ut&&e.setHeader(gs,this.#Ut);const t=await this.#Gt.run(e);return this.#rs(t)}async#ss(e){const t=new Map;for(const[s,r]of e.args){const e=await this.#_t.serialize(r);t.set(s,e)}return new k(e.fqn,e.version,t,e.headers,e.mode)}async#es(e){const t=new Map;for(const[s,r]of e.args){const e=await this.#_t.deserialize(r);t.set(s,e)}return new k(e.fqn,e.version,t,e.headers,e.mode)}async#ts(e){const t=await this.#_t.serialize(e.result);return new D(e.status,t,e.headers)}async#rs(e){const t=await this.#_t.deserialize(e.result);return new D(e.status,t,e.headers)}async#Kt(){const e=await this.updateState();return this.reportState(e)}}class vs{#K;constructor(e){this.#K=e}async handle(e,t){return this.#K.run(e)}}class Ss{#ns=new G;constructor(){this.#as()}#as(){const e=globalThis;e.__run=this.#is.bind(this),e.ProcedureNotAccessible=O}async#is(e,t,s,r){const n=this.#ns.parse(t),a=new Map(Object.entries(s)),i=r instanceof k?r.headers:new Map,o=new k(e,n,a,i,h),c=this.getTrustKey();void 0!==c&&o.setHeader("X-Jitar-Trust-Key",c);const u=await this.runInternal(o);if(u.status!==p)throw u.result;return u.result}}class Es extends Ss{#os;#cs;#us=new Y(this);constructor(e){super(),this.#os=new ys({url:e.remoteUrl,gateway:new se({url:e.remoteUrl,remote:e.remote}),healthManager:e.healthManager,executionManager:e.executionManager,scheduleManager:e.scheduleManager}),this.#cs=e.middlewareManager}get worker(){return this.#os}async start(){await this.#ls(),this.#us.start()}async stop(){this.#us.stop(),await this.#hs()}getTrustKey(){}run(e){return this.#cs.handle(e)}async runInternal(e){return this.#us.run(e)}async#ls(){await Promise.all([this.#os.start(),this.#cs.start()]);const e=new vs(this.#os);this.#cs.addMiddleware(e)}async#hs(){await Promise.all([this.#cs.stop(),this.#os.stop()])}}const bs="starting",xs="started",Os="stopping",As="stopped";class Cs extends a{constructor(){super("Invalid health check")}}class Is{#ce=As;#ds=new Map;#j;#ps;constructor(e,t=[]){this.#j=e,this.#ps=t}get state(){return this.#ce}async start(){if(this.#ce===As)try{this.#ce=bs,await this.#ms(),this.#ce=xs}catch(e){throw this.#ce=As,e}}async stop(){if(this.#ce===xs)try{this.#ce=Os,this.clearHealthChecks(),this.#ce=As}catch(e){throw this.#ce=xs,e}}async loadHealthCheck(e){const t=await this.#gs(e);this.addHealthCheck(t)}addHealthCheck(e){if(void 0===e.isHealthy)throw new Cs;this.#ds.set(e.name,e)}clearHealthChecks(){this.#ds.clear()}async isHealthy(){const e=[];for(const t of this.#ds.values()){const s=this.#fs(t);e.push(s)}return Promise.all(e).then(e=>e.every(e=>e)).catch(()=>!1)}async getHealth(){const e=[];for(const[t,s]of this.#ds){const r=this.#fs(s).then(e=>({name:t,isHealthy:e})).catch(()=>({name:t,isHealthy:!1}));e.push(r)}const t=new Map;return Promise.allSettled(e).then(e=>e.forEach(e=>this.#ws(e,t))).then(()=>t)}async#ms(){(await Promise.all(this.#ps.map(e=>this.#gs(e)))).forEach(e=>this.addHealthCheck(e))}async#gs(e){return(await this.#j.import(e)).default}#ws(e,t){"fulfilled"===e.status?t.set(e.value.name,e.value.isHealthy):t.set(e.reason.name,!1)}async#fs(e){const t=e.isHealthy(),s=e.timeout;if(void 0===s)return t;const r=new Promise(e=>{setTimeout(e,s)}).then(()=>!1);return Promise.race([r,t])}}const Ns=0,Ms=1,Ts=2,Rs=3;class zs{#ys;#vs;constructor(e=Ms,t=console){this.#ys=e,this.#vs=t}debug(...e){if(this.#ys>Ns)return;const t=this.#Ss("DEBUG",e);this.#vs.debug(t)}info(...e){if(this.#ys>Ms)return;const t=this.#Ss("INFO",e);this.#vs.info(t)}warn(...e){if(this.#ys>Ts)return;const t=this.#Ss("WARN",e);this.#vs.warn(t)}error(...e){if(this.#ys>Rs)return;const t=this.#Ss("ERROR",e);this.#vs.error(t)}fatal(...e){const t=this.#Ss("FATAL",e);this.#vs.error(t)}#Ss(e,t){return`[${e}][${(new Date).toISOString()}] ${t.map(e=>this.#Es(e)).join(" ")}`}#Es(e,t=0){let s;switch(typeof e){case"string":s=e;break;case"object":s=this.#bs(e,t+1);break;case"undefined":s="undefined";break;case"function":s="function";break;default:s=String(e)}return`${this.#xs(t)}${s}`}#bs(e,t){if(null===e)return"null";if(Array.isArray(e)){return`[\n${e.map(e=>this.#Es(e,t)).join(",\n")}\n${this.#xs(t-1)}]`}return e instanceof Error?e.stack??e.message:JSON.stringify(e)}#xs(e){return" ".repeat(e)}}const Ps="starting",Ls="started",ks="stopping",Ds="stopped";class Fs extends a{constructor(){super("Invalid middleware")}}class Vs{#ce=Ds;#Os=[];#j;#As;constructor(e,t=[]){this.#j=e,this.#As=t}get state(){return this.#ce}async start(){if(this.#ce===Ds)try{this.#ce=Ps,await this.#Cs(),this.#ce=Ls}catch(e){throw this.#ce=Ds,e}}async stop(){if(this.#ce===Ls)try{this.#ce=ks,this.clearMiddlewares(),this.#ce=Ds}catch(e){throw this.#ce=Ls,e}}async loadMiddleware(e){const t=await this.#Is(e);this.addMiddleware(t)}addMiddleware(e){if(void 0===e?.handle)throw new Fs;this.#Os.push(e)}getMiddleware(e){return this.#Os.find(t=>t instanceof e)}clearMiddlewares(){this.#Os=[]}handle(e){return this.#Ns(e,0)()}async#Cs(){(await Promise.all(this.#As.map(e=>this.#Is(e)))).forEach(e=>this.addMiddleware(e))}async#Is(e){return(await this.#j.import(e)).default}#Ns(e,t){const s=this.#Os[t];if(void 0===s)return async()=>new D(p);const r=this.#Ns(e,t+1);return async()=>await s.handle(e,r)}}class js{#Ms;#Ts;#Rs;#zs=null;constructor(e,t,s=5e3){this.#Ms=e,this.#Ts=t,this.#Rs=s}start(){this.#Ps()}stop(){null!==this.#zs&&(clearTimeout(this.#zs),this.#zs=null)}#Ps(){this.#zs=setTimeout(async()=>{null!==this.#zs&&(await this.#Ls(),this.#Ps())},this.#Rs),this.#zs.unref()}async#Ls(){try{await this.#Ts()}catch(e){this.#Ms.warn("Scheduled task failed",e)}}}class $s{#ks=[];#Ms;constructor(e){this.#Ms=e}create(e,t){const s=new js(this.#Ms,e,t);return this.#ks.push(s),s}remove(e){const t=this.#ks.indexOf(e);t<0||this.#ks.splice(t,1)}startAll(){this.#ks.forEach(e=>e.start())}stopAll(){this.#ks.forEach(e=>e.stop())}}class Hs{#Ds;constructor(e){this.#Ds=e}build(e){const t=e.remoteUrl,s=e.middleware,r=e.segments,n=new zs(e.logLevel??Ts),a=this.#Ds.build(t),i=new ge(t),o=this.#Fs(i),c=this.#Vs(i,s),u=this.#js(i,r),l=this.#$s(n);return new Es({remoteUrl:t,remote:a,healthManager:o,middlewareManager:c,executionManager:u,scheduleManager:l})}#Fs(e){return new Is(e)}#Vs(e,t=[]){const s=new Vs(e);return t.forEach(e=>s.addMiddleware(e)),s}#js(e,t=[]){const s=new _(e);return t.forEach(e=>s.addSegment(e)),s}#$s(e){return new $s(e)}}class Us{#Hs;constructor(e=!0){this.#Hs=e}validate(e,t){const s=[];this.#Us("",e,t,s);return{valid:0===s.length,errors:s}}#Us(e,t,s,r){this.#Hs&&this.#Gs(e,t,s,r),this.#qs(e,t,s,r)}#Gs(e,t,s,r){const n=Object.keys(t),a=Object.keys(s);for(const t of n)if(!1===a.includes(t)){const s=this.#Bs(e,t);r.push(`Unknown field '${s}'`)}}#qs(e,t,s,r){const n=Object.keys(s);for(const a of n){const n=this.#Bs(e,a),i=s[a],o=t[a];this.#Ws(n,o,i,r)}}#Ws(e,t,s,r){if(void 0!==t)switch(s.type){case"string":return this.#_s(e,t,s,r);case"integer":return this.#Ks(e,t,s,r);case"real":return this.#Ys(e,t,s,r);case"boolean":return this.#Xs(e,t,s,r);case"url":return this.#Js(e,t,s,r);case"group":return this.#Qs(e,t,s,r);case"list":return this.#Zs(e,t,s,r)}else!0===s.required&&r.push(`Field '${e}' is required`)}#_s(e,t,s,r){"string"!=typeof t&&r.push(`Field '${e}' is not a string`)}#Ks(e,t,s,r){"number"==typeof t&&!1!==Number.isInteger(t)||r.push(`Field '${e}' is not an integer`)}#Ys(e,t,s,r){"number"!=typeof t&&r.push(`Field '${e}' is not a real number`)}#Xs(e,t,s,r){"boolean"!=typeof t&&r.push(`Field '${e}' is not a boolean`)}#Js(e,t,s,r){"string"==typeof t&&!1!==t.startsWith("http")||r.push(`Field '${e}' is not a valid URL`)}#Qs(e,t,s,r){"object"==typeof t?this.#Us(e,t,s.fields,r):r.push(`Field '${e}' is not an object`)}#Zs(e,t,s,r){if(!Array.isArray(t))return void r.push(`Field '${e}' is not a list`);const n=t;for(const t in n){const a=this.#Bs(e,t),i=n[t];this.#Ws(a,i,s.items,r)}}#Bs(e,t){return""===e?t:`${e}.${t}`}}const Gs="content-type",qs="x-jitar-content-type",Bs="x-jitar-procedure-version",Ws="application/json",_s="application/octet-stream";class Ks extends Error{constructor(){super("Invalid worker id")}}class Ys{#he;#er;#U=new H;#tr=new Us;constructor(e,t){this.#he=e,this.#er=t}connect(){return Promise.resolve()}disconnect(){return Promise.resolve()}async provide(e){const t=`${this.#he}/${e}`,s=await this.#sr(t,{method:"GET"}),r=s.headers.get(Gs)??_s,n=await s.arrayBuffer(),a=Buffer.from(n);return new ae(e,r,a)}async isHealthy(){const e=`${this.#he}/health/status`,t=await this.#sr(e,{method:"GET"});return"true"===await t.text()}async getHealth(){const e=`${this.#he}/health`,t=await this.#sr(e,{method:"GET"}),s=await t.json();return new Map(Object.entries(s))}async addWorker(e,t,s){const r=`${this.#he}/workers`,n={url:e,procedureNames:t,trustKey:s},a={method:"POST",headers:{"Content-Type":Ws},body:JSON.stringify(n)},i=await this.#sr(r,a),o=i.headers.get(Gs);if(null===o||!1===o.includes(Ws))throw new Ks;const c=await i.json();if(!1===this.#tr.validate(c,{id:{type:"string",required:!0}}).valid)throw new Ks;return c.id}async reportWorker(e,t){const s=`${this.#he}/workers/${e}/report`,r={state:t},n={method:"POST",headers:{"Content-Type":Ws},body:JSON.stringify(r)};await this.#sr(s,n)}async removeWorker(e){const t=`${this.#he}/workers/${e}`,s={method:"DELETE",headers:{"Content-Type":Ws}};await this.#sr(t,s)}async run(e){e.setHeader(Gs,Ws);const t=Object.fromEntries(e.args),s=Object.fromEntries(e.headers),r=e.version.toString();s[Bs]=r;const n=`${this.#he}/rpc/${e.fqn}`,a={method:"POST",redirect:"manual",headers:s,body:await this.#rr(t)},i=await this.#sr(n,a,!1),o=i.status,c=await this.#nr(i),u=this.#ar(i);return new D(o,c,u)}async#sr(e,t,s=!0){const r=await this.#er.execute(e,t);if(s&&this.#ir(r)){const e=await this.#nr(r);throw this.#U.fromStatus(r.status,String(e))}return r}#ir(e){return e.status<200||e.status>399}async#rr(e){return JSON.stringify(e)}async#nr(e){const t=e.headers.get(qs)??e.headers.get(Gs);if(t?.includes("undefined"))return;if(t?.includes("null"))return null;if(t?.includes("json"))return e.json();const s=await e.text();return t?.includes("boolean")?"true"===s:t?.includes("number")?Number(s):s}#ar(e){const t=new Map;for(const[s,r]of e.headers)t.set(s,r);return t}}class Xs{async execute(e,t){return fetch(e,t)}}class Js{#er;constructor(e=new Xs){this.#er=e}build(e){return new Ys(e,this.#er)}}export{P as ArrayParameter,e as BadRequest,C as Class,Hs as ClientBuilder,t as Forbidden,Js as HttpRemoteBuilder,M as Implementation,R as NamedParameter,s as NotFound,r as NotImplemented,L as ObjectParameter,n as PaymentRequired,N as Procedure,k as Request,D as Response,A as Segment,a as ServerError,i as Teapot,o as Unauthorized,I as Version};
|
|
1
|
+
class e extends Error{constructor(e="Invalid request"){super(e)}}class t extends Error{constructor(e="Forbidden"){super(e)}}class s extends Error{constructor(e="Not found"){super(e)}}class r extends Error{constructor(e="Not implemented"){super(e)}}class i extends Error{constructor(e="Payment required"){super(e)}}class n extends Error{constructor(e="Server error"){super(e)}}class a extends Error{constructor(e="I'm a teapot"){super(e)}}class o extends Error{constructor(e="Unauthorized"){super(e)}}const c="private",l="protected",u="public",h="normal",d="dry",p=200,m=400,f=401,g=402,w=403,y=404,E=418,S=500,v=501;class b extends e{#e;constructor(e){super(`Invalid version number '${e}'`),this.#e=e}get number(){return this.#e}}class O extends s{#t;constructor(e){super(`Procedure '${e}' not found`),this.#t=e}get fqn(){return this.#t}}class A extends t{constructor(e,t){super(`Procedure '${e}' (v${t}) is not accessible`)}}class T{#s;#r=new Map;#i=new Map;constructor(e){this.#s=e}get id(){return this.#s}addClass(e){return this.#r.set(e.fqn,e),this}hasClass(e){return void 0!==this.getClass(e)}getClass(e){return this.#r.get(e)}getClassByImplementation(e){return this.getClasses().find(t=>t.implementation===e)}getClasses(){return[...this.#r.values()]}addProcedure(e){return this.#i.set(e.fqn,e),this}hasProcedure(e){return this.#i.has(e)}getProcedure(e){return this.#i.get(e)}getExposedProcedures(){return[...this.#i.values()].filter(e=>e.public||e.protected)}}class N{#t;#n;constructor(e,t){this.#t=e,this.#n=t}get fqn(){return this.#t}get implementation(){return this.#n}}class I{static get DEFAULT(){return new I(0,0,0)}#a;#o;#c;constructor(e=0,t=0,s=0){this.#a=e,this.#o=t,this.#c=s}get major(){return this.#a}get minor(){return this.#o}get patch(){return this.#c}equals(e){return this.#a===e.major&&this.#o===e.minor&&this.#c===e.patch}greater(e){return this.#a!==e.major?this.#a>e.major:this.#o!==e.minor?this.#o>e.minor:this.#c!==e.patch&&this.#c>e.patch}less(e){return this.#a!==e.major?this.#a<e.major:this.#o!==e.minor?this.#o<e.minor:this.#c!==e.patch&&this.#c<e.patch}toString(){return`${this.#a}.${this.#o}.${this.#c}`}}class x{#t;#l=new Map;#u;constructor(e){this.#t=e}get fqn(){return this.#t}get public(){return[...this.#l.values()].some(e=>e.public)}get protected(){return[...this.#l.values()].some(e=>e.protected)}addImplementation(e){return this.#l.set(e.version,e),this.#h(e)&&(this.#u=e),this}#h(e){return void 0===this.#u||e.version.greater(this.#u.version)}getImplementation(e){const t=this.#d(e);return this.#l.get(t)}#d(e){let t=I.DEFAULT;for(const s of this.#l.keys()){if(s.equals(e))return s;s.greater(e)||t.less(s)&&(t=s)}return t}}class C{#p;#m;#f;#g;constructor(e,t,s,r){this.#p=e,this.#m=t,this.#f=s,this.#g=r}get version(){return this.#p}get public(){return this.#m===u}get protected(){return this.#m===l}get private(){return this.#m===c}get parameters(){return this.#f}get executable(){return this.#g}}class R{#w;#y;constructor(e,t=!1){this.#w=e,this.#y=t}get name(){return this.#w}get isOptional(){return this.#y}}class M extends R{}class z extends R{#E;constructor(e,t,s){super(t??"(anonymous)",s),this.#E=e}get variables(){return this.#E}}class L extends z{}class P extends z{}class k{#t;#p;#S;#v=new Map;#b;constructor(e,t,s,r,i){this.#t=e,this.#p=t,this.#S=s,this.#v=r,this.#b=i}get fqn(){return this.#t}get version(){return this.#p}get args(){return this.#S}get headers(){return this.#v}get mode(){return this.#b}clearArguments(){this.#S.clear()}setArgument(e,t){this.#S.set(e,t)}getArgument(e){return this.#S.get(e)}hasArgument(e){return this.#S.has(e)}removeArgument(e){this.#S.delete(e)}clearHeaders(){this.#v.clear()}setHeader(e,t){this.#v.set(e.toLowerCase(),t)}getHeader(e){return this.#v.get(e.toLowerCase())}hasHeader(e){return this.#v.has(e.toLowerCase())}removeHeader(e){this.#v.delete(e.toLowerCase())}}class ${#O;#A;#v;constructor(e,t=void 0,s=new Map){this.#O=e,this.#A=t,this.#v=s}get status(){return this.#O}get result(){return this.#A}set result(e){this.#A=e}get headers(){return this.#v}clearHeaders(){this.#v.clear()}setHeader(e,t){this.#v.set(e.toLowerCase(),t)}getHeader(e){return this.#v.get(e.toLowerCase())}hasHeader(e){return this.#v.has(e.toLowerCase())}removeHeader(e){this.#v.delete(e.toLowerCase())}}class V extends e{#T;constructor(e){super(`Unknown parameter ${e}`),this.#T=e}get parameterName(){return this.#T}}class D extends e{#T;constructor(e){super(`Missing value for parameter '${e}'`),this.#T=e}get parameterName(){return this.#T}}class j extends e{#T;constructor(e){super(`Invalid value for parameter '${e}'`),this.#T=e}get parameterName(){return this.#T}}class F{extract(e,t){const s=this.#N(e,t),r=[];for(const t of e){const e=this.#I(t,s);r.push(e)}if(s.size>0){const e=s.keys().next().value;throw new V(e)}return r}#N(e,t){const s=new Map;for(const[r,i]of t){if(this.#x(r)){const t=this.#C(r);!0===this.#R(e,t)&&s.set(t,i);continue}s.set(r,i)}return s}#x(e){return e.startsWith("*")}#C(e){return e.substring(1)}#R(e,t){return void 0!==e.find(e=>e.name===t)}#I(e,t,s){return e instanceof M?this.#M(e,t,s):this.#z(e,t)}#M(e,t,s){const r=t.get(e.name);if(this.#L(e,r,s))throw new D(e.name);if(this.#P(e,r,s))throw new j(e.name);return t.delete(e.name),r}#z(e,t){return e instanceof L?this.#k(e,t):this.#$(e,t)}#k(e,t){const s=this.#V(e,t);return void 0!==s?Object.values(s):void 0}#$(e,t){return this.#V(e,t)}#V(e,t){const s=e instanceof L,r={},i=[];let n=!1,a=0;for(const o of e.variables){const c=s?a++:o.name,l=this.#I(o,t,e);void 0!==l?n=!0:!1===o.isOptional&&i.push(o.name),r[c]=l}if(!0===n&&i.length>0)throw new D(i[0]);return n?r:void 0}#L(e,t,s){return void 0===t&&(!0!==e.isOptional&&!0!==s?.isOptional)}#P(e,t,s){return!1!==e.name.startsWith("...")&&(void 0===s&&t instanceof Array==!1||s instanceof L&&t instanceof Array==!1||s instanceof P&&t instanceof Object==!1)}}class B{toStatus(n){return n instanceof e?m:n instanceof t?w:n instanceof s?y:n instanceof r?v:n instanceof i?g:n instanceof a?E:n instanceof o?f:S}fromStatus(c,l){switch(c){case m:return new e(l);case w:return new t(l);case y:return new s(l);case v:return new r(l);case g:return new i(l);case E:return new a(l);case f:return new o(l);default:return new n(l)}}}const H=/^\d+(?:\.\d+){0,2}$/;class U{parse(e){if(0===e.trim().length)return I.DEFAULT;if(!1===H.test(e))throw new b(e);const t=e.split(".");switch(t.length){case 1:return new I(Number.parseInt(t[0]));case 2:return new I(Number.parseInt(t[0]),Number.parseInt(t[1]));default:return new I(Number.parseInt(t[0]),Number.parseInt(t[1]),Number.parseInt(t[2]))}}}class G extends s{#t;#p;constructor(e,t){super(`No implementation found for procedure '${e}' with version '${t}'`),this.#t=e,this.#p=t}get fqn(){return this.#t}get version(){return this.#p}}class q extends n{constructor(){super("Invalid segment")}}class W{#D=new Map;addSegment(e){this.#D.set(e.id,e)}clearSegments(){this.#D.clear()}getClassNames(){const e=new Set;for(const t of this.#D.values()){t.getClasses().forEach(t=>e.add(t.fqn))}return[...e.values()]}hasClass(e){return this.getClassNames().includes(e)}getClass(e){for(const t of this.#D.values())if(t.hasClass(e))return t.getClass(e)}getClassByImplementation(e){for(const t of this.#D.values()){const s=t.getClassByImplementation(e);if(void 0!==s)return s}}getProcedureNames(){const e=new Set;for(const t of this.#D.values()){t.getExposedProcedures().forEach(t=>e.add(t.fqn))}return[...e.values()]}hasProcedure(e){return this.getProcedureNames().includes(e)}getProcedure(e){for(const t of this.#D.values())if(t.hasProcedure(e))return t.getProcedure(e)}}class _{#j;#F;#B=new F;#H=new B;#U=new W;constructor(e,t=[]){this.#j=e,this.#F=t}async start(){return this.#G()}async stop(){return this.#q()}async loadSegment(e){const t=await this.#j.import(e);this.addSegment(t.default)}async addSegment(e){if(e instanceof T==!1)throw new q;this.#U.addSegment(e)}getClassNames(){return this.#U.getClassNames()}hasClass(e){return this.#U.hasClass(e)}getClass(e){return this.#U.getClass(e)}getClassByImplementation(e){return this.#U.getClassByImplementation(e)}getProcedureNames(){return this.#U.getProcedureNames()}hasProcedure(e){return this.#U.hasProcedure(e)}getProcedure(e){return this.#U.getProcedure(e)}async run(e){const t=this.#W(e.fqn,e.version),s=this.#B.extract(t.parameters,e.args);return e.mode===d?new $(p,void 0):this.#_(e,t,s)}async#G(){await Promise.all(this.#F.map(e=>this.loadSegment(e)))}#q(){this.#U.clearSegments()}#W(e,t){const s=this.#U.getProcedure(e);if(void 0===s)throw new O(e);const r=s.getImplementation(t);if(void 0===r)throw new G(s.fqn,t.toString());return r}async#_(e,t,s){try{const r=await t.executable.call(e,...s);return new $(p,r)}catch(e){const t=this.#H.toStatus(e);return new $(t,e)}}}class K extends n{constructor(){super("Request cancelled")}}class Y{#K;#Y;#X=[];#J=!1;#Q=0;constructor(e,t=20){this.#K=e,this.#Y=t}start(){this.#J=!0,this.#Z()}stop(){this.#J=!1,this.#ee()}run(e){return new Promise((t,s)=>{this.#X.push({request:e,resolve:t,reject:s}),this.#Z()})}#Z(){if(this.#te())return;const e=this.#X.length,t=this.#Y-this.#Q,s=Math.min(e,t);this.#se(s)}#te(){return this.#re()||this.#ie()||this.#ne()}#re(){return!1===this.#J}#ie(){return 0===this.#X.length}#ne(){return this.#Q>=this.#Y}#se(e){const t=this.#X.splice(0,e);this.#Q+=e,t.forEach(e=>this.#ae(e))}async#ae(e){try{const t=await this.#K.run(e.request);e.resolve(t)}catch(t){e.reject(t)}finally{this.#Q--,this.#Z()}}#ee(){for(;this.#X.length>0;){const e=this.#X.shift();void 0!==e&&this.#oe(e)}}#oe(e){e.reject(new K)}}const X="starting",J="available",Q="unavailable",Z="stopping",ee="stopped";class te{#ce=ee;get state(){return this.#ce}set state(e){this.#ce=e}async start(e){if(!this.isStarted())try{this.setStarting(),await e()}catch(e){throw this.setStopped(),e}}async stop(e){this.isStopped()||(this.setStopping(),await e(),this.setStopped())}isStarted(){return this.#le(ee)}isStopped(){return this.#ue(ee)}isAvailable(){return this.#ue(J)}setStarting(){this.#ce=X}setAvailable(){this.#ce=J}setUnavailable(){this.#ce=Q}setAvailability(e){return this.#ce=e?J:Q,this.#ce}setStopping(){this.#ce=Z}setStopped(){this.#ce=ee}#ue(...e){return e.includes(this.#ce)}#le(...e){return!1===this.#ue(...e)}}class se{#he;#de;#pe=new te;constructor(e){this.#he=e.url,this.#de=e.remote}get url(){return this.#he}get state(){return this.#pe.state}get trustKey(){}async start(){return this.#pe.start(async()=>{await this.#de.connect(),await this.updateState()})}async stop(){return this.#pe.stop(async()=>{await this.#de.disconnect()})}isHealthy(){return this.#de.isHealthy()}getHealth(){return this.#de.getHealth()}async updateState(){const e=await this.isHealthy();return this.#pe.setAvailability(e)}getProcedureNames(){throw new r}hasProcedure(e){throw new r}addWorker(e){return this.#de.addWorker(e.url,e.getProcedureNames(),e.trustKey)}reportWorker(e,t){return this.#de.reportWorker(e,t)}removeWorker(e){return this.#de.removeWorker(e)}run(e){return this.#de.run(e)}}class re extends Error{#me;constructor(e){super(`Invalid location: ${e}`),this.#me=e}get location(){return this.#me}}class ie extends Error{#fe;constructor(e){super(`The file '${e}' could not be found`),this.#fe=e}get filename(){return this.#fe}}class ne{#me;#ge;#we;constructor(e,t,s){this.#me=e,this.#ge=t,this.#we=s}get location(){return this.#me}get type(){return this.#ge}get content(){return this.#we}get size(){return this.#we.length}}class ae{#me;#ye;#Ee;constructor(e,t){const s=t.resolve(e);this.#me=t.normalize(e),this.#ye=t.normalize(s),this.#Ee=t}getAbsoluteLocation(e){const t=this.#Ee.isAbsolute(e)?e:this.#Ee.join(this.#me,e),s=this.#Ee.resolve(t),r=this.#Ee.normalize(s);return this.#Se(r,e),r}getRelativeLocation(e){const t=this.#Ee.relative(this.#me,e);return this.#Ee.normalize(t)}normalizeLocation(e){return this.#Ee.normalize(e)}async getType(e){const t=this.getAbsoluteLocation(e);return await this.#Ee.mimeType(t)??"application/octet-stream"}async getContent(e){const t=this.getAbsoluteLocation(e);if(!1===await this.#Ee.exists(t))throw new ie(e);return this.#Ee.read(t)}async exists(e){const t=this.getAbsoluteLocation(e);return this.#Ee.exists(t)}isDirectory(e){const t=this.getAbsoluteLocation(e);return this.#Ee.isDirectory(t)}async read(e){const t=this.getAbsoluteLocation(e),s=await this.getType(t),r=await this.getContent(t);return new ne(e,s,r)}async write(e,t){const s=this.getAbsoluteLocation(e);return this.#Ee.write(s,t)}async copy(e,t){const s=this.getAbsoluteLocation(e),r=this.getAbsoluteLocation(t);return this.#Ee.copy(s,r)}async delete(e){const t=this.getAbsoluteLocation(e);return this.#Ee.delete(t)}async filter(e){const t=this.getAbsoluteLocation("./"),s=this.#Ee.normalize(e);return(await this.#Ee.filter(t,s)).map(e=>this.#Ee.normalize(e))}#Se(e,t){if(!1===e.startsWith(this.#ye))throw new re(t)}}class oe extends Error{constructor(){super("Remote files are not supported")}}class ce{copy(e,t){throw new oe}delete(e){throw new oe}exists(e){throw new oe}async filter(e,t){return[]}isAbsolute(e){return e.startsWith("/")}isDirectory(e){throw new oe}join(...e){throw new oe}read(e){throw new oe}resolve(e){return e}relative(e,t){throw new oe}normalize(e){return e}mimeType(e){throw new oe}write(e,t){throw new oe}}class le extends ae{constructor(e){super(e,new ce)}}class ue extends Error{#he;#ve;constructor(e,t){super(`Module '${e}' could not be loaded${void 0!==t?` | ${t}`:""}`),this.#he=e,this.#ve=t}get url(){return this.#he}get reason(){return this.#ve}}class he{#be;constructor(e){this.#be=e}async import(e){const t=this.#be.locate(e);try{return await import(t)}catch(e){const s=e instanceof Error?e.message:String(e);throw new ue(t,s)}}}class de{constructor(e){}locate(e){throw new ue(e,"Remote module loading is not allowed")}}class pe extends he{constructor(e){super(new de(e))}}class me{#Oe;#Ae;constructor(e,t){this.#Oe=e,this.#Ae=t}get fileManager(){return this.#Oe}get importManager(){return this.#Ae}async filter(...e){return(await Promise.all(e.map(e=>this.#Oe.filter(e)))).flat().map(e=>this.#Oe.getRelativeLocation(e))}exists(e){return this.#Oe.exists(e)}read(e){return this.#Oe.read(e)}import(e){return this.#Ae.import(e)}}class fe extends me{constructor(e){super(new le(e),new pe(e))}fork(e){const t=this.fileManager.getAbsoluteLocation(e);return new fe(t)}}class ge extends Error{constructor(e){super(`The class '${e}' could not be found`)}}class we extends Error{constructor(e){super(`The class '${e}' is invalid`)}}class ye extends Error{constructor(e){super(`No deserializer found for value of type '${e}'`)}}class Ee extends Error{constructor(e){super(`No serializer found for value of type '${e}'`)}}class Se{#Te=[];addSerializer(e){e.parent=this,this.#Te.unshift(e)}async serialize(e){const t=this.#Te.find(t=>t.canSerialize(e));if(void 0===t)throw new Ee(typeof e);return t.serialize(e)}async deserialize(e){const t=this.#Te.find(t=>t.canDeserialize(e));if(void 0===t)throw new ye(typeof e);return t.deserialize(e)}}class ve extends Error{constructor(){super("Parent serializer not set")}}class be{#Ne;set parent(e){this.#Ne=e}serializeOther(e){if(void 0===this.#Ne)throw new ve;return this.#Ne.serialize(e)}deserializeOther(e){if(void 0===this.#Ne)throw new ve;return this.#Ne.deserialize(e)}}class Oe extends be{canSerialize(e){return e instanceof Array}canDeserialize(e){return e instanceof Array}async serialize(e){const t=[];for(const s of e)t.push(await this.serializeOther(s));return t}async deserialize(e){return Promise.all(e.map(async e=>this.deserializeOther(e)))}}class Ae extends Error{constructor(e){super(`Invalid BigInt string '${e}'`)}}class Te extends be{canSerialize(e){return"bigint"==typeof e}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"BigInt"===t.name&&"string"==typeof t.value}async serialize(e){return{serialized:!0,name:"BigInt",value:e.toString()}}async deserialize(e){try{return BigInt(e.value)}catch{throw new Ae(e.value)}}}class Ne extends Error{constructor(e){super(`Invalid Buffer string '${e}'`)}}class Ie extends be{canSerialize(e){return e instanceof Buffer}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Buffer"===t.name&&"string"==typeof t.base64}async serialize(e){return{serialized:!0,name:"Buffer",base64:e.toString("base64")}}async deserialize(e){try{return Buffer.from(e.base64,"base64")}catch{throw new Ne(e.base64)}}}class xe{}class Ce extends xe{elements;constructor(e){super(),this.elements=e}clone(){const e=this.elements.map(e=>e.clone());return new Ce(e)}toString(){return`[${this.elements.map(e=>e.toString()).join(",")}]`}}class Re{}class Me extends Re{identifier;constructor(e){super(),this.identifier=e}is(e){return this.identifier===e}}class ze extends Me{parameters;body;isAsync;constructor(e,t,s,r=!1){super(e),this.parameters=t,this.body=s,this.isAsync=r}clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new ze(this.identifier,e,t,this.isAsync)}toString(){const e=this.isAsync?"async ":"",t=this.identifier?` ${this.identifier}`:"",s=this.parameters.map(e=>e.toString()),r=this.body.toString();return`${e}function${t}(${s.join(",")})${r}`}}class Le extends ze{constructor(e,t,s=!1){super(void 0,e,t,s)}clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new Le(e,t,this.isAsync)}toString(){const e=this.isAsync?"async ":"",t=this.parameters.map(e=>e.toString()),s=this.body.toString();return`${e}(${t.join(", ")})=>${s}`}}class Pe{binding;initializer;constructor(e,t){this.binding=e,this.initializer=t}clone(){const e=this.binding.clone(),t=this.initializer?.clone();return new Pe(e,t)}toString(){return`${this.binding.toString()}${void 0!==this.initializer?`=${this.initializer.toString(!1)}`:""}`}}class ke extends Re{code;constructor(e){super(),this.code=e}clone(){return new ke(this.code)}toString(){return this.code}}class $e{identifier;visibility;location;constructor(e,t,s){this.identifier=e,this.visibility=t,this.location=s}is(e){return this.identifier===e}}class Ve extends $e{parameters;body;constructor(e,t){super("constructor","public","instance"),this.parameters=e,this.body=t}clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new Ve(e,t)}toString(){const e=this.parameters.map(e=>e.toString()),t=this.body.toString();return`${this.identifier}(${e.join(",")}) ${t}`}}class De extends $e{body;constructor(e,t,s,r){super(e,t,s),this.body=r}clone(){const e=this.body.clone();return new De(this.identifier,this.visibility,this.location,e)}toString(){const e="static"===this.location?"static ":"",t="private"===this.visibility?"#":"",s=this.body.toString();return`${e}get ${t}${this.identifier}()${s}`}}class je extends $e{parameter;body;constructor(e,t,s,r,i){super(e,t,s),this.parameter=r,this.body=i}clone(){const e=this.parameter.clone(),t=this.body.clone();return new je(this.identifier,this.visibility,this.location,e,t)}toString(){const e="static"===this.location?"static ":"",t="private"===this.visibility?"#":"",s=this.parameter.toString(),r=this.body.toString();return`${e}set ${t}${this.identifier}(${s})${r}`}}class Fe extends $e{parameters;body;isAsync;constructor(e,t,s,r,i,n=!1){super(e,t,s),this.parameters=r,this.body=i,this.isAsync=n}clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new Fe(this.identifier,this.visibility,this.location,e,t,this.isAsync)}toString(){const e="static"===this.location?"static ":"",t="private"===this.visibility?"#":"",s=this.isAsync?"async ":"",r=this.parameters.map(e=>e.toString()),i=this.body.toString();return`${e}${s}${t}${this.identifier}(${r.join(",")})${i}`}}class Be extends $e{initializer;constructor(e,t,s,r){super(e,t,s),this.initializer=r}clone(){const e=this.initializer?.clone();return new Be(this.identifier,this.visibility,this.location,e)}toString(){const e="static"===this.location?"static ":"",t="private"===this.visibility?"#":"",s=void 0!==this.initializer?`=${this.initializer.toString(!0)}`:";";return`${e}${t}${this.identifier}${s}`}}class He extends Me{parent;members;constructor(e,t,s){super(e),this.parent=t,this.members=s}get construct(){return this.members.find(e=>e instanceof Ve)}get fields(){return this.members.filter(e=>e instanceof Be)}get getters(){return this.members.filter(e=>e instanceof De)}get setters(){return this.members.filter(e=>e instanceof je)}get methods(){return this.members.filter(e=>e instanceof Fe)}get publicFields(){return this.fields.filter(e=>"public"===e.visibility)}get publicGetters(){return this.getters.filter(e=>"public"===e.visibility)}get publicSetters(){return this.setters.filter(e=>"public"===e.visibility)}get publicMethods(){return this.methods.filter(e=>"public"===e.visibility)}get readable(){return[...this.publicFields,...this.publicGetters]}get writable(){return[...this.publicFields,...this.publicSetters]}getMember(e){return this.members.find(t=>t.is(e))}hasMember(e){return this.members.some(t=>t.is(e))}getField(e){return this.fields.find(t=>t.is(e))}hasField(e){return this.fields.some(t=>t.is(e))}getGetter(e){return this.getters.find(t=>t.is(e))}hasGetter(e){return this.getters.some(t=>t.is(e))}getSetter(e){return this.setters.find(t=>t.is(e))}hasSetter(e){return this.setters.some(t=>t.is(e))}getMethod(e){return this.methods.find(t=>t.is(e))}hasMethod(e){return this.methods.some(t=>t.is(e))}canRead(e){return this.readable.some(t=>t.is(e))}canWrite(e){return this.writable.some(t=>t.is(e))}clone(){const e=this.members.map(e=>e.clone());return new He(this.identifier,this.parent,e)}toString(){return`class ${this.identifier??""}${void 0!==this.parent?` extends ${this.parent}`:""}{${this.members.map(e=>e.toString()).join("")}}`}}class Ue extends Re{members;from;constructor(e,t){super(),this.members=e,this.from=t}hasMember(e){return this.members.some(t=>t.is(e))}getMember(e){return this.members.find(t=>t.is(e))}clone(){const e=this.members.map(e=>e.clone());return new Ue(e,this.from)}toString(){const e=this.members.map(e=>e.toString()),t=this.from?` from '${this.from}'`:"";return`export {${e.join(",")}}${t};`}}class Ge extends Re{code;constructor(e){super(),this.code=e}clone(){return new Ge(this.code)}toString(e=!0){const t=!1===e||this.code.endsWith("}")?"":";";return`${this.code}${t}`}}class qe extends ze{clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new qe(this.identifier,e,t,this.isAsync)}toString(){const e=this.isAsync?"async ":"",t=this.identifier??"",s=this.parameters.map(e=>e.toString()),r=this.body.toString();return`${e}function* ${t}(${s.join(",")})${r}`}}class We extends Fe{clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new We(this.identifier,this.visibility,this.location,e,t,this.isAsync)}toString(){const e=this.isAsync?"async ":"",t=this.identifier,s=this.parameters.map(e=>e.toString()),r=this.body.toString();return`${e}*${t}(${s.join(",")})${r}`}}class _e extends xe{identifier;isRest;constructor(e,t=!1){super(),this.identifier=e,this.isRest=t}clone(){return new _e(this.identifier,this.isRest)}toString(){return`${this.isRest?"...":""}${this.identifier}`}}class Ke extends Re{members;from;constructor(e,t){super(),this.members=e,this.from=t}hasMember(e){return this.members.some(t=>t.is(e))}getMember(e){return this.members.find(t=>t.is(e))}clone(){const e=this.members.map(e=>e.clone());return new Ke(e,this.from)}toString(){if(0===this.members.length)return`import '${this.from}';`;return`import {${this.members.map(e=>e.toString()).join(",")}} from '${this.from}';`}}class Ye extends Me{type;binding;initializer;constructor(e,t,s){super(t.toString()),this.type=e,this.binding=t,this.initializer=s}clone(){const e=this.binding.clone(),t=this.initializer?.clone();return new Ye(this.type,e,t)}toString(){const e=void 0!==this.initializer?`=${this.initializer.toString(!0)}`:"",t=e.endsWith(";")?"":";";return`${this.type} ${this.identifier}${e}${t}`}}class Xe{statements;constructor(e){this.statements=e}get exports(){return this.statements.filter(e=>e instanceof Ue)}get imports(){return this.statements.filter(e=>e instanceof Ke)}get expressions(){return this.statements.filter(e=>e instanceof Ge)}get declarations(){return this.statements.filter(e=>e instanceof Me)}get variables(){return this.statements.filter(e=>e instanceof Ye)}get functions(){return this.statements.filter(e=>e instanceof ze)}get classes(){return this.statements.filter(e=>e instanceof He)}get exported(){const e=[];for(const t of this.exports)for(const s of t.members){const t=this.getDeclaration(s.identifier);void 0!==t&&e.push(t)}return e}get exportedVariables(){return this.exported.filter(e=>e instanceof Ye)}get exportedFunctions(){return this.exported.filter(e=>e instanceof ze)}get exportedClasses(){return this.exported.filter(e=>e instanceof He)}getExport(e){return this.exports.find(t=>t.hasMember(e))}getImport(e){return this.imports.find(t=>t.hasMember(e))}hasDeclaration(e){return this.declarations.some(t=>t.is(e))}getDeclaration(e){return this.declarations.find(t=>t.is(e))}hasVariable(e){return this.variables.some(t=>t.is(e))}getVariable(e){return this.variables.find(t=>t.is(e))}hasFunction(e){return this.functions.some(t=>t.is(e))}getFunction(e){return this.functions.find(t=>t.is(e))}hasClass(e){return this.classes.some(t=>t.is(e))}getClass(e){return this.classes.find(t=>t.is(e))}clone(){const e=this.statements.map(e=>e.clone());return new Xe(e)}toString(){return this.statements.map(e=>e.toString(!0)).join("\n")}}class Je{identifier;alias;constructor(e,t){this.identifier=e,this.alias=t}is(e){return this.alias===e||void 0===this.alias&&this.identifier===e}clone(){return new Je(this.identifier,this.alias)}toString(){return void 0===this.alias?this.identifier:`${this.identifier} as ${this.alias}`}}class Qe extends xe{elements;constructor(e){super(),this.elements=e}clone(){const e=this.elements.map(e=>e.clone());return new Qe(e)}toString(){return`{${this.elements.map(e=>e.toString()).join(",")}}`}}const Ze={SINGLE:"//",MULTI_START:"/*",MULTI_END:"*/"},et=Object.values(Ze);const tt=".",st="(",rt=")",it="[",nt="]",at="{",ot="}",ct="_",lt={SCOPE:":",SEPARATOR:",",TERMINATOR:";"},ut=Object.values(lt);function ht(e){return ut.includes(e)}const dt={UNDEFINED:void 0,NULL:null,STRING:""},pt=["null","undefined"],mt=Object.values(dt);function ft(e){return mt.includes(e)}const gt={OPEN:st,CLOSE:rt};function wt(e){return e===gt.OPEN||e===gt.CLOSE}const yt={IMPORT:"import",EXPORT:"export",AS:"as",FROM:"from",DEFAULT:"default",ASYNC:"async",AWAIT:"await",USING:"using",CONST:"const",LET:"let",VAR:"var",FUNCTION:"function",RETURN:"return",YIELD:"yield",CLASS:"class",CONSTRUCTOR:"constructor",GET:"get",SET:"set",EXTENDS:"extends",STATIC:"static",NEW:"new",THIS:"this",DO:"do",WHILE:"while",FOR:"for",OF:"of",IN:"in",BREAK:"break",CONTINUE:"continue",IF:"if",ELSE:"else",SWITCH:"switch",CASE:"case",THROW:"throw",TRY:"try",CATCH:"catch",FINALLY:"finally"},Et=Object.values(yt),St=[yt.IMPORT,yt.EXPORT,yt.VAR,yt.LET,yt.CONST,yt.FUNCTION,yt.CLASS,yt.ASYNC],vt=[yt.VAR,yt.LET,yt.CONST,yt.FUNCTION,yt.CLASS,yt.USING],bt=[yt.AS,yt.ASYNC,yt.GET,yt.SET,yt.OF,yt.YIELD,yt.FROM,yt.STATIC];function Ot(e){return St.includes(e)}function At(e){return bt.includes(e)}const Tt={OPEN:it,CLOSE:nt};function Nt(e){return e===Tt.OPEN||e===Tt.CLOSE}const It=Object.values({SINGLE:"'",DOUBLE:'"',BACKTICK:"`"});function xt(e){return It.includes(e)}const Ct={ADD:"+",ARROW:"=>",ASSIGN:"=",ASSIGN_ADD:"+=",ASSIGN_BITWISE_AND:"&=",ASSIGN_BITWISE_OR:"|=",ASSIGN_BITWISE_XOR:"^=",ASSIGN_DIVIDE:"/=",ASSIGN_EXPONENTIAL:"**=",ASSIGN_LEFT_SHIFT:"<<=",ASSIGN_LOGICAL_AND:"&&=",ASSIGN_LOGICAL_OR:"||=",ASSIGN_REMAINDER:"%=",ASSIGN_MULTIPLY:"*=",ASSIGN_NULLISH:"??=",ASSIGN_RIGHT_SHIFT:">>=",ASSIGN_SUBTRACT:"-=",BITWISE_AND:"&",BITWISE_OR:"|",BITWISE_NOT:"~",BITWISE_XOR:"^",DECREMENT:"--",DIVIDE:"/",EQUAL:"==",EQUAL_STRICT:"===",EXPONENTIAL:"**",GREATER:">",GREATER_EQUAL:">=",INCREMENT:"++",LEFT_SHIFT:"<<",LESS:"<",LESS_EQUAL:"<=",LOGICAL_AND:"&&",LOGICAL_OR:"||",REMAINDER:"%",MULTIPLY:"*",NULLISH:"??",CHAINING:".",OPTIONAL_CHAINING:"?.",SPREAD:"...",NOT:"!",NOT_EQUAL:"!=",NOT_EQUAL_STRICT:"!==",RIGHT_SHIFT:">>",SUBTRACT:"-",TERNARY:"?",$BRIDGE_CHAINING_SPREAD:".."},Rt=Object.values(Ct);function Mt(e){return Rt.includes(e)}const zt={OPEN:at,CLOSE:ot};function Lt(e){return e===zt.OPEN||e===zt.CLOSE}const Pt={BOOLEAN:"boolean",COMMENT:"comment",DIVIDER:"divider",GROUP:"group",IDENTIFIER:"identifier",KEYWORD:"keyword",LIST:"list",LITERAL:"literal",NOTHING:"nothing",NUMBER:"number",OPERATOR:"operator",INDICATOR:"indicator",REGEX:"regex",SCOPE:"scope",WHITESPACE:"whitespace",NONE:"none"},kt={SPACE:" ",TAB:"\t",NEWLINE:"\n",CARRIAGE_RETURN:"\r"},$t=Object.values(kt);function Vt(e){return $t.includes(e)}class Dt{#Ie;#xe;constructor(e){this.#Ie=e,this.#xe=0}get items(){return this.#Ie}get position(){return this.#xe}get size(){return this.#Ie.length}get eol(){return this.#xe>=this.#Ie.length}get current(){return this.#Ie[this.#xe]}get next(){return this.#Ie[this.#xe+1]}get previous(){return this.#Ie[this.#xe-1]}notAtEnd(){return!1===this.eol}get(e){return this.#Ie[e]}step(e=1){return this.#xe+=e,this.current}stepBack(e=1){return this.#xe-=e,this.current}hasNext(){return this.#xe+1<this.#Ie.length}insert(...e){this.#Ie.splice(this.#xe,0,...e)}}class jt extends Dt{constructor(e){super(e.split(""))}}class Ft{#ge;#Ce;#Re;#Me;constructor(e,t,s,r){this.#ge=e,this.#Ce=t,this.#Re=s,this.#Me=r}get type(){return this.#ge}get value(){return this.#Ce}get start(){return this.#Re}get end(){return this.#Me}isType(e){return this.#ge===e}hasValue(e){return this.#Ce===e}toString(){return`${this.#Ce}`}}class Bt extends Dt{}const Ht=["true","false"];const Ut=["0","1","2","3","4","5","6","7","8","9"],Gt=[...Ut,"a","b","c","d","e","f","A","B","C","D","E","F"],qt=["0","1"];function Wt(e){return Ut.includes(e)}const _t={GENERATOR:"*",PRIVATE:"#"},Kt=Object.values(_t);class Yt{tokenize(e){const t=new jt(e),s=[];let r;for(;t.notAtEnd();){const e=this.#ze(t,r);if(void 0===e)break;e.isType(Pt.WHITESPACE)||e.isType(Pt.COMMENT)?t.step():(s.push(e),this.#Le(e)&&(r=e),t.step())}return new Bt(s)}#Le(e){return!1===[Pt.WHITESPACE,Pt.COMMENT].includes(e.type)}#ze(e,t){const s=e.current,r=e.position;if(Vt(s)){const t=e.position;return new Ft(Pt.WHITESPACE,s,r,t)}if(function(e){return et.includes(e)}(s+e.next)){const t=this.#Pe(e),s=e.position;return new Ft(Pt.COMMENT,t,r,s)}if(this.#ke(s,t)){const t=this.#$e(e),s=e.position;return new Ft(Pt.REGEX,t,r,s)}if(this.#Ve(e,t)){const t=this.#De(e),s=e.position;return new Ft(Pt.NUMBER,t,r,s)}if(xt(s)){const t=this.#je(e),s=e.position;return new Ft(Pt.LITERAL,t,r,s)}if(Mt(s)){const t=this.#Fe(e),s=e.position;return new Ft(Pt.OPERATOR,t,r,s)}if(function(e){return Kt.includes(e)}(s)){const t=this.#Fe(e),s=e.position;return new Ft(Pt.INDICATOR,t,r,s)}if(ht(s)){const t=e.position;return new Ft(Pt.DIVIDER,s,r,t)}if(wt(s)){const t=e.position;return new Ft(Pt.GROUP,s,r,t)}if(Lt(s)){const t=e.position;return new Ft(Pt.SCOPE,s,r,t)}if(Nt(s)){const t=e.position;return new Ft(Pt.LIST,s,r,t)}if(ft(s))return;const i=this.#Be(e),n=e.position;return function(e){return Et.includes(e)}(i)?new Ft(Pt.KEYWORD,i,r,n):function(e){return Ht.includes(e)}(i)?new Ft(Pt.BOOLEAN,i,r,n):function(e){return pt.includes(e)}(i)?new Ft(Pt.NOTHING,i,r,n):new Ft(Pt.IDENTIFIER,i,r,n)}#Pe(e){const t=e.current+e.next===Ze.MULTI_START,s=t?Ze.MULTI_END:kt.NEWLINE;let r=t?Ze.MULTI_START:Ze.SINGLE;for(e.step(2);e.notAtEnd();){const i=e.current;if((t?i+e.next:i)===s){e.step(s.length-1);break}r+=i,e.step()}return t?r+Ze.MULTI_END:r.trim()}#ke(e,t){return e===Ct.DIVIDE&&(void 0===t||([Pt.OPERATOR,Pt.DIVIDER,Pt.KEYWORD].includes(t.type)||[gt.OPEN,Tt.OPEN].includes(t.value)))}#He(e){return Vt(e)||e==tt||!1===this.#Ue(e)}#$e(e){let t=e.current,s=!1;for(e.step();e.notAtEnd();){const r=e.current,i=e.previous;if(r===Ct.DIVIDE&&"\\"!==i)s=!0;else if(!0===s&&this.#He(r)){e.stepBack();break}t+=r,e.step()}return t}#Ve(e,t){const s=e.current,r=e.next;return!!Wt(s)||s===Ct.SUBTRACT&&(!t?.isType(Pt.NUMBER)&&Wt(r))}#Ge(e,t,s){return t?!1===(r=e,Gt.includes(r))&&e!==ct:s?!1===function(e){return qt.includes(e)}(e)&&e!==ct:!1===Wt(e)&&e!==tt&&e!==ct&&"e"!==e;var r}#De(e){let t=e.current;t===Ct.SUBTRACT&&(t+=e.step()),e.step();const s="x"===e.current,r="b"===e.current;for((s||r)&&(t+=e.current,e.step());e.notAtEnd();){const i=e.current;if(this.#Ge(i,s,r)){e.stepBack();break}t+=i,e.step()}return t}#je(e){const t=e.current;let s=t,r=!1;for(e.step();e.notAtEnd();){const i=e.current;if(!1===r){if(i===t){s+=i;break}"\\"===i&&(r=!0)}else r=!1;s+=i,e.step()}return s}#Ue(e){return!1===(ft(e)||Vt(e)||Mt(e)||xt(e)||ht(e)||wt(e)||Lt(e)||Nt(e))}#Be(e){let t="";for(;e.notAtEnd();){const s=e.current;if(!1===this.#Ue(s)){e.stepBack();break}t+=s,e.step()}return t}#Fe(e){let t=e.current;for(e.step();e.notAtEnd();){const s=e.current;if(!1===Mt(s)||!1===Mt(t+s)){e.stepBack();break}t+=s,e.step()}return t}}class Xt extends Error{constructor(e,t){super(`Expected keyword '${e}' at position ${t}`)}}class Jt extends Error{constructor(e,t){super(`Expected token '${e}' at position ${t}`)}}class Qt extends Error{constructor(e,t){super(`Unexpected keyword '${e}' at position ${t}`)}}class Zt extends Error{constructor(e){super(`The given code does not contain ${e}`)}}class es extends Error{constructor(e,t){super(`Unexpected token '${e}' at position ${t}`)}}const ts=new Ft(Pt.NONE,"",-1,0);class ss{#qe;constructor(e=[]){this.#qe=e}get tokens(){return this.#qe}append(...e){this.#qe.push(...e)}merge(e){this.append(...e.tokens)}generate(){let e="";for(let t=0;t<this.#qe.length;t++){const s=this.#qe[t-1]??ts,r=this.#qe[t],i=this.#qe[t+1]??ts,n=this.#We(s,r)?" ":"",a=this.#_e(r,i)?" ":"";e+=`${n}${r.value}${a}`}return e}#We(e,t){return!(!t.isType(Pt.KEYWORD)||!this.#Ke(e))||!(!t.isType(Pt.OPERATOR)||!e.isType(Pt.OPERATOR))}#_e(e,t){return e.isType(Pt.KEYWORD)&&(t.isType(Pt.KEYWORD)||this.#Ke(t))}#Ke(e){return e.isType(Pt.IDENTIFIER)||e.isType(Pt.BOOLEAN)||e.isType(Pt.NOTHING)||e.isType(Pt.NUMBER)}}const rs="default";class is{#Ye;constructor(e=new Yt){this.#Ye=e}parse(e){const t=this.#Ye.tokenize(e),s=this.#Xe(t);return new Xe(s)}parseStatement(e){const t=this.#Ye.tokenize(e),s=this.#Je(t);if(void 0===s)throw new Zt("a statement");return s}parseImport(e){const t=this.#Ye.tokenize(e),s=this.#Qe(t);if(s instanceof Ke==!1)throw new Zt("an import definition");return s}parseExport(e){const t=this.#Ye.tokenize(e),s=this.#Qe(t);if(s instanceof Ue==!1)throw new Zt("an export definition");return s}parseVariable(e){const t=this.#Ye.tokenize(e),s=this.#Qe(t);if(s instanceof Ye==!1)throw new Zt("a variable definition");return s}parseFunction(e){const t=this.#Ye.tokenize(e),s=this.#Qe(t);if(s instanceof ze==!1)throw new Zt("a function definition");return s}parseClass(e){const t=this.#Ye.tokenize(e),s=this.#Qe(t);if(s instanceof He==!1)throw new Zt("a class definition");return s}#Xe(e){const t=[];for(;e.notAtEnd();){const s=this.#Je(e);void 0!==s&&t.push(s)}return t}#Je(e,t=!1){const s=e.current;if(this.#Ze(s))return this.#et(e);if(s.isType(Pt.IDENTIFIER)){const s=e.next;return s?.hasValue(Ct.ARROW)?this.#tt(e,t):this.#et(e)}if(s.isType(Pt.KEYWORD)){if(At(s.value)){const t=e.next,r=void 0!==t&&(t.hasValue(yt.FUNCTION)||t.hasValue(gt.OPEN));if(s.hasValue(yt.ASYNC)&&r)return e.step(),this.#Je(e,!0);if(void 0===t||this.#st(t))return this.#et(e)}return s.hasValue(yt.RETURN)?this.#et(e):!1===Ot(s.value)?this.#et(e):this.#Qe(e,t)}if(s.isType(Pt.REGEX))return this.#et(e);if(s.hasValue(gt.OPEN)){const s=this.#rt(e,gt.OPEN,gt.CLOSE);return s?.hasValue(Ct.ARROW)?this.#tt(e,t):this.#et(e)}if(s.hasValue(zt.OPEN))return this.#et(e);if(s.hasValue(Tt.OPEN))return this.#et(e);if(s.hasValue(Ct.NOT)||s.hasValue(Ct.SUBTRACT))return this.#et(e);if(!ht(s.value))throw new es(s.value,s.start);e.step()}#Ze(e){return e.isType(Pt.LITERAL)||e.isType(Pt.NUMBER)||e.isType(Pt.BOOLEAN)||e.isType(Pt.NOTHING)||e.hasValue(yt.NEW)}#Qe(e,t=!1){const s=e.current;switch(e.step(),s.value){case yt.IMPORT:return this.#it(e);case yt.EXPORT:return this.#nt(e);case yt.CLASS:return this.#at(e);case yt.FUNCTION:return this.#ot(e,t);case yt.VAR:return this.#ct(e,"var");case yt.LET:return this.#ct(e,"let");case yt.CONST:return this.#ct(e,"const");case yt.ASYNC:return this.#Je(e,!0);default:throw new Qt(s.value,s.start)}}#it(e){const t=[];let s=e.current;if(s.isType(Pt.LITERAL)){const e=this.#lt(s.value);return new Ke(t,e)}if(s.hasValue(gt.OPEN)){s=e.step();const r=this.#lt(s.value);return e.step(2),new Ke(t,r)}if(!1===s.hasValue(zt.OPEN)){const r=s.hasValue(Ct.MULTIPLY)?Ct.MULTIPLY:rs;let i=s.value;s=e.step(),s.hasValue(yt.AS)&&(s=e.step(),i=s.value,s=e.step()),t.push(new Je(r,i))}if(s.hasValue(lt.SEPARATOR)&&(s=e.step()),s.hasValue(zt.OPEN)){const r=this.#ut(e);t.push(...r),s=e.current}if(!1===s.hasValue(yt.FROM))throw new Xt(yt.FROM,s.start);s=e.step();const r=this.#lt(s.value);return e.step(),new Ke(t,r)}#nt(e){switch(e.current.value){case yt.DEFAULT:return e.step(),this.#ht(e,!0);case zt.OPEN:return this.#dt(e);default:return this.#ht(e,!1)}}#ht(e,t){let s=e.current,r=0;if(t&&this.#pt(e)){const t=`$_EXPORT_${s.start}_${s.end}`;e.insert(new Ft(Pt.KEYWORD,yt.CONST,0,0),new Ft(Pt.IDENTIFIER,t,0,0),new Ft(Pt.OPERATOR,Ct.ASSIGN,0,0)),s=e.current}var i;s.hasValue(yt.ASYNC)&&(s=e.step(),r++),i=s.value,vt.includes(i)&&(s=e.step(),r++);const n=this.#Ue(s)?s.value:"",a=t?rs:void 0;let o;s=e.step(),s?.hasValue(yt.FROM)&&(s=e.step(),o=this.#lt(s.value)),r>0&&(r++,e.stepBack(r));const c=new Je(n,a);return new Ue([c],o)}#pt(e){const t=e.current;if(this.#Ze(t))return!0;const s=e.next;return this.#Ue(t)&&s?.hasValue(gt.OPEN)}#dt(e){const t=this.#ut(e);let s,r=e.current;return r?.hasValue(yt.FROM)&&(r=e.step(),s=this.#lt(r.value)),e.step(),new Ue(t,s)}#lt(e){return e.slice(1,-1)}#ut(e){const t=[];let s=e.step();for(;e.notAtEnd();){if(s.hasValue(zt.CLOSE)){e.step();break}if(s.hasValue(lt.SEPARATOR)){s=e.step();continue}const r=this.#mt(e);t.push(r),s=e.step()}return t}#mt(e){let t=e.current;const s=t.value;let r;return e.next.hasValue(yt.AS)&&(t=e.step(2),r=t.value),new Je(s,r)}#ct(e,t){const s=this.#ft(e),r=this.#gt(e);return new Ye(t,s,r)}#ft(e){const t=e.current;return t.hasValue(Tt.OPEN)?this.#wt(e):t.hasValue(zt.OPEN)?this.#yt(e):this.#Et(e)}#wt(e){const t=this.#St(e,Tt.CLOSE);return new Ce(t)}#yt(e){const t=this.#St(e,zt.CLOSE);return new Qe(t)}#St(e,t){const s=[];for(e.step();e.notAtEnd();){const r=e.current;if(r.hasValue(t)){e.step();break}if(r.hasValue(lt.SEPARATOR)){e.step();continue}const i=this.#ft(e),n=this.#gt(e),a=new Pe(i,n);s.push(a)}return s}#Et(e){let t=e.current,s=!1;t.hasValue(Ct.SPREAD)&&(s=!0,t=e.step());const r=t.value;return e.step(),new _e(r,s)}#gt(e){const t=e.current;if(!1!==t.hasValue(Ct.ASSIGN))return e.step(),this.#Je(e,!1);t.hasValue(lt.TERMINATOR)&&e.step()}#ot(e,t){let s,r=e.current,i=!1;r.hasValue(_t.GENERATOR)&&(i=!0,r=e.step()),this.#Ue(r)&&(s=r.value,e.step());const n=this.#St(e,gt.CLOSE);if(r=e.current,!1===r.hasValue(zt.OPEN))throw new Jt(zt.OPEN,r.start);const a=this.#vt(e);return i?new qe(s,n,a,t):new ze(s,n,a,t)}#tt(e,t){let s,r,i=e.current;if(i.hasValue(gt.OPEN))s=this.#St(e,gt.CLOSE);else{const t=this.#Et(e);s=[new Pe(t,void 0)]}if(i=e.current,!1===i.hasValue(Ct.ARROW))throw new Jt(Ct.ARROW,i.start);if(i=e.step(),i.hasValue(zt.OPEN))r=this.#vt(e);else{const t=this.#et(e);r=new ke(t.code)}return new Le(s,r,t)}#at(e){let t,s,r=e.current;if(this.#Ue(r)&&(t=r.value,r=e.step()),r.hasValue(yt.EXTENDS)&&(r=e.step(),s=r.value,r=e.step()),!1===r.hasValue(zt.OPEN))throw new Jt(zt.OPEN,r.start);const i=this.#bt(e);return new He(t,s,i)}#bt(e){let t=e.step();const s=[];for(;e.notAtEnd();){if(t.hasValue(zt.CLOSE)){e.step();break}const r=this.#Ot(e);s.push(r),t=e.current}return s}#Ot(e){let t=e.current,s="public",r="instance",i=!1;for(;e.notAtEnd();){if(t.hasValue(_t.PRIVATE))s="private";else if(t.hasValue(yt.STATIC))r="static";else{if(!t.hasValue(yt.ASYNC)){if(t.hasValue(yt.CONSTRUCTOR))return this.#At(e);if(t.hasValue(yt.GET))return this.#Tt(e,r);if(t.hasValue(yt.SET))return this.#Nt(e,r);if(t.hasValue(_t.GENERATOR))return e.step(),this.#It(e,s,r,i,!0);break}i=!0}t=e.step()}return e.next.hasValue(gt.OPEN)?this.#It(e,s,r,i,!1):this.#xt(e,s,r)}#At(e){e.step();const t=this.#St(e,gt.CLOSE),s=e.current;if(!1===s.hasValue(zt.OPEN))throw new Jt(zt.OPEN,s.start);const r=this.#vt(e);return new Ve(t,r)}#Tt(e,t){let s="public",r=e.step();r.hasValue(_t.PRIVATE)&&(s="private",r=e.step());const i=r.value;e.step();if(0!==this.#St(e,gt.CLOSE).length)throw new Zt("an empty parameter list");if(r=e.current,!1===r.hasValue(zt.OPEN))throw new Jt(zt.OPEN,r.start);const n=this.#vt(e);return new De(i,s,t,n)}#Nt(e,t){let s="public",r=e.step();r.hasValue(_t.PRIVATE)&&(s="private",r=e.step());const i=r.value;e.step();const n=this.#St(e,gt.CLOSE);if(r=e.current,1!==n.length)throw new Zt("exactly one setter parameter");if(!1===r.hasValue(zt.OPEN))throw new Jt(zt.OPEN,r.start);const a=this.#vt(e);return new je(i,s,t,n[0],a)}#It(e,t,s,r,i){let n=e.current;const a=n.value;e.step();const o=this.#St(e,gt.CLOSE);if(n=e.current,!1===n.hasValue(zt.OPEN))throw new Jt(zt.OPEN,n.start);const c=this.#vt(e);return i?new We(a,t,s,o,c,r):new Fe(a,t,s,o,c,r)}#xt(e,t,s){const r=e.current.value;e.step();const i=this.#gt(e);return new Be(r,t,s,i)}#vt(e){const t=this.#Ct(e,zt.OPEN,zt.CLOSE).generate();return new ke(t)}#et(e){const t=new ss;let s=e.current;for(;e.notAtEnd();){if(s.hasValue(Tt.OPEN)){const r=this.#Ct(e,Tt.OPEN,Tt.CLOSE);t.merge(r),s=e.current}else if(s.hasValue(gt.OPEN)){const r=this.#Ct(e,gt.OPEN,gt.CLOSE);t.merge(r),s=e.current}else if(s.hasValue(zt.OPEN)){const r=this.#Ct(e,zt.OPEN,zt.CLOSE);t.merge(r),s=e.current}else t.append(s),s=e.step();if(void 0===s)break;if(this.#st(s)){s.hasValue(lt.TERMINATOR)&&e.step();break}}const r=t.generate();return new Ge(r)}#Ct(e,t,s){let r=e.current;const i=new ss([r]);for(r=e.step();e.notAtEnd();){if(r.hasValue(t)){const n=this.#Ct(e,t,s);i.merge(n),r=e.current;continue}if(r.hasValue(s))return e.step(),i.append(r),i;i.append(r),r=e.step()}return i}#rt(e,t,s){const r=e.position;this.#Ct(e,t,s);const i=e.current,n=e.position;return e.stepBack(n-r),i}#st(e){return[lt.TERMINATOR,lt.SEPARATOR].includes(e.value)||[Tt.CLOSE,gt.CLOSE,zt.CLOSE].includes(e.value)||Ot(e.value)}#Ue(e){return e.isType(Pt.IDENTIFIER)||e.isType(Pt.KEYWORD)&&At(e.value)}}class ns{merge(e,t){const s=void 0!==e.construct?[e.construct]:[],r=[...this.#Rt(e.fields,t.fields),...s,...this.#Rt(e.methods,t.methods),...this.#Rt(e.getters,t.getters),...this.#Rt(e.setters,t.setters)];return new He(e.identifier,t.identifier,r)}#Rt(e,t){const s=new Map;return t.forEach(e=>s.set(e.identifier,e)),e.forEach(e=>s.set(e.identifier,e)),[...s.values()]}}class as{#Mt=new is;#zt=new ns;fromModule(e,t=!1){const s=Object.entries(e),r=[];for(const[e,i]of s){if("function"!=typeof i.toString)continue;const s=i.toString();if(s.startsWith("class"))r.push(this.fromClass(i,t));else if(s.startsWith("function"))r.push(this.fromFunction(i));else{const t=new _e(e,!1),i=new Ge(s);r.push(new Ye("var",t,i))}}return new Xe(r)}fromClass(e,t=!1){const s=this.isClass(e)?this.#Lt(e):this.#Pt(e);if(!1===t)return s;const r=this.getParentClass(e);if(""===r.name)return s;const i=this.fromClass(r,!0);return this.#zt.merge(s,i)}fromObject(e,t=!0){const s=this.getClass(e);return this.fromClass(s,t)}fromFunction(e){const t=e.toString();return this.#Mt.parseFunction(t)}createInstance(e,t=[]){return new e(...t)}getClass(e){return e.constructor}getParentClass(e){return Object.getPrototypeOf(e)}isClassObject(e){return this.isClass(e.constructor)}isFunctionObject(e){return this.isFunction(e.constructor)}isClass(e){return e.toString().startsWith("class")}isFunction(e){return e.toString().startsWith("function")||e.toString().startsWith("async function")}#Lt(e){const t=e.toString();return this.#Mt.parseClass(t)}#Pt(e){const t=this.createInstance(e),s=this.#kt(e,t);return new He(e.name,void 0,s)}#kt(e,t){return[...this.#$t(t),...this.#Vt(e)]}#$t(e){const t=Object.getOwnPropertyNames(e),s=e,r=[];for(const e of t){const t=s[e],i=void 0!==t?new Ge(String(t)):void 0,n=new Be(e,"public","instance",i);r.push(n)}return r}#Vt(e){const t=Object.getOwnPropertyDescriptors(e.prototype),s=[];for(const e in t){const r=t[e],i=r.value;if(i instanceof Function==!1)continue;const n=this.fromFunction(i);"constructor"===n.identifier?s.push(new Ve(n.parameters,n.body)):void 0!==r.get?s.push(new De(n.identifier,"public","instance",n.body)):void 0!==r.set?s.push(new je(n.identifier,"public","instance",n.parameters[0],n.body)):s.push(new Fe(n.identifier,"public","instance",n.parameters,n.body,n.isAsync))}return s}}const os=new as;class cs extends be{#Dt;constructor(e){super(),this.#Dt=e}canSerialize(e){return e instanceof Object&&os.isClassObject(e)}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"class"===t.name&&"string"==typeof t.key&&t.args instanceof Object&&t.args.constructor===Object&&t.fields instanceof Object&&t.fields.constructor===Object}async serialize(e){const t=os.getClass(e),s=os.fromClass(t,!0),r=this.#jt(s),i=this.#Dt.resolveKey(t);if(void 0===i)throw new ge(t.name);return{serialized:!0,key:i,name:"class",args:await this.#Ft(s,r,e),fields:await this.#Bt(s,r,e)}}#jt(e){const t=e.construct;return(t?.parameters??[]).map(e=>e.binding.identifier)}async#Ft(e,t,s){const r={};for(const[i,n]of t.entries()){const t=e.canRead(n)?await this.serializeOther(s[n]):void 0;r[i.toString()]=t}return r}async#Bt(e,t,s){const r={};for(const i of e.writable){const n=i.identifier;t.includes(n)||!1===e.canRead(n)||(r[n]=await this.serializeOther(s[n]))}return r}async deserialize(e){const t=await this.#Ht(e);if(void 0===t)throw new ge(e.key);if(t instanceof Function==!1)throw new we(e.key);const s=await this.#Ut(t,e.args),r=os.createInstance(t,s);for(const t in e.fields){const s=e.fields[t];r[t]=await this.deserializeOther(s)}return r}async#Ut(e,t){const s=os.fromClass(e,!0).construct,r=(s?.parameters??[]).map((e,s)=>{const r=s.toString(),i=t[r];return this.deserializeOther(i)});return Promise.all(r)}async#Ht(e){return globalThis[e.key]??this.#Dt.resolveClass(e.key)}}class ls extends Error{constructor(e){super(`Invalid date string '${e}'`)}}class us extends be{canSerialize(e){return e instanceof Date}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Date"===t.name&&"string"==typeof t.value}async serialize(e){return{serialized:!0,name:"Date",value:e.toISOString()}}async deserialize(e){const t=new Date(e.value);if("Invalid Date"===t.toString())throw new ls(e.value);return t}}class hs extends be{canSerialize(e){if(e instanceof Object==!1)return!1;const t=e;return t.constructor===Error||t.constructor===EvalError||t.constructor===RangeError||t.constructor===ReferenceError||t.constructor===SyntaxError||t.constructor===TypeError||t.constructor===URIError||t.constructor===AggregateError}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Error"===t.name&&t.type in globalThis}async serialize(e){return{serialized:!0,name:"Error",type:e.constructor.name,stack:e.stack,message:e.message,cause:e.cause}}async deserialize(e){const t=new(0,globalThis[e.type])(e.message,{cause:e.cause});return t.stack=e.stack,t}}class ds extends be{canSerialize(e){return e instanceof Map}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Map"===t.name&&t.entries instanceof Object&&t.entries.keys instanceof Array&&t.entries.values instanceof Array}async serialize(e){const t=[],s=[];for(const[r,i]of e)t.push(await this.serializeOther(r)),s.push(await this.serializeOther(i));return{serialized:!0,name:"Map",entries:{keys:t,values:s}}}async deserialize(e){const t=e.entries.keys,s=e.entries.values,r=new Map;for(let e=0;e<t.length;e++){const i=await this.deserializeOther(t[e]),n=await this.deserializeOther(s[e]);r.set(i,n)}return r}}class ps extends be{canSerialize(e){return e instanceof Object&&e.constructor===Object}canDeserialize(e){return e instanceof Object&&e.constructor===Object}async serialize(e){const t={};for(const s in e){const r=e[s];t[s]=await this.serializeOther(r)}return t}async deserialize(e){const t={};for(const s in e){const r=e[s];t[s]=await this.deserializeOther(r)}return t}}class ms extends be{canSerialize(e){return e instanceof Object==!1}canDeserialize(e){return e instanceof Object==!1}async serialize(e){return e}async deserialize(e){return e}}class fs extends Error{constructor(e,t){super(`Invalid regular expression '${e}' with flags '${t}'`)}}class gs extends be{canSerialize(e){return e instanceof RegExp}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"RegExp"===t.name&&"string"==typeof t.source&&"string"==typeof t.flags}async serialize(e){return{serialized:!0,name:"RegExp",source:e.source,flags:e.flags}}async deserialize(e){try{return new RegExp(e.source,e.flags)}catch{throw new fs(e.source,e.flags)}}}class ws extends be{canSerialize(e){return e instanceof Set}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Set"===t.name&&t.values instanceof Array}async serialize(e){const t=[];for(const s of e.values())t.push(await this.serializeOther(s));return{serialized:!0,name:"Set",values:t}}async deserialize(e){const t=await Promise.all(e.values.map(async e=>this.deserializeOther(e)));return new Set([...t])}}const ys=new as;class Es extends be{canSerialize(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof BigInt64Array||e instanceof BigUint64Array}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"TypedArray"===t.name&&t.type in globalThis&&t.bytes instanceof Array}async serialize(e){const t=e.constructor.name,s=new DataView(e.buffer),r=[];for(let e=0;e<s.byteLength;e++)r.push(s.getUint8(e));return{serialized:!0,name:"TypedArray",type:t,bytes:r}}async deserialize(e){const t=e.type,s=e.bytes,r=new ArrayBuffer(s.length),i=new DataView(r);for(let e=0;e<s.length;e++)i.setUint8(e,s[e]);const n=globalThis[t];return ys.createInstance(n,[r])}}class Ss extends Error{constructor(e){super(`Invalid url string '${e}'`)}}class vs extends be{canSerialize(e){return e instanceof URL}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Url"===t.name&&"string"==typeof t.value}async serialize(e){return{serialized:!0,name:"Url",value:e.toString()}}async deserialize(e){try{return new URL(e.value)}catch{throw new Ss(e.value)}}}class bs{static build(e){const t=new Se;return t.addSerializer(new ms),t.addSerializer(new ps),void 0!==e&&t.addSerializer(new cs(e)),t.addSerializer(new hs),t.addSerializer(new gs),t.addSerializer(new Te),t.addSerializer(new vs),t.addSerializer(new us),t.addSerializer(new ws),t.addSerializer(new ds),t.addSerializer(new Oe),t.addSerializer(new Es),"undefined"!=typeof Buffer&&t.addSerializer(new Ie),t}}class Os{#Gt;constructor(e){this.#Gt=e}resolveKey(e){const t=this.#Gt.getClassByImplementation(e);return t?.fqn}resolveClass(e){const t=this.#Gt.getClass(e);return t?.implementation}}class As extends o{constructor(){super("Request not trusted")}}const Ts="X-Jitar-Trust-Key",Ns="X-Jitar-Data-Encoding",Is="serialized";class xs{#s;#he;#qt;#Wt;#_t;#Gt;#Kt;#Yt;#Xt;#pe=new te;constructor(e){this.#he=e.url,this.#qt=e.trustKey,this.#Wt=e.gateway,this.#_t=!0===e.registerAtGateway,this.#Gt=e.executionManager,this.#Kt=e.healthManager;const t=e.scheduleManager;this.#Yt=t.create(()=>this.#Jt(),e.reportInterval);const s=new Os(this.#Gt);this.#Xt=bs.build(s)}get id(){return this.#s}set id(e){this.#s=e}get state(){return this.#pe.state}get url(){return this.#he}get trustKey(){return this.#qt}async start(){return this.#pe.start(async()=>{await Promise.all([this.#Gt.start(),this.#Kt.start()]),void 0!==this.#Wt&&(await this.#Wt.start(),this.#_t&&(this.#s=await this.#Wt.addWorker(this),this.#Yt.start())),await this.updateState()})}async stop(){return this.#pe.stop(async()=>{void 0!==this.#Wt&&(void 0!==this.#s&&(this.#Yt.stop(),await this.#Wt.removeWorker(this.#s)),await this.#Wt.stop()),await Promise.all([this.#Kt.stop(),this.#Gt.stop()])})}getProcedureNames(){return this.#Gt.getProcedureNames()}hasProcedure(e){return this.#Gt.hasProcedure(e)}isHealthy(){return this.#Kt.isHealthy()}getHealth(){return this.#Kt.getHealth()}isAvailable(){return this.#pe.isAvailable()}async updateState(){const e=await this.isHealthy();return this.#pe.setAvailability(e)}async reportState(e){if(void 0!==this.#Wt&&void 0!==this.#s)return this.#Wt.reportWorker(this.#s,e)}async run(e){return this.#Qt(e)?this.#Zt(e):this.#es(e)}#Qt(e){return void 0===this.#Wt||this.#Gt.hasProcedure(e.fqn)}async#Zt(e){const t=this.#Gt.getProcedure(e.fqn),s=t?.getImplementation(e.version);if(this.#ts(s))throw new O(e.fqn);if(this.#ss(e,s))throw new As;const r=e.getHeader(Ns);r===Is&&(e=await this.#rs(e)),e.removeHeader(Ns);const i=await this.#Gt.run(e);return r===Is?this.#is(i):i}#ts(e){return void 0===e||e.private}#ss(e,t){if(t.public)return!1;const s=e.getHeader(Ts);return this.#qt!==s}async#es(e){(e=await this.#ns(e)).setHeader(Ns,Is),void 0!==this.#qt&&e.setHeader(Ts,this.#qt);const t=await this.#Wt.run(e);return this.#as(t)}async#ns(e){const t=new Map;for(const[s,r]of e.args){const e=await this.#Xt.serialize(r);t.set(s,e)}return new k(e.fqn,e.version,t,e.headers,e.mode)}async#rs(e){const t=new Map;for(const[s,r]of e.args){const e=await this.#Xt.deserialize(r);t.set(s,e)}return new k(e.fqn,e.version,t,e.headers,e.mode)}async#is(e){const t=await this.#Xt.serialize(e.result);return new $(e.status,t,e.headers)}async#as(e){const t=await this.#Xt.deserialize(e.result);return new $(e.status,t,e.headers)}async#Jt(){const e=await this.updateState();return this.reportState(e)}}class Cs{#K;constructor(e){this.#K=e}async handle(e,t){return this.#K.run(e)}}class Rs{#os=new U;constructor(){this.#cs()}#cs(){const e=globalThis;e.__run=this.#ls.bind(this),e.ProcedureNotAccessible=A}async#ls(e,t,s,r){const i=this.#os.parse(t),n=new Map(Object.entries(s)),a=r instanceof k?r.headers:new Map,o=new k(e,i,n,a,h),c=this.getTrustKey();void 0!==c&&o.setHeader("X-Jitar-Trust-Key",c);const l=await this.runInternal(o);if(l.status!==p)throw l.result;return l.result}}class Ms extends Rs{#us;#hs;#ds=new Y(this);constructor(e){super(),this.#us=new xs({url:e.remoteUrl,gateway:new se({url:e.remoteUrl,remote:e.remote}),healthManager:e.healthManager,executionManager:e.executionManager,scheduleManager:e.scheduleManager}),this.#hs=e.middlewareManager}get worker(){return this.#us}async start(){await this.#ps(),this.#ds.start()}async stop(){this.#ds.stop(),await this.#ms()}getTrustKey(){}run(e){return this.#hs.handle(e)}async runInternal(e){return this.#ds.run(e)}async#ps(){await Promise.all([this.#us.start(),this.#hs.start()]);const e=new Cs(this.#us);this.#hs.addMiddleware(e)}async#ms(){await Promise.all([this.#hs.stop(),this.#us.stop()])}}const zs="starting",Ls="started",Ps="stopping",ks="stopped";class $s extends n{constructor(){super("Invalid health check")}}class Vs{#ce=ks;#fs=new Map;#j;#gs;constructor(e,t=[]){this.#j=e,this.#gs=t}get state(){return this.#ce}async start(){if(this.#ce===ks)try{this.#ce=zs,await this.#ws(),this.#ce=Ls}catch(e){throw this.#ce=ks,e}}async stop(){if(this.#ce===Ls)try{this.#ce=Ps,this.clearHealthChecks(),this.#ce=ks}catch(e){throw this.#ce=Ls,e}}async loadHealthCheck(e){const t=await this.#ys(e);this.addHealthCheck(t)}addHealthCheck(e){if(void 0===e.isHealthy)throw new $s;this.#fs.set(e.name,e)}clearHealthChecks(){this.#fs.clear()}async isHealthy(){const e=[];for(const t of this.#fs.values()){const s=this.#Es(t);e.push(s)}return Promise.all(e).then(e=>e.every(e=>e)).catch(()=>!1)}async getHealth(){const e=[];for(const[t,s]of this.#fs){const r=this.#Es(s).then(e=>({name:t,isHealthy:e})).catch(()=>({name:t,isHealthy:!1}));e.push(r)}const t=new Map;return Promise.allSettled(e).then(e=>e.forEach(e=>this.#Ss(e,t))).then(()=>t)}async#ws(){(await Promise.all(this.#gs.map(e=>this.#ys(e)))).forEach(e=>this.addHealthCheck(e))}async#ys(e){return(await this.#j.import(e)).default}#Ss(e,t){"fulfilled"===e.status?t.set(e.value.name,e.value.isHealthy):t.set(e.reason.name,!1)}async#Es(e){const t=e.isHealthy(),s=e.timeout;if(void 0===s)return t;const r=new Promise(e=>{setTimeout(e,s)}).then(()=>!1);return Promise.race([r,t])}}const Ds=0,js=1,Fs=2,Bs=3;class Hs{#vs;#bs;constructor(e=js,t=console){this.#vs=e,this.#bs=t}debug(...e){if(this.#vs>Ds)return;const t=this.#Os("DEBUG",e);this.#bs.debug(t)}info(...e){if(this.#vs>js)return;const t=this.#Os("INFO",e);this.#bs.info(t)}warn(...e){if(this.#vs>Fs)return;const t=this.#Os("WARN",e);this.#bs.warn(t)}error(...e){if(this.#vs>Bs)return;const t=this.#Os("ERROR",e);this.#bs.error(t)}fatal(...e){const t=this.#Os("FATAL",e);this.#bs.error(t)}#Os(e,t){return`[${e}][${(new Date).toISOString()}] ${t.map(e=>this.#As(e)).join(" ")}`}#As(e,t=0){let s;switch(typeof e){case"string":s=e;break;case"object":s=this.#Ts(e,t+1);break;case"undefined":s="undefined";break;case"function":s="function";break;default:s=String(e)}return`${this.#Ns(t)}${s}`}#Ts(e,t){if(null===e)return"null";if(Array.isArray(e)){return`[\n${e.map(e=>this.#As(e,t)).join(",\n")}\n${this.#Ns(t-1)}]`}return e instanceof Error?e.stack??e.message:JSON.stringify(e)}#Ns(e){return" ".repeat(e)}}const Us="starting",Gs="started",qs="stopping",Ws="stopped";class _s extends n{constructor(){super("Invalid middleware")}}class Ks{#ce=Ws;#Is=[];#j;#xs;constructor(e,t=[]){this.#j=e,this.#xs=t}get state(){return this.#ce}async start(){if(this.#ce===Ws)try{this.#ce=Us,await this.#Cs(),this.#ce=Gs}catch(e){throw this.#ce=Ws,e}}async stop(){if(this.#ce===Gs)try{this.#ce=qs,this.clearMiddlewares(),this.#ce=Ws}catch(e){throw this.#ce=Gs,e}}async loadMiddleware(e){const t=await this.#Rs(e);this.addMiddleware(t)}addMiddleware(e){if(void 0===e?.handle)throw new _s;this.#Is.push(e)}getMiddleware(e){return this.#Is.find(t=>t instanceof e)}clearMiddlewares(){this.#Is=[]}handle(e){return this.#Ms(e,0)()}async#Cs(){(await Promise.all(this.#xs.map(e=>this.#Rs(e)))).forEach(e=>this.addMiddleware(e))}async#Rs(e){return(await this.#j.import(e)).default}#Ms(e,t){const s=this.#Is[t];if(void 0===s)return async()=>new $(p);const r=this.#Ms(e,t+1);return async()=>await s.handle(e,r)}}class Ys{#zs;#Ls;#Ps;#ks=null;constructor(e,t,s=5e3){this.#zs=e,this.#Ls=t,this.#Ps=s}start(){this.#$s()}stop(){null!==this.#ks&&(clearTimeout(this.#ks),this.#ks=null)}#$s(){this.#ks=setTimeout(async()=>{null!==this.#ks&&(await this.#Vs(),this.#$s())},this.#Ps),this.#ks.unref()}async#Vs(){try{await this.#Ls()}catch(e){this.#zs.warn("Scheduled task failed",e)}}}class Xs{#Ds=[];#zs;constructor(e){this.#zs=e}create(e,t){const s=new Ys(this.#zs,e,t);return this.#Ds.push(s),s}remove(e){const t=this.#Ds.indexOf(e);t<0||this.#Ds.splice(t,1)}startAll(){this.#Ds.forEach(e=>e.start())}stopAll(){this.#Ds.forEach(e=>e.stop())}}class Js{#js;constructor(e){this.#js=e}build(e){const t=e.remoteUrl,s=e.middleware,r=e.segments,i=new Hs(e.logLevel??Fs),n=this.#js.build(t),a=new fe(t),o=this.#Fs(a),c=this.#Bs(a,s),l=this.#Hs(a,r),u=this.#Us(i);return new Ms({remoteUrl:t,remote:n,healthManager:o,middlewareManager:c,executionManager:l,scheduleManager:u})}#Fs(e){return new Vs(e)}#Bs(e,t=[]){const s=new Ks(e);return t.forEach(e=>s.addMiddleware(e)),s}#Hs(e,t=[]){const s=new _(e);return t.forEach(e=>s.addSegment(e)),s}#Us(e){return new Xs(e)}}class Qs{#Gs;constructor(e=!0){this.#Gs=e}validate(e,t){const s=[];this.#qs("",e,t,s);return{valid:0===s.length,errors:s}}#qs(e,t,s,r){this.#Gs&&this.#Ws(e,t,s,r),this.#_s(e,t,s,r)}#Ws(e,t,s,r){const i=Object.keys(t),n=Object.keys(s);for(const t of i)if(!1===n.includes(t)){const s=this.#Ks(e,t);r.push(`Unknown field '${s}'`)}}#_s(e,t,s,r){const i=Object.keys(s);for(const n of i){const i=this.#Ks(e,n),a=s[n],o=t[n];this.#Ys(i,o,a,r)}}#Ys(e,t,s,r){if(void 0!==t)switch(s.type){case"string":return this.#Xs(e,t,s,r);case"integer":return this.#Js(e,t,s,r);case"real":return this.#Qs(e,t,s,r);case"boolean":return this.#Zs(e,t,s,r);case"url":return this.#er(e,t,s,r);case"group":return this.#tr(e,t,s,r);case"list":return this.#sr(e,t,s,r)}else!0===s.required&&r.push(`Field '${e}' is required`)}#Xs(e,t,s,r){"string"!=typeof t&&r.push(`Field '${e}' is not a string`)}#Js(e,t,s,r){"number"==typeof t&&!1!==Number.isInteger(t)||r.push(`Field '${e}' is not an integer`)}#Qs(e,t,s,r){"number"!=typeof t&&r.push(`Field '${e}' is not a real number`)}#Zs(e,t,s,r){"boolean"!=typeof t&&r.push(`Field '${e}' is not a boolean`)}#er(e,t,s,r){"string"==typeof t&&!1!==t.startsWith("http")||r.push(`Field '${e}' is not a valid URL`)}#tr(e,t,s,r){"object"==typeof t?this.#qs(e,t,s.fields,r):r.push(`Field '${e}' is not an object`)}#sr(e,t,s,r){if(!Array.isArray(t))return void r.push(`Field '${e}' is not a list`);const i=t;for(const t in i){const n=this.#Ks(e,t),a=i[t];this.#Ys(n,a,s.items,r)}}#Ks(e,t){return""===e?t:`${e}.${t}`}}const Zs="content-type",er="x-jitar-content-type",tr="x-jitar-procedure-version",sr="application/json",rr="application/octet-stream";class ir extends Error{constructor(){super("Invalid worker id")}}class nr{#he;#rr;#H=new B;#ir=new Qs;constructor(e,t){this.#he=e,this.#rr=t}connect(){return Promise.resolve()}disconnect(){return Promise.resolve()}async provide(e){const t=`${this.#he}/${e}`,s=await this.#nr(t,{method:"GET"}),r=s.headers.get(Zs)??rr,i=await s.arrayBuffer(),n=Buffer.from(i);return new ne(e,r,n)}async isHealthy(){const e=`${this.#he}/health/status`,t=await this.#nr(e,{method:"GET"});return"true"===await t.text()}async getHealth(){const e=`${this.#he}/health`,t=await this.#nr(e,{method:"GET"}),s=await t.json();return new Map(Object.entries(s))}async addWorker(e,t,s){const r=`${this.#he}/workers`,i={url:e,procedureNames:t,trustKey:s},n={method:"POST",headers:{"Content-Type":sr},body:JSON.stringify(i)},a=await this.#nr(r,n),o=a.headers.get(Zs);if(null===o||!1===o.includes(sr))throw new ir;const c=await a.json();if(!1===this.#ir.validate(c,{id:{type:"string",required:!0}}).valid)throw new ir;return c.id}async reportWorker(e,t){const s=`${this.#he}/workers/${e}/report`,r={state:t},i={method:"POST",headers:{"Content-Type":sr},body:JSON.stringify(r)};await this.#nr(s,i)}async removeWorker(e){const t=`${this.#he}/workers/${e}`,s={method:"DELETE",headers:{"Content-Type":sr}};await this.#nr(t,s)}async run(e){e.setHeader(Zs,sr);const t=Object.fromEntries(e.args),s=Object.fromEntries(e.headers),r=e.version.toString();s[tr]=r;const i=`${this.#he}/rpc/${e.fqn}`,n={method:"POST",redirect:"manual",headers:s,body:await this.#ar(t)},a=await this.#nr(i,n,!1),o=a.status,c=await this.#or(a),l=this.#cr(a);return new $(o,c,l)}async#nr(e,t,s=!0){const r=await this.#rr.execute(e,t);if(s&&this.#lr(r)){const e=await this.#or(r);throw this.#H.fromStatus(r.status,String(e))}return r}#lr(e){return e.status<200||e.status>399}async#ar(e){return JSON.stringify(e)}async#or(e){const t=e.headers.get(er)??e.headers.get(Zs);if(t?.includes("undefined"))return;if(t?.includes("null"))return null;if(t?.includes("json"))return e.json();const s=await e.text();return t?.includes("boolean")?"true"===s:t?.includes("number")?Number(s):s}#cr(e){const t=new Map;for(const[s,r]of e.headers)t.set(s,r);return t}}class ar{async execute(e,t){return fetch(e,t)}}class or{#rr;constructor(e=new ar){this.#rr=e}build(e){return new nr(e,this.#rr)}}export{L as ArrayParameter,e as BadRequest,N as Class,Js as ClientBuilder,t as Forbidden,or as HttpRemoteBuilder,C as Implementation,M as NamedParameter,s as NotFound,r as NotImplemented,P as ObjectParameter,i as PaymentRequired,x as Procedure,k as Request,$ as Response,T as Segment,n as ServerError,a as Teapot,o as Unauthorized,I as Version};
|
package/dist/lib.d.ts
CHANGED
|
@@ -1,3 +1,78 @@
|
|
|
1
|
+
type RuntimeConfiguration = {
|
|
2
|
+
source: string;
|
|
3
|
+
target: string;
|
|
4
|
+
segments: string;
|
|
5
|
+
resources: string;
|
|
6
|
+
meta: {
|
|
7
|
+
root: string;
|
|
8
|
+
configFile: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type GatewayConfiguration = {
|
|
13
|
+
monitorInterval?: number;
|
|
14
|
+
trustKey?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type ProxyConfiguration = {
|
|
18
|
+
gateway: string;
|
|
19
|
+
repository: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type RepositoryConfiguration = {
|
|
23
|
+
indexFilename?: string;
|
|
24
|
+
serveIndexOnNotFound?: boolean;
|
|
25
|
+
assetRoot?: string;
|
|
26
|
+
assets?: string[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type WorkerConfiguration = {
|
|
30
|
+
gateway?: string;
|
|
31
|
+
segments: string[];
|
|
32
|
+
trustKey?: string;
|
|
33
|
+
reportInterval?: number;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type StandaloneConfiguration = RepositoryConfiguration & Pick<WorkerConfiguration, 'segments'>;
|
|
37
|
+
|
|
38
|
+
type RemoteWorkerConfiguration = {
|
|
39
|
+
unavailableThreshold?: number;
|
|
40
|
+
stoppedThreshold?: number;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type ServerConfiguration = {
|
|
44
|
+
url: string;
|
|
45
|
+
setUp?: string[];
|
|
46
|
+
tearDown?: string[];
|
|
47
|
+
middleware?: string[];
|
|
48
|
+
healthChecks?: string[];
|
|
49
|
+
gateway?: GatewayConfiguration;
|
|
50
|
+
proxy?: ProxyConfiguration;
|
|
51
|
+
repository?: RepositoryConfiguration;
|
|
52
|
+
standalone?: StandaloneConfiguration;
|
|
53
|
+
worker?: WorkerConfiguration;
|
|
54
|
+
remoteWorker?: RemoteWorkerConfiguration;
|
|
55
|
+
meta: {
|
|
56
|
+
root: string;
|
|
57
|
+
configFile: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
declare class ConfigurationManager {
|
|
62
|
+
#private;
|
|
63
|
+
constructor(rootPath?: string);
|
|
64
|
+
configureEnvironment(filename?: string): Promise<void>;
|
|
65
|
+
getRuntimeConfiguration(filename?: string): Promise<RuntimeConfiguration>;
|
|
66
|
+
getServerConfiguration(filename: string): Promise<ServerConfiguration>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare class BuildHelper {
|
|
70
|
+
#private;
|
|
71
|
+
constructor(configuration: RuntimeConfiguration);
|
|
72
|
+
readApplication(): Promise<void>;
|
|
73
|
+
generateModuleCode(filename: string, segmentNames?: string[]): string;
|
|
74
|
+
}
|
|
75
|
+
|
|
1
76
|
declare class BadRequest extends Error {
|
|
2
77
|
constructor(message?: string);
|
|
3
78
|
}
|
|
@@ -168,5 +243,5 @@ interface HealthCheck {
|
|
|
168
243
|
isHealthy(): Promise<boolean>;
|
|
169
244
|
}
|
|
170
245
|
|
|
171
|
-
export { ArrayParameter, BadRequest, Class, Forbidden, Implementation, NamedParameter, NotFound, NotImplemented, ObjectParameter, PaymentRequired, Procedure, Request, Response, Segment, ServerError, Teapot, Unauthorized, Version };
|
|
246
|
+
export { ArrayParameter, BadRequest, BuildHelper, Class, ConfigurationManager, Forbidden, Implementation, NamedParameter, NotFound, NotImplemented, ObjectParameter, PaymentRequired, Procedure, Request, Response, Segment, ServerError, Teapot, Unauthorized, Version };
|
|
172
247
|
export type { HealthCheck, Middleware, NextHandler };
|
package/dist/lib.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{V as t,
|
|
1
|
+
import{V as e,H as t,n as a,L as s,v as i,w as r,x as n,o,p}from"./ConfigurationManager-D8N-pXTY.js";export{A as ArrayParameter,B as BadRequest,C as ConfigurationManager,F as Forbidden,j as NamedParameter,N as NotFound,k as NotImplemented,O as ObjectParameter,l as PaymentRequired,G as Request,R as Response,m as Segment,S as ServerError,T as Teapot,U as Unauthorized}from"./ConfigurationManager-D8N-pXTY.js";import"node:fs";import"node:path";import"glob";import"mime-types";import"dotenv";class c{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get fqn(){return this.#e}get implementation(){return this.#t}}class u{#e;#a=new Map;#s;constructor(e){this.#e=e}get fqn(){return this.#e}get public(){return[...this.#a.values()].some(e=>e.public)}get protected(){return[...this.#a.values()].some(e=>e.protected)}addImplementation(e){return this.#a.set(e.version,e),this.#i(e)&&(this.#s=e),this}#i(e){return void 0===this.#s||e.version.greater(this.#s.version)}getImplementation(e){const t=this.#r(e);return this.#a.get(t)}#r(t){let a=e.DEFAULT;for(const e of this.#a.keys()){if(e.equals(t))return e;e.greater(t)||a.less(e)&&(a=e)}return a}}class h{#n;#o;#l;#p;constructor(e,t,a,s){this.#n=e,this.#o=t,this.#l=a,this.#p=s}get version(){return this.#n}get public(){return this.#o===t.PUBLIC}get protected(){return this.#o===t.PROTECTED}get private(){return this.#o===t.PRIVATE}get parameters(){return this.#l}get executable(){return this.#p}}class g extends Error{constructor(){super("Application not read")}}class f extends Error{constructor(e){super(`Application module not found '${e}'`)}}class d{#m=new a;#c;#u;#h;constructor(e){const t=this.#m.makePathAbsolute(e.source,e.meta.root),a=this.#m.makePathAbsolute(e.target,e.meta.root),n=this.#m.makePathAbsolute(e.resources,e.meta.root),o=this.#m.makePathAbsolute(e.segments,e.meta.root),l=new s(t),p=new s(a),m=new s(n),c=new s(o);this.#c=new i(l,p,m,c),this.#u=new r(this.#c)}async readApplication(){const e=this.#c.source,t=this.#c.resource,a=this.#c.segment,s=await e.filter(n.MODULE_PATTERN),i=await t.filter(n.RESOURCE_PATTERN),r=await a.filter(n.SEGMENT_PATTERN);this.#h=await this.#u.read(s,i,r)}generateModuleCode(e,t=[]){if(void 0===this.#h)throw new g;const a=this.#h.repository.get(e);if(void 0===a)throw new f(e);const s=this.#h.resources,i=this.#h.segmentation,r=i.getSegments(e);if(0===r.length){return new o(a,s,i).generate()}if(void 0===r.find(e=>t.includes(e.name))){return new p(a,r).generate()}return new o(a,s,i).generate()}}export{d as BuildHelper,c as Class,h as Implementation,u as Procedure,e as Version};
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "rimraf dist && tsc -p tsconfig.json && jitar build",
|
|
6
|
+
"build": "rimraf build dist && tsc -p src/tsconfig.json && jitar build",
|
|
7
7
|
"standalone": "jitar start --service=services/standalone.json",
|
|
8
8
|
"gateway": "jitar start --service=services/gateway.json",
|
|
9
9
|
"hi": "jitar start --service=services/hi.json",
|
|
10
10
|
"hello": "jitar start --service=services/hello.json"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"jitar": "^0.
|
|
13
|
+
"jitar": "^0.11.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"rimraf": "^6.1.
|
|
16
|
+
"rimraf": "^6.1.3",
|
|
17
|
+
"typescript": "5.9.3"
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
3
|
"useDefineForClassFields": true,
|
|
5
4
|
"allowJs": false,
|
|
6
5
|
"skipLibCheck": true,
|
|
7
|
-
"esModuleInterop": false,
|
|
8
6
|
"allowSyntheticDefaultImports": true,
|
|
9
7
|
"strict": true,
|
|
10
8
|
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"module": "ESNext",
|
|
12
|
-
"moduleResolution": "Node",
|
|
13
|
-
"resolveJsonModule": true,
|
|
14
9
|
"isolatedModules": true,
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
"include": ["src", "test"]
|
|
10
|
+
"target": "esnext",
|
|
11
|
+
"module": "esnext",
|
|
12
|
+
"moduleResolution": "bundler"
|
|
13
|
+
}
|
|
21
14
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jitar-react-starter",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite --config src/app/vite.config.ts",
|
|
8
|
+
"build": "npm run build-domain && npm run build-app",
|
|
9
|
+
"build-domain": "rimraf build dist && tsc -p src/tsconfig.json && jitar build",
|
|
10
|
+
"build-app": "vite build --config src/app/vite.config.ts",
|
|
11
|
+
"standalone": "jitar start --service=services/standalone.json"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"jitar": "^0.11.0",
|
|
15
|
+
"react": "^19.2.6",
|
|
16
|
+
"react-dom": "^19.2.6"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@jitar/plugin-vite": "^0.11.0",
|
|
20
|
+
"@types/node": "^24.12.4",
|
|
21
|
+
"@types/react": "^19.2.15",
|
|
22
|
+
"@types/react-dom": "^19.2.3",
|
|
23
|
+
"@vitejs/plugin-react": "^5.2.0",
|
|
24
|
+
"rimraf": "^6.1.3",
|
|
25
|
+
"typescript": "^5.9.3",
|
|
26
|
+
"vite": "^7.3.3"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import './App.css';
|
|
5
|
-
import reactLogo from '
|
|
6
|
-
import jitarLogo from '
|
|
5
|
+
import reactLogo from '../assets/react.svg';
|
|
6
|
+
import jitarLogo from '../assets/jitar.svg';
|
|
7
7
|
|
|
8
|
-
import { sayHello } from '
|
|
8
|
+
import { sayHello } from '../../domain/sayHello';
|
|
9
9
|
|
|
10
10
|
export default function App()
|
|
11
11
|
{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="77" height="47" fill="none" aria-labelledby="vite-logo-title" viewBox="0 0 77 47"><title id="vite-logo-title">Vite</title><style>.parenthesis{fill:#000}@media (prefers-color-scheme:dark){.parenthesis{fill:#fff}}</style><path fill="#9135ff" d="M40.151 45.71c-.663.844-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.493c-.92 0-1.457-1.04-.92-1.788l7.479-10.471c1.07-1.498 0-3.578-1.842-3.578H15.443c-.92 0-1.456-1.04-.92-1.788l9.696-13.576c.213-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.472c-1.07 1.497 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.087.89 1.83L40.153 45.712z"/><mask id="a" width="48" height="47" x="14" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M40.047 45.71c-.663.843-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.389c-.92 0-1.457-1.04-.92-1.788l7.479-10.472c1.07-1.497 0-3.578-1.842-3.578H15.34c-.92 0-1.456-1.04-.92-1.788l9.696-13.575c.213-.297.556-.474.92-.474H53.93c.92 0 1.456 1.04.92 1.788L47.37 13.03c-1.07 1.498 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.088.89 1.831L40.049 45.712z"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#eee6ff" rx="5.508" ry="14.704" transform="rotate(269.814 20.96 11.29)scale(-1 1)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#eee6ff" rx="10.399" ry="29.851" transform="rotate(89.814 -16.902 -8.275)scale(1 -1)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#8900ff" rx="5.508" ry="30.487" transform="rotate(89.814 -19.197 -7.127)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.928 4.177)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.738 5.52)scale(1 -1)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#eee6ff" rx="14.072" ry="22.078" transform="rotate(93.35 31.245 55.578)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx="14.592" cy="9.743" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(39.51 14.592 9.743)"/></g><g filter="url(#k)"><ellipse cx="61.728" cy="-5.321" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 61.728 -5.32)"/></g><g filter="url(#l)"><ellipse cx="55.618" cy="7.104" fill="#00c2ff" rx="5.971" ry="9.665" transform="rotate(37.892 55.618 7.104)"/></g><g filter="url(#m)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#n)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#o)"><ellipse cx="49.857" cy="30.678" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 49.857 30.678)"/></g><g filter="url(#p)"><ellipse cx="52.623" cy="33.171" fill="#00c2ff" rx="5.971" ry="15.297" transform="rotate(37.892 52.623 33.17)"/></g></g><path d="M6.919 0c-9.198 13.166-9.252 33.575 0 46.789h6.215c-9.25-13.214-9.196-33.623 0-46.789zm62.424 0h-6.215c9.198 13.166 9.252 33.575 0 46.789h6.215c9.25-13.214 9.196-33.623 0-46.789" class="parenthesis"/><defs><filter id="b" width="60.045" height="41.654" x="-5.564" y="16.92" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-40.407" y="-6.762" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="d" width="79.355" height="29.4" x="-35.435" y="2.801" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="e" width="79.579" height="29.4" x="-30.84" y="20.8" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="f" width="79.579" height="29.4" x="-29.307" y="21.949" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="g" width="74.749" height="58.852" x="29.961" y="-17.13" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="h" width="61.377" height="25.362" x="37.754" y="3.055" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="i" width="61.377" height="25.362" x="37.754" y="3.055" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="j" width="56.045" height="63.649" x="-13.43" y="-22.082" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="k" width="54.814" height="64.646" x="34.321" y="-37.644" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="l" width="33.541" height="35.313" x="38.847" y="-10.552" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="m" width="54.814" height="64.646" x="-15.081" y="6.78" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="n" width="54.814" height="64.646" x="-15.081" y="6.78" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="o" width="54.814" height="64.646" x="22.45" y="-1.645" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="p" width="39.409" height="43.623" x="32.919" y="11.36" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter></defs></svg>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import react from '@vitejs/plugin-react';
|
|
4
|
+
import jitar, { JitarConfig } from '@jitar/plugin-vite';
|
|
5
|
+
|
|
6
|
+
const jitarConfig: JitarConfig = {
|
|
7
|
+
projectRoot: '../../',
|
|
8
|
+
sourceRoot: '../',
|
|
9
|
+
jitarUrl: 'http://localhost:3000',
|
|
10
|
+
segments: [],
|
|
11
|
+
middleware: []
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default defineConfig({
|
|
15
|
+
root: './src/app',
|
|
16
|
+
publicDir: 'public',
|
|
17
|
+
build: {
|
|
18
|
+
outDir: '../../dist/app',
|
|
19
|
+
emptyOutDir: true
|
|
20
|
+
},
|
|
21
|
+
plugins: [
|
|
22
|
+
react(),
|
|
23
|
+
jitar(jitarConfig)
|
|
24
|
+
]
|
|
25
|
+
});
|