@elyx-code/project-logic-tree 0.0.7140 → 0.0.7141

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 mot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleDriveUploadFile,version:"2.0.0",description:"Upload a file to Google Drive (media / import+copy) with auto content detection and simplified inputs.",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleDriveUploadFile);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I,A,D,V,N,_,L,K,q,W,H,te,ne,z,Q,J,ae,ee,de,ye,fe,ve,Ce,Oe;try{const Ne=((c=(a=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.connection.id}))==null?void 0:a.value)==null?void 0:c.valueAsType)??((f=(e=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.connection.id}))==null?void 0:e.value)==null?void 0:f.value);if(!(Ne instanceof Na))return Mp(i,"Invalid or missing connection entity");const De=((m=(h=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.content.id}))==null?void 0:h.value)==null?void 0:m.valueAsType)??((g=(T=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.content.id}))==null?void 0:T.value)==null?void 0:g.value),Ue=(V=((I=(E=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.name.id}))==null?void 0:E.value)==null?void 0:I.valueAsType)??((D=(A=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.name.id}))==null?void 0:A.value)==null?void 0:D.value))==null?void 0:V.trim(),Je=(((_=(N=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.mimeType.id}))==null?void 0:N.value)==null?void 0:_.valueAsType)??((K=(L=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.mimeType.id}))==null?void 0:L.value)==null?void 0:K.value))||"application/octet-stream",qe=(((W=(q=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.folderId.id}))==null?void 0:q.value)==null?void 0:W.valueAsType)??((te=(H=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.folderId.id}))==null?void 0:H.value)==null?void 0:te.value))||void 0,rt=(((z=(ne=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.description.id}))==null?void 0:ne.value)==null?void 0:z.valueAsType)??((J=(Q=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.description.id}))==null?void 0:Q.value)==null?void 0:J.value))||void 0,dt=(((ee=(ae=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.importMimeType.id}))==null?void 0:ae.value)==null?void 0:ee.valueAsType)??((ye=(de=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.importMimeType.id}))==null?void 0:de.value)==null?void 0:ye.value))||"text/plain";if(!Ue)return Mp(i,"Missing required input: name");const ze=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],it=fr(Ne),Mt={Authorization:`Bearer ${await ze.getAccessToken()}`},jt=`${((fe=ze.env)==null?void 0:fe.API_BASE_URL)+"/editor-runtime"}/v2/external-integrations/proxy/${ze.projectId}/${vi["google-drive"]}/${it}`,wt=async(Wi,pi,{params:ci,body:As,contentType:rs,providerHeaders:Ar,responseType:mr}={})=>{const ri=`${jt}/${Ren(pi)}`,zt={...Mt};return rs&&(zt["Content-Type"]=rs),(Ar||mr)&&(zt[Ien]=JSON.stringify({...Ar?{headers:Ar}:{},...mr?{responseType:mr}:{}})),Ii.request({method:Wi,url:ri,params:ci,data:As,responseType:mr||"json",headers:zt})},ht=typeof Je=="string"&&Je.startsWith("application/vnd.google-apps.");if(ht&&(De==null||De==="")){const Wi={name:Ue,mimeType:Je};qe&&(Wi.parents=[qe]),typeof rt=="string"&&(Wi.description=rt);const pi=await wt("POST","/drive/v3/files",{params:{supportsAllDrives:"true",fields:zb},body:JSON.stringify(Wi),contentType:"application/json"});return pi.status!==200&&pi.status!==201?Mp(i,`Drive create failed (status=${pi.status})`):LV({file:pi.data})}if(ht&&De!=null){let Wi=await Cen(De);const ci=((mr,ri)=>ri||(mr==="application/vnd.google-apps.spreadsheet"?"text/csv":mr==="application/vnd.google-apps.document"||mr==="application/vnd.google-apps.presentation"?"text/html":"text/plain"))(Je,dt),As=ci.startsWith("text/")&&!/charset=/i.test(ci)?`${ci}; charset=UTF-8`:ci;ci.startsWith("text/csv")&&(Wi=wen(Wi));const rs=new TextEncoder().encode(Wi);if(rs.byteLength>dq)return Mp(i,`Text body exceeds simple upload limit (${rs.byteLength} bytes).`);let Ar;try{const mr=await wt("POST","/upload/drive/v3/files",{params:{uploadType:"media",supportsAllDrives:"true",fields:zb},body:rs,contentType:As});if(mr.status!==200&&mr.status!==201)return Mp(i,`Drive media upload failed (status=${mr.status})`);if(Ar=(ve=mr.data)==null?void 0:ve.id,!Ar)return Mp(i,"Drive media upload did not return an id");const ri={name:Ue,mimeType:Je};qe&&(ri.parents=[qe]),typeof rt=="string"&&(ri.description=rt);const zt=await wt("POST",`/drive/v3/files/${encodeURIComponent(Ar)}/copy`,{params:{supportsAllDrives:"true",fields:zb},body:JSON.stringify(ri),contentType:"application/json"});return zt.status!==200&&zt.status!==201?Mp(i,`Drive copy-convert failed (status=${zt.status})`):LV({file:zt.data})}finally{if(Ar)try{await wt("DELETE",`/drive/v3/files/${encodeURIComponent(Ar)}`,{params:{supportsAllDrives:"true"}})}catch{}}}if(De==null)return Mp(i,"Missing content for non-native upload");const{bytes:Jt,inferredMime:ut,isBinary:Et}=await Den(De),xt=Jt.byteLength;if(xt>dq)return Mp(i,`File too large for simple upload (${xt} bytes).`);const Er=await wt("POST","/upload/drive/v3/files",{params:{uploadType:"media",supportsAllDrives:"true",fields:zb},body:Jt,contentType:Je||ut||(Et?"application/octet-stream":"text/plain; charset=UTF-8")});if(Er.status!==200&&Er.status!==201)return Mp(i,`Drive media upload failed (status=${Er.status})`);let Ms=Er.data;const Es=(Ce=Er.data)==null?void 0:Ce.id;return Es&&(qe||Ue||rt)&&(Ms=await Oen(wt,Es,Ue,rt,qe)),LV({file:Ms})}catch(Ne){const De=((Oe=Ne.response)==null?void 0:Oe.data)||Ne.message||Ne;return oe.Logger.error("[Google Drive] Upload document failed:",De),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:De,result:null}}}})}}function LV(l){return{value:j.Success,error:null,result:l}}function Mp(l,u){return oe.Logger.log("[Google Drive] Upload error:",u),{value:l.catchesError||l.errorCalls.length?j.CaughtError:j.UnhandledError,error:u,result:null}}async function Oen(l,u,i,n,a){const c={};i&&(c.name=i),typeof n=="string"&&(c.description=n);const e={supportsAllDrives:"true",fields:zb},f={...e};a&&(f.addParents=a,f.removeParents="root");let h=await l("PATCH",`/drive/v3/files/${encodeURIComponent(u)}`,{params:f,body:JSON.stringify(c),contentType:"application/json"});if(h.status>=400&&a&&(h=await l("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}const Pen="id,name,mimeType,webViewLink",xen="X-Elyx-Proxy-Config";function _en(l){return l.startsWith("/")?l.slice(1):l}const GV=(l,u)=>(oe.Logger.log("[Google Drive Clone Document] error:",u),{value:l.catchesError||l.errorCalls.length?j.CaughtError:j.UnhandledError,error:u,result:null});class Tot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleDriveCloneDocument,version:"1.0.0",description:"Google Drive clone document operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleDriveCloneDocument);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I,A,D,V,N,_,L;try{const K=B.operation[me.GoogleDriveCloneDocument],q=((c=(a=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.connection.id}))==null?void 0:a.value)==null?void 0:c.valueAsType)??((f=(e=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.connection.id}))==null?void 0:e.value)==null?void 0:f.value);if(!(q instanceof Na))return GV(i,"Invalid or missing connection entity");const W=(m=(h=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.documentId.id}))==null?void 0:h.value)==null?void 0:m.value;if(!W)return GV(i,"Missing required input: documentId");const H=(g=(T=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.newName.id}))==null?void 0:T.value)==null?void 0:g.value,te=(I=(E=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.parentFolderIds.id}))==null?void 0:E.value)==null?void 0:I.value,ne=(D=(A=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.description.id}))==null?void 0:A.value)==null?void 0:D.value,z=(N=(V=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.starred.id}))==null?void 0:V.value)==null?void 0:N.value,Q=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],J=fr(q),ee={Authorization:`Bearer ${await Q.getAccessToken()}`},de=`${((_=Q.env)==null?void 0:_.API_BASE_URL)+"/editor-runtime"}/v2/external-integrations/proxy/${Q.projectId}/${vi["google-drive"]}/${J}`,ye=async(Oe,Ne,{params:De,body:Ue,contentType:Je,providerHeaders:qe,responseType:rt}={})=>{const dt=`${de}/${_en(Ne)}`,ze={...ee};return Je&&(ze["Content-Type"]=Je),(qe||rt)&&(ze[xen]=JSON.stringify({...qe?{headers:qe}:{},...rt?{responseType:rt}:{}})),Ii({method:Oe,url:dt,headers:ze,params:De,data:Ue,responseType:rt||"json"})},fe={};H&&(fe.name=H),te&&te.length>0&&(fe.parents=te),ne&&(fe.description=ne),z!==void 0&&(fe.starred=z);const Ce=(await ye("POST",`/v3/files/${W}/copy`,{params:{fields:Pen,supportsAllDrives:!0},body:fe,contentType:"application/json"})).data;return{value:j.Success,error:null,result:{id:Ce.id,name:Ce.name,mimeType:Ce.mimeType,webViewLink:Ce.webViewLink}}}catch(K){const q=((L=K.response)==null?void 0:L.data)||K.message||K;return GV(i,q)}}})}}const Ven="X-Elyx-Proxy-Config";function Nen(l){return l.startsWith("/")?l.slice(1):l}const BV=(l,u)=>(oe.Logger.log("[Google Drive Delete Document] error:",u),{value:l.catchesError||l.errorCalls.length?j.CaughtError:j.UnhandledError,error:u,result:null});class vot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleDriveDeleteDocument,version:"1.0.0",description:"Google Drive delete document operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleDriveDeleteDocument);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I;try{const A=B.operation[me.GoogleDriveDeleteDocument],D=((c=(a=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===A.inputs.connection.id}))==null?void 0:a.value)==null?void 0:c.valueAsType)??((f=(e=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===A.inputs.connection.id}))==null?void 0:e.value)==null?void 0:f.value);if(!(D instanceof Na))return BV(i,"Invalid or missing connection entity");const V=(m=(h=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===A.inputs.documentId.id}))==null?void 0:h.value)==null?void 0:m.value;if(!V)return BV(i,"Missing required input: documentId");const N=(g=(T=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===A.inputs.permanent.id}))==null?void 0:T.value)==null?void 0:g.value,_=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],L=fr(D),q={Authorization:`Bearer ${await _.getAccessToken()}`},W=`${((E=_.env)==null?void 0:E.API_BASE_URL)+"/editor-runtime"}/v2/external-integrations/proxy/${_.projectId}/${vi["google-drive"]}/${L}`,H=async(te,ne,{params:z,body:Q,contentType:J,providerHeaders:ae,responseType:ee}={})=>{const de=`${W}/${Nen(ne)}`,ye={...q};return J&&(ye["Content-Type"]=J),(ae||ee)&&(ye[Ven]=JSON.stringify({...ae?{headers:ae}:{},...ee?{responseType:ee}:{}})),Ii({method:te,url:de,headers:ye,params:z,data:Q,responseType:ee||"json"})};return N?await H("DELETE",`/v3/files/${V}`,{params:{supportsAllDrives:!0}}):await H("PATCH",`/v3/files/${V}`,{params:{supportsAllDrives:!0},body:{trashed:!0},contentType:"application/json"}),{value:j.Success,error:null,result:null}}catch(A){const D=((I=A.response)==null?void 0:I.data)||A.message||A;return BV(i,D)}}})}}class got extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleGeminiGenerateContent,version:"1.0.0",description:"Send Gmail email operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleGeminiGenerateContent);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h;try{const m=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.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?j.CaughtError:j.UnhandledError,error:"No entity template provided",result:null};if(!(T instanceof Na))return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:"Invalid entity template value provided",result:null};const g=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation["external-integration--google-gemini--post--generate-content"].inputs.prompt.id}),E=(c=g==null?void 0:g.value)==null?void 0:c.value;if(!E||typeof E!="string")return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:"Invalid prompt value provided",result:null};const I=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation["external-integration--google-gemini--post--generate-content"].inputs.model.id}),A=(e=I==null?void 0:I.value)==null?void 0:e.value;if(!A||typeof A!="string")return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:"Invalid model value provided",result:null};const D=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],V=fr(T);console.log("Triggering Google Gemini generate content action with connectionId:",V);const N=await(await Ii.post(`${(f=D.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/trigger-action/${vi["google-gemini"]}/${V}/generate-content`,{payload:{prompt:E,model:A}},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${await D.getAccessToken()}`}})).data;return oe.Logger.log("[Google Gemini] Generate content action response:",N),{value:j.Success,error:null,result:{content:N.content}}}catch(m){const T=((h=m.response)==null?void 0:h.data)||m.message||m;return oe.Logger.error("[Google Gemini] Generate content failed:",T),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:T,result:null}}}})}}class bot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsCreateSpreadsheet,version:"1.0.0",description:"Create Spreadsheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsCreateSpreadsheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"createSpreadsheet"),E="["+je(i,i.project,"Create spreadsheet")+": `"+T+"`] ",I=(z,Q,J)=>{const ae=je(z==null?void 0:z.valueOwner,m==null?void 0:m.logic,Q),ee=Xe(z==null?void 0:z.valueOwner,m==null?void 0:m.logic,J);return`"${ae}" (\`${ee}\`)`},A=n.find(z=>{var Q;return((Q=z.valueOwner.declaration)==null?void 0:Q.id)===B.operation[me.GoogleSheetsCreateSpreadsheet].inputs.connection.id}),D=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!D||!D.id||!D.name||D.type!==r.DefinitionEntity)throw new Error(`${E}The ${I(A,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const V=fr(D);if(!V)throw new Error(`${E}The ${I(A,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const N=n.find(z=>{var Q;return((Q=z.valueOwner.declaration)==null?void 0:Q.id)===B.operation[me.GoogleSheetsCreateSpreadsheet].inputs.title.id}),_=(c=N==null?void 0:N.value)==null?void 0:c.value;if(_&&typeof _!="string")throw new Error(`${E}The ${I(N,"Title","title")} input value is invalid. If present, it must be a non-empty string. E.g. "My Spreadsheet"`);const K={Authorization:`Bearer ${await m.getAccessToken()}`},q=`${(e=m.env)==null?void 0:e.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${m.projectId}/${vi["google-sheet"]}/${V}`,W=async z=>Ii.post(q,z,{headers:K}),H={};_&&(H.properties={title:_});const ne=((f=(await W({method:"POST",endpoint:"/v4/spreadsheets",data:H})).data)==null?void 0:f.data)||{};return{value:j.Success,error:null,result:{spreadsheetId:ne.spreadsheetId,spreadsheetUrl:ne.spreadsheetUrl}}}catch(m){const T=((h=m.response)==null?void 0:h.data)||m.message||m;return oe.Logger.log("[Google Sheets] error:",T),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:T,result:null}}}})}}class Eot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsGetSpreadsheet,version:"1.0.0",description:"Get Spreadsheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsGetSpreadsheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"getSpreadsheet"),I="["+je(i,i.project,"Get spreadsheet")+": `"+g+"`] ",A=(z,Q,J)=>{const ae=je(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,Q),ee=Xe(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,J);return`"${ae}" (\`${ee}\`)`},D=n.find(z=>{var Q;return((Q=z.valueOwner.declaration)==null?void 0:Q.id)===B.operation[me.GoogleSheetsGetSpreadsheet].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(z=>{var Q;return((Q=z.valueOwner.declaration)==null?void 0:Q.id)===B.operation[me.GoogleSheetsGetSpreadsheet].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q={Authorization:`Bearer ${await T.getAccessToken()}`},W=`${(e=T.env)==null?void 0:e.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=((f=(await(async z=>Ii.post(W,z,{headers:q}))({method:"GET",endpoint:`/v4/spreadsheets/${L}`})).data)==null?void 0:f.data)||{};return{value:j.Success,error:null,result:{title:(h=ne.properties)==null?void 0:h.title,spreadsheetUrl:ne.spreadsheetUrl}}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class Aot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsAddSheet,version:"1.0.0",description:"Add Sheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsAddSheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I;try{const A=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!A||!A.env)throw new Error("Editor context or environment missing");const D=Xe(i,i.project,"addSheet"),N="["+je(i,i.project,"Add sheet")+": `"+D+"`] ",_=(fe,ve,Ce)=>{const Oe=je(fe==null?void 0:fe.valueOwner,A==null?void 0:A.logic,ve),Ne=Xe(fe==null?void 0:fe.valueOwner,A==null?void 0:A.logic,Ce);return`"${Oe}" (\`${Ne}\`)`},L=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAddSheet].inputs.connection.id}),K=(a=L==null?void 0:L.value)==null?void 0:a.valueAsType;if(!K||!K.id||!K.name||K.type!==r.DefinitionEntity)throw new Error(`${N}The ${_(L,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const q=fr(K);if(!q)throw new Error(`${N}The ${_(L,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const W=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAddSheet].inputs.spreadsheetId.id}),H=(c=W==null?void 0:W.value)==null?void 0:c.value;if(!H||H==="")throw new Error(`${N}The ${_(W,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof H!="string")throw new Error(`${N}The ${_(W,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const te=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAddSheet].inputs.title.id}),ne=(e=te==null?void 0:te.value)==null?void 0:e.value;if(ne!=null&&typeof ne!="string")throw new Error(`${N}The ${_(te,"Title","title")} input value is invalid. If present, it must be a string. E.g. "New Sheet"`);const Q={Authorization:`Bearer ${await A.getAccessToken()}`},J=`${(f=A.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${A.projectId}/${vi["google-sheet"]}/${q}`,ye=(E=(g=(T=(m=(((h=(await(async fe=>Ii.post(J,fe,{headers:Q}))({method:"POST",endpoint:`/v4/spreadsheets/${H}:batchUpdate`,data:{requests:[{addSheet:{properties:{title:ne}}}]}})).data)==null?void 0:h.data)||{}).replies)==null?void 0:m[0])==null?void 0:T.addSheet)==null?void 0:g.properties)==null?void 0:E.sheetId;return{value:j.Success,error:null,result:{sheetId:ye}}}catch(A){const D=((I=A.response)==null?void 0:I.data)||A.message||A;return oe.Logger.log("[Google Sheets] error:",D),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:D,result:null}}}})}}class Iot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsDeleteSheet,version:"1.0.0",description:"Delete Sheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsDeleteSheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"deleteSheet"),E="["+je(i,i.project,"Delete sheet")+": `"+T+"`] ",I=(ne,z,Q)=>{const J=je(ne==null?void 0:ne.valueOwner,m==null?void 0:m.logic,z),ae=Xe(ne==null?void 0:ne.valueOwner,m==null?void 0:m.logic,Q);return`"${J}" (\`${ae}\`)`},A=n.find(ne=>{var z;return((z=ne.valueOwner.declaration)==null?void 0:z.id)===B.operation[me.GoogleSheetsDeleteSheet].inputs.connection.id}),D=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!D||!D.id||!D.name||D.type!==r.DefinitionEntity)throw new Error(`${E}The ${I(A,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const V=fr(D);if(!V)throw new Error(`${E}The ${I(A,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const N=n.find(ne=>{var z;return((z=ne.valueOwner.declaration)==null?void 0:z.id)===B.operation[me.GoogleSheetsDeleteSheet].inputs.spreadsheetId.id}),_=(c=N==null?void 0:N.value)==null?void 0:c.value;if(!_||_==="")throw new Error(`${E}The ${I(N,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof _!="string")throw new Error(`${E}The ${I(N,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const L=n.find(ne=>{var z;return((z=ne.valueOwner.declaration)==null?void 0:z.id)===B.operation[me.GoogleSheetsDeleteSheet].inputs.sheetId.id}),K=(e=L==null?void 0:L.value)==null?void 0:e.value;if(K==null)throw new Error(`${E}The ${I(L,"Sheet ID","sheetId")} input is missing.`);if(typeof K!="number")throw new Error(`${E}The ${I(L,"Sheet ID","sheetId")} input value is invalid. It must be a number. E.g. 0`);const W={Authorization:`Bearer ${await m.getAccessToken()}`},H=`${(f=m.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${m.projectId}/${vi["google-sheet"]}/${V}`;return await(async ne=>Ii.post(H,ne,{headers:W}))({method:"POST",endpoint:`/v4/spreadsheets/${_}:batchUpdate`,data:{requests:[{deleteSheet:{sheetId:K}}]}}),{value:j.Success,error:null,result:{success:!0}}}catch(m){const T=((h=m.response)==null?void 0:h.data)||m.message||m;return oe.Logger.log("[Google Sheets] error:",T),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:T,result:null}}}})}}function PN(l){let u="",i=l;for(;i>0;){const n=(i-1)%26;u=String.fromCharCode(65+n)+u,i=Math.floor((i-n)/26)}return u}function yO(l){if(!/^[A-Z]+$/.test(l))return NaN;let u=0;for(let i=0;i<l.length;i++)u=u*26+(l.charCodeAt(i)-64);return u}function AE(l,u){const i=(u==null?void 0:u.errorPrefix)||"";if(typeof l!="string")throw new Error(`${i}Input must be a string.`);let n,a=l;if(l.includes("!")){const I=l.split("!");let A=I.slice(0,-1).join("!");a=I[I.length-1],A.startsWith("'")&&A.endsWith("'")&&(A=A.slice(1,-1)),n=A}const c=/^(\$?[A-Z]+)?(\$?\d+)?(?::(\$?[A-Z]+)?(\$?\d+)?)?$/i,e=a.match(c);if(!e)throw new Error(`${i}Invalid A1 notation format: ${l}`);const[f,h,m,T,g]=e,E={sheet:n};return h&&(E.startColumn=h.toUpperCase()),m&&(E.startRow=m),T&&(E.endColumn=T.toUpperCase()),g&&(E.endRow=g),E}function PB(l,u){const i=u!=null&&u.errorPrefix?u.errorPrefix:"",n=T=>{if(typeof T=="string"){const g=T.replace("$","");return/^\d+$/.test(g)?parseInt(g,10):NaN}return T},a=T=>typeof T=="string"?yO(T.replace("$","").toUpperCase()):T,c=n(l.startRow),e=n(l.endRow),f=a(l.startColumn),h=a(l.endColumn),m=T=>typeof T=="string"&&T.includes("{{")&&T.includes("}}");if(l.startRow!==void 0&&l.startRow!==null&&l.startRow!==""&&isNaN(c)&&!m(l.startRow))throw new Error(`${i}Start Row is invalid.`);if(l.endRow!==void 0&&l.endRow!==null&&l.endRow!==""&&isNaN(e)&&!m(l.endRow))throw new Error(`${i}End Row is invalid.`);if(l.startColumn!==void 0&&l.startColumn!==null&&l.startColumn!==""&&isNaN(f)&&!m(l.startColumn))throw new Error(`${i}Start Column is invalid.`);if(l.endColumn!==void 0&&l.endColumn!==null&&l.endColumn!==""&&isNaN(h)&&!m(l.endColumn))throw new Error(`${i}End Column is invalid.`);if(c!=null&&!isNaN(c)&&c<1)throw new Error(`${i}Start Row must be greater than or equal to 1.`);if(e!=null&&!isNaN(e)&&e<1)throw new Error(`${i}End Row must be greater than or equal to 1.`);if(f!=null&&!isNaN(f)&&f<1)throw new Error(`${i}Start Column must be greater than or equal to 1.`);if(h!=null&&!isNaN(h)&&h<1)throw new Error(`${i}End Column must be greater than or equal to 1.`);if(c!=null&&!isNaN(c)&&e!==void 0&&e!==null&&!isNaN(e)&&c>e)throw new Error(`${i}Start Row must be less than or equal to End Row.`);if(f!=null&&!isNaN(f)&&h!==void 0&&h!==null&&!isNaN(h)&&f>h)throw new Error(`${i}Start Column must be less than or equal to End Column.`);if(typeof l.sheet=="number"&&l.sheet<0)throw new Error(`${i}Sheet ID must be greater than or equal to 0.`)}async function Ld(l,u,i){if(!l)return;let n=l;if(typeof l=="string"){const e=l.trim();if(e.startsWith("{"))try{n=new Function("return "+e)()}catch{try{n=JSON.parse(e)}catch{}}else try{n=AE(e,{errorPrefix:"Internal"})}catch{}}if(n.sheet===void 0||n.sheet===null||n.sheet==="")return;const a=typeof n.sheet=="string",c=typeof n.sheet=="number";if(!(u==="Name"&&a)&&!(u==="Id"&&c))try{const e=await i();for(const f of e){const h=f.id,m=f.name;if(a&&m===n.sheet){n._resolvedSheetId=h,n._resolvedSheetName=m;return}if(c&&h===n.sheet){n._resolvedSheetId=h,n._resolvedSheetName=m;return}}}catch{}}function Sv(l,u){if(!l)return"";if(typeof l=="string")return l;let i=l;if(typeof l=="string"&&l.trim().startsWith("{"))try{i=JSON.parse(l)}catch{}if(PB(i,u),i.namedRange&&i.namedRange.trim()!=="")return i.namedRange;const n=i._resolvedSheetName!==void 0?i._resolvedSheetName:typeof i.sheet=="string"?i.sheet:void 0,a=n?`'${n}'!`:"",c=typeof i.startColumn=="number"?PN(i.startColumn):i.startColumn||"",e=typeof i.startRow=="number"?i.startRow.toString():i.startRow||"",f=typeof i.endColumn=="number"?PN(i.endColumn):i.endColumn||"",h=typeof i.endRow=="number"?i.endRow.toString():i.endRow||"",m=`${c}${e}`,T=`${f}${h}`;return m&&T?`${a}${m}:${T}`:m?`${a}${m}`:a.replace(/!$/,"")}function $f(l,u){if(!l)return{};let i=l;if(typeof l=="string"){const g=l.trim();if(g.startsWith("{"))try{i=new Function("return "+g)()}catch{try{i=JSON.parse(g)}catch{}}else try{i=AE(g,u)}catch{}}PB(i,u);const n={},a=i._resolvedSheetId!==void 0?i._resolvedSheetId:typeof i.sheet=="number"?i.sheet:void 0;a!=null&&(n.sheetId=a);const c=g=>{if(typeof g=="string"){const E=g.replace("$","");return/^\d+$/.test(E)?parseInt(E,10):NaN}return g},e=g=>typeof g=="string"?yO(g.replace("$","").toUpperCase()):g,f=c(i.startRow),h=c(i.endRow),m=e(i.startColumn),T=e(i.endColumn);return f!=null&&(n.startRowIndex=f-1),h!=null&&(n.endRowIndex=h),m!=null&&(n.startColumnIndex=m-1),T!=null&&(n.endColumnIndex=T),n}function Rot(l,u){if(!l)return{};let i=l;if(typeof l=="string")if(l.trim().startsWith("{"))try{i=JSON.parse(l)}catch{i=AE(l,{errorPrefix:"Internal"})}else i=AE(l,{errorPrefix:"Internal"});PB(i,u);const n={},a=i._resolvedSheetId!==void 0?i._resolvedSheetId:typeof i.sheet=="number"?i.sheet:void 0;a!=null&&(n.sheetId=a);const c=g=>{if(typeof g=="string"){const E=g.replace("$","");return/^\d+$/.test(E)?parseInt(E,10):NaN}return g},e=g=>typeof g=="string"?yO(g.replace("$","").toUpperCase()):g,f=c(i.startRow),h=c(i.endRow),m=e(i.startColumn),T=e(i.endColumn);return f!=null?(n.dimension="ROWS",n.startIndex=f-1,h!=null?n.endIndex=h:n.endIndex=f):m!=null&&(n.dimension="COLUMNS",n.startIndex=m-1,T!=null?n.endIndex=T:n.endIndex=m),n}class Dot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsAppendRows,version:"1.0.0",description:"Append Row(s) Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsAppendRows);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g;try{const E=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!E||!E.env)throw new Error("Editor context or environment missing");const I=Xe(i,i.project,"appendRows"),D="["+je(i,i.project,"Append rows")+": `"+I+"`] ",V=(fe,ve,Ce)=>{const Oe=je(fe==null?void 0:fe.valueOwner,E==null?void 0:E.logic,ve),Ne=Xe(fe==null?void 0:fe.valueOwner,E==null?void 0:E.logic,Ce);return`"${Oe}" (\`${Ne}\`)`},N=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAppendRows].inputs.connection.id}),_=(a=N==null?void 0:N.value)==null?void 0:a.valueAsType;if(!_||!_.id||!_.name||_.type!==r.DefinitionEntity)throw new Error(`${D}The ${V(N,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const L=fr(_);if(!L)throw new Error(`${D}The ${V(N,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const K=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAppendRows].inputs.spreadsheetId.id}),q=(c=K==null?void 0:K.value)==null?void 0:c.value;if(!q||q==="")throw new Error(`${D}The ${V(K,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof q!="string")throw new Error(`${D}The ${V(K,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const W=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAppendRows].inputs.range.id}),H=(e=W==null?void 0:W.value)==null?void 0:e.value;if(!H||H==="")throw new Error(`${D}The ${V(W,"Range","range")} input is missing.`);const te=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAppendRows].inputs.values.id}),ne=(f=te==null?void 0:te.value)==null?void 0:f.value;if(ne==null)throw new Error(`${D}The ${V(te,"Values","values")} input is missing.`);const Q={Authorization:`Bearer ${await E.getAccessToken()}`},J=`${(h=E.env)==null?void 0:h.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${E.projectId}/${vi["google-sheet"]}/${L}`,ae=async fe=>Ii.post(J,fe,{headers:Q});let ee=ne;if(typeof ne=="string")try{ee=JSON.parse(ne)}catch{}await Ld(H,"Name",async()=>{var ve;return(((ve=(await ae({method:"GET",endpoint:`/v4/spreadsheets/${q}?fields=sheets.properties(sheetId,title)`})).data)==null?void 0:ve.sheets)||[]).map(Ce=>{var Oe,Ne;return{id:(Oe=Ce.properties)==null?void 0:Oe.sheetId,name:(Ne=Ce.properties)==null?void 0:Ne.title}})});const ye=((m=(await ae({method:"POST",endpoint:`/v4/spreadsheets/${q}/values/${Sv(H,{errorPrefix:`${D}The ${V(W,"Range","range")} input `})}:append`,params:{valueInputOption:"USER_ENTERED"},data:{values:Array.isArray(ee)?ee:[ee]}})).data)==null?void 0:m.data)||{};return{value:j.Success,error:null,result:{updatedRange:(T=ye.updates)==null?void 0:T.updatedRange}}}catch(E){const I=((g=E.response)==null?void 0:g.data)||E.message||E;return oe.Logger.log("[Google Sheets] error:",I),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:I,result:null}}}})}}class Cot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsGetRangeValues,version:"1.0.0",description:"Get Range Values Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsGetRangeValues);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"getRangeValues"),I="["+je(i,i.project,"Get range values")+": `"+g+"`] ",A=(J,ae,ee)=>{const de=je(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ae),ye=Xe(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ee);return`"${de}" (\`${ye}\`)`},D=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsGetRangeValues].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsGetRangeValues].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsGetRangeValues].inputs.range.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(!q||q==="")throw new Error(`${I}The ${A(K,"Range","range")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async J=>Ii.post(te,J,{headers:H});await Ld(q,"Name",async()=>{var ae;return(((ae=(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data)==null?void 0:ae.sheets)||[]).map(ee=>{var de,ye;return{id:(de=ee.properties)==null?void 0:de.sheetId,name:(ye=ee.properties)==null?void 0:ye.title}})});const Q=((h=(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}/values/${Sv(q,{errorPrefix:`${I}The ${A(K,"Range","range")} input `})}`})).data)==null?void 0:h.data)||{};return{value:j.Success,error:null,result:{values:Q.values}}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class wot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsUpdateRangeValues,version:"1.0.0",description:"Update Range Values Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsUpdateRangeValues);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"updateRangeValues"),A="["+je(i,i.project,"Update range values")+": `"+E+"`] ",D=(ye,fe,ve)=>{const Ce=je(ye==null?void 0:ye.valueOwner,g==null?void 0:g.logic,fe),Oe=Xe(ye==null?void 0:ye.valueOwner,g==null?void 0:g.logic,ve);return`"${Ce}" (\`${Oe}\`)`},V=n.find(ye=>{var fe;return((fe=ye.valueOwner.declaration)==null?void 0:fe.id)===B.operation[me.GoogleSheetsUpdateRangeValues].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(ye=>{var fe;return((fe=ye.valueOwner.declaration)==null?void 0:fe.id)===B.operation[me.GoogleSheetsUpdateRangeValues].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(ye=>{var fe;return((fe=ye.valueOwner.declaration)==null?void 0:fe.id)===B.operation[me.GoogleSheetsUpdateRangeValues].inputs.range.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(!W||W==="")throw new Error(`${A}The ${D(q,"Range","range")} input is missing.`);const H=n.find(ye=>{var fe;return((fe=ye.valueOwner.declaration)==null?void 0:fe.id)===B.operation[me.GoogleSheetsUpdateRangeValues].inputs.values.id}),te=(f=H==null?void 0:H.value)==null?void 0:f.value;if(te==null)throw new Error(`${A}The ${D(H,"Values","values")} input is missing.`);const z={Authorization:`Bearer ${await g.getAccessToken()}`},Q=`${(h=g.env)==null?void 0:h.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,J=async ye=>Ii.post(Q,ye,{headers:z});let ae=te;if(typeof te=="string")try{ae=JSON.parse(te)}catch{}await Ld(W,"Name",async()=>{var fe;return(((fe=(await J({method:"GET",endpoint:`/v4/spreadsheets/${K}?fields=sheets.properties(sheetId,title)`})).data)==null?void 0:fe.sheets)||[]).map(ve=>{var Ce,Oe;return{id:(Ce=ve.properties)==null?void 0:Ce.sheetId,name:(Oe=ve.properties)==null?void 0:Oe.title}})});const de=((m=(await J({method:"PUT",endpoint:`/v4/spreadsheets/${K}/values/${Sv(W,{errorPrefix:`${A}The ${D(q,"Range","range")} input `})}`,params:{valueInputOption:"USER_ENTERED"},data:{values:Array.isArray(ae)?ae:[ae]}})).data)==null?void 0:m.data)||{};return{value:j.Success,error:null,result:{updatedRange:de.updatedRange}}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Oot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsClearRange,version:"1.0.0",description:"Clear Range Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsClearRange);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"clearRange"),I="["+je(i,i.project,"Clear range")+": `"+g+"`] ",A=(J,ae,ee)=>{const de=je(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ae),ye=Xe(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ee);return`"${de}" (\`${ye}\`)`},D=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearRange].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearRange].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearRange].inputs.range.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(!q||q==="")throw new Error(`${I}The ${A(K,"Range","range")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async J=>Ii.post(te,J,{headers:H});await Ld(q,"Name",async()=>{var ae;return(((ae=(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data)==null?void 0:ae.sheets)||[]).map(ee=>{var de,ye;return{id:(de=ee.properties)==null?void 0:de.sheetId,name:(ye=ee.properties)==null?void 0:ye.title}})});const Q=((h=(await ne({method:"POST",endpoint:`/v4/spreadsheets/${L}/values/${Sv(q,{errorPrefix:`${I}The ${A(K,"Range","range")} input `})}:clear`,data:{}})).data)==null?void 0:h.data)||{};return{value:j.Success,error:null,result:{clearedRange:Q.clearedRange}}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class Pot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsBatchUpdateSpreadsheet,version:"1.0.0",description:"Batch Update Spreadsheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsBatchUpdateSpreadsheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"batchUpdateSpreadsheet"),I="["+je(i,i.project,"Batch update spreadsheet")+": `"+g+"`] ",A=(ae,ee,de)=>{const ye=je(ae==null?void 0:ae.valueOwner,T==null?void 0:T.logic,ee),fe=Xe(ae==null?void 0:ae.valueOwner,T==null?void 0:T.logic,de);return`"${ye}" (\`${fe}\`)`},D=n.find(ae=>{var ee;return((ee=ae.valueOwner.declaration)==null?void 0:ee.id)===B.operation[me.GoogleSheetsBatchUpdateSpreadsheet].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(ae=>{var ee;return((ee=ae.valueOwner.declaration)==null?void 0:ee.id)===B.operation[me.GoogleSheetsBatchUpdateSpreadsheet].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(ae=>{var ee;return((ee=ae.valueOwner.declaration)==null?void 0:ee.id)===B.operation[me.GoogleSheetsBatchUpdateSpreadsheet].inputs.requests.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null||q==="")throw new Error(`${I}The ${A(K,"Requests","requests")} input is missing.`);let W=q;if(typeof q=="string")try{W=JSON.parse(q)}catch{}if(Array.isArray(W)||(W=[W]),W.length===0)throw new Error(`${I}The ${A(K,"Requests","requests")} input evaluated to an empty array. E.g. [{ addSheet: { properties: { title: "New Sheet" } } }]`);const te={Authorization:`Bearer ${await T.getAccessToken()}`},ne=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,Q=await(async ae=>Ii.post(ne,ae,{headers:te}))({method:"POST",endpoint:`/v4/spreadsheets/${L}:batchUpdate`,data:{requests:W}}),J=((h=Q.data)==null?void 0:h.data)||Q.data||{};return{value:j.Success,result:{replies:J.replies||[]},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class xot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsRenameSheet,version:"1.0.0",description:"Rename or Update Sheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsRenameSheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"renameSheet"),I="["+je(i,i.project,"Rename sheet")+": `"+g+"`] ",A=(ee,de,ye)=>{const fe=je(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,de),ve=Xe(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,ye);return`"${fe}" (\`${ve}\`)`},D=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsRenameSheet].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsRenameSheet].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsRenameSheet].inputs.sheetId.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null)throw new Error(`${I}The ${A(K,"Sheet ID","sheetId")} input is missing.`);if(typeof q!="number")throw new Error(`${I}The ${A(K,"Sheet ID","sheetId")} input value is invalid. It must be a number. E.g. 0`);const W=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsRenameSheet].inputs.title.id}),H=(f=W==null?void 0:W.value)==null?void 0:f.value;if(H!=null&&typeof H!="string")throw new Error(`${I}The ${A(W,"Title","title")} input value is invalid, if present, it must be a string.`);const ne={Authorization:`Bearer ${await T.getAccessToken()}`},z=`${(h=T.env)==null?void 0:h.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,Q=async ee=>Ii.post(z,ee,{headers:ne}),J={sheetId:q},ae=[];return H&&(J.title=H,ae.push("title")),await Q({method:"POST",endpoint:`/v4/spreadsheets/${L}:batchUpdate`,data:{requests:[{updateSheetProperties:{properties:J,fields:ae.join(",")}}]}}),{value:j.Success,result:{success:!0},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class _ot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsCopySheet,version:"1.0.0",description:"Copy Sheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsCopySheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"copySheet"),A="["+je(i,i.project,"Copy sheet")+": `"+E+"`] ",D=(de,ye,fe)=>{const ve=je(de==null?void 0:de.valueOwner,g==null?void 0:g.logic,ye),Ce=Xe(de==null?void 0:de.valueOwner,g==null?void 0:g.logic,fe);return`"${ve}" (\`${Ce}\`)`},V=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsCopySheet].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsCopySheet].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsCopySheet].inputs.sheetId.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(W==null)throw new Error(`${A}The ${D(q,"Sheet ID","sheetId")} input is missing.`);if(typeof W!="number")throw new Error(`${A}The ${D(q,"Sheet ID","sheetId")} input value is invalid. It must be a number. E.g. 0`);const H=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsCopySheet].inputs.destinationSpreadsheetId.id}),te=(f=H==null?void 0:H.value)==null?void 0:f.value;if(!te||te==="")throw new Error(`${A}The ${D(H,"Destination Spreadsheet ID","destinationSpreadsheetId")} input is missing.`);if(typeof te!="string")throw new Error(`${A}The ${D(H,"Destination Spreadsheet ID","destinationSpreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const z={Authorization:`Bearer ${await g.getAccessToken()}`},Q=`${(h=g.env)==null?void 0:h.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,ae=await(async de=>Ii.post(Q,de,{headers:z}))({method:"POST",endpoint:`/v4/spreadsheets/${K}/sheets/${W}:copyTo`,data:{destinationSpreadsheetId:te}}),ee=((m=ae.data)==null?void 0:m.data)||ae.data||{};return{value:j.Success,result:{newSheetId:ee.sheetId},error:null}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Vot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsClearSheet,version:"1.0.0",description:"Clear Sheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsClearSheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"clearSheet"),I="["+je(i,i.project,"Clear sheet")+": `"+g+"`] ",A=(J,ae,ee)=>{const de=je(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ae),ye=Xe(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ee);return`"${de}" (\`${ye}\`)`},D=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearSheet].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearSheet].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearSheet].inputs.sheetName.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(!q||q==="")throw new Error(`${I}The ${A(K,"Sheet Name","sheetName")} input is missing.`);if(typeof q!="string")throw new Error(`${I}The ${A(K,"Sheet Name","sheetName")} input value is invalid. It must be a non-empty string. E.g. "Sheet1"`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,z=await(async J=>Ii.post(te,J,{headers:H}))({method:"POST",endpoint:`/v4/spreadsheets/${L}/values/${q}:clear`,data:{}}),Q=((h=z.data)==null?void 0:h.data)||z.data||{};return{value:j.Success,result:{clearedRange:Q.clearedRange},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class Not extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsBatchGetValues,version:"1.0.0",description:"Batch Get Values Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsBatchGetValues);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"batchGetValues"),I="["+je(i,i.project,"Batch get values")+": `"+g+"`] ",A=(ee,de,ye)=>{const fe=je(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,de),ve=Xe(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,ye);return`"${fe}" (\`${ve}\`)`},D=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsBatchGetValues].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsBatchGetValues].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsBatchGetValues].inputs.ranges.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null||q==="")throw new Error(`${I}The ${A(K,"Ranges","ranges")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async ee=>Ii.post(te,ee,{headers:H});let z=Array.isArray(q)?q:[q];if(z.length===0)throw new Error(`${I}The ${A(K,"Ranges","ranges")} input evaluated to an empty array. E.g. ["Sheet1!A1:B2"]`);for(const ee of z)await Ld(ee,"Name",async()=>{var ye;return(((ye=(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data)==null?void 0:ye.sheets)||[]).map(fe=>{var ve,Ce;return{id:(ve=fe.properties)==null?void 0:ve.sheetId,name:(Ce=fe.properties)==null?void 0:Ce.title}})});let Q=z.map(ee=>`ranges=${encodeURIComponent(Sv(ee,{errorPrefix:`${I}The ${A(K,"Ranges","ranges")} input `}))}`).join("&");const J=await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}/values:batchGet?${Q}`}),ae=((h=J.data)==null?void 0:h.data)||J.data||{};return{value:j.Success,result:{valueRanges:ae.valueRanges||[]},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class $ot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsFormatCells,version:"1.0.0",description:"Format Cells Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsFormatCells);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"formatCells"),A="["+je(i,i.project,"Format cells")+": `"+E+"`] ",D=(fe,ve,Ce)=>{const Oe=je(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,ve),Ne=Xe(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,Ce);return`"${Oe}" (\`${Ne}\`)`},V=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsFormatCells].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsFormatCells].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsFormatCells].inputs.range.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(W==null)throw new Error(`${A}The ${D(q,"Range","range")} input is missing.`);const te={Authorization:`Bearer ${await g.getAccessToken()}`},ne=`${(f=g.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,z=async fe=>Ii.post(ne,fe,{headers:te});await Ld(W,"Id",async()=>(await z({method:"GET",endpoint:`/v4/spreadsheets/${K}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(ve=>({id:ve.properties.sheetId,name:ve.properties.title})));const Q=$f(W,{errorPrefix:`${A}The ${D(q,"Range","range")} input `}),J=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsFormatCells].inputs.bold.id}),ae=!!((h=J==null?void 0:J.value)!=null&&h.value),ee=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsFormatCells].inputs.italic.id}),de=!!((m=ee==null?void 0:ee.value)!=null&&m.value),ye={repeatCell:{range:Q,cell:{userEnteredFormat:{textFormat:{bold:ae,italic:de}}},fields:"userEnteredFormat.textFormat(bold,italic)"}};return await z({method:"POST",endpoint:`/v4/spreadsheets/${K}:batchUpdate`,data:{requests:[ye]}}),{value:j.Success,result:{success:!0},error:null}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Lot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsSetNumberFormat,version:"1.0.0",description:"Set Number Format Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsSetNumberFormat);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"setNumberFormat"),I="["+je(i,i.project,"Set number format")+": `"+g+"`] ",A=(ee,de,ye)=>{const fe=je(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,de),ve=Xe(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,ye);return`"${fe}" (\`${ve}\`)`},D=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetNumberFormat].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetNumberFormat].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetNumberFormat].inputs.range.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null)throw new Error(`${I}The ${A(K,"Range","range")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async ee=>Ii.post(te,ee,{headers:H});await Ld(q,"Id",async()=>(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(de=>({id:de.properties.sheetId,name:de.properties.title})));const z=$f(q,{errorPrefix:`${I}The ${A(K,"Range","range")} input `}),Q=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetNumberFormat].inputs.pattern.id}),J=(h=Q==null?void 0:Q.value)==null?void 0:h.value;if(J==null||J==="")throw new Error(`${I}The ${A(Q,"Pattern","pattern")} input is missing.`);if(typeof J!="string")throw new Error(`${I}The ${A(Q,"Pattern","pattern")} input value is invalid. It must be a string.`);const ae={repeatCell:{range:z,cell:{userEnteredFormat:{numberFormat:{type:"CUSTOM",pattern:J}}},fields:"userEnteredFormat.numberFormat"}};return await ne({method:"POST",endpoint:`/v4/spreadsheets/${L}:batchUpdate`,data:{requests:[ae]}}),{value:j.Success,result:{success:!0},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class Got extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsSetBackgroundColor,version:"1.0.0",description:"Set Background Color Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsSetBackgroundColor);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"setBackgroundColor"),I="["+je(i,i.project,"Set background color")+": `"+g+"`] ",A=(ee,de,ye)=>{const fe=je(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,de),ve=Xe(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,ye);return`"${fe}" (\`${ve}\`)`},D=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetBackgroundColor].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetBackgroundColor].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetBackgroundColor].inputs.range.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null)throw new Error(`${I}The ${A(K,"Range","range")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async ee=>Ii.post(te,ee,{headers:H});await Ld(q,"Id",async()=>(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(de=>({id:de.properties.sheetId,name:de.properties.title})));const z=$f(q,{errorPrefix:`${I}The ${A(K,"Range","range")} input `}),Q=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetBackgroundColor].inputs.color.id}),J=(h=Q==null?void 0:Q.value)==null?void 0:h.value;if(J==null)throw new Error(`${I}The ${A(Q,"Color","color")} input is missing.`);if(typeof J!="object")throw new Error(`${I}The ${A(Q,"Color","color")} input value is invalid. It must be a valid color object.`);const ae={repeatCell:{range:z,cell:{userEnteredFormat:{backgroundColor:{red:J.red!==void 0?J.red/255:void 0,green:J.green!==void 0?J.green/255:void 0,blue:J.blue!==void 0?J.blue/255:void 0,alpha:J.alpha!==void 0?J.alpha:void 0}}},fields:"userEnteredFormat.backgroundColor"}};return await ne({method:"POST",endpoint:`/v4/spreadsheets/${L}:batchUpdate`,data:{requests:[ae]}}),{value:j.Success,result:{success:!0},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class Bot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsMergeUnmergeCells,version:"1.0.0",description:"Merge or Unmerge Cells Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsMergeUnmergeCells);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"mergeUnmergeCells"),A="["+je(i,i.project,"Merge/Unmerge cells")+": `"+E+"`] ",D=(fe,ve,Ce)=>{const Oe=je(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,ve),Ne=Xe(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,Ce);return`"${Oe}" (\`${Ne}\`)`},V=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsMergeUnmergeCells].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsMergeUnmergeCells].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsMergeUnmergeCells].inputs.range.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(W==null)throw new Error(`${A}The ${D(q,"Range","range")} input is missing.`);const te={Authorization:`Bearer ${await g.getAccessToken()}`},ne=`${(f=g.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,z=async fe=>Ii.post(ne,fe,{headers:te});await Ld(W,"Id",async()=>(await z({method:"GET",endpoint:`/v4/spreadsheets/${K}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(ve=>({id:ve.properties.sheetId,name:ve.properties.title})));const Q=$f(W,{errorPrefix:`${A}The ${D(q,"Range","range")} input `}),J=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsMergeUnmergeCells].inputs.merge.id}),ae=!!((h=J==null?void 0:J.value)!=null&&h.value),ee=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsMergeUnmergeCells].inputs.mergeType.id}),de=(m=ee==null?void 0:ee.value)==null?void 0:m.value;if(de!=null&&typeof de!="string")throw new Error(`${A}The ${D(ee,"Merge Type","mergeType")} input value is invalid, if present, it must be a string.`);const ye=ae?{mergeCells:{range:Q,mergeType:de||"MERGE_ALL"}}:{unmergeCells:{range:Q}};return await z({method:"POST",endpoint:`/v4/spreadsheets/${K}:batchUpdate`,data:{requests:[ye]}}),{value:j.Success,result:{success:!0},error:null}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Mot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsAutoResizeDimensions,version:"1.0.0",description:"Auto-Resize Dimensions Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsAutoResizeDimensions);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"autoResizeDimensions"),E="["+je(i,i.project,"Auto-resize dimensions")+": `"+T+"`] ",I=(Q,J,ae)=>{const ee=je(Q==null?void 0:Q.valueOwner,m==null?void 0:m.logic,J),de=Xe(Q==null?void 0:Q.valueOwner,m==null?void 0:m.logic,ae);return`"${ee}" (\`${de}\`)`},A=n.find(Q=>{var J;return((J=Q.valueOwner.declaration)==null?void 0:J.id)===B.operation[me.GoogleSheetsAutoResizeDimensions].inputs.connection.id}),D=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!D||!D.id||!D.name||D.type!==r.DefinitionEntity)throw new Error(`${E}The ${I(A,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const V=fr(D);if(!V)throw new Error(`${E}The ${I(A,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const N=n.find(Q=>{var J;return((J=Q.valueOwner.declaration)==null?void 0:J.id)===B.operation[me.GoogleSheetsAutoResizeDimensions].inputs.spreadsheetId.id}),_=(c=N==null?void 0:N.value)==null?void 0:c.value;if(!_||_==="")throw new Error(`${E}The ${I(N,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof _!="string")throw new Error(`${E}The ${I(N,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const L=n.find(Q=>{var J;return((J=Q.valueOwner.declaration)==null?void 0:J.id)===B.operation[me.GoogleSheetsAutoResizeDimensions].inputs.range.id}),K=(e=L==null?void 0:L.value)==null?void 0:e.value;if(K==null)throw new Error(`${E}The ${I(L,"Range","range")} input is missing.`);const W={Authorization:`Bearer ${await m.getAccessToken()}`},H=`${(f=m.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${m.projectId}/${vi["google-sheet"]}/${V}`,te=async Q=>Ii.post(H,Q,{headers:W}),ne={autoResizeDimensions:{dimensions:Rot(K,{errorPrefix:`${E}The ${I(L,"Range","range")} input `})}},z=await te({method:"POST",endpoint:`/v4/spreadsheets/${_}:batchUpdate`,data:{requests:[ne]}});return{value:j.Success,result:{success:!0},error:null}}catch(m){const T=((h=m.response)==null?void 0:h.data)||m.message||m;return oe.Logger.log("[Google Sheets] error:",T),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:T,result:null}}}})}}class Fot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsFindAndReplace,version:"1.0.0",description:"Find and Replace Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsFindAndReplace);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I,A,D,V;try{const N=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!N||!N.env)throw new Error("Editor context or environment missing");const _=Xe(i,i.project,"findAndReplace"),K="["+je(i,i.project,"Find and replace")+": `"+_+"`] ",q=(ze,it,ft)=>{const Mt=je(ze==null?void 0:ze.valueOwner,N==null?void 0:N.logic,it),jt=Xe(ze==null?void 0:ze.valueOwner,N==null?void 0:N.logic,ft);return`"${Mt}" (\`${jt}\`)`},W=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.connection.id}),H=(a=W==null?void 0:W.value)==null?void 0:a.valueAsType;if(!H||!H.id||!H.name||H.type!==r.DefinitionEntity)throw new Error(`${K}The ${q(W,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const te=fr(H);if(!te)throw new Error(`${K}The ${q(W,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const ne=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.spreadsheetId.id}),z=(c=ne==null?void 0:ne.value)==null?void 0:c.value;if(!z||z==="")throw new Error(`${K}The ${q(ne,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof z!="string")throw new Error(`${K}The ${q(ne,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const Q=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.range.id}),J=(e=Q==null?void 0:Q.value)==null?void 0:e.value;if(J==null)throw new Error(`${K}The ${q(Q,"Range","range")} input is missing.`);const ae=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.find.id}),ee=(f=ae==null?void 0:ae.value)==null?void 0:f.value;if(!ee||ee==="")throw new Error(`${K}The ${q(ae,"Find","find")} input is missing.`);if(typeof ee!="string")throw new Error(`${K}The ${q(ae,"Find","find")} input value is invalid. It must be a non-empty string.`);const de=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.replace.id}),ye=((h=de==null?void 0:de.value)==null?void 0:h.value)||"";if(typeof ye!="string")throw new Error(`${K}The ${q(de,"Replace","replace")} input value is invalid. It must be a string.`);const fe=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.matchCase.id}),ve=!!((m=fe==null?void 0:fe.value)!=null&&m.value),Ce=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.matchEntireCell.id}),Oe=!!((T=Ce==null?void 0:Ce.value)!=null&&T.value),De={Authorization:`Bearer ${await N.getAccessToken()}`},Ue=`${(g=N.env)==null?void 0:g.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${N.projectId}/${vi["google-sheet"]}/${te}`,Je=async ze=>Ii.post(Ue,ze,{headers:De}),qe={findReplace:{range:$f(J,{errorPrefix:`${K}The ${q(Q,"Range","range")} input `}),find:ee,replacement:ye,matchCase:ve,matchEntireCell:Oe}},rt=await Je({method:"POST",endpoint:`/v4/spreadsheets/${z}:batchUpdate`,data:{requests:[qe]}}),dt=((E=rt.data)==null?void 0:E.data)||rt.data||{};return{value:j.Success,result:{occurrencesChanged:((D=(A=(I=dt.replies)==null?void 0:I[0])==null?void 0:A.findReplace)==null?void 0:D.occurrencesChanged)||0},error:null}}catch(N){const _=((V=N.response)==null?void 0:V.data)||N.message||N;return oe.Logger.log("[Google Sheets] error:",_),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:_,result:null}}}})}}class kot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsAddDataValidation,version:"1.0.0",description:"Add Data Validation Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsAddDataValidation);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"addDataValidation"),A="["+je(i,i.project,"Add data validation")+": `"+E+"`] ",D=(Ce,Oe,Ne)=>{const De=je(Ce==null?void 0:Ce.valueOwner,g==null?void 0:g.logic,Oe),Ue=Xe(Ce==null?void 0:Ce.valueOwner,g==null?void 0:g.logic,Ne);return`"${De}" (\`${Ue}\`)`},V=n.find(Ce=>{var Oe;return((Oe=Ce.valueOwner.declaration)==null?void 0:Oe.id)===B.operation[me.GoogleSheetsAddDataValidation].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(Ce=>{var Oe;return((Oe=Ce.valueOwner.declaration)==null?void 0:Oe.id)===B.operation[me.GoogleSheetsAddDataValidation].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(Ce=>{var Oe;return((Oe=Ce.valueOwner.declaration)==null?void 0:Oe.id)===B.operation[me.GoogleSheetsAddDataValidation].inputs.range.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(W==null)throw new Error(`${A}The ${D(q,"Range","range")} input is missing.`);const te={Authorization:`Bearer ${await g.getAccessToken()}`},ne=`${(f=g.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,z=async Ce=>Ii.post(ne,Ce,{headers:te});await Ld(W,"Id",async()=>(await z({method:"GET",endpoint:`/v4/spreadsheets/${K}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(Oe=>({id:Oe.properties.sheetId,name:Oe.properties.title})));const Q=$f(W,{errorPrefix:`${A}The ${D(q,"Range","range")} input `}),J=n.find(Ce=>{var Oe;return((Oe=Ce.valueOwner.declaration)==null?void 0:Oe.id)===B.operation[me.GoogleSheetsAddDataValidation].inputs.conditionType.id}),ae=(h=J==null?void 0:J.value)==null?void 0:h.value;if(!ae||ae==="")throw new Error(`${A}The ${D(J,"Condition Type","conditionType")} input is missing.`);if(typeof ae!="string")throw new Error(`${A}The ${D(J,"Condition Type","conditionType")} input value is invalid. It must be a non-empty string. E.g. "ONE_OF_LIST"`);const ee=n.find(Ce=>{var Oe;return((Oe=Ce.valueOwner.declaration)==null?void 0:Oe.id)===B.operation[me.GoogleSheetsAddDataValidation].inputs.conditionValues.id}),de=(m=ee==null?void 0:ee.value)==null?void 0:m.value;let ye=de;if(typeof de=="string")try{ye=JSON.parse(de)}catch{ye=de.split(",").map(Oe=>Oe.trim())}Array.isArray(ye)||(ye=ye?[ye]:[]);const fe={setDataValidation:{range:Q,rule:{condition:{type:ae,values:ye.map(Ce=>({userEnteredValue:String(Ce)}))},showCustomUi:!0}}},ve=await z({method:"POST",endpoint:`/v4/spreadsheets/${K}:batchUpdate`,data:{requests:[fe]}});return{value:j.Success,result:{success:!0},error:null}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Sot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsSortRange,version:"1.0.0",description:"Sort Range Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsSortRange);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"sortRange"),A="["+je(i,i.project,"Sort range")+": `"+E+"`] ",D=(fe,ve,Ce)=>{const Oe=je(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,ve),Ne=Xe(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,Ce);return`"${Oe}" (\`${Ne}\`)`},V=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsSortRange].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsSortRange].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsSortRange].inputs.range.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(W==null)throw new Error(`${A}The ${D(q,"Range","range")} input is missing.`);const te={Authorization:`Bearer ${await g.getAccessToken()}`},ne=`${(f=g.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,z=async fe=>Ii.post(ne,fe,{headers:te});await Ld(W,"Id",async()=>(await z({method:"GET",endpoint:`/v4/spreadsheets/${K}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(ve=>({id:ve.properties.sheetId,name:ve.properties.title})));const Q=$f(W,{errorPrefix:`${A}The ${D(q,"Range","range")} input `}),J=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsSortRange].inputs.sortColumnIndex.id}),ae=(h=J==null?void 0:J.value)==null?void 0:h.value;if(ae==null)throw new Error(`${A}The ${D(J,"Sort Column Index","sortColumnIndex")} input is missing.`);if(typeof ae!="number")throw new Error(`${A}The ${D(J,"Sort Column Index","sortColumnIndex")} input value is invalid. It must be a number.`);const ee=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsSortRange].inputs.sortOrder.id}),de=(m=ee==null?void 0:ee.value)==null?void 0:m.value;if(de==null||de==="")throw new Error(`${A}The ${D(ee,"Sort Order","sortOrder")} input is missing.`);if(typeof de!="string")throw new Error(`${A}The ${D(ee,"Sort Order","sortOrder")} input value is invalid. It must be a string.`);const ye={sortRange:{range:Q,sortSpecs:[{dimensionIndex:ae,sortOrder:de.toUpperCase()}]}};return await z({method:"POST",endpoint:`/v4/spreadsheets/${K}:batchUpdate`,data:{requests:[ye]}}),{value:j.Success,result:{success:!0},error:null}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Uot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsApplyClearFilter,version:"1.0.0",description:"Apply or Clear Filter Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsApplyClearFilter);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"applyClearFilter"),I="["+je(i,i.project,"Apply or clear filter")+": `"+g+"`] ",A=(de,ye,fe)=>{const ve=je(de==null?void 0:de.valueOwner,T==null?void 0:T.logic,ye),Ce=Xe(de==null?void 0:de.valueOwner,T==null?void 0:T.logic,fe);return`"${ve}" (\`${Ce}\`)`},D=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsApplyClearFilter].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsApplyClearFilter].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsApplyClearFilter].inputs.range.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null)throw new Error(`${I}The ${A(K,"Range","range")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async de=>Ii.post(te,de,{headers:H});await Ld(q,"Id",async()=>(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(ye=>({id:ye.properties.sheetId,name:ye.properties.title})));const z=$f(q,{errorPrefix:`${I}The ${A(K,"Range","range")} input `}),Q=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsApplyClearFilter].inputs.clearOnly.id}),J=(h=Q==null?void 0:Q.value)==null?void 0:h.value;if(J!=null&&typeof J!="boolean")throw new Error(`${I}The ${A(Q,"Clear Only","clearOnly")} input value is invalid. If present, it must be a boolean. E.g. true`);const ae=J?{clearBasicFilter:{sheetId}}:{setBasicFilter:{filter:{range:z}}},ee=await ne({method:"POST",endpoint:`/v4/spreadsheets/${L}:batchUpdate`,data:{requests:[ae]}});return{value:j.Success,result:{success:!0},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class jot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsUpdateSpreadsheetProperties,version:"1.0.0",description:"Update Spreadsheet Properties Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsUpdateSpreadsheetProperties);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I,A;try{const D=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!D||!D.env)throw new Error("Editor context or environment missing");const V=Xe(i,i.project,"updateSpreadsheetProperties"),_="["+je(i,i.project,"Update spreadsheet properties")+": `"+V+"`] ",L=(Mt,jt,wt)=>{const ht=je(Mt==null?void 0:Mt.valueOwner,D==null?void 0:D.logic,jt),Jt=Xe(Mt==null?void 0:Mt.valueOwner,D==null?void 0:D.logic,wt);return`"${ht}" (\`${Jt}\`)`},K=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.connection.id}),q=(a=K==null?void 0:K.value)==null?void 0:a.valueAsType;if(!q||!q.id||!q.name||q.type!==r.DefinitionEntity)throw new Error(`${_}The ${L(K,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const W=fr(q);if(!W)throw new Error(`${_}The ${L(K,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const H=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.spreadsheetId.id}),te=(c=H==null?void 0:H.value)==null?void 0:c.value;if(!te||te==="")throw new Error(`${_}The ${L(H,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof te!="string")throw new Error(`${_}The ${L(H,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const ne=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.title.id}),z=(e=ne==null?void 0:ne.value)==null?void 0:e.value;if(z!=null&&typeof z!="string")throw new Error(`${_}The ${L(ne,"Title","title")} input value is invalid. If present, it must be a string. E.g. "My Spreadsheet"`);const Q=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.locale.id}),J=(f=Q==null?void 0:Q.value)==null?void 0:f.value;if(J!=null&&typeof J!="string")throw new Error(`${_}The ${L(Q,"Locale","locale")} input value is invalid. If present, it must be a string. E.g. "en_US"`);const ae=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.timeZone.id}),ee=(h=ae==null?void 0:ae.value)==null?void 0:h.value;if(ee!=null&&typeof ee!="string")throw new Error(`${_}The ${L(ae,"Time Zone","timeZone")} input value is invalid. If present, it must be a string. E.g. "America/New_York"`);const de=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.autoRecalc.id}),ye=(m=de==null?void 0:de.value)==null?void 0:m.value;if(ye!=null&&typeof ye!="string")throw new Error(`${_}The ${L(de,"Auto Recalculation","autoRecalc")} input value is invalid. If present, it must be a string enum value. E.g. "ON_CHANGE"`);const fe=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.defaultFormat.id}),ve=(T=fe==null?void 0:fe.value)==null?void 0:T.value;if(ve!=null&&(typeof ve!="object"||Array.isArray(ve)))throw new Error(`${_}The ${L(fe,"Default Format","defaultFormat")} input value is invalid. If present, it must be an object representing the CellFormat.`);const Ce=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.iterativeCalculationSettings.id}),Oe=(g=Ce==null?void 0:Ce.value)==null?void 0:g.value;if(Oe!=null&&(typeof Oe!="object"||Array.isArray(Oe)))throw new Error(`${_}The ${L(Ce,"Iterative Calculation Settings","iterativeCalculationSettings")} input value is invalid. If present, it must be an object.`);const Ne=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.spreadsheetTheme.id}),De=(E=Ne==null?void 0:Ne.value)==null?void 0:E.value;if(De!=null&&(typeof De!="object"||Array.isArray(De)))throw new Error(`${_}The ${L(Ne,"Spreadsheet Theme","spreadsheetTheme")} input value is invalid. If present, it must be an object.`);const Ue={};z!=null&&(Ue.title=z),J!=null&&(Ue.locale=J),ee!=null&&(Ue.timeZone=ee),ye!=null&&(Ue.autoRecalc=ye),ve!=null&&(Ue.defaultFormat=ve),Oe!=null&&(Ue.iterativeCalculationSettings=Oe),De!=null&&(Ue.spreadsheetTheme=De);const Je=(Mt,jt="")=>{let wt=[];for(const ht in Mt){if(!Object.prototype.hasOwnProperty.call(Mt,ht))continue;const Jt=Mt[ht],ut=jt?`${jt}.${ht}`:ht;Jt!==null&&typeof Jt=="object"&&!Array.isArray(Jt)&&Object.keys(Jt).length>0?wt.push(...Je(Jt,ut)):wt.push(ut)}return wt},qe=Je(Ue);if(qe.length===0)throw new Error(`${_}At least one property must be provided to update.`);const dt={Authorization:`Bearer ${await D.getAccessToken()}`},ze=`${(I=D.env)==null?void 0:I.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${D.projectId}/${vi["google-sheet"]}/${W}`,ft=await(async Mt=>Ii.post(ze,Mt,{headers:dt}))({method:"POST",endpoint:`/v4/spreadsheets/${te}:batchUpdate`,data:{requests:[{updateSpreadsheetProperties:{properties:Ue,fields:qe.join(",")}}]}});return{value:j.Success,result:{success:!0},error:null}}catch(D){const V=((A=D.response)==null?void 0:A.data)||D.message||D;return oe.Logger.log("[Google Sheets] error:",V),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:V,result:null}}}})}}const nb=(l,u)=>(oe.Logger.log("[Google Sheets Clone Sheet] error:",u),{value:l.catchesError||l.errorCalls.length?j.CaughtError:j.UnhandledError,error:u,result:null});class $en extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsCloneSheet,version:"1.0.0",description:"Google Sheets clone sheet operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsCloneSheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I,A,D,V,N,_,L,K,q,W,H,te;try{const ne=B.operation[me.GoogleSheetsCloneSheet],z=((c=(a=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.connection.id}))==null?void 0:a.value)==null?void 0:c.valueAsType)??((f=(e=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.connection.id}))==null?void 0:e.value)==null?void 0:f.value);if(!(z instanceof Na))return nb(i,"Invalid or missing connection entity");const Q=(m=(h=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.spreadsheetId.id}))==null?void 0:h.value)==null?void 0:m.value;if(!Q)return nb(i,"Missing required input: spreadsheetId");const J=(g=(T=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.sheet.id}))==null?void 0:T.value)==null?void 0:g.value;if(J==null||J==="")return nb(i,"Missing required input: sheet");const ae=(I=(E=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.newSheetName.id}))==null?void 0:E.value)==null?void 0:I.value,ee=(D=(A=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.insertIndex.id}))==null?void 0:A.value)==null?void 0:D.value,de=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],ye=fr(z),ve={Authorization:`Bearer ${await de.getAccessToken()}`},Ce=`${(V=de.env)==null?void 0:V.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${de.projectId}/${vi["google-sheet"]}/${ye}`,Oe=async rt=>Ii.post(Ce,rt,{headers:ve});let Ne;if(!isNaN(Number(J)))Ne=Number(J);else{const rt=await Oe({method:"GET",endpoint:`/v4/spreadsheets/${Q}`}),ze=(((_=(N=rt.data)==null?void 0:N.data)==null?void 0:_.sheets)||((L=rt.data)==null?void 0:L.sheets)||[]).find(it=>{var ft;return((ft=it.properties)==null?void 0:ft.title)===String(J)});if(!ze)return nb(i,`Could not find sheet with name "${J}"`);Ne=ze.properties.sheetId}const De={sourceSheetId:Ne};ae&&(De.newSheetName=ae),typeof ee=="number"&&(De.insertSheetIndex=ee);const Ue=await Oe({method:"POST",endpoint:`/v4/spreadsheets/${Q}:batchUpdate`,data:{requests:[{duplicateSheet:De}]}}),qe=((H=(W=(q=(((K=Ue.data)==null?void 0:K.data)||Ue.data||{}).replies)==null?void 0:q[0])==null?void 0:W.duplicateSheet)==null?void 0:H.properties)||{};return{value:j.Success,error:null,result:{newSheetId:qe.sheetId,newSheetName:qe.title}}}catch(ne){const z=((te=ne.response)==null?void 0:te.data)||ne.message||ne;return nb(i,z)}}})}}class Kot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_UPLOAD_FILE,version:"1.0.0",description:"Cloud File System: Upload File",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.UploadFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"uploadFile"),E="["+je(i,i.project,"Upload file")+": `"+T+"`] ",I=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.UploadFile].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(ae=>ae.resourceId===D))throw new Error(`${E}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const N=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.UploadFile].inputs.key.id}),_=(e=N==null?void 0:N.value)==null?void 0:e.value;if(!_||_==="")throw new Error(`${E}The "${je(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof _!="string")throw new Error(`${E}The "${je(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.UploadFile].inputs.file.id}),K=(f=L==null?void 0:L.value)==null?void 0:f.value;if(!K)throw new Error(`${E}The "${je(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"File")}" (\`${Xe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"file")}\`) input is missing'`);if(typeof K!="object"||!K.uri||typeof K.uri!="string")throw new Error(`${E}The "${je(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"File")}" (\`${Xe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"file")}\`) input is invalid, should be an object with a text 'uri' property.`);const q=K.uri,W=K.mimeType||"application/octet-stream",H=_,ne=(h=(await Ii.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files?bucket=${D}&key=${encodeURIComponent(H)}&contentType=${encodeURIComponent(W)}`,{},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}})).data)==null?void 0:h.uploadUrl;if(!ne)throw new Error(`${E}Failed to retrieve pre-signed upload URL.`);let z;try{z=await OB(q,()=>m.getAccessToken())}catch(ae){throw new Error(`${E}Failed to fetch file content from '${q}': ${(ae==null?void 0:ae.message)||ae}`)}await Ii.put(ne,z,{headers:{"Content-Type":W}});const J={uri:`${m.env.API_BASE_URL}/cloud-files-service/v1/files/download?bucket=${D}&key=${encodeURIComponent(H)}`,name:H.split("/").pop()||H,mimeType:W,size:z.length};return{value:j.Success,error:null,result:J}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class qot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_FILE,version:"1.0.0",description:"Cloud File System: Get File",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.GetFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"getFile"),T="["+je(i,i.project,"Get file")+": `"+h+"`] ",g=n.find(L=>{var K,q;return((q=(K=L.valueOwner)==null?void 0:K.declaration)==null?void 0:q.id)===B.operation[Se.GetFile].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(L=>L.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(L=>{var K,q;return((q=(K=L.valueOwner)==null?void 0:K.declaration)==null?void 0:q.id)===B.operation[Se.GetFile].inputs.key.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value;if(!V||V==="")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof V!="string")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=(await Ii.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/metadata?bucket=${I}&key=${encodeURIComponent(V)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}})).data;return{value:j.Success,error:null,result:{uri:_.uri,name:_.name,key:_.key,size:_.size,mimeType:_.mimeType,access:_.access,lastModified:_.lastModified}}}catch(f){return{value:j.UnhandledError,error:f,result:null}}}})}}class Zot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_LIST_FILES,version:"1.0.0",description:"Cloud File System: List Files",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.ListFiles);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"listFiles"),E="["+je(i,i.project,"List files")+": `"+T+"`] ",I=n.find(ye=>{var fe,ve;return((ve=(fe=ye.valueOwner)==null?void 0:fe.declaration)==null?void 0:ve.id)===B.operation[Se.ListFiles].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(ye=>ye.resourceId===D))throw new Error(`${E}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const N=n.find(ye=>{var fe,ve;return((ve=(fe=ye.valueOwner)==null?void 0:fe.declaration)==null?void 0:ve.id)===B.operation[Se.ListFiles].inputs.path.id}),_=(e=N==null?void 0:N.value)==null?void 0:e.value;if(_!==void 0&&typeof _!="string")throw new Error(`${E}The "${je(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"Path")}" (\`${Xe(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"path")}\`) input value is invalid, if present, it must be a string.`);const L=n.find(ye=>{var fe,ve;return((ve=(fe=ye.valueOwner)==null?void 0:fe.declaration)==null?void 0:ve.id)===B.operation[Se.ListFiles].inputs.maxKeys.id}),K=(f=L==null?void 0:L.value)==null?void 0:f.value;if(K!==void 0&&(typeof K!="number"||K<=0))throw new Error(`${E}The "${je(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Max results")}" (\`${Xe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"maxKeys")}\`) input value is invalid, if present, it must be a number greater than 0.`);const q=n.find(ye=>{var fe,ve;return((ve=(fe=ye.valueOwner)==null?void 0:fe.declaration)==null?void 0:ve.id)===B.operation[Se.ListFiles].inputs.startAfter.id}),W=(h=q==null?void 0:q.value)==null?void 0:h.value;if(W!==void 0&&(typeof W!="string"||W===""))throw new Error(`${E}The "${je(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"Start after")}" (\`${Xe(q==null?void 0:q.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=${D}`;_&&(H+=`&path=${encodeURIComponent(_)}`),K&&(H+=`&maxKeys=${K}`),W&&(H+=`&startAfter=${encodeURIComponent(W)}`);const te=await Ii.get(H,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}}),ne=ye=>{var Oe;if(!ye)return"application/octet-stream";const fe=ye.split(".");if(fe.length<=1)return"application/octet-stream";const ve=(Oe=fe.pop())==null?void 0:Oe.toLowerCase();return ve&&{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",txt:"text/plain",html:"text/html",css:"text/css",js:"application/javascript",json:"application/json",csv:"text/csv",xml:"application/xml",zip:"application/zip",mp3:"audio/mpeg",mp4:"video/mp4",mov:"video/quicktime",wav:"audio/wav"}[ve]||"application/octet-stream"},Q=(te.data.items||te.data.files||[]).map(ye=>({uri:ye.uri||ye.url||`${m.env.API_BASE_URL}/cloud-files-service/v1/files/download?bucket=${D}&key=${encodeURIComponent(ye.key)}`,name:ye.name,key:ye.key,mimeType:ye.mimeType||ne(ye.key),size:ye.size||0,lastModified:ye.lastModified,access:ye.access})),J=te.data.total!==void 0?te.data.total:Q.length,ae=te.data.size!==void 0?te.data.size:Q.reduce((ye,fe)=>ye+(fe.size||0),0),ee=te.data.nextStartAfter!==void 0?te.data.nextStartAfter:null,de=te.data.hasMore!==void 0?te.data.hasMore:!1;return{value:j.Success,error:null,result:{items:Q,total:J,size:ae,nextStartAfter:ee,hasMore:de}}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class Hot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_DELETE_FILES,version:"1.0.0",description:"Cloud File System: Delete Files",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.DeleteFiles);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"deleteFiles"),T="["+je(i,i.project,"Delete files")+": `"+h+"`] ",g=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.DeleteFiles].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(K=>K.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.DeleteFiles].inputs.keys.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value,N=Array.isArray(V)?V:typeof V=="string"&&V!==""?[V]:[];if(!N||N.length===0)throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Keys")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"keys")}\`) input is missing.`);if(!Array.isArray(N)||N.some(K=>typeof K!="string"||K===""))throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Keys")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"keys")}\`) input value is invalid, if present, it must be a list of non-empty strings.`);const L=(await Ii.delete(`${f.env.API_BASE_URL}/cloud-files-service/v1/files`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`},data:{bucket:I,keys:N}})).data;return{value:j.Success,error:null,result:null}}catch(f){return{value:j.UnhandledError,error:f,result:null}}}})}}class Wot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_COPY_FILE,version:"1.0.0",description:"Cloud File System: Copy File",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.CopyFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"copyFile"),I="["+je(i,i.project,"Copy file")+": `"+g+"`] ",A=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.CopyFile].inputs.bucket.id}),D=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!D||!D.id||!D.name||D.type!==r.DefinitionEntity)throw new Error(`${I}Invalid input "${je(A==null?void 0:A.valueOwner,T==null?void 0:T.logic,"Storage")}" (\`${Xe(A==null?void 0:A.valueOwner,T==null?void 0:T.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const V=$s(D==null?void 0:D.id,((c=T.branchHead)==null?void 0:c.identifier)||"main");if(!((T==null?void 0:T.liveResources)||[]).find(ae=>ae.resourceId===V))throw new Error(`${I}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const _=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.CopyFile].inputs.sourceKey.id}),L=(e=_==null?void 0:_.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${I}The "${je(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${Xe(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${I}The "${je(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${Xe(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.CopyFile].inputs.destinationKey.id}),q=(f=K==null?void 0:K.value)==null?void 0:f.value;if(!q||q==="")throw new Error(`${I}The "${je(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${Xe(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input is missing.`);if(typeof q!="string")throw new Error(`${I}The "${je(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${Xe(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const W=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.CopyFile].inputs.destinationBucket.id}),H=(h=W==null?void 0:W.value)==null?void 0:h.valueAsType;if(H&&(!H.id||!H.name||H.type!==r.DefinitionEntity))throw new Error(`${I}Invalid input "${je(W==null?void 0:W.valueOwner,T==null?void 0:T.logic,"Destination Storage")}" (\`${Xe(W==null?void 0:W.valueOwner,T==null?void 0:T.logic,"destinationBucket")}\`), expected a valid "Cloud file system" node.`);const te=H!=null&&H.id?$s(H.id,((m=T.branchHead)==null?void 0:m.identifier)||"main"):V;if(!((T==null?void 0:T.liveResources)||[]).find(ae=>ae.resourceId===te))throw new Error(`${I}The destination "Cloud file system" is not live. Publish the project first, then try again to run the operation node.`);const z={headers:{Authorization:`Bearer ${await T.getAccessToken()}`}},J=(await Ii.post(`${T.env.API_BASE_URL}/cloud-files-service/v1/files/copy`,{bucket:V,destinationBucket:te,sourceKey:L,destinationKey:q},z)).data;return{value:j.Success,error:null,result:null}}catch(T){return{value:j.UnhandledError,error:T,result:null}}}})}}class zot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_MOVE_FILE,version:"1.0.0",description:"Cloud File System: Move File",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.MoveFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"moveFile"),I="["+je(i,i.project,"Move file")+": `"+g+"`] ",A=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.MoveFile].inputs.bucket.id}),D=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!D||!D.id||!D.name||D.type!==r.DefinitionEntity)throw new Error(`${I}Invalid input "${je(A==null?void 0:A.valueOwner,T==null?void 0:T.logic,"Storage")}" (\`${Xe(A==null?void 0:A.valueOwner,T==null?void 0:T.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const V=$s(D==null?void 0:D.id,((c=T.branchHead)==null?void 0:c.identifier)||"main");if(!((T==null?void 0:T.liveResources)||[]).find(ae=>ae.resourceId===V))throw new Error(`${I}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const _=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.MoveFile].inputs.sourceKey.id}),L=(e=_==null?void 0:_.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${I}The "${je(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${Xe(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${I}The "${je(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${Xe(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.MoveFile].inputs.destinationKey.id}),q=(f=K==null?void 0:K.value)==null?void 0:f.value;if(!q||q==="")throw new Error(`${I}The "${je(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${Xe(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input is missing.`);if(typeof q!="string")throw new Error(`${I}The "${je(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${Xe(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const W=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.MoveFile].inputs.destinationBucket.id}),H=(h=W==null?void 0:W.value)==null?void 0:h.valueAsType;if(H&&(!H.id||!H.name||H.type!==r.DefinitionEntity))throw new Error(`${I}Invalid input "${je(W==null?void 0:W.valueOwner,T==null?void 0:T.logic,"Destination storage")}" (\`${Xe(W==null?void 0:W.valueOwner,T==null?void 0:T.logic,"destinationBucket")}\`), expected a valid "Cloud file system" node.`);const te=H!=null&&H.id?$s(H.id,((m=T.branchHead)==null?void 0:m.identifier)||"main"):V;if(!((T==null?void 0:T.liveResources)||[]).find(ae=>ae.resourceId===te))throw new Error(`${I}The destination "Cloud file system" is not live. Publish the project first, then try again to run the operation node.`);const z={headers:{Authorization:`Bearer ${await T.getAccessToken()}`}},J=(await Ii.post(`${T.env.API_BASE_URL}/cloud-files-service/v1/files/move`,{bucket:V,destinationBucket:te,sourceKey:L,destinationKey:q},z)).data;return{value:j.Success,error:null,result:null}}catch(T){return{value:j.UnhandledError,error:T,result:null}}}})}}class Yot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_RENAME_FILE,version:"1.0.0",description:"Cloud File System: Rename File",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.RenameFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=Xe(i,i.project,"renameFile"),g="["+je(i,i.project,"Rename file")+": `"+m+"`] ",E=n.find(ne=>{var z,Q;return((Q=(z=ne.valueOwner)==null?void 0:z.declaration)==null?void 0:Q.id)===B.operation[Se.RenameFile].inputs.bucket.id}),I=(a=E==null?void 0:E.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==r.DefinitionEntity)throw new Error(`${g}Invalid input "${je(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${Xe(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const A=$s(I==null?void 0:I.id,((c=h.branchHead)==null?void 0:c.identifier)||"main");if(!((h==null?void 0:h.liveResources)||[]).find(ne=>ne.resourceId===A))throw new Error(`${g}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const V=n.find(ne=>{var z,Q;return((Q=(z=ne.valueOwner)==null?void 0:z.declaration)==null?void 0:Q.id)===B.operation[Se.RenameFile].inputs.key.id}),N=(e=V==null?void 0:V.value)==null?void 0:e.value;if(!N||N==="")throw new Error(`${g}The "${je(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof N!="string")throw new Error(`${g}The "${je(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=n.find(ne=>{var z,Q;return((Q=(z=ne.valueOwner)==null?void 0:z.declaration)==null?void 0:Q.id)===B.operation[Se.RenameFile].inputs.newName.id}),L=(f=_==null?void 0:_.value)==null?void 0:f.value;if(!L||L==="")throw new Error(`${g}The "${je(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"New name")}" (\`${Xe(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"newName")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${g}The "${je(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"New name")}" (\`${Xe(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"newName")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=N.lastIndexOf("/"),W=`${K!==-1?N.substring(0,K+1):""}${L}`,H={headers:{Authorization:`Bearer ${await h.getAccessToken()}`}},te=await Ii.post(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/rename`,{bucket:A,key:N,newName:L},H);return{value:j.Success,error:null,result:te.data||{key:N,newName:L,destinationKey:W}}}catch(h){return{value:j.UnhandledError,error:h,result:null}}}})}}class Jot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_FILE_METADATA,version:"1.0.0",description:"Cloud File System: Get File Metadata",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.GetFileMetadata);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"getFileMetadata"),T="["+je(i,i.project,"Get file metadata")+": `"+h+"`] ",g=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation[Se.GetFileMetadata].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(_=>_.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation[Se.GetFileMetadata].inputs.key.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value;if(!V||V==="")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof V!="string")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const N=await Ii.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/metadata?bucket=${I}&key=${encodeURIComponent(V)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});return{value:j.Success,error:null,result:N.data}}catch(f){return{value:j.UnhandledError,error:f,result:null}}}})}}class Qot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CHECK_FILE_EXISTS,version:"1.0.0",description:"Cloud File System: Check File Exists",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.CheckFileExists);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"checkFileExists"),T="["+je(i,i.project,"Check File Exists")+": `"+h+"`] ",g=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation[Se.CheckFileExists].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(_=>_.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation[Se.CheckFileExists].inputs.key.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value;if(!V||V==="")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof V!="string")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const N=await Ii.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/exists?bucket=${I}&key=${encodeURIComponent(V)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});return{value:j.Success,error:null,result:N.data.exists}}catch(f){return{value:j.UnhandledError,error:f,result:!1}}}})}}class Xot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_PRESIGNED_URL,version:"1.0.0",description:"Cloud File System: Get Pre-signed URL",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.GetPresignedUrl);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"getPresignedUrl"),E="["+je(i,i.project,"Get pre-signed URL")+": `"+T+"`] ",I=n.find(Q=>{var J,ae;return((ae=(J=Q.valueOwner)==null?void 0:J.declaration)==null?void 0:ae.id)===B.operation[Se.GetPresignedUrl].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(Q=>Q.resourceId===D))throw new Error(`${E}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const N=n.find(Q=>{var J,ae;return((ae=(J=Q.valueOwner)==null?void 0:J.declaration)==null?void 0:ae.id)===B.operation[Se.GetPresignedUrl].inputs.key.id}),_=(e=N==null?void 0:N.value)==null?void 0:e.value;if(!_||_==="")throw new Error(`${E}The "${je(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof _!="string")throw new Error(`${E}The "${je(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=n.find(Q=>{var J,ae;return((ae=(J=Q.valueOwner)==null?void 0:J.declaration)==null?void 0:ae.id)===B.operation[Se.GetPresignedUrl].inputs.action.id}),K=(f=L==null?void 0:L.value)==null?void 0:f.value,q=(K||"read").toLowerCase(),W=["read","write","delete","metadata","upload","putobject","head","headobject","getobject","get"];if(!K||K==="")throw new Error(`${E}The "${je(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Action")}" (\`${Xe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"action")}\`) input is missing.`);if(!W.includes(q))throw new Error(`${E}Invalid "${je(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Action")}" (\`${Xe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"action")}\`) input value, must be one of "read", "write", "delete" or "metadata".`);const H=n.find(Q=>{var J,ae;return((ae=(J=Q.valueOwner)==null?void 0:J.declaration)==null?void 0:ae.id)===B.operation[Se.GetPresignedUrl].inputs.expiresInSeconds.id}),te=(h=H==null?void 0:H.value)==null?void 0:h.value,ne=te!=null?Number(te):3600;if(isNaN(ne)||ne<=0)throw new Error(`${E}Invalid "${je(H==null?void 0:H.valueOwner,m==null?void 0:m.logic,"Expires in seconds")}" (\`${Xe(H==null?void 0:H.valueOwner,m==null?void 0:m.logic,"expiresInSeconds")}\`) input value, expected a positive number.`);const z=await Ii.get(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/presigned-url?bucket=${D}&key=${encodeURIComponent(_)}&action=${q}&expiresInSeconds=${ne}`,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:j.Success,error:null,result:z.data}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class edt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_SET_FILE_ACCESS,version:"1.0.0",description:"Cloud File System: Set File Access",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.SetFileAccess);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=Xe(i,i.project,"setFileAccess"),g="["+je(i,i.project,"Set file access")+": `"+m+"`] ",E=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.SetFileAccess].inputs.bucket.id}),I=(a=E==null?void 0:E.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==r.DefinitionEntity)throw new Error(`${g}Invalid input "${je(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${Xe(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const A=$s(I==null?void 0:I.id,((c=h.branchHead)==null?void 0:c.identifier)||"main");if(!((h==null?void 0:h.liveResources)||[]).find(K=>K.resourceId===A))throw new Error(`${g}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const V=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.SetFileAccess].inputs.key.id}),N=(e=V==null?void 0:V.value)==null?void 0:e.value;if(!N||N==="")throw new Error(`${g}The "${je(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof N!="string")throw new Error(`${g}The "${je(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.SetFileAccess].inputs.access.id}),L=((f=_==null?void 0:_.value)==null?void 0:f.value)??"private";if(!L||L==="")throw new Error(`${g}The "${je(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"Access")}" (\`${Xe(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"access")}\`) input is missing.`);if(typeof L!="string"||!["public","private"].includes(L))throw new Error(`${g}The "${je(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"Access")}" (\`${Xe(_==null?void 0:_.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 Ii.post(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/access`,{bucket:A,key:N,access:L},{headers:{Authorization:`Bearer ${await h.getAccessToken()}`}}),{value:j.Success,error:null,result:null}}catch(h){return{value:j.UnhandledError,error:h,result:null}}}})}}class tdt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CREATE_FOLDER,version:"1.0.0",description:"Cloud File System: Create Folder",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.CreateFolder);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"createFolder"),T="["+je(i,i.project,"Create folder")+": `"+h+"`] ",g=n.find(L=>{var K,q;return((q=(K=L.valueOwner)==null?void 0:K.declaration)==null?void 0:q.id)===B.operation[Se.CreateFolder].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(L=>L.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(L=>{var K,q;return((q=(K=L.valueOwner)==null?void 0:K.declaration)==null?void 0:q.id)===B.operation[Se.CreateFolder].inputs.folderPath.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value;if(!V||V==="")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Folder path")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"folderPath")}\`) input is missing.`);if(typeof V!="string")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Folder path")}" (\`${Xe(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.`);const _=(await Ii.post(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/folders`,{bucket:I,folderPath:V},{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}})).data;return{value:j.Success,error:null,result:null}}catch(f){return{value:j.UnhandledError,error:f,result:null}}}})}}class idt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_DELETE_FOLDERS,version:"1.0.0",description:"Cloud File System: Delete Folders",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.DeleteFolders);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"deleteFolders"),T="["+je(i,i.project,"Delete folders")+": `"+h+"`] ",g=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.DeleteFolders].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(K=>K.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.DeleteFolders].inputs.folderPaths.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value,N=Array.isArray(V)?V:typeof V=="string"&&V!==""?[V]:[];if(!N||N.length===0)throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Folder paths")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"folderPaths")}\`) input is missing.`);if(!Array.isArray(N)||N.some(K=>typeof K!="string"||K===""))throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Folder paths")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"folderPaths")}\`) input value is invalid, if present, it must be a list of non-empty strings.`);const L=(await Ii.delete(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/folders`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`},data:{bucket:I,folderPaths:N}})).data;return{value:j.Success,error:null,result:null}}catch(f){return{value:j.UnhandledError,error:f,result:null}}}})}}class ndt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CREATE_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Create Multipart Upload",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.CreateMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"createMultipartUpload"),E="["+je(i,i.project,"Create multipart upload")+": `"+T+"`] ",I=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.CreateMultipartUpload].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),V=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.CreateMultipartUpload].inputs.key.id}),N=(e=V==null?void 0:V.value)==null?void 0:e.value;if(!N||N==="")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof N!="string")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.CreateMultipartUpload].inputs.contentType.id}),L=((f=_==null?void 0:_.value)==null?void 0:f.value)||"application/octet-stream";if(!L||L==="")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Content Type")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"contentType")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Content Type")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"contentType")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=await Ii.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart?bucket=${D}&key=${encodeURIComponent(N)}&contentType=${encodeURIComponent(L)}`,{},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:j.Success,error:null,result:{uploadId:typeof K.data=="object"&&((h=K.data)!=null&&h.uploadId)?K.data.uploadId:K.data}}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class rdt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.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:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.GetUploadPartPresignedUrl);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"getUploadPartPresignedUrl"),E="["+je(i,i.project,"Get upload part pre-signed URL")+": `"+T+"`] ",I=n.find(H=>{var te,ne;return((ne=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:ne.id)===B.operation[Se.GetUploadPartPresignedUrl].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),V=n.find(H=>{var te,ne;return((ne=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:ne.id)===B.operation[Se.GetUploadPartPresignedUrl].inputs.key.id}),N=(e=V==null?void 0:V.value)==null?void 0:e.value;if(!N||N==="")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof N!="string")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=n.find(H=>{var te,ne;return((ne=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:ne.id)===B.operation[Se.GetUploadPartPresignedUrl].inputs.uploadId.id}),L=(f=_==null?void 0:_.value)==null?void 0:f.value;if(!L||L==="")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=n.find(H=>{var te,ne;return((ne=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:ne.id)===B.operation[Se.GetUploadPartPresignedUrl].inputs.partNumber.id}),q=Number((h=K==null?void 0:K.value)==null?void 0:h.value);if(isNaN(q)||q<=0)throw new Error(`${E}The "${je(K==null?void 0:K.valueOwner,m==null?void 0:m.logic,"Part number")}" (\`${Xe(K==null?void 0:K.valueOwner,m==null?void 0:m.logic,"partNumber")}\`) input is missing or invalid.`);const W=await Ii.get(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${L}?bucket=${D}&key=${encodeURIComponent(N)}&partNumber=${q}`,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:j.Success,error:null,result:W.data}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class adt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_COMPLETE_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Complete Multipart Upload",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.CompleteMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"completeMultipartUpload"),E="["+je(i,i.project,"Complete multipart upload")+": `"+T+"`] ",I=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===B.operation[Se.CompleteMultipartUpload].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),V=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===B.operation[Se.CompleteMultipartUpload].inputs.key.id}),N=(e=V==null?void 0:V.value)==null?void 0:e.value;if(!N||N==="")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof N!="string")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===B.operation[Se.CompleteMultipartUpload].inputs.uploadId.id}),L=(f=_==null?void 0:_.value)==null?void 0:f.value;if(!L||L==="")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===B.operation[Se.CompleteMultipartUpload].inputs.parts.id}),q=(h=K==null?void 0:K.value)==null?void 0:h.value;if(!Array.isArray(q)||q.length===0)throw new Error(`${E}The "${je(K==null?void 0:K.valueOwner,m==null?void 0:m.logic,"Parts")}" (\`${Xe(K==null?void 0:K.valueOwner,m==null?void 0:m.logic,"parts")}\`) input is missing or empty.`);if(q.some(te=>{let ne=!1,z=!1;return(te.partNumber&&Number(te.partNumber)>0||te.PartNumber&&Number(te.PartNumber)>0)&&(ne=!0),(te.etag&&typeof te.etag=="string"||te.ETag&&typeof te.ETag=="string")&&(z=!0),!ne||!z}))throw new Error(`${E}The "${je(K==null?void 0:K.valueOwner,m==null?void 0:m.logic,"Parts")}" (\`${Xe(K==null?void 0:K.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 Ii.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${L}/complete?bucket=${D}&key=${encodeURIComponent(N)}`,{parts:q},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}})).data||{};return{value:j.Success,error:null,result:{location:H.location||H.Location||N,key:H.key||H.Key||N,etag:H.etag||H.ETag||null}}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class sdt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_ABORT_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Abort Multipart Upload",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.AbortMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=Xe(i,i.project,"abortMultipartUpload"),g="["+je(i,i.project,"Abort multipart upload")+": `"+m+"`] ",E=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.AbortMultipartUpload].inputs.bucket.id}),I=(a=E==null?void 0:E.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==r.DefinitionEntity)throw new Error(`${g}Invalid input "${je(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${Xe(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const A=$s(I==null?void 0:I.id,((c=h.branchHead)==null?void 0:c.identifier)||"main"),D=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.AbortMultipartUpload].inputs.key.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value;if(!V||V==="")throw new Error(`${g}The "${je(D==null?void 0:D.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof V!="string")throw new Error(`${g}The "${je(D==null?void 0:D.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const N=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.AbortMultipartUpload].inputs.uploadId.id}),_=(f=N==null?void 0:N.value)==null?void 0:f.value;if(!_||_==="")throw new Error(`${g}The "${je(N==null?void 0:N.valueOwner,h==null?void 0:h.logic,"Upload ID")}" (\`${Xe(N==null?void 0:N.valueOwner,h==null?void 0:h.logic,"uploadId")}\`) input is missing.`);if(typeof _!="string")throw new Error(`${g}The "${je(N==null?void 0:N.valueOwner,h==null?void 0:h.logic,"Upload ID")}" (\`${Xe(N==null?void 0:N.valueOwner,h==null?void 0:h.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=(await Ii.delete(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${_}?bucket=${A}&key=${encodeURIComponent(V)}`,{headers:{Authorization:`Bearer ${await h.getAccessToken()}`}})).data;return{value:j.Success,error:null,result:null}}catch(h){return{value:j.UnhandledError,error:h,result:null}}}})}}class Len extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_UPLOAD_FILE_PART,version:"1.0.0",description:"Cloud File System: Upload File Part",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.UploadFilePart);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E;try{const I=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!I||!I.env)throw new Error("Editor context or environment missing");const A=Xe(i,i.project,"uploadFilePart"),V="["+je(i,i.project,"Upload file part")+": `"+A+"`] ",N=n.find(ve=>{var Ce,Oe;return((Oe=(Ce=ve.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Oe.id)===B.operation[Se.UploadFilePart].inputs.bucket.id}),_=(a=N==null?void 0:N.value)==null?void 0:a.valueAsType;if(!_||!_.id||!_.name||_.type!==r.DefinitionEntity)throw new Error(`${V}Invalid input "${je(N==null?void 0:N.valueOwner,I==null?void 0:I.logic,"Storage")}" (\`${Xe(N==null?void 0:N.valueOwner,I==null?void 0:I.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const L=$s(_==null?void 0:_.id,((c=I.branchHead)==null?void 0:c.identifier)||"main");if(!((I==null?void 0:I.liveResources)||[]).find(ve=>ve.resourceId===L))throw new Error(`${V}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const q=n.find(ve=>{var Ce,Oe;return((Oe=(Ce=ve.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Oe.id)===B.operation[Se.UploadFilePart].inputs.key.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(!W||W==="")throw new Error(`${V}The "${je(q==null?void 0:q.valueOwner,I==null?void 0:I.logic,"Key")}" (\`${Xe(q==null?void 0:q.valueOwner,I==null?void 0:I.logic,"key")}\`) input is missing.`);if(typeof W!="string")throw new Error(`${V}The "${je(q==null?void 0:q.valueOwner,I==null?void 0:I.logic,"Key")}" (\`${Xe(q==null?void 0:q.valueOwner,I==null?void 0:I.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const H=n.find(ve=>{var Ce,Oe;return((Oe=(Ce=ve.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Oe.id)===B.operation[Se.UploadFilePart].inputs.uploadId.id}),te=(f=H==null?void 0:H.value)==null?void 0:f.value;if(!te||te==="")throw new Error(`${V}The "${je(H==null?void 0:H.valueOwner,I==null?void 0:I.logic,"Upload ID")}" (\`${Xe(H==null?void 0:H.valueOwner,I==null?void 0:I.logic,"uploadId")}\`) input is missing.`);if(typeof te!="string")throw new Error(`${V}The "${je(H==null?void 0:H.valueOwner,I==null?void 0:I.logic,"Upload ID")}" (\`${Xe(H==null?void 0:H.valueOwner,I==null?void 0:I.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const ne=n.find(ve=>{var Ce,Oe;return((Oe=(Ce=ve.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Oe.id)===B.operation[Se.UploadFilePart].inputs.partNumber.id}),z=Number((h=ne==null?void 0:ne.value)==null?void 0:h.value);if(((m=ne==null?void 0:ne.value)==null?void 0:m.value)===void 0||((T=ne==null?void 0:ne.value)==null?void 0:T.value)===null||isNaN(z)||z<=0)throw new Error(`${V}The "${je(ne==null?void 0:ne.valueOwner,I==null?void 0:I.logic,"Part number")}" (\`${Xe(ne==null?void 0:ne.valueOwner,I==null?void 0:I.logic,"partNumber")}\`) input is missing or invalid.`);const Q=n.find(ve=>{var Ce,Oe;return((Oe=(Ce=ve.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Oe.id)===B.operation[Se.UploadFilePart].inputs.bytes.id}),J=(g=Q==null?void 0:Q.value)==null?void 0:g.value;if(J==null)throw new Error(`${V}The "${je(Q==null?void 0:Q.valueOwner,I==null?void 0:I.logic,"Bytes")}" (\`${Xe(Q==null?void 0:Q.valueOwner,I==null?void 0:I.logic,"bytes")}\`) input is missing.`);const ee=(E=(await Ii.get(`${I.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${te}?bucket=${L}&key=${encodeURIComponent(W)}&partNumber=${z}`,{headers:{Authorization:`Bearer ${await I.getAccessToken()}`}})).data)==null?void 0:E.uploadUrl;if(!ee)throw new Error(`${V}Failed to obtain presigned upload URL for part ${z}.`);const de=await Ii.put(ee,J,{headers:{"Content-Type":"application/octet-stream"}}),ye=de.headers.etag||de.headers.ETag||"",fe=typeof ye=="string"?ye.replace(/"/g,""):"";return{value:j.Success,error:null,result:{partNumber:z,etag:fe}}}catch(I){return{value:j.UnhandledError,error:I,result:null}}}})}}class xN extends rO{constructor(u,i,n=i.projectId){super(u,X.Editor),this._editor=i,this.id=n}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,n){return this._editor.resolveInitialChildrenPositions(u,i,n)}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,n){return this._editor.moveBranchHeadToVersion(u,i,n)}loadInitialBranchHead(){return this._editor.loadInitialBranchHead()}}function Gen(l,u){return u instanceof xN?u:new xN(l,u)}class _N extends rO{constructor(u,i){super(u,X.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 Ben(l,u){return u instanceof _N?u:new _N(l,u)}function Men(l){l.register(new Yet(l)),l.register(new zet(l)),l.register(new qet(l)),l.register(new Het(l)),l.register(new Wet(l)),l.register(new Zet(l)),l.register(new xat(l)),l.register(new _at(l)),l.register(new Vat(l)),l.register(new $at(l)),l.register(new Nat(l)),l.register(new Lat(l)),l.register(new Elt(l)),l.register(new Alt(l)),l.register(new Ilt(l)),l.register(new Rlt(l)),l.register(new Dlt(l)),l.register(new Clt(l)),l.register(new wlt(l)),l.register(new Olt(l)),l.register(new Plt(l)),l.register(new xlt(l)),l.register(new Prt(l)),l.register(new xrt(l)),l.register(new _rt(l)),l.register(new Vrt(l)),l.register(new Nrt(l)),l.register(new $rt(l)),l.register(new Lrt(l)),l.register(new Grt(l)),l.register(new Brt(l)),l.register(new Mrt(l)),l.register(new Frt(l)),l.register(new krt(l)),l.register(new Srt(l)),l.register(new Urt(l)),l.register(new jrt(l)),l.register(new Krt(l)),l.register(new qrt(l)),l.register(new Zrt(l)),l.register(new Hrt(l)),l.register(new Yrt(l)),l.register(new Jrt(l)),l.register(new Qrt(l)),l.register(new znt(l)),l.register(new Ynt(l)),l.register(new Jnt(l)),l.register(new Qnt(l)),l.register(new Xnt(l)),l.register(new ert(l)),l.register(new trt(l)),l.register(new irt(l)),l.register(new nrt(l)),l.register(new art(l)),l.register(new srt(l)),l.register(new lrt(l)),l.register(new ort(l)),l.register(new drt(l)),l.register(new ynt(l)),l.register(new Fst(l)),l.register(new Bst(l)),l.register(new Mst(l)),l.register(new fit(l)),l.register(new yit(l)),l.register(new hit(l)),l.register(new mit(l)),l.register(new Tit(l)),l.register(new vit(l)),l.register(new git(l)),l.register(new bit(l)),l.register(new Eit(l)),l.register(new $it(l)),l.register(new pnt(l)),l.register(new cnt(l)),l.register(new fnt(l)),l.register(new Ait(l)),l.register(new Iit(l)),l.register(new Rit(l)),l.register(new Dit(l)),l.register(new Cit(l)),l.register(new wit(l)),l.register(new Oit(l)),l.register(new Pit(l)),l.register(new xit(l)),l.register(new _it(l)),l.register(new Vit(l)),l.register(new Nit(l)),l.register(new Lit(l)),l.register(new Git(l)),l.register(new Bit(l)),l.register(new Mit(l)),l.register(new Fit(l)),l.register(new kit(l)),l.register(new Sit(l)),l.register(new Uit(l)),l.register(new jit(l)),l.register(new Kit(l)),l.register(new qit(l)),l.register(new Zit(l)),l.register(new tnt(l)),l.register(new int(l)),l.register(new nnt(l)),l.register(new Hit(l)),l.register(new Wit(l)),l.register(new zit(l)),l.register(new Yit(l)),l.register(new Jit(l)),l.register(new Qit(l)),l.register(new Xit(l)),l.register(new ent(l)),l.register(new jst(l)),l.register(new Kst(l)),l.register(new qst(l)),l.register(new Zst(l)),l.register(new kst(l)),l.register(new Sst(l)),l.register(new Ust(l)),l.register(new Hst(l)),l.register(new zst(l)),l.register(new Jst(l)),l.register(new Wst(l)),l.register(new Yst(l)),l.register(new Qst(l)),l.register(new tlt(l)),l.register(new Xst(l)),l.register(new elt(l)),l.register(new urt(l)),l.register(new yrt(l)),l.register(new hrt(l)),l.register(new vrt(l)),l.register(new grt(l)),l.register(new brt(l)),l.register(new Ert(l)),l.register(new Art(l)),l.register(new Irt(l)),l.register(new Rrt(l)),l.register(new Drt(l)),l.register(new mrt(l)),l.register(new Trt(l)),l.register(new Kot(l)),l.register(new qot(l)),l.register(new Zot(l)),l.register(new Hot(l)),l.register(new Wot(l)),l.register(new zot(l)),l.register(new Yot(l)),l.register(new Jot(l)),l.register(new Qot(l)),l.register(new Xot(l)),l.register(new edt(l)),l.register(new tdt(l)),l.register(new idt(l)),l.register(new ndt(l)),l.register(new rdt(l)),l.register(new adt(l)),l.register(new sdt(l)),l.register(new crt(l)),l.register(new frt(l)),l.register(new prt(l)),l.register(new rrt(l)),l.register(new wrt(l)),l.register(new Ort(l)),l.register(new Crt(l)),l.register(new Bat(l)),l.register(new lst(l)),l.register(new sst(l)),l.register(new ost(l)),l.register(new dst(l)),l.register(new kat(l)),l.register(new Sat(l)),l.register(new Hat(l)),l.register(new qat(l)),l.register(new rst(l)),l.register(new Qat(l)),l.register(new est(l)),l.register(new ist(l)),l.register(new tst(l)),l.register(new Zat(l)),l.register(new zat(l)),l.register(new Yat(l)),l.register(new Wat(l)),l.register(new Gat(l)),l.register(new Uat(l)),l.register(new Xat(l)),l.register(new cst(l)),l.register(new IN(l)),l.register(new Fat(l)),l.register(new jat(l)),l.register(new Mat(l)),l.register(new nst(l)),l.register(new Kat(l)),l.register(new Jat(l)),l.register(new ast(l)),l.register(new pst(l)),l.register(new ust(l)),l.register(new fst(l)),l.register(new IN(l)),l.register(new hst(l)),l.register(new yst(l)),l.register(new mst(l)),l.register(new fat(l)),l.register(new yat(l)),l.register(new hat(l)),l.register(new eat(l)),l.register(new zrt(l)),l.register(new rat(l)),l.register(new oat(l)),l.register(new Wrt(l)),l.register(new dat(l)),l.register(new cat(l)),l.register(new sat(l)),l.register(new aat(l)),l.register(new iD(l)),l.register(new mat(l)),l.register(new Tat(l)),l.register(new lat(l)),l.register(new pat(l)),l.register(new uat(l)),l.register(new nat(l)),l.register(new iat(l)),l.register(new tat(l)),l.register(new Xrt(l)),l.register(new bat(l)),l.register(new gat(l)),l.register(new Eat(l)),l.register(new vat(l)),l.register(new lnt(l)),l.register(new rnt(l)),l.register(new snt(l)),l.register(new ont(l)),l.register(new dnt(l)),l.register(new ant(l)),l.register(new unt(l)),l.register(new Nlt(l)),l.register(new Flt(l)),l.register(new Slt(l)),l.register(new jlt(l)),l.register(new Klt(l)),l.register(new qlt(l)),l.register(new Zlt(l)),l.register(new Mlt(l)),l.register(new klt(l)),l.register(new Ult(l)),l.register(new Blt(l)),l.register(new Glt(l)),l.register(new Llt(l)),l.register(new $lt(l)),l.register(new _lt(l)),l.register(new Vlt(l)),l.register(new Jlt(l)),l.register(new Qlt(l)),l.register(new zlt(l)),l.register(new Ylt(l)),l.register(new blt(l)),l.register(new Hlt(l)),l.register(new Wlt(l)),l.register(new eot(l)),l.register(new Xlt(l)),l.register(new tot(l)),l.register(new iot(l)),l.register(new not(l)),l.register(new Jet(l)),l.register(new Qet(l)),l.register(new eD(l)),l.register(new tD(l)),l.register(new oot(l)),l.register(new dot(l)),l.register(new cot(l)),l.register(new got(l)),l.register(new yot(l)),l.register(new uot(l)),l.register(new pot(l)),l.register(new hot(l)),l.register(new fot(l)),l.register(new mot(l)),l.register(new Tot(l)),l.register(new vot(l)),l.register(new bot(l)),l.register(new Eot(l)),l.register(new Aot(l)),l.register(new Iot(l)),l.register(new Dot(l)),l.register(new Cot(l)),l.register(new wot(l)),l.register(new Oot(l)),l.register(new Pot(l)),l.register(new xot(l)),l.register(new jot(l)),l.register(new _ot(l)),l.register(new Vot(l)),l.register(new Not(l)),l.register(new $ot(l)),l.register(new Lot(l)),l.register(new Got(l)),l.register(new Bot(l)),l.register(new Mot(l)),l.register(new Fot(l)),l.register(new kot(l)),l.register(new Sot(l)),l.register(new Uot(l)),l.register(new rot(l)),l.register(new aot(l))}class xB{constructor(u=new oe.Events("extensions-registry-fallback-events")){C(this,"extensionsRegistry",new Map);C(this,"initialized",new Set);C(this,"initializedContexts",new Set);C(this,"onResolveEditorContextCallback",()=>null);C(this,"onResolveProjectLogicContextCallback",()=>null);C(this,"onResolveEditorGUIContextCallback",()=>null);C(this,"onResolveGUIContextCallback",()=>null);C(this,"onResolveCompileContextCallback",()=>null);C(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||xe.Normal)-(i.manifest.initPriority||xe.Normal))}async setup(){Men(this),oe.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(u){switch(u){case X.Editor:return this.onResolveEditorContextCallback();case X.Logic:return this.onResolveProjectLogicContextCallback();case X.EditorGUI:return this.onResolveEditorGUIContextCallback();case X.Compile:return this.onResolveCompileContextCallback();case X.PublicationRun:return this.onResolvePublicationRunContextCallback();case X.GUI:return this.onResolveGUIContextCallback();case X.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${u}`)}}requestContexts(u,i=[]){const n=[];i.length===0&&(i=u.manifest.contexts);for(const a of i){const c=this.requestContext(a);c&&n.push(c)}return n}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 n of this.extensionInOrder)if(n.module.init&&!this.initialized.has(n.manifest.id)){const a=n.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);a.length&&(await((i=(u=n.module).init)==null?void 0:i.call(u,a)),this.initialized.add(n.manifest.id))}else!n.module.init&&!this.initialized.has(n.manifest.id)&&this.initialized.add(n.manifest.id)}async initForReady(){oe.Logger.log("Initializing extensions for ready contexts...");for(const u of this.extensionInOrder)if(u.module.init&&!this.initialized.has(u.manifest.id)){oe.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)):oe.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)?(oe.Logger.log("Set "+u.manifest.id+" extension as initialized by default..."),this.initialized.add(u.manifest.id)):oe.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)){oe.Logger.warn(`Context ${u} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(u),u){case X.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case X.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}oe.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 I1=null;const _B={requestExtension:l=>(I1||(I1=new xB,I1.setup()),I1.requestExtension(l))};function Qf(l){return!(l instanceof Error)&&typeof l=="object"&&l!==null?l:l instanceof Error?{name:l.name,message:l.message,stack:l.stack,...l}:l}function uq(l){var u,i,n;if(l&&typeof l=="object"&&"value"in l){const a=l;return{single:((u=a.value)==null?void 0:u.valueAsTypeSingle)??((i=a.value)==null?void 0:i.value),list:((n=a.value)==null?void 0:n.valueAsTypeList)??null}}return{single:l,list:Array.isArray(l)?l:null}}const Xf={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};class VN extends Error{constructor(){super("Execution was stopped"),this.name="ExecutionStoppedError"}}var VB=(l=>(l.FinishedSuccess="finished-success",l.FinishedError="finished-error",l.Running="running",l.Paused="paused",l.Stopped="stopped",l.NotStarted="not-started",l))(VB||{});const ldt={..._B,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class oT extends oe.Events{constructor(i,n,a,c=null,e=ldt){super();C(this,"project");C(this,"entryPoint");C(this,"state","not-started");C(this,"events",new oe.Events("fe-exec-inst-events"));C(this,"entities",[]);C(this,"parentExecution",null);C(this,"executing",[]);C(this,"executed",[]);C(this,"skipped",[]);C(this,"scheduled",[]);C(this,"localTestValues");C(this,"resolvedValues");C(this,"persistedExecutionResults");C(this,"lastExecutionResults");C(this,"onAddToSkippedListCallback",null);C(this,"onRemoveFromSkippedListCallback",null);C(this,"onAddEntityCallback",null);C(this,"onRemoveEntityCallback",null);C(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=n,this.entryPoint=a,this.project=i,this.parentExecution=c,this.localTestValues=new Hb(M.UUID.uuid(),this.project),this.resolvedValues=new Hb(M.UUID.uuid(),this.project),this.persistedExecutionResults=new Hb(M.UUID.uuid(),this.project),this.lastExecutionResults=new Hb(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 VN;for(;this.isPaused();){if(this.isStopped())throw new VN;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),zn.includes(i.type)&&Gt(i).forEach(n=>this.skip(n))))}async schedule(i,n,a){if(this.hasExecuted(i))return null;if(Oi.includes(i.type))return this.executeBranch(i,a,n);if(Yn.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,a,n);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,n){const a=[];return wi.includes(n.type)?a.push(...n.inputs.filter(e=>I0(e))):[...di,...Oi].includes(n.type)?a.push(...n.inputs):oi.includes(n.type)&&a.push(...n.outputs.filter(e=>I0(e))),a.map(e=>{var h;let f=i.find(m=>m.valueOwner.id===e.id);if(f)return f;if(!f&&Oi.includes(n.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 Ua.includes(e.type)?Wd(e,this.valueResolutionContext):Wc(e,this.valueResolutionContext)}).reduce((e,f)=>{const h=Hp(f==null?void 0:f.valueOwner,this.project),m=f?[f]:[];return h.forEach(T=>{var I,A,D;if(T.id===(f==null?void 0:f.valueOwner.id))return;const g=Xi(T.getDataType(null),T,this.project);g==null||g.metaSync({value:(I=f==null?void 0:f.value)==null?void 0:I.value},null),g==null||g.setValueAsTypeList(((A=f==null?void 0:f.value)==null?void 0:A.valueAsTypeList)||null),g==null||g.setValueAsTypeSingle(((D=f==null?void 0:f.value)==null?void 0:D.valueAsTypeSingle)||null);const E={...f,valueOwner:T,value:g};m.push(E)}),[...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,n,a,c={}){var f,h;this.logBeforeExecution("executeInternalCall",i,n);const e={...Xf,...c};try{let m={value:j.Success,error:null,result:null};if(n.sort((D,V)=>D.valueOwner.index-V.valueOwner.index),Object.values(wa).includes(i.declaration.id)){const D=this.parentContext.requestExtension(Gn+i.declaration.id).module.main;D?m=await D(i,n,this):oe.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{const D=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,n,a,e);m={value:D.value,error:D.error,result:D.result}}let T=null;if(m.error&&i.error){oe.Logger.warn("Raw error executing entity: ",m.error);const{single:D,list:V}=uq(m.error),N=Qf(D),_=(f=i.error)==null?void 0:f.getDataType(null),L=Xi(_||null,i.error,a);if(_!=null&&_.asType)V!==null?L==null||L.setValueAsTypeList(V):L==null||L.setValueAsTypeSingle(D);else{const K=oa(N)?JSON.stringify(N,null,2):N;L==null||L.metaSync({value:K},null)}T={valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:L}}const g=i==null?void 0:i.getDataType(null),E=Xi(g,i,a),{single:I,list:A}=uq(m.result);return g!=null&&g.asType?A!==null?E==null||E.setValueAsTypeList(A):E==null||E.setValueAsTypeSingle(I):E==null||E.metaSync({value:I},null),{value:m.value,entity:i,error:T,result:{value:E||null,valueOwner:i,type:Ze.ExecutionResult,inheritanceLink:null}}}catch(m){if(m&&(m.name==="ExecutionStoppedError"||m.message==="Execution was stopped"))throw m;oe.Logger.warn("Internal call execution error: ",m);let T=null;if(i.error){const g=Qf(m),E=(h=i.error)==null?void 0:h.getDataType(null),I=Xi(E,i.error,a);if(E!=null&&E.asType)I==null||I.setValueAsTypeSingle(m);else{const A=oa(g)?JSON.stringify(g,null,2):g;I==null||I.metaSync({value:A},null)}T={valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:I}}return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,entity:i,error:T,result:null}}}static async executeOperation(i,n,a,c){var e,f;c?c.logBeforeExecution("executeOperation",i,n):console.log(`executeOperation (${i.type}) -> [${Ee(i,a)}] Inputs:${n.length?`
61
+ `),u}class mot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleDriveUploadFile,version:"2.0.0",description:"Upload a file to Google Drive (media / import+copy) with auto content detection and simplified inputs.",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleDriveUploadFile);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I,A,D,V,N,_,L,K,q,W,H,te,ne,z,Q,J,ae,ee,de,ye,fe,ve,Ce,Oe;try{const Ne=((c=(a=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.connection.id}))==null?void 0:a.value)==null?void 0:c.valueAsType)??((f=(e=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.connection.id}))==null?void 0:e.value)==null?void 0:f.value);if(!(Ne instanceof Na))return Mp(i,"Invalid or missing connection entity");const De=((m=(h=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.content.id}))==null?void 0:h.value)==null?void 0:m.valueAsType)??((g=(T=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.content.id}))==null?void 0:T.value)==null?void 0:g.value),Ue=(V=((I=(E=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.name.id}))==null?void 0:E.value)==null?void 0:I.valueAsType)??((D=(A=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.name.id}))==null?void 0:A.value)==null?void 0:D.value))==null?void 0:V.trim(),Je=(((_=(N=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.mimeType.id}))==null?void 0:N.value)==null?void 0:_.valueAsType)??((K=(L=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.mimeType.id}))==null?void 0:L.value)==null?void 0:K.value))||"application/octet-stream",qe=(((W=(q=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.folderId.id}))==null?void 0:q.value)==null?void 0:W.valueAsType)??((te=(H=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.folderId.id}))==null?void 0:H.value)==null?void 0:te.value))||void 0,rt=(((z=(ne=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.description.id}))==null?void 0:ne.value)==null?void 0:z.valueAsType)??((J=(Q=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.description.id}))==null?void 0:Q.value)==null?void 0:J.value))||void 0,dt=(((ee=(ae=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.importMimeType.id}))==null?void 0:ae.value)==null?void 0:ee.valueAsType)??((ye=(de=n.find(Wi=>{var pi,ci;return((ci=(pi=Wi.valueOwner)==null?void 0:pi.declaration)==null?void 0:ci.id)===B.operation[me.GoogleDriveUploadFile].inputs.importMimeType.id}))==null?void 0:de.value)==null?void 0:ye.value))||"text/plain";if(!Ue)return Mp(i,"Missing required input: name");const ze=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],it=fr(Ne),Mt={Authorization:`Bearer ${await ze.getAccessToken()}`},jt=`${((fe=ze.env)==null?void 0:fe.API_BASE_URL)+"/editor-runtime"}/v2/external-integrations/proxy/${ze.projectId}/${vi["google-drive"]}/${it}`,wt=async(Wi,pi,{params:ci,body:As,contentType:rs,providerHeaders:Ar,responseType:mr}={})=>{const ri=`${jt}/${Ren(pi)}`,zt={...Mt};return rs&&(zt["Content-Type"]=rs),(Ar||mr)&&(zt[Ien]=JSON.stringify({...Ar?{headers:Ar}:{},...mr?{responseType:mr}:{}})),Ii.request({method:Wi,url:ri,params:ci,data:As,responseType:mr||"json",headers:zt})},ht=typeof Je=="string"&&Je.startsWith("application/vnd.google-apps.");if(ht&&(De==null||De==="")){const Wi={name:Ue,mimeType:Je};qe&&(Wi.parents=[qe]),typeof rt=="string"&&(Wi.description=rt);const pi=await wt("POST","/drive/v3/files",{params:{supportsAllDrives:"true",fields:zb},body:JSON.stringify(Wi),contentType:"application/json"});return pi.status!==200&&pi.status!==201?Mp(i,`Drive create failed (status=${pi.status})`):LV({file:pi.data})}if(ht&&De!=null){let Wi=await Cen(De);const ci=((mr,ri)=>ri||(mr==="application/vnd.google-apps.spreadsheet"?"text/csv":mr==="application/vnd.google-apps.document"||mr==="application/vnd.google-apps.presentation"?"text/html":"text/plain"))(Je,dt),As=ci.startsWith("text/")&&!/charset=/i.test(ci)?`${ci}; charset=UTF-8`:ci;ci.startsWith("text/csv")&&(Wi=wen(Wi));const rs=new TextEncoder().encode(Wi);if(rs.byteLength>dq)return Mp(i,`Text body exceeds simple upload limit (${rs.byteLength} bytes).`);let Ar;try{const mr=await wt("POST","/upload/drive/v3/files",{params:{uploadType:"media",supportsAllDrives:"true",fields:zb},body:rs,contentType:As});if(mr.status!==200&&mr.status!==201)return Mp(i,`Drive media upload failed (status=${mr.status})`);if(Ar=(ve=mr.data)==null?void 0:ve.id,!Ar)return Mp(i,"Drive media upload did not return an id");const ri={name:Ue,mimeType:Je};qe&&(ri.parents=[qe]),typeof rt=="string"&&(ri.description=rt);const zt=await wt("POST",`/drive/v3/files/${encodeURIComponent(Ar)}/copy`,{params:{supportsAllDrives:"true",fields:zb},body:JSON.stringify(ri),contentType:"application/json"});return zt.status!==200&&zt.status!==201?Mp(i,`Drive copy-convert failed (status=${zt.status})`):LV({file:zt.data})}finally{if(Ar)try{await wt("DELETE",`/drive/v3/files/${encodeURIComponent(Ar)}`,{params:{supportsAllDrives:"true"}})}catch{}}}if(De==null)return Mp(i,"Missing content for non-native upload");const{bytes:Jt,inferredMime:ut,isBinary:Et}=await Den(De),xt=Jt.byteLength;if(xt>dq)return Mp(i,`File too large for simple upload (${xt} bytes).`);const Er=await wt("POST","/upload/drive/v3/files",{params:{uploadType:"media",supportsAllDrives:"true",fields:zb},body:Jt,contentType:Je||ut||(Et?"application/octet-stream":"text/plain; charset=UTF-8")});if(Er.status!==200&&Er.status!==201)return Mp(i,`Drive media upload failed (status=${Er.status})`);let Ms=Er.data;const Es=(Ce=Er.data)==null?void 0:Ce.id;return Es&&(qe||Ue||rt)&&(Ms=await Oen(wt,Es,Ue,rt,qe)),LV({file:Ms})}catch(Ne){const De=((Oe=Ne.response)==null?void 0:Oe.data)||Ne.message||Ne;return oe.Logger.error("[Google Drive] Upload document failed:",De),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:De,result:null}}}})}}function LV(l){return{value:j.Success,error:null,result:l}}function Mp(l,u){return oe.Logger.log("[Google Drive] Upload error:",u),{value:l.catchesError||l.errorCalls.length?j.CaughtError:j.UnhandledError,error:u,result:null}}async function Oen(l,u,i,n,a){const c={};i&&(c.name=i),typeof n=="string"&&(c.description=n);const e={supportsAllDrives:"true",fields:zb},f={...e};a&&(f.addParents=a,f.removeParents="root");let h=await l("PATCH",`/drive/v3/files/${encodeURIComponent(u)}`,{params:f,body:JSON.stringify(c),contentType:"application/json"});if(h.status>=400&&a&&(h=await l("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}const Pen="id,name,mimeType,webViewLink",xen="X-Elyx-Proxy-Config";function _en(l){return l.startsWith("/")?l.slice(1):l}const GV=(l,u)=>(oe.Logger.log("[Google Drive Clone Document] error:",u),{value:l.catchesError||l.errorCalls.length?j.CaughtError:j.UnhandledError,error:u,result:null});class Tot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleDriveCloneDocument,version:"1.0.0",description:"Google Drive clone document operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleDriveCloneDocument);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I,A,D,V,N,_,L;try{const K=B.operation[me.GoogleDriveCloneDocument],q=((c=(a=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.connection.id}))==null?void 0:a.value)==null?void 0:c.valueAsType)??((f=(e=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.connection.id}))==null?void 0:e.value)==null?void 0:f.value);if(!(q instanceof Na))return GV(i,"Invalid or missing connection entity");const W=(m=(h=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.documentId.id}))==null?void 0:h.value)==null?void 0:m.value;if(!W)return GV(i,"Missing required input: documentId");const H=(g=(T=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.newName.id}))==null?void 0:T.value)==null?void 0:g.value,te=(I=(E=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.parentFolderIds.id}))==null?void 0:E.value)==null?void 0:I.value,ne=(D=(A=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.description.id}))==null?void 0:A.value)==null?void 0:D.value,z=(N=(V=n.find(Oe=>{var Ne,De;return((De=(Ne=Oe.valueOwner)==null?void 0:Ne.declaration)==null?void 0:De.id)===K.inputs.starred.id}))==null?void 0:V.value)==null?void 0:N.value,Q=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],J=fr(q),ee={Authorization:`Bearer ${await Q.getAccessToken()}`},de=`${((_=Q.env)==null?void 0:_.API_BASE_URL)+"/editor-runtime"}/v2/external-integrations/proxy/${Q.projectId}/${vi["google-drive"]}/${J}`,ye=async(Oe,Ne,{params:De,body:Ue,contentType:Je,providerHeaders:qe,responseType:rt}={})=>{const dt=`${de}/${_en(Ne)}`,ze={...ee};return Je&&(ze["Content-Type"]=Je),(qe||rt)&&(ze[xen]=JSON.stringify({...qe?{headers:qe}:{},...rt?{responseType:rt}:{}})),Ii({method:Oe,url:dt,headers:ze,params:De,data:Ue,responseType:rt||"json"})},fe={};H&&(fe.name=H),te&&te.length>0&&(fe.parents=te),ne&&(fe.description=ne),z!==void 0&&(fe.starred=z);const Ce=(await ye("POST",`/v3/files/${W}/copy`,{params:{fields:Pen,supportsAllDrives:!0},body:fe,contentType:"application/json"})).data;return{value:j.Success,error:null,result:{id:Ce.id,name:Ce.name,mimeType:Ce.mimeType,webViewLink:Ce.webViewLink}}}catch(K){const q=((L=K.response)==null?void 0:L.data)||K.message||K;return GV(i,q)}}})}}const Ven="X-Elyx-Proxy-Config";function Nen(l){return l.startsWith("/")?l.slice(1):l}const BV=(l,u)=>(oe.Logger.log("[Google Drive Delete Document] error:",u),{value:l.catchesError||l.errorCalls.length?j.CaughtError:j.UnhandledError,error:u,result:null});class vot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleDriveDeleteDocument,version:"1.0.0",description:"Google Drive delete document operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleDriveDeleteDocument);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I;try{const A=B.operation[me.GoogleDriveDeleteDocument],D=((c=(a=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===A.inputs.connection.id}))==null?void 0:a.value)==null?void 0:c.valueAsType)??((f=(e=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===A.inputs.connection.id}))==null?void 0:e.value)==null?void 0:f.value);if(!(D instanceof Na))return BV(i,"Invalid or missing connection entity");const V=(m=(h=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===A.inputs.documentId.id}))==null?void 0:h.value)==null?void 0:m.value;if(!V)return BV(i,"Missing required input: documentId");const N=(g=(T=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===A.inputs.permanent.id}))==null?void 0:T.value)==null?void 0:g.value,_=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],L=fr(D),q={Authorization:`Bearer ${await _.getAccessToken()}`},W=`${((E=_.env)==null?void 0:E.API_BASE_URL)+"/editor-runtime"}/v2/external-integrations/proxy/${_.projectId}/${vi["google-drive"]}/${L}`,H=async(te,ne,{params:z,body:Q,contentType:J,providerHeaders:ae,responseType:ee}={})=>{const de=`${W}/${Nen(ne)}`,ye={...q};return J&&(ye["Content-Type"]=J),(ae||ee)&&(ye[Ven]=JSON.stringify({...ae?{headers:ae}:{},...ee?{responseType:ee}:{}})),Ii({method:te,url:de,headers:ye,params:z,data:Q,responseType:ee||"json"})};return N?await H("DELETE",`/v3/files/${V}`,{params:{supportsAllDrives:!0}}):await H("PATCH",`/v3/files/${V}`,{params:{supportsAllDrives:!0},body:{trashed:!0},contentType:"application/json"}),{value:j.Success,error:null,result:null}}catch(A){const D=((I=A.response)==null?void 0:I.data)||A.message||A;return BV(i,D)}}})}}class got extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleGeminiGenerateContent,version:"1.0.0",description:"Send Gmail email operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleGeminiGenerateContent);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h;try{const m=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.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?j.CaughtError:j.UnhandledError,error:"No entity template provided",result:null};if(!(T instanceof Na))return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:"Invalid entity template value provided",result:null};const g=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation["external-integration--google-gemini--post--generate-content"].inputs.prompt.id}),E=(c=g==null?void 0:g.value)==null?void 0:c.value;if(!E||typeof E!="string")return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:"Invalid prompt value provided",result:null};const I=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation["external-integration--google-gemini--post--generate-content"].inputs.model.id}),A=(e=I==null?void 0:I.value)==null?void 0:e.value;if(!A||typeof A!="string")return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:"Invalid model value provided",result:null};const D=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],V=fr(T);console.log("Triggering Google Gemini generate content action with connectionId:",V);const N=await(await Ii.post(`${(f=D.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/trigger-action/${vi["google-gemini"]}/${V}/generate-content`,{payload:{prompt:E,model:A}},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${await D.getAccessToken()}`}})).data;return oe.Logger.log("[Google Gemini] Generate content action response:",N),{value:j.Success,error:null,result:{content:N.content}}}catch(m){const T=((h=m.response)==null?void 0:h.data)||m.message||m;return oe.Logger.error("[Google Gemini] Generate content failed:",T),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:T,result:null}}}})}}class bot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsCreateSpreadsheet,version:"1.0.0",description:"Create Spreadsheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsCreateSpreadsheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"createSpreadsheet"),E="["+je(i,i.project,"Create spreadsheet")+": `"+T+"`] ",I=(z,Q,J)=>{const ae=je(z==null?void 0:z.valueOwner,m==null?void 0:m.logic,Q),ee=Xe(z==null?void 0:z.valueOwner,m==null?void 0:m.logic,J);return`"${ae}" (\`${ee}\`)`},A=n.find(z=>{var Q;return((Q=z.valueOwner.declaration)==null?void 0:Q.id)===B.operation[me.GoogleSheetsCreateSpreadsheet].inputs.connection.id}),D=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!D||!D.id||!D.name||D.type!==r.DefinitionEntity)throw new Error(`${E}The ${I(A,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const V=fr(D);if(!V)throw new Error(`${E}The ${I(A,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const N=n.find(z=>{var Q;return((Q=z.valueOwner.declaration)==null?void 0:Q.id)===B.operation[me.GoogleSheetsCreateSpreadsheet].inputs.title.id}),_=(c=N==null?void 0:N.value)==null?void 0:c.value;if(_&&typeof _!="string")throw new Error(`${E}The ${I(N,"Title","title")} input value is invalid. If present, it must be a non-empty string. E.g. "My Spreadsheet"`);const K={Authorization:`Bearer ${await m.getAccessToken()}`},q=`${(e=m.env)==null?void 0:e.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${m.projectId}/${vi["google-sheet"]}/${V}`,W=async z=>Ii.post(q,z,{headers:K}),H={};_&&(H.properties={title:_});const ne=((f=(await W({method:"POST",endpoint:"/v4/spreadsheets",data:H})).data)==null?void 0:f.data)||{};return{value:j.Success,error:null,result:{spreadsheetId:ne.spreadsheetId,spreadsheetUrl:ne.spreadsheetUrl}}}catch(m){const T=((h=m.response)==null?void 0:h.data)||m.message||m;return oe.Logger.log("[Google Sheets] error:",T),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:T,result:null}}}})}}class Eot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsGetSpreadsheet,version:"1.0.0",description:"Get Spreadsheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsGetSpreadsheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"getSpreadsheet"),I="["+je(i,i.project,"Get spreadsheet")+": `"+g+"`] ",A=(z,Q,J)=>{const ae=je(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,Q),ee=Xe(z==null?void 0:z.valueOwner,T==null?void 0:T.logic,J);return`"${ae}" (\`${ee}\`)`},D=n.find(z=>{var Q;return((Q=z.valueOwner.declaration)==null?void 0:Q.id)===B.operation[me.GoogleSheetsGetSpreadsheet].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(z=>{var Q;return((Q=z.valueOwner.declaration)==null?void 0:Q.id)===B.operation[me.GoogleSheetsGetSpreadsheet].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q={Authorization:`Bearer ${await T.getAccessToken()}`},W=`${(e=T.env)==null?void 0:e.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=((f=(await(async z=>Ii.post(W,z,{headers:q}))({method:"GET",endpoint:`/v4/spreadsheets/${L}`})).data)==null?void 0:f.data)||{};return{value:j.Success,error:null,result:{title:(h=ne.properties)==null?void 0:h.title,spreadsheetUrl:ne.spreadsheetUrl}}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class Aot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsAddSheet,version:"1.0.0",description:"Add Sheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsAddSheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I;try{const A=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!A||!A.env)throw new Error("Editor context or environment missing");const D=Xe(i,i.project,"addSheet"),N="["+je(i,i.project,"Add sheet")+": `"+D+"`] ",_=(fe,ve,Ce)=>{const Oe=je(fe==null?void 0:fe.valueOwner,A==null?void 0:A.logic,ve),Ne=Xe(fe==null?void 0:fe.valueOwner,A==null?void 0:A.logic,Ce);return`"${Oe}" (\`${Ne}\`)`},L=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAddSheet].inputs.connection.id}),K=(a=L==null?void 0:L.value)==null?void 0:a.valueAsType;if(!K||!K.id||!K.name||K.type!==r.DefinitionEntity)throw new Error(`${N}The ${_(L,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const q=fr(K);if(!q)throw new Error(`${N}The ${_(L,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const W=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAddSheet].inputs.spreadsheetId.id}),H=(c=W==null?void 0:W.value)==null?void 0:c.value;if(!H||H==="")throw new Error(`${N}The ${_(W,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof H!="string")throw new Error(`${N}The ${_(W,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const te=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAddSheet].inputs.title.id}),ne=(e=te==null?void 0:te.value)==null?void 0:e.value;if(ne!=null&&typeof ne!="string")throw new Error(`${N}The ${_(te,"Title","title")} input value is invalid. If present, it must be a string. E.g. "New Sheet"`);const Q={Authorization:`Bearer ${await A.getAccessToken()}`},J=`${(f=A.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${A.projectId}/${vi["google-sheet"]}/${q}`,ye=(E=(g=(T=(m=(((h=(await(async fe=>Ii.post(J,fe,{headers:Q}))({method:"POST",endpoint:`/v4/spreadsheets/${H}:batchUpdate`,data:{requests:[{addSheet:{properties:{title:ne}}}]}})).data)==null?void 0:h.data)||{}).replies)==null?void 0:m[0])==null?void 0:T.addSheet)==null?void 0:g.properties)==null?void 0:E.sheetId;return{value:j.Success,error:null,result:{sheetId:ye}}}catch(A){const D=((I=A.response)==null?void 0:I.data)||A.message||A;return oe.Logger.log("[Google Sheets] error:",D),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:D,result:null}}}})}}class Iot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsDeleteSheet,version:"1.0.0",description:"Delete Sheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsDeleteSheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"deleteSheet"),E="["+je(i,i.project,"Delete sheet")+": `"+T+"`] ",I=(ne,z,Q)=>{const J=je(ne==null?void 0:ne.valueOwner,m==null?void 0:m.logic,z),ae=Xe(ne==null?void 0:ne.valueOwner,m==null?void 0:m.logic,Q);return`"${J}" (\`${ae}\`)`},A=n.find(ne=>{var z;return((z=ne.valueOwner.declaration)==null?void 0:z.id)===B.operation[me.GoogleSheetsDeleteSheet].inputs.connection.id}),D=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!D||!D.id||!D.name||D.type!==r.DefinitionEntity)throw new Error(`${E}The ${I(A,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const V=fr(D);if(!V)throw new Error(`${E}The ${I(A,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const N=n.find(ne=>{var z;return((z=ne.valueOwner.declaration)==null?void 0:z.id)===B.operation[me.GoogleSheetsDeleteSheet].inputs.spreadsheetId.id}),_=(c=N==null?void 0:N.value)==null?void 0:c.value;if(!_||_==="")throw new Error(`${E}The ${I(N,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof _!="string")throw new Error(`${E}The ${I(N,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const L=n.find(ne=>{var z;return((z=ne.valueOwner.declaration)==null?void 0:z.id)===B.operation[me.GoogleSheetsDeleteSheet].inputs.sheetId.id}),K=(e=L==null?void 0:L.value)==null?void 0:e.value;if(K==null)throw new Error(`${E}The ${I(L,"Sheet ID","sheetId")} input is missing.`);if(typeof K!="number")throw new Error(`${E}The ${I(L,"Sheet ID","sheetId")} input value is invalid. It must be a number. E.g. 0`);const W={Authorization:`Bearer ${await m.getAccessToken()}`},H=`${(f=m.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${m.projectId}/${vi["google-sheet"]}/${V}`;return await(async ne=>Ii.post(H,ne,{headers:W}))({method:"POST",endpoint:`/v4/spreadsheets/${_}:batchUpdate`,data:{requests:[{deleteSheet:{sheetId:K}}]}}),{value:j.Success,error:null,result:{success:!0}}}catch(m){const T=((h=m.response)==null?void 0:h.data)||m.message||m;return oe.Logger.log("[Google Sheets] error:",T),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:T,result:null}}}})}}function PN(l){let u="",i=l;for(;i>0;){const n=(i-1)%26;u=String.fromCharCode(65+n)+u,i=Math.floor((i-n)/26)}return u}function yO(l){if(!/^[A-Z]+$/.test(l))return NaN;let u=0;for(let i=0;i<l.length;i++)u=u*26+(l.charCodeAt(i)-64);return u}function AE(l,u){const i=(u==null?void 0:u.errorPrefix)||"";if(typeof l!="string")throw new Error(`${i}Input must be a string.`);let n,a=l;if(l.includes("!")){const I=l.split("!");let A=I.slice(0,-1).join("!");a=I[I.length-1],A.startsWith("'")&&A.endsWith("'")&&(A=A.slice(1,-1)),n=A}const c=/^(\$?[A-Z]+)?(\$?\d+)?(?::(\$?[A-Z]+)?(\$?\d+)?)?$/i,e=a.match(c);if(!e)throw new Error(`${i}Invalid A1 notation format: ${l}`);const[f,h,m,T,g]=e,E={sheet:n};return h&&(E.startColumn=h.toUpperCase()),m&&(E.startRow=m),T&&(E.endColumn=T.toUpperCase()),g&&(E.endRow=g),E}function PB(l,u){const i=u!=null&&u.errorPrefix?u.errorPrefix:"",n=T=>{if(typeof T=="string"){const g=T.replace("$","");return/^\d+$/.test(g)?parseInt(g,10):NaN}return T},a=T=>{if(typeof T=="string"){const g=T.replace("$","").toUpperCase();return/^\d+$/.test(g)?parseInt(g,10):yO(g)}return T},c=n(l.startRow),e=n(l.endRow),f=a(l.startColumn),h=a(l.endColumn),m=T=>typeof T=="string"&&T.includes("{{")&&T.includes("}}");if(l.startRow!==void 0&&l.startRow!==null&&l.startRow!==""&&isNaN(c)&&!m(l.startRow))throw new Error(`${i}Start Row is invalid.`);if(l.endRow!==void 0&&l.endRow!==null&&l.endRow!==""&&isNaN(e)&&!m(l.endRow))throw new Error(`${i}End Row is invalid.`);if(l.startColumn!==void 0&&l.startColumn!==null&&l.startColumn!==""&&isNaN(f)&&!m(l.startColumn))throw new Error(`${i}Start Column is invalid.`);if(l.endColumn!==void 0&&l.endColumn!==null&&l.endColumn!==""&&isNaN(h)&&!m(l.endColumn))throw new Error(`${i}End Column is invalid.`);if(c!=null&&!isNaN(c)&&c<1)throw new Error(`${i}Start Row must be greater than or equal to 1.`);if(e!=null&&!isNaN(e)&&e<1)throw new Error(`${i}End Row must be greater than or equal to 1.`);if(f!=null&&!isNaN(f)&&f<1)throw new Error(`${i}Start Column must be greater than or equal to 1.`);if(h!=null&&!isNaN(h)&&h<1)throw new Error(`${i}End Column must be greater than or equal to 1.`);if(c!=null&&!isNaN(c)&&e!==void 0&&e!==null&&!isNaN(e)&&c>e)throw new Error(`${i}Start Row must be less than or equal to End Row.`);if(f!=null&&!isNaN(f)&&h!==void 0&&h!==null&&!isNaN(h)&&f>h)throw new Error(`${i}Start Column must be less than or equal to End Column.`);if(typeof l.sheet=="number"&&l.sheet<0)throw new Error(`${i}Sheet ID must be greater than or equal to 0.`)}async function Ld(l,u,i){if(!l)return;let n=l;if(typeof l=="string"){const e=l.trim();if(e.startsWith("{"))try{n=new Function("return "+e)()}catch{try{n=JSON.parse(e)}catch{}}else try{n=AE(e,{errorPrefix:"Internal"})}catch{}}if(n.sheet===void 0||n.sheet===null||n.sheet==="")return;const a=typeof n.sheet=="string",c=typeof n.sheet=="number";if(!(u==="Name"&&a)&&!(u==="Id"&&c))try{const e=await i();for(const f of e){const h=f.id,m=f.name;if(a&&m===n.sheet){n._resolvedSheetId=h,n._resolvedSheetName=m;return}if(c&&h===n.sheet){n._resolvedSheetId=h,n._resolvedSheetName=m;return}}}catch{}}function Sv(l,u){if(!l)return"";if(typeof l=="string")return l;let i=l;if(typeof l=="string"&&l.trim().startsWith("{"))try{i=JSON.parse(l)}catch{}if(PB(i,u),i.namedRange&&i.namedRange.trim()!=="")return i.namedRange;const n=i._resolvedSheetName!==void 0?i._resolvedSheetName:typeof i.sheet=="string"?i.sheet:void 0,a=n?`'${n}'!`:"",c=E=>{if(typeof E=="number")return PN(E);if(typeof E=="string"){const I=E.replace("$","");if(/^\d+$/.test(I))return(E.startsWith("$")?"$":"")+PN(parseInt(I,10))}return E||""},e=c(i.startColumn),f=typeof i.startRow=="number"?i.startRow.toString():i.startRow||"",h=c(i.endColumn),m=typeof i.endRow=="number"?i.endRow.toString():i.endRow||"",T=`${e}${f}`,g=`${h}${m}`;return T&&g?`${a}${T}:${g}`:T?`${a}${T}`:a.replace(/!$/,"")}function $f(l,u){if(!l)return{};let i=l;if(typeof l=="string"){const g=l.trim();if(g.startsWith("{"))try{i=new Function("return "+g)()}catch{try{i=JSON.parse(g)}catch{}}else try{i=AE(g,u)}catch{}}PB(i,u);const n={},a=i._resolvedSheetId!==void 0?i._resolvedSheetId:typeof i.sheet=="number"?i.sheet:void 0;a!=null&&(n.sheetId=a);const c=g=>{if(typeof g=="string"){const E=g.replace("$","");return/^\d+$/.test(E)?parseInt(E,10):NaN}return g},e=g=>{if(typeof g=="string"){const E=g.replace("$","").toUpperCase();return/^\d+$/.test(E)?parseInt(E,10):yO(E)}return g},f=c(i.startRow),h=c(i.endRow),m=e(i.startColumn),T=e(i.endColumn);return f!=null&&(n.startRowIndex=f-1),h!=null&&(n.endRowIndex=h),m!=null&&(n.startColumnIndex=m-1),T!=null&&(n.endColumnIndex=T),n}function Rot(l,u){if(!l)return{};let i=l;if(typeof l=="string")if(l.trim().startsWith("{"))try{i=JSON.parse(l)}catch{i=AE(l,{errorPrefix:"Internal"})}else i=AE(l,{errorPrefix:"Internal"});PB(i,u);const n={},a=i._resolvedSheetId!==void 0?i._resolvedSheetId:typeof i.sheet=="number"?i.sheet:void 0;a!=null&&(n.sheetId=a);const c=g=>{if(typeof g=="string"){const E=g.replace("$","");return/^\d+$/.test(E)?parseInt(E,10):NaN}return g},e=g=>{if(typeof g=="string"){const E=g.replace("$","").toUpperCase();return/^\d+$/.test(E)?parseInt(E,10):yO(E)}return g},f=c(i.startRow),h=c(i.endRow),m=e(i.startColumn),T=e(i.endColumn);return f!=null?(n.dimension="ROWS",n.startIndex=f-1,h!=null?n.endIndex=h:n.endIndex=f):m!=null&&(n.dimension="COLUMNS",n.startIndex=m-1,T!=null?n.endIndex=T:n.endIndex=m),n}class Dot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsAppendRows,version:"1.0.0",description:"Append Row(s) Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsAppendRows);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g;try{const E=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!E||!E.env)throw new Error("Editor context or environment missing");const I=Xe(i,i.project,"appendRows"),D="["+je(i,i.project,"Append rows")+": `"+I+"`] ",V=(fe,ve,Ce)=>{const Oe=je(fe==null?void 0:fe.valueOwner,E==null?void 0:E.logic,ve),Ne=Xe(fe==null?void 0:fe.valueOwner,E==null?void 0:E.logic,Ce);return`"${Oe}" (\`${Ne}\`)`},N=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAppendRows].inputs.connection.id}),_=(a=N==null?void 0:N.value)==null?void 0:a.valueAsType;if(!_||!_.id||!_.name||_.type!==r.DefinitionEntity)throw new Error(`${D}The ${V(N,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const L=fr(_);if(!L)throw new Error(`${D}The ${V(N,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const K=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAppendRows].inputs.spreadsheetId.id}),q=(c=K==null?void 0:K.value)==null?void 0:c.value;if(!q||q==="")throw new Error(`${D}The ${V(K,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof q!="string")throw new Error(`${D}The ${V(K,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const W=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAppendRows].inputs.range.id}),H=(e=W==null?void 0:W.value)==null?void 0:e.value;if(!H||H==="")throw new Error(`${D}The ${V(W,"Range","range")} input is missing.`);const te=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsAppendRows].inputs.values.id}),ne=(f=te==null?void 0:te.value)==null?void 0:f.value;if(ne==null)throw new Error(`${D}The ${V(te,"Values","values")} input is missing.`);const Q={Authorization:`Bearer ${await E.getAccessToken()}`},J=`${(h=E.env)==null?void 0:h.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${E.projectId}/${vi["google-sheet"]}/${L}`,ae=async fe=>Ii.post(J,fe,{headers:Q});let ee=ne;if(typeof ne=="string")try{ee=JSON.parse(ne)}catch{}await Ld(H,"Name",async()=>{var ve;return(((ve=(await ae({method:"GET",endpoint:`/v4/spreadsheets/${q}?fields=sheets.properties(sheetId,title)`})).data)==null?void 0:ve.sheets)||[]).map(Ce=>{var Oe,Ne;return{id:(Oe=Ce.properties)==null?void 0:Oe.sheetId,name:(Ne=Ce.properties)==null?void 0:Ne.title}})});const ye=((m=(await ae({method:"POST",endpoint:`/v4/spreadsheets/${q}/values/${Sv(H,{errorPrefix:`${D}The ${V(W,"Range","range")} input `})}:append`,params:{valueInputOption:"USER_ENTERED"},data:{values:Array.isArray(ee)?ee:[ee]}})).data)==null?void 0:m.data)||{};return{value:j.Success,error:null,result:{updatedRange:(T=ye.updates)==null?void 0:T.updatedRange}}}catch(E){const I=((g=E.response)==null?void 0:g.data)||E.message||E;return oe.Logger.log("[Google Sheets] error:",I),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:I,result:null}}}})}}class Cot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsGetRangeValues,version:"1.0.0",description:"Get Range Values Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsGetRangeValues);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"getRangeValues"),I="["+je(i,i.project,"Get range values")+": `"+g+"`] ",A=(J,ae,ee)=>{const de=je(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ae),ye=Xe(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ee);return`"${de}" (\`${ye}\`)`},D=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsGetRangeValues].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsGetRangeValues].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsGetRangeValues].inputs.range.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(!q||q==="")throw new Error(`${I}The ${A(K,"Range","range")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async J=>Ii.post(te,J,{headers:H});await Ld(q,"Name",async()=>{var ae;return(((ae=(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data)==null?void 0:ae.sheets)||[]).map(ee=>{var de,ye;return{id:(de=ee.properties)==null?void 0:de.sheetId,name:(ye=ee.properties)==null?void 0:ye.title}})});const Q=((h=(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}/values/${Sv(q,{errorPrefix:`${I}The ${A(K,"Range","range")} input `})}`})).data)==null?void 0:h.data)||{};return{value:j.Success,error:null,result:{values:Q.values}}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class wot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsUpdateRangeValues,version:"1.0.0",description:"Update Range Values Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsUpdateRangeValues);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"updateRangeValues"),A="["+je(i,i.project,"Update range values")+": `"+E+"`] ",D=(ye,fe,ve)=>{const Ce=je(ye==null?void 0:ye.valueOwner,g==null?void 0:g.logic,fe),Oe=Xe(ye==null?void 0:ye.valueOwner,g==null?void 0:g.logic,ve);return`"${Ce}" (\`${Oe}\`)`},V=n.find(ye=>{var fe;return((fe=ye.valueOwner.declaration)==null?void 0:fe.id)===B.operation[me.GoogleSheetsUpdateRangeValues].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(ye=>{var fe;return((fe=ye.valueOwner.declaration)==null?void 0:fe.id)===B.operation[me.GoogleSheetsUpdateRangeValues].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(ye=>{var fe;return((fe=ye.valueOwner.declaration)==null?void 0:fe.id)===B.operation[me.GoogleSheetsUpdateRangeValues].inputs.range.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(!W||W==="")throw new Error(`${A}The ${D(q,"Range","range")} input is missing.`);const H=n.find(ye=>{var fe;return((fe=ye.valueOwner.declaration)==null?void 0:fe.id)===B.operation[me.GoogleSheetsUpdateRangeValues].inputs.values.id}),te=(f=H==null?void 0:H.value)==null?void 0:f.value;if(te==null)throw new Error(`${A}The ${D(H,"Values","values")} input is missing.`);const z={Authorization:`Bearer ${await g.getAccessToken()}`},Q=`${(h=g.env)==null?void 0:h.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,J=async ye=>Ii.post(Q,ye,{headers:z});let ae=te;if(typeof te=="string")try{ae=JSON.parse(te)}catch{}await Ld(W,"Name",async()=>{var fe;return(((fe=(await J({method:"GET",endpoint:`/v4/spreadsheets/${K}?fields=sheets.properties(sheetId,title)`})).data)==null?void 0:fe.sheets)||[]).map(ve=>{var Ce,Oe;return{id:(Ce=ve.properties)==null?void 0:Ce.sheetId,name:(Oe=ve.properties)==null?void 0:Oe.title}})});const de=((m=(await J({method:"PUT",endpoint:`/v4/spreadsheets/${K}/values/${Sv(W,{errorPrefix:`${A}The ${D(q,"Range","range")} input `})}`,params:{valueInputOption:"USER_ENTERED"},data:{values:Array.isArray(ae)?ae:[ae]}})).data)==null?void 0:m.data)||{};return{value:j.Success,error:null,result:{updatedRange:de.updatedRange}}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Oot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsClearRange,version:"1.0.0",description:"Clear Range Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsClearRange);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"clearRange"),I="["+je(i,i.project,"Clear range")+": `"+g+"`] ",A=(J,ae,ee)=>{const de=je(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ae),ye=Xe(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ee);return`"${de}" (\`${ye}\`)`},D=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearRange].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearRange].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearRange].inputs.range.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(!q||q==="")throw new Error(`${I}The ${A(K,"Range","range")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async J=>Ii.post(te,J,{headers:H});await Ld(q,"Name",async()=>{var ae;return(((ae=(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data)==null?void 0:ae.sheets)||[]).map(ee=>{var de,ye;return{id:(de=ee.properties)==null?void 0:de.sheetId,name:(ye=ee.properties)==null?void 0:ye.title}})});const Q=((h=(await ne({method:"POST",endpoint:`/v4/spreadsheets/${L}/values/${Sv(q,{errorPrefix:`${I}The ${A(K,"Range","range")} input `})}:clear`,data:{}})).data)==null?void 0:h.data)||{};return{value:j.Success,error:null,result:{clearedRange:Q.clearedRange}}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class Pot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsBatchUpdateSpreadsheet,version:"1.0.0",description:"Batch Update Spreadsheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsBatchUpdateSpreadsheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"batchUpdateSpreadsheet"),I="["+je(i,i.project,"Batch update spreadsheet")+": `"+g+"`] ",A=(ae,ee,de)=>{const ye=je(ae==null?void 0:ae.valueOwner,T==null?void 0:T.logic,ee),fe=Xe(ae==null?void 0:ae.valueOwner,T==null?void 0:T.logic,de);return`"${ye}" (\`${fe}\`)`},D=n.find(ae=>{var ee;return((ee=ae.valueOwner.declaration)==null?void 0:ee.id)===B.operation[me.GoogleSheetsBatchUpdateSpreadsheet].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(ae=>{var ee;return((ee=ae.valueOwner.declaration)==null?void 0:ee.id)===B.operation[me.GoogleSheetsBatchUpdateSpreadsheet].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(ae=>{var ee;return((ee=ae.valueOwner.declaration)==null?void 0:ee.id)===B.operation[me.GoogleSheetsBatchUpdateSpreadsheet].inputs.requests.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null||q==="")throw new Error(`${I}The ${A(K,"Requests","requests")} input is missing.`);let W=q;if(typeof q=="string")try{W=JSON.parse(q)}catch{}if(Array.isArray(W)||(W=[W]),W.length===0)throw new Error(`${I}The ${A(K,"Requests","requests")} input evaluated to an empty array. E.g. [{ addSheet: { properties: { title: "New Sheet" } } }]`);const te={Authorization:`Bearer ${await T.getAccessToken()}`},ne=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,Q=await(async ae=>Ii.post(ne,ae,{headers:te}))({method:"POST",endpoint:`/v4/spreadsheets/${L}:batchUpdate`,data:{requests:W}}),J=((h=Q.data)==null?void 0:h.data)||Q.data||{};return{value:j.Success,result:{replies:J.replies||[]},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class xot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsRenameSheet,version:"1.0.0",description:"Rename or Update Sheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsRenameSheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"renameSheet"),I="["+je(i,i.project,"Rename sheet")+": `"+g+"`] ",A=(ee,de,ye)=>{const fe=je(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,de),ve=Xe(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,ye);return`"${fe}" (\`${ve}\`)`},D=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsRenameSheet].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsRenameSheet].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsRenameSheet].inputs.sheetId.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null)throw new Error(`${I}The ${A(K,"Sheet ID","sheetId")} input is missing.`);if(typeof q!="number")throw new Error(`${I}The ${A(K,"Sheet ID","sheetId")} input value is invalid. It must be a number. E.g. 0`);const W=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsRenameSheet].inputs.title.id}),H=(f=W==null?void 0:W.value)==null?void 0:f.value;if(H!=null&&typeof H!="string")throw new Error(`${I}The ${A(W,"Title","title")} input value is invalid, if present, it must be a string.`);const ne={Authorization:`Bearer ${await T.getAccessToken()}`},z=`${(h=T.env)==null?void 0:h.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,Q=async ee=>Ii.post(z,ee,{headers:ne}),J={sheetId:q},ae=[];return H&&(J.title=H,ae.push("title")),await Q({method:"POST",endpoint:`/v4/spreadsheets/${L}:batchUpdate`,data:{requests:[{updateSheetProperties:{properties:J,fields:ae.join(",")}}]}}),{value:j.Success,result:{success:!0},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class _ot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsCopySheet,version:"1.0.0",description:"Copy Sheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsCopySheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"copySheet"),A="["+je(i,i.project,"Copy sheet")+": `"+E+"`] ",D=(de,ye,fe)=>{const ve=je(de==null?void 0:de.valueOwner,g==null?void 0:g.logic,ye),Ce=Xe(de==null?void 0:de.valueOwner,g==null?void 0:g.logic,fe);return`"${ve}" (\`${Ce}\`)`},V=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsCopySheet].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsCopySheet].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsCopySheet].inputs.sheetId.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(W==null)throw new Error(`${A}The ${D(q,"Sheet ID","sheetId")} input is missing.`);if(typeof W!="number")throw new Error(`${A}The ${D(q,"Sheet ID","sheetId")} input value is invalid. It must be a number. E.g. 0`);const H=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsCopySheet].inputs.destinationSpreadsheetId.id}),te=(f=H==null?void 0:H.value)==null?void 0:f.value;if(!te||te==="")throw new Error(`${A}The ${D(H,"Destination Spreadsheet ID","destinationSpreadsheetId")} input is missing.`);if(typeof te!="string")throw new Error(`${A}The ${D(H,"Destination Spreadsheet ID","destinationSpreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const z={Authorization:`Bearer ${await g.getAccessToken()}`},Q=`${(h=g.env)==null?void 0:h.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,ae=await(async de=>Ii.post(Q,de,{headers:z}))({method:"POST",endpoint:`/v4/spreadsheets/${K}/sheets/${W}:copyTo`,data:{destinationSpreadsheetId:te}}),ee=((m=ae.data)==null?void 0:m.data)||ae.data||{};return{value:j.Success,result:{newSheetId:ee.sheetId},error:null}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Vot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsClearSheet,version:"1.0.0",description:"Clear Sheet Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsClearSheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"clearSheet"),I="["+je(i,i.project,"Clear sheet")+": `"+g+"`] ",A=(J,ae,ee)=>{const de=je(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ae),ye=Xe(J==null?void 0:J.valueOwner,T==null?void 0:T.logic,ee);return`"${de}" (\`${ye}\`)`},D=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearSheet].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearSheet].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(J=>{var ae;return((ae=J.valueOwner.declaration)==null?void 0:ae.id)===B.operation[me.GoogleSheetsClearSheet].inputs.sheetName.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(!q||q==="")throw new Error(`${I}The ${A(K,"Sheet Name","sheetName")} input is missing.`);if(typeof q!="string")throw new Error(`${I}The ${A(K,"Sheet Name","sheetName")} input value is invalid. It must be a non-empty string. E.g. "Sheet1"`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,z=await(async J=>Ii.post(te,J,{headers:H}))({method:"POST",endpoint:`/v4/spreadsheets/${L}/values/${q}:clear`,data:{}}),Q=((h=z.data)==null?void 0:h.data)||z.data||{};return{value:j.Success,result:{clearedRange:Q.clearedRange},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class Not extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsBatchGetValues,version:"1.0.0",description:"Batch Get Values Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsBatchGetValues);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"batchGetValues"),I="["+je(i,i.project,"Batch get values")+": `"+g+"`] ",A=(ee,de,ye)=>{const fe=je(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,de),ve=Xe(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,ye);return`"${fe}" (\`${ve}\`)`},D=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsBatchGetValues].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsBatchGetValues].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsBatchGetValues].inputs.ranges.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null||q==="")throw new Error(`${I}The ${A(K,"Ranges","ranges")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async ee=>Ii.post(te,ee,{headers:H});let z=Array.isArray(q)?q:[q];if(z.length===0)throw new Error(`${I}The ${A(K,"Ranges","ranges")} input evaluated to an empty array. E.g. ["Sheet1!A1:B2"]`);for(const ee of z)await Ld(ee,"Name",async()=>{var ye;return(((ye=(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data)==null?void 0:ye.sheets)||[]).map(fe=>{var ve,Ce;return{id:(ve=fe.properties)==null?void 0:ve.sheetId,name:(Ce=fe.properties)==null?void 0:Ce.title}})});let Q=z.map(ee=>`ranges=${encodeURIComponent(Sv(ee,{errorPrefix:`${I}The ${A(K,"Ranges","ranges")} input `}))}`).join("&");const J=await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}/values:batchGet?${Q}`}),ae=((h=J.data)==null?void 0:h.data)||J.data||{};return{value:j.Success,result:{valueRanges:ae.valueRanges||[]},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class $ot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsFormatCells,version:"1.0.0",description:"Format Cells Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsFormatCells);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"formatCells"),A="["+je(i,i.project,"Format cells")+": `"+E+"`] ",D=(fe,ve,Ce)=>{const Oe=je(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,ve),Ne=Xe(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,Ce);return`"${Oe}" (\`${Ne}\`)`},V=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsFormatCells].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsFormatCells].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsFormatCells].inputs.range.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(W==null)throw new Error(`${A}The ${D(q,"Range","range")} input is missing.`);const te={Authorization:`Bearer ${await g.getAccessToken()}`},ne=`${(f=g.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,z=async fe=>Ii.post(ne,fe,{headers:te});await Ld(W,"Id",async()=>(await z({method:"GET",endpoint:`/v4/spreadsheets/${K}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(ve=>({id:ve.properties.sheetId,name:ve.properties.title})));const Q=$f(W,{errorPrefix:`${A}The ${D(q,"Range","range")} input `}),J=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsFormatCells].inputs.bold.id}),ae=!!((h=J==null?void 0:J.value)!=null&&h.value),ee=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsFormatCells].inputs.italic.id}),de=!!((m=ee==null?void 0:ee.value)!=null&&m.value),ye={repeatCell:{range:Q,cell:{userEnteredFormat:{textFormat:{bold:ae,italic:de}}},fields:"userEnteredFormat.textFormat(bold,italic)"}};return await z({method:"POST",endpoint:`/v4/spreadsheets/${K}:batchUpdate`,data:{requests:[ye]}}),{value:j.Success,result:{success:!0},error:null}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Lot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsSetNumberFormat,version:"1.0.0",description:"Set Number Format Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsSetNumberFormat);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"setNumberFormat"),I="["+je(i,i.project,"Set number format")+": `"+g+"`] ",A=(ee,de,ye)=>{const fe=je(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,de),ve=Xe(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,ye);return`"${fe}" (\`${ve}\`)`},D=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetNumberFormat].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetNumberFormat].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetNumberFormat].inputs.range.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null)throw new Error(`${I}The ${A(K,"Range","range")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async ee=>Ii.post(te,ee,{headers:H});await Ld(q,"Id",async()=>(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(de=>({id:de.properties.sheetId,name:de.properties.title})));const z=$f(q,{errorPrefix:`${I}The ${A(K,"Range","range")} input `}),Q=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetNumberFormat].inputs.pattern.id}),J=(h=Q==null?void 0:Q.value)==null?void 0:h.value;if(J==null||J==="")throw new Error(`${I}The ${A(Q,"Pattern","pattern")} input is missing.`);if(typeof J!="string")throw new Error(`${I}The ${A(Q,"Pattern","pattern")} input value is invalid. It must be a string.`);const ae={repeatCell:{range:z,cell:{userEnteredFormat:{numberFormat:{type:"CUSTOM",pattern:J}}},fields:"userEnteredFormat.numberFormat"}};return await ne({method:"POST",endpoint:`/v4/spreadsheets/${L}:batchUpdate`,data:{requests:[ae]}}),{value:j.Success,result:{success:!0},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class Got extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsSetBackgroundColor,version:"1.0.0",description:"Set Background Color Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsSetBackgroundColor);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"setBackgroundColor"),I="["+je(i,i.project,"Set background color")+": `"+g+"`] ",A=(ee,de,ye)=>{const fe=je(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,de),ve=Xe(ee==null?void 0:ee.valueOwner,T==null?void 0:T.logic,ye);return`"${fe}" (\`${ve}\`)`},D=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetBackgroundColor].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetBackgroundColor].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetBackgroundColor].inputs.range.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null)throw new Error(`${I}The ${A(K,"Range","range")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async ee=>Ii.post(te,ee,{headers:H});await Ld(q,"Id",async()=>(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(de=>({id:de.properties.sheetId,name:de.properties.title})));const z=$f(q,{errorPrefix:`${I}The ${A(K,"Range","range")} input `}),Q=n.find(ee=>{var de;return((de=ee.valueOwner.declaration)==null?void 0:de.id)===B.operation[me.GoogleSheetsSetBackgroundColor].inputs.color.id}),J=(h=Q==null?void 0:Q.value)==null?void 0:h.value;if(J==null)throw new Error(`${I}The ${A(Q,"Color","color")} input is missing.`);if(typeof J!="object")throw new Error(`${I}The ${A(Q,"Color","color")} input value is invalid. It must be a valid color object.`);const ae={repeatCell:{range:z,cell:{userEnteredFormat:{backgroundColor:{red:J.red!==void 0?J.red/255:void 0,green:J.green!==void 0?J.green/255:void 0,blue:J.blue!==void 0?J.blue/255:void 0,alpha:J.alpha!==void 0?J.alpha:void 0}}},fields:"userEnteredFormat.backgroundColor"}};return await ne({method:"POST",endpoint:`/v4/spreadsheets/${L}:batchUpdate`,data:{requests:[ae]}}),{value:j.Success,result:{success:!0},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class Bot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsMergeUnmergeCells,version:"1.0.0",description:"Merge or Unmerge Cells Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsMergeUnmergeCells);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"mergeUnmergeCells"),A="["+je(i,i.project,"Merge/Unmerge cells")+": `"+E+"`] ",D=(fe,ve,Ce)=>{const Oe=je(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,ve),Ne=Xe(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,Ce);return`"${Oe}" (\`${Ne}\`)`},V=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsMergeUnmergeCells].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsMergeUnmergeCells].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsMergeUnmergeCells].inputs.range.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(W==null)throw new Error(`${A}The ${D(q,"Range","range")} input is missing.`);const te={Authorization:`Bearer ${await g.getAccessToken()}`},ne=`${(f=g.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,z=async fe=>Ii.post(ne,fe,{headers:te});await Ld(W,"Id",async()=>(await z({method:"GET",endpoint:`/v4/spreadsheets/${K}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(ve=>({id:ve.properties.sheetId,name:ve.properties.title})));const Q=$f(W,{errorPrefix:`${A}The ${D(q,"Range","range")} input `}),J=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsMergeUnmergeCells].inputs.merge.id}),ae=!!((h=J==null?void 0:J.value)!=null&&h.value),ee=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsMergeUnmergeCells].inputs.mergeType.id}),de=(m=ee==null?void 0:ee.value)==null?void 0:m.value;if(de!=null&&typeof de!="string")throw new Error(`${A}The ${D(ee,"Merge Type","mergeType")} input value is invalid, if present, it must be a string.`);const ye=ae?{mergeCells:{range:Q,mergeType:de||"MERGE_ALL"}}:{unmergeCells:{range:Q}};return await z({method:"POST",endpoint:`/v4/spreadsheets/${K}:batchUpdate`,data:{requests:[ye]}}),{value:j.Success,result:{success:!0},error:null}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Mot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsAutoResizeDimensions,version:"1.0.0",description:"Auto-Resize Dimensions Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsAutoResizeDimensions);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"autoResizeDimensions"),E="["+je(i,i.project,"Auto-resize dimensions")+": `"+T+"`] ",I=(Q,J,ae)=>{const ee=je(Q==null?void 0:Q.valueOwner,m==null?void 0:m.logic,J),de=Xe(Q==null?void 0:Q.valueOwner,m==null?void 0:m.logic,ae);return`"${ee}" (\`${de}\`)`},A=n.find(Q=>{var J;return((J=Q.valueOwner.declaration)==null?void 0:J.id)===B.operation[me.GoogleSheetsAutoResizeDimensions].inputs.connection.id}),D=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!D||!D.id||!D.name||D.type!==r.DefinitionEntity)throw new Error(`${E}The ${I(A,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const V=fr(D);if(!V)throw new Error(`${E}The ${I(A,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const N=n.find(Q=>{var J;return((J=Q.valueOwner.declaration)==null?void 0:J.id)===B.operation[me.GoogleSheetsAutoResizeDimensions].inputs.spreadsheetId.id}),_=(c=N==null?void 0:N.value)==null?void 0:c.value;if(!_||_==="")throw new Error(`${E}The ${I(N,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof _!="string")throw new Error(`${E}The ${I(N,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const L=n.find(Q=>{var J;return((J=Q.valueOwner.declaration)==null?void 0:J.id)===B.operation[me.GoogleSheetsAutoResizeDimensions].inputs.range.id}),K=(e=L==null?void 0:L.value)==null?void 0:e.value;if(K==null)throw new Error(`${E}The ${I(L,"Range","range")} input is missing.`);const W={Authorization:`Bearer ${await m.getAccessToken()}`},H=`${(f=m.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${m.projectId}/${vi["google-sheet"]}/${V}`,te=async Q=>Ii.post(H,Q,{headers:W}),ne={autoResizeDimensions:{dimensions:Rot(K,{errorPrefix:`${E}The ${I(L,"Range","range")} input `})}},z=await te({method:"POST",endpoint:`/v4/spreadsheets/${_}:batchUpdate`,data:{requests:[ne]}});return{value:j.Success,result:{success:!0},error:null}}catch(m){const T=((h=m.response)==null?void 0:h.data)||m.message||m;return oe.Logger.log("[Google Sheets] error:",T),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:T,result:null}}}})}}class Fot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsFindAndReplace,version:"1.0.0",description:"Find and Replace Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsFindAndReplace);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I,A,D,V;try{const N=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!N||!N.env)throw new Error("Editor context or environment missing");const _=Xe(i,i.project,"findAndReplace"),K="["+je(i,i.project,"Find and replace")+": `"+_+"`] ",q=(ze,it,ft)=>{const Mt=je(ze==null?void 0:ze.valueOwner,N==null?void 0:N.logic,it),jt=Xe(ze==null?void 0:ze.valueOwner,N==null?void 0:N.logic,ft);return`"${Mt}" (\`${jt}\`)`},W=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.connection.id}),H=(a=W==null?void 0:W.value)==null?void 0:a.valueAsType;if(!H||!H.id||!H.name||H.type!==r.DefinitionEntity)throw new Error(`${K}The ${q(W,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const te=fr(H);if(!te)throw new Error(`${K}The ${q(W,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const ne=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.spreadsheetId.id}),z=(c=ne==null?void 0:ne.value)==null?void 0:c.value;if(!z||z==="")throw new Error(`${K}The ${q(ne,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof z!="string")throw new Error(`${K}The ${q(ne,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const Q=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.range.id}),J=(e=Q==null?void 0:Q.value)==null?void 0:e.value;if(J==null)throw new Error(`${K}The ${q(Q,"Range","range")} input is missing.`);const ae=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.find.id}),ee=(f=ae==null?void 0:ae.value)==null?void 0:f.value;if(!ee||ee==="")throw new Error(`${K}The ${q(ae,"Find","find")} input is missing.`);if(typeof ee!="string")throw new Error(`${K}The ${q(ae,"Find","find")} input value is invalid. It must be a non-empty string.`);const de=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.replace.id}),ye=((h=de==null?void 0:de.value)==null?void 0:h.value)||"";if(typeof ye!="string")throw new Error(`${K}The ${q(de,"Replace","replace")} input value is invalid. It must be a string.`);const fe=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.matchCase.id}),ve=!!((m=fe==null?void 0:fe.value)!=null&&m.value),Ce=n.find(ze=>{var it;return((it=ze.valueOwner.declaration)==null?void 0:it.id)===B.operation[me.GoogleSheetsFindAndReplace].inputs.matchEntireCell.id}),Oe=!!((T=Ce==null?void 0:Ce.value)!=null&&T.value),De={Authorization:`Bearer ${await N.getAccessToken()}`},Ue=`${(g=N.env)==null?void 0:g.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${N.projectId}/${vi["google-sheet"]}/${te}`,Je=async ze=>Ii.post(Ue,ze,{headers:De}),qe={findReplace:{range:$f(J,{errorPrefix:`${K}The ${q(Q,"Range","range")} input `}),find:ee,replacement:ye,matchCase:ve,matchEntireCell:Oe}},rt=await Je({method:"POST",endpoint:`/v4/spreadsheets/${z}:batchUpdate`,data:{requests:[qe]}}),dt=((E=rt.data)==null?void 0:E.data)||rt.data||{};return{value:j.Success,result:{occurrencesChanged:((D=(A=(I=dt.replies)==null?void 0:I[0])==null?void 0:A.findReplace)==null?void 0:D.occurrencesChanged)||0},error:null}}catch(N){const _=((V=N.response)==null?void 0:V.data)||N.message||N;return oe.Logger.log("[Google Sheets] error:",_),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:_,result:null}}}})}}class kot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsAddDataValidation,version:"1.0.0",description:"Add Data Validation Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsAddDataValidation);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"addDataValidation"),A="["+je(i,i.project,"Add data validation")+": `"+E+"`] ",D=(Ce,Oe,Ne)=>{const De=je(Ce==null?void 0:Ce.valueOwner,g==null?void 0:g.logic,Oe),Ue=Xe(Ce==null?void 0:Ce.valueOwner,g==null?void 0:g.logic,Ne);return`"${De}" (\`${Ue}\`)`},V=n.find(Ce=>{var Oe;return((Oe=Ce.valueOwner.declaration)==null?void 0:Oe.id)===B.operation[me.GoogleSheetsAddDataValidation].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(Ce=>{var Oe;return((Oe=Ce.valueOwner.declaration)==null?void 0:Oe.id)===B.operation[me.GoogleSheetsAddDataValidation].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(Ce=>{var Oe;return((Oe=Ce.valueOwner.declaration)==null?void 0:Oe.id)===B.operation[me.GoogleSheetsAddDataValidation].inputs.range.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(W==null)throw new Error(`${A}The ${D(q,"Range","range")} input is missing.`);const te={Authorization:`Bearer ${await g.getAccessToken()}`},ne=`${(f=g.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,z=async Ce=>Ii.post(ne,Ce,{headers:te});await Ld(W,"Id",async()=>(await z({method:"GET",endpoint:`/v4/spreadsheets/${K}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(Oe=>({id:Oe.properties.sheetId,name:Oe.properties.title})));const Q=$f(W,{errorPrefix:`${A}The ${D(q,"Range","range")} input `}),J=n.find(Ce=>{var Oe;return((Oe=Ce.valueOwner.declaration)==null?void 0:Oe.id)===B.operation[me.GoogleSheetsAddDataValidation].inputs.conditionType.id}),ae=(h=J==null?void 0:J.value)==null?void 0:h.value;if(!ae||ae==="")throw new Error(`${A}The ${D(J,"Condition Type","conditionType")} input is missing.`);if(typeof ae!="string")throw new Error(`${A}The ${D(J,"Condition Type","conditionType")} input value is invalid. It must be a non-empty string. E.g. "ONE_OF_LIST"`);const ee=n.find(Ce=>{var Oe;return((Oe=Ce.valueOwner.declaration)==null?void 0:Oe.id)===B.operation[me.GoogleSheetsAddDataValidation].inputs.conditionValues.id}),de=(m=ee==null?void 0:ee.value)==null?void 0:m.value;let ye=de;if(typeof de=="string")try{ye=JSON.parse(de)}catch{ye=de.split(",").map(Oe=>Oe.trim())}Array.isArray(ye)||(ye=ye?[ye]:[]);const fe={setDataValidation:{range:Q,rule:{condition:{type:ae,values:ye.map(Ce=>({userEnteredValue:String(Ce)}))},showCustomUi:!0}}},ve=await z({method:"POST",endpoint:`/v4/spreadsheets/${K}:batchUpdate`,data:{requests:[fe]}});return{value:j.Success,result:{success:!0},error:null}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Sot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsSortRange,version:"1.0.0",description:"Sort Range Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsSortRange);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T;try{const g=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!g||!g.env)throw new Error("Editor context or environment missing");const E=Xe(i,i.project,"sortRange"),A="["+je(i,i.project,"Sort range")+": `"+E+"`] ",D=(fe,ve,Ce)=>{const Oe=je(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,ve),Ne=Xe(fe==null?void 0:fe.valueOwner,g==null?void 0:g.logic,Ce);return`"${Oe}" (\`${Ne}\`)`},V=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsSortRange].inputs.connection.id}),N=(a=V==null?void 0:V.value)==null?void 0:a.valueAsType;if(!N||!N.id||!N.name||N.type!==r.DefinitionEntity)throw new Error(`${A}The ${D(V,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const _=fr(N);if(!_)throw new Error(`${A}The ${D(V,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const L=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsSortRange].inputs.spreadsheetId.id}),K=(c=L==null?void 0:L.value)==null?void 0:c.value;if(!K||K==="")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof K!="string")throw new Error(`${A}The ${D(L,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const q=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsSortRange].inputs.range.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(W==null)throw new Error(`${A}The ${D(q,"Range","range")} input is missing.`);const te={Authorization:`Bearer ${await g.getAccessToken()}`},ne=`${(f=g.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${g.projectId}/${vi["google-sheet"]}/${_}`,z=async fe=>Ii.post(ne,fe,{headers:te});await Ld(W,"Id",async()=>(await z({method:"GET",endpoint:`/v4/spreadsheets/${K}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(ve=>({id:ve.properties.sheetId,name:ve.properties.title})));const Q=$f(W,{errorPrefix:`${A}The ${D(q,"Range","range")} input `}),J=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsSortRange].inputs.sortColumnIndex.id}),ae=(h=J==null?void 0:J.value)==null?void 0:h.value;if(ae==null)throw new Error(`${A}The ${D(J,"Sort Column Index","sortColumnIndex")} input is missing.`);if(typeof ae!="number")throw new Error(`${A}The ${D(J,"Sort Column Index","sortColumnIndex")} input value is invalid. It must be a number.`);const ee=n.find(fe=>{var ve;return((ve=fe.valueOwner.declaration)==null?void 0:ve.id)===B.operation[me.GoogleSheetsSortRange].inputs.sortOrder.id}),de=(m=ee==null?void 0:ee.value)==null?void 0:m.value;if(de==null||de==="")throw new Error(`${A}The ${D(ee,"Sort Order","sortOrder")} input is missing.`);if(typeof de!="string")throw new Error(`${A}The ${D(ee,"Sort Order","sortOrder")} input value is invalid. It must be a string.`);const ye={sortRange:{range:Q,sortSpecs:[{dimensionIndex:ae,sortOrder:de.toUpperCase()}]}};return await z({method:"POST",endpoint:`/v4/spreadsheets/${K}:batchUpdate`,data:{requests:[ye]}}),{value:j.Success,result:{success:!0},error:null}}catch(g){const E=((T=g.response)==null?void 0:T.data)||g.message||g;return oe.Logger.log("[Google Sheets] error:",E),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:E,result:null}}}})}}class Uot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsApplyClearFilter,version:"1.0.0",description:"Apply or Clear Filter Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsApplyClearFilter);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"applyClearFilter"),I="["+je(i,i.project,"Apply or clear filter")+": `"+g+"`] ",A=(de,ye,fe)=>{const ve=je(de==null?void 0:de.valueOwner,T==null?void 0:T.logic,ye),Ce=Xe(de==null?void 0:de.valueOwner,T==null?void 0:T.logic,fe);return`"${ve}" (\`${Ce}\`)`},D=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsApplyClearFilter].inputs.connection.id}),V=(a=D==null?void 0:D.value)==null?void 0:a.valueAsType;if(!V||!V.id||!V.name||V.type!==r.DefinitionEntity)throw new Error(`${I}The ${A(D,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const N=fr(V);if(!N)throw new Error(`${I}The ${A(D,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const _=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsApplyClearFilter].inputs.spreadsheetId.id}),L=(c=_==null?void 0:_.value)==null?void 0:c.value;if(!L||L==="")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof L!="string")throw new Error(`${I}The ${A(_,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const K=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsApplyClearFilter].inputs.range.id}),q=(e=K==null?void 0:K.value)==null?void 0:e.value;if(q==null)throw new Error(`${I}The ${A(K,"Range","range")} input is missing.`);const H={Authorization:`Bearer ${await T.getAccessToken()}`},te=`${(f=T.env)==null?void 0:f.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${T.projectId}/${vi["google-sheet"]}/${N}`,ne=async de=>Ii.post(te,de,{headers:H});await Ld(q,"Id",async()=>(await ne({method:"GET",endpoint:`/v4/spreadsheets/${L}?fields=sheets.properties(sheetId,title)`})).data.sheets.map(ye=>({id:ye.properties.sheetId,name:ye.properties.title})));const z=$f(q,{errorPrefix:`${I}The ${A(K,"Range","range")} input `}),Q=n.find(de=>{var ye;return((ye=de.valueOwner.declaration)==null?void 0:ye.id)===B.operation[me.GoogleSheetsApplyClearFilter].inputs.clearOnly.id}),J=(h=Q==null?void 0:Q.value)==null?void 0:h.value;if(J!=null&&typeof J!="boolean")throw new Error(`${I}The ${A(Q,"Clear Only","clearOnly")} input value is invalid. If present, it must be a boolean. E.g. true`);const ae=J?{clearBasicFilter:{sheetId}}:{setBasicFilter:{filter:{range:z}}},ee=await ne({method:"POST",endpoint:`/v4/spreadsheets/${L}:batchUpdate`,data:{requests:[ae]}});return{value:j.Success,result:{success:!0},error:null}}catch(T){const g=((m=T.response)==null?void 0:m.data)||T.message||T;return oe.Logger.log("[Google Sheets] error:",g),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:g,result:null}}}})}}class jot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsUpdateSpreadsheetProperties,version:"1.0.0",description:"Update Spreadsheet Properties Google Sheets operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsUpdateSpreadsheetProperties);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I,A;try{const D=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!D||!D.env)throw new Error("Editor context or environment missing");const V=Xe(i,i.project,"updateSpreadsheetProperties"),_="["+je(i,i.project,"Update spreadsheet properties")+": `"+V+"`] ",L=(Mt,jt,wt)=>{const ht=je(Mt==null?void 0:Mt.valueOwner,D==null?void 0:D.logic,jt),Jt=Xe(Mt==null?void 0:Mt.valueOwner,D==null?void 0:D.logic,wt);return`"${ht}" (\`${Jt}\`)`},K=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.connection.id}),q=(a=K==null?void 0:K.value)==null?void 0:a.valueAsType;if(!q||!q.id||!q.name||q.type!==r.DefinitionEntity)throw new Error(`${_}The ${L(K,"Connection","connection")} input is missing or invalid. Expected a valid connection entity.`);const W=fr(q);if(!W)throw new Error(`${_}The ${L(K,"Connection","connection")} input is invalid, it is missing the underlying Connection ID value.`);const H=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.spreadsheetId.id}),te=(c=H==null?void 0:H.value)==null?void 0:c.value;if(!te||te==="")throw new Error(`${_}The ${L(H,"Spreadsheet ID","spreadsheetId")} input is missing.`);if(typeof te!="string")throw new Error(`${_}The ${L(H,"Spreadsheet ID","spreadsheetId")} input value is invalid. It must be a non-empty string. E.g. "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"`);const ne=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.title.id}),z=(e=ne==null?void 0:ne.value)==null?void 0:e.value;if(z!=null&&typeof z!="string")throw new Error(`${_}The ${L(ne,"Title","title")} input value is invalid. If present, it must be a string. E.g. "My Spreadsheet"`);const Q=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.locale.id}),J=(f=Q==null?void 0:Q.value)==null?void 0:f.value;if(J!=null&&typeof J!="string")throw new Error(`${_}The ${L(Q,"Locale","locale")} input value is invalid. If present, it must be a string. E.g. "en_US"`);const ae=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.timeZone.id}),ee=(h=ae==null?void 0:ae.value)==null?void 0:h.value;if(ee!=null&&typeof ee!="string")throw new Error(`${_}The ${L(ae,"Time Zone","timeZone")} input value is invalid. If present, it must be a string. E.g. "America/New_York"`);const de=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.autoRecalc.id}),ye=(m=de==null?void 0:de.value)==null?void 0:m.value;if(ye!=null&&typeof ye!="string")throw new Error(`${_}The ${L(de,"Auto Recalculation","autoRecalc")} input value is invalid. If present, it must be a string enum value. E.g. "ON_CHANGE"`);const fe=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.defaultFormat.id}),ve=(T=fe==null?void 0:fe.value)==null?void 0:T.value;if(ve!=null&&(typeof ve!="object"||Array.isArray(ve)))throw new Error(`${_}The ${L(fe,"Default Format","defaultFormat")} input value is invalid. If present, it must be an object representing the CellFormat.`);const Ce=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.iterativeCalculationSettings.id}),Oe=(g=Ce==null?void 0:Ce.value)==null?void 0:g.value;if(Oe!=null&&(typeof Oe!="object"||Array.isArray(Oe)))throw new Error(`${_}The ${L(Ce,"Iterative Calculation Settings","iterativeCalculationSettings")} input value is invalid. If present, it must be an object.`);const Ne=n.find(Mt=>{var jt;return((jt=Mt.valueOwner.declaration)==null?void 0:jt.id)===B.operation[me.GoogleSheetsUpdateSpreadsheetProperties].inputs.spreadsheetTheme.id}),De=(E=Ne==null?void 0:Ne.value)==null?void 0:E.value;if(De!=null&&(typeof De!="object"||Array.isArray(De)))throw new Error(`${_}The ${L(Ne,"Spreadsheet Theme","spreadsheetTheme")} input value is invalid. If present, it must be an object.`);const Ue={};z!=null&&(Ue.title=z),J!=null&&(Ue.locale=J),ee!=null&&(Ue.timeZone=ee),ye!=null&&(Ue.autoRecalc=ye),ve!=null&&(Ue.defaultFormat=ve),Oe!=null&&(Ue.iterativeCalculationSettings=Oe),De!=null&&(Ue.spreadsheetTheme=De);const Je=(Mt,jt="")=>{let wt=[];for(const ht in Mt){if(!Object.prototype.hasOwnProperty.call(Mt,ht))continue;const Jt=Mt[ht],ut=jt?`${jt}.${ht}`:ht;Jt!==null&&typeof Jt=="object"&&!Array.isArray(Jt)&&Object.keys(Jt).length>0?wt.push(...Je(Jt,ut)):wt.push(ut)}return wt},qe=Je(Ue);if(qe.length===0)throw new Error(`${_}At least one property must be provided to update.`);const dt={Authorization:`Bearer ${await D.getAccessToken()}`},ze=`${(I=D.env)==null?void 0:I.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${D.projectId}/${vi["google-sheet"]}/${W}`,ft=await(async Mt=>Ii.post(ze,Mt,{headers:dt}))({method:"POST",endpoint:`/v4/spreadsheets/${te}:batchUpdate`,data:{requests:[{updateSpreadsheetProperties:{properties:Ue,fields:qe.join(",")}}]}});return{value:j.Success,result:{success:!0},error:null}}catch(D){const V=((A=D.response)==null?void 0:A.data)||D.message||D;return oe.Logger.log("[Google Sheets] error:",V),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,error:V,result:null}}}})}}const nb=(l,u)=>(oe.Logger.log("[Google Sheets Clone Sheet] error:",u),{value:l.catchesError||l.errorCalls.length?j.CaughtError:j.UnhandledError,error:u,result:null});class $en extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Gn+me.GoogleSheetsCloneSheet,version:"1.0.0",description:"Google Sheets clone sheet operation implementation module",initPriority:xe.High,permissions:[_e.All],contexts:[X.Editor,X.Logic]});C(this,"module",{init:i=>{const n=i.find(a=>a.contextType===X.Logic);if(n){const a=n.get(me.GoogleSheetsCloneSheet);a&&(a.implementation=this.module.main)}},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E,I,A,D,V,N,_,L,K,q,W,H,te;try{const ne=B.operation[me.GoogleSheetsCloneSheet],z=((c=(a=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.connection.id}))==null?void 0:a.value)==null?void 0:c.valueAsType)??((f=(e=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.connection.id}))==null?void 0:e.value)==null?void 0:f.value);if(!(z instanceof Na))return nb(i,"Invalid or missing connection entity");const Q=(m=(h=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.spreadsheetId.id}))==null?void 0:h.value)==null?void 0:m.value;if(!Q)return nb(i,"Missing required input: spreadsheetId");const J=(g=(T=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.sheet.id}))==null?void 0:T.value)==null?void 0:g.value;if(J==null||J==="")return nb(i,"Missing required input: sheet");const ae=(I=(E=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.newSheetName.id}))==null?void 0:E.value)==null?void 0:I.value,ee=(D=(A=n.find(rt=>{var dt,ze;return((ze=(dt=rt.valueOwner)==null?void 0:dt.declaration)==null?void 0:ze.id)===ne.inputs.insertIndex.id}))==null?void 0:A.value)==null?void 0:D.value,de=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],ye=fr(z),ve={Authorization:`Bearer ${await de.getAccessToken()}`},Ce=`${(V=de.env)==null?void 0:V.API_BASE_URL}/editor-runtime/v1/external-integrations/generic-proxy/${de.projectId}/${vi["google-sheet"]}/${ye}`,Oe=async rt=>Ii.post(Ce,rt,{headers:ve});let Ne;if(!isNaN(Number(J)))Ne=Number(J);else{const rt=await Oe({method:"GET",endpoint:`/v4/spreadsheets/${Q}`}),ze=(((_=(N=rt.data)==null?void 0:N.data)==null?void 0:_.sheets)||((L=rt.data)==null?void 0:L.sheets)||[]).find(it=>{var ft;return((ft=it.properties)==null?void 0:ft.title)===String(J)});if(!ze)return nb(i,`Could not find sheet with name "${J}"`);Ne=ze.properties.sheetId}const De={sourceSheetId:Ne};ae&&(De.newSheetName=ae),typeof ee=="number"&&(De.insertSheetIndex=ee);const Ue=await Oe({method:"POST",endpoint:`/v4/spreadsheets/${Q}:batchUpdate`,data:{requests:[{duplicateSheet:De}]}}),qe=((H=(W=(q=(((K=Ue.data)==null?void 0:K.data)||Ue.data||{}).replies)==null?void 0:q[0])==null?void 0:W.duplicateSheet)==null?void 0:H.properties)||{};return{value:j.Success,error:null,result:{newSheetId:qe.sheetId,newSheetName:qe.title}}}catch(ne){const z=((te=ne.response)==null?void 0:te.data)||ne.message||ne;return nb(i,z)}}})}}class Kot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_UPLOAD_FILE,version:"1.0.0",description:"Cloud File System: Upload File",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.UploadFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"uploadFile"),E="["+je(i,i.project,"Upload file")+": `"+T+"`] ",I=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.UploadFile].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(ae=>ae.resourceId===D))throw new Error(`${E}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const N=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.UploadFile].inputs.key.id}),_=(e=N==null?void 0:N.value)==null?void 0:e.value;if(!_||_==="")throw new Error(`${E}The "${je(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof _!="string")throw new Error(`${E}The "${je(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.UploadFile].inputs.file.id}),K=(f=L==null?void 0:L.value)==null?void 0:f.value;if(!K)throw new Error(`${E}The "${je(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"File")}" (\`${Xe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"file")}\`) input is missing'`);if(typeof K!="object"||!K.uri||typeof K.uri!="string")throw new Error(`${E}The "${je(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"File")}" (\`${Xe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"file")}\`) input is invalid, should be an object with a text 'uri' property.`);const q=K.uri,W=K.mimeType||"application/octet-stream",H=_,ne=(h=(await Ii.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files?bucket=${D}&key=${encodeURIComponent(H)}&contentType=${encodeURIComponent(W)}`,{},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}})).data)==null?void 0:h.uploadUrl;if(!ne)throw new Error(`${E}Failed to retrieve pre-signed upload URL.`);let z;try{z=await OB(q,()=>m.getAccessToken())}catch(ae){throw new Error(`${E}Failed to fetch file content from '${q}': ${(ae==null?void 0:ae.message)||ae}`)}await Ii.put(ne,z,{headers:{"Content-Type":W}});const J={uri:`${m.env.API_BASE_URL}/cloud-files-service/v1/files/download?bucket=${D}&key=${encodeURIComponent(H)}`,name:H.split("/").pop()||H,mimeType:W,size:z.length};return{value:j.Success,error:null,result:J}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class qot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_FILE,version:"1.0.0",description:"Cloud File System: Get File",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.GetFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"getFile"),T="["+je(i,i.project,"Get file")+": `"+h+"`] ",g=n.find(L=>{var K,q;return((q=(K=L.valueOwner)==null?void 0:K.declaration)==null?void 0:q.id)===B.operation[Se.GetFile].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(L=>L.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(L=>{var K,q;return((q=(K=L.valueOwner)==null?void 0:K.declaration)==null?void 0:q.id)===B.operation[Se.GetFile].inputs.key.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value;if(!V||V==="")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof V!="string")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=(await Ii.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/metadata?bucket=${I}&key=${encodeURIComponent(V)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}})).data;return{value:j.Success,error:null,result:{uri:_.uri,name:_.name,key:_.key,size:_.size,mimeType:_.mimeType,access:_.access,lastModified:_.lastModified}}}catch(f){return{value:j.UnhandledError,error:f,result:null}}}})}}class Zot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_LIST_FILES,version:"1.0.0",description:"Cloud File System: List Files",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.ListFiles);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"listFiles"),E="["+je(i,i.project,"List files")+": `"+T+"`] ",I=n.find(ye=>{var fe,ve;return((ve=(fe=ye.valueOwner)==null?void 0:fe.declaration)==null?void 0:ve.id)===B.operation[Se.ListFiles].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(ye=>ye.resourceId===D))throw new Error(`${E}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const N=n.find(ye=>{var fe,ve;return((ve=(fe=ye.valueOwner)==null?void 0:fe.declaration)==null?void 0:ve.id)===B.operation[Se.ListFiles].inputs.path.id}),_=(e=N==null?void 0:N.value)==null?void 0:e.value;if(_!==void 0&&typeof _!="string")throw new Error(`${E}The "${je(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"Path")}" (\`${Xe(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"path")}\`) input value is invalid, if present, it must be a string.`);const L=n.find(ye=>{var fe,ve;return((ve=(fe=ye.valueOwner)==null?void 0:fe.declaration)==null?void 0:ve.id)===B.operation[Se.ListFiles].inputs.maxKeys.id}),K=(f=L==null?void 0:L.value)==null?void 0:f.value;if(K!==void 0&&(typeof K!="number"||K<=0))throw new Error(`${E}The "${je(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Max results")}" (\`${Xe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"maxKeys")}\`) input value is invalid, if present, it must be a number greater than 0.`);const q=n.find(ye=>{var fe,ve;return((ve=(fe=ye.valueOwner)==null?void 0:fe.declaration)==null?void 0:ve.id)===B.operation[Se.ListFiles].inputs.startAfter.id}),W=(h=q==null?void 0:q.value)==null?void 0:h.value;if(W!==void 0&&(typeof W!="string"||W===""))throw new Error(`${E}The "${je(q==null?void 0:q.valueOwner,m==null?void 0:m.logic,"Start after")}" (\`${Xe(q==null?void 0:q.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=${D}`;_&&(H+=`&path=${encodeURIComponent(_)}`),K&&(H+=`&maxKeys=${K}`),W&&(H+=`&startAfter=${encodeURIComponent(W)}`);const te=await Ii.get(H,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}}),ne=ye=>{var Oe;if(!ye)return"application/octet-stream";const fe=ye.split(".");if(fe.length<=1)return"application/octet-stream";const ve=(Oe=fe.pop())==null?void 0:Oe.toLowerCase();return ve&&{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",txt:"text/plain",html:"text/html",css:"text/css",js:"application/javascript",json:"application/json",csv:"text/csv",xml:"application/xml",zip:"application/zip",mp3:"audio/mpeg",mp4:"video/mp4",mov:"video/quicktime",wav:"audio/wav"}[ve]||"application/octet-stream"},Q=(te.data.items||te.data.files||[]).map(ye=>({uri:ye.uri||ye.url||`${m.env.API_BASE_URL}/cloud-files-service/v1/files/download?bucket=${D}&key=${encodeURIComponent(ye.key)}`,name:ye.name,key:ye.key,mimeType:ye.mimeType||ne(ye.key),size:ye.size||0,lastModified:ye.lastModified,access:ye.access})),J=te.data.total!==void 0?te.data.total:Q.length,ae=te.data.size!==void 0?te.data.size:Q.reduce((ye,fe)=>ye+(fe.size||0),0),ee=te.data.nextStartAfter!==void 0?te.data.nextStartAfter:null,de=te.data.hasMore!==void 0?te.data.hasMore:!1;return{value:j.Success,error:null,result:{items:Q,total:J,size:ae,nextStartAfter:ee,hasMore:de}}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class Hot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_DELETE_FILES,version:"1.0.0",description:"Cloud File System: Delete Files",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.DeleteFiles);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"deleteFiles"),T="["+je(i,i.project,"Delete files")+": `"+h+"`] ",g=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.DeleteFiles].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(K=>K.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.DeleteFiles].inputs.keys.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value,N=Array.isArray(V)?V:typeof V=="string"&&V!==""?[V]:[];if(!N||N.length===0)throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Keys")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"keys")}\`) input is missing.`);if(!Array.isArray(N)||N.some(K=>typeof K!="string"||K===""))throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Keys")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"keys")}\`) input value is invalid, if present, it must be a list of non-empty strings.`);const L=(await Ii.delete(`${f.env.API_BASE_URL}/cloud-files-service/v1/files`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`},data:{bucket:I,keys:N}})).data;return{value:j.Success,error:null,result:null}}catch(f){return{value:j.UnhandledError,error:f,result:null}}}})}}class Wot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_COPY_FILE,version:"1.0.0",description:"Cloud File System: Copy File",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.CopyFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"copyFile"),I="["+je(i,i.project,"Copy file")+": `"+g+"`] ",A=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.CopyFile].inputs.bucket.id}),D=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!D||!D.id||!D.name||D.type!==r.DefinitionEntity)throw new Error(`${I}Invalid input "${je(A==null?void 0:A.valueOwner,T==null?void 0:T.logic,"Storage")}" (\`${Xe(A==null?void 0:A.valueOwner,T==null?void 0:T.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const V=$s(D==null?void 0:D.id,((c=T.branchHead)==null?void 0:c.identifier)||"main");if(!((T==null?void 0:T.liveResources)||[]).find(ae=>ae.resourceId===V))throw new Error(`${I}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const _=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.CopyFile].inputs.sourceKey.id}),L=(e=_==null?void 0:_.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${I}The "${je(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${Xe(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${I}The "${je(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${Xe(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.CopyFile].inputs.destinationKey.id}),q=(f=K==null?void 0:K.value)==null?void 0:f.value;if(!q||q==="")throw new Error(`${I}The "${je(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${Xe(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input is missing.`);if(typeof q!="string")throw new Error(`${I}The "${je(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${Xe(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const W=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.CopyFile].inputs.destinationBucket.id}),H=(h=W==null?void 0:W.value)==null?void 0:h.valueAsType;if(H&&(!H.id||!H.name||H.type!==r.DefinitionEntity))throw new Error(`${I}Invalid input "${je(W==null?void 0:W.valueOwner,T==null?void 0:T.logic,"Destination Storage")}" (\`${Xe(W==null?void 0:W.valueOwner,T==null?void 0:T.logic,"destinationBucket")}\`), expected a valid "Cloud file system" node.`);const te=H!=null&&H.id?$s(H.id,((m=T.branchHead)==null?void 0:m.identifier)||"main"):V;if(!((T==null?void 0:T.liveResources)||[]).find(ae=>ae.resourceId===te))throw new Error(`${I}The destination "Cloud file system" is not live. Publish the project first, then try again to run the operation node.`);const z={headers:{Authorization:`Bearer ${await T.getAccessToken()}`}},J=(await Ii.post(`${T.env.API_BASE_URL}/cloud-files-service/v1/files/copy`,{bucket:V,destinationBucket:te,sourceKey:L,destinationKey:q},z)).data;return{value:j.Success,error:null,result:null}}catch(T){return{value:j.UnhandledError,error:T,result:null}}}})}}class zot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_MOVE_FILE,version:"1.0.0",description:"Cloud File System: Move File",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.MoveFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h,m;try{const T=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!T||!T.env)throw new Error("Editor context or environment missing");const g=Xe(i,i.project,"moveFile"),I="["+je(i,i.project,"Move file")+": `"+g+"`] ",A=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.MoveFile].inputs.bucket.id}),D=(a=A==null?void 0:A.value)==null?void 0:a.valueAsType;if(!D||!D.id||!D.name||D.type!==r.DefinitionEntity)throw new Error(`${I}Invalid input "${je(A==null?void 0:A.valueOwner,T==null?void 0:T.logic,"Storage")}" (\`${Xe(A==null?void 0:A.valueOwner,T==null?void 0:T.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const V=$s(D==null?void 0:D.id,((c=T.branchHead)==null?void 0:c.identifier)||"main");if(!((T==null?void 0:T.liveResources)||[]).find(ae=>ae.resourceId===V))throw new Error(`${I}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const _=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.MoveFile].inputs.sourceKey.id}),L=(e=_==null?void 0:_.value)==null?void 0:e.value;if(!L||L==="")throw new Error(`${I}The "${je(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${Xe(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${I}The "${je(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"Source key")}" (\`${Xe(_==null?void 0:_.valueOwner,T==null?void 0:T.logic,"sourceKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.MoveFile].inputs.destinationKey.id}),q=(f=K==null?void 0:K.value)==null?void 0:f.value;if(!q||q==="")throw new Error(`${I}The "${je(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${Xe(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input is missing.`);if(typeof q!="string")throw new Error(`${I}The "${je(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"Destination key")}" (\`${Xe(K==null?void 0:K.valueOwner,T==null?void 0:T.logic,"destinationKey")}\`) input value is invalid, if present, it must be a non-empty string.`);const W=n.find(ae=>{var ee,de;return((de=(ee=ae.valueOwner)==null?void 0:ee.declaration)==null?void 0:de.id)===B.operation[Se.MoveFile].inputs.destinationBucket.id}),H=(h=W==null?void 0:W.value)==null?void 0:h.valueAsType;if(H&&(!H.id||!H.name||H.type!==r.DefinitionEntity))throw new Error(`${I}Invalid input "${je(W==null?void 0:W.valueOwner,T==null?void 0:T.logic,"Destination storage")}" (\`${Xe(W==null?void 0:W.valueOwner,T==null?void 0:T.logic,"destinationBucket")}\`), expected a valid "Cloud file system" node.`);const te=H!=null&&H.id?$s(H.id,((m=T.branchHead)==null?void 0:m.identifier)||"main"):V;if(!((T==null?void 0:T.liveResources)||[]).find(ae=>ae.resourceId===te))throw new Error(`${I}The destination "Cloud file system" is not live. Publish the project first, then try again to run the operation node.`);const z={headers:{Authorization:`Bearer ${await T.getAccessToken()}`}},J=(await Ii.post(`${T.env.API_BASE_URL}/cloud-files-service/v1/files/move`,{bucket:V,destinationBucket:te,sourceKey:L,destinationKey:q},z)).data;return{value:j.Success,error:null,result:null}}catch(T){return{value:j.UnhandledError,error:T,result:null}}}})}}class Yot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_RENAME_FILE,version:"1.0.0",description:"Cloud File System: Rename File",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.RenameFile);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=Xe(i,i.project,"renameFile"),g="["+je(i,i.project,"Rename file")+": `"+m+"`] ",E=n.find(ne=>{var z,Q;return((Q=(z=ne.valueOwner)==null?void 0:z.declaration)==null?void 0:Q.id)===B.operation[Se.RenameFile].inputs.bucket.id}),I=(a=E==null?void 0:E.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==r.DefinitionEntity)throw new Error(`${g}Invalid input "${je(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${Xe(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const A=$s(I==null?void 0:I.id,((c=h.branchHead)==null?void 0:c.identifier)||"main");if(!((h==null?void 0:h.liveResources)||[]).find(ne=>ne.resourceId===A))throw new Error(`${g}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const V=n.find(ne=>{var z,Q;return((Q=(z=ne.valueOwner)==null?void 0:z.declaration)==null?void 0:Q.id)===B.operation[Se.RenameFile].inputs.key.id}),N=(e=V==null?void 0:V.value)==null?void 0:e.value;if(!N||N==="")throw new Error(`${g}The "${je(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof N!="string")throw new Error(`${g}The "${je(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=n.find(ne=>{var z,Q;return((Q=(z=ne.valueOwner)==null?void 0:z.declaration)==null?void 0:Q.id)===B.operation[Se.RenameFile].inputs.newName.id}),L=(f=_==null?void 0:_.value)==null?void 0:f.value;if(!L||L==="")throw new Error(`${g}The "${je(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"New name")}" (\`${Xe(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"newName")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${g}The "${je(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"New name")}" (\`${Xe(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"newName")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=N.lastIndexOf("/"),W=`${K!==-1?N.substring(0,K+1):""}${L}`,H={headers:{Authorization:`Bearer ${await h.getAccessToken()}`}},te=await Ii.post(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/rename`,{bucket:A,key:N,newName:L},H);return{value:j.Success,error:null,result:te.data||{key:N,newName:L,destinationKey:W}}}catch(h){return{value:j.UnhandledError,error:h,result:null}}}})}}class Jot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_FILE_METADATA,version:"1.0.0",description:"Cloud File System: Get File Metadata",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.GetFileMetadata);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"getFileMetadata"),T="["+je(i,i.project,"Get file metadata")+": `"+h+"`] ",g=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation[Se.GetFileMetadata].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(_=>_.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation[Se.GetFileMetadata].inputs.key.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value;if(!V||V==="")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof V!="string")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const N=await Ii.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/metadata?bucket=${I}&key=${encodeURIComponent(V)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});return{value:j.Success,error:null,result:N.data}}catch(f){return{value:j.UnhandledError,error:f,result:null}}}})}}class Qot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CHECK_FILE_EXISTS,version:"1.0.0",description:"Cloud File System: Check File Exists",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.CheckFileExists);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"checkFileExists"),T="["+je(i,i.project,"Check File Exists")+": `"+h+"`] ",g=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation[Se.CheckFileExists].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(_=>_.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(_=>{var L,K;return((K=(L=_.valueOwner)==null?void 0:L.declaration)==null?void 0:K.id)===B.operation[Se.CheckFileExists].inputs.key.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value;if(!V||V==="")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input is missing.`);if(typeof V!="string")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const N=await Ii.get(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/exists?bucket=${I}&key=${encodeURIComponent(V)}`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}});return{value:j.Success,error:null,result:N.data.exists}}catch(f){return{value:j.UnhandledError,error:f,result:!1}}}})}}class Xot extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_GET_PRESIGNED_URL,version:"1.0.0",description:"Cloud File System: Get Pre-signed URL",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.GetPresignedUrl);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"getPresignedUrl"),E="["+je(i,i.project,"Get pre-signed URL")+": `"+T+"`] ",I=n.find(Q=>{var J,ae;return((ae=(J=Q.valueOwner)==null?void 0:J.declaration)==null?void 0:ae.id)===B.operation[Se.GetPresignedUrl].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main");if(!((m==null?void 0:m.liveResources)||[]).find(Q=>Q.resourceId===D))throw new Error(`${E}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const N=n.find(Q=>{var J,ae;return((ae=(J=Q.valueOwner)==null?void 0:J.declaration)==null?void 0:ae.id)===B.operation[Se.GetPresignedUrl].inputs.key.id}),_=(e=N==null?void 0:N.value)==null?void 0:e.value;if(!_||_==="")throw new Error(`${E}The "${je(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof _!="string")throw new Error(`${E}The "${je(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(N==null?void 0:N.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const L=n.find(Q=>{var J,ae;return((ae=(J=Q.valueOwner)==null?void 0:J.declaration)==null?void 0:ae.id)===B.operation[Se.GetPresignedUrl].inputs.action.id}),K=(f=L==null?void 0:L.value)==null?void 0:f.value,q=(K||"read").toLowerCase(),W=["read","write","delete","metadata","upload","putobject","head","headobject","getobject","get"];if(!K||K==="")throw new Error(`${E}The "${je(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Action")}" (\`${Xe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"action")}\`) input is missing.`);if(!W.includes(q))throw new Error(`${E}Invalid "${je(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"Action")}" (\`${Xe(L==null?void 0:L.valueOwner,m==null?void 0:m.logic,"action")}\`) input value, must be one of "read", "write", "delete" or "metadata".`);const H=n.find(Q=>{var J,ae;return((ae=(J=Q.valueOwner)==null?void 0:J.declaration)==null?void 0:ae.id)===B.operation[Se.GetPresignedUrl].inputs.expiresInSeconds.id}),te=(h=H==null?void 0:H.value)==null?void 0:h.value,ne=te!=null?Number(te):3600;if(isNaN(ne)||ne<=0)throw new Error(`${E}Invalid "${je(H==null?void 0:H.valueOwner,m==null?void 0:m.logic,"Expires in seconds")}" (\`${Xe(H==null?void 0:H.valueOwner,m==null?void 0:m.logic,"expiresInSeconds")}\`) input value, expected a positive number.`);const z=await Ii.get(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/presigned-url?bucket=${D}&key=${encodeURIComponent(_)}&action=${q}&expiresInSeconds=${ne}`,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:j.Success,error:null,result:z.data}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class edt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_SET_FILE_ACCESS,version:"1.0.0",description:"Cloud File System: Set File Access",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.SetFileAccess);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=Xe(i,i.project,"setFileAccess"),g="["+je(i,i.project,"Set file access")+": `"+m+"`] ",E=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.SetFileAccess].inputs.bucket.id}),I=(a=E==null?void 0:E.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==r.DefinitionEntity)throw new Error(`${g}Invalid input "${je(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${Xe(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const A=$s(I==null?void 0:I.id,((c=h.branchHead)==null?void 0:c.identifier)||"main");if(!((h==null?void 0:h.liveResources)||[]).find(K=>K.resourceId===A))throw new Error(`${g}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const V=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.SetFileAccess].inputs.key.id}),N=(e=V==null?void 0:V.value)==null?void 0:e.value;if(!N||N==="")throw new Error(`${g}The "${je(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof N!="string")throw new Error(`${g}The "${je(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.SetFileAccess].inputs.access.id}),L=((f=_==null?void 0:_.value)==null?void 0:f.value)??"private";if(!L||L==="")throw new Error(`${g}The "${je(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"Access")}" (\`${Xe(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"access")}\`) input is missing.`);if(typeof L!="string"||!["public","private"].includes(L))throw new Error(`${g}The "${je(_==null?void 0:_.valueOwner,h==null?void 0:h.logic,"Access")}" (\`${Xe(_==null?void 0:_.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 Ii.post(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/access`,{bucket:A,key:N,access:L},{headers:{Authorization:`Bearer ${await h.getAccessToken()}`}}),{value:j.Success,error:null,result:null}}catch(h){return{value:j.UnhandledError,error:h,result:null}}}})}}class tdt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CREATE_FOLDER,version:"1.0.0",description:"Cloud File System: Create Folder",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.CreateFolder);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"createFolder"),T="["+je(i,i.project,"Create folder")+": `"+h+"`] ",g=n.find(L=>{var K,q;return((q=(K=L.valueOwner)==null?void 0:K.declaration)==null?void 0:q.id)===B.operation[Se.CreateFolder].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(L=>L.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(L=>{var K,q;return((q=(K=L.valueOwner)==null?void 0:K.declaration)==null?void 0:q.id)===B.operation[Se.CreateFolder].inputs.folderPath.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value;if(!V||V==="")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Folder path")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"folderPath")}\`) input is missing.`);if(typeof V!="string")throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Folder path")}" (\`${Xe(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.`);const _=(await Ii.post(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/folders`,{bucket:I,folderPath:V},{headers:{Authorization:`Bearer ${await f.getAccessToken()}`}})).data;return{value:j.Success,error:null,result:null}}catch(f){return{value:j.UnhandledError,error:f,result:null}}}})}}class idt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_DELETE_FOLDERS,version:"1.0.0",description:"Cloud File System: Delete Folders",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.DeleteFolders);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e;try{const f=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!f||!f.env)throw new Error("Editor context or environment missing");const h=Xe(i,i.project,"deleteFolders"),T="["+je(i,i.project,"Delete folders")+": `"+h+"`] ",g=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.DeleteFolders].inputs.bucket.id}),E=(a=g==null?void 0:g.value)==null?void 0:a.valueAsType;if(!E||!E.id||!E.name||E.type!==r.DefinitionEntity)throw new Error(`${T}Invalid input "${je(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"Storage")}" (\`${Xe(g==null?void 0:g.valueOwner,f==null?void 0:f.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const I=$s(E==null?void 0:E.id,((c=f.branchHead)==null?void 0:c.identifier)||"main");if(!((f==null?void 0:f.liveResources)||[]).find(K=>K.resourceId===I))throw new Error(`${T}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const D=n.find(K=>{var q,W;return((W=(q=K.valueOwner)==null?void 0:q.declaration)==null?void 0:W.id)===B.operation[Se.DeleteFolders].inputs.folderPaths.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value,N=Array.isArray(V)?V:typeof V=="string"&&V!==""?[V]:[];if(!N||N.length===0)throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Folder paths")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"folderPaths")}\`) input is missing.`);if(!Array.isArray(N)||N.some(K=>typeof K!="string"||K===""))throw new Error(`${T}The "${je(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"Folder paths")}" (\`${Xe(D==null?void 0:D.valueOwner,f==null?void 0:f.logic,"folderPaths")}\`) input value is invalid, if present, it must be a list of non-empty strings.`);const L=(await Ii.delete(`${f.env.API_BASE_URL}/cloud-files-service/v1/files/folders`,{headers:{Authorization:`Bearer ${await f.getAccessToken()}`},data:{bucket:I,folderPaths:N}})).data;return{value:j.Success,error:null,result:null}}catch(f){return{value:j.UnhandledError,error:f,result:null}}}})}}class ndt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_CREATE_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Create Multipart Upload",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.CreateMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"createMultipartUpload"),E="["+je(i,i.project,"Create multipart upload")+": `"+T+"`] ",I=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.CreateMultipartUpload].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),V=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.CreateMultipartUpload].inputs.key.id}),N=(e=V==null?void 0:V.value)==null?void 0:e.value;if(!N||N==="")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof N!="string")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.CreateMultipartUpload].inputs.contentType.id}),L=((f=_==null?void 0:_.value)==null?void 0:f.value)||"application/octet-stream";if(!L||L==="")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Content Type")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"contentType")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Content Type")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"contentType")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=await Ii.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart?bucket=${D}&key=${encodeURIComponent(N)}&contentType=${encodeURIComponent(L)}`,{},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:j.Success,error:null,result:{uploadId:typeof K.data=="object"&&((h=K.data)!=null&&h.uploadId)?K.data.uploadId:K.data}}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class rdt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.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:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.GetUploadPartPresignedUrl);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"getUploadPartPresignedUrl"),E="["+je(i,i.project,"Get upload part pre-signed URL")+": `"+T+"`] ",I=n.find(H=>{var te,ne;return((ne=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:ne.id)===B.operation[Se.GetUploadPartPresignedUrl].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),V=n.find(H=>{var te,ne;return((ne=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:ne.id)===B.operation[Se.GetUploadPartPresignedUrl].inputs.key.id}),N=(e=V==null?void 0:V.value)==null?void 0:e.value;if(!N||N==="")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof N!="string")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=n.find(H=>{var te,ne;return((ne=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:ne.id)===B.operation[Se.GetUploadPartPresignedUrl].inputs.uploadId.id}),L=(f=_==null?void 0:_.value)==null?void 0:f.value;if(!L||L==="")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=n.find(H=>{var te,ne;return((ne=(te=H.valueOwner)==null?void 0:te.declaration)==null?void 0:ne.id)===B.operation[Se.GetUploadPartPresignedUrl].inputs.partNumber.id}),q=Number((h=K==null?void 0:K.value)==null?void 0:h.value);if(isNaN(q)||q<=0)throw new Error(`${E}The "${je(K==null?void 0:K.valueOwner,m==null?void 0:m.logic,"Part number")}" (\`${Xe(K==null?void 0:K.valueOwner,m==null?void 0:m.logic,"partNumber")}\`) input is missing or invalid.`);const W=await Ii.get(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${L}?bucket=${D}&key=${encodeURIComponent(N)}&partNumber=${q}`,{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}});return{value:j.Success,error:null,result:W.data}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class adt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_COMPLETE_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Complete Multipart Upload",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.CompleteMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h;try{const m=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!m||!m.env)throw new Error("Editor context or environment missing");const T=Xe(i,i.project,"completeMultipartUpload"),E="["+je(i,i.project,"Complete multipart upload")+": `"+T+"`] ",I=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===B.operation[Se.CompleteMultipartUpload].inputs.bucket.id}),A=(a=I==null?void 0:I.value)==null?void 0:a.valueAsType;if(!A||!A.id||!A.name||A.type!==r.DefinitionEntity)throw new Error(`${E}Invalid input "${je(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"Storage")}" (\`${Xe(I==null?void 0:I.valueOwner,m==null?void 0:m.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const D=$s(A==null?void 0:A.id,((c=m.branchHead)==null?void 0:c.identifier)||"main"),V=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===B.operation[Se.CompleteMultipartUpload].inputs.key.id}),N=(e=V==null?void 0:V.value)==null?void 0:e.value;if(!N||N==="")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input is missing.`);if(typeof N!="string")throw new Error(`${E}The "${je(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"Key")}" (\`${Xe(V==null?void 0:V.valueOwner,m==null?void 0:m.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const _=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===B.operation[Se.CompleteMultipartUpload].inputs.uploadId.id}),L=(f=_==null?void 0:_.value)==null?void 0:f.value;if(!L||L==="")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input is missing.`);if(typeof L!="string")throw new Error(`${E}The "${je(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"Upload ID")}" (\`${Xe(_==null?void 0:_.valueOwner,m==null?void 0:m.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=n.find(te=>{var ne,z;return((z=(ne=te.valueOwner)==null?void 0:ne.declaration)==null?void 0:z.id)===B.operation[Se.CompleteMultipartUpload].inputs.parts.id}),q=(h=K==null?void 0:K.value)==null?void 0:h.value;if(!Array.isArray(q)||q.length===0)throw new Error(`${E}The "${je(K==null?void 0:K.valueOwner,m==null?void 0:m.logic,"Parts")}" (\`${Xe(K==null?void 0:K.valueOwner,m==null?void 0:m.logic,"parts")}\`) input is missing or empty.`);if(q.some(te=>{let ne=!1,z=!1;return(te.partNumber&&Number(te.partNumber)>0||te.PartNumber&&Number(te.PartNumber)>0)&&(ne=!0),(te.etag&&typeof te.etag=="string"||te.ETag&&typeof te.ETag=="string")&&(z=!0),!ne||!z}))throw new Error(`${E}The "${je(K==null?void 0:K.valueOwner,m==null?void 0:m.logic,"Parts")}" (\`${Xe(K==null?void 0:K.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 Ii.post(`${m.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${L}/complete?bucket=${D}&key=${encodeURIComponent(N)}`,{parts:q},{headers:{Authorization:`Bearer ${await m.getAccessToken()}`}})).data||{};return{value:j.Success,error:null,result:{location:H.location||H.Location||N,key:H.key||H.Key||N,etag:H.etag||H.ETag||null}}}catch(m){return{value:j.UnhandledError,error:m,result:null}}}})}}class sdt extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_ABORT_MULTIPART_UPLOAD,version:"1.0.0",description:"Cloud File System: Abort Multipart Upload",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.AbortMultipartUpload);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f;try{const h=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!h||!h.env)throw new Error("Editor context or environment missing");const m=Xe(i,i.project,"abortMultipartUpload"),g="["+je(i,i.project,"Abort multipart upload")+": `"+m+"`] ",E=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.AbortMultipartUpload].inputs.bucket.id}),I=(a=E==null?void 0:E.value)==null?void 0:a.valueAsType;if(!I||!I.id||!I.name||I.type!==r.DefinitionEntity)throw new Error(`${g}Invalid input "${je(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"Storage")}" (\`${Xe(E==null?void 0:E.valueOwner,h==null?void 0:h.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const A=$s(I==null?void 0:I.id,((c=h.branchHead)==null?void 0:c.identifier)||"main"),D=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.AbortMultipartUpload].inputs.key.id}),V=(e=D==null?void 0:D.value)==null?void 0:e.value;if(!V||V==="")throw new Error(`${g}The "${je(D==null?void 0:D.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,h==null?void 0:h.logic,"key")}\`) input is missing.`);if(typeof V!="string")throw new Error(`${g}The "${je(D==null?void 0:D.valueOwner,h==null?void 0:h.logic,"Key")}" (\`${Xe(D==null?void 0:D.valueOwner,h==null?void 0:h.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const N=n.find(q=>{var W,H;return((H=(W=q.valueOwner)==null?void 0:W.declaration)==null?void 0:H.id)===B.operation[Se.AbortMultipartUpload].inputs.uploadId.id}),_=(f=N==null?void 0:N.value)==null?void 0:f.value;if(!_||_==="")throw new Error(`${g}The "${je(N==null?void 0:N.valueOwner,h==null?void 0:h.logic,"Upload ID")}" (\`${Xe(N==null?void 0:N.valueOwner,h==null?void 0:h.logic,"uploadId")}\`) input is missing.`);if(typeof _!="string")throw new Error(`${g}The "${je(N==null?void 0:N.valueOwner,h==null?void 0:h.logic,"Upload ID")}" (\`${Xe(N==null?void 0:N.valueOwner,h==null?void 0:h.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const K=(await Ii.delete(`${h.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${_}?bucket=${A}&key=${encodeURIComponent(V)}`,{headers:{Authorization:`Bearer ${await h.getAccessToken()}`}})).data;return{value:j.Success,error:null,result:null}}catch(h){return{value:j.UnhandledError,error:h,result:null}}}})}}class Len extends Ve{constructor(){super(...arguments);C(this,"manifest",{id:Be.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CLOUD_FILE_SYSTEM_UPLOAD_FILE_PART,version:"1.0.0",description:"Cloud File System: Upload File Part",initPriority:xe.High,permissions:[_e.All],contexts:[X.Logic]});C(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const a=n.get(Se.UploadFilePart);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,n)=>{var a,c,e,f,h,m,T,g,E;try{const I=this.extensionsRegistry.requestContexts(this,[X.Editor])[0];if(!I||!I.env)throw new Error("Editor context or environment missing");const A=Xe(i,i.project,"uploadFilePart"),V="["+je(i,i.project,"Upload file part")+": `"+A+"`] ",N=n.find(ve=>{var Ce,Oe;return((Oe=(Ce=ve.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Oe.id)===B.operation[Se.UploadFilePart].inputs.bucket.id}),_=(a=N==null?void 0:N.value)==null?void 0:a.valueAsType;if(!_||!_.id||!_.name||_.type!==r.DefinitionEntity)throw new Error(`${V}Invalid input "${je(N==null?void 0:N.valueOwner,I==null?void 0:I.logic,"Storage")}" (\`${Xe(N==null?void 0:N.valueOwner,I==null?void 0:I.logic,"bucket")}\`), expected a valid "Cloud file system" node.`);const L=$s(_==null?void 0:_.id,((c=I.branchHead)==null?void 0:c.identifier)||"main");if(!((I==null?void 0:I.liveResources)||[]).find(ve=>ve.resourceId===L))throw new Error(`${V}The provided storage is not live. Publish the project first, then try again to run the operation node.`);const q=n.find(ve=>{var Ce,Oe;return((Oe=(Ce=ve.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Oe.id)===B.operation[Se.UploadFilePart].inputs.key.id}),W=(e=q==null?void 0:q.value)==null?void 0:e.value;if(!W||W==="")throw new Error(`${V}The "${je(q==null?void 0:q.valueOwner,I==null?void 0:I.logic,"Key")}" (\`${Xe(q==null?void 0:q.valueOwner,I==null?void 0:I.logic,"key")}\`) input is missing.`);if(typeof W!="string")throw new Error(`${V}The "${je(q==null?void 0:q.valueOwner,I==null?void 0:I.logic,"Key")}" (\`${Xe(q==null?void 0:q.valueOwner,I==null?void 0:I.logic,"key")}\`) input value is invalid, if present, it must be a non-empty string.`);const H=n.find(ve=>{var Ce,Oe;return((Oe=(Ce=ve.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Oe.id)===B.operation[Se.UploadFilePart].inputs.uploadId.id}),te=(f=H==null?void 0:H.value)==null?void 0:f.value;if(!te||te==="")throw new Error(`${V}The "${je(H==null?void 0:H.valueOwner,I==null?void 0:I.logic,"Upload ID")}" (\`${Xe(H==null?void 0:H.valueOwner,I==null?void 0:I.logic,"uploadId")}\`) input is missing.`);if(typeof te!="string")throw new Error(`${V}The "${je(H==null?void 0:H.valueOwner,I==null?void 0:I.logic,"Upload ID")}" (\`${Xe(H==null?void 0:H.valueOwner,I==null?void 0:I.logic,"uploadId")}\`) input value is invalid, if present, it must be a non-empty string.`);const ne=n.find(ve=>{var Ce,Oe;return((Oe=(Ce=ve.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Oe.id)===B.operation[Se.UploadFilePart].inputs.partNumber.id}),z=Number((h=ne==null?void 0:ne.value)==null?void 0:h.value);if(((m=ne==null?void 0:ne.value)==null?void 0:m.value)===void 0||((T=ne==null?void 0:ne.value)==null?void 0:T.value)===null||isNaN(z)||z<=0)throw new Error(`${V}The "${je(ne==null?void 0:ne.valueOwner,I==null?void 0:I.logic,"Part number")}" (\`${Xe(ne==null?void 0:ne.valueOwner,I==null?void 0:I.logic,"partNumber")}\`) input is missing or invalid.`);const Q=n.find(ve=>{var Ce,Oe;return((Oe=(Ce=ve.valueOwner)==null?void 0:Ce.declaration)==null?void 0:Oe.id)===B.operation[Se.UploadFilePart].inputs.bytes.id}),J=(g=Q==null?void 0:Q.value)==null?void 0:g.value;if(J==null)throw new Error(`${V}The "${je(Q==null?void 0:Q.valueOwner,I==null?void 0:I.logic,"Bytes")}" (\`${Xe(Q==null?void 0:Q.valueOwner,I==null?void 0:I.logic,"bytes")}\`) input is missing.`);const ee=(E=(await Ii.get(`${I.env.API_BASE_URL}/cloud-files-service/v1/files/multipart/${te}?bucket=${L}&key=${encodeURIComponent(W)}&partNumber=${z}`,{headers:{Authorization:`Bearer ${await I.getAccessToken()}`}})).data)==null?void 0:E.uploadUrl;if(!ee)throw new Error(`${V}Failed to obtain presigned upload URL for part ${z}.`);const de=await Ii.put(ee,J,{headers:{"Content-Type":"application/octet-stream"}}),ye=de.headers.etag||de.headers.ETag||"",fe=typeof ye=="string"?ye.replace(/"/g,""):"";return{value:j.Success,error:null,result:{partNumber:z,etag:fe}}}catch(I){return{value:j.UnhandledError,error:I,result:null}}}})}}class xN extends rO{constructor(u,i,n=i.projectId){super(u,X.Editor),this._editor=i,this.id=n}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,n){return this._editor.resolveInitialChildrenPositions(u,i,n)}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,n){return this._editor.moveBranchHeadToVersion(u,i,n)}loadInitialBranchHead(){return this._editor.loadInitialBranchHead()}}function Gen(l,u){return u instanceof xN?u:new xN(l,u)}class _N extends rO{constructor(u,i){super(u,X.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 Ben(l,u){return u instanceof _N?u:new _N(l,u)}function Men(l){l.register(new Yet(l)),l.register(new zet(l)),l.register(new qet(l)),l.register(new Het(l)),l.register(new Wet(l)),l.register(new Zet(l)),l.register(new xat(l)),l.register(new _at(l)),l.register(new Vat(l)),l.register(new $at(l)),l.register(new Nat(l)),l.register(new Lat(l)),l.register(new Elt(l)),l.register(new Alt(l)),l.register(new Ilt(l)),l.register(new Rlt(l)),l.register(new Dlt(l)),l.register(new Clt(l)),l.register(new wlt(l)),l.register(new Olt(l)),l.register(new Plt(l)),l.register(new xlt(l)),l.register(new Prt(l)),l.register(new xrt(l)),l.register(new _rt(l)),l.register(new Vrt(l)),l.register(new Nrt(l)),l.register(new $rt(l)),l.register(new Lrt(l)),l.register(new Grt(l)),l.register(new Brt(l)),l.register(new Mrt(l)),l.register(new Frt(l)),l.register(new krt(l)),l.register(new Srt(l)),l.register(new Urt(l)),l.register(new jrt(l)),l.register(new Krt(l)),l.register(new qrt(l)),l.register(new Zrt(l)),l.register(new Hrt(l)),l.register(new Yrt(l)),l.register(new Jrt(l)),l.register(new Qrt(l)),l.register(new znt(l)),l.register(new Ynt(l)),l.register(new Jnt(l)),l.register(new Qnt(l)),l.register(new Xnt(l)),l.register(new ert(l)),l.register(new trt(l)),l.register(new irt(l)),l.register(new nrt(l)),l.register(new art(l)),l.register(new srt(l)),l.register(new lrt(l)),l.register(new ort(l)),l.register(new drt(l)),l.register(new ynt(l)),l.register(new Fst(l)),l.register(new Bst(l)),l.register(new Mst(l)),l.register(new fit(l)),l.register(new yit(l)),l.register(new hit(l)),l.register(new mit(l)),l.register(new Tit(l)),l.register(new vit(l)),l.register(new git(l)),l.register(new bit(l)),l.register(new Eit(l)),l.register(new $it(l)),l.register(new pnt(l)),l.register(new cnt(l)),l.register(new fnt(l)),l.register(new Ait(l)),l.register(new Iit(l)),l.register(new Rit(l)),l.register(new Dit(l)),l.register(new Cit(l)),l.register(new wit(l)),l.register(new Oit(l)),l.register(new Pit(l)),l.register(new xit(l)),l.register(new _it(l)),l.register(new Vit(l)),l.register(new Nit(l)),l.register(new Lit(l)),l.register(new Git(l)),l.register(new Bit(l)),l.register(new Mit(l)),l.register(new Fit(l)),l.register(new kit(l)),l.register(new Sit(l)),l.register(new Uit(l)),l.register(new jit(l)),l.register(new Kit(l)),l.register(new qit(l)),l.register(new Zit(l)),l.register(new tnt(l)),l.register(new int(l)),l.register(new nnt(l)),l.register(new Hit(l)),l.register(new Wit(l)),l.register(new zit(l)),l.register(new Yit(l)),l.register(new Jit(l)),l.register(new Qit(l)),l.register(new Xit(l)),l.register(new ent(l)),l.register(new jst(l)),l.register(new Kst(l)),l.register(new qst(l)),l.register(new Zst(l)),l.register(new kst(l)),l.register(new Sst(l)),l.register(new Ust(l)),l.register(new Hst(l)),l.register(new zst(l)),l.register(new Jst(l)),l.register(new Wst(l)),l.register(new Yst(l)),l.register(new Qst(l)),l.register(new tlt(l)),l.register(new Xst(l)),l.register(new elt(l)),l.register(new urt(l)),l.register(new yrt(l)),l.register(new hrt(l)),l.register(new vrt(l)),l.register(new grt(l)),l.register(new brt(l)),l.register(new Ert(l)),l.register(new Art(l)),l.register(new Irt(l)),l.register(new Rrt(l)),l.register(new Drt(l)),l.register(new mrt(l)),l.register(new Trt(l)),l.register(new Kot(l)),l.register(new qot(l)),l.register(new Zot(l)),l.register(new Hot(l)),l.register(new Wot(l)),l.register(new zot(l)),l.register(new Yot(l)),l.register(new Jot(l)),l.register(new Qot(l)),l.register(new Xot(l)),l.register(new edt(l)),l.register(new tdt(l)),l.register(new idt(l)),l.register(new ndt(l)),l.register(new rdt(l)),l.register(new adt(l)),l.register(new sdt(l)),l.register(new crt(l)),l.register(new frt(l)),l.register(new prt(l)),l.register(new rrt(l)),l.register(new wrt(l)),l.register(new Ort(l)),l.register(new Crt(l)),l.register(new Bat(l)),l.register(new lst(l)),l.register(new sst(l)),l.register(new ost(l)),l.register(new dst(l)),l.register(new kat(l)),l.register(new Sat(l)),l.register(new Hat(l)),l.register(new qat(l)),l.register(new rst(l)),l.register(new Qat(l)),l.register(new est(l)),l.register(new ist(l)),l.register(new tst(l)),l.register(new Zat(l)),l.register(new zat(l)),l.register(new Yat(l)),l.register(new Wat(l)),l.register(new Gat(l)),l.register(new Uat(l)),l.register(new Xat(l)),l.register(new cst(l)),l.register(new IN(l)),l.register(new Fat(l)),l.register(new jat(l)),l.register(new Mat(l)),l.register(new nst(l)),l.register(new Kat(l)),l.register(new Jat(l)),l.register(new ast(l)),l.register(new pst(l)),l.register(new ust(l)),l.register(new fst(l)),l.register(new IN(l)),l.register(new hst(l)),l.register(new yst(l)),l.register(new mst(l)),l.register(new fat(l)),l.register(new yat(l)),l.register(new hat(l)),l.register(new eat(l)),l.register(new zrt(l)),l.register(new rat(l)),l.register(new oat(l)),l.register(new Wrt(l)),l.register(new dat(l)),l.register(new cat(l)),l.register(new sat(l)),l.register(new aat(l)),l.register(new iD(l)),l.register(new mat(l)),l.register(new Tat(l)),l.register(new lat(l)),l.register(new pat(l)),l.register(new uat(l)),l.register(new nat(l)),l.register(new iat(l)),l.register(new tat(l)),l.register(new Xrt(l)),l.register(new bat(l)),l.register(new gat(l)),l.register(new Eat(l)),l.register(new vat(l)),l.register(new lnt(l)),l.register(new rnt(l)),l.register(new snt(l)),l.register(new ont(l)),l.register(new dnt(l)),l.register(new ant(l)),l.register(new unt(l)),l.register(new Nlt(l)),l.register(new Flt(l)),l.register(new Slt(l)),l.register(new jlt(l)),l.register(new Klt(l)),l.register(new qlt(l)),l.register(new Zlt(l)),l.register(new Mlt(l)),l.register(new klt(l)),l.register(new Ult(l)),l.register(new Blt(l)),l.register(new Glt(l)),l.register(new Llt(l)),l.register(new $lt(l)),l.register(new _lt(l)),l.register(new Vlt(l)),l.register(new Jlt(l)),l.register(new Qlt(l)),l.register(new zlt(l)),l.register(new Ylt(l)),l.register(new blt(l)),l.register(new Hlt(l)),l.register(new Wlt(l)),l.register(new eot(l)),l.register(new Xlt(l)),l.register(new tot(l)),l.register(new iot(l)),l.register(new not(l)),l.register(new Jet(l)),l.register(new Qet(l)),l.register(new eD(l)),l.register(new tD(l)),l.register(new oot(l)),l.register(new dot(l)),l.register(new cot(l)),l.register(new got(l)),l.register(new yot(l)),l.register(new uot(l)),l.register(new pot(l)),l.register(new hot(l)),l.register(new fot(l)),l.register(new mot(l)),l.register(new Tot(l)),l.register(new vot(l)),l.register(new bot(l)),l.register(new Eot(l)),l.register(new Aot(l)),l.register(new Iot(l)),l.register(new Dot(l)),l.register(new Cot(l)),l.register(new wot(l)),l.register(new Oot(l)),l.register(new Pot(l)),l.register(new xot(l)),l.register(new jot(l)),l.register(new _ot(l)),l.register(new Vot(l)),l.register(new Not(l)),l.register(new $ot(l)),l.register(new Lot(l)),l.register(new Got(l)),l.register(new Bot(l)),l.register(new Mot(l)),l.register(new Fot(l)),l.register(new kot(l)),l.register(new Sot(l)),l.register(new Uot(l)),l.register(new rot(l)),l.register(new aot(l))}class xB{constructor(u=new oe.Events("extensions-registry-fallback-events")){C(this,"extensionsRegistry",new Map);C(this,"initialized",new Set);C(this,"initializedContexts",new Set);C(this,"onResolveEditorContextCallback",()=>null);C(this,"onResolveProjectLogicContextCallback",()=>null);C(this,"onResolveEditorGUIContextCallback",()=>null);C(this,"onResolveGUIContextCallback",()=>null);C(this,"onResolveCompileContextCallback",()=>null);C(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||xe.Normal)-(i.manifest.initPriority||xe.Normal))}async setup(){Men(this),oe.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(u){switch(u){case X.Editor:return this.onResolveEditorContextCallback();case X.Logic:return this.onResolveProjectLogicContextCallback();case X.EditorGUI:return this.onResolveEditorGUIContextCallback();case X.Compile:return this.onResolveCompileContextCallback();case X.PublicationRun:return this.onResolvePublicationRunContextCallback();case X.GUI:return this.onResolveGUIContextCallback();case X.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${u}`)}}requestContexts(u,i=[]){const n=[];i.length===0&&(i=u.manifest.contexts);for(const a of i){const c=this.requestContext(a);c&&n.push(c)}return n}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 n of this.extensionInOrder)if(n.module.init&&!this.initialized.has(n.manifest.id)){const a=n.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);a.length&&(await((i=(u=n.module).init)==null?void 0:i.call(u,a)),this.initialized.add(n.manifest.id))}else!n.module.init&&!this.initialized.has(n.manifest.id)&&this.initialized.add(n.manifest.id)}async initForReady(){oe.Logger.log("Initializing extensions for ready contexts...");for(const u of this.extensionInOrder)if(u.module.init&&!this.initialized.has(u.manifest.id)){oe.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)):oe.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)?(oe.Logger.log("Set "+u.manifest.id+" extension as initialized by default..."),this.initialized.add(u.manifest.id)):oe.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)){oe.Logger.warn(`Context ${u} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(u),u){case X.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case X.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}oe.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 I1=null;const _B={requestExtension:l=>(I1||(I1=new xB,I1.setup()),I1.requestExtension(l))};function Qf(l){return!(l instanceof Error)&&typeof l=="object"&&l!==null?l:l instanceof Error?{name:l.name,message:l.message,stack:l.stack,...l}:l}function uq(l){var u,i,n;if(l&&typeof l=="object"&&"value"in l){const a=l;return{single:((u=a.value)==null?void 0:u.valueAsTypeSingle)??((i=a.value)==null?void 0:i.value),list:((n=a.value)==null?void 0:n.valueAsTypeList)??null}}return{single:l,list:Array.isArray(l)?l:null}}const Xf={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};class VN extends Error{constructor(){super("Execution was stopped"),this.name="ExecutionStoppedError"}}var VB=(l=>(l.FinishedSuccess="finished-success",l.FinishedError="finished-error",l.Running="running",l.Paused="paused",l.Stopped="stopped",l.NotStarted="not-started",l))(VB||{});const ldt={..._B,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class oT extends oe.Events{constructor(i,n,a,c=null,e=ldt){super();C(this,"project");C(this,"entryPoint");C(this,"state","not-started");C(this,"events",new oe.Events("fe-exec-inst-events"));C(this,"entities",[]);C(this,"parentExecution",null);C(this,"executing",[]);C(this,"executed",[]);C(this,"skipped",[]);C(this,"scheduled",[]);C(this,"localTestValues");C(this,"resolvedValues");C(this,"persistedExecutionResults");C(this,"lastExecutionResults");C(this,"onAddToSkippedListCallback",null);C(this,"onRemoveFromSkippedListCallback",null);C(this,"onAddEntityCallback",null);C(this,"onRemoveEntityCallback",null);C(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=n,this.entryPoint=a,this.project=i,this.parentExecution=c,this.localTestValues=new Hb(M.UUID.uuid(),this.project),this.resolvedValues=new Hb(M.UUID.uuid(),this.project),this.persistedExecutionResults=new Hb(M.UUID.uuid(),this.project),this.lastExecutionResults=new Hb(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 VN;for(;this.isPaused();){if(this.isStopped())throw new VN;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),zn.includes(i.type)&&Gt(i).forEach(n=>this.skip(n))))}async schedule(i,n,a){if(this.hasExecuted(i))return null;if(Oi.includes(i.type))return this.executeBranch(i,a,n);if(Yn.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,a,n);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,n){const a=[];return wi.includes(n.type)?a.push(...n.inputs.filter(e=>I0(e))):[...di,...Oi].includes(n.type)?a.push(...n.inputs):oi.includes(n.type)&&a.push(...n.outputs.filter(e=>I0(e))),a.map(e=>{var h;let f=i.find(m=>m.valueOwner.id===e.id);if(f)return f;if(!f&&Oi.includes(n.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 Ua.includes(e.type)?Wd(e,this.valueResolutionContext):Wc(e,this.valueResolutionContext)}).reduce((e,f)=>{const h=Hp(f==null?void 0:f.valueOwner,this.project),m=f?[f]:[];return h.forEach(T=>{var I,A,D;if(T.id===(f==null?void 0:f.valueOwner.id))return;const g=Xi(T.getDataType(null),T,this.project);g==null||g.metaSync({value:(I=f==null?void 0:f.value)==null?void 0:I.value},null),g==null||g.setValueAsTypeList(((A=f==null?void 0:f.value)==null?void 0:A.valueAsTypeList)||null),g==null||g.setValueAsTypeSingle(((D=f==null?void 0:f.value)==null?void 0:D.valueAsTypeSingle)||null);const E={...f,valueOwner:T,value:g};m.push(E)}),[...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,n,a,c={}){var f,h;this.logBeforeExecution("executeInternalCall",i,n);const e={...Xf,...c};try{let m={value:j.Success,error:null,result:null};if(n.sort((D,V)=>D.valueOwner.index-V.valueOwner.index),Object.values(wa).includes(i.declaration.id)){const D=this.parentContext.requestExtension(Gn+i.declaration.id).module.main;D?m=await D(i,n,this):oe.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{const D=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,n,a,e);m={value:D.value,error:D.error,result:D.result}}let T=null;if(m.error&&i.error){oe.Logger.warn("Raw error executing entity: ",m.error);const{single:D,list:V}=uq(m.error),N=Qf(D),_=(f=i.error)==null?void 0:f.getDataType(null),L=Xi(_||null,i.error,a);if(_!=null&&_.asType)V!==null?L==null||L.setValueAsTypeList(V):L==null||L.setValueAsTypeSingle(D);else{const K=oa(N)?JSON.stringify(N,null,2):N;L==null||L.metaSync({value:K},null)}T={valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:L}}const g=i==null?void 0:i.getDataType(null),E=Xi(g,i,a),{single:I,list:A}=uq(m.result);return g!=null&&g.asType?A!==null?E==null||E.setValueAsTypeList(A):E==null||E.setValueAsTypeSingle(I):E==null||E.metaSync({value:I},null),{value:m.value,entity:i,error:T,result:{value:E||null,valueOwner:i,type:Ze.ExecutionResult,inheritanceLink:null}}}catch(m){if(m&&(m.name==="ExecutionStoppedError"||m.message==="Execution was stopped"))throw m;oe.Logger.warn("Internal call execution error: ",m);let T=null;if(i.error){const g=Qf(m),E=(h=i.error)==null?void 0:h.getDataType(null),I=Xi(E,i.error,a);if(E!=null&&E.asType)I==null||I.setValueAsTypeSingle(m);else{const A=oa(g)?JSON.stringify(g,null,2):g;I==null||I.metaSync({value:A},null)}T={valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:I}}return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,entity:i,error:T,result:null}}}static async executeOperation(i,n,a,c){var e,f;c?c.logBeforeExecution("executeOperation",i,n):console.log(`executeOperation (${i.type}) -> [${Ee(i,a)}] Inputs:${n.length?`
62
62
  `:""}${n.map(h=>{var m,T,g;return`${(m=h.valueOwner)==null?void 0:m.type} (${(T=h.valueOwner)==null?void 0:T.id}) "${Ee(h.valueOwner,a)}": ${JSON.stringify((g=h.value)==null?void 0:g.value,null,2)}`}).join(`
63
63
  `)}
64
64
  `);try{let h={value:j.Success,error:null,result:null};n.sort((E,I)=>E.valueOwner.index-I.valueOwner.index),i.declaration.implementation&&(h=await i.declaration.implementation(i,n.sort((E,I)=>E.valueOwner.index-I.valueOwner.index)));let m=null;if(h.error&&i.error){const E=Qf(h.error),I=((e=i.error)==null?void 0:e.getDataType(null))||null,A=Xi(I,i.error,a);if(I!=null&&I.asType)A==null||A.setValueAsTypeSingle(h.error);else{const D=oa(E)?JSON.stringify(E,null,2):E;A==null||A.metaSync({value:D},null)}m={valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:A}}const T=i==null?void 0:i.getDataType(null),g=Xi(T,i,a);return T!=null&&T.asType?g==null||g.setValueAsTypeSingle(h.result):g==null||g.metaSync({value:h.result},null),{value:h.value,entity:i,error:m,result:{value:g||null,valueOwner:i,type:Ze.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=Qf(h),g=(f=i.error)==null?void 0:f.getDataType(null),E=Xi(g,i.error,a);if(g!=null&&g.asType)E==null||E.setValueAsTypeSingle(h);else{const I=oa(T)?JSON.stringify(T,null,2):T;E==null||E.metaSync({value:I},null)}m={valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:E}}return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,entity:i,error:m,result:null}}}async executeSearch(i,n,a){var c;this.logBeforeExecution("executeSearch",i,n);try{let e={value:j.Success,error:null,result:null};const f=await(await this.parentContext.requestExtension(Be.SEARCH_NODE_IMPLEMENTATION)).module.main(i,n),h=i==null?void 0:i.getDataType(null),m=Xi(h,i,a);return m==null||m.metaSync({value:f},null),f.error?{value:j.UnhandledError,entity:i,error:{valueOwner:i,type:Ze.ExecutionResult,inheritanceLink:null,value:m},result:null}:{value:e.value,entity:i,error:null,result:{value:m,valueOwner:i,type:Ze.ExecutionResult,inheritanceLink:null}}}catch(e){if(e&&(e.name==="ExecutionStoppedError"||e.message==="Execution was stopped"))throw e;if(oe.Logger.warn(`Search node execution error: ${e}`),!i.error)return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,entity:i,error:null,result:null};const f=Qf(e),h=(c=i.error)==null?void 0:c.getDataType(null),m=Xi(h,i.error,a),T=oa(f)?JSON.stringify(f,null,2):f;return m==null||m.metaSync({value:T},null),{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,entity:i,error:{valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:m},result:null}}}async executeLoop(i,n,a,c={}){var f,h,m,T,g,E,I,A,D,V,N,_,L,K,q,W,H;this.logBeforeExecution("executeLoop",i,n);const e={...Xf,...c};try{let te={value:j.Success,error:null,result:null};const ne=n.map(ye=>{var fe,ve;return((fe=ye==null?void 0:ye.value)==null?void 0:fe.valueAsType)||((ve=ye==null?void 0:ye.value)==null?void 0:ve.value)});let z={};const Q=i.body.inputs.find(ye=>ye!==i.currentIterationNumberArgumentDeclaration&&ye!==i.currentValueArgumentDeclaration);if(Q){const ye=Q,fe=Xi(ye.getDataType(null),ye,a);fe==null||fe.metaSync({value:((f=ye.defaultValue)==null?void 0:f.value)||null},null),z[ye.id]={value:fe||null,valueOwner:ye,type:Ze.ExecutionResult,inheritanceLink:null}}let J={value:j.Success,entity:i.body,error:null,result:null};switch(i.declaration.id){case B.loop["counted-loop"].id:{const ye=ne[0];let fe=1;for(;fe<=ye&&fe<=1e3;){await this.checkStateAndPause();const ve=i.body.inputs.map(Ce=>{if(Ce===i.currentIterationNumberArgumentDeclaration){const Oe=i.currentIterationNumberArgumentDeclaration.getDataType(null),Ne=jc(Oe),De=this.lastExecutionResults.readValue(Ce.id);if(De){De.metaSync({value:fe},null);const rt=wr(De,Ce);this.lastExecutionResults.writeValue(Ce,rt);const dt={value:rt,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ze.ExecutionResult,inheritanceLink:null};return z[Ce.id]=dt,dt}const Ue={id:M.UUID.uuid(),deletable:!0,editable:!0,type:r.LiteralValue,autogeneration:null,version:M.UUID.uuid(),createdAt:new Date().toISOString(),author:M.sessionAuthor,deleted:!1,previousVersion:null,value:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ne,standaloneParent:Ce.toReference()},Je=Ir(Ue,a);this.lastExecutionResults.writeValue(Ce,Je);const qe={value:Je,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ze.ExecutionResult,inheritanceLink:null};return z[Ce.id]=qe,qe}else return z[Ce.id]}).filter(Ce=>!!Ce);if(J=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),J!=null&&J.result&&J.value!==j.Return){const Ce=i.body.inputs.find(Oe=>Oe!==i.currentIterationNumberArgumentDeclaration&&Oe!==i.currentValueArgumentDeclaration);if(Ce){let Oe=(h=J.result.value)==null?void 0:h.value;Oe===void 0&&(Oe=null),(m=z[Ce.id].value)==null||m.metaSync({value:Oe},null);const Ne=wr(z[Ce.id].value,Ce);this.lastExecutionResults.writeValue(Ce,Ne)}}if([j.CaughtError,j.UnhandledError,j.Break,j.Return].includes(J.value))break;fe++}break}case B.loop["manual-flow-loop"].id:{let ye=1;for(;ye<=50;){await this.checkStateAndPause();const fe=i.body.inputs.map(ve=>{if(ve===i.currentIterationNumberArgumentDeclaration){const Ce=this.lastExecutionResults.readValue(ve.id);if(Ce){Ce.metaSync({value:ye},null);const Ue=wr(Ce,ve);this.lastExecutionResults.writeValue(ve,Ue);const Je={value:Ue,valueOwner:ve,type:Ze.ExecutionResult,inheritanceLink:null};return z[ve.id]=Je,Je}const Oe=i.currentIterationNumberArgumentDeclaration.getDataType(null),Ne=Xi(Oe,ve,a);return Ne==null||Ne.metaSync({value:ye},null),this.lastExecutionResults.writeValue(ve,Ne),{value:Ne,valueOwner:ve,type:Ze.ExecutionResult,inheritanceLink:null}}else return z[ve.id]}).filter(ve=>!!ve);if(J=await this.executeFullFunctionDeclarationLogic(i.body,fe,e),J!=null&&J.result&&J.value!==j.Return){const ve=i.body.inputs.find(Ce=>Ce!==i.currentIterationNumberArgumentDeclaration&&Ce!==i.currentValueArgumentDeclaration);if(ve){let Ce=(T=J.result.value)==null?void 0:T.value;Ce===void 0&&(Ce=null),(g=z[ve.id].value)==null||g.metaSync({value:Ce},null);const Oe=wr(z[ve.id].value,ve);this.lastExecutionResults.writeValue(ve,Oe)}}if([j.CaughtError,j.UnhandledError,j.Break,j.Return].includes(J.value))break;ye++}break}case B.loop["list-loop"].id:{const ye=ne[0];let fe=1;const ve=ye;for(let Ce=0;Ce<ve.length;Ce++){await this.checkStateAndPause();const Oe=ve[Ce],Ne=i.body.inputs.map(De=>{if(De===i.currentIterationNumberArgumentDeclaration){const Ue=this.lastExecutionResults.readValue(De.id);if(Ue){Ue.metaSync({value:fe},null);const dt=wr(Ue,De);return this.lastExecutionResults.writeValue(De,dt),{value:dt,valueOwner:De,type:Ze.ExecutionResult,inheritanceLink:null}}const Je=i.currentIterationNumberArgumentDeclaration.getDataType(null),qe=Xi(Je,De,a);return qe==null||qe.metaSync({value:fe},null),this.lastExecutionResults.writeValue(De,qe),{value:qe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ze.ExecutionResult,inheritanceLink:null}}else if(De===i.currentValueArgumentDeclaration){const Ue=i.currentValueArgumentDeclaration.getDataType(null),Je=jc(Ue),qe=this.lastExecutionResults.readValue(De.id);if(qe){qe.metaSync({value:Oe},null);const it=wr(qe,De);return this.lastExecutionResults.writeValue(De,it),{value:it,valueOwner:De,type:Ze.ExecutionResult,inheritanceLink:null}}const rt={id:M.UUID.uuid(),deletable:!0,editable:!0,type:r.LiteralValue,autogeneration:null,version:M.UUID.uuid(),createdAt:new Date().toISOString(),author:M.sessionAuthor,deleted:!1,previousVersion:null,value:Oe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Je,standaloneParent:De.toReference()},dt=Ir(rt,a);return this.lastExecutionResults.writeValue(De,dt),{value:dt,valueOwner:i.currentValueArgumentDeclaration,type:Ze.ExecutionResult,inheritanceLink:null}}else return z[De.id]}).filter(De=>!!De);if(J=await this.executeFullFunctionDeclarationLogic(i.body,Ne,e),J!=null&&J.result&&J.value!==j.Return){const De=i.body.inputs.find(Ue=>Ue!==i.currentIterationNumberArgumentDeclaration&&Ue!==i.currentValueArgumentDeclaration);if(De){let Ue=(E=J.result.value)==null?void 0:E.value;Ue===void 0&&(Ue=null),(I=z[De.id].value)==null||I.metaSync({value:Ue},null);const Je=wr(z[De.id].value,De);this.lastExecutionResults.writeValue(De,Je)}}if([j.CaughtError,j.UnhandledError,j.Break,j.Return].includes(J.value))break;fe++}break}case B.loop["object-keys-loop"].id:{const ye=ne[0];let fe=1;const ve=ye?Object.keys(ye):[];for(let Ce=0;Ce<ve.length;Ce++){await this.checkStateAndPause();const Oe=ve[Ce],Ne=i.body.inputs.map(De=>{if(De===i.currentIterationNumberArgumentDeclaration){const Ue=this.lastExecutionResults.readValue(De.id);if(Ue){Ue.metaSync({value:fe},null);const dt=wr(Ue,De);return this.lastExecutionResults.writeValue(De,dt),{value:dt,valueOwner:De,type:Ze.ExecutionResult,inheritanceLink:null}}const Je=i.currentIterationNumberArgumentDeclaration.getDataType(null),qe=Xi(Je,De,a);return qe==null||qe.metaSync({value:fe},null),this.lastExecutionResults.writeValue(De,qe),{value:qe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ze.ExecutionResult,inheritanceLink:null}}else if(De===i.currentValueArgumentDeclaration){const Ue=i.currentValueArgumentDeclaration.getDataType(null),Je=jc(Ue),qe=this.lastExecutionResults.readValue(De.id);if(qe){qe.metaSync({value:Oe},null);const it=wr(qe,De);return this.lastExecutionResults.writeValue(De,it),{value:qe,valueOwner:De,type:Ze.ExecutionResult,inheritanceLink:null}}const rt={id:M.UUID.uuid(),deletable:!0,editable:!0,type:r.LiteralValue,autogeneration:null,version:M.UUID.uuid(),createdAt:new Date().toISOString(),author:M.sessionAuthor,deleted:!1,previousVersion:null,value:Oe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Je,standaloneParent:De.toReference()},dt=Ir(rt,a);return this.lastExecutionResults.writeValue(De,dt),{value:dt,valueOwner:i.currentValueArgumentDeclaration,type:Ze.ExecutionResult,inheritanceLink:null}}else return z[De.id]}).filter(De=>!!De);if(J=await this.executeFullFunctionDeclarationLogic(i.body,Ne,e),J!=null&&J.result&&J.value!==j.Return){const De=i.body.inputs.find(Ue=>Ue!==i.currentIterationNumberArgumentDeclaration&&Ue!==i.currentValueArgumentDeclaration);if(De){let Ue=(A=J.result.value)==null?void 0:A.value;Ue===void 0&&(Ue=null),(D=z[De.id].value)==null||D.metaSync({value:Ue},null);const Je=wr(z[De.id].value,De);this.lastExecutionResults.writeValue(De,Je)}}if([j.CaughtError,j.UnhandledError,j.Break,j.Return].includes(J.value))break;fe++}break}case B.loop["object-values-loop"].id:{const ye=ne[0];let fe=1;const ve=ye?Object.values(ye):[];for(let Ce=0;Ce<ve.length;Ce++){await this.checkStateAndPause();const Oe=ve[Ce],Ne=i.body.inputs.map(De=>{if(De===i.currentIterationNumberArgumentDeclaration){const Ue=this.lastExecutionResults.readValue(De.id);if(Ue){Ue.metaSync({value:fe},null);const dt=wr(Ue,De);return this.lastExecutionResults.writeValue(De,dt),{value:dt,valueOwner:De,type:Ze.ExecutionResult,inheritanceLink:null}}const Je=i.currentIterationNumberArgumentDeclaration.getDataType(null),qe=Xi(Je,De,a);return qe==null||qe.metaSync({value:fe},null),this.lastExecutionResults.writeValue(De,qe),{value:qe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ze.ExecutionResult,inheritanceLink:null}}else if(De===i.currentValueArgumentDeclaration){const Ue=i.currentValueArgumentDeclaration.getDataType(null),Je=jc(Ue),qe=this.lastExecutionResults.readValue(De.id);if(qe){qe.metaSync({value:Oe},null);const it=wr(qe,De);return this.lastExecutionResults.writeValue(De,it),{value:qe,valueOwner:De,type:Ze.ExecutionResult,inheritanceLink:null}}const rt={id:M.UUID.uuid(),deletable:!0,editable:!0,type:r.LiteralValue,autogeneration:null,version:M.UUID.uuid(),createdAt:new Date().toISOString(),author:M.sessionAuthor,deleted:!1,previousVersion:null,value:Oe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Je,standaloneParent:De.toReference()},dt=Ir(rt,a);return this.lastExecutionResults.writeValue(De,dt),{value:dt,valueOwner:i.currentValueArgumentDeclaration,type:Ze.ExecutionResult,inheritanceLink:null}}else return z[De.id]}).filter(De=>!!De);if(J=await this.executeFullFunctionDeclarationLogic(i.body,Ne,e),J!=null&&J.result&&J.value!==j.Return){const De=i.body.inputs.find(Ue=>Ue!==i.currentIterationNumberArgumentDeclaration&&Ue!==i.currentValueArgumentDeclaration);if(De){let Ue=(V=J.result.value)==null?void 0:V.value;Ue===void 0&&(Ue=null),(N=z[De.id].value)==null||N.metaSync({value:Ue},null);const Je=wr(z[De.id].value,De);this.lastExecutionResults.writeValue(De,Je)}}if([j.CaughtError,j.UnhandledError,j.Break,j.Return].includes(J.value))break;fe++}break}case B.loop["string-loop"].id:{const ye=ne[0];let fe=1;const ve=ye.split("");for(let Ce=0;Ce<ve.length;Ce++){await this.checkStateAndPause();const Oe=ve[Ce],Ne=i.body.inputs.map(De=>{if(De===i.currentIterationNumberArgumentDeclaration){const Ue=this.lastExecutionResults.readValue(De.id);if(Ue){Ue.metaSync({value:fe},null);const dt=wr(Ue,De);return this.lastExecutionResults.writeValue(De,dt),{value:dt,valueOwner:De,type:Ze.ExecutionResult,inheritanceLink:null}}const Je=i.currentIterationNumberArgumentDeclaration.getDataType(null),qe=Xi(Je,De,a);return qe==null||qe.metaSync({value:fe},null),this.lastExecutionResults.writeValue(De,qe),{value:qe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ze.ExecutionResult,inheritanceLink:null}}else if(De===i.currentValueArgumentDeclaration){const Ue=i.currentValueArgumentDeclaration.getDataType(null),Je=jc(Ue),qe=this.lastExecutionResults.readValue(De.id);if(qe){qe.metaSync({value:Oe},null);const it=wr(qe,De);return this.lastExecutionResults.writeValue(De,it),{value:it,valueOwner:De,type:Ze.ExecutionResult,inheritanceLink:null}}const rt={id:M.UUID.uuid(),deletable:!0,editable:!0,type:r.LiteralValue,autogeneration:null,version:M.UUID.uuid(),createdAt:new Date().toISOString(),author:M.sessionAuthor,deleted:!1,previousVersion:null,value:Oe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Je,standaloneParent:De.toReference()},dt=Ir(rt,a);return this.lastExecutionResults.writeValue(De,dt),{value:dt,valueOwner:i.currentValueArgumentDeclaration,type:Ze.ExecutionResult,inheritanceLink:null}}else return z[De.id]}).filter(De=>!!De);if(J=await this.executeFullFunctionDeclarationLogic(i.body,Ne,e),(J.results||[]).forEach(De=>{var dt,ze,it;if(De.valueOwner.type!==r.InputMap||oi.includes(De.valueOwner.parent.type))return;const Ue=i.body.inputs.find(ft=>Ee(ft,a)===Ee(De.valueOwner,a)),qe=[...(dt=z[Ue.id].value)==null?void 0:dt.value,((ze=De.value)==null?void 0:ze.value)||null];(it=z[Ue.id].value)==null||it.metaSync({value:qe},null);const rt=wr(z[Ue.id].value,Ue);this.lastExecutionResults.writeValue(Ue,rt)}),[j.CaughtError,j.UnhandledError,j.Break,j.Return].includes(J.value))break;fe++}break}}let ae=j.Success;if(J.value===j.UnhandledError?i.catchesError||i.errorCalls.length?ae=j.CaughtError:ae=j.UnhandledError:[j.CaughtError,j.Return].includes(J.value)&&(ae=J.value),te={value:ae,error:((L=(_=J.error)==null?void 0:_.value)==null?void 0:L.value)||null,result:((q=(K=J==null?void 0:J.result)==null?void 0:K.value)==null?void 0:q.value)||null},te.value===j.UnhandledError||te.value===j.CaughtError){let ye=null;if(i.error){const fe=Qf(te.error),ve=(W=i.error)==null?void 0:W.getDataType(null),Ce=Xi(ve||null,i.error,a);if(ve!=null&&ve.asType)Ce==null||Ce.setValueAsTypeSingle(te.error);else{const Oe=oa(fe)?JSON.stringify(fe,null,2):fe;Ce==null||Ce.metaSync({value:Oe},null)}ye={valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:Ce}}return{value:te.value,entity:i,error:ye,result:null}}const ee=i==null?void 0:i.getDataType(null),de=Xi(ee,i,a);return ee!=null&&ee.asType?de==null||de.setValueAsTypeSingle(te.result):de==null||de.metaSync({value:te.result},null),{value:te.value,entity:i,error:null,result:{value:de||null,valueOwner:i,type:Ze.ExecutionResult,inheritanceLink:null}}}catch(te){if(te&&(te.name==="ExecutionStoppedError"||te.message==="Execution was stopped"))throw te;if(oe.Logger.warn("Error executing loop: ",te),i.error){const ne=Qf(te),z=(H=i.error)==null?void 0:H.getDataType(null),Q=Xi(z,i.error,a);if(z!=null&&z.asType)Q==null||Q.setValueAsTypeSingle(te);else{const J=oa(ne)?JSON.stringify(ne,null,2):ne;Q==null||Q.metaSync({value:J},null)}return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,entity:i,error:{valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:Q},result:null}}else return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,entity:i,error:null,result:null}}}async executeFunctionCall(i,n,a,c={}){var f,h,m,T,g,E,I,A,D,V,N,_,L,K,q,W,H,te,ne,z,Q,J,ae,ee,de,ye;const e={...Xf,...c};try{this.logBeforeExecution("executeFunctionCall",i,n);const fe=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,n,a,e);let ve=null;if(fe.error&&i.error){oe.Logger.warn("Raw error executing entity: ",fe.error);const De=(f=i.error)==null?void 0:f.getDataType(null),Ue=Xi(De||null,i.error,a);De!=null&&De.asType?(m=(h=fe.error)==null?void 0:h.value)!=null&&m.valueAsTypeSingle?Ue==null||Ue.setValueAsTypeSingle((g=(T=fe.error)==null?void 0:T.value)==null?void 0:g.valueAsTypeSingle):(I=(E=fe.error)==null?void 0:E.value)!=null&&I.valueAsTypeList&&Array.isArray((D=(A=fe.error)==null?void 0:A.value)==null?void 0:D.valueAsTypeList)&&(Ue==null||Ue.setValueAsTypeList((N=(V=fe.error)==null?void 0:V.value)==null?void 0:N.valueAsTypeList)):Ue==null||Ue.metaSync({value:(L=(_=fe.error)==null?void 0:_.value)==null?void 0:L.value},null),ve={valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:Ue}}let Ce=j.Success;fe.value===j.UnhandledError&&(i.catchesError||i.errorCalls.length?Ce=j.CaughtError:Ce=j.UnhandledError);const Oe=i==null?void 0:i.getDataType(null),Ne=Xi(Oe,i,a);return Oe!=null&&Oe.asType?(q=(K=fe.result)==null?void 0:K.value)!=null&&q.valueAsTypeSingle?Ne==null||Ne.setValueAsTypeSingle((H=(W=fe.result)==null?void 0:W.value)==null?void 0:H.valueAsTypeSingle):(ne=(te=fe.result)==null?void 0:te.value)!=null&&ne.valueAsTypeList&&Array.isArray((Q=(z=fe.result)==null?void 0:z.value)==null?void 0:Q.valueAsTypeList)&&(Ne==null||Ne.setValueAsTypeList((ae=(J=fe.result)==null?void 0:J.value)==null?void 0:ae.valueAsTypeList)):Ne==null||Ne.metaSync({value:((de=(ee=fe.result)==null?void 0:ee.value)==null?void 0:de.value)||null},null),{value:Ce,entity:i,error:ve,result:{value:Ne||null,valueOwner:i,type:Ze.ExecutionResult,inheritanceLink:null}}}catch(fe){if(fe&&(fe.name==="ExecutionStoppedError"||fe.message==="Execution was stopped"))throw fe;if(!i.error)return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,entity:i,error:null,result:null};const ve=Qf(fe),Ce=(ye=i.error)==null?void 0:ye.getDataType(null),Oe=Xi(Ce,i.error,a);if(Ce!=null&&Ce.asType)Oe==null||Oe.setValueAsTypeSingle(fe);else{const Ne=oa(ve)?JSON.stringify(ve,null,2):ve;Oe==null||Oe.metaSync({value:Ne},null)}return{value:i.catchesError||i.errorCalls.length?j.CaughtError:j.UnhandledError,entity:i,error:{valueOwner:i.error,type:Ze.ExecutionResult,inheritanceLink:null,value:Oe},result:null}}}async executeCondition(i,n){var c,e,f,h;this.logBeforeExecution("executeCondition",i,n);let a=!1;switch(i.declaration.id){case hs.BooleanIsTrue:{const m=(e=(c=n[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 hs.BooleanIsFalse:{const m=(h=(f=n[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 ba.And:{a=(await Promise.all(i.andChildrenGroup.map(async T=>{const g=this.mergeExernalValuesWithInternalInputs(n,T);return(await this.executeCondition(T,g)).value===j.Success}))).every(T=>T);break}case ba.Or:{a=(await Promise.all(i.orChildrenGroup.map(async T=>{const g=this.mergeExernalValuesWithInternalInputs(n,T);return(await this.executeCondition(T,g)).value===j.Success}))).some(T=>T);break}default:throw new Error(`Condition declaration ${i.declaration.name} does not have an implementation.`)}return{value:a?j.Success:j.ConditionNotMet,entity:i,error:null,result:null}}async executeDetachedFullFunctionDeclarationLogic(i,n,a,c={}){this.logBeforeExecution("executeDetachedFullFunctionDeclarationLogic",i,n);const e={...Xf,...c,onBeforeEntityExecution:(m,T,g)=>{var E;return((E=c==null?void 0:c.onBeforeEntityExecution)==null?void 0:E.call(c,m,T,{...g,detached:!0}))||Promise.resolve()},onEntityExecuted:(m,T,g)=>{var E;return((E=c==null?void 0:c.onEntityExecuted)==null?void 0:E.call(c,m,T,{...g,detached:!0}))||Promise.resolve()}},f=new oT(a,[i,...AD(i)],i,this,this.parentContext);return f.inheritValuesFromContext(this),await f.execute(e,n)}async executeFullFunctionDeclarationLogic(i,n,a={}){this.logBeforeExecution("executeFullFunctionDeclarationLogic",i,n);const c={...Xf,...a},e=AD(i),f=[];e.forEach(T=>{if(T.type===r.VariableDeclaration||T.type===r.VariableInstance){const g=T;g.internalCalls&&f.push(...g.internalCalls)}}),e.push(...f),console.log(`[executeFullFunctionDeclarationLogic] Reseting children for: ${Ee(i,this.project)}
package/dist/index.js CHANGED
@@ -169427,7 +169427,13 @@ function u$(l, u) {
169427
169427
  return /^\d+$/.test(g) ? parseInt(g, 10) : NaN;
169428
169428
  }
169429
169429
  return T;
169430
- }, a = (T) => typeof T == "string" ? d$(T.replace("$", "").toUpperCase()) : T, c = n(l.startRow), e = n(l.endRow), f = a(l.startColumn), h = a(l.endColumn), m = (T) => typeof T == "string" && T.includes("{{") && T.includes("}}");
169430
+ }, a = (T) => {
169431
+ if (typeof T == "string") {
169432
+ const g = T.replace("$", "").toUpperCase();
169433
+ return /^\d+$/.test(g) ? parseInt(g, 10) : d$(g);
169434
+ }
169435
+ return T;
169436
+ }, c = n(l.startRow), e = n(l.endRow), f = a(l.startColumn), h = a(l.endColumn), m = (T) => typeof T == "string" && T.includes("{{") && T.includes("}}");
169431
169437
  if (l.startRow !== void 0 && l.startRow !== null && l.startRow !== "" && isNaN(c) && !m(l.startRow))
169432
169438
  throw new Error(`${i}Start Row is invalid.`);
169433
169439
  if (l.endRow !== void 0 && l.endRow !== null && l.endRow !== "" && isNaN(e) && !m(l.endRow))
@@ -169519,8 +169525,17 @@ function tA(l, u) {
169519
169525
  }
169520
169526
  if (u$(i, u), i.namedRange && i.namedRange.trim() !== "")
169521
169527
  return i.namedRange;
169522
- const n = i._resolvedSheetName !== void 0 ? i._resolvedSheetName : typeof i.sheet == "string" ? i.sheet : void 0, a = n ? `'${n}'!` : "", c = typeof i.startColumn == "number" ? HF(i.startColumn) : i.startColumn || "", e = typeof i.startRow == "number" ? i.startRow.toString() : i.startRow || "", f = typeof i.endColumn == "number" ? HF(i.endColumn) : i.endColumn || "", h = typeof i.endRow == "number" ? i.endRow.toString() : i.endRow || "", m = `${c}${e}`, T = `${f}${h}`;
169523
- return m && T ? `${a}${m}:${T}` : m ? `${a}${m}` : a.replace(/!$/, "");
169528
+ const n = i._resolvedSheetName !== void 0 ? i._resolvedSheetName : typeof i.sheet == "string" ? i.sheet : void 0, a = n ? `'${n}'!` : "", c = (E) => {
169529
+ if (typeof E == "number")
169530
+ return HF(E);
169531
+ if (typeof E == "string") {
169532
+ const I = E.replace("$", "");
169533
+ if (/^\d+$/.test(I))
169534
+ return (E.startsWith("$") ? "$" : "") + HF(parseInt(I, 10));
169535
+ }
169536
+ return E || "";
169537
+ }, e = c(i.startColumn), f = typeof i.startRow == "number" ? i.startRow.toString() : i.startRow || "", h = c(i.endColumn), m = typeof i.endRow == "number" ? i.endRow.toString() : i.endRow || "", T = `${e}${f}`, g = `${h}${m}`;
169538
+ return T && g ? `${a}${T}:${g}` : T ? `${a}${T}` : a.replace(/!$/, "");
169524
169539
  }
169525
169540
  function eh(l, u) {
169526
169541
  if (!l)
@@ -169552,7 +169567,13 @@ function eh(l, u) {
169552
169567
  return /^\d+$/.test(E) ? parseInt(E, 10) : NaN;
169553
169568
  }
169554
169569
  return g;
169555
- }, e = (g) => typeof g == "string" ? d$(g.replace("$", "").toUpperCase()) : g, f = c(i.startRow), h = c(i.endRow), m = e(i.startColumn), T = e(i.endColumn);
169570
+ }, e = (g) => {
169571
+ if (typeof g == "string") {
169572
+ const E = g.replace("$", "").toUpperCase();
169573
+ return /^\d+$/.test(E) ? parseInt(E, 10) : d$(E);
169574
+ }
169575
+ return g;
169576
+ }, f = c(i.startRow), h = c(i.endRow), m = e(i.startColumn), T = e(i.endColumn);
169556
169577
  return f != null && (n.startRowIndex = f - 1), h != null && (n.endRowIndex = h), m != null && (n.startColumnIndex = m - 1), T != null && (n.endColumnIndex = T), n;
169557
169578
  }
169558
169579
  function T7i(l, u) {
@@ -169577,7 +169598,13 @@ function T7i(l, u) {
169577
169598
  return /^\d+$/.test(E) ? parseInt(E, 10) : NaN;
169578
169599
  }
169579
169600
  return g;
169580
- }, e = (g) => typeof g == "string" ? d$(g.replace("$", "").toUpperCase()) : g, f = c(i.startRow), h = c(i.endRow), m = e(i.startColumn), T = e(i.endColumn);
169601
+ }, e = (g) => {
169602
+ if (typeof g == "string") {
169603
+ const E = g.replace("$", "").toUpperCase();
169604
+ return /^\d+$/.test(E) ? parseInt(E, 10) : d$(E);
169605
+ }
169606
+ return g;
169607
+ }, f = c(i.startRow), h = c(i.endRow), m = e(i.startColumn), T = e(i.endColumn);
169581
169608
  return f != null ? (n.dimension = "ROWS", n.startIndex = f - 1, h != null ? n.endIndex = h : n.endIndex = f) : m != null && (n.dimension = "COLUMNS", n.startIndex = m - 1, T != null ? n.endIndex = T : n.endIndex = m), n;
169582
169609
  }
169583
169610
  class v7i extends Ve {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.7140",
3
+ "version": "0.0.7141",
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",