var e=new Set([`starting`,`running`]);function t(t){return e.has(t)}function n(e){return e===`starting`||e===`running`?`active`:e===`idle`||e===`stalled`?`idle`:`completed`}function r(e){switch(e){case`starting`:return{label:`Connecting`,tone:`sky`,pulse:!0,attention:!1};case`running`:return{label:`Working`,tone:`sky`,pulse:!0,attention:!1};case`stalled`:return{label:`Stalled`,tone:`amber`,pulse:!1,attention:!1};case`awaiting_approval`:return{label:`Pending approval`,tone:`amber`,pulse:!1,attention:!0};case`awaiting_input`:return{label:`Awaiting input`,tone:`indigo`,pulse:!1,attention:!0};case`plan_ready`:return{label:`Plan ready`,tone:`violet`,pulse:!1,attention:!0};case`completed_unseen`:return{label:`Completed`,tone:`emerald`,pulse:!1,attention:!0};case`failed`:return{label:`Failed`,tone:`red`,pulse:!1,attention:!0};case`stopped`:return{label:`Stopped`,tone:`neutral`,pulse:!1,attention:!1};case`draft`:return{label:`Ready`,tone:`neutral`,pulse:!1,attention:!1};case`idle`:return{label:`Idle`,tone:`neutral`,pulse:!1,attention:!1}}}var i=30*6e4,a=new Map;function o(e){if(e.runtimeLifecycle)return n(e.runtimeLifecycle.state);let t=new Date(e.lastActivity).getTime(),r;if(Number.isFinite(t))r=Date.now()-t<i?`idle`:`completed`;else if(e.status===`idle`||e.status===`completed`)return e.status;else return`completed`;let o=a.get(e.id),s=Date.now();if(o){let e=Number.isFinite(t)&&t>o.lastActivityMs,n={active:2,idle:1,completed:0};if(n[r]<n[o.status]&&!e&&s-o.at<6e4)return o.status}return a.set(e.id,{status:r,at:s,lastActivityMs:Number.isFinite(t)?t:0}),r}function s(e){return e<.001?`$${(e*1e3).toFixed(3)}m`:`$${e.toFixed(4)}`}function c(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:`${e}`}function l(e){return e.lastUserActivity?new Date(e.lastUserActivity).getTime():new Date(e.startedAt).getTime()}function u(e,t){return l(t)-l(e)}function d(e){let t=Math.max(0,Date.now()-new Date(e).getTime()),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}export{c as a,r as c,d as i,o as n,t as o,s as r,n as s,u as t};