@elyx-code/project-logic-tree 0.0.6483 → 0.0.6485

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.
@@ -81,7 +81,7 @@ If an entity is called by another, they must be in the same scope, which means t
81
81
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(u){return u instanceof this?u:new this(u)}static concat(u,...r){const a=new this(u);return r.forEach(o=>a.set(o)),a}static accessor(u){const a=(this[Gx]=this[Gx]={accessors:{}}).accessors,o=this.prototype;function p(e){const y=Oc(e);a[y]||(mme(o,e),a[y]=!0)}return Te.isArray(u)?u.forEach(p):p(u),this}}Iy.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Te.reduceDescriptors(Iy.prototype,({value:d},u)=>{let r=u[0].toUpperCase()+u.slice(1);return{get:()=>d,set(a){this[r]=a}}}),Te.freezeMethods(Iy);const yn=Iy;function kI(d,u){const r=this||SI,a=u||r,o=yn.from(a.headers);let p=a.data;return Te.forEach(d,function(y){p=y.call(r,p,o.normalize(),u?u.status:void 0)}),o.normalize(),p}function Fx(d){return!!(d&&d.__CANCEL__)}function Nd(d,u,r){Ot.call(this,d??"canceled",Ot.ERR_CANCELED,u,r),this.name="CanceledError"}Te.inherits(Nd,Ot,{__CANCEL__:!0});function Sx(d,u,r){const a=r.config.validateStatus;!r.status||!a||a(r.status)?d(r):u(new Ot("Request failed with status code "+r.status,[Ot.ERR_BAD_REQUEST,Ot.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function vme(d){const u=/^([-+\w]{1,25})(:?\/\/|:)/.exec(d);return u&&u[1]||""}function Eme(d,u){d=d||10;const r=new Array(d),a=new Array(d);let o=0,p=0,e;return u=u!==void 0?u:1e3,function(v){const E=Date.now(),w=a[p];e||(e=E),r[o]=v,a[o]=E;let A=p,$=0;for(;A!==o;)$+=r[A++],A=A%d;if(o=(o+1)%d,o===p&&(p=(p+1)%d),E-e<u)return;const V=w&&E-w;return V?Math.round($*1e3/V):void 0}}function Tme(d,u){let r=0,a=1e3/u,o,p;const e=(E,w=Date.now())=>{r=w,o=null,p&&(clearTimeout(p),p=null),d.apply(null,E)};return[(...E)=>{const w=Date.now(),A=w-r;A>=a?e(E,w):(o=E,p||(p=setTimeout(()=>{p=null,e(o)},a-A)))},()=>o&&e(o)]}const Ay=(d,u,r=3)=>{let a=0;const o=Eme(50,250);return Tme(p=>{const e=p.loaded,y=p.lengthComputable?p.total:void 0,v=e-a,E=o(v),w=e<=y;a=e;const A={loaded:e,total:y,progress:y?e/y:void 0,bytes:v,rate:E||void 0,estimated:E&&y&&w?(y-e)/E:void 0,event:p,lengthComputable:y!=null,[u?"download":"upload"]:!0};d(A)},r)},Kx=(d,u)=>{const r=d!=null;return[a=>u[0]({lengthComputable:r,total:d,loaded:a}),u[1]]},kx=d=>(...u)=>Te.asap(()=>d(...u)),Ime=Fi.hasStandardBrowserEnv?((d,u)=>r=>(r=new URL(r,Fi.origin),d.protocol===r.protocol&&d.host===r.host&&(u||d.port===r.port)))(new URL(Fi.origin),Fi.navigator&&/(msie|trident)/i.test(Fi.navigator.userAgent)):()=>!0,Ame=Fi.hasStandardBrowserEnv?{write(d,u,r,a,o,p){const e=[d+"="+encodeURIComponent(u)];Te.isNumber(r)&&e.push("expires="+new Date(r).toGMTString()),Te.isString(a)&&e.push("path="+a),Te.isString(o)&&e.push("domain="+o),p===!0&&e.push("secure"),document.cookie=e.join("; ")},read(d){const u=document.cookie.match(new RegExp("(^|;\\s*)("+d+")=([^;]*)"));return u?decodeURIComponent(u[3]):null},remove(d){this.write(d,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function bme(d){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(d)}function wme(d,u){return u?d.replace(/\/?\/$/,"")+"/"+u.replace(/^\/+/,""):d}function qx(d,u,r){let a=!bme(u);return d&&(a||r==!1)?wme(d,u):u}const Zx=d=>d instanceof yn?{...d}:d;function fl(d,u){u=u||{};const r={};function a(E,w,A,$){return Te.isPlainObject(E)&&Te.isPlainObject(w)?Te.merge.call({caseless:$},E,w):Te.isPlainObject(w)?Te.merge({},w):Te.isArray(w)?w.slice():w}function o(E,w,A,$){if(Te.isUndefined(w)){if(!Te.isUndefined(E))return a(void 0,E,A,$)}else return a(E,w,A,$)}function p(E,w){if(!Te.isUndefined(w))return a(void 0,w)}function e(E,w){if(Te.isUndefined(w)){if(!Te.isUndefined(E))return a(void 0,E)}else return a(void 0,w)}function y(E,w,A){if(A in u)return a(E,w);if(A in d)return a(void 0,E)}const v={url:p,method:p,data:p,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:(E,w,A)=>o(Zx(E),Zx(w),A,!0)};return Te.forEach(Object.keys(Object.assign({},d,u)),function(w){const A=v[w]||o,$=A(d[w],u[w],w);Te.isUndefined($)&&A!==y||(r[w]=$)}),r}const Hx=d=>{const u=fl({},d);let{data:r,withXSRFToken:a,xsrfHeaderName:o,xsrfCookieName:p,headers:e,auth:y}=u;u.headers=e=yn.from(e),u.url=Bx(qx(u.baseURL,u.url,u.allowAbsoluteUrls),d.params,d.paramsSerializer),y&&e.set("Authorization","Basic "+btoa((y.username||"")+":"+(y.password?unescape(encodeURIComponent(y.password)):"")));let v;if(Te.isFormData(r)){if(Fi.hasStandardBrowserEnv||Fi.hasStandardBrowserWebWorkerEnv)e.setContentType(void 0);else if((v=e.getContentType())!==!1){const[E,...w]=v?v.split(";").map(A=>A.trim()).filter(Boolean):[];e.setContentType([E||"multipart/form-data",...w].join("; "))}}if(Fi.hasStandardBrowserEnv&&(a&&Te.isFunction(a)&&(a=a(u)),a||a!==!1&&Ime(u.url))){const E=o&&p&&Ame.read(p);E&&e.set(o,E)}return u},Rme=typeof XMLHttpRequest<"u"&&function(d){return new Promise(function(r,a){const o=Hx(d);let p=o.data;const e=yn.from(o.headers).normalize();let{responseType:y,onUploadProgress:v,onDownloadProgress:E}=o,w,A,$,V,B;function F(){V&&V(),B&&B(),o.cancelToken&&o.cancelToken.unsubscribe(w),o.signal&&o.signal.removeEventListener("abort",w)}let K=new XMLHttpRequest;K.open(o.method.toUpperCase(),o.url,!0),K.timeout=o.timeout;function q(){if(!K)return;const W=yn.from("getAllResponseHeaders"in K&&K.getAllResponseHeaders()),Q={data:!y||y==="text"||y==="json"?K.responseText:K.response,status:K.status,statusText:K.statusText,headers:W,config:d,request:K};Sx(function(X){r(X),F()},function(X){a(X),F()},Q),K=null}"onloadend"in K?K.onloadend=q:K.onreadystatechange=function(){!K||K.readyState!==4||K.status===0&&!(K.responseURL&&K.responseURL.indexOf("file:")===0)||setTimeout(q)},K.onabort=function(){K&&(a(new Ot("Request aborted",Ot.ECONNABORTED,d,K)),K=null)},K.onerror=function(){a(new Ot("Network Error",Ot.ERR_NETWORK,d,K)),K=null},K.ontimeout=function(){let de=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const Q=o.transitional||xx;o.timeoutErrorMessage&&(de=o.timeoutErrorMessage),a(new Ot(de,Q.clarifyTimeoutError?Ot.ETIMEDOUT:Ot.ECONNABORTED,d,K)),K=null},p===void 0&&e.setContentType(null),"setRequestHeader"in K&&Te.forEach(e.toJSON(),function(de,Q){K.setRequestHeader(Q,de)}),Te.isUndefined(o.withCredentials)||(K.withCredentials=!!o.withCredentials),y&&y!=="json"&&(K.responseType=o.responseType),E&&([$,B]=Ay(E,!0),K.addEventListener("progress",$)),v&&K.upload&&([A,V]=Ay(v),K.upload.addEventListener("progress",A),K.upload.addEventListener("loadend",V)),(o.cancelToken||o.signal)&&(w=W=>{K&&(a(!W||W.type?new Nd(null,d,K):W),K.abort(),K=null)},o.cancelToken&&o.cancelToken.subscribe(w),o.signal&&(o.signal.aborted?w():o.signal.addEventListener("abort",w)));const ie=vme(o.url);if(ie&&Fi.protocols.indexOf(ie)===-1){a(new Ot("Unsupported protocol "+ie+":",Ot.ERR_BAD_REQUEST,d));return}K.send(p||null)})},gme=(d,u)=>{const{length:r}=d=d?d.filter(Boolean):[];if(u||r){let a=new AbortController,o;const p=function(E){if(!o){o=!0,y();const w=E instanceof Error?E:this.reason;a.abort(w instanceof Ot?w:new Nd(w instanceof Error?w.message:w))}};let e=u&&setTimeout(()=>{e=null,p(new Ot(`timeout ${u} of ms exceeded`,Ot.ETIMEDOUT))},u);const y=()=>{d&&(e&&clearTimeout(e),e=null,d.forEach(E=>{E.unsubscribe?E.unsubscribe(p):E.removeEventListener("abort",p)}),d=null)};d.forEach(E=>E.addEventListener("abort",p));const{signal:v}=a;return v.unsubscribe=()=>Te.asap(y),v}},_me=function*(d,u){let r=d.byteLength;if(!u||r<u){yield d;return}let a=0,o;for(;a<r;)o=a+u,yield d.slice(a,o),a=o},Dme=async function*(d,u){for await(const r of Ome(d))yield*_me(r,u)},Ome=async function*(d){if(d[Symbol.asyncIterator]){yield*d;return}const u=d.getReader();try{for(;;){const{done:r,value:a}=await u.read();if(r)break;yield a}}finally{await u.cancel()}},Jx=(d,u,r,a)=>{const o=Dme(d,u);let p=0,e,y=v=>{e||(e=!0,a&&a(v))};return new ReadableStream({async pull(v){try{const{done:E,value:w}=await o.next();if(E){y(),v.close();return}let A=w.byteLength;if(r){let $=p+=A;r($)}v.enqueue(new Uint8Array(w))}catch(E){throw y(E),E}},cancel(v){return y(v),o.return()}},{highWaterMark:2})},by=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Wx=by&&typeof ReadableStream=="function",Cme=by&&(typeof TextEncoder=="function"?(d=>u=>d.encode(u))(new TextEncoder):async d=>new Uint8Array(await new Response(d).arrayBuffer())),Yx=(d,...u)=>{try{return!!d(...u)}catch{return!1}},$me=Wx&&Yx(()=>{let d=!1;const u=new Request(Fi.origin,{body:new ReadableStream,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!u}),zx=64*1024,qI=Wx&&Yx(()=>Te.isReadableStream(new Response("").body)),wy={stream:qI&&(d=>d.body)};by&&(d=>{["text","arrayBuffer","blob","formData","stream"].forEach(u=>{!wy[u]&&(wy[u]=Te.isFunction(d[u])?r=>r[u]():(r,a)=>{throw new Ot(`Response type '${u}' is not supported`,Ot.ERR_NOT_SUPPORT,a)})})})(new Response);const Pme=async d=>{if(d==null)return 0;if(Te.isBlob(d))return d.size;if(Te.isSpecCompliantForm(d))return(await new Request(Fi.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(Te.isArrayBufferView(d)||Te.isArrayBuffer(d))return d.byteLength;if(Te.isURLSearchParams(d)&&(d=d+""),Te.isString(d))return(await Cme(d)).byteLength},Nme=async(d,u)=>{const r=Te.toFiniteNumber(d.getContentLength());return r??Pme(u)},ZI={http:Xye,xhr:Rme,fetch:by&&(async d=>{let{url:u,method:r,data:a,signal:o,cancelToken:p,timeout:e,onDownloadProgress:y,onUploadProgress:v,responseType:E,headers:w,withCredentials:A="same-origin",fetchOptions:$}=Hx(d);E=E?(E+"").toLowerCase():"text";let V=gme([o,p&&p.toAbortSignal()],e),B;const F=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let K;try{if(v&&$me&&r!=="get"&&r!=="head"&&(K=await Nme(w,a))!==0){let Q=new Request(u,{method:"POST",body:a,duplex:"half"}),ce;if(Te.isFormData(a)&&(ce=Q.headers.get("content-type"))&&w.setContentType(ce),Q.body){const[X,z]=Kx(K,Ay(kx(v)));a=Jx(Q.body,zx,X,z)}}Te.isString(A)||(A=A?"include":"omit");const q="credentials"in Request.prototype;B=new Request(u,{...$,signal:V,method:r.toUpperCase(),headers:w.normalize().toJSON(),body:a,duplex:"half",credentials:q?A:void 0});let ie=await fetch(B);const W=qI&&(E==="stream"||E==="response");if(qI&&(y||W&&F)){const Q={};["status","statusText","headers"].forEach(pe=>{Q[pe]=ie[pe]});const ce=Te.toFiniteNumber(ie.headers.get("content-length")),[X,z]=y&&Kx(ce,Ay(kx(y),!0))||[];ie=new Response(Jx(ie.body,zx,X,()=>{z&&z(),F&&F()}),Q)}E=E||"text";let de=await wy[Te.findKey(wy,E)||"text"](ie,d);return!W&&F&&F(),await new Promise((Q,ce)=>{Sx(Q,ce,{data:de,headers:yn.from(ie.headers),status:ie.status,statusText:ie.statusText,config:d,request:B})})}catch(q){throw F&&F(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Ot("Network Error",Ot.ERR_NETWORK,d,B),{cause:q.cause||q}):Ot.from(q,q&&q.code,d,B)}})};Te.forEach(ZI,(d,u)=>{if(d){try{Object.defineProperty(d,"name",{value:u})}catch{}Object.defineProperty(d,"adapterName",{value:u})}});const Xx=d=>`- ${d}`,Vme=d=>Te.isFunction(d)||d===null||d===!1,Qx={getAdapter:d=>{d=Te.isArray(d)?d:[d];const{length:u}=d;let r,a;const o={};for(let p=0;p<u;p++){r=d[p];let e;if(a=r,!Vme(r)&&(a=ZI[(e=String(r)).toLowerCase()],a===void 0))throw new Ot(`Unknown adapter '${e}'`);if(a)break;o[e||"#"+p]=a}if(!a){const p=Object.entries(o).map(([y,v])=>`adapter ${y} `+(v===!1?"is not supported by the environment":"is not available in the build"));let e=u?p.length>1?`since :
82
82
  `+p.map(Xx).join(`
83
83
  `):" "+Xx(p[0]):"as no adapter specified";throw new Ot("There is no suitable adapter to dispatch the request "+e,"ERR_NOT_SUPPORT")}return a},adapters:ZI};function HI(d){if(d.cancelToken&&d.cancelToken.throwIfRequested(),d.signal&&d.signal.aborted)throw new Nd(null,d)}function ej(d){return HI(d),d.headers=yn.from(d.headers),d.data=kI.call(d,d.transformRequest),["post","put","patch"].indexOf(d.method)!==-1&&d.headers.setContentType("application/x-www-form-urlencoded",!1),Qx.getAdapter(d.adapter||SI.adapter)(d).then(function(a){return HI(d),a.data=kI.call(d,d.transformResponse,a),a.headers=yn.from(a.headers),a},function(a){return Fx(a)||(HI(d),a&&a.response&&(a.response.data=kI.call(d,d.transformResponse,a.response),a.response.headers=yn.from(a.response.headers))),Promise.reject(a)})}const tj="1.9.0",Ry={};["object","boolean","number","function","string","symbol"].forEach((d,u)=>{Ry[d]=function(a){return typeof a===d||"a"+(u<1?"n ":" ")+d}});const rj={};Ry.transitional=function(u,r,a){function o(p,e){return"[Axios v"+tj+"] Transitional option '"+p+"'"+e+(a?". "+a:"")}return(p,e,y)=>{if(u===!1)throw new Ot(o(e," has been removed"+(r?" in "+r:"")),Ot.ERR_DEPRECATED);return r&&!rj[e]&&(rj[e]=!0,console.warn(o(e," has been deprecated since v"+r+" and will be removed in the near future"))),u?u(p,e,y):!0}},Ry.spelling=function(u){return(r,a)=>(console.warn(`${a} is likely a misspelling of ${u}`),!0)};function Lme(d,u,r){if(typeof d!="object")throw new Ot("options must be an object",Ot.ERR_BAD_OPTION_VALUE);const a=Object.keys(d);let o=a.length;for(;o-- >0;){const p=a[o],e=u[p];if(e){const y=d[p],v=y===void 0||e(y,p,d);if(v!==!0)throw new Ot("option "+p+" must be "+v,Ot.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Ot("Unknown option "+p,Ot.ERR_BAD_OPTION)}}const gy={assertOptions:Lme,validators:Ry},Zn=gy.validators;class _y{constructor(u){this.defaults=u||{},this.interceptors={request:new Ux,response:new Ux}}async request(u,r){try{return await this._request(u,r)}catch(a){if(a instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const p=o.stack?o.stack.replace(/^.+\n/,""):"";try{a.stack?p&&!String(a.stack).endsWith(p.replace(/^.+\n.+\n/,""))&&(a.stack+=`
84
- `+p):a.stack=p}catch{}}throw a}}_request(u,r){typeof u=="string"?(r=r||{},r.url=u):r=u||{},r=fl(this.defaults,r);const{transitional:a,paramsSerializer:o,headers:p}=r;a!==void 0&&gy.assertOptions(a,{silentJSONParsing:Zn.transitional(Zn.boolean),forcedJSONParsing:Zn.transitional(Zn.boolean),clarifyTimeoutError:Zn.transitional(Zn.boolean)},!1),o!=null&&(Te.isFunction(o)?r.paramsSerializer={serialize:o}:gy.assertOptions(o,{encode:Zn.function,serialize:Zn.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),gy.assertOptions(r,{baseUrl:Zn.spelling("baseURL"),withXsrfToken:Zn.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let e=p&&Te.merge(p.common,p[r.method]);p&&Te.forEach(["delete","get","head","post","put","patch","common"],B=>{delete p[B]}),r.headers=yn.concat(e,p);const y=[];let v=!0;this.interceptors.request.forEach(function(F){typeof F.runWhen=="function"&&F.runWhen(r)===!1||(v=v&&F.synchronous,y.unshift(F.fulfilled,F.rejected))});const E=[];this.interceptors.response.forEach(function(F){E.push(F.fulfilled,F.rejected)});let w,A=0,$;if(!v){const B=[ej.bind(this),void 0];for(B.unshift.apply(B,y),B.push.apply(B,E),$=B.length,w=Promise.resolve(r);A<$;)w=w.then(B[A++],B[A++]);return w}$=y.length;let V=r;for(A=0;A<$;){const B=y[A++],F=y[A++];try{V=B(V)}catch(K){F.call(this,K);break}}try{w=ej.call(this,V)}catch(B){return Promise.reject(B)}for(A=0,$=E.length;A<$;)w=w.then(E[A++],E[A++]);return w}getUri(u){u=fl(this.defaults,u);const r=qx(u.baseURL,u.url,u.allowAbsoluteUrls);return Bx(r,u.params,u.paramsSerializer)}}Te.forEach(["delete","get","head","options"],function(u){_y.prototype[u]=function(r,a){return this.request(fl(a||{},{method:u,url:r,data:(a||{}).data}))}}),Te.forEach(["post","put","patch"],function(u){function r(a){return function(p,e,y){return this.request(fl(y||{},{method:u,headers:a?{"Content-Type":"multipart/form-data"}:{},url:p,data:e}))}}_y.prototype[u]=r(),_y.prototype[u+"Form"]=r(!0)});const Dy=_y;class JI{constructor(u){if(typeof u!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(p){r=p});const a=this;this.promise.then(o=>{if(!a._listeners)return;let p=a._listeners.length;for(;p-- >0;)a._listeners[p](o);a._listeners=null}),this.promise.then=o=>{let p;const e=new Promise(y=>{a.subscribe(y),p=y}).then(o);return e.cancel=function(){a.unsubscribe(p)},e},u(function(p,e,y){a.reason||(a.reason=new Nd(p,e,y),r(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(u){if(this.reason){u(this.reason);return}this._listeners?this._listeners.push(u):this._listeners=[u]}unsubscribe(u){if(!this._listeners)return;const r=this._listeners.indexOf(u);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const u=new AbortController,r=a=>{u.abort(a)};return this.subscribe(r),u.signal.unsubscribe=()=>this.unsubscribe(r),u.signal}static source(){let u;return{token:new JI(function(o){u=o}),cancel:u}}}const Mme=JI;function Bme(d){return function(r){return d.apply(null,r)}}function Ume(d){return Te.isObject(d)&&d.isAxiosError===!0}const WI={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};Object.entries(WI).forEach(([d,u])=>{WI[u]=d});const xme=WI;function ij(d){const u=new Dy(d),r=Ax(Dy.prototype.request,u);return Te.extend(r,Dy.prototype,u,{allOwnKeys:!0}),Te.extend(r,u,null,{allOwnKeys:!0}),r.create=function(o){return ij(fl(d,o))},r}const di=ij(SI);di.Axios=Dy,di.CanceledError=Nd,di.CancelToken=Mme,di.isCancel=Fx,di.VERSION=tj,di.toFormData=Ey,di.AxiosError=Ot,di.Cancel=di.CanceledError,di.all=function(u){return Promise.all(u)},di.spread=Bme,di.isAxiosError=Ume,di.mergeConfig=fl,di.AxiosHeaders=yn,di.formToJSON=d=>jx(Te.isHTMLForm(d)?new FormData(d):d),di.getAdapter=Qx.getAdapter,di.HttpStatusCode=xme,di.default=di;const jme=di;class sj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION,version:"1.0.0",description:"Number addition operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Addition);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const e=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)}).reduce((y,v)=>y+v,0);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class nj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION,version:"1.0.0",description:"Number subtraction operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Subtraction);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),[p,e]=o,y=p-e;return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class aj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION,version:"1.0.0",description:"Number multiplication operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Multiplication);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const e=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)}).reduce((y,v)=>y*v,1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class oj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION,version:"1.0.0",description:"Number division operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Division);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),[p,e]=o;if(e===0)throw new Error("Division by zero is not allowed");const y=p/e;return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class lj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER,version:"1.0.0",description:"Number remainder operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Remainder);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),[p,e]=o;if(e===0)throw new Error("Division by zero is not allowed");const y=p%e;return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class dj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION,version:"1.0.0",description:"Number exponentiation operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Exponentiation);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),[p,e]=o,y=Math.pow(p,e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class uj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER,version:"1.0.0",description:"Randomness generate random integer operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomInteger);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1],y=lye(p,e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class cj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT,version:"1.0.0",description:"Randomness generate random float operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomFloat);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=vx();return{value:Z.Success,error:null,results:[o]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class pj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL,version:"1.0.0",description:"Randomness generate random hexadecimal operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomHexadecimal);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0],e=Ex(p);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class fj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62,version:"1.0.0",description:"Randomness generate random base62 operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomBase62);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0],e=Tx(p);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class hj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64,version:"1.0.0",description:"Randomness generate random base64 operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomBase64);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0],e=uye(p);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class yj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC,version:"1.0.0",description:"Randomness generate random alphanumeric operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomAlphanumeric);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0],e=cye(p);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class mj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER,version:"1.0.0",description:"Generate identifier operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateIdentifier);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1],y=Ix(p,e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class vj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4,version:"1.0.0",description:"Generate UUID v4 operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomUUIDv4);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=cl();return{value:Z.Success,error:null,results:[o]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Ej extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER,version:"1.0.0",description:"Generate short identifier operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{Me.log("Initializing Random Generate Short Identifier Module");const a=r.find(o=>o.contextType===be.Logic);if(a){Me.log("Project state found, setting up operation");const o=a.get(_e.GenerateShortIdentifier);o?(Me.log("Operation found, setting autoexecutable and implementation"),o.autoexecutable=!0,o.implementation=this.module.main):Me.warn("Operation generate-short-identifier not found in project state")}else Me.warn("Project state not found in contexts for Random Generate Short Identifier Module")},main:async(r,a)=>{try{const o=pye();return{value:Z.Success,error:null,results:[o]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Tj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN,version:"1.0.0",description:"Generate hexadecimal token operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateHexadecimalToken);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=fye();return{value:Z.Success,error:null,results:[o]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Ij extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN,version:"1.0.0",description:"String join operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.Join);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],y=o.slice(1).join(p);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Aj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT,version:"1.0.0",description:"String split operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.Split);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1],y=p.split(e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class bj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST,version:"1.0.0",description:"String delete last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.DeleteLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.slice(0,-1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class wj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST,version:"1.0.0",description:"String delete first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.DeleteFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.slice(1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Rj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE,version:"1.0.0",description:"String reverse operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.Reverse);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.split("").reverse().join("");return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class gj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE,version:"1.0.0",description:"String to lower case operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ToLowerCase);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.toLowerCase();return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class _j extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE,version:"1.0.0",description:"String to upper case operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ToUpperCase);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.toUpperCase();return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Dj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_INDEX,version:"1.0.0",description:"String delete index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.DeleteIndex);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};if(e<0||e>=p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const y=p.slice(0,e)+p.slice(e+1);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Oj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_INDEX,version:"1.0.0",description:"String add index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.AddIndex);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};if(e<0||e>p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const v=p.slice(0,e)+y+p.slice(e);return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Cj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST,version:"1.0.0",description:"String replace first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ReplaceFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const v=p.replace(e,y);return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class $j extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST,version:"1.0.0",description:"String replace last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ReplaceLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(w=>{var A,$;return((A=w.value)==null?void 0:A.valueAsType)||(($=w.value)==null?void 0:$.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const v=p.lastIndexOf(e);if(v===-1)return{value:Z.Success,error:null,results:[p]};const E=p.slice(0,v)+p.slice(v).replace(e,y);return{value:Z.Success,error:null,results:[E]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Pj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_INDEX,version:"1.0.0",description:"String replace index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ReplaceIndex);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};if(e<0||e>=p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const v=p.slice(0,e)+y+p.slice(e+1);return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Nj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_SINGLE_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ReplaceSingleMatch);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const v=p.replace(e,y);return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Vj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES,version:"1.0.0",description:"String replace all matches operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ReplaceAllMatches);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const v=p.split(e).join(y);return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Lj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM,version:"1.0.0",description:"String get index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.GetIndexItem);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const y=p.charAt(e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Mj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST,version:"1.0.0",description:"String get first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.GetFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.charAt(0);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Bj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST,version:"1.0.0",description:"String get last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.GetLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.charAt(p.length-1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Uj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF,version:"1.0.0",description:"String get index of operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.GetIndexOf);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const y=p.indexOf(e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class xj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND,version:"1.0.0",description:"String append operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.Append);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const y=p+e;return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class jj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND,version:"1.0.0",description:"String prepend operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.Prepend);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const y=e+p;return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Gj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN,version:"1.0.0",description:"List join operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.Join);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const y=p.join(e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Fj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT,version:"1.0.0",description:"List split operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.Split);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const y=p.split(e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Sj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE,version:"1.0.0",description:"List reverse operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.Reverse);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const e=p.slice().reverse();return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Kj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST,version:"1.0.0",description:"List delete last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.DeleteLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const e=p.slice(0,-1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class kj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST,version:"1.0.0",description:"List delete first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.DeleteFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const e=p.slice(1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class qj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_INDEX,version:"1.0.0",description:"List add index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.AddIndex);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};if(e<0||e>p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const v=[...p.slice(0,e),y,...p.slice(e)];return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Zj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_INDEX,version:"1.0.0",description:"List replace index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.ReplaceIndex);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};if(e<0||e>=p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const v=[...p];return v[e]=y,{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Hj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST,version:"1.0.0",description:"List replace first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.ReplaceFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(w=>{var A,$;return((A=w.value)==null?void 0:A.valueAsType)||(($=w.value)==null?void 0:$.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const v=p.indexOf(e);if(v===-1)return{value:Z.Success,error:null,results:[p]};const E=[...p];return E[v]=y,{value:Z.Success,error:null,results:[E]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Jj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST,version:"1.0.0",description:"List replace last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.ReplaceLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(w=>{var A,$;return((A=w.value)==null?void 0:A.valueAsType)||(($=w.value)==null?void 0:$.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const v=p.lastIndexOf(e);if(v===-1)return{value:Z.Success,error:null,results:[p]};const E=[...p];return E[v]=y,{value:Z.Success,error:null,results:[E]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Wj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM,version:"1.0.0",description:"List get index item operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.GetIndexItem);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};if(e<0||e>=p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const y=p[e];return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Yj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST,version:"1.0.0",description:"List get first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.GetFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const e=p[0];return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class zj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST,version:"1.0.0",description:"List get last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.GetLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const e=p[p.length-1];return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Xj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND,version:"1.0.0",description:"List append operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.Append);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const y=[...p,e];return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Qj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND,version:"1.0.0",description:"List prepend operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.Prepend);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const y=[e,...p];return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class e3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_PARALLEL,version:"1.0.0",description:"Execution parallel operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(tr.Parallel);o&&(o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(A=>{var $,V;return(($=A.value)==null?void 0:$.valueAsType)||((V=A.value)==null?void 0:V.value)})[0];if(!p)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list of action entities provided",results:[]};if(!Array.isArray(p))return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Invalid input value. Expected a list of action entities",results:[]};const y=this.extensionsRegistry.requestContexts(this,[be.Editor])[0],E=p.map(A=>{const $=new mn(y.logic,[A],A,null,this.extensionsRegistry);return $.inheritValuesFromContext(y),$}).map(A=>A.execute()),w=await Promise.all(E);return{value:Z.Success,error:null,results:[w]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class t3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_SEQUENTIAL,version:"1.0.0",description:"Execution sequential operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(tr.Sequential);o&&(o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list of action entities provided",results:[]};if(!Array.isArray(p))return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Invalid input value. Expected a list of action entities",results:[]};const e=[];for(let y=0;y<p.length;y++){const v=p[y],w=this.extensionsRegistry.requestContexts(this,[be.Editor])[0],A=new mn(w.logic,[v],v,null,this.extensionsRegistry);A.inheritValuesFromContext(w);const $=await A.execute();e.push($)}return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class r3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT,version:"1.0.0",description:"Execution wait operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(tr.Wait);o&&(o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(e=>{var y,v;return((y=e.value)==null?void 0:y.valueAsType)||((v=e.value)==null?void 0:v.value)})[0];return typeof p!="number"||p<0?{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Invalid wait time provided",results:[]}:(await new Promise(e=>setTimeout(e,p)),{value:Z.Success,error:null,results:[]})}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class i3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CREATE_NEW_INSTANCE,version:"1.0.0",description:"Entity create new instance operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(pr.CreateNewInstance);o&&(o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(w=>{var A,$;return((A=w.value)==null?void 0:A.valueAsType)||(($=w.value)==null?void 0:$.value)}),p=o[0];if(!p)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No entity template provided",results:[]};if(!(p instanceof Qn))return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Invalid entity template value provided",results:[]};const e=o[1]||{},v=Vi(p).map(w=>w.name);let E=e;if(v.includes(Le.PERSISTED_ENTITY)){const w=p.properties.find($=>{var V;return((V=$.implements)==null?void 0:V.id)===he["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id});if(!w)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No database property found in entity",results:[]};if(!w.getDefaultValue())return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Database property has no database as entity as default value",results:[]}}return{value:Z.Success,error:null,results:[E]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class s3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY,version:"1.0.0",description:"Entity validate operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(pr.Validate);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)});Me.log("Inputs for entity validation: ",o);const e=rT(o[1]).safeParse(o[0]);return e.success?{value:Z.Success,error:null,results:[o[0]]}:{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:e.error.errors,results:[]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class n3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST,version:"1.0.0",description:"HTTP request operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(yi.HttpRequest);o&&(o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[3]||{},e={method:o[0],url:o[1],params:o[2],headers:p,data:o[4]};Me.log("Axios request config: ",e);const y=await jme(e);return{value:Z.Success,error:null,results:[y.status,y.headers,y.data]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class YI extends NI{constructor(u,r,a=r.projectId){super(u,be.Editor),this._editor=r,this.id=a}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 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 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(u){this._editor.undoableStackValueIndex=u}get PROJECT_NOTIFICATIONS_CHANNEL(){return this._editor.PROJECT_NOTIFICATIONS_CHANNEL}getAccessToken(){return this._editor.getAccessToken()}removeValueByOwnerId(u){return this._editor.removeValueByOwnerId(u)}removeValue(u){return this._editor.removeValue(u)}undo(){return this._editor.undo()}redo(){return this._editor.redo()}initTest(u,r){return this._editor.initTest(u,r)}removeTest(){return this._editor.removeTest()}async copyEntities(u){return this._editor.copyEntities(u)}resolveInitialChildrenPositions(u,r,a){return this._editor.resolveInitialChildrenPositions(u,r,a)}publish(){return this._editor.publish()}loadActivePublication(u){return this._editor.loadActivePublication(u)}requestActiveDynamicValue(u){return this._editor.requestActiveDynamicValue(u)}}function Gme(d,u){return u instanceof YI?u:new YI(d,u)}function Fme(d){d.register(new mx(d)),d.register(new yx(d)),d.register(new cx(d)),d.register(new fx(d)),d.register(new hx(d)),d.register(new px(d)),d.register(new sj(d)),d.register(new nj(d)),d.register(new aj(d)),d.register(new lj(d)),d.register(new oj(d)),d.register(new dj(d)),d.register(new uj(d)),d.register(new cj(d)),d.register(new pj(d)),d.register(new fj(d)),d.register(new hj(d)),d.register(new yj(d)),d.register(new mj(d)),d.register(new vj(d)),d.register(new Ej(d)),d.register(new Tj(d)),d.register(new Ij(d)),d.register(new Aj(d)),d.register(new bj(d)),d.register(new wj(d)),d.register(new Rj(d)),d.register(new gj(d)),d.register(new _j(d)),d.register(new Dj(d)),d.register(new Oj(d)),d.register(new Cj(d)),d.register(new $j(d)),d.register(new Pj(d)),d.register(new Nj(d)),d.register(new Vj(d)),d.register(new Lj(d)),d.register(new Mj(d)),d.register(new Bj(d)),d.register(new Uj(d)),d.register(new xj(d)),d.register(new jj(d)),d.register(new Gj(d)),d.register(new Fj(d)),d.register(new Sj(d)),d.register(new Kj(d)),d.register(new kj(d)),d.register(new qj(d)),d.register(new Zj(d)),d.register(new Hj(d)),d.register(new Jj(d)),d.register(new Wj(d)),d.register(new Yj(d)),d.register(new zj(d)),d.register(new Xj(d)),d.register(new Qj(d)),d.register(new e3(d)),d.register(new t3(d)),d.register(new r3(d)),d.register(new i3(d)),d.register(new s3(d)),d.register(new n3(d))}class a3{constructor(u=new gc){_(this,"extensionsRegistry",new Map);_(this,"initialized",new Set);_(this,"initializedContexts",new Set);_(this,"onResolveEditorContextCallback",()=>null);_(this,"onResolveProjectLogicContextCallback",()=>null);_(this,"onResolveGUIContextCallback",()=>null);_(this,"onResolveCompileContextCallback",()=>null);this.events=u,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(u){this.onResolveEditorContextCallback=u}onResolveProjectLogicContext(u){this.onResolveProjectLogicContextCallback=u}onResolveGUIContext(u){this.onResolveGUIContextCallback=u}onResolveCompileContext(u){this.onResolveCompileContextCallback=u}get extensionInOrder(){return Array.from(this.extensionsRegistry.values()).sort((u,r)=>(u.manifest.initPriority||We.Normal)-(r.manifest.initPriority||We.Normal))}async setup(){Fme(this),Me.log("Initializing extensions without context..."),this.initForReady()}requestContext(u){switch(u){case be.Editor:return this.onResolveEditorContextCallback();case be.Logic:return this.onResolveProjectLogicContextCallback();case be.GUI:return this.onResolveGUIContextCallback();case be.Compile:return this.onResolveCompileContextCallback();default:throw new Error(`Unknown context type: ${u}`)}}requestContexts(u,r=[]){const a=[];r.length===0&&(r=u.manifest.contexts);for(const o of r){const p=this.requestContext(o);p&&a.push(p)}return a}requestModule(u){const r=this.extensionsRegistry.get(u);if(r){if(r.module)return r.module;throw new Error(`Module ${u} is not registered properly.`)}throw new Error(`Unknown module: ${u}`)}register(u){this.extensionsRegistry.set(u.manifest.id,u)}async initAll(){var u,r;for(const a of this.extensionInOrder)if(a.module.init&&!this.initialized.has(a.manifest.id)){const o=a.manifest.contexts.map(p=>this.requestContext(p)).filter(p=>p!==null);o.length&&(await((r=(u=a.module).init)==null?void 0:r.call(u,o)),this.initialized.add(a.manifest.id))}else!a.module.init&&!this.initialized.has(a.manifest.id)&&this.initialized.add(a.manifest.id)}async initForReady(){Me.log("Initializing extensions for ready contexts...");for(const u of this.extensionInOrder)if(u.module.init&&!this.initialized.has(u.manifest.id)){Me.log("Initializing "+u.manifest.id+" extension...");const r=this.requestContexts(u);u.manifest.contexts.every(o=>!!r.find(p=>p.contextType===o))?(await u.module.init(r),this.initialized.add(u.manifest.id)):Me.warn(`Skipping initialization of ${u.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${u.manifest.contexts.join(", ")}`,`Available contexts: ${r.map(o=>o.contextType).join(", ")}`)}else!u.module.init&&!this.initialized.has(u.manifest.id)?(Me.log("Set "+u.manifest.id+" extension as initialized by default..."),this.initialized.add(u.manifest.id)):Me.log(`Skipping initialization of ${u.manifest.id} extension, already initialized or no init method defined.`)}async destroyAll(){for(const u of[...this.extensionInOrder].reverse())u.module.destroy&&await u.module.destroy();this.events.destroy()}on(u,r){this.events.on(u,r)}emit(u,...r){this.events.emit(u,...r)}off(u,r){this.events.off(u,r)}emitAsync(u,...r){return this.events.emitAsync(u,...r)}emitAsyncAll(u,...r){return this.events.emitAsyncAll(u,...r)}emitAsyncAllSettled(u,...r){return this.events.emitAsyncAllSettled(u,...r)}emitAsyncSequentially(u,...r){return this.events.emitAsyncSequentially(u,...r)}emitAsyncSequentiallyAll(u,...r){return this.events.emitAsyncSequentiallyAll(u,...r)}emitAsyncSequentiallyAllSettled(u,...r){return this.events.emitAsyncSequentiallyAllSettled(u,...r)}async contextAvailable(u){if(this.initializedContexts.has(u)){Me.warn(`Context ${u} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(u),u){case be.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case be.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}Me.log(`Context ${u} is now available. Initializing extensions for this context...`),await this.initForReady()}}let Oy=null;const zI={requestModule:d=>(Oy||(Oy=new a3,Oy.setup()),Oy.requestModule(d))},no={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var XI=(d=>(d.FinishedSuccess="finished-success",d.FinishedError="finished-error",d.Running="running",d.Paused="paused",d.Stopped="stopped",d.NotStarted="not-started",d))(XI||{});const o3={...zI};class mn extends gc{constructor(r,a,o,p=null,e=o3){super();_(this,"project");_(this,"entryPoint");_(this,"state","not-started");_(this,"events",new gc);_(this,"entities",[]);_(this,"parentExecution",null);_(this,"executing",[]);_(this,"executed",[]);_(this,"skipped",[]);_(this,"scheduled",[]);_(this,"localTestValues");_(this,"resolvedValues");_(this,"persistedExecutionResults");_(this,"lastExecutionResults");_(this,"onAddToSkippedListCallback",null);_(this,"onRemoveFromSkippedListCallback",null);_(this,"onAddEntityCallback",null);_(this,"onRemoveEntityCallback",null);_(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=a,this.entryPoint=o,this.project=r,this.parentExecution=p,this.localTestValues=new vc(N.UUID.uuid(),this.project),this.resolvedValues=new vc(N.UUID.uuid(),this.project),this.persistedExecutionResults=new vc(N.UUID.uuid(),this.project),this.lastExecutionResults=new vc(N.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults}}skip(r){this.hasEntity(r)&&(this.removeFromScheduledList(r),!this.skipped.includes(r)&&(this.skipped.push(r),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(r),wi.includes(r.type)&&dt(r).forEach(a=>this.skip(a))))}async schedule(r,a,o){if(this.hasExecuted(r))return null;if(Dt.includes(r.type))return this.executeBranch(r,o,a);if(xi.includes(r.type)){if(r.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(r,o,a);this.scheduled.includes(r)||this.scheduled.push(r)}return null}mergeExernalValuesWithInternalInputs(r,a){const o=[];return[...sr,...Dt].includes(a.type)?o.push(...a.inputs):hr.includes(a.type)&&o.push(...a.outputs),o.map(e=>{var v;let y=r.find(E=>E.valueOwner.id===e.id);if(y)return y;if(!y&&Dt.includes(a.type)&&(y=r.find(E=>{var w;return((w=E.valueOwner.declaration)==null?void 0:w.id)===e.id})),y){const E=(v=y.value)==null?void 0:v.clone(null);return E==null||E.setStandaloneParent(e),{...y,valueOwner:e,value:E||null,inheritanceLink:{sources:[y],target:e}}}return un.includes(e.type)?py(e,this.valueResolutionContext):ll(e,this.valueResolutionContext)}).reduce((e,y)=>{const v=fn(y==null?void 0:y.valueOwner,this.project),E=y?[y]:[];return v.forEach(w=>{var V,B,F;if(w.id===(y==null?void 0:y.valueOwner.id))return;const A=lt(w.getDataType(null),w,this.project);A==null||A.metaSync({value:(V=y==null?void 0:y.value)==null?void 0:V.value},null),A==null||A.setValueAsTypeList(((B=y==null?void 0:y.value)==null?void 0:B.valueAsTypeList)||null),A==null||A.setValueAsTypeSingle(((F=y==null?void 0:y.value)==null?void 0:F.valueAsTypeSingle)||null);const $={...y,valueOwner:w,value:A};E.push($)}),[...e,...E]},[]).sort((e,y)=>e.valueOwner.index-y.valueOwner.index)}inheritValuesFromContext(r){this.localTestValues=r.localTestValues,this.resolvedValues=r.resolvedValues,this.persistedExecutionResults=r.persistedExecutionResults}async executeInternalCall(r,a,o,p={}){var y,v;const e={...no,...p};try{let E={value:Z.Success,error:null,results:[]};if(a.sort((w,A)=>w.valueOwner.index-A.valueOwner.index),Object.values(Wr).includes(r.declaration.id)){const w=this.parentContext.requestModule(Cd+r.declaration.id).main;w?E=await w(r,a):Me.warn(`No implementation found for built-in function: ${r.declaration.id}`)}else{debugger;E=await this.executeDetachedFullFunctionDeclarationLogic(r.declaration,a,o,e);debugger;const w=r.outputs.map($=>{var q,ie,W,de;const V=[...$.declaration.getCounterparts(),$.declaration],B=E.results.find(Q=>V.some(X=>Q.valueOwner.id===(X==null?void 0:X.id))),F=$==null?void 0:$.getDataType(null),K=lt(F,$,o);return F!=null&&F.asType?Array.isArray((q=B==null?void 0:B.value)==null?void 0:q.valueAsType)?K==null||K.setValueAsTypeList((ie=B==null?void 0:B.value)==null?void 0:ie.valueAsTypeList):K==null||K.setValueAsTypeSingle(((W=B==null?void 0:B.value)==null?void 0:W.valueAsType)||null):K==null||K.metaSync({value:(de=B==null?void 0:B.value)==null?void 0:de.value},null),{valueOwner:$,type:Ae.ExecutionResult,inheritanceLink:null,value:K}});let A=null;debugger;if(E.error){Me.warn("Raw error executing entity: ",E.error);const $=(y=r.error)==null?void 0:y.getDataType(null),V=lt($||null,r.error,o);$!=null&&$.asType?V==null||V.setValueAsTypeSingle(E.error):V==null||V.metaSync({value:E.error},null),A={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:V}}return{value:E.value,entity:r,error:A,results:w}}return{...E,entity:r}}catch(E){Me.warn("Internal call execution error: ",E);let w=null;if(r.error){const A=(v=r.error)==null?void 0:v.getDataType(null),$=lt(A,r.error,o);A!=null&&A.asType?$==null||$.setValueAsTypeSingle(E):$==null||$.metaSync({value:E},null),w={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:$}}return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:w,results:[]}}}static async executeOperation(r,a,o){var p,e;try{let y={value:Z.Success,error:null,results:[]};if(a.sort((w,A)=>w.valueOwner.index-A.valueOwner.index),r.declaration.implementation&&(y=await r.declaration.implementation(r,a),r.id==="6ccf056e-d850-46bc-b803-778ef9841363"))debugger;const v=r.outputs.map((w,A)=>{const $=w==null?void 0:w.getDataType(null),V=lt($,w,o);return $!=null&&$.asType?V==null||V.setValueAsTypeSingle(y.results[A]):V==null||V.metaSync({value:y.results[A]},null),{valueOwner:w,type:Ae.ExecutionResult,inheritanceLink:null,value:V}});let E=null;if(y.error&&r.error){Me.warn("Raw error executing entity: ",y.error);const w=((p=r.error)==null?void 0:p.getDataType(null))||null,A=lt(w,r.error,o);w!=null&&w.asType?A==null||A.setValueAsTypeSingle(y.error):A==null||A.metaSync({value:y.error},null),E={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:A}}if(r.id==="6ccf056e-d850-46bc-b803-778ef9841363")debugger;return{value:y.value,entity:r,error:E,results:v}}catch(y){Me.warn("Operation execution error: ",y);let v=null;if(r.error){const E=(e=r.error)==null?void 0:e.getDataType(null),w=lt(E,r.error,o);E!=null&&E.asType?w==null||w.setValueAsTypeSingle(y):w==null||w.metaSync({value:y},null),v={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:w}}return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:v,results:[]}}}async executeSearch(r,a,o){var p;try{let e={value:Z.Success,error:null,results:[]};const y=r.outputs[0];if(!y)return{value:Z.Success,entity:r,error:null,results:[]};let v={value:null,valueOwner:y,type:Ae.ExecutionResult,inheritanceLink:null};const E=await this.parentContext.requestModule(Qe.SEARCH_NODE_IMPLEMENTATION).main(r,a),w=y==null?void 0:y.getDataType(null),A=lt(w,y,o);return A==null||A.metaSync({value:E.data},null),v.value=A,{value:e.value,entity:r,error:null,results:[v]}}catch(e){if(Me.warn(`Search node execution error: ${e}`),!r.error)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:null,results:[]};const y=(p=r.error)==null?void 0:p.getDataType(null),v=lt(y,r.error,o);return v==null||v.metaSync({value:e},null),{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:{valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:v},results:[]}}}async executeLoop(r,a,o,p={}){var y,v;const e={...no,...p};try{let E={value:Z.Success,error:null,results:[]};const w=a.map(K=>{var q,ie;return((q=K==null?void 0:K.value)==null?void 0:q.valueAsType)||((ie=K==null?void 0:K.value)==null?void 0:ie.value)});let A={};r.getUniqueReturnDeclarations().forEach(K=>{const q=r.body.inputs.find(Q=>Y(Q,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(K)),ie=K==null?void 0:K.getDataType(null),W=lt(ie,q,o);ie!=null&&ie.asType?W==null||W.setValueAsTypeList([]):W==null||W.metaSync({value:[]},null),this.lastExecutionResults.writeValue(q,W);const de={value:W,valueOwner:q,type:Ae.ExecutionResult,inheritanceLink:null};A[q.id]=de});let V={value:Z.Success,entity:r.body,error:null,results:[]};switch(r.declaration.id){case he.loop["counted-loop"].id:{const K=w[0];let q=1;for(;q<=K&&q<=50;){const ie=r.body.inputs.map(de=>{if(de===r.currentIterationNumberArgumentDeclaration){const Q=r.currentIterationNumberArgumentDeclaration.getDataType(null),ce=vl(Q),X=this.lastExecutionResults.readValue(de.id);if(X){X.metaSync({value:q},null),this.lastExecutionResults.writeValue(de,X);const ue={value:X,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null};return A[de.id]=ue,ue}const z={id:N.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:q,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:de.toReference()},pe=dr(z,o);this.lastExecutionResults.writeValue(de,pe);const te={value:pe,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null};return A[de.id]=te,te}else return A[de.id]}).filter(de=>!!de),W=await this.executeFullFunctionDeclarationLogic(r.body,ie,e);if(V=W,V.results.forEach(de=>{var z,pe,te,ue;if(de.valueOwner.type!==f.ReturnDeclaration)return;const Q=r.body.inputs.find(Ie=>Y(Ie,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(de.valueOwner)),X=[...((pe=(z=A==null?void 0:A[Q.id])==null?void 0:z.value)==null?void 0:pe.value)||[],((te=de==null?void 0:de.value)==null?void 0:te.value)||null];(ue=A[Q.id].value)==null||ue.metaSync({value:X},null),this.lastExecutionResults.writeValue(Q,A[Q.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(W.value))break;q++}break}case he.loop["manual-flow-loop"].id:{let K=1;for(;K<=50;){const q=r.body.inputs.map(W=>{if(W===r.currentIterationNumberArgumentDeclaration){const de=this.lastExecutionResults.readValue(W.id);if(de){de.metaSync({value:K},null),this.lastExecutionResults.writeValue(W,de);const z={value:de,valueOwner:W,type:Ae.ExecutionResult,inheritanceLink:null};return A[W.id]=z,z}const Q=r.currentIterationNumberArgumentDeclaration.getDataType(null),ce=lt(Q,W,o);return ce==null||ce.metaSync({value:K},null),this.lastExecutionResults.writeValue(W,ce),{value:ce,valueOwner:W,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[W.id]}).filter(W=>!!W),ie=await this.executeFullFunctionDeclarationLogic(r.body,q,e);if(V=ie,V.results.forEach(W=>{var X,z,pe;if(W.valueOwner.type!==f.ReturnDeclaration)return;const de=r.body.inputs.find(te=>Y(te,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(W.valueOwner)),ce=[...(X=A[de.id].value)==null?void 0:X.value,((z=W.value)==null?void 0:z.value)||null];(pe=A[de.id].value)==null||pe.metaSync({value:ce},null),this.lastExecutionResults.writeValue(de,A[de.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(ie.value))break;K++}break}case he.loop["list-loop"].id:{const K=w[0];let q=1;const ie=K;for(let W=0;W<ie.length;W++){const de=ie[W],Q=r.body.inputs.map(X=>{if(X===r.currentIterationNumberArgumentDeclaration){const z=this.lastExecutionResults.readValue(X.id);if(z)return z.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,z),{value:z,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const pe=r.currentIterationNumberArgumentDeclaration.getDataType(null),te=lt(pe,X,o);return te==null||te.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(X===r.currentValueArgumentDeclaration){const z=r.currentValueArgumentDeclaration.getDataType(null),pe=vl(z),te=this.lastExecutionResults.readValue(X.id);if(te)return te.metaSync({value:de},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const ue={id:N.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:pe,standaloneParent:X.toReference()},Ie=dr(ue,o);return this.lastExecutionResults.writeValue(X,Ie),{value:Ie,valueOwner:r.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[X.id]}).filter(X=>!!X),ce=await this.executeFullFunctionDeclarationLogic(r.body,Q,e);if(V=ce,V.results.forEach(X=>{var ue,Ie,Ue;if(X.valueOwner.type!==f.ReturnDeclaration)return;const z=r.body.inputs.find(Pe=>Y(Pe,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(X.valueOwner)),te=[...(ue=A[z.id].value)==null?void 0:ue.value,((Ie=X.value)==null?void 0:Ie.value)||null];(Ue=A[z.id].value)==null||Ue.metaSync({value:te},null),this.lastExecutionResults.writeValue(z,A[z.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(ce.value))break;q++}break}case he.loop["object-keys-loop"].id:{const K=w[0];let q=1;const ie=K?Object.keys(K):[];for(let W=0;W<ie.length;W++){const de=ie[W],Q=r.body.inputs.map(X=>{if(X===r.currentIterationNumberArgumentDeclaration){const z=this.lastExecutionResults.readValue(X.id);if(z)return z.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,z),{value:z,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const pe=r.currentIterationNumberArgumentDeclaration.getDataType(null),te=lt(pe,X,o);return te==null||te.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(X===r.currentValueArgumentDeclaration){const z=r.currentValueArgumentDeclaration.getDataType(null),pe=vl(z),te=this.lastExecutionResults.readValue(X.id);if(te)return te.metaSync({value:de},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const ue={id:N.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:pe,standaloneParent:X.toReference()},Ie=dr(ue,o);return this.lastExecutionResults.writeValue(X,Ie),{value:Ie,valueOwner:r.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[X.id]}).filter(X=>!!X),ce=await this.executeFullFunctionDeclarationLogic(r.body,Q,e);if(V=ce,V.results.forEach(X=>{var ue,Ie,Ue;if(X.valueOwner.type!==f.ReturnDeclaration)return;const z=r.body.inputs.find(Pe=>Y(Pe,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(X.valueOwner)),te=[...(ue=A[z.id].value)==null?void 0:ue.value,((Ie=X.value)==null?void 0:Ie.value)||null];(Ue=A[z.id].value)==null||Ue.metaSync({value:te},null),this.lastExecutionResults.writeValue(z,A[z.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(ce.value))break;q++}break}case he.loop["object-values-loop"].id:{const K=w[0];let q=1;const ie=K?Object.values(K):[];for(let W=0;W<ie.length;W++){const de=ie[W],Q=r.body.inputs.map(X=>{if(X===r.currentIterationNumberArgumentDeclaration){const z=this.lastExecutionResults.readValue(X.id);if(z)return z.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,z),{value:z,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const pe=r.currentIterationNumberArgumentDeclaration.getDataType(null),te=lt(pe,X,o);return te==null||te.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(X===r.currentValueArgumentDeclaration){const z=r.currentValueArgumentDeclaration.getDataType(null),pe=vl(z),te=this.lastExecutionResults.readValue(X.id);if(te)return te.metaSync({value:de},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const ue={id:N.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:pe,standaloneParent:X.toReference()},Ie=dr(ue,o);return this.lastExecutionResults.writeValue(X,Ie),{value:Ie,valueOwner:r.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[X.id]}).filter(X=>!!X),ce=await this.executeFullFunctionDeclarationLogic(r.body,Q,e);if(V=ce,V.results.forEach(X=>{var ue,Ie,Ue;if(X.valueOwner.type!==f.ReturnDeclaration)return;const z=r.body.inputs.find(Pe=>Y(Pe,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(X.valueOwner)),te=[...(ue=A[z.id].value)==null?void 0:ue.value,((Ie=X.value)==null?void 0:Ie.value)||null];(Ue=A[z.id].value)==null||Ue.metaSync({value:te},null),this.lastExecutionResults.writeValue(z,A[z.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(ce.value))break;q++}break}case he.loop["string-loop"].id:{const K=w[0];let q=1;const ie=K.split("");for(let W=0;W<ie.length;W++){const de=ie[W],Q=r.body.inputs.map(X=>{if(X===r.currentIterationNumberArgumentDeclaration){const z=this.lastExecutionResults.readValue(X.id);if(z)return z.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,z),{value:z,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const pe=r.currentIterationNumberArgumentDeclaration.getDataType(null),te=lt(pe,X,o);return te==null||te.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(X===r.currentValueArgumentDeclaration){const z=r.currentValueArgumentDeclaration.getDataType(null),pe=vl(z),te=this.lastExecutionResults.readValue(X.id);if(te)return te.metaSync({value:de},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const ue={id:N.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:pe,standaloneParent:X.toReference()},Ie=dr(ue,o);return this.lastExecutionResults.writeValue(X,Ie),{value:Ie,valueOwner:r.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[X.id]}).filter(X=>!!X),ce=await this.executeFullFunctionDeclarationLogic(r.body,Q,e);if(V=ce,V.results.forEach(X=>{var ue,Ie,Ue;if(X.valueOwner.type!==f.ReturnDeclaration)return;const z=r.body.inputs.find(Pe=>Y(Pe,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(X.valueOwner)),te=[...(ue=A[z.id].value)==null?void 0:ue.value,((Ie=X.value)==null?void 0:Ie.value)||null];(Ue=A[z.id].value)==null||Ue.metaSync({value:te},null),this.lastExecutionResults.writeValue(z,A[z.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(ce.value))break;q++}break}}let B=[];r.body.inputs.forEach(K=>{var ie;const q=A[K.id];if(q){const W=(ie=q.value)==null?void 0:ie.clone(null),de=r.outputs.find(Q=>Q.declaration&&Gi.fromLoopOutputDeclarationToBodyArgumentDeclarationName(Q.declaration)===Y(K,o));if(!de)return;B.push({valueOwner:de,type:Ae.ExecutionResult,inheritanceLink:null,value:W})}}),E={value:[Z.CaughtError,Z.Return].includes(V.value)?V.value:Z.Success,error:null,results:B};let F=null;if(E.error&&r.error){Me.warn("Raw error executing entity: ",E.error);const K=(y=r.error)==null?void 0:y.getDataType(null),q=lt(K||null,r.error,o);K!=null&&K.asType?q==null||q.setValueAsTypeSingle(E.error):q==null||q.metaSync({value:E.error},null),F={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:q}}return{value:E.value,entity:r,error:F,results:E.results}}catch(E){if(Me.warn("Error executing loop: ",E),r.error){const w=(v=r.error)==null?void 0:v.getDataType(null),A=lt(w,r.error,o);return w!=null&&w.asType?A==null||A.setValueAsTypeSingle(E):A==null||A.metaSync({value:E},null),{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:{valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:A},results:[]}}else return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:null,results:[]}}}async executeFunctionCall(r,a,o,p={}){var y,v;const e={...no,...p};try{let E={value:Z.Success,error:null,results:[]};E=await this.executeDetachedFullFunctionDeclarationLogic(r.declaration,a,o,e);const w=r.outputs.map($=>{var q,ie,W,de;const V=[...$.declaration.getCounterparts(),$.declaration],B=E.results.find(Q=>V.some(X=>Q.valueOwner.id===(X==null?void 0:X.id))),F=$==null?void 0:$.getDataType(null),K=lt(F,$,o);return F!=null&&F.asType?Array.isArray((q=B==null?void 0:B.value)==null?void 0:q.valueAsType)?K==null||K.setValueAsTypeList((ie=B==null?void 0:B.value)==null?void 0:ie.valueAsTypeList):K==null||K.setValueAsTypeSingle(((W=B==null?void 0:B.value)==null?void 0:W.valueAsType)||null):K==null||K.metaSync({value:(de=B==null?void 0:B.value)==null?void 0:de.value},null),{valueOwner:$,type:Ae.ExecutionResult,inheritanceLink:null,value:K}});let A=null;if(E.error&&r.error){Me.warn("Raw error executing entity: ",E.error);const $=(y=r.error)==null?void 0:y.getDataType(null),V=lt($||null,r.error,o);$!=null&&$.asType?V==null||V.setValueAsTypeSingle(E.error):V==null||V.metaSync({value:E.error},null),A={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:V}}return{value:E.value,entity:r,error:A,results:w}}catch(E){if(!r.error)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:null,results:[]};const w=(v=r.error)==null?void 0:v.getDataType(null),A=lt(w,r.error,o);return w!=null&&w.asType?A==null||A.setValueAsTypeSingle(E):A==null||A.metaSync({value:E},null),{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:{valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:A},results:[]}}}async executeCondition(r,a){var p,e,y,v,E,w,A,$,V,B,F,K,q,ie,W,de,Q,ce,X,z,pe,te,ue,Ie,Ue,Pe,ge,$e,qe,xe,ot,Rt,ur,Ar,Mr,Xr,ci,Es,Bs,wn,Us,pi,Ts,Rn,ra,lf,wl,df;let o=!1;switch(r.declaration.id){case oi.Empty:{o=!((e=(p=a[0])==null?void 0:p.value)!=null&&e.value);break}case oi.NotEmpty:{o=!!((v=(y=a[0])==null?void 0:y.value)!=null&&v.value);break}case ut.Equal:{if([oe.String,oe.Number,oe.Boolean,oe.Null,oe.Enum,oe.Date,oe.UUID].includes((w=(E=a[0])==null?void 0:E.value)==null?void 0:w.name)){o=(($=(A=a[0])==null?void 0:A.value)==null?void 0:$.value)===((B=(V=a[1])==null?void 0:V.value)==null?void 0:B.value);break}if(((K=(F=a[0])==null?void 0:F.value)==null?void 0:K.name)===oe.KeyValue||((ie=(q=a[0])==null?void 0:q.value)==null?void 0:ie.name)===oe.Untyped){const ia=(de=(W=a[0])==null?void 0:W.value)==null?void 0:de.value,fi=(ce=(Q=a[1])==null?void 0:Q.value)==null?void 0:ce.value;o=JSON.stringify(ia)===JSON.stringify(fi);break}break}case ut.NotEqual:{if([oe.String,oe.Number,oe.Boolean,oe.Null,oe.Enum,oe.Date,oe.UUID].includes((z=(X=a[0])==null?void 0:X.value)==null?void 0:z.name)){o=((te=(pe=a[0])==null?void 0:pe.value)==null?void 0:te.value)!==((Ie=(ue=a[1])==null?void 0:ue.value)==null?void 0:Ie.value);break}if(((Pe=(Ue=a[0])==null?void 0:Ue.value)==null?void 0:Pe.name)===oe.Untyped||(($e=(ge=a[0])==null?void 0:ge.value)==null?void 0:$e.name)===oe.KeyValue){const ia=(xe=(qe=a[0])==null?void 0:qe.value)==null?void 0:xe.value,fi=(Rt=(ot=a[1])==null?void 0:ot.value)==null?void 0:Rt.value;o=JSON.stringify(ia)!==JSON.stringify(fi);break}break}case ut.MoreThanOrEqual:{o=((Ar=(ur=a[0])==null?void 0:ur.value)==null?void 0:Ar.value)>=((Xr=(Mr=a[1])==null?void 0:Mr.value)==null?void 0:Xr.value);break}case ut.MoreThan:{o=((Es=(ci=a[0])==null?void 0:ci.value)==null?void 0:Es.value)>((wn=(Bs=a[1])==null?void 0:Bs.value)==null?void 0:wn.value);break}case ut.LessThanOrEqual:{o=((pi=(Us=a[0])==null?void 0:Us.value)==null?void 0:pi.value)<=((Rn=(Ts=a[1])==null?void 0:Ts.value)==null?void 0:Rn.value);break}case ut.LessThan:{o=((lf=(ra=a[0])==null?void 0:ra.value)==null?void 0:lf.value)<((df=(wl=a[1])==null?void 0:wl.value)==null?void 0:df.value);break}case Kr.And:{o=(await Promise.all(r.andChildrenGroup.map(async fi=>{const zd=this.mergeExernalValuesWithInternalInputs(a,fi);return(await this.executeCondition(fi,zd)).value===Z.Success}))).every(fi=>fi);break}case Kr.Or:{o=(await Promise.all(r.orChildrenGroup.map(async fi=>{const zd=this.mergeExernalValuesWithInternalInputs(a,fi);return(await this.executeCondition(fi,zd)).value===Z.Success}))).some(fi=>fi);break}}return{value:o?Z.Success:Z.CaughtError,entity:r,error:null,results:[]}}async executeDetachedFullFunctionDeclarationLogic(r,a,o,p={}){const e={...no,...p,onBeforeEntityExecution:(E,w,A)=>{var $;return(($=p==null?void 0:p.onBeforeEntityExecution)==null?void 0:$.call(p,E,w,{...A,detached:!0}))||Promise.resolve()},onEntityExecuted:(E,w,A)=>{var $;return(($=p==null?void 0:p.onEntityExecuted)==null?void 0:$.call(p,E,w,{...A,detached:!0}))||Promise.resolve()}},y=new mn(o,[r,...Dm(r)],r,this,this.parentContext);return y.inheritValuesFromContext(this),await y.execute(e,a)}async executeFullFunctionDeclarationLogic(r,a,o={}){const p={...no,...o},e=Dm(r);e.forEach(A=>{this.addEntity(A)}),e.reduce((A,$)=>hr.includes($.type)?[...A,...$.outputs]:sr.includes($.type)&&$.type!==f.Condition?[...A,...$.outputs,...$.inputs]:$.type===f.Condition?[...A,...$.inputs]:A,[]).forEach(A=>{this.lastExecutionResults.removeValue(A.id)});const v=await this.executeBranch(r,p,a),w=r.getUniqueReturnDeclarations().reduce((A,$)=>{const V=v==null?void 0:v.results.find(B=>B.valueOwner.id===$.id);return V?[...A,V]:A},[]);return{...v||{},value:(v==null?void 0:v.value)||Z.Success,entity:r,error:(v==null?void 0:v.error)||null,results:w}}static async executeEntryPointEntity(r,a){return{value:Z.Success,entity:r,error:null,results:a}}static async executeVariable(r,a){return{value:Z.Success,entity:r,error:null,results:[a]}}static async executeReturnStatement(r,a){return{value:r.throws?Z.CaughtError:Z.Return,entity:r,error:null,results:a}}static async executeContinueStatement(r,a){return{value:Z.Continue,entity:r,error:null,results:a}}static async executeBreakStatement(r,a){return{value:Z.Break,entity:r,error:null,results:a}}mergeValues(r,a){const o=[];for(let p=0;p<a.length;p++)r!=null&&r[p]?o.push(r[p]):o.push(a[p]);return o}async executeEntity(r,a=[],o={}){var y,v,E,w,A,$,V,B,F,K,q,ie,W,de,Q,ce,X;const p={...no,...o},e={detached:!1};switch(r.type){case f.Condition:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((y=p.onBeforeEntityExecution)==null?void 0:y.call(p,r,z,e)),this.executeCondition(r,z)}case f.InternalCall:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((v=p.onBeforeEntityExecution)==null?void 0:v.call(p,r,z,e)),this.executeInternalCall(r,z,this.project)}case f.Operation:{const z=this.mergeExernalValuesWithInternalInputs(a,r);if(r.id==="6ccf056e-d850-46bc-b803-778ef9841363")debugger;return await((E=p.onBeforeEntityExecution)==null?void 0:E.call(p,r,z,e)),mn.executeOperation(r,z,this.project)}case f.VariableInstance:case f.VariableDeclaration:{let z=py(r,this.valueResolutionContext);const pe=Ni(r),te=pe.getDataType(null);if(te!=null&&te.isObject()){let Ue={};if(((w=te==null?void 0:te.entity)==null?void 0:w.type)===f.DefinitionEntity&&(Ue={...Ue,...te.entity.getActiveRawDefaultValue()}),z!=null&&z.value)Tr((A=z==null?void 0:z.value)==null?void 0:A.value)&&(Ue={...Ue,...($=z==null?void 0:z.value)==null?void 0:$.value}),z==null||z.value.metaSync({value:Ue},null);else{const Pe=lt(te,r,this.project);Pe==null||Pe.metaSync({value:Ue},null),z={valueOwner:pe,type:Ae.ExecutionResult,inheritanceLink:null,value:Pe}}this.lastExecutionResults.writeValue(pe,z.value),pe.inputs.forEach(Pe=>{var ge;if(((ge=Pe.declaration)==null?void 0:ge.type)===f.Property&&Pe.declaration.static){const $e=this.lastExecutionResults.readValue(Pe.declaration.id),qe=Y(Pe,this.project),xe=xr(qe);if($e)$e.metaSync({value:Ue[xe]},null),this.lastExecutionResults.writeValue(Pe.declaration,$e);else{const ot=lt(Pe.getDataType(null),Pe,this.project);ot==null||ot.metaSync({value:Ue[xe]},null),this.lastExecutionResults.writeValue(Pe.declaration,ot)}}})}else this.lastExecutionResults.writeValue(pe,z==null?void 0:z.value);const ue=[],Ie=(V=z==null?void 0:z.value)!=null&&V.value&&Tr((B=z.value)==null?void 0:B.value)?((F=z.value)==null?void 0:F.value)||{}:{};return r.outputs.map(Ue=>{const Pe=xr(Y(Ue,this.project)),ge=Ie[Pe],$e=lt(Ue.getDataType(null),Ue,this.project);$e==null||$e.metaSync({value:ge},null);const qe={value:$e,valueOwner:Ue,type:Ae.ExecutionResult,inheritanceLink:z?{sources:[z],target:r}:null};ue.push(qe)}),z.type=Ae.ExecutionResult,{value:Z.Success,entity:r,error:null,results:[z,...ue]}}case f.FunctionCall:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((K=p.onBeforeEntityExecution)==null?void 0:K.call(p,r,z,e)),this.executeFunctionCall(r,z,this.project)}case f.FunctionDeclaration:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((q=p.onBeforeEntityExecution)==null?void 0:q.call(p,r,z,e)),mn.executeEntryPointEntity(r,z)}case f.Search:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((ie=p.onBeforeEntityExecution)==null?void 0:ie.call(p,r,z,e)),this.executeSearch(r,z,this.project)}case f.Loop:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((W=p.onBeforeEntityExecution)==null?void 0:W.call(p,r,z,e)),this.executeLoop(r,z,this.project,p)}case f.ReturnStatement:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((de=p.onBeforeEntityExecution)==null?void 0:de.call(p,r,z,e)),mn.executeReturnStatement(r,z)}case f.ContinueStatement:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((Q=p.onBeforeEntityExecution)==null?void 0:Q.call(p,r,z,e)),mn.executeContinueStatement(r,z)}case f.BreakStatement:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((ce=p.onBeforeEntityExecution)==null?void 0:ce.call(p,r,z,e)),mn.executeBreakStatement(r,z)}case f.GlobalEvent:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((X=p.onBeforeEntityExecution)==null?void 0:X.call(p,r,z,e)),mn.executeEntryPointEntity(r,z)}default:throw new Error(`Entity type ${r==null?void 0:r.type} is not recognized for execution.`)}}storeLastExecutionValues(r){r.error&&r.error.valueOwner&&this.lastExecutionResults.writeValue(r.error.valueOwner,r.error.value),r.results.forEach(a=>{const o=fn(a.valueOwner,this.project);a.value?o.forEach(p=>{this.lastExecutionResults.writeValue(p,a.value)}):o.forEach(p=>{this.lastExecutionResults.removeValue(p.id)})})}async executeBranch(r,a={},o=[]){var E;const p={...no,...a},e={detached:!1};if(!this.hasEntity(r)||this.hasSkipped(r))return null;this.addToExecutingList(r),this.hasScheduled(r)&&this.removeScheduled(r);const v=await this.executeEntity(r,o,p);debugger;if(this.removeFromExecutingList(r),this.addToAlreadyExecutedList(r),this.storeLastExecutionValues(v),await((E=p.onEntityExecuted)==null?void 0:E.call(p,r,v,e)),v.value===Z.Success){const w=(r.successCalls||r.calls||[]).filter(F=>this.hasEntity(F));(r.errorCalls||[]).forEach(F=>{this.skip(F)});let $=[];const V=(await Promise.all(w.map(F=>this.schedule(F,v.results,p)))).filter(F=>!!F),B=V.filter(F=>!!F).find(F=>F.value===Z.CaughtError||F.value===Z.Return||F.value===Z.Break||F.value===Z.Continue);return B||($=[...$,...V],v)}else if(v.value===Z.CaughtError){const w=(r.errorCalls||[]).filter(F=>this.hasEntity(F));(r.successCalls||r.calls||[]).forEach(F=>{this.skip(F)});let $=[];const V=(await Promise.all(w.map(F=>this.schedule(F,v.results,p)))).filter(F=>!!F),B=V.filter(F=>!!F).find(F=>F.value===Z.CaughtError||F.value===Z.UnhandledError||F.value===Z.Return||F.value===Z.Break||F.value===Z.Continue);return B||($=[...$,...V],v)}else{if(v.value===Z.UnhandledError)return this.executing.forEach(w=>{this.skip(w)}),this.scheduled.forEach(w=>{this.skip(w)}),wi.includes(v.entity.type)&&dt(v.entity).forEach(w=>{this.skip(w)}),v;if(v.value===Z.Return)return v;if(v.value===Z.Break)return v;if(v.value===Z.Continue)return v}return v}async execute(r={},a=[]){const o={...no,...r};this.state="running";const p=await this.executeBranch(this.entryPoint,o,a);return this.state="finished-success",p}addEntity(r){var a;this.entities.includes(r)||(this.entities.push(r),(a=this.onAddEntityCallback)==null||a.call(this,r))}addEntities(r){r.forEach(a=>this.addEntity(a))}removeEntity(r){var a;if(r!==this.entryPoint){const o=this.entities.indexOf(r);o>-1&&(this.entities.splice(o,1),(a=this.onRemoveEntityCallback)==null||a.call(this,r))}}hasEntity(r){var p,e,y;if(this.entities.includes(r))return!0;if(((p=r.parent)==null?void 0:p.type)===f.FunctionDeclaration&&((y=(e=r.parent)==null?void 0:e.parent)==null?void 0:y.type)===f.DefinitionEntity)return this.entities.includes(r.parent);const a=fr(r);if(!a)return!1;const o=a.type===f.Loop&&r.parent===a.body?a.body:null;return o?this.entities.includes(o)||this.entities.includes(a):this.entities.includes(a)}removeScheduled(r){const a=this.scheduled.indexOf(r);a>-1&&this.scheduled.splice(a,1)}hasScheduled(r){return!!this.scheduled.includes(r)}hasSkipped(r){return!!this.skipped.includes(r)}hasExecuted(r){return!!this.executed.includes(r)}hasEntityWithId(r){const a=this.project.get(r);return a?this.hasEntity(a):!1}onAddToSkippedList(r){this.onAddToSkippedListCallback=r}onAbortExecution(r){this.onAbortExecutionCallback=r}onAddEntity(r){this.onAddEntityCallback=r}onRemoveFromSkippedList(r){this.onRemoveFromSkippedListCallback=r}onRemoveEntity(r){this.onRemoveEntityCallback=r}addToExecutingList(r){this.executing.includes(r)||this.executing.push(r)}addToScheduledList(r){this.scheduled.includes(r)||this.scheduled.push(r)}removeFromScheduledList(r){const a=this.scheduled.indexOf(r);a>-1&&this.scheduled.splice(a,1)}removeFromExecutingList(r){var o;const a=this.executing.indexOf(r);a>-1&&(this.executing.splice(a,1),(o=this.onAbortExecutionCallback)==null||o.call(this,r))}removeFromAlreadyExecutedList(r){const a=this.executed.indexOf(r);a>-1&&this.executed.splice(a,1)}removeFromSkippedList(r){var o;const a=this.skipped.indexOf(r);a>-1&&(this.skipped.splice(a,1),(o=this.onRemoveFromSkippedListCallback)==null||o.call(this,r))}addToAlreadyExecutedList(r){this.executed.includes(r)||this.executed.push(r)}addToSkippedList(r){var a;this.skipped.includes(r)||(this.skipped.push(r),(a=this.onAddToSkippedListCallback)==null||a.call(this,r))}}function Sme(d){var u,r;if(d.isList)return"list";if(((u=d.entity)==null?void 0:u.type)===f.DefinitionEntity)return"definition-entity";switch((r=d.entity)==null?void 0:r.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 Vs={[f.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[f.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[f.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[f.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[f.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[f.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[f.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[f.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[f.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[f.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[f.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[f.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[f.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[f.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[f.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[f.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[f.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[f.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[f.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[f.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[f.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[f.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[f.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[f.ReturnDeclaration]:{singular:"Output definition",plural:"Output definitions",shortSingular:"Output",shortPlural:"Outputs"},[f.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"},[f.DataType]:{singular:"Data type",plural:"Data types",shortSingular:"Data type",shortPlural:"Data types"},[f.LiteralValue]:{singular:"Literal value",plural:"Literal values",shortSingular:"Value",shortPlural:"Values"}};function QI(d){const u=Om(d);if(!u){const a=Hd(d);if(a.includes(Le.HTTP_ENDPOINT))return"HTTP endpoint";if(a.includes(Le.PERSISTED_ENTITY))return"Persisted entity";if(a.includes(Le.CRON_JOB))return"Scheduled execution";if(a.includes(Le.RELATIONAL_DATABASE))return"Relational database"}if(u){let a="Extension of "+Y(u,u.project)+" entity",o=Rd(a);const p=Hd(d);return p.includes(Le.HTTP_ENDPOINT)?"HTTP endpoint"+(o?", "+o:""):p.includes(Le.PERSISTED_ENTITY)?"Persisted entity"+(o?", "+o:""):p.includes(Le.CRON_JOB)?"Scheduled execution"+(o?", "+o:""):p.includes(Le.RELATIONAL_DATABASE)?"Relational database"+(o?", "+o:""):a}let r="";return d.abstract&&(r="Template "),d.static&&(r+=r?" single copy ":"Single copy "),r?r+"definition":"Definition"}function l3(d){return d.parent.type===f.DefinitionEntity||d.parent.type===f.InstalledProject?"Internal action of "+Y(d.parent,d.project):d.parent.type===f.Loop?"Action repeated on every iteration":"Internal action of entity"}function eA(d){return Ib(d)?l3(d):"Custom trigger"}function Kme(d){var u;switch(d.type){case f.DefinitionEntity:return QI(d);case f.FunctionDeclaration:return eA(d)}return(u=Vs[d.type])==null?void 0:u.singular}function kme(d){var u;switch(d.type){case f.DefinitionEntity:return QI(d);case f.FunctionDeclaration:return eA(d)}return(u=Vs[d.type])==null?void 0:u.singular}const tA=4e4,d3=280,qme=300,rA=65,Vd=32,Cy=39,u3=26,c3=49,$y=44,Zme=35,Py=52,iA=10,Ca=iA*2,Ny=38,Vy=90,sA=270,p3=tA/2+120,f3=tA/2+180;function h3(d){let r=Vd+$y+Ny+iA;const a=[...d.inputs];return a.length&&(r+=Ca,a.forEach(()=>{r+=u3})),{height:r,width:280}}function y3(d){let r=rA;const a=[];if([f.DefinitionEntity].includes(d.type)){const v=[...d.suggestedProperties||[],...d.properties||[]];v.length&&(r+=Ca,v.forEach(E=>{r+=E.static?c3:Cy}))}if([f.DefinitionEntity,f.InstalledProject,f.Loop].includes(d.type)){const v=[...(d==null?void 0:d.suggestedMethods)||[],...d.methods||[],...d.functions||[],...d.body?[d.body]:[]];v.length&&(r+=Ca,v.forEach(E=>{const w=h3(E);r+=w.height}))}sr.includes(d.type)?(Tt.includes(d.type)?a.push(...(d.usedInputs||[]).flatMap(v=>[v])||[]):a.push(...(d.inputs||[]).flatMap(v=>[v])||[]),d.error&&(r+=Py)):[f.ReturnStatement,f.BreakStatement,f.ContinueStatement].includes(d.type)?(a.push(...d.outputs||[]),d.throws&&(r+=Py)):d.type===f.Condition&&(a.push(d.inputs[0]),d.inputs[1]&&a.push(d.inputs[1]));const o=a.length;o&&(r+=o*Cy,r+=Ca);const p=[];if(d.type===f.FunctionDeclaration||d.type===f.GlobalEvent?p.push(...d.inputs||[]):sr.includes(d.type)&&(Tt.includes(d.type)?p.push(...d.usedOutputs||[]):p.push(...d.outputs||[])),Tt.includes(d.type)){d.readsValue&&(r+=Ca,r+=$y),d.writesValues.length&&(r+=Ca,r+=$y),d.internalCalls.length&&d.usedInternalCalls.forEach(()=>r+=Py+Ca);const v=d.getDataType(null);(!v||v.inferred)&&(r+=Ny)}const e=p.length;return e&&(r+=e*Cy,r+=Ca),[f.DefinitionEntity,f.FunctionDeclaration,f.ReturnStatement,f.BreakStatement,f.ContinueStatement].includes(d.type)&&(r+=Ny),{height:r,width:280}}function Cc(d){return`${d.split("-").map((a,o)=>o===0?a.charAt(0).toUpperCase()+a.slice(1):a.toLowerCase()).join(" ")}.`}function Hme(d){switch(d.code){case re.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case re.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case re.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case re.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case re.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case re.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case re.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case se.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case se.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case re.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case re.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case se.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case re.NoProperties:return"This entity has no properties, so it doesn't do anything";case re.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case re.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case re.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case re.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case re.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case re.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case re.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case re.PropertyImplementsNonAbstact:return"This property implements a non-template property";case re.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case re.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case re.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case re.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case re.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case se.InternalCallDeclarationIsNotFunctionDeclaration:return"This internal call is not an action";case se.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case se.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case se.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case se.UnreachableEntity:return"This entity is unreachable";case re.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";case re.AbstractEntityImplements:return"This template entity implements a non-template entity";case re.AbstractExtendingNonAbstractEntity:return"This template entity extends a non-template entity";case re.InvalidPropertiesCombination:return"This entity has an invalid combination of properties";case re.ExtendingNonInteractiveEntity:return"This entity extends a non-interactive entity";case re.ExtendsIncompatibleEntities:return"This entity extends incompatible entities";case re.ImplementingNonAbstractEntity:return"This entity implements a non-template entity";case re.ImplementsIncompatibleEntities:return"This entity implements incompatible entities";case re.LackingReturnStatementOnSomeBranches:return"This action is missing a termination on some branches";case re.LastCalledEntityMustBeReturnEntity:return"The last called entity in this action must be a termination node";case re.MissingRequiredValue:return"This action is missing a required value";case re.NoPrimaryKeyProperty:return"This entity has no primary key property";case re.NonAbstractExtendingAbstractEntity:return"This non-template entity extends a template entity";case re.NonStaticExtendingStaticEntity:return"This non-static entity extends a static entity";case re.NonStaticImplementingStaticEntity:return"This non-static entity implements a static entity";case re.StaticExtendingNonStaticEntity:return"This static entity extends a non-static entity";case re.StaticImplementingNonStaticEntity:return"This static entity implements a non-static entity";case re.VariableReadsValueAndInternalCall:return"This variable reads a value while being used to execute internal logic";case re.VariableWritesValuesAndInternalCall:return"This variable writes values while being used to execute internal logic";case se.InternalCallDeclarationNotInParentDatatypeEntity:return"This internal call declaration is not in the parent entity";case se.EmptyName:return"This entity has no name";case se.InvalidObjectStructure:return"This entity has an invalid structure";case se.LoopBodyFunctionOverwrite:return"This loop body action overwrites an action in the template entity with the same name";case se.MethodOverwritesBaseMethodWithSameImplementation:return"This action overwrites a base action with the same implementation";case se.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"This action overwrites an action in an extended entity with the same implementation";case se.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"This action overwrites an action in an implemented entity with the same implementation";case se.MissingCaller:return"This action is missing a caller";case se.NameAsResolvedCodeNameNotUniqueInScope:return"This entity has a name that is not unique in the scope of the code it is used in";case se.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"This entity name can only contain letters, numbers, underscores and spaces";case se.NameMustStartWithLetterOrUnderscore:return"This entity name must start with a letter or an underscore";case se.NoOverlapWithImplementedSignature:return"This action does not overlap with the implemented action signature";case se.PropertyOverwritesBasePropertyWithSameImplementation:return"This property overwrites a base property with the same implementation";case se.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an extended entity with the same implementation";case se.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an implemented entity with the same implementation";case se.ReaderWriterIncompatibleDataType:return"This reader/writer has an incompatible data type with the value it is reading/writing";case ta.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case ta.StatusCodeMustBeNumber:return"HTTP status code must be a number, between 100 and 599";case vs.UUIDMustBeString:return`UUID must be a string, eg: "${cl()}"`;case vs.UUIDMustNotContainSpaces:return`UUID must not contain spaces, eg: "${cl()}"`;case vs.UUIDMustBeValidFormat:return`UUID must be in a valid format. Eg: "${cl()}"`;case ki.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case ki.StringValueMustNotHaveDashes:return"This value must not contain dashes";case ki.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return Cc(d.code)}}function Jme(d){switch(d.code){case re.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case re.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case re.IncorrectEntityImplementation:return"Incorrect implementation";case re.IncorrectMethodImplementation:return"Incorrect action implementation";case re.IncorrectPropertyImplementation:return"Incorrect property implementation";case re.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case re.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case se.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case se.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case re.MissingMethodImplementation:return"Missing action";case re.MissingPropertyImplementation:return"Missing property";case se.NameNotUniqueInScope:return"Duplicate name";case re.NoProperties:return"No properties";case re.NonStaticPropertyInStaticEntity:return"Non-static property";case re.StaticEntityWithNonStaticProperties:return"Non-static properties";case re.ReadingFromIncompatibleType:return"Read from different type";case re.WritingToIncompatibleType:return"Write to different type";case re.ScopeWithoutLogic:return"No logic";case re.NonStaticPropertyImplementsStatic:return"Invalid static property";case re.PropertyImplementsIncompatibleType:return"Incompatible data type";case re.PropertyImplementsNonAbstact:return"Non-template property";case re.StaticPropertyImplementsNonStatic:return"Non-static property";case re.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case re.VariableHasInputsAndInternalCall:return"Bad internal call";case re.VariableHasOutputsAndInternalCall:return"Bad internal call";case re.VariableIsCalledAndHasInternalCall:return"Bad internal call";case se.InternalCallDeclarationIsNotFunctionDeclaration:return"Declaration not an action";case se.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case se.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case se.InternalCallParentMissingDataType:return"Parent has no data type";case se.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case se.UnreachableEntity:return"Unreachable entity";case re.DisconnectedCallableEntity:return"Disconnected entity";case re.AbstractEntityImplements:return"Abstract entity implements a non-template entity";case re.AbstractExtendingNonAbstractEntity:return"Abstract entity extends a non-template entity";case re.InvalidPropertiesCombination:return"Invalid properties combination";case re.ExtendingNonInteractiveEntity:return"Extending non-interactive entity";case re.ExtendsIncompatibleEntities:return"Extends incompatible entities";case re.ImplementingNonAbstractEntity:return"Implementing non-template entity";case re.ImplementsIncompatibleEntities:return"Implements incompatible entities";case re.LackingReturnStatementOnSomeBranches:return"Missing termination on some branches";case re.LastCalledEntityMustBeReturnEntity:return"Last called entity must be a termination node";case re.MissingRequiredValue:return"Missing required value";case re.NoPrimaryKeyProperty:return"No primary key property";case re.NonAbstractExtendingAbstractEntity:return"Non-template entity extending a template entity";case re.NonStaticExtendingStaticEntity:return"Non-static entity extending a static entity";case re.NonStaticImplementingStaticEntity:return"Non-static entity implementing a static entity";case re.StaticExtendingNonStaticEntity:return"Static entity extending a non-static entity";case re.StaticImplementingNonStaticEntity:return"Static entity implementing a non-static entity";case re.VariableReadsValueAndInternalCall:return"Variable reads value and has internal call";case re.VariableWritesValuesAndInternalCall:return"Variable writes values and has internal call";case se.EmptyName:return"Empty name";case se.InvalidObjectStructure:return"Invalid object structure";case se.LoopBodyFunctionOverwrite:return"Loop body action overwrites action with same name";case se.MethodOverwritesBaseMethodWithSameImplementation:return"Action overwrites base action with same implementation";case se.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case se.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case se.MissingCaller:return"Missing caller";case se.NameAsResolvedCodeNameNotUniqueInScope:return"Name not unique in scope";case se.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"Name can only contain letters, numbers, underscores and spaces";case se.NameMustStartWithLetterOrUnderscore:return"Name must start with letter or underscore";case se.NoOverlapWithImplementedSignature:return"No overlap with implemented signature";case se.PropertyOverwritesBasePropertyWithSameImplementation:return"Property overwrites base property with same implementation";case se.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case se.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case se.ReaderWriterIncompatibleDataType:return"Reader/writer incompatible data type";case ta.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case ta.StatusCodeMustBeNumber:return"HTTP status code must be a number";case vs.UUIDMustBeString:return"UUID must be a string";case vs.UUIDMustNotContainSpaces:return"UUID must not contain spaces";case vs.UUIDMustBeValidFormat:return"UUID must be in a valid format";case ki.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case ki.StringValueMustNotHaveDashes:return"This value must not contain dashes";case ki.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return Cc(d.code)}}function Wme(d){switch(d.code){case re.AbstractEntityWithNonAbstractMethods:return`${Y(d.entity,d.entity.project)} has non-template actions`;case re.AbstractEntityWithNonAbstractProperties:return`${Y(d.entity,d.entity.project)} has non-template properties`;case re.IncorrectEntityImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements template`;case re.IncorrectMethodImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements the template`;case re.IncorrectPropertyImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements the template`;case re.AbstractMethodInNonAbstractEntity:return`${Y(d.entity,d.entity.project)} can't be a template`;case re.AbstractPropertyInNonAbstractEntity:return`${Y(d.entity,d.entity.project)} can't be a template`;case se.MethodOverwritesOtherSiblingWithSameName:return`${Y(d.entity,d.entity.project)} overwrites action`;case se.PropertyOverwritesOtherSiblingWithSameName:return`${Y(d.entity,d.entity.project)} overwrites property`;case re.MissingMethodImplementation:return`${Y(d.entity,d.entity.project)} is missing action`;case re.MissingPropertyImplementation:return`${Y(d.entity,d.entity.project)} is missing property`;case se.NameNotUniqueInScope:return`${Y(d.entity,d.entity.project)} name is not unique`;case re.NoProperties:return`${Y(d.entity,d.entity.project)} has no properties`;case re.NonStaticPropertyInStaticEntity:return`${Y(d.entity,d.entity.project)} has non-static property`;case re.StaticEntityWithNonStaticProperties:return`${Y(d.entity,d.entity.project)} has non-static properties`;case re.ReadingFromIncompatibleType:return`${Y(d.entity,d.entity.project)} reads from different type`;case re.WritingToIncompatibleType:return`${Y(d.entity,d.entity.project)} writes to different type`;case re.ScopeWithoutLogic:return`${Y(d.entity,d.entity.project)} has no logic`;case re.NonStaticPropertyImplementsStatic:return`${Y(d.entity,d.entity.project)} has invalid static property`;case re.PropertyImplementsIncompatibleType:return`${Y(d.entity,d.entity.project)} has incompatible data type`;case re.PropertyImplementsNonAbstact:return`${Y(d.entity,d.entity.project)} has non-template property`;case re.StaticPropertyImplementsNonStatic:return`${Y(d.entity,d.entity.project)} has non-static property`;case re.VariableCallsOthersAndHasInternalCall:return`${Y(d.entity,d.entity.project)} has bad internal call`;case re.VariableHasInputsAndInternalCall:return`${Y(d.entity,d.entity.project)} has bad internal call`;case re.VariableHasOutputsAndInternalCall:return`${Y(d.entity,d.entity.project)} has bad internal call`;case re.VariableIsCalledAndHasInternalCall:return`${Y(d.entity,d.entity.project)} has bad internal call`;case se.InternalCallDeclarationIsNotFunctionDeclaration:return`${Y(d.entity,d.entity.project)} has declaration that is not an action`;case se.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${Y(d.entity,d.entity.project)} has declaration that is not found in parent`;case se.InternalCallParentDeclarationEntityInvalidType:return`${Y(d.entity,d.entity.project)} has invalid parent declaration type`;case se.InternalCallParentMissingDataType:return`${Y(d.entity,d.entity.project)}'s parent has no data type`;case se.InternalCallDeclarationNotInParentDatatypeEntity:return`${Y(d.entity,d.entity.project)} has declaration that is not in parent`;case se.UnreachableEntity:return`${Y(d.entity,d.entity.project)} is unreachable`;case re.DisconnectedCallableEntity:return`${Y(d.entity,d.entity.project)} is not executed by any entity`;case re.AbstractEntityImplements:return`${Y(d.entity,d.entity.project)} implements a non-template entity`;case re.AbstractExtendingNonAbstractEntity:return`${Y(d.entity,d.entity.project)} extends a non-template entity`;case re.InvalidPropertiesCombination:return`${Y(d.entity,d.entity.project)} has invalid properties combination`;case re.ExtendingNonInteractiveEntity:return`${Y(d.entity,d.entity.project)} extends a non-interactive entity`;case re.ExtendsIncompatibleEntities:return`${Y(d.entity,d.entity.project)} extends incompatible entities`;case re.ImplementingNonAbstractEntity:return`${Y(d.entity,d.entity.project)} implements a non-template entity`;case re.ImplementsIncompatibleEntities:return`${Y(d.entity,d.entity.project)} implements incompatible entities`;case re.LackingReturnStatementOnSomeBranches:return`${Y(d.entity,d.entity.project)} is missing termination on some branches`;case re.LastCalledEntityMustBeReturnEntity:return`${Y(d.entity,d.entity.project)}'s last called entity must be a termination node`;case re.MissingRequiredValue:return`${Y(d.entity,d.entity.project)} is missing a required value`;case re.NoPrimaryKeyProperty:return`${Y(d.entity,d.entity.project)} has no primary key property`;case re.NonAbstractExtendingAbstractEntity:return`${Y(d.entity,d.entity.project)} extends a template entity`;case re.NonStaticExtendingStaticEntity:return`${Y(d.entity,d.entity.project)} extends a static entity`;case re.NonStaticImplementingStaticEntity:return`${Y(d.entity,d.entity.project)} implements a static entity`;case re.StaticExtendingNonStaticEntity:return`${Y(d.entity,d.entity.project)} extends a non-static entity`;case re.StaticImplementingNonStaticEntity:return`${Y(d.entity,d.entity.project)} implements a non-static entity`;case re.VariableReadsValueAndInternalCall:return`${Y(d.entity,d.entity.project)} reads a value and has internal call`;case re.VariableWritesValuesAndInternalCall:return`${Y(d.entity,d.entity.project)} writes values and has internal call`;case se.EmptyName:return`${Vs[d.entity.type]} has no name`;case se.InvalidObjectStructure:return`${Y(d.entity,d.entity.project)} has invalid structure`;case se.LoopBodyFunctionOverwrite:return`${Y(d.entity,d.entity.project)}'s loop body action overwrites an action`;case se.MethodOverwritesBaseMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites base action`;case se.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another action with same implementation`;case se.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another action with same implementation`;case se.MissingCaller:return`${Y(d.entity,d.entity.project)} is missing a caller`;case se.NameAsResolvedCodeNameNotUniqueInScope:return`${Y(d.entity,d.entity.project)} has a name not unique in the scope`;case se.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${Y(d.entity,d.entity.project)} name can only contain letters, numbers, underscores and spaces`;case se.NameMustStartWithLetterOrUnderscore:return`${Y(d.entity,d.entity.project)} name must start with letter or underscore`;case se.NoOverlapWithImplementedSignature:return`${Y(d.entity,d.entity.project)} has no overlap with implemented signature`;case se.PropertyOverwritesBasePropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites base property`;case se.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another property with same implementation`;case se.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another property with same implementation`;case se.ReaderWriterIncompatibleDataType:return`${Y(d.entity,d.entity.project)} has reader/writer with incompatible data type`;case ta.StatusCodeMustBeBetween100And599:return`${Y(d.entity,d.entity.project)} HTTP status code must be between 100 and 599`;case ta.StatusCodeMustBeNumber:return`${Y(d.entity,d.entity.project)} HTTP status code must be a number`;case vs.UUIDMustBeString:return`${Y(d.entity,d.entity.project)} UUID must be a string`;case vs.UUIDMustNotContainSpaces:return`${Y(d.entity,d.entity.project)} UUID must not contain spaces`;case vs.UUIDMustBeValidFormat:return`${Y(d.entity,d.entity.project)} UUID must be in a valid format`;case ki.MustBeUniqueAmongSameEntities:return`${Y(d.entity,d.entity.project)} value must be unique among the same kind`;case ki.StringValueMustNotHaveDashes:return`${Y(d.entity,d.entity.project)} value must not contain dashes`;case ki.StringValueMustNotHaveSpaces:return`${Y(d.entity,d.entity.project)} value must not contain spaces`;default:return`${Y(d.entity,d.entity.project)} Error: ${Cc(d.code)}`}}function Yme(d){var u,r,a,o;switch(d.code){case re.AbstractEntityWithNonAbstractMethods:return`${Y(d.entity,d.entity.project)} has non-template actions`;case re.AbstractEntityWithNonAbstractProperties:return`${Y(d.entity,d.entity.project)} has non-template properties`;case re.IncorrectEntityImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements the template entity`;case re.IncorrectMethodImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements the template action it's based on`;case re.IncorrectPropertyImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements the template property it's based on`;case re.AbstractMethodInNonAbstractEntity:return`${Y(d.entity,d.entity.project)} is a template action in a non-template entity`;case re.AbstractPropertyInNonAbstractEntity:return`${Y(d.entity,d.entity.project)} is a template property in a non-template entity`;case se.MethodOverwritesOtherSiblingWithSameName:return`${Y(d.entity,d.entity.project)} overwrites an action in the template entity`;case se.PropertyOverwritesOtherSiblingWithSameName:return`${Y(d.entity,d.entity.project)} overwrites a property in the template entity`;case re.MissingMethodImplementation:return`${Y(d.entity,d.entity.project)} is missing an action implementation from the template entity`;case re.MissingPropertyImplementation:return`${Y(d.entity,d.entity.project)} is missing a property implementation from the template entity`;case se.NameNotUniqueInScope:return`${Y(d.entity,d.entity.project)} has a duplicate name in the same scope`;case re.NoProperties:return`${Y(d.entity,d.entity.project)} has no properties, so it doesn't do anything`;case re.NonStaticPropertyInStaticEntity:return`${Y(d.entity,d.entity.project)} has a non-static property in a static entity`;case re.StaticEntityWithNonStaticProperties:return`${Y(d.entity,d.entity.project)} has non-static properties in a static entity`;case re.ReadingFromIncompatibleType:return`${Y(d.entity,d.entity.project)} reads data from a value of a different data type`;case re.WritingToIncompatibleType:return`${Y(d.entity,d.entity.project)} writes data to a value of a different data type`;case re.ScopeWithoutLogic:return`${Y(d.entity,d.entity.project)} has no logic`;case re.NonStaticPropertyImplementsStatic:return`${Y(d.entity,d.entity.project)} has a static property in a non-static entity`;case re.PropertyImplementsIncompatibleType:return`${Y(d.entity,d.entity.project)} implements a property of a different data type`;case re.PropertyImplementsNonAbstact:return`${Y(d.entity,d.entity.project)} implements a non-template property`;case re.StaticPropertyImplementsNonStatic:return`${Y(d.entity,d.entity.project)} has a static property in a non-static entity`;case re.VariableCallsOthersAndHasInternalCall:return`${Y(d.entity,d.entity.project)} calls other entities while being used to execute internal logic`;case re.VariableHasInputsAndInternalCall:return`${Y(d.entity,d.entity.project)} has inputs while being used to execute internal logic`;case re.VariableHasOutputsAndInternalCall:return`${Y(d.entity,d.entity.project)} has outputs while being used to execute internal logic`;case re.VariableIsCalledAndHasInternalCall:return`${Y(d.entity,d.entity.project)} is called while being used to execute internal logic`;case se.InternalCallDeclarationIsNotFunctionDeclaration:return`${Y(d.entity,d.entity.project)} has a declaration that is not an action`;case se.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${Y(d.entity,d.entity.project)} has a declaration that is not found in ${(u=d.entity.parent.getDataType(null))!=null&&u.entity?Y((r=d.entity.parent.getDataType(null))==null?void 0:r.entity,d.entity.project):"the variable's data-type entity"}`;case se.InternalCallParentDeclarationEntityInvalidType:return`${Y(d.entity,d.entity.project)} is part of a variable whos data-type entity can't have actions`;case se.InternalCallParentMissingDataType:return`${Y(d.entity,d.entity.project)} is part of a variable with no data-type entity`;case se.InternalCallDeclarationNotInParentDatatypeEntity:return`${Y(d.entity,d.entity.project)} has a declaration doesn't belong to ${(a=d.entity.parent.getDataType(null))!=null&&a.entity?Y((o=d.entity.parent.getDataType(null))==null?void 0:o.entity,d.entity.project):"the variable's data-type entity"}`;case se.UnreachableEntity:return`${Y(d.entity,d.entity.project)} is unreachable`;case re.DisconnectedCallableEntity:return`${Y(d.entity,d.entity.project)} is disconnected and won't be executed by anything after publishing`;case re.AbstractEntityImplements:return`${Y(d.entity,d.entity.project)} implements a non-template entity`;case re.AbstractExtendingNonAbstractEntity:return`${Y(d.entity,d.entity.project)} extends a non-template entity`;case re.InvalidPropertiesCombination:return`${Y(d.entity,d.entity.project)} has an invalid combination of properties`;case re.ExtendingNonInteractiveEntity:return`${Y(d.entity,d.entity.project)} extends a non-interactive entity`;case re.ExtendsIncompatibleEntities:return`${Y(d.entity,d.entity.project)} extends incompatible entities`;case re.ImplementingNonAbstractEntity:return`${Y(d.entity,d.entity.project)} implements a non-template entity`;case re.ImplementsIncompatibleEntities:return`${Y(d.entity,d.entity.project)} implements incompatible entities`;case re.LackingReturnStatementOnSomeBranches:return`${Y(d.entity,d.entity.project)} has branches that don't terminate`;case re.LastCalledEntityMustBeReturnEntity:return`${Y(d.entity,d.entity.project)} must end with a termination node`;case re.MissingRequiredValue:return`${Y(d.entity,d.entity.project)} is missing a required value`;case re.NoPrimaryKeyProperty:return`${Y(d.entity,d.entity.project)} has no primary key property`;case re.NonAbstractExtendingAbstractEntity:return`${Y(d.entity,d.entity.project)} is a non-template entity extending a template entity`;case re.NonStaticExtendingStaticEntity:return`${Y(d.entity,d.entity.project)} is a non-static entity extending a static entity`;case re.NonStaticImplementingStaticEntity:return`${Y(d.entity,d.entity.project)} is a non-static entity implementing a static entity`;case re.StaticExtendingNonStaticEntity:return`${Y(d.entity,d.entity.project)} is a static entity extending a non-static entity`;case re.StaticImplementingNonStaticEntity:return`${Y(d.entity,d.entity.project)} is a static entity implementing a non-static entity`;case re.VariableReadsValueAndInternalCall:return`${Y(d.entity,d.entity.project)} reads a value and has an internal call`;case re.VariableWritesValuesAndInternalCall:return`${Y(d.entity,d.entity.project)} writes values and has an internal call`;case se.EmptyName:return`${Vs[d.entity.type]} has no name`;case se.InvalidObjectStructure:return`${Y(d.entity,d.entity.project)} has an invalid structure`;case se.LoopBodyFunctionOverwrite:return`${Y(d.entity,d.entity.project)}'s loop body action overwrites`;case se.MethodOverwritesBaseMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites a base action with same implementation`;case se.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another action with same implementation`;case se.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another action with same implementation`;case se.MissingCaller:return`${Y(d.entity,d.entity.project)} is missing a caller`;case se.NameAsResolvedCodeNameNotUniqueInScope:return`${Y(d.entity,d.entity.project)} has a name that is not unique in the scope`;case se.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${Y(d.entity,d.entity.project)} name can only contain letters, numbers, underscores and spaces`;case se.NameMustStartWithLetterOrUnderscore:return`${Y(d.entity,d.entity.project)} name must start with letter or underscore`;case se.NoOverlapWithImplementedSignature:return`${Y(d.entity,d.entity.project)} has no overlap with implemented signature`;case se.PropertyOverwritesBasePropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites a base property with same implementation`;case se.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another property with same implementation`;case se.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another property with same implementation`;case se.ReaderWriterIncompatibleDataType:return`${Y(d.entity,d.entity.project)} has a reader/writer with incompatible data type`;case ta.StatusCodeMustBeBetween100And599:return`${Y(d.entity,d.entity.project)} HTTP status code must be between 100 and 599`;case ta.StatusCodeMustBeNumber:return`${Y(d.entity,d.entity.project)} HTTP status code must be a number, between 100 and 599`;case vs.UUIDMustBeString:return`${Y(d.entity,d.entity.project)} UUID must be a string, eg: "${cl()}"`;case vs.UUIDMustNotContainSpaces:return`${Y(d.entity,d.entity.project)} UUID must not contain spaces, eg: "${cl()}"`;case vs.UUIDMustBeValidFormat:return`${Y(d.entity,d.entity.project)} UUID must be in a valid format. Eg: "${cl()}"`;case ki.MustBeUniqueAmongSameEntities:return`${Y(d.entity,d.entity.project)} value must be unique among the same kind`;case ki.StringValueMustNotHaveDashes:return`${Y(d.entity,d.entity.project)} value must not contain dashes`;case ki.StringValueMustNotHaveSpaces:return`${Y(d.entity,d.entity.project)} value must not contain spaces`;default:return`${Y(d.entity,d.entity.project)} Error: ${Cc(d.code)}`}}var nA=(d=>(d.ValuesAlreadyConnected="values-already-connected",d.CannotReadMoreThanOneValue="cannot-read-more-than-one-value",d.CannotReadValueFromChildren="cannot-read-value-from-children",d.CannotWriteValueToChildren="cannot-write-value-to-children",d.CannotBeCalledByChildren="cannot-be-called-by-children",d.ExecutionsAlreadyConnected="executions-already-connected",d.DataTypesNotCompatible="data-types-not-compatible",d.CannotCallAncestor="cannot-call-ancestor",d.CannotConnectToItself="cannot-connect-to-itself",d.CannotWriteValueToAncestor="cannot-write-value-to-ancestor",d.NotInScope="not-in-scope",d.IsNotValueWrittingEntity="is-not-value-writting-entity",d.IsNotValueReadingEntity="is-not-value-reading-entity",d.ContinueOrBreakStatementCalledFromOutsideLoop="continue-or-break-statement-called-from-outside-loop",d.ElementInLoopBodyCallingOutsideLoop="element-in-loop-body-calling-outside-loop",d.CallerIsInHigherScope="caller-is-in-higher-scope",d.CallerIsInLowerScope="caller-is-in-lower-scope",d.CallIsInHigherScope="call-is-in-higher-scope",d.CallIsInLowerScope="call-is-in-lower-scope",d.OtherIncompatibleScopeReason="other-incompatible-scope-reason",d.SiblingInternalCallAlreadyUsedInParentVariable="sibling-internal-call-already-used-in-parent-variable",d.ErrorOututMapCannotBeConnectedToParentSuccessBranchCallees="error-output-map-cannot-be-connected-to-parent-success-branch-callees",d.SuccessOutputMapCannotBeConnectedToParentErrorBranchCallees="success-output-map-cannot-be-connected-to-parent-error-branch-callees",d))(nA||{});const zme=Object.values(nA);var aA=(d=>(d.NotPartOfOngoingTest="not-part-of-ongoing-test",d.CannotBeAddedToTest="cannot-be-added-to-test",d))(aA||{});const Xme=Object.values(aA);var oA=(d=>(d.Suggestion="suggestion",d.CanvasGloballyDisabled="canvas-globally-disabled",d.CannotInteractWithInputInVariableWithInternalCalls="cannot-interact-with-input-in-variable-with-internal-calls",d.CannotInteractWithOutputInVariableWithInternalCalls="cannot-interact-with-output-in-variable-with-internal-calls",d))(oA||{});const Qme=Object.values(oA);function e0e(d,u){const r=[...d,...u];return Array.from(new Set(r))}function t0e(d,u){const r=[...d,...u],a=Array.from(new Set(r));return{hasChanged:a.length!==d.length,reasons:a}}function r0e(d,u){const r=d.filter(o=>!u.includes(o));return{hasChanged:r.length!==d.length,reasons:r}}function i0e(d,u){return d.find(r=>r.entity.id===u)||null}function m3(d){return d.filter((u,r)=>d.indexOf(u)===r)}class Ai{constructor(u,r,a=null,o){_(this,"ids",[]);_(this,"entity");_(this,"entityCardHeight");_(this,"entityCardWidth");_(this,"index");_(this,"childEntities",[]);_(this,"children",[]);_(this,"parents",[]);_(this,"calculationEntryPoint");_(this,"_onlyEntities",null);_(this,"_changeSet",null);if(this.index=r,this.entity=u,this.calculationEntryPoint=a||this,this===this.calculationEntryPoint&&!o)throw new Error("Change set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(u,r,a){const o=p3-sA-d3,p=f3-Vy-rA;u.metaSync({x:u.x||o,y:u.y||p},r);const e=new Ai(u,0,null,r);e._onlyEntities=a||[],e.ids=["0"];const y=[];e.next(E=>{y.push(...E)}),Ai.recursivelyAssembleChildrenAreas(y),e.resolveChildrenOverlaps();const v=e.flattenChildEntities();return e._onlyEntities?v.filter(E=>(e._onlyEntities||[]).includes(E)):v}static recursivelyAssembleChildrenAreas(u){const r=[];u.forEach(a=>{a.next(o=>{r.push(...o)})}),r.length>0&&Ai.recursivelyAssembleChildrenAreas(r)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(u){this.calculationEntryPoint._changeSet=u}findAreaInChildrenFromEntity(u){if(this.entity===u)return this;const r=this.children.find(o=>o.entity===u);return r||this.children.reduce((o,p)=>o||p.findAreaInChildrenFromEntity(u),null)}findAreaFromEntity(u){if(this.entity===u)return this;const r=this.calculationEntryPoint.children,a=r.find(p=>p.entity===u);return a||r.reduce((p,e)=>p||e.findAreaInChildrenFromEntity(u),null)}addParent(u){if(!this.parents.includes(u)){const r=Ai.resolveIds(u,this.index);this.ids.push(...r),this.parents.push(u)}}static resolveIds(u,r){return u?u.ids.map(a=>`${a}-${r}`):[`${r}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const u=bn(this.entity,!0);if(this.entity.type===f.Project){const r=[],a=[],o=[];u.forEach(e=>{if(f.DefinitionEntity===e.type){a.push(e);return}else if(Dt.includes(e.type)){o.push(e);return}r.push(e)});const p=r.sort((e,y)=>{const v=!!Tm(e,y).length,E=bn(e),w=bn(y);return v?0:E.length&&!w.length?-1:!E.length&&w.length?1:0}).filter(e=>!Ao(e).length);this.childEntities=[...a,...o,...p]}else{const r=[],a=[],o=[],p=[],e=[];wi.includes(this.entity.type)&&bm(this.entity).forEach(E=>{if(Tt.includes(E.type)){o.push(E);return}const w=fr(E);r.push(w)}),Nr.includes(this.entity.type)&&a.push(...this.entity.detachedChildren);const y=u.filter(v=>{const E=r.includes(v);return E||o.includes(v)||a.includes(v)?!1:Tt.includes(v.type)?(o.push(v),!1):xi.includes(v.type)&&!E?(p.push(v),!1):v.type===f.DefinitionEntity?(e.push(v),!1):!0});r.sort((v,E)=>Il(v,E)?-1:0),p.sort((v,E)=>Il(v,E)?-1:0),o.sort((v,E)=>pb(v,E)?1:pb(E,v)?-1:0),this.childEntities=[...e,...r,...p,...y,...o,...a]}}calculateCardSize(){const u=y3(this.entity);this.entityCardWidth=u.width,this.entityCardHeight=u.height}static getBoundriesOfTwoAreas(u,r){return{top:Math.min(u.top,r.top),left:Math.min(u.left,r.left),bottom:Math.max(u.bottom,r.bottom),right:Math.max(u.right,r.right)}}static getBoundriedOfCombinedAreas(u,r){const a=u.filter(p=>!r.includes(p));return a.reduce((p,e)=>r.includes(e)?p:Ai.getBoundriesOfTwoAreas(p,e.fullBranchArea),a[0].fullBranchArea)}getFullAreaUntilAny(u){const r=this.ownEntityPlusBufferArea;return this.children.filter(e=>!u.includes(e)).map(e=>e.getFullAreaUntilAny(u)).reduce((e,y)=>Ai.getBoundriesOfTwoAreas(e,y),r)}getFullAreaUntilAreaOrAnyChildren(u){const r=[u,...u.flattenChildren()],a=this.ownEntityPlusBufferArea;return this.children.filter(e=>r.includes(e)).map(e=>e.getFullAreaUntil(u)).reduce((e,y)=>Ai.getBoundriesOfTwoAreas(e,y),a)}getFullAreaUntil(u){const r=this.ownEntityPlusBufferArea;return this.children.filter(p=>p!==u).map(p=>p.getFullAreaUntil(u)).reduce((p,e)=>Ai.getBoundriesOfTwoAreas(p,e),r)}get fullBranchArea(){const u=this.ownEntityPlusBufferArea;return this.children.map(o=>o.fullBranchArea).reduce((o,p)=>Ai.getBoundriesOfTwoAreas(o,p),u)}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 u=this.ownEntityArea;return{top:u.top,left:u.left,bottom:u.bottom+Vy,right:u.right+sA}}static filterOutRepeatedAreas(u){return u.filter((r,a)=>u.indexOf(r)===a)}getEarliestId(u,r){const a=u.split("-"),o=r.split("-");return a.length<o.length?u:a.length>o.length?r:a.reduce((e,y,v)=>y<o[v]?u:r,u)}getEarliestLevel(){return this.ids.reduce((a,o)=>this.getEarliestId(a,o),this.ids[0]).split("-").length}countColumns(){let u=0;if(this!==this.calculationEntryPoint)u++;else return u;if(!this.parents.length)return u;const a=this.parents.reduce((o,p)=>p.getEarliestLevel()>o.getEarliestLevel()?p:o,this.parents[0]).countColumns();return u+=a,u}getLatestId(u,r){if(u===r)return u;const a=u.split("-"),o=r.split("-");return a.length<o.length?r:a.length>o.length?u:a.reduce((e,y,v)=>y>o[v]?u:r,u)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((a,o)=>this.getLatestId(a,o),this.ids[0]).split("-").length}smoothPosition(){const u=this.flattenSiblings();if(!u.length&&this.parents.length<=1&&this.children.length){const r=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(a=>{a!==this.calculationEntryPoint&&a.shiftDownAlone(r)})}else if([...Dt].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const r=u.filter(a=>!this.parents.includes(a));r.length?r.every(o=>{const p=this.countColumns(),e=o.countColumns();return p>e})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():r.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(u,r){if(u.includes(this))return u;this.move(this.entity,{y:this.entity.y+r});let a=[...u,this];return this.children.forEach(o=>{if(Ai.getEarliestParentInChain(o)!==this)return;const e=i0e(a,o.entity.id);a=Ai.filterOutRepeatedAreas([...a]),e||(a=a.filter(v=>v!==o));const y=o.shiftDownUntilAny(a,r);a.push(...y)}),a}shiftRightUntilAny(u,r){u.includes(this)||(this.move(this.entity,{x:this.entity.x+r}),this.children.forEach(a=>{const o=Ai.filterOutRepeatedAreas([...this.flattenSiblings(),...u]);Ai.getEarliestParentInChain(a)===this&&a.shiftRightUntilAny(o,r)}))}shiftRight(u){this.move(this.entity,{x:this.entity.x+u}),this.children.forEach(r=>{const o=r.flattenSiblings().filter(p=>p!==r);r.shiftRightUntilAny(o,u)})}shiftDownAlone(u){this.move(this.entity,{y:this.entity.y+u})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const u=this.parents.reduce((o,p)=>{const e=p.ownEntityArea,y=e.top+Vd,v={top:y,left:e.left,bottom:y,right:e.right};return Ai.getBoundriesOfTwoAreas(o,v)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),a=(u.bottom-u.top)/2-Vd;this.shiftDownAlone(a)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const u=this.children.reduce((o,p)=>{const e=p.ownEntityArea,y=e.top+Vd,v={top:y,left:e.left,bottom:y,right:e.right};return Ai.getBoundriesOfTwoAreas(o,v)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),a=(u.bottom-u.top)/2-Vd;return this.shiftDownAlone(a),a}resolveChildrenOverlaps(){const u=this.flattenChildren();let r=[];u.forEach(a=>{const o=a.adjustVerticallyToAvoidOverlaps();r.push(...o)}),u.forEach(a=>{a.smoothPosition()})}static getEarliestParentInChain(u){let r=u.parents[0];return u.parents.length&&(r=u.parents.sort((a,o)=>{if(!a.ids.length)return-1;if(!o.ids.length)return 1;const p=a.ids.sort((y,v)=>y.length<v.length?-1:0),e=o.ids.sort((y,v)=>y.length<v.length?-1:0);return p[0].length-e[0].length})[0]),r}flattenEarlierSiblings(u=new Set){return u.add(this.entity.id),this.parents.reduce((a,o)=>{if(u.has(o.entity.id))return a;u.add(o.entity.id);const e=o.children.slice(0,o.children.indexOf(this)).reduce((y,v)=>[...y,v,...v.flattenChildren(u)],[]);return[...a,...e]},[])}flattenSiblings(u=new Set){return u.add(this.entity.id),this.parents.reduce((a,o)=>{if(u.has(o.entity.id))return a;u.add(o.entity.id);const e=o.children.filter(y=>y!==this).reduce((y,v)=>[...y,v,...v.flattenChildren(u)],[]);return[...a,...e]},[])}flattenChildren(u=new Set){return this.children.reduce((r,a)=>u.has(a.entity.id)?r:(u.add(a.entity.id),[...r,a,...a.flattenChildren(u)]),[])}flattenParents(u=new Set){return this.parents.reduce((a,o)=>u.has(o.entity.id)?a:(u.add(o.entity.id),[...a,o,...o.flattenParents(u)]),[])}getAreaIfRendered(u){return this.calculationEntryPoint.flattenChildren().find(o=>o.entity.id===u.id)||null}getLowerSiblings(){const u=this.parents.reduce((r,a)=>{const o=a.children.indexOf(this),p=a.children.slice(o+1);return[...r,...p]},[]);return m3(u)}getLowerAreas(){const u=this.getLowerSiblings(),r=this.parents.reduce((a,o)=>[...a,...o.getLowerAreas()],[]);return m3([...u,...r])}adjustVerticallyToAvoidOverlaps(u=[]){const a=Ai.getEarliestParentInChain(this).children[this.index-1];if(!a)return u;const o=this.flattenEarlierSiblings(),p=this.flattenParents(),e=[...o,...p,a],E=R(e.flatMap(V=>Tm(this.entity,V.entity))).filter(V=>V.id!==this.entity.id).map(V=>this.findAreaFromEntity(V)).filter(V=>!!V),w=this.getFullAreaUntilAny(E),A=a.getFullAreaUntilAny(E),$=e.reduce((V,B)=>B===this||B.fullBranchArea.left!==w.left?V:Math.max(V,B.fullBranchArea.bottom),A.bottom);if(w.top<$){const V=$-w.top+Vy;return this.shiftDownUntilAny(u,V)}return u}move(u,r){(this.onlyEntities||[]).includes(u)&&u.metaSync(r,this.changeSet)}addChild(u){const r=this.childEntities[u];let a=null;r.x&&r.y?a=this.getAreaIfRendered(r):!r.x&&!r.y&&this.move(r,{x:this.entity.x,y:this.entity.y}),a||(a=new Ai(r,u,this.calculationEntryPoint));const o=this.ownEntityPlusBufferArea;this.children.includes(a)||(this.children.push(a),a.addParent(this));const p=a.fullBranchArea;if(p.left<o.right){const e=o.right-p.left;a.shiftRight(e)}return a}flattenChildEntities(u=new Set){return this.children.reduce((r,a)=>u.has(a.entity.id)?r:(u.add(a.entity.id),[...r,a.entity,...a.flattenChildEntities(u)]),[])}next(u){const r=[];this.childEntities.forEach((a,o)=>{const p=this.addChild(o);p&&r.push(p)}),u(r)}}var $c=(d=>(d.Amazon="amazon",d.Google="google",d.Microsoft="microsoft",d))($c||{}),kr=(d=>(d.RelationalDatabase="relational-database",d.CompiledLocalCodebase="compiled-local-codebase",d.CloudHostedCodebase="cloud-hosted-codebase",d.HttpApi="http-api",d.HttpEndpoint="http-endpoint",d.ServerlessFunction="serverless-function",d))(kr||{}),lA=(d=>(d.Post="post",d.Get="get",d.Acknowledgement="acknowledgment",d.Progress="progress",d.Error="error",d.Complete="complete",d))(lA||{}),hl=(d=>(d.Queued="queued",d.Running="running",d.Success="success",d.Failed="failed",d.CleanedUp="cleaned-up",d.Skipped="skipped",d.AbortedByUser="aborted-by-user",d.UnrecoverableFailure="unrecoverable-failure",d.Reverted="reverted",d.UnpublishingStarted="unpublishing-started",d.Unpublished="unpublished",d))(hl||{}),dA=(d=>(d.Queued="queued",d.Running="running",d.Success="success",d.Failed="failed",d.CleanedUp="cleaned-up",d.UnrecoverableFailure="unrecoverable-failure",d.Reverted="reverted",d.UnpublishingStarted="unpublishing-started",d.Unpublished="unpublished",d))(dA||{}),yt=(d=>(d.ProjectNotFound="project-not-found",d.ProjectPublishRequestAcknowledged="project-publish-request-acknowledged",d.PublicationStepFailedReasonUnknown="publication-step-failed-reason-unknown",d.DeploymentCompleted="deployment-completed",d.DeploymentStarted="deployment-started",d.DeploymentFailed="deployment-failed",d.AllInfrastructureSuccessfullyProvisioned="all-infrastucture-successfully-provisioned",d.RequestPayloadValidationFailed="request-payload-validation-failed",d.ProjectStateValidationFailedMissingName="project-state-validation-failed-missing-name",d.ProjectStateValidationFailedMissingAnyFunctionality="project-state-validation-failed-missing-any-functionality",d.ProjectAlreadyBeingPublished="project-already-being-published",d.BillingSubscriptionUpdateFailed="billing-subscription-update-failed",d.RelationalDatabaseDeploymentStarted="relational-database-deployment-started",d.RelationalDatabaseDeploymentCompleted="relational-database-deployment-completed",d.RelationalDatabaseDeploymentFailed="relational-database-deployment-failed",d.CreatingNewRelationalDatabase="creating-new-relational-database",d.WaitingForPreviousRelationalDatabaseDeployment="waiting-for-previous-relationa-database-deployment",d.RelationalDatabaseAlreadyExists="relational-database-already-exists",d.RelationalDatabaseDeletionStarted="relational-database-deletion-started",d.RelationalDatabaseDeletionCompleted="relational-database-deletion-completed",d.RelationalDatabaseDeletionFailed="relational-database-deletion-failed",d.WaitingForPreviousRelationalDatabaseDeletion="waiting-for-previous-relationa-database-deletion",d.HttpApiDeploymentStarted="http-api-deployment-started",d.HttpApiDeploymentCompleted="http-api-deployment-completed",d.HttpApiDeploymentFailed="http-api-deployment-failed",d.CreatingNewHttpApi="creating-new-http-api",d.HttpApiAlreadyExists="http-api-already-exists",d.HttpApiDeletionStarted="http-api-deletion-started",d.HttpApiDeletionCompleted="http-api-deletion-completed",d.HttpApiDeletionFailed="http-api-deletion-failed",d.WaitingForPreviousHttpApiDeletion="waiting-for-previous-http-api-deletion",d.BusinessLogicCodebaseDeploymentStarted="business-logic-codebase-deployment-started",d.BusinessLogicCodebaseDeploymentCompleted="business-logic-codebase-deployment-completed",d.BusinessLogicCodebaseDeploymentFailed="business-logic-codebase-deployment-failed",d.BundlingCodebaseForDownload="bundling-codebase-for-download",d.UploadingCodebaseToCloudStorage="uploading-codebase-to-cloud-storage",d.UploadingCodebaseToCloudStorageCompleted="uploading-codebase-to-cloud-storage-completed",d.UploadingCodebaseToCloudStorageFailed="uploading-codebase-to-cloud-storage-failed",d.InfrastructureValuesCodebaseInterpolationStarted="infrastructure-values-codebase-interpolation-started",d.InfrastructureValuesCodebaseInterpolationCompleted="infrastructure-values-codebase-interpolation-completed",d.InfrastructureValuesCodebaseInterpolationFailed="infrastructure-values-codebase-interpolation-failed",d.CodeCompilationStarted="code-compilation-started",d.CodeCompilationCompleted="code-compilation-completed",d.CodeCompilationFailed="code-compilation-failed",d.BundleCodebaseStarted="bundle-codebase-started",d.BundleCodebaseCompleted="bundle-codebase-completed",d.BundleCodebaseFailed="bundle-codebase-failed",d.InstallingCodebaseDependenciesStarted="installing-codebase-dependencies-started",d.InstallingCodebaseDependenciesCompleted="installing-codebase-dependencies-completed",d.InstallingCodebaseDependenciesFailed="installing-codebase-dependencies-failed",d.MigrateRelationalDatabaseStarted="migrate-relational-database-started",d.MigrateRelationalDatabaseCompleted="migrate-relational-database-completed",d.MigrateRelationalDatabaseFailed="migrate-relational-database-failed",d))(yt||{}),vn=(d=>(d.CodeCompilation="code-compilation",d.RelationalDatabaseDeployment="relational-database-deployment",d.RelationalDatabaseDeletion="relational-database-deletion",d.HttpApiDeployment="http-api-deployment",d.HttpApiDeletion="http-api-deletion",d.InfrastructureValuesCodebaseInterpolation="infrastructure-values-codebase-interpolation",d.BundleCodebase="bundle-codebase",d.MigrateRelationalDatabase="migrate-relational-database",d.BusinessLogicCodebaseDeployment="business-logic-codebase-deployment",d.CodebaseCleanup="codebase-cleanup",d))(vn||{});kr.CloudHostedCodebase,kr.HttpApi,kr.RelationalDatabase,kr.CloudHostedCodebase,kr.CloudHostedCodebase,kr.RelationalDatabase,kr.CloudHostedCodebase,kr.CloudHostedCodebase;function v3(d){return`project-${d}-http-api`}function E3(d){return`entity-${d}-database`}class T3{constructor(u,r,a,o,p,e,y,v,E){_(this,"stepType");_(this,"id");_(this,"resourceType");_(this,"index");_(this,"dependency",[]);_(this,"lastEvent",null);_(this,"lasEventTimestamp",null);_(this,"status",hl.Queued);_(this,"publicationRun");_(this,"resource");this.stepType=u,this.id=r,this.resourceType=a,this.status=o,this.dependency=p,this.index=e,this.lasEventTimestamp=y,this.publicationRun=v,this.resource=E}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(u){var r,a;this.status=u.status,this.dependency=u.dependency,this.index=u.index,this.stepType=u.stepType,this.resourceType=u.resourceType,this.lastEvent=u.lastEvent,this.id=u.id,(a=this.resource)==null||a.setDetails((r=u.resource)==null?void 0:r.details)}}var I3=(d=>(d.Ready="ready",d.Provisioning="provisioning",d.Queued="queued",d.ProvisioningFailed="provisioning-failed",d.Deleting="deleting",d.DeletingFailed="deleting-failed",d.Deleted="deleted",d))(I3||{});class uA{constructor(u,r,a){_(this,"provisionedBy");_(this,"publicationRun");_(this,"resourceType");_(this,"provider");_(this,"resourceId");_(this,"details",null);_(this,"name",null);_(this,"status","queued");this.publicationRun=u,this.resourceType=r,this.provider=a}setDetails(u){this.details=u}setStatus(u){this.status=u}setProvisionedBy(u){this.provisionedBy=u}}class cA extends uA{constructor(r,a,o,p){super(r,o,p);_(this,"resourceType");_(this,"owners",new Map);_(this,"details",null);_(this,"status","queued");a.forEach(e=>{this.owners.set(e.id,e)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var r,a;return this.resourceType===kr.HttpApi?this.resourceId=v3(this.publicationRun.project.id):this.resourceType===kr.RelationalDatabase&&(this.resourceId=E3((a=(r=Array.from(this.owners.values()))==null?void 0:r[0])==null?void 0:a.id)),this.resourceId}}class pA extends uA{constructor(r,a,o){super(r,a,o);_(this,"resourceType");_(this,"details",null);_(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceType===kr.CompiledLocalCodebase?this.resourceId=`compiled-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}--${this.publicationRun.id}`:this.resourceType===kr.CloudHostedCodebase&&(this.resourceId=`cloud-hosted-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}`),this.resourceId}}class s0e{constructor(u,r){_(this,"id");_(this,"projectAutoIncrementPublicationCount");_(this,"projectPublishedSemanticVersion");_(this,"projectVersion");_(this,"projectId");_(this,"cloudProvider");_(this,"triggeredBy");_(this,"createdAt");_(this,"updatedAt");_(this,"status");_(this,"steps",[]);_(this,"editor");_(this,"explicitResources",new Map);_(this,"implicitGlobalResources",new Map);_(this,"finalGlobalEvent",null);_(this,"finalStatus",null);this.id=u.id,this.projectAutoIncrementPublicationCount=u.projectAutoIncrementPublicationCount,this.projectPublishedSemanticVersion=u.projectPublishedSemanticVersion,this.projectVersion=u.projectVersion,this.projectId=u.projectId,this.cloudProvider=u.cloudProvider,this.triggeredBy=u.triggeredBy,this.createdAt=u.createdAt,this.updatedAt=u.updatedAt,this.status=u.status,this.editor=r}get project(){return this.editor.project}getInfraTypes(u){return this.steps.filter(r=>u.includes(r.resourceType))}getStepsTypes(u){return this.steps.filter(r=>u.includes(r.stepType))}toIds(u){return u.map(r=>r.id)}getResourceForEntity(u){const r=Array.from(this.explicitResources.values()).find(a=>a.owners.has(u.id));return r||null}async init(){await this.initResources()}async initResources(){this.implicitGlobalResources.set(kr.CompiledLocalCodebase,new pA(this,kr.CompiledLocalCodebase,$c.Amazon)),this.implicitGlobalResources.set(kr.CloudHostedCodebase,new pA(this,kr.CloudHostedCodebase,$c.Amazon));const u=this.project.entities.filter(a=>es(a,Le.HTTP_ENDPOINT)),r=this.project.entities.filter(a=>es(a,Le.RELATIONAL_DATABASE));if(r.length&&r.forEach(a=>{const o=new cA(this,[a],kr.RelationalDatabase,$c.Amazon);this.explicitResources.set(o.resourceId,o)}),u.length){const a=new cA(this,u,kr.HttpApi,$c.Amazon);this.explicitResources.set(a.resourceId,a)}}setSteps(u,r){u.forEach(a=>{this.addStep(a,r)}),this.editor.events.emit(yt.ProjectPublishRequestAcknowledged,{})}addStep(u,r){const a=u.dependency||[];if(a.length){const p=a.filter(e=>!this.steps.find(y=>y.id===e));if(p.length)throw new Error(`Missing dependencies: ${p.join(", ")}`)}if(!u.resource)throw new Error(`Resource not found for step ${u.stepType} (${u.id})`);if(!this.steps.find(p=>p.id===u.id)){const p=this.implicitGlobalResources.get(u.resourceType)||this.explicitResources.get(u.resource.resourceId),e=new T3(u.stepType,u.id,u.resourceType,u.status,a,u.index,r,this,p);this.steps.push(e)}}onUpdate(u){var r;if(Me.log("onUpdate",u),(r=u.payload)!=null&&r.stepType){const a=this.steps.find(o=>{var p;return o.id===((p=u.payload)==null?void 0:p.id)});a&&L(u.emittedAt).isAfter(L(a.lasEventTimestamp))&&a.update(u.payload)}this.editor.events.emit("publication-updated",{}),u.type===lA.Error?(this.finalStatus=dA.Failed,this.finalGlobalEvent=u.event,this.editor.events.emit("project-publication-error",u)):u.type===lA.Complete&&(this.finalStatus=dA.Success,this.finalGlobalEvent=u.event,this.editor.events.emit("project-publication-completed",u))}}function n0e(d){switch(d){case vn.CodeCompilation:return"Code generation";case vn.RelationalDatabaseDeployment:return"Database creation";case vn.HttpApiDeployment:return"HTTP gateway creation";case vn.InfrastructureValuesCodebaseInterpolation:return"Link code with resources";case vn.BundleCodebase:return"Bundle code";case vn.MigrateRelationalDatabase:return"Database structure migration";case vn.BusinessLogicCodebaseDeployment:return"Update servers with new code";case vn.CodebaseCleanup:return"Code cleanup";case vn.HttpApiDeletion:return"HTTP gateway deletion";case vn.RelationalDatabaseDeletion:return"Database deletion";default:return"Publication finished"}}function a0e(d){switch(d){case yt.DeploymentCompleted:return"Successfully published";case yt.DeploymentStarted:return"Publication started";case yt.DeploymentFailed:return"Publication failed";case yt.AllInfrastructureSuccessfullyProvisioned:return"All infrastructure successfully provisioned";case yt.RequestPayloadValidationFailed:return"Request payload validation failed";case yt.ProjectStateValidationFailedMissingName:return"Project state validation failed: missing name";case yt.ProjectStateValidationFailedMissingAnyFunctionality:return"Project state validation failed: missing any functionality";case yt.RelationalDatabaseDeploymentStarted:return"Database creation started";case yt.RelationalDatabaseDeploymentCompleted:return"Database creation completed";case yt.RelationalDatabaseDeploymentFailed:return"Database creation failed";case yt.CreatingNewRelationalDatabase:return"Creating new database (up to 5 mins)";case yt.WaitingForPreviousRelationalDatabaseDeployment:return"Waiting for previous database creation";case yt.RelationalDatabaseAlreadyExists:return"Database already exists";case yt.HttpApiDeploymentStarted:return"HTTP gateway creation started";case yt.HttpApiDeploymentCompleted:return"HTTP gateway creation completed";case yt.HttpApiDeploymentFailed:return"HTTP gateway creation failed";case yt.CreatingNewHttpApi:return"Creating new HTTP gateway";case yt.HttpApiAlreadyExists:return"HTTP gateway already exists";case yt.BusinessLogicCodebaseDeploymentStarted:return"Update servers with new code started";case yt.BusinessLogicCodebaseDeploymentCompleted:return"Update servers with new code completed";case yt.BusinessLogicCodebaseDeploymentFailed:return"Update servers with new code failed";case yt.BundlingCodebaseForDownload:return"Bundling code for download";case yt.UploadingCodebaseToCloudStorage:return"Uploading code to cloud storage";case yt.InfrastructureValuesCodebaseInterpolationStarted:return"Linking code with resources started";case yt.InfrastructureValuesCodebaseInterpolationCompleted:return"Linking code with resources completed";case yt.InfrastructureValuesCodebaseInterpolationFailed:return"Linking code with resources failed";case yt.CodeCompilationStarted:return"Code generation started";case yt.CodeCompilationCompleted:return"Code generation completed";case yt.CodeCompilationFailed:return"Code generation failed";case yt.BundleCodebaseStarted:return"Code bundling started";case yt.BundleCodebaseCompleted:return"Code bundling completed";case yt.BundleCodebaseFailed:return"Code bundling failed";case yt.InstallingCodebaseDependenciesStarted:return"Installing code dependencies";case yt.InstallingCodebaseDependenciesCompleted:return"Installing code dependencies completed";case yt.InstallingCodebaseDependenciesFailed:return"Installing code dependencies failed";case yt.MigrateRelationalDatabaseStarted:return"Database structure migration started";case yt.MigrateRelationalDatabaseCompleted:return"Database structure migration completed";case yt.MigrateRelationalDatabaseFailed:return"Database structure migration failed";case yt.ProjectAlreadyBeingPublished:return"Project already being published. You need to wait for the previous publication to complete";case yt.ProjectPublishRequestAcknowledged:return"Project publish request acknowledged";case yt.UploadingCodebaseToCloudStorageCompleted:return"Uploading code to cloud storage completed";case yt.UploadingCodebaseToCloudStorageFailed:return"Uploading code to cloud storage failed";case yt.BillingSubscriptionUpdateFailed:return"Billing subscription update failed";case yt.ProjectNotFound:return"Project not found";case yt.HttpApiDeletionCompleted:return"HTTP gateway deletion completed";case yt.HttpApiDeletionFailed:return"HTTP gateway deletion failed";case yt.HttpApiDeletionStarted:return"HTTP gateway deletion started";case yt.PublicationStepFailedReasonUnknown:return"Publication step failed: reason unknown";case yt.WaitingForPreviousHttpApiDeletion:return"Waiting for previous HTTP gateway deletion";case yt.RelationalDatabaseDeletionStarted:return"Database deletion started";case yt.RelationalDatabaseDeletionCompleted:return"Database deletion completed";case yt.RelationalDatabaseDeletionFailed:return"Database deletion failed";case yt.WaitingForPreviousRelationalDatabaseDeletion:return"Waiting for previous database deletion"}return"Unknown event"}var A3=(d=>(d.NO_LOGIC="NO_LOGIC",d.NO_NAME="NO_NAME",d.NO_CHANGES="NO_CHANGES",d.PROJECT_PUBLICATION_ALREADY_ONGOING="PROJECT_PUBLICATION_ALREADY_ONGOING",d))(A3||{});function o0e(d){switch(d){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 l0e(d){switch(d){case kr.RelationalDatabase:return"Relational database";case kr.HttpEndpoint:case kr.HttpApi:return"HTTP endpoints";case kr.ServerlessFunction:case kr.CloudHostedCodebase:return"Server code functions";default:return"Resources"}}function d0e(d){switch(d){case hl.Running:return"In progress";case hl.Failed:return"Failed";case hl.Success:return"Succeeded";case hl.Skipped:return"Skipped";case hl.Queued:default:return"Queued"}}function b3(d){var o;(o=d.dataType)==null||o.validate(),d.inputs.forEach(p=>p.validate()),d.outputs.forEach(p=>p.validate()),d.internalCalls.forEach(p=>p.validate());const r=[...Pa(d),...Eo(d),...w3(d),...Na(d),...R3(d)],a=rb(d);return r.push(...a),Er(d.errors,r)}function w3(d,u){const a=[...d.project.getVariableDeclarations()].filter(o=>o.id!==d.id);return Hp(d,[xr],a,u)}function R3(d){const u=[];if(d.parent!==d.project)return u;if(d.catchesError){const r=bt({id:`${d.id}--${se.GlobalVariableDeclarationCannotCatchError}`,message:`${Vs[d.type].singular} "${Y(d,d.project)}" with id "${d.id}" cannot catch an error because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:H.Error,code:se.GlobalVariableDeclarationCannotCatchError,entity:d});u.push(r.error)}if(d.errorCalls.length){const r=bt({id:`${d.id}--${se.GlobalVariableDeclarationCannotCallOnError}`,message:`${Vs[d.type].singular} "${Y(d,d.project)}" with id "${d.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:H.Error,code:se.GlobalVariableDeclarationCannotCallOnError,entity:d});u.push(r.error)}if(d.calledBy.length){const r=bt({id:`${d.id}--${se.GlobalVariableDeclarationCannotBeCalled}`,message:`${Vs[d.type].singular} "${Y(d,d.project)}" with id "${d.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:H.Error,code:se.GlobalVariableDeclarationCannotBeCalled,entity:d});u.push(r.error)}return[]}const u0e=Object.freeze(Object.defineProperty({__proto__:null,validate:b3,validateGlobalVariableDeclaration:R3,validateVariableDeclarationName:w3},Symbol.toStringTag,{value:"Module"}));function g3(d){d.inputs.forEach(o=>o.validate()),d.outputs.forEach(o=>o.validate()),d.internalCalls.forEach(o=>o.validate());const r=[...Pa(d),...Eo(d),...Na(d)],a=rb(d);return r.push(...a),Er(d.errors,r)}const c0e=Object.freeze(Object.defineProperty({__proto__:null,validate:g3},Symbol.toStringTag,{value:"Module"}));var fA=(d=>(d.Parent="parent",d.DataTypeEntity="data-type-entity",d.VarDeclaration="var-declaration",d))(fA||{});const xt=class xt extends Cr{constructor(r,a){super(r);_(this,"initialData");_(this,"id");_(this,"x");_(this,"y");_(this,"type",f.VariableInstance);_(this,"catchesError",!1);_(this,"defaultValue",null);_(this,"writesValues",[]);_(this,"readsValue",null);_(this,"declaration");_(this,"inputs",[]);_(this,"outputs",[]);_(this,"error",null);_(this,"calledBySuccess",[]);_(this,"calledByError",[]);_(this,"calledByEntry",[]);_(this,"successCalls",[]);_(this,"errorCalls",[]);_(this,"internalCalls",[]);_(this,"project");_(this,"errors",[]);_(this,"parent");_(this,"detachedDependents",{});_(this,"knownVersions",null);_(this,"activeVersion",!1);_(this,"initialized",!1);_(this,"startedInitialization",!1);_(this,"suggestion",!1);_(this,"_codeNativeValueValidation",null);this.initialData=r,this.project=a,this.id=r.id,this.x=r.x,this.y=r.y,this.catchesError=r.catchesError||!1}static new(r=null){return{id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||L().toISOString(),author:(r==null?void 0:r.author)||N.sessionAuthor,previousVersion:null,deleted:!1,type:f.VariableInstance,catchesError:!0,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(r,a){let o=a;if(r.parent){const V=J(r.parent);o=a.get(V)}const p=J(r.declaration),e=a.get(p),y=r.calledByEntry.map(V=>{const B=J(V);return a.get(B)}),v=r.calledBySuccess.map(V=>{const B=J(V);return a.get(B)}),E=r.calledByError.map(V=>{const B=J(V);return a.get(B)});let w=null;if(r.readsValue){const V=J(r.readsValue);w=a.get(V)}const A={id:r.id,version:N.UUID.uuid(),createdAt:L().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.VariableInstance,catchesError:r.catchesError||!1,declaration:e.toReference(),calledByEntry:y,calledBySuccess:v,calledByError:E,defaultValue:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:w,inputs:[],outputs:[],writesValues:[],error:null,x:0,y:0,parent:o},$=ne(A,a);return $.setParent(o,null),$}static validateGenerationTarget(r,a){let o=JSON.parse(JSON.stringify(r));const p=[],e=ti(o,{parent:{list:!1,types:[...Nr,f.Project],optional:!0},declaration:{list:!1,types:[f.VariableDeclaration]}},a);return o=e.modifiedData,p.push(...e.errors,...Vr(o)),{errors:p,modifiedData:o}}get codeName(){var r;return(r=this.declaration)==null?void 0:r.codeName}get codeNativeValueValidation(){var r;return this._codeNativeValueValidation||((r=this.declaration)==null?void 0:r.codeNativeValueValidation)||null}validateGeneratedUpdate(r){const a=[];let o=JSON.parse(JSON.stringify(r));const p=Zp(o,this);return o=p.modifiedData,a.push(...p.errors),r.parent&&a.push(new ae({id:`${this.id}--${k.InvalidParentUpdate}`,code:k.InvalidParentUpdate,severity:H.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.
84
+ `+p):a.stack=p}catch{}}throw a}}_request(u,r){typeof u=="string"?(r=r||{},r.url=u):r=u||{},r=fl(this.defaults,r);const{transitional:a,paramsSerializer:o,headers:p}=r;a!==void 0&&gy.assertOptions(a,{silentJSONParsing:Zn.transitional(Zn.boolean),forcedJSONParsing:Zn.transitional(Zn.boolean),clarifyTimeoutError:Zn.transitional(Zn.boolean)},!1),o!=null&&(Te.isFunction(o)?r.paramsSerializer={serialize:o}:gy.assertOptions(o,{encode:Zn.function,serialize:Zn.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),gy.assertOptions(r,{baseUrl:Zn.spelling("baseURL"),withXsrfToken:Zn.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let e=p&&Te.merge(p.common,p[r.method]);p&&Te.forEach(["delete","get","head","post","put","patch","common"],B=>{delete p[B]}),r.headers=yn.concat(e,p);const y=[];let v=!0;this.interceptors.request.forEach(function(F){typeof F.runWhen=="function"&&F.runWhen(r)===!1||(v=v&&F.synchronous,y.unshift(F.fulfilled,F.rejected))});const E=[];this.interceptors.response.forEach(function(F){E.push(F.fulfilled,F.rejected)});let w,A=0,$;if(!v){const B=[ej.bind(this),void 0];for(B.unshift.apply(B,y),B.push.apply(B,E),$=B.length,w=Promise.resolve(r);A<$;)w=w.then(B[A++],B[A++]);return w}$=y.length;let V=r;for(A=0;A<$;){const B=y[A++],F=y[A++];try{V=B(V)}catch(K){F.call(this,K);break}}try{w=ej.call(this,V)}catch(B){return Promise.reject(B)}for(A=0,$=E.length;A<$;)w=w.then(E[A++],E[A++]);return w}getUri(u){u=fl(this.defaults,u);const r=qx(u.baseURL,u.url,u.allowAbsoluteUrls);return Bx(r,u.params,u.paramsSerializer)}}Te.forEach(["delete","get","head","options"],function(u){_y.prototype[u]=function(r,a){return this.request(fl(a||{},{method:u,url:r,data:(a||{}).data}))}}),Te.forEach(["post","put","patch"],function(u){function r(a){return function(p,e,y){return this.request(fl(y||{},{method:u,headers:a?{"Content-Type":"multipart/form-data"}:{},url:p,data:e}))}}_y.prototype[u]=r(),_y.prototype[u+"Form"]=r(!0)});const Dy=_y;class JI{constructor(u){if(typeof u!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(p){r=p});const a=this;this.promise.then(o=>{if(!a._listeners)return;let p=a._listeners.length;for(;p-- >0;)a._listeners[p](o);a._listeners=null}),this.promise.then=o=>{let p;const e=new Promise(y=>{a.subscribe(y),p=y}).then(o);return e.cancel=function(){a.unsubscribe(p)},e},u(function(p,e,y){a.reason||(a.reason=new Nd(p,e,y),r(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(u){if(this.reason){u(this.reason);return}this._listeners?this._listeners.push(u):this._listeners=[u]}unsubscribe(u){if(!this._listeners)return;const r=this._listeners.indexOf(u);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const u=new AbortController,r=a=>{u.abort(a)};return this.subscribe(r),u.signal.unsubscribe=()=>this.unsubscribe(r),u.signal}static source(){let u;return{token:new JI(function(o){u=o}),cancel:u}}}const Mme=JI;function Bme(d){return function(r){return d.apply(null,r)}}function Ume(d){return Te.isObject(d)&&d.isAxiosError===!0}const WI={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};Object.entries(WI).forEach(([d,u])=>{WI[u]=d});const xme=WI;function ij(d){const u=new Dy(d),r=Ax(Dy.prototype.request,u);return Te.extend(r,Dy.prototype,u,{allOwnKeys:!0}),Te.extend(r,u,null,{allOwnKeys:!0}),r.create=function(o){return ij(fl(d,o))},r}const di=ij(SI);di.Axios=Dy,di.CanceledError=Nd,di.CancelToken=Mme,di.isCancel=Fx,di.VERSION=tj,di.toFormData=Ey,di.AxiosError=Ot,di.Cancel=di.CanceledError,di.all=function(u){return Promise.all(u)},di.spread=Bme,di.isAxiosError=Ume,di.mergeConfig=fl,di.AxiosHeaders=yn,di.formToJSON=d=>jx(Te.isHTMLForm(d)?new FormData(d):d),di.getAdapter=Qx.getAdapter,di.HttpStatusCode=xme,di.default=di;const jme=di;class sj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION,version:"1.0.0",description:"Number addition operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Addition);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const e=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)}).reduce((y,v)=>y+v,0);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class nj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION,version:"1.0.0",description:"Number subtraction operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Subtraction);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),[p,e]=o,y=p-e;return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class aj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION,version:"1.0.0",description:"Number multiplication operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Multiplication);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const e=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)}).reduce((y,v)=>y*v,1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class oj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION,version:"1.0.0",description:"Number division operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Division);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),[p,e]=o;if(e===0)throw new Error("Division by zero is not allowed");const y=p/e;return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class lj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER,version:"1.0.0",description:"Number remainder operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Remainder);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),[p,e]=o;if(e===0)throw new Error("Division by zero is not allowed");const y=p%e;return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class dj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION,version:"1.0.0",description:"Number exponentiation operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Zt.Exponentiation);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),[p,e]=o,y=Math.pow(p,e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class uj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER,version:"1.0.0",description:"Randomness generate random integer operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomInteger);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1],y=lye(p,e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class cj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT,version:"1.0.0",description:"Randomness generate random float operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomFloat);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=vx();return{value:Z.Success,error:null,results:[o]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class pj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL,version:"1.0.0",description:"Randomness generate random hexadecimal operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomHexadecimal);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0],e=Ex(p);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class fj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62,version:"1.0.0",description:"Randomness generate random base62 operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomBase62);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0],e=Tx(p);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class hj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64,version:"1.0.0",description:"Randomness generate random base64 operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomBase64);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0],e=uye(p);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class yj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC,version:"1.0.0",description:"Randomness generate random alphanumeric operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomAlphanumeric);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0],e=cye(p);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class mj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER,version:"1.0.0",description:"Generate identifier operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateIdentifier);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1],y=Ix(p,e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class vj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4,version:"1.0.0",description:"Generate UUID v4 operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateRandomUUIDv4);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=cl();return{value:Z.Success,error:null,results:[o]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Ej extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER,version:"1.0.0",description:"Generate short identifier operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{Me.log("Initializing Random Generate Short Identifier Module");const a=r.find(o=>o.contextType===be.Logic);if(a){Me.log("Project state found, setting up operation");const o=a.get(_e.GenerateShortIdentifier);o?(Me.log("Operation found, setting autoexecutable and implementation"),o.autoexecutable=!0,o.implementation=this.module.main):Me.warn("Operation generate-short-identifier not found in project state")}else Me.warn("Project state not found in contexts for Random Generate Short Identifier Module")},main:async(r,a)=>{try{const o=pye();return{value:Z.Success,error:null,results:[o]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Tj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN,version:"1.0.0",description:"Generate hexadecimal token operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(_e.GenerateHexadecimalToken);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=fye();return{value:Z.Success,error:null,results:[o]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Ij extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN,version:"1.0.0",description:"String join operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.Join);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],y=o.slice(1).join(p);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Aj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT,version:"1.0.0",description:"String split operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.Split);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1],y=p.split(e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class bj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST,version:"1.0.0",description:"String delete last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.DeleteLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.slice(0,-1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class wj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST,version:"1.0.0",description:"String delete first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.DeleteFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.slice(1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Rj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE,version:"1.0.0",description:"String reverse operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.Reverse);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.split("").reverse().join("");return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class gj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE,version:"1.0.0",description:"String to lower case operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ToLowerCase);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.toLowerCase();return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class _j extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE,version:"1.0.0",description:"String to upper case operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ToUpperCase);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.toUpperCase();return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Dj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_INDEX,version:"1.0.0",description:"String delete index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.DeleteIndex);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};if(e<0||e>=p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const y=p.slice(0,e)+p.slice(e+1);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Oj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_INDEX,version:"1.0.0",description:"String add index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.AddIndex);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};if(e<0||e>p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const v=p.slice(0,e)+y+p.slice(e);return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Cj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST,version:"1.0.0",description:"String replace first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ReplaceFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const v=p.replace(e,y);return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class $j extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST,version:"1.0.0",description:"String replace last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ReplaceLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(w=>{var A,$;return((A=w.value)==null?void 0:A.valueAsType)||(($=w.value)==null?void 0:$.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const v=p.lastIndexOf(e);if(v===-1)return{value:Z.Success,error:null,results:[p]};const E=p.slice(0,v)+p.slice(v).replace(e,y);return{value:Z.Success,error:null,results:[E]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Pj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_INDEX,version:"1.0.0",description:"String replace index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ReplaceIndex);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};if(e<0||e>=p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const v=p.slice(0,e)+y+p.slice(e+1);return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Nj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_SINGLE_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ReplaceSingleMatch);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const v=p.replace(e,y);return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Vj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES,version:"1.0.0",description:"String replace all matches operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.ReplaceAllMatches);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const v=p.split(e).join(y);return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Lj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM,version:"1.0.0",description:"String get index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.GetIndexItem);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const y=p.charAt(e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Mj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST,version:"1.0.0",description:"String get first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.GetFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.charAt(0);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Bj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST,version:"1.0.0",description:"String get last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.GetLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const e=p.charAt(p.length-1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Uj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF,version:"1.0.0",description:"String get index of operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.GetIndexOf);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const y=p.indexOf(e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class xj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND,version:"1.0.0",description:"String append operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.Append);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const y=p+e;return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class jj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND,version:"1.0.0",description:"String prepend operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Ge.Prepend);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const y=e+p;return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Gj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN,version:"1.0.0",description:"List join operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.Join);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const y=p.join(e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Fj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT,version:"1.0.0",description:"List split operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.Split);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No string provided or string is empty",results:[]};const y=p.split(e);return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Sj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE,version:"1.0.0",description:"List reverse operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.Reverse);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const e=p.slice().reverse();return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Kj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST,version:"1.0.0",description:"List delete last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.DeleteLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const e=p.slice(0,-1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class kj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST,version:"1.0.0",description:"List delete first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.DeleteFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const e=p.slice(1);return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class qj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_INDEX,version:"1.0.0",description:"List add index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.AddIndex);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};if(e<0||e>p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const v=[...p.slice(0,e),y,...p.slice(e)];return{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Zj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_INDEX,version:"1.0.0",description:"List replace index operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.ReplaceIndex);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(E=>{var w,A;return((w=E.value)==null?void 0:w.valueAsType)||((A=E.value)==null?void 0:A.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};if(e<0||e>=p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const v=[...p];return v[e]=y,{value:Z.Success,error:null,results:[v]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Hj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST,version:"1.0.0",description:"List replace first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.ReplaceFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(w=>{var A,$;return((A=w.value)==null?void 0:A.valueAsType)||(($=w.value)==null?void 0:$.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const v=p.indexOf(e);if(v===-1)return{value:Z.Success,error:null,results:[p]};const E=[...p];return E[v]=y,{value:Z.Success,error:null,results:[E]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Jj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST,version:"1.0.0",description:"List replace last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.ReplaceLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(w=>{var A,$;return((A=w.value)==null?void 0:A.valueAsType)||(($=w.value)==null?void 0:$.value)}),p=o[0],e=o[1],y=o[2];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const v=p.lastIndexOf(e);if(v===-1)return{value:Z.Success,error:null,results:[p]};const E=[...p];return E[v]=y,{value:Z.Success,error:null,results:[E]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Wj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM,version:"1.0.0",description:"List get index item operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.GetIndexItem);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};if(e<0||e>=p.length)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Index out of bounds",results:[]};const y=p[e];return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Yj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST,version:"1.0.0",description:"List get first operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.GetFirst);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const e=p[0];return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class zj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST,version:"1.0.0",description:"List get last operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.GetLast);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const e=p[p.length-1];return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Xj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND,version:"1.0.0",description:"List append operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.Append);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const y=[...p,e];return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class Qj extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND,version:"1.0.0",description:"List prepend operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(Fe.Prepend);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[0],e=o[1];if(!p||p.length===0)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list provided or list is empty",results:[]};const y=[e,...p];return{value:Z.Success,error:null,results:[y]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class e3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_PARALLEL,version:"1.0.0",description:"Execution parallel operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(tr.Parallel);o&&(o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(A=>{var $,V;return(($=A.value)==null?void 0:$.valueAsType)||((V=A.value)==null?void 0:V.value)})[0];if(!p)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list of action entities provided",results:[]};if(!Array.isArray(p))return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Invalid input value. Expected a list of action entities",results:[]};const y=this.extensionsRegistry.requestContexts(this,[be.Editor])[0],E=p.map(A=>{const $=new mn(y.logic,[A],A,null,this.extensionsRegistry);return $.inheritValuesFromContext(y),$}).map(A=>A.execute()),w=await Promise.all(E);return{value:Z.Success,error:null,results:[w]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class t3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_SEQUENTIAL,version:"1.0.0",description:"Execution sequential operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(tr.Sequential);o&&(o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)})[0];if(!p)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No list of action entities provided",results:[]};if(!Array.isArray(p))return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Invalid input value. Expected a list of action entities",results:[]};const e=[];for(let y=0;y<p.length;y++){const v=p[y],w=this.extensionsRegistry.requestContexts(this,[be.Editor])[0],A=new mn(w.logic,[v],v,null,this.extensionsRegistry);A.inheritValuesFromContext(w);const $=await A.execute();e.push($)}return{value:Z.Success,error:null,results:[e]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class r3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT,version:"1.0.0",description:"Execution wait operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(tr.Wait);o&&(o.implementation=this.module.main)}},main:async(r,a)=>{try{const p=a.map(e=>{var y,v;return((y=e.value)==null?void 0:y.valueAsType)||((v=e.value)==null?void 0:v.value)})[0];return typeof p!="number"||p<0?{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Invalid wait time provided",results:[]}:(await new Promise(e=>setTimeout(e,p)),{value:Z.Success,error:null,results:[]})}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class i3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CREATE_NEW_INSTANCE,version:"1.0.0",description:"Entity create new instance operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(pr.CreateNewInstance);o&&(o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(w=>{var A,$;return((A=w.value)==null?void 0:A.valueAsType)||(($=w.value)==null?void 0:$.value)}),p=o[0];if(!p)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No entity template provided",results:[]};if(!(p instanceof Qn))return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Invalid entity template value provided",results:[]};const e=o[1]||{},v=Vi(p).map(w=>w.name);let E=e;if(v.includes(Le.PERSISTED_ENTITY)){const w=p.properties.find($=>{var V;return((V=$.implements)==null?void 0:V.id)===he["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id});if(!w)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"No database property found in entity",results:[]};if(!w.getDefaultValue())return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:"Database property has no database as entity as default value",results:[]}}return{value:Z.Success,error:null,results:[E]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class s3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY,version:"1.0.0",description:"Entity validate operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(pr.Validate);o&&(o.autoexecutable=!0,o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(y=>{var v,E;return((v=y.value)==null?void 0:v.valueAsType)||((E=y.value)==null?void 0:E.value)});Me.log("Inputs for entity validation: ",o);const e=rT(o[1]).safeParse(o[0]);return e.success?{value:Z.Success,error:null,results:[o[0]]}:{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:e.error.errors,results:[]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class n3 extends rt{constructor(){super(...arguments);_(this,"manifest",{id:Qe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST,version:"1.0.0",description:"HTTP request operation implementation module",initPriority:We.High,permissions:[Xe.All],contexts:[be.Logic]});_(this,"module",{init:r=>{const a=r.find(o=>o.contextType===be.Logic);if(a){const o=a.get(yi.HttpRequest);o&&(o.implementation=this.module.main)}},main:async(r,a)=>{try{const o=a.map(v=>{var E,w;return((E=v.value)==null?void 0:E.valueAsType)||((w=v.value)==null?void 0:w.value)}),p=o[3]||{},e={method:o[0],url:o[1],params:o[2],headers:p,data:o[4]};Me.log("Axios request config: ",e);const y=await jme(e);return{value:Z.Success,error:null,results:[y.status,y.headers,y.data]}}catch(o){return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,error:o,results:[]}}}})}}class YI extends NI{constructor(u,r,a=r.projectId){super(u,be.Editor),this._editor=r,this.id=a}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 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 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(u){this._editor.undoableStackValueIndex=u}get PROJECT_NOTIFICATIONS_CHANNEL(){return this._editor.PROJECT_NOTIFICATIONS_CHANNEL}getAccessToken(){return this._editor.getAccessToken()}removeValueByOwnerId(u){return this._editor.removeValueByOwnerId(u)}removeValue(u){return this._editor.removeValue(u)}undo(){return this._editor.undo()}redo(){return this._editor.redo()}initTest(u,r){return this._editor.initTest(u,r)}removeTest(){return this._editor.removeTest()}async copyEntities(u){return this._editor.copyEntities(u)}resolveInitialChildrenPositions(u,r,a){return this._editor.resolveInitialChildrenPositions(u,r,a)}publish(){return this._editor.publish()}loadActivePublication(u){return this._editor.loadActivePublication(u)}requestActiveDynamicValue(u){return this._editor.requestActiveDynamicValue(u)}}function Gme(d,u){return u instanceof YI?u:new YI(d,u)}function Fme(d){d.register(new mx(d)),d.register(new yx(d)),d.register(new cx(d)),d.register(new fx(d)),d.register(new hx(d)),d.register(new px(d)),d.register(new sj(d)),d.register(new nj(d)),d.register(new aj(d)),d.register(new lj(d)),d.register(new oj(d)),d.register(new dj(d)),d.register(new uj(d)),d.register(new cj(d)),d.register(new pj(d)),d.register(new fj(d)),d.register(new hj(d)),d.register(new yj(d)),d.register(new mj(d)),d.register(new vj(d)),d.register(new Ej(d)),d.register(new Tj(d)),d.register(new Ij(d)),d.register(new Aj(d)),d.register(new bj(d)),d.register(new wj(d)),d.register(new Rj(d)),d.register(new gj(d)),d.register(new _j(d)),d.register(new Dj(d)),d.register(new Oj(d)),d.register(new Cj(d)),d.register(new $j(d)),d.register(new Pj(d)),d.register(new Nj(d)),d.register(new Vj(d)),d.register(new Lj(d)),d.register(new Mj(d)),d.register(new Bj(d)),d.register(new Uj(d)),d.register(new xj(d)),d.register(new jj(d)),d.register(new Gj(d)),d.register(new Fj(d)),d.register(new Sj(d)),d.register(new Kj(d)),d.register(new kj(d)),d.register(new qj(d)),d.register(new Zj(d)),d.register(new Hj(d)),d.register(new Jj(d)),d.register(new Wj(d)),d.register(new Yj(d)),d.register(new zj(d)),d.register(new Xj(d)),d.register(new Qj(d)),d.register(new e3(d)),d.register(new t3(d)),d.register(new r3(d)),d.register(new i3(d)),d.register(new s3(d)),d.register(new n3(d))}class a3{constructor(u=new gc){_(this,"extensionsRegistry",new Map);_(this,"initialized",new Set);_(this,"initializedContexts",new Set);_(this,"onResolveEditorContextCallback",()=>null);_(this,"onResolveProjectLogicContextCallback",()=>null);_(this,"onResolveGUIContextCallback",()=>null);_(this,"onResolveCompileContextCallback",()=>null);this.events=u,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(u){this.onResolveEditorContextCallback=u}onResolveProjectLogicContext(u){this.onResolveProjectLogicContextCallback=u}onResolveGUIContext(u){this.onResolveGUIContextCallback=u}onResolveCompileContext(u){this.onResolveCompileContextCallback=u}get extensionInOrder(){return Array.from(this.extensionsRegistry.values()).sort((u,r)=>(u.manifest.initPriority||We.Normal)-(r.manifest.initPriority||We.Normal))}async setup(){Fme(this),Me.log("Initializing extensions without context..."),this.initForReady()}requestContext(u){switch(u){case be.Editor:return this.onResolveEditorContextCallback();case be.Logic:return this.onResolveProjectLogicContextCallback();case be.GUI:return this.onResolveGUIContextCallback();case be.Compile:return this.onResolveCompileContextCallback();default:throw new Error(`Unknown context type: ${u}`)}}requestContexts(u,r=[]){const a=[];r.length===0&&(r=u.manifest.contexts);for(const o of r){const p=this.requestContext(o);p&&a.push(p)}return a}requestModule(u){const r=this.extensionsRegistry.get(u);if(r){if(r.module)return r.module;throw new Error(`Module ${u} is not registered properly.`)}throw new Error(`Unknown module: ${u}`)}register(u){this.extensionsRegistry.set(u.manifest.id,u)}async initAll(){var u,r;for(const a of this.extensionInOrder)if(a.module.init&&!this.initialized.has(a.manifest.id)){const o=a.manifest.contexts.map(p=>this.requestContext(p)).filter(p=>p!==null);o.length&&(await((r=(u=a.module).init)==null?void 0:r.call(u,o)),this.initialized.add(a.manifest.id))}else!a.module.init&&!this.initialized.has(a.manifest.id)&&this.initialized.add(a.manifest.id)}async initForReady(){Me.log("Initializing extensions for ready contexts...");for(const u of this.extensionInOrder)if(u.module.init&&!this.initialized.has(u.manifest.id)){Me.log("Initializing "+u.manifest.id+" extension...");const r=this.requestContexts(u);u.manifest.contexts.every(o=>!!r.find(p=>p.contextType===o))?(await u.module.init(r),this.initialized.add(u.manifest.id)):Me.warn(`Skipping initialization of ${u.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${u.manifest.contexts.join(", ")}`,`Available contexts: ${r.map(o=>o.contextType).join(", ")}`)}else!u.module.init&&!this.initialized.has(u.manifest.id)?(Me.log("Set "+u.manifest.id+" extension as initialized by default..."),this.initialized.add(u.manifest.id)):Me.log(`Skipping initialization of ${u.manifest.id} extension, already initialized or no init method defined.`)}async destroyAll(){for(const u of[...this.extensionInOrder].reverse())u.module.destroy&&await u.module.destroy();this.events.destroy()}on(u,r){this.events.on(u,r)}emit(u,...r){this.events.emit(u,...r)}off(u,r){this.events.off(u,r)}emitAsync(u,...r){return this.events.emitAsync(u,...r)}emitAsyncAll(u,...r){return this.events.emitAsyncAll(u,...r)}emitAsyncAllSettled(u,...r){return this.events.emitAsyncAllSettled(u,...r)}emitAsyncSequentially(u,...r){return this.events.emitAsyncSequentially(u,...r)}emitAsyncSequentiallyAll(u,...r){return this.events.emitAsyncSequentiallyAll(u,...r)}emitAsyncSequentiallyAllSettled(u,...r){return this.events.emitAsyncSequentiallyAllSettled(u,...r)}async contextAvailable(u){if(this.initializedContexts.has(u)){Me.warn(`Context ${u} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(u),u){case be.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case be.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}Me.log(`Context ${u} is now available. Initializing extensions for this context...`),await this.initForReady()}}let Oy=null;const zI={requestModule:d=>(Oy||(Oy=new a3,Oy.setup()),Oy.requestModule(d))},no={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var XI=(d=>(d.FinishedSuccess="finished-success",d.FinishedError="finished-error",d.Running="running",d.Paused="paused",d.Stopped="stopped",d.NotStarted="not-started",d))(XI||{});const o3={...zI};class mn extends gc{constructor(r,a,o,p=null,e=o3){super();_(this,"project");_(this,"entryPoint");_(this,"state","not-started");_(this,"events",new gc);_(this,"entities",[]);_(this,"parentExecution",null);_(this,"executing",[]);_(this,"executed",[]);_(this,"skipped",[]);_(this,"scheduled",[]);_(this,"localTestValues");_(this,"resolvedValues");_(this,"persistedExecutionResults");_(this,"lastExecutionResults");_(this,"onAddToSkippedListCallback",null);_(this,"onRemoveFromSkippedListCallback",null);_(this,"onAddEntityCallback",null);_(this,"onRemoveEntityCallback",null);_(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=a,this.entryPoint=o,this.project=r,this.parentExecution=p,this.localTestValues=new vc(N.UUID.uuid(),this.project),this.resolvedValues=new vc(N.UUID.uuid(),this.project),this.persistedExecutionResults=new vc(N.UUID.uuid(),this.project),this.lastExecutionResults=new vc(N.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults}}skip(r){this.hasEntity(r)&&(this.removeFromScheduledList(r),!this.skipped.includes(r)&&(this.skipped.push(r),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(r),wi.includes(r.type)&&dt(r).forEach(a=>this.skip(a))))}async schedule(r,a,o){if(this.hasExecuted(r))return null;if(Dt.includes(r.type))return this.executeBranch(r,o,a);if(xi.includes(r.type)){if(r.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(r,o,a);this.scheduled.includes(r)||this.scheduled.push(r)}return null}mergeExernalValuesWithInternalInputs(r,a){const o=[];return[...sr,...Dt].includes(a.type)?o.push(...a.inputs):hr.includes(a.type)&&o.push(...a.outputs),o.map(e=>{var v;let y=r.find(E=>E.valueOwner.id===e.id);if(y)return y;if(!y&&Dt.includes(a.type)&&(y=r.find(E=>{var w;return((w=E.valueOwner.declaration)==null?void 0:w.id)===e.id})),y){const E=(v=y.value)==null?void 0:v.clone(null);return E==null||E.setStandaloneParent(e),{...y,valueOwner:e,value:E||null,inheritanceLink:{sources:[y],target:e}}}return un.includes(e.type)?py(e,this.valueResolutionContext):ll(e,this.valueResolutionContext)}).reduce((e,y)=>{const v=fn(y==null?void 0:y.valueOwner,this.project),E=y?[y]:[];return v.forEach(w=>{var V,B,F;if(w.id===(y==null?void 0:y.valueOwner.id))return;const A=lt(w.getDataType(null),w,this.project);A==null||A.metaSync({value:(V=y==null?void 0:y.value)==null?void 0:V.value},null),A==null||A.setValueAsTypeList(((B=y==null?void 0:y.value)==null?void 0:B.valueAsTypeList)||null),A==null||A.setValueAsTypeSingle(((F=y==null?void 0:y.value)==null?void 0:F.valueAsTypeSingle)||null);const $={...y,valueOwner:w,value:A};E.push($)}),[...e,...E]},[]).sort((e,y)=>e.valueOwner.index-y.valueOwner.index)}inheritValuesFromContext(r){this.localTestValues=r.localTestValues,this.resolvedValues=r.resolvedValues,this.persistedExecutionResults=r.persistedExecutionResults}async executeInternalCall(r,a,o,p={}){var y,v;const e={...no,...p};try{let E={value:Z.Success,error:null,results:[]};if(a.sort((w,A)=>w.valueOwner.index-A.valueOwner.index),Object.values(Wr).includes(r.declaration.id)){const w=this.parentContext.requestModule(Cd+r.declaration.id).main;w?E=await w(r,a):Me.warn(`No implementation found for built-in function: ${r.declaration.id}`)}else{debugger;E=await this.executeDetachedFullFunctionDeclarationLogic(r.declaration,a,o,e);debugger;const w=r.outputs.map($=>{var q,ie,W,de;const V=[...$.declaration.getCounterparts(),$.declaration],B=E.results.find(Q=>V.some(X=>Q.valueOwner.id===(X==null?void 0:X.id))),F=$==null?void 0:$.getDataType(null),K=lt(F,$,o);return F!=null&&F.asType?Array.isArray((q=B==null?void 0:B.value)==null?void 0:q.valueAsType)?K==null||K.setValueAsTypeList((ie=B==null?void 0:B.value)==null?void 0:ie.valueAsTypeList):K==null||K.setValueAsTypeSingle(((W=B==null?void 0:B.value)==null?void 0:W.valueAsType)||null):K==null||K.metaSync({value:(de=B==null?void 0:B.value)==null?void 0:de.value},null),{valueOwner:$,type:Ae.ExecutionResult,inheritanceLink:null,value:K}});let A=null;debugger;if(E.error){Me.warn("Raw error executing entity: ",E.error);const $=(y=r.error)==null?void 0:y.getDataType(null),V=lt($||null,r.error,o);$!=null&&$.asType?V==null||V.setValueAsTypeSingle(E.error):V==null||V.metaSync({value:E.error},null),A={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:V}}return{value:E.value,entity:r,error:A,results:w}}return{...E,entity:r}}catch(E){Me.warn("Internal call execution error: ",E);let w=null;if(r.error){const A=(v=r.error)==null?void 0:v.getDataType(null),$=lt(A,r.error,o);A!=null&&A.asType?$==null||$.setValueAsTypeSingle(E):$==null||$.metaSync({value:E},null),w={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:$}}return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:w,results:[]}}}static async executeOperation(r,a,o){var p,e;try{let y={value:Z.Success,error:null,results:[]};a.sort((w,A)=>w.valueOwner.index-A.valueOwner.index),r.declaration.implementation&&(y=await r.declaration.implementation(r,a));const v=r.outputs.map((w,A)=>{const $=w==null?void 0:w.getDataType(null),V=lt($,w,o);return $!=null&&$.asType?V==null||V.setValueAsTypeSingle(y.results[A]):V==null||V.metaSync({value:y.results[A]},null),{valueOwner:w,type:Ae.ExecutionResult,inheritanceLink:null,value:V}});let E=null;if(y.error&&r.error){Me.warn("Raw error executing entity: ",y.error);const w=((p=r.error)==null?void 0:p.getDataType(null))||null,A=lt(w,r.error,o);w!=null&&w.asType?A==null||A.setValueAsTypeSingle(y.error):A==null||A.metaSync({value:y.error},null),E={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:A}}return{value:y.value,entity:r,error:E,results:v}}catch(y){Me.warn("Operation execution error: ",y);let v=null;if(r.error){const E=(e=r.error)==null?void 0:e.getDataType(null),w=lt(E,r.error,o);E!=null&&E.asType?w==null||w.setValueAsTypeSingle(y):w==null||w.metaSync({value:y},null),v={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:w}}return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:v,results:[]}}}async executeSearch(r,a,o){var p;try{let e={value:Z.Success,error:null,results:[]};const y=r.outputs[0];if(!y)return{value:Z.Success,entity:r,error:null,results:[]};let v={value:null,valueOwner:y,type:Ae.ExecutionResult,inheritanceLink:null};const E=await this.parentContext.requestModule(Qe.SEARCH_NODE_IMPLEMENTATION).main(r,a),w=y==null?void 0:y.getDataType(null),A=lt(w,y,o);return A==null||A.metaSync({value:E.data},null),v.value=A,{value:e.value,entity:r,error:null,results:[v]}}catch(e){if(Me.warn(`Search node execution error: ${e}`),!r.error)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:null,results:[]};const y=(p=r.error)==null?void 0:p.getDataType(null),v=lt(y,r.error,o);return v==null||v.metaSync({value:e},null),{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:{valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:v},results:[]}}}async executeLoop(r,a,o,p={}){var y,v;const e={...no,...p};try{let E={value:Z.Success,error:null,results:[]};const w=a.map(K=>{var q,ie;return((q=K==null?void 0:K.value)==null?void 0:q.valueAsType)||((ie=K==null?void 0:K.value)==null?void 0:ie.value)});let A={};r.getUniqueReturnDeclarations().forEach(K=>{const q=r.body.inputs.find(Q=>Y(Q,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(K)),ie=K==null?void 0:K.getDataType(null),W=lt(ie,q,o);ie!=null&&ie.asType?W==null||W.setValueAsTypeList([]):W==null||W.metaSync({value:[]},null),this.lastExecutionResults.writeValue(q,W);const de={value:W,valueOwner:q,type:Ae.ExecutionResult,inheritanceLink:null};A[q.id]=de});let V={value:Z.Success,entity:r.body,error:null,results:[]};switch(r.declaration.id){case he.loop["counted-loop"].id:{const K=w[0];let q=1;for(;q<=K&&q<=50;){const ie=r.body.inputs.map(de=>{if(de===r.currentIterationNumberArgumentDeclaration){const Q=r.currentIterationNumberArgumentDeclaration.getDataType(null),ce=vl(Q),X=this.lastExecutionResults.readValue(de.id);if(X){X.metaSync({value:q},null),this.lastExecutionResults.writeValue(de,X);const ue={value:X,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null};return A[de.id]=ue,ue}const z={id:N.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:q,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:de.toReference()},pe=dr(z,o);this.lastExecutionResults.writeValue(de,pe);const te={value:pe,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null};return A[de.id]=te,te}else return A[de.id]}).filter(de=>!!de),W=await this.executeFullFunctionDeclarationLogic(r.body,ie,e);if(V=W,V.results.forEach(de=>{var z,pe,te,ue;if(de.valueOwner.type!==f.ReturnDeclaration)return;const Q=r.body.inputs.find(Ie=>Y(Ie,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(de.valueOwner)),X=[...((pe=(z=A==null?void 0:A[Q.id])==null?void 0:z.value)==null?void 0:pe.value)||[],((te=de==null?void 0:de.value)==null?void 0:te.value)||null];(ue=A[Q.id].value)==null||ue.metaSync({value:X},null),this.lastExecutionResults.writeValue(Q,A[Q.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(W.value))break;q++}break}case he.loop["manual-flow-loop"].id:{let K=1;for(;K<=50;){const q=r.body.inputs.map(W=>{if(W===r.currentIterationNumberArgumentDeclaration){const de=this.lastExecutionResults.readValue(W.id);if(de){de.metaSync({value:K},null),this.lastExecutionResults.writeValue(W,de);const z={value:de,valueOwner:W,type:Ae.ExecutionResult,inheritanceLink:null};return A[W.id]=z,z}const Q=r.currentIterationNumberArgumentDeclaration.getDataType(null),ce=lt(Q,W,o);return ce==null||ce.metaSync({value:K},null),this.lastExecutionResults.writeValue(W,ce),{value:ce,valueOwner:W,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[W.id]}).filter(W=>!!W),ie=await this.executeFullFunctionDeclarationLogic(r.body,q,e);if(V=ie,V.results.forEach(W=>{var X,z,pe;if(W.valueOwner.type!==f.ReturnDeclaration)return;const de=r.body.inputs.find(te=>Y(te,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(W.valueOwner)),ce=[...(X=A[de.id].value)==null?void 0:X.value,((z=W.value)==null?void 0:z.value)||null];(pe=A[de.id].value)==null||pe.metaSync({value:ce},null),this.lastExecutionResults.writeValue(de,A[de.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(ie.value))break;K++}break}case he.loop["list-loop"].id:{const K=w[0];let q=1;const ie=K;for(let W=0;W<ie.length;W++){const de=ie[W],Q=r.body.inputs.map(X=>{if(X===r.currentIterationNumberArgumentDeclaration){const z=this.lastExecutionResults.readValue(X.id);if(z)return z.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,z),{value:z,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const pe=r.currentIterationNumberArgumentDeclaration.getDataType(null),te=lt(pe,X,o);return te==null||te.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(X===r.currentValueArgumentDeclaration){const z=r.currentValueArgumentDeclaration.getDataType(null),pe=vl(z),te=this.lastExecutionResults.readValue(X.id);if(te)return te.metaSync({value:de},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const ue={id:N.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:pe,standaloneParent:X.toReference()},Ie=dr(ue,o);return this.lastExecutionResults.writeValue(X,Ie),{value:Ie,valueOwner:r.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[X.id]}).filter(X=>!!X),ce=await this.executeFullFunctionDeclarationLogic(r.body,Q,e);if(V=ce,V.results.forEach(X=>{var ue,Ie,Ue;if(X.valueOwner.type!==f.ReturnDeclaration)return;const z=r.body.inputs.find(Pe=>Y(Pe,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(X.valueOwner)),te=[...(ue=A[z.id].value)==null?void 0:ue.value,((Ie=X.value)==null?void 0:Ie.value)||null];(Ue=A[z.id].value)==null||Ue.metaSync({value:te},null),this.lastExecutionResults.writeValue(z,A[z.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(ce.value))break;q++}break}case he.loop["object-keys-loop"].id:{const K=w[0];let q=1;const ie=K?Object.keys(K):[];for(let W=0;W<ie.length;W++){const de=ie[W],Q=r.body.inputs.map(X=>{if(X===r.currentIterationNumberArgumentDeclaration){const z=this.lastExecutionResults.readValue(X.id);if(z)return z.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,z),{value:z,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const pe=r.currentIterationNumberArgumentDeclaration.getDataType(null),te=lt(pe,X,o);return te==null||te.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(X===r.currentValueArgumentDeclaration){const z=r.currentValueArgumentDeclaration.getDataType(null),pe=vl(z),te=this.lastExecutionResults.readValue(X.id);if(te)return te.metaSync({value:de},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const ue={id:N.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:pe,standaloneParent:X.toReference()},Ie=dr(ue,o);return this.lastExecutionResults.writeValue(X,Ie),{value:Ie,valueOwner:r.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[X.id]}).filter(X=>!!X),ce=await this.executeFullFunctionDeclarationLogic(r.body,Q,e);if(V=ce,V.results.forEach(X=>{var ue,Ie,Ue;if(X.valueOwner.type!==f.ReturnDeclaration)return;const z=r.body.inputs.find(Pe=>Y(Pe,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(X.valueOwner)),te=[...(ue=A[z.id].value)==null?void 0:ue.value,((Ie=X.value)==null?void 0:Ie.value)||null];(Ue=A[z.id].value)==null||Ue.metaSync({value:te},null),this.lastExecutionResults.writeValue(z,A[z.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(ce.value))break;q++}break}case he.loop["object-values-loop"].id:{const K=w[0];let q=1;const ie=K?Object.values(K):[];for(let W=0;W<ie.length;W++){const de=ie[W],Q=r.body.inputs.map(X=>{if(X===r.currentIterationNumberArgumentDeclaration){const z=this.lastExecutionResults.readValue(X.id);if(z)return z.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,z),{value:z,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const pe=r.currentIterationNumberArgumentDeclaration.getDataType(null),te=lt(pe,X,o);return te==null||te.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(X===r.currentValueArgumentDeclaration){const z=r.currentValueArgumentDeclaration.getDataType(null),pe=vl(z),te=this.lastExecutionResults.readValue(X.id);if(te)return te.metaSync({value:de},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const ue={id:N.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:pe,standaloneParent:X.toReference()},Ie=dr(ue,o);return this.lastExecutionResults.writeValue(X,Ie),{value:Ie,valueOwner:r.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[X.id]}).filter(X=>!!X),ce=await this.executeFullFunctionDeclarationLogic(r.body,Q,e);if(V=ce,V.results.forEach(X=>{var ue,Ie,Ue;if(X.valueOwner.type!==f.ReturnDeclaration)return;const z=r.body.inputs.find(Pe=>Y(Pe,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(X.valueOwner)),te=[...(ue=A[z.id].value)==null?void 0:ue.value,((Ie=X.value)==null?void 0:Ie.value)||null];(Ue=A[z.id].value)==null||Ue.metaSync({value:te},null),this.lastExecutionResults.writeValue(z,A[z.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(ce.value))break;q++}break}case he.loop["string-loop"].id:{const K=w[0];let q=1;const ie=K.split("");for(let W=0;W<ie.length;W++){const de=ie[W],Q=r.body.inputs.map(X=>{if(X===r.currentIterationNumberArgumentDeclaration){const z=this.lastExecutionResults.readValue(X.id);if(z)return z.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,z),{value:z,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const pe=r.currentIterationNumberArgumentDeclaration.getDataType(null),te=lt(pe,X,o);return te==null||te.metaSync({value:q},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:r.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(X===r.currentValueArgumentDeclaration){const z=r.currentValueArgumentDeclaration.getDataType(null),pe=vl(z),te=this.lastExecutionResults.readValue(X.id);if(te)return te.metaSync({value:de},null),this.lastExecutionResults.writeValue(X,te),{value:te,valueOwner:X,type:Ae.ExecutionResult,inheritanceLink:null};const ue={id:N.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:pe,standaloneParent:X.toReference()},Ie=dr(ue,o);return this.lastExecutionResults.writeValue(X,Ie),{value:Ie,valueOwner:r.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[X.id]}).filter(X=>!!X),ce=await this.executeFullFunctionDeclarationLogic(r.body,Q,e);if(V=ce,V.results.forEach(X=>{var ue,Ie,Ue;if(X.valueOwner.type!==f.ReturnDeclaration)return;const z=r.body.inputs.find(Pe=>Y(Pe,o)===Gi.fromReturnDeclarationToBodyArgumentDeclarationName(X.valueOwner)),te=[...(ue=A[z.id].value)==null?void 0:ue.value,((Ie=X.value)==null?void 0:Ie.value)||null];(Ue=A[z.id].value)==null||Ue.metaSync({value:te},null),this.lastExecutionResults.writeValue(z,A[z.id].value)}),[Z.CaughtError,Z.Break,Z.Return].includes(ce.value))break;q++}break}}let B=[];r.body.inputs.forEach(K=>{var ie;const q=A[K.id];if(q){const W=(ie=q.value)==null?void 0:ie.clone(null),de=r.outputs.find(Q=>Q.declaration&&Gi.fromLoopOutputDeclarationToBodyArgumentDeclarationName(Q.declaration)===Y(K,o));if(!de)return;B.push({valueOwner:de,type:Ae.ExecutionResult,inheritanceLink:null,value:W})}}),E={value:[Z.CaughtError,Z.Return].includes(V.value)?V.value:Z.Success,error:null,results:B};let F=null;if(E.error&&r.error){Me.warn("Raw error executing entity: ",E.error);const K=(y=r.error)==null?void 0:y.getDataType(null),q=lt(K||null,r.error,o);K!=null&&K.asType?q==null||q.setValueAsTypeSingle(E.error):q==null||q.metaSync({value:E.error},null),F={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:q}}return{value:E.value,entity:r,error:F,results:E.results}}catch(E){if(Me.warn("Error executing loop: ",E),r.error){const w=(v=r.error)==null?void 0:v.getDataType(null),A=lt(w,r.error,o);return w!=null&&w.asType?A==null||A.setValueAsTypeSingle(E):A==null||A.metaSync({value:E},null),{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:{valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:A},results:[]}}else return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:null,results:[]}}}async executeFunctionCall(r,a,o,p={}){var y,v;const e={...no,...p};try{let E={value:Z.Success,error:null,results:[]};E=await this.executeDetachedFullFunctionDeclarationLogic(r.declaration,a,o,e);const w=r.outputs.map($=>{var q,ie,W,de;const V=[...$.declaration.getCounterparts(),$.declaration],B=E.results.find(Q=>V.some(X=>Q.valueOwner.id===(X==null?void 0:X.id))),F=$==null?void 0:$.getDataType(null),K=lt(F,$,o);return F!=null&&F.asType?Array.isArray((q=B==null?void 0:B.value)==null?void 0:q.valueAsType)?K==null||K.setValueAsTypeList((ie=B==null?void 0:B.value)==null?void 0:ie.valueAsTypeList):K==null||K.setValueAsTypeSingle(((W=B==null?void 0:B.value)==null?void 0:W.valueAsType)||null):K==null||K.metaSync({value:(de=B==null?void 0:B.value)==null?void 0:de.value},null),{valueOwner:$,type:Ae.ExecutionResult,inheritanceLink:null,value:K}});let A=null;if(E.error&&r.error){Me.warn("Raw error executing entity: ",E.error);const $=(y=r.error)==null?void 0:y.getDataType(null),V=lt($||null,r.error,o);$!=null&&$.asType?V==null||V.setValueAsTypeSingle(E.error):V==null||V.metaSync({value:E.error},null),A={valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:V}}return{value:E.value,entity:r,error:A,results:w}}catch(E){if(!r.error)return{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:null,results:[]};const w=(v=r.error)==null?void 0:v.getDataType(null),A=lt(w,r.error,o);return w!=null&&w.asType?A==null||A.setValueAsTypeSingle(E):A==null||A.metaSync({value:E},null),{value:r.catchesError||r.errorCalls.length?Z.CaughtError:Z.UnhandledError,entity:r,error:{valueOwner:r.error,type:Ae.ExecutionResult,inheritanceLink:null,value:A},results:[]}}}async executeCondition(r,a){var p,e,y,v,E,w,A,$,V,B,F,K,q,ie,W,de,Q,ce,X,z,pe,te,ue,Ie,Ue,Pe,ge,$e,qe,xe,ot,Rt,ur,Ar,Mr,Xr,ci,Es,Bs,wn,Us,pi,Ts,Rn,ra,lf,wl,df;let o=!1;switch(r.declaration.id){case oi.Empty:{o=!((e=(p=a[0])==null?void 0:p.value)!=null&&e.value);break}case oi.NotEmpty:{o=!!((v=(y=a[0])==null?void 0:y.value)!=null&&v.value);break}case ut.Equal:{if([oe.String,oe.Number,oe.Boolean,oe.Null,oe.Enum,oe.Date,oe.UUID].includes((w=(E=a[0])==null?void 0:E.value)==null?void 0:w.name)){o=(($=(A=a[0])==null?void 0:A.value)==null?void 0:$.value)===((B=(V=a[1])==null?void 0:V.value)==null?void 0:B.value);break}if(((K=(F=a[0])==null?void 0:F.value)==null?void 0:K.name)===oe.KeyValue||((ie=(q=a[0])==null?void 0:q.value)==null?void 0:ie.name)===oe.Untyped){const ia=(de=(W=a[0])==null?void 0:W.value)==null?void 0:de.value,fi=(ce=(Q=a[1])==null?void 0:Q.value)==null?void 0:ce.value;o=JSON.stringify(ia)===JSON.stringify(fi);break}break}case ut.NotEqual:{if([oe.String,oe.Number,oe.Boolean,oe.Null,oe.Enum,oe.Date,oe.UUID].includes((z=(X=a[0])==null?void 0:X.value)==null?void 0:z.name)){o=((te=(pe=a[0])==null?void 0:pe.value)==null?void 0:te.value)!==((Ie=(ue=a[1])==null?void 0:ue.value)==null?void 0:Ie.value);break}if(((Pe=(Ue=a[0])==null?void 0:Ue.value)==null?void 0:Pe.name)===oe.Untyped||(($e=(ge=a[0])==null?void 0:ge.value)==null?void 0:$e.name)===oe.KeyValue){const ia=(xe=(qe=a[0])==null?void 0:qe.value)==null?void 0:xe.value,fi=(Rt=(ot=a[1])==null?void 0:ot.value)==null?void 0:Rt.value;o=JSON.stringify(ia)!==JSON.stringify(fi);break}break}case ut.MoreThanOrEqual:{o=((Ar=(ur=a[0])==null?void 0:ur.value)==null?void 0:Ar.value)>=((Xr=(Mr=a[1])==null?void 0:Mr.value)==null?void 0:Xr.value);break}case ut.MoreThan:{o=((Es=(ci=a[0])==null?void 0:ci.value)==null?void 0:Es.value)>((wn=(Bs=a[1])==null?void 0:Bs.value)==null?void 0:wn.value);break}case ut.LessThanOrEqual:{o=((pi=(Us=a[0])==null?void 0:Us.value)==null?void 0:pi.value)<=((Rn=(Ts=a[1])==null?void 0:Ts.value)==null?void 0:Rn.value);break}case ut.LessThan:{o=((lf=(ra=a[0])==null?void 0:ra.value)==null?void 0:lf.value)<((df=(wl=a[1])==null?void 0:wl.value)==null?void 0:df.value);break}case Kr.And:{o=(await Promise.all(r.andChildrenGroup.map(async fi=>{const zd=this.mergeExernalValuesWithInternalInputs(a,fi);return(await this.executeCondition(fi,zd)).value===Z.Success}))).every(fi=>fi);break}case Kr.Or:{o=(await Promise.all(r.orChildrenGroup.map(async fi=>{const zd=this.mergeExernalValuesWithInternalInputs(a,fi);return(await this.executeCondition(fi,zd)).value===Z.Success}))).some(fi=>fi);break}}return{value:o?Z.Success:Z.CaughtError,entity:r,error:null,results:[]}}async executeDetachedFullFunctionDeclarationLogic(r,a,o,p={}){const e={...no,...p,onBeforeEntityExecution:(E,w,A)=>{var $;return(($=p==null?void 0:p.onBeforeEntityExecution)==null?void 0:$.call(p,E,w,{...A,detached:!0}))||Promise.resolve()},onEntityExecuted:(E,w,A)=>{var $;return(($=p==null?void 0:p.onEntityExecuted)==null?void 0:$.call(p,E,w,{...A,detached:!0}))||Promise.resolve()}},y=new mn(o,[r,...Dm(r)],r,this,this.parentContext);return y.inheritValuesFromContext(this),await y.execute(e,a)}async executeFullFunctionDeclarationLogic(r,a,o={}){const p={...no,...o},e=Dm(r);e.forEach(A=>{this.addEntity(A)}),e.reduce((A,$)=>hr.includes($.type)?[...A,...$.outputs]:sr.includes($.type)&&$.type!==f.Condition?[...A,...$.outputs,...$.inputs]:$.type===f.Condition?[...A,...$.inputs]:A,[]).forEach(A=>{this.lastExecutionResults.removeValue(A.id)});const v=await this.executeBranch(r,p,a),w=r.getUniqueReturnDeclarations().reduce((A,$)=>{const V=v==null?void 0:v.results.find(B=>B.valueOwner.id===$.id);return V?[...A,V]:A},[]);return{...v||{},value:(v==null?void 0:v.value)||Z.Success,entity:r,error:(v==null?void 0:v.error)||null,results:w}}static async executeEntryPointEntity(r,a){return{value:Z.Success,entity:r,error:null,results:a}}static async executeVariable(r,a){return{value:Z.Success,entity:r,error:null,results:[a]}}static async executeReturnStatement(r,a){return{value:r.throws?Z.CaughtError:Z.Return,entity:r,error:null,results:a}}static async executeContinueStatement(r,a){return{value:Z.Continue,entity:r,error:null,results:a}}static async executeBreakStatement(r,a){return{value:Z.Break,entity:r,error:null,results:a}}mergeValues(r,a){const o=[];for(let p=0;p<a.length;p++)r!=null&&r[p]?o.push(r[p]):o.push(a[p]);return o}async executeEntity(r,a=[],o={}){var y,v,E,w,A,$,V,B,F,K,q,ie,W,de,Q,ce,X;const p={...no,...o},e={detached:!1};switch(r.type){case f.Condition:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((y=p.onBeforeEntityExecution)==null?void 0:y.call(p,r,z,e)),this.executeCondition(r,z)}case f.InternalCall:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((v=p.onBeforeEntityExecution)==null?void 0:v.call(p,r,z,e)),this.executeInternalCall(r,z,this.project)}case f.Operation:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((E=p.onBeforeEntityExecution)==null?void 0:E.call(p,r,z,e)),mn.executeOperation(r,z,this.project)}case f.VariableInstance:case f.VariableDeclaration:{let z=py(r,this.valueResolutionContext);const pe=Ni(r),te=pe.getDataType(null);if(te!=null&&te.isObject()){let Ue={};if(((w=te==null?void 0:te.entity)==null?void 0:w.type)===f.DefinitionEntity&&(Ue={...Ue,...te.entity.getActiveRawDefaultValue()}),z!=null&&z.value)Tr((A=z==null?void 0:z.value)==null?void 0:A.value)&&(Ue={...Ue,...($=z==null?void 0:z.value)==null?void 0:$.value}),z==null||z.value.metaSync({value:Ue},null);else{const Pe=lt(te,r,this.project);Pe==null||Pe.metaSync({value:Ue},null),z={valueOwner:pe,type:Ae.ExecutionResult,inheritanceLink:null,value:Pe}}this.lastExecutionResults.writeValue(pe,z.value),pe.inputs.forEach(Pe=>{var ge;if(((ge=Pe.declaration)==null?void 0:ge.type)===f.Property&&Pe.declaration.static){const $e=this.lastExecutionResults.readValue(Pe.declaration.id),qe=Y(Pe,this.project),xe=xr(qe);if($e)$e.metaSync({value:Ue[xe]},null),this.lastExecutionResults.writeValue(Pe.declaration,$e);else{const ot=lt(Pe.getDataType(null),Pe,this.project);ot==null||ot.metaSync({value:Ue[xe]},null),this.lastExecutionResults.writeValue(Pe.declaration,ot)}}})}else this.lastExecutionResults.writeValue(pe,z==null?void 0:z.value);const ue=[],Ie=(V=z==null?void 0:z.value)!=null&&V.value&&Tr((B=z.value)==null?void 0:B.value)?((F=z.value)==null?void 0:F.value)||{}:{};return r.outputs.map(Ue=>{const Pe=xr(Y(Ue,this.project)),ge=Ie[Pe],$e=lt(Ue.getDataType(null),Ue,this.project);$e==null||$e.metaSync({value:ge},null);const qe={value:$e,valueOwner:Ue,type:Ae.ExecutionResult,inheritanceLink:z?{sources:[z],target:r}:null};ue.push(qe)}),z.type=Ae.ExecutionResult,{value:Z.Success,entity:r,error:null,results:[z,...ue]}}case f.FunctionCall:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((K=p.onBeforeEntityExecution)==null?void 0:K.call(p,r,z,e)),this.executeFunctionCall(r,z,this.project)}case f.FunctionDeclaration:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((q=p.onBeforeEntityExecution)==null?void 0:q.call(p,r,z,e)),mn.executeEntryPointEntity(r,z)}case f.Search:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((ie=p.onBeforeEntityExecution)==null?void 0:ie.call(p,r,z,e)),this.executeSearch(r,z,this.project)}case f.Loop:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((W=p.onBeforeEntityExecution)==null?void 0:W.call(p,r,z,e)),this.executeLoop(r,z,this.project,p)}case f.ReturnStatement:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((de=p.onBeforeEntityExecution)==null?void 0:de.call(p,r,z,e)),mn.executeReturnStatement(r,z)}case f.ContinueStatement:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((Q=p.onBeforeEntityExecution)==null?void 0:Q.call(p,r,z,e)),mn.executeContinueStatement(r,z)}case f.BreakStatement:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((ce=p.onBeforeEntityExecution)==null?void 0:ce.call(p,r,z,e)),mn.executeBreakStatement(r,z)}case f.GlobalEvent:{const z=this.mergeExernalValuesWithInternalInputs(a,r);return await((X=p.onBeforeEntityExecution)==null?void 0:X.call(p,r,z,e)),mn.executeEntryPointEntity(r,z)}default:throw new Error(`Entity type ${r==null?void 0:r.type} is not recognized for execution.`)}}storeLastExecutionValues(r){r.error&&r.error.valueOwner&&this.lastExecutionResults.writeValue(r.error.valueOwner,r.error.value),r.results.forEach(a=>{const o=fn(a.valueOwner,this.project);a.value?o.forEach(p=>{this.lastExecutionResults.writeValue(p,a.value)}):o.forEach(p=>{this.lastExecutionResults.removeValue(p.id)})})}async executeBranch(r,a={},o=[]){var E;const p={...no,...a},e={detached:!1};if(!this.hasEntity(r)||this.hasSkipped(r))return null;this.addToExecutingList(r),this.hasScheduled(r)&&this.removeScheduled(r);const v=await this.executeEntity(r,o,p);debugger;if(this.removeFromExecutingList(r),this.addToAlreadyExecutedList(r),this.storeLastExecutionValues(v),await((E=p.onEntityExecuted)==null?void 0:E.call(p,r,v,e)),v.value===Z.Success){const w=(r.successCalls||r.calls||[]).filter(F=>this.hasEntity(F));(r.errorCalls||[]).forEach(F=>{this.skip(F)});let $=[];const V=(await Promise.all(w.map(F=>this.schedule(F,v.results,p)))).filter(F=>!!F),B=V.filter(F=>!!F).find(F=>F.value===Z.CaughtError||F.value===Z.Return||F.value===Z.Break||F.value===Z.Continue);return B||($=[...$,...V],v)}else if(v.value===Z.CaughtError){const w=(r.errorCalls||[]).filter(F=>this.hasEntity(F));(r.successCalls||r.calls||[]).forEach(F=>{this.skip(F)});let $=[];const V=(await Promise.all(w.map(F=>this.schedule(F,v.results,p)))).filter(F=>!!F),B=V.filter(F=>!!F).find(F=>F.value===Z.CaughtError||F.value===Z.UnhandledError||F.value===Z.Return||F.value===Z.Break||F.value===Z.Continue);return B||($=[...$,...V],v)}else{if(v.value===Z.UnhandledError)return this.executing.forEach(w=>{this.skip(w)}),this.scheduled.forEach(w=>{this.skip(w)}),wi.includes(v.entity.type)&&dt(v.entity).forEach(w=>{this.skip(w)}),v;if(v.value===Z.Return)return v;if(v.value===Z.Break)return v;if(v.value===Z.Continue)return v}return v}async execute(r={},a=[]){const o={...no,...r};this.state="running";const p=await this.executeBranch(this.entryPoint,o,a);return this.state="finished-success",p}addEntity(r){var a;this.entities.includes(r)||(this.entities.push(r),(a=this.onAddEntityCallback)==null||a.call(this,r))}addEntities(r){r.forEach(a=>this.addEntity(a))}removeEntity(r){var a;if(r!==this.entryPoint){const o=this.entities.indexOf(r);o>-1&&(this.entities.splice(o,1),(a=this.onRemoveEntityCallback)==null||a.call(this,r))}}hasEntity(r){var p,e,y;if(this.entities.includes(r))return!0;if(((p=r.parent)==null?void 0:p.type)===f.FunctionDeclaration&&((y=(e=r.parent)==null?void 0:e.parent)==null?void 0:y.type)===f.DefinitionEntity)return this.entities.includes(r.parent);const a=fr(r);if(!a)return!1;const o=a.type===f.Loop&&r.parent===a.body?a.body:null;return o?this.entities.includes(o)||this.entities.includes(a):this.entities.includes(a)}removeScheduled(r){const a=this.scheduled.indexOf(r);a>-1&&this.scheduled.splice(a,1)}hasScheduled(r){return!!this.scheduled.includes(r)}hasSkipped(r){return!!this.skipped.includes(r)}hasExecuted(r){return!!this.executed.includes(r)}hasEntityWithId(r){const a=this.project.get(r);return a?this.hasEntity(a):!1}onAddToSkippedList(r){this.onAddToSkippedListCallback=r}onAbortExecution(r){this.onAbortExecutionCallback=r}onAddEntity(r){this.onAddEntityCallback=r}onRemoveFromSkippedList(r){this.onRemoveFromSkippedListCallback=r}onRemoveEntity(r){this.onRemoveEntityCallback=r}addToExecutingList(r){this.executing.includes(r)||this.executing.push(r)}addToScheduledList(r){this.scheduled.includes(r)||this.scheduled.push(r)}removeFromScheduledList(r){const a=this.scheduled.indexOf(r);a>-1&&this.scheduled.splice(a,1)}removeFromExecutingList(r){var o;const a=this.executing.indexOf(r);a>-1&&(this.executing.splice(a,1),(o=this.onAbortExecutionCallback)==null||o.call(this,r))}removeFromAlreadyExecutedList(r){const a=this.executed.indexOf(r);a>-1&&this.executed.splice(a,1)}removeFromSkippedList(r){var o;const a=this.skipped.indexOf(r);a>-1&&(this.skipped.splice(a,1),(o=this.onRemoveFromSkippedListCallback)==null||o.call(this,r))}addToAlreadyExecutedList(r){this.executed.includes(r)||this.executed.push(r)}addToSkippedList(r){var a;this.skipped.includes(r)||(this.skipped.push(r),(a=this.onAddToSkippedListCallback)==null||a.call(this,r))}}function Sme(d){var u,r;if(d.isList)return"list";if(((u=d.entity)==null?void 0:u.type)===f.DefinitionEntity)return"definition-entity";switch((r=d.entity)==null?void 0:r.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 Vs={[f.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[f.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[f.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[f.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[f.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[f.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[f.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[f.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[f.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[f.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[f.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[f.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[f.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[f.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[f.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[f.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[f.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[f.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[f.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[f.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[f.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[f.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[f.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[f.ReturnDeclaration]:{singular:"Output definition",plural:"Output definitions",shortSingular:"Output",shortPlural:"Outputs"},[f.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"},[f.DataType]:{singular:"Data type",plural:"Data types",shortSingular:"Data type",shortPlural:"Data types"},[f.LiteralValue]:{singular:"Literal value",plural:"Literal values",shortSingular:"Value",shortPlural:"Values"}};function QI(d){const u=Om(d);if(!u){const a=Hd(d);if(a.includes(Le.HTTP_ENDPOINT))return"HTTP endpoint";if(a.includes(Le.PERSISTED_ENTITY))return"Persisted entity";if(a.includes(Le.CRON_JOB))return"Scheduled execution";if(a.includes(Le.RELATIONAL_DATABASE))return"Relational database"}if(u){let a="Extension of "+Y(u,u.project)+" entity",o=Rd(a);const p=Hd(d);return p.includes(Le.HTTP_ENDPOINT)?"HTTP endpoint"+(o?", "+o:""):p.includes(Le.PERSISTED_ENTITY)?"Persisted entity"+(o?", "+o:""):p.includes(Le.CRON_JOB)?"Scheduled execution"+(o?", "+o:""):p.includes(Le.RELATIONAL_DATABASE)?"Relational database"+(o?", "+o:""):a}let r="";return d.abstract&&(r="Template "),d.static&&(r+=r?" single copy ":"Single copy "),r?r+"definition":"Definition"}function l3(d){return d.parent.type===f.DefinitionEntity||d.parent.type===f.InstalledProject?"Internal action of "+Y(d.parent,d.project):d.parent.type===f.Loop?"Action repeated on every iteration":"Internal action of entity"}function eA(d){return Ib(d)?l3(d):"Custom trigger"}function Kme(d){var u;switch(d.type){case f.DefinitionEntity:return QI(d);case f.FunctionDeclaration:return eA(d)}return(u=Vs[d.type])==null?void 0:u.singular}function kme(d){var u;switch(d.type){case f.DefinitionEntity:return QI(d);case f.FunctionDeclaration:return eA(d)}return(u=Vs[d.type])==null?void 0:u.singular}const tA=4e4,d3=280,qme=300,rA=65,Vd=32,Cy=39,u3=26,c3=49,$y=44,Zme=35,Py=52,iA=10,Ca=iA*2,Ny=38,Vy=90,sA=270,p3=tA/2+120,f3=tA/2+180;function h3(d){let r=Vd+$y+Ny+iA;const a=[...d.inputs];return a.length&&(r+=Ca,a.forEach(()=>{r+=u3})),{height:r,width:280}}function y3(d){let r=rA;const a=[];if([f.DefinitionEntity].includes(d.type)){const v=[...d.suggestedProperties||[],...d.properties||[]];v.length&&(r+=Ca,v.forEach(E=>{r+=E.static?c3:Cy}))}if([f.DefinitionEntity,f.InstalledProject,f.Loop].includes(d.type)){const v=[...(d==null?void 0:d.suggestedMethods)||[],...d.methods||[],...d.functions||[],...d.body?[d.body]:[]];v.length&&(r+=Ca,v.forEach(E=>{const w=h3(E);r+=w.height}))}sr.includes(d.type)?(Tt.includes(d.type)?a.push(...(d.usedInputs||[]).flatMap(v=>[v])||[]):a.push(...(d.inputs||[]).flatMap(v=>[v])||[]),d.error&&(r+=Py)):[f.ReturnStatement,f.BreakStatement,f.ContinueStatement].includes(d.type)?(a.push(...d.outputs||[]),d.throws&&(r+=Py)):d.type===f.Condition&&(a.push(d.inputs[0]),d.inputs[1]&&a.push(d.inputs[1]));const o=a.length;o&&(r+=o*Cy,r+=Ca);const p=[];if(d.type===f.FunctionDeclaration||d.type===f.GlobalEvent?p.push(...d.inputs||[]):sr.includes(d.type)&&(Tt.includes(d.type)?p.push(...d.usedOutputs||[]):p.push(...d.outputs||[])),Tt.includes(d.type)){d.readsValue&&(r+=Ca,r+=$y),d.writesValues.length&&(r+=Ca,r+=$y),d.internalCalls.length&&d.usedInternalCalls.forEach(()=>r+=Py+Ca);const v=d.getDataType(null);(!v||v.inferred)&&(r+=Ny)}const e=p.length;return e&&(r+=e*Cy,r+=Ca),[f.DefinitionEntity,f.FunctionDeclaration,f.ReturnStatement,f.BreakStatement,f.ContinueStatement].includes(d.type)&&(r+=Ny),{height:r,width:280}}function Cc(d){return`${d.split("-").map((a,o)=>o===0?a.charAt(0).toUpperCase()+a.slice(1):a.toLowerCase()).join(" ")}.`}function Hme(d){switch(d.code){case re.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case re.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case re.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case re.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case re.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case re.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case re.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case se.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case se.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case re.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case re.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case se.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case re.NoProperties:return"This entity has no properties, so it doesn't do anything";case re.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case re.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case re.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case re.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case re.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case re.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case re.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case re.PropertyImplementsNonAbstact:return"This property implements a non-template property";case re.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case re.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case re.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case re.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case re.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case se.InternalCallDeclarationIsNotFunctionDeclaration:return"This internal call is not an action";case se.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case se.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case se.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case se.UnreachableEntity:return"This entity is unreachable";case re.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";case re.AbstractEntityImplements:return"This template entity implements a non-template entity";case re.AbstractExtendingNonAbstractEntity:return"This template entity extends a non-template entity";case re.InvalidPropertiesCombination:return"This entity has an invalid combination of properties";case re.ExtendingNonInteractiveEntity:return"This entity extends a non-interactive entity";case re.ExtendsIncompatibleEntities:return"This entity extends incompatible entities";case re.ImplementingNonAbstractEntity:return"This entity implements a non-template entity";case re.ImplementsIncompatibleEntities:return"This entity implements incompatible entities";case re.LackingReturnStatementOnSomeBranches:return"This action is missing a termination on some branches";case re.LastCalledEntityMustBeReturnEntity:return"The last called entity in this action must be a termination node";case re.MissingRequiredValue:return"This action is missing a required value";case re.NoPrimaryKeyProperty:return"This entity has no primary key property";case re.NonAbstractExtendingAbstractEntity:return"This non-template entity extends a template entity";case re.NonStaticExtendingStaticEntity:return"This non-static entity extends a static entity";case re.NonStaticImplementingStaticEntity:return"This non-static entity implements a static entity";case re.StaticExtendingNonStaticEntity:return"This static entity extends a non-static entity";case re.StaticImplementingNonStaticEntity:return"This static entity implements a non-static entity";case re.VariableReadsValueAndInternalCall:return"This variable reads a value while being used to execute internal logic";case re.VariableWritesValuesAndInternalCall:return"This variable writes values while being used to execute internal logic";case se.InternalCallDeclarationNotInParentDatatypeEntity:return"This internal call declaration is not in the parent entity";case se.EmptyName:return"This entity has no name";case se.InvalidObjectStructure:return"This entity has an invalid structure";case se.LoopBodyFunctionOverwrite:return"This loop body action overwrites an action in the template entity with the same name";case se.MethodOverwritesBaseMethodWithSameImplementation:return"This action overwrites a base action with the same implementation";case se.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"This action overwrites an action in an extended entity with the same implementation";case se.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"This action overwrites an action in an implemented entity with the same implementation";case se.MissingCaller:return"This action is missing a caller";case se.NameAsResolvedCodeNameNotUniqueInScope:return"This entity has a name that is not unique in the scope of the code it is used in";case se.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"This entity name can only contain letters, numbers, underscores and spaces";case se.NameMustStartWithLetterOrUnderscore:return"This entity name must start with a letter or an underscore";case se.NoOverlapWithImplementedSignature:return"This action does not overlap with the implemented action signature";case se.PropertyOverwritesBasePropertyWithSameImplementation:return"This property overwrites a base property with the same implementation";case se.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an extended entity with the same implementation";case se.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an implemented entity with the same implementation";case se.ReaderWriterIncompatibleDataType:return"This reader/writer has an incompatible data type with the value it is reading/writing";case ta.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case ta.StatusCodeMustBeNumber:return"HTTP status code must be a number, between 100 and 599";case vs.UUIDMustBeString:return`UUID must be a string, eg: "${cl()}"`;case vs.UUIDMustNotContainSpaces:return`UUID must not contain spaces, eg: "${cl()}"`;case vs.UUIDMustBeValidFormat:return`UUID must be in a valid format. Eg: "${cl()}"`;case ki.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case ki.StringValueMustNotHaveDashes:return"This value must not contain dashes";case ki.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return Cc(d.code)}}function Jme(d){switch(d.code){case re.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case re.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case re.IncorrectEntityImplementation:return"Incorrect implementation";case re.IncorrectMethodImplementation:return"Incorrect action implementation";case re.IncorrectPropertyImplementation:return"Incorrect property implementation";case re.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case re.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case se.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case se.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case re.MissingMethodImplementation:return"Missing action";case re.MissingPropertyImplementation:return"Missing property";case se.NameNotUniqueInScope:return"Duplicate name";case re.NoProperties:return"No properties";case re.NonStaticPropertyInStaticEntity:return"Non-static property";case re.StaticEntityWithNonStaticProperties:return"Non-static properties";case re.ReadingFromIncompatibleType:return"Read from different type";case re.WritingToIncompatibleType:return"Write to different type";case re.ScopeWithoutLogic:return"No logic";case re.NonStaticPropertyImplementsStatic:return"Invalid static property";case re.PropertyImplementsIncompatibleType:return"Incompatible data type";case re.PropertyImplementsNonAbstact:return"Non-template property";case re.StaticPropertyImplementsNonStatic:return"Non-static property";case re.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case re.VariableHasInputsAndInternalCall:return"Bad internal call";case re.VariableHasOutputsAndInternalCall:return"Bad internal call";case re.VariableIsCalledAndHasInternalCall:return"Bad internal call";case se.InternalCallDeclarationIsNotFunctionDeclaration:return"Declaration not an action";case se.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case se.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case se.InternalCallParentMissingDataType:return"Parent has no data type";case se.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case se.UnreachableEntity:return"Unreachable entity";case re.DisconnectedCallableEntity:return"Disconnected entity";case re.AbstractEntityImplements:return"Abstract entity implements a non-template entity";case re.AbstractExtendingNonAbstractEntity:return"Abstract entity extends a non-template entity";case re.InvalidPropertiesCombination:return"Invalid properties combination";case re.ExtendingNonInteractiveEntity:return"Extending non-interactive entity";case re.ExtendsIncompatibleEntities:return"Extends incompatible entities";case re.ImplementingNonAbstractEntity:return"Implementing non-template entity";case re.ImplementsIncompatibleEntities:return"Implements incompatible entities";case re.LackingReturnStatementOnSomeBranches:return"Missing termination on some branches";case re.LastCalledEntityMustBeReturnEntity:return"Last called entity must be a termination node";case re.MissingRequiredValue:return"Missing required value";case re.NoPrimaryKeyProperty:return"No primary key property";case re.NonAbstractExtendingAbstractEntity:return"Non-template entity extending a template entity";case re.NonStaticExtendingStaticEntity:return"Non-static entity extending a static entity";case re.NonStaticImplementingStaticEntity:return"Non-static entity implementing a static entity";case re.StaticExtendingNonStaticEntity:return"Static entity extending a non-static entity";case re.StaticImplementingNonStaticEntity:return"Static entity implementing a non-static entity";case re.VariableReadsValueAndInternalCall:return"Variable reads value and has internal call";case re.VariableWritesValuesAndInternalCall:return"Variable writes values and has internal call";case se.EmptyName:return"Empty name";case se.InvalidObjectStructure:return"Invalid object structure";case se.LoopBodyFunctionOverwrite:return"Loop body action overwrites action with same name";case se.MethodOverwritesBaseMethodWithSameImplementation:return"Action overwrites base action with same implementation";case se.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case se.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case se.MissingCaller:return"Missing caller";case se.NameAsResolvedCodeNameNotUniqueInScope:return"Name not unique in scope";case se.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"Name can only contain letters, numbers, underscores and spaces";case se.NameMustStartWithLetterOrUnderscore:return"Name must start with letter or underscore";case se.NoOverlapWithImplementedSignature:return"No overlap with implemented signature";case se.PropertyOverwritesBasePropertyWithSameImplementation:return"Property overwrites base property with same implementation";case se.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case se.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case se.ReaderWriterIncompatibleDataType:return"Reader/writer incompatible data type";case ta.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case ta.StatusCodeMustBeNumber:return"HTTP status code must be a number";case vs.UUIDMustBeString:return"UUID must be a string";case vs.UUIDMustNotContainSpaces:return"UUID must not contain spaces";case vs.UUIDMustBeValidFormat:return"UUID must be in a valid format";case ki.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case ki.StringValueMustNotHaveDashes:return"This value must not contain dashes";case ki.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return Cc(d.code)}}function Wme(d){switch(d.code){case re.AbstractEntityWithNonAbstractMethods:return`${Y(d.entity,d.entity.project)} has non-template actions`;case re.AbstractEntityWithNonAbstractProperties:return`${Y(d.entity,d.entity.project)} has non-template properties`;case re.IncorrectEntityImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements template`;case re.IncorrectMethodImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements the template`;case re.IncorrectPropertyImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements the template`;case re.AbstractMethodInNonAbstractEntity:return`${Y(d.entity,d.entity.project)} can't be a template`;case re.AbstractPropertyInNonAbstractEntity:return`${Y(d.entity,d.entity.project)} can't be a template`;case se.MethodOverwritesOtherSiblingWithSameName:return`${Y(d.entity,d.entity.project)} overwrites action`;case se.PropertyOverwritesOtherSiblingWithSameName:return`${Y(d.entity,d.entity.project)} overwrites property`;case re.MissingMethodImplementation:return`${Y(d.entity,d.entity.project)} is missing action`;case re.MissingPropertyImplementation:return`${Y(d.entity,d.entity.project)} is missing property`;case se.NameNotUniqueInScope:return`${Y(d.entity,d.entity.project)} name is not unique`;case re.NoProperties:return`${Y(d.entity,d.entity.project)} has no properties`;case re.NonStaticPropertyInStaticEntity:return`${Y(d.entity,d.entity.project)} has non-static property`;case re.StaticEntityWithNonStaticProperties:return`${Y(d.entity,d.entity.project)} has non-static properties`;case re.ReadingFromIncompatibleType:return`${Y(d.entity,d.entity.project)} reads from different type`;case re.WritingToIncompatibleType:return`${Y(d.entity,d.entity.project)} writes to different type`;case re.ScopeWithoutLogic:return`${Y(d.entity,d.entity.project)} has no logic`;case re.NonStaticPropertyImplementsStatic:return`${Y(d.entity,d.entity.project)} has invalid static property`;case re.PropertyImplementsIncompatibleType:return`${Y(d.entity,d.entity.project)} has incompatible data type`;case re.PropertyImplementsNonAbstact:return`${Y(d.entity,d.entity.project)} has non-template property`;case re.StaticPropertyImplementsNonStatic:return`${Y(d.entity,d.entity.project)} has non-static property`;case re.VariableCallsOthersAndHasInternalCall:return`${Y(d.entity,d.entity.project)} has bad internal call`;case re.VariableHasInputsAndInternalCall:return`${Y(d.entity,d.entity.project)} has bad internal call`;case re.VariableHasOutputsAndInternalCall:return`${Y(d.entity,d.entity.project)} has bad internal call`;case re.VariableIsCalledAndHasInternalCall:return`${Y(d.entity,d.entity.project)} has bad internal call`;case se.InternalCallDeclarationIsNotFunctionDeclaration:return`${Y(d.entity,d.entity.project)} has declaration that is not an action`;case se.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${Y(d.entity,d.entity.project)} has declaration that is not found in parent`;case se.InternalCallParentDeclarationEntityInvalidType:return`${Y(d.entity,d.entity.project)} has invalid parent declaration type`;case se.InternalCallParentMissingDataType:return`${Y(d.entity,d.entity.project)}'s parent has no data type`;case se.InternalCallDeclarationNotInParentDatatypeEntity:return`${Y(d.entity,d.entity.project)} has declaration that is not in parent`;case se.UnreachableEntity:return`${Y(d.entity,d.entity.project)} is unreachable`;case re.DisconnectedCallableEntity:return`${Y(d.entity,d.entity.project)} is not executed by any entity`;case re.AbstractEntityImplements:return`${Y(d.entity,d.entity.project)} implements a non-template entity`;case re.AbstractExtendingNonAbstractEntity:return`${Y(d.entity,d.entity.project)} extends a non-template entity`;case re.InvalidPropertiesCombination:return`${Y(d.entity,d.entity.project)} has invalid properties combination`;case re.ExtendingNonInteractiveEntity:return`${Y(d.entity,d.entity.project)} extends a non-interactive entity`;case re.ExtendsIncompatibleEntities:return`${Y(d.entity,d.entity.project)} extends incompatible entities`;case re.ImplementingNonAbstractEntity:return`${Y(d.entity,d.entity.project)} implements a non-template entity`;case re.ImplementsIncompatibleEntities:return`${Y(d.entity,d.entity.project)} implements incompatible entities`;case re.LackingReturnStatementOnSomeBranches:return`${Y(d.entity,d.entity.project)} is missing termination on some branches`;case re.LastCalledEntityMustBeReturnEntity:return`${Y(d.entity,d.entity.project)}'s last called entity must be a termination node`;case re.MissingRequiredValue:return`${Y(d.entity,d.entity.project)} is missing a required value`;case re.NoPrimaryKeyProperty:return`${Y(d.entity,d.entity.project)} has no primary key property`;case re.NonAbstractExtendingAbstractEntity:return`${Y(d.entity,d.entity.project)} extends a template entity`;case re.NonStaticExtendingStaticEntity:return`${Y(d.entity,d.entity.project)} extends a static entity`;case re.NonStaticImplementingStaticEntity:return`${Y(d.entity,d.entity.project)} implements a static entity`;case re.StaticExtendingNonStaticEntity:return`${Y(d.entity,d.entity.project)} extends a non-static entity`;case re.StaticImplementingNonStaticEntity:return`${Y(d.entity,d.entity.project)} implements a non-static entity`;case re.VariableReadsValueAndInternalCall:return`${Y(d.entity,d.entity.project)} reads a value and has internal call`;case re.VariableWritesValuesAndInternalCall:return`${Y(d.entity,d.entity.project)} writes values and has internal call`;case se.EmptyName:return`${Vs[d.entity.type]} has no name`;case se.InvalidObjectStructure:return`${Y(d.entity,d.entity.project)} has invalid structure`;case se.LoopBodyFunctionOverwrite:return`${Y(d.entity,d.entity.project)}'s loop body action overwrites an action`;case se.MethodOverwritesBaseMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites base action`;case se.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another action with same implementation`;case se.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another action with same implementation`;case se.MissingCaller:return`${Y(d.entity,d.entity.project)} is missing a caller`;case se.NameAsResolvedCodeNameNotUniqueInScope:return`${Y(d.entity,d.entity.project)} has a name not unique in the scope`;case se.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${Y(d.entity,d.entity.project)} name can only contain letters, numbers, underscores and spaces`;case se.NameMustStartWithLetterOrUnderscore:return`${Y(d.entity,d.entity.project)} name must start with letter or underscore`;case se.NoOverlapWithImplementedSignature:return`${Y(d.entity,d.entity.project)} has no overlap with implemented signature`;case se.PropertyOverwritesBasePropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites base property`;case se.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another property with same implementation`;case se.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another property with same implementation`;case se.ReaderWriterIncompatibleDataType:return`${Y(d.entity,d.entity.project)} has reader/writer with incompatible data type`;case ta.StatusCodeMustBeBetween100And599:return`${Y(d.entity,d.entity.project)} HTTP status code must be between 100 and 599`;case ta.StatusCodeMustBeNumber:return`${Y(d.entity,d.entity.project)} HTTP status code must be a number`;case vs.UUIDMustBeString:return`${Y(d.entity,d.entity.project)} UUID must be a string`;case vs.UUIDMustNotContainSpaces:return`${Y(d.entity,d.entity.project)} UUID must not contain spaces`;case vs.UUIDMustBeValidFormat:return`${Y(d.entity,d.entity.project)} UUID must be in a valid format`;case ki.MustBeUniqueAmongSameEntities:return`${Y(d.entity,d.entity.project)} value must be unique among the same kind`;case ki.StringValueMustNotHaveDashes:return`${Y(d.entity,d.entity.project)} value must not contain dashes`;case ki.StringValueMustNotHaveSpaces:return`${Y(d.entity,d.entity.project)} value must not contain spaces`;default:return`${Y(d.entity,d.entity.project)} Error: ${Cc(d.code)}`}}function Yme(d){var u,r,a,o;switch(d.code){case re.AbstractEntityWithNonAbstractMethods:return`${Y(d.entity,d.entity.project)} has non-template actions`;case re.AbstractEntityWithNonAbstractProperties:return`${Y(d.entity,d.entity.project)} has non-template properties`;case re.IncorrectEntityImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements the template entity`;case re.IncorrectMethodImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements the template action it's based on`;case re.IncorrectPropertyImplementation:return`${Y(d.entity,d.entity.project)} incorrectly implements the template property it's based on`;case re.AbstractMethodInNonAbstractEntity:return`${Y(d.entity,d.entity.project)} is a template action in a non-template entity`;case re.AbstractPropertyInNonAbstractEntity:return`${Y(d.entity,d.entity.project)} is a template property in a non-template entity`;case se.MethodOverwritesOtherSiblingWithSameName:return`${Y(d.entity,d.entity.project)} overwrites an action in the template entity`;case se.PropertyOverwritesOtherSiblingWithSameName:return`${Y(d.entity,d.entity.project)} overwrites a property in the template entity`;case re.MissingMethodImplementation:return`${Y(d.entity,d.entity.project)} is missing an action implementation from the template entity`;case re.MissingPropertyImplementation:return`${Y(d.entity,d.entity.project)} is missing a property implementation from the template entity`;case se.NameNotUniqueInScope:return`${Y(d.entity,d.entity.project)} has a duplicate name in the same scope`;case re.NoProperties:return`${Y(d.entity,d.entity.project)} has no properties, so it doesn't do anything`;case re.NonStaticPropertyInStaticEntity:return`${Y(d.entity,d.entity.project)} has a non-static property in a static entity`;case re.StaticEntityWithNonStaticProperties:return`${Y(d.entity,d.entity.project)} has non-static properties in a static entity`;case re.ReadingFromIncompatibleType:return`${Y(d.entity,d.entity.project)} reads data from a value of a different data type`;case re.WritingToIncompatibleType:return`${Y(d.entity,d.entity.project)} writes data to a value of a different data type`;case re.ScopeWithoutLogic:return`${Y(d.entity,d.entity.project)} has no logic`;case re.NonStaticPropertyImplementsStatic:return`${Y(d.entity,d.entity.project)} has a static property in a non-static entity`;case re.PropertyImplementsIncompatibleType:return`${Y(d.entity,d.entity.project)} implements a property of a different data type`;case re.PropertyImplementsNonAbstact:return`${Y(d.entity,d.entity.project)} implements a non-template property`;case re.StaticPropertyImplementsNonStatic:return`${Y(d.entity,d.entity.project)} has a static property in a non-static entity`;case re.VariableCallsOthersAndHasInternalCall:return`${Y(d.entity,d.entity.project)} calls other entities while being used to execute internal logic`;case re.VariableHasInputsAndInternalCall:return`${Y(d.entity,d.entity.project)} has inputs while being used to execute internal logic`;case re.VariableHasOutputsAndInternalCall:return`${Y(d.entity,d.entity.project)} has outputs while being used to execute internal logic`;case re.VariableIsCalledAndHasInternalCall:return`${Y(d.entity,d.entity.project)} is called while being used to execute internal logic`;case se.InternalCallDeclarationIsNotFunctionDeclaration:return`${Y(d.entity,d.entity.project)} has a declaration that is not an action`;case se.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${Y(d.entity,d.entity.project)} has a declaration that is not found in ${(u=d.entity.parent.getDataType(null))!=null&&u.entity?Y((r=d.entity.parent.getDataType(null))==null?void 0:r.entity,d.entity.project):"the variable's data-type entity"}`;case se.InternalCallParentDeclarationEntityInvalidType:return`${Y(d.entity,d.entity.project)} is part of a variable whos data-type entity can't have actions`;case se.InternalCallParentMissingDataType:return`${Y(d.entity,d.entity.project)} is part of a variable with no data-type entity`;case se.InternalCallDeclarationNotInParentDatatypeEntity:return`${Y(d.entity,d.entity.project)} has a declaration doesn't belong to ${(a=d.entity.parent.getDataType(null))!=null&&a.entity?Y((o=d.entity.parent.getDataType(null))==null?void 0:o.entity,d.entity.project):"the variable's data-type entity"}`;case se.UnreachableEntity:return`${Y(d.entity,d.entity.project)} is unreachable`;case re.DisconnectedCallableEntity:return`${Y(d.entity,d.entity.project)} is disconnected and won't be executed by anything after publishing`;case re.AbstractEntityImplements:return`${Y(d.entity,d.entity.project)} implements a non-template entity`;case re.AbstractExtendingNonAbstractEntity:return`${Y(d.entity,d.entity.project)} extends a non-template entity`;case re.InvalidPropertiesCombination:return`${Y(d.entity,d.entity.project)} has an invalid combination of properties`;case re.ExtendingNonInteractiveEntity:return`${Y(d.entity,d.entity.project)} extends a non-interactive entity`;case re.ExtendsIncompatibleEntities:return`${Y(d.entity,d.entity.project)} extends incompatible entities`;case re.ImplementingNonAbstractEntity:return`${Y(d.entity,d.entity.project)} implements a non-template entity`;case re.ImplementsIncompatibleEntities:return`${Y(d.entity,d.entity.project)} implements incompatible entities`;case re.LackingReturnStatementOnSomeBranches:return`${Y(d.entity,d.entity.project)} has branches that don't terminate`;case re.LastCalledEntityMustBeReturnEntity:return`${Y(d.entity,d.entity.project)} must end with a termination node`;case re.MissingRequiredValue:return`${Y(d.entity,d.entity.project)} is missing a required value`;case re.NoPrimaryKeyProperty:return`${Y(d.entity,d.entity.project)} has no primary key property`;case re.NonAbstractExtendingAbstractEntity:return`${Y(d.entity,d.entity.project)} is a non-template entity extending a template entity`;case re.NonStaticExtendingStaticEntity:return`${Y(d.entity,d.entity.project)} is a non-static entity extending a static entity`;case re.NonStaticImplementingStaticEntity:return`${Y(d.entity,d.entity.project)} is a non-static entity implementing a static entity`;case re.StaticExtendingNonStaticEntity:return`${Y(d.entity,d.entity.project)} is a static entity extending a non-static entity`;case re.StaticImplementingNonStaticEntity:return`${Y(d.entity,d.entity.project)} is a static entity implementing a non-static entity`;case re.VariableReadsValueAndInternalCall:return`${Y(d.entity,d.entity.project)} reads a value and has an internal call`;case re.VariableWritesValuesAndInternalCall:return`${Y(d.entity,d.entity.project)} writes values and has an internal call`;case se.EmptyName:return`${Vs[d.entity.type]} has no name`;case se.InvalidObjectStructure:return`${Y(d.entity,d.entity.project)} has an invalid structure`;case se.LoopBodyFunctionOverwrite:return`${Y(d.entity,d.entity.project)}'s loop body action overwrites`;case se.MethodOverwritesBaseMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites a base action with same implementation`;case se.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another action with same implementation`;case se.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another action with same implementation`;case se.MissingCaller:return`${Y(d.entity,d.entity.project)} is missing a caller`;case se.NameAsResolvedCodeNameNotUniqueInScope:return`${Y(d.entity,d.entity.project)} has a name that is not unique in the scope`;case se.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${Y(d.entity,d.entity.project)} name can only contain letters, numbers, underscores and spaces`;case se.NameMustStartWithLetterOrUnderscore:return`${Y(d.entity,d.entity.project)} name must start with letter or underscore`;case se.NoOverlapWithImplementedSignature:return`${Y(d.entity,d.entity.project)} has no overlap with implemented signature`;case se.PropertyOverwritesBasePropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites a base property with same implementation`;case se.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another property with same implementation`;case se.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${Y(d.entity,d.entity.project)} overwrites another property with same implementation`;case se.ReaderWriterIncompatibleDataType:return`${Y(d.entity,d.entity.project)} has a reader/writer with incompatible data type`;case ta.StatusCodeMustBeBetween100And599:return`${Y(d.entity,d.entity.project)} HTTP status code must be between 100 and 599`;case ta.StatusCodeMustBeNumber:return`${Y(d.entity,d.entity.project)} HTTP status code must be a number, between 100 and 599`;case vs.UUIDMustBeString:return`${Y(d.entity,d.entity.project)} UUID must be a string, eg: "${cl()}"`;case vs.UUIDMustNotContainSpaces:return`${Y(d.entity,d.entity.project)} UUID must not contain spaces, eg: "${cl()}"`;case vs.UUIDMustBeValidFormat:return`${Y(d.entity,d.entity.project)} UUID must be in a valid format. Eg: "${cl()}"`;case ki.MustBeUniqueAmongSameEntities:return`${Y(d.entity,d.entity.project)} value must be unique among the same kind`;case ki.StringValueMustNotHaveDashes:return`${Y(d.entity,d.entity.project)} value must not contain dashes`;case ki.StringValueMustNotHaveSpaces:return`${Y(d.entity,d.entity.project)} value must not contain spaces`;default:return`${Y(d.entity,d.entity.project)} Error: ${Cc(d.code)}`}}var nA=(d=>(d.ValuesAlreadyConnected="values-already-connected",d.CannotReadMoreThanOneValue="cannot-read-more-than-one-value",d.CannotReadValueFromChildren="cannot-read-value-from-children",d.CannotWriteValueToChildren="cannot-write-value-to-children",d.CannotBeCalledByChildren="cannot-be-called-by-children",d.ExecutionsAlreadyConnected="executions-already-connected",d.DataTypesNotCompatible="data-types-not-compatible",d.CannotCallAncestor="cannot-call-ancestor",d.CannotConnectToItself="cannot-connect-to-itself",d.CannotWriteValueToAncestor="cannot-write-value-to-ancestor",d.NotInScope="not-in-scope",d.IsNotValueWrittingEntity="is-not-value-writting-entity",d.IsNotValueReadingEntity="is-not-value-reading-entity",d.ContinueOrBreakStatementCalledFromOutsideLoop="continue-or-break-statement-called-from-outside-loop",d.ElementInLoopBodyCallingOutsideLoop="element-in-loop-body-calling-outside-loop",d.CallerIsInHigherScope="caller-is-in-higher-scope",d.CallerIsInLowerScope="caller-is-in-lower-scope",d.CallIsInHigherScope="call-is-in-higher-scope",d.CallIsInLowerScope="call-is-in-lower-scope",d.OtherIncompatibleScopeReason="other-incompatible-scope-reason",d.SiblingInternalCallAlreadyUsedInParentVariable="sibling-internal-call-already-used-in-parent-variable",d.ErrorOututMapCannotBeConnectedToParentSuccessBranchCallees="error-output-map-cannot-be-connected-to-parent-success-branch-callees",d.SuccessOutputMapCannotBeConnectedToParentErrorBranchCallees="success-output-map-cannot-be-connected-to-parent-error-branch-callees",d))(nA||{});const zme=Object.values(nA);var aA=(d=>(d.NotPartOfOngoingTest="not-part-of-ongoing-test",d.CannotBeAddedToTest="cannot-be-added-to-test",d))(aA||{});const Xme=Object.values(aA);var oA=(d=>(d.Suggestion="suggestion",d.CanvasGloballyDisabled="canvas-globally-disabled",d.CannotInteractWithInputInVariableWithInternalCalls="cannot-interact-with-input-in-variable-with-internal-calls",d.CannotInteractWithOutputInVariableWithInternalCalls="cannot-interact-with-output-in-variable-with-internal-calls",d))(oA||{});const Qme=Object.values(oA);function e0e(d,u){const r=[...d,...u];return Array.from(new Set(r))}function t0e(d,u){const r=[...d,...u],a=Array.from(new Set(r));return{hasChanged:a.length!==d.length,reasons:a}}function r0e(d,u){const r=d.filter(o=>!u.includes(o));return{hasChanged:r.length!==d.length,reasons:r}}function i0e(d,u){return d.find(r=>r.entity.id===u)||null}function m3(d){return d.filter((u,r)=>d.indexOf(u)===r)}class Ai{constructor(u,r,a=null,o){_(this,"ids",[]);_(this,"entity");_(this,"entityCardHeight");_(this,"entityCardWidth");_(this,"index");_(this,"childEntities",[]);_(this,"children",[]);_(this,"parents",[]);_(this,"calculationEntryPoint");_(this,"_onlyEntities",null);_(this,"_changeSet",null);if(this.index=r,this.entity=u,this.calculationEntryPoint=a||this,this===this.calculationEntryPoint&&!o)throw new Error("Change set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(u,r,a){const o=p3-sA-d3,p=f3-Vy-rA;u.metaSync({x:u.x||o,y:u.y||p},r);const e=new Ai(u,0,null,r);e._onlyEntities=a||[],e.ids=["0"];const y=[];e.next(E=>{y.push(...E)}),Ai.recursivelyAssembleChildrenAreas(y),e.resolveChildrenOverlaps();const v=e.flattenChildEntities();return e._onlyEntities?v.filter(E=>(e._onlyEntities||[]).includes(E)):v}static recursivelyAssembleChildrenAreas(u){const r=[];u.forEach(a=>{a.next(o=>{r.push(...o)})}),r.length>0&&Ai.recursivelyAssembleChildrenAreas(r)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(u){this.calculationEntryPoint._changeSet=u}findAreaInChildrenFromEntity(u){if(this.entity===u)return this;const r=this.children.find(o=>o.entity===u);return r||this.children.reduce((o,p)=>o||p.findAreaInChildrenFromEntity(u),null)}findAreaFromEntity(u){if(this.entity===u)return this;const r=this.calculationEntryPoint.children,a=r.find(p=>p.entity===u);return a||r.reduce((p,e)=>p||e.findAreaInChildrenFromEntity(u),null)}addParent(u){if(!this.parents.includes(u)){const r=Ai.resolveIds(u,this.index);this.ids.push(...r),this.parents.push(u)}}static resolveIds(u,r){return u?u.ids.map(a=>`${a}-${r}`):[`${r}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const u=bn(this.entity,!0);if(this.entity.type===f.Project){const r=[],a=[],o=[];u.forEach(e=>{if(f.DefinitionEntity===e.type){a.push(e);return}else if(Dt.includes(e.type)){o.push(e);return}r.push(e)});const p=r.sort((e,y)=>{const v=!!Tm(e,y).length,E=bn(e),w=bn(y);return v?0:E.length&&!w.length?-1:!E.length&&w.length?1:0}).filter(e=>!Ao(e).length);this.childEntities=[...a,...o,...p]}else{const r=[],a=[],o=[],p=[],e=[];wi.includes(this.entity.type)&&bm(this.entity).forEach(E=>{if(Tt.includes(E.type)){o.push(E);return}const w=fr(E);r.push(w)}),Nr.includes(this.entity.type)&&a.push(...this.entity.detachedChildren);const y=u.filter(v=>{const E=r.includes(v);return E||o.includes(v)||a.includes(v)?!1:Tt.includes(v.type)?(o.push(v),!1):xi.includes(v.type)&&!E?(p.push(v),!1):v.type===f.DefinitionEntity?(e.push(v),!1):!0});r.sort((v,E)=>Il(v,E)?-1:0),p.sort((v,E)=>Il(v,E)?-1:0),o.sort((v,E)=>pb(v,E)?1:pb(E,v)?-1:0),this.childEntities=[...e,...r,...p,...y,...o,...a]}}calculateCardSize(){const u=y3(this.entity);this.entityCardWidth=u.width,this.entityCardHeight=u.height}static getBoundriesOfTwoAreas(u,r){return{top:Math.min(u.top,r.top),left:Math.min(u.left,r.left),bottom:Math.max(u.bottom,r.bottom),right:Math.max(u.right,r.right)}}static getBoundriedOfCombinedAreas(u,r){const a=u.filter(p=>!r.includes(p));return a.reduce((p,e)=>r.includes(e)?p:Ai.getBoundriesOfTwoAreas(p,e.fullBranchArea),a[0].fullBranchArea)}getFullAreaUntilAny(u){const r=this.ownEntityPlusBufferArea;return this.children.filter(e=>!u.includes(e)).map(e=>e.getFullAreaUntilAny(u)).reduce((e,y)=>Ai.getBoundriesOfTwoAreas(e,y),r)}getFullAreaUntilAreaOrAnyChildren(u){const r=[u,...u.flattenChildren()],a=this.ownEntityPlusBufferArea;return this.children.filter(e=>r.includes(e)).map(e=>e.getFullAreaUntil(u)).reduce((e,y)=>Ai.getBoundriesOfTwoAreas(e,y),a)}getFullAreaUntil(u){const r=this.ownEntityPlusBufferArea;return this.children.filter(p=>p!==u).map(p=>p.getFullAreaUntil(u)).reduce((p,e)=>Ai.getBoundriesOfTwoAreas(p,e),r)}get fullBranchArea(){const u=this.ownEntityPlusBufferArea;return this.children.map(o=>o.fullBranchArea).reduce((o,p)=>Ai.getBoundriesOfTwoAreas(o,p),u)}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 u=this.ownEntityArea;return{top:u.top,left:u.left,bottom:u.bottom+Vy,right:u.right+sA}}static filterOutRepeatedAreas(u){return u.filter((r,a)=>u.indexOf(r)===a)}getEarliestId(u,r){const a=u.split("-"),o=r.split("-");return a.length<o.length?u:a.length>o.length?r:a.reduce((e,y,v)=>y<o[v]?u:r,u)}getEarliestLevel(){return this.ids.reduce((a,o)=>this.getEarliestId(a,o),this.ids[0]).split("-").length}countColumns(){let u=0;if(this!==this.calculationEntryPoint)u++;else return u;if(!this.parents.length)return u;const a=this.parents.reduce((o,p)=>p.getEarliestLevel()>o.getEarliestLevel()?p:o,this.parents[0]).countColumns();return u+=a,u}getLatestId(u,r){if(u===r)return u;const a=u.split("-"),o=r.split("-");return a.length<o.length?r:a.length>o.length?u:a.reduce((e,y,v)=>y>o[v]?u:r,u)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((a,o)=>this.getLatestId(a,o),this.ids[0]).split("-").length}smoothPosition(){const u=this.flattenSiblings();if(!u.length&&this.parents.length<=1&&this.children.length){const r=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(a=>{a!==this.calculationEntryPoint&&a.shiftDownAlone(r)})}else if([...Dt].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const r=u.filter(a=>!this.parents.includes(a));r.length?r.every(o=>{const p=this.countColumns(),e=o.countColumns();return p>e})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():r.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(u,r){if(u.includes(this))return u;this.move(this.entity,{y:this.entity.y+r});let a=[...u,this];return this.children.forEach(o=>{if(Ai.getEarliestParentInChain(o)!==this)return;const e=i0e(a,o.entity.id);a=Ai.filterOutRepeatedAreas([...a]),e||(a=a.filter(v=>v!==o));const y=o.shiftDownUntilAny(a,r);a.push(...y)}),a}shiftRightUntilAny(u,r){u.includes(this)||(this.move(this.entity,{x:this.entity.x+r}),this.children.forEach(a=>{const o=Ai.filterOutRepeatedAreas([...this.flattenSiblings(),...u]);Ai.getEarliestParentInChain(a)===this&&a.shiftRightUntilAny(o,r)}))}shiftRight(u){this.move(this.entity,{x:this.entity.x+u}),this.children.forEach(r=>{const o=r.flattenSiblings().filter(p=>p!==r);r.shiftRightUntilAny(o,u)})}shiftDownAlone(u){this.move(this.entity,{y:this.entity.y+u})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const u=this.parents.reduce((o,p)=>{const e=p.ownEntityArea,y=e.top+Vd,v={top:y,left:e.left,bottom:y,right:e.right};return Ai.getBoundriesOfTwoAreas(o,v)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),a=(u.bottom-u.top)/2-Vd;this.shiftDownAlone(a)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const u=this.children.reduce((o,p)=>{const e=p.ownEntityArea,y=e.top+Vd,v={top:y,left:e.left,bottom:y,right:e.right};return Ai.getBoundriesOfTwoAreas(o,v)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),a=(u.bottom-u.top)/2-Vd;return this.shiftDownAlone(a),a}resolveChildrenOverlaps(){const u=this.flattenChildren();let r=[];u.forEach(a=>{const o=a.adjustVerticallyToAvoidOverlaps();r.push(...o)}),u.forEach(a=>{a.smoothPosition()})}static getEarliestParentInChain(u){let r=u.parents[0];return u.parents.length&&(r=u.parents.sort((a,o)=>{if(!a.ids.length)return-1;if(!o.ids.length)return 1;const p=a.ids.sort((y,v)=>y.length<v.length?-1:0),e=o.ids.sort((y,v)=>y.length<v.length?-1:0);return p[0].length-e[0].length})[0]),r}flattenEarlierSiblings(u=new Set){return u.add(this.entity.id),this.parents.reduce((a,o)=>{if(u.has(o.entity.id))return a;u.add(o.entity.id);const e=o.children.slice(0,o.children.indexOf(this)).reduce((y,v)=>[...y,v,...v.flattenChildren(u)],[]);return[...a,...e]},[])}flattenSiblings(u=new Set){return u.add(this.entity.id),this.parents.reduce((a,o)=>{if(u.has(o.entity.id))return a;u.add(o.entity.id);const e=o.children.filter(y=>y!==this).reduce((y,v)=>[...y,v,...v.flattenChildren(u)],[]);return[...a,...e]},[])}flattenChildren(u=new Set){return this.children.reduce((r,a)=>u.has(a.entity.id)?r:(u.add(a.entity.id),[...r,a,...a.flattenChildren(u)]),[])}flattenParents(u=new Set){return this.parents.reduce((a,o)=>u.has(o.entity.id)?a:(u.add(o.entity.id),[...a,o,...o.flattenParents(u)]),[])}getAreaIfRendered(u){return this.calculationEntryPoint.flattenChildren().find(o=>o.entity.id===u.id)||null}getLowerSiblings(){const u=this.parents.reduce((r,a)=>{const o=a.children.indexOf(this),p=a.children.slice(o+1);return[...r,...p]},[]);return m3(u)}getLowerAreas(){const u=this.getLowerSiblings(),r=this.parents.reduce((a,o)=>[...a,...o.getLowerAreas()],[]);return m3([...u,...r])}adjustVerticallyToAvoidOverlaps(u=[]){const a=Ai.getEarliestParentInChain(this).children[this.index-1];if(!a)return u;const o=this.flattenEarlierSiblings(),p=this.flattenParents(),e=[...o,...p,a],E=R(e.flatMap(V=>Tm(this.entity,V.entity))).filter(V=>V.id!==this.entity.id).map(V=>this.findAreaFromEntity(V)).filter(V=>!!V),w=this.getFullAreaUntilAny(E),A=a.getFullAreaUntilAny(E),$=e.reduce((V,B)=>B===this||B.fullBranchArea.left!==w.left?V:Math.max(V,B.fullBranchArea.bottom),A.bottom);if(w.top<$){const V=$-w.top+Vy;return this.shiftDownUntilAny(u,V)}return u}move(u,r){(this.onlyEntities||[]).includes(u)&&u.metaSync(r,this.changeSet)}addChild(u){const r=this.childEntities[u];let a=null;r.x&&r.y?a=this.getAreaIfRendered(r):!r.x&&!r.y&&this.move(r,{x:this.entity.x,y:this.entity.y}),a||(a=new Ai(r,u,this.calculationEntryPoint));const o=this.ownEntityPlusBufferArea;this.children.includes(a)||(this.children.push(a),a.addParent(this));const p=a.fullBranchArea;if(p.left<o.right){const e=o.right-p.left;a.shiftRight(e)}return a}flattenChildEntities(u=new Set){return this.children.reduce((r,a)=>u.has(a.entity.id)?r:(u.add(a.entity.id),[...r,a.entity,...a.flattenChildEntities(u)]),[])}next(u){const r=[];this.childEntities.forEach((a,o)=>{const p=this.addChild(o);p&&r.push(p)}),u(r)}}var $c=(d=>(d.Amazon="amazon",d.Google="google",d.Microsoft="microsoft",d))($c||{}),kr=(d=>(d.RelationalDatabase="relational-database",d.CompiledLocalCodebase="compiled-local-codebase",d.CloudHostedCodebase="cloud-hosted-codebase",d.HttpApi="http-api",d.HttpEndpoint="http-endpoint",d.ServerlessFunction="serverless-function",d))(kr||{}),lA=(d=>(d.Post="post",d.Get="get",d.Acknowledgement="acknowledgment",d.Progress="progress",d.Error="error",d.Complete="complete",d))(lA||{}),hl=(d=>(d.Queued="queued",d.Running="running",d.Success="success",d.Failed="failed",d.CleanedUp="cleaned-up",d.Skipped="skipped",d.AbortedByUser="aborted-by-user",d.UnrecoverableFailure="unrecoverable-failure",d.Reverted="reverted",d.UnpublishingStarted="unpublishing-started",d.Unpublished="unpublished",d))(hl||{}),dA=(d=>(d.Queued="queued",d.Running="running",d.Success="success",d.Failed="failed",d.CleanedUp="cleaned-up",d.UnrecoverableFailure="unrecoverable-failure",d.Reverted="reverted",d.UnpublishingStarted="unpublishing-started",d.Unpublished="unpublished",d))(dA||{}),yt=(d=>(d.ProjectNotFound="project-not-found",d.ProjectPublishRequestAcknowledged="project-publish-request-acknowledged",d.PublicationStepFailedReasonUnknown="publication-step-failed-reason-unknown",d.DeploymentCompleted="deployment-completed",d.DeploymentStarted="deployment-started",d.DeploymentFailed="deployment-failed",d.AllInfrastructureSuccessfullyProvisioned="all-infrastucture-successfully-provisioned",d.RequestPayloadValidationFailed="request-payload-validation-failed",d.ProjectStateValidationFailedMissingName="project-state-validation-failed-missing-name",d.ProjectStateValidationFailedMissingAnyFunctionality="project-state-validation-failed-missing-any-functionality",d.ProjectAlreadyBeingPublished="project-already-being-published",d.BillingSubscriptionUpdateFailed="billing-subscription-update-failed",d.RelationalDatabaseDeploymentStarted="relational-database-deployment-started",d.RelationalDatabaseDeploymentCompleted="relational-database-deployment-completed",d.RelationalDatabaseDeploymentFailed="relational-database-deployment-failed",d.CreatingNewRelationalDatabase="creating-new-relational-database",d.WaitingForPreviousRelationalDatabaseDeployment="waiting-for-previous-relationa-database-deployment",d.RelationalDatabaseAlreadyExists="relational-database-already-exists",d.RelationalDatabaseDeletionStarted="relational-database-deletion-started",d.RelationalDatabaseDeletionCompleted="relational-database-deletion-completed",d.RelationalDatabaseDeletionFailed="relational-database-deletion-failed",d.WaitingForPreviousRelationalDatabaseDeletion="waiting-for-previous-relationa-database-deletion",d.HttpApiDeploymentStarted="http-api-deployment-started",d.HttpApiDeploymentCompleted="http-api-deployment-completed",d.HttpApiDeploymentFailed="http-api-deployment-failed",d.CreatingNewHttpApi="creating-new-http-api",d.HttpApiAlreadyExists="http-api-already-exists",d.HttpApiDeletionStarted="http-api-deletion-started",d.HttpApiDeletionCompleted="http-api-deletion-completed",d.HttpApiDeletionFailed="http-api-deletion-failed",d.WaitingForPreviousHttpApiDeletion="waiting-for-previous-http-api-deletion",d.BusinessLogicCodebaseDeploymentStarted="business-logic-codebase-deployment-started",d.BusinessLogicCodebaseDeploymentCompleted="business-logic-codebase-deployment-completed",d.BusinessLogicCodebaseDeploymentFailed="business-logic-codebase-deployment-failed",d.BundlingCodebaseForDownload="bundling-codebase-for-download",d.UploadingCodebaseToCloudStorage="uploading-codebase-to-cloud-storage",d.UploadingCodebaseToCloudStorageCompleted="uploading-codebase-to-cloud-storage-completed",d.UploadingCodebaseToCloudStorageFailed="uploading-codebase-to-cloud-storage-failed",d.InfrastructureValuesCodebaseInterpolationStarted="infrastructure-values-codebase-interpolation-started",d.InfrastructureValuesCodebaseInterpolationCompleted="infrastructure-values-codebase-interpolation-completed",d.InfrastructureValuesCodebaseInterpolationFailed="infrastructure-values-codebase-interpolation-failed",d.CodeCompilationStarted="code-compilation-started",d.CodeCompilationCompleted="code-compilation-completed",d.CodeCompilationFailed="code-compilation-failed",d.BundleCodebaseStarted="bundle-codebase-started",d.BundleCodebaseCompleted="bundle-codebase-completed",d.BundleCodebaseFailed="bundle-codebase-failed",d.InstallingCodebaseDependenciesStarted="installing-codebase-dependencies-started",d.InstallingCodebaseDependenciesCompleted="installing-codebase-dependencies-completed",d.InstallingCodebaseDependenciesFailed="installing-codebase-dependencies-failed",d.MigrateRelationalDatabaseStarted="migrate-relational-database-started",d.MigrateRelationalDatabaseCompleted="migrate-relational-database-completed",d.MigrateRelationalDatabaseFailed="migrate-relational-database-failed",d))(yt||{}),vn=(d=>(d.CodeCompilation="code-compilation",d.RelationalDatabaseDeployment="relational-database-deployment",d.RelationalDatabaseDeletion="relational-database-deletion",d.HttpApiDeployment="http-api-deployment",d.HttpApiDeletion="http-api-deletion",d.InfrastructureValuesCodebaseInterpolation="infrastructure-values-codebase-interpolation",d.BundleCodebase="bundle-codebase",d.MigrateRelationalDatabase="migrate-relational-database",d.BusinessLogicCodebaseDeployment="business-logic-codebase-deployment",d.CodebaseCleanup="codebase-cleanup",d))(vn||{});kr.CloudHostedCodebase,kr.HttpApi,kr.RelationalDatabase,kr.CloudHostedCodebase,kr.CloudHostedCodebase,kr.RelationalDatabase,kr.CloudHostedCodebase,kr.CloudHostedCodebase;function v3(d){return`project-${d}-http-api`}function E3(d){return`entity-${d}-database`}class T3{constructor(u,r,a,o,p,e,y,v,E){_(this,"stepType");_(this,"id");_(this,"resourceType");_(this,"index");_(this,"dependency",[]);_(this,"lastEvent",null);_(this,"lasEventTimestamp",null);_(this,"status",hl.Queued);_(this,"publicationRun");_(this,"resource");this.stepType=u,this.id=r,this.resourceType=a,this.status=o,this.dependency=p,this.index=e,this.lasEventTimestamp=y,this.publicationRun=v,this.resource=E}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(u){var r,a;this.status=u.status,this.dependency=u.dependency,this.index=u.index,this.stepType=u.stepType,this.resourceType=u.resourceType,this.lastEvent=u.lastEvent,this.id=u.id,(a=this.resource)==null||a.setDetails((r=u.resource)==null?void 0:r.details)}}var I3=(d=>(d.Ready="ready",d.Provisioning="provisioning",d.Queued="queued",d.ProvisioningFailed="provisioning-failed",d.Deleting="deleting",d.DeletingFailed="deleting-failed",d.Deleted="deleted",d))(I3||{});class uA{constructor(u,r,a){_(this,"provisionedBy");_(this,"publicationRun");_(this,"resourceType");_(this,"provider");_(this,"resourceId");_(this,"details",null);_(this,"name",null);_(this,"status","queued");this.publicationRun=u,this.resourceType=r,this.provider=a}setDetails(u){this.details=u}setStatus(u){this.status=u}setProvisionedBy(u){this.provisionedBy=u}}class cA extends uA{constructor(r,a,o,p){super(r,o,p);_(this,"resourceType");_(this,"owners",new Map);_(this,"details",null);_(this,"status","queued");a.forEach(e=>{this.owners.set(e.id,e)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var r,a;return this.resourceType===kr.HttpApi?this.resourceId=v3(this.publicationRun.project.id):this.resourceType===kr.RelationalDatabase&&(this.resourceId=E3((a=(r=Array.from(this.owners.values()))==null?void 0:r[0])==null?void 0:a.id)),this.resourceId}}class pA extends uA{constructor(r,a,o){super(r,a,o);_(this,"resourceType");_(this,"details",null);_(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceType===kr.CompiledLocalCodebase?this.resourceId=`compiled-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}--${this.publicationRun.id}`:this.resourceType===kr.CloudHostedCodebase&&(this.resourceId=`cloud-hosted-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}`),this.resourceId}}class s0e{constructor(u,r){_(this,"id");_(this,"projectAutoIncrementPublicationCount");_(this,"projectPublishedSemanticVersion");_(this,"projectVersion");_(this,"projectId");_(this,"cloudProvider");_(this,"triggeredBy");_(this,"createdAt");_(this,"updatedAt");_(this,"status");_(this,"steps",[]);_(this,"editor");_(this,"explicitResources",new Map);_(this,"implicitGlobalResources",new Map);_(this,"finalGlobalEvent",null);_(this,"finalStatus",null);this.id=u.id,this.projectAutoIncrementPublicationCount=u.projectAutoIncrementPublicationCount,this.projectPublishedSemanticVersion=u.projectPublishedSemanticVersion,this.projectVersion=u.projectVersion,this.projectId=u.projectId,this.cloudProvider=u.cloudProvider,this.triggeredBy=u.triggeredBy,this.createdAt=u.createdAt,this.updatedAt=u.updatedAt,this.status=u.status,this.editor=r}get project(){return this.editor.project}getInfraTypes(u){return this.steps.filter(r=>u.includes(r.resourceType))}getStepsTypes(u){return this.steps.filter(r=>u.includes(r.stepType))}toIds(u){return u.map(r=>r.id)}getResourceForEntity(u){const r=Array.from(this.explicitResources.values()).find(a=>a.owners.has(u.id));return r||null}async init(){await this.initResources()}async initResources(){this.implicitGlobalResources.set(kr.CompiledLocalCodebase,new pA(this,kr.CompiledLocalCodebase,$c.Amazon)),this.implicitGlobalResources.set(kr.CloudHostedCodebase,new pA(this,kr.CloudHostedCodebase,$c.Amazon));const u=this.project.entities.filter(a=>es(a,Le.HTTP_ENDPOINT)),r=this.project.entities.filter(a=>es(a,Le.RELATIONAL_DATABASE));if(r.length&&r.forEach(a=>{const o=new cA(this,[a],kr.RelationalDatabase,$c.Amazon);this.explicitResources.set(o.resourceId,o)}),u.length){const a=new cA(this,u,kr.HttpApi,$c.Amazon);this.explicitResources.set(a.resourceId,a)}}setSteps(u,r){u.forEach(a=>{this.addStep(a,r)}),this.editor.events.emit(yt.ProjectPublishRequestAcknowledged,{})}addStep(u,r){const a=u.dependency||[];if(a.length){const p=a.filter(e=>!this.steps.find(y=>y.id===e));if(p.length)throw new Error(`Missing dependencies: ${p.join(", ")}`)}if(!u.resource)throw new Error(`Resource not found for step ${u.stepType} (${u.id})`);if(!this.steps.find(p=>p.id===u.id)){const p=this.implicitGlobalResources.get(u.resourceType)||this.explicitResources.get(u.resource.resourceId),e=new T3(u.stepType,u.id,u.resourceType,u.status,a,u.index,r,this,p);this.steps.push(e)}}onUpdate(u){var r;if(Me.log("onUpdate",u),(r=u.payload)!=null&&r.stepType){const a=this.steps.find(o=>{var p;return o.id===((p=u.payload)==null?void 0:p.id)});a&&L(u.emittedAt).isAfter(L(a.lasEventTimestamp))&&a.update(u.payload)}this.editor.events.emit("publication-updated",{}),u.type===lA.Error?(this.finalStatus=dA.Failed,this.finalGlobalEvent=u.event,this.editor.events.emit("project-publication-error",u)):u.type===lA.Complete&&(this.finalStatus=dA.Success,this.finalGlobalEvent=u.event,this.editor.events.emit("project-publication-completed",u))}}function n0e(d){switch(d){case vn.CodeCompilation:return"Code generation";case vn.RelationalDatabaseDeployment:return"Database creation";case vn.HttpApiDeployment:return"HTTP gateway creation";case vn.InfrastructureValuesCodebaseInterpolation:return"Link code with resources";case vn.BundleCodebase:return"Bundle code";case vn.MigrateRelationalDatabase:return"Database structure migration";case vn.BusinessLogicCodebaseDeployment:return"Update servers with new code";case vn.CodebaseCleanup:return"Code cleanup";case vn.HttpApiDeletion:return"HTTP gateway deletion";case vn.RelationalDatabaseDeletion:return"Database deletion";default:return"Publication finished"}}function a0e(d){switch(d){case yt.DeploymentCompleted:return"Successfully published";case yt.DeploymentStarted:return"Publication started";case yt.DeploymentFailed:return"Publication failed";case yt.AllInfrastructureSuccessfullyProvisioned:return"All infrastructure successfully provisioned";case yt.RequestPayloadValidationFailed:return"Request payload validation failed";case yt.ProjectStateValidationFailedMissingName:return"Project state validation failed: missing name";case yt.ProjectStateValidationFailedMissingAnyFunctionality:return"Project state validation failed: missing any functionality";case yt.RelationalDatabaseDeploymentStarted:return"Database creation started";case yt.RelationalDatabaseDeploymentCompleted:return"Database creation completed";case yt.RelationalDatabaseDeploymentFailed:return"Database creation failed";case yt.CreatingNewRelationalDatabase:return"Creating new database (up to 5 mins)";case yt.WaitingForPreviousRelationalDatabaseDeployment:return"Waiting for previous database creation";case yt.RelationalDatabaseAlreadyExists:return"Database already exists";case yt.HttpApiDeploymentStarted:return"HTTP gateway creation started";case yt.HttpApiDeploymentCompleted:return"HTTP gateway creation completed";case yt.HttpApiDeploymentFailed:return"HTTP gateway creation failed";case yt.CreatingNewHttpApi:return"Creating new HTTP gateway";case yt.HttpApiAlreadyExists:return"HTTP gateway already exists";case yt.BusinessLogicCodebaseDeploymentStarted:return"Update servers with new code started";case yt.BusinessLogicCodebaseDeploymentCompleted:return"Update servers with new code completed";case yt.BusinessLogicCodebaseDeploymentFailed:return"Update servers with new code failed";case yt.BundlingCodebaseForDownload:return"Bundling code for download";case yt.UploadingCodebaseToCloudStorage:return"Uploading code to cloud storage";case yt.InfrastructureValuesCodebaseInterpolationStarted:return"Linking code with resources started";case yt.InfrastructureValuesCodebaseInterpolationCompleted:return"Linking code with resources completed";case yt.InfrastructureValuesCodebaseInterpolationFailed:return"Linking code with resources failed";case yt.CodeCompilationStarted:return"Code generation started";case yt.CodeCompilationCompleted:return"Code generation completed";case yt.CodeCompilationFailed:return"Code generation failed";case yt.BundleCodebaseStarted:return"Code bundling started";case yt.BundleCodebaseCompleted:return"Code bundling completed";case yt.BundleCodebaseFailed:return"Code bundling failed";case yt.InstallingCodebaseDependenciesStarted:return"Installing code dependencies";case yt.InstallingCodebaseDependenciesCompleted:return"Installing code dependencies completed";case yt.InstallingCodebaseDependenciesFailed:return"Installing code dependencies failed";case yt.MigrateRelationalDatabaseStarted:return"Database structure migration started";case yt.MigrateRelationalDatabaseCompleted:return"Database structure migration completed";case yt.MigrateRelationalDatabaseFailed:return"Database structure migration failed";case yt.ProjectAlreadyBeingPublished:return"Project already being published. You need to wait for the previous publication to complete";case yt.ProjectPublishRequestAcknowledged:return"Project publish request acknowledged";case yt.UploadingCodebaseToCloudStorageCompleted:return"Uploading code to cloud storage completed";case yt.UploadingCodebaseToCloudStorageFailed:return"Uploading code to cloud storage failed";case yt.BillingSubscriptionUpdateFailed:return"Billing subscription update failed";case yt.ProjectNotFound:return"Project not found";case yt.HttpApiDeletionCompleted:return"HTTP gateway deletion completed";case yt.HttpApiDeletionFailed:return"HTTP gateway deletion failed";case yt.HttpApiDeletionStarted:return"HTTP gateway deletion started";case yt.PublicationStepFailedReasonUnknown:return"Publication step failed: reason unknown";case yt.WaitingForPreviousHttpApiDeletion:return"Waiting for previous HTTP gateway deletion";case yt.RelationalDatabaseDeletionStarted:return"Database deletion started";case yt.RelationalDatabaseDeletionCompleted:return"Database deletion completed";case yt.RelationalDatabaseDeletionFailed:return"Database deletion failed";case yt.WaitingForPreviousRelationalDatabaseDeletion:return"Waiting for previous database deletion"}return"Unknown event"}var A3=(d=>(d.NO_LOGIC="NO_LOGIC",d.NO_NAME="NO_NAME",d.NO_CHANGES="NO_CHANGES",d.PROJECT_PUBLICATION_ALREADY_ONGOING="PROJECT_PUBLICATION_ALREADY_ONGOING",d))(A3||{});function o0e(d){switch(d){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 l0e(d){switch(d){case kr.RelationalDatabase:return"Relational database";case kr.HttpEndpoint:case kr.HttpApi:return"HTTP endpoints";case kr.ServerlessFunction:case kr.CloudHostedCodebase:return"Server code functions";default:return"Resources"}}function d0e(d){switch(d){case hl.Running:return"In progress";case hl.Failed:return"Failed";case hl.Success:return"Succeeded";case hl.Skipped:return"Skipped";case hl.Queued:default:return"Queued"}}function b3(d){var o;(o=d.dataType)==null||o.validate(),d.inputs.forEach(p=>p.validate()),d.outputs.forEach(p=>p.validate()),d.internalCalls.forEach(p=>p.validate());const r=[...Pa(d),...Eo(d),...w3(d),...Na(d),...R3(d)],a=rb(d);return r.push(...a),Er(d.errors,r)}function w3(d,u){const a=[...d.project.getVariableDeclarations()].filter(o=>o.id!==d.id);return Hp(d,[xr],a,u)}function R3(d){const u=[];if(d.parent!==d.project)return u;if(d.catchesError){const r=bt({id:`${d.id}--${se.GlobalVariableDeclarationCannotCatchError}`,message:`${Vs[d.type].singular} "${Y(d,d.project)}" with id "${d.id}" cannot catch an error because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:H.Error,code:se.GlobalVariableDeclarationCannotCatchError,entity:d});u.push(r.error)}if(d.errorCalls.length){const r=bt({id:`${d.id}--${se.GlobalVariableDeclarationCannotCallOnError}`,message:`${Vs[d.type].singular} "${Y(d,d.project)}" with id "${d.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:H.Error,code:se.GlobalVariableDeclarationCannotCallOnError,entity:d});u.push(r.error)}if(d.calledBy.length){const r=bt({id:`${d.id}--${se.GlobalVariableDeclarationCannotBeCalled}`,message:`${Vs[d.type].singular} "${Y(d,d.project)}" with id "${d.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:H.Error,code:se.GlobalVariableDeclarationCannotBeCalled,entity:d});u.push(r.error)}return[]}const u0e=Object.freeze(Object.defineProperty({__proto__:null,validate:b3,validateGlobalVariableDeclaration:R3,validateVariableDeclarationName:w3},Symbol.toStringTag,{value:"Module"}));function g3(d){d.inputs.forEach(o=>o.validate()),d.outputs.forEach(o=>o.validate()),d.internalCalls.forEach(o=>o.validate());const r=[...Pa(d),...Eo(d),...Na(d)],a=rb(d);return r.push(...a),Er(d.errors,r)}const c0e=Object.freeze(Object.defineProperty({__proto__:null,validate:g3},Symbol.toStringTag,{value:"Module"}));var fA=(d=>(d.Parent="parent",d.DataTypeEntity="data-type-entity",d.VarDeclaration="var-declaration",d))(fA||{});const xt=class xt extends Cr{constructor(r,a){super(r);_(this,"initialData");_(this,"id");_(this,"x");_(this,"y");_(this,"type",f.VariableInstance);_(this,"catchesError",!1);_(this,"defaultValue",null);_(this,"writesValues",[]);_(this,"readsValue",null);_(this,"declaration");_(this,"inputs",[]);_(this,"outputs",[]);_(this,"error",null);_(this,"calledBySuccess",[]);_(this,"calledByError",[]);_(this,"calledByEntry",[]);_(this,"successCalls",[]);_(this,"errorCalls",[]);_(this,"internalCalls",[]);_(this,"project");_(this,"errors",[]);_(this,"parent");_(this,"detachedDependents",{});_(this,"knownVersions",null);_(this,"activeVersion",!1);_(this,"initialized",!1);_(this,"startedInitialization",!1);_(this,"suggestion",!1);_(this,"_codeNativeValueValidation",null);this.initialData=r,this.project=a,this.id=r.id,this.x=r.x,this.y=r.y,this.catchesError=r.catchesError||!1}static new(r=null){return{id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||L().toISOString(),author:(r==null?void 0:r.author)||N.sessionAuthor,previousVersion:null,deleted:!1,type:f.VariableInstance,catchesError:!0,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(r,a){let o=a;if(r.parent){const V=J(r.parent);o=a.get(V)}const p=J(r.declaration),e=a.get(p),y=r.calledByEntry.map(V=>{const B=J(V);return a.get(B)}),v=r.calledBySuccess.map(V=>{const B=J(V);return a.get(B)}),E=r.calledByError.map(V=>{const B=J(V);return a.get(B)});let w=null;if(r.readsValue){const V=J(r.readsValue);w=a.get(V)}const A={id:r.id,version:N.UUID.uuid(),createdAt:L().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.VariableInstance,catchesError:r.catchesError||!1,declaration:e.toReference(),calledByEntry:y,calledBySuccess:v,calledByError:E,defaultValue:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:w,inputs:[],outputs:[],writesValues:[],error:null,x:0,y:0,parent:o},$=ne(A,a);return $.setParent(o,null),$}static validateGenerationTarget(r,a){let o=JSON.parse(JSON.stringify(r));const p=[],e=ti(o,{parent:{list:!1,types:[...Nr,f.Project],optional:!0},declaration:{list:!1,types:[f.VariableDeclaration]}},a);return o=e.modifiedData,p.push(...e.errors,...Vr(o)),{errors:p,modifiedData:o}}get codeName(){var r;return(r=this.declaration)==null?void 0:r.codeName}get codeNativeValueValidation(){var r;return this._codeNativeValueValidation||((r=this.declaration)==null?void 0:r.codeNativeValueValidation)||null}validateGeneratedUpdate(r){const a=[];let o=JSON.parse(JSON.stringify(r));const p=Zp(o,this);return o=p.modifiedData,a.push(...p.errors),r.parent&&a.push(new ae({id:`${this.id}--${k.InvalidParentUpdate}`,code:k.InvalidParentUpdate,severity:H.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.
85
85
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
86
86
  Specifically for variables, their scope is also calculated from their value readers and value writters.
87
87
  You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`})),{errors:a,modifiedData:o}}subscribeDependents(r){return r.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(r){return r.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],o=[],p=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(r);a.push(...v.updated),o.push(...v.added),p.push(...v.removed),e.push(...v.affected)}),r==null||r.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}onDetachedDependencyRemoved(r,a,o){const p=[],e=[],y=[],v=[];if(a==="parent"){const{updated:E,added:w,removed:A}=this.remove({ignoreUpstream:!1},o);p.push(...E),e.push(...w),y.push(...A)}if(a==="var-declaration"){const{updated:E,added:w,removed:A}=this.remove({ignoreUpstream:!1},o);p.push(...E),e.push(...w),y.push(...A)}return{updated:R(p),added:R(e),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(r,a,o){const p=[],e=[],y=[],v=[];if(a==="parent"){const{updated:E,added:w,removed:A}=this.restore({},o);p.push(...E),e.push(...w),y.push(...A)}if(a==="var-declaration"){const{updated:E,added:w,removed:A}=this.restore({},o);p.push(...E),e.push(...w),y.push(...A)}return{updated:R(p),added:R(e),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){var r,a,o,p,e,y,v;return(a=(r=this.parent)==null?void 0:r.unsubscribeDependents)==null||a.call(r,[{entity:this,field:"parent"}]),(e=(p=(o=this.declaration.dataType)==null?void 0:o.entity)==null?void 0:p.unsubscribeDependents)==null||e.call(p,[{entity:this,field:"data-type-entity"}]),(v=(y=this.declaration)==null?void 0:y.unsubscribeDependents)==null||v.call(y,[{entity:this,field:"var-declaration"}]),this}subscribeToDependencies(){var r,a,o,p;return(r=this.parent)==null||r.subscribeDependents([{entity:this,field:"parent"}]),(p=(o=(a=this.declaration.dataType)==null?void 0:a.entity)==null?void 0:o.subscribeDependents)==null||p.call(o,[{entity:this,field:"data-type-entity"}]),this.declaration.subscribeDependents([{entity:this,field:"var-declaration"}]),this}increaseVersion(r){if(r&&!L(r).isValid())throw new Error(`The shared timestamp '${r}' is not a valid ISO 8601 date string.`);return r&&L(r).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=N.UUID.uuid(),this.createdAt=L(r).toISOString()||L().toISOString(),this)}captureVersion(){var a;const r=((a=this.knownVersions)==null?void 0:a.get(this.version))||new xt(this,this.project);return r.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,r):new Map([[this.version,r]]),r.inputs=[...this.inputs],r.outputs=[...this.outputs],r.internalCalls=[...this.internalCalls],r.successCalls=[...this.successCalls],r.errorCalls=[...this.errorCalls],r.writesValues=[...this.writesValues],r.readsValue=this.readsValue,r.defaultValue=this.defaultValue,r.declaration=this.declaration,r.calledBySuccess=[...this.calledBySuccess],r.calledByError=[...this.calledByError],r.calledByEntry=[...this.calledByEntry],r.error=this.error,r.parent=this.parent,this}recursiveCaptureUpstreamVersions(r){const a=[],o=[],p=[],e=[];if(this.parent){this.parent.increaseVersion(r);const y=this.parent.recursiveCaptureUpstreamVersions(r);a.push(this.parent,...y.updated),o.push(...y.added),p.push(...y.removed)}return{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}async restoreVersion(r){var v;const a=[],o=[],p=[],e=[];if(this.version===r)return{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this};if(!this.knownVersions){const E=new Map;for(const[w,A]of this.knownVersions||new Map){if(E.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[$,V]of A.knownVersions)E.set($,V);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(r);if(!y){const E=await this.APILoadVersion({},r);if(!E)throw new Error(`Version with id '${r}' for entity with id '${this.id}' not found.`);y=new xt(E,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:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}updateWithShallowTransfer(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(r,a),this.version=r.version,this.createdAt=r.createdAt,this.author=r.author,this.deleted=r.deleted,this.previousVersion=r.previousVersion,this.unsubscribeFromDependencies(),r.parent){const o=J(r.parent),p=this.project.get(o),e=this.parent;if(e&&e.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,a);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${o}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(r.readsValue){const o=J(r.readsValue),p=this.project.get(o),e=this.readsValue;e&&e.id!==(p==null?void 0:p.id)&&this.removeValueWriter(a),p&&this.setValueWriter(p,a)}if(r.declaration){const o=J(r.declaration),p=this.project.get(o);p&&this.setDeclaration(p)}return r.calledByEntry.forEach(o=>{const p=J(o),e=this.project.get(p);e&&(this.addEntryCaller(e,a),e.addCall(this,a))}),[...this.calledByEntry].forEach(o=>{r.calledByEntry.find(e=>J(e)===o.id)||(this.removeCaller(o,a),o.removeCall(this,a))}),r.calledBySuccess.forEach(o=>{const p=J(o),e=this.project.get(p);e&&(this.addSuccessCaller(e,a),e.addSuccessCall(this,a))}),[...this.calledBySuccess].forEach(o=>{r.calledBySuccess.find(e=>J(e)===o.id)||(this.removeCaller(o,a),o.removeCall(this,a))}),r.calledByError.forEach(o=>{const p=J(o),e=this.project.get(p);e&&(this.addErrorCaller(e,a),e.addErrorCall(this,a))}),[...this.calledBySuccess].forEach(o=>{r.calledBySuccess.find(e=>J(e)===o.id)||(this.removeCaller(o,a),o.removeCall(this,a))}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const r=[],a=[],o=[],p=[];if(this.initialData.parent){const e=J(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),r.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=J(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),r.push(y))}if(this.initialData.declaration){const e=J(this.initialData.declaration),y=this.project.get(e);y&&(this.setDeclaration(y),r.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=J(e),v=this.project.get(y);v&&this.addEntryCaller(v,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=J(e),v=this.project.get(y);v&&this.addSuccessCaller(v,null)}),this.initialData.calledByError.forEach(e=>{const y=J(e),v=this.project.get(y);v&&this.addErrorCaller(v,null)}),{updated:R(r),added:R(a),removed:R(o),affected:R(p),self:this}}afterAllChildrenInitialized(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){var ge;const a=[],o=[],p=[],e=[];if(this.initialized=!0,!this.declaration.dataType||(ge=this.declaration.dataType)!=null&&ge.inferred){const{added:$e,updated:qe,removed:xe,affected:ot}=this.declaration.inferDataTypeAndSyncInstancesInputsAndOutputs(r);o.push(...$e),a.push(...qe),p.push(...xe),e.push(...ot)}const{added:y,updated:v,removed:E,affected:w}=this.syncInputs(r);o.push(...y),a.push(...v),p.push(...E),e.push(...w);const{added:A,updated:$,removed:V,affected:B}=this.syncOutputs(r);o.push(...A),a.push(...$),p.push(...V),e.push(...B);const{added:F,updated:K,removed:q,affected:ie}=this.generateUnusedInternalCalls(r);o.push(...F),a.push(...K),p.push(...q),e.push(...ie);const{added:W,updated:de,removed:Q,affected:ce}=this.removeUnrecognizedInputs(r);o.push(...W),a.push(...de),p.push(...Q),e.push(...ce);const{added:X,updated:z,removed:pe,affected:te}=this.removeUnrecognizedOutputs(r);o.push(...X),a.push(...z),p.push(...pe),e.push(...te);const{added:ue,updated:Ie,removed:Ue,affected:Pe}=this.removeUnrecognizedInternalCalls(r);return o.push(...ue),a.push(...Ie),p.push(...Ue),e.push(...Pe),this.captureVersion(),r==null||r.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}addSelfToProject(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){const a=[this],o=[],p=[],e=[];return this.parent===this.project&&this.project.addVariableInstance(this),this.readsValue&&(this.readsValue.addValueReader(this,r),a.push(this.readsValue)),this.writesValues.forEach(y=>{y.setValueWriter(this,r),a.push(y)}),this.successCalls.forEach(y=>{y.addSuccessCaller(this,r),a.push(y)}),this.errorCalls.forEach(y=>{y.addErrorCaller(this,r),a.push(y)}),this.calledBySuccess.forEach(y=>{y.addSuccessCall(this,r),a.push(y)}),this.calledByError.forEach(y=>{y.addErrorCall(this,r),a.push(y)}),this.calledByEntry.forEach(y=>{y.addCall(this,r),a.push(y)}),this.subscribe(),this.subscribeToDependencies(),r==null||r.attemptAutoclose("add-self-to-project",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(r=>r.readsValue||r.defaultValue)}get unusedInputs(){return this.inputs.filter(r=>!r.readsValue&&!r.defaultValue)}get usedOutputs(){return this.outputs.filter(r=>r.writesValues.length)}get unusedOutputs(){return this.outputs.filter(r=>!r.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(r=>!!r.calledBy.length)}get unusedInternalCalls(){const r=this.usedInternalCalls;return this.internalCalls.filter(o=>!(r.find(y=>y.id===o.id)||r.find(y=>y.declaration===o.declaration)))}removeInternalCall(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-variable-instance-internal-call"))){const o=this.internalCalls.findIndex(p=>p.id===r.id);return o>-1&&(this.internalCalls.splice(o,1),a&&(a==null||a.add(this,S.Affected))),a==null||a.attemptAutoclose("remove-variable-instance-internal-call",this.id),this}removeInput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-input"))){const o=this.inputs.findIndex(p=>p.id===r.id);return o>-1&&(this.inputs.splice(o,1),a&&(a==null||a.add(this,S.Affected))),a==null||a.attemptAutoclose("remove-input",this.id),this}addInput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-input"))){return this.inputs.includes(r)?(a==null||a.attemptAutoclose("add-input",this.id),this):(this.inputs.push(r),a==null||a.add(this,S.Affected),a==null||a.attemptAutoclose("add-input",this.id),this)}addOutput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-output"))){return this.outputs.includes(r)?(a==null||a.attemptAutoclose("add-output",this.id),this):(this.outputs.push(r),a==null||a.add(this,S.Affected),a==null||a.attemptAutoclose("add-output",this.id),this)}removeOutput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-output"))){const o=this.outputs.findIndex(p=>p.id===r.id);return o>-1&&(this.outputs.splice(o,1),a&&(a==null||a.add(this,S.Affected))),a==null||a.attemptAutoclose("remove-output",this.id),this}addSuccessCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-success-caller")),o=!1){return this.calledBySuccess.find(p=>p.id===r.id)||(this.calledBySuccess.push(r),a==null||a.add(this,S.Updated),o&&He(this,a)),a==null||a.attemptAutoclose("add-success-caller",this.id),this}addErrorCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-error-caller")),o=!1){return this.calledByError.find(p=>p.id===r.id)||(this.calledByError.push(r),a==null||a.add(this,S.Updated),o&&He(this,a)),a==null||a.attemptAutoclose("add-error-caller",this.id),this}addEntryCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-entry-caller")),o=!1){return this.calledByEntry.find(p=>p.id===r.id)||(this.calledByEntry.push(r),a==null||a.add(this,S.Updated),o&&He(this,a)),a==null||a.attemptAutoclose("add-entry-caller",this.id),this}addErrorCall(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-error-call")),o=!1){return this.errorCalls.find(p=>p.id===r.id)||(this.errorCalls.push(r),o&&He(this,a),a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("add-error-call",this.id),this}addSuccessCall(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-success-call")),o=!1){return this.successCalls.find(p=>p.id===r.id)||(this.successCalls.push(r),o&&He(this,a),a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("add-success-call",this.id),this}removeCall(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-call")),o=!1){const p=this.successCalls.findIndex(y=>y.id===r.id);p>-1&&(this.successCalls.splice(p,1),a==null||a.add(this,S.Affected));const e=this.errorCalls.findIndex(y=>y.id===r.id);return e>-1&&(this.errorCalls.splice(e,1),a==null||a.add(this,S.Affected)),o&&He(this,a),a==null||a.attemptAutoclose("remove-call",this.id),this}removeCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-caller")),o=!1){return this.calledBySuccess=this.calledBySuccess.filter(p=>p.id!==r.id?!0:(a==null||a.add(this,S.Updated),a==null||a.add(p,S.Affected),!1)),this.calledByError=this.calledByError.filter(p=>p.id!==r.id?!0:(a==null||a.add(this,S.Updated),a==null||a.add(p,S.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(p=>p.id!==r.id?!0:(a==null||a.add(this,S.Updated),a==null||a.add(p,S.Affected),!1)),o&&He(this,a),a==null||a.attemptAutoclose("remove-caller",this.id),this}addValueReader(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-value-reader"))){return this.writesValues.includes(r)?(a==null||a.attemptAutoclose("add-value-reader",this.id),this):(this.writesValues.push(r),a==null||a.add(this,S.Affected),this)}setParent(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var o;return((o=this.parent)==null?void 0:o.id)!==(r==null?void 0:r.id)&&(this.parent=r,a&&(a==null||a.add(this,S.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}initChildren(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=ne(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(r)),this.initialData.declaration.type===f.GenericReference){const a=this.project.findSubscribedInstanceFromReference(this.initialData.declaration);if(!a)return this;this.declaration=a}else this.declaration=ne(this.initialData.declaration,this.project),this.declaration.initChildren(r);return nf.initWritesValues(this,this.parent),sf.initReadsValue(this),this.initialData.inputs.forEach(a=>{const o=ne(a,this.project);return o.setParent(this,null),o.initChildren(r),this.addInput(o,null),o}),this.initialData.outputs.forEach(a=>{const o=ne(a,this.project);return o.setParent(this,null),o.initChildren(r),this.addOutput(o,r),o}),this.successCalls=this.initialData.successCalls.map(a=>{const o=ne(a,this.project);if(o.addSuccessCaller(this),[f.BreakStatement,f.ContinueStatement].includes(o.type))o.setParent(this.parent.parent,null),o.initChildren(r);else if(o.type===f.ReturnStatement){const p=Hr(this,this.project);o.setParent(p,null),o.initChildren(r)}else o.type!==f.InternalCall&&(o.setParent(this.parent,null),o.initChildren(r));return o}),this.errorCalls=this.initialData.errorCalls.map(a=>{const o=ne(a,this.project);if(o.addErrorCaller(this),[f.BreakStatement,f.ContinueStatement].includes(o.type))o.setParent(this.parent.parent,null),o.initChildren(r);else if(o.type===f.ReturnStatement){const p=Hr(this,this.project);o.setParent(p,null),o.initChildren(r)}else o.type!==f.InternalCall&&(o.setParent(this.parent,null),o.initChildren(r));return o}),this.internalCalls=this.initialData.internalCalls.reduce((a,o)=>{if(o.type===f.GenericReference){const p=this.project.findSubscribedInstanceFromReference(o);if(!p)return a;const e=p;return e.setParent(this,null),[...a,e]}else{const p=ne(o,this.project);return p.setParent(this,null),p.initChildren(r),[...a,p]}},[]),this.initialData.error&&(this.error=ne(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(r)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(r),r==null||r.attemptAutoclose("init-children",this.id),this}setValueWriter(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"set-value-writer"))){return this.readsValue!==r&&(this.readsValue=r,a==null||a.add(this,S.Updated)),a==null||a.attemptAutoclose("set-value-writer",this.id),this}removeValueWriter(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-value-writer"))){return this.readsValue&&(this.readsValue=null,r==null||r.add(this,S.Updated)),r==null||r.attemptAutoclose("remove-value-writer",this.id),this}removeValueReader(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-value-reader"))){return this.writesValues.includes(r)?(this.writesValues=this.writesValues.filter(o=>o.id!==r.id),a==null||a.add(this,S.Affected),this):(a==null||a.attemptAutoclose("remove-value-reader",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const o=Lr(this,r),p=this.toMeta();return this.x=r.x||p.x,this.y=r.y||p.y,this.catchesError=r.catchesError!==void 0?r.catchesError:this.catchesError,super.metaSync(r),r.deleted===!0&&!p.deleted?a==null||a.add(this,S.Removed):r.deleted===!1&&p.deleted?a==null||a.add(this,S.Added):o&&(a==null||a.add(this,S.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(r=ve,...a){return await xt.repository.APILoad(this.id,...a),this}async APICreate(r=ve,...a){return await xt.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(r=ve,...a){return await xt.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(r=ve,...a){return await xt.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(r=ve,...a){return await xt.repository.APIClone(this.id,...a),this}async APILoadVersion(r=ve,a,...o){return await xt.repository.APILoadVersion(this.id,a,...o)}removeFromParent(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){const a=[],o=[],p=[],e=[];return this.parent.type===f.Project?(this.parent.removeVariableInstance(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),r==null||r.attemptAutoclose("remove-from-parent",this.id),{added:R(p),updated:R(a),removed:R(o),affected:R(e),self:this}}remove({ignoreUpstream:r}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){const o=[],p=[],e=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:w,added:A}=v.entity.onDetachedDependencyRemoved(this,v.field,a);o.push(...E),p.push(...w),e.push(...A)}),this.defaultValue){const{updated:v,removed:E}=this.defaultValue.remove({ignoreUpstream:!0},a);o.push(...v),p.push(...E)}if(this.readsValue&&(o.push(this.readsValue),this.readsValue.removeValueReader(this,a)),this.writesValues.forEach(v=>{o.push(v),v.setValueWriter(null,a)}),this.inputs.forEach(v=>{const{updated:E,removed:w}=v.remove({ignoreUpstream:!0},a);o.push(...E),p.push(...w)}),this.outputs.forEach(v=>{const{updated:E,removed:w}=v.remove({ignoreUpstream:!0},a);o.push(...E),p.push(...w)}),this.successCalls.forEach(v=>{o.push(v),v.removeCaller(this,a)}),this.errorCalls.forEach(v=>{o.push(v),v.removeCaller(this,a)}),this.internalCalls.forEach(v=>{const{updated:E,removed:w}=v.remove({ignoreUpstream:!0},a);o.push(...E),p.push(...w)}),!r){const v=this.removeFromParent(a);e.push(...v.added),o.push(...v.updated),p.push(...v.removed),y.push(...v.affected),this.calledBy.forEach(E=>{o.push(E),E.removeCall(this,a)})}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:R(e),updated:R(o),removed:R(p),affected:R(y),self:this}}restore({}={},r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){const a=[],o=[],p=[],e=[];if(r!=null&&r.hasAdded(this.id))return r==null||r.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},r),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:E,added:w}=y.entity.onDetachedDependencyRestored(this,y.field,r);o.push(...v),p.push(...E),a.push(...w)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},r);o.push(...y)}return this.readsValue&&(o.push(this.readsValue),this.readsValue.addValueReader(this,r)),this.writesValues.forEach(y=>{o.push(y),y.setValueWriter(this,r)}),this.inputs.forEach(y=>{const{updated:v}=y.restore({},r);o.push(...v)}),this.outputs.forEach(y=>{const{updated:v}=y.restore({},r);o.push(...v)}),this.successCalls.forEach(y=>{o.push(y),y.addSuccessCaller(this,r)}),this.errorCalls.forEach(y=>{o.push(y),y.addErrorCaller(this,r)}),this.internalCalls.forEach(y=>{const{updated:v}=y.restore({},r);o.push(...v)}),this.calledBySuccess.forEach(y=>{o.push(y),y.addSuccessCall(this,r)}),this.calledByError.forEach(y=>{o.push(y),y.addErrorCall(this,r)}),this.calledByEntry.forEach(y=>{o.push(y),y.addCall(this,r)}),r==null||r.attemptAutoclose("restore-entity",this.id),{added:R(a),updated:R(o),removed:R(p),affected:R(e),self:this}}toFlat(r=new Set){var o,p;return r.has(this.id)?[]:(r.add(this.id),[this,...((o=this.defaultValue)==null?void 0:o.toFlat(r))||[],...this.writesValues.flatMap(e=>e.toFlat(r)),...((p=this.readsValue)==null?void 0:p.toFlat(r))||[],...this.successCalls.flatMap(e=>e.toFlat(r)),...this.errorCalls.flatMap(e=>e.toFlat(r)),...this.inputs.flatMap(e=>e.toFlat(r)),...this.outputs.flatMap(e=>e.toFlat(r)),...this.internalCalls.flatMap(e=>e.toFlat(r))])}toFlatIds(r=new Set){var o;return r.has(this.id)?[]:(r.add(this.id),[this.id,...((o=this.defaultValue)==null?void 0:o.toFlatIds(r))||[],...this.writesValues.flatMap(p=>p.toFlatIds(r)),...this.successCalls.flatMap(p=>p.toFlatIds(r)),...this.errorCalls.flatMap(p=>p.toFlatIds(r)),...this.inputs.flatMap(p=>p.toFlatIds(r)),...this.outputs.flatMap(p=>p.toFlatIds(r)),...this.internalCalls.flatMap(p=>p.toFlatIds(r))])}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}}toJSON(r=new Set){var a,o,p;return r.has(this.id)?this.toReference():(r.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,declaration:this.declaration.toJSON(r),defaultValue:((a=this.defaultValue)==null?void 0:a.toJSON(r))||null,readsValue:((o=this.readsValue)==null?void 0:o.toReference())||null,writesValues:this.writesValues.map(e=>e.toJSON(r)),inputs:this.inputs.map(e=>e.toJSON(r)),outputs:this.outputs.map(e=>e.toJSON(r)),successCalls:this.successCalls.map(e=>e.toJSON(r)),errorCalls:this.errorCalls.map(e=>e.toJSON(r)),internalCalls:this.internalCalls.map(e=>e.toJSON(r)),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:((p=this.error)==null?void 0:p.toJSON(r))||null,x:this.x,y:this.y})}toJSONClone(r=Se){var o,p,e,y,v,E,w,A;let a;return(o=r.seenEntityMaps)!=null&&o.has(this.id)?a=r.seenEntityMaps.get(this.id):(a=r.newId||jr(this,this.project,r.uuidStrategy),r.seenEntityMaps&&r.seenEntityMaps.set(this.id,a)),(p=r.seenEntities)!=null&&p.has(a)||(e=r.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:r.seenEntityMaps}):((y=r.seenEntities)==null||y.add(a),(v=r.seenEntities)==null||v.add(this.id),{id:a,version:N.UUID.uuid(),createdAt:r.timestamp||L().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,defaultValue:((E=this.defaultValue)==null?void 0:E.toJSONClone({...r,newId:null}))||null,declaration:this.declaration.toReference({seenEntityMaps:r.seenEntityMaps}),readsValue:((w=this.readsValue)==null?void 0:w.toReference({seenEntityMaps:r.seenEntityMaps}))||null,writesValues:this.writesValues.map($=>$.toJSONClone({...r,newId:null})),inputs:this.inputs.map($=>$.toJSONClone({...r,newId:null})),outputs:this.outputs.map($=>$.toJSONClone({...r,newId:null})),successCalls:this.successCalls.map($=>$.toJSONClone({...r,newId:null})),errorCalls:this.errorCalls.map($=>$.toJSONClone({...r,newId:null})),internalCalls:this.internalCalls.map($=>this.calledBy.length||this.readsValue?$.toJSONClone({...r,newId:null}):$.toReference({seenEntityMaps:r.seenEntityMaps})),calledBySuccess:this.calledBySuccess.map($=>$.toReference({seenEntityMaps:r.seenEntityMaps})),calledByError:this.calledByError.map($=>$.toReference({seenEntityMaps:r.seenEntityMaps})),calledByEntry:this.calledByEntry.map($=>$.toReference({seenEntityMaps:r.seenEntityMaps})),error:((A=this.error)==null?void 0:A.toJSONClone({...r,newId:null}))||null,parent:this.parent.toReference({seenEntityMaps:r.seenEntityMaps}),x:this.x,y:this.y})}toReference(r=Se){var o;let a=this.id;return(o=r.seenEntityMaps)!=null&&o.has(this.id)&&(a=r.seenEntityMaps.get(this.id)),{id:a+"--"+N.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(r=Se){var o,p,e,y,v;let a=this.id;return(o=r.seenEntityMaps)!=null&&o.has(this.id)&&(a=r.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,x:this.x,y:this.y,defaultValue:((p=this.defaultValue)==null?void 0:p.toReference(r))||null,declaration:((e=this.declaration)==null?void 0:e.toReference(r))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(r))||null,writesValues:this.writesValues.map(E=>E.toReference(r)),inputs:this.inputs.map(E=>E.toReference(r)),outputs:this.outputs.map(E=>E.toReference(r)),successCalls:this.successCalls.map(E=>E.toReference(r)),errorCalls:this.errorCalls.map(E=>E.toReference(r)),calledBySuccess:this.calledBySuccess.map(E=>E.toReference(r)),calledByError:this.calledByError.map(E=>E.toReference(r)),calledByEntry:this.calledByEntry.map(E=>E.toReference(r)),internalCalls:this.internalCalls.map(E=>E.toReference(r)),error:((v=this.error)==null?void 0:v.toReference(r))||null,parent:this.parent.toReference(r)}}toFlatJSON(r=new Set){var o,p;return r.has(this.id)?[]:(r.add(this.id),[this.toShallowJSON(),...((o=this.defaultValue)==null?void 0:o.toFlatJSON(r))||[],...((p=this.declaration)==null?void 0:p.toFlatJSON(r))||[],...this.writesValues.flatMap(e=>e.toFlatJSON(r)),...this.successCalls.flatMap(e=>e.toFlatJSON(r)),...this.errorCalls.flatMap(e=>e.toFlatJSON(r)),...this.inputs.flatMap(e=>e.toFlatJSON(r)),...this.outputs.flatMap(e=>e.toFlatJSON(r)),...this.internalCalls.flatMap(e=>e.toFlatJSON(r)),...this.calledBy.flatMap(e=>e.toFlatJSON(r))])}toGenerationTarget(){const r=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(a=>a.id),calledBySuccess:this.calledBySuccess.map(a=>a.id),calledByError:this.calledByError.map(a=>a.id),parent:r}}toFlatGenerationTarget(r=new Set){var o,p,e;return r.has(this.id)?[]:(r.add(this.id),[this.toGenerationTarget(),...((o=this.defaultValue)==null?void 0:o.toFlatGenerationTarget(r))||[],...((p=this.declaration)==null?void 0:p.toFlatGenerationTarget(r))||[],...((e=this.readsValue)==null?void 0:e.toFlatGenerationTarget(r))||[],...this.writesValues.flatMap(y=>y.toFlatGenerationTarget(r)),...this.successCalls.flatMap(y=>y.toFlatGenerationTarget(r)),...this.errorCalls.flatMap(y=>y.toFlatGenerationTarget(r)),...this.inputs.flatMap(y=>y.toFlatGenerationTarget(r)),...this.outputs.flatMap(y=>y.toFlatGenerationTarget(r)),...this.internalCalls.flatMap(y=>y.toFlatGenerationTarget(r))])}clearErrors(){var r;return this.errors=[],(r=this.defaultValue)==null||r.clearErrors(),this.inputs.forEach(a=>a.clearErrors()),this.outputs.forEach(a=>a.clearErrors()),this.successCalls.forEach(a=>a.clearErrors()),this.errorCalls.forEach(a=>a.clearErrors()),this.internalCalls.forEach(a=>a.clearErrors()),this}validate(){const r=g3(this);return this.errors=r,{success:!0}}getErrors(){var a,o;return[...this.errors,...((a=this.defaultValue)==null?void 0:a.getErrors())||[],...this.inputs.flatMap(p=>p.getErrors()),...this.internalCalls.flatMap(p=>p.getErrors()),...this.outputs.flatMap(p=>p.getErrors()),...((o=this.readsValue)==null?void 0:o.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var r;return this.defaultValue||((r=this.declaration)==null?void 0:r.defaultValue)||null}setDefaultValue(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"set-default-value"))){const o=this.defaultValue;return(o==null?void 0:o.id)!==(r==null?void 0:r.id)&&(o==null||o.remove({ignoreUpstream:!0},a),this.defaultValue=r,a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("set-default-value",this.id),this}clone(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,o=null,p=!0){var B,F,K,q;let e=Ur(a,this);const y=this.toJSON(),v=o||N.UUID.uuid();y.inputs=[],y.id=v,y.version=N.UUID.uuid(),y.createdAt=(r==null?void 0:r.timestamp)||L().toISOString(),y.author=(r==null?void 0:r.author)||"1",y.previousVersion=null,y.deleted=!1;const E=dr(y,e);a?E.setParent(a,null):E.setParent(this.parent,null),p&&E.subscribe(),E.initChildren(r),r==null||r.add(E,S.Added);const w=(B=this.defaultValue)==null?void 0:B.clone(r,E,N.UUID.uuid(),p);E.defaultValue=w||null;const A=(F=this.inputs)==null?void 0:F.map(ie=>ie.clone(r,E,N.UUID.uuid(),p));E.inputs=A;const $=(K=this.outputs)==null?void 0:K.map(ie=>ie.clone(r,E,N.UUID.uuid(),p));E.outputs=$;const V=(q=this.internalCalls)==null?void 0:q.map(ie=>ie.clone(r,E,N.UUID.uuid(),p));return E.internalCalls=V,r==null||r.attemptAutoclose("clone-entity",this.id),E}addInternalCall(r){return this.internalCalls.find(a=>a===r)||this.internalCalls.push(r),this}setDeclaration(r){return this.declaration!==r&&(this.declaration=r),this}removeUnrecognizedInputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-variable-instance-inputs"))){const a=[],o=[],p=[],e=[];return this.declaration.dataType&&!this.declaration.dataType.isObject()?[...this.inputs].forEach(y=>{const v=y.remove({ignoreUpstream:!1},r);p.push(...v.removed),a.push(...v.updated)}):this.declaration.dataType&&this.declaration.dataType.hasStrictObjectStructure()&&[...this.inputs].forEach(y=>{var E;if(!y.declaration){const w=y.remove({ignoreUpstream:!1},r);p.push(...w.removed),a.push(...w.updated);return}if(![...((E=this.declaration.dataType)==null?void 0:E.entity).allProperties].find(w=>y.declaration===w)){const w=y.remove({ignoreUpstream:!1},r);p.push(...w.removed),a.push(...w.updated)}}),r==null||r.attemptAutoclose("remove-unrecognized-variable-instance-inputs",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}removeUnrecognizedOutputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-variable-instance-outputs"))){const a=[],o=[],p=[],e=[];return this.declaration.dataType&&!this.declaration.dataType.isObject()?[...this.outputs].forEach(y=>{const v=y.remove({ignoreUpstream:!1},r);p.push(...v.removed),a.push(...v.updated)}):this.declaration.dataType&&this.declaration.dataType.hasStrictObjectStructure()&&[...this.outputs].forEach(y=>{var E;if(!y.declaration){const w=y.remove({ignoreUpstream:!1},r);p.push(...w.removed),a.push(...w.updated);return}if(![...((E=this.declaration.dataType)==null?void 0:E.entity).allProperties].find(w=>y.declaration===w)){const w=y.remove({ignoreUpstream:!1},r);p.push(...w.removed),a.push(...w.updated)}}),r==null||r.attemptAutoclose("remove-unrecognized-variable-instance-outputs",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}removeUnrecognizedInternalCalls(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-variable-declaration-internal-calls"))){var v;const a=[],o=[],p=[],e=[];if(!this.declaration.dataType||!this.declaration.dataType.entity||![f.DefinitionEntity,f.PrimitiveEntity,f.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))[...this.internalCalls].forEach(E=>{const w=E.remove({ignoreUpstream:!1},r);p.push(...w.removed),a.push(...w.updated)});else if(this.declaration.dataType&&this.declaration.dataType.entity&&[f.DefinitionEntity,f.PrimitiveEntity,f.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)){const E=[...((v=this.declaration.dataType)==null?void 0:v.entity).allMethods];[...this.internalCalls].forEach(w=>{if(!w.declaration){const $=w.remove({ignoreUpstream:!1},r);p.push(...$.removed),a.push(...$.updated);return}if(!E.find($=>w.declaration===$)){const $=w.remove({ignoreUpstream:!1},r);p.push(...$.removed),a.push(...$.updated);return}})}return this.internalCalls.filter((E,w)=>{const A=this.internalCalls.findIndex(V=>V.declaration===E.declaration&&V!==E);if(A===-1)return!1;const $=this.internalCalls[A];return L($==null?void 0:$.createdAt).isSame(L(E.createdAt))?w>A:!!L($==null?void 0:$.createdAt).isAfter(E.createdAt)}).forEach(E=>{const w=E.remove({ignoreUpstream:!1},r);p.push(...w.removed),a.push(...w.updated)}),r==null||r.attemptAutoclose("remove-unrecognized-variable-declaration-internal-calls",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}syncInputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"sync-variable-instance-inputs"))){const a=[],o=[],p=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity){if([f.DefinitionEntity,f.PrimitiveEntity,f.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList){const y=[...this.declaration.dataType.entity.properties];y.filter(A=>!A.getDataType(r)).forEach(A=>{const $=this.inputs.find(F=>Y(F,this.project)===Y(A,this.project));if(!$)return;const V=this.declaration.getMasterInputWithValueWritterFromAllInstances($);if(!V)return;const B=Tn(V);A.setDataType(B,r),$.setDeclaration(A,r)}),y.filter(A=>!this.inputs.find($=>{var V;return((V=$.declaration)==null?void 0:V.id)===A.id})).forEach(A=>{const $={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||L().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.InputMap,parent:this.toReference(),name:null,description:null,codeName:null,declaration:A,defaultValue:null,index:A.index,readsValue:null},V=ne($,this.project);return V.setParent(this,r),V.initChildren(r),r==null||r.add(V,S.Added),this.addInput(V,r),V}),this.inputs.filter(A=>!A.declaration).forEach(A=>{const $=y.find(V=>Y(V,this.project)===Y(A,this.project));$&&A.setDeclaration($,r)})}}else return r==null||r.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return r==null||r.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return r==null||r.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:R(a),updated:R(o),removed:R(p),affected:R(e),self:this}}syncOutputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"sync-variable-instance-outputs"))){const a=[],o=[],p=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity)[f.DefinitionEntity,f.PrimitiveEntity,f.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList&&[...this.declaration.dataType.entity.properties].filter(E=>!this.outputs.find(w=>w.declaration===E)).map(E=>{const w={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||L().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.OutputMap,parent:this.toReference(),defaultValue:null,declaration:E,index:E.index,writesValues:[]},A=ne(w,this.project);return A.setParent(this,r),A.initChildren(r),r==null||r.add(A,S.Added),this.addOutput(A,r),A});else return r==null||r.attemptAutoclose("sync-variable-instance-outputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return r==null||r.attemptAutoclose("sync-variable-instance-outputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return r==null||r.attemptAutoclose("sync-variable-instance-outputs",this.id),{added:R(a),updated:R(o),removed:R(p),affected:R(e),self:this}}generateUnusedInternalCalls(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"generate-unused-internal-calls"))){const a=[],o=[],p=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity)[f.DefinitionEntity,f.PrimitiveEntity,f.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList&&[...this.declaration.dataType.entity.getAllInteractiveMethods()].filter(E=>!this.internalCalls.find(A=>{var V,B,F,K,q;return(((V=A.declaration)==null?void 0:V.id)||((F=(B=A.initialData)==null?void 0:B.declaration)==null?void 0:F.entityId)||((q=(K=A.initialData)==null?void 0:K.declaration)==null?void 0:q.id))===E.id})).map(E=>{const w=E.createInternalCall(r,this);return r==null||r.add(w,S.Added),this.addInternalCall(w),w});else return r==null||r.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return r==null||r.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return r==null||r.attemptAutoclose("generate-unused-internal-calls",this.id),{added:R(a),updated:R(o),removed:R(p),affected:R(e),self:this}}getDataType(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"get-data-type"))){var a;return((a=this.declaration)==null?void 0:a.getDataType(r))||null}getUnusedInputs(){return this.inputs.filter(r=>r.suggestion||!r.readsValue&&!r.defaultValue)}getUnusedOutputs(){return this.outputs.filter(r=>r.suggestion||!r.writesValues.length)}getUsedInputs(){return this.inputs.filter(r=>!r.suggestion&&(r.readsValue||r.defaultValue))}getUsedOutputs(){return this.outputs.filter(r=>!r.suggestion&&r.writesValues.length)}};_(xt,"repository",{APICreate:async(r,...a)=>r,APIUpdate:async(r,...a)=>r,APIDelete:async(r,...a)=>r,APIClone:async(r,...a)=>{},APILoad:async(r,...a)=>null,APILoadVersion:async(r,a,...o)=>null}),_(xt,"type",f.VariableInstance),_(xt,"USER_MANAGED_PARENT_TYPES",[...Nr,f.Project]),_(xt,"PARENT_TYPES",[...xt.USER_MANAGED_PARENT_TYPES]),_(xt,"MUTABLE_BASE_PROPERTIES",["catchesError"]),_(xt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),_(xt,"BASE_PROPERTIES",[...xt.MUTABLE_BASE_PROPERTIES,...xt.INMUTABLE_BASE_PROPERTIES]),_(xt,"MUTABLE_META_PROPERTIES",[...xt.MUTABLE_BASE_PROPERTIES,"x","y"]),_(xt,"INMUTABLE_META_PROPERTIES",[...xt.INMUTABLE_BASE_PROPERTIES]),_(xt,"META_PROPERTIES",[...xt.MUTABLE_META_PROPERTIES,...xt.INMUTABLE_META_PROPERTIES]),_(xt,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),_(xt,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),_(xt,"UPSTREAM_PROPERTIES",[...xt.MUTABLE_UPSTREAM_PROPERTIES,...xt.INMUTABLE_UPSTREAM_PROPERTIES]),_(xt,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),_(xt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),_(xt,"DOWNSTREAM_PROPERTIES",[...xt.MUTABLE_DOWNSTREAM_PROPERTIES,...xt.INMUTABLE_DOWNSTREAM_PROPERTIES]),_(xt,"PROPERTIES",[...xt.META_PROPERTIES,...xt.UPSTREAM_PROPERTIES,...xt.DOWNSTREAM_PROPERTIES]);let ao=xt;var _3=(d=>(d.Parent="parent",d.DataTypeEntity="variable-data-type-entity",d.DataType="variable-data-type",d))(_3||{});const jt=class jt extends Cr{constructor(r,a){super(r);_(this,"initialData");_(this,"id");_(this,"name");_(this,"codeName",null);_(this,"description",null);_(this,"required",!1);_(this,"constant",!1);_(this,"x");_(this,"y");_(this,"type",f.VariableDeclaration);_(this,"catchesError",!1);_(this,"defaultValue",null);_(this,"dataType",null);_(this,"writesValues",[]);_(this,"readsValue",null);_(this,"inputs",[]);_(this,"outputs",[]);_(this,"error",null);_(this,"calledBySuccess",[]);_(this,"calledByError",[]);_(this,"calledByEntry",[]);_(this,"successCalls",[]);_(this,"errorCalls",[]);_(this,"internalCalls",[]);_(this,"parent");_(this,"errors",[]);_(this,"project");_(this,"detachedDependents",{});_(this,"knownVersions",null);_(this,"activeVersion",!1);_(this,"initialized",!1);_(this,"startedInitialization",!1);_(this,"suggestion",!1);_(this,"codeNativeValueValidation",null);this.initialData=r,this.project=a,this.id=r.id,this.name=r.name,this.description=r.description,this.constant=r.constant,this.codeName=r.codeName,this.required=r.required,this.x=r.x,this.y=r.y,this.catchesError=r.catchesError||!1}static new(r=null){return{id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||L().toISOString(),author:(r==null?void 0:r.author)||N.sessionAuthor,previousVersion:null,deleted:!1,type:f.VariableDeclaration,catchesError:!0,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(r,a){let o=a;if(r.parent){const A=J(r.parent);o=a.get(A)}const p=r.calledByEntry.map(A=>{const $=J(A);return a.get($)}),e=r.calledBySuccess.map(A=>{const $=J(A);return a.get($)}),y=r.calledByError.map(A=>{const $=J(A);return a.get($)});let v=null;if(r.readsValue){const A=J(r.readsValue);v=a.get(A)}const E={id:r.id,version:N.UUID.uuid(),createdAt:L().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.VariableDeclaration,catchesError:r.catchesError||!1,name:r.name,defaultValue:null,codeName:r.codeName||null,description:r.description||null,constant:r.constant||!1,required:r.required||!1,calledByEntry:p,calledBySuccess:e,calledByError:y,dataType:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:v,inputs:[],outputs:[],writesValues:[],error:null,x:0,y:0,parent:o},w=ne(E,a);return w.setParent(o,null),w}static validateGenerationTarget(r,a){let o=JSON.parse(JSON.stringify(r));const p=[],e=ti(o,{parent:{list:!1,types:[...Nr,f.Project],optional:!0}},a);o=e.modifiedData;const y=gb(o,a);return p.push(...e.errors,...y,...Vr(o)),{errors:p,modifiedData:o}}get variableInstances(){const r=[];return Object.values(this.detachedDependents).forEach(a=>{a.field===fA.VarDeclaration&&!r.includes(a.entity)&&r.push(a.entity)}),r}validateGeneratedUpdate(r){const a=[];let o=JSON.parse(JSON.stringify(r));const p=Zp(o,this);return o=p.modifiedData,a.push(...p.errors),r.parent&&a.push(new ae({id:`${this.id}--${k.InvalidParentUpdate}`,code:k.InvalidParentUpdate,severity:H.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.
@@ -393,7 +393,7 @@ All global 'function-declaration' entity ids are:
393
393
  The project currently has no global 'function-declaration' entities that can be called as 'function-call' entities.`;p.push(new ae({id:`${o.id}--${k.InvalidReference}`,code:k.InvalidReference,severity:H.Error,message:`Entity of type "${f.FunctionCall}" with id "${o.id}", has an invalid reference at the 'declaration' property. The 'declaration' property must be a valid reference to an 'function-declaration' entity.
394
394
  References can either be an ID string or an object with exacly four properties: 'id', 'entityId', 'entityType', 'type'.${v}`}))}return{errors:p,modifiedData:o}}validateGeneratedUpdate(r){const a=[];return r.parent&&a.push(new ae({id:`${this.id}--${k.InvalidParentUpdate}`,code:k.InvalidParentUpdate,severity:H.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.
395
395
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
396
- You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`})),{errors:a,modifiedData:r}}subscribeDependents(r){return r.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(r){return r.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],o=[],p=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(r);a.push(...v.updated),o.push(...v.added),p.push(...v.removed),e.push(...v.affected)}),r==null||r.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}onDetachedDependencyRemoved(r,a,o){const p=[],e=[],y=[],v=[];if(a==="declaration"){const{updated:E,added:w,removed:A}=this.remove({ignoreUpstream:!1},o);p.push(...E),e.push(...w),y.push(...A)}if(a==="parent"){const{updated:E,added:w,removed:A}=this.remove({ignoreUpstream:!1},o);p.push(...E),e.push(...w),y.push(...A)}return{updated:R(p),added:R(e),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(r,a,o){const p=[],e=[],y=[],v=[];if(a==="declaration"){const{updated:E,added:w,removed:A}=this.restore({},o);p.push(...E),e.push(...w),y.push(...A)}if(a==="parent"){const{updated:E,added:w,removed:A}=this.restore({},o);p.push(...E),e.push(...w),y.push(...A)}return{updated:R(p),added:R(e),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){var r;return(r=this.parent)==null||r.unsubscribeDependents([{entity:this,field:"parent"}]),this.declaration.unsubscribeDependents([{entity:this,field:"declaration"}]),this}subscribeToDependencies(){var r;return(r=this.parent)==null||r.subscribeDependents([{entity:this,field:"parent"}]),this.declaration.subscribeDependents([{entity:this,field:"declaration"}]),this}increaseVersion(r){if(r&&!L(r).isValid())throw new Error(`The shared timestamp '${r}' is not a valid ISO 8601 date string.`);return r&&L(r).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=N.UUID.uuid(),this.createdAt=L(r).toISOString()||L().toISOString(),this)}captureVersion(){var a;const r=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Qt(this,this.project);return r.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,r):new Map([[this.version,r]]),r.inputs=[...this.inputs],r.outputs=[...this.outputs],r.error=this.error,r.successCalls=[...this.successCalls],r.errorCalls=[...this.errorCalls],r.process=this.process,r.declaration=this.declaration,r.calledBySuccess=[...this.calledBySuccess],r.calledByError=[...this.calledByError],r.calledByEntry=[...this.calledByEntry],r.parent=this.parent,this}recursiveCaptureUpstreamVersions(r){const a=[],o=[],p=[],e=[];if(this.parent){this.parent.increaseVersion(r);const y=this.parent.recursiveCaptureUpstreamVersions(r);a.push(this.parent,...y.updated),o.push(...y.added),p.push(...y.removed)}return{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}async restoreVersion(r){var v;const a=[],o=[],p=[],e=[];if(this.version===r)return{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this};if(!this.knownVersions){const E=new Map;for(const[w,A]of this.knownVersions||new Map){if(E.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[$,V]of A.knownVersions)E.set($,V);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(r);if(!y){const E=await this.APILoadVersion({},r);if(!E)throw new Error(`Version with id '${r}' for entity with id '${this.id}' not found.`);y=new Qt(E,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.error=y.error,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.process=y.process,this.declaration=y.declaration,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.parent=y.parent,{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}updateWithShallowTransfer(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(r,a),this.version=r.version,this.createdAt=r.createdAt,this.author=r.author,this.deleted=r.deleted,this.previousVersion=r.previousVersion,this.unsubscribeFromDependencies(),r.parent){const o=J(r.parent),p=this.project.get(o),e=this.parent;if(e&&e.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,a);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${o}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(r.declaration){const o=J(r.declaration),p=this.project.get(o);p&&this.setDeclaration(p)}return r.calledByEntry.forEach(o=>{const p=J(o),e=this.project.get(p);e&&(this.addEntryCaller(e,a),e.addCall(this,a))}),[...this.calledByEntry].forEach(o=>{r.calledByEntry.find(e=>J(e)===o.id)||(this.removeCaller(o,a),o.removeCall(this,a))}),r.calledBySuccess.forEach(o=>{const p=J(o),e=this.project.get(p);e&&(this.addSuccessCaller(e,a),e.addSuccessCall(this,a))}),[...this.calledBySuccess].forEach(o=>{r.calledBySuccess.find(e=>J(e)===o.id)||(this.removeCaller(o,a),o.removeCall(this,a))}),r.calledByError.forEach(o=>{const p=J(o),e=this.project.get(p);e&&(this.addErrorCaller(e,a),e.addErrorCall(this,a))}),[...this.calledBySuccess].forEach(o=>{r.calledBySuccess.find(e=>J(e)===o.id)||(this.removeCaller(o,a),o.removeCall(this,a))}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const r=[],a=[],o=[],p=[];if(this.initialData.parent){const e=J(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),r.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.declaration){const e=J(this.initialData.declaration),y=this.project.get(e);y&&(this.setDeclaration(y),r.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=J(e),v=this.project.get(y);v&&this.addEntryCaller(v,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=J(e),v=this.project.get(y);v&&this.addSuccessCaller(v,null)}),this.initialData.calledByError.forEach(e=>{const y=J(e),v=this.project.get(y);v&&this.addErrorCaller(v,null)}),{updated:R(r),added:R(a),removed:R(o),affected:R(p),self:this}}afterAllChildrenInitialized(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],o=[],p=[],e=[];this.initialized=!0;const{updated:y,added:v,removed:E}=this.syncInputs(r),{updated:w,added:A,removed:$}=this.syncOutputs(r);return a.push(...y,...w),o.push(...v,...A),p.push(...E,...$),this.captureVersion(),r==null||r.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}addSelfToProject(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){var y;const a=[this],o=[],p=[],e=[];return this.parent===this.project&&this.project.addFunctionCall(this),(y=this.process)==null||y.writesValues.forEach(v=>{v.setValueWriter(this.process,r),a.push(v)}),this.successCalls.forEach(v=>{v.addSuccessCaller(this,r),a.push(v)}),this.errorCalls.forEach(v=>{v.addErrorCaller(this,r),a.push(v)}),this.calledBySuccess.forEach(v=>{v.addSuccessCall(this,r),a.push(v)}),this.calledByError.forEach(v=>{v.addErrorCall(this,r),a.push(v)}),this.calledByEntry.forEach(v=>{v.addCall(this,r),a.push(v)}),this.subscribe(),this.subscribeToDependencies(),r==null||r.attemptAutoclose("add-self-to-project",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-input"))){const o=this.inputs.findIndex(p=>p.id===r.id);return o>-1&&(this.inputs.splice(o,1),a&&(a==null||a.add(this,S.Affected))),a==null||a.attemptAutoclose("remove-input",this.id),this}addInput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-input"))){return this.inputs.includes(r)?(a==null||a.attemptAutoclose("add-input",this.id),this):(this.inputs.push(r),a==null||a.add(this,S.Affected),a==null||a.attemptAutoclose("add-input",this.id),this)}addOutput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-output"))){return this.outputs.includes(r)?(a==null||a.attemptAutoclose("add-output",this.id),this):(this.outputs.push(r),a==null||a.add(this,S.Affected),a==null||a.attemptAutoclose("add-output",this.id),this)}removeOutput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-output"))){const o=this.outputs.findIndex(p=>p.id===r.id);return o>-1&&(this.outputs.splice(o,1),a&&(a==null||a.add(this,S.Affected))),a==null||a.attemptAutoclose("remove-output",this.id),this}addValueReader(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-value-reader"))){var o;return this.process&&!this.process.writesValues.includes(r)&&((o=this.process)==null||o.addValueReader(r,a),a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("add-value-reader",this.id),this}removeValueReader(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-value-reader"))){var o;return this.process&&this.process.writesValues.includes(r)&&((o=this.process)==null||o.removeValueReader(r,a),a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("remove-value-reader",this.id),this}addSuccessCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-success-caller")),o=!1){return this.calledBySuccess.find(p=>p.id===r.id)||(this.calledBySuccess.push(r),a==null||a.add(this,S.Updated),o&&He(this,a)),a==null||a.attemptAutoclose("add-success-caller",this.id),this}addErrorCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-error-caller")),o=!1){return this.calledByError.find(p=>p.id===r.id)||(this.calledByError.push(r),a==null||a.add(this,S.Updated),o&&He(this,a)),a==null||a.attemptAutoclose("add-error-caller",this.id),this}addEntryCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-entry-caller")),o=!1){return this.calledByEntry.find(p=>p.id===r.id)||(this.calledByEntry.push(r),a==null||a.add(this,S.Updated),o&&He(this,a)),a==null||a.attemptAutoclose("add-entry-caller",this.id),this}addErrorCall(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-error-call")),o=!1){return this.errorCalls.find(p=>p.id===r.id)||(this.errorCalls.push(r),o&&He(this,a),a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("add-error-call",this.id),this}addSuccessCall(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-success-call")),o=!1){return this.successCalls.find(p=>p.id===r.id)||(this.successCalls.push(r),o&&He(this,a),a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("add-success-call",this.id),this}removeCall(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-call")),o=!1){const p=this.successCalls.findIndex(y=>y.id===r.id);p>-1&&(this.successCalls.splice(p,1),a==null||a.add(this,S.Affected));const e=this.errorCalls.findIndex(y=>y.id===r.id);return e>-1&&(this.errorCalls.splice(e,1),a==null||a.add(this,S.Affected)),o&&He(this,a),a==null||a.attemptAutoclose("remove-call",this.id),this}removeCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-caller")),o=!1){return this.calledBySuccess=this.calledBySuccess.filter(p=>p.id!==r.id?!0:(a==null||a.add(this,S.Updated),a==null||a.add(p,S.Affected),!1)),this.calledByError=this.calledByError.filter(p=>p.id!==r.id?!0:(a==null||a.add(this,S.Updated),a==null||a.add(p,S.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(p=>p.id!==r.id?!0:(a==null||a.add(this,S.Updated),a==null||a.add(p,S.Affected),!1)),o&&He(this,a),a==null||a.attemptAutoclose("remove-caller",this.id),this}setParent(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var o;return((o=this.parent)==null?void 0:o.id)!==(r==null?void 0:r.id)&&(this.parent=r,a&&(a==null||a.add(this,S.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}setDeclaration(r){return this.declaration=r,this}initChildren(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.declaration.type===f.FunctionDeclaration){const a=ne(this.initialData.declaration,this.project);this.declaration=a}else{const a=J(this.initialData.declaration),o=this.project.get(a);this.declaration=o}return this.successCalls=this.initialData.successCalls.map(a=>{const o=ne(a,this.project);if(o.addSuccessCaller(this),[f.BreakStatement,f.ContinueStatement].includes(o.type))o.setParent(this.parent.parent,null),o.initChildren(r);else if(o.type===f.ReturnStatement){const p=Hr(this,this.project);o.setParent(p,null),o.initChildren(r)}else o.type!==f.InternalCall&&(o.setParent(this.parent,null),o.initChildren(r));return o}),this.errorCalls=this.initialData.errorCalls.map(a=>{const o=ne(a,this.project);if(o.addErrorCaller(this),[f.BreakStatement,f.ContinueStatement].includes(o.type))o.setParent(this.parent.parent,null),o.initChildren(r);else if(o.type===f.ReturnStatement){const p=Hr(this,this.project);o.setParent(p,null),o.initChildren(r)}else o.type!==f.InternalCall&&(o.setParent(this.parent,null),o.initChildren(r));return o}),this.inputs=this.initialData.inputs.map(a=>{const o=ne(a,this.project);return o.setParent(this,null),o.initChildren(r),o}),this.initialData.process&&(this.process=ne(this.initialData.process,this.project),this.process.setParent(this,null),this.process.initChildren(r)),this.initialData.error&&(this.error=ne(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(r)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(r),r==null||r.attemptAutoclose("init-children",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const o=Lr(this,r),p=this.toMeta();return this.x=r.x||p.x,this.y=r.y||p.y,this.catchesError=r.catchesError!==void 0?r.catchesError:this.catchesError,super.metaSync(r),r.deleted===!0&&!p.deleted?a==null||a.add(this,S.Removed):r.deleted===!1&&p.deleted?a==null||a.add(this,S.Added):o&&(a==null||a.add(this,S.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(r=ve,...a){return await Qt.repository.APILoad(this.id,...a),this}async APICreate(r=ve,...a){return await Qt.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(r=ve,...a){return await Qt.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(r=ve,...a){return await Qt.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(r=ve,...a){return await Qt.repository.APIClone(this.id,...a),this}async APILoadVersion(r=ve,a,...o){return await Qt.repository.APILoadVersion(this.id,a,...o)}removeFromParent(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){const a=[],o=[],p=[],e=[];return this.parent.type===f.Project?(this.parent.removeFunctionCall(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),r==null||r.attemptAutoclose("remove-from-parent",this.id),{added:R(p),updated:R(a),removed:R(o),affected:R(e),self:this}}remove({ignoreUpstream:r}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){var v;const o=[],p=[],e=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(E=>{const{updated:w,removed:A,added:$}=E.entity.onDetachedDependencyRemoved(this,E.field,a);o.push(...w),p.push(...A),e.push(...$)}),this.process){const{updated:E,removed:w}=(v=this.process)==null?void 0:v.remove({ignoreUpstream:!0},a);o.push(...E),p.push(...w)}if(this.inputs.forEach(E=>{const{updated:w,removed:A}=E.remove({ignoreUpstream:!0},a);o.push(...w),p.push(...A)}),this.outputs.forEach(E=>{const{updated:w,removed:A}=E.remove({ignoreUpstream:!0},a);o.push(...w),p.push(...A)}),this.error){const{updated:E,removed:w}=this.error.remove({ignoreUpstream:!0},a);o.push(...E),p.push(...w)}if(this.successCalls.forEach(E=>{o.push(E),E.removeCaller(this,a)}),this.errorCalls.forEach(E=>{o.push(E),E.removeCaller(this,a)}),!r){const E=this.removeFromParent(a);e.push(...E.added),o.push(...E.updated),p.push(...E.removed),y.push(...E.affected),this.calledBy.forEach(w=>{o.push(w),w.removeCall(this,a)})}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:R(e),updated:R(o),removed:R(p),affected:R(y),self:this}}restore({}={},r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){const a=[],o=[],p=[],e=[];if(r!=null&&r.hasAdded(this.id))return r==null||r.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},r),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:E,added:w}=y.entity.onDetachedDependencyRestored(this,y.field,r);o.push(...v),p.push(...E),a.push(...w)}),this.process){const{updated:y}=this.process.restore({},r);o.push(...y)}return this.inputs.forEach(y=>{const{updated:v}=y.restore({},r);o.push(...v)}),this.outputs.forEach(y=>{const{updated:v}=y.restore({},r);o.push(...v)}),this.successCalls.forEach(y=>{o.push(y),y.addSuccessCaller(this,r)}),this.errorCalls.forEach(y=>{o.push(y),y.addErrorCaller(this,r)}),this.calledBySuccess.forEach(y=>{o.push(y),y.addSuccessCall(this,r)}),this.calledByError.forEach(y=>{o.push(y),y.addErrorCall(this,r)}),this.calledByEntry.forEach(y=>{o.push(y),y.addCall(this,r)}),r==null||r.attemptAutoclose("restore-entity",this.id),{added:R(a),updated:R(o),removed:R(p),affected:R(e),self:this}}toFlat(r=new Set){return r.has(this.id)?[]:(r.add(this.id),[this,...this.successCalls.flatMap(o=>o.toFlat(r)),...this.errorCalls.flatMap(o=>o.toFlat(r)),...this.inputs.flatMap(o=>o.toFlat(r)),...this.outputs.flatMap(o=>o.toFlat(r)),...this.process?this.process.toFlat(r):[],...this.error?this.error.toFlat(r):[],...this.calledBy.flatMap(o=>o.toFlat(r))])}toFlatIds(r=new Set){return r.has(this.id)?[]:(r.add(this.id),[this.id,...this.successCalls.flatMap(o=>o.toFlatIds(r)),...this.errorCalls.flatMap(o=>o.toFlatIds(r)),...this.inputs.flatMap(o=>o.toFlatIds(r)),...this.outputs.flatMap(o=>o.toFlatIds(r))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,catchesError:this.catchesError}}toJSON(r=new Set){var a,o;return r.has(this.id)?this.toReference():(r.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,catchesError:this.catchesError,x:this.x,y:this.y,successCalls:this.successCalls.map(p=>p.toJSON(r)),errorCalls:this.errorCalls.map(p=>p.toJSON(r)),calledBySuccess:this.calledBySuccess.map(p=>p.toReference()),calledByError:this.calledByError.map(p=>p.toReference()),calledByEntry:this.calledByEntry.map(p=>p.toReference()),process:(a=this.process)==null?void 0:a.toJSON(r),declaration:this.declaration.toJSON(r),inputs:this.inputs.map(p=>p.toJSON(r)),outputs:this.outputs.map(p=>p.toJSON(r)),parent:this.parent.toReference(),error:(o=this.error)==null?void 0:o.toJSON(r)})}toJSONClone(r=Se){var o,p,e,y,v,E,w;let a;return(o=r.seenEntityMaps)!=null&&o.has(this.id)?a=r.seenEntityMaps.get(this.id):(a=r.newId||jr(this,this.project,r.uuidStrategy),r.seenEntityMaps&&r.seenEntityMaps.set(this.id,a)),(p=r.seenEntities)!=null&&p.has(a)||(e=r.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:r.seenEntityMaps}):((y=r.seenEntities)==null||y.add(a),(v=r.seenEntities)==null||v.add(this.id),{id:a,version:N.UUID.uuid(),createdAt:r.timestamp||L().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(A=>A.toJSONClone({...r,newId:null})),errorCalls:this.errorCalls.map(A=>A.toJSONClone({...r,newId:null})),calledBySuccess:this.calledBySuccess.map(A=>A.toReference({seenEntityMaps:r.seenEntityMaps})),calledByError:this.calledByError.map(A=>A.toReference({seenEntityMaps:r.seenEntityMaps})),calledByEntry:this.calledByEntry.map(A=>A.toReference({seenEntityMaps:r.seenEntityMaps})),process:(E=this.process)==null?void 0:E.toJSONClone({...r,newId:null}),declaration:this.declaration.toJSONClone({...r,newId:null}),inputs:this.inputs.map(A=>A.toJSONClone({...r,newId:null})),outputs:this.outputs.map(A=>A.toJSONClone({...r,newId:null})),error:(w=this.error)==null?void 0:w.toJSONClone({...r,newId:null}),parent:this.parent.toReference({seenEntityMaps:r.seenEntityMaps})})}toReference(r=Se){var o;let a=this.id;return(o=r.seenEntityMaps)!=null&&o.has(this.id)&&(a=r.seenEntityMaps.get(this.id)),{id:a+"--"+N.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(r=Se){var o;let a=this.id;return(o=r.seenEntityMaps)!=null&&o.has(this.id)&&(a=r.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,catchesError:this.catchesError,x:this.x,y:this.y,process:this.process?this.process.toReference(r):null,inputs:this.inputs.map(p=>p.toReference(r)),outputs:this.outputs.map(p=>p.toReference(r)),declaration:this.declaration.toReference(r),successCalls:this.successCalls.map(p=>p.toReference(r)),errorCalls:this.errorCalls.map(p=>p.toReference(r)),calledBySuccess:this.calledBySuccess.map(p=>p.toReference(r)),calledByError:this.calledByError.map(p=>p.toReference(r)),calledByEntry:this.calledByEntry.map(p=>p.toReference(r)),error:this.error?this.error.toReference(r):null,parent:this.parent.toReference(r)}}toFlatJSON(r=new Set){return r.has(this.id)?[]:(r.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(o=>o.toFlatJSON(r)),...this.errorCalls.flatMap(o=>o.toFlatJSON(r)),...this.inputs.flatMap(o=>o.toFlatJSON(r)),...this.outputs.flatMap(o=>o.toFlatJSON(r)),...this.process?this.process.toFlatJSON(r):[],...this.error?this.error.toFlatJSON(r):[]])}toGenerationTarget(){const r=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,calledByEntry:this.calledByEntry.map(a=>a.id),calledBySuccess:this.calledBySuccess.map(a=>a.id),calledByError:this.calledByError.map(a=>a.id),declaration:this.declaration.id,parent:r}}toFlatGenerationTarget(r=new Set){return r.has(this.id)?[]:(r.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(o=>o.toFlatGenerationTarget(r)),...this.errorCalls.flatMap(o=>o.toFlatGenerationTarget(r)),...this.inputs.flatMap(o=>o.toFlatGenerationTarget(r)),...this.outputs.flatMap(o=>o.toFlatGenerationTarget(r)),...this.process?this.process.toFlatGenerationTarget(r):[],...this.error?this.error.toFlatGenerationTarget(r):[]])}clearErrors(){var r,a;return this.errors=[],this.inputs.forEach(o=>o.clearErrors()),this.outputs.forEach(o=>o.clearErrors()),this.successCalls.forEach(o=>o.clearErrors()),this.errorCalls.forEach(o=>o.clearErrors()),(r=this.process)==null||r.clearErrors(),(a=this.error)==null||a.clearErrors(),this}validate(){const r=T5(this);return this.errors=r,{success:!0}}getErrors(){return[...this.errors,...this.inputs.flatMap(a=>a.getErrors()),...this.outputs.flatMap(a=>a.getErrors()),...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,o=null,p=!0){var B,F;let e=Ur(a,this);const y=this.toJSON(),v=o||N.UUID.uuid();y.inputs=[];const E=v.split("-id"),w=E[E.length-1||0]||v;y.id=v,y.version=N.UUID.uuid(),y.createdAt=(r==null?void 0:r.timestamp)||L().toISOString(),y.author=(r==null?void 0:r.author)||"1",y.previousVersion=null,y.deleted=!1;const A=dr(y,e);a?A.setParent(a,null):A.setParent(this.parent,null),p&&A.subscribe(),A.initChildren(r),r==null||r.add(A,S.Added);const $=(B=this.inputs)==null?void 0:B.map((K,q)=>K.clone(r,A,w+"-input-map-"+q+"-id",p));A.inputs=$;const V=(F=this.outputs)==null?void 0:F.map((K,q)=>K.clone(r,A,w+"-output-map-"+q+"-id",p));return A.outputs=V,this.error&&(A.error=this.error.clone(r,A,w+"-error-map-id",p)),this.process&&(A.process=this.process.clone(r,A,w+"-process-id",p)),r==null||r.attemptAutoclose("clone-entity",this.id),A}removeUnrecognizedInputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-inputs"))){const a=[],o=[],p=[],e=[];return this.inputs.forEach(v=>{if(!this.declaration.inputs.find(w=>{var A;return w.id===((A=v.declaration)==null?void 0:A.id)})){const w=v.remove({ignoreUpstream:!1},r);p.push(...w.removed),a.push(...w.updated)}}),this.inputs.filter((v,E)=>{const w=this.inputs.findIndex($=>$.declaration===v.declaration&&$!==v);if(w===-1)return!1;const A=this.inputs[w];return L(A==null?void 0:A.createdAt).isSame(L(v.createdAt))?E>w:!!L(A==null?void 0:A.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},r);p.push(...E.removed),a.push(...E.updated)}),r==null||r.attemptAutoclose("remove-unrecognized-inputs",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}removeUnrecognizedOutputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-outputs"))){const a=[],o=[],p=[],e=[];return this.outputs.forEach(v=>{if(!this.declaration.getUniqueReturnDeclarations().find(w=>{var A;return w.id===((A=v.declaration)==null?void 0:A.id)})){const w=v.remove({ignoreUpstream:!1},r);p.push(...w.removed),a.push(...w.updated)}}),this.outputs.filter((v,E)=>{const w=this.outputs.findIndex($=>$.declaration===v.declaration&&$!==v);if(w===-1)return!1;const A=this.outputs[w];return L(A==null?void 0:A.createdAt).isSame(L(v.createdAt))?E>w:!!L(A==null?void 0:A.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},r);p.push(...E.removed),a.push(...E.updated)}),r==null||r.attemptAutoclose("remove-unrecognized-outputs",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}syncInputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"sync-missing-fixed-inputs"))){const a=[],o=[],p=[],e=[],y=this.declaration.inputs.filter(A=>!this.inputs.find($=>$.declaration.id===A.id));this.inputs.sort((A,$)=>A.index-$.index),y.forEach(A=>{this.inputs.forEach(B=>{B.index>=A.index&&B.metaSync({index:B.index+1},r)});const $={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||L().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.InputMap,declaration:A.toJSON(),readsValue:null,defaultValue:null,index:A.index,name:null,codeName:null,description:null,parent:this.toReference()},V=ne($,this.project);V.setParent(this,r),V.initChildren(r),r==null||r.add(V,S.Added),V.addSelfToProject(r),o.push(V)}),this.inputs.sort((A,$)=>A.index-$.index);const{updated:v,added:E,removed:w}=this.removeUnrecognizedInputs(r);return a.push(...v),o.push(...E),p.push(...w),r==null||r.attemptAutoclose("sync-missing-fixed-inputs",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}syncOutputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"sync-missing-fixed-outputs"))){const a=[],o=[],p=[],e=[],y=[];this.outputs=this.initialData.outputs.reduce(($,V)=>{if(V.type===f.GenericReference){const F=qi(V,this.project);return F?[...$,F]:$}const B=ne(V,this.project);return y.push(B.index),B.setParent(this,null),B.initChildren(r),[...$,B]},[]);const v=this.declaration.getUniqueReturnDeclarations().filter($=>!this.outputs.find(V=>{var B;return((B=V.declaration)==null?void 0:B.id)===$.id}));this.outputs.sort(($,V)=>$.index-V.index),v.forEach(($,V)=>{this.outputs.forEach(q=>{q.index>=$.index&&q.index++});const B=y.includes($.index)?this.outputs.length-1+V:$.index,F={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||L().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.OutputMap,declaration:$.toJSON(),defaultValue:null,writesValues:[],index:B,parent:this.toReference()},K=ne(F,this.project);K.setParent(this,r),K.initChildren(r),r==null||r.add(K,S.Added),K.addSelfToProject(r)}),this.outputs.sort(($,V)=>$.index-V.index);const{updated:E,added:w,removed:A}=this.removeUnrecognizedOutputs(r);return a.push(...E),o.push(...w),p.push(...A),r==null||r.attemptAutoclose("sync-missing-fixed-outputs",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}getUnusedInputs(){return this.inputs.filter(r=>r.suggestion||!r.readsValue&&!r.defaultValue)}getUnusedOutputs(){return this.outputs.filter(r=>r.suggestion||!r.writesValues.length)}getUsedInputs(){return this.inputs.filter(r=>!r.suggestion&&(r.readsValue||r.defaultValue))}getUsedOutputs(){return this.outputs.filter(r=>!r.suggestion&&r.writesValues.length)}};_(Qt,"repository",{APICreate:async(r,...a)=>r,APIUpdate:async(r,...a)=>r,APIDelete:async(r,...a)=>r,APIClone:async(r,...a)=>{},APILoad:async(r,...a)=>null,APILoadVersion:async(r,a,...o)=>null}),_(Qt,"type",f.FunctionCall),_(Qt,"USER_MANAGED_PARENT_TYPES",[...Nr,f.Project]),_(Qt,"PARENT_TYPES",[...Qt.USER_MANAGED_PARENT_TYPES]),_(Qt,"MUTABLE_BASE_PROPERTIES",["catchesError"]),_(Qt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),_(Qt,"BASE_PROPERTIES",[...Qt.MUTABLE_BASE_PROPERTIES,...Qt.INMUTABLE_BASE_PROPERTIES]),_(Qt,"MUTABLE_META_PROPERTIES",["x","y"]),_(Qt,"INMUTABLE_META_PROPERTIES",[...Qt.INMUTABLE_BASE_PROPERTIES]),_(Qt,"META_PROPERTIES",[...Qt.MUTABLE_META_PROPERTIES,...Qt.INMUTABLE_META_PROPERTIES]),_(Qt,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),_(Qt,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),_(Qt,"UPSTREAM_PROPERTIES",[...Qt.MUTABLE_UPSTREAM_PROPERTIES,...Qt.INMUTABLE_UPSTREAM_PROPERTIES]),_(Qt,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","writesValues","inputs","outputs","error"]),_(Qt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),_(Qt,"DOWNSTREAM_PROPERTIES",[...Qt.MUTABLE_DOWNSTREAM_PROPERTIES,...Qt.INMUTABLE_DOWNSTREAM_PROPERTIES]),_(Qt,"PROPERTIES",[...Qt.META_PROPERTIES,...Qt.UPSTREAM_PROPERTIES,...Qt.DOWNSTREAM_PROPERTIES]);let To=Qt;function nb(d){return d&&typeof d.then=="function"}function tIe(d){const u=new zn(d[0]),r=d.map(o=>o.id),a={};return d.forEach(o=>{a[o.id]=o}),u.order=r,u.flatRecord=a,u.orderEntities(),u.order.map(o=>u.flatRecord[o])}function rIe(d){const u=new zn(Object.values(d)[0]),r=Object.keys(d);return u.order=r,u.flatRecord=d,u.orderEntities(),u.order}class zn{constructor(u){_(this,"order",[]);_(this,"flatRecord",{});_(this,"allBuiltInEntityIds",zs());_(this,"onGoingVisits",{});u&&(this.flatten(u),this.orderEntities())}flatten(u){const r=new Set(zs()),a=R(me(u,r,{ignoreBuiltInBaseEntities:!0})),o=new Set;for(const p of a)this.flatRecord[p.id]=p,o.add(p.id);this.order=Array.from(o)}moveEntityAfterDependencies(u){const{upstream:r}=kd(u,this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});for(const a of Object.keys(r)){const o=this.order.indexOf(a),p=this.order.indexOf(u.id);if(o>p)return this.order.splice(p,1),this.order.splice(o,0,u.id),!0}return!1}orderEntities(){let u=!1;for(let r=0;r<this.order.length;r++){const a=this.order[r],o=this.flatRecord[a];if(o||Me.warn(`Entity with id ${a} not found in flatRecord. Skipping...`),this.moveEntityAfterDependencies(o)){u=!0;break}}u&&this.orderEntities()}getUpstreamOngoingDependenciesVisits(u,r){const{upstream:a}=kd(this.flatRecord[u],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds}),o={};return Object.entries(this.onGoingVisits[r]||{}).forEach(([p,e])=>{Object.keys(a).includes(p)&&(o[p]=e)}),o}getDownstreamOngoingDependenciesVisits(u,r){const a=Object.keys(this.onGoingVisits[r]||{}),o=new Set(a.flatMap(e=>Object.keys(kd(this.flatRecord[e],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds}).downstream))),p={};return Array.from(o).forEach(e=>{e===u&&(p[e]=this.onGoingVisits[r][e])}),p}async settlePromises(u,r){const a=Object.values(u);a.length&&await Promise.all(a),Object.keys(u).forEach(o=>{delete this.onGoingVisits[r][o]})}visit(u){const r=this.order;for(const a of r)u(this.flatRecord[a],this.flatRecord);return this}reverseVisit(u){const r=this.order.slice().reverse();for(const a of r)u(this.flatRecord[a],this.flatRecord);return this}async visitAsync(u){const r=this.order,a=Math.random().toString(36).substring(7);this.onGoingVisits[a]={};for(const o of r){const p=this.getUpstreamOngoingDependenciesVisits(o,a);Object.keys(p).length&&await this.settlePromises(p,a);const e=u(this.flatRecord[o],this.flatRecord);nb(e)&&(this.onGoingVisits[a][o]=e)}return await this.settlePromises(this.onGoingVisits[a],a),this.onGoingVisits[a]={},this}async reverseVisitAsync(u){const r=this.order.slice().reverse(),a=Math.random().toString(36).substring(7);this.onGoingVisits[a]={};for(const o of r){const p=this.getDownstreamOngoingDependenciesVisits(o,a);Object.keys(p).length&&await this.settlePromises(p,a);const e=u(this.flatRecord[o],this.flatRecord);nb(e)&&(this.onGoingVisits[a][o]=e)}return await this.settlePromises(this.onGoingVisits[a],a),this.onGoingVisits[a]={},this}}function A5(d,u){switch(d.id){case he["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const r=d.project.entities.filter(v=>!!v.implements.find(E=>E.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),a=r.find(v=>{const E=v.properties.find($=>$.implements&&$.implements.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),w=E==null?void 0:E.getDefaultValue();return(w==null?void 0:w.value)===!0});if(!a&&r.length){const E=r[0].properties.find(A=>A.implements&&A.implements.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),w=E==null?void 0:E.defaultValue;if(w)w.metaSync({value:!0},u);else if(E!=null&&E.dataType){const A={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(u==null?void 0:u.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:E==null?void 0:E.toReference()},$=ne(A,d.project);return $.setParent(E,u),$.initChildren(u),u==null||u.add($,S.Added),$.addSelfToProject(u),{newEntities:[$]}}return{newEntities:[]}}else if(a)return{newEntities:[]};const o=d.project.get(he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),p=vm(o,"Main database",u);if(p.errors.length>0)return{newEntities:[]};const e=p.properties.find(v=>v.implements&&v.implements.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),y=e==null?void 0:e.defaultValue;if(y)y.metaSync({value:!0},u);else if(e!=null&&e.dataType){const v={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(u==null?void 0:u.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:e==null?void 0:e.toReference()},E=ne(v,d.project);E.setParent(e,u),E.initChildren(u),u==null||u.add(E,S.Added),E.addSelfToProject(u)}return{newEntities:[p]}}}return{newEntities:[]}}function b5(d,u){const r=[],a=[],o=[],p=[];return d.implements.filter(y=>y.type===f.BuiltInBaseEntity).forEach(y=>{var v;switch(y.id){case he["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const E=d.project.entities.filter(V=>V.implements.find(B=>B.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));let w=E.find(V=>!!V.properties.find(B=>{var F;return B.implements&&B.implements.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((F=B.getDefaultValue())==null?void 0:F.value)===!0}));if(!w&&E.length)w=E[0];else if(!w&&!E.length){w=d.project.getBuiltIn(he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id).implement("Relational database",u);const B=w.properties.find(F=>{var K;return((K=F.implements)==null?void 0:K.id)===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id});(v=B==null?void 0:B.defaultValue)==null||v.metaSync({value:!0},u),a.push(w)}const A=d.properties.find(V=>V.implements&&V.implements.id===he["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id),$=A==null?void 0:A.defaultValue;if(A&&!$){const V={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(u==null?void 0:u.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:null,valueAsTypeSingle:(w==null?void 0:w.toJSON())||null,valueAsTypeList:null,parent:A==null?void 0:A.toReference()},B=ne(V,d.project);B.hydrateAncestors(),B.setParent(A,u),B.addSelfToProject(u),B.initChildren(u),u==null||u.add(B,S.Added),a.push(B);return}else $&&!$.valueAsTypeSingle&&$.setValueAsTypeSingle(w||null,u);return}}}),{self:d,updated:R(r),added:R(a),removed:R(o),affected:R(p)}}function vm(d,u,r,a){const o=a||N.UUID.uuid(),p=N.UUID.uuid(),e={id:o,version:p,createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,name:u,type:f.DefinitionEntity,codeName:null,description:null,static:d.static,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:null,implements:[d.toJSON()],x:0,y:0,parent:d.project.toReference()};A5(d,r);const y=ne(e,d.project);return y.hydrateAncestors(),r==null||r.add(y,S.Added),y.addSelfToProject(r),y.addImplementation(d),y.setParent(d.project,r),y.initChildren(r),b5(y,r),y}function ab(d,u){return u.entities.find(o=>{const p=o.properties,e=p.map(A=>A.name),y=d.every(A=>e.includes(A)),v=e.filter(A=>!d.includes(A)),E=p.every(A=>!v.includes(A.name)||!A.required);return y&&E})||null}function w5(d,u,r,a=mi.OrDataTypeGroup){const o=[],p=[],e=[],y=[],E={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:d.toJSON(),isList:!1,asType:!1,andChildrenGroup:null,index:null,orChildrenGroup:null,staticEntities:null,interactiveEntities:null,actionEntities:null,like:!0,inferred:!1,parentRelationType:a,parent:u.toReference()},w=ne(E,d.project);return p.push(w),w.setParent(u,r),w.initChildren(r),r==null||r.add(w,S.Added),w.setEntity(d,r),w.addSelfToProject(r),{updated:R(o),added:R(p),removed:R(e),affected:R(y),self:w}}function ob(d,u,r,a,o){var E,w,A,$,V,B,F,K;const p=[],e=[],y=[],v=[];switch(typeof d){case"string":let q=!1;const ie=new Date(d);if(ie instanceof Date&&!isNaN(ie.valueOf())&&(q=!0),q){const W=u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Date].id);u.setEntity(W,a);break}else{const W=u.project.getBuiltIn(he[f.PrimitiveEntity][oe.String].id);u.setEntity(W,a);break}case"number":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Number].id),a);break;case"boolean":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Boolean].id),a);break;case"object":if(d===null){u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Null].id),a);break}else if(Array.isArray(d))if(u.metaSync({isList:!0},a),d.length>0){const W=d.slice(0,5).filter(Q=>Q!==void 0);if(W.every(Q=>typeof Q==typeof W[0])&&(typeof W[0]!="object"||W[0]===null))switch(typeof W[0]){case"string":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.String].id),a);break;case"number":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Number].id),a);break;case"boolean":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Boolean].id),a);break;case"object":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Null].id),a);break}else{const Q=[];let ce=!1;W.forEach(z=>{var pe,te,ue,Ie;if(Array.isArray(z)&&(ce=!0),typeof z=="object"&&!Array.isArray(z)&&z!==null){const Ue=Em(z,u.project,{...r,id:N.UUID.uuid()},a,o);Ue.hasCreated&&Q.push((pe=Ue.changeSet)==null?void 0:pe.self),p.push(...(te=Ue.changeSet)==null?void 0:te.updated),e.push(...(ue=Ue.changeSet)==null?void 0:ue.added),y.push(...(Ie=Ue.changeSet)==null?void 0:Ie.removed)}});const X=R(Q);if(!X.length&&!ce){W.forEach(z=>{const pe={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:null,isList:!1,asType:!1,andChildrenGroup:null,index:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parentRelationType:mi.OrDataTypeGroup,parent:u.toReference()},te=ne(pe,u.project);switch(te.setParent(u,a),te.initChildren(a),a==null||a.add(te,S.Added),te.addSelfToProject(a),typeof z){case"string":te.setEntity(te.project.getBuiltIn(he[f.PrimitiveEntity][oe.String].id),a);break;case"number":te.setEntity(te.project.getBuiltIn(he[f.PrimitiveEntity][oe.Number].id),a);break;case"boolean":te.setEntity(te.project.getBuiltIn(he[f.PrimitiveEntity][oe.Boolean].id),a);break;case"object":te.setEntity(te.project.getBuiltIn(he[f.PrimitiveEntity][oe.Null].id),a);break}});break}else X.length===1&&!ce?u.setEntity(X[0],a):W.forEach(z=>{if(typeof z=="object"&&!Array.isArray(z)&&z!==null){const pe=ab(Object.keys(z),u.project);if(pe){const te=w5(pe||X[0],u,a,mi.OrDataTypeGroup);p.push(...te.updated),e.push(...te.added),y.push(...te.removed)}}else{const pe={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:null,isList:Array.isArray(z),asType:!1,andChildrenGroup:null,index:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parentRelationType:mi.OrDataTypeGroup,parent:u.toReference()},te=ne(pe,u.project);te.setParent(u,a),te.initChildren(a),a==null||a.add(te,S.Added),te.addSelfToProject(a);const ue=ob(z,te,{...r,id:N.UUID.uuid()},a,o);p.push(...ue.updated),e.push(...ue.added),y.push(...ue.removed)}})}}else{const W=Em(d[0],u.project,{...r},a,o);u.setEntity((E=W.changeSet)==null?void 0:E.self,a),p.push(...(w=W.changeSet)==null?void 0:w.updated),e.push(...(A=W.changeSet)==null?void 0:A.added),y.push(...($=W.changeSet)==null?void 0:$.removed);break}else{const W=Em(d,u.project,{...r},a,o);u.setEntity((V=W.changeSet)==null?void 0:V.self,a),p.push(...(B=W.changeSet)==null?void 0:B.updated),e.push(...(F=W.changeSet)==null?void 0:F.added),y.push(...(K=W.changeSet)==null?void 0:K.removed);break}}return{updated:R(p),added:R(e),removed:R(y),affected:R(v),self:u}}function Em(d,u,r,a,o){const p=[],e=[],y=[],v=[],E=Object.keys(d),w=ab(E,u);if(w)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],affected:[],self:w}};const A=o?r.name+" of "+o.name:r.name,V={id:r.id||N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,name:A,codeName:null,type:f.DefinitionEntity,description:r.description||null,static:r.static||!1,abstract:r.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:null,implements:[],x:0,y:0,parent:u.toReference()},B=ne(V,u);return B.setParent(u,a),B.initChildren(a),a==null||a.add(B,S.Added),B.addSelfToProject(a),e.push(B),E.forEach((F,K)=>{const ie={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,name:F,type:f.Property,codeName:F,description:null,static:!1,abstract:!1,defaultValue:null,constant:!1,interactive:!0,dataType:null,implements:null,extends:null,index:K,hidden:!1,private:!1,required:!0,parent:B.toReference()},W=ne(ie,u);W.setParent(B,a),W.initChildren(a),a==null||a.add(W,S.Added),W.addSelfToProject(a),e.push(W);const de=d[F],ce={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:null,implementationChooseOne:!1,entity:null,isList:!1,asType:!1,andChildrenGroup:null,index:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parent:W.toReference()},X=ne(ce,u);X.setParent(W,a),X.initChildren(a),a==null||a.add(X,S.Added),X.addSelfToProject(a),e.push(X);const z=ob(de,X,{...r,name:F,id:N.UUID.uuid()},a,o||B);p.push(...z.updated),e.push(...z.added),y.push(...z.removed)}),{hasCreated:!0,changeSet:{updated:R(p),added:R(e),removed:R(y),affected:R(v),self:B}}}function Va(d,u,r,a){const o=[];return!d.length||!u.length?{errors:o,overlap:!1}:(d.length>u.length?d.forEach(p=>{const e=u.find(v=>v.name===p.name),y=u.find(v=>{var E,w;return!!p.implements&&((E=v.implements)==null?void 0:E.id)===((w=p.implements)==null?void 0:w.id)});if(e){const v=new ir({id:p.id+"--"+e.id+"--"+a,message:`Entity of type ${p.type} named "${p.name}" with id "${p.id}" overrides a base ${e.type} ${e.name} with id "${e.id}" that has the same name`,severity:H.Error,code:a,entity:p,firstRelationship:e});o.push(v)}if(y){const v=new ir({id:p.id+"--"+y.id+"--"+r,message:`Entity of type ${p.type} named "${p.name}" with id "${p.id}" overrides a base ${y.type} ${y.name} with id "${y.id}" that implements the same base descriptor`,severity:H.Error,code:r,entity:p,firstRelationship:y});o.push(v)}}):u.forEach(p=>{var v;const e=d.find(E=>E.name===p.name),y=d.find(E=>{var w,A;return!!E.implements&&((w=E.implements)==null?void 0:w.id)===((A=p.implements)==null?void 0:A.id)});if(e){const E=new ir({id:e.id+"--"+p.id+"--"+a,message:`Entity of type ${e.type} named "${e.name}" with id "${e.id}" overrides a base entity ${p.name} with id "${p.id}" that has the same name`,severity:H.Error,code:a,entity:e,firstRelationship:p});o.push(E)}if(y){const E=new ir({id:y.id+"--"+p.id+"--"+r,message:`Entity of type ${y.type} named "${y.name}" with id "${y.id}" overrides a base entity ${p.name} with id "${p.id}" that implements the same base ${(v=y==null?void 0:y.implements)==null?void 0:v.type}`,severity:H.Error,code:r,entity:y,firstRelationship:p});o.push(E)}}),{errors:o,overlap:!!o.length})}function iIe(d,u){return d.abstract||(d.properties.forEach(a=>{a.abstract||a.metaSync({abstract:!0},u)}),Object.values(d.detachedDependents).forEach(a=>{a.field===gI.Entity&&a.entity.remove({ignoreUpstream:!1},u)}),d.metaSync({abstract:!0},u)),d}function sIe(d,u){return d.abstract&&(d.properties.forEach(a=>{a.abstract&&a.metaSync({abstract:!1},u)}),Object.values(d.detachedDependents).forEach(a=>{(a.field===Bm.Implements||a.field===Bm.Extends)&&a.entity.onDetachedDependencyRemoved(d,a.field,u)}),d.metaSync({abstract:!1},u)),d}function nIe(d,u){return d.static||(d.properties.forEach(a=>{a.static||a.metaSync({static:!0},u)}),d.metaSync({static:!0},u)),d}function aIe(d,u){return d.static&&d.metaSync({static:!1},u),d}var ki=(d=>(d.StringValueMustNotHaveSpaces="string-value-must-not-have-spaces",d.StringValueMustNotHaveDashes="string-value-must-not-have-dashes",d.MustBeUniqueAmongSameEntities="must-be-unique-among-same-entities",d))(ki||{});function lb(d,u){const r=[],a=u;if(!a)return{errors:r,override:u};if(typeof a!="string")return{errors:[],override:u};if(a.includes(" ")){const o=new ir({id:d.id+"--string-value-must-not-have-spaces",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value cannot contain spaces.`,severity:H.Error,code:"string-value-must-not-have-spaces",entity:d});r.push(o)}return{errors:r,override:a.replace(/\s/g,"-")}}function R5(d,u){const r=[],a=u;if(!a)return{errors:r,override:u};if(typeof a!="string")return{errors:[],override:u};if(a.includes(" ")){const o=new ir({id:d.id+"--string-value-must-not-have-spaces",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value cannot contain spaces or dashes.`,severity:H.Error,code:"string-value-must-not-have-spaces",entity:d});r.push(o)}if(a.includes("-")){const o=new ir({id:d.id+"--string-value-must-not-have-dashes",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value cannot contain spaces or dashes.`,severity:H.Error,code:"string-value-must-not-have-dashes",entity:d});r.push(o)}return{errors:r,override:a.replace(/\s|-/g,"_")}}function db(d,u){var r;if(d.type===f.LiteralValue){let a=(r=d.value)==null?void 0:r.toString();try{a=JSON.stringify(d.value,null,2)}catch{}return`${d.type}: ${d.id} (${Y(d,u)}) = ${a}`}if(d.type===f.DataType){if(d instanceof fs||d.increaseVersion)return`${d.type}: ${d.id} (${Yd(d)})`;try{const a=Yd(d);return`${d.type}: ${d.id} (${a})`}catch{}}return`${d.type}: ${d.id} (${Y(d,u)})`}function Fd(d,u){const r=Ao(d);if(r.length===0)return{list:[],last:null};let a=null;return{list:r.flatMap(p=>{if(p===u)return a=p,[p];const e=Fd(p,u);return e.last&&(a=e.last),[p,...e.list]}),last:a}}function Io(d,u){const r=d.calledBy;if(r.length===0)return{list:[],last:null,callType:null};let a=null,o=null;return{list:r.flatMap(e=>{if(e===u)return a=e,Dt.includes(e.type)?e.parent.type===f.Loop?o="loop-body":o="entry":e.successCalls.includes(d)?o="success":e.errorCalls.includes(d)&&(o="error"),[e];if(e.type===f.FunctionDeclaration&&e.parent.type===f.Loop&&e.parent===u)return a=e.parent,o="loop-body",[e];if(!xi.includes(e.type))return[e];const y=Io(e,u);return y.last&&(a=y.last,o=y.callType),[e,...y.list]}),last:a,callType:o}}function oIe(d,u){if(d===u)return"same-entity";if(!wi.includes(d.type)||!Yp(d).find(o=>o.callee===u))return null;if(Dt.includes(d.type)){if(d.calls.includes(u))return d.type===f.Loop?"loop-body":"entry"}else if(sr.includes(d.type)&&d.type!==f.InternalCall){if(d.successCalls.includes(u))return"success";if(d.errorCalls.includes(u))return"error"}return null}function Jp(d){const u=Di(d,d.project);return u?Dt.includes(u.type)?u:u.type===f.Loop?u.body:null:null}function g5(d,u){const r=d.calledBy;return!r||!r.length?!1:r.every(a=>a===u?!0:xi.includes(a.type)?!!Io(a,u).last:!1)}function _5(d){return d.filter(u=>{const r=Jp(u);return!d.filter(p=>p!==u).some(p=>p===r?!1:Im(p,u))})}function D5(d,u){if(!d)throw new Error("findNextSingleCallerAncestor: Target is not defined, cannot find ancestor.");let r=d;(d.type===f.VariableDeclaration||d.type===f.VariableInstance)&&!d.calledBy.length&&!d.successCalls.length&&!d.errorCalls.length&&d.internalCalls.some($=>!!$.calledBy.length)&&(r=d.internalCalls.find(V=>!!V.calledBy.length));const a=u||Di(r,d.project);if(!a)return{ancestor:null,callType:null};if(a.type===f.Project)return{ancestor:null,callType:null};const o=Yp(a);if(!o.find($=>$.callee===r))return{ancestor:null,callType:null};if(a.type===f.Loop){if(a.body.calls.includes(r))return{ancestor:a,callType:"loop-body"}}else if(Dt.includes(a.type)){if(a.calls.includes(r))return a.type===f.FunctionDeclaration&&a.parent.type===f.Loop?{ancestor:a,callType:"loop-body"}:{ancestor:a,callType:"entry"}}else if(sr.includes(a.type)){if(a.successCalls.includes(r))return{ancestor:a,callType:"success"};if(a.errorCalls.includes(r))return{ancestor:a,callType:"error"}}const e=o.filter($=>!($.callee===r||!wi.includes($.callee.type)||!dt($.callee).find(F=>F===r))).filter(($,V,B)=>B.findIndex(F=>F.callee===$.callee)===V);if(e.length===0)return{ancestor:null,callType:null};if(e.length===1){const $=e[0];if($.callee.type===f.Loop){if($.callee.body.calls.includes(r))return{ancestor:$.callee,callType:"loop-body"}}else{if(Dt.includes($.callee.type))return $.callee.type===f.FunctionDeclaration&&$.callee.parent.type===f.Loop?{ancestor:$.callee,callType:"loop-body"}:{ancestor:$.callee,callType:"entry"};if(sr.includes($.callee.type)){if($.callType==="success"&&$.callee.type===f.InternalCall)return{ancestor:$.callee,callType:"success"};if($.callType==="error"&&$.callee.type===f.InternalCall)return{ancestor:$.callee,callType:"error"}}}}const y=e.filter($=>g5(r,$.callee)),v=y.filter($=>{const V=dt($.callee),B=y.filter(K=>K.callee!==$.callee).map(K=>K.callee);return!V.some(K=>!!B.find(ie=>ie===K))});if(v.length===0){if(a.type===f.Loop){if(dt(a.body).find(ie=>ie===r))return{ancestor:a,callType:"loop-body"};if(ri(a.successCalls).find(ie=>ie===r))return{ancestor:a,callType:"success"};if(ri(a.errorCalls).find(ie=>ie===r))return{ancestor:a,callType:"error"}}else if(sr.includes(a.type)){if(ri(a.successCalls).find(K=>K===r))return{ancestor:a,callType:"success"};if(ri(a.errorCalls).find(K=>K===r))return{ancestor:a,callType:"error"}}return a.parent.type===f.Loop?{ancestor:a,callType:"loop-body"}:{ancestor:a,callType:"entry"}}if(v.length>1)throw new Error(`findNextSingleCallerAncestor: Could not be resolved, multiple candidates found: ${v.map($=>Y($.callee,r.project)).join(", ")}`);const E=v[0].callee,A=Yp(E).find($=>$.callee===r);return{ancestor:E,callType:A.callType}}function lIe(d){if(![f.VariableDeclaration,f.OutputMap].includes(d.type))throw new Error("getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders can only be used with a value writer entity");let u;if(d.type===f.VariableDeclaration?u=d:d.type===f.OutputMap&&(u=d.parent),!u)throw new Error("getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders can only be used with a value writer entity that has a caller");const r=R([d,...cb(d)]),a=R(r.map(y=>ub(y)).flatMap(y=>hr.includes(y==null?void 0:y.type)?y.calledBy:[y]));if(a.length===1){if(Dt.includes(a[0].type))return a[0].parent.type===f.Loop?{ancestor:a[0],callType:"loop-body"}:{ancestor:a[0],callType:"entry"};if(a[0].successCalls.includes(u))return{ancestor:a[0],callType:"success"};if(a[0].errorCalls.includes(u))return{ancestor:a[0],callType:"error"}}const o=a.map(y=>{if(Dt.includes(y.type))return y.parent.type===f.Loop?{ancestor:y,callType:"loop-body"}:{ancestor:y,callType:"entry"};const v=D5(y);if(!v.ancestor)throw new Error(`getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders: Could not be resolved, no ancestor found for ${Y(y,u.project)}`);return v}).filter((y,v,E)=>v===E.findIndex(w=>{var A,$;return((A=w.ancestor)==null?void 0:A.id)===(($=y.ancestor)==null?void 0:$.id)})),p=Jp(u),e=o.filter(y=>y!=null&&y.ancestor?p===y.ancestor?!0:!o.filter(w=>w.ancestor!==y.ancestor).map(w=>w.ancestor).some(w=>{const A=Io(y.ancestor,w);return!!(A!=null&&A.last)}):!1);if(e.length===0)return{ancestor:p,callType:(p==null?void 0:p.parent.type)===f.Loop?"loop-body":"entry"};if(e.length>1)throw new Error(`getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders: Could not be resolved, multiple candidates found: ${e.map(y=>Y(y.ancestor,u.project)).join(", ")}`);return{ancestor:e[0].ancestor,callType:e[0].callType}}function O5(d,u){if(d===u)return!0;if(dt(d).includes(u)||!dt(u).includes(d))return!1;const o=d.calledBy;return o.length===0?!1:o.length===1?o[0]===u:_5(o).length>1&&o.includes(u)?!1:o.every(e=>d===u?!0:Dt.includes(e.type)?!1:O5(e,u))}function C5(d){const u=[];let r=d.calledBySuccess;r=r.filter(o=>!r.filter(y=>y!==o).some(y=>Im(y,o)));let a=d.calledByError;a=a.filter(o=>!a.filter(y=>y!==o).some(y=>Im(y,o)));for(const o of r)u.push({ancestor:o,callType:"success"});for(const o of a)u.push({ancestor:o,callType:"error"});return u}function $5(d){const u=[];return C5(d).forEach(a=>{a.ancestor.type===f.Condition&&u.push({condition:a.ancestor,call:d,callType:a.callType});const p=$5(a.ancestor).filter(e=>!u.some(y=>y.condition.id===e.condition.id));u.push(...p)}),u}function ub(d){if(!d)return null;if(d.type===f.Condition&&d.parent.type===f.Condition)return Am(d.parent);if($v.includes(d.type))return d;const u=d.parent;return u?ub(u):null}function cb(d,u=new Set){return d.writesValues.reduce((r,a)=>u.has(a.id)?r:(u.add(a.id),un.includes(a.type)?[...r,a]:Br.includes(a.type)?[...r,a,...cb(a,u)]:r),[])}function Wp(d){const u=d.calledBy;if(u.length===0)return d.project;const r=u.reduce((a,o)=>{const p=Di(o,d.project);return!p||p.type===f.Project?a:a.type===f.Project||Fd(p,a).last?p:(Fd(a,p).last,a)},d.project);return r.type===f.FunctionDeclaration&&r.parent.type===f.Loop?r.parent:r}function He(d,u){let r=Wp(d);if(d.type===f.InternalCall)if(d.parent.type===f.VariableInstance){const o=Xs(r,d.parent.declaration,d.project);!o.compatible&&o.type!=="b-is-global-a-is-not"?d.parent.remove({ignoreUpstream:!1},u):(d.parent.setParent(r,u),d.parent.addSelfToProject(u))}else d.parent.setParent(r,u),d.parent.addSelfToProject(u);else if((d.type===f.ContinueStatement||d.type===f.BreakStatement)&&r.type!==f.Loop){d.remove({ignoreUpstream:!1},u);return}else if(d.type===f.ReturnStatement&&!Nr.includes(r.type)){d.remove({ignoreUpstream:!1},u);return}else if(Tt.includes(d.type)){const o=d.usedInternalCalls[0];if(o)if(r=Wp(o),d.type===f.VariableInstance){const p=Xs(r,d.declaration,d.project);!p.compatible&&p.type!=="b-is-global-a-is-not"?d.remove({ignoreUpstream:!1},u):(d.setParent(r,u),d.addSelfToProject(u))}else d.setParent(r,u),d.addSelfToProject(u);else if(d.type===f.VariableInstance){const p=Xs(r,d.declaration,d.project);!p.compatible&&p.type!=="b-is-global-a-is-not"?d.remove({ignoreUpstream:!1},u):(d.setParent(r,u),d.addSelfToProject(u))}else d.setParent(r,u),d.addSelfToProject(u)}else d.setParent(r,u),d.addSelfToProject(u);if(hr.includes(d.type))return;dt(d).forEach(o=>{let p=Wp(o);if(o.type===f.InternalCall)if(o.parent.type===f.VariableInstance){const e=Xs(p,o.parent.declaration,d.project);!e.compatible&&e.type!=="b-is-global-a-is-not"?o.parent.remove({ignoreUpstream:!1},u):(o.parent.setParent(p,u),o.parent.addSelfToProject(u))}else o.parent.setParent(p,u),o.parent.addSelfToProject(u);else if((o.type===f.ContinueStatement||o.type===f.BreakStatement)&&p.type!==f.Loop){o.remove({ignoreUpstream:!1},u);return}else if(o.type===f.ReturnStatement&&!Nr.includes(p.type)){o.remove({ignoreUpstream:!1},u);return}else if(Tt.includes(o.type)){const e=o.usedInternalCalls[0];if(e)if(p=Wp(e),o.type===f.VariableInstance){const y=Xs(p,o.declaration,d.project);!y.compatible&&y.type!=="b-is-global-a-is-not"?o.remove({ignoreUpstream:!1},u):(o.setParent(p,u),o.addSelfToProject(u))}else o.setParent(p,u),o.addSelfToProject(u);else if(o.type===f.VariableInstance){const y=Xs(p,o.declaration,d.project);!y.compatible&&y.type!=="b-is-global-a-is-not"?o.remove({ignoreUpstream:!1},u):(o.setParent(p,u),o.addSelfToProject(u))}else o.setParent(p,u),o.addSelfToProject(u)}else o.setParent(p,u),o.addSelfToProject(u)})}function Tm(d,u,r=new Set){const a=bn(d),o=bn(u),p=a.filter(v=>!o.includes(v)),e=a.filter(v=>o.includes(v)),y=p.reduce((v,E)=>r.has(E.id)?v:(r.add(E.id),R([...v,...Tm(E,u,r)])),[]);return R([...e,...y])}function Il(d,u){const r=Fd(d,u);return r.last===u&&r.list.length>0&&r.list[0]!==u}function pb(d,u){return!!Fd(d,u).last}function Im(d,u){return!!Io(d,u).last}function fb(d,u){if(!d||!u)throw new Error("Both entities must be defined to find a common ancestor");if(d===u)return d;const r=d.parent;if(r){if(r===u)return u;if(r.type===f.Project)return null}else return null;const a=u.parent;if(a){if(a===d)return d;if(a.type===f.Project)return null}else return null;return fb(r,a)}function dIe(d,u,r=!0){if(!d||!u)throw new Error("Both entities must be defined to find a common ancestor");if(d===u)return{ancestor:d,callType:"same-entity"};if(xi.includes(d.type)&&wi.includes(u.type)){const y=Io(d,u),v=y.last;if(v){if(v===u)return{ancestor:u,callType:y.callType}}else return{ancestor:null,callType:null}}if(xi.includes(u.type)&&wi.includes(d.type)){const y=Io(u,d),v=y.last;if(v){if(v===d)return{ancestor:d,callType:y.callType}}else return{ancestor:null,callType:null}}const a=Jp(d),o=Jp(u);if(!a||!o)return{ancestor:null,callType:null};if(a!==o)return{ancestor:null,callType:null};if(a.calls.includes(d)||a.calls.includes(u))return{ancestor:a,callType:"entry"};const p=a.calls.reduce((y,v)=>{if(!wi.includes(v.type))return y;const E=Yp(v),w=E.find($=>$.callee===d),A=E.find($=>$.callee===u);return w&&A&&(!r||w.callType===A.callType)?[...y,{ancestor:v,callType:w.callType}]:y},[]);if(p.length===0)return{ancestor:null,callType:null};if(p.length===1)return{ancestor:p[0].ancestor,callType:p[0].callType};const e=p.filter(y=>!p.some(v=>v.ancestor!==y.ancestor&&Io(y.ancestor,v.ancestor).last===v.ancestor));return e.length===1?{ancestor:e[0].ancestor,callType:e[0].callType}:{ancestor:a,callType:"entry"}}function fr(d){if(th.includes(d.type)){if(d.type===f.FunctionDeclaration){const u=d.parent;if(u.type===f.DefinitionEntity)return fr(u);if(u.type===f.Loop)return u}return d.type===f.DefinitionEntity&&d.parent.type===f.DataType||d.type===f.Condition&&d.parent.type===f.Condition?fr(d.parent):d}else{const u=d.parent;return u?fr(u):null}}function Sd(d,u){const r=Kd(d,u);if(!r)return null;if(th.includes(r.type)){if(r.type===f.FunctionDeclaration){const a=Kd(r.parent,u);if(a){if(a.type===f.DefinitionEntity)return a;if(a.type===f.Loop)return a}}if(r.parent){const a=Kd(r.parent,u);if(a&&(r.type===f.DefinitionEntity&&a.type===f.DataType||r.type===f.Condition&&a.type===f.Condition))return Sd(a,u)}return r}else{const a=r.parent?Kd(r.parent,u):null;return a?Sd(a,u):null}}function Yp(d){if(d.type===f.Loop){const u=[...ri(d.successCalls).map(o=>({callee:o,callType:"success"})),...ri(d.errorCalls).map(o=>({callee:o,callType:"error"})),...(d.body?dt(d.body):[]).map(o=>({callee:o,callType:"loop-body"}))];return R(u.map(o=>o.callee)).map(o=>{var e;const p=(e=u.find(y=>y.callee===o))==null?void 0:e.callType;return{callee:o,callType:p}})}if(sr.includes(d.type)){const u=[...ri(d.successCalls).map(o=>({callee:o,callType:"success"})),...ri(d.errorCalls).map(o=>({callee:o,callType:"error"}))];return R(u.map(o=>o.callee)).map(o=>{var e;const p=(e=u.find(y=>y.callee===o))==null?void 0:e.callType;return{callee:o,callType:p}})}if(Dt.includes(d.type)){const u=[...ri(d.calls).map(o=>d.parent.type===f.Loop?{callee:o,callType:"loop-body"}:{callee:o,callType:"entry"})];return R(u.map(o=>o.callee)).map(o=>{var e;const p=(e=u.find(y=>y.callee===o))==null?void 0:e.callType;return{callee:o,callType:p}})}return[]}function Am(d){if(!d)return null;if(d.type===f.Condition&&d.parent.type===f.Condition)return Am(d.parent);if(xi.includes(d.type))return d;const u=d.parent;return u?Am(u):null}function P5(d){if(!d)return null;if(sr.includes(d.type))return d;const u=d.parent;return u?P5(u):null}function N5(d){if(!d)return null;if(wi.includes(d.type))return d;const u=d.parent;return u?N5(u):null}function uIe(d){return d.type===f.VariableDeclaration?[d]:sr.includes(d.type)?[...d.inputs,...d.outputs||[]]:hr.includes(d.type)?d.outputs:jo.includes(d.type)||d.type===f.FunctionDeclaration?d.inputs:[]}function cIe(d){const u=bn(d),r=[],a=[];Xg.includes(d.type)&&r.push(...bm(d));const o=u.filter(p=>{const e=r.includes(p);return e?!1:xi.includes(p.type)&&!e?(a.push(p),!1):!0});return r.sort((p,e)=>Il(e,p)?-1:0),a.sort((p,e)=>Il(e,p)?-1:0),[...r,...a,...o]}function V5(d){return[...d].sort((u,r)=>Il(r,u)?-1:0)}function pIe(d){const u=V5(d),r=[];return u.forEach(a=>{const o=r[r.length-1];if(o){const p=o[o.length-1];Il(a,p)?r.push([a]):o.push(a)}else r.push([a])}),r}function La(d){const u=d.map(r=>fr(r));return R(u)}function bm(d){return sr.includes(d.type)?[...La(d.successCalls),...La(d.errorCalls)]:Dt.includes(d.type)?La(d.calls):[]}function fIe(d,u){return bm(d).includes(u)}function wm(d){return d.writesValues||[]}function hIe(d,u){return wm(d).includes(u)}function L5(d){var u;return Tt.includes((u=d==null?void 0:d.readsValue)==null?void 0:u.type)?d.readsValue:null}function yIe(d){return d.writesValues}function M5(d=[]){return d.map(L5).filter(u=>!!u)}function Rm(d=[]){return d.map(u=>u.writesValues).flat().filter(u=>Tt.includes(u.type))}function B5(d=[]){return d.map(u=>u.readsValue).filter(u=>!!u&&Tt.includes(u.type))}function U5(d){return Tt.includes(d.type)?d:null}function x5(d){return d.writesValues.map(U5).filter(u=>!!u)}function j5(d=[]){return d.reduce((u,r)=>r.type===f.OutputMap?[...u,...x5(r)]:u,[])}function dt(d){return d.type===f.Loop?R([...ri(d.successCalls),...ri(d.errorCalls),...d.body?dt(d.body):[]]):sr.includes(d.type)?R([...ri(d.successCalls),...ri(d.errorCalls)]):Dt.includes(d.type)?R(ri(d.calls)):[]}function mIe(d){return sr.includes(d.type)?[...ri(d.successCalls),...ri(d.errorCalls)]:Dt.includes(d.type)?ri(d.calls):[]}function G5(d,u=new Set){return d.writesValues.filter(a=>Tt.includes(a.type)&&!u.has(a.id)).reduce((a,o)=>u.has(o.id)?a:[...a,...vr(o,u)],[])}function F5(d,u=new Set){var a;return(((a=d.readsValue)==null?void 0:a.writesValues)||[]).filter(o=>Tt.includes(o.type)&&!u.has(o.id)).reduce((o,p)=>u.has(p.id)?o:[...o,...vr(p,u)],[])}function vr(d,u=new Set){if(u.has(d.id))return[];if(d.type===f.ReturnStatement)return B5(d.outputs).reduce((a,o)=>[...a,...vr(o,u)],[]);if(d.type===f.FunctionCall||d.type===f.Operation||d.type===f.Condition)return[...dt(d).reduce((p,e)=>{const y=fr(e);return[...p,...vr(y||e,u)]},[]),...M5(d.inputs),...j5(d.outputs)].reduce((p,e)=>[...p,...vr(e,u)],[]);if(jo.includes(d.type)){const r=Rm(d.inputs),o=dt(d).reduce((p,e)=>{const y=fr(e);return[...p,...vr(y||e,u)]},[]);return r.push(...o),r.reduce((p,e)=>[...p,...vr(e,u)],[])}if(d.type===f.FunctionDeclaration){const r=[...Rm(d.inputs)],o=dt(d).reduce((p,e)=>{const y=fr(e);return[...p,...vr(y||e,u)]},[]);return r.push(...o),r.reduce((p,e)=>[...p,...vr(e)],[])}if(Tt.includes(d.type)){u.add(d.id);const a=dt(d).reduce((o,p)=>{const e=fr(p);return[...o,...vr(e||p,u)]},[]);return[d,...a,...F5(d,u),...G5(d,u)]}return[]}function ms(d,u=new Set){return u.has(d.id)?[]:(u.add(d.id),[...bn(d).reduce((o,p)=>[...o,p,...ms(p,u)],[])])}function ri(d){return d.reduce((u,r)=>r.type===f.ReturnStatement||r.type===f.ContinueStatement||r.type===f.BreakStatement?[...u,r]:[...u,r,...dt(r)],[])}function S5(d){const u=d.entities||[],r=[...u,...d.functions||[],...d.events||[],...d.projects||[]],a=u.reduce((v,E)=>[...v,...E.properties],[]),o=u.reduce((v,E)=>[...v,...E.methods],[]),p=o.reduce((v,E)=>[...v,...Rm(E.inputs),...ri(La(E.calls)),...E.returnStatements],[]),e=d.functions.reduce((v,E)=>[...v,...ri(La(E.calls)),...E.returnStatements],[]),y=d.events.reduce((v,E)=>[...v,...ri(La(E.calls)),...E.returnStatements],[]);return[...r,...a,...o,...p,...e,...y]}function K5(d,u){return u.filter(a=>{if(!a)return!1;switch(a.type){case f.FunctionCall:return a.inputs.find(o=>o.id===d.id)!==void 0||a.outputs.find(o=>o.id===d.id)!==void 0;case f.Condition:return a.successCalls.find(o=>o.id===d.id)!==void 0||a.errorCalls.find(o=>o.id===d.id)!==void 0||a.inputs.find(o=>o.id===d.id)!==void 0;case f.Operation:return a.outputs.find(o=>o.id===d.id)!==void 0;case f.VariableDeclaration:return sr.includes(d.type)?ES(d).find(p=>{var e;return((e=p.readsValue)==null?void 0:e.id)===a.id})!==void 0:!1;case f.DefinitionEntity:return a.properties.find(o=>o.id===d.id)!==void 0||a.methods.find(o=>o.id===d.id)!==void 0;case f.FunctionDeclaration:return a.inputs.find(o=>o.id===d.id)!==void 0||(a.returnStatements.map(o=>o.outputs).flat()||[]).find(o=>o.id===d.id)!==void 0;default:return!1}})}function vIe(d){const u=S5(d.project);return K5(d,u)}function Kd(d,u){return d?typeof d=="string"?u[d]:d.type===f.GenericReference?u[d.entityId]:u[d.id]?u[d.id]:null:null}function k5(d={},u){const r={};return Object.keys(d).forEach(a=>{const o=u.get(a)||a,p=d[a];r[o]=p}),r}function kd(d,u={},r={}){const a={ignoreBuiltInBaseEntities:!1,allBuiltInEntityIds:[],entityMaps:new Map,...r};if(a.ignoreBuiltInBaseEntities&&(Zi.includes(d.type)||(a.allBuiltInEntityIds||[]).includes(d.id)))return{upstream:{},downstream:{}};const o=d,p=d,e=d,y=d,v=d,E=d,w=d,A=d,$=d,V=d,B=d,F=d,K=d,q=[...K.readsValue?[K.readsValue]:[],...K.declaration?[K.declaration]:[],...(F.calledByEntry||[]).flatMap(Q=>Q),...(F.calledBySuccess||[]).flatMap(Q=>Q),...(F.calledByError||[]).flatMap(Q=>Q),...V.parent?[V.parent]:[]];Array.isArray(e.implements)?q.push(...e.implements.flatMap(Q=>Q)):$.implements&&q.push($.implements),Array.isArray(e.extends)?q.push(...e.extends.flatMap(Q=>Q)):$.extends&&q.push($.extends),v.valueAsTypeList&&Array.isArray(v.valueAsTypeList)&&q.push(...v.valueAsTypeList.flatMap(Q=>Q)),v.valueAsTypeSingle&&q.push(v.valueAsTypeSingle),(K.internalCalls||[]).forEach(Q=>{const ce=J(Q);if(ce&&u[ce]){const X=u[ce];[...X.calledByEntry||[],...X.calledBySuccess||[],...X.calledByError||[]].forEach(z=>{const pe=J(z);pe&&u[pe]&&q.push(u[pe])})}});const ie=[...(o.inputs||[]).flatMap(Q=>Q),...(B.inputsDeclarations||[]).flatMap(Q=>Q),...(o.outputs||[]).flatMap(Q=>Q),...(B.outputsDeclarations||[]).flatMap(Q=>Q),...(K.internalCalls||[]).flatMap(Q=>Q),...K.writesValues||[],...F.dataType?[F.dataType]:[],...E.body?[E.body]:[],...F.defaultValue?[F.defaultValue]:[],...(F.successCalls||[]).flatMap(Q=>Q),...(F.errorCalls||[]).flatMap(Q=>Q),...(e.properties||[]).flatMap(Q=>Q),...(e.methods||[]).flatMap(Q=>Q),...(e.abstractMethods||[]).flatMap(Q=>Q),...w.error?[w.error]:[],...w.process?[w.process]:[],...V.throws?[V.throws]:[],...(p.andChildrenGroup||[]).flatMap(Q=>Q),...(p.orChildrenGroup||[]).flatMap(Q=>Q),...(A.entities||[]).flatMap(Q=>Q),...(A.functions||[]).flatMap(Q=>Q),...(A.functionCalls||[]).flatMap(Q=>Q),...(A.events||[]).flatMap(Q=>Q),...(A.conditions||[]).flatMap(Q=>Q),...(A.operations||[]).flatMap(Q=>Q),...(A.loops||[]).flatMap(Q=>Q),...(A.variableDeclarations||[]).flatMap(Q=>Q),...(A.variableInstances||[]).flatMap(Q=>Q),...(A.searches||[]).flatMap(Q=>Q),...(A.projects||[]).flatMap(Q=>Q),...(y.calls||[]).flatMap(Q=>Q)];d.type===f.DataType&&(p.entity&&u[J(p.entity)]&&u[J(p.entity)].parent&&J(u[J(p.entity)].parent)===d.id?ie.push(p.entity):p.entity&&q.push(p.entity)),(K.internalCalls||[]).forEach(Q=>{const ce=J(Q);if(ce&&u[ce]){const X=u[ce];[...X.successCalls||[],...X.errorCalls||[]].forEach(z=>{const pe=J(z);pe&&u[pe]&&ie.push(u[pe])})}});const W={},de={};return q.forEach(Q=>{var z;const ce=J(Q);if(ce&&a.ignoreBuiltInBaseEntities&&(Zi.includes(Q.type)||(a.allBuiltInEntityIds||[]).includes(ce)))return;const X=Q.version;if(ce){const pe=((z=a.entityMaps)==null?void 0:z.get(ce))||ce;W[pe]=X}}),ie.forEach(Q=>{var z;const ce=J(Q);if(ce&&a.ignoreBuiltInBaseEntities&&(Zi.includes(Q.type)||(a.allBuiltInEntityIds||[]).includes(ce)))return;const X=Q.version;if(ce){const pe=((z=a.entityMaps)==null?void 0:z.get(ce))||ce;de[pe]=X}}),{upstream:W,downstream:de}}function EIe(d,u){const r=[];if(xi.includes(d.type)){Ms(d).forEach(p=>{const e=Sd(p,u);e&&r.push(e)});const o=[...d.inputs||[],...d.outputs||[]].map(p=>{const e=Kd(p,u);return e?IS(e,u):null}).filter(p=>p!==null);r.push(...R(o))}if(Tt.includes(d.type)){const a=gm(d);a&&r.push(a)}return R(r)}function Ao(d){const u=[];if(xi.includes(d.type)){d.calledBy.forEach(o=>{const p=fr(o);p&&u.push(p)});const a=[...d.inputs||[],...d.outputs||[]].map(o=>gm(o)).filter(o=>o!==null);u.push(...R(a))}if(Tt.includes(d.type)){const r=gm(d);r&&u.push(r)}return R(u)}function Ms(d){return[...d.calledByEntry||[],...d.calledByError||[],...d.calledBySuccess||[]].filter(u=>u.type!==f.GenericReference)}function q5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");return[d,...d.inputs.flatMap(a=>me(a,u,r)),...d.outputs.flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...d.parent?me(d.parent,u,r):[]]}function Z5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");return[d,...d.defaultValue?me(d.defaultValue,u):[],...d.writesValues.flatMap(a=>me(a,u,r)),...d.dataType?me(d.dataType,u,r):[],...d.parent?me(d.parent,u,r):[]]}function H5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.BreakStatement)throw new Error("Entity must be a break statement to be flattened");return[d,...d.outputs.flatMap(a=>me(a,u,r)),...d.throws?me(d.throws,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function J5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");return[d,...(d.properties||[]).flatMap(a=>me(a,u,r)),...(d.methods||[]).flatMap(a=>me(a,u,r)),...(d.abstractMethods||[]).flatMap(a=>me(a,u,r)),...d.extends?me(d.extends,u,r):[]]}function W5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Condition)throw new Error("Entity must be a condition to be flattened");return[d,...(d.andChildrenGroup||[]).flatMap(a=>me(a,u,r)),...(d.orChildrenGroup||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function Y5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");return[d,...d.outputs.flatMap(a=>me(a,u,r)),...d.throws?me(d.throws,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function z5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");return[d,...d.extends?me(d.extends,u,r):[],...(d.implements||[]).flatMap(a=>me(a,u,r)),...(d.properties||[]).flatMap(a=>me(a,u,r)),...(d.methods||[]).flatMap(a=>me(a,u,r)),...(d.abstractMethods||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function X5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.DataType)throw new Error("Entity must be a data type to be flattened");return[d,...(d.andChildrenGroup||[]).flatMap(a=>me(a,u,r)),...(d.orChildrenGroup||[]).flatMap(a=>me(a,u,r)),...d.entity?me(d.entity,u,r):[],...d.parent?me(d.parent,u,r):[]]}function Q5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.FunctionCall)throw new Error("Entity must be a function call to be flattened");return[d,...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...d.process?me(d.process,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function eS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");return[d,...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.calls||[]).flatMap(a=>me(a,u,r)),...d.implements?me(d.implements,u,r):[],...d.parent?me(d.parent,u,r):[]]}function tS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.GlobalEvent)throw new Error("Entity must be a global event to be flattened");return[d,...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.calls||[]).flatMap(a=>me(a,u,r)),...d.implements?me(d.implements,u,r):[],...d.parent?me(d.parent,u,r):[]]}function rS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.InputMap)throw new Error("Entity must be an input map to be flattened");return[d,...d.readsValue?me(d.readsValue,u,r):[],...d.declaration?me(d.declaration,u,r):[],...d.defaultValue?me(d.defaultValue,u,r):[],...d.parent?me(d.parent,u,r):[]]}function iS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.InstalledProject)throw new Error("Entity must be an installed project to be flattened");return[d,...(d.functions||[]).flatMap(a=>me(a,u,r)),...(d.events||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function sS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.InternalCall)throw new Error("Entity must be an internal call to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...d.process?me(d.process,u,r):[],...d.parent?me(d.parent,u,r):[]]}function nS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.LiteralValue)throw new Error("Entity must be a literal value to be flattened");return[d,...d.valueAsTypeSingle?me(d.valueAsTypeSingle,u,r):[],...d.valueAsTypeList&&Array.isArray(d.valueAsTypeList)?d.valueAsTypeList.flatMap(a=>me(a,u,r)):[],...d.parent?me(d.parent,u,r):[]]}function aS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Loop)throw new Error("Entity must be a loop to be flattened");return[d,...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...d.process?me(d.process,u,r):[],...d.body?me(d.body,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function oS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Operation)throw new Error("Entity must be an operation to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...d.process?me(d.process,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function lS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.OutputMap)throw new Error("Entity must be an output map to be flattened");return[d,...(d.writesValues||[]).flatMap(a=>me(a,u,r)),...d.declaration?me(d.declaration,u,r):[],...d.defaultValue?me(d.defaultValue,u,r):[],...d.parent?me(d.parent,u,r):[]]}function dS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");return[d,...(d.properties||[]).flatMap(a=>me(a,u,r)),...(d.methods||[]).flatMap(a=>me(a,u,r)),...(d.abstractMethods||[]).flatMap(a=>me(a,u,r))]}function uS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Project)throw new Error("Entity must be a project to be flattened");return[d,...(d.entities||[]).flatMap(a=>me(a,u,r)),...(d.functions||[]).flatMap(a=>me(a,u,r)),...(d.events||[]).flatMap(a=>me(a,u,r)),...(d.projects||[]).flatMap(a=>me(a,u,r)),...(d.variableDeclarations||[]).flatMap(a=>me(a,u,r)),...(d.variableInstances||[]).flatMap(a=>me(a,u,r)),...(d.operations||[]).flatMap(a=>me(a,u,r)),...(d.conditions||[]).flatMap(a=>me(a,u,r)),...(d.functionCalls||[]).flatMap(a=>me(a,u,r)),...(d.projects||[]).flatMap(a=>me(a,u,r)),...(d.loops||[]).flatMap(a=>me(a,u,r)),...(d.searches||[]).flatMap(a=>me(a,u,r))]}function cS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Property)throw new Error("Entity must be a property to be flattened");return[d,...d.defaultValue?me(d.defaultValue,u,r):[],...d.dataType?me(d.dataType,u,r):[],...d.parent?me(d.parent,u,r):[]]}function pS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ReturnDeclaration)throw new Error("Entity must be a return declaration to be flattened");return[d,...d.readsValue?me(d.readsValue,u,r):[],...d.defaultValue?me(d.defaultValue,u,r):[],...d.dataType?me(d.dataType,u,r):[],...d.parent?me(d.parent,u,r):[]]}function fS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");return[d,...(d.outputs||[]).flatMap(a=>me(a,u,r)),...d.throws?me(d.throws,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function hS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Search)throw new Error("Entity must be a search to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(d.inputsDeclarations||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputsDeclarations||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function yS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");return[d,...d.defaultValue?me(d.defaultValue,u,r):[],...d.dataType?me(d.dataType,u,r):[],...d.parent?me(d.parent,u,r):[]]}function mS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...(d.internalCalls||[]).flatMap(a=>me(a,u,r)),...(d.writesValues||[]).flatMap(a=>me(a,u,r)),...d.readsValue?me(d.readsValue,u,r):[],...d.defaultValue?me(d.defaultValue,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.dataType?me(d.dataType,u,r):[],...d.parent?me(d.parent,u,r):[]]}function vS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...(d.internalCalls||[]).flatMap(a=>me(a,u,r)),...(d.writesValues||[]).flatMap(a=>me(a,u,r)),...d.readsValue?me(d.readsValue,u,r):[],...d.defaultValue?me(d.defaultValue,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.declaration?me(d.declaration,u,r):[],...d.parent?me(d.parent,u,r):[]]}function zs(){const d=new Set,u=KL.flatMap(r=>me(r,d)).map(r=>r.id);if(!u.includes("http-request-error-return-delaration-id"))throw new Error("Built-in base entities must be included in the list");return u}function me(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(!d)throw new Error("Entity must be defined to be flattened");if(d.type===f.GenericReference)return[];if(r.ignoreBuiltInBaseEntities&&(Zi.includes(d.type)||zs().includes(d.id)))return[];if(u.has(d.id))return[];switch(d.type){case f.FunctionCall:return Q5(d,u,r);case f.Operation:return oS(d,u,r);case f.Condition:return W5(d,u,r);case f.Loop:return aS(d,u,r);case f.Search:return hS(d,u,r);case f.GlobalEvent:return tS(d,u,r);case f.ReturnStatement:return fS(d,u,r);case f.ContinueStatement:return Y5(d,u,r);case f.BreakStatement:return H5(d,u,r);case f.VariableDeclaration:return mS(d,u,r);case f.DefinitionEntity:return z5(d,u,r);case f.FunctionDeclaration:return eS(d,u,r);case f.Project:return uS(d,u,r);case f.ActionDescriptor:return q5(d,u,r);case f.ArgumentDeclaration:return Z5(d,u,r);case f.ReturnDeclaration:return pS(d,u,r);case f.ValueDescriptor:return yS(d,u,r);case f.InputMap:return rS(d,u,r);case f.OutputMap:return lS(d,u,r);case f.DataType:return X5(d,u,r);case f.InstalledProject:return iS(d,u,r);case f.InternalCall:return sS(d,u,r);case f.LiteralValue:return nS(d,u,r);case f.Property:return cS(d,u,r);case f.VariableInstance:return vS(d,u,r);case f.BuiltInBaseEntity:return r.ignoreBuiltInBaseEntities?[]:J5(d,u,r);case f.PrimitiveEntity:return r.ignoreBuiltInBaseEntities?[]:dS(d,u,r)}return[]}function hb(d){return d.type===f.FunctionCall||d.type===f.InternalCall||[f.Operation,f.Condition,f.Loop].includes(d.type)?d.declaration.inputs:d.type===f.FunctionDeclaration||jo.includes(d.type)?d.inputs:d.type===f.Search?d.inputsDeclarations:[]}function TIe(d,u){return u.type===f.Condition?u.inputs.find(r=>r.declaration.id===d.id):u.type===f.FunctionCall||u.type===f.Operation?u.inputs.find(r=>r.declaration.id===d.id):null}function ES(d){return sr.includes(d.type)?d.inputs:[]}function TS(d){var u;return d.type===f.FunctionCall?((u=d.declaration.returnStatements[0])==null?void 0:u.outputs)||[]:[f.Operation,f.Condition,f.Loop].includes(d.type)?d.declaration.outputs:d.type===f.Search?d.outputsDeclarations:hr.includes(d.type)?d.outputs:[]}function IIe(d,u){return u.type===f.Condition?null:(u.type===f.FunctionCall||u.type===f.Operation)&&u.outputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===d.id})||null}function AIe(d){return d.type===f.Condition?[]:sr.includes(d.type)?d.outputs:[]}function gm(d){const u=d.readsValue;return u?fr(u):null}function IS(d,u){const r=d.readsValue;return r?Sd(r,u):null}function AS(d){const u=d.internalCalls||[];return R(La(R(u.flatMap(r=>[...r.successCalls,...r.errorCalls]))))}function bS(d){const u=d.internalCalls||[];return R(R(u.flatMap(r=>[...r.successCalls,...r.errorCalls])))}function qd(d){const u=wm(d),r=[];return u.forEach(a=>{if(Tt.includes(a.type))r.push(a);else if(un.includes(a.type)){const o=fr(a.parent);r.push(o)}}),r}function Zd(d){const u=wm(d),r=[];return u.forEach(a=>{if(Tt.includes(a.type))r.push(a);else if(un.includes(a.type)){const o=a.parent;r.push(o)}}),r}function R(d){const u=new Set;return d.filter(r=>!r||u.has(r.id)?!1:(u.add(r.id),!0))}function wS(d){return d.type===f.Project?null:$v.includes(d.type)?d:Zi.includes(d.type)?null:d.parent?wS(d.parent):null}function bn(d,u=!1){const r=[];if(d.type===f.Project&&r.push(...(d==null?void 0:d.entities)||[],...(d==null?void 0:d.functions)||[],...(d==null?void 0:d.variableDeclarations)||[],...(d==null?void 0:d.variableInstances)||[],...(d==null?void 0:d.searches)||[],...(d==null?void 0:d.loops)||[],...(d==null?void 0:d.operations)||[],...(d==null?void 0:d.conditions)||[],...(d==null?void 0:d.functionCalls)||[],...(d==null?void 0:d.events)||[],...(d==null?void 0:d.projects)||[]),Nr.includes(d.type)&&r.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===f.DefinitionEntity){const a=[...d.suggestedMethods,...d.methods].flatMap(o=>o.collapsed&&u?[]:bn(o));r.push(...a)}if(d.type===f.Condition){const a=d.successCalls.map(p=>fr(p)),o=d.errorCalls.map(p=>fr(p));r.push(...a,...o)}if(jo.includes(d.type)){if(d.collapsed&&u)return[];const a=d.inputs.map(p=>qd(p)).flat(),o=d.calls.map(p=>fr(p));r.push(...R(a),...o)}if(sr.includes(d.type)&&d.type!==f.Condition&&d.type!==f.Loop){const a=d==null?void 0:d.outputs.map(e=>qd(e)).flat(),o=d.successCalls.map(e=>fr(e)),p=d.errorCalls.map(e=>fr(e));r.push(...R(a),...o,...p)}if(Tt.includes(d.type)){const a=qd(d),o=AS(d);r.push(...a,...o)}if(d.type===f.Loop){const a=d.outputs.map(e=>qd(e)).flat();if(d.body){const e=bn(d.body,u);r.push(...e)}const o=d.errorCalls.map(e=>fr(e)),p=d.successCalls.map(e=>fr(e));r.push(...R(a),...p,...o)}if(d.type===f.FunctionDeclaration){if(d.collapsed&&u)return[];const a=d.inputs.map(p=>qd(p)).flat(),o=d.calls.map(p=>fr(p));r.push(...R(a),...o)}return R(r)}function _m(d,u=!1){const r=[];if(d.type===f.Project&&r.push(...(d==null?void 0:d.variableDeclarations)||[],...(d==null?void 0:d.variableInstances)||[],...(d==null?void 0:d.searches)||[],...(d==null?void 0:d.loops)||[],...(d==null?void 0:d.operations)||[],...(d==null?void 0:d.conditions)||[],...(d==null?void 0:d.functionCalls)||[]),Nr.includes(d.type)&&r.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===f.DefinitionEntity){const a=[...d.suggestedMethods,...d.methods].flatMap(o=>o.collapsed&&u?[]:_m(o));r.push(...a)}if(d.type===f.Condition){const a=d.successCalls,o=d.errorCalls;r.push(...a,...o)}if(jo.includes(d.type)){if(d.collapsed&&u)return[];const a=d.inputs.map(p=>Zd(p)).flat(),o=d.calls;r.push(...R(a),...o)}if(sr.includes(d.type)&&d.type!==f.Condition&&d.type!==f.Loop){const a=d==null?void 0:d.outputs.map(e=>Zd(e)).flat(),o=d.successCalls,p=d.errorCalls;r.push(...R(a),...o,...p)}if(Tt.includes(d.type)){const a=Zd(d),o=bS(d);r.push(...a,...o)}if(d.type===f.Loop){const a=d.outputs.map(e=>Zd(e)).flat();if(d.body){const e=_m(d.body,u);r.push(...e)}const o=d.errorCalls,p=d.successCalls;r.push(...R(a),...p,...o)}if(d.type===f.FunctionDeclaration){if(d.collapsed&&u)return[];const a=d.inputs.map(p=>Zd(p)).flat(),o=d.calls;r.push(...R(a),...o)}return R(r)}function Dm(d,u=!1){const r=bn(d,u),a=[...r,...r.reduce((o,p)=>[...o,...Dm(p,u)],[])];return R(a)}function RS(d,u=!1){const r=_m(d,u),a=[...r,...r.reduce((o,p)=>[...o,...RS(p,u)],[])];return R(a)}function gS(d){const u=Ao(d),r=[...u,...u.reduce((a,o)=>[...a,...gS(o)],[])];return R(r)}function zp(d){return d.implements.reduce((u,r)=>r.type===f.DefinitionEntity?[...u,f.DefinitionEntity,...zp(r),...Xp(r)]:[...u,r.name],[])}function Xp(d){return d.extends?d.extends.type===f.DefinitionEntity?[f.DefinitionEntity,...Xp(d.extends),...zp(d.extends)]:[d.extends.name]:[]}function yb(d){return d.extends?d.extends.type===f.DefinitionEntity?[d.extends,...yb(d.extends),...mb(d.extends)]:[d.extends]:[]}function mb(d){return d.implements.reduce((u,r)=>r.type===f.DefinitionEntity?[...u,r,...mb(r),...yb(r)]:[...u,r],[])}function Hd(d){return[...Xp(d),...zp(d)].filter((r,a,o)=>o.indexOf(r)===a)}function vb(d){return d.implements.length===0&&!d.extends?null:d.implements.find(a=>a.type===f.BuiltInBaseEntity&&a.name===Le.PERSISTED_ENTITY)?d:[...d.implements,...d.extends?[d.extends]:[]].reduce((a,o)=>{if(o.type===f.DefinitionEntity){const p=vb(o);if(p)return p}return a},null)}function bIe(d){return d.extends&&d.extends.type===f.BuiltInBaseEntity?d.extends:null}function wIe(d){const u=d.implements.find(r=>r.type===f.BuiltInBaseEntity);return u&&u.type===f.BuiltInBaseEntity?u:null}function Om(d){return d.extends&&d.extends.type===f.DefinitionEntity?d.extends:null}function Vi(d){if(d.type===f.BuiltInBaseEntity)return[d];const u=[...d.implements,...d.extends?[d.extends]:[]].reduce((r,a)=>a.type===f.BuiltInBaseEntity?[...r,a]:a.type===f.DefinitionEntity?[...r,...Vi(a)]:r,[]);return R(u)}function Qp(d){return d.type===f.PrimitiveEntity?!0:d.type===f.BuiltInBaseEntity?d.interactive:!Vi(d).find(a=>!a.interactive)}function RIe(d){return d.parent===d.project&&d.project.variableDeclarations.includes(d)}function Eb(d){return d.parent!==d.project?!1:f.VariableDeclaration===d.type?d.project.variableDeclarations.includes(d):f.VariableInstance===d.type?d.project.variableInstances.includes(d):f.FunctionCall===d.type?d.project.functionCalls.includes(d):f.Condition===d.type?d.project.conditions.includes(d):f.Operation===d.type?d.project.operations.includes(d):f.Loop===d.type?d.project.loops.includes(d):f.Search===d.type?d.project.searches.includes(d):!1}function _S(d){if([...Dt,f.DefinitionEntity,f.InstalledProject,f.Project].includes(d.type)||Eb(d))return!1;const u=Ao(d);return u.length===0?!0:u.some(r=>_S(r))}function Tb(d){return[...Dt,f.DefinitionEntity,f.InstalledProject,f.Project].includes(d.type)||Eb(d)?!1:Ao(d).length===0}function DS(d,u=0){if(Tb(d)){const r=Ao(d);return r.length===0?d:r.map(o=>DS(o,u+1)).reduce((o,p)=>o?p&&p.x<o.x?p:o:p,null)}return null}function OS(d){const u=[];if(Tb(d))u.push(d);else return[];return Ao(d).forEach(a=>{u.push(...OS(a))}),u}function Ib(d){return d.type===f.FunctionDeclaration&&d.parent!==d.project&&!![f.DefinitionEntity,f.Loop,f.InstalledProject].includes(d.parent.type)}function gIe(d,u){const r=new Map;return d.forEach(a=>{r.set(a.id,a)}),u.forEach(a=>{r.set(a.id,a)}),Array.from(r.values())}function ef(d){switch(d){case f.DefinitionEntity:return Qn;case f.FunctionDeclaration:return Qa;case f.VariableDeclaration:return oo;case f.VariableInstance:return ao;case f.FunctionCall:return To;case f.Operation:return eo;case f.Condition:return io;case f.ReturnStatement:return to;case f.Loop:return Gi;case f.Search:return lo;case f.InputMap:return Wn;case f.OutputMap:return In;case f.ArgumentDeclaration:return kn;case f.ReturnDeclaration:return Qi;case f.Property:return Xn;case f.InstalledProject:return uo;case f.Project:return N;case f.DataType:return fs;case f.GlobalEvent:return ro;case f.InternalCall:return co;case f.ValueDescriptor:return An;case f.BuiltInBaseEntity:return ea;case f.PrimitiveEntity:return ts;case f.ActionDescriptor:return ct;case f.LiteralValue:return Ki;case f.ContinueStatement:return Pi;case f.BreakStatement:return po;default:return null}}function Di(d,u,r=null){const a=d!=null&&d.parent?J(d==null?void 0:d.parent):null;let o=a?u.get(a):null,p=r||d;if((d==null?void 0:d.id)===(u==null?void 0:u.id))return u;if(d.type===f.ReturnStatement)return Hr(d,u,p);if(d.type===f.FunctionDeclaration&&(o==null?void 0:o.type)===f.Loop)return o;if(Dt.includes(d.type))return d;if(d.type===f.Loop)return p.id===d.id?o:d;if(Zi.includes(d.type))return null;const e=d.parent;if(!e)return null;if(e.type===f.GenericReference){const y=J(e);if(!y)return null;const v=u.get(y);return v?Di(v,u,p):null}else return e===u?u:Di(e,u,p)}function Hr(d,u,r=null){const a=d!=null&&d.parent?J(d==null?void 0:d.parent):null;let o=a?u.get(a):null,p=r||d;if(d.type===f.FunctionDeclaration&&(o==null?void 0:o.type)===f.Loop)return Hr(o.parent,u,p);if(Dt.includes(d.type))return d;if(Zi.includes(d.type))return null;const e=d.parent;if(!e)return null;if(e.type===f.GenericReference){const y=J(e);if(!y)return null;const v=u.get(y);return v?Hr(v,u,p):null}else return e===u?u:Hr(e,u,p)}function Jd(d,u){if(Zi.includes(d.type))return Me.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with a built-in entity type: ${d.type}`),null;if(u.getBuiltIn(d.id))return Me.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with a built-in entity: ${d.id}`),null;const r=qi(d.parent,u);return r?r===u?Nr.includes(d.type)?d:(Me.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with an entity that has the project as parent: ${d.id}`),null):r.type===f.DefinitionEntity?d:Jd(r,u):(Me.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with an entity that has no parent: ${d.id}`),null)}function Cm(d,u,r){if(d===u||u===r||d===r||!d||!u)return!1;const a=Di(u.parent,r);return a===r?!1:a===d?!0:Cm(a,u,r)}var $m=(d=>(d.SameBothLocal="same-both-local",d.AInB="a-in-b",d.BInA="b-in-a",d.ParallelInCommonParent="parallel-in-common-parent",d.ParallelInProject="parallel-in-project",d.AIsGlobalBIsNot="a-is-global-b-is-not",d.BIsGlobalAIsNot="b-is-global-a-is-not",d.SameBothGlobal="same-both-global",d))($m||{});function Xs(d,u,r){const a=Di(d,r),o=Di(u,r);if(!a)throw new Error("Could not find scope owner for the entity: "+d.id);if(!o)throw new Error("Could not find scope owner for the entity: "+u.id);if(a===o&&a.type!==f.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:a};if(a===o&&a.type===f.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:a};if(a.type===f.Project&&o.type!==f.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:a};if(a.type!==f.Project&&o.type===f.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:o};if(Cm(a,o,r))return{compatible:!0,type:"b-in-a",commonAncestorScope:a};if(Cm(o,a,r))return{compatible:!0,type:"a-in-b",commonAncestorScope:o};const y=fb(a,o);return y===r?{compatible:!1,type:"parallel-in-project",commonAncestorScope:y}:y?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:Di(y,r)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:r}}function CS(d,u,r){const a=Xs(d,u,r);if(!a.compatible||a.type!=="same-both-local")return null;if(d===u)return d;let o=Di(d.parent,r);if(o){if(o===u)return u;if(o.type===f.Project)return d}else return d;for(;o;){if(o){if(o===u)return u;if(o.type===f.Project)return d}else return d;o=Di(o.parent,r)}let p=Di(u.parent,r);if(p){if(p===d)return d;if(p.type===f.Project)return u}else return u;for(;p;){if(p){if(p===d)return d;if(p.type===f.Project)return u}else return u;p=Di(p.parent,r)}return null}function $S(d){return d.length===0?null:d.length===1?d[0]:d.reduce((r,a)=>{const o=CS(r,a,a.project);return!o||o===a?r:a},d[0])}function qi(d,u){if(!d)return null;let r;return typeof d=="string"?r=d:d.type===f.GenericReference?r=J(d):r=d.id,r===u.id?u:u.get(r)}function bo(d){if(!d)return null;if(Zi.includes(d.type))return d;if(d.type===f.Project)return null;if(d.project.getBuiltIn(d.id))return d;const u=d.parent;return!u||u.type===f.Project?null:bo(u)}function tf(d){const u=[];function r(p,e){return u.some(y=>y.blockedByCaller===p&&y.blockedByCalling===e)}function a(p,e){r(p,e)||u.push({blockedByCaller:p,blockedByCalling:e})}const o=Jd(d,d.project);return o?(d.calledBySuccess.forEach(p=>{[...p.successCalls||[]].forEach(v=>{hr.includes(v.type)&&v!==d&&(dt(d).find(A=>A===v)||a(p,v))});let y;if(sr.includes(p.type)&&(y=p),y){const v=tf(y);v.reachable||dt(d).find(A=>A===p)||v.blocks.forEach(A=>{a(p,A.blockedByCalling)})}}),d.calledByError.forEach(p=>{[...p.errorCalls||[]].forEach(v=>{hr.includes(v.type)&&v!==d&&(dt(d).find(A=>A===v)||a(p,v))});let y;if(sr.includes(p.type)&&(y=p),y){const v=tf(y);v.reachable||dt(d).find(A=>A===p)||v.blocks.forEach(A=>{a(p,A.blockedByCalling)})}}),d.calledByEntry.forEach(p=>{if([...p.calls||[]].forEach(v=>{hr.includes(v.type)&&v!==d&&(dt(d).find(A=>A===v)||a(p,v))}),p===o)return;let y;if(p.type===f.FunctionDeclaration){const v=fr(p);if(v.type===f.DefinitionEntity)return;v.type===f.Loop&&(y=v)}if(y){const v=tf(y);v.reachable||v.blocks.forEach(E=>{a(p,E.blockedByCalling)})}}),{reachable:u.length===0,entryPoint:o,blocks:u}):{reachable:!0,entryPoint:null,blocks:[]}}function _Ie(d){return th.includes(d.type)?d.type===f.FunctionDeclaration?!Ib(d):!0:!1}function DIe(d){if(f.ActionDescriptor===d.type){if(d.project.operationDeclarations.find(p=>p.id===d.id))return f.Operation;if(d.project.globalEventActionDescriptors.find(p=>p.id===d.id))return f.GlobalEvent;if(d.project.loopDeclarations.find(p=>p.id===d.id))return f.Loop;if(d.project.conditionDeclarations.find(p=>p.id===d.id))return f.Condition}return d.type}function Pm(d,u){return d.type===f.BuiltInBaseEntity?d.name===u:!!Xp(d).includes(u)}function OIe(d,u){return d.type===f.BuiltInBaseEntity?d.name===u:!!zp(d).includes(u)}function es(d,u){return d.type===f.BuiltInBaseEntity?d.name===u:!!Hd(d).includes(u)}function CIe(d){const u=[];return d.entities.forEach(r=>{if(Pm(r,Le.PERSISTED_ENTITY)){u.push(r);return}}),R(u)}function $Ie(d){const u=[];return d.entities.forEach(r=>{if(Pm(r,Le.RELATIONAL_DATABASE)){u.push(r);return}}),R(u)}function PIe(d){return d.type!==f.DefinitionEntity||d.abstract||!Pm(d,Le.PERSISTED_ENTITY)?null:(d==null?void 0:d.properties.find(r=>{var a;return((a=r.implements)==null?void 0:a.id)===he[f.BuiltInBaseEntity][Le.PERSISTED_ENTITY].properties.primaryKey.id&&!r.abstract}))||null}function PS(d){var a;const u=vb(d);if(!u)return null;const r=u.properties.find(o=>{var p;return((p=o.implements)==null?void 0:p.id)===he[f.BuiltInBaseEntity][Le.PERSISTED_ENTITY].properties.database.id});return r?(a=r.getDefaultValue())==null?void 0:a.valueAsType:null}function Wd(d){if(d.type!==f.DefinitionEntity)return[];if(d.abstract)return[];if(!es(d,Le.PERSISTED_ENTITY))return[];const u=[],r=d.properties.filter(a=>{var o;return((o=a.implements)==null?void 0:o.id)!==he[f.BuiltInBaseEntity][Le.PERSISTED_ENTITY].properties.database.id&&!a.abstract});return u.push(...r),u}function NIe(d){var r;if(!d||d.type!==f.DefinitionEntity||!es(d,Le.PERSISTED_ENTITY))return null;const u=d.properties.find(a=>{var o;return((o=a.implements)==null?void 0:o.id)===he[f.BuiltInBaseEntity][Le.PERSISTED_ENTITY].properties.database.id});return(r=u==null?void 0:u.getDefaultValue())==null?void 0:r.valueAsTypeSingle}function Ur(d,u){var a;if(!t_.includes(u.type)||!d)return u.project||null;let r=u.project;return d.type===f.Project?r=d:((a=u.project)==null?void 0:a.id)!==d.project.id&&(r=d.project),r}function VIe(d){switch(d){case f.Project:return N;case f.InstalledProject:return uo;case f.DefinitionEntity:return Qn;case f.FunctionDeclaration:return Qa;case f.GlobalEvent:return ro;case f.VariableInstance:return ao;case f.VariableDeclaration:return oo;case f.InputMap:return Wn;case f.OutputMap:return In;case f.Condition:return io;case f.Operation:return eo;case f.FunctionCall:return To;case f.ReturnDeclaration:return Qi;case f.ArgumentDeclaration:return kn;case f.PrimitiveEntity:return ts;case f.DataType:return fs;case f.Property:return Xn;case f.ActionDescriptor:return ct;case f.ReturnStatement:return to;case f.ContinueStatement:return Pi;case f.BreakStatement:return po;case f.Loop:return Gi;case f.Search:return lo;case f.ValueDescriptor:return An;case f.InternalCall:return co;case f.LiteralValue:return Ki}return null}function LIe(d){const u={added:{},updated:{},removed:{},affected:[],seenEntities:[],self:d==null?void 0:d.self};return d==null||d.added.forEach(r=>{u.added[r.id]=r}),d==null||d.updated.forEach(r=>{u.updated[r.id]=r}),d==null||d.removed.forEach(r=>{u.removed[r.id]=r}),u.affected=Array.from(new Set(d==null?void 0:d.affected.map(r=>r.id))),u}function Lr(d,u){const r=ef(d.type);return r?!r.MUTABLE_META_PROPERTIES.every(o=>{const p=d[o],e=u[o];return e===void 0||p===e?!0:Array.isArray(p)&&Array.isArray(e)?p.length!==e.length?!1:p.every((y,v)=>y===e[v]):!1}):!1}function Nm(d,u={}){if(d.type===f.Project)return[];if(!d.parent)return[];const r=J(d.parent);if(!r)return[];const a=u[r];return a?[a.id,...Nm(a,u)]:[]}function MIe(d){const u=[],r=new Set;return[...d.listAdded,...d.listUpdated,...d.listAffected].forEach(a=>{const o=fr(a);!o||r.has(o.id)||(r.add(o.id),u.push(o))}),R(u)}function BIe(d){if(d.type===f.Condition)return null;if(d.type===f.Search)return d.project.getBuiltIn(he["value-descriptor"][Jl.SearchErrorOutputDescriptor].id)||null;if(d.type===f.Operation)return d.declaration.error;if(d.type===f.FunctionCall){const r=d.declaration.returnStatements.find(a=>!!a.throws);return(r==null?void 0:r.throws)||null}return null}function NS(d){const u=d.entities.filter(o=>!!o.implements.find(p=>p.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),r=u.find(o=>{const p=o.properties.find(v=>v.implements&&v.implements.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),e=p==null?void 0:p.getDefaultValue();return(e==null?void 0:e.value)===!0});return r||u[0]||null}function Ab(d,u){const r=Array.from(new Set([...u.getAllBuiltInIds(),...zs()]));return!!(r.includes(d.id)||!Nm(d,{...u.instances,...u.builtInInstances}).every(p=>!r.includes(p)))}function VS(d){if(!d)return null;if(d.type===f.Project)return d.id;const u=d.parent;return u?VS(u):d.id}function rf(d){if(d.declaration&&d.declaration.type===f.Property){if(d.declaration.interactive){if(d.declaration.implements&&!d.declaration.implements.interactive)return!1;if(d.declaration.extends&&!d.declaration.extends.interactive)return!1}else return!1;if(d.declaration.private){const u=fr(d),r=Jd(u,d.project);if((r==null?void 0:r.type)===f.FunctionDeclaration&&(r==null?void 0:r.parent.type)===f.DefinitionEntity&&(r==null?void 0:r.parent.id)!==d.declaration.parent.id)return!1}}return!0}function bb(d){if(d.interactive){if(d.implements&&!d.implements.interactive)return!1;if(d.extends&&!d.extends.interactive)return!1}else return!1;if(d.private){const u=fr(d),r=Jd(u,d.project);if((r==null?void 0:r.type)===f.FunctionDeclaration&&(r==null?void 0:r.parent.type)===f.DefinitionEntity&&(r==null?void 0:r.parent.id)!==d.parent.id)return!1}return!0}function UIe(d,u,r){const a=u,o=r,p=!!r,e=[];return a.forEach(y=>{var v;if(p){const E=Xs(o,y,d);if(!E.compatible&&E.type!=="b-is-global-a-is-not")return;e.push(y)}else{if(((v=y.parent)==null?void 0:v.type)!==f.Project)return;e.push(y)}}),R(e)}function Vm(d){return d.replace(/["'`]/g,"")}function xr(d){const r=Vm(d).split(/[\s-]+/).filter(e=>e.length>0);if(r.length===0)return"";const a=r[0],o=a[0].toLowerCase()+a.slice(1),p=r.slice(1).map(e=>e[0].toUpperCase()+e.slice(1));return[o,...p].join("")}function Al(d){return Vm(d).split(/[\s-]+/).filter(a=>a.length>0).map(a=>a[0].toUpperCase()+a.slice(1)).join("")}function LS(d){const u=Vm(d).trim();if(!u)return"";const r=u.replace(/[\s_-]+/g," ").split(" ").filter(Boolean),a=[];for(const o of r){let p=o;p=p.replace(/([A-Z]+)([A-Z][a-z]+)/g,"$1-$2"),p=p.replace(/([a-z0-9])([A-Z][a-z0-9]*)/g,"$1-$2"),p=p.replace(/([0-9])([a-zA-Z]+)/g,"$1-$2"),p=p.replace(/([a-zA-Z])([0-9])/g,"$1-$2");for(const e of p.split("-"))e&&a.push(e)}return a.join("-")}function xIe(d){const u=Vm(d).trim();if(!u)return"";const r=u.replace(/[\s_-]+/g," ").split(" ").filter(Boolean),a=[];for(const o of r){let p=o;p=p.replace(/([A-Z]+)([A-Z][a-z]+)/g,"$1_$2"),p=p.replace(/([a-z0-9])([A-Z][a-z0-9]*)/g,"$1_$2"),p=p.replace(/([0-9])([a-zA-Z]+)/g,"$1_$2"),p=p.replace(/([a-zA-Z])([0-9])/g,"$1_$2");for(const e of p.split("_"))e&&a.push(e)}return a.join("_")}function Lm(d){return LS(d).toLowerCase()}function Yd(d){var r,a,o,p;if(!d)return"Any data type";let u="";if(d.interactiveEntities===!1?u+=` but only definition nodes ${d.asType?"as template ":""}that don't include non-interactive built-in functionality`:d.interactiveEntities===!0&&(u+=` but only definition nodes ${d.asType?"as template ":""}that extend or implement interactive built-in functionality`),d.staticEntities===!1?u?u+=" and that aren't a single global copy instance":u+=` but only definition nodes ${d.asType?"as template ":""}that aren't a single global copy instance`:d.staticEntities===!0&&(u?u+=" and that are a single global copy instance":u+=` but only definition nodes ${d.asType?"as template ":""}that are a single global copy instance`),d.actionEntities===!1?u?u+=" excluding executable/action nodes":u+=` excluding executable/action nodes ${d.asType?"templates ":""}`:d.actionEntities===!0&&(u?u+=" and not executable/action nodes":u+=" but not executable/action nodes"),d.entity&&(u=""),d.asType&&!u&&!((r=d.andChildrenGroup)!=null&&r.length)&&!((a=d.orChildrenGroup)!=null&&a.length)&&(u=" as template"),!d.entity){const e=d.isList;if(!((o=d.andChildrenGroup)!=null&&o.length)&&!((p=d.orChildrenGroup)!=null&&p.length))return e?`List of an any data type${u}`:`Any data type${u}`;let y="",v=!1,E=!1;return(d.andChildrenGroup||[]).forEach(w=>{const A=Yd(w),$=Rd(A);v&&(y+=" and "),w.isGroup?y+="("+$+")":v?y+=$:y+=A,v=!0,E=!0}),(d.orChildrenGroup||[]).forEach(w=>{const A=Yd(w),$=Rd(A);v&&(E&&(y+=","),y+=" or "),w.isGroup?y+="("+$+")":v?y+=$:y+=A,v=!0}),e?`List of ${Rd(y)}`:y}if(d.entity.type===f.PrimitiveEntity){let e=d.entity.name;switch(d.entity.name){case oe.String:e="Text";break;case oe.KeyValue:e="Data structure";break}return d.isList?`List of ${e}s${u}`:`${e.slice(0,1).toUpperCase()}${e.slice(1)}${u}`}else if(d.entity.type===f.DefinitionEntity){const e=Y(d.entity,d.project);return d.isList?`List of ${e} values${u}`:e.slice(0,1).toUpperCase()+e.slice(1)+u}else if(d.entity.type===f.BuiltInBaseEntity){const e=BS(d.entity);return d.isList?`List of ${e} values${u}`:e.slice(0,1).toUpperCase()+e.slice(1)+u}else if(d.entity.type===f.LiteralValue){if(d.entity.name===oe.Null)return"Empty value";if(d.entity.name===oe.Untyped)return"Untyped value";if(d.entity.name===oe.File)return"File";if(d.entity.name===oe.String)return`"${d.entity.value}" text`;if(d.entity.name===oe.Number)return`Number '${d.entity.value}'`;if(d.entity.name===oe.Boolean)return`${d.entity.value} value`;if(d.entity.name===oe.UUID)return`"${d.entity.value}" unique identifier`;if(d.entity.name===oe.Date)return`"${d.entity.value}" date`}return d.isList?`List of ${Y(d.entity,d.project)} values${u}`:`${Y(d.entity,d.project).slice(0,1).toUpperCase()+Y(d.entity,d.project).slice(1)} value${u}`}function jIe(d){if(!d)return"Any data type";const u=d.getDataType(null);return Yd(u)}function Mm(d){switch(d.declaration.id){case ut.Equal:return"is equal to";case ut.NotEqual:return"is not equal to";case ut.MoreThan:return"is greater than";case ut.MoreThanOrEqual:return"is greater than or equal to";case ut.LessThan:return"is less than";case ut.LessThanOrEqual:return"is less than or equal to";case Kr.And:return"and";case Kr.Or:return"or";case oi.Empty:return"is empty";case oi.NotEmpty:return"is present"}}function MS(d){return d.includes(Le.HTTP_ENDPOINT)?"HTTP endpoint":d.includes(Le.PERSISTED_ENTITY)?"Persisted entity":d.includes(Le.CRON_JOB)?"Scheduled execution":d.includes(Le.RELATIONAL_DATABASE)?"Relational database":"Entity"}function BS(d){switch(d.name){case Le.HTTP_ENDPOINT:return"HTTP endpoint";case Le.PERSISTED_ENTITY:return"Persisted entity";case Le.CRON_JOB:return"Scheduled execution";case Le.RELATIONAL_DATABASE:return"Relational database"}return"Entity"}function GIe(d){const u=Om(d);if(!u){const r=Hd(d);return r.includes(Le.HTTP_ENDPOINT)?"HTTP endpoint":r.includes(Le.PERSISTED_ENTITY)?"Persisted entity":r.includes(Le.CRON_JOB)?"Scheduled execution":r.includes(Le.RELATIONAL_DATABASE)?"Relational database":Y(d,d.project)+" entity"}return Y(u,d.project)+" entity"}function US(d){let u="Find ";return d.outputsDeclarations.forEach((r,a)=>{const o=Hy(r,null),p=Rd(o&&o.entity?Y(o.entity,d.project):"unstructured data");a===0?u+=`${p} `:a===d.outputsDeclarations.length-1?u+=`and ${p} `:u+=`, ${p} `}),u}function xS(d){switch(d.name){case oe.String:return"Text";case oe.Number:return"Number";case oe.Boolean:return"Boolean";case oe.KeyValue:return"Data structure";case oe.UUID:return"Unique identifier";case oe.Date:return"Date";case oe.EntityTemplate:return"Entity as template";case oe.Enum:return"Enumeration";case oe.File:return"File";case oe.Null:return"Empty";case oe.ActionDescriptor:return"Action descriptor";case oe.Untyped:return"Untyped";default:return d.name}}function jS(d){switch(d.id){case Je.List:return"Loop over list items";case Je.ManualFlow:return"Manual flow control loop";case Je.ObjectKeys:return"Loop over object keys";case Je.ObjectValues:return"Loop over object values";case Je.Counted:return"Loop given number of times";case Je.String:return"Loop over text characters";case Zt.Addition:return"Sum numbers";case Zt.Subtraction:return"Subtract numbers";case Zt.Multiplication:return"Multiply numbers";case Zt.Division:return"Divide numbers";case Zt.Remainder:return"Get remainder of numbers";case Zt.Exponentiation:return"Get exponent of numbers";case Ge.AddIndex:return"Add at index position";case Ge.DeleteFirst:return"Delete first character";case Ge.DeleteLast:return"Delete last character";case Ge.DeleteIndex:return"Delete at index position";case Ge.Join:return"Join texts";case Ge.ReplaceAllMatches:return"Replace all matches";case Ge.ReplaceFirst:return"Replace first match";case Ge.ReplaceLast:return"Replace last match";case Ge.Split:return"Split text";case Ge.ReplaceIndex:return"Replace at index position";case Ge.ReplaceSingleMatch:return"Replace single match";case Ge.GetFirst:return"Get first character";case Ge.GetLast:return"Get last character";case Ge.GetIndexItem:return"Get at index position";case Ge.GetIndexOf:return"Get the index number of the character";case Ge.Append:return"Add at the end";case Ge.Prepend:return"Add at the start";case tr.Wait:return"Wait";case tr.Parallel:return"Run in parallel";case tr.Sequential:return"Run in sequence";case yi.HttpRequest:return"HTTP request";case pr.CreateNewInstance:return"Create new copy of entity";case Fe.AddIndex:return"Add item at index position";case Fe.DeleteFirst:return"Delete first item";case Fe.DeleteLast:return"Delete last item";case Fe.DeleteIndex:return"Delete item at index position";case Fe.Join:return"Join lists";case Fe.ReplaceFirst:return"Replace first match";case Fe.ReplaceLast:return"Replace last match";case Fe.Split:return"Split list";case Fe.ReplaceIndex:return"Replace at index position";case Fe.GetFirst:return"Get first item";case Fe.GetLast:return"Get last item";case Fe.GetIndexItem:return"Get item at index position";case Fe.Append:return"Add item at the end";case Fe.Prepend:return"Add item at the start";case Ea.PROJECT_PUBLICATION_COMPLETED:return"Project publication completed";default:return(d.name.slice(0,1).toUpperCase()+d.name.slice(1)).replaceAll("-"," ")}}function Y(d,u){var r;if(f.FunctionDeclaration===d.type){const a=d.name;if(Object.values(Wr).includes(a))switch(a){case Wr.AbortExecution:return"Abort ongoing execution";case Wr.DeletePersistedEntity:return"Delete entry from database";case Wr.CreatePersistedEntity:return"Save new data entry in database";case Wr.UpdatePersistedEntity:return"Update entity data to database";default:return Ii(d.type).replaceAll("-"," ")}return a}if(f.BuiltInBaseEntity===d.type)return MS([d.name]);if(Qg.includes(d.type)&&d.type!==f.ActionDescriptor)return d.name;switch(d.type){case f.Search:return US(d);case f.GlobalEvent:return d.implements?Y(d.implements,u):Ii(d.type).replaceAll("-"," ");case f.Operation:case f.InternalCall:case f.Loop:const a=qi(d.declaration,u);return Y(a,u);case f.ActionDescriptor:return jS(d);case f.BreakStatement:const o=qi(d.parent,u);return`Stop loop ${Y(o,u)}`;case f.ContinueStatement:const p=qi(d.parent,u);return`Execute next iteration of ${Y(p,u)}`;case f.FunctionCall:return qi(d.declaration,u).name;case f.Condition:{const y=d;if(y.declaration.id===Kr.And)return"If all conditions are met";if(y.declaration.id===Kr.Or)return"If any condition is met";if((r=d.inputs)!=null&&r.length){const v=Y(y.inputs[0],y.project);if(y.inputs[1]){const E=y.inputs[1].declaration.name;return`If ${v} ${Mm(y)} ${E}`}return`If ${v} ${Mm(y)}`}else return`If ${Mm(y)}`}case f.ReturnStatement:{const y=qi(d.parent,u);return y?`Output of ${Y(y,u)}`:"Return statement"}case f.InputMap:if(d.declaration){const y=qi(d.declaration,u);return Y(y,u)||""}else{if(!d.name)throw new Error(`Input map entity with id "${d.id}" has no name and no declaration.`);return d.name||""}case f.VariableInstance:{const y=qi(d.declaration,u);return Y(y,u)||""}case f.OutputMap:if(d.declaration){const y=qi(d.declaration,u);return(y==null?void 0:y.name)||""}else return d.parentRelationType===Fa.Error?"Undeclared error":"";case f.PrimitiveEntity:case f.LiteralValue:return xS(d);default:return Ii(d.type).replaceAll("-"," ")}}function wb(d,u){const r=[];d.name||r.push(new ae({id:`${d.id}--${se.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:H.Error,code:se.EmptyName}));const a=u.entities.filter(o=>o.name===d.name);return a.length&&r.push(new ae({id:`${d.id}--${se.NameNotUniqueInScope}`,message:`Entity with id "${d.id}" and type "${d.type}" has a name "${d.name}" that is not unique in the project. Entity with id "${a[0].id}" has the same name.
396
+ You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`})),{errors:a,modifiedData:r}}subscribeDependents(r){return r.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(r){return r.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],o=[],p=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(r);a.push(...v.updated),o.push(...v.added),p.push(...v.removed),e.push(...v.affected)}),r==null||r.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}onDetachedDependencyRemoved(r,a,o){const p=[],e=[],y=[],v=[];if(a==="declaration"){const{updated:E,added:w,removed:A}=this.remove({ignoreUpstream:!1},o);p.push(...E),e.push(...w),y.push(...A)}if(a==="parent"){const{updated:E,added:w,removed:A}=this.remove({ignoreUpstream:!1},o);p.push(...E),e.push(...w),y.push(...A)}return{updated:R(p),added:R(e),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(r,a,o){const p=[],e=[],y=[],v=[];if(a==="declaration"){const{updated:E,added:w,removed:A}=this.restore({},o);p.push(...E),e.push(...w),y.push(...A)}if(a==="parent"){const{updated:E,added:w,removed:A}=this.restore({},o);p.push(...E),e.push(...w),y.push(...A)}return{updated:R(p),added:R(e),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){var r;return(r=this.parent)==null||r.unsubscribeDependents([{entity:this,field:"parent"}]),this.declaration.unsubscribeDependents([{entity:this,field:"declaration"}]),this}subscribeToDependencies(){var r;return(r=this.parent)==null||r.subscribeDependents([{entity:this,field:"parent"}]),this.declaration.subscribeDependents([{entity:this,field:"declaration"}]),this}increaseVersion(r){if(r&&!L(r).isValid())throw new Error(`The shared timestamp '${r}' is not a valid ISO 8601 date string.`);return r&&L(r).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=N.UUID.uuid(),this.createdAt=L(r).toISOString()||L().toISOString(),this)}captureVersion(){var a;const r=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Qt(this,this.project);return r.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,r):new Map([[this.version,r]]),r.inputs=[...this.inputs],r.outputs=[...this.outputs],r.error=this.error,r.successCalls=[...this.successCalls],r.errorCalls=[...this.errorCalls],r.process=this.process,r.declaration=this.declaration,r.calledBySuccess=[...this.calledBySuccess],r.calledByError=[...this.calledByError],r.calledByEntry=[...this.calledByEntry],r.parent=this.parent,this}recursiveCaptureUpstreamVersions(r){const a=[],o=[],p=[],e=[];if(this.parent){this.parent.increaseVersion(r);const y=this.parent.recursiveCaptureUpstreamVersions(r);a.push(this.parent,...y.updated),o.push(...y.added),p.push(...y.removed)}return{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}async restoreVersion(r){var v;const a=[],o=[],p=[],e=[];if(this.version===r)return{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this};if(!this.knownVersions){const E=new Map;for(const[w,A]of this.knownVersions||new Map){if(E.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[$,V]of A.knownVersions)E.set($,V);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(r);if(!y){const E=await this.APILoadVersion({},r);if(!E)throw new Error(`Version with id '${r}' for entity with id '${this.id}' not found.`);y=new Qt(E,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.error=y.error,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.process=y.process,this.declaration=y.declaration,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.parent=y.parent,{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}updateWithShallowTransfer(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(r,a),this.version=r.version,this.createdAt=r.createdAt,this.author=r.author,this.deleted=r.deleted,this.previousVersion=r.previousVersion,this.unsubscribeFromDependencies(),r.parent){const o=J(r.parent),p=this.project.get(o),e=this.parent;if(e&&e.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,a);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${o}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(r.declaration){const o=J(r.declaration),p=this.project.get(o);p&&this.setDeclaration(p)}return r.calledByEntry.forEach(o=>{const p=J(o),e=this.project.get(p);e&&(this.addEntryCaller(e,a),e.addCall(this,a))}),[...this.calledByEntry].forEach(o=>{r.calledByEntry.find(e=>J(e)===o.id)||(this.removeCaller(o,a),o.removeCall(this,a))}),r.calledBySuccess.forEach(o=>{const p=J(o),e=this.project.get(p);e&&(this.addSuccessCaller(e,a),e.addSuccessCall(this,a))}),[...this.calledBySuccess].forEach(o=>{r.calledBySuccess.find(e=>J(e)===o.id)||(this.removeCaller(o,a),o.removeCall(this,a))}),r.calledByError.forEach(o=>{const p=J(o),e=this.project.get(p);e&&(this.addErrorCaller(e,a),e.addErrorCall(this,a))}),[...this.calledBySuccess].forEach(o=>{r.calledBySuccess.find(e=>J(e)===o.id)||(this.removeCaller(o,a),o.removeCall(this,a))}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const r=[],a=[],o=[],p=[];if(this.initialData.parent){const e=J(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),r.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.declaration){const e=J(this.initialData.declaration),y=this.project.get(e);y&&(this.setDeclaration(y),r.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=J(e),v=this.project.get(y);v&&this.addEntryCaller(v,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=J(e),v=this.project.get(y);v&&this.addSuccessCaller(v,null)}),this.initialData.calledByError.forEach(e=>{const y=J(e),v=this.project.get(y);v&&this.addErrorCaller(v,null)}),{updated:R(r),added:R(a),removed:R(o),affected:R(p),self:this}}afterAllChildrenInitialized(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],o=[],p=[],e=[];this.initialized=!0;const{updated:y,added:v,removed:E}=this.syncInputs(r),{updated:w,added:A,removed:$}=this.syncOutputs(r);return a.push(...y,...w),o.push(...v,...A),p.push(...E,...$),this.captureVersion(),r==null||r.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}addSelfToProject(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){var y;const a=[this],o=[],p=[],e=[];return this.parent===this.project&&this.project.addFunctionCall(this),(y=this.process)==null||y.writesValues.forEach(v=>{v.setValueWriter(this.process,r),a.push(v)}),this.successCalls.forEach(v=>{v.addSuccessCaller(this,r),a.push(v)}),this.errorCalls.forEach(v=>{v.addErrorCaller(this,r),a.push(v)}),this.calledBySuccess.forEach(v=>{v.addSuccessCall(this,r),a.push(v)}),this.calledByError.forEach(v=>{v.addErrorCall(this,r),a.push(v)}),this.calledByEntry.forEach(v=>{v.addCall(this,r),a.push(v)}),this.subscribe(),this.subscribeToDependencies(),r==null||r.attemptAutoclose("add-self-to-project",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-input"))){const o=this.inputs.findIndex(p=>p.id===r.id);return o>-1&&(this.inputs.splice(o,1),a&&(a==null||a.add(this,S.Affected))),a==null||a.attemptAutoclose("remove-input",this.id),this}addInput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-input"))){return this.inputs.includes(r)?(a==null||a.attemptAutoclose("add-input",this.id),this):(this.inputs.push(r),a==null||a.add(this,S.Affected),a==null||a.attemptAutoclose("add-input",this.id),this)}addOutput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-output"))){return this.outputs.includes(r)?(a==null||a.attemptAutoclose("add-output",this.id),this):(this.outputs.push(r),a==null||a.add(this,S.Affected),a==null||a.attemptAutoclose("add-output",this.id),this)}removeOutput(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-output"))){const o=this.outputs.findIndex(p=>p.id===r.id);return o>-1&&(this.outputs.splice(o,1),a&&(a==null||a.add(this,S.Affected))),a==null||a.attemptAutoclose("remove-output",this.id),this}addValueReader(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-value-reader"))){var o;return this.process&&!this.process.writesValues.includes(r)&&((o=this.process)==null||o.addValueReader(r,a),a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("add-value-reader",this.id),this}removeValueReader(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-value-reader"))){var o;return this.process&&this.process.writesValues.includes(r)&&((o=this.process)==null||o.removeValueReader(r,a),a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("remove-value-reader",this.id),this}addSuccessCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-success-caller")),o=!1){return this.calledBySuccess.find(p=>p.id===r.id)||(this.calledBySuccess.push(r),a==null||a.add(this,S.Updated),o&&He(this,a)),a==null||a.attemptAutoclose("add-success-caller",this.id),this}addErrorCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-error-caller")),o=!1){return this.calledByError.find(p=>p.id===r.id)||(this.calledByError.push(r),a==null||a.add(this,S.Updated),o&&He(this,a)),a==null||a.attemptAutoclose("add-error-caller",this.id),this}addEntryCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-entry-caller")),o=!1){return this.calledByEntry.find(p=>p.id===r.id)||(this.calledByEntry.push(r),a==null||a.add(this,S.Updated),o&&He(this,a)),a==null||a.attemptAutoclose("add-entry-caller",this.id),this}addErrorCall(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-error-call")),o=!1){return this.errorCalls.find(p=>p.id===r.id)||(this.errorCalls.push(r),o&&He(this,a),a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("add-error-call",this.id),this}addSuccessCall(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"add-success-call")),o=!1){return this.successCalls.find(p=>p.id===r.id)||(this.successCalls.push(r),o&&He(this,a),a==null||a.add(this,S.Affected)),a==null||a.attemptAutoclose("add-success-call",this.id),this}removeCall(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-call")),o=!1){const p=this.successCalls.findIndex(y=>y.id===r.id);p>-1&&(this.successCalls.splice(p,1),a==null||a.add(this,S.Affected));const e=this.errorCalls.findIndex(y=>y.id===r.id);return e>-1&&(this.errorCalls.splice(e,1),a==null||a.add(this,S.Affected)),o&&He(this,a),a==null||a.attemptAutoclose("remove-call",this.id),this}removeCaller(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-caller")),o=!1){return this.calledBySuccess=this.calledBySuccess.filter(p=>p.id!==r.id?!0:(a==null||a.add(this,S.Updated),a==null||a.add(p,S.Affected),!1)),this.calledByError=this.calledByError.filter(p=>p.id!==r.id?!0:(a==null||a.add(this,S.Updated),a==null||a.add(p,S.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(p=>p.id!==r.id?!0:(a==null||a.add(this,S.Updated),a==null||a.add(p,S.Affected),!1)),o&&He(this,a),a==null||a.attemptAutoclose("remove-caller",this.id),this}setParent(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var o;return((o=this.parent)==null?void 0:o.id)!==(r==null?void 0:r.id)&&(this.parent=r,a&&(a==null||a.add(this,S.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}setDeclaration(r){return this.declaration=r,this}initChildren(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.declaration.type===f.FunctionDeclaration){const a=ne(this.initialData.declaration,this.project);this.declaration=a}else{const a=J(this.initialData.declaration),o=this.project.get(a);this.declaration=o}return this.successCalls=this.initialData.successCalls.map(a=>{const o=ne(a,this.project);if(o.addSuccessCaller(this),[f.BreakStatement,f.ContinueStatement].includes(o.type))o.setParent(this.parent.parent,null),o.initChildren(r);else if(o.type===f.ReturnStatement){const p=Hr(this,this.project);o.setParent(p,null),o.initChildren(r)}else o.type!==f.InternalCall&&(o.setParent(this.parent,null),o.initChildren(r));return o}),this.errorCalls=this.initialData.errorCalls.map(a=>{const o=ne(a,this.project);if(o.addErrorCaller(this),[f.BreakStatement,f.ContinueStatement].includes(o.type))o.setParent(this.parent.parent,null),o.initChildren(r);else if(o.type===f.ReturnStatement){const p=Hr(this,this.project);o.setParent(p,null),o.initChildren(r)}else o.type!==f.InternalCall&&(o.setParent(this.parent,null),o.initChildren(r));return o}),this.inputs=this.initialData.inputs.map(a=>{const o=ne(a,this.project);return o.setParent(this,null),o.initChildren(r),o}),this.initialData.process&&(this.process=ne(this.initialData.process,this.project),this.process.setParent(this,null),this.process.initChildren(r)),this.initialData.error&&(this.error=ne(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(r)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(r),r==null||r.attemptAutoclose("init-children",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(r,a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const o=Lr(this,r),p=this.toMeta();return this.x=r.x||p.x,this.y=r.y||p.y,this.catchesError=r.catchesError!==void 0?r.catchesError:this.catchesError,super.metaSync(r),r.deleted===!0&&!p.deleted?a==null||a.add(this,S.Removed):r.deleted===!1&&p.deleted?a==null||a.add(this,S.Added):o&&(a==null||a.add(this,S.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(r=ve,...a){return await Qt.repository.APILoad(this.id,...a),this}async APICreate(r=ve,...a){return await Qt.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(r=ve,...a){return await Qt.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(r=ve,...a){return await Qt.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(r=ve,...a){return await Qt.repository.APIClone(this.id,...a),this}async APILoadVersion(r=ve,a,...o){return await Qt.repository.APILoadVersion(this.id,a,...o)}removeFromParent(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){const a=[],o=[],p=[],e=[];return this.parent.type===f.Project?(this.parent.removeFunctionCall(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),r==null||r.attemptAutoclose("remove-from-parent",this.id),{added:R(p),updated:R(a),removed:R(o),affected:R(e),self:this}}remove({ignoreUpstream:r}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){var v;const o=[],p=[],e=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(E=>{const{updated:w,removed:A,added:$}=E.entity.onDetachedDependencyRemoved(this,E.field,a);o.push(...w),p.push(...A),e.push(...$)}),this.process){const{updated:E,removed:w}=(v=this.process)==null?void 0:v.remove({ignoreUpstream:!0},a);o.push(...E),p.push(...w)}if(this.inputs.forEach(E=>{const{updated:w,removed:A}=E.remove({ignoreUpstream:!0},a);o.push(...w),p.push(...A)}),this.outputs.forEach(E=>{const{updated:w,removed:A}=E.remove({ignoreUpstream:!0},a);o.push(...w),p.push(...A)}),this.error){const{updated:E,removed:w}=this.error.remove({ignoreUpstream:!0},a);o.push(...E),p.push(...w)}if(this.successCalls.forEach(E=>{o.push(E),E.removeCaller(this,a)}),this.errorCalls.forEach(E=>{o.push(E),E.removeCaller(this,a)}),!r){const E=this.removeFromParent(a);e.push(...E.added),o.push(...E.updated),p.push(...E.removed),y.push(...E.affected),this.calledBy.forEach(w=>{o.push(w),w.removeCall(this,a)})}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:R(e),updated:R(o),removed:R(p),affected:R(y),self:this}}restore({}={},r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){const a=[],o=[],p=[],e=[];if(r!=null&&r.hasAdded(this.id))return r==null||r.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},r),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:E,added:w}=y.entity.onDetachedDependencyRestored(this,y.field,r);o.push(...v),p.push(...E),a.push(...w)}),this.process){const{updated:y}=this.process.restore({},r);o.push(...y)}return this.inputs.forEach(y=>{const{updated:v}=y.restore({},r);o.push(...v)}),this.outputs.forEach(y=>{const{updated:v}=y.restore({},r);o.push(...v)}),this.successCalls.forEach(y=>{o.push(y),y.addSuccessCaller(this,r)}),this.errorCalls.forEach(y=>{o.push(y),y.addErrorCaller(this,r)}),this.calledBySuccess.forEach(y=>{o.push(y),y.addSuccessCall(this,r)}),this.calledByError.forEach(y=>{o.push(y),y.addErrorCall(this,r)}),this.calledByEntry.forEach(y=>{o.push(y),y.addCall(this,r)}),r==null||r.attemptAutoclose("restore-entity",this.id),{added:R(a),updated:R(o),removed:R(p),affected:R(e),self:this}}toFlat(r=new Set){return r.has(this.id)?[]:(r.add(this.id),[this,...this.successCalls.flatMap(o=>o.toFlat(r)),...this.errorCalls.flatMap(o=>o.toFlat(r)),...this.inputs.flatMap(o=>o.toFlat(r)),...this.outputs.flatMap(o=>o.toFlat(r)),...this.process?this.process.toFlat(r):[],...this.error?this.error.toFlat(r):[],...this.calledBy.flatMap(o=>o.toFlat(r))])}toFlatIds(r=new Set){return r.has(this.id)?[]:(r.add(this.id),[this.id,...this.successCalls.flatMap(o=>o.toFlatIds(r)),...this.errorCalls.flatMap(o=>o.toFlatIds(r)),...this.inputs.flatMap(o=>o.toFlatIds(r)),...this.outputs.flatMap(o=>o.toFlatIds(r))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,catchesError:this.catchesError}}toJSON(r=new Set){var a,o;return r.has(this.id)?this.toReference():(r.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,catchesError:this.catchesError,x:this.x,y:this.y,successCalls:this.successCalls.map(p=>p.toJSON(r)),errorCalls:this.errorCalls.map(p=>p.toJSON(r)),calledBySuccess:this.calledBySuccess.map(p=>p.toReference()),calledByError:this.calledByError.map(p=>p.toReference()),calledByEntry:this.calledByEntry.map(p=>p.toReference()),process:(a=this.process)==null?void 0:a.toJSON(r),declaration:this.declaration.toJSON(r),inputs:this.inputs.map(p=>p.toJSON(r)),outputs:this.outputs.map(p=>p.toJSON(r)),parent:this.parent.toReference(),error:(o=this.error)==null?void 0:o.toJSON(r)})}toJSONClone(r=Se){var o,p,e,y,v,E,w;let a;return(o=r.seenEntityMaps)!=null&&o.has(this.id)?a=r.seenEntityMaps.get(this.id):(a=r.newId||jr(this,this.project,r.uuidStrategy),r.seenEntityMaps&&r.seenEntityMaps.set(this.id,a)),(p=r.seenEntities)!=null&&p.has(a)||(e=r.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:r.seenEntityMaps}):((y=r.seenEntities)==null||y.add(a),(v=r.seenEntities)==null||v.add(this.id),{id:a,version:N.UUID.uuid(),createdAt:r.timestamp||L().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(A=>A.toJSONClone({...r,newId:null})),errorCalls:this.errorCalls.map(A=>A.toJSONClone({...r,newId:null})),calledBySuccess:this.calledBySuccess.map(A=>A.toReference({seenEntityMaps:r.seenEntityMaps})),calledByError:this.calledByError.map(A=>A.toReference({seenEntityMaps:r.seenEntityMaps})),calledByEntry:this.calledByEntry.map(A=>A.toReference({seenEntityMaps:r.seenEntityMaps})),process:(E=this.process)==null?void 0:E.toJSONClone({...r,newId:null}),declaration:this.declaration.toJSONClone({...r,newId:null}),inputs:this.inputs.map(A=>A.toJSONClone({...r,newId:null})),outputs:this.outputs.map(A=>A.toJSONClone({...r,newId:null})),error:(w=this.error)==null?void 0:w.toJSONClone({...r,newId:null}),parent:this.parent.toReference({seenEntityMaps:r.seenEntityMaps})})}toReference(r=Se){var o;let a=this.id;return(o=r.seenEntityMaps)!=null&&o.has(this.id)&&(a=r.seenEntityMaps.get(this.id)),{id:a+"--"+N.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(r=Se){var o;let a=this.id;return(o=r.seenEntityMaps)!=null&&o.has(this.id)&&(a=r.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,catchesError:this.catchesError,x:this.x,y:this.y,process:this.process?this.process.toReference(r):null,inputs:this.inputs.map(p=>p.toReference(r)),outputs:this.outputs.map(p=>p.toReference(r)),declaration:this.declaration.toReference(r),successCalls:this.successCalls.map(p=>p.toReference(r)),errorCalls:this.errorCalls.map(p=>p.toReference(r)),calledBySuccess:this.calledBySuccess.map(p=>p.toReference(r)),calledByError:this.calledByError.map(p=>p.toReference(r)),calledByEntry:this.calledByEntry.map(p=>p.toReference(r)),error:this.error?this.error.toReference(r):null,parent:this.parent.toReference(r)}}toFlatJSON(r=new Set){return r.has(this.id)?[]:(r.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(o=>o.toFlatJSON(r)),...this.errorCalls.flatMap(o=>o.toFlatJSON(r)),...this.inputs.flatMap(o=>o.toFlatJSON(r)),...this.outputs.flatMap(o=>o.toFlatJSON(r)),...this.process?this.process.toFlatJSON(r):[],...this.error?this.error.toFlatJSON(r):[]])}toGenerationTarget(){const r=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,calledByEntry:this.calledByEntry.map(a=>a.id),calledBySuccess:this.calledBySuccess.map(a=>a.id),calledByError:this.calledByError.map(a=>a.id),declaration:this.declaration.id,parent:r}}toFlatGenerationTarget(r=new Set){return r.has(this.id)?[]:(r.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(o=>o.toFlatGenerationTarget(r)),...this.errorCalls.flatMap(o=>o.toFlatGenerationTarget(r)),...this.inputs.flatMap(o=>o.toFlatGenerationTarget(r)),...this.outputs.flatMap(o=>o.toFlatGenerationTarget(r)),...this.process?this.process.toFlatGenerationTarget(r):[],...this.error?this.error.toFlatGenerationTarget(r):[]])}clearErrors(){var r,a;return this.errors=[],this.inputs.forEach(o=>o.clearErrors()),this.outputs.forEach(o=>o.clearErrors()),this.successCalls.forEach(o=>o.clearErrors()),this.errorCalls.forEach(o=>o.clearErrors()),(r=this.process)==null||r.clearErrors(),(a=this.error)==null||a.clearErrors(),this}validate(){const r=T5(this);return this.errors=r,{success:!0}}getErrors(){return[...this.errors,...this.inputs.flatMap(a=>a.getErrors()),...this.outputs.flatMap(a=>a.getErrors()),...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,o=null,p=!0){var B,F;let e=Ur(a,this);const y=this.toJSON(),v=o||N.UUID.uuid();y.inputs=[];const E=v.split("-id"),w=E[E.length-1||0]||v;y.id=v,y.version=N.UUID.uuid(),y.createdAt=(r==null?void 0:r.timestamp)||L().toISOString(),y.author=(r==null?void 0:r.author)||"1",y.previousVersion=null,y.deleted=!1;const A=dr(y,e);a?A.setParent(a,null):A.setParent(this.parent,null),p&&A.subscribe(),A.initChildren(r),r==null||r.add(A,S.Added);const $=(B=this.inputs)==null?void 0:B.map((K,q)=>K.clone(r,A,w+"-input-map-"+q+"-id",p));A.inputs=$;const V=(F=this.outputs)==null?void 0:F.map((K,q)=>K.clone(r,A,w+"-output-map-"+q+"-id",p));return A.outputs=V,this.error&&(A.error=this.error.clone(r,A,w+"-error-map-id",p)),this.process&&(A.process=this.process.clone(r,A,w+"-process-id",p)),r==null||r.attemptAutoclose("clone-entity",this.id),A}removeUnrecognizedInputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-inputs"))){const a=[],o=[],p=[],e=[];return this.inputs.forEach(v=>{if(!this.declaration.inputs.find(w=>{var A;return w.id===((A=v.declaration)==null?void 0:A.id)})){const w=v.remove({ignoreUpstream:!1},r);p.push(...w.removed),a.push(...w.updated)}}),this.inputs.filter((v,E)=>{const w=this.inputs.findIndex($=>$.declaration===v.declaration&&$!==v);if(w===-1)return!1;const A=this.inputs[w];return L(A==null?void 0:A.createdAt).isSame(L(v.createdAt))?E>w:!!L(A==null?void 0:A.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},r);p.push(...E.removed),a.push(...E.updated)}),r==null||r.attemptAutoclose("remove-unrecognized-inputs",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}removeUnrecognizedOutputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-outputs"))){const a=[],o=[],p=[],e=[];return this.outputs.forEach(v=>{if(!this.declaration.getUniqueReturnDeclarations().find(w=>{var A;return w.id===((A=v.declaration)==null?void 0:A.id)})){const w=v.remove({ignoreUpstream:!1},r);p.push(...w.removed),a.push(...w.updated)}}),this.outputs.filter((v,E)=>{const w=this.outputs.findIndex($=>$.declaration===v.declaration&&$!==v);if(w===-1)return!1;const A=this.outputs[w];return L(A==null?void 0:A.createdAt).isSame(L(v.createdAt))?E>w:!!L(A==null?void 0:A.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},r);p.push(...E.removed),a.push(...E.updated)}),r==null||r.attemptAutoclose("remove-unrecognized-outputs",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}syncInputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"sync-missing-fixed-inputs"))){const a=[],o=[],p=[],e=[],y=this.declaration.inputs.filter(A=>!this.inputs.find($=>$.declaration.id===A.id));this.inputs.sort((A,$)=>A.index-$.index),y.forEach(A=>{this.inputs.forEach(B=>{B.index>=A.index&&B.metaSync({index:B.index+1},r)});const $={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||L().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.InputMap,declaration:A.toJSON(),readsValue:null,defaultValue:null,index:A.index,name:null,codeName:null,description:null,parent:this.toReference()},V=ne($,this.project);V.setParent(this,r),V.initChildren(r),r==null||r.add(V,S.Added),V.addSelfToProject(r),o.push(V)}),this.inputs.sort((A,$)=>A.index-$.index);const{updated:v,added:E,removed:w}=this.removeUnrecognizedInputs(r);return a.push(...v),o.push(...E),p.push(...w),r==null||r.attemptAutoclose("sync-missing-fixed-inputs",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}syncOutputs(r=this.project.addChangeSet(new G(this.project,N.sessionAuthor,L().toISOString(),this,!0,"sync-missing-fixed-outputs"))){const a=[],o=[],p=[],e=[],y=[];this.outputs=this.initialData.outputs.reduce(($,V)=>{if(V.type===f.GenericReference){const F=qi(V,this.project);return F?[...$,F]:$}const B=ne(V,this.project);return y.push(B.index),B.setParent(this,null),B.initChildren(r),[...$,B]},[]);const v=this.declaration.getUniqueReturnDeclarations().filter($=>!this.outputs.find(V=>{var B;return((B=V.declaration)==null?void 0:B.id)===$.id}));this.outputs.sort(($,V)=>$.index-V.index),v.forEach(($,V)=>{this.outputs.forEach(q=>{q.index>=$.index&&q.index++});const B=y.includes($.index)?this.outputs.length-1+V:$.index,F={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||L().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.OutputMap,declaration:$.toJSON(),defaultValue:null,writesValues:[],index:B,parent:this.toReference()},K=ne(F,this.project);K.setParent(this,r),K.initChildren(r),r==null||r.add(K,S.Added),K.addSelfToProject(r)}),this.outputs.sort(($,V)=>$.index-V.index);const{updated:E,added:w,removed:A}=this.removeUnrecognizedOutputs(r);return a.push(...E),o.push(...w),p.push(...A),r==null||r.attemptAutoclose("sync-missing-fixed-outputs",this.id),{updated:R(a),added:R(o),removed:R(p),affected:R(e),self:this}}getUnusedInputs(){return this.inputs.filter(r=>r.suggestion||!r.readsValue&&!r.defaultValue)}getUnusedOutputs(){return this.outputs.filter(r=>r.suggestion||!r.writesValues.length)}getUsedInputs(){return this.inputs.filter(r=>!r.suggestion&&(r.readsValue||r.defaultValue))}getUsedOutputs(){return this.outputs.filter(r=>!r.suggestion&&r.writesValues.length)}};_(Qt,"repository",{APICreate:async(r,...a)=>r,APIUpdate:async(r,...a)=>r,APIDelete:async(r,...a)=>r,APIClone:async(r,...a)=>{},APILoad:async(r,...a)=>null,APILoadVersion:async(r,a,...o)=>null}),_(Qt,"type",f.FunctionCall),_(Qt,"USER_MANAGED_PARENT_TYPES",[...Nr,f.Project]),_(Qt,"PARENT_TYPES",[...Qt.USER_MANAGED_PARENT_TYPES]),_(Qt,"MUTABLE_BASE_PROPERTIES",["catchesError"]),_(Qt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),_(Qt,"BASE_PROPERTIES",[...Qt.MUTABLE_BASE_PROPERTIES,...Qt.INMUTABLE_BASE_PROPERTIES]),_(Qt,"MUTABLE_META_PROPERTIES",["x","y"]),_(Qt,"INMUTABLE_META_PROPERTIES",[...Qt.INMUTABLE_BASE_PROPERTIES]),_(Qt,"META_PROPERTIES",[...Qt.MUTABLE_META_PROPERTIES,...Qt.INMUTABLE_META_PROPERTIES]),_(Qt,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),_(Qt,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),_(Qt,"UPSTREAM_PROPERTIES",[...Qt.MUTABLE_UPSTREAM_PROPERTIES,...Qt.INMUTABLE_UPSTREAM_PROPERTIES]),_(Qt,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","writesValues","inputs","outputs","error"]),_(Qt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),_(Qt,"DOWNSTREAM_PROPERTIES",[...Qt.MUTABLE_DOWNSTREAM_PROPERTIES,...Qt.INMUTABLE_DOWNSTREAM_PROPERTIES]),_(Qt,"PROPERTIES",[...Qt.META_PROPERTIES,...Qt.UPSTREAM_PROPERTIES,...Qt.DOWNSTREAM_PROPERTIES]);let To=Qt;function nb(d){return d&&typeof d.then=="function"}function tIe(d){const u=new zn(d[0]),r=d.map(o=>o.id),a={};return d.forEach(o=>{a[o.id]=o}),u.order=r,u.flatRecord=a,u.orderEntities(),u.order.map(o=>u.flatRecord[o])}function rIe(d){const u=new zn(Object.values(d)[0]),r=Object.keys(d);return u.order=r,u.flatRecord=d,u.orderEntities(),u.order}class zn{constructor(u){_(this,"order",[]);_(this,"flatRecord",{});_(this,"allBuiltInEntityIds",zs());_(this,"onGoingVisits",{});u&&(this.flatten(u),this.orderEntities())}flatten(u){const r=new Set(zs()),a=R(me(u,r,{ignoreBuiltInBaseEntities:!0})),o=new Set;for(const p of a)this.flatRecord[p.id]=p,o.add(p.id);this.order=Array.from(o)}moveEntityAfterDependencies(u){const{upstream:r}=kd(u,this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});for(const a of Object.keys(r)){const o=this.order.indexOf(a),p=this.order.indexOf(u.id);if(o>p)return this.order.splice(p,1),this.order.splice(o,0,u.id),!0}return!1}orderEntities(){let u=!1;for(let r=0;r<this.order.length;r++){const a=this.order[r],o=this.flatRecord[a];if(o||Me.warn(`Entity with id ${a} not found in flatRecord. Skipping...`),this.moveEntityAfterDependencies(o)){u=!0;break}}u&&this.orderEntities()}getUpstreamOngoingDependenciesVisits(u,r){const{upstream:a}=kd(this.flatRecord[u],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds}),o={};return Object.entries(this.onGoingVisits[r]||{}).forEach(([p,e])=>{Object.keys(a).includes(p)&&(o[p]=e)}),o}getDownstreamOngoingDependenciesVisits(u,r){const a=Object.keys(this.onGoingVisits[r]||{}),o=new Set(a.flatMap(e=>Object.keys(kd(this.flatRecord[e],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds}).downstream))),p={};return Array.from(o).forEach(e=>{e===u&&(p[e]=this.onGoingVisits[r][e])}),p}async settlePromises(u,r){const a=Object.values(u);a.length&&await Promise.all(a),Object.keys(u).forEach(o=>{delete this.onGoingVisits[r][o]})}visit(u){const r=this.order;for(const a of r)u(this.flatRecord[a],this.flatRecord);return this}reverseVisit(u){const r=this.order.slice().reverse();for(const a of r)u(this.flatRecord[a],this.flatRecord);return this}async visitAsync(u){const r=this.order,a=Math.random().toString(36).substring(7);this.onGoingVisits[a]={};for(const o of r){const p=this.getUpstreamOngoingDependenciesVisits(o,a);Object.keys(p).length&&await this.settlePromises(p,a);const e=u(this.flatRecord[o],this.flatRecord);nb(e)&&(this.onGoingVisits[a][o]=e)}return await this.settlePromises(this.onGoingVisits[a],a),this.onGoingVisits[a]={},this}async reverseVisitAsync(u){const r=this.order.slice().reverse(),a=Math.random().toString(36).substring(7);this.onGoingVisits[a]={};for(const o of r){const p=this.getDownstreamOngoingDependenciesVisits(o,a);Object.keys(p).length&&await this.settlePromises(p,a);const e=u(this.flatRecord[o],this.flatRecord);nb(e)&&(this.onGoingVisits[a][o]=e)}return await this.settlePromises(this.onGoingVisits[a],a),this.onGoingVisits[a]={},this}}function A5(d,u){switch(d.id){case he["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const r=d.project.entities.filter(v=>!!v.implements.find(E=>E.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),a=r.find(v=>{const E=v.properties.find($=>$.implements&&$.implements.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),w=E==null?void 0:E.getDefaultValue();return(w==null?void 0:w.value)===!0});if(!a&&r.length){const E=r[0].properties.find(A=>A.implements&&A.implements.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),w=E==null?void 0:E.defaultValue;if(w)w.metaSync({value:!0},u);else if(E!=null&&E.dataType){const A={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(u==null?void 0:u.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:E==null?void 0:E.toReference()},$=ne(A,d.project);return $.setParent(E,u),$.initChildren(u),u==null||u.add($,S.Added),$.addSelfToProject(u),{newEntities:[$]}}return{newEntities:[]}}else if(a)return{newEntities:[]};const o=d.project.get(he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),p=vm(o,"Main database",u);if(p.errors.length>0)return{newEntities:[]};const e=p.properties.find(v=>v.implements&&v.implements.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),y=e==null?void 0:e.defaultValue;if(y)y.metaSync({value:!0},u);else if(e!=null&&e.dataType){const v={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(u==null?void 0:u.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:e==null?void 0:e.toReference()},E=ne(v,d.project);E.setParent(e,u),E.initChildren(u),u==null||u.add(E,S.Added),E.addSelfToProject(u)}return{newEntities:[p]}}}return{newEntities:[]}}function b5(d,u){const r=[],a=[],o=[],p=[];return d.implements.filter(y=>y.type===f.BuiltInBaseEntity).forEach(y=>{var v;switch(y.id){case he["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const E=d.project.entities.filter(V=>V.implements.find(B=>B.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));let w=E.find(V=>!!V.properties.find(B=>{var F;return B.implements&&B.implements.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((F=B.getDefaultValue())==null?void 0:F.value)===!0}));if(!w&&E.length)w=E[0];else if(!w&&!E.length){w=d.project.getBuiltIn(he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id).implement("Relational database",u);const B=w.properties.find(F=>{var K;return((K=F.implements)==null?void 0:K.id)===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id});(v=B==null?void 0:B.defaultValue)==null||v.metaSync({value:!0},u),a.push(w)}const A=d.properties.find(V=>V.implements&&V.implements.id===he["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id),$=A==null?void 0:A.defaultValue;if(A&&!$){const V={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(u==null?void 0:u.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:null,valueAsTypeSingle:(w==null?void 0:w.toJSON())||null,valueAsTypeList:null,parent:A==null?void 0:A.toReference()},B=ne(V,d.project);B.hydrateAncestors(),B.setParent(A,u),B.addSelfToProject(u),B.initChildren(u),u==null||u.add(B,S.Added),a.push(B);return}else $&&!$.valueAsTypeSingle&&$.setValueAsTypeSingle(w||null,u);return}}}),{self:d,updated:R(r),added:R(a),removed:R(o),affected:R(p)}}function vm(d,u,r,a){const o=a||N.UUID.uuid(),p=N.UUID.uuid(),e={id:o,version:p,createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,name:u,type:f.DefinitionEntity,codeName:null,description:null,static:d.static,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:null,implements:[d.toJSON()],x:0,y:0,parent:d.project.toReference()};A5(d,r);const y=ne(e,d.project);return y.hydrateAncestors(),r==null||r.add(y,S.Added),y.addSelfToProject(r),y.addImplementation(d),y.setParent(d.project,r),y.initChildren(r),b5(y,r),y}function ab(d,u){return u.entities.find(o=>{const p=o.properties,e=p.map(A=>A.name),y=d.every(A=>e.includes(A)),v=e.filter(A=>!d.includes(A)),E=p.every(A=>!v.includes(A.name)||!A.required);return y&&E})||null}function w5(d,u,r,a=mi.OrDataTypeGroup){const o=[],p=[],e=[],y=[],E={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:d.toJSON(),isList:!1,asType:!1,andChildrenGroup:null,index:null,orChildrenGroup:null,staticEntities:null,interactiveEntities:null,actionEntities:null,like:!0,inferred:!1,parentRelationType:a,parent:u.toReference()},w=ne(E,d.project);return p.push(w),w.setParent(u,r),w.initChildren(r),r==null||r.add(w,S.Added),w.setEntity(d,r),w.addSelfToProject(r),{updated:R(o),added:R(p),removed:R(e),affected:R(y),self:w}}function ob(d,u,r,a,o){var E,w,A,$,V,B,F,K;const p=[],e=[],y=[],v=[];switch(typeof d){case"string":let q=!1;const ie=new Date(d);if(ie instanceof Date&&!isNaN(ie.valueOf())&&(q=!0),q){const W=u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Date].id);u.setEntity(W,a);break}else{const W=u.project.getBuiltIn(he[f.PrimitiveEntity][oe.String].id);u.setEntity(W,a);break}case"number":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Number].id),a);break;case"boolean":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Boolean].id),a);break;case"object":if(d===null){u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Null].id),a);break}else if(Array.isArray(d))if(u.metaSync({isList:!0},a),d.length>0){const W=d.slice(0,5).filter(Q=>Q!==void 0);if(W.every(Q=>typeof Q==typeof W[0])&&(typeof W[0]!="object"||W[0]===null))switch(typeof W[0]){case"string":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.String].id),a);break;case"number":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Number].id),a);break;case"boolean":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Boolean].id),a);break;case"object":u.setEntity(u.project.getBuiltIn(he[f.PrimitiveEntity][oe.Null].id),a);break}else{const Q=[];let ce=!1;W.forEach(z=>{var pe,te,ue,Ie;if(Array.isArray(z)&&(ce=!0),typeof z=="object"&&!Array.isArray(z)&&z!==null){const Ue=Em(z,u.project,{...r,id:N.UUID.uuid()},a,o);Ue.hasCreated&&Q.push((pe=Ue.changeSet)==null?void 0:pe.self),p.push(...(te=Ue.changeSet)==null?void 0:te.updated),e.push(...(ue=Ue.changeSet)==null?void 0:ue.added),y.push(...(Ie=Ue.changeSet)==null?void 0:Ie.removed)}});const X=R(Q);if(!X.length&&!ce){W.forEach(z=>{const pe={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:null,isList:!1,asType:!1,andChildrenGroup:null,index:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parentRelationType:mi.OrDataTypeGroup,parent:u.toReference()},te=ne(pe,u.project);switch(te.setParent(u,a),te.initChildren(a),a==null||a.add(te,S.Added),te.addSelfToProject(a),typeof z){case"string":te.setEntity(te.project.getBuiltIn(he[f.PrimitiveEntity][oe.String].id),a);break;case"number":te.setEntity(te.project.getBuiltIn(he[f.PrimitiveEntity][oe.Number].id),a);break;case"boolean":te.setEntity(te.project.getBuiltIn(he[f.PrimitiveEntity][oe.Boolean].id),a);break;case"object":te.setEntity(te.project.getBuiltIn(he[f.PrimitiveEntity][oe.Null].id),a);break}});break}else X.length===1&&!ce?u.setEntity(X[0],a):W.forEach(z=>{if(typeof z=="object"&&!Array.isArray(z)&&z!==null){const pe=ab(Object.keys(z),u.project);if(pe){const te=w5(pe||X[0],u,a,mi.OrDataTypeGroup);p.push(...te.updated),e.push(...te.added),y.push(...te.removed)}}else{const pe={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:null,isList:Array.isArray(z),asType:!1,andChildrenGroup:null,index:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parentRelationType:mi.OrDataTypeGroup,parent:u.toReference()},te=ne(pe,u.project);te.setParent(u,a),te.initChildren(a),a==null||a.add(te,S.Added),te.addSelfToProject(a);const ue=ob(z,te,{...r,id:N.UUID.uuid()},a,o);p.push(...ue.updated),e.push(...ue.added),y.push(...ue.removed)}})}}else{const W=Em(d[0],u.project,{...r},a,o);u.setEntity((E=W.changeSet)==null?void 0:E.self,a),p.push(...(w=W.changeSet)==null?void 0:w.updated),e.push(...(A=W.changeSet)==null?void 0:A.added),y.push(...($=W.changeSet)==null?void 0:$.removed);break}else{const W=Em(d,u.project,{...r},a,o);u.setEntity((V=W.changeSet)==null?void 0:V.self,a),p.push(...(B=W.changeSet)==null?void 0:B.updated),e.push(...(F=W.changeSet)==null?void 0:F.added),y.push(...(K=W.changeSet)==null?void 0:K.removed);break}}return{updated:R(p),added:R(e),removed:R(y),affected:R(v),self:u}}function Em(d,u,r,a,o){const p=[],e=[],y=[],v=[],E=Object.keys(d),w=ab(E,u);if(w)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],affected:[],self:w}};const A=o?r.name+" of "+o.name:r.name,V={id:r.id||N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,name:A,codeName:null,type:f.DefinitionEntity,description:r.description||null,static:r.static||!1,abstract:r.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:null,implements:[],x:0,y:0,parent:u.toReference()},B=ne(V,u);return B.setParent(u,a),B.initChildren(a),a==null||a.add(B,S.Added),B.addSelfToProject(a),e.push(B),E.forEach((F,K)=>{const ie={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,name:F,type:f.Property,codeName:F,description:null,static:!1,abstract:!1,defaultValue:null,constant:!1,interactive:!0,dataType:null,implements:null,extends:null,index:K,hidden:!1,private:!1,required:!0,parent:B.toReference()},W=ne(ie,u);W.setParent(B,a),W.initChildren(a),a==null||a.add(W,S.Added),W.addSelfToProject(a),e.push(W);const de=d[F],ce={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:null,implementationChooseOne:!1,entity:null,isList:!1,asType:!1,andChildrenGroup:null,index:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parent:W.toReference()},X=ne(ce,u);X.setParent(W,a),X.initChildren(a),a==null||a.add(X,S.Added),X.addSelfToProject(a),e.push(X);const z=ob(de,X,{...r,name:F,id:N.UUID.uuid()},a,o||B);p.push(...z.updated),e.push(...z.added),y.push(...z.removed)}),{hasCreated:!0,changeSet:{updated:R(p),added:R(e),removed:R(y),affected:R(v),self:B}}}function Va(d,u,r,a){const o=[];return!d.length||!u.length?{errors:o,overlap:!1}:(d.length>u.length?d.forEach(p=>{const e=u.find(v=>v.name===p.name),y=u.find(v=>{var E,w;return!!p.implements&&((E=v.implements)==null?void 0:E.id)===((w=p.implements)==null?void 0:w.id)});if(e){const v=new ir({id:p.id+"--"+e.id+"--"+a,message:`Entity of type ${p.type} named "${p.name}" with id "${p.id}" overrides a base ${e.type} ${e.name} with id "${e.id}" that has the same name`,severity:H.Error,code:a,entity:p,firstRelationship:e});o.push(v)}if(y){const v=new ir({id:p.id+"--"+y.id+"--"+r,message:`Entity of type ${p.type} named "${p.name}" with id "${p.id}" overrides a base ${y.type} ${y.name} with id "${y.id}" that implements the same base descriptor`,severity:H.Error,code:r,entity:p,firstRelationship:y});o.push(v)}}):u.forEach(p=>{var v;const e=d.find(E=>E.name===p.name),y=d.find(E=>{var w,A;return!!E.implements&&((w=E.implements)==null?void 0:w.id)===((A=p.implements)==null?void 0:A.id)});if(e){const E=new ir({id:e.id+"--"+p.id+"--"+a,message:`Entity of type ${e.type} named "${e.name}" with id "${e.id}" overrides a base entity ${p.name} with id "${p.id}" that has the same name`,severity:H.Error,code:a,entity:e,firstRelationship:p});o.push(E)}if(y){const E=new ir({id:y.id+"--"+p.id+"--"+r,message:`Entity of type ${y.type} named "${y.name}" with id "${y.id}" overrides a base entity ${p.name} with id "${p.id}" that implements the same base ${(v=y==null?void 0:y.implements)==null?void 0:v.type}`,severity:H.Error,code:r,entity:y,firstRelationship:p});o.push(E)}}),{errors:o,overlap:!!o.length})}function iIe(d,u){return d.abstract||(d.properties.forEach(a=>{a.abstract||a.metaSync({abstract:!0},u)}),Object.values(d.detachedDependents).forEach(a=>{a.field===gI.Entity&&a.entity.remove({ignoreUpstream:!1},u)}),d.metaSync({abstract:!0},u)),d}function sIe(d,u){return d.abstract&&(d.properties.forEach(a=>{a.abstract&&a.metaSync({abstract:!1},u)}),Object.values(d.detachedDependents).forEach(a=>{(a.field===Bm.Implements||a.field===Bm.Extends)&&a.entity.onDetachedDependencyRemoved(d,a.field,u)}),d.metaSync({abstract:!1},u)),d}function nIe(d,u){return d.static||(d.properties.forEach(a=>{a.static||a.metaSync({static:!0},u)}),d.metaSync({static:!0},u)),d}function aIe(d,u){return d.static&&d.metaSync({static:!1},u),d}var ki=(d=>(d.StringValueMustNotHaveSpaces="string-value-must-not-have-spaces",d.StringValueMustNotHaveDashes="string-value-must-not-have-dashes",d.MustBeUniqueAmongSameEntities="must-be-unique-among-same-entities",d))(ki||{});function lb(d,u){const r=[],a=u;if(!a)return{errors:r,override:u};if(typeof a!="string")return{errors:[],override:u};if(a.includes(" ")){const o=new ir({id:d.id+"--string-value-must-not-have-spaces",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value cannot contain spaces.`,severity:H.Error,code:"string-value-must-not-have-spaces",entity:d});r.push(o)}return{errors:r,override:a.replace(/\s/g,"-")}}function R5(d,u){const r=[],a=u;if(!a)return{errors:r,override:u};if(typeof a!="string")return{errors:[],override:u};if(a.includes(" ")){const o=new ir({id:d.id+"--string-value-must-not-have-spaces",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value cannot contain spaces or dashes.`,severity:H.Error,code:"string-value-must-not-have-spaces",entity:d});r.push(o)}if(a.includes("-")){const o=new ir({id:d.id+"--string-value-must-not-have-dashes",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value cannot contain spaces or dashes.`,severity:H.Error,code:"string-value-must-not-have-dashes",entity:d});r.push(o)}return{errors:r,override:a.replace(/\s|-/g,"_")}}function db(d,u){var r;if(d.type===f.LiteralValue){let a=(r=d.value)==null?void 0:r.toString();try{a=JSON.stringify(d.value,null,2)}catch{}return`${d.type}: ${d.id} (${Y(d,u)}) = ${a}`}if(d.type===f.DataType){if(d instanceof fs||d.increaseVersion)return`${d.type}: ${d.id} (${Yd(d)})`;try{const a=Yd(d);return`${d.type}: ${d.id} (${a})`}catch{}}return`${d.type}: ${d.id} (${Y(d,u)})`}function Fd(d,u){const r=Ao(d);if(r.length===0)return{list:[],last:null};let a=null;return{list:r.flatMap(p=>{if(p===u)return a=p,[p];const e=Fd(p,u);return e.last&&(a=e.last),[p,...e.list]}),last:a}}function Io(d,u){const r=d.calledBy;if(r.length===0)return{list:[],last:null,callType:null};let a=null,o=null;return{list:r.flatMap(e=>{if(e===u)return a=e,Dt.includes(e.type)?e.parent.type===f.Loop?o="loop-body":o="entry":e.successCalls.includes(d)?o="success":e.errorCalls.includes(d)&&(o="error"),[e];if(e.type===f.FunctionDeclaration&&e.parent.type===f.Loop&&e.parent===u)return a=e.parent,o="loop-body",[e];if(!xi.includes(e.type))return[e];const y=Io(e,u);return y.last&&(a=y.last,o=y.callType),[e,...y.list]}),last:a,callType:o}}function oIe(d,u){if(d===u)return"same-entity";if(!wi.includes(d.type)||!Yp(d).find(o=>o.callee===u))return null;if(Dt.includes(d.type)){if(d.calls.includes(u))return d.type===f.Loop?"loop-body":"entry"}else if(sr.includes(d.type)&&d.type!==f.InternalCall){if(d.successCalls.includes(u))return"success";if(d.errorCalls.includes(u))return"error"}return null}function Jp(d){const u=Di(d,d.project);return u?Dt.includes(u.type)?u:u.type===f.Loop?u.body:null:null}function g5(d,u){const r=d.calledBy;return!r||!r.length?!1:r.every(a=>a===u?!0:xi.includes(a.type)?!!Io(a,u).last:!1)}function _5(d){return d.filter(u=>{const r=Jp(u);return!d.filter(p=>p!==u).some(p=>p===r?!1:Im(p,u))})}function D5(d,u){if(!d)throw new Error("findNextSingleCallerAncestor: Target is not defined, cannot find ancestor.");let r=d;(d.type===f.VariableDeclaration||d.type===f.VariableInstance)&&!d.calledBy.length&&!d.successCalls.length&&!d.errorCalls.length&&d.internalCalls.some($=>!!$.calledBy.length)&&(r=d.internalCalls.find(V=>!!V.calledBy.length));const a=u||Di(r,d.project);if(!a)return{ancestor:null,callType:null};if(a.type===f.Project)return{ancestor:null,callType:null};const o=Yp(a);if(!o.find($=>$.callee===r))return{ancestor:null,callType:null};if(a.type===f.Loop){if(a.body.calls.includes(r))return{ancestor:a,callType:"loop-body"}}else if(Dt.includes(a.type)){if(a.calls.includes(r))return a.type===f.FunctionDeclaration&&a.parent.type===f.Loop?{ancestor:a,callType:"loop-body"}:{ancestor:a,callType:"entry"}}else if(sr.includes(a.type)){if(a.successCalls.includes(r))return{ancestor:a,callType:"success"};if(a.errorCalls.includes(r))return{ancestor:a,callType:"error"}}const e=o.filter($=>!($.callee===r||!wi.includes($.callee.type)||!dt($.callee).find(F=>F===r))).filter(($,V,B)=>B.findIndex(F=>F.callee===$.callee)===V);if(e.length===0)return{ancestor:null,callType:null};if(e.length===1){const $=e[0];if($.callee.type===f.Loop){if($.callee.body.calls.includes(r))return{ancestor:$.callee,callType:"loop-body"}}else{if(Dt.includes($.callee.type))return $.callee.type===f.FunctionDeclaration&&$.callee.parent.type===f.Loop?{ancestor:$.callee,callType:"loop-body"}:{ancestor:$.callee,callType:"entry"};if(sr.includes($.callee.type)){if($.callType==="success"&&$.callee.type===f.InternalCall)return{ancestor:$.callee,callType:"success"};if($.callType==="error"&&$.callee.type===f.InternalCall)return{ancestor:$.callee,callType:"error"}}}}const y=e.filter($=>g5(r,$.callee)),v=y.filter($=>{const V=dt($.callee),B=y.filter(K=>K.callee!==$.callee).map(K=>K.callee);return!V.some(K=>!!B.find(ie=>ie===K))});if(v.length===0){if(a.type===f.Loop){if(dt(a.body).find(ie=>ie===r))return{ancestor:a,callType:"loop-body"};if(ri(a.successCalls).find(ie=>ie===r))return{ancestor:a,callType:"success"};if(ri(a.errorCalls).find(ie=>ie===r))return{ancestor:a,callType:"error"}}else if(sr.includes(a.type)){if(ri(a.successCalls).find(K=>K===r))return{ancestor:a,callType:"success"};if(ri(a.errorCalls).find(K=>K===r))return{ancestor:a,callType:"error"}}return a.parent.type===f.Loop?{ancestor:a,callType:"loop-body"}:{ancestor:a,callType:"entry"}}if(v.length>1)throw new Error(`findNextSingleCallerAncestor: Could not be resolved, multiple candidates found: ${v.map($=>Y($.callee,r.project)).join(", ")}`);const E=v[0].callee,A=Yp(E).find($=>$.callee===r);return{ancestor:E,callType:A.callType}}function lIe(d){if(![f.VariableDeclaration,f.OutputMap].includes(d.type))throw new Error("getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders can only be used with a value writer entity");let u;if(d.type===f.VariableDeclaration?u=d:d.type===f.OutputMap&&(u=d.parent),!u)throw new Error("getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders can only be used with a value writer entity that has a caller");const r=R([d,...cb(d)]),a=R(r.map(y=>ub(y)).flatMap(y=>hr.includes(y==null?void 0:y.type)?y.calledBy:[y]));if(a.length===1){const y=a[0];if(Dt.includes(y.type))return y.parent.type===f.Loop?{ancestor:y,callType:"loop-body"}:{ancestor:y,callType:"entry"};if(u===y)return{ancestor:y,callType:"success"};if(y.successCalls.includes(u))return{ancestor:y,callType:"success"};if(y.errorCalls.includes(u))return{ancestor:y,callType:"error"};throw new Error(`getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders: Could not be resolved, single caller found, but it is not a valid caller: ${Y(y,u.project)}`)}const o=a.map(y=>{if(Dt.includes(y.type))return y.parent.type===f.Loop?{ancestor:y,callType:"loop-body"}:{ancestor:y,callType:"entry"};const v=D5(y);if(!v.ancestor)throw new Error(`getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders: Could not be resolved, no ancestor found for ${Y(y,u.project)}`);return v}).filter((y,v,E)=>v===E.findIndex(w=>{var A,$;return((A=w.ancestor)==null?void 0:A.id)===(($=y.ancestor)==null?void 0:$.id)})),p=Jp(u),e=o.filter(y=>y!=null&&y.ancestor?p===y.ancestor?!0:!o.filter(w=>w.ancestor!==y.ancestor).map(w=>w.ancestor).some(w=>{const A=Io(y.ancestor,w);return!!(A!=null&&A.last)}):!1);if(e.length===0)return{ancestor:p,callType:(p==null?void 0:p.parent.type)===f.Loop?"loop-body":"entry"};if(e.length>1)throw new Error(`getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders: Could not be resolved, multiple candidates found: ${e.map(y=>Y(y.ancestor,u.project)).join(", ")}`);return{ancestor:e[0].ancestor,callType:e[0].callType}}function O5(d,u){if(d===u)return!0;if(dt(d).includes(u)||!dt(u).includes(d))return!1;const o=d.calledBy;return o.length===0?!1:o.length===1?o[0]===u:_5(o).length>1&&o.includes(u)?!1:o.every(e=>d===u?!0:Dt.includes(e.type)?!1:O5(e,u))}function C5(d){const u=[];let r=d.calledBySuccess;r=r.filter(o=>!r.filter(y=>y!==o).some(y=>Im(y,o)));let a=d.calledByError;a=a.filter(o=>!a.filter(y=>y!==o).some(y=>Im(y,o)));for(const o of r)u.push({ancestor:o,callType:"success"});for(const o of a)u.push({ancestor:o,callType:"error"});return u}function $5(d){const u=[];return C5(d).forEach(a=>{a.ancestor.type===f.Condition&&u.push({condition:a.ancestor,call:d,callType:a.callType});const p=$5(a.ancestor).filter(e=>!u.some(y=>y.condition.id===e.condition.id));u.push(...p)}),u}function ub(d){if(!d)return null;if(d.type===f.Condition&&d.parent.type===f.Condition)return Am(d.parent);if($v.includes(d.type))return d;const u=d.parent;return u?ub(u):null}function cb(d,u=new Set){return d.writesValues.reduce((r,a)=>u.has(a.id)?r:(u.add(a.id),un.includes(a.type)?[...r,a]:Br.includes(a.type)?[...r,a,...cb(a,u)]:r),[])}function Wp(d){const u=d.calledBy;if(u.length===0)return d.project;const r=u.reduce((a,o)=>{const p=Di(o,d.project);return!p||p.type===f.Project?a:a.type===f.Project||Fd(p,a).last?p:(Fd(a,p).last,a)},d.project);return r.type===f.FunctionDeclaration&&r.parent.type===f.Loop?r.parent:r}function He(d,u){let r=Wp(d);if(d.type===f.InternalCall)if(d.parent.type===f.VariableInstance){const o=Xs(r,d.parent.declaration,d.project);!o.compatible&&o.type!=="b-is-global-a-is-not"?d.parent.remove({ignoreUpstream:!1},u):(d.parent.setParent(r,u),d.parent.addSelfToProject(u))}else d.parent.setParent(r,u),d.parent.addSelfToProject(u);else if((d.type===f.ContinueStatement||d.type===f.BreakStatement)&&r.type!==f.Loop){d.remove({ignoreUpstream:!1},u);return}else if(d.type===f.ReturnStatement&&!Nr.includes(r.type)){d.remove({ignoreUpstream:!1},u);return}else if(Tt.includes(d.type)){const o=d.usedInternalCalls[0];if(o)if(r=Wp(o),d.type===f.VariableInstance){const p=Xs(r,d.declaration,d.project);!p.compatible&&p.type!=="b-is-global-a-is-not"?d.remove({ignoreUpstream:!1},u):(d.setParent(r,u),d.addSelfToProject(u))}else d.setParent(r,u),d.addSelfToProject(u);else if(d.type===f.VariableInstance){const p=Xs(r,d.declaration,d.project);!p.compatible&&p.type!=="b-is-global-a-is-not"?d.remove({ignoreUpstream:!1},u):(d.setParent(r,u),d.addSelfToProject(u))}else d.setParent(r,u),d.addSelfToProject(u)}else d.setParent(r,u),d.addSelfToProject(u);if(hr.includes(d.type))return;dt(d).forEach(o=>{let p=Wp(o);if(o.type===f.InternalCall)if(o.parent.type===f.VariableInstance){const e=Xs(p,o.parent.declaration,d.project);!e.compatible&&e.type!=="b-is-global-a-is-not"?o.parent.remove({ignoreUpstream:!1},u):(o.parent.setParent(p,u),o.parent.addSelfToProject(u))}else o.parent.setParent(p,u),o.parent.addSelfToProject(u);else if((o.type===f.ContinueStatement||o.type===f.BreakStatement)&&p.type!==f.Loop){o.remove({ignoreUpstream:!1},u);return}else if(o.type===f.ReturnStatement&&!Nr.includes(p.type)){o.remove({ignoreUpstream:!1},u);return}else if(Tt.includes(o.type)){const e=o.usedInternalCalls[0];if(e)if(p=Wp(e),o.type===f.VariableInstance){const y=Xs(p,o.declaration,d.project);!y.compatible&&y.type!=="b-is-global-a-is-not"?o.remove({ignoreUpstream:!1},u):(o.setParent(p,u),o.addSelfToProject(u))}else o.setParent(p,u),o.addSelfToProject(u);else if(o.type===f.VariableInstance){const y=Xs(p,o.declaration,d.project);!y.compatible&&y.type!=="b-is-global-a-is-not"?o.remove({ignoreUpstream:!1},u):(o.setParent(p,u),o.addSelfToProject(u))}else o.setParent(p,u),o.addSelfToProject(u)}else o.setParent(p,u),o.addSelfToProject(u)})}function Tm(d,u,r=new Set){const a=bn(d),o=bn(u),p=a.filter(v=>!o.includes(v)),e=a.filter(v=>o.includes(v)),y=p.reduce((v,E)=>r.has(E.id)?v:(r.add(E.id),R([...v,...Tm(E,u,r)])),[]);return R([...e,...y])}function Il(d,u){const r=Fd(d,u);return r.last===u&&r.list.length>0&&r.list[0]!==u}function pb(d,u){return!!Fd(d,u).last}function Im(d,u){return!!Io(d,u).last}function fb(d,u){if(!d||!u)throw new Error("Both entities must be defined to find a common ancestor");if(d===u)return d;const r=d.parent;if(r){if(r===u)return u;if(r.type===f.Project)return null}else return null;const a=u.parent;if(a){if(a===d)return d;if(a.type===f.Project)return null}else return null;return fb(r,a)}function dIe(d,u,r=!0){if(!d||!u)throw new Error("Both entities must be defined to find a common ancestor");if(d===u)return{ancestor:d,callType:"same-entity"};if(xi.includes(d.type)&&wi.includes(u.type)){const y=Io(d,u),v=y.last;if(v){if(v===u)return{ancestor:u,callType:y.callType}}else return{ancestor:null,callType:null}}if(xi.includes(u.type)&&wi.includes(d.type)){const y=Io(u,d),v=y.last;if(v){if(v===d)return{ancestor:d,callType:y.callType}}else return{ancestor:null,callType:null}}const a=Jp(d),o=Jp(u);if(!a||!o)return{ancestor:null,callType:null};if(a!==o)return{ancestor:null,callType:null};if(a.calls.includes(d)||a.calls.includes(u))return{ancestor:a,callType:"entry"};const p=a.calls.reduce((y,v)=>{if(!wi.includes(v.type))return y;const E=Yp(v),w=E.find($=>$.callee===d),A=E.find($=>$.callee===u);return w&&A&&(!r||w.callType===A.callType)?[...y,{ancestor:v,callType:w.callType}]:y},[]);if(p.length===0)return{ancestor:null,callType:null};if(p.length===1)return{ancestor:p[0].ancestor,callType:p[0].callType};const e=p.filter(y=>!p.some(v=>v.ancestor!==y.ancestor&&Io(y.ancestor,v.ancestor).last===v.ancestor));return e.length===1?{ancestor:e[0].ancestor,callType:e[0].callType}:{ancestor:a,callType:"entry"}}function fr(d){if(th.includes(d.type)){if(d.type===f.FunctionDeclaration){const u=d.parent;if(u.type===f.DefinitionEntity)return fr(u);if(u.type===f.Loop)return u}return d.type===f.DefinitionEntity&&d.parent.type===f.DataType||d.type===f.Condition&&d.parent.type===f.Condition?fr(d.parent):d}else{const u=d.parent;return u?fr(u):null}}function Sd(d,u){const r=Kd(d,u);if(!r)return null;if(th.includes(r.type)){if(r.type===f.FunctionDeclaration){const a=Kd(r.parent,u);if(a){if(a.type===f.DefinitionEntity)return a;if(a.type===f.Loop)return a}}if(r.parent){const a=Kd(r.parent,u);if(a&&(r.type===f.DefinitionEntity&&a.type===f.DataType||r.type===f.Condition&&a.type===f.Condition))return Sd(a,u)}return r}else{const a=r.parent?Kd(r.parent,u):null;return a?Sd(a,u):null}}function Yp(d){if(d.type===f.Loop){const u=[...ri(d.successCalls).map(o=>({callee:o,callType:"success"})),...ri(d.errorCalls).map(o=>({callee:o,callType:"error"})),...(d.body?dt(d.body):[]).map(o=>({callee:o,callType:"loop-body"}))];return R(u.map(o=>o.callee)).map(o=>{var e;const p=(e=u.find(y=>y.callee===o))==null?void 0:e.callType;return{callee:o,callType:p}})}if(sr.includes(d.type)){const u=[...ri(d.successCalls).map(o=>({callee:o,callType:"success"})),...ri(d.errorCalls).map(o=>({callee:o,callType:"error"}))];return R(u.map(o=>o.callee)).map(o=>{var e;const p=(e=u.find(y=>y.callee===o))==null?void 0:e.callType;return{callee:o,callType:p}})}if(Dt.includes(d.type)){const u=[...ri(d.calls).map(o=>d.parent.type===f.Loop?{callee:o,callType:"loop-body"}:{callee:o,callType:"entry"})];return R(u.map(o=>o.callee)).map(o=>{var e;const p=(e=u.find(y=>y.callee===o))==null?void 0:e.callType;return{callee:o,callType:p}})}return[]}function Am(d){if(!d)return null;if(d.type===f.Condition&&d.parent.type===f.Condition)return Am(d.parent);if(xi.includes(d.type))return d;const u=d.parent;return u?Am(u):null}function P5(d){if(!d)return null;if(sr.includes(d.type))return d;const u=d.parent;return u?P5(u):null}function N5(d){if(!d)return null;if(wi.includes(d.type))return d;const u=d.parent;return u?N5(u):null}function uIe(d){return d.type===f.VariableDeclaration?[d]:sr.includes(d.type)?[...d.inputs,...d.outputs||[]]:hr.includes(d.type)?d.outputs:jo.includes(d.type)||d.type===f.FunctionDeclaration?d.inputs:[]}function cIe(d){const u=bn(d),r=[],a=[];Xg.includes(d.type)&&r.push(...bm(d));const o=u.filter(p=>{const e=r.includes(p);return e?!1:xi.includes(p.type)&&!e?(a.push(p),!1):!0});return r.sort((p,e)=>Il(e,p)?-1:0),a.sort((p,e)=>Il(e,p)?-1:0),[...r,...a,...o]}function V5(d){return[...d].sort((u,r)=>Il(r,u)?-1:0)}function pIe(d){const u=V5(d),r=[];return u.forEach(a=>{const o=r[r.length-1];if(o){const p=o[o.length-1];Il(a,p)?r.push([a]):o.push(a)}else r.push([a])}),r}function La(d){const u=d.map(r=>fr(r));return R(u)}function bm(d){return sr.includes(d.type)?[...La(d.successCalls),...La(d.errorCalls)]:Dt.includes(d.type)?La(d.calls):[]}function fIe(d,u){return bm(d).includes(u)}function wm(d){return d.writesValues||[]}function hIe(d,u){return wm(d).includes(u)}function L5(d){var u;return Tt.includes((u=d==null?void 0:d.readsValue)==null?void 0:u.type)?d.readsValue:null}function yIe(d){return d.writesValues}function M5(d=[]){return d.map(L5).filter(u=>!!u)}function Rm(d=[]){return d.map(u=>u.writesValues).flat().filter(u=>Tt.includes(u.type))}function B5(d=[]){return d.map(u=>u.readsValue).filter(u=>!!u&&Tt.includes(u.type))}function U5(d){return Tt.includes(d.type)?d:null}function x5(d){return d.writesValues.map(U5).filter(u=>!!u)}function j5(d=[]){return d.reduce((u,r)=>r.type===f.OutputMap?[...u,...x5(r)]:u,[])}function dt(d){return d.type===f.Loop?R([...ri(d.successCalls),...ri(d.errorCalls),...d.body?dt(d.body):[]]):sr.includes(d.type)?R([...ri(d.successCalls),...ri(d.errorCalls)]):Dt.includes(d.type)?R(ri(d.calls)):[]}function mIe(d){return sr.includes(d.type)?[...ri(d.successCalls),...ri(d.errorCalls)]:Dt.includes(d.type)?ri(d.calls):[]}function G5(d,u=new Set){return d.writesValues.filter(a=>Tt.includes(a.type)&&!u.has(a.id)).reduce((a,o)=>u.has(o.id)?a:[...a,...vr(o,u)],[])}function F5(d,u=new Set){var a;return(((a=d.readsValue)==null?void 0:a.writesValues)||[]).filter(o=>Tt.includes(o.type)&&!u.has(o.id)).reduce((o,p)=>u.has(p.id)?o:[...o,...vr(p,u)],[])}function vr(d,u=new Set){if(u.has(d.id))return[];if(d.type===f.ReturnStatement)return B5(d.outputs).reduce((a,o)=>[...a,...vr(o,u)],[]);if(d.type===f.FunctionCall||d.type===f.Operation||d.type===f.Condition)return[...dt(d).reduce((p,e)=>{const y=fr(e);return[...p,...vr(y||e,u)]},[]),...M5(d.inputs),...j5(d.outputs)].reduce((p,e)=>[...p,...vr(e,u)],[]);if(jo.includes(d.type)){const r=Rm(d.inputs),o=dt(d).reduce((p,e)=>{const y=fr(e);return[...p,...vr(y||e,u)]},[]);return r.push(...o),r.reduce((p,e)=>[...p,...vr(e,u)],[])}if(d.type===f.FunctionDeclaration){const r=[...Rm(d.inputs)],o=dt(d).reduce((p,e)=>{const y=fr(e);return[...p,...vr(y||e,u)]},[]);return r.push(...o),r.reduce((p,e)=>[...p,...vr(e)],[])}if(Tt.includes(d.type)){u.add(d.id);const a=dt(d).reduce((o,p)=>{const e=fr(p);return[...o,...vr(e||p,u)]},[]);return[d,...a,...F5(d,u),...G5(d,u)]}return[]}function ms(d,u=new Set){return u.has(d.id)?[]:(u.add(d.id),[...bn(d).reduce((o,p)=>[...o,p,...ms(p,u)],[])])}function ri(d){return d.reduce((u,r)=>r.type===f.ReturnStatement||r.type===f.ContinueStatement||r.type===f.BreakStatement?[...u,r]:[...u,r,...dt(r)],[])}function S5(d){const u=d.entities||[],r=[...u,...d.functions||[],...d.events||[],...d.projects||[]],a=u.reduce((v,E)=>[...v,...E.properties],[]),o=u.reduce((v,E)=>[...v,...E.methods],[]),p=o.reduce((v,E)=>[...v,...Rm(E.inputs),...ri(La(E.calls)),...E.returnStatements],[]),e=d.functions.reduce((v,E)=>[...v,...ri(La(E.calls)),...E.returnStatements],[]),y=d.events.reduce((v,E)=>[...v,...ri(La(E.calls)),...E.returnStatements],[]);return[...r,...a,...o,...p,...e,...y]}function K5(d,u){return u.filter(a=>{if(!a)return!1;switch(a.type){case f.FunctionCall:return a.inputs.find(o=>o.id===d.id)!==void 0||a.outputs.find(o=>o.id===d.id)!==void 0;case f.Condition:return a.successCalls.find(o=>o.id===d.id)!==void 0||a.errorCalls.find(o=>o.id===d.id)!==void 0||a.inputs.find(o=>o.id===d.id)!==void 0;case f.Operation:return a.outputs.find(o=>o.id===d.id)!==void 0;case f.VariableDeclaration:return sr.includes(d.type)?ES(d).find(p=>{var e;return((e=p.readsValue)==null?void 0:e.id)===a.id})!==void 0:!1;case f.DefinitionEntity:return a.properties.find(o=>o.id===d.id)!==void 0||a.methods.find(o=>o.id===d.id)!==void 0;case f.FunctionDeclaration:return a.inputs.find(o=>o.id===d.id)!==void 0||(a.returnStatements.map(o=>o.outputs).flat()||[]).find(o=>o.id===d.id)!==void 0;default:return!1}})}function vIe(d){const u=S5(d.project);return K5(d,u)}function Kd(d,u){return d?typeof d=="string"?u[d]:d.type===f.GenericReference?u[d.entityId]:u[d.id]?u[d.id]:null:null}function k5(d={},u){const r={};return Object.keys(d).forEach(a=>{const o=u.get(a)||a,p=d[a];r[o]=p}),r}function kd(d,u={},r={}){const a={ignoreBuiltInBaseEntities:!1,allBuiltInEntityIds:[],entityMaps:new Map,...r};if(a.ignoreBuiltInBaseEntities&&(Zi.includes(d.type)||(a.allBuiltInEntityIds||[]).includes(d.id)))return{upstream:{},downstream:{}};const o=d,p=d,e=d,y=d,v=d,E=d,w=d,A=d,$=d,V=d,B=d,F=d,K=d,q=[...K.readsValue?[K.readsValue]:[],...K.declaration?[K.declaration]:[],...(F.calledByEntry||[]).flatMap(Q=>Q),...(F.calledBySuccess||[]).flatMap(Q=>Q),...(F.calledByError||[]).flatMap(Q=>Q),...V.parent?[V.parent]:[]];Array.isArray(e.implements)?q.push(...e.implements.flatMap(Q=>Q)):$.implements&&q.push($.implements),Array.isArray(e.extends)?q.push(...e.extends.flatMap(Q=>Q)):$.extends&&q.push($.extends),v.valueAsTypeList&&Array.isArray(v.valueAsTypeList)&&q.push(...v.valueAsTypeList.flatMap(Q=>Q)),v.valueAsTypeSingle&&q.push(v.valueAsTypeSingle),(K.internalCalls||[]).forEach(Q=>{const ce=J(Q);if(ce&&u[ce]){const X=u[ce];[...X.calledByEntry||[],...X.calledBySuccess||[],...X.calledByError||[]].forEach(z=>{const pe=J(z);pe&&u[pe]&&q.push(u[pe])})}});const ie=[...(o.inputs||[]).flatMap(Q=>Q),...(B.inputsDeclarations||[]).flatMap(Q=>Q),...(o.outputs||[]).flatMap(Q=>Q),...(B.outputsDeclarations||[]).flatMap(Q=>Q),...(K.internalCalls||[]).flatMap(Q=>Q),...K.writesValues||[],...F.dataType?[F.dataType]:[],...E.body?[E.body]:[],...F.defaultValue?[F.defaultValue]:[],...(F.successCalls||[]).flatMap(Q=>Q),...(F.errorCalls||[]).flatMap(Q=>Q),...(e.properties||[]).flatMap(Q=>Q),...(e.methods||[]).flatMap(Q=>Q),...(e.abstractMethods||[]).flatMap(Q=>Q),...w.error?[w.error]:[],...w.process?[w.process]:[],...V.throws?[V.throws]:[],...(p.andChildrenGroup||[]).flatMap(Q=>Q),...(p.orChildrenGroup||[]).flatMap(Q=>Q),...(A.entities||[]).flatMap(Q=>Q),...(A.functions||[]).flatMap(Q=>Q),...(A.functionCalls||[]).flatMap(Q=>Q),...(A.events||[]).flatMap(Q=>Q),...(A.conditions||[]).flatMap(Q=>Q),...(A.operations||[]).flatMap(Q=>Q),...(A.loops||[]).flatMap(Q=>Q),...(A.variableDeclarations||[]).flatMap(Q=>Q),...(A.variableInstances||[]).flatMap(Q=>Q),...(A.searches||[]).flatMap(Q=>Q),...(A.projects||[]).flatMap(Q=>Q),...(y.calls||[]).flatMap(Q=>Q)];d.type===f.DataType&&(p.entity&&u[J(p.entity)]&&u[J(p.entity)].parent&&J(u[J(p.entity)].parent)===d.id?ie.push(p.entity):p.entity&&q.push(p.entity)),(K.internalCalls||[]).forEach(Q=>{const ce=J(Q);if(ce&&u[ce]){const X=u[ce];[...X.successCalls||[],...X.errorCalls||[]].forEach(z=>{const pe=J(z);pe&&u[pe]&&ie.push(u[pe])})}});const W={},de={};return q.forEach(Q=>{var z;const ce=J(Q);if(ce&&a.ignoreBuiltInBaseEntities&&(Zi.includes(Q.type)||(a.allBuiltInEntityIds||[]).includes(ce)))return;const X=Q.version;if(ce){const pe=((z=a.entityMaps)==null?void 0:z.get(ce))||ce;W[pe]=X}}),ie.forEach(Q=>{var z;const ce=J(Q);if(ce&&a.ignoreBuiltInBaseEntities&&(Zi.includes(Q.type)||(a.allBuiltInEntityIds||[]).includes(ce)))return;const X=Q.version;if(ce){const pe=((z=a.entityMaps)==null?void 0:z.get(ce))||ce;de[pe]=X}}),{upstream:W,downstream:de}}function EIe(d,u){const r=[];if(xi.includes(d.type)){Ms(d).forEach(p=>{const e=Sd(p,u);e&&r.push(e)});const o=[...d.inputs||[],...d.outputs||[]].map(p=>{const e=Kd(p,u);return e?IS(e,u):null}).filter(p=>p!==null);r.push(...R(o))}if(Tt.includes(d.type)){const a=gm(d);a&&r.push(a)}return R(r)}function Ao(d){const u=[];if(xi.includes(d.type)){d.calledBy.forEach(o=>{const p=fr(o);p&&u.push(p)});const a=[...d.inputs||[],...d.outputs||[]].map(o=>gm(o)).filter(o=>o!==null);u.push(...R(a))}if(Tt.includes(d.type)){const r=gm(d);r&&u.push(r)}return R(u)}function Ms(d){return[...d.calledByEntry||[],...d.calledByError||[],...d.calledBySuccess||[]].filter(u=>u.type!==f.GenericReference)}function q5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");return[d,...d.inputs.flatMap(a=>me(a,u,r)),...d.outputs.flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...d.parent?me(d.parent,u,r):[]]}function Z5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");return[d,...d.defaultValue?me(d.defaultValue,u):[],...d.writesValues.flatMap(a=>me(a,u,r)),...d.dataType?me(d.dataType,u,r):[],...d.parent?me(d.parent,u,r):[]]}function H5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.BreakStatement)throw new Error("Entity must be a break statement to be flattened");return[d,...d.outputs.flatMap(a=>me(a,u,r)),...d.throws?me(d.throws,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function J5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");return[d,...(d.properties||[]).flatMap(a=>me(a,u,r)),...(d.methods||[]).flatMap(a=>me(a,u,r)),...(d.abstractMethods||[]).flatMap(a=>me(a,u,r)),...d.extends?me(d.extends,u,r):[]]}function W5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Condition)throw new Error("Entity must be a condition to be flattened");return[d,...(d.andChildrenGroup||[]).flatMap(a=>me(a,u,r)),...(d.orChildrenGroup||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function Y5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");return[d,...d.outputs.flatMap(a=>me(a,u,r)),...d.throws?me(d.throws,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function z5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");return[d,...d.extends?me(d.extends,u,r):[],...(d.implements||[]).flatMap(a=>me(a,u,r)),...(d.properties||[]).flatMap(a=>me(a,u,r)),...(d.methods||[]).flatMap(a=>me(a,u,r)),...(d.abstractMethods||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function X5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.DataType)throw new Error("Entity must be a data type to be flattened");return[d,...(d.andChildrenGroup||[]).flatMap(a=>me(a,u,r)),...(d.orChildrenGroup||[]).flatMap(a=>me(a,u,r)),...d.entity?me(d.entity,u,r):[],...d.parent?me(d.parent,u,r):[]]}function Q5(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.FunctionCall)throw new Error("Entity must be a function call to be flattened");return[d,...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...d.process?me(d.process,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function eS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");return[d,...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.calls||[]).flatMap(a=>me(a,u,r)),...d.implements?me(d.implements,u,r):[],...d.parent?me(d.parent,u,r):[]]}function tS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.GlobalEvent)throw new Error("Entity must be a global event to be flattened");return[d,...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.calls||[]).flatMap(a=>me(a,u,r)),...d.implements?me(d.implements,u,r):[],...d.parent?me(d.parent,u,r):[]]}function rS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.InputMap)throw new Error("Entity must be an input map to be flattened");return[d,...d.readsValue?me(d.readsValue,u,r):[],...d.declaration?me(d.declaration,u,r):[],...d.defaultValue?me(d.defaultValue,u,r):[],...d.parent?me(d.parent,u,r):[]]}function iS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.InstalledProject)throw new Error("Entity must be an installed project to be flattened");return[d,...(d.functions||[]).flatMap(a=>me(a,u,r)),...(d.events||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function sS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.InternalCall)throw new Error("Entity must be an internal call to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...d.process?me(d.process,u,r):[],...d.parent?me(d.parent,u,r):[]]}function nS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.LiteralValue)throw new Error("Entity must be a literal value to be flattened");return[d,...d.valueAsTypeSingle?me(d.valueAsTypeSingle,u,r):[],...d.valueAsTypeList&&Array.isArray(d.valueAsTypeList)?d.valueAsTypeList.flatMap(a=>me(a,u,r)):[],...d.parent?me(d.parent,u,r):[]]}function aS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Loop)throw new Error("Entity must be a loop to be flattened");return[d,...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...d.process?me(d.process,u,r):[],...d.body?me(d.body,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function oS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Operation)throw new Error("Entity must be an operation to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...d.process?me(d.process,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function lS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.OutputMap)throw new Error("Entity must be an output map to be flattened");return[d,...(d.writesValues||[]).flatMap(a=>me(a,u,r)),...d.declaration?me(d.declaration,u,r):[],...d.defaultValue?me(d.defaultValue,u,r):[],...d.parent?me(d.parent,u,r):[]]}function dS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");return[d,...(d.properties||[]).flatMap(a=>me(a,u,r)),...(d.methods||[]).flatMap(a=>me(a,u,r)),...(d.abstractMethods||[]).flatMap(a=>me(a,u,r))]}function uS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Project)throw new Error("Entity must be a project to be flattened");return[d,...(d.entities||[]).flatMap(a=>me(a,u,r)),...(d.functions||[]).flatMap(a=>me(a,u,r)),...(d.events||[]).flatMap(a=>me(a,u,r)),...(d.projects||[]).flatMap(a=>me(a,u,r)),...(d.variableDeclarations||[]).flatMap(a=>me(a,u,r)),...(d.variableInstances||[]).flatMap(a=>me(a,u,r)),...(d.operations||[]).flatMap(a=>me(a,u,r)),...(d.conditions||[]).flatMap(a=>me(a,u,r)),...(d.functionCalls||[]).flatMap(a=>me(a,u,r)),...(d.projects||[]).flatMap(a=>me(a,u,r)),...(d.loops||[]).flatMap(a=>me(a,u,r)),...(d.searches||[]).flatMap(a=>me(a,u,r))]}function cS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Property)throw new Error("Entity must be a property to be flattened");return[d,...d.defaultValue?me(d.defaultValue,u,r):[],...d.dataType?me(d.dataType,u,r):[],...d.parent?me(d.parent,u,r):[]]}function pS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ReturnDeclaration)throw new Error("Entity must be a return declaration to be flattened");return[d,...d.readsValue?me(d.readsValue,u,r):[],...d.defaultValue?me(d.defaultValue,u,r):[],...d.dataType?me(d.dataType,u,r):[],...d.parent?me(d.parent,u,r):[]]}function fS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");return[d,...(d.outputs||[]).flatMap(a=>me(a,u,r)),...d.throws?me(d.throws,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function hS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Search)throw new Error("Entity must be a search to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(d.inputsDeclarations||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputsDeclarations||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...d.error?me(d.error,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.parent?me(d.parent,u,r):[]]}function yS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");return[d,...d.defaultValue?me(d.defaultValue,u,r):[],...d.dataType?me(d.dataType,u,r):[],...d.parent?me(d.parent,u,r):[]]}function mS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...(d.internalCalls||[]).flatMap(a=>me(a,u,r)),...(d.writesValues||[]).flatMap(a=>me(a,u,r)),...d.readsValue?me(d.readsValue,u,r):[],...d.defaultValue?me(d.defaultValue,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.dataType?me(d.dataType,u,r):[],...d.parent?me(d.parent,u,r):[]]}function vS(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>me(a,u,r)),...(d.errorCalls||[]).flatMap(a=>me(a,u,r)),...(d.inputs||[]).flatMap(a=>me(a,u,r)),...(d.outputs||[]).flatMap(a=>me(a,u,r)),...(d.internalCalls||[]).flatMap(a=>me(a,u,r)),...(d.writesValues||[]).flatMap(a=>me(a,u,r)),...d.readsValue?me(d.readsValue,u,r):[],...d.defaultValue?me(d.defaultValue,u,r):[],...(Ms(d)||[]).flatMap(a=>me(a,u,r)),...d.declaration?me(d.declaration,u,r):[],...d.parent?me(d.parent,u,r):[]]}function zs(){const d=new Set,u=KL.flatMap(r=>me(r,d)).map(r=>r.id);if(!u.includes("http-request-error-return-delaration-id"))throw new Error("Built-in base entities must be included in the list");return u}function me(d,u=new Set,r={ignoreBuiltInBaseEntities:!1}){if(!d)throw new Error("Entity must be defined to be flattened");if(d.type===f.GenericReference)return[];if(r.ignoreBuiltInBaseEntities&&(Zi.includes(d.type)||zs().includes(d.id)))return[];if(u.has(d.id))return[];switch(d.type){case f.FunctionCall:return Q5(d,u,r);case f.Operation:return oS(d,u,r);case f.Condition:return W5(d,u,r);case f.Loop:return aS(d,u,r);case f.Search:return hS(d,u,r);case f.GlobalEvent:return tS(d,u,r);case f.ReturnStatement:return fS(d,u,r);case f.ContinueStatement:return Y5(d,u,r);case f.BreakStatement:return H5(d,u,r);case f.VariableDeclaration:return mS(d,u,r);case f.DefinitionEntity:return z5(d,u,r);case f.FunctionDeclaration:return eS(d,u,r);case f.Project:return uS(d,u,r);case f.ActionDescriptor:return q5(d,u,r);case f.ArgumentDeclaration:return Z5(d,u,r);case f.ReturnDeclaration:return pS(d,u,r);case f.ValueDescriptor:return yS(d,u,r);case f.InputMap:return rS(d,u,r);case f.OutputMap:return lS(d,u,r);case f.DataType:return X5(d,u,r);case f.InstalledProject:return iS(d,u,r);case f.InternalCall:return sS(d,u,r);case f.LiteralValue:return nS(d,u,r);case f.Property:return cS(d,u,r);case f.VariableInstance:return vS(d,u,r);case f.BuiltInBaseEntity:return r.ignoreBuiltInBaseEntities?[]:J5(d,u,r);case f.PrimitiveEntity:return r.ignoreBuiltInBaseEntities?[]:dS(d,u,r)}return[]}function hb(d){return d.type===f.FunctionCall||d.type===f.InternalCall||[f.Operation,f.Condition,f.Loop].includes(d.type)?d.declaration.inputs:d.type===f.FunctionDeclaration||jo.includes(d.type)?d.inputs:d.type===f.Search?d.inputsDeclarations:[]}function TIe(d,u){return u.type===f.Condition?u.inputs.find(r=>r.declaration.id===d.id):u.type===f.FunctionCall||u.type===f.Operation?u.inputs.find(r=>r.declaration.id===d.id):null}function ES(d){return sr.includes(d.type)?d.inputs:[]}function TS(d){var u;return d.type===f.FunctionCall?((u=d.declaration.returnStatements[0])==null?void 0:u.outputs)||[]:[f.Operation,f.Condition,f.Loop].includes(d.type)?d.declaration.outputs:d.type===f.Search?d.outputsDeclarations:hr.includes(d.type)?d.outputs:[]}function IIe(d,u){return u.type===f.Condition?null:(u.type===f.FunctionCall||u.type===f.Operation)&&u.outputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===d.id})||null}function AIe(d){return d.type===f.Condition?[]:sr.includes(d.type)?d.outputs:[]}function gm(d){const u=d.readsValue;return u?fr(u):null}function IS(d,u){const r=d.readsValue;return r?Sd(r,u):null}function AS(d){const u=d.internalCalls||[];return R(La(R(u.flatMap(r=>[...r.successCalls,...r.errorCalls]))))}function bS(d){const u=d.internalCalls||[];return R(R(u.flatMap(r=>[...r.successCalls,...r.errorCalls])))}function qd(d){const u=wm(d),r=[];return u.forEach(a=>{if(Tt.includes(a.type))r.push(a);else if(un.includes(a.type)){const o=fr(a.parent);r.push(o)}}),r}function Zd(d){const u=wm(d),r=[];return u.forEach(a=>{if(Tt.includes(a.type))r.push(a);else if(un.includes(a.type)){const o=a.parent;r.push(o)}}),r}function R(d){const u=new Set;return d.filter(r=>!r||u.has(r.id)?!1:(u.add(r.id),!0))}function wS(d){return d.type===f.Project?null:$v.includes(d.type)?d:Zi.includes(d.type)?null:d.parent?wS(d.parent):null}function bn(d,u=!1){const r=[];if(d.type===f.Project&&r.push(...(d==null?void 0:d.entities)||[],...(d==null?void 0:d.functions)||[],...(d==null?void 0:d.variableDeclarations)||[],...(d==null?void 0:d.variableInstances)||[],...(d==null?void 0:d.searches)||[],...(d==null?void 0:d.loops)||[],...(d==null?void 0:d.operations)||[],...(d==null?void 0:d.conditions)||[],...(d==null?void 0:d.functionCalls)||[],...(d==null?void 0:d.events)||[],...(d==null?void 0:d.projects)||[]),Nr.includes(d.type)&&r.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===f.DefinitionEntity){const a=[...d.suggestedMethods,...d.methods].flatMap(o=>o.collapsed&&u?[]:bn(o));r.push(...a)}if(d.type===f.Condition){const a=d.successCalls.map(p=>fr(p)),o=d.errorCalls.map(p=>fr(p));r.push(...a,...o)}if(jo.includes(d.type)){if(d.collapsed&&u)return[];const a=d.inputs.map(p=>qd(p)).flat(),o=d.calls.map(p=>fr(p));r.push(...R(a),...o)}if(sr.includes(d.type)&&d.type!==f.Condition&&d.type!==f.Loop){const a=d==null?void 0:d.outputs.map(e=>qd(e)).flat(),o=d.successCalls.map(e=>fr(e)),p=d.errorCalls.map(e=>fr(e));r.push(...R(a),...o,...p)}if(Tt.includes(d.type)){const a=qd(d),o=AS(d);r.push(...a,...o)}if(d.type===f.Loop){const a=d.outputs.map(e=>qd(e)).flat();if(d.body){const e=bn(d.body,u);r.push(...e)}const o=d.errorCalls.map(e=>fr(e)),p=d.successCalls.map(e=>fr(e));r.push(...R(a),...p,...o)}if(d.type===f.FunctionDeclaration){if(d.collapsed&&u)return[];const a=d.inputs.map(p=>qd(p)).flat(),o=d.calls.map(p=>fr(p));r.push(...R(a),...o)}return R(r)}function _m(d,u=!1){const r=[];if(d.type===f.Project&&r.push(...(d==null?void 0:d.variableDeclarations)||[],...(d==null?void 0:d.variableInstances)||[],...(d==null?void 0:d.searches)||[],...(d==null?void 0:d.loops)||[],...(d==null?void 0:d.operations)||[],...(d==null?void 0:d.conditions)||[],...(d==null?void 0:d.functionCalls)||[]),Nr.includes(d.type)&&r.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===f.DefinitionEntity){const a=[...d.suggestedMethods,...d.methods].flatMap(o=>o.collapsed&&u?[]:_m(o));r.push(...a)}if(d.type===f.Condition){const a=d.successCalls,o=d.errorCalls;r.push(...a,...o)}if(jo.includes(d.type)){if(d.collapsed&&u)return[];const a=d.inputs.map(p=>Zd(p)).flat(),o=d.calls;r.push(...R(a),...o)}if(sr.includes(d.type)&&d.type!==f.Condition&&d.type!==f.Loop){const a=d==null?void 0:d.outputs.map(e=>Zd(e)).flat(),o=d.successCalls,p=d.errorCalls;r.push(...R(a),...o,...p)}if(Tt.includes(d.type)){const a=Zd(d),o=bS(d);r.push(...a,...o)}if(d.type===f.Loop){const a=d.outputs.map(e=>Zd(e)).flat();if(d.body){const e=_m(d.body,u);r.push(...e)}const o=d.errorCalls,p=d.successCalls;r.push(...R(a),...p,...o)}if(d.type===f.FunctionDeclaration){if(d.collapsed&&u)return[];const a=d.inputs.map(p=>Zd(p)).flat(),o=d.calls;r.push(...R(a),...o)}return R(r)}function Dm(d,u=!1){const r=bn(d,u),a=[...r,...r.reduce((o,p)=>[...o,...Dm(p,u)],[])];return R(a)}function RS(d,u=!1){const r=_m(d,u),a=[...r,...r.reduce((o,p)=>[...o,...RS(p,u)],[])];return R(a)}function gS(d){const u=Ao(d),r=[...u,...u.reduce((a,o)=>[...a,...gS(o)],[])];return R(r)}function zp(d){return d.implements.reduce((u,r)=>r.type===f.DefinitionEntity?[...u,f.DefinitionEntity,...zp(r),...Xp(r)]:[...u,r.name],[])}function Xp(d){return d.extends?d.extends.type===f.DefinitionEntity?[f.DefinitionEntity,...Xp(d.extends),...zp(d.extends)]:[d.extends.name]:[]}function yb(d){return d.extends?d.extends.type===f.DefinitionEntity?[d.extends,...yb(d.extends),...mb(d.extends)]:[d.extends]:[]}function mb(d){return d.implements.reduce((u,r)=>r.type===f.DefinitionEntity?[...u,r,...mb(r),...yb(r)]:[...u,r],[])}function Hd(d){return[...Xp(d),...zp(d)].filter((r,a,o)=>o.indexOf(r)===a)}function vb(d){return d.implements.length===0&&!d.extends?null:d.implements.find(a=>a.type===f.BuiltInBaseEntity&&a.name===Le.PERSISTED_ENTITY)?d:[...d.implements,...d.extends?[d.extends]:[]].reduce((a,o)=>{if(o.type===f.DefinitionEntity){const p=vb(o);if(p)return p}return a},null)}function bIe(d){return d.extends&&d.extends.type===f.BuiltInBaseEntity?d.extends:null}function wIe(d){const u=d.implements.find(r=>r.type===f.BuiltInBaseEntity);return u&&u.type===f.BuiltInBaseEntity?u:null}function Om(d){return d.extends&&d.extends.type===f.DefinitionEntity?d.extends:null}function Vi(d){if(d.type===f.BuiltInBaseEntity)return[d];const u=[...d.implements,...d.extends?[d.extends]:[]].reduce((r,a)=>a.type===f.BuiltInBaseEntity?[...r,a]:a.type===f.DefinitionEntity?[...r,...Vi(a)]:r,[]);return R(u)}function Qp(d){return d.type===f.PrimitiveEntity?!0:d.type===f.BuiltInBaseEntity?d.interactive:!Vi(d).find(a=>!a.interactive)}function RIe(d){return d.parent===d.project&&d.project.variableDeclarations.includes(d)}function Eb(d){return d.parent!==d.project?!1:f.VariableDeclaration===d.type?d.project.variableDeclarations.includes(d):f.VariableInstance===d.type?d.project.variableInstances.includes(d):f.FunctionCall===d.type?d.project.functionCalls.includes(d):f.Condition===d.type?d.project.conditions.includes(d):f.Operation===d.type?d.project.operations.includes(d):f.Loop===d.type?d.project.loops.includes(d):f.Search===d.type?d.project.searches.includes(d):!1}function _S(d){if([...Dt,f.DefinitionEntity,f.InstalledProject,f.Project].includes(d.type)||Eb(d))return!1;const u=Ao(d);return u.length===0?!0:u.some(r=>_S(r))}function Tb(d){return[...Dt,f.DefinitionEntity,f.InstalledProject,f.Project].includes(d.type)||Eb(d)?!1:Ao(d).length===0}function DS(d,u=0){if(Tb(d)){const r=Ao(d);return r.length===0?d:r.map(o=>DS(o,u+1)).reduce((o,p)=>o?p&&p.x<o.x?p:o:p,null)}return null}function OS(d){const u=[];if(Tb(d))u.push(d);else return[];return Ao(d).forEach(a=>{u.push(...OS(a))}),u}function Ib(d){return d.type===f.FunctionDeclaration&&d.parent!==d.project&&!![f.DefinitionEntity,f.Loop,f.InstalledProject].includes(d.parent.type)}function gIe(d,u){const r=new Map;return d.forEach(a=>{r.set(a.id,a)}),u.forEach(a=>{r.set(a.id,a)}),Array.from(r.values())}function ef(d){switch(d){case f.DefinitionEntity:return Qn;case f.FunctionDeclaration:return Qa;case f.VariableDeclaration:return oo;case f.VariableInstance:return ao;case f.FunctionCall:return To;case f.Operation:return eo;case f.Condition:return io;case f.ReturnStatement:return to;case f.Loop:return Gi;case f.Search:return lo;case f.InputMap:return Wn;case f.OutputMap:return In;case f.ArgumentDeclaration:return kn;case f.ReturnDeclaration:return Qi;case f.Property:return Xn;case f.InstalledProject:return uo;case f.Project:return N;case f.DataType:return fs;case f.GlobalEvent:return ro;case f.InternalCall:return co;case f.ValueDescriptor:return An;case f.BuiltInBaseEntity:return ea;case f.PrimitiveEntity:return ts;case f.ActionDescriptor:return ct;case f.LiteralValue:return Ki;case f.ContinueStatement:return Pi;case f.BreakStatement:return po;default:return null}}function Di(d,u,r=null){const a=d!=null&&d.parent?J(d==null?void 0:d.parent):null;let o=a?u.get(a):null,p=r||d;if((d==null?void 0:d.id)===(u==null?void 0:u.id))return u;if(d.type===f.ReturnStatement)return Hr(d,u,p);if(d.type===f.FunctionDeclaration&&(o==null?void 0:o.type)===f.Loop)return o;if(Dt.includes(d.type))return d;if(d.type===f.Loop)return p.id===d.id?o:d;if(Zi.includes(d.type))return null;const e=d.parent;if(!e)return null;if(e.type===f.GenericReference){const y=J(e);if(!y)return null;const v=u.get(y);return v?Di(v,u,p):null}else return e===u?u:Di(e,u,p)}function Hr(d,u,r=null){const a=d!=null&&d.parent?J(d==null?void 0:d.parent):null;let o=a?u.get(a):null,p=r||d;if(d.type===f.FunctionDeclaration&&(o==null?void 0:o.type)===f.Loop)return Hr(o.parent,u,p);if(Dt.includes(d.type))return d;if(Zi.includes(d.type))return null;const e=d.parent;if(!e)return null;if(e.type===f.GenericReference){const y=J(e);if(!y)return null;const v=u.get(y);return v?Hr(v,u,p):null}else return e===u?u:Hr(e,u,p)}function Jd(d,u){if(Zi.includes(d.type))return Me.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with a built-in entity type: ${d.type}`),null;if(u.getBuiltIn(d.id))return Me.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with a built-in entity: ${d.id}`),null;const r=qi(d.parent,u);return r?r===u?Nr.includes(d.type)?d:(Me.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with an entity that has the project as parent: ${d.id}`),null):r.type===f.DefinitionEntity?d:Jd(r,u):(Me.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with an entity that has no parent: ${d.id}`),null)}function Cm(d,u,r){if(d===u||u===r||d===r||!d||!u)return!1;const a=Di(u.parent,r);return a===r?!1:a===d?!0:Cm(a,u,r)}var $m=(d=>(d.SameBothLocal="same-both-local",d.AInB="a-in-b",d.BInA="b-in-a",d.ParallelInCommonParent="parallel-in-common-parent",d.ParallelInProject="parallel-in-project",d.AIsGlobalBIsNot="a-is-global-b-is-not",d.BIsGlobalAIsNot="b-is-global-a-is-not",d.SameBothGlobal="same-both-global",d))($m||{});function Xs(d,u,r){const a=Di(d,r),o=Di(u,r);if(!a)throw new Error("Could not find scope owner for the entity: "+d.id);if(!o)throw new Error("Could not find scope owner for the entity: "+u.id);if(a===o&&a.type!==f.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:a};if(a===o&&a.type===f.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:a};if(a.type===f.Project&&o.type!==f.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:a};if(a.type!==f.Project&&o.type===f.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:o};if(Cm(a,o,r))return{compatible:!0,type:"b-in-a",commonAncestorScope:a};if(Cm(o,a,r))return{compatible:!0,type:"a-in-b",commonAncestorScope:o};const y=fb(a,o);return y===r?{compatible:!1,type:"parallel-in-project",commonAncestorScope:y}:y?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:Di(y,r)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:r}}function CS(d,u,r){const a=Xs(d,u,r);if(!a.compatible||a.type!=="same-both-local")return null;if(d===u)return d;let o=Di(d.parent,r);if(o){if(o===u)return u;if(o.type===f.Project)return d}else return d;for(;o;){if(o){if(o===u)return u;if(o.type===f.Project)return d}else return d;o=Di(o.parent,r)}let p=Di(u.parent,r);if(p){if(p===d)return d;if(p.type===f.Project)return u}else return u;for(;p;){if(p){if(p===d)return d;if(p.type===f.Project)return u}else return u;p=Di(p.parent,r)}return null}function $S(d){return d.length===0?null:d.length===1?d[0]:d.reduce((r,a)=>{const o=CS(r,a,a.project);return!o||o===a?r:a},d[0])}function qi(d,u){if(!d)return null;let r;return typeof d=="string"?r=d:d.type===f.GenericReference?r=J(d):r=d.id,r===u.id?u:u.get(r)}function bo(d){if(!d)return null;if(Zi.includes(d.type))return d;if(d.type===f.Project)return null;if(d.project.getBuiltIn(d.id))return d;const u=d.parent;return!u||u.type===f.Project?null:bo(u)}function tf(d){const u=[];function r(p,e){return u.some(y=>y.blockedByCaller===p&&y.blockedByCalling===e)}function a(p,e){r(p,e)||u.push({blockedByCaller:p,blockedByCalling:e})}const o=Jd(d,d.project);return o?(d.calledBySuccess.forEach(p=>{[...p.successCalls||[]].forEach(v=>{hr.includes(v.type)&&v!==d&&(dt(d).find(A=>A===v)||a(p,v))});let y;if(sr.includes(p.type)&&(y=p),y){const v=tf(y);v.reachable||dt(d).find(A=>A===p)||v.blocks.forEach(A=>{a(p,A.blockedByCalling)})}}),d.calledByError.forEach(p=>{[...p.errorCalls||[]].forEach(v=>{hr.includes(v.type)&&v!==d&&(dt(d).find(A=>A===v)||a(p,v))});let y;if(sr.includes(p.type)&&(y=p),y){const v=tf(y);v.reachable||dt(d).find(A=>A===p)||v.blocks.forEach(A=>{a(p,A.blockedByCalling)})}}),d.calledByEntry.forEach(p=>{if([...p.calls||[]].forEach(v=>{hr.includes(v.type)&&v!==d&&(dt(d).find(A=>A===v)||a(p,v))}),p===o)return;let y;if(p.type===f.FunctionDeclaration){const v=fr(p);if(v.type===f.DefinitionEntity)return;v.type===f.Loop&&(y=v)}if(y){const v=tf(y);v.reachable||v.blocks.forEach(E=>{a(p,E.blockedByCalling)})}}),{reachable:u.length===0,entryPoint:o,blocks:u}):{reachable:!0,entryPoint:null,blocks:[]}}function _Ie(d){return th.includes(d.type)?d.type===f.FunctionDeclaration?!Ib(d):!0:!1}function DIe(d){if(f.ActionDescriptor===d.type){if(d.project.operationDeclarations.find(p=>p.id===d.id))return f.Operation;if(d.project.globalEventActionDescriptors.find(p=>p.id===d.id))return f.GlobalEvent;if(d.project.loopDeclarations.find(p=>p.id===d.id))return f.Loop;if(d.project.conditionDeclarations.find(p=>p.id===d.id))return f.Condition}return d.type}function Pm(d,u){return d.type===f.BuiltInBaseEntity?d.name===u:!!Xp(d).includes(u)}function OIe(d,u){return d.type===f.BuiltInBaseEntity?d.name===u:!!zp(d).includes(u)}function es(d,u){return d.type===f.BuiltInBaseEntity?d.name===u:!!Hd(d).includes(u)}function CIe(d){const u=[];return d.entities.forEach(r=>{if(Pm(r,Le.PERSISTED_ENTITY)){u.push(r);return}}),R(u)}function $Ie(d){const u=[];return d.entities.forEach(r=>{if(Pm(r,Le.RELATIONAL_DATABASE)){u.push(r);return}}),R(u)}function PIe(d){return d.type!==f.DefinitionEntity||d.abstract||!Pm(d,Le.PERSISTED_ENTITY)?null:(d==null?void 0:d.properties.find(r=>{var a;return((a=r.implements)==null?void 0:a.id)===he[f.BuiltInBaseEntity][Le.PERSISTED_ENTITY].properties.primaryKey.id&&!r.abstract}))||null}function PS(d){var a;const u=vb(d);if(!u)return null;const r=u.properties.find(o=>{var p;return((p=o.implements)==null?void 0:p.id)===he[f.BuiltInBaseEntity][Le.PERSISTED_ENTITY].properties.database.id});return r?(a=r.getDefaultValue())==null?void 0:a.valueAsType:null}function Wd(d){if(d.type!==f.DefinitionEntity)return[];if(d.abstract)return[];if(!es(d,Le.PERSISTED_ENTITY))return[];const u=[],r=d.properties.filter(a=>{var o;return((o=a.implements)==null?void 0:o.id)!==he[f.BuiltInBaseEntity][Le.PERSISTED_ENTITY].properties.database.id&&!a.abstract});return u.push(...r),u}function NIe(d){var r;if(!d||d.type!==f.DefinitionEntity||!es(d,Le.PERSISTED_ENTITY))return null;const u=d.properties.find(a=>{var o;return((o=a.implements)==null?void 0:o.id)===he[f.BuiltInBaseEntity][Le.PERSISTED_ENTITY].properties.database.id});return(r=u==null?void 0:u.getDefaultValue())==null?void 0:r.valueAsTypeSingle}function Ur(d,u){var a;if(!t_.includes(u.type)||!d)return u.project||null;let r=u.project;return d.type===f.Project?r=d:((a=u.project)==null?void 0:a.id)!==d.project.id&&(r=d.project),r}function VIe(d){switch(d){case f.Project:return N;case f.InstalledProject:return uo;case f.DefinitionEntity:return Qn;case f.FunctionDeclaration:return Qa;case f.GlobalEvent:return ro;case f.VariableInstance:return ao;case f.VariableDeclaration:return oo;case f.InputMap:return Wn;case f.OutputMap:return In;case f.Condition:return io;case f.Operation:return eo;case f.FunctionCall:return To;case f.ReturnDeclaration:return Qi;case f.ArgumentDeclaration:return kn;case f.PrimitiveEntity:return ts;case f.DataType:return fs;case f.Property:return Xn;case f.ActionDescriptor:return ct;case f.ReturnStatement:return to;case f.ContinueStatement:return Pi;case f.BreakStatement:return po;case f.Loop:return Gi;case f.Search:return lo;case f.ValueDescriptor:return An;case f.InternalCall:return co;case f.LiteralValue:return Ki}return null}function LIe(d){const u={added:{},updated:{},removed:{},affected:[],seenEntities:[],self:d==null?void 0:d.self};return d==null||d.added.forEach(r=>{u.added[r.id]=r}),d==null||d.updated.forEach(r=>{u.updated[r.id]=r}),d==null||d.removed.forEach(r=>{u.removed[r.id]=r}),u.affected=Array.from(new Set(d==null?void 0:d.affected.map(r=>r.id))),u}function Lr(d,u){const r=ef(d.type);return r?!r.MUTABLE_META_PROPERTIES.every(o=>{const p=d[o],e=u[o];return e===void 0||p===e?!0:Array.isArray(p)&&Array.isArray(e)?p.length!==e.length?!1:p.every((y,v)=>y===e[v]):!1}):!1}function Nm(d,u={}){if(d.type===f.Project)return[];if(!d.parent)return[];const r=J(d.parent);if(!r)return[];const a=u[r];return a?[a.id,...Nm(a,u)]:[]}function MIe(d){const u=[],r=new Set;return[...d.listAdded,...d.listUpdated,...d.listAffected].forEach(a=>{const o=fr(a);!o||r.has(o.id)||(r.add(o.id),u.push(o))}),R(u)}function BIe(d){if(d.type===f.Condition)return null;if(d.type===f.Search)return d.project.getBuiltIn(he["value-descriptor"][Jl.SearchErrorOutputDescriptor].id)||null;if(d.type===f.Operation)return d.declaration.error;if(d.type===f.FunctionCall){const r=d.declaration.returnStatements.find(a=>!!a.throws);return(r==null?void 0:r.throws)||null}return null}function NS(d){const u=d.entities.filter(o=>!!o.implements.find(p=>p.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),r=u.find(o=>{const p=o.properties.find(v=>v.implements&&v.implements.id===he["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),e=p==null?void 0:p.getDefaultValue();return(e==null?void 0:e.value)===!0});return r||u[0]||null}function Ab(d,u){const r=Array.from(new Set([...u.getAllBuiltInIds(),...zs()]));return!!(r.includes(d.id)||!Nm(d,{...u.instances,...u.builtInInstances}).every(p=>!r.includes(p)))}function VS(d){if(!d)return null;if(d.type===f.Project)return d.id;const u=d.parent;return u?VS(u):d.id}function rf(d){if(d.declaration&&d.declaration.type===f.Property){if(d.declaration.interactive){if(d.declaration.implements&&!d.declaration.implements.interactive)return!1;if(d.declaration.extends&&!d.declaration.extends.interactive)return!1}else return!1;if(d.declaration.private){const u=fr(d),r=Jd(u,d.project);if((r==null?void 0:r.type)===f.FunctionDeclaration&&(r==null?void 0:r.parent.type)===f.DefinitionEntity&&(r==null?void 0:r.parent.id)!==d.declaration.parent.id)return!1}}return!0}function bb(d){if(d.interactive){if(d.implements&&!d.implements.interactive)return!1;if(d.extends&&!d.extends.interactive)return!1}else return!1;if(d.private){const u=fr(d),r=Jd(u,d.project);if((r==null?void 0:r.type)===f.FunctionDeclaration&&(r==null?void 0:r.parent.type)===f.DefinitionEntity&&(r==null?void 0:r.parent.id)!==d.parent.id)return!1}return!0}function UIe(d,u,r){const a=u,o=r,p=!!r,e=[];return a.forEach(y=>{var v;if(p){const E=Xs(o,y,d);if(!E.compatible&&E.type!=="b-is-global-a-is-not")return;e.push(y)}else{if(((v=y.parent)==null?void 0:v.type)!==f.Project)return;e.push(y)}}),R(e)}function Vm(d){return d.replace(/["'`]/g,"")}function xr(d){const r=Vm(d).split(/[\s-]+/).filter(e=>e.length>0);if(r.length===0)return"";const a=r[0],o=a[0].toLowerCase()+a.slice(1),p=r.slice(1).map(e=>e[0].toUpperCase()+e.slice(1));return[o,...p].join("")}function Al(d){return Vm(d).split(/[\s-]+/).filter(a=>a.length>0).map(a=>a[0].toUpperCase()+a.slice(1)).join("")}function LS(d){const u=Vm(d).trim();if(!u)return"";const r=u.replace(/[\s_-]+/g," ").split(" ").filter(Boolean),a=[];for(const o of r){let p=o;p=p.replace(/([A-Z]+)([A-Z][a-z]+)/g,"$1-$2"),p=p.replace(/([a-z0-9])([A-Z][a-z0-9]*)/g,"$1-$2"),p=p.replace(/([0-9])([a-zA-Z]+)/g,"$1-$2"),p=p.replace(/([a-zA-Z])([0-9])/g,"$1-$2");for(const e of p.split("-"))e&&a.push(e)}return a.join("-")}function xIe(d){const u=Vm(d).trim();if(!u)return"";const r=u.replace(/[\s_-]+/g," ").split(" ").filter(Boolean),a=[];for(const o of r){let p=o;p=p.replace(/([A-Z]+)([A-Z][a-z]+)/g,"$1_$2"),p=p.replace(/([a-z0-9])([A-Z][a-z0-9]*)/g,"$1_$2"),p=p.replace(/([0-9])([a-zA-Z]+)/g,"$1_$2"),p=p.replace(/([a-zA-Z])([0-9])/g,"$1_$2");for(const e of p.split("_"))e&&a.push(e)}return a.join("_")}function Lm(d){return LS(d).toLowerCase()}function Yd(d){var r,a,o,p;if(!d)return"Any data type";let u="";if(d.interactiveEntities===!1?u+=` but only definition nodes ${d.asType?"as template ":""}that don't include non-interactive built-in functionality`:d.interactiveEntities===!0&&(u+=` but only definition nodes ${d.asType?"as template ":""}that extend or implement interactive built-in functionality`),d.staticEntities===!1?u?u+=" and that aren't a single global copy instance":u+=` but only definition nodes ${d.asType?"as template ":""}that aren't a single global copy instance`:d.staticEntities===!0&&(u?u+=" and that are a single global copy instance":u+=` but only definition nodes ${d.asType?"as template ":""}that are a single global copy instance`),d.actionEntities===!1?u?u+=" excluding executable/action nodes":u+=` excluding executable/action nodes ${d.asType?"templates ":""}`:d.actionEntities===!0&&(u?u+=" and not executable/action nodes":u+=" but not executable/action nodes"),d.entity&&(u=""),d.asType&&!u&&!((r=d.andChildrenGroup)!=null&&r.length)&&!((a=d.orChildrenGroup)!=null&&a.length)&&(u=" as template"),!d.entity){const e=d.isList;if(!((o=d.andChildrenGroup)!=null&&o.length)&&!((p=d.orChildrenGroup)!=null&&p.length))return e?`List of an any data type${u}`:`Any data type${u}`;let y="",v=!1,E=!1;return(d.andChildrenGroup||[]).forEach(w=>{const A=Yd(w),$=Rd(A);v&&(y+=" and "),w.isGroup?y+="("+$+")":v?y+=$:y+=A,v=!0,E=!0}),(d.orChildrenGroup||[]).forEach(w=>{const A=Yd(w),$=Rd(A);v&&(E&&(y+=","),y+=" or "),w.isGroup?y+="("+$+")":v?y+=$:y+=A,v=!0}),e?`List of ${Rd(y)}`:y}if(d.entity.type===f.PrimitiveEntity){let e=d.entity.name;switch(d.entity.name){case oe.String:e="Text";break;case oe.KeyValue:e="Data structure";break}return d.isList?`List of ${e}s${u}`:`${e.slice(0,1).toUpperCase()}${e.slice(1)}${u}`}else if(d.entity.type===f.DefinitionEntity){const e=Y(d.entity,d.project);return d.isList?`List of ${e} values${u}`:e.slice(0,1).toUpperCase()+e.slice(1)+u}else if(d.entity.type===f.BuiltInBaseEntity){const e=BS(d.entity);return d.isList?`List of ${e} values${u}`:e.slice(0,1).toUpperCase()+e.slice(1)+u}else if(d.entity.type===f.LiteralValue){if(d.entity.name===oe.Null)return"Empty value";if(d.entity.name===oe.Untyped)return"Untyped value";if(d.entity.name===oe.File)return"File";if(d.entity.name===oe.String)return`"${d.entity.value}" text`;if(d.entity.name===oe.Number)return`Number '${d.entity.value}'`;if(d.entity.name===oe.Boolean)return`${d.entity.value} value`;if(d.entity.name===oe.UUID)return`"${d.entity.value}" unique identifier`;if(d.entity.name===oe.Date)return`"${d.entity.value}" date`}return d.isList?`List of ${Y(d.entity,d.project)} values${u}`:`${Y(d.entity,d.project).slice(0,1).toUpperCase()+Y(d.entity,d.project).slice(1)} value${u}`}function jIe(d){if(!d)return"Any data type";const u=d.getDataType(null);return Yd(u)}function Mm(d){switch(d.declaration.id){case ut.Equal:return"is equal to";case ut.NotEqual:return"is not equal to";case ut.MoreThan:return"is greater than";case ut.MoreThanOrEqual:return"is greater than or equal to";case ut.LessThan:return"is less than";case ut.LessThanOrEqual:return"is less than or equal to";case Kr.And:return"and";case Kr.Or:return"or";case oi.Empty:return"is empty";case oi.NotEmpty:return"is present"}}function MS(d){return d.includes(Le.HTTP_ENDPOINT)?"HTTP endpoint":d.includes(Le.PERSISTED_ENTITY)?"Persisted entity":d.includes(Le.CRON_JOB)?"Scheduled execution":d.includes(Le.RELATIONAL_DATABASE)?"Relational database":"Entity"}function BS(d){switch(d.name){case Le.HTTP_ENDPOINT:return"HTTP endpoint";case Le.PERSISTED_ENTITY:return"Persisted entity";case Le.CRON_JOB:return"Scheduled execution";case Le.RELATIONAL_DATABASE:return"Relational database"}return"Entity"}function GIe(d){const u=Om(d);if(!u){const r=Hd(d);return r.includes(Le.HTTP_ENDPOINT)?"HTTP endpoint":r.includes(Le.PERSISTED_ENTITY)?"Persisted entity":r.includes(Le.CRON_JOB)?"Scheduled execution":r.includes(Le.RELATIONAL_DATABASE)?"Relational database":Y(d,d.project)+" entity"}return Y(u,d.project)+" entity"}function US(d){let u="Find ";return d.outputsDeclarations.forEach((r,a)=>{const o=Hy(r,null),p=Rd(o&&o.entity?Y(o.entity,d.project):"unstructured data");a===0?u+=`${p} `:a===d.outputsDeclarations.length-1?u+=`and ${p} `:u+=`, ${p} `}),u}function xS(d){switch(d.name){case oe.String:return"Text";case oe.Number:return"Number";case oe.Boolean:return"Boolean";case oe.KeyValue:return"Data structure";case oe.UUID:return"Unique identifier";case oe.Date:return"Date";case oe.EntityTemplate:return"Entity as template";case oe.Enum:return"Enumeration";case oe.File:return"File";case oe.Null:return"Empty";case oe.ActionDescriptor:return"Action descriptor";case oe.Untyped:return"Untyped";default:return d.name}}function jS(d){switch(d.id){case Je.List:return"Loop over list items";case Je.ManualFlow:return"Manual flow control loop";case Je.ObjectKeys:return"Loop over object keys";case Je.ObjectValues:return"Loop over object values";case Je.Counted:return"Loop given number of times";case Je.String:return"Loop over text characters";case Zt.Addition:return"Sum numbers";case Zt.Subtraction:return"Subtract numbers";case Zt.Multiplication:return"Multiply numbers";case Zt.Division:return"Divide numbers";case Zt.Remainder:return"Get remainder of numbers";case Zt.Exponentiation:return"Get exponent of numbers";case Ge.AddIndex:return"Add at index position";case Ge.DeleteFirst:return"Delete first character";case Ge.DeleteLast:return"Delete last character";case Ge.DeleteIndex:return"Delete at index position";case Ge.Join:return"Join texts";case Ge.ReplaceAllMatches:return"Replace all matches";case Ge.ReplaceFirst:return"Replace first match";case Ge.ReplaceLast:return"Replace last match";case Ge.Split:return"Split text";case Ge.ReplaceIndex:return"Replace at index position";case Ge.ReplaceSingleMatch:return"Replace single match";case Ge.GetFirst:return"Get first character";case Ge.GetLast:return"Get last character";case Ge.GetIndexItem:return"Get at index position";case Ge.GetIndexOf:return"Get the index number of the character";case Ge.Append:return"Add at the end";case Ge.Prepend:return"Add at the start";case tr.Wait:return"Wait";case tr.Parallel:return"Run in parallel";case tr.Sequential:return"Run in sequence";case yi.HttpRequest:return"HTTP request";case pr.CreateNewInstance:return"Create new copy of entity";case Fe.AddIndex:return"Add item at index position";case Fe.DeleteFirst:return"Delete first item";case Fe.DeleteLast:return"Delete last item";case Fe.DeleteIndex:return"Delete item at index position";case Fe.Join:return"Join lists";case Fe.ReplaceFirst:return"Replace first match";case Fe.ReplaceLast:return"Replace last match";case Fe.Split:return"Split list";case Fe.ReplaceIndex:return"Replace at index position";case Fe.GetFirst:return"Get first item";case Fe.GetLast:return"Get last item";case Fe.GetIndexItem:return"Get item at index position";case Fe.Append:return"Add item at the end";case Fe.Prepend:return"Add item at the start";case Ea.PROJECT_PUBLICATION_COMPLETED:return"Project publication completed";default:return(d.name.slice(0,1).toUpperCase()+d.name.slice(1)).replaceAll("-"," ")}}function Y(d,u){var r;if(f.FunctionDeclaration===d.type){const a=d.name;if(Object.values(Wr).includes(a))switch(a){case Wr.AbortExecution:return"Abort ongoing execution";case Wr.DeletePersistedEntity:return"Delete entry from database";case Wr.CreatePersistedEntity:return"Save new data entry in database";case Wr.UpdatePersistedEntity:return"Update entity data to database";default:return Ii(d.type).replaceAll("-"," ")}return a}if(f.BuiltInBaseEntity===d.type)return MS([d.name]);if(Qg.includes(d.type)&&d.type!==f.ActionDescriptor)return d.name;switch(d.type){case f.Search:return US(d);case f.GlobalEvent:return d.implements?Y(d.implements,u):Ii(d.type).replaceAll("-"," ");case f.Operation:case f.InternalCall:case f.Loop:const a=qi(d.declaration,u);return Y(a,u);case f.ActionDescriptor:return jS(d);case f.BreakStatement:const o=qi(d.parent,u);return`Stop loop ${Y(o,u)}`;case f.ContinueStatement:const p=qi(d.parent,u);return`Execute next iteration of ${Y(p,u)}`;case f.FunctionCall:return qi(d.declaration,u).name;case f.Condition:{const y=d;if(y.declaration.id===Kr.And)return"If all conditions are met";if(y.declaration.id===Kr.Or)return"If any condition is met";if((r=d.inputs)!=null&&r.length){const v=Y(y.inputs[0],y.project);if(y.inputs[1]){const E=y.inputs[1].declaration.name;return`If ${v} ${Mm(y)} ${E}`}return`If ${v} ${Mm(y)}`}else return`If ${Mm(y)}`}case f.ReturnStatement:{const y=qi(d.parent,u);return y?`Output of ${Y(y,u)}`:"Return statement"}case f.InputMap:if(d.declaration){const y=qi(d.declaration,u);return Y(y,u)||""}else{if(!d.name)throw new Error(`Input map entity with id "${d.id}" has no name and no declaration.`);return d.name||""}case f.VariableInstance:{const y=qi(d.declaration,u);return Y(y,u)||""}case f.OutputMap:if(d.declaration){const y=qi(d.declaration,u);return(y==null?void 0:y.name)||""}else return d.parentRelationType===Fa.Error?"Undeclared error":"";case f.PrimitiveEntity:case f.LiteralValue:return xS(d);default:return Ii(d.type).replaceAll("-"," ")}}function wb(d,u){const r=[];d.name||r.push(new ae({id:`${d.id}--${se.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:H.Error,code:se.EmptyName}));const a=u.entities.filter(o=>o.name===d.name);return a.length&&r.push(new ae({id:`${d.id}--${se.NameNotUniqueInScope}`,message:`Entity with id "${d.id}" and type "${d.type}" has a name "${d.name}" that is not unique in the project. Entity with id "${a[0].id}" has the same name.
397
397
  Please provide a unique 'name' string.`,severity:H.Error,code:se.NameNotUniqueInScope})),r}function Rb(d,u){const r=[];d.name||r.push(new ae({id:`${d.id}--${se.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:H.Error,code:se.EmptyName}));const a=d.parent?J(d.parent):null;let o=u;a&&(o=u.get(a));const p=[];o.type===f.DefinitionEntity?p.push(...o.methods.map(y=>y)):o.type===f.Project?p.push(...o.functions.map(y=>y)):o.type===f.Loop?o.body&&p.push(o.body):o.type===f.InstalledProject&&p.push(...o.functions.map(y=>y));const e=p.filter(y=>y.name===d.name);return e.length&&r.push(new ae({id:`${d.id}--${se.NameNotUniqueInScope}`,message:`Entity with id "${d.id}" and type "${d.type}" has a name "${d.name}" that is not unique in ${o.type===f.Project?"the globally declared project scope":"its parent entity"}. Entity with id "${e[0].id}" has the same name.
398
398
  Please provide a unique 'name' string.`,severity:H.Error,code:se.NameNotUniqueInScope})),r}function gb(d,u){const r=[];d.name||r.push(new ae({id:`${d.id}--${se.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:H.Error,code:se.EmptyName}));const a=d.parent&&qi(d.parent,u)||u;if(!a)r.push(new ae({id:`${d.id}--parent-reference--${k.ReferencedEntityNotFound}`,message:`The entity with id '${d.parent}' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,severity:H.Error,code:k.ReferencedEntityNotFound}));else{const p=MA(a).filter(e=>e.name===d.name);p.length&&r.push(new ae({id:`${d.id}--${se.NameNotUniqueInScope}`,message:`Entity with id "${d.id}" and type "${d.type}" has a name "${d.name}" that is not unique in its scope or higher scopes. Entity with id "${p[0].id}" has the same name.
399
399
  Please provide a unique 'name' string.`,severity:H.Error,code:se.NameNotUniqueInScope}))}return r}function _b(d,u){const r=[];d.name||r.push(new ae({id:`${d.id}--${se.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:H.Error,code:se.EmptyName}));const a=J(d.parent);if(!a)r.push(new ae({id:`${d.id}--parent-reference--${k.InvalidReferenceObjectStructure}`,message:`Reference object at 'parent' property for entity with id "${d.id}" and type "${d.type}" is not a valid reference. A reference needs to be a 'id' string of an existing entity in the project.`,severity:H.Error,code:k.InvalidReferenceObjectStructure}));else{const o=u.get(a);if(!o)r.push(new ae({id:`${d.id}--parent-reference--${k.ReferencedEntityNotFound}`,message:`The entity with id '${a}' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,severity:H.Error,code:k.ReferencedEntityNotFound}));else{const e=o.properties.filter(y=>y.name===d.name);e.length&&r.push(new ae({id:`${d.id}--${se.NameNotUniqueInScope}`,message:`Entity with id "${d.id}" and type "${d.type}" has a name "${d.name}" that is not unique among all properties in the parent entity. Entity with id "${e[0].id}" has the same name.