import{b3 as O,b5 as b,h as r,cI as U,v as n,aP as i,m as y,aO as T,cJ as p,cK as $,cL as N,aD as P,aw as k,a7 as A,aQ as f,a4 as m,u as z,e as h,k as J,aY as I,aZ as w,a_ as G,n as L,l as M,aC as x}from"./index-dNe6i2rS.js";import{l as v,U as q}from"./time-utils-CQYZ5msB.js";import{e as B}from"./vendor-react-wBh_31cN.js";import{j as u}from"./join-oazOKFfj.js";import{i as g}from"./includes-ucXR_9jq.js";import{a as _}from"./add-SI0q72Q7.js";import{a as S}from"./always-oSAuSdys.js";var d=_(-1);function F(t){return O(t).getTime()}const c=b(F,1);var Q={};Q.getQuartz=function(t){var e=[],a=[];if(a=K(t),a)e.push(a);else{var s=t.split(" ");a=E(s),e.push(a),s[2]!=="*"&&s[4]!=="*"&&(s[2]="*",a=E(s),e.push(a))}return e};function R(t){var e="",a;return t.split("").forEach(function(s){a=parseInt(s),isNaN(a)?e+=s:a>=0&&a<=7?e+=a+1:e=1}),e}function E(t){var e=[];e.push("0");var a=!1;return t.length===6&&t.shift(),t.forEach(function(s,o,l){if((o===0||o===1)&&e.push(s),o===2&&(s!=="?"&&(a=!0),s==="*"&&(a=!1,s="?"),e.push(s)),o===3&&e.push(s),o===4){var C=R(s);a===!0?e.push("?"):e.push(C)}if(o>=5)return!0}),e.push("*"),e}function K(t){var e=!1;return t.indexOf("@hourly")===0&&(e=["0","0","*","*","*","?","*"]),(t.indexOf("@daily")===0||t.indexOf("@midnight")===0)&&(e=["0","0","0","*","*","?","*"]),t.indexOf("@weekly")===0&&(e=["0","0","0","?","*","1","*"]),t.indexOf("@monthly")===0&&(e=["0","0","0","1","*","?","*"]),(t.indexOf("@yearly")===0||t.indexOf("@annually")===0)&&(e=["0","0","0","1","1","?","*"]),e||!1}var W=Q,Y=W,Z=Y;const H=B(Z),V=r(H.getQuartz,P,n(5,T(g("/"),r(i("/"),n(-1,p(d)),u("/")))),u(" ")),X=r(i(" "),N,$(5),n(-1,p(d)),n(-1,r(i(","),y(r(T(g("-"),r(i("-"),y(p(d)),u("-"))),T(g("/"),r(i("/"),n(0,p(d)),u("/"))))),u(","))),u(" "),U(/\?/g,"*")),ee=t=>k(t,"0 m k d L ? y"),j={u2q:V,q2u:X,qGetExact:ee},D=(t,e,a)=>({cronExpression:J(S(e),t?S(j.qGetExact(a)):j.u2q),startDateTime:e?x:r(q,c),endDateTime:e?x:z(r(q,c))}),ae={cronExpression:j.q2u,startDateTime:r(v,c),endDateTime:r(v,c),nextExecutionDateTime:r(v,c)},te=A.injectEndpoints({endpoints:t=>({addJobSchedule:t.mutation({query:({pId:e,data:{doNotRepeat:a,doNotParse:s,...o},jobName:l})=>({url:`project/${e}/jobs/${l}/schedule/v2`,method:"POST",data:r(h(D(a,s??!1,o.startDateTime)),L(M))(o)}),invalidatesTags:f.cacheByArgProperties(m.ProjectTags.JobSchedule,["pId","jobName"])}),updateJobSchedule:t.mutation({query:({pId:e,data:{doNotRepeat:a,doNotParse:s,...o},jobName:l})=>({url:`project/${e}/jobs/${l}/schedule/v2`,method:"PUT",data:h(D(a,s??!1,o.startDateTime),o)}),invalidatesTags:f.cacheByArgProperties(m.ProjectTags.JobSchedule,["pId","jobName"])}),getJobSchedule:t.query({query:({pId:e,jobName:a})=>({url:`project/${e}/jobs/${a}/schedule/v2`}),extraOptions:{skipError:!0},transformResponse:z(r(J(I(w("*"),"cronExpression"),G("doNotRepeat",!0)),h(ae))),providesTags:f.cacheByArgProperties(m.ProjectTags.JobSchedule,["pId","jobName"])}),deleteJobSchedule:t.mutation({query:({pId:e,jobName:a})=>({url:`project/${e}/jobs/${a}/schedule/v2`,method:"DELETE"})})})}),{useAddJobScheduleMutation:le,useGetJobScheduleQuery:pe,useUpdateJobScheduleMutation:de,useDeleteJobScheduleMutation:fe,util:me}=te;export{le as a,pe as b,fe as c,d,c as g,me as j,ae as s,de as u};
