@elyx-code/project-logic-tree 0.0.6771 → 0.0.6772

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/index.cjs CHANGED
@@ -89,7 +89,7 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
89
89
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(p){return p instanceof this?p:new this(p)}static concat(p,...i){const n=new this(p);return i.forEach(a=>n.set(a)),n}static accessor(p){const n=(this[C4]=this[C4]={accessors:{}}).accessors,a=this.prototype;function c(e){const y=K0(e);n[y]||(abi(a,e),n[y]=!0)}return Ue.isArray(p)?p.forEach(c):c(p),this}}XI.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Ue.reduceDescriptors(XI.prototype,({value:o},p)=>{let i=p[0].toUpperCase()+p.slice(1);return{get:()=>o,set(n){this[i]=n}}});Ue.freezeMethods(XI);const bl=XI;function gO(o,p){const i=this||dN,n=p||i,a=bl.from(n.headers);let c=n.data;return Ue.forEach(o,function(y){c=y.call(i,c,a.normalize(),p?p.status:void 0)}),a.normalize(),c}function Gxe(o){return!!(o&&o.__CANCEL__)}function jh(o,p,i){si.call(this,o??"canceled",si.ERR_CANCELED,p,i),this.name="CanceledError"}Ue.inherits(jh,si,{__CANCEL__:!0});function kxe(o,p,i){const n=i.config.validateStatus;!i.status||!n||n(i.status)?o(i):p(new si("Request failed with status code "+i.status,[si.ERR_BAD_REQUEST,si.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))}function sbi(o){const p=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return p&&p[1]||""}function lbi(o,p){o=o||10;const i=new Array(o),n=new Array(o);let a=0,c=0,e;return p=p!==void 0?p:1e3,function(m){const v=Date.now(),E=n[c];e||(e=v),i[a]=m,n[a]=v;let b=c,w=0;for(;b!==a;)w+=i[b++],b=b%o;if(a=(a+1)%o,a===c&&(c=(c+1)%o),v-e<p)return;const V=E&&v-E;return V?Math.round(w*1e3/V):void 0}}function obi(o,p){let i=0,n=1e3/p,a,c;const e=(v,E=Date.now())=>{i=E,a=null,c&&(clearTimeout(c),c=null),o(...v)};return[(...v)=>{const E=Date.now(),b=E-i;b>=n?e(v,E):(a=v,c||(c=setTimeout(()=>{c=null,e(a)},n-b)))},()=>a&&e(a)]}const mA=(o,p,i=3)=>{let n=0;const a=lbi(50,250);return obi(c=>{const e=c.loaded,y=c.lengthComputable?c.total:void 0,m=e-n,v=a(m),E=e<=y;n=e;const b={loaded:e,total:y,progress:y?e/y:void 0,bytes:m,rate:v||void 0,estimated:v&&y&&E?(y-e)/v:void 0,event:c,lengthComputable:y!=null,[p?"download":"upload"]:!0};o(b)},i)},_4=(o,p)=>{const i=o!=null;return[n=>p[0]({lengthComputable:i,total:o,loaded:n}),p[1]]},V4=o=>(...p)=>Ue.asap(()=>o(...p)),dbi=ra.hasStandardBrowserEnv?((o,p)=>i=>(i=new URL(i,ra.origin),o.protocol===i.protocol&&o.host===i.host&&(p||o.port===i.port)))(new URL(ra.origin),ra.navigator&&/(msie|trident)/i.test(ra.navigator.userAgent)):()=>!0,ubi=ra.hasStandardBrowserEnv?{write(o,p,i,n,a,c,e){if(typeof document>"u")return;const y=[`${o}=${encodeURIComponent(p)}`];Ue.isNumber(i)&&y.push(`expires=${new Date(i).toUTCString()}`),Ue.isString(n)&&y.push(`path=${n}`),Ue.isString(a)&&y.push(`domain=${a}`),c===!0&&y.push("secure"),Ue.isString(e)&&y.push(`SameSite=${e}`),document.cookie=y.join("; ")},read(o){if(typeof document>"u")return null;const p=document.cookie.match(new RegExp("(?:^|; )"+o+"=([^;]*)"));return p?decodeURIComponent(p[1]):null},remove(o){this.write(o,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function pbi(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function cbi(o,p){return p?o.replace(/\/?\/$/,"")+"/"+p.replace(/^\/+/,""):o}function jxe(o,p,i){let n=!pbi(p);return o&&(n||i==!1)?cbi(o,p):p}const P4=o=>o instanceof bl?{...o}:o;function Vc(o,p){p=p||{};const i={};function n(v,E,b,w){return Ue.isPlainObject(v)&&Ue.isPlainObject(E)?Ue.merge.call({caseless:w},v,E):Ue.isPlainObject(E)?Ue.merge({},E):Ue.isArray(E)?E.slice():E}function a(v,E,b,w){if(Ue.isUndefined(E)){if(!Ue.isUndefined(v))return n(void 0,v,b,w)}else return n(v,E,b,w)}function c(v,E){if(!Ue.isUndefined(E))return n(void 0,E)}function e(v,E){if(Ue.isUndefined(E)){if(!Ue.isUndefined(v))return n(void 0,v)}else return n(void 0,E)}function y(v,E,b){if(b in p)return n(v,E);if(b in o)return n(void 0,v)}const m={url:c,method:c,data:c,baseURL:e,transformRequest:e,transformResponse:e,paramsSerializer:e,timeout:e,timeoutMessage:e,withCredentials:e,withXSRFToken:e,adapter:e,responseType:e,xsrfCookieName:e,xsrfHeaderName:e,onUploadProgress:e,onDownloadProgress:e,decompress:e,maxContentLength:e,maxBodyLength:e,beforeRedirect:e,transport:e,httpAgent:e,httpsAgent:e,cancelToken:e,socketPath:e,responseEncoding:e,validateStatus:y,headers:(v,E,b)=>a(P4(v),P4(E),b,!0)};return Ue.forEach(Object.keys({...o,...p}),function(E){const b=m[E]||a,w=b(o[E],p[E],E);Ue.isUndefined(w)&&b!==y||(i[E]=w)}),i}const Uxe=o=>{const p=Vc({},o);let{data:i,withXSRFToken:n,xsrfHeaderName:a,xsrfCookieName:c,headers:e,auth:y}=p;if(p.headers=e=bl.from(e),p.url=Lxe(jxe(p.baseURL,p.url,p.allowAbsoluteUrls),o.params,o.paramsSerializer),y&&e.set("Authorization","Basic "+btoa((y.username||"")+":"+(y.password?unescape(encodeURIComponent(y.password)):""))),Ue.isFormData(i)){if(ra.hasStandardBrowserEnv||ra.hasStandardBrowserWebWorkerEnv)e.setContentType(void 0);else if(Ue.isFunction(i.getHeaders)){const m=i.getHeaders(),v=["content-type","content-length"];Object.entries(m).forEach(([E,b])=>{v.includes(E.toLowerCase())&&e.set(E,b)})}}if(ra.hasStandardBrowserEnv&&(n&&Ue.isFunction(n)&&(n=n(p)),n||n!==!1&&dbi(p.url))){const m=a&&c&&ubi.read(c);m&&e.set(a,m)}return p},fbi=typeof XMLHttpRequest<"u",ybi=fbi&&function(o){return new Promise(function(i,n){const a=Uxe(o);let c=a.data;const e=bl.from(a.headers).normalize();let{responseType:y,onUploadProgress:m,onDownloadProgress:v}=a,E,b,w,V,$;function M(){V&&V(),$&&$(),a.cancelToken&&a.cancelToken.unsubscribe(E),a.signal&&a.signal.removeEventListener("abort",E)}let k=new XMLHttpRequest;k.open(a.method.toUpperCase(),a.url,!0),k.timeout=a.timeout;function F(){if(!k)return;const Y=bl.from("getAllResponseHeaders"in k&&k.getAllResponseHeaders()),ee={data:!y||y==="text"||y==="json"?k.responseText:k.response,status:k.status,statusText:k.statusText,headers:Y,config:o,request:k};kxe(function(ae){i(ae),M()},function(ae){n(ae),M()},ee),k=null}"onloadend"in k?k.onloadend=F:k.onreadystatechange=function(){!k||k.readyState!==4||k.status===0&&!(k.responseURL&&k.responseURL.indexOf("file:")===0)||setTimeout(F)},k.onabort=function(){k&&(n(new si("Request aborted",si.ECONNABORTED,o,k)),k=null)},k.onerror=function(ie){const ee=ie&&ie.message?ie.message:"Network Error",de=new si(ee,si.ERR_NETWORK,o,k);de.event=ie||null,n(de),k=null},k.ontimeout=function(){let ie=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const ee=a.transitional||Mxe;a.timeoutErrorMessage&&(ie=a.timeoutErrorMessage),n(new si(ie,ee.clarifyTimeoutError?si.ETIMEDOUT:si.ECONNABORTED,o,k)),k=null},c===void 0&&e.setContentType(null),"setRequestHeader"in k&&Ue.forEach(e.toJSON(),function(ie,ee){k.setRequestHeader(ee,ie)}),Ue.isUndefined(a.withCredentials)||(k.withCredentials=!!a.withCredentials),y&&y!=="json"&&(k.responseType=a.responseType),v&&([w,$]=mA(v,!0),k.addEventListener("progress",w)),m&&k.upload&&([b,V]=mA(m),k.upload.addEventListener("progress",b),k.upload.addEventListener("loadend",V)),(a.cancelToken||a.signal)&&(E=Y=>{k&&(n(!Y||Y.type?new jh(null,o,k):Y),k.abort(),k=null)},a.cancelToken&&a.cancelToken.subscribe(E),a.signal&&(a.signal.aborted?E():a.signal.addEventListener("abort",E)));const U=sbi(a.url);if(U&&ra.protocols.indexOf(U)===-1){n(new si("Unsupported protocol "+U+":",si.ERR_BAD_REQUEST,o));return}k.send(c||null)})},hbi=(o,p)=>{const{length:i}=o=o?o.filter(Boolean):[];if(p||i){let n=new AbortController,a;const c=function(v){if(!a){a=!0,y();const E=v instanceof Error?v:this.reason;n.abort(E instanceof si?E:new jh(E instanceof Error?E.message:E))}};let e=p&&setTimeout(()=>{e=null,c(new si(`timeout ${p} of ms exceeded`,si.ETIMEDOUT))},p);const y=()=>{o&&(e&&clearTimeout(e),e=null,o.forEach(v=>{v.unsubscribe?v.unsubscribe(c):v.removeEventListener("abort",c)}),o=null)};o.forEach(v=>v.addEventListener("abort",c));const{signal:m}=n;return m.unsubscribe=()=>Ue.asap(y),m}},mbi=hbi,Tbi=function*(o,p){let i=o.byteLength;if(!p||i<p){yield o;return}let n=0,a;for(;n<i;)a=n+p,yield o.slice(n,a),n=a},vbi=async function*(o,p){for await(const i of Ebi(o))yield*Tbi(i,p)},Ebi=async function*(o){if(o[Symbol.asyncIterator]){yield*o;return}const p=o.getReader();try{for(;;){const{done:i,value:n}=await p.read();if(i)break;yield n}}finally{await p.cancel()}},N4=(o,p,i,n)=>{const a=vbi(o,p);let c=0,e,y=m=>{e||(e=!0,n&&n(m))};return new ReadableStream({async pull(m){try{const{done:v,value:E}=await a.next();if(v){y(),m.close();return}let b=E.byteLength;if(i){let w=c+=b;i(w)}m.enqueue(new Uint8Array(E))}catch(v){throw y(v),v}},cancel(m){return y(m),a.return()}},{highWaterMark:2})},x4=64*1024,{isFunction:$b}=Ue,bbi=(({Request:o,Response:p})=>({Request:o,Response:p}))(Ue.global),{ReadableStream:$4,TextEncoder:L4}=Ue.global,M4=(o,...p)=>{try{return!!o(...p)}catch{return!1}},Abi=o=>{o=Ue.merge.call({skipUndefined:!0},bbi,o);const{fetch:p,Request:i,Response:n}=o,a=p?$b(p):typeof fetch=="function",c=$b(i),e=$b(n);if(!a)return!1;const y=a&&$b($4),m=a&&(typeof L4=="function"?($=>M=>$.encode(M))(new L4):async $=>new Uint8Array(await new i($).arrayBuffer())),v=c&&y&&M4(()=>{let $=!1;const M=new i(ra.origin,{body:new $4,method:"POST",get duplex(){return $=!0,"half"}}).headers.has("Content-Type");return $&&!M}),E=e&&y&&M4(()=>Ue.isReadableStream(new n("").body)),b={stream:E&&($=>$.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach($=>{!b[$]&&(b[$]=(M,k)=>{let F=M&&M[$];if(F)return F.call(M);throw new si(`Response type '${$}' is not supported`,si.ERR_NOT_SUPPORT,k)})});const w=async $=>{if($==null)return 0;if(Ue.isBlob($))return $.size;if(Ue.isSpecCompliantForm($))return(await new i(ra.origin,{method:"POST",body:$}).arrayBuffer()).byteLength;if(Ue.isArrayBufferView($)||Ue.isArrayBuffer($))return $.byteLength;if(Ue.isURLSearchParams($)&&($=$+""),Ue.isString($))return(await m($)).byteLength},V=async($,M)=>{const k=Ue.toFiniteNumber($.getContentLength());return k??w(M)};return async $=>{let{url:M,method:k,data:F,signal:U,cancelToken:Y,timeout:ie,onDownloadProgress:ee,onUploadProgress:de,responseType:ae,headers:fe,withCredentials:ve="same-origin",fetchOptions:ue}=Uxe($),ye=p||fetch;ae=ae?(ae+"").toLowerCase():"text";let Ve=mbi([U,Y&&Y.toAbortSignal()],ie),_e=null;const xe=Ve&&Ve.unsubscribe&&(()=>{Ve.unsubscribe()});let Pe;try{if(de&&v&&k!=="get"&&k!=="head"&&(Pe=await V(fe,F))!==0){let lt=new i(M,{method:"POST",body:F,duplex:"half"}),ut;if(Ue.isFormData(F)&&(ut=lt.headers.get("content-type"))&&fe.setContentType(ut),lt.body){const[_t,Bt]=_4(Pe,mA(V4(de)));F=N4(lt.body,x4,_t,Bt)}}Ue.isString(ve)||(ve=ve?"include":"omit");const Be=c&&"credentials"in i.prototype,Se={...ue,signal:Ve,method:k.toUpperCase(),headers:fe.normalize().toJSON(),body:F,duplex:"half",credentials:Be?ve:void 0};_e=c&&new i(M,Se);let je=await(c?ye(_e,ue):ye(M,Se));const Ze=E&&(ae==="stream"||ae==="response");if(E&&(ee||Ze&&xe)){const lt={};["status","statusText","headers"].forEach(Gi=>{lt[Gi]=je[Gi]});const ut=Ue.toFiniteNumber(je.headers.get("content-length")),[_t,Bt]=ee&&_4(ut,mA(V4(ee),!0))||[];je=new n(N4(je.body,x4,_t,()=>{Bt&&Bt(),xe&&xe()}),lt)}ae=ae||"text";let Ye=await b[Ue.findKey(b,ae)||"text"](je,$);return!Ze&&xe&&xe(),await new Promise((lt,ut)=>{kxe(lt,ut,{data:Ye,headers:bl.from(je.headers),status:je.status,statusText:je.statusText,config:$,request:_e})})}catch(Be){throw xe&&xe(),Be&&Be.name==="TypeError"&&/Load failed|fetch/i.test(Be.message)?Object.assign(new si("Network Error",si.ERR_NETWORK,$,_e),{cause:Be.cause||Be}):si.from(Be,Be&&Be.code,$,_e)}}},gbi=new Map,Kxe=o=>{let p=o&&o.env||{};const{fetch:i,Request:n,Response:a}=p,c=[n,a,i];let e=c.length,y=e,m,v,E=gbi;for(;y--;)m=c[y],v=E.get(m),v===void 0&&E.set(m,v=y?new Map:Abi(p)),E=v;return v};Kxe();const uN={http:BEi,xhr:ybi,fetch:{get:Kxe}};Ue.forEach(uN,(o,p)=>{if(o){try{Object.defineProperty(o,"name",{value:p})}catch{}Object.defineProperty(o,"adapterName",{value:p})}});const B4=o=>`- ${o}`,Ibi=o=>Ue.isFunction(o)||o===null||o===!1;function Rbi(o,p){o=Ue.isArray(o)?o:[o];const{length:i}=o;let n,a;const c={};for(let e=0;e<i;e++){n=o[e];let y;if(a=n,!Ibi(n)&&(a=uN[(y=String(n)).toLowerCase()],a===void 0))throw new si(`Unknown adapter '${y}'`);if(a&&(Ue.isFunction(a)||(a=a.get(p))))break;c[y||"#"+e]=a}if(!a){const e=Object.entries(c).map(([m,v])=>`adapter ${m} `+(v===!1?"is not supported by the environment":"is not available in the build"));let y=i?e.length>1?`since :
90
90
  `+e.map(B4).join(`
91
91
  `):" "+B4(e[0]):"as no adapter specified";throw new si("There is no suitable adapter to dispatch the request "+y,"ERR_NOT_SUPPORT")}return a}const Fxe={getAdapter:Rbi,adapters:uN};function IO(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new jh(null,o)}function G4(o){return IO(o),o.headers=bl.from(o.headers),o.data=gO.call(o,o.transformRequest),["post","put","patch"].indexOf(o.method)!==-1&&o.headers.setContentType("application/x-www-form-urlencoded",!1),Fxe.getAdapter(o.adapter||dN.adapter,o)(o).then(function(n){return IO(o),n.data=gO.call(o,o.transformResponse,n),n.headers=bl.from(n.headers),n},function(n){return Gxe(n)||(IO(o),n&&n.response&&(n.response.data=gO.call(o,o.transformResponse,n.response),n.response.headers=bl.from(n.response.headers))),Promise.reject(n)})}const Sxe="1.13.2",QI={};["object","boolean","number","function","string","symbol"].forEach((o,p)=>{QI[o]=function(n){return typeof n===o||"a"+(p<1?"n ":" ")+o}});const k4={};QI.transitional=function(p,i,n){function a(c,e){return"[Axios v"+Sxe+"] Transitional option '"+c+"'"+e+(n?". "+n:"")}return(c,e,y)=>{if(p===!1)throw new si(a(e," has been removed"+(i?" in "+i:"")),si.ERR_DEPRECATED);return i&&!k4[e]&&(k4[e]=!0,console.warn(a(e," has been deprecated since v"+i+" and will be removed in the near future"))),p?p(c,e,y):!0}};QI.spelling=function(p){return(i,n)=>(console.warn(`${n} is likely a misspelling of ${p}`),!0)};function Dbi(o,p,i){if(typeof o!="object")throw new si("options must be an object",si.ERR_BAD_OPTION_VALUE);const n=Object.keys(o);let a=n.length;for(;a-- >0;){const c=n[a],e=p[c];if(e){const y=o[c],m=y===void 0||e(y,c,o);if(m!==!0)throw new si("option "+c+" must be "+m,si.ERR_BAD_OPTION_VALUE);continue}if(i!==!0)throw new si("Unknown option "+c,si.ERR_BAD_OPTION)}}const Sb={assertOptions:Dbi,validators:QI},Ao=Sb.validators;class TA{constructor(p){this.defaults=p||{},this.interceptors={request:new O4,response:new O4}}async request(p,i){try{return await this._request(p,i)}catch(n){if(n instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const c=a.stack?a.stack.replace(/^.+\n/,""):"";try{n.stack?c&&!String(n.stack).endsWith(c.replace(/^.+\n.+\n/,""))&&(n.stack+=`
92
- `+c):n.stack=c}catch{}}throw n}}_request(p,i){typeof p=="string"?(i=i||{},i.url=p):i=p||{},i=Vc(this.defaults,i);const{transitional:n,paramsSerializer:a,headers:c}=i;n!==void 0&&Sb.assertOptions(n,{silentJSONParsing:Ao.transitional(Ao.boolean),forcedJSONParsing:Ao.transitional(Ao.boolean),clarifyTimeoutError:Ao.transitional(Ao.boolean)},!1),a!=null&&(Ue.isFunction(a)?i.paramsSerializer={serialize:a}:Sb.assertOptions(a,{encode:Ao.function,serialize:Ao.function},!0)),i.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?i.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:i.allowAbsoluteUrls=!0),Sb.assertOptions(i,{baseUrl:Ao.spelling("baseURL"),withXsrfToken:Ao.spelling("withXSRFToken")},!0),i.method=(i.method||this.defaults.method||"get").toLowerCase();let e=c&&Ue.merge(c.common,c[i.method]);c&&Ue.forEach(["delete","get","head","post","put","patch","common"],$=>{delete c[$]}),i.headers=bl.concat(e,c);const y=[];let m=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(i)===!1||(m=m&&M.synchronous,y.unshift(M.fulfilled,M.rejected))});const v=[];this.interceptors.response.forEach(function(M){v.push(M.fulfilled,M.rejected)});let E,b=0,w;if(!m){const $=[G4.bind(this),void 0];for($.unshift(...y),$.push(...v),w=$.length,E=Promise.resolve(i);b<w;)E=E.then($[b++],$[b++]);return E}w=y.length;let V=i;for(;b<w;){const $=y[b++],M=y[b++];try{V=$(V)}catch(k){M.call(this,k);break}}try{E=G4.call(this,V)}catch($){return Promise.reject($)}for(b=0,w=v.length;b<w;)E=E.then(v[b++],v[b++]);return E}getUri(p){p=Vc(this.defaults,p);const i=jxe(p.baseURL,p.url,p.allowAbsoluteUrls);return Lxe(i,p.params,p.paramsSerializer)}}Ue.forEach(["delete","get","head","options"],function(p){TA.prototype[p]=function(i,n){return this.request(Vc(n||{},{method:p,url:i,data:(n||{}).data}))}});Ue.forEach(["post","put","patch"],function(p){function i(n){return function(c,e,y){return this.request(Vc(y||{},{method:p,headers:n?{"Content-Type":"multipart/form-data"}:{},url:c,data:e}))}}TA.prototype[p]=i(),TA.prototype[p+"Form"]=i(!0)});const qb=TA;class pN{constructor(p){if(typeof p!="function")throw new TypeError("executor must be a function.");let i;this.promise=new Promise(function(c){i=c});const n=this;this.promise.then(a=>{if(!n._listeners)return;let c=n._listeners.length;for(;c-- >0;)n._listeners[c](a);n._listeners=null}),this.promise.then=a=>{let c;const e=new Promise(y=>{n.subscribe(y),c=y}).then(a);return e.cancel=function(){n.unsubscribe(c)},e},p(function(c,e,y){n.reason||(n.reason=new jh(c,e,y),i(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(p){if(this.reason){p(this.reason);return}this._listeners?this._listeners.push(p):this._listeners=[p]}unsubscribe(p){if(!this._listeners)return;const i=this._listeners.indexOf(p);i!==-1&&this._listeners.splice(i,1)}toAbortSignal(){const p=new AbortController,i=n=>{p.abort(n)};return this.subscribe(i),p.signal.unsubscribe=()=>this.unsubscribe(i),p.signal}static source(){let p;return{token:new pN(function(a){p=a}),cancel:p}}}const wbi=pN;function Obi(o){return function(i){return o.apply(null,i)}}function Cbi(o){return Ue.isObject(o)&&o.isAxiosError===!0}const aC={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(aC).forEach(([o,p])=>{aC[p]=o});const _bi=aC;function qxe(o){const p=new qb(o),i=Ixe(qb.prototype.request,p);return Ue.extend(i,qb.prototype,p,{allOwnKeys:!0}),Ue.extend(i,p,null,{allOwnKeys:!0}),i.create=function(a){return qxe(Vc(o,a))},i}const En=qxe(dN);En.Axios=qb;En.CanceledError=jh;En.CancelToken=wbi;En.isCancel=Gxe;En.VERSION=Sxe;En.toFormData=YI;En.AxiosError=si;En.Cancel=En.CanceledError;En.all=function(p){return Promise.all(p)};En.spread=Obi;En.isAxiosError=Cbi;En.mergeConfig=Vc;En.AxiosHeaders=bl;En.formToJSON=o=>Bxe(Ue.isHTMLForm(o)?new FormData(o):o);En.getAdapter=Fxe.getAdapter;En.HttpStatusCode=_bi;En.default=En;const Vbi=En;class Zxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST,version:"1.0.0",description:"HTTP request operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Wn.HttpRequest);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=a[3]||{},e={method:a[0],url:a[1],params:a[2],headers:c,data:a[4]};J.Logger.log("Axios request config: ",e);const y=await Vbi(e);return{value:G.Success,error:null,result:{status:y.status,headers:y.headers,data:y.data}}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class Hxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY,version:"1.0.0",description:"Entity validate operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.Validate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)});J.Logger.log("Inputs for entity validation: ",a);const e=GR(a[1]).safeParse(a[0]);return e.success?{value:G.Success,error:null,result:{data:a[0]}}:{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:e.error.errors,result:null}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}const Ia=o=>o.map(p=>{var i,n;return((i=p.value)==null?void 0:i.valueAsType)??((n=p.value)==null?void 0:n.value)});class Wxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY,version:"1.0.0",description:"Entity read-key operation implementation module (top-level)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.ReadKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c]=Ia(n),e=rvi(a,c);return{value:G.Success,error:null,result:e}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class zxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY,version:"1.0.0",description:"Entity write-key operation implementation module (top-level, immutable)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.WriteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=nvi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class Jxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY,version:"1.0.0",description:"Entity delete-key operation implementation module (top-level, immutable)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.DeleteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c]=Ia(n),e=avi(a,c);return{value:G.Success,error:null,result:e}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class Yxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY,version:"1.0.0",description:"Entity read-nested-key operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.ReadNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=svi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class Xxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY,version:"1.0.0",description:"Entity write-nested-key operation implementation module (immutable, no auto-create)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.WriteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=lvi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class Qxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY,version:"1.0.0",description:"Entity write-safe-nested-key-recursively operation implementation module (immutable, auto-create)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.WriteSafeNestedKeyRecursively);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=ovi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class e$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY,version:"1.0.0",description:"Entity delete-nested-key operation implementation module (immutable)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.DeleteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c]=Ia(n),e=dvi(a,c);return{value:G.Success,error:null,result:e}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class t$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY,version:"1.0.0",description:"Object has-key (top-level property present?)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Ce.HasKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=Ia(n),e=uvi(a,c);return{value:G.Success,error:null,result:e}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class i$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object key-value-equals (top-level property strict equality)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Ce.KeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=pvi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class r$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY,version:"1.0.0",description:"Object has-nested-key (path present?)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Ce.HasNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=Ia(n),e=cvi(a,c);return{value:G.Success,error:null,result:e}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class n$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object nested-key-value-equals (path strict equality)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Ce.NestedKeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=fvi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class a$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE,version:"1.0.0",description:"Object is-instance-of-type (DefinitionEntity-based runtime check)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Ce.IsInstanceOfType);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,y,m,v,E,b,w,V;try{const $=((c=(a=n[0])==null?void 0:a.value)==null?void 0:c.parent)||((y=(e=n[0])==null?void 0:e.value)==null?void 0:y.standaloneParent),M=(v=(m=n[0])==null?void 0:m.value)==null?void 0:v.value,k=(b=(E=n[1])==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle;if(!M)throw new TypeError("IsInstanceOfType expects a non-null input value.");if(!k)throw new TypeError("IsInstanceOfType expects a valid expectedType input.");if(!$)throw new TypeError("IsInstanceOfType cannot determine the value owner.");if(k.type!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType expects expectedType to be a DefinitionEntity.");const F=$.getDataType(null);if(((w=F==null?void 0:F.entity)==null?void 0:w.type)!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType cannot determine the data type of the input value.");let U=!1;return((V=F==null?void 0:F.entity)==null?void 0:V.id)!==(k==null?void 0:k.id)?U=!1:GR(F==null?void 0:F.entity).safeParse(M).success?U=!0:U=!1,{value:G.Success,error:null,result:U}}catch($){return{value:G.UnhandledError,error:$,result:null}}}})}}class s$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE,version:"1.0.0",description:"Object merge operation implementation module (immutable, shallow merge with right-precedence)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Ce.Merge);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const a=Ia(n),c=yvi(...a);return{value:G.Success,error:null,result:c}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class l$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS,version:"1.0.0",description:"Object keys operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Ce.Keys);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=Ia(n),c=hvi(a);return{value:G.Success,error:null,result:c}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class o$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES,version:"1.0.0",description:"Object values operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Ce.Values);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=Ia(n),c=mvi(a);return{value:G.Success,error:null,result:c}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class d$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES,version:"1.0.0",description:"Object entries operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Ce.Entries);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=Ia(n),c=Tvi(a);return{value:G.Success,error:null,result:c}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}let ss=null;try{ss=require("crypto")}catch{}const Gm=typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle?globalThis.crypto:ss&&ss.webcrypto?ss.webcrypto:null,Ou=Gm?Gm.subtle:null;function Wm(o){const p=new ArrayBuffer(o.byteLength);return new Uint8Array(p).set(o),p}function Hr(o,p="utf8"){if(o instanceof Uint8Array)return o;const i=String(o);if(p==="utf8"){if(typeof TextEncoder<"u")return new TextEncoder().encode(i);if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"utf8"))}else if(p==="hex"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"hex"))}else if(p==="base64"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"base64"))}else if(p==="base64url"){const n=i.replace(/-/g,"+").replace(/_/g,"/").replace(/=+$/,"");if(typeof Buffer<"u")return new Uint8Array(Buffer.from(n,"base64"));const a=typeof atob=="function"?atob(n):"",c=new Uint8Array(a.length);for(let e=0;e<a.length;e++)c[e]=a.charCodeAt(e);return c}throw new Error(`Unsupported environment/encoding combo for toBytes(${p})`)}function to(o,p="utf8"){if(p==="utf8"){if(typeof TextDecoder<"u")return new TextDecoder().decode(o);if(typeof Buffer<"u")return Buffer.from(o).toString("utf8")}else if(p==="hex"){if(typeof Buffer<"u")return Buffer.from(o).toString("hex")}else if(p==="base64"){if(typeof Buffer<"u")return Buffer.from(o).toString("base64")}else if(p==="base64url"&&typeof Buffer<"u")return Buffer.from(o).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");throw new Error(`Unsupported environment/encoding combo for fromBytes(${p})`)}const u$e=o=>Hr(o,"base64"),p$e=(o,p)=>{const i=o instanceof Uint8Array?o:Hr(String(o),p||"utf8");return to(i,"base64")},_y=(o,p)=>{const i=o instanceof Uint8Array?o:Hr(String(o),p||"utf8");return to(i,"base64url")},Pc=o=>Hr(o,"base64url"),c$e=(o,p)=>{const i=o instanceof Uint8Array?o:Hr(String(o),p||"utf8");return to(i,"hex")},f$e=o=>Hr(o,"hex");function cN(o){if(Gm&&Gm.getRandomValues){const p=new Uint8Array(o);return Gm.getRandomValues(p),p}if(ss&&ss.randomBytes)return new Uint8Array(ss.randomBytes(o));throw new Error("Secure random not available")}function eR(o,p){if(!(o instanceof Uint8Array)||!(p instanceof Uint8Array)||o.length!==p.length)return!1;let i=0;for(let n=0;n<o.length;n++)i|=o[n]^p[n];return i===0}function y$e(o,p,i,n){if((typeof o!="string"||typeof p!="string")&&typeof o!="string"&&typeof p!="string")throw new Error("Invalid input types");const a=i??"utf8",c=n??"utf8",e=Hr(o??"",a),y=Hr(p??"",c);return eR(e,y)}async function h$e(o,p){if(Ou){const i=await Ou.digest({name:o},Wm(p));return new Uint8Array(i)}if(ss){const i=o.replace("SHA-","sha"),n=ss.createHash(i);return n.update(Buffer.from(p)),new Uint8Array(n.digest())}throw new Error("Hash not available")}async function m$e(o,p,i,n){if(typeof p!="string")throw new Error("Invalid input type for data; expected string");const a=String(o??"SHA-256"),c=i??"utf8",e=n??"base64url",y=Hr(p??"",c),m=await h$e(a,y);return to(m,e)}async function tR(o,p,i){if(Ou){const n=await Ou.importKey("raw",Wm(p),{name:"HMAC",hash:{name:o}},!1,["sign"]),a=await Ou.sign("HMAC",n,Wm(i));return new Uint8Array(a)}if(ss){const n=`sha${o.split("-")[1]}`,a=ss.createHmac(n,Buffer.from(p));return a.update(Buffer.from(i)),new Uint8Array(a.digest())}throw new Error("HMAC not available")}async function T$e(o,p,i,n,a,c){if(typeof o!="string"||typeof p!="string")throw new Error("Invalid input types for key or data; expected strings");const e=String(i??"SHA-256"),y=n??"utf8",m=a??"utf8",v=c??"base64url",E=Hr(o??"",y),b=Hr(p??"",m),w=await tR(e,E,b);return to(w,v)}async function iR(o,p,{iterations:i,length:n,hashAlg:a="SHA-256"}){if(Ou){const c=await Ou.importKey("raw",Wm(o),"PBKDF2",!1,["deriveBits"]),e=await Ou.deriveBits({name:"PBKDF2",salt:Wm(p),iterations:i,hash:a},c,n*8);return new Uint8Array(e)}if(ss){const c=a==="SHA-512"?"sha512":"sha256";return await new Promise((e,y)=>{ss.pbkdf2(Buffer.from(o),Buffer.from(p),i,n,c,(m,v)=>{m?y(m):e(new Uint8Array(v))})})}throw new Error("PBKDF2 not available")}async function v$e(o,p,i,n,a,c,e,y){if(typeof o!="string"||typeof p!="string")throw new Error("Invalid input types for password or salt; expected strings");const m=c??"utf8",v=e??"utf8",E=y??"base64url",b=Math.max(1,Number(i)||21e4),w=Math.max(1,Number(n)||32),V=a??"SHA-256",$=Hr(o??"",m),M=Hr(p??"",v),k=await iR($,M,{iterations:b,length:w,hashAlg:V});return to(k,E)}async function E$e(o,p=cN(16),i=21e4,n=32,a="SHA-256"){const c=Hr(o,"utf8"),e=await iR(c,p,{iterations:i,length:n,hashAlg:a}),y=_y(p),m=_y(e);return`pbkdf2$${a.toLowerCase()}$${i}$${y}$${m}`}async function b$e(o,p){const i=String(p).split("$");if(i.length!==5||i[0]!=="pbkdf2")return!1;const n=i[1].toLowerCase(),a=parseInt(i[2],10),c=Pc(i[3]),e=Pc(i[4]),y=n.includes("512")?"SHA-512":"SHA-256",m=await iR(Hr(o,"utf8"),c,{iterations:a,length:e.length,hashAlg:y});return eR(m,e)}async function A$e(o,p,i,n,a,c){const e=p!=null?Math.max(1,Number(p)||0):void 0,y=i!=null?Math.max(1,Number(i)||0):void 0,m=n??void 0,v=c??"base64url",E=a!=null?Hr(a,v):void 0;return await E$e(String(o??""),E,e,y,m)}function j4(o){return _y(Hr(JSON.stringify(o),"utf8"))}function vA(o){try{return JSON.parse(to(Pc(o),"utf8"))}catch{return null}}async function g$e(o,p,{alg:i="HS256",includeIat:n=!0,expiresInSeconds:a,notBeforeSeconds:c,issuer:e,subject:y,audience:m,jwtid:v,header:E={}}={}){const b={alg:i,typ:"JWT",...E},w=Math.floor(Date.now()/1e3),V={...o||{}};n&&(V.iat=w),typeof a=="number"&&(V.exp=w+a),typeof c=="number"&&(V.nbf=w+c),e&&(V.iss=e),y&&(V.sub=y),m&&(V.aud=m),v&&(V.jti=v);const $=j4(b),M=j4(V),k=Hr(`${$}.${M}`,"utf8"),U=await tR(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,k),Y=_y(U);return`${$}.${M}.${Y}`}async function I$e(o,p,i,n,a,c,e,y,m,v,E,b){if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(o!=null&&typeof o!="object")throw new Error("Invalid input type for payload; expected object");if(E!=null&&typeof E!="object")throw new Error("Invalid input type for header; expected object");if(v!=null&&typeof v!="string")throw new Error("Invalid input type for jwtid; expected string");if(e!=null&&typeof e!="string")throw new Error("Invalid input type for issuer; expected string");if(y!=null&&typeof y!="string")throw new Error("Invalid input type for subject; expected string");if(m!=null&&typeof m!="string"&&!Array.isArray(m))throw new Error("Invalid input type for audience; expected string or string[]");const V=Hr(p??"",b??"utf8");return await g$e(o??{},V,{alg:i??"HS256",includeIat:n==null?!0:!!n,expiresInSeconds:a!=null?Number(a):void 0,notBeforeSeconds:c!=null?Number(c):void 0,issuer:e??void 0,subject:y??void 0,audience:m??void 0,jwtid:v??void 0,header:E??void 0})}async function R$e(o,p,{alg:i="HS256",issuer:n,audience:a,maxAgeSeconds:c,clockSkewSeconds:e=60}={}){try{const[y,m,v]=String(o).split(".");if(!y||!m||!v)return{valid:!1,header:null,payload:null,reason:"Malformed"};const E=vA(y),b=vA(m);if(!E||!b)return{valid:!1,header:E,payload:b,reason:"Bad base64/json"};if(E.alg!==i)return{valid:!1,header:E,payload:b,reason:"Alg mismatch"};const w=Hr(`${y}.${m}`,"utf8"),$=await tR(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,w),M=Pc(v);if(!eR($,M))return{valid:!1,header:E,payload:b,reason:"Bad signature"};const k=Math.floor(Date.now()/1e3),F=Math.max(0,Number(e)||0);if(b.nbf!=null&&k+F<Number(b.nbf))return{valid:!1,header:E,payload:b,reason:"Not before"};if(b.exp!=null&&k-F>=Number(b.exp))return{valid:!1,header:E,payload:b,reason:"Expired"};if(n&&b.iss!==n)return{valid:!1,header:E,payload:b,reason:"Issuer mismatch"};if(a){const U=b.aud;if(!(Array.isArray(U)?U.includes(a):U===a))return{valid:!1,header:E,payload:b,reason:"Audience mismatch"}}return c!=null&&b.iat!=null&&k-Number(b.iat)>Number(c)+F?{valid:!1,header:E,payload:b,reason:"MaxAge exceeded"}:{valid:!0,header:E,payload:b}}catch(y){return{valid:!1,header:null,payload:null,reason:String((y==null?void 0:y.message)??y)}}}async function D$e(o,p,i,n,a,c,e,y){if(typeof o!="string")throw new Error("Invalid input type for token; expected string");if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(typeof n!="string")throw new Error("Invalid input type for issuer; expected string");if(a!=null&&typeof a!="string")throw new Error("Invalid input type for audience; expected string");const v=Hr(p??"",y??"utf8");return await R$e(String(o??""),v,{alg:i??"HS256",issuer:n??void 0,audience:a??void 0,maxAgeSeconds:c!=null?Number(c):void 0,clockSkewSeconds:e!=null?Number(e):void 0})}function w$e(o){const[p,i,n]=String(o).split(".");return{header:p?vA(p):null,payload:i?vA(i):null,signature:n?Pc(n):new Uint8Array}}function O$e(o,p){if(!o)throw new Error("Token is required for decoding");if(typeof o!="string")throw new Error("Invalid input type for token; expected string");const i=p??"base64url",{header:n,payload:a,signature:c}=w$e(String(o??"")),e=to(c,i);return{header:n,payload:a,signature:e}}class C$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES,version:"1.0.0",description:"Randomness generate random bytes operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(et.GenerateRandomBytes);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)}),e=Math.max(0,Number(a)||0),y=c??"base64url",m=cN(e),v=to(m,y);return{value:G.Success,error:null,result:v}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class _$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER,version:"1.0.0",description:"Randomness generate random integer operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomInteger);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=a[0],e=a[1],y=mOe(c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class V$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT,version:"1.0.0",description:"Randomness generate random float operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomFloat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=SI();return{value:G.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class P$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL,version:"1.0.0",description:"Randomness generate random hexadecimal operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomHexadecimal);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=KP(c);return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class N$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62,version:"1.0.0",description:"Randomness generate random base62 operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomBase62);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=FP(c);return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class x$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64,version:"1.0.0",description:"Randomness generate random base64 operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=vOe(c);return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class $$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC,version:"1.0.0",description:"Randomness generate random alphanumeric operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomAlphanumeric);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=SP(c);return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class L$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER,version:"1.0.0",description:"Generate identifier operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateIdentifier);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=a[0],e=a[1],y=qP(c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class M$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4,version:"1.0.0",description:"Generate UUID v4 operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomUUIDv4);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=wu();return{value:G.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class B$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER,version:"1.0.0",description:"Generate short identifier operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{J.Logger.log("Initializing Random Generate Short Identifier Module");const n=i.find(a=>a.contextType===X.Logic);if(n){J.Logger.log("Project state found, setting up operation");const a=n.get(et.GenerateShortIdentifier);a?(J.Logger.log("Operation found, setting autoexecutable and implementation"),a.autoexecutable=!0,a.implementation=this.module.main):J.Logger.warn("Operation generate-short-identifier not found in project state")}else J.Logger.warn("Project state not found in contexts for Random Generate Short Identifier Module")},main:async(i,n)=>{try{const a=EOe();return{value:G.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class G$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN,version:"1.0.0",description:"Generate hexadecimal token operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateHexadecimalToken);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=bOe();return{value:G.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}function Pbi(o){let p;if(o===null?p="null":Array.isArray(o)?p="array":p=typeof o,!["string","number","boolean","null","object","array"].includes(p))throw new TypeError("GetTypeOf cannot determine type of the given value.");return p}class k$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF,version:"1.0.0",description:"Data type get type of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(ze.GetTypeOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)})[0];return{value:G.Success,error:null,result:Pbi(c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class j$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING,version:"1.0.0",description:"Coerce any value to string via JS String(value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.ToString);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=String(a);return{value:G.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class U$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER,version:"1.0.0",description:"Coerce to number via JS Number(value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.ToNumber);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=Number(a);return{value:G.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class K$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES,version:"1.0.0",description:"Convert string/bytes-like to Uint8Array (utf8|hex|base64|base64url)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.ToBytes);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=Hr(a,c||"utf8");return{value:G.Success,error:null,result:y}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class F$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING,version:"1.0.0",description:"Convert Uint8Array to string (utf8|hex|base64|base64url)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.FromBytesToString);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=to(a,c||"utf8");return{value:G.Success,error:null,result:y}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class S$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64,version:"1.0.0",description:"Bytes -> base64 string (accepts string input by converting from utf8)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.EncodeBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)});return{value:G.Success,error:null,result:p$e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class q$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64,version:"1.0.0",description:"base64 string -> bytes (Uint8Array)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.DecodeBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=u$e(String(a));return{value:G.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class Z$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL,version:"1.0.0",description:"Bytes -> base64url string (accepts string input by converting from utf8)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.EncodeBase64Url);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=_y(a,c||"utf8");return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class H$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL,version:"1.0.0",description:"base64url string -> bytes (Uint8Array)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.DecodeBase64Url);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=Pc(String(a));return{value:G.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class W$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX,version:"1.0.0",description:"Bytes -> hex string (accepts string input by converting from utf8)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.EncodeHex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=c$e(a,c||"utf8");return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class z$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX,version:"1.0.0",description:"hex string -> bytes (Uint8Array)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.DecodeHex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=f$e(String(a));return{value:G.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class J$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH,version:"1.0.0",description:"Crypto: Hash (SHA-256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(li.Hash);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)});return{value:G.Success,error:null,result:m$e(a,c,e,y)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class Y$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC,version:"1.0.0",description:"Crypto: HMAC (SHA-256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(li.Hmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y,m,v]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)});return{value:G.Success,error:null,result:T$e(c,e,a,y,m,v)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class X$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL,version:"1.0.0",description:"Crypto: constant-time equality for byte sequences",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(li.ConstantTimeEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)});return{value:G.Success,error:null,result:y$e(a,c,e,y)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class Q$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2,version:"1.0.0",description:"Crypto: derive key with PBKDF2 (SHA-256/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(li.DeriveKeyPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y,m,v,E,b]=n.map(w=>{var V,$;return((V=w.value)==null?void 0:V.valueAsType)??(($=w.value)==null?void 0:$.value)});return{value:G.Success,error:null,result:v$e(a,c,e,y,m,v,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class eLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE,version:"1.0.0",description:"Json parse string into object operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Xr.Parse);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{var a;try{const c=(a=n[0].value)==null?void 0:a.value;if(typeof c!="string")throw new Error(`Invalid input type for JSON.parse operation: expected string, got ${typeof c}`);const e=JSON.parse(c);return{value:G.Success,error:null,result:e}}catch(c){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:c,result:null}}}})}}class tLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY,version:"1.0.0",description:"Json stringify object into string operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Xr.Stringify);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{var a,c;try{const e=(a=n[0].value)==null?void 0:a.value,y=(c=n[1].value)==null?void 0:c.value;if(!e||typeof e!="object"&&!Array.isArray(e))throw new Error(`Invalid input type for JSON.stringify operation: expected object or array, got ${typeof e}`);if(!y&&y!==0){const v=JSON.stringify(e);return{value:G.Success,error:null,result:v}}const m=JSON.stringify(e,null,y);return{value:G.Success,error:null,result:m}}catch(e){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:e,result:null}}}})}}class iLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC,version:"1.0.0",description:"JWT: build (HS256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(er.BuildJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y,m,v,E,b,w,V,$,M]=n.map(k=>{var F,U;return((F=k.value)==null?void 0:F.valueAsType)??((U=k.value)==null?void 0:U.value)});return{value:G.Success,error:null,result:await I$e(a,c,e,y,m,v,E,b,w,V,$,M)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class rLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC,version:"1.0.0",description:"JWT: verify (HS256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(er.VerifyJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y,m,v,E,b]=n.map(w=>{var V,$;return((V=w.value)==null?void 0:V.valueAsType)??(($=w.value)==null?void 0:$.value)});return{value:G.Success,error:null,result:await D$e(a,c,e,y,m,v,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class nLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE,version:"1.0.0",description:"JWT: decode (no verification)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(er.DecodeJwt);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)});return{value:G.Success,error:null,result:O$e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class aLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2,version:"1.0.0",description:"Password: hash (PBKDF2) -> envelope string",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Qr.HashPasswordPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y,m,v]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)});return{value:G.Success,error:null,result:await A$e(a,c,e,y,m,v)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class sLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2,version:"1.0.0",description:"Password: verify (PBKDF2) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Qr.VerifyPasswordPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=await b$e(String(a??""),String(c??""));return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class sC extends HI{constructor(p,i,n=i.projectId){super(p,X.Editor),this._editor=i,this.id=n}get ready(){return this._editor.ready}get hasLoadedLogic(){return this._editor.hasLoadedLogic}get destroyed(){return this._editor.destroyed}get logicLoadingPromise(){return this._editor.logicLoadingPromise}get logic(){return this._editor.logic}get lastPublishedProjectState(){return this._editor.lastPublishedProjectState}get branch(){return this._editor.branch}get projectId(){return this._editor.projectId}get sessionId(){return this._editor.sessionId}get userAuthorId(){return this._editor.userAuthorId}get peerConnections(){return this._editor.peerConnections}get test(){return this._editor.test}get localTestValues(){return this._editor.localTestValues}get resolvedValues(){return this._editor.resolvedValues}get persistedExecutionResults(){return this._editor.persistedExecutionResults}get publication(){return this._editor.publication}get livePublishedVersions(){return this._editor.livePublishedVersions}get publications(){return this._editor.publications}get liveResources(){return this._editor.liveResources}get execution(){return this._editor.execution}get project(){return this._editor.logic}get lastExecutionResults(){return this._editor.lastExecutionResults}get undoableStackValueIndex(){return this._editor.undoableStackValueIndex}set undoableStackValueIndex(p){this._editor.undoableStackValueIndex=p}get PROJECT_NOTIFICATIONS_CHANNEL(){return this._editor.PROJECT_NOTIFICATIONS_CHANNEL}getAccessToken(){return this._editor.getAccessToken()}removeValueByOwnerId(p){return this._editor.removeValueByOwnerId(p)}removeValue(p){return this._editor.removeValue(p)}undo(){return this._editor.undo()}redo(){return this._editor.redo()}initTest(p,i){return this._editor.initTest(p,i)}removeTest(p){return this._editor.removeTest(p)}async copyEntities(p,i={}){return this._editor.copyEntities(p,i)}resolveInitialChildrenPositions(p,i,n){return this._editor.resolveInitialChildrenPositions(p,i,n)}publish(){return this._editor.publish()}loadGivenPublication(p){return this._editor.loadGivenPublication(p)}validateProjectState(p){return this._editor.validateProjectState(p)}requestActiveDynamicValue(p,i=!1){return this._editor.requestActiveDynamicValue(p,i)}getValueTypePreference(p){return this._editor.getValueTypePreference(p)}setValueTypePreference(p,i){return this._editor.setValueTypePreference(p,i)}}function Nbi(o,p){return p instanceof sC?p:new sC(o,p)}class lC extends HI{constructor(p,i){super(p,X.PublicationRun),this._publicationRun=i}get id(){return this._publicationRun.id}get projectAutoIncrementPublicationCount(){return this._publicationRun.projectAutoIncrementPublicationCount}get projectPublishedSemanticVersion(){return this._publicationRun.projectPublishedSemanticVersion}get projectVersion(){return this._publicationRun.projectVersion}get projectId(){return this._publicationRun.projectId}get triggeredBy(){return this._publicationRun.triggeredBy}get createdAt(){return this._publicationRun.createdAt}get updatedAt(){return this._publicationRun.updatedAt}get status(){return this._publicationRun.status}get steps(){return this._publicationRun.steps}get editor(){return this._publicationRun.editor}get explicitResources(){return this._publicationRun.explicitResources}get implicitGlobalResources(){return this._publicationRun.implicitGlobalResources}get finalGlobalEvent(){return this._publicationRun.finalGlobalEvent}get finalStatus(){return this._publicationRun.finalStatus}}function xbi(o,p){return p instanceof lC?p:new lC(o,p)}function $bi(o){o.register(new QOe(o)),o.register(new XOe(o)),o.register(new WOe(o)),o.register(new JOe(o)),o.register(new YOe(o)),o.register(new zOe(o)),o.register(new MNe(o)),o.register(new BNe(o)),o.register(new GNe(o)),o.register(new jNe(o)),o.register(new kNe(o)),o.register(new UNe(o)),o.register(new _$e(o)),o.register(new V$e(o)),o.register(new P$e(o)),o.register(new N$e(o)),o.register(new x$e(o)),o.register(new $$e(o)),o.register(new L$e(o)),o.register(new M$e(o)),o.register(new B$e(o)),o.register(new G$e(o)),o.register(new LPe(o)),o.register(new MPe(o)),o.register(new BPe(o)),o.register(new GPe(o)),o.register(new kPe(o)),o.register(new jPe(o)),o.register(new UPe(o)),o.register(new KPe(o)),o.register(new FPe(o)),o.register(new SPe(o)),o.register(new qPe(o)),o.register(new ZPe(o)),o.register(new HPe(o)),o.register(new WPe(o)),o.register(new zPe(o)),o.register(new JPe(o)),o.register(new YPe(o)),o.register(new XPe(o)),o.register(new QPe(o)),o.register(new iNe(o)),o.register(new rNe(o)),o.register(new nNe(o)),o.register(new tPe(o)),o.register(new iPe(o)),o.register(new rPe(o)),o.register(new nPe(o)),o.register(new aPe(o)),o.register(new sPe(o)),o.register(new lPe(o)),o.register(new oPe(o)),o.register(new dPe(o)),o.register(new pPe(o)),o.register(new cPe(o)),o.register(new fPe(o)),o.register(new yPe(o)),o.register(new hPe(o)),o.register(new vVe(o)),o.register(new EVe(o)),o.register(new bVe(o)),o.register(new Hxe(o)),o.register(new Zxe(o)),o.register(new T_e(o)),o.register(new v_e(o)),o.register(new E_e(o)),o.register(new b_e(o)),o.register(new A_e(o)),o.register(new g_e(o)),o.register(new I_e(o)),o.register(new R_e(o)),o.register(new D_e(o)),o.register(new G_e(o)),o.register(new hVe(o)),o.register(new mVe(o)),o.register(new TVe(o)),o.register(new w_e(o)),o.register(new O_e(o)),o.register(new C_e(o)),o.register(new __e(o)),o.register(new V_e(o)),o.register(new P_e(o)),o.register(new N_e(o)),o.register(new x_e(o)),o.register(new $_e(o)),o.register(new L_e(o)),o.register(new M_e(o)),o.register(new B_e(o)),o.register(new k_e(o)),o.register(new j_e(o)),o.register(new U_e(o)),o.register(new K_e(o)),o.register(new F_e(o)),o.register(new S_e(o)),o.register(new q_e(o)),o.register(new Z_e(o)),o.register(new H_e(o)),o.register(new W_e(o)),o.register(new z_e(o)),o.register(new J_e(o)),o.register(new aVe(o)),o.register(new sVe(o)),o.register(new lVe(o)),o.register(new Y_e(o)),o.register(new X_e(o)),o.register(new Q_e(o)),o.register(new eVe(o)),o.register(new tVe(o)),o.register(new iVe(o)),o.register(new rVe(o)),o.register(new nVe(o)),o.register(new Yxe(o)),o.register(new Xxe(o)),o.register(new Qxe(o)),o.register(new e$e(o)),o.register(new Wxe(o)),o.register(new zxe(o)),o.register(new Jxe(o)),o.register(new t$e(o)),o.register(new r$e(o)),o.register(new a$e(o)),o.register(new i$e(o)),o.register(new n$e(o)),o.register(new s$e(o)),o.register(new d$e(o)),o.register(new l$e(o)),o.register(new o$e(o)),o.register(new mPe(o)),o.register(new bPe(o)),o.register(new APe(o)),o.register(new RPe(o)),o.register(new DPe(o)),o.register(new wPe(o)),o.register(new OPe(o)),o.register(new CPe(o)),o.register(new _Pe(o)),o.register(new VPe(o)),o.register(new PPe(o)),o.register(new gPe(o)),o.register(new IPe(o)),o.register(new vPe(o)),o.register(new EPe(o)),o.register(new TPe(o)),o.register(new uPe(o)),o.register(new xPe(o)),o.register(new $Pe(o)),o.register(new NPe(o)),o.register(new FNe(o)),o.register(new fxe(o)),o.register(new cxe(o)),o.register(new yxe(o)),o.register(new hxe(o)),o.register(new ZNe(o)),o.register(new HNe(o)),o.register(new QNe(o)),o.register(new YNe(o)),o.register(new uxe(o)),o.register(new nxe(o)),o.register(new sxe(o)),o.register(new oxe(o)),o.register(new lxe(o)),o.register(new XNe(o)),o.register(new txe(o)),o.register(new ixe(o)),o.register(new exe(o)),o.register(new KNe(o)),o.register(new WNe(o)),o.register(new axe(o)),o.register(new vxe(o)),o.register(new tC(o)),o.register(new qNe(o)),o.register(new zNe(o)),o.register(new SNe(o)),o.register(new dxe(o)),o.register(new JNe(o)),o.register(new rxe(o)),o.register(new pxe(o)),o.register(new Txe(o)),o.register(new mxe(o)),o.register(new Exe(o)),o.register(new tC(o)),o.register(new Axe(o)),o.register(new bxe(o)),o.register(new gxe(o)),o.register(new ENe(o)),o.register(new bNe(o)),o.register(new ANe(o)),o.register(new sNe(o)),o.register(new tNe(o)),o.register(new uNe(o)),o.register(new yNe(o)),o.register(new eNe(o)),o.register(new hNe(o)),o.register(new vNe(o)),o.register(new cNe(o)),o.register(new pNe(o)),o.register(new hA(o)),o.register(new gNe(o)),o.register(new INe(o)),o.register(new fNe(o)),o.register(new TNe(o)),o.register(new mNe(o)),o.register(new dNe(o)),o.register(new oNe(o)),o.register(new lNe(o)),o.register(new aNe(o)),o.register(new wNe(o)),o.register(new DNe(o)),o.register(new ONe(o)),o.register(new RNe(o)),o.register(new pVe(o)),o.register(new oVe(o)),o.register(new uVe(o)),o.register(new cVe(o)),o.register(new fVe(o)),o.register(new dVe(o)),o.register(new yVe(o)),o.register(new k$e(o)),o.register(new q$e(o)),o.register(new H$e(o)),o.register(new z$e(o)),o.register(new S$e(o)),o.register(new Z$e(o)),o.register(new W$e(o)),o.register(new F$e(o)),o.register(new K$e(o)),o.register(new U$e(o)),o.register(new j$e(o)),o.register(new eLe(o)),o.register(new tLe(o)),o.register(new X$e(o)),o.register(new Q$e(o)),o.register(new C$e(o)),o.register(new J$e(o)),o.register(new Y$e(o)),o.register(new rLe(o)),o.register(new iLe(o)),o.register(new nLe(o)),o.register(new aLe(o)),o.register(new sLe(o)),o.register(new tCe(o)),o.register(new iCe(o)),o.register(new fA(o)),o.register(new yA(o))}class fN{constructor(p=new J.Events("extensions-registry-fallback-events")){I(this,"extensionsRegistry",new Map);I(this,"initialized",new Set);I(this,"initializedContexts",new Set);I(this,"onResolveEditorContextCallback",()=>null);I(this,"onResolveProjectLogicContextCallback",()=>null);I(this,"onResolveEditorGUIContextCallback",()=>null);I(this,"onResolveGUIContextCallback",()=>null);I(this,"onResolveCompileContextCallback",()=>null);I(this,"onResolvePublicationRunContextCallback",()=>null);this.events=p,this.off=this.events.off.bind(this.events),this.on=this.events.on.bind(this.events),this.emit=this.events.emit.bind(this.events),this.emitAsync=this.events.emitAsync.bind(this.events),this.emitAsyncAll=this.events.emitAsyncAll.bind(this.events),this.emitAsyncAllSettled=this.events.emitAsyncAllSettled.bind(this.events),this.emitAsyncSequentially=this.events.emitAsyncSequentially.bind(this.events),this.emitAsyncSequentiallyAll=this.events.emitAsyncSequentiallyAll.bind(this.events),this.emitAsyncSequentiallyAllSettled=this.events.emitAsyncSequentiallyAllSettled.bind(this.events)}onResolveEditorContext(p){this.onResolveEditorContextCallback=p}onResolveProjectLogicContext(p){this.onResolveProjectLogicContextCallback=p}onResolveGUIContext(p){this.onResolveGUIContextCallback=p}onResolveEditorGUIContext(p){this.onResolveEditorGUIContextCallback=p}onResolveCompileContext(p){this.onResolveCompileContextCallback=p}onResolvePublicationRunContext(p){this.onResolvePublicationRunContextCallback=p}get extensionInOrder(){return Array.from(this.extensionsRegistry.values()).sort((p,i)=>(p.manifest.initPriority||Ee.Normal)-(i.manifest.initPriority||Ee.Normal))}async setup(){$bi(this),J.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(p){switch(p){case X.Editor:return this.onResolveEditorContextCallback();case X.Logic:return this.onResolveProjectLogicContextCallback();case X.EditorGUI:return this.onResolveEditorGUIContextCallback();case X.Compile:return this.onResolveCompileContextCallback();case X.PublicationRun:return this.onResolvePublicationRunContextCallback();case X.GUI:return this.onResolveGUIContextCallback();case X.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${p}`)}}requestContexts(p,i=[]){const n=[];i.length===0&&(i=p.manifest.contexts);for(const a of i){const c=this.requestContext(a);c&&n.push(c)}return n}requestExtension(p){const i=this.extensionsRegistry.get(p);if(i)return i;throw new Error(`Unknown extension: ${p}`)}register(p){this.extensionsRegistry.set(p.manifest.id,p)}async initAll(){var p,i;for(const n of this.extensionInOrder)if(n.module.init&&!this.initialized.has(n.manifest.id)){const a=n.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);a.length&&(await((i=(p=n.module).init)==null?void 0:i.call(p,a)),this.initialized.add(n.manifest.id))}else!n.module.init&&!this.initialized.has(n.manifest.id)&&this.initialized.add(n.manifest.id)}async initForReady(){J.Logger.log("Initializing extensions for ready contexts...");for(const p of this.extensionInOrder)if(p.module.init&&!this.initialized.has(p.manifest.id)){J.Logger.log("Initializing "+p.manifest.id+" extension...");const i=this.requestContexts(p);p.manifest.contexts.every(a=>!!i.find(c=>c.contextType===a))?(await p.module.init(i),this.initialized.add(p.manifest.id)):J.Logger.warn(`Skipping initialization of ${p.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${p.manifest.contexts.join(", ")}`,`Available contexts: ${i.map(a=>a.contextType).join(", ")}`)}else!p.module.init&&!this.initialized.has(p.manifest.id)?(J.Logger.log("Set "+p.manifest.id+" extension as initialized by default..."),this.initialized.add(p.manifest.id)):J.Logger.log(`Skipping initialization of ${p.manifest.id} extension, already initialized or no init method defined.`)}async destroyAll(){for(const p of[...this.extensionInOrder].reverse())p.module.destroy&&await p.module.destroy();this.events.destroy()}on(p,i){this.events.on(p,i)}emit(p,...i){this.events.emit(p,...i)}off(p,i){this.events.off(p,i)}emitAsync(p,...i){return this.events.emitAsync(p,...i)}emitAsyncAll(p,...i){return this.events.emitAsyncAll(p,...i)}emitAsyncAllSettled(p,...i){return this.events.emitAsyncAllSettled(p,...i)}emitAsyncSequentially(p,...i){return this.events.emitAsyncSequentially(p,...i)}emitAsyncSequentiallyAll(p,...i){return this.events.emitAsyncSequentiallyAll(p,...i)}emitAsyncSequentiallyAllSettled(p,...i){return this.events.emitAsyncSequentiallyAllSettled(p,...i)}async contextAvailable(p){if(this.initializedContexts.has(p)){J.Logger.warn(`Context ${p} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(p),p){case X.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case X.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}J.Logger.log(`Context ${p} is now available. Initializing extensions for this context...`),await this.initForReady()}getValueTypePreference(p){return window.localStorage.getItem("dynamic-value-type-preference--"+p)||null}setValueTypePreference(p,i){window.localStorage.setItem("dynamic-value-type-preference--"+p,(i==null?void 0:i.toString())||""),this.emit(p,{})}}let Lb=null;const yN={requestExtension:o=>(Lb||(Lb=new fN,Lb.setup()),Lb.requestExtension(o))},bu={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var hN=(o=>(o.FinishedSuccess="finished-success",o.FinishedError="finished-error",o.Running="running",o.Paused="paused",o.Stopped="stopped",o.NotStarted="not-started",o))(hN||{});const lLe={...yN,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class Ru extends J.Events{constructor(i,n,a,c=null,e=lLe){super();I(this,"project");I(this,"entryPoint");I(this,"state","not-started");I(this,"events",new J.Events("fe-exec-inst-events"));I(this,"entities",[]);I(this,"parentExecution",null);I(this,"executing",[]);I(this,"executed",[]);I(this,"skipped",[]);I(this,"scheduled",[]);I(this,"localTestValues");I(this,"resolvedValues");I(this,"persistedExecutionResults");I(this,"lastExecutionResults");I(this,"onAddToSkippedListCallback",null);I(this,"onRemoveFromSkippedListCallback",null);I(this,"onAddEntityCallback",null);I(this,"onRemoveEntityCallback",null);I(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=n,this.entryPoint=a,this.project=i,this.parentExecution=c,this.localTestValues=new Nm(x.UUID.uuid(),this.project),this.resolvedValues=new Nm(x.UUID.uuid(),this.project),this.persistedExecutionResults=new Nm(x.UUID.uuid(),this.project),this.lastExecutionResults=new Nm(x.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults,getValueTypePreference:this.parentContext.getValueTypePreference,setValueTypePreference:this.parentContext.setValueTypePreference}}skip(i){this.hasEntity(i)&&(this.removeFromScheduledList(i),!this.skipped.includes(i)&&(this.skipped.push(i),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(i),Zr.includes(i.type)&&Rt(i).forEach(n=>this.skip(n))))}async schedule(i,n,a){if(this.hasExecuted(i))return null;if(Yt.includes(i.type))return this.executeBranch(i,a,n);if(qr.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,a,n);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,n){const a=[];return[...ei,...Yt].includes(n.type)?a.push(...n.inputs):Ut.includes(n.type)&&a.push(...n.outputs),a.map(e=>{var m;let y=i.find(v=>v.valueOwner.id===e.id);if(y)return y;if(!y&&Yt.includes(n.type)&&(y=i.find(v=>{var E;return((E=v.valueOwner.declaration)==null?void 0:E.id)===e.id})),y){const v=(m=y.value)==null?void 0:m.clone(null);return v==null||v.setStandaloneParent(e,null),{...y,valueOwner:e,value:v||null,inheritanceLink:{sources:[y],target:e}}}return Ma.includes(e.type)?Io(e,this.valueResolutionContext):_c(e,this.valueResolutionContext)}).reduce((e,y)=>{const m=_o(y==null?void 0:y.valueOwner,this.project),v=y?[y]:[];return m.forEach(E=>{var V,$,M;if(E.id===(y==null?void 0:y.valueOwner.id))return;const b=It(E.getDataType(null),E,this.project);b==null||b.metaSync({value:(V=y==null?void 0:y.value)==null?void 0:V.value},null),b==null||b.setValueAsTypeList((($=y==null?void 0:y.value)==null?void 0:$.valueAsTypeList)||null),b==null||b.setValueAsTypeSingle(((M=y==null?void 0:y.value)==null?void 0:M.valueAsTypeSingle)||null);const w={...y,valueOwner:E,value:b};v.push(w)}),[...e,...v]},[]).sort((e,y)=>e.valueOwner.index-y.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,n,a,c={}){var y,m;const e={...bu,...c};try{let v={value:G.Success,error:null,result:null};if(n.sort((E,b)=>E.valueOwner.index-b.valueOwner.index),Object.values(vr).includes(i.declaration.id)){const E=this.parentContext.requestExtension(cy+i.declaration.id).module.main;E?v=await E(i,n):J.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{v=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,n,a,e);let E=null;if(v.error){J.Logger.warn("Raw error executing entity: ",v.error);const b=(y=i.error)==null?void 0:y.getDataType(null),w=It(b||null,i.error,a);b!=null&&b.asType?w==null||w.setValueAsTypeSingle(v.error):w==null||w.metaSync({value:v.error},null),E={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:w}}return{value:v.value,entity:i,error:E,result:{value:v.result||null,valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null}}}return{...v,entity:i}}catch(v){J.Logger.warn("Internal call execution error: ",v);let E=null;if(i.error){const b=(m=i.error)==null?void 0:m.getDataType(null),w=It(b,i.error,a);b!=null&&b.asType?w==null||w.setValueAsTypeSingle(v):w==null||w.metaSync({value:v},null),E={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:w}}return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:E,result:null}}}static async executeOperation(i,n,a){var c,e;try{let y={value:G.Success,error:null,result:null};n.sort((b,w)=>b.valueOwner.index-w.valueOwner.index),i.declaration.implementation&&(y=await i.declaration.implementation(i,n));let m=null;if(y.error&&i.error){J.Logger.warn("Raw error executing entity: ",y.error);const b=((c=i.error)==null?void 0:c.getDataType(null))||null,w=It(b,i.error,a);b!=null&&b.asType?w==null||w.setValueAsTypeSingle(y.error):w==null||w.metaSync({value:y.error},null),m={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:w}}const v=i==null?void 0:i.getDataType(null),E=It(v,i,a);return v!=null&&v.asType?E==null||E.setValueAsTypeSingle(y.result):E==null||E.metaSync({value:y.result},null),{value:y.value,entity:i,error:m,result:{value:E||null,valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null}}}catch(y){J.Logger.warn("Operation execution error: ",y);let m=null;if(i.error){const v=(e=i.error)==null?void 0:e.getDataType(null),E=It(v,i.error,a);v!=null&&v.asType?E==null||E.setValueAsTypeSingle(y):E==null||E.metaSync({value:y},null),m={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:E}}return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:m,result:null}}}async executeSearch(i,n,a){var c;try{let e={value:G.Success,error:null,result:null};const y=await(await this.parentContext.requestExtension(Ae.SEARCH_NODE_IMPLEMENTATION)).module.main(i,n),m=i==null?void 0:i.getDataType(null),v=It(m,i,a);return v==null||v.metaSync({value:y},null),y.error?{value:G.UnhandledError,entity:i,error:{valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null,value:v},result:null}:{value:e.value,entity:i,error:null,result:{value:v,valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null}}}catch(e){if(J.Logger.warn(`Search node execution error: ${e}`),!i.error)return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null};const y=(c=i.error)==null?void 0:c.getDataType(null),m=It(y,i.error,a);return m==null||m.metaSync({value:e},null),{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:{valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:m},result:null}}}async executeLoop(i,n,a,c={}){var y,m,v,E,b,w;const e={...bu,...c};try{let V={value:G.Success,error:null,result:null};const $=n.map(ie=>{var ee,de;return((ee=ie==null?void 0:ie.value)==null?void 0:ee.valueAsType)||((de=ie==null?void 0:ie.value)==null?void 0:de.value)});let M={};i.getUniqueInputMaps().forEach(ie=>{const ee=i.body.inputs.find(ve=>le(ve,a)===le(ie,a)),de=ie==null?void 0:ie.getDataType(null),ae=It(de,ee,a);de!=null&&de.asType?ae==null||ae.setValueAsTypeList([]):ae==null||ae.metaSync({value:[]},null),this.lastExecutionResults.writeValue(ee,ae);const fe={value:ae,valueOwner:ee,type:Ne.ExecutionResult,inheritanceLink:null};M[ee.id]=fe});let F={value:G.Success,entity:i.body,error:null,result:null};switch(i.declaration.id){case Q.loop["counted-loop"].id:{const ie=$[0];let ee=1;for(;ee<=ie&&ee<=50;){const de=i.body.inputs.map(ae=>{if(ae===i.currentIterationNumberArgumentDeclaration){const fe=i.currentIterationNumberArgumentDeclaration.getDataType(null),ve=Tc(fe),ue=this.lastExecutionResults.readValue(ae.id);if(ue){ue.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ae,ue);const xe={value:ue,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null};return M[ae.id]=xe,xe}const ye={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:ee,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ve,standaloneParent:ae.toReference()},Ve=Si(ye,a);this.lastExecutionResults.writeValue(ae,Ve);const _e={value:Ve,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null};return M[ae.id]=_e,_e}else return M[ae.id]}).filter(ae=>!!ae);if(F=await this.executeFullFunctionDeclarationLogic(i.body,de,e),(F.results||[]).forEach(ae=>{var ye,Ve,_e,xe;if(ae.valueOwner.type!==d.InputMap||Ut.includes(ae.valueOwner.parent.type))return;const fe=i.body.inputs.find(Pe=>le(Pe,a)===le(ae.valueOwner,a)),ue=[...((Ve=(ye=M==null?void 0:M[fe.id])==null?void 0:ye.value)==null?void 0:Ve.value)||[],((_e=ae==null?void 0:ae.value)==null?void 0:_e.value)||null];(xe=M[fe.id].value)==null||xe.metaSync({value:ue},null),this.lastExecutionResults.writeValue(fe,M[fe.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ee++}break}case Q.loop["manual-flow-loop"].id:{let ie=1;for(;ie<=50;){const ee=i.body.inputs.map(de=>{if(de===i.currentIterationNumberArgumentDeclaration){const ae=this.lastExecutionResults.readValue(de.id);if(ae){ae.metaSync({value:ie},null),this.lastExecutionResults.writeValue(de,ae);const ye={value:ae,valueOwner:de,type:Ne.ExecutionResult,inheritanceLink:null};return M[de.id]=ye,ye}const fe=i.currentIterationNumberArgumentDeclaration.getDataType(null),ve=It(fe,de,a);return ve==null||ve.metaSync({value:ie},null),this.lastExecutionResults.writeValue(de,ve),{value:ve,valueOwner:de,type:Ne.ExecutionResult,inheritanceLink:null}}else return M[de.id]}).filter(de=>!!de);if(F=await this.executeFullFunctionDeclarationLogic(i.body,ee,e),(F.results||[]).forEach(de=>{var ue,ye,Ve;if(de.valueOwner.type!==d.InputMap||Ut.includes(de.valueOwner.parent.type))return;const ae=i.body.inputs.find(_e=>le(_e,a)===le(de.valueOwner,a)),ve=[...(ue=M[ae.id].value)==null?void 0:ue.value,((ye=de.value)==null?void 0:ye.value)||null];(Ve=M[ae.id].value)==null||Ve.metaSync({value:ve},null),this.lastExecutionResults.writeValue(ae,M[ae.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ie++}break}case Q.loop["list-loop"].id:{const ie=$[0];let ee=1;const de=ie;for(let ae=0;ae<de.length;ae++){const fe=de[ae],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,a);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=Tc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const xe={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Pe=Si(xe,a);return this.lastExecutionResults.writeValue(ue,Pe),{value:Pe,valueOwner:i.currentValueArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else return M[ue.id]}).filter(ue=>!!ue);if(F=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(F.results||[]).forEach(ue=>{var xe,Pe,Be;if(ue.valueOwner.type!==d.InputMap||Ut.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>le(Se,a)===le(ue.valueOwner,a)),_e=[...(xe=M[ye.id].value)==null?void 0:xe.value,((Pe=ue.value)==null?void 0:Pe.value)||null];(Be=M[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,M[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ee++}break}case Q.loop["object-keys-loop"].id:{const ie=$[0];let ee=1;const de=ie?Object.keys(ie):[];for(let ae=0;ae<de.length;ae++){const fe=de[ae],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,a);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=Tc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const xe={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Pe=Si(xe,a);return this.lastExecutionResults.writeValue(ue,Pe),{value:Pe,valueOwner:i.currentValueArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else return M[ue.id]}).filter(ue=>!!ue);if(F=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(F.results||[]).forEach(ue=>{var xe,Pe,Be;if(ue.valueOwner.type!==d.InputMap||Ut.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>le(Se,a)===le(ue.valueOwner,a)),_e=[...(xe=M[ye.id].value)==null?void 0:xe.value,((Pe=ue.value)==null?void 0:Pe.value)||null];(Be=M[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,M[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ee++}break}case Q.loop["object-values-loop"].id:{const ie=$[0];let ee=1;const de=ie?Object.values(ie):[];for(let ae=0;ae<de.length;ae++){const fe=de[ae],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,a);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=Tc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const xe={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Pe=Si(xe,a);return this.lastExecutionResults.writeValue(ue,Pe),{value:Pe,valueOwner:i.currentValueArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else return M[ue.id]}).filter(ue=>!!ue);if(F=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(F.results||[]).forEach(ue=>{var xe,Pe,Be;if(ue.valueOwner.type!==d.InputMap||Ut.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>le(Se,a)===le(ue.valueOwner,a)),_e=[...(xe=M[ye.id].value)==null?void 0:xe.value,((Pe=ue.value)==null?void 0:Pe.value)||null];(Be=M[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,M[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ee++}break}case Q.loop["string-loop"].id:{const ie=$[0];let ee=1;const de=ie.split("");for(let ae=0;ae<de.length;ae++){const fe=de[ae],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,a);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=Tc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const xe={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Pe=Si(xe,a);return this.lastExecutionResults.writeValue(ue,Pe),{value:Pe,valueOwner:i.currentValueArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else return M[ue.id]}).filter(ue=>!!ue);if(F=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(F.results||[]).forEach(ue=>{var xe,Pe,Be;if(ue.valueOwner.type!==d.InputMap||Ut.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>le(Se,a)===le(ue.valueOwner,a)),_e=[...(xe=M[ye.id].value)==null?void 0:xe.value,((Pe=ue.value)==null?void 0:Pe.value)||null];(Be=M[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,M[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ee++}break}}if(V={value:[G.CaughtError,G.Return].includes(F.value)?F.value:G.Success,error:((m=(y=F.error)==null?void 0:y.value)==null?void 0:m.value)||null,result:((E=(v=F==null?void 0:F.result)==null?void 0:v.value)==null?void 0:E.value)||null},V.error&&i.error){const ie=(b=i.error)==null?void 0:b.getDataType(null),ee=It(ie||null,i.error,a);ie!=null&&ie.asType?ee==null||ee.setValueAsTypeSingle(V.error):ee==null||ee.metaSync({value:V.error},null);const de={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:ee};return{value:V.value,entity:i,error:de,result:null}}const U=i==null?void 0:i.getDataType(null),Y=It(U,i,a);return U!=null&&U.asType?Y==null||Y.setValueAsTypeSingle(V.result):Y==null||Y.metaSync({value:V.result},null),{value:V.value,entity:i,error:null,result:{value:Y||null,valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null}}}catch(V){if(J.Logger.warn("Error executing loop: ",V),i.error){const $=(w=i.error)==null?void 0:w.getDataType(null),M=It($,i.error,a);return $!=null&&$.asType?M==null||M.setValueAsTypeSingle(V):M==null||M.metaSync({value:V},null),{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:{valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:M},result:null}}else return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null}}}async executeFunctionCall(i,n,a,c={}){var y,m,v,E,b,w,V,$,M,k,F,U,Y,ie,ee,de,ae,fe,ve,ue,ye,Ve,_e,xe,Pe,Be;const e={...bu,...c};try{const Se=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,n,a,e);let je=null;if(Se.error&&i.error){J.Logger.warn("Raw error executing entity: ",Se.error);const ut=(y=i.error)==null?void 0:y.getDataType(null),_t=It(ut||null,i.error,a);ut!=null&&ut.asType?(v=(m=Se.error)==null?void 0:m.value)!=null&&v.valueAsTypeSingle?_t==null||_t.setValueAsTypeSingle((b=(E=Se.error)==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle):(V=(w=Se.error)==null?void 0:w.value)!=null&&V.valueAsTypeList&&Array.isArray((M=($=Se.error)==null?void 0:$.value)==null?void 0:M.valueAsTypeList)&&(_t==null||_t.setValueAsTypeList((F=(k=Se.error)==null?void 0:k.value)==null?void 0:F.valueAsTypeList)):_t==null||_t.metaSync({value:(Y=(U=Se.error)==null?void 0:U.value)==null?void 0:Y.value},null),je={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:_t}}let Ze=G.Success;Se.value===G.UnhandledError&&(i.catchesError||i.errorCalls.length?Ze=G.CaughtError:Ze=G.UnhandledError);const Ye=i==null?void 0:i.getDataType(null),lt=It(Ye,i,a);return Ye!=null&&Ye.asType?(ee=(ie=Se.result)==null?void 0:ie.value)!=null&&ee.valueAsTypeSingle?lt==null||lt.setValueAsTypeSingle((ae=(de=Se.result)==null?void 0:de.value)==null?void 0:ae.valueAsTypeSingle):(ve=(fe=Se.result)==null?void 0:fe.value)!=null&&ve.valueAsTypeList&&Array.isArray((ye=(ue=Se.result)==null?void 0:ue.value)==null?void 0:ye.valueAsTypeList)&&(lt==null||lt.setValueAsTypeList((_e=(Ve=Se.result)==null?void 0:Ve.value)==null?void 0:_e.valueAsTypeList)):lt==null||lt.metaSync({value:((Pe=(xe=Se.result)==null?void 0:xe.value)==null?void 0:Pe.value)||null},null),{value:Ze,entity:i,error:je,result:{value:lt||null,valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null}}}catch(Se){if(!i.error)return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null};const je=(Be=i.error)==null?void 0:Be.getDataType(null),Ze=It(je,i.error,a);return je!=null&&je.asType?Ze==null||Ze.setValueAsTypeSingle(Se):Ze==null||Ze.metaSync({value:Se},null),{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:{valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:Ze},result:null}}}async executeCondition(i,n){var c,e,y,m;let a=!1;switch(i.declaration.id){case en.BooleanIsTrue:{const v=(e=(c=n[0])==null?void 0:c.value)==null?void 0:e.value;if(typeof v!="boolean")throw new TypeError("BooleanIsTrue expects a boolean input.");a=v===!0;break}case en.BooleanIsFalse:{const v=(m=(y=n[0])==null?void 0:y.value)==null?void 0:m.value;if(typeof v!="boolean")throw new TypeError("BooleanIsFalse expects a boolean input.");a=v===!1;break}case or.And:{a=(await Promise.all(i.andChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(n,E);return(await this.executeCondition(E,b)).value===G.Success}))).every(E=>E);break}case or.Or:{a=(await Promise.all(i.orChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(n,E);return(await this.executeCondition(E,b)).value===G.Success}))).some(E=>E);break}default:throw new Error(`Condition declaration ${i.declaration.name} does not have an implementation.`)}return{value:a?G.Success:G.ConditionNotMet,entity:i,error:null,result:null}}async executeDetachedFullFunctionDeclarationLogic(i,n,a,c={}){const e={...bu,...c,onBeforeEntityExecution:(v,E,b)=>{var w;return((w=c==null?void 0:c.onBeforeEntityExecution)==null?void 0:w.call(c,v,E,{...b,detached:!0}))||Promise.resolve()},onEntityExecuted:(v,E,b)=>{var w;return((w=c==null?void 0:c.onEntityExecuted)==null?void 0:w.call(c,v,E,{...b,detached:!0}))||Promise.resolve()}},y=new Ru(a,[i,...PA(i)],i,this,this.parentContext);return y.inheritValuesFromContext(this),await y.execute(e,n)}async executeFullFunctionDeclarationLogic(i,n,a={}){const c={...bu,...a},e=PA(i);e.forEach(v=>{this.addEntity(v)}),e.reduce((v,E)=>Ut.includes(E.type)?[...v,...E.outputs]:ei.includes(E.type)&&E.type!==d.Condition?[...v,...E.outputs,...E.inputs]:E.type===d.Condition?[...v,...E.inputs]:v,[]).forEach(v=>{this.lastExecutionResults.removeValue(v.id)});const m=await this.executeBranch(i,c,n);return{...m||{},value:(m==null?void 0:m.value)||G.Success,entity:i,error:(m==null?void 0:m.error)||null,result:(m==null?void 0:m.result)||null}}static async executeEntryPointEntity(i,n){return{value:G.Success,entity:i,error:null,result:null}}async executeReturnStatement(i,n){var y,m,v,E,b,w,V;if((y=i.throws)!=null&&y.readsValue){const $=Io(i.throws,this.valueResolutionContext);return{value:G.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Ne.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Io(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((m=c==null?void 0:c.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)yr((v=a==null?void 0:a.value)==null?void 0:v.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const M=It(c,i,this.project);M==null||M.metaSync({value:$},null),a={valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null,value:M}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(M=>{var k,F;if(((k=M.declaration)==null?void 0:k.type)===d.Property&&M.declaration.static){const U=this.lastExecutionResults.readValue(M.declaration.id),Y=le(M,this.project),ie=M.codeName||((F=M.declaration)==null?void 0:F.codeName)||Hi(Y);if(U)U.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,U);else{const ee=It(M.getDataType(null),M,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&yr((w=a.value)==null?void 0:w.value)?((V=a.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var U;const M=$.codeName||((U=$.declaration)==null?void 0:U.codeName)||Hi(le($,this.project)),k=e[M],F=It($.getDataType(null),$,this.project);F==null||F.metaSync({value:k},null),Ne.ExecutionResult}),a.type=Ne.ExecutionResult,{value:G.Return,entity:i,error:null,result:a}}async executeContinueStatement(i,n){var y,m,v,E,b,w,V;if((y=i.throws)!=null&&y.readsValue){const $=Io(i.throws,this.valueResolutionContext);return{value:G.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Ne.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Io(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((m=c==null?void 0:c.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)yr((v=a==null?void 0:a.value)==null?void 0:v.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const M=It(c,i,this.project);M==null||M.metaSync({value:$},null),a={valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null,value:M}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(M=>{var k,F;if(((k=M.declaration)==null?void 0:k.type)===d.Property&&M.declaration.static){const U=this.lastExecutionResults.readValue(M.declaration.id),Y=le(M,this.project),ie=M.codeName||((F=M.declaration)==null?void 0:F.codeName)||Hi(Y);if(U)U.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,U);else{const ee=It(M.getDataType(null),M,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&yr((w=a.value)==null?void 0:w.value)?((V=a.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var U;const M=$.codeName||((U=$.declaration)==null?void 0:U.codeName)||Hi(le($,this.project)),k=e[M],F=It($.getDataType(null),$,this.project);F==null||F.metaSync({value:k},null),Ne.ExecutionResult}),a.type=Ne.ExecutionResult,{value:G.Continue,entity:i,error:null,result:a}}async executeBreakStatement(i,n){var y,m,v,E,b,w,V;if((y=i.throws)!=null&&y.readsValue){const $=Io(i.throws,this.valueResolutionContext);return{value:G.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Ne.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Io(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((m=c==null?void 0:c.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)yr((v=a==null?void 0:a.value)==null?void 0:v.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const M=It(c,i,this.project);M==null||M.metaSync({value:$},null),a={valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null,value:M}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(M=>{var k,F;if(((k=M.declaration)==null?void 0:k.type)===d.Property&&M.declaration.static){const U=this.lastExecutionResults.readValue(M.declaration.id),Y=le(M,this.project),ie=M.codeName||((F=M.declaration)==null?void 0:F.codeName)||Hi(Y);if(U)U.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,U);else{const ee=It(M.getDataType(null),M,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&yr((w=a.value)==null?void 0:w.value)?((V=a.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var U;const M=$.codeName||((U=$.declaration)==null?void 0:U.codeName)||Hi(le($,this.project)),k=e[M],F=It($.getDataType(null),$,this.project);F==null||F.metaSync({value:k},null),Ne.ExecutionResult}),a.type=Ne.ExecutionResult,{value:G.Break,entity:i,error:null,result:a}}async executeVariable(i,n){var m,v,E,b,w,V;let a=Io(i,this.valueResolutionContext);const c=Hn(i),e=c.getDataType(null);if(e!=null&&e.isObject()){let $={};if(((m=e==null?void 0:e.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...e.entity.getActiveRawDefaultValue()}),a!=null&&a.value)yr((v=a==null?void 0:a.value)==null?void 0:v.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const M=It(e,i,this.project);M==null||M.metaSync({value:$},null),a={valueOwner:c,type:Ne.ExecutionResult,inheritanceLink:null,value:M}}this.lastExecutionResults.writeValue(c,a.value),c.inputs.forEach(M=>{var k,F;if(((k=M.declaration)==null?void 0:k.type)===d.Property&&M.declaration.static){const U=this.lastExecutionResults.readValue(M.declaration.id),Y=le(M,this.project),ie=M.codeName||((F=M.declaration)==null?void 0:F.codeName)||Hi(Y);if(U)U.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,U);else{const ee=It(M.getDataType(null),M,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,ee)}}})}else this.lastExecutionResults.writeValue(c,a==null?void 0:a.value);const y=(b=a==null?void 0:a.value)!=null&&b.value&&yr((w=a.value)==null?void 0:w.value)?((V=a.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var U;const M=$.codeName||((U=$.declaration)==null?void 0:U.codeName)||Hi(le($,this.project)),k=y[M],F=It($.getDataType(null),$,this.project);F==null||F.metaSync({value:k},null),Ne.ExecutionResult}),a.type=Ne.ExecutionResult,{value:G.Success,entity:i,error:null,result:a}}mergeValues(i,n){const a=[];for(let c=0;c<n.length;c++)i!=null&&i[c]?a.push(i[c]):a.push(n[c]);return a}async executeEntity(i,n=[],a={}){var y,m,v,E,b,w,V,$,M,k,F;const c={...bu,...a},e={detached:!1};switch(i.type){case d.Condition:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((y=c.onBeforeEntityExecution)==null?void 0:y.call(c,i,U,e)),this.executeCondition(i,U)}case d.InternalCall:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((m=c.onBeforeEntityExecution)==null?void 0:m.call(c,i,U,e)),this.executeInternalCall(i,U,this.project)}case d.Operation:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((v=c.onBeforeEntityExecution)==null?void 0:v.call(c,i,U,e)),Ru.executeOperation(i,U,this.project)}case d.VariableInstance:case d.VariableDeclaration:return this.executeVariable(i,n);case d.FunctionCall:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((E=c.onBeforeEntityExecution)==null?void 0:E.call(c,i,U,e)),this.executeFunctionCall(i,U,this.project)}case d.FunctionDeclaration:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((b=c.onBeforeEntityExecution)==null?void 0:b.call(c,i,U,e)),Ru.executeEntryPointEntity(i,U)}case d.Search:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((w=c.onBeforeEntityExecution)==null?void 0:w.call(c,i,U,e)),this.executeSearch(i,U,this.project)}case d.Loop:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((V=c.onBeforeEntityExecution)==null?void 0:V.call(c,i,U,e)),this.executeLoop(i,U,this.project,c)}case d.ReturnStatement:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await(($=c.onBeforeEntityExecution)==null?void 0:$.call(c,i,U,e)),this.executeReturnStatement(i,U)}case d.ContinueStatement:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((M=c.onBeforeEntityExecution)==null?void 0:M.call(c,i,U,e)),this.executeContinueStatement(i,U)}case d.BreakStatement:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((k=c.onBeforeEntityExecution)==null?void 0:k.call(c,i,U,e)),this.executeBreakStatement(i,U)}case d.GlobalEvent:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((F=c.onBeforeEntityExecution)==null?void 0:F.call(c,i,U,e)),Ru.executeEntryPointEntity(i,U)}default:throw new Error(`Entity type ${i==null?void 0:i.type} is not recognized for execution.`)}}storeLastExecutionValues(i){var a,c,e;if(i.error&&i.error.valueOwner&&this.lastExecutionResults.writeValue(i.error.valueOwner,i.error.value),!i.result||!((a=i.result)!=null&&a.valueOwner))return;const n=_o((c=i.result)==null?void 0:c.valueOwner,this.project);(e=i.result)!=null&&e.value?n.forEach(y=>{var m;this.lastExecutionResults.writeValue(y,(m=i.result)==null?void 0:m.value)}):n.forEach(y=>{this.lastExecutionResults.removeValue(y.id)})}async executeBranch(i,n={},a=[]){var v;const c={...bu,...n},e={detached:!1};if(!this.hasEntity(i)||this.hasSkipped(i))return null;this.addToExecutingList(i),this.hasScheduled(i)&&this.removeScheduled(i);const m=await this.executeEntity(i,a,c);if(this.removeFromExecutingList(i),this.addToAlreadyExecutedList(i),this.storeLastExecutionValues(m),await((v=c.onEntityExecuted)==null?void 0:v.call(c,i,m,e)),m.value===G.Success){const E=(i.successCalls||i.calls||[]).filter(M=>this.hasEntity(M));(i.errorCalls||[]).forEach(M=>{this.skip(M)});let w=[];const V=(await Promise.all(E.map(M=>this.schedule(M,[],c)))).filter(M=>!!M),$=V.filter(M=>!!M).find(M=>M.value===G.CaughtError||M.value===G.Return||M.value===G.Break||M.value===G.Continue);return $||(w=[...w,...V],m)}else if(m.value===G.CaughtError||m.value===G.ConditionNotMet){const E=(i.errorCalls||[]).filter(M=>this.hasEntity(M));(i.successCalls||i.calls||[]).forEach(M=>{this.skip(M)});let w=[];const V=(await Promise.all(E.map(M=>this.schedule(M,[],c)))).filter(M=>!!M),$=V.filter(M=>!!M).find(M=>M.value===G.CaughtError||M.value===G.UnhandledError||M.value===G.Return||M.value===G.Break||M.value===G.Continue);return $||(w=[...w,...V],m)}else{if(m.value===G.UnhandledError)return this.executing.forEach(E=>{this.skip(E)}),this.scheduled.forEach(E=>{this.skip(E)}),Zr.includes(m.entity.type)&&Rt(m.entity).forEach(E=>{this.skip(E)}),m;if(m.value===G.Return)return m;if(m.value===G.Break)return m;if(m.value===G.Continue)return m}return m}async execute(i={},n=[]){const a={...bu,...i};this.state="running";const c=await this.executeBranch(this.entryPoint,a,n);return this.state="finished-success",c}addEntity(i){var n;this.entities.includes(i)||(this.entities.push(i),(n=this.onAddEntityCallback)==null||n.call(this,i,{}))}async addEntityAsync(i,n={}){var a;this.entities.includes(i)||(this.entities.push(i),await((a=this.onAddEntityCallback)==null?void 0:a.call(this,i,n)))}addEntities(i){i.forEach(n=>this.addEntity(n))}async addEntitiesAsync(i,n={}){const a=J.YieldTracker.from(n),c=[];for(const e of i)c.push(this.addEntityAsync(e,n)),await a.tick();await Promise.all(c)}removeEntity(i){var n;if(i!==this.entryPoint){const a=this.entities.indexOf(i);a>-1&&(this.entities.splice(a,1),(n=this.onRemoveEntityCallback)==null||n.call(this,i,{}))}}hasEntity(i){var c,e,y;if(this.entities.includes(i))return!0;if(((c=i.parent)==null?void 0:c.type)===d.FunctionDeclaration&&((y=(e=i.parent)==null?void 0:e.parent)==null?void 0:y.type)===d.DefinitionEntity)return this.entities.includes(i.parent);const n=oi(i);if(!n)return!1;const a=n.type===d.Loop&&i.parent===n.body?n.body:null;return a?this.entities.includes(a)||this.entities.includes(n):this.entities.includes(n)}removeScheduled(i){const n=this.scheduled.indexOf(i);n>-1&&this.scheduled.splice(n,1)}hasScheduled(i){return!!this.scheduled.includes(i)}hasSkipped(i){return!!this.skipped.includes(i)}hasExecuted(i){return!!this.executed.includes(i)}hasEntityWithId(i){const n=this.project.get(i);return n?this.hasEntity(n):!1}onAddToSkippedList(i){this.onAddToSkippedListCallback=i}onAbortExecution(i){this.onAbortExecutionCallback=i}onAddEntity(i){this.onAddEntityCallback=i}onRemoveFromSkippedList(i){this.onRemoveFromSkippedListCallback=i}onRemoveEntity(i){this.onRemoveEntityCallback=i}addToExecutingList(i){this.executing.includes(i)||this.executing.push(i)}addToScheduledList(i){this.scheduled.includes(i)||this.scheduled.push(i)}removeFromScheduledList(i){const n=this.scheduled.indexOf(i);n>-1&&this.scheduled.splice(n,1)}removeFromExecutingList(i){var a;const n=this.executing.indexOf(i);n>-1&&(this.executing.splice(n,1),(a=this.onAbortExecutionCallback)==null||a.call(this,i,{}))}removeFromAlreadyExecutedList(i){const n=this.executed.indexOf(i);n>-1&&this.executed.splice(n,1)}removeFromSkippedList(i){var a;const n=this.skipped.indexOf(i);n>-1&&(this.skipped.splice(n,1),(a=this.onRemoveFromSkippedListCallback)==null||a.call(this,i,{}))}addToAlreadyExecutedList(i){this.executed.includes(i)||this.executed.push(i)}addToSkippedList(i){var n;this.skipped.includes(i)||(this.skipped.push(i),(n=this.onAddToSkippedListCallback)==null||n.call(this,i,{}))}getValueTypePreference(i){return this.parentContext.getValueTypePreference(i)||null}setValueTypePreference(i,n){this.parentContext.setValueTypePreference(i,n),this.emit(i,{})}}function Lbi(o){var p,i;if(o.isList)return"list";if(((p=o.entity)==null?void 0:p.type)===d.DefinitionEntity)return"definition-entity";switch((i=o.entity)==null?void 0:i.name){case oe.Number:return"number";case oe.String:return"text";case oe.Boolean:return"boolean";case oe.UUID:return"uuid";case oe.Date:return"date-time";default:return"definition-entity"}}const as={[d.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[d.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[d.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[d.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[d.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[d.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[d.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[d.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[d.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[d.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[d.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[d.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[d.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[d.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[d.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[d.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[d.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[d.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[d.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[d.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"},[d.DataType]:{singular:"Data type",plural:"Data types",shortSingular:"Data type",shortPlural:"Data types"},[d.LiteralValue]:{singular:"Literal value",plural:"Literal values",shortSingular:"Value",shortPlural:"Values"}};function mN(o){const p=$R(o);if(!p){const n=Ly(o);if(n.includes(Re.HTTP_ENDPOINT))return"HTTP endpoint";if(n.includes(Re.PERSISTED_ENTITY))return"Persisted entity";if(n.includes(Re.CRON_JOB))return"Scheduled execution";if(n.includes(Re.RELATIONAL_DATABASE))return"Relational database"}if(p){let n="Extension of "+le(p,p.project)+" entity",a=Co(n);const c=Ly(o);return c.includes(Re.HTTP_ENDPOINT)?"HTTP endpoint"+(a?", "+a:""):c.includes(Re.PERSISTED_ENTITY)?"Persisted entity"+(a?", "+a:""):c.includes(Re.CRON_JOB)?"Scheduled execution"+(a?", "+a:""):c.includes(Re.RELATIONAL_DATABASE)?"Relational database"+(a?", "+a:""):n}let i="";return o.abstract&&(i="Template "),o.static&&(i+=i?" single copy ":"Single copy "),i?i+"definition":"Definition"}function oLe(o){return o.parent.type===d.DefinitionEntity||o.parent.type===d.InstalledProject?"Internal action of "+le(o.parent,o.project):o.parent.type===d.Loop?"Action repeated on every iteration":"Internal action of entity"}function TN(o){return hx(o)?oLe(o):"Custom trigger"}function Mbi(o){var p;switch(o.type){case d.DefinitionEntity:return mN(o);case d.FunctionDeclaration:return TN(o)}return(p=as[o.type])==null?void 0:p.singular}function Bbi(o){var p;switch(o.type){case d.DefinitionEntity:return mN(o);case d.FunctionDeclaration:return TN(o)}return(p=as[o.type])==null?void 0:p.singular}const vN=4e4,dLe=280,Gbi=300,EN=65,fy=32,Zb=39,uLe=26,pLe=49,EA=44,kbi=35,Hb=52,bN=10,pd=bN*2,bA=38,Wb=90,oC=270,cLe=vN/2+120,fLe=vN/2+180;function yLe(o){let i=fy+EA+bA+bN;const n=[...o.inputs];return n.length&&(i+=pd,n.forEach(()=>{i+=uLe})),{height:i,width:280}}function hLe(o){let i=EN;const n=[];if([d.DefinitionEntity].includes(o.type)){const m=[...o.suggestedProperties||[],...o.properties||[]];m.length&&(i+=pd,m.forEach(v=>{i+=v.static?pLe:Zb}))}if([d.DefinitionEntity,d.InstalledProject,d.Loop].includes(o.type)){const m=[...(o==null?void 0:o.suggestedMethods)||[],...o.methods||[],...o.functions||[],...o.body?[o.body]:[]];m.length&&(i+=pd,m.forEach(v=>{const E=yLe(v);i+=E.height}))}ei.includes(o.type)?(Gt.includes(o.type)?n.push(...(o.usedInputs||[]).flatMap(m=>[m])||[]):n.push(...(o.inputs||[]).flatMap(m=>[m])||[]),o.error&&(i+=Hb)):[d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(o.type)?(n.push(...o.outputs||[]),o.throws&&(i+=Hb)):o.type===d.Condition&&(n.push(o.inputs[0]),o.inputs[1]&&n.push(o.inputs[1]));const a=n.length;a&&(i+=a*Zb,i+=pd);const c=[];if(o.type===d.FunctionDeclaration||o.type===d.GlobalEvent?c.push(...o.inputs||[]):ei.includes(o.type)&&(Gt.includes(o.type)?c.push(...o.usedOutputs||[]):c.push(...o.outputs||[])),Gt.includes(o.type)){o.readsValue&&(i+=pd,i+=EA),o.writesValues.length&&(i+=pd,i+=EA),o.internalCalls.length&&o.usedInternalCalls.forEach(()=>i+=Hb+pd);const m=o.getDataType(null);(!m||m.inferred)&&(i+=bA)}const e=c.length;return e&&(i+=e*Zb,i+=pd),[d.DefinitionEntity,d.FunctionDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(o.type)&&(i+=bA),{height:i,width:280}}function pv(o){return`${o.split("-").map((n,a)=>a===0?n.charAt(0).toUpperCase()+n.slice(1):n.toLowerCase()).join(" ")}.`}function jbi(o){switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case he.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case he.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case he.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case he.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case he.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case he.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case Ie.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case Ie.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case he.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case he.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case Ie.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case he.NoProperties:return"This entity has no properties, so it doesn't do anything";case he.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case he.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case he.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case he.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case he.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case he.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case he.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case he.PropertyImplementsNonAbstact:return"This property implements a non-template property";case he.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case he.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case he.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case he.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case he.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case Ie.InternalCallDeclarationIsInvalidType:return"This internal call is not an action";case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case Ie.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case Ie.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case Ie.UnreachableEntity:return"This entity is unreachable";case he.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";case he.AbstractEntityImplements:return"This template entity implements a non-template entity";case he.AbstractExtendingNonAbstractEntity:return"This template entity extends a non-template entity";case he.InvalidPropertiesCombination:return"This entity has an invalid combination of properties";case he.ExtendingNonInteractiveEntity:return"This entity extends a non-interactive entity";case he.ExtendsIncompatibleEntities:return"This entity extends incompatible entities";case he.ImplementingNonAbstractEntity:return"This entity implements a non-template entity";case he.ImplementsIncompatibleEntities:return"This entity implements incompatible entities";case he.LackingReturnStatementOnSomeBranches:return"This action is missing a termination on some branches";case he.LastCalledEntityMustBeReturnEntity:return"The last called entity in this action must be a termination node";case he.MissingRequiredValue:return"This action is missing a required value";case he.NoPrimaryKeyProperty:return"This entity has no primary key property";case he.NonAbstractExtendingAbstractEntity:return"This non-template entity extends a template entity";case he.NonStaticExtendingStaticEntity:return"This non-static entity extends a static entity";case he.NonStaticImplementingStaticEntity:return"This non-static entity implements a static entity";case he.StaticExtendingNonStaticEntity:return"This static entity extends a non-static entity";case he.StaticImplementingNonStaticEntity:return"This static entity implements a non-static entity";case he.VariableReadsValueAndInternalCall:return"This variable reads a value while being used to execute internal logic";case he.VariableWritesValuesAndInternalCall:return"This variable writes values while being used to execute internal logic";case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return"This internal call declaration is not in the parent entity";case Ie.EmptyName:return"This entity has no name";case Ie.InvalidObjectStructure:return"This entity has an invalid structure";case Ie.LoopBodyFunctionOverwrite:return"This loop body action overwrites an action in the template entity with the same name";case Ie.MethodOverwritesBaseMethodWithSameImplementation:return"This action overwrites a base action with the same implementation";case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"This action overwrites an action in an extended entity with the same implementation";case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"This action overwrites an action in an implemented entity with the same implementation";case Ie.MissingCaller:return"This action is missing a caller";case Ie.NameAsResolvedCodeNameNotUniqueInScope:return"This entity has a name that is not unique in the scope of the code it is used in";case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"This entity name can only contain letters, numbers, underscores and spaces";case Ie.NameMustStartWithLetterOrUnderscore:return"This entity name must start with a letter or an underscore";case Ie.NoOverlapWithImplementedSignature:return"This action does not overlap with the implemented action signature";case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return"This property overwrites a base property with the same implementation";case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an extended entity with the same implementation";case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an implemented entity with the same implementation";case Ie.ReaderWriterIncompatibleDataType:return"This reader/writer has an incompatible data type with the value it is reading/writing";case $o.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case $o.StatusCodeMustBeNumber:return"HTTP status code must be a number, between 100 and 599";case Ba.UUIDMustBeString:return`UUID must be a string, eg: "${wu()}"`;case Ba.UUIDMustNotContainSpaces:return`UUID must not contain spaces, eg: "${wu()}"`;case Ba.UUIDMustBeValidFormat:return`UUID must be in a valid format. Eg: "${wu()}"`;case aa.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case aa.StringValueMustNotHaveDashes:return"This value must not contain dashes";case aa.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return pv(o.code)}}function Ubi(o){switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case he.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case he.IncorrectEntityImplementation:return"Incorrect implementation";case he.IncorrectMethodImplementation:return"Incorrect action implementation";case he.IncorrectPropertyImplementation:return"Incorrect property implementation";case he.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case he.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case Ie.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case Ie.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case he.MissingMethodImplementation:return"Missing action";case he.MissingPropertyImplementation:return"Missing property";case Ie.NameNotUniqueInScope:return"Duplicate name";case he.NoProperties:return"No properties";case he.NonStaticPropertyInStaticEntity:return"Non-static property";case he.StaticEntityWithNonStaticProperties:return"Non-static properties";case he.ReadingFromIncompatibleType:return"Read from different type";case he.WritingToIncompatibleType:return"Write to different type";case he.ScopeWithoutLogic:return"No logic";case he.NonStaticPropertyImplementsStatic:return"Invalid static property";case he.PropertyImplementsIncompatibleType:return"Incompatible data type";case he.PropertyImplementsNonAbstact:return"Non-template property";case he.StaticPropertyImplementsNonStatic:return"Non-static property";case he.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case he.VariableHasInputsAndInternalCall:return"Bad internal call";case he.VariableHasOutputsAndInternalCall:return"Bad internal call";case he.VariableIsCalledAndHasInternalCall:return"Bad internal call";case Ie.InternalCallDeclarationIsInvalidType:return"Declaration not an action";case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case Ie.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case Ie.InternalCallParentMissingDataType:return"Parent has no data type";case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case Ie.UnreachableEntity:return"Unreachable entity";case he.DisconnectedCallableEntity:return"Disconnected entity";case he.AbstractEntityImplements:return"Abstract entity implements a non-template entity";case he.AbstractExtendingNonAbstractEntity:return"Abstract entity extends a non-template entity";case he.InvalidPropertiesCombination:return"Invalid properties combination";case he.ExtendingNonInteractiveEntity:return"Extending non-interactive entity";case he.ExtendsIncompatibleEntities:return"Extends incompatible entities";case he.ImplementingNonAbstractEntity:return"Implementing non-template entity";case he.ImplementsIncompatibleEntities:return"Implements incompatible entities";case he.LackingReturnStatementOnSomeBranches:return"Missing termination on some branches";case he.LastCalledEntityMustBeReturnEntity:return"Last called entity must be a termination node";case he.MissingRequiredValue:return"Missing required value";case he.NoPrimaryKeyProperty:return"No primary key property";case he.NonAbstractExtendingAbstractEntity:return"Non-template entity extending a template entity";case he.NonStaticExtendingStaticEntity:return"Non-static entity extending a static entity";case he.NonStaticImplementingStaticEntity:return"Non-static entity implementing a static entity";case he.StaticExtendingNonStaticEntity:return"Static entity extending a non-static entity";case he.StaticImplementingNonStaticEntity:return"Static entity implementing a non-static entity";case he.VariableReadsValueAndInternalCall:return"Variable reads value and has internal call";case he.VariableWritesValuesAndInternalCall:return"Variable writes values and has internal call";case Ie.EmptyName:return"Empty name";case Ie.InvalidObjectStructure:return"Invalid object structure";case Ie.LoopBodyFunctionOverwrite:return"Loop body action overwrites action with same name";case Ie.MethodOverwritesBaseMethodWithSameImplementation:return"Action overwrites base action with same implementation";case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case Ie.MissingCaller:return"Missing caller";case Ie.NameAsResolvedCodeNameNotUniqueInScope:return"Name not unique in scope";case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"Name can only contain letters, numbers, underscores and spaces";case Ie.NameMustStartWithLetterOrUnderscore:return"Name must start with letter or underscore";case Ie.NoOverlapWithImplementedSignature:return"No overlap with implemented signature";case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return"Property overwrites base property with same implementation";case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case Ie.ReaderWriterIncompatibleDataType:return"Reader/writer incompatible data type";case $o.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case $o.StatusCodeMustBeNumber:return"HTTP status code must be a number";case Ba.UUIDMustBeString:return"UUID must be a string";case Ba.UUIDMustNotContainSpaces:return"UUID must not contain spaces";case Ba.UUIDMustBeValidFormat:return"UUID must be in a valid format";case aa.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case aa.StringValueMustNotHaveDashes:return"This value must not contain dashes";case aa.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return pv(o.code)}}function Kbi(o){switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return`${le(o.entity,o.entity.project)} has non-template actions`;case he.AbstractEntityWithNonAbstractProperties:return`${le(o.entity,o.entity.project)} has non-template properties`;case he.IncorrectEntityImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements template`;case he.IncorrectMethodImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements the template`;case he.IncorrectPropertyImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements the template`;case he.AbstractMethodInNonAbstractEntity:return`${le(o.entity,o.entity.project)} can't be a template`;case he.AbstractPropertyInNonAbstractEntity:return`${le(o.entity,o.entity.project)} can't be a template`;case Ie.MethodOverwritesOtherSiblingWithSameName:return`${le(o.entity,o.entity.project)} overwrites action`;case Ie.PropertyOverwritesOtherSiblingWithSameName:return`${le(o.entity,o.entity.project)} overwrites property`;case he.MissingMethodImplementation:return`${le(o.entity,o.entity.project)} is missing action`;case he.MissingPropertyImplementation:return`${le(o.entity,o.entity.project)} is missing property`;case Ie.NameNotUniqueInScope:return`${le(o.entity,o.entity.project)} name is not unique`;case he.NoProperties:return`${le(o.entity,o.entity.project)} has no properties`;case he.NonStaticPropertyInStaticEntity:return`${le(o.entity,o.entity.project)} has non-static property`;case he.StaticEntityWithNonStaticProperties:return`${le(o.entity,o.entity.project)} has non-static properties`;case he.ReadingFromIncompatibleType:return`${le(o.entity,o.entity.project)} reads from different type`;case he.WritingToIncompatibleType:return`${le(o.entity,o.entity.project)} writes to different type`;case he.ScopeWithoutLogic:return`${le(o.entity,o.entity.project)} has no logic`;case he.NonStaticPropertyImplementsStatic:return`${le(o.entity,o.entity.project)} has invalid static property`;case he.PropertyImplementsIncompatibleType:return`${le(o.entity,o.entity.project)} has incompatible data type`;case he.PropertyImplementsNonAbstact:return`${le(o.entity,o.entity.project)} has non-template property`;case he.StaticPropertyImplementsNonStatic:return`${le(o.entity,o.entity.project)} has non-static property`;case he.VariableCallsOthersAndHasInternalCall:return`${le(o.entity,o.entity.project)} has bad internal call`;case he.VariableHasInputsAndInternalCall:return`${le(o.entity,o.entity.project)} has bad internal call`;case he.VariableHasOutputsAndInternalCall:return`${le(o.entity,o.entity.project)} has bad internal call`;case he.VariableIsCalledAndHasInternalCall:return`${le(o.entity,o.entity.project)} has bad internal call`;case Ie.InternalCallDeclarationIsInvalidType:return`${le(o.entity,o.entity.project)} has declaration that is not an action`;case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${le(o.entity,o.entity.project)} has declaration that is not found in parent`;case Ie.InternalCallParentDeclarationEntityInvalidType:return`${le(o.entity,o.entity.project)} has invalid parent declaration type`;case Ie.InternalCallParentMissingDataType:return`${le(o.entity,o.entity.project)}'s parent has no data type`;case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return`${le(o.entity,o.entity.project)} has declaration that is not in parent`;case Ie.UnreachableEntity:return`${le(o.entity,o.entity.project)} is unreachable`;case he.DisconnectedCallableEntity:return`${le(o.entity,o.entity.project)} is not executed by any entity`;case he.AbstractEntityImplements:return`${le(o.entity,o.entity.project)} implements a non-template entity`;case he.AbstractExtendingNonAbstractEntity:return`${le(o.entity,o.entity.project)} extends a non-template entity`;case he.InvalidPropertiesCombination:return`${le(o.entity,o.entity.project)} has invalid properties combination`;case he.ExtendingNonInteractiveEntity:return`${le(o.entity,o.entity.project)} extends a non-interactive entity`;case he.ExtendsIncompatibleEntities:return`${le(o.entity,o.entity.project)} extends incompatible entities`;case he.ImplementingNonAbstractEntity:return`${le(o.entity,o.entity.project)} implements a non-template entity`;case he.ImplementsIncompatibleEntities:return`${le(o.entity,o.entity.project)} implements incompatible entities`;case he.LackingReturnStatementOnSomeBranches:return`${le(o.entity,o.entity.project)} is missing termination on some branches`;case he.LastCalledEntityMustBeReturnEntity:return`${le(o.entity,o.entity.project)}'s last called entity must be a termination node`;case he.MissingRequiredValue:return`${le(o.entity,o.entity.project)} is missing a required value`;case he.NoPrimaryKeyProperty:return`${le(o.entity,o.entity.project)} has no primary key property`;case he.NonAbstractExtendingAbstractEntity:return`${le(o.entity,o.entity.project)} extends a template entity`;case he.NonStaticExtendingStaticEntity:return`${le(o.entity,o.entity.project)} extends a static entity`;case he.NonStaticImplementingStaticEntity:return`${le(o.entity,o.entity.project)} implements a static entity`;case he.StaticExtendingNonStaticEntity:return`${le(o.entity,o.entity.project)} extends a non-static entity`;case he.StaticImplementingNonStaticEntity:return`${le(o.entity,o.entity.project)} implements a non-static entity`;case he.VariableReadsValueAndInternalCall:return`${le(o.entity,o.entity.project)} reads a value and has internal call`;case he.VariableWritesValuesAndInternalCall:return`${le(o.entity,o.entity.project)} writes values and has internal call`;case Ie.EmptyName:return`${as[o.entity.type]} has no name`;case Ie.InvalidObjectStructure:return`${le(o.entity,o.entity.project)} has invalid structure`;case Ie.LoopBodyFunctionOverwrite:return`${le(o.entity,o.entity.project)}'s loop body action overwrites an action`;case Ie.MethodOverwritesBaseMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites base action`;case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MissingCaller:return`${le(o.entity,o.entity.project)} is missing a caller`;case Ie.NameAsResolvedCodeNameNotUniqueInScope:return`${le(o.entity,o.entity.project)} has a name not unique in the scope`;case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${le(o.entity,o.entity.project)} name can only contain letters, numbers, underscores and spaces`;case Ie.NameMustStartWithLetterOrUnderscore:return`${le(o.entity,o.entity.project)} name must start with letter or underscore`;case Ie.NoOverlapWithImplementedSignature:return`${le(o.entity,o.entity.project)} has no overlap with implemented signature`;case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites base property`;case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.ReaderWriterIncompatibleDataType:return`${le(o.entity,o.entity.project)} has reader/writer with incompatible data type`;case $o.StatusCodeMustBeBetween100And599:return`${le(o.entity,o.entity.project)} HTTP status code must be between 100 and 599`;case $o.StatusCodeMustBeNumber:return`${le(o.entity,o.entity.project)} HTTP status code must be a number`;case Ba.UUIDMustBeString:return`${le(o.entity,o.entity.project)} UUID must be a string`;case Ba.UUIDMustNotContainSpaces:return`${le(o.entity,o.entity.project)} UUID must not contain spaces`;case Ba.UUIDMustBeValidFormat:return`${le(o.entity,o.entity.project)} UUID must be in a valid format`;case aa.MustBeUniqueAmongSameEntities:return`${le(o.entity,o.entity.project)} value must be unique among the same kind`;case aa.StringValueMustNotHaveDashes:return`${le(o.entity,o.entity.project)} value must not contain dashes`;case aa.StringValueMustNotHaveSpaces:return`${le(o.entity,o.entity.project)} value must not contain spaces`;default:return`${le(o.entity,o.entity.project)} Error: ${pv(o.code)}`}}function Fbi(o){var p,i,n,a;switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return`${le(o.entity,o.entity.project)} has non-template actions`;case he.AbstractEntityWithNonAbstractProperties:return`${le(o.entity,o.entity.project)} has non-template properties`;case he.IncorrectEntityImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements the template entity`;case he.IncorrectMethodImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements the template action it's based on`;case he.IncorrectPropertyImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements the template property it's based on`;case he.AbstractMethodInNonAbstractEntity:return`${le(o.entity,o.entity.project)} is a template action in a non-template entity`;case he.AbstractPropertyInNonAbstractEntity:return`${le(o.entity,o.entity.project)} is a template property in a non-template entity`;case Ie.MethodOverwritesOtherSiblingWithSameName:return`${le(o.entity,o.entity.project)} overwrites an action in the template entity`;case Ie.PropertyOverwritesOtherSiblingWithSameName:return`${le(o.entity,o.entity.project)} overwrites a property in the template entity`;case he.MissingMethodImplementation:return`${le(o.entity,o.entity.project)} is missing an action implementation from the template entity`;case he.MissingPropertyImplementation:return`${le(o.entity,o.entity.project)} is missing a property implementation from the template entity`;case Ie.NameNotUniqueInScope:return`${le(o.entity,o.entity.project)} has a duplicate name in the same scope`;case he.NoProperties:return`${le(o.entity,o.entity.project)} has no properties, so it doesn't do anything`;case he.NonStaticPropertyInStaticEntity:return`${le(o.entity,o.entity.project)} has a non-static property in a static entity`;case he.StaticEntityWithNonStaticProperties:return`${le(o.entity,o.entity.project)} has non-static properties in a static entity`;case he.ReadingFromIncompatibleType:return`${le(o.entity,o.entity.project)} reads data from a value of a different data type`;case he.WritingToIncompatibleType:return`${le(o.entity,o.entity.project)} writes data to a value of a different data type`;case he.ScopeWithoutLogic:return`${le(o.entity,o.entity.project)} has no logic`;case he.NonStaticPropertyImplementsStatic:return`${le(o.entity,o.entity.project)} has a static property in a non-static entity`;case he.PropertyImplementsIncompatibleType:return`${le(o.entity,o.entity.project)} implements a property of a different data type`;case he.PropertyImplementsNonAbstact:return`${le(o.entity,o.entity.project)} implements a non-template property`;case he.StaticPropertyImplementsNonStatic:return`${le(o.entity,o.entity.project)} has a static property in a non-static entity`;case he.VariableCallsOthersAndHasInternalCall:return`${le(o.entity,o.entity.project)} calls other entities while being used to execute internal logic`;case he.VariableHasInputsAndInternalCall:return`${le(o.entity,o.entity.project)} has inputs while being used to execute internal logic`;case he.VariableHasOutputsAndInternalCall:return`${le(o.entity,o.entity.project)} has outputs while being used to execute internal logic`;case he.VariableIsCalledAndHasInternalCall:return`${le(o.entity,o.entity.project)} is called while being used to execute internal logic`;case Ie.InternalCallDeclarationIsInvalidType:return`${le(o.entity,o.entity.project)} has a declaration that is not an action`;case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${le(o.entity,o.entity.project)} has a declaration that is not found in ${(p=o.entity.parent.getDataType(null))!=null&&p.entity?le((i=o.entity.parent.getDataType(null))==null?void 0:i.entity,o.entity.project):"the variable's data-type entity"}`;case Ie.InternalCallParentDeclarationEntityInvalidType:return`${le(o.entity,o.entity.project)} is part of a variable whos data-type entity can't have actions`;case Ie.InternalCallParentMissingDataType:return`${le(o.entity,o.entity.project)} is part of a variable with no data-type entity`;case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return`${le(o.entity,o.entity.project)} has a declaration doesn't belong to ${(n=o.entity.parent.getDataType(null))!=null&&n.entity?le((a=o.entity.parent.getDataType(null))==null?void 0:a.entity,o.entity.project):"the variable's data-type entity"}`;case Ie.UnreachableEntity:return`${le(o.entity,o.entity.project)} is unreachable`;case he.DisconnectedCallableEntity:return`${le(o.entity,o.entity.project)} is disconnected and won't be executed by anything after publishing`;case he.AbstractEntityImplements:return`${le(o.entity,o.entity.project)} implements a non-template entity`;case he.AbstractExtendingNonAbstractEntity:return`${le(o.entity,o.entity.project)} extends a non-template entity`;case he.InvalidPropertiesCombination:return`${le(o.entity,o.entity.project)} has an invalid combination of properties`;case he.ExtendingNonInteractiveEntity:return`${le(o.entity,o.entity.project)} extends a non-interactive entity`;case he.ExtendsIncompatibleEntities:return`${le(o.entity,o.entity.project)} extends incompatible entities`;case he.ImplementingNonAbstractEntity:return`${le(o.entity,o.entity.project)} implements a non-template entity`;case he.ImplementsIncompatibleEntities:return`${le(o.entity,o.entity.project)} implements incompatible entities`;case he.LackingReturnStatementOnSomeBranches:return`${le(o.entity,o.entity.project)} has branches that don't terminate`;case he.LastCalledEntityMustBeReturnEntity:return`${le(o.entity,o.entity.project)} must end with a termination node`;case he.MissingRequiredValue:return`${le(o.entity,o.entity.project)} is missing a required value`;case he.NoPrimaryKeyProperty:return`${le(o.entity,o.entity.project)} has no primary key property`;case he.NonAbstractExtendingAbstractEntity:return`${le(o.entity,o.entity.project)} is a non-template entity extending a template entity`;case he.NonStaticExtendingStaticEntity:return`${le(o.entity,o.entity.project)} is a non-static entity extending a static entity`;case he.NonStaticImplementingStaticEntity:return`${le(o.entity,o.entity.project)} is a non-static entity implementing a static entity`;case he.StaticExtendingNonStaticEntity:return`${le(o.entity,o.entity.project)} is a static entity extending a non-static entity`;case he.StaticImplementingNonStaticEntity:return`${le(o.entity,o.entity.project)} is a static entity implementing a non-static entity`;case he.VariableReadsValueAndInternalCall:return`${le(o.entity,o.entity.project)} reads a value and has an internal call`;case he.VariableWritesValuesAndInternalCall:return`${le(o.entity,o.entity.project)} writes values and has an internal call`;case Ie.EmptyName:return`${as[o.entity.type]} has no name`;case Ie.InvalidObjectStructure:return`${le(o.entity,o.entity.project)} has an invalid structure`;case Ie.LoopBodyFunctionOverwrite:return`${le(o.entity,o.entity.project)}'s loop body action overwrites`;case Ie.MethodOverwritesBaseMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites a base action with same implementation`;case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MissingCaller:return`${le(o.entity,o.entity.project)} is missing a caller`;case Ie.NameAsResolvedCodeNameNotUniqueInScope:return`${le(o.entity,o.entity.project)} has a name that is not unique in the scope`;case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${le(o.entity,o.entity.project)} name can only contain letters, numbers, underscores and spaces`;case Ie.NameMustStartWithLetterOrUnderscore:return`${le(o.entity,o.entity.project)} name must start with letter or underscore`;case Ie.NoOverlapWithImplementedSignature:return`${le(o.entity,o.entity.project)} has no overlap with implemented signature`;case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites a base property with same implementation`;case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.ReaderWriterIncompatibleDataType:return`${le(o.entity,o.entity.project)} has a reader/writer with incompatible data type`;case $o.StatusCodeMustBeBetween100And599:return`${le(o.entity,o.entity.project)} HTTP status code must be between 100 and 599`;case $o.StatusCodeMustBeNumber:return`${le(o.entity,o.entity.project)} HTTP status code must be a number, between 100 and 599`;case Ba.UUIDMustBeString:return`${le(o.entity,o.entity.project)} UUID must be a string, eg: "${wu()}"`;case Ba.UUIDMustNotContainSpaces:return`${le(o.entity,o.entity.project)} UUID must not contain spaces, eg: "${wu()}"`;case Ba.UUIDMustBeValidFormat:return`${le(o.entity,o.entity.project)} UUID must be in a valid format. Eg: "${wu()}"`;case aa.MustBeUniqueAmongSameEntities:return`${le(o.entity,o.entity.project)} value must be unique among the same kind`;case aa.StringValueMustNotHaveDashes:return`${le(o.entity,o.entity.project)} value must not contain dashes`;case aa.StringValueMustNotHaveSpaces:return`${le(o.entity,o.entity.project)} value must not contain spaces`;default:return`${le(o.entity,o.entity.project)} Error: ${pv(o.code)}`}}var AN=(o=>(o.ValuesAlreadyConnected="values-already-connected",o.CannotReadMoreThanOneValue="cannot-read-more-than-one-value",o.CannotReadValueFromChildren="cannot-read-value-from-children",o.CannotWriteValueToChildren="cannot-write-value-to-children",o.CannotBeCalledByChildren="cannot-be-called-by-children",o.ExecutionsAlreadyConnected="executions-already-connected",o.DataTypesNotCompatible="data-types-not-compatible",o.CannotCallAncestor="cannot-call-ancestor",o.CannotConnectToItself="cannot-connect-to-itself",o.CannotWriteValueToAncestor="cannot-write-value-to-ancestor",o.NotInScope="not-in-scope",o.IsNotValueWrittingEntity="is-not-value-writting-entity",o.IsNotValueReadingEntity="is-not-value-reading-entity",o.ContinueOrBreakStatementCalledFromOutsideLoop="continue-or-break-statement-called-from-outside-loop",o.ElementInLoopBodyCallingOutsideLoop="element-in-loop-body-calling-outside-loop",o.CallerIsInHigherScope="caller-is-in-higher-scope",o.CallerIsInLowerScope="caller-is-in-lower-scope",o.CallIsInHigherScope="call-is-in-higher-scope",o.CallIsInLowerScope="call-is-in-lower-scope",o.OtherIncompatibleScopeReason="other-incompatible-scope-reason",o.SiblingInternalCallAlreadyUsedInParentVariable="sibling-internal-call-already-used-in-parent-variable",o.ErrorOututMapCannotBeConnectedToParentSuccessBranchCallees="error-output-map-cannot-be-connected-to-parent-success-branch-callees",o.SuccessOutputMapCannotBeConnectedToParentErrorBranchCallees="success-output-map-cannot-be-connected-to-parent-error-branch-callees",o))(AN||{});const Sbi=Object.values(AN);var gN=(o=>(o.NotPartOfOngoingTest="not-part-of-ongoing-test",o.CannotBeAddedToTest="cannot-be-added-to-test",o))(gN||{});const qbi=Object.values(gN);var IN=(o=>(o.Suggestion="suggestion",o.CanvasGloballyDisabled="canvas-globally-disabled",o.CannotInteractWithInputInVariableWithInternalCalls="cannot-interact-with-input-in-variable-with-internal-calls",o.CannotInteractWithOutputInVariableWithInternalCalls="cannot-interact-with-output-in-variable-with-internal-calls",o.PropertyIsConstantItsValueCantBeReset="property-is-constant-its-value-cant-be-reset",o.CannotWriteValueOfGlobalVariableDeclaration="cannot-write-value-of-global-variable-declaration",o.CannotReSetValueOfConstantVariable="cannot-reset-value-of-constant-variable",o))(IN||{});const Zbi=Object.values(IN);function Hbi(o,p){const i=[...o,...p];return Array.from(new Set(i))}function Wbi(o,p){const i=[...o,...p],n=Array.from(new Set(i));return{hasChanged:n.length!==o.length,reasons:n}}function zbi(o,p){const i=o.filter(a=>!p.includes(a));return{hasChanged:i.length!==o.length,reasons:i}}function Jbi(o,p){return o.find(i=>i.entity.id===p)||null}function U4(o){return o.filter((p,i)=>o.indexOf(p)===i)}class In{constructor(p,i,n=null,a){I(this,"ids",[]);I(this,"entity");I(this,"entityCardHeight");I(this,"entityCardWidth");I(this,"index");I(this,"childEntities",[]);I(this,"children",[]);I(this,"parents",[]);I(this,"calculationEntryPoint");I(this,"_onlyEntities",null);I(this,"_changeSet",null);if(this.index=i,this.entity=p,this.calculationEntryPoint=n||this,this===this.calculationEntryPoint&&!a)throw new Error("Change set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(p,i,n){const a=cLe-oC-dLe,c=fLe-Wb-EN;p.metaSync({x:p.x||a,y:p.y||c},i);const e=new In(p,0,null,i);e._onlyEntities=n||[],e.ids=["0"];const y=[];e.next(v=>{y.push(...v)}),In.recursivelyAssembleChildrenAreas(y),e.resolveChildrenOverlaps();const m=e.flattenChildEntities();return e._onlyEntities?m.filter(v=>(e._onlyEntities||[]).includes(v)):m}static recursivelyAssembleChildrenAreas(p){const i=[];p.forEach(n=>{n.next(a=>{i.push(...a)})}),i.length>0&&In.recursivelyAssembleChildrenAreas(i)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(p){this.calculationEntryPoint._changeSet=p}findAreaInChildrenFromEntity(p){if(this.entity===p)return this;const i=this.children.find(a=>a.entity===p);return i||this.children.reduce((a,c)=>a||c.findAreaInChildrenFromEntity(p),null)}findAreaFromEntity(p){if(this.entity===p)return this;const i=this.calculationEntryPoint.children,n=i.find(c=>c.entity===p);return n||i.reduce((c,e)=>c||e.findAreaInChildrenFromEntity(p),null)}addParent(p){if(!this.parents.includes(p)){const i=In.resolveIds(p,this.index);this.ids.push(...i),this.parents.push(p)}}static resolveIds(p,i){return p?p.ids.map(n=>`${n}-${i}`):[`${i}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const p=Il(this.entity,!0);if(this.entity.type===d.Project){const i=[],n=[],a=[];p.forEach(e=>{if(d.DefinitionEntity===e.type){n.push(e);return}else if(Yt.includes(e.type)){a.push(e);return}i.push(e)});const c=i.sort((e,y)=>{const m=!!OA(e,y).length,v=Il(e),E=Il(y);return m?0:v.length&&!E.length?-1:!v.length&&E.length?1:0}).filter(e=>!Sp(e).length);this.childEntities=[...n,...a,...c]}else{const i=[],n=[],a=[],c=[],e=[];Zr.includes(this.entity.type)&&NR(this.entity).forEach(v=>{if(Gt.includes(v.type)){a.push(v);return}const E=oi(v);i.push(E)}),nr.includes(this.entity.type)&&n.push(...this.entity.detachedChildren);const y=p.filter(m=>{const v=i.includes(m);return v||a.includes(m)||n.includes(m)?!1:Gt.includes(m.type)?(a.push(m),!1):qr.includes(m.type)&&!v?(c.push(m),!1):m.type===d.DefinitionEntity?(e.push(m),!1):!0});i.sort((m,v)=>Nc(m,v)?-1:0),c.sort((m,v)=>Nc(m,v)?-1:0),a.sort((m,v)=>IC(m,v)?1:IC(v,m)?-1:0),this.childEntities=[...e,...i,...c,...y,...a,...n]}}calculateCardSize(){const p=hLe(this.entity);this.entityCardWidth=p.width,this.entityCardHeight=p.height}static getBoundriesOfTwoAreas(p,i){return{top:Math.min(p.top,i.top),left:Math.min(p.left,i.left),bottom:Math.max(p.bottom,i.bottom),right:Math.max(p.right,i.right)}}static getBoundriedOfCombinedAreas(p,i){const n=p.filter(c=>!i.includes(c));return n.reduce((c,e)=>i.includes(e)?c:In.getBoundriesOfTwoAreas(c,e.fullBranchArea),n[0].fullBranchArea)}getFullAreaUntilAny(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(e=>!p.includes(e)).map(e=>e.getFullAreaUntilAny(p)).reduce((e,y)=>In.getBoundriesOfTwoAreas(e,y),i)}getFullAreaUntilAreaOrAnyChildren(p){const i=[p,...p.flattenChildren()],n=this.ownEntityPlusBufferArea;return this.children.filter(e=>i.includes(e)).map(e=>e.getFullAreaUntil(p)).reduce((e,y)=>In.getBoundriesOfTwoAreas(e,y),n)}getFullAreaUntil(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(c=>c!==p).map(c=>c.getFullAreaUntil(p)).reduce((c,e)=>In.getBoundriesOfTwoAreas(c,e),i)}get fullBranchArea(){const p=this.ownEntityPlusBufferArea;return this.children.map(a=>a.fullBranchArea).reduce((a,c)=>In.getBoundriesOfTwoAreas(a,c),p)}get ownEntityArea(){return{top:this.entity.y,left:this.entity.x,bottom:this.entity.y+this.entityCardHeight,right:this.entity.x+this.entityCardWidth}}get ownEntityPlusBufferArea(){const p=this.ownEntityArea;return{top:p.top,left:p.left,bottom:p.bottom+Wb,right:p.right+oC}}static filterOutRepeatedAreas(p){return p.filter((i,n)=>p.indexOf(i)===n)}getEarliestId(p,i){const n=p.split("-"),a=i.split("-");return n.length<a.length?p:n.length>a.length?i:n.reduce((e,y,m)=>y<a[m]?p:i,p)}getEarliestLevel(){return this.ids.reduce((n,a)=>this.getEarliestId(n,a),this.ids[0]).split("-").length}countColumns(){let p=0;if(this!==this.calculationEntryPoint)p++;else return p;if(!this.parents.length)return p;const n=this.parents.reduce((a,c)=>c.getEarliestLevel()>a.getEarliestLevel()?c:a,this.parents[0]).countColumns();return p+=n,p}getLatestId(p,i){if(p===i)return p;const n=p.split("-"),a=i.split("-");return n.length<a.length?i:n.length>a.length?p:n.reduce((e,y,m)=>y>a[m]?p:i,p)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((n,a)=>this.getLatestId(n,a),this.ids[0]).split("-").length}smoothPosition(){const p=this.flattenSiblings();if(!p.length&&this.parents.length<=1&&this.children.length){const i=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(n=>{n!==this.calculationEntryPoint&&n.shiftDownAlone(i)})}else if([...Yt].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const i=p.filter(n=>!this.parents.includes(n));i.length?i.every(a=>{const c=this.countColumns(),e=a.countColumns();return c>e})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():i.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(p,i){if(p.includes(this))return p;this.move(this.entity,{y:this.entity.y+i});let n=[...p,this];return this.children.forEach(a=>{if(In.getEarliestParentInChain(a)!==this)return;const e=Jbi(n,a.entity.id);n=In.filterOutRepeatedAreas([...n]),e||(n=n.filter(m=>m!==a));const y=a.shiftDownUntilAny(n,i);n.push(...y)}),n}shiftRightUntilAny(p,i){p.includes(this)||(this.move(this.entity,{x:this.entity.x+i}),this.children.forEach(n=>{const a=In.filterOutRepeatedAreas([...this.flattenSiblings(),...p]);In.getEarliestParentInChain(n)===this&&n.shiftRightUntilAny(a,i)}))}shiftRight(p){this.move(this.entity,{x:this.entity.x+p}),this.children.forEach(i=>{const a=i.flattenSiblings().filter(c=>c!==i);i.shiftRightUntilAny(a,p)})}shiftDownAlone(p){this.move(this.entity,{y:this.entity.y+p})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const p=this.parents.reduce((a,c)=>{const e=c.ownEntityArea,y=e.top+fy,m={top:y,left:e.left,bottom:y,right:e.right};return In.getBoundriesOfTwoAreas(a,m)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),n=(p.bottom-p.top)/2-fy;this.shiftDownAlone(n)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const p=this.children.reduce((a,c)=>{const e=c.ownEntityArea,y=e.top+fy,m={top:y,left:e.left,bottom:y,right:e.right};return In.getBoundriesOfTwoAreas(a,m)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),n=(p.bottom-p.top)/2-fy;return this.shiftDownAlone(n),n}resolveChildrenOverlaps(){const p=this.flattenChildren();let i=[];p.forEach(n=>{const a=n.adjustVerticallyToAvoidOverlaps();i.push(...a)}),p.forEach(n=>{n.smoothPosition()})}static getEarliestParentInChain(p){let i=p.parents[0];return p.parents.length&&(i=p.parents.sort((n,a)=>{if(!n.ids.length)return-1;if(!a.ids.length)return 1;const c=n.ids.sort((y,m)=>y.length<m.length?-1:0),e=a.ids.sort((y,m)=>y.length<m.length?-1:0);return c[0].length-e[0].length})[0]),i}flattenEarlierSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((n,a)=>{if(p.has(a.entity.id))return n;p.add(a.entity.id);const e=a.children.slice(0,a.children.indexOf(this)).reduce((y,m)=>[...y,m,...m.flattenChildren(p)],[]);return[...n,...e]},[])}flattenSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((n,a)=>{if(p.has(a.entity.id))return n;p.add(a.entity.id);const e=a.children.filter(y=>y!==this).reduce((y,m)=>[...y,m,...m.flattenChildren(p)],[]);return[...n,...e]},[])}flattenChildren(p=new Set){return this.children.reduce((i,n)=>p.has(n.entity.id)?i:(p.add(n.entity.id),[...i,n,...n.flattenChildren(p)]),[])}flattenParents(p=new Set){return this.parents.reduce((n,a)=>p.has(a.entity.id)?n:(p.add(a.entity.id),[...n,a,...a.flattenParents(p)]),[])}getAreaIfRendered(p){return this.calculationEntryPoint.flattenChildren().find(a=>a.entity.id===p.id)||null}getLowerSiblings(){const p=this.parents.reduce((i,n)=>{const a=n.children.indexOf(this),c=n.children.slice(a+1);return[...i,...c]},[]);return U4(p)}getLowerAreas(){const p=this.getLowerSiblings(),i=this.parents.reduce((n,a)=>[...n,...a.getLowerAreas()],[]);return U4([...p,...i])}adjustVerticallyToAvoidOverlaps(p=[]){const n=In.getEarliestParentInChain(this).children[this.index-1];if(!n)return p;const a=this.flattenEarlierSiblings(),c=this.flattenParents(),e=[...a,...c,n],v=D(e.flatMap(V=>OA(this.entity,V.entity))).filter(V=>V.id!==this.entity.id).map(V=>this.findAreaFromEntity(V)).filter(V=>!!V),E=this.getFullAreaUntilAny(v),b=n.getFullAreaUntilAny(v),w=e.reduce((V,$)=>$===this||$.fullBranchArea.left!==E.left?V:Math.max(V,$.fullBranchArea.bottom),b.bottom);if(E.top<w){const V=w-E.top+Wb;return this.shiftDownUntilAny(p,V)}return p}move(p,i){(this.onlyEntities||[]).includes(p)&&p.metaSync(i,this.changeSet)}addChild(p){const i=this.childEntities[p];let n=null;i.x&&i.y?n=this.getAreaIfRendered(i):!i.x&&!i.y&&this.move(i,{x:this.entity.x,y:this.entity.y}),n||(n=new In(i,p,this.calculationEntryPoint));const a=this.ownEntityPlusBufferArea;this.children.includes(n)||(this.children.push(n),n.addParent(this));const c=n.fullBranchArea;if(c.left<a.right){const e=a.right-c.left;n.shiftRight(e)}return n}flattenChildEntities(p=new Set){return this.children.reduce((i,n)=>p.has(n.entity.id)?i:(p.add(n.entity.id),[...i,n.entity,...n.flattenChildEntities(p)]),[])}next(p){const i=[];this.childEntities.forEach((n,a)=>{const c=this.addChild(a);c&&i.push(c)}),p(i)}}var $m=(o=>(o.Amazon="amazon",o.Google="google",o.Microsoft="microsoft",o))($m||{}),hr=(o=>(o.RelationalDatabase="relational-database",o.CompiledLocalCodebase="compiled-local-codebase",o.CloudHostedCodebase="cloud-hosted-codebase",o.HttpApi="http-api",o.HttpEndpoint="http-endpoint",o.ServerlessFunction="serverless-function",o.CronJob="cron-job",o))(hr||{}),dC=(o=>(o.Post="post",o.Get="get",o.Acknowledgement="acknowledgment",o.Progress="progress",o.Error="error",o.Complete="complete",o))(dC||{}),vc=(o=>(o.Queued="queued",o.Running="running",o.Success="success",o.Failed="failed",o.CleanedUp="cleaned-up",o.Skipped="skipped",o.AbortedByUser="aborted-by-user",o.UnrecoverableFailure="unrecoverable-failure",o.Reverted="reverted",o.UnpublishingStarted="unpublishing-started",o.Unpublished="unpublished",o))(vc||{}),uC=(o=>(o.Queued="queued",o.Running="running",o.Success="success",o.Failed="failed",o.CleanedUp="cleaned-up",o.UnrecoverableFailure="unrecoverable-failure",o.Reverted="reverted",o.UnpublishingStarted="unpublishing-started",o.Unpublished="unpublished",o))(uC||{}),$t=(o=>(o.ProjectNotFound="project-not-found",o.ProjectPublishRequestAcknowledged="project-publish-request-acknowledged",o.PublicationStepFailedReasonUnknown="publication-step-failed-reason-unknown",o.DeploymentCompleted="deployment-completed",o.DeploymentStarted="deployment-started",o.DeploymentFailed="deployment-failed",o.AllInfrastructureSuccessfullyProvisioned="all-infrastucture-successfully-provisioned",o.RequestPayloadValidationFailed="request-payload-validation-failed",o.ProjectStateValidationFailedMissingName="project-state-validation-failed-missing-name",o.ProjectStateValidationFailedMissingAnyFunctionality="project-state-validation-failed-missing-any-functionality",o.ProjectAlreadyBeingPublished="project-already-being-published",o.BillingSubscriptionUpdateFailed="billing-subscription-update-failed",o.RelationalDatabaseDeploymentStarted="relational-database-deployment-started",o.RelationalDatabaseDeploymentCompleted="relational-database-deployment-completed",o.RelationalDatabaseDeploymentFailed="relational-database-deployment-failed",o.CreatingNewRelationalDatabase="creating-new-relational-database",o.WaitingForPreviousRelationalDatabaseDeployment="waiting-for-previous-relationa-database-deployment",o.RelationalDatabaseAlreadyExists="relational-database-already-exists",o.RelationalDatabaseDeletionStarted="relational-database-deletion-started",o.RelationalDatabaseDeletionCompleted="relational-database-deletion-completed",o.RelationalDatabaseDeletionFailed="relational-database-deletion-failed",o.WaitingForPreviousRelationalDatabaseDeletion="waiting-for-previous-relationa-database-deletion",o.HttpApiDeploymentStarted="http-api-deployment-started",o.HttpApiDeploymentCompleted="http-api-deployment-completed",o.HttpApiDeploymentFailed="http-api-deployment-failed",o.CreatingNewHttpApi="creating-new-http-api",o.HttpApiAlreadyExists="http-api-already-exists",o.HttpApiDeletionStarted="http-api-deletion-started",o.HttpApiDeletionCompleted="http-api-deletion-completed",o.HttpApiDeletionFailed="http-api-deletion-failed",o.WaitingForPreviousHttpApiDeletion="waiting-for-previous-http-api-deletion",o.BusinessLogicCodebaseDeploymentStarted="business-logic-codebase-deployment-started",o.BusinessLogicCodebaseDeploymentCompleted="business-logic-codebase-deployment-completed",o.BusinessLogicCodebaseDeploymentFailed="business-logic-codebase-deployment-failed",o.BundlingCodebaseForDownload="bundling-codebase-for-download",o.UploadingCodebaseToCloudStorage="uploading-codebase-to-cloud-storage",o.UploadingCodebaseToCloudStorageCompleted="uploading-codebase-to-cloud-storage-completed",o.UploadingCodebaseToCloudStorageFailed="uploading-codebase-to-cloud-storage-failed",o.InfrastructureValuesCodebaseInterpolationStarted="infrastructure-values-codebase-interpolation-started",o.InfrastructureValuesCodebaseInterpolationCompleted="infrastructure-values-codebase-interpolation-completed",o.InfrastructureValuesCodebaseInterpolationFailed="infrastructure-values-codebase-interpolation-failed",o.CodeCompilationStarted="code-compilation-started",o.CodeCompilationCompleted="code-compilation-completed",o.CodeCompilationFailed="code-compilation-failed",o.BundleCodebaseStarted="bundle-codebase-started",o.BundleCodebaseCompleted="bundle-codebase-completed",o.BundleCodebaseFailed="bundle-codebase-failed",o.InstallingCodebaseDependenciesStarted="installing-codebase-dependencies-started",o.InstallingCodebaseDependenciesCompleted="installing-codebase-dependencies-completed",o.InstallingCodebaseDependenciesFailed="installing-codebase-dependencies-failed",o.MigrateRelationalDatabaseStarted="migrate-relational-database-started",o.MigrateRelationalDatabaseCompleted="migrate-relational-database-completed",o.MigrateRelationalDatabaseFailed="migrate-relational-database-failed",o.ExecutePublicationCompletedEventStarted="execute-publication-completed-event-started",o.ExecutePublicationCompletedEventCompleted="execute-publication-completed-event-completed",o.ExecutePublicationCompletedEventFailed="execute-publication-completed-event-failed",o.ExecutePublicationCompletedEventTimedOut="execute-publication-completed-event-timed-out",o))($t||{}),Tl=(o=>(o.CodeCompilation="code-compilation",o.RelationalDatabaseDeployment="relational-database-deployment",o.RelationalDatabaseDeletion="relational-database-deletion",o.HttpApiDeployment="http-api-deployment",o.HttpApiDeletion="http-api-deletion",o.InfrastructureValuesCodebaseInterpolation="infrastructure-values-codebase-interpolation",o.BundleCodebase="bundle-codebase",o.MigrateRelationalDatabase="migrate-relational-database",o.BusinessLogicCodebaseDeployment="business-logic-codebase-deployment",o.ExecutePublicationCompletedEvent="execute-publication-completed-event",o.CodebaseCleanup="codebase-cleanup",o))(Tl||{});hr.CloudHostedCodebase,hr.HttpApi,hr.RelationalDatabase,hr.CloudHostedCodebase,hr.CloudHostedCodebase,hr.RelationalDatabase,hr.CloudHostedCodebase,hr.CloudHostedCodebase;function mLe(o){return`project-${o}-http-api`}function rR(o){return`entity-${o}-database`}class TLe{constructor(p,i,n,a,c,e,y,m,v){I(this,"stepType");I(this,"id");I(this,"resourceType");I(this,"index");I(this,"dependency",[]);I(this,"lastEvent",null);I(this,"lastEventTimestamp",null);I(this,"status",vc.Queued);I(this,"publicationRun");I(this,"resource");this.stepType=p,this.id=i,this.resourceType=n,this.status=a,this.dependency=c,this.index=e,this.lastEventTimestamp=y,this.publicationRun=m,this.resource=v}toJSON(){return{stepType:this.stepType,id:this.id,resourceType:this.resourceType,index:this.index,status:this.status,dependency:this.dependency,lastEvent:this.lastEvent,resource:{resourceId:this.resource.resourceId,resourceType:this.resource.resourceType,provider:this.resource.provider,details:this.resource.details,status:this.resource.status,name:this.resource.name}}}async update(p){var i,n;this.status=p.status,this.dependency=p.dependency,this.index=p.index,this.stepType=p.stepType,this.resourceType=p.resourceType,this.lastEvent=p.lastEvent,this.id=p.id,(n=this.resource)==null||n.setDetails((i=p.resource)==null?void 0:i.details)}}var vLe=(o=>(o.Ready="ready",o.Provisioning="provisioning",o.Queued="queued",o.ProvisioningFailed="provisioning-failed",o.Deleting="deleting",o.DeletingFailed="deleting-failed",o.Deleted="deleted",o))(vLe||{});class af{constructor(p,i,n){I(this,"provisionedBy");I(this,"publicationRun");I(this,"resourceType");I(this,"provider");I(this,"resourceId");I(this,"details",null);I(this,"name",null);I(this,"status","queued");this.publicationRun=p,this.resourceType=i,this.provider=n}setDetails(p){this.details=p}setStatus(p){this.status=p}setProvisionedBy(p){this.provisionedBy=p}}class Ybi extends af{constructor(i,n,a){super(i,hr.HttpEndpoint,a);I(this,"resourceType",hr.HttpEndpoint);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,n;return this.resourceId=rR((n=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:n.id),this.resourceId}}class Xbi extends af{constructor(i,n,a){super(i,hr.ServerlessFunction,a);I(this,"resourceType",hr.ServerlessFunction);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,n;return this.resourceId=rR((n=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:n.id),this.resourceId}}class ELe extends af{constructor(i,n,a){super(i,hr.HttpApi,a);I(this,"resourceType",hr.HttpApi);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=mLe(this.publicationRun.project.id),this.resourceId}}class bLe extends af{constructor(i,n,a){super(i,hr.RelationalDatabase,a);I(this,"resourceType",hr.RelationalDatabase);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,n;return this.resourceId=rR((n=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:n.id),this.resourceId}}class ALe extends af{constructor(i,n){super(i,hr.CloudHostedCodebase,n);I(this,"resourceType",hr.CloudHostedCodebase);I(this,"details",null);I(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`cloud-hosted-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}`,this.resourceId}}class gLe extends af{constructor(i,n){super(i,hr.CompiledLocalCodebase,n);I(this,"resourceType",hr.CompiledLocalCodebase);I(this,"details",null);I(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`compiled-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}--${this.publicationRun.id}`,this.resourceId}}class Qbi{constructor(p,i){I(this,"id");I(this,"projectAutoIncrementPublicationCount");I(this,"projectPublishedSemanticVersion");I(this,"projectVersion");I(this,"projectId");I(this,"triggeredBy");I(this,"createdAt");I(this,"updatedAt");I(this,"status");I(this,"steps",[]);I(this,"editor");I(this,"explicitResources",new Map);I(this,"implicitGlobalResources",new Map);I(this,"finalGlobalEvent",null);I(this,"finalStatus",null);I(this,"contextType",X.PublicationRun);I(this,"extensionsRegistry");this.id=p.id,this.projectAutoIncrementPublicationCount=p.projectAutoIncrementPublicationCount,this.projectPublishedSemanticVersion=p.projectPublishedSemanticVersion,this.projectVersion=p.projectVersion,this.projectId=p.projectId,this.triggeredBy=p.triggeredBy,this.createdAt=p.createdAt,this.updatedAt=p.updatedAt,this.status=p.status,this.editor=i,this.initRegistry()}get off(){return this.extensionsRegistry.off}get on(){return this.extensionsRegistry.on}get emit(){return this.extensionsRegistry.emit}get emitAsync(){return this.extensionsRegistry.emitAsync}get emitAsyncAll(){return this.extensionsRegistry.emitAsyncAll}get emitAsyncAllSettled(){return this.extensionsRegistry.emitAsyncAllSettled}get emitAsyncSequentially(){return this.extensionsRegistry.emitAsyncSequentially}get emitAsyncSequentiallyAll(){return this.extensionsRegistry.emitAsyncSequentiallyAll}get emitAsyncSequentiallyAllSettled(){return this.extensionsRegistry.emitAsyncSequentiallyAllSettled}get project(){return this.editor.project}getInfraTypes(p){return this.steps.filter(i=>p.includes(i.resourceType))}getStepsTypes(p){return this.steps.filter(i=>p.includes(i.stepType))}toIds(p){return p.map(i=>i.id)}getResourceForEntity(p){const i=Array.from(this.explicitResources.values()).find(n=>n.owners.has(p.id));return i||null}async init(){await this.initResources()}async initResources(){this.implicitGlobalResources.set(hr.CompiledLocalCodebase,new gLe(this,$m.Amazon)),this.implicitGlobalResources.set(hr.CloudHostedCodebase,new ALe(this,$m.Amazon));const p=this.project.entities.filter(n=>Wi(n,Re.HTTP_ENDPOINT)),i=this.project.entities.filter(n=>Wi(n,Re.RELATIONAL_DATABASE));if(i.length&&i.forEach(n=>{const a=new bLe(this,[n],$m.Amazon);this.explicitResources.set(a.resourceId,a)}),p.length){const n=new ELe(this,p,$m.Amazon);this.explicitResources.set(n.resourceId,n)}}setSteps(p,i){p.forEach(n=>{this.addStep(n,i)}),this.editor.events.emit($t.ProjectPublishRequestAcknowledged,{})}addStep(p,i){const n=p.dependency||[];if(n.length){const c=n.filter(e=>!this.steps.find(y=>y.id===e));if(c.length)throw new Error(`Missing dependencies: ${c.join(", ")}`)}if(!this.steps.find(c=>c.id===p.id)){const c=new TLe(p.stepType,p.id,p.resourceType,p.status,n,p.index,i,this,null);this.steps.push(c)}}onUpdate(p){var i;if(J.Logger.log("onUpdate",p),(i=p.payload)!=null&&i.stepType){const n=this.steps.find(a=>{var c;return a.id===((c=p.payload)==null?void 0:c.id)});n&&L(p.emittedAt).isAfter(L(n.lastEventTimestamp))&&n.update(p.payload)}this.editor.events.emit("publication-updated",{}),p.type===dC.Error?(this.finalStatus=uC.Failed,this.finalGlobalEvent=p.event,this.editor.events.emit("project-publication-error",p)):p.type===dC.Complete&&(this.finalStatus=uC.Success,this.finalGlobalEvent=p.event,this.editor.events.emit("project-publication-completed",p))}requestExtension(p){return this.extensionsRegistry.requestExtension(p)}async initRegistry(){return this.extensionsRegistry=new fN(this.editor.events),await this.extensionsRegistry.setup(),this.extensionsRegistry.onResolvePublicationRunContext(()=>this),await this.extensionsRegistry.contextAvailable(X.PublicationRun),this.extensionsRegistry}}function eAi(o){switch(o){case Tl.CodeCompilation:return"Code generation";case Tl.RelationalDatabaseDeployment:return"Database creation";case Tl.HttpApiDeployment:return"HTTP gateway creation";case Tl.InfrastructureValuesCodebaseInterpolation:return"Link code with resources";case Tl.BundleCodebase:return"Bundle code";case Tl.MigrateRelationalDatabase:return"Database structure migration";case Tl.BusinessLogicCodebaseDeployment:return"Update servers with new code";case Tl.CodebaseCleanup:return"Code cleanup";case Tl.HttpApiDeletion:return"HTTP gateway deletion";case Tl.RelationalDatabaseDeletion:return"Database deletion";default:return"Publication finished"}}function tAi(o){switch(o){case $t.DeploymentCompleted:return"Successfully published";case $t.DeploymentStarted:return"Publication started";case $t.DeploymentFailed:return"Publication failed";case $t.AllInfrastructureSuccessfullyProvisioned:return"All infrastructure successfully provisioned";case $t.RequestPayloadValidationFailed:return"Request payload validation failed";case $t.ProjectStateValidationFailedMissingName:return"Project state validation failed: missing name";case $t.ProjectStateValidationFailedMissingAnyFunctionality:return"Project state validation failed: missing any functionality";case $t.RelationalDatabaseDeploymentStarted:return"Database creation started";case $t.RelationalDatabaseDeploymentCompleted:return"Database creation completed";case $t.RelationalDatabaseDeploymentFailed:return"Database creation failed";case $t.CreatingNewRelationalDatabase:return"Creating new database (up to 5 mins)";case $t.WaitingForPreviousRelationalDatabaseDeployment:return"Waiting for previous database creation";case $t.RelationalDatabaseAlreadyExists:return"Database already exists";case $t.HttpApiDeploymentStarted:return"HTTP gateway creation started";case $t.HttpApiDeploymentCompleted:return"HTTP gateway creation completed";case $t.HttpApiDeploymentFailed:return"HTTP gateway creation failed";case $t.CreatingNewHttpApi:return"Creating new HTTP gateway";case $t.HttpApiAlreadyExists:return"HTTP gateway already exists";case $t.BusinessLogicCodebaseDeploymentStarted:return"Update servers with new code started";case $t.BusinessLogicCodebaseDeploymentCompleted:return"Update servers with new code completed";case $t.BusinessLogicCodebaseDeploymentFailed:return"Update servers with new code failed";case $t.BundlingCodebaseForDownload:return"Bundling code for download";case $t.UploadingCodebaseToCloudStorage:return"Uploading code to cloud storage";case $t.InfrastructureValuesCodebaseInterpolationStarted:return"Linking code with resources started";case $t.InfrastructureValuesCodebaseInterpolationCompleted:return"Linking code with resources completed";case $t.InfrastructureValuesCodebaseInterpolationFailed:return"Linking code with resources failed";case $t.CodeCompilationStarted:return"Code generation started";case $t.CodeCompilationCompleted:return"Code generation completed";case $t.CodeCompilationFailed:return"Code generation failed";case $t.BundleCodebaseStarted:return"Code bundling started";case $t.BundleCodebaseCompleted:return"Code bundling completed";case $t.BundleCodebaseFailed:return"Code bundling failed";case $t.InstallingCodebaseDependenciesStarted:return"Installing code dependencies";case $t.InstallingCodebaseDependenciesCompleted:return"Installing code dependencies completed";case $t.InstallingCodebaseDependenciesFailed:return"Installing code dependencies failed";case $t.MigrateRelationalDatabaseStarted:return"Database structure migration started";case $t.MigrateRelationalDatabaseCompleted:return"Database structure migration completed";case $t.MigrateRelationalDatabaseFailed:return"Database structure migration failed";case $t.ProjectAlreadyBeingPublished:return"Project already being published. You need to wait for the previous publication to complete";case $t.ProjectPublishRequestAcknowledged:return"Project publish request acknowledged";case $t.UploadingCodebaseToCloudStorageCompleted:return"Uploading code to cloud storage completed";case $t.UploadingCodebaseToCloudStorageFailed:return"Uploading code to cloud storage failed";case $t.BillingSubscriptionUpdateFailed:return"Billing subscription update failed";case $t.ProjectNotFound:return"Project not found";case $t.HttpApiDeletionCompleted:return"HTTP gateway deletion completed";case $t.HttpApiDeletionFailed:return"HTTP gateway deletion failed";case $t.HttpApiDeletionStarted:return"HTTP gateway deletion started";case $t.PublicationStepFailedReasonUnknown:return"Publication step failed: reason unknown";case $t.WaitingForPreviousHttpApiDeletion:return"Waiting for previous HTTP gateway deletion";case $t.RelationalDatabaseDeletionStarted:return"Database deletion started";case $t.RelationalDatabaseDeletionCompleted:return"Database deletion completed";case $t.RelationalDatabaseDeletionFailed:return"Database deletion failed";case $t.WaitingForPreviousRelationalDatabaseDeletion:return"Waiting for previous database deletion"}return"Unknown event"}var ILe=(o=>(o.NO_LOGIC="NO_LOGIC",o.NO_NAME="NO_NAME",o.NO_CHANGES="NO_CHANGES",o.PROJECT_PUBLICATION_ALREADY_ONGOING="PROJECT_PUBLICATION_ALREADY_ONGOING",o))(ILe||{});function iAi(o){switch(o){case"NO_LOGIC":return"This project has no logic";case"NO_NAME":return"This project has no name";case"NO_CHANGES":return"This version has already been published";case"PROJECT_PUBLICATION_ALREADY_ONGOING":return"This project is already being published";default:return"Publishing is currently not available. Try again later"}}function rAi(o){switch(o){case hr.RelationalDatabase:return"Relational database";case hr.HttpEndpoint:case hr.HttpApi:return"HTTP endpoints";case hr.ServerlessFunction:case hr.CloudHostedCodebase:return"Server code functions";default:return"Resources"}}function nAi(o){switch(o){case vc.Running:return"In progress";case vc.Failed:return"Failed";case vc.Success:return"Succeeded";case vc.Skipped:return"Skipped";case vc.Queued:default:return"Queued"}}function RLe(o){var n;if(!Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION))return null;let p=null;const i=Q["built-in-base-entity"].BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_ENTITY.properties.integration.id;if(o.type===d.BuiltInBaseEntity?Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION)&&(p=pC(o.name)):o.type===d.DefinitionEntity&&o.implements.forEach(a=>{if(Wi(a,Re.EXTERNAL_INTEGRATION_CONNECTION)){const c=pC(a==null?void 0:a.name);if(c)return p=c,!0}}),!p){const a=o.properties.find(c=>!!c.implements.find(e=>e.id===i)||!!c.implements.find(e=>{var y;return((y=e.extends)==null?void 0:y.id)===i}));p=(n=a==null?void 0:a.getDefaultValue())==null?void 0:n.value}return p}function aAi(o){return vhe[o]}function pC(o){return o.includes("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_")?o.replace("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_","").toLocaleLowerCase().replace("_auth",""):null}function DLe(o){if(o.type!==d.ActionDescriptor&&o.type!==d.Operation)throw new Error("Only ActionDescriptorState or OperationState can be used to resolve an external integration ID");if(o.type===d.ActionDescriptor){const p=o;if(p.id.startsWith("external-integration--"))return p.id.split("--")[1]}if(o.type===d.Operation){const p=o.declaration;if(Object.values(Qt).includes(p.id))return p.id.split("--")[1]||null}return null}function sAi(o){if(!o)throw new Error("The integrationName parameter is required to resolve the base built-in name.");return Object.values(Re).find(i=>!!(i.startsWith("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_")&&i.endsWith("_AUTH")&&i.replace("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_","").replace("_AUTH","").toLowerCase()===o.toLowerCase()))||null}function lAi(o){return o.type===d.BuiltInBaseEntity||o.type===d.DefinitionEntity?RLe(o):o.type===d.ActionDescriptor||o.type===d.Operation?DLe(o):null}function wLe(o){var a,c,e;if(!Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION))return null;let p=null;const i=G4e(o,Re.EXTERNAL_INTEGRATION_CONNECTION);if(!i)return null;const n=Q["built-in-base-entity"][i.id].properties.connectionId.id;if(o.type===d.BuiltInBaseEntity){if(Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION)){const y=o.properties.find(m=>{var v;return((v=m.extends)==null?void 0:v.id)===n});y&&(p=(a=y.getDefaultValue())==null?void 0:a.value)}}else if(o.type===d.DefinitionEntity){const y=o.properties.find(m=>!!m.implements.find(v=>v.id===n)||!!m.implements.find(v=>{var E;return((E=v.extends)==null?void 0:E.id)===n}));if(!y&&((c=o.extends)==null?void 0:c.type)===d.DefinitionEntity)return wLe(o.extends);p=(e=y==null?void 0:y.getDefaultValue())==null?void 0:e.value}return p}async function OLe(o,p={}){var y;const i=J.YieldTracker.from(p),a=[...ea(o),...Rs(o),...RN(o),...ta(o),...DN(o)],c=Cv(o);a.push(...c);const e=Lt(o.errors,a);await i.tick();for(const m of o.inputs)await m.validateAsync({tracker:i});for(const m of o.outputs)await m.validateAsync({tracker:i});for(const m of o.internalCalls)await m.validateAsync({tracker:i});return await((y=o.dataType)==null?void 0:y.validateAsync({tracker:i})),e}function CLe(o){var a;(a=o.dataType)==null||a.validate(),o.inputs.forEach(c=>c.validate()),o.outputs.forEach(c=>c.validate()),o.internalCalls.forEach(c=>c.validate());const i=[...ea(o),...Rs(o),...RN(o),...ta(o),...DN(o)],n=Cv(o);return i.push(...n),Lt(o.errors,i)}function RN(o,p){const n=[...o.project.getVariableDeclarations()].filter(a=>a.id!==o.id);return Vv(o,[Hi],n,p)}function DN(o){const p=[];if(o.parent!==o.project)return p;if(o.catchesError){const i=Ot({id:`${o.id}--${Ie.GlobalVariableDeclarationCannotCatchError}`,message:`${as[o.type].singular} "${le(o,o.project)}" with id "${o.id}" cannot catch an error because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:ce.Error,code:Ie.GlobalVariableDeclarationCannotCatchError,entity:o});p.push(i.error)}if(o.errorCalls.length){const i=Ot({id:`${o.id}--${Ie.GlobalVariableDeclarationCannotCallOnError}`,message:`${as[o.type].singular} "${le(o,o.project)}" with id "${o.id}" cannot call other entities from its error branch because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:ce.Error,code:Ie.GlobalVariableDeclarationCannotCallOnError,entity:o});p.push(i.error)}if(o.calledBy.length){const i=Ot({id:`${o.id}--${Ie.GlobalVariableDeclarationCannotBeCalled}`,message:`${as[o.type].singular} "${le(o,o.project)}" with id "${o.id}" cannot be called because it is globally declared. Global variable declarations must be self initialized when the project is loaded, and not be called for initialization.`,severity:ce.Error,code:Ie.GlobalVariableDeclarationCannotBeCalled,entity:o});p.push(i.error)}return[]}const oAi=Object.freeze(Object.defineProperty({__proto__:null,validate:CLe,validateAsync:OLe,validateGlobalVariableDeclaration:DN,validateVariableDeclarationName:RN},Symbol.toStringTag,{value:"Module"}));async function _Le(o,p={}){const i=J.YieldTracker.from(p),a=[...ea(o),...Rs(o),...ta(o)],c=Cv(o);a.push(...c);const e=Lt(o.errors,a);await i.tick();for(const y of o.inputs)await y.validateAsync({tracker:i});for(const y of o.outputs)await y.validateAsync({tracker:i});for(const y of o.internalCalls)await y.validateAsync({tracker:i});return e}function VLe(o){o.inputs.forEach(a=>a.validate()),o.outputs.forEach(a=>a.validate()),o.internalCalls.forEach(a=>a.validate());const i=[...ea(o),...Rs(o),...ta(o)],n=Cv(o);return i.push(...n),Lt(o.errors,i)}function dAi(o){const p=[],i=o.declaration.constant;if(i&&o.readsValue){const n=Ot({id:`${o.id}--${he.ValueReadingOverridesConstantVariable}`,message:`The '${o.type}' entity "${le(o,o.project)}" with id "${o.id}" is a constant variable whose value cannot be overriden, but reads a value.`,severity:ce.Error,code:he.ValueReadingOverridesConstantVariable,entity:o});p.push(n.error)}if(i&&o.defaultValue){const n=Ot({id:`${o.id}--${he.DefaultValueOverridesConstantVariable}`,message:`The '${o.type}' entity "${le(o,o.project)}" with id "${o.id}" is a constant variable whose value cannot be overridden, but has a 'defaultValue'.`,severity:ce.Error,code:he.DefaultValueOverridesConstantVariable,entity:o});p.push(n.error)}return p}const uAi=Object.freeze(Object.defineProperty({__proto__:null,validate:VLe,validateAsync:_Le,validateConstantValueOverride:dAi},Symbol.toStringTag,{value:"Module"}));var wN=(o=>(o.Parent="parent",o.DataTypeEntity="data-type-entity",o.VarDeclaration="var-declaration",o))(wN||{});const mi=class mi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"x");I(this,"y");I(this,"type",d.VariableInstance);I(this,"catchesError",!1);I(this,"defaultValue",null);I(this,"writesValues",[]);I(this,"readsValue",null);I(this,"declaration");I(this,"inputs",[]);I(this,"outputs",[]);I(this,"error",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"successCalls",[]);I(this,"errorCalls",[]);I(this,"internalCalls",[]);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.x=i.x,this.y=i.y,this.catchesError=i.catchesError||!1}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableInstance,catchesError:!1,declaration:null,internalCalls:[],successCalls:[],errorCalls:[],readsValue:null,writesValues:[],defaultValue:null,inputs:[],outputs:[],parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],error:null,x:0,y:0}}static fromGenerationTarget(i,n){let a=n;if(i.parent){const V=ne(i.parent);a=n.get(V)}const c=ne(i.declaration),e=n.get(c),y=i.calledByEntry.map(V=>{const $=ne(V);return n.get($)}),m=i.calledBySuccess.map(V=>{const $=ne(V);return n.get($)}),v=i.calledByError.map(V=>{const $=ne(V);return n.get($)});let E=null;if(i.readsValue){const V=ne(i.readsValue);E=n.get(V)}const b={id:i.id,version:x.UUID.uuid(),createdAt:L().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableInstance,catchesError:i.catchesError||!1,declaration:e.toReference(),calledByEntry:y,calledBySuccess:m,calledByError:v,defaultValue:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:E,inputs:[],outputs:[],writesValues:[],error:null,x:0,y:0,parent:a},w=me(b,n);return w.setParent(a,null),w}static validateGenerationTarget(i,n){let a=JSON.parse(JSON.stringify(i));const c=[],e=bn(a,{parent:{list:!1,types:[...nr,d.Project],optional:!0},declaration:{list:!1,types:[d.VariableDeclaration]}},n);return a=e.modifiedData,c.push(...e.errors,...xr(a)),{errors:c,modifiedData:a}}get codeName(){var i;return(i=this.declaration)==null?void 0:i.codeName}get codeNativeValueValidation(){var i;return this._codeNativeValueValidation||((i=this.declaration)==null?void 0:i.codeNativeValueValidation)||null}validateGeneratedUpdate(i){const n=[];let a=JSON.parse(JSON.stringify(i));const c=of(a,this);return a=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${se.InvalidParentUpdate}`,code:se.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
92
+ `+c):n.stack=c}catch{}}throw n}}_request(p,i){typeof p=="string"?(i=i||{},i.url=p):i=p||{},i=Vc(this.defaults,i);const{transitional:n,paramsSerializer:a,headers:c}=i;n!==void 0&&Sb.assertOptions(n,{silentJSONParsing:Ao.transitional(Ao.boolean),forcedJSONParsing:Ao.transitional(Ao.boolean),clarifyTimeoutError:Ao.transitional(Ao.boolean)},!1),a!=null&&(Ue.isFunction(a)?i.paramsSerializer={serialize:a}:Sb.assertOptions(a,{encode:Ao.function,serialize:Ao.function},!0)),i.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?i.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:i.allowAbsoluteUrls=!0),Sb.assertOptions(i,{baseUrl:Ao.spelling("baseURL"),withXsrfToken:Ao.spelling("withXSRFToken")},!0),i.method=(i.method||this.defaults.method||"get").toLowerCase();let e=c&&Ue.merge(c.common,c[i.method]);c&&Ue.forEach(["delete","get","head","post","put","patch","common"],$=>{delete c[$]}),i.headers=bl.concat(e,c);const y=[];let m=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(i)===!1||(m=m&&M.synchronous,y.unshift(M.fulfilled,M.rejected))});const v=[];this.interceptors.response.forEach(function(M){v.push(M.fulfilled,M.rejected)});let E,b=0,w;if(!m){const $=[G4.bind(this),void 0];for($.unshift(...y),$.push(...v),w=$.length,E=Promise.resolve(i);b<w;)E=E.then($[b++],$[b++]);return E}w=y.length;let V=i;for(;b<w;){const $=y[b++],M=y[b++];try{V=$(V)}catch(k){M.call(this,k);break}}try{E=G4.call(this,V)}catch($){return Promise.reject($)}for(b=0,w=v.length;b<w;)E=E.then(v[b++],v[b++]);return E}getUri(p){p=Vc(this.defaults,p);const i=jxe(p.baseURL,p.url,p.allowAbsoluteUrls);return Lxe(i,p.params,p.paramsSerializer)}}Ue.forEach(["delete","get","head","options"],function(p){TA.prototype[p]=function(i,n){return this.request(Vc(n||{},{method:p,url:i,data:(n||{}).data}))}});Ue.forEach(["post","put","patch"],function(p){function i(n){return function(c,e,y){return this.request(Vc(y||{},{method:p,headers:n?{"Content-Type":"multipart/form-data"}:{},url:c,data:e}))}}TA.prototype[p]=i(),TA.prototype[p+"Form"]=i(!0)});const qb=TA;class pN{constructor(p){if(typeof p!="function")throw new TypeError("executor must be a function.");let i;this.promise=new Promise(function(c){i=c});const n=this;this.promise.then(a=>{if(!n._listeners)return;let c=n._listeners.length;for(;c-- >0;)n._listeners[c](a);n._listeners=null}),this.promise.then=a=>{let c;const e=new Promise(y=>{n.subscribe(y),c=y}).then(a);return e.cancel=function(){n.unsubscribe(c)},e},p(function(c,e,y){n.reason||(n.reason=new jh(c,e,y),i(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(p){if(this.reason){p(this.reason);return}this._listeners?this._listeners.push(p):this._listeners=[p]}unsubscribe(p){if(!this._listeners)return;const i=this._listeners.indexOf(p);i!==-1&&this._listeners.splice(i,1)}toAbortSignal(){const p=new AbortController,i=n=>{p.abort(n)};return this.subscribe(i),p.signal.unsubscribe=()=>this.unsubscribe(i),p.signal}static source(){let p;return{token:new pN(function(a){p=a}),cancel:p}}}const wbi=pN;function Obi(o){return function(i){return o.apply(null,i)}}function Cbi(o){return Ue.isObject(o)&&o.isAxiosError===!0}const aC={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(aC).forEach(([o,p])=>{aC[p]=o});const _bi=aC;function qxe(o){const p=new qb(o),i=Ixe(qb.prototype.request,p);return Ue.extend(i,qb.prototype,p,{allOwnKeys:!0}),Ue.extend(i,p,null,{allOwnKeys:!0}),i.create=function(a){return qxe(Vc(o,a))},i}const En=qxe(dN);En.Axios=qb;En.CanceledError=jh;En.CancelToken=wbi;En.isCancel=Gxe;En.VERSION=Sxe;En.toFormData=YI;En.AxiosError=si;En.Cancel=En.CanceledError;En.all=function(p){return Promise.all(p)};En.spread=Obi;En.isAxiosError=Cbi;En.mergeConfig=Vc;En.AxiosHeaders=bl;En.formToJSON=o=>Bxe(Ue.isHTMLForm(o)?new FormData(o):o);En.getAdapter=Fxe.getAdapter;En.HttpStatusCode=_bi;En.default=En;const Vbi=En;class Zxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST,version:"1.0.0",description:"HTTP request operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Wn.HttpRequest);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=a[3]||{},e={method:a[0],url:a[1],params:a[2],headers:c,data:a[4]};J.Logger.log("Axios request config: ",e);const y=await Vbi(e);return{value:G.Success,error:null,result:{status:y.status,headers:y.headers,data:y.data}}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class Hxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY,version:"1.0.0",description:"Entity validate operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.Validate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)});J.Logger.log("Inputs for entity validation: ",a);const e=GR(a[1]).safeParse(a[0]);return e.success?{value:G.Success,error:null,result:{data:a[0]}}:{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:e.error.errors,result:null}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}const Ia=o=>o.map(p=>{var i,n;return((i=p.value)==null?void 0:i.valueAsType)??((n=p.value)==null?void 0:n.value)});class Wxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY,version:"1.0.0",description:"Entity read-key operation implementation module (top-level)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.ReadKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c]=Ia(n),e=rvi(a,c);return{value:G.Success,error:null,result:e}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class zxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY,version:"1.0.0",description:"Entity write-key operation implementation module (top-level, immutable)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.WriteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=nvi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class Jxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY,version:"1.0.0",description:"Entity delete-key operation implementation module (top-level, immutable)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.DeleteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c]=Ia(n),e=avi(a,c);return{value:G.Success,error:null,result:e}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class Yxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY,version:"1.0.0",description:"Entity read-nested-key operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.ReadNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=svi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class Xxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY,version:"1.0.0",description:"Entity write-nested-key operation implementation module (immutable, no auto-create)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.WriteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=lvi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class Qxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY,version:"1.0.0",description:"Entity write-safe-nested-key-recursively operation implementation module (immutable, auto-create)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.WriteSafeNestedKeyRecursively);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=ovi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class e$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY,version:"1.0.0",description:"Entity delete-nested-key operation implementation module (immutable)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Ce.DeleteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const[a,c]=Ia(n),e=dvi(a,c);return{value:G.Success,error:null,result:e}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class t$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY,version:"1.0.0",description:"Object has-key (top-level property present?)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Ce.HasKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=Ia(n),e=uvi(a,c);return{value:G.Success,error:null,result:e}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class i$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object key-value-equals (top-level property strict equality)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Ce.KeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=pvi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class r$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY,version:"1.0.0",description:"Object has-nested-key (path present?)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Ce.HasNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=Ia(n),e=cvi(a,c);return{value:G.Success,error:null,result:e}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class n$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object nested-key-value-equals (path strict equality)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Ce.NestedKeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e]=Ia(n),y=fvi(a,c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class a$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE,version:"1.0.0",description:"Object is-instance-of-type (DefinitionEntity-based runtime check)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Ce.IsInstanceOfType);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,y,m,v,E,b,w,V;try{const $=((c=(a=n[0])==null?void 0:a.value)==null?void 0:c.parent)||((y=(e=n[0])==null?void 0:e.value)==null?void 0:y.standaloneParent),M=(v=(m=n[0])==null?void 0:m.value)==null?void 0:v.value,k=(b=(E=n[1])==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle;if(!M)throw new TypeError("IsInstanceOfType expects a non-null input value.");if(!k)throw new TypeError("IsInstanceOfType expects a valid expectedType input.");if(!$)throw new TypeError("IsInstanceOfType cannot determine the value owner.");if(k.type!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType expects expectedType to be a DefinitionEntity.");const F=$.getDataType(null);if(((w=F==null?void 0:F.entity)==null?void 0:w.type)!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType cannot determine the data type of the input value.");let U=!1;return((V=F==null?void 0:F.entity)==null?void 0:V.id)!==(k==null?void 0:k.id)?U=!1:GR(F==null?void 0:F.entity).safeParse(M).success?U=!0:U=!1,{value:G.Success,error:null,result:U}}catch($){return{value:G.UnhandledError,error:$,result:null}}}})}}class s$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE,version:"1.0.0",description:"Object merge operation implementation module (immutable, shallow merge with right-precedence)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Ce.Merge);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const a=Ia(n),c=yvi(...a);return{value:G.Success,error:null,result:c}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class l$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS,version:"1.0.0",description:"Object keys operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Ce.Keys);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=Ia(n),c=hvi(a);return{value:G.Success,error:null,result:c}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class o$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES,version:"1.0.0",description:"Object values operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Ce.Values);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=Ia(n),c=mvi(a);return{value:G.Success,error:null,result:c}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}class d$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES,version:"1.0.0",description:"Object entries operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Ce.Entries);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=Ia(n),c=Tvi(a);return{value:G.Success,error:null,result:c}}catch(a){return{value:G.UnhandledError,error:a,result:null}}}})}}let ss=null;try{ss=require("crypto")}catch{}const Gm=typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle?globalThis.crypto:ss&&ss.webcrypto?ss.webcrypto:null,Ou=Gm?Gm.subtle:null;function Wm(o){const p=new ArrayBuffer(o.byteLength);return new Uint8Array(p).set(o),p}function Hr(o,p="utf8"){if(o instanceof Uint8Array)return o;const i=String(o);if(p==="utf8"){if(typeof TextEncoder<"u")return new TextEncoder().encode(i);if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"utf8"))}else if(p==="hex"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"hex"))}else if(p==="base64"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"base64"))}else if(p==="base64url"){const n=i.replace(/-/g,"+").replace(/_/g,"/").replace(/=+$/,"");if(typeof Buffer<"u")return new Uint8Array(Buffer.from(n,"base64"));const a=typeof atob=="function"?atob(n):"",c=new Uint8Array(a.length);for(let e=0;e<a.length;e++)c[e]=a.charCodeAt(e);return c}throw new Error(`Unsupported environment/encoding combo for toBytes(${p})`)}function to(o,p="utf8"){if(p==="utf8"){if(typeof TextDecoder<"u")return new TextDecoder().decode(o);if(typeof Buffer<"u")return Buffer.from(o).toString("utf8")}else if(p==="hex"){if(typeof Buffer<"u")return Buffer.from(o).toString("hex")}else if(p==="base64"){if(typeof Buffer<"u")return Buffer.from(o).toString("base64")}else if(p==="base64url"&&typeof Buffer<"u")return Buffer.from(o).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");throw new Error(`Unsupported environment/encoding combo for fromBytes(${p})`)}const u$e=o=>Hr(o,"base64"),p$e=(o,p)=>{const i=o instanceof Uint8Array?o:Hr(String(o),p||"utf8");return to(i,"base64")},_y=(o,p)=>{const i=o instanceof Uint8Array?o:Hr(String(o),p||"utf8");return to(i,"base64url")},Pc=o=>Hr(o,"base64url"),c$e=(o,p)=>{const i=o instanceof Uint8Array?o:Hr(String(o),p||"utf8");return to(i,"hex")},f$e=o=>Hr(o,"hex");function cN(o){if(Gm&&Gm.getRandomValues){const p=new Uint8Array(o);return Gm.getRandomValues(p),p}if(ss&&ss.randomBytes)return new Uint8Array(ss.randomBytes(o));throw new Error("Secure random not available")}function eR(o,p){if(!(o instanceof Uint8Array)||!(p instanceof Uint8Array)||o.length!==p.length)return!1;let i=0;for(let n=0;n<o.length;n++)i|=o[n]^p[n];return i===0}function y$e(o,p,i,n){if((typeof o!="string"||typeof p!="string")&&typeof o!="string"&&typeof p!="string")throw new Error("Invalid input types");const a=i??"utf8",c=n??"utf8",e=Hr(o??"",a),y=Hr(p??"",c);return eR(e,y)}async function h$e(o,p){if(Ou){const i=await Ou.digest({name:o},Wm(p));return new Uint8Array(i)}if(ss){const i=o.replace("SHA-","sha"),n=ss.createHash(i);return n.update(Buffer.from(p)),new Uint8Array(n.digest())}throw new Error("Hash not available")}async function m$e(o,p,i,n){if(typeof p!="string")throw new Error("Invalid input type for data; expected string");const a=String(o??"SHA-256"),c=i??"utf8",e=n??"base64url",y=Hr(p??"",c),m=await h$e(a,y);return to(m,e)}async function tR(o,p,i){if(Ou){const n=await Ou.importKey("raw",Wm(p),{name:"HMAC",hash:{name:o}},!1,["sign"]),a=await Ou.sign("HMAC",n,Wm(i));return new Uint8Array(a)}if(ss){const n=`sha${o.split("-")[1]}`,a=ss.createHmac(n,Buffer.from(p));return a.update(Buffer.from(i)),new Uint8Array(a.digest())}throw new Error("HMAC not available")}async function T$e(o,p,i,n,a,c){if(typeof o!="string"||typeof p!="string")throw new Error("Invalid input types for key or data; expected strings");const e=String(i??"SHA-256"),y=n??"utf8",m=a??"utf8",v=c??"base64url",E=Hr(o??"",y),b=Hr(p??"",m),w=await tR(e,E,b);return to(w,v)}async function iR(o,p,{iterations:i,length:n,hashAlg:a="SHA-256"}){if(Ou){const c=await Ou.importKey("raw",Wm(o),"PBKDF2",!1,["deriveBits"]),e=await Ou.deriveBits({name:"PBKDF2",salt:Wm(p),iterations:i,hash:a},c,n*8);return new Uint8Array(e)}if(ss){const c=a==="SHA-512"?"sha512":"sha256";return await new Promise((e,y)=>{ss.pbkdf2(Buffer.from(o),Buffer.from(p),i,n,c,(m,v)=>{m?y(m):e(new Uint8Array(v))})})}throw new Error("PBKDF2 not available")}async function v$e(o,p,i,n,a,c,e,y){if(typeof o!="string"||typeof p!="string")throw new Error("Invalid input types for password or salt; expected strings");const m=c??"utf8",v=e??"utf8",E=y??"base64url",b=Math.max(1,Number(i)||21e4),w=Math.max(1,Number(n)||32),V=a??"SHA-256",$=Hr(o??"",m),M=Hr(p??"",v),k=await iR($,M,{iterations:b,length:w,hashAlg:V});return to(k,E)}async function E$e(o,p=cN(16),i=21e4,n=32,a="SHA-256"){const c=Hr(o,"utf8"),e=await iR(c,p,{iterations:i,length:n,hashAlg:a}),y=_y(p),m=_y(e);return`pbkdf2$${a.toLowerCase()}$${i}$${y}$${m}`}async function b$e(o,p){const i=String(p).split("$");if(i.length!==5||i[0]!=="pbkdf2")return!1;const n=i[1].toLowerCase(),a=parseInt(i[2],10),c=Pc(i[3]),e=Pc(i[4]),y=n.includes("512")?"SHA-512":"SHA-256",m=await iR(Hr(o,"utf8"),c,{iterations:a,length:e.length,hashAlg:y});return eR(m,e)}async function A$e(o,p,i,n,a,c){const e=p!=null?Math.max(1,Number(p)||0):void 0,y=i!=null?Math.max(1,Number(i)||0):void 0,m=n??void 0,v=c??"base64url",E=a!=null?Hr(a,v):void 0;return await E$e(String(o??""),E,e,y,m)}function j4(o){return _y(Hr(JSON.stringify(o),"utf8"))}function vA(o){try{return JSON.parse(to(Pc(o),"utf8"))}catch{return null}}async function g$e(o,p,{alg:i="HS256",includeIat:n=!0,expiresInSeconds:a,notBeforeSeconds:c,issuer:e,subject:y,audience:m,jwtid:v,header:E={}}={}){const b={alg:i,typ:"JWT",...E},w=Math.floor(Date.now()/1e3),V={...o||{}};n&&(V.iat=w),typeof a=="number"&&(V.exp=w+a),typeof c=="number"&&(V.nbf=w+c),e&&(V.iss=e),y&&(V.sub=y),m&&(V.aud=m),v&&(V.jti=v);const $=j4(b),M=j4(V),k=Hr(`${$}.${M}`,"utf8"),U=await tR(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,k),Y=_y(U);return`${$}.${M}.${Y}`}async function I$e(o,p,i,n,a,c,e,y,m,v,E,b){if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(o!=null&&typeof o!="object")throw new Error("Invalid input type for payload; expected object");if(E!=null&&typeof E!="object")throw new Error("Invalid input type for header; expected object");if(v!=null&&typeof v!="string")throw new Error("Invalid input type for jwtid; expected string");if(e!=null&&typeof e!="string")throw new Error("Invalid input type for issuer; expected string");if(y!=null&&typeof y!="string")throw new Error("Invalid input type for subject; expected string");if(m!=null&&typeof m!="string"&&!Array.isArray(m))throw new Error("Invalid input type for audience; expected string or string[]");const V=Hr(p??"",b??"utf8");return await g$e(o??{},V,{alg:i??"HS256",includeIat:n==null?!0:!!n,expiresInSeconds:a!=null?Number(a):void 0,notBeforeSeconds:c!=null?Number(c):void 0,issuer:e??void 0,subject:y??void 0,audience:m??void 0,jwtid:v??void 0,header:E??void 0})}async function R$e(o,p,{alg:i="HS256",issuer:n,audience:a,maxAgeSeconds:c,clockSkewSeconds:e=60}={}){try{const[y,m,v]=String(o).split(".");if(!y||!m||!v)return{valid:!1,header:null,payload:null,reason:"Malformed"};const E=vA(y),b=vA(m);if(!E||!b)return{valid:!1,header:E,payload:b,reason:"Bad base64/json"};if(E.alg!==i)return{valid:!1,header:E,payload:b,reason:"Alg mismatch"};const w=Hr(`${y}.${m}`,"utf8"),$=await tR(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,w),M=Pc(v);if(!eR($,M))return{valid:!1,header:E,payload:b,reason:"Bad signature"};const k=Math.floor(Date.now()/1e3),F=Math.max(0,Number(e)||0);if(b.nbf!=null&&k+F<Number(b.nbf))return{valid:!1,header:E,payload:b,reason:"Not before"};if(b.exp!=null&&k-F>=Number(b.exp))return{valid:!1,header:E,payload:b,reason:"Expired"};if(n&&b.iss!==n)return{valid:!1,header:E,payload:b,reason:"Issuer mismatch"};if(a){const U=b.aud;if(!(Array.isArray(U)?U.includes(a):U===a))return{valid:!1,header:E,payload:b,reason:"Audience mismatch"}}return c!=null&&b.iat!=null&&k-Number(b.iat)>Number(c)+F?{valid:!1,header:E,payload:b,reason:"MaxAge exceeded"}:{valid:!0,header:E,payload:b}}catch(y){return{valid:!1,header:null,payload:null,reason:String((y==null?void 0:y.message)??y)}}}async function D$e(o,p,i,n,a,c,e,y){if(typeof o!="string")throw new Error("Invalid input type for token; expected string");if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(typeof n!="string")throw new Error("Invalid input type for issuer; expected string");if(a!=null&&typeof a!="string")throw new Error("Invalid input type for audience; expected string");const v=Hr(p??"",y??"utf8");return await R$e(String(o??""),v,{alg:i??"HS256",issuer:n??void 0,audience:a??void 0,maxAgeSeconds:c!=null?Number(c):void 0,clockSkewSeconds:e!=null?Number(e):void 0})}function w$e(o){const[p,i,n]=String(o).split(".");return{header:p?vA(p):null,payload:i?vA(i):null,signature:n?Pc(n):new Uint8Array}}function O$e(o,p){if(!o)throw new Error("Token is required for decoding");if(typeof o!="string")throw new Error("Invalid input type for token; expected string");const i=p??"base64url",{header:n,payload:a,signature:c}=w$e(String(o??"")),e=to(c,i);return{header:n,payload:a,signature:e}}class C$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES,version:"1.0.0",description:"Randomness generate random bytes operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(et.GenerateRandomBytes);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)}),e=Math.max(0,Number(a)||0),y=c??"base64url",m=cN(e),v=to(m,y);return{value:G.Success,error:null,result:v}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class _$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER,version:"1.0.0",description:"Randomness generate random integer operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomInteger);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=a[0],e=a[1],y=mOe(c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class V$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT,version:"1.0.0",description:"Randomness generate random float operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomFloat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=SI();return{value:G.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class P$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL,version:"1.0.0",description:"Randomness generate random hexadecimal operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomHexadecimal);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=KP(c);return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class N$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62,version:"1.0.0",description:"Randomness generate random base62 operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomBase62);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=FP(c);return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class x$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64,version:"1.0.0",description:"Randomness generate random base64 operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=vOe(c);return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class $$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC,version:"1.0.0",description:"Randomness generate random alphanumeric operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomAlphanumeric);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=SP(c);return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class L$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER,version:"1.0.0",description:"Generate identifier operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateIdentifier);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=a[0],e=a[1],y=qP(c,e);return{value:G.Success,error:null,result:y}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class M$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4,version:"1.0.0",description:"Generate UUID v4 operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateRandomUUIDv4);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=wu();return{value:G.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class B$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER,version:"1.0.0",description:"Generate short identifier operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{J.Logger.log("Initializing Random Generate Short Identifier Module");const n=i.find(a=>a.contextType===X.Logic);if(n){J.Logger.log("Project state found, setting up operation");const a=n.get(et.GenerateShortIdentifier);a?(J.Logger.log("Operation found, setting autoexecutable and implementation"),a.autoexecutable=!0,a.implementation=this.module.main):J.Logger.warn("Operation generate-short-identifier not found in project state")}else J.Logger.warn("Project state not found in contexts for Random Generate Short Identifier Module")},main:async(i,n)=>{try{const a=EOe();return{value:G.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class G$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN,version:"1.0.0",description:"Generate hexadecimal token operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(et.GenerateHexadecimalToken);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const a=bOe();return{value:G.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}function Pbi(o){let p;if(o===null?p="null":Array.isArray(o)?p="array":p=typeof o,!["string","number","boolean","null","object","array"].includes(p))throw new TypeError("GetTypeOf cannot determine type of the given value.");return p}class k$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF,version:"1.0.0",description:"Data type get type of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(ze.GetTypeOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)})[0];return{value:G.Success,error:null,result:Pbi(c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class j$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING,version:"1.0.0",description:"Coerce any value to string via JS String(value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.ToString);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=String(a);return{value:G.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class U$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER,version:"1.0.0",description:"Coerce to number via JS Number(value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.ToNumber);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=Number(a);return{value:G.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class K$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES,version:"1.0.0",description:"Convert string/bytes-like to Uint8Array (utf8|hex|base64|base64url)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.ToBytes);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=Hr(a,c||"utf8");return{value:G.Success,error:null,result:y}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class F$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING,version:"1.0.0",description:"Convert Uint8Array to string (utf8|hex|base64|base64url)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.FromBytesToString);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=to(a,c||"utf8");return{value:G.Success,error:null,result:y}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class S$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64,version:"1.0.0",description:"Bytes -> base64 string (accepts string input by converting from utf8)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.EncodeBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)});return{value:G.Success,error:null,result:p$e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class q$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64,version:"1.0.0",description:"base64 string -> bytes (Uint8Array)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.DecodeBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=u$e(String(a));return{value:G.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class Z$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL,version:"1.0.0",description:"Bytes -> base64url string (accepts string input by converting from utf8)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.EncodeBase64Url);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=_y(a,c||"utf8");return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class H$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL,version:"1.0.0",description:"base64url string -> bytes (Uint8Array)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.DecodeBase64Url);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=Pc(String(a));return{value:G.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class W$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX,version:"1.0.0",description:"Bytes -> hex string (accepts string input by converting from utf8)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.EncodeHex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=c$e(a,c||"utf8");return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class z$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX,version:"1.0.0",description:"hex string -> bytes (Uint8Array)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(ze.DecodeHex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=f$e(String(a));return{value:G.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class J$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH,version:"1.0.0",description:"Crypto: Hash (SHA-256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(li.Hash);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)});return{value:G.Success,error:null,result:m$e(a,c,e,y)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class Y$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC,version:"1.0.0",description:"Crypto: HMAC (SHA-256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(li.Hmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y,m,v]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)});return{value:G.Success,error:null,result:T$e(c,e,a,y,m,v)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class X$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL,version:"1.0.0",description:"Crypto: constant-time equality for byte sequences",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(li.ConstantTimeEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)});return{value:G.Success,error:null,result:y$e(a,c,e,y)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class Q$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2,version:"1.0.0",description:"Crypto: derive key with PBKDF2 (SHA-256/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(li.DeriveKeyPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y,m,v,E,b]=n.map(w=>{var V,$;return((V=w.value)==null?void 0:V.valueAsType)??(($=w.value)==null?void 0:$.value)});return{value:G.Success,error:null,result:v$e(a,c,e,y,m,v,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class eLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE,version:"1.0.0",description:"Json parse string into object operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Xr.Parse);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{var a;try{const c=(a=n[0].value)==null?void 0:a.value;if(typeof c!="string")throw new Error(`Invalid input type for JSON.parse operation: expected string, got ${typeof c}`);const e=JSON.parse(c);return{value:G.Success,error:null,result:e}}catch(c){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:c,result:null}}}})}}class tLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY,version:"1.0.0",description:"Json stringify object into string operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(Xr.Stringify);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,n)=>{var a,c;try{const e=(a=n[0].value)==null?void 0:a.value,y=(c=n[1].value)==null?void 0:c.value;if(!e||typeof e!="object"&&!Array.isArray(e))throw new Error(`Invalid input type for JSON.stringify operation: expected object or array, got ${typeof e}`);if(!y&&y!==0){const v=JSON.stringify(e);return{value:G.Success,error:null,result:v}}const m=JSON.stringify(e,null,y);return{value:G.Success,error:null,result:m}}catch(e){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:e,result:null}}}})}}class iLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC,version:"1.0.0",description:"JWT: build (HS256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(er.BuildJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y,m,v,E,b,w,V,$,M]=n.map(k=>{var F,U;return((F=k.value)==null?void 0:F.valueAsType)??((U=k.value)==null?void 0:U.value)});return{value:G.Success,error:null,result:await I$e(a,c,e,y,m,v,E,b,w,V,$,M)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class rLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC,version:"1.0.0",description:"JWT: verify (HS256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(er.VerifyJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y,m,v,E,b]=n.map(w=>{var V,$;return((V=w.value)==null?void 0:V.valueAsType)??(($=w.value)==null?void 0:$.value)});return{value:G.Success,error:null,result:await D$e(a,c,e,y,m,v,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class nLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE,version:"1.0.0",description:"JWT: decode (no verification)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(er.DecodeJwt);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)});return{value:G.Success,error:null,result:O$e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class aLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2,version:"1.0.0",description:"Password: hash (PBKDF2) -> envelope string",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Qr.HashPasswordPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c,e,y,m,v]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)});return{value:G.Success,error:null,result:await A$e(a,c,e,y,m,v)}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class sLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2,version:"1.0.0",description:"Password: verify (PBKDF2) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),a=n==null?void 0:n.get(Qr.VerifyPasswordPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{try{const[a,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=await b$e(String(a??""),String(c??""));return{value:G.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:a,result:null}}}})}}class sC extends HI{constructor(p,i,n=i.projectId){super(p,X.Editor),this._editor=i,this.id=n}get ready(){return this._editor.ready}get hasLoadedLogic(){return this._editor.hasLoadedLogic}get destroyed(){return this._editor.destroyed}get logicLoadingPromise(){return this._editor.logicLoadingPromise}get logic(){return this._editor.logic}get lastPublishedProjectState(){return this._editor.lastPublishedProjectState}get branch(){return this._editor.branch}get projectId(){return this._editor.projectId}get sessionId(){return this._editor.sessionId}get userAuthorId(){return this._editor.userAuthorId}get peerConnections(){return this._editor.peerConnections}get test(){return this._editor.test}get localTestValues(){return this._editor.localTestValues}get resolvedValues(){return this._editor.resolvedValues}get persistedExecutionResults(){return this._editor.persistedExecutionResults}get publication(){return this._editor.publication}get livePublishedVersions(){return this._editor.livePublishedVersions}get publications(){return this._editor.publications}get liveResources(){return this._editor.liveResources}get execution(){return this._editor.execution}get project(){return this._editor.logic}get lastExecutionResults(){return this._editor.lastExecutionResults}get undoableStackValueIndex(){return this._editor.undoableStackValueIndex}set undoableStackValueIndex(p){this._editor.undoableStackValueIndex=p}get PROJECT_NOTIFICATIONS_CHANNEL(){return this._editor.PROJECT_NOTIFICATIONS_CHANNEL}getAccessToken(){return this._editor.getAccessToken()}removeValueByOwnerId(p){return this._editor.removeValueByOwnerId(p)}removeValue(p){return this._editor.removeValue(p)}undo(){return this._editor.undo()}redo(){return this._editor.redo()}initTest(p,i){return this._editor.initTest(p,i)}removeTest(p){return this._editor.removeTest(p)}async copyEntities(p,i={}){return this._editor.copyEntities(p,i)}resolveInitialChildrenPositions(p,i,n){return this._editor.resolveInitialChildrenPositions(p,i,n)}publish(){return this._editor.publish()}loadGivenPublication(p){return this._editor.loadGivenPublication(p)}validateProjectState(p){return this._editor.validateProjectState(p)}requestActiveDynamicValue(p,i=!1){return this._editor.requestActiveDynamicValue(p,i)}getValueTypePreference(p){return this._editor.getValueTypePreference(p)}setValueTypePreference(p,i){return this._editor.setValueTypePreference(p,i)}implementFeature(p){return this._editor.implementFeature(p)}}function Nbi(o,p){return p instanceof sC?p:new sC(o,p)}class lC extends HI{constructor(p,i){super(p,X.PublicationRun),this._publicationRun=i}get id(){return this._publicationRun.id}get projectAutoIncrementPublicationCount(){return this._publicationRun.projectAutoIncrementPublicationCount}get projectPublishedSemanticVersion(){return this._publicationRun.projectPublishedSemanticVersion}get projectVersion(){return this._publicationRun.projectVersion}get projectId(){return this._publicationRun.projectId}get triggeredBy(){return this._publicationRun.triggeredBy}get createdAt(){return this._publicationRun.createdAt}get updatedAt(){return this._publicationRun.updatedAt}get status(){return this._publicationRun.status}get steps(){return this._publicationRun.steps}get editor(){return this._publicationRun.editor}get explicitResources(){return this._publicationRun.explicitResources}get implicitGlobalResources(){return this._publicationRun.implicitGlobalResources}get finalGlobalEvent(){return this._publicationRun.finalGlobalEvent}get finalStatus(){return this._publicationRun.finalStatus}}function xbi(o,p){return p instanceof lC?p:new lC(o,p)}function $bi(o){o.register(new QOe(o)),o.register(new XOe(o)),o.register(new WOe(o)),o.register(new JOe(o)),o.register(new YOe(o)),o.register(new zOe(o)),o.register(new MNe(o)),o.register(new BNe(o)),o.register(new GNe(o)),o.register(new jNe(o)),o.register(new kNe(o)),o.register(new UNe(o)),o.register(new _$e(o)),o.register(new V$e(o)),o.register(new P$e(o)),o.register(new N$e(o)),o.register(new x$e(o)),o.register(new $$e(o)),o.register(new L$e(o)),o.register(new M$e(o)),o.register(new B$e(o)),o.register(new G$e(o)),o.register(new LPe(o)),o.register(new MPe(o)),o.register(new BPe(o)),o.register(new GPe(o)),o.register(new kPe(o)),o.register(new jPe(o)),o.register(new UPe(o)),o.register(new KPe(o)),o.register(new FPe(o)),o.register(new SPe(o)),o.register(new qPe(o)),o.register(new ZPe(o)),o.register(new HPe(o)),o.register(new WPe(o)),o.register(new zPe(o)),o.register(new JPe(o)),o.register(new YPe(o)),o.register(new XPe(o)),o.register(new QPe(o)),o.register(new iNe(o)),o.register(new rNe(o)),o.register(new nNe(o)),o.register(new tPe(o)),o.register(new iPe(o)),o.register(new rPe(o)),o.register(new nPe(o)),o.register(new aPe(o)),o.register(new sPe(o)),o.register(new lPe(o)),o.register(new oPe(o)),o.register(new dPe(o)),o.register(new pPe(o)),o.register(new cPe(o)),o.register(new fPe(o)),o.register(new yPe(o)),o.register(new hPe(o)),o.register(new vVe(o)),o.register(new EVe(o)),o.register(new bVe(o)),o.register(new Hxe(o)),o.register(new Zxe(o)),o.register(new T_e(o)),o.register(new v_e(o)),o.register(new E_e(o)),o.register(new b_e(o)),o.register(new A_e(o)),o.register(new g_e(o)),o.register(new I_e(o)),o.register(new R_e(o)),o.register(new D_e(o)),o.register(new G_e(o)),o.register(new hVe(o)),o.register(new mVe(o)),o.register(new TVe(o)),o.register(new w_e(o)),o.register(new O_e(o)),o.register(new C_e(o)),o.register(new __e(o)),o.register(new V_e(o)),o.register(new P_e(o)),o.register(new N_e(o)),o.register(new x_e(o)),o.register(new $_e(o)),o.register(new L_e(o)),o.register(new M_e(o)),o.register(new B_e(o)),o.register(new k_e(o)),o.register(new j_e(o)),o.register(new U_e(o)),o.register(new K_e(o)),o.register(new F_e(o)),o.register(new S_e(o)),o.register(new q_e(o)),o.register(new Z_e(o)),o.register(new H_e(o)),o.register(new W_e(o)),o.register(new z_e(o)),o.register(new J_e(o)),o.register(new aVe(o)),o.register(new sVe(o)),o.register(new lVe(o)),o.register(new Y_e(o)),o.register(new X_e(o)),o.register(new Q_e(o)),o.register(new eVe(o)),o.register(new tVe(o)),o.register(new iVe(o)),o.register(new rVe(o)),o.register(new nVe(o)),o.register(new Yxe(o)),o.register(new Xxe(o)),o.register(new Qxe(o)),o.register(new e$e(o)),o.register(new Wxe(o)),o.register(new zxe(o)),o.register(new Jxe(o)),o.register(new t$e(o)),o.register(new r$e(o)),o.register(new a$e(o)),o.register(new i$e(o)),o.register(new n$e(o)),o.register(new s$e(o)),o.register(new d$e(o)),o.register(new l$e(o)),o.register(new o$e(o)),o.register(new mPe(o)),o.register(new bPe(o)),o.register(new APe(o)),o.register(new RPe(o)),o.register(new DPe(o)),o.register(new wPe(o)),o.register(new OPe(o)),o.register(new CPe(o)),o.register(new _Pe(o)),o.register(new VPe(o)),o.register(new PPe(o)),o.register(new gPe(o)),o.register(new IPe(o)),o.register(new vPe(o)),o.register(new EPe(o)),o.register(new TPe(o)),o.register(new uPe(o)),o.register(new xPe(o)),o.register(new $Pe(o)),o.register(new NPe(o)),o.register(new FNe(o)),o.register(new fxe(o)),o.register(new cxe(o)),o.register(new yxe(o)),o.register(new hxe(o)),o.register(new ZNe(o)),o.register(new HNe(o)),o.register(new QNe(o)),o.register(new YNe(o)),o.register(new uxe(o)),o.register(new nxe(o)),o.register(new sxe(o)),o.register(new oxe(o)),o.register(new lxe(o)),o.register(new XNe(o)),o.register(new txe(o)),o.register(new ixe(o)),o.register(new exe(o)),o.register(new KNe(o)),o.register(new WNe(o)),o.register(new axe(o)),o.register(new vxe(o)),o.register(new tC(o)),o.register(new qNe(o)),o.register(new zNe(o)),o.register(new SNe(o)),o.register(new dxe(o)),o.register(new JNe(o)),o.register(new rxe(o)),o.register(new pxe(o)),o.register(new Txe(o)),o.register(new mxe(o)),o.register(new Exe(o)),o.register(new tC(o)),o.register(new Axe(o)),o.register(new bxe(o)),o.register(new gxe(o)),o.register(new ENe(o)),o.register(new bNe(o)),o.register(new ANe(o)),o.register(new sNe(o)),o.register(new tNe(o)),o.register(new uNe(o)),o.register(new yNe(o)),o.register(new eNe(o)),o.register(new hNe(o)),o.register(new vNe(o)),o.register(new cNe(o)),o.register(new pNe(o)),o.register(new hA(o)),o.register(new gNe(o)),o.register(new INe(o)),o.register(new fNe(o)),o.register(new TNe(o)),o.register(new mNe(o)),o.register(new dNe(o)),o.register(new oNe(o)),o.register(new lNe(o)),o.register(new aNe(o)),o.register(new wNe(o)),o.register(new DNe(o)),o.register(new ONe(o)),o.register(new RNe(o)),o.register(new pVe(o)),o.register(new oVe(o)),o.register(new uVe(o)),o.register(new cVe(o)),o.register(new fVe(o)),o.register(new dVe(o)),o.register(new yVe(o)),o.register(new k$e(o)),o.register(new q$e(o)),o.register(new H$e(o)),o.register(new z$e(o)),o.register(new S$e(o)),o.register(new Z$e(o)),o.register(new W$e(o)),o.register(new F$e(o)),o.register(new K$e(o)),o.register(new U$e(o)),o.register(new j$e(o)),o.register(new eLe(o)),o.register(new tLe(o)),o.register(new X$e(o)),o.register(new Q$e(o)),o.register(new C$e(o)),o.register(new J$e(o)),o.register(new Y$e(o)),o.register(new rLe(o)),o.register(new iLe(o)),o.register(new nLe(o)),o.register(new aLe(o)),o.register(new sLe(o)),o.register(new tCe(o)),o.register(new iCe(o)),o.register(new fA(o)),o.register(new yA(o))}class fN{constructor(p=new J.Events("extensions-registry-fallback-events")){I(this,"extensionsRegistry",new Map);I(this,"initialized",new Set);I(this,"initializedContexts",new Set);I(this,"onResolveEditorContextCallback",()=>null);I(this,"onResolveProjectLogicContextCallback",()=>null);I(this,"onResolveEditorGUIContextCallback",()=>null);I(this,"onResolveGUIContextCallback",()=>null);I(this,"onResolveCompileContextCallback",()=>null);I(this,"onResolvePublicationRunContextCallback",()=>null);this.events=p,this.off=this.events.off.bind(this.events),this.on=this.events.on.bind(this.events),this.emit=this.events.emit.bind(this.events),this.emitAsync=this.events.emitAsync.bind(this.events),this.emitAsyncAll=this.events.emitAsyncAll.bind(this.events),this.emitAsyncAllSettled=this.events.emitAsyncAllSettled.bind(this.events),this.emitAsyncSequentially=this.events.emitAsyncSequentially.bind(this.events),this.emitAsyncSequentiallyAll=this.events.emitAsyncSequentiallyAll.bind(this.events),this.emitAsyncSequentiallyAllSettled=this.events.emitAsyncSequentiallyAllSettled.bind(this.events)}onResolveEditorContext(p){this.onResolveEditorContextCallback=p}onResolveProjectLogicContext(p){this.onResolveProjectLogicContextCallback=p}onResolveGUIContext(p){this.onResolveGUIContextCallback=p}onResolveEditorGUIContext(p){this.onResolveEditorGUIContextCallback=p}onResolveCompileContext(p){this.onResolveCompileContextCallback=p}onResolvePublicationRunContext(p){this.onResolvePublicationRunContextCallback=p}get extensionInOrder(){return Array.from(this.extensionsRegistry.values()).sort((p,i)=>(p.manifest.initPriority||Ee.Normal)-(i.manifest.initPriority||Ee.Normal))}async setup(){$bi(this),J.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(p){switch(p){case X.Editor:return this.onResolveEditorContextCallback();case X.Logic:return this.onResolveProjectLogicContextCallback();case X.EditorGUI:return this.onResolveEditorGUIContextCallback();case X.Compile:return this.onResolveCompileContextCallback();case X.PublicationRun:return this.onResolvePublicationRunContextCallback();case X.GUI:return this.onResolveGUIContextCallback();case X.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${p}`)}}requestContexts(p,i=[]){const n=[];i.length===0&&(i=p.manifest.contexts);for(const a of i){const c=this.requestContext(a);c&&n.push(c)}return n}requestExtension(p){const i=this.extensionsRegistry.get(p);if(i)return i;throw new Error(`Unknown extension: ${p}`)}register(p){this.extensionsRegistry.set(p.manifest.id,p)}async initAll(){var p,i;for(const n of this.extensionInOrder)if(n.module.init&&!this.initialized.has(n.manifest.id)){const a=n.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);a.length&&(await((i=(p=n.module).init)==null?void 0:i.call(p,a)),this.initialized.add(n.manifest.id))}else!n.module.init&&!this.initialized.has(n.manifest.id)&&this.initialized.add(n.manifest.id)}async initForReady(){J.Logger.log("Initializing extensions for ready contexts...");for(const p of this.extensionInOrder)if(p.module.init&&!this.initialized.has(p.manifest.id)){J.Logger.log("Initializing "+p.manifest.id+" extension...");const i=this.requestContexts(p);p.manifest.contexts.every(a=>!!i.find(c=>c.contextType===a))?(await p.module.init(i),this.initialized.add(p.manifest.id)):J.Logger.warn(`Skipping initialization of ${p.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${p.manifest.contexts.join(", ")}`,`Available contexts: ${i.map(a=>a.contextType).join(", ")}`)}else!p.module.init&&!this.initialized.has(p.manifest.id)?(J.Logger.log("Set "+p.manifest.id+" extension as initialized by default..."),this.initialized.add(p.manifest.id)):J.Logger.log(`Skipping initialization of ${p.manifest.id} extension, already initialized or no init method defined.`)}async destroyAll(){for(const p of[...this.extensionInOrder].reverse())p.module.destroy&&await p.module.destroy();this.events.destroy()}on(p,i){this.events.on(p,i)}emit(p,...i){this.events.emit(p,...i)}off(p,i){this.events.off(p,i)}emitAsync(p,...i){return this.events.emitAsync(p,...i)}emitAsyncAll(p,...i){return this.events.emitAsyncAll(p,...i)}emitAsyncAllSettled(p,...i){return this.events.emitAsyncAllSettled(p,...i)}emitAsyncSequentially(p,...i){return this.events.emitAsyncSequentially(p,...i)}emitAsyncSequentiallyAll(p,...i){return this.events.emitAsyncSequentiallyAll(p,...i)}emitAsyncSequentiallyAllSettled(p,...i){return this.events.emitAsyncSequentiallyAllSettled(p,...i)}async contextAvailable(p){if(this.initializedContexts.has(p)){J.Logger.warn(`Context ${p} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(p),p){case X.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case X.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}J.Logger.log(`Context ${p} is now available. Initializing extensions for this context...`),await this.initForReady()}getValueTypePreference(p){return window.localStorage.getItem("dynamic-value-type-preference--"+p)||null}setValueTypePreference(p,i){window.localStorage.setItem("dynamic-value-type-preference--"+p,(i==null?void 0:i.toString())||""),this.emit(p,{})}}let Lb=null;const yN={requestExtension:o=>(Lb||(Lb=new fN,Lb.setup()),Lb.requestExtension(o))},bu={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var hN=(o=>(o.FinishedSuccess="finished-success",o.FinishedError="finished-error",o.Running="running",o.Paused="paused",o.Stopped="stopped",o.NotStarted="not-started",o))(hN||{});const lLe={...yN,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class Ru extends J.Events{constructor(i,n,a,c=null,e=lLe){super();I(this,"project");I(this,"entryPoint");I(this,"state","not-started");I(this,"events",new J.Events("fe-exec-inst-events"));I(this,"entities",[]);I(this,"parentExecution",null);I(this,"executing",[]);I(this,"executed",[]);I(this,"skipped",[]);I(this,"scheduled",[]);I(this,"localTestValues");I(this,"resolvedValues");I(this,"persistedExecutionResults");I(this,"lastExecutionResults");I(this,"onAddToSkippedListCallback",null);I(this,"onRemoveFromSkippedListCallback",null);I(this,"onAddEntityCallback",null);I(this,"onRemoveEntityCallback",null);I(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=n,this.entryPoint=a,this.project=i,this.parentExecution=c,this.localTestValues=new Nm(x.UUID.uuid(),this.project),this.resolvedValues=new Nm(x.UUID.uuid(),this.project),this.persistedExecutionResults=new Nm(x.UUID.uuid(),this.project),this.lastExecutionResults=new Nm(x.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults,getValueTypePreference:this.parentContext.getValueTypePreference,setValueTypePreference:this.parentContext.setValueTypePreference}}skip(i){this.hasEntity(i)&&(this.removeFromScheduledList(i),!this.skipped.includes(i)&&(this.skipped.push(i),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(i),Zr.includes(i.type)&&Rt(i).forEach(n=>this.skip(n))))}async schedule(i,n,a){if(this.hasExecuted(i))return null;if(Yt.includes(i.type))return this.executeBranch(i,a,n);if(qr.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,a,n);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,n){const a=[];return[...ei,...Yt].includes(n.type)?a.push(...n.inputs):Ut.includes(n.type)&&a.push(...n.outputs),a.map(e=>{var m;let y=i.find(v=>v.valueOwner.id===e.id);if(y)return y;if(!y&&Yt.includes(n.type)&&(y=i.find(v=>{var E;return((E=v.valueOwner.declaration)==null?void 0:E.id)===e.id})),y){const v=(m=y.value)==null?void 0:m.clone(null);return v==null||v.setStandaloneParent(e,null),{...y,valueOwner:e,value:v||null,inheritanceLink:{sources:[y],target:e}}}return Ma.includes(e.type)?Io(e,this.valueResolutionContext):_c(e,this.valueResolutionContext)}).reduce((e,y)=>{const m=_o(y==null?void 0:y.valueOwner,this.project),v=y?[y]:[];return m.forEach(E=>{var V,$,M;if(E.id===(y==null?void 0:y.valueOwner.id))return;const b=It(E.getDataType(null),E,this.project);b==null||b.metaSync({value:(V=y==null?void 0:y.value)==null?void 0:V.value},null),b==null||b.setValueAsTypeList((($=y==null?void 0:y.value)==null?void 0:$.valueAsTypeList)||null),b==null||b.setValueAsTypeSingle(((M=y==null?void 0:y.value)==null?void 0:M.valueAsTypeSingle)||null);const w={...y,valueOwner:E,value:b};v.push(w)}),[...e,...v]},[]).sort((e,y)=>e.valueOwner.index-y.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,n,a,c={}){var y,m;const e={...bu,...c};try{let v={value:G.Success,error:null,result:null};if(n.sort((E,b)=>E.valueOwner.index-b.valueOwner.index),Object.values(vr).includes(i.declaration.id)){const E=this.parentContext.requestExtension(cy+i.declaration.id).module.main;E?v=await E(i,n):J.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{v=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,n,a,e);let E=null;if(v.error){J.Logger.warn("Raw error executing entity: ",v.error);const b=(y=i.error)==null?void 0:y.getDataType(null),w=It(b||null,i.error,a);b!=null&&b.asType?w==null||w.setValueAsTypeSingle(v.error):w==null||w.metaSync({value:v.error},null),E={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:w}}return{value:v.value,entity:i,error:E,result:{value:v.result||null,valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null}}}return{...v,entity:i}}catch(v){J.Logger.warn("Internal call execution error: ",v);let E=null;if(i.error){const b=(m=i.error)==null?void 0:m.getDataType(null),w=It(b,i.error,a);b!=null&&b.asType?w==null||w.setValueAsTypeSingle(v):w==null||w.metaSync({value:v},null),E={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:w}}return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:E,result:null}}}static async executeOperation(i,n,a){var c,e;try{let y={value:G.Success,error:null,result:null};n.sort((b,w)=>b.valueOwner.index-w.valueOwner.index),i.declaration.implementation&&(y=await i.declaration.implementation(i,n));let m=null;if(y.error&&i.error){J.Logger.warn("Raw error executing entity: ",y.error);const b=((c=i.error)==null?void 0:c.getDataType(null))||null,w=It(b,i.error,a);b!=null&&b.asType?w==null||w.setValueAsTypeSingle(y.error):w==null||w.metaSync({value:y.error},null),m={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:w}}const v=i==null?void 0:i.getDataType(null),E=It(v,i,a);return v!=null&&v.asType?E==null||E.setValueAsTypeSingle(y.result):E==null||E.metaSync({value:y.result},null),{value:y.value,entity:i,error:m,result:{value:E||null,valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null}}}catch(y){J.Logger.warn("Operation execution error: ",y);let m=null;if(i.error){const v=(e=i.error)==null?void 0:e.getDataType(null),E=It(v,i.error,a);v!=null&&v.asType?E==null||E.setValueAsTypeSingle(y):E==null||E.metaSync({value:y},null),m={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:E}}return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:m,result:null}}}async executeSearch(i,n,a){var c;try{let e={value:G.Success,error:null,result:null};const y=await(await this.parentContext.requestExtension(Ae.SEARCH_NODE_IMPLEMENTATION)).module.main(i,n),m=i==null?void 0:i.getDataType(null),v=It(m,i,a);return v==null||v.metaSync({value:y},null),y.error?{value:G.UnhandledError,entity:i,error:{valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null,value:v},result:null}:{value:e.value,entity:i,error:null,result:{value:v,valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null}}}catch(e){if(J.Logger.warn(`Search node execution error: ${e}`),!i.error)return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null};const y=(c=i.error)==null?void 0:c.getDataType(null),m=It(y,i.error,a);return m==null||m.metaSync({value:e},null),{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:{valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:m},result:null}}}async executeLoop(i,n,a,c={}){var y,m,v,E,b,w;const e={...bu,...c};try{let V={value:G.Success,error:null,result:null};const $=n.map(ie=>{var ee,de;return((ee=ie==null?void 0:ie.value)==null?void 0:ee.valueAsType)||((de=ie==null?void 0:ie.value)==null?void 0:de.value)});let M={};i.getUniqueInputMaps().forEach(ie=>{const ee=i.body.inputs.find(ve=>le(ve,a)===le(ie,a)),de=ie==null?void 0:ie.getDataType(null),ae=It(de,ee,a);de!=null&&de.asType?ae==null||ae.setValueAsTypeList([]):ae==null||ae.metaSync({value:[]},null),this.lastExecutionResults.writeValue(ee,ae);const fe={value:ae,valueOwner:ee,type:Ne.ExecutionResult,inheritanceLink:null};M[ee.id]=fe});let F={value:G.Success,entity:i.body,error:null,result:null};switch(i.declaration.id){case Q.loop["counted-loop"].id:{const ie=$[0];let ee=1;for(;ee<=ie&&ee<=50;){const de=i.body.inputs.map(ae=>{if(ae===i.currentIterationNumberArgumentDeclaration){const fe=i.currentIterationNumberArgumentDeclaration.getDataType(null),ve=Tc(fe),ue=this.lastExecutionResults.readValue(ae.id);if(ue){ue.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ae,ue);const xe={value:ue,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null};return M[ae.id]=xe,xe}const ye={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:ee,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ve,standaloneParent:ae.toReference()},Ve=Si(ye,a);this.lastExecutionResults.writeValue(ae,Ve);const _e={value:Ve,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null};return M[ae.id]=_e,_e}else return M[ae.id]}).filter(ae=>!!ae);if(F=await this.executeFullFunctionDeclarationLogic(i.body,de,e),(F.results||[]).forEach(ae=>{var ye,Ve,_e,xe;if(ae.valueOwner.type!==d.InputMap||Ut.includes(ae.valueOwner.parent.type))return;const fe=i.body.inputs.find(Pe=>le(Pe,a)===le(ae.valueOwner,a)),ue=[...((Ve=(ye=M==null?void 0:M[fe.id])==null?void 0:ye.value)==null?void 0:Ve.value)||[],((_e=ae==null?void 0:ae.value)==null?void 0:_e.value)||null];(xe=M[fe.id].value)==null||xe.metaSync({value:ue},null),this.lastExecutionResults.writeValue(fe,M[fe.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ee++}break}case Q.loop["manual-flow-loop"].id:{let ie=1;for(;ie<=50;){const ee=i.body.inputs.map(de=>{if(de===i.currentIterationNumberArgumentDeclaration){const ae=this.lastExecutionResults.readValue(de.id);if(ae){ae.metaSync({value:ie},null),this.lastExecutionResults.writeValue(de,ae);const ye={value:ae,valueOwner:de,type:Ne.ExecutionResult,inheritanceLink:null};return M[de.id]=ye,ye}const fe=i.currentIterationNumberArgumentDeclaration.getDataType(null),ve=It(fe,de,a);return ve==null||ve.metaSync({value:ie},null),this.lastExecutionResults.writeValue(de,ve),{value:ve,valueOwner:de,type:Ne.ExecutionResult,inheritanceLink:null}}else return M[de.id]}).filter(de=>!!de);if(F=await this.executeFullFunctionDeclarationLogic(i.body,ee,e),(F.results||[]).forEach(de=>{var ue,ye,Ve;if(de.valueOwner.type!==d.InputMap||Ut.includes(de.valueOwner.parent.type))return;const ae=i.body.inputs.find(_e=>le(_e,a)===le(de.valueOwner,a)),ve=[...(ue=M[ae.id].value)==null?void 0:ue.value,((ye=de.value)==null?void 0:ye.value)||null];(Ve=M[ae.id].value)==null||Ve.metaSync({value:ve},null),this.lastExecutionResults.writeValue(ae,M[ae.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ie++}break}case Q.loop["list-loop"].id:{const ie=$[0];let ee=1;const de=ie;for(let ae=0;ae<de.length;ae++){const fe=de[ae],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,a);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=Tc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const xe={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Pe=Si(xe,a);return this.lastExecutionResults.writeValue(ue,Pe),{value:Pe,valueOwner:i.currentValueArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else return M[ue.id]}).filter(ue=>!!ue);if(F=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(F.results||[]).forEach(ue=>{var xe,Pe,Be;if(ue.valueOwner.type!==d.InputMap||Ut.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>le(Se,a)===le(ue.valueOwner,a)),_e=[...(xe=M[ye.id].value)==null?void 0:xe.value,((Pe=ue.value)==null?void 0:Pe.value)||null];(Be=M[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,M[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ee++}break}case Q.loop["object-keys-loop"].id:{const ie=$[0];let ee=1;const de=ie?Object.keys(ie):[];for(let ae=0;ae<de.length;ae++){const fe=de[ae],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,a);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=Tc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const xe={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Pe=Si(xe,a);return this.lastExecutionResults.writeValue(ue,Pe),{value:Pe,valueOwner:i.currentValueArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else return M[ue.id]}).filter(ue=>!!ue);if(F=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(F.results||[]).forEach(ue=>{var xe,Pe,Be;if(ue.valueOwner.type!==d.InputMap||Ut.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>le(Se,a)===le(ue.valueOwner,a)),_e=[...(xe=M[ye.id].value)==null?void 0:xe.value,((Pe=ue.value)==null?void 0:Pe.value)||null];(Be=M[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,M[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ee++}break}case Q.loop["object-values-loop"].id:{const ie=$[0];let ee=1;const de=ie?Object.values(ie):[];for(let ae=0;ae<de.length;ae++){const fe=de[ae],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,a);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=Tc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const xe={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Pe=Si(xe,a);return this.lastExecutionResults.writeValue(ue,Pe),{value:Pe,valueOwner:i.currentValueArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else return M[ue.id]}).filter(ue=>!!ue);if(F=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(F.results||[]).forEach(ue=>{var xe,Pe,Be;if(ue.valueOwner.type!==d.InputMap||Ut.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>le(Se,a)===le(ue.valueOwner,a)),_e=[...(xe=M[ye.id].value)==null?void 0:xe.value,((Pe=ue.value)==null?void 0:Pe.value)||null];(Be=M[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,M[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ee++}break}case Q.loop["string-loop"].id:{const ie=$[0];let ee=1;const de=ie.split("");for(let ae=0;ae<de.length;ae++){const fe=de[ae],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,a);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=Tc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Ne.ExecutionResult,inheritanceLink:null};const xe={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Pe=Si(xe,a);return this.lastExecutionResults.writeValue(ue,Pe),{value:Pe,valueOwner:i.currentValueArgumentDeclaration,type:Ne.ExecutionResult,inheritanceLink:null}}else return M[ue.id]}).filter(ue=>!!ue);if(F=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(F.results||[]).forEach(ue=>{var xe,Pe,Be;if(ue.valueOwner.type!==d.InputMap||Ut.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>le(Se,a)===le(ue.valueOwner,a)),_e=[...(xe=M[ye.id].value)==null?void 0:xe.value,((Pe=ue.value)==null?void 0:Pe.value)||null];(Be=M[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,M[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(F.value))break;ee++}break}}if(V={value:[G.CaughtError,G.Return].includes(F.value)?F.value:G.Success,error:((m=(y=F.error)==null?void 0:y.value)==null?void 0:m.value)||null,result:((E=(v=F==null?void 0:F.result)==null?void 0:v.value)==null?void 0:E.value)||null},V.error&&i.error){const ie=(b=i.error)==null?void 0:b.getDataType(null),ee=It(ie||null,i.error,a);ie!=null&&ie.asType?ee==null||ee.setValueAsTypeSingle(V.error):ee==null||ee.metaSync({value:V.error},null);const de={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:ee};return{value:V.value,entity:i,error:de,result:null}}const U=i==null?void 0:i.getDataType(null),Y=It(U,i,a);return U!=null&&U.asType?Y==null||Y.setValueAsTypeSingle(V.result):Y==null||Y.metaSync({value:V.result},null),{value:V.value,entity:i,error:null,result:{value:Y||null,valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null}}}catch(V){if(J.Logger.warn("Error executing loop: ",V),i.error){const $=(w=i.error)==null?void 0:w.getDataType(null),M=It($,i.error,a);return $!=null&&$.asType?M==null||M.setValueAsTypeSingle(V):M==null||M.metaSync({value:V},null),{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:{valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:M},result:null}}else return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null}}}async executeFunctionCall(i,n,a,c={}){var y,m,v,E,b,w,V,$,M,k,F,U,Y,ie,ee,de,ae,fe,ve,ue,ye,Ve,_e,xe,Pe,Be;const e={...bu,...c};try{const Se=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,n,a,e);let je=null;if(Se.error&&i.error){J.Logger.warn("Raw error executing entity: ",Se.error);const ut=(y=i.error)==null?void 0:y.getDataType(null),_t=It(ut||null,i.error,a);ut!=null&&ut.asType?(v=(m=Se.error)==null?void 0:m.value)!=null&&v.valueAsTypeSingle?_t==null||_t.setValueAsTypeSingle((b=(E=Se.error)==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle):(V=(w=Se.error)==null?void 0:w.value)!=null&&V.valueAsTypeList&&Array.isArray((M=($=Se.error)==null?void 0:$.value)==null?void 0:M.valueAsTypeList)&&(_t==null||_t.setValueAsTypeList((F=(k=Se.error)==null?void 0:k.value)==null?void 0:F.valueAsTypeList)):_t==null||_t.metaSync({value:(Y=(U=Se.error)==null?void 0:U.value)==null?void 0:Y.value},null),je={valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:_t}}let Ze=G.Success;Se.value===G.UnhandledError&&(i.catchesError||i.errorCalls.length?Ze=G.CaughtError:Ze=G.UnhandledError);const Ye=i==null?void 0:i.getDataType(null),lt=It(Ye,i,a);return Ye!=null&&Ye.asType?(ee=(ie=Se.result)==null?void 0:ie.value)!=null&&ee.valueAsTypeSingle?lt==null||lt.setValueAsTypeSingle((ae=(de=Se.result)==null?void 0:de.value)==null?void 0:ae.valueAsTypeSingle):(ve=(fe=Se.result)==null?void 0:fe.value)!=null&&ve.valueAsTypeList&&Array.isArray((ye=(ue=Se.result)==null?void 0:ue.value)==null?void 0:ye.valueAsTypeList)&&(lt==null||lt.setValueAsTypeList((_e=(Ve=Se.result)==null?void 0:Ve.value)==null?void 0:_e.valueAsTypeList)):lt==null||lt.metaSync({value:((Pe=(xe=Se.result)==null?void 0:xe.value)==null?void 0:Pe.value)||null},null),{value:Ze,entity:i,error:je,result:{value:lt||null,valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null}}}catch(Se){if(!i.error)return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null};const je=(Be=i.error)==null?void 0:Be.getDataType(null),Ze=It(je,i.error,a);return je!=null&&je.asType?Ze==null||Ze.setValueAsTypeSingle(Se):Ze==null||Ze.metaSync({value:Se},null),{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:{valueOwner:i.error,type:Ne.ExecutionResult,inheritanceLink:null,value:Ze},result:null}}}async executeCondition(i,n){var c,e,y,m;let a=!1;switch(i.declaration.id){case en.BooleanIsTrue:{const v=(e=(c=n[0])==null?void 0:c.value)==null?void 0:e.value;if(typeof v!="boolean")throw new TypeError("BooleanIsTrue expects a boolean input.");a=v===!0;break}case en.BooleanIsFalse:{const v=(m=(y=n[0])==null?void 0:y.value)==null?void 0:m.value;if(typeof v!="boolean")throw new TypeError("BooleanIsFalse expects a boolean input.");a=v===!1;break}case or.And:{a=(await Promise.all(i.andChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(n,E);return(await this.executeCondition(E,b)).value===G.Success}))).every(E=>E);break}case or.Or:{a=(await Promise.all(i.orChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(n,E);return(await this.executeCondition(E,b)).value===G.Success}))).some(E=>E);break}default:throw new Error(`Condition declaration ${i.declaration.name} does not have an implementation.`)}return{value:a?G.Success:G.ConditionNotMet,entity:i,error:null,result:null}}async executeDetachedFullFunctionDeclarationLogic(i,n,a,c={}){const e={...bu,...c,onBeforeEntityExecution:(v,E,b)=>{var w;return((w=c==null?void 0:c.onBeforeEntityExecution)==null?void 0:w.call(c,v,E,{...b,detached:!0}))||Promise.resolve()},onEntityExecuted:(v,E,b)=>{var w;return((w=c==null?void 0:c.onEntityExecuted)==null?void 0:w.call(c,v,E,{...b,detached:!0}))||Promise.resolve()}},y=new Ru(a,[i,...PA(i)],i,this,this.parentContext);return y.inheritValuesFromContext(this),await y.execute(e,n)}async executeFullFunctionDeclarationLogic(i,n,a={}){const c={...bu,...a},e=PA(i);e.forEach(v=>{this.addEntity(v)}),e.reduce((v,E)=>Ut.includes(E.type)?[...v,...E.outputs]:ei.includes(E.type)&&E.type!==d.Condition?[...v,...E.outputs,...E.inputs]:E.type===d.Condition?[...v,...E.inputs]:v,[]).forEach(v=>{this.lastExecutionResults.removeValue(v.id)});const m=await this.executeBranch(i,c,n);return{...m||{},value:(m==null?void 0:m.value)||G.Success,entity:i,error:(m==null?void 0:m.error)||null,result:(m==null?void 0:m.result)||null}}static async executeEntryPointEntity(i,n){return{value:G.Success,entity:i,error:null,result:null}}async executeReturnStatement(i,n){var y,m,v,E,b,w,V;if((y=i.throws)!=null&&y.readsValue){const $=Io(i.throws,this.valueResolutionContext);return{value:G.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Ne.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Io(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((m=c==null?void 0:c.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)yr((v=a==null?void 0:a.value)==null?void 0:v.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const M=It(c,i,this.project);M==null||M.metaSync({value:$},null),a={valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null,value:M}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(M=>{var k,F;if(((k=M.declaration)==null?void 0:k.type)===d.Property&&M.declaration.static){const U=this.lastExecutionResults.readValue(M.declaration.id),Y=le(M,this.project),ie=M.codeName||((F=M.declaration)==null?void 0:F.codeName)||Hi(Y);if(U)U.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,U);else{const ee=It(M.getDataType(null),M,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&yr((w=a.value)==null?void 0:w.value)?((V=a.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var U;const M=$.codeName||((U=$.declaration)==null?void 0:U.codeName)||Hi(le($,this.project)),k=e[M],F=It($.getDataType(null),$,this.project);F==null||F.metaSync({value:k},null),Ne.ExecutionResult}),a.type=Ne.ExecutionResult,{value:G.Return,entity:i,error:null,result:a}}async executeContinueStatement(i,n){var y,m,v,E,b,w,V;if((y=i.throws)!=null&&y.readsValue){const $=Io(i.throws,this.valueResolutionContext);return{value:G.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Ne.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Io(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((m=c==null?void 0:c.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)yr((v=a==null?void 0:a.value)==null?void 0:v.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const M=It(c,i,this.project);M==null||M.metaSync({value:$},null),a={valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null,value:M}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(M=>{var k,F;if(((k=M.declaration)==null?void 0:k.type)===d.Property&&M.declaration.static){const U=this.lastExecutionResults.readValue(M.declaration.id),Y=le(M,this.project),ie=M.codeName||((F=M.declaration)==null?void 0:F.codeName)||Hi(Y);if(U)U.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,U);else{const ee=It(M.getDataType(null),M,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&yr((w=a.value)==null?void 0:w.value)?((V=a.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var U;const M=$.codeName||((U=$.declaration)==null?void 0:U.codeName)||Hi(le($,this.project)),k=e[M],F=It($.getDataType(null),$,this.project);F==null||F.metaSync({value:k},null),Ne.ExecutionResult}),a.type=Ne.ExecutionResult,{value:G.Continue,entity:i,error:null,result:a}}async executeBreakStatement(i,n){var y,m,v,E,b,w,V;if((y=i.throws)!=null&&y.readsValue){const $=Io(i.throws,this.valueResolutionContext);return{value:G.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Ne.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Io(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((m=c==null?void 0:c.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)yr((v=a==null?void 0:a.value)==null?void 0:v.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const M=It(c,i,this.project);M==null||M.metaSync({value:$},null),a={valueOwner:i,type:Ne.ExecutionResult,inheritanceLink:null,value:M}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(M=>{var k,F;if(((k=M.declaration)==null?void 0:k.type)===d.Property&&M.declaration.static){const U=this.lastExecutionResults.readValue(M.declaration.id),Y=le(M,this.project),ie=M.codeName||((F=M.declaration)==null?void 0:F.codeName)||Hi(Y);if(U)U.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,U);else{const ee=It(M.getDataType(null),M,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&yr((w=a.value)==null?void 0:w.value)?((V=a.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var U;const M=$.codeName||((U=$.declaration)==null?void 0:U.codeName)||Hi(le($,this.project)),k=e[M],F=It($.getDataType(null),$,this.project);F==null||F.metaSync({value:k},null),Ne.ExecutionResult}),a.type=Ne.ExecutionResult,{value:G.Break,entity:i,error:null,result:a}}async executeVariable(i,n){var m,v,E,b,w,V;let a=Io(i,this.valueResolutionContext);const c=Hn(i),e=c.getDataType(null);if(e!=null&&e.isObject()){let $={};if(((m=e==null?void 0:e.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...e.entity.getActiveRawDefaultValue()}),a!=null&&a.value)yr((v=a==null?void 0:a.value)==null?void 0:v.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const M=It(e,i,this.project);M==null||M.metaSync({value:$},null),a={valueOwner:c,type:Ne.ExecutionResult,inheritanceLink:null,value:M}}this.lastExecutionResults.writeValue(c,a.value),c.inputs.forEach(M=>{var k,F;if(((k=M.declaration)==null?void 0:k.type)===d.Property&&M.declaration.static){const U=this.lastExecutionResults.readValue(M.declaration.id),Y=le(M,this.project),ie=M.codeName||((F=M.declaration)==null?void 0:F.codeName)||Hi(Y);if(U)U.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,U);else{const ee=It(M.getDataType(null),M,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(M.declaration,ee)}}})}else this.lastExecutionResults.writeValue(c,a==null?void 0:a.value);const y=(b=a==null?void 0:a.value)!=null&&b.value&&yr((w=a.value)==null?void 0:w.value)?((V=a.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var U;const M=$.codeName||((U=$.declaration)==null?void 0:U.codeName)||Hi(le($,this.project)),k=y[M],F=It($.getDataType(null),$,this.project);F==null||F.metaSync({value:k},null),Ne.ExecutionResult}),a.type=Ne.ExecutionResult,{value:G.Success,entity:i,error:null,result:a}}mergeValues(i,n){const a=[];for(let c=0;c<n.length;c++)i!=null&&i[c]?a.push(i[c]):a.push(n[c]);return a}async executeEntity(i,n=[],a={}){var y,m,v,E,b,w,V,$,M,k,F;const c={...bu,...a},e={detached:!1};switch(i.type){case d.Condition:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((y=c.onBeforeEntityExecution)==null?void 0:y.call(c,i,U,e)),this.executeCondition(i,U)}case d.InternalCall:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((m=c.onBeforeEntityExecution)==null?void 0:m.call(c,i,U,e)),this.executeInternalCall(i,U,this.project)}case d.Operation:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((v=c.onBeforeEntityExecution)==null?void 0:v.call(c,i,U,e)),Ru.executeOperation(i,U,this.project)}case d.VariableInstance:case d.VariableDeclaration:return this.executeVariable(i,n);case d.FunctionCall:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((E=c.onBeforeEntityExecution)==null?void 0:E.call(c,i,U,e)),this.executeFunctionCall(i,U,this.project)}case d.FunctionDeclaration:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((b=c.onBeforeEntityExecution)==null?void 0:b.call(c,i,U,e)),Ru.executeEntryPointEntity(i,U)}case d.Search:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((w=c.onBeforeEntityExecution)==null?void 0:w.call(c,i,U,e)),this.executeSearch(i,U,this.project)}case d.Loop:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((V=c.onBeforeEntityExecution)==null?void 0:V.call(c,i,U,e)),this.executeLoop(i,U,this.project,c)}case d.ReturnStatement:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await(($=c.onBeforeEntityExecution)==null?void 0:$.call(c,i,U,e)),this.executeReturnStatement(i,U)}case d.ContinueStatement:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((M=c.onBeforeEntityExecution)==null?void 0:M.call(c,i,U,e)),this.executeContinueStatement(i,U)}case d.BreakStatement:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((k=c.onBeforeEntityExecution)==null?void 0:k.call(c,i,U,e)),this.executeBreakStatement(i,U)}case d.GlobalEvent:{const U=this.mergeExernalValuesWithInternalInputs(n,i);return await((F=c.onBeforeEntityExecution)==null?void 0:F.call(c,i,U,e)),Ru.executeEntryPointEntity(i,U)}default:throw new Error(`Entity type ${i==null?void 0:i.type} is not recognized for execution.`)}}storeLastExecutionValues(i){var a,c,e;if(i.error&&i.error.valueOwner&&this.lastExecutionResults.writeValue(i.error.valueOwner,i.error.value),!i.result||!((a=i.result)!=null&&a.valueOwner))return;const n=_o((c=i.result)==null?void 0:c.valueOwner,this.project);(e=i.result)!=null&&e.value?n.forEach(y=>{var m;this.lastExecutionResults.writeValue(y,(m=i.result)==null?void 0:m.value)}):n.forEach(y=>{this.lastExecutionResults.removeValue(y.id)})}async executeBranch(i,n={},a=[]){var v;const c={...bu,...n},e={detached:!1};if(!this.hasEntity(i)||this.hasSkipped(i))return null;this.addToExecutingList(i),this.hasScheduled(i)&&this.removeScheduled(i);const m=await this.executeEntity(i,a,c);if(this.removeFromExecutingList(i),this.addToAlreadyExecutedList(i),this.storeLastExecutionValues(m),await((v=c.onEntityExecuted)==null?void 0:v.call(c,i,m,e)),m.value===G.Success){const E=(i.successCalls||i.calls||[]).filter(M=>this.hasEntity(M));(i.errorCalls||[]).forEach(M=>{this.skip(M)});let w=[];const V=(await Promise.all(E.map(M=>this.schedule(M,[],c)))).filter(M=>!!M),$=V.filter(M=>!!M).find(M=>M.value===G.CaughtError||M.value===G.Return||M.value===G.Break||M.value===G.Continue);return $||(w=[...w,...V],m)}else if(m.value===G.CaughtError||m.value===G.ConditionNotMet){const E=(i.errorCalls||[]).filter(M=>this.hasEntity(M));(i.successCalls||i.calls||[]).forEach(M=>{this.skip(M)});let w=[];const V=(await Promise.all(E.map(M=>this.schedule(M,[],c)))).filter(M=>!!M),$=V.filter(M=>!!M).find(M=>M.value===G.CaughtError||M.value===G.UnhandledError||M.value===G.Return||M.value===G.Break||M.value===G.Continue);return $||(w=[...w,...V],m)}else{if(m.value===G.UnhandledError)return this.executing.forEach(E=>{this.skip(E)}),this.scheduled.forEach(E=>{this.skip(E)}),Zr.includes(m.entity.type)&&Rt(m.entity).forEach(E=>{this.skip(E)}),m;if(m.value===G.Return)return m;if(m.value===G.Break)return m;if(m.value===G.Continue)return m}return m}async execute(i={},n=[]){const a={...bu,...i};this.state="running";const c=await this.executeBranch(this.entryPoint,a,n);return this.state="finished-success",c}addEntity(i){var n;this.entities.includes(i)||(this.entities.push(i),(n=this.onAddEntityCallback)==null||n.call(this,i,{}))}async addEntityAsync(i,n={}){var a;this.entities.includes(i)||(this.entities.push(i),await((a=this.onAddEntityCallback)==null?void 0:a.call(this,i,n)))}addEntities(i){i.forEach(n=>this.addEntity(n))}async addEntitiesAsync(i,n={}){const a=J.YieldTracker.from(n),c=[];for(const e of i)c.push(this.addEntityAsync(e,n)),await a.tick();await Promise.all(c)}removeEntity(i){var n;if(i!==this.entryPoint){const a=this.entities.indexOf(i);a>-1&&(this.entities.splice(a,1),(n=this.onRemoveEntityCallback)==null||n.call(this,i,{}))}}hasEntity(i){var c,e,y;if(this.entities.includes(i))return!0;if(((c=i.parent)==null?void 0:c.type)===d.FunctionDeclaration&&((y=(e=i.parent)==null?void 0:e.parent)==null?void 0:y.type)===d.DefinitionEntity)return this.entities.includes(i.parent);const n=oi(i);if(!n)return!1;const a=n.type===d.Loop&&i.parent===n.body?n.body:null;return a?this.entities.includes(a)||this.entities.includes(n):this.entities.includes(n)}removeScheduled(i){const n=this.scheduled.indexOf(i);n>-1&&this.scheduled.splice(n,1)}hasScheduled(i){return!!this.scheduled.includes(i)}hasSkipped(i){return!!this.skipped.includes(i)}hasExecuted(i){return!!this.executed.includes(i)}hasEntityWithId(i){const n=this.project.get(i);return n?this.hasEntity(n):!1}onAddToSkippedList(i){this.onAddToSkippedListCallback=i}onAbortExecution(i){this.onAbortExecutionCallback=i}onAddEntity(i){this.onAddEntityCallback=i}onRemoveFromSkippedList(i){this.onRemoveFromSkippedListCallback=i}onRemoveEntity(i){this.onRemoveEntityCallback=i}addToExecutingList(i){this.executing.includes(i)||this.executing.push(i)}addToScheduledList(i){this.scheduled.includes(i)||this.scheduled.push(i)}removeFromScheduledList(i){const n=this.scheduled.indexOf(i);n>-1&&this.scheduled.splice(n,1)}removeFromExecutingList(i){var a;const n=this.executing.indexOf(i);n>-1&&(this.executing.splice(n,1),(a=this.onAbortExecutionCallback)==null||a.call(this,i,{}))}removeFromAlreadyExecutedList(i){const n=this.executed.indexOf(i);n>-1&&this.executed.splice(n,1)}removeFromSkippedList(i){var a;const n=this.skipped.indexOf(i);n>-1&&(this.skipped.splice(n,1),(a=this.onRemoveFromSkippedListCallback)==null||a.call(this,i,{}))}addToAlreadyExecutedList(i){this.executed.includes(i)||this.executed.push(i)}addToSkippedList(i){var n;this.skipped.includes(i)||(this.skipped.push(i),(n=this.onAddToSkippedListCallback)==null||n.call(this,i,{}))}getValueTypePreference(i){return this.parentContext.getValueTypePreference(i)||null}setValueTypePreference(i,n){this.parentContext.setValueTypePreference(i,n),this.emit(i,{})}}function Lbi(o){var p,i;if(o.isList)return"list";if(((p=o.entity)==null?void 0:p.type)===d.DefinitionEntity)return"definition-entity";switch((i=o.entity)==null?void 0:i.name){case oe.Number:return"number";case oe.String:return"text";case oe.Boolean:return"boolean";case oe.UUID:return"uuid";case oe.Date:return"date-time";default:return"definition-entity"}}const as={[d.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[d.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[d.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[d.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[d.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[d.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[d.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[d.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[d.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[d.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[d.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[d.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[d.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[d.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[d.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[d.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[d.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[d.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[d.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[d.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"},[d.DataType]:{singular:"Data type",plural:"Data types",shortSingular:"Data type",shortPlural:"Data types"},[d.LiteralValue]:{singular:"Literal value",plural:"Literal values",shortSingular:"Value",shortPlural:"Values"}};function mN(o){const p=$R(o);if(!p){const n=Ly(o);if(n.includes(Re.HTTP_ENDPOINT))return"HTTP endpoint";if(n.includes(Re.PERSISTED_ENTITY))return"Persisted entity";if(n.includes(Re.CRON_JOB))return"Scheduled execution";if(n.includes(Re.RELATIONAL_DATABASE))return"Relational database"}if(p){let n="Extension of "+le(p,p.project)+" entity",a=Co(n);const c=Ly(o);return c.includes(Re.HTTP_ENDPOINT)?"HTTP endpoint"+(a?", "+a:""):c.includes(Re.PERSISTED_ENTITY)?"Persisted entity"+(a?", "+a:""):c.includes(Re.CRON_JOB)?"Scheduled execution"+(a?", "+a:""):c.includes(Re.RELATIONAL_DATABASE)?"Relational database"+(a?", "+a:""):n}let i="";return o.abstract&&(i="Template "),o.static&&(i+=i?" single copy ":"Single copy "),i?i+"definition":"Definition"}function oLe(o){return o.parent.type===d.DefinitionEntity||o.parent.type===d.InstalledProject?"Internal action of "+le(o.parent,o.project):o.parent.type===d.Loop?"Action repeated on every iteration":"Internal action of entity"}function TN(o){return hx(o)?oLe(o):"Custom trigger"}function Mbi(o){var p;switch(o.type){case d.DefinitionEntity:return mN(o);case d.FunctionDeclaration:return TN(o)}return(p=as[o.type])==null?void 0:p.singular}function Bbi(o){var p;switch(o.type){case d.DefinitionEntity:return mN(o);case d.FunctionDeclaration:return TN(o)}return(p=as[o.type])==null?void 0:p.singular}const vN=4e4,dLe=280,Gbi=300,EN=65,fy=32,Zb=39,uLe=26,pLe=49,EA=44,kbi=35,Hb=52,bN=10,pd=bN*2,bA=38,Wb=90,oC=270,cLe=vN/2+120,fLe=vN/2+180;function yLe(o){let i=fy+EA+bA+bN;const n=[...o.inputs];return n.length&&(i+=pd,n.forEach(()=>{i+=uLe})),{height:i,width:280}}function hLe(o){let i=EN;const n=[];if([d.DefinitionEntity].includes(o.type)){const m=[...o.suggestedProperties||[],...o.properties||[]];m.length&&(i+=pd,m.forEach(v=>{i+=v.static?pLe:Zb}))}if([d.DefinitionEntity,d.InstalledProject,d.Loop].includes(o.type)){const m=[...(o==null?void 0:o.suggestedMethods)||[],...o.methods||[],...o.functions||[],...o.body?[o.body]:[]];m.length&&(i+=pd,m.forEach(v=>{const E=yLe(v);i+=E.height}))}ei.includes(o.type)?(Gt.includes(o.type)?n.push(...(o.usedInputs||[]).flatMap(m=>[m])||[]):n.push(...(o.inputs||[]).flatMap(m=>[m])||[]),o.error&&(i+=Hb)):[d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(o.type)?(n.push(...o.outputs||[]),o.throws&&(i+=Hb)):o.type===d.Condition&&(n.push(o.inputs[0]),o.inputs[1]&&n.push(o.inputs[1]));const a=n.length;a&&(i+=a*Zb,i+=pd);const c=[];if(o.type===d.FunctionDeclaration||o.type===d.GlobalEvent?c.push(...o.inputs||[]):ei.includes(o.type)&&(Gt.includes(o.type)?c.push(...o.usedOutputs||[]):c.push(...o.outputs||[])),Gt.includes(o.type)){o.readsValue&&(i+=pd,i+=EA),o.writesValues.length&&(i+=pd,i+=EA),o.internalCalls.length&&o.usedInternalCalls.forEach(()=>i+=Hb+pd);const m=o.getDataType(null);(!m||m.inferred)&&(i+=bA)}const e=c.length;return e&&(i+=e*Zb,i+=pd),[d.DefinitionEntity,d.FunctionDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(o.type)&&(i+=bA),{height:i,width:280}}function pv(o){return`${o.split("-").map((n,a)=>a===0?n.charAt(0).toUpperCase()+n.slice(1):n.toLowerCase()).join(" ")}.`}function jbi(o){switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case he.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case he.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case he.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case he.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case he.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case he.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case Ie.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case Ie.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case he.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case he.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case Ie.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case he.NoProperties:return"This entity has no properties, so it doesn't do anything";case he.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case he.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case he.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case he.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case he.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case he.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case he.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case he.PropertyImplementsNonAbstact:return"This property implements a non-template property";case he.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case he.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case he.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case he.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case he.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case Ie.InternalCallDeclarationIsInvalidType:return"This internal call is not an action";case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case Ie.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case Ie.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case Ie.UnreachableEntity:return"This entity is unreachable";case he.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";case he.AbstractEntityImplements:return"This template entity implements a non-template entity";case he.AbstractExtendingNonAbstractEntity:return"This template entity extends a non-template entity";case he.InvalidPropertiesCombination:return"This entity has an invalid combination of properties";case he.ExtendingNonInteractiveEntity:return"This entity extends a non-interactive entity";case he.ExtendsIncompatibleEntities:return"This entity extends incompatible entities";case he.ImplementingNonAbstractEntity:return"This entity implements a non-template entity";case he.ImplementsIncompatibleEntities:return"This entity implements incompatible entities";case he.LackingReturnStatementOnSomeBranches:return"This action is missing a termination on some branches";case he.LastCalledEntityMustBeReturnEntity:return"The last called entity in this action must be a termination node";case he.MissingRequiredValue:return"This action is missing a required value";case he.NoPrimaryKeyProperty:return"This entity has no primary key property";case he.NonAbstractExtendingAbstractEntity:return"This non-template entity extends a template entity";case he.NonStaticExtendingStaticEntity:return"This non-static entity extends a static entity";case he.NonStaticImplementingStaticEntity:return"This non-static entity implements a static entity";case he.StaticExtendingNonStaticEntity:return"This static entity extends a non-static entity";case he.StaticImplementingNonStaticEntity:return"This static entity implements a non-static entity";case he.VariableReadsValueAndInternalCall:return"This variable reads a value while being used to execute internal logic";case he.VariableWritesValuesAndInternalCall:return"This variable writes values while being used to execute internal logic";case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return"This internal call declaration is not in the parent entity";case Ie.EmptyName:return"This entity has no name";case Ie.InvalidObjectStructure:return"This entity has an invalid structure";case Ie.LoopBodyFunctionOverwrite:return"This loop body action overwrites an action in the template entity with the same name";case Ie.MethodOverwritesBaseMethodWithSameImplementation:return"This action overwrites a base action with the same implementation";case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"This action overwrites an action in an extended entity with the same implementation";case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"This action overwrites an action in an implemented entity with the same implementation";case Ie.MissingCaller:return"This action is missing a caller";case Ie.NameAsResolvedCodeNameNotUniqueInScope:return"This entity has a name that is not unique in the scope of the code it is used in";case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"This entity name can only contain letters, numbers, underscores and spaces";case Ie.NameMustStartWithLetterOrUnderscore:return"This entity name must start with a letter or an underscore";case Ie.NoOverlapWithImplementedSignature:return"This action does not overlap with the implemented action signature";case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return"This property overwrites a base property with the same implementation";case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an extended entity with the same implementation";case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an implemented entity with the same implementation";case Ie.ReaderWriterIncompatibleDataType:return"This reader/writer has an incompatible data type with the value it is reading/writing";case $o.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case $o.StatusCodeMustBeNumber:return"HTTP status code must be a number, between 100 and 599";case Ba.UUIDMustBeString:return`UUID must be a string, eg: "${wu()}"`;case Ba.UUIDMustNotContainSpaces:return`UUID must not contain spaces, eg: "${wu()}"`;case Ba.UUIDMustBeValidFormat:return`UUID must be in a valid format. Eg: "${wu()}"`;case aa.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case aa.StringValueMustNotHaveDashes:return"This value must not contain dashes";case aa.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return pv(o.code)}}function Ubi(o){switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case he.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case he.IncorrectEntityImplementation:return"Incorrect implementation";case he.IncorrectMethodImplementation:return"Incorrect action implementation";case he.IncorrectPropertyImplementation:return"Incorrect property implementation";case he.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case he.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case Ie.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case Ie.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case he.MissingMethodImplementation:return"Missing action";case he.MissingPropertyImplementation:return"Missing property";case Ie.NameNotUniqueInScope:return"Duplicate name";case he.NoProperties:return"No properties";case he.NonStaticPropertyInStaticEntity:return"Non-static property";case he.StaticEntityWithNonStaticProperties:return"Non-static properties";case he.ReadingFromIncompatibleType:return"Read from different type";case he.WritingToIncompatibleType:return"Write to different type";case he.ScopeWithoutLogic:return"No logic";case he.NonStaticPropertyImplementsStatic:return"Invalid static property";case he.PropertyImplementsIncompatibleType:return"Incompatible data type";case he.PropertyImplementsNonAbstact:return"Non-template property";case he.StaticPropertyImplementsNonStatic:return"Non-static property";case he.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case he.VariableHasInputsAndInternalCall:return"Bad internal call";case he.VariableHasOutputsAndInternalCall:return"Bad internal call";case he.VariableIsCalledAndHasInternalCall:return"Bad internal call";case Ie.InternalCallDeclarationIsInvalidType:return"Declaration not an action";case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case Ie.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case Ie.InternalCallParentMissingDataType:return"Parent has no data type";case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case Ie.UnreachableEntity:return"Unreachable entity";case he.DisconnectedCallableEntity:return"Disconnected entity";case he.AbstractEntityImplements:return"Abstract entity implements a non-template entity";case he.AbstractExtendingNonAbstractEntity:return"Abstract entity extends a non-template entity";case he.InvalidPropertiesCombination:return"Invalid properties combination";case he.ExtendingNonInteractiveEntity:return"Extending non-interactive entity";case he.ExtendsIncompatibleEntities:return"Extends incompatible entities";case he.ImplementingNonAbstractEntity:return"Implementing non-template entity";case he.ImplementsIncompatibleEntities:return"Implements incompatible entities";case he.LackingReturnStatementOnSomeBranches:return"Missing termination on some branches";case he.LastCalledEntityMustBeReturnEntity:return"Last called entity must be a termination node";case he.MissingRequiredValue:return"Missing required value";case he.NoPrimaryKeyProperty:return"No primary key property";case he.NonAbstractExtendingAbstractEntity:return"Non-template entity extending a template entity";case he.NonStaticExtendingStaticEntity:return"Non-static entity extending a static entity";case he.NonStaticImplementingStaticEntity:return"Non-static entity implementing a static entity";case he.StaticExtendingNonStaticEntity:return"Static entity extending a non-static entity";case he.StaticImplementingNonStaticEntity:return"Static entity implementing a non-static entity";case he.VariableReadsValueAndInternalCall:return"Variable reads value and has internal call";case he.VariableWritesValuesAndInternalCall:return"Variable writes values and has internal call";case Ie.EmptyName:return"Empty name";case Ie.InvalidObjectStructure:return"Invalid object structure";case Ie.LoopBodyFunctionOverwrite:return"Loop body action overwrites action with same name";case Ie.MethodOverwritesBaseMethodWithSameImplementation:return"Action overwrites base action with same implementation";case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case Ie.MissingCaller:return"Missing caller";case Ie.NameAsResolvedCodeNameNotUniqueInScope:return"Name not unique in scope";case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"Name can only contain letters, numbers, underscores and spaces";case Ie.NameMustStartWithLetterOrUnderscore:return"Name must start with letter or underscore";case Ie.NoOverlapWithImplementedSignature:return"No overlap with implemented signature";case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return"Property overwrites base property with same implementation";case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case Ie.ReaderWriterIncompatibleDataType:return"Reader/writer incompatible data type";case $o.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case $o.StatusCodeMustBeNumber:return"HTTP status code must be a number";case Ba.UUIDMustBeString:return"UUID must be a string";case Ba.UUIDMustNotContainSpaces:return"UUID must not contain spaces";case Ba.UUIDMustBeValidFormat:return"UUID must be in a valid format";case aa.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case aa.StringValueMustNotHaveDashes:return"This value must not contain dashes";case aa.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return pv(o.code)}}function Kbi(o){switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return`${le(o.entity,o.entity.project)} has non-template actions`;case he.AbstractEntityWithNonAbstractProperties:return`${le(o.entity,o.entity.project)} has non-template properties`;case he.IncorrectEntityImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements template`;case he.IncorrectMethodImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements the template`;case he.IncorrectPropertyImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements the template`;case he.AbstractMethodInNonAbstractEntity:return`${le(o.entity,o.entity.project)} can't be a template`;case he.AbstractPropertyInNonAbstractEntity:return`${le(o.entity,o.entity.project)} can't be a template`;case Ie.MethodOverwritesOtherSiblingWithSameName:return`${le(o.entity,o.entity.project)} overwrites action`;case Ie.PropertyOverwritesOtherSiblingWithSameName:return`${le(o.entity,o.entity.project)} overwrites property`;case he.MissingMethodImplementation:return`${le(o.entity,o.entity.project)} is missing action`;case he.MissingPropertyImplementation:return`${le(o.entity,o.entity.project)} is missing property`;case Ie.NameNotUniqueInScope:return`${le(o.entity,o.entity.project)} name is not unique`;case he.NoProperties:return`${le(o.entity,o.entity.project)} has no properties`;case he.NonStaticPropertyInStaticEntity:return`${le(o.entity,o.entity.project)} has non-static property`;case he.StaticEntityWithNonStaticProperties:return`${le(o.entity,o.entity.project)} has non-static properties`;case he.ReadingFromIncompatibleType:return`${le(o.entity,o.entity.project)} reads from different type`;case he.WritingToIncompatibleType:return`${le(o.entity,o.entity.project)} writes to different type`;case he.ScopeWithoutLogic:return`${le(o.entity,o.entity.project)} has no logic`;case he.NonStaticPropertyImplementsStatic:return`${le(o.entity,o.entity.project)} has invalid static property`;case he.PropertyImplementsIncompatibleType:return`${le(o.entity,o.entity.project)} has incompatible data type`;case he.PropertyImplementsNonAbstact:return`${le(o.entity,o.entity.project)} has non-template property`;case he.StaticPropertyImplementsNonStatic:return`${le(o.entity,o.entity.project)} has non-static property`;case he.VariableCallsOthersAndHasInternalCall:return`${le(o.entity,o.entity.project)} has bad internal call`;case he.VariableHasInputsAndInternalCall:return`${le(o.entity,o.entity.project)} has bad internal call`;case he.VariableHasOutputsAndInternalCall:return`${le(o.entity,o.entity.project)} has bad internal call`;case he.VariableIsCalledAndHasInternalCall:return`${le(o.entity,o.entity.project)} has bad internal call`;case Ie.InternalCallDeclarationIsInvalidType:return`${le(o.entity,o.entity.project)} has declaration that is not an action`;case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${le(o.entity,o.entity.project)} has declaration that is not found in parent`;case Ie.InternalCallParentDeclarationEntityInvalidType:return`${le(o.entity,o.entity.project)} has invalid parent declaration type`;case Ie.InternalCallParentMissingDataType:return`${le(o.entity,o.entity.project)}'s parent has no data type`;case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return`${le(o.entity,o.entity.project)} has declaration that is not in parent`;case Ie.UnreachableEntity:return`${le(o.entity,o.entity.project)} is unreachable`;case he.DisconnectedCallableEntity:return`${le(o.entity,o.entity.project)} is not executed by any entity`;case he.AbstractEntityImplements:return`${le(o.entity,o.entity.project)} implements a non-template entity`;case he.AbstractExtendingNonAbstractEntity:return`${le(o.entity,o.entity.project)} extends a non-template entity`;case he.InvalidPropertiesCombination:return`${le(o.entity,o.entity.project)} has invalid properties combination`;case he.ExtendingNonInteractiveEntity:return`${le(o.entity,o.entity.project)} extends a non-interactive entity`;case he.ExtendsIncompatibleEntities:return`${le(o.entity,o.entity.project)} extends incompatible entities`;case he.ImplementingNonAbstractEntity:return`${le(o.entity,o.entity.project)} implements a non-template entity`;case he.ImplementsIncompatibleEntities:return`${le(o.entity,o.entity.project)} implements incompatible entities`;case he.LackingReturnStatementOnSomeBranches:return`${le(o.entity,o.entity.project)} is missing termination on some branches`;case he.LastCalledEntityMustBeReturnEntity:return`${le(o.entity,o.entity.project)}'s last called entity must be a termination node`;case he.MissingRequiredValue:return`${le(o.entity,o.entity.project)} is missing a required value`;case he.NoPrimaryKeyProperty:return`${le(o.entity,o.entity.project)} has no primary key property`;case he.NonAbstractExtendingAbstractEntity:return`${le(o.entity,o.entity.project)} extends a template entity`;case he.NonStaticExtendingStaticEntity:return`${le(o.entity,o.entity.project)} extends a static entity`;case he.NonStaticImplementingStaticEntity:return`${le(o.entity,o.entity.project)} implements a static entity`;case he.StaticExtendingNonStaticEntity:return`${le(o.entity,o.entity.project)} extends a non-static entity`;case he.StaticImplementingNonStaticEntity:return`${le(o.entity,o.entity.project)} implements a non-static entity`;case he.VariableReadsValueAndInternalCall:return`${le(o.entity,o.entity.project)} reads a value and has internal call`;case he.VariableWritesValuesAndInternalCall:return`${le(o.entity,o.entity.project)} writes values and has internal call`;case Ie.EmptyName:return`${as[o.entity.type]} has no name`;case Ie.InvalidObjectStructure:return`${le(o.entity,o.entity.project)} has invalid structure`;case Ie.LoopBodyFunctionOverwrite:return`${le(o.entity,o.entity.project)}'s loop body action overwrites an action`;case Ie.MethodOverwritesBaseMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites base action`;case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MissingCaller:return`${le(o.entity,o.entity.project)} is missing a caller`;case Ie.NameAsResolvedCodeNameNotUniqueInScope:return`${le(o.entity,o.entity.project)} has a name not unique in the scope`;case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${le(o.entity,o.entity.project)} name can only contain letters, numbers, underscores and spaces`;case Ie.NameMustStartWithLetterOrUnderscore:return`${le(o.entity,o.entity.project)} name must start with letter or underscore`;case Ie.NoOverlapWithImplementedSignature:return`${le(o.entity,o.entity.project)} has no overlap with implemented signature`;case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites base property`;case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.ReaderWriterIncompatibleDataType:return`${le(o.entity,o.entity.project)} has reader/writer with incompatible data type`;case $o.StatusCodeMustBeBetween100And599:return`${le(o.entity,o.entity.project)} HTTP status code must be between 100 and 599`;case $o.StatusCodeMustBeNumber:return`${le(o.entity,o.entity.project)} HTTP status code must be a number`;case Ba.UUIDMustBeString:return`${le(o.entity,o.entity.project)} UUID must be a string`;case Ba.UUIDMustNotContainSpaces:return`${le(o.entity,o.entity.project)} UUID must not contain spaces`;case Ba.UUIDMustBeValidFormat:return`${le(o.entity,o.entity.project)} UUID must be in a valid format`;case aa.MustBeUniqueAmongSameEntities:return`${le(o.entity,o.entity.project)} value must be unique among the same kind`;case aa.StringValueMustNotHaveDashes:return`${le(o.entity,o.entity.project)} value must not contain dashes`;case aa.StringValueMustNotHaveSpaces:return`${le(o.entity,o.entity.project)} value must not contain spaces`;default:return`${le(o.entity,o.entity.project)} Error: ${pv(o.code)}`}}function Fbi(o){var p,i,n,a;switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return`${le(o.entity,o.entity.project)} has non-template actions`;case he.AbstractEntityWithNonAbstractProperties:return`${le(o.entity,o.entity.project)} has non-template properties`;case he.IncorrectEntityImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements the template entity`;case he.IncorrectMethodImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements the template action it's based on`;case he.IncorrectPropertyImplementation:return`${le(o.entity,o.entity.project)} incorrectly implements the template property it's based on`;case he.AbstractMethodInNonAbstractEntity:return`${le(o.entity,o.entity.project)} is a template action in a non-template entity`;case he.AbstractPropertyInNonAbstractEntity:return`${le(o.entity,o.entity.project)} is a template property in a non-template entity`;case Ie.MethodOverwritesOtherSiblingWithSameName:return`${le(o.entity,o.entity.project)} overwrites an action in the template entity`;case Ie.PropertyOverwritesOtherSiblingWithSameName:return`${le(o.entity,o.entity.project)} overwrites a property in the template entity`;case he.MissingMethodImplementation:return`${le(o.entity,o.entity.project)} is missing an action implementation from the template entity`;case he.MissingPropertyImplementation:return`${le(o.entity,o.entity.project)} is missing a property implementation from the template entity`;case Ie.NameNotUniqueInScope:return`${le(o.entity,o.entity.project)} has a duplicate name in the same scope`;case he.NoProperties:return`${le(o.entity,o.entity.project)} has no properties, so it doesn't do anything`;case he.NonStaticPropertyInStaticEntity:return`${le(o.entity,o.entity.project)} has a non-static property in a static entity`;case he.StaticEntityWithNonStaticProperties:return`${le(o.entity,o.entity.project)} has non-static properties in a static entity`;case he.ReadingFromIncompatibleType:return`${le(o.entity,o.entity.project)} reads data from a value of a different data type`;case he.WritingToIncompatibleType:return`${le(o.entity,o.entity.project)} writes data to a value of a different data type`;case he.ScopeWithoutLogic:return`${le(o.entity,o.entity.project)} has no logic`;case he.NonStaticPropertyImplementsStatic:return`${le(o.entity,o.entity.project)} has a static property in a non-static entity`;case he.PropertyImplementsIncompatibleType:return`${le(o.entity,o.entity.project)} implements a property of a different data type`;case he.PropertyImplementsNonAbstact:return`${le(o.entity,o.entity.project)} implements a non-template property`;case he.StaticPropertyImplementsNonStatic:return`${le(o.entity,o.entity.project)} has a static property in a non-static entity`;case he.VariableCallsOthersAndHasInternalCall:return`${le(o.entity,o.entity.project)} calls other entities while being used to execute internal logic`;case he.VariableHasInputsAndInternalCall:return`${le(o.entity,o.entity.project)} has inputs while being used to execute internal logic`;case he.VariableHasOutputsAndInternalCall:return`${le(o.entity,o.entity.project)} has outputs while being used to execute internal logic`;case he.VariableIsCalledAndHasInternalCall:return`${le(o.entity,o.entity.project)} is called while being used to execute internal logic`;case Ie.InternalCallDeclarationIsInvalidType:return`${le(o.entity,o.entity.project)} has a declaration that is not an action`;case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${le(o.entity,o.entity.project)} has a declaration that is not found in ${(p=o.entity.parent.getDataType(null))!=null&&p.entity?le((i=o.entity.parent.getDataType(null))==null?void 0:i.entity,o.entity.project):"the variable's data-type entity"}`;case Ie.InternalCallParentDeclarationEntityInvalidType:return`${le(o.entity,o.entity.project)} is part of a variable whos data-type entity can't have actions`;case Ie.InternalCallParentMissingDataType:return`${le(o.entity,o.entity.project)} is part of a variable with no data-type entity`;case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return`${le(o.entity,o.entity.project)} has a declaration doesn't belong to ${(n=o.entity.parent.getDataType(null))!=null&&n.entity?le((a=o.entity.parent.getDataType(null))==null?void 0:a.entity,o.entity.project):"the variable's data-type entity"}`;case Ie.UnreachableEntity:return`${le(o.entity,o.entity.project)} is unreachable`;case he.DisconnectedCallableEntity:return`${le(o.entity,o.entity.project)} is disconnected and won't be executed by anything after publishing`;case he.AbstractEntityImplements:return`${le(o.entity,o.entity.project)} implements a non-template entity`;case he.AbstractExtendingNonAbstractEntity:return`${le(o.entity,o.entity.project)} extends a non-template entity`;case he.InvalidPropertiesCombination:return`${le(o.entity,o.entity.project)} has an invalid combination of properties`;case he.ExtendingNonInteractiveEntity:return`${le(o.entity,o.entity.project)} extends a non-interactive entity`;case he.ExtendsIncompatibleEntities:return`${le(o.entity,o.entity.project)} extends incompatible entities`;case he.ImplementingNonAbstractEntity:return`${le(o.entity,o.entity.project)} implements a non-template entity`;case he.ImplementsIncompatibleEntities:return`${le(o.entity,o.entity.project)} implements incompatible entities`;case he.LackingReturnStatementOnSomeBranches:return`${le(o.entity,o.entity.project)} has branches that don't terminate`;case he.LastCalledEntityMustBeReturnEntity:return`${le(o.entity,o.entity.project)} must end with a termination node`;case he.MissingRequiredValue:return`${le(o.entity,o.entity.project)} is missing a required value`;case he.NoPrimaryKeyProperty:return`${le(o.entity,o.entity.project)} has no primary key property`;case he.NonAbstractExtendingAbstractEntity:return`${le(o.entity,o.entity.project)} is a non-template entity extending a template entity`;case he.NonStaticExtendingStaticEntity:return`${le(o.entity,o.entity.project)} is a non-static entity extending a static entity`;case he.NonStaticImplementingStaticEntity:return`${le(o.entity,o.entity.project)} is a non-static entity implementing a static entity`;case he.StaticExtendingNonStaticEntity:return`${le(o.entity,o.entity.project)} is a static entity extending a non-static entity`;case he.StaticImplementingNonStaticEntity:return`${le(o.entity,o.entity.project)} is a static entity implementing a non-static entity`;case he.VariableReadsValueAndInternalCall:return`${le(o.entity,o.entity.project)} reads a value and has an internal call`;case he.VariableWritesValuesAndInternalCall:return`${le(o.entity,o.entity.project)} writes values and has an internal call`;case Ie.EmptyName:return`${as[o.entity.type]} has no name`;case Ie.InvalidObjectStructure:return`${le(o.entity,o.entity.project)} has an invalid structure`;case Ie.LoopBodyFunctionOverwrite:return`${le(o.entity,o.entity.project)}'s loop body action overwrites`;case Ie.MethodOverwritesBaseMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites a base action with same implementation`;case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MissingCaller:return`${le(o.entity,o.entity.project)} is missing a caller`;case Ie.NameAsResolvedCodeNameNotUniqueInScope:return`${le(o.entity,o.entity.project)} has a name that is not unique in the scope`;case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${le(o.entity,o.entity.project)} name can only contain letters, numbers, underscores and spaces`;case Ie.NameMustStartWithLetterOrUnderscore:return`${le(o.entity,o.entity.project)} name must start with letter or underscore`;case Ie.NoOverlapWithImplementedSignature:return`${le(o.entity,o.entity.project)} has no overlap with implemented signature`;case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites a base property with same implementation`;case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${le(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.ReaderWriterIncompatibleDataType:return`${le(o.entity,o.entity.project)} has a reader/writer with incompatible data type`;case $o.StatusCodeMustBeBetween100And599:return`${le(o.entity,o.entity.project)} HTTP status code must be between 100 and 599`;case $o.StatusCodeMustBeNumber:return`${le(o.entity,o.entity.project)} HTTP status code must be a number, between 100 and 599`;case Ba.UUIDMustBeString:return`${le(o.entity,o.entity.project)} UUID must be a string, eg: "${wu()}"`;case Ba.UUIDMustNotContainSpaces:return`${le(o.entity,o.entity.project)} UUID must not contain spaces, eg: "${wu()}"`;case Ba.UUIDMustBeValidFormat:return`${le(o.entity,o.entity.project)} UUID must be in a valid format. Eg: "${wu()}"`;case aa.MustBeUniqueAmongSameEntities:return`${le(o.entity,o.entity.project)} value must be unique among the same kind`;case aa.StringValueMustNotHaveDashes:return`${le(o.entity,o.entity.project)} value must not contain dashes`;case aa.StringValueMustNotHaveSpaces:return`${le(o.entity,o.entity.project)} value must not contain spaces`;default:return`${le(o.entity,o.entity.project)} Error: ${pv(o.code)}`}}var AN=(o=>(o.ValuesAlreadyConnected="values-already-connected",o.CannotReadMoreThanOneValue="cannot-read-more-than-one-value",o.CannotReadValueFromChildren="cannot-read-value-from-children",o.CannotWriteValueToChildren="cannot-write-value-to-children",o.CannotBeCalledByChildren="cannot-be-called-by-children",o.ExecutionsAlreadyConnected="executions-already-connected",o.DataTypesNotCompatible="data-types-not-compatible",o.CannotCallAncestor="cannot-call-ancestor",o.CannotConnectToItself="cannot-connect-to-itself",o.CannotWriteValueToAncestor="cannot-write-value-to-ancestor",o.NotInScope="not-in-scope",o.IsNotValueWrittingEntity="is-not-value-writting-entity",o.IsNotValueReadingEntity="is-not-value-reading-entity",o.ContinueOrBreakStatementCalledFromOutsideLoop="continue-or-break-statement-called-from-outside-loop",o.ElementInLoopBodyCallingOutsideLoop="element-in-loop-body-calling-outside-loop",o.CallerIsInHigherScope="caller-is-in-higher-scope",o.CallerIsInLowerScope="caller-is-in-lower-scope",o.CallIsInHigherScope="call-is-in-higher-scope",o.CallIsInLowerScope="call-is-in-lower-scope",o.OtherIncompatibleScopeReason="other-incompatible-scope-reason",o.SiblingInternalCallAlreadyUsedInParentVariable="sibling-internal-call-already-used-in-parent-variable",o.ErrorOututMapCannotBeConnectedToParentSuccessBranchCallees="error-output-map-cannot-be-connected-to-parent-success-branch-callees",o.SuccessOutputMapCannotBeConnectedToParentErrorBranchCallees="success-output-map-cannot-be-connected-to-parent-error-branch-callees",o))(AN||{});const Sbi=Object.values(AN);var gN=(o=>(o.NotPartOfOngoingTest="not-part-of-ongoing-test",o.CannotBeAddedToTest="cannot-be-added-to-test",o))(gN||{});const qbi=Object.values(gN);var IN=(o=>(o.Suggestion="suggestion",o.CanvasGloballyDisabled="canvas-globally-disabled",o.CannotInteractWithInputInVariableWithInternalCalls="cannot-interact-with-input-in-variable-with-internal-calls",o.CannotInteractWithOutputInVariableWithInternalCalls="cannot-interact-with-output-in-variable-with-internal-calls",o.PropertyIsConstantItsValueCantBeReset="property-is-constant-its-value-cant-be-reset",o.CannotWriteValueOfGlobalVariableDeclaration="cannot-write-value-of-global-variable-declaration",o.CannotReSetValueOfConstantVariable="cannot-reset-value-of-constant-variable",o))(IN||{});const Zbi=Object.values(IN);function Hbi(o,p){const i=[...o,...p];return Array.from(new Set(i))}function Wbi(o,p){const i=[...o,...p],n=Array.from(new Set(i));return{hasChanged:n.length!==o.length,reasons:n}}function zbi(o,p){const i=o.filter(a=>!p.includes(a));return{hasChanged:i.length!==o.length,reasons:i}}function Jbi(o,p){return o.find(i=>i.entity.id===p)||null}function U4(o){return o.filter((p,i)=>o.indexOf(p)===i)}class In{constructor(p,i,n=null,a){I(this,"ids",[]);I(this,"entity");I(this,"entityCardHeight");I(this,"entityCardWidth");I(this,"index");I(this,"childEntities",[]);I(this,"children",[]);I(this,"parents",[]);I(this,"calculationEntryPoint");I(this,"_onlyEntities",null);I(this,"_changeSet",null);if(this.index=i,this.entity=p,this.calculationEntryPoint=n||this,this===this.calculationEntryPoint&&!a)throw new Error("Change set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(p,i,n){const a=cLe-oC-dLe,c=fLe-Wb-EN;p.metaSync({x:p.x||a,y:p.y||c},i);const e=new In(p,0,null,i);e._onlyEntities=n||[],e.ids=["0"];const y=[];e.next(v=>{y.push(...v)}),In.recursivelyAssembleChildrenAreas(y),e.resolveChildrenOverlaps();const m=e.flattenChildEntities();return e._onlyEntities?m.filter(v=>(e._onlyEntities||[]).includes(v)):m}static recursivelyAssembleChildrenAreas(p){const i=[];p.forEach(n=>{n.next(a=>{i.push(...a)})}),i.length>0&&In.recursivelyAssembleChildrenAreas(i)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(p){this.calculationEntryPoint._changeSet=p}findAreaInChildrenFromEntity(p){if(this.entity===p)return this;const i=this.children.find(a=>a.entity===p);return i||this.children.reduce((a,c)=>a||c.findAreaInChildrenFromEntity(p),null)}findAreaFromEntity(p){if(this.entity===p)return this;const i=this.calculationEntryPoint.children,n=i.find(c=>c.entity===p);return n||i.reduce((c,e)=>c||e.findAreaInChildrenFromEntity(p),null)}addParent(p){if(!this.parents.includes(p)){const i=In.resolveIds(p,this.index);this.ids.push(...i),this.parents.push(p)}}static resolveIds(p,i){return p?p.ids.map(n=>`${n}-${i}`):[`${i}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const p=Il(this.entity,!0);if(this.entity.type===d.Project){const i=[],n=[],a=[];p.forEach(e=>{if(d.DefinitionEntity===e.type){n.push(e);return}else if(Yt.includes(e.type)){a.push(e);return}i.push(e)});const c=i.sort((e,y)=>{const m=!!OA(e,y).length,v=Il(e),E=Il(y);return m?0:v.length&&!E.length?-1:!v.length&&E.length?1:0}).filter(e=>!Sp(e).length);this.childEntities=[...n,...a,...c]}else{const i=[],n=[],a=[],c=[],e=[];Zr.includes(this.entity.type)&&NR(this.entity).forEach(v=>{if(Gt.includes(v.type)){a.push(v);return}const E=oi(v);i.push(E)}),nr.includes(this.entity.type)&&n.push(...this.entity.detachedChildren);const y=p.filter(m=>{const v=i.includes(m);return v||a.includes(m)||n.includes(m)?!1:Gt.includes(m.type)?(a.push(m),!1):qr.includes(m.type)&&!v?(c.push(m),!1):m.type===d.DefinitionEntity?(e.push(m),!1):!0});i.sort((m,v)=>Nc(m,v)?-1:0),c.sort((m,v)=>Nc(m,v)?-1:0),a.sort((m,v)=>IC(m,v)?1:IC(v,m)?-1:0),this.childEntities=[...e,...i,...c,...y,...a,...n]}}calculateCardSize(){const p=hLe(this.entity);this.entityCardWidth=p.width,this.entityCardHeight=p.height}static getBoundriesOfTwoAreas(p,i){return{top:Math.min(p.top,i.top),left:Math.min(p.left,i.left),bottom:Math.max(p.bottom,i.bottom),right:Math.max(p.right,i.right)}}static getBoundriedOfCombinedAreas(p,i){const n=p.filter(c=>!i.includes(c));return n.reduce((c,e)=>i.includes(e)?c:In.getBoundriesOfTwoAreas(c,e.fullBranchArea),n[0].fullBranchArea)}getFullAreaUntilAny(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(e=>!p.includes(e)).map(e=>e.getFullAreaUntilAny(p)).reduce((e,y)=>In.getBoundriesOfTwoAreas(e,y),i)}getFullAreaUntilAreaOrAnyChildren(p){const i=[p,...p.flattenChildren()],n=this.ownEntityPlusBufferArea;return this.children.filter(e=>i.includes(e)).map(e=>e.getFullAreaUntil(p)).reduce((e,y)=>In.getBoundriesOfTwoAreas(e,y),n)}getFullAreaUntil(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(c=>c!==p).map(c=>c.getFullAreaUntil(p)).reduce((c,e)=>In.getBoundriesOfTwoAreas(c,e),i)}get fullBranchArea(){const p=this.ownEntityPlusBufferArea;return this.children.map(a=>a.fullBranchArea).reduce((a,c)=>In.getBoundriesOfTwoAreas(a,c),p)}get ownEntityArea(){return{top:this.entity.y,left:this.entity.x,bottom:this.entity.y+this.entityCardHeight,right:this.entity.x+this.entityCardWidth}}get ownEntityPlusBufferArea(){const p=this.ownEntityArea;return{top:p.top,left:p.left,bottom:p.bottom+Wb,right:p.right+oC}}static filterOutRepeatedAreas(p){return p.filter((i,n)=>p.indexOf(i)===n)}getEarliestId(p,i){const n=p.split("-"),a=i.split("-");return n.length<a.length?p:n.length>a.length?i:n.reduce((e,y,m)=>y<a[m]?p:i,p)}getEarliestLevel(){return this.ids.reduce((n,a)=>this.getEarliestId(n,a),this.ids[0]).split("-").length}countColumns(){let p=0;if(this!==this.calculationEntryPoint)p++;else return p;if(!this.parents.length)return p;const n=this.parents.reduce((a,c)=>c.getEarliestLevel()>a.getEarliestLevel()?c:a,this.parents[0]).countColumns();return p+=n,p}getLatestId(p,i){if(p===i)return p;const n=p.split("-"),a=i.split("-");return n.length<a.length?i:n.length>a.length?p:n.reduce((e,y,m)=>y>a[m]?p:i,p)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((n,a)=>this.getLatestId(n,a),this.ids[0]).split("-").length}smoothPosition(){const p=this.flattenSiblings();if(!p.length&&this.parents.length<=1&&this.children.length){const i=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(n=>{n!==this.calculationEntryPoint&&n.shiftDownAlone(i)})}else if([...Yt].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const i=p.filter(n=>!this.parents.includes(n));i.length?i.every(a=>{const c=this.countColumns(),e=a.countColumns();return c>e})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():i.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(p,i){if(p.includes(this))return p;this.move(this.entity,{y:this.entity.y+i});let n=[...p,this];return this.children.forEach(a=>{if(In.getEarliestParentInChain(a)!==this)return;const e=Jbi(n,a.entity.id);n=In.filterOutRepeatedAreas([...n]),e||(n=n.filter(m=>m!==a));const y=a.shiftDownUntilAny(n,i);n.push(...y)}),n}shiftRightUntilAny(p,i){p.includes(this)||(this.move(this.entity,{x:this.entity.x+i}),this.children.forEach(n=>{const a=In.filterOutRepeatedAreas([...this.flattenSiblings(),...p]);In.getEarliestParentInChain(n)===this&&n.shiftRightUntilAny(a,i)}))}shiftRight(p){this.move(this.entity,{x:this.entity.x+p}),this.children.forEach(i=>{const a=i.flattenSiblings().filter(c=>c!==i);i.shiftRightUntilAny(a,p)})}shiftDownAlone(p){this.move(this.entity,{y:this.entity.y+p})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const p=this.parents.reduce((a,c)=>{const e=c.ownEntityArea,y=e.top+fy,m={top:y,left:e.left,bottom:y,right:e.right};return In.getBoundriesOfTwoAreas(a,m)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),n=(p.bottom-p.top)/2-fy;this.shiftDownAlone(n)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const p=this.children.reduce((a,c)=>{const e=c.ownEntityArea,y=e.top+fy,m={top:y,left:e.left,bottom:y,right:e.right};return In.getBoundriesOfTwoAreas(a,m)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),n=(p.bottom-p.top)/2-fy;return this.shiftDownAlone(n),n}resolveChildrenOverlaps(){const p=this.flattenChildren();let i=[];p.forEach(n=>{const a=n.adjustVerticallyToAvoidOverlaps();i.push(...a)}),p.forEach(n=>{n.smoothPosition()})}static getEarliestParentInChain(p){let i=p.parents[0];return p.parents.length&&(i=p.parents.sort((n,a)=>{if(!n.ids.length)return-1;if(!a.ids.length)return 1;const c=n.ids.sort((y,m)=>y.length<m.length?-1:0),e=a.ids.sort((y,m)=>y.length<m.length?-1:0);return c[0].length-e[0].length})[0]),i}flattenEarlierSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((n,a)=>{if(p.has(a.entity.id))return n;p.add(a.entity.id);const e=a.children.slice(0,a.children.indexOf(this)).reduce((y,m)=>[...y,m,...m.flattenChildren(p)],[]);return[...n,...e]},[])}flattenSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((n,a)=>{if(p.has(a.entity.id))return n;p.add(a.entity.id);const e=a.children.filter(y=>y!==this).reduce((y,m)=>[...y,m,...m.flattenChildren(p)],[]);return[...n,...e]},[])}flattenChildren(p=new Set){return this.children.reduce((i,n)=>p.has(n.entity.id)?i:(p.add(n.entity.id),[...i,n,...n.flattenChildren(p)]),[])}flattenParents(p=new Set){return this.parents.reduce((n,a)=>p.has(a.entity.id)?n:(p.add(a.entity.id),[...n,a,...a.flattenParents(p)]),[])}getAreaIfRendered(p){return this.calculationEntryPoint.flattenChildren().find(a=>a.entity.id===p.id)||null}getLowerSiblings(){const p=this.parents.reduce((i,n)=>{const a=n.children.indexOf(this),c=n.children.slice(a+1);return[...i,...c]},[]);return U4(p)}getLowerAreas(){const p=this.getLowerSiblings(),i=this.parents.reduce((n,a)=>[...n,...a.getLowerAreas()],[]);return U4([...p,...i])}adjustVerticallyToAvoidOverlaps(p=[]){const n=In.getEarliestParentInChain(this).children[this.index-1];if(!n)return p;const a=this.flattenEarlierSiblings(),c=this.flattenParents(),e=[...a,...c,n],v=D(e.flatMap(V=>OA(this.entity,V.entity))).filter(V=>V.id!==this.entity.id).map(V=>this.findAreaFromEntity(V)).filter(V=>!!V),E=this.getFullAreaUntilAny(v),b=n.getFullAreaUntilAny(v),w=e.reduce((V,$)=>$===this||$.fullBranchArea.left!==E.left?V:Math.max(V,$.fullBranchArea.bottom),b.bottom);if(E.top<w){const V=w-E.top+Wb;return this.shiftDownUntilAny(p,V)}return p}move(p,i){(this.onlyEntities||[]).includes(p)&&p.metaSync(i,this.changeSet)}addChild(p){const i=this.childEntities[p];let n=null;i.x&&i.y?n=this.getAreaIfRendered(i):!i.x&&!i.y&&this.move(i,{x:this.entity.x,y:this.entity.y}),n||(n=new In(i,p,this.calculationEntryPoint));const a=this.ownEntityPlusBufferArea;this.children.includes(n)||(this.children.push(n),n.addParent(this));const c=n.fullBranchArea;if(c.left<a.right){const e=a.right-c.left;n.shiftRight(e)}return n}flattenChildEntities(p=new Set){return this.children.reduce((i,n)=>p.has(n.entity.id)?i:(p.add(n.entity.id),[...i,n.entity,...n.flattenChildEntities(p)]),[])}next(p){const i=[];this.childEntities.forEach((n,a)=>{const c=this.addChild(a);c&&i.push(c)}),p(i)}}var $m=(o=>(o.Amazon="amazon",o.Google="google",o.Microsoft="microsoft",o))($m||{}),hr=(o=>(o.RelationalDatabase="relational-database",o.CompiledLocalCodebase="compiled-local-codebase",o.CloudHostedCodebase="cloud-hosted-codebase",o.HttpApi="http-api",o.HttpEndpoint="http-endpoint",o.ServerlessFunction="serverless-function",o.CronJob="cron-job",o))(hr||{}),dC=(o=>(o.Post="post",o.Get="get",o.Acknowledgement="acknowledgment",o.Progress="progress",o.Error="error",o.Complete="complete",o))(dC||{}),vc=(o=>(o.Queued="queued",o.Running="running",o.Success="success",o.Failed="failed",o.CleanedUp="cleaned-up",o.Skipped="skipped",o.AbortedByUser="aborted-by-user",o.UnrecoverableFailure="unrecoverable-failure",o.Reverted="reverted",o.UnpublishingStarted="unpublishing-started",o.Unpublished="unpublished",o))(vc||{}),uC=(o=>(o.Queued="queued",o.Running="running",o.Success="success",o.Failed="failed",o.CleanedUp="cleaned-up",o.UnrecoverableFailure="unrecoverable-failure",o.Reverted="reverted",o.UnpublishingStarted="unpublishing-started",o.Unpublished="unpublished",o))(uC||{}),$t=(o=>(o.ProjectNotFound="project-not-found",o.ProjectPublishRequestAcknowledged="project-publish-request-acknowledged",o.PublicationStepFailedReasonUnknown="publication-step-failed-reason-unknown",o.DeploymentCompleted="deployment-completed",o.DeploymentStarted="deployment-started",o.DeploymentFailed="deployment-failed",o.AllInfrastructureSuccessfullyProvisioned="all-infrastucture-successfully-provisioned",o.RequestPayloadValidationFailed="request-payload-validation-failed",o.ProjectStateValidationFailedMissingName="project-state-validation-failed-missing-name",o.ProjectStateValidationFailedMissingAnyFunctionality="project-state-validation-failed-missing-any-functionality",o.ProjectAlreadyBeingPublished="project-already-being-published",o.BillingSubscriptionUpdateFailed="billing-subscription-update-failed",o.RelationalDatabaseDeploymentStarted="relational-database-deployment-started",o.RelationalDatabaseDeploymentCompleted="relational-database-deployment-completed",o.RelationalDatabaseDeploymentFailed="relational-database-deployment-failed",o.CreatingNewRelationalDatabase="creating-new-relational-database",o.WaitingForPreviousRelationalDatabaseDeployment="waiting-for-previous-relationa-database-deployment",o.RelationalDatabaseAlreadyExists="relational-database-already-exists",o.RelationalDatabaseDeletionStarted="relational-database-deletion-started",o.RelationalDatabaseDeletionCompleted="relational-database-deletion-completed",o.RelationalDatabaseDeletionFailed="relational-database-deletion-failed",o.WaitingForPreviousRelationalDatabaseDeletion="waiting-for-previous-relationa-database-deletion",o.HttpApiDeploymentStarted="http-api-deployment-started",o.HttpApiDeploymentCompleted="http-api-deployment-completed",o.HttpApiDeploymentFailed="http-api-deployment-failed",o.CreatingNewHttpApi="creating-new-http-api",o.HttpApiAlreadyExists="http-api-already-exists",o.HttpApiDeletionStarted="http-api-deletion-started",o.HttpApiDeletionCompleted="http-api-deletion-completed",o.HttpApiDeletionFailed="http-api-deletion-failed",o.WaitingForPreviousHttpApiDeletion="waiting-for-previous-http-api-deletion",o.BusinessLogicCodebaseDeploymentStarted="business-logic-codebase-deployment-started",o.BusinessLogicCodebaseDeploymentCompleted="business-logic-codebase-deployment-completed",o.BusinessLogicCodebaseDeploymentFailed="business-logic-codebase-deployment-failed",o.BundlingCodebaseForDownload="bundling-codebase-for-download",o.UploadingCodebaseToCloudStorage="uploading-codebase-to-cloud-storage",o.UploadingCodebaseToCloudStorageCompleted="uploading-codebase-to-cloud-storage-completed",o.UploadingCodebaseToCloudStorageFailed="uploading-codebase-to-cloud-storage-failed",o.InfrastructureValuesCodebaseInterpolationStarted="infrastructure-values-codebase-interpolation-started",o.InfrastructureValuesCodebaseInterpolationCompleted="infrastructure-values-codebase-interpolation-completed",o.InfrastructureValuesCodebaseInterpolationFailed="infrastructure-values-codebase-interpolation-failed",o.CodeCompilationStarted="code-compilation-started",o.CodeCompilationCompleted="code-compilation-completed",o.CodeCompilationFailed="code-compilation-failed",o.BundleCodebaseStarted="bundle-codebase-started",o.BundleCodebaseCompleted="bundle-codebase-completed",o.BundleCodebaseFailed="bundle-codebase-failed",o.InstallingCodebaseDependenciesStarted="installing-codebase-dependencies-started",o.InstallingCodebaseDependenciesCompleted="installing-codebase-dependencies-completed",o.InstallingCodebaseDependenciesFailed="installing-codebase-dependencies-failed",o.MigrateRelationalDatabaseStarted="migrate-relational-database-started",o.MigrateRelationalDatabaseCompleted="migrate-relational-database-completed",o.MigrateRelationalDatabaseFailed="migrate-relational-database-failed",o.ExecutePublicationCompletedEventStarted="execute-publication-completed-event-started",o.ExecutePublicationCompletedEventCompleted="execute-publication-completed-event-completed",o.ExecutePublicationCompletedEventFailed="execute-publication-completed-event-failed",o.ExecutePublicationCompletedEventTimedOut="execute-publication-completed-event-timed-out",o))($t||{}),Tl=(o=>(o.CodeCompilation="code-compilation",o.RelationalDatabaseDeployment="relational-database-deployment",o.RelationalDatabaseDeletion="relational-database-deletion",o.HttpApiDeployment="http-api-deployment",o.HttpApiDeletion="http-api-deletion",o.InfrastructureValuesCodebaseInterpolation="infrastructure-values-codebase-interpolation",o.BundleCodebase="bundle-codebase",o.MigrateRelationalDatabase="migrate-relational-database",o.BusinessLogicCodebaseDeployment="business-logic-codebase-deployment",o.ExecutePublicationCompletedEvent="execute-publication-completed-event",o.CodebaseCleanup="codebase-cleanup",o))(Tl||{});hr.CloudHostedCodebase,hr.HttpApi,hr.RelationalDatabase,hr.CloudHostedCodebase,hr.CloudHostedCodebase,hr.RelationalDatabase,hr.CloudHostedCodebase,hr.CloudHostedCodebase;function mLe(o){return`project-${o}-http-api`}function rR(o){return`entity-${o}-database`}class TLe{constructor(p,i,n,a,c,e,y,m,v){I(this,"stepType");I(this,"id");I(this,"resourceType");I(this,"index");I(this,"dependency",[]);I(this,"lastEvent",null);I(this,"lastEventTimestamp",null);I(this,"status",vc.Queued);I(this,"publicationRun");I(this,"resource");this.stepType=p,this.id=i,this.resourceType=n,this.status=a,this.dependency=c,this.index=e,this.lastEventTimestamp=y,this.publicationRun=m,this.resource=v}toJSON(){return{stepType:this.stepType,id:this.id,resourceType:this.resourceType,index:this.index,status:this.status,dependency:this.dependency,lastEvent:this.lastEvent,resource:{resourceId:this.resource.resourceId,resourceType:this.resource.resourceType,provider:this.resource.provider,details:this.resource.details,status:this.resource.status,name:this.resource.name}}}async update(p){var i,n;this.status=p.status,this.dependency=p.dependency,this.index=p.index,this.stepType=p.stepType,this.resourceType=p.resourceType,this.lastEvent=p.lastEvent,this.id=p.id,(n=this.resource)==null||n.setDetails((i=p.resource)==null?void 0:i.details)}}var vLe=(o=>(o.Ready="ready",o.Provisioning="provisioning",o.Queued="queued",o.ProvisioningFailed="provisioning-failed",o.Deleting="deleting",o.DeletingFailed="deleting-failed",o.Deleted="deleted",o))(vLe||{});class af{constructor(p,i,n){I(this,"provisionedBy");I(this,"publicationRun");I(this,"resourceType");I(this,"provider");I(this,"resourceId");I(this,"details",null);I(this,"name",null);I(this,"status","queued");this.publicationRun=p,this.resourceType=i,this.provider=n}setDetails(p){this.details=p}setStatus(p){this.status=p}setProvisionedBy(p){this.provisionedBy=p}}class Ybi extends af{constructor(i,n,a){super(i,hr.HttpEndpoint,a);I(this,"resourceType",hr.HttpEndpoint);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,n;return this.resourceId=rR((n=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:n.id),this.resourceId}}class Xbi extends af{constructor(i,n,a){super(i,hr.ServerlessFunction,a);I(this,"resourceType",hr.ServerlessFunction);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,n;return this.resourceId=rR((n=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:n.id),this.resourceId}}class ELe extends af{constructor(i,n,a){super(i,hr.HttpApi,a);I(this,"resourceType",hr.HttpApi);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=mLe(this.publicationRun.project.id),this.resourceId}}class bLe extends af{constructor(i,n,a){super(i,hr.RelationalDatabase,a);I(this,"resourceType",hr.RelationalDatabase);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,n;return this.resourceId=rR((n=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:n.id),this.resourceId}}class ALe extends af{constructor(i,n){super(i,hr.CloudHostedCodebase,n);I(this,"resourceType",hr.CloudHostedCodebase);I(this,"details",null);I(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`cloud-hosted-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}`,this.resourceId}}class gLe extends af{constructor(i,n){super(i,hr.CompiledLocalCodebase,n);I(this,"resourceType",hr.CompiledLocalCodebase);I(this,"details",null);I(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`compiled-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}--${this.publicationRun.id}`,this.resourceId}}class Qbi{constructor(p,i){I(this,"id");I(this,"projectAutoIncrementPublicationCount");I(this,"projectPublishedSemanticVersion");I(this,"projectVersion");I(this,"projectId");I(this,"triggeredBy");I(this,"createdAt");I(this,"updatedAt");I(this,"status");I(this,"steps",[]);I(this,"editor");I(this,"explicitResources",new Map);I(this,"implicitGlobalResources",new Map);I(this,"finalGlobalEvent",null);I(this,"finalStatus",null);I(this,"contextType",X.PublicationRun);I(this,"extensionsRegistry");this.id=p.id,this.projectAutoIncrementPublicationCount=p.projectAutoIncrementPublicationCount,this.projectPublishedSemanticVersion=p.projectPublishedSemanticVersion,this.projectVersion=p.projectVersion,this.projectId=p.projectId,this.triggeredBy=p.triggeredBy,this.createdAt=p.createdAt,this.updatedAt=p.updatedAt,this.status=p.status,this.editor=i,this.initRegistry()}get off(){return this.extensionsRegistry.off}get on(){return this.extensionsRegistry.on}get emit(){return this.extensionsRegistry.emit}get emitAsync(){return this.extensionsRegistry.emitAsync}get emitAsyncAll(){return this.extensionsRegistry.emitAsyncAll}get emitAsyncAllSettled(){return this.extensionsRegistry.emitAsyncAllSettled}get emitAsyncSequentially(){return this.extensionsRegistry.emitAsyncSequentially}get emitAsyncSequentiallyAll(){return this.extensionsRegistry.emitAsyncSequentiallyAll}get emitAsyncSequentiallyAllSettled(){return this.extensionsRegistry.emitAsyncSequentiallyAllSettled}get project(){return this.editor.project}getInfraTypes(p){return this.steps.filter(i=>p.includes(i.resourceType))}getStepsTypes(p){return this.steps.filter(i=>p.includes(i.stepType))}toIds(p){return p.map(i=>i.id)}getResourceForEntity(p){const i=Array.from(this.explicitResources.values()).find(n=>n.owners.has(p.id));return i||null}async init(){await this.initResources()}async initResources(){this.implicitGlobalResources.set(hr.CompiledLocalCodebase,new gLe(this,$m.Amazon)),this.implicitGlobalResources.set(hr.CloudHostedCodebase,new ALe(this,$m.Amazon));const p=this.project.entities.filter(n=>Wi(n,Re.HTTP_ENDPOINT)),i=this.project.entities.filter(n=>Wi(n,Re.RELATIONAL_DATABASE));if(i.length&&i.forEach(n=>{const a=new bLe(this,[n],$m.Amazon);this.explicitResources.set(a.resourceId,a)}),p.length){const n=new ELe(this,p,$m.Amazon);this.explicitResources.set(n.resourceId,n)}}setSteps(p,i){p.forEach(n=>{this.addStep(n,i)}),this.editor.events.emit($t.ProjectPublishRequestAcknowledged,{})}addStep(p,i){const n=p.dependency||[];if(n.length){const c=n.filter(e=>!this.steps.find(y=>y.id===e));if(c.length)throw new Error(`Missing dependencies: ${c.join(", ")}`)}if(!this.steps.find(c=>c.id===p.id)){const c=new TLe(p.stepType,p.id,p.resourceType,p.status,n,p.index,i,this,null);this.steps.push(c)}}onUpdate(p){var i;if(J.Logger.log("onUpdate",p),(i=p.payload)!=null&&i.stepType){const n=this.steps.find(a=>{var c;return a.id===((c=p.payload)==null?void 0:c.id)});n&&L(p.emittedAt).isAfter(L(n.lastEventTimestamp))&&n.update(p.payload)}this.editor.events.emit("publication-updated",{}),p.type===dC.Error?(this.finalStatus=uC.Failed,this.finalGlobalEvent=p.event,this.editor.events.emit("project-publication-error",p)):p.type===dC.Complete&&(this.finalStatus=uC.Success,this.finalGlobalEvent=p.event,this.editor.events.emit("project-publication-completed",p))}requestExtension(p){return this.extensionsRegistry.requestExtension(p)}async initRegistry(){return this.extensionsRegistry=new fN(this.editor.events),await this.extensionsRegistry.setup(),this.extensionsRegistry.onResolvePublicationRunContext(()=>this),await this.extensionsRegistry.contextAvailable(X.PublicationRun),this.extensionsRegistry}}function eAi(o){switch(o){case Tl.CodeCompilation:return"Code generation";case Tl.RelationalDatabaseDeployment:return"Database creation";case Tl.HttpApiDeployment:return"HTTP gateway creation";case Tl.InfrastructureValuesCodebaseInterpolation:return"Link code with resources";case Tl.BundleCodebase:return"Bundle code";case Tl.MigrateRelationalDatabase:return"Database structure migration";case Tl.BusinessLogicCodebaseDeployment:return"Update servers with new code";case Tl.CodebaseCleanup:return"Code cleanup";case Tl.HttpApiDeletion:return"HTTP gateway deletion";case Tl.RelationalDatabaseDeletion:return"Database deletion";default:return"Publication finished"}}function tAi(o){switch(o){case $t.DeploymentCompleted:return"Successfully published";case $t.DeploymentStarted:return"Publication started";case $t.DeploymentFailed:return"Publication failed";case $t.AllInfrastructureSuccessfullyProvisioned:return"All infrastructure successfully provisioned";case $t.RequestPayloadValidationFailed:return"Request payload validation failed";case $t.ProjectStateValidationFailedMissingName:return"Project state validation failed: missing name";case $t.ProjectStateValidationFailedMissingAnyFunctionality:return"Project state validation failed: missing any functionality";case $t.RelationalDatabaseDeploymentStarted:return"Database creation started";case $t.RelationalDatabaseDeploymentCompleted:return"Database creation completed";case $t.RelationalDatabaseDeploymentFailed:return"Database creation failed";case $t.CreatingNewRelationalDatabase:return"Creating new database (up to 5 mins)";case $t.WaitingForPreviousRelationalDatabaseDeployment:return"Waiting for previous database creation";case $t.RelationalDatabaseAlreadyExists:return"Database already exists";case $t.HttpApiDeploymentStarted:return"HTTP gateway creation started";case $t.HttpApiDeploymentCompleted:return"HTTP gateway creation completed";case $t.HttpApiDeploymentFailed:return"HTTP gateway creation failed";case $t.CreatingNewHttpApi:return"Creating new HTTP gateway";case $t.HttpApiAlreadyExists:return"HTTP gateway already exists";case $t.BusinessLogicCodebaseDeploymentStarted:return"Update servers with new code started";case $t.BusinessLogicCodebaseDeploymentCompleted:return"Update servers with new code completed";case $t.BusinessLogicCodebaseDeploymentFailed:return"Update servers with new code failed";case $t.BundlingCodebaseForDownload:return"Bundling code for download";case $t.UploadingCodebaseToCloudStorage:return"Uploading code to cloud storage";case $t.InfrastructureValuesCodebaseInterpolationStarted:return"Linking code with resources started";case $t.InfrastructureValuesCodebaseInterpolationCompleted:return"Linking code with resources completed";case $t.InfrastructureValuesCodebaseInterpolationFailed:return"Linking code with resources failed";case $t.CodeCompilationStarted:return"Code generation started";case $t.CodeCompilationCompleted:return"Code generation completed";case $t.CodeCompilationFailed:return"Code generation failed";case $t.BundleCodebaseStarted:return"Code bundling started";case $t.BundleCodebaseCompleted:return"Code bundling completed";case $t.BundleCodebaseFailed:return"Code bundling failed";case $t.InstallingCodebaseDependenciesStarted:return"Installing code dependencies";case $t.InstallingCodebaseDependenciesCompleted:return"Installing code dependencies completed";case $t.InstallingCodebaseDependenciesFailed:return"Installing code dependencies failed";case $t.MigrateRelationalDatabaseStarted:return"Database structure migration started";case $t.MigrateRelationalDatabaseCompleted:return"Database structure migration completed";case $t.MigrateRelationalDatabaseFailed:return"Database structure migration failed";case $t.ProjectAlreadyBeingPublished:return"Project already being published. You need to wait for the previous publication to complete";case $t.ProjectPublishRequestAcknowledged:return"Project publish request acknowledged";case $t.UploadingCodebaseToCloudStorageCompleted:return"Uploading code to cloud storage completed";case $t.UploadingCodebaseToCloudStorageFailed:return"Uploading code to cloud storage failed";case $t.BillingSubscriptionUpdateFailed:return"Billing subscription update failed";case $t.ProjectNotFound:return"Project not found";case $t.HttpApiDeletionCompleted:return"HTTP gateway deletion completed";case $t.HttpApiDeletionFailed:return"HTTP gateway deletion failed";case $t.HttpApiDeletionStarted:return"HTTP gateway deletion started";case $t.PublicationStepFailedReasonUnknown:return"Publication step failed: reason unknown";case $t.WaitingForPreviousHttpApiDeletion:return"Waiting for previous HTTP gateway deletion";case $t.RelationalDatabaseDeletionStarted:return"Database deletion started";case $t.RelationalDatabaseDeletionCompleted:return"Database deletion completed";case $t.RelationalDatabaseDeletionFailed:return"Database deletion failed";case $t.WaitingForPreviousRelationalDatabaseDeletion:return"Waiting for previous database deletion"}return"Unknown event"}var ILe=(o=>(o.NO_LOGIC="NO_LOGIC",o.NO_NAME="NO_NAME",o.NO_CHANGES="NO_CHANGES",o.PROJECT_PUBLICATION_ALREADY_ONGOING="PROJECT_PUBLICATION_ALREADY_ONGOING",o))(ILe||{});function iAi(o){switch(o){case"NO_LOGIC":return"This project has no logic";case"NO_NAME":return"This project has no name";case"NO_CHANGES":return"This version has already been published";case"PROJECT_PUBLICATION_ALREADY_ONGOING":return"This project is already being published";default:return"Publishing is currently not available. Try again later"}}function rAi(o){switch(o){case hr.RelationalDatabase:return"Relational database";case hr.HttpEndpoint:case hr.HttpApi:return"HTTP endpoints";case hr.ServerlessFunction:case hr.CloudHostedCodebase:return"Server code functions";default:return"Resources"}}function nAi(o){switch(o){case vc.Running:return"In progress";case vc.Failed:return"Failed";case vc.Success:return"Succeeded";case vc.Skipped:return"Skipped";case vc.Queued:default:return"Queued"}}function RLe(o){var n;if(!Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION))return null;let p=null;const i=Q["built-in-base-entity"].BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_ENTITY.properties.integration.id;if(o.type===d.BuiltInBaseEntity?Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION)&&(p=pC(o.name)):o.type===d.DefinitionEntity&&o.implements.forEach(a=>{if(Wi(a,Re.EXTERNAL_INTEGRATION_CONNECTION)){const c=pC(a==null?void 0:a.name);if(c)return p=c,!0}}),!p){const a=o.properties.find(c=>!!c.implements.find(e=>e.id===i)||!!c.implements.find(e=>{var y;return((y=e.extends)==null?void 0:y.id)===i}));p=(n=a==null?void 0:a.getDefaultValue())==null?void 0:n.value}return p}function aAi(o){return vhe[o]}function pC(o){return o.includes("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_")?o.replace("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_","").toLocaleLowerCase().replace("_auth",""):null}function DLe(o){if(o.type!==d.ActionDescriptor&&o.type!==d.Operation)throw new Error("Only ActionDescriptorState or OperationState can be used to resolve an external integration ID");if(o.type===d.ActionDescriptor){const p=o;if(p.id.startsWith("external-integration--"))return p.id.split("--")[1]}if(o.type===d.Operation){const p=o.declaration;if(Object.values(Qt).includes(p.id))return p.id.split("--")[1]||null}return null}function sAi(o){if(!o)throw new Error("The integrationName parameter is required to resolve the base built-in name.");return Object.values(Re).find(i=>!!(i.startsWith("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_")&&i.endsWith("_AUTH")&&i.replace("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_","").replace("_AUTH","").toLowerCase()===o.toLowerCase()))||null}function lAi(o){return o.type===d.BuiltInBaseEntity||o.type===d.DefinitionEntity?RLe(o):o.type===d.ActionDescriptor||o.type===d.Operation?DLe(o):null}function wLe(o){var a,c,e;if(!Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION))return null;let p=null;const i=G4e(o,Re.EXTERNAL_INTEGRATION_CONNECTION);if(!i)return null;const n=Q["built-in-base-entity"][i.id].properties.connectionId.id;if(o.type===d.BuiltInBaseEntity){if(Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION)){const y=o.properties.find(m=>{var v;return((v=m.extends)==null?void 0:v.id)===n});y&&(p=(a=y.getDefaultValue())==null?void 0:a.value)}}else if(o.type===d.DefinitionEntity){const y=o.properties.find(m=>!!m.implements.find(v=>v.id===n)||!!m.implements.find(v=>{var E;return((E=v.extends)==null?void 0:E.id)===n}));if(!y&&((c=o.extends)==null?void 0:c.type)===d.DefinitionEntity)return wLe(o.extends);p=(e=y==null?void 0:y.getDefaultValue())==null?void 0:e.value}return p}async function OLe(o,p={}){var y;const i=J.YieldTracker.from(p),a=[...ea(o),...Rs(o),...RN(o),...ta(o),...DN(o)],c=Cv(o);a.push(...c);const e=Lt(o.errors,a);await i.tick();for(const m of o.inputs)await m.validateAsync({tracker:i});for(const m of o.outputs)await m.validateAsync({tracker:i});for(const m of o.internalCalls)await m.validateAsync({tracker:i});return await((y=o.dataType)==null?void 0:y.validateAsync({tracker:i})),e}function CLe(o){var a;(a=o.dataType)==null||a.validate(),o.inputs.forEach(c=>c.validate()),o.outputs.forEach(c=>c.validate()),o.internalCalls.forEach(c=>c.validate());const i=[...ea(o),...Rs(o),...RN(o),...ta(o),...DN(o)],n=Cv(o);return i.push(...n),Lt(o.errors,i)}function RN(o,p){const n=[...o.project.getVariableDeclarations()].filter(a=>a.id!==o.id);return Vv(o,[Hi],n,p)}function DN(o){const p=[];if(o.parent!==o.project)return p;if(o.catchesError){const i=Ot({id:`${o.id}--${Ie.GlobalVariableDeclarationCannotCatchError}`,message:`${as[o.type].singular} "${le(o,o.project)}" with id "${o.id}" cannot catch an error because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:ce.Error,code:Ie.GlobalVariableDeclarationCannotCatchError,entity:o});p.push(i.error)}if(o.errorCalls.length){const i=Ot({id:`${o.id}--${Ie.GlobalVariableDeclarationCannotCallOnError}`,message:`${as[o.type].singular} "${le(o,o.project)}" with id "${o.id}" cannot call other entities from its error branch because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:ce.Error,code:Ie.GlobalVariableDeclarationCannotCallOnError,entity:o});p.push(i.error)}if(o.calledBy.length){const i=Ot({id:`${o.id}--${Ie.GlobalVariableDeclarationCannotBeCalled}`,message:`${as[o.type].singular} "${le(o,o.project)}" with id "${o.id}" cannot be called because it is globally declared. Global variable declarations must be self initialized when the project is loaded, and not be called for initialization.`,severity:ce.Error,code:Ie.GlobalVariableDeclarationCannotBeCalled,entity:o});p.push(i.error)}return[]}const oAi=Object.freeze(Object.defineProperty({__proto__:null,validate:CLe,validateAsync:OLe,validateGlobalVariableDeclaration:DN,validateVariableDeclarationName:RN},Symbol.toStringTag,{value:"Module"}));async function _Le(o,p={}){const i=J.YieldTracker.from(p),a=[...ea(o),...Rs(o),...ta(o)],c=Cv(o);a.push(...c);const e=Lt(o.errors,a);await i.tick();for(const y of o.inputs)await y.validateAsync({tracker:i});for(const y of o.outputs)await y.validateAsync({tracker:i});for(const y of o.internalCalls)await y.validateAsync({tracker:i});return e}function VLe(o){o.inputs.forEach(a=>a.validate()),o.outputs.forEach(a=>a.validate()),o.internalCalls.forEach(a=>a.validate());const i=[...ea(o),...Rs(o),...ta(o)],n=Cv(o);return i.push(...n),Lt(o.errors,i)}function dAi(o){const p=[],i=o.declaration.constant;if(i&&o.readsValue){const n=Ot({id:`${o.id}--${he.ValueReadingOverridesConstantVariable}`,message:`The '${o.type}' entity "${le(o,o.project)}" with id "${o.id}" is a constant variable whose value cannot be overriden, but reads a value.`,severity:ce.Error,code:he.ValueReadingOverridesConstantVariable,entity:o});p.push(n.error)}if(i&&o.defaultValue){const n=Ot({id:`${o.id}--${he.DefaultValueOverridesConstantVariable}`,message:`The '${o.type}' entity "${le(o,o.project)}" with id "${o.id}" is a constant variable whose value cannot be overridden, but has a 'defaultValue'.`,severity:ce.Error,code:he.DefaultValueOverridesConstantVariable,entity:o});p.push(n.error)}return p}const uAi=Object.freeze(Object.defineProperty({__proto__:null,validate:VLe,validateAsync:_Le,validateConstantValueOverride:dAi},Symbol.toStringTag,{value:"Module"}));var wN=(o=>(o.Parent="parent",o.DataTypeEntity="data-type-entity",o.VarDeclaration="var-declaration",o))(wN||{});const mi=class mi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"x");I(this,"y");I(this,"type",d.VariableInstance);I(this,"catchesError",!1);I(this,"defaultValue",null);I(this,"writesValues",[]);I(this,"readsValue",null);I(this,"declaration");I(this,"inputs",[]);I(this,"outputs",[]);I(this,"error",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"successCalls",[]);I(this,"errorCalls",[]);I(this,"internalCalls",[]);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.x=i.x,this.y=i.y,this.catchesError=i.catchesError||!1}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableInstance,catchesError:!1,declaration:null,internalCalls:[],successCalls:[],errorCalls:[],readsValue:null,writesValues:[],defaultValue:null,inputs:[],outputs:[],parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],error:null,x:0,y:0}}static fromGenerationTarget(i,n){let a=n;if(i.parent){const V=ne(i.parent);a=n.get(V)}const c=ne(i.declaration),e=n.get(c),y=i.calledByEntry.map(V=>{const $=ne(V);return n.get($)}),m=i.calledBySuccess.map(V=>{const $=ne(V);return n.get($)}),v=i.calledByError.map(V=>{const $=ne(V);return n.get($)});let E=null;if(i.readsValue){const V=ne(i.readsValue);E=n.get(V)}const b={id:i.id,version:x.UUID.uuid(),createdAt:L().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableInstance,catchesError:i.catchesError||!1,declaration:e.toReference(),calledByEntry:y,calledBySuccess:m,calledByError:v,defaultValue:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:E,inputs:[],outputs:[],writesValues:[],error:null,x:0,y:0,parent:a},w=me(b,n);return w.setParent(a,null),w}static validateGenerationTarget(i,n){let a=JSON.parse(JSON.stringify(i));const c=[],e=bn(a,{parent:{list:!1,types:[...nr,d.Project],optional:!0},declaration:{list:!1,types:[d.VariableDeclaration]}},n);return a=e.modifiedData,c.push(...e.errors,...xr(a)),{errors:c,modifiedData:a}}get codeName(){var i;return(i=this.declaration)==null?void 0:i.codeName}get codeNativeValueValidation(){var i;return this._codeNativeValueValidation||((i=this.declaration)==null?void 0:i.codeNativeValueValidation)||null}validateGeneratedUpdate(i){const n=[];let a=JSON.parse(JSON.stringify(i));const c=of(a,this);return a=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${se.InvalidParentUpdate}`,code:se.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
93
93
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
94
94
  Specifically for variables, their scope is also calculated from their value readers and value writters.
95
95
  You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`})),{errors:n,modifiedData:a}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const n=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),a.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(a),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,a){const c=[],e=[],y=[],m=[];if(n==="parent"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},a);c.push(...v),e.push(...E),y.push(...b)}if(n==="var-declaration"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},a);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,a){const c=[],e=[],y=[],m=[];if(n==="parent"){const{updated:v,added:E,removed:b}=this.restore({},a);c.push(...v),e.push(...E),y.push(...b)}if(n==="var-declaration"){const{updated:v,added:E,removed:b}=this.restore({},a);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,a,c,e,y,m;return(n=(i=this.parent)==null?void 0:i.unsubscribeDependents)==null||n.call(i,[{entity:this,field:"parent"}]),(e=(c=(a=this.declaration.dataType)==null?void 0:a.entity)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"data-type-entity"}]),(m=(y=this.declaration)==null?void 0:y.unsubscribeDependents)==null||m.call(y,[{entity:this,field:"var-declaration"}]),this}subscribeToDependencies(){var i,n,a,c;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"parent"}]),(c=(a=(n=this.declaration.dataType)==null?void 0:n.entity)==null?void 0:a.subscribeDependents)==null||c.call(a,[{entity:this,field:"data-type-entity"}]),this.declaration.subscribeDependents([{entity:this,field:"var-declaration"}]),this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new mi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.internalCalls=[...this.internalCalls],i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.writesValues=[...this.writesValues],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.declaration=this.declaration,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.error=this.error,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),a.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(a),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],a=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(a),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new mi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.inputs=y.inputs,this.outputs=y.outputs,this.internalCalls=y.internalCalls,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.writesValues=y.writesValues,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.declaration=y.declaration,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.error=y.error,this.parent=y.parent,{updated:D(n),added:D(a),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const a=ne(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${a}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const a=ne(i.readsValue),c=this.project.get(a),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.declaration){const a=ne(i.declaration),c=this.project.get(a);c&&this.setDeclaration(c)}if(i.calledByEntry.forEach(a=>{const c=ne(a),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(a=>{i.calledByEntry.find(e=>ne(e)===a.id)||(this.removeCaller(a,n),a.removeCall(this,n))}),i.calledBySuccess.forEach(a=>{const c=ne(a),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(a=>{i.calledBySuccess.find(e=>ne(e)===a.id)||(this.removeCaller(a,n),a.removeCall(this,n))}),i.calledByError.forEach(a=>{const c=ne(a),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(a=>{i.calledByError.find(e=>ne(e)===a.id)||(this.removeCaller(a,n),a.removeCall(this,n))}),i.outputs.forEach(a=>{const c=ne(a),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(a=>{i.outputs.find(e=>ne(e)===a.id)||(this.removeOutput(a,n),a.removeFromParent(n))}),i.inputs.forEach(a=>{const c=ne(a),e=this.project.get(c);e&&(this.addInput(e,n),e.setParent(this,n))}),[...this.inputs].forEach(a=>{i.inputs.find(e=>ne(e)===a.id)||(this.removeInput(a,n),a.removeFromParent(n))}),i.defaultValue){const a=ne(i.defaultValue),c=this.project.get(a);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return i.writesValues.forEach(a=>{const c=ne(a),e=this.project.get(c);e&&(this.addValueReader(e,n),e.setValueWriter(this,n))}),[...this.writesValues].forEach(a=>{i.writesValues.find(e=>ne(e)===a.id)||(this.removeValueReader(a,n),a.setValueWriter(null,n))}),this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],a=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}if(this.initialData.declaration){const e=ne(this.initialData.declaration),y=this.project.get(e);y&&(this.setDeclaration(y),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(a),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.AfterAllChildrenInitialized))){var Pe;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],a=[],c=[],e=[];if(this.initialized=!0,!this.declaration.dataType||(Pe=this.declaration.dataType)!=null&&Pe.inferred){const{added:Be,updated:Se,removed:je,affected:Ze}=this.declaration.inferDataTypeAndSyncInstancesInputsAndOutputs(i);a.push(...Be),n.push(...Se),c.push(...je),e.push(...Ze)}if(this.readsValue&&this.defaultValue&&(this.project.diggestedBuiltInBaseEntitiesIds.has(this.defaultValue.id)||this.defaultValue.remove({ignoreUpstream:!1},i),this.setDefaultValue(null,i)),this.defaultValue&&!this.readsValue&&!this.project.diggestedBuiltInBaseEntitiesIds.has(this.id)&&this.project.diggestedBuiltInBaseEntitiesIds.has(this.defaultValue.id)){const Be=this.defaultValue.clone(i,this);this.setDefaultValue(Be,i)}const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);a.push(...y),n.push(...m),c.push(...v),e.push(...E);const{added:b,updated:w,removed:V,affected:$}=this.syncOutputs(i);a.push(...b),n.push(...w),c.push(...V),e.push(...$);const{added:M,updated:k,removed:F,affected:U}=this.generateUnusedInternalCalls(i);a.push(...M),n.push(...k),c.push(...F),e.push(...U);const{added:Y,updated:ie,removed:ee,affected:de}=this.removeUnrecognizedInputs(i);a.push(...Y),n.push(...ie),c.push(...ee),e.push(...de);const{added:ae,updated:fe,removed:ve,affected:ue}=this.removeUnrecognizedOutputs(i);a.push(...ae),n.push(...fe),c.push(...ve),e.push(...ue);const{added:ye,updated:Ve,removed:_e,affected:xe}=this.removeUnrecognizedInternalCalls(i);return a.push(...ye),n.push(...Ve),c.push(..._e),e.push(...xe),this.inputs.sort((Be,Se)=>{var je,Ze;return(Be.index??((je=Be.declaration)==null?void 0:je.index))-(Se.index??((Ze=Se.declaration)==null?void 0:Ze.index))}),this.outputs.sort((Be,Se)=>{var je,Ze;return(Be.index??((je=Be.declaration)==null?void 0:je.index))-(Se.index??((Ze=Se.declaration)==null?void 0:Ze.index))}),this.declaration.constant&&this.readsValue&&(this.readsValue.removeValueReader(this,i),this.removeValueWriter(i)),this.declaration.constant&&this.defaultValue&&this.defaultValue.remove({ignoreUpstream:!1},i),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(a),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){const n=[this],a=[],c=[],e=[];return this.parent===this.project&&this.project.addVariableInstance(this),this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.writesValues.forEach(y=>{y.setValueWriter(this,i),n.push(y)}),this.successCalls.forEach(y=>{y.addSuccessCaller(this,i),n.push(y)}),this.errorCalls.forEach(y=>{y.addErrorCaller(this,i),n.push(y)}),this.calledBySuccess.forEach(y=>{y.addSuccessCall(this,i),n.push(y)}),this.calledByError.forEach(y=>{y.addErrorCall(this,i),n.push(y)}),this.calledByEntry.forEach(y=>{y.addCall(this,i),n.push(y)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(a),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(i=>i.readsValue||i.defaultValue)}get unusedInputs(){return this.inputs.filter(i=>!i.readsValue&&!i.defaultValue)}get usedOutputs(){return this.outputs.filter(i=>i.writesValues.length)}get unusedOutputs(){return this.outputs.filter(i=>!i.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(i=>!!i.calledBy.length||!!i.writesValues.length||!!i.successCalls.length||!!i.errorCalls.length)}get unusedInternalCalls(){const i=this.usedInternalCalls;return this.internalCalls.filter(a=>!(i.find(y=>y.id===a.id)||i.find(y=>y.declaration===a.declaration)))}removeInternalCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"remove-variable-instance-internal-call"))){const a=this.internalCalls.findIndex(c=>c.id===i.id);return a>-1&&(this.internalCalls.splice(a,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-variable-instance-internal-call",this.id),this}removeInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.RemoveInput))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this;const a=this.inputs.findIndex(c=>c.id===i.id);return a>-1&&(this.inputs.splice(a,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this}addInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.AddInput))){return this.checkCanEdit(this,n)?this.inputs.includes(i)?(n==null||n.attemptAutoclose(_.AddInput,this.id),this):(this.inputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose(_.AddInput,this.id),this):(J.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddInput,this.id),this)}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const a=this.outputs.findIndex(c=>c.id===i.id);return a>-1&&(this.outputs.splice(a,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.AddSuccessCaller)),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),a&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.AddErrorCaller)),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),a&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.AddEntryCaller)),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),a&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}addErrorCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.AddErrorCall)),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCall,n)?(this.errorCalls.find(c=>c.id===i.id)||(this.errorCalls.push(i),a&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddErrorCall,this.id),this):this}addSuccessCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.AddSuccessCall)),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCall,n)?(this.successCalls.find(c=>c.id===i.id)||(this.successCalls.push(i),a&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddSuccessCall,this.id),this):this}removeCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.RemoveCall)),a=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCall,n))return this;const c=this.successCalls.findIndex(y=>y.id===i.id);c>-1&&(this.successCalls.splice(c,1),n==null||n.add(this,H.Affected));const e=this.errorCalls.findIndex(y=>y.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),n==null||n.add(this,H.Affected)),a&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCall,this.id),this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"remove-caller")),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),a&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}addValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.AddValueReader))){var e,y,m;if(!this.checkCanEditFromScopeOwnerWithSideEffects(this,_.AddValueReader,n))return this;const a=i.type===d.InputMap&&i.parent.type===d.VariableInstance&&((e=i.declaration)==null?void 0:e.type)===d.Property&&((y=i.declaration)==null?void 0:y.constant),c=i.type===d.VariableInstance&&((m=i.declaration)==null?void 0:m.constant);return(a||c)&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${this.id}`,action:_.SetValueWriter,owner:i,counterpart:this,errorReason:Ri.ValueReadingOverridesConstantVariable,rootAction:!1}),n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):this.writesValues.includes(i)?(n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):(this.writesValues.push(i),n==null||n.add(this,H.Affected),this)}setError(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.SetErrorEntity))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setError] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this;const a=this.error;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},n),this.error=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.declaration.type===d.GenericReference){const n=this.project.findSubscribedInstanceFromReference(this.initialData.declaration);if(!n)return this;this.declaration=n}else this.declaration=me(this.initialData.declaration,this.project),this.declaration.initChildren(i);return Pv.initWritesValues(this,this.parent),df.initReadsValue(this),this.initialData.inputs.forEach(n=>{const a=me(n,this.project);return a.setParent(this,null),a.initChildren(i),this.addInput(a,null),a}),this.initialData.outputs.forEach(n=>{const a=me(n,this.project);return a.setParent(this,null),a.initChildren(i),this.addOutput(a,i),a}),this.successCalls=this.initialData.successCalls.map(n=>{const a=me(n,this.project);if(a.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(a.type))a.setParent(this.parent.parent,null),a.initChildren(i);else if(a.type===d.ReturnStatement){const c=tn(this,this.project);a.setParent(c,null),a.initChildren(i)}else a.type!==d.InternalCall&&(a.setParent(this.parent,null),a.initChildren(i));return a}),this.errorCalls=this.initialData.errorCalls.map(n=>{const a=me(n,this.project);if(a.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(a.type))a.setParent(this.parent.parent,null),a.initChildren(i);else if(a.type===d.ReturnStatement){const c=tn(this,this.project);a.setParent(c,null),a.initChildren(i)}else a.type!==d.InternalCall&&(a.setParent(this.parent,null),a.initChildren(i));return a}),this.internalCalls=this.initialData.internalCalls.reduce((n,a)=>{if(a.type===d.GenericReference){const c=this.project.findSubscribedInstanceFromReference(a);if(!c)return n;const e=c;return e.setParent(this,null),[...n,e]}else{const c=me(a,this.project);return c.setParent(this,null),c.initChildren(i),[...n,c]}},[]),this.initialData.error&&(this.error=me(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.SetValueWriter))){var a,c,e;return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(a=this.declaration)!=null&&a.constant&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${i.id}`,action:_.SetValueWriter,owner:this,counterpart:i,errorReason:Ri.ValueReadingOverridesConstantVariable,rootAction:((c=n==null?void 0:n.self)==null?void 0:c.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.SetValueWriter}),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):(this.readsValue!==i&&(this.readsValue=i,this.readsValue&&((e=this.defaultValue)==null||e.remove({ignoreUpstream:!1},n)),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}removeValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.RemoveValueReader,n)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(a=>a.id!==i.id),n==null||n.add(this,H.Affected),this):(n==null||n.attemptAutoclose(_.RemoveValueReader,this.id),this):this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const a=Lr(this,i,n),c=$r(this,a),e=this.toMeta();return this.x=a.x||e.x,this.y=a.y||e.y,this.catchesError=a.catchesError!==void 0?a.catchesError:this.catchesError,super.baseMetaSync(a,this,n),a.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):a.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await mi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await mi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await mi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await mi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await mi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...a){return await mi.repository.APILoadVersion(this.id,n,...a)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],a=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeVariableInstance(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(a),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ri.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);a.push(...E),c.push(...b),e.push(...w)}),this.defaultValue){const{updated:v,removed:E}=this.defaultValue.remove({ignoreUpstream:!0},n);a.push(...v),c.push(...E)}if(this.readsValue&&(a.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.writesValues.forEach(v=>{a.push(v),v.setValueWriter(null,n)}),this.inputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);a.push(...E),c.push(...b)}),this.outputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);a.push(...E),c.push(...b)}),this.successCalls.forEach(v=>{a.push(v),v.removeCaller(this,n)}),this.errorCalls.forEach(v=>{a.push(v),v.removeCaller(this,n)}),this.internalCalls.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);a.push(...E),c.push(...b)}),!i){const v=this.removeFromParent(n);e.push(...v.added),a.push(...v.updated),c.push(...v.removed),y.push(...v.affected),this.calledBy.forEach(E=>{a.push(E),E.removeCall(this,n)})}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(a),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],a=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);a.push(...m),c.push(...v),n.push(...E)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);a.push(...y)}return this.readsValue&&(a.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.writesValues.forEach(y=>{a.push(y),y.setValueWriter(this,i)}),this.inputs.forEach(y=>{const{updated:m}=y.restore({},i);a.push(...m)}),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);a.push(...m)}),this.successCalls.forEach(y=>{a.push(y),y.addSuccessCaller(this,i)}),this.errorCalls.forEach(y=>{a.push(y),y.addErrorCaller(this,i)}),this.internalCalls.forEach(y=>{const{updated:m}=y.restore({},i);a.push(...m)}),this.calledBySuccess.forEach(y=>{a.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{a.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{a.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(a),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this,...((a=this.defaultValue)==null?void 0:a.toFlat(i))||[],...this.writesValues.flatMap(e=>e.toFlat(i)),...((c=this.readsValue)==null?void 0:c.toFlat(i))||[],...this.successCalls.flatMap(e=>e.toFlat(i)),...this.errorCalls.flatMap(e=>e.toFlat(i)),...this.inputs.flatMap(e=>e.toFlat(i)),...this.outputs.flatMap(e=>e.toFlat(i)),...this.internalCalls.flatMap(e=>e.toFlat(i))])}toFlatIds(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((a=this.defaultValue)==null?void 0:a.toFlatIds(i))||[],...this.writesValues.flatMap(c=>c.toFlatIds(i)),...this.successCalls.flatMap(c=>c.toFlatIds(i)),...this.errorCalls.flatMap(c=>c.toFlatIds(i)),...this.inputs.flatMap(c=>c.toFlatIds(i)),...this.outputs.flatMap(c=>c.toFlatIds(i)),...this.internalCalls.flatMap(c=>c.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,catchesError:this.catchesError,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var n,a,c;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,declaration:this.declaration.toJSON(i),defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,readsValue:((a=this.readsValue)==null?void 0:a.toReference())||null,writesValues:this.writesValues.map(e=>e.toJSON(i)),inputs:this.inputs.map(e=>e.toJSON(i)),outputs:this.outputs.map(e=>e.toJSON(i)),successCalls:this.successCalls.map(e=>e.toJSON(i)),errorCalls:this.errorCalls.map(e=>e.toJSON(i)),internalCalls:this.internalCalls.map(e=>e.toJSON(i)),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),parent:this.parent.toReference(),error:((c=this.error)==null?void 0:c.toJSON(i))||null,x:this.x,y:this.y})}toJSONClone(i=tt){var a,c,e,y,m,v,E,b;let n;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||L().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,declaration:this.declaration.toReference({seenEntityMaps:i.seenEntityMaps}),readsValue:((E=this.readsValue)==null?void 0:E.toReference({seenEntityMaps:i.seenEntityMaps}))||null,writesValues:this.writesValues.map(w=>w.toJSONClone({...i,newId:null})),inputs:this.inputs.map(w=>w.toJSONClone({...i,newId:null})),outputs:this.outputs.map(w=>w.toJSONClone({...i,newId:null})),successCalls:this.successCalls.map(w=>w.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(w=>w.toJSONClone({...i,newId:null})),internalCalls:this.internalCalls.map(w=>this.calledBy.length||this.readsValue?w.toJSONClone({...i,newId:null}):w.toReference({seenEntityMaps:i.seenEntityMaps})),calledBySuccess:this.calledBySuccess.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),error:((b=this.error)==null?void 0:b.toJSONClone({...i,newId:null}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps}),x:this.x,y:this.y})}toReference(i=tt){var a;let n=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=tt){var a,c,e,y,m;let n=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,declaration:((e=this.declaration)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,writesValues:this.writesValues.map(v=>v.toReference(i)),inputs:this.inputs.map(v=>v.toReference(i)),outputs:this.outputs.map(v=>v.toReference(i)),successCalls:this.successCalls.map(v=>v.toReference(i)),errorCalls:this.errorCalls.map(v=>v.toReference(i)),calledBySuccess:this.calledBySuccess.map(v=>v.toReference(i)),calledByError:this.calledByError.map(v=>v.toReference(i)),calledByEntry:this.calledByEntry.map(v=>v.toReference(i)),internalCalls:this.internalCalls.map(v=>v.toReference(i)),error:((m=this.error)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((a=this.defaultValue)==null?void 0:a.toFlatJSON(i))||[],...((c=this.declaration)==null?void 0:c.toFlatJSON(i))||[],...this.writesValues.flatMap(e=>e.toFlatJSON(i)),...this.successCalls.flatMap(e=>e.toFlatJSON(i)),...this.errorCalls.flatMap(e=>e.toFlatJSON(i)),...this.inputs.flatMap(e=>e.toFlatJSON(i)),...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.internalCalls.flatMap(e=>e.toFlatJSON(i)),...this.calledBy.flatMap(e=>e.toFlatJSON(i))])}toGenerationTarget(i=tt){var c,e;const n=this.parent.type===d.Project?void 0:(c=i.seenEntityMaps)!=null&&c.has(this.parent.id)?i.seenEntityMaps.get(this.parent.id):this.parent.id;let a=this.id;return(e=i.seenEntityMaps)!=null&&e.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(y=>y.id),calledBySuccess:this.calledBySuccess.map(y=>y.id),calledByError:this.calledByError.map(y=>y.id),parent:n}}toFlatGenerationTarget(i=new Set){var a,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((a=this.defaultValue)==null?void 0:a.toFlatGenerationTarget(i))||[],...((c=this.declaration)==null?void 0:c.toFlatGenerationTarget(i))||[],...((e=this.readsValue)==null?void 0:e.toFlatGenerationTarget(i))||[],...this.writesValues.flatMap(y=>y.toFlatGenerationTarget(i)),...this.successCalls.flatMap(y=>y.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(y=>y.toFlatGenerationTarget(i)),...this.inputs.flatMap(y=>y.toFlatGenerationTarget(i)),...this.outputs.flatMap(y=>y.toFlatGenerationTarget(i)),...this.internalCalls.flatMap(y=>y.toFlatGenerationTarget(i))])}clearErrors(){var i;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),this.inputs.forEach(n=>n.clearErrors()),this.outputs.forEach(n=>n.clearErrors()),this.successCalls.forEach(n=>n.clearErrors()),this.errorCalls.forEach(n=>n.clearErrors()),this.internalCalls.forEach(n=>n.clearErrors()),this}validate(){return this.errors=VLe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await _Le(this,{tracker:n}),{success:!0}}getErrors(){var n;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...this.inputs.flatMap(a=>a.getErrors()),...this.internalCalls.flatMap(a=>a.getErrors()),...this.outputs.flatMap(a=>a.getErrors())]}async getErrorsAsync(i={}){var e;const n=J.YieldTracker.from(i),a=[...this.errors];await n.tick();const c=await((e=this.defaultValue)==null?void 0:e.getErrorsAsync({tracker:n}));c&&a.push(...c);for(const y of this.inputs){const m=await y.getErrorsAsync({tracker:n});a.push(...m)}for(const y of this.internalCalls){const m=await y.getErrorsAsync({tracker:n});a.push(...m)}for(const y of this.outputs){const m=await y.getErrorsAsync({tracker:n});a.push(...m)}return a}getShallowErrors(){return this.errors}getDefaultValue(){var i;return this.defaultValue||((i=this.declaration)==null?void 0:i.defaultValue)||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const a=this.defaultValue;if((a==null?void 0:a.id)!==(i==null?void 0:i.id)){if(a==null||a.remove({ignoreUpstream:!0},n),this.defaultValue=i,this.defaultValue){const c=this.readsValue;this.removeValueWriter(n),c==null||c.removeValueReader(this,n)}n==null||n.add(this,H.Affected)}return n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.CloneEntity)),n=null,a=null,c=!0){var $,M,k,F;const e=Ir(n,this),y=this.toJSON(),m=a||x.UUID.uuid();y.inputs=[],y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||L().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Si(y,e);n?v.setParent(n,i):v.setParent(this.parent,null),c&&v.subscribe(),v.initChildren(i),i==null||i.add(v,H.Added);const E=($=this.defaultValue)==null?void 0:$.clone(i,v,x.UUID.uuid(),c);v.defaultValue=E||null;const b=(M=this.inputs)==null?void 0:M.map(U=>U.clone(i,v,x.UUID.uuid(),c));v.inputs=b;const w=(k=this.outputs)==null?void 0:k.map(U=>U.clone(i,v,x.UUID.uuid(),c));v.outputs=w;const V=(F=this.internalCalls)==null?void 0:F.map(U=>U.clone(i,v,x.UUID.uuid(),c));return v.internalCalls=V,i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}addInternalCall(i){return this.internalCalls.find(n=>n===i)||this.internalCalls.push(i),this}setDeclaration(i){return this.declaration!==i&&(this.declaration=i),this}removeUnrecognizedInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.RemoveUnrecognizedInputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],a=[],c=[],e=[];return this.declaration.dataType&&!this.declaration.dataType.isObject()?[...this.inputs].forEach(y=>{const m=y.remove({ignoreUpstream:!1},i);c.push(...m.removed),n.push(...m.updated)}):this.declaration.dataType&&this.declaration.dataType.hasStrictObjectStructure()&&[...this.inputs].forEach(y=>{var v;if(!y.declaration){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated);return}if(![...((v=this.declaration.dataType)==null?void 0:v.entity).allProperties].find(E=>y.declaration===E)){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}}),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:D(n),added:D(a),removed:D(c),affected:D(e),self:this}}removeUnrecognizedOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-variable-instance-outputs"))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],a=[],c=[],e=[];return this.declaration.dataType&&!this.declaration.dataType.isObject()?[...this.outputs].forEach(y=>{const m=y.remove({ignoreUpstream:!1},i);c.push(...m.removed),n.push(...m.updated)}):this.declaration.dataType&&this.declaration.dataType.hasStrictObjectStructure()&&[...this.outputs].forEach(y=>{var v;if(!y.declaration){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated);return}if(![...((v=this.declaration.dataType)==null?void 0:v.entity).allProperties].find(E=>y.declaration===E)){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}}),i==null||i.attemptAutoclose("remove-unrecognized-variable-instance-outputs",this.id),{updated:D(n),added:D(a),removed:D(c),affected:D(e),self:this}}removeUnrecognizedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-variable-declaration-internal-calls"))){const n=[],a=[],c=[],e=[];if(!this.declaration.dataType||!this.declaration.dataType.entity||![d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))[...this.internalCalls].forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)});else if(this.declaration.dataType&&this.declaration.dataType.entity&&[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)){const m=[...this.declaration.dataType.entity.getAllInteractiveMethods()],v=[...m].filter(E=>!m.some(b=>{var w,V;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((V=b.extends)==null?void 0:V.id)===E.id)})&&!E.deleted);[...this.internalCalls].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}})}return this.internalCalls.filter((m,v)=>{const E=this.internalCalls.findIndex(w=>w.declaration===m.declaration&&w!==m);if(E===-1)return!1;const b=this.internalCalls[E];return L(b==null?void 0:b.createdAt).isSame(L(m.createdAt))?v>E:!!L(b==null?void 0:b.createdAt).isAfter(m.createdAt)}).forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-internal-calls",this.id),{updated:D(n),added:D(a),removed:D(c),affected:D(e),self:this}}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"sync-variable-instance-inputs"))){const n=[],a=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList){const y=[...this.declaration.dataType.entity.properties];y.filter(b=>!b.getDataType(i)).forEach(b=>{const w=this.inputs.find(M=>le(M,this.project)===le(b,this.project));if(!w)return;const V=this.declaration.getMasterInputWithValueWritterFromAllInstances(w);if(!V)return;const $=Td(V);b.setDataType($,i),w.setDeclaration(b,i)}),y.filter(b=>!this.inputs.find(w=>{var V;return((V=w.declaration)==null?void 0:V.id)===b.id})).forEach(b=>{const w={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:b,defaultValue:null,index:b.index,readsValue:null},V=me(w,this.project);return V.setParent(this,i),V.initChildren(i),i==null||i.add(V,H.Added),this.addInput(V,i),V}),this.inputs.filter(b=>!b.declaration).forEach(b=>{const w=y.find(V=>le(V,this.project)===le(b,this.project));w&&b.setDeclaration(w,i)})}}else return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:D(n),updated:D(a),removed:D(c),affected:D(e),self:this}}syncOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,_.SyncOutputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[syncOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],a=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity)[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList&&[...this.declaration.dataType.entity.properties].filter(v=>!this.outputs.find(E=>E.declaration===v)).map(v=>{const E={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,parent:this.toReference(),declaration:v,index:v.index,writesValues:[]},b=me(E,this.project);return b.setParent(this,i),b.initChildren(i),i==null||i.add(b,H.Added),this.addOutput(b,i),b});else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:D(n),updated:D(a),removed:D(c),affected:D(e),self:this}}generateUnusedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"generate-unused-internal-calls"))){const n=[],a=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList){const y=[...this.declaration.dataType.entity.getAllInteractiveMethods()];[...y].filter(E=>!y.some(b=>{var w,V;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((V=b.extends)==null?void 0:V.id)===E.id)})&&!E.deleted).filter(E=>!this.internalCalls.find(w=>{var $,M,k,F,U;return((($=w.declaration)==null?void 0:$.id)||((k=(M=w.initialData)==null?void 0:M.declaration)==null?void 0:k.entityId)||((U=(F=w.initialData)==null?void 0:F.declaration)==null?void 0:U.id))===E.id})).forEach(E=>{const b=this.internalCalls.find(w=>{const V=xc(w.declaration),$=xc(E);return V.id===$.id});if(b)b.setDeclaration(E),b.subscribeToDependencies();else{const w=E.createInternalCall(i,this);i==null||i.add(w,H.Added),this.addInternalCall(w)}})}}else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:D(n),updated:D(a),removed:D(c),affected:D(e),self:this}}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,L().toISOString(),this,!0,"get-data-type"))){var a;const n=((a=this.declaration)==null?void 0:a.getDataType(i))||null;return i==null||i.attemptAutoclose("get-data-type",this.id),n}getUnusedInputs(){return this.inputs.filter(i=>i.suggestion||!i.readsValue&&!i.defaultValue)}getUnusedOutputs(){return this.outputs.filter(i=>i.suggestion||!i.writesValues.length)}getUsedInputs(){return this.inputs.filter(i=>!i.suggestion&&(i.readsValue||i.defaultValue))}getUsedOutputs(){return this.outputs.filter(i=>!i.suggestion&&i.writesValues.length)}};I(mi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...a)=>null}),I(mi,"type",d.VariableInstance),I(mi,"USER_MANAGED_PARENT_TYPES",[...nr,d.Project]),I(mi,"PARENT_TYPES",[...mi.USER_MANAGED_PARENT_TYPES]),I(mi,"MUTABLE_BASE_PROPERTIES",["catchesError"]),I(mi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(mi,"BASE_PROPERTIES",[...mi.MUTABLE_BASE_PROPERTIES,...mi.INMUTABLE_BASE_PROPERTIES]),I(mi,"MUTABLE_META_PROPERTIES",[...mi.MUTABLE_BASE_PROPERTIES,"x","y"]),I(mi,"INMUTABLE_META_PROPERTIES",[...mi.INMUTABLE_BASE_PROPERTIES]),I(mi,"META_PROPERTIES",[...mi.MUTABLE_META_PROPERTIES,...mi.INMUTABLE_META_PROPERTIES]),I(mi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(mi,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),I(mi,"UPSTREAM_PROPERTIES",[...mi.MUTABLE_UPSTREAM_PROPERTIES,...mi.INMUTABLE_UPSTREAM_PROPERTIES]),I(mi,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),I(mi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),I(mi,"DOWNSTREAM_PROPERTIES",[...mi.MUTABLE_DOWNSTREAM_PROPERTIES,...mi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(mi,"PROPERTIES",[...mi.META_PROPERTIES,...mi.UPSTREAM_PROPERTIES,...mi.DOWNSTREAM_PROPERTIES]);let Gu=mi;var PLe=(o=>(o.Parent="variable-declaration-parent",o.DataTypeEntity="variable-declaration-data-type-entity",o.DataType="variable-declaration-data-type",o))(PLe||{});const Ti=class Ti extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"name");I(this,"codeName",null);I(this,"description",null);I(this,"required",!1);I(this,"constant",!1);I(this,"x");I(this,"y");I(this,"type",d.VariableDeclaration);I(this,"catchesError",!1);I(this,"defaultValue",null);I(this,"dataType",null);I(this,"writesValues",[]);I(this,"readsValue",null);I(this,"inputs",[]);I(this,"outputs",[]);I(this,"error",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"successCalls",[]);I(this,"errorCalls",[]);I(this,"internalCalls",[]);I(this,"parent");I(this,"errors",[]);I(this,"project");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.name=i.name,this.description=i.description,this.constant=i.constant,this.codeName=i.codeName,this.required=i.required,this.x=i.x,this.y=i.y,this.catchesError=i.catchesError||!1}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableDeclaration,catchesError:!1,name:"",codeName:null,description:"",dataType:null,internalCalls:[],successCalls:[],errorCalls:[],readsValue:null,writesValues:[],defaultValue:null,constant:!1,required:!1,inputs:[],outputs:[],parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],error:null,x:0,y:0}}static fromGenerationTarget(i,n){let a=n;if(i.parent){const b=ne(i.parent);a=n.get(b)}const c=i.calledByEntry.map(b=>{const w=ne(b);return n.get(w)}),e=i.calledBySuccess.map(b=>{const w=ne(b);return n.get(w)}),y=i.calledByError.map(b=>{const w=ne(b);return n.get(w)});let m=null;if(i.readsValue){const b=ne(i.readsValue);m=n.get(b)}const v={id:i.id,version:x.UUID.uuid(),createdAt:L().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableDeclaration,catchesError:i.catchesError||!1,name:i.name,defaultValue:null,codeName:i.codeName||null,description:i.description||null,constant:i.constant||!1,required:i.required||!1,calledByEntry:c,calledBySuccess:e,calledByError:y,dataType:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:m,inputs:[],outputs:[],writesValues:[],error:null,x:0,y:0,parent:a},E=me(v,n);return E.setParent(a,null),E}static validateGenerationTarget(i,n){let a=JSON.parse(JSON.stringify(i));const c=[],e=bn(a,{parent:{list:!1,types:[...nr,d.Project],optional:!0}},n);a=e.modifiedData;const y=xP(a,n);return c.push(...e.errors,...y,...xr(a)),{errors:c,modifiedData:a}}get variableInstances(){const i=[];return Object.values(this.detachedDependents).forEach(n=>{n.field===wN.VarDeclaration&&!i.includes(n.entity)&&i.push(n.entity)}),i}validateGeneratedUpdate(i){const n=[];let a=JSON.parse(JSON.stringify(i));const c=of(a,this);return a=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${se.InvalidParentUpdate}`,code:se.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
package/dist/index.d.ts CHANGED
@@ -11552,6 +11552,7 @@ export declare class DefaultEditorContext extends ExtensionContextBase<Extension
11552
11552
  requestActiveDynamicValue(valueOwner: EntityWithValueState, onlyDefault?: boolean): IDynamicValue | null;
11553
11553
  getValueTypePreference(valueOwnerId: EntityId): DynamicValueTypes.DefaultValue | DynamicValueTypes.Testing | null;
11554
11554
  setValueTypePreference(valueOwnerId: EntityId, valueTypePreference: DynamicValueTypes.DefaultValue | DynamicValueTypes.Testing | null): void;
11555
+ implementFeature(featureId: string): Promise<void>;
11555
11556
  }
11556
11557
 
11557
11558
  export declare type DefaultExtensionContext = DefaultEditorContext | DefaultProjectLogicContext | DefaultPublicationRunContext;
@@ -21191,6 +21192,7 @@ export declare function getReferencedEntityStateOrErrors(data: ElementGeneration
21191
21192
  sessionId: string;
21192
21193
  }>): void;
21193
21194
  handleReconnectingWebsocket(): void;
21195
+ handleChunkedChangeSetMessage(message: PersistChangeSetEntityActionRequestPayload): PersistChangeSetEntityActionRequestPayload | null;
21194
21196
  handlePersistChangeSetMessage(message: PersistChangeSetEntityActionRequestPayload): void;
21195
21197
  getLogic(options?: {
21196
21198
  mockLogic?: ProjectState;
@@ -21218,9 +21220,10 @@ export declare function getReferencedEntityStateOrErrors(data: ElementGeneration
21218
21220
  loadGivenPublication(publicationId: string): Promise<IPublication>;
21219
21221
  requestExtension<T = any>(moduleId: string): IRegisteredExtension<T>;
21220
21222
  initRegistry(): Promise<ExtensionsRegistry<any>>;
21223
+ implementFeature(featureId: string): Promise<void>;
21221
21224
  }
21222
21225
 
21223
- export declare interface IEditorContext extends ExtensionContextBase<ExtensionContextType.Editor>, Omit<IEditor, 'onLogicLoadingComplete' | 'onLogicLoadingCompleteCallback' | 'onProjectHeadLoaded' | 'onProjectHeadLoadedCallback' | 'onProjectSetupError' | 'onProjectSetupErrorCallback' | 'onRenderedCallback' | 'handleIncommingWebsocketMessage' | 'handleNotificationChannelsMessage' | 'handlePersistChangeSetMessage' | 'handleReconnectingWebsocket' | 'getLogic' | 'injectLocalImplementationOfSearchExecution' | 'setup' | 'destroy' | 'requestExtension' | 'socket' | 'events' | 'initRegistry' | 'extensionsRegistry' | 'on' | 'emit' | 'off' | 'contextType' | 'registerNonDefaultLocalImplementationsOfModules'> {
21226
+ export declare interface IEditorContext extends ExtensionContextBase<ExtensionContextType.Editor>, Omit<IEditor, 'onLogicLoadingComplete' | 'onLogicLoadingCompleteCallback' | 'onProjectHeadLoaded' | 'onProjectHeadLoadedCallback' | 'onProjectSetupError' | 'onProjectSetupErrorCallback' | 'onRenderedCallback' | 'handleIncommingWebsocketMessage' | 'handleNotificationChannelsMessage' | 'handlePersistChangeSetMessage' | 'handleReconnectingWebsocket' | 'handleChunkedChangeSetMessage' | 'getLogic' | 'injectLocalImplementationOfSearchExecution' | 'setup' | 'destroy' | 'requestExtension' | 'socket' | 'events' | 'initRegistry' | 'extensionsRegistry' | 'on' | 'emit' | 'off' | 'contextType' | 'registerNonDefaultLocalImplementationsOfModules'> {
21224
21227
  }
21225
21228
 
21226
21229
  export declare interface IEntityActionRequestPayload<P extends {
package/dist/index.js CHANGED
@@ -119388,6 +119388,9 @@ class J2 extends pO {
119388
119388
  i
119389
119389
  );
119390
119390
  }
119391
+ implementFeature(p) {
119392
+ return this._editor.implementFeature(p);
119393
+ }
119391
119394
  }
119392
119395
  function Gki(o, p) {
119393
119396
  return p instanceof J2 ? p : new J2(o, p);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.6771",
3
+ "version": "0.0.6772",
4
4
  "author": "Sergio Herrero",
5
5
  "license": "UNLICENSED",
6
6
  "description": "An installable module which contains the type definitions and ephemeral state management for a projects' logic tree data structure",