@elyx-code/project-logic-tree 0.0.7101 → 0.0.7102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -58,7 +58,7 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
58
58
  `)),!u.includes(" ")&&/\\t/.test(u)&&(u=u.replace(/\\t/g," ")),u=u.replace(/\r\n/g,`
59
59
  `).replace(/\r/g,`
60
60
  `),u=u.replace(/\n/g,`\r
61
- `),u}class WSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:_s+je.GoogleDriveUploadFile,version:"2.0.0",description:"Upload a file to Google Drive (media / import+copy) with auto content detection and simplified inputs.",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Editor,ae.Logic]});D(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(je.GoogleDriveUploadFile);a&&(a.implementation=this.module.main)}},main:async(i,r)=>{var a,c,e,f,h,m,T,b,A,w,I,C,$,L,x,B,q,W,z,H,te,se,Y,ie,ne,pe,ue,me,Te,Ee,Ie,Ce,Le;try{const Ue=((c=(a=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.connection.id}))==null?void 0:a.value)==null?void 0:c.valueAsType)??((f=(e=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.connection.id}))==null?void 0:e.value)==null?void 0:f.value);if(!(Ue instanceof ta))return Tu(i,"Invalid or missing connection entity");const we=((m=(h=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.content.id}))==null?void 0:h.value)==null?void 0:m.valueAsType)??((b=(T=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.content.id}))==null?void 0:T.value)==null?void 0:b.value),Fe=($=((w=(A=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.name.id}))==null?void 0:A.value)==null?void 0:w.valueAsType)??((C=(I=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.name.id}))==null?void 0:I.value)==null?void 0:C.value))==null?void 0:$.trim(),Je=(((x=(L=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.mimeType.id}))==null?void 0:L.value)==null?void 0:x.valueAsType)??((q=(B=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.mimeType.id}))==null?void 0:B.value)==null?void 0:q.value))||"application/octet-stream",Ze=(((z=(W=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.folderId.id}))==null?void 0:W.value)==null?void 0:z.valueAsType)??((te=(H=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.folderId.id}))==null?void 0:H.value)==null?void 0:te.value))||void 0,ct=(((Y=(se=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.description.id}))==null?void 0:se.value)==null?void 0:Y.valueAsType)??((ne=(ie=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.description.id}))==null?void 0:ie.value)==null?void 0:ne.value))||void 0,gt=(((ue=(pe=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.importMimeType.id}))==null?void 0:pe.value)==null?void 0:ue.valueAsType)??((Te=(me=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.importMimeType.id}))==null?void 0:me.value)==null?void 0:Te.value))||"text/plain";if(!Fe)return Tu(i,"Missing required input: name");const dt=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0],st=rd(Ue),Ci={Authorization:`Bearer ${await dt.getAccessToken()}`},Zi=`${((Ee=dt.env)==null?void 0:Ee.API_BASE_URL)+"/editor-runtime"}/v2/external-integrations/proxy/${dt.projectId}/${Nr["google-drive"]}/${st}`,Ct=async(Bi,si,{params:li,body:ma,contentType:Qn,providerHeaders:Fr,responseType:Lr}={})=>{const Yt=`${Zi}/${i$i(si)}`,Kt={...Ci};return Qn&&(Kt["Content-Type"]=Qn),(Fr||Lr)&&(Kt[t$i]=JSON.stringify({...Fr?{headers:Fr}:{},...Lr?{responseType:Lr}:{}})),kr.request({method:Bi,url:Yt,params:li,data:ma,responseType:Lr||"json",headers:Kt})},yt=typeof Je=="string"&&Je.startsWith("application/vnd.google-apps.");if(yt&&(we==null||we==="")){const Bi={name:Fe,mimeType:Je};Ze&&(Bi.parents=[Ze]),typeof ct=="string"&&(Bi.description=ct);const si=await Ct("POST","/drive/v3/files",{params:{supportsAllDrives:"true",fields:TE},body:JSON.stringify(Bi),contentType:"application/json"});return si.status!==200&&si.status!==201?Tu(i,`Drive create failed (status=${si.status})`):WP({file:si.data})}if(yt&&we!=null){let Bi=await n$i(we);const li=((Lr,Yt)=>Yt||(Lr==="application/vnd.google-apps.spreadsheet"?"text/csv":Lr==="application/vnd.google-apps.document"||Lr==="application/vnd.google-apps.presentation"?"text/html":"text/plain"))(Je,gt),ma=li.startsWith("text/")&&!/charset=/i.test(li)?`${li}; charset=UTF-8`:li;li.startsWith("text/csv")&&(Bi=a$i(Bi));const Qn=new TextEncoder().encode(Bi);if(Qn.byteLength>rK)return Tu(i,`Text body exceeds simple upload limit (${Qn.byteLength} bytes).`);let Fr;try{const Lr=await Ct("POST","/upload/drive/v3/files",{params:{uploadType:"media",supportsAllDrives:"true",fields:TE},body:Qn,contentType:ma});if(Lr.status!==200&&Lr.status!==201)return Tu(i,`Drive media upload failed (status=${Lr.status})`);if(Fr=(Ie=Lr.data)==null?void 0:Ie.id,!Fr)return Tu(i,"Drive media upload did not return an id");const Yt={name:Fe,mimeType:Je};Ze&&(Yt.parents=[Ze]),typeof ct=="string"&&(Yt.description=ct);const Kt=await Ct("POST",`/drive/v3/files/${encodeURIComponent(Fr)}/copy`,{params:{supportsAllDrives:"true",fields:TE},body:JSON.stringify(Yt),contentType:"application/json"});return Kt.status!==200&&Kt.status!==201?Tu(i,`Drive copy-convert failed (status=${Kt.status})`):WP({file:Kt.data})}finally{if(Fr)try{await Ct("DELETE",`/drive/v3/files/${encodeURIComponent(Fr)}`,{params:{supportsAllDrives:"true"}})}catch{}}}if(we==null)return Tu(i,"Missing content for non-native upload");const{bytes:ri,inferredMime:nt,isBinary:vt}=await r$i(we),Ot=ri.byteLength;if(Ot>rK)return Tu(i,`File too large for simple upload (${Ot} bytes).`);const Ur=await Ct("POST","/upload/drive/v3/files",{params:{uploadType:"media",supportsAllDrives:"true",fields:TE},body:ri,contentType:Je||nt||(vt?"application/octet-stream":"text/plain; charset=UTF-8")});if(Ur.status!==200&&Ur.status!==201)return Tu(i,`Drive media upload failed (status=${Ur.status})`);let Na=Ur.data;const ha=(Ce=Ur.data)==null?void 0:Ce.id;return ha&&(Ze||Fe||ct)&&(Na=await s$i(Ct,ha,Fe,ct,Ze)),WP({file:Na})}catch(Ue){const we=((Le=Ue.response)==null?void 0:Le.data)||Ue.message||Ue;return re.Logger.error("[Google Drive] Upload document failed:",we),{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:we,result:null}}}})}}function WP(s){return{value:K.Success,error:null,result:s}}function Tu(s,u){return re.Logger.log("[Google Drive] Upload error:",u),{value:s.catchesError||s.errorCalls.length?K.CaughtError:K.UnhandledError,error:u,result:null}}async function s$i(s,u,i,r,a){const c={};i&&(c.name=i),typeof r=="string"&&(c.description=r);const e={supportsAllDrives:"true",fields:TE},f={...e};a&&(f.addParents=a,f.removeParents="root");let h=await s("PATCH",`/drive/v3/files/${encodeURIComponent(u)}`,{params:f,body:JSON.stringify(c),contentType:"application/json"});if(h.status>=400&&a&&(h=await s("PATCH",`/drive/v3/files/${encodeURIComponent(u)}`,{params:{...e,addParents:a},body:JSON.stringify(c),contentType:"application/json"})),h.status!==200)throw new Error(`Drive metadata update failed (status=${h.status})`);return h.data}class zSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:_s+je.GoogleGeminiGenerateContent,version:"1.0.0",description:"Send Gmail email operation implementation module",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Editor,ae.Logic]});D(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(je.GoogleGeminiGenerateContent);a&&(a.implementation=this.module.main)}},main:async(i,r)=>{var a,c,e,f,h;try{const m=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation["external-integration--google-gemini--post--generate-content"].inputs.connection.id}),T=(a=m==null?void 0:m.value)==null?void 0:a.valueAsType;if(!T)return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:"No entity template provided",result:null};if(!(T instanceof ta))return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:"Invalid entity template value provided",result:null};const b=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation["external-integration--google-gemini--post--generate-content"].inputs.prompt.id}),A=(c=b==null?void 0:b.value)==null?void 0:c.value;if(!A||typeof A!="string")return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:"Invalid prompt value provided",result:null};const w=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation["external-integration--google-gemini--post--generate-content"].inputs.model.id}),I=(e=w==null?void 0:w.value)==null?void 0:e.value;if(!I||typeof I!="string")return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:"Invalid model value provided",result:null};const C=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0],$=rd(T);console.log("Triggering Google Gemini generate content action with connectionId:",$);const L=await(await kr.post(`${(f=C.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/trigger-action/${Nr["google-gemini"]}/${$}/generate-content`,{payload:{prompt:A,model:I}},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${await C.getAccessToken()}`}})).data;return re.Logger.log("[Google Gemini] Generate content action response:",L),{value:K.Success,error:null,result:{content:L.content}}}catch(m){const T=((h=m.response)==null?void 0:h.data)||m.message||m;return re.Logger.error("[Google Gemini] Generate content failed:",T),{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:T,result:null}}}})}}class YSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_UPLOAD_FILE,version:"1.0.0",description:"Cloud File System: Upload File",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.UploadFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"uploadFile"),A="["+qe(i,i.project,"Upload file")+": `"+T+"`] ",w=r.find(me=>{var Te,Ee;return((Ee=(Te=me.valueOwner)==null?void 0:Te.declaration)==null?void 0:Ee.id)===U.operation[ke.UploadFile].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(me=>me.resourceId===C))throw new Error(`${A}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const L=r.find(me=>{var Te,Ee;return((Ee=(Te=me.valueOwner)==null?void 0:Te.declaration)==null?void 0:Ee.id)===U.operation[ke.UploadFile].inputs.key.id}),x=(e=L==null?void 0:L.value)==null?void 0:e.value;if(!x||x==="")throw new Error(`${A}The "${qe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof x!="string")throw new Error(`${A}The "${qe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const B=r.find(me=>{var Te,Ee;return((Ee=(Te=me.valueOwner)==null?void 0:Te.declaration)==null?void 0:Ee.id)===U.operation[ke.UploadFile].inputs.file.id}),q=(f=B==null?void 0:B.value)==null?void 0:f.value;if(!q)throw new Error(`${A}The "${qe(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"File")}" (\`${ft(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"file")}\`) input is missing'`);if(typeof q!="object"||!q.uri||typeof q.uri!="string")throw new Error(`${A}The "${qe(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"File")}" (\`${ft(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"file")}\`) input is invalid, should be an object with a text 'uri' property`);const W=q.uri,z=q.mimeType||"application/octet-stream",H=x,se=(h=(await kr.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files?bucket=${C}&key=${encodeURIComponent(H)}&contentType=${encodeURIComponent(z)}`,{},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}})).data)==null?void 0:h.uploadUrl;if(!se)throw new Error(`${A}Failed to retrieve pre-signed upload URL.`);let Y;if(W.startsWith("http://")||W.startsWith("https://"))try{const me=await m.getAccessToken();me&&(Y={Authorization:`Bearer ${me}`})}catch{}const ie=await fetch(W,{headers:Y});if(!ie.ok&&!W.startsWith("data:")&&!W.startsWith("blob:"))throw new Error(`${A}Failed to fetch file content from '${W}' (status: ${ie.status})`);const ne=await ie.blob();await kr.put(se,ne,{headers:{"Content-Type":z}});const ue={uri:`${m.env.API_BASE_URL}/cloud-files-service/v1/files/download?bucket=${C}&key=${encodeURIComponent(H)}`,name:H.split("/").pop()||H,mimeType:z,size:ne.size};return{value:K.Success,error:null,result:ue}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class JSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_DOWNLOAD_FILE,version:"1.0.0",description:"Cloud File System: Download File",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.DownloadFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"downloadFile"),T="["+qe(i,i.project,"Download file")+": `"+h+"`] ",b=r.find(z=>{var H,te;return((te=(H=z.valueOwner)==null?void 0:H.declaration)==null?void 0:te.id)===U.operation[ke.DownloadFile].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(z=>z.resourceId===w))throw new Error("The provided storage is not live. Publish the project first, then try again to run the operation node.");const C=r.find(z=>{var H,te;return((te=(H=z.valueOwner)==null?void 0:H.declaration)==null?void 0:te.id)===U.operation[ke.DownloadFile].inputs.key.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value;if(!$||$==="")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof $!="string")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=z=>{var Y;if(!z)return"application/octet-stream";const H=z.split(".");if(H.length===1)return"application/octet-stream";const te=(Y=H.pop())==null?void 0:Y.toLowerCase();return{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",pdf:"application/pdf",txt:"text/plain",html:"text/html",csv:"text/csv",json:"application/json",mp4:"video/mp4"}[te]||"application/octet-stream"};let x=0,B=L($);try{const z=await kr.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/metadata?bucket=${w}&key=${encodeURIComponent($)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});z.data&&(typeof z.data.size=="number"&&(x=z.data.size),z.data.mimeType&&z.data.mimeType!=="application/octet-stream"&&(B=z.data.mimeType))}catch{}const W={uri:`${f.env.API_BASE_URL}/cloud-files-service/v1/files/download?bucket=${w}&key=${encodeURIComponent($)}`,name:$.split("/").pop()||$,mimeType:B,size:x};return{value:K.Success,error:null,result:W}}catch(f){return{value:K.UnhandledError,error:f,result:null}}}})}}class QSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_LIST_FILES,version:"1.0.0",description:"Cloud File System: List Files",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.ListFiles);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"listFiles"),A="["+qe(i,i.project,"List files")+": `"+T+"`] ",w=r.find(Te=>{var Ee,Ie;return((Ie=(Ee=Te.valueOwner)==null?void 0:Ee.declaration)==null?void 0:Ie.id)===U.operation[ke.ListFiles].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(Te=>Te.resourceId===C))throw new Error(`${A}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const L=r.find(Te=>{var Ee,Ie;return((Ie=(Ee=Te.valueOwner)==null?void 0:Ee.declaration)==null?void 0:Ie.id)===U.operation[ke.ListFiles].inputs.path.id}),x=(e=L==null?void 0:L.value)==null?void 0:e.value;if(x!==void 0&&(typeof x!="string"||x===""))throw new Error(`${A}The "${qe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Path")}" (\`${ft(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"path")}\`) input value is invalid, if present, it must be a non-empty string.`);const B=r.find(Te=>{var Ee,Ie;return((Ie=(Ee=Te.valueOwner)==null?void 0:Ee.declaration)==null?void 0:Ie.id)===U.operation[ke.ListFiles].inputs.maxKeys.id}),q=(f=B==null?void 0:B.value)==null?void 0:f.value;if(q!==void 0&&(typeof q!="number"||q<=0))throw new Error(`${A}The "${qe(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"Max results")}" (\`${ft(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"maxKeys")}\`) input value is invalid, if present, it must be a number greater than 0.`);const W=r.find(Te=>{var Ee,Ie;return((Ie=(Ee=Te.valueOwner)==null?void 0:Ee.declaration)==null?void 0:Ie.id)===U.operation[ke.ListFiles].inputs.startAfter.id}),z=(h=W==null?void 0:W.value)==null?void 0:h.value;if(z!==void 0&&(typeof z!="string"||z===""))throw new Error(`${A}The "${qe(W==null?void 0:W.valueOwner,m==null?void 0:m.logic,"Start after")}" (\`${ft(W==null?void 0:W.valueOwner,m==null?void 0:m.logic,"startAfter")}\`) input value is invalid, if present, it must be a non-empty string.`);let H=`${m.env.API_BASE_URL}/cloud-files-service/v1/files?bucket=${C}`;x&&(H+=`&path=${encodeURIComponent(x)}`),q&&(H+=`&maxKeys=${q}`),z&&(H+=`&startAfter=${encodeURIComponent(z)}`);const te=await kr.get(H,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}}),se=Te=>{var Le;if(!Te)return"application/octet-stream";const Ee=Te.split(".");if(Ee.length===1)return"application/octet-stream";const Ie=(Le=Ee.pop())==null?void 0:Le.toLowerCase();return{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",pdf:"application/pdf",txt:"text/plain",html:"text/html",csv:"text/csv",json:"application/json",mp4:"video/mp4"}[Ie]||"application/octet-stream"},ie=(te.data.items||te.data.files||[]).map(Te=>{var Ee;return{uri:Te.uri||Te.url||`${m.env.API_BASE_URL}/cloud-files-service/v1/files/download?bucket=${C}&key=${encodeURIComponent(Te.key)}`,name:Te.name||((Ee=Te.key)==null?void 0:Ee.split("/").pop())||Te.key,key:Te.key,mimeType:Te.mimeType||se(Te.key),size:Te.size||0,lastModified:Te.lastModified||Te.lastModifiedDate,access:Te.access}}),ne=te.data.total!==void 0?te.data.total:ie.length,pe=te.data.size!==void 0?te.data.size:ie.reduce((Te,Ee)=>Te+(Ee.size||0),0),ue=te.data.nextStartAfter!==void 0?te.data.nextStartAfter:null,me=te.data.hasMore!==void 0?te.data.hasMore:!1;return{value:K.Success,error:null,result:{items:ie,total:ne,size:pe,nextStartAfter:ue,hasMore:me}}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class XSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_DELETE_FILES,version:"1.0.0",description:"Cloud File System: Delete Files",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.DeleteFiles);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"deleteFiles"),T="["+qe(i,i.project,"Delete files")+": `"+h+"`] ",b=r.find(B=>{var q,W;return((W=(q=B.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===U.operation[ke.DeleteFiles].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(B=>B.resourceId===w))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const C=r.find(B=>{var q,W;return((W=(q=B.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===U.operation[ke.DeleteFiles].inputs.keys.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value,L=Array.isArray($)?$:typeof $=="string"&&$!==""?[$]:[];if(!L||L.length===0)throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Keys")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"keys")}\`) input is missing.`);if(!Array.isArray(L)||L.some(B=>typeof B!="string"||B===""))throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Keys")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"keys")}\`) input value is invalid, if present, it must be a list of non-empty strings.`);const x=await kr.delete(`${f.env.API_BASE_URL}/cloud-files-service/v1/files`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`},data:{bucket:w,keys:L}});return{value:K.Success,error:null,result:x.data}}catch(f){return{value:K.UnhandledError,error:f,result:null}}}})}}class eqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_COPY_FILE,version:"1.0.0",description:"Cloud File System: Copy File",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.CopyFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const b=ft(i,i.project,"copyFile"),w="["+qe(i,i.project,"Copy file")+": `"+b+"`] ",I=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.CopyFile].inputs.bucket.id}),C=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!C||!C.id||!C.name||C.type!==d.DefinitionEntity)throw new Error(`${w}Invalid input "${qe(I==null?void 0:I.valueOwner,T==null?void 0:T.logic,"Storage")}" (\`${ft(I==null?void 0:I.valueOwner,T==null?void 0:T.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const $=Ca(C==null?void 0:C.id,((c=T.branchHead)==null?void 0:c.identifier)||"main");if(!((T==null?void 0:T.liveResources)||[]).find(ne=>ne.resourceId===$))throw new Error(`${w}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const x=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.CopyFile].inputs.sourceKey.id}),B=(e=x==null?void 0:x.value)==null?void 0:e.value;if(!B||B==="")throw new Error(`${w}The "${qe(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${ft(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${w}The "${qe(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${ft(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.CopyFile].inputs.destinationKey.id}),W=(f=q==null?void 0:q.value)==null?void 0:f.value;if(!W||W==="")throw new Error(`${w}The "${qe(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${ft(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input is missing.`);if(typeof W!="string")throw new Error(`${w}The "${qe(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${ft(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const z=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.CopyFile].inputs.destinationBucket.id}),H=(h=z==null?void 0:z.value)==null?void 0:h.valueAsType;if(H&&(!H.id||!H.name||H.type!==d.DefinitionEntity))throw new Error(`${w}Invalid input "${qe(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,"Destination Storage")}" (\`${ft(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,"destinationBucket")}\`), expected a valid "Cloud file system" node.`);const te=H!=null&&H.id?Ca(H.id,((m=T.branchHead)==null?void 0:m.identifier)||"main"):$;if(!((T==null?void 0:T.liveResources)||[]).find(ne=>ne.resourceId===te))throw new Error(`${w}The destination "Cloud file system" is not live. Publish the project first, then try again to run the operation node.`);const Y={headers:{Authorization:`Bearer ${await T.getAccessToken()}`}},ie=await kr.post(`${T.env.API_BASE_URL}/cloud-files-service/v1/files/copy`,{bucket:$,destinationBucket:te,sourceKey:B,destinationKey:W},Y);return{value:K.Success,error:null,result:ie.data}}catch(T){return{value:K.UnhandledError,error:T,result:null}}}})}}class tqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_MOVE_FILE,version:"1.0.0",description:"Cloud File System: Move File",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.MoveFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const b=ft(i,i.project,"moveFile"),w="["+qe(i,i.project,"Move file")+": `"+b+"`] ",I=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.MoveFile].inputs.bucket.id}),C=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!C||!C.id||!C.name||C.type!==d.DefinitionEntity)throw new Error(`${w}Invalid input "${qe(I==null?void 0:I.valueOwner,T==null?void 0:T.logic,"Storage")}" (\`${ft(I==null?void 0:I.valueOwner,T==null?void 0:T.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const $=Ca(C==null?void 0:C.id,((c=T.branchHead)==null?void 0:c.identifier)||"main");if(!((T==null?void 0:T.liveResources)||[]).find(ne=>ne.resourceId===$))throw new Error(`${w}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const x=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.MoveFile].inputs.sourceKey.id}),B=(e=x==null?void 0:x.value)==null?void 0:e.value;if(!B||B==="")throw new Error(`${w}The "${qe(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${ft(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${w}The "${qe(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${ft(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.MoveFile].inputs.destinationKey.id}),W=(f=q==null?void 0:q.value)==null?void 0:f.value;if(!W||W==="")throw new Error(`${w}The "${qe(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${ft(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input is missing.`);if(typeof W!="string")throw new Error(`${w}The "${qe(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${ft(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const z=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.MoveFile].inputs.destinationBucket.id}),H=(h=z==null?void 0:z.value)==null?void 0:h.valueAsType;if(H&&(!H.id||!H.name||H.type!==d.DefinitionEntity))throw new Error(`${w}Invalid input "${qe(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,"Destination storage")}" (\`${ft(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,"destinationBucket")}\`), expected a valid "Cloud file system" node.`);const te=H!=null&&H.id?Ca(H.id,((m=T.branchHead)==null?void 0:m.identifier)||"main"):$;if(!((T==null?void 0:T.liveResources)||[]).find(ne=>ne.resourceId===te))throw new Error(`${w}The destination "Cloud file system" is not live. Publish the project first, then try again to run the operation node.`);const Y={headers:{Authorization:`Bearer ${await T.getAccessToken()}`}},ie=await kr.post(`${T.env.API_BASE_URL}/cloud-files-service/v1/files/move`,{bucket:$,destinationBucket:te,sourceKey:B,destinationKey:W},Y);return{value:K.Success,error:null,result:ie.data}}catch(T){return{value:K.UnhandledError,error:T,result:null}}}})}}class iqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_RENAME_FILE,version:"1.0.0",description:"Cloud File System: Rename File",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.RenameFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=ft(i,i.project,"renameFile"),b="["+qe(i,i.project,"Rename file")+": `"+m+"`] ",A=r.find(se=>{var Y,ie;return((ie=(Y=se.valueOwner)==null?void 0:Y.declaration)==null?void 0:ie.id)===U.operation[ke.RenameFile].inputs.bucket.id}),w=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!w||!w.id||!w.name||w.type!==d.DefinitionEntity)throw new Error(`${b}Invalid input "${qe(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${ft(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=Ca(w==null?void 0:w.id,((c=h.branchHead)==null?void 0:c.identifier)||"main");if(!((h==null?void 0:h.liveResources)||[]).find(se=>se.resourceId===I))throw new Error(`${b}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const $=r.find(se=>{var Y,ie;return((ie=(Y=se.valueOwner)==null?void 0:Y.declaration)==null?void 0:ie.id)===U.operation[ke.RenameFile].inputs.key.id}),L=(e=$==null?void 0:$.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${b}The "${qe($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${b}The "${qe($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const x=r.find(se=>{var Y,ie;return((ie=(Y=se.valueOwner)==null?void 0:Y.declaration)==null?void 0:ie.id)===U.operation[ke.RenameFile].inputs.newName.id}),B=(f=x==null?void 0:x.value)==null?void 0:f.value;if(!B||B==="")throw new Error(`${b}The "${qe(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"New name")}" (\`${ft(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"newName")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${b}The "${qe(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"New name")}" (\`${ft(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"newName")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=L.lastIndexOf("/"),z=`${q!==-1?L.substring(0,q+1):""}${B}`,H={headers:{Authorization:`Bearer ${await h.getAccessToken()}`}},te=await kr.post(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/rename`,{bucket:I,key:L,newName:B},H);return{value:K.Success,error:null,result:te.data||{key:L,newName:B,destinationKey:z}}}catch(h){return{value:K.UnhandledError,error:h,result:null}}}})}}class rqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_FILE_METADATA,version:"1.0.0",description:"Cloud File System: Get File Metadata",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.GetFileMetadata);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"getFileMetadata"),T="["+qe(i,i.project,"Get file metadata")+": `"+h+"`] ",b=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.GetFileMetadata].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(x=>x.resourceId===w))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const C=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.GetFileMetadata].inputs.key.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value;if(!$||$==="")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof $!="string")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=await kr.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/metadata?bucket=${w}&key=${encodeURIComponent($)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});return{value:K.Success,error:null,result:L.data}}catch(f){return{value:K.UnhandledError,error:f,result:null}}}})}}class nqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CHECK_FILE_EXISTS,version:"1.0.0",description:"Cloud File System: Check File Exists",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.CheckFileExists);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"checkFileExists"),T="["+qe(i,i.project,"Check File Exists")+": `"+h+"`] ",b=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.CheckFileExists].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(x=>x.resourceId===w))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const C=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.CheckFileExists].inputs.key.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value;if(!$||$==="")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof $!="string")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=await kr.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/exists?bucket=${w}&key=${encodeURIComponent($)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});return{value:K.Success,error:null,result:L.data.exists}}catch(f){return{value:K.UnhandledError,error:f,result:!1}}}})}}class aqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_PRESIGNED_URL,version:"1.0.0",description:"Cloud File System: Get Pre-signed URL",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.GetPresignedUrl);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"getPresignedUrl"),A="["+qe(i,i.project,"Get pre-signed URL")+": `"+T+"`] ",w=r.find(ie=>{var ne,pe;return((pe=(ne=ie.valueOwner)==null?void 0:ne.declaration)==null?void 0:pe.id)===U.operation[ke.GetPresignedUrl].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(ie=>ie.resourceId===C))throw new Error(`${A}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const L=r.find(ie=>{var ne,pe;return((pe=(ne=ie.valueOwner)==null?void 0:ne.declaration)==null?void 0:pe.id)===U.operation[ke.GetPresignedUrl].inputs.key.id}),x=(e=L==null?void 0:L.value)==null?void 0:e.value;if(!x||x==="")throw new Error(`${A}The "${qe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof x!="string")throw new Error(`${A}The "${qe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const B=r.find(ie=>{var ne,pe;return((pe=(ne=ie.valueOwner)==null?void 0:ne.declaration)==null?void 0:pe.id)===U.operation[ke.GetPresignedUrl].inputs.action.id}),q=(f=B==null?void 0:B.value)==null?void 0:f.value,W=(q||"read").toLowerCase(),z=["read","write","delete","metadata","upload","putobject","head","headobject","getobject","get"];if(!q||q==="")throw new Error(`${A}The "${qe(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"Action")}" (\`${ft(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"action")}\`) input is missing.`);if(!z.includes(W))throw new Error(`${A}Invalid "${qe(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"Action")}" (\`${ft(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"action")}\`) input value, must be one of "read", "write", "delete" or "metadata".`);const H=r.find(ie=>{var ne,pe;return((pe=(ne=ie.valueOwner)==null?void 0:ne.declaration)==null?void 0:pe.id)===U.operation[ke.GetPresignedUrl].inputs.expiresInSeconds.id}),te=(h=H==null?void 0:H.value)==null?void 0:h.value,se=te!=null?Number(te):3600;if(isNaN(se)||se<=0)throw new Error(`${A}Invalid "${qe(H==null?void 0:H.valueOwner,m==null?void 0:m.logic,"Expires in seconds")}" (\`${ft(H==null?void 0:H.valueOwner,m==null?void 0:m.logic,"expiresInSeconds")}\`) input value, expected a positive number.`);const Y=await kr.get(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/presigned-url?bucket=${C}&key=${encodeURIComponent(x)}&action=${W}&expiresInSeconds=${se}`,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:K.Success,error:null,result:Y.data}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class sqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_SET_FILE_ACCESS,version:"1.0.0",description:"Cloud File System: Set File Access",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.SetFileAccess);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=ft(i,i.project,"setFileAccess"),b="["+qe(i,i.project,"Set file access")+": `"+m+"`] ",A=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.SetFileAccess].inputs.bucket.id}),w=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!w||!w.id||!w.name||w.type!==d.DefinitionEntity)throw new Error(`${b}Invalid input "${qe(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${ft(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=Ca(w==null?void 0:w.id,((c=h.branchHead)==null?void 0:c.identifier)||"main");if(!((h==null?void 0:h.liveResources)||[]).find(q=>q.resourceId===I))throw new Error(`${b}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const $=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.SetFileAccess].inputs.key.id}),L=(e=$==null?void 0:$.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${b}The "${qe($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${b}The "${qe($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const x=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.SetFileAccess].inputs.access.id}),B=((f=x==null?void 0:x.value)==null?void 0:f.value)??"private";if(!B||B==="")throw new Error(`${b}The "${qe(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"Access")}" (\`${ft(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"access")}\`) input is missing.`);if(typeof B!="string"||!["public","private"].includes(B))throw new Error(`${b}The "${qe(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"Access")}" (\`${ft(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"access")}\`) input value is invalid, if present, it must be exactly the "public" or "private" text values.`);return await kr.post(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/access`,{bucket:I,key:L,access:B},{headers:{Authorization:`Bearer ${await h.getAccessToken()}`}}),{value:K.Success,error:null,result:null}}catch(h){return{value:K.UnhandledError,error:h,result:null}}}})}}class lqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CREATE_FOLDER,version:"1.0.0",description:"Cloud File System: Create Folder",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.CreateFolder);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"createFolder"),T="["+qe(i,i.project,"Create folder")+": `"+h+"`] ",b=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.CreateFolder].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(x=>x.resourceId===w))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const C=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.CreateFolder].inputs.folderPath.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value;if(!$||$==="")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Folder path")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"folderPath")}\`) input is missing.`);if(typeof $!="string")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Folder path")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"folderPath")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=await kr.post(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/folder`,{bucket:w,folderPath:$},{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});return{value:K.Success,error:null,result:L.data}}catch(f){return{value:K.UnhandledError,error:f,result:null}}}})}}class oqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_DELETE_FOLDERS,version:"1.0.0",description:"Cloud File System: Delete Folders",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.DeleteFolders);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"deleteFolders"),T="["+qe(i,i.project,"Delete folders")+": `"+h+"`] ",b=r.find(B=>{var q,W;return((W=(q=B.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===U.operation[ke.DeleteFolders].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(B=>B.resourceId===w))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const C=r.find(B=>{var q,W;return((W=(q=B.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===U.operation[ke.DeleteFolders].inputs.folderPaths.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value,L=Array.isArray($)?$:typeof $=="string"&&$!==""?[$]:[];if(!L||L.length===0)throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Folder paths")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"folderPaths")}\`) input is missing.`);if(!Array.isArray(L)||L.some(B=>typeof B!="string"||B===""))throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Folder paths")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"folderPaths")}\`) input value is invalid, if present, it must be a list of non-empty strings.`);const x=await kr.delete(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/folders`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`},data:{bucket:w,folderPaths:L}});return{value:K.Success,error:null,result:x.data}}catch(f){return{value:K.UnhandledError,error:f,result:null}}}})}}class dqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CREATE_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Create Multipart Upload",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.CreateMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"createMultipartUpload"),A="["+qe(i,i.project,"Create multipart upload")+": `"+T+"`] ",w=r.find(W=>{var z,H;return((H=(z=W.valueOwner)==null?void 0:z.declaration)==null?void 0:H.id)===U.operation[ke.CreateMultipartUpload].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),$=r.find(W=>{var z,H;return((H=(z=W.valueOwner)==null?void 0:z.declaration)==null?void 0:H.id)===U.operation[ke.CreateMultipartUpload].inputs.key.id}),L=(e=$==null?void 0:$.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const x=r.find(W=>{var z,H;return((H=(z=W.valueOwner)==null?void 0:z.declaration)==null?void 0:H.id)===U.operation[ke.CreateMultipartUpload].inputs.contentType.id}),B=((f=x==null?void 0:x.value)==null?void 0:f.value)||"application/octet-stream";if(!B||B==="")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Content Type")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"contentType")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Content Type")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"contentType")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=await kr.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart?bucket=${C}&key=${encodeURIComponent(L)}&contentType=${encodeURIComponent(B)}`,{},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:K.Success,error:null,result:{uploadId:typeof q.data=="object"&&((h=q.data)!=null&&h.uploadId)?q.data.uploadId:q.data}}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class uqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_UPLOAD_PART_PRESIGNED_URL,version:"1.0.0",description:"Cloud File System: Get Upload Part Pre-signed URL",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.GetUploadPartPresignedUrl);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"getUploadPartPresignedUrl"),A="["+qe(i,i.project,"Get upload part pre-signed URL")+": `"+T+"`] ",w=r.find(H=>{var te,se;return((se=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:se.id)===U.operation[ke.GetUploadPartPresignedUrl].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),$=r.find(H=>{var te,se;return((se=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:se.id)===U.operation[ke.GetUploadPartPresignedUrl].inputs.key.id}),L=(e=$==null?void 0:$.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const x=r.find(H=>{var te,se;return((se=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:se.id)===U.operation[ke.GetUploadPartPresignedUrl].inputs.uploadId.id}),B=(f=x==null?void 0:x.value)==null?void 0:f.value;if(!B||B==="")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=r.find(H=>{var te,se;return((se=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:se.id)===U.operation[ke.GetUploadPartPresignedUrl].inputs.partNumber.id}),W=Number((h=q==null?void 0:q.value)==null?void 0:h.value);if(isNaN(W)||W<=0)throw new Error(`${A}The "${qe(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"Part number")}" (\`${ft(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"partNumber")}\`) input is missing or invalid.`);const z=await kr.get(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${B}?bucket=${C}&key=${encodeURIComponent(L)}&partNumber=${W}`,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:K.Success,error:null,result:z.data}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class pqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_COMPLETE_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Complete Multipart Upload",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.CompleteMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"completeMultipartUpload"),A="["+qe(i,i.project,"Complete multipart upload")+": `"+T+"`] ",w=r.find(te=>{var se,Y;return((Y=(se=te.valueOwner)==null?void 0:se.declaration)==null?void 0:Y.id)===U.operation[ke.CompleteMultipartUpload].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),$=r.find(te=>{var se,Y;return((Y=(se=te.valueOwner)==null?void 0:se.declaration)==null?void 0:Y.id)===U.operation[ke.CompleteMultipartUpload].inputs.key.id}),L=(e=$==null?void 0:$.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const x=r.find(te=>{var se,Y;return((Y=(se=te.valueOwner)==null?void 0:se.declaration)==null?void 0:Y.id)===U.operation[ke.CompleteMultipartUpload].inputs.uploadId.id}),B=(f=x==null?void 0:x.value)==null?void 0:f.value;if(!B||B==="")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=r.find(te=>{var se,Y;return((Y=(se=te.valueOwner)==null?void 0:se.declaration)==null?void 0:Y.id)===U.operation[ke.CompleteMultipartUpload].inputs.parts.id}),W=(h=q==null?void 0:q.value)==null?void 0:h.value;if(!Array.isArray(W)||W.length===0)throw new Error(`${A}The "${qe(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"Parts")}" (\`${ft(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"parts")}\`) input is missing or empty.`);if(W.some(te=>{let se=!1,Y=!1;return(te.partNumber&&Number(te.partNumber)>0||te.PartNumber&&Number(te.PartNumber)>0)&&(se=!0),(te.etag&&typeof te.etag=="string"||te.ETag&&typeof te.ETag=="string")&&(Y=!0),!se||!Y}))throw new Error(`${A}The "${qe(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"Parts")}" (\`${ft(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"parts")}\`) input value is invalid, if present, it must be an array of objects with "partNumber" and "etag" properties.`);const H=(await kr.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${B}/complete?bucket=${C}&key=${encodeURIComponent(L)}`,{parts:W},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}})).data||{};return{value:K.Success,error:null,result:{location:H.location||H.Location||L,key:H.key||H.Key||L,etag:H.etag||H.ETag||null}}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class cqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_ABORT_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Abort Multipart Upload",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.AbortMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=ft(i,i.project,"abortMultipartUpload"),b="["+qe(i,i.project,"Abort multipart upload")+": `"+m+"`] ",A=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.AbortMultipartUpload].inputs.bucket.id}),w=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!w||!w.id||!w.name||w.type!==d.DefinitionEntity)throw new Error(`${b}Invalid input "${qe(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${ft(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=Ca(w==null?void 0:w.id,((c=h.branchHead)==null?void 0:c.identifier)||"main"),C=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.AbortMultipartUpload].inputs.key.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value;if(!$||$==="")throw new Error(`${b}The "${qe(C==null?void 0:C.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof $!="string")throw new Error(`${b}The "${qe(C==null?void 0:C.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.AbortMultipartUpload].inputs.uploadId.id}),x=(f=L==null?void 0:L.value)==null?void 0:f.value;if(!x||x==="")throw new Error(`${b}The "${qe(L==null?void 0:L.valueOwner,h==null?void 0:h.logic,"Upload ID")}" (\`${ft(L==null?void 0:L.valueOwner,h==null?void 0:h.logic,"uploadId")}\`) input is missing.`);if(typeof x!="string")throw new Error(`${b}The "${qe(L==null?void 0:L.valueOwner,h==null?void 0:h.logic,"Upload ID")}" (\`${ft(L==null?void 0:L.valueOwner,h==null?void 0:h.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const B=await kr.delete(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${x}?bucket=${I}&key=${encodeURIComponent($)}`,{headers:{Authorization:`Bearer ${await h.getAccessToken()}`}});return{value:K.Success,error:null,result:B.data}}catch(h){return{value:K.UnhandledError,error:h,result:null}}}})}}class l$i extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_UPLOAD_FILE_PART,version:"1.0.0",description:"Cloud File System: Upload File Part",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.UploadFilePart);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m,T,b,A;try{const w=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!w||!w.env)throw new Error("Editor context or environment missing");const I=ft(i,i.project,"uploadFilePart"),$="["+qe(i,i.project,"Upload file part")+": `"+I+"`] ",L=r.find(Ie=>{var Ce,Le;return((Le=(Ce=Ie.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Le.id)===U.operation[ke.UploadFilePart].inputs.bucket.id}),x=(a=L==null?void 0:L.value)==null?void 0:a.valueAsType;if(!x||!x.id||!x.name||x.type!==d.DefinitionEntity)throw new Error(`${$}Invalid input "${qe(L==null?void 0:L.valueOwner,w==null?void 0:w.logic,"Storage")}" (\`${ft(L==null?void 0:L.valueOwner,w==null?void 0:w.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const B=Ca(x==null?void 0:x.id,((c=w.branchHead)==null?void 0:c.identifier)||"main");if(!((w==null?void 0:w.liveResources)||[]).find(Ie=>Ie.resourceId===B))throw new Error(`${$}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const W=r.find(Ie=>{var Ce,Le;return((Le=(Ce=Ie.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Le.id)===U.operation[ke.UploadFilePart].inputs.key.id}),z=(e=W==null?void 0:W.value)==null?void 0:e.value;if(!z||z==="")throw new Error(`${$}The "${qe(W==null?void 0:W.valueOwner,w==null?void 0:w.logic,"Key")}" (\`${ft(W==null?void 0:W.valueOwner,w==null?void 0:w.logic,"key")}\`) input is missing.`);if(typeof z!="string")throw new Error(`${$}The "${qe(W==null?void 0:W.valueOwner,w==null?void 0:w.logic,"Key")}" (\`${ft(W==null?void 0:W.valueOwner,w==null?void 0:w.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const H=r.find(Ie=>{var Ce,Le;return((Le=(Ce=Ie.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Le.id)===U.operation[ke.UploadFilePart].inputs.uploadId.id}),te=(f=H==null?void 0:H.value)==null?void 0:f.value;if(!te||te==="")throw new Error(`${$}The "${qe(H==null?void 0:H.valueOwner,w==null?void 0:w.logic,"Upload ID")}" (\`${ft(H==null?void 0:H.valueOwner,w==null?void 0:w.logic,"uploadId")}\`) input is missing.`);if(typeof te!="string")throw new Error(`${$}The "${qe(H==null?void 0:H.valueOwner,w==null?void 0:w.logic,"Upload ID")}" (\`${ft(H==null?void 0:H.valueOwner,w==null?void 0:w.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const se=r.find(Ie=>{var Ce,Le;return((Le=(Ce=Ie.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Le.id)===U.operation[ke.UploadFilePart].inputs.partNumber.id}),Y=Number((h=se==null?void 0:se.value)==null?void 0:h.value);if(((m=se==null?void 0:se.value)==null?void 0:m.value)===void 0||((T=se==null?void 0:se.value)==null?void 0:T.value)===null||isNaN(Y)||Y<=0)throw new Error(`${$}The "${qe(se==null?void 0:se.valueOwner,w==null?void 0:w.logic,"Part number")}" (\`${ft(se==null?void 0:se.valueOwner,w==null?void 0:w.logic,"partNumber")}\`) input is missing or invalid.`);const ie=r.find(Ie=>{var Ce,Le;return((Le=(Ce=Ie.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Le.id)===U.operation[ke.UploadFilePart].inputs.bytes.id}),ne=(b=ie==null?void 0:ie.value)==null?void 0:b.value;if(ne==null)throw new Error(`${$}The "${qe(ie==null?void 0:ie.valueOwner,w==null?void 0:w.logic,"Bytes")}" (\`${ft(ie==null?void 0:ie.valueOwner,w==null?void 0:w.logic,"bytes")}\`) input is missing.`);const ue=(A=(await kr.get(`${w.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${te}?bucket=${B}&key=${encodeURIComponent(z)}&partNumber=${Y}`,{headers:{Authorization:`Bearer ${await w.getAccessToken()}`}})).data)==null?void 0:A.uploadUrl;if(!ue)throw new Error(`${$}Failed to obtain presigned upload URL for part ${Y}.`);const me=await kr.put(ue,ne,{headers:{"Content-Type":"application/octet-stream"}}),Te=me.headers.etag||me.headers.ETag||"",Ee=typeof Te=="string"?Te.replace(/"/g,""):"";return{value:K.Success,error:null,result:{partNumber:Y,etag:Ee}}}catch(w){return{value:K.UnhandledError,error:w,result:null}}}})}}class GN extends vD{constructor(u,i,r=i.projectId){super(u,ae.Editor),this._editor=i,this.id=r}get ready(){return this._editor.ready}get env(){return this._editor.env}get hasLoadedLogic(){return this._editor.hasLoadedLogic}get destroyed(){return this._editor.destroyed}get logicLoadingPromise(){return this._editor.logicLoadingPromise}get logic(){return this._editor.logic}get lastPublishedProjectState(){return this._editor.lastPublishedProjectState}get branchHead(){return this._editor.branchHead}get branchHeadPromise(){return this._editor.branchHeadPromise}get projectId(){return this._editor.projectId}get sessionId(){return this._editor.sessionId}get userAuthorId(){return this._editor.userAuthorId}get peerConnections(){return this._editor.peerConnections}get test(){return this._editor.test}get localTestValues(){return this._editor.localTestValues}get resolvedValues(){return this._editor.resolvedValues}get persistedExecutionResults(){return this._editor.persistedExecutionResults}get publication(){return this._editor.publication}get livePublishedVersions(){return this._editor.livePublishedVersions}get publications(){return this._editor.publications}get liveResources(){return this._editor.liveResources}get execution(){return this._editor.execution}get project(){return this._editor.logic}get lastExecutionResults(){return this._editor.lastExecutionResults}get undoableStackValueIndex(){return this._editor.undoableStackValueIndex}set undoableStackValueIndex(u){this._editor.undoableStackValueIndex=u}get activeWorkspace(){return this._editor.activeWorkspace}get branches(){return this._editor.branches}get roles(){return this._editor.roles}get READ_ONLY(){return this._editor.READ_ONLY}get isViewingNonHead(){return this._editor.isViewingNonHead}get canEdit(){return this._editor.canEdit}get PROJECT_NOTIFICATIONS_CHANNEL(){return this._editor.PROJECT_NOTIFICATIONS_CHANNEL}getAccessToken(){return this._editor.getAccessToken()}getRefreshToken(){return this._editor.getRefreshToken()}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,i){return this._editor.initTest(u,i)}removeTest(u){return this._editor.removeTest(u)}async copyEntities(u,i={}){return this._editor.copyEntities(u,i)}resolveInitialChildrenPositions(u,i,r){return this._editor.resolveInitialChildrenPositions(u,i,r)}publish(){return this._editor.publish()}loadGivenPublication(u){return this._editor.loadGivenPublication(u)}validateProjectState(u){return this._editor.validateProjectState(u)}requestActiveDynamicValue(u,i=!1){return this._editor.requestActiveDynamicValue(u,i)}getValueTypePreference(u){return this._editor.getValueTypePreference(u)}setValueTypePreference(u,i){return this._editor.setValueTypePreference(u,i)}implementFeature(u){return this._editor.implementFeature(u)}getProjectRoles(){return this._editor.getProjectRoles()}getLastPublishedVersionLogic(u){return this._editor.getLastPublishedVersionLogic(u)}initialLoads(u){return this._editor.initialLoads(u)}moveBranchHeadToVersion(u,i,r){return this._editor.moveBranchHeadToVersion(u,i,r)}loadInitialBranchHead(){return this._editor.loadInitialBranchHead()}}function o$i(s,u){return u instanceof GN?u:new GN(s,u)}class kN extends vD{constructor(u,i){super(u,ae.PublicationRun),this._publicationRun=i}get id(){return this._publicationRun.id}get projectAutoIncrementPublicationCount(){return this._publicationRun.projectAutoIncrementPublicationCount}get projectPublishedSemanticVersion(){return this._publicationRun.projectPublishedSemanticVersion}get envIdentifier(){return this._publicationRun.envIdentifier}get projectVersion(){return this._publicationRun.projectVersion}get projectBranchId(){return this._publicationRun.projectBranchId}get projectId(){return this._publicationRun.projectId}get triggeredBy(){return this._publicationRun.triggeredBy}get createdAt(){return this._publicationRun.createdAt}get updatedAt(){return this._publicationRun.updatedAt}get status(){return this._publicationRun.status}get steps(){return this._publicationRun.steps}get cleanupSteps(){return this._publicationRun.cleanupSteps}get editor(){return this._publicationRun.editor}get explicitResources(){return this._publicationRun.explicitResources}get implicitGlobalResources(){return this._publicationRun.implicitGlobalResources}get finalGlobalEvent(){return this._publicationRun.finalGlobalEvent}get finalStatus(){return this._publicationRun.finalStatus}}function d$i(s,u){return u instanceof kN?u:new kN(s,u)}function u$i(s){s.register(new VGe(s)),s.register(new xGe(s)),s.register(new OGe(s)),s.register(new PGe(s)),s.register(new NGe(s)),s.register(new _Ge(s)),s.register(new fje(s)),s.register(new yje(s)),s.register(new hje(s)),s.register(new Tje(s)),s.register(new mje(s)),s.register(new vje(s)),s.register(new nSe(s)),s.register(new aSe(s)),s.register(new sSe(s)),s.register(new lSe(s)),s.register(new oSe(s)),s.register(new dSe(s)),s.register(new uSe(s)),s.register(new pSe(s)),s.register(new cSe(s)),s.register(new fSe(s)),s.register(new c4e(s)),s.register(new f4e(s)),s.register(new y4e(s)),s.register(new h4e(s)),s.register(new m4e(s)),s.register(new T4e(s)),s.register(new v4e(s)),s.register(new E4e(s)),s.register(new b4e(s)),s.register(new A4e(s)),s.register(new g4e(s)),s.register(new I4e(s)),s.register(new R4e(s)),s.register(new w4e(s)),s.register(new D4e(s)),s.register(new C4e(s)),s.register(new O4e(s)),s.register(new _4e(s)),s.register(new P4e(s)),s.register(new V4e(s)),s.register(new $4e(s)),s.register(new L4e(s)),s.register(new xFe(s)),s.register(new VFe(s)),s.register(new $Fe(s)),s.register(new LFe(s)),s.register(new BFe(s)),s.register(new MFe(s)),s.register(new GFe(s)),s.register(new kFe(s)),s.register(new UFe(s)),s.register(new jFe(s)),s.register(new KFe(s)),s.register(new SFe(s)),s.register(new qFe(s)),s.register(new ZFe(s)),s.register(new JUe(s)),s.register(new gKe(s)),s.register(new bKe(s)),s.register(new AKe(s)),s.register(new Yke(s)),s.register(new Jke(s)),s.register(new Qke(s)),s.register(new Xke(s)),s.register(new eUe(s)),s.register(new tUe(s)),s.register(new iUe(s)),s.register(new rUe(s)),s.register(new nUe(s)),s.register(new TUe(s)),s.register(new WUe(s)),s.register(new zUe(s)),s.register(new YUe(s)),s.register(new aUe(s)),s.register(new sUe(s)),s.register(new lUe(s)),s.register(new oUe(s)),s.register(new dUe(s)),s.register(new uUe(s)),s.register(new pUe(s)),s.register(new cUe(s)),s.register(new fUe(s)),s.register(new yUe(s)),s.register(new hUe(s)),s.register(new mUe(s)),s.register(new vUe(s)),s.register(new EUe(s)),s.register(new bUe(s)),s.register(new AUe(s)),s.register(new gUe(s)),s.register(new IUe(s)),s.register(new RUe(s)),s.register(new wUe(s)),s.register(new DUe(s)),s.register(new CUe(s)),s.register(new OUe(s)),s.register(new _Ue(s)),s.register(new GUe(s)),s.register(new kUe(s)),s.register(new UUe(s)),s.register(new PUe(s)),s.register(new NUe(s)),s.register(new xUe(s)),s.register(new VUe(s)),s.register(new $Ue(s)),s.register(new LUe(s)),s.register(new BUe(s)),s.register(new MUe(s)),s.register(new DKe(s)),s.register(new CKe(s)),s.register(new OKe(s)),s.register(new _Ke(s)),s.register(new IKe(s)),s.register(new RKe(s)),s.register(new wKe(s)),s.register(new PKe(s)),s.register(new xKe(s)),s.register(new $Ke(s)),s.register(new NKe(s)),s.register(new VKe(s)),s.register(new LKe(s)),s.register(new GKe(s)),s.register(new BKe(s)),s.register(new MKe(s)),s.register(new HFe(s)),s.register(new JFe(s)),s.register(new QFe(s)),s.register(new t4e(s)),s.register(new i4e(s)),s.register(new r4e(s)),s.register(new n4e(s)),s.register(new a4e(s)),s.register(new s4e(s)),s.register(new l4e(s)),s.register(new o4e(s)),s.register(new XFe(s)),s.register(new e4e(s)),s.register(new YSe(s)),s.register(new JSe(s)),s.register(new QSe(s)),s.register(new XSe(s)),s.register(new eqe(s)),s.register(new tqe(s)),s.register(new iqe(s)),s.register(new rqe(s)),s.register(new nqe(s)),s.register(new aqe(s)),s.register(new sqe(s)),s.register(new lqe(s)),s.register(new oqe(s)),s.register(new dqe(s)),s.register(new uqe(s)),s.register(new pqe(s)),s.register(new cqe(s)),s.register(new zFe(s)),s.register(new YFe(s)),s.register(new WFe(s)),s.register(new FFe(s)),s.register(new u4e(s)),s.register(new p4e(s)),s.register(new d4e(s)),s.register(new bje(s)),s.register(new Sje(s)),s.register(new Kje(s)),s.register(new qje(s)),s.register(new Zje(s)),s.register(new Ije(s)),s.register(new Rje(s)),s.register(new Pje(s)),s.register(new Oje(s)),s.register(new Fje(s)),s.register(new Lje(s)),s.register(new Mje(s)),s.register(new kje(s)),s.register(new Gje(s)),s.register(new _je(s)),s.register(new xje(s)),s.register(new Vje(s)),s.register(new Nje(s)),s.register(new Eje(s)),s.register(new wje(s)),s.register(new Bje(s)),s.register(new zje(s)),s.register(new xN(s)),s.register(new gje(s)),s.register(new Dje(s)),s.register(new Aje(s)),s.register(new Uje(s)),s.register(new Cje(s)),s.register(new $je(s)),s.register(new jje(s)),s.register(new Wje(s)),s.register(new Hje(s)),s.register(new Yje(s)),s.register(new xN(s)),s.register(new Qje(s)),s.register(new Jje(s)),s.register(new Xje(s)),s.register(new Y4e(s)),s.register(new J4e(s)),s.register(new Q4e(s)),s.register(new M4e(s)),s.register(new x4e(s)),s.register(new F4e(s)),s.register(new q4e(s)),s.register(new N4e(s)),s.register(new Z4e(s)),s.register(new z4e(s)),s.register(new K4e(s)),s.register(new j4e(s)),s.register(new bR(s)),s.register(new X4e(s)),s.register(new eje(s)),s.register(new S4e(s)),s.register(new W4e(s)),s.register(new H4e(s)),s.register(new U4e(s)),s.register(new k4e(s)),s.register(new G4e(s)),s.register(new B4e(s)),s.register(new rje(s)),s.register(new ije(s)),s.register(new nje(s)),s.register(new tje(s)),s.register(new SUe(s)),s.register(new FUe(s)),s.register(new KUe(s)),s.register(new qUe(s)),s.register(new ZUe(s)),s.register(new jUe(s)),s.register(new HUe(s)),s.register(new mSe(s)),s.register(new gSe(s)),s.register(new RSe(s)),s.register(new DSe(s)),s.register(new ASe(s)),s.register(new ISe(s)),s.register(new wSe(s)),s.register(new bSe(s)),s.register(new ESe(s)),s.register(new vSe(s)),s.register(new TSe(s)),s.register(new ySe(s)),s.register(new hSe(s)),s.register(new NSe(s)),s.register(new xSe(s)),s.register(new _Se(s)),s.register(new PSe(s)),s.register(new rSe(s)),s.register(new CSe(s)),s.register(new OSe(s)),s.register(new $Se(s)),s.register(new VSe(s)),s.register(new LSe(s)),s.register(new BSe(s)),s.register(new MSe(s)),s.register(new $Ge(s)),s.register(new LGe(s)),s.register(new vR(s)),s.register(new ER(s)),s.register(new USe(s)),s.register(new FSe(s)),s.register(new SSe(s)),s.register(new zSe(s)),s.register(new ZSe(s)),s.register(new jSe(s)),s.register(new KSe(s)),s.register(new HSe(s)),s.register(new qSe(s)),s.register(new WSe(s))}class RB{constructor(u=new re.Events("extensions-registry-fallback-events")){D(this,"extensionsRegistry",new Map);D(this,"initialized",new Set);D(this,"initializedContexts",new Set);D(this,"onResolveEditorContextCallback",()=>null);D(this,"onResolveProjectLogicContextCallback",()=>null);D(this,"onResolveEditorGUIContextCallback",()=>null);D(this,"onResolveGUIContextCallback",()=>null);D(this,"onResolveCompileContextCallback",()=>null);D(this,"onResolvePublicationRunContextCallback",()=>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}onResolveEditorGUIContext(u){this.onResolveEditorGUIContextCallback=u}onResolveCompileContext(u){this.onResolveCompileContextCallback=u}onResolvePublicationRunContext(u){this.onResolvePublicationRunContextCallback=u}get extensionInOrder(){return Array.from(this.extensionsRegistry.values()).sort((u,i)=>(u.manifest.initPriority||Oe.Normal)-(i.manifest.initPriority||Oe.Normal))}async setup(){u$i(this),re.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(u){switch(u){case ae.Editor:return this.onResolveEditorContextCallback();case ae.Logic:return this.onResolveProjectLogicContextCallback();case ae.EditorGUI:return this.onResolveEditorGUIContextCallback();case ae.Compile:return this.onResolveCompileContextCallback();case ae.PublicationRun:return this.onResolvePublicationRunContextCallback();case ae.GUI:return this.onResolveGUIContextCallback();case ae.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${u}`)}}requestContexts(u,i=[]){const r=[];i.length===0&&(i=u.manifest.contexts);for(const a of i){const c=this.requestContext(a);c&&r.push(c)}return r}requestExtension(u){const i=this.extensionsRegistry.get(u);if(i)return i;throw new Error(`Unknown extension: ${u}`)}register(u){this.extensionsRegistry.set(u.manifest.id,u)}async initAll(){var u,i;for(const r of this.extensionInOrder)if(r.module.init&&!this.initialized.has(r.manifest.id)){const a=r.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);a.length&&(await((i=(u=r.module).init)==null?void 0:i.call(u,a)),this.initialized.add(r.manifest.id))}else!r.module.init&&!this.initialized.has(r.manifest.id)&&this.initialized.add(r.manifest.id)}async initForReady(){re.Logger.log("Initializing extensions for ready contexts...");for(const u of this.extensionInOrder)if(u.module.init&&!this.initialized.has(u.manifest.id)){re.Logger.debug("Initializing "+u.manifest.id+" extension...");const i=this.requestContexts(u);u.manifest.contexts.every(a=>!!i.find(c=>c.contextType===a))?(await u.module.init(i),this.initialized.add(u.manifest.id)):re.Logger.warn(`Skipping initialization of ${u.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${u.manifest.contexts.join(", ")}`,`Available contexts: ${i.map(a=>a.contextType).join(", ")}`)}else!u.module.init&&!this.initialized.has(u.manifest.id)?(re.Logger.log("Set "+u.manifest.id+" extension as initialized by default..."),this.initialized.add(u.manifest.id)):re.Logger.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,i){this.events.on(u,i)}emit(u,...i){this.events.emit(u,...i)}off(u,i){this.events.off(u,i)}emitAsync(u,...i){return this.events.emitAsync(u,...i)}emitAsyncAll(u,...i){return this.events.emitAsyncAll(u,...i)}emitAsyncAllSettled(u,...i){return this.events.emitAsyncAllSettled(u,...i)}emitAsyncSequentially(u,...i){return this.events.emitAsyncSequentially(u,...i)}emitAsyncSequentiallyAll(u,...i){return this.events.emitAsyncSequentiallyAll(u,...i)}emitAsyncSequentiallyAllSettled(u,...i){return this.events.emitAsyncSequentiallyAllSettled(u,...i)}async contextAvailable(u){if(this.initializedContexts.has(u)){re.Logger.warn(`Context ${u} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(u),u){case ae.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case ae.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}re.Logger.log(`Context ${u} is now available. Initializing extensions for this context...`),await this.initForReady()}getValueTypePreference(u){return window.localStorage.getItem("dynamic-value-type-preference--"+u)||null}setValueTypePreference(u,i){window.localStorage.setItem("dynamic-value-type-preference--"+u,(i==null?void 0:i.toString())||""),this.emit(u,{})}}let jI=null;const wB={requestExtension:s=>(jI||(jI=new RB,jI.setup()),jI.requestExtension(s))};function Oc(s){return!(s instanceof Error)&&typeof s=="object"&&s!==null?s:s instanceof Error?{name:s.name,message:s.message,stack:s.stack,...s}:s}function nK(s){var u,i,r;if(s&&typeof s=="object"&&"value"in s){const a=s;return{single:((u=a.value)==null?void 0:u.valueAsTypeSingle)??((i=a.value)==null?void 0:i.value),list:((r=a.value)==null?void 0:r.valueAsTypeList)??null}}return{single:s,list:Array.isArray(s)?s:null}}const _c={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};class UN extends Error{constructor(){super("Execution was stopped"),this.name="ExecutionStoppedError"}}var DB=(s=>(s.FinishedSuccess="finished-success",s.FinishedError="finished-error",s.Running="running",s.Paused="paused",s.Stopped="stopped",s.NotStarted="not-started",s))(DB||{});const fqe={...wB,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class Lm extends re.Events{constructor(i,r,a,c=null,e=fqe){super();D(this,"project");D(this,"entryPoint");D(this,"state","not-started");D(this,"events",new re.Events("fe-exec-inst-events"));D(this,"entities",[]);D(this,"parentExecution",null);D(this,"executing",[]);D(this,"executed",[]);D(this,"skipped",[]);D(this,"scheduled",[]);D(this,"localTestValues");D(this,"resolvedValues");D(this,"persistedExecutionResults");D(this,"lastExecutionResults");D(this,"onAddToSkippedListCallback",null);D(this,"onRemoveFromSkippedListCallback",null);D(this,"onAddEntityCallback",null);D(this,"onRemoveEntityCallback",null);D(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=r,this.entryPoint=a,this.project=i,this.parentExecution=c,this.localTestValues=new hE(M.UUID.uuid(),this.project),this.resolvedValues=new hE(M.UUID.uuid(),this.project),this.persistedExecutionResults=new hE(M.UUID.uuid(),this.project),this.lastExecutionResults=new hE(M.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults,getValueTypePreference:this.parentContext.getValueTypePreference,setValueTypePreference:this.parentContext.setValueTypePreference}}get rootExecution(){let i=this;for(;i.parentExecution;)i=i.parentExecution;return i}get rootState(){return this.rootExecution.state}isStopped(){return this.state==="stopped"||this.rootExecution.state==="stopped"}isPaused(){return this.state==="paused"||this.rootExecution.state==="paused"}async checkStateAndPause(){if(this.isStopped())throw new UN;for(;this.isPaused();){if(this.isStopped())throw new UN;await new Promise(i=>setTimeout(i,100))}}skip(i){this.hasEntity(i)&&(this.removeFromScheduledList(i),!this.skipped.includes(i)&&(this.skipped.push(i),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(i),Cr.includes(i.type)&&Lt(i).forEach(r=>this.skip(r))))}async schedule(i,r,a){if(this.hasExecuted(i))return null;if(Ei.includes(i.type))return this.executeBranch(i,a,r);if(Or.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,a,r);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,r){const a=[];return vi.includes(r.type)?a.push(...r.inputs.filter(e=>Qy(e))):[...ni,...Ei].includes(r.type)?a.push(...r.inputs):ti.includes(r.type)&&a.push(...r.outputs.filter(e=>Qy(e))),a.map(e=>{var h;let f=i.find(m=>m.valueOwner.id===e.id);if(f)return f;if(!f&&Ei.includes(r.type)&&(f=i.find(m=>{var T;return((T=m.valueOwner.declaration)==null?void 0:T.id)===e.id})),f){const m=(h=f.value)==null?void 0:h.clone(null);return m==null||m.setStandaloneParent(e,null),{...f,valueOwner:e,value:m||null,inheritanceLink:{sources:[f],target:e}}}return kn.includes(e.type)?hd(e,this.valueResolutionContext):Dp(e,this.valueResolutionContext)}).reduce((e,f)=>{const h=wu(f==null?void 0:f.valueOwner,this.project),m=f?[f]:[];return h.forEach(T=>{var w,I,C;if(T.id===(f==null?void 0:f.valueOwner.id))return;const b=ki(T.getDataType(null),T,this.project);b==null||b.metaSync({value:(w=f==null?void 0:f.value)==null?void 0:w.value},null),b==null||b.setValueAsTypeList(((I=f==null?void 0:f.value)==null?void 0:I.valueAsTypeList)||null),b==null||b.setValueAsTypeSingle(((C=f==null?void 0:f.value)==null?void 0:C.valueAsTypeSingle)||null);const A={...f,valueOwner:T,value:b};m.push(A)}),[...e,...m]},[]).sort((e,f)=>e.valueOwner.index-f.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,r,a,c={}){var f,h;this.logBeforeExecution("executeInternalCall",i,r);const e={..._c,...c};try{let m={value:K.Success,error:null,result:null};if(r.sort((C,$)=>C.valueOwner.index-$.valueOwner.index),Object.values(wn).includes(i.declaration.id)){const C=this.parentContext.requestExtension(_s+i.declaration.id).module.main;C?m=await C(i,r,this):re.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{const C=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);m={value:C.value,error:C.error,result:C.result}}let T=null;if(m.error&&i.error){re.Logger.warn("Raw error executing entity: ",m.error);const{single:C,list:$}=nK(m.error),L=Oc(C),x=(f=i.error)==null?void 0:f.getDataType(null),B=ki(x||null,i.error,a);if(x!=null&&x.asType)$!==null?B==null||B.setValueAsTypeList($):B==null||B.setValueAsTypeSingle(C);else{const q=Tn(L)?JSON.stringify(L,null,2):L;B==null||B.metaSync({value:q},null)}T={valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:B}}const b=i==null?void 0:i.getDataType(null),A=ki(b,i,a),{single:w,list:I}=nK(m.result);return b!=null&&b.asType?I!==null?A==null||A.setValueAsTypeList(I):A==null||A.setValueAsTypeSingle(w):A==null||A.metaSync({value:w},null),{value:m.value,entity:i,error:T,result:{value:A||null,valueOwner:i,type:Se.ExecutionResult,inheritanceLink:null}}}catch(m){if(m&&(m.name==="ExecutionStoppedError"||m.message==="Execution was stopped"))throw m;re.Logger.warn("Internal call execution error: ",m);let T=null;if(i.error){const b=Oc(m),A=(h=i.error)==null?void 0:h.getDataType(null),w=ki(A,i.error,a);if(A!=null&&A.asType)w==null||w.setValueAsTypeSingle(m);else{const I=Tn(b)?JSON.stringify(b,null,2):b;w==null||w.metaSync({value:I},null)}T={valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:w}}return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,entity:i,error:T,result:null}}}static async executeOperation(i,r,a,c){var e,f;c?c.logBeforeExecution("executeOperation",i,r):console.log(`executeOperation (${i.type}) -> [${he(i,a)}] Inputs:${r.length?`
61
+ `),u}class WSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:_s+je.GoogleDriveUploadFile,version:"2.0.0",description:"Upload a file to Google Drive (media / import+copy) with auto content detection and simplified inputs.",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Editor,ae.Logic]});D(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(je.GoogleDriveUploadFile);a&&(a.implementation=this.module.main)}},main:async(i,r)=>{var a,c,e,f,h,m,T,b,A,w,I,C,$,L,x,B,q,W,z,H,te,se,Y,ie,ne,pe,ue,me,Te,Ee,Ie,Ce,Le;try{const Ue=((c=(a=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.connection.id}))==null?void 0:a.value)==null?void 0:c.valueAsType)??((f=(e=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.connection.id}))==null?void 0:e.value)==null?void 0:f.value);if(!(Ue instanceof ta))return Tu(i,"Invalid or missing connection entity");const we=((m=(h=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.content.id}))==null?void 0:h.value)==null?void 0:m.valueAsType)??((b=(T=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.content.id}))==null?void 0:T.value)==null?void 0:b.value),Fe=($=((w=(A=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.name.id}))==null?void 0:A.value)==null?void 0:w.valueAsType)??((C=(I=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.name.id}))==null?void 0:I.value)==null?void 0:C.value))==null?void 0:$.trim(),Je=(((x=(L=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.mimeType.id}))==null?void 0:L.value)==null?void 0:x.valueAsType)??((q=(B=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.mimeType.id}))==null?void 0:B.value)==null?void 0:q.value))||"application/octet-stream",Ze=(((z=(W=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.folderId.id}))==null?void 0:W.value)==null?void 0:z.valueAsType)??((te=(H=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.folderId.id}))==null?void 0:H.value)==null?void 0:te.value))||void 0,ct=(((Y=(se=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.description.id}))==null?void 0:se.value)==null?void 0:Y.valueAsType)??((ne=(ie=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.description.id}))==null?void 0:ie.value)==null?void 0:ne.value))||void 0,gt=(((ue=(pe=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.importMimeType.id}))==null?void 0:pe.value)==null?void 0:ue.valueAsType)??((Te=(me=r.find(Bi=>{var si,li;return((li=(si=Bi.valueOwner)==null?void 0:si.declaration)==null?void 0:li.id)===U.operation[je.GoogleDriveUploadFile].inputs.importMimeType.id}))==null?void 0:me.value)==null?void 0:Te.value))||"text/plain";if(!Fe)return Tu(i,"Missing required input: name");const dt=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0],st=rd(Ue),Ci={Authorization:`Bearer ${await dt.getAccessToken()}`},Zi=`${((Ee=dt.env)==null?void 0:Ee.API_BASE_URL)+"/editor-runtime"}/v2/external-integrations/proxy/${dt.projectId}/${Nr["google-drive"]}/${st}`,Ct=async(Bi,si,{params:li,body:ma,contentType:Qn,providerHeaders:Fr,responseType:Lr}={})=>{const Yt=`${Zi}/${i$i(si)}`,Kt={...Ci};return Qn&&(Kt["Content-Type"]=Qn),(Fr||Lr)&&(Kt[t$i]=JSON.stringify({...Fr?{headers:Fr}:{},...Lr?{responseType:Lr}:{}})),kr.request({method:Bi,url:Yt,params:li,data:ma,responseType:Lr||"json",headers:Kt})},yt=typeof Je=="string"&&Je.startsWith("application/vnd.google-apps.");if(yt&&(we==null||we==="")){const Bi={name:Fe,mimeType:Je};Ze&&(Bi.parents=[Ze]),typeof ct=="string"&&(Bi.description=ct);const si=await Ct("POST","/drive/v3/files",{params:{supportsAllDrives:"true",fields:TE},body:JSON.stringify(Bi),contentType:"application/json"});return si.status!==200&&si.status!==201?Tu(i,`Drive create failed (status=${si.status})`):WP({file:si.data})}if(yt&&we!=null){let Bi=await n$i(we);const li=((Lr,Yt)=>Yt||(Lr==="application/vnd.google-apps.spreadsheet"?"text/csv":Lr==="application/vnd.google-apps.document"||Lr==="application/vnd.google-apps.presentation"?"text/html":"text/plain"))(Je,gt),ma=li.startsWith("text/")&&!/charset=/i.test(li)?`${li}; charset=UTF-8`:li;li.startsWith("text/csv")&&(Bi=a$i(Bi));const Qn=new TextEncoder().encode(Bi);if(Qn.byteLength>rK)return Tu(i,`Text body exceeds simple upload limit (${Qn.byteLength} bytes).`);let Fr;try{const Lr=await Ct("POST","/upload/drive/v3/files",{params:{uploadType:"media",supportsAllDrives:"true",fields:TE},body:Qn,contentType:ma});if(Lr.status!==200&&Lr.status!==201)return Tu(i,`Drive media upload failed (status=${Lr.status})`);if(Fr=(Ie=Lr.data)==null?void 0:Ie.id,!Fr)return Tu(i,"Drive media upload did not return an id");const Yt={name:Fe,mimeType:Je};Ze&&(Yt.parents=[Ze]),typeof ct=="string"&&(Yt.description=ct);const Kt=await Ct("POST",`/drive/v3/files/${encodeURIComponent(Fr)}/copy`,{params:{supportsAllDrives:"true",fields:TE},body:JSON.stringify(Yt),contentType:"application/json"});return Kt.status!==200&&Kt.status!==201?Tu(i,`Drive copy-convert failed (status=${Kt.status})`):WP({file:Kt.data})}finally{if(Fr)try{await Ct("DELETE",`/drive/v3/files/${encodeURIComponent(Fr)}`,{params:{supportsAllDrives:"true"}})}catch{}}}if(we==null)return Tu(i,"Missing content for non-native upload");const{bytes:ri,inferredMime:nt,isBinary:vt}=await r$i(we),Ot=ri.byteLength;if(Ot>rK)return Tu(i,`File too large for simple upload (${Ot} bytes).`);const Ur=await Ct("POST","/upload/drive/v3/files",{params:{uploadType:"media",supportsAllDrives:"true",fields:TE},body:ri,contentType:Je||nt||(vt?"application/octet-stream":"text/plain; charset=UTF-8")});if(Ur.status!==200&&Ur.status!==201)return Tu(i,`Drive media upload failed (status=${Ur.status})`);let Na=Ur.data;const ha=(Ce=Ur.data)==null?void 0:Ce.id;return ha&&(Ze||Fe||ct)&&(Na=await s$i(Ct,ha,Fe,ct,Ze)),WP({file:Na})}catch(Ue){const we=((Le=Ue.response)==null?void 0:Le.data)||Ue.message||Ue;return re.Logger.error("[Google Drive] Upload document failed:",we),{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:we,result:null}}}})}}function WP(s){return{value:K.Success,error:null,result:s}}function Tu(s,u){return re.Logger.log("[Google Drive] Upload error:",u),{value:s.catchesError||s.errorCalls.length?K.CaughtError:K.UnhandledError,error:u,result:null}}async function s$i(s,u,i,r,a){const c={};i&&(c.name=i),typeof r=="string"&&(c.description=r);const e={supportsAllDrives:"true",fields:TE},f={...e};a&&(f.addParents=a,f.removeParents="root");let h=await s("PATCH",`/drive/v3/files/${encodeURIComponent(u)}`,{params:f,body:JSON.stringify(c),contentType:"application/json"});if(h.status>=400&&a&&(h=await s("PATCH",`/drive/v3/files/${encodeURIComponent(u)}`,{params:{...e,addParents:a},body:JSON.stringify(c),contentType:"application/json"})),h.status!==200)throw new Error(`Drive metadata update failed (status=${h.status})`);return h.data}class zSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:_s+je.GoogleGeminiGenerateContent,version:"1.0.0",description:"Send Gmail email operation implementation module",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Editor,ae.Logic]});D(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(je.GoogleGeminiGenerateContent);a&&(a.implementation=this.module.main)}},main:async(i,r)=>{var a,c,e,f,h;try{const m=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation["external-integration--google-gemini--post--generate-content"].inputs.connection.id}),T=(a=m==null?void 0:m.value)==null?void 0:a.valueAsType;if(!T)return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:"No entity template provided",result:null};if(!(T instanceof ta))return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:"Invalid entity template value provided",result:null};const b=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation["external-integration--google-gemini--post--generate-content"].inputs.prompt.id}),A=(c=b==null?void 0:b.value)==null?void 0:c.value;if(!A||typeof A!="string")return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:"Invalid prompt value provided",result:null};const w=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation["external-integration--google-gemini--post--generate-content"].inputs.model.id}),I=(e=w==null?void 0:w.value)==null?void 0:e.value;if(!I||typeof I!="string")return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:"Invalid model value provided",result:null};const C=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0],$=rd(T);console.log("Triggering Google Gemini generate content action with connectionId:",$);const L=await(await kr.post(`${(f=C.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/trigger-action/${Nr["google-gemini"]}/${$}/generate-content`,{payload:{prompt:A,model:I}},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${await C.getAccessToken()}`}})).data;return re.Logger.log("[Google Gemini] Generate content action response:",L),{value:K.Success,error:null,result:{content:L.content}}}catch(m){const T=((h=m.response)==null?void 0:h.data)||m.message||m;return re.Logger.error("[Google Gemini] Generate content failed:",T),{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,error:T,result:null}}}})}}class YSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_UPLOAD_FILE,version:"1.0.0",description:"Cloud File System: Upload File",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.UploadFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"uploadFile"),A="["+qe(i,i.project,"Upload file")+": `"+T+"`] ",w=r.find(me=>{var Te,Ee;return((Ee=(Te=me.valueOwner)==null?void 0:Te.declaration)==null?void 0:Ee.id)===U.operation[ke.UploadFile].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(me=>me.resourceId===C))throw new Error(`${A}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const L=r.find(me=>{var Te,Ee;return((Ee=(Te=me.valueOwner)==null?void 0:Te.declaration)==null?void 0:Ee.id)===U.operation[ke.UploadFile].inputs.key.id}),x=(e=L==null?void 0:L.value)==null?void 0:e.value;if(!x||x==="")throw new Error(`${A}The "${qe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof x!="string")throw new Error(`${A}The "${qe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const B=r.find(me=>{var Te,Ee;return((Ee=(Te=me.valueOwner)==null?void 0:Te.declaration)==null?void 0:Ee.id)===U.operation[ke.UploadFile].inputs.file.id}),q=(f=B==null?void 0:B.value)==null?void 0:f.value;if(!q)throw new Error(`${A}The "${qe(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"File")}" (\`${ft(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"file")}\`) input is missing'`);if(typeof q!="object"||!q.uri||typeof q.uri!="string")throw new Error(`${A}The "${qe(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"File")}" (\`${ft(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"file")}\`) input is invalid, should be an object with a text 'uri' property`);const W=q.uri,z=q.mimeType||"application/octet-stream",H=x,se=(h=(await kr.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files?bucket=${C}&key=${encodeURIComponent(H)}&contentType=${encodeURIComponent(z)}`,{},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}})).data)==null?void 0:h.uploadUrl;if(!se)throw new Error(`${A}Failed to retrieve pre-signed upload URL.`);let Y;if(W.startsWith("http://")||W.startsWith("https://"))try{const me=await m.getAccessToken();me&&(Y={Authorization:`Bearer ${me}`})}catch{}const ie=await fetch(W,{headers:Y});if(!ie.ok&&!W.startsWith("data:")&&!W.startsWith("blob:"))throw new Error(`${A}Failed to fetch file content from '${W}' (status: ${ie.status})`);const ne=await ie.blob();await kr.put(se,ne,{headers:{"Content-Type":z}});const ue={uri:`${m.env.API_BASE_URL}/cloud-files-service/v1/files/download?bucket=${C}&key=${encodeURIComponent(H)}`,name:H.split("/").pop()||H,mimeType:z,size:ne.size};return{value:K.Success,error:null,result:ue}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class JSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_DOWNLOAD_FILE,version:"1.0.0",description:"Cloud File System: Download File",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.DownloadFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"downloadFile"),T="["+qe(i,i.project,"Download file")+": `"+h+"`] ",b=r.find(z=>{var H,te;return((te=(H=z.valueOwner)==null?void 0:H.declaration)==null?void 0:te.id)===U.operation[ke.DownloadFile].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(z=>z.resourceId===w))throw new Error("The provided storage is not live. Publish the project first, then try again to run the operation node.");const C=r.find(z=>{var H,te;return((te=(H=z.valueOwner)==null?void 0:H.declaration)==null?void 0:te.id)===U.operation[ke.DownloadFile].inputs.key.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value;if(!$||$==="")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof $!="string")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=z=>{var Y;if(!z)return"application/octet-stream";const H=z.split(".");if(H.length===1)return"application/octet-stream";const te=(Y=H.pop())==null?void 0:Y.toLowerCase();return{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",pdf:"application/pdf",txt:"text/plain",html:"text/html",csv:"text/csv",json:"application/json",mp4:"video/mp4"}[te]||"application/octet-stream"};let x=0,B=L($);try{const z=await kr.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/metadata?bucket=${w}&key=${encodeURIComponent($)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});z.data&&(typeof z.data.size=="number"&&(x=z.data.size),z.data.mimeType&&z.data.mimeType!=="application/octet-stream"&&(B=z.data.mimeType))}catch{}const W={uri:`${f.env.API_BASE_URL}/cloud-files-service/v1/files/download?bucket=${w}&key=${encodeURIComponent($)}`,name:$.split("/").pop()||$,mimeType:B,size:x};return{value:K.Success,error:null,result:W}}catch(f){return{value:K.UnhandledError,error:f,result:null}}}})}}class QSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_LIST_FILES,version:"1.0.0",description:"Cloud File System: List Files",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.ListFiles);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"listFiles"),A="["+qe(i,i.project,"List files")+": `"+T+"`] ",w=r.find(Te=>{var Ee,Ie;return((Ie=(Ee=Te.valueOwner)==null?void 0:Ee.declaration)==null?void 0:Ie.id)===U.operation[ke.ListFiles].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(Te=>Te.resourceId===C))throw new Error(`${A}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const L=r.find(Te=>{var Ee,Ie;return((Ie=(Ee=Te.valueOwner)==null?void 0:Ee.declaration)==null?void 0:Ie.id)===U.operation[ke.ListFiles].inputs.path.id}),x=(e=L==null?void 0:L.value)==null?void 0:e.value;if(x!==void 0&&(typeof x!="string"||x===""))throw new Error(`${A}The "${qe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Path")}" (\`${ft(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"path")}\`) input value is invalid, if present, it must be a non-empty string.`);const B=r.find(Te=>{var Ee,Ie;return((Ie=(Ee=Te.valueOwner)==null?void 0:Ee.declaration)==null?void 0:Ie.id)===U.operation[ke.ListFiles].inputs.maxKeys.id}),q=(f=B==null?void 0:B.value)==null?void 0:f.value;if(q!==void 0&&(typeof q!="number"||q<=0))throw new Error(`${A}The "${qe(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"Max results")}" (\`${ft(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"maxKeys")}\`) input value is invalid, if present, it must be a number greater than 0.`);const W=r.find(Te=>{var Ee,Ie;return((Ie=(Ee=Te.valueOwner)==null?void 0:Ee.declaration)==null?void 0:Ie.id)===U.operation[ke.ListFiles].inputs.startAfter.id}),z=(h=W==null?void 0:W.value)==null?void 0:h.value;if(z!==void 0&&(typeof z!="string"||z===""))throw new Error(`${A}The "${qe(W==null?void 0:W.valueOwner,m==null?void 0:m.logic,"Start after")}" (\`${ft(W==null?void 0:W.valueOwner,m==null?void 0:m.logic,"startAfter")}\`) input value is invalid, if present, it must be a non-empty string.`);let H=`${m.env.API_BASE_URL}/cloud-files-service/v1/files?bucket=${C}`;x&&(H+=`&path=${encodeURIComponent(x)}`),q&&(H+=`&maxKeys=${q}`),z&&(H+=`&startAfter=${encodeURIComponent(z)}`);const te=await kr.get(H,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}}),se=Te=>{var Le;if(!Te)return"application/octet-stream";const Ee=Te.split(".");if(Ee.length===1)return"application/octet-stream";const Ie=(Le=Ee.pop())==null?void 0:Le.toLowerCase();return{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",pdf:"application/pdf",txt:"text/plain",html:"text/html",csv:"text/csv",json:"application/json",mp4:"video/mp4"}[Ie]||"application/octet-stream"},ie=(te.data.items||te.data.files||[]).map(Te=>{var Ee;return{uri:Te.uri||Te.url||`${m.env.API_BASE_URL}/cloud-files-service/v1/files/download?bucket=${C}&key=${encodeURIComponent(Te.key)}`,name:Te.name||((Ee=Te.key)==null?void 0:Ee.split("/").pop())||Te.key,key:Te.key,mimeType:Te.mimeType||se(Te.key),size:Te.size||0,lastModified:Te.lastModified||Te.lastModifiedDate,access:Te.access}}),ne=te.data.total!==void 0?te.data.total:ie.length,pe=te.data.size!==void 0?te.data.size:ie.reduce((Te,Ee)=>Te+(Ee.size||0),0),ue=te.data.nextStartAfter!==void 0?te.data.nextStartAfter:null,me=te.data.hasMore!==void 0?te.data.hasMore:!1;return{value:K.Success,error:null,result:{items:ie,total:ne,size:pe,nextStartAfter:ue,hasMore:me}}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class XSe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_DELETE_FILES,version:"1.0.0",description:"Cloud File System: Delete Files",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.DeleteFiles);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"deleteFiles"),T="["+qe(i,i.project,"Delete files")+": `"+h+"`] ",b=r.find(B=>{var q,W;return((W=(q=B.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===U.operation[ke.DeleteFiles].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(B=>B.resourceId===w))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const C=r.find(B=>{var q,W;return((W=(q=B.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===U.operation[ke.DeleteFiles].inputs.keys.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value,L=Array.isArray($)?$:typeof $=="string"&&$!==""?[$]:[];if(!L||L.length===0)throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Keys")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"keys")}\`) input is missing.`);if(!Array.isArray(L)||L.some(B=>typeof B!="string"||B===""))throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Keys")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"keys")}\`) input value is invalid, if present, it must be a list of non-empty strings.`);const x=await kr.delete(`${f.env.API_BASE_URL}/cloud-files-service/v1/files`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`},data:{bucket:w,keys:L}});return{value:K.Success,error:null,result:x.data}}catch(f){return{value:K.UnhandledError,error:f,result:null}}}})}}class eqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_COPY_FILE,version:"1.0.0",description:"Cloud File System: Copy File",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.CopyFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const b=ft(i,i.project,"copyFile"),w="["+qe(i,i.project,"Copy file")+": `"+b+"`] ",I=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.CopyFile].inputs.bucket.id}),C=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!C||!C.id||!C.name||C.type!==d.DefinitionEntity)throw new Error(`${w}Invalid input "${qe(I==null?void 0:I.valueOwner,T==null?void 0:T.logic,"Storage")}" (\`${ft(I==null?void 0:I.valueOwner,T==null?void 0:T.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const $=Ca(C==null?void 0:C.id,((c=T.branchHead)==null?void 0:c.identifier)||"main");if(!((T==null?void 0:T.liveResources)||[]).find(ne=>ne.resourceId===$))throw new Error(`${w}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const x=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.CopyFile].inputs.sourceKey.id}),B=(e=x==null?void 0:x.value)==null?void 0:e.value;if(!B||B==="")throw new Error(`${w}The "${qe(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${ft(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${w}The "${qe(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${ft(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.CopyFile].inputs.destinationKey.id}),W=(f=q==null?void 0:q.value)==null?void 0:f.value;if(!W||W==="")throw new Error(`${w}The "${qe(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${ft(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input is missing.`);if(typeof W!="string")throw new Error(`${w}The "${qe(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${ft(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const z=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.CopyFile].inputs.destinationBucket.id}),H=(h=z==null?void 0:z.value)==null?void 0:h.valueAsType;if(H&&(!H.id||!H.name||H.type!==d.DefinitionEntity))throw new Error(`${w}Invalid input "${qe(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,"Destination Storage")}" (\`${ft(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,"destinationBucket")}\`), expected a valid "Cloud file system" node.`);const te=H!=null&&H.id?Ca(H.id,((m=T.branchHead)==null?void 0:m.identifier)||"main"):$;if(!((T==null?void 0:T.liveResources)||[]).find(ne=>ne.resourceId===te))throw new Error(`${w}The destination "Cloud file system" is not live. Publish the project first, then try again to run the operation node.`);const Y={headers:{Authorization:`Bearer ${await T.getAccessToken()}`}},ie=await kr.post(`${T.env.API_BASE_URL}/cloud-files-service/v1/files/copy`,{bucket:$,destinationBucket:te,sourceKey:B,destinationKey:W},Y);return{value:K.Success,error:null,result:ie.data}}catch(T){return{value:K.UnhandledError,error:T,result:null}}}})}}class tqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_MOVE_FILE,version:"1.0.0",description:"Cloud File System: Move File",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.MoveFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const b=ft(i,i.project,"moveFile"),w="["+qe(i,i.project,"Move file")+": `"+b+"`] ",I=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.MoveFile].inputs.bucket.id}),C=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!C||!C.id||!C.name||C.type!==d.DefinitionEntity)throw new Error(`${w}Invalid input "${qe(I==null?void 0:I.valueOwner,T==null?void 0:T.logic,"Storage")}" (\`${ft(I==null?void 0:I.valueOwner,T==null?void 0:T.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const $=Ca(C==null?void 0:C.id,((c=T.branchHead)==null?void 0:c.identifier)||"main");if(!((T==null?void 0:T.liveResources)||[]).find(ne=>ne.resourceId===$))throw new Error(`${w}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const x=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.MoveFile].inputs.sourceKey.id}),B=(e=x==null?void 0:x.value)==null?void 0:e.value;if(!B||B==="")throw new Error(`${w}The "${qe(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${ft(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${w}The "${qe(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${ft(x==null?void 0:x.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.MoveFile].inputs.destinationKey.id}),W=(f=q==null?void 0:q.value)==null?void 0:f.value;if(!W||W==="")throw new Error(`${w}The "${qe(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${ft(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input is missing.`);if(typeof W!="string")throw new Error(`${w}The "${qe(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${ft(q==null?void 0:q.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const z=r.find(ne=>{var pe,ue;return((ue=(pe=ne.valueOwner)==null?void 0:pe.declaration)==null?void 0:ue.id)===U.operation[ke.MoveFile].inputs.destinationBucket.id}),H=(h=z==null?void 0:z.value)==null?void 0:h.valueAsType;if(H&&(!H.id||!H.name||H.type!==d.DefinitionEntity))throw new Error(`${w}Invalid input "${qe(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,"Destination storage")}" (\`${ft(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,"destinationBucket")}\`), expected a valid "Cloud file system" node.`);const te=H!=null&&H.id?Ca(H.id,((m=T.branchHead)==null?void 0:m.identifier)||"main"):$;if(!((T==null?void 0:T.liveResources)||[]).find(ne=>ne.resourceId===te))throw new Error(`${w}The destination "Cloud file system" is not live. Publish the project first, then try again to run the operation node.`);const Y={headers:{Authorization:`Bearer ${await T.getAccessToken()}`}},ie=await kr.post(`${T.env.API_BASE_URL}/cloud-files-service/v1/files/move`,{bucket:$,destinationBucket:te,sourceKey:B,destinationKey:W},Y);return{value:K.Success,error:null,result:ie.data}}catch(T){return{value:K.UnhandledError,error:T,result:null}}}})}}class iqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_RENAME_FILE,version:"1.0.0",description:"Cloud File System: Rename File",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.RenameFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=ft(i,i.project,"renameFile"),b="["+qe(i,i.project,"Rename file")+": `"+m+"`] ",A=r.find(se=>{var Y,ie;return((ie=(Y=se.valueOwner)==null?void 0:Y.declaration)==null?void 0:ie.id)===U.operation[ke.RenameFile].inputs.bucket.id}),w=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!w||!w.id||!w.name||w.type!==d.DefinitionEntity)throw new Error(`${b}Invalid input "${qe(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${ft(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=Ca(w==null?void 0:w.id,((c=h.branchHead)==null?void 0:c.identifier)||"main");if(!((h==null?void 0:h.liveResources)||[]).find(se=>se.resourceId===I))throw new Error(`${b}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const $=r.find(se=>{var Y,ie;return((ie=(Y=se.valueOwner)==null?void 0:Y.declaration)==null?void 0:ie.id)===U.operation[ke.RenameFile].inputs.key.id}),L=(e=$==null?void 0:$.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${b}The "${qe($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${b}The "${qe($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const x=r.find(se=>{var Y,ie;return((ie=(Y=se.valueOwner)==null?void 0:Y.declaration)==null?void 0:ie.id)===U.operation[ke.RenameFile].inputs.newName.id}),B=(f=x==null?void 0:x.value)==null?void 0:f.value;if(!B||B==="")throw new Error(`${b}The "${qe(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"New name")}" (\`${ft(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"newName")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${b}The "${qe(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"New name")}" (\`${ft(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"newName")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=L.lastIndexOf("/"),z=`${q!==-1?L.substring(0,q+1):""}${B}`,H={headers:{Authorization:`Bearer ${await h.getAccessToken()}`}},te=await kr.post(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/rename`,{bucket:I,key:L,newName:B},H);return{value:K.Success,error:null,result:te.data||{key:L,newName:B,destinationKey:z}}}catch(h){return{value:K.UnhandledError,error:h,result:null}}}})}}class rqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_FILE_METADATA,version:"1.0.0",description:"Cloud File System: Get File Metadata",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.GetFileMetadata);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"getFileMetadata"),T="["+qe(i,i.project,"Get file metadata")+": `"+h+"`] ",b=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.GetFileMetadata].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(x=>x.resourceId===w))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const C=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.GetFileMetadata].inputs.key.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value;if(!$||$==="")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof $!="string")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=await kr.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/metadata?bucket=${w}&key=${encodeURIComponent($)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});return{value:K.Success,error:null,result:L.data}}catch(f){return{value:K.UnhandledError,error:f,result:null}}}})}}class nqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CHECK_FILE_EXISTS,version:"1.0.0",description:"Cloud File System: Check File Exists",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.CheckFileExists);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"checkFileExists"),T="["+qe(i,i.project,"Check File Exists")+": `"+h+"`] ",b=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.CheckFileExists].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(x=>x.resourceId===w))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const C=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.CheckFileExists].inputs.key.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value;if(!$||$==="")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof $!="string")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=await kr.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/exists?bucket=${w}&key=${encodeURIComponent($)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});return{value:K.Success,error:null,result:L.data.exists}}catch(f){return{value:K.UnhandledError,error:f,result:!1}}}})}}class aqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_PRESIGNED_URL,version:"1.0.0",description:"Cloud File System: Get Pre-signed URL",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.GetPresignedUrl);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"getPresignedUrl"),A="["+qe(i,i.project,"Get pre-signed URL")+": `"+T+"`] ",w=r.find(ie=>{var ne,pe;return((pe=(ne=ie.valueOwner)==null?void 0:ne.declaration)==null?void 0:pe.id)===U.operation[ke.GetPresignedUrl].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(ie=>ie.resourceId===C))throw new Error(`${A}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const L=r.find(ie=>{var ne,pe;return((pe=(ne=ie.valueOwner)==null?void 0:ne.declaration)==null?void 0:pe.id)===U.operation[ke.GetPresignedUrl].inputs.key.id}),x=(e=L==null?void 0:L.value)==null?void 0:e.value;if(!x||x==="")throw new Error(`${A}The "${qe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof x!="string")throw new Error(`${A}The "${qe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const B=r.find(ie=>{var ne,pe;return((pe=(ne=ie.valueOwner)==null?void 0:ne.declaration)==null?void 0:pe.id)===U.operation[ke.GetPresignedUrl].inputs.action.id}),q=(f=B==null?void 0:B.value)==null?void 0:f.value,W=(q||"read").toLowerCase(),z=["read","write","delete","metadata","upload","putobject","head","headobject","getobject","get"];if(!q||q==="")throw new Error(`${A}The "${qe(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"Action")}" (\`${ft(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"action")}\`) input is missing.`);if(!z.includes(W))throw new Error(`${A}Invalid "${qe(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"Action")}" (\`${ft(B==null?void 0:B.valueOwner,m==null?void 0:m.logic,"action")}\`) input value, must be one of "read", "write", "delete" or "metadata".`);const H=r.find(ie=>{var ne,pe;return((pe=(ne=ie.valueOwner)==null?void 0:ne.declaration)==null?void 0:pe.id)===U.operation[ke.GetPresignedUrl].inputs.expiresInSeconds.id}),te=(h=H==null?void 0:H.value)==null?void 0:h.value,se=te!=null?Number(te):3600;if(isNaN(se)||se<=0)throw new Error(`${A}Invalid "${qe(H==null?void 0:H.valueOwner,m==null?void 0:m.logic,"Expires in seconds")}" (\`${ft(H==null?void 0:H.valueOwner,m==null?void 0:m.logic,"expiresInSeconds")}\`) input value, expected a positive number.`);const Y=await kr.get(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/presigned-url?bucket=${C}&key=${encodeURIComponent(x)}&action=${W}&expiresInSeconds=${se}`,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:K.Success,error:null,result:Y.data}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class sqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_SET_FILE_ACCESS,version:"1.0.0",description:"Cloud File System: Set File Access",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.SetFileAccess);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=ft(i,i.project,"setFileAccess"),b="["+qe(i,i.project,"Set file access")+": `"+m+"`] ",A=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.SetFileAccess].inputs.bucket.id}),w=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!w||!w.id||!w.name||w.type!==d.DefinitionEntity)throw new Error(`${b}Invalid input "${qe(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${ft(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=Ca(w==null?void 0:w.id,((c=h.branchHead)==null?void 0:c.identifier)||"main");if(!((h==null?void 0:h.liveResources)||[]).find(q=>q.resourceId===I))throw new Error(`${b}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const $=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.SetFileAccess].inputs.key.id}),L=(e=$==null?void 0:$.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${b}The "${qe($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${b}The "${qe($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const x=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.SetFileAccess].inputs.access.id}),B=((f=x==null?void 0:x.value)==null?void 0:f.value)??"private";if(!B||B==="")throw new Error(`${b}The "${qe(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"Access")}" (\`${ft(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"access")}\`) input is missing.`);if(typeof B!="string"||!["public","private"].includes(B))throw new Error(`${b}The "${qe(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"Access")}" (\`${ft(x==null?void 0:x.valueOwner,h==null?void 0:h.logic,"access")}\`) input value is invalid, if present, it must be exactly the "public" or "private" text values.`);return await kr.post(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/access`,{bucket:I,key:L,access:B},{headers:{Authorization:`Bearer ${await h.getAccessToken()}`}}),{value:K.Success,error:null,result:null}}catch(h){return{value:K.UnhandledError,error:h,result:null}}}})}}class lqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CREATE_FOLDER,version:"1.0.0",description:"Cloud File System: Create Folder",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.CreateFolder);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"createFolder"),T="["+qe(i,i.project,"Create folder")+": `"+h+"`] ",b=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.CreateFolder].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(x=>x.resourceId===w))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const C=r.find(x=>{var B,q;return((q=(B=x.valueOwner)==null?void 0:B.declaration)==null?void 0:q.id)===U.operation[ke.CreateFolder].inputs.folderPath.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value;if(!$||$==="")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Folder path")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"folderPath")}\`) input is missing.`);if(typeof $!="string")throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Folder path")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"folderPath")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=await kr.post(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/folders`,{bucket:w,folderPath:$},{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});return{value:K.Success,error:null,result:L.data}}catch(f){return{value:K.UnhandledError,error:f,result:null}}}})}}class oqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_DELETE_FOLDERS,version:"1.0.0",description:"Cloud File System: Delete Folders",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.DeleteFolders);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=ft(i,i.project,"deleteFolders"),T="["+qe(i,i.project,"Delete folders")+": `"+h+"`] ",b=r.find(B=>{var q,W;return((W=(q=B.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===U.operation[ke.DeleteFolders].inputs.bucket.id}),A=(a=b==null?void 0:b.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==d.DefinitionEntity)throw new Error(`${T}Invalid input "${qe(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${ft(b==null?void 0:b.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const w=Ca(A==null?void 0:A.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(B=>B.resourceId===w))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const C=r.find(B=>{var q,W;return((W=(q=B.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===U.operation[ke.DeleteFolders].inputs.folderPaths.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value,L=Array.isArray($)?$:typeof $=="string"&&$!==""?[$]:[];if(!L||L.length===0)throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Folder paths")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"folderPaths")}\`) input is missing.`);if(!Array.isArray(L)||L.some(B=>typeof B!="string"||B===""))throw new Error(`${T}The "${qe(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"Folder paths")}" (\`${ft(C==null?void 0:C.valueOwner,f==null?void 0:f.logic,"folderPaths")}\`) input value is invalid, if present, it must be a list of non-empty strings.`);const x=await kr.delete(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/folders`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`},data:{bucket:w,folderPaths:L}});return{value:K.Success,error:null,result:x.data}}catch(f){return{value:K.UnhandledError,error:f,result:null}}}})}}class dqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CREATE_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Create Multipart Upload",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.CreateMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"createMultipartUpload"),A="["+qe(i,i.project,"Create multipart upload")+": `"+T+"`] ",w=r.find(W=>{var z,H;return((H=(z=W.valueOwner)==null?void 0:z.declaration)==null?void 0:H.id)===U.operation[ke.CreateMultipartUpload].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),$=r.find(W=>{var z,H;return((H=(z=W.valueOwner)==null?void 0:z.declaration)==null?void 0:H.id)===U.operation[ke.CreateMultipartUpload].inputs.key.id}),L=(e=$==null?void 0:$.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const x=r.find(W=>{var z,H;return((H=(z=W.valueOwner)==null?void 0:z.declaration)==null?void 0:H.id)===U.operation[ke.CreateMultipartUpload].inputs.contentType.id}),B=((f=x==null?void 0:x.value)==null?void 0:f.value)||"application/octet-stream";if(!B||B==="")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Content Type")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"contentType")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Content Type")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"contentType")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=await kr.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart?bucket=${C}&key=${encodeURIComponent(L)}&contentType=${encodeURIComponent(B)}`,{},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:K.Success,error:null,result:{uploadId:typeof q.data=="object"&&((h=q.data)!=null&&h.uploadId)?q.data.uploadId:q.data}}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class uqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_UPLOAD_PART_PRESIGNED_URL,version:"1.0.0",description:"Cloud File System: Get Upload Part Pre-signed URL",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.GetUploadPartPresignedUrl);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"getUploadPartPresignedUrl"),A="["+qe(i,i.project,"Get upload part pre-signed URL")+": `"+T+"`] ",w=r.find(H=>{var te,se;return((se=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:se.id)===U.operation[ke.GetUploadPartPresignedUrl].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),$=r.find(H=>{var te,se;return((se=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:se.id)===U.operation[ke.GetUploadPartPresignedUrl].inputs.key.id}),L=(e=$==null?void 0:$.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const x=r.find(H=>{var te,se;return((se=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:se.id)===U.operation[ke.GetUploadPartPresignedUrl].inputs.uploadId.id}),B=(f=x==null?void 0:x.value)==null?void 0:f.value;if(!B||B==="")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=r.find(H=>{var te,se;return((se=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:se.id)===U.operation[ke.GetUploadPartPresignedUrl].inputs.partNumber.id}),W=Number((h=q==null?void 0:q.value)==null?void 0:h.value);if(isNaN(W)||W<=0)throw new Error(`${A}The "${qe(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"Part number")}" (\`${ft(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"partNumber")}\`) input is missing or invalid.`);const z=await kr.get(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${B}?bucket=${C}&key=${encodeURIComponent(L)}&partNumber=${W}`,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:K.Success,error:null,result:z.data}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class pqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_COMPLETE_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Complete Multipart Upload",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.CompleteMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=ft(i,i.project,"completeMultipartUpload"),A="["+qe(i,i.project,"Complete multipart upload")+": `"+T+"`] ",w=r.find(te=>{var se,Y;return((Y=(se=te.valueOwner)==null?void 0:se.declaration)==null?void 0:Y.id)===U.operation[ke.CompleteMultipartUpload].inputs.bucket.id}),I=(a=w==null?void 0:w.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==d.DefinitionEntity)throw new Error(`${A}Invalid input "${qe(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${ft(w==null?void 0:w.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const C=Ca(I==null?void 0:I.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),$=r.find(te=>{var se,Y;return((Y=(se=te.valueOwner)==null?void 0:se.declaration)==null?void 0:Y.id)===U.operation[ke.CompleteMultipartUpload].inputs.key.id}),L=(e=$==null?void 0:$.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${A}The "${qe($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${ft($==null?void 0:$.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const x=r.find(te=>{var se,Y;return((Y=(se=te.valueOwner)==null?void 0:se.declaration)==null?void 0:Y.id)===U.operation[ke.CompleteMultipartUpload].inputs.uploadId.id}),B=(f=x==null?void 0:x.value)==null?void 0:f.value;if(!B||B==="")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input is missing.`);if(typeof B!="string")throw new Error(`${A}The "${qe(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${ft(x==null?void 0:x.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const q=r.find(te=>{var se,Y;return((Y=(se=te.valueOwner)==null?void 0:se.declaration)==null?void 0:Y.id)===U.operation[ke.CompleteMultipartUpload].inputs.parts.id}),W=(h=q==null?void 0:q.value)==null?void 0:h.value;if(!Array.isArray(W)||W.length===0)throw new Error(`${A}The "${qe(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"Parts")}" (\`${ft(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"parts")}\`) input is missing or empty.`);if(W.some(te=>{let se=!1,Y=!1;return(te.partNumber&&Number(te.partNumber)>0||te.PartNumber&&Number(te.PartNumber)>0)&&(se=!0),(te.etag&&typeof te.etag=="string"||te.ETag&&typeof te.ETag=="string")&&(Y=!0),!se||!Y}))throw new Error(`${A}The "${qe(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"Parts")}" (\`${ft(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"parts")}\`) input value is invalid, if present, it must be an array of objects with "partNumber" and "etag" properties.`);const H=(await kr.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${B}/complete?bucket=${C}&key=${encodeURIComponent(L)}`,{parts:W},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}})).data||{};return{value:K.Success,error:null,result:{location:H.location||H.Location||L,key:H.key||H.Key||L,etag:H.etag||H.ETag||null}}}catch(m){return{value:K.UnhandledError,error:m,result:null}}}})}}class cqe extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_ABORT_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Abort Multipart Upload",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.AbortMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=ft(i,i.project,"abortMultipartUpload"),b="["+qe(i,i.project,"Abort multipart upload")+": `"+m+"`] ",A=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.AbortMultipartUpload].inputs.bucket.id}),w=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!w||!w.id||!w.name||w.type!==d.DefinitionEntity)throw new Error(`${b}Invalid input "${qe(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${ft(A==null?void 0:A.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=Ca(w==null?void 0:w.id,((c=h.branchHead)==null?void 0:c.identifier)||"main"),C=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.AbortMultipartUpload].inputs.key.id}),$=(e=C==null?void 0:C.value)==null?void 0:e.value;if(!$||$==="")throw new Error(`${b}The "${qe(C==null?void 0:C.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof $!="string")throw new Error(`${b}The "${qe(C==null?void 0:C.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${ft(C==null?void 0:C.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=r.find(q=>{var W,z;return((z=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:z.id)===U.operation[ke.AbortMultipartUpload].inputs.uploadId.id}),x=(f=L==null?void 0:L.value)==null?void 0:f.value;if(!x||x==="")throw new Error(`${b}The "${qe(L==null?void 0:L.valueOwner,h==null?void 0:h.logic,"Upload ID")}" (\`${ft(L==null?void 0:L.valueOwner,h==null?void 0:h.logic,"uploadId")}\`) input is missing.`);if(typeof x!="string")throw new Error(`${b}The "${qe(L==null?void 0:L.valueOwner,h==null?void 0:h.logic,"Upload ID")}" (\`${ft(L==null?void 0:L.valueOwner,h==null?void 0:h.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const B=await kr.delete(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${x}?bucket=${I}&key=${encodeURIComponent($)}`,{headers:{Authorization:`Bearer ${await h.getAccessToken()}`}});return{value:K.Success,error:null,result:B.data}}catch(h){return{value:K.UnhandledError,error:h,result:null}}}})}}class l$i extends xe{constructor(){super(...arguments);D(this,"manifest",{id:$e.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_UPLOAD_FILE_PART,version:"1.0.0",description:"Cloud File System: Upload File Part",initPriority:Oe.High,permissions:[Pe.All],contexts:[ae.Logic]});D(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(ke.UploadFilePart);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m,T,b,A;try{const w=this.extensionsRegistry.requestContexts(this,[ae.Editor])[0];if(!w||!w.env)throw new Error("Editor context or environment missing");const I=ft(i,i.project,"uploadFilePart"),$="["+qe(i,i.project,"Upload file part")+": `"+I+"`] ",L=r.find(Ie=>{var Ce,Le;return((Le=(Ce=Ie.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Le.id)===U.operation[ke.UploadFilePart].inputs.bucket.id}),x=(a=L==null?void 0:L.value)==null?void 0:a.valueAsType;if(!x||!x.id||!x.name||x.type!==d.DefinitionEntity)throw new Error(`${$}Invalid input "${qe(L==null?void 0:L.valueOwner,w==null?void 0:w.logic,"Storage")}" (\`${ft(L==null?void 0:L.valueOwner,w==null?void 0:w.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const B=Ca(x==null?void 0:x.id,((c=w.branchHead)==null?void 0:c.identifier)||"main");if(!((w==null?void 0:w.liveResources)||[]).find(Ie=>Ie.resourceId===B))throw new Error(`${$}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const W=r.find(Ie=>{var Ce,Le;return((Le=(Ce=Ie.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Le.id)===U.operation[ke.UploadFilePart].inputs.key.id}),z=(e=W==null?void 0:W.value)==null?void 0:e.value;if(!z||z==="")throw new Error(`${$}The "${qe(W==null?void 0:W.valueOwner,w==null?void 0:w.logic,"Key")}" (\`${ft(W==null?void 0:W.valueOwner,w==null?void 0:w.logic,"key")}\`) input is missing.`);if(typeof z!="string")throw new Error(`${$}The "${qe(W==null?void 0:W.valueOwner,w==null?void 0:w.logic,"Key")}" (\`${ft(W==null?void 0:W.valueOwner,w==null?void 0:w.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const H=r.find(Ie=>{var Ce,Le;return((Le=(Ce=Ie.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Le.id)===U.operation[ke.UploadFilePart].inputs.uploadId.id}),te=(f=H==null?void 0:H.value)==null?void 0:f.value;if(!te||te==="")throw new Error(`${$}The "${qe(H==null?void 0:H.valueOwner,w==null?void 0:w.logic,"Upload ID")}" (\`${ft(H==null?void 0:H.valueOwner,w==null?void 0:w.logic,"uploadId")}\`) input is missing.`);if(typeof te!="string")throw new Error(`${$}The "${qe(H==null?void 0:H.valueOwner,w==null?void 0:w.logic,"Upload ID")}" (\`${ft(H==null?void 0:H.valueOwner,w==null?void 0:w.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const se=r.find(Ie=>{var Ce,Le;return((Le=(Ce=Ie.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Le.id)===U.operation[ke.UploadFilePart].inputs.partNumber.id}),Y=Number((h=se==null?void 0:se.value)==null?void 0:h.value);if(((m=se==null?void 0:se.value)==null?void 0:m.value)===void 0||((T=se==null?void 0:se.value)==null?void 0:T.value)===null||isNaN(Y)||Y<=0)throw new Error(`${$}The "${qe(se==null?void 0:se.valueOwner,w==null?void 0:w.logic,"Part number")}" (\`${ft(se==null?void 0:se.valueOwner,w==null?void 0:w.logic,"partNumber")}\`) input is missing or invalid.`);const ie=r.find(Ie=>{var Ce,Le;return((Le=(Ce=Ie.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Le.id)===U.operation[ke.UploadFilePart].inputs.bytes.id}),ne=(b=ie==null?void 0:ie.value)==null?void 0:b.value;if(ne==null)throw new Error(`${$}The "${qe(ie==null?void 0:ie.valueOwner,w==null?void 0:w.logic,"Bytes")}" (\`${ft(ie==null?void 0:ie.valueOwner,w==null?void 0:w.logic,"bytes")}\`) input is missing.`);const ue=(A=(await kr.get(`${w.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${te}?bucket=${B}&key=${encodeURIComponent(z)}&partNumber=${Y}`,{headers:{Authorization:`Bearer ${await w.getAccessToken()}`}})).data)==null?void 0:A.uploadUrl;if(!ue)throw new Error(`${$}Failed to obtain presigned upload URL for part ${Y}.`);const me=await kr.put(ue,ne,{headers:{"Content-Type":"application/octet-stream"}}),Te=me.headers.etag||me.headers.ETag||"",Ee=typeof Te=="string"?Te.replace(/"/g,""):"";return{value:K.Success,error:null,result:{partNumber:Y,etag:Ee}}}catch(w){return{value:K.UnhandledError,error:w,result:null}}}})}}class GN extends vD{constructor(u,i,r=i.projectId){super(u,ae.Editor),this._editor=i,this.id=r}get ready(){return this._editor.ready}get env(){return this._editor.env}get hasLoadedLogic(){return this._editor.hasLoadedLogic}get destroyed(){return this._editor.destroyed}get logicLoadingPromise(){return this._editor.logicLoadingPromise}get logic(){return this._editor.logic}get lastPublishedProjectState(){return this._editor.lastPublishedProjectState}get branchHead(){return this._editor.branchHead}get branchHeadPromise(){return this._editor.branchHeadPromise}get projectId(){return this._editor.projectId}get sessionId(){return this._editor.sessionId}get userAuthorId(){return this._editor.userAuthorId}get peerConnections(){return this._editor.peerConnections}get test(){return this._editor.test}get localTestValues(){return this._editor.localTestValues}get resolvedValues(){return this._editor.resolvedValues}get persistedExecutionResults(){return this._editor.persistedExecutionResults}get publication(){return this._editor.publication}get livePublishedVersions(){return this._editor.livePublishedVersions}get publications(){return this._editor.publications}get liveResources(){return this._editor.liveResources}get execution(){return this._editor.execution}get project(){return this._editor.logic}get lastExecutionResults(){return this._editor.lastExecutionResults}get undoableStackValueIndex(){return this._editor.undoableStackValueIndex}set undoableStackValueIndex(u){this._editor.undoableStackValueIndex=u}get activeWorkspace(){return this._editor.activeWorkspace}get branches(){return this._editor.branches}get roles(){return this._editor.roles}get READ_ONLY(){return this._editor.READ_ONLY}get isViewingNonHead(){return this._editor.isViewingNonHead}get canEdit(){return this._editor.canEdit}get PROJECT_NOTIFICATIONS_CHANNEL(){return this._editor.PROJECT_NOTIFICATIONS_CHANNEL}getAccessToken(){return this._editor.getAccessToken()}getRefreshToken(){return this._editor.getRefreshToken()}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,i){return this._editor.initTest(u,i)}removeTest(u){return this._editor.removeTest(u)}async copyEntities(u,i={}){return this._editor.copyEntities(u,i)}resolveInitialChildrenPositions(u,i,r){return this._editor.resolveInitialChildrenPositions(u,i,r)}publish(){return this._editor.publish()}loadGivenPublication(u){return this._editor.loadGivenPublication(u)}validateProjectState(u){return this._editor.validateProjectState(u)}requestActiveDynamicValue(u,i=!1){return this._editor.requestActiveDynamicValue(u,i)}getValueTypePreference(u){return this._editor.getValueTypePreference(u)}setValueTypePreference(u,i){return this._editor.setValueTypePreference(u,i)}implementFeature(u){return this._editor.implementFeature(u)}getProjectRoles(){return this._editor.getProjectRoles()}getLastPublishedVersionLogic(u){return this._editor.getLastPublishedVersionLogic(u)}initialLoads(u){return this._editor.initialLoads(u)}moveBranchHeadToVersion(u,i,r){return this._editor.moveBranchHeadToVersion(u,i,r)}loadInitialBranchHead(){return this._editor.loadInitialBranchHead()}}function o$i(s,u){return u instanceof GN?u:new GN(s,u)}class kN extends vD{constructor(u,i){super(u,ae.PublicationRun),this._publicationRun=i}get id(){return this._publicationRun.id}get projectAutoIncrementPublicationCount(){return this._publicationRun.projectAutoIncrementPublicationCount}get projectPublishedSemanticVersion(){return this._publicationRun.projectPublishedSemanticVersion}get envIdentifier(){return this._publicationRun.envIdentifier}get projectVersion(){return this._publicationRun.projectVersion}get projectBranchId(){return this._publicationRun.projectBranchId}get projectId(){return this._publicationRun.projectId}get triggeredBy(){return this._publicationRun.triggeredBy}get createdAt(){return this._publicationRun.createdAt}get updatedAt(){return this._publicationRun.updatedAt}get status(){return this._publicationRun.status}get steps(){return this._publicationRun.steps}get cleanupSteps(){return this._publicationRun.cleanupSteps}get editor(){return this._publicationRun.editor}get explicitResources(){return this._publicationRun.explicitResources}get implicitGlobalResources(){return this._publicationRun.implicitGlobalResources}get finalGlobalEvent(){return this._publicationRun.finalGlobalEvent}get finalStatus(){return this._publicationRun.finalStatus}}function d$i(s,u){return u instanceof kN?u:new kN(s,u)}function u$i(s){s.register(new VGe(s)),s.register(new xGe(s)),s.register(new OGe(s)),s.register(new PGe(s)),s.register(new NGe(s)),s.register(new _Ge(s)),s.register(new fje(s)),s.register(new yje(s)),s.register(new hje(s)),s.register(new Tje(s)),s.register(new mje(s)),s.register(new vje(s)),s.register(new nSe(s)),s.register(new aSe(s)),s.register(new sSe(s)),s.register(new lSe(s)),s.register(new oSe(s)),s.register(new dSe(s)),s.register(new uSe(s)),s.register(new pSe(s)),s.register(new cSe(s)),s.register(new fSe(s)),s.register(new c4e(s)),s.register(new f4e(s)),s.register(new y4e(s)),s.register(new h4e(s)),s.register(new m4e(s)),s.register(new T4e(s)),s.register(new v4e(s)),s.register(new E4e(s)),s.register(new b4e(s)),s.register(new A4e(s)),s.register(new g4e(s)),s.register(new I4e(s)),s.register(new R4e(s)),s.register(new w4e(s)),s.register(new D4e(s)),s.register(new C4e(s)),s.register(new O4e(s)),s.register(new _4e(s)),s.register(new P4e(s)),s.register(new V4e(s)),s.register(new $4e(s)),s.register(new L4e(s)),s.register(new xFe(s)),s.register(new VFe(s)),s.register(new $Fe(s)),s.register(new LFe(s)),s.register(new BFe(s)),s.register(new MFe(s)),s.register(new GFe(s)),s.register(new kFe(s)),s.register(new UFe(s)),s.register(new jFe(s)),s.register(new KFe(s)),s.register(new SFe(s)),s.register(new qFe(s)),s.register(new ZFe(s)),s.register(new JUe(s)),s.register(new gKe(s)),s.register(new bKe(s)),s.register(new AKe(s)),s.register(new Yke(s)),s.register(new Jke(s)),s.register(new Qke(s)),s.register(new Xke(s)),s.register(new eUe(s)),s.register(new tUe(s)),s.register(new iUe(s)),s.register(new rUe(s)),s.register(new nUe(s)),s.register(new TUe(s)),s.register(new WUe(s)),s.register(new zUe(s)),s.register(new YUe(s)),s.register(new aUe(s)),s.register(new sUe(s)),s.register(new lUe(s)),s.register(new oUe(s)),s.register(new dUe(s)),s.register(new uUe(s)),s.register(new pUe(s)),s.register(new cUe(s)),s.register(new fUe(s)),s.register(new yUe(s)),s.register(new hUe(s)),s.register(new mUe(s)),s.register(new vUe(s)),s.register(new EUe(s)),s.register(new bUe(s)),s.register(new AUe(s)),s.register(new gUe(s)),s.register(new IUe(s)),s.register(new RUe(s)),s.register(new wUe(s)),s.register(new DUe(s)),s.register(new CUe(s)),s.register(new OUe(s)),s.register(new _Ue(s)),s.register(new GUe(s)),s.register(new kUe(s)),s.register(new UUe(s)),s.register(new PUe(s)),s.register(new NUe(s)),s.register(new xUe(s)),s.register(new VUe(s)),s.register(new $Ue(s)),s.register(new LUe(s)),s.register(new BUe(s)),s.register(new MUe(s)),s.register(new DKe(s)),s.register(new CKe(s)),s.register(new OKe(s)),s.register(new _Ke(s)),s.register(new IKe(s)),s.register(new RKe(s)),s.register(new wKe(s)),s.register(new PKe(s)),s.register(new xKe(s)),s.register(new $Ke(s)),s.register(new NKe(s)),s.register(new VKe(s)),s.register(new LKe(s)),s.register(new GKe(s)),s.register(new BKe(s)),s.register(new MKe(s)),s.register(new HFe(s)),s.register(new JFe(s)),s.register(new QFe(s)),s.register(new t4e(s)),s.register(new i4e(s)),s.register(new r4e(s)),s.register(new n4e(s)),s.register(new a4e(s)),s.register(new s4e(s)),s.register(new l4e(s)),s.register(new o4e(s)),s.register(new XFe(s)),s.register(new e4e(s)),s.register(new YSe(s)),s.register(new JSe(s)),s.register(new QSe(s)),s.register(new XSe(s)),s.register(new eqe(s)),s.register(new tqe(s)),s.register(new iqe(s)),s.register(new rqe(s)),s.register(new nqe(s)),s.register(new aqe(s)),s.register(new sqe(s)),s.register(new lqe(s)),s.register(new oqe(s)),s.register(new dqe(s)),s.register(new uqe(s)),s.register(new pqe(s)),s.register(new cqe(s)),s.register(new zFe(s)),s.register(new YFe(s)),s.register(new WFe(s)),s.register(new FFe(s)),s.register(new u4e(s)),s.register(new p4e(s)),s.register(new d4e(s)),s.register(new bje(s)),s.register(new Sje(s)),s.register(new Kje(s)),s.register(new qje(s)),s.register(new Zje(s)),s.register(new Ije(s)),s.register(new Rje(s)),s.register(new Pje(s)),s.register(new Oje(s)),s.register(new Fje(s)),s.register(new Lje(s)),s.register(new Mje(s)),s.register(new kje(s)),s.register(new Gje(s)),s.register(new _je(s)),s.register(new xje(s)),s.register(new Vje(s)),s.register(new Nje(s)),s.register(new Eje(s)),s.register(new wje(s)),s.register(new Bje(s)),s.register(new zje(s)),s.register(new xN(s)),s.register(new gje(s)),s.register(new Dje(s)),s.register(new Aje(s)),s.register(new Uje(s)),s.register(new Cje(s)),s.register(new $je(s)),s.register(new jje(s)),s.register(new Wje(s)),s.register(new Hje(s)),s.register(new Yje(s)),s.register(new xN(s)),s.register(new Qje(s)),s.register(new Jje(s)),s.register(new Xje(s)),s.register(new Y4e(s)),s.register(new J4e(s)),s.register(new Q4e(s)),s.register(new M4e(s)),s.register(new x4e(s)),s.register(new F4e(s)),s.register(new q4e(s)),s.register(new N4e(s)),s.register(new Z4e(s)),s.register(new z4e(s)),s.register(new K4e(s)),s.register(new j4e(s)),s.register(new bR(s)),s.register(new X4e(s)),s.register(new eje(s)),s.register(new S4e(s)),s.register(new W4e(s)),s.register(new H4e(s)),s.register(new U4e(s)),s.register(new k4e(s)),s.register(new G4e(s)),s.register(new B4e(s)),s.register(new rje(s)),s.register(new ije(s)),s.register(new nje(s)),s.register(new tje(s)),s.register(new SUe(s)),s.register(new FUe(s)),s.register(new KUe(s)),s.register(new qUe(s)),s.register(new ZUe(s)),s.register(new jUe(s)),s.register(new HUe(s)),s.register(new mSe(s)),s.register(new gSe(s)),s.register(new RSe(s)),s.register(new DSe(s)),s.register(new ASe(s)),s.register(new ISe(s)),s.register(new wSe(s)),s.register(new bSe(s)),s.register(new ESe(s)),s.register(new vSe(s)),s.register(new TSe(s)),s.register(new ySe(s)),s.register(new hSe(s)),s.register(new NSe(s)),s.register(new xSe(s)),s.register(new _Se(s)),s.register(new PSe(s)),s.register(new rSe(s)),s.register(new CSe(s)),s.register(new OSe(s)),s.register(new $Se(s)),s.register(new VSe(s)),s.register(new LSe(s)),s.register(new BSe(s)),s.register(new MSe(s)),s.register(new $Ge(s)),s.register(new LGe(s)),s.register(new vR(s)),s.register(new ER(s)),s.register(new USe(s)),s.register(new FSe(s)),s.register(new SSe(s)),s.register(new zSe(s)),s.register(new ZSe(s)),s.register(new jSe(s)),s.register(new KSe(s)),s.register(new HSe(s)),s.register(new qSe(s)),s.register(new WSe(s))}class RB{constructor(u=new re.Events("extensions-registry-fallback-events")){D(this,"extensionsRegistry",new Map);D(this,"initialized",new Set);D(this,"initializedContexts",new Set);D(this,"onResolveEditorContextCallback",()=>null);D(this,"onResolveProjectLogicContextCallback",()=>null);D(this,"onResolveEditorGUIContextCallback",()=>null);D(this,"onResolveGUIContextCallback",()=>null);D(this,"onResolveCompileContextCallback",()=>null);D(this,"onResolvePublicationRunContextCallback",()=>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}onResolveEditorGUIContext(u){this.onResolveEditorGUIContextCallback=u}onResolveCompileContext(u){this.onResolveCompileContextCallback=u}onResolvePublicationRunContext(u){this.onResolvePublicationRunContextCallback=u}get extensionInOrder(){return Array.from(this.extensionsRegistry.values()).sort((u,i)=>(u.manifest.initPriority||Oe.Normal)-(i.manifest.initPriority||Oe.Normal))}async setup(){u$i(this),re.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(u){switch(u){case ae.Editor:return this.onResolveEditorContextCallback();case ae.Logic:return this.onResolveProjectLogicContextCallback();case ae.EditorGUI:return this.onResolveEditorGUIContextCallback();case ae.Compile:return this.onResolveCompileContextCallback();case ae.PublicationRun:return this.onResolvePublicationRunContextCallback();case ae.GUI:return this.onResolveGUIContextCallback();case ae.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${u}`)}}requestContexts(u,i=[]){const r=[];i.length===0&&(i=u.manifest.contexts);for(const a of i){const c=this.requestContext(a);c&&r.push(c)}return r}requestExtension(u){const i=this.extensionsRegistry.get(u);if(i)return i;throw new Error(`Unknown extension: ${u}`)}register(u){this.extensionsRegistry.set(u.manifest.id,u)}async initAll(){var u,i;for(const r of this.extensionInOrder)if(r.module.init&&!this.initialized.has(r.manifest.id)){const a=r.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);a.length&&(await((i=(u=r.module).init)==null?void 0:i.call(u,a)),this.initialized.add(r.manifest.id))}else!r.module.init&&!this.initialized.has(r.manifest.id)&&this.initialized.add(r.manifest.id)}async initForReady(){re.Logger.log("Initializing extensions for ready contexts...");for(const u of this.extensionInOrder)if(u.module.init&&!this.initialized.has(u.manifest.id)){re.Logger.debug("Initializing "+u.manifest.id+" extension...");const i=this.requestContexts(u);u.manifest.contexts.every(a=>!!i.find(c=>c.contextType===a))?(await u.module.init(i),this.initialized.add(u.manifest.id)):re.Logger.warn(`Skipping initialization of ${u.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${u.manifest.contexts.join(", ")}`,`Available contexts: ${i.map(a=>a.contextType).join(", ")}`)}else!u.module.init&&!this.initialized.has(u.manifest.id)?(re.Logger.log("Set "+u.manifest.id+" extension as initialized by default..."),this.initialized.add(u.manifest.id)):re.Logger.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,i){this.events.on(u,i)}emit(u,...i){this.events.emit(u,...i)}off(u,i){this.events.off(u,i)}emitAsync(u,...i){return this.events.emitAsync(u,...i)}emitAsyncAll(u,...i){return this.events.emitAsyncAll(u,...i)}emitAsyncAllSettled(u,...i){return this.events.emitAsyncAllSettled(u,...i)}emitAsyncSequentially(u,...i){return this.events.emitAsyncSequentially(u,...i)}emitAsyncSequentiallyAll(u,...i){return this.events.emitAsyncSequentiallyAll(u,...i)}emitAsyncSequentiallyAllSettled(u,...i){return this.events.emitAsyncSequentiallyAllSettled(u,...i)}async contextAvailable(u){if(this.initializedContexts.has(u)){re.Logger.warn(`Context ${u} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(u),u){case ae.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case ae.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}re.Logger.log(`Context ${u} is now available. Initializing extensions for this context...`),await this.initForReady()}getValueTypePreference(u){return window.localStorage.getItem("dynamic-value-type-preference--"+u)||null}setValueTypePreference(u,i){window.localStorage.setItem("dynamic-value-type-preference--"+u,(i==null?void 0:i.toString())||""),this.emit(u,{})}}let jI=null;const wB={requestExtension:s=>(jI||(jI=new RB,jI.setup()),jI.requestExtension(s))};function Oc(s){return!(s instanceof Error)&&typeof s=="object"&&s!==null?s:s instanceof Error?{name:s.name,message:s.message,stack:s.stack,...s}:s}function nK(s){var u,i,r;if(s&&typeof s=="object"&&"value"in s){const a=s;return{single:((u=a.value)==null?void 0:u.valueAsTypeSingle)??((i=a.value)==null?void 0:i.value),list:((r=a.value)==null?void 0:r.valueAsTypeList)??null}}return{single:s,list:Array.isArray(s)?s:null}}const _c={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};class UN extends Error{constructor(){super("Execution was stopped"),this.name="ExecutionStoppedError"}}var DB=(s=>(s.FinishedSuccess="finished-success",s.FinishedError="finished-error",s.Running="running",s.Paused="paused",s.Stopped="stopped",s.NotStarted="not-started",s))(DB||{});const fqe={...wB,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class Lm extends re.Events{constructor(i,r,a,c=null,e=fqe){super();D(this,"project");D(this,"entryPoint");D(this,"state","not-started");D(this,"events",new re.Events("fe-exec-inst-events"));D(this,"entities",[]);D(this,"parentExecution",null);D(this,"executing",[]);D(this,"executed",[]);D(this,"skipped",[]);D(this,"scheduled",[]);D(this,"localTestValues");D(this,"resolvedValues");D(this,"persistedExecutionResults");D(this,"lastExecutionResults");D(this,"onAddToSkippedListCallback",null);D(this,"onRemoveFromSkippedListCallback",null);D(this,"onAddEntityCallback",null);D(this,"onRemoveEntityCallback",null);D(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=r,this.entryPoint=a,this.project=i,this.parentExecution=c,this.localTestValues=new hE(M.UUID.uuid(),this.project),this.resolvedValues=new hE(M.UUID.uuid(),this.project),this.persistedExecutionResults=new hE(M.UUID.uuid(),this.project),this.lastExecutionResults=new hE(M.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults,getValueTypePreference:this.parentContext.getValueTypePreference,setValueTypePreference:this.parentContext.setValueTypePreference}}get rootExecution(){let i=this;for(;i.parentExecution;)i=i.parentExecution;return i}get rootState(){return this.rootExecution.state}isStopped(){return this.state==="stopped"||this.rootExecution.state==="stopped"}isPaused(){return this.state==="paused"||this.rootExecution.state==="paused"}async checkStateAndPause(){if(this.isStopped())throw new UN;for(;this.isPaused();){if(this.isStopped())throw new UN;await new Promise(i=>setTimeout(i,100))}}skip(i){this.hasEntity(i)&&(this.removeFromScheduledList(i),!this.skipped.includes(i)&&(this.skipped.push(i),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(i),Cr.includes(i.type)&&Lt(i).forEach(r=>this.skip(r))))}async schedule(i,r,a){if(this.hasExecuted(i))return null;if(Ei.includes(i.type))return this.executeBranch(i,a,r);if(Or.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,a,r);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,r){const a=[];return vi.includes(r.type)?a.push(...r.inputs.filter(e=>Qy(e))):[...ni,...Ei].includes(r.type)?a.push(...r.inputs):ti.includes(r.type)&&a.push(...r.outputs.filter(e=>Qy(e))),a.map(e=>{var h;let f=i.find(m=>m.valueOwner.id===e.id);if(f)return f;if(!f&&Ei.includes(r.type)&&(f=i.find(m=>{var T;return((T=m.valueOwner.declaration)==null?void 0:T.id)===e.id})),f){const m=(h=f.value)==null?void 0:h.clone(null);return m==null||m.setStandaloneParent(e,null),{...f,valueOwner:e,value:m||null,inheritanceLink:{sources:[f],target:e}}}return kn.includes(e.type)?hd(e,this.valueResolutionContext):Dp(e,this.valueResolutionContext)}).reduce((e,f)=>{const h=wu(f==null?void 0:f.valueOwner,this.project),m=f?[f]:[];return h.forEach(T=>{var w,I,C;if(T.id===(f==null?void 0:f.valueOwner.id))return;const b=ki(T.getDataType(null),T,this.project);b==null||b.metaSync({value:(w=f==null?void 0:f.value)==null?void 0:w.value},null),b==null||b.setValueAsTypeList(((I=f==null?void 0:f.value)==null?void 0:I.valueAsTypeList)||null),b==null||b.setValueAsTypeSingle(((C=f==null?void 0:f.value)==null?void 0:C.valueAsTypeSingle)||null);const A={...f,valueOwner:T,value:b};m.push(A)}),[...e,...m]},[]).sort((e,f)=>e.valueOwner.index-f.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,r,a,c={}){var f,h;this.logBeforeExecution("executeInternalCall",i,r);const e={..._c,...c};try{let m={value:K.Success,error:null,result:null};if(r.sort((C,$)=>C.valueOwner.index-$.valueOwner.index),Object.values(wn).includes(i.declaration.id)){const C=this.parentContext.requestExtension(_s+i.declaration.id).module.main;C?m=await C(i,r,this):re.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{const C=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);m={value:C.value,error:C.error,result:C.result}}let T=null;if(m.error&&i.error){re.Logger.warn("Raw error executing entity: ",m.error);const{single:C,list:$}=nK(m.error),L=Oc(C),x=(f=i.error)==null?void 0:f.getDataType(null),B=ki(x||null,i.error,a);if(x!=null&&x.asType)$!==null?B==null||B.setValueAsTypeList($):B==null||B.setValueAsTypeSingle(C);else{const q=Tn(L)?JSON.stringify(L,null,2):L;B==null||B.metaSync({value:q},null)}T={valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:B}}const b=i==null?void 0:i.getDataType(null),A=ki(b,i,a),{single:w,list:I}=nK(m.result);return b!=null&&b.asType?I!==null?A==null||A.setValueAsTypeList(I):A==null||A.setValueAsTypeSingle(w):A==null||A.metaSync({value:w},null),{value:m.value,entity:i,error:T,result:{value:A||null,valueOwner:i,type:Se.ExecutionResult,inheritanceLink:null}}}catch(m){if(m&&(m.name==="ExecutionStoppedError"||m.message==="Execution was stopped"))throw m;re.Logger.warn("Internal call execution error: ",m);let T=null;if(i.error){const b=Oc(m),A=(h=i.error)==null?void 0:h.getDataType(null),w=ki(A,i.error,a);if(A!=null&&A.asType)w==null||w.setValueAsTypeSingle(m);else{const I=Tn(b)?JSON.stringify(b,null,2):b;w==null||w.metaSync({value:I},null)}T={valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:w}}return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,entity:i,error:T,result:null}}}static async executeOperation(i,r,a,c){var e,f;c?c.logBeforeExecution("executeOperation",i,r):console.log(`executeOperation (${i.type}) -> [${he(i,a)}] Inputs:${r.length?`
62
62
  `:""}${r.map(h=>{var m,T,b;return`${(m=h.valueOwner)==null?void 0:m.type} (${(T=h.valueOwner)==null?void 0:T.id}) "${he(h.valueOwner,a)}": ${JSON.stringify((b=h.value)==null?void 0:b.value,null,2)}`}).join(`
63
63
  `)}
64
64
  `);try{let h={value:K.Success,error:null,result:null};r.sort((A,w)=>A.valueOwner.index-w.valueOwner.index),i.declaration.implementation&&(h=await i.declaration.implementation(i,r.sort((A,w)=>A.valueOwner.index-w.valueOwner.index)));let m=null;if(h.error&&i.error){const A=Oc(h.error),w=((e=i.error)==null?void 0:e.getDataType(null))||null,I=ki(w,i.error,a);if(w!=null&&w.asType)I==null||I.setValueAsTypeSingle(h.error);else{const C=Tn(A)?JSON.stringify(A,null,2):A;I==null||I.metaSync({value:C},null)}m={valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:I}}const T=i==null?void 0:i.getDataType(null),b=ki(T,i,a);return T!=null&&T.asType?b==null||b.setValueAsTypeSingle(h.result):b==null||b.metaSync({value:h.result},null),{value:h.value,entity:i,error:m,result:{value:b||null,valueOwner:i,type:Se.ExecutionResult,inheritanceLink:null}}}catch(h){if(h&&(h.name==="ExecutionStoppedError"||h.message==="Execution was stopped"))throw h;console.warn("Operation execution error: ",h);let m=null;if(i.error){const T=Oc(h),b=(f=i.error)==null?void 0:f.getDataType(null),A=ki(b,i.error,a);if(b!=null&&b.asType)A==null||A.setValueAsTypeSingle(h);else{const w=Tn(T)?JSON.stringify(T,null,2):T;A==null||A.metaSync({value:w},null)}m={valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:A}}return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,entity:i,error:m,result:null}}}async executeSearch(i,r,a){var c;this.logBeforeExecution("executeSearch",i,r);try{let e={value:K.Success,error:null,result:null};const f=await(await this.parentContext.requestExtension($e.SEARCH_NODE_IMPLEMENTATION)).module.main(i,r),h=i==null?void 0:i.getDataType(null),m=ki(h,i,a);return m==null||m.metaSync({value:f},null),f.error?{value:K.UnhandledError,entity:i,error:{valueOwner:i,type:Se.ExecutionResult,inheritanceLink:null,value:m},result:null}:{value:e.value,entity:i,error:null,result:{value:m,valueOwner:i,type:Se.ExecutionResult,inheritanceLink:null}}}catch(e){if(e&&(e.name==="ExecutionStoppedError"||e.message==="Execution was stopped"))throw e;if(re.Logger.warn(`Search node execution error: ${e}`),!i.error)return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,entity:i,error:null,result:null};const f=Oc(e),h=(c=i.error)==null?void 0:c.getDataType(null),m=ki(h,i.error,a),T=Tn(f)?JSON.stringify(f,null,2):f;return m==null||m.metaSync({value:T},null),{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,entity:i,error:{valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:m},result:null}}}async executeLoop(i,r,a,c={}){var f,h,m,T,b,A,w,I,C,$,L,x,B,q,W,z,H;this.logBeforeExecution("executeLoop",i,r);const e={..._c,...c};try{let te={value:K.Success,error:null,result:null};const se=r.map(Te=>{var Ee,Ie;return((Ee=Te==null?void 0:Te.value)==null?void 0:Ee.valueAsType)||((Ie=Te==null?void 0:Te.value)==null?void 0:Ie.value)});let Y={};const ie=i.body.inputs.find(Te=>Te!==i.currentIterationNumberArgumentDeclaration&&Te!==i.currentValueArgumentDeclaration);if(ie){const Te=ie,Ee=ki(Te.getDataType(null),Te,a);Ee==null||Ee.metaSync({value:((f=Te.defaultValue)==null?void 0:f.value)||null},null),Y[Te.id]={value:Ee||null,valueOwner:Te,type:Se.ExecutionResult,inheritanceLink:null}}let ne={value:K.Success,entity:i.body,error:null,result:null};switch(i.declaration.id){case U.loop["counted-loop"].id:{const Te=se[0];let Ee=1;for(;Ee<=Te&&Ee<=1e3;){await this.checkStateAndPause();const Ie=i.body.inputs.map(Ce=>{if(Ce===i.currentIterationNumberArgumentDeclaration){const Le=i.currentIterationNumberArgumentDeclaration.getDataType(null),Ue=bp(Le),we=this.lastExecutionResults.readValue(Ce.id);if(we){we.metaSync({value:Ee},null);const ct=Yr(we,Ce);this.lastExecutionResults.writeValue(Ce,ct);const gt={value:ct,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Se.ExecutionResult,inheritanceLink:null};return Y[Ce.id]=gt,gt}const Fe={id:M.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:M.UUID.uuid(),createdAt:new Date().toISOString(),author:M.sessionAuthor,deleted:!1,previousVersion:null,value:Ee,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ue,standaloneParent:Ce.toReference()},Je=Kr(Fe,a);this.lastExecutionResults.writeValue(Ce,Je);const Ze={value:Je,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Se.ExecutionResult,inheritanceLink:null};return Y[Ce.id]=Ze,Ze}else return Y[Ce.id]}).filter(Ce=>!!Ce);if(ne=await this.executeFullFunctionDeclarationLogic(i.body,Ie,e),ne!=null&&ne.result&&ne.value!==K.Return){const Ce=i.body.inputs.find(Le=>Le!==i.currentIterationNumberArgumentDeclaration&&Le!==i.currentValueArgumentDeclaration);if(Ce){let Le=(h=ne.result.value)==null?void 0:h.value;Le===void 0&&(Le=null),(m=Y[Ce.id].value)==null||m.metaSync({value:Le},null);const Ue=Yr(Y[Ce.id].value,Ce);this.lastExecutionResults.writeValue(Ce,Ue)}}if([K.CaughtError,K.UnhandledError,K.Break,K.Return].includes(ne.value))break;Ee++}break}case U.loop["manual-flow-loop"].id:{let Te=1;for(;Te<=50;){await this.checkStateAndPause();const Ee=i.body.inputs.map(Ie=>{if(Ie===i.currentIterationNumberArgumentDeclaration){const Ce=this.lastExecutionResults.readValue(Ie.id);if(Ce){Ce.metaSync({value:Te},null);const Fe=Yr(Ce,Ie);this.lastExecutionResults.writeValue(Ie,Fe);const Je={value:Fe,valueOwner:Ie,type:Se.ExecutionResult,inheritanceLink:null};return Y[Ie.id]=Je,Je}const Le=i.currentIterationNumberArgumentDeclaration.getDataType(null),Ue=ki(Le,Ie,a);return Ue==null||Ue.metaSync({value:Te},null),this.lastExecutionResults.writeValue(Ie,Ue),{value:Ue,valueOwner:Ie,type:Se.ExecutionResult,inheritanceLink:null}}else return Y[Ie.id]}).filter(Ie=>!!Ie);if(ne=await this.executeFullFunctionDeclarationLogic(i.body,Ee,e),ne!=null&&ne.result&&ne.value!==K.Return){const Ie=i.body.inputs.find(Ce=>Ce!==i.currentIterationNumberArgumentDeclaration&&Ce!==i.currentValueArgumentDeclaration);if(Ie){let Ce=(T=ne.result.value)==null?void 0:T.value;Ce===void 0&&(Ce=null),(b=Y[Ie.id].value)==null||b.metaSync({value:Ce},null);const Le=Yr(Y[Ie.id].value,Ie);this.lastExecutionResults.writeValue(Ie,Le)}}if([K.CaughtError,K.UnhandledError,K.Break,K.Return].includes(ne.value))break;Te++}break}case U.loop["list-loop"].id:{const Te=se[0];let Ee=1;const Ie=Te;for(let Ce=0;Ce<Ie.length;Ce++){await this.checkStateAndPause();const Le=Ie[Ce],Ue=i.body.inputs.map(we=>{if(we===i.currentIterationNumberArgumentDeclaration){const Fe=this.lastExecutionResults.readValue(we.id);if(Fe){Fe.metaSync({value:Ee},null);const gt=Yr(Fe,we);return this.lastExecutionResults.writeValue(we,gt),{value:gt,valueOwner:we,type:Se.ExecutionResult,inheritanceLink:null}}const Je=i.currentIterationNumberArgumentDeclaration.getDataType(null),Ze=ki(Je,we,a);return Ze==null||Ze.metaSync({value:Ee},null),this.lastExecutionResults.writeValue(we,Ze),{value:Ze,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Se.ExecutionResult,inheritanceLink:null}}else if(we===i.currentValueArgumentDeclaration){const Fe=i.currentValueArgumentDeclaration.getDataType(null),Je=bp(Fe),Ze=this.lastExecutionResults.readValue(we.id);if(Ze){Ze.metaSync({value:Le},null);const st=Yr(Ze,we);return this.lastExecutionResults.writeValue(we,st),{value:st,valueOwner:we,type:Se.ExecutionResult,inheritanceLink:null}}const ct={id:M.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:M.UUID.uuid(),createdAt:new Date().toISOString(),author:M.sessionAuthor,deleted:!1,previousVersion:null,value:Le,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Je,standaloneParent:we.toReference()},gt=Kr(ct,a);return this.lastExecutionResults.writeValue(we,gt),{value:gt,valueOwner:i.currentValueArgumentDeclaration,type:Se.ExecutionResult,inheritanceLink:null}}else return Y[we.id]}).filter(we=>!!we);if(ne=await this.executeFullFunctionDeclarationLogic(i.body,Ue,e),ne!=null&&ne.result&&ne.value!==K.Return){const we=i.body.inputs.find(Fe=>Fe!==i.currentIterationNumberArgumentDeclaration&&Fe!==i.currentValueArgumentDeclaration);if(we){let Fe=(A=ne.result.value)==null?void 0:A.value;Fe===void 0&&(Fe=null),(w=Y[we.id].value)==null||w.metaSync({value:Fe},null);const Je=Yr(Y[we.id].value,we);this.lastExecutionResults.writeValue(we,Je)}}if([K.CaughtError,K.UnhandledError,K.Break,K.Return].includes(ne.value))break;Ee++}break}case U.loop["object-keys-loop"].id:{const Te=se[0];let Ee=1;const Ie=Te?Object.keys(Te):[];for(let Ce=0;Ce<Ie.length;Ce++){await this.checkStateAndPause();const Le=Ie[Ce],Ue=i.body.inputs.map(we=>{if(we===i.currentIterationNumberArgumentDeclaration){const Fe=this.lastExecutionResults.readValue(we.id);if(Fe){Fe.metaSync({value:Ee},null);const gt=Yr(Fe,we);return this.lastExecutionResults.writeValue(we,gt),{value:gt,valueOwner:we,type:Se.ExecutionResult,inheritanceLink:null}}const Je=i.currentIterationNumberArgumentDeclaration.getDataType(null),Ze=ki(Je,we,a);return Ze==null||Ze.metaSync({value:Ee},null),this.lastExecutionResults.writeValue(we,Ze),{value:Ze,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Se.ExecutionResult,inheritanceLink:null}}else if(we===i.currentValueArgumentDeclaration){const Fe=i.currentValueArgumentDeclaration.getDataType(null),Je=bp(Fe),Ze=this.lastExecutionResults.readValue(we.id);if(Ze){Ze.metaSync({value:Le},null);const st=Yr(Ze,we);return this.lastExecutionResults.writeValue(we,st),{value:Ze,valueOwner:we,type:Se.ExecutionResult,inheritanceLink:null}}const ct={id:M.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:M.UUID.uuid(),createdAt:new Date().toISOString(),author:M.sessionAuthor,deleted:!1,previousVersion:null,value:Le,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Je,standaloneParent:we.toReference()},gt=Kr(ct,a);return this.lastExecutionResults.writeValue(we,gt),{value:gt,valueOwner:i.currentValueArgumentDeclaration,type:Se.ExecutionResult,inheritanceLink:null}}else return Y[we.id]}).filter(we=>!!we);if(ne=await this.executeFullFunctionDeclarationLogic(i.body,Ue,e),ne!=null&&ne.result&&ne.value!==K.Return){const we=i.body.inputs.find(Fe=>Fe!==i.currentIterationNumberArgumentDeclaration&&Fe!==i.currentValueArgumentDeclaration);if(we){let Fe=(I=ne.result.value)==null?void 0:I.value;Fe===void 0&&(Fe=null),(C=Y[we.id].value)==null||C.metaSync({value:Fe},null);const Je=Yr(Y[we.id].value,we);this.lastExecutionResults.writeValue(we,Je)}}if([K.CaughtError,K.UnhandledError,K.Break,K.Return].includes(ne.value))break;Ee++}break}case U.loop["object-values-loop"].id:{const Te=se[0];let Ee=1;const Ie=Te?Object.values(Te):[];for(let Ce=0;Ce<Ie.length;Ce++){await this.checkStateAndPause();const Le=Ie[Ce],Ue=i.body.inputs.map(we=>{if(we===i.currentIterationNumberArgumentDeclaration){const Fe=this.lastExecutionResults.readValue(we.id);if(Fe){Fe.metaSync({value:Ee},null);const gt=Yr(Fe,we);return this.lastExecutionResults.writeValue(we,gt),{value:gt,valueOwner:we,type:Se.ExecutionResult,inheritanceLink:null}}const Je=i.currentIterationNumberArgumentDeclaration.getDataType(null),Ze=ki(Je,we,a);return Ze==null||Ze.metaSync({value:Ee},null),this.lastExecutionResults.writeValue(we,Ze),{value:Ze,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Se.ExecutionResult,inheritanceLink:null}}else if(we===i.currentValueArgumentDeclaration){const Fe=i.currentValueArgumentDeclaration.getDataType(null),Je=bp(Fe),Ze=this.lastExecutionResults.readValue(we.id);if(Ze){Ze.metaSync({value:Le},null);const st=Yr(Ze,we);return this.lastExecutionResults.writeValue(we,st),{value:Ze,valueOwner:we,type:Se.ExecutionResult,inheritanceLink:null}}const ct={id:M.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:M.UUID.uuid(),createdAt:new Date().toISOString(),author:M.sessionAuthor,deleted:!1,previousVersion:null,value:Le,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Je,standaloneParent:we.toReference()},gt=Kr(ct,a);return this.lastExecutionResults.writeValue(we,gt),{value:gt,valueOwner:i.currentValueArgumentDeclaration,type:Se.ExecutionResult,inheritanceLink:null}}else return Y[we.id]}).filter(we=>!!we);if(ne=await this.executeFullFunctionDeclarationLogic(i.body,Ue,e),ne!=null&&ne.result&&ne.value!==K.Return){const we=i.body.inputs.find(Fe=>Fe!==i.currentIterationNumberArgumentDeclaration&&Fe!==i.currentValueArgumentDeclaration);if(we){let Fe=($=ne.result.value)==null?void 0:$.value;Fe===void 0&&(Fe=null),(L=Y[we.id].value)==null||L.metaSync({value:Fe},null);const Je=Yr(Y[we.id].value,we);this.lastExecutionResults.writeValue(we,Je)}}if([K.CaughtError,K.UnhandledError,K.Break,K.Return].includes(ne.value))break;Ee++}break}case U.loop["string-loop"].id:{const Te=se[0];let Ee=1;const Ie=Te.split("");for(let Ce=0;Ce<Ie.length;Ce++){await this.checkStateAndPause();const Le=Ie[Ce],Ue=i.body.inputs.map(we=>{if(we===i.currentIterationNumberArgumentDeclaration){const Fe=this.lastExecutionResults.readValue(we.id);if(Fe){Fe.metaSync({value:Ee},null);const gt=Yr(Fe,we);return this.lastExecutionResults.writeValue(we,gt),{value:gt,valueOwner:we,type:Se.ExecutionResult,inheritanceLink:null}}const Je=i.currentIterationNumberArgumentDeclaration.getDataType(null),Ze=ki(Je,we,a);return Ze==null||Ze.metaSync({value:Ee},null),this.lastExecutionResults.writeValue(we,Ze),{value:Ze,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Se.ExecutionResult,inheritanceLink:null}}else if(we===i.currentValueArgumentDeclaration){const Fe=i.currentValueArgumentDeclaration.getDataType(null),Je=bp(Fe),Ze=this.lastExecutionResults.readValue(we.id);if(Ze){Ze.metaSync({value:Le},null);const st=Yr(Ze,we);return this.lastExecutionResults.writeValue(we,st),{value:st,valueOwner:we,type:Se.ExecutionResult,inheritanceLink:null}}const ct={id:M.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:M.UUID.uuid(),createdAt:new Date().toISOString(),author:M.sessionAuthor,deleted:!1,previousVersion:null,value:Le,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Je,standaloneParent:we.toReference()},gt=Kr(ct,a);return this.lastExecutionResults.writeValue(we,gt),{value:gt,valueOwner:i.currentValueArgumentDeclaration,type:Se.ExecutionResult,inheritanceLink:null}}else return Y[we.id]}).filter(we=>!!we);if(ne=await this.executeFullFunctionDeclarationLogic(i.body,Ue,e),(ne.results||[]).forEach(we=>{var gt,dt,st;if(we.valueOwner.type!==d.InputMap||ti.includes(we.valueOwner.parent.type))return;const Fe=i.body.inputs.find(ut=>he(ut,a)===he(we.valueOwner,a)),Ze=[...(gt=Y[Fe.id].value)==null?void 0:gt.value,((dt=we.value)==null?void 0:dt.value)||null];(st=Y[Fe.id].value)==null||st.metaSync({value:Ze},null);const ct=Yr(Y[Fe.id].value,Fe);this.lastExecutionResults.writeValue(Fe,ct)}),[K.CaughtError,K.UnhandledError,K.Break,K.Return].includes(ne.value))break;Ee++}break}}let pe=K.Success;if(ne.value===K.UnhandledError?i.catchesError||i.errorCalls.length?pe=K.CaughtError:pe=K.UnhandledError:[K.CaughtError,K.Return].includes(ne.value)&&(pe=ne.value),te={value:pe,error:((B=(x=ne.error)==null?void 0:x.value)==null?void 0:B.value)||null,result:((W=(q=ne==null?void 0:ne.result)==null?void 0:q.value)==null?void 0:W.value)||null},te.value===K.UnhandledError||te.value===K.CaughtError){let Te=null;if(i.error){const Ee=Oc(te.error),Ie=(z=i.error)==null?void 0:z.getDataType(null),Ce=ki(Ie||null,i.error,a);if(Ie!=null&&Ie.asType)Ce==null||Ce.setValueAsTypeSingle(te.error);else{const Le=Tn(Ee)?JSON.stringify(Ee,null,2):Ee;Ce==null||Ce.metaSync({value:Le},null)}Te={valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:Ce}}return{value:te.value,entity:i,error:Te,result:null}}const ue=i==null?void 0:i.getDataType(null),me=ki(ue,i,a);return ue!=null&&ue.asType?me==null||me.setValueAsTypeSingle(te.result):me==null||me.metaSync({value:te.result},null),{value:te.value,entity:i,error:null,result:{value:me||null,valueOwner:i,type:Se.ExecutionResult,inheritanceLink:null}}}catch(te){if(te&&(te.name==="ExecutionStoppedError"||te.message==="Execution was stopped"))throw te;if(re.Logger.warn("Error executing loop: ",te),i.error){const se=Oc(te),Y=(H=i.error)==null?void 0:H.getDataType(null),ie=ki(Y,i.error,a);if(Y!=null&&Y.asType)ie==null||ie.setValueAsTypeSingle(te);else{const ne=Tn(se)?JSON.stringify(se,null,2):se;ie==null||ie.metaSync({value:ne},null)}return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,entity:i,error:{valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:ie},result:null}}else return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,entity:i,error:null,result:null}}}async executeFunctionCall(i,r,a,c={}){var f,h,m,T,b,A,w,I,C,$,L,x,B,q,W,z,H,te,se,Y,ie,ne,pe,ue,me,Te;const e={..._c,...c};try{this.logBeforeExecution("executeFunctionCall",i,r);const Ee=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);let Ie=null;if(Ee.error&&i.error){re.Logger.warn("Raw error executing entity: ",Ee.error);const we=(f=i.error)==null?void 0:f.getDataType(null),Fe=ki(we||null,i.error,a);we!=null&&we.asType?(m=(h=Ee.error)==null?void 0:h.value)!=null&&m.valueAsTypeSingle?Fe==null||Fe.setValueAsTypeSingle((b=(T=Ee.error)==null?void 0:T.value)==null?void 0:b.valueAsTypeSingle):(w=(A=Ee.error)==null?void 0:A.value)!=null&&w.valueAsTypeList&&Array.isArray((C=(I=Ee.error)==null?void 0:I.value)==null?void 0:C.valueAsTypeList)&&(Fe==null||Fe.setValueAsTypeList((L=($=Ee.error)==null?void 0:$.value)==null?void 0:L.valueAsTypeList)):Fe==null||Fe.metaSync({value:(B=(x=Ee.error)==null?void 0:x.value)==null?void 0:B.value},null),Ie={valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:Fe}}let Ce=K.Success;Ee.value===K.UnhandledError&&(i.catchesError||i.errorCalls.length?Ce=K.CaughtError:Ce=K.UnhandledError);const Le=i==null?void 0:i.getDataType(null),Ue=ki(Le,i,a);return Le!=null&&Le.asType?(W=(q=Ee.result)==null?void 0:q.value)!=null&&W.valueAsTypeSingle?Ue==null||Ue.setValueAsTypeSingle((H=(z=Ee.result)==null?void 0:z.value)==null?void 0:H.valueAsTypeSingle):(se=(te=Ee.result)==null?void 0:te.value)!=null&&se.valueAsTypeList&&Array.isArray((ie=(Y=Ee.result)==null?void 0:Y.value)==null?void 0:ie.valueAsTypeList)&&(Ue==null||Ue.setValueAsTypeList((pe=(ne=Ee.result)==null?void 0:ne.value)==null?void 0:pe.valueAsTypeList)):Ue==null||Ue.metaSync({value:((me=(ue=Ee.result)==null?void 0:ue.value)==null?void 0:me.value)||null},null),{value:Ce,entity:i,error:Ie,result:{value:Ue||null,valueOwner:i,type:Se.ExecutionResult,inheritanceLink:null}}}catch(Ee){if(Ee&&(Ee.name==="ExecutionStoppedError"||Ee.message==="Execution was stopped"))throw Ee;if(!i.error)return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,entity:i,error:null,result:null};const Ie=Oc(Ee),Ce=(Te=i.error)==null?void 0:Te.getDataType(null),Le=ki(Ce,i.error,a);if(Ce!=null&&Ce.asType)Le==null||Le.setValueAsTypeSingle(Ee);else{const Ue=Tn(Ie)?JSON.stringify(Ie,null,2):Ie;Le==null||Le.metaSync({value:Ue},null)}return{value:i.catchesError||i.errorCalls.length?K.CaughtError:K.UnhandledError,entity:i,error:{valueOwner:i.error,type:Se.ExecutionResult,inheritanceLink:null,value:Le},result:null}}}async executeCondition(i,r){var c,e,f,h;this.logBeforeExecution("executeCondition",i,r);let a=!1;switch(i.declaration.id){case ua.BooleanIsTrue:{const m=(e=(c=r[0])==null?void 0:c.value)==null?void 0:e.value;if(typeof m!="boolean")throw new TypeError("BooleanIsTrue expects a boolean input.");a=m===!0;break}case ua.BooleanIsFalse:{const m=(h=(f=r[0])==null?void 0:f.value)==null?void 0:h.value;if(typeof m!="boolean")throw new TypeError("BooleanIsFalse expects a boolean input.");a=m===!1;break}case vn.And:{a=(await Promise.all(i.andChildrenGroup.map(async T=>{const b=this.mergeExernalValuesWithInternalInputs(r,T);return(await this.executeCondition(T,b)).value===K.Success}))).every(T=>T);break}case vn.Or:{a=(await Promise.all(i.orChildrenGroup.map(async T=>{const b=this.mergeExernalValuesWithInternalInputs(r,T);return(await this.executeCondition(T,b)).value===K.Success}))).some(T=>T);break}default:throw new Error(`Condition declaration ${i.declaration.name} does not have an implementation.`)}return{value:a?K.Success:K.ConditionNotMet,entity:i,error:null,result:null}}async executeDetachedFullFunctionDeclarationLogic(i,r,a,c={}){this.logBeforeExecution("executeDetachedFullFunctionDeclarationLogic",i,r);const e={..._c,...c,onBeforeEntityExecution:(m,T,b)=>{var A;return((A=c==null?void 0:c.onBeforeEntityExecution)==null?void 0:A.call(c,m,T,{...b,detached:!0}))||Promise.resolve()},onEntityExecuted:(m,T,b)=>{var A;return((A=c==null?void 0:c.onEntityExecuted)==null?void 0:A.call(c,m,T,{...b,detached:!0}))||Promise.resolve()}},f=new Lm(a,[i,...UR(i)],i,this,this.parentContext);return f.inheritValuesFromContext(this),await f.execute(e,r)}async executeFullFunctionDeclarationLogic(i,r,a={}){this.logBeforeExecution("executeFullFunctionDeclarationLogic",i,r);const c={..._c,...a},e=UR(i),f=[];e.forEach(T=>{if(T.type===d.VariableDeclaration||T.type===d.VariableInstance){const b=T;b.internalCalls&&f.push(...b.internalCalls)}}),e.push(...f),console.log(`[executeFullFunctionDeclarationLogic] Reseting children for: ${he(i,this.project)}
package/dist/index.js CHANGED
@@ -141097,7 +141097,7 @@ class wOi extends Ve {
141097
141097
  `${T}The "${He(D == null ? void 0 : D.valueOwner, f == null ? void 0 : f.logic, "Folder path")}" (\`${yt(D == null ? void 0 : D.valueOwner, f == null ? void 0 : f.logic, "folderPath")}\`) input value is invalid, if present, it must be a non-empty string.`
141098
141098
  );
141099
141099
  const L = await Ur.post(
141100
- `${f.env.API_BASE_URL}/cloud-files-service/v1/files/folder`,
141100
+ `${f.env.API_BASE_URL}/cloud-files-service/v1/files/folders`,
141101
141101
  { bucket: w, folderPath: $ },
141102
141102
  {
141103
141103
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.7101",
3
+ "version": "0.0.7102",
4
4
  "author": "Sergio Herrero",
5
5
  "license": "UNLICENSED",
6
6
  "description": "An installable module which contains the type definitions and ephemeral state management for a projects' logic tree data structure",