import{by as b,aF as j,Q as x,bz as N,bA as k,R as z,p as w,bB as C,bc as F,aR as S,j as e,H as u,bC as V,M as o,bD as H,l as h,bE as m,X as A,W as v,bF as P,bG as $,bH as B,G as O,ae as L,bI as R,a3 as E,aD as W,S as G}from"./index-DTC0Ed21.js";import{u as J}from"./useTaskTypesData-DEDxUwkB.js";import{A as M}from"./useActivityData-B5503wCJ.js";import{I as Q}from"./IconArrowRight-BEyjYI9V.js";var U=b.isFinite;function _(s){return typeof s=="number"&&U(s)}const q=s=>[j.IActivityType.ChangeStatus,j.IActivityType.ChangeTask].includes(s.Type),rs=({sprintId:s,activityData:t})=>{const r=x(s),i=N(k(t,q),a=>a.Json.Changes).filter(a=>(a==null?void 0:a.FieldName)==="Status"),{statuses:n,isLoading:d}=z(r),{data:c,isLoading:l}=w.useGetAvailableStatusesQuery({ids:i.map(a=>Number(a==null?void 0:a.NewValue)).filter(_)},{skip:!i.length});return{statuses:C([...n,...c??[]],"Id"),isLoading:d||l}},g=({name:s,email:t,action:r,predicate:i,timestamp:n,nextState:d})=>{const c=F(),l=c?"white":"dark.6",a=c?"gray.6":"gray.7",{formatDate:p}=S();return e.jsxs(u,{justify:"space-between",px:8,children:[e.jsxs(u,{gap:4,c:l,children:[e.jsx(V,{email:t,name:s,hoverCardProps:{position:"bottom-start"},children:e.jsx(o,{fz:"xs",children:s})}),e.jsx(o,{fz:"xs",c:a,children:r}),e.jsx(o,{fz:"xs",fw:500,children:i}),d&&e.jsx(H,{variant:"transparent",size:16,c:a,children:e.jsx(Q,{style:{width:"80%",height:"80%"}})}),d]}),e.jsx(o,{fz:"xs",c:a,children:n&&p(n,{useTimezone:!0,format:"longWithTime"})})]})},is=({sprintId:s,activity:t,statuses:r})=>{const{t:i}=h(),n=x(s),{taskTypes:d}=J(n==null?void 0:n.ProjectId),{formatDate:c}=S();return t.Json.Changes.filter(a=>Z.includes(a.FieldName)).map((a,p)=>{var f,y;const{action:D,predicate:I}=K(a),T=!!a.OldValue&&!a.NewValue;return e.jsx(g,{name:(f=t.Author)==null?void 0:f.Name,email:(y=t.Author)==null?void 0:y.Email,action:i(`taskAction.${D}`),predicate:i(`taskActivity.${I}`),timestamp:t.Timestamp,nextState:X({predicate:a.FieldName,value:T?a.OldValue:a.NewValue,statuses:r,types:d,emptyValue:i("activities.empty"),formatDate:c})},`${t.Id}${p}`)})},K=s=>s.FieldName==="SprintId"?{action:"move",predicate:"SprintId"}:!s.OldValue&&s.NewValue?{action:"add",predicate:`${s.FieldName}`}:s.OldValue&&s.NewValue?{action:"edit",predicate:`${s.FieldName}`}:s.OldValue&&!s.NewValue?{action:"remove",predicate:`${s.FieldName}`}:{action:"",predicate:""},X=({predicate:s,value:t,statuses:r,types:i,emptyValue:n,formatDate:d})=>{if(!t)return e.jsx(o,{td:"line-through",style:{wordBreak:"normal"},children:n});if(s==="Title"&&m(t))return t;if(s==="Description")return e.jsx("div",{dangerouslySetInnerHTML:{__html:t.toString()},style:{wordBreak:"normal"}});if(s==="Status"){const c=A(r,["Id",t]);return e.jsx(v,{status:c,fz:"xs",lh:"16px",mih:20,style:{borderRadius:3}})}if(s==="PerformerId"&&!m(t))return e.jsxs(u,{gap:6,children:[e.jsx(P,{size:16,user:t}),e.jsx(o,{fz:"xs",children:t.Name})]});if(s==="Priority")return e.jsx($,{priority:t,iconSize:16,gap:4,textSize:"xs"});if(s==="SprintId")return e.jsx(Y,{sprintId:Number(t)});if(s==="TypeId")return e.jsx(B,{type:A(i,["Id",t]),iconSize:16,gap:4,textSize:"xs"});if(["StartDate","EndDate","DueDate"].includes(s)&&m(t))return e.jsx(o,{fz:"xs",children:d(t)})},Y=({sprintId:s})=>{const t=x(s);return t?e.jsxs(O,{align:"center",gap:4,visibleFrom:"xs",children:[e.jsx(L,{variant:"transparent",radius:"sm",size:16,color:t.Color||"gray.5",children:e.jsx(R,{size:14})}),e.jsx(E,{label:t.Name,openDelay:400,children:e.jsx(o,{size:"xs",truncate:"end",maw:150,children:t.Name})})]}):null},Z=["Priority","StartDate","EndDate","DueDate","PerformerId","Status","SprintId","TypeId"],ns=({activity:s,showType:t=!0})=>{const{t:r}=h(),i=s.Description.startsWith("Add");return e.jsxs(u,{wrap:"nowrap",align:"start",py:4,px:8,children:[e.jsx(W,{size:32,user:s.Author}),e.jsxs(G,{gap:6,w:"100%",children:[e.jsx(M,{activity:s,description:{action:r(`taskAction.${i?"add":"remove"}`),predicate:r("activities.typeOptions.attach"),type:t?r("activities.typeOptions.history"):void 0}}),e.jsx(o,{children:s.Json.Name})]})]})},os=({activity:s})=>{var r;const{t}=h();return e.jsx(g,{name:(r=s.Author)==null?void 0:r.Name,action:t("taskAction.create"),predicate:t("taskActivity.SprintId"),timestamp:s.Timestamp})};export{os as H,ns as a,is as b,g as c,rs as u};
