import{B as $,c as m,p as o,d as b,n as g,aq as V,e as L}from"./index-B-YXshIJ.js";import{d as y,c as h}from"./index-Brfj1MB8.js";import{t as W}from"./helpers-x0Kr9bmt.js";import{e as j}from"./work-item-utils-BC5ckKim.js";const R=(e,l,t,a)=>"\n  <b>".concat(e,"</b><br />\n  Successful deployments: <b>").concat(g(l),"</b><br />\n  Total deployments: <b>").concat(g(t),"</b><br />\n  ").concat(a===void 0?"":"Total pipelines: <b>".concat(g(a),"</b>"),"\n"),x=e=>'\n  <div class="'.concat(e.width===2?"col-span-2":"",'">\n    ').concat(e.label,'\n    <div class="font-semibold">').concat(e.value,"</div>\n    ").concat(e.graphValue!==void 0&&e.graphValue<=1?'\n    <div class="rounded-md bg-gray-500 mt-1 h-1.5 w-full">\n      <div class="bg-gray-300 h-1.5 rounded-md" style="width: '.concat(e.graphValue*100,'%"></div>\n    </div>'):"","\n  </div>\n"),D=(e,l,t)=>[t?{label:l.groupLabel||"Group",value:t}:void 0,e.priority?{label:"Priority",value:"\n        <span\n          class='inline-block w-2 h-2 mr-1'\n          style='background: ".concat(V(e.priority),"'\n        ></span>\n        ").concat(e.priority,"\n      ")}:void 0,e.severity?{label:"Severity",value:e.severity}:void 0,e.rca.length?{label:"RCA",value:e.rca.join(" / "),width:2}:void 0],S=e=>'\n  <div class="grid grid-cols-2 gap-4 my-3">\n    '.concat(e.filter(L).map(x).join(""),"\n  </div>\n"),T=(e,l)=>'\n  <img src="'.concat(l.icon,'" width="14" height="14" class="inline -mt-1" />\n  <strong>#').concat(e.id,": ").concat(e.title,"</strong>\n"),C=(e,l)=>W(e)(l).filter(t=>t.start).map(t=>{var a;return{label:t.label,timeDiff:j({start:t.start.toISOString(),end:(a=t.end)==null?void 0:a.toISOString()})}}),q=({workItemType:e,cycleTime:l,workCenterTime:t,workItemTimes:a,workItemGroup:c})=>(i,d=[])=>{const s=a(i),n=l(i),f=Math.round(t(i)/n*100),v=e(i.typeId),p=i.groupId?c(i.groupId):void 0,u=s.devComplete?new Date(s.end).getTime()-new Date(s.devComplete).getTime():void 0,r=$(C(v,s).sort(y(h(m("timeDiff"))))),O=[...D(i,v,p==null?void 0:p.name),{label:"Cycle time",value:o(n)},u?{label:"Change lead time",value:o(u),graphValue:b(u,n).getOr(void 0)}:void 0,r?{label:"Longest time",value:"".concat(r.label," (").concat(o(r.timeDiff),")"),graphValue:b(r.timeDiff,n).getOr(void 0)}:void 0,{label:"Efficiency",value:"".concat(f,"%"),graphValue:f/100},...d];return'\n    <div class="w-72 pt-2">\n      '.concat(T(i,v),"\n      ").concat(S(O),"\n    </div>\n  ").trim()},E=({workItemType:e,workItemTimes:l,workItemGroup:t})=>(a,c=[])=>{const i=$(C(e(a.typeId),l(a)).sort(y(h(m("timeDiff"))))),d=a.groupId?t(a.groupId):void 0,s=[...D(a,e(a.typeId),d==null?void 0:d.name),{label:"Current status",value:a.state},{label:"Age",value:o(Date.now()-new Date(a.created.on).getTime())},i?{label:"Longest time so far",value:"".concat(i.label," (").concat(o(i.timeDiff),")"),graphValue:b(i.timeDiff,Date.now()-new Date(a.created.on).getTime()).getOr(void 0)}:void 0,...c];return'\n  <div class="w-72 pt-2">\n    '.concat(T(a,e(a.typeId)),"\n    ").concat(S(s),"\n  </div>\n").trim()};export{E as a,q as c,R as e};
