import{l as c,i$ as D,gR as l,j0 as y,j1 as p,j2 as m,j3 as j,j4 as F,j5 as d,j6 as x,j7 as Y,u as L,D as A,r as O,hH as T}from"./index-ea7817a2.js";import{s as I}from"./index-3945355b.js";import{b as G,c as R}from"./Project-80a71be4.js";import{c as C,d as H}from"./index-077fa3a4.js";var $=864e5;function U(a,t){c(2,arguments);var e=I(a),r=I(t),n=e.getTime()-D(e),i=r.getTime()-D(r);return Math.round((n-i)/$)}function z(a,t){c(2,arguments);var e=l(a),r=l(t);return e.getFullYear()-r.getFullYear()}function M(a,t){var e=a.getFullYear()-t.getFullYear()||a.getMonth()-t.getMonth()||a.getDate()-t.getDate()||a.getHours()-t.getHours()||a.getMinutes()-t.getMinutes()||a.getSeconds()-t.getSeconds()||a.getMilliseconds()-t.getMilliseconds();return e<0?-1:e>0?1:e}function _(a,t){c(2,arguments);var e=l(a),r=l(t),n=M(e,r),i=Math.abs(U(e,r));e.setDate(e.getDate()-n*i);var o=+(M(e,r)===-n),s=n*(i-o);return s===0?0:s}function k(a,t,e){c(2,arguments);var r=y(a,t)/G;return p(e==null?void 0:e.roundingMethod)(r)}function q(a,t,e){c(2,arguments);var r=y(a,t)/R;return p(e==null?void 0:e.roundingMethod)(r)}function P(a,t){c(2,arguments);var e=l(a),r=l(t),n=m(e,r),i=Math.abs(z(e,r));e.setFullYear(1584),r.setFullYear(1584);var o=m(e,r)===-n,s=n*(i-Number(o));return s===0?0:s}var J=["years","months","weeks","days","hours","minutes","seconds"];function K(a,t){var e,r,n,i,o;if(arguments.length<1)throw new TypeError("1 argument required, but only ".concat(arguments.length," present"));var s=F(),u=(e=(r=t==null?void 0:t.locale)!==null&&r!==void 0?r:s.locale)!==null&&e!==void 0?e:j,f=(n=t==null?void 0:t.format)!==null&&n!==void 0?n:J,E=(i=t==null?void 0:t.zero)!==null&&i!==void 0?i:!1,b=(o=t==null?void 0:t.delimiter)!==null&&o!==void 0?o:" ";if(!u.formatDistance)return"";var N=f.reduce(function(g,v){var S="x".concat(v.replace(/(^.)/,function(w){return w.toUpperCase()})),h=a[v];return typeof h=="number"&&(E||a[v])?g.concat(u.formatDistance(S,h)):g},[]).join(b);return N}function Q(a){c(1,arguments);var t=l(a.start),e=l(a.end);if(isNaN(t.getTime()))throw new RangeError("Start Date is invalid");if(isNaN(e.getTime()))throw new RangeError("End Date is invalid");var r={};r.years=Math.abs(P(e,t));var n=m(e,t),i=d(t,{years:n*r.years});r.months=Math.abs(x(e,i));var o=d(i,{months:n*r.months});r.days=Math.abs(_(e,o));var s=d(o,{days:n*r.days});r.hours=Math.abs(k(e,s));var u=d(s,{hours:n*r.hours});r.minutes=Math.abs(q(e,u));var f=d(u,{minutes:n*r.minutes});return r.seconds=Math.abs(Y(e,f)),r}const ee=a=>K(Q({start:0,end:a}),{format:["years","months","days","hours","minutes","seconds"],locale:{formatDistance:(t,e)=>B[t].replace("{{count}}",e)}}),B={xSeconds:"{{count}}s",xMinutes:"{{count}}m",xHours:"{{count}}h",xDays:"{{count}}d",xMonths:"{{count}}m",xYears:"{{count}}y"},te=({projectId:a,jobName:t,exectution:e})=>{const{id:r}=L(),i={pId:a??r,name:t,execId:(e==null?void 0:e.id)??0},{currentData:o}=C.getJobExecution.useQueryState(i),s=A(e??{},o??{}),u=(s==null?void 0:s.finalStatus)==="UNDEFINED"||(s==null?void 0:s.state)==="AGGREGATING_LOGS";return H(i,{skip:!u,pollingInterval:5e3}),O.useMemo(()=>({execution:s,isStillExecuting:u}),[s,u])},re=(a,t=[])=>{const e=t.filter(r=>r.state==="RUNNING").length;if(e)return{width:"fit-content",value:`${e} ${e>1?"executions":"execution"} in progress`,variant:"light",loading:!0};switch(a){case"SUCCEEDED":return{width:"fit-content",value:"Success",variant:"success"};case"FAILED":return{width:"fit-content",value:"Fail",variant:"fail"};case"IN_PROGRESS":return{width:"fit-content",value:"In progress",variant:"light",loading:!0};case"KILLED":return{width:"fit-content",value:"Killed",variant:"label"};case"UNDEFINED":return{width:"fit-content",value:"-",variant:"label",loading:!0};default:return{width:"fit-content",value:a?T(a).replaceAll("_"," "):"-",variant:"label"}}};export{re as g,ee as m,te as u};
