import{C as a}from"./gateway.9f52e1b9.js";import"./vue-router.9c189215.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[t]="8e01f290-242f-443b-9ee9-e8473bad57c2",i._sentryDebugIdIdentifier="sentry-dbid-8e01f290-242f-443b-9ee9-e8473bad57c2")}catch{}})();class l{async list(t){return a.get(`projects/${t}/builds`)}async get(t){return a.get(`builds/${t}`)}async download(t){return a.get(`builds/${t}/download`)}}const n=new l;class g{constructor(t){this.dto=t}static async list(t){return(await n.list(t)).map(r=>new g(r))}get id(){return this.dto.id}get projectId(){return this.dto.projectId}get createdAt(){return new Date(this.dto.createdAt)}get status(){return this.dto.status}get log(){return this.dto.log}get latest(){return this.dto.latest}get abstraVersion(){return this.dto.abstraVersion}async download(){const t=await n.download(this.id);if(!t)throw new Error("Download failed");window.open(t.url,"_blank")}}class d{constructor(t,s,r){this.projectId=t,this.buildId=s,this.project=r}static fromV0(t,s,r){const o={hooks:r.hooks.map(e=>({id:e.path,logQuery:{buildId:s,stageId:e.path,stageTitle:e.title},...e})),forms:r.forms.map(e=>({id:e.path,logQuery:{buildId:s,stageId:e.path,stageTitle:e.title},...e})),jobs:r.jobs.map(e=>({id:e.identifier,logQuery:{buildId:s,stageId:e.identifier,stageTitle:e.title},...e})),scripts:[]};return new d(t,s,o)}static fromDTO(t,s,r){const o={hooks:r.hooks.map(e=>({logQuery:{buildId:s,stageId:e.id,stageTitle:e.title},...e})),forms:r.forms.map(e=>({logQuery:{buildId:s,stageId:e.id,stageTitle:e.title},...e})),jobs:r.jobs.map(e=>({logQuery:{buildId:s,stageId:e.id,stageTitle:e.title},...e})),scripts:r.scripts.map(e=>({logQuery:{buildId:s,stageId:e.id,stageTitle:e.title},...e}))};return new d(t,s,o)}static async get(t){const s=await n.get(t);if(!s)throw new Error("Build not found");const{projectId:r,abstraJson:o}=s;if(!o)return null;const e=JSON.parse(o);if(!e.version)throw new Error("Version is invalid");return e.version==="0.1"?this.fromV0(r,t,e):this.fromDTO(r,t,e)}get runtimes(){return[...this.project.forms.map(t=>({...t,type:"form"})),...this.project.hooks.map(t=>({...t,type:"hook"})),...this.project.jobs.map(t=>({...t,type:"job"})),...this.project.scripts.map(t=>({...t,type:"script"}))]}}function p(i,t){return i.toLocaleString(void 0,{hour12:!1,timeZoneName:"short",day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",weekday:"long",...t})}export{g as B,d as a,l as b,p as g};
//# sourceMappingURL=datetime.2ad99619.js.map
