PageSourceSearch

https://creativ-ai.com/_next/static/chunks/app/collections/%5Bcollection_id%5D/tasks/page-d49ce5fbf0bed9e4.js

js creativ-ai.com collected 2026-10-03 21:15:23 UTC 56,254 bytes, 10 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5572],{5968:(e,t,s)=>{"use strict";s.d(t,{L4:()=>g,Sc:()=>o,UA:()=>p,Zw:()=>b,cq:()=>u,de:()=>x,rK:()=>m});var a=s(26708),r=s(35625),l=s(48934),i=s(66609),n=s(91752),d=s(35831);let c=(e,t)=>{if("string"==typeof e&&e.trim())return e;if(e&&"object"==typeof e){let t=e.message;if("string"==typeof t&&t.trim())return t}return t},o=e=>(0,a.I)({queryKey:["collectionGroups",e],queryFn:()=>(0,d.P$)(e),enabled:!!e,staleTime:3e5}),m=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:e=>(0,d.wj)(e),onSuccess:(t,s)=>{t.success?e.invalidateQueries({queryKey:["collectionGroups",s.collection_id]}):i.toast.error(c(t.error,"Failed to create group. Please try a different name."))},onError:()=>{i.toast.error("Failed to create group. Please try again.")}})},x=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:e=>(0,d.Ic)(e),onSuccess:(t,s)=>{t.success&&(e.invalidateQueries({queryKey:["collectionGroups",s.collection_id]}),e.invalidateQueries({queryKey:n.LT.members(s.collection_id)}),e.refetchQueries({queryKey:n.LT.members(s.collection_id),type:"active"}))}})},u=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:e=>(0,d.Ni)(e),onSuccess:(t,s)=>{if(t.success){i.toast.success(t.data?.message||"Group deleted successfully."),e.invalidateQueries({queryKey:["collectionGroups",s.collection_id]}),e.invalidateQueries({queryKey:n.LT.members(s.collection_id)}),e.refetchQueries({queryKey:n.LT.members(s.collection_id),type:"active"});return}i.toast.error(c(t.error,"Failed to delete group. Please try again."))},onError:()=>{i.toast.error("Failed to delete group. Please try again.")}})},p=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:e=>(0,d.jK)(e),onSuccess:(t,s)=>{t.success&&(e.invalidateQueries({queryKey:n.LT.members(s.collection_id)}),e.invalidateQueries({queryKey:["membersByGroup",s.collection_id]}),e.refetchQueries({queryKey:n.LT.members(s.collection_id),type:"active"}))}})},g=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:e=>(0,d.ZH)(e),onSuccess:(t,s)=>{t.success&&(e.invalidateQueries({queryKey:n.LT.members(s.collection_id)}),e.invalidateQueries({queryKey:["membersByGroup",s.collection_id]}),e.refetchQueries({queryKey:n.LT.members(s.collection_id),type:"active"}))}})},b=(e,t)=>(0,a.I)({queryKey:["membersByGroup",e,t],queryFn:()=>(0,d.yy)({collection_id:e,group_name:t||""}),enabled:!!e&&!!t,staleTime:3e5})},26518:(e,t,s)=>{"use strict";s.d(t,{l:()=>d});var a=s(95155),r=s(12115),l=s(66088),i=s(61878),n=s(94514);let d=({options:e,value:t,onChange:s,placeholder:d="Select an option...",disabled:c=!1,className:o="",icon:m,searchable:x=!1,searchPlaceholder:u="Search...",renderOption:p,renderValue:g})=>{let[b,h]=(0,r.useState)(!1),[k,v]=(0,r.useState)(""),f=(0,r.useRef)(null),j=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&(h(!1),v(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,r.useEffect)(()=>{b&&x&&j.current&&setTimeout(()=>j.current?.focus(),50)},[b,x]);let y=e.find(e=>e.value===t),N=x&&k?e.filter(e=>e.label.toLowerCase().includes(k.toLowerCase())):e;return(0,a.jsxs)("div",{ref:f,className:`relative ${o}`,children:[(0,a.jsxs)("button",{type:"button",onClick:()=>!c&&h(!b),disabled:c,className:`
2          w-full px-3.5 h-11 bg-(--mk-surface) border border-(--mk-card-border) rounded-xl
3          focus:outline-none focus:border-(--mk-green-border-strong)
4          transition-all text-sm text-left flex items-center justify-between gap-3
5          ${c?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-(--mk-green-border)"}
6        `,children:[(0,a.jsx)("div",{className:"flex items-center gap-2 flex-1",children:g?g(y):(0,a.jsxs)(a.Fragment,{children:[m&&(0,a.jsx)("span",{className:"text-primary",children:m}),(0,a.jsx)("span",{className:y?"text-(--mk-text) font-medium":"text-(--mk-text-3)",children:y?.label||d})]})}),(0,a.jsx)(l.A,{size:16,className:`text-(--mk-text-3) transition-transform shrink-0 ${b?"rotate-180":""}`})]}),b&&!c&&(0,a.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-2 bg-(--mk-modal-bg) border border-(--mk-card-border-strong) rounded-2xl overflow-hidden z-50",style:{boxShadow:"0 16px 40px -8px rgba(0,0,0,0.35)"},children:[x&&(0,a.jsx)("div",{className:"px-2 pt-2 pb-1 border-b border-(--mk-divider)",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 bg-(--mk-surface) rounded-lg border border-(--mk-card-border)",children:[(0,a.jsx)(i.A,{size:13,className:"text-(--mk-text-3) shrink-0"}),(0,a.jsx)("input",{ref:j,type:"text",value:k,onChange:e=>v(e.target.value),placeholder:u,className:"flex-1 text-sm bg-transparent outline-none text-(--mk-text) placeholder:text-(--mk-text-3)"}),k&&(0,a.jsx)("button",{type:"button",onClick:()=>v(""),className:"text-(--mk-text-3) hover:text-(--mk-text)",children:"\xd7"})]})}),(0,a.jsxs)("div",{className:"py-1 max-h-56 overflow-y-auto",children:[0===N.length?(0,a.jsx)("p",{className:"px-3.5 py-3 text-sm text-(--mk-text-3)",children:"No results found"}):null,N.map(e=>{let r=t===e.value;return(0,a.jsxs)("button",{type:"button",onClick:()=>{s(e.value),h(!1),v("")},className:`
7                    w-full px-3.5 py-2.5 text-left text-sm flex items-center justify-between
8                    transition-colors border-b border-(--mk-divider) last:border-b-0
9                    ${r?"bg-(--mk-green-bg) text-(--mk-green-text) font-medium":"text-(--mk-text) hover:bg-(--mk-surface)"}
10                  `,children:[p?p(e,r):(0,a.jsx)("span",{children:e.label}),!p&&r&&(0,a.jsx)(n.A,{size:16,className:"text-(--mk-green-text)"})]},e.value)})]})]})]})}},31882:(e,t,s)=>{"use strict";s.d(t,{HI:()=>j,bq:()=>P,P4:()=>A,W6:()=>S,mS:()=>w,I:()=>_,vj:()=>C,Sj:()=>F,EZ:()=>$,f_:()=>M,G5:()=>T});var a=s(26708),r=s(35625),l=s(48934),i=s(66609),n=s(86589);let d="/api/v2/tasks",c=async e=>(await n.A.post(`https://creativai-apis.com${d}/create`,e)).data,o=async e=>(await n.A.post(`https://creativai-apis.com${d}/update`,e)).data,m=async e=>(await n.A.post(`https://creativai-apis.com${d}/cancel`,e)).data,x=async e=>(await n.A.post(`https://creativai-apis.com${d}/update-status`,e)).data,u=async e=>(await n.A.post(`https://creativai-apis.com${d}/update-progress`,e)).data,p=async e=>(await n.A.post(`https://creativai-apis.com${d}/add-comment`,e)).data,g=async e=>(await n.A.post(`https://creativai-apis.com${d}/list`,e)).data,b=async e=>(await n.A.post(`https://creativai-apis.com${d}/get`,e)).data,h=async e=>(await n.A.post(`https://creativai-apis.com${d}/activity`,e)).data,k=async e=>(await n.A.post(`https://creativai-apis.com${d}/my-tasks`,e)).data,v=async e=>(await n.A.post(`https://creativai-apis.com${d}/delete`,e)).data;var f=s(81008);let j={all:["collectionTasks"],listBase:(e,t)=>[...j.all,"list",e,t],list:(e,t,s)=>[...j.listBase(e,t),s],detail:(e,t)=>[...j.all,"detail",e,t],activity:(e,t)=>[...j.all,"activity",e,t]},y=(e,t)=>"string"==typeof e?e:e&&"object"==typeof e&&"string"==typeof e.message&&e.message.trim()?e.message:t,N=async(e,t,s)=>
10{await e.invalidateQueries({queryKey:j.listBase(t,"all")}),await e.invalidateQueries({queryKey:j.listBase(t,"my")}),s&&(await e.invalidateQueries({queryKey:j.detail(t,s)}),await e.invalidateQueries({queryKey:j.activity(t,s)}))},_=(e,t="all")=>{let{isAuthenticated:s,loading:r}=(0,f.A)(),l="all"===e.collection_id,i="my"===t?{status:e.status,page_size:e.page_size,last_evaluated_key:e.last_evaluated_key}:{status:e.status,priority:e.priority,assigned_to:e.assigned_to,group:e.group,overdue_only:e.overdue_only,page_size:e.page_size,last_evaluated_key:e.last_evaluated_key};return(0,a.I)({queryKey:j.list(e.collection_id,t,i),queryFn:()=>"my"===t?k({collection_id:e.collection_id,status:e.status,page_size:e.page_size,last_evaluated_key:e.last_evaluated_key}):g(e),enabled:s&&!r&&!!e.collection_id&&!l,staleTime:6e4,retry:1})},w=e=>{let{isAuthenticated:t,loading:s}=(0,f.A)();return(0,a.I)({queryKey:e?j.detail(e.collection_id,e.task_id):[...j.all,"detail","none"],queryFn:()=>b(e),enabled:t&&!s&&!!e?.collection_id&&!!e?.task_id,staleTime:3e4,retry:1})},S=e=>{let{isAuthenticated:t,loading:s}=(0,f.A)();return(0,a.I)({queryKey:e?j.activity(e.collection_id,e.task_id):[...j.all,"activity","none"],queryFn:()=>h(e),enabled:t&&!s&&!!e?.collection_id&&!!e?.task_id,staleTime:3e4,retry:1})},C=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:c,onSuccess:async(t,s)=>{t.success?(await N(e,s.collection_id),i.toast.success(t.data?.message||"Task created successfully")):i.toast.error(y(t.error,"Failed to create task. Please try again."))}})},$=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:o,onSuccess:async(t,s)=>{t.success?(await N(e,s.collection_id,s.task_id),i.toast.success(t.data?.message||"Task updated")):i.toast.error(y(t.error,"Failed to update task. Please try again."))}})},A=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:m,onSuccess:async(t,s)=>{t.success?(await N(e,s.collection_id,s.task_id),i.toast.success(t.data?.message||"Task canceled")):i.toast.error(y(t.error,"Failed to cancel task. Please try again."))}})},T=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:x,onSuccess:async(t,s)=>{t.success?(await N(e,s.collection_id,s.task_id),i.toast.success(t.data?.message||"Task status updated")):i.toast.error(y(t.error,"Failed to update task status. Please try again."))}})},M=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:u,onSuccess:async(t,s)=>{t.success?(await N(e,s.collection_id,s.task_id),i.toast.success(t.data?.message||"Task progress updated")):i.toast.error(y(t.error,"Failed to update task progress. Please try again."))}})},P=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:p,onSuccess:async(t,s)=>{t.success?(await N(e,s.collection_id,s.task_id),i.toast.success(t.data?.message||"Comment added")):i.toast.error(y(t.error,"Failed to add comment. Please try again."))}})},F=()=>{let e=(0,r.jE)();return(0,l.n)({mutationFn:v,onSuccess:async(t,s)=>{t.success?(await N(e,s.collection_id),i.toast.success(t.data?.message||"Task deleted")):i.toast.error(y(t.error,"Failed to delete task. Please try again."))}})}},35547:(e,t,s)=>{Promise.resolve().then(s.bind(s,98677))},39658:(e,t,s)=>{"use strict";s.d(t,{p:()=>i});var a=s(95155),r=s(12115),l=s(91337);let i=r.forwardRef(({className:e,type:t,...s},r)=>(0,a.jsx)("input",{type:t,className:(0,l.cn)("flex h-11 w-full rounded-xl border border-(--mk-card-border) bg-(--mk-surface) text-(--mk-text) px-3.5 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-(--mk-text-3) focus:outline-none focus:border-(--mk-green-border-strong) hover:border-(--mk-green-border) transition-colors disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...s}));i.displayName="Input"},91337:(e,t,s)=>{"use strict";s.d(t,{cn:()=>l,n:()=>i});var a=s(29722),r=s(622);function l(...e){return(0,r.QP)((0,a.$)(e))}function i(e,t="us-east-1"){if(!e?.startsWith("s3://"))return e;let s=e.replace(/^s3:\/\//,""),a=s.indexOf("/"),r=s.substring(0,a),l=s.substring(a+1);return`https://${r}.s3.${t}.amazonaws.com/${l}`}},98677:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>Z});var a=s(95155),r=s(12115),l=s(73321),i=s(13545),n=s(81008),d=s(98670),c=s(66785),o=s(35625),m=s(90426),x=s(82396),u=s(66609),p=s(31882),g=s(5968),b=s(91752),h=s(95609),k=s(33210);let v=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}
10],f=()=>({id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:"",selectedUserIds:[],assignedGroups:[],slices:[],selectedColumns:[]}),j=(e,t,s,a)=>{if(""===e.trim())return t;let r=Number.parseInt(e,10);return Number.isNaN(r)?t:Math.max(s,Math.min(a,r))},y=(e,t)=>{if(e<=0||0===t.length)return new Map;let s=t.map(e=>({...e,weight:Math.max(0,e.weight)})).filter(e=>e.weight>0);if(0===s.length)return new Map;let a=s.reduce((e,t)=>e+t.weight,0),r=s.map(t=>{let s=e*t.weight/a,r=Math.floor(s);return{id:t.id,base:r,remainder:s-r}}),l=r.reduce((e,t)=>e+t.base,0),i=new Map(r.map(e=>[e.id,e.base])),n=[...r].sort((e,t)=>t.remainder-e.remainder),d=0;for(;l<e&&n.length>0;){let e=n[d%n.length];i.set(e.id,(i.get(e.id)||0)+1),l+=1,d+=1}return i},N=({isOpen:e,isSubmitting:t,mode:s,initialTask:l,groupOptions:n,onClose:d,onSubmit:c,collectionId:o})=>{let x,u,p="edit"===s&&l?.title||"",g="edit"===s&&l?.description||"",N="edit"===s&&l?.priority||"medium",_="edit"===s?(e=>{if(!e)return"";let t=new Date(e);if(Number.isNaN(t.getTime()))return"";let s=t.getFullYear(),a=`${t.getMonth()+1}`.padStart(2,"0"),r=`${t.getDate()}`.padStart(2,"0"),l=`${t.getHours()}`.padStart(2,"0"),i=`${t.getMinutes()}`.padStart(2,"0");return`${s}-${a}-${r}T${l}:${i}`})(l?.due_date):"",w="edit"===s&&l?.assigned_users||[],S="edit"===s&&l?.assigned_groups||[],[C,$]=(0,r.useState)(p),[A,T]=(0,r.useState)(g),[M,P]=(0,r.useState)(N),[F,z]=(0,r.useState)(_),[I,E]=(0,r.useState)(w),[q,K]=(0,r.useState)(S),[O,L]=(0,r.useState)("general"),[D,G]=(0,r.useState)("auto"),[Q,U]=(0,r.useState)("segment_wise"),[B,H]=(0,r.useState)("dedicated"),[R,W]=(0,r.useState)(""),[V,Z]=(0,r.useState)([f()]),[Y,X]=(0,r.useState)({}),[J,ee]=(0,r.useState)(""),{data:et}=(0,b.r)(o),{data:es}=(0,h.x)(o),ea=(0,r.useMemo)(()=>(et?.data?.members||[]).filter(e=>!!e.user_id).map(e=>({value:e.user_id,label:e.user_email})),[et?.data?.members]),er=(0,r.useMemo)(()=>new Map(ea.map(e=>[e.value,e.label])),[ea]),el=(0,r.useMemo)(()=>{let e=new Map;for(let t of et?.data?.members||[])for(let s of t.groups||[])e.set(s,(e.get(s)||0)+1);return e},[et?.data?.members]),ei=(0,r.useMemo)(()=>(Array.isArray(es?.data)?es.data:[]).map(e=>({value:e.plate_id,label:`${e.name} (${e.segment_count} segments)`,data:e})),[es]),en=(0,r.useMemo)(()=>(Array.isArray(es?.data)?es.data:[]).find(e=>e.plate_id===R)||null,[es,R]),ed=(0,r.useMemo)(()=>(en?.columns||[]).map(e=>({value:e,label:e})),[en?.columns]),ec=en?.segment_count??0,eo=(0,r.useMemo)(()=>{if("create"!==s||"data_plate_verification"!==O||"auto"!==D||!R)return null;if(ec<=0)return{warning:"Selected data plate has no segments.",rows:[]};if(0===I.length&&0===q.length)return{warning:"Select at least one user or group to preview distribution.",rows:[]};if("column_wise"===Q)return{info:"Column-wise allocation depends on selected columns and backend grouping rules.",rows:[]};let e=[],t=I.length,a=q.map(e=>({id:e,weight:Math.max(1,el.get(e)||0)})),r=[];t>0&&r.push({id:"__individual_users__",weight:t}),r.push(...a);let l=y(ec,r),i=l.get("__individual_users__")||0;if(I.length>0){let t=y(i,I.map(e=>({id:e,weight:1})));for(let s of I)e.push({label:er.get(s)||s,type:"user",count:t.get(s)||0})}for(let t of q)e.push({label:t,type:"group",count:l.get(t)||0});return{rows:e,total:ec}},[s,O,D,R,ec,I,q,Q,el,er]),em="create"===s?"Create Task":"Edit Task",ex="create"===s?"Assign users and/or groups.":"Updating assignees replaces current assignments.",eu=(e,t)=>{Z(s=>s.map(s=>s.id===e?t(s):s))},ep=(e,t,s)=>`${e}:${t}:${s}`,eg=(e,t,s,a)=>{let r=ep(e,t,s);return Object.prototype.hasOwnProperty.call(Y,r)?Y[r]:String(a)},eb=(e,t,s,a)=>{let r=ep(e,t,s);X(e=>({...e,[r]:a}))},eh=(e,t,s)=>{let a=ep(e,t,s);X(e=>{if(!Object.prototype.hasOwnProperty.call(e,a))return e;let t={...e};return delete t[a],t})},ek=e=>{X(t=>{let s=`${e}:`,a=Object.entries(t).filter(([e])=>!e.startsWith(s));return a.length===Object.keys(t).length?t:Object.fromEntries(a)})},ev="create"===s&&"data_plate_verification"===O,ef=ev&&"custom"===D;return e?(0,a.jsx)("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4 animate-in fade-in duration-200",children:(0,a.jsxs)("div",{className:"w-full max-w-2xl bg-(--mk-modal-bg) rounded-2xl border border-(--mk-card-border-strong) shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200",children:[(0,a.jsxs)("div",{className:"px-5 py-4 border-b border-(--mk-divider) bg-(--mk-modal-bg) flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold text-(--mk-text)",children:em}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-(--mk-text-3) mt-0.5",children:ex})]}),(0,a.jsx)("button",{type:"button",onClick:d,className:"w-8 h-8 inline-flex items-center justify-center rounded-lg text-(--mk-text-3) hover:text-(--mk-text) hover:bg-(--mk-surface) dark:hover:text-white",children:(0,a.jsx)(k.A,{size:16})})]}),(0,a.jsxs)("div",{className:"p-5 space-y-5 max-h-[70vh] overflow-y-auto",children:["create"===s&&(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:"Task Type"}),(0,a.jsx)(m.l6,{className:"mt-2",options:[{value:"general",label:"General Task"},{value:"data_plate_verification",label:"Data Plate Verification"}],value:O,onChange:e=>L(e)})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:["Title ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)(m.pd,{value:C,onChange:e=>$(e.target.value),maxLength:200,placeholder:"Enter task title",className:"mt-2"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:"Description"}),(0,a.jsx)(m.TM,{value:A,onChange:e=>T(e.target.value),maxLength:2e3,placeholder:"Add details",rows:4,className:"mt-2"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:"Priority"}),(0,a.jsx)(m.l6,{className:"mt-2",options:v,value:M,onChange:e=>P(e)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:"Due Date"}),(0,a.jsx)(m.pd,{className:"mt-2",type:"datetime-local",value:F,onChange:e=>z(e.target.value),min:(x=new Date,u=e=>String(e).padStart(2,"0"),`${x.getFullYear()}-${u(x.getMonth()+1)}-${u(x.getDate())}T${u(x.getHours())}:${u(x.getMinutes())}`)})]})]}),ev&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:["Distribution Mode ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)(m.l6,{className:"mt-2",options:[{value:"auto",label:"Auto Mode"},{value:"custom",label:"Custom Mode"}],value:D,onChange:e=>{G(e),"custom"===e&&H("dedicated")}})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:["Sub-Plate Type ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)(m.l6,{className:"mt-2",options:[{value:"segment_wise",label:"Segment-wise"},{value:"column_wise",label:"Column-wise"}],value:Q,onChange:e=>U(e)})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:["Data Plate ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)(m.l6,{className:"mt-2",options:ei,value:R,onChange:e=>{W(e)},searchable:!0,searchPlaceholder:"Search data plates...",placeholder:ei.length>0?"Select data plate":"No data plates available",disabled:0===ei.length}),R&&(0,a.jsxs)("p",{className:"mt-1 text-xs text-(--mk-text-3)",children:["Total segments: ",e
10c]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:["Verification Mode ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)(m.l6,{className:"mt-2",options:[{value:"dedicated",label:"Dedicated (single reviewer per sub-plate)"},..."auto"===D?[{value:"shared",label:"Shared (all assignees review each segment)"}]:[]],value:B,onChange:e=>H(e)})]})]}),("edit"===s||!ev||"auto"===D)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:"Assigned Users"}),(0,a.jsx)(m.KF,{className:"mt-2",options:ea,value:I,onChange:E,placeholder:ea.length>0?"Select users":"No members available",disabled:0===ea.length})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:"Assigned Groups"}),(0,a.jsx)(m.KF,{className:"mt-2",options:n,value:q,onChange:K,placeholder:n.length>0?"Select groups":"No groups available",disabled:0===n.length}),(0,a.jsx)("p",{className:"mt-1 text-xs text-(--mk-text-3)",children:"At least one user or group is required."})]}),ev&&"auto"===D&&eo&&(0,a.jsxs)("div",{className:"rounded-lg border border-(--mk-card-border) bg-(--mk-surface)/60 p-3 space-y-2",children:[(0,a.jsx)("p",{className:"text-xs font-semibold text-(--mk-text)",children:"Auto Distribution Preview"}),"warning"in eo&&eo.warning&&(0,a.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:eo.warning}),"info"in eo&&eo.info&&(0,a.jsx)("p",{className:"text-xs text-(--mk-text-3)",children:eo.info}),eo.rows.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"space-y-1",children:eo.rows.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,a.jsx)("span",{className:"text-(--mk-text-2)",children:e.label}),(0,a.jsxs)("span",{className:"font-medium text-(--mk-text)",children:[e.count," segments"]})]},`${e.type}-${e.label}`))}),(0,a.jsxs)("div",{className:"pt-1 border-t border-(--mk-card-border) flex items-center justify-between text-xs",children:[(0,a.jsx)("span",{className:"text-(--mk-text-3)",children:"Total"}),(0,a.jsxs)("span",{className:"font-semibold text-(--mk-text)",children:[eo.total||0," segments"]})]})]})]})]}),ef&&(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-(--mk-text)",children:"Custom Sub-Plate Assignments"}),(0,a.jsx)(m.$n,{size:"sm",variant:"secondary",onClick:()=>Z(e=>[...e,f()]),children:"Add Sub-Plate"})]}),(0,a.jsx)("p",{className:"text-xs text-(--mk-text-3)",children:"Submitting in custom mode creates the parent task and all listed sub-plates atomically in a single request."}),V.map((e,t)=>(0,a.jsxs)("div",{className:"rounded-lg border border-(--mk-card-border) p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("p",{className:"text-xs font-medium text-(--mk-text-3)",children:["Sub-Plate ",t+1]}),V.length>1&&(0,a.jsx)(m.$n,{size:"sm",variant:"danger",onClick:()=>{ek(e.id),Z(t=>t.filter(t=>t.id!==e.id))},children:"Remove"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:"Name (optional)"}),(0,a.jsx)(m.pd,{className:"mt-2",value:e.name,onChange:t=>eu(e.id,e=>({...e,name:t.target.value})),placeholder:"Segments 0-30 (Alice)"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:"Assigned Users"}),(0,a.jsx)(m.KF,{className:"mt-2",options:ea,value:e.selectedUserIds,onChange:t=>eu(e.id,e=>({...e,selectedUserIds:t})),placeholder:ea.length>0?"Select users":"No members available",disabled:0===ea.length})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:"Assigned Groups"}),(0,a.jsx)(m.KF,{className:"mt-2",options:n,value:e.assignedGroups,onChange:t=>eu(e.id,e=>({...e,assignedGroups:t})),placeholder:n.length>0?"Select groups":"No groups available",disabled:0===n.length}),(0,a.jsx)("p",{className:"mt-1 text-xs text-(--mk-text-3)",children:"At least one user or group is required."})]}),"segment_wise"===Q?(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:["Segment Slice
10s ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("p",{className:"mt-1 text-xs text-(--mk-text-3)",children:["Range: 0 to ",Math.max(0,ec-1)," ","(end is exclusive, max ",ec,")"]}),(0,a.jsxs)("div",{className:"mt-2 space-y-2",children:[e.slices.map((t,s)=>(0,a.jsxs)("div",{className:"flex gap-2 items-end",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("label",{className:"text-xs text-(--mk-text-3) block mb-1",children:"Start"}),(0,a.jsx)(m.pd,{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:eg(e.id,s,"start",t.start),onFocus:e=>e.currentTarget.select(),onClick:e=>e.currentTarget.select(),onChange:t=>{let a=t.target.value.replace(/\D+/g,"");if(eb(e.id,s,"start",a),""===a)return;let r=Number.parseInt(a,10);eu(e.id,e=>({...e,slices:e.slices.map((e,t)=>t!==s?e:{...e,start:r})}))},onBlur:a=>{let r=eg(e.id,s,"start",t.start),l=Math.max(0,ec-1);eu(e.id,e=>({...e,slices:e.slices.map((e,t)=>{if(t!==s)return e;let a=j(r,e.start,0,l),i=Math.max(1,ec);return{...e,start:a,end:e.end<=a?Math.min(i,a+1):Math.min(e.end,i)}})})),eh(e.id,s,"start")},placeholder:"0"})]}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("label",{className:"text-xs text-(--mk-text-3) block mb-1",children:"End"}),(0,a.jsx)(m.pd,{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:eg(e.id,s,"end",t.end),onFocus:e=>e.currentTarget.select(),onClick:e=>e.currentTarget.select(),onChange:t=>{let a=t.target.value.replace(/\D+/g,"");if(eb(e.id,s,"end",a),""===a)return;let r=Number.parseInt(a,10);eu(e.id,e=>({...e,slices:e.slices.map((e,t)=>t===s?{...e,end:r}:e)}))},onBlur:a=>{let r=eg(e.id,s,"end",t.end),l=Math.max(1,ec),i=Math.min(t.start+1,l);eu(e.id,e=>({...e,slices:e.slices.map((e,t)=>t===s?{...e,end:j(r,e.end,i,l)}:e)})),eh(e.id,s,"end")},placeholder:"30"})]}),(0,a.jsx)(m.$n,{size:"sm",variant:"secondary",onClick:()=>{ek(e.id),eu(e.id,e=>({...e,slices:e.slices.filter((e,t)=>t!==s)}))},className:"text-red-600 hover:text-red-700",children:"Remove"})]},s)),(0,a.jsx)(m.$n,{size:"sm",variant:"secondary",onClick:()=>eu(e.id,e=>{let t=e.slices.length>0?e.slices[e.slices.length-1].end:0,s=Math.max(1,ec);return t>=s?e:{...e,slices:[...e.slices,{start:Math.min(t,Math.max(0,ec-1)),end:Math.min(t+30,s)}]}}),disabled:ec<=0||e.slices.length>0&&e.slices[e.slices.length-1].end>=ec,children:"+ Add Slice"})]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wide",children:["Columns ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)(m.KF,{className:"mt-2",options:ed,value:e.selectedColumns,onChange:t=>eu(e.id,e=>({...e,selectedColumns:t})),placeholder:ed.length>0?"Select columns to verify":"No columns available. Select a data plate first.",disabled:0===ed.length})]})]},e.id))]}),J&&(0,a.jsxs)("div",{className:"rounded-xl border border-red-500/25 bg-red-500/8 px-3.5 py-3 text-sm text-red-500 flex items-start gap-2",children:[(0,a.jsx)(i.A,{size:15,className:"mt-0.5 shrink-0"}),J]})]}),(0,a.jsxs)("div",{className:"px-5 py-4 border-t border-(--mk-divider) bg-(--mk-surface) flex justify-end gap-3",children:[(0,a.jsx)(m.$n,{variant:"secondary",onClick:d,disabled:t,children:"Cancel"}),(0,a.jsx)(m.$n,{onClick:()=>{ee("");let e=C.trim();if(!e)return;let t=F?new Date(F).toISOString():null;if("edit"===s){if(!l?.task_id)return;c({collection_id:o,task_id:l.task_id,title:e,description:A.trim(),priority:M,due_date:t,assigned_users:I,assigned_groups:q});return}if("general"===O)return void c({kind:"general",params:{collection_id:o,title:e,description:A.trim(),priority:M,due_date:t,assigned_users:I,assigned_groups:q}});if(!R)return void ee("Please select a data plate.");if("auto"===D)return 0===I.length&&0===q.length?void ee("Select at least one user or group."):void c({kind:"verification_auto",params:{collection_id:o,plate_id:R,mode:Q,title:e,description:A.trim(),priority:M,due_date:t,assigned_users:I,assigned_groups:q,verification_mode:B}});if(0===V.length)return void ee("Add at least one sub-plate.");let a=[];for(let e=0;e<V.length;e+=1){let t=V[e];if(0===t.selectedUserIds.length&&0===t.assignedGroups.length)return void ee(`Sub-plate ${e+1}: select at least one user or group.`);let s={name:t.name.trim()||void 0,mode:Q,assigned_users:t.selectedUserIds,assigned_groups:t.assignedGroups};if("segment_wise"===Q){if(ec<=0)return void ee("Selected data plate has no segments to assign.");if(0===t.slices.length)return void ee(`Sub-plate ${e+1}: add at least one segment slice.`);for(let s=0;s<t.slices.length;s+=1){let a=t.slices[s];if(a.start<0||a.end>ec||a.start>=ec)return void ee(`Sub-plate ${e+1}, slice ${s+1}: slice must be within 0-${ec}.`);if(a.start>=a.end)return void ee(`Sub-plate ${e+1}, slice ${s+1}: start must be less than end.`);
10if(s>0&&a.start<t.slices[s-1].end)return void ee(`Sub-plate ${e+1}: slices cannot overlap.`)}a.push({...s,slices:t.slices.map(e=>({start:e.start,end:e.end})),verification_mode:B})}else{if(0===t.selectedColumns.length)return void ee(`Sub-plate ${e+1}: select at least one column.`);a.push({...s,columns:t.selectedColumns,verification_mode:B})}}c({kind:"verification_custom",params:{collection_id:o,title:e,description:A.trim(),priority:M,due_date:t,task_type:"data_plate_verification",verification_config:{plate_id:R,sub_plate_type:Q},sub_plates:a}})},loading:t,disabled:!C.trim(),children:"create"===s?"Create Task":"Save Changes"})]})]})}):null},_={low:"Low",medium:"Medium",high:"High"},w={low:"bg-(--mk-surface) text-(--mk-text-2) border border-(--mk-card-border) dark:text-(--mk-text-3)",medium:"bg-purple-100 text-purple-800 border border-purple-200 dark:bg-purple-950/30 dark:text-purple-300 dark:border-purple-800/40",high:"bg-red-100 text-red-800 border border-red-200 dark:bg-red-950/30 dark:text-red-300 dark:border-red-800/40"},S=({priority:e})=>(0,a.jsx)(m.Ex,{className:w[e],children:_[e]}),C={pending:"Pending",in_progress:"In Progress",completed:"Completed",canceled:"Canceled"},$={pending:"bg-amber-100 text-amber-800 border border-amber-200 dark:bg-amber-950/30 dark:text-amber-300 dark:border-amber-800/40",in_progress:"bg-blue-100 text-blue-800 border border-blue-200 dark:bg-blue-950/30 dark:text-blue-300 dark:border-blue-800/40",completed:"bg-green-100 text-green-800 border border-green-200 dark:bg-green-950/30 dark:text-green-300 dark:border-green-800/40",canceled:"bg-(--mk-surface) text-(--mk-text-2) border border-(--mk-card-border) dark:text-(--mk-text-3)"},A=({status:e})=>(0,a.jsx)(m.Ex,{className:$[e],children:C[e]});var T=s(98500),M=s.n(T),P=s(98307),F=s(51914),z=s(61878),I=s(76527),E=s(66088),q=s(49387),K=s(72140),O=s(22164),L=s(96035),D=s(91337);let G=[{value:"all",label:"All Status"},{value:"pending",label:"Pending"},{value:"in_progress",label:"In Progress"},{value:"completed",label:"Completed"},{value:"canceled",label:"Canceled"}],Q=[{value:"all",label:"All Priority"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}],U=[{value:"pending",label:"Pending"},{value:"in_progress",label:"In Progress"},{value:"completed",label:"Completed"},{value:"canceled",label:"Canceled"}],B=e=>{if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?"—":new Intl.DateTimeFormat("en-US",{month:"short",day:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(t)},H=({collectionId:e,isAdmin:t})=>{let s=(0,o.jE)(),[l,n]=(0,r.useState)("all"),[d,c]=(0,r.useState)("all"),[b,h]=(0,r.useState)("all"),[k,v]=(0,r.useState)(!1),[f,j]=(0,r.useState)(""),[y,_]=(0,r.useState)(null),[w,C]=(0,r.useState)(!1),[$,T]=(0,r.useState)(!1),[M,q]=(0,r.useState)(!1),[K,O]=(0,r.useState)({isOpen:!1,type:"delete",taskId:""}),L=(0,r.useMemo)(()=>({collection_id:e,..."all"!==d&&{status:d},..."all"===l&&"all"!==b&&{priority:b},..."all"===l&&k&&{overdue_only:!0},page_size:100}),[e,k,b,l,d]),{data:U,isLoading:B,isFetching:H}=(0,p.I)(L,l),Z=(0,r.useMemo)(()=>{let e=U?.data?.tasks||[],t=new Set(e.map(e=>e.task_id));if(e=e.filter(e=>!e.parent_task_id||!t.has(e.parent_task_id)),!f.trim())return e;let s=f.trim().toLowerCase();return e.filter(e=>e.title.toLowerCase().includes(s)||(e.description||"").toLowerCase().includes(s))},[U?.data?.tasks,f]),Y=(0,r.useMemo)(()=>{if(!Z.length)return null;let e=new Set;return Z.forEach(t=>{e.add(t.task_id),(t.child_tasks||[]).forEach(t=>{e.add(t.task_id)})}),y&&e.has(y)?y:null},[y,Z]),X=(0,r.useMemo)(()=>Y?{collection_id:e,task_id:Y}:null,[Y,e]),{data:J,isLoading:ee,isFetching:et}=(0,p.mS)(X),{data:es,isLoading:ea}=(0,p.W6)(Y?{collection_id:e,task_id:Y,page_size:50}:null),er=J?.data?.task||null,{data:el}=(0,g.Sc)(e),ei=(0,r.useMemo)(()=>(el?.data?.groups||[]).map(e=>({value:e.display_name,label:e.display_name})),[el?.data?.groups]),en=(0,p.vj)(),ed=(0,p.EZ)(),ec=(0,p.G5)(),eo=(0,p.f_)(),em=(0,p.bq)(),ex=(0,p.P4)(),eu=(0,p.Sj)(),ep=(e,t)=>"string"==typeof e&&e.trim()?e:e&&"object"==typeof e&&"string"==typeof e.message&&e.message.trim()?e.message:t,eg=async()=>{await s.invalidateQueries({queryKey:p.HI.listBase(e,"all")}),await s.invalidateQueries({queryKey:p.HI.listBase(e,"my")}
10)},eb=async e=>{if("kind"in e){if("general"===e.kind)return void en.mutate(e.params,{onSuccess:e=>{e.success&&e.data?.task?.task_id&&(_(e.data.task.task_id),C(!1))}});if("verification_auto"===e.kind){q(!0);try{let t=await (0,x.sT)(e.params);if(!t.success)return void u.toast.error(ep(t.error,"Failed to create verification task. Please try again."));await eg();let s=t.data?.parent_task?.task_id;s&&_(s),C(!1),u.toast.success("Verification task created")}catch(e){u.toast.error(ep(e,"Failed to create verification task. Please try again."))}finally{q(!1)}return}q(!0);try{let t=await en.mutateAsync(e.params);if(!t.success||!t.data?.task?.task_id)return void u.toast.error(ep(t.error,"Failed to create custom verification task."));let s=t.data.task.task_id;await eg(),_(s),C(!1)}catch(e){u.toast.error(ep(e,"Failed to create custom verification task. Please try again."))}finally{q(!1)}}},eh=async t=>{if(!Y)return!1;try{return!!(await ec.mutateAsync({collection_id:e,task_id:Y,status:t})).success}catch(t){let e=t instanceof Error&&t.message.trim()?t.message:"Failed to update task status. Please try again.";return u.toast.error("Status update failed",{description:e}),!1}},ek=async t=>{if(!Y)return!1;try{return!!(await eo.mutateAsync({collection_id:e,task_id:Y,progress:Math.max(0,Math.min(100,t))})).success}catch{return!1}},ev=async t=>{if(!Y||!t.trim())return!1;try{return!!(await em.mutateAsync({collection_id:e,task_id:Y,content:t.trim()})).success}catch{return!1}};return(0,r.useMemo)(()=>{let e=J?.data?.recent_activity||[],t=es?.data?.activity||[];return t.length>0?t:e},[es?.data?.activity,J?.data?.recent_activity]),(0,a.jsxs)("div",{className:"space-y-4 sm:space-y-6",children:[(0,a.jsxs)("div",{className:"bg-(--mk-bg) rounded-xl border border-(--mk-card-border) shadow-sm overflow-visible",children:[(0,a.jsx)("div",{className:"px-4 sm:px-6 py-4 sm:py-5 border-b border-(--mk-card-border) bg-linear-to-br from-(--mk-green-bg) to-transparent",children:(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-start sm:items-center gap-3",children:[(0,a.jsx)("div",{className:"w-11 h-11 rounded-xl bg-(--mk-green) flex items-center justify-center shadow-sm",children:(0,a.jsx)(P.A,{size:20,className:"text-(--mk-on-green)"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-lg sm:text-xl font-bold text-(--mk-text)",children:"Collection Tasks"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-(--mk-text-3) mt-0.5",children:"Plan, assign, and track work for this collection."})]})]}),t&&(0,a.jsx)(m.$n,{size:"sm",onClick:()=>C(!0),leftIcon:(0,a.jsx)(F.A,{size:14}),children:"New Task"})]})}),(0,a.jsxs)("div",{className:"p-4 sm:p-6 space-y-4",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-3",children:[t&&(0,a.jsxs)("div",{className:"lg:col-span-2",children:[(0,a.jsx)("label",{className:"text-xs text-(--mk-text-3)",children:"Scope"}),(0,a.jsx)(m.l6,{className:"mt-1",options:[{value:"all",label:"All Tasks"},{value:"my",label:"My Tasks"}],value:l,onChange:e=>n(e)})]}),(0,a.jsxs)("div",{className:(0,D.cn)("lg:col-span-2",!t&&"lg:col-span-3"),children:[(0,a.jsx)("label",{className:"text-xs text-(--mk-text-3)",children:"Status"}),(0,a.jsx)(m.l6,{className:"mt-1",options:G,value:d,onChange:e=>c(e)})]}),(0,a.jsxs)("div",{className:(0,D.cn)("lg:col-span-2",!t&&"lg:col-span-3"),children:[(0,a.jsx)("label",{className:"text-xs text-(--mk-text-3)",children:"Priority"}),(0,a.jsx)(m.l6,{className:"mt-1",options:Q,value:b,onChange:e=>h(e),disabled:"my"===l})]}),(0,a.jsxs)("div",{className:(0,D.cn)("lg:col-span-4",!t&&"lg:col-span-4"),children:[(0,a.jsx)("label",{className:"text-xs text-(--mk-text-3)",children:"Search"}),(0,a.jsxs)("div",{className:"mt-1 relative",children:[(0,a.jsx)(z.A,{size:14,className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-(--mk-text-3) pointer-events-none"}),(0,a.jsx)("input",{type:"text",placeholder:"Search tasks",value:f,onChange:e=>j(e.target.value),className:"w-full h-11 pl-9 pr-3.5 bg-(--mk-surface) border border-(--mk-card-border) rounded-xl text-sm text-(--mk-text) placeholder:text-(--mk-text-3) focus:outline-none focus:border-(--mk-green-border-strong) hover:border-(--mk-green-border) transition-colors"})]})]}),(0,a.jsxs)("div",{className:(0,D.cn)("lg:col-span-2",!t&&"lg:col-span-2"),children:[(0,a.jsx)("label",{className:"text-xs text-(--mk-text-3) opacity-0",children:"Toggle"}),"my"===l?(0,a.jsxs)("div",{className:"w-full mt-1 h-10.5 px-3.5 rounded-lg border border-(--mk-card-border) bg-(--mk-surface)/50 text-(--mk-text-3) text-sm inline-flex items-center justify-center gap-2",children:[(0,a.jsx)(I.A,{size:14}),(0,a.jsx)("span",{children:"Overdue"})]}):(0,a.jsxs)("button",{type:"button","aria-pressed":k,onClick:()=>v(e=>!e),className:(0,D.cn)("w-full mt-1 h-10.5 px-3.5 rounded-lg border inline-flex items-center justify-between gap-2 text-sm font-medium transition-all focus:outline-none focus:ring-2 focus:ring-(--mk-green)/20",k?"bg-(--mk-green-bg) border-(--mk-green-border)/40 text-(--mk-green-text) shadow-sm":"bg-(--mk-card) border-(--mk-card-border) text-(--mk-text-2) hover:border-(--mk-card-border)"),children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-2 truncate",children:[(0,a.jsx)(I.A,{size:14}),(0,a.jsx)("span",{className:"truncate",children:"Overdue"})]}),k?(0,a.jsx)("span",{className:"inline-flex items-center rounded-full bg-(--mk-green)/15 px-1.5 py-0.5 text-[10px] font-semibold leading-none",children:"ON"}):null]})]})]}),U&&!U.success&&(0,a.jsx)("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-800/40 rounded-lg px-3 py-2",children:("string"==typeof U.error?U.error:U.error?.message)||"Failed to load tasks."}),H&&Z.length>0&&(0,a.jsx)("div",{className:"rounded-lg border border-(--mk-green-border)/20 bg-(--mk-green-bg) px-3 py-2",children:(0,a.jsx)("p",{className:"text-xs text-(--mk-green-text) font-medium",children:"Updating tasks..."})}),(0,a.jsx)("div",{className:"space-y-3",children:B?(0,a.jsx)(W,{}):0===Z.length?(0,a.jsxs)("div",{className:"rounded-xl border border-dashed border-(--mk-card-border) p-8 text-center",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-(--mk-text)",children:"No tasks foun
10d"}),(0,a.jsx)("p",{className:"text-xs text-(--mk-text-3) mt-1",children:"Try adjusting filters or create a new task."})]}):Z.map(e=>{let s="data_plate_verification"===e.task_type&&Array.isArray(e.child_tasks)&&e.child_tasks.length>0,r=e.task_id===Y;return(0,a.jsxs)("div",{className:"space-y-0",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>_(r?null:e.task_id),className:(0,D.cn)("w-full text-left p-4 rounded-t-xl border transition-all",r?"border-(--mk-green-border) bg-(--mk-green-bg) shadow-sm":"border-(--mk-card-border) bg-(--mk-bg) hover:border-(--mk-card-border)"),children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("p",{className:"text-sm sm:text-base font-semibold text-(--mk-text) line-clamp-1",children:e.title}),(0,a.jsx)(A,{status:e.status})]}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-(--mk-text-3) mt-1 line-clamp-1",children:e.description||"No description"}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[(0,a.jsx)(S,{priority:e.priority}),"data_plate_verification"===e.task_type&&(0,a.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full bg-blue-100 text-blue-700 border border-blue-200 dark:bg-blue-950/30 dark:text-blue-300 dark:border-blue-800/40",children:"Verification"}),s&&(0,a.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full bg-(--mk-surface) text-(--mk-text-2) border border-(--mk-card-border)",children:[e.child_tasks?.length," child tasks"]}),e.is_overdue&&(0,a.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full bg-red-100 text-red-700 border border-red-200 dark:bg-red-950/30 dark:text-red-300 dark:border-red-800/40 inline-flex items-center gap-1",children:[(0,a.jsx)(i.A,{size:10}),"Overdue"]})]})]}),(0,a.jsx)("div",{className:"shrink-0",children:(0,a.jsx)(E.A,{size:20,className:(0,D.cn)("text-(--mk-text-3) transition-transform duration-200",r&&"rotate-180 text-(--mk-green-text)")})})]}),(0,a.jsxs)("div",{className:"mt-3 flex items-center justify-between",children:[(0,a.jsx)("div",{className:"h-2 rounded-full bg-(--mk-divider) overflow-hidden flex-1 mr-3",children:(0,a.jsx)("div",{className:"h-full bg-(--mk-green) transition-all duration-300",style:{width:`${Math.max(0,Math.min(100,e.progress||0))}%`}})}),(0,a.jsxs)("span",{className:"text-xs font-medium text-(--mk-text-2) whitespace-nowrap",children:[e.progress||0,"%"]})]})]}),r&&er&&(0,a.jsx)("div",{className:"border-t border-l border-r border-(--mk-green-border) bg-(--mk-green-bg) rounded-b-xl overflow-hidden",children:(0,a.jsx)(R,{task:er,isAdmin:t,timeline:es?.data?.activity||[],isActivityLoading:ea,onOpenEdit:()=>T(!0),onStatusUpdate:eh,onProgressUpdate:ek,onAddComment:ev,onCancelTask:()=>O({isOpen:!0,type:"cancel",taskId:er.task_id}),onDeleteTask:()=>O({isOpen:!0,type:"delete",taskId:er.task_id}),isUpdatingStatus:ec.isPending,isUpdatingProgress:eo.isPending,isAddingComment:em.isPending,isCanceling:ex.isPending,isDeleting:eu.isPending})})]},e.task_id)})})]})]}),w&&(0,a.jsx)(N,{isOpen:w,isSubmitting:en.isPending||M,mode:"create",collectionId:e,groupOptions:ei,onClose:()=>C(!1),onSubmit:eb}),$&&er&&(0,a.jsx)(N,{isOpen:$,isSubmitting:ed.isPending,mode:"edit",collectionId:e,initialTask:er,groupOptions:ei,onClose:()=>T(!1),onSubmit:e=>{"kind"in e||ed.mutate(e,{onSuccess:e=>{e.success&&T(!1)}})}}),K.isOpen&&(0,a.jsx)(V,{isOpen:K.isOpen,type:K.type,isLoading:"delete"===K.type?eu.isPending:ex.isPending,onConfirm:()=>{K.taskId&&("delete"===K.type?eu.mutate({collection_id:e,task_id:K.taskId},{onSuccess:()=>{_(null),O({isOpen:!1,type:"delete",taskId:""})}}):"cancel"===K.type&&ex.mutate({collection_id:e,task_id:K.taskId},{onSuccess:()=>{O({isOpen:!1,type:"delete",taskId:""})}}))},onCancel:()=>O({isOpen:!1,type:"delete",taskId:""})})]})},R=({task:e,isAdmin:t,timeline:s,isActivityLoading:l,onOpenEdit:n,onStatusUpdate:d,onProgressUpdate:c,onAddComment:o,onCancelTask:x,onDeleteTask:u,isUpdatingStatus:p,isUpdatingProgress:g,isAddingComment:b,isCanceling:h,isDeleting:k})=>{let[v,f]=(0,r.useState)(e.status),[j,y]=(0,r.useState)(e.progress||0),[N,_]=(0,r.useState)(""),w="data_plate_verification"===e.task_type,S=async()=>{await o(N)&&_("")};return(0,a.jsxs)("div",{className:"bg-(--mk-modal-bg) overflow-hidden",children:[(0,a.jsxs)("div",{className:"px-4 sm:px-5 py-3 border-b border-(--mk-card-border) flex flex-wrap items-center justify-between gap-3",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wider",children:"Task Details"}),t&&(0,a.jsxs)("button",{onClick:n,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold rounded-lg bg-(--mk-surface) border border-(--mk-card-border-strong) text-(--mk-text-2) hover:bg-(--mk-surface-2) hover:text-(--mk-text) transition-colors",children:[(0,a.jsx)(q.A,{size:11}),"Edit"]})]}),(0,a.jsxs)("div",{className:"p-4 sm:p-5 space-y-5",children:[e.is_overdue&&(0,a.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-red-200 dark:border-red-800/40 bg-red-50 dark:bg-red-950/20 px-3 py-2.5 text-sm text-red-700 dark:text-red-300",children:[(0,a.jsx)(i.A,{size:15,className:"mt-0.5 shrink-0"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-semibold",children:"Overdue"}),"completed"===e.status&&e.completed_at?` — completed on ${B(e.completed_at)}, after the due date.`:e.due_date?` — due date passed on ${B(e.due_date)}.`:"."]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-(--mk-text-3)",children:"Due Date"}),(0,a.jsxs)("p",{className:(0,D.cn)("text-sm mt-1 inline-flex items-center gap-1",e.is_overdue?"text-red-600 dark:text-red-400 font-medium":"text-(--mk-text)"),children:[(0,a.jsx)(K.A,{size:13,className:"shrink-0"}),B(e.due_date)||"—"]}
10)]}),e.completed_at&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-(--mk-text-3)",children:"Completed At"}),(0,a.jsx)("p",{className:"text-sm text-(--mk-text) mt-1",children:B(e.completed_at)})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-(--mk-text-3)",children:"Assignees"}),(0,a.jsx)("p",{className:"text-sm text-(--mk-text) mt-1 wrap-break-word",children:(e.assigned_user_emails||[]).join(", ")||"None"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-(--mk-text-3)",children:"Groups"}),(0,a.jsx)("p",{className:"text-sm text-(--mk-text) mt-1 wrap-break-word",children:(e.assigned_groups||[]).join(", ")||"None"})]})]}),(0,a.jsxs)("div",{className:"bg-(--mk-card) border border-(--mk-card-border) rounded-xl p-4 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-end gap-2",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("label",{className:"text-xs font-medium text-(--mk-text-3) block mb-1",children:"Status"}),(0,a.jsx)(m.l6,{options:U,value:v,onChange:e=>f(e),disabled:"canceled"===e.status||w})]}),(0,a.jsx)(m.$n,{size:"sm",onClick:()=>void d(v),loading:p,disabled:"canceled"===e.status||v===e.status||w,children:"Update"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("label",{className:"text-xs font-medium text-(--mk-text-3)",children:"Progress %"}),(0,a.jsxs)("span",{className:"text-xs font-bold tabular-nums text-(--mk-text)",children:[j,"%"]})]}),(0,a.jsx)("div",{className:"relative h-1.5 rounded-full bg-(--mk-divider) overflow-hidden",children:(0,a.jsx)("div",{className:"absolute inset-y-0 left-0 rounded-full bg-(--mk-green) transition-all duration-300",style:{width:`${Math.max(0,Math.min(100,j))}%`}})}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"number",min:0,max:100,value:j,onChange:e=>y(Number(e.target.value||0)),disabled:"in_progress"!==e.status||w,className:"w-20 px-2.5 py-1.5 rounded-lg border border-(--mk-card-border) bg-(--mk-bg) text-(--mk-text) text-sm text-center focus:outline-none focus:border-(--mk-green)/60 disabled:opacity-40 disabled:cursor-not-allowed tabular-nums"}),(0,a.jsx)(m.$n,{size:"sm",onClick:()=>void c(j),loading:g,disabled:"in_progress"!==e.status||j===e.progress||j<0||j>100||w,children:"Save"})]})]})]}),w&&(0,a.jsx)("div",{className:"rounded-lg border border-blue-200 dark:border-blue-800/40 bg-blue-50 dark:bg-blue-950/20 px-3 py-2 text-xs text-blue-700 dark:text-blue-300",children:"Verification task progress is updated automatically as assignees verify segments or cells."}),w&&e.child_tasks&&e.child_tasks.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("p",{className:"text-xs font-semibold text-(--mk-text)",children:["Child Tasks (",e.child_tasks.length,")"]}),(0,a.jsx)("div",{className:"space-y-2 rounded-lg border border-(--mk-card-border) p-3",children:e.child_tasks.map(t=>{let s=t.sub_plate_id?`/data-plates/${t.sub_plate_id}?collection=${e.collection_id}`:null,r=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-(--mk-text) truncate",children:t.title}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[(0,a.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-(--mk-divider) text-(--mk-text-2)",children:t.status}),(0,a.jsxs)("span",{className:"text-[10px] text-(--mk-text-3)",children:[t.progress||0,"% complete"]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,a.jsx)("div",{className:"w-16",children:(0,a.jsx)("div",{className:"h-1 rounded-full bg-(--mk-divider) overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-(--mk-green) transition-all",style:{width:`${Math.max(0,Math.min(100,t.progress||0))}%`}})})}),s&&(0,a.jsxs)("span",{className:"text-[11px] font-medium text-(--mk-green-text) inline-flex items-center gap-0.5 whitespace-nowrap",children:["Open sub-plate",(0,a.jsx)(O.A,{size:10})]})]})]});return s?(0,a.jsx)(M(),{href:s,className:"flex items-start justify-between gap-2 p-2 rounded-lg bg-(--mk-surface)/50 border border-(--mk-divider) hover:border-(--mk-green-border)/40 hover:bg-(--mk-green-bg) transition-colors",children:r},t.task_id):(0,a.jsx)("div",{className:"flex items-start justify-between gap-2 p-2 rounded-lg bg-(--mk-surface)/50 border border-(--mk-divider)",children:r},t.task_id)})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold text-(--mk-text-3) uppercase tracking-wider mb-2",children:"Add Comment"}),(0,a.jsxs)("div",{className:"rounded-xl border border-(--mk-card-border) bg-(--mk-card) overflow-hidden focu
10s-within:border-(--mk-green)/50 transition-colors",children:[(0,a.jsx)(m.TM,{rows:3,value:N,onChange:e=>_(e.target.value),placeholder:"Write an update...",className:"border-0 rounded-none bg-transparent focus:ring-0 resize-none"}),(0,a.jsx)("div",{className:"flex justify-end items-center gap-2 px-3 py-2 border-t border-(--mk-divider) bg-(--mk-surface)/60",children:(0,a.jsx)(m.$n,{size:"sm",onClick:()=>void S(),loading:b,leftIcon:(0,a.jsx)(L.A,{size:13}),disabled:!N.trim(),children:"Post Comment"})})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-(--mk-text-3) uppercase tracking-wider",children:"Activity"}),(0,a.jsx)("div",{className:"rounded-xl border border-(--mk-card-border) bg-(--mk-card) max-h-64 overflow-y-auto",style:{scrollbarWidth:"thin"},children:l?(0,a.jsx)("p",{className:"p-4 text-sm text-(--mk-text-3)",children:"Loading activity..."}):0===s.length?(0,a.jsx)("p",{className:"p-4 text-sm text-(--mk-text-3)",children:"No activity yet."}):(0,a.jsx)("div",{className:"divide-y divide-(--mk-divider)",children:s.map(e=>(0,a.jsxs)("div",{className:"px-4 py-3 flex gap-3",children:[(0,a.jsx)("div",{className:`mt-1.5 w-2 h-2 rounded-full shrink-0 ${"comment"===e.type?"bg-(--mk-green)":"status_change"===e.type?"bg-blue-400":"progress_update"===e.type?"bg-purple-400":"bg-(--mk-text-3)"}`}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wide text-(--mk-text-3)",children:e.type.replaceAll("_"," ")}),(0,a.jsx)("span",{className:"text-[10px] text-(--mk-text-3)",children:B(e.created_at)})]}),(0,a.jsx)("p",{className:"text-sm text-(--mk-text) mt-1 leading-relaxed",children:e.content}),(0,a.jsx)("p",{className:"text-[10px] text-(--mk-text-3) mt-1",children:e.user_email||"System"})]})]},e.comment_id))})})]}),t&&(0,a.jsxs)("div",{className:"flex justify-end gap-2 flex-wrap pt-2 border-t border-(--mk-divider)",children:["canceled"!==e.status&&(0,a.jsx)(m.$n,{variant:"outline",size:"sm",onClick:x,loading:h,className:"text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-800/40 hover:bg-amber-50 dark:hover:bg-amber-950/20",children:"Cancel Task"}),(0,a.jsx)(m.$n,{variant:"danger",size:"sm",onClick:u,loading:k,children:"Delete Task"})]})]})]})},W=()=>(0,a.jsx)("div",{className:"space-y-3",children:Array.from({length:4}).map((e,t)=>(0,a.jsx)("div",{className:"rounded-xl border border-(--mk-card-border) bg-(--mk-bg) p-4",children:(0,a.jsxs)("div",{className:"animate-pulse space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("div",{className:"h-4 w-2/3 rounded bg-(--mk-divider)"}),(0,a.jsx)("div",{className:"h-5 w-20 rounded-full bg-(--mk-divider)"})]}),(0,a.jsx)("div",{className:"h-3.5 w-full rounded bg-(--mk-surface)/70"}),(0,a.jsx)("div",{className:"h-3.5 w-5/6 rounded bg-(--mk-surface)/70"}),(0,a.jsx)("div",{className:"h-1.5 w-full rounded bg-(--mk-divider)"})]})},`task-list-skeleton-${t}`))}),V=({isOpen:e,type:t,isLoading:s,onConfirm:r,onCancel:l})=>{if(!e)return null;let i="delete"===t;return(0,a.jsx)("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-sm bg-(--mk-bg) rounded-xl border border-(--mk-card-border) shadow-2xl overflow-hidden",children:[(0,a.jsx)("div",{className:"px-5 py-4 border-b border-(--mk-card-border)",children:(0,a.jsx)("h3",{className:"text-lg font-semibold text-(--mk-text)",children:i?"Delete Task":"Cancel Task"})}),(0,a.jsx)("div",{className:"px-5 py-4",children:(0,a.jsx)("p",{className:"text-sm text-(--mk-text-3)",children:i?"Are you sure you want to delete this task? This action cannot be undone and will remove all associated sub-plates and assignments.":"Are you sure you want to cancel this task? It will be marked as canceled but can still be edited or deleted later."})}),(0,a.jsxs)("div",{className:"px-5 py-4 border-t border-(--mk-card-border) flex justify-end gap-3",children:[(0,a.jsx)(m.$n,{variant:"secondary",onClick:l,disabled:s,size:"sm",children:"Keep Task"}),(0,a.jsxs)(m.$n,{variant:"danger",onClick:r,loading:s,size:"sm",children:[i?"Delete":"Cancel"," Task"]})]})]})})};function Z(){let e=(0,l.useParams)(),{user:t}=(0,n.A)(),{selectedCollectionId:s,setSelectedCollectionId:o}=(0,d.G)(),{data:m}=(0,c.X)(),x=e?.collection_id||s||"";(0,r.useEffect)(()=>{x&&o(x)},[x,o]);
10let u=x?m?.find(e=>e.collection_id===x):null,p={collection_id:x,collection_name:u?.collection_name||x||"Collection",ownership:u?.ownership,my_role:u?.my_role};if(!t)return(0,a.jsx)("div",{className:"flex items-center justify-center h-full bg-(--mk-bg) px-4",children:(0,a.jsxs)("div",{className:"text-center max-w-sm",children:[(0,a.jsx)(i.A,{size:48,className:"mx-auto text-(--mk-text-3) mb-4"}),(0,a.jsx)("p",{className:"text-(--mk-text-3)",children:"Please log in to access collection tasks."})]})});let g="owned"===p.ownership||"admin"===p.my_role;return(0,a.jsx)("div",{className:"h-full overflow-y-auto bg-(--mk-bg)",children:(0,a.jsxs)("div",{className:"max-w-6xl mx-auto px-3 sm:px-6 md:px-8 py-3 sm:py-6 md:py-8 space-y-3 sm:space-y-5",children:[(0,a.jsx)("div",{className:"flex items-center gap-3 bg-(--mk-modal-bg) border border-(--mk-card-border-strong) rounded-xl px-3 sm:px-4 py-2.5 sm:py-3",children:(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm sm:text-base font-semibold text-(--mk-text) truncate",children:"Collection Tasks"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-(--mk-text-3) truncate",children:p.collection_name})]})}),(0,a.jsx)(H,{collectionId:x,isAdmin:g})]})})}}},e=>{e.O(0,[9204,9135,120,748,8409,6609,8143,6708,8500,6876,1008,426,1186,8441,8928,7358],()=>e(e.s=35547)),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.