import{O as he,c1 as nt,p as de,ad as ye,ae as fe,r as i,af as be,bT as ve,b as R,x as ot,aR as Oe,v as D,ei as rt,aj as lt,d4 as Ge,d2 as oe,j as e,bv as Ee,E as Ue,ej as it,bu as Ve,ck as at,F as $,aE as He,q as M,aI as ct,bU as xe,aw as le,bV as $e,bF as dt,u as We,G as A,V as J,a4 as ue,bR as Qe,br as ut,bG as Q,B as q,a0 as Xe,o as pt,b2 as Z,ek as ht,de as G,bb as X,c2 as ie,S as W,A as me,bM as Ye,el as je,em as xt,en as qe,Y as mt,bJ as se,bS as De,N as H,bO as Je,c3 as jt,be as gt,T as yt,L as ft,C as bt,I as vt,ab as Ke,bX as It,eo as wt,ep as Ie,h as we,ao as Ct,H as St,dY as pe,aJ as _t}from"./index-n-59FgrC.js";import{u as Ft,H as ge}from"./useTaskTypesData-CgG6u01U.js";import{T as Ce}from"./TasksSearchInput-5LSyivTU.js";import{I as Tt,G as kt}from"./GenericViewSettings-0aFJmnZF.js";import{a as re}from"./IconUser-BvK8eLe8.js";import{I as Nt,a as Bt}from"./IconSortDescending-DCVZ-bvF.js";import{r as zt}from"./const-C6xp0SqX.js";import{u as At}from"./useTasksData-B6wVLlCr.js";/**
 * @license @tabler/icons-react v3.35.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */const Mt=[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M16 15l-4 4",key:"svg-1"}],["path",{d:"M8 15l4 4",key:"svg-2"}]],Ze=he("outline","arrow-narrow-down","ArrowNarrowDown",Mt);/**
 * @license @tabler/icons-react v3.35.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */const Rt=[["path",{d:"M4 6h16",key:"svg-0"}],["path",{d:"M6 12h12",key:"svg-1"}],["path",{d:"M9 18h6",key:"svg-2"}]],Lt=he("outline","filter-2","Filter2",Rt);/**
 * @license @tabler/icons-react v3.35.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */const Pt=[["path",{d:"M5 5a5 5 0 0 1 7 0a5 5 0 0 0 7 0v9a5 5 0 0 1 -7 0a5 5 0 0 0 -7 0v-9z",key:"svg-0"}],["path",{d:"M5 21v-7",key:"svg-1"}]],et=he("outline","flag","Flag",Pt),Os=()=>{const t=nt("sprintId"),{data:n,isFetching:o}=de.useFetchProjectsQuery({States:fe(!0),ReturnDataType:ye.ProjectReturnDataType.Projects}),{data:r,isFetching:s}=de.useFetchProjectsQuery({States:fe(),ReturnDataType:ye.ProjectReturnDataType.Projects}),h=i.useMemo(()=>{const a=be((n==null?void 0:n.Projects)||[]);return ve(t)&&a.sprintEntities[t]||null},[n==null?void 0:n.Projects,t]),d=i.useMemo(()=>{const a=be((r==null?void 0:r.Projects)||[]);return ve(t)&&a.sprintEntities[t]||null},[r==null?void 0:r.Projects,t]);return{factSprint:h,sprint:d,isFetching:o||s}},Se=[{type:"type",Icon:Ge},{type:"priority",Icon:Tt},{type:"status",Icon:oe},{type:"performer",Icon:re},{type:"author",Icon:re}],K={typeIds:[],statusIds:[],priorities:[],performerIds:[],authorIds:[]},Ot=(t,n,o,r=[])=>{const{t:s}=R(),{taskTypes:h,isFetching:d}=Ft(t==null?void 0:t.rootProjectId),{statuses:a=[],isFetching:u}=ot(t),f=(n==null?void 0:n.UserIds)||[],{data:c=[],isFetching:m}=Oe.useGetByIdQuery({ids:f},{skip:!f.length}),l=D(j=>j[rt.reducerPath].currentUser.Id),p=i.useMemo(()=>{const j=c.map(C=>({...C,isCurrent:C.Id===l}));return lt(j,["isCurrent","Name"],["desc","asc"])},[c,l]),b=i.useMemo(()=>({type:s("sprintFilters.types"),status:s("sprintFilters.statuses"),priority:s("sprintFilters.priorities"),performer:s("sprintFilters.performers"),author:s("sprintFilters.authors")}),[s]),v=i.useMemo(()=>({type:s("sprintFilters.valueLabel.types"),status:s("sprintFilters.valueLabel.statuses"),priority:s("sprintFilters.valueLabel.priorities"),performer:s("sprintFilters.valueLabel.performers"),author:s("sprintFilters.valueLabel.authors")}),[s]),g=i.useMemo(()=>(r.length>0?Se.filter(C=>C.type!=="performer"):Se).map(C=>({...C,label:b[C.type],valueName:v[C.type]})),[b,v,r]),I=i.useMemo(()=>o.map(j=>j.type).filter(Boolean),[o]),x=i.useMemo(()=>g.filter(j=>!I.includes(j.type)),[g,I]),T=i.useMemo(()=>(h||[]).map(j=>({value:j.Id.toString(),node:e.jsx(Ee,{type:j})})),[h]),B=i.useMemo(()=>a.map(j=>{var C;return{value:j.Id.toString(),node:e.jsx(Ue,{status:j,withLabel:!0,filled:!1,truncate:!0,iconSize:20}),searchText:((C=j.Name)==null?void 0:C.toLowerCase())||""}}),[a]),P=i.useMemo(()=>it.map(j=>({value:j.toString(),node:e.jsx(Ve,{priority:j,withLabel:!0})})),[]),E=i.useMemo(()=>p.map(j=>({value:j.Id.toString(),node:e.jsx(at,{user:j,fullInfo:!0}),searchText:`${j.Name} ${j.Email}`.toLowerCase()})),[p]),F=i.useMemo(()=>[{value:"-1",node:e.jsxs($,{align:"center",gap:8,pl:0,w:"100%",children:[e.jsx(He,{size:34}),e.jsx(M,{fz:14,lh:"18px",truncate:!0,children:s("members.notAssigned")})]}),searchText:s("members.notAssigned").toLowerCase()},...E],[E,s]),k=o.length<5&&x.length>0,U=i.useMemo(()=>o.length===0?!1:o.every(j=>j.type&&j.values.length>0),[o]);return{taskTypes:h,statuses:a,projectUsers:c,filterTypeOptions:g,availableTypeOptions:x,typeOptions:T,statusOptions:B,priorityOptions:P,performerOptions:F,userOptionsList:E,canAddFilter:k,allFiltersHaveValues:U,isTaskTypesLoading:d,isStatusesLoading:u,isUsersLoading:m,buildPayload:j=>{const C=Y=>j.filter(V=>V.type===Y).flatMap(V=>V.values),O=Y=>Y.map(V=>Number(V)).filter(V=>!Number.isNaN(V));return{typeIds:O(C("type")),statusIds:O(C("status")),priorities:O(C("priority")),performerIds:O(C("performer")),authorIds:O(C("author"))}}}},Gs=({sprint:t})=>{const{t:n}=R(),{taskKey:o}=D(s=>s.taskModalSlice),{data:r}=ct(o);return e.jsx(ge,{children:e.jsxs("title",{children:[r?r.Title:t.Name," | ",n("appName."+xe)]})})},Es=()=>{const{t}=R();return e.jsxs(e.Fragment,{children:[e.jsx(ge,{children:e.jsxs("title",{children:["403 | ",t("appName."+xe)]})}),e.jsx(le,{description:t("archived.description"),illustration:"noAccess",buttons:[{buttonText:t("404.goHome"),handleClick:()=>$e.navigate("/")}]})]})},Us=({onClick:t})=>{const{t:n}=R();return e.jsx(le,{illustration:"noResults",title:n("nodata.noResults.title"),description:n("nodata.noResults.description"),buttons:[{buttonText:n("nodata.noResults.action"),handleClick:t}]})},Vs=()=>{const{t}=R();return e.jsxs(e.Fragment,{children:[e.jsx(ge,{children:e.jsxs("title",{children:["404 | ",t("appName."+xe)]})}),e.jsx(le,{title:t("404.title"),description:t("404.description",{entity:t("404.entities.page")}),illustration:"404",buttons:[{buttonText:t("404.goHome"),handleClick:()=>$e.navigate("/")}]})]})},Hs=({onClick:t})=>{const{t:n}=R(),o=dt();return e.jsx(le,{illustration:"noTasks",title:n("nodata.noTasks2.title"),description:n("nodata.noTasks2.description"),buttons:o.tasks.create?[{buttonText:n("nodata.noTasks2.action"),handleClick:t}]:[]})},Gt=({projectId:t,selected:n,onSelect:o})=>{const r=D(h=>h.usersCache.currentUser),{project:s}=We(t);if(Oe.useGetByIdQuery({ids:(s==null?void 0:s.UserIds)||[]},{refetchOnFocus:!0}),!!s)return e.jsx(A,{gap:12,wrap:"nowrap",pt:2,children:e.jsx(J.Group,{openDelay:300,closeDelay:100,children:e.jsx(ue.Group,{spacing:"sm",children:e.jsx(Qe,{size:32,onClick:()=>o==null?void 0:o(ut(n,[r.Id])),user:r,style:n!=null&&n.includes(r.Id)?{boxShadow:"0 0 0 2px var(--mantine-color-blue-5)",cursor:"pointer",zIndex:1}:{cursor:"pointer"}},r.Id)})})})},Et=({sprint:t,canCreate:n})=>{const{t:o}=R(),r=Q("(max-width: 576px)"),s=()=>{pt({defaultValues:{sprint:t}})};return n?r?e.jsx(q,{leftSection:e.jsx(Xe,{size:16}),onClick:s,radius:"xl",style:{position:"fixed",bottom:16,right:16,zIndex:1e3},children:o("common.action.add")}):e.jsx(q,{onClick:s,children:o("sidebar.action.addTask")}):null},Ut="_groupButton_yvi5l_1",Vt="_active_yvi5l_10",_e={groupButton:Ut,active:Vt},Fe=({groupBy:t,handleToggle:n})=>{const{t:o}=R(),r=i.useMemo(()=>o(t?`sprintGrouping.${t}`:"sprintGrouping.title"),[t,o]),s=t!=="status";return e.jsx(q,{variant:"default",size:"sm",className:Z(_e.groupButton,s&&_e.active),"aria-label":o("sprintGrouping.title"),styles:{inner:{justifyContent:"flex-start"}},leftSection:e.jsx(ht,{size:16,color:s?"#339AF0":"#31394A"}),onClick:n,children:r})},Ht="_filterButton_p5jbl_1",$t="_active_p5jbl_10",Wt="_activeFilters_p5jbl_25",Qt="_title_p5jbl_36",Xt="_filterRow_p5jbl_41",Yt="_filterRowContent_p5jbl_47",qt="_filterRowMain_p5jbl_55",Dt="_filterRowDelete_p5jbl_60",Jt="_chip_p5jbl_70",Kt="_filterControls_p5jbl_86",Zt="_filterTypeCol_p5jbl_93",es="_filterValueCol_p5jbl_97",ts="_chipWrapper_p5jbl_127",ss="_chipIcons_p5jbl_133",ns="_chipPlaceholder_p5jbl_166",os="_chipSelected_p5jbl_170",rs="_deleteButton_p5jbl_204",ls="_addButton_p5jbl_208",is="_resetButton_p5jbl_227",as="_dropdown_p5jbl_240",cs="_dropdownHeader_p5jbl_249",ds="_selectAllButton_p5jbl_256",us="_optionList_p5jbl_265",ps="_option_p5jbl_265",hs="_optionLabel_p5jbl_288",xs="_dropdownFooter_p5jbl_294",ms="_applyButton_p5jbl_300",js="_searchInput_p5jbl_304",y={filterButton:Ht,active:$t,activeFilters:Wt,title:Qt,filterRow:Xt,filterRowContent:Yt,filterRowMain:qt,filterRowDelete:Dt,chip:Jt,filterControls:Kt,filterTypeCol:Zt,filterValueCol:es,chipWrapper:ts,chipIcons:ss,chipPlaceholder:ns,chipSelected:os,deleteButton:rs,addButton:ls,resetButton:is,dropdown:as,dropdownHeader:cs,selectAllButton:ds,optionList:us,option:ps,optionLabel:hs,dropdownFooter:xs,applyButton:ms,searchInput:js},ne=t=>{const{options:n,placeholder:o,onSelect:r,selectedType:s,id:h=0,isGrouping:d}=t,[a,u]=i.useState(!1),f=Q("(max-width: 576px)"),c=s?d?n.find(x=>x.value===s):n.find(x=>x.type===s):null,m=f?"100%":175,l=f?16:12,p=f?"20px":"16px",b=f?20:16,v=c?c.Icon:null,g=c?c.label:o,I=x=>{d?r(x.value):r(x.type,h),u(!1)};return e.jsxs(G,{opened:a,onChange:u,position:"bottom-start",withinPortal:f,children:[e.jsx(G.Target,{children:e.jsx(X,{w:m,className:Z(y.chip,y.chipPlaceholder,c&&y.chipSelected),"data-opened":a,onClick:()=>u(x=>!x),children:e.jsxs(A,{gap:8,align:"center",wrap:"nowrap",style:{width:"100%"},children:[v&&e.jsx(v,{size:b,style:{flexShrink:0}}),e.jsx(M,{fz:l,lh:p,style:{flex:1,textAlign:"left"},children:g}),e.jsx(ie,{size:16,style:{flexShrink:0}})]})})}),e.jsx(G.Dropdown,{w:260,className:y.dropdown,onClick:x=>x.stopPropagation(),children:e.jsx(W,{gap:0,children:n.length?n.map(x=>{const T=d?x.value??"null":x.type,B=x.label,P=x.Icon;return e.jsx(X,{className:y.option,onClick:()=>I(x),children:e.jsxs(A,{gap:10,align:"center",children:[e.jsx(P,{size:20}),e.jsx(M,{fz:14,children:B})]})},T)}):e.jsx($,{mih:80,align:"center",justify:"center",children:e.jsx(M,{c:"gray.6",size:"sm",children:o})})})})]})},gs=({options:t,placeholder:n,onSelect:o,selectedOrder:r,disabled:s=!1})=>{const[h,d]=i.useState(!1),a=Q("(max-width: 576px)"),u=i.useMemo(()=>t.find(p=>p.value===r),[t,r]),f=a?"100%":175,c=a?16:12,m=a?"20px":"16px",l=a?20:16;return e.jsxs(G,{opened:h,onChange:d,position:"bottom-start",withinPortal:a,children:[e.jsx(G.Target,{children:e.jsx(X,{w:f,className:Z(y.chip,y.chipPlaceholder,u&&y.chipSelected),disabled:s,"data-opened":h,onClick:()=>d(p=>!p),children:e.jsxs(A,{gap:8,align:"center",wrap:"nowrap",style:{width:"100%"},children:[u&&e.jsx(u.Icon,{size:l,style:{flexShrink:0}}),e.jsx(M,{fz:c,lh:m,style:{flex:1,textAlign:"left"},children:u?u.label:n}),e.jsx(ie,{size:16,style:{flexShrink:0}})]})})}),e.jsx(G.Dropdown,{w:260,className:y.dropdown,onClick:p=>p.stopPropagation(),children:e.jsx(W,{gap:0,children:t.length?t.map(p=>e.jsx(X,{className:y.option,onClick:()=>{o(p.value),d(!1)},children:e.jsxs(A,{gap:10,align:"center",children:[e.jsx(p.Icon,{size:20}),e.jsx(M,{fz:14,children:p.label})]})},p.value)):e.jsx($,{mih:80,align:"center",justify:"center",children:e.jsx(M,{c:"gray.6",size:"sm",children:n})})})})]})},Te=({groupings:t,onGroupingsChange:n,isMobileLayout:o,isKanban:r})=>{const{t:s}=R(),h=i.useMemo(()=>[{value:"type",label:s("sprintGrouping.type"),Icon:oe},{value:"priority",label:s("sprintGrouping.priority"),Icon:et},{value:"status",label:s("sprintGrouping.status"),Icon:oe},{value:"performer",label:s("sprintGrouping.performer"),Icon:re}],[s]),d=i.useMemo(()=>[{value:"asc",label:s("sprintGrouping.ascending"),Icon:Nt},{value:"desc",label:s("sprintGrouping.descending"),Icon:Bt}],[s]),a=m=>{m&&n({groupBy:m,sortOrder:"asc"})},u=m=>{n({...t,sortOrder:m})},f=()=>{n({groupBy:null,sortOrder:null})},c=t.groupBy===null;return e.jsxs(W,{gap:0,children:[!o&&e.jsx(M,{size:"sm",className:y.title,children:s("sprintGrouping.title")}),e.jsx(W,{gap:8,children:e.jsx("div",{className:y.filterRow,children:e.jsxs("div",{className:y.filterRowContent,children:[e.jsx("div",{className:y.filterRowMain,children:e.jsxs("div",{className:y.filterControls,children:[e.jsx("div",{className:y.filterTypeCol,children:e.jsx(ne,{isGrouping:!0,options:h,placeholder:s("sprintGrouping.placeholder"),onSelect:a,selectedType:t.groupBy})}),e.jsx("div",{className:y.filterValueCol,children:e.jsx(gs,{options:d,placeholder:s("sprintGrouping.orderPlaceholder"),onSelect:u,selectedOrder:t.sortOrder,disabled:c})})]})}),e.jsx("div",{className:y.filterRowDelete,children:e.jsx(me,{variant:"subtle",color:"red",size:30,onClick:r?void 0:f,className:y.deleteButton,disabled:r||c,style:r?{opacity:.5,cursor:"not-allowed"}:void 0,children:e.jsx(Ye,{size:18})})})]})})})]})},ys={content:{borderBottomLeftRadius:0,borderBottomRightRadius:0},body:{paddingTop:8}},ke=({groupBy:t,sortOrder:n,onGroupChange:o,isKanban:r})=>{const{t:s}=R(),h=Q("(max-width: 576px)"),[d,a]=i.useState(!1),u=i.useRef(!1),[f,c]=i.useState(()=>({groupBy:t,sortOrder:n}));i.useEffect(()=>{u.current||c({groupBy:t,sortOrder:n}),u.current=!1},[t,n]);const m=i.useCallback(()=>a(b=>!b),[]),l=i.useCallback(()=>a(!1),[]),p=i.useCallback(b=>{u.current=!0,c(b),o(b.groupBy,b.sortOrder),h&&l()},[o,h,l]);return h?e.jsxs(e.Fragment,{children:[e.jsx(A,{gap:8,justify:"flex-start",children:e.jsx(Fe,{groupBy:t,handleToggle:m})}),e.jsx(je,{opened:d,onClose:l,position:"bottom",size:250,title:s("sprintGrouping.title"),withCloseButton:!0,padding:"md",radius:"lg",overlayProps:{opacity:.35,blur:2},styles:ys,children:e.jsx(Te,{groupings:f,onGroupingsChange:p,isMobileLayout:!0,isKanban:r})})]}):e.jsxs(G,{opened:d,onChange:a,position:"bottom-start",width:400,withinPortal:!1,children:[e.jsx(G.Target,{children:e.jsx("div",{children:e.jsx(Fe,{groupBy:t,handleToggle:m})})}),e.jsx(G.Dropdown,{w:420,maw:"100%",px:16,pt:8,pb:16,children:e.jsx(Te,{groupings:f,onGroupingsChange:p,isKanban:r})})]})},fs="_sortButton_v9284_1",bs="_active_v9284_11",Ne={sortButton:fs,active:bs},Be=({sortBy:t,sortByOrder:n,handleToggle:o})=>{const{t:r}=R(),s=i.useMemo(()=>r(t?`sprintSorting.${t}`:"sprintSorting.title"),[t,r]),h=t!==null,d=i.useMemo(()=>{if(t===null)return e.jsx(xt,{size:16,color:"#31394A"});if(n==="asc")return e.jsx(qe,{size:16,color:"#339AF0"});if(n==="desc")return e.jsx(Ze,{size:16,color:"#339AF0"})},[t,n]);return e.jsx(q,{variant:"default",size:"sm",className:Z(Ne.sortButton,h&&Ne.active),"aria-label":r("sprintSorting.title"),styles:{inner:{justifyContent:"flex-start"}},leftSection:d,onClick:o,children:s})},vs="_menuList_1vsp6_7",Is="_menuItem_1vsp6_11",ae={menuList:vs,menuItem:Is},ze=({groupBy:t,sorting:n,onSortingChange:o,isMobileLayout:r})=>{const{t:s}=R(),h=i.useMemo(()=>{const c=[];return t!=="type"&&c.push({value:"type",label:s("sprintSorting.type"),Icon:Ge}),t!=="priority"&&c.push({value:"priority",label:s("sprintSorting.priority"),Icon:et}),t!=="status"&&c.push({value:"status",label:s("sprintSorting.status"),Icon:oe}),t!=="performer"&&c.push({value:"performer",label:s("sprintSorting.performer"),Icon:re}),c},[t,s]),d=c=>n.sortBy!==c?null:n.sortByOrder,a=c=>{const m=d(c),l=h.find(p=>p.value===c);return l?m==="asc"?qe:m==="desc"?Ze:l.Icon:null},u=c=>{const m=d(c);o(m===null?{sortBy:c,sortByOrder:"asc"}:m==="asc"?{sortBy:c,sortByOrder:"desc"}:{sortBy:null,sortByOrder:null})},f=c=>{const m=a(c.value),l=n.sortBy===c.value,p=e.jsxs(A,{gap:10,justify:"space-between",style:{width:"100%"},wrap:"nowrap",children:[e.jsxs(A,{gap:10,wrap:"nowrap",children:[e.jsx($,{w:20,h:20,justify:"center",style:{backgroundColor:l?"#E7F5FF":void 0,borderRadius:10},children:m&&e.jsx(m,{size:l?14:20,color:l?"#339AF0":void 0})}),e.jsx(M,{fz:14,children:c.label})]}),l&&e.jsx(mt,{size:16,style:{opacity:.5}})]});return r?e.jsx(X,{className:ae.menuItem,"data-active":l,onClick:()=>u(c.value),style:{width:"100%"},children:p},c.value??"null"):e.jsx(se.Item,{className:ae.menuItem,"data-active":l,onClick:()=>u(c.value),children:p},c.value??"null")};return r?e.jsx(W,{gap:0,className:ae.menuList,children:h.map(f)}):e.jsx(e.Fragment,{children:h.map(f)})},ws={content:{borderBottomLeftRadius:0,borderBottomRightRadius:0},body:{paddingTop:8}},Ae=({groupBy:t,sortBy:n,sortByOrder:o,onSortChange:r})=>{const{t:s}=R(),h=Q("(max-width: 576px)"),[d,a]=i.useState(!1),u=i.useRef(!1),[f,c]=i.useState(()=>({sortBy:n,sortByOrder:o}));i.useEffect(()=>{u.current||c({sortBy:n,sortByOrder:o}),u.current=!1},[n,o]);const m=i.useCallback(()=>a(b=>!b),[]),l=i.useCallback(()=>a(!1),[]),p=i.useCallback(b=>{u.current=!0,c(b),r(b.sortBy,b.sortByOrder),h&&l()},[r,h,l]);return h?e.jsxs(e.Fragment,{children:[e.jsx(Be,{sortBy:n,sortByOrder:o,handleToggle:m}),e.jsx(je,{opened:d,onClose:l,position:"bottom",size:250,title:s("sprintSorting.title"),withCloseButton:!0,padding:"md",radius:"lg",overlayProps:{opacity:.35,blur:2},styles:ws,children:e.jsx(ze,{groupBy:t,sorting:f,onSortingChange:p,isMobileLayout:!0})})]}):e.jsxs(se,{opened:d,onChange:a,position:"bottom-start",withinPortal:!1,closeOnItemClick:!1,children:[e.jsx(se.Target,{children:e.jsx("div",{children:e.jsx(Be,{sortBy:n,sortByOrder:o,handleToggle:m})})}),e.jsx(se.Dropdown,{w:260,px:0,py:8,children:e.jsx(ze,{groupBy:t,sorting:f,onSortingChange:p})})]})},tt=({option:t,selected:n,onToggle:o})=>e.jsx(X,{className:y.option,onClick:o,children:e.jsxs(A,{justify:"space-between",align:"center",gap:12,wrap:"nowrap",children:[e.jsx("div",{className:y.optionLabel,children:t.node}),e.jsx(De,{checked:n,onChange:()=>{},onClick:r=>{r.stopPropagation(),o()},size:"sm",styles:{input:{cursor:"pointer"}}})]})},t.value),Cs={[H.IStatusType.BeExecuted]:10,[H.IStatusType.Active]:20,[H.IStatusType.Done]:30,[H.IStatusType.Closed]:40},Ss=(t,n)=>{const o={[H.IStatusType.BeExecuted]:[],[H.IStatusType.Active]:[],[H.IStatusType.Done]:[],[H.IStatusType.Closed]:[]},r=t.reduce((s,h)=>{let d=h.Type===H.IStatusType.Custom?H.IStatusType.BeExecuted:h.Type;if(d===H.IStatusType.NotStarted&&(d=H.IStatusType.BeExecuted),zt.includes(d)){const a=n.find(u=>u.value===h.Id.toString());if(a){const u=s[d]??[];u.push({status:h,option:a}),s[d]=u}}return s},o);return Object.entries(r).map(([s,h=[]])=>{const d=Number(s);return{type:d,order:Cs[d]??0,items:h.sort((a,u)=>a.status.Order-u.status.Order)}}).filter(s=>s.items.length>0).sort((s,h)=>s.order-h.order)},_s=({options:t,statuses:n,draft:o,setDraft:r,normalizedQuery:s})=>{const{t:h}=R(),[d,a]=i.useState({}),u=i.useMemo(()=>{const l=Ss(n,t);return s?l.map(p=>{const v=h(`enum.statusType.${p.type}`).toLowerCase().includes(s),g=p.items.filter(I=>{var x;return(x=I.option.searchText)==null?void 0:x.toLowerCase().includes(s)});return v||g.length>0?{...p,items:v?p.items:g}:null}).filter(p=>p!==null&&p.items.length>0):l.length?l:null},[n,t,s,h]),f=i.useMemo(()=>{if(!s||!u)return d;const l={...d};return u.forEach(p=>{l[p.type]=!0}),l},[s,u,d]),c=l=>{a(p=>({...p,[l]:!p[l]}))},m=l=>{r(p=>p.includes(l)?p.filter(b=>b!==l):[...p,l])};return e.jsx(Je,{type:"hover",children:u&&u.length>0?e.jsx("div",{className:y.optionList,children:u.map(l=>{const p=!!f[l.type],b=l.items.map(x=>x.option),v=b.every(x=>o.includes(x.value)),g=b.some(x=>o.includes(x.value)),I=()=>{r(v?x=>x.filter(T=>!b.some(B=>B.value===T)):x=>{const T=b.map(B=>B.value).filter(B=>!x.includes(B));return[...x,...T]})};return e.jsxs("div",{children:[e.jsx(X,{className:y.option,onClick:()=>c(l.type),style:{padding:"8px 16px"},children:e.jsxs(A,{justify:"space-between",align:"center",gap:12,wrap:"nowrap",children:[e.jsxs(A,{gap:8,align:"center",wrap:"nowrap",children:[e.jsx(me,{size:20,variant:"transparent",color:"#343A40",onClick:x=>{x.stopPropagation(),c(l.type)},children:p?e.jsx(ie,{size:20}):e.jsx(jt,{size:20})}),e.jsx(M,{fz:14,fw:400,c:"#343A40",children:h(`enum.statusType.${l.type}`)})]}),e.jsx(De,{checked:v,indeterminate:g&&!v,onChange:()=>{},onClick:x=>{x.stopPropagation(),I()},size:"sm",styles:{input:{cursor:"pointer"}}})]})}),e.jsx(gt,{in:p,children:l.items.map(x=>{const T=o.includes(x.option.value);return e.jsx("div",{style:{paddingLeft:"40px"},children:e.jsx(tt,{option:x.option,selected:T,onToggle:()=>m(x.option.value)})},x.option.value)})})]},l.type)})}):e.jsx($,{mih:120,justify:"center",align:"center",children:e.jsx(M,{c:"gray.6",size:"sm",children:h("sprintFilters.empty")})})})},Fs=({options:t,draft:n,setDraft:o,searchable:r,loading:s,searchPlaceholder:h,type:d,statuses:a})=>{const{t:u}=R(),[f,c]=i.useState(""),m=f.trim().toLowerCase(),l=i.useMemo(()=>m?t.filter(g=>{var I;return(I=g.searchText)==null?void 0:I.includes(m)}):t,[m,t]),p=g=>{o(I=>I.includes(g)?I.filter(x=>x!==g):[...I,g])},b=l.length>0&&l.every(g=>n.includes(g.value)),v=()=>{o(b?[]:l.map(g=>g.value))};return e.jsxs(W,{gap:0,children:[r&&e.jsx(yt,{value:f,onChange:g=>c(g.currentTarget.value),placeholder:h,size:"xs",radius:4,className:y.searchInput,mb:4}),e.jsxs("div",{className:y.dropdownHeader,children:[e.jsx(M,{fz:11,c:"gray.6",fw:400,tt:"uppercase",children:u(`sprintFilters.valuePlural.${d}`)}),l.length>0&&e.jsx(X,{onClick:v,className:y.selectAllButton,children:e.jsx(M,{fz:12,c:"blue.6",fw:500,children:u(b?"sprintFilters.deselectAll":"sprintFilters.selectAll")})})]}),s&&!t.length?e.jsx($,{mih:120,justify:"center",align:"center",children:e.jsx(ft,{size:20})}):d==="status"&&a?e.jsx(_s,{options:t,statuses:a,draft:n,setDraft:o,normalizedQuery:m}):e.jsx(Je,{type:"hover",children:l.length?e.jsx("div",{className:y.optionList,children:l.map(g=>{const I=n.includes(g.value);return e.jsx(tt,{option:g,selected:I,onToggle:()=>p(g.value)},g.value)})}):e.jsx($,{mih:120,justify:"center",align:"center",children:e.jsx(M,{c:"gray.6",size:"sm",children:u("sprintFilters.empty")})})})]})},ce=5,Me=9,Ts=({filter:t,filterOption:n,options:o,loading:r,searchable:s,searchPlaceholder:h,onValuesChange:d,taskTypes:a=[],statuses:u=[],projectUsers:f=[]})=>{const{t:c}=R(),[m,l]=i.useState(!1),[p,b]=i.useState(t.values),v=Q("(max-width: 576px)");i.useEffect(()=>{m||b(t.values)},[m,t.values]);const g=()=>{t.type&&(d(t.type,p,!0),l(!1))},I=t.values.length,x=i.useMemo(()=>o.map(_=>_.value),[o]),T=v?20:16,B=v?20:18,P=i.useMemo(()=>t.values.length?["author","performer"].includes(n.type)?e.jsxs(ue.Group,{spacing:7,children:[t.values.slice(0,Me).map(_=>{if(_==="-1")return e.jsx(J,{label:c("members.notAssigned"),withArrow:!0,children:e.jsx(He,{size:B})},_);const j=f.find(C=>C.Id.toString()===_);return j?e.jsx(Qe,{size:B,user:j},_):null}),t.values.length>Me&&e.jsx(ue,{style:{borderColor:"#4DABF7",background:"#FFFFFF"},size:B,color:"#4DABF7",children:"..."})]}):e.jsxs(e.Fragment,{children:[t.values.slice(0,ce).map(_=>{switch(n.type){case"status":{const j=u.find(C=>C.Id.toString()===_);return j?e.jsx(J,{label:j.Name,children:e.jsx(Ue,{status:j,withLabel:!1,filled:!1,iconSize:T},_)},j.Name):null}case"priority":{const j=Number(_);return e.jsx(J,{label:c("taskPriorities."+j),children:e.jsx(Ve,{priority:j,withLabel:!1,iconSize:T},_)},j)}case"type":{const j=a==null?void 0:a.find(C=>C.Id.toString()===_);return j?e.jsx(J,{label:j.Name,children:e.jsx(Ee,{type:j,withLabel:!1,iconSize:T},_)},j.Name):null}default:return null}}).filter(Boolean),t.values.length>ce?e.jsx(M,{fz:12,c:"#343A40",children:`+${t.values.length-ce}`}):null]}):null,[t.values,n.type,u,a,f,B,T,c]),E=v?"100%":175,F=v?16:12,k=v?"20px":"16px",U=t.type&&["performer","author"].includes(t.type)?300:260;return e.jsx("div",{className:y.chipWrapper,children:e.jsxs(G,{opened:m,onChange:l,position:"bottom-start",withinPortal:v,shadow:"md",children:[e.jsx(G.Target,{children:e.jsx(X,{className:y.chip,size:32,w:E,"data-opened":m,onClick:()=>l(_=>!_),children:e.jsxs(A,{gap:8,align:"center",wrap:"nowrap",w:"100%",children:[x.length===I?e.jsx(M,{fz:F,lh:k,c:"#343A40",children:c(`sprintFilters.allValue.${n.type}`)}):I>0&&P?e.jsx(A,{gap:4,align:"center",wrap:"nowrap",className:y.chipIcons,style:{flex:1},children:P}):e.jsx(M,{fz:F,lh:k,truncate:"end",c:"#A4B0C2E5",style:{flex:1},children:n.valueName}),e.jsx($,{gap:0,ml:"auto",children:e.jsx(ie,{size:16})})]})})}),e.jsx(G.Dropdown,{w:U,className:y.dropdown,onClick:_=>_.stopPropagation(),children:e.jsxs(W,{gap:0,children:[e.jsx(Fs,{options:o,draft:p,setDraft:b,searchable:s,loading:r,searchPlaceholder:h,type:n.type,statuses:n.type==="status"?u:void 0}),e.jsx("div",{className:y.dropdownFooter,children:e.jsx(q,{size:"xs",onClick:g,className:y.applyButton,children:c("sprintFilters.apply")})})]})})]})})},Re=({sprint:t,project:n,filters:o,onFiltersChange:r,onApply:s,performerIds:h=[]})=>{const{t:d}=R(),a=Q("(max-width: 576px)"),{taskTypes:u,statuses:f,projectUsers:c,filterTypeOptions:m,typeOptions:l,statusOptions:p,priorityOptions:b,performerOptions:v,userOptionsList:g,canAddFilter:I,allFiltersHaveValues:x,isTaskTypesLoading:T,isStatusesLoading:B,isUsersLoading:P,buildPayload:E}=Ot(t,n,o,h),F=i.useMemo(()=>o.map(w=>w.type).filter(Boolean),[o]),k=i.useMemo(()=>m.filter(w=>!F.includes(w.type)),[m,F]),U=w=>{const z=o.map((S,N)=>N!==w?S.type:null).filter(Boolean);return m.filter(S=>!z.includes(S.type))},_=w=>{r(z=>{const S=z.filter((N,L)=>L!==w);return s==null||s(E(S),!1),S})},j=()=>{I&&r(w=>[...w,{values:[]}])},C=w=>{r(z=>[...z,{type:w,values:[]}])},O=(w,z=0)=>{r(S=>S.map((N,L)=>L===z?{type:w,values:[]}:N))},Y=(w,z,S)=>{const N=o.map(L=>L.type===w?{...L,values:z}:L);r(N),S&&(s==null||s(E(N),!1))},V=()=>{r([]),s==null||s(K,!1)},ee=(w,z)=>{const S=w.type?m.find(st=>st.type===w.type):null;let N=[],L=!1,te=!1;if(w.type)switch(w.type){case"type":N=l,L=T;break;case"status":N=p,L=B,te=!0;break;case"priority":N=b;break;case"performer":N=v,L=P,te=!0;break;case"author":N=g,L=P,te=!0;break}return e.jsx("div",{className:y.filterRow,children:e.jsxs("div",{className:y.filterRowContent,children:[e.jsx("div",{className:y.filterRowMain,children:w.type?S?e.jsxs("div",{className:y.filterControls,children:[e.jsx("div",{className:y.filterTypeCol,children:e.jsx(ne,{id:z,options:U(z),placeholder:S.label,onSelect:O,selectedType:w.type})}),e.jsx("div",{className:y.filterValueCol,children:e.jsx(Ts,{filter:w,filterOption:S,options:N,taskTypes:u??[],statuses:f??[],projectUsers:c,loading:L,searchable:te,searchPlaceholder:d("sprintFilters.search"),onValuesChange:Y})})]}):null:e.jsx(ne,{id:z,options:k,placeholder:d("sprintFilters.placeholder"),onSelect:O})}),w.type&&e.jsx("div",{className:y.filterRowDelete,children:e.jsx(me,{variant:"subtle",color:"red",size:30,onClick:()=>_(z),className:y.deleteButton,children:e.jsx(Ye,{size:18})})})]})},z)};return e.jsxs(W,{gap:0,children:[!a&&e.jsx(M,{size:"sm",className:y.title,children:d("sprintFilters.title")}),o.length>0?e.jsx(W,{gap:8,children:o.map((w,z)=>ee(w,z))}):e.jsx("div",{className:y.filterRow,children:e.jsx(ne,{options:m,placeholder:d("sprintFilters.placeholder"),onSelect:C})}),e.jsxs($,{my:a?8:5,justify:"space-between",children:[e.jsx(bt,{children:I&&e.jsx(q,{variant:"default",size:"compact-md",leftSection:e.jsx(Xe,{size:15}),className:y.addButton,onClick:j,disabled:!x,children:d("sprintFilters.add")})}),o.length>0&&e.jsx($,{justify:"flex-end",children:e.jsx(q,{variant:"subtle",size:"compact-md",className:y.resetButton,onClick:V,color:"red",children:d("sprintFilters.deleteAll")})})]})]})},Le=({filters:t,handleToggleFilters:n,resetFilters:o})=>{const{t:r}=R(),[s,h]=i.useState(!1),d=i.useMemo(()=>t.filter(a=>a.values.length>0).length,[t]);return e.jsx(q,{variant:"default",size:"sm",className:Z(y.filterButton,d&&y.active),"aria-label":r("sprintFilters.title"),styles:{inner:{justifyContent:"flex-start"}},leftSection:e.jsx(Lt,{size:16,color:d?"#339AF0":"#31394A"}),rightSection:s&&d?e.jsx(vt,{size:16,onClick:a=>{o(),a.stopPropagation()}}):d>0&&e.jsx(M,{className:y.activeFilters,children:d}),onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onClick:n,children:r("sprintFilters.title")})},Pe=({sprint:t,project:n,filters:o,onFiltersChange:r,onApply:s,resetFilters:h,performerIds:d=[]})=>{const{t:a}=R(),u=Q("(max-width: 576px)"),[f,c]=i.useState(!1),m=i.useCallback(()=>c(v=>!v),[]),l=i.useCallback(()=>c(!1),[]),p=i.useCallback((v,g)=>{s(v,g),g&&l()},[s,l]),b=i.useCallback(()=>{h(),l()},[h,l]);return u?e.jsxs(e.Fragment,{children:[e.jsx(A,{gap:8,justify:"flex-start",children:e.jsx(Le,{filters:o,handleToggleFilters:m,resetFilters:b})}),e.jsx(je,{opened:f,onClose:l,position:"bottom",size:"70%",title:a("sprintFilters.title"),withCloseButton:!0,padding:"md",radius:"lg",overlayProps:{opacity:.35,blur:2},styles:{content:{borderBottomLeftRadius:0,borderBottomRightRadius:0},body:{paddingTop:8}},children:e.jsx(Re,{sprint:t,project:n,filters:o,onFiltersChange:r,onApply:p,performerIds:d})})]}):e.jsxs(G,{opened:f,onChange:c,position:"bottom-start",width:400,withinPortal:!1,children:[e.jsx(G.Target,{children:e.jsx("div",{children:e.jsx(Le,{filters:o,handleToggleFilters:m,resetFilters:b})})}),e.jsx(G.Dropdown,{w:420,maw:"100%",px:16,py:8,children:e.jsx(Re,{sprint:t,project:n,filters:o,onFiltersChange:r,onApply:p,performerIds:d})})]})},$s=({sprintData:t,search:n,setSearch:o,performerIds:r,setPerformerIds:s,loading:h,onFiltersApply:d,filters:a,setFilters:u})=>{const f=Ke(),c=It(t.rootProjectId),m=wt(),l=!!Ie(we.sprintTimeline,m.pathname),p=!!Ie(we.sprintKanban,m.pathname),b=Q("(max-width: 768px)"),v=Q("(max-width: 576px)"),{project:g}=We(t.ProjectId),{data:I}=Ct.useGetCountersQuery(),x=i.useMemo(()=>St(I,["Id",t.Id]),[I,t.Id]),T=((x==null?void 0:x.TotalCount)??0)>0,B=a.length>0,P=T||B,E=!v||T,F=D(S=>{var N;return(N=S.settingsSlice.sprints)==null?void 0:N[t.Id]}),k=F==null?void 0:F.groupBy,U=p?k??"status":k===void 0?"status":k,_=(F==null?void 0:F.sortOrder)??"asc",j=(F==null?void 0:F.sortBy)??null,C=(F==null?void 0:F.sortByOrder)??"asc";i.useEffect(()=>{u([])},[t.Id,u]),i.useEffect(()=>{(r==null?void 0:r.length)>0&&u(S=>S.some(L=>L.type==="performer")?S.filter(L=>L.type!=="performer"):S)},[r]);const O=i.useCallback(S=>{d(S)},[d]),Y=i.useCallback((S,N)=>{f(pe({sprintId:t.Id.toString(),settings:{groupBy:S,sortOrder:N}}))},[f,t.Id]),V=i.useCallback((S,N)=>{f(pe({sprintId:t.Id.toString(),settings:{sortBy:S,sortByOrder:N}}))},[f,t.Id]),ee=i.useCallback(S=>{s(S),u([]),O(K)},[s,u,O]),w=i.useCallback(()=>{u([]),O(K)},[u,O]),z=i.useMemo(()=>e.jsxs(e.Fragment,{children:[(g==null?void 0:g.rootProjectId)&&e.jsx(Gt,{projectId:g.rootProjectId,selected:r,onSelect:ee}),E&&e.jsx(Et,{sprint:t,canCreate:c.tasks.create}),!l&&e.jsx(kt,{})]}),[c.tasks.create,l,r,g==null?void 0:g.rootProjectId,ee,t,E]);return b?e.jsx(W,{gap:12,children:e.jsxs(W,{gap:12,children:[e.jsxs(A,{gap:8,align:"center",wrap:"nowrap",justify:"space-between",children:[e.jsx(Ce,{value:n,onChange:o,loading:h,size:"sm",style:{maxWidth:"300px",minWidth:0,flexShrink:1}}),e.jsx(A,{gap:8,align:"center",wrap:"nowrap",children:z})]}),P&&e.jsxs($,{style:{overflow:"auto"},children:[e.jsx(Ae,{groupBy:l?null:U,sortBy:j,sortByOrder:C,onSortChange:V}),!l&&e.jsx(ke,{groupBy:U,sortOrder:_,onGroupChange:Y,isKanban:p}),e.jsx(Pe,{sprint:t,project:g,filters:a,onFiltersChange:u,onApply:O,resetFilters:w,performerIds:r})]})]})}):e.jsxs(A,{justify:"space-between",gap:16,align:"center",children:[e.jsx(A,{style:{gap:"16px 24px"},flex:1,children:e.jsx(Ce,{value:n,onChange:o,loading:h})}),e.jsxs(A,{gap:12,align:"center",wrap:"nowrap",children:[P&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{groupBy:l?null:U,sortBy:j,sortByOrder:C,onSortChange:V}),!l&&e.jsx(ke,{groupBy:U,sortOrder:_,onGroupChange:Y,isKanban:p}),e.jsx(Pe,{sprint:t,project:g,filters:a,onFiltersChange:u,onApply:O,resetFilters:w,performerIds:r})]}),z]})]})},ks=t=>de.useGetAvailableStatusesQuery({entityType:(t==null?void 0:t.statusesEntityType)||0,entityIds:[(t==null?void 0:t.statusesEntityId)||0]},{skip:!t}),Ws=({sprintData:t,projectData:n})=>{var x,T,B,P,E,F;const o=Ke(),r=D(k=>k.usersCache.currentUser.Id),s=D(k=>{var U,_;return(_=(U=k.settingsSlice.sprints)==null?void 0:U[t.Id])==null?void 0:_.performerIds}),[h,d]=_t(""),[a,u]=i.useState(K),{groupedBySprint:f,error:c,isError:m,isLoading:l,isFetching:p,isSearching:b}=At({sprintId:t.Id,performerIds:((x=a.performerIds)==null?void 0:x.length)>0?a.performerIds:s,search:h,typeIds:a.typeIds,statusIds:a.statusIds,priorities:a.priorities,authorIds:a.authorIds}),v=!!(s!=null&&s.length)||b||((T=a.typeIds)==null?void 0:T.length)>0||((B=a.statusIds)==null?void 0:B.length)>0||((P=a.priorities)==null?void 0:P.length)>0||((E=a.authorIds)==null?void 0:E.length)>0||((F=a.performerIds)==null?void 0:F.length)>0,g=i.useCallback(k=>{o(pe({sprintId:t.Id.toString(),settings:{performerIds:k}}))},[o,t.Id]),I=i.useCallback(k=>{u({typeIds:k.typeIds,statusIds:k.statusIds,priorities:k.priorities,authorIds:k.authorIds,performerIds:k.performerIds})},[]);return i.useEffect(()=>{u(K)},[t.Id]),i.useEffect(()=>{s!=null&&s.length&&(s.includes(r)?g([r]):g([]))},[]),ks(n),i.useMemo(()=>({sprintData:t,search:h,setSearch:d,error:c,performerIds:s,handleAssign:g,handleFiltersApply:I,appliedFilters:a,isFetching:p,isError:m,isLoading:l,groupedBySprint:f,withFilters:v}),[c,f,a,g,I,m,p,l,s,h,d,t,v])};export{Es as A,K as E,Vs as N,Gs as S,Ws as a,$s as b,Us as c,Hs as d,Os as u};
