import{a7 as c,a4 as a,aQ as y,h as i,e as n,m as u,u as b,k as f,aY as j,aZ as J,a_ as d,aT as A}from"./index-dNe6i2rS.js";import{g as l,J as T}from"./index-DlAh4Ixf.js";import{u as $}from"./utils-C3tzOLw4.js";import{s as _}from"./index-dHd2aGu6.js";import{m as S}from"./mergeRight-D1nsCm60.js";const q=c.injectEndpoints({endpoints:r=>({getAgentJobs:r.query({query:({projectId:e,sortBy:s=T.SUBMISSION_TIME,nameFilter:t="",lastExecState:o=[],limit:g=20,offset:p=0})=>{const m=A.stringify({expand:["creator","executions(sort_by=submissiontime:desc;offset=0;limit=10)"],limit:g,offset:p,sort_by:l(s),filter_by:["jobtype:AGENT",...t!==""?[`name:${t}`]:[],...o.length>0?[`latest_execution_state:${o.join(",")}`]:[]]});return{url:`project/${e}/jobs?${m}`}},transformResponse:i(S({items:[],count:0}),n({items:u(n({executions:{items:u($)},jobSchedule:i(b(n(_)),f(j(J("*"),"cronExpression"),d("doNotRepeat",!0)))}))})),providesTags:y.providesListItems(a.ProjectTags.AgentJob,"name")}),getAgentJobDefaultConfig:r.query({query:({projectId:e})=>({url:`project/${e}/jobs/agent/configuration`})}),getAgentJobByName:r.query({query:({pId:e,jobName:s})=>({url:`project/${e}/jobs/${s}?expand=creator`}),providesTags:(e,s,{pId:t,jobName:o})=>[{type:a.ProjectTags.AgentJob,id:`${t}-${o}`}]}),createAgentJob:r.mutation({query:({pId:e,data:s,name:t})=>({url:`project/${e}/jobs/${t}`,method:"put",data:s}),invalidatesTags:(e,s,{pId:t,name:o})=>[{type:a.ProjectTags.AgentJob,id:"LIST"},{type:a.ProjectTags.AgentJob,id:`${t}-${o}`}]})})}),{useGetAgentJobsQuery:P,useGetAgentJobDefaultConfigQuery:Q,useGetAgentJobByNameQuery:E,useCreateAgentJobMutation:G}=q;export{Q as a,G as b,E as c,P as u};
