import{d as L,eB as $,F as j,G as P,b as n,c as m,w as s,u as e,eG as U,f as r,aA as C,ad as V,cw as E,b$ as G,eD as o,ew as T,eu as f,eC as O,e as y,cK as R,cS as K,b8 as z,cs as H}from"./outputWidgets.562826ac.js";import"./router.e5ce2c0b.js";import{B as J}from"./build.bcddcd14.js";import"./columns.29d297cf.js";import{C as M}from"./gateway.c80b0686.js";import{a as Q}from"./asyncComputed.df2d9552.js";import{t as W}from"./ant-design.1ee2ab2c.js";import{h as F}from"./index.d63b7f4e.js";import{R as X}from"./dayjs.aa493480.js";import{f as Y}from"./index.b048d0fb.js";import{A as Z}from"./Title.f7aaa881.js";import{A as w}from"./FormItem.fc4e7da8.js";import{F as q}from"./Base.bf8dc0b1.js";import{b as ee}from"./Text.712cfc26.js";import{C as te,A as ae}from"./CollapsePanel.5e649f25.js";import{A as g}from"./index.583cd440.js";import"./index.82606edc.js";import"./activeRecord.6bb1bd7f.js";import"./pubsub.7185b91b.js";import"./index.cf4c23b9.js";import"./transButton.17480f27.js";(function(){try{var p=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(p._sentryDebugIds=p._sentryDebugIds||{},p._sentryDebugIds[t]="eead4b8c-500b-4b19-b3df-970f9e5c2b2b",p._sentryDebugIdIdentifier="sentry-dbid-eead4b8c-500b-4b19-b3df-970f9e5c2b2b")}catch{}})();class le{list(t){const d=new URLSearchParams({offset:t.offset.toString(),limit:t.limit.toString(),from:t.from.getTime().toString(),to:t.to.getTime().toString(),search:t.search});return M.get(`projects/${t.projectId}/builds/${t.buildId}/logs?${d}`)}}const re=new le;class h{constructor(t,d,b,l,_,A,v){this.executionId=t,this.runtimeType=d,this.runtimeName=b,this.payload=l,this.event=_,this.buildId=A,this.createdAt=v}static fromDTO(t){return new h(t.executionId,t.runtimeType,t.runtimeName,t.payload,t.event,t.buildId,new Date(t.createdAt))}static async list(t){return(await re.list(t)).logs.map(h.fromDTO)}}const ne={key:0},se=["textContent"],oe=["textContent"],ie=["textContent"],de=["textContent"],Re=L({__name:"Logs",setup(p){function t(i){return Y(i,new Date,{addSuffix:!0})}const d=$(),b=d.params.projectId,l=j({selectedBuild:d.query.buildId||"latest",dateRange:[F().subtract(30,"days"),F()],search:"",limit:50,offset:0}),_=P(()=>c.value?[{label:"Latest",value:"latest"},{label:"All",value:"all"},...c.value.builds.map(i=>({label:`${t(i.createdAt)} (${i.id.slice(0,8)})`,value:i.id}))]:[{label:"Latest",value:"latest"},{label:"All",value:"all"}]),A=i=>{l.selectedBuild=i,I()},{loading:v,result:c,refetch:I}=Q(()=>Promise.all([h.list({projectId:b,limit:l.limit,offset:l.offset,buildId:l.selectedBuild,from:l.dateRange[0].toDate(),to:l.dateRange[1].toDate(),search:l.search}),J.list(b)]).then(([i,u])=>U({logs:i,builds:u})));return(i,u)=>(n(),m(e(R),{direction:"vertical"},{default:s(()=>{var k,x,B;return[r(e(Z),null,{default:s(()=>[C("Logs")]),_:1}),r(e(q),null,{default:s(()=>[r(e(w),{label:"Build"},{default:s(()=>[r(e(V),{value:l.selectedBuild,"onUpdate:value":u[0]||(u[0]=a=>l.selectedBuild=a),options:_.value,"option-label":"label","option-value":"value",filter:!1,onChange:A},null,8,["value","options"])]),_:1}),r(e(w),{label:"From"},{default:s(()=>[r(e(X),{value:l.dateRange,"onUpdate:value":u[1]||(u[1]=a=>l.dateRange=a)},null,8,["value"])]),_:1}),r(e(w),{label:"Search"},{default:s(()=>[r(e(E),{value:l.search,"onUpdate:value":u[2]||(u[2]=a=>l.search=a),type:"search"},null,8,["value"])]),_:1}),r(e(G),{loading:e(v),onClick:e(I)},{default:s(()=>[C("Filter")]),_:1},8,["loading","onClick"])]),_:1}),(k=e(c))!=null&&k.logs.length?(n(),m(e(ee),{key:0},{default:s(()=>[C(" Showing from "+o(l.offset+1)+" to "+o(l.offset+l.limit),1)]),_:1})):T("",!0),(x=e(c))!=null&&x.logs.length?(n(),m(e(te),{key:1,"data-source":(B=e(c))==null?void 0:B.logs,loading:e(v)},{default:s(()=>[(n(!0),f(z,null,O(e(c).logs,(a,N)=>(n(),m(e(ae),{key:N},{header:s(()=>[r(e(R),null,{default:s(()=>[l.selectedBuild=="all"?(n(),f("span",ne,o(a.buildId.split("-")[0]),1)):T("",!0),r(e(g),{type:"vertical"}),y("span",null,o(t(a.createdAt)),1),r(e(g),{type:"vertical"}),y("span",null,o(a.runtimeType)+":"+o(a.runtimeName),1),r(e(g),{type:"vertical"}),y("span",null,o(a.executionId.slice(0,8)),1),r(e(g),{type:"vertical"}),y("span",null,o(a.event),1)]),_:2},1024)]),default:s(()=>{var D,S;return[y("div",null,[a.event==="stdout"?(n(),f("pre",{key:0,textContent:o(a.payload.log)},null,8,se)):a.event==="stderr"?(n(),f("pre",{key:1,textContent:o(a.payload.log)},null,8,oe)):a.event==="program-start-failed"?(n(),f("pre",{key:2,textContent:o(a.payload.error)},null,8,ie)):a.event==="widgets-computed"&&((S=(D=a.payload.errors)==null?void 0:D.general)==null?void 0:S.repr)?(n(),f("pre",{key:3,textContent:o(a.payload.errors.general.repr)},null,8,de)):(n(),m(e(K),{key:4,"tree-data":e(W)(a.payload)},null,8,["tree-data"]))])]}),_:2},1024))),128))]),_:1},8,["data-source","loading"])):(n(),m(e(H),{key:2}))]}),_:1}))}});export{Re as default};
//# sourceMappingURL=Logs.5b972ae3.js.map
