import{b as z,v as B,w as h,x as j,y as D,z as E,i as c,r as w,j as t,q as u,C as F,S as b,F as l,E as q,H as A,J as G,B as g,k as N,K as R,M as W}from"./index-n-59FgrC.js";import{G as p}from"./Grid-BqPdkRdY.js";import{I as H}from"./IconArrowRight-DlXTlKKx.js";import"./get-base-value-JqT_q0U7.js";const I=()=>N.dispatch(R.actions.close()),L=()=>{var m,x;const{t:i}=z(),{tasks:a,sprintId:v,onSuccess:o}=B(s=>s.diffStatusesModal),C=h((m=a==null?void 0:a.at(0))==null?void 0:m.SprintId),d=h(v),{statuses:n}=j(C),{statuses:y}=j(d),S=D((x=a??[])==null?void 0:x.map(s=>E(s.newStatus)?s.Status:void 0).filter(c).filter(s=>n.some(e=>e.Id===s))),[r,M]=w.useState({}),f=w.useMemo(()=>!!(a!=null&&a.filter(s=>n.some(e=>e.Id===s.Status)).every(s=>c(s.newStatus)||c(r[s.Status]))),[a,n,r]),T=()=>{!a||!d||!f||(W({tasks:a.map(({newStatus:s,...e})=>({...e,Status:s??r[e.Status]??e.Status})),sprint:d}),I(),o==null||o())};return t.jsxs(t.Fragment,{children:[t.jsx(u,{children:i("diffStatus.description")}),t.jsx(F,{flex:1,py:32,children:t.jsxs(p,{children:[t.jsx(p.Col,{span:{base:12,md:6},children:t.jsxs(b,{gap:16,children:[t.jsx(u,{fw:"bold",children:i("diffStatus.current")}),S.map(s=>t.jsxs(l,{gap:8,justify:"space-between",children:[t.jsx(q,{status:A(n,["Id",s])}),t.jsx(H,{color:"var(--mantine-color-gray-5)",size:20})]},s))]})}),t.jsx(p.Col,{span:{base:12,md:6},children:t.jsxs(b,{gap:16,children:[t.jsx(u,{fw:"bold",children:i("diffStatus.new")}),S.map(s=>t.jsx(l,{children:t.jsx(G,{placeholder:i("diffStatus.choose"),value:r[s],onChange:e=>M(k=>({...k,[s]:e.Id})),statuses:y||[]})},s))]})})]})}),t.jsxs(l,{gap:16,children:[t.jsx(g,{size:"md",fullWidth:!0,radius:"md",variant:"subtle",color:"dark.3",onClick:I,children:i("common.action.cancel")}),t.jsx(g,{size:"md",fullWidth:!0,radius:"md",onClick:T,disabled:!f,children:i("common.action.save")})]})]})};export{L as default};
